@eigenpal/docx-js-editor 0.0.28 → 0.0.29
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/{ClipboardManager-BzgQ-SOi.d.cts → ClipboardManager-t936d0KD.d.mts} +1 -1
- package/dist/{DocumentAgent-B9FUoSVS.d.cts → DocumentAgent-BqA9EJ3F.d.mts} +1 -1
- package/dist/FindReplaceDialog-AQFR4OCT.js +1 -1
- package/dist/FindReplaceDialog-N4J5OB7O.mjs +1 -0
- package/dist/FootnotePropertiesDialog-UFUIHLDW.mjs +1 -0
- package/dist/FootnotePropertiesDialog-YYIZU5U6.js +1 -1
- package/dist/HyperlinkDialog-HGZ2S37Z.js +1 -1
- package/dist/HyperlinkDialog-YQSQFHOP.mjs +1 -0
- package/dist/ImagePositionDialog-DQ4JWS4F.js +1 -1
- package/dist/ImagePositionDialog-HT6J2SHV.mjs +1 -0
- package/dist/ImagePropertiesDialog-3VK2S2AF.mjs +1 -0
- package/dist/ImagePropertiesDialog-GJMGLM6G.js +1 -1
- package/dist/PageSetupDialog-3QCVUNDL.mjs +1 -0
- package/dist/PageSetupDialog-ZZTFPZKJ.js +1 -1
- package/dist/TablePropertiesDialog-FI5E3RCB.mjs +1 -0
- package/dist/TablePropertiesDialog-STZOGHJB.js +1 -1
- package/dist/chunk-2KHL5RSD.js +3 -3
- package/dist/chunk-4VUZBV2S.js +1 -1
- package/dist/chunk-6WPRCJ5A.mjs +1 -0
- package/dist/chunk-7HZRJTOL.mjs +4 -0
- package/dist/chunk-AARNCPWR.js +1 -1
- package/dist/chunk-AZRYS2WF.mjs +2 -0
- package/dist/chunk-BUEMG4NW.js +1 -1
- package/dist/chunk-CQRI4YUS.mjs +26 -0
- package/dist/chunk-CTYOM6BE.js +2 -2
- package/dist/{chunk-PRBTINOW.js → chunk-DLVLK5FT.mjs} +2 -2
- package/dist/chunk-FVUGBRDD.js +1 -1
- package/dist/chunk-G72SXG7G.js +258 -0
- package/dist/chunk-H5NTJZO4.js +1 -1
- package/dist/chunk-I6LFWQFR.mjs +59 -0
- package/dist/chunk-IFPN3NT3.js +3 -3
- package/dist/chunk-IRO7KGGC.js +59 -0
- package/dist/chunk-KCUPCJFL.mjs +111 -0
- package/dist/chunk-LYBG4YI7.mjs +1 -0
- package/dist/chunk-M5F4SK3W.mjs +1 -0
- package/dist/chunk-MRWJ3GNH.js +9 -0
- package/dist/chunk-MVCTPHRR.mjs +258 -0
- package/dist/chunk-PB7VMDDP.js +24 -0
- package/dist/chunk-PJVI53AH.js +2 -2
- package/dist/chunk-QAZ4233N.mjs +1 -0
- package/dist/{chunk-OJ7NJK46.cjs → chunk-QQ63M65M.js} +1 -1
- package/dist/chunk-QTSXJRP6.mjs +1 -0
- package/dist/chunk-QVPR2W5S.js +1 -1
- package/dist/chunk-SE5EN2QL.js +1 -1
- package/dist/chunk-TAUMSKRE.mjs +1 -0
- package/dist/{chunk-JO2CKU4O.js → chunk-TDEHAPMZ.mjs} +1 -1
- package/dist/chunk-VHWEKJ35.js +10 -0
- package/dist/chunk-VR6PT4IZ.js +26 -0
- package/dist/chunk-W53SI3XW.mjs +1 -0
- package/dist/chunk-WOHFANC5.mjs +3 -0
- package/dist/chunk-XGL3EGKF.js +7 -7
- package/dist/chunk-XWBCP563.mjs +2 -0
- package/dist/{chunk-TOGKKPIW.js → chunk-YGTSQZRK.mjs} +1 -1
- package/dist/chunk-Z35FA4M4.mjs +10 -0
- package/dist/{clipboard-Cm7udEnb.d.cts → clipboard-BkM7Zvgs.d.mts} +1 -1
- package/dist/{colorResolver-Bu7uJqpw.d.cts → colorResolver-BwI_Uxp3.d.mts} +2 -2
- package/dist/{core-plugins-reexport.d.cts → core-plugins-reexport.d.mts} +4 -4
- package/dist/core-plugins-reexport.js +1 -1
- package/dist/core-plugins-reexport.mjs +1 -0
- package/dist/{core-reexport.d.cts → core-reexport.d.mts} +11 -11
- package/dist/core-reexport.js +1 -1
- package/dist/core-reexport.mjs +1 -0
- package/dist/executor-L2MVKMXO.js +1 -1
- package/dist/executor-XKBCCVNY.mjs +1 -0
- package/dist/{fontLoader-X8ocGzeD.d.cts → fontLoader-DicgJidU.d.mts} +1 -1
- package/dist/{headless-reexport.d.cts → headless-reexport.d.mts} +7 -7
- package/dist/headless-reexport.js +2 -2
- package/dist/headless-reexport.mjs +4 -0
- package/dist/{index.d.cts → index.d.mts} +14 -14
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/index.mjs +155 -0
- package/dist/lib-BCT2DRYI.mjs +1 -0
- package/dist/lib-U35UU4OU.js +1 -1
- package/dist/{mcp-reexport.d.cts → mcp-reexport.d.mts} +2 -2
- package/dist/mcp-reexport.js +9 -9
- package/dist/mcp-reexport.mjs +16 -0
- package/dist/processTemplate-5ZST2Q5L.js +1 -0
- package/dist/{processTemplate-CGIQEJ26.js → processTemplate-LRHXOWMZ.mjs} +1 -1
- package/dist/{react-BgZObIoP.d.ts → react-By80Gfi-.d.ts} +4 -0
- package/dist/{react-D9JDP3cV.d.cts → react-C-pJU0Y4.d.mts} +8 -4
- package/dist/{react.d.cts → react.d.mts} +5 -5
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -0
- package/dist/{registry-Bxb5ZI1z.d.cts → registry-DyIMyB-0.d.mts} +1 -1
- package/dist/selectionRects-6TRAXB7D.js +1 -0
- package/dist/selectionRects-IS7ZAS3A.mjs +1 -0
- package/dist/{types-D03hsi5t.d.cts → types-B3LkfO0u.d.mts} +1 -1
- package/dist/{ui.d.cts → ui.d.mts} +3 -3
- package/dist/ui.js +1 -1
- package/dist/ui.mjs +1 -0
- package/dist/{variableDetector-iGl52A6q.d.cts → variableDetector-CIqTek7A.d.mts} +1 -1
- package/package.json +17 -18
- package/dist/FindReplaceDialog-J3DI3U5I.cjs +0 -1
- package/dist/FootnotePropertiesDialog-DO5DCAW6.cjs +0 -1
- package/dist/HyperlinkDialog-PEPS3C2G.cjs +0 -1
- package/dist/ImagePositionDialog-UYXYHSP4.cjs +0 -1
- package/dist/ImagePropertiesDialog-V6SVKINO.cjs +0 -1
- package/dist/PageSetupDialog-RLMYJ3BA.cjs +0 -1
- package/dist/TablePropertiesDialog-A36OXG3A.cjs +0 -1
- package/dist/chunk-2FYTKTQL.cjs +0 -111
- package/dist/chunk-2VHQ7YOQ.cjs +0 -1
- package/dist/chunk-3YHC2RAO.js +0 -258
- package/dist/chunk-63YB7DGI.js +0 -59
- package/dist/chunk-7OCUAFPO.cjs +0 -258
- package/dist/chunk-HE3SUXOQ.cjs +0 -4
- package/dist/chunk-HRUPO723.js +0 -10
- package/dist/chunk-IA4LPH2A.cjs +0 -1
- package/dist/chunk-JMR5HNJP.cjs +0 -10
- package/dist/chunk-KR32M3S4.cjs +0 -1
- package/dist/chunk-MSV5LTHM.cjs +0 -9
- package/dist/chunk-NLYEW36R.js +0 -26
- package/dist/chunk-NVAQQYBJ.cjs +0 -1
- package/dist/chunk-P7ZF45KZ.cjs +0 -1
- package/dist/chunk-PCJ5ACUV.cjs +0 -1
- package/dist/chunk-PVV7DV3L.cjs +0 -59
- package/dist/chunk-QDNL7NWN.cjs +0 -3
- package/dist/chunk-VPDOOMUJ.cjs +0 -26
- package/dist/chunk-VTAS7VZ6.cjs +0 -2
- package/dist/chunk-XKBIFFAS.cjs +0 -24
- package/dist/chunk-XS2AQFMF.cjs +0 -2
- package/dist/chunk-YS7FDEZ4.cjs +0 -1
- package/dist/core-plugins-reexport.cjs +0 -1
- package/dist/core-reexport.cjs +0 -1
- package/dist/executor-JGWZ7S6Z.cjs +0 -1
- package/dist/headless-reexport.cjs +0 -4
- package/dist/index.cjs +0 -155
- package/dist/lib-SPXD4LFI.cjs +0 -1
- package/dist/mcp-reexport.cjs +0 -16
- package/dist/processTemplate-FOYV6BC5.cjs +0 -1
- package/dist/react.cjs +0 -1
- package/dist/selectionRects-BMXJJCPJ.cjs +0 -1
- package/dist/selectionRects-TWK7CAC3.js +0 -1
- package/dist/ui.cjs +0 -1
- /package/dist/{agentApi-BVHzyk2l.d.cts → agentApi-BVHzyk2l.d.mts} +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
'use strict';var chunkQQ63M65M_js=require('./chunk-QQ63M65M.js'),chunk2KHL5RSD_js=require('./chunk-2KHL5RSD.js'),chunkCTYOM6BE_js=require('./chunk-CTYOM6BE.js'),chunkPJVI53AH_js=require('./chunk-PJVI53AH.js'),chunkFVUGBRDD_js=require('./chunk-FVUGBRDD.js'),chunkMRWJ3GNH_js=require('./chunk-MRWJ3GNH.js'),chunk4VUZBV2S_js=require('./chunk-4VUZBV2S.js'),chunkAARNCPWR_js=require('./chunk-AARNCPWR.js'),chunkVR6PT4IZ_js=require('./chunk-VR6PT4IZ.js'),chunkSE5EN2QL_js=require('./chunk-SE5EN2QL.js'),chunkH5NTJZO4_js=require('./chunk-H5NTJZO4.js'),rf=require('react'),jsxRuntime=require('react/jsx-runtime'),prosemirrorState=require('prosemirror-state'),prosemirrorView=require('prosemirror-view'),prosemirrorHistory=require('prosemirror-history'),prosemirrorModel=require('prosemirror-model'),prosemirrorCommands=require('prosemirror-commands'),prosemirrorTables=require('prosemirror-tables'),prosemirrorDropcursor=require('prosemirror-dropcursor'),prosemirrorKeymap=require('prosemirror-keymap');require('prosemirror-view/style/prosemirror.css');var sonner=require('sonner'),client=require('react-dom/client');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var rf__default=/*#__PURE__*/_interopDefault(rf);function Gf(){return jsxRuntime.jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M2 0C0.9 0 0 0.9 0 2V38C0 39.1 0.9 40 2 40H30C31.1 40 32 39.1 32 38V10L22 0H2Z",fill:"#cbd5e1"}),jsxRuntime.jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsxRuntime.jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function Ss({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function Kf(e){return e.replace(/\.docx$/i,"")}function hc({value:e,onChange:t,placeholder:n="Untitled",editable:o=true}){let r=Kf(e);return o?jsxRuntime.jsx("input",{type:"text",value:r,onChange:i=>{let a=i.target.value;t?.(a.endsWith(".docx")?a:a+".docx");},placeholder:n,className:"text-base font-normal text-slate-800 bg-transparent border-0 outline-none px-2 py-0 rounded hover:bg-slate-50 focus:bg-white focus:ring-1 focus:ring-slate-300 min-w-[100px] max-w-[300px] truncate leading-tight","aria-label":"Document name"}):jsxRuntime.jsx("span",{className:"text-base font-normal text-slate-800 px-2 py-0 min-w-[100px] max-w-[300px] truncate leading-tight",children:r||n})}function ks({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function Ts(){let e=chunk2KHL5RSD_js.x(),{disabled:t=false,onFormat:n,onPrint:o,showPrintButton:r=true,onPageSetup:i,onInsertImage:a,onInsertTable:s,showTableInsert:l=true,onInsertPageBreak:u,onInsertTOC:d,onRefocusEditor:c}=e,p=rf.useCallback(b=>{!t&&n&&n(b);},[t,n]),f=rf.useCallback((b,g)=>{!t&&s&&(s(b,g),requestAnimationFrame(()=>c?.()));},[t,s,c]);return jsxRuntime.jsxs("div",{className:"flex items-center",role:"menubar","aria-label":"Menu bar",children:[(r&&o||i)&&jsxRuntime.jsx(chunk2KHL5RSD_js.e,{label:"File",disabled:t,items:[...r&&o?[{icon:"print",label:"Print",shortcut:"Ctrl+P",onClick:o}]:[],...i?[{icon:"settings",label:"Page setup",onClick:i}]:[]]}),jsxRuntime.jsx(chunk2KHL5RSD_js.e,{label:"Format",disabled:t,items:[{icon:"format_textdirection_l_to_r",label:"Left-to-right text",onClick:()=>p("setLtr")},{icon:"format_textdirection_r_to_l",label:"Right-to-left text",onClick:()=>p("setRtl")}]}),jsxRuntime.jsx(chunk2KHL5RSD_js.e,{label:"Insert",disabled:t,items:[...a?[{icon:"image",label:"Image",onClick:a}]:[],...l&&s?[{icon:"grid_on",label:"Table",submenuContent:b=>jsxRuntime.jsx(chunk2KHL5RSD_js.f,{onInsert:(g,x)=>{f(g,x),b();}})}]:[],...a||l&&s?[{type:"separator"}]:[],{icon:"page_break",label:"Page break",onClick:u,disabled:!u},{icon:"format_list_numbered",label:"Table of contents",onClick:d,disabled:!d}]})]})}function bc({children:e}){let t=null,n=null,o=[],r=[];rf.Children.forEach(e,a=>{rf.isValidElement(a)&&(a.type===Ss?t=a:a.type===ks?n=a:a.type===Ts?r.push(a):o.push(a));});let i=rf.useCallback(a=>{let s=a.target;s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.tagName==="SELECT"||s.tagName==="OPTION"||a.preventDefault();},[]);return jsxRuntime.jsxs("div",{className:"flex items-stretch bg-white pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsxRuntime.jsx(Gf,{})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[o.length>0&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-1",children:o}),r.length>0&&jsxRuntime.jsx("div",{className:"flex items-center px-1",children:r})]}),n&&jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:n})]})}function Yf({children:e,className:t,...n}){return jsxRuntime.jsx(chunk2KHL5RSD_js.w.Provider,{value:n,children:jsxRuntime.jsx("div",{className:chunk2KHL5RSD_js.a("flex flex-col bg-white shadow-sm flex-shrink-0",t),"data-testid":"editor-toolbar",children:e})})}var zt=Yf;zt.TitleBar=bc;zt.Logo=Ss;zt.DocumentName=hc;zt.MenuBar=Ts;zt.TitleBarRight=ks;zt.FormattingBar=chunk2KHL5RSD_js.y;var Sc=rf.createContext(null);function KS(){let e=rf.useContext(Sc);if(!e)throw new Error("useErrorNotifications must be used within an ErrorProvider");return e}function kc({children:e}){let t=rf.useMemo(()=>new chunkFVUGBRDD_js.H,[]),n=rf.useSyncExternalStore(t.subscribe,t.getSnapshot),o=rf.useCallback((u,d)=>{t.showError(u,d);},[t]),r=rf.useCallback((u,d)=>{t.showWarning(u,d);},[t]),i=rf.useCallback((u,d)=>{t.showInfo(u,d);},[t]),a=rf.useCallback(u=>{t.dismiss(u);},[t]),s=rf.useCallback(()=>{t.clearAll();},[t]),l=rf.useMemo(()=>({notifications:n.notifications,showError:o,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:s}),[n.notifications,o,r,i,a,s]);return jsxRuntime.jsxs(Sc.Provider,{value:l,children:[e,jsxRuntime.jsx(em,{notifications:n.notifications,onDismiss:a})]})}function em({notifications:e,onDismiss:t}){let n=e.filter(r=>!r.dismissed);return n.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:n.map(r=>jsxRuntime.jsx(tm,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function tm({notification:e,onDismiss:t}){let[n,o]=rf.useState(false),i=(m=>{switch(m){case "error":return {bg:"var(--doc-error-bg)",border:"#f5c6cb",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"#ffeeba",text:"#856404",icon:"var(--doc-warning)"};case "info":return {bg:"#e8f4fd",border:"#b8daff",text:"#0c5460",icon:"var(--doc-primary)"}}})(e.severity),a={background:i.bg,border:`1px solid ${i.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",animation:"slideIn 0.3s ease-out"},s={display:"flex",alignItems:"flex-start",gap:"8px"},l={color:i.icon,flexShrink:0},u={flex:1,minWidth:0},d={color:i.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},c={marginTop:"8px",padding:"8px",background:"rgba(0, 0, 0, 0.05)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:i.text,maxHeight:"200px",overflow:"auto"},p={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:i.text},f=m=>{switch(m){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:a,children:[jsxRuntime.jsx("style",{children:`
|
|
2
|
+
@keyframes slideIn {
|
|
3
|
+
from {
|
|
4
|
+
opacity: 0;
|
|
5
|
+
transform: translateX(100%);
|
|
6
|
+
}
|
|
7
|
+
to {
|
|
8
|
+
opacity: 1;
|
|
9
|
+
transform: translateX(0);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`}),jsxRuntime.jsxs("div",{style:s,children:[jsxRuntime.jsx("span",{style:l,children:f(e.severity)}),jsxRuntime.jsxs("div",{style:u,children:[jsxRuntime.jsx("div",{style:d,children:e.message}),e.details&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!n),style:{...p,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:n?"Hide details":"Show details"}),n&&jsxRuntime.jsx("div",{style:c,children:e.details})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,style:p,title:"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 si=class extends rf.Component{constructor(n){super(n);chunkH5NTJZO4_js.d(this,"resetError",()=>{this.setState({hasError:false,error:null,errorInfo:null});});this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(n){return {hasError:true,error:n}}componentDidCatch(n,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",n,o),this.props.onError&&this.props.onError(n,o);}render(){if(this.state.hasError){let{fallback:n,showDetails:o=true}=this.props,{error:r,errorInfo:i}=this.state;return n?typeof n=="function"?n(r,this.resetError):n:jsxRuntime.jsx(nm,{error:r,errorInfo:i,showDetails:o,onReset:this.resetError})}return this.props.children}};function nm({error:e,errorInfo:t,showDetails:n,onReset:o}){let r={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"white",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},i={color:"var(--doc-error)",marginBottom:"16px"},a={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},l={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"},u={padding:"10px 20px",background:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:"docx-error-fallback",style:r,children:[jsxRuntime.jsx("div",{style:i,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:a,children:"Something went wrong"}),jsxRuntime.jsx("p",{style:s,children:"An error occurred while rendering this component. Please try again or contact support if the problem persists."}),n&&jsxRuntime.jsxs("div",{style:l,children:[jsxRuntime.jsx("strong",{children:"Error:"})," ",e.message,t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[`
|
|
13
|
+
|
|
14
|
+
`,jsxRuntime.jsx("strong",{children:"Component Stack:"}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:o,style:u,children:"Try Again"})]})}function YS({message:e,details:t,onRetry:n,className:o=""}){let r={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",background:"white",borderRadius:"8px",border:"1px solid var(--doc-border-light)"},i={color:"var(--doc-error)",marginBottom:"16px"},a={fontSize:"16px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},l={marginBottom:"16px",padding:"12px",background:"var(--doc-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",maxWidth:"100%",overflow:"auto",textAlign:"left"},u={padding:"8px 16px",background:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",fontSize:"13px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:`docx-parse-error ${o}`,style:r,children:[jsxRuntime.jsx("div",{style:i,children:jsxRuntime.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",children:[jsxRuntime.jsx("path",{d:"M10 10h20v20H10z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M25 10l-10 20M15 10l10 20",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h3",{style:a,children:"Unable to Parse Document"}),jsxRuntime.jsx("p",{style:s,children:e}),t&&jsxRuntime.jsx("div",{style:l,children:t}),n&&jsxRuntime.jsx("button",{type:"button",onClick:n,style:u,children:"Try Again"})]})}function qS({feature:e,description:t,className:n=""}){let o={display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:"var(--doc-warning-bg)",border:"1px solid #ffeeba",borderRadius:"4px",fontSize:"12px",color:"#856404"},r={flexShrink:0,color:"var(--doc-warning)"};return jsxRuntime.jsxs("div",{className:`docx-unsupported-warning ${n}`,style:o,children:[jsxRuntime.jsx("span",{style:r,children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M8 2l7 12H1L8 2z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M8 6v4M8 12v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("strong",{children:e}),t&&`: ${t}`]})]})}function XS(e){return e.message.includes("parse")||e.message.includes("Parse")||e.message.includes("XML")||e.message.includes("DOCX")||e.message.includes("Invalid")}function ZS(e){let t=e.message.toLowerCase();return t.includes("network")||t.includes("fetch")?"Network error. Please check your internet connection and try again.":t.includes("parse")||t.includes("xml")||t.includes("invalid")?"The document could not be parsed. It may be corrupted or in an unsupported format.":t.includes("permission")||t.includes("access")?"Access denied. You may not have permission to access this file.":t.includes("not found")||t.includes("404")?"The requested file was not found.":t.includes("timeout")?"The operation timed out. Please try again.":"An unexpected error occurred. Please try again."}function wc({document:e,onChange:t,onSelectionChange:n}){let o=rf.useMemo(()=>new chunkFVUGBRDD_js.C,[]),[r,i]=rf.useState({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),a=rf.useCallback((d,c,p)=>{if(!e)return;let f=chunkFVUGBRDD_js.z(e,d);if(!f){o.clearSelection(),i({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null});return}o.selectCell({tableIndex:d,rowIndex:c,columnIndex:p});let b=chunk2KHL5RSD_js.ea(f,{tableIndex:d,rowIndex:c,columnIndex:p});i({context:b,table:f,tableIndex:d,rowIndex:c,columnIndex:p}),n?.(b);},[e,o,n]),s=rf.useCallback(()=>{o.clearSelection(),i({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),n?.(null);},[o,n]),l=rf.useCallback(d=>{if(!e||!r.context||r.tableIndex===null||r.rowIndex===null||r.columnIndex===null)return;let c=r.table;if(!c)return;let p=null,f=null,m=r.rowIndex,b=r.columnIndex;switch(d){case "addRowAbove":p=chunk2KHL5RSD_js.ha(c,r.rowIndex,"before"),m=r.rowIndex+1;break;case "addRowBelow":p=chunk2KHL5RSD_js.ha(c,r.rowIndex,"after");break;case "addColumnLeft":p=chunk2KHL5RSD_js.ja(c,r.columnIndex,"before"),b=r.columnIndex+1;break;case "addColumnRight":p=chunk2KHL5RSD_js.ja(c,r.columnIndex,"after");break;case "deleteRow":c.rows.length>1&&(p=chunk2KHL5RSD_js.ia(c,r.rowIndex),m>=p.rows.length&&(m=p.rows.length-1));break;case "deleteColumn":{if(chunk2KHL5RSD_js.fa(c)>1){p=chunk2KHL5RSD_js.ka(c,r.columnIndex);let x=chunk2KHL5RSD_js.fa(p);b>=x&&(b=x-1);}break}case "mergeCells":r.context.selection.selectedCells&&(p=chunk2KHL5RSD_js.la(c,r.context.selection));break;case "splitCell":r.context.canSplitCell&&(p=chunk2KHL5RSD_js.ma(c,r.rowIndex,r.columnIndex));break;case "deleteTable":f=chunkFVUGBRDD_js.B(e,r.tableIndex),s(),t?.(f);return}p&&(f=chunkFVUGBRDD_js.A(e,r.tableIndex,p),t?.(f),f&&a(r.tableIndex,m,b));},[e,r,t,s,a]),u=rf.useCallback((d,c,p)=>o.isCellSelected(d,c,p),[o,r]);return {state:r,handleCellClick:a,handleAction:l,clearSelection:s,isCellSelected:u,tableContext:r.context}}var vc=({headings:e,onHeadingClick:t,onClose:n,topOffset:o=0})=>{let[r,i]=rf.useState(false);return rf.useEffect(()=>{requestAnimationFrame(()=>i(true));},[]),jsxRuntime.jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":"Document outline",style:{position:"absolute",top:o,left:30,bottom:0,width:240,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:r?"translateX(0)":"translateX(-270px)",transition:"transform 0.15s ease-out"},onMouseDown:a=>a.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px"},children:[jsxRuntime.jsx("button",{onClick:n,"aria-label":"Close outline",style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"#444746"},title:"Close outline",children:jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:"arrow_back",size:20})}),jsxRuntime.jsx("span",{style:{fontWeight:400,fontSize:14,color:"#1f1f1f",letterSpacing:"0.01em"},children:"Outline"})]}),jsxRuntime.jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:20},children:e.length===0?jsxRuntime.jsx("div",{style:{padding:"8px 16px",color:"#80868b",fontSize:13,lineHeight:"20px"},children:"No headings found. Add headings to your document to see them here."}):e.map((a,s)=>jsxRuntime.jsx("div",{style:{marginLeft:a.level*12},children:jsxRuntime.jsx("button",{className:"docx-outline-heading-btn",onClick:()=>t(a.pmPos),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 12px",fontSize:13,fontWeight:400,color:"#1f1f1f",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:a.text,children:a.text})},`${a.pmPos}-${s}`))})]})};function Ec(e){return e?.length?e.flatMap(t=>t.content.filter(n=>n.type==="run").flatMap(n=>"content"in n?n.content:[]).filter(n=>n.type==="text").map(n=>"text"in n?n.text:"")).join(""):""}function Cs(e){return e?new Date(e).toLocaleString(void 0,{hour:"numeric",minute:"2-digit",month:"short",day:"numeric"}):""}function vs(e){return e.split(/\s+/).map(t=>t[0]).join("").toUpperCase().slice(0,2)}var Mc=["#6DCCB1","#79AAD9","#EE789D","#A987D1","#E6A85F","#F2CC8F","#68B3A2","#B07AA1","#59A14F","#FF9DA7","#E15759","#76B7B2"];function lm(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return Mc[Math.abs(t)%Mc.length]}var cm=340,dm=8,di={background:"none",border:"none",cursor:"pointer",padding:4,color:"#5f6368",display:"flex",borderRadius:"50%"},Pc={padding:"6px 16px",fontSize:14,border:"none",background:"none",color:"#1a73e8",cursor:"pointer",fontWeight:500,fontFamily:"inherit"},Ic=({comments:e,trackedChanges:t,onCommentClick:n,onCommentReply:o,onCommentResolve:r,onCommentDelete:i,onAddComment:a,onCancelAddComment:s,onAcceptChange:l,onRejectChange:u,onTrackedChangeReply:d,topOffset:c=0,showResolved:p=false,isAddingComment:f=false,addCommentYPosition:m=null,pageWidth:b=816,editorContainerRef:g,anchorPositions:x})=>{let[T,S]=rf.useState(null),[B,C]=rf.useState(""),[P,_]=rf.useState(""),[q,z]=rf.useState(null),[H,ee]=rf.useState(null),[ue,A]=rf.useState(new Map),[O,ie]=rf.useState(false),ae=rf.useRef(new Set),N=rf.useRef(null),Ie=rf.useRef(new Map),Fe=rf.useMemo(()=>e.filter(v=>!(v.parentId!=null||v.done&&!p)),[e,p]),Ve=rf.useMemo(()=>{let v=new Map;for(let U of e)if(U.parentId!=null){let D=v.get(U.parentId);D?D.push(U):v.set(U.parentId,[U]);}return v},[e]),M=v=>Ve.get(v)??[],F=rf.useCallback(()=>{let v=g?.current;if(!v)return;let U=v.querySelector(".paged-editor__pages");if(!U)return;let D=v.getBoundingClientRect(),me=v.scrollTop,ge=[];for(let be of Fe){let pe=`comment-${be.id}`,_e=x?.get(pe);if(_e!=null)ge.push({id:pe,targetY:_e,height:Ie.current.get(pe)?.offsetHeight||80});else {let Ke=U.querySelector(`[data-comment-id="${be.id}"]`);if(Ke){let Ue=Ke.getBoundingClientRect();ge.push({id:pe,targetY:Ue.top-D.top+me,height:Ie.current.get(pe)?.offsetHeight||80});}}}t.forEach((be,pe)=>{let _e=`tc-${be.revisionId}-${pe}`,Ke=x?.get(`revision-${be.revisionId}`);if(Ke!=null)ge.push({id:_e,targetY:Ke,height:Ie.current.get(_e)?.offsetHeight||80});else {let Ue=U.querySelector(`[data-revision-id="${be.revisionId}"]`);if(Ue){let tt=Ue.getBoundingClientRect();ge.push({id:_e,targetY:tt.top-D.top+me,height:Ie.current.get(_e)?.offsetHeight||80});}}}),f&&m!=null&&ge.push({id:"new-comment-input",targetY:m,height:Ie.current.get("new-comment-input")?.offsetHeight||120}),ge.sort((be,pe)=>be.targetY-pe.targetY);let he=new Map,De=0;for(let be of ge){let pe=Math.max(be.targetY,De+dm);he.set(be.id,pe),De=pe+be.height;}A(he);},[Fe,t,g,f,m,x]);rf.useEffect(()=>{let v=g?.current;if(!v)return;let U=v.querySelector(".paged-editor__pages");if(!U)return;let D=me=>{let ge=me.target;if(!N.current?.contains(ge)){if(U.contains(ge)){let he=ge.closest("[data-comment-id]");if(he?.dataset.commentId){z(`comment-${he.dataset.commentId}`),n?.(Number(he.dataset.commentId));return}let De=ge.closest(".docx-insertion")||ge.closest(".docx-deletion");if(De?.dataset.revisionId){let be=Number(De.dataset.revisionId),pe=t.findIndex(_e=>_e.revisionId===be);if(pe>=0){z(`tc-${t[pe].revisionId}-${pe}`);return}}}z(null),ee(null);}};return v.addEventListener("click",D),()=>v.removeEventListener("click",D)},[g,t,n]),rf.useEffect(()=>{let v=g?.current;if(!v)return;let U=setTimeout(F,50),D=setTimeout(()=>{F(),ie(true);},400),me=new ResizeObserver(()=>{requestAnimationFrame(F);});return me.observe(v),()=>{clearTimeout(U),clearTimeout(D),me.disconnect();}},[F,g]),rf.useEffect(()=>{let v=requestAnimationFrame(F);return ()=>cancelAnimationFrame(v)},[q,f,F]),rf.useEffect(()=>{let v=[];if(q){let ge=Ie.current.get(q);ge&&v.push(ge);}let U=Ie.current.get("new-comment-input");if(U&&v.push(U),v.length===0)return;let D,me=new ResizeObserver(()=>{cancelAnimationFrame(D),D=requestAnimationFrame(F);});for(let ge of v)me.observe(ge);return ()=>{cancelAnimationFrame(D),me.disconnect();}},[q,F]);let k=()=>{P.trim()&&(a?.(P.trim()),_(""));},L=(v,U)=>{z(q===v?null:v),ee(null),U!==void 0&&n?.(U);},I=ue.size>0,E=(v,U=32)=>({width:U,height:U,borderRadius:"50%",backgroundColor:lm(v),color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:U===32?13:11,fontWeight:500,flexShrink:0}),Z=v=>({padding:"6px 16px",fontSize:14,border:"none",borderRadius:20,background:v?"#1a73e8":"#f1f3f4",color:v?"#fff":"#80868b",cursor:v?"pointer":"default",fontWeight:500,fontFamily:"inherit"}),le=(v,U,D)=>{let me=ae.current.has(v);return D!==void 0&&ae.current.add(v),{...I?D!==void 0?{position:"absolute",top:D,left:0,right:0,opacity:1}:{position:"absolute",top:0,left:0,right:0,opacity:0,visibility:"hidden"}:{marginBottom:6},padding:U?"10px 12px":"8px 10px",borderRadius:8,backgroundColor:U?"#fff":"#f8fbff",cursor:"pointer",boxShadow:U?"0 1px 3px rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15)":"0 1px 3px rgba(60,64,67,0.2), 0 2px 6px rgba(60,64,67,0.08)",transition:I&&D===void 0?"none":!me&&D!==void 0?"opacity 0.2s ease, box-shadow 0.2s ease":O?"opacity 0.2s ease, box-shadow 0.2s ease, top 0.15s ease":"none"}},$=(v,U)=>v.length===0?null:jsxRuntime.jsxs("div",{style:{marginTop:8},children:[(U?v:v.slice(-1)).map(D=>jsxRuntime.jsxs("div",{style:{marginBottom:U?8:0,paddingTop:8,borderTop:"1px solid #e8eaed"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:E(D.author||"U",28),children:vs(D.author||"U")}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:D.author||"Unknown"}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Cs(D.date)})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:4,...U?{}:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"}},children:Ec(D.content)})]},D.id)),!U&&v.length>1&&jsxRuntime.jsxs("div",{style:{fontSize:12,color:"#5f6368",marginTop:4},children:[v.length-1," more ",v.length-1===1?"reply":"replies"]})]}),Y=(v,U)=>jsxRuntime.jsx("div",{onClick:D=>D.stopPropagation(),style:{marginTop:12},children:T===v?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("input",{ref:D=>D?.focus({preventScroll:true}),type:"text",value:B,onChange:D=>C(D.target.value),onMouseDown:D=>D.stopPropagation(),onKeyDown:D=>{D.stopPropagation(),D.key==="Enter"&&(D.preventDefault(),B.trim()&&U&&U(v,B.trim()),C(""),S(null)),D.key==="Escape"&&(S(null),C(""));},placeholder:"Reply or add others with @",style:{width:"100%",border:"1px solid #1a73e8",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",boxSizing:"border-box",color:"#202124"}}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsxRuntime.jsx("button",{onClick:D=>{D.stopPropagation(),S(null),C("");},style:Pc,children:"Cancel"}),jsxRuntime.jsx("button",{onClick:D=>{D.stopPropagation(),B.trim()&&U&&U(v,B.trim()),C(""),S(null);},disabled:!B.trim(),style:Z(!!B.trim()),children:"Reply"})]})]}):jsxRuntime.jsx("input",{readOnly:true,onMouseDown:D=>D.stopPropagation(),onClick:D=>{D.stopPropagation(),S(v);},placeholder:"Reply or add others with @",style:{width:"100%",border:"1px solid #dadce0",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",color:"#80868b",cursor:"text",backgroundColor:"#fff",boxSizing:"border-box"}})}),ne=v=>{let U=M(v.id),D=`comment-${v.id}`,me=q===D,ge=ue.get(D);return jsxRuntime.jsxs("div",{ref:he=>{he?Ie.current.set(D,he):Ie.current.delete(D);},"data-comment-id":v.id,className:"docx-comment-card",onClick:()=>L(D,v.id),onMouseDown:he=>he.stopPropagation(),style:{...le(D,me,ge),opacity:I&&ge===void 0?0:v.done?.6:1},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:E(v.author||"U"),children:vs(v.author||"U")}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:v.author||"Unknown"}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Cs(v.date)})]}),me&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:4,marginTop:2,position:"relative"},children:[jsxRuntime.jsx("button",{onClick:he=>{he.stopPropagation(),r?.(v.id);},title:"Resolve",style:di,children:jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:"check",size:20})}),jsxRuntime.jsx("button",{onClick:he=>{he.stopPropagation(),ee(H===D?null:D);},title:"More options",style:di,children:jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:"more_vert",size:20})}),H===D&&jsxRuntime.jsx("div",{onClick:he=>he.stopPropagation(),onMouseDown:he=>he.stopPropagation(),style:{position:"absolute",top:32,right:0,background:"#fff",borderRadius:8,boxShadow:"0 2px 6px rgba(60,64,67,0.3), 0 1px 2px rgba(60,64,67,0.15)",zIndex:100,minWidth:120,padding:"4px 0"},children:jsxRuntime.jsx("button",{onClick:()=>{ee(null),i?.(v.id);},style:{display:"block",width:"100%",padding:"8px 16px",border:"none",background:"none",textAlign:"left",fontSize:14,color:"#202124",cursor:"pointer",fontFamily:"inherit"},onMouseOver:he=>{he.target.style.backgroundColor="#f1f3f4";},onMouseOut:he=>{he.target.style.backgroundColor="transparent";},children:"Delete"})})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:6},children:Ec(v.content)}),$(U,me),me&&!v.done&&Y(v.id,o)]},v.id)},fe=v=>Ve.get(v)??[],Te=(v,U)=>{let D=v.author||"Unknown",me=`tc-${v.revisionId}-${U}`,ge=q===me,he=ue.get(me),De=fe(v.revisionId);return jsxRuntime.jsxs("div",{ref:be=>{be?Ie.current.set(me,be):Ie.current.delete(me);},className:"docx-tracked-change-card",onClick:()=>L(me),onMouseDown:be=>be.stopPropagation(),style:le(me,ge,he),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:E(D),children:vs(D)}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:D}),v.date&&jsxRuntime.jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Cs(v.date)})]}),ge&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:4,marginTop:2},children:[jsxRuntime.jsx("button",{onClick:be=>{be.stopPropagation(),l?.(v.from,v.to);},title:"Accept",style:di,children:jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:"check",size:20})}),jsxRuntime.jsx("button",{onClick:be=>{be.stopPropagation(),u?.(v.from,v.to);},title:"Reject",style:di,children:jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:"close",size:20})})]})]}),jsxRuntime.jsxs("div",{style:{fontSize:13,lineHeight:"20px",color:"#202124",marginTop:6},children:[v.type==="insertion"?"Added":"Deleted"," ",jsxRuntime.jsxs("span",{style:{color:v.type==="insertion"?"#137333":"#c5221f",fontWeight:500},children:['"',v.text.length>50?v.text.slice(0,50)+"...":v.text,'"']})]}),$(De,ge),ge&&Y(v.revisionId,d)]},me)};return jsxRuntime.jsx("aside",{ref:N,className:"docx-comments-sidebar",role:"complementary","aria-label":"Comments and changes",style:{position:"absolute",top:c,left:`calc(50% - 120px + ${b/2+12}px)`,bottom:0,width:cm,fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,backgroundColor:"transparent",overflowY:I?"visible":"auto",overflowX:"visible",opacity:I?1:0,transition:"opacity 0.15s ease"},onMouseDown:v=>v.stopPropagation(),children:jsxRuntime.jsxs("div",{style:{position:"relative"},children:[f&&jsxRuntime.jsxs("div",{ref:v=>{v?Ie.current.set("new-comment-input",v):Ie.current.delete("new-comment-input");},style:{...I?ue.get("new-comment-input")!==void 0?{position:"absolute",top:ue.get("new-comment-input"),left:0,right:0}:{position:"absolute",top:0,left:0,right:0,visibility:"hidden"}:{marginBottom:8},padding:12,borderRadius:8,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15)",zIndex:50},children:[jsxRuntime.jsx("textarea",{ref:v=>v?.focus({preventScroll:true}),value:P,onChange:v=>_(v.target.value),onMouseDown:v=>v.stopPropagation(),onKeyDown:v=>{v.stopPropagation(),v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),k()),v.key==="Escape"&&(s?.(),_(""));},placeholder:"Add a comment...",style:{width:"100%",border:"1px solid #1a73e8",borderRadius:20,outline:"none",resize:"none",fontSize:14,lineHeight:"20px",padding:"8px 16px",fontFamily:"inherit",minHeight:40,boxSizing:"border-box",color:"#202124"}}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsxRuntime.jsx("button",{onClick:()=>{s?.(),_("");},style:Pc,children:"Cancel"}),jsxRuntime.jsx("button",{onClick:k,disabled:!P.trim(),style:Z(!!P.trim()),children:"Comment"})]})]}),Fe.map(v=>ne(v)),t.map((v,U)=>Te(v,U)),Fe.length===0&&t.length===0&&!f&&jsxRuntime.jsx("div",{style:{padding:"24px 16px",textAlign:"center",color:"#80868b",fontSize:13},children:"No comments or changes yet."})]})})};var fm=15840,Lc=1440,mm=1440,gm=567,Ac=20,hm="var(--doc-text-muted)",bm="var(--doc-text-subtle)",ym="var(--doc-primary)",xm="var(--doc-primary)",Sm="var(--doc-primary-hover)";function Dc({sectionProps:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,unit:i="inch",className:a="",style:s}){let[l,u]=rf.useState(null),[d,c]=rf.useState(null),p=rf.useRef(null),f=e?.pageHeight??fm,m=e?.marginTop??Lc,b=e?.marginBottom??Lc,g=chunkSE5EN2QL_js.a(f)*t,x=chunkSE5EN2QL_js.a(m)*t,T=chunkSE5EN2QL_js.a(b)*t,S=rf.useCallback((q,z)=>{n&&(q.preventDefault(),u(z));},[n]),B=rf.useCallback(q=>{if(!l||!p.current)return;let z=p.current.getBoundingClientRect(),H=q.clientY-z.top,ee=chunkSE5EN2QL_js.b(H/t);if(l==="topMargin"){let ue=f-b-720,A=Math.max(0,Math.min(ee,ue));o?.(Math.round(A));}else if(l==="bottomMargin"){let ue=f-ee,A=f-m-720,O=Math.max(0,Math.min(ue,A));r?.(Math.round(O));}},[l,t,f,m,b,o,r]),C=rf.useCallback(()=>{u(null);},[]);rf.useEffect(()=>{if(l)return document.addEventListener("mousemove",B),document.addEventListener("mouseup",C),()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",C);}},[l,B,C]);let P=Tm(f,t,i),_={position:"relative",width:Ac,height:chunkSE5EN2QL_js.k(g),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:l?"ns-resize":"default",...s};return jsxRuntime.jsxs("div",{ref:p,className:`docx-vertical-ruler ${a}`,style:_,role:"slider","aria-label":"Vertical ruler","aria-orientation":"vertical",children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:P.map((q,z)=>jsxRuntime.jsx(km,{tick:q},z))}),jsxRuntime.jsx(Bc,{type:"topMargin",position:x,editable:n,isDragging:l==="topMargin",isHovered:d==="topMargin",onMouseEnter:()=>c("topMargin"),onMouseLeave:()=>c(null),onMouseDown:q=>S(q,"topMargin")}),jsxRuntime.jsx(Bc,{type:"bottomMargin",position:g-T,editable:n,isDragging:l==="bottomMargin",isHovered:d==="bottomMargin",onMouseEnter:()=>c("bottomMargin"),onMouseLeave:()=>c(null),onMouseDown:q=>S(q,"bottomMargin")})]})}function km({tick:e}){let t={position:"absolute",top:chunkSE5EN2QL_js.k(e.position),right:0,height:1,width:e.width,backgroundColor:bm},n={position:"absolute",top:chunkSE5EN2QL_js.k(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:hm,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:t}),e.label&&jsxRuntime.jsx("div",{style:n,children:e.label})]})}function Bc({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:s}){let l=o?Sm:r?xm:ym,u={position:"absolute",top:chunkSE5EN2QL_js.k(t-5),right:0,width:Ac,height:10,cursor:n?"ns-resize":"default",zIndex:o?10:1},d={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${l}`,transition:"border-right-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:u,onMouseEnter:i,onMouseLeave:a,onMouseDown:s,role:"slider","aria-label":e==="topMargin"?"Top margin":"Bottom margin","aria-orientation":"vertical",tabIndex:n?0:-1,children:jsxRuntime.jsx("div",{style:d})})}function Tm(e,t,n){let o=[];if(n==="inch"){let r=mm/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=chunkSE5EN2QL_js.a(s)*t;if(a%8===0){let u=a/8;o.push({position:l,width:10,label:u>0?String(u):void 0});}else a%4===0?o.push({position:l,width:6}):a%2===0?o.push({position:l,width:4}):o.push({position:l,width:2});}}else {let r=gm/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=chunkSE5EN2QL_js.a(s)*t;if(a%10===0){let u=a/10;o.push({position:l,width:10,label:u>0?String(u):void 0});}else a%5===0?o.push({position:l,width:6}):o.push({position:l,width:3});}}return o}var tn={High:50,Default:100,Low:150};function ft(e){return t=>{let n={...e.defaultOptions,...t};return {type:"extension",config:{name:e.name,priority:e.priority??tn.Default,options:n},onSchemaReady(o){return e.onSchemaReady(o,n)}}}}function Qe(e){return t=>{let n={...e.defaultOptions,...t},o=typeof e.nodeSpec=="function"?e.nodeSpec(n):e.nodeSpec;return {type:"node",config:{name:e.name,priority:e.priority??tn.Default,options:n,schemaNodeName:e.schemaNodeName,nodeSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}function He(e){return t=>{let n={...e.defaultOptions,...t},o=typeof e.markSpec=="function"?e.markSpec(n):e.markSpec;return {type:"mark",config:{name:e.name,priority:e.priority??tn.Default,options:n,schemaMarkName:e.schemaMarkName,markSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}var Nc=Qe({name:"doc",schemaNodeName:"doc",nodeSpec:{content:"(paragraph | horizontalRule | pageBreak | table | textBox)+"}});var zc=Qe({name:"text",schemaNodeName:"text",nodeSpec:{group:"inline"}});function Oc(e,t){if(!e)return {};let n={};if(e.fontFamily){let a=null;if(e.fontFamily.asciiTheme&&t?.fontScheme,a||(a=e.fontFamily.ascii||e.fontFamily.hAnsi||e.fontFamily.eastAsia||e.fontFamily.cs||null),a){let s=chunkQQ63M65M_js.a(a);n.fontFamily=s.cssFallback;}}if(e.fontSize!==void 0&&(n.fontSize=`${chunkSE5EN2QL_js.i(e.fontSize)}pt`),e.bold&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic"),e.color&&(n.color=chunk4VUZBV2S_js.a(e.color,t)),e.highlight&&e.highlight!=="none"&&(n.backgroundColor=chunk4VUZBV2S_js.n(e.highlight)),e.shading){let a=Wc(e.shading,t);a&&!n.backgroundColor&&(n.backgroundColor=a);}let o=[],r=[],i=[];if(e.underline&&e.underline.style!=="none"){o.push("underline");let a=Cm(e.underline.style);a!=="solid"&&r.push(a),e.underline.color&&i.push(chunk4VUZBV2S_js.a(e.underline.color,t));}if(e.strike&&o.push("line-through"),e.doubleStrike&&o.push("line-through"),o.length>0&&(n.textDecoration=o.join(" "),r.length>0&&(n.textDecorationStyle=r[0]),i.length>0&&(n.textDecorationColor=i[0])),e.vertAlign)switch(e.vertAlign){case "superscript":n.verticalAlign="super",n.fontSize||(n.fontSize="0.83em");break;case "subscript":n.verticalAlign="sub",n.fontSize||(n.fontSize="0.83em");break}if(e.position&&e.position!==0){let a=chunkSE5EN2QL_js.h(e.position);n.position="relative",n.top=chunkSE5EN2QL_js.k(-a);}return e.allCaps?n.textTransform="uppercase":e.smallCaps&&(n.fontVariant="small-caps"),e.spacing!==void 0&&e.spacing!==0&&(n.letterSpacing=chunkSE5EN2QL_js.k(chunkSE5EN2QL_js.a(e.spacing))),e.scale!==void 0&&e.scale!==100&&(n.transform=`scaleX(${e.scale/100})`,n.display="inline-block"),e.hidden&&(n.display="none"),e.emboss&&(n.textShadow="1px 1px 1px rgba(255,255,255,0.5), -1px -1px 1px rgba(0,0,0,0.3)"),e.imprint&&(n.textShadow="-1px -1px 1px rgba(255,255,255,0.5), 1px 1px 1px rgba(0,0,0,0.3)"),e.outline&&(n.WebkitTextStroke="1px currentColor",n.WebkitTextFillColor="transparent"),e.shadow&&!e.emboss&&!e.imprint&&(n.textShadow="1px 1px 2px rgba(0,0,0,0.3)"),e.rtl&&(n.direction="rtl"),n}function $c(e,t){if(!e)return {};let n={};if(e.alignment&&(n.textAlign=vm(e.alignment)),e.spaceBefore!==void 0&&(n.marginTop=chunkSE5EN2QL_js.k(chunkSE5EN2QL_js.a(e.spaceBefore))),e.spaceAfter!==void 0&&(n.marginBottom=chunkSE5EN2QL_js.k(chunkSE5EN2QL_js.a(e.spaceAfter))),e.lineSpacing!==void 0&&e.lineSpacing>0)switch(e.lineSpacingRule){case "exact":{let o=chunkSE5EN2QL_js.a(e.lineSpacing);o>0&&(n.lineHeight=chunkSE5EN2QL_js.k(o));break}case "atLeast":{let o=chunkSE5EN2QL_js.a(e.lineSpacing);o>0&&(n.minHeight=chunkSE5EN2QL_js.k(o),n.lineHeight=chunkSE5EN2QL_js.k(o));break}default:{let o=e.lineSpacing/240;o>0&&(n.lineHeight=o.toString());break}}if(e.indentLeft!==void 0&&(n.marginLeft=chunkSE5EN2QL_js.k(chunkSE5EN2QL_js.a(e.indentLeft))),e.indentRight!==void 0&&(n.marginRight=chunkSE5EN2QL_js.k(chunkSE5EN2QL_js.a(e.indentRight))),e.indentFirstLine!==void 0&&(e.hangingIndent?n.textIndent=chunkSE5EN2QL_js.k(chunkSE5EN2QL_js.a(e.indentFirstLine)):n.textIndent=chunkSE5EN2QL_js.k(chunkSE5EN2QL_js.a(e.indentFirstLine))),e.borders&&(e.borders.top&&Object.assign(n,zo(e.borders.top,"Top",t)),e.borders.bottom&&Object.assign(n,zo(e.borders.bottom,"Bottom",t)),e.borders.left&&Object.assign(n,zo(e.borders.left,"Left",t)),e.borders.right&&Object.assign(n,zo(e.borders.right,"Right",t))),e.shading){let o=Wc(e.shading,t);o&&(n.backgroundColor=o);}return e.bidi&&(n.direction="rtl"),e.pageBreakBefore&&(n.pageBreakBefore="always"),e.keepNext&&(n.pageBreakAfter="avoid"),e.keepLines&&(n.pageBreakInside="avoid"),n}function zo(e,t="",n){if(!e||e.style==="none"||e.style==="nil")return {};let o={},r=e.size?chunkSE5EN2QL_js.j(e.size):1,i=e.color?chunk4VUZBV2S_js.a(e.color,n):"#000000",a=Rm(e.style),s=`border${t}Width`,l=`border${t}Style`,u=`border${t}Color`;return o[s]=chunkSE5EN2QL_js.k(Math.max(1,r)),o[l]=a,o[u]=i,o}function Wc(e,t){return !e||e.pattern==="clear"||e.pattern==="nil"?"":e.fill?e.fill.auto||e.fill.rgb==="auto"||e.fill.rgb==="FFFFFF"?"":chunk4VUZBV2S_js.c(e.fill,t):e.pattern==="solid"&&e.color?chunk4VUZBV2S_js.c(e.color,t):e.pattern&&e.pattern.startsWith("pct")&&e.color?chunk4VUZBV2S_js.c(e.color,t):""}function Cm(e){switch(e){case "double":return "double";case "dotted":case "dottedHeavy":return "dotted";case "dash":case "dashedHeavy":case "dashLong":case "dashLongHeavy":case "dotDash":case "dashDotHeavy":case "dotDotDash":case "dashDotDotHeavy":return "dashed";case "wave":case "wavyHeavy":case "wavyDouble":return "wavy";default:return "solid"}}function vm(e){switch(e){case "center":return "center";case "right":return "right";case "both":case "distribute":return "justify";default:return "left"}}function Rm(e){switch(e){case "none":case "nil":return "none";case "double":case "triple":return "double";case "dotted":return "dotted";case "dashed":case "dashSmallGap":return "dashed";case "threeDEmboss":return "ridge";case "threeDEngrave":return "groove";case "outset":return "outset";case "inset":return "inset";default:return "solid"}}function Oo(e){let t=[];return e.descendants((n,o)=>{if(n.type.name==="paragraph"){let r=n.attrs.outlineLevel,i=n.attrs.styleId,a=r;if(a==null&&i){let s=i.match(/^[Hh]eading(\d)$/);s&&(a=parseInt(s[1],10)-1);}if(a!=null&&a>=0&&a<=8){let s="";n.forEach(l=>{l.isText&&(s+=l.text||"");}),s.trim()&&t.push({text:s.trim(),level:a,pmPos:o});}}}),t}function Mm(e){let t=e.indentLeft;e.numPr?.numId&&t==null&&(t=((e.numPr.ilvl??0)+1)*720);let n={alignment:e.alignment,spaceBefore:e.spaceBefore,spaceAfter:e.spaceAfter,lineSpacing:e.lineSpacing,lineSpacingRule:e.lineSpacingRule,indentLeft:t,indentRight:e.indentRight,indentFirstLine:e.indentFirstLine,hangingIndent:e.hangingIndent,borders:e.borders,shading:e.shading},o=$c(n);return Object.entries(o).map(([r,i])=>`${r.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${i}`).join("; ")}function Pm(e){switch(e){case "upperRoman":return "docx-list-upper-roman";case "lowerRoman":return "docx-list-lower-roman";case "upperLetter":return "docx-list-upper-alpha";case "lowerLetter":return "docx-list-lower-alpha";default:return "docx-list-decimal"}}function Im(e,t,n){if(!e?.numId)return "";let o=e.ilvl??0;return t?`docx-list-bullet docx-list-level-${o}`:`docx-list-numbered ${Pm(n)} docx-list-level-${o}`}function $o(e){if(!e)return;let t=e.trim(),n=parseFloat(t);if(!(isNaN(n)||n===0)){if(t.endsWith("pt"))return Math.round(n*20);if(t.endsWith("px"))return Math.round(n*15);if(t.endsWith("in"))return Math.round(n*1440);if(t.endsWith("mm"))return Math.round(n*(1440/25.4));if(t.endsWith("cm"))return Math.round(n*(1440/2.54));if(/^[\d.]+$/.test(t))return Math.round(n*15)}}function Fm(e){switch(e.trim().toLowerCase()){case "left":case "start":return "left";case "center":return "center";case "right":case "end":return "right";case "justify":return "both";default:return}}function Lm(e){if(!e||e==="normal")return;let t=e.trim();if(t.endsWith("%")){let o=parseFloat(t);return isNaN(o)||o===0?void 0:{lineSpacing:Math.round(240*(o/100)),lineSpacingRule:"auto"}}if(/[a-z]/i.test(t)){let o=$o(t);return o==null?void 0:{lineSpacing:o,lineSpacingRule:"exact"}}let n=parseFloat(t);if(!(isNaN(n)||n===0))return {lineSpacing:Math.round(240*n),lineSpacingRule:"auto"}}function _c(e){let t=e.style,n={};if(t.textAlign){let i=Fm(t.textAlign);i&&(n.alignment=i);}let o=t.marginLeft||t.paddingLeft;if(o){let i=$o(o);i!=null&&(n.indentLeft=i);}let r=t.marginRight||t.paddingRight;if(r){let i=$o(r);i!=null&&(n.indentRight=i);}if(t.textIndent){let i=$o(t.textIndent);i!=null&&(i<0?(n.indentFirstLine=Math.abs(i),n.hangingIndent=true):n.indentFirstLine=i);}if(t.lineHeight){let i=Lm(t.lineHeight);i&&(n.lineSpacing=i.lineSpacing,n.lineSpacingRule=i.lineSpacingRule);}if(t.marginTop){let i=$o(t.marginTop);i!=null&&(n.spaceBefore=i);}if(t.marginBottom){let i=$o(t.marginBottom);i!=null&&(n.spaceAfter=i);}return n}var Bm={content:"inline*",group:"block",attrs:{paraId:{default:null},textId:{default:null},alignment:{default:null},spaceBefore:{default:null},spaceAfter:{default:null},lineSpacing:{default:null},lineSpacingRule:{default:null},indentLeft:{default:null},indentRight:{default:null},indentFirstLine:{default:null},hangingIndent:{default:false},numPr:{default:null},listNumFmt:{default:null},listIsBullet:{default:null},listMarker:{default:null},listMarkerHidden:{default:null},listMarkerFontFamily:{default:null},listMarkerFontSize:{default:null},styleId:{default:null},borders:{default:null},shading:{default:null},tabs:{default:null},pageBreakBefore:{default:null},keepNext:{default:null},keepLines:{default:null},contextualSpacing:{default:null},defaultTextFormatting:{default:null},sectionBreakType:{default:null},bidi:{default:null},outlineLevel:{default:null},bookmarks:{default:null},_originalFormatting:{default:null},_sectionProperties:{default:null}},parseDOM:[{tag:"p",getAttrs(e){let t=e,n={paraId:t.dataset.paraId||void 0,alignment:t.dataset.alignment,styleId:t.dataset.styleId||void 0,sectionBreakType:t.dataset.sectionBreak||void 0},o=_c(t);return {...o,...n,alignment:n.alignment||o.alignment||void 0}}},...["h1","h2","h3","h4","h5","h6"].map(e=>({tag:e,getAttrs(t){let n=parseInt(e.charAt(1));return {..._c(t),styleId:`Heading${n}`,outlineLevel:n-1}}}))],toDOM(e){let t=e.attrs,n=Mm(t),o=Im(t.numPr,t.listIsBullet,t.listNumFmt),r={};return n&&(r.style=n),o&&(r.class=o),t.paraId&&(r["data-para-id"]=t.paraId),t.alignment&&(r["data-alignment"]=t.alignment),t.styleId&&(r["data-style-id"]=t.styleId),t.listMarker&&(r["data-list-marker"]=t.listMarker),t.bidi&&(r.dir="rtl"),t.sectionBreakType&&(r["data-section-break"]=t.sectionBreakType,r.class=(r.class?r.class+" ":"")+"docx-section-break"),["p",r,0]}};function Ot(e,t){return (n,o)=>{let{$from:r,$to:i}=n.selection;if(!o)return true;let a=n.tr,s=new Set;return n.doc.nodesBetween(r.pos,i.pos,(l,u)=>{l.type.name==="paragraph"&&!s.has(u)&&(s.add(u),a=a.setNodeMarkup(u,void 0,{...l.attrs,[e]:t}));}),o(a.scrollIntoView()),true}}function Vc(e){return (t,n)=>{let{$from:o,$to:r}=t.selection;if(!n)return true;let i=t.tr,a=new Set;return t.doc.nodesBetween(o.pos,r.pos,(s,l)=>{s.type.name==="paragraph"&&!a.has(l)&&(a.add(l),i=i.setNodeMarkup(l,void 0,{...s.attrs,...e}));}),n(i.scrollIntoView()),true}}function br(e){return (t,n)=>Ot("alignment",e)(t,n)}function ui(e,t="auto"){return (n,o)=>Vc({lineSpacing:e,lineSpacingRule:t})(n,o)}function Am(e=720){return (t,n)=>{let{$from:o,$to:r}=t.selection;if(!n)return true;let i=t.tr,a=new Set;return t.doc.nodesBetween(o.pos,r.pos,(s,l)=>{if(s.type.name==="paragraph"&&!a.has(l)){a.add(l);let u=s.attrs.indentLeft||0;i=i.setNodeMarkup(l,void 0,{...s.attrs,indentLeft:u+e});}}),n(i.scrollIntoView()),true}}function Dm(e=720){return (t,n)=>{let{$from:o,$to:r}=t.selection;if(!n)return true;let i=t.tr,a=new Set;return t.doc.nodesBetween(o.pos,r.pos,(s,l)=>{if(s.type.name==="paragraph"&&!a.has(l)){a.add(l);let u=s.attrs.indentLeft||0,d=Math.max(0,u-e);i=i.setNodeMarkup(l,void 0,{...s.attrs,indentLeft:d>0?d:null});}}),n(i.scrollIntoView()),true}}function Hm(e){return (t,n)=>(o,r)=>{let{$from:i,$to:a}=o.selection;if(!r)return true;let s=o.tr,l=new Set,u=[];if(n?.runFormatting){let c=n.runFormatting;c.bold&&u.push(e.marks.bold.create()),c.italic&&u.push(e.marks.italic.create()),c.fontSize&&u.push(e.marks.fontSize.create({size:c.fontSize})),c.fontFamily&&u.push(e.marks.fontFamily.create({ascii:c.fontFamily.ascii,hAnsi:c.fontFamily.hAnsi,asciiTheme:c.fontFamily.asciiTheme})),c.color&&!c.color.auto&&u.push(e.marks.textColor.create({rgb:c.color.rgb,themeColor:c.color.themeColor,themeTint:c.color.themeTint,themeShade:c.color.themeShade})),c.underline&&c.underline.style!=="none"&&u.push(e.marks.underline.create({style:c.underline.style,color:c.underline.color})),(c.strike||c.doubleStrike)&&u.push(e.marks.strike.create({double:c.doubleStrike||false}));}let d=[e.marks.bold,e.marks.italic,e.marks.fontSize,e.marks.fontFamily,e.marks.textColor,e.marks.underline,e.marks.strike].filter(Boolean);return o.doc.nodesBetween(i.pos,a.pos,(c,p)=>{if(c.type.name==="paragraph"&&!l.has(p)){l.add(p);let f={...c.attrs,styleId:t};if(n){let m=n.paragraphFormatting;f.alignment=m?.alignment??null,f.spaceBefore=m?.spaceBefore??null,f.spaceAfter=m?.spaceAfter??null,f.lineSpacing=m?.lineSpacing??null,f.lineSpacingRule=m?.lineSpacingRule??null,f.indentLeft=m?.indentLeft??null,f.indentRight=m?.indentRight??null,f.indentFirstLine=m?.indentFirstLine??null,f.hangingIndent=m?.hangingIndent??null,f.contextualSpacing=m?.contextualSpacing??null,f.keepNext=m?.keepNext??null,f.keepLines=m?.keepLines??null,f.pageBreakBefore=m?.pageBreakBefore??null,f.outlineLevel=m?.outlineLevel??null;}if(s=s.setNodeMarkup(p,void 0,f),n){let m=p+1,b=p+c.nodeSize-1;if(b>m){for(let g of d)s=s.removeMark(m,b,g);for(let g of u)s=s.addMark(m,b,g);}}}}),u.length>0&&(s=s.setStoredMarks(u)),r(s.scrollIntoView()),true}}var Uc=Qe({name:"paragraph",schemaNodeName:"paragraph",nodeSpec:Bm,onSchemaReady(e){let t=Hm(e.schema);return {commands:{setAlignment:n=>br(n),alignLeft:()=>br("left"),alignCenter:()=>br("center"),alignRight:()=>br("right"),alignJustify:()=>br("both"),setLineSpacing:(n,o)=>ui(n,o),singleSpacing:()=>ui(240),oneAndHalfSpacing:()=>ui(360),doubleSpacing:()=>ui(480),setSpaceBefore:n=>Ot("spaceBefore",n),setSpaceAfter:n=>Ot("spaceAfter",n),increaseIndent:n=>Am(n),decreaseIndent:n=>Dm(n),setIndentLeft:n=>Ot("indentLeft",n>0?n:null),setIndentRight:n=>Ot("indentRight",n>0?n:null),setIndentFirstLine:(n,o)=>Vc({indentFirstLine:n>0?n:null,hangingIndent:o??false}),applyStyle:(n,o)=>t(n,o),clearStyle:()=>Ot("styleId",null),insertSectionBreak:n=>Ot("sectionBreakType",n),removeSectionBreak:()=>Ot("sectionBreakType",null),generateTOC:()=>(n,o)=>{let r=Oo(n.doc);if(r.length===0)return false;if(!o)return true;let{schema:i}=n,a=n.tr,s=[];for(let d of r){let c=`_Toc${Math.floor(1e8+Math.random()*9e8)}`;s.push({name:c,level:d.level,text:d.text});let p=a.mapping.map(d.pmPos),m=a.doc.resolve(p).nodeAfter;if(m&&m.type.name==="paragraph"){let x=[...(m.attrs.bookmarks||[]).filter(T=>!T.name.startsWith("_Toc")),{id:Math.floor(Math.random()*2147483647),name:c}];a.setNodeMarkup(p,void 0,{...m.attrs,bookmarks:x});}}let l=[];l.push(i.node("paragraph",{styleId:"TOCHeading",alignment:"center"},[i.text("Table of Contents",[i.marks.bold.create()])]));for(let d of s){let c=d.level*720,p=`TOC${d.level+1}`,f=i.marks.hyperlink.create({href:`#${d.name}`});l.push(i.node("paragraph",{styleId:p,indentLeft:c>0?c:null},[i.text(d.text,[f])]));}let u=a.mapping.map(n.selection.from);return a.insert(u,prosemirrorModel.Fragment.from(l)),o(a.scrollIntoView()),true},toggleBidi:()=>(n,o)=>{let{$from:r}=n.selection,i=r.parent;if(i.type.name!=="paragraph")return false;let a=i.attrs.bidi||false;return Ot("bidi",a?null:true)(n,o)},setRtl:()=>Ot("bidi",true),setLtr:()=>Ot("bidi",null),setTabs:n=>Ot("tabs",n.length>0?n:null),addTabStop:(n,o="left",r="none")=>(i,a)=>{let{$from:s}=i.selection,l=s.parent;if(l.type.name!=="paragraph")return false;let c=[...(l.attrs.tabs||[]).filter(p=>p.position!==n),{position:n,alignment:o,leader:r}].sort((p,f)=>p.position-f.position);return Ot("tabs",c)(i,a)},removeTabStop:n=>(o,r)=>{let{$from:i}=o.selection,a=i.parent;if(a.type.name!=="paragraph")return false;let l=(a.attrs.tabs||[]).filter(u=>u.position!==n);return Ot("tabs",l.length>0?l:null)(o,r)}}}}});var Gc=ft({name:"history",defaultOptions:{depth:100,newGroupDelay:500},onSchemaReady(e,t){return {plugins:[prosemirrorHistory.history({depth:t.depth,newGroupDelay:t.newGroupDelay})],commands:{undo:()=>prosemirrorHistory.undo,redo:()=>prosemirrorHistory.redo},keyboardShortcuts:{"Mod-z":prosemirrorHistory.undo,"Mod-y":prosemirrorHistory.redo,"Mod-Shift-z":prosemirrorHistory.redo}}}});var Yc=He({name:"bold",schemaMarkName:"bold",markSpec:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs(e){let t=e.style?.fontWeight;return t==="normal"||t==="400"?false:null}},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2})$/.test(e)?null:false}],toDOM(){return ["strong",0]}},onSchemaReady(e){return {commands:{toggleBold:()=>prosemirrorCommands.toggleMark(e.schema.marks.bold)},keyboardShortcuts:{"Mod-b":prosemirrorCommands.toggleMark(e.schema.marks.bold)}}}});var Xc=He({name:"italic",schemaMarkName:"italic",markSpec:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"?null:false}],toDOM(){return ["em",0]}},onSchemaReady(e){return {commands:{toggleItalic:()=>prosemirrorCommands.toggleMark(e.schema.marks.italic)},keyboardShortcuts:{"Mod-i":prosemirrorCommands.toggleMark(e.schema.marks.italic)}}}});function zm(e){let t={};for(let n of e)switch(n.type.name){case "bold":t.bold=true;break;case "italic":t.italic=true;break;case "underline":t.underline={style:n.attrs.style||"single"};break;case "strike":t.strike=true;break;case "textColor":t.color=n.attrs;break;case "highlight":t.highlight=n.attrs.color;break;case "fontSize":t.fontSize=n.attrs.size;break;case "fontFamily":t.fontFamily={ascii:n.attrs.ascii,hAnsi:n.attrs.hAnsi};break;case "superscript":t.vertAlign="superscript";break;case "subscript":t.vertAlign="subscript";break}return t}function Zc(e,t){let{$from:n}=e.selection,o=n.parent;if(o.type.name!=="paragraph"||o.textContent.length>0)return t;let r=t.storedMarks||e.storedMarks||[];if(r.length===0)return t.setNodeMarkup(n.before(),void 0,{...o.attrs,defaultTextFormatting:null});let i=zm(r);return t.setNodeMarkup(n.before(),void 0,{...o.attrs,defaultTextFormatting:i})}function xn(e,t){return (n,o)=>{let{from:r,to:i,empty:a}=n.selection,s=e.create(t);if(a){if(o){let l=e.isInSet(n.storedMarks||n.selection.$from.marks())?(n.storedMarks||n.selection.$from.marks()).filter(d=>d.type!==e):n.storedMarks||n.selection.$from.marks(),u=n.tr.setStoredMarks([...l,s]);u=Zc(n,u),o(u);}return true}return o&&o(n.tr.addMark(r,i,s).scrollIntoView()),true}}function Sn(e){return (t,n)=>{let{from:o,to:r,empty:i}=t.selection;if(i){if(n){let a=(t.storedMarks||t.selection.$from.marks()).filter(l=>l.type!==e),s=t.tr.setStoredMarks(a);s=Zc(t,s),n(s);}return true}return n&&n(t.tr.removeMark(o,r,e).scrollIntoView()),true}}function Ms(e,t){let n=[];return e.bold&&n.push(t.marks.bold.create()),e.italic&&n.push(t.marks.italic.create()),e.underline&&n.push(t.marks.underline.create({style:e.underline.style||"single",color:e.underline.color})),e.strike&&n.push(t.marks.strike.create()),e.doubleStrike&&n.push(t.marks.strike.create({double:true})),e.color&&n.push(t.marks.textColor.create({rgb:e.color.rgb,themeColor:e.color.themeColor,themeTint:e.color.themeTint,themeShade:e.color.themeShade})),e.highlight&&n.push(t.marks.highlight.create({color:e.highlight})),e.fontSize&&n.push(t.marks.fontSize.create({size:e.fontSize})),e.fontFamily&&n.push(t.marks.fontFamily.create({ascii:e.fontFamily.ascii,hAnsi:e.fontFamily.hAnsi,asciiTheme:e.fontFamily.asciiTheme})),e.vertAlign==="superscript"&&n.push(t.marks.superscript.create()),e.vertAlign==="subscript"&&n.push(t.marks.subscript.create()),n}var yr=(e,t)=>{let{from:n,to:o,empty:r}=e.selection;if(r)return t&&t(e.tr.setStoredMarks([])),true;if(t){let i=e.tr;e.doc.nodesBetween(n,o,(a,s)=>{if(a.isText&&a.marks.length>0){let l=Math.max(n,s),u=Math.min(o,s+a.nodeSize);for(let d of a.marks)i=i.removeMark(l,u,d.type);}}),t(i.scrollIntoView());}return true};var Qc=He({name:"underline",schemaMarkName:"underline",markSpec:{attrs:{style:{default:"single"},color:{default:null}},parseDOM:[{tag:"u"},{style:"text-decoration",getAttrs:e=>e.includes("underline")?{}:false}],toDOM(e){let t=e.attrs,n=["text-decoration: underline"];if(t.style&&t.style!=="single"){let r={double:"double",dotted:"dotted",dash:"dashed",wave:"wavy"}[t.style];r&&n.push(`text-decoration-style: ${r}`);}return t.color?.rgb&&n.push(`text-decoration-color: #${t.color.rgb}`),["span",{style:n.join("; ")},0]}},onSchemaReady(e){return {commands:{toggleUnderline:()=>prosemirrorCommands.toggleMark(e.schema.marks.underline),setUnderlineStyle:(t,n)=>xn(e.schema.marks.underline,{style:t,color:n})},keyboardShortcuts:{"Mod-u":prosemirrorCommands.toggleMark(e.schema.marks.underline)}}}});var ed=He({name:"strike",schemaMarkName:"strike",markSpec:{attrs:{double:{default:false}},parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:e=>e.includes("line-through")?{}:false}],toDOM(){return ["s",0]}},onSchemaReady(e){return {commands:{toggleStrike:()=>prosemirrorCommands.toggleMark(e.schema.marks.strike)}}}});var td=He({name:"textColor",schemaMarkName:"textColor",markSpec:{attrs:{rgb:{default:null},themeColor:{default:null},themeTint:{default:null},themeShade:{default:null}},parseDOM:[{style:"color",getAttrs:e=>{let n=e.match(/#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})/);return n?{rgb:n[1].toUpperCase()}:false}}],toDOM(e){let t=e.attrs,n=Oc({color:t});return ["span",{style:n.color?`color: ${n.color}`:""},0]}},onSchemaReady(e){return {commands:{setTextColor:t=>!t.rgb&&!t.themeColor?Sn(e.schema.marks.textColor):xn(e.schema.marks.textColor,t),clearTextColor:()=>Sn(e.schema.marks.textColor)}}}});var nd=He({name:"highlight",schemaMarkName:"highlight",markSpec:{attrs:{color:{default:"yellow"}},parseDOM:[{tag:"mark"},{style:"background-color",getAttrs:e=>e&&e!=="transparent"&&e!=="inherit"?{color:e}:false}],toDOM(e){let t=e.attrs.color;return ["mark",{style:`background-color: ${chunk4VUZBV2S_js.n(t)}`},0]}},onSchemaReady(e){return {commands:{setHighlight:t=>!t||t==="none"?Sn(e.schema.marks.highlight):xn(e.schema.marks.highlight,{color:t}),clearHighlight:()=>Sn(e.schema.marks.highlight)}}}});var od=He({name:"fontSize",schemaMarkName:"fontSize",markSpec:{attrs:{size:{default:24}},parseDOM:[{style:"font-size",getAttrs:e=>{let t=e,n=t.match(/^([\d.]+)px$/);if(n){let i=parseFloat(n[1])*.75;return {size:Math.round(i*2)}}let o=t.match(/^([\d.]+)pt$/);return o?{size:Math.round(parseFloat(o[1])*2)}:false}}],toDOM(e){let n=e.attrs.size/2,o=(n*1.15).toFixed(2);return ["span",{style:`font-size: ${n}pt; line-height: ${o}pt`},0]}},onSchemaReady(e){return {commands:{setFontSize:t=>xn(e.schema.marks.fontSize,{size:t}),clearFontSize:()=>Sn(e.schema.marks.fontSize)}}}});var rd=He({name:"fontFamily",schemaMarkName:"fontFamily",markSpec:{attrs:{ascii:{default:null},hAnsi:{default:null},eastAsia:{default:null},cs:{default:null},asciiTheme:{default:null},hAnsiTheme:{default:null},eastAsiaTheme:{default:null},csTheme:{default:null}},parseDOM:[{style:"font-family",getAttrs:e=>{let n=e.split(",")[0].trim().replace(/['"]/g,"");return n?{ascii:n}:false}}],toDOM(e){let t=e.attrs,n=t.ascii||t.hAnsi;return n?["span",{style:`font-family: ${n.includes(" ")?`"${n}"`:n}, sans-serif`},0]:["span",0]}},onSchemaReady(e){return {commands:{setFontFamily:t=>xn(e.schema.marks.fontFamily,{ascii:t,hAnsi:t}),clearFontFamily:()=>Sn(e.schema.marks.fontFamily)}}}});var id=He({name:"superscript",schemaMarkName:"superscript",markSpec:{excludes:"subscript",parseDOM:[{tag:"sup"}],toDOM(){return ["sup",0]}},onSchemaReady(e){return {commands:{toggleSuperscript:()=>prosemirrorCommands.toggleMark(e.schema.marks.superscript)}}}});var ad=He({name:"subscript",schemaMarkName:"subscript",markSpec:{excludes:"superscript",parseDOM:[{tag:"sub"}],toDOM(){return ["sub",0]}},onSchemaReady(e){return {commands:{toggleSubscript:()=>prosemirrorCommands.toggleMark(e.schema.marks.subscript)}}}});function Wo(e){let t=e.schema.marks.hyperlink;if(!t)return null;let{empty:n,$from:o,from:r,to:i}=e.selection;if(n){let s=e.storedMarks||o.marks();for(let l of s)if(l.type===t)return {href:l.attrs.href,tooltip:l.attrs.tooltip};return null}let a=null;return e.doc.nodesBetween(r,i,s=>{if(s.isText&&a===null){let l=t.isInSet(s.marks);if(l)return a={href:l.attrs.href,tooltip:l.attrs.tooltip},false}return true}),a}function _o(e){let{from:t,to:n,empty:o}=e.selection;return o?"":e.doc.textBetween(t,n,"")}var sd=He({name:"hyperlink",schemaMarkName:"hyperlink",markSpec:{attrs:{href:{},tooltip:{default:null},rId:{default:null}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs:e=>{let t=e;return {href:t.getAttribute("href")||"",tooltip:t.getAttribute("title")||void 0}}}],toDOM(e){let t=e.attrs,n={href:t.href,target:"_blank",rel:"noopener noreferrer"};return t.tooltip&&(n.title=t.tooltip),["a",n,0]}},onSchemaReady(e){let t=e.schema.marks.hyperlink,n=(i,a)=>(s,l)=>{let{from:u,to:d,empty:c}=s.selection;if(c)return false;if(l){let p=t.create({href:i,tooltip:a||null}),f=s.tr.addMark(u,d,p),m=s.schema.marks.textColor;m&&(f=f.removeMark(u,d,m)),l(f.scrollIntoView());}return true},o=(i,a)=>{let{from:s,to:l,empty:u}=i.selection;if(u){let d=i.selection.$from;if(!d.marks().find(g=>g.type===t))return false;let f=d.pos,m=d.pos;return d.parent.forEach((g,x)=>{if(g.isText){let T=d.start()+x,S=T+g.nodeSize;T<=d.pos&&d.pos<=S&&g.marks.some(C=>C.type===t)&&(f=Math.min(f,T),m=Math.max(m,S));}}),a&&a(i.tr.removeMark(f,m,t).scrollIntoView()),true}return a&&a(i.tr.removeMark(s,l,t).scrollIntoView()),true};return {commands:{setHyperlink:n,removeHyperlink:()=>o,insertHyperlink:(i,a,s)=>(l,u)=>{if(u){let d=t.create({href:a,tooltip:s||null}),c=l.schema.text(i,[d]);u(l.tr.replaceSelectionWith(c,false).scrollIntoView());}return true}}}}});var ld=He({name:"allCaps",schemaMarkName:"allCaps",markSpec:{parseDOM:[{style:"text-transform",getAttrs:e=>e==="uppercase"?{}:false}],toDOM(){return ["span",{style:"text-transform: uppercase"},0]}}});var cd=He({name:"smallCaps",schemaMarkName:"smallCaps",markSpec:{parseDOM:[{style:"font-variant",getAttrs:e=>e==="small-caps"?{}:false}],toDOM(){return ["span",{style:"font-variant: small-caps"},0]}}});var dd=He({name:"footnoteRef",schemaMarkName:"footnoteRef",markSpec:{attrs:{id:{},noteType:{default:"footnote"}},parseDOM:[{tag:"sup.docx-footnote-ref",getAttrs:e=>{let t=e;return {id:t.dataset.id||"",noteType:t.dataset.noteType||"footnote"}}}],toDOM(e){let t=e.attrs;return ["sup",{class:`docx-${t.noteType}-ref`,"data-id":t.id,"data-note-type":t.noteType},0]}},onSchemaReady(e){let{schema:t}=e;function n(r){return i=>(a,s)=>{if(!s)return true;let l=t.marks.footnoteRef.create({id:String(i),noteType:r}),u=t.text(String(i),[l]),d=a.tr.replaceSelectionWith(u,false);return s(d.scrollIntoView()),true}}let o=(r,i)=>{let{$from:a,$to:s}=r.selection;if(!i)return true;let l=r.tr,u=t.marks.footnoteRef;return l=l.removeMark(a.pos,s.pos,u),i(l.scrollIntoView()),true};return {commands:{insertFootnote:n("footnote"),insertEndnote:n("endnote"),deleteNoteRef:()=>o}}}});function _m(e){return e/2*(96/72)}var ud=He({name:"characterSpacing",schemaMarkName:"characterSpacing",markSpec:{attrs:{spacing:{default:null},position:{default:null},scale:{default:null},kerning:{default:null}},parseDOM:[{tag:"span.docx-char-spacing",getAttrs:e=>{let t=e;return {spacing:t.dataset.spacing?Number(t.dataset.spacing):null,position:t.dataset.position?Number(t.dataset.position):null,scale:t.dataset.scale?Number(t.dataset.scale):null,kerning:t.dataset.kerning?Number(t.dataset.kerning):null}}}],toDOM(e){let t=e.attrs,n=[],o={class:"docx-char-spacing"};if(t.spacing!=null&&t.spacing!==0&&(n.push(`letter-spacing: ${chunkSE5EN2QL_js.k(chunkSE5EN2QL_js.a(t.spacing))}`),o["data-spacing"]=String(t.spacing)),t.position!=null&&t.position!==0){let r=_m(t.position);n.push(`vertical-align: ${chunkSE5EN2QL_js.k(r)}`),o["data-position"]=String(t.position);}return t.scale!=null&&t.scale!==100&&(n.push(`transform: scaleX(${t.scale/100})`),n.push("display: inline-block"),o["data-scale"]=String(t.scale)),t.kerning!=null&&(o["data-kerning"]=String(t.kerning)),n.length>0&&(o.style=n.join("; ")),["span",o,0]}}});var pd=He({name:"comment",schemaMarkName:"comment",markSpec:{attrs:{commentId:{default:0}},inclusive:false,parseDOM:[{tag:"span.docx-comment",getAttrs(e){return {commentId:parseInt(e.dataset.commentId||"0",10)}}}],toDOM(e){return ["span",{class:"docx-comment","data-comment-id":String(e.attrs.commentId),style:"background-color: rgba(255, 212, 0, 0.25); border-bottom: 2px solid rgba(255, 212, 0, 0.6);"},0]}}});var fd=He({name:"insertion",schemaMarkName:"insertion",markSpec:{attrs:{revisionId:{default:0},author:{default:""},date:{default:null}},inclusive:false,parseDOM:[{tag:"span.docx-insertion",getAttrs(e){let t=e;return {revisionId:parseInt(t.dataset.revisionId||"0",10),author:t.dataset.author||"",date:t.dataset.date||null}}}],toDOM(e){return ["span",{class:"docx-insertion","data-revision-id":String(e.attrs.revisionId),"data-author":e.attrs.author,...e.attrs.date?{"data-date":e.attrs.date}:{},style:"color: #2e7d32; text-decoration: underline; text-decoration-color: #2e7d32;"},0]}}}),md=He({name:"deletion",schemaMarkName:"deletion",markSpec:{attrs:{revisionId:{default:0},author:{default:""},date:{default:null}},inclusive:false,parseDOM:[{tag:"span.docx-deletion",getAttrs(e){let t=e;return {revisionId:parseInt(t.dataset.revisionId||"0",10),author:t.dataset.author||"",date:t.dataset.date||null}}}],toDOM(e){return ["span",{class:"docx-deletion","data-revision-id":String(e.attrs.revisionId),"data-author":e.attrs.author,...e.attrs.date?{"data-date":e.attrs.date}:{},style:"color: #c62828; text-decoration: line-through; text-decoration-color: #c62828;"},0]}}});var gd=He({name:"emboss",schemaMarkName:"emboss",markSpec:{parseDOM:[{tag:"span.docx-emboss"}],toDOM(){return ["span",{class:"docx-emboss",style:"text-shadow: 1px 1px 1px rgba(255,255,255,0.5), -1px -1px 1px rgba(0,0,0,0.3)"},0]}}}),hd=He({name:"imprint",schemaMarkName:"imprint",markSpec:{parseDOM:[{tag:"span.docx-imprint"}],toDOM(){return ["span",{class:"docx-imprint",style:"-1px -1px 1px rgba(255,255,255,0.5), 1px 1px 1px rgba(0,0,0,0.3)"},0]}}}),bd=He({name:"textShadow",schemaMarkName:"textShadow",markSpec:{parseDOM:[{tag:"span.docx-text-shadow"}],toDOM(){return ["span",{class:"docx-text-shadow",style:"text-shadow: 1px 1px 2px rgba(0,0,0,0.3)"},0]}}}),yd=He({name:"emphasisMark",schemaMarkName:"emphasisMark",markSpec:{attrs:{type:{default:"dot"}},parseDOM:[{tag:"span.docx-emphasis-mark",getAttrs:e=>({type:e.dataset.emType||"dot"})}],toDOM(e){let t=e.attrs.type,n="filled dot";switch(t){case "dot":n="filled dot";break;case "comma":n="filled sesame";break;case "circle":n="filled circle";break;case "underDot":n="filled dot";break}let o=t==="underDot"?"under right":"over right";return ["span",{class:"docx-emphasis-mark","data-em-type":t,style:`text-emphasis: ${n}; text-emphasis-position: ${o}; -webkit-text-emphasis: ${n}; -webkit-text-emphasis-position: ${o}`},0]}}}),xd=He({name:"textOutline",schemaMarkName:"textOutline",markSpec:{parseDOM:[{tag:"span.docx-text-outline"}],toDOM(){return ["span",{class:"docx-text-outline",style:"-webkit-text-stroke: 1px currentColor; -webkit-text-fill-color: transparent"},0]}}});var Sd=Qe({name:"hardBreak",schemaNodeName:"hardBreak",nodeSpec:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return ["br"]}},onSchemaReady(e){let t=e.schema.nodes.hardBreak;return {keyboardShortcuts:{"Shift-Enter":(n,o)=>(o&&o(n.tr.replaceSelectionWith(t.create()).scrollIntoView()),true)}}}});var kd=Qe({name:"tab",schemaNodeName:"tab",nodeSpec:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"span.docx-tab"}],toDOM(){return ["span",{class:"docx-tab",style:"display: inline-block; min-width: 16px; white-space: pre;"}," "]}}});var Td=Qe({name:"image",schemaNodeName:"image",nodeSpec:{inline:true,group:"inline",draggable:true,attrs:{src:{},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},rId:{default:null},wrapType:{default:"inline"},displayMode:{default:"inline"},cssFloat:{default:null},transform:{default:null},distTop:{default:null},distBottom:{default:null},distLeft:{default:null},distRight:{default:null},position:{default:null},borderWidth:{default:null},borderColor:{default:null},borderStyle:{default:null},wrapText:{default:null},hlinkHref:{default:null}},parseDOM:[{tag:"img[src]",getAttrs(e){let t=e;return {src:t.getAttribute("src")||"",alt:t.getAttribute("alt")||void 0,title:t.getAttribute("title")||void 0,width:t.width||void 0,height:t.height||void 0,rId:t.dataset.rid||void 0,wrapType:t.dataset.wrapType||"inline",displayMode:t.dataset.displayMode||"inline",cssFloat:t.dataset.cssFloat||void 0,transform:t.dataset.transform||void 0,borderWidth:t.dataset.borderWidth?Number(t.dataset.borderWidth):void 0,borderColor:t.dataset.borderColor||void 0,borderStyle:t.dataset.borderStyle||void 0}}}],toDOM(e){let t=e.attrs,n={src:t.src,class:"docx-image"};t.alt&&(n.alt=t.alt),t.title&&(n.title=t.title),t.rId&&(n["data-rid"]=t.rId),t.wrapType&&(n["data-wrap-type"]=t.wrapType),t.displayMode&&(n["data-display-mode"]=t.displayMode),t.cssFloat&&(n["data-css-float"]=t.cssFloat),t.transform&&(n["data-transform"]=t.transform),t.borderWidth&&(n["data-border-width"]=String(t.borderWidth)),t.borderColor&&(n["data-border-color"]=t.borderColor),t.borderStyle&&(n["data-border-style"]=t.borderStyle);let o=[];if(t.width&&(n.width=String(t.width),o.push(`width: ${t.width}px`)),t.height&&(n.height=String(t.height),o.push(`height: ${t.height}px`)),o.push("max-width: 100%"),t.width&&t.height?o.push("object-fit: contain"):o.push("height: auto"),t.displayMode==="float"&&t.cssFloat&&t.cssFloat!=="none"){o.push(`float: ${t.cssFloat}`),n.class+=` docx-image-float docx-image-float-${t.cssFloat}`;let r=t.distTop??0,i=t.distBottom??0,a=t.distLeft??0,s=t.distRight??0;t.cssFloat==="left"?o.push(`margin: ${r}px ${s||12}px ${i}px ${a}px`):o.push(`margin: ${r}px ${s}px ${i}px ${a||12}px`);}else if(t.displayMode==="block"){o.push("display: block"),o.push("margin-left: auto"),o.push("margin-right: auto"),n.class+=" docx-image-block";let r=t.distTop??0,i=t.distBottom??0;r>0&&o.push(`margin-top: ${r}px`),i>0&&o.push(`margin-bottom: ${i}px`);}if(t.transform&&o.push(`transform: ${t.transform}`),t.borderWidth&&t.borderWidth>0){let r=t.borderStyle||"solid",i=t.borderColor||"#000000";o.push(`border: ${t.borderWidth}px ${r} ${i}`);}return n.style=o.join("; "),["img",n]}}});var wd=Qe({name:"textBox",schemaNodeName:"textBox",nodeSpec:{group:"block",content:"(paragraph | table)+",isolating:true,draggable:true,attrs:{width:{default:200},height:{default:null},textBoxId:{default:null},fillColor:{default:null},outlineWidth:{default:null},outlineColor:{default:null},outlineStyle:{default:null},marginTop:{default:4},marginBottom:{default:4},marginLeft:{default:7},marginRight:{default:7},verticalAlign:{default:null},displayMode:{default:"inline"},cssFloat:{default:null},wrapType:{default:"inline"}},parseDOM:[{tag:"div.docx-textbox",getAttrs(e){let t=e;return {width:t.dataset.width?Number(t.dataset.width):void 0,height:t.dataset.height?Number(t.dataset.height):void 0,textBoxId:t.dataset.textboxId||void 0,fillColor:t.dataset.fillColor||void 0,outlineWidth:t.dataset.outlineWidth?Number(t.dataset.outlineWidth):void 0,outlineColor:t.dataset.outlineColor||void 0,outlineStyle:t.dataset.outlineStyle||void 0,marginTop:t.dataset.marginTop?Number(t.dataset.marginTop):void 0,marginBottom:t.dataset.marginBottom?Number(t.dataset.marginBottom):void 0,marginLeft:t.dataset.marginLeft?Number(t.dataset.marginLeft):void 0,marginRight:t.dataset.marginRight?Number(t.dataset.marginRight):void 0,verticalAlign:t.dataset.verticalAlign||void 0,displayMode:t.dataset.displayMode||void 0,cssFloat:t.dataset.cssFloat||void 0,wrapType:t.dataset.wrapType||void 0}}}],toDOM(e){let t=e.attrs,n={class:"docx-textbox"};t.width&&(n["data-width"]=String(t.width)),t.height&&(n["data-height"]=String(t.height)),t.textBoxId&&(n["data-textbox-id"]=t.textBoxId),t.fillColor&&(n["data-fill-color"]=t.fillColor),t.outlineWidth&&(n["data-outline-width"]=String(t.outlineWidth)),t.outlineColor&&(n["data-outline-color"]=t.outlineColor),t.outlineStyle&&(n["data-outline-style"]=t.outlineStyle),t.marginTop!=null&&(n["data-margin-top"]=String(t.marginTop)),t.marginBottom!=null&&(n["data-margin-bottom"]=String(t.marginBottom)),t.marginLeft!=null&&(n["data-margin-left"]=String(t.marginLeft)),t.marginRight!=null&&(n["data-margin-right"]=String(t.marginRight)),t.verticalAlign&&(n["data-vertical-align"]=t.verticalAlign),t.displayMode&&(n["data-display-mode"]=t.displayMode),t.cssFloat&&(n["data-css-float"]=t.cssFloat),t.wrapType&&(n["data-wrap-type"]=t.wrapType);let o=[];if(t.width&&o.push(`width: ${t.width}px`),t.height&&o.push(`min-height: ${t.height}px`),t.fillColor&&o.push(`background-color: ${t.fillColor}`),t.outlineWidth&&t.outlineWidth>0){let l=t.outlineStyle||"solid",u=t.outlineColor||"#000000";o.push(`border: ${t.outlineWidth}px ${l} ${u}`);}else o.push("border: 1px solid var(--doc-border, #d1d5db)");let r=t.marginTop??4,i=t.marginBottom??4,a=t.marginLeft??7,s=t.marginRight??7;return o.push(`padding: ${r}px ${s}px ${i}px ${a}px`),t.verticalAlign==="middle"||t.verticalAlign==="center"?(o.push("display: flex"),o.push("flex-direction: column"),o.push("justify-content: center")):t.verticalAlign==="bottom"&&(o.push("display: flex"),o.push("flex-direction: column"),o.push("justify-content: flex-end")),t.displayMode==="float"&&t.cssFloat&&t.cssFloat!=="none"?(o.push(`float: ${t.cssFloat}`),o.push("margin: 4px 8px")):t.displayMode==="block"&&(o.push("margin-left: auto"),o.push("margin-right: auto")),o.push("box-sizing: border-box"),o.push("overflow: hidden"),o.push("position: relative"),n.style=o.join("; "),["div",n,0]}}});function Vm(e,t,n){switch(e){case "ellipse":case "oval":return `<ellipse cx="${t/2}" cy="${n/2}" rx="${t/2}" ry="${n/2}" />`;case "roundRect":return `<rect x="0" y="0" width="${t}" height="${n}" rx="${Math.min(t,n)*.1}" />`;case "triangle":case "isosTriangle":return `<polygon points="${t/2},0 ${t},${n} 0,${n}" />`;case "diamond":return `<polygon points="${t/2},0 ${t},${n/2} ${t/2},${n} 0,${n/2}" />`;case "line":case "straightConnector1":return `<line x1="0" y1="${n/2}" x2="${t}" y2="${n/2}" />`;default:return `<rect x="0" y="0" width="${t}" height="${n}" />`}}function Um(e,t){let n="";try{n=JSON.parse(t.gradientStops||"[]").map(c=>`<stop offset="${Math.round(c.position/1e3)}%" stop-color="${c.color}" />`).join("");}catch{return ""}let o=t.gradientType||"linear";if(o==="radial"||o==="rectangular"||o==="path")return `<radialGradient id="${e}" cx="50%" cy="50%" r="50%">${n}</radialGradient>`;let i=((t.gradientAngle||0)-90)*Math.PI/180,a=Math.round(50+50*Math.cos(i+Math.PI)),s=Math.round(50+50*Math.sin(i+Math.PI)),l=Math.round(50+50*Math.cos(i)),u=Math.round(50+50*Math.sin(i));return `<linearGradient id="${e}" x1="${a}%" y1="${s}%" x2="${l}%" y2="${u}%">${n}</linearGradient>`}var Cd=Qe({name:"shape",schemaNodeName:"shape",nodeSpec:{inline:true,group:"inline",draggable:true,atom:true,attrs:{shapeType:{default:"rect"},shapeId:{default:null},width:{default:100},height:{default:80},fillColor:{default:null},fillType:{default:"solid"},gradientType:{default:null},gradientAngle:{default:null},gradientStops:{default:null},outlineWidth:{default:1},outlineColor:{default:"#000000"},outlineStyle:{default:"solid"},transform:{default:null},displayMode:{default:"inline"},cssFloat:{default:null},wrapType:{default:"inline"},shadowColor:{default:null},shadowBlur:{default:null},shadowOffsetX:{default:null},shadowOffsetY:{default:null},glowColor:{default:null},glowRadius:{default:null}},parseDOM:[{tag:"span.docx-shape",getAttrs(e){let t=e;return {shapeType:t.dataset.shapeType||"rect",shapeId:t.dataset.shapeId||void 0,width:t.dataset.width?Number(t.dataset.width):void 0,height:t.dataset.height?Number(t.dataset.height):void 0,fillColor:t.dataset.fillColor||void 0,fillType:t.dataset.fillType||"solid",gradientType:t.dataset.gradientType||void 0,gradientAngle:t.dataset.gradientAngle?Number(t.dataset.gradientAngle):void 0,gradientStops:t.dataset.gradientStops||void 0,outlineWidth:t.dataset.outlineWidth?Number(t.dataset.outlineWidth):void 0,outlineColor:t.dataset.outlineColor||void 0,outlineStyle:t.dataset.outlineStyle||void 0,transform:t.dataset.transform||void 0,displayMode:t.dataset.displayMode||void 0,cssFloat:t.dataset.cssFloat||void 0,wrapType:t.dataset.wrapType||void 0,shadowColor:t.dataset.shadowColor||void 0,shadowBlur:t.dataset.shadowBlur?Number(t.dataset.shadowBlur):void 0,shadowOffsetX:t.dataset.shadowOffsetX?Number(t.dataset.shadowOffsetX):void 0,shadowOffsetY:t.dataset.shadowOffsetY?Number(t.dataset.shadowOffsetY):void 0,glowColor:t.dataset.glowColor||void 0,glowRadius:t.dataset.glowRadius?Number(t.dataset.glowRadius):void 0}}}],toDOM(e){let t=e.attrs,n=t.width||100,o=t.height||80,r={class:"docx-shape","data-shape-type":t.shapeType||"rect"};t.shapeId&&(r["data-shape-id"]=t.shapeId),r["data-width"]=String(n),r["data-height"]=String(o),t.fillColor&&(r["data-fill-color"]=t.fillColor),t.fillType&&(r["data-fill-type"]=t.fillType),t.gradientType&&(r["data-gradient-type"]=t.gradientType),t.gradientAngle!=null&&(r["data-gradient-angle"]=String(t.gradientAngle)),t.gradientStops&&(r["data-gradient-stops"]=t.gradientStops),t.outlineWidth&&(r["data-outline-width"]=String(t.outlineWidth)),t.outlineColor&&(r["data-outline-color"]=t.outlineColor),t.outlineStyle&&(r["data-outline-style"]=t.outlineStyle),t.transform&&(r["data-transform"]=t.transform),t.displayMode&&(r["data-display-mode"]=t.displayMode),t.cssFloat&&(r["data-css-float"]=t.cssFloat),t.wrapType&&(r["data-wrap-type"]=t.wrapType),t.shadowColor&&(r["data-shadow-color"]=t.shadowColor),t.shadowBlur!=null&&(r["data-shadow-blur"]=String(t.shadowBlur)),t.shadowOffsetX!=null&&(r["data-shadow-offset-x"]=String(t.shadowOffsetX)),t.shadowOffsetY!=null&&(r["data-shadow-offset-y"]=String(t.shadowOffsetY)),t.glowColor&&(r["data-glow-color"]=t.glowColor),t.glowRadius!=null&&(r["data-glow-radius"]=String(t.glowRadius));let i=["display: inline-block",`width: ${n}px`,`height: ${o}px`,"vertical-align: middle","line-height: 0"];if(t.transform&&i.push(`transform: ${t.transform}`),t.displayMode==="float"&&t.cssFloat&&t.cssFloat!=="none"?(i.push(`float: ${t.cssFloat}`),i.push("margin: 4px 8px")):t.displayMode==="block"&&(i.push("display: block"),i.push("margin: 4px auto")),t.shadowColor){let m=t.shadowOffsetX||2,b=t.shadowOffsetY||2,g=t.shadowBlur||4;i.push(`filter: drop-shadow(${m}px ${b}px ${g}px ${t.shadowColor})`);}if(t.glowColor&&t.glowRadius){let m=i.find(g=>g.startsWith("filter:")),b=`drop-shadow(0 0 ${t.glowRadius}px ${t.glowColor})`;if(m){let g=i.indexOf(m);i[g]=m+" "+b;}else i.push(`filter: ${b}`);}r.style=i.join("; ");let a="",s;if(t.fillType==="gradient"&&t.gradientStops){let m=`grad-${t.shapeId||Math.random().toString(36).slice(2,8)}`;s=`url(#${m})`,a=Um(m,t);}else s=t.fillType==="none"?"none":t.fillColor||"#ffffff";let l=t.outlineWidth||1,u=t.outlineColor||"#000000",d=t.outlineStyle==="dashed"?' stroke-dasharray="8 4"':t.outlineStyle==="dotted"?' stroke-dasharray="2 2"':"",c=Vm(t.shapeType||"rect",n,o),p=`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${o}" viewBox="0 0 ${n} ${o}" style="fill:${s};stroke:${u};stroke-width:${l}${d}">`+(a?`<defs>${a}</defs>`:"")+c+"</svg>",f=document.createElement("span");return Object.entries(r).forEach(([m,b])=>{f.setAttribute(m,b);}),f.innerHTML=p,{dom:f}}}});var vd=Qe({name:"horizontalRule",schemaNodeName:"horizontalRule",nodeSpec:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return ["hr"]}}});var Rd=Qe({name:"pageBreak",schemaNodeName:"pageBreak",nodeSpec:{group:"block",atom:true,selectable:true,parseDOM:[{tag:"div.docx-page-break"}],toDOM(){return ["div",{class:"docx-page-break"}]}}});var Ed=Qe({name:"field",schemaNodeName:"field",nodeSpec:{inline:true,group:"inline",atom:true,selectable:true,attrs:{fieldType:{default:"UNKNOWN"},instruction:{default:""},displayText:{default:""},fieldKind:{default:"simple"},fldLock:{default:false},dirty:{default:false}},parseDOM:[{tag:"span.docx-field",getAttrs(e){let t=e;return {fieldType:t.dataset.fieldType||"UNKNOWN",instruction:t.dataset.instruction||"",displayText:t.textContent||"",fieldKind:t.dataset.fieldKind||"simple",fldLock:t.dataset.fldLock==="true",dirty:t.dataset.dirty==="true"}}}],toDOM(e){let{fieldType:t,instruction:n,displayText:o,fieldKind:r,fldLock:i,dirty:a}=e.attrs,s=o||"";if(!s)switch(t){case "PAGE":s="{page}";break;case "NUMPAGES":s="{pages}";break;case "DATE":case "TIME":case "CREATEDATE":case "SAVEDATE":s=new Date().toLocaleDateString();break;case "MERGEFIELD":s=`\xAB${n.replace(/^MERGEFIELD\s+/i,"").replace(/\s*\\.*$/,"")}\xBB`;break;default:s=`{${t}}`;}return ["span",{class:`docx-field docx-field-${t.toLowerCase()}`,"data-field-type":t,"data-instruction":n,"data-field-kind":r,...i?{"data-fld-lock":"true"}:{},...a?{"data-dirty":"true"}:{},style:"outline: 1px solid rgba(200,200,200,0.4); padding: 0 1px; border-radius: 2px;"},s]}}});var Md=Qe({name:"sdt",schemaNodeName:"sdt",nodeSpec:{inline:true,group:"inline",content:"inline*",attrs:{sdtType:{default:"richText"},alias:{default:null},tag:{default:null},lock:{default:null},placeholder:{default:null},showingPlaceholder:{default:false},dateFormat:{default:null},listItems:{default:null},checked:{default:null}},parseDOM:[{tag:"span.docx-sdt",getAttrs(e){let t=e;return {sdtType:t.dataset.sdtType||"richText",alias:t.dataset.alias||null,tag:t.dataset.tag||null,lock:t.dataset.lock||null,placeholder:t.dataset.placeholder||null,showingPlaceholder:t.dataset.showingPlaceholder==="true",dateFormat:t.dataset.dateFormat||null,listItems:t.dataset.listItems||null,checked:t.dataset.checked==="true"?true:t.dataset.checked==="false"?false:null}}}],toDOM(e){let t=e.attrs,n={class:`docx-sdt docx-sdt-${t.sdtType}`,"data-sdt-type":String(t.sdtType)};return t.alias&&(n["data-alias"]=String(t.alias)),t.tag&&(n["data-tag"]=String(t.tag)),t.lock&&(n["data-lock"]=String(t.lock)),t.placeholder&&(n["data-placeholder"]=String(t.placeholder)),t.showingPlaceholder&&(n["data-showing-placeholder"]="true"),t.dateFormat&&(n["data-date-format"]=String(t.dateFormat)),t.listItems&&(n["data-list-items"]=String(t.listItems)),t.checked!=null&&(n["data-checked"]=String(t.checked)),t.sdtType==="checkbox"?n.style="border: 1px solid #ccc; border-radius: 3px; padding: 0 2px; display: inline;":n.style="border-bottom: 1px dashed #999; padding: 0 1px; display: inline;",["span",n,0]}}});var Pd=Qe({name:"math",schemaNodeName:"math",nodeSpec:{inline:true,group:"inline",atom:true,selectable:true,attrs:{display:{default:"inline"},ommlXml:{default:""},plainText:{default:""}},parseDOM:[{tag:"span.docx-math",getAttrs(e){let t=e;return {display:t.dataset.display||"inline",ommlXml:t.dataset.ommlXml||"",plainText:t.textContent||""}}}],toDOM(e){let{display:t,ommlXml:n,plainText:o}=e.attrs,r=o||"[equation]";return ["span",{class:`docx-math docx-math-${t}`,"data-display":t,"data-omml-xml":n,style:'font-style: italic; font-family: "Cambria Math", "Latin Modern Math", serif; background: rgba(200,200,255,0.1); padding: 0 2px; border-radius: 2px;'},r]}}});function Qm(e){switch(e.toLowerCase()){case "solid":return "single";case "double":return "double";case "dotted":return "dotted";case "dashed":return "dashed";case "groove":return "threeDEngrave";case "ridge":return "threeDEmboss";case "inset":return "inset";case "outset":return "outset";default:return "single"}}function eg(e){if(!e)return 8;let t=e.trim().toLowerCase();if(t==="thin")return 4;if(t==="medium")return 8;if(t==="thick")return 16;let n=parseFloat(t);return isNaN(n)?8:t.endsWith("pt")?Math.round(n*8):(t.endsWith("px"),Math.round(n*6))}function Id(e){if(!e||e==="transparent"||e==="inherit")return null;let t=e.match(/#([0-9a-fA-F]{6})/);if(t)return {rgb:t[1].toUpperCase()};let n=e.match(/#([0-9a-fA-F]{3})$/);if(n){let[r,i,a]=n[1];return {rgb:(r+r+i+i+a+a).toUpperCase()}}let o=e.match(/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);return o?{rgb:[o[1],o[2],o[3]].map(i=>parseInt(i).toString(16).padStart(2,"0")).join("").toUpperCase()}:null}function tg(e){let t=(a,s,l)=>{if(!(!a||a==="none"||a==="hidden"))return {style:Qm(a),color:Id(s)||void 0,size:eg(l)}},n=t(e.borderTopStyle,e.borderTopColor,e.borderTopWidth),o=t(e.borderBottomStyle,e.borderBottomColor,e.borderBottomWidth),r=t(e.borderLeftStyle,e.borderLeftColor,e.borderLeftWidth),i=t(e.borderRightStyle,e.borderRightColor,e.borderRightWidth);return !n&&!o&&!r&&!i?null:{top:n,bottom:o,left:r,right:i}}function ng(e){let t=a=>{if(!a||a==="0px")return;let s=parseFloat(a);if(!(isNaN(s)||s===0))return a.endsWith("pt")?Math.round(s*20):Math.round(s*15)},n=t(e.paddingTop),o=t(e.paddingRight),r=t(e.paddingBottom),i=t(e.paddingLeft);return n===void 0&&o===void 0&&r===void 0&&i===void 0?null:{top:n,right:o,bottom:r,left:i}}function og(e){if(e)switch(e.toLowerCase()){case "top":return "top";case "middle":return "center";case "bottom":return "bottom";default:return}}function rg(e){return Id(e)?.rgb}function Fd(e){let t=e.style,n=tg(t),o=ng(t);return {colspan:e.colSpan||1,rowspan:e.rowSpan||1,verticalAlign:e.dataset.valign||og(t.verticalAlign)||void 0,backgroundColor:e.dataset.bgcolor||rg(t.backgroundColor)||void 0,borders:n||void 0,margins:o||void 0}}var ig={content:"tableRow+",group:"block",tableRole:"table",isolating:true,attrs:{styleId:{default:null},width:{default:null},widthType:{default:null},justification:{default:null},columnWidths:{default:null},floating:{default:null},cellMargins:{default:null},look:{default:null},_originalFormatting:{default:null}},parseDOM:[{tag:"table",getAttrs(e){let t=e;return {styleId:t.dataset.styleId||void 0,justification:t.dataset.justification}}}],toDOM(e){let t=e.attrs,n={class:"docx-table"};t.styleId&&(n["data-style-id"]=t.styleId);let o=["border-collapse: collapse"];if(t.width&&t.widthType==="pct")o.push(`width: ${t.width/50}%`),o.push("table-layout: fixed");else if(t.width&&t.widthType==="dxa"){let r=Math.round(t.width/20*1.333);o.push(`width: ${r}px`),o.push("table-layout: fixed");}else o.push("width: 100%"),o.push("table-layout: fixed");return t.justification==="center"?o.push("margin-left: auto","margin-right: auto"):t.justification==="right"&&o.push("margin-left: auto"),n.style=o.join("; "),["table",n,["tbody",0]]}},ag={content:"(tableCell | tableHeader)+",tableRole:"row",attrs:{height:{default:null},heightRule:{default:null},isHeader:{default:false},_originalFormatting:{default:null}},parseDOM:[{tag:"tr"}],toDOM(e){let t=e.attrs,n={};if(t.height){let o=Math.round(t.height/20*1.333);n.style=`height: ${o}px`;}return ["tr",n,0]}},sg={single:"solid",double:"double",dotted:"dotted",dashed:"dashed",thick:"solid",dashSmallGap:"dashed",dotDash:"dashed",dotDotDash:"dotted",triple:"double",thinThickSmallGap:"double",thickThinSmallGap:"double",thinThickThinSmallGap:"double",thinThickMediumGap:"double",thickThinMediumGap:"double",thinThickThinMediumGap:"double",thinThickLargeGap:"double",thickThinLargeGap:"double",thinThickThinLargeGap:"double",wave:"solid",doubleWave:"double",dashDotStroked:"dashed",threeDEmboss:"ridge",threeDEngrave:"groove",outset:"outset",inset:"inset"};function Ld(e){let t=[],n=e.borders;if(!n)return t;let o=r=>{if(!r||!r.style||r.style==="none"||r.style==="nil")return "none";let i=r.size?Math.max(1,Math.round(r.size/8*1.333)):1,a=sg[r.style]||"solid",s=r.color?.rgb?`#${r.color.rgb}`:"#000000";return `${i}px ${a} ${s}`};return t.push(`border-top: ${o(n.top)}`),t.push(`border-bottom: ${o(n.bottom)}`),t.push(`border-left: ${o(n.left)}`),t.push(`border-right: ${o(n.right)}`),t}function Bd(e){let t=e.margins;if(!t){let s=Math.round(7.1982);return [`padding: ${s}px ${s}px`]}let n=s=>s?Math.round(s/20*1.333):0,o=n(t.top),r=n(t.right),i=n(t.bottom),a=n(t.left);return [`padding: ${o}px ${r}px ${i}px ${a}px`]}function Ad(e){if(!e)return [];let t=[];switch(e){case "tbRl":case "tbRlV":t.push("writing-mode: vertical-rl");break;case "btLr":t.push("writing-mode: vertical-lr","transform: rotate(180deg)");break;case "rl":case "rlV":t.push("direction: rtl");break;case "tb":case "tbV":t.push("writing-mode: vertical-lr");break}return t}function Dd(e){let t=[];if(e.colwidth&&e.colwidth.length>0){let n=e.colwidth.reduce((o,r)=>o+r,0);t.push(`width: ${n}px`);}else if(e.width&&e.widthType==="pct")t.push(`width: ${e.width}%`);else if(e.width){let n=Math.round(e.width/20*1.333);t.push(`width: ${n}px`);}return t}var lg={content:"(paragraph | table)+",tableRole:"cell",isolating:true,attrs:{colspan:{default:1},rowspan:{default:1},colwidth:{default:null},width:{default:null},widthType:{default:null},verticalAlign:{default:null},backgroundColor:{default:null},borders:{default:null},margins:{default:null},textDirection:{default:null},noWrap:{default:false},_originalFormatting:{default:null}},parseDOM:[{tag:"td",getAttrs:e=>Fd(e)}],toDOM(e){let t=e.attrs,n={class:"docx-table-cell"};t.colspan>1&&(n.colspan=String(t.colspan)),t.rowspan>1&&(n.rowspan=String(t.rowspan));let o=[];return o.push(...Bd(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...Dd(t)),o.push(...Ld(t)),o.push(...Ad(t.textDirection)),t.verticalAlign&&(n["data-valign"]=t.verticalAlign,o.push(`vertical-align: ${t.verticalAlign}`)),t.backgroundColor&&(n["data-bgcolor"]=t.backgroundColor,o.push(`background-color: #${t.backgroundColor}`)),n.style=o.join("; "),["td",n,0]}},cg={content:"(paragraph | table)+",tableRole:"header_cell",isolating:true,attrs:{colspan:{default:1},rowspan:{default:1},colwidth:{default:null},width:{default:null},widthType:{default:null},verticalAlign:{default:null},backgroundColor:{default:null},borders:{default:null},margins:{default:null},textDirection:{default:null},noWrap:{default:false},_originalFormatting:{default:null}},parseDOM:[{tag:"th",getAttrs:e=>Fd(e)}],toDOM(e){let t=e.attrs,n={class:"docx-table-header"};t.colspan>1&&(n.colspan=String(t.colspan)),t.rowspan>1&&(n.rowspan=String(t.rowspan));let o=["font-weight: bold"];return o.push(...Bd(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...Dd(t)),o.push(...Ld(t)),o.push(...Ad(t.textDirection)),t.verticalAlign&&(n["data-valign"]=t.verticalAlign,o.push(`vertical-align: ${t.verticalAlign}`)),t.backgroundColor&&(n["data-bgcolor"]=t.backgroundColor,o.push(`background-color: #${t.backgroundColor}`)),n.style=o.join("; "),["th",n,0]}};function qe(e){let{selection:t}=e,{$from:n}=t,o=t instanceof prosemirrorTables.CellSelection,r,i,a,s,l;for(let m=n.depth;m>0;m--){let b=n.node(m);if(b.type.name==="tableCell"||b.type.name==="tableHeader"){l=b;let g=n.node(m-1);if(g&&g.type.name==="tableRow"){let x=0,T=false;g.forEach((S,B,C)=>{T||(C===n.index(m-1)?(s=x,T=true):x+=S.attrs.colspan||1);});}}else if(b.type.name==="tableRow"){let g=n.node(m-1);g&&g.type.name==="table"&&(a=n.index(m-1));}else if(b.type.name==="table"){r=b,i=n.before(m);break}}if(!r)return {isInTable:false};let u=0,d=0;r.forEach(m=>{if(m.type.name==="tableRow"){u++;let b=0;m.forEach(g=>{b+=g.attrs.colspan||1;}),d=Math.max(d,b);}});let c=l&&((l.attrs.colspan||1)>1||(l.attrs.rowspan||1)>1),p,f;if(l){let m=l.attrs;m.backgroundColor&&typeof m.backgroundColor=="string"&&(f=m.backgroundColor);let b=m.borders;if(b)for(let g of ["top","right","bottom","left"]){let x=b[g];if(x?.color&&x.style&&x.style!=="none"&&x.style!=="nil"){p=x.color;break}}}return {isInTable:true,table:r,tablePos:i,rowIndex:a,columnIndex:s,rowCount:u,columnCount:d,hasMultiCellSelection:o,canSplitCell:!!c,cellBorderColor:p,cellBackgroundColor:f}}function jn(e){let{$from:t}=e.selection;for(let n=t.depth;n>0;n--){let o=t.node(n);if(o.type.name==="tableCell"||o.type.name==="tableHeader")return true}return false}function Hd(e){let{$from:t}=e.selection,n=-1,o=-1,r=-1;for(let i=t.depth;i>0;i--){let a=t.node(i);if(a.type.name==="tableCell"||a.type.name==="tableHeader")n=i;else if(a.type.name==="tableRow")o=i;else if(a.type.name==="table"){r=i;break}}return n===-1||o===-1||r===-1?null:{cellDepth:n,cellPos:t.before(n),rowDepth:o,tableDepth:r}}function Nd(){return (e,t)=>{if(!jn(e))return false;let n=Hd(e);if(!n)return false;let{$from:o}=e.selection,r=o.node(n.tableDepth),i=o.node(n.rowDepth),a=o.index(n.rowDepth),s=o.index(n.tableDepth);if(a<i.childCount-1){let l=n.cellPos+o.node(n.cellDepth).nodeSize;if(t){let u=l+1+1,d=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(u)));t(d.scrollIntoView());}return true}if(s<r.childCount-1){let u=o.before(n.rowDepth)+i.nodeSize;if(t){let d=u+1+1+1,c=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(d)));t(c.scrollIntoView());}return true}return false}}function zd(){return (e,t)=>{if(!jn(e))return false;let n=Hd(e);if(!n)return false;let{$from:o}=e.selection,r=o.node(n.tableDepth),i=o.index(n.rowDepth),a=o.index(n.tableDepth);if(i>0){let l=o.node(n.rowDepth).child(i-1),u=n.cellPos-l.nodeSize;if(t){let d=u+l.nodeSize-2,c=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(d),-1));t(c.scrollIntoView());}return true}if(a>0){let s=r.child(a-1),u=o.before(n.rowDepth)-s.nodeSize;if(t){let c=u+s.nodeSize-1-1,p=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(c),-1));t(p.scrollIntoView());}return true}return false}}var dg=Qe({name:"table",schemaNodeName:"table",nodeSpec:ig}),ug=Qe({name:"tableRow",schemaNodeName:"tableRow",nodeSpec:ag}),pg=Qe({name:"tableCell",schemaNodeName:"tableCell",nodeSpec:lg}),fg=Qe({name:"tableHeader",schemaNodeName:"tableHeader",nodeSpec:cg}),mg=ft({name:"tablePlugin",onSchemaReady(e){let{schema:t}=e;function n(...M){return (F,k,L)=>{for(let I of M)if(I(F,k,L))return true;return false}}function o(M,F={}){let k=M?.attrs??{};return {colspan:k.colspan||1,rowspan:1,colwidth:k.colwidth,width:k.width,widthType:k.widthType,verticalAlign:k.verticalAlign,backgroundColor:k.backgroundColor,borders:k.borders,margins:k.margins,textDirection:k.textDirection,noWrap:k.noWrap,...F}}function r(M,F,k="000000",L=9360){let I=[],E=Math.floor(L/F),Z=360,le="atLeast",$={style:"single",size:4,color:{rgb:k}},Y={top:$,bottom:$,left:$,right:$};for(let fe=0;fe<M;fe++){let Te=[];for(let v=0;v<F;v++){let U=t.nodes.paragraph.create(),D={colspan:1,rowspan:1,borders:Y,width:E,widthType:"dxa"};Te.push(t.nodes.tableCell.create(D,U));}I.push(t.nodes.tableRow.create({height:Z,heightRule:le},Te));}let ne=Array(F).fill(E);return t.nodes.table.create({columnWidths:ne,width:L,widthType:"dxa"},I)}function i(M,F){return (k,L)=>{let{$from:I}=k.selection,E="000000",Z=k.storedMarks||I.marks();for(let $ of Z)if($.type.name==="textColor"&&$.attrs.rgb){E=$.attrs.rgb;break}let le=I.pos;for(let $=I.depth;$>0;$--){let Y=I.node($);if(Y.type.name==="paragraph"||Y.type.name==="table"){le=I.after($);break}}if(L){let $=9360;for(let he=I.depth;he>0;he--){let De=I.node(he);if(De.type.name==="tableCell"||De.type.name==="tableHeader"){let be=De.attrs.width;be&&be>0&&($=Math.max(be-216,360));break}}let Y=r(M,F,E,$),ne=t.nodes.paragraph.create(),Te=k.doc.resolve(le).nodeBefore?.type.name==="table",v=Te?[ne,Y,ne]:[Y,ne],U=k.tr.insert(le,v),D=le+1;Te&&(D+=ne.nodeSize);let ge=D+1+1;U.setSelection(prosemirrorState.TextSelection.create(U.doc,ge)),L(U.scrollIntoView());}return true}}function a(M,F){let k=qe(M);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0)return false;if(F){let L=M.tr,I=k.table.child(k.rowIndex),E=[];I.forEach($=>{let Y=t.nodes.paragraph.create(),ne=o($);E.push(t.nodes.tableCell.create(ne,Y));});let Z=t.nodes.tableRow.create({height:I.attrs.height??360,heightRule:I.attrs.heightRule??"atLeast"},E),le=k.tablePos+1;for(let $=0;$<k.rowIndex;$++)le+=k.table.child($).nodeSize;L.insert(le,Z),F(L.scrollIntoView());}return true}function s(M,F){let k=qe(M);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0)return false;if(F){let L=M.tr,I=k.table.child(k.rowIndex),E=[];I.forEach($=>{let Y=t.nodes.paragraph.create(),ne=o($);E.push(t.nodes.tableCell.create(ne,Y));});let Z=t.nodes.tableRow.create({height:I.attrs.height??360,heightRule:I.attrs.heightRule??"atLeast"},E),le=k.tablePos+1;for(let $=0;$<=k.rowIndex;$++)le+=k.table.child($).nodeSize;L.insert(le,Z),F(L.scrollIntoView());}return true}function l(M,F){let k=qe(M);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0||(k.rowCount||0)<=1)return false;if(F){let L=M.tr,I=k.tablePos+1;for(let Z=0;Z<k.rowIndex;Z++)I+=k.table.child(Z).nodeSize;let E=I+k.table.child(k.rowIndex).nodeSize;L.delete(I,E),F(L.scrollIntoView());}return true}function u(M,F){let k=qe(M);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0)return false;if(F){let L=M.tr,I=(k.columnCount||1)+1,E=Math.floor(100/I),Z=k.tablePos+1;k.table.forEach(Y=>{if(Y.type.name==="tableRow"){let ne=Z+1,fe=0;if(Y.forEach(Te=>{if(fe===k.columnIndex){let v=t.nodes.paragraph.create(),U=o(Te,{colspan:1,rowspan:1});U.width=E,U.widthType="pct";let D=t.nodes.tableCell.create(U,v);L=L.insert(ne,D);}ne+=Te.nodeSize,fe+=Te.attrs.colspan||1;}),fe<=k.columnIndex){let Te=t.nodes.paragraph.create(),v=o(Y.child(Y.childCount-1)??null,{colspan:1,rowspan:1});v.width=E,v.widthType="pct";let U=t.nodes.tableCell.create(v,Te);L=L.insert(ne,U);}}Z+=Y.nodeSize;});let $=L.doc.nodeAt(k.tablePos);if($&&$.type.name==="table"){let Y=$.child(0);if(Y&&Y.type.name==="tableRow"){let v=k.tablePos+2;Y.forEach(U=>{(U.type.name==="tableCell"||U.type.name==="tableHeader")&&(L=L.setNodeMarkup(v,void 0,{...U.attrs,width:E,widthType:"pct"})),v+=U.nodeSize;});}let ne=Y?.childCount??I,fe=$.attrs.width||9360,Te=Math.floor(fe/Math.max(1,ne));L=L.setNodeMarkup(k.tablePos,void 0,{...$.attrs,columnWidths:Array(ne).fill(Te)});}F(L.scrollIntoView());}return true}function d(M,F){let k=qe(M);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0)return false;if(F){let L=M.tr,I=(k.columnCount||1)+1,E=Math.floor(100/I),Z=k.tablePos+1;k.table.forEach(Y=>{if(Y.type.name==="tableRow"){let ne=Z+1,fe=0,Te=false;if(Y.forEach(v=>{if(ne+=v.nodeSize,fe+=v.attrs.colspan||1,!Te&&fe>k.columnIndex){let U=t.nodes.paragraph.create(),D=o(v,{colspan:1,rowspan:1});D.width=E,D.widthType="pct";let me=t.nodes.tableCell.create(D,U);L=L.insert(ne,me),Te=true;}}),!Te){let v=t.nodes.paragraph.create(),U=o(Y.child(Y.childCount-1)??null,{colspan:1,rowspan:1});U.width=E,U.widthType="pct";let D=t.nodes.tableCell.create(U,v);L=L.insert(ne,D);}}Z+=Y.nodeSize;});let $=L.doc.nodeAt(k.tablePos);if($&&$.type.name==="table"){let Y=$.child(0);if(Y&&Y.type.name==="tableRow"){let v=k.tablePos+2;Y.forEach(U=>{(U.type.name==="tableCell"||U.type.name==="tableHeader")&&(L=L.setNodeMarkup(v,void 0,{...U.attrs,width:E,widthType:"pct"})),v+=U.nodeSize;});}let ne=Y?.childCount??I,fe=$.attrs.width||9360,Te=Math.floor(fe/Math.max(1,ne));L=L.setNodeMarkup(k.tablePos,void 0,{...$.attrs,columnWidths:Array(ne).fill(Te)});}F(L.scrollIntoView());}return true}function c(M,F){let k=qe(M);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0||(k.columnCount||0)<=1)return false;if(F){let L=M.tr,I=(k.columnCount||2)-1,E=Math.floor(100/I),Z=[],le=k.tablePos+1;k.table.forEach(Y=>{if(Y.type.name==="tableRow"){let ne=le+1,fe=0;Y.forEach(Te=>{let v=ne,U=ne+Te.nodeSize,D=Te.attrs.colspan||1;fe<=k.columnIndex&&k.columnIndex<fe+D&&Z.push({start:v,end:U}),ne=U,fe+=D;});}le+=Y.nodeSize;}),Z.reverse().forEach(({start:Y,end:ne})=>{L=L.delete(Y,ne);});let $=L.doc.nodeAt(k.tablePos);if($&&$.type.name==="table"){let Y=$.child(0);if(Y&&Y.type.name==="tableRow"){let v=k.tablePos+2;Y.forEach(U=>{(U.type.name==="tableCell"||U.type.name==="tableHeader")&&(L=L.setNodeMarkup(v,void 0,{...U.attrs,width:E,widthType:"pct"})),v+=U.nodeSize;});}let ne=Y?.childCount??I,fe=$.attrs.width||9360,Te=Math.floor(fe/Math.max(1,ne));L=L.setNodeMarkup(k.tablePos,void 0,{...$.attrs,columnWidths:Array(ne).fill(Te)});}F(L.scrollIntoView());}return true}function p(M,F){let k=qe(M);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(F){let L=M.tr;L.delete(k.tablePos,k.tablePos+k.table.nodeSize),F(L.scrollIntoView());}return true}function f(M,F){let k=qe(M);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(F){let L=k.tablePos+1,I=M.doc.resolve(L),E=M.doc.resolve(k.tablePos+k.table.nodeSize-2),Z=prosemirrorTables.CellSelection.create(M.doc,I.pos,E.pos);F(M.tr.setSelection(Z));}return true}function m(M,F){let k=qe(M);if(!k.isInTable||k.tablePos===void 0||!k.table||k.rowIndex===void 0)return false;if(F){let I=k.tablePos+1;for(let Y=0;Y<k.rowIndex;Y++){let ne=k.table.child(Y);I+=ne.nodeSize;}let E=k.table.child(k.rowIndex),Z=I+1,le=I+E.nodeSize-2,$=prosemirrorTables.CellSelection.create(M.doc,Z,le);F(M.tr.setSelection($));}return true}function b(M,F){let k=qe(M);if(!k.isInTable||k.tablePos===void 0||!k.table||k.columnIndex===void 0)return false;if(F){let L=k.tablePos+1,I=k.table.child(0),E=k.table.child(k.table.childCount-1),Z=L+1;for(let ne=0;ne<k.columnIndex&&ne<I.childCount;ne++)Z+=I.child(ne).nodeSize;let le=L;for(let ne=0;ne<k.table.childCount-1;ne++)le+=k.table.child(ne).nodeSize;let $=le+1;for(let ne=0;ne<k.columnIndex&&ne<E.childCount;ne++)$+=E.child(ne).nodeSize;let Y=prosemirrorTables.CellSelection.create(M.doc,Z,$);F(M.tr.setSelection(Y));}return true}function g(M){let F=M.selection,k=[];if(F instanceof prosemirrorTables.CellSelection)return F.forEachCell((I,E)=>{k.push({pos:E,node:I});}),k;let{$from:L}=F;for(let I=L.depth;I>0;I--){let E=L.node(I);if(E.type.name==="tableCell"||E.type.name==="tableHeader"){k.push({pos:L.before(I),node:E});break}}return k}function x(M,F){let k=new Map,L=new Map,I=M.childCount,E=0;return M.forEach((Z,le,$)=>{if(Z.type.name!=="tableRow")return;let Y=0;Z.forEach((ne,fe)=>{let Te=F+le+fe+2,v=ne.attrs.colspan||1;k.set(Te,{rowIdx:$,colIdx:Y,colspan:v,pos:Te,node:ne}),L.set(`${$},${Y}`,Te),Y+=v;}),E=Math.max(E,Y);}),{cellByPos:k,cellByRC:L,totalRows:I,totalCols:E}}function T(M,F){return (k,L)=>{let I=qe(k);if(!I.isInTable||I.tablePos===void 0||!I.table)return false;if(L){let E=k.tr,Z=I.table,le=I.tablePos,$=F??{style:"single",size:4,color:{rgb:"000000"}},Y={style:"none"},{cellByPos:ne,cellByRC:fe}=x(Z,le),Te=g(k),v=1/0,U=-1,D=1/0,me=-1;for(let{pos:be}of Te){let pe=ne.get(be);pe&&(v=Math.min(v,pe.rowIdx),U=Math.max(U,pe.rowIdx),D=Math.min(D,pe.colIdx),me=Math.max(me,pe.colIdx+pe.colspan-1));}let ge=new Map,he=(be,pe)=>ge.get(be)??{...pe.attrs},De=(be,pe)=>{ge.set(be,pe);};for(let{pos:be}of Te){let pe=ne.get(be);if(!pe)continue;let _e=pe.rowIdx===v,Ke=pe.rowIdx===U,Ue=pe.colIdx===D,tt=pe.colIdx+pe.colspan-1===me,Ye;switch(M){case "all":Ye={top:$,bottom:$,left:$,right:$};break;case "outside":Ye={top:_e?$:Y,bottom:Ke?$:Y,left:Ue?$:Y,right:tt?$:Y};break;case "inside":Ye={top:_e?Y:$,bottom:Ke?Y:$,left:Ue?Y:$,right:tt?Y:$};break;case "none":Ye={top:Y,bottom:Y,left:Y,right:Y};break}let it=he(be,pe.node),vt=it.borders||{};if(De(be,{...it,borders:{...vt,...Ye}}),Ye.top){let Ne=fe.get(`${pe.rowIdx-1},${pe.colIdx}`);if(Ne!==void 0){let xt=ne.get(Ne),ze=he(Ne,xt.node),ht=ze.borders||{};De(Ne,{...ze,borders:{...ht,bottom:Ye.top}});}}if(Ye.bottom){let Ne=fe.get(`${pe.rowIdx+1},${pe.colIdx}`);if(Ne!==void 0){let xt=ne.get(Ne),ze=he(Ne,xt.node),ht=ze.borders||{};De(Ne,{...ze,borders:{...ht,top:Ye.bottom}});}}if(Ye.left){let Ne=fe.get(`${pe.rowIdx},${pe.colIdx-1}`);if(Ne!==void 0){let xt=ne.get(Ne),ze=he(Ne,xt.node),ht=ze.borders||{};De(Ne,{...ze,borders:{...ht,right:Ye.left}});}}if(Ye.right){let Ne=fe.get(`${pe.rowIdx},${pe.colIdx+pe.colspan}`);if(Ne!==void 0){let xt=ne.get(Ne),ze=he(Ne,xt.node),ht=ze.borders||{};De(Ne,{...ze,borders:{...ht,left:Ye.right}});}}}for(let[be,pe]of ge)E.setNodeMarkup(E.mapping.map(be),void 0,pe);L(E.scrollIntoView());}return true}}function S(M){return (F,k)=>{let L=qe(F);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;if(k){let I=F.tr,E=g(F),Z=M?M.replace(/^#/,""):null;for(let{pos:le,node:$}of E)I.setNodeMarkup(I.mapping.map(le),void 0,{...$.attrs,backgroundColor:Z});k(I.scrollIntoView());}return true}}function B(M,F,k){return (L,I)=>{let E=qe(L);if(!E.isInTable||E.tablePos===void 0||!E.table)return false;if(I){let Z=L.tr,le=g(L),$=F||{style:"none"},Y={style:"none"},ne=["top","bottom","left","right"],{cellByPos:fe,cellByRC:Te}=x(E.table,E.tablePos),v=new Map,U=(ge,he)=>v.get(ge)??{...he.attrs},D=(ge,he)=>v.set(ge,he),me={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:ge,node:he}of le){let De=fe.get(ge),be=U(ge,he),pe=be.borders||{},_e=M==="all"?ne:[M],Ke=k?{top:Y,bottom:Y,left:Y,right:Y}:{...pe};for(let Ue of _e)Ke[Ue]=$;if(De){let Ue=k?ne:_e;for(let tt of Ue){let Ye=Ke[tt],it=me[tt],vt=tt==="right"?De.colIdx+De.colspan:De.colIdx+it.dCol,Ne=Te.get(`${De.rowIdx+it.dRow},${vt}`);if(Ne!==void 0){let xt=fe.get(Ne),ze=U(Ne,xt.node),ht=ze.borders||{};D(Ne,{...ze,borders:{...ht,[it.adjSide]:Ye}});}}}D(ge,{...be,borders:Ke});}for(let[ge,he]of v)Z.setNodeMarkup(Z.mapping.map(ge),void 0,he);I(Z.scrollIntoView());}return true}}function C(M){return (F,k)=>{let L=qe(F);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;if(k){let I=F.tr,E=g(F);for(let{pos:Z,node:le}of E)I.setNodeMarkup(I.mapping.map(Z),void 0,{...le.attrs,verticalAlign:M});k(I.scrollIntoView());}return true}}function P(M){return (F,k)=>{let L=qe(F);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;if(k){let I=F.tr,E=g(F);for(let{pos:Z,node:le}of E){let Y={...le.attrs.margins||{},...M};I.setNodeMarkup(I.mapping.map(Z),void 0,{...le.attrs,margins:Y});}k(I.scrollIntoView());}return true}}function _(M){return (F,k)=>{let L=qe(F);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;if(k){let I=F.tr,E=g(F);for(let{pos:Z,node:le}of E)I.setNodeMarkup(I.mapping.map(Z),void 0,{...le.attrs,textDirection:M});k(I.scrollIntoView());}return true}}function q(){return (M,F)=>{let k=qe(M);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(F){let L=M.tr,I=g(M);for(let{pos:E,node:Z}of I)L.setNodeMarkup(L.mapping.map(E),void 0,{...Z.attrs,noWrap:!Z.attrs.noWrap});F(L.scrollIntoView());}return true}}function z(M,F){return (k,L)=>{let I=qe(k);if(!I.isInTable||I.tablePos===void 0||!I.table)return false;if(L){let E=k.tr,{$from:Z}=k.selection;for(let le=Z.depth;le>0;le--){let $=Z.node(le);if($.type.name==="tableRow"){let Y=Z.before(le),ne={...$.attrs,height:M,heightRule:M?F||"atLeast":null};return E.setNodeMarkup(Y,void 0,ne),L(E.scrollIntoView()),true}}}return true}}function H(){return (M,F)=>{let k=qe(M);if(!k.isInTable||k.tablePos===void 0||!k.table||!k.columnCount)return false;if(F){let L=M.tr,I=k.table,E=k.columnCount,Z=I.attrs.columnWidths,le=Z?Z.reduce((fe,Te)=>fe+Te,0):9360,$=Math.floor(le/E),Y=k.tablePos+1;I.forEach(fe=>{if(fe.type.name==="tableRow"){let Te=Y+1;fe.forEach(v=>{(v.type.name==="tableCell"||v.type.name==="tableHeader")&&(L=L.setNodeMarkup(Te,void 0,{...v.attrs,width:$,widthType:"dxa",colwidth:null})),Te+=v.nodeSize;});}Y+=fe.nodeSize;});let ne=Array(E).fill($);L=L.setNodeMarkup(k.tablePos,void 0,{...I.attrs,columnWidths:ne}),F(L.scrollIntoView());}return true}}function ee(){return (M,F)=>{let k=qe(M);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(F){let L=M.tr,I=k.table,E=k.tablePos+1;I.forEach(Z=>{if(Z.type.name==="tableRow"){let le=E+1;Z.forEach($=>{($.type.name==="tableCell"||$.type.name==="tableHeader")&&(L=L.setNodeMarkup(le,void 0,{...$.attrs,width:null,widthType:null,colwidth:null})),le+=$.nodeSize;});}E+=Z.nodeSize;}),L=L.setNodeMarkup(k.tablePos,void 0,{...I.attrs,columnWidths:null,width:null,widthType:"auto"}),F(L.scrollIntoView());}return true}}function ue(M){return (F,k)=>{let L=qe(F);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;if(k){let I=F.tr,E=L.table,Z=L.tablePos,le=E.childCount,$=M.look??{firstRow:true,lastRow:false,noHBand:false},Y=M.conditionals??{},ne=M.tableBorders;I=I.setNodeMarkup(Z,void 0,{...E.attrs,styleId:M.styleId});let fe=0,Te=Z+1;for(let v=0;v<le;v++){let U=E.child(v),D=v===0&&!!$.firstRow,me=v===le-1&&!!$.lastRow,ge=$.noHBand!==true,he=U.childCount,De;D?De="firstRow":me?De="lastRow":(ge&&(De=fe%2===0?"band1Horz":"band2Horz"),fe++);let be=Te+1;for(let pe=0;pe<he;pe++){let _e=U.child(pe),Ke=I.mapping.map(be),Ue=De,tt=pe===0&&!!$.firstCol,Ye=pe===he-1&&!!$.lastCol;D&&tt&&Y.nwCell?Ue="nwCell":D&&Ye&&Y.neCell?Ue="neCell":me&&tt&&Y.swCell?Ue="swCell":me&&Ye&&Y.seCell?Ue="seCell":tt?Ue="firstCol":Ye&&(Ue="lastCol");let it=Ue?Y[Ue]:void 0,vt={..._e.attrs};it?.backgroundColor?vt.backgroundColor=it.backgroundColor:vt.backgroundColor=null;let Ne={},xt=["top","bottom","left","right"];for(let ze of xt)it?.borders&&it.borders[ze]!==void 0?Ne[ze]=it.borders[ze]:ne&&(ze==="top"&&v>0||ze==="bottom"&&v<le-1?Ne[ze]=ne.insideH??ne[ze]:ze==="left"&&pe>0||ze==="right"&&pe<he-1?Ne[ze]=ne.insideV??ne[ze]:Ne[ze]=ne[ze]);Object.keys(Ne).length>0?vt.borders=Ne:vt.borders=null,I=I.setNodeMarkup(Ke,void 0,vt),be+=_e.nodeSize;}Te+=U.nodeSize;}k(I.scrollIntoView());}return true}}function A(M){return (F,k)=>{let L=qe(F);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;if(k){let I=F.tr,E={...L.table.attrs};"width"in M&&(E.width=M.width),"widthType"in M&&(E.widthType=M.widthType),"justification"in M&&(E.justification=M.justification),I.setNodeMarkup(L.tablePos,void 0,E),k(I.scrollIntoView());}return true}}function O(){return (M,F)=>{let k=qe(M);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(F){let L=M.tr,{$from:I}=M.selection;for(let E=I.depth;E>0;E--){let Z=I.node(E);if(Z.type.name==="tableRow"){let le=I.before(E),$={...Z.attrs,isHeader:!Z.attrs.isHeader};return L.setNodeMarkup(le,void 0,$),F(L.scrollIntoView()),true}}}return true}}function ie(M){return (F,k)=>{let L=qe(F);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;if(k){let I=F.tr,E=g(F),Z=M.replace(/^#/,""),le={style:"single",size:4},{cellByPos:$,cellByRC:Y}=x(L.table,L.tablePos),ne=new Map,fe=(U,D)=>ne.get(U)??{...D.attrs},Te=(U,D)=>ne.set(U,D),v={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:U,node:D}of E){let me=$.get(U),ge=fe(U,D),he=ge.borders||{},De={};for(let be of ["top","bottom","left","right"]){let pe={...le,...he[be],color:{rgb:Z}};if(De[be]=pe,me){let _e=v[be],Ke=be==="right"?me.colIdx+me.colspan:me.colIdx+_e.dCol,Ue=Y.get(`${me.rowIdx+_e.dRow},${Ke}`);if(Ue!==void 0){let tt=$.get(Ue),Ye=fe(Ue,tt.node),it=Ye.borders||{};Te(Ue,{...Ye,borders:{...it,[_e.adjSide]:pe}});}}}Te(U,{...ge,borders:{...he,...De}});}for(let[U,D]of ne)I.setNodeMarkup(I.mapping.map(U),void 0,D);k(I.scrollIntoView());}return true}}function ae(M){return (F,k)=>{let L=qe(F);if(!L.isInTable||L.tablePos===void 0||!L.table)return false;if(k){let I=F.tr,E=g(F),Z={style:"single",color:{rgb:"000000"}},{cellByPos:le,cellByRC:$}=x(L.table,L.tablePos),Y=new Map,ne=(v,U)=>Y.get(v)??{...U.attrs},fe=(v,U)=>Y.set(v,U),Te={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:v,node:U}of E){let D=le.get(v),me=ne(v,U),ge=me.borders||{},he={};for(let De of ["top","bottom","left","right"]){let be={...Z,...ge[De],size:M};if(he[De]=be,D){let pe=Te[De],_e=De==="right"?D.colIdx+D.colspan:D.colIdx+pe.dCol,Ke=$.get(`${D.rowIdx+pe.dRow},${_e}`);if(Ke!==void 0){let Ue=le.get(Ke),tt=ne(Ke,Ue.node),Ye=tt.borders||{};fe(Ke,{...tt,borders:{...Ye,[pe.adjSide]:be}});}}}fe(v,{...me,borders:{...ge,...he}});}for(let[v,U]of Y)I.setNodeMarkup(I.mapping.map(v),void 0,U);k(I.scrollIntoView());}return true}}function N(){return (M,F)=>{let k=M.selection;if(!("$anchorCell"in k&&typeof k.forEachCell=="function"))return false;let I=qe(M);if(!I.isInTable||I.tablePos===void 0||!I.table)return false;let E=0;I.table.descendants($=>{($.type.name==="tableCell"||$.type.name==="tableHeader")&&(E+=1);});let Z=0;if(k.forEachCell(()=>{Z+=1;}),!(E>0&&Z>=E))return false;if(F){let $=M.tr.delete(I.tablePos,I.tablePos+I.table.nodeSize);F($.scrollIntoView());}return true}}function Ie(){return M=>{let{$from:F,empty:k}=M.selection;if(!k)return false;let L=F.parent;if(L.type.name!=="paragraph"||L.textContent.length>0)return false;let I=F.depth;if(I<1)return false;let E=F.node(I-1),Z=F.index(I-1),le=Z>0?E.child(Z-1):null,$=Z+1<E.childCount?E.child(Z+1):null,Y=le?.type.name==="table",ne=$?.type.name==="table";return !!(Y||ne)}}let Fe=new prosemirrorState.PluginKey("activeCell"),Ve=new prosemirrorState.Plugin({key:Fe,props:{decorations(M){let{selection:F}=M;if(F instanceof prosemirrorTables.CellSelection)return prosemirrorView.DecorationSet.empty;let{$from:k}=F;for(let L=k.depth;L>0;L--){let I=k.node(L);if(I.type.name==="tableCell"||I.type.name==="tableHeader"){let E=k.before(L);return prosemirrorView.DecorationSet.create(M.doc,[prosemirrorView.Decoration.node(E,E+I.nodeSize,{class:"activeCell"})])}}return prosemirrorView.DecorationSet.empty}}});return {plugins:[prosemirrorTables.columnResizing({handleWidth:5,cellMinWidth:25,lastColumnResizable:true}),prosemirrorTables.tableEditing(),Ve],keyboardShortcuts:{Backspace:n(N(),Ie()),Delete:n(N(),Ie())},commands:{insertTable:(M,F)=>i(M,F),addRowAbove:()=>a,addRowBelow:()=>s,deleteRow:()=>l,addColumnLeft:()=>u,addColumnRight:()=>d,deleteColumn:()=>c,deleteTable:()=>p,selectTable:()=>f,selectRow:()=>m,selectColumn:()=>b,mergeCells:()=>prosemirrorTables.mergeCells,splitCell:()=>prosemirrorTables.splitCell,setCellBorder:(M,F,k)=>B(M,F,k),setTableBorders:(M,F)=>T(M,F),setCellVerticalAlign:M=>C(M),setCellMargins:M=>P(M),setCellTextDirection:M=>_(M),toggleNoWrap:()=>q(),setRowHeight:(M,F)=>z(M,F),toggleHeaderRow:()=>O(),distributeColumns:()=>H(),autoFitContents:()=>ee(),setTableProperties:M=>A(M),applyTableStyle:M=>ue(M),setCellFillColor:M=>S(M),setTableBorderColor:M=>ie(M),setTableBorderWidth:M=>ae(M),removeTableBorders:()=>T("none"),setAllTableBorders:M=>T("all",M),setOutsideTableBorders:M=>T("outside",M),setInsideTableBorders:M=>T("inside",M)}}}});function Od(){return [dg(),ug(),pg(),fg(),mg()]}function Fs(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}function $d(e){return (t,n)=>{let{$from:o,$to:r}=t.selection,i=o.parent;if(i.type.name!=="paragraph")return false;let s=i.attrs.numPr?.numId===e;if(!n)return true;let l=t.tr,u=new Set;return t.doc.nodesBetween(o.pos,r.pos,(d,c)=>{if(d.type.name==="paragraph"&&!u.has(c))if(u.add(c),s)l=l.setNodeMarkup(c,void 0,{...d.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});else {let p=e===1;l=l.setNodeMarkup(c,void 0,{...d.attrs,numPr:{numId:e,ilvl:d.attrs.numPr?.ilvl||0},listIsBullet:p,listNumFmt:p?null:"decimal",listMarker:null});}}),n(l.scrollIntoView()),true}}var gg=(e,t)=>$d(1)(e,t),hg=(e,t)=>$d(2)(e,t),bg=(e,t)=>{let{$from:n}=e.selection,o=n.parent;if(o.type.name!=="paragraph"||!o.attrs.numPr)return false;let r=o.attrs.numPr.ilvl||0;if(r>=8)return false;if(!t)return true;let i=n.before(n.depth);return t(e.tr.setNodeMarkup(i,void 0,{...o.attrs,numPr:{...o.attrs.numPr,ilvl:r+1},indentLeft:null,indentFirstLine:null,hangingIndent:null}).scrollIntoView()),true},yg=(e,t)=>{let{$from:n}=e.selection,o=n.parent;if(o.type.name!=="paragraph"||!o.attrs.numPr)return false;let r=o.attrs.numPr.ilvl||0;if(!t)return true;let i=n.before(n.depth);return r<=0?t(e.tr.setNodeMarkup(i,void 0,{...o.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null,indentLeft:null,indentFirstLine:null,hangingIndent:null}).scrollIntoView()):t(e.tr.setNodeMarkup(i,void 0,{...o.attrs,numPr:{...o.attrs.numPr,ilvl:r-1},indentLeft:null,indentFirstLine:null,hangingIndent:null}).scrollIntoView()),true},xg=(e,t)=>{let{$from:n,$to:o}=e.selection;if(!t)return true;let r=e.tr,i=new Set;return e.doc.nodesBetween(n.pos,o.pos,(a,s)=>{a.type.name==="paragraph"&&a.attrs.numPr&&!i.has(s)&&(i.add(s),r=r.setNodeMarkup(s,void 0,{...a.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null}));}),t(r.scrollIntoView()),true};function Sg(){return (e,t)=>{let{$from:n,empty:o}=e.selection;if(!o)return false;let r=n.parent;if(r.type.name!=="paragraph"||!r.attrs.numPr||r.textContent.length>0)return false;if(t){let a=e.tr.setNodeMarkup(n.before(),void 0,{...r.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});t(a);}return true}}function kg(){return (e,t)=>{let{$from:n,empty:o}=e.selection;if(!o)return false;let r=n.parent;if(r.type.name!=="paragraph"||!r.attrs.numPr)return false;if(t){let{tr:a}=e,s=n.pos;a.split(s,1,[{type:e.schema.nodes.paragraph,attrs:{...r.attrs}}]),t(a.scrollIntoView());}return true}}function Tg(){return (e,t)=>{let{$from:n,empty:o}=e.selection;if(!o||n.parentOffset!==0)return false;let r=n.parent;if(r.type.name!=="paragraph"||!r.attrs.numPr)return false;if(t){let a=e.tr.setNodeMarkup(n.before(),void 0,{...r.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});t(a);}return true}}function wg(){return (e,t)=>{let{$from:n,$to:o}=e.selection,r=[];if(e.doc.nodesBetween(n.pos,o.pos,(i,a)=>{i.type.name==="paragraph"&&i.attrs.numPr&&(i.attrs.numPr.ilvl??0)<8&&r.push({pos:a,attrs:i.attrs});}),r.length===0)return false;if(t){let i=e.tr;for(let{pos:a,attrs:s}of r){let l=s.numPr;i=i.setNodeMarkup(a,void 0,{...s,numPr:{...l,ilvl:(l.ilvl??0)+1},indentLeft:null,indentFirstLine:null,hangingIndent:null});}t(i);}return true}}function Cg(){return (e,t)=>{let{$from:n,$to:o}=e.selection,r=[];if(e.doc.nodesBetween(n.pos,o.pos,(i,a)=>{i.type.name==="paragraph"&&i.attrs.numPr&&r.push({pos:a,attrs:i.attrs});}),r.length===0)return false;if(t){let i=e.tr;for(let{pos:a,attrs:s}of r){let l=s.numPr,u=l.ilvl??0;u<=0?i=i.setNodeMarkup(a,void 0,{...s,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null,indentLeft:null,indentFirstLine:null,hangingIndent:null}):i=i.setNodeMarkup(a,void 0,{...s,numPr:{...l,ilvl:u-1},indentLeft:null,indentFirstLine:null,hangingIndent:null});}t(i);}return true}}function vg(){return (e,t)=>{let{schema:n}=e,o=n.nodes.tab;if(!o)return false;if(t){let r=e.tr.replaceSelectionWith(o.create());t(r.scrollIntoView());}return true}}var Wd=ft({name:"list",priority:tn.High,onSchemaReady(){return {commands:{toggleBulletList:()=>gg,toggleNumberedList:()=>hg,increaseListLevel:()=>bg,decreaseListLevel:()=>yg,removeList:()=>xg},keyboardShortcuts:{Tab:Fs(Nd(),wg(),vg()),"Shift-Tab":Fs(zd(),Cg()),"Shift-Enter":()=>false,Enter:Fs(Sg(),kg()),Backspace:Tg()}}}});function Vd(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}var Lg=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parentOffset!==0||n.parent.type.name!=="paragraph")return false;let o=n.parent.attrs,r=o.indentFirstLine!=null&&o.indentFirstLine>0,i=!!o.hangingIndent,a=o.indentLeft!=null&&o.indentLeft>0;if(!r&&!i&&!a)return false;if(t){let s=n.before(),l=e.tr.setNodeMarkup(s,void 0,{...o,indentFirstLine:null,hangingIndent:null,indentLeft:null});t(l.scrollIntoView());}return true},Bg=["defaultTextFormatting","styleId","lineSpacing","lineSpacingRule","spaceAfter","spaceBefore","contextualSpacing"],Ud=new Set(["fontFamily","fontSize","textColor"]),Ag=(e,t,n)=>{let{$from:o}=e.selection,r=o.parent.type.name==="paragraph"?o.parent:null,a=(e.storedMarks||o.marks()).filter(u=>Ud.has(u.type.name)),s=null;if(!prosemirrorCommands.splitBlock(e,t?u=>{s=u;}:void 0,n))return false;if(t&&s!==null){let u=s,{$from:d}=u.selection,c=d.parent;if(c.type.name==="paragraph"){let p={...c.attrs},f=false;if(r)for(let m of Bg){let b=r.attrs[m];b!=null&&p[m]==null&&(p[m]=b,f=true);}if(p.borders&&(p.borders=null,f=true),f&&u.setNodeMarkup(d.before(),void 0,p),c.textContent.length===0){let m=a;if(m.length===0&&r){let b=r.attrs.defaultTextFormatting;b&&(m=Ms(b,e.schema).filter(x=>Ud.has(x.type.name)));}if(m.length>0){let b={...p.defaultTextFormatting??{}},g=false;for(let x of m)if(x.type.name==="fontSize"&&x.attrs.size!==b.fontSize&&(b.fontSize=x.attrs.size,g=true),x.type.name==="fontFamily"){let T=x.attrs.ascii;T&&(!b.fontFamily||b.fontFamily.ascii!==T)&&(b.fontFamily={...b.fontFamily,ascii:T,hAnsi:x.attrs.hAnsi},g=true);}g&&u.setNodeMarkup(d.before(),void 0,{...p,defaultTextFormatting:b}),u.setStoredMarks(m);}}}t(u.scrollIntoView());}return true},jd=ft({name:"baseKeymap",priority:tn.Low,onSchemaReady(e){return {keyboardShortcuts:{...prosemirrorCommands.baseKeymap,Enter:Ag,Backspace:Vd(prosemirrorCommands.deleteSelection,Lg,prosemirrorCommands.joinBackward),Delete:Vd(prosemirrorCommands.deleteSelection,prosemirrorCommands.joinForward),"Mod-a":prosemirrorCommands.selectAll,Escape:prosemirrorCommands.selectParentNode}}}});var fi=new prosemirrorState.PluginKey("selectionTracker");function Uo(e){let{selection:t,doc:n}=e,{from:o,to:r,empty:i}=t,a=n.resolve(o),s=0,l=0;n.forEach((B,C,P)=>{if(C>r)return false;C<=o&&(s=P),C<=r&&(l=P);});let u=Ng(e),d=a.parent,c={};d.type.name==="paragraph"&&(d.attrs.alignment&&(c.alignment=d.attrs.alignment),d.attrs.lineSpacing&&(c.lineSpacing=d.attrs.lineSpacing,c.lineSpacingRule=d.attrs.lineSpacingRule),d.attrs.indentLeft&&(c.indentLeft=d.attrs.indentLeft),d.attrs.indentRight&&(c.indentRight=d.attrs.indentRight),d.attrs.indentFirstLine&&(c.indentFirstLine=d.attrs.indentFirstLine),d.attrs.hangingIndent&&(c.hangingIndent=d.attrs.hangingIndent),d.attrs.tabs&&(c.tabs=d.attrs.tabs),d.attrs.numPr&&(c.numPr=d.attrs.numPr),d.attrs.styleId&&(c.styleId=d.attrs.styleId));let p=d.attrs?.numPr,f=!!p?.numId,m=p?.numId===1?"bullet":p?.numId?"numbered":void 0,b=p?.ilvl,g=e.storedMarks||(i?a.marks():[]),x=[],T=false,S=false;for(let B of g)B.type.name==="comment"&&B.attrs.commentId&&x.push(B.attrs.commentId),B.type.name==="insertion"&&(T=true),B.type.name==="deletion"&&(S=true);return {hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:c,startParagraphIndex:s,endParagraphIndex:l,inList:f,listType:m,listLevel:b,activeCommentIds:x,inInsertion:T,inDeletion:S}}function Ng(e){let{selection:t}=e,{empty:n,$from:o}=t,r=e.storedMarks||(n?o.marks():[]),i={};for(let a of r)switch(a.type.name){case "bold":i.bold=true;break;case "italic":i.italic=true;break;case "underline":i.underline={style:a.attrs.style||"single",color:a.attrs.color};break;case "strike":a.attrs.double?i.doubleStrike=true:i.strike=true;break;case "textColor":i.color={rgb:a.attrs.rgb,themeColor:a.attrs.themeColor,themeTint:a.attrs.themeTint,themeShade:a.attrs.themeShade};break;case "highlight":i.highlight=a.attrs.color;break;case "fontSize":i.fontSize=a.attrs.size;break;case "fontFamily":i.fontFamily={ascii:a.attrs.ascii,hAnsi:a.attrs.hAnsi,asciiTheme:a.attrs.asciiTheme};break;case "superscript":i.vertAlign="superscript";break;case "subscript":i.vertAlign="subscript";break}return i}function mi(e){return new prosemirrorState.Plugin({key:fi,state:{init(t,n){return Uo(n)},apply(t,n,o,r){if(!t.selectionSet&&!t.docChanged)return n;let i=Uo(r);return e&&!Og(n,i)&&setTimeout(()=>e(i),0),i}},view(){return {update(t,n){if(!e||t.state.selection.eq(n.selection)&&t.state.doc.eq(n.doc))return;let o=fi.getState(t.state);o&&e(o);}}}})}function zg(e,t){if(e===t)return true;if(!e||!t||e.length!==t.length)return false;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return false;return true}function Og(e,t){return e.hasSelection===t.hasSelection&&e.isMultiParagraph===t.isMultiParagraph&&e.startParagraphIndex===t.startParagraphIndex&&e.endParagraphIndex===t.endParagraphIndex&&e.inList===t.inList&&e.listType===t.listType&&e.listLevel===t.listLevel&&e.inInsertion===t.inInsertion&&e.inDeletion===t.inDeletion&&zg(e.activeCommentIds,t.activeCommentIds)&&JSON.stringify(e.textFormatting)===JSON.stringify(t.textFormatting)&&JSON.stringify(e.paragraphFormatting)===JSON.stringify(t.paragraphFormatting)}var Gd=ft({name:"selectionTracker",defaultOptions:{},onSchemaReady(e,t){return {plugins:[mi(t.onSelectionChange)],commands:{extractSelectionContext:()=>(n,o)=>(Uo(n),true)}}}});var _g=new prosemirrorState.PluginKey("imageDrag"),Yd=ft({name:"imageDrag",onSchemaReady(e){return {plugins:[new prosemirrorState.Plugin({key:_g,props:{handleDOMEvents:{dragstart(n,o){let{selection:r}=n.state;if(r instanceof prosemirrorState.NodeSelection&&r.node.type.name==="image"){n.dom.classList.add("pm-image-dragging");let i=o;if(i.dataTransfer){i.dataTransfer.effectAllowed="move";let a=document.createElement("div");a.style.cssText="position: fixed; left: -9999px; top: -9999px; opacity: 0.6; pointer-events: none; border: 2px dashed var(--doc-primary, #2563eb); border-radius: 4px; background: rgba(37, 99, 235, 0.08);",a.style.width=`${r.node.attrs.width||100}px`,a.style.height=`${r.node.attrs.height||100}px`,document.body.appendChild(a),i.dataTransfer.setDragImage(a,0,0),requestAnimationFrame(()=>{document.body.removeChild(a);});}}return false},dragend(n){return n.dom.classList.remove("pm-image-dragging"),n.dom.querySelectorAll(".pm-drop-indicator").forEach(r=>r.remove()),false},dragover(n,o){let{selection:r}=n.state;if(r instanceof prosemirrorState.NodeSelection&&r.node.type.name==="image"){let i=o;i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="move");}return false},drop(n){return n.dom.classList.remove("pm-image-dragging"),n.dom.querySelectorAll(".pm-drop-indicator").forEach(r=>r.remove()),false}}}})]}}});var Ls=612;async function jg(e){return await new Promise((t,n)=>{let o=new FileReader;o.onload=()=>t(o.result),o.onerror=()=>n(o.error??new Error("Failed to read image file")),o.readAsDataURL(e);})}async function Gg(e){return await new Promise((t,n)=>{let o=new Image;o.onload=()=>t({width:o.naturalWidth||1,height:o.naturalHeight||1}),o.onerror=()=>n(new Error("Failed to load pasted image")),o.src=e;})}async function Kg(e,t){let n=e.state.schema.nodes.image;if(!n)return;let o=e.state.selection.from;for(let r of t){let i;try{i=await jg(r);}catch{continue}let a=1,s=1;try{({width:a,height:s}=await Gg(i));}catch{a=1,s=1;}let l=a,u=s;if(l>Ls){let p=Ls/l;l=Ls,u=Math.max(1,Math.round(u*p));}let d=n.create({src:i,alt:r.name,width:l,height:u,rId:`rId_img_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,wrapType:"inline",displayMode:"inline"}),c=e.state.tr.insert(o,d);o+=d.nodeSize,c.setSelection(prosemirrorState.TextSelection.create(c.doc,o)),e.dispatch(c.scrollIntoView());}e.focus();}var qd=ft({name:"imagePaste",onSchemaReady(e){return {plugins:[new prosemirrorState.Plugin({props:{handleDOMEvents:{paste(n,o){let r=o,i=chunk2KHL5RSD_js.L(r.clipboardData);return i.length===0||!n.state.schema.nodes.image?false:(r.preventDefault(),Kg(n,i).catch(()=>{}),true)}}}})]}}});var Xd=ft({name:"dropCursor",onSchemaReady(){return {plugins:[prosemirrorDropcursor.dropCursor({color:"var(--doc-primary, #4285f4)",width:2})]}}});var gi=new prosemirrorState.PluginKey("paragraphChangeTracker");function Zd(e){let t=0;return e.descendants(n=>{n.type.name==="paragraph"&&t++;}),t}function Zg(e,t,n){let o=new Set,r=false;return e.nodesBetween(t,n,i=>{if(i.type.name==="paragraph"){let a=i.attrs.paraId;a?o.add(a):r=true;}}),{ids:o,hasUntracked:r}}function Jg(){return new prosemirrorState.Plugin({key:gi,state:{init(e,t){return {changedParaIds:new Set,structuralChange:false,hasUntrackedChanges:false,paragraphCount:Zd(t.doc)}},apply(e,t){if(e.getMeta(gi)==="clear")return {changedParaIds:new Set,structuralChange:false,hasUntrackedChanges:false,paragraphCount:t.paragraphCount};if(!e.docChanged)return t;let n=Zd(e.doc),o={changedParaIds:new Set(t.changedParaIds),structuralChange:t.structuralChange,hasUntrackedChanges:t.hasUntrackedChanges,paragraphCount:n};t.paragraphCount!==n&&(o.structuralChange=true);for(let r of e.steps)r.getMap().forEach((a,s,l,u)=>{let{ids:d,hasUntracked:c}=Zg(e.doc,l,u);for(let p of d)o.changedParaIds.add(p);c&&(o.hasUntrackedChanges=true);});return o}}})}function Bs(e){return gi.getState(e)}function Jd(e){return Bs(e)?.changedParaIds??new Set}function Qd(e){return Bs(e)?.structuralChange??false}function eu(e){return Bs(e)?.hasUntrackedChanges??false}function tu(e){return e.tr.setMeta(gi,"clear")}var nu=ft({name:"paragraphChangeTracker",defaultOptions:{},onSchemaReady(){return {plugins:[Jg()]}}});var ou=ft({name:"bidiShortcut",priority:tn.High,onSchemaReady(e){return {plugins:[new prosemirrorState.Plugin({props:{handleKeyDown(t,n){if(n.key!=="Shift"||!(n.metaKey||n.ctrlKey))return false;let r=In.getCommands();return n.code==="ShiftLeft"?(n.preventDefault(),r.setLtr()(t.state,t.dispatch),true):n.code==="ShiftRight"?(n.preventDefault(),r.setRtl()(t.state,t.dispatch),true):false}}})]}}});function ru(e){let t={},n=e.split(";");for(let o of n){let r=o.trim();if(!r)continue;let i=r.indexOf(":");if(i<0)continue;let a=r.slice(0,i).trim(),s=r.slice(i+1).trim();a&&s&&(t[a]=s);}return t}function th(e,t){let n=e.getAttribute("style")||"",o=ru(n);for(let[r,i]of Object.entries(t))r in o||e.style.setProperty(r,i);}function nh(e){let t=e.querySelectorAll("style");if(t.length===0)return;let n=[];for(let o of t){let r=o.textContent||"";if(r.trim())try{let i=e.createElement("style");i.textContent=r,e.head.appendChild(i);let a=i.sheet;if(a)for(let s=0;s<a.cssRules.length;s++){let l=a.cssRules[s];if(l instanceof CSSStyleRule){let u={},d=l.style;for(let c=0;c<d.length;c++){let p=d[c];u[p]=d.getPropertyValue(p);}Object.keys(u).length>0&&n.push({selector:l.selectorText,declarations:u});}}e.head.removeChild(i);}catch{let i=/([^{]+)\{([^}]+)\}/g,a;for(;(a=i.exec(r))!==null;){let s=a[1].trim(),l=ru(a[2]);Object.keys(l).length>0&&n.push({selector:s,declarations:l});}}}if(n.length!==0)for(let{selector:o,declarations:r}of n)try{let i=e.body.querySelectorAll(o);for(let a of i)th(a,r);}catch{}}function oh(e){let t=e.body.querySelectorAll('b[id^="docs-internal-guid-"]');for(let n of t){let o=n.parentNode;if(o){for(;n.firstChild;)o.insertBefore(n.firstChild,n);o.removeChild(n);}}}function rh(e){let t=e.includes("<style"),n=e.includes("docs-internal-guid-");if(!t&&!n)return e;try{let r=new DOMParser().parseFromString(e,"text/html");if(t){nh(r);let i=r.querySelectorAll("style");for(let a of i)a.remove();}return n&&oh(r),r.body.innerHTML}catch{return e}}var iu=ft({name:"pasteStyleInliner",priority:tn.High,onSchemaReady(){return {plugins:[new prosemirrorState.Plugin({props:{transformPastedHTML(t){return rh(t)}}})]}}});function jo(e={}){let t=new Set(e.disable||[]),n=[];function o(r,i){t.has(r)||n.push(i);}return o("doc",Nc()),o("text",zc()),o("paragraph",Uc()),o("history",Gc({depth:e.historyDepth,newGroupDelay:e.historyNewGroupDelay})),o("bold",Yc()),o("italic",Xc()),o("underline",Qc()),o("strike",ed()),o("textColor",td()),o("highlight",nd()),o("fontSize",od()),o("fontFamily",rd()),o("superscript",id()),o("subscript",ad()),o("hyperlink",sd()),o("allCaps",ld()),o("smallCaps",cd()),o("footnoteRef",dd()),o("characterSpacing",ud()),o("emboss",gd()),o("imprint",hd()),o("textShadow",bd()),o("emphasisMark",yd()),o("textOutline",xd()),o("comment",pd()),o("insertion",fd()),o("deletion",md()),o("hardBreak",Sd()),o("tab",kd()),o("image",Td()),o("textBox",wd()),o("shape",Cd()),o("imageDrag",Yd()),o("imagePaste",qd()),o("dropCursor",Xd()),o("horizontalRule",vd()),o("pageBreak",Rd()),o("field",Ed()),o("sdt",Md()),o("math",Pd()),t.has("table")||n.push(...Od()),o("pasteStyleInliner",iu()),o("list",Wd()),o("baseKeymap",jd()),o("selectionTracker",Gd({onSelectionChange:e.onSelectionChange})),o("paragraphChangeTracker",nu()),o("bidiShortcut",ou()),n}var Gn=class{constructor(t){chunkH5NTJZO4_js.d(this,"extensions");chunkH5NTJZO4_js.d(this,"schema",null);chunkH5NTJZO4_js.d(this,"plugins",[]);chunkH5NTJZO4_js.d(this,"commands",{});this.extensions=[...t].sort((n,o)=>n.config.priority-o.config.priority);}buildSchema(){let t={},n={};for(let o of this.extensions)o.type==="node"?t[o.config.schemaNodeName]=o.config.nodeSpec:o.type==="mark"&&(n[o.config.schemaMarkName]=o.config.markSpec);this.schema=new prosemirrorModel.Schema({nodes:t,marks:n});}initializeRuntime(){if(!this.schema)throw new Error("ExtensionManager: buildSchema() must be called before initializeRuntime()");let t={schema:this.schema},n=[],o=[],r={};for(let i of this.extensions){let a=i.onSchemaReady(t);a.commands&&Object.assign(r,a.commands),a.keyboardShortcuts&&n.push(a.keyboardShortcuts),a.plugins&&o.push(...a.plugins);}this.plugins=[...o,...n.map(i=>prosemirrorKeymap.keymap(i))],this.commands=r;}getSchema(){if(!this.schema)throw new Error("ExtensionManager: buildSchema() must be called first");return this.schema}getPlugins(){return this.plugins}getCommands(){return this.commands}getCommand(t){return this.commands[t]}destroy(){this.plugins=[],this.commands={};}};var hi=new Gn(jo());hi.buildSchema();hi.initializeRuntime();var In=hi,ke=hi.getSchema();var sh={styleId:"Normal",type:"paragraph",name:"Normal",default:true,pPr:{spaceAfter:160,lineSpacing:259,lineSpacingRule:"auto"}},xr=class{constructor(t){chunkH5NTJZO4_js.d(this,"stylesById");chunkH5NTJZO4_js.d(this,"docDefaults");chunkH5NTJZO4_js.d(this,"defaultParagraphStyle");if(this.stylesById=new Map,this.docDefaults=t?.docDefaults,t?.styles)for(let n of t.styles)n.styleId&&this.stylesById.set(n.styleId,n);this.defaultParagraphStyle=this.findDefaultStyle("paragraph");}getStyle(t){return this.stylesById.get(t)}getParagraphStyles(){let t=[];for(let n of this.stylesById.values())n.type==="paragraph"&&!n.hidden&&!n.semiHidden&&t.push(n);return t.sort((n,o)=>{let r=n.uiPriority??99,i=o.uiPriority??99;return r!==i?r-i:(n.name??n.styleId).localeCompare(o.name??o.styleId)})}resolveParagraphStyle(t){let n={};if(this.docDefaults?.pPr&&(n.paragraphFormatting={...this.docDefaults.pPr}),this.docDefaults?.rPr&&(n.runFormatting={...this.docDefaults.rPr}),!t)return this.defaultParagraphStyle&&this.mergeStyleIntoResult(n,this.defaultParagraphStyle),n;let o=this.stylesById.get(t);return o?(this.mergeStyleIntoResult(n,o),n):(this.defaultParagraphStyle&&this.mergeStyleIntoResult(n,this.defaultParagraphStyle),n)}getTableStyles(){let t=[];for(let n of this.stylesById.values())n.type==="table"&&!n.hidden&&!n.semiHidden&&t.push(n);return t.sort((n,o)=>{let r=n.uiPriority??99,i=o.uiPriority??99;return r!==i?r-i:(n.name??n.styleId).localeCompare(o.name??o.styleId)})}resolveRunStyle(t){let n={};if(this.docDefaults?.rPr&&(n={...this.docDefaults.rPr}),!t)return Object.keys(n).length>0?n:void 0;let o=this.stylesById.get(t);if(!o?.rPr)return Object.keys(n).length>0?n:void 0;let r=this.mergeTextFormatting(n,o.rPr);return r&&Object.keys(r).length>0?r:void 0}getRunStyleOwnProperties(t){if(!t)return;let n=this.stylesById.get(t);if(n?.rPr)return Object.keys(n.rPr).length>0?{...n.rPr}:void 0}getDocDefaults(){return this.docDefaults}getDefaultParagraphStyle(){return this.defaultParagraphStyle}hasStyle(t){return this.stylesById.has(t)}findDefaultStyle(t){for(let n of this.stylesById.values())if(n.type===t&&n.default)return n;if(t==="paragraph")return this.stylesById.get("Normal")??sh}mergeStyleIntoResult(t,n){n.pPr&&(t.paragraphFormatting=this.mergeParagraphFormatting(t.paragraphFormatting,n.pPr)),n.rPr&&(t.runFormatting=this.mergeTextFormatting(t.runFormatting,n.rPr));}mergeParagraphFormatting(t,n){if(!n)return t;if(!t)return n?{...n}:void 0;let o={...t};for(let r of Object.keys(n)){let i=n[r];if(i!==void 0)if(r==="runProperties")o.runProperties=this.mergeTextFormatting(o.runProperties,n.runProperties);else if(r==="borders"||r==="numPr"||r==="frame"){let a=o[r],s=i;o[r]={...a||{},...s||{}};}else r==="tabs"&&Array.isArray(i)?o.tabs=[...i]:o[r]=i;}return o}mergeTextFormatting(t,n){if(!n)return t;if(!t)return n?{...n}:void 0;let o={...t};for(let r of Object.keys(n)){let i=n[r];i!==void 0&&(typeof i=="object"&&i!==null?o[r]={...o[r]||{},...i}:o[r]=i);}return o}};function To(e){return new xr(e)}function xi(e,t){let n=e.package.document.content,o=[],r=t?.styles?To(t.styles):null;for(let i of n)if(i.type==="paragraph")o.push(...au(i,r)),kh(i)&&o.push(ke.node("pageBreak"));else if(i.type==="table"){let a=Ds(i,r);o.push(a);}return o.length===0&&o.push(ke.node("paragraph",{},[])),ke.node("doc",null,o)}function As(e,t,n,o){let r=ch(e,t),i=[],a,s=new Set,l;t&&(l=t.resolveParagraphStyle(e.formatting?.styleId).runFormatting);let u=Tn(l,o);for(let d of e.content){if(d.type==="commentRangeStart")s.add(d.id);else if(d.type==="commentRangeEnd")s.delete(d.id);else if(d.type==="run"){let c=Hs(d,u,t);s.size>0&&(c=lh(c,s)),i.push(...c);}else if(d.type==="hyperlink"){let c=Ns(d,u,t);i.push(...c);}else if(d.type==="simpleField"||d.type==="complexField"){let c=fh(d,u);c&&i.push(c);}else if(d.type==="inlineSdt"){let c=gh(d,u,t);c&&i.push(c);}else if(d.type==="insertion"){let c=bi(d,"insertion",u,t);i.push(...c);}else if(d.type==="deletion"){let c=bi(d,"deletion",u,t);i.push(...c);}else if(d.type==="moveFrom"){let c=bi(d,"deletion",u,t);i.push(...c);}else if(d.type==="moveTo"){let c=bi(d,"insertion",u,t);i.push(...c);}else if(d.type==="mathEquation"){let c=mh(d);c&&i.push(c);}d.type==="bookmarkStart"&&(a||(a=[]),a.push({id:d.id,name:d.name}));}return a&&(r.bookmarks=a),ke.node("paragraph",r,i)}function lh(e,t){if(t.size===0)return e;let n=[...t][0],o=ke.marks.comment.create({commentId:n});return e.map(r=>r.isText?r.mark(o.addToSet(r.marks)):r)}function bi(e,t,n,o){let r=[];for(let a of e.content)a.type==="run"?r.push(...Hs(a,n,o)):a.type==="hyperlink"&&r.push(...Ns(a,n,o));let i=ke.marks[t].create({revisionId:e.info.id,author:e.info.author,date:e.info.date??null});return r.map(a=>a.isText?a.mark(i.addToSet(a.marks)):a)}function ch(e,t){let n=e.formatting,o=n?.styleId,r={paraId:e.paraId??void 0,textId:e.textId??void 0,styleId:o,numPr:n?.numPr,listNumFmt:e.listRendering?.numFmt,listIsBullet:e.listRendering?.isBullet,listMarker:e.listRendering?.marker,listMarkerHidden:e.listRendering?.markerHidden||void 0,listMarkerFontFamily:e.listRendering?.markerFontFamily||void 0,listMarkerFontSize:e.listRendering?.markerFontSize||void 0,_originalFormatting:n||void 0};if(t){let i=t.resolveParagraphStyle(o),a=i.paragraphFormatting,s=i.runFormatting;r.alignment=n?.alignment??a?.alignment,r.spaceBefore=n?.spaceBefore??a?.spaceBefore,r.spaceAfter=n?.spaceAfter??a?.spaceAfter,r.lineSpacing=n?.lineSpacing??a?.lineSpacing,r.lineSpacingRule=n?.lineSpacingRule??a?.lineSpacingRule,r.indentLeft=n?.indentLeft??a?.indentLeft,r.indentRight=n?.indentRight??a?.indentRight,r.indentFirstLine=n?.indentFirstLine??a?.indentFirstLine,r.hangingIndent=n?.hangingIndent??a?.hangingIndent,r.borders=n?.borders??a?.borders,r.shading=n?.shading??a?.shading,r.tabs=n?.tabs??a?.tabs,r.pageBreakBefore=n?.pageBreakBefore??a?.pageBreakBefore,r.keepNext=n?.keepNext??a?.keepNext,r.keepLines=n?.keepLines??a?.keepLines,r.contextualSpacing=n?.contextualSpacing??a?.contextualSpacing,r.outlineLevel=n?.outlineLevel??a?.outlineLevel,r.bidi=n?.bidi??a?.bidi;let l=yi(n?.runProperties,t);r.defaultTextFormatting=Tn(s,l),!n?.numPr&&a?.numPr&&a.numPr.numId!==0&&(r.numPr=a.numPr);}else r.alignment=n?.alignment,r.spaceBefore=n?.spaceBefore,r.spaceAfter=n?.spaceAfter,r.lineSpacing=n?.lineSpacing,r.lineSpacingRule=n?.lineSpacingRule,r.indentLeft=n?.indentLeft,r.indentRight=n?.indentRight,r.indentFirstLine=n?.indentFirstLine,r.hangingIndent=n?.hangingIndent,r.borders=n?.borders,r.shading=n?.shading,r.tabs=n?.tabs,r.pageBreakBefore=n?.pageBreakBefore,r.keepNext=n?.keepNext,r.keepLines=n?.keepLines,r.outlineLevel=n?.outlineLevel,r.bidi=n?.bidi,r.defaultTextFormatting=yi(n?.runProperties,t);if(e.sectionProperties){r._sectionProperties=e.sectionProperties;let i=e.sectionProperties.sectionStart;(i==="nextPage"||i==="continuous"||i==="oddPage"||i==="evenPage")&&(r.sectionBreakType=i);}return r}function Kt(e,t,n){if(!e||!t)return;let o=e.getStyle(t);if(!o?.tblStylePr)return;let r=o.tblStylePr.find(l=>l.type===n);if(!r)return;let i=yi(r.pPr?.runProperties,e),a=yi(r.rPr,e),s=Tn(i,a);return {tcPr:r.tcPr,rPr:s}}function kn(e,t){if(!e&&!t)return;if(!e)return t;if(!t)return e;let n={},o=e.tcPr,r=t.tcPr;if(o||r){let i={...o??{},...r??{}};(o?.borders||r?.borders)&&(i.borders={...o?.borders??{},...r?.borders??{}}),(o?.shading||r?.shading)&&(i.shading={...o?.shading??{},...r?.shading??{}}),(o?.margins||r?.margins)&&(i.margins={...o?.margins??{},...r?.margins??{}}),n.tcPr=i;}return n.rPr=Tn(e.rPr,t.rPr),n}function yi(e,t){if(!e)return;if(!e.styleId||!t)return e;let n=t.resolveRunStyle(e.styleId);return Tn(n,e)}function dh(e){let t=new Map,n=e.rows.length,o=new Map;for(let r=0;r<n;r++){let i=e.rows[r],a=0;for(let s=0;s<i.cells.length;s++){let l=i.cells[s],u=l.formatting?.gridSpan??1,d=l.formatting?.vMerge,c=`${r}-${a}`;if(d==="restart")o.set(a,r),t.set(c,{rowSpan:1,skip:false});else if(d==="continue"){let p=o.get(a);if(p!==void 0){let f=`${p}-${a}`,m=t.get(f);m&&m.rowSpan++;}t.set(c,{rowSpan:1,skip:true});}else o.delete(a),t.set(c,{rowSpan:1,skip:false});a+=u;}}return t}function Ds(e,t){let n=dh(e),o=e.columnWidths,r=o?.reduce((S,B)=>S+B,0)??0,i=e.formatting?.styleId,a=e.formatting?.look,s=i?t?.getStyle(i):void 0,l=e.formatting?.borders??s?.tblPr?.borders,u=e.formatting?.cellMargins??s?.tblPr?.cellMargins??void 0,d=u?{top:u.top?.value,bottom:u.bottom?.value,left:u.left?.value,right:u.right?.value}:void 0,c={styleId:e.formatting?.styleId,width:e.formatting?.width?.value,widthType:e.formatting?.width?.type,justification:e.formatting?.justification,columnWidths:o,floating:e.formatting?.floating,cellMargins:d,look:e.formatting?.look,_originalFormatting:e.formatting||void 0},p={wholeTable:Kt(t,i,"wholeTable"),firstRow:Kt(t,i,"firstRow"),lastRow:Kt(t,i,"lastRow"),firstCol:Kt(t,i,"firstCol"),lastCol:Kt(t,i,"lastCol"),band1Horz:Kt(t,i,"band1Horz"),band2Horz:Kt(t,i,"band2Horz"),band1Vert:Kt(t,i,"band1Vert"),band2Vert:Kt(t,i,"band2Vert"),nwCell:Kt(t,i,"nwCell"),neCell:Kt(t,i,"neCell"),swCell:Kt(t,i,"swCell"),seCell:Kt(t,i,"seCell")},f=a?.noHBand!==true,m=a?.noVBand!==true,b=0,g=e.rows.length,x=o?.length??e.rows[0]?.cells.reduce((S,B)=>S+(B.formatting?.gridSpan??1),0)??0,T=e.rows.map((S,B)=>{let C=B===0&&!!a?.firstRow,P=B===g-1&&!!a?.lastRow,_=f&&!C&&!P?b%2===0?p.band1Horz:p.band2Horz:void 0;return f&&!C&&!P&&b++,uh(S,t,C,o,r,p,_,m,a,l,B,g,x,n,d)});return ke.node("table",c,T)}function uh(e,t,n,o,r,i,a,s,l,u,d,c,p,f,m){let b={height:e.formatting?.height?.value,heightRule:e.formatting?.heightRule,isHeader:n||e.formatting?.header,_originalFormatting:e.formatting||void 0},g=e.cells.length,x=d===0,T=d===(c??1)-1,S=e.formatting?.conditionalFormat,B=S?.firstRow??x,C=S?.lastRow??T,P=p??g,_=0,q=[];for(let z=0;z<e.cells.length;z++){let H=e.cells[z],ee=H.formatting?.gridSpan??1,ue=`${d??0}-${_}`,A=f?.get(ue),O=A?.skip??false,ie=A?.rowSpan??1,ae;if(o&&r&&r>0){let Z=0;for(let le=0;le<ee&&_+le<o.length;le++)Z+=o[_+le];ae=Math.round(Z/r*100);}if(_+=ee,O)continue;let N=_-ee===0,Ie=_===P,Fe=H.formatting?.conditionalFormat,Ve=Fe?.firstRow??B,M=Fe?.lastRow??C,F=Fe?.firstColumn??N,k=Fe?.lastColumn??Ie,L;if(s){let Z=l?.firstColumn?1:0,le=_-ee-Z;le>=0&&!(l?.lastColumn&&k)&&!(l?.firstColumn&&F)&&(L=le%2===0?i?.band1Vert:i?.band2Vert);}Fe?.oddVBand?L=i?.band1Vert:Fe?.evenVBand&&(L=i?.band2Vert);let I=a;S?.oddHBand?I=i?.band1Horz:S?.evenHBand&&(I=i?.band2Horz),Fe?.oddHBand?I=i?.band1Horz:Fe?.evenHBand&&(I=i?.band2Horz);let E=i?.wholeTable;E=kn(E,I),E=kn(E,L),Ve&&(l?.firstRow||S?.firstRow||Fe?.firstRow)&&(E=kn(E,i?.firstRow)),M&&(l?.lastRow||S?.lastRow||Fe?.lastRow)&&(E=kn(E,i?.lastRow)),F&&(l?.firstColumn||S?.firstColumn||Fe?.firstColumn)&&(E=kn(E,i?.firstCol)),k&&(l?.lastColumn||S?.lastColumn||Fe?.lastColumn)&&(E=kn(E,i?.lastCol)),Ve&&F&&(l?.firstRow||S?.firstRow||Fe?.firstRow)&&(l?.firstColumn||S?.firstColumn||Fe?.firstColumn)&&(E=kn(E,i?.nwCell)),Ve&&k&&(l?.firstRow||S?.firstRow||Fe?.firstRow)&&(l?.lastColumn||S?.lastColumn||Fe?.lastColumn)&&(E=kn(E,i?.neCell)),M&&F&&(l?.lastRow||S?.lastRow||Fe?.lastRow)&&(l?.firstColumn||S?.firstColumn||Fe?.firstColumn)&&(E=kn(E,i?.swCell)),M&&k&&(l?.lastRow||S?.lastRow||Fe?.lastRow)&&(l?.lastColumn||S?.lastColumn||Fe?.lastColumn)&&(E=kn(E,i?.seCell)),q.push(ph(H,t,n,ae,E,u,x,T,N,Ie,ie,m));}return ke.node("tableRow",b,q)}function ph(e,t,n,o,r,i,a,s,l,u,d,c){let p=e.formatting,f=d??1,m=p?.width?.value,b=p?.width?.type;m===void 0&&o!==void 0&&(m=o,b="pct");let g=p?.shading?.fill?.rgb??r?.tcPr?.shading?.fill?.rgb,x=i?{top:a?i.top:i.insideH,bottom:s?i.bottom:i.insideH,left:l?i.left:i.insideV,right:u?i.right:i.insideV}:void 0,T=r?.tcPr?.borders,S=p?.borders,B=x||T||S?{...x??{},...T??{},...S??{}}:void 0,C={colspan:p?.gridSpan??1,rowspan:f,width:m,widthType:b,verticalAlign:p?.verticalAlign,backgroundColor:g,textDirection:p?.textDirection,noWrap:p?.noWrap,borders:B,margins:p?.margins?{top:p.margins.top?.value,bottom:p.margins.bottom?.value,left:p.margins.left?.value,right:p.margins.right?.value}:r?.tcPr?.margins?{top:r.tcPr.margins.top?.value,bottom:r.tcPr.margins.bottom?.value,left:r.tcPr.margins.left?.value,right:r.tcPr.margins.right?.value}:c,_originalFormatting:p||void 0},P=[];for(let q of e.content)q.type==="paragraph"?P.push(As(q,t,void 0,r?.rPr)):q.type==="table"&&P.push(Ds(q,t));P.length===0&&P.push(ke.node("paragraph",{},[]));let _=n?"tableHeader":"tableCell";return ke.node(_,C,P)}function fh(e,t){let n="",o,r=e.type==="simpleField"?e.content:e.fieldResult;if(r){for(let s of r)if(s.type==="run"){for(let l of s.content)l.type==="text"&&(n+=l.text);!o&&s.formatting&&(o=s.formatting);}}let i=Tn(t,o),a=zs(i);return ke.node("field",{fieldType:e.fieldType,instruction:e.instruction,displayText:n,fieldKind:e.type==="simpleField"?"simple":"complex",fldLock:e.fldLock??false,dirty:e.dirty??false},void 0,a)}function mh(e){return ke.node("math",{display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""})}function gh(e,t,n){let o=e.properties,r=[];for(let i of e.content)if(i.type==="run"){let a=Hs(i,t,n);r.push(...a);}else if(i.type==="hyperlink"){let a=Ns(i,t,n);r.push(...a);}return ke.node("sdt",{sdtType:o.sdtType,alias:o.alias??null,tag:o.tag??null,lock:o.lock??null,placeholder:o.placeholder??null,showingPlaceholder:o.showingPlaceholder??false,dateFormat:o.dateFormat??null,listItems:o.listItems?JSON.stringify(o.listItems):null,checked:o.checked??null},r.length>0?r:void 0)}function Hs(e,t,n){let o=[],r=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0,i=Tn(Tn(t,r),e.formatting),a=zs(i);for(let s of e.content){let l=hh(s,a);o.push(...l);}return o}function Tn(e,t){if(!t&&!e)return;if(!t)return e;if(!e)return t;let n={...e};if(t.bold!==void 0&&(n.bold=t.bold),t.italic!==void 0&&(n.italic=t.italic),t.underline!==void 0&&(n.underline=t.underline),t.strike!==void 0&&(n.strike=t.strike),t.doubleStrike!==void 0&&(n.doubleStrike=t.doubleStrike),t.color!==void 0){let o=t.color.rgb||t.color.themeColor||t.color.themeTint||t.color.themeShade;(!t.color.auto||o)&&(n.color=t.color);}return t.highlight!==void 0&&(n.highlight=t.highlight),t.fontSize!==void 0&&(n.fontSize=t.fontSize),t.fontFamily!==void 0&&(n.fontFamily=t.fontFamily),t.vertAlign!==void 0&&(n.vertAlign=t.vertAlign),t.allCaps!==void 0&&(n.allCaps=t.allCaps),t.smallCaps!==void 0&&(n.smallCaps=t.smallCaps),n}function hh(e,t){switch(e.type){case "text":return e.text?[ke.text(e.text,t)]:[];case "break":return e.breakType==="textWrapping"||!e.breakType?[ke.node("hardBreak")]:[];case "tab":return [ke.node("tab")];case "drawing":return e.image?[bh(e.image)]:[];case "shape":{let r=e.shape;return r.textBody&&r.textBody.content.length>0?[]:[yh(r)]}case "footnoteRef":let n=ke.mark("footnoteRef",{id:e.id.toString(),noteType:"footnote"});return [ke.text(e.id.toString(),[...t,n])];case "endnoteRef":let o=ke.mark("footnoteRef",{id:e.id.toString(),noteType:"endnote"});return [ke.text(e.id.toString(),[...t,o])];default:return []}}function bh(e){let t=e.size?.width?chunkSE5EN2QL_js.c(e.size.width):void 0,n=e.size?.height?chunkSE5EN2QL_js.c(e.size.height):void 0,o=e.wrap.type,r=e.wrap.wrapText,i=e.position?.horizontal?.alignment,a;o==="inline"||o==="topAndBottom"?a="none":o==="square"||o==="tight"||o==="through"?r==="left"?a="right":r==="right"||i==="left"?a="left":i==="right"?a="right":a="none":a="none";let s="inline";o==="inline"?s="inline":a&&a!=="none"?s="float":s="block";let l;if(e.transform){let x=[];e.transform.rotation&&x.push(`rotate(${e.transform.rotation}deg)`),e.transform.flipH&&x.push("scaleX(-1)"),e.transform.flipV&&x.push("scaleY(-1)"),x.length>0&&(l=x.join(" "));}let u=e.wrap.distT?chunkSE5EN2QL_js.c(e.wrap.distT):void 0,d=e.wrap.distB?chunkSE5EN2QL_js.c(e.wrap.distB):void 0,c=e.wrap.distL?chunkSE5EN2QL_js.c(e.wrap.distL):void 0,p=e.wrap.distR?chunkSE5EN2QL_js.c(e.wrap.distR):void 0,f;e.position&&(f={horizontal:e.position.horizontal?{relativeTo:e.position.horizontal.relativeTo,posOffset:e.position.horizontal.posOffset,align:e.position.horizontal.alignment}:void 0,vertical:e.position.vertical?{relativeTo:e.position.vertical.relativeTo,posOffset:e.position.vertical.posOffset,align:e.position.vertical.alignment}:void 0});let m,b,g;if(e.outline&&e.outline.width){m=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(b=`#${e.outline.color.rgb}`);let x={solid:"solid",dot:"dotted",dash:"dashed",lgDash:"dashed",dashDot:"dashed",lgDashDot:"dashed",lgDashDotDot:"dashed",sysDot:"dotted",sysDash:"dashed",sysDashDot:"dashed",sysDashDotDot:"dashed"};g=e.outline.style&&x[e.outline.style]||"solid";}return ke.node("image",{src:e.src||"",alt:e.alt,title:e.title,width:t,height:n,rId:e.rId,wrapType:o,displayMode:s,cssFloat:a,transform:l,distTop:u,distBottom:d,distLeft:c,distRight:p,position:f,borderWidth:m,borderColor:b,borderStyle:g,wrapText:r,hlinkHref:e.hlinkHref})}function Ns(e,t,n){let o=[],r=e.href||(e.anchor?`#${e.anchor}`:""),i=ke.mark("hyperlink",{href:r,tooltip:e.tooltip,rId:e.rId});for(let a of e.children)if(a.type==="run"){let s=a.formatting?.styleId?n?.resolveRunStyle(a.formatting.styleId):void 0,l=Tn(Tn(t,s),a.formatting),d=[...zs(l),i];for(let c of a.content)c.type==="text"&&c.text&&o.push(ke.text(c.text,d));}return o}function zs(e){if(!e)return [];let t=[];return e.bold&&t.push(ke.mark("bold")),e.italic&&t.push(ke.mark("italic")),e.underline&&e.underline.style!=="none"&&t.push(ke.mark("underline",{style:e.underline.style,color:e.underline.color})),(e.strike||e.doubleStrike)&&t.push(ke.mark("strike",{double:e.doubleStrike||false})),e.color&&!e.color.auto&&t.push(ke.mark("textColor",{rgb:e.color.rgb,themeColor:e.color.themeColor,themeTint:e.color.themeTint,themeShade:e.color.themeShade})),e.highlight&&e.highlight!=="none"&&t.push(ke.mark("highlight",{color:e.highlight})),e.fontSize&&t.push(ke.mark("fontSize",{size:e.fontSize})),e.fontFamily&&t.push(ke.mark("fontFamily",{ascii:e.fontFamily.ascii,hAnsi:e.fontFamily.hAnsi,eastAsia:e.fontFamily.eastAsia,cs:e.fontFamily.cs,asciiTheme:e.fontFamily.asciiTheme,hAnsiTheme:e.fontFamily.hAnsiTheme,eastAsiaTheme:e.fontFamily.eastAsiaTheme,csTheme:e.fontFamily.csTheme})),e.vertAlign==="superscript"?t.push(ke.mark("superscript")):e.vertAlign==="subscript"&&t.push(ke.mark("subscript")),e.allCaps&&t.push(ke.mark("allCaps")),e.smallCaps&&t.push(ke.mark("smallCaps")),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&t.push(ke.mark("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null})),e.emboss&&t.push(ke.mark("emboss")),e.imprint&&t.push(ke.mark("imprint")),e.shadow&&t.push(ke.mark("textShadow")),e.emphasisMark&&e.emphasisMark!=="none"&&t.push(ke.mark("emphasisMark",{type:e.emphasisMark})),e.outline&&t.push(ke.mark("textOutline")),t}function yh(e){let t=e.size?.width?chunkSE5EN2QL_js.c(e.size.width):100,n=e.size?.height?chunkSE5EN2QL_js.c(e.size.height):80,o,r="solid",i,a,s;if(e.fill&&(r=e.fill.type,e.fill.color?.rgb&&(o=`#${e.fill.color.rgb}`),e.fill.type==="gradient"&&e.fill.gradient)){let p=e.fill.gradient;i=p.type,a=p.angle,s=JSON.stringify(p.stops.map(f=>({position:f.position,color:f.color.rgb?`#${f.color.rgb}`:"#000000"})));}let l,u,d;e.outline&&(e.outline.width&&(l=Math.round(e.outline.width/914400*96*100)/100),e.outline.color?.rgb&&(u=`#${e.outline.color.rgb}`),d=e.outline.style||"solid");let c;if(e.transform){let p=[];e.transform.rotation&&p.push(`rotate(${e.transform.rotation}deg)`),e.transform.flipH&&p.push("scaleX(-1)"),e.transform.flipV&&p.push("scaleY(-1)"),p.length>0&&(c=p.join(" "));}return ke.node("shape",{shapeType:e.shapeType||"rect",shapeId:e.id,width:t,height:n,fillColor:o,fillType:r,gradientType:i,gradientAngle:a,gradientStops:s,outlineWidth:l,outlineColor:u,outlineStyle:d,transform:c})}function au(e,t){let n=xh(e),o=As(e,t),r=[];n.length>0&&o.content.size===0||r.push(o);for(let a of n)r.push(Sh(a,t));return r}function xh(e){let t=[];for(let n of e.content)if(n.type==="run"){for(let o of n.content)if(o.type==="shape"&&"shape"in o){let r=o.shape;r.textBody&&r.textBody.content.length>0&&t.push({type:"textBox",id:r.id,size:r.size,position:r.position,wrap:r.wrap,fill:r.fill,outline:r.outline,content:r.textBody.content,margins:r.textBody.margins});}}return t}function Sh(e,t){let n=e.size?.width?chunkSE5EN2QL_js.c(e.size.width):200,o=e.size?.height?chunkSE5EN2QL_js.c(e.size.height):void 0,r;e.fill?.color?.rgb&&(r=`#${e.fill.color.rgb}`);let i,a,s;e.outline&&e.outline.width&&(i=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(a=`#${e.outline.color.rgb}`),s=e.outline.style||"solid");let l=e.margins?.top!=null?chunkSE5EN2QL_js.c(e.margins.top):4,u=e.margins?.bottom!=null?chunkSE5EN2QL_js.c(e.margins.bottom):4,d=e.margins?.left!=null?chunkSE5EN2QL_js.c(e.margins.left):7,c=e.margins?.right!=null?chunkSE5EN2QL_js.c(e.margins.right):7,p=[];for(let f of e.content)p.push(As(f,t));return p.length===0&&p.push(ke.node("paragraph",{},[])),ke.node("textBox",{width:n,height:o,textBoxId:e.id,fillColor:r,outlineWidth:i,outlineColor:a,outlineStyle:s,marginTop:l,marginBottom:u,marginLeft:d,marginRight:c},p)}function Os(e,t){let n=[],o=t?.styles?To(t.styles):null;for(let r of e)r.type==="paragraph"?n.push(...au(r,o)):r.type==="table"&&n.push(Ds(r,o));return n.length===0&&n.push(ke.node("paragraph",{},[])),ke.node("doc",null,n)}function kh(e){for(let t of e.content)if(t.type==="run"){for(let n of t.content)if(n.type==="break"&&n.breakType==="page")return true}return false}function Si(){return ke.node("doc",null,[ke.node("paragraph",{},[])])}function ki(e,t){let o={content:lu(e),finalSectionProperties:t?.package.document.finalSectionProperties,sections:t?.package.document.sections,comments:t?.package.document.comments};return t?{...t,package:{...t.package,document:o}}:{package:{document:o}}}function lu(e){let t=[],n=du(e);return e.forEach(o=>{o.type.name==="paragraph"?t.push($s(o,n)):o.type.name==="table"?t.push(pu(o,n)):o.type.name==="textBox"?t.push(_h(o)):o.type.name==="pageBreak"&&t.push(Th());}),t}function Th(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function $s(e,t){let n=e.attrs,o=wh(cu(e,t),e),r=n.bookmarks;if(r&&r.length>0){let a=r.map(l=>({type:"bookmarkStart",id:l.id,name:l.name})),s=r.map(l=>({type:"bookmarkEnd",id:l.id}));o=[...a,...o,...s];}let i={type:"paragraph",paraId:n.paraId||void 0,textId:n.textId||void 0,formatting:Ch(n),content:o};return n._sectionProperties?i.sectionProperties=n._sectionProperties:n.sectionBreakType&&(i.sectionProperties={sectionStart:n.sectionBreakType}),i}function wh(e,t){let n=new Set;if(t.forEach(a=>{for(let s of a.marks)s.type.name==="comment"&&n.add(s.attrs.commentId);}),n.size===0)return e;let o=[],r=new Set,i=0;t.forEach(a=>{let s=new Set;for(let l of a.marks)l.type.name==="comment"&&s.add(l.attrs.commentId);for(let l of [...r])s.has(l)||(o.push({type:"commentRangeEnd",id:l}),r.delete(l));for(let l of s)r.has(l)||(o.push({type:"commentRangeStart",id:l}),r.add(l));i<e.length&&o.push(e[i]),i++;});for(let a of r)o.push({type:"commentRangeEnd",id:a});return o}function Ch(e){if(e._originalFormatting){let n=e._originalFormatting,o={...n};return e.alignment!==(n.alignment||void 0)&&(o.alignment=e.alignment||void 0),e.numPr!==n.numPr&&JSON.stringify(e.numPr)!==JSON.stringify(n.numPr)&&(o.numPr=e.numPr||void 0),e.styleId!==(n.styleId||void 0)&&(o.styleId=e.styleId||void 0),e.pageBreakBefore!==(n.pageBreakBefore||void 0)&&(o.pageBreakBefore=e.pageBreakBefore||void 0),e.bidi!==(n.bidi||void 0)&&(o.bidi=e.bidi||void 0),o}if(e.alignment||e.spaceBefore||e.spaceAfter||e.lineSpacing||e.indentLeft||e.indentRight||e.indentFirstLine||e.numPr||e.styleId||e.borders||e.shading||e.tabs||e.outlineLevel!=null||e.contextualSpacing||e.bidi)return {alignment:e.alignment||void 0,spaceBefore:e.spaceBefore||void 0,spaceAfter:e.spaceAfter||void 0,lineSpacing:e.lineSpacing||void 0,lineSpacingRule:e.lineSpacingRule||void 0,indentLeft:e.indentLeft||void 0,indentRight:e.indentRight||void 0,indentFirstLine:e.indentFirstLine||void 0,hangingIndent:e.hangingIndent||void 0,numPr:e.numPr||void 0,styleId:e.styleId||void 0,borders:e.borders||void 0,shading:e.shading||void 0,tabs:e.tabs||void 0,outlineLevel:e.outlineLevel??void 0,contextualSpacing:e.contextualSpacing||void 0,bidi:e.bidi||void 0}}function cu(e,t){let n=[],o=t??du(e),r=null,i=null,a=null;return e.forEach(s=>{let l=s.marks.find(p=>p.type.name==="footnoteRef");if(l){r&&(n.push(r),r=null,i=null),a&&(n.push(a),a=null);let f={type:l.attrs.noteType==="endnote"?"endnoteRef":"footnoteRef",id:parseInt(l.attrs.id,10)||0};n.push({type:"run",content:[f]});return}let u=s.marks.find(p=>p.type.name==="insertion"),d=s.marks.find(p=>p.type.name==="deletion");if(u||d){r&&(n.push(r),r=null,i=null),a&&(n.push(a),a=null);let p=u||d,f=s.marks.filter(C=>C.type.name!=="insertion"&&C.type.name!=="deletion"),m=Ws(f),b={type:"run",content:s.isText&&s.text?[{type:"text",text:s.text}]:[],...Object.keys(m).length>0?{formatting:m}:{}},g={id:p.attrs.revisionId,author:p.attrs.author||"Unknown",date:p.attrs.date||void 0},x=g.id,T=(o.insertionById.get(x)??0)>0,S=(o.deletionById.get(x)??0)>0,B=T&&S;u?B?n.push({type:"moveTo",info:g,content:[b]}):n.push({type:"insertion",info:g,content:[b]}):B?n.push({type:"moveFrom",info:g,content:[b]}):n.push({type:"deletion",info:g,content:[b]});return}let c=s.marks.find(p=>p.type.name==="hyperlink");if(c){let p=vh(c),f=a?.href||(a?.anchor?`#${a.anchor}`:"");a&&f===p||(r&&(n.push(r),r=null,i=null),a&&n.push(a),a=Eh(c)),su(a,s);return}if(a&&(n.push(a),a=null),s.isText){let p=Rh(s.marks);r&&i===p?Mh(r,s.text||""):(r&&n.push(r),r=uu(s.text||"",s.marks),i=p);}else s.type.name==="hardBreak"?(r&&(n.push(r),r=null,i=null),n.push(Ph())):s.type.name==="image"?(r&&(n.push(r),r=null,i=null),n.push(Ah(s))):s.type.name==="shape"?(r&&(n.push(r),r=null,i=null),n.push(Dh(s))):s.type.name==="tab"?(r&&(n.push(r),r=null,i=null),n.push(Ih())):s.type.name==="field"?(r&&(n.push(r),r=null,i=null),n.push(Fh(s,s.marks))):s.type.name==="sdt"?(r&&(n.push(r),r=null,i=null),n.push(Bh(s))):s.type.name==="math"&&(r&&(n.push(r),r=null,i=null),n.push(Lh(s)));}),r&&n.push(r),a&&n.push(a),n}function du(e){let t=new Map,n=new Map;return e.descendants(o=>{let r=o.marks.find(a=>a.type.name==="insertion"),i=o.marks.find(a=>a.type.name==="deletion");if(r){let a=Number(r.attrs.revisionId);Number.isFinite(a)&&t.set(a,(t.get(a)??0)+1);}if(i){let a=Number(i.attrs.revisionId);Number.isFinite(a)&&n.set(a,(n.get(a)??0)+1);}}),{insertionById:t,deletionById:n}}function vh(e){return e.attrs.href||""}function Rh(e){let t=e.filter(n=>n.type.name!=="hyperlink");return t.length===0?"":t.map(n=>`${n.type.name}:${JSON.stringify(n.attrs)}`).sort().join("|")}function Eh(e){let t=e.attrs.href;return t?.startsWith("#")?{type:"hyperlink",anchor:t.substring(1),tooltip:e.attrs.tooltip||void 0,children:[]}:{type:"hyperlink",href:t,tooltip:e.attrs.tooltip||void 0,rId:e.attrs.rId||void 0,children:[]}}function su(e,t){if(t.isText&&t.text){let n=t.marks.filter(r=>r.type.name!=="hyperlink"),o=uu(t.text,n);e.children.push(o);}}function uu(e,t){let n=Ws(t),o={type:"text",text:e};return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:[o]}}function Mh(e,t){let n=e.content[e.content.length-1];n&&n.type==="text"?n.text+=t:e.content.push({type:"text",text:t});}function Ph(){return {type:"run",content:[{type:"break",breakType:"textWrapping"}]}}function Ih(){return {type:"run",content:[{type:"tab"}]}}function Fh(e,t){let n=e.attrs,o=t&&t.length>0?Ws(t):void 0,r=n.displayText||"";if(!r)switch(n.fieldType){case "PAGE":r="1";break;case "NUMPAGES":r="1";break;default:r=" ";break}let i={type:"run",content:[{type:"text",text:r}],...o&&Object.keys(o).length>0?{formatting:o}:{}};return n.fieldKind==="complex"?{type:"complexField",instruction:n.instruction,fieldType:n.fieldType,fieldCode:[],fieldResult:[i],fldLock:n.fldLock||void 0,dirty:n.dirty||void 0}:{type:"simpleField",instruction:n.instruction,fieldType:n.fieldType,content:[i],fldLock:n.fldLock||void 0,dirty:n.dirty||void 0}}function Lh(e){let t=e.attrs;return {type:"mathEquation",display:t.display||"inline",ommlXml:t.ommlXml,plainText:t.plainText||void 0}}function Bh(e){let t=e.attrs,n={sdtType:t.sdtType??"richText",alias:t.alias??void 0,tag:t.tag??void 0,lock:t.lock??void 0,placeholder:t.placeholder??void 0,showingPlaceholder:t.showingPlaceholder??void 0,dateFormat:t.dateFormat??void 0,listItems:t.listItems?JSON.parse(t.listItems):void 0,checked:t.checked!=null?t.checked:void 0},r=cu(e).filter(i=>i.type==="run"||i.type==="hyperlink");return {type:"inlineSdt",properties:n,content:r}}function Ah(e){let t=e.attrs,n=t.wrapType||"inline",o=914400/96,r={type:n};t.distTop!==void 0&&(r.distT=Math.round(t.distTop*o)),t.distBottom!==void 0&&(r.distB=Math.round(t.distBottom*o)),t.distLeft!==void 0&&(r.distL=Math.round(t.distLeft*o)),t.distRight!==void 0&&(r.distR=Math.round(t.distRight*o)),t.wrapText&&(r.wrapText=t.wrapText);let i={type:"image",rId:t.rId||"",src:t.src,alt:t.alt||void 0,title:t.title||void 0,size:{width:chunkSE5EN2QL_js.d(t.width||0),height:chunkSE5EN2QL_js.d(t.height||0)},wrap:r};if(t.transform){let s=t.transform,l={},u=s.match(/rotate\(([-\d.]+)deg\)/);u&&(l.rotation=parseFloat(u[1])),s.includes("scaleX(-1)")&&(l.flipH=true),s.includes("scaleY(-1)")&&(l.flipV=true),(l.rotation||l.flipH||l.flipV)&&(i.transform=l);}if(t.position?.horizontal&&t.position?.vertical){let s=t.position;i.position={horizontal:{relativeTo:s.horizontal.relativeTo||"column",alignment:s.horizontal.align,posOffset:s.horizontal.posOffset},vertical:{relativeTo:s.vertical.relativeTo||"paragraph",alignment:s.vertical.align,posOffset:s.vertical.posOffset}};}if(t.borderWidth&&t.borderWidth>0){let s={solid:"solid",dotted:"dot",dashed:"dash",double:"solid",groove:"solid",ridge:"solid",inset:"solid",outset:"solid"};i.outline={width:Math.round(t.borderWidth*(914400/96)),color:t.borderColor?{rgb:t.borderColor.replace("#","")}:void 0,style:t.borderStyle&&s[t.borderStyle]||"solid"};}return t.hlinkHref&&(i.hlinkHref=t.hlinkHref),{type:"run",content:[{type:"drawing",image:i}]}}function Dh(e){let t=e.attrs,n={type:"shape",shapeType:t.shapeType||"rect",id:t.shapeId||void 0,size:{width:t.width?Math.round(t.width*(914400/96)):0,height:t.height?Math.round(t.height*(914400/96)):0}};if(t.fillType==="gradient"&&t.gradientStops)try{let r=JSON.parse(t.gradientStops);n.fill={type:"gradient",gradient:{type:t.gradientType||"linear",angle:t.gradientAngle||void 0,stops:r.map(i=>({position:i.position,color:{rgb:i.color.replace("#","")}}))}};}catch{n.fill={type:"solid",color:{rgb:(t.fillColor||"000000").replace("#","")}};}else t.fillColor?n.fill={type:t.fillType||"solid",color:{rgb:t.fillColor.replace("#","")}}:t.fillType==="none"&&(n.fill={type:"none"});if(t.outlineWidth&&t.outlineWidth>0){let r={solid:"solid",dotted:"dot",dashed:"dash"};n.outline={width:Math.round(t.outlineWidth*(914400/96)),color:t.outlineColor?{rgb:t.outlineColor.replace("#","")}:void 0,style:t.outlineStyle&&r[t.outlineStyle]||"solid"};}return {type:"run",content:[{type:"shape",shape:n}]}}function Ws(e){let t={};for(let n of e)switch(n.type.name){case "bold":t.bold=true,t.boldCs=true;break;case "italic":t.italic=true,t.italicCs=true;break;case "underline":{let o=n.attrs;t.underline={style:o.style||"single",color:o.color};break}case "strike":n.attrs.double?t.doubleStrike=true:t.strike=true;break;case "textColor":{let o=n.attrs;t.color={rgb:o.rgb,themeColor:o.themeColor,themeTint:o.themeTint,themeShade:o.themeShade};break}case "highlight":t.highlight=n.attrs.color;break;case "fontSize":t.fontSize=n.attrs.size,t.fontSizeCs=n.attrs.size;break;case "fontFamily":{let o=n.attrs;t.fontFamily={ascii:o.ascii,hAnsi:o.hAnsi,eastAsia:o.eastAsia||void 0,cs:o.cs||o.ascii||void 0,asciiTheme:o.asciiTheme,hAnsiTheme:o.hAnsiTheme||void 0,eastAsiaTheme:o.eastAsiaTheme||void 0,csTheme:o.csTheme||void 0};break}case "superscript":t.vertAlign="superscript";break;case "subscript":t.vertAlign="subscript";break;case "allCaps":t.allCaps=true;break;case "smallCaps":t.smallCaps=true;break;case "characterSpacing":{n.attrs.spacing!=null&&(t.spacing=n.attrs.spacing),n.attrs.position!=null&&(t.position=n.attrs.position),n.attrs.scale!=null&&(t.scale=n.attrs.scale),n.attrs.kerning!=null&&(t.kerning=n.attrs.kerning);break}case "emboss":t.emboss=true;break;case "imprint":t.imprint=true;break;case "textShadow":t.shadow=true;break;case "emphasisMark":t.emphasisMark=n.attrs.type||"dot";break;case "textOutline":t.outline=true;break}return t}function Hh(e){for(let t of e)for(let n of t.cells){let o=n.formatting?.borders;if(o){let r=o.top||o.left||o.right||o.bottom||o.insideH||o.insideV;return r?{top:o.top??r,bottom:o.bottom??r,left:o.left??r,right:o.right??r,insideH:o.insideH??o.bottom??r,insideV:o.insideV??o.right??r}:void 0}}}function pu(e,t){let n=e.attrs,o=[];e.forEach(i=>{i.type.name==="tableRow"&&o.push(zh(i,t));});let r=Nh(n)||void 0;if(!r?.borders){let i=Hh(o);if(i)if(r)r.borders=i;else return {type:"table",columnWidths:n.columnWidths||void 0,formatting:{borders:i},rows:o}}return {type:"table",columnWidths:n.columnWidths||void 0,formatting:r,rows:o}}function Nh(e){if(e._originalFormatting){let r=e._originalFormatting,i={...r};e.styleId!==(r.styleId||void 0)&&(i.styleId=e.styleId||void 0),e.justification!==(r.justification||void 0)&&(i.justification=e.justification||void 0),e.floating!==(r.floating||void 0)&&(i.floating=e.floating||void 0),e.look!==(r.look||void 0)&&(i.look=e.look||void 0);let a=r.width?.value,s=r.width?.type;return (e.width!==a||e.widthType!==s)&&(e.width!=null||e.widthType?i.width={value:e.width??0,type:e.widthType||"dxa"}:i.width=void 0),e.cellMargins&&(i.cellMargins={top:e.cellMargins.top!=null?{value:e.cellMargins.top,type:"dxa"}:void 0,bottom:e.cellMargins.bottom!=null?{value:e.cellMargins.bottom,type:"dxa"}:void 0,left:e.cellMargins.left!=null?{value:e.cellMargins.left,type:"dxa"}:void 0,right:e.cellMargins.right!=null?{value:e.cellMargins.right,type:"dxa"}:void 0}),i}if(!(e.styleId||e.width!=null||e.widthType||e.justification||e.floating||e.cellMargins||e.look))return;let n=e.cellMargins?{top:e.cellMargins.top!=null?{value:e.cellMargins.top,type:"dxa"}:void 0,bottom:e.cellMargins.bottom!=null?{value:e.cellMargins.bottom,type:"dxa"}:void 0,left:e.cellMargins.left!=null?{value:e.cellMargins.left,type:"dxa"}:void 0,right:e.cellMargins.right!=null?{value:e.cellMargins.right,type:"dxa"}:void 0}:void 0,o;return (e.width!=null||e.widthType)&&(o={value:e.width??0,type:e.widthType||"dxa"}),{styleId:e.styleId||void 0,width:o,justification:e.justification||void 0,floating:e.floating||void 0,cellMargins:n,look:e.look||void 0}}function zh(e,t){let n=e.attrs,o=[];return e.forEach(r=>{(r.type.name==="tableCell"||r.type.name==="tableHeader")&&o.push($h(r,t));}),{type:"tableRow",formatting:Oh(n),cells:o}}function Oh(e){if(e._originalFormatting){let n=e._originalFormatting,o={...n};return e.height!==(n.height?.value||void 0)&&(o.height=e.height?{value:e.height,type:"dxa"}:void 0),e.heightRule!==(n.heightRule||void 0)&&(o.heightRule=e.heightRule||void 0),e.isHeader!==(n.header||void 0)&&(o.header=e.isHeader||void 0),o}if(e.height||e.isHeader)return {height:e.height?{value:e.height,type:"dxa"}:void 0,heightRule:e.heightRule||void 0,header:e.isHeader||void 0}}function $h(e,t){let n=e.attrs,o=[];return e.forEach(r=>{r.type.name==="paragraph"?o.push($s(r,t)):r.type.name==="table"&&o.push(pu(r,t));}),{type:"tableCell",formatting:Wh(n),content:o}}function Wh(e){if(e._originalFormatting){let o=e._originalFormatting,r={...o};if(e.colspan>1&&(r.gridSpan=e.colspan),e.width!=null&&(r.width={value:e.width,type:e.widthType||"dxa"}),e.verticalAlign!==(o.verticalAlign||void 0)&&(r.verticalAlign=e.verticalAlign||void 0),e.backgroundColor?r.shading={fill:{rgb:e.backgroundColor}}:!e.backgroundColor&&o.shading&&(r.shading=void 0),e.borders&&(r.borders=e.borders),e.margins){let i=e.margins,a={};i.top!=null&&(a.top={value:i.top,type:"dxa"}),i.bottom!=null&&(a.bottom={value:i.bottom,type:"dxa"}),i.left!=null&&(a.left={value:i.left,type:"dxa"}),i.right!=null&&(a.right={value:i.right,type:"dxa"}),r.margins=a;}return e.textDirection!==(o.textDirection||void 0)&&(r.textDirection=e.textDirection||void 0),r}if(!(e.colspan>1||e.rowspan>1||e.width!=null||e.verticalAlign||e.backgroundColor||e.borders||e.margins||e.textDirection))return;let n;if(e.margins){let o=e.margins;n={},o.top!=null&&(n.top={value:o.top,type:"dxa"}),o.bottom!=null&&(n.bottom={value:o.bottom,type:"dxa"}),o.left!=null&&(n.left={value:o.left,type:"dxa"}),o.right!=null&&(n.right={value:o.right,type:"dxa"});}return {gridSpan:e.colspan>1?e.colspan:void 0,width:e.width!=null?{value:e.width,type:e.widthType||"dxa"}:void 0,verticalAlign:e.verticalAlign||void 0,textDirection:e.textDirection||void 0,shading:e.backgroundColor?{fill:{rgb:e.backgroundColor}}:void 0,borders:e.borders,margins:n}}function _h(e){let t=e.attrs,n=[];e.forEach(a=>{a.type.name==="paragraph"&&n.push($s(a));});let o={type:"shape",shapeType:"rect",id:t.textBoxId||void 0,size:{width:t.width?Math.round(t.width*(914400/96)):0,height:t.height?Math.round(t.height*(914400/96)):0},textBody:{content:n.length>0?n:[{type:"paragraph",content:[]}],margins:{top:t.marginTop!=null?Math.round(t.marginTop*(914400/96)):void 0,bottom:t.marginBottom!=null?Math.round(t.marginBottom*(914400/96)):void 0,left:t.marginLeft!=null?Math.round(t.marginLeft*(914400/96)):void 0,right:t.marginRight!=null?Math.round(t.marginRight*(914400/96)):void 0}}};if(t.fillColor&&(o.fill={type:"solid",color:{rgb:t.fillColor.replace("#","")}}),t.outlineWidth&&t.outlineWidth>0){let a={solid:"solid",dotted:"dot",dashed:"dash"};o.outline={width:Math.round(t.outlineWidth*(914400/96)),color:t.outlineColor?{rgb:t.outlineColor.replace("#","")}:void 0,style:t.outlineStyle&&a[t.outlineStyle]||"solid"};}return {type:"paragraph",content:[{type:"run",content:[{type:"shape",shape:o}]}]}}function Sr(e){return lu(e)}function Go(e){let{selection:t,doc:n}=e,{from:o,to:r,empty:i}=t,a=n.resolve(o),s=0,l=0;n.forEach((g,x,T)=>{x<=o&&(s=T),x<=r&&(l=T);});let u={},d=a.parent,c=d.type.name==="paragraph"&&d.textContent.length===0,p=d.attrs?.defaultTextFormatting,f=e.storedMarks||t.$from.marks();c&&f.length===0&&p&&(u={...p});for(let g of f)switch(g.type.name){case "bold":u.bold=true;break;case "italic":u.italic=true;break;case "underline":u.underline={style:g.attrs.style||"single",color:g.attrs.color};break;case "strike":g.attrs.double?u.doubleStrike=true:u.strike=true;break;case "textColor":u.color={rgb:g.attrs.rgb,themeColor:g.attrs.themeColor};break;case "highlight":u.highlight=g.attrs.color;break;case "fontSize":u.fontSize=g.attrs.size;break;case "fontFamily":u.fontFamily={ascii:g.attrs.ascii,hAnsi:g.attrs.hAnsi};break;case "superscript":u.vertAlign="superscript";break;case "subscript":u.vertAlign="subscript";break}let m={},b=null;return d.type.name==="paragraph"&&(d.attrs.alignment&&(m.alignment=d.attrs.alignment),d.attrs.lineSpacing&&(m.lineSpacing=d.attrs.lineSpacing,m.lineSpacingRule=d.attrs.lineSpacingRule),d.attrs.numPr&&(m.numPr=d.attrs.numPr),d.attrs.indentLeft&&(m.indentLeft=d.attrs.indentLeft),d.attrs.indentRight&&(m.indentRight=d.attrs.indentRight),d.attrs.indentFirstLine&&(m.indentFirstLine=d.attrs.indentFirstLine),d.attrs.hangingIndent&&(m.hangingIndent=d.attrs.hangingIndent),d.attrs.tabs&&(m.tabs=d.attrs.tabs),d.attrs.bidi&&(m.bidi=true),d.attrs.styleId&&(b=d.attrs.styleId)),{hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:m,styleId:b,startParagraphIndex:s,endParagraphIndex:l}}var Et=In.getCommands(),Ti=Et.toggleBold(),wi=Et.toggleItalic(),Ci=Et.toggleUnderline(),vi=Et.toggleStrike(),Ri=Et.toggleSuperscript(),Ei=Et.toggleSubscript();function kr(e){return Et.setTextColor(e)}var Mi=Et.clearTextColor();function Pi(e){return Et.setHighlight(e)}Et.clearHighlight();function Ii(e){return Et.setFontSize(e)}Et.clearFontSize();function Fi(e){return Et.setFontFamily(e)}Et.clearFontFamily();function Li(e,t){return Et.setHyperlink(e,t)}var Bi=Et.removeHyperlink();function Tr(e,t,n){return Et.insertHyperlink(e,t,n)}var st=In.getCommands();function Ai(e){return st.setAlignment(e)}st.alignLeft();st.alignCenter();st.alignRight();st.alignJustify();function Di(e,t="auto"){return st.setLineSpacing(e,t)}st.singleSpacing();st.oneAndHalfSpacing();st.doubleSpacing();function Hi(e=720){return st.increaseIndent(e)}function Ni(e=720){return st.decreaseIndent(e)}function zi(e){return st.setIndentLeft(e)}function Oi(e){return st.setIndentRight(e)}function wr(e,t){return st.setIndentFirstLine(e,t)}var $i=st.toggleBulletList(),Wi=st.toggleNumberedList(),_i=st.increaseListLevel(),Vi=st.decreaseListLevel();st.removeList();function Cr(e,t){return st.applyStyle(e,t)}st.clearStyle();st.removeSectionBreak();function Ui(e){return st.removeTabStop(e)}var ji=st.setRtl(),Gi=st.setLtr(),Ki=st.generateTOC();var et=In.getCommands();function Yi(e,t){return et.insertTable(e,t)}function vr(e,t){return et.addRowAbove()(e,t)}function wo(e,t){return et.addRowBelow()(e,t)}function Rr(e,t){return et.deleteRow()(e,t)}function Er(e,t){return et.addColumnLeft()(e,t)}function Co(e,t){return et.addColumnRight()(e,t)}function Mr(e,t){return et.deleteColumn()(e,t)}function Pr(e,t){return et.deleteTable()(e,t)}function qi(e,t){return et.selectTable()(e,t)}function Xi(e,t){return et.selectRow()(e,t)}function Zi(e,t){return et.selectColumn()(e,t)}function Ji(e,t){return et.mergeCells()(e,t)}function Qi(e,t){return et.splitCell()(e,t)}function Kn(e,t,n){return et.setCellBorder(e,t,n)}function ea(e,t){return et.removeTableBorders()(e,t)}function ta(e,t,n){return et.setAllTableBorders(n)(e,t)}function na(e,t,n){return et.setOutsideTableBorders(n)(e,t)}function oa(e,t,n){return et.setInsideTableBorders(n)(e,t)}function ra(e){return et.setCellVerticalAlign(e)}function ia(e){return et.setCellMargins(e)}function aa(e){return et.setCellTextDirection(e)}function sa(){return et.toggleNoWrap()}function la(e,t){return et.setRowHeight(e,t)}function ca(){return et.toggleHeaderRow()}function da(){return et.distributeColumns()}function ua(){return et.autoFitContents()}function Ir(e){return et.setTableProperties(e)}function pa(e){return et.applyTableStyle(e)}function fa(e){return et.setCellFillColor(e)}function ma(e){return et.setTableBorderColor(e)}function ga(e){return et.setTableBorderWidth(e)}var ha=(e,t)=>{let{schema:n}=e,o=n.nodes.pageBreak,r=n.nodes.paragraph;if(!o||!r)return false;if(t){let{$from:i}=e.selection,a=e.tr,s=o.create(),l=s.nodeSize,u;if(i.parent.isTextblock)if(i.parentOffset>0&&i.parentOffset<i.parent.content.size){a.split(i.pos);let d=a.mapping.map(i.pos);a.insert(d,prosemirrorModel.Fragment.from([s,r.create()])),u=d+l+1;}else if(i.parentOffset===i.parent.content.size){let d=i.after();a.insert(d,prosemirrorModel.Fragment.from([s,r.create()])),u=d+l+1;}else {let d=i.before();a.insert(d,s),u=d+l+1;}else {let d=i.pos;a.insert(d,prosemirrorModel.Fragment.from([s,r.create()])),u=d+l+1;}a.setSelection(prosemirrorState.TextSelection.create(a.doc,u)),t(a.scrollIntoView());}return true};function Pu(e,t,n){return (o,r)=>{let i=o.schema.marks.insertion,a=o.schema.marks.deletion;if(!i&&!a)return false;let s=n==="accept"?i:a,l=n==="accept"?a:i;if(r){let u=o.tr,d=[];o.doc.nodesBetween(e,t,(c,p)=>{if(!c.isText)return;let f=p+c.nodeSize,m=Math.max(e,p),b=Math.min(t,f);l&&c.marks.some(g=>g.type===l)&&d.push({from:m,to:b}),s&&c.marks.some(g=>g.type===s)&&u.removeMark(m,b,s);});for(let c of d.reverse())u.delete(c.from,c.to);u.steps.length>0&&r(u);}return true}}function Vs(e,t){return Pu(e,t,"accept")}function Us(e,t){return Pu(e,t,"reject")}var Fu={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"2px 0",fontSize:11,color:"#4285f4",userSelect:"none"},Lu={fontWeight:500,letterSpacing:.3},ab={background:"none",border:"none",color:"#4285f4",cursor:"pointer",fontSize:11,padding:"2px 6px",borderRadius:3},sb={position:"absolute",right:0,top:"100%",background:"white",border:"1px solid #dadce0",borderRadius:4,boxShadow:"0 2px 6px rgba(0,0,0,0.15)",zIndex:100,minWidth:160,padding:"4px 0"},ba={display:"block",width:"100%",padding:"6px 12px",border:"none",background:"none",textAlign:"left",cursor:"pointer",fontSize:12,color:"#3c4043"},Au=rf.forwardRef(function({headerFooter:t,position:n,styles:o,targetElement:r,parentElement:i,onSave:a,onClose:s,onSelectionChange:l,onRemove:u},d){let c=rf.useRef(null),p=rf.useRef(null),[f,m]=rf.useState(false),[b,g]=rf.useState(false),x=rf.useRef(null),[T,S]=rf.useState(null);rf.useLayoutEffect(()=>{let q=()=>{let H=i.getBoundingClientRect(),ee=r.getBoundingClientRect();S({top:ee.top-H.top+i.scrollTop,left:ee.left-H.left+i.scrollLeft,width:ee.width});};q();let z=i.closest('[style*="overflow"]')||i;return z.addEventListener("scroll",q),window.addEventListener("resize",q),()=>{z.removeEventListener("scroll",q),window.removeEventListener("resize",q);}},[r,i]),rf.useEffect(()=>{if(!c.current||p.current)return;let q=Os(t.content,{styles:o||void 0}),z=new Gn(jo());z.buildSchema(),z.initializeRuntime();let H=z.getPlugins(),ee=prosemirrorState.EditorState.create({doc:q,schema:ke,plugins:H}),ue=new prosemirrorView.EditorView(c.current,{state:ee,dispatchTransaction(A){let O=ue.state.apply(A);if(ue.updateState(O),A.docChanged&&m(true),A.selectionSet||A.docChanged){let ie=Go(O);l?.(ie);}}});return p.current=ue,requestAnimationFrame(()=>{ue.focus();let A=Go(ue.state);l?.(A);}),()=>{ue.destroy(),p.current=null;}},[T]);let B=rf.useCallback(()=>{if(!p.current)return;let q=Sr(p.current.state.doc);a(q);},[a]),C=rf.useCallback(()=>{f?B():s();},[f,B,s]);rf.useEffect(()=>{function q(z){z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),C());}return document.addEventListener("keydown",q,true),()=>document.removeEventListener("keydown",q,true)},[C]),rf.useEffect(()=>{if(!b)return;function q(z){x.current&&!x.current.contains(z.target)&&g(false);}return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[b]),rf.useImperativeHandle(d,()=>({getView:()=>p.current,focus:()=>p.current?.focus(),undo:()=>{let q=p.current;return q?prosemirrorHistory.undo(q.state,q.dispatch):false},redo:()=>{let q=p.current;return q?prosemirrorHistory.redo(q.state,q.dispatch):false}}));let P=n==="header"?"Header":"Footer";if(!T)return null;let _={position:"absolute",top:T.top,left:T.left,width:T.width,zIndex:10};return jsxRuntime.jsxs("div",{className:"hf-inline-editor",style:_,onMouseDown:q=>{q.stopPropagation();},children:[n==="footer"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:Fu,children:[jsxRuntime.jsx("span",{style:Lu,children:P}),jsxRuntime.jsx(Bu,{label:P,showOptions:b,setShowOptions:g,optionsRef:x,onRemove:u,onClose:C,viewRef:p})]}),jsxRuntime.jsx("div",{ref:c,className:"hf-editor-pm",style:{minHeight:40,outline:"none"}}),n==="header"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:Fu,children:[jsxRuntime.jsx("span",{style:Lu,children:P}),jsxRuntime.jsx(Bu,{label:P,showOptions:b,setShowOptions:g,optionsRef:x,onRemove:u,onClose:C,viewRef:p})]})]})});function Bu({label:e,showOptions:t,setShowOptions:n,optionsRef:o,onRemove:r,onClose:i,viewRef:a}){let s=l=>{let u=a.current;if(!u)return;let{$from:d,from:c}=u.state.selection,p=u.state.storedMarks||d.marks(),f=ke.nodes.field.create({fieldType:l,instruction:` ${l} \\* MERGEFORMAT `,fieldKind:"simple",dirty:true}),m=u.state.tr.insert(c,f.mark(p));u.dispatch(m),u.focus();};return jsxRuntime.jsxs("div",{style:{position:"relative"},ref:o,children:[jsxRuntime.jsx("button",{type:"button",style:ab,onClick:l=>{l.stopPropagation(),n(u=>!u);},onMouseDown:l=>l.stopPropagation(),children:"Options \u25BE"}),t&&jsxRuntime.jsxs("div",{style:sb,children:[jsxRuntime.jsx("button",{type:"button",style:ba,onClick:()=>{n(false),s("PAGE");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert current page number"}),jsxRuntime.jsx("button",{type:"button",style:ba,onClick:()=>{n(false),s("NUMPAGES");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert total page count"}),jsxRuntime.jsx("div",{style:{borderTop:"1px solid #e8eaed",margin:"4px 0"}}),r&&jsxRuntime.jsxs("button",{type:"button",style:ba,onClick:()=>{n(false),r();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Remove ",e.toLowerCase()]}),jsxRuntime.jsxs("button",{type:"button",style:ba,onClick:()=>{n(false),i();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Close ",e.toLowerCase()," editing"]})]})]})}var zu={position:"fixed",zIndex:1e4,background:"white",borderRadius:"8px",boxShadow:"0 1px 3px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.08)",border:"1px solid #dadce0",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px"},cb={...zu,padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",maxWidth:"400px"},db={...zu,padding:"12px",width:"320px"},qs={width:"20px",height:"20px",flexShrink:0,color:"#5f6368",display:"flex",alignItems:"center",justifyContent:"center"},ub={color:"#1a73e8",textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"220px",fontSize:"14px",lineHeight:"20px",cursor:"pointer"},pb={width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"none",borderRadius:"4px",cursor:"pointer",color:"#5f6368",padding:0,flexShrink:0},fb={width:"1px",height:"20px",background:"#dadce0",flexShrink:0},Hu={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},Nu={flex:1,padding:"6px 8px",border:"1px solid #dadce0",borderRadius:"4px",fontSize:"14px",outline:"none",lineHeight:"20px"},mb={color:"#1a73e8",fontWeight:600,fontSize:"14px",border:"none",background:"none",cursor:"pointer",padding:"6px 12px",borderRadius:"4px",flexShrink:0},Ko={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function gb(){return jsxRuntime.jsxs("svg",{...Ko,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 hb(){return jsxRuntime.jsxs("svg",{...Ko,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 bb(){return jsxRuntime.jsx("svg",{...Ko,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 yb(){return jsxRuntime.jsxs("svg",{...Ko,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 xb(){return jsxRuntime.jsxs("svg",{...Ko,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 Sb(){return jsxRuntime.jsxs("svg",{...Ko,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 Xs({title:e,onClick:t,children:n}){return jsxRuntime.jsx("button",{type:"button",className:"ep-hyperlink-popup__icon-btn",style:pb,title:e,onClick:t,children:n})}function Ou({data:e,onNavigate:t,onCopy:n,onEdit:o,onRemove:r,onClose:i,readOnly:a}){let[s,l]=rf.useState("view"),[u,d]=rf.useState(""),[c,p]=rf.useState(""),f=rf.useRef(null),m=rf.useRef(null);rf.useEffect(()=>{e&&(l("view"),d(e.displayText),p(e.href));},[e]),rf.useEffect(()=>{s==="edit"&&requestAnimationFrame(()=>{m.current?.focus(),m.current?.select();});},[s]),rf.useEffect(()=>{if(!e)return;let P=false,_=z=>{f.current&&!f.current.contains(z.target)&&i();},q=setTimeout(()=>{P||document.addEventListener("mousedown",_);},0);return ()=>{P=true,clearTimeout(q),document.removeEventListener("mousedown",_);}},[e,i]),rf.useEffect(()=>{if(!e)return;let P=_=>{_.key==="Escape"&&(s==="edit"?l("view"):i());};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[e,s,i]);let b=rf.useCallback(()=>{e&&(n(e.href),sonner.toast("Link copied to clipboard"));},[e,n]),g=rf.useCallback(()=>{e&&(d(e.displayText),p(e.href),l("edit"));},[e]),x=rf.useCallback(()=>{let P=c.trim();P&&o(u.trim()||P,P);},[u,c,o]),T=rf.useCallback(P=>{P.key==="Enter"&&(P.preventDefault(),x());},[x]);if(!e)return null;let{anchorRect:S}=e,B=S.bottom+4,C=S.left;return s==="edit"?jsxRuntime.jsxs("div",{ref:f,className:"ep-hyperlink-popup ep-hyperlink-popup--edit",style:{...db,top:B,left:C},onMouseDown:P=>P.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:Hu,children:[jsxRuntime.jsx("span",{style:qs,children:jsxRuntime.jsx(xb,{})}),jsxRuntime.jsx("input",{ref:m,type:"text",style:Nu,value:u,onChange:P=>d(P.target.value),onKeyDown:T,placeholder:"Display text",onFocus:P=>P.target.style.borderColor="#1a73e8",onBlur:P=>P.target.style.borderColor="#dadce0"})]}),jsxRuntime.jsxs("div",{style:{...Hu,marginBottom:0},children:[jsxRuntime.jsx("span",{style:qs,children:jsxRuntime.jsx(Sb,{})}),jsxRuntime.jsx("input",{type:"text",style:Nu,value:c,onChange:P=>p(P.target.value),onKeyDown:T,placeholder:"https://example.com",onFocus:P=>P.target.style.borderColor="#1a73e8",onBlur:P=>P.target.style.borderColor="#dadce0"}),jsxRuntime.jsx("button",{type:"button",style:{...mb,opacity:c.trim()?1:.5,cursor:c.trim()?"pointer":"default"},onClick:x,disabled:!c.trim(),children:"Apply"})]})]}):jsxRuntime.jsxs("div",{ref:f,className:"ep-hyperlink-popup",style:{...cb,top:B,left:C},onMouseDown:P=>P.stopPropagation(),children:[jsxRuntime.jsx("span",{style:qs,children:jsxRuntime.jsx(gb,{})}),jsxRuntime.jsx("a",{href:e.href,style:ub,title:e.href,target:"_blank",rel:"noopener noreferrer",onClick:P=>{P.preventDefault(),t(e.href);},children:e.href}),jsxRuntime.jsx("span",{style:fb}),jsxRuntime.jsx(Xs,{title:"Copy link",onClick:b,children:jsxRuntime.jsx(hb,{})}),!a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xs,{title:"Edit link",onClick:g,children:jsxRuntime.jsx(bb,{})}),jsxRuntime.jsx(Xs,{title:"Remove link",onClick:r,children:jsxRuntime.jsx(yb,{})})]})]})}var Pe=e=>({style:"single",size:4,color:{rgb:e}}),Tb=[{id:"TableNormal",name:"Normal Table",look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGrid",name:"Table Grid",tableBorders:{top:Pe("000000"),bottom:Pe("000000"),left:Pe("000000"),right:Pe("000000"),insideH:Pe("000000"),insideV:Pe("000000")},look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGridLight",name:"Grid Table Light",tableBorders:{top:Pe("BFBFBF"),bottom:Pe("BFBFBF"),left:Pe("BFBFBF"),right:Pe("BFBFBF"),insideH:Pe("BFBFBF"),insideV:Pe("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:Pe("000000")}}}},{id:"PlainTable1",name:"Plain Table 1",tableBorders:{top:Pe("BFBFBF"),bottom:Pe("BFBFBF"),insideH:Pe("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:Pe("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:Pe("B4C6E7"),bottom:Pe("B4C6E7"),left:Pe("B4C6E7"),right:Pe("B4C6E7"),insideH:Pe("B4C6E7"),insideV:Pe("B4C6E7")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:Pe("4472C4")}}}},{id:"GridTable4-Accent1",name:"Grid Table 4 Accent 1",tableBorders:{top:Pe("4472C4"),bottom:Pe("4472C4"),left:Pe("4472C4"),right:Pe("4472C4"),insideH:Pe("4472C4"),insideV:Pe("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:Pe("FFFFFF"),bottom:Pe("FFFFFF"),left:Pe("FFFFFF"),right:Pe("FFFFFF"),insideH:Pe("FFFFFF"),insideV:Pe("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:Pe("ED7D31"),bottom:Pe("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:Pe("A5A5A5"),bottom:Pe("A5A5A5"),insideH:Pe("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:Pe("5B9BD5"),bottom:Pe("5B9BD5"),left:Pe("5B9BD5"),right:Pe("5B9BD5"),insideH:Pe("5B9BD5"),insideV:Pe("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:Pe("70AD47"),bottom:Pe("70AD47"),left:Pe("70AD47"),right:Pe("70AD47"),insideH:Pe("70AD47"),insideV:Pe("70AD47")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#70AD47"},band1Horz:{backgroundColor:"#E2EFDA"}}}];function $u(e){return Tb.find(t=>t.id===e)}function Wu(){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:`
|
|
15
|
+
@keyframes docx-spin {
|
|
16
|
+
to { transform: rotate(360deg); }
|
|
17
|
+
}
|
|
18
|
+
`}),jsxRuntime.jsx("div",{style:{fontSize:"14px"},children:"Loading document..."})]})}function _u(){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:"No document loaded"})]})}function Vu({message:e}){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:"Failed to Load Document"}),jsxRuntime.jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function Cb(e,t){return JSON.stringify(e)===JSON.stringify(t)}function vb(e,t={}){let{maxEntries:n=100,groupingInterval:o=500,enableKeyboardShortcuts:r=true,isEqual:i=Cb,onUndo:a,onRedo:s,containerRef:l}=t,[u,d]=rf.useState(e),[c,p]=rf.useState([]),[f,m]=rf.useState([]),b=rf.useRef(0),g=rf.useRef(false),x=rf.useCallback((z,H)=>{if(i(u,z))return;if(g.current){d(z);return}let ee=Date.now();ee-b.current<o&&c.length>0?p(A=>{let O=[...A];return O[O.length-1]={state:u,timestamp:ee,description:H||O[O.length-1].description},O}):p(A=>{let O={state:u,timestamp:ee,description:H},ie=[...A,O];return ie.length>n?ie.slice(ie.length-n):ie}),m([]),d(z),b.current=ee;},[u,i,o,n,c.length]),T=rf.useCallback(()=>{if(c.length===0)return;g.current=true;let z=c[c.length-1];return p(H=>H.slice(0,-1)),m(H=>[...H,{state:u,timestamp:Date.now()}]),d(z.state),setTimeout(()=>{g.current=false;},0),a?.(z.state),z.state},[c,u,a]),S=rf.useCallback(()=>{if(f.length===0)return;g.current=true;let z=f[f.length-1];return m(H=>H.slice(0,-1)),p(H=>[...H,{state:u,timestamp:Date.now()}]),d(z.state),setTimeout(()=>{g.current=false;},0),s?.(z.state),z.state},[f,u,s]),B=rf.useCallback(()=>{p([]),m([]);},[]),C=rf.useCallback(z=>{d(z??e),p([]),m([]),b.current=0;},[e]),P=rf.useCallback(()=>[...c],[c]),_=rf.useCallback(()=>[...f],[f]),q=rf.useCallback(z=>{d(H=>z(H)),p(H=>H.map(ee=>({...ee,state:z(ee.state)}))),m(H=>H.map(ee=>({...ee,state:z(ee.state)})));},[]);return rf.useEffect(()=>{if(!r)return;let z=ee=>{if((ee.ctrlKey||ee.metaKey)&&ee.key==="z"&&!ee.shiftKey){ee.preventDefault(),T();return}if((ee.ctrlKey||ee.metaKey)&&ee.key==="y"||(ee.ctrlKey||ee.metaKey)&&ee.key==="z"&&ee.shiftKey){ee.preventDefault(),S();return}},H=l?.current||document;return H.addEventListener("keydown",z),()=>{H.removeEventListener("keydown",z);}},[r,T,S,l]),{state:u,canUndo:c.length>0,canRedo:f.length>0,undoCount:c.length,redoCount:f.length,push:x,undo:T,redo:S,clear:B,reset:C,getUndoStack:P,getRedoStack:_,transformAll:q}}function ju(e,t={}){let n=rf.useCallback((o,r)=>!(o?.package?.document!==r?.package?.document&&JSON.stringify(o?.package?.document)!==JSON.stringify(r?.package?.document)||o?.package?.headers!==r?.package?.headers||o?.package?.footers!==r?.package?.footers),[]);return vb(e,{...t,isEqual:n})}var Yn=new prosemirrorState.PluginKey("suggestionMode"),Sa="suggestionModeApplied",Mb=Date.now();function ka(e){return {revisionId:Mb++,author:e.author,date:new Date().toISOString()}}function Qs(e,t,n,o){try{let r=e.resolve(t);for(let i of [r.nodeBefore,r.nodeAfter])if(i?.isText){let a=i.marks.find(s=>s.type.name===n&&s.attrs.author===o);if(a)return a.attrs}}catch{}return null}function Yu(e,t,n,o,r,i,a){let s=[];if(t.nodesBetween(n,o,(u,d)=>{if(!u.isText)return;let c=Math.max(d,n),p=Math.min(d+u.nodeSize,o);if(c>=p)return;let f=u.marks.some(m=>m.type===r&&m.attrs.author===a.author);s.push({from:c,to:p,isOwnInsert:f});}),s.length===0)return;let l=Qs(t,n,"deletion",a.author)||ka(a);for(let u=s.length-1;u>=0;u--){let d=s[u];d.isOwnInsert?e.delete(d.from,d.to):e.addMark(d.from,d.to,i.create(l));}}function Gu(e,t,n,o,r){let i=e.state.schema.marks.insertion;if(!i)return false;let a=e.state.tr;a.setMeta(Sa,true);let s=Qs(e.state.doc,t,"insertion",r.author)||ka(r);if(t!==n){let u=e.state.schema.marks.deletion;u&&Yu(a,e.state.doc,t,n,i,u,r);}let l=a.mapping.map(n);return a.insertText(o,l,l),a.addMark(l,l+o.length,i.create(s)),e.dispatch(a.scrollIntoView()),true}function Ku(e,t,n){let o=Yn.getState(e);if(!o?.active)return false;let{$from:r,$to:i,empty:a}=e.selection,s=e.schema.marks.insertion,l=e.schema.marks.deletion;if(!s||!l)return false;if(!t)return true;let u=e.tr;if(u.setMeta(Sa,true),!a){Yu(u,e.doc,r.pos,i.pos,s,l,o);let x=u.mapping.map(i.pos);return u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(x))),t(u.scrollIntoView()),true}let d=n==="backward",c=d?r.pos-1:r.pos,p=d?r.pos:r.pos+1;if(c<0||p>e.doc.content.size)return true;let m=e.doc.resolve(c).nodeAfter;if(!m?.isText)return false;let b=m.marks.some(x=>x.type===s&&x.attrs.author===o.author);if(m.marks.some(x=>x.type===l)){let x=d?c:p;u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(x)));}else if(b)u.delete(c,p);else {let x=Qs(e.doc,c,"deletion",o.author)||ka(o);u.addMark(c,p,l.create(x));let T=d?c:p;u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(T)));}return t(u.scrollIntoView()),true}function qu(e=false,t="User"){return new prosemirrorState.Plugin({key:Yn,state:{init(){return {active:e,author:t}},apply(n,o){let r=n.getMeta(Yn);return r?{...o,...r}:o}},props:{handleDOMEvents:{beforeinput(n,o){let r=Yn.getState(n.state);if(!r?.active)return false;if(o.inputType==="insertText"&&o.data){o.preventDefault();let{from:i,to:a}=n.state.selection;return Gu(n,i,a,o.data,r)}return false}},handleKeyDown(n,o){return Yn.getState(n.state)?.active?o.key==="Backspace"?Ku(n.state,n.dispatch,"backward"):o.key==="Delete"?Ku(n.state,n.dispatch,"forward"):false:false},handleTextInput(n,o,r,i){let a=Yn.getState(n.state);return a?.active?Gu(n,o,r,i,a):false}},appendTransaction(n,o,r){let i=Yn.getState(r);if(!i?.active)return null;let a=n.find(c=>c.docChanged&&!c.getMeta(Sa));if(!a)return null;let s=r.schema.marks.insertion;if(!s)return null;let l=ka(i),u=r.tr;u.setMeta(Sa,true);let d=r.schema.marks.deletion;return a.steps.forEach(c=>{c.getMap().forEach((f,m,b,g)=>{g>b&&r.doc.nodesBetween(b,g,(x,T)=>{if(!x.isText)return;if(!x.marks.some(B=>B.type===s||d&&B.type===d)){let B=Math.max(T,b),C=Math.min(T+x.nodeSize,g);u.addMark(B,C,s.create(l));}});});}),u.steps.length>0?u:null}})}function Xu(e,t,n,o){if(n){let r={active:e};o!==void 0&&(r.author=o);let i=t.tr.setMeta(Yn,r);n(i);}return true}var Nb={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function ep(e,t,n,o=[]){let r=n?.getSchema()??ke,i=e?xi(e,{styles:t??void 0}):Si(),a=[...o,...n?.getPlugins()??[]];return prosemirrorState.EditorState.create({doc:i,schema:r,plugins:a})}function zb(e,t){return t?ki(e.doc,t):null}var Ob=rf.forwardRef(function(t,n){let{document:o,styles:r,theme:i,widthPx:a=612,readOnly:s=false,onTransaction:l,onSelectionChange:u,externalPlugins:d=[],extensionManager:c,onEditorViewReady:p,onEditorViewDestroy:f,onKeyDown:m}=t,b=rf.useRef(null),g=rf.useRef(null),x=rf.useRef(o),T=rf.useRef(false),S=rf.useRef(null),B=rf.useRef(false),C=rf.useRef(l),P=rf.useRef(u),_=rf.useRef(p),q=rf.useRef(f),z=rf.useRef(m);C.current=l,P.current=u,_.current=p,q.current=f,z.current=m,x.current=o;let H=rf.useCallback(()=>{if(!b.current||T.current)return;let A={state:ep(o,r,c,d),editable:()=>!s,dispatchTransaction:O=>{if(!g.current||T.current)return;let ie=g.current.state.apply(O);g.current.updateState(ie),C.current?.(O,ie),(O.selectionSet||O.docChanged)&&P.current?.(ie);},handleKeyDown:(O,ie)=>z.current?.(O,ie)??false,handleDOMEvents:{focus:()=>false,blur:()=>false}};g.current=new prosemirrorView.EditorView(b.current,A),_.current?.(g.current);},[o,r,d,c,s]),ee=rf.useCallback(()=>{g.current&&!T.current&&(T.current=true,q.current?.(),g.current.destroy(),g.current=null,T.current=false);},[]);return rf.useEffect(()=>(H(),()=>ee()),[]),rf.useEffect(()=>{if(!g.current||T.current)return;let A=(ie=>{if(!ie)return "empty";let ae=ie.package?.properties;return `${ae?.created||""}-${ae?.modified||""}-${ae?.title||""}`})(o);if(B.current&&A===S.current)return;B.current=true,S.current=A;let O=ep(o,r,c,d);g.current.updateState(O),P.current?.(O);},[o,r,c,d]),rf.useEffect(()=>{g.current;},[s]),rf.useImperativeHandle(n,()=>({getState(){return g.current?.state??null},getView(){return g.current??null},getDocument(){return g.current?zb(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(ue){g.current&&!T.current&&g.current.dispatch(ue);},executeCommand(ue){return g.current?ue(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(ue,A){if(!g.current)return;let{state:O,dispatch:ie}=g.current,ae=O.doc.resolve(ue),N=A!==void 0?O.doc.resolve(A):ae,Ie=prosemirrorState.TextSelection.between(ae,N);ie(O.tr.setSelection(Ie));},setNodeSelection(ue){if(!g.current)return;let{state:A,dispatch:O}=g.current;try{let ie=prosemirrorState.NodeSelection.create(A.doc,ue);O(A.tr.setSelection(ie));}catch{this.setSelection(ue);}},setCellSelection(ue,A){if(!g.current)return;let{state:O,dispatch:ie}=g.current;try{let ae=prosemirrorTables.CellSelection.create(O.doc,ue,A);ie(O.tr.setSelection(ae));}catch{this.setSelection(ue,A);}},scrollToSelection(){}}),[]),jsxRuntime.jsx("div",{ref:b,className:"paged-editor__hidden-pm",style:{...Nb,width:a>0?`${a}px`:void 0}})}),tp=rf.memo(Ob);var Vb="#000",Ub="rgba(66, 133, 244, 0.3)",jb=2,Gb=530,Kb={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},Yb=(e,t,n,o)=>({position:"absolute",left:e.x,top:e.y,width:n,height:e.height,backgroundColor:t,opacity:o?1:0,transition:"opacity 0.05s ease-out",pointerEvents:"none"}),qb=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),Xb=({position:e,color:t,width:n,blinkInterval:o,isFocused:r})=>{let[i,a]=rf.useState(r),s=rf.useRef(null);return rf.useEffect(()=>(s.current&&(window.clearInterval(s.current),s.current=null),r&&o>0?(a(true),s.current=window.setInterval(()=>{a(l=>!l);},o)):a(false),()=>{s.current&&window.clearInterval(s.current);}),[r,o]),rf.useEffect(()=>{if(r)return a(true),s.current&&window.clearInterval(s.current),o>0&&(s.current=window.setInterval(()=>{a(l=>!l);},o)),()=>{s.current&&window.clearInterval(s.current);}},[e.x,e.y,r,o]),jsxRuntime.jsx("div",{style:Yb(e,t,n,i),"data-testid":"caret"})},Zb=({rect:e,color:t,index:n})=>jsxRuntime.jsx("div",{style:qb(e,t),"data-testid":`selection-rect-${n}`,"data-page-index":e.pageIndex}),op=({selectionRects:e,caretPosition:t,isFocused:n,readOnly:o=false,caretColor:r=Vb,selectionColor:i=Ub,caretWidth:a=jb,blinkInterval:s=Gb})=>{if(o)return null;let l=e.length>0,u=t!==null&&!l;return jsxRuntime.jsxs("div",{style:Kb,"data-testid":"selection-overlay",children:[l&&e.map((d,c)=>jsxRuntime.jsx(Zb,{rect:d,color:i,index:c},`sel-${d.pageIndex}-${d.x}-${d.y}-${c}`)),u&&t&&jsxRuntime.jsx(Xb,{position:t,color:r,width:a,blinkInterval:s,isFocused:n})]})};var nl=10,qn=nl/2,Ar=2,sp="#2563eb",ip={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},Qb={position:"absolute",border:`${Ar}px solid ${sp}`,pointerEvents:"none",boxSizing:"border-box"},ey={position:"absolute",width:`${nl}px`,height:`${nl}px`,backgroundColor:sp,border:"1px solid white",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},ty={position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.75)",color:"white",fontSize:"11px",fontFamily:"system-ui, sans-serif",padding:"2px 8px",borderRadius:"3px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:20,transform:"translateX(-50%)"},ny={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize"};function oy(e,t,n,o,r,i){let a=e.includes("w")?-1:1,s=e.includes("n")?-1:1,l=o+t*a,u=r+n*s;if(i){let d=Math.max(l/o,u/r);l=o*d,u=r*d;}return {width:Math.max(20,Math.min(2e3,l)),height:Math.max(20,Math.min(2e3,u))}}function lp({imageInfo:e,zoom:t,isFocused:n,onResize:o,onResizeStart:r,onResizeEnd:i,onDragMove:a,onDragStart:s,onDragEnd:l}){let[u,d]=rf.useState(false),[c,p]=rf.useState(false),[f,m]=rf.useState(0),[b,g]=rf.useState(0),[x,T]=rf.useState(null),S=rf.useRef(null),B=rf.useRef(null),C=rf.useRef(o),P=rf.useRef(r),_=rf.useRef(i),q=rf.useRef(a),z=rf.useRef(s),H=rf.useRef(l);C.current=o,P.current=r,_.current=i,q.current=a,z.current=s,H.current=l;let ee=rf.useRef(e),ue=rf.useRef(t);ee.current=e,ue.current=t;let A=rf.useCallback(()=>{if(!e||!B.current){T(null);return}let M=B.current.offsetParent;if(!M){T(null);return}let F=M.getBoundingClientRect(),k=e.element.getBoundingClientRect();T({left:(k.left-F.left)/t,top:(k.top-F.top)/t,width:k.width/t,height:k.height/t});},[e,t]);rf.useEffect(()=>{A();},[A]),rf.useEffect(()=>{if(!e)return;let M=B.current?.closest('[style*="overflow"]')??B.current?.closest(".paged-editor__container");if(!M)return;let F=()=>{S.current&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(A);};return M.addEventListener("scroll",F,{passive:true}),window.addEventListener("resize",F,{passive:true}),()=>{M.removeEventListener("scroll",F),window.removeEventListener("resize",F),S.current&&cancelAnimationFrame(S.current);}},[e,A]);let O=rf.useCallback((M,F)=>{if(!e||!x)return;F.preventDefault(),F.stopPropagation();let k=x.width,L=x.height,I=F.clientX,E=F.clientY,Z=Math.round(k),le=Math.round(L);d(true),m(Z),g(le),P.current?.();let $=ne=>{let fe=ue.current,Te=(ne.clientX-I)/fe,v=(ne.clientY-E)/fe,U=!ne.shiftKey,D=oy(M,Te,v,k,L,U);Z=Math.round(D.width),le=Math.round(D.height),m(Z),g(le),T(me=>{if(!me)return me;let ge={...me};return M.includes("w")&&(ge.left=me.left+(me.width-D.width)),M.includes("n")&&(ge.top=me.top+(me.height-D.height)),ge.width=D.width,ge.height=D.height,ge});},Y=()=>{window.removeEventListener("mousemove",$),window.removeEventListener("mouseup",Y),d(false);let ne=ee.current;ne&&C.current?.(ne.pmPos,Z,le),_.current?.();};window.addEventListener("mousemove",$),window.addEventListener("mouseup",Y);},[e,x]),ie=rf.useCallback(M=>{if(!e||!x)return;M.preventDefault(),M.stopPropagation();let F=4,k=M.clientX,L=M.clientY,I=false,E=null,Z=$=>{let Y=$.clientX-k,ne=$.clientY-L;!I&&Math.sqrt(Y*Y+ne*ne)<F||(I||(I=true,p(true),z.current?.(),E=document.createElement("div"),E.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);",E.style.width=`${x.width}px`,E.style.height=`${x.height}px`,document.body.appendChild(E)),E&&(E.style.left=`${$.clientX-x.width/2}px`,E.style.top=`${$.clientY-x.height/2}px`));},le=$=>{if(window.removeEventListener("mousemove",Z),window.removeEventListener("mouseup",le),E&&(E.remove(),E=null),p(false),I){let Y=ee.current;Y&&q.current?.(Y.pmPos,$.clientX,$.clientY),H.current?.();}};window.addEventListener("mousemove",Z),window.addEventListener("mouseup",le);},[e,x]);if(!!!(e&&x&&n))return jsxRuntime.jsx("div",{ref:B,style:{...ip,visibility:"hidden"},className:"image-selection-overlay"});let{left:N,top:Ie,width:Fe,height:Ve}=x;return jsxRuntime.jsxs("div",{ref:B,style:ip,className:"image-selection-overlay",children:[jsxRuntime.jsx("div",{style:{...Qb,left:N-Ar,top:Ie-Ar,width:Fe+Ar*2,height:Ve+Ar*2}}),jsxRuntime.jsx("div",{style:{position:"absolute",left:N,top:Ie,width:Fe,height:Ve,cursor:c?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:ie}),jsxRuntime.jsx(wa,{handle:"nw",style:{left:N-qn,top:Ie-qn},onMouseDown:O}),jsxRuntime.jsx(wa,{handle:"ne",style:{left:N+Fe-qn,top:Ie-qn},onMouseDown:O}),jsxRuntime.jsx(wa,{handle:"se",style:{left:N+Fe-qn,top:Ie+Ve-qn},onMouseDown:O}),jsxRuntime.jsx(wa,{handle:"sw",style:{left:N-qn,top:Ie+Ve-qn},onMouseDown:O}),u&&jsxRuntime.jsxs("div",{style:{...ty,left:N+Fe/2,top:Ie+Ve+12},children:[f," \xD7 ",b]})]})}function wa({handle:e,style:t,onMouseDown:n}){return jsxRuntime.jsx("div",{style:{...ey,...t,cursor:ny[e]},onMouseDown:o=>n(e,o),"data-handle":e})}var ry="Calibri";function ol(e,t,n){if(!n||t<=n)return {width:e,height:t};let o=n/t;return {width:Math.round(e*o),height:n}}var iy=11;function rt(e){return e/1440*96}var ay=0;function Zn(){return `block-${++ay}`}function sy(e,t){let n=[];for(let o=0;o<=t;o+=1){let r=e[o]??0;if(r<=0)break;n.push(r);}return n.length===0?"1.":`${n.join(".")}.`}function Ca(e,t){let n={};for(let o of e)switch(o.type.name){case "bold":n.bold=true;break;case "italic":n.italic=true;break;case "underline":{let r=o.attrs;if(r.style||r.color){let i=r.color?chunk4VUZBV2S_js.a(r.color,t):void 0;n.underline={style:r.style,color:i};}else n.underline=true;break}case "strike":n.strike=true;break;case "textColor":{let r=o.attrs;(r.themeColor||r.rgb)&&(n.color=chunk4VUZBV2S_js.a({rgb:r.rgb,themeColor:r.themeColor,themeTint:r.themeTint,themeShade:r.themeShade},t));break}case "highlight":n.highlight=chunk4VUZBV2S_js.n(o.attrs.color);break;case "fontSize":{let r=o.attrs;n.fontSize=r.size/2;break}case "fontFamily":{let r=o.attrs;n.fontFamily=r.ascii||r.hAnsi;break}case "superscript":n.superscript=true;break;case "subscript":n.subscript=true;break;case "hyperlink":{let r=o.attrs;n.hyperlink={href:r.href,tooltip:r.tooltip};break}case "footnoteRef":{let r=o.attrs,i=typeof r.id=="string"?parseInt(r.id,10):r.id;r.noteType==="endnote"?n.endnoteRefId=i:n.footnoteRefId=i;break}case "comment":{let r=o.attrs.commentId;r&&(n.commentIds||(n.commentIds=[]),n.commentIds.push(r));break}case "insertion":n.isInsertion=true,n.changeAuthor=o.attrs.author,n.changeDate=o.attrs.date,n.changeRevisionId=o.attrs.revisionId;break;case "deletion":n.isDeletion=true,n.changeAuthor=o.attrs.author,n.changeDate=o.attrs.date,n.changeRevisionId=o.attrs.revisionId;break}return n}function ly(e,t,n){let o=[],r=t+1,i=n.theme;return e.forEach((a,s)=>{let l=r+s;if(a.isText&&a.text){let u=Ca(a.marks,i),d={kind:"text",text:a.text,...u,pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="hardBreak"){let u={kind:"lineBreak",pmStart:l,pmEnd:l+a.nodeSize};o.push(u);}else if(a.type.name==="tab"){let d={kind:"tab",...Ca(a.marks,i),pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="image"){let u=a.attrs,d=ol(u.width||100,u.height||100,n.pageContentHeight),c={kind:"image",src:u.src,width:d.width,height:d.height,alt:u.alt,transform:u.transform,wrapType:u.wrapType,displayMode:u.displayMode,cssFloat:u.cssFloat,distTop:u.distTop,distBottom:u.distBottom,distLeft:u.distLeft,distRight:u.distRight,position:u.position,pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="field"){let u=a.attrs.fieldType,c={kind:"field",fieldType:u==="PAGE"?"PAGE":u==="NUMPAGES"?"NUMPAGES":u==="DATE"?"DATE":u==="TIME"?"TIME":"OTHER",fallback:a.attrs.displayText||"",pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="math"){let d={kind:"text",text:a.attrs.plainText||"[equation]",italic:true,fontFamily:"Cambria Math",pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="sdt"){let u=l+1;a.forEach((d,c)=>{let p=u+c;if(d.isText&&d.text){let f=Ca(d.marks,i),m={kind:"text",text:d.text,...f,pmStart:p,pmEnd:p+d.nodeSize};o.push(m);}else if(d.type.name==="hardBreak"){let f={kind:"lineBreak",pmStart:p,pmEnd:p+d.nodeSize};o.push(f);}else if(d.type.name==="tab"){let m={kind:"tab",...Ca(d.marks,i),pmStart:p,pmEnd:p+d.nodeSize};o.push(m);}else if(d.type.name==="image"){let f=d.attrs,m=ol(f.width||100,f.height||100,n.pageContentHeight),b={kind:"image",src:f.src,width:m.width,height:m.height,alt:f.alt,transform:f.transform,wrapType:f.wrapType,displayMode:f.displayMode,cssFloat:f.cssFloat,distTop:f.distTop,distBottom:f.distBottom,distLeft:f.distLeft,distRight:f.distRight,position:f.position,pmStart:p,pmEnd:p+d.nodeSize};o.push(b);}});}}),o}function cy(e,t){let n={};if(e.alignment){let s=e.alignment;s==="both"||s==="distribute"?n.alignment="justify":s==="left"?n.alignment="left":s==="center"?n.alignment="center":s==="right"&&(n.alignment="right");}(e.spaceBefore!=null||e.spaceAfter!=null||e.lineSpacing!=null)&&(n.spacing={},e.spaceBefore!=null&&(n.spacing.before=rt(e.spaceBefore)),e.spaceAfter!=null&&(n.spacing.after=rt(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(n.spacing.line=rt(e.lineSpacing),n.spacing.lineUnit="px",n.spacing.lineRule=e.lineSpacingRule):(n.spacing.line=e.lineSpacing/240,n.spacing.lineUnit="multiplier",n.spacing.lineRule="auto")));let o=e.indentLeft,r=e.indentFirstLine,i=e.hangingIndent;if(e.numPr?.numId&&o==null&&(o=((e.numPr.ilvl??0)+1)*720,r==null&&(r=-360,i=true)),(o!=null||e.indentRight!=null||r!=null)&&(n.indent={},o!=null&&(n.indent.left=rt(o)),e.indentRight!=null&&(n.indent.right=rt(e.indentRight)),r!=null&&(i?n.indent.hanging=Math.abs(rt(r)):n.indent.firstLine=rt(r))),e.styleId&&(n.styleId=e.styleId),e.borders){let s=e.borders;n.borders={};let l=u=>u?va(u,t):void 0;s.top&&(n.borders.top=l(s.top)),s.bottom&&(n.borders.bottom=l(s.bottom)),s.left&&(n.borders.left=l(s.left)),s.right&&(n.borders.right=l(s.right)),s.between&&(n.borders.between=l(s.between)),s.bar&&(n.borders.bar=l(s.bar)),!n.borders.top&&!n.borders.bottom&&!n.borders.left&&!n.borders.right&&!n.borders.between&&!n.borders.bar&&delete n.borders;}e.shading?.fill?.rgb&&(n.shading=`#${e.shading.fill.rgb}`),e.tabs&&e.tabs.length>0&&(n.tabs=e.tabs.map(s=>({val:dy(s.alignment),pos:s.position,leader:s.leader}))),e.pageBreakBefore&&(n.pageBreakBefore=true),e.keepNext&&(n.keepNext=true),e.keepLines&&(n.keepLines=true),e.contextualSpacing&&(n.contextualSpacing=true),e.bidi&&(n.bidi=true),e.styleId&&(n.styleId=e.styleId),e.numPr&&(n.numPr={numId:e.numPr.numId,ilvl:e.numPr.ilvl}),e.listMarker&&(n.listMarker=e.listMarker),e.listIsBullet!=null&&(n.listIsBullet=e.listIsBullet),e.listMarkerHidden&&(n.listMarkerHidden=true),e.listMarkerFontFamily&&(n.listMarkerFontFamily=e.listMarkerFontFamily),e.listMarkerFontSize&&(n.listMarkerFontSize=e.listMarkerFontSize);let a=e.defaultTextFormatting;return a&&(a.fontSize!=null&&(n.defaultFontSize=a.fontSize/2),a.fontFamily&&(n.defaultFontFamily=a.fontFamily.ascii||a.fontFamily.hAnsi)),n}function dy(e){switch(e){case "left":return "start";case "right":return "end";case "center":return "center";case "decimal":return "decimal";case "bar":return "bar";case "clear":return "clear";case "num":return "start";default:return "start"}}function rl(e,t,n){let o=e.attrs,r=ly(e,t,n),i=cy(o,n.theme);return {kind:"paragraph",id:Zn(),runs:r,attrs:i,pmStart:t,pmEnd:t+e.nodeSize}}function uy(e){return Math.max(1,Math.round(e/8*1.333))}var py={single:"solid",double:"double",dotted:"dotted",dashed:"dashed",thick:"solid",dashSmallGap:"dashed",dotDash:"dashed",dotDotDash:"dotted",triple:"double",wave:"solid",doubleWave:"double",threeDEmboss:"ridge",threeDEngrave:"groove",outset:"outset",inset:"inset"};function va(e,t){if(!e||!e.style||e.style==="none"||e.style==="nil")return;let n={style:py[e.style]||"solid",width:uy(e.size??0),color:e.color?chunk4VUZBV2S_js.a(e.color,t):"#000000"};return e.space!==void 0&&(n.space=chunkSE5EN2QL_js.g(e.space)),n}function fy(e,t){let n=e.borders;if(!n)return;let o={},r=["top","bottom","left","right"];for(let i of r){let a=n[i],s=a?va(a,t):void 0;o[i]=s??{width:0,style:"none"};}return Object.keys(o).length>0?o:void 0}function my(e,t,n){let o=[],r=t+1;e.forEach(l=>{l.type.name==="paragraph"?o.push(rl(l,r,n)):l.type.name==="table"&&o.push(cp(l,r,n)),r+=l.nodeSize;});let i=e.attrs,a=i.margins,s={top:a?.top!=null?rt(a.top):1,right:a?.right!=null?rt(a.right):7,bottom:a?.bottom!=null?rt(a.bottom):1,left:a?.left!=null?rt(a.left):7};return {id:Zn(),blocks:o,colSpan:i.colspan,rowSpan:i.rowspan,width:i.width?rt(i.width):void 0,verticalAlign:i.verticalAlign,background:i.backgroundColor?`#${i.backgroundColor}`:void 0,borders:fy(i,n.theme),padding:s}}function gy(e,t,n){let o=[],r=t+1;e.forEach(a=>{(a.type.name==="tableCell"||a.type.name==="tableHeader")&&o.push(my(a,r,n)),r+=a.nodeSize;});let i=e.attrs;return {id:Zn(),cells:o,height:i.height?rt(i.height):void 0,heightRule:i.heightRule??void 0,isHeader:i.isHeader}}function cp(e,t,n){let o=[],r=t+1;e.forEach(m=>{m.type.name==="tableRow"&&o.push(gy(m,r,n)),r+=m.nodeSize;});let a=e.attrs.columnWidths?.map(rt),s=e.attrs.width,l=e.attrs.widthType;if(!a&&o.length>0){let b=o[0].cells.map(g=>g.width);b.every(g=>g!==void 0&&g>0)&&(a=b);}let u=e.attrs.justification,d=e.attrs._originalFormatting,c=d?.indent?.value&&d.indent.type==="dxa"?rt(d.indent.value):void 0,p=e.attrs.floating,f=p?{horzAnchor:p.horzAnchor,vertAnchor:p.vertAnchor,tblpX:p.tblpX!==void 0?rt(p.tblpX):void 0,tblpXSpec:p.tblpXSpec,tblpY:p.tblpY!==void 0?rt(p.tblpY):void 0,tblpYSpec:p.tblpYSpec,topFromText:p.topFromText!==void 0?rt(p.topFromText):void 0,bottomFromText:p.bottomFromText!==void 0?rt(p.bottomFromText):void 0,leftFromText:p.leftFromText!==void 0?rt(p.leftFromText):void 0,rightFromText:p.rightFromText!==void 0?rt(p.rightFromText):void 0}:void 0;return {kind:"table",id:Zn(),rows:o,columnWidths:a,width:s,widthType:l,justification:u,indent:c,floating:f,pmStart:t,pmEnd:t+e.nodeSize}}function hy(e,t,n){let o=e.attrs,r=o.wrapType,i=r==="behind"||r==="inFront",a=ol(o.width||100,o.height||100,n);return {kind:"image",id:Zn(),src:o.src,width:a.width,height:a.height,alt:o.alt,transform:o.transform,anchor:i?{isAnchored:true,offsetH:o.distLeft,offsetV:o.distTop,behindDoc:r==="behind"}:void 0,hlinkHref:o.hlinkHref,pmStart:t,pmEnd:t+e.nodeSize}}function by(e,t,n){let o=e.attrs,r=[];return e.forEach((i,a)=>{if(i.type.name==="paragraph"){let s=rl(i,t+1+a,n);r.push(s);}}),{kind:"textBox",id:Zn(),width:o.width??chunkQQ63M65M_js.d,height:o.height??void 0,fillColor:o.fillColor,outlineWidth:o.outlineWidth,outlineColor:o.outlineColor,outlineStyle:o.outlineStyle,margins:{top:o.marginTop??chunkQQ63M65M_js.c.top,bottom:o.marginBottom??chunkQQ63M65M_js.c.bottom,left:o.marginLeft??chunkQQ63M65M_js.c.left,right:o.marginRight??chunkQQ63M65M_js.c.right},content:r,pmStart:t,pmEnd:t+e.nodeSize}}function dp(e,t={}){let n={...t,defaultFont:t.defaultFont??ry,defaultSize:t.defaultSize??iy},o=[],r=0,i=new Map;return e.forEach((a,s)=>{let l=r+s;switch(a.type.name){case "paragraph":{let u=rl(a,l,n),d=a.attrs;if(d.numPr&&!d.listMarker){let p=d.numPr.numId;if(p==null||p===0)break;let f=d.numPr.ilvl??0,m=i.get(p)??new Array(9).fill(0);m[f]=(m[f]??0)+1;for(let g=f+1;g<m.length;g+=1)m[g]=0;i.set(p,m);let b=d.listIsBullet?"\u2022":sy(m,f);u.attrs={...u.attrs,listMarker:b};}o.push(u);let c=d._sectionProperties;if(c||d.sectionBreakType){let p={kind:"sectionBreak",id:Zn(),type:c?.sectionStart??d.sectionBreakType};if(c){(c.pageWidth||c.pageHeight)&&(p.pageSize={w:rt(c.pageWidth??12240),h:rt(c.pageHeight??15840)}),(c.marginTop!==void 0||c.marginLeft!==void 0)&&(p.margins={top:rt(c.marginTop??1440),bottom:rt(c.marginBottom??1440),left:rt(c.marginLeft??1440),right:rt(c.marginRight??1440)});let f=c.columnCount??1;if(f>1){let m={count:f,gap:rt(c.columnSpace??720),equalWidth:c.equalWidth??true,separator:c.separator};p.columns=m;}}o.push(p);}}break;case "table":o.push(cp(a,l,n));break;case "image":o.push(hy(a,l,n.pageContentHeight));break;case "textBox":o.push(by(a,l,n));break;case "horizontalRule":case "pageBreak":{let u={kind:"pageBreak",id:Zn(),pmStart:l,pmEnd:l+a.nodeSize};o.push(u);break}}}),o}var Bn=11,Dr="Calibri",Ra=1,Yo=.5;function up(e){return {fontFamily:e.fontFamily??Dr,fontSize:e.fontSize??Bn,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function gp(e,t,n){let o=chunkQQ63M65M_js.k(e),r=n?.ascent??o*.8,i=n?.descent??o*.2,a=n?.singleLineRatio??1.15,s=o*a,l;if(t?.lineRule==="exact"&&t.line!==void 0)l=t.line;else if(t?.lineRule==="atLeast"&&t.line!==void 0){let u=s*Ra;l=Math.max(t.line,u);}else t?.line!==void 0&&t?.lineUnit==="multiplier"?l=s*t.line:t?.line!==void 0&&t?.lineUnit==="px"?l=t.line:l=s*Ra;return {ascent:r,descent:i,lineHeight:l}}function pp(e,t,n){let o=chunkQQ63M65M_js.g({fontSize:e,fontFamily:n??Dr});return gp(e,t,o)}function fp(e){return e.kind==="text"}function xy(e){return e.kind==="tab"}function Sy(e){return e.kind==="image"}function ky(e){return e.kind==="lineBreak"}function Ty(e){return e.kind==="field"}function wy(e){return !e.text||e.text.length===0}function Cy(e){let t=[];for(let n=0;n<e.length;n++){let o=e[n];(o===" "||o==="-"||o===" ")&&t.push(n+1);}return t}var vy=48;function mp(e,t,n,o){if(!n||n.length===0)return {leftMargin:0,rightMargin:0};let r=0,i=0,a=o+e,s=a+t;for(let l of n)s>l.topY&&a<l.bottomY&&(r=Math.max(r,l.leftMargin),i=Math.max(i,l.rightMargin));return {leftMargin:r,rightMargin:i}}function vn(e,t,n){let o=e.runs,r=e.attrs,i=r?.spacing,a=n?.floatingZones,s=n?.paragraphYOffset??0,l=r?.indent,u=l?.left??0,d=l?.right??0,c=(l?.firstLine??0)-(l?.hanging??0),p=Math.max(1,t-u-d),f=Math.max(1,p-c),m=0,b=chunkQQ63M65M_js.k(Bn)*Ra,g=mp(0,b,a,s),x=Math.max(1,f-g.leftMargin-g.rightMargin),T=[];if(o.length===0){let z=r?.defaultFontSize??Bn,H=r?.defaultFontFamily??Dr,ee=pp(z,i,H);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...ee}),{kind:"paragraph",lines:T,totalHeight:ee.lineHeight}}if(o.length===1&&fp(o[0])&&wy(o[0])){let z=o[0],H=z.fontSize??r?.defaultFontSize??Bn,ee=z.fontFamily??r?.defaultFontFamily??Dr,ue=pp(H,i,ee);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...ue}),{kind:"paragraph",lines:T,totalHeight:ue.lineHeight}}let S={fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,maxFontSize:Bn,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:x,leftOffset:g.leftMargin,rightOffset:g.rightMargin},B=()=>{let z=gp(S.maxFontSize,i,S.maxFontMetrics),H={...z};S.maxImageHeightPx>H.lineHeight&&(H.lineHeight=S.maxImageHeightPx,H.ascent=S.maxImageHeightPx*.8,H.descent=S.maxImageHeightPx*.2);let ee={fromRun:S.fromRun,fromChar:S.fromChar,toRun:S.toRun,toChar:S.toChar,width:S.width,...H};S.leftOffset>0&&(ee.leftOffset=S.leftOffset),S.rightOffset>0&&(ee.rightOffset=S.rightOffset),T.push(ee),m+=z.lineHeight;},C=(z,H)=>{B();let ee=chunkQQ63M65M_js.k(Bn)*Ra,ue=mp(m,ee,a,s),A=Math.max(1,p-ue.leftMargin-ue.rightMargin);S={fromRun:z,fromChar:H,toRun:z,toChar:H,width:0,maxFontSize:Bn,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:A,leftOffset:ue.leftMargin,rightOffset:ue.rightMargin};},P=z=>{let H=z.fontSize??Bn;(!S.maxFontMetrics||H>S.maxFontSize)&&(S.maxFontSize=H,S.maxFontMetrics=chunkQQ63M65M_js.g(z));};for(let z=0;z<o.length;z++){let H=o[z];if(ky(H)){S.toRun=z,S.toChar=0,C(z+1,0);continue}if(xy(H)){let ee=up(H);P(ee);let ue=H.width??vy;S.width+ue>S.availableWidth+Yo&&(C(z,0),P(ee)),S.width+=ue,S.toRun=z,S.toChar=1;continue}if(Sy(H)){let ee=H.wrapType,ue=H.displayMode==="float"||ee&&["square","tight","through"].includes(ee);if(H.position&&ue){S.toRun=z,S.toChar=1;continue}if(ee==="topAndBottom"||H.displayMode==="block"){S.width>0&&C(z,0);let ie=H.height,ae=H.distTop??6,N=H.distBottom??6;S.toRun=z,S.toChar=1,S.maxImageHeightPx=ie+ae+N,C(z+1,0);continue}let A=H.width,O=H.height;O>S.maxImageHeightPx&&(S.maxImageHeightPx=O),S.width+A>S.availableWidth+Yo&&C(z,0),S.width+=A,S.toRun=z,S.toChar=1;continue}if(Ty(H)){let ee=H.fallback||"1",ue={fontFamily:H.fontFamily??Dr,fontSize:H.fontSize??Bn,bold:H.bold,italic:H.italic};P(ue);let A=chunkQQ63M65M_js.h(ee,ue);S.width>0&&S.width+A>S.availableWidth+Yo&&(C(z,0),P(ue)),S.width+=A,S.toRun=z,S.toChar=1;continue}if(fp(H)){let ee=H,ue=ee.text,A=up(ee);if(P(A),!ue||ue.length===0){S.toRun=z,S.toChar=0;continue}let O=Cy(ue),ie=0;for(;ie<ue.length;){let ae=ue.length;for(let Fe of O)if(Fe>ie){ae=Fe;break}let N=ue.slice(ie,ae),Ie=chunkQQ63M65M_js.h(N,A);if(Ie>S.availableWidth+Yo){S.width>0&&(C(z,ie),P(A));let{charWidths:Fe}=chunkQQ63M65M_js.i(N,A),Ve=0;for(;Ve<N.length;){let M=0,F=Ve;for(;F<N.length;){let k=Fe[F]??0;if(M+k>S.availableWidth+Yo)break;M+=k,F+=1;}F===Ve&&(F=Math.min(N.length,Ve+1),M=Fe[Ve]??0),S.width+=M,S.toRun=z,S.toChar=ie+F,Ve=F,Ve<N.length&&(C(z,ie+Ve),P(A));}ie=ae;continue}S.width>0&&S.width+Ie>S.availableWidth+Yo&&(C(z,ie),P(A)),S.width+=Ie,S.toRun=z,S.toChar=ae,ie=ae;}}}B();let q=T.reduce((z,H)=>z+H.lineHeight,0);return i?.before&&(q+=i.before),i?.after&&(q+=i.after),{kind:"paragraph",lines:T,totalHeight:q}}var Ry=new Map;function hp(){Ry.clear();}var Ey=new Map;function bp(){Ey.clear();}var My=5e3,Py=My,Jn=new Map;function il(e){let t=[];for(let o of e.runs)o.kind==="text"?t.push(`t:${o.text}|${o.fontFamily}|${o.fontSize}|${o.bold}|${o.italic}`):o.kind==="tab"?t.push(`tab:${o.width}`):o.kind==="image"?t.push(`img:${o.width}x${o.height}`):o.kind==="lineBreak"&&t.push("br");let n=e.attrs;return n&&(n.alignment&&t.push(`align:${n.alignment}`),n.indent&&t.push(`indent:${n.indent.left}|${n.indent.right}|${n.indent.firstLine}|${n.indent.hanging}`),n.spacing&&t.push(`spacing:${n.spacing.before}|${n.spacing.after}|${n.spacing.line}|${n.spacing.lineRule}`)),t.join("||")}function Iy(){for(;Jn.size>Py;){let e=Jn.keys().next().value;if(e===void 0)break;Jn.delete(e);}}function al(e,t){let n=il(e),o=Jn.get(n);if(o!==void 0&&o.maxWidth===t)return Jn.delete(n),Jn.set(n,o),o.measure}function sl(e,t,n){let o=il(e);Jn.set(o,{measure:n,maxWidth:t}),Iy();}function yp(){Jn.clear();}function ll(){hp(),bp(),yp();}function Fy(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function Ly(e,t){let n=[];for(let o=t.fromRun;o<=t.toRun&&o<e.runs.length;o++){let r=e.runs[o];if(r){if(r.kind==="tab"||r.kind==="image"||r.kind==="lineBreak"){n.push(r);continue}if(r.kind==="text"){let i=r.text??"",a=o===t.fromRun,s=o===t.toRun;if(a||s){let l=a?t.fromChar:0,u=s?t.toChar:i.length,d=i.slice(l,u);d.length>0&&n.push({...r,text:d});}else n.push(r);}}}return n}function By(e,t){let n,o,r=e.pmStart??0,i=0;for(let a=0;a<e.runs.length&&a<=t.toRun;a++){let s=e.runs[a];s&&(a<t.fromRun?s.kind==="text"?i+=(s.text??"").length:(s.kind==="tab"||s.kind==="lineBreak"||s.kind==="image")&&(i+=1):a===t.fromRun&&(i+=t.fromChar,n=r+i,s.kind==="text"&&(i=t.fromChar)));}if(n!==void 0){let a=0;for(let s=t.fromRun;s<=t.toRun&&s<e.runs.length;s++){let l=e.runs[s];if(l)if(l.kind==="text"){let u=l.text??"",d=s===t.fromRun?t.fromChar:0,c=s===t.toRun?t.toChar:u.length;a+=c-d;}else (l.kind==="tab"||l.kind==="lineBreak"||l.kind==="image")&&(a+=1);}o=n+a;}return {pmStart:n,pmEnd:o}}function Ay(e,t,n,o){let r=0;for(let i=n;i<o&&i<e.lines.length;i++){let s=e.lines[i].lineHeight;if(t>=r&&t<r+s)return i;r+=s;}return o>n?Math.min(o-1,e.lines.length-1):null}function Dy(e,t,n,o){let{pmStart:r,pmEnd:i}=By(e,t);if(r===void 0||i===void 0)return {charOffset:0,pmPosition:e.pmStart??0};let a=e.attrs?.alignment??"left",s=0;a==="center"?s=Math.max(0,(o-t.width)/2):a==="right"&&(s=Math.max(0,o-t.width));let l=Math.max(0,n-s);if(l<=0)return {charOffset:0,pmPosition:r};let u=Ly(e,t);if(u.length===0)return {charOffset:0,pmPosition:r};let d=0,c=0;for(let f of u){if(f.kind==="tab"){let m=f.width??48,b=d+m;if(l<=b){let g=d+m/2;return l<g?{charOffset:c,pmPosition:r+c}:{charOffset:c+1,pmPosition:r+c+1}}d=b,c+=1;continue}if(f.kind==="image"){let m=f.width,b=d+m;if(l<=b){let g=d+m/2;return l<g?{charOffset:c,pmPosition:r+c}:{charOffset:c+1,pmPosition:r+c+1}}d=b,c+=1;continue}if(f.kind==="lineBreak"){if(l>=d)return {charOffset:c,pmPosition:r+c};c+=1;continue}if(f.kind==="text"){let m=f.text??"";if(m.length===0)continue;let b=Fy(f),g=chunkQQ63M65M_js.i(m,b),x=d+g.width;if(l<=x){let T=l-d,S=chunkQQ63M65M_js.j(T,g.charWidths),B=c+S;return {charOffset:B,pmPosition:r+B}}d=x,c+=m.length;}}return {charOffset:i-r,pmPosition:i}}function xp(e){let{fragment:t,block:n,measure:o,localX:r,localY:i}=e;if(t.kind!=="paragraph"||n.kind!=="paragraph"||o.kind!=="paragraph")return null;let a=t,s=n,l=o,u=Ay(l,i,a.fromLine,a.toLine);if(u===null)return null;let d=l.lines[u];if(!d)return null;let c=0;for(let S=a.fromLine;S<u;S++)c+=l.lines[S]?.lineHeight??0;let p=s.attrs?.indent,f=p?.left??0,m=p?.right??0,b=Math.max(0,t.width-f-m),g=r-f,{charOffset:x,pmPosition:T}=Dy(s,d,g,b);return {pmPosition:T,charOffset:x,lineIndex:u}}function Hy(e){let{cellBlock:t,cellMeasure:n,cellLocalX:o,cellLocalY:r}=e;if(!t||!n)return null;let i={fragment:{kind:"paragraph",blockId:t.id,x:0,y:0,width:n.lines.reduce((s,l)=>Math.max(s,l.width),100),fromLine:0,toLine:n.lines.length,height:n.totalHeight},block:t,measure:n,pageIndex:e.pageIndex,localX:o,localY:r};return xp(i)?.pmPosition??null}function cl(e,t){if(t)return Hy(t);if(!e)return null;let{fragment:n}=e;return n.kind==="paragraph"?xp(e)?.pmPosition??null:n.kind==="image"?n.pmStart??null:null}function kp(e,t,n,o=1){let r=document.elementsFromPoint(t,n),i=r.find(d=>d.classList.contains("layout-page"));if(!i)return null;let a=r.find(d=>d.tagName==="SPAN"&&d.dataset.pmStart!==void 0&&d.dataset.pmEnd!==void 0);if(a)return dl(a,t);let s=r.find(d=>d.classList.contains("layout-empty-run"));if(s){let d=s.closest(".layout-paragraph");if(d&&d.dataset.pmStart)return Number(d.dataset.pmStart)}let l=r.find(d=>d.classList.contains("layout-paragraph")&&d.dataset.pmStart!==void 0);if(l&&l.dataset.pmStart){let d=Sp(l,t,n);return d!==null?d:Number(l.dataset.pmStart)}let u=r.find(d=>d.classList.contains("layout-table-cell"));return u?Sp(u,t,n):Ny(e,i,t,n)}function dl(e,t,n){let o=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(e.classList.contains("layout-run-tab")){let c=e.getBoundingClientRect(),p=(c.left+c.right)/2;return t<p?o:r}let i=e.firstChild;if(!i||i.nodeType!==Node.TEXT_NODE)return o;let a=i,s=a.length;if(s===0)return o;let l=e.ownerDocument;if(!l)return o;let u=0,d=s;for(;u<d;){let c=Math.floor((u+d)/2),p=l.createRange();p.setStart(a,c),p.setEnd(a,c);let m=p.getBoundingClientRect().left;t<m?d=c:u=c+1;}if(u>0&&u<=s){let c=l.createRange();c.setStart(a,u-1),c.setEnd(a,u-1);let p=c.getBoundingClientRect();c.setStart(a,Math.min(u,s)),c.setEnd(a,Math.min(u,s));let f=c.getBoundingClientRect(),m=Math.abs(t-p.left),b=Math.abs(t-f.left);if(m<b)return o+(u-1)}return o+Math.min(u,r-o)}function Sp(e,t,n){let o=e.querySelector(".layout-empty-run");if(o){let c=o.closest(".layout-paragraph");if(c&&c.dataset.pmStart)return Number(c.dataset.pmStart)}let r=e.querySelectorAll(".layout-line"),i=null,a=1/0;for(let c of Array.from(r)){let p=c,f=p.getBoundingClientRect(),m=(f.top+f.bottom)/2,b=Math.abs(n-m);b<a&&(a=b,i=p);}if(!i){let c=e.querySelector(".layout-paragraph[data-pm-start]");return c?.dataset.pmStart?Number(c.dataset.pmStart):e.dataset.pmStart?Number(e.dataset.pmStart):null}let s=i.querySelectorAll("span[data-pm-start][data-pm-end]");if(s.length===0){let c=i.closest(".layout-paragraph");return c?.dataset.pmStart?Number(c.dataset.pmStart):null}let l=null,u=1/0;for(let c of Array.from(s)){let p=c,f=p.getBoundingClientRect();if(t>=f.left&&t<=f.right)return dl(p,t);let m=t<f.left?f.left-t:t-f.right;m<u&&(u=m,l=p);}if(!l)return null;let d=l.getBoundingClientRect();return t<d.left?Number(l.dataset.pmStart):Number(l.dataset.pmEnd)}function Ny(e,t,n,o,r){if(t.querySelectorAll("span[data-pm-start][data-pm-end]").length===0){let f=t.querySelectorAll(".layout-paragraph");if(f.length>0){let m=f[0];return Number(m.dataset.pmStart)||0}return null}let a=t.querySelectorAll(".layout-line"),s=null,l=1/0;for(let f of Array.from(a)){let m=f,b=m.getBoundingClientRect(),g=(b.top+b.bottom)/2,x=Math.abs(o-g);x<l&&(l=x,s=m);}if(!s)return null;let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart):null}let d=null,c=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect();if(n>=b.left&&n<=b.right)return dl(m,n);let g=n<b.left?b.left-n:n-b.right;g<c&&(c=g,d=m);}if(!d)return null;let p=d.getBoundingClientRect();return n<p.left?Number(d.dataset.pmStart):Number(d.dataset.pmEnd)}var Qn={fragment:"layout-fragment",paragraph:"layout-fragment-paragraph",table:"layout-fragment-table",image:"layout-fragment-image"};function zy(e){return e.kind==="paragraph"}function Oy(e){return e.kind==="table"}function $y(e){return e.kind==="image"}function Ea(e){e.style.position="absolute",e.style.overflow="hidden";}function Wy(e,t,n){let o=n.createElement("div");return o.className=`${Qn.fragment} ${Qn.paragraph}`,Ea(o),o.dataset.blockId=String(e.blockId),o.dataset.fromLine=String(e.fromLine),o.dataset.toLine=String(e.toLine),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),e.continuesFromPrev&&(o.dataset.continuesFromPrev="true"),e.continuesOnNext&&(o.dataset.continuesOnNext="true"),o}function _y(e,t,n){let o=n.createElement("div");return o.className=`${Qn.fragment} ${Qn.table}`,Ea(o),o.dataset.blockId=String(e.blockId),o.dataset.fromRow=String(e.fromRow),o.dataset.toRow=String(e.toRow),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),o}function Vy(e,t,n){let o=n.createElement("div");return o.className=`${Qn.fragment} ${Qn.image}`,Ea(o),o.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(o.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(o.dataset.pmEnd=String(e.pmEnd)),e.isAnchored&&(o.dataset.anchored="true"),e.zIndex!==void 0&&(o.style.zIndex=String(e.zIndex)),o}function Hr(e,t,n={}){let o=n.document??document;if(zy(e))return Wy(e,t,o);if(Oy(e))return _y(e,t,o);if($y(e))return Vy(e,t,o);let r=o.createElement("div");r.className=Qn.fragment,Ea(r);let i=e;return i.blockId!==void 0&&(r.dataset.blockId=String(i.blockId)),i.kind&&(r.dataset.kind=i.kind),r}function ul(e){return e/1440*96}function Uy(e){return e/96*1440}function jy(e){let{explicitStops:t=[],defaultTabInterval:n=720,leftIndent:o=0}=e,r=t.filter(c=>c.val!=="clear").filter(c=>c.pos>=o),i=t.filter(c=>c.val==="clear").map(c=>c.pos),a=r.reduce((c,p)=>Math.max(c,p.pos),0),s=[...r];o>0&&!r.some(c=>c.pos<=o)&&(i.some(p=>Math.abs(p-o)<20)||s.push({val:"start",pos:o,leader:"none"}));let u=a>0?Math.max(a,o):o,d=o+14400;for(;u<d;){u+=n;let c=r.some(m=>Math.abs(m.pos-u)<20),p=i.some(m=>Math.abs(m-u)<20),f=o>0&&Math.abs(u-o)<20;!c&&!p&&!f&&s.push({val:"start",pos:u,leader:"none"});}return s.sort((c,p)=>c.pos-p.pos)}function Tp(e,t,n="",o,r="."){let{defaultTabInterval:i=720}=t,a=Uy(e),l=jy(t).find(c=>c.pos>a);if(!l){let c=ul(i),p=c-e%c;return p<=0&&(p=c),{width:p,alignment:"default"}}let d=ul(l.pos)-e;if(l.val==="center"||l.val==="end"){let c=o?o(n):0;l.val==="center"?d-=c/2:d-=c;}else if(l.val==="decimal"){let c=n.indexOf(r);if(c>=0&&o){let p=n.slice(0,c),f=o(p);d-=f;}}else if(l.val==="bar")return {width:0,leader:l.leader,alignment:"bar"};if(d<1){let c=ul(i),p=c-e%c;return p<=0&&(p=c),{width:p,alignment:"default"}}return {width:d,leader:l.leader,alignment:l.val}}var nn={fragment:"layout-paragraph",line:"layout-line",run:"layout-run",text:"layout-run-text",tab:"layout-run-tab",image:"layout-run-image",lineBreak:"layout-run-linebreak"};function zr(e){return e.kind==="text"}function Ma(e){return e.kind==="tab"}function vp(e){return e.kind==="image"}function pl(e){return e.kind==="lineBreak"}function fl(e){return e.kind==="field"}function Gy(e,t){if(t.fontFamily&&(e.style.fontFamily=chunkQQ63M65M_js.a(t.fontFamily).cssFallback),t.fontSize){let o=t.fontSize*96/72;e.style.fontSize=`${o}px`;}t.bold&&(e.style.fontWeight="bold"),t.italic&&(e.style.fontStyle="italic"),t.color&&(e.style.color=t.color),t.letterSpacing&&(e.style.letterSpacing=`${t.letterSpacing}px`),t.highlight&&(e.style.backgroundColor=t.highlight);let n=[];t.underline&&(n.push("underline"),typeof t.underline=="object"&&(t.underline.style&&(e.style.textDecorationStyle=t.underline.style),t.underline.color&&(e.style.textDecorationColor=t.underline.color))),t.strike&&n.push("line-through"),t.commentIds&&t.commentIds.length>0&&(e.style.backgroundColor="rgba(255, 212, 0, 0.25)",e.style.borderBottom="2px solid rgba(255, 212, 0, 0.6)",e.dataset.commentId=String(t.commentIds[0])),t.isInsertion&&(e.style.backgroundColor="rgba(52, 168, 83, 0.08)",e.style.borderBottom="2px dashed #2e7d32",e.style.paddingBottom="1px",e.classList.add("docx-insertion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId!=null&&(e.dataset.revisionId=String(t.changeRevisionId))),t.isDeletion&&(e.style.backgroundColor="rgba(211, 47, 47, 0.08)",e.style.color="#c62828",n.includes("line-through")||n.push("line-through"),e.style.textDecorationColor="#c62828",e.classList.add("docx-deletion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId!=null&&(e.dataset.revisionId=String(t.changeRevisionId))),n.length>0&&(e.style.textDecorationLine=n.join(" ")),t.superscript&&(e.style.verticalAlign="super",e.style.fontSize="0.75em"),t.subscript&&(e.style.verticalAlign="sub",e.style.fontSize="0.75em");}function qo(e,t,n){t!==void 0&&(e.dataset.pmStart=String(t)),n!==void 0&&(e.dataset.pmEnd=String(n));}function ml(e,t){let n=t.createElement("span");if(n.className=`${nn.run} ${nn.text}`,Gy(n,e),qo(n,e.pmStart,e.pmEnd),e.hyperlink){let o=t.createElement("a");o.href=e.hyperlink.href,e.hyperlink.href.startsWith("#")||(o.target="_blank",o.rel="noopener noreferrer"),e.hyperlink.tooltip&&(o.title=e.hyperlink.tooltip),o.textContent=e.text;let r=e.color||"#0563c1";o.style.color=r,o.style.textDecoration="underline",n.style.color=r,n.appendChild(o);}else n.textContent=e.text;return n}function Rp(e,t,n,o){let r=t.createElement("span");if(r.className=`${nn.run} ${nn.tab}`,r.style.display="inline-block",r.style.width=`${n}px`,r.style.overflow="hidden",qo(r,e.pmStart,e.pmEnd),o&&o!=="none"){let i=Ky(o);i&&(r.style.backgroundImage=`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='4' height='16'><text x='0' y='12' font-size='12' fill='%23000'>${i}</text></svg>`)}")`,r.style.backgroundRepeat="repeat-x",r.style.backgroundPosition="bottom");}return r.textContent="\xA0",r}function Ky(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "middleDot":return "\xB7";case "heavy":return "_";default:return null}}function Yy(e,t){let n=t.createElement("img");return n.className=`${nn.run} ${nn.image}`,n.src=e.src,n.width=e.width,n.height=e.height,e.alt&&(n.alt=e.alt),e.transform&&(n.style.transform=e.transform),n.style.display="inline",n.style.verticalAlign="middle",qo(n,e.pmStart,e.pmEnd),n}function wp(e,t){let n=t.createElement("div");n.className="layout-block-image",n.style.display="block",n.style.textAlign="center",n.style.marginTop=`${e.distTop??6}px`,n.style.marginBottom=`${e.distBottom??6}px`;let o=t.createElement("img");return o.src=e.src,o.width=e.width,o.height=e.height,o.style.marginLeft="auto",o.style.marginRight="auto",e.alt&&(o.alt=e.alt),e.transform&&(o.style.transform=e.transform),qo(n,e.pmStart,e.pmEnd),n.appendChild(o),n}function Ep(e,t){return Xo(e)||e.displayMode==="block"||e.wrapType==="topAndBottom"?wp(e,t):Yy(e,t)}function Mp(e,t){let n=t.createElement("br");return n.className=`${nn.run} ${nn.lineBreak}`,qo(n,e.pmStart,e.pmEnd),n}function Pp(e,t,n){let o=e.fallback??"";switch(e.fieldType){case "PAGE":o=String(n.pageNumber);break;case "NUMPAGES":o=String(n.totalPages);break;case "DATE":o=new Date().toLocaleDateString();break;case "TIME":o=new Date().toLocaleTimeString();break}let r={text:o,bold:e.bold,italic:e.italic,underline:e.underline,strike:e.strike,color:e.color,highlight:e.highlight,fontFamily:e.fontFamily,fontSize:e.fontSize,pmStart:e.pmStart,pmEnd:e.pmEnd};return ml(r,t)}function qy(e,t,n){if(zr(e))return ml(e,t);if(Ma(e))return Rp(e,t,48,void 0);if(vp(e))return Ep(e,t);if(pl(e))return Mp(e,t);if(fl(e)&&n)return Pp(e,t,n);let o=t.createElement("span");return o.className=nn.run,o}function Ip(e,t){let n=[],o=e.runs;for(let r=t.fromRun;r<=t.toRun;r++){let i=o[r];if(i)if(zr(i)){let a=r===t.fromRun?t.fromChar:0,s=r===t.toRun?t.toChar:i.text.length;if(a>0||s<i.text.length){let l=i.text.slice(a,s);n.push({...i,text:l,pmStart:i.pmStart!==void 0?i.pmStart+a:void 0,pmEnd:i.pmStart!==void 0?i.pmStart+s:void 0});}else n.push(i);}else n.push(i);}return n}function Xy(e){return [e.pmStart??"no-start",e.pmEnd??"no-end",e.src,e.width,e.height,e.displayMode??"inline",e.wrapType??"none"].join("|")}function Zy(e){return {val:e.val,pos:e.pos,leader:e.leader}}function Jy(e,t,n){let o="";for(let r=t+1;r<e.length;r++){let i=e[r];if(zr(i))o+=i.text;else if(fl(i))i.fieldType==="PAGE"&&n?o+=String(n.pageNumber):i.fieldType==="NUMPAGES"&&n?o+=String(n.totalPages):o+=i.fallback??"";else if(Ma(i)||pl(i))break}return o}function Qy(e){let n=e.createElement("canvas").getContext("2d");return (o,r=11,i="Calibri")=>{if(!n)return o.length*7;let a=chunkQQ63M65M_js.a(i).cssFallback,s=r*96/72;return n.font=`${s}px ${a}`,n.measureText(o).width}}function Fp(e,t,n,o,r){let i=o.createElement("div");i.className=nn.line,i.style.height=`${t.lineHeight}px`,i.style.lineHeight=`${t.lineHeight}px`;let a=Ip(e,t);if(a.length===0){let b=o.createElement("span");return b.className=`${nn.run} layout-empty-run`,b.innerHTML=" ",i.appendChild(b),i}let s=n==="justify",l=false;s&&r&&(l=!r.isLastLine||r.paragraphEndsWithLineBreak,l&&(i.style.textAlign="justify",i.style.textAlignLast="justify",i.style.width=`${r.availableWidth}px`)),i.style.whiteSpace="pre";let u=a.some(b=>zr(b)&&b.highlight);i.style.overflow=u?"hidden":"visible";let d=a.some(Ma),c,p=Qy(o);if(d){let b=r?.tabStops?.map(Zy),g=r?.leftIndentPx?Math.round(r.leftIndentPx*15):0;c={explicitStops:b,leftIndent:g};}let f=0,m=r?.leftIndentPx??0;if(r?.isFirstLine){let b=r?.firstLineIndentPx??0;f=m+b;}else f=m;for(let b=0;b<a.length;b++){let g=a[b];if(Ma(g)&&c){let x=Jy(a,b,r?.context),T=Tp(f,c,x,p),S=Rp(g,o,T.width,T.leader);i.appendChild(S),f+=T.width;}else if(zr(g)){let x=ml(g,o);if(g.highlight){let C=(g.fontSize?g.fontSize*96/72:14.67)*1.2,P=Math.max(0,t.lineHeight-C);if(P>0){let _=P/2;x.style.paddingTop=`${_}px`,x.style.paddingBottom=`${_}px`;}}i.appendChild(x);let T=g.fontSize||11,S=g.fontFamily||"Calibri";f+=p(g.text,T,S);}else if(vp(g)){if(Xo(g))continue;let x=Xy(g);if(r?.renderedInlineImageKeys?.has(x))continue;r?.renderedInlineImageKeys?.add(x);let T=Ep(g,o);i.appendChild(T),g.displayMode!=="block"&&g.wrapType!=="topAndBottom"&&(f+=g.width);}else if(pl(g)){let x=Mp(g,o);i.appendChild(x);}else if(fl(g)&&r?.context){let x=Pp(g,o,r.context);i.appendChild(x);let T=g.fallback??"";g.fieldType==="PAGE"?T=String(r.context.pageNumber):g.fieldType==="NUMPAGES"&&(T=String(r.context.totalPages));let S=g.fontSize||11,B=g.fontFamily||"Calibri";f+=p(T,S,B);}else {let x=qy(g,o,r?.context);i.appendChild(x);}}return i}function Nr(e,t){return !e&&!t?true:!e||!t?false:e.style===t.style&&e.width===t.width&&e.color===t.color}function Cp(e,t){return !e&&!t||!e||!t?false:Nr(e.top,t.top)&&Nr(e.bottom,t.bottom)&&Nr(e.left,t.left)&&Nr(e.right,t.right)&&Nr(e.between,t.between)}function An(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=nn.fragment,a.style.position="relative",a.dataset.blockId=String(e.blockId),a.dataset.fromLine=String(e.fromLine),a.dataset.toLine=String(e.toLine),qo(a,e.pmStart,e.pmEnd),e.continuesFromPrev&&(a.dataset.continuesFromPrev="true"),e.continuesOnNext&&(a.dataset.continuesOnNext="true");let s=n.lines.slice(e.fromLine,e.toLine),l=t.attrs?.alignment;t.attrs?.styleId&&(a.dataset.styleId=t.attrs.styleId);let u=t.attrs?.bidi;u&&(a.dir="rtl"),l?l==="center"?a.style.textAlign="center":l==="right"?a.style.textAlign="right":l==="left"?a.style.textAlign="left":a.style.textAlign=u?"right":"left":u&&(a.style.textAlign="right");let d=t.attrs?.indent,c=0,p=0;d&&(u?(d.left&&d.left>0&&(p=d.left),d.right&&d.right>0&&(c=d.right)):(d.left&&d.left>0&&(c=d.left),d.right&&d.right>0&&(p=d.right)));let f=t.attrs?.borders;if(f){let C=H=>{switch(H){case "single":return "solid";case "double":return "double";case "dotted":return "dotted";case "dashed":return "dashed";case "thick":return "solid";case "wave":return "wavy";case "dashSmallGap":return "dashed";case "nil":case "none":return "none";default:return "solid"}};a.style.boxSizing="border-box";let P=H=>`${H.width}px ${C(H.style)} ${H.color}`,_=Cp(r.prevBorders,f),q=Cp(f,r.nextBorders);if(_&&f.between?a.style.borderTop=P(f.between):f.top&&!_&&(a.style.borderTop=P(f.top)),f.bottom&&!q&&(a.style.borderBottom=P(f.bottom)),f.left&&(a.style.borderLeft=P(f.left)),f.right&&(a.style.borderRight=P(f.right)),f.bar){let H=i.createElement("div");H.style.position="absolute",H.style.left="-8px",H.style.top="0",H.style.bottom="0",H.style.borderLeft=P(f.bar),a.style.position="relative",a.appendChild(H);}if(f.top||f.bottom||f.left||f.right||f.between){let H=f.top||f.between;a.style.paddingLeft=f.left?`${f.left.space??4}px`:"0",a.style.paddingRight=f.right?`${f.right.space??4}px`:"0",a.style.paddingTop=H?`${H.space??2}px`:"0",a.style.paddingBottom=f.bottom?`${f.bottom.space??6}px`:"0";}}t.attrs?.shading&&(a.style.backgroundColor=t.attrs.shading);let m=e.width-c-p,g=t.runs[t.runs.length-1]?.kind==="lineBreak",x=n.lines.length,T=0;d?.hanging&&d.hanging>0?T=-d.hanging:d?.firstLine&&d.firstLine>0&&(T=d.firstLine);let S=0,B=r.renderedInlineImageKeys??new Set;for(let C=0;C<s.length;C++){let P=s[C],_=e.fromLine+C,q=_===x-1,z=_===0&&!e.continuesFromPrev,H=P.leftOffset??0,ee=P.rightOffset??0,ue=m;if(z){let ae=d?.hanging&&d.hanging>0,N=d?.firstLine&&d.firstLine>0;ae&&d?.hanging?ue=m+d.hanging:N&&d?.firstLine&&(ue=m-d.firstLine);}let A=Fp(t,P,l,i,{availableWidth:ue-H-ee,isLastLine:q,isFirstLine:z,paragraphEndsWithLineBreak:g,tabStops:t.attrs?.tabs,leftIndentPx:c,firstLineIndentPx:z?T:0,context:o,renderedInlineImageKeys:B});if(H>0||ee>0){H>0&&(A.style.marginLeft=`${H}px`),ee>0&&(A.style.marginRight=`${ee}px`);let ae=ue-H-ee;ae>0&&(A.style.width=`${ae}px`);}S+=P.lineHeight;let O=d?.hanging&&d.hanging>0,ie=d?.firstLine&&d.firstLine>0;if(z?c>0&&O?(A.style.paddingLeft=`${c}px`,A.style.textIndent=`-${d.hanging}px`):c>0&&ie?(A.style.paddingLeft=`${c}px`,A.style.textIndent=`${d.firstLine}px`):c>0?A.style.paddingLeft=`${c}px`:ie&&(A.style.textIndent=`${d.firstLine}px`):c>0?A.style.paddingLeft=`${c}px`:O&&(A.style.paddingLeft=`${d.hanging}px`),p>0&&(A.style.paddingRight=`${p}px`),z&&t.attrs?.listMarker&&!t.attrs?.listMarkerHidden){let ae=Math.max(0,c-(d?.hanging??0));A.style.paddingLeft=`${ae}px`,A.style.textIndent="0";let N;if(!t.attrs.listMarkerFontFamily||!t.attrs.listMarkerFontSize)for(let M=P.fromRun;M<=P.toRun;M++){let F=t.runs[M];if(F&&F.kind==="text"){N=F;break}}let Ie=t.attrs.listMarkerFontFamily??N?.fontFamily??t.attrs.defaultFontFamily,Fe=t.attrs.listMarkerFontSize??N?.fontSize??t.attrs.defaultFontSize,Ve=ex(t.attrs.listMarker,d,i,Ie,Fe);A.insertBefore(Ve,A.firstChild);}a.appendChild(A);}return a}function ex(e,t,n,o,r){let i=n.createElement("span");if(i.className="layout-list-marker",i.style.display="inline-block",o&&(i.style.fontFamily=chunkQQ63M65M_js.a(o).cssFallback),r){let s=r*96/72;i.style.fontSize=`${s}px`;}i.textContent=e;let a=t?.hanging??24;return i.style.minWidth=`${a}px`,i.style.textAlign="left",i.style.boxSizing="border-box",i}var Rn={table:"layout-table",row:"layout-table-row",cell:"layout-table-cell",cellContent:"layout-table-cell-content",resizeHandle:"layout-table-resize-handle",rowResizeHandle:"layout-table-row-resize-handle",tableEdgeHandleBottom:"layout-table-edge-handle-bottom",tableEdgeHandleRight:"layout-table-edge-handle-right"};function tx(e,t,n){let o=[],r=0;for(let i=0;i<e.blocks.length;i++){let a=e.blocks[i];if(a?.kind!=="paragraph"){let u=t.blocks[i];u&&u.kind==="table"&&(r+=u.totalHeight??0);continue}let s=a;for(let u of s.runs){if(u.kind!=="image")continue;let d=u;if(!Xo(d))continue;let c=d.position,p=d.distTop??0,f=d.distBottom??0,m=d.distLeft??12,b=d.distRight??12,g="left",x=0;if(c?.horizontal){let B=c.horizontal;B.align==="right"?(g="right",x=n-d.width):B.align==="left"?x=0:B.align==="center"?x=(n-d.width)/2:B.posOffset!==void 0&&(x=eo(B.posOffset),g=x>n/2?"right":"left");}else d.cssFloat==="right"&&(g="right",x=n-d.width);let T=r;if(c?.vertical){let B=c.vertical;B.posOffset!==void 0?T=r+eo(B.posOffset):B.align==="top"&&(T=0);}x=Math.max(0,Math.min(x,n-d.width));let S="bothSides";d.cssFloat==="left"?S="right":d.cssFloat==="right"&&(S="left"),o.push({src:d.src,width:d.width,height:d.height,alt:d.alt,transform:d.transform,x,y:T,side:g,distTop:p,distBottom:f,distLeft:m,distRight:b,wrapText:S,pmStart:d.pmStart,pmEnd:d.pmEnd});}let l=t.blocks[i];l&&l.kind==="paragraph"&&(r+=l.totalHeight);}return o}function nx(e,t,n,o){let r=o.createElement("div");r.className=Rn.cellContent,r.style.position="relative";let i=e.padding?.left??7,a=e.padding?.right??7,s=Math.max(0,t.width-i-a);r.style.width=`${s}px`;let l=tx(e,t,s),u;if(l.length>0){u=l.map(p=>{let f=p.x+p.width+p.distRight,m=p.y-p.distTop,b=p.y+p.height+p.distBottom,g=0,x=0,T=p.wrapText??"bothSides";return T==="right"?g=f:T==="left"?x=s-(p.x-p.distLeft):p.side==="left"?g=f:x=s-(p.x-p.distLeft),{leftMargin:g,rightMargin:x,topY:m,bottomY:b}});let c=o.createElement("div");c.className="layout-cell-floating-images-layer",c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.width="100%",c.style.height="100%",c.style.pointerEvents="none",c.style.zIndex="10",c.style.overflow="hidden";for(let p of l){let f=o.createElement("div");f.className="layout-cell-floating-image",f.style.position="absolute",f.style.left=`${p.x}px`,f.style.top=`${p.y}px`,f.style.pointerEvents="auto",p.pmStart!==void 0&&(f.dataset.pmStart=String(p.pmStart)),p.pmEnd!==void 0&&(f.dataset.pmEnd=String(p.pmEnd));let m=o.createElement("img");m.src=p.src,m.style.width=`${p.width}px`,m.style.height=`${p.height}px`,m.style.display="block",p.alt&&(m.alt=p.alt),p.transform&&(m.style.transform=p.transform),f.appendChild(m),c.appendChild(f);}r.appendChild(c);}let d=0;for(let c=0;c<e.blocks.length;c++){let p=e.blocks[c],f=t.blocks[c];if(p?.kind==="paragraph"&&f?.kind==="paragraph"){let m=p,b=f;u&&u.length>0&&(b=vn(m,s,{floatingZones:u,paragraphYOffset:d}));let g={blockId:m.id,width:s,height:b.totalHeight,fromLine:0,toLine:b.lines.length,pmStart:m.pmStart,pmEnd:m.pmEnd},x={...n,insideTableCell:true},T=An(g,m,b,x,{document:o});T.style.position="relative",r.appendChild(T),d+=b.totalHeight;}else if(p?.kind==="table"&&f?.kind==="table"){let g=ox(p,f,n,o);g.style.position="relative",r.appendChild(g),d+=f.totalHeight??0;}}return r}function ox(e,t,n,o){let r=o.createElement("div");r.className=`${Rn.table} layout-nested-table`,r.style.position="relative",r.style.width=`${t.totalWidth}px`,r.style.display="block",e.justification==="center"?(r.style.marginLeft="auto",r.style.marginRight="auto"):e.justification==="right"?r.style.marginLeft="auto":e.indent&&(r.style.marginLeft=`${e.indent}px`),r.dataset.blockId=String(e.id),e.pmStart!==void 0&&(r.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(r.dataset.pmEnd=String(e.pmEnd));let i=[],a=0;for(let u=0;u<t.rows.length;u++)i.push(a),a+=t.rows[u]?.height??0;i.push(a);let s=new Map,l=0;for(let u=0;u<e.rows.length;u++){let d=e.rows[u],c=t.rows[u];if(!d||!c)continue;let p=gl(d,c,u,l,t.columnWidths,e.rows.length,n,o,s,i);r.appendChild(p),l+=c.height;}return r.style.height=`${l}px`,r}function Pa(e,t,n){let o=`border${t.charAt(0).toUpperCase()+t.slice(1)}`;if(!n||n.style==="none"||n.style==="nil"||n.width===0)e.style[o]="none";else {let r=n.width??1,i=n.color??"#000000",a=n.style??"solid";e.style[o]=`${r}px ${a} ${i}`;}}function rx(e,t,n,o,r,i,a){let s=a.createElement("div");s.className=Rn.cell,s.style.position="absolute",s.style.left=`${n}px`,s.style.top="0",s.style.width=`${t.width}px`,s.style.height=`${o}px`,s.style.overflow="hidden",s.style.boxSizing="border-box";let l=e.padding?.top??1,u=e.padding?.right??7,d=e.padding?.bottom??1,c=e.padding?.left??7;if(s.style.padding=`${l}px ${u}px ${d}px ${c}px`,e.borders&&(r.isFirstRow&&Pa(s,"top",e.borders.top),Pa(s,"right",e.borders.right),Pa(s,"bottom",e.borders.bottom),r.isFirstCol&&Pa(s,"left",e.borders.left)),e.background&&(s.style.backgroundColor=e.background),e.verticalAlign)switch(s.style.display="flex",s.style.flexDirection="column",e.verticalAlign){case "top":s.style.justifyContent="flex-start";break;case "center":s.style.justifyContent="center";break;case "bottom":s.style.justifyContent="flex-end";break}let p=nx(e,t,i,a);if(s.appendChild(p),e.blocks.length>0){let f=e.blocks[0],m=e.blocks[e.blocks.length-1];f&&"pmStart"in f&&f.pmStart!==void 0&&(s.dataset.pmStart=String(f.pmStart)),m&&"pmEnd"in m&&m.pmEnd!==void 0&&(s.dataset.pmEnd=String(m.pmEnd));}return s}function gl(e,t,n,o,r,i,a,s,l,u,d){let c=s.createElement("div");c.className=Rn.row,c.style.position="absolute",c.style.left="0",c.style.top=`${o}px`,c.style.width="100%",c.style.height=`${t.height}px`,c.dataset.rowIndex=String(n);let p=new Set;if(l){for(let[,b]of l)if(b.startRow<n&&b.startRow+b.rowSpan>n)for(let g=0;g<b.colSpan;g++)p.add(b.columnIndex+g);}let f=0,m=0;for(;p.has(m);)f+=r[m]??0,m++;for(let b=0;b<e.cells.length;b++){let g=e.cells[b],x=t.cells[b];if(!g||!x)continue;let T=g.colSpan??1,S=g.rowSpan??1,B=t.height;if(S>1&&u){B=0;for(let H=n;H<n+S&&H<u.length-1;H++)B+=(u[H+1]??0)-(u[H]??0);B===0&&(B=t.height*S);}let C=n===0||d===true,_=m===0;m+T>=r.length;let z=rx(g,x,f,B,{isFirstRow:C,isFirstCol:_},a,s);if(z.dataset.cellIndex=String(b),z.dataset.columnIndex=String(m),S>1&&(z.dataset.rowSpan=String(S)),c.appendChild(z),S>1&&l){let H=`${n}-${m}`;l.set(H,{cell:g,cellMeasure:x,columnIndex:m,startRow:n,rowSpan:S,colSpan:T,x:f,totalHeight:B});}for(let H=0;H<T&&m+H<r.length;H++)f+=r[m+H]??0;for(m+=T;p.has(m);)f+=r[m]??0,m++;}return c}function Ia(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Rn.table,a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",a.dataset.blockId=String(e.blockId),a.dataset.fromRow=String(e.fromRow),a.dataset.toRow=String(e.toRow),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let s=0;for(let m=0;m<n.columnWidths.length-1;m++){s+=n.columnWidths[m]??0;let b=i.createElement("div");b.className=Rn.resizeHandle,b.style.position="absolute",b.style.left=`${s-3}px`,b.style.top="0",b.style.width="6px",b.style.height="100%",b.style.cursor="col-resize",b.style.zIndex="10",b.dataset.columnIndex=String(m),b.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}let l=[],u=0;for(let m=0;m<n.rows.length;m++)l.push(u),u+=n.rows[m]?.height??0;l.push(u);let d=new Map,c=e.headerRowCount??0,p=0;if(c>0&&e.continuesFromPrev)for(let m=0;m<c;m++){let b=t.rows[m],g=n.rows[m];if(!b||!g)continue;let x=gl(b,g,m,p,n.columnWidths,t.rows.length,o,i,d,l,m===0);x.dataset.repeatedHeader="true",a.appendChild(x),p+=g.height;}for(let m=e.fromRow;m<e.toRow;m++){let b=t.rows[m],g=n.rows[m];if(!b||!g)continue;let x=c>0&&e.continuesFromPrev?false:e.continuesFromPrev&&m===e.fromRow,T=gl(b,g,m,p,n.columnWidths,t.rows.length,o,i,d,l,x);a.appendChild(T),p+=g.height;}let f=0;for(let m=e.fromRow;m<e.toRow;m++)if(f+=n.rows[m]?.height??0,m<e.toRow-1){let b=i.createElement("div");b.className=Rn.rowResizeHandle,b.style.position="absolute",b.style.left="0",b.style.top=`${f-3}px`,b.style.width="100%",b.style.height="6px",b.style.cursor="row-resize",b.style.zIndex="10",b.dataset.rowIndex=String(m),b.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}if(e.toRow===t.rows.length){let m=i.createElement("div");m.className=Rn.tableEdgeHandleBottom,m.style.position="absolute",m.style.left="0",m.style.top=`${f-3}px`,m.style.width="100%",m.style.height="6px",m.style.cursor="row-resize",m.style.zIndex="10",m.dataset.rowIndex=String(t.rows.length-1),m.dataset.tableBlockId=String(e.blockId),m.dataset.isEdge="bottom",e.pmStart!==void 0&&(m.dataset.tablePmStart=String(e.pmStart)),a.appendChild(m);}if(e.toRow===t.rows.length){let m=n.columnWidths.reduce((g,x)=>g+x,0),b=i.createElement("div");b.className=Rn.tableEdgeHandleRight,b.style.position="absolute",b.style.left=`${m-3}px`,b.style.top="0",b.style.width="6px",b.style.height="100%",b.style.cursor="col-resize",b.style.zIndex="10",b.dataset.columnIndex=String(n.columnWidths.length-1),b.dataset.tableBlockId=String(e.blockId),b.dataset.isEdge="right",e.pmStart!==void 0&&(b.dataset.tablePmStart=String(e.pmStart)),a.appendChild(b);}return a}var hl={image:"layout-image",imageAnchored:"layout-image-anchored"};function Fa(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=hl.image,e.isAnchored&&a.classList.add(hl.imageAnchored),a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",e.zIndex!==void 0&&(a.style.zIndex=String(e.zIndex)),t.anchor?.behindDoc&&(a.style.zIndex="-1"),a.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let s=i.createElement("img");if(s.src=t.src,s.alt=t.alt??"",s.style.width="100%",s.style.height="100%",s.style.objectFit="contain",s.style.display="block",t.transform&&(s.style.transform=t.transform),s.draggable=false,t.hlinkHref){let l=i.createElement("a");l.href=t.hlinkHref,l.target="_blank",l.rel="noopener noreferrer",l.style.display="block",l.style.width="100%",l.style.height="100%",l.appendChild(s),a.appendChild(l);}else a.appendChild(s);return a}var Lp={textBox:"layout-textbox"};function La(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");if(a.className=Lp.textBox,a.style.position="absolute",a.style.width=`${e.width}px`,a.style.height=`${e.height}px`,a.style.overflow="hidden",a.style.boxSizing="border-box",t.fillColor&&(a.style.backgroundColor=t.fillColor),t.outlineWidth&&t.outlineWidth>0){let d=t.outlineStyle||"solid",c=t.outlineColor||"#000000";a.style.border=`${t.outlineWidth}px ${d} ${c}`;}let s=t.margins??chunkQQ63M65M_js.c;a.style.padding=`${s.top}px ${s.right}px ${s.bottom}px ${s.left}px`,a.dataset.blockId=String(e.blockId),e.pmStart!==void 0&&(a.dataset.pmStart=String(e.pmStart)),e.pmEnd!==void 0&&(a.dataset.pmEnd=String(e.pmEnd));let l=e.width-s.left-s.right,u=0;for(let d=0;d<t.content.length;d++){let c=t.content[d],p=n.innerMeasures[d];if(!p)continue;let f={blockId:c.id,width:l,height:p.totalHeight,pmStart:c.pmStart,pmEnd:c.pmEnd,fromLine:0,toLine:p.lines.length},m=An(f,c,p,o,{document:i});m.style.position="relative",m.style.left="0",m.style.top="0",a.appendChild(m),u+=p.totalHeight;}return a}var to={page:"layout-page",content:"layout-page-content",header:"layout-page-header",footer:"layout-page-footer"};function Aa(e,t,n,o){if(e.style.position="relative",e.style.width=`${t}px`,e.style.height=`${n}px`,e.style.backgroundColor=o.backgroundColor??"#ffffff",e.style.overflow="hidden",e.style.fontFamily='Calibri, "Segoe UI", Arial, sans-serif',e.style.fontSize=`${1056/72}px`,e.style.color="#000000",o.showBorders&&(e.style.border="1px solid #ccc"),o.showShadow&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)"),o.pageBorders){let r=o.pageBorders,i=["top","bottom","left","right"],a=["Top","Bottom","Left","Right"];for(let s=0;s<i.length;s++){let l=r[i[s]];if(l&&l.style!=="none"&&l.style!=="nil"){let u=zo(l,a[s],o.theme);for(let[d,c]of Object.entries(u))e.style[d]=String(c);}}}}function ix(e,t){let n=t.margins;e.style.position="absolute",e.style.top=`${n.top}px`,e.style.left=`${n.left}px`,e.style.right=`${n.right}px`,e.style.bottom=`${n.bottom}px`,e.style.overflow="visible";}function Dp(e){return e?.align??e?.alignment}function ax(e,t){let n=e.position.vertical;if(!n)return e.paragraphY;let o=Dp(n),r=n.posOffset!==void 0?eo(n.posOffset):void 0;if(n.relativeTo==="page"){if(r!==void 0)return r-t.flowTop;if(o==="top")return -t.flowTop;if(o==="bottom")return t.pageHeight-e.height-t.flowTop;if(o==="center")return (t.pageHeight-e.height)/2-t.flowTop}if(n.relativeTo==="margin"){let i=t.margins.top,a=t.pageHeight-t.margins.top-t.margins.bottom;if(r!==void 0)return i+r-t.flowTop;if(o==="top")return i-t.flowTop;if(o==="bottom")return i+a-e.height-t.flowTop;if(o==="center")return i+(a-e.height)/2-t.flowTop}return r!==void 0?e.paragraphY+r:e.paragraphY}function sx(e,t,n){let o=t.position.horizontal;if(!o){e.style.left="0";return}let r=Dp(o);if(o.relativeTo==="page"){if(o.posOffset!==void 0){e.style.left=`${eo(o.posOffset)-n.flowLeft}px`;return}if(r==="right"){e.style.left=`${n.pageWidth-t.width-n.flowLeft}px`;return}if(r==="center"){e.style.left=`${(n.pageWidth-t.width)/2-n.flowLeft}px`;return}if(r==="left"){e.style.left=`${-n.flowLeft}px`;return}}if(o.posOffset!==void 0){e.style.left=`${eo(o.posOffset)}px`;return}if(r==="right"){e.style.left=`${n.contentWidth-t.width}px`;return}if(r==="center"){e.style.left=`${(n.contentWidth-t.width)/2}px`;return}e.style.left="0";}function lx(e,t,n){e.style.position="absolute",e.style.left=`${t.x-n.left}px`,e.style.top=`${t.y-n.top}px`,e.style.width=`${t.width}px`,"height"in t&&(e.style.height=`${t.height}px`);}function eo(e){return e===void 0?0:Math.round(e*96/914400)}function Xo(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function cx(e,t,n){let o=[];for(let r of e.runs){if(r.kind!=="image")continue;let i=r;if(!Xo(i))continue;let a=i.position,s=i.distTop??0,l=i.distBottom??0,u=i.distLeft??12,d=i.distRight??12,c="left",p=0;if(a?.horizontal){let b=a.horizontal;b.align==="right"?(c="right",p=n-i.width):b.align==="left"?(c="left",p=0):b.align==="center"?(c="left",p=(n-i.width)/2):b.posOffset!==void 0&&(p=eo(b.posOffset),c=p>n/2?"right":"left");}else i.cssFloat==="right"&&(c="right",p=n-i.width);let f=0;if(a?.vertical){let b=a.vertical;b.align==="top"?f=0:b.align==="bottom"?f=t:b.posOffset!==void 0?f=eo(b.posOffset):f=t,b.relativeTo==="margin"&&(b.align==="top"||b.posOffset!==void 0)||b.relativeTo==="paragraph"&&(f=t+f);}else f=t;let m="bothSides";i.cssFloat==="left"?m="right":i.cssFloat==="right"&&(m="left"),o.push({src:i.src,width:i.width,height:i.height,alt:i.alt,transform:i.transform,side:c,x:p,y:f,distTop:s,distBottom:l,distLeft:u,distRight:d,pmStart:i.pmStart,pmEnd:i.pmEnd,wrapText:m,wrapType:i.wrapType});}return o}function dx(e,t){return e.map(n=>{let o=n.x+n.width+n.distRight,r=n.y-n.distTop,i=n.y+n.height+n.distBottom,a=0,s=0,l=n.wrapText??"bothSides";return l==="right"?a=o:l==="left"?s=t-(n.x-n.distLeft):n.side==="left"?a=o:s=t-(n.x-n.distLeft),{leftMargin:a,rightMargin:s,topY:r,bottomY:i}})}function ux(e,t){let n=t.createElement("div");n.className="layout-floating-images-layer",n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.right="0",n.style.bottom="0",n.style.pointerEvents="none",n.style.zIndex="10";for(let o of e){let r=t.createElement("div");r.className="layout-page-floating-image",r.style.position="absolute",r.style.pointerEvents="auto",r.style.top=`${o.y}px`,r.style.left=`${o.x}px`,o.pmStart!==void 0&&(r.dataset.pmStart=String(o.pmStart)),o.pmEnd!==void 0&&(r.dataset.pmEnd=String(o.pmEnd));let i=t.createElement("img");i.src=o.src,i.style.width=`${o.width}px`,i.style.height=`${o.height}px`,i.style.display="block",o.alt&&(i.alt=o.alt),o.transform&&(i.style.transform=o.transform),r.appendChild(i),n.appendChild(r);}return n}function Bp(e,t,n,o){let r=n.document??document,i=r.createElement("div");i.style.position="relative";let a=t.contentWidth??600,s=[],l=0;for(let u=0;u<e.blocks.length;u++){let d=e.blocks[u],c=e.measures[u];if(d?.kind==="paragraph"&&c?.kind==="paragraph"){let p=d,f=c,m=l,b=[];for(let S of p.runs)if(S.kind==="image"&&"position"in S&&S.position){let B=S;s.push({src:B.src,width:B.width,height:B.height,alt:B.alt,paragraphY:m,position:B.position});}else b.push(S);let g={...p,runs:b},x={blockId:p.id,width:a,height:f.totalHeight,fromLine:0,toLine:f.lines.length},T=An(x,g,f,t,{document:r});T.style.position="relative",T.style.marginBottom="0",i.appendChild(T),l+=f.totalHeight;}}for(let u of s){let d=r.createElement("img");d.src=u.src,d.width=u.width,d.height=u.height,u.alt&&(d.alt=u.alt),d.style.position="absolute",d.style.display="block",d.style.width=`${u.width}px`,d.style.height=`${u.height}px`,d.style.maxWidth="none",d.style.maxHeight="none",sx(d,u,o),d.style.top=`${ax(u,o)}px`,i.appendChild(d);}return i}function px(e,t,n){let o=n.createElement("div");o.className="layout-footnote-area",o.style.width=`${t}px`;let r=n.createElement("div");r.style.width="33%",r.style.height="0.5px",r.style.backgroundColor="#000",r.style.marginBottom="6px",r.style.marginTop="6px",o.appendChild(r);for(let i of e){let a=n.createElement("div");a.style.fontSize="10px",a.style.lineHeight="1.3",a.style.marginBottom="4px",a.style.color="#000";let s=n.createElement("sup");s.textContent=i.displayNumber,s.style.fontSize="7px",s.style.marginRight="2px",a.appendChild(s);let l=n.createTextNode(" "+i.text);a.appendChild(l),o.appendChild(a);}return o}function Ha(e,t,n={}){let o=n.document??document,r=o.createElement("div");r.className=n.pageClassName??to.page,r.dataset.pageNumber=String(e.number),Aa(r,e.size.w,e.size.h,n);let i=o.createElement("div");i.className=to.content,ix(i,e);let a=e.size.w-e.margins.left-e.margins.right,s=[],l=[];for(let f of e.fragments)if(f.kind==="paragraph"&&n.blockLookup){let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind==="paragraph"){let b=m.block,g=f.y-e.margins.top,x=cx(b,g,a);s.push(...x);}}for(let f of s)l.push({side:f.side,x:f.x,y:f.y,width:f.width,height:f.height,distTop:f.distTop,distBottom:f.distBottom,distLeft:f.distLeft,distRight:f.distRight,wrapText:f.wrapText,wrapType:f.wrapType});if(n.blockLookup)for(let f of e.fragments){if(f.kind!=="table")continue;let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind!=="table")continue;let g=m.block.floating;if(!g)continue;let x=f.x-e.margins.left,T=f.y-e.margins.top,S=g.topFromText??0,B=g.bottomFromText??0,C=g.leftFromText??12,P=g.rightFromText??12,_=x<a/2?"left":"right";l.push({side:_,x,y:T,width:f.width,height:f.height,distTop:S,distBottom:B,distLeft:C,distRight:P});}let u=l.length>0?dx(l,a):[];if(s.length>0){let f=ux(s,o);i.appendChild(f);}let d=f=>{if(f.kind!=="paragraph"||!n.blockLookup||!f.blockId)return;let m=n.blockLookup.get(String(f.blockId));if(m?.block.kind==="paragraph")return m.block.attrs?.borders},c,p=new Map;for(let f=0;f<e.fragments.length;f++){let m=e.fragments[f],b,g={...t,section:"body",contentWidth:a},x=m.y-e.margins.top;if(n.blockLookup&&m.blockId){let T=n.blockLookup.get(String(m.blockId));if(m.kind==="paragraph"&&T?.block.kind==="paragraph"&&T?.measure.kind==="paragraph"){let S=T.block,B=f+1<e.fragments.length?d(e.fragments[f+1]):void 0,C=String(m.blockId),P=p.get(C);P||(P=new Set,p.set(C,P));let _=T.measure;u.length>0&&(_=vn(S,a,{floatingZones:u,paragraphYOffset:x})),b=An(m,S,_,g,{document:o,prevBorders:c,nextBorders:B,renderedInlineImageKeys:P}),c=S.attrs?.borders;}else m.kind==="table"&&T?.block.kind==="table"&&T?.measure.kind==="table"?(b=Ia(m,T.block,T.measure,g,{document:o}),c=void 0):m.kind==="image"&&T?.block.kind==="image"&&T?.measure.kind==="image"?(b=Fa(m,T.block,T.measure,g,{document:o}),c=void 0):m.kind==="textBox"&&T?.block.kind==="textBox"&&T?.measure.kind==="textBox"?(b=La(m,T.block,T.measure,g,{document:o}),c=void 0):(b=Hr(m,g,{document:o}),c=void 0);}else b=Hr(m,g,{document:o}),c=void 0;lx(b,m,{left:e.margins.left,top:e.margins.top}),i.appendChild(b);}if(e.columns&&e.columns.separator&&e.columns.count>1){let f=e.columns.count,m=e.columns.gap,b=(a-(f-1)*m)/f,g=e.size.h-e.margins.top-e.margins.bottom;for(let x=0;x<f-1;x++){let T=(x+1)*b+x*m+m/2,S=o.createElement("div");S.style.position="absolute",S.style.left=`${T}px`,S.style.top="0",S.style.height=`${g}px`,S.style.width="0.5px",S.style.backgroundColor="#000",S.style.pointerEvents="none",i.appendChild(S);}}if(n.footnoteArea&&n.footnoteArea.length>0){let f=px(n.footnoteArea,a,o);f.style.position="absolute";let m=e.footnoteReservedHeight??0,b=e.size.h-e.margins.bottom-e.margins.top;f.style.top=`${b-m}px`,f.style.left="0",f.style.right="0",i.appendChild(f);}r.appendChild(i);{let m=n.headerDistance??e.margins.header??48,b=e.size.w-e.margins.left-e.margins.right,g=Math.max(e.margins.top-m,48),x=n.headerContent?.visualTop??0,T=n.headerContent?.visualBottom??n.headerContent?.height??0,S=Math.max(T-x,24),B=T>g,C=o.createElement("div");C.className=to.header,C.style.position="absolute",C.style.top=`${m+x}px`,C.style.left=`${e.margins.left}px`,C.style.right=`${e.margins.right}px`,C.style.width=`${b}px`,C.style.height=`${S}px`,C.style.minHeight=`${S}px`;let P=!B;if(n.headerContent&&n.headerContent.blocks.length>0){let _=Bp(n.headerContent,{...t,section:"header",contentWidth:b},n,{flowTop:m,flowLeft:e.margins.left,contentWidth:b,pageWidth:e.size.w,pageHeight:e.size.h,margins:e.margins});_.style.top=`${-x}px`,_.querySelector("img")&&(P=false),C.appendChild(_);}P&&(C.style.maxHeight=`${g}px`,C.style.overflow="hidden"),r.appendChild(C);}{let m=n.footerDistance??e.margins.footer??48,b=e.size.w-e.margins.left-e.margins.right,g=Math.max(e.margins.bottom-m,48),x=n.footerContent?.visualTop??0,T=n.footerContent?.visualBottom??n.footerContent?.height??0,S=Math.max(T-x,24),B=S>g,C=o.createElement("div");C.className=to.footer,C.style.position="absolute",C.style.top=`${e.size.h-m-S}px`,C.style.left=`${e.margins.left}px`,C.style.right=`${e.margins.right}px`,C.style.width=`${b}px`,C.style.height=`${S}px`,C.style.minHeight=`${S}px`;let P=!B;if(n.footerContent&&n.footerContent.blocks.length>0){let _=Bp(n.footerContent,{...t,section:"footer",contentWidth:b},n,{flowTop:e.size.h-m-(n.footerContent?.height??0),flowLeft:e.margins.left,contentWidth:b,pageWidth:e.size.w,pageHeight:e.size.h,margins:e.margins});_.style.top=`${-x}px`,_.querySelector("img")&&(P=false),C.appendChild(_);}P&&(C.style.maxHeight=`${g}px`,C.style.overflow="hidden"),r.appendChild(C);}return r}function bl(e,t,n){let o={pageNumber:e.number,totalPages:t,section:"body"},r={...n};if(n.footnotesByPage){let i=n.footnotesByPage.get(e.number);i&&i.length>0&&(r.footnoteArea=i);}return {context:o,pageOptions:r}}function Ap(e){let t=[];t.push(`s:${e.size.w},${e.size.h}`),t.push(`m:${e.margins.top},${e.margins.right},${e.margins.bottom},${e.margins.left}`),t.push(`n:${e.number}`),e.footnoteReservedHeight&&t.push(`fn:${e.footnoteReservedHeight}`);for(let n of e.fragments){let o=`${n.kind}:${n.blockId},${n.x},${n.y},${n.width},${n.height}`;n.pmStart!==void 0&&(o+=`,ps:${n.pmStart}`),n.pmEnd!==void 0&&(o+=`,pe:${n.pmEnd}`),n.kind==="paragraph"?o+=`,fl:${n.fromLine},tl:${n.toLine}`:n.kind==="table"&&(o+=`,fr:${n.fromRow},tr:${n.toRow}`),t.push(o);}return t.join("|")}function fx(e){let t=[];return e.headerContent&&t.push(`hdr:${e.headerContent.blocks.length},${e.headerContent.height},${e.headerContent.visualTop??0},${e.headerContent.visualBottom??e.headerContent.height}`),e.footerContent&&t.push(`ftr:${e.footerContent.blocks.length},${e.footerContent.height},${e.footerContent.visualTop??0},${e.footerContent.visualBottom??e.footerContent.height}`),e.theme&&t.push(`thm:${e.theme.name??"default"}`),e.pageBorders&&t.push(`pb:${JSON.stringify(e.pageBorders)}`),e.headerDistance!==void 0&&t.push(`hd:${e.headerDistance}`),e.footerDistance!==void 0&&t.push(`fd:${e.footerDistance}`),t.join("|")}function mx(e,t){e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.gap=`${t}px`,e.style.padding=`${t}px`,e.style.backgroundColor="var(--doc-bg, #f8f9fa)";}var Ba=2,gx=8;function yl(e,t,n={}){let o=e.length,r=n.pageGap??24,i=t,a=i.__pageRenderState,s=fx(n),l=o>=gx;if(a&&a.optionsHash===s&&l){let g=a.pageStates,x=a.pageDataMap,T=i.__pageObserver,S=[];for(let P of e)S.push(Ap(P));let B=a.totalPages!==o,C=Math.min(g.length,e.length);for(let P=0;P<C;P++){let _=g[P],q=S[P];if(_.fingerprint===q&&!B){let ee=x.get(_.element);ee&&(ee.page=e[P]);continue}let z=_.element,H=x.get(z);H&&(H.page=e[P],H.rendered&&hx(z,x,o,n)),_.fingerprint=q,Aa(z,e[P].size.w,e[P].size.h,n),z.dataset.pageNumber=String(e[P].number);}if(e.length>g.length){let P=n.document??document;for(let _=g.length;_<e.length;_++){let q=e[_],z=P.createElement("div");z.className=n.pageClassName??to.page,z.dataset.pageNumber=String(q.number),z.dataset.pageIndex=String(_),Aa(z,q.size.w,q.size.h,n),t.appendChild(z),g.push({element:z,fingerprint:S[_]}),x.set(z,{page:q,index:_,rendered:false}),T&&T.observe(z);}}if(e.length<g.length){for(let P=g.length-1;P>=e.length;P--){let _=g[P].element;T&&T.unobserve(_),x.delete(_),t.removeChild(_);}g.length=e.length;}for(let P=0;P<g.length;P++){let _=x.get(g[P].element);_&&(_.index=P);}a.totalPages=o,a.currentOptions=n;return}let d=i.__pageObserver;d&&(d.disconnect(),i.__pageObserver=void 0),t.innerHTML="",i.__pageRenderState=void 0,mx(t,r);let c=[],p=[];for(let g=0;g<e.length;g++){let x=e[g];if(p.push(Ap(x)),l){let S=(n.document??document).createElement("div");S.className=n.pageClassName??to.page,S.dataset.pageNumber=String(x.number),S.dataset.pageIndex=String(g),Aa(S,x.size.w,x.size.h,n),t.appendChild(S),c.push(S);}else {let{context:T,pageOptions:S}=bl(x,o,n),B=Ha(x,T,S);t.appendChild(B),c.push(B);}}if(!l)return;let f=new Map;for(let g=0;g<e.length;g++)f.set(c[g],{page:e[g],index:g,rendered:false});let m=new IntersectionObserver(g=>{let x=i.__pageRenderState;if(!x)return;let{currentOptions:T,totalPages:S,pageDataMap:B}=x;for(let q of g){let z=q.target,H=B.get(z);if(H&&q.isIntersecting){Da(z,B,S,T);for(let ee=-Ba;ee<=Ba;ee++){let ue=H.index+ee;ue>=0&&ue<x.pageStates.length&&ue!==H.index&&Da(x.pageStates[ue].element,B,S,T);}}}let C=window.innerHeight,P=C*3,_=new Set;for(let[q,z]of B){if(!z.rendered)continue;let H=q.getBoundingClientRect();H.bottom>-P&&H.top<C+P&&_.add(z.index);}for(let[q,z]of B){if(!z.rendered)continue;let H=false;for(let ee of _)if(Math.abs(z.index-ee)<=Ba+1){H=true;break}!H&&_.size>0&&bx(q,B);}},{root:null,rootMargin:"1500px 0px 1500px 0px"});for(let g of c)m.observe(g);i.__pageObserver=m,i.__pageRenderState={pageStates:c.map((g,x)=>({element:g,fingerprint:p[x]})),totalPages:o,optionsHash:s,pageDataMap:f,currentOptions:n};let b=Math.min(e.length,Ba+3);for(let g=0;g<b;g++)Da(c[g],f,o,n);}function Da(e,t,n,o){let r=t.get(e);if(!r||r.rendered)return;let{context:i,pageOptions:a}=bl(r.page,n,o),s=Ha(r.page,i,a);for(;s.firstChild;)e.appendChild(s.firstChild);r.rendered=true;}function hx(e,t,n,o){let r=t.get(e);if(!r)return;let{context:i,pageOptions:a}=bl(r.page,n,o),l=Ha(r.page,i,a).querySelector(`.${to.content}`),u=e.querySelector(`.${to.content}`);l&&u?e.replaceChild(l,u):(e.innerHTML="",r.rendered=false,Da(e,t,n,o));}function bx(e,t){let n=t.get(e);!n||!n.rendered||(e.innerHTML="",n.rendered=false);}var Na=class{constructor(t={}){chunkH5NTJZO4_js.d(this,"container",null);chunkH5NTJZO4_js.d(this,"blockLookup",new Map);chunkH5NTJZO4_js.d(this,"pageStates",[]);chunkH5NTJZO4_js.d(this,"totalPages",0);chunkH5NTJZO4_js.d(this,"options");chunkH5NTJZO4_js.d(this,"doc");this.options=t,this.doc=t.document??document;}setBlockLookup(t){this.blockLookup=t;}mount(t){this.container=t,this.applyContainerStyles();}unmount(){this.container&&(this.container.innerHTML=""),this.container=null,this.pageStates=[];}applyContainerStyles(){if(!this.container)return;let t=this.options.pageGap??24;this.container.style.display="flex",this.container.style.flexDirection="column",this.container.style.alignItems="center",this.container.style.gap=`${t}px`,this.container.style.padding=`${t}px`,this.container.style.backgroundColor=this.options.containerBackground??"var(--doc-bg, #f8f9fa)",this.container.style.minHeight="100%";}paint(t){if(!this.container)throw new Error("LayoutPainter: not mounted");let{pages:n}=t;this.totalPages=n.length,this.container.innerHTML="",this.pageStates=[];for(let o=0;o<n.length;o++){let r=n[o],i={pageNumber:r.number,totalPages:this.totalPages,section:"body"},a=this.renderPageWithLookup(r,i);this.container.appendChild(a),this.pageStates.push({element:a,pageNumber:r.number,fragmentCount:r.fragments.length});}}renderPageWithLookup(t,n){let o=this.doc.createElement("div");o.className="layout-page",o.dataset.pageNumber=String(t.number),o.style.position="relative",o.style.width=`${t.size.w}px`,o.style.height=`${t.size.h}px`,o.style.backgroundColor=this.options.pageBackground??"#ffffff",o.style.overflow="hidden",this.options.showShadow&&(o.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)");let r=this.doc.createElement("div");r.className="layout-page-content",r.style.position="absolute",r.style.top=`${t.margins.top}px`,r.style.left=`${t.margins.left}px`,r.style.right=`${t.margins.right}px`,r.style.bottom=`${t.margins.bottom}px`,r.style.overflow="visible";for(let i of t.fragments){let a=this.renderFragmentWithLookup(i,n);this.applyFragmentPosition(a,i),r.appendChild(a);}return o.appendChild(r),o}renderFragmentWithLookup(t,n){let o=this.blockLookup.get(String(t.blockId));if(t.kind==="paragraph"&&o){let r=o.block,i=o.measure;return An(t,r,i,n,{document:this.doc})}if(t.kind==="table"&&o){let r=o.block,i=o.measure;return Ia(t,r,i,n,{document:this.doc})}if(t.kind==="image"&&o){let r=o.block,i=o.measure;return Fa(t,r,i,n,{document:this.doc})}if(t.kind==="textBox"&&o){let r=o.block,i=o.measure;return La(t,r,i,n,{document:this.doc})}return Hr(t,n,{document:this.doc})}applyFragmentPosition(t,n){t.style.position="absolute",t.style.left=`${n.x}px`,t.style.top=`${n.y}px`,t.style.width=`${n.width}px`,"height"in n&&(t.style.height=`${n.height}px`);}getPageCount(){return this.totalPages}getPageElement(t){return this.pageStates[t]?.element??null}scrollToPage(t){let n=this.pageStates.find(o=>o.pageNumber===t);n?.element&&n.element.scrollIntoView({behavior:"smooth",block:"start"});}};var Dn,no,oo,Hn,Zo,Ro,Hp,xl,za=class{constructor(){chunkH5NTJZO4_js.f(this,Ro);chunkH5NTJZO4_js.f(this,Dn,0);chunkH5NTJZO4_js.f(this,no,0);chunkH5NTJZO4_js.f(this,oo,false);chunkH5NTJZO4_js.f(this,Hn,null);chunkH5NTJZO4_js.f(this,Zo,new Set);}setStateSeq(t){chunkH5NTJZO4_js.g(this,Dn,t);}incrementStateSeq(){return ++chunkH5NTJZO4_js.i(this,Dn)._}getStateSeq(){return chunkH5NTJZO4_js.e(this,Dn)}getRenderSeq(){return chunkH5NTJZO4_js.e(this,no)}onLayoutStart(){chunkH5NTJZO4_js.g(this,oo,true);}onLayoutComplete(t){chunkH5NTJZO4_js.g(this,no,t),chunkH5NTJZO4_js.g(this,oo,false),chunkH5NTJZO4_js.h(this,Ro,Hp).call(this);}isSafeToRender(){return !chunkH5NTJZO4_js.e(this,oo)&&chunkH5NTJZO4_js.e(this,no)>=chunkH5NTJZO4_js.e(this,Dn)}requestRender(){this.isSafeToRender()?chunkH5NTJZO4_js.h(this,Ro,xl).call(this):chunkH5NTJZO4_js.g(this,Hn,()=>chunkH5NTJZO4_js.h(this,Ro,xl).call(this));}onRender(t){return chunkH5NTJZO4_js.e(this,Zo).add(t),()=>{chunkH5NTJZO4_js.e(this,Zo).delete(t);}}reset(){chunkH5NTJZO4_js.g(this,Dn,0),chunkH5NTJZO4_js.g(this,no,0),chunkH5NTJZO4_js.g(this,oo,false),chunkH5NTJZO4_js.g(this,Hn,null);}getDebugInfo(){return {stateSeq:chunkH5NTJZO4_js.e(this,Dn),renderSeq:chunkH5NTJZO4_js.e(this,no),layoutUpdating:chunkH5NTJZO4_js.e(this,oo),hasPendingRender:chunkH5NTJZO4_js.e(this,Hn)!==null,isSafe:this.isSafeToRender()}}};Dn=new WeakMap,no=new WeakMap,oo=new WeakMap,Hn=new WeakMap,Zo=new WeakMap,Ro=new WeakSet,Hp=function(){if(chunkH5NTJZO4_js.e(this,Hn)&&this.isSafeToRender()){let t=chunkH5NTJZO4_js.e(this,Hn);chunkH5NTJZO4_js.g(this,Hn,null),t();}},xl=function(){for(let t of chunkH5NTJZO4_js.e(this,Zo))try{t();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};var zp=".layout-page-content .layout-line";function yx(e){let t=e.parentElement;for(;t&&t!==document.documentElement;){let{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement;}return null}function xx(e){let t=yx(e);if(!t)return;let n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=40;n.bottom>o.bottom-r?t.scrollTop+=n.bottom-o.bottom+r:n.top<o.top+r&&(t.scrollTop-=o.top-n.top+r);}function Op({pagesContainerRef:e}){let t=rf.useRef(null),n=rf.useRef(-1),o=rf.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let d of Array.from(l)){let c=d,p=Number(c.dataset.pmStart),f=Number(c.dataset.pmEnd);if(c.classList.contains("layout-run-tab")){if(s>=p&&s<f)return c.getBoundingClientRect().left;continue}if(s>=p&&s<=f&&d.firstChild?.nodeType===Node.TEXT_NODE){let m=d.firstChild,b=Math.min(s-p,m.length),g=c.ownerDocument;if(!g)continue;let x=g.createRange();return x.setStart(m,b),x.setEnd(m,b),x.getBoundingClientRect().left}}let u=e.current.querySelectorAll(".layout-empty-run");for(let d of Array.from(u)){let c=d.closest(".layout-paragraph");if(!c)continue;let p=Number(c.dataset.pmStart),f=Number(c.dataset.pmEnd);if(s>=p&&s<=f)return d.getBoundingClientRect().left}return null},[e]),r=rf.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll(zp);for(let u of Array.from(l)){let d=u,c=d.querySelectorAll("span[data-pm-start][data-pm-end]");for(let p of Array.from(c)){let f=p,m=Number(f.dataset.pmStart),b=Number(f.dataset.pmEnd);if(s>=m&&s<=b)return d}}for(let u of Array.from(l)){let d=u,c=d.closest(".layout-paragraph");if(!c)continue;let p=Number(c.dataset.pmStart),f=Number(c.dataset.pmEnd);if(s>=p&&s<=f&&c.querySelector(".layout-line")===d)return d}return null},[e]),i=rf.useCallback((s,l)=>{let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart)+1:null}for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect(),g=Number(m.dataset.pmStart),x=Number(m.dataset.pmEnd);if(m.classList.contains("layout-run-tab")){if(l>=b.left&&l<=b.right){let T=(b.left+b.right)/2;return l<T?g:x}continue}if(l>=b.left&&l<=b.right){let T=m.firstChild;if(!T||T.nodeType!==Node.TEXT_NODE)return g;let S=T,B=m.ownerDocument;if(!B)return g;let C=0,P=S.length;for(;C<P;){let _=Math.floor((C+P)/2),q=B.createRange();q.setStart(S,_),q.setEnd(S,_),l<q.getBoundingClientRect().left?P=_:C=_+1;}if(C>0&&C<=S.length){let _=B.createRange();_.setStart(S,C-1),_.setEnd(S,C-1);let q=_.getBoundingClientRect().left;_.setStart(S,Math.min(C,S.length)),_.setEnd(S,Math.min(C,S.length));let z=_.getBoundingClientRect().left;if(Math.abs(l-q)<Math.abs(l-z))return g+(C-1)}return g+Math.min(C,x-g)}}let d=null,c=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect(),g=l<b.left?b.left-l:l-b.right;g<c&&(c=g,d=m);}if(!d)return null;let p=d.getBoundingClientRect();return l<p.left?Number(d.dataset.pmStart):Number(d.dataset.pmEnd)},[]),a=rf.useCallback((s,l)=>{if(l.key!=="ArrowUp"&&l.key!=="ArrowDown")return (["ArrowLeft","ArrowRight","Home","End"].includes(l.key)||l.key.length===1&&!l.ctrlKey&&!l.metaKey)&&(t.current=null,n.current=-1),false;if(l.ctrlKey||l.metaKey)return t.current=null,n.current=-1,false;if(!e.current)return false;let u=Array.from(e.current.querySelectorAll(zp));if(u.length===0)return false;let{from:d,anchor:c}=s.state.selection;if(t.current===null){let S=o(d);if(S===null)return false;t.current=S;}let p;if(n.current>=0&&n.current<u.length)p=n.current;else {let S=r(d);if(!S||(p=u.indexOf(S),p===-1))return false}let f=l.key==="ArrowUp"?p-1:p+1;if(f<0||f>=u.length)return n.current=-1,false;let m=u[f],b=i(m,t.current);if(b===null)return false;n.current=f;let{state:g,dispatch:x}=s,T=Math.max(0,Math.min(b,g.doc.content.size));try{let S=l.shiftKey?prosemirrorState.TextSelection.create(g.doc,c,T):prosemirrorState.TextSelection.create(g.doc,T);x(g.tr.setSelection(S));}catch{let S=g.doc.resolve(T),B=l.shiftKey?prosemirrorState.TextSelection.between(g.doc.resolve(c),S):prosemirrorState.TextSelection.near(S);x(g.tr.setSelection(B));}return xx(m),true},[e,o,r,i]);return {stickyXRef:t,lastVisualLineIndexRef:n,getCaretClientX:o,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}var ro=40,_a=12;function Sx(e){let t=e.parentElement;for(;t&&t!==document.documentElement;){let{overflowY:n}=getComputedStyle(t);if((n==="auto"||n==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement;}return null}function $p({pagesContainerRef:e,onScrollExtendSelection:t}){let n=rf.useRef(null),o=rf.useRef({x:0,y:0}),r=rf.useRef(false),i=rf.useRef(null),a=rf.useCallback(()=>{if(i.current)return i.current;let c=e.current;return c?(i.current=Sx(c),i.current):null},[e]),s=rf.useCallback(()=>{r.current=false,n.current!==null&&(cancelAnimationFrame(n.current),n.current=null);},[]),l=rf.useCallback(()=>{if(!r.current)return;let c=a();if(!c)return;let p=c.getBoundingClientRect(),{x:f,y:m}=o.current,b=0;if(m<p.top+ro){let g=Math.max(0,p.top+ro-m);b=-Math.min(_a,g/ro*_a);}else if(m>p.bottom-ro){let g=Math.max(0,m-(p.bottom-ro));b=Math.min(_a,g/ro*_a);}b!==0&&(c.scrollTop+=b,t(f,m)),n.current=requestAnimationFrame(l);},[a,t]),u=rf.useCallback(()=>{r.current||(r.current=true,n.current=requestAnimationFrame(l));},[l]);return {updateMousePosition:rf.useCallback((c,p)=>{if(o.current={x:c,y:p},!r.current){let f=a();if(!f)return;let m=f.getBoundingClientRect();(p<m.top+ro||p>m.bottom-ro)&&u();}},[a,u]),stopAutoScroll:s}}var kx=12,Va=8;function Wp(e){let t=[];for(let n of e)if(n.kind==="paragraph")for(let o of n.runs)o.kind==="text"&&o.footnoteRefId!=null&&t.push({footnoteId:o.footnoteRefId,pmPos:o.pmStart??0});return t}function Sl(e,t){let n=new Map;if(t.length===0)return n;for(let o of t)for(let r of e){let i=false;for(let a of r.fragments){let s=a.pmStart??-1,l=a.pmEnd??-1;if(s>=0&&l>=0&&o.pmPos>=s&&o.pmPos<l){let u=n.get(r.number)??[];u.includes(o.footnoteId)||u.push(o.footnoteId),n.set(r.number,u),i=true;break}}if(i)break}return n}function Tx(e,t,n){let o=[];for(let a=0;a<e.content.length;a++){let s=e.content[a],l=[];if(a===0){let d={kind:"text",text:`${t} `,fontSize:Va,superscript:true};l.push(d);}for(let d of s.content){let c=d;if(c.type==="run"&&Array.isArray(c.content)){let p=c.formatting,f={};if(p){if(p.bold&&(f.bold=true),p.italic&&(f.italic=true),p.underline&&(f.underline=true),p.strike&&(f.strike=true),p.color){let m=p.color;m.val?f.color=`#${m.val}`:m.rgb&&(f.color=`#${m.rgb}`);}if(p.fontSize&&(f.fontSize=p.fontSize/2),p.fontFamily){let m=p.fontFamily;f.fontFamily=m.ascii||m.hAnsi;}}f.fontSize||(f.fontSize=Va);for(let m of c.content){let b=m;b.type==="text"&&typeof b.text=="string"?l.push({kind:"text",text:b.text,...f}):b.type==="tab"?l.push({kind:"tab",...f}):b.type==="break"?l.push({kind:"lineBreak"}):b.type;}}}l.length===0&&l.push({kind:"text",text:"",fontSize:Va});let u={kind:"paragraph",id:`fn-${e.id}-p${a}`,runs:l};o.push(u);}o.length===0&&o.push({kind:"paragraph",id:`fn-${e.id}-empty`,runs:[{kind:"text",text:"",fontSize:Va}]});let r=[];for(let a of o)if(a.kind==="paragraph"){let s=vn(a,n);r.push(s);}let i=r.reduce((a,s)=>s.kind==="paragraph"?a+s.totalHeight:a,0);return {id:e.id,displayNumber:t,blocks:o,measures:r,height:i}}function _p(e,t,n){let o=new Map,r=new Map;for(let s of e)(s.noteType==="normal"||s.noteType==null)&&r.set(s.id,s);let i=1,a=new Set;for(let s of t){if(a.has(s.footnoteId))continue;a.add(s.footnoteId);let l=r.get(s.footnoteId);if(!l)continue;let u=Tx(l,i,n);o.set(s.footnoteId,u),i++;}return o}function Vp(e,t){let n=new Map;for(let[o,r]of e){let i=0;for(let a of r){let s=t.get(a);s&&(i+=s.height);}i>0&&(i+=kx,n.set(o,i));}return n}var kl=class{constructor(t,n=1){chunkH5NTJZO4_js.d(this,"pagesContainer");chunkH5NTJZO4_js.d(this,"zoom");this.pagesContainer=t,this.zoom=n;}getCoordinatesForPosition(t){let n=this.pagesContainer.getBoundingClientRect(),o=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(o)){let a=i,s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(a.classList.contains("layout-run-tab")){if(t>=s&&t<l){let u=a.getBoundingClientRect(),d=a.closest(".layout-line"),c=d?d.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:c/this.zoom}}continue}if(t>=s&&t<=l&&i.firstChild?.nodeType===Node.TEXT_NODE){let u=i.firstChild,d=Math.min(t-s,u.length),c=a.ownerDocument;if(!c)continue;let p=c.createRange();p.setStart(u,d),p.setEnd(u,d);let f=p.getBoundingClientRect(),m=a.closest(".layout-line"),b=m?m.offsetHeight:16;return {x:(f.left-n.left)/this.zoom,y:(f.top-n.top)/this.zoom,height:b/this.zoom}}}let r=this.pagesContainer.querySelectorAll(".layout-empty-run");for(let i of Array.from(r)){let a=i.closest(".layout-paragraph");if(!a)continue;let s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(t>=s&&t<=l){let u=i.getBoundingClientRect(),d=i.closest(".layout-line"),c=d?d.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:c/this.zoom}}}return null}findElementsForRange(t,n){let o=[],r=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(r)){let a=i,s=Number(a.dataset.pmStart);Number(a.dataset.pmEnd)>t&&s<n&&o.push(a);}return o}getRectsForRange(t,n){let o=this.pagesContainer.getBoundingClientRect(),r=[],i=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let a of Array.from(i)){let s=a,l=Number(s.dataset.pmStart);if(Number(s.dataset.pmEnd)>t&&l<n){if(s.classList.contains("layout-run-tab")){let m=s.getBoundingClientRect();r.push({x:(m.left-o.left)/this.zoom,y:(m.top-o.top)/this.zoom,width:m.width/this.zoom,height:m.height/this.zoom});continue}if(a.firstChild?.nodeType!==Node.TEXT_NODE)continue;let d=a.firstChild,c=s.ownerDocument;if(!c)continue;let p=Math.max(0,t-l),f=Math.min(d.length,n-l);if(p<f){let m=c.createRange();m.setStart(d,p),m.setEnd(d,f);let b=m.getClientRects();for(let g of Array.from(b))r.push({x:(g.left-o.left)/this.zoom,y:(g.top-o.top)/this.zoom,width:g.width/this.zoom,height:g.height/this.zoom});}}}return r}getContainerOffset(){let t=this.pagesContainer.parentElement;if(!t)return {x:0,y:0};let n=this.pagesContainer.getBoundingClientRect(),o=t.getBoundingClientRect();return {x:(n.left-o.left)/this.zoom,y:(n.top-o.top)/this.zoom}}};function Up(e,t=1){return new kl(e,t)}var Ex=816,Yp=1056,Ua={top:96,right:96,bottom:96,left:96},Mx=24,so=30,Px=200,Ix=[],Fx={position:"relative",width:"100%",minHeight:"100%",overflow:"visible",backgroundColor:"var(--doc-bg, #f8f9fa)"},qp=24,Lx={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:qp,paddingBottom:24},Bx={position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},Ax={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function Dx(e,t,n,o,r){let i=new Map;if(!e?.state)return i;let{doc:a,schema:s}=e.state,l=s.marks.comment,u=s.marks.insertion,d=s.marks.deletion;if(!l&&!u&&!d)return i;let c=new Set,p=qp+r;return a.descendants((f,m)=>{if(f.isText)for(let b of f.marks){let g=null;if(l&&b.type===l?g=`comment-${b.attrs.commentId}`:(u&&b.type===u||d&&b.type===d)&&(g=`revision-${b.attrs.revisionId}`),!g||c.has(g))continue;c.add(g);let x=chunkQQ63M65M_js.p(t,n,o,m);if(x){i.set(g,x.y+p);continue}for(let T=0;T<t.pages.length;T++){let S=t.pages[T],B=false;for(let C of S.fragments){let P=C.pmStart??0,_=C.pmEnd??P;if(m<P||m>_)continue;let q=C.kind==="table"?Hx(n,o,C,m):0;i.set(g,C.y+q+chunkQQ63M65M_js.l(t,T)+p),B=true;break}if(B)break}}}),i}function Hx(e,t,n,o){let r=e.findIndex(l=>l.id===n.blockId);if(r===-1)return 0;let i=e[r],a=t[r];if(i.kind!=="table"||a.kind!=="table")return 0;let s=0;for(let l=n.fromRow;l<n.toRow;l++){let u=i.rows[l];if(!u||u.cells.some(c=>c.blocks.some(p=>{let f=p.pmStart??0,m=p.pmEnd??f;return o>=f&&o<=m})))break;s+=a.rows[l]?.height??0;}return s}function pn(e){return Math.round(e/1440*96)}function Nx(e){return {w:e?.pageWidth?pn(e.pageWidth):Ex,h:e?.pageHeight?pn(e.pageHeight):Yp}}function zx(e){let t=e?.marginTop?pn(e.marginTop):Ua.top,n=e?.marginBottom?pn(e.marginBottom):Ua.bottom;return {top:t,right:e?.marginRight?pn(e.marginRight):Ua.right,bottom:n,left:e?.marginLeft?pn(e.marginLeft):Ua.left,header:e?.headerDistance?pn(e.headerDistance):48,footer:e?.footerDistance?pn(e.footerDistance):48}}function Ox(e){let t=e?.columnCount??1;if(t<=1)return;let n=pn(e?.columnSpace??720);return {count:t,gap:n,equalWidth:e?.equalWidth??true,separator:e?.separator}}function $x(e,t,n){function o(l,u){return u.count<=1?l:Math.floor((l-(u.count-1)*u.gap)/u.count)}let r=[],i=[];for(let l=0;l<e.length;l++)if(e[l].kind==="sectionBreak"){r.push(l);let u=e[l];i.push(u.columns??{count:1,gap:0});}i.push(n??{count:1,gap:0});let a=0,s=[];for(let l=0;l<e.length;l++){let u=i[a];s.push(o(t,u)),a<r.length&&l===r[a]&&a++;}return s}function Wx(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function Tl(e){return e===void 0?0:Math.round(e*96/914400)}function _x(e,t,n){if(e){if(t==="pct")return n*e/5e3;if(t==="dxa"||!t||t==="auto")return Math.round(e/20*1.333)}}function Xp(e,t){let i=e.columnWidths??[],a=_x(e.width,e.widthType,t);if(i.length===0&&e.rows.length>0){let c=e.rows[0].cells.reduce((m,b)=>m+(b.colSpan??1),0),f=(a??t)/Math.max(1,c);i=Array(c).fill(f);}else if(i.length>0&&a){let c=i.reduce((p,f)=>p+f,0);if(c>0&&Math.abs(c-a)>1){let p=a/c;i=i.map(f=>f*p);}}let s=new Map;for(let c=0;c<e.rows.length;c++){let p=e.rows[c];if(!p)continue;let f=0,m=s.get(c)??new Set;for(;m.has(f);)f++;for(let b of p.cells){let g=b.colSpan??1,x=b.rowSpan??1;if(x>1)for(let T=c+1;T<c+x;T++){s.has(T)||s.set(T,new Set);let S=s.get(T);for(let B=0;B<g;B++)S.add(f+B);}for(f+=g;m.has(f);)f++;}}let l=e.rows.map((c,p)=>{let f=0,m=s.get(p)??new Set;for(;m.has(f);)f++;return {cells:c.cells.map(b=>{let g=b.colSpan??1,x=0;for(let C=0;C<g&&f+C<i.length;C++)x+=i[f+C]??0;for(x===0&&(x=b.width??100),f+=g;m.has(f);)f++;let T=b.padding?.left??7,S=b.padding?.right??7,B=Math.max(1,x-T-S);return {blocks:b.blocks.map(C=>Zp(C,B)),width:x,height:0,colSpan:b.colSpan,rowSpan:b.rowSpan}}),height:0}});for(let c=0;c<l.length;c++){let p=l[c],f=e.rows[c]?.cells,m=0;for(let T=0;T<p.cells.length;T++){let S=p.cells[T],B=f?.[T];S.height=S.blocks.reduce((_,q)=>"totalHeight"in q?_+q.totalHeight:_,0);let C=B?.padding?.top??1,P=B?.padding?.bottom??1;S.height+=C+P,m=Math.max(m,S.height);}let b=e.rows[c],g=b?.height,x=b?.heightRule;g&&x==="exact"?p.height=g:g&&x==="atLeast"?p.height=Math.max(m,g):p.height=Math.max(m,24);}let u=l.reduce((c,p)=>c+p.height,0),d=i.reduce((c,p)=>c+p,0)||a||t;return {kind:"table",rows:l,columnWidths:i,totalWidth:d,totalHeight:u}}function Vx(e,t){let n=[];for(let o=0;o<e.length;o++){let r=e[o];if(r.kind!=="paragraph")continue;let i=r;for(let a of i.runs){if(a.kind!=="image")continue;let s=a;if(!Wx(s))continue;let l=0,u=s.position,d=s.distTop??0,c=s.distBottom??0,p=s.distLeft??12,f=s.distRight??12;if(u?.vertical){let x=u.vertical;x.align==="top"&&x.relativeTo==="margin"?l=0:x.posOffset!==void 0&&(l=Tl(x.posOffset));}let m=l+s.height,b=0,g=0;if(u?.horizontal){let x=u.horizontal;if(x.align==="left")b=s.width+f;else if(x.align==="right")g=s.width+p;else if(x.posOffset!==void 0){let T=Tl(x.posOffset);T<t/2?b=T+s.width+f:g=t-T+p;}}else s.cssFloat==="left"?b=s.width+f:s.cssFloat==="right"&&(g=s.width+p);if(b>0||g>0){let x=u?.vertical?.relativeTo==="margin"||u?.vertical?.relativeTo==="page";n.push({leftMargin:b,rightMargin:g,topY:l-d,bottomY:m+c,anchorBlockIndex:o,isMarginRelative:x});}}}for(let o=0;o<e.length;o++){let r=e[o];if(r.kind!=="table")continue;let i=r,a=i.floating;if(!a)continue;let s=Xp(i,t),l=s.totalWidth,u=s.totalHeight,d=a.leftFromText??12,c=a.rightFromText??12,p=a.topFromText??0,f=a.bottomFromText??0,m=0,b=0,g=0;a.tblpX!==void 0?g=a.tblpX:a.tblpXSpec?a.tblpXSpec==="left"||a.tblpXSpec==="inside"?g=0:a.tblpXSpec==="right"||a.tblpXSpec==="outside"?g=t-l:a.tblpXSpec==="center"&&(g=(t-l)/2):i.justification==="center"?g=(t-l)/2:i.justification==="right"&&(g=t-l),g<t/2?m=g+l+c:b=t-g+d;let x=a.tblpY??0,T=x+u;n.push({leftMargin:m,rightMargin:b,topY:x-p,bottomY:T+f,anchorBlockIndex:o});}return n}function Zp(e,t,n,o){switch(e.kind){case "paragraph":{let r=e;if(!n||n.length===0){let a=al(r,t);if(a)return a}let i=vn(r,t,{floatingZones:n,paragraphYOffset:o??0});return (!n||n.length===0)&&sl(r,t,i),i}case "table":return Xp(e,t);case "image":{let r=e;return {kind:"image",width:r.width??100,height:r.height??100}}case "textBox":{let r=e,i=r.margins??chunkQQ63M65M_js.c,a=(r.width??chunkQQ63M65M_js.d)-i.left-i.right,s=r.content.map(d=>vn(d,a)),l=s.reduce((d,c)=>d+c.totalHeight,0),u=r.height??l+i.top+i.bottom;return {kind:"textBox",width:r.width??chunkQQ63M65M_js.d,height:u,innerMeasures:s}}case "pageBreak":return {kind:"pageBreak"};case "columnBreak":return {kind:"columnBreak"};case "sectionBreak":return {kind:"sectionBreak"};default:return {kind:"paragraph",lines:[],totalHeight:0}}}function Jp(e,t){let n=Array.isArray(t)?t[0]??0:t,o=Vx(e,n),r=o.filter(p=>p.isMarginRelative),i=o.filter(p=>!p.isMarginRelative),a=new Map;for(let p of r){let f=a.get(p.topY)??[];f.push(p),a.set(p.topY,f);}let s=[...i];for(let p of a.values()){let f=Math.min(...p.map(m=>m.anchorBlockIndex));for(let m of p)s.push({...m,anchorBlockIndex:f});}let l=new Map;for(let p of s){let f=l.get(p.anchorBlockIndex)??[];f.push({leftMargin:p.leftMargin,rightMargin:p.rightMargin,topY:p.topY,bottomY:p.bottomY}),l.set(p.anchorBlockIndex,f);}let u=new Set(s.map(p=>p.anchorBlockIndex)),d=0,c=[];return e.map((p,f)=>{u.has(f)&&(d=0,c=l.get(f)??[]);let m=c.length>0?c:void 0;try{let b=performance.now(),g=Array.isArray(t)?t[f]??n:t,x=Zp(p,g,m,d),T=performance.now()-b;return T>500&&console.warn(`[measureBlocks] Block ${f} (${p.kind}) took ${Math.round(T)}ms`),"totalHeight"in x&&(p.kind==="table"&&p.floating||(d+=x.totalHeight)),x}catch(b){return console.error(`[measureBlocks] Error measuring block ${f} (${p.kind}):`,b),{totalHeight:20}}})}function ja(e){let t=[];for(let n of e){let o=n;if(o.type==="run"&&Array.isArray(o.content)){let r=o.formatting,i={};if(r){if(r.bold&&(i.bold=true),r.italic&&(i.italic=true),r.underline&&(i.underline=true),r.strike&&(i.strike=true),r.color){let a=r.color;a.val?i.color=`#${a.val}`:a.rgb&&(i.color=`#${a.rgb}`);}if(r.fontSize&&(i.fontSize=r.fontSize/2),r.fontFamily){let a=r.fontFamily;i.fontFamily=a.ascii||a.hAnsi;}}for(let a of o.content){let s=a;if(s.type==="text"&&typeof s.text=="string")t.push({kind:"text",text:s.text,...i});else if(s.type==="tab")t.push({kind:"tab",...i});else if(s.type==="break")t.push({kind:"lineBreak"});else if(s.type==="drawing"&&s.image){let l=s.image,u=l.size,d=m=>Math.round(m/914400*96),c=u?.width?d(u.width):100,p=u?.height?d(u.height):100,f=l.position;t.push({kind:"image",src:l.src||"",width:c,height:p,alt:l.alt||void 0,position:f?{horizontal:f.horizontal,vertical:f.vertical}:void 0});}}}if(o.type==="simpleField"){let r=o.fieldType,i={};if(Array.isArray(o.content)&&o.content.length>0){let a=o.content[0];if(a?.type==="run"&&a.formatting){let s=a.formatting;if(s.fontSize&&(i.fontSize=s.fontSize/2),s.fontFamily){let l=s.fontFamily;i.fontFamily=l.ascii||l.hAnsi;}if(s.bold&&(i.bold=true),s.italic&&(i.italic=true),s.color){let l=s.color,u=l.rgb||l.val;u&&(i.color=u.startsWith("#")?u:`#${u}`);}}}if(r==="PAGE")t.push({kind:"field",fieldType:"PAGE",fallback:"1",...i});else if(r==="NUMPAGES")t.push({kind:"field",fieldType:"NUMPAGES",fallback:"1",...i});else if(Array.isArray(o.content)){let a=ja(o.content);t.push(...a);}continue}if(o.type==="complexField"){let r=o.fieldType,i={};if(Array.isArray(o.fieldResult)&&o.fieldResult.length>0){let a=o.fieldResult[0];if(a?.type==="run"&&a.formatting){let s=a.formatting;if(s.fontSize&&(i.fontSize=s.fontSize/2),s.fontFamily){let l=s.fontFamily;i.fontFamily=l.ascii||l.hAnsi;}if(s.bold&&(i.bold=true),s.italic&&(i.italic=true),s.color){let l=s.color,u=l.rgb||l.val;u&&(i.color=u.startsWith("#")?u:`#${u}`);}}}if(r==="PAGE")t.push({kind:"field",fieldType:"PAGE",fallback:"1",...i});else if(r==="NUMPAGES")t.push({kind:"field",fieldType:"NUMPAGES",fallback:"1",...i});else if(Array.isArray(o.fieldResult)){let a=ja(o.fieldResult);t.push(...a);}}if(o.type==="hyperlink"&&Array.isArray(o.children)){let r=ja(o.children);t.push(...r);}}return t}function Ux(e){return e?.align??e?.alignment}function jx(e,t,n,o){let r=o.section==="header"?o.margins.header??48:o.pageSize.h-(o.margins.footer??48)-n,i=e.position?.vertical;if(!i)return t;let a=Ux(i),s=i.posOffset!==void 0?Tl(i.posOffset):void 0;if(i.relativeTo==="page"){if(s!==void 0)return s-r;if(a==="top")return -r;if(a==="bottom")return o.pageSize.h-e.height-r;if(a==="center")return (o.pageSize.h-e.height)/2-r}if(i.relativeTo==="margin"){let l=o.margins.top,u=o.pageSize.h-o.margins.top-o.margins.bottom;if(s!==void 0)return l+s-r;if(a==="top")return l-r;if(a==="bottom")return l+u-e.height-r;if(a==="center")return l+(u-e.height)/2-r}return s!==void 0?t+s:t}function Gx(e,t,n,o){let r=0,i=n,a=0;for(let s=0;s<e.length;s++){let l=e[s],u=t[s];if(l?.kind!=="paragraph"||u?.kind!=="paragraph")continue;let d=l,c=a,p=c+u.totalHeight;r=Math.min(r,c),i=Math.max(i,p);for(let f of d.runs){if(f.kind!=="image"||!f.position)continue;let m=f,b=jx(m,c,n,o);r=Math.min(r,b),i=Math.max(i,b+m.height);}a=p;}return {visualTop:r,visualBottom:i}}function Gp(e,t,n){if(!e||!e.content||e.content.length===0)return;let o=[];for(let u of e.content){let d=u;if(d.type==="paragraph"&&Array.isArray(d.content)){let c=d.formatting,p={};if(c){if(c.alignment){let m=c.alignment;m==="both"?p.alignment="justify":["left","center","right","justify"].includes(m)&&(p.alignment=m);}if(c.borders){let m=c.borders,b={};for(let g of ["top","bottom","left","right","between"]){let x=m[g];if(x){let T=va(x);T&&(b[g]=T);}}Object.keys(b).length>0&&(p.borders=b);}(c.spaceAfter!=null||c.spaceBefore!=null)&&(p.spacing={before:c.spaceBefore,after:c.spaceAfter}),Array.isArray(c.tabs)&&c.tabs.length>0&&(p.tabs=c.tabs.map(m=>({val:m.alignment==="left"?"start":m.alignment==="right"?"end":m.alignment,pos:m.position,leader:m.leader})));}let f=ja(d.content);if(f.length>0){let m={kind:"paragraph",id:String(o.length),runs:f,attrs:Object.keys(p).length>0?p:void 0};o.push(m);}}}if(o.length===0)return;let r=o.map(u=>{if(u.kind!=="paragraph")return u;let d=u;if(!d.runs.some(f=>f.kind==="image"&&"position"in f&&f.position))return u;let p=d.runs.filter(f=>!(f.kind==="image"&&"position"in f&&f.position));return p.length===0&&p.push({kind:"text",text:""}),{...d,runs:p}}),i=Jp(r,t),a=i.reduce((u,d)=>d.kind==="paragraph"?u+d.totalHeight:u,0),{visualTop:s,visualBottom:l}=Gx(o,i,a,n);return {blocks:o,measures:i,height:a,visualTop:s,visualBottom:l}}function Kx(e,t,n){let o=new Map;if(!n?.package?.footnotes)return o;let r=new Map;for(let i of n.package.footnotes)i.noteType&&i.noteType!=="normal"||r.set(i.id,i);for(let[i,a]of e){let s=[];for(let l of a){let u=r.get(l);if(!u)continue;let c=t.get(l)?.displayNumber??0,p=chunkVR6PT4IZ_js.b(u);s.push({displayNumber:String(c),text:p});}s.length>0&&o.set(i,s);}return o}var Yx=rf.forwardRef(function(t,n){let{document:o,styles:r,theme:i,sectionProperties:a,headerContent:s,footerContent:l,readOnly:u=false,pageGap:d=Mx,zoom:c=1,onDocumentChange:p,onSelectionChange:f,externalPlugins:m=Ix,extensionManager:b,onReady:g,onRenderedDomContextReady:x,pluginOverlays:T,onHeaderFooterDoubleClick:S,hfEditMode:B,onBodyClick:C,className:P,style:_,commentsSidebarOpen:q=false,sidebarOverlay:z,scrollContainerRef:H,onHyperlinkClick:ee,onContextMenu:ue,onAnchorPositionsChange:A}=t,O=rf.useCallback(()=>H&&typeof H=="object"?H.current:ie.current,[H]),ie=rf.useRef(null),ae=rf.useRef(null),N=rf.useRef(null),Ie=rf.useRef(null),{handlePMKeyDown:Fe}=Op({pagesContainerRef:ae}),Ve=rf.useRef(()=>{}),M=rf.useRef(f),F=rf.useRef(p),k=rf.useRef(g),L=rf.useRef(x);M.current=f,F.current=p,k.current=g,L.current=x;let[I,E]=rf.useState(null),[Z,le]=rf.useState([]),[$,Y]=rf.useState([]),[ne,fe]=rf.useState(false),[Te,v]=rf.useState([]),[U,D]=rf.useState(null),[me,ge]=rf.useState(null),he=rf.useRef(false),De=rf.useCallback((w,W)=>{let G=w.tagName==="IMG"?w:w.querySelector("img"),K=(G??w).getBoundingClientRect();return {element:G??w,pmPos:W,width:Math.round(K.width/c),height:Math.round(K.height/c)}},[c]),be=rf.useRef(false),pe=rf.useRef(null),_e=rf.useRef(false),Ke=rf.useRef(0),Ue=rf.useRef(0),tt=rf.useRef(0),Ye=rf.useRef({left:0,right:0}),it=rf.useRef(null),vt=rf.useRef(false),Ne=rf.useRef(0),xt=rf.useRef(0),ze=rf.useRef(0),ht=rf.useRef(0),Wt=rf.useRef(null),Xa=rf.useRef(false),on=rf.useRef(false),er=rf.useRef(0),Ur=rf.useRef(0),zn=rf.useRef(0),Fo=rf.useRef(0),ct=rf.useRef(null),qt=rf.useRef(false),Pt=rf.useRef(null),St=rf.useRef(null),_t=rf.useRef(null),gn=5,[It,ce]=rf.useState(null),Xt=rf.useRef(null),On=rf.useCallback(()=>{Xt.current&&(clearTimeout(Xt.current),Xt.current=null);},[]);rf.useEffect(()=>()=>{Xt.current&&clearTimeout(Xt.current);},[]);let Zt=rf.useMemo(()=>new za,[]),hn=rf.useMemo(()=>Nx(a),[a]),Le=rf.useMemo(()=>zx(a),[a]),Dt=rf.useMemo(()=>Ox(a),[a]),Vt=hn.w-Le.left-Le.right,rn=rf.useMemo(()=>new Na({pageGap:d,showShadow:true,pageBackground:"#fff"}),[d]);Ie.current=rn;let Ht=rf.useCallback(w=>{let W=performance.now(),G=Zt.getStateSeq();Zt.onLayoutStart();try{let K=performance.now(),oe=hn.h-Le.top-Le.bottom,j=dp(w.doc,{theme:i,pageContentHeight:oe}),Q=performance.now()-K;Q>500&&console.warn(`[PagedEditor] toFlowBlocks took ${Math.round(Q)}ms (${j.length} blocks)`),le(j),K=performance.now();let re=$x(j,Vt,Dt),de=Jp(j,re);Q=performance.now()-K,Q>1e3&&console.warn(`[PagedEditor] measureBlocks took ${Math.round(Q)}ms (${j.length} blocks)`),Y(de);let Se=Wp(j),xe=Se.length>0&&o?.package?.footnotes,we=Gp(s,Vt,{section:"header",pageSize:hn,margins:Le}),Ee=Gp(l,Vt,{section:"footer",pageSize:hn,margins:Le}),ve=Le.header??48,Ae=Le.footer??48,je=Le.top-ve,dt=Le.bottom-Ae,ut=we?.visualBottom??we?.height??0,Qt=Ee?Math.max((Ee.visualBottom??Ee.height)-(Ee.visualTop??0),Ee.height):0,Wn=Le;if(ut>je||Qt>dt){Wn={...Le};let Gt=8;ut>je&&(Wn.top=Math.max(Le.top,ve+ut+Gt)),Qt>dt&&(Wn.bottom=Math.max(Le.bottom,Ae+Qt+Gt));}K=performance.now();let en,ho=new Map,sr=new Map,es=a?.sectionStart,lr={pageSize:hn,margins:Wn,columns:Dt,bodyBreakType:es,pageGap:d};if(xe){let Gt=chunkQQ63M65M_js.e(j,de,lr);ho=Sl(Gt.pages,Se),sr=_p(o.package.footnotes,Se,Vt);let bo=Vp(ho,sr);if(bo.size>0){en=chunkQQ63M65M_js.e(j,de,{...lr,footnoteReservedHeights:bo}),ho=Sl(en.pages,Se);for(let[bn,yo]of ho){let _n=en.pages.find(qr=>qr.number===bn);_n&&(_n.footnoteIds=yo);}}else en=Gt;}else en=chunkQQ63M65M_js.e(j,de,lr);if(Q=performance.now()-K,Q>500&&console.warn(`[PagedEditor] layoutDocument took ${Math.round(Q)}ms (${en.pages.length} pages)`),E(en),ae.current&&Ie.current){K=performance.now();let Gt=new Map;for(let bn=0;bn<j.length;bn++){let yo=j[bn],_n=de[bn];yo&&_n&&Gt.set(String(yo.id),{block:yo,measure:_n});}Ie.current.setBlockLookup(Gt);let bo=xe?Kx(ho,sr,o):void 0;if(yl(en.pages,ae.current,{pageGap:d,showShadow:!0,pageBackground:"#fff",blockLookup:Gt,headerContent:we,footerContent:Ee,headerDistance:a?.headerDistance?pn(a.headerDistance):void 0,footerDistance:a?.footerDistance?pn(a.footerDistance):void 0,pageBorders:a?.pageBorders,theme:i,footnotesByPage:bo?.size?bo:void 0}),Q=performance.now()-K,Q>500&&console.warn(`[PagedEditor] renderPages took ${Math.round(Q)}ms`),x){let bn=Up(ae.current,c);x(bn);}}if(A){let Gt=Dx(N.current?.getView()??null,en,j,de,d);A(Gt);}let Yr=performance.now()-W;Yr>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(Yr)}ms total (${j.length} blocks, ${de.length} measures)`);}catch(K){console.error("[PagedEditor] Layout pipeline error:",K);}Zt.onLayoutComplete(G);},[Vt,Dt,hn,Le,d,c,Zt,s,l,a,x,o]),an=rf.useRef(null),po=rf.useCallback(w=>{if(an.current){an.current.state=w;return}let W=requestAnimationFrame(()=>{let G=an.current;an.current=null,G&&Ht(G.state);});an.current={rafId:W,state:w};},[Ht]);rf.useEffect(()=>()=>{an.current&&(cancelAnimationFrame(an.current.rafId),an.current=null);},[]);let En=rf.useCallback((w,W=1)=>{if(!ae.current)return null;let G=ae.current.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!G)return null;let K=G.getBoundingClientRect(),oe=ae.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let Q of Array.from(oe)){let re=Q,de=Number(re.dataset.pmStart),Se=Number(re.dataset.pmEnd);if(re.classList.contains("layout-run-tab")){if(w>=de&&w<Se){let xe=re.getBoundingClientRect(),we=re.closest(".layout-page"),Ee=we?Number(we.dataset.pageNumber)-1:0,ve=re.closest(".layout-line"),Ae=ve?ve.offsetHeight:16;return {x:(xe.left-K.left)/W,y:(xe.top-K.top)/W,height:Ae,pageIndex:Ee}}continue}if(w>=de&&w<=Se&&Q.firstChild?.nodeType===Node.TEXT_NODE){let xe=Q.firstChild,we=Math.min(w-de,xe.length),Ee=re.ownerDocument;if(!Ee)continue;let ve=Ee.createRange();ve.setStart(xe,we),ve.setEnd(xe,we);let Ae=ve.getBoundingClientRect(),je=re.closest(".layout-page"),dt=je?Number(je.dataset.pageNumber)-1:0,ut=re.closest(".layout-line"),Qt=ut?ut.offsetHeight:16;return {x:(Ae.left-K.left)/W,y:(Ae.top-K.top)/W,height:Qt,pageIndex:dt}}}let j=ae.current.querySelectorAll(".layout-empty-run");for(let Q of Array.from(j)){let re=Q.closest(".layout-paragraph");if(!re)continue;let de=Number(re.dataset.pmStart),Se=Number(re.dataset.pmEnd);if(w>=de&&w<=Se){let xe=Q.getBoundingClientRect(),we=re.closest(".layout-page"),Ee=we?Number(we.dataset.pageNumber)-1:0,ve=Q.closest(".layout-line"),Ae=ve?ve.offsetHeight:16;return {x:(xe.left-K.left)/W,y:(xe.top-K.top)/W,height:Ae,pageIndex:Ee}}}return null},[]),Ut=rf.useCallback(w=>{let{from:W,to:G}=w.selection;if(M.current?.(W,G),ae.current){let K=ae.current.querySelectorAll(".layout-table-cell-selected");for(let Q of Array.from(K))Q.classList.remove("layout-table-cell-selected");let oe=w.selection;if("$anchorCell"in oe&&typeof oe.forEachCell=="function"){let Q=[];oe.forEachCell((de,Se)=>{Q.push([Se,Se+de.nodeSize]);});let re=ae.current.querySelectorAll(".layout-table-cell");for(let de of Array.from(re)){let Se=de,xe=Se.dataset.pmStart;if(xe!==void 0){let we=Number(xe);for(let[Ee,ve]of Q)if(we>=Ee&&we<ve){Se.classList.add("layout-table-cell-selected");break}}}}}if(!(!I||Z.length===0))if(W===G){let K=En(W,c);if(K)D(K);else {let oe=ae.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),j=ae.current?.querySelector(".layout-page");if(oe&&j){let Q=oe.getBoundingClientRect(),re=j.getBoundingClientRect(),de=chunkQQ63M65M_js.p(I,Z,$,W);D(de?{...de,x:de.x+(re.left-Q.left)/c,y:de.y+(re.top-Q.top)/c}:null);}else D(null);}v([]);}else {let K=ae.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(K&&ae.current){let oe=K.getBoundingClientRect(),j=[],Q=ae.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let re of Array.from(Q)){let de=re,Se=Number(de.dataset.pmStart);if(Number(de.dataset.pmEnd)>W&&Se<G){if(de.classList.contains("layout-run-tab")){let je=de.getBoundingClientRect(),dt=de.closest(".layout-page"),ut=dt?Number(dt.dataset.pageNumber)-1:0;j.push({x:(je.left-oe.left)/c,y:(je.top-oe.top)/c,width:je.width/c,height:je.height/c,pageIndex:ut});continue}let we=null;if(re.firstChild?.nodeType===Node.TEXT_NODE?we=re.firstChild:re.firstChild?.nodeType===Node.ELEMENT_NODE&&re.firstChild.tagName==="A"&&re.firstChild.firstChild?.nodeType===Node.TEXT_NODE&&(we=re.firstChild.firstChild),!we)continue;let Ee=de.ownerDocument;if(!Ee)continue;let ve=Math.max(0,W-Se),Ae=Math.min(we.length,G-Se);if(ve<Ae){let je=Ee.createRange();je.setStart(we,ve),je.setEnd(we,Ae);let dt=je.getClientRects();for(let ut of Array.from(dt)){let Qt=de.closest(".layout-page"),Wn=Qt?Number(Qt.dataset.pageNumber)-1:0;j.push({x:(ut.left-oe.left)/c,y:(ut.top-oe.top)/c,width:ut.width/c,height:ut.height/c,pageIndex:Wn});}}}}if(j.length>0)v(j);else {let re=ae.current.querySelector(".layout-page");if(re){let de=re.getBoundingClientRect(),Se=(de.left-oe.left)/c,xe=(de.top-oe.top)/c,Ee=chunkQQ63M65M_js.o(I,Z,$,W,G).map(ve=>({...ve,x:ve.x+Se,y:ve.y+xe}));v(Ee);}else v([]);}}else v([]);D(null);}},[I,Z,$,En,c]),fo=rf.useCallback((w,W)=>{if(w.docChanged){Zt.incrementStateSeq(),po(W);let G=N.current?.getDocument();G&&F.current?.(G);}Zt.requestRender(),w.docChanged||Ut(W);},[po,Ut,Zt]),jr=rf.useCallback(w=>{let{selection:W}=w;W instanceof prosemirrorState.NodeSelection&&W.node.type.name==="image"?(v([]),D(null)):Zt.isSafeToRender()&&Ut(w),requestAnimationFrame(()=>{let G=N.current?.getView();if(!G){ge(null);return}let{selection:K}=G.state;if(K instanceof prosemirrorState.NodeSelection&&K.node.type.name==="image"){let oe=K.from,j=ae.current?.querySelector(`[data-pm-start="${oe}"]`);if(j){ge(De(j,oe));return}}he.current||ge(null);});},[Ut,c,De,Zt]),Mt=rf.useCallback((w,W)=>{if(!ae.current||!I)return null;let G=kp(ae.current,w,W,c);if(G!==null)return G;let K=ae.current.querySelectorAll(".layout-page"),oe=-1,j=null;for(let we=0;we<K.length;we++){let ve=K[we].getBoundingClientRect();if(w>=ve.left&&w<=ve.right&&W>=ve.top&&W<=ve.bottom){oe=we,j=ve;break}}if(oe<0||!j)return null;let Q=(w-j.left)/c,re=(W-j.top)/c,de=I.pages[oe];if(!de)return null;let Se={pageIndex:oe,page:de,pageY:re},xe=chunkQQ63M65M_js.m(Se,Z,$,{x:Q,y:re});if(!xe)return null;if(xe.fragment.kind==="table"){let we=chunkQQ63M65M_js.n(Se,Z,$,{x:Q,y:re});return cl(xe,we)}return cl(xe)},[I,Z,$,c]),sn=rf.useCallback(w=>{let W=N.current?.getView();if(!W)return null;try{let G=W.state.doc.resolve(w);for(let K=G.depth;K>0;K--){let oe=G.node(K);if(oe.type.name==="tableCell"||oe.type.name==="tableHeader")return G.before(K)}}catch{}return null},[]),Ft=rf.useCallback(w=>{let W=["layout-block-image","layout-image","layout-page-floating-image"],G=K=>!!K.dataset.pmStart&&W.some(oe=>K.classList.contains(oe));return w.tagName==="IMG"&&w.classList.contains("layout-run-image")?w:w.tagName==="IMG"&&w.parentElement&&G(w.parentElement)?w.parentElement:G(w)?w:null},[]),mo=rf.useCallback(w=>{let W=ae.current;if(!W)return;let G=W.querySelector(`[data-pm-start="${w}"]`);G&&G.scrollIntoView({behavior:"smooth",block:"center"});},[]),tr=rf.useCallback(w=>{if(!N.current)return;if(w.button===2){w.preventDefault();return}if(w.button!==0||(ce(null),On(),w.target.closest("a[href]")&&w.preventDefault(),u))return;if(B&&C){let j=w.target;if(!(j.closest(".layout-page-header")||j.closest(".layout-page-footer")||j.closest(".hf-inline-editor"))){w.preventDefault(),w.stopPropagation(),C();return}}if(!B){let j=w.target;if(j.closest(".layout-page-header")||j.closest(".layout-page-footer")){w.preventDefault(),N.current&&(N.current.setSelection(0),N.current.focus(),fe(true));return}}let G=w.target;if(G.classList.contains("layout-table-resize-handle")){w.preventDefault(),w.stopPropagation(),_e.current=true,Ke.current=w.clientX,it.current=G,G.classList.add("dragging");let j=parseInt(G.dataset.columnIndex??"0",10);Ue.current=j,tt.current=parseInt(G.dataset.tablePmStart??"0",10);let Q=N.current.getView();if(Q){let re=Q.state.doc.resolve(tt.current+1);for(let de=re.depth;de>=0;de--){let Se=re.node(de);if(Se.type.name==="table"){let xe=Se.attrs.columnWidths;xe&&xe[j]!==void 0&&xe[j+1]!==void 0&&(Ye.current={left:xe[j],right:xe[j+1]});break}}}return}if(G.classList.contains("layout-table-row-resize-handle")||G.classList.contains("layout-table-edge-handle-bottom")){w.preventDefault(),w.stopPropagation(),vt.current=true,Ne.current=w.clientY,Wt.current=G,Xa.current=G.dataset.isEdge==="bottom",G.classList.add("dragging");let j=parseInt(G.dataset.rowIndex??"0",10);xt.current=j,ze.current=parseInt(G.dataset.tablePmStart??"0",10);let Q=N.current.getView();if(Q){let re=Q.state.doc.resolve(ze.current+1);for(let de=re.depth;de>=0;de--){let Se=re.node(de);if(Se.type.name==="table"){let xe=null,we=0;if(Se.forEach(Ee=>{we===j&&(xe=Ee),we++;}),xe){let Ee=xe.attrs.height;if(Ee)ht.current=Ee;else {let Ae=G.closest(".layout-table")?.querySelector(`[data-row-index="${j}"]`),je=Ae?Ae.getBoundingClientRect().height:30;ht.current=Math.round(je*15);}}break}}}return}if(G.classList.contains("layout-table-edge-handle-right")){w.preventDefault(),w.stopPropagation(),on.current=true,er.current=w.clientX,ct.current=G,G.classList.add("dragging");let j=parseInt(G.dataset.columnIndex??"0",10);Ur.current=j,zn.current=parseInt(G.dataset.tablePmStart??"0",10);let Q=N.current.getView();if(Q){let re=Q.state.doc.resolve(zn.current+1);for(let de=re.depth;de>=0;de--){let Se=re.node(de);if(Se.type.name==="table"){let xe=Se.attrs.columnWidths;xe&&xe[j]!==void 0&&(Fo.current=xe[j]);break}}}return}let K=Ft(G);if(K){w.preventDefault(),w.stopPropagation();let j=K.dataset.pmStart;if(j!==void 0){let Q=parseInt(j,10);N.current.setNodeSelection(Q),ge(De(K,Q)),v([]),D(null);}N.current.focus(),fe(true);return}ge(null),w.preventDefault();let oe=Mt(w.clientX,w.clientY);if(oe!==null){let j=sn(oe);Pt.current=j,qt.current=false,St.current=null,_t.current=null,be.current=true,pe.current=oe,N.current.setSelection(oe);}else {Pt.current=null,qt.current=false;let j=N.current.getView();if(j){let Q=Math.max(0,j.state.doc.content.size-1);N.current.setSelection(Q),pe.current=Q,be.current=true;}}N.current.focus(),fe(true);},[Mt,sn,u,B,C,c,ee,On]),Mn=rf.useCallback((w,W)=>{Ve.current(w,W);},[]),{updateMousePosition:nr,stopAutoScroll:$n}=$p({pagesContainerRef:ae,onScrollExtendSelection:Mn});Ve.current=(w,W)=>{if(!be.current||pe.current===null||!N.current)return;let G=Mt(w,W);G!==null&&N.current.setSelection(pe.current,G);};let or=rf.useCallback(w=>{if(_e.current){w.preventDefault();let K=w.clientX-Ke.current;if(it.current){let oe=parseFloat(it.current.style.left);it.current.style.left=`${oe+K}px`,Ke.current=w.clientX;let j=Math.round(K*15),Q=300,re=Ye.current.left+j,de=Ye.current.right-j;re>=Q&&de>=Q&&(Ye.current={left:re,right:de});}return}if(vt.current){w.preventDefault();let K=w.clientY-Ne.current;if(Wt.current){let oe=parseFloat(Wt.current.style.top);Wt.current.style.top=`${oe+K}px`,Ne.current=w.clientY;let j=Math.round(K*15),Q=200,re=ht.current+j;re>=Q&&(ht.current=re);}return}if(on.current){w.preventDefault();let K=w.clientX-er.current;if(ct.current){let oe=parseFloat(ct.current.style.left);ct.current.style.left=`${oe+K}px`,er.current=w.clientX;let j=Math.round(K*15),Q=300,re=Fo.current+j;re>=Q&&(Fo.current=re);}return}if(!be.current||pe.current===null||!N.current||!ae.current)return;nr(w.clientX,w.clientY);let W=Mt(w.clientX,w.clientY);if(W===null)return;if(Pt.current!==null){if(qt.current){let oe=sn(W);if(oe!==null){N.current.setCellSelection(Pt.current,oe);return}}let K=sn(W);if(K!==null&&K!==Pt.current){qt.current=true,N.current.setCellSelection(Pt.current,K),_t.current=null;return}if(St.current!==null&&W===St.current){if(_t.current===null)_t.current=w.clientX;else if(Math.abs(w.clientX-_t.current)>=gn){qt.current=true,N.current.setCellSelection(Pt.current,Pt.current),_t.current=null;return}}else _t.current=null,St.current=W;}let G=pe.current;N.current.setSelection(G,W);},[Mt,sn,nr]),Be=rf.useCallback(()=>{if(_e.current){_e.current=false,it.current&&(it.current.classList.remove("dragging"),it.current=null);let w=N.current?.getView();if(w){let W=tt.current,G=Ue.current,{left:K,right:oe}=Ye.current,j=w.state.doc.resolve(W+1);for(let Q=j.depth;Q>=0;Q--){let re=j.node(Q);if(re.type.name==="table"){let de=j.before(Q),Se=w.state.tr,xe=[...re.attrs.columnWidths];xe[G]=K,xe[G+1]=oe,Se.setNodeMarkup(de,void 0,{...re.attrs,columnWidths:xe});let we=de+1;re.forEach(Ee=>{let ve=we+1,Ae=0;Ee.forEach(je=>{let dt=je.attrs.colspan||1;if(Ae===G||Ae===G+1){let ut=Ae===G?K:oe;Se.setNodeMarkup(Se.mapping.map(ve),void 0,{...je.attrs,width:ut,widthType:"dxa",colwidth:null});}ve+=je.nodeSize,Ae+=dt;}),we+=Ee.nodeSize;}),w.dispatch(Se);break}}}return}if(vt.current){vt.current=false,Wt.current&&(Wt.current.classList.remove("dragging"),Wt.current=null);let w=N.current?.getView();if(w){let W=ze.current,G=xt.current,K=ht.current,oe=w.state.doc.resolve(W+1);for(let j=oe.depth;j>=0;j--){let Q=oe.node(j);if(Q.type.name==="table"){let re=oe.before(j),de=w.state.tr,Se=re+1,xe=0;Q.forEach(we=>{xe===G&&de.setNodeMarkup(de.mapping.map(Se),void 0,{...we.attrs,height:K,heightRule:"atLeast"}),Se+=we.nodeSize,xe++;}),w.dispatch(de);break}}}return}if(on.current){on.current=false,ct.current&&(ct.current.classList.remove("dragging"),ct.current=null);let w=N.current?.getView();if(w){let W=zn.current,G=Ur.current,K=Fo.current,oe=w.state.doc.resolve(W+1);for(let j=oe.depth;j>=0;j--){let Q=oe.node(j);if(Q.type.name==="table"){let re=oe.before(j),de=w.state.tr,Se=[...Q.attrs.columnWidths];Se[G]=K,de.setNodeMarkup(re,void 0,{...Q.attrs,columnWidths:Se});let xe=re+1;Q.forEach(we=>{let Ee=xe+1,ve=0;we.forEach(Ae=>{let je=Ae.attrs.colspan||1;ve===G&&de.setNodeMarkup(de.mapping.map(Ee),void 0,{...Ae.attrs,width:K,widthType:"dxa",colwidth:null}),Ee+=Ae.nodeSize,ve+=je;}),xe+=we.nodeSize;}),w.dispatch(de);break}}}return}be.current=false,qt.current=false,St.current=null,_t.current=null,$n();},[$n]);rf.useEffect(()=>(window.addEventListener("mousemove",or),window.addEventListener("mouseup",Be),()=>{window.removeEventListener("mousemove",or),window.removeEventListener("mouseup",Be);}),[or,Be]);let Ze=rf.useCallback(w=>{if(u||be.current||_e.current||vt.current||on.current||qt.current)return;let W=ae.current;if(!W)return;let G=w.clientX,K=w.clientY,oe=w.target.closest(".layout-table");if(!oe){let Ee=W.querySelectorAll(".layout-table");for(let ve of Array.from(Ee)){let Ae=ve.getBoundingClientRect(),je=G>=Ae.left-so&&G<Ae.left,dt=K>=Ae.top-so&&K<Ae.top,ut=G>=Ae.left-so&&G<=Ae.right,Qt=K>=Ae.top-so&&K<=Ae.bottom;if(je&&Qt||dt&&ut){oe=ve;break}}}if(!oe){ce(null);return}let j=oe.getBoundingClientRect(),Q=G<j.left+so&&G>=j.left-so,re=K<j.top+so&&K>=j.top-so;if(!Q&&!re){ce(null);return}let de=oe.querySelectorAll(":scope > .layout-table-row");if(de.length===0){ce(null);return}let Se=W.parentElement;if(!Se)return;let xe=Se.getBoundingClientRect(),we=Ee=>Ee&&Number(Ee.dataset.pmStart)||0;if(Q)for(let Ee=0;Ee<de.length;Ee++){let ve=de[Ee].getBoundingClientRect();if(K>=ve.top&&K<=ve.bottom){let Ae=de[Ee].querySelector(".layout-table-cell"),je=we(Ae);if(!je)break;let dt=ve.top+ve.height/2;ce({type:"row",x:j.left-xe.left-24,y:dt-xe.top-10,cellPmPos:je}),On();return}}if(re){let Ee=de[0].querySelectorAll(":scope > .layout-table-cell");for(let ve=0;ve<Ee.length;ve++){let Ae=Ee[ve].getBoundingClientRect();if(G>=Ae.left&&G<=Ae.right){let je=we(Ee[ve]);if(!je)break;let dt=Ae.left+Ae.width/2;ce({type:"column",x:dt-xe.left-10,y:j.top-xe.top-24,cellPmPos:je}),On();return}}}Xt.current||(Xt.current=setTimeout(()=>{ce(null),Xt.current=null;},Px));},[u,On]),Za=rf.useCallback(w=>{if(w.preventDefault(),w.stopPropagation(),!It||!N.current)return;let W=N.current.getView();if(!W)return;let{type:G,cellPmPos:K}=It,oe=W.state.tr.setSelection(prosemirrorState.TextSelection.create(W.state.doc,K+1));W.dispatch(oe),G==="row"?wo(W.state,W.dispatch):Co(W.state,W.dispatch),ce(null),N.current.focus();},[It]),Ja=rf.useCallback(w=>{let W=w.target.closest("a[href]");if(W){w.preventDefault();let G=W.getAttribute("href")||"";if(G.startsWith("#")){let K=G.substring(1);if(K&&N.current){let oe=N.current.getView();if(oe){let j=null;oe.state.doc.descendants((Q,re)=>{if(j!==null)return false;if(Q.type.name==="paragraph"&&Q.attrs.bookmarks?.some(Se=>Se.name===K))return j=re,false}),j!==null&&(mo(j),N.current.setSelection(j+1));}}}else if(ee){let K=N.current?.getView();if(!(K&&K.state.selection.from!==K.state.selection.to)){let j=W.textContent||"",Q=W.getAttribute("title")||void 0,re=W.getBoundingClientRect();ee({href:G,displayText:j,tooltip:Q,anchorRect:re});}}return}if(w.detail===2&&S){let G=w.target,K=G.closest(".layout-page-header"),oe=G.closest(".layout-page-footer");if(K){w.preventDefault(),w.stopPropagation(),S("header");return}if(oe){w.preventDefault(),w.stopPropagation(),S("footer");return}}if(w.detail===2&&N.current){let G=Mt(w.clientX,w.clientY);if(G!==null){let K=sn(G);if(K!==null){w.preventDefault(),w.stopPropagation(),N.current.setCellSelection(K,K);return}let oe=N.current.getView();if(oe){let{doc:j}=oe.state,Q=j.resolve(G),re=Q.parent;if(re.isTextblock){let de=re.textContent,Se=Q.parentOffset,xe=Se;for(;xe>0&&/\w/.test(de[xe-1]);)xe--;let we=Se;for(;we<de.length&&/\w/.test(de[we]);)we++;let Ee=Q.start()+xe,ve=Q.start()+we;Ee<ve&&N.current.setSelection(Ee,ve);}}}}if(w.detail===3&&N.current){let G=Mt(w.clientX,w.clientY);if(G!==null){let K=N.current.getView();if(K){let{doc:oe}=K.state,j=oe.resolve(G),Q=j.start(j.depth),re=j.end(j.depth);N.current.setSelection(Q,re);}}}},[Mt,S,ee]),bt=rf.useCallback(w=>{if(!ue)return;w.preventDefault();let W=N.current?.getView();if(!W)return;let{from:G,to:K}=W.state.selection,oe=Mt(w.clientX,w.clientY);oe!==null&&(G===K||oe<G||oe>K)&&(N.current?.setSelection(oe),N.current?.focus(),fe(true));let j=N.current?.getState(),Q=j?j.selection.from!==j.selection.to:false;ue({x:w.clientX,y:w.clientY,hasSelection:Q});},[ue,Mt]),kt=rf.useCallback(w=>{u||w.target.closest(".docx-comments-sidebar")||(N.current?.focus(),fe(true));},[u]),Gr=rf.useCallback(w=>{let W=w.relatedTarget;W&&ie.current?.contains(W)||W?.closest('[role="toolbar"], [data-radix-popper-content-wrapper], [data-radix-select-content], .docx-table-options-dropdown')||fe(false);},[]),Kr=rf.useCallback((w,W,G)=>{let K=N.current?.getView();if(K)try{let oe=K.state.doc.nodeAt(w);if(!oe||oe.type.name!=="image")return;let j=K.state.tr.setNodeMarkup(w,void 0,{...oe.attrs,width:W,height:G});K.dispatch(j),N.current?.setNodeSelection(w);}catch{}},[]),Qa=rf.useCallback(()=>{he.current=true;},[]),Lo=rf.useCallback(()=>{he.current=false;},[]),Bo=rf.useCallback((w,W,G)=>{let K=N.current?.getView();if(K)try{let oe=K.state.doc.nodeAt(w);if(!oe||oe.type.name!=="image")return;if(oe.attrs.displayMode==="float"||oe.attrs.wrapType&&["square","tight","through"].includes(oe.attrs.wrapType)){let Q=ae.current?.querySelectorAll(".layout-page");if(!Q||Q.length===0)return;let re=null;for(let dt of Q){let ut=dt.getBoundingClientRect();if(G>=ut.top&&G<=ut.bottom){re=dt.querySelector(".layout-page-content");break}}if(re||(re=Q[Q.length-1].querySelector(".layout-page-content")),!re)return;let de=re.getBoundingClientRect(),Se=(W-de.left)/c,xe=(G-de.top)/c,we=914400/96,Ee=Math.round(Se*we),ve=Math.round(xe*we),Ae={horizontal:{posOffset:Ee,relativeTo:"margin"},vertical:{posOffset:ve,relativeTo:"margin"}},je=K.state.tr.setNodeMarkup(w,void 0,{...oe.attrs,position:Ae});K.dispatch(je),N.current?.setNodeSelection(w);}else {let Q=Mt(W,G);if(Q===null||Q===w||Q===w+1)return;let re=K.state.tr;if(Q<=w)re=re.delete(w,w+oe.nodeSize),re=re.insert(Q,oe),N.current?.setNodeSelection(Q);else {re=re.delete(w,w+oe.nodeSize);let de=Q-oe.nodeSize;re=re.insert(Math.min(de,re.doc.content.size),oe),N.current?.setNodeSelection(Math.min(de,re.doc.content.size-1));}K.dispatch(re);}}catch{}},[Mt,c]),rr=rf.useCallback(()=>{he.current=true;},[]),Ao=rf.useCallback(()=>{he.current=false;},[]),go=rf.useCallback(w=>{if(!u){if(N.current?.isFocused()||(N.current?.focus(),fe(true)),w.key===" "&&!w.ctrlKey&&!w.metaKey&&!w.nativeEvent.isComposing){w.preventDefault();let W=N.current?.getView();if(W){let{from:G,to:K}=W.state.selection;W.someProp("handleTextInput",j=>j(W,G,K," "))||W.dispatch(W.state.tr.insertText(" "));}return}if(["PageUp","PageDown"].includes(w.key)&&!w.metaKey&&w.ctrlKey,w.key==="Home"&&(w.metaKey||w.ctrlKey)){let W=O();W&&(W.scrollTop=0);}if(w.key==="End"&&(w.metaKey||w.ctrlKey)){let W=O();W&&(W.scrollTop=W.scrollHeight);}}},[u,O]),ir=rf.useCallback(w=>{u||w.target.closest(".docx-comments-sidebar")||N.current?.isFocused()||(N.current?.focus(),fe(true));},[u]),ar=rf.useCallback(w=>{Ht(w.state),Ut(w.state),u||requestAnimationFrame(()=>{w.focus(),fe(true);});},[Ht,Ut,u]);rf.useEffect(()=>{let w=()=>{let W=N.current?.getView();W&&(chunkQQ63M65M_js.f(),ll(),Ht(W.state),Ut(W.state));};return window.document.fonts.addEventListener("loadingdone",w),()=>{window.document.fonts.removeEventListener("loadingdone",w);}},[]);let jt=rf.useRef(0);rf.useEffect(()=>{if(jt.current===0){jt.current=1;return}let w=N.current?.getView();w&&Ht(w.state);},[s,l,Ht]),rf.useEffect(()=>{let w=ie.current;if(!w)return;let W=new ResizeObserver(()=>{let G=N.current?.getState();G&&Ut(G);});return W.observe(w),()=>W.disconnect()},[Ut]),rf.useImperativeHandle(n,()=>({getDocument(){return N.current?.getDocument()??null},getState(){return N.current?.getState()??null},getView(){return N.current?.getView()??null},focus(){N.current?.focus(),fe(true);},blur(){N.current?.blur(),fe(false);},isFocused(){return N.current?.isFocused()??false},dispatch(w){N.current?.dispatch(w);},undo(){return N.current?.undo()??false},redo(){return N.current?.redo()??false},setSelection(w,W){N.current?.setSelection(w,W);},getLayout(){return I},relayout(){let w=N.current?.getState();w&&Ht(w);},scrollToPosition:mo}),[I,Ht,mo]),rf.useEffect(()=>{let w=N.current?.getState();I&&w&&Ut(w);},[I,Ut]),rf.useEffect(()=>{k.current&&N.current&&k.current({getDocument:()=>N.current?.getDocument()??null,getState:()=>N.current?.getState()??null,getView:()=>N.current?.getView()??null,focus:()=>{N.current?.focus(),fe(true);},blur:()=>{N.current?.blur(),fe(false);},isFocused:()=>N.current?.isFocused()??false,dispatch:w=>N.current?.dispatch(w),undo:()=>N.current?.undo()??false,redo:()=>N.current?.redo()??false,setSelection:(w,W)=>N.current?.setSelection(w,W),getLayout:()=>I,relayout:()=>{let w=N.current?.getState();w&&Ht(w);},scrollToPosition:mo});},[I,Ht]);let Jt=rf.useMemo(()=>{if(!I)return Yp+48;let w=I.pages.length;return w*hn.h+(w-1)*d+48},[I,hn.h,d]);return jsxRuntime.jsxs("div",{ref:ie,className:`ep-root paged-editor ${P??""}`,style:{...Fx,..._},tabIndex:0,onFocus:kt,onBlur:Gr,onKeyDown:go,onMouseDown:ir,children:[jsxRuntime.jsx(tp,{ref:N,document:o,styles:r,widthPx:Vt,readOnly:u,onTransaction:fo,onSelectionChange:jr,externalPlugins:m,extensionManager:b,onEditorViewReady:ar,onKeyDown:Fe}),jsxRuntime.jsxs("div",{style:{...Lx,minHeight:Jt,transform:(()=>{let w=[];return q&&w.push("translateX(-120px)"),c!==1&&w.push(`scale(${c})`),w.length>0?w.join(" "):void 0})(),transformOrigin:"top center",transition:"transform 0.2s ease"},children:[jsxRuntime.jsx("div",{ref:ae,className:`paged-editor__pages${u?" paged-editor--readonly":""}${B?` paged-editor--hf-editing paged-editor--editing-${B}`:""}`,style:Bx,onMouseDown:tr,onMouseMove:Ze,onClick:Ja,onContextMenu:bt,"aria-hidden":"true"}),jsxRuntime.jsx(op,{selectionRects:Te,caretPosition:U,isFocused:ne,pageGap:d,readOnly:u}),jsxRuntime.jsx(lp,{imageInfo:me,zoom:c,isFocused:ne,onResize:Kr,onResizeStart:Qa,onResizeEnd:Lo,onDragMove:Bo,onDragStart:rr,onDragEnd:Ao}),It&&jsxRuntime.jsx("button",{type:"button",onMouseDown:Za,onMouseEnter:On,onMouseLeave:()=>ce(null),style:{position:"absolute",left:It.x,top:It.y,width:20,height:20,borderRadius:"4px",border:"1px solid #dadce0",backgroundColor:"#f8f9fa",color:"#5f6368",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:200,padding:0,boxShadow:"none"},title:It.type==="row"?"Insert row below":"Insert column to the right","aria-label":It.type==="row"?"Insert row below":"Insert column to the right",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"})})}),T&&jsxRuntime.jsx("div",{className:"paged-editor__plugin-overlays",style:Ax,children:T})]}),z]})}),Qp=rf.memo(Yx);var Jx=rf.lazy(()=>import('./FindReplaceDialog-AQFR4OCT.js')),Qx=rf.lazy(()=>import('./HyperlinkDialog-HGZ2S37Z.js')),eS=rf.lazy(()=>import('./TablePropertiesDialog-STZOGHJB.js').then(e=>({default:e.TablePropertiesDialog}))),tS=rf.lazy(()=>import('./ImagePositionDialog-DQ4JWS4F.js').then(e=>({default:e.ImagePositionDialog}))),nS=rf.lazy(()=>import('./ImagePropertiesDialog-GJMGLM6G.js').then(e=>({default:e.ImagePropertiesDialog}))),oS=rf.lazy(()=>import('./FootnotePropertiesDialog-YYIZU5U6.js').then(e=>({default:e.FootnotePropertiesDialog}))),rS=rf.lazy(()=>import('./PageSetupDialog-ZZTFPZKJ.js').then(e=>({default:e.PageSetupDialog}))),ef=[{value:"editing",label:"Editing",icon:"edit_note",desc:"Edit document directly"},{value:"suggesting",label:"Suggesting",icon:"rate_review",desc:"Edits become suggestions"},{value:"viewing",label:"Viewing",icon:"visibility",desc:"Read-only, no edits"}];function sS({mode:e,onModeChange:t}){let[n,o]=rf.useState(false),[r,i]=rf.useState(false),a=rf.useRef(null),s=rf.useRef(null),[l,u]=rf.useState({top:0,left:0}),d=ef.find(c=>c.value===e);return rf.useEffect(()=>{let c=window.matchMedia("(max-width: 1400px)");i(c.matches);let p=f=>i(f.matches);return c.addEventListener("change",p),()=>c.removeEventListener("change",p)},[]),rf.useEffect(()=>{if(!n||!a.current)return;let c=a.current.getBoundingClientRect();u({top:c.bottom+2,left:c.right-220});},[n]),rf.useEffect(()=>{if(!n)return;let c=f=>{!a.current?.contains(f.target)&&!s.current?.contains(f.target)&&o(false);},p=f=>{f.key==="Escape"&&o(false);};return document.addEventListener("mousedown",c),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",p);}},[n]),jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:a,type:"button",onMouseDown:c=>c.preventDefault(),onClick:()=>o(!n),title:`${d.label} (Ctrl+Shift+E)`,style:{display:"flex",alignItems:"center",gap:r?0:4,padding:r?"2px 4px":"2px 6px 2px 4px",border:"none",background:n?"var(--doc-hover, #f3f4f6)":"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text, #374151)",whiteSpace:"nowrap",height:28},children:[jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:d.icon,size:18}),!r&&jsxRuntime.jsx("span",{children:d.label}),jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:"arrow_drop_down",size:16})]}),n&&jsxRuntime.jsx("div",{ref:s,onMouseDown:c=>c.preventDefault(),style:{position:"fixed",top:l.top,left:l.left,backgroundColor:"white",border:"1px solid var(--doc-border, #d1d5db)",borderRadius:8,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.12)",padding:"4px 0",zIndex:1e4,minWidth:220},children:ef.map(c=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>{t(c.value),o(false);},onMouseOver:p=>{p.currentTarget.style.backgroundColor="var(--doc-hover, #f3f4f6)";},onMouseOut:p=>{p.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, #374151)",width:"100%",textAlign:"left"},children:[jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:c.icon,size:20}),jsxRuntime.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[jsxRuntime.jsx("span",{style:{fontWeight:500},children:c.label}),jsxRuntime.jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted, #9ca3af)"},children:c.desc})]}),c.value===e&&jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:"check",size:18,style:{marginLeft:"auto",color:"#1a73e8"}})]},c.value))})]})}var lS=Date.now(),Ga=-1,tf=new Map;function nf(e,t,n){if(!e||!t)return null;let o=e.querySelector(".paged-editor__pages");if(!o)return null;let r=o.querySelectorAll("[data-pm-start]");for(let i of r){let a=i,s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(n>=s&&n<=l)return a.getBoundingClientRect().top-t.getBoundingClientRect().top}return null}function wl(e,t,n){return {id:lS++,author:t,date:new Date().toISOString(),content:[{type:"paragraph",formatting:{},content:[{type:"run",formatting:{},content:[{type:"text",text:e}]}]}],...n!==void 0&&{parentId:n}}}var of=rf.forwardRef(function({documentBuffer:t,document:n,onSave:o,author:r="User",onChange:i,onSelectionChange:a,onError:s,onFontsLoaded:l,theme:u,showToolbar:d=true,showZoomControl:c=true,showMarginGuides:p=false,marginGuideColor:f,showRuler:m=false,rulerUnit:b="inch",initialZoom:g=1,readOnly:x=false,toolbarExtra:T,className:S="",style:B,placeholder:C,loadingIndicator:P,showOutline:_=false,showPrintButton:q=true,printOptions:z,onPrint:H,onCopy:ee,onCut:ue,onPaste:A,mode:O,onModeChange:ie,externalPlugins:ae,onEditorViewReady:N,onRenderedDomContextReady:Ie,pluginOverlays:Fe,renderLogo:Ve,documentName:M,onDocumentNameChange:F,documentNameEditable:k=true,renderTitleBarRight:L},I){let[E,Z]=rf.useState({isLoading:!!t,parseError:null,zoom:g,selectionFormatting:{},paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[le,$]=rf.useState(false),[Y,ne]=rf.useState(false),[fe,Te]=rf.useState(false),[v,U]=rf.useState(false),[D,me]=rf.useState(null),[ge,he]=rf.useState(_),De=rf.useRef(false);De.current=ge;let[be,pe]=rf.useState([]),[_e,Ke]=rf.useState(false),[Ue,tt]=rf.useState([]),[Ye,it]=rf.useState([]),[vt,Ne]=rf.useState(tf),[xt,ze]=rf.useState(false),[ht,Wt]=rf.useState(null),[Xa,on]=rf.useState(null),[er,Ur]=rf.useState(O??"editing"),zn=O??er,Fo=y=>{O||Ur(y),ie?.(y);},ct=x||zn==="viewing",[qt,Pt]=rf.useState(null),[St,_t]=rf.useState({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false}),gn=rf.useRef(null),It=rf.useCallback(()=>{let y=Le.current?.getView();if(!y)return;let{doc:h,schema:R}=y.state,V=R.marks.insertion,X=R.marks.deletion;if(!V&&!X)return;let te=[];h.descendants((se,Ce)=>{if(se.isText)for(let Me of se.marks)(Me.type===V||Me.type===X)&&te.push({type:Me.type===V?"insertion":"deletion",text:se.text||"",author:Me.attrs.author||"",date:Me.attrs.date,from:Ce,to:Ce+se.nodeSize,revisionId:Me.attrs.revisionId});});let J=[];for(let se of te){let Ce=J[J.length-1];Ce&&Ce.revisionId===se.revisionId&&Ce.type===se.type&&Ce.to===se.from?(Ce.text+=se.text,Ce.to=se.to):J.push({...se});}it(J);},[]);rf.useEffect(()=>()=>{gn.current&&clearTimeout(gn.current);},[]),rf.useEffect(()=>{if(he(_),_){let y=Le.current?.getView();y&&pe(Oo(y.state.doc));}},[_]);let ce=ju(n||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),Xt=rf.useRef(false);rf.useEffect(()=>{if(Xt.current)return;let y=ce.state;if(!y)return;let h=y.package?.document?.comments;h&&h.length>0&&(tt(h),Ke(true),Xt.current=true);},[ce.state]);let On=rf.useMemo(()=>{let y=new Gn(jo());return y.buildSchema(),y.initializeRuntime(),y},[]),Zt=rf.useMemo(()=>qu(false,r),[]),hn=rf.useMemo(()=>[Zt,...ae??[]],[Zt,ae]),Le=rf.useRef(null),Dt=rf.useRef(null),Vt=rf.useRef(null),rn=rf.useRef(null),Ht=rf.useRef(null),an=rf.useRef(null),po=rf.useRef(null),En=rf.useRef(null),Ut=rf.useRef(null),fo=rf.useRef(null),[jr,Mt]=rf.useState(0),sn=rf.useRef(ce.state);sn.current=ce.state;let Ft=rf.useRef({style:"single",size:4,color:{rgb:"000000"}}),mo=rf.useRef(null),tr=rf.useCallback(y=>{let h=mo.current;if(h&&h.styles===y)return h.resolver;let R=To(y);return mo.current={styles:y,resolver:R},R},[]),[Mn,nr]=rf.useState({currentPage:1,totalPages:1,visible:false}),$n=rf.useRef(null),or=rf.useCallback(y=>{if(Ut.current=y,fo.current&&(fo.current.disconnect(),fo.current=null),!y){Mt(0);return}Mt(y.offsetHeight);let h=new ResizeObserver(()=>{Mt(y.offsetHeight);});h.observe(y),fo.current=h;},[]);rf.useEffect(()=>()=>{fo.current?.disconnect();},[]);let Be=rf.useCallback(()=>D&&Dt.current?Dt.current.getView():Le.current?.getView(),[D]),Ze=rf.useCallback(()=>{D&&Dt.current?Dt.current.focus():Le.current?.focus();},[D]),Za=rf.useCallback(()=>{D&&Dt.current?Dt.current.undo():Le.current?.undo();},[D]),Ja=rf.useCallback(()=>{D&&Dt.current?Dt.current.redo():Le.current?.redo();},[D]),bt=chunkCTYOM6BE_js.m(),kt=chunkPJVI53AH_js.m(),[Gr,Kr]=rf.useState(false),Qa=rf.useCallback(()=>Kr(true),[]),[Lo,Bo]=rf.useState(null),rr=rf.useRef(0),Ao=rf.useCallback(()=>{Xt.current=false,ar.current=false,tt([]),it([]),pe([]),Ke(false),ze(false),Wt(null),on(null),Pt(null),me(null),Ne(tf),bt.setMatches([],0),gn.current&&(clearTimeout(gn.current),gn.current=null);},[bt.setMatches]),go=rf.useCallback(y=>{Ao(),ce.reset(y),Z(h=>({...h,isLoading:false,parseError:null})),chunkVR6PT4IZ_js.l(y).catch(h=>{console.warn("Failed to load document fonts:",h);});},[Ao,ce]),ir=rf.useCallback(async y=>{let h=++rr.current;Ao(),Z(R=>({...R,isLoading:true,parseError:null}));try{let R=await chunkVR6PT4IZ_js.n(y);if(rr.current!==h)return;go(R);}catch(R){if(rr.current!==h)return;let V=R instanceof Error?R.message:"Failed to parse document";Z(X=>({...X,isLoading:false,parseError:V})),s?.(R instanceof Error?R:new Error(V));}},[Ao,go,s]);rf.useEffect(()=>{if(!t){n&&go(n);return}ir(t);},[t,n]),rf.useEffect(()=>{ce.state?Vt.current=new chunkMRWJ3GNH_js.f(ce.state):Vt.current=null;},[ce.state]);let ar=rf.useRef(false);rf.useEffect(()=>{if(!E.isLoading&&ce.state){let y=setTimeout(()=>{It(),ar.current||(ar.current=true,it(h=>(h.length>0&&Ke(true),h)));},200);return ()=>clearTimeout(y)}},[E.isLoading,ce.state,It]),rf.useEffect(()=>chunkVR6PT4IZ_js.h(()=>{l?.();}),[l]),rf.useEffect(()=>{let y=Le.current?.getView();y&&Xu(zn==="suggesting",y.state,y.dispatch,r);},[zn,r]);let jt=rf.useCallback(y=>(ce.push(y),y),[ce]),Jt=rf.useCallback(y=>{if(jt(y),i?.(y),De.current){let h=Le.current?.getView();h&&pe(Oo(h.state.doc));}gn.current&&clearTimeout(gn.current),gn.current=setTimeout(It,300);},[i,jt,It]),w=rf.useCallback(y=>{let h=Be();if(h){let{from:ot,to:Ge}=h.state.selection;Ht.current={from:ot,to:Ge};}let R=null;if(h&&(R=qe(h.state),R.isInTable||(R=null)),R?.cellBorderColor){let ot=R.cellBorderColor,Ge=ot.rgb;(!Ge||Ge==="auto")&&(Ge=chunk4VUZBV2S_js.a(ot,u).replace(/^#/,"")),Ft.current={...Ft.current,color:{rgb:Ge}};}let V=null;if(h){let ot=h.state.selection,Ge=ot.node;Ge?.type.name==="image"&&(V={pos:ot.from,wrapType:Ge.attrs.wrapType??"inline",displayMode:Ge.attrs.displayMode??"inline",cssFloat:Ge.attrs.cssFloat??null,transform:Ge.attrs.transform??null,alt:Ge.attrs.alt??null,borderWidth:Ge.attrs.borderWidth??null,borderColor:Ge.attrs.borderColor??null,borderStyle:Ge.attrs.borderStyle??null});}if(!y){Pt(null),Z(ot=>({...ot,selectionFormatting:{},pmTableContext:R,pmImageContext:V}));return}let{textFormatting:X,paragraphFormatting:te}=y,J=X.fontFamily?.ascii||X.fontFamily?.hAnsi,se=X.fontSize;if(!J||!se){let ot=sn.current,Ge=y.styleId;if(ot?.package.styles&&Ge){let Tt=tr(ot.package.styles).resolveParagraphStyle(Ge);!J&&Tt.runFormatting?.fontFamily&&(J=Tt.runFormatting.fontFamily.ascii||Tt.runFormatting.fontFamily.hAnsi),!se&&Tt.runFormatting?.fontSize&&(se=Tt.runFormatting.fontSize);}}let Ce=X.color?.rgb?`#${X.color.rgb}`:void 0,Me=te.numPr,at=Me?{type:Me.numId===1?"bullet":"numbered",level:Me.ilvl??0,isInList:true,numId:Me.numId}:void 0,nt={bold:X.bold,italic:X.italic,underline:!!X.underline,strike:X.strike,superscript:X.vertAlign==="superscript",subscript:X.vertAlign==="subscript",fontFamily:J,fontSize:se,color:Ce,highlight:X.highlight,alignment:te.alignment,lineSpacing:te.lineSpacing,listState:at,styleId:y.styleId??void 0,indentLeft:te.indentLeft,bidi:!!te.bidi};if(Z(ot=>({...ot,selectionFormatting:nt,paragraphIndentLeft:te.indentLeft??0,paragraphIndentRight:te.indentRight??0,paragraphFirstLineIndent:te.indentFirstLine??0,paragraphHangingIndent:te.hangingIndent??false,paragraphTabs:te.tabs??null,pmTableContext:R,pmImageContext:V})),h&&y.hasSelection&&!xt&&!ct){let ot=En.current,Ge=po.current,{from:ln}=h.state.selection,Tt=nf(ot,Ge,ln);if(Tt!=null&&ot&&Ge){let pr=ot.querySelector(".paged-editor__pages")?.querySelector(".layout-page"),Jr=pr?pr.getBoundingClientRect().right-Ge.getBoundingClientRect().left:Ge.getBoundingClientRect().width/2+408;Pt({top:Tt,left:Jr});}}else Pt(null);a?.(y);},[a,xt,ct]),W=wc({document:ce.state,onChange:Jt,onSelectionChange:y=>{}});rf.useEffect(()=>{let y=h=>{let V=navigator.platform.toUpperCase().indexOf("MAC")>=0?h.metaKey:h.ctrlKey;if(!V&&!h.shiftKey&&!h.altKey&&(h.key==="Delete"||h.key==="Backspace")){let X=Le.current?.getView();if(X){let te=X.state.selection;if("$anchorCell"in te&&typeof te.forEachCell=="function"){let se=qe(X.state);if(se.isInTable&&se.table){let Ce=0;se.table.descendants(at=>{(at.type.name==="tableCell"||at.type.name==="tableHeader")&&(Ce+=1);});let Me=0;if(te.forEachCell(()=>{Me+=1;}),Ce>0&&Me>=Ce){h.preventDefault(),Pr(X.state,X.dispatch);return}}}}if(W.state.tableIndex!==null){h.preventDefault(),W.handleAction("deleteTable");return}}if(V&&!h.shiftKey&&!h.altKey){if(h.key.toLowerCase()==="f"){h.preventDefault();let X=window.getSelection(),te=X&&!X.isCollapsed?X.toString():"";bt.openFind(te);}else if(h.key.toLowerCase()==="h"){h.preventDefault();let X=window.getSelection(),te=X&&!X.isCollapsed?X.toString():"";bt.openReplace(te);}else if(h.key.toLowerCase()==="k"){h.preventDefault();let X=Le.current?.getView();if(X){let te=_o(X.state),J=Wo(X.state);J?kt.openEdit({url:J.href,displayText:te,tooltip:J.tooltip}):kt.openInsert(te);}}}};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y);}},[bt,kt,W]);let G=rf.useCallback((y,h)=>{let R=Be();R&&(Yi(y,h)(R.state,R.dispatch),Ze());},[Be,Ze]),K=rf.useCallback(()=>{let y=Be();y&&(ha(y.state,y.dispatch),Ze());},[Be,Ze]),oe=rf.useCallback(()=>{let y=Be();y&&(Ki(y.state,y.dispatch),Ze());},[Be,Ze]),j=rf.useCallback(()=>{he(y=>{if(!y){let h=Le.current?.getView();h&&pe(Oo(h.state.doc));}return !y});},[]),Q=rf.useCallback(y=>{Le.current?.scrollToPosition(y),Le.current?.setSelection(y+1),Le.current?.focus();},[]),re=rf.useCallback(()=>{an.current?.click();},[]),de=rf.useCallback(y=>{let h=y.target.files?.[0];if(!h)return;let R=Be();if(!R)return;let V=new FileReader;V.onload=()=>{let X=V.result,te=new Image;te.onload=()=>{let J=te.naturalWidth,se=te.naturalHeight,Ce=612;if(J>Ce){let Ge=Ce/J;J=Ce,se=Math.round(se*Ge);}let Me=`rId_img_${Date.now()}`,at=R.state.schema.nodes.image.create({src:X,alt:h.name,width:J,height:se,rId:Me,wrapType:"inline",displayMode:"inline"}),{from:nt}=R.state.selection,ot=R.state.tr.insert(nt,at);R.dispatch(ot.scrollIntoView()),Ze();},te.src=X;},V.readAsDataURL(h),y.target.value="";},[Be,Ze]),Se=rf.useCallback(y=>{let h=Be();if(!h||!E.pmImageContext)return;let R=E.pmImageContext.pos,V=h.state.doc.nodeAt(R);if(!V||V.type.name!=="image")return;let X="inline",te=null;switch(y){case "inline":X="inline",te=null;break;case "square":case "tight":case "through":X="float",te="left";break;case "topAndBottom":X="block",te=null;break;case "behind":case "inFront":X="float",te="none";break;case "wrapLeft":X="float",te="right",y="square";break;case "wrapRight":X="float",te="left",y="square";break}let J=h.state.tr.setNodeMarkup(R,void 0,{...V.attrs,wrapType:y,displayMode:X,cssFloat:te});h.dispatch(J.scrollIntoView()),Ze();},[Be,Ze,E.pmImageContext]),xe=rf.useCallback(y=>{let h=Be();if(!h||!E.pmImageContext)return;let R=E.pmImageContext.pos,V=h.state.doc.nodeAt(R);if(!V||V.type.name!=="image")return;let X=V.attrs.transform||"",te=X.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),J=te?parseFloat(te[1]):0,se=/scaleX\(-1\)/.test(X),Ce=/scaleY\(-1\)/.test(X);switch(y){case "rotateCW":J=(J+90)%360;break;case "rotateCCW":J=(J-90+360)%360;break;case "flipH":se=!se;break;case "flipV":Ce=!Ce;break}let Me=[];J!==0&&Me.push(`rotate(${J}deg)`),se&&Me.push("scaleX(-1)"),Ce&&Me.push("scaleY(-1)");let at=Me.length>0?Me.join(" "):null,nt=h.state.tr.setNodeMarkup(R,void 0,{...V.attrs,transform:at});h.dispatch(nt.scrollIntoView()),Ze();},[Be,Ze,E.pmImageContext]),we=rf.useCallback(y=>{let h=Be();if(!h||!E.pmImageContext)return;let R=E.pmImageContext.pos,V=h.state.doc.nodeAt(R);if(!V||V.type.name!=="image")return;let X=h.state.tr.setNodeMarkup(R,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});h.dispatch(X.scrollIntoView()),Ze();},[Be,Ze,E.pmImageContext]),Ee=rf.useCallback(()=>{Te(true);},[]),ve=rf.useCallback(y=>{let h=Be();if(!h||!E.pmImageContext)return;let R=E.pmImageContext.pos,V=h.state.doc.nodeAt(R);if(!V||V.type.name!=="image")return;let X=h.state.tr.setNodeMarkup(R,void 0,{...V.attrs,alt:y.alt??null,borderWidth:y.borderWidth??null,borderColor:y.borderColor??null,borderStyle:y.borderStyle??null});h.dispatch(X.scrollIntoView()),Ze();},[Be,Ze,E.pmImageContext]),Ae=rf.useCallback((y,h)=>{if(!ce.state?.package)return;let R={...ce.state.package.document,finalSectionProperties:{...ce.state.package.document.finalSectionProperties,footnotePr:y,endnotePr:h}};jt({...ce.state,package:{...ce.state.package,document:R}});},[ce,jt]),je=rf.useCallback(y=>{let h=Be();if(h){switch(y){case "addRowAbove":vr(h.state,h.dispatch);break;case "addRowBelow":wo(h.state,h.dispatch);break;case "addColumnLeft":Er(h.state,h.dispatch);break;case "addColumnRight":Co(h.state,h.dispatch);break;case "deleteRow":Rr(h.state,h.dispatch);break;case "deleteColumn":Mr(h.state,h.dispatch);break;case "deleteTable":Pr(h.state,h.dispatch);break;case "selectTable":qi(h.state,h.dispatch);break;case "selectRow":Xi(h.state,h.dispatch);break;case "selectColumn":Zi(h.state,h.dispatch);break;case "mergeCells":Ji(h.state,h.dispatch);break;case "splitCell":Qi(h.state,h.dispatch);break;case "borderAll":ta(h.state,h.dispatch,Ft.current);break;case "borderOutside":na(h.state,h.dispatch,Ft.current);break;case "borderInside":oa(h.state,h.dispatch,Ft.current);break;case "borderNone":ea(h.state,h.dispatch);break;case "borderTop":Kn("top",Ft.current,true)(h.state,h.dispatch);break;case "borderBottom":Kn("bottom",Ft.current,true)(h.state,h.dispatch);break;case "borderLeft":Kn("left",Ft.current,true)(h.state,h.dispatch);break;case "borderRight":Kn("right",Ft.current,true)(h.state,h.dispatch);break;default:if(typeof y=="object"){if(y.type==="cellFillColor")fa(y.color)(h.state,h.dispatch);else if(y.type==="borderColor"){let R=y.color.replace(/^#/,"");Ft.current={...Ft.current,color:{rgb:R}},ma(y.color)(h.state,h.dispatch);}else if(y.type==="borderWidth")Ft.current={...Ft.current,size:y.size},ga(y.size)(h.state,h.dispatch);else if(y.type==="cellBorder")Kn(y.side,{style:y.style,size:y.size,color:{rgb:y.color.replace(/^#/,"")}})(h.state,h.dispatch);else if(y.type==="cellVerticalAlign")ra(y.align)(h.state,h.dispatch);else if(y.type==="cellMargins")ia(y.margins)(h.state,h.dispatch);else if(y.type==="cellTextDirection")aa(y.direction)(h.state,h.dispatch);else if(y.type==="toggleNoWrap")sa()(h.state,h.dispatch);else if(y.type==="rowHeight")la(y.height,y.rule)(h.state,h.dispatch);else if(y.type==="toggleHeaderRow")ca()(h.state,h.dispatch);else if(y.type==="distributeColumns")da()(h.state,h.dispatch);else if(y.type==="autoFitContents")ua()(h.state,h.dispatch);else if(y.type==="openTableProperties")$(true);else if(y.type==="tableProperties")Ir(y.props)(h.state,h.dispatch);else if(y.type==="applyTableStyle"){let R=$u(y.styleId),V=sn.current;if(!R&&V?.package.styles){let te=tr(V.package.styles).getStyle(y.styleId);if(te){if(R={id:te.styleId,name:te.name??te.styleId},te.tblPr?.borders){let J=te.tblPr.borders;R.tableBorders={};for(let se of ["top","bottom","left","right","insideH","insideV"]){let Ce=J[se];Ce&&(R.tableBorders[se]={style:Ce.style,size:Ce.size,color:Ce.color?.rgb?{rgb:Ce.color.rgb}:void 0});}}if(te.tblStylePr){R.conditionals={};for(let J of te.tblStylePr){let se={};if(J.tcPr?.shading?.fill&&(se.backgroundColor=`#${J.tcPr.shading.fill}`),J.tcPr?.borders){let Ce={};for(let Me of ["top","bottom","left","right"]){let at=J.tcPr.borders[Me];at&&(Ce[Me]={style:at.style,size:at.size,color:at.color?.rgb?{rgb:at.color.rgb}:void 0});}se.borders=Ce;}J.rPr?.bold&&(se.bold=true),J.rPr?.color?.rgb&&(se.color=`#${J.rPr.color.rgb}`),R.conditionals[J.type]=se;}}R.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}R&&pa({styleId:R.id,tableBorders:R.tableBorders,conditionals:R.conditionals,look:R.look})(h.state,h.dispatch);}}else W.handleAction(y);}Ze();}},[W,Be,Ze]),dt=rf.useCallback(y=>{y.preventDefault(),y.stopPropagation();let h=Le.current?.getView(),R=h?jn(h.state):false,{from:V,to:X}=h?.state.selection??{from:0,to:0},te=V!==X;_t({isOpen:true,position:{x:y.clientX,y:y.clientY},hasSelection:te,cursorInTable:R});},[]),ut=rf.useCallback(y=>{let h=Be();if(!h)return;h.focus();let R=h===Le.current?.getView(),{from:V,to:X}=h.state.selection,te=Ht.current;if(R&&te&&(V!==te.from||X!==te.to))try{let J=h.state.tr.setSelection(prosemirrorState.TextSelection.create(h.state.doc,te.from,te.to));h.dispatch(J);}catch(J){console.warn("Could not restore selection:",J);}if(y==="bold"){Ti(h.state,h.dispatch);return}if(y==="italic"){wi(h.state,h.dispatch);return}if(y==="underline"){Ci(h.state,h.dispatch);return}if(y==="strikethrough"){vi(h.state,h.dispatch);return}if(y==="superscript"){Ri(h.state,h.dispatch);return}if(y==="subscript"){Ei(h.state,h.dispatch);return}if(y==="bulletList"){$i(h.state,h.dispatch);return}if(y==="numberedList"){Wi(h.state,h.dispatch);return}if(y==="indent"){_i(h.state,h.dispatch)||Hi()(h.state,h.dispatch);return}if(y==="outdent"){Vi(h.state,h.dispatch)||Ni()(h.state,h.dispatch);return}if(y==="clearFormatting"){yr(h.state,h.dispatch);return}if(y==="setRtl"){ji(h.state,h.dispatch);return}if(y==="setLtr"){Gi(h.state,h.dispatch);return}if(y==="insertLink"){let J=_o(h.state),se=Wo(h.state);se?kt.openEdit({url:se.href,displayText:J,tooltip:se.tooltip}):kt.openInsert(J);return}if(typeof y=="object")switch(y.type){case "alignment":Ai(y.value)(h.state,h.dispatch);break;case "textColor":{let J=y.value;typeof J=="string"?kr({rgb:J.replace("#","")})(h.state,h.dispatch):J.auto?Mi(h.state,h.dispatch):kr(J)(h.state,h.dispatch);break}case "highlightColor":{let J=y.value?chunk2KHL5RSD_js.z(y.value):"";Pi(J||y.value)(h.state,h.dispatch);break}case "fontSize":Ii(chunk2KHL5RSD_js.i(y.value))(h.state,h.dispatch);break;case "fontFamily":Fi(y.value)(h.state,h.dispatch);break;case "lineSpacing":Di(y.value)(h.state,h.dispatch);break;case "applyStyle":{let J=sn.current,se=J?.package.styles?tr(J.package.styles):null;if(se){let Ce=se.resolveParagraphStyle(y.value);Cr(y.value,{paragraphFormatting:Ce.paragraphFormatting,runFormatting:Ce.runFormatting})(h.state,h.dispatch);}else Cr(y.value)(h.state,h.dispatch);break}}},[Be]),Qt=rf.useCallback(y=>{Z(h=>({...h,zoom:y}));},[]),Wn=rf.useCallback(y=>{let h=Be();if(!h)return;let R=y.url||"",V=y.tooltip,{empty:X}=h.state.selection;X&&y.displayText?Tr(y.displayText,R,V)(h.state,h.dispatch):X?y.displayText&&Tr(y.displayText,R,V)(h.state,h.dispatch):Li(R,V)(h.state,h.dispatch),kt.close(),Ze();},[kt,Be,Ze]),en=rf.useCallback(()=>{let y=Be();y&&(Bi(y.state,y.dispatch),Ze());},[Be,Ze]),ho=rf.useCallback(()=>{en(),kt.close();},[kt,en]),sr=rf.useCallback(y=>Bo(y),[]),es=rf.useCallback(y=>{window.open(y,"_blank","noopener,noreferrer");},[]),lr=rf.useCallback(y=>{navigator.clipboard.writeText(y).catch(()=>{let h=document.createElement("textarea");h.value=y,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h);});},[]),Yr=rf.useCallback((y,h)=>{let R=Be();if(!R)return;let V=R.state.schema.marks.hyperlink;if(!V)return;let{$from:X}=R.state.selection,te=X.marks().find(J=>J.type===V);if(te){let J=X.parent,se=X.start(),Ce=[],Me=null;J.forEach((Tt,ur)=>{let pr=se+ur,Jr=pr+Tt.nodeSize;(Tt.isText?Tt.marks.find(Ml=>Ml.type===V&&Ml.attrs.href===te.attrs.href):null)?Me?Me.end=Jr:Me={start:pr,end:Jr}:Me&&(Ce.push(Me),Me=null);}),Me&&Ce.push(Me);let at=X.pos,nt=Ce.find(Tt=>Tt.start<=at&&at<=Tt.end);if(!nt)return;let ot=R.state.tr,Ge=V.create({href:h,tooltip:te.attrs.tooltip}),ln=R.state.schema.text(y,[...X.marks().filter(Tt=>Tt.type!==V),Ge]);ot.replaceWith(nt.start,nt.end,ln),R.dispatch(ot.scrollIntoView());}Bo(null),Ze();},[Be,Ze]),Gt=rf.useCallback(()=>{let y=Be();if(!y)return;let h=y.state.schema.marks.hyperlink;if(!h)return;let{$from:R}=y.state.selection,V=R.marks().find(nt=>nt.type===h);if(!V&&R.nodeAfter&&(V=R.nodeAfter.marks.find(nt=>nt.type===h)),!V&&R.nodeBefore&&(V=R.nodeBefore.marks.find(nt=>nt.type===h)),!V&&Lo&&R.parent.forEach(ot=>{if(!V&&ot.isText){let Ge=ot.marks.find(ln=>ln.type===h&&ln.attrs.href===Lo.href);Ge&&(V=Ge);}}),!V)return;let X=R.parent,te=R.start(),J=[],se=null;X.forEach((nt,ot)=>{let Ge=te+ot,ln=Ge+nt.nodeSize;(nt.isText?nt.marks.find(ur=>ur.type===h&&ur.attrs.href===V.attrs.href):null)?se?se.end=ln:se={start:Ge,end:ln}:se&&(J.push(se),se=null);}),se&&J.push(se);let Ce=R.pos,Me=J.find(nt=>nt.start<=Ce&&Ce<=nt.end);if(!Me)return;let at=y.state.tr;at.removeMark(Me.start,Me.end,h),y.dispatch(at.scrollIntoView()),Bo(null),Ze(),sonner.toast("Link removed");},[Be,Ze,Lo]),bo=rf.useCallback(()=>{Bo(null);},[]),bn=rf.useCallback(y=>{let h=Le.current?.getView(),R=h?jn(h.state):false;_t({isOpen:true,position:y,hasSelection:y.hasSelection,cursorInTable:R});},[]),yo=rf.useCallback(()=>{_t({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false});},[]),_n=rf.useMemo(()=>{let h=typeof navigator<"u"&&/Mac/.test(navigator.platform)?"\u2318":"Ctrl",R=[{action:"cut",label:"Cut",shortcut:`${h}+X`},{action:"copy",label:"Copy",shortcut:`${h}+C`},{action:"paste",label:"Paste",shortcut:`${h}+V`},{action:"pasteAsPlainText",label:"Paste as Plain Text",shortcut:`${h}+Shift+V`,dividerAfter:true},{action:"delete",label:"Delete",shortcut:"Del",dividerAfter:!St.hasSelection&&!St.cursorInTable}];return St.hasSelection&&R.push({action:"addComment",label:"Comment",dividerAfter:!St.cursorInTable}),St.cursorInTable&&R.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",dividerAfter:true}),R.push({action:"selectAll",label:"Select All",shortcut:`${h}+A`}),R},[St.hasSelection,St.cursorInTable]),qr=rf.useCallback(async y=>{let h=Be();if(h)switch(Ze(),y){case "cut":document.execCommand("cut");break;case "copy":document.execCommand("copy");break;case "paste":{try{let R=await navigator.clipboard.read(),V="",X="";for(let se of R)se.types.includes("text/html")&&(V=await(await se.getType("text/html")).text()),se.types.includes("text/plain")&&(X=await(await se.getType("text/plain")).text());let te=new DataTransfer;V&&te.items.add(V,"text/html"),X&&te.items.add(X,"text/plain");let J=new ClipboardEvent("paste",{clipboardData:te,bubbles:!0,cancelable:!0});h.dom.dispatchEvent(J);}catch{try{let R=await navigator.clipboard.readText();R&&h.dispatch(h.state.tr.insertText(R));}catch{}}break}case "pasteAsPlainText":try{let R=await navigator.clipboard.readText();R&&h.dispatch(h.state.tr.insertText(R));}catch{}break;case "delete":{let{from:R,to:V}=h.state.selection;R!==V&&h.dispatch(h.state.tr.deleteRange(R,V));break}case "selectAll":h.dispatch(h.state.tr.setSelection(prosemirrorState.TextSelection.create(h.state.doc,0,h.state.doc.content.size)));break;case "addRowAbove":vr(h.state,h.dispatch);break;case "addRowBelow":wo(h.state,h.dispatch);break;case "deleteRow":Rr(h.state,h.dispatch);break;case "addColumnLeft":Er(h.state,h.dispatch);break;case "addColumnRight":Co(h.state,h.dispatch);break;case "deleteColumn":Mr(h.state,h.dispatch);break;case "addComment":{let{from:R,to:V}=h.state.selection;if(R===V)break;let X=nf(En.current,po.current,R);Wt({from:R,to:V});let te=h.state.schema.marks.comment.create({commentId:Ga}),J=h.state.tr.addMark(R,V,te);J.setSelection(prosemirrorState.TextSelection.create(J.doc,V)),h.dispatch(J),on(X),Ke(true),ze(true),Pt(null);break}}},[Be,Ze]),Vn=rf.useCallback(y=>h=>{if(!ce.state||ct)return;let R={...ce.state,package:{...ce.state.package,document:{...ce.state.package.document,finalSectionProperties:{...ce.state.package.document.finalSectionProperties,[y]:h}}}};Jt(R);},[ce.state,ct,Jt]),Tf=rf.useMemo(()=>Vn("marginLeft"),[Vn]),wf=rf.useMemo(()=>Vn("marginRight"),[Vn]),Cf=rf.useMemo(()=>Vn("marginTop"),[Vn]),vf=rf.useMemo(()=>Vn("marginBottom"),[Vn]),Rf=rf.useCallback(y=>{if(!ce.state||ct)return;let h={...ce.state,package:{...ce.state.package,document:{...ce.state.package.document,finalSectionProperties:{...ce.state.package.document.finalSectionProperties,...y}}}};Jt(h);},[ce.state,ct,Jt]),Ef=rf.useCallback(y=>{let h=Be();h&&zi(y)(h.state,h.dispatch);},[Be]),Mf=rf.useCallback(y=>{let h=Be();h&&Oi(y)(h.state,h.dispatch);},[Be]),Pf=rf.useCallback(y=>{let h=Be();h&&(y<0?wr(-y,true)(h.state,h.dispatch):wr(y,false)(h.state,h.dispatch));},[Be]),If=rf.useCallback(y=>{let h=Be();h&&Ui(y)(h.state,h.dispatch);},[Be]),Do=En.current;rf.useEffect(()=>{if(!Do)return;let y=()=>{let h=Le.current?.getLayout();if(!h||h.pages.length===0)return;let R=Do.scrollTop,V=h.pages.length,X=24,te=24,J=R+Do.clientHeight/2,se=te,Ce=1;for(let Me=0;Me<h.pages.length;Me++){let at=h.pages[Me].size.h,nt=se+at;if(J<nt){Ce=Me+1;break}se=nt+X,Ce=Me+2;}Ce=Math.min(Ce,V),nr({currentPage:Ce,totalPages:V,visible:true}),$n.current&&clearTimeout($n.current),$n.current=setTimeout(()=>{nr(Me=>({...Me,visible:false}));},600);};return Do.addEventListener("scroll",y,{passive:true}),()=>{Do.removeEventListener("scroll",y),$n.current&&clearTimeout($n.current);}},[Do]);let El=rf.useCallback(async y=>{if(!Vt.current)return null;try{let h=Vt.current.getDocument(),R=Le.current?.getDocument();R?.package?.document&&(h.package.document.content=R.package.document.content),h.package.document.comments=Ue;let V=y?.selective!==!1,X=Le.current?.getView(),te;if(V&&X){let se=X.state;te={selective:{changedParaIds:Jd(se),structuralChange:Qd(se),hasUntrackedChanges:eu(se)}};}let J=await Vt.current.toBuffer(te);return X&&X.dispatch(tu(X.state)),o?.(J),J}catch(h){return s?.(h instanceof Error?h:new Error("Failed to save document")),null}},[o,s,Ue]),Ff=rf.useCallback(y=>{s?.(y);},[s]),Xr=rf.useCallback(()=>{let y=rn.current?.querySelector(".paged-editor__pages");if(!y){window.print(),H?.();return}let h=window.open("","_blank");if(!h){window.print(),H?.();return}let R=[];for(let X of Array.from(document.styleSheets))try{for(let te of Array.from(X.cssRules))te instanceof CSSFontFaceRule&&R.push(te.cssText);}catch{}let V=y.cloneNode(true);V.style.cssText="display: block; margin: 0; padding: 0;";for(let X of Array.from(V.querySelectorAll(".layout-page"))){let te=X;te.style.boxShadow="none",te.style.margin="0";}h.document.write(`<!DOCTYPE html>
|
|
19
|
+
<html><head><title>Print</title>
|
|
20
|
+
<style>
|
|
21
|
+
${R.join(`
|
|
22
|
+
`)}
|
|
23
|
+
* { margin: 0; padding: 0; }
|
|
24
|
+
body { background: white; }
|
|
25
|
+
.layout-page { break-after: page; }
|
|
26
|
+
.layout-page:last-child { break-after: auto; }
|
|
27
|
+
@page { margin: 0; size: auto; }
|
|
28
|
+
</style>
|
|
29
|
+
</head><body>${V.outerHTML}</body></html>`),h.document.close(),h.onload=()=>{h.print(),h.close();},setTimeout(()=>{h.closed||(h.print(),h.close());},1e3),H?.();},[H]),Nt=rf.useRef(null),Lf=rf.useCallback((y,h)=>{if(!ce.state||!y.trim())return Nt.current=null,null;let R=chunkCTYOM6BE_js.j(ce.state,y,h),V={matches:R,totalCount:R.length,currentIndex:0};return Nt.current=V,bt.setMatches(R,0),R.length>0&&rn.current&&chunkCTYOM6BE_js.l(rn.current,R[0]),V},[ce.state,bt]),Bf=rf.useCallback(()=>{if(!Nt.current||Nt.current.matches.length===0)return null;let y=bt.goToNextMatch(),h=Nt.current.matches[y];return h&&rn.current&&chunkCTYOM6BE_js.l(rn.current,h),h||null},[bt]),Af=rf.useCallback(()=>{if(!Nt.current||Nt.current.matches.length===0)return null;let y=bt.goToPreviousMatch(),h=Nt.current.matches[y];return h&&rn.current&&chunkCTYOM6BE_js.l(rn.current,h),h||null},[bt]),Df=rf.useCallback(y=>{if(!ce.state||!Nt.current||Nt.current.matches.length===0)return false;let h=Nt.current.matches[Nt.current.currentIndex];if(!h)return false;try{let R=chunkAARNCPWR_js.a(ce.state,{type:"replaceText",range:{start:{paragraphIndex:h.paragraphIndex,offset:h.startOffset},end:{paragraphIndex:h.paragraphIndex,offset:h.endOffset}},text:y});return Jt(R),!0}catch(R){return console.error("Replace failed:",R),false}},[ce.state,Jt]),Hf=rf.useCallback((y,h,R)=>{if(!ce.state||!y.trim())return 0;let V=chunkCTYOM6BE_js.j(ce.state,y,R);if(V.length===0)return 0;let X=ce.state,te=[...V].sort((J,se)=>J.paragraphIndex!==se.paragraphIndex?se.paragraphIndex-J.paragraphIndex:se.startOffset-J.startOffset);for(let J of te)try{X=chunkAARNCPWR_js.a(X,{type:"replaceText",range:{start:{paragraphIndex:J.paragraphIndex,offset:J.startOffset},end:{paragraphIndex:J.paragraphIndex,offset:J.endOffset}},text:h});}catch(se){console.error("Replace failed for match:",J,se);}return Jt(X),Nt.current=null,bt.setMatches([],0),V.length},[ce.state,Jt,bt]);rf.useImperativeHandle(I,()=>({getAgent:()=>Vt.current,getDocument:()=>ce.state,getEditorRef:()=>Le.current,save:El,setZoom:y=>Z(h=>({...h,zoom:y})),getZoom:()=>E.zoom,focus:()=>{Le.current?.focus();},getCurrentPage:()=>Mn.currentPage,getTotalPages:()=>Mn.totalPages,scrollToPage:y=>{},openPrintPreview:Xr,print:Xr,loadDocument:go,loadDocumentBuffer:ir}),[ce.state,E.zoom,Mn,El,Xr,go,ir]);let{headerContent:cr,footerContent:dr}=rf.useMemo(()=>{if(!ce.state?.package)return {headerContent:null,footerContent:null};let y=ce.state.package,h=y.document?.finalSectionProperties,R=y.headers,V=y.footers,X=null,te=null;if(R&&h?.headerReferences){let J=h.headerReferences.find(se=>se.type==="default");J?.rId&&(X=R.get(J.rId)??null);}if(V&&h?.footerReferences){let J=h.footerReferences.find(se=>se.type==="default");J?.rId&&(te=V.get(J.rId)??null);}return {headerContent:X,footerContent:te}},[ce.state]),Nf=rf.useCallback(y=>{if(y==="header"?cr:dr){me(y);return}if(!ce.state?.package)return;let R=ce.state.package,V=R.document?.finalSectionProperties;if(!V)return;let X=`rId_new_${y}`,te={type:y==="header"?"header":"footer",hdrFtrType:"default",content:[{type:"paragraph",content:[]}]},J=y==="header"?"headers":"footers",se=new Map(R[J]??[]);se.set(X,te);let Ce=y==="header"?"headerReferences":"footerReferences",Me=V[Ce]??[],at={type:"default",rId:X},nt={...ce.state,package:{...R,[J]:se,document:R.document?{...R.document,finalSectionProperties:{...V,[Ce]:[...Me,at]}}:R.document}};jt(nt),me(y);},[cr,dr,ce,jt]),ts=rf.useCallback(y=>{if(!D||!ce.state?.package){me(null);return}let h=ce.state.package,R=h.document?.finalSectionProperties,X=(D==="header"?R?.headerReferences:R?.footerReferences)?.find(se=>se.type==="default"),te=D==="header"?"headers":"footers",J=h[te];if(X?.rId&&J){let se=J.get(X.rId),Ce={type:D,hdrFtrType:"default",...se,content:y},Me=new Map(J);Me.set(X.rId,Ce);let at={...ce.state,package:{...h,[te]:Me}};jt(at);}me(null);},[D,ce,jt]),zf=rf.useCallback(()=>{if(!D)return;let y=Dt.current?.getView();if(y){let h=Sr(y.state.doc);ts(h);}else me(null);},[D,ts]),Of=rf.useCallback(()=>{if(!D||!ce.state?.package){me(null);return}let y=ce.state.package,h=y.document?.finalSectionProperties,R=D==="header"?"headerReferences":"footerReferences",V=D==="header"?"headers":"footers",X=h?.[R],te=X?.find(J=>J.type==="default");if(te?.rId){let J=new Map(y[V]??[]);J.delete(te.rId);let se=(X??[]).filter(Me=>Me.rId!==te.rId),Ce={...ce.state,package:{...y,[V]:J,document:y.document?{...y.document,finalSectionProperties:{...h,[R]:se}}:y.document}};jt(Ce);}me(null);},[D,ce,jt]),$f=rf.useCallback(y=>{let h=rn.current?.querySelector(".paged-editor__pages");if(!h)return null;let R=y==="header"?".layout-page-header":".layout-page-footer";return h.querySelector(R)},[]),Zr={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg-subtle)",...B},Wf={display:"flex",flex:1,minHeight:0,minWidth:0,flexDirection:"row"},_f={flex:1,minHeight:0,minWidth:0,overflow:"auto",position:"relative"};if(E.isLoading)return jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-loading ${S}`,style:Zr,"data-testid":"docx-editor",children:P||jsxRuntime.jsx(Wu,{})});if(E.parseError)return jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-error ${S}`,style:Zr,"data-testid":"docx-editor",children:jsxRuntime.jsx(Vu,{message:E.parseError})});if(!ce.state)return jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-empty ${S}`,style:Zr,"data-testid":"docx-editor",children:C||jsxRuntime.jsx(_u,{})});let Vf=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(chunk2KHL5RSD_js.C,{}),jsxRuntime.jsx(chunk2KHL5RSD_js.A,{onClick:()=>Ke(!_e),active:_e,title:"Toggle comments sidebar",ariaLabel:"Toggle comments sidebar",children:jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:"comment",size:20})}),jsxRuntime.jsx(chunk2KHL5RSD_js.C,{}),jsxRuntime.jsx(sS,{mode:zn,onModeChange:y=>{Fo(y),y==="suggesting"&&Ke(true);}}),T]});return jsxRuntime.jsx(kc,{children:jsxRuntime.jsx(si,{onError:Ff,children:jsxRuntime.jsxs("div",{ref:rn,className:`ep-root docx-editor ${S}`,style:Zr,"data-testid":"docx-editor",children:[jsxRuntime.jsx("div",{style:Wf,children:jsxRuntime.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[d&&!x&&jsxRuntime.jsxs("div",{ref:or,className:"z-50 flex flex-col gap-0 bg-white shadow-sm flex-shrink-0",children:[jsxRuntime.jsxs(zt,{currentFormatting:E.selectionFormatting,onFormat:ut,onUndo:Za,onRedo:Ja,canUndo:true,canRedo:true,disabled:ct,documentStyles:ce.state?.package.styles?.styles,theme:ce.state?.package.theme||u,showPrintButton:q,onPrint:Xr,showZoomControl:c,zoom:E.zoom,onZoomChange:Qt,onRefocusEditor:Ze,onInsertTable:G,showTableInsert:true,onInsertImage:re,onInsertPageBreak:K,onInsertTOC:oe,imageContext:E.pmImageContext,onImageWrapType:Se,onImageTransform:xe,onOpenImageProperties:Ee,onPageSetup:Qa,tableContext:E.pmTableContext,onTableAction:je,children:[jsxRuntime.jsxs(zt.TitleBar,{children:[Ve&&jsxRuntime.jsx(zt.Logo,{children:Ve()}),M!==void 0&&jsxRuntime.jsx(zt.DocumentName,{value:M,onChange:F,editable:k}),L&&jsxRuntime.jsx(zt.TitleBarRight,{children:L()}),jsxRuntime.jsx(zt.MenuBar,{})]}),jsxRuntime.jsx(zt.FormattingBar,{children:Vf})]}),m&&jsxRuntime.jsx("div",{className:"flex justify-center px-5 py-1 overflow-x-auto flex-shrink-0 bg-doc-bg",style:{paddingRight:_e?"calc(20px + 240px)":void 0,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(chunk2KHL5RSD_js.E,{sectionProps:ce.state?.package.document?.finalSectionProperties,zoom:E.zoom,unit:b,editable:!ct,onLeftMarginChange:Tf,onRightMarginChange:wf,indentLeft:E.paragraphIndentLeft,indentRight:E.paragraphIndentRight,onIndentLeftChange:Ef,onIndentRightChange:Mf,showFirstLineIndent:true,firstLineIndent:E.paragraphFirstLineIndent,hangingIndent:E.paragraphHangingIndent,onFirstLineIndentChange:Pf,tabStops:E.paragraphTabs,onTabStopRemove:If})})]}),jsxRuntime.jsx("div",{ref:En,style:_f,children:jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative"},children:jsxRuntime.jsxs("div",{ref:po,style:{position:"relative",flex:1,minWidth:0},onMouseDown:y=>{y.target===y.currentTarget&&(y.preventDefault(),Le.current?.focus());},onContextMenu:dt,children:[m&&!x&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:10,paddingTop:48},children:jsxRuntime.jsx(Dc,{sectionProps:ce.state?.package.document?.finalSectionProperties,zoom:E.zoom,unit:b,editable:!ct,onTopMarginChange:Cf,onBottomMarginChange:vf})}),jsxRuntime.jsx(Qp,{ref:Le,document:ce.state,styles:ce.state?.package.styles,theme:ce.state?.package.theme||u,sectionProperties:ce.state?.package.document?.finalSectionProperties,headerContent:cr,footerContent:dr,onHeaderFooterDoubleClick:Nf,hfEditMode:D,onBodyClick:zf,zoom:E.zoom,readOnly:ct,extensionManager:On,onDocumentChange:Jt,onSelectionChange:(y,h)=>{let R=Le.current?.getView();if(R){let V=Go(R.state);w(V);}else w(null);},externalPlugins:hn,onReady:y=>{N?.(y.getView());},onRenderedDomContextReady:Ie,pluginOverlays:Fe,onHyperlinkClick:sr,onContextMenu:bn,commentsSidebarOpen:_e,onAnchorPositionsChange:Ne,scrollContainerRef:En,sidebarOverlay:_e?jsxRuntime.jsx(Ic,{comments:Ue,trackedChanges:Ye,anchorPositions:vt,pageWidth:(()=>{let y=ce.state?.package?.document?.finalSectionProperties;return y?.pageWidth?Math.round(y.pageWidth/15):816})(),editorContainerRef:En,onCommentResolve:y=>{tt(h=>h.map(R=>R.id===y?{...R,done:true}:R));},onCommentDelete:y=>{tt(h=>h.filter(R=>R.id!==y&&R.parentId!==y));},onCommentReply:(y,h)=>{tt(R=>[...R,wl(h,r,y)]);},onAddComment:y=>{let h=wl(y,r),R=Le.current?.getView();if(R&&ht){let{from:V,to:X}=ht,te=R.state.schema.marks.comment.create({commentId:Ga}),J=R.state.schema.marks.comment.create({commentId:h.id}),se=R.state.tr.removeMark(V,X,te).addMark(V,X,J);R.dispatch(se);}tt(V=>[...V,h]),ze(false),Wt(null),on(null);},onTrackedChangeReply:(y,h)=>{tt(R=>[...R,wl(h,r,y)]);},onCancelAddComment:()=>{let y=Le.current?.getView();if(y&&ht){let{from:h,to:R}=ht,V=y.state.schema.marks.comment.create({commentId:Ga});y.dispatch(y.state.tr.removeMark(h,R,V));}ze(false),Wt(null),on(null);},onAcceptChange:(y,h)=>{let R=Le.current?.getView();R&&(Vs(y,h)(R.state,R.dispatch),It());},onRejectChange:(y,h)=>{let R=Le.current?.getView();R&&(Us(y,h)(R.state,R.dispatch),It());},isAddingComment:xt,addCommentYPosition:Xa,topOffset:0}):void 0}),qt!=null&&!xt&&!ct&&jsxRuntime.jsx(chunk2KHL5RSD_js.c,{content:"Add comment",side:"bottom",delayMs:300,children:jsxRuntime.jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),y.stopPropagation();let h=Le.current?.getView();if(h){let{from:R,to:V}=h.state.selection;if(R!==V){Wt({from:R,to:V});let X=h.state.schema.marks.comment.create({commentId:Ga}),te=h.state.tr.addMark(R,V,X);te.setSelection(prosemirrorState.TextSelection.create(te.doc,V)),h.dispatch(te);}}on(qt.top),Ke(true),ze(true),Pt(null);},style:{position:"absolute",top:qt.top,left:qt.left,transform:"translate(-50%, -50%)",zIndex:50,width:28,height:28,borderRadius:6,border:"1px solid rgba(26, 115, 232, 0.3)",backgroundColor:"#fff",color:"#1a73e8",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(60,64,67,0.2)",transition:"background-color 0.15s ease, box-shadow 0.15s ease"},onMouseOver:y=>{y.currentTarget.style.backgroundColor="rgba(26, 115, 232, 0.08)",y.currentTarget.style.boxShadow="0 1px 4px rgba(26, 115, 232, 0.3)";},onMouseOut:y=>{y.currentTarget.style.backgroundColor="#fff",y.currentTarget.style.boxShadow="0 1px 3px rgba(60,64,67,0.2)";},children:jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:"add_comment",size:16})})}),jsxRuntime.jsx(chunk2KHL5RSD_js.Z,{isOpen:St.isOpen,position:St.position,hasSelection:St.hasSelection,isEditable:!ct,items:_n,onAction:qr,onClose:()=>_t(y=>({...y,isOpen:false}))}),D&&(D==="header"?cr:dr)&&(()=>{let y=$f(D),h=po.current;return !y||!h?null:jsxRuntime.jsx(Au,{ref:Dt,headerFooter:D==="header"?cr:dr,position:D,styles:ce.state?.package.styles,targetElement:y,parentElement:h,onSave:ts,onClose:()=>me(null),onSelectionChange:w,onRemove:Of})})()]})})}),Mn.totalPages>1&&jsxRuntime.jsxs("div",{style:{position:"absolute",right:24,top:"50%",transform:"translateY(-50%)",backgroundColor:"rgba(0, 0, 0, 0.7)",color:"white",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:Mn.visible?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:[Mn.currentPage," of ",Mn.totalPages]}),ge&&jsxRuntime.jsx(vc,{headings:be,onHeadingClick:Q,onClose:()=>he(false),topOffset:jr}),!ge&&jsxRuntime.jsx("button",{className:"docx-outline-nav",onClick:j,onMouseDown:y=>y.stopPropagation(),title:"Show document outline",style:{position:"absolute",left:48,top:jr+12,zIndex:20,background:"transparent",border:"none",borderRadius:"50%",padding:6,cursor:"pointer",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(chunk2KHL5RSD_js.d,{name:"format_list_bulleted",size:20,style:{color:"#444746"}})})]})}),jsxRuntime.jsx(Ou,{data:Lo,onNavigate:es,onCopy:lr,onEdit:Yr,onRemove:Gt,onClose:bo,readOnly:ct}),jsxRuntime.jsx(chunk2KHL5RSD_js.Z,{isOpen:St.isOpen,position:St.position,hasSelection:St.hasSelection,isEditable:!ct,items:_n,onAction:qr,onClose:yo}),jsxRuntime.jsx(sonner.Toaster,{position:"bottom-right"}),jsxRuntime.jsxs(rf.Suspense,{fallback:null,children:[bt.state.isOpen&&jsxRuntime.jsx(Jx,{isOpen:bt.state.isOpen,onClose:bt.close,onFind:Lf,onFindNext:Bf,onFindPrevious:Af,onReplace:Df,onReplaceAll:Hf,initialSearchText:bt.state.searchText,replaceMode:bt.state.replaceMode,currentResult:Nt.current}),kt.state.isOpen&&jsxRuntime.jsx(Qx,{isOpen:kt.state.isOpen,onClose:kt.close,onSubmit:Wn,onRemove:kt.state.isEditing?ho:void 0,initialData:kt.state.initialData,selectedText:kt.state.selectedText,isEditing:kt.state.isEditing}),le&&jsxRuntime.jsx(eS,{isOpen:le,onClose:()=>$(false),onApply:y=>{let h=Be();h&&Ir(y)(h.state,h.dispatch);},currentProps:E.pmTableContext?.table?.attrs}),Y&&jsxRuntime.jsx(tS,{isOpen:Y,onClose:()=>ne(false),onApply:we}),fe&&jsxRuntime.jsx(nS,{isOpen:fe,onClose:()=>Te(false),onApply:ve,currentData:E.pmImageContext?{alt:E.pmImageContext.alt??void 0,borderWidth:E.pmImageContext.borderWidth??void 0,borderColor:E.pmImageContext.borderColor??void 0,borderStyle:E.pmImageContext.borderStyle??void 0}:void 0}),Gr&&jsxRuntime.jsx(rS,{isOpen:Gr,onClose:()=>Kr(false),onApply:Rf,currentProps:ce.state?.package.document?.finalSectionProperties}),v&&jsxRuntime.jsx(oS,{isOpen:v,onClose:()=>U(false),onApply:Ae,footnotePr:ce.state?.package.document?.finalSectionProperties?.footnotePr,endnotePr:ce.state?.package.document?.finalSectionProperties?.endnotePr})]}),jsxRuntime.jsx("input",{ref:an,type:"file",accept:"image/*",style:{display:"none"},onChange:de})]})})})});function NM(e,t,n={}){return new Promise((o,r)=>{let i=rf__default.default.createRef(),a=null;try{a=client.createRoot(t);}catch(d){r(d);return}let s={save:async()=>{let d=await(i.current?.save()??Promise.resolve(null));return d?new Blob([d],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}):null},getDocument:()=>i.current?.getDocument()??null,focus:()=>i.current?.focus(),setZoom:d=>i.current?.setZoom(d),destroy:()=>{a?.unmount(),a=null;}},l=false,u=rf__default.default.createElement(of,{...n,documentBuffer:e,onError:d=>{n.onError?.(d),l||(l=true,r(d));},onChange:d=>{n.onChange?.(d),l||(l=true,o(s));},ref:i});a.render(u);})}function GM(e,t={}){let{storageKey:n,interval:o,enabled:r=true,maxAge:i,onSave:a,onError:s,onRecoveryAvailable:l,saveOnChange:u,debounceDelay:d}=t,c=rf.useMemo(()=>new chunkFVUGBRDD_js.r({storageKey:n,interval:o,maxAge:i,saveOnChange:u,debounceDelay:d,onSave:a,onError:s,onRecoveryAvailable:l}),[n]);rf.useEffect(()=>{r?(c.enable(),c.startInterval()):c.disable();},[c,r]),rf.useEffect(()=>{c.onDocumentChanged(e??null);},[c,e]),rf.useEffect(()=>()=>{c.destroy();},[c]);let p=rf.useSyncExternalStore(c.subscribe,c.getSnapshot),f=rf.useCallback(()=>c.save(),[c]),m=rf.useCallback(()=>c.clear(),[c]),b=rf.useCallback(()=>c.getRecoveryData(),[c]),g=rf.useCallback(()=>c.acceptRecovery(),[c]),x=rf.useCallback(()=>c.dismissRecovery(),[c]),T=rf.useCallback(()=>c.enable(),[c]),S=rf.useCallback(()=>c.disable(),[c]);return {status:p.status,lastSaveTime:p.lastSaveTime,save:f,clearAutoSave:m,hasRecoveryData:p.hasRecoveryData,getRecoveryData:b,acceptRecovery:g,dismissRecovery:x,isEnabled:p.isEnabled,enable:T,disable:S}}var gS=1,af=.25,sf=4,hS=.1,fn=[.25,.5,.75,1,1.25,1.5,2,3,4];function lf(e,t,n){return Math.max(t,Math.min(n,e))}function cf(e){return Math.round(e*100)/100}function bS(e){let t=fn[0],n=Math.abs(e-t);for(let o of fn){let r=Math.abs(e-o);r<n&&(n=r,t=o);}return t}function yS(e){for(let t of fn)if(t>e+.01)return t;return fn[fn.length-1]}function xS(e){for(let t=fn.length-1;t>=0;t--)if(fn[t]<e-.01)return fn[t];return fn[0]}function qM(e={}){let{initialZoom:t=gS,minZoom:n=af,maxZoom:o=sf,zoomStep:r=hS,enabled:i=true,containerRef:a,onZoomChange:s,enableKeyboardShortcuts:l=true,preventDefault:u=true}=e,[d,c]=rf.useState(t),p=rf.useRef(d);rf.useEffect(()=>{p.current=d;},[d]);let f=rf.useCallback(C=>{let P=cf(lf(C,n,o));P!==p.current&&(c(P),s?.(P));},[n,o,s]),m=rf.useCallback(()=>{f(p.current+r);},[r,f]),b=rf.useCallback(()=>{f(p.current-r);},[r,f]),g=rf.useCallback(()=>{f(t);},[t,f]),x=rf.useCallback(()=>{f(1);},[f]),T=rf.useCallback((C,P)=>{if(P>0){let _=C/P;f(_);}},[f]),S=rf.useCallback(C=>{if(!i||!(C.ctrlKey||C.metaKey))return;u&&C.preventDefault();let _=C.deltaY;_<0?f(p.current+r):_>0&&f(p.current-r);},[i,u,r,f]),B=rf.useCallback(C=>{if(!(!i||!l||!(C.ctrlKey||C.metaKey))){if(C.key==="0"){C.preventDefault(),x();return}if(C.key==="+"||C.key==="="){C.preventDefault(),m();return}if(C.key==="-"){C.preventDefault(),b();return}}},[i,l,m,b,x]);return rf.useEffect(()=>{if(!i)return;let C=a?.current;if(C)return C.addEventListener("wheel",S,{passive:false}),()=>{C.removeEventListener("wheel",S);}},[i,a,S]),rf.useEffect(()=>{if(!(!i||!l))return document.addEventListener("keydown",B),()=>{document.removeEventListener("keydown",B);}},[i,l,B]),{zoom:d,setZoom:f,zoomIn:m,zoomOut:b,resetZoom:g,zoomTo100:x,zoomToFit:T,isMinZoom:d<=n,isMaxZoom:d>=o,zoomPercent:Math.round(d*100),handleWheel:S,handleKeyDown:B}}function XM(){return [...fn]}function ZM(e){return bS(e)}function JM(e){return yS(e)}function QM(e){return xS(e)}function eP(e){return `${Math.round(e*100)}%`}function tP(e){let t=e.match(/(\d+(\.\d+)?)/);if(t){let n=parseFloat(t[1]);if(!isNaN(n))return n/100}return null}function nP(e){return fn.some(t=>Math.abs(t-e)<.01)}function oP(e,t=af,n=sf){return cf(lf(e,t,n))}var Qo={backgroundColor:"rgba(26, 115, 232, 0.3)",borderRadius:0,zIndex:0,opacity:1,mixBlendMode:"multiply"},iP={backgroundColor:"rgba(0, 120, 215, 0.4)",borderColor:"rgba(0, 120, 215, 0.6)",borderRadius:1,zIndex:0,opacity:1},aP={backgroundColor:"--docx-selection-bg",borderColor:"--docx-selection-border",textColor:"--docx-selection-text"};function df(e){let t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return [];let n=t.getRangeAt(0);if(e&&!e.contains(n.commonAncestorContainer))return [];let o=n.getClientRects(),r=[],i=0,a=0;if(e){let s=e.getBoundingClientRect();i=s.left+e.scrollLeft,a=s.top+e.scrollTop;}for(let s=0;s<o.length;s++){let l=o[s];l.width===0&&l.height===0||r.push({left:l.left-i,top:l.top-a,width:l.width,height:l.height});}return r}function SS(e,t=2){if(e.length<=1)return e;let n=[...e].sort((i,a)=>Math.abs(i.top-a.top)<t?i.left-a.left:i.top-a.top),o=[],r={...n[0]};for(let i=1;i<n.length;i++){let a=n[i],s=Math.abs(a.top-r.top)<t,l=a.left<=r.left+r.width+t;if(s&&l){let u=Math.max(r.left+r.width,a.left+a.width);r.width=u-r.left,r.height=Math.max(r.height,a.height);}else o.push(r),r={...a};}return o.push(r),o}function Rl(e){let t=df(e);return SS(t)}function sP(e,t=Qo){return {position:"absolute",left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,backgroundColor:t.backgroundColor,borderRadius:t.borderRadius?`${t.borderRadius}px`:void 0,border:t.borderColor?`1px solid ${t.borderColor}`:void 0,zIndex:t.zIndex??0,opacity:t.opacity??1,mixBlendMode:t.mixBlendMode,pointerEvents:"none",userSelect:"none"}}function lP(e,t=Qo){let n=t.backgroundColor;return `
|
|
30
|
+
${e}::selection,
|
|
31
|
+
${e} *::selection {
|
|
32
|
+
background-color: ${n} !important;
|
|
33
|
+
color: inherit !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
${e}::-moz-selection,
|
|
37
|
+
${e} *::-moz-selection {
|
|
38
|
+
background-color: ${n} !important;
|
|
39
|
+
color: inherit !important;
|
|
40
|
+
}
|
|
41
|
+
`}function uf(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function pf(){let e=window.getSelection();return e?e.toString():""}function ff(e){let t=window.getSelection();if(!t||t.rangeCount===0)return false;let n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)}function cP(){let e=window.getSelection();return !e||e.rangeCount===0?null:e.getRangeAt(0).getBoundingClientRect()}function dP(e,t,n,o,r){try{let i=document.createRange();return i.setStart(t,n),i.setEnd(o,r),i}catch{return null}}function uP(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e));}function pP(){let e=window.getSelection();e&&e.removeAllRanges();}function kS(){let e=window.getSelection();if(!e||e.rangeCount===0)return false;let t=e.anchorNode,n=e.focusNode;return !t||!n?false:t===n?e.focusOffset<e.anchorOffset:(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_PRECEDING)!==0}function fP(){let e=window.getSelection();if(!e||e.rangeCount===0||!kS())return;let t=e.getRangeAt(0),n=document.createRange();n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset),e.removeAllRanges(),e.addRange(n);}var uo=null;function mf(e=Qo){TS();let t=`
|
|
42
|
+
/* DOCX Editor Selection Highlighting */
|
|
43
|
+
|
|
44
|
+
/* Base selection style for all editable content */
|
|
45
|
+
.docx-editor [contenteditable="true"]::selection,
|
|
46
|
+
.docx-editor [contenteditable="true"] *::selection,
|
|
47
|
+
.docx-run-editable::selection,
|
|
48
|
+
.docx-run-editable *::selection {
|
|
49
|
+
background-color: ${e.backgroundColor} !important;
|
|
50
|
+
color: inherit !important;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Firefox selection */
|
|
54
|
+
.docx-editor [contenteditable="true"]::-moz-selection,
|
|
55
|
+
.docx-editor [contenteditable="true"] *::-moz-selection,
|
|
56
|
+
.docx-run-editable::-moz-selection,
|
|
57
|
+
.docx-run-editable *::-moz-selection {
|
|
58
|
+
background-color: ${e.backgroundColor} !important;
|
|
59
|
+
color: inherit !important;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Ensure selection is visible against all backgrounds */
|
|
63
|
+
.docx-run-highlighted::selection,
|
|
64
|
+
.docx-run-highlighted *::selection {
|
|
65
|
+
/* For highlighted (yellow background) text, use darker selection */
|
|
66
|
+
background-color: rgba(26, 115, 232, 0.5) !important;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.docx-run-highlighted::-moz-selection,
|
|
70
|
+
.docx-run-highlighted *::-moz-selection {
|
|
71
|
+
background-color: rgba(26, 115, 232, 0.5) !important;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Selection in dark text */
|
|
75
|
+
.docx-run-dark-bg::selection,
|
|
76
|
+
.docx-run-dark-bg *::selection {
|
|
77
|
+
/* Use lighter selection for dark backgrounds */
|
|
78
|
+
background-color: rgba(100, 181, 246, 0.5) !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.docx-run-dark-bg::-moz-selection,
|
|
82
|
+
.docx-run-dark-bg *::-moz-selection {
|
|
83
|
+
background-color: rgba(100, 181, 246, 0.5) !important;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Programmatic highlight class */
|
|
87
|
+
.docx-selection-highlight {
|
|
88
|
+
background-color: ${e.backgroundColor};
|
|
89
|
+
${e.borderRadius?`border-radius: ${e.borderRadius}px;`:""}
|
|
90
|
+
${e.mixBlendMode?`mix-blend-mode: ${e.mixBlendMode};`:""}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Find/replace highlight */
|
|
94
|
+
.docx-find-highlight {
|
|
95
|
+
background-color: rgba(255, 235, 59, 0.5);
|
|
96
|
+
border-radius: 2px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.docx-find-highlight-current {
|
|
100
|
+
background-color: rgba(255, 152, 0, 0.6);
|
|
101
|
+
border-radius: 2px;
|
|
102
|
+
outline: 2px solid rgba(255, 152, 0, 0.8);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* AI action selection preview */
|
|
106
|
+
.docx-ai-selection-preview {
|
|
107
|
+
background-color: rgba(156, 39, 176, 0.2);
|
|
108
|
+
border-bottom: 2px dashed rgba(156, 39, 176, 0.6);
|
|
109
|
+
}
|
|
110
|
+
`;uo=document.createElement("style"),uo.id="docx-selection-styles",uo.textContent=t,document.head.appendChild(uo);}function TS(){uo&&(uo.remove(),uo=null);let e=document.getElementById("docx-selection-styles");e&&e.remove();}function gf(){return uo!==null||document.getElementById("docx-selection-styles")!==null}function mP(e,t,n=true){return ()=>{if(!e){t([]);return}let o=n?Rl(e):df(e);t(o);}}function SP(e){let{containerRef:t,enabled:n=true,config:o=Qo,useOverlay:r=false,debounceMs:i=16,onSelectionChange:a}=e,[s,l]=rf.useState(false),[u,d]=rf.useState(""),[c,p]=rf.useState([]),[f,m]=rf.useState(false),b=rf.useRef(null),g=rf.useRef(0),x=rf.useCallback(()=>{let C=t.current,P=uf(),_=pf(),q=C?ff(C):false;if(l(P),d(_),m(q),r&&q){let z=Rl(C);p(z);}else p([]);a&&a(P&&q,_);},[t,r,a]),T=rf.useCallback(()=>{let C=performance.now();if(C-g.current<i){b.current!==null&&clearTimeout(b.current),b.current=window.setTimeout(()=>{g.current=performance.now(),x(),b.current=null;},i);return}g.current=C,x();},[i,x]),S=rf.useCallback(()=>{x();},[x]),B=rf.useCallback(C=>({position:"absolute",left:`${C.left}px`,top:`${C.top}px`,width:`${C.width}px`,height:`${C.height}px`,backgroundColor:o.backgroundColor,borderRadius:o.borderRadius?`${o.borderRadius}px`:void 0,border:o.borderColor?`1px solid ${o.borderColor}`:void 0,zIndex:o.zIndex??0,opacity:o.opacity??1,mixBlendMode:o.mixBlendMode,pointerEvents:"none",userSelect:"none"}),[o]);return rf.useEffect(()=>(n&&!gf()&&mf(o),()=>{}),[n,o]),rf.useEffect(()=>{if(!n)return;let C=()=>{T();};return document.addEventListener("selectionchange",C),document.addEventListener("mouseup",C),x(),()=>{document.removeEventListener("selectionchange",C),document.removeEventListener("mouseup",C),b.current!==null&&clearTimeout(b.current);}},[n,T,x]),{hasSelection:s,selectedText:u,highlightRects:c,isSelectionInContainer:f,refresh:S,getOverlayStyle:B}}function kP(e,t=Qo){return e.map((n,o)=>rf__default.default.createElement("div",{key:`selection-overlay-${o}`,style:{position:"absolute",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,backgroundColor:t.backgroundColor,borderRadius:t.borderRadius?`${t.borderRadius}px`:void 0,border:t.borderColor?`1px solid ${t.borderColor}`:void 0,zIndex:t.zIndex??0,opacity:t.opacity??1,mixBlendMode:t.mixBlendMode,pointerEvents:"none",userSelect:"none"}}))}function EP(e={}){let{onCopy:t,onCut:n,onPaste:o,cleanWordFormatting:r=true,editable:i=true,onError:a}=e,s=rf.useRef(false),l=rf.useRef(null),u=rf.useCallback(async g=>{if(s.current)return false;s.current=true;try{let x=await chunk2KHL5RSD_js.M(g.runs,{onError:a});return x&&t?.(g),x}finally{s.current=false;}},[t,a]),d=rf.useCallback(async g=>{if(s.current||!i)return false;s.current=true;try{let x=await chunk2KHL5RSD_js.M(g.runs,{onError:a});return x&&n?.(g),x}finally{s.current=false;}},[n,i,a]),c=rf.useCallback(async(g=false)=>{if(s.current||!i)return null;s.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let x=await navigator.clipboard.read(),T="",S="";for(let C of x)C.types.includes("text/html")&&(T=await(await C.getType("text/html")).text()),C.types.includes("text/plain")&&(S=await(await C.getType("text/plain")).text());g&&(T="");let B=chunk2KHL5RSD_js.T(T,S,r);return l.current=B,o?.(B,g),B}return null}catch(x){return a?.(x),null}finally{s.current=false;}},[i,r,o,a]),p=rf.useCallback(g=>{let x=chunkFVUGBRDD_js.F();if(!x)return;g.preventDefault();let T=chunk2KHL5RSD_js.O(x.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",T.plainText),g.clipboardData.setData("text/html",T.html),T.internal&&g.clipboardData.setData("application/x-docx-editor",T.internal)),t?.(x);},[t]),f=rf.useCallback(g=>{if(!i)return;let x=chunkFVUGBRDD_js.F();if(!x)return;g.preventDefault();let T=chunk2KHL5RSD_js.O(x.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",T.plainText),g.clipboardData.setData("text/html",T.html),T.internal&&g.clipboardData.setData("application/x-docx-editor",T.internal)),n?.(x);},[i,n]),m=rf.useCallback(g=>{if(!i)return;g.preventDefault();let x=chunk2KHL5RSD_js.S(g,{cleanWordFormatting:r});if(x){l.current=x;let T=g.shiftKey??false;o?.(x,T);}},[i,r,o]),b=rf.useCallback(g=>{},[]);return {copy:u,cut:d,paste:c,handleCopy:p,handleCut:f,handlePaste:m,handleKeyDown:b,isProcessing:s.current,lastPastedContent:l.current}}var qa={position:"right",defaultSize:280,minSize:200,maxSize:500,resizable:true,collapsible:true,defaultCollapsed:false},Sf=chunkFVUGBRDD_js.I,kf=`
|
|
111
|
+
.plugin-host {
|
|
112
|
+
display: flex;
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
overflow: visible;
|
|
116
|
+
position: relative;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.plugin-host-editor {
|
|
120
|
+
flex: 1;
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
min-width: 0;
|
|
124
|
+
overflow: visible;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
.plugin-panels-left,
|
|
129
|
+
.plugin-panels-right {
|
|
130
|
+
display: flex;
|
|
131
|
+
flex-direction: column;
|
|
132
|
+
flex-shrink: 0;
|
|
133
|
+
background: #f8f9fa;
|
|
134
|
+
border-color: #e9ecef;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.plugin-panels-left {
|
|
138
|
+
border-right: 1px solid #e9ecef;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.plugin-panels-right {
|
|
142
|
+
border-left: 1px solid #e9ecef;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.plugin-panels-bottom {
|
|
146
|
+
border-top: 1px solid #e9ecef;
|
|
147
|
+
background: #f8f9fa;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.plugin-panel {
|
|
151
|
+
position: relative;
|
|
152
|
+
display: flex;
|
|
153
|
+
flex-direction: column;
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
transition: width 0.2s ease, height 0.2s ease;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.plugin-panel.collapsed {
|
|
159
|
+
overflow: visible;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.plugin-panel-toggle {
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
gap: 4px;
|
|
166
|
+
padding: 6px 8px;
|
|
167
|
+
background: transparent;
|
|
168
|
+
border: none;
|
|
169
|
+
cursor: pointer;
|
|
170
|
+
font-size: 12px;
|
|
171
|
+
color: #6c757d;
|
|
172
|
+
white-space: nowrap;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.plugin-panel.collapsed .plugin-panel-toggle {
|
|
176
|
+
writing-mode: vertical-rl;
|
|
177
|
+
text-orientation: mixed;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
height: 100%;
|
|
180
|
+
padding: 8px 6px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.plugin-panel-toggle:hover {
|
|
184
|
+
background: #e9ecef;
|
|
185
|
+
color: #495057;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.plugin-panel-toggle-icon {
|
|
189
|
+
font-weight: bold;
|
|
190
|
+
font-size: 14px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.plugin-panel.collapsed .plugin-panel-toggle-icon {
|
|
194
|
+
transform: rotate(90deg);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.plugin-panel-toggle-label {
|
|
198
|
+
font-weight: 500;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.plugin-panel-content {
|
|
202
|
+
flex: 1;
|
|
203
|
+
overflow: auto;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* Right panel rendered inside viewport - scrolls with content */
|
|
207
|
+
.plugin-panel-in-viewport {
|
|
208
|
+
position: absolute;
|
|
209
|
+
top: 0;
|
|
210
|
+
/* Position is set dynamically via inline styles based on page edge */
|
|
211
|
+
width: 220px;
|
|
212
|
+
pointer-events: auto;
|
|
213
|
+
z-index: 10;
|
|
214
|
+
overflow: visible;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.plugin-panel-in-viewport.collapsed {
|
|
218
|
+
width: 32px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.plugin-panel-in-viewport .plugin-panel-toggle {
|
|
222
|
+
position: sticky;
|
|
223
|
+
top: 0;
|
|
224
|
+
background: rgba(255, 255, 255, 0.95);
|
|
225
|
+
border-radius: 4px;
|
|
226
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.plugin-panel-in-viewport-content {
|
|
230
|
+
overflow: visible;
|
|
231
|
+
position: relative;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* Plugin overlay container for rendering highlights/decorations */
|
|
235
|
+
.plugin-overlays-container {
|
|
236
|
+
position: absolute;
|
|
237
|
+
top: 0;
|
|
238
|
+
left: 0;
|
|
239
|
+
right: 0;
|
|
240
|
+
bottom: 0;
|
|
241
|
+
pointer-events: none;
|
|
242
|
+
overflow: visible;
|
|
243
|
+
z-index: 5;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.plugin-overlay {
|
|
247
|
+
position: absolute;
|
|
248
|
+
top: 0;
|
|
249
|
+
left: 0;
|
|
250
|
+
right: 0;
|
|
251
|
+
bottom: 0;
|
|
252
|
+
pointer-events: none;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* Individual overlay children manage their own pointer-events.
|
|
256
|
+
Do NOT set pointer-events: auto here \u2014 it overrides overlay containers
|
|
257
|
+
that need pointer-events: none to let clicks pass through to the editor. */
|
|
258
|
+
`,PS=rf.forwardRef(function({plugins:t,children:n,className:o=""},r){let[i,a]=rf.useState(null),s=rf.useRef(n.props);s.current=n.props;let[l,u]=rf.useState(null),d=rf.useMemo(()=>new chunkFVUGBRDD_js.J,[]),c=rf.useSyncExternalStore(d.subscribe,d.getSnapshot),[p,f]=rf.useState(()=>{let A=new Set;for(let O of t)({...qa,...O.panelConfig}).defaultCollapsed&&A.add(O.id);return A}),[m]=rf.useState(()=>{let A=new Map;for(let O of t){let ie={...qa,...O.panelConfig};A.set(O.id,ie.defaultSize);}return A});rf.useEffect(()=>{if(!i)return;let A=t.map(O=>({id:O.id,styles:O.styles,initialize:O.initialize,onStateChange:O.onStateChange,destroy:O.destroy}));return d.initialize(A,i),()=>{d.destroy();}},[d,i,t]),rf.useEffect(()=>{let A=t.filter(O=>O.styles).map(O=>Sf(O.id,O.styles));return ()=>A.forEach(O=>O())},[t]),rf.useEffect(()=>{if(!i?.dom)return;let A=()=>{d.updateStates(i);},O=null,ie=()=>{O&&cancelAnimationFrame(O),O=requestAnimationFrame(A);};A();let ae=i.dom;ae.addEventListener("input",ie),ae.addEventListener("focus",A),ae.addEventListener("click",A);let N=i.dispatch.bind(i);return i.dispatch=Ie=>{N(Ie),ie();},()=>{ae.removeEventListener("input",ie),ae.removeEventListener("focus",A),ae.removeEventListener("click",A),O&&cancelAnimationFrame(O),i.dispatch=N;}},[i,d]),rf.useEffect(()=>Sf("plugin-host-base",kf),[]);let b=rf.useCallback(A=>{if(!i)return;if(i.coordsAtPos(A)){i.dom.scrollIntoView({block:"center",inline:"nearest"});let{state:ie}=i,ae=ie.doc.resolve(Math.min(A,ie.doc.content.size)),N=ie.tr.setSelection(prosemirrorState.TextSelection.near(ae));i.dispatch(N),i.focus();}},[i]),g=rf.useCallback((A,O)=>{if(!i)return;let{state:ie}=i,ae=ie.doc.content.size,N=Math.max(0,Math.min(A,ae)),Ie=Math.max(0,Math.min(O,ae)),Fe=ie.tr.setSelection(prosemirrorState.TextSelection.create(ie.doc,N,Ie));i.dispatch(Fe),i.focus();},[i]),x=rf.useCallback(A=>d.getPluginState(A),[d]),T=rf.useCallback((A,O)=>{d.setPluginState(A,O);},[d]),S=rf.useCallback(()=>{i&&d.updateStates(i);},[i,d]);rf.useImperativeHandle(r,()=>({getPluginState:x,setPluginState:T,getEditorView:()=>i,refreshPluginStates:S}),[x,T,i,S]);let B=rf.useMemo(()=>{let A=[];for(let O of t)O.proseMirrorPlugins&&A.push(...O.proseMirrorPlugins);return A},[t]),C=rf.useCallback(A=>{f(O=>{let ie=new Set(O);return ie.has(A)?ie.delete(A):ie.add(A),ie});},[]),[P,_]=rf.useState(null);rf.useEffect(()=>{if(!l){_(null);return}let A=()=>{let ae=l.pagesContainer,N=ae.querySelector(".layout-page");if(!N){_(null);return}let Ie=l.getContainerOffset(),Fe=N.getBoundingClientRect(),Ve=ae.getBoundingClientRect(),M=(Fe.right-Ve.left)/l.zoom,F=Ie.x+M+5;_(F);};A();let O=()=>{requestAnimationFrame(A);};window.addEventListener("resize",O);let ie=new ResizeObserver(()=>{requestAnimationFrame(A);});return ie.observe(l.pagesContainer),()=>{window.removeEventListener("resize",O),ie.disconnect();}},[l]);let q=rf.useMemo(()=>{let A=[];if(l){for(let O of t)if(O.renderOverlay){let ie=c.states.get(O.id);A.push(jsxRuntime.jsx("div",{className:"plugin-overlay","data-plugin-id":O.id,children:O.renderOverlay(l,ie,i)},`overlay-${O.id}`));}}for(let O of t){if(!O.Panel||(O.panelConfig?.position??"right")!=="right")continue;let ae={...qa,...O.panelConfig},N=p.has(O.id),Ie=m.get(O.id)??ae.defaultSize,Fe=O.Panel,Ve=c.states.get(O.id),M=P!==null?`${P}px`:"calc(50% + 428px)";A.push(jsxRuntime.jsxs("div",{className:`plugin-panel-in-viewport ${N?"collapsed":""}`,style:{width:N?"32px":`${Ie}px`,left:M},"data-plugin-id":O.id,children:[ae.collapsible&&jsxRuntime.jsx("button",{className:"plugin-panel-toggle",onClick:()=>C(O.id),title:N?`Show ${O.name}`:`Hide ${O.name}`,"aria-label":N?`Show ${O.name}`:`Hide ${O.name}`,children:jsxRuntime.jsx("span",{className:"plugin-panel-toggle-icon",children:N?"\u2039":"\u203A"})}),!N&&l&&jsxRuntime.jsx("div",{className:"plugin-panel-in-viewport-content",children:jsxRuntime.jsx(Fe,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:g,pluginState:Ve,panelWidth:Ie,renderedDomContext:l})})]},`panel-overlay-${O.id}`));}return A.length>0?A:null},[l,t,c.version,i,p,m,b,g,C,P]),z=rf.useCallback(A=>{u(A);let O=s.current?.onRenderedDomContextReady;typeof O=="function"&&O(A);},[]),H=rf.useMemo(()=>rf.cloneElement(n,{externalPlugins:B,pluginOverlays:q,onRenderedDomContextReady:z,onEditorViewReady:A=>{a(A);let O=s.current?.onEditorViewReady;typeof O=="function"&&O(A);}}),[n,B,q,z]),ee=rf.useMemo(()=>{let A=[],O=[],ie=[];for(let ae of t){if(!ae.Panel)continue;let N=ae.panelConfig?.position??"right";N==="left"?A.push(ae):N==="bottom"?ie.push(ae):O.push(ae);}return {left:A,right:O,bottom:ie}},[t]),ue=A=>{if(!A.Panel)return null;let O={...qa,...A.panelConfig},ie=p.has(A.id),ae=m.get(A.id)??O.defaultSize,N=A.Panel,Ie=c.states.get(A.id);return jsxRuntime.jsxs("div",{className:`plugin-panel plugin-panel-${O.position} ${ie?"collapsed":""}`,style:{[O.position==="bottom"?"height":"width"]:ie?"32px":`${ae}px`,minWidth:O.position!=="bottom"?ie?"32px":`${O.minSize}px`:void 0,maxWidth:O.position!=="bottom"?`${O.maxSize}px`:void 0,minHeight:O.position==="bottom"?ie?"32px":`${O.minSize}px`:void 0,maxHeight:O.position==="bottom"?`${O.maxSize}px`:void 0},"data-plugin-id":A.id,children:[O.collapsible&&jsxRuntime.jsxs("button",{className:"plugin-panel-toggle",onClick:()=>C(A.id),title:ie?`Show ${A.name}`:`Hide ${A.name}`,"aria-label":ie?`Show ${A.name}`:`Hide ${A.name}`,children:[jsxRuntime.jsx("span",{className:"plugin-panel-toggle-icon",children:ie?"\u203A":"\u2039"}),ie&&jsxRuntime.jsx("span",{className:"plugin-panel-toggle-label",children:A.name})]}),!ie&&jsxRuntime.jsx("div",{className:"plugin-panel-content",children:jsxRuntime.jsx(N,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:g,pluginState:Ie,panelWidth:ae,renderedDomContext:l??null})})]},A.id)};return jsxRuntime.jsxs("div",{className:`plugin-host ${o}`,children:[ee.left.length>0&&jsxRuntime.jsx("div",{className:"plugin-panels-left",children:ee.left.map(ue)}),jsxRuntime.jsxs("div",{className:"plugin-host-editor",children:[H,ee.bottom.length>0&&jsxRuntime.jsx("div",{className:"plugin-panels-bottom",children:ee.bottom.map(ue)})]})]})});exports.A=SS;exports.B=Rl;exports.C=sP;exports.D=lP;exports.E=uf;exports.F=pf;exports.G=ff;exports.H=cP;exports.I=dP;exports.J=uP;exports.K=pP;exports.L=kS;exports.M=fP;exports.N=mf;exports.O=TS;exports.P=gf;exports.Q=mP;exports.R=SP;exports.S=kP;exports.T=EP;exports.U=kf;exports.V=PS;exports.a=zt;exports.b=KS;exports.c=kc;exports.d=si;exports.e=YS;exports.f=qS;exports.g=XS;exports.h=ZS;exports.i=wc;exports.j=of;exports.k=NM;exports.l=GM;exports.m=fn;exports.n=qM;exports.o=XM;exports.p=ZM;exports.q=JM;exports.r=QM;exports.s=eP;exports.t=tP;exports.u=nP;exports.v=oP;exports.w=Qo;exports.x=iP;exports.y=aP;exports.z=df;
|