@eigenpal/docx-js-editor 0.0.30 → 0.0.32
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-D0D4aUKE.d.ts → ClipboardManager-C0rTRkVQ.d.ts} +29 -1
- package/dist/{ClipboardManager-t936d0KD.d.mts → ClipboardManager-CgpKW2At.d.mts} +29 -1
- package/dist/PageSetupDialog-2SKHDRTF.js +1 -0
- package/dist/PageSetupDialog-SMQJXEBL.mjs +1 -0
- package/dist/chunk-2HDYCD2Q.mjs +1 -0
- package/dist/chunk-37SLIJPH.mjs +58 -0
- package/dist/{chunk-KCUPCJFL.mjs → chunk-6AJI5NPH.mjs} +1 -1
- package/dist/chunk-7MGFEP2R.mjs +26 -0
- package/dist/chunk-7QTNB64A.mjs +9 -0
- package/dist/chunk-EEV6TUOX.mjs +261 -0
- package/dist/chunk-EF3LLEN7.js +4 -0
- package/dist/chunk-EV3CM6TU.js +1 -0
- package/dist/chunk-HWWZOJMR.mjs +4 -0
- package/dist/{chunk-VHWEKJ35.js → chunk-KCOGY3V2.js} +5 -5
- package/dist/chunk-KUL2SDYC.js +26 -0
- package/dist/chunk-P7WEP4JU.js +9 -0
- package/dist/{chunk-Z35FA4M4.mjs → chunk-RTFUE3KK.mjs} +5 -5
- package/dist/{chunk-XGL3EGKF.js → chunk-UMDJQ3Q4.js} +4 -4
- package/dist/chunk-WH2EK2HU.js +261 -0
- package/dist/chunk-ZJNGMDRE.js +58 -0
- package/dist/core-plugins-reexport.js +1 -1
- package/dist/core-plugins-reexport.mjs +1 -1
- package/dist/core-reexport.d.mts +2 -2
- package/dist/core-reexport.d.ts +2 -2
- package/dist/core-reexport.js +1 -1
- package/dist/core-reexport.mjs +1 -1
- package/dist/headless-reexport.js +2 -2
- package/dist/headless-reexport.mjs +1 -1
- package/dist/index.d.mts +10 -27
- package/dist/index.d.ts +10 -27
- package/dist/index.js +23 -66
- package/dist/index.mjs +23 -66
- package/dist/mcp-reexport.js +10 -10
- package/dist/mcp-reexport.mjs +9 -9
- package/dist/{react-C-pJU0Y4.d.mts → react-B2h6vE3D.d.mts} +118 -83
- package/dist/{react-By80Gfi-.d.ts → react-CAc4htNH.d.ts} +118 -83
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -1
- package/dist/selectionRects-DEX5THEG.js +1 -0
- package/dist/selectionRects-SQTAHMCH.mjs +1 -0
- package/dist/styles.css +1 -1
- package/dist/ui.js +1 -1
- package/dist/ui.mjs +1 -1
- package/package.json +2 -1
- package/dist/PageSetupDialog-3QCVUNDL.mjs +0 -1
- package/dist/PageSetupDialog-ZZTFPZKJ.js +0 -1
- package/dist/chunk-2KHL5RSD.js +0 -4
- package/dist/chunk-7HZRJTOL.mjs +0 -4
- package/dist/chunk-CQRI4YUS.mjs +0 -26
- package/dist/chunk-G72SXG7G.js +0 -258
- package/dist/chunk-I6LFWQFR.mjs +0 -59
- package/dist/chunk-IRO7KGGC.js +0 -59
- package/dist/chunk-MRWJ3GNH.js +0 -9
- package/dist/chunk-MVCTPHRR.mjs +0 -258
- package/dist/chunk-QQ63M65M.js +0 -1
- package/dist/chunk-TDEHAPMZ.mjs +0 -1
- package/dist/chunk-VR6PT4IZ.js +0 -26
- package/dist/chunk-YGTSQZRK.mjs +0 -9
- package/dist/selectionRects-6TRAXB7D.js +0 -1
- package/dist/selectionRects-IS7ZAS3A.mjs +0 -1
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import {e,q,p,n,o,f as f$2,c as c$1,d as d$2,a as a$4,l as l$2,h as h$2,g as g$2,k as k$1,i as i$2,j as j$2,m as m$2}from'./chunk-2HDYCD2Q.mjs';import {i,z,C,A,d,E,c,Z,ea as ea$1,ma as ma$1,la as la$1,fa as fa$1,ka as ka$1,ia as ia$1,ja,ha as ha$1,w,a as a$2,y,L,M,T,O,S,x,e as e$2,f as f$3}from'./chunk-HWWZOJMR.mjs';import {m,j,l as l$1}from'./chunk-XWBCP563.mjs';import {m as m$1}from'./chunk-AZRYS2WF.mjs';import {J,C as C$1,z as z$1,B,A as A$1,H,I,r,F}from'./chunk-QTSXJRP6.mjs';import {f}from'./chunk-7QTNB64A.mjs';import {a,n as n$2,c as c$3}from'./chunk-QAZ4233N.mjs';import {a as a$1}from'./chunk-M5F4SK3W.mjs';import {l,n as n$1,h,b}from'./chunk-7MGFEP2R.mjs';import {a as a$3,b as b$1,k,g as g$1,c as c$2,j as j$1,d as d$3,i as i$3,h as h$3}from'./chunk-LYBG4YI7.mjs';import {d as d$1,f as f$1,g,i as i$1,e as e$1,h as h$1}from'./chunk-TAUMSKRE.mjs';import Qf,{createContext,forwardRef,useRef,useState,useLayoutEffect,useEffect,useCallback,useImperativeHandle,memo,useMemo,lazy,Suspense,useSyncExternalStore,cloneElement,Component,useContext,Children,isValidElement}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {PluginKey,EditorState,NodeSelection,TextSelection,Plugin,Selection}from'prosemirror-state';import {EditorView,DecorationSet,Decoration}from'prosemirror-view';import {redo,undo,history}from'prosemirror-history';import {Schema,Fragment as Fragment$1}from'prosemirror-model';import {toggleMark,selectParentNode,selectAll,baseKeymap,splitBlock,joinForward,deleteSelection,joinBackward}from'prosemirror-commands';import {CellSelection,splitCell,mergeCells,columnResizing,tableEditing}from'prosemirror-tables';import {dropCursor}from'prosemirror-dropcursor';import {AddMarkStep,RemoveMarkStep,AddNodeMarkStep,RemoveNodeMarkStep}from'prosemirror-transform';import {keymap}from'prosemirror-keymap';import'prosemirror-view/style/prosemirror.css';import {toast,Toaster}from'sonner';import {createRoot}from'react-dom/client';function Km(){return jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[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"}),jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function Ys({children:e}){return jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function Gm(e){return e.replace(/\.docx$/i,"")}function Xc({value:e,onChange:t,placeholder:n="Untitled",editable:o=true}){let r=Gm(e);return o?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"}):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 qs({children:e}){return jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function Xs(){let e=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=useCallback(b=>{!t&&n&&n(b);},[t,n]),f=useCallback((b,g)=>{!t&&s&&(s(b,g),requestAnimationFrame(()=>c?.()));},[t,s,c]);return jsxs("div",{className:"flex items-center",role:"menubar","aria-label":"Menu bar",children:[(r&&o||i)&&jsx(e$2,{label:"File",disabled:t,items:[...r&&o?[{icon:"print",label:"Print",shortcut:"Ctrl+P",onClick:o}]:[],...i?[{icon:"settings",label:"Page setup",onClick:i}]:[]]}),jsx(e$2,{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")}]}),jsx(e$2,{label:"Insert",disabled:t,items:[...a?[{icon:"image",label:"Image",onClick:a}]:[],...l&&s?[{icon:"grid_on",label:"Table",submenuContent:b=>jsx(f$3,{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 Zc({children:e}){let t=null,n=null,o=[],r=[];Children.forEach(e,a=>{isValidElement(a)&&(a.type===Ys?t=a:a.type===qs?n=a:a.type===Xs?r.push(a):o.push(a));});let i=useCallback(a=>{let s=a.target;s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.tagName==="SELECT"||s.tagName==="OPTION"||a.preventDefault();},[]);return jsxs("div",{className:"flex items-stretch bg-white pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsx(Km,{})}),jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[o.length>0&&jsx("div",{className:"flex items-center gap-2 px-1",children:o}),r.length>0&&jsx("div",{className:"flex items-center px-1",children:r})]}),n&&jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:n})]})}function Ym({children:e,className:t,...n}){return jsx(w.Provider,{value:n,children:jsx("div",{className:a$2("flex flex-col bg-white shadow-sm flex-shrink-0",t),"data-testid":"editor-toolbar",children:e})})}var _t=Ym;_t.TitleBar=Zc;_t.Logo=Ys;_t.DocumentName=Xc;_t.MenuBar=Xs;_t.TitleBarRight=qs;_t.FormattingBar=y;var ed=createContext(null);function tC(){let e=useContext(ed);if(!e)throw new Error("useErrorNotifications must be used within an ErrorProvider");return e}function td({children:e}){let t=useMemo(()=>new H,[]),n=useSyncExternalStore(t.subscribe,t.getSnapshot),o=useCallback((u,d)=>{t.showError(u,d);},[t]),r=useCallback((u,d)=>{t.showWarning(u,d);},[t]),i=useCallback((u,d)=>{t.showInfo(u,d);},[t]),a=useCallback(u=>{t.dismiss(u);},[t]),s=useCallback(()=>{t.clearAll();},[t]),l=useMemo(()=>({notifications:n.notifications,showError:o,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:s}),[n.notifications,o,r,i,a,s]);return jsxs(ed.Provider,{value:l,children:[e,jsx(eg,{notifications:n.notifications,onDismiss:a})]})}function eg({notifications:e,onDismiss:t}){let n=e.filter(r=>!r.dismissed);return n.length===0?null: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=>jsx(tg,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function tg({notification:e,onDismiss:t}){let[n,o]=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 jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxs("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:a,children:[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
|
+
`}),jsxs("div",{style:s,children:[jsx("span",{style:l,children:f(e.severity)}),jsxs("div",{style:u,children:[jsx("div",{style:d,children:e.message}),e.details&&jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>o(!n),style:{...p,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:n?"Hide details":"Show details"}),n&&jsx("div",{style:c,children:e.details})]})]}),jsx("button",{type:"button",onClick:t,style:p,title:"Dismiss",children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var Ri=class extends Component{constructor(n){super(n);d$1(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:jsx(ng,{error:r,errorInfo:i,showDetails:o,onReset:this.resetError})}return this.props.children}};function ng({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 jsxs("div",{className:"docx-error-fallback",style:r,children:[jsx("div",{style:i,children:jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsx("h2",{style:a,children:"Something went wrong"}),jsx("p",{style:s,children:"An error occurred while rendering this component. Please try again or contact support if the problem persists."}),n&&jsxs("div",{style:l,children:[jsx("strong",{children:"Error:"})," ",e.message,t&&jsxs(Fragment,{children:[`
|
|
13
|
+
|
|
14
|
+
`,jsx("strong",{children:"Component Stack:"}),t.componentStack]})]}),jsx("button",{type:"button",onClick:o,style:u,children:"Try Again"})]})}function nC({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 jsxs("div",{className:`docx-parse-error ${o}`,style:r,children:[jsx("div",{style:i,children:jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",children:[jsx("path",{d:"M10 10h20v20H10z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),jsx("path",{d:"M25 10l-10 20M15 10l10 20",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsx("h3",{style:a,children:"Unable to Parse Document"}),jsx("p",{style:s,children:e}),t&&jsx("div",{style:l,children:t}),n&&jsx("button",{type:"button",onClick:n,style:u,children:"Try Again"})]})}function oC({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 jsxs("div",{className:`docx-unsupported-warning ${n}`,style:o,children:[jsx("span",{style:r,children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsx("path",{d:"M8 2l7 12H1L8 2z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsx("path",{d:"M8 6v4M8 12v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),jsxs("span",{children:[jsx("strong",{children:e}),t&&`: ${t}`]})]})}function rC(e){return e.message.includes("parse")||e.message.includes("Parse")||e.message.includes("XML")||e.message.includes("DOCX")||e.message.includes("Invalid")}function iC(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 od({document:e,onChange:t,onSelectionChange:n}){let o=useMemo(()=>new C$1,[]),[r,i]=useState({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),a=useCallback((d,c,p)=>{if(!e)return;let f=z$1(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=ea$1(f,{tableIndex:d,rowIndex:c,columnIndex:p});i({context:b,table:f,tableIndex:d,rowIndex:c,columnIndex:p}),n?.(b);},[e,o,n]),s=useCallback(()=>{o.clearSelection(),i({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),n?.(null);},[o,n]),l=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=ha$1(c,r.rowIndex,"before"),m=r.rowIndex+1;break;case "addRowBelow":p=ha$1(c,r.rowIndex,"after");break;case "addColumnLeft":p=ja(c,r.columnIndex,"before"),b=r.columnIndex+1;break;case "addColumnRight":p=ja(c,r.columnIndex,"after");break;case "deleteRow":c.rows.length>1&&(p=ia$1(c,r.rowIndex),m>=p.rows.length&&(m=p.rows.length-1));break;case "deleteColumn":{if(fa$1(c)>1){p=ka$1(c,r.columnIndex);let x=fa$1(p);b>=x&&(b=x-1);}break}case "mergeCells":r.context.selection.selectedCells&&(p=la$1(c,r.context.selection));break;case "splitCell":r.context.canSplitCell&&(p=ma$1(c,r.rowIndex,r.columnIndex));break;case "deleteTable":f=B(e,r.tableIndex),s(),t?.(f);return}p&&(f=A$1(e,r.tableIndex,p),t?.(f),f&&a(r.tableIndex,m,b));},[e,r,t,s,a]),u=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 id=({headings:e,onHeadingClick:t,onClose:n,topOffset:o=0})=>{let[r,i]=useState(false);return useEffect(()=>{requestAnimationFrame(()=>i(true));},[]),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:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px"},children:[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:jsx(d,{name:"arrow_back",size:20})}),jsx("span",{style:{fontWeight:400,fontSize:14,color:"#1f1f1f",letterSpacing:"0.01em"},children:"Outline"})]}),jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:20},children:e.length===0?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)=>jsx("div",{style:{marginLeft:a.level*12},children: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 ad(e,t,n,o,r,i){if(e.length===0)return [];let a=n?.getContainerOffset(),s=[];for(let d of e){let c;if(d.fixedY!=null&&(c=d.fixedY*o),c==null&&d.anchorKey){let p=t.get(d.anchorKey);p!=null&&(c=p*o);}if(c==null&&n){let p=n.getRectsForRange(d.anchorPos,d.anchorPos+1);p.length>0&&a&&(c=(p[0].y+a.y)*o);}if(c==null){let p=i.get(d.id);p!=null&&(c=p);}c!=null&&(s.push({item:d,targetY:c}),i.set(d.id,c));}s.sort((d,c)=>{let p=d.targetY-c.targetY;return p!==0?p:(d.item.priority??0)-(c.item.priority??0)});let l=[],u=0;for(let d of s){let c=r.get(d.item.id)??d.item.estimatedHeight??80,p=Math.max(d.targetY,u+8);l.push({item:d.item,y:p}),u=p+c;}return l}function dd({items:e,anchorPositions:t,renderedDomContext:n,pageWidth:o,zoom:r,editorContainerRef:i,onExpandedItemChange:a}){let[s,l]=useState(null);useEffect(()=>{a?.(s);},[s,a]);let[u,d]=useState(false),c=useRef(new Map),p=useRef(new Map),f=useRef(new Set),m=useRef(null),b=useRef(new Map),g=useRef(new Map),[x,T]=useState(0),S=useMemo(()=>ad(e,t,n,r,c.current,p.current),[e,t,n,r,x]),B=S.length>0,v=useMemo(()=>{let D=new Map;for(let P of S)D.set(P.item.id,P.y);return D},[S]);useEffect(()=>{for(let D of S)f.current.add(D.item.id);},[S]),useEffect(()=>{let D=setTimeout(()=>T(I=>I+1),50),P=setTimeout(()=>{T(I=>I+1),d(true);},400);return ()=>{clearTimeout(D),clearTimeout(P);}},[e.length]),useEffect(()=>{let D=i?.current;if(!D)return;let P=new ResizeObserver(()=>{requestAnimationFrame(()=>T(I=>I+1));});return P.observe(D),()=>P.disconnect()},[i]),useEffect(()=>{let D=requestAnimationFrame(()=>{for(let[P,I]of b.current)c.current.set(P,I.offsetHeight);T(P=>P+1);});return ()=>cancelAnimationFrame(D)},[s]),useEffect(()=>{if(!s)return;let D=b.current.get(s);if(!D){let J=requestAnimationFrame(()=>T(se=>se+1));return ()=>cancelAnimationFrame(J)}let P,I=new ResizeObserver(()=>{cancelAnimationFrame(P),P=requestAnimationFrame(()=>{c.current.set(s,D.offsetHeight),T(J=>J+1);});});return I.observe(D),()=>{cancelAnimationFrame(P),I.disconnect();}},[s]),useEffect(()=>{let D=i?.current;if(!D)return;let P=D.querySelector(".paged-editor__pages");if(!P)return;let I=J=>{let se=J.target;if(!m.current?.contains(se)){if(P.contains(se)){let ie=se.closest("[data-comment-id]");if(ie?.dataset.commentId){l(`comment-${ie.dataset.commentId}`);return}let z=se.closest(".docx-insertion")||se.closest(".docx-deletion");if(z?.dataset.revisionId){let N=`tc-${z.dataset.revisionId}-`,ue=e.find(me=>me.id.startsWith(N));if(ue){l(ue.id);return}}}l(null);}};return D.addEventListener("click",I),()=>D.removeEventListener("click",I)},[i,e]);let E=useCallback(D=>{let P=g.current.get(D);return P||(P=I=>{I?(b.current.set(D,I),c.current.set(D,I.offsetHeight)):(b.current.delete(D),c.current.delete(D));},g.current.set(D,P)),P},[]),V=useCallback(D=>{l(P=>P===D?null:D);},[]);return e.length===0?null:jsx("aside",{ref:m,className:"docx-unified-sidebar",role:"complementary","aria-label":"Annotations sidebar",style:{position:"absolute",top:0,left:`calc(50% - ${176}px + ${o*r/2+12}px)`,width:340,fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,backgroundColor:"transparent",overflowY:"visible",overflowX:"visible",opacity:B?1:0,transition:"opacity 0.15s ease"},onMouseDown:D=>D.stopPropagation(),children:jsx("div",{style:{position:"relative"},children:e.map(D=>{let P=v.get(D.id),I=s===D.id,se=!f.current.has(D.id)&&P!==void 0,ie=B&&!v.has(D.id),z=B?P!==void 0?{position:"absolute",top:P,left:0,right:0,opacity:1}:{position:"absolute",top:0,left:0,right:0,opacity:0,visibility:"hidden"}:{marginBottom:6},N=ie?"none":se||D.isTemporary?"opacity 0.2s ease":u?"opacity 0.2s ease, top 0.15s ease":"none";return jsx("div",{style:{...z,transition:N},children:D.render({isExpanded:I,onToggleExpand:()=>V(D.id),measureRef:E(D.id)})},D.id)})})})}function ud({comments:e,anchorPositions:t,zoom:n,pageWidth:o,sidebarOpen:r,resolvedCommentIds:i,onMarkerClick:a}){let l=e.filter(u=>u.parentId==null).map(u=>{let d=i.has(u.id);if(!d&&r||d&&r)return null;let c=t.get(`comment-${u.id}`);return c==null?null:{comment:u,isResolved:d,y:c}}).filter(Boolean);return l.length===0?null:jsx("div",{className:"docx-comment-margin-markers",style:{position:"absolute",top:0,left:`calc(50% + ${o*n/2+6}px)`,zIndex:30,pointerEvents:"none"},onMouseDown:u=>u.stopPropagation(),children:l.map(({comment:u,isResolved:d$1,y:c})=>jsx("button",{onClick:()=>a(u.id),title:d$1?"Resolved comment":"Comment",style:{position:"absolute",top:c*n,left:0,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",borderRadius:4,background:"transparent",cursor:"pointer",pointerEvents:"auto",color:"#5f6368",padding:0,fontFamily:"inherit"},onMouseOver:p=>{p.currentTarget.style.opacity="0.7";},onMouseOut:p=>{p.currentTarget.style.opacity="1";},children:jsx(d,{name:d$1?"chat_bubble_check":"chat_bubble_outline",size:18})},u.id))})}function Pi(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 Wo(e){return e?new Date(e).toLocaleString(void 0,{hour:"numeric",minute:"2-digit",month:"short",day:"numeric"}):""}function Vo(e){return e.split(/\s+/).map(t=>t[0]).join("").toUpperCase().slice(0,2)}var pd=["#6DCCB1","#79AAD9","#EE789D","#A987D1","#E6A85F","#F2CC8F","#68B3A2","#B07AA1","#59A14F","#FF9DA7","#E15759","#76B7B2"];function sg(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return pd[Math.abs(t)%pd.length]}var Uo={background:"none",border:"none",cursor:"pointer",padding:4,color:"#5f6368",display:"flex",borderRadius:"50%"},Mi={padding:"6px 16px",fontSize:14,border:"none",background:"none",color:"#1a73e8",cursor:"pointer",fontWeight:500,fontFamily:"inherit"};function jo(e,t=32){return {width:t,height:t,borderRadius:"50%",backgroundColor:sg(e),color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:t===32?13:11,fontWeight:500,flexShrink:0}}function Ii(e){return {padding:"6px 16px",fontSize:14,border:"none",borderRadius:20,background:e?"#1a73e8":"#f1f3f4",color:e?"#fff":"#80868b",cursor:e?"pointer":"default",fontWeight:500,fontFamily:"inherit"}}function Li({replies:e,isExpanded:t}){if(e.length===0)return null;let n=t?e:e.slice(-1),o=t?0:e.length-1;return jsxs("div",{style:{marginTop:8},children:[o>0&&jsxs("div",{style:{fontSize:12,fontWeight:500,color:"#1a73e8",paddingTop:6,paddingBottom:6,borderTop:"1px solid #e8eaed"},children:[o," more ",o===1?"reply":"replies"]}),n.map(r=>jsxs("div",{style:{marginBottom:t?8:0,paddingTop:8,borderTop:"1px solid #e8eaed"},children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsx("div",{style:jo(r.author||"U",28),children:Vo(r.author||"U")}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:r.author||"Unknown"}),jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Wo(r.date)})]})]}),jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:4,...t?{}:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"}},children:Pi(r.content)})]},r.id))]})}var lg={width:"100%",border:"1px solid #1a73e8",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",boxSizing:"border-box",color:"#202124"},cg={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"};function Bi({onSubmit:e}){let[t,n]=useState(false),[o,r]=useState("");if(!t)return jsx("div",{onClick:a=>a.stopPropagation(),style:{marginTop:12},children:jsx("input",{readOnly:true,onMouseDown:a=>a.stopPropagation(),onClick:a=>{a.stopPropagation(),n(true);},placeholder:"Reply or add others with @",style:cg})});let i=o.trim();return jsxs("div",{onClick:a=>a.stopPropagation(),style:{marginTop:12},children:[jsx("input",{ref:a=>a?.focus({preventScroll:true}),type:"text",value:o,onChange:a=>r(a.target.value),onMouseDown:a=>a.stopPropagation(),onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"&&(a.preventDefault(),i&&e(i),r(""),n(false)),a.key==="Escape"&&(n(false),r(""));},placeholder:"Reply or add others with @",style:lg}),jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsx("button",{onClick:a=>{a.stopPropagation(),n(false),r("");},style:Mi,children:"Cancel"}),jsx("button",{onClick:a=>{a.stopPropagation(),i&&e(i),r(""),n(false);},disabled:!i,style:Ii(!!i),children:"Reply"})]})]})}var Ai={padding:"8px 10px",borderRadius:8,backgroundColor:"#f8fbff",cursor:"pointer",boxShadow:"0 1px 3px rgba(60,64,67,0.2), 0 2px 6px rgba(60,64,67,0.08)"},Di={padding:"10px 12px",borderRadius:8,backgroundColor:"#fff",cursor:"pointer",boxShadow:"0 1px 3px rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15)"};function gd({comment:e,replies:t,isExpanded:n,onToggleExpand:o,measureRef:r,onReply:i,onResolve:a,onUnresolve:s,onDelete:l}){let[u,d$1]=useState(false);return jsxs("div",{ref:r,"data-comment-id":e.id,className:"docx-comment-card",onClick:o,onMouseDown:c=>c.stopPropagation(),style:{...n?Di:Ai},children:[e.done&&jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",marginBottom:8,fontSize:11,fontWeight:500,color:"#188038",backgroundColor:"#e6f4ea",borderRadius:10},children:[jsx(d,{name:"check",size:12}),"Resolved"]}),jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsx("div",{style:jo(e.author||"U"),children:Vo(e.author||"U")}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:e.author||"Unknown"}),jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Wo(e.date)})]}),n&&jsxs("div",{style:{display:"flex",gap:4,marginTop:2,position:"relative"},children:[jsx("button",{onClick:c=>{c.stopPropagation(),e.done?s?.(e.id):a?.(e.id);},title:e.done?"Reopen":"Resolve",style:Uo,children:jsx(d,{name:e.done?"undo":"check",size:20})}),jsx("button",{onClick:c=>{c.stopPropagation(),d$1(!u);},title:"More options",style:Uo,children:jsx(d,{name:"more_vert",size:20})}),u&&jsx("div",{onClick:c=>c.stopPropagation(),onMouseDown:c=>c.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:jsx("button",{onClick:()=>{d$1(false),l?.(e.id);},style:{display:"block",width:"100%",padding:"8px 16px",border:"none",background:"none",textAlign:"left",fontSize:14,color:"#202124",cursor:"pointer",fontFamily:"inherit"},onMouseOver:c=>{c.target.style.backgroundColor="#f1f3f4";},onMouseOut:c=>{c.target.style.backgroundColor="transparent";},children:"Delete"})})]})]}),jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:6},children:Pi(e.content)}),jsx(Li,{replies:t,isExpanded:n}),n&&!e.done&&jsx(Bi,{onSubmit:c=>i?.(e.id,c)})]})}function hd({change:e,replies:t,isExpanded:n,onToggleExpand:o,measureRef:r,onAccept:i,onReject:a,onReply:s}){let l=e.author||"Unknown";return jsxs("div",{ref:r,className:"docx-tracked-change-card",onClick:()=>o(),onMouseDown:u=>u.stopPropagation(),style:n?Di:Ai,children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsx("div",{style:jo(l),children:Vo(l)}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:l}),e.date&&jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Wo(e.date)})]}),n&&jsxs("div",{style:{display:"flex",gap:4,marginTop:2},children:[jsx("button",{onClick:u=>{u.stopPropagation(),i?.(e.from,e.to);},title:"Accept",style:Uo,children:jsx(d,{name:"check",size:20})}),jsx("button",{onClick:u=>{u.stopPropagation(),a?.(e.from,e.to);},title:"Reject",style:Uo,children:jsx(d,{name:"close",size:20})})]})]}),jsxs("div",{style:{fontSize:13,lineHeight:"20px",color:"#202124",marginTop:6},children:[e.type==="insertion"?"Added":"Deleted"," ",jsxs("span",{style:{color:e.type==="insertion"?"#137333":"#c5221f",fontWeight:500},children:['"',e.text.length>50?e.text.slice(0,50)+"...":e.text,'"']})]}),jsx(Li,{replies:t,isExpanded:n}),n&&jsx(Bi,{onSubmit:u=>s?.(e.revisionId,u)})]})}function yd({measureRef:e,onSubmit:t,onCancel:n}){let[o,r]=useState(""),i=()=>{o.trim()&&(t?.(o.trim()),r(""));};return jsxs("div",{ref:e,onMouseDown:a=>a.stopPropagation(),style:{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:[jsx("textarea",{ref:a=>a?.focus({preventScroll:true}),value:o,onChange:a=>r(a.target.value),onMouseDown:a=>a.stopPropagation(),onKeyDown:a=>{a.stopPropagation(),a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),i()),a.key==="Escape"&&(n?.(),r(""));},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"}}),jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsx("button",{onClick:()=>{n?.(),r("");},style:Mi,children:"Cancel"}),jsx("button",{onClick:i,disabled:!o.trim(),style:Ii(!!o.trim()),children:"Comment"})]})]})}function Sd({measureRef:e,onToggleExpand:t}){return jsx("div",{ref:e,onClick:t,onMouseDown:n=>n.stopPropagation(),style:{display:"inline-flex",alignItems:"center",cursor:"pointer",color:"#5f6368",padding:2},onMouseOver:n=>{n.currentTarget.style.opacity="0.7";},onMouseOut:n=>{n.currentTarget.style.opacity="1";},children:jsx(d,{name:"chat_bubble_check",size:20})})}function kd({comments:e,trackedChanges:t,callbacks:n,showResolved:o=false,isAddingComment:r=false,addCommentYPosition:i=null}){let a=useMemo(()=>e.filter(l=>!(l.parentId!=null||l.done&&!o)),[e,o]),s=useMemo(()=>{let l=new Map;for(let u of e)if(u.parentId!=null){let d=l.get(u.parentId);d?d.push(u):l.set(u.parentId,[u]);}return l},[e]);return useMemo(()=>{let l=[];r&&i!=null&&l.push({id:"new-comment-input",anchorPos:0,fixedY:i,priority:-1e3,isTemporary:true,estimatedHeight:120,render:u=>jsx(yd,{...u,onSubmit:n.onAddComment,onCancel:n.onCancelAddComment})});for(let u of a){let d=s.get(u.id)??[];l.push({id:`comment-${u.id}`,anchorPos:0,anchorKey:`comment-${u.id}`,priority:0,estimatedHeight:u.done?28:80,render:c=>u.done&&!c.isExpanded?jsx(Sd,{...c,comment:u}):jsx(gd,{...c,comment:u,replies:d,onReply:n.onCommentReply,onResolve:n.onCommentResolve,onUnresolve:n.onCommentUnresolve,onDelete:n.onCommentDelete})});}return t.forEach((u,d)=>{let c=s.get(u.revisionId)??[];l.push({id:`tc-${u.revisionId}-${d}`,anchorPos:u.from,anchorKey:`revision-${u.revisionId}`,priority:1,estimatedHeight:80,render:p=>jsx(hd,{...p,change:u,replies:c,onAccept:n.onAcceptChange,onReject:n.onRejectChange,onReply:n.onTrackedChangeReply})});}),l},[a,t,s,n,r,i])}var mg=15840,Td=1440,gg=1440,hg=567,vd=20,bg="var(--doc-text-muted)",yg="var(--doc-text-subtle)",xg="var(--doc-primary)",Sg="var(--doc-primary)",kg="var(--doc-primary-hover)";function Rd({sectionProps:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,unit:i="inch",className:a="",style:s}){let[l,u]=useState(null),[d,c]=useState(null),p=useRef(null),f=e?.pageHeight??mg,m=e?.marginTop??Td,b=e?.marginBottom??Td,g=a$3(f)*t,x=a$3(m)*t,T=a$3(b)*t,S=useCallback((D,P)=>{n&&(D.preventDefault(),u(P));},[n]),B=useCallback(D=>{if(!l||!p.current)return;let P=p.current.getBoundingClientRect(),I=D.clientY-P.top,J=b$1(I/t);if(l==="topMargin"){let se=f-b-720,ie=Math.max(0,Math.min(J,se));o?.(Math.round(ie));}else if(l==="bottomMargin"){let se=f-J,ie=f-m-720,z=Math.max(0,Math.min(se,ie));r?.(Math.round(z));}},[l,t,f,m,b,o,r]),v=useCallback(()=>{u(null);},[]);useEffect(()=>{if(l)return document.addEventListener("mousemove",B),document.addEventListener("mouseup",v),()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",v);}},[l,B,v]);let E=Tg(f,t,i),V={position:"relative",width:vd,height:k(g),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:l?"ns-resize":"default",...s};return jsxs("div",{ref:p,className:`docx-vertical-ruler ${a}`,style:V,role:"slider","aria-label":"Vertical ruler","aria-orientation":"vertical",children:[jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:E.map((D,P)=>jsx(Cg,{tick:D},P))}),jsx(wd,{type:"topMargin",position:x,editable:n,isDragging:l==="topMargin",isHovered:d==="topMargin",onMouseEnter:()=>c("topMargin"),onMouseLeave:()=>c(null),onMouseDown:D=>S(D,"topMargin")}),jsx(wd,{type:"bottomMargin",position:g-T,editable:n,isDragging:l==="bottomMargin",isHovered:d==="bottomMargin",onMouseEnter:()=>c("bottomMargin"),onMouseLeave:()=>c(null),onMouseDown:D=>S(D,"bottomMargin")})]})}function Cg({tick:e}){let t={position:"absolute",top:k(e.position),right:0,height:1,width:e.width,backgroundColor:yg},n={position:"absolute",top:k(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:bg,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxs(Fragment,{children:[jsx("div",{style:t}),e.label&&jsx("div",{style:n,children:e.label})]})}function wd({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:s}){let l=o?kg:r?Sg:xg,u={position:"absolute",top:k(t-5),right:0,width:vd,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 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:jsx("div",{style:d})})}function Tg(e,t,n){let o=[];if(n==="inch"){let r=gg/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=a$3(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=hg/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=a$3(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 Qt={High:50,Default:100,Low:150};function gt(e){return t=>{let n={...e.defaultOptions,...t};return {type:"extension",config:{name:e.name,priority:e.priority??Qt.Default,options:n},onSchemaReady(o){return e.onSchemaReady(o,n)}}}}function tt(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??Qt.Default,options:n,schemaNodeName:e.schemaNodeName,nodeSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}function Ae(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??Qt.Default,options:n,schemaMarkName:e.schemaMarkName,markSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}var Pd=tt({name:"doc",schemaNodeName:"doc",nodeSpec:{content:"(paragraph | horizontalRule | pageBreak | table | textBox)+"}});var Md=tt({name:"text",schemaNodeName:"text",nodeSpec:{group:"inline"}});function Id(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=a$4(a);n.fontFamily=s.cssFallback;}}if(e.fontSize!==void 0&&(n.fontSize=`${i$3(e.fontSize)}pt`),e.bold&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic"),e.color&&(n.color=a(e.color,t)),e.highlight&&e.highlight!=="none"&&(n.backgroundColor=n$2(e.highlight)),e.shading){let a=Ld(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$1=vg(e.underline.style);a$1!=="solid"&&r.push(a$1),e.underline.color&&i.push(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=h$3(e.position);n.position="relative",n.top=k(-a);}return e.allCaps?n.textTransform="uppercase":e.smallCaps&&(n.fontVariant="small-caps"),e.spacing!==void 0&&e.spacing!==0&&(n.letterSpacing=k(a$3(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 Fd(e,t){if(!e)return {};let n={};if(e.alignment&&(n.textAlign=Rg(e.alignment)),e.spaceBefore!==void 0&&(n.marginTop=k(a$3(e.spaceBefore))),e.spaceAfter!==void 0&&(n.marginBottom=k(a$3(e.spaceAfter))),e.lineSpacing!==void 0&&e.lineSpacing>0)switch(e.lineSpacingRule){case "exact":{let o=a$3(e.lineSpacing);o>0&&(n.lineHeight=k(o));break}case "atLeast":{let o=a$3(e.lineSpacing);o>0&&(n.minHeight=k(o),n.lineHeight=k(o));break}default:{let o=e.lineSpacing/240;o>0&&(n.lineHeight=o.toString());break}}if(e.indentLeft!==void 0&&(n.marginLeft=k(a$3(e.indentLeft))),e.indentRight!==void 0&&(n.marginRight=k(a$3(e.indentRight))),e.indentFirstLine!==void 0&&(e.hangingIndent?n.textIndent=k(a$3(e.indentFirstLine)):n.textIndent=k(a$3(e.indentFirstLine))),e.borders&&(e.borders.top&&Object.assign(n,Go(e.borders.top,"Top",t)),e.borders.bottom&&Object.assign(n,Go(e.borders.bottom,"Bottom",t)),e.borders.left&&Object.assign(n,Go(e.borders.left,"Left",t)),e.borders.right&&Object.assign(n,Go(e.borders.right,"Right",t))),e.shading){let o=Ld(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 Go(e,t="",n){if(!e||e.style==="none"||e.style==="nil")return {};let o={},r=e.size?j$1(e.size):1,i=e.color?a(e.color,n):"#000000",a$1=Eg(e.style),s=`border${t}Width`,l=`border${t}Style`,u=`border${t}Color`;return o[s]=k(Math.max(1,r)),o[l]=a$1,o[u]=i,o}function Ld(e,t){return !e||e.pattern==="clear"||e.pattern==="nil"?"":e.fill?e.fill.auto||e.fill.rgb==="auto"||e.fill.rgb==="FFFFFF"?"":c$3(e.fill,t):e.pattern==="solid"&&e.color?c$3(e.color,t):e.pattern&&e.pattern.startsWith("pct")&&e.color?c$3(e.color,t):""}function vg(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 Rg(e){switch(e){case "center":return "center";case "right":return "right";case "both":case "distribute":return "justify";default:return "left"}}function Eg(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 Yo(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 Mg(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=Fd(n);return Object.entries(o).map(([r,i])=>`${r.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${i}`).join("; ")}function Ig(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 Fg(e,t,n){if(!e?.numId)return "";let o=e.ilvl??0;return t?`docx-list-bullet docx-list-level-${o}`:`docx-list-numbered ${Ig(n)} docx-list-level-${o}`}function qo(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 Lg(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 Bg(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=qo(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 Bd(e){let t=e.style,n={};if(t.textAlign){let i=Lg(t.textAlign);i&&(n.alignment=i);}let o=t.marginLeft||t.paddingLeft;if(o){let i=qo(o);i!=null&&(n.indentLeft=i);}let r=t.marginRight||t.paddingRight;if(r){let i=qo(r);i!=null&&(n.indentRight=i);}if(t.textIndent){let i=qo(t.textIndent);i!=null&&(i<0?(n.indentFirstLine=Math.abs(i),n.hangingIndent=true):n.indentFirstLine=i);}if(t.lineHeight){let i=Bg(t.lineHeight);i&&(n.lineSpacing=i.lineSpacing,n.lineSpacingRule=i.lineSpacingRule);}if(t.marginTop){let i=qo(t.marginTop);i!=null&&(n.spaceBefore=i);}if(t.marginBottom){let i=qo(t.marginBottom);i!=null&&(n.spaceAfter=i);}return n}var Ag={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=Bd(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 {...Bd(t),styleId:`Heading${n}`,outlineLevel:n-1}}}))],toDOM(e){let t=e.attrs,n=Mg(t),o=Fg(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 Wt(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 Ad(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 Mr(e){return (t,n)=>Wt("alignment",e)(t,n)}function Ni(e,t="auto"){return (n,o)=>Ad({lineSpacing:e,lineSpacingRule:t})(n,o)}function Dg(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 Hg(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 Ng(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 Dd=tt({name:"paragraph",schemaNodeName:"paragraph",nodeSpec:Ag,onSchemaReady(e){let t=Ng(e.schema);return {commands:{setAlignment:n=>Mr(n),alignLeft:()=>Mr("left"),alignCenter:()=>Mr("center"),alignRight:()=>Mr("right"),alignJustify:()=>Mr("both"),setLineSpacing:(n,o)=>Ni(n,o),singleSpacing:()=>Ni(240),oneAndHalfSpacing:()=>Ni(360),doubleSpacing:()=>Ni(480),setSpaceBefore:n=>Wt("spaceBefore",n),setSpaceAfter:n=>Wt("spaceAfter",n),increaseIndent:n=>Dg(n),decreaseIndent:n=>Hg(n),setIndentLeft:n=>Wt("indentLeft",n>0?n:null),setIndentRight:n=>Wt("indentRight",n>0?n:null),setIndentFirstLine:(n,o)=>Ad({indentFirstLine:n>0?n:null,hangingIndent:o??false}),applyStyle:(n,o)=>t(n,o),clearStyle:()=>Wt("styleId",null),insertSectionBreak:n=>Wt("sectionBreakType",n),removeSectionBreak:()=>Wt("sectionBreakType",null),generateTOC:()=>(n,o)=>{let r=Yo(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,Fragment$1.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 Wt("bidi",a?null:true)(n,o)},setRtl:()=>Wt("bidi",true),setLtr:()=>Wt("bidi",null),setTabs:n=>Wt("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 Wt("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 Wt("tabs",l.length>0?l:null)(o,r)}}}}});var Nd=gt({name:"history",defaultOptions:{depth:100,newGroupDelay:500},onSchemaReady(e,t){return {plugins:[history({depth:t.depth,newGroupDelay:t.newGroupDelay})],commands:{undo:()=>undo,redo:()=>redo},keyboardShortcuts:{"Mod-z":undo,"Mod-y":redo,"Mod-Shift-z":redo}}}});var Od=Ae({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:()=>toggleMark(e.schema.marks.bold)},keyboardShortcuts:{"Mod-b":toggleMark(e.schema.marks.bold)}}}});var _d=Ae({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:()=>toggleMark(e.schema.marks.italic)},keyboardShortcuts:{"Mod-i":toggleMark(e.schema.marks.italic)}}}});function Og(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 Wd(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=Og(r);return t.setNodeMarkup(n.before(),void 0,{...o.attrs,defaultTextFormatting:i})}function Cn(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=Wd(n,u),o(u);}return true}return o&&o(n.tr.addMark(r,i,s).scrollIntoView()),true}}function Tn(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=Wd(t,s),n(s);}return true}return n&&n(t.tr.removeMark(o,r,e).scrollIntoView()),true}}function Vd(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 Ir=(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 jd=Ae({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:()=>toggleMark(e.schema.marks.underline),setUnderlineStyle:(t,n)=>Cn(e.schema.marks.underline,{style:t,color:n})},keyboardShortcuts:{"Mod-u":toggleMark(e.schema.marks.underline)}}}});var Kd=Ae({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:()=>toggleMark(e.schema.marks.strike)}}}});var Gd=Ae({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=Id({color:t});return ["span",{style:n.color?`color: ${n.color}`:""},0]}},onSchemaReady(e){return {commands:{setTextColor:t=>!t.rgb&&!t.themeColor?Tn(e.schema.marks.textColor):Cn(e.schema.marks.textColor,t),clearTextColor:()=>Tn(e.schema.marks.textColor)}}}});var Yd=Ae({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: ${n$2(t)}`},0]}},onSchemaReady(e){return {commands:{setHighlight:t=>!t||t==="none"?Tn(e.schema.marks.highlight):Cn(e.schema.marks.highlight,{color:t}),clearHighlight:()=>Tn(e.schema.marks.highlight)}}}});var qd=Ae({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=>Cn(e.schema.marks.fontSize,{size:t}),clearFontSize:()=>Tn(e.schema.marks.fontSize)}}}});var Xd=Ae({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=>Cn(e.schema.marks.fontFamily,{ascii:t,hAnsi:t}),clearFontFamily:()=>Tn(e.schema.marks.fontFamily)}}}});var Zd=Ae({name:"superscript",schemaMarkName:"superscript",markSpec:{excludes:"subscript",parseDOM:[{tag:"sup"}],toDOM(){return ["sup",0]}},onSchemaReady(e){return {commands:{toggleSuperscript:()=>toggleMark(e.schema.marks.superscript)}}}});var Jd=Ae({name:"subscript",schemaMarkName:"subscript",markSpec:{excludes:"superscript",parseDOM:[{tag:"sub"}],toDOM(){return ["sub",0]}},onSchemaReady(e){return {commands:{toggleSubscript:()=>toggleMark(e.schema.marks.subscript)}}}});function Xo(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 Zo(e){let{from:t,to:n,empty:o}=e.selection;return o?"":e.doc.textBetween(t,n,"")}var Qd=Ae({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(v=>v.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 eu=Ae({name:"allCaps",schemaMarkName:"allCaps",markSpec:{parseDOM:[{style:"text-transform",getAttrs:e=>e==="uppercase"?{}:false}],toDOM(){return ["span",{style:"text-transform: uppercase"},0]}}});var tu=Ae({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 nu=Ae({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 Vg(e){return e/2*(96/72)}var ou=Ae({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: ${k(a$3(t.spacing))}`),o["data-spacing"]=String(t.spacing)),t.position!=null&&t.position!==0){let r=Vg(t.position);n.push(`vertical-align: ${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 ru=Ae({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 iu=Ae({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]}}}),au=Ae({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 su=Ae({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]}}}),lu=Ae({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]}}}),cu=Ae({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]}}}),du=Ae({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]}}}),uu=Ae({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 pu=tt({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 fu=tt({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 mu=tt({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 gu=tt({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 Ug(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 jg(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 hu=tt({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=jg(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=Ug(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 bu=tt({name:"horizontalRule",schemaNodeName:"horizontalRule",nodeSpec:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return ["hr"]}}});var yu=tt({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 xu=tt({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 Su=tt({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 ku=tt({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 eh(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 th(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 Cu(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 nh(e){let t=(a,s,l)=>{if(!(!a||a==="none"||a==="hidden"))return {style:eh(a),color:Cu(s)||void 0,size:th(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 oh(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 rh(e){if(e)switch(e.toLowerCase()){case "top":return "top";case "middle":return "center";case "bottom":return "bottom";default:return}}function ih(e){return Cu(e)?.rgb}function Tu(e){let t=e.style,n=nh(t),o=oh(t);return {colspan:e.colSpan||1,rowspan:e.rowSpan||1,verticalAlign:e.dataset.valign||rh(t.verticalAlign)||void 0,backgroundColor:e.dataset.bgcolor||ih(t.backgroundColor)||void 0,borders:n||void 0,margins:o||void 0}}var ah={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]]}},sh={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]}},lh={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 wu(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=lh[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 vu(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 Ru(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 Eu(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 ch={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=>Tu(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(...vu(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...Eu(t)),o.push(...wu(t)),o.push(...Ru(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]}},dh={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=>Tu(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(...vu(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...Eu(t)),o.push(...wu(t)),o.push(...Ru(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 Xe(e){let{selection:t}=e,{$from:n}=t,o=t instanceof 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,v)=>{T||(v===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 Gn(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 Pu(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 Mu(){return (e,t)=>{if(!Gn(e))return false;let n=Pu(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(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(Selection.near(e.doc.resolve(d)));t(c.scrollIntoView());}return true}return false}}function Iu(){return (e,t)=>{if(!Gn(e))return false;let n=Pu(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(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(Selection.near(e.doc.resolve(c),-1));t(p.scrollIntoView());}return true}return false}}var uh=tt({name:"table",schemaNodeName:"table",nodeSpec:ah}),ph=tt({name:"tableRow",schemaNodeName:"tableRow",nodeSpec:sh}),fh=tt({name:"tableCell",schemaNodeName:"tableCell",nodeSpec:ch}),mh=tt({name:"tableHeader",schemaNodeName:"tableHeader",nodeSpec:dh}),gh=gt({name:"tablePlugin",onSchemaReady(e){let{schema:t}=e;function n(...R){return (L,k,M)=>{for(let F of R)if(F(L,k,M))return true;return false}}function o(R,L={}){let k=R?.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,...L}}function r(R,L,k="000000",M=9360){let F=[],H=Math.floor(M/L),oe=360,ee="atLeast",_={style:"single",size:4,color:{rgb:k}},G={top:_,bottom:_,left:_,right:_};for(let xe=0;xe<R;xe++){let re=[];for(let pe=0;pe<L;pe++){let de=t.nodes.paragraph.create(),Pe={colspan:1,rowspan:1,borders:G,width:H,widthType:"dxa"};re.push(t.nodes.tableCell.create(Pe,de));}F.push(t.nodes.tableRow.create({height:oe,heightRule:ee},re));}let ne=Array(L).fill(H);return t.nodes.table.create({columnWidths:ne,width:M,widthType:"dxa"},F)}function i(R,L){return (k,M)=>{let{$from:F}=k.selection,H="000000",oe=k.storedMarks||F.marks();for(let _ of oe)if(_.type.name==="textColor"&&_.attrs.rgb){H=_.attrs.rgb;break}let ee=F.pos;for(let _=F.depth;_>0;_--){let G=F.node(_);if(G.type.name==="paragraph"||G.type.name==="table"){ee=F.after(_);break}}if(M){let _=9360;for(let Ne=F.depth;Ne>0;Ne--){let Ke=F.node(Ne);if(Ke.type.name==="tableCell"||Ke.type.name==="tableHeader"){let ze=Ke.attrs.width;ze&&ze>0&&(_=Math.max(ze-216,360));break}}let G=r(R,L,H,_),ne=t.nodes.paragraph.create(),re=k.doc.resolve(ee).nodeBefore?.type.name==="table",pe=re?[ne,G,ne]:[G,ne],de=k.tr.insert(ee,pe),Pe=ee+1;re&&(Pe+=ne.nodeSize);let je=Pe+1+1;de.setSelection(TextSelection.create(de.doc,je)),M(de.scrollIntoView());}return true}}function a(R,L){let k=Xe(R);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0)return false;if(L){let M=R.tr,F=k.table.child(k.rowIndex),H=[];F.forEach(_=>{let G=t.nodes.paragraph.create(),ne=o(_);H.push(t.nodes.tableCell.create(ne,G));});let oe=t.nodes.tableRow.create({height:F.attrs.height??360,heightRule:F.attrs.heightRule??"atLeast"},H),ee=k.tablePos+1;for(let _=0;_<k.rowIndex;_++)ee+=k.table.child(_).nodeSize;M.insert(ee,oe),L(M.scrollIntoView());}return true}function s(R,L){let k=Xe(R);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0)return false;if(L){let M=R.tr,F=k.table.child(k.rowIndex),H=[];F.forEach(_=>{let G=t.nodes.paragraph.create(),ne=o(_);H.push(t.nodes.tableCell.create(ne,G));});let oe=t.nodes.tableRow.create({height:F.attrs.height??360,heightRule:F.attrs.heightRule??"atLeast"},H),ee=k.tablePos+1;for(let _=0;_<=k.rowIndex;_++)ee+=k.table.child(_).nodeSize;M.insert(ee,oe),L(M.scrollIntoView());}return true}function l(R,L){let k=Xe(R);if(!k.isInTable||k.rowIndex===void 0||!k.table||k.tablePos===void 0||(k.rowCount||0)<=1)return false;if(L){let M=R.tr,F=k.tablePos+1;for(let oe=0;oe<k.rowIndex;oe++)F+=k.table.child(oe).nodeSize;let H=F+k.table.child(k.rowIndex).nodeSize;M.delete(F,H),L(M.scrollIntoView());}return true}function u(R,L){let k=Xe(R);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0)return false;if(L){let M=R.tr,F=(k.columnCount||1)+1,H=Math.floor(100/F),oe=k.tablePos+1;k.table.forEach(G=>{if(G.type.name==="tableRow"){let ne=oe+1,xe=0;if(G.forEach(re=>{if(xe===k.columnIndex){let pe=t.nodes.paragraph.create(),de=o(re,{colspan:1,rowspan:1});de.width=H,de.widthType="pct";let Pe=t.nodes.tableCell.create(de,pe);M=M.insert(ne,Pe);}ne+=re.nodeSize,xe+=re.attrs.colspan||1;}),xe<=k.columnIndex){let re=t.nodes.paragraph.create(),pe=o(G.child(G.childCount-1)??null,{colspan:1,rowspan:1});pe.width=H,pe.widthType="pct";let de=t.nodes.tableCell.create(pe,re);M=M.insert(ne,de);}}oe+=G.nodeSize;});let _=M.doc.nodeAt(k.tablePos);if(_&&_.type.name==="table"){let G=_.child(0);if(G&&G.type.name==="tableRow"){let pe=k.tablePos+2;G.forEach(de=>{(de.type.name==="tableCell"||de.type.name==="tableHeader")&&(M=M.setNodeMarkup(pe,void 0,{...de.attrs,width:H,widthType:"pct"})),pe+=de.nodeSize;});}let ne=G?.childCount??F,xe=_.attrs.width||9360,re=Math.floor(xe/Math.max(1,ne));M=M.setNodeMarkup(k.tablePos,void 0,{..._.attrs,columnWidths:Array(ne).fill(re)});}L(M.scrollIntoView());}return true}function d(R,L){let k=Xe(R);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0)return false;if(L){let M=R.tr,F=(k.columnCount||1)+1,H=Math.floor(100/F),oe=k.tablePos+1;k.table.forEach(G=>{if(G.type.name==="tableRow"){let ne=oe+1,xe=0,re=false;if(G.forEach(pe=>{if(ne+=pe.nodeSize,xe+=pe.attrs.colspan||1,!re&&xe>k.columnIndex){let de=t.nodes.paragraph.create(),Pe=o(pe,{colspan:1,rowspan:1});Pe.width=H,Pe.widthType="pct";let De=t.nodes.tableCell.create(Pe,de);M=M.insert(ne,De),re=true;}}),!re){let pe=t.nodes.paragraph.create(),de=o(G.child(G.childCount-1)??null,{colspan:1,rowspan:1});de.width=H,de.widthType="pct";let Pe=t.nodes.tableCell.create(de,pe);M=M.insert(ne,Pe);}}oe+=G.nodeSize;});let _=M.doc.nodeAt(k.tablePos);if(_&&_.type.name==="table"){let G=_.child(0);if(G&&G.type.name==="tableRow"){let pe=k.tablePos+2;G.forEach(de=>{(de.type.name==="tableCell"||de.type.name==="tableHeader")&&(M=M.setNodeMarkup(pe,void 0,{...de.attrs,width:H,widthType:"pct"})),pe+=de.nodeSize;});}let ne=G?.childCount??F,xe=_.attrs.width||9360,re=Math.floor(xe/Math.max(1,ne));M=M.setNodeMarkup(k.tablePos,void 0,{..._.attrs,columnWidths:Array(ne).fill(re)});}L(M.scrollIntoView());}return true}function c(R,L){let k=Xe(R);if(!k.isInTable||k.columnIndex===void 0||!k.table||k.tablePos===void 0||(k.columnCount||0)<=1)return false;if(L){let M=R.tr,F=(k.columnCount||2)-1,H=Math.floor(100/F),oe=[],ee=k.tablePos+1;k.table.forEach(G=>{if(G.type.name==="tableRow"){let ne=ee+1,xe=0;G.forEach(re=>{let pe=ne,de=ne+re.nodeSize,Pe=re.attrs.colspan||1;xe<=k.columnIndex&&k.columnIndex<xe+Pe&&oe.push({start:pe,end:de}),ne=de,xe+=Pe;});}ee+=G.nodeSize;}),oe.reverse().forEach(({start:G,end:ne})=>{M=M.delete(G,ne);});let _=M.doc.nodeAt(k.tablePos);if(_&&_.type.name==="table"){let G=_.child(0);if(G&&G.type.name==="tableRow"){let pe=k.tablePos+2;G.forEach(de=>{(de.type.name==="tableCell"||de.type.name==="tableHeader")&&(M=M.setNodeMarkup(pe,void 0,{...de.attrs,width:H,widthType:"pct"})),pe+=de.nodeSize;});}let ne=G?.childCount??F,xe=_.attrs.width||9360,re=Math.floor(xe/Math.max(1,ne));M=M.setNodeMarkup(k.tablePos,void 0,{..._.attrs,columnWidths:Array(ne).fill(re)});}L(M.scrollIntoView());}return true}function p(R,L){let k=Xe(R);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(L){let M=R.tr;M.delete(k.tablePos,k.tablePos+k.table.nodeSize),L(M.scrollIntoView());}return true}function f(R,L){let k=Xe(R);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(L){let M=k.tablePos+1,F=R.doc.resolve(M),H=R.doc.resolve(k.tablePos+k.table.nodeSize-2),oe=CellSelection.create(R.doc,F.pos,H.pos);L(R.tr.setSelection(oe));}return true}function m(R,L){let k=Xe(R);if(!k.isInTable||k.tablePos===void 0||!k.table||k.rowIndex===void 0)return false;if(L){let F=k.tablePos+1;for(let G=0;G<k.rowIndex;G++){let ne=k.table.child(G);F+=ne.nodeSize;}let H=k.table.child(k.rowIndex),oe=F+1,ee=F+H.nodeSize-2,_=CellSelection.create(R.doc,oe,ee);L(R.tr.setSelection(_));}return true}function b(R,L){let k=Xe(R);if(!k.isInTable||k.tablePos===void 0||!k.table||k.columnIndex===void 0)return false;if(L){let M=k.tablePos+1,F=k.table.child(0),H=k.table.child(k.table.childCount-1),oe=M+1;for(let ne=0;ne<k.columnIndex&&ne<F.childCount;ne++)oe+=F.child(ne).nodeSize;let ee=M;for(let ne=0;ne<k.table.childCount-1;ne++)ee+=k.table.child(ne).nodeSize;let _=ee+1;for(let ne=0;ne<k.columnIndex&&ne<H.childCount;ne++)_+=H.child(ne).nodeSize;let G=CellSelection.create(R.doc,oe,_);L(R.tr.setSelection(G));}return true}function g(R){let L=R.selection,k=[];if(L instanceof CellSelection)return L.forEachCell((F,H)=>{k.push({pos:H,node:F});}),k;let{$from:M}=L;for(let F=M.depth;F>0;F--){let H=M.node(F);if(H.type.name==="tableCell"||H.type.name==="tableHeader"){k.push({pos:M.before(F),node:H});break}}return k}function x(R,L){let k=new Map,M=new Map,F=R.childCount,H=0;return R.forEach((oe,ee,_)=>{if(oe.type.name!=="tableRow")return;let G=0;oe.forEach((ne,xe)=>{let re=L+ee+xe+2,pe=ne.attrs.colspan||1;k.set(re,{rowIdx:_,colIdx:G,colspan:pe,pos:re,node:ne}),M.set(`${_},${G}`,re),G+=pe;}),H=Math.max(H,G);}),{cellByPos:k,cellByRC:M,totalRows:F,totalCols:H}}function T(R,L){return (k,M)=>{let F=Xe(k);if(!F.isInTable||F.tablePos===void 0||!F.table)return false;if(M){let H=k.tr,oe=F.table,ee=F.tablePos,_=L??{style:"single",size:4,color:{rgb:"000000"}},G={style:"none"},{cellByPos:ne,cellByRC:xe}=x(oe,ee),re=g(k),pe=1/0,de=-1,Pe=1/0,De=-1;for(let{pos:ze}of re){let ve=ne.get(ze);ve&&(pe=Math.min(pe,ve.rowIdx),de=Math.max(de,ve.rowIdx),Pe=Math.min(Pe,ve.colIdx),De=Math.max(De,ve.colIdx+ve.colspan-1));}let je=new Map,Ne=(ze,ve)=>je.get(ze)??{...ve.attrs},Ke=(ze,ve)=>{je.set(ze,ve);};for(let{pos:ze}of re){let ve=ne.get(ze);if(!ve)continue;let Ie=ve.rowIdx===pe,Ye=ve.rowIdx===de,Ge=ve.colIdx===Pe,lt=ve.colIdx+ve.colspan-1===De,qe;switch(R){case "all":qe={top:_,bottom:_,left:_,right:_};break;case "outside":qe={top:Ie?_:G,bottom:Ye?_:G,left:Ge?_:G,right:lt?_:G};break;case "inside":qe={top:Ie?G:_,bottom:Ye?G:_,left:Ge?G:_,right:lt?G:_};break;case "none":qe={top:G,bottom:G,left:G,right:G};break}let ht=Ne(ze,ve.node),It=ht.borders||{};if(Ke(ze,{...ht,borders:{...It,...qe}}),qe.top){let He=xe.get(`${ve.rowIdx-1},${ve.colIdx}`);if(He!==void 0){let st=ne.get(He),Be=Ne(He,st.node),ut=Be.borders||{};Ke(He,{...Be,borders:{...ut,bottom:qe.top}});}}if(qe.bottom){let He=xe.get(`${ve.rowIdx+1},${ve.colIdx}`);if(He!==void 0){let st=ne.get(He),Be=Ne(He,st.node),ut=Be.borders||{};Ke(He,{...Be,borders:{...ut,top:qe.bottom}});}}if(qe.left){let He=xe.get(`${ve.rowIdx},${ve.colIdx-1}`);if(He!==void 0){let st=ne.get(He),Be=Ne(He,st.node),ut=Be.borders||{};Ke(He,{...Be,borders:{...ut,right:qe.left}});}}if(qe.right){let He=xe.get(`${ve.rowIdx},${ve.colIdx+ve.colspan}`);if(He!==void 0){let st=ne.get(He),Be=Ne(He,st.node),ut=Be.borders||{};Ke(He,{...Be,borders:{...ut,left:qe.right}});}}}for(let[ze,ve]of je)H.setNodeMarkup(H.mapping.map(ze),void 0,ve);M(H.scrollIntoView());}return true}}function S(R){return (L,k)=>{let M=Xe(L);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let F=L.tr,H=g(L),oe=R?R.replace(/^#/,""):null;for(let{pos:ee,node:_}of H)F.setNodeMarkup(F.mapping.map(ee),void 0,{..._.attrs,backgroundColor:oe});k(F.scrollIntoView());}return true}}function B(R,L,k){return (M,F)=>{let H=Xe(M);if(!H.isInTable||H.tablePos===void 0||!H.table)return false;if(F){let oe=M.tr,ee=g(M),_=L||{style:"none"},G={style:"none"},ne=["top","bottom","left","right"],{cellByPos:xe,cellByRC:re}=x(H.table,H.tablePos),pe=new Map,de=(je,Ne)=>pe.get(je)??{...Ne.attrs},Pe=(je,Ne)=>pe.set(je,Ne),De={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:je,node:Ne}of ee){let Ke=xe.get(je),ze=de(je,Ne),ve=ze.borders||{},Ie=R==="all"?ne:[R],Ye=k?{top:G,bottom:G,left:G,right:G}:{...ve};for(let Ge of Ie)Ye[Ge]=_;if(Ke){let Ge=k?ne:Ie;for(let lt of Ge){let qe=Ye[lt],ht=De[lt],It=lt==="right"?Ke.colIdx+Ke.colspan:Ke.colIdx+ht.dCol,He=re.get(`${Ke.rowIdx+ht.dRow},${It}`);if(He!==void 0){let st=xe.get(He),Be=de(He,st.node),ut=Be.borders||{};Pe(He,{...Be,borders:{...ut,[ht.adjSide]:qe}});}}}Pe(je,{...ze,borders:Ye});}for(let[je,Ne]of pe)oe.setNodeMarkup(oe.mapping.map(je),void 0,Ne);F(oe.scrollIntoView());}return true}}function v(R){return (L,k)=>{let M=Xe(L);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let F=L.tr,H=g(L);for(let{pos:oe,node:ee}of H)F.setNodeMarkup(F.mapping.map(oe),void 0,{...ee.attrs,verticalAlign:R});k(F.scrollIntoView());}return true}}function E(R){return (L,k)=>{let M=Xe(L);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let F=L.tr,H=g(L);for(let{pos:oe,node:ee}of H){let G={...ee.attrs.margins||{},...R};F.setNodeMarkup(F.mapping.map(oe),void 0,{...ee.attrs,margins:G});}k(F.scrollIntoView());}return true}}function V(R){return (L,k)=>{let M=Xe(L);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let F=L.tr,H=g(L);for(let{pos:oe,node:ee}of H)F.setNodeMarkup(F.mapping.map(oe),void 0,{...ee.attrs,textDirection:R});k(F.scrollIntoView());}return true}}function D(){return (R,L)=>{let k=Xe(R);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(L){let M=R.tr,F=g(R);for(let{pos:H,node:oe}of F)M.setNodeMarkup(M.mapping.map(H),void 0,{...oe.attrs,noWrap:!oe.attrs.noWrap});L(M.scrollIntoView());}return true}}function P(R,L){return (k,M)=>{let F=Xe(k);if(!F.isInTable||F.tablePos===void 0||!F.table)return false;if(M){let H=k.tr,{$from:oe}=k.selection;for(let ee=oe.depth;ee>0;ee--){let _=oe.node(ee);if(_.type.name==="tableRow"){let G=oe.before(ee),ne={..._.attrs,height:R,heightRule:R?L||"atLeast":null};return H.setNodeMarkup(G,void 0,ne),M(H.scrollIntoView()),true}}}return true}}function I(){return (R,L)=>{let k=Xe(R);if(!k.isInTable||k.tablePos===void 0||!k.table||!k.columnCount)return false;if(L){let M=R.tr,F=k.table,H=k.columnCount,oe=F.attrs.columnWidths,ee=oe?oe.reduce((xe,re)=>xe+re,0):9360,_=Math.floor(ee/H),G=k.tablePos+1;F.forEach(xe=>{if(xe.type.name==="tableRow"){let re=G+1;xe.forEach(pe=>{(pe.type.name==="tableCell"||pe.type.name==="tableHeader")&&(M=M.setNodeMarkup(re,void 0,{...pe.attrs,width:_,widthType:"dxa",colwidth:null})),re+=pe.nodeSize;});}G+=xe.nodeSize;});let ne=Array(H).fill(_);M=M.setNodeMarkup(k.tablePos,void 0,{...F.attrs,columnWidths:ne}),L(M.scrollIntoView());}return true}}function J(){return (R,L)=>{let k=Xe(R);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(L){let M=R.tr,F=k.table,H=k.tablePos+1;F.forEach(oe=>{if(oe.type.name==="tableRow"){let ee=H+1;oe.forEach(_=>{(_.type.name==="tableCell"||_.type.name==="tableHeader")&&(M=M.setNodeMarkup(ee,void 0,{..._.attrs,width:null,widthType:null,colwidth:null})),ee+=_.nodeSize;});}H+=oe.nodeSize;}),M=M.setNodeMarkup(k.tablePos,void 0,{...F.attrs,columnWidths:null,width:null,widthType:"auto"}),L(M.scrollIntoView());}return true}}function se(R){return (L,k)=>{let M=Xe(L);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let F=L.tr,H=M.table,oe=M.tablePos,ee=H.childCount,_=R.look??{firstRow:true,lastRow:false,noHBand:false},G=R.conditionals??{},ne=R.tableBorders;F=F.setNodeMarkup(oe,void 0,{...H.attrs,styleId:R.styleId});let xe=0,re=oe+1;for(let pe=0;pe<ee;pe++){let de=H.child(pe),Pe=pe===0&&!!_.firstRow,De=pe===ee-1&&!!_.lastRow,je=_.noHBand!==true,Ne=de.childCount,Ke;Pe?Ke="firstRow":De?Ke="lastRow":(je&&(Ke=xe%2===0?"band1Horz":"band2Horz"),xe++);let ze=re+1;for(let ve=0;ve<Ne;ve++){let Ie=de.child(ve),Ye=F.mapping.map(ze),Ge=Ke,lt=ve===0&&!!_.firstCol,qe=ve===Ne-1&&!!_.lastCol;Pe&<&&G.nwCell?Ge="nwCell":Pe&&qe&&G.neCell?Ge="neCell":De&<&&G.swCell?Ge="swCell":De&&qe&&G.seCell?Ge="seCell":lt?Ge="firstCol":qe&&(Ge="lastCol");let ht=Ge?G[Ge]:void 0,It={...Ie.attrs};ht?.backgroundColor?It.backgroundColor=ht.backgroundColor:It.backgroundColor=null;let He={},st=["top","bottom","left","right"];for(let Be of st)ht?.borders&&ht.borders[Be]!==void 0?He[Be]=ht.borders[Be]:ne&&(Be==="top"&&pe>0||Be==="bottom"&&pe<ee-1?He[Be]=ne.insideH??ne[Be]:Be==="left"&&ve>0||Be==="right"&&ve<Ne-1?He[Be]=ne.insideV??ne[Be]:He[Be]=ne[Be]);Object.keys(He).length>0?It.borders=He:It.borders=null,F=F.setNodeMarkup(Ye,void 0,It),ze+=Ie.nodeSize;}re+=de.nodeSize;}k(F.scrollIntoView());}return true}}function ie(R){return (L,k)=>{let M=Xe(L);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let F=L.tr,H={...M.table.attrs};"width"in R&&(H.width=R.width),"widthType"in R&&(H.widthType=R.widthType),"justification"in R&&(H.justification=R.justification),F.setNodeMarkup(M.tablePos,void 0,H),k(F.scrollIntoView());}return true}}function z(){return (R,L)=>{let k=Xe(R);if(!k.isInTable||k.tablePos===void 0||!k.table)return false;if(L){let M=R.tr,{$from:F}=R.selection;for(let H=F.depth;H>0;H--){let oe=F.node(H);if(oe.type.name==="tableRow"){let ee=F.before(H),_={...oe.attrs,isHeader:!oe.attrs.isHeader};return M.setNodeMarkup(ee,void 0,_),L(M.scrollIntoView()),true}}}return true}}function N(R){return (L,k)=>{let M=Xe(L);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let F=L.tr,H=g(L),oe=R.replace(/^#/,""),ee={style:"single",size:4},{cellByPos:_,cellByRC:G}=x(M.table,M.tablePos),ne=new Map,xe=(de,Pe)=>ne.get(de)??{...Pe.attrs},re=(de,Pe)=>ne.set(de,Pe),pe={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:de,node:Pe}of H){let De=_.get(de),je=xe(de,Pe),Ne=je.borders||{},Ke={};for(let ze of ["top","bottom","left","right"]){let ve={...ee,...Ne[ze],color:{rgb:oe}};if(Ke[ze]=ve,De){let Ie=pe[ze],Ye=ze==="right"?De.colIdx+De.colspan:De.colIdx+Ie.dCol,Ge=G.get(`${De.rowIdx+Ie.dRow},${Ye}`);if(Ge!==void 0){let lt=_.get(Ge),qe=xe(Ge,lt.node),ht=qe.borders||{};re(Ge,{...qe,borders:{...ht,[Ie.adjSide]:ve}});}}}re(de,{...je,borders:{...Ne,...Ke}});}for(let[de,Pe]of ne)F.setNodeMarkup(F.mapping.map(de),void 0,Pe);k(F.scrollIntoView());}return true}}function ue(R){return (L,k)=>{let M=Xe(L);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(k){let F=L.tr,H=g(L),oe={style:"single",color:{rgb:"000000"}},{cellByPos:ee,cellByRC:_}=x(M.table,M.tablePos),G=new Map,ne=(pe,de)=>G.get(pe)??{...de.attrs},xe=(pe,de)=>G.set(pe,de),re={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:pe,node:de}of H){let Pe=ee.get(pe),De=ne(pe,de),je=De.borders||{},Ne={};for(let Ke of ["top","bottom","left","right"]){let ze={...oe,...je[Ke],size:R};if(Ne[Ke]=ze,Pe){let ve=re[Ke],Ie=Ke==="right"?Pe.colIdx+Pe.colspan:Pe.colIdx+ve.dCol,Ye=_.get(`${Pe.rowIdx+ve.dRow},${Ie}`);if(Ye!==void 0){let Ge=ee.get(Ye),lt=ne(Ye,Ge.node),qe=lt.borders||{};xe(Ye,{...lt,borders:{...qe,[ve.adjSide]:ze}});}}}xe(pe,{...De,borders:{...je,...Ne}});}for(let[pe,de]of G)F.setNodeMarkup(F.mapping.map(pe),void 0,de);k(F.scrollIntoView());}return true}}function me(){return (R,L)=>{let k=R.selection;if(!("$anchorCell"in k&&typeof k.forEachCell=="function"))return false;let F=Xe(R);if(!F.isInTable||F.tablePos===void 0||!F.table)return false;let H=0;F.table.descendants(_=>{(_.type.name==="tableCell"||_.type.name==="tableHeader")&&(H+=1);});let oe=0;if(k.forEachCell(()=>{oe+=1;}),!(H>0&&oe>=H))return false;if(L){let _=R.tr.delete(F.tablePos,F.tablePos+F.table.nodeSize);L(_.scrollIntoView());}return true}}function Ee(){return R=>{let{$from:L,empty:k}=R.selection;if(!k)return false;let M=L.parent;if(M.type.name!=="paragraph"||M.textContent.length>0)return false;let F=L.depth;if(F<1)return false;let H=L.node(F-1),oe=L.index(F-1),ee=oe>0?H.child(oe-1):null,_=oe+1<H.childCount?H.child(oe+1):null,G=ee?.type.name==="table",ne=_?.type.name==="table";return !!(G||ne)}}let ce=new PluginKey("activeCell"),Y=new Plugin({key:ce,props:{decorations(R){let{selection:L}=R;if(L instanceof CellSelection)return DecorationSet.empty;let{$from:k}=L;for(let M=k.depth;M>0;M--){let F=k.node(M);if(F.type.name==="tableCell"||F.type.name==="tableHeader"){let H=k.before(M);return DecorationSet.create(R.doc,[Decoration.node(H,H+F.nodeSize,{class:"activeCell"})])}}return DecorationSet.empty}}});return {plugins:[columnResizing({handleWidth:5,cellMinWidth:25,lastColumnResizable:true}),tableEditing(),Y],keyboardShortcuts:{Backspace:n(me(),Ee()),Delete:n(me(),Ee())},commands:{insertTable:(R,L)=>i(R,L),addRowAbove:()=>a,addRowBelow:()=>s,deleteRow:()=>l,addColumnLeft:()=>u,addColumnRight:()=>d,deleteColumn:()=>c,deleteTable:()=>p,selectTable:()=>f,selectRow:()=>m,selectColumn:()=>b,mergeCells:()=>mergeCells,splitCell:()=>splitCell,setCellBorder:(R,L,k)=>B(R,L,k),setTableBorders:(R,L)=>T(R,L),setCellVerticalAlign:R=>v(R),setCellMargins:R=>E(R),setCellTextDirection:R=>V(R),toggleNoWrap:()=>D(),setRowHeight:(R,L)=>P(R,L),toggleHeaderRow:()=>z(),distributeColumns:()=>I(),autoFitContents:()=>J(),setTableProperties:R=>ie(R),applyTableStyle:R=>se(R),setCellFillColor:R=>S(R),setTableBorderColor:R=>N(R),setTableBorderWidth:R=>ue(R),removeTableBorders:()=>T("none"),setAllTableBorders:R=>T("all",R),setOutsideTableBorders:R=>T("outside",R),setInsideTableBorders:R=>T("inside",R)}}}});function Fu(){return [uh(),ph(),fh(),mh(),gh()]}function il(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}function Lu(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 hh=(e,t)=>Lu(1)(e,t),bh=(e,t)=>Lu(2)(e,t),yh=(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},xh=(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},Sh=(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 kh(){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 Ch(){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 Th(){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 wh(){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 vh(){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 Rh(){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 Bu=gt({name:"list",priority:Qt.High,onSchemaReady(){return {commands:{toggleBulletList:()=>hh,toggleNumberedList:()=>bh,increaseListLevel:()=>yh,decreaseListLevel:()=>xh,removeList:()=>Sh},keyboardShortcuts:{Tab:il(Mu(),wh(),Rh()),"Shift-Tab":il(Iu(),vh()),"Shift-Enter":()=>false,Enter:il(kh(),Ch()),Backspace:Th()}}}});function Du(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}var Bh=(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},Ah=["defaultTextFormatting","styleId","lineSpacing","lineSpacingRule","spaceAfter","spaceBefore","contextualSpacing"],Hu=new Set(["fontFamily","fontSize","textColor"]),Dh=(e,t,n)=>{let{$from:o}=e.selection,r=o.parent.type.name==="paragraph"?o.parent:null,a=(e.storedMarks||o.marks()).filter(u=>Hu.has(u.type.name)),s=null;if(!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 Ah){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=Vd(b,e.schema).filter(x=>Hu.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},Nu=gt({name:"baseKeymap",priority:Qt.Low,onSchemaReady(e){return {keyboardShortcuts:{...baseKeymap,Enter:Dh,Backspace:Du(deleteSelection,Bh,joinBackward),Delete:Du(deleteSelection,joinForward),"Mod-a":selectAll,Escape:selectParentNode}}}});var zu=new PluginKey("selectionTracker");function Oi(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,v,E)=>{if(v>r)return false;v<=o&&(s=E),v<=r&&(l=E);});let u=zh(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 zh(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 Ou(e){return new Plugin({key:zu,state:{init(t,n){return Oi(n)},apply(t,n,o,r){if(!t.selectionSet&&!t.docChanged)return n;let i=Oi(r);return e&&!$h(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=zu.getState(t.state);o&&e(o);}}}})}function Oh(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 $h(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&&Oh(e.activeCommentIds,t.activeCommentIds)&&JSON.stringify(e.textFormatting)===JSON.stringify(t.textFormatting)&&JSON.stringify(e.paragraphFormatting)===JSON.stringify(t.paragraphFormatting)}var $u=gt({name:"selectionTracker",defaultOptions:{},onSchemaReady(e,t){return {plugins:[Ou(t.onSelectionChange)],commands:{extractSelectionContext:()=>(n,o)=>(Oi(n),true)}}}});var Vh=new PluginKey("imageDrag"),Wu=gt({name:"imageDrag",onSchemaReady(e){return {plugins:[new Plugin({key:Vh,props:{handleDOMEvents:{dragstart(n,o){let{selection:r}=n.state;if(r instanceof 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 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 al=612;async function Kh(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 Gh(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 Yh(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 Kh(r);}catch{continue}let a=1,s=1;try{({width:a,height:s}=await Gh(i));}catch{a=1,s=1;}let l=a,u=s;if(l>al){let p=al/l;l=al,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(TextSelection.create(c.doc,o)),e.dispatch(c.scrollIntoView());}e.focus();}var Vu=gt({name:"imagePaste",onSchemaReady(e){return {plugins:[new Plugin({props:{handleDOMEvents:{paste(n,o){let r=o,i=L(r.clipboardData);return i.length===0||!n.state.schema.nodes.image?false:(r.preventDefault(),Yh(n,i).catch(()=>{}),true)}}}})]}}});var Uu=gt({name:"dropCursor",onSchemaReady(){return {plugins:[dropCursor({color:"var(--doc-primary, #4285f4)",width:2})]}}});var $i=new PluginKey("paragraphChangeTracker");function ju(e){let t=0;return e.descendants(n=>{n.type.name==="paragraph"&&t++;}),t}function sl(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 nb(e,t,n){let o=Math.min(t,n),r=Math.max(t,n),i=r>o?r:o+1,a=sl(e,o,i);if(a.ids.size>0||a.hasUntracked)return a;try{let s=e.resolve(o);for(let l=s.depth;l>=0;l--){let u=s.node(l);if(u.type.name==="paragraph"){let d=u.attrs.paraId;return d?{ids:new Set([d]),hasUntracked:!1}:{ids:new Set,hasUntracked:!0}}}}catch{}return {ids:new Set,hasUntracked:false}}function ob(){return new Plugin({key:$i,state:{init(e,t){return {changedParaIds:new Set,structuralChange:false,hasUntrackedChanges:false,paragraphCount:ju(t.doc)}},apply(e,t){if(e.getMeta($i)==="clear")return {changedParaIds:new Set,structuralChange:false,hasUntrackedChanges:false,paragraphCount:t.paragraphCount};if(!e.docChanged)return t;let n=ju(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){if(r instanceof AddMarkStep||r instanceof RemoveMarkStep){let{ids:a,hasUntracked:s}=nb(e.doc,r.from,r.to);for(let l of a)o.changedParaIds.add(l);s&&(o.hasUntrackedChanges=true);continue}if(r instanceof AddNodeMarkStep||r instanceof RemoveNodeMarkStep){let a=r.pos,s=e.doc.nodeAt(a),l=s?a+s.nodeSize:a+1,{ids:u,hasUntracked:d}=sl(e.doc,a,l);for(let c of u)o.changedParaIds.add(c);d&&(o.hasUntrackedChanges=true);continue}r.getMap().forEach((a,s,l,u)=>{let{ids:d,hasUntracked:c}=sl(e.doc,l,u);for(let p of d)o.changedParaIds.add(p);c&&(o.hasUntrackedChanges=true);});}return o}}})}function ll(e){return $i.getState(e)}function Ku(e){return ll(e)?.changedParaIds??new Set}function Gu(e){return ll(e)?.structuralChange??false}function Yu(e){return ll(e)?.hasUntrackedChanges??false}function qu(e){return e.tr.setMeta($i,"clear")}var Xu=gt({name:"paragraphChangeTracker",defaultOptions:{},onSchemaReady(){return {plugins:[ob()]}}});var Zu=gt({name:"bidiShortcut",priority:Qt.High,onSchemaReady(e){return {plugins:[new Plugin({props:{handleKeyDown(t,n){if(n.key!=="Shift"||!(n.metaKey||n.ctrlKey))return false;let r=Yn.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 Ju(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 ab(e,t){let n=e.getAttribute("style")||"",o=Ju(n);for(let[r,i]of Object.entries(t))r in o||e.style.setProperty(r,i);}function sb(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=Ju(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)ab(a,r);}catch{}}function lb(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 cb(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){sb(r);let i=r.querySelectorAll("style");for(let a of i)a.remove();}return n&&lb(r),r.body.innerHTML}catch{return e}}var Qu=gt({name:"pasteStyleInliner",priority:Qt.High,onSchemaReady(){return {plugins:[new Plugin({props:{transformPastedHTML(t){return cb(t)}}})]}}});function Qo(e={}){let t=new Set(e.disable||[]),n=[];function o(r,i){t.has(r)||n.push(i);}return o("doc",Pd()),o("text",Md()),o("paragraph",Dd()),o("history",Nd({depth:e.historyDepth,newGroupDelay:e.historyNewGroupDelay})),o("bold",Od()),o("italic",_d()),o("underline",jd()),o("strike",Kd()),o("textColor",Gd()),o("highlight",Yd()),o("fontSize",qd()),o("fontFamily",Xd()),o("superscript",Zd()),o("subscript",Jd()),o("hyperlink",Qd()),o("allCaps",eu()),o("smallCaps",tu()),o("footnoteRef",nu()),o("characterSpacing",ou()),o("emboss",su()),o("imprint",lu()),o("textShadow",cu()),o("emphasisMark",du()),o("textOutline",uu()),o("comment",ru()),o("insertion",iu()),o("deletion",au()),o("hardBreak",pu()),o("tab",fu()),o("image",mu()),o("textBox",gu()),o("shape",hu()),o("imageDrag",Wu()),o("imagePaste",Vu()),o("dropCursor",Uu()),o("horizontalRule",bu()),o("pageBreak",yu()),o("field",xu()),o("sdt",Su()),o("math",ku()),t.has("table")||n.push(...Fu()),o("pasteStyleInliner",Qu()),o("list",Bu()),o("baseKeymap",Nu()),o("selectionTracker",$u({onSelectionChange:e.onSelectionChange})),o("paragraphChangeTracker",Xu()),o("bidiShortcut",Zu()),n}var qn=class{constructor(t){d$1(this,"extensions");d$1(this,"schema",null);d$1(this,"plugins",[]);d$1(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 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=>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 _i=new qn(Qo());_i.buildSchema();_i.initializeRuntime();var Yn=_i,we=_i.getSchema();var pb={styleId:"Normal",type:"paragraph",name:"Normal",default:true,pPr:{spaceAfter:160,lineSpacing:259,lineSpacingRule:"auto"}},Fr=class{constructor(t){d$1(this,"stylesById");d$1(this,"docDefaults");d$1(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")??pb}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 Fr(e)}function cl(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(...ep(i,r)),Rb(i)&&o.push(we.node("pageBreak"));else if(i.type==="table"){let a=ul(i,r);o.push(a);}return o.length===0&&o.push(we.node("paragraph",{},[])),we.node("doc",null,o)}function dl(e,t,n,o){let r=mb(e,t),i=[],a,s=new Set,l;t&&(l=t.resolveParagraphStyle(e.formatting?.styleId).runFormatting);let u=vn(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=pl(d,u,t);s.size>0&&(c=fb(c,s)),i.push(...c);}else if(d.type==="hyperlink"){let c=fl(d,u,t);i.push(...c);}else if(d.type==="simpleField"||d.type==="complexField"){let c=yb(d,u);c&&i.push(c);}else if(d.type==="inlineSdt"){let c=Sb(d,u,t);c&&i.push(c);}else if(d.type==="insertion"){let c=Wi(d,"insertion",u,t);i.push(...c);}else if(d.type==="deletion"){let c=Wi(d,"deletion",u,t);i.push(...c);}else if(d.type==="moveFrom"){let c=Wi(d,"deletion",u,t);i.push(...c);}else if(d.type==="moveTo"){let c=Wi(d,"insertion",u,t);i.push(...c);}else if(d.type==="mathEquation"){let c=xb(d);c&&i.push(c);}d.type==="bookmarkStart"&&(a||(a=[]),a.push({id:d.id,name:d.name}));}return a&&(r.bookmarks=a),we.node("paragraph",r,i)}function fb(e,t){if(t.size===0)return e;let n=[...t][0],o=we.marks.comment.create({commentId:n});return e.map(r=>r.isText?r.mark(o.addToSet(r.marks)):r)}function Wi(e,t,n,o){let r=[];for(let a of e.content)a.type==="run"?r.push(...pl(a,n,o)):a.type==="hyperlink"&&r.push(...fl(a,n,o));let i=we.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 mb(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=Vi(n?.runProperties,t);r.defaultTextFormatting=vn(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=Vi(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 Yt(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=Vi(r.pPr?.runProperties,e),a=Vi(r.rPr,e),s=vn(i,a);return {tcPr:r.tcPr,rPr:s}}function wn(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=vn(e.rPr,t.rPr),n}function Vi(e,t){if(!e)return;if(!e.styleId||!t)return e;let n=t.resolveRunStyle(e.styleId);return vn(n,e)}function gb(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 ul(e,t){let n=gb(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:Yt(t,i,"wholeTable"),firstRow:Yt(t,i,"firstRow"),lastRow:Yt(t,i,"lastRow"),firstCol:Yt(t,i,"firstCol"),lastCol:Yt(t,i,"lastCol"),band1Horz:Yt(t,i,"band1Horz"),band2Horz:Yt(t,i,"band2Horz"),band1Vert:Yt(t,i,"band1Vert"),band2Vert:Yt(t,i,"band2Vert"),nwCell:Yt(t,i,"nwCell"),neCell:Yt(t,i,"neCell"),swCell:Yt(t,i,"swCell"),seCell:Yt(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 v=B===0&&!!a?.firstRow,E=B===g-1&&!!a?.lastRow,V=f&&!v&&!E?b%2===0?p.band1Horz:p.band2Horz:void 0;return f&&!v&&!E&&b++,hb(S,t,v,o,r,p,V,m,a,l,B,g,x,n,d)});return we.node("table",c,T)}function hb(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:!!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,v=S?.lastRow??T,E=p??g,V=0,D=[];for(let P=0;P<e.cells.length;P++){let I=e.cells[P],J=I.formatting?.gridSpan??1,se=`${d??0}-${V}`,ie=f?.get(se),z=ie?.skip??false,N=ie?.rowSpan??1,ue;if(o&&r&&r>0){let oe=0;for(let ee=0;ee<J&&V+ee<o.length;ee++)oe+=o[V+ee];ue=Math.round(oe/r*100);}if(V+=J,z)continue;let me=V-J===0,Ee=V===E,ce=I.formatting?.conditionalFormat,Y=ce?.firstRow??B,R=ce?.lastRow??v,L=ce?.firstColumn??me,k=ce?.lastColumn??Ee,M;if(s){let oe=l?.firstColumn?1:0,ee=V-J-oe;ee>=0&&!(l?.lastColumn&&k)&&!(l?.firstColumn&&L)&&(M=ee%2===0?i?.band1Vert:i?.band2Vert);}ce?.oddVBand?M=i?.band1Vert:ce?.evenVBand&&(M=i?.band2Vert);let F=a;S?.oddHBand?F=i?.band1Horz:S?.evenHBand&&(F=i?.band2Horz),ce?.oddHBand?F=i?.band1Horz:ce?.evenHBand&&(F=i?.band2Horz);let H=i?.wholeTable;H=wn(H,F),H=wn(H,M),Y&&(l?.firstRow||S?.firstRow||ce?.firstRow)&&(H=wn(H,i?.firstRow)),R&&(l?.lastRow||S?.lastRow||ce?.lastRow)&&(H=wn(H,i?.lastRow)),L&&(l?.firstColumn||S?.firstColumn||ce?.firstColumn)&&(H=wn(H,i?.firstCol)),k&&(l?.lastColumn||S?.lastColumn||ce?.lastColumn)&&(H=wn(H,i?.lastCol)),Y&&L&&(l?.firstRow||S?.firstRow||ce?.firstRow)&&(l?.firstColumn||S?.firstColumn||ce?.firstColumn)&&(H=wn(H,i?.nwCell)),Y&&k&&(l?.firstRow||S?.firstRow||ce?.firstRow)&&(l?.lastColumn||S?.lastColumn||ce?.lastColumn)&&(H=wn(H,i?.neCell)),R&&L&&(l?.lastRow||S?.lastRow||ce?.lastRow)&&(l?.firstColumn||S?.firstColumn||ce?.firstColumn)&&(H=wn(H,i?.swCell)),R&&k&&(l?.lastRow||S?.lastRow||ce?.lastRow)&&(l?.lastColumn||S?.lastColumn||ce?.lastColumn)&&(H=wn(H,i?.seCell)),D.push(bb(I,t,n,ue,H,u,x,T,me,Ee,N,m));}return we.node("tableRow",b,D)}function bb(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,v={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},E=[];for(let D of e.content)D.type==="paragraph"?E.push(dl(D,t,void 0,r?.rPr)):D.type==="table"&&E.push(ul(D,t));E.length===0&&E.push(we.node("paragraph",{},[]));let V=n?"tableHeader":"tableCell";return we.node(V,v,E)}function yb(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=vn(t,o),a=ml(i);return we.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 xb(e){return we.node("math",{display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""})}function Sb(e,t,n){let o=e.properties,r=[];for(let i of e.content)if(i.type==="run"){let a=pl(i,t,n);r.push(...a);}else if(i.type==="hyperlink"){let a=fl(i,t,n);r.push(...a);}return we.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 pl(e,t,n){let o=[],r=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0,i=vn(vn(t,r),e.formatting),a=ml(i);for(let s of e.content){let l=kb(s,a);o.push(...l);}return o}function vn(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 kb(e,t){switch(e.type){case "text":return e.text?[we.text(e.text,t)]:[];case "break":return e.breakType==="textWrapping"||!e.breakType?[we.node("hardBreak")]:[];case "tab":return [we.node("tab")];case "drawing":return e.image?[Cb(e.image)]:[];case "shape":{let r=e.shape;return r.textBody&&r.textBody.content.length>0?[]:[Tb(r)]}case "footnoteRef":let n=we.mark("footnoteRef",{id:e.id.toString(),noteType:"footnote"});return [we.text(e.id.toString(),[...t,n])];case "endnoteRef":let o=we.mark("footnoteRef",{id:e.id.toString(),noteType:"endnote"});return [we.text(e.id.toString(),[...t,o])];default:return []}}function Cb(e){let t=e.size?.width?c$2(e.size.width):void 0,n=e.size?.height?c$2(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?c$2(e.wrap.distT):void 0,d=e.wrap.distB?c$2(e.wrap.distB):void 0,c=e.wrap.distL?c$2(e.wrap.distL):void 0,p=e.wrap.distR?c$2(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 we.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 fl(e,t,n){let o=[],r=e.href||(e.anchor?`#${e.anchor}`:""),i=we.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=vn(vn(t,s),a.formatting),d=[...ml(l),i];for(let c of a.content)c.type==="text"&&c.text&&o.push(we.text(c.text,d));}return o}function ml(e){if(!e)return [];let t=[];return e.bold&&t.push(we.mark("bold")),e.italic&&t.push(we.mark("italic")),e.underline&&e.underline.style!=="none"&&t.push(we.mark("underline",{style:e.underline.style,color:e.underline.color})),(e.strike||e.doubleStrike)&&t.push(we.mark("strike",{double:e.doubleStrike||false})),e.color&&!e.color.auto&&t.push(we.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(we.mark("highlight",{color:e.highlight})),e.fontSize&&t.push(we.mark("fontSize",{size:e.fontSize})),e.fontFamily&&t.push(we.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(we.mark("superscript")):e.vertAlign==="subscript"&&t.push(we.mark("subscript")),e.allCaps&&t.push(we.mark("allCaps")),e.smallCaps&&t.push(we.mark("smallCaps")),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&t.push(we.mark("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null})),e.emboss&&t.push(we.mark("emboss")),e.imprint&&t.push(we.mark("imprint")),e.shadow&&t.push(we.mark("textShadow")),e.emphasisMark&&e.emphasisMark!=="none"&&t.push(we.mark("emphasisMark",{type:e.emphasisMark})),e.outline&&t.push(we.mark("textOutline")),t}function Tb(e){let t=e.size?.width?c$2(e.size.width):100,n=e.size?.height?c$2(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 we.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 ep(e,t){let n=wb(e),o=dl(e,t),r=[];n.length>0&&o.content.size===0||r.push(o);for(let a of n)r.push(vb(a,t));return r}function wb(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 vb(e,t){let n=e.size?.width?c$2(e.size.width):200,o=e.size?.height?c$2(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?c$2(e.margins.top):4,u=e.margins?.bottom!=null?c$2(e.margins.bottom):4,d=e.margins?.left!=null?c$2(e.margins.left):7,c=e.margins?.right!=null?c$2(e.margins.right):7,p=[];for(let f of e.content)p.push(dl(f,t));return p.length===0&&p.push(we.node("paragraph",{},[])),we.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 gl(e,t){let n=[],o=t?.styles?To(t.styles):null;for(let r of e)r.type==="paragraph"?n.push(...ep(r,o)):r.type==="table"&&n.push(ul(r,o));return n.length===0&&n.push(we.node("paragraph",{},[])),we.node("doc",null,n)}function Rb(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 hl(){return we.node("doc",null,[we.node("paragraph",{},[])])}function np(e,t){let o={content:op(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 op(e){let t=[],n=ip(e);return e.forEach(o=>{o.type.name==="paragraph"?t.push(bl(o,n)):o.type.name==="table"?t.push(sp(o,n)):o.type.name==="textBox"?t.push(Gb(o)):o.type.name==="pageBreak"&&t.push(Eb());}),t}function Eb(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function bl(e,t){let n=e.attrs,o=Pb(rp(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:Mb(n),content:o};return n._sectionProperties?i.sectionProperties=n._sectionProperties:n.sectionBreakType&&(i.sectionProperties={sectionStart:n.sectionBreakType}),i}function Pb(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 Mb(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 rp(e,t){let n=[],o=t??ip(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(v=>v.type.name!=="insertion"&&v.type.name!=="deletion"),m=yl(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=Ib(c),f=a?.href||(a?.anchor?`#${a.anchor}`:"");a&&f===p||(r&&(n.push(r),r=null,i=null),a&&n.push(a),a=Lb(c)),tp(a,s);return}if(a&&(n.push(a),a=null),s.isText){let p=Fb(s.marks);r&&i===p?Bb(r,s.text||""):(r&&n.push(r),r=ap(s.text||"",s.marks),i=p);}else s.type.name==="hardBreak"?(r&&(n.push(r),r=null,i=null),n.push(Ab())):s.type.name==="image"?(r&&(n.push(r),r=null,i=null),n.push(Ob(s))):s.type.name==="shape"?(r&&(n.push(r),r=null,i=null),n.push($b(s))):s.type.name==="tab"?(r&&(n.push(r),r=null,i=null),n.push(Db())):s.type.name==="field"?(r&&(n.push(r),r=null,i=null),n.push(Hb(s,s.marks))):s.type.name==="sdt"?(r&&(n.push(r),r=null,i=null),n.push(zb(s))):s.type.name==="math"&&(r&&(n.push(r),r=null,i=null),n.push(Nb(s)));}),r&&n.push(r),a&&n.push(a),n}function ip(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 Ib(e){return e.attrs.href||""}function Fb(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 Lb(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 tp(e,t){if(t.isText&&t.text){let n=t.marks.filter(r=>r.type.name!=="hyperlink"),o=ap(t.text,n);e.children.push(o);}}function ap(e,t){let n=yl(t),o={type:"text",text:e};return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:[o]}}function Bb(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 Ab(){return {type:"run",content:[{type:"break",breakType:"textWrapping"}]}}function Db(){return {type:"run",content:[{type:"tab"}]}}function Hb(e,t){let n=e.attrs,o=t&&t.length>0?yl(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 Nb(e){let t=e.attrs;return {type:"mathEquation",display:t.display||"inline",ommlXml:t.ommlXml,plainText:t.plainText||void 0}}function zb(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=rp(e).filter(i=>i.type==="run"||i.type==="hyperlink");return {type:"inlineSdt",properties:n,content:r}}function Ob(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:d$3(t.width||0),height:d$3(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 $b(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 yl(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 _b(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 sp(e,t){let n=e.attrs,o=[];e.forEach(i=>{i.type.name==="tableRow"&&o.push(Vb(i,t));});let r=Wb(n)||void 0;if(!r?.borders){let i=_b(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 Wb(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 Vb(e,t){let n=e.attrs,o=[];return e.forEach(r=>{(r.type.name==="tableCell"||r.type.name==="tableHeader")&&o.push(jb(r,t));}),{type:"tableRow",formatting:Ub(n),cells:o}}function Ub(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 jb(e,t){let n=e.attrs,o=[];return e.forEach(r=>{r.type.name==="paragraph"?o.push(bl(r,t)):r.type.name==="table"&&o.push(sp(r,t));}),{type:"tableCell",formatting:Kb(n),content:o}}function Kb(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 Gb(e){let t=e.attrs,n=[];e.forEach(a=>{a.type.name==="paragraph"&&n.push(bl(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 Ui(e){return op(e)}function er(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 Mt=Yn.getCommands(),ji=Mt.toggleBold(),Ki=Mt.toggleItalic(),Gi=Mt.toggleUnderline(),Yi=Mt.toggleStrike(),qi=Mt.toggleSuperscript(),Xi=Mt.toggleSubscript();function Lr(e){return Mt.setTextColor(e)}var Zi=Mt.clearTextColor();function Ji(e){return Mt.setHighlight(e)}Mt.clearHighlight();function Qi(e){return Mt.setFontSize(e)}Mt.clearFontSize();function ea(e){return Mt.setFontFamily(e)}Mt.clearFontFamily();function ta(e,t){return Mt.setHyperlink(e,t)}var na=Mt.removeHyperlink();function Br(e,t,n){return Mt.insertHyperlink(e,t,n)}var at=Yn.getCommands();function oa(e){return at.setAlignment(e)}at.alignLeft();at.alignCenter();at.alignRight();at.alignJustify();function ra(e,t="auto"){return at.setLineSpacing(e,t)}at.singleSpacing();at.oneAndHalfSpacing();at.doubleSpacing();function ia(e=720){return at.increaseIndent(e)}function aa(e=720){return at.decreaseIndent(e)}function sa(e){return at.setIndentLeft(e)}function la(e){return at.setIndentRight(e)}function Ar(e,t){return at.setIndentFirstLine(e,t)}var ca=at.toggleBulletList(),da=at.toggleNumberedList(),ua=at.increaseListLevel(),pa=at.decreaseListLevel();at.removeList();function Dr(e,t){return at.applyStyle(e,t)}at.clearStyle();at.removeSectionBreak();function fa(e){return at.removeTabStop(e)}var ma=at.setRtl(),ga=at.setLtr(),ha=at.generateTOC();var nt=Yn.getCommands();function ba(e,t){return nt.insertTable(e,t)}function Hr(e,t){return nt.addRowAbove()(e,t)}function wo(e,t){return nt.addRowBelow()(e,t)}function Nr(e,t){return nt.deleteRow()(e,t)}function zr(e,t){return nt.addColumnLeft()(e,t)}function vo(e,t){return nt.addColumnRight()(e,t)}function Or(e,t){return nt.deleteColumn()(e,t)}function $r(e,t){return nt.deleteTable()(e,t)}function ya(e,t){return nt.selectTable()(e,t)}function xa(e,t){return nt.selectRow()(e,t)}function Sa(e,t){return nt.selectColumn()(e,t)}function ka(e,t){return nt.mergeCells()(e,t)}function Ca(e,t){return nt.splitCell()(e,t)}function Xn(e,t,n){return nt.setCellBorder(e,t,n)}function Ta(e,t){return nt.removeTableBorders()(e,t)}function wa(e,t,n){return nt.setAllTableBorders(n)(e,t)}function va(e,t,n){return nt.setOutsideTableBorders(n)(e,t)}function Ra(e,t,n){return nt.setInsideTableBorders(n)(e,t)}function Ea(e){return nt.setCellVerticalAlign(e)}function Pa(e){return nt.setCellMargins(e)}function Ma(e){return nt.setCellTextDirection(e)}function Ia(){return nt.toggleNoWrap()}function Fa(e,t){return nt.setRowHeight(e,t)}function La(){return nt.toggleHeaderRow()}function Ba(){return nt.distributeColumns()}function Aa(){return nt.autoFitContents()}function _r(e){return nt.setTableProperties(e)}function Da(e){return nt.applyTableStyle(e)}function Ha(e){return nt.setCellFillColor(e)}function Na(e){return nt.setTableBorderColor(e)}function za(e){return nt.setTableBorderWidth(e)}var Oa=(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,Fragment$1.from([s,r.create()])),u=d+l+1;}else if(i.parentOffset===i.parent.content.size){let d=i.after();a.insert(d,Fragment$1.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,Fragment$1.from([s,r.create()])),u=d+l+1;}a.setSelection(TextSelection.create(a.doc,u)),t(a.scrollIntoView());}return true};function Sp(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 kp(e,t){return Sp(e,t,"accept")}function Cp(e,t){return Sp(e,t,"reject")}var wp={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"2px 0",fontSize:11,color:"#4285f4",userSelect:"none"},vp={fontWeight:500,letterSpacing:.3},my={background:"none",border:"none",color:"#4285f4",cursor:"pointer",fontSize:11,padding:"2px 6px",borderRadius:3},gy={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"},$a={display:"block",width:"100%",padding:"6px 12px",border:"none",background:"none",textAlign:"left",cursor:"pointer",fontSize:12,color:"#3c4043"},Ep=forwardRef(function({headerFooter:t,position:n,styles:o,targetElement:r,parentElement:i,onSave:a,onClose:s,onSelectionChange:l,onRemove:u},d){let c=useRef(null),p=useRef(null),[f,m]=useState(false),[b,g]=useState(false),x=useRef(null),[T,S]=useState(null);useLayoutEffect(()=>{let D=()=>{let I=i.getBoundingClientRect(),J=r.getBoundingClientRect();S({top:J.top-I.top+i.scrollTop,left:J.left-I.left+i.scrollLeft,width:J.width});};D();let P=i.closest('[style*="overflow"]')||i;return P.addEventListener("scroll",D),window.addEventListener("resize",D),()=>{P.removeEventListener("scroll",D),window.removeEventListener("resize",D);}},[r,i]),useEffect(()=>{if(!c.current||p.current)return;let D=gl(t.content,{styles:o||void 0}),P=new qn(Qo());P.buildSchema(),P.initializeRuntime();let I=P.getPlugins(),J=EditorState.create({doc:D,schema:we,plugins:I}),se=new EditorView(c.current,{state:J,dispatchTransaction(ie){let z=se.state.apply(ie);if(se.updateState(z),ie.docChanged&&m(true),ie.selectionSet||ie.docChanged){let N=er(z);l?.(N);}}});return p.current=se,requestAnimationFrame(()=>{se.focus();let ie=er(se.state);l?.(ie);}),()=>{se.destroy(),p.current=null;}},[T]);let B=useCallback(()=>{if(!p.current)return;let D=Ui(p.current.state.doc);a(D);},[a]),v=useCallback(()=>{f?B():s();},[f,B,s]);useEffect(()=>{function D(P){P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),v());}return document.addEventListener("keydown",D,true),()=>document.removeEventListener("keydown",D,true)},[v]),useEffect(()=>{if(!b)return;function D(P){x.current&&!x.current.contains(P.target)&&g(false);}return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[b]),useImperativeHandle(d,()=>({getView:()=>p.current,focus:()=>p.current?.focus(),undo:()=>{let D=p.current;return D?undo(D.state,D.dispatch):false},redo:()=>{let D=p.current;return D?redo(D.state,D.dispatch):false}}));let E=n==="header"?"Header":"Footer";if(!T)return null;let V={position:"absolute",top:T.top,left:T.left,width:T.width,zIndex:10};return jsxs("div",{className:"hf-inline-editor",style:V,onMouseDown:D=>{D.stopPropagation();},children:[n==="footer"&&jsxs("div",{className:"hf-separator-bar",style:wp,children:[jsx("span",{style:vp,children:E}),jsx(Rp,{label:E,showOptions:b,setShowOptions:g,optionsRef:x,onRemove:u,onClose:v,viewRef:p})]}),jsx("div",{ref:c,className:"hf-editor-pm",style:{minHeight:40,outline:"none"}}),n==="header"&&jsxs("div",{className:"hf-separator-bar",style:wp,children:[jsx("span",{style:vp,children:E}),jsx(Rp,{label:E,showOptions:b,setShowOptions:g,optionsRef:x,onRemove:u,onClose:v,viewRef:p})]})]})});function Rp({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=we.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 jsxs("div",{style:{position:"relative"},ref:o,children:[jsx("button",{type:"button",style:my,onClick:l=>{l.stopPropagation(),n(u=>!u);},onMouseDown:l=>l.stopPropagation(),children:"Options \u25BE"}),t&&jsxs("div",{style:gy,children:[jsx("button",{type:"button",style:$a,onClick:()=>{n(false),s("PAGE");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert current page number"}),jsx("button",{type:"button",style:$a,onClick:()=>{n(false),s("NUMPAGES");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert total page count"}),jsx("div",{style:{borderTop:"1px solid #e8eaed",margin:"4px 0"}}),r&&jsxs("button",{type:"button",style:$a,onClick:()=>{n(false),r();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Remove ",e.toLowerCase()]}),jsxs("button",{type:"button",style:$a,onClick:()=>{n(false),i();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Close ",e.toLowerCase()," editing"]})]})]})}var Fp={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"},by={...Fp,padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",maxWidth:"400px"},yy={...Fp,padding:"12px",width:"320px"},wl={width:"20px",height:"20px",flexShrink:0,color:"#5f6368",display:"flex",alignItems:"center",justifyContent:"center"},xy={color:"#1a73e8",textDecoration:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"220px",fontSize:"14px",lineHeight:"20px",cursor:"pointer"},Sy={width:"28px",height:"28px",display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"none",borderRadius:"4px",cursor:"pointer",color:"#5f6368",padding:0,flexShrink:0},ky={width:"1px",height:"20px",background:"#dadce0",flexShrink:0},Mp={display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},Ip={flex:1,padding:"6px 8px",border:"1px solid #dadce0",borderRadius:"4px",fontSize:"14px",outline:"none",lineHeight:"20px"},Cy={color:"#1a73e8",fontWeight:600,fontSize:"14px",border:"none",background:"none",cursor:"pointer",padding:"6px 12px",borderRadius:"4px",flexShrink:0},tr={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};function Ty(){return jsxs("svg",{...tr,children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M2 12h20"}),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 wy(){return jsxs("svg",{...tr,children:[jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function vy(){return jsx("svg",{...tr,children:jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function Ry(){return jsxs("svg",{...tr,children:[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"}),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"}),jsx("line",{x1:"8",y1:"2",x2:"8",y2:"5"}),jsx("line",{x1:"2",y1:"8",x2:"5",y2:"8"}),jsx("line",{x1:"16",y1:"19",x2:"16",y2:"22"}),jsx("line",{x1:"19",y1:"16",x2:"22",y2:"16"})]})}function Ey(){return jsxs("svg",{...tr,children:[jsx("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),jsx("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),jsx("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),jsx("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function Py(){return jsxs("svg",{...tr,children:[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"}),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 vl({title:e,onClick:t,children:n}){return jsx("button",{type:"button",className:"ep-hyperlink-popup__icon-btn",style:Sy,title:e,onClick:t,children:n})}function Lp({data:e,onNavigate:t,onCopy:n,onEdit:o,onRemove:r,onClose:i,readOnly:a}){let[s,l]=useState("view"),[u,d]=useState(""),[c,p]=useState(""),f=useRef(null),m=useRef(null);useEffect(()=>{e&&(l("view"),d(e.displayText),p(e.href));},[e]),useEffect(()=>{s==="edit"&&requestAnimationFrame(()=>{m.current?.focus(),m.current?.select();});},[s]),useEffect(()=>{if(!e)return;let E=false,V=P=>{f.current&&!f.current.contains(P.target)&&i();},D=setTimeout(()=>{E||document.addEventListener("mousedown",V);},0);return ()=>{E=true,clearTimeout(D),document.removeEventListener("mousedown",V);}},[e,i]),useEffect(()=>{if(!e)return;let E=V=>{V.key==="Escape"&&(s==="edit"?l("view"):i());};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[e,s,i]);let b=useCallback(()=>{e&&(n(e.href),toast("Link copied to clipboard"));},[e,n]),g=useCallback(()=>{e&&(d(e.displayText),p(e.href),l("edit"));},[e]),x=useCallback(()=>{let E=c.trim();E&&o(u.trim()||E,E);},[u,c,o]),T=useCallback(E=>{E.key==="Enter"&&(E.preventDefault(),x());},[x]);if(!e)return null;let{anchorRect:S}=e,B=S.bottom+4,v=S.left;return s==="edit"?jsxs("div",{ref:f,className:"ep-hyperlink-popup ep-hyperlink-popup--edit",style:{...yy,top:B,left:v},onMouseDown:E=>E.stopPropagation(),children:[jsxs("div",{style:Mp,children:[jsx("span",{style:wl,children:jsx(Ey,{})}),jsx("input",{ref:m,type:"text",style:Ip,value:u,onChange:E=>d(E.target.value),onKeyDown:T,placeholder:"Display text",onFocus:E=>E.target.style.borderColor="#1a73e8",onBlur:E=>E.target.style.borderColor="#dadce0"})]}),jsxs("div",{style:{...Mp,marginBottom:0},children:[jsx("span",{style:wl,children:jsx(Py,{})}),jsx("input",{type:"text",style:Ip,value:c,onChange:E=>p(E.target.value),onKeyDown:T,placeholder:"https://example.com",onFocus:E=>E.target.style.borderColor="#1a73e8",onBlur:E=>E.target.style.borderColor="#dadce0"}),jsx("button",{type:"button",style:{...Cy,opacity:c.trim()?1:.5,cursor:c.trim()?"pointer":"default"},onClick:x,disabled:!c.trim(),children:"Apply"})]})]}):jsxs("div",{ref:f,className:"ep-hyperlink-popup",style:{...by,top:B,left:v},onMouseDown:E=>E.stopPropagation(),children:[jsx("span",{style:wl,children:jsx(Ty,{})}),jsx("a",{href:e.href,style:xy,title:e.href,target:"_blank",rel:"noopener noreferrer",onClick:E=>{E.preventDefault(),t(e.href);},children:e.href}),jsx("span",{style:ky}),jsx(vl,{title:"Copy link",onClick:b,children:jsx(wy,{})}),!a&&jsxs(Fragment,{children:[jsx(vl,{title:"Edit link",onClick:g,children:jsx(vy,{})}),jsx(vl,{title:"Remove link",onClick:r,children:jsx(Ry,{})})]})]})}var Re=e=>({style:"single",size:4,color:{rgb:e}}),Iy=[{id:"TableNormal",name:"Normal Table",look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGrid",name:"Table Grid",tableBorders:{top:Re("000000"),bottom:Re("000000"),left:Re("000000"),right:Re("000000"),insideH:Re("000000"),insideV:Re("000000")},look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGridLight",name:"Grid Table Light",tableBorders:{top:Re("BFBFBF"),bottom:Re("BFBFBF"),left:Re("BFBFBF"),right:Re("BFBFBF"),insideH:Re("BFBFBF"),insideV:Re("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:Re("000000")}}}},{id:"PlainTable1",name:"Plain Table 1",tableBorders:{top:Re("BFBFBF"),bottom:Re("BFBFBF"),insideH:Re("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:Re("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:Re("B4C6E7"),bottom:Re("B4C6E7"),left:Re("B4C6E7"),right:Re("B4C6E7"),insideH:Re("B4C6E7"),insideV:Re("B4C6E7")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:Re("4472C4")}}}},{id:"GridTable4-Accent1",name:"Grid Table 4 Accent 1",tableBorders:{top:Re("4472C4"),bottom:Re("4472C4"),left:Re("4472C4"),right:Re("4472C4"),insideH:Re("4472C4"),insideV:Re("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:Re("FFFFFF"),bottom:Re("FFFFFF"),left:Re("FFFFFF"),right:Re("FFFFFF"),insideH:Re("FFFFFF"),insideV:Re("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:Re("ED7D31"),bottom:Re("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:Re("A5A5A5"),bottom:Re("A5A5A5"),insideH:Re("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:Re("5B9BD5"),bottom:Re("5B9BD5"),left:Re("5B9BD5"),right:Re("5B9BD5"),insideH:Re("5B9BD5"),insideV:Re("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:Re("70AD47"),bottom:Re("70AD47"),left:Re("70AD47"),right:Re("70AD47"),insideH:Re("70AD47"),insideV:Re("70AD47")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#70AD47"},band1Horz:{backgroundColor:"#E2EFDA"}}}];function Bp(e){return Iy.find(t=>t.id===e)}function Ap(){return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"20px",color:"var(--doc-text-muted)"},children:[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"}}),jsx("style",{children:`
|
|
15
|
+
@keyframes docx-spin {
|
|
16
|
+
to { transform: rotate(360deg); }
|
|
17
|
+
}
|
|
18
|
+
`}),jsx("div",{style:{fontSize:"14px"},children:"Loading document..."})]})}function Dp(){return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--doc-text-placeholder)"},children:[jsxs("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsx("polyline",{points:"14 2 14 8 20 8"})]}),jsx("div",{style:{marginTop:"16px"},children:"No document loaded"})]})}function Hp({message:e}){return jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"20px",textAlign:"center"},children:[jsx("div",{style:{color:"var(--doc-error)",marginBottom:"16px"},children:jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M12 8v4M12 16v.01"})]})}),jsx("h3",{style:{color:"var(--doc-error)",marginBottom:"8px"},children:"Failed to Load Document"}),jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function Ly(e,t){return JSON.stringify(e)===JSON.stringify(t)}function By(e,t={}){let{maxEntries:n=100,groupingInterval:o=500,enableKeyboardShortcuts:r=true,isEqual:i=Ly,onUndo:a,onRedo:s,containerRef:l}=t,[u,d]=useState(e),[c,p]=useState([]),[f,m]=useState([]),b=useRef(0),g=useRef(false),x=useCallback((P,I)=>{if(i(u,P))return;if(g.current){d(P);return}let J=Date.now();J-b.current<o&&c.length>0?p(ie=>{let z=[...ie];return z[z.length-1]={state:u,timestamp:J,description:I||z[z.length-1].description},z}):p(ie=>{let z={state:u,timestamp:J,description:I},N=[...ie,z];return N.length>n?N.slice(N.length-n):N}),m([]),d(P),b.current=J;},[u,i,o,n,c.length]),T=useCallback(()=>{if(c.length===0)return;g.current=true;let P=c[c.length-1];return p(I=>I.slice(0,-1)),m(I=>[...I,{state:u,timestamp:Date.now()}]),d(P.state),setTimeout(()=>{g.current=false;},0),a?.(P.state),P.state},[c,u,a]),S=useCallback(()=>{if(f.length===0)return;g.current=true;let P=f[f.length-1];return m(I=>I.slice(0,-1)),p(I=>[...I,{state:u,timestamp:Date.now()}]),d(P.state),setTimeout(()=>{g.current=false;},0),s?.(P.state),P.state},[f,u,s]),B=useCallback(()=>{p([]),m([]);},[]),v=useCallback(P=>{d(P??e),p([]),m([]),b.current=0;},[e]),E=useCallback(()=>[...c],[c]),V=useCallback(()=>[...f],[f]),D=useCallback(P=>{d(I=>P(I)),p(I=>I.map(J=>({...J,state:P(J.state)}))),m(I=>I.map(J=>({...J,state:P(J.state)})));},[]);return useEffect(()=>{if(!r)return;let P=J=>{if((J.ctrlKey||J.metaKey)&&J.key==="z"&&!J.shiftKey){J.preventDefault(),T();return}if((J.ctrlKey||J.metaKey)&&J.key==="y"||(J.ctrlKey||J.metaKey)&&J.key==="z"&&J.shiftKey){J.preventDefault(),S();return}},I=l?.current||document;return I.addEventListener("keydown",P),()=>{I.removeEventListener("keydown",P);}},[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:v,getUndoStack:E,getRedoStack:V,transformAll:D}}function zp(e,t={}){let n=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 By(e,{...t,isEqual:n})}var Zn=new PluginKey("suggestionMode"),Va="suggestionModeApplied",Hy=Date.now();function Ua(e){return {revisionId:Hy++,author:e.author,date:new Date().toISOString()}}function Pl(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 _p(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=Pl(t,n,"deletion",a.author)||Ua(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 Op(e,t,n,o,r){let i=e.state.schema.marks.insertion;if(!i)return false;let a=e.state.tr;a.setMeta(Va,true);let s=Pl(e.state.doc,t,"insertion",r.author)||Ua(r);if(t!==n){let u=e.state.schema.marks.deletion;u&&_p(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 $p(e,t,n){let o=Zn.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(Va,true),!a){_p(u,e.doc,r.pos,i.pos,s,l,o);let x=u.mapping.map(i.pos);return u.setSelection(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(TextSelection.near(u.doc.resolve(x)));}else if(b)u.delete(c,p);else {let x=Pl(e.doc,c,"deletion",o.author)||Ua(o);u.addMark(c,p,l.create(x));let T=d?c:p;u.setSelection(TextSelection.near(u.doc.resolve(T)));}return t(u.scrollIntoView()),true}function Wp(e=false,t="User"){return new Plugin({key:Zn,state:{init(){return {active:e,author:t}},apply(n,o){let r=n.getMeta(Zn);return r?{...o,...r}:o}},props:{handleDOMEvents:{beforeinput(n,o){let r=Zn.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 Op(n,i,a,o.data,r)}return false}},handleKeyDown(n,o){return Zn.getState(n.state)?.active?o.key==="Backspace"?$p(n.state,n.dispatch,"backward"):o.key==="Delete"?$p(n.state,n.dispatch,"forward"):false:false},handleTextInput(n,o,r,i){let a=Zn.getState(n.state);return a?.active?Op(n,o,r,i,a):false}},appendTransaction(n,o,r){let i=Zn.getState(r);if(!i?.active)return null;let a=n.find(c=>c.docChanged&&!c.getMeta(Va));if(!a)return null;let s=r.schema.marks.insertion;if(!s)return null;let l=Ua(i),u=r.tr;u.setMeta(Va,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),v=Math.min(T+x.nodeSize,g);u.addMark(B,v,s.create(l));}});});}),u.steps.length>0?u:null}})}function Vp(e,t,n,o){if(n){let r={active:e};o!==void 0&&(r.author=o);let i=t.tr.setMeta(Zn,r);n(i);}return true}var jy={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function Gp(e,t,n,o=[]){let r=n?.getSchema()??we,i=e?cl(e,{styles:t??void 0}):hl(),a=[...o,...n?.getPlugins()??[]];return EditorState.create({doc:i,schema:r,plugins:a})}function Ky(e,t){return t?np(e.doc,t):null}var Gy=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=useRef(null),g=useRef(null),x=useRef(o),T=useRef(false),S=useRef(null),B=useRef(false),v=useRef(l),E=useRef(u),V=useRef(p),D=useRef(f),P=useRef(m);v.current=l,E.current=u,V.current=p,D.current=f,P.current=m,x.current=o;let I=useCallback(()=>{if(!b.current||T.current)return;let ie={state:Gp(o,r,c,d),editable:()=>!s,dispatchTransaction:z=>{if(!g.current||T.current)return;let N=g.current.state.apply(z);g.current.updateState(N),v.current?.(z,N),(z.selectionSet||z.docChanged)&&E.current?.(N);},handleKeyDown:(z,N)=>P.current?.(z,N)??false,handleDOMEvents:{focus:()=>false,blur:()=>false}};g.current=new EditorView(b.current,ie),V.current?.(g.current);},[o,r,d,c,s]),J=useCallback(()=>{g.current&&!T.current&&(T.current=true,D.current?.(),g.current.destroy(),g.current=null,T.current=false);},[]);return useEffect(()=>(I(),()=>J()),[]),useEffect(()=>{if(!g.current||T.current)return;let ie=(N=>{if(!N)return "empty";let ue=N.package?.properties;return `${ue?.created||""}-${ue?.modified||""}-${ue?.title||""}`})(o);if(B.current&&ie===S.current)return;B.current=true,S.current=ie;let z=Gp(o,r,c,d);g.current.updateState(z),E.current?.(z);},[o,r,c,d]),useEffect(()=>{g.current;},[s]),useImperativeHandle(n,()=>({getState(){return g.current?.state??null},getView(){return g.current??null},getDocument(){return g.current?Ky(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(se){g.current&&!T.current&&g.current.dispatch(se);},executeCommand(se){return g.current?se(g.current.state,g.current.dispatch,g.current):false},undo(){return g.current?undo(g.current.state,g.current.dispatch):false},redo(){return g.current?redo(g.current.state,g.current.dispatch):false},canUndo(){return g.current?undo(g.current.state):false},canRedo(){return g.current?redo(g.current.state):false},setSelection(se,ie){if(!g.current)return;let{state:z,dispatch:N}=g.current,ue=z.doc.resolve(se),me=ie!==void 0?z.doc.resolve(ie):ue,Ee=TextSelection.between(ue,me);N(z.tr.setSelection(Ee));},setNodeSelection(se){if(!g.current)return;let{state:ie,dispatch:z}=g.current;try{let N=NodeSelection.create(ie.doc,se);z(ie.tr.setSelection(N));}catch{this.setSelection(se);}},setCellSelection(se,ie){if(!g.current)return;let{state:z,dispatch:N}=g.current;try{let ue=CellSelection.create(z.doc,se,ie);N(z.tr.setSelection(ue));}catch{this.setSelection(se,ie);}},scrollToSelection(){}}),[]),jsx("div",{ref:b,className:"paged-editor__hidden-pm",style:{...jy,width:a>0?`${a}px`:void 0}})}),Yp=memo(Gy);var Zy="#000",Jy="rgba(66, 133, 244, 0.3)",Qy=2,ex=530,tx={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},nx=(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"}),ox=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),rx=({position:e,color:t,width:n,blinkInterval:o,isFocused:r})=>{let[i,a]=useState(r),s=useRef(null);return 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]),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]),jsx("div",{style:nx(e,t,n,i),"data-testid":"caret"})},ix=({rect:e,color:t,index:n})=>jsx("div",{style:ox(e,t),"data-testid":`selection-rect-${n}`,"data-page-index":e.pageIndex}),Xp=({selectionRects:e,caretPosition:t,isFocused:n,readOnly:o=false,caretColor:r=Zy,selectionColor:i=Jy,caretWidth:a=Qy,blinkInterval:s=ex})=>{if(o)return null;let l=e.length>0,u=t!==null&&!l;return jsxs("div",{style:tx,"data-testid":"selection-overlay",children:[l&&e.map((d,c)=>jsx(ix,{rect:d,color:i,index:c},`sel-${d.pageIndex}-${d.x}-${d.y}-${c}`)),u&&t&&jsx(rx,{position:t,color:r,width:a,blinkInterval:s,isFocused:n})]})};var Fl=10,Jn=Fl/2,jr=2,ef="#2563eb",Jp={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},sx={position:"absolute",border:`${jr}px solid ${ef}`,pointerEvents:"none",boxSizing:"border-box"},lx={position:"absolute",width:`${Fl}px`,height:`${Fl}px`,backgroundColor:ef,border:"1px solid white",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},cx={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%)"},dx={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize"};function ux(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 tf({imageInfo:e,zoom:t,isFocused:n,onResize:o,onResizeStart:r,onResizeEnd:i,onDragMove:a,onDragStart:s,onDragEnd:l}){let[u,d]=useState(false),[c,p]=useState(false),[f,m]=useState(0),[b,g]=useState(0),[x,T]=useState(null),S=useRef(null),B=useRef(null),v=useRef(o),E=useRef(r),V=useRef(i),D=useRef(a),P=useRef(s),I=useRef(l);v.current=o,E.current=r,V.current=i,D.current=a,P.current=s,I.current=l;let J=useRef(e),se=useRef(t);J.current=e,se.current=t;let ie=useCallback(()=>{if(!e||!B.current){T(null);return}let R=B.current.offsetParent;if(!R){T(null);return}let L=R.getBoundingClientRect(),k=e.element.getBoundingClientRect();T({left:(k.left-L.left)/t,top:(k.top-L.top)/t,width:k.width/t,height:k.height/t});},[e,t]);useEffect(()=>{ie();},[ie]),useEffect(()=>{if(!e)return;let R=B.current?.closest('[style*="overflow"]')??B.current?.closest(".paged-editor__container");if(!R)return;let L=()=>{S.current&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(ie);};return R.addEventListener("scroll",L,{passive:true}),window.addEventListener("resize",L,{passive:true}),()=>{R.removeEventListener("scroll",L),window.removeEventListener("resize",L),S.current&&cancelAnimationFrame(S.current);}},[e,ie]);let z=useCallback((R,L)=>{if(!e||!x)return;L.preventDefault(),L.stopPropagation();let k=x.width,M=x.height,F=L.clientX,H=L.clientY,oe=Math.round(k),ee=Math.round(M);d(true),m(oe),g(ee),E.current?.();let _=ne=>{let xe=se.current,re=(ne.clientX-F)/xe,pe=(ne.clientY-H)/xe,de=!ne.shiftKey,Pe=ux(R,re,pe,k,M,de);oe=Math.round(Pe.width),ee=Math.round(Pe.height),m(oe),g(ee),T(De=>{if(!De)return De;let je={...De};return R.includes("w")&&(je.left=De.left+(De.width-Pe.width)),R.includes("n")&&(je.top=De.top+(De.height-Pe.height)),je.width=Pe.width,je.height=Pe.height,je});},G=()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",G),d(false);let ne=J.current;ne&&v.current?.(ne.pmPos,oe,ee),V.current?.();};window.addEventListener("mousemove",_),window.addEventListener("mouseup",G);},[e,x]),N=useCallback(R=>{if(!e||!x)return;R.preventDefault(),R.stopPropagation();let L=4,k=R.clientX,M=R.clientY,F=false,H=null,oe=_=>{let G=_.clientX-k,ne=_.clientY-M;!F&&Math.sqrt(G*G+ne*ne)<L||(F||(F=true,p(true),P.current?.(),H=document.createElement("div"),H.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);",H.style.width=`${x.width}px`,H.style.height=`${x.height}px`,document.body.appendChild(H)),H&&(H.style.left=`${_.clientX-x.width/2}px`,H.style.top=`${_.clientY-x.height/2}px`));},ee=_=>{if(window.removeEventListener("mousemove",oe),window.removeEventListener("mouseup",ee),H&&(H.remove(),H=null),p(false),F){let G=J.current;G&&D.current?.(G.pmPos,_.clientX,_.clientY),I.current?.();}};window.addEventListener("mousemove",oe),window.addEventListener("mouseup",ee);},[e,x]);if(!!!(e&&x&&n))return jsx("div",{ref:B,style:{...Jp,visibility:"hidden"},className:"image-selection-overlay"});let{left:me,top:Ee,width:ce,height:Y}=x;return jsxs("div",{ref:B,style:Jp,className:"image-selection-overlay",children:[jsx("div",{style:{...sx,left:me-jr,top:Ee-jr,width:ce+jr*2,height:Y+jr*2}}),jsx("div",{style:{position:"absolute",left:me,top:Ee,width:ce,height:Y,cursor:c?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:N}),jsx(Ka,{handle:"nw",style:{left:me-Jn,top:Ee-Jn},onMouseDown:z}),jsx(Ka,{handle:"ne",style:{left:me+ce-Jn,top:Ee-Jn},onMouseDown:z}),jsx(Ka,{handle:"se",style:{left:me+ce-Jn,top:Ee+Y-Jn},onMouseDown:z}),jsx(Ka,{handle:"sw",style:{left:me-Jn,top:Ee+Y-Jn},onMouseDown:z}),u&&jsxs("div",{style:{...cx,left:me+ce/2,top:Ee+Y+12},children:[f," \xD7 ",b]})]})}function Ka({handle:e,style:t,onMouseDown:n}){return jsx("div",{style:{...lx,...t,cursor:dx[e]},onMouseDown:o=>n(e,o),"data-handle":e})}var px="Calibri";function Ll(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 fx=11;function ot(e){return e/1440*96}var mx=0;function eo(){return `block-${++mx}`}function gx(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 Ga(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?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=a({rgb:r.rgb,themeColor:r.themeColor,themeTint:r.themeTint,themeShade:r.themeShade},t));break}case "highlight":n.highlight=n$2(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 hx(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=Ga(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",...Ga(a.marks,i),pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="image"){let u=a.attrs,d=Ll(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=Ga(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",...Ga(d.marks,i),pmStart:p,pmEnd:p+d.nodeSize};o.push(m);}else if(d.type.name==="image"){let f=d.attrs,m=Ll(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 bx(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=ot(e.spaceBefore)),e.spaceAfter!=null&&(n.spacing.after=ot(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(n.spacing.line=ot(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=ot(o)),e.indentRight!=null&&(n.indent.right=ot(e.indentRight)),r!=null&&(i?n.indent.hanging=Math.abs(ot(r)):n.indent.firstLine=ot(r))),e.styleId&&(n.styleId=e.styleId),e.borders){let s=e.borders;n.borders={};let l=u=>u?Ya(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:yx(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 yx(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 Bl(e,t,n){let o=e.attrs,r=hx(e,t,n),i=bx(o,n.theme);return {kind:"paragraph",id:eo(),runs:r,attrs:i,pmStart:t,pmEnd:t+e.nodeSize}}function xx(e){return Math.max(1,Math.round(e/8*1.333))}var Sx={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 Ya(e,t){if(!e||!e.style||e.style==="none"||e.style==="nil")return;let n={style:Sx[e.style]||"solid",width:xx(e.size??0),color:e.color?a(e.color,t):"#000000"};return e.space!==void 0&&(n.space=g$1(e.space)),n}function kx(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?Ya(a,t):void 0;o[i]=s??{width:0,style:"none"};}return Object.keys(o).length>0?o:void 0}function Cx(e,t,n){let o=[],r=t+1;e.forEach(l=>{l.type.name==="paragraph"?o.push(Bl(l,r,n)):l.type.name==="table"&&o.push(nf(l,r,n)),r+=l.nodeSize;});let i=e.attrs,a=i.margins,s={top:a?.top!=null?ot(a.top):0,right:a?.right!=null?ot(a.right):7,bottom:a?.bottom!=null?ot(a.bottom):0,left:a?.left!=null?ot(a.left):7};return {id:eo(),blocks:o,colSpan:i.colspan,rowSpan:i.rowspan,width:i.width?ot(i.width):void 0,verticalAlign:i.verticalAlign,background:i.backgroundColor?`#${i.backgroundColor}`:void 0,borders:kx(i,n.theme),padding:s}}function Tx(e,t,n){let o=[],r=t+1;e.forEach(a=>{(a.type.name==="tableCell"||a.type.name==="tableHeader")&&o.push(Cx(a,r,n)),r+=a.nodeSize;});let i=e.attrs;return {id:eo(),cells:o,height:i.height?ot(i.height):void 0,heightRule:i.heightRule??void 0,isHeader:i.isHeader}}function nf(e,t,n){let o=[],r=t+1;e.forEach(m=>{m.type.name==="tableRow"&&o.push(Tx(m,r,n)),r+=m.nodeSize;});let a=e.attrs.columnWidths?.map(ot),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"?ot(d.indent.value):void 0,p=e.attrs.floating,f=p?{horzAnchor:p.horzAnchor,vertAnchor:p.vertAnchor,tblpX:p.tblpX!==void 0?ot(p.tblpX):void 0,tblpXSpec:p.tblpXSpec,tblpY:p.tblpY!==void 0?ot(p.tblpY):void 0,tblpYSpec:p.tblpYSpec,topFromText:p.topFromText!==void 0?ot(p.topFromText):void 0,bottomFromText:p.bottomFromText!==void 0?ot(p.bottomFromText):void 0,leftFromText:p.leftFromText!==void 0?ot(p.leftFromText):void 0,rightFromText:p.rightFromText!==void 0?ot(p.rightFromText):void 0}:void 0;return {kind:"table",id:eo(),rows:o,columnWidths:a,width:s,widthType:l,justification:u,indent:c,floating:f,pmStart:t,pmEnd:t+e.nodeSize}}function wx(e,t,n){let o=e.attrs,r=o.wrapType,i=r==="behind"||r==="inFront",a=Ll(o.width||100,o.height||100,n);return {kind:"image",id:eo(),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 vx(e,t,n){let o=e.attrs,r=[];return e.forEach((i,a)=>{if(i.type.name==="paragraph"){let s=Bl(i,t+1+a,n);r.push(s);}}),{kind:"textBox",id:eo(),width:o.width??d$2,height:o.height??void 0,fillColor:o.fillColor,outlineWidth:o.outlineWidth,outlineColor:o.outlineColor,outlineStyle:o.outlineStyle,margins:{top:o.marginTop??c$1.top,bottom:o.marginBottom??c$1.bottom,left:o.marginLeft??c$1.left,right:o.marginRight??c$1.right},content:r,pmStart:t,pmEnd:t+e.nodeSize}}function of(e,t={}){let n={...t,defaultFont:t.defaultFont??px,defaultSize:t.defaultSize??fx},o=[],r=0,i=new Map;return e.forEach((a,s)=>{let l=r+s;switch(a.type.name){case "paragraph":{let u=Bl(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":gx(m,f);u.attrs={...u.attrs,listMarker:b};}o.push(u);let c=d._sectionProperties;if(c||d.sectionBreakType){let p={kind:"sectionBreak",id:eo(),type:c?.sectionStart??d.sectionBreakType};if(c){(c.pageWidth||c.pageHeight)&&(p.pageSize={w:ot(c.pageWidth??12240),h:ot(c.pageHeight??15840)}),(c.marginTop!==void 0||c.marginLeft!==void 0)&&(p.margins={top:ot(c.marginTop??1440),bottom:ot(c.marginBottom??1440),left:ot(c.marginLeft??1440),right:ot(c.marginRight??1440)});let f=c.columnCount??1;if(f>1){let m={count:f,gap:ot(c.columnSpace??720),equalWidth:c.equalWidth??true,separator:c.separator};p.columns=m;}}o.push(p);}}break;case "table":o.push(nf(a,l,n));break;case "image":o.push(wx(a,l,n.pageContentHeight));break;case "textBox":o.push(vx(a,l,n));break;case "horizontalRule":case "pageBreak":{let u={kind:"pageBreak",id:eo(),pmStart:l,pmEnd:l+a.nodeSize};o.push(u);break}}}),o}var zn=11,Kr="Calibri",qa=1,nr=.5;function Rx(e,t){if(t&&t.length>0)for(let o of t){let r=k$1(o.pos);if(r>e+.5)return Math.max(1,r-e)}let n=e%Al;return Math.max(1,n<.5?Al:Al-n)}function Ex(e,t,n,o=false){let r=1,i=e.length,a=0;for(;r<=i;){let s=r+i>>>1;h$2(e.slice(0,s),t)<=n?(a=s,r=s+1):i=s-1;}return o&&a===0?1:a}function rf(e){return {fontFamily:e.fontFamily??Kr,fontSize:e.fontSize??zn,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function cf(e,t,n){let o=l$2(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*qa;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*qa;return {ascent:r,descent:i,lineHeight:l}}function af(e,t,n){let o=g$2({fontSize:e,fontFamily:n??Kr});return cf(e,t,o)}function sf(e){return e.kind==="text"}function Px(e){return e.kind==="tab"}function Mx(e){return e.kind==="image"}function Ix(e){return e.kind==="lineBreak"}function Fx(e){return e.kind==="field"}function Lx(e){return !e.text||e.text.length===0}function Bx(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 Al=48;function lf(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 Pn(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=l$2(zn)*qa,g=lf(0,b,a,s),x=Math.max(1,f-g.leftMargin-g.rightMargin),T=[];if(o.length===0){let P=r?.defaultFontSize??zn,I=r?.defaultFontFamily??Kr,J=af(P,i,I);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...J}),{kind:"paragraph",lines:T,totalHeight:J.lineHeight}}if(o.length===1&&sf(o[0])&&Lx(o[0])){let P=o[0],I=P.fontSize??r?.defaultFontSize??zn,J=P.fontFamily??r?.defaultFontFamily??Kr,se=af(I,i,J);return T.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...se}),{kind:"paragraph",lines:T,totalHeight:se.lineHeight}}let S={fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,maxFontSize:zn,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:x,leftOffset:g.leftMargin,rightOffset:g.rightMargin},B=()=>{let P=cf(S.maxFontSize,i,S.maxFontMetrics),I={...P};S.maxImageHeightPx>I.lineHeight&&(I.lineHeight=S.maxImageHeightPx,I.ascent=S.maxImageHeightPx*.8,I.descent=S.maxImageHeightPx*.2);let J={fromRun:S.fromRun,fromChar:S.fromChar,toRun:S.toRun,toChar:S.toChar,width:S.width,...I};S.leftOffset>0&&(J.leftOffset=S.leftOffset),S.rightOffset>0&&(J.rightOffset=S.rightOffset),T.push(J),m+=P.lineHeight;},v=(P,I)=>{B();let J=l$2(zn)*qa,se=lf(m,J,a,s),ie=Math.max(1,p-se.leftMargin-se.rightMargin);S={fromRun:P,fromChar:I,toRun:P,toChar:I,width:0,maxFontSize:zn,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:ie,leftOffset:se.leftMargin,rightOffset:se.rightMargin};},E=P=>{let I=P.fontSize??zn;(!S.maxFontMetrics||I>S.maxFontSize)&&(S.maxFontSize=I,S.maxFontMetrics=g$2(P));};for(let P=0;P<o.length;P++){let I=o[P];if(Ix(I)){S.toRun=P,S.toChar=0,v(P+1,0);continue}if(Px(I)){let J=rf(I);E(J);let se=r?.tabs,ie=S.width+(S.leftOffset??0),z=Rx(ie,se);S.width+z>S.availableWidth+nr&&(v(P,0),E(J)),S.width+=z,S.toRun=P,S.toChar=1;continue}if(Mx(I)){let J=I.wrapType,se=I.displayMode==="float"||J&&["square","tight","through"].includes(J);if(I.position&&se){S.toRun=P,S.toChar=1;continue}if(J==="topAndBottom"||I.displayMode==="block"){S.width>0&&v(P,0);let N=I.height,ue=I.distTop??6,me=I.distBottom??6;S.toRun=P,S.toChar=1,S.maxImageHeightPx=N+ue+me,v(P+1,0);continue}let ie=I.width,z=I.height;z>S.maxImageHeightPx&&(S.maxImageHeightPx=z),S.width+ie>S.availableWidth+nr&&v(P,0),S.width+=ie,S.toRun=P,S.toChar=1;continue}if(Fx(I)){let J=I.fallback||"1",se={fontFamily:I.fontFamily??Kr,fontSize:I.fontSize??zn,bold:I.bold,italic:I.italic};E(se);let ie=h$2(J,se);S.width>0&&S.width+ie>S.availableWidth+nr&&(v(P,0),E(se)),S.width+=ie,S.toRun=P,S.toChar=1;continue}if(sf(I)){let J=I,se=J.text,ie=rf(J);if(E(ie),!se||se.length===0){S.toRun=P,S.toChar=0;continue}let z=Bx(se),N=0;for(;N<se.length;){let ue=se.length;for(let ce of z)if(ce>N){ue=ce;break}let me=se.slice(N,ue),Ee=h$2(me,ie);if(Ee>S.availableWidth+nr){let ce=0;for(;ce<me.length;){let Y=S.availableWidth-S.width+nr,R=me.slice(ce),L=Ex(R,ie,Y);if(L===0){if(S.width>0){v(P,N+ce),E(ie);continue}L=1;}let k=ce+L,M=me.slice(ce,k),F=h$2(M,ie);S.width+=F,S.toRun=P,S.toChar=N+k,ce=k,ce<me.length&&(v(P,N+ce),E(ie));}N=ue;continue}S.width>0&&S.width+Ee>S.availableWidth+nr&&(v(P,N),E(ie)),S.width+=Ee,S.toRun=P,S.toChar=ue,N=ue;}}}B();let D=T.reduce((P,I)=>P+I.lineHeight,0);return i?.before&&(D+=i.before),i?.after&&(D+=i.after),{kind:"paragraph",lines:T,totalHeight:D}}var Ax=new Map;function df(){Ax.clear();}var Dx=new Map;function uf(){Dx.clear();}var Hx=5e3,Nx=Hx,to=new Map;function Dl(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 zx(){for(;to.size>Nx;){let e=to.keys().next().value;if(e===void 0)break;to.delete(e);}}function Hl(e,t){let n=Dl(e),o=to.get(n);if(o!==void 0&&o.maxWidth===t)return to.delete(n),to.set(n,o),o.measure}function Nl(e,t,n){let o=Dl(e);to.set(o,{measure:n,maxWidth:t}),zx();}function pf(){to.clear();}function zl(){df(),uf(),pf();}function Ox(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function $x(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 _x(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 Wx(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 Vx(e,t,n,o){let{pmStart:r,pmEnd:i}=_x(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=$x(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=Ox(f),g=i$2(m,b),x=d+g.width;if(l<=x){let T=l-d,S=j$2(T,g.charWidths),B=c+S;return {charOffset:B,pmPosition:r+B}}d=x,c+=m.length;}}return {charOffset:i-r,pmPosition:i}}function ff(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=Wx(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}=Vx(s,d,g,b);return {pmPosition:T,charOffset:x,lineIndex:u}}function Ux(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 ff(i)?.pmPosition??null}function Ol(e,t){if(t)return Ux(t);if(!e)return null;let{fragment:n}=e;return n.kind==="paragraph"?ff(e)?.pmPosition??null:n.kind==="image"?n.pmStart??null:null}function gf(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 $l(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=mf(l,t,n);return d!==null?d:Number(l.dataset.pmStart)}let u=r.find(d=>d.classList.contains("layout-table-cell"));return u?mf(u,t,n):jx(e,i,t,n)}function $l(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 mf(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 $l(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 jx(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 $l(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 no={fragment:"layout-fragment",paragraph:"layout-fragment-paragraph",table:"layout-fragment-table",image:"layout-fragment-image"};function Kx(e){return e.kind==="paragraph"}function Gx(e){return e.kind==="table"}function Yx(e){return e.kind==="image"}function Xa(e){e.style.position="absolute",e.style.overflow="hidden";}function qx(e,t,n){let o=n.createElement("div");return o.className=`${no.fragment} ${no.paragraph}`,Xa(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 Xx(e,t,n){let o=n.createElement("div");return o.className=`${no.fragment} ${no.table}`,Xa(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 Zx(e,t,n){let o=n.createElement("div");return o.className=`${no.fragment} ${no.image}`,Xa(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 Gr(e,t,n={}){let o=n.document??document;if(Kx(e))return qx(e,t,o);if(Gx(e))return Xx(e,t,o);if(Yx(e))return Zx(e,t,o);let r=o.createElement("div");r.className=no.fragment,Xa(r);let i=e;return i.blockId!==void 0&&(r.dataset.blockId=String(i.blockId)),i.kind&&(r.dataset.kind=i.kind),r}function _l(e){return e/1440*96}function Jx(e){return e/96*1440}function Qx(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 hf(e,t,n="",o,r="."){let{defaultTabInterval:i=720}=t,a=Jx(e),l=Qx(t).find(c=>c.pos>a);if(!l){let c=_l(i),p=c-e%c;return p<=0&&(p=c),{width:p,alignment:"default"}}let d=_l(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=_l(i),p=c-e%c;return p<=0&&(p=c),{width:p,alignment:"default"}}return {width:d,leader:l.leader,alignment:l.val}}var en={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 qr(e){return e.kind==="text"}function Za(e){return e.kind==="tab"}function xf(e){return e.kind==="image"}function Wl(e){return e.kind==="lineBreak"}function Vl(e){return e.kind==="field"}function eS(e,t,n){if(t.fontFamily&&(e.style.fontFamily=a$4(t.fontFamily).cssFallback),t.fontSize){let r=t.fontSize*96/72;e.style.fontSize=`${r}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 o=[];if(t.underline&&(o.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&&o.push("line-through"),t.commentIds&&t.commentIds.length>0){let r=t.commentIds.find(i=>!n||!n.has(i));r!=null&&(e.style.backgroundColor="rgba(255, 212, 0, 0.15)",e.style.borderBottom="1px solid rgba(255, 212, 0, 0.4)",e.dataset.commentId=String(r));}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",o.includes("line-through")||o.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))),o.length>0&&(e.style.textDecorationLine=o.join(" ")),t.superscript&&(e.style.verticalAlign="super",e.style.fontSize="0.75em"),t.subscript&&(e.style.verticalAlign="sub",e.style.fontSize="0.75em");}function or(e,t,n){t!==void 0&&(e.dataset.pmStart=String(t)),n!==void 0&&(e.dataset.pmEnd=String(n));}function Ul(e,t,n){let o=t.createElement("span");if(o.className=`${en.run} ${en.text}`,eS(o,e,n),or(o,e.pmStart,e.pmEnd),e.hyperlink){let r=t.createElement("a");r.href=e.hyperlink.href,e.hyperlink.href.startsWith("#")||(r.target="_blank",r.rel="noopener noreferrer"),e.hyperlink.tooltip&&(r.title=e.hyperlink.tooltip),r.textContent=e.text;let i=e.color||"#0563c1";r.style.color=i,r.style.textDecoration="underline",o.style.color=i,o.appendChild(r);}else o.textContent=e.text;return o}function Sf(e,t,n,o){let r=t.createElement("span");if(r.className=`${en.run} ${en.tab}`,r.style.display="inline-block",r.style.width=`${n}px`,r.style.overflow="hidden",or(r,e.pmStart,e.pmEnd),o&&o!=="none"){let i=tS(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 tS(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "middleDot":return "\xB7";case "heavy":return "_";default:return null}}function nS(e,t){let n=t.createElement("img");return n.className=`${en.run} ${en.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",or(n,e.pmStart,e.pmEnd),n}function bf(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),or(n,e.pmStart,e.pmEnd),n.appendChild(o),n}function kf(e,t){return rr(e)||e.displayMode==="block"||e.wrapType==="topAndBottom"?bf(e,t):nS(e,t)}function Cf(e,t){let n=t.createElement("br");return n.className=`${en.run} ${en.lineBreak}`,or(n,e.pmStart,e.pmEnd),n}function Tf(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 Ul(r,t,n?.resolvedCommentIds)}function oS(e,t,n){if(qr(e))return Ul(e,t,n?.resolvedCommentIds);if(Za(e))return Sf(e,t,48,void 0);if(xf(e))return kf(e,t);if(Wl(e))return Cf(e,t);if(Vl(e)&&n)return Tf(e,t,n);let o=t.createElement("span");return o.className=en.run,o}function wf(e,t){let n=[],o=e.runs;for(let r=t.fromRun;r<=t.toRun;r++){let i=o[r];if(i)if(qr(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 rS(e){return [e.pmStart??"no-start",e.pmEnd??"no-end",e.src,e.width,e.height,e.displayMode??"inline",e.wrapType??"none"].join("|")}function iS(e){return {val:e.val,pos:e.pos,leader:e.leader}}function aS(e,t,n){let o="";for(let r=t+1;r<e.length;r++){let i=e[r];if(qr(i))o+=i.text;else if(Vl(i))i.fieldType==="PAGE"&&n?o+=String(n.pageNumber):i.fieldType==="NUMPAGES"&&n?o+=String(n.totalPages):o+=i.fallback??"";else if(Za(i)||Wl(i))break}return o}function sS(e){let n=e.createElement("canvas").getContext("2d");return (o,r=11,i="Calibri")=>{if(!n)return o.length*7;let a=a$4(i).cssFallback,s=r*96/72;return n.font=`${s}px ${a}`,n.measureText(o).width}}function vf(e,t,n,o,r){let i=o.createElement("div");i.className=en.line,i.style.height=`${t.lineHeight}px`,i.style.lineHeight=`${t.lineHeight}px`;let a=wf(e,t);if(a.length===0){let b=o.createElement("span");return b.className=`${en.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=>qr(b)&&b.highlight);i.style.overflow=u?"hidden":"visible";let d=a.some(Za),c,p=sS(o);if(d){let b=r?.tabStops?.map(iS),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(Za(g)&&c){let x=aS(a,b,r?.context),T=hf(f,c,x,p),S=Sf(g,o,T.width,T.leader);i.appendChild(S),f+=T.width;}else if(qr(g)){let x=Ul(g,o,r?.context?.resolvedCommentIds);if(g.highlight){let v=(g.fontSize?g.fontSize*96/72:14.67)*1.2,E=Math.max(0,t.lineHeight-v);if(E>0){let V=E/2;x.style.paddingTop=`${V}px`,x.style.paddingBottom=`${V}px`;}}i.appendChild(x);let T=g.fontSize||11,S=g.fontFamily||"Calibri";f+=p(g.text,T,S);}else if(xf(g)){if(rr(g))continue;let x=rS(g);if(r?.renderedInlineImageKeys?.has(x))continue;r?.renderedInlineImageKeys?.add(x);let T=kf(g,o);i.appendChild(T),g.displayMode!=="block"&&g.wrapType!=="topAndBottom"&&(f+=g.width);}else if(Wl(g)){let x=Cf(g,o);i.appendChild(x);}else if(Vl(g)&&r?.context){let x=Tf(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=oS(g,o,r?.context);i.appendChild(x);}}return i}function Yr(e,t){return !e&&!t?true:!e||!t?false:e.style===t.style&&e.width===t.width&&e.color===t.color}function yf(e,t){return !e&&!t||!e||!t?false:Yr(e.top,t.top)&&Yr(e.bottom,t.bottom)&&Yr(e.left,t.left)&&Yr(e.right,t.right)&&Yr(e.between,t.between)}function On(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=en.fragment,a.style.position="relative",a.dataset.blockId=String(e.blockId),a.dataset.fromLine=String(e.fromLine),a.dataset.toLine=String(e.toLine),or(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 v=I=>{switch(I){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 E=I=>`${I.width}px ${v(I.style)} ${I.color}`,V=yf(r.prevBorders,f),D=yf(f,r.nextBorders);if(V&&f.between?a.style.borderTop=E(f.between):f.top&&!V&&(a.style.borderTop=E(f.top)),f.bottom&&!D&&(a.style.borderBottom=E(f.bottom)),f.left&&(a.style.borderLeft=E(f.left)),f.right&&(a.style.borderRight=E(f.right)),f.bar){let I=i.createElement("div");I.style.position="absolute",I.style.left="-8px",I.style.top="0",I.style.bottom="0",I.style.borderLeft=E(f.bar),a.style.position="relative",a.appendChild(I);}if(f.top||f.bottom||f.left||f.right||f.between){let I=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=I?`${I.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 v=0;v<s.length;v++){let E=s[v],V=e.fromLine+v,D=V===x-1,P=V===0&&!e.continuesFromPrev,I=E.leftOffset??0,J=E.rightOffset??0,se=m;if(P){let ue=d?.hanging&&d.hanging>0,me=d?.firstLine&&d.firstLine>0;ue&&d?.hanging?se=m+d.hanging:me&&d?.firstLine&&(se=m-d.firstLine);}let ie=vf(t,E,l,i,{availableWidth:se-I-J,isLastLine:D,isFirstLine:P,paragraphEndsWithLineBreak:g,tabStops:t.attrs?.tabs,leftIndentPx:c,firstLineIndentPx:P?T:0,context:o,renderedInlineImageKeys:B});if(I>0||J>0){I>0&&(ie.style.marginLeft=`${I}px`),J>0&&(ie.style.marginRight=`${J}px`);let ue=se-I-J;ue>0&&(ie.style.width=`${ue}px`);}S+=E.lineHeight;let z=d?.hanging&&d.hanging>0,N=d?.firstLine&&d.firstLine>0;if(P?c>0&&z?(ie.style.paddingLeft=`${c}px`,ie.style.textIndent=`-${d.hanging}px`):c>0&&N?(ie.style.paddingLeft=`${c}px`,ie.style.textIndent=`${d.firstLine}px`):c>0?ie.style.paddingLeft=`${c}px`:N&&(ie.style.textIndent=`${d.firstLine}px`):c>0?ie.style.paddingLeft=`${c}px`:z&&(ie.style.paddingLeft=`${d.hanging}px`),p>0&&(ie.style.paddingRight=`${p}px`),P&&t.attrs?.listMarker&&!t.attrs?.listMarkerHidden){let ue=Math.max(0,c-(d?.hanging??0));ie.style.paddingLeft=`${ue}px`,ie.style.textIndent="0";let me;if(!t.attrs.listMarkerFontFamily||!t.attrs.listMarkerFontSize)for(let R=E.fromRun;R<=E.toRun;R++){let L=t.runs[R];if(L&&L.kind==="text"){me=L;break}}let Ee=t.attrs.listMarkerFontFamily??me?.fontFamily??t.attrs.defaultFontFamily,ce=t.attrs.listMarkerFontSize??me?.fontSize??t.attrs.defaultFontSize,Y=lS(t.attrs.listMarker,d,i,Ee,ce);ie.insertBefore(Y,ie.firstChild);}a.appendChild(ie);}return a}function lS(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=a$4(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 Mn={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 cS(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(!rr(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=oo(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+oo(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 dS(e,t,n,o){let r=o.createElement("div");r.className=Mn.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=cS(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=Pn(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=On(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=uS(p,f,n,o);g.style.position="relative",r.appendChild(g),d+=f.totalHeight??0;}}return r}function uS(e,t,n,o){let r=o.createElement("div");r.className=`${Mn.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=jl(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 Ja(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 pS(e,t,n,o,r,i,a){let s=a.createElement("div");s.className=Mn.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&&Ja(s,"top",e.borders.top),Ja(s,"right",e.borders.right),Ja(s,"bottom",e.borders.bottom),r.isFirstCol&&Ja(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=dS(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 jl(e,t,n,o,r,i,a,s,l,u,d){let c=s.createElement("div");c.className=Mn.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 I=n;I<n+S&&I<u.length-1;I++)B+=(u[I+1]??0)-(u[I]??0);B===0&&(B=t.height*S);}let v=n===0||d===true,V=m===0;m+T>=r.length;let P=pS(g,x,f,B,{isFirstRow:v,isFirstCol:V},a,s);if(P.dataset.cellIndex=String(b),P.dataset.columnIndex=String(m),S>1&&(P.dataset.rowSpan=String(S)),c.appendChild(P),S>1&&l){let I=`${n}-${m}`;l.set(I,{cell:g,cellMeasure:x,columnIndex:m,startRow:n,rowSpan:S,colSpan:T,x:f,totalHeight:B});}for(let I=0;I<T&&m+I<r.length;I++)f+=r[m+I]??0;for(m+=T;p.has(m);)f+=r[m]??0,m++;}return c}function Qa(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Mn.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=Mn.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=jl(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=jl(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=Mn.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=Mn.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=Mn.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 Kl={image:"layout-image",imageAnchored:"layout-image-anchored"};function es(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Kl.image,e.isAnchored&&a.classList.add(Kl.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 Rf={textBox:"layout-textbox"};function ts(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");if(a.className=Rf.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??c$1;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=On(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 ro={page:"layout-page",content:"layout-page-content",header:"layout-page-header",footer:"layout-page-footer"};function os(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=Go(l,a[s],o.theme);for(let[d,c]of Object.entries(u))e.style[d]=String(c);}}}}function fS(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 Mf(e){return e?.align??e?.alignment}function mS(e,t){let n=e.position.vertical;if(!n)return e.paragraphY;let o=Mf(n),r=n.posOffset!==void 0?oo(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 gS(e,t,n){let o=t.position.horizontal;if(!o){e.style.left="0";return}let r=Mf(o);if(o.relativeTo==="page"){if(o.posOffset!==void 0){e.style.left=`${oo(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=`${oo(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 hS(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 oo(e){return e===void 0?0:Math.round(e*96/914400)}function rr(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function bS(e,t,n){let o=[];for(let r of e.runs){if(r.kind!=="image")continue;let i=r;if(!rr(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=oo(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=oo(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 yS(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 xS(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 Ef(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=On(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",gS(d,u,o),d.style.top=`${mS(u,o)}px`,i.appendChild(d);}return i}function SS(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 Gl(e,t,n={}){let o=n.document??document,r=o.createElement("div");r.className=n.pageClassName??ro.page,r.dataset.pageNumber=String(e.number),os(r,e.size.w,e.size.h,n);let i=o.createElement("div");i.className=ro.content,fS(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=bS(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,v=g.leftFromText??12,E=g.rightFromText??12,V=x<a/2?"left":"right";l.push({side:V,x,y:T,width:f.width,height:f.height,distTop:S,distBottom:B,distLeft:v,distRight:E});}let u=l.length>0?yS(l,a):[];if(s.length>0){let f=xS(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,v=String(m.blockId),E=p.get(v);E||(E=new Set,p.set(v,E));let V=T.measure;u.length>0&&(V=Pn(S,a,{floatingZones:u,paragraphYOffset:x})),b=On(m,S,V,g,{document:o,prevBorders:c,nextBorders:B,renderedInlineImageKeys:E}),c=S.attrs?.borders;}else m.kind==="table"&&T?.block.kind==="table"&&T?.measure.kind==="table"?(b=Qa(m,T.block,T.measure,g,{document:o}),c=void 0):m.kind==="image"&&T?.block.kind==="image"&&T?.measure.kind==="image"?(b=es(m,T.block,T.measure,g,{document:o}),c=void 0):m.kind==="textBox"&&T?.block.kind==="textBox"&&T?.measure.kind==="textBox"?(b=ts(m,T.block,T.measure,g,{document:o}),c=void 0):(b=Gr(m,g,{document:o}),c=void 0);}else b=Gr(m,g,{document:o}),c=void 0;hS(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=SS(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,v=o.createElement("div");v.className=ro.header,v.style.position="absolute",v.style.top=`${m+x}px`,v.style.left=`${e.margins.left}px`,v.style.right=`${e.margins.right}px`,v.style.width=`${b}px`,v.style.height=`${S}px`,v.style.minHeight=`${S}px`;let E=!B;if(n.headerContent&&n.headerContent.blocks.length>0){let V=Ef(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});V.style.top=`${-x}px`,V.querySelector("img")&&(E=false),v.appendChild(V);}E&&(v.style.maxHeight=`${g}px`,v.style.overflow="hidden"),r.appendChild(v);}{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,v=o.createElement("div");v.className=ro.footer,v.style.position="absolute",v.style.top=`${e.size.h-m-S}px`,v.style.left=`${e.margins.left}px`,v.style.right=`${e.margins.right}px`,v.style.width=`${b}px`,v.style.height=`${S}px`,v.style.minHeight=`${S}px`;let E=!B;if(n.footerContent&&n.footerContent.blocks.length>0){let V=Ef(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});V.style.top=`${-x}px`,V.querySelector("img")&&(E=false),v.appendChild(V);}E&&(v.style.maxHeight=`${g}px`,v.style.overflow="hidden"),r.appendChild(v);}return r}function Yl(e,t,n){let o={pageNumber:e.number,totalPages:t,section:"body",resolvedCommentIds:n.resolvedCommentIds},r={...n};if(n.titlePg&&e.number===1&&(r.headerContent=n.firstPageHeaderContent,r.footerContent=n.firstPageFooterContent),n.footnotesByPage){let i=n.footnotesByPage.get(e.number);i&&i.length>0&&(r.footnoteArea=i);}return {context:o,pageOptions:r}}function Pf(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 kS(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.firstPageHeaderContent&&t.push(`fp-hdr:${e.firstPageHeaderContent.blocks.length},${e.firstPageHeaderContent.height}`),e.firstPageFooterContent&&t.push(`fp-ftr:${e.firstPageFooterContent.blocks.length},${e.firstPageFooterContent.height}`),e.titlePg&&t.push("titlePg"),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 CS(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 ns=2,TS=8;function If(e,t,n={}){let o=e.length,r=n.pageGap??24,i=t,a=i.__pageRenderState,s=kS(n),l=o>=TS;if(a&&a.optionsHash===s&&l){let g=a.pageStates,x=a.pageDataMap,T=i.__pageObserver,S=[];for(let E of e)S.push(Pf(E));let B=a.totalPages!==o,v=Math.min(g.length,e.length);for(let E=0;E<v;E++){let V=g[E],D=S[E];if(V.fingerprint===D&&!B){let J=x.get(V.element);J&&(J.page=e[E]);continue}let P=V.element,I=x.get(P);I&&(I.page=e[E],I.rendered&&wS(P,x,o,n)),V.fingerprint=D,os(P,e[E].size.w,e[E].size.h,n),P.dataset.pageNumber=String(e[E].number);}if(e.length>g.length){let E=n.document??document;for(let V=g.length;V<e.length;V++){let D=e[V],P=E.createElement("div");P.className=n.pageClassName??ro.page,P.dataset.pageNumber=String(D.number),P.dataset.pageIndex=String(V),os(P,D.size.w,D.size.h,n),t.appendChild(P),g.push({element:P,fingerprint:S[V]}),x.set(P,{page:D,index:V,rendered:false}),T&&T.observe(P);}}if(e.length<g.length){for(let E=g.length-1;E>=e.length;E--){let V=g[E].element;T&&T.unobserve(V),x.delete(V),t.removeChild(V);}g.length=e.length;}for(let E=0;E<g.length;E++){let V=x.get(g[E].element);V&&(V.index=E);}a.totalPages=o,a.currentOptions=n;return}let d=i.__pageObserver;d&&(d.disconnect(),i.__pageObserver=void 0),t.innerHTML="",i.__pageRenderState=void 0,CS(t,r);let c=[],p=[];for(let g=0;g<e.length;g++){let x=e[g];if(p.push(Pf(x)),l){let S=(n.document??document).createElement("div");S.className=n.pageClassName??ro.page,S.dataset.pageNumber=String(x.number),S.dataset.pageIndex=String(g),os(S,x.size.w,x.size.h,n),t.appendChild(S),c.push(S);}else {let{context:T,pageOptions:S}=Yl(x,o,n),B=Gl(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 D of g){let P=D.target,I=B.get(P);if(I&&D.isIntersecting){rs(P,B,S,T);for(let J=-ns;J<=ns;J++){let se=I.index+J;se>=0&&se<x.pageStates.length&&se!==I.index&&rs(x.pageStates[se].element,B,S,T);}}}let v=window.innerHeight,E=v*3,V=new Set;for(let[D,P]of B){if(!P.rendered)continue;let I=D.getBoundingClientRect();I.bottom>-E&&I.top<v+E&&V.add(P.index);}for(let[D,P]of B){if(!P.rendered)continue;let I=false;for(let J of V)if(Math.abs(P.index-J)<=ns+1){I=true;break}!I&&V.size>0&&vS(D,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,ns+3);for(let g=0;g<b;g++)rs(c[g],f,o,n);}function rs(e,t,n,o){let r=t.get(e);if(!r||r.rendered)return;let{context:i,pageOptions:a}=Yl(r.page,n,o),s=Gl(r.page,i,a);for(;s.firstChild;)e.appendChild(s.firstChild);r.rendered=true;}function wS(e,t,n,o){let r=t.get(e);if(!r)return;let{context:i,pageOptions:a}=Yl(r.page,n,o),l=Gl(r.page,i,a).querySelector(`.${ro.content}`),u=e.querySelector(`.${ro.content}`);l&&u?e.replaceChild(l,u):(e.innerHTML="",r.rendered=false,rs(e,t,n,o));}function vS(e,t){let n=t.get(e);!n||!n.rendered||(e.innerHTML="",n.rendered=false);}var is=class{constructor(t={}){d$1(this,"container",null);d$1(this,"blockLookup",new Map);d$1(this,"pageStates",[]);d$1(this,"totalPages",0);d$1(this,"options");d$1(this,"doc");d$1(this,"resolvedCommentIds",new Set);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",resolvedCommentIds:this.resolvedCommentIds},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 On(t,r,i,n,{document:this.doc})}if(t.kind==="table"&&o){let r=o.block,i=o.measure;return Qa(t,r,i,n,{document:this.doc})}if(t.kind==="image"&&o){let r=o.block,i=o.measure;return es(t,r,i,n,{document:this.doc})}if(t.kind==="textBox"&&o){let r=o.block,i=o.measure;return ts(t,r,i,n,{document:this.doc})}return Gr(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 $n,io,ao,_n,ir,Eo,Ff,ql,as=class{constructor(){f$1(this,Eo);f$1(this,$n,0);f$1(this,io,0);f$1(this,ao,false);f$1(this,_n,null);f$1(this,ir,new Set);}setStateSeq(t){g(this,$n,t);}incrementStateSeq(){return ++i$1(this,$n)._}getStateSeq(){return e$1(this,$n)}getRenderSeq(){return e$1(this,io)}onLayoutStart(){g(this,ao,true);}onLayoutComplete(t){g(this,io,t),g(this,ao,false),h$1(this,Eo,Ff).call(this);}isSafeToRender(){return !e$1(this,ao)&&e$1(this,io)>=e$1(this,$n)}requestRender(){this.isSafeToRender()?h$1(this,Eo,ql).call(this):g(this,_n,()=>h$1(this,Eo,ql).call(this));}onRender(t){return e$1(this,ir).add(t),()=>{e$1(this,ir).delete(t);}}reset(){g(this,$n,0),g(this,io,0),g(this,ao,false),g(this,_n,null);}getDebugInfo(){return {stateSeq:e$1(this,$n),renderSeq:e$1(this,io),layoutUpdating:e$1(this,ao),hasPendingRender:e$1(this,_n)!==null,isSafe:this.isSafeToRender()}}};$n=new WeakMap,io=new WeakMap,ao=new WeakMap,_n=new WeakMap,ir=new WeakMap,Eo=new WeakSet,Ff=function(){if(e$1(this,_n)&&this.isSafeToRender()){let t=e$1(this,_n);g(this,_n,null),t();}},ql=function(){for(let t of e$1(this,ir))try{t();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};var Bf=".layout-page-content .layout-line";function RS(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 ES(e){let t=RS(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 Af({pagesContainerRef:e}){let t=useRef(null),n=useRef(-1),o=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=useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll(Bf);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=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 v=0,E=S.length;for(;v<E;){let V=Math.floor((v+E)/2),D=B.createRange();D.setStart(S,V),D.setEnd(S,V),l<D.getBoundingClientRect().left?E=V:v=V+1;}if(v>0&&v<=S.length){let V=B.createRange();V.setStart(S,v-1),V.setEnd(S,v-1);let D=V.getBoundingClientRect().left;V.setStart(S,Math.min(v,S.length)),V.setEnd(S,Math.min(v,S.length));let P=V.getBoundingClientRect().left;if(Math.abs(l-D)<Math.abs(l-P))return g+(v-1)}return g+Math.min(v,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=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(Bf));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?TextSelection.create(g.doc,c,T):TextSelection.create(g.doc,T);x(g.tr.setSelection(S));}catch{let S=g.doc.resolve(T),B=l.shiftKey?TextSelection.between(g.doc.resolve(c),S):TextSelection.near(S);x(g.tr.setSelection(B));}return ES(m),true},[e,o,r,i]);return {stickyXRef:t,lastVisualLineIndexRef:n,getCaretClientX:o,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}var so=40,ds=12;function PS(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 Df({pagesContainerRef:e,onScrollExtendSelection:t}){let n=useRef(null),o=useRef({x:0,y:0}),r=useRef(false),i=useRef(null),a=useCallback(()=>{if(i.current)return i.current;let c=e.current;return c?(i.current=PS(c),i.current):null},[e]),s=useCallback(()=>{r.current=false,n.current!==null&&(cancelAnimationFrame(n.current),n.current=null);},[]),l=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+so){let g=Math.max(0,p.top+so-m);b=-Math.min(ds,g/so*ds);}else if(m>p.bottom-so){let g=Math.max(0,m-(p.bottom-so));b=Math.min(ds,g/so*ds);}b!==0&&(c.scrollTop+=b,t(f,m)),n.current=requestAnimationFrame(l);},[a,t]),u=useCallback(()=>{r.current||(r.current=true,n.current=requestAnimationFrame(l));},[l]);return {updateMousePosition: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+so||p>m.bottom-so)&&u();}},[a,u]),stopAutoScroll:s}}var MS=12,us=8;function Hf(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 Xl(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 IS(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:us,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=us);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:us});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:us}]});let r=[];for(let a of o)if(a.kind==="paragraph"){let s=Pn(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 Nf(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=IS(l,i,n);o.set(s.footnoteId,u),i++;}return o}function zf(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+=MS,n.set(o,i));}return n}var Zl=class{constructor(t,n=1){d$1(this,"pagesContainer");d$1(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 Of(e,t=1){return new Zl(e,t)}var DS=816,Wf=1056,ps={top:96,right:96,bottom:96,left:96},HS=24,uo=30,NS=200,zS=[],OS={position:"relative",width:"100%",minHeight:"100%",overflow:"visible",backgroundColor:"var(--doc-bg, #f8f9fa)"},Vf=24,$S={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:Vf,paddingBottom:24},_S={position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},WS={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function VS(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=Vf+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=q(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 v of S.fragments){let E=v.pmStart??0,V=v.pmEnd??E;if(m<E||m>V)continue;let D=v.kind==="table"?US(n,o,v,m):0;i.set(g,v.y+D+m$2(t,T)+p),B=true;break}if(B)break}}}),i}function US(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 Nt(e){return Math.round(e/1440*96)}function jS(e){return {w:e?.pageWidth?Nt(e.pageWidth):DS,h:e?.pageHeight?Nt(e.pageHeight):Wf}}function KS(e){let t=e?.marginTop?Nt(e.marginTop):ps.top,n=e?.marginBottom?Nt(e.marginBottom):ps.bottom;return {top:t,right:e?.marginRight?Nt(e.marginRight):ps.right,bottom:n,left:e?.marginLeft?Nt(e.marginLeft):ps.left,header:e?.headerDistance?Nt(e.headerDistance):48,footer:e?.footerDistance?Nt(e.footerDistance):48}}function GS(e){let t=e?.columnCount??1;if(t<=1)return;let n=Nt(e?.columnSpace??720);return {count:t,gap:n,equalWidth:e?.equalWidth??true,separator:e?.separator}}function YS(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 qS(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function Jl(e){return e===void 0?0:Math.round(e*96/914400)}function XS(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 Uf(e,t){let r=e.columnWidths??[],i=XS(e.width,e.widthType,t);if(r.length===0&&e.rows.length>0){let d=e.rows[0].cells.reduce((f,m)=>f+(m.colSpan??1),0),p=(i??t)/Math.max(1,d);r=Array(d).fill(p);}else if(r.length>0&&i){let d=r.reduce((c,p)=>c+p,0);if(d>0&&Math.abs(d-i)>1){let c=i/d;r=r.map(p=>p*c);}}let a=new Map;for(let d=0;d<e.rows.length;d++){let c=e.rows[d];if(!c)continue;let p=0,f=a.get(d)??new Set;for(;f.has(p);)p++;for(let m of c.cells){let b=m.colSpan??1,g=m.rowSpan??1;if(g>1)for(let x=d+1;x<d+g;x++){a.has(x)||a.set(x,new Set);let T=a.get(x);for(let S=0;S<b;S++)T.add(p+S);}for(p+=b;f.has(p);)p++;}}let s=e.rows.map((d,c)=>{let p=0,f=a.get(c)??new Set;for(;f.has(p);)p++;return {cells:d.cells.map(m=>{let b=m.colSpan??1,g=0;for(let B=0;B<b&&p+B<r.length;B++)g+=r[p+B]??0;for(g===0&&(g=m.width??100),p+=b;f.has(p);)p++;let x=m.padding?.left??7,T=m.padding?.right??7,S=Math.max(1,g-x-T);return {blocks:m.blocks.map(B=>jf(B,S)),width:g,height:0,colSpan:m.colSpan,rowSpan:m.rowSpan}}),height:0}});for(let d=0;d<s.length;d++){let c=s[d],p=e.rows[d]?.cells,f=0;for(let x=0;x<c.cells.length;x++){let T=c.cells[x],S=p?.[x];T.height=T.blocks.reduce((E,V)=>"totalHeight"in V?E+V.totalHeight:E,0);let B=S?.padding?.top??0,v=S?.padding?.bottom??0;T.height+=B+v,f=Math.max(f,T.height);}let m=e.rows[d],b=m?.height,g=m?.heightRule;b&&g==="exact"?c.height=b:b?c.height=Math.max(f,b):c.height=f;}let l=s.reduce((d,c)=>d+c.height,0),u=r.reduce((d,c)=>d+c,0)||i||t;return {kind:"table",rows:s,columnWidths:r,totalWidth:u,totalHeight:l}}function ZS(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(!qS(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=Jl(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=Jl(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=Uf(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 jf(e,t,n,o){switch(e.kind){case "paragraph":{let r=e;if(!n||n.length===0){let a=Hl(r,t);if(a)return a}let i=Pn(r,t,{floatingZones:n,paragraphYOffset:o??0});return (!n||n.length===0)&&Nl(r,t,i),i}case "table":return Uf(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??c$1,a=(r.width??d$2)-i.left-i.right,s=r.content.map(d=>Pn(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??d$2,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 Kf(e,t){let n=Array.isArray(t)?t[0]??0:t,o=ZS(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=jf(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 ms(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=ms(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=ms(o.fieldResult);t.push(...a);}}if(o.type==="hyperlink"&&Array.isArray(o.children)){let r=ms(o.children);t.push(...r);}}return t}function JS(e){return e?.align??e?.alignment}function QS(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=JS(i),s=i.posOffset!==void 0?Jl(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 ek(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=QS(m,c,n,o);r=Math.min(r,b),i=Math.max(i,b+m.height);}a=p;}return {visualTop:r,visualBottom:i}}function fs(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 b=c.alignment;b==="both"?p.alignment="justify":["left","center","right","justify"].includes(b)&&(p.alignment=b);}if(c.borders){let b=c.borders,g={};for(let x of ["top","bottom","left","right","between"]){let T=b[x];if(T){let S=Ya(T);S&&(g[x]=S);}}Object.keys(g).length>0&&(p.borders=g);}if(c.spaceAfter!=null||c.spaceBefore!=null||c.lineSpacing!=null){let b={};if(c.spaceBefore!=null&&(b.before=Nt(c.spaceBefore)),c.spaceAfter!=null&&(b.after=Nt(c.spaceAfter)),c.lineSpacing!=null){let g=c.lineSpacingRule;g==="exact"||g==="atLeast"?(b.line=Nt(c.lineSpacing),b.lineUnit="px",b.lineRule=g):(b.line=c.lineSpacing/240,b.lineUnit="multiplier",b.lineRule="auto");}p.spacing=b;}Array.isArray(c.tabs)&&c.tabs.length>0&&(p.tabs=c.tabs.map(b=>({val:b.alignment==="left"?"start":b.alignment==="right"?"end":b.alignment,pos:Nt(b.position),leader:b.leader})));}let f=ms(d.content);f.length===0&&f.push({kind:"text",text:""});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=Kf(r,t),a=i.reduce((u,d)=>d.kind==="paragraph"?u+d.totalHeight:u,0),{visualTop:s,visualBottom:l}=ek(o,i,a,n);return {blocks:o,measures:i,height:a,visualTop:s,visualBottom:l}}function tk(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=b(u);s.push({displayNumber:String(c),text:p});}s.length>0&&o.set(i,s);}return o}var nk=forwardRef(function(t,n$1){let{document:o$1,styles:r,theme:i,sectionProperties:a,headerContent:s,footerContent:l,firstPageHeaderContent:u,firstPageFooterContent:d,readOnly:c=false,pageGap:p$1=HS,zoom:f=1,onDocumentChange:m,onSelectionChange:b,externalPlugins:g=zS,extensionManager:x,onReady:T,onRenderedDomContextReady:S,pluginOverlays:B,onHeaderFooterDoubleClick:v,hfEditMode:E,onBodyClick:V,className:D,style:P,commentsSidebarOpen:I=false,sidebarOverlay:J,scrollContainerRef:se,onHyperlinkClick:ie,onContextMenu:z,onAnchorPositionsChange:N,resolvedCommentIds:ue}=t,me=useCallback(()=>se&&typeof se=="object"?se.current:Ee.current,[se]),Ee=useRef(null),ce=useRef(null),Y=useRef(null),R=useRef(null),{handlePMKeyDown:L}=Af({pagesContainerRef:ce}),k=useRef(()=>{}),M=useRef(b),F=useRef(m),H=useRef(T),oe=useRef(S);M.current=b,F.current=m,H.current=T,oe.current=S;let[ee,_]=useState(null),[G,ne]=useState([]),[xe,re]=useState([]),[pe,de]=useState(false),[Pe,De]=useState([]),[je,Ne]=useState(null),[Ke,ze]=useState(null),ve=useRef(false),Ie=useCallback((C,W)=>{let U=C.tagName==="IMG"?C:C.querySelector("img"),K=(U??C).getBoundingClientRect();return {element:U??C,pmPos:W,width:Math.round(K.width/f),height:Math.round(K.height/f)}},[f]),Ye=useRef(false),Ge=useRef(null),lt=useRef(false),qe=useRef(0),ht=useRef(0),It=useRef(0),He=useRef({left:0,right:0}),st=useRef(null),Be=useRef(false),ut=useRef(0),Xt=useRef(0),cr=useRef(0),bt=useRef(0),Rt=useRef(null),ys=useRef(false),Fn=useRef(false),Lo=useRef(0),dr=useRef(0),mn=useRef(0),gn=useRef(0),Zt=useRef(null),jt=useRef(false),hn=useRef(null),tn=useRef(null),bn=useRef(null),xs=5,[zt,nn]=useState(null),ct=useRef(null),on=useCallback(()=>{ct.current&&(clearTimeout(ct.current),ct.current=null);},[]);useEffect(()=>()=>{ct.current&&clearTimeout(ct.current);},[]);let Ft=useMemo(()=>new as,[]),pt=useMemo(()=>jS(a),[a]),Ct=useMemo(()=>KS(a),[a]),Jt=useMemo(()=>GS(a),[a]),Et=pt.w-Ct.left-Ct.right,ti=useMemo(()=>new is({pageGap:p$1,showShadow:true,pageBackground:"#fff"}),[p$1]);R.current=ti;let Ot=useCallback(C=>{let W=performance.now(),U=Ft.getStateSeq();Ft.onLayoutStart();try{let K=performance.now(),Q=pt.h-Ct.top-Ct.bottom,$=of(C.doc,{theme:i,pageContentHeight:Q}),Z=performance.now()-K;Z>500&&console.warn(`[PagedEditor] toFlowBlocks took ${Math.round(Z)}ms (${$.length} blocks)`),ne($),K=performance.now();let te=YS($,Et,Jt),le=Kf($,te);Z=performance.now()-K,Z>1e3&&console.warn(`[PagedEditor] measureBlocks took ${Math.round(Z)}ms (${$.length} blocks)`),re(le);let Se=Hf($),ge=Se.length>0&&o$1?.package?.footnotes,he={section:"header",pageSize:pt,margins:Ct},ke={section:"footer",pageSize:pt,margins:Ct},Te=fs(s,Et,he),Me=fs(l,Et,ke),Ue=a?.titlePg===!0,mt=Ue?fs(u,Et,he):void 0,yt=Ue?fs(d,Et,ke):void 0,sn=Ct.header??48,Ao=Ct.footer??48,ai=Ct.top-sn,si=Ct.bottom-Ao,li=xt=>xt?xt.visualBottom??xt.height:0,ci=xt=>xt?Math.max((xt.visualBottom??xt.height)-(xt.visualTop??0),xt.height):0,br=Math.max(li(Te),li(mt)),yr=Math.max(ci(Me),ci(yt)),Do=Ct;(br>ai||yr>si)&&(Do={...Ct},br>ai&&(Do.top=Math.max(Ct.top,sn+br)),yr>si&&(Do.bottom=Math.max(Ct.bottom,Ao+yr))),K=performance.now();let ln,ho=new Map,xr=new Map,ws=a?.sectionStart,Sr={pageSize:pt,margins:Do,columns:Jt,bodyBreakType:ws,pageGap:p$1};if(ge){let xt=e($,le,Sr);ho=Xl(xt.pages,Se),xr=Nf(o$1.package.footnotes,Se,Et);let bo=zf(ho,xr);if(bo.size>0){ln=e($,le,{...Sr,footnoteReservedHeights:bo}),ho=Xl(ln.pages,Se);for(let[xn,yo]of ho){let xo=ln.pages.find(vs=>vs.number===xn);xo&&(xo.footnoteIds=yo);}}else ln=xt;}else ln=e($,le,Sr);if(Z=performance.now()-K,Z>500&&console.warn(`[PagedEditor] layoutDocument took ${Math.round(Z)}ms (${ln.pages.length} pages)`),_(ln),ce.current&&R.current){K=performance.now();let xt=new Map;for(let xn=0;xn<$.length;xn++){let yo=$[xn],xo=le[xn];yo&&xo&&xt.set(String(yo.id),{block:yo,measure:xo});}R.current.setBlockLookup(xt);let bo=ge?tk(ho,xr,o$1):void 0;if(If(ln.pages,ce.current,{pageGap:p$1,showShadow:!0,pageBackground:"#fff",blockLookup:xt,headerContent:Te,footerContent:Me,firstPageHeaderContent:mt,firstPageFooterContent:yt,titlePg:Ue,headerDistance:a?.headerDistance?Nt(a.headerDistance):void 0,footerDistance:a?.footerDistance?Nt(a.footerDistance):void 0,pageBorders:a?.pageBorders,theme:i,footnotesByPage:bo?.size?bo:void 0,resolvedCommentIds:ue}),Z=performance.now()-K,Z>500&&console.warn(`[PagedEditor] renderPages took ${Math.round(Z)}ms`),S){let xn=Of(ce.current,f);S(xn);}}if(N){let xt=VS(Y.current?.getView()??null,ln,$,le,p$1);N(xt);}let di=performance.now()-W;di>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(di)}ms total (${$.length} blocks, ${le.length} measures)`);}catch(K){console.error("[PagedEditor] Layout pipeline error:",K);}Ft.onLayoutComplete(U);},[Et,Jt,pt,Ct,p$1,f,Ft,s,l,u,d,a,S,o$1,ue]),rn=useRef(null),Ln=useCallback(C=>{if(rn.current){rn.current.state=C;return}let W=requestAnimationFrame(()=>{let U=rn.current;rn.current=null,U&&Ot(U.state);});rn.current={rafId:W,state:C};},[Ot]);useEffect(()=>()=>{rn.current&&(cancelAnimationFrame(rn.current.rafId),rn.current=null);},[]);let ur=useCallback((C,W=1)=>{if(!ce.current)return null;let U=ce.current.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!U)return null;let K=U.getBoundingClientRect(),Q=ce.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let Z of Array.from(Q)){let te=Z,le=Number(te.dataset.pmStart),Se=Number(te.dataset.pmEnd);if(te.classList.contains("layout-run-tab")){if(C>=le&&C<Se){let ge=te.getBoundingClientRect(),he=te.closest(".layout-page"),ke=he?Number(he.dataset.pageNumber)-1:0,Te=te.closest(".layout-line"),Me=Te?Te.offsetHeight:16;return {x:(ge.left-K.left)/W,y:(ge.top-K.top)/W,height:Me,pageIndex:ke}}continue}if(C>=le&&C<=Se&&Z.firstChild?.nodeType===Node.TEXT_NODE){let ge=Z.firstChild,he=Math.min(C-le,ge.length),ke=te.ownerDocument;if(!ke)continue;let Te=ke.createRange();Te.setStart(ge,he),Te.setEnd(ge,he);let Me=Te.getBoundingClientRect(),Ue=te.closest(".layout-page"),mt=Ue?Number(Ue.dataset.pageNumber)-1:0,yt=te.closest(".layout-line"),sn=yt?yt.offsetHeight:16;return {x:(Me.left-K.left)/W,y:(Me.top-K.top)/W,height:sn,pageIndex:mt}}}let $=ce.current.querySelectorAll(".layout-empty-run");for(let Z of Array.from($)){let te=Z.closest(".layout-paragraph");if(!te)continue;let le=Number(te.dataset.pmStart),Se=Number(te.dataset.pmEnd);if(C>=le&&C<=Se){let ge=Z.getBoundingClientRect(),he=te.closest(".layout-page"),ke=he?Number(he.dataset.pageNumber)-1:0,Te=Z.closest(".layout-line"),Me=Te?Te.offsetHeight:16;return {x:(ge.left-K.left)/W,y:(ge.top-K.top)/W,height:Me,pageIndex:ke}}}return null},[]),ae=useCallback(C=>{let{from:W,to:U}=C.selection;if(M.current?.(W,U),ce.current){let K=ce.current.querySelectorAll(".layout-table-cell-selected");for(let Z of Array.from(K))Z.classList.remove("layout-table-cell-selected");let Q=C.selection;if("$anchorCell"in Q&&typeof Q.forEachCell=="function"){let Z=[];Q.forEachCell((le,Se)=>{Z.push([Se,Se+le.nodeSize]);});let te=ce.current.querySelectorAll(".layout-table-cell");for(let le of Array.from(te)){let Se=le,ge=Se.dataset.pmStart;if(ge!==void 0){let he=Number(ge);for(let[ke,Te]of Z)if(he>=ke&&he<Te){Se.classList.add("layout-table-cell-selected");break}}}}}if(!(!ee||G.length===0))if(W===U){let K=ur(W,f);if(K)Ne(K);else {let Q=ce.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),$=ce.current?.querySelector(".layout-page");if(Q&&$){let Z=Q.getBoundingClientRect(),te=$.getBoundingClientRect(),le=q(ee,G,xe,W);Ne(le?{...le,x:le.x+(te.left-Z.left)/f,y:le.y+(te.top-Z.top)/f}:null);}else Ne(null);}De([]);}else {let K=ce.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(K&&ce.current){let Q=K.getBoundingClientRect(),$=[],Z=ce.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let te of Array.from(Z)){let le=te,Se=Number(le.dataset.pmStart);if(Number(le.dataset.pmEnd)>W&&Se<U){if(le.classList.contains("layout-run-tab")){let Ue=le.getBoundingClientRect(),mt=le.closest(".layout-page"),yt=mt?Number(mt.dataset.pageNumber)-1:0;$.push({x:(Ue.left-Q.left)/f,y:(Ue.top-Q.top)/f,width:Ue.width/f,height:Ue.height/f,pageIndex:yt});continue}let he=null;if(te.firstChild?.nodeType===Node.TEXT_NODE?he=te.firstChild:te.firstChild?.nodeType===Node.ELEMENT_NODE&&te.firstChild.tagName==="A"&&te.firstChild.firstChild?.nodeType===Node.TEXT_NODE&&(he=te.firstChild.firstChild),!he)continue;let ke=le.ownerDocument;if(!ke)continue;let Te=Math.max(0,W-Se),Me=Math.min(he.length,U-Se);if(Te<Me){let Ue=ke.createRange();Ue.setStart(he,Te),Ue.setEnd(he,Me);let mt=Ue.getClientRects();for(let yt of Array.from(mt)){let sn=le.closest(".layout-page"),Ao=sn?Number(sn.dataset.pageNumber)-1:0;$.push({x:(yt.left-Q.left)/f,y:(yt.top-Q.top)/f,width:yt.width/f,height:yt.height/f,pageIndex:Ao});}}}}if($.length>0)De($);else {let te=ce.current.querySelector(".layout-page");if(te){let le=te.getBoundingClientRect(),Se=(le.left-Q.left)/f,ge=(le.top-Q.top)/f,ke=p(ee,G,xe,W,U).map(Te=>({...Te,x:Te.x+Se,y:Te.y+ge}));De(ke);}else De([]);}}else De([]);Ne(null);}},[ee,G,xe,ur,f]),pr=useCallback((C,W)=>{if(C.docChanged){Ft.incrementStateSeq(),Ln(W);let U=Y.current?.getDocument();U&&F.current?.(U);}Ft.requestRender(),C.docChanged||ae(W);},[Ln,ae,Ft]),Ss=useCallback(C=>{let{selection:W}=C;W instanceof NodeSelection&&W.node.type.name==="image"?(De([]),Ne(null)):Ft.isSafeToRender()&&ae(C),requestAnimationFrame(()=>{let U=Y.current?.getView();if(!U){ze(null);return}let{selection:K}=U.state;if(K instanceof NodeSelection&&K.node.type.name==="image"){let Q=K.from,$=ce.current?.querySelector(`[data-pm-start="${Q}"]`);if($){ze(Ie($,Q));return}}ve.current||ze(null);});},[ae,f,Ie,Ft]),Lt=useCallback((C,W)=>{if(!ce.current||!ee)return null;let U=gf(ce.current,C,W,f);if(U!==null)return U;let K=ce.current.querySelectorAll(".layout-page"),Q=-1,$=null;for(let he=0;he<K.length;he++){let Te=K[he].getBoundingClientRect();if(C>=Te.left&&C<=Te.right&&W>=Te.top&&W<=Te.bottom){Q=he,$=Te;break}}if(Q<0||!$)return null;let Z=(C-$.left)/f,te=(W-$.top)/f,le=ee.pages[Q];if(!le)return null;let Se={pageIndex:Q,page:le,pageY:te},ge=n(Se,G,xe,{x:Z,y:te});if(!ge)return null;if(ge.fragment.kind==="table"){let he=o(Se,G,xe,{x:Z,y:te});return Ol(ge,he)}return Ol(ge)},[ee,G,xe,f]),Wn=useCallback(C=>{let W=Y.current?.getView();if(!W)return null;try{let U=W.state.doc.resolve(C);for(let K=U.depth;K>0;K--){let Q=U.node(K);if(Q.type.name==="tableCell"||Q.type.name==="tableHeader")return U.before(K)}}catch{}return null},[]),Ve=useCallback(C=>{let W=["layout-block-image","layout-image","layout-page-floating-image"],U=K=>!!K.dataset.pmStart&&W.some(Q=>K.classList.contains(Q));return C.tagName==="IMG"&&C.classList.contains("layout-run-image")?C:C.tagName==="IMG"&&C.parentElement&&U(C.parentElement)?C.parentElement:U(C)?C:null},[]),Bt=useCallback(C=>{let W=ce.current;if(!W)return;let U=W.querySelector(`[data-pm-start="${C}"]`);U&&U.scrollIntoView({behavior:"smooth",block:"center"});},[]),Vn=useCallback(C=>{if(!Y.current)return;if(C.button===2){C.preventDefault();return}if(C.button!==0||(nn(null),on(),C.target.closest("a[href]")&&C.preventDefault(),c))return;if(E&&V){let $=C.target;if(!($.closest(".layout-page-header")||$.closest(".layout-page-footer")||$.closest(".hf-inline-editor"))){C.preventDefault(),C.stopPropagation(),V();return}}if(!E){let $=C.target;if($.closest(".layout-page-header")||$.closest(".layout-page-footer")){C.preventDefault(),Y.current&&(Y.current.setSelection(0),Y.current.focus(),de(true));return}}let U=C.target;if(U.classList.contains("layout-table-resize-handle")){C.preventDefault(),C.stopPropagation(),lt.current=true,qe.current=C.clientX,st.current=U,U.classList.add("dragging");let $=parseInt(U.dataset.columnIndex??"0",10);ht.current=$,It.current=parseInt(U.dataset.tablePmStart??"0",10);let Z=Y.current.getView();if(Z){let te=Z.state.doc.resolve(It.current+1);for(let le=te.depth;le>=0;le--){let Se=te.node(le);if(Se.type.name==="table"){let ge=Se.attrs.columnWidths;ge&&ge[$]!==void 0&&ge[$+1]!==void 0&&(He.current={left:ge[$],right:ge[$+1]});break}}}return}if(U.classList.contains("layout-table-row-resize-handle")||U.classList.contains("layout-table-edge-handle-bottom")){C.preventDefault(),C.stopPropagation(),Be.current=true,ut.current=C.clientY,Rt.current=U,ys.current=U.dataset.isEdge==="bottom",U.classList.add("dragging");let $=parseInt(U.dataset.rowIndex??"0",10);Xt.current=$,cr.current=parseInt(U.dataset.tablePmStart??"0",10);let Z=Y.current.getView();if(Z){let te=Z.state.doc.resolve(cr.current+1);for(let le=te.depth;le>=0;le--){let Se=te.node(le);if(Se.type.name==="table"){let ge=null,he=0;if(Se.forEach(ke=>{he===$&&(ge=ke),he++;}),ge){let ke=ge.attrs.height;if(ke)bt.current=ke;else {let Me=U.closest(".layout-table")?.querySelector(`[data-row-index="${$}"]`),Ue=Me?Me.getBoundingClientRect().height:30;bt.current=Math.round(Ue*15);}}break}}}return}if(U.classList.contains("layout-table-edge-handle-right")){C.preventDefault(),C.stopPropagation(),Fn.current=true,Lo.current=C.clientX,Zt.current=U,U.classList.add("dragging");let $=parseInt(U.dataset.columnIndex??"0",10);dr.current=$,mn.current=parseInt(U.dataset.tablePmStart??"0",10);let Z=Y.current.getView();if(Z){let te=Z.state.doc.resolve(mn.current+1);for(let le=te.depth;le>=0;le--){let Se=te.node(le);if(Se.type.name==="table"){let ge=Se.attrs.columnWidths;ge&&ge[$]!==void 0&&(gn.current=ge[$]);break}}}return}let K=Ve(U);if(K){C.preventDefault(),C.stopPropagation();let $=K.dataset.pmStart;if($!==void 0){let Z=parseInt($,10);Y.current.setNodeSelection(Z),ze(Ie(K,Z)),De([]),Ne(null);}Y.current.focus(),de(true);return}ze(null),C.preventDefault();let Q=Lt(C.clientX,C.clientY);if(Q!==null){let $=Wn(Q);hn.current=$,jt.current=false,tn.current=null,bn.current=null,Ye.current=true,Ge.current=Q,Y.current.setSelection(Q);}else {hn.current=null,jt.current=false;let $=Y.current.getView();if($){let Z=Math.max(0,$.state.doc.content.size-1);Y.current.setSelection(Z),Ge.current=Z,Ye.current=true;}}Y.current.focus(),de(true);},[Lt,Wn,c,E,V,f,ie,on]),an=useCallback((C,W)=>{k.current(C,W);},[]),{updateMousePosition:fr,stopAutoScroll:mr}=Df({pagesContainerRef:ce,onScrollExtendSelection:an});k.current=(C,W)=>{if(!Ye.current||Ge.current===null||!Y.current)return;let U=Lt(C,W);U!==null&&Y.current.setSelection(Ge.current,U);};let Un=useCallback(C=>{if(lt.current){C.preventDefault();let K=C.clientX-qe.current;if(st.current){let Q=parseFloat(st.current.style.left);st.current.style.left=`${Q+K}px`,qe.current=C.clientX;let $=Math.round(K*15),Z=300,te=He.current.left+$,le=He.current.right-$;te>=Z&&le>=Z&&(He.current={left:te,right:le});}return}if(Be.current){C.preventDefault();let K=C.clientY-ut.current;if(Rt.current){let Q=parseFloat(Rt.current.style.top);Rt.current.style.top=`${Q+K}px`,ut.current=C.clientY;let $=Math.round(K*15),Z=200,te=bt.current+$;te>=Z&&(bt.current=te);}return}if(Fn.current){C.preventDefault();let K=C.clientX-Lo.current;if(Zt.current){let Q=parseFloat(Zt.current.style.left);Zt.current.style.left=`${Q+K}px`,Lo.current=C.clientX;let $=Math.round(K*15),Z=300,te=gn.current+$;te>=Z&&(gn.current=te);}return}if(!Ye.current||Ge.current===null||!Y.current||!ce.current)return;fr(C.clientX,C.clientY);let W=Lt(C.clientX,C.clientY);if(W===null)return;if(hn.current!==null){if(jt.current){let Q=Wn(W);if(Q!==null){Y.current.setCellSelection(hn.current,Q);return}}let K=Wn(W);if(K!==null&&K!==hn.current){jt.current=true,Y.current.setCellSelection(hn.current,K),bn.current=null;return}if(tn.current!==null&&W===tn.current){if(bn.current===null)bn.current=C.clientX;else if(Math.abs(C.clientX-bn.current)>=xs){jt.current=true,Y.current.setCellSelection(hn.current,hn.current),bn.current=null;return}}else bn.current=null,tn.current=W;}let U=Ge.current;Y.current.setSelection(U,W);},[Lt,Wn,fr]),yn=useCallback(()=>{if(lt.current){lt.current=false,st.current&&(st.current.classList.remove("dragging"),st.current=null);let C=Y.current?.getView();if(C){let W=It.current,U=ht.current,{left:K,right:Q}=He.current,$=C.state.doc.resolve(W+1);for(let Z=$.depth;Z>=0;Z--){let te=$.node(Z);if(te.type.name==="table"){let le=$.before(Z),Se=C.state.tr,ge=[...te.attrs.columnWidths];ge[U]=K,ge[U+1]=Q,Se.setNodeMarkup(le,void 0,{...te.attrs,columnWidths:ge});let he=le+1;te.forEach(ke=>{let Te=he+1,Me=0;ke.forEach(Ue=>{let mt=Ue.attrs.colspan||1;if(Me===U||Me===U+1){let yt=Me===U?K:Q;Se.setNodeMarkup(Se.mapping.map(Te),void 0,{...Ue.attrs,width:yt,widthType:"dxa",colwidth:null});}Te+=Ue.nodeSize,Me+=mt;}),he+=ke.nodeSize;}),C.dispatch(Se);break}}}return}if(Be.current){Be.current=false,Rt.current&&(Rt.current.classList.remove("dragging"),Rt.current=null);let C=Y.current?.getView();if(C){let W=cr.current,U=Xt.current,K=bt.current,Q=C.state.doc.resolve(W+1);for(let $=Q.depth;$>=0;$--){let Z=Q.node($);if(Z.type.name==="table"){let te=Q.before($),le=C.state.tr,Se=te+1,ge=0;Z.forEach(he=>{ge===U&&le.setNodeMarkup(le.mapping.map(Se),void 0,{...he.attrs,height:K,heightRule:"atLeast"}),Se+=he.nodeSize,ge++;}),C.dispatch(le);break}}}return}if(Fn.current){Fn.current=false,Zt.current&&(Zt.current.classList.remove("dragging"),Zt.current=null);let C=Y.current?.getView();if(C){let W=mn.current,U=dr.current,K=gn.current,Q=C.state.doc.resolve(W+1);for(let $=Q.depth;$>=0;$--){let Z=Q.node($);if(Z.type.name==="table"){let te=Q.before($),le=C.state.tr,Se=[...Z.attrs.columnWidths];Se[U]=K,le.setNodeMarkup(te,void 0,{...Z.attrs,columnWidths:Se});let ge=te+1;Z.forEach(he=>{let ke=ge+1,Te=0;he.forEach(Me=>{let Ue=Me.attrs.colspan||1;Te===U&&le.setNodeMarkup(le.mapping.map(ke),void 0,{...Me.attrs,width:K,widthType:"dxa",colwidth:null}),ke+=Me.nodeSize,Te+=Ue;}),ge+=he.nodeSize;}),C.dispatch(le);break}}}return}Ye.current=false,jt.current=false,tn.current=null,bn.current=null,mr();},[mr]);useEffect(()=>(window.addEventListener("mousemove",Un),window.addEventListener("mouseup",yn),()=>{window.removeEventListener("mousemove",Un),window.removeEventListener("mouseup",yn);}),[Un,yn]);let ks=useCallback(C=>{if(c||Ye.current||lt.current||Be.current||Fn.current||jt.current)return;let W=ce.current;if(!W)return;let U=C.clientX,K=C.clientY,Q=C.target.closest(".layout-table");if(!Q){let ke=W.querySelectorAll(".layout-table");for(let Te of Array.from(ke)){let Me=Te.getBoundingClientRect(),Ue=U>=Me.left-uo&&U<Me.left,mt=K>=Me.top-uo&&K<Me.top,yt=U>=Me.left-uo&&U<=Me.right,sn=K>=Me.top-uo&&K<=Me.bottom;if(Ue&&sn||mt&&yt){Q=Te;break}}}if(!Q){nn(null);return}let $=Q.getBoundingClientRect(),Z=U<$.left+uo&&U>=$.left-uo,te=K<$.top+uo&&K>=$.top-uo;if(!Z&&!te){nn(null);return}let le=Q.querySelectorAll(":scope > .layout-table-row");if(le.length===0){nn(null);return}let Se=W.parentElement;if(!Se)return;let ge=Se.getBoundingClientRect(),he=ke=>ke&&Number(ke.dataset.pmStart)||0;if(Z)for(let ke=0;ke<le.length;ke++){let Te=le[ke].getBoundingClientRect();if(K>=Te.top&&K<=Te.bottom){let Me=le[ke].querySelector(".layout-table-cell"),Ue=he(Me);if(!Ue)break;let mt=Te.top+Te.height/2;nn({type:"row",x:$.left-ge.left-24,y:mt-ge.top-10,cellPmPos:Ue}),on();return}}if(te){let ke=le[0].querySelectorAll(":scope > .layout-table-cell");for(let Te=0;Te<ke.length;Te++){let Me=ke[Te].getBoundingClientRect();if(U>=Me.left&&U<=Me.right){let Ue=he(ke[Te]);if(!Ue)break;let mt=Me.left+Me.width/2;nn({type:"column",x:mt-ge.left-10,y:$.top-ge.top-24,cellPmPos:Ue}),on();return}}}ct.current||(ct.current=setTimeout(()=>{nn(null),ct.current=null;},NS));},[c,on]),mo=useCallback(C=>{if(C.preventDefault(),C.stopPropagation(),!zt||!Y.current)return;let W=Y.current.getView();if(!W)return;let{type:U,cellPmPos:K}=zt,Q=W.state.tr.setSelection(TextSelection.create(W.state.doc,K+1));W.dispatch(Q),U==="row"?wo(W.state,W.dispatch):vo(W.state,W.dispatch),nn(null),Y.current.focus();},[zt]),ni=useCallback(C=>{let W=C.target.closest("a[href]");if(W){C.preventDefault();let U=W.getAttribute("href")||"";if(U.startsWith("#")){let K=U.substring(1);if(K&&Y.current){let Q=Y.current.getView();if(Q){let $=null;Q.state.doc.descendants((Z,te)=>{if($!==null)return false;if(Z.type.name==="paragraph"&&Z.attrs.bookmarks?.some(Se=>Se.name===K))return $=te,false}),$!==null&&(Bt($),Y.current.setSelection($+1));}}}else if(ie){let K=Y.current?.getView();if(!(K&&K.state.selection.from!==K.state.selection.to)){let $=W.textContent||"",Z=W.getAttribute("title")||void 0,te=W.getBoundingClientRect();ie({href:U,displayText:$,tooltip:Z,anchorRect:te});}}return}if(C.detail===2&&v){let U=C.target,K=U.closest(".layout-page-header"),Q=U.closest(".layout-page-footer");if(K||Q){let $=U.closest("[data-page-number]"),Z=$?Number($.dataset.pageNumber):1;if(K){C.preventDefault(),C.stopPropagation(),v("header",Z);return}if(Q){C.preventDefault(),C.stopPropagation(),v("footer",Z);return}}}if(C.detail===2&&Y.current){let U=Lt(C.clientX,C.clientY);if(U!==null){let K=Wn(U);if(K!==null){C.preventDefault(),C.stopPropagation(),Y.current.setCellSelection(K,K);return}let Q=Y.current.getView();if(Q){let{doc:$}=Q.state,Z=$.resolve(U),te=Z.parent;if(te.isTextblock){let le=te.textContent,Se=Z.parentOffset,ge=Se;for(;ge>0&&/\w/.test(le[ge-1]);)ge--;let he=Se;for(;he<le.length&&/\w/.test(le[he]);)he++;let ke=Z.start()+ge,Te=Z.start()+he;ke<Te&&Y.current.setSelection(ke,Te);}}}}if(C.detail===3&&Y.current){let U=Lt(C.clientX,C.clientY);if(U!==null){let K=Y.current.getView();if(K){let{doc:Q}=K.state,$=Q.resolve(U),Z=$.start($.depth),te=$.end($.depth);Y.current.setSelection(Z,te);}}}},[Lt,v,ie]),gr=useCallback(C=>{if(!z)return;C.preventDefault();let W=Y.current?.getView();if(!W)return;let{from:U,to:K}=W.state.selection,Q=Lt(C.clientX,C.clientY);Q!==null&&(U===K||Q<U||Q>K)&&(Y.current?.setSelection(Q),Y.current?.focus(),de(true));let $=Y.current?.getState(),Z=$?$.selection.from!==$.selection.to:false;z({x:C.clientX,y:C.clientY,hasSelection:Z});},[z,Lt]),Bo=useCallback(C=>{if(c)return;let W=C.target;W.closest(".docx-comments-sidebar")||W.closest(".docx-unified-sidebar")||(Y.current?.focus(),de(true));},[c]),At=useCallback(C=>{let W=C.relatedTarget;W&&Ee.current?.contains(W)||W?.closest('[role="toolbar"], [data-radix-popper-content-wrapper], [data-radix-select-content], .docx-table-options-dropdown')||de(false);},[]),oi=useCallback((C,W,U)=>{let K=Y.current?.getView();if(K)try{let Q=K.state.doc.nodeAt(C);if(!Q||Q.type.name!=="image")return;let $=K.state.tr.setNodeMarkup(C,void 0,{...Q.attrs,width:W,height:U});K.dispatch($),Y.current?.setNodeSelection(C);}catch{}},[]),hr=useCallback(()=>{ve.current=true;},[]),Bn=useCallback(()=>{ve.current=false;},[]),ri=useCallback((C,W,U)=>{let K=Y.current?.getView();if(K)try{let Q=K.state.doc.nodeAt(C);if(!Q||Q.type.name!=="image")return;if(Q.attrs.displayMode==="float"||Q.attrs.wrapType&&["square","tight","through"].includes(Q.attrs.wrapType)){let Z=ce.current?.querySelectorAll(".layout-page");if(!Z||Z.length===0)return;let te=null;for(let mt of Z){let yt=mt.getBoundingClientRect();if(U>=yt.top&&U<=yt.bottom){te=mt.querySelector(".layout-page-content");break}}if(te||(te=Z[Z.length-1].querySelector(".layout-page-content")),!te)return;let le=te.getBoundingClientRect(),Se=(W-le.left)/f,ge=(U-le.top)/f,he=914400/96,ke=Math.round(Se*he),Te=Math.round(ge*he),Me={horizontal:{posOffset:ke,relativeTo:"margin"},vertical:{posOffset:Te,relativeTo:"margin"}},Ue=K.state.tr.setNodeMarkup(C,void 0,{...Q.attrs,position:Me});K.dispatch(Ue),Y.current?.setNodeSelection(C);}else {let Z=Lt(W,U);if(Z===null||Z===C||Z===C+1)return;let te=K.state.tr;if(Z<=C)te=te.delete(C,C+Q.nodeSize),te=te.insert(Z,Q),Y.current?.setNodeSelection(Z);else {te=te.delete(C,C+Q.nodeSize);let le=Z-Q.nodeSize;te=te.insert(Math.min(le,te.doc.content.size),Q),Y.current?.setNodeSelection(Math.min(le,te.doc.content.size-1));}K.dispatch(te);}}catch{}},[Lt,f]),go=useCallback(()=>{ve.current=true;},[]),Cs=useCallback(()=>{ve.current=false;},[]),Le=useCallback(C=>{if(!c){if(Y.current?.isFocused()||(Y.current?.focus(),de(true)),C.key===" "&&!C.ctrlKey&&!C.metaKey&&!C.nativeEvent.isComposing){C.preventDefault();let W=Y.current?.getView();if(W){let{from:U,to:K}=W.state.selection;W.someProp("handleTextInput",$=>$(W,U,K," "))||W.dispatch(W.state.tr.insertText(" "));}return}if(["PageUp","PageDown"].includes(C.key)&&!C.metaKey&&C.ctrlKey,C.key==="Home"&&(C.metaKey||C.ctrlKey)){let W=me();W&&(W.scrollTop=0);}if(C.key==="End"&&(C.metaKey||C.ctrlKey)){let W=me();W&&(W.scrollTop=W.scrollHeight);}}},[c,me]),Je=useCallback(C=>{c||C.target.closest(".docx-comments-sidebar")||C.target.closest(".docx-unified-sidebar")||Y.current?.isFocused()||(Y.current?.focus(),de(true));},[c]),Ts=useCallback(C=>{Ot(C.state),ae(C.state),c||requestAnimationFrame(()=>{C.focus(),de(true);});},[Ot,ae,c]);useEffect(()=>{let C=()=>{let W=Y.current?.getView();W&&(f$2(),zl(),Ot(W.state),ae(W.state));};return window.document.fonts.addEventListener("loadingdone",C),()=>{window.document.fonts.removeEventListener("loadingdone",C);}},[]);let ii=useRef(0);useEffect(()=>{if(ii.current===0){ii.current=1;return}let C=Y.current?.getView();C&&Ot(C.state);},[s,l,u,d,Ot]),useEffect(()=>{let C=Ee.current;if(!C)return;let W=new ResizeObserver(()=>{let U=Y.current?.getState();U&&ae(U);});return W.observe(C),()=>W.disconnect()},[ae]),useImperativeHandle(n$1,()=>({getDocument(){return Y.current?.getDocument()??null},getState(){return Y.current?.getState()??null},getView(){return Y.current?.getView()??null},focus(){Y.current?.focus(),de(true);},blur(){Y.current?.blur(),de(false);},isFocused(){return Y.current?.isFocused()??false},dispatch(C){Y.current?.dispatch(C);},undo(){return Y.current?.undo()??false},redo(){return Y.current?.redo()??false},setSelection(C,W){Y.current?.setSelection(C,W);},getLayout(){return ee},relayout(){let C=Y.current?.getState();C&&Ot(C);},scrollToPosition:Bt}),[ee,Ot,Bt]),useEffect(()=>{let C=Y.current?.getState();ee&&C&&ae(C);},[ee,ae]),useEffect(()=>{H.current&&Y.current&&H.current({getDocument:()=>Y.current?.getDocument()??null,getState:()=>Y.current?.getState()??null,getView:()=>Y.current?.getView()??null,focus:()=>{Y.current?.focus(),de(true);},blur:()=>{Y.current?.blur(),de(false);},isFocused:()=>Y.current?.isFocused()??false,dispatch:C=>Y.current?.dispatch(C),undo:()=>Y.current?.undo()??false,redo:()=>Y.current?.redo()??false,setSelection:(C,W)=>Y.current?.setSelection(C,W),getLayout:()=>ee,relayout:()=>{let C=Y.current?.getState();C&&Ot(C);},scrollToPosition:Bt});},[ee,Ot]);let ft=useMemo(()=>{if(!ee)return Wf+48;let C=ee.pages.length;return C*pt.h+(C-1)*p$1+48},[ee,pt.h,p$1]);return jsxs("div",{ref:Ee,className:`ep-root paged-editor ${D??""}`,style:{...OS,...P},tabIndex:0,onFocus:Bo,onBlur:At,onKeyDown:Le,onMouseDown:Je,children:[jsx(Yp,{ref:Y,document:o$1,styles:r,widthPx:Et,readOnly:c,onTransaction:pr,onSelectionChange:Ss,externalPlugins:g,extensionManager:x,onEditorViewReady:Ts,onKeyDown:L}),jsxs("div",{style:{...$S,minHeight:ft,marginBottom:f!==1?ft*(f-1):void 0,transform:(()=>{let C=[];return I&&C.push(`translateX(-${176}px)`),f!==1&&C.push(`scale(${f})`),C.length>0?C.join(" "):void 0})(),transformOrigin:"top center",transition:"transform 0.2s ease"},children:[jsx("div",{ref:ce,className:`paged-editor__pages${c?" paged-editor--readonly":""}${E?` paged-editor--hf-editing paged-editor--editing-${E}`:""}`,style:_S,onMouseDown:Vn,onMouseMove:ks,onClick:ni,onContextMenu:gr,"aria-hidden":"true"}),jsx(Xp,{selectionRects:Pe,caretPosition:je,isFocused:pe,pageGap:p$1,readOnly:c}),jsx(tf,{imageInfo:Ke,zoom:f,isFocused:pe,onResize:oi,onResizeStart:hr,onResizeEnd:Bn,onDragMove:ri,onDragStart:go,onDragEnd:Cs}),zt&&jsx("button",{type:"button",onMouseDown:mo,onMouseEnter:on,onMouseLeave:()=>nn(null),style:{position:"absolute",left:zt.x,top:zt.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:zt.type==="row"?"Insert row below":"Insert column to the right","aria-label":zt.type==="row"?"Insert row below":"Insert column to the right",children:jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:jsx("path",{d:"M6 1v10M1 6h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),B&&jsx("div",{className:"paged-editor__plugin-overlays",style:WS,children:B})]}),J&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:ft*f,pointerEvents:"none",overflow:"visible"},children:jsx("div",{style:{pointerEvents:"auto"},children:J})})]})}),Gf=memo(nk);var ak=lazy(()=>import('./FindReplaceDialog-N4J5OB7O.mjs')),sk=lazy(()=>import('./HyperlinkDialog-YQSQFHOP.mjs')),lk=lazy(()=>import('./TablePropertiesDialog-FI5E3RCB.mjs').then(e=>({default:e.TablePropertiesDialog}))),ck=lazy(()=>import('./ImagePositionDialog-HT6J2SHV.mjs').then(e=>({default:e.ImagePositionDialog}))),dk=lazy(()=>import('./ImagePropertiesDialog-3VK2S2AF.mjs').then(e=>({default:e.ImagePropertiesDialog}))),uk=lazy(()=>import('./FootnotePropertiesDialog-UFUIHLDW.mjs').then(e=>({default:e.FootnotePropertiesDialog}))),pk=lazy(()=>import('./PageSetupDialog-SMQJXEBL.mjs').then(e=>({default:e.PageSetupDialog}))),Yf=[{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 gk({mode:e,onModeChange:t}){let[n,o]=useState(false),[r,i]=useState(false),a=useRef(null),s=useRef(null),[l,u]=useState({top:0,left:0}),d$1=Yf.find(c=>c.value===e);return 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)},[]),useEffect(()=>{if(!n||!a.current)return;let c=a.current.getBoundingClientRect();u({top:c.bottom+2,left:c.right-220});},[n]),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]),jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:a,type:"button",onMouseDown:c=>c.preventDefault(),onClick:()=>o(!n),title:`${d$1.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:[jsx(d,{name:d$1.icon,size:18}),!r&&jsx("span",{children:d$1.label}),jsx(d,{name:"arrow_drop_down",size:16})]}),n&&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:Yf.map(c=>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:[jsx(d,{name:c.icon,size:20}),jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[jsx("span",{style:{fontWeight:500},children:c.label}),jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted, #9ca3af)"},children:c.desc})]}),c.value===e&&jsx(d,{name:"check",size:18,style:{marginLeft:"auto",color:"#1a73e8"}})]},c.value))})]})}var ec=1,Zr=-1;function hk(e,t){let n=t.filter(i=>i.parentId!=null);if(n.length===0)return;let o=new Map;for(let i of n){let a=o.get(i.parentId);a?a.push(i.id):o.set(i.parentId,[i.id]);}function r(i){for(let a of i)if(a.type==="paragraph"){if(!a.content.some(l=>l.type==="commentRangeStart"||l.type==="commentRangeEnd"))continue;let s=[];for(let l of a.content)if(l.type==="commentRangeStart"){s.push(l);let u=o.get(l.id);if(u)for(let d of u)s.push({type:"commentRangeStart",id:d});}else if(l.type==="commentRangeEnd"){s.push(l);let u=o.get(l.id);if(u)for(let d of u)s.push({type:"commentRangeEnd",id:d});}else s.push(l);a.content=s;}else if(a.type==="table")for(let s of a.rows)for(let l of s.cells)r(l.content);}r(e);}function bk(e,t){let n=new Set(t.map(a=>a.id)),o=t.filter(a=>a.parentId!=null&&!n.has(a.parentId));if(o.length===0)return;let r=new Map;for(let a of o){let s=r.get(a.parentId);s?s.push(a.id):r.set(a.parentId,[a.id]);}function i(a){for(let s of a)if(s.type==="paragraph"){if(!s.content.some(d=>(d.type==="insertion"||d.type==="deletion")&&r.has(d.info.id)))continue;let u=[];for(let d of s.content)if((d.type==="insertion"||d.type==="deletion")&&r.has(d.info.id)){let c=r.get(d.info.id);for(let p of c)u.push({type:"commentRangeStart",id:p});u.push(d);for(let p of c)u.push({type:"commentRangeEnd",id:p});}else u.push(d);s.content=u;}else if(s.type==="table")for(let l of s.rows)for(let u of l.cells)i(u.content);}i(e);}var qf=new Map;function Xf(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 Ql(e,t,n){return {id:ec++,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 Jf=forwardRef(function({documentBuffer:t,document:n,onSave:o,author:r="User",onChange:i$1,onSelectionChange:a$2,onError:s,onFontsLoaded:l$2,theme:u,showToolbar:d$1=true,showZoomControl:c$1=true,showMarginGuides:p=false,marginGuideColor:f$1,showRuler:m$2=false,rulerUnit:b="inch",initialZoom:g=1,readOnly:x=false,toolbarExtra:T,className:S="",style:B,placeholder:v,loadingIndicator:E$1,showOutline:V=false,showOutlineButton:D=true,showPrintButton:P=true,printOptions:I,onPrint:J,onCopy:se,onCut:ie,onPaste:z$1,mode:N,onModeChange:ue,onCommentAdd:me,onCommentResolve:Ee,onCommentDelete:ce,onCommentReply:Y,externalPlugins:R,onEditorViewReady:L,onRenderedDomContextReady:k,pluginOverlays:M,pluginSidebarItems:F,pluginRenderedDomContext:H,renderLogo:oe,documentName:ee,onDocumentNameChange:_,documentNameEditable:G=true,renderTitleBarRight:ne},xe){let[re,pe]=useState({isLoading:!!t,parseError:null,zoom:g,selectionFormatting:{},paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[de,Pe]=useState(false),[De,je]=useState(false),[Ne,Ke]=useState(false),[ze,ve]=useState(false),[Ie,Ye]=useState(null),[Ge,lt]=useState(false),[qe,ht]=useState(V),It=useRef(false);It.current=qe;let[He,st]=useState([]),[Be,ut]=useState(false),[Xt,cr]=useState(null),[bt,Rt]=useState([]),[ys,Fn]=useState([]),[Lo,dr]=useState(qf),[mn,gn]=useState(false),[Zt,jt]=useState(null),[hn,tn]=useState(null),[bn,xs]=useState(N??"editing"),zt=N??bn,nn=y=>{N||xs(y),ue?.(y);},ct=x||zt==="viewing",[on,Ft]=useState(null),[pt,Ct]=useState({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false}),Jt=useRef(null),Et=useRef(null),ti=useRef(bt);ti.current=bt;let Ot=useRef(mn);Ot.current=mn;let rn=useRef(ce);rn.current=ce;let Ln=useCallback(()=>{let y=Ve.current?.getView();if(!y)return;let{doc:h,schema:w}=y.state,A=w.marks.insertion,O=w.marks.deletion;if(!A&&!O)return;let j=[];h.descendants((X,fe)=>{if(X.isText)for(let be of X.marks)(be.type===A||be.type===O)&&j.push({type:be.type===A?"insertion":"deletion",text:X.text||"",author:be.attrs.author||"",date:be.attrs.date,from:fe,to:fe+X.nodeSize,revisionId:be.attrs.revisionId});});let q=[];for(let X of j){let fe=q[q.length-1];fe&&fe.revisionId===X.revisionId&&fe.type===X.type&&fe.to===X.from?(fe.text+=X.text,fe.to=X.to):q.push({...X});}Fn(q);},[]),ur=useCallback(()=>{if(Ot.current)return;let y=Ve.current?.getView();if(!y)return;let{doc:h,schema:w}=y.state,A=w.marks.comment;if(!A)return;let O=new Set;h.descendants(X=>{for(let fe of X.marks)if(fe.type===A){let be=fe.attrs.commentId;be!==Zr&&O.add(be);}});let j=ti.current,q=new Set;for(let X of j)X.parentId==null&&!O.has(X.id)&&q.add(X.id);if(q.size!==0){for(let X of j)q.has(X.id)&&rn.current?.(X);Rt(X=>X.filter(fe=>!q.has(fe.id)&&!q.has(fe.parentId)));}},[]);useEffect(()=>()=>{Jt.current&&clearTimeout(Jt.current),Et.current&&clearTimeout(Et.current);},[]),useEffect(()=>{if(ht(V),V){let y=Ve.current?.getView();y&&st(Yo(y.state.doc));}},[V]);let ae=zp(n||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),pr=useRef(false);useEffect(()=>{if(pr.current)return;let y=ae.state;if(!y)return;let h=y.package?.document?.comments;if(h&&h.length>0){Rt(h),ut(true),pr.current=true;let w=h.reduce((O,j)=>Math.max(O,j.id),0),A=Ve.current?.getView();A&&A.state.doc.descendants(O=>{for(let j of O.marks)j.attrs.revisionId!=null&&(w=Math.max(w,j.attrs.revisionId));}),w>=ec&&(ec=w+1);}},[ae.state]);let Ss=useMemo(()=>{let y=new qn(Qo());return y.buildSchema(),y.initializeRuntime(),y},[]),Lt=useMemo(()=>Wp(zt==="suggesting",r),[]),Wn=useMemo(()=>[Lt,...R??[]],[Lt,R]),Ve=useRef(null),Bt=useRef(null),Vn=useRef(null),an=useRef(null),fr=useRef(null),mr=useRef(null),Un=useRef(null),yn=useRef(null),ks=useRef(null),mo=useRef(null),[ni,gr]=useState(0),Bo=useRef(ae.state);Bo.current=ae.state;let At=useRef({style:"single",size:4,color:{rgb:"000000"}}),oi=useRef(null),hr=useCallback(y=>{let h=oi.current;if(h&&h.styles===y)return h.resolver;let w=To(y);return oi.current={styles:y,resolver:w},w},[]),[Bn,ri]=useState({currentPage:1,totalPages:1,visible:false}),go=useRef(null),Cs=useCallback(y=>{if(ks.current=y,mo.current&&(mo.current.disconnect(),mo.current=null),!y){gr(0);return}gr(y.offsetHeight);let h=new ResizeObserver(()=>{gr(y.offsetHeight);});h.observe(y),mo.current=h;},[]);useEffect(()=>()=>{mo.current?.disconnect();},[]);let Le=useCallback(()=>Ie&&Bt.current?Bt.current.getView():Ve.current?.getView(),[Ie]),Je=useCallback(()=>{Ie&&Bt.current?Bt.current.focus():Ve.current?.focus();},[Ie]),Ts=useCallback(()=>{Ie&&Bt.current?Bt.current.undo():Ve.current?.undo();},[Ie]),ii=useCallback(()=>{Ie&&Bt.current?Bt.current.redo():Ve.current?.redo();},[Ie]),ft=m(),C$1=m$1(),[W,U]=useState(false),K=useCallback(()=>U(true),[]),[Q,$]=useState(null),Z$1=useRef(0),te=useCallback(()=>{pr.current=false,ge.current=false,Rt([]),Fn([]),st([]),ut(false),gn(false),jt(null),tn(null),Ft(null),Ye(null),dr(qf),ft.setMatches([],0),Jt.current&&(clearTimeout(Jt.current),Jt.current=null),Et.current&&(clearTimeout(Et.current),Et.current=null);},[ft.setMatches]),le=useCallback(y=>{te(),ae.reset(y),pe(h=>({...h,isLoading:false,parseError:null})),l(y).catch(h=>{console.warn("Failed to load document fonts:",h);});},[te,ae]),Se=useCallback(async y=>{let h=++Z$1.current;te(),pe(w=>({...w,isLoading:true,parseError:null}));try{let w=await n$1(y);if(Z$1.current!==h)return;le(w);}catch(w){if(Z$1.current!==h)return;let A=w instanceof Error?w.message:"Failed to parse document";pe(O=>({...O,isLoading:false,parseError:A})),s?.(w instanceof Error?w:new Error(A));}},[te,le,s]);useEffect(()=>{if(!t){n&&le(n);return}Se(t);},[t,n]),useEffect(()=>{ae.state?Vn.current=new f(ae.state):Vn.current=null;},[ae.state]);let ge=useRef(false);useEffect(()=>{if(!re.isLoading&&ae.state){let y=setTimeout(()=>{Ln(),ge.current||(ge.current=true,Fn(h=>(h.length>0&&ut(true),h)));},200);return ()=>clearTimeout(y)}},[re.isLoading,ae.state,Ln]),useEffect(()=>h(()=>{l$2?.();}),[l$2]),useEffect(()=>{let y=Ve.current?.getView();y&&Vp(zt==="suggesting",y.state,y.dispatch,r);},[zt,r]);let he=useCallback(y=>(ae.push(y),y),[ae]),ke=useCallback(y=>{if(he(y),i$1?.(y),It.current){let h=Ve.current?.getView();h&&st(Yo(h.state.doc));}Jt.current&&clearTimeout(Jt.current),Jt.current=setTimeout(Ln,300),Et.current&&clearTimeout(Et.current),Et.current=setTimeout(ur,300);},[i$1,he,Ln,ur]),Te=useCallback(y=>{let h=Le();if(h){let{from:et,to:We}=h.state.selection;fr.current={from:et,to:We};}let w=null;if(h&&(w=Xe(h.state),w.isInTable||(w=null)),w?.cellBorderColor){let et=w.cellBorderColor,We=et.rgb;(!We||We==="auto")&&(We=a(et,u).replace(/^#/,"")),At.current={...At.current,color:{rgb:We}};}let A=null;if(h){let et=h.state.selection,We=et.node;We?.type.name==="image"&&(A={pos:et.from,wrapType:We.attrs.wrapType??"inline",displayMode:We.attrs.displayMode??"inline",cssFloat:We.attrs.cssFloat??null,transform:We.attrs.transform??null,alt:We.attrs.alt??null,borderWidth:We.attrs.borderWidth??null,borderColor:We.attrs.borderColor??null,borderStyle:We.attrs.borderStyle??null});}if(!y){Ft(null),pe(et=>({...et,selectionFormatting:{},pmTableContext:w,pmImageContext:A}));return}let{textFormatting:O,paragraphFormatting:j}=y,q=O.fontFamily?.ascii||O.fontFamily?.hAnsi,X=O.fontSize;if(!q||!X){let et=Bo.current,We=y.styleId;if(et?.package.styles&&We){let Tt=hr(et.package.styles).resolveParagraphStyle(We);!q&&Tt.runFormatting?.fontFamily&&(q=Tt.runFormatting.fontFamily.ascii||Tt.runFormatting.fontFamily.hAnsi),!X&&Tt.runFormatting?.fontSize&&(X=Tt.runFormatting.fontSize);}}let fe=O.color?.rgb?`#${O.color.rgb}`:void 0,be=j.numPr,Fe=be?{type:be.numId===1?"bullet":"numbered",level:be.ilvl??0,isInList:true,numId:be.numId}:void 0,Qe={bold:O.bold,italic:O.italic,underline:!!O.underline,strike:O.strike,superscript:O.vertAlign==="superscript",subscript:O.vertAlign==="subscript",fontFamily:q,fontSize:X,color:fe,highlight:O.highlight,alignment:j.alignment,lineSpacing:j.lineSpacing,listState:Fe,styleId:y.styleId??void 0,indentLeft:j.indentLeft,bidi:!!j.bidi};if(pe(et=>({...et,selectionFormatting:Qe,paragraphIndentLeft:j.indentLeft??0,paragraphIndentRight:j.indentRight??0,paragraphFirstLineIndent:j.indentFirstLine??0,paragraphHangingIndent:j.hangingIndent??false,paragraphTabs:j.tabs??null,pmTableContext:w,pmImageContext:A})),h&&y.hasSelection&&!mn&&!ct){let et=yn.current,We=Un.current,{from:Kt}=h.state.selection,Tt=Xf(et,We,Kt);if(Tt!=null&&et&&We){let Cr=et.querySelector(".paged-editor__pages")?.querySelector(".layout-page"),bi=Cr?Cr.getBoundingClientRect().right-We.getBoundingClientRect().left:We.getBoundingClientRect().width/2+408;Ft({top:Tt,left:bi});}}else Ft(null);a$2?.(y);},[a$2,mn,ct]),Me=od({document:ae.state,onChange:ke,onSelectionChange:y=>{}});useEffect(()=>{let y=h=>{let A=navigator.platform.toUpperCase().indexOf("MAC")>=0?h.metaKey:h.ctrlKey;if(!A&&!h.shiftKey&&!h.altKey&&(h.key==="Delete"||h.key==="Backspace")){let O=Ve.current?.getView();if(O){let j=O.state.selection;if("$anchorCell"in j&&typeof j.forEachCell=="function"){let X=Xe(O.state);if(X.isInTable&&X.table){let fe=0;X.table.descendants(Fe=>{(Fe.type.name==="tableCell"||Fe.type.name==="tableHeader")&&(fe+=1);});let be=0;if(j.forEachCell(()=>{be+=1;}),fe>0&&be>=fe){h.preventDefault(),$r(O.state,O.dispatch);return}}}}if(Me.state.tableIndex!==null){h.preventDefault(),Me.handleAction("deleteTable");return}}if(A&&!h.shiftKey&&!h.altKey){if(h.key.toLowerCase()==="f"){h.preventDefault();let O=window.getSelection(),j=O&&!O.isCollapsed?O.toString():"";ft.openFind(j);}else if(h.key.toLowerCase()==="h"){h.preventDefault();let O=window.getSelection(),j=O&&!O.isCollapsed?O.toString():"";ft.openReplace(j);}else if(h.key.toLowerCase()==="k"){h.preventDefault();let O=Ve.current?.getView();if(O){let j=Zo(O.state),q=Xo(O.state);q?C$1.openEdit({url:q.href,displayText:j,tooltip:q.tooltip}):C$1.openInsert(j);}}}};return document.addEventListener("keydown",y),()=>{document.removeEventListener("keydown",y);}},[ft,C$1,Me]);let Ue=useCallback((y,h)=>{let w=Le();w&&(ba(y,h)(w.state,w.dispatch),Je());},[Le,Je]),mt=useCallback(()=>{let y=Le();y&&(Oa(y.state,y.dispatch),Je());},[Le,Je]),yt=useCallback(()=>{let y=Le();y&&(ha(y.state,y.dispatch),Je());},[Le,Je]),sn=useCallback(()=>{ht(y=>{if(!y){let h=Ve.current?.getView();h&&st(Yo(h.state.doc));}return !y});},[]),Ao=useCallback(y=>{Ve.current?.scrollToPosition(y),Ve.current?.setSelection(y+1),Ve.current?.focus();},[]),ai=useCallback(()=>{mr.current?.click();},[]),si=useCallback(y=>{let h=y.target.files?.[0];if(!h)return;let w=Le();if(!w)return;let A=new FileReader;A.onload=()=>{let O=A.result,j=new Image;j.onload=()=>{let q=j.naturalWidth,X=j.naturalHeight,fe=612;if(q>fe){let We=fe/q;q=fe,X=Math.round(X*We);}let be=`rId_img_${Date.now()}`,Fe=w.state.schema.nodes.image.create({src:O,alt:h.name,width:q,height:X,rId:be,wrapType:"inline",displayMode:"inline"}),{from:Qe}=w.state.selection,et=w.state.tr.insert(Qe,Fe);w.dispatch(et.scrollIntoView()),Je();},j.src=O;},A.readAsDataURL(h),y.target.value="";},[Le,Je]),li=useCallback(y=>{let h=Le();if(!h||!re.pmImageContext)return;let w=re.pmImageContext.pos,A=h.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let O="inline",j=null;switch(y){case "inline":O="inline",j=null;break;case "square":case "tight":case "through":O="float",j="left";break;case "topAndBottom":O="block",j=null;break;case "behind":case "inFront":O="float",j="none";break;case "wrapLeft":O="float",j="right",y="square";break;case "wrapRight":O="float",j="left",y="square";break}let q=h.state.tr.setNodeMarkup(w,void 0,{...A.attrs,wrapType:y,displayMode:O,cssFloat:j});h.dispatch(q.scrollIntoView()),Je();},[Le,Je,re.pmImageContext]),ci=useCallback(y=>{let h=Le();if(!h||!re.pmImageContext)return;let w=re.pmImageContext.pos,A=h.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let O=A.attrs.transform||"",j=O.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),q=j?parseFloat(j[1]):0,X=/scaleX\(-1\)/.test(O),fe=/scaleY\(-1\)/.test(O);switch(y){case "rotateCW":q=(q+90)%360;break;case "rotateCCW":q=(q-90+360)%360;break;case "flipH":X=!X;break;case "flipV":fe=!fe;break}let be=[];q!==0&&be.push(`rotate(${q}deg)`),X&&be.push("scaleX(-1)"),fe&&be.push("scaleY(-1)");let Fe=be.length>0?be.join(" "):null,Qe=h.state.tr.setNodeMarkup(w,void 0,{...A.attrs,transform:Fe});h.dispatch(Qe.scrollIntoView()),Je();},[Le,Je,re.pmImageContext]),br=useCallback(y=>{let h=Le();if(!h||!re.pmImageContext)return;let w=re.pmImageContext.pos,A=h.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let O=h.state.tr.setNodeMarkup(w,void 0,{...A.attrs,position:{horizontal:y.horizontal,vertical:y.vertical},distTop:y.distTop??A.attrs.distTop,distBottom:y.distBottom??A.attrs.distBottom,distLeft:y.distLeft??A.attrs.distLeft,distRight:y.distRight??A.attrs.distRight});h.dispatch(O.scrollIntoView()),Je();},[Le,Je,re.pmImageContext]),yr=useCallback(()=>{Ke(true);},[]),Do=useCallback(y=>{let h=Le();if(!h||!re.pmImageContext)return;let w=re.pmImageContext.pos,A=h.state.doc.nodeAt(w);if(!A||A.type.name!=="image")return;let O=h.state.tr.setNodeMarkup(w,void 0,{...A.attrs,alt:y.alt??null,borderWidth:y.borderWidth??null,borderColor:y.borderColor??null,borderStyle:y.borderStyle??null});h.dispatch(O.scrollIntoView()),Je();},[Le,Je,re.pmImageContext]),ln=useCallback((y,h)=>{if(!ae.state?.package)return;let w={...ae.state.package.document,finalSectionProperties:{...ae.state.package.document.finalSectionProperties,footnotePr:y,endnotePr:h}};he({...ae.state,package:{...ae.state.package,document:w}});},[ae,he]),ho=useCallback(y=>{let h=Le();if(h){switch(y){case "addRowAbove":Hr(h.state,h.dispatch);break;case "addRowBelow":wo(h.state,h.dispatch);break;case "addColumnLeft":zr(h.state,h.dispatch);break;case "addColumnRight":vo(h.state,h.dispatch);break;case "deleteRow":Nr(h.state,h.dispatch);break;case "deleteColumn":Or(h.state,h.dispatch);break;case "deleteTable":$r(h.state,h.dispatch);break;case "selectTable":ya(h.state,h.dispatch);break;case "selectRow":xa(h.state,h.dispatch);break;case "selectColumn":Sa(h.state,h.dispatch);break;case "mergeCells":ka(h.state,h.dispatch);break;case "splitCell":Ca(h.state,h.dispatch);break;case "borderAll":wa(h.state,h.dispatch,At.current);break;case "borderOutside":va(h.state,h.dispatch,At.current);break;case "borderInside":Ra(h.state,h.dispatch,At.current);break;case "borderNone":Ta(h.state,h.dispatch);break;case "borderTop":Xn("top",At.current,true)(h.state,h.dispatch);break;case "borderBottom":Xn("bottom",At.current,true)(h.state,h.dispatch);break;case "borderLeft":Xn("left",At.current,true)(h.state,h.dispatch);break;case "borderRight":Xn("right",At.current,true)(h.state,h.dispatch);break;default:if(typeof y=="object"){if(y.type==="cellFillColor")Ha(y.color)(h.state,h.dispatch);else if(y.type==="borderColor"){let w=y.color.replace(/^#/,"");At.current={...At.current,color:{rgb:w}},Na(y.color)(h.state,h.dispatch);}else if(y.type==="borderWidth")At.current={...At.current,size:y.size},za(y.size)(h.state,h.dispatch);else if(y.type==="cellBorder")Xn(y.side,{style:y.style,size:y.size,color:{rgb:y.color.replace(/^#/,"")}})(h.state,h.dispatch);else if(y.type==="cellVerticalAlign")Ea(y.align)(h.state,h.dispatch);else if(y.type==="cellMargins")Pa(y.margins)(h.state,h.dispatch);else if(y.type==="cellTextDirection")Ma(y.direction)(h.state,h.dispatch);else if(y.type==="toggleNoWrap")Ia()(h.state,h.dispatch);else if(y.type==="rowHeight")Fa(y.height,y.rule)(h.state,h.dispatch);else if(y.type==="toggleHeaderRow")La()(h.state,h.dispatch);else if(y.type==="distributeColumns")Ba()(h.state,h.dispatch);else if(y.type==="autoFitContents")Aa()(h.state,h.dispatch);else if(y.type==="openTableProperties")Pe(true);else if(y.type==="tableProperties")_r(y.props)(h.state,h.dispatch);else if(y.type==="applyTableStyle"){let w=Bp(y.styleId),A=Bo.current;if(!w&&A?.package.styles){let j=hr(A.package.styles).getStyle(y.styleId);if(j){if(w={id:j.styleId,name:j.name??j.styleId},j.tblPr?.borders){let q=j.tblPr.borders;w.tableBorders={};for(let X of ["top","bottom","left","right","insideH","insideV"]){let fe=q[X];fe&&(w.tableBorders[X]={style:fe.style,size:fe.size,color:fe.color?.rgb?{rgb:fe.color.rgb}:void 0});}}if(j.tblStylePr){w.conditionals={};for(let q of j.tblStylePr){let X={};if(q.tcPr?.shading?.fill&&(X.backgroundColor=`#${q.tcPr.shading.fill}`),q.tcPr?.borders){let fe={};for(let be of ["top","bottom","left","right"]){let Fe=q.tcPr.borders[be];Fe&&(fe[be]={style:Fe.style,size:Fe.size,color:Fe.color?.rgb?{rgb:Fe.color.rgb}:void 0});}X.borders=fe;}q.rPr?.bold&&(X.bold=true),q.rPr?.color?.rgb&&(X.color=`#${q.rPr.color.rgb}`),w.conditionals[q.type]=X;}}w.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}w&&Da({styleId:w.id,tableBorders:w.tableBorders,conditionals:w.conditionals,look:w.look})(h.state,h.dispatch);}}else Me.handleAction(y);}Je();}},[Me,Le,Je]),xr=useCallback(y=>{y.preventDefault(),y.stopPropagation();let h=Ve.current?.getView(),w=h?Gn(h.state):false,{from:A,to:O}=h?.state.selection??{from:0,to:0},j=A!==O;Ct({isOpen:true,position:{x:y.clientX,y:y.clientY},hasSelection:j,cursorInTable:w});},[]),ws=useCallback(y=>{let h=Le();if(!h)return;h.focus();let w=h===Ve.current?.getView(),{from:A,to:O}=h.state.selection,j=fr.current;if(w&&j&&(A!==j.from||O!==j.to))try{let q=h.state.tr.setSelection(TextSelection.create(h.state.doc,j.from,j.to));h.dispatch(q);}catch(q){console.warn("Could not restore selection:",q);}if(y==="bold"){ji(h.state,h.dispatch);return}if(y==="italic"){Ki(h.state,h.dispatch);return}if(y==="underline"){Gi(h.state,h.dispatch);return}if(y==="strikethrough"){Yi(h.state,h.dispatch);return}if(y==="superscript"){qi(h.state,h.dispatch);return}if(y==="subscript"){Xi(h.state,h.dispatch);return}if(y==="bulletList"){ca(h.state,h.dispatch);return}if(y==="numberedList"){da(h.state,h.dispatch);return}if(y==="indent"){ua(h.state,h.dispatch)||ia()(h.state,h.dispatch);return}if(y==="outdent"){pa(h.state,h.dispatch)||aa()(h.state,h.dispatch);return}if(y==="clearFormatting"){Ir(h.state,h.dispatch);return}if(y==="setRtl"){ma(h.state,h.dispatch);return}if(y==="setLtr"){ga(h.state,h.dispatch);return}if(y==="insertLink"){let q=Zo(h.state),X=Xo(h.state);X?C$1.openEdit({url:X.href,displayText:q,tooltip:X.tooltip}):C$1.openInsert(q);return}if(typeof y=="object")switch(y.type){case "alignment":oa(y.value)(h.state,h.dispatch);break;case "textColor":{let q=y.value;typeof q=="string"?Lr({rgb:q.replace("#","")})(h.state,h.dispatch):q.auto?Zi(h.state,h.dispatch):Lr(q)(h.state,h.dispatch);break}case "highlightColor":{let q=y.value?z(y.value):"";Ji(q||y.value)(h.state,h.dispatch);break}case "fontSize":Qi(i(y.value))(h.state,h.dispatch);break;case "fontFamily":ea(y.value)(h.state,h.dispatch);break;case "lineSpacing":ra(y.value)(h.state,h.dispatch);break;case "applyStyle":{let q=Bo.current,X=q?.package.styles?hr(q.package.styles):null;if(X){let fe=X.resolveParagraphStyle(y.value);Dr(y.value,{paragraphFormatting:fe.paragraphFormatting,runFormatting:fe.runFormatting})(h.state,h.dispatch);}else Dr(y.value)(h.state,h.dispatch);break}}},[Le]),Sr=useCallback(y=>{pe(h=>({...h,zoom:y}));},[]),di=useCallback(y=>{let h=Le();if(!h)return;let w=y.url||"",A=y.tooltip,{empty:O}=h.state.selection;O&&y.displayText?Br(y.displayText,w,A)(h.state,h.dispatch):O?y.displayText&&Br(y.displayText,w,A)(h.state,h.dispatch):ta(w,A)(h.state,h.dispatch),C$1.close(),Je();},[C$1,Le,Je]),xt=useCallback(()=>{let y=Le();y&&(na(y.state,y.dispatch),Je());},[Le,Je]),bo=useCallback(()=>{xt(),C$1.close();},[C$1,xt]),xn=useCallback(y=>$(y),[]),yo=useCallback(y=>{window.open(y,"_blank","noopener,noreferrer");},[]),xo=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);});},[]),vs=useCallback((y,h)=>{let w=Le();if(!w)return;let A=w.state.schema.marks.hyperlink;if(!A)return;let{$from:O}=w.state.selection,j=O.marks().find(q=>q.type===A);if(j){let q=O.parent,X=O.start(),fe=[],be=null;q.forEach((Tt,kr)=>{let Cr=X+kr,bi=Cr+Tt.nodeSize;(Tt.isText?Tt.marks.find(lc=>lc.type===A&&lc.attrs.href===j.attrs.href):null)?be?be.end=bi:be={start:Cr,end:bi}:be&&(fe.push(be),be=null);}),be&&fe.push(be);let Fe=O.pos,Qe=fe.find(Tt=>Tt.start<=Fe&&Fe<=Tt.end);if(!Qe)return;let et=w.state.tr,We=A.create({href:h,tooltip:j.attrs.tooltip}),Kt=w.state.schema.text(y,[...O.marks().filter(Tt=>Tt.type!==A),We]);et.replaceWith(Qe.start,Qe.end,Kt),w.dispatch(et.scrollIntoView());}$(null),Je();},[Le,Je]),hm=useCallback(()=>{let y=Le();if(!y)return;let h=y.state.schema.marks.hyperlink;if(!h)return;let{$from:w}=y.state.selection,A=w.marks().find(Qe=>Qe.type===h);if(!A&&w.nodeAfter&&(A=w.nodeAfter.marks.find(Qe=>Qe.type===h)),!A&&w.nodeBefore&&(A=w.nodeBefore.marks.find(Qe=>Qe.type===h)),!A&&Q&&w.parent.forEach(et=>{if(!A&&et.isText){let We=et.marks.find(Kt=>Kt.type===h&&Kt.attrs.href===Q.href);We&&(A=We);}}),!A)return;let O=w.parent,j=w.start(),q=[],X=null;O.forEach((Qe,et)=>{let We=j+et,Kt=We+Qe.nodeSize;(Qe.isText?Qe.marks.find(kr=>kr.type===h&&kr.attrs.href===A.attrs.href):null)?X?X.end=Kt:X={start:We,end:Kt}:X&&(q.push(X),X=null);}),X&&q.push(X);let fe=w.pos,be=q.find(Qe=>Qe.start<=fe&&fe<=Qe.end);if(!be)return;let Fe=y.state.tr;Fe.removeMark(be.start,be.end,h),y.dispatch(Fe.scrollIntoView()),$(null),Je(),toast("Link removed");},[Le,Je,Q]),bm=useCallback(()=>{$(null);},[]),ym=useCallback(y=>{let h=Ve.current?.getView(),w=h?Gn(h.state):false;Ct({isOpen:true,position:y,hasSelection:y.hasSelection,cursorInTable:w});},[]),xm=useCallback(()=>{Ct({isOpen:false,position:{x:0,y:0},hasSelection:false,cursorInTable:false});},[]),rc=useMemo(()=>{let h=typeof navigator<"u"&&/Mac/.test(navigator.platform)?"\u2318":"Ctrl",w=[{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:!pt.hasSelection&&!pt.cursorInTable}];return pt.hasSelection&&w.push({action:"addComment",label:"Comment",dividerAfter:!pt.cursorInTable}),pt.cursorInTable&&w.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}),w.push({action:"selectAll",label:"Select All",shortcut:`${h}+A`}),w},[pt.hasSelection,pt.cursorInTable]),ic=useCallback(async y=>{let h=Le();if(h)switch(Je(),y){case "cut":document.execCommand("cut");break;case "copy":document.execCommand("copy");break;case "paste":{try{let w=await navigator.clipboard.read(),A="",O="";for(let X of w)X.types.includes("text/html")&&(A=await(await X.getType("text/html")).text()),X.types.includes("text/plain")&&(O=await(await X.getType("text/plain")).text());let j=new DataTransfer;A&&j.items.add(A,"text/html"),O&&j.items.add(O,"text/plain");let q=new ClipboardEvent("paste",{clipboardData:j,bubbles:!0,cancelable:!0});h.dom.dispatchEvent(q);}catch{try{let w=await navigator.clipboard.readText();w&&h.dispatch(h.state.tr.insertText(w));}catch{}}break}case "pasteAsPlainText":try{let w=await navigator.clipboard.readText();w&&h.dispatch(h.state.tr.insertText(w));}catch{}break;case "delete":{let{from:w,to:A}=h.state.selection;w!==A&&h.dispatch(h.state.tr.deleteRange(w,A));break}case "selectAll":h.dispatch(h.state.tr.setSelection(TextSelection.create(h.state.doc,0,h.state.doc.content.size)));break;case "addRowAbove":Hr(h.state,h.dispatch);break;case "addRowBelow":wo(h.state,h.dispatch);break;case "deleteRow":Nr(h.state,h.dispatch);break;case "addColumnLeft":zr(h.state,h.dispatch);break;case "addColumnRight":vo(h.state,h.dispatch);break;case "deleteColumn":Or(h.state,h.dispatch);break;case "addComment":{let{from:w,to:A}=h.state.selection;if(w===A)break;let O=Xf(yn.current,Un.current,w);jt({from:w,to:A});let j=h.state.schema.marks.comment.create({commentId:Zr}),q=h.state.tr.addMark(w,A,j);q.setSelection(TextSelection.create(q.doc,A)),h.dispatch(q),tn(O),ut(true),gn(true),Ft(null);break}}},[Le,Je]),jn=useCallback(y=>h=>{if(!ae.state||ct)return;let w={...ae.state,package:{...ae.state.package,document:{...ae.state.package.document,finalSectionProperties:{...ae.state.package.document.finalSectionProperties,[y]:h}}}};ke(w);},[ae.state,ct,ke]),Sm=useMemo(()=>jn("marginLeft"),[jn]),km=useMemo(()=>jn("marginRight"),[jn]),Cm=useMemo(()=>jn("marginTop"),[jn]),Tm=useMemo(()=>jn("marginBottom"),[jn]),wm=useCallback(y=>{if(!ae.state||ct)return;let h={...ae.state,package:{...ae.state.package,document:{...ae.state.package.document,finalSectionProperties:{...ae.state.package.document.finalSectionProperties,...y}}}};ke(h);},[ae.state,ct,ke]),vm=useCallback(y=>{let h=Le();h&&sa(y)(h.state,h.dispatch);},[Le]),Rm=useCallback(y=>{let h=Le();h&&la(y)(h.state,h.dispatch);},[Le]),Em=useCallback(y=>{let h=Le();h&&(y<0?Ar(-y,true)(h.state,h.dispatch):Ar(y,false)(h.state,h.dispatch));},[Le]),Pm=useCallback(y=>{let h=Le();h&&fa(y)(h.state,h.dispatch);},[Le]),Ho=yn.current;useEffect(()=>{if(!Ho)return;let y=()=>{let h=Ve.current?.getLayout();if(!h||h.pages.length===0)return;let w=Ho.scrollTop,A=h.pages.length,O=24,j=24,q=w+Ho.clientHeight/2,X=j,fe=1;for(let be=0;be<h.pages.length;be++){let Fe=h.pages[be].size.h,Qe=X+Fe;if(q<Qe){fe=be+1;break}X=Qe+O,fe=be+2;}fe=Math.min(fe,A),ri({currentPage:fe,totalPages:A,visible:true}),go.current&&clearTimeout(go.current),go.current=setTimeout(()=>{ri(be=>({...be,visible:false}));},600);};return Ho.addEventListener("scroll",y,{passive:true}),()=>{Ho.removeEventListener("scroll",y),go.current&&clearTimeout(go.current);}},[Ho]);let ac=useCallback(async y=>{if(!Vn.current)return null;try{let h=Vn.current.getDocument(),w=Ve.current?.getDocument();w?.package?.document&&(h.package.document.content=w.package.document.content),h.package.document.comments=bt,hk(h.package.document.content,bt),bk(h.package.document.content,bt);let A=y?.selective!==!1,O=Ve.current?.getView(),j;if(A&&O){let X=O.state,fe=new Set(bt.map(Fe=>Fe.id)),be=bt.some(Fe=>Fe.parentId!=null&&fe.has(Fe.parentId));j={selective:{changedParaIds:Ku(X),structuralChange:Gu(X)||be,hasUntrackedChanges:Yu(X)}};}let q=await Vn.current.toBuffer(j);return O&&O.dispatch(qu(O.state)),o?.(q),q}catch(h){return s?.(h instanceof Error?h:new Error("Failed to save document")),null}},[o,s,bt]),Mm=useCallback(y=>{s?.(y);},[s]),ui=useCallback(()=>{let y=an.current?.querySelector(".paged-editor__pages");if(!y){window.print(),J?.();return}let h=window.open("","_blank");if(!h){window.print(),J?.();return}let w=[];for(let O of Array.from(document.styleSheets))try{for(let j of Array.from(O.cssRules))j instanceof CSSFontFaceRule&&w.push(j.cssText);}catch{}let A=y.cloneNode(true);A.style.cssText="display: block; margin: 0; padding: 0;";for(let O of Array.from(A.querySelectorAll(".layout-page"))){let j=O;j.style.boxShadow="none",j.style.margin="0";}h.document.write(`<!DOCTYPE html>
|
|
19
|
+
<html><head><title>Print</title>
|
|
20
|
+
<style>
|
|
21
|
+
${w.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>${A.outerHTML}</body></html>`),h.document.close(),h.onload=()=>{h.print(),h.close();},setTimeout(()=>{h.closed||(h.print(),h.close());},1e3),J?.();},[J]),$t=useRef(null),Im=useCallback((y,h)=>{if(!ae.state||!y.trim())return $t.current=null,null;let w=j(ae.state,y,h),A={matches:w,totalCount:w.length,currentIndex:0};return $t.current=A,ft.setMatches(w,0),w.length>0&&an.current&&l$1(an.current,w[0]),A},[ae.state,ft]),Fm=useCallback(()=>{if(!$t.current||$t.current.matches.length===0)return null;let y=ft.goToNextMatch(),h=$t.current.matches[y];return h&&an.current&&l$1(an.current,h),h||null},[ft]),Lm=useCallback(()=>{if(!$t.current||$t.current.matches.length===0)return null;let y=ft.goToPreviousMatch(),h=$t.current.matches[y];return h&&an.current&&l$1(an.current,h),h||null},[ft]),Bm=useCallback(y=>{if(!ae.state||!$t.current||$t.current.matches.length===0)return false;let h=$t.current.matches[$t.current.currentIndex];if(!h)return false;try{let w=a$1(ae.state,{type:"replaceText",range:{start:{paragraphIndex:h.paragraphIndex,offset:h.startOffset},end:{paragraphIndex:h.paragraphIndex,offset:h.endOffset}},text:y});return ke(w),!0}catch(w){return console.error("Replace failed:",w),false}},[ae.state,ke]),Am=useCallback((y,h,w)=>{if(!ae.state||!y.trim())return 0;let A=j(ae.state,y,w);if(A.length===0)return 0;let O=ae.state,j$1=[...A].sort((q,X)=>q.paragraphIndex!==X.paragraphIndex?X.paragraphIndex-q.paragraphIndex:X.startOffset-q.startOffset);for(let q of j$1)try{O=a$1(O,{type:"replaceText",range:{start:{paragraphIndex:q.paragraphIndex,offset:q.startOffset},end:{paragraphIndex:q.paragraphIndex,offset:q.endOffset}},text:h});}catch(X){console.error("Replace failed for match:",q,X);}return ke(O),$t.current=null,ft.setMatches([],0),A.length},[ae.state,ke,ft]);useImperativeHandle(xe,()=>({getAgent:()=>Vn.current,getDocument:()=>ae.state,getEditorRef:()=>Ve.current,save:ac,setZoom:y=>pe(h=>({...h,zoom:y})),getZoom:()=>re.zoom,focus:()=>{Ve.current?.focus();},getCurrentPage:()=>Bn.currentPage,getTotalPages:()=>Bn.totalPages,scrollToPage:y=>{},openPrintPreview:ui,print:ui,loadDocument:le,loadDocumentBuffer:Se}),[ae.state,re.zoom,Bn,ac,ui,le,Se]);let{headerContent:pi,footerContent:fi,firstPageHeaderContent:mi,firstPageFooterContent:gi}=useMemo(()=>{if(!ae.state?.package)return {headerContent:null,footerContent:null,firstPageHeaderContent:null,firstPageFooterContent:null};let y=ae.state.package,h=y.document?.finalSectionProperties,w=y.headers,A=y.footers,O=null,j=null,q=null,X=null;if(w&&h?.headerReferences){let fe=h.headerReferences.find(Fe=>Fe.type==="default");fe?.rId&&(O=w.get(fe.rId)??null);let be=h.headerReferences.find(Fe=>Fe.type==="first");be?.rId&&(q=w.get(be.rId)??null);}if(A&&h?.footerReferences){let fe=h.footerReferences.find(Fe=>Fe.type==="default");fe?.rId&&(j=A.get(fe.rId)??null);let be=h.footerReferences.find(Fe=>Fe.type==="first");be?.rId&&(X=A.get(be.rId)??null);}return h?.titlePg||(!O&&q&&(O=q),!j&&X&&(j=X)),{headerContent:O,footerContent:j,firstPageHeaderContent:q,firstPageFooterContent:X}},[ae.state]),Dm=useCallback((y,h)=>{let A=ae.state?.package?.document?.finalSectionProperties?.titlePg===true&&(h??1)===1,O=A?y==="header"?mi:gi:y==="header"?pi:fi;if(lt(A),O){Ye(y);return}if(!ae.state?.package)return;let j=ae.state.package,q=j.document?.finalSectionProperties;if(!q)return;let X=A?"first":"default",fe=`rId_new_${y}_${X}`,be={type:y==="header"?"header":"footer",hdrFtrType:X,content:[{type:"paragraph",content:[]}]},Fe=y==="header"?"headers":"footers",Qe=new Map(j[Fe]??[]);Qe.set(fe,be);let et=y==="header"?"headerReferences":"footerReferences",We=q[et]??[],Kt={type:X,rId:fe},Tt={...ae.state,package:{...j,[Fe]:Qe,document:j.document?{...j.document,finalSectionProperties:{...q,[et]:[...We,Kt]}}:j.document}};he(Tt),Ye(y);},[pi,fi,mi,gi,ae,he]),Rs=useCallback(y=>{if(!Ie||!ae.state?.package){Ye(null);return}let h=ae.state.package,w=h.document?.finalSectionProperties,A=Ie==="header"?w?.headerReferences:w?.footerReferences,O=Ge?"first":"default",j=A?.find(fe=>fe.type===O)??A?.find(fe=>fe.type==="default")??A?.find(fe=>fe.type==="first")??A?.[0],q=Ie==="header"?"headers":"footers",X=h[q];if(j?.rId&&X){let fe=X.get(j.rId),be={type:Ie,hdrFtrType:j.type,...fe,content:y},Fe=new Map(X);Fe.set(j.rId,be);let Qe={...ae.state,package:{...h,[q]:Fe}};he(Qe);}Ye(null);},[Ie,ae,he]),Hm=useCallback(()=>{if(!Ie)return;let y=Bt.current?.getView();if(y){let h=Ui(y.state.doc);Rs(h);}else Ye(null);},[Ie,Rs]),Nm=useCallback(()=>{if(!Ie||!ae.state?.package){Ye(null);return}let y=ae.state.package,h=y.document?.finalSectionProperties,w=Ie==="header"?"headerReferences":"footerReferences",A=Ie==="header"?"headers":"footers",O=h?.[w],j=Ge?"first":"default",q=O?.find(X=>X.type===j)??O?.find(X=>X.type==="default")??O?.find(X=>X.type==="first")??O?.[0];if(q?.rId){let X=new Map(y[A]??[]);X.delete(q.rId);let fe=(O??[]).filter(Fe=>Fe.rId!==q.rId),be={...ae.state,package:{...y,[A]:X,document:y.document?{...y.document,finalSectionProperties:{...h,[w]:fe}}:y.document}};he(be);}Ye(null);},[Ie,ae,he]),zm=useCallback(y=>{let h=an.current?.querySelector(".paged-editor__pages");if(!h)return null;let w=y==="header"?".layout-page-header":".layout-page-footer";return h.querySelector(w)},[]),hi={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg-subtle)",...B},Om={display:"flex",flex:1,minHeight:0,minWidth:0,flexDirection:"row"},Sn=useRef({});Sn.current={onCommentReply:(y,h)=>{let w=Ql(h,r,y),A=bt.find(O=>O.id===y);Rt(O=>[...O,w]),A&&Y?.(w,A);},onCommentResolve:y=>{let h=bt.find(w=>w.id===y);Rt(w=>w.map(A=>A.id===y?{...A,done:true}:A)),h&&Ee?.({...h,done:true});},onCommentUnresolve:y=>{Rt(h=>h.map(w=>w.id===y?{...w,done:void 0}:w));},onCommentDelete:y=>{let h=bt.find(A=>A.id===y);Rt(A=>A.filter(O=>O.id!==y&&O.parentId!==y));let w=Ve.current?.getView();if(w){let A=w.state.schema.marks.comment?.create({commentId:y});if(A){let O=w.state.tr.removeMark(0,w.state.doc.content.size,A);O.docChanged&&w.dispatch(O);}}h&&ce?.(h);},onAddComment:y=>{let h=Ql(y,r),w=Ve.current?.getView();if(w&&Zt){let{from:A,to:O}=Zt,j=w.state.schema.marks.comment.create({commentId:Zr}),q=w.state.schema.marks.comment.create({commentId:h.id}),X=w.state.tr.removeMark(A,O,j).addMark(A,O,q);w.dispatch(X);}Rt(A=>[...A,h]),gn(false),jt(null),tn(null),me?.(h);},onCancelAddComment:()=>{let y=Ve.current?.getView();if(y&&Zt){let{from:h,to:w}=Zt,A=y.state.schema.marks.comment.create({commentId:Zr});y.dispatch(y.state.tr.removeMark(h,w,A));}gn(false),jt(null),tn(null);},onAcceptChange:(y,h)=>{let w=Ve.current?.getView();w&&(kp(y,h)(w.state,w.dispatch),Ln());},onRejectChange:(y,h)=>{let w=Ve.current?.getView();w&&(Cp(y,h)(w.state,w.dispatch),Ln());},onTrackedChangeReply:(y,h)=>{Rt(w=>[...w,Ql(h,r,y)]);}};let $m=useMemo(()=>({onCommentReply:(...y)=>Sn.current.onCommentReply?.(...y),onCommentResolve:(...y)=>Sn.current.onCommentResolve?.(...y),onCommentUnresolve:(...y)=>Sn.current.onCommentUnresolve?.(...y),onCommentDelete:(...y)=>Sn.current.onCommentDelete?.(...y),onAddComment:(...y)=>Sn.current.onAddComment?.(...y),onCancelAddComment:(...y)=>Sn.current.onCancelAddComment?.(...y),onAcceptChange:(...y)=>Sn.current.onAcceptChange?.(...y),onRejectChange:(...y)=>Sn.current.onRejectChange?.(...y),onTrackedChangeReply:(...y)=>Sn.current.onTrackedChangeReply?.(...y)}),[]),sc=kd({comments:bt,trackedChanges:ys,callbacks:$m,showResolved:Be,isAddingComment:Be?mn:false,addCommentYPosition:hn}),Es=useMemo(()=>{let y=[];return Be&&y.push(...sc),F&&y.push(...F),y},[Be,sc,F]),Ps=Es.length>0,No=useMemo(()=>{let y=new Set;for(let h of bt)h.done&&h.parentId==null&&y.add(h.id);return y},[bt]),_m=useMemo(()=>{if(!Xt?.startsWith("comment-"))return No;let y=parseInt(Xt.slice(8),10);if(isNaN(y)||!No.has(y))return No;let h=new Set(No);return h.delete(y),h},[No,Xt]),Wm={flex:1,minHeight:0,minWidth:0,overflow:"auto",position:"relative"};if(re.isLoading)return jsx("div",{className:`ep-root docx-editor docx-editor-loading ${S}`,style:hi,"data-testid":"docx-editor",children:E$1||jsx(Ap,{})});if(re.parseError)return jsx("div",{className:`ep-root docx-editor docx-editor-error ${S}`,style:hi,"data-testid":"docx-editor",children:jsx(Hp,{message:re.parseError})});if(!ae.state)return jsx("div",{className:`ep-root docx-editor docx-editor-empty ${S}`,style:hi,"data-testid":"docx-editor",children:v||jsx(Dp,{})});let Vm=jsxs(Fragment,{children:[jsx(C,{}),jsx(A,{onClick:()=>ut(!Be),active:Be,title:"Toggle comments sidebar",ariaLabel:"Toggle comments sidebar",children:jsx(d,{name:"comment",size:20})}),jsx(C,{}),jsx(gk,{mode:zt,onModeChange:y=>{nn(y),y==="suggesting"&&ut(true);}}),T]});return jsx(td,{children:jsx(Ri,{onError:Mm,children:jsxs("div",{ref:an,className:`ep-root docx-editor ${S}`,style:hi,"data-testid":"docx-editor",children:[jsx("div",{style:Om,children:jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[d$1&&!x&&jsxs("div",{ref:Cs,className:"z-50 flex flex-col gap-0 bg-white shadow-sm flex-shrink-0",children:[jsxs(_t,{currentFormatting:re.selectionFormatting,onFormat:ws,onUndo:Ts,onRedo:ii,canUndo:true,canRedo:true,disabled:ct,documentStyles:ae.state?.package.styles?.styles,theme:ae.state?.package.theme||u,showPrintButton:P,onPrint:ui,showZoomControl:c$1,zoom:re.zoom,onZoomChange:Sr,onRefocusEditor:Je,onInsertTable:Ue,showTableInsert:true,onInsertImage:ai,onInsertPageBreak:mt,onInsertTOC:yt,imageContext:re.pmImageContext,onImageWrapType:li,onImageTransform:ci,onOpenImageProperties:yr,onPageSetup:K,tableContext:re.pmTableContext,onTableAction:ho,children:[jsxs(_t.TitleBar,{children:[oe&&jsx(_t.Logo,{children:oe()}),ee!==void 0&&jsx(_t.DocumentName,{value:ee,onChange:_,editable:G}),ne&&jsx(_t.TitleBarRight,{children:ne()}),jsx(_t.MenuBar,{})]}),jsx(_t.FormattingBar,{children:Vm})]}),m$2&&jsx("div",{className:"flex justify-center px-5 py-1 overflow-x-auto flex-shrink-0 bg-doc-bg",style:{paddingRight:Ps?`calc(20px + ${352}px)`:void 0,transition:"padding 0.2s ease"},children:jsx(E,{sectionProps:ae.state?.package.document?.finalSectionProperties,zoom:re.zoom,unit:b,editable:!ct,onLeftMarginChange:Sm,onRightMarginChange:km,indentLeft:re.paragraphIndentLeft,indentRight:re.paragraphIndentRight,onIndentLeftChange:vm,onIndentRightChange:Rm,showFirstLineIndent:true,firstLineIndent:re.paragraphFirstLineIndent,hangingIndent:re.paragraphHangingIndent,onFirstLineIndentChange:Em,tabStops:re.paragraphTabs,onTabStopRemove:Pm})})]}),jsx("div",{ref:yn,style:Wm,children:jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative"},children:jsxs("div",{ref:Un,style:{position:"relative",flex:1,minWidth:0},onMouseDown:y=>{y.target===y.currentTarget&&(y.preventDefault(),Ve.current?.focus());},onContextMenu:xr,children:[m$2&&!x&&jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:10,paddingTop:48},children:jsx(Rd,{sectionProps:ae.state?.package.document?.finalSectionProperties,zoom:re.zoom,unit:b,editable:!ct,onTopMarginChange:Cm,onBottomMarginChange:Tm})}),Xt&&Xt.startsWith("comment-")&&jsx("style",{children:`.paged-editor__pages [data-comment-id="${Xt.replace("comment-","")}"] { background-color: rgba(255, 212, 0, 0.35) !important; border-bottom: 2px solid rgba(255, 212, 0, 0.7) !important; }`}),Xt?.startsWith("tc-")&&jsx("style",{children:`
|
|
30
|
+
.paged-editor__pages .docx-insertion[data-revision-id="${Xt.split("-")[1]}"] { background-color: rgba(52, 168, 83, 0.2) !important; border-bottom: 2px solid #2e7d32 !important; }
|
|
31
|
+
.paged-editor__pages .docx-deletion[data-revision-id="${Xt.split("-")[1]}"] { background-color: rgba(211, 47, 47, 0.2) !important; text-decoration-thickness: 2px !important; }
|
|
32
|
+
`}),jsx(Gf,{ref:Ve,document:ae.state,styles:ae.state?.package.styles,theme:ae.state?.package.theme||u,sectionProperties:ae.state?.package.document?.finalSectionProperties,headerContent:pi,footerContent:fi,firstPageHeaderContent:mi,firstPageFooterContent:gi,onHeaderFooterDoubleClick:Dm,hfEditMode:Ie,onBodyClick:Hm,zoom:re.zoom,readOnly:ct,extensionManager:Ss,onDocumentChange:ke,onSelectionChange:(y,h)=>{let w=Ve.current?.getView();if(w){let A=er(w.state);Te(A);}else Te(null);},externalPlugins:Wn,onReady:y=>{L?.(y.getView());},onRenderedDomContextReady:k,pluginOverlays:M,onHyperlinkClick:xn,onContextMenu:ym,commentsSidebarOpen:Ps,onAnchorPositionsChange:dr,resolvedCommentIds:_m,scrollContainerRef:yn,sidebarOverlay:jsxs(Fragment,{children:[Es.length>0&&jsx(dd,{items:Es,anchorPositions:Lo,renderedDomContext:H??null,pageWidth:(()=>{let y=ae.state?.package?.document?.finalSectionProperties;return y?.pageWidth?Math.round(y.pageWidth/15):816})(),zoom:re.zoom,editorContainerRef:yn,onExpandedItemChange:cr}),jsx(ud,{comments:bt,anchorPositions:Lo,zoom:re.zoom,pageWidth:(()=>{let y=ae.state?.package?.document?.finalSectionProperties;return y?.pageWidth?Math.round(y.pageWidth/15):816})(),sidebarOpen:Ps,resolvedCommentIds:No,onMarkerClick:()=>{ut(true);}})]})}),on!=null&&!mn&&!ct&&jsx(c,{content:"Add comment",side:"bottom",delayMs:300,children:jsx("button",{type:"button",onMouseDown:y=>{y.preventDefault(),y.stopPropagation();let h=Ve.current?.getView();if(h){let{from:w,to:A}=h.state.selection;if(w!==A){jt({from:w,to:A});let O=h.state.schema.marks.comment.create({commentId:Zr}),j=h.state.tr.addMark(w,A,O);j.setSelection(TextSelection.create(j.doc,A)),h.dispatch(j);}}tn(on.top),ut(true),gn(true),Ft(null);},style:{position:"absolute",top:on.top,left:on.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:jsx(d,{name:"add_comment",size:16})})}),jsx(Z,{isOpen:pt.isOpen,position:pt.position,hasSelection:pt.hasSelection,isEditable:!ct,items:rc,onAction:ic,onClose:()=>Ct(y=>({...y,isOpen:false}))}),Ie&&(()=>{let y=Ge?Ie==="header"?mi:gi:Ie==="header"?pi:fi;if(!y)return null;let h=zm(Ie),w=Un.current;return !h||!w?null:jsx(Ep,{ref:Bt,headerFooter:y,position:Ie,styles:ae.state?.package.styles,targetElement:h,parentElement:w,onSave:Rs,onClose:()=>Ye(null),onSelectionChange:Te,onRemove:Nm})})()]})})}),Bn.totalPages>1&&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:Bn.visible?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:[Bn.currentPage," of ",Bn.totalPages]}),qe&&jsx(id,{headings:He,onHeadingClick:Ao,onClose:()=>ht(false),topOffset:ni}),D&&!qe&&jsx("button",{className:"docx-outline-nav",onClick:sn,onMouseDown:y=>y.stopPropagation(),title:"Show document outline",style:{position:"absolute",left:48,top:ni+12,zIndex:20,background:"transparent",border:"none",borderRadius:"50%",padding:6,cursor:"pointer",display:"flex",alignItems:"center"},children:jsx(d,{name:"format_list_bulleted",size:20,style:{color:"#444746"}})})]})}),jsx(Lp,{data:Q,onNavigate:yo,onCopy:xo,onEdit:vs,onRemove:hm,onClose:bm,readOnly:ct}),jsx(Z,{isOpen:pt.isOpen,position:pt.position,hasSelection:pt.hasSelection,isEditable:!ct,items:rc,onAction:ic,onClose:xm}),jsx(Toaster,{position:"bottom-right"}),jsxs(Suspense,{fallback:null,children:[ft.state.isOpen&&jsx(ak,{isOpen:ft.state.isOpen,onClose:ft.close,onFind:Im,onFindNext:Fm,onFindPrevious:Lm,onReplace:Bm,onReplaceAll:Am,initialSearchText:ft.state.searchText,replaceMode:ft.state.replaceMode,currentResult:$t.current}),C$1.state.isOpen&&jsx(sk,{isOpen:C$1.state.isOpen,onClose:C$1.close,onSubmit:di,onRemove:C$1.state.isEditing?bo:void 0,initialData:C$1.state.initialData,selectedText:C$1.state.selectedText,isEditing:C$1.state.isEditing}),de&&jsx(lk,{isOpen:de,onClose:()=>Pe(false),onApply:y=>{let h=Le();h&&_r(y)(h.state,h.dispatch);},currentProps:re.pmTableContext?.table?.attrs}),De&&jsx(ck,{isOpen:De,onClose:()=>je(false),onApply:br}),Ne&&jsx(dk,{isOpen:Ne,onClose:()=>Ke(false),onApply:Do,currentData:re.pmImageContext?{alt:re.pmImageContext.alt??void 0,borderWidth:re.pmImageContext.borderWidth??void 0,borderColor:re.pmImageContext.borderColor??void 0,borderStyle:re.pmImageContext.borderStyle??void 0}:void 0}),W&&jsx(pk,{isOpen:W,onClose:()=>U(false),onApply:wm,currentProps:ae.state?.package.document?.finalSectionProperties}),ze&&jsx(uk,{isOpen:ze,onClose:()=>ve(false),onApply:ln,footnotePr:ae.state?.package.document?.finalSectionProperties?.footnotePr,endnotePr:ae.state?.package.document?.finalSectionProperties?.endnotePr})]}),jsx("input",{ref:mr,type:"file",accept:"image/*",style:{display:"none"},onChange:si})]})})})});function xI(e,t,n={}){return new Promise((o,r)=>{let i=Qf.createRef(),a=null;try{a=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=Qf.createElement(Jf,{...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 PI(e,t={}){let{storageKey:n,interval:o,enabled:r$1=true,maxAge:i,onSave:a,onError:s,onRecoveryAvailable:l,saveOnChange:u,debounceDelay:d}=t,c=useMemo(()=>new r({storageKey:n,interval:o,maxAge:i,saveOnChange:u,debounceDelay:d,onSave:a,onError:s,onRecoveryAvailable:l}),[n]);useEffect(()=>{r$1?(c.enable(),c.startInterval()):c.disable();},[c,r$1]),useEffect(()=>{c.onDocumentChanged(e??null);},[c,e]),useEffect(()=>()=>{c.destroy();},[c]);let p=useSyncExternalStore(c.subscribe,c.getSnapshot),f=useCallback(()=>c.save(),[c]),m=useCallback(()=>c.clear(),[c]),b=useCallback(()=>c.getRecoveryData(),[c]),g=useCallback(()=>c.acceptRecovery(),[c]),x=useCallback(()=>c.dismissRecovery(),[c]),T=useCallback(()=>c.enable(),[c]),S=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 Tk=1,em=.25,tm=4,wk=.1,pn=[.25,.5,.75,1,1.25,1.5,2,3,4];function nm(e,t,n){return Math.max(t,Math.min(n,e))}function om(e){return Math.round(e*100)/100}function vk(e){let t=pn[0],n=Math.abs(e-t);for(let o of pn){let r=Math.abs(e-o);r<n&&(n=r,t=o);}return t}function Rk(e){for(let t of pn)if(t>e+.01)return t;return pn[pn.length-1]}function Ek(e){for(let t=pn.length-1;t>=0;t--)if(pn[t]<e-.01)return pn[t];return pn[0]}function FI(e={}){let{initialZoom:t=Tk,minZoom:n=em,maxZoom:o=tm,zoomStep:r=wk,enabled:i=true,containerRef:a,onZoomChange:s,enableKeyboardShortcuts:l=true,preventDefault:u=true}=e,[d,c]=useState(t),p=useRef(d);useEffect(()=>{p.current=d;},[d]);let f=useCallback(v=>{let E=om(nm(v,n,o));E!==p.current&&(c(E),s?.(E));},[n,o,s]),m=useCallback(()=>{f(p.current+r);},[r,f]),b=useCallback(()=>{f(p.current-r);},[r,f]),g=useCallback(()=>{f(t);},[t,f]),x=useCallback(()=>{f(1);},[f]),T=useCallback((v,E)=>{if(E>0){let V=v/E;f(V);}},[f]),S=useCallback(v=>{if(!i||!(v.ctrlKey||v.metaKey))return;u&&v.preventDefault();let V=v.deltaY;V<0?f(p.current+r):V>0&&f(p.current-r);},[i,u,r,f]),B=useCallback(v=>{if(!(!i||!l||!(v.ctrlKey||v.metaKey))){if(v.key==="0"){v.preventDefault(),x();return}if(v.key==="+"||v.key==="="){v.preventDefault(),m();return}if(v.key==="-"){v.preventDefault(),b();return}}},[i,l,m,b,x]);return useEffect(()=>{if(!i)return;let v=a?.current;if(v)return v.addEventListener("wheel",S,{passive:false}),()=>{v.removeEventListener("wheel",S);}},[i,a,S]),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 LI(){return [...pn]}function BI(e){return vk(e)}function AI(e){return Rk(e)}function DI(e){return Ek(e)}function HI(e){return `${Math.round(e*100)}%`}function NI(e){let t=e.match(/(\d+(\.\d+)?)/);if(t){let n=parseFloat(t[1]);if(!isNaN(n))return n/100}return null}function zI(e){return pn.some(t=>Math.abs(t-e)<.01)}function OI(e,t=em,n=tm){return om(nm(e,t,n))}var sr={backgroundColor:"rgba(26, 115, 232, 0.3)",borderRadius:0,zIndex:0,opacity:1,mixBlendMode:"multiply"},_I={backgroundColor:"rgba(0, 120, 215, 0.4)",borderColor:"rgba(0, 120, 215, 0.6)",borderRadius:1,zIndex:0,opacity:1},WI={backgroundColor:"--docx-selection-bg",borderColor:"--docx-selection-border",textColor:"--docx-selection-text"};function rm(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 Pk(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 oc(e){let t=rm(e);return Pk(t)}function VI(e,t=sr){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 UI(e,t=sr){let n=t.backgroundColor;return `
|
|
33
|
+
${e}::selection,
|
|
34
|
+
${e} *::selection {
|
|
35
|
+
background-color: ${n} !important;
|
|
36
|
+
color: inherit !important;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
${e}::-moz-selection,
|
|
40
|
+
${e} *::-moz-selection {
|
|
41
|
+
background-color: ${n} !important;
|
|
42
|
+
color: inherit !important;
|
|
43
|
+
}
|
|
44
|
+
`}function im(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function am(){let e=window.getSelection();return e?e.toString():""}function sm(e){let t=window.getSelection();if(!t||t.rangeCount===0)return false;let n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)}function jI(){let e=window.getSelection();return !e||e.rangeCount===0?null:e.getRangeAt(0).getBoundingClientRect()}function KI(e,t,n,o,r){try{let i=document.createRange();return i.setStart(t,n),i.setEnd(o,r),i}catch{return null}}function GI(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e));}function YI(){let e=window.getSelection();e&&e.removeAllRanges();}function Mk(){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 qI(){let e=window.getSelection();if(!e||e.rangeCount===0||!Mk())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 fo=null;function lm(e=sr){Ik();let t=`
|
|
45
|
+
/* DOCX Editor Selection Highlighting */
|
|
46
|
+
|
|
47
|
+
/* Base selection style for all editable content */
|
|
48
|
+
.docx-editor [contenteditable="true"]::selection,
|
|
49
|
+
.docx-editor [contenteditable="true"] *::selection,
|
|
50
|
+
.docx-run-editable::selection,
|
|
51
|
+
.docx-run-editable *::selection {
|
|
52
|
+
background-color: ${e.backgroundColor} !important;
|
|
53
|
+
color: inherit !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Firefox selection */
|
|
57
|
+
.docx-editor [contenteditable="true"]::-moz-selection,
|
|
58
|
+
.docx-editor [contenteditable="true"] *::-moz-selection,
|
|
59
|
+
.docx-run-editable::-moz-selection,
|
|
60
|
+
.docx-run-editable *::-moz-selection {
|
|
61
|
+
background-color: ${e.backgroundColor} !important;
|
|
62
|
+
color: inherit !important;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Ensure selection is visible against all backgrounds */
|
|
66
|
+
.docx-run-highlighted::selection,
|
|
67
|
+
.docx-run-highlighted *::selection {
|
|
68
|
+
/* For highlighted (yellow background) text, use darker selection */
|
|
69
|
+
background-color: rgba(26, 115, 232, 0.5) !important;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.docx-run-highlighted::-moz-selection,
|
|
73
|
+
.docx-run-highlighted *::-moz-selection {
|
|
74
|
+
background-color: rgba(26, 115, 232, 0.5) !important;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* Selection in dark text */
|
|
78
|
+
.docx-run-dark-bg::selection,
|
|
79
|
+
.docx-run-dark-bg *::selection {
|
|
80
|
+
/* Use lighter selection for dark backgrounds */
|
|
81
|
+
background-color: rgba(100, 181, 246, 0.5) !important;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.docx-run-dark-bg::-moz-selection,
|
|
85
|
+
.docx-run-dark-bg *::-moz-selection {
|
|
86
|
+
background-color: rgba(100, 181, 246, 0.5) !important;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Programmatic highlight class */
|
|
90
|
+
.docx-selection-highlight {
|
|
91
|
+
background-color: ${e.backgroundColor};
|
|
92
|
+
${e.borderRadius?`border-radius: ${e.borderRadius}px;`:""}
|
|
93
|
+
${e.mixBlendMode?`mix-blend-mode: ${e.mixBlendMode};`:""}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* Find/replace highlight */
|
|
97
|
+
.docx-find-highlight {
|
|
98
|
+
background-color: rgba(255, 235, 59, 0.5);
|
|
99
|
+
border-radius: 2px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.docx-find-highlight-current {
|
|
103
|
+
background-color: rgba(255, 152, 0, 0.6);
|
|
104
|
+
border-radius: 2px;
|
|
105
|
+
outline: 2px solid rgba(255, 152, 0, 0.8);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* AI action selection preview */
|
|
109
|
+
.docx-ai-selection-preview {
|
|
110
|
+
background-color: rgba(156, 39, 176, 0.2);
|
|
111
|
+
border-bottom: 2px dashed rgba(156, 39, 176, 0.6);
|
|
112
|
+
}
|
|
113
|
+
`;fo=document.createElement("style"),fo.id="docx-selection-styles",fo.textContent=t,document.head.appendChild(fo);}function Ik(){fo&&(fo.remove(),fo=null);let e=document.getElementById("docx-selection-styles");e&&e.remove();}function cm(){return fo!==null||document.getElementById("docx-selection-styles")!==null}function XI(e,t,n=true){return ()=>{if(!e){t([]);return}let o=n?oc(e):rm(e);t(o);}}function nF(e){let{containerRef:t,enabled:n=true,config:o=sr,useOverlay:r=false,debounceMs:i=16,onSelectionChange:a}=e,[s,l]=useState(false),[u,d]=useState(""),[c,p]=useState([]),[f,m]=useState(false),b=useRef(null),g=useRef(0),x=useCallback(()=>{let v=t.current,E=im(),V=am(),D=v?sm(v):false;if(l(E),d(V),m(D),r&&D){let P=oc(v);p(P);}else p([]);a&&a(E&&D,V);},[t,r,a]),T=useCallback(()=>{let v=performance.now();if(v-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=v,x();},[i,x]),S=useCallback(()=>{x();},[x]),B=useCallback(v=>({position:"absolute",left:`${v.left}px`,top:`${v.top}px`,width:`${v.width}px`,height:`${v.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 useEffect(()=>(n&&!cm()&&lm(o),()=>{}),[n,o]),useEffect(()=>{if(!n)return;let v=()=>{T();};return document.addEventListener("selectionchange",v),document.addEventListener("mouseup",v),x(),()=>{document.removeEventListener("selectionchange",v),document.removeEventListener("mouseup",v),b.current!==null&&clearTimeout(b.current);}},[n,T,x]),{hasSelection:s,selectedText:u,highlightRects:c,isSelectionInContainer:f,refresh:S,getOverlayStyle:B}}function oF(e,t=sr){return e.map((n,o)=>Qf.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 cF(e={}){let{onCopy:t,onCut:n,onPaste:o,cleanWordFormatting:r=true,editable:i=true,onError:a}=e,s=useRef(false),l=useRef(null),u=useCallback(async g=>{if(s.current)return false;s.current=true;try{let x=await M(g.runs,{onError:a});return x&&t?.(g),x}finally{s.current=false;}},[t,a]),d=useCallback(async g=>{if(s.current||!i)return false;s.current=true;try{let x=await M(g.runs,{onError:a});return x&&n?.(g),x}finally{s.current=false;}},[n,i,a]),c=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$1="",S="";for(let v of x)v.types.includes("text/html")&&(T$1=await(await v.getType("text/html")).text()),v.types.includes("text/plain")&&(S=await(await v.getType("text/plain")).text());g&&(T$1="");let B=T(T$1,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=useCallback(g=>{let x=F();if(!x)return;g.preventDefault();let T=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=useCallback(g=>{if(!i)return;let x=F();if(!x)return;g.preventDefault();let T=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=useCallback(g=>{if(!i)return;g.preventDefault();let x=S(g,{cleanWordFormatting:r});if(x){l.current=x;let T=g.shiftKey??false;o?.(x,T);}},[i,r,o]),b=useCallback(g=>{},[]);return {copy:u,cut:d,paste:c,handleCopy:p,handleCut:f,handlePaste:m,handleKeyDown:b,isProcessing:s.current,lastPastedContent:l.current}}var bs={position:"right",defaultSize:280,minSize:200,maxSize:500,resizable:true,collapsible:true,defaultCollapsed:false},mm=I,gm=`
|
|
114
|
+
.plugin-host {
|
|
115
|
+
display: flex;
|
|
116
|
+
width: 100%;
|
|
117
|
+
height: 100%;
|
|
118
|
+
overflow: visible;
|
|
119
|
+
position: relative;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.plugin-host-editor {
|
|
123
|
+
flex: 1;
|
|
124
|
+
display: flex;
|
|
125
|
+
flex-direction: column;
|
|
126
|
+
min-width: 0;
|
|
127
|
+
overflow: visible;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
.plugin-panels-left,
|
|
132
|
+
.plugin-panels-right {
|
|
133
|
+
display: flex;
|
|
134
|
+
flex-direction: column;
|
|
135
|
+
flex-shrink: 0;
|
|
136
|
+
background: #f8f9fa;
|
|
137
|
+
border-color: #e9ecef;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.plugin-panels-left {
|
|
141
|
+
border-right: 1px solid #e9ecef;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.plugin-panels-right {
|
|
145
|
+
border-left: 1px solid #e9ecef;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.plugin-panels-bottom {
|
|
149
|
+
border-top: 1px solid #e9ecef;
|
|
150
|
+
background: #f8f9fa;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.plugin-panel {
|
|
154
|
+
position: relative;
|
|
155
|
+
display: flex;
|
|
156
|
+
flex-direction: column;
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
transition: width 0.2s ease, height 0.2s ease;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.plugin-panel.collapsed {
|
|
162
|
+
overflow: visible;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.plugin-panel-toggle {
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
gap: 4px;
|
|
169
|
+
padding: 6px 8px;
|
|
170
|
+
background: transparent;
|
|
171
|
+
border: none;
|
|
172
|
+
cursor: pointer;
|
|
173
|
+
font-size: 12px;
|
|
174
|
+
color: #6c757d;
|
|
175
|
+
white-space: nowrap;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.plugin-panel.collapsed .plugin-panel-toggle {
|
|
179
|
+
writing-mode: vertical-rl;
|
|
180
|
+
text-orientation: mixed;
|
|
181
|
+
flex-direction: column;
|
|
182
|
+
height: 100%;
|
|
183
|
+
padding: 8px 6px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.plugin-panel-toggle:hover {
|
|
187
|
+
background: #e9ecef;
|
|
188
|
+
color: #495057;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.plugin-panel-toggle-icon {
|
|
192
|
+
font-weight: bold;
|
|
193
|
+
font-size: 14px;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.plugin-panel.collapsed .plugin-panel-toggle-icon {
|
|
197
|
+
transform: rotate(90deg);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.plugin-panel-toggle-label {
|
|
201
|
+
font-weight: 500;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.plugin-panel-content {
|
|
205
|
+
flex: 1;
|
|
206
|
+
overflow: auto;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/* Right panel rendered inside viewport - scrolls with content */
|
|
210
|
+
.plugin-panel-in-viewport {
|
|
211
|
+
position: absolute;
|
|
212
|
+
top: 0;
|
|
213
|
+
/* Position is set dynamically via inline styles based on page edge */
|
|
214
|
+
width: 220px;
|
|
215
|
+
pointer-events: auto;
|
|
216
|
+
z-index: 10;
|
|
217
|
+
overflow: visible;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.plugin-panel-in-viewport.collapsed {
|
|
221
|
+
width: 32px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.plugin-panel-in-viewport .plugin-panel-toggle {
|
|
225
|
+
position: sticky;
|
|
226
|
+
top: 0;
|
|
227
|
+
background: rgba(255, 255, 255, 0.95);
|
|
228
|
+
border-radius: 4px;
|
|
229
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.plugin-panel-in-viewport-content {
|
|
233
|
+
overflow: visible;
|
|
234
|
+
position: relative;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/* Plugin overlay container for rendering highlights/decorations */
|
|
238
|
+
.plugin-overlays-container {
|
|
239
|
+
position: absolute;
|
|
240
|
+
top: 0;
|
|
241
|
+
left: 0;
|
|
242
|
+
right: 0;
|
|
243
|
+
bottom: 0;
|
|
244
|
+
pointer-events: none;
|
|
245
|
+
overflow: visible;
|
|
246
|
+
z-index: 5;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.plugin-overlay {
|
|
250
|
+
position: absolute;
|
|
251
|
+
top: 0;
|
|
252
|
+
left: 0;
|
|
253
|
+
right: 0;
|
|
254
|
+
bottom: 0;
|
|
255
|
+
pointer-events: none;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/* Individual overlay children manage their own pointer-events.
|
|
259
|
+
Do NOT set pointer-events: auto here \u2014 it overrides overlay containers
|
|
260
|
+
that need pointer-events: none to let clicks pass through to the editor. */
|
|
261
|
+
`,Nk=forwardRef(function({plugins:t,children:n,className:o=""},r){let[i,a]=useState(null),s=useRef(n.props);s.current=n.props;let[l,u]=useState(null),d=useMemo(()=>new J,[]),c=useSyncExternalStore(d.subscribe,d.getSnapshot),[p,f]=useState(()=>{let z=new Set;for(let N of t)({...bs,...N.panelConfig}).defaultCollapsed&&z.add(N.id);return z}),[m]=useState(()=>{let z=new Map;for(let N of t){let ue={...bs,...N.panelConfig};z.set(N.id,ue.defaultSize);}return z});useEffect(()=>{if(!i)return;let z=t.map(N=>({id:N.id,styles:N.styles,initialize:N.initialize,onStateChange:N.onStateChange,destroy:N.destroy}));return d.initialize(z,i),()=>{d.destroy();}},[d,i,t]),useEffect(()=>{let z=t.filter(N=>N.styles).map(N=>mm(N.id,N.styles));return ()=>z.forEach(N=>N())},[t]),useEffect(()=>{if(!i?.dom)return;let z=()=>{d.updateStates(i);},N=null,ue=()=>{N&&cancelAnimationFrame(N),N=requestAnimationFrame(z);};z();let me=i.dom;me.addEventListener("input",ue),me.addEventListener("focus",z),me.addEventListener("click",z);let Ee=i.dispatch.bind(i);return i.dispatch=ce=>{Ee(ce),ue();},()=>{me.removeEventListener("input",ue),me.removeEventListener("focus",z),me.removeEventListener("click",z),N&&cancelAnimationFrame(N),i.dispatch=Ee;}},[i,d]),useEffect(()=>mm("plugin-host-base",gm),[]);let b=useCallback(z=>{if(!i)return;if(i.coordsAtPos(z)){i.dom.scrollIntoView({block:"center",inline:"nearest"});let{state:ue}=i,me=ue.doc.resolve(Math.min(z,ue.doc.content.size)),Ee=ue.tr.setSelection(TextSelection.near(me));i.dispatch(Ee),i.focus();}},[i]),g=useCallback((z,N)=>{if(!i)return;let{state:ue}=i,me=ue.doc.content.size,Ee=Math.max(0,Math.min(z,me)),ce=Math.max(0,Math.min(N,me)),Y=ue.tr.setSelection(TextSelection.create(ue.doc,Ee,ce));i.dispatch(Y),i.focus();},[i]),x=useCallback(z=>d.getPluginState(z),[d]),T=useCallback((z,N)=>{d.setPluginState(z,N);},[d]),S=useCallback(()=>{i&&d.updateStates(i);},[i,d]);useImperativeHandle(r,()=>({getPluginState:x,setPluginState:T,getEditorView:()=>i,refreshPluginStates:S}),[x,T,i,S]);let B=useMemo(()=>{let z=[];for(let N of t)N.proseMirrorPlugins&&z.push(...N.proseMirrorPlugins);return z},[t]),v=useCallback(z=>{f(N=>{let ue=new Set(N);return ue.has(z)?ue.delete(z):ue.add(z),ue});},[]),[E,V]=useState(null);useEffect(()=>{if(!l){V(null);return}let z=()=>{let me=l.pagesContainer,Ee=me.querySelector(".layout-page");if(!Ee){V(null);return}let ce=l.getContainerOffset(),Y=Ee.getBoundingClientRect(),R=me.getBoundingClientRect(),L=(Y.right-R.left)/l.zoom,k=ce.x+L+5;V(k);};z();let N=()=>{requestAnimationFrame(z);};window.addEventListener("resize",N);let ue=new ResizeObserver(()=>{requestAnimationFrame(z);});return ue.observe(l.pagesContainer),()=>{window.removeEventListener("resize",N),ue.disconnect();}},[l]);let D=useMemo(()=>{let z=[];if(l){for(let N of t)if(N.renderOverlay){let ue=c.states.get(N.id);z.push(jsx("div",{className:"plugin-overlay","data-plugin-id":N.id,children:N.renderOverlay(l,ue,i)},`overlay-${N.id}`));}}for(let N of t){if(!N.Panel||(N.panelConfig?.position??"right")!=="right")continue;let me={...bs,...N.panelConfig},Ee=p.has(N.id),ce=m.get(N.id)??me.defaultSize,Y=N.Panel,R=c.states.get(N.id),L=E!==null?`${E}px`:"calc(50% + 428px)";z.push(jsxs("div",{className:`plugin-panel-in-viewport ${Ee?"collapsed":""}`,style:{width:Ee?"32px":`${ce}px`,left:L},"data-plugin-id":N.id,children:[me.collapsible&&jsx("button",{className:"plugin-panel-toggle",onClick:()=>v(N.id),title:Ee?`Show ${N.name}`:`Hide ${N.name}`,"aria-label":Ee?`Show ${N.name}`:`Hide ${N.name}`,children:jsx("span",{className:"plugin-panel-toggle-icon",children:Ee?"\u2039":"\u203A"})}),!Ee&&l&&jsx("div",{className:"plugin-panel-in-viewport-content",children:jsx(Y,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:g,pluginState:R,panelWidth:ce,renderedDomContext:l})})]},`panel-overlay-${N.id}`));}return z.length>0?z:null},[l,t,c.version,i,p,m,b,g,v,E]),P=useMemo(()=>{let z=[];for(let N of t){if(!N.getSidebarItems)continue;let ue=c.states.get(N.id),me={editorView:i,renderedDomContext:l,anchorPositions:new Map,zoom:l?.zoom??1},Ee=N.getSidebarItems(ue,me);z.push(...Ee);}return z},[t,c.version,i,l]),I=useCallback(z=>{u(z);let N=s.current?.onRenderedDomContextReady;typeof N=="function"&&N(z);},[]),J$1=useMemo(()=>cloneElement(n,{externalPlugins:B,pluginOverlays:D,pluginSidebarItems:P,pluginRenderedDomContext:l,onRenderedDomContextReady:I,onEditorViewReady:z=>{a(z);let N=s.current?.onEditorViewReady;typeof N=="function"&&N(z);}}),[n,B,D,P,l,I]),se=useMemo(()=>{let z=[],N=[],ue=[];for(let me of t){if(!me.Panel)continue;let Ee=me.panelConfig?.position??"right";Ee==="left"?z.push(me):Ee==="bottom"?ue.push(me):N.push(me);}return {left:z,right:N,bottom:ue}},[t]),ie=z=>{if(!z.Panel)return null;let N={...bs,...z.panelConfig},ue=p.has(z.id),me=m.get(z.id)??N.defaultSize,Ee=z.Panel,ce=c.states.get(z.id);return jsxs("div",{className:`plugin-panel plugin-panel-${N.position} ${ue?"collapsed":""}`,style:{[N.position==="bottom"?"height":"width"]:ue?"32px":`${me}px`,minWidth:N.position!=="bottom"?ue?"32px":`${N.minSize}px`:void 0,maxWidth:N.position!=="bottom"?`${N.maxSize}px`:void 0,minHeight:N.position==="bottom"?ue?"32px":`${N.minSize}px`:void 0,maxHeight:N.position==="bottom"?`${N.maxSize}px`:void 0},"data-plugin-id":z.id,children:[N.collapsible&&jsxs("button",{className:"plugin-panel-toggle",onClick:()=>v(z.id),title:ue?`Show ${z.name}`:`Hide ${z.name}`,"aria-label":ue?`Show ${z.name}`:`Hide ${z.name}`,children:[jsx("span",{className:"plugin-panel-toggle-icon",children:ue?"\u203A":"\u2039"}),ue&&jsx("span",{className:"plugin-panel-toggle-label",children:z.name})]}),!ue&&jsx("div",{className:"plugin-panel-content",children:jsx(Ee,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:g,pluginState:ce,panelWidth:me,renderedDomContext:l??null})})]},z.id)};return jsxs("div",{className:`plugin-host ${o}`,children:[se.left.length>0&&jsx("div",{className:"plugin-panels-left",children:se.left.map(ie)}),jsxs("div",{className:"plugin-host-editor",children:[J$1,se.bottom.length>0&&jsx("div",{className:"plugin-panels-bottom",children:se.bottom.map(ie)})]})]})});export{Pk as A,oc as B,VI as C,UI as D,im as E,am as F,sm as G,jI as H,KI as I,GI as J,YI as K,Mk as L,qI as M,lm as N,Ik as O,cm as P,XI as Q,nF as R,oF as S,cF as T,gm as U,Nk as V,_t as a,tC as b,td as c,Ri as d,nC as e,oC as f,rC as g,iC as h,od as i,Jf as j,xI as k,PI as l,pn as m,FI as n,LI as o,BI as p,AI as q,DI as r,HI as s,NI as t,zI as u,OI as v,sr as w,_I as x,WI as y,rm as z};
|