@eigenpal/docx-js-editor 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/DocumentAgent-Ci6_T-XM.d.ts +412 -0
  2. package/dist/DocumentAgent-DEGFgYEN.d.cts +412 -0
  3. package/dist/FindReplaceDialog-BAACAU67.cjs +1 -0
  4. package/dist/FindReplaceDialog-RWYDRWHF.js +1 -0
  5. package/dist/FootnotePropertiesDialog-BC6JIPDA.cjs +1 -0
  6. package/dist/FootnotePropertiesDialog-CWQF5EBK.js +1 -0
  7. package/dist/HyperlinkDialog-EG2BSLPD.cjs +1 -0
  8. package/dist/HyperlinkDialog-YAVK64F4.js +1 -0
  9. package/dist/ImagePositionDialog-IGYS5KMK.cjs +1 -0
  10. package/dist/ImagePositionDialog-S6SMH7XH.js +1 -0
  11. package/dist/ImagePropertiesDialog-UO5QUIBS.js +1 -0
  12. package/dist/ImagePropertiesDialog-VGV4E4SN.cjs +1 -0
  13. package/dist/TablePropertiesDialog-VBOU4DID.js +1 -0
  14. package/dist/TablePropertiesDialog-WRM47JI6.cjs +1 -0
  15. package/dist/{types-BALm1KBi.d.cts → agentApi-CbVUCZRu.d.cts} +1 -308
  16. package/dist/{types-BALm1KBi.d.ts → agentApi-CbVUCZRu.d.ts} +1 -308
  17. package/dist/chunk-2ASOEN3V.js +1 -0
  18. package/dist/chunk-6MBDPZVD.js +111 -0
  19. package/dist/chunk-6YLNNCRZ.cjs +10 -0
  20. package/dist/chunk-BVQ2QRHA.cjs +4 -0
  21. package/dist/chunk-COP5BIBZ.js +10 -0
  22. package/dist/chunk-CZ7W7MCM.cjs +2 -0
  23. package/dist/chunk-E6XDMUAM.js +4 -0
  24. package/dist/chunk-EMKABJPH.js +1 -0
  25. package/dist/{chunk-GIZ5CTBD.cjs → chunk-EPCZ24TY.cjs} +5 -5
  26. package/dist/chunk-ESI4BSBF.js +1 -0
  27. package/dist/chunk-FLECKDK4.cjs +58 -0
  28. package/dist/chunk-ITWEFKGQ.cjs +1 -0
  29. package/dist/chunk-KESNGXGO.js +1 -0
  30. package/dist/chunk-KVAT5SVD.js +2 -0
  31. package/dist/chunk-L34XFLQZ.cjs +1 -0
  32. package/dist/chunk-M7F2CUUD.js +2 -0
  33. package/dist/chunk-MDPDH7KS.js +58 -0
  34. package/dist/chunk-MTX3EEBJ.js +258 -0
  35. package/dist/chunk-NT2REEAA.cjs +1 -0
  36. package/dist/{chunk-P332HWDE.js → chunk-OTG4NABM.js} +5 -5
  37. package/dist/chunk-OW5H5DNE.cjs +1 -0
  38. package/dist/chunk-PJVI53AH.js +2 -0
  39. package/dist/chunk-PNMZPPPI.cjs +2 -0
  40. package/dist/chunk-SF53KLDZ.cjs +1 -0
  41. package/dist/chunk-TOI5W3HK.js +8 -0
  42. package/dist/chunk-UAVOWAIF.cjs +8 -0
  43. package/dist/chunk-VN7XH644.cjs +258 -0
  44. package/dist/chunk-W4DUKACP.cjs +111 -0
  45. package/dist/chunk-XS2AQFMF.cjs +2 -0
  46. package/dist/chunk-ZDYHAYN6.js +1 -0
  47. package/dist/clipboard-BOocwmAM.d.ts +539 -0
  48. package/dist/clipboard-Cx7cb3kX.d.cts +539 -0
  49. package/dist/{colorResolver-BNj-uZ58.d.ts → colorResolver-CIDiSPWd.d.cts} +3 -411
  50. package/dist/{colorResolver-DiMquGWR.d.cts → colorResolver-KXbUgzWC.d.ts} +3 -411
  51. package/dist/core-plugins.cjs +1 -1
  52. package/dist/core-plugins.d.cts +4 -3
  53. package/dist/core-plugins.d.ts +4 -3
  54. package/dist/core-plugins.js +1 -1
  55. package/dist/core.cjs +1 -0
  56. package/dist/core.d.cts +23 -0
  57. package/dist/core.d.ts +23 -0
  58. package/dist/core.js +1 -0
  59. package/dist/headless.cjs +2 -2
  60. package/dist/headless.d.cts +8 -175
  61. package/dist/headless.d.ts +8 -175
  62. package/dist/headless.js +1 -1
  63. package/dist/index.cjs +9 -378
  64. package/dist/index.d.cts +17 -4161
  65. package/dist/index.d.ts +17 -4161
  66. package/dist/index.js +9 -378
  67. package/dist/insertOperations-CzB5b-Of.d.ts +176 -0
  68. package/dist/insertOperations-DKVmCV32.d.cts +176 -0
  69. package/dist/mcp-cli.js +21 -21
  70. package/dist/mcp.cjs +10 -10
  71. package/dist/mcp.d.cts +2 -1
  72. package/dist/mcp.d.ts +2 -1
  73. package/dist/mcp.js +9 -9
  74. package/dist/processTemplate-BHBTDAIC.js +1 -0
  75. package/dist/processTemplate-QOEAXCKA.cjs +1 -0
  76. package/dist/react-Be1YOl4z.d.ts +1356 -0
  77. package/dist/react-DPuSVbgY.d.cts +1356 -0
  78. package/dist/react.cjs +1 -0
  79. package/dist/react.css +1 -0
  80. package/dist/react.d.cts +9 -0
  81. package/dist/react.d.ts +9 -0
  82. package/dist/react.js +1 -0
  83. package/dist/{registry-CzqAPdui.d.ts → registry-D4tvj9f3.d.ts} +1 -1
  84. package/dist/{registry-BUTMLqSj.d.cts → registry-ngv6Bumt.d.cts} +1 -1
  85. package/dist/types-D96elyJF.d.cts +310 -0
  86. package/dist/types-xMzSPT4i.d.ts +310 -0
  87. package/dist/ui.cjs +1 -0
  88. package/dist/ui.d.cts +2103 -0
  89. package/dist/ui.d.ts +2103 -0
  90. package/dist/ui.js +1 -0
  91. package/dist/variableDetector-CPxKo9jP.d.cts +173 -0
  92. package/dist/variableDetector-DeM1N-_L.d.ts +173 -0
  93. package/package.json +85 -10
  94. package/dist/chunk-56AGRHVO.cjs +0 -58
  95. package/dist/chunk-E23CAQXT.js +0 -9
  96. package/dist/chunk-HIBC7HTU.cjs +0 -9
  97. package/dist/chunk-ICEPOA7G.js +0 -58
  98. package/dist/chunk-IZGUXSCC.js +0 -10
  99. package/dist/chunk-XF3IPO7C.cjs +0 -10
@@ -0,0 +1,258 @@
1
+ 'use strict';var chunkY37VT37I_cjs=require('./chunk-Y37VT37I.cjs'),chunkPNMZPPPI_cjs=require('./chunk-PNMZPPPI.cjs'),chunkBVQ2QRHA_cjs=require('./chunk-BVQ2QRHA.cjs'),chunkXS2AQFMF_cjs=require('./chunk-XS2AQFMF.cjs'),chunkSF53KLDZ_cjs=require('./chunk-SF53KLDZ.cjs'),chunkA7VY2V4X_cjs=require('./chunk-A7VY2V4X.cjs'),chunkEPCZ24TY_cjs=require('./chunk-EPCZ24TY.cjs'),chunkCZ7W7MCM_cjs=require('./chunk-CZ7W7MCM.cjs'),chunkRTESADL3_cjs=require('./chunk-RTESADL3.cjs'),fd=require('react'),jsxRuntime=require('react/jsx-runtime'),prosemirrorState=require('prosemirror-state'),prosemirrorView=require('prosemirror-view'),prosemirrorHistory=require('prosemirror-history'),prosemirrorModel=require('prosemirror-model'),prosemirrorCommands=require('prosemirror-commands'),prosemirrorTables=require('prosemirror-tables'),prosemirrorDropcursor=require('prosemirror-dropcursor'),prosemirrorKeymap=require('prosemirror-keymap');require('prosemirror-view/style/prosemirror.css');var client=require('react-dom/client');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var fd__default=/*#__PURE__*/_interopDefault(fd);var es=fd.createContext(null);function Ch(){let e=fd.useContext(es);if(!e)throw new Error("useErrorNotifications must be used within an ErrorProvider");return e}function ts({children:e}){let[t,n]=fd.useState([]),o=fd.useRef(0),r=fd.useCallback((d,p,f)=>{let m=`error-${++o.current}-${Date.now()}`,b={id:m,message:d,severity:p,details:f,timestamp:Date.now()};return n(g=>[...g,b]),p!=="error"&&setTimeout(()=>{l(m);},5e3),m},[]),i=fd.useCallback((d,p)=>{r(d,"error",p);},[r]),a=fd.useCallback((d,p)=>{r(d,"warning",p);},[r]),s=fd.useCallback((d,p)=>{r(d,"info",p);},[r]),l=fd.useCallback(d=>{n(p=>p.map(f=>f.id===d?{...f,dismissed:true}:f)),setTimeout(()=>{n(p=>p.filter(f=>f.id!==d));},300);},[]),u=fd.useCallback(()=>{n([]);},[]),c={notifications:t,showError:i,showWarning:a,showInfo:s,dismissNotification:l,clearNotifications:u};return jsxRuntime.jsxs(es.Provider,{value:c,children:[e,jsxRuntime.jsx(Vd,{notifications:t,onDismiss:l})]})}function Vd({notifications:e,onDismiss:t}){let n=e.filter(r=>!r.dismissed);return n.length===0?null:jsxRuntime.jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:n.map(r=>jsxRuntime.jsx(jd,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function jd({notification:e,onDismiss:t}){let[n,o]=fd.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},c={color:i.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},d={marginTop:"8px",padding:"8px",background:"rgba(0, 0, 0, 0.05)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:i.text,maxHeight:"200px",overflow:"auto"},p={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:i.text},f=m=>{switch(m){case "error":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxRuntime.jsxs("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:a,children:[jsxRuntime.jsx("style",{children:`
2
+ @keyframes slideIn {
3
+ from {
4
+ opacity: 0;
5
+ transform: translateX(100%);
6
+ }
7
+ to {
8
+ opacity: 1;
9
+ transform: translateX(0);
10
+ }
11
+ }
12
+ `}),jsxRuntime.jsxs("div",{style:s,children:[jsxRuntime.jsx("span",{style:l,children:f(e.severity)}),jsxRuntime.jsxs("div",{style:u,children:[jsxRuntime.jsx("div",{style:c,children:e.message}),e.details&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!n),style:{...p,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:n?"Hide details":"Show details"}),n&&jsxRuntime.jsx("div",{style:d,children:e.details})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,style:p,title:"Dismiss",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var Ao=class extends fd.Component{constructor(n){super(n);chunkRTESADL3_cjs.e(this,"resetError",()=>{this.setState({hasError:false,error:null,errorInfo:null});});this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(n){return {hasError:true,error:n}}componentDidCatch(n,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",n,o),this.props.onError&&this.props.onError(n,o);}render(){if(this.state.hasError){let{fallback:n,showDetails:o=true}=this.props,{error:r,errorInfo:i}=this.state;return n?typeof n=="function"?n(r,this.resetError):n:jsxRuntime.jsx(Ud,{error:r,errorInfo:i,showDetails:o,onReset:this.resetError})}return this.props.children}};function Ud({error:e,errorInfo:t,showDetails:n,onReset:o}){let r={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"white",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},i={color:"var(--doc-error)",marginBottom:"16px"},a={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},l={width:"100%",maxWidth:"600px",marginBottom:"16px",padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"200px",overflow:"auto"},u={padding:"10px 20px",background:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:"docx-error-fallback",style:r,children:[jsxRuntime.jsx("div",{style:i,children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsxRuntime.jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h2",{style:a,children:"Something went wrong"}),jsxRuntime.jsx("p",{style:s,children:"An error occurred while rendering this component. Please try again or contact support if the problem persists."}),n&&jsxRuntime.jsxs("div",{style:l,children:[jsxRuntime.jsx("strong",{children:"Error:"})," ",e.message,t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[`
13
+
14
+ `,jsxRuntime.jsx("strong",{children:"Component Stack:"}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:o,style:u,children:"Try Again"})]})}function Th({message:e,details:t,onRetry:n,className:o=""}){let r={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",background:"white",borderRadius:"8px",border:"1px solid var(--doc-border-light)"},i={color:"var(--doc-error)",marginBottom:"16px"},a={fontSize:"16px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},l={marginBottom:"16px",padding:"12px",background:"var(--doc-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",maxWidth:"100%",overflow:"auto",textAlign:"left"},u={padding:"8px 16px",background:"var(--doc-primary)",color:"white",border:"none",borderRadius:"4px",fontSize:"13px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:`docx-parse-error ${o}`,style:r,children:[jsxRuntime.jsx("div",{style:i,children:jsxRuntime.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",children:[jsxRuntime.jsx("path",{d:"M10 10h20v20H10z",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M25 10l-10 20M15 10l10 20",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h3",{style:a,children:"Unable to Parse Document"}),jsxRuntime.jsx("p",{style:s,children:e}),t&&jsxRuntime.jsx("div",{style:l,children:t}),n&&jsxRuntime.jsx("button",{type:"button",onClick:n,style:u,children:"Try Again"})]})}function Rh({feature:e,description:t,className:n=""}){let o={display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:"var(--doc-warning-bg)",border:"1px solid #ffeeba",borderRadius:"4px",fontSize:"12px",color:"#856404"},r={flexShrink:0,color:"var(--doc-warning)"};return jsxRuntime.jsxs("div",{className:`docx-unsupported-warning ${n}`,style:o,children:[jsxRuntime.jsx("span",{style:r,children:jsxRuntime.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[jsxRuntime.jsx("path",{d:"M8 2l7 12H1L8 2z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M8 6v4M8 12v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("strong",{children:e}),t&&`: ${t}`]})]})}function vh(e){return e.message.includes("parse")||e.message.includes("Parse")||e.message.includes("XML")||e.message.includes("DOCX")||e.message.includes("Invalid")}function Ph(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."}var Bh={TABLE_INDEX:"data-table-index",ROW_INDEX:"data-row",COLUMN_INDEX:"data-col",TABLE_CELL:"data-table-cell"};function Kd(e,t){if(!e.package?.document?.content)return null;let n=0;for(let o of e.package.document.content)if(o.type==="table"){if(n===t)return o;n++;}return null}function qd(e,t,n){if(!e.package?.document?.content)return e;let o=0,r=e.package.document.content.map(i=>{if(i.type==="table"){if(o===t)return o++,n;o++;}return i});return {...e,package:{...e.package,document:{...e.package.document,content:r}}}}function Yd(e,t){if(!e.package?.document?.content)return e;let n=0,o=e.package.document.content.filter(r=>{if(r.type==="table"){let i=n===t;return n++,!i}return true});return {...e,package:{...e.package,document:{...e.package.document,content:o}}}}function os({document:e,onChange:t,onSelectionChange:n}){let[o,r]=fd.useState({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),i=fd.useCallback((u,c,d)=>{if(!e)return;let p=Kd(e,u);if(!p){r({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null});return}let m=chunkBVQ2QRHA_cjs.U(p,{tableIndex:u,rowIndex:c,columnIndex:d});r({context:m,table:p,tableIndex:u,rowIndex:c,columnIndex:d}),n?.(m);},[e,n]),a=fd.useCallback(()=>{r({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),n?.(null);},[n]),s=fd.useCallback(u=>{if(!e||!o.context||o.tableIndex===null||o.rowIndex===null||o.columnIndex===null)return;let c=o.table;if(!c)return;let d=null,p=null,f=o.rowIndex,m=o.columnIndex;switch(u){case "addRowAbove":d=chunkBVQ2QRHA_cjs.X(c,o.rowIndex,"before"),f=o.rowIndex+1;break;case "addRowBelow":d=chunkBVQ2QRHA_cjs.X(c,o.rowIndex,"after");break;case "addColumnLeft":d=chunkBVQ2QRHA_cjs.Z(c,o.columnIndex,"before"),m=o.columnIndex+1;break;case "addColumnRight":d=chunkBVQ2QRHA_cjs.Z(c,o.columnIndex,"after");break;case "deleteRow":c.rows.length>1&&(d=chunkBVQ2QRHA_cjs.Y(c,o.rowIndex),f>=d.rows.length&&(f=d.rows.length-1));break;case "deleteColumn":{if(chunkBVQ2QRHA_cjs.V(c)>1){d=chunkBVQ2QRHA_cjs._(c,o.columnIndex);let g=chunkBVQ2QRHA_cjs.V(d);m>=g&&(m=g-1);}break}case "mergeCells":o.context.selection.selectedCells&&(d=chunkBVQ2QRHA_cjs.$(c,o.context.selection));break;case "splitCell":o.context.canSplitCell&&(d=chunkBVQ2QRHA_cjs.aa(c,o.rowIndex,o.columnIndex));break;case "deleteTable":p=Yd(e,o.tableIndex),a(),t?.(p);return}d&&(p=qd(e,o.tableIndex,d),t?.(p),p&&i(o.tableIndex,f,m));},[e,o,t,a,i]),l=fd.useCallback((u,c,d)=>o.tableIndex===u&&o.rowIndex===c&&o.columnIndex===d,[o]);return {state:o,handleCellClick:i,handleAction:s,clearSelection:a,isCellSelected:l,tableContext:o.context}}var is=({headings:e,onHeadingClick:t,onClose:n,topOffset:o=0})=>{let[r,i]=fd.useState(false);return fd.useEffect(()=>{requestAnimationFrame(()=>i(true));},[]),jsxRuntime.jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":"Document outline",style:{position:"absolute",top:o,left:30,bottom:0,width:240,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:r?"translateX(0)":"translateX(-270px)",transition:"transform 0.15s ease-out"},onMouseDown:a=>a.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px"},children:[jsxRuntime.jsx("button",{onClick:n,"aria-label":"Close outline",style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"#444746"},title:"Close outline",children:jsxRuntime.jsx(chunkBVQ2QRHA_cjs.d,{name:"arrow_back",size:20})}),jsxRuntime.jsx("span",{style:{fontWeight:400,fontSize:14,color:"#1f1f1f",letterSpacing:"0.01em"},children:"Outline"})]}),jsxRuntime.jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:20},children:e.length===0?jsxRuntime.jsx("div",{style:{padding:"8px 16px",color:"#80868b",fontSize:13,lineHeight:"20px"},children:"No headings found. Add headings to your document to see them here."}):e.map((a,s)=>jsxRuntime.jsx("div",{style:{marginLeft:a.level*12},children:jsxRuntime.jsx("button",{className:"docx-outline-heading-btn",onClick:()=>t(a.pmPos),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 12px",fontSize:13,fontWeight:400,color:"#1f1f1f",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:a.text,children:a.text})},`${a.pmPos}-${s}`))})]})};var eu=15840,ss=1440,tu=1440,nu=567,cs=20,ou="var(--doc-text-muted)",ru="var(--doc-text-subtle)",iu="var(--doc-primary)",au="var(--doc-primary)",su="var(--doc-primary-hover)";function ds({sectionProps:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,unit:i="inch",className:a="",style:s}){let[l,u]=fd.useState(null),[c,d]=fd.useState(null),p=fd.useRef(null),f=e?.pageHeight??eu,m=e?.marginTop??ss,b=e?.marginBottom??ss,g=chunkSF53KLDZ_cjs.n(f)*t,k=chunkSF53KLDZ_cjs.n(m)*t,P=chunkSF53KLDZ_cjs.n(b)*t,S=fd.useCallback((A,F)=>{n&&(A.preventDefault(),u(F));},[n]),B=fd.useCallback(A=>{if(!l||!p.current)return;let F=p.current.getBoundingClientRect(),R=A.clientY-F.top,te=chunkSF53KLDZ_cjs.o(R/t);if(l==="topMargin"){let re=f-b-720,Q=Math.max(0,Math.min(te,re));o?.(Math.round(Q));}else if(l==="bottomMargin"){let re=f-te,Q=f-m-720,pe=Math.max(0,Math.min(re,Q));r?.(Math.round(pe));}},[l,t,f,m,b,o,r]),E=fd.useCallback(()=>{u(null);},[]);fd.useEffect(()=>{if(l)return document.addEventListener("mousemove",B),document.addEventListener("mouseup",E),()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",E);}},[l,B,E]);let J=cu(f,t,i),Z={position:"relative",width:cs,height:chunkSF53KLDZ_cjs.x(g),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:l?"ns-resize":"default",...s};return jsxRuntime.jsxs("div",{ref:p,className:`docx-vertical-ruler ${a}`,style:Z,role:"slider","aria-label":"Vertical ruler","aria-orientation":"vertical",children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:J.map((A,F)=>jsxRuntime.jsx(lu,{tick:A},F))}),jsxRuntime.jsx(ls,{type:"topMargin",position:k,editable:n,isDragging:l==="topMargin",isHovered:c==="topMargin",onMouseEnter:()=>d("topMargin"),onMouseLeave:()=>d(null),onMouseDown:A=>S(A,"topMargin")}),jsxRuntime.jsx(ls,{type:"bottomMargin",position:g-P,editable:n,isDragging:l==="bottomMargin",isHovered:c==="bottomMargin",onMouseEnter:()=>d("bottomMargin"),onMouseLeave:()=>d(null),onMouseDown:A=>S(A,"bottomMargin")})]})}function lu({tick:e}){let t={position:"absolute",top:chunkSF53KLDZ_cjs.x(e.position),right:0,height:1,width:e.width,backgroundColor:ru},n={position:"absolute",top:chunkSF53KLDZ_cjs.x(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:ou,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:t}),e.label&&jsxRuntime.jsx("div",{style:n,children:e.label})]})}function ls({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:s}){let l=o?su:r?au:iu,u={position:"absolute",top:chunkSF53KLDZ_cjs.x(t-5),right:0,width:cs,height:10,cursor:n?"ns-resize":"default",zIndex:o?10:1},c={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${l}`,transition:"border-right-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:u,onMouseEnter:i,onMouseLeave:a,onMouseDown:s,role:"slider","aria-label":e==="topMargin"?"Top margin":"Bottom margin","aria-orientation":"vertical",tabIndex:n?0:-1,children:jsxRuntime.jsx("div",{style:c})})}function cu(e,t,n){let o=[];if(n==="inch"){let r=tu/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=chunkSF53KLDZ_cjs.n(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=nu/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=chunkSF53KLDZ_cjs.n(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 on={High:50,Default:100,Low:150};function St(e){return t=>{let n={...e.defaultOptions,...t};return {type:"extension",config:{name:e.name,priority:e.priority??on.Default,options:n},onSchemaReady(o){return e.onSchemaReady(o,n)}}}}function $e(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??on.Default,options:n,schemaNodeName:e.schemaNodeName,nodeSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}function we(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??on.Default,options:n,schemaMarkName:e.schemaMarkName,markSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}var ps=$e({name:"doc",schemaNodeName:"doc",nodeSpec:{content:"(paragraph | horizontalRule | pageBreak | table)+"}});var fs=$e({name:"text",schemaNodeName:"text",nodeSpec:{group:"inline"}});var uu={calibri:{googleFont:"Carlito",category:"sans-serif",fallbackStack:["Carlito","Calibri","Arial","Helvetica","sans-serif"]},cambria:{googleFont:"Caladea",category:"serif",fallbackStack:["Caladea","Cambria","Georgia","serif"]},arial:{googleFont:"Arimo",category:"sans-serif",fallbackStack:["Arimo","Arial","Helvetica","sans-serif"]},"times new roman":{googleFont:"Tinos",category:"serif",fallbackStack:["Tinos","Times New Roman","Times","serif"]},"courier new":{googleFont:"Cousine",category:"monospace",fallbackStack:["Cousine","Courier New","Courier","monospace"]},georgia:{googleFont:"Tinos",category:"serif",fallbackStack:["Georgia","Tinos","Times New Roman","serif"]},verdana:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Verdana","Open Sans","Arial","sans-serif"]},tahoma:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Tahoma","Open Sans","Arial","sans-serif"]},"trebuchet ms":{googleFont:"Fira Sans",category:"sans-serif",fallbackStack:["Trebuchet MS","Fira Sans","Arial","sans-serif"]},"comic sans ms":{googleFont:"Comic Neue",category:"cursive",fallbackStack:["Comic Sans MS","Comic Neue","cursive"]},impact:{googleFont:"Anton",category:"sans-serif",fallbackStack:["Impact","Anton","Arial Black","sans-serif"]},"palatino linotype":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Palatino Linotype","EB Garamond","Palatino","Georgia","serif"]},"book antiqua":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Book Antiqua","EB Garamond","Palatino","Georgia","serif"]},garamond:{googleFont:"EB Garamond",category:"serif",fallbackStack:["Garamond","EB Garamond","Georgia","serif"]},"century gothic":{googleFont:"Questrial",category:"sans-serif",fallbackStack:["Century Gothic","Questrial","Arial","sans-serif"]},"lucida sans":{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Lucida Sans","Open Sans","Arial","sans-serif"]},"lucida console":{googleFont:"Cousine",category:"monospace",fallbackStack:["Lucida Console","Cousine","Courier New","monospace"]},consolas:{googleFont:"Inconsolata",category:"monospace",fallbackStack:["Consolas","Inconsolata","Cousine","Courier New","monospace"]},"ms mincho":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","Noto Serif JP","serif"]},"ms gothic":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","Noto Sans JP","sans-serif"]},simhei:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","Noto Sans SC","sans-serif"]},simsun:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","Noto Serif SC","serif"]},"malgun gothic":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","Noto Sans KR","sans-serif"]}},pu={"sans-serif":"Arial, Helvetica, sans-serif",serif:"Times New Roman, Times, serif",monospace:"Courier New, Courier, monospace",cursive:"cursive",fantasy:"fantasy","system-ui":"system-ui, sans-serif"};function fu(e){let t=e.toLowerCase();return t.includes("mono")||t.includes("courier")||t.includes("consolas")||t.includes("console")||t.includes("code")||t.includes("terminal")?"monospace":t.includes("times")||t.includes("georgia")||t.includes("garamond")||t.includes("palatino")||t.includes("baskerville")||t.includes("bodoni")||t.includes("cambria")||t.includes("mincho")||t.includes("ming")||t.includes("song")||t.includes("serif")?"serif":t.includes("script")||t.includes("cursive")||t.includes("comic")||t.includes("brush")||t.includes("hand")?"cursive":"sans-serif"}function gs(e){let t=e.trim().toLowerCase(),n=uu[t];if(n)return {googleFont:n.googleFont,cssFallback:n.fallbackStack.map(ms).join(", "),originalFont:e,hasGoogleEquivalent:true};let o=fu(e),r=pu[o];return {googleFont:null,cssFallback:`${ms(e)}, ${r}`,originalFont:e,hasGoogleEquivalent:false}}function ms(e){return ["serif","sans-serif","monospace","cursive","fantasy","system-ui"].includes(e.toLowerCase())?e:/[\s,'"()]/.test(e)?`"${e.replace(/"/g,'\\"')}"`:e}function bs(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=gs(a);n.fontFamily=s.cssFallback;}}if(e.fontSize!==void 0&&(n.fontSize=`${chunkSF53KLDZ_cjs.v(e.fontSize)}pt`),e.bold&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic"),e.color&&(n.color=chunkSF53KLDZ_cjs.a(e.color,t)),e.highlight&&e.highlight!=="none"){let a=chunkSF53KLDZ_cjs.b(e.highlight);a&&(n.backgroundColor=a);}if(e.shading){let a=xs(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=mu(e.underline.style);a!=="solid"&&r.push(a),e.underline.color&&i.push(chunkSF53KLDZ_cjs.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=chunkSF53KLDZ_cjs.u(e.position);n.position="relative",n.top=chunkSF53KLDZ_cjs.x(-a);}return e.allCaps?n.textTransform="uppercase":e.smallCaps&&(n.fontVariant="small-caps"),e.spacing!==void 0&&e.spacing!==0&&(n.letterSpacing=chunkSF53KLDZ_cjs.x(chunkSF53KLDZ_cjs.n(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 ys(e,t){if(!e)return {};let n={};if(e.alignment&&(n.textAlign=gu(e.alignment)),e.spaceBefore!==void 0&&(n.marginTop=chunkSF53KLDZ_cjs.x(chunkSF53KLDZ_cjs.n(e.spaceBefore))),e.spaceAfter!==void 0&&(n.marginBottom=chunkSF53KLDZ_cjs.x(chunkSF53KLDZ_cjs.n(e.spaceAfter))),e.lineSpacing!==void 0&&e.lineSpacing>0)switch(e.lineSpacingRule){case "exact":{let o=chunkSF53KLDZ_cjs.n(e.lineSpacing);o>0&&(n.lineHeight=chunkSF53KLDZ_cjs.x(o));break}case "atLeast":{let o=chunkSF53KLDZ_cjs.n(e.lineSpacing);o>0&&(n.minHeight=chunkSF53KLDZ_cjs.x(o),n.lineHeight=chunkSF53KLDZ_cjs.x(o));break}default:{let o=e.lineSpacing/240;o>0&&(n.lineHeight=o.toString());break}}if(e.indentLeft!==void 0&&(n.marginLeft=chunkSF53KLDZ_cjs.x(chunkSF53KLDZ_cjs.n(e.indentLeft))),e.indentRight!==void 0&&(n.marginRight=chunkSF53KLDZ_cjs.x(chunkSF53KLDZ_cjs.n(e.indentRight))),e.indentFirstLine!==void 0&&(e.hangingIndent?n.textIndent=chunkSF53KLDZ_cjs.x(chunkSF53KLDZ_cjs.n(e.indentFirstLine)):n.textIndent=chunkSF53KLDZ_cjs.x(chunkSF53KLDZ_cjs.n(e.indentFirstLine))),e.borders&&(e.borders.top&&Object.assign(n,An(e.borders.top,"Top",t)),e.borders.bottom&&Object.assign(n,An(e.borders.bottom,"Bottom",t)),e.borders.left&&Object.assign(n,An(e.borders.left,"Left",t)),e.borders.right&&Object.assign(n,An(e.borders.right,"Right",t))),e.shading){let o=xs(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 An(e,t="",n){if(!e||e.style==="none"||e.style==="nil")return {};let o={},r=e.size?chunkSF53KLDZ_cjs.w(e.size):1,i=e.color?chunkSF53KLDZ_cjs.a(e.color,n):"#000000",a=hu(e.style),s=`border${t}Width`,l=`border${t}Style`,u=`border${t}Color`;return o[s]=chunkSF53KLDZ_cjs.x(Math.max(1,r)),o[l]=a,o[u]=i,o}function xs(e,t){return !e||e.pattern==="clear"||e.pattern==="nil"?"":e.fill?e.fill.auto||e.fill.rgb==="auto"||e.fill.rgb==="FFFFFF"?"":chunkSF53KLDZ_cjs.c(e.fill,t):e.pattern==="solid"&&e.color?chunkSF53KLDZ_cjs.c(e.color,t):e.pattern&&e.pattern.startsWith("pct")&&e.color?chunkSF53KLDZ_cjs.c(e.color,t):""}function mu(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 gu(e){switch(e){case "center":return "center";case "right":return "right";case "both":case "distribute":return "justify";default:return "left"}}function hu(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 Dn(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 yu(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=ys(n);return Object.entries(o).map(([r,i])=>`${r.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${i}`).join("; ")}function xu(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 Su(e,t,n){if(!e?.numId)return "";let o=e.ilvl??0;return t?`docx-list-bullet docx-list-level-${o}`:`docx-list-numbered ${xu(n)} docx-list-level-${o}`}var ku={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},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},outlineLevel:{default:null},bookmarks:{default:null},_originalFormatting:{default:null}},parseDOM:[{tag:"p",getAttrs(e){let t=e;return {paraId:t.dataset.paraId||void 0,alignment:t.dataset.alignment,styleId:t.dataset.styleId||void 0,sectionBreakType:t.dataset.sectionBreak||void 0}}}],toDOM(e){let t=e.attrs,n=yu(t),o=Su(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.sectionBreakType&&(r["data-section-break"]=t.sectionBreakType,r.class=(r.class?r.class+" ":"")+"docx-section-break"),["p",r,0]}};function It(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 Ss(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 oo(e){return (t,n)=>It("alignment",e)(t,n)}function Ho(e,t="auto"){return (n,o)=>Ss({lineSpacing:e,lineSpacingRule:t})(n,o)}function wu(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 Cu(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,c=Math.max(0,u-e);i=i.setNodeMarkup(l,void 0,{...s.attrs,indentLeft:c>0?c:null});}}),n(i.scrollIntoView()),true}}function Tu(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 d=n.runFormatting;d.bold&&u.push(e.marks.bold.create()),d.italic&&u.push(e.marks.italic.create()),d.fontSize&&u.push(e.marks.fontSize.create({size:d.fontSize})),d.fontFamily&&u.push(e.marks.fontFamily.create({ascii:d.fontFamily.ascii,hAnsi:d.fontFamily.hAnsi,asciiTheme:d.fontFamily.asciiTheme})),d.color&&!d.color.auto&&u.push(e.marks.textColor.create({rgb:d.color.rgb,themeColor:d.color.themeColor,themeTint:d.color.themeTint,themeShade:d.color.themeShade})),d.underline&&d.underline.style!=="none"&&u.push(e.marks.underline.create({style:d.underline.style,color:d.underline.color})),(d.strike||d.doubleStrike)&&u.push(e.marks.strike.create({double:d.doubleStrike||false}));}let c=[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,(d,p)=>{if(d.type.name==="paragraph"&&!l.has(p)){l.add(p);let f={...d.attrs,styleId:t};if(n?.paragraphFormatting){let m=n.paragraphFormatting;m.alignment!==void 0&&(f.alignment=m.alignment),m.spaceBefore!==void 0&&(f.spaceBefore=m.spaceBefore),m.spaceAfter!==void 0&&(f.spaceAfter=m.spaceAfter),m.lineSpacing!==void 0&&(f.lineSpacing=m.lineSpacing),m.lineSpacingRule!==void 0&&(f.lineSpacingRule=m.lineSpacingRule),m.indentLeft!==void 0&&(f.indentLeft=m.indentLeft),m.indentRight!==void 0&&(f.indentRight=m.indentRight),m.indentFirstLine!==void 0&&(f.indentFirstLine=m.indentFirstLine);}if(s=s.setNodeMarkup(p,void 0,f),n){let m=p+1,b=p+d.nodeSize-1;if(b>m){for(let g of c)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 ks=$e({name:"paragraph",schemaNodeName:"paragraph",nodeSpec:ku,onSchemaReady(e){let t=Tu(e.schema);return {commands:{setAlignment:n=>oo(n),alignLeft:()=>oo("left"),alignCenter:()=>oo("center"),alignRight:()=>oo("right"),alignJustify:()=>oo("both"),setLineSpacing:(n,o)=>Ho(n,o),singleSpacing:()=>Ho(240),oneAndHalfSpacing:()=>Ho(360),doubleSpacing:()=>Ho(480),setSpaceBefore:n=>It("spaceBefore",n),setSpaceAfter:n=>It("spaceAfter",n),increaseIndent:n=>wu(n),decreaseIndent:n=>Cu(n),setIndentLeft:n=>It("indentLeft",n>0?n:null),setIndentRight:n=>It("indentRight",n>0?n:null),setIndentFirstLine:(n,o)=>Ss({indentFirstLine:n>0?n:null,hangingIndent:o??false}),applyStyle:(n,o)=>t(n,o),clearStyle:()=>It("styleId",null),insertSectionBreak:n=>It("sectionBreakType",n),removeSectionBreak:()=>It("sectionBreakType",null),generateTOC:()=>(n,o)=>{let r=Dn(n.doc);if(r.length===0)return false;if(!o)return true;let{schema:i}=n,a=n.tr,s=[];for(let c of r){let d=`_Toc${Math.floor(1e8+Math.random()*9e8)}`;s.push({name:d,level:c.level,text:c.text});let p=a.mapping.map(c.pmPos),m=a.doc.resolve(p).nodeAfter;if(m&&m.type.name==="paragraph"){let k=[...(m.attrs.bookmarks||[]).filter(P=>!P.name.startsWith("_Toc")),{id:Math.floor(Math.random()*2147483647),name:d}];a.setNodeMarkup(p,void 0,{...m.attrs,bookmarks:k});}}let l=[];l.push(i.node("paragraph",{styleId:"TOCHeading",alignment:"center"},[i.text("Table of Contents",[i.marks.bold.create()])]));for(let c of s){let d=c.level*720,p=`TOC${c.level+1}`,f=i.marks.hyperlink.create({href:`#${c.name}`});l.push(i.node("paragraph",{styleId:p,indentLeft:d>0?d:null},[i.text(c.text,[f])]));}let u=a.mapping.map(n.selection.from);return a.insert(u,prosemirrorModel.Fragment.from(l)),o(a.scrollIntoView()),true},setTabs:n=>It("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 d=[...(l.attrs.tabs||[]).filter(p=>p.position!==n),{position:n,alignment:o,leader:r}].sort((p,f)=>p.position-f.position);return It("tabs",d)(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 It("tabs",l.length>0?l:null)(o,r)}}}}});var Cs=St({name:"history",defaultOptions:{depth:100,newGroupDelay:500},onSchemaReady(e,t){return {plugins:[prosemirrorHistory.history({depth:t.depth,newGroupDelay:t.newGroupDelay})],commands:{undo:()=>prosemirrorHistory.undo,redo:()=>prosemirrorHistory.redo},keyboardShortcuts:{"Mod-z":prosemirrorHistory.undo,"Mod-y":prosemirrorHistory.redo,"Mod-Shift-z":prosemirrorHistory.redo}}}});var Rs=we({name:"bold",schemaMarkName:"bold",markSpec:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2})$/.test(e)?null:false}],toDOM(){return ["strong",0]}},onSchemaReady(e){return {commands:{toggleBold:()=>prosemirrorCommands.toggleMark(e.schema.marks.bold)},keyboardShortcuts:{"Mod-b":prosemirrorCommands.toggleMark(e.schema.marks.bold)}}}});var Ps=we({name:"italic",schemaMarkName:"italic",markSpec:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"?null:false}],toDOM(){return ["em",0]}},onSchemaReady(e){return {commands:{toggleItalic:()=>prosemirrorCommands.toggleMark(e.schema.marks.italic)},keyboardShortcuts:{"Mod-i":prosemirrorCommands.toggleMark(e.schema.marks.italic)}}}});function vu(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 Es(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=vu(r);return t.setNodeMarkup(n.before(),void 0,{...o.attrs,defaultTextFormatting:i})}function Wt(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(c=>c.type!==e):n.storedMarks||n.selection.$from.marks(),u=n.tr.setStoredMarks([...l,s]);u=Es(n,u),o(u);}return true}return o&&o(n.tr.addMark(r,i,s).scrollIntoView()),true}}function _t(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=Es(t,s),n(s);}return true}return n&&n(t.tr.removeMark(o,r,e).scrollIntoView()),true}}var ro=(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 c of a.marks)i=i.removeMark(l,u,c.type);}}),t(i.scrollIntoView());}return true};var Is=we({name:"underline",schemaMarkName:"underline",markSpec:{attrs:{style:{default:"single"},color:{default:null}},parseDOM:[{tag:"u"},{style:"text-decoration",getAttrs:e=>e.includes("underline")?{}:false}],toDOM(e){let t=e.attrs,n=["text-decoration: underline"];if(t.style&&t.style!=="single"){let r={double:"double",dotted:"dotted",dash:"dashed",wave:"wavy"}[t.style];r&&n.push(`text-decoration-style: ${r}`);}return t.color?.rgb&&n.push(`text-decoration-color: #${t.color.rgb}`),["span",{style:n.join("; ")},0]}},onSchemaReady(e){return {commands:{toggleUnderline:()=>prosemirrorCommands.toggleMark(e.schema.marks.underline),setUnderlineStyle:(t,n)=>Wt(e.schema.marks.underline,{style:t,color:n})},keyboardShortcuts:{"Mod-u":prosemirrorCommands.toggleMark(e.schema.marks.underline)}}}});var Fs=we({name:"strike",schemaMarkName:"strike",markSpec:{attrs:{double:{default:false}},parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:e=>e.includes("line-through")?{}:false}],toDOM(){return ["s",0]}},onSchemaReady(e){return {commands:{toggleStrike:()=>prosemirrorCommands.toggleMark(e.schema.marks.strike)}}}});var Ls=we({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=bs({color:t});return ["span",{style:n.color?`color: ${n.color}`:""},0]}},onSchemaReady(e){return {commands:{setTextColor:t=>!t.rgb&&!t.themeColor?_t(e.schema.marks.textColor):Wt(e.schema.marks.textColor,t),clearTextColor:()=>_t(e.schema.marks.textColor)}}}});var Bs=we({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: ${chunkSF53KLDZ_cjs.b(t)||(t.startsWith("#")?t:`#${t}`)}`},0]}},onSchemaReady(e){return {commands:{setHighlight:t=>!t||t==="none"?_t(e.schema.marks.highlight):Wt(e.schema.marks.highlight,{color:t}),clearHighlight:()=>_t(e.schema.marks.highlight)}}}});var As=we({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=>Wt(e.schema.marks.fontSize,{size:t}),clearFontSize:()=>_t(e.schema.marks.fontSize)}}}});var Ds=we({name:"fontFamily",schemaMarkName:"fontFamily",markSpec:{attrs:{ascii:{default:null},hAnsi:{default:null},asciiTheme:{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=>Wt(e.schema.marks.fontFamily,{ascii:t,hAnsi:t}),clearFontFamily:()=>_t(e.schema.marks.fontFamily)}}}});var Hs=we({name:"superscript",schemaMarkName:"superscript",markSpec:{excludes:"subscript",parseDOM:[{tag:"sup"}],toDOM(){return ["sup",0]}},onSchemaReady(e){return {commands:{toggleSuperscript:()=>prosemirrorCommands.toggleMark(e.schema.marks.superscript)}}}});var Ns=we({name:"subscript",schemaMarkName:"subscript",markSpec:{excludes:"superscript",parseDOM:[{tag:"sub"}],toDOM(){return ["sub",0]}},onSchemaReady(e){return {commands:{toggleSubscript:()=>prosemirrorCommands.toggleMark(e.schema.marks.subscript)}}}});function Hn(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 Nn(e){let{from:t,to:n,empty:o}=e.selection;return o?"":e.doc.textBetween(t,n,"")}var zs=we({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:c,empty:d}=s.selection;if(d)return false;if(l){let p=t.create({href:i,tooltip:a||null});l(s.tr.addMark(u,c,p).scrollIntoView());}return true},o=(i,a)=>{let{from:s,to:l,empty:u}=i.selection;if(u){let c=i.selection.$from;if(!c.marks().find(g=>g.type===t))return false;let f=c.pos,m=c.pos;return c.parent.forEach((g,k)=>{if(g.isText){let P=c.start()+k,S=P+g.nodeSize;P<=c.pos&&c.pos<=S&&g.marks.some(E=>E.type===t)&&(f=Math.min(f,P),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 c=t.create({href:a,tooltip:s||null}),d=l.schema.text(i,[c]);u(l.tr.replaceSelectionWith(d,false).scrollIntoView());}return true}}}}});var Os=we({name:"allCaps",schemaMarkName:"allCaps",markSpec:{parseDOM:[{style:"text-transform",getAttrs:e=>e==="uppercase"?{}:false}],toDOM(){return ["span",{style:"text-transform: uppercase"},0]}}});var $s=we({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 Ws=we({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]),c=a.tr.replaceSelectionWith(u,false);return s(c.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 Iu(e){return e/2*(96/72)}var _s=we({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: ${chunkSF53KLDZ_cjs.x(chunkSF53KLDZ_cjs.n(t.spacing))}`),o["data-spacing"]=String(t.spacing)),t.position!=null&&t.position!==0){let r=Iu(t.position);n.push(`vertical-align: ${chunkSF53KLDZ_cjs.x(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 Vs=we({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 js=we({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]}}}),Us=we({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 Gs=we({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]}}}),Ks=we({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]}}}),qs=we({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]}}}),Ys=we({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]}}}),Xs=we({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 Zs=$e({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 Js=$e({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 Qs=$e({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}},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 el=$e({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 Fu(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 Lu(e,t){let n="";try{n=JSON.parse(t.gradientStops||"[]").map(d=>`<stop offset="${Math.round(d.position/1e3)}%" stop-color="${d.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 tl=$e({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=Lu(m,t);}else s=t.fillType==="none"?"none":t.fillColor||"#ffffff";let l=t.outlineWidth||1,u=t.outlineColor||"#000000",c=t.outlineStyle==="dashed"?' stroke-dasharray="8 4"':t.outlineStyle==="dotted"?' stroke-dasharray="2 2"':"",d=Fu(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}${c}">`+(a?`<defs>${a}</defs>`:"")+d+"</svg>",f=document.createElement("span");return Object.entries(r).forEach(([m,b])=>{f.setAttribute(m,b);}),f.innerHTML=p,{dom:f}}}});var nl=$e({name:"horizontalRule",schemaNodeName:"horizontalRule",nodeSpec:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return ["hr"]}}});var ol=$e({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 rl=$e({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 il=$e({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 al=$e({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]}}});var Wu={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]]}},_u={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]}},Vu={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 sl(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=Vu[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 ll(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 cl(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 dl(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 ju={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){let t=e;return {colspan:t.colSpan||1,rowspan:t.rowSpan||1,verticalAlign:t.dataset.valign,backgroundColor:t.dataset.bgcolor||void 0}}}],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(...ll(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...dl(t)),o.push(...sl(t)),o.push(...cl(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]}},Uu={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){let t=e;return {colspan:t.colSpan||1,rowspan:t.rowSpan||1,verticalAlign:t.dataset.valign,backgroundColor:t.dataset.bgcolor||void 0}}}],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(...ll(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...dl(t)),o.push(...sl(t)),o.push(...cl(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 ze(e){let{selection:t}=e,{$from:n}=t,o=t instanceof prosemirrorTables.CellSelection,r,i,a,s,l;for(let p=n.depth;p>0;p--){let f=n.node(p);if(f.type.name==="tableCell"||f.type.name==="tableHeader"){l=f;let m=n.node(p-1);if(m&&m.type.name==="tableRow"){let b=0,g=false;m.forEach((k,P,S)=>{g||(S===n.index(p-1)?(s=b,g=true):b+=k.attrs.colspan||1);});}}else if(f.type.name==="tableRow"){let m=n.node(p-1);m&&m.type.name==="table"&&(a=n.index(p-1));}else if(f.type.name==="table"){r=f,i=n.before(p);break}}if(!r)return {isInTable:false};let u=0,c=0;r.forEach(p=>{if(p.type.name==="tableRow"){u++;let f=0;p.forEach(m=>{f+=m.attrs.colspan||1;}),c=Math.max(c,f);}});let d=l&&((l.attrs.colspan||1)>1||(l.attrs.rowspan||1)>1);return {isInTable:true,table:r,tablePos:i,rowIndex:a,columnIndex:s,rowCount:u,columnCount:c,hasMultiCellSelection:o,canSplitCell:!!d}}function io(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 ul(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 pl(){return (e,t)=>{if(!io(e))return false;let n=ul(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,c=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(u)));t(c.scrollIntoView());}return true}if(s<r.childCount-1){let u=o.before(n.rowDepth)+i.nodeSize;if(t){let c=u+1+1+1,d=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(c)));t(d.scrollIntoView());}return true}return false}}function fl(){return (e,t)=>{if(!io(e))return false;let n=ul(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 c=u+l.nodeSize-2,d=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(c),-1));t(d.scrollIntoView());}return true}if(a>0){let s=r.child(a-1),u=o.before(n.rowDepth)-s.nodeSize;if(t){let d=u+s.nodeSize-1-1,p=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(d),-1));t(p.scrollIntoView());}return true}return false}}var Gu=$e({name:"table",schemaNodeName:"table",nodeSpec:Wu}),Ku=$e({name:"tableRow",schemaNodeName:"tableRow",nodeSpec:_u}),qu=$e({name:"tableCell",schemaNodeName:"tableCell",nodeSpec:ju}),Yu=$e({name:"tableHeader",schemaNodeName:"tableHeader",nodeSpec:Uu}),Xu=St({name:"tablePlugin",onSchemaReady(e){let{schema:t}=e;function n(...T){return (I,y,v)=>{for(let w of T)if(w(I,y,v))return true;return false}}function o(T,I={}){let y=T?.attrs??{};return {colspan:y.colspan||1,rowspan:1,colwidth:y.colwidth,width:y.width,widthType:y.widthType,verticalAlign:y.verticalAlign,backgroundColor:y.backgroundColor,borders:y.borders,margins:y.margins,textDirection:y.textDirection,noWrap:y.noWrap,...I}}function r(T,I,y="000000",v=9360){let w=[],M=Math.floor(v/I),G=360,U="atLeast",H={style:"single",size:4,color:{rgb:y}},z={top:H,bottom:H,left:H,right:H};for(let ge=0;ge<T;ge++){let fe=[];for(let se=0;se<I;se++){let O=t.nodes.paragraph.create(),ue={colspan:1,rowspan:1,borders:z,width:M,widthType:"dxa"};fe.push(t.nodes.tableCell.create(ue,O));}w.push(t.nodes.tableRow.create({height:G,heightRule:U},fe));}let $=Array(I).fill(M);return t.nodes.table.create({columnWidths:$,width:v,widthType:"dxa"},w)}function i(T,I){return (y,v)=>{let{$from:w}=y.selection,M="000000",G=y.storedMarks||w.marks();for(let H of G)if(H.type.name==="textColor"&&H.attrs.rgb){M=H.attrs.rgb;break}let U=w.pos;for(let H=w.depth;H>0;H--){let z=w.node(H);if(z.type.name==="paragraph"||z.type.name==="table"){U=w.after(H);break}}if(v){let H=9360;for(let Ve=w.depth;Ve>0;Ve--){let He=w.node(Ve);if(He.type.name==="tableCell"||He.type.name==="tableHeader"){let ve=He.attrs.width;ve&&ve>0&&(H=Math.max(ve-216,360));break}}let z=r(T,I,M,H),$=t.nodes.paragraph.create(),fe=y.doc.resolve(U).nodeBefore?.type.name==="table",se=fe?[$,z,$]:[z,$],O=y.tr.insert(U,se),ue=U+1;fe&&(ue+=$.nodeSize);let _e=ue+1+1;O.setSelection(prosemirrorState.TextSelection.create(O.doc,_e)),v(O.scrollIntoView());}return true}}function a(T,I){let y=ze(T);if(!y.isInTable||y.rowIndex===void 0||!y.table||y.tablePos===void 0)return false;if(I){let v=T.tr,w=y.table.child(y.rowIndex),M=[];w.forEach(H=>{let z=t.nodes.paragraph.create(),$=o(H);M.push(t.nodes.tableCell.create($,z));});let G=t.nodes.tableRow.create({height:w.attrs.height??360,heightRule:w.attrs.heightRule??"atLeast"},M),U=y.tablePos+1;for(let H=0;H<y.rowIndex;H++)U+=y.table.child(H).nodeSize;v.insert(U,G),I(v.scrollIntoView());}return true}function s(T,I){let y=ze(T);if(!y.isInTable||y.rowIndex===void 0||!y.table||y.tablePos===void 0)return false;if(I){let v=T.tr,w=y.table.child(y.rowIndex),M=[];w.forEach(H=>{let z=t.nodes.paragraph.create(),$=o(H);M.push(t.nodes.tableCell.create($,z));});let G=t.nodes.tableRow.create({height:w.attrs.height??360,heightRule:w.attrs.heightRule??"atLeast"},M),U=y.tablePos+1;for(let H=0;H<=y.rowIndex;H++)U+=y.table.child(H).nodeSize;v.insert(U,G),I(v.scrollIntoView());}return true}function l(T,I){let y=ze(T);if(!y.isInTable||y.rowIndex===void 0||!y.table||y.tablePos===void 0||(y.rowCount||0)<=1)return false;if(I){let v=T.tr,w=y.tablePos+1;for(let G=0;G<y.rowIndex;G++)w+=y.table.child(G).nodeSize;let M=w+y.table.child(y.rowIndex).nodeSize;v.delete(w,M),I(v.scrollIntoView());}return true}function u(T,I){let y=ze(T);if(!y.isInTable||y.columnIndex===void 0||!y.table||y.tablePos===void 0)return false;if(I){let v=T.tr,w=(y.columnCount||1)+1,M=Math.floor(100/w),G=y.tablePos+1,U=0;y.table.forEach(z=>{if(z.type.name==="tableRow"){let $=G+1,ge=0;if(z.forEach(fe=>{if(ge===y.columnIndex){let se=t.nodes.paragraph.create(),O=o(fe,{colspan:1,rowspan:1});U===0&&(O.width=M,O.widthType="pct");let ue=t.nodes.tableCell.create(O,se);v=v.insert($,ue);}$+=fe.nodeSize,ge+=fe.attrs.colspan||1;}),ge<=y.columnIndex){let fe=t.nodes.paragraph.create(),se=o(z.child(z.childCount-1)??null,{colspan:1,rowspan:1});U===0&&(se.width=M,se.widthType="pct");let O=t.nodes.tableCell.create(se,fe);v=v.insert($,O);}U++;}G+=z.nodeSize;});let H=v.doc.nodeAt(y.tablePos);if(H&&H.type.name==="table"){let z=H.child(0);if(z&&z.type.name==="tableRow"){let se=y.tablePos+2;z.forEach(O=>{(O.type.name==="tableCell"||O.type.name==="tableHeader")&&(v=v.setNodeMarkup(se,void 0,{...O.attrs,width:M,widthType:"pct"})),se+=O.nodeSize;});}let $=z?.childCount??w,ge=H.attrs.width||9360,fe=Math.floor(ge/Math.max(1,$));v=v.setNodeMarkup(y.tablePos,void 0,{...H.attrs,columnWidths:Array($).fill(fe)});}I(v.scrollIntoView());}return true}function c(T,I){let y=ze(T);if(!y.isInTable||y.columnIndex===void 0||!y.table||y.tablePos===void 0)return false;if(I){let v=T.tr,w=(y.columnCount||1)+1,M=Math.floor(100/w),G=y.tablePos+1,U=0;y.table.forEach(z=>{if(z.type.name==="tableRow"){let $=G+1,ge=0,fe=false;if(z.forEach(se=>{if($+=se.nodeSize,ge+=se.attrs.colspan||1,!fe&&ge>y.columnIndex){let O=t.nodes.paragraph.create(),ue=o(se,{colspan:1,rowspan:1});U===0&&(ue.width=M,ue.widthType="pct");let Ce=t.nodes.tableCell.create(ue,O);v=v.insert($,Ce),fe=true;}}),!fe){let se=t.nodes.paragraph.create(),O=o(z.child(z.childCount-1)??null,{colspan:1,rowspan:1});U===0&&(O.width=M,O.widthType="pct");let ue=t.nodes.tableCell.create(O,se);v=v.insert($,ue);}U++;}G+=z.nodeSize;});let H=v.doc.nodeAt(y.tablePos);if(H&&H.type.name==="table"){let z=H.child(0);if(z&&z.type.name==="tableRow"){let se=y.tablePos+2;z.forEach(O=>{(O.type.name==="tableCell"||O.type.name==="tableHeader")&&(v=v.setNodeMarkup(se,void 0,{...O.attrs,width:M,widthType:"pct"})),se+=O.nodeSize;});}let $=z?.childCount??w,ge=H.attrs.width||9360,fe=Math.floor(ge/Math.max(1,$));v=v.setNodeMarkup(y.tablePos,void 0,{...H.attrs,columnWidths:Array($).fill(fe)});}I(v.scrollIntoView());}return true}function d(T,I){let y=ze(T);if(!y.isInTable||y.columnIndex===void 0||!y.table||y.tablePos===void 0||(y.columnCount||0)<=1)return false;if(I){let v=T.tr,w=(y.columnCount||2)-1,M=Math.floor(100/w),G=[],U=y.tablePos+1;y.table.forEach(z=>{if(z.type.name==="tableRow"){let $=U+1,ge=0;z.forEach(fe=>{let se=$,O=$+fe.nodeSize,ue=fe.attrs.colspan||1;ge<=y.columnIndex&&y.columnIndex<ge+ue&&G.push({start:se,end:O}),$=O,ge+=ue;});}U+=z.nodeSize;}),G.reverse().forEach(({start:z,end:$})=>{v=v.delete(z,$);});let H=v.doc.nodeAt(y.tablePos);if(H&&H.type.name==="table"){let z=H.child(0);if(z&&z.type.name==="tableRow"){let se=y.tablePos+2;z.forEach(O=>{(O.type.name==="tableCell"||O.type.name==="tableHeader")&&(v=v.setNodeMarkup(se,void 0,{...O.attrs,width:M,widthType:"pct"})),se+=O.nodeSize;});}let $=z?.childCount??w,ge=H.attrs.width||9360,fe=Math.floor(ge/Math.max(1,$));v=v.setNodeMarkup(y.tablePos,void 0,{...H.attrs,columnWidths:Array($).fill(fe)});}I(v.scrollIntoView());}return true}function p(T,I){let y=ze(T);if(!y.isInTable||y.tablePos===void 0||!y.table)return false;if(I){let v=T.tr;v.delete(y.tablePos,y.tablePos+y.table.nodeSize),I(v.scrollIntoView());}return true}function f(T,I){let y=ze(T);if(!y.isInTable||y.tablePos===void 0||!y.table)return false;if(I){let v=y.tablePos+1,w=T.doc.resolve(v),M=T.doc.resolve(y.tablePos+y.table.nodeSize-2),G=prosemirrorTables.CellSelection.create(T.doc,w.pos,M.pos);I(T.tr.setSelection(G));}return true}function m(T,I){let y=ze(T);if(!y.isInTable||y.tablePos===void 0||!y.table||y.rowIndex===void 0)return false;if(I){let w=y.tablePos+1;for(let z=0;z<y.rowIndex;z++){let $=y.table.child(z);w+=$.nodeSize;}let M=y.table.child(y.rowIndex),G=w+1,U=w+M.nodeSize-2,H=prosemirrorTables.CellSelection.create(T.doc,G,U);I(T.tr.setSelection(H));}return true}function b(T,I){let y=ze(T);if(!y.isInTable||y.tablePos===void 0||!y.table||y.columnIndex===void 0)return false;if(I){let v=y.tablePos+1,w=y.table.child(0),M=y.table.child(y.table.childCount-1),G=v+1;for(let $=0;$<y.columnIndex&&$<w.childCount;$++)G+=w.child($).nodeSize;let U=v;for(let $=0;$<y.table.childCount-1;$++)U+=y.table.child($).nodeSize;let H=U+1;for(let $=0;$<y.columnIndex&&$<M.childCount;$++)H+=M.child($).nodeSize;let z=prosemirrorTables.CellSelection.create(T.doc,G,H);I(T.tr.setSelection(z));}return true}function g(T){let I=T.selection,y=[];if(I instanceof prosemirrorTables.CellSelection)return I.forEachCell((w,M)=>{y.push({pos:M,node:w});}),y;let{$from:v}=I;for(let w=v.depth;w>0;w--){let M=v.node(w);if(M.type.name==="tableCell"||M.type.name==="tableHeader"){y.push({pos:v.before(w),node:M});break}}return y}function k(T,I){let y=new Map,v=new Map,w=T.childCount,M=0;return T.forEach((G,U,H)=>{if(G.type.name!=="tableRow")return;let z=0;G.forEach(($,ge)=>{let fe=I+U+ge+2,se=$.attrs.colspan||1;y.set(fe,{rowIdx:H,colIdx:z,colspan:se,pos:fe,node:$}),v.set(`${H},${z}`,fe),z+=se;}),M=Math.max(M,z);}),{cellByPos:y,cellByRC:v,totalRows:w,totalCols:M}}function P(T,I){return (y,v)=>{let w=ze(y);if(!w.isInTable||w.tablePos===void 0||!w.table)return false;if(v){let M=y.tr,G=w.table,U=w.tablePos,H=I??{style:"single",size:4,color:{rgb:"000000"}},z={style:"none"},{cellByPos:$,cellByRC:ge}=k(G,U),fe=g(y),se=1/0,O=-1,ue=1/0,Ce=-1;for(let{pos:ve}of fe){let D=$.get(ve);D&&(se=Math.min(se,D.rowIdx),O=Math.max(O,D.rowIdx),ue=Math.min(ue,D.colIdx),Ce=Math.max(Ce,D.colIdx+D.colspan-1));}let _e=new Map,Ve=(ve,D)=>_e.get(ve)??{...D.attrs},He=(ve,D)=>{_e.set(ve,D);};for(let{pos:ve}of fe){let D=$.get(ve);if(!D)continue;let nt=D.rowIdx===se,Fe=D.rowIdx===O,Te=D.colIdx===ue,Ue=D.colIdx+D.colspan-1===Ce,Me;switch(T){case "all":Me={top:H,bottom:H,left:H,right:H};break;case "outside":Me={top:nt?H:z,bottom:Fe?H:z,left:Te?H:z,right:Ue?H:z};break;case "inside":Me={top:nt?z:H,bottom:Fe?z:H,left:Te?z:H,right:Ue?z:H};break;case "none":Me={top:z,bottom:z,left:z,right:z};break}let ot=Ve(ve,D.node),yt=ot.borders||{};if(He(ve,{...ot,borders:{...yt,...Me}}),Me.top){let Ne=ge.get(`${D.rowIdx-1},${D.colIdx}`);if(Ne!==void 0){let mt=$.get(Ne),Le=Ve(Ne,mt.node),at=Le.borders||{};He(Ne,{...Le,borders:{...at,bottom:Me.top}});}}if(Me.bottom){let Ne=ge.get(`${D.rowIdx+1},${D.colIdx}`);if(Ne!==void 0){let mt=$.get(Ne),Le=Ve(Ne,mt.node),at=Le.borders||{};He(Ne,{...Le,borders:{...at,top:Me.bottom}});}}if(Me.left){let Ne=ge.get(`${D.rowIdx},${D.colIdx-1}`);if(Ne!==void 0){let mt=$.get(Ne),Le=Ve(Ne,mt.node),at=Le.borders||{};He(Ne,{...Le,borders:{...at,right:Me.left}});}}if(Me.right){let Ne=ge.get(`${D.rowIdx},${D.colIdx+D.colspan}`);if(Ne!==void 0){let mt=$.get(Ne),Le=Ve(Ne,mt.node),at=Le.borders||{};He(Ne,{...Le,borders:{...at,left:Me.right}});}}}for(let[ve,D]of _e)M.setNodeMarkup(M.mapping.map(ve),void 0,D);v(M.scrollIntoView());}return true}}function S(T){return (I,y)=>{let v=ze(I);if(!v.isInTable||v.tablePos===void 0||!v.table)return false;if(y){let w=I.tr,M=g(I),G=T?T.replace(/^#/,""):null;for(let{pos:U,node:H}of M)w.setNodeMarkup(w.mapping.map(U),void 0,{...H.attrs,backgroundColor:G});y(w.scrollIntoView());}return true}}function B(T,I){return (y,v)=>{let w=ze(y);if(!w.isInTable||w.tablePos===void 0||!w.table)return false;if(v){let M=y.tr,G=g(y),U=I||{style:"none"},{cellByPos:H,cellByRC:z}=k(w.table,w.tablePos),$=new Map,ge=(O,ue)=>$.get(O)??{...ue.attrs},fe=(O,ue)=>$.set(O,ue),se={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:O,node:ue}of G){let Ce=H.get(O),_e=ge(O,ue),Ve=_e.borders||{},He=T==="all"?["top","bottom","left","right"]:[T],ve={...Ve};for(let D of He)if(ve[D]=U,Ce){let nt=se[D],Fe=D==="right"?Ce.colIdx+Ce.colspan:Ce.colIdx+nt.dCol,Te=z.get(`${Ce.rowIdx+nt.dRow},${Fe}`);if(Te!==void 0){let Ue=H.get(Te),Me=ge(Te,Ue.node),ot=Me.borders||{};fe(Te,{...Me,borders:{...ot,[nt.adjSide]:U}});}}fe(O,{..._e,borders:ve});}for(let[O,ue]of $)M.setNodeMarkup(M.mapping.map(O),void 0,ue);v(M.scrollIntoView());}return true}}function E(T){return (I,y)=>{let v=ze(I);if(!v.isInTable||v.tablePos===void 0||!v.table)return false;if(y){let w=I.tr,M=g(I);for(let{pos:G,node:U}of M)w.setNodeMarkup(w.mapping.map(G),void 0,{...U.attrs,verticalAlign:T});y(w.scrollIntoView());}return true}}function J(T){return (I,y)=>{let v=ze(I);if(!v.isInTable||v.tablePos===void 0||!v.table)return false;if(y){let w=I.tr,M=g(I);for(let{pos:G,node:U}of M){let z={...U.attrs.margins||{},...T};w.setNodeMarkup(w.mapping.map(G),void 0,{...U.attrs,margins:z});}y(w.scrollIntoView());}return true}}function Z(T){return (I,y)=>{let v=ze(I);if(!v.isInTable||v.tablePos===void 0||!v.table)return false;if(y){let w=I.tr,M=g(I);for(let{pos:G,node:U}of M)w.setNodeMarkup(w.mapping.map(G),void 0,{...U.attrs,textDirection:T});y(w.scrollIntoView());}return true}}function A(){return (T,I)=>{let y=ze(T);if(!y.isInTable||y.tablePos===void 0||!y.table)return false;if(I){let v=T.tr,w=g(T);for(let{pos:M,node:G}of w)v.setNodeMarkup(v.mapping.map(M),void 0,{...G.attrs,noWrap:!G.attrs.noWrap});I(v.scrollIntoView());}return true}}function F(T,I){return (y,v)=>{let w=ze(y);if(!w.isInTable||w.tablePos===void 0||!w.table)return false;if(v){let M=y.tr,{$from:G}=y.selection;for(let U=G.depth;U>0;U--){let H=G.node(U);if(H.type.name==="tableRow"){let z=G.before(U),$={...H.attrs,height:T,heightRule:T?I||"atLeast":null};return M.setNodeMarkup(z,void 0,$),v(M.scrollIntoView()),true}}}return true}}function R(){return (T,I)=>{let y=ze(T);if(!y.isInTable||y.tablePos===void 0||!y.table||!y.columnCount)return false;if(I){let v=T.tr,w=y.table,M=y.columnCount,G=w.attrs.columnWidths,U=G?G.reduce((ge,fe)=>ge+fe,0):9360,H=Math.floor(U/M),z=y.tablePos+1;w.forEach(ge=>{if(ge.type.name==="tableRow"){let fe=z+1;ge.forEach(se=>{(se.type.name==="tableCell"||se.type.name==="tableHeader")&&(v=v.setNodeMarkup(fe,void 0,{...se.attrs,width:H,widthType:"dxa",colwidth:null})),fe+=se.nodeSize;});}z+=ge.nodeSize;});let $=Array(M).fill(H);v=v.setNodeMarkup(y.tablePos,void 0,{...w.attrs,columnWidths:$}),I(v.scrollIntoView());}return true}}function te(){return (T,I)=>{let y=ze(T);if(!y.isInTable||y.tablePos===void 0||!y.table)return false;if(I){let v=T.tr,w=y.table,M=y.tablePos+1;w.forEach(G=>{if(G.type.name==="tableRow"){let U=M+1;G.forEach(H=>{(H.type.name==="tableCell"||H.type.name==="tableHeader")&&(v=v.setNodeMarkup(U,void 0,{...H.attrs,width:null,widthType:null,colwidth:null})),U+=H.nodeSize;});}M+=G.nodeSize;}),v=v.setNodeMarkup(y.tablePos,void 0,{...w.attrs,columnWidths:null,width:null,widthType:"auto"}),I(v.scrollIntoView());}return true}}function re(T){return (I,y)=>{let v=ze(I);if(!v.isInTable||v.tablePos===void 0||!v.table)return false;if(y){let w=I.tr,M=v.table,G=v.tablePos,U=M.childCount,H=T.look??{firstRow:true,lastRow:false,noHBand:false},z=T.conditionals??{},$=T.tableBorders;w=w.setNodeMarkup(G,void 0,{...M.attrs,styleId:T.styleId});let ge=0,fe=G+1;for(let se=0;se<U;se++){let O=M.child(se),ue=se===0&&!!H.firstRow,Ce=se===U-1&&!!H.lastRow,_e=H.noHBand!==true,Ve=O.childCount,He;ue?He="firstRow":Ce?He="lastRow":(_e&&(He=ge%2===0?"band1Horz":"band2Horz"),ge++);let ve=fe+1;for(let D=0;D<Ve;D++){let nt=O.child(D),Fe=w.mapping.map(ve),Te=He,Ue=D===0&&!!H.firstCol,Me=D===Ve-1&&!!H.lastCol;ue&&Ue&&z.nwCell?Te="nwCell":ue&&Me&&z.neCell?Te="neCell":Ce&&Ue&&z.swCell?Te="swCell":Ce&&Me&&z.seCell?Te="seCell":Ue?Te="firstCol":Me&&(Te="lastCol");let ot=Te?z[Te]:void 0,yt={...nt.attrs};ot?.backgroundColor?yt.backgroundColor=ot.backgroundColor:yt.backgroundColor=null;let Ne={},mt=["top","bottom","left","right"];for(let Le of mt)ot?.borders&&ot.borders[Le]!==void 0?Ne[Le]=ot.borders[Le]:$&&(Le==="top"&&se>0||Le==="bottom"&&se<U-1?Ne[Le]=$.insideH??$[Le]:Le==="left"&&D>0||Le==="right"&&D<Ve-1?Ne[Le]=$.insideV??$[Le]:Ne[Le]=$[Le]);Object.keys(Ne).length>0?yt.borders=Ne:yt.borders=null,w=w.setNodeMarkup(Fe,void 0,yt),ve+=nt.nodeSize;}fe+=O.nodeSize;}y(w.scrollIntoView());}return true}}function Q(T){return (I,y)=>{let v=ze(I);if(!v.isInTable||v.tablePos===void 0||!v.table)return false;if(y){let w=I.tr,M={...v.table.attrs};"width"in T&&(M.width=T.width),"widthType"in T&&(M.widthType=T.widthType),"justification"in T&&(M.justification=T.justification),w.setNodeMarkup(v.tablePos,void 0,M),y(w.scrollIntoView());}return true}}function pe(){return (T,I)=>{let y=ze(T);if(!y.isInTable||y.tablePos===void 0||!y.table)return false;if(I){let v=T.tr,{$from:w}=T.selection;for(let M=w.depth;M>0;M--){let G=w.node(M);if(G.type.name==="tableRow"){let U=w.before(M),H={...G.attrs,isHeader:!G.attrs.isHeader};return v.setNodeMarkup(U,void 0,H),I(v.scrollIntoView()),true}}}return true}}function L(T){return (I,y)=>{let v=ze(I);if(!v.isInTable||v.tablePos===void 0||!v.table)return false;if(y){let w=I.tr,M=g(I),G=T.replace(/^#/,""),U={style:"single",size:4},{cellByPos:H,cellByRC:z}=k(v.table,v.tablePos),$=new Map,ge=(O,ue)=>$.get(O)??{...ue.attrs},fe=(O,ue)=>$.set(O,ue),se={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:O,node:ue}of M){let Ce=H.get(O),_e=ge(O,ue),Ve=_e.borders||{},He={};for(let ve of ["top","bottom","left","right"]){let D={...U,...Ve[ve],color:{rgb:G}};if(He[ve]=D,Ce){let nt=se[ve],Fe=ve==="right"?Ce.colIdx+Ce.colspan:Ce.colIdx+nt.dCol,Te=z.get(`${Ce.rowIdx+nt.dRow},${Fe}`);if(Te!==void 0){let Ue=H.get(Te),Me=ge(Te,Ue.node),ot=Me.borders||{};fe(Te,{...Me,borders:{...ot,[nt.adjSide]:D}});}}}fe(O,{..._e,borders:{...Ve,...He}});}for(let[O,ue]of $)w.setNodeMarkup(w.mapping.map(O),void 0,ue);y(w.scrollIntoView());}return true}}function N(T){return (I,y)=>{let v=ze(I);if(!v.isInTable||v.tablePos===void 0||!v.table)return false;if(y){let w=I.tr,M=g(I),G={style:"single",color:{rgb:"000000"}},{cellByPos:U,cellByRC:H}=k(v.table,v.tablePos),z=new Map,$=(se,O)=>z.get(se)??{...O.attrs},ge=(se,O)=>z.set(se,O),fe={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:se,node:O}of M){let ue=U.get(se),Ce=$(se,O),_e=Ce.borders||{},Ve={};for(let He of ["top","bottom","left","right"]){let ve={...G,..._e[He],size:T};if(Ve[He]=ve,ue){let D=fe[He],nt=He==="right"?ue.colIdx+ue.colspan:ue.colIdx+D.dCol,Fe=H.get(`${ue.rowIdx+D.dRow},${nt}`);if(Fe!==void 0){let Te=U.get(Fe),Ue=$(Fe,Te.node),Me=Ue.borders||{};ge(Fe,{...Ue,borders:{...Me,[D.adjSide]:ve}});}}}ge(se,{...Ce,borders:{..._e,...Ve}});}for(let[se,O]of z)w.setNodeMarkup(w.mapping.map(se),void 0,O);y(w.scrollIntoView());}return true}}function Y(){return (T,I)=>{let y=T.selection;if(!("$anchorCell"in y&&typeof y.forEachCell=="function"))return false;let w=ze(T);if(!w.isInTable||w.tablePos===void 0||!w.table)return false;let M=0;w.table.descendants(H=>{(H.type.name==="tableCell"||H.type.name==="tableHeader")&&(M+=1);});let G=0;if(y.forEachCell(()=>{G+=1;}),!(M>0&&G>=M))return false;if(I){let H=T.tr.delete(w.tablePos,w.tablePos+w.table.nodeSize);I(H.scrollIntoView());}return true}}function xe(){return T=>{let{$from:I,empty:y}=T.selection;if(!y)return false;let v=I.parent;if(v.type.name!=="paragraph"||v.textContent.length>0)return false;let w=I.depth;if(w<1)return false;let M=I.node(w-1),G=I.index(w-1),U=G>0?M.child(G-1):null,H=G+1<M.childCount?M.child(G+1):null,z=U?.type.name==="table",$=H?.type.name==="table";return !!(z||$)}}let le=new prosemirrorState.PluginKey("activeCell"),Re=new prosemirrorState.Plugin({key:le,props:{decorations(T){let{selection:I}=T;if(I instanceof prosemirrorTables.CellSelection)return prosemirrorView.DecorationSet.empty;let{$from:y}=I;for(let v=y.depth;v>0;v--){let w=y.node(v);if(w.type.name==="tableCell"||w.type.name==="tableHeader"){let M=y.before(v);return prosemirrorView.DecorationSet.create(T.doc,[prosemirrorView.Decoration.node(M,M+w.nodeSize,{class:"activeCell"})])}}return prosemirrorView.DecorationSet.empty}}});return {plugins:[prosemirrorTables.columnResizing({handleWidth:5,cellMinWidth:25,lastColumnResizable:true}),prosemirrorTables.tableEditing(),Re],keyboardShortcuts:{Backspace:n(Y(),xe()),Delete:n(Y(),xe())},commands:{insertTable:(T,I)=>i(T,I),addRowAbove:()=>a,addRowBelow:()=>s,deleteRow:()=>l,addColumnLeft:()=>u,addColumnRight:()=>c,deleteColumn:()=>d,deleteTable:()=>p,selectTable:()=>f,selectRow:()=>m,selectColumn:()=>b,mergeCells:()=>prosemirrorTables.mergeCells,splitCell:()=>prosemirrorTables.splitCell,setCellBorder:(T,I)=>B(T,I),setTableBorders:(T,I)=>P(T,I),setCellVerticalAlign:T=>E(T),setCellMargins:T=>J(T),setCellTextDirection:T=>Z(T),toggleNoWrap:()=>A(),setRowHeight:(T,I)=>F(T,I),toggleHeaderRow:()=>pe(),distributeColumns:()=>R(),autoFitContents:()=>te(),setTableProperties:T=>Q(T),applyTableStyle:T=>re(T),setCellFillColor:T=>S(T),setTableBorderColor:T=>L(T),setTableBorderWidth:T=>N(T),removeTableBorders:()=>P("none"),setAllTableBorders:T=>P("all",T),setOutsideTableBorders:T=>P("outside",T),setInsideTableBorders:T=>P("inside",T)}}}});function ml(){return [Gu(),Ku(),qu(),Yu(),Xu()]}function Vi(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}function gl(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,(c,d)=>{if(c.type.name==="paragraph"&&!u.has(d))if(u.add(d),s)l=l.setNodeMarkup(d,void 0,{...c.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});else {let p=e===1;l=l.setNodeMarkup(d,void 0,{...c.attrs,numPr:{numId:e,ilvl:c.attrs.numPr?.ilvl||0},listIsBullet:p,listNumFmt:p?null:"decimal",listMarker:null});}}),n(l.scrollIntoView()),true}}var Zu=(e,t)=>gl(1)(e,t),Ju=(e,t)=>gl(2)(e,t),Qu=(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},ep=(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},tp=(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 np(){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 op(){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 rp(){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 ip(){return (e,t)=>{let{$from:n}=e.selection,o=n.parent;if(o.type.name!=="paragraph")return false;let r=o.attrs.numPr;if(!r)return false;let i=r.ilvl??0;if(i>=8)return false;if(t){let a=e.tr.setNodeMarkup(n.before(),void 0,{...o.attrs,numPr:{...r,ilvl:i+1},indentLeft:null,indentFirstLine:null,hangingIndent:null});t(a);}return true}}function ap(){return (e,t)=>{let{$from:n}=e.selection,o=n.parent;if(o.type.name!=="paragraph")return false;let r=o.attrs.numPr;if(!r)return false;let i=r.ilvl??0;if(i<=0){if(t){let a=e.tr.setNodeMarkup(n.before(),void 0,{...o.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null,indentLeft:null,indentFirstLine:null,hangingIndent:null});t(a);}return true}if(t){let a=e.tr.setNodeMarkup(n.before(),void 0,{...o.attrs,numPr:{...r,ilvl:i-1},indentLeft:null,indentFirstLine:null,hangingIndent:null});t(a);}return true}}function sp(){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 hl=St({name:"list",priority:on.High,onSchemaReady(){return {commands:{toggleBulletList:()=>Zu,toggleNumberedList:()=>Ju,increaseListLevel:()=>Qu,decreaseListLevel:()=>ep,removeList:()=>tp},keyboardShortcuts:{Tab:Vi(pl(),ip(),sp()),"Shift-Tab":Vi(fl(),ap()),"Shift-Enter":()=>false,Enter:Vi(np(),op()),Backspace:rp()}}}});function yl(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}var mp=(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},gp=(e,t,n)=>{if(!prosemirrorCommands.splitBlock(e,t,n))return false;if(t&&n){let o=n.state,{$from:r}=o.selection,i=r.parent;if(i.type.name==="paragraph"&&i.attrs.borders){let a=r.before(),s=o.tr.setNodeMarkup(a,void 0,{...i.attrs,borders:null});t(s.scrollIntoView());}}return true},xl=St({name:"baseKeymap",priority:on.Low,onSchemaReady(e){return {keyboardShortcuts:{...prosemirrorCommands.baseKeymap,Enter:gp,Backspace:yl(prosemirrorCommands.deleteSelection,mp,prosemirrorCommands.joinBackward),Delete:yl(prosemirrorCommands.deleteSelection,prosemirrorCommands.joinForward),"Mod-a":prosemirrorCommands.selectAll,Escape:prosemirrorCommands.selectParentNode}}}});var yp=new prosemirrorState.PluginKey("selectionTracker");function ao(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,k,P)=>{k<=o&&(s=P),k<=r&&(l=P);});let u=xp(e),c=a.parent,d={};c.type.name==="paragraph"&&(c.attrs.alignment&&(d.alignment=c.attrs.alignment),c.attrs.lineSpacing&&(d.lineSpacing=c.attrs.lineSpacing,d.lineSpacingRule=c.attrs.lineSpacingRule),c.attrs.indentLeft&&(d.indentLeft=c.attrs.indentLeft),c.attrs.indentRight&&(d.indentRight=c.attrs.indentRight),c.attrs.indentFirstLine&&(d.indentFirstLine=c.attrs.indentFirstLine),c.attrs.hangingIndent&&(d.hangingIndent=c.attrs.hangingIndent),c.attrs.tabs&&(d.tabs=c.attrs.tabs),c.attrs.numPr&&(d.numPr=c.attrs.numPr));let p=c.attrs?.numPr,f=!!p?.numId,m=p?.numId===1?"bullet":p?.numId?"numbered":void 0,b=p?.ilvl;return {hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:d,startParagraphIndex:s,endParagraphIndex:l,inList:f,listType:m,listLevel:b}}function xp(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 Sl(e){return new prosemirrorState.Plugin({key:yp,state:{init(t,n){return ao(n)},apply(t,n,o,r){if(!t.selectionSet&&!t.docChanged)return n;let i=ao(r);return e&&!Sp(n,i)&&setTimeout(()=>e(i),0),i}},view(){return {update(t,n){if(t.state.selection.eq(n.selection)&&t.state.doc.eq(n.doc))return;let o=ao(t.state);e&&e(o);}}}})}function Sp(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&&JSON.stringify(e.textFormatting)===JSON.stringify(t.textFormatting)&&JSON.stringify(e.paragraphFormatting)===JSON.stringify(t.paragraphFormatting)}var kl=St({name:"selectionTracker",defaultOptions:{},onSchemaReady(e,t){return {plugins:[Sl(t.onSelectionChange)],commands:{extractSelectionContext:()=>(n,o)=>(ao(n),true)}}}});var Cp=new prosemirrorState.PluginKey("imageDrag"),Cl=St({name:"imageDrag",onSchemaReady(e){return {plugins:[new prosemirrorState.Plugin({key:Cp,props:{handleDOMEvents:{dragstart(n,o){let{selection:r}=n.state;if(r instanceof prosemirrorState.NodeSelection&&r.node.type.name==="image"){n.dom.classList.add("pm-image-dragging");let i=o;if(i.dataTransfer){i.dataTransfer.effectAllowed="move";let a=document.createElement("div");a.style.cssText="position: fixed; left: -9999px; top: -9999px; opacity: 0.6; pointer-events: none; border: 2px dashed var(--doc-primary, #2563eb); border-radius: 4px; background: rgba(37, 99, 235, 0.08);",a.style.width=`${r.node.attrs.width||100}px`,a.style.height=`${r.node.attrs.height||100}px`,document.body.appendChild(a),i.dataTransfer.setDragImage(a,0,0),requestAnimationFrame(()=>{document.body.removeChild(a);});}}return false},dragend(n){return n.dom.classList.remove("pm-image-dragging"),n.dom.querySelectorAll(".pm-drop-indicator").forEach(r=>r.remove()),false},dragover(n,o){let{selection:r}=n.state;if(r instanceof prosemirrorState.NodeSelection&&r.node.type.name==="image"){let i=o;i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="move");}return false},drop(n){return n.dom.classList.remove("pm-image-dragging"),n.dom.querySelectorAll(".pm-drop-indicator").forEach(r=>r.remove()),false}}}})]}}});var Tl=St({name:"dropCursor",onSchemaReady(){return {plugins:[prosemirrorDropcursor.dropCursor({color:"var(--doc-primary, #4285f4)",width:2})]}}});function On(e={}){let t=new Set(e.disable||[]),n=[];function o(r,i){t.has(r)||n.push(i);}return o("doc",ps()),o("text",fs()),o("paragraph",ks()),o("history",Cs({depth:e.historyDepth,newGroupDelay:e.historyNewGroupDelay})),o("bold",Rs()),o("italic",Ps()),o("underline",Is()),o("strike",Fs()),o("textColor",Ls()),o("highlight",Bs()),o("fontSize",As()),o("fontFamily",Ds()),o("superscript",Hs()),o("subscript",Ns()),o("hyperlink",zs()),o("allCaps",Os()),o("smallCaps",$s()),o("footnoteRef",Ws()),o("characterSpacing",_s()),o("emboss",Gs()),o("imprint",Ks()),o("textShadow",qs()),o("emphasisMark",Ys()),o("textOutline",Xs()),o("comment",Vs()),o("insertion",js()),o("deletion",Us()),o("hardBreak",Zs()),o("tab",Js()),o("image",Qs()),o("textBox",el()),o("shape",tl()),o("imageDrag",Cl()),o("dropCursor",Tl()),o("horizontalRule",nl()),o("pageBreak",ol()),o("field",rl()),o("sdt",il()),o("math",al()),t.has("table")||n.push(...ml()),o("list",hl()),o("baseKeymap",xl()),o("selectionTracker",kl({onSelectionChange:e.onSelectionChange})),n}var rn=class{constructor(t){chunkRTESADL3_cjs.e(this,"extensions");chunkRTESADL3_cjs.e(this,"schema",null);chunkRTESADL3_cjs.e(this,"plugins",[]);chunkRTESADL3_cjs.e(this,"commands",{});this.extensions=[...t].sort((n,o)=>n.config.priority-o.config.priority);}buildSchema(){let t={},n={};for(let o of this.extensions)o.type==="node"?t[o.config.schemaNodeName]=o.config.nodeSpec:o.type==="mark"&&(n[o.config.schemaMarkName]=o.config.markSpec);this.schema=new prosemirrorModel.Schema({nodes:t,marks:n});}initializeRuntime(){if(!this.schema)throw new Error("ExtensionManager: buildSchema() must be called before initializeRuntime()");let t={schema:this.schema},n=[],o=[],r={};for(let i of this.extensions){let a=i.onSchemaReady(t);a.commands&&Object.assign(r,a.commands),a.keyboardShortcuts&&n.push(a.keyboardShortcuts),a.plugins&&o.push(...a.plugins);}this.plugins=[...o,...n.map(i=>prosemirrorKeymap.keymap(i))],this.commands=r;}getSchema(){if(!this.schema)throw new Error("ExtensionManager: buildSchema() must be called first");return this.schema}getPlugins(){return this.plugins}getCommands(){return this.commands}getCommand(t){return this.commands[t]}destroy(){this.plugins=[],this.commands={};}};var zo=new rn(On());zo.buildSchema();zo.initializeRuntime();var $n=zo,he=zo.getSchema();var so=class{constructor(t){chunkRTESADL3_cjs.e(this,"stylesById");chunkRTESADL3_cjs.e(this,"docDefaults");chunkRTESADL3_cjs.e(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")}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 an(e){return new so(e)}function ji(e,t){let n=e.package.document.content,o=[],r=t?.styles?an(t.styles):null;for(let i of n)if(i.type==="paragraph"){let a=vl(i),s=$o(i,r);o.push(s);for(let l of a)o.push(Pl(l,r));zp(i)&&o.push(he.node("pageBreak"));}else if(i.type==="table"){let a=Ui(i,r);o.push(a);}return o.length===0&&o.push(he.node("paragraph",{},[])),he.node("doc",null,o)}function $o(e,t,n,o){let r=Ep(e,t),i=[],a,s=new Set,l;t&&(l=t.resolveParagraphStyle(e.formatting?.styleId).runFormatting);let u=jt(l,o);for(let c of e.content){if(c.type==="commentRangeStart")s.add(c.id);else if(c.type==="commentRangeEnd")s.delete(c.id);else if(c.type==="run"){let d=Gi(c,u,t);s.size>0&&(d=Pp(d,s)),i.push(...d);}else if(c.type==="hyperlink"){let d=Ki(c,u,t);i.push(...d);}else if(c.type==="simpleField"||c.type==="complexField"){let d=Lp(c,u);d&&i.push(d);}else if(c.type==="inlineSdt"){let d=Ap(c,u,t);d&&i.push(d);}else if(c.type==="insertion"){let d=Rl(c,"insertion",u,t);i.push(...d);}else if(c.type==="deletion"){let d=Rl(c,"deletion",u,t);i.push(...d);}else if(c.type==="mathEquation"){let d=Bp(c);d&&i.push(d);}c.type==="bookmarkStart"&&(a||(a=[]),a.push({id:c.id,name:c.name}));}return a&&(r.bookmarks=a),he.node("paragraph",r,i)}function Pp(e,t){if(t.size===0)return e;let n=[...t][0],o=he.marks.comment.create({commentId:n});return e.map(r=>r.isText?r.mark(o.addToSet(r.marks)):r)}function Rl(e,t,n,o){let r=[];for(let a of e.content)a.type==="run"?r.push(...Gi(a,n,o)):a.type==="hyperlink"&&r.push(...Ki(a,n,o));let i=he.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 Ep(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,_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;let l=Oo(n?.runProperties,t);if(r.defaultTextFormatting=jt(s,l),e.sectionProperties?.sectionStart){let u=e.sectionProperties.sectionStart;(u==="nextPage"||u==="continuous"||u==="oddPage"||u==="evenPage")&&(r.sectionBreakType=u);}!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.defaultTextFormatting=Oo(n?.runProperties,t);if(e.sectionProperties?.sectionStart){let i=e.sectionProperties.sectionStart;(i==="nextPage"||i==="continuous"||i==="oddPage"||i==="evenPage")&&(r.sectionBreakType=i);}return r}function Ct(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=Oo(r.pPr?.runProperties,e),a=Oo(r.rPr,e),s=jt(i,a);return {tcPr:r.tcPr,rPr:s}}function Vt(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=jt(e.rPr,t.rPr),n}function Oo(e,t){if(!e)return;if(!e.styleId||!t)return e;let n=t.resolveRunStyle(e.styleId);return jt(n,e)}function Mp(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,c=l.formatting?.vMerge,d=`${r}-${a}`;if(c==="restart")o.set(a,r),t.set(d,{rowSpan:1,skip:false});else if(c==="continue"){let p=o.get(a);if(p!==void 0){let f=`${p}-${a}`,m=t.get(f);m&&m.rowSpan++;}t.set(d,{rowSpan:1,skip:true});}else o.delete(a),t.set(d,{rowSpan:1,skip:false});a+=u;}}return t}function Ui(e,t){let n=Mp(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,c=u?{top:u.top?.value,bottom:u.bottom?.value,left:u.left?.value,right:u.right?.value}:void 0,d={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:c,look:e.formatting?.look,_originalFormatting:e.formatting||void 0},p={wholeTable:Ct(t,i,"wholeTable"),firstRow:Ct(t,i,"firstRow"),lastRow:Ct(t,i,"lastRow"),firstCol:Ct(t,i,"firstCol"),lastCol:Ct(t,i,"lastCol"),band1Horz:Ct(t,i,"band1Horz"),band2Horz:Ct(t,i,"band2Horz"),band1Vert:Ct(t,i,"band1Vert"),band2Vert:Ct(t,i,"band2Vert"),nwCell:Ct(t,i,"nwCell"),neCell:Ct(t,i,"neCell"),swCell:Ct(t,i,"swCell"),seCell:Ct(t,i,"seCell")},f=a?.noHBand!==true,m=a?.noVBand!==true,b=0,g=e.rows.length,k=o?.length??e.rows[0]?.cells.reduce((S,B)=>S+(B.formatting?.gridSpan??1),0)??0,P=e.rows.map((S,B)=>{let E=B===0&&!!a?.firstRow,J=B===g-1&&!!a?.lastRow,Z=f&&!E&&!J?b%2===0?p.band1Horz:p.band2Horz:void 0;return f&&!E&&!J&&b++,Ip(S,t,E,o,r,p,Z,m,a,l,B,g,k,n,c)});return he.node("table",d,P)}function Ip(e,t,n,o,r,i,a,s,l,u,c,d,p,f,m){let b={height:e.formatting?.height?.value,heightRule:e.formatting?.heightRule,isHeader:n||e.formatting?.header,_originalFormatting:e.formatting||void 0},g=e.cells.length,k=c===0,P=c===(d??1)-1,S=e.formatting?.conditionalFormat,B=S?.firstRow??k,E=S?.lastRow??P,J=p??g,Z=0,A=[];for(let F=0;F<e.cells.length;F++){let R=e.cells[F],te=R.formatting?.gridSpan??1,re=`${c??0}-${Z}`,Q=f?.get(re),pe=Q?.skip??false,L=Q?.rowSpan??1,N;if(o&&r&&r>0){let G=0;for(let U=0;U<te&&Z+U<o.length;U++)G+=o[Z+U];N=Math.round(G/r*100);}if(Z+=te,pe)continue;let Y=Z-te===0,xe=Z===J,le=R.formatting?.conditionalFormat,Re=le?.firstRow??B,T=le?.lastRow??E,I=le?.firstColumn??Y,y=le?.lastColumn??xe,v;if(s){let G=l?.firstColumn?1:0,U=Z-te-G;U>=0&&!(l?.lastColumn&&y)&&!(l?.firstColumn&&I)&&(v=U%2===0?i?.band1Vert:i?.band2Vert);}le?.oddVBand?v=i?.band1Vert:le?.evenVBand&&(v=i?.band2Vert);let w=a;S?.oddHBand?w=i?.band1Horz:S?.evenHBand&&(w=i?.band2Horz),le?.oddHBand?w=i?.band1Horz:le?.evenHBand&&(w=i?.band2Horz);let M=i?.wholeTable;M=Vt(M,w),M=Vt(M,v),Re&&(l?.firstRow||S?.firstRow||le?.firstRow)&&(M=Vt(M,i?.firstRow)),T&&(l?.lastRow||S?.lastRow||le?.lastRow)&&(M=Vt(M,i?.lastRow)),I&&(l?.firstColumn||S?.firstColumn||le?.firstColumn)&&(M=Vt(M,i?.firstCol)),y&&(l?.lastColumn||S?.lastColumn||le?.lastColumn)&&(M=Vt(M,i?.lastCol)),Re&&I&&(l?.firstRow||S?.firstRow||le?.firstRow)&&(l?.firstColumn||S?.firstColumn||le?.firstColumn)&&(M=Vt(M,i?.nwCell)),Re&&y&&(l?.firstRow||S?.firstRow||le?.firstRow)&&(l?.lastColumn||S?.lastColumn||le?.lastColumn)&&(M=Vt(M,i?.neCell)),T&&I&&(l?.lastRow||S?.lastRow||le?.lastRow)&&(l?.firstColumn||S?.firstColumn||le?.firstColumn)&&(M=Vt(M,i?.swCell)),T&&y&&(l?.lastRow||S?.lastRow||le?.lastRow)&&(l?.lastColumn||S?.lastColumn||le?.lastColumn)&&(M=Vt(M,i?.seCell)),A.push(Fp(R,t,n,N,M,u,k,P,Y,xe,L,m));}return he.node("tableRow",b,A)}function Fp(e,t,n,o,r,i,a,s,l,u,c,d){let p=e.formatting,f=c??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,k=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,P=r?.tcPr?.borders,S=p?.borders,B=k||P||S?{...k??{},...P??{},...S??{}}:void 0,E={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}:d,_originalFormatting:p||void 0},J=[];for(let A of e.content)A.type==="paragraph"?J.push($o(A,t,void 0,r?.rPr)):A.type==="table"&&J.push(Ui(A,t));J.length===0&&J.push(he.node("paragraph",{},[]));let Z=n?"tableHeader":"tableCell";return he.node(Z,E,J)}function Lp(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=jt(t,o),a=qi(i);return he.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 Bp(e){return he.node("math",{display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""})}function Ap(e,t,n){let o=e.properties,r=[];for(let i of e.content)if(i.type==="run"){let a=Gi(i,t,n);r.push(...a);}else if(i.type==="hyperlink"){let a=Ki(i,t,n);r.push(...a);}return he.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 Gi(e,t,n){let o=[],r=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0,i=jt(jt(t,r),e.formatting),a=qi(i);for(let s of e.content){let l=Dp(s,a);o.push(...l);}return o}function jt(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 Dp(e,t){switch(e.type){case "text":return e.text?[he.text(e.text,t)]:[];case "break":return e.breakType==="textWrapping"||!e.breakType?[he.node("hardBreak")]:[];case "tab":return [he.node("tab")];case "drawing":return e.image?[Hp(e.image)]:[];case "shape":{let r=e.shape;return r.textBody&&r.textBody.content.length>0?[]:[Np(r)]}case "footnoteRef":let n=he.mark("footnoteRef",{id:e.id.toString(),noteType:"footnote"});return [he.text(e.id.toString(),[...t,n])];case "endnoteRef":let o=he.mark("footnoteRef",{id:e.id.toString(),noteType:"endnote"});return [he.text(e.id.toString(),[...t,o])];default:return []}}function Hp(e){let t=e.size?.width?chunkEPCZ24TY_cjs.a(e.size.width):void 0,n=e.size?.height?chunkEPCZ24TY_cjs.a(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 k=[];e.transform.rotation&&k.push(`rotate(${e.transform.rotation}deg)`),e.transform.flipH&&k.push("scaleX(-1)"),e.transform.flipV&&k.push("scaleY(-1)"),k.length>0&&(l=k.join(" "));}let u=e.wrap.distT?chunkEPCZ24TY_cjs.a(e.wrap.distT):void 0,c=e.wrap.distB?chunkEPCZ24TY_cjs.a(e.wrap.distB):void 0,d=e.wrap.distL?chunkEPCZ24TY_cjs.a(e.wrap.distL):void 0,p=e.wrap.distR?chunkEPCZ24TY_cjs.a(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 k={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&&k[e.outline.style]||"solid";}return he.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:c,distLeft:d,distRight:p,position:f,borderWidth:m,borderColor:b,borderStyle:g,wrapText:r})}function Ki(e,t,n){let o=[],r=e.href||(e.anchor?`#${e.anchor}`:""),i=he.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=jt(jt(t,s),a.formatting),c=[...qi(l),i];for(let d of a.content)d.type==="text"&&d.text&&o.push(he.text(d.text,c));}return o}function qi(e){if(!e)return [];let t=[];return e.bold&&t.push(he.mark("bold")),e.italic&&t.push(he.mark("italic")),e.underline&&e.underline.style!=="none"&&t.push(he.mark("underline",{style:e.underline.style,color:e.underline.color})),(e.strike||e.doubleStrike)&&t.push(he.mark("strike",{double:e.doubleStrike||false})),e.color&&!e.color.auto&&t.push(he.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(he.mark("highlight",{color:e.highlight})),e.fontSize&&t.push(he.mark("fontSize",{size:e.fontSize})),e.fontFamily&&t.push(he.mark("fontFamily",{ascii:e.fontFamily.ascii,hAnsi:e.fontFamily.hAnsi,asciiTheme:e.fontFamily.asciiTheme})),e.vertAlign==="superscript"?t.push(he.mark("superscript")):e.vertAlign==="subscript"&&t.push(he.mark("subscript")),e.allCaps&&t.push(he.mark("allCaps")),e.smallCaps&&t.push(he.mark("smallCaps")),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&t.push(he.mark("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null})),e.emboss&&t.push(he.mark("emboss")),e.imprint&&t.push(he.mark("imprint")),e.shadow&&t.push(he.mark("textShadow")),e.emphasisMark&&e.emphasisMark!=="none"&&t.push(he.mark("emphasisMark",{type:e.emphasisMark})),e.outline&&t.push(he.mark("textOutline")),t}function Np(e){let t=e.size?.width?chunkEPCZ24TY_cjs.a(e.size.width):100,n=e.size?.height?chunkEPCZ24TY_cjs.a(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,c;e.outline&&(e.outline.width&&(l=Math.round(e.outline.width/914400*96*100)/100),e.outline.color?.rgb&&(u=`#${e.outline.color.rgb}`),c=e.outline.style||"solid");let d;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&&(d=p.join(" "));}return he.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:c,transform:d})}function vl(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 Pl(e,t){let n=e.size?.width?chunkEPCZ24TY_cjs.a(e.size.width):200,o=e.size?.height?chunkEPCZ24TY_cjs.a(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?chunkEPCZ24TY_cjs.a(e.margins.top):4,u=e.margins?.bottom!=null?chunkEPCZ24TY_cjs.a(e.margins.bottom):4,c=e.margins?.left!=null?chunkEPCZ24TY_cjs.a(e.margins.left):7,d=e.margins?.right!=null?chunkEPCZ24TY_cjs.a(e.margins.right):7,p=[];for(let f of e.content)p.push($o(f,t));return p.length===0&&p.push(he.node("paragraph",{},[])),he.node("textBox",{width:n,height:o,textBoxId:e.id,fillColor:r,outlineWidth:i,outlineColor:a,outlineStyle:s,marginTop:l,marginBottom:u,marginLeft:c,marginRight:d},p)}function Yi(e,t){let n=[],o=t?.styles?an(t.styles):null;for(let r of e)if(r.type==="paragraph"){let i=vl(r);n.push($o(r,o));for(let a of i)n.push(Pl(a,o));}else r.type==="table"&&n.push(Ui(r,o));return n.length===0&&n.push(he.node("paragraph",{},[])),he.node("doc",null,n)}function zp(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 Xi(){return he.node("doc",null,[he.node("paragraph",{},[])])}function Ml(e,t){let o={content:Il(e),finalSectionProperties:t?.package.document.finalSectionProperties,sections:t?.package.document.sections};return t?{...t,package:{...t.package,document:o}}:{package:{document:o}}}function Il(e){let t=[];return e.forEach(n=>{n.type.name==="paragraph"?t.push(Zi(n)):n.type.name==="table"?t.push(Bl(n)):n.type.name==="textBox"?t.push(af(n)):n.type.name==="pageBreak"&&t.push(Op());}),t}function Op(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function Zi(e){let t=e.attrs,n=$p(Fl(e),e),o=t.bookmarks;if(o&&o.length>0){let i=o.map(s=>({type:"bookmarkStart",id:s.id,name:s.name})),a=o.map(s=>({type:"bookmarkEnd",id:s.id}));n=[...i,...n,...a];}let r={type:"paragraph",paraId:t.paraId||void 0,textId:t.textId||void 0,formatting:Wp(t),content:n};return t.sectionBreakType&&(r.sectionProperties={sectionStart:t.sectionBreakType}),r}function $p(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 s)r.has(l)||(o.push({type:"commentRangeStart",id:l}),r.add(l));i<e.length&&o.push(e[i]);for(let l of r)s.has(l)||(o.push({type:"commentRangeEnd",id:l}),r.delete(l));i++;});for(let a of r)o.push({type:"commentRangeEnd",id:a});return o}function Wp(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),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)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}}function Fl(e){let t=[],n=null,o=null,r=null;return e.forEach(i=>{let a=i.marks.find(c=>c.type.name==="footnoteRef");if(a){n&&(t.push(n),n=null,o=null),r&&(t.push(r),r=null);let d={type:a.attrs.noteType==="endnote"?"endnoteRef":"footnoteRef",id:parseInt(a.attrs.id,10)||0};t.push({type:"run",content:[d]});return}let s=i.marks.find(c=>c.type.name==="insertion"),l=i.marks.find(c=>c.type.name==="deletion");if(s||l){n&&(t.push(n),n=null,o=null),r&&(t.push(r),r=null);let c=s||l,d=i.marks.filter(b=>b.type.name!=="insertion"&&b.type.name!=="deletion"),p=Ji(d),f={type:"run",content:i.isText&&i.text?[{type:"text",text:i.text}]:[],...Object.keys(p).length>0?{formatting:p}:{}},m={id:c.attrs.revisionId,author:c.attrs.author||"Unknown",date:c.attrs.date||void 0};s?t.push({type:"insertion",info:m,content:[f]}):t.push({type:"deletion",info:m,content:[f]});return}let u=i.marks.find(c=>c.type.name==="hyperlink");if(u){let c=_p(u),d=r?.href||(r?.anchor?`#${r.anchor}`:"");r&&d===c||(n&&(t.push(n),n=null,o=null),r&&t.push(r),r=jp(u)),El(r,i);return}if(r&&(t.push(r),r=null),i.isText){let c=Vp(i.marks);n&&o===c?Up(n,i.text||""):(n&&t.push(n),n=Ll(i.text||"",i.marks),o=c);}else i.type.name==="hardBreak"?(n&&(t.push(n),n=null,o=null),t.push(Gp())):i.type.name==="image"?(n&&(t.push(n),n=null,o=null),t.push(Zp(i))):i.type.name==="shape"?(n&&(t.push(n),n=null,o=null),t.push(Jp(i))):i.type.name==="tab"?(n&&(t.push(n),n=null,o=null),t.push(Kp())):i.type.name==="field"?(n&&(t.push(n),n=null,o=null),t.push(qp(i,i.marks))):i.type.name==="sdt"?(n&&(t.push(n),n=null,o=null),t.push(Xp(i))):i.type.name==="math"&&(n&&(t.push(n),n=null,o=null),t.push(Yp(i)));}),n&&t.push(n),r&&t.push(r),t}function _p(e){return e.attrs.href||""}function Vp(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 jp(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 El(e,t){if(t.isText&&t.text){let n=t.marks.filter(r=>r.type.name!=="hyperlink"),o=Ll(t.text,n);e.children.push(o);}}function Ll(e,t){let n=Ji(t),o={type:"text",text:e};return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:[o]}}function Up(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 Gp(){return {type:"run",content:[{type:"break",breakType:"textWrapping"}]}}function Kp(){return {type:"run",content:[{type:"tab"}]}}function qp(e,t){let n=e.attrs,o=t&&t.length>0?Ji(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 Yp(e){let t=e.attrs;return {type:"mathEquation",display:t.display||"inline",ommlXml:t.ommlXml,plainText:t.plainText||void 0}}function Xp(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=Fl(e).filter(i=>i.type==="run"||i.type==="hyperlink");return {type:"inlineSdt",properties:n,content:r}}function Zp(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:chunkEPCZ24TY_cjs.b(t.width||0),height:chunkEPCZ24TY_cjs.b(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 {type:"run",content:[{type:"drawing",image:i}]}}function Jp(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 Ji(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,cs:o.ascii||void 0,asciiTheme:o.asciiTheme};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 Qp(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 Bl(e){let t=e.attrs,n=[];e.forEach(r=>{r.type.name==="tableRow"&&n.push(tf(r));});let o=ef(t)||void 0;if(!o?.borders){let r=Qp(n);if(r)if(o)o.borders=r;else return {type:"table",columnWidths:t.columnWidths||void 0,formatting:{borders:r},rows:n}}return {type:"table",columnWidths:t.columnWidths||void 0,formatting:o,rows:n}}function ef(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 tf(e){let t=e.attrs,n=[];return e.forEach(o=>{(o.type.name==="tableCell"||o.type.name==="tableHeader")&&n.push(of(o));}),{type:"tableRow",formatting:nf(t),cells:n}}function nf(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 of(e){let t=e.attrs,n=[];return e.forEach(o=>{o.type.name==="paragraph"?n.push(Zi(o)):o.type.name==="table"&&n.push(Bl(o));}),{type:"tableCell",formatting:rf(t),content:n}}function rf(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 af(e){let t=e.attrs,n=[];e.forEach(a=>{a.type.name==="paragraph"&&n.push(Zi(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 Wo(e){return Il(e)}function Wn(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,k,P)=>{k<=o&&(s=P),k<=r&&(l=P);});let u={},c=a.parent,d=c.type.name==="paragraph"&&c.textContent.length===0,p=c.attrs?.defaultTextFormatting,f=e.storedMarks||t.$from.marks();d&&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 c.type.name==="paragraph"&&(c.attrs.alignment&&(m.alignment=c.attrs.alignment),c.attrs.lineSpacing&&(m.lineSpacing=c.attrs.lineSpacing,m.lineSpacingRule=c.attrs.lineSpacingRule),c.attrs.numPr&&(m.numPr=c.attrs.numPr),c.attrs.indentLeft&&(m.indentLeft=c.attrs.indentLeft),c.attrs.indentRight&&(m.indentRight=c.attrs.indentRight),c.attrs.indentFirstLine&&(m.indentFirstLine=c.attrs.indentFirstLine),c.attrs.hangingIndent&&(m.hangingIndent=c.attrs.hangingIndent),c.attrs.tabs&&(m.tabs=c.attrs.tabs),c.attrs.styleId&&(b=c.attrs.styleId)),{hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:m,styleId:b,startParagraphIndex:s,endParagraphIndex:l}}var ft=$n.getCommands(),_o=ft.toggleBold(),Vo=ft.toggleItalic(),jo=ft.toggleUnderline(),Uo=ft.toggleStrike(),Go=ft.toggleSuperscript(),Ko=ft.toggleSubscript();function qo(e){return ft.setTextColor(e)}ft.clearTextColor();function Yo(e){return ft.setHighlight(e)}ft.clearHighlight();function Xo(e){return ft.setFontSize(e)}ft.clearFontSize();function Zo(e){return ft.setFontFamily(e)}ft.clearFontFamily();function Jo(e,t){return ft.setHyperlink(e,t)}var Qo=ft.removeHyperlink();function lo(e,t,n){return ft.insertHyperlink(e,t,n)}var Ye=$n.getCommands();function er(e){return Ye.setAlignment(e)}Ye.alignLeft();Ye.alignCenter();Ye.alignRight();Ye.alignJustify();function tr(e,t="auto"){return Ye.setLineSpacing(e,t)}Ye.singleSpacing();Ye.oneAndHalfSpacing();Ye.doubleSpacing();function nr(e=720){return Ye.increaseIndent(e)}function or(e=720){return Ye.decreaseIndent(e)}function rr(e){return Ye.setIndentLeft(e)}function ir(e){return Ye.setIndentRight(e)}function co(e,t){return Ye.setIndentFirstLine(e,t)}var ar=Ye.toggleBulletList(),sr=Ye.toggleNumberedList(),lr=Ye.increaseListLevel(),cr=Ye.decreaseListLevel();Ye.removeList();function uo(e,t){return Ye.applyStyle(e,t)}Ye.clearStyle();Ye.removeSectionBreak();function dr(e){return Ye.removeTabStop(e)}var ur=Ye.generateTOC();var We=$n.getCommands();function pr(e,t){return We.insertTable(e,t)}function fr(e,t){return We.addRowAbove()(e,t)}function mr(e,t){return We.addRowBelow()(e,t)}function gr(e,t){return We.deleteRow()(e,t)}function hr(e,t){return We.addColumnLeft()(e,t)}function br(e,t){return We.addColumnRight()(e,t)}function yr(e,t){return We.deleteColumn()(e,t)}function po(e,t){return We.deleteTable()(e,t)}function xr(e,t){return We.selectTable()(e,t)}function Sr(e,t){return We.selectRow()(e,t)}function kr(e,t){return We.selectColumn()(e,t)}function wr(e,t){return We.mergeCells()(e,t)}function Cr(e,t){return We.splitCell()(e,t)}function sn(e,t){return We.setCellBorder(e,t)}function Tr(e,t){return We.removeTableBorders()(e,t)}function Rr(e,t,n){return We.setAllTableBorders(n)(e,t)}function vr(e,t,n){return We.setOutsideTableBorders(n)(e,t)}function Pr(e,t,n){return We.setInsideTableBorders(n)(e,t)}function Er(e){return We.setCellVerticalAlign(e)}function Mr(e){return We.setCellMargins(e)}function Ir(e){return We.setCellTextDirection(e)}function Fr(){return We.toggleNoWrap()}function Lr(e,t){return We.setRowHeight(e,t)}function Br(){return We.toggleHeaderRow()}function Ar(){return We.distributeColumns()}function Dr(){return We.autoFitContents()}function fo(e){return We.setTableProperties(e)}function Hr(e){return We.applyTableStyle(e)}function Nr(e){return We.setCellFillColor(e)}function zr(e){return We.setTableBorderColor(e)}function Or(e){return We.setTableBorderWidth(e)}var $r=(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 c=a.mapping.map(i.pos);a.insert(c,prosemirrorModel.Fragment.from([s,r.create()])),u=c+l+1;}else if(i.parentOffset===i.parent.content.size){let c=i.after();a.insert(c,prosemirrorModel.Fragment.from([s,r.create()])),u=c+l+1;}else {let c=i.before();a.insert(c,s),u=c+l+1;}else {let c=i.pos;a.insert(c,prosemirrorModel.Fragment.from([s,r.create()])),u=c+l+1;}a.setSelection(prosemirrorState.TextSelection.create(a.doc,u)),t(a.scrollIntoView());}return true};var Yl={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"2px 0",fontSize:11,color:"#4285f4",userSelect:"none"},Xl={fontWeight:500,letterSpacing:.3},vf={background:"none",border:"none",color:"#4285f4",cursor:"pointer",fontSize:11,padding:"2px 6px",borderRadius:3},Pf={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"},Wr={display:"block",width:"100%",padding:"6px 12px",border:"none",background:"none",textAlign:"left",cursor:"pointer",fontSize:12,color:"#3c4043"},Jl=fd.forwardRef(function({headerFooter:t,position:n,styles:o,targetElement:r,parentElement:i,onSave:a,onClose:s,onSelectionChange:l,onRemove:u},c){let d=fd.useRef(null),p=fd.useRef(null),[f,m]=fd.useState(false),[b,g]=fd.useState(false),k=fd.useRef(null),[P,S]=fd.useState(null);fd.useLayoutEffect(()=>{let A=()=>{let R=i.getBoundingClientRect(),te=r.getBoundingClientRect();S({top:te.top-R.top+i.scrollTop,left:te.left-R.left+i.scrollLeft,width:te.width});};A();let F=i.closest('[style*="overflow"]')||i;return F.addEventListener("scroll",A),window.addEventListener("resize",A),()=>{F.removeEventListener("scroll",A),window.removeEventListener("resize",A);}},[r,i]),fd.useEffect(()=>{if(!d.current||p.current)return;let A=Yi(t.content,{styles:o||void 0}),F=new rn(On());F.buildSchema(),F.initializeRuntime();let R=F.getPlugins(),te=prosemirrorState.EditorState.create({doc:A,schema:he,plugins:R}),re=new prosemirrorView.EditorView(d.current,{state:te,dispatchTransaction(Q){let pe=re.state.apply(Q);if(re.updateState(pe),Q.docChanged&&m(true),Q.selectionSet||Q.docChanged){let L=Wn(pe);l?.(L);}}});return p.current=re,requestAnimationFrame(()=>{re.focus();let Q=Wn(re.state);l?.(Q);}),()=>{re.destroy(),p.current=null;}},[P]);let B=fd.useCallback(()=>{if(!p.current)return;let A=Wo(p.current.state.doc);a(A);},[a]),E=fd.useCallback(()=>{f?B():s();},[f,B,s]);fd.useEffect(()=>{function A(F){F.key==="Escape"&&(F.preventDefault(),F.stopPropagation(),E());}return document.addEventListener("keydown",A,true),()=>document.removeEventListener("keydown",A,true)},[E]),fd.useEffect(()=>{if(!b)return;function A(F){k.current&&!k.current.contains(F.target)&&g(false);}return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[b]),fd.useImperativeHandle(c,()=>({getView:()=>p.current,focus:()=>p.current?.focus(),undo:()=>{let A=p.current;return A?prosemirrorHistory.undo(A.state,A.dispatch):false},redo:()=>{let A=p.current;return A?prosemirrorHistory.redo(A.state,A.dispatch):false}}));let J=n==="header"?"Header":"Footer";if(!P)return null;let Z={position:"absolute",top:P.top,left:P.left,width:P.width,zIndex:10};return jsxRuntime.jsxs("div",{className:"hf-inline-editor",style:Z,onMouseDown:A=>{A.stopPropagation();},children:[n==="footer"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:Yl,children:[jsxRuntime.jsx("span",{style:Xl,children:J}),jsxRuntime.jsx(Zl,{label:J,showOptions:b,setShowOptions:g,optionsRef:k,onRemove:u,onClose:E,viewRef:p})]}),jsxRuntime.jsx("div",{ref:d,className:"hf-editor-pm",style:{minHeight:40,outline:"none"}}),n==="header"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:Yl,children:[jsxRuntime.jsx("span",{style:Xl,children:J}),jsxRuntime.jsx(Zl,{label:J,showOptions:b,setShowOptions:g,optionsRef:k,onRemove:u,onClose:E,viewRef:p})]})]})});function Zl({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:c,from:d}=u.state.selection,p=u.state.storedMarks||c.marks(),f=he.nodes.field.create({fieldType:l,instruction:` ${l} \\* MERGEFORMAT `,fieldKind:"simple",dirty:true}),m=u.state.tr.insert(d,f.mark(p));u.dispatch(m),u.focus();};return jsxRuntime.jsxs("div",{style:{position:"relative"},ref:o,children:[jsxRuntime.jsx("button",{type:"button",style:vf,onClick:l=>{l.stopPropagation(),n(u=>!u);},onMouseDown:l=>l.stopPropagation(),children:"Options \u25BE"}),t&&jsxRuntime.jsxs("div",{style:Pf,children:[jsxRuntime.jsx("button",{type:"button",style:Wr,onClick:()=>{n(false),s("PAGE");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert current page number"}),jsxRuntime.jsx("button",{type:"button",style:Wr,onClick:()=>{n(false),s("NUMPAGES");},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:"Insert total page count"}),jsxRuntime.jsx("div",{style:{borderTop:"1px solid #e8eaed",margin:"4px 0"}}),r&&jsxRuntime.jsxs("button",{type:"button",style:Wr,onClick:()=>{n(false),r();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Remove ",e.toLowerCase()]}),jsxRuntime.jsxs("button",{type:"button",style:Wr,onClick:()=>{n(false),i();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Close ",e.toLowerCase()," editing"]})]})]})}var be=e=>({style:"single",size:4,color:{rgb:e}}),Ef=[{id:"TableNormal",name:"Normal Table",look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGrid",name:"Table Grid",tableBorders:{top:be("000000"),bottom:be("000000"),left:be("000000"),right:be("000000"),insideH:be("000000"),insideV:be("000000")},look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGridLight",name:"Grid Table Light",tableBorders:{top:be("BFBFBF"),bottom:be("BFBFBF"),left:be("BFBFBF"),right:be("BFBFBF"),insideH:be("BFBFBF"),insideV:be("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:be("000000")}}}},{id:"PlainTable1",name:"Plain Table 1",tableBorders:{top:be("BFBFBF"),bottom:be("BFBFBF"),insideH:be("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:be("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:be("B4C6E7"),bottom:be("B4C6E7"),left:be("B4C6E7"),right:be("B4C6E7"),insideH:be("B4C6E7"),insideV:be("B4C6E7")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:be("4472C4")}}}},{id:"GridTable4-Accent1",name:"Grid Table 4 Accent 1",tableBorders:{top:be("4472C4"),bottom:be("4472C4"),left:be("4472C4"),right:be("4472C4"),insideH:be("4472C4"),insideV:be("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:be("FFFFFF"),bottom:be("FFFFFF"),left:be("FFFFFF"),right:be("FFFFFF"),insideH:be("FFFFFF"),insideV:be("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:be("ED7D31"),bottom:be("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:be("A5A5A5"),bottom:be("A5A5A5"),insideH:be("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:be("5B9BD5"),bottom:be("5B9BD5"),left:be("5B9BD5"),right:be("5B9BD5"),insideH:be("5B9BD5"),insideV:be("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:be("70AD47"),bottom:be("70AD47"),left:be("70AD47"),right:be("70AD47"),insideH:be("70AD47"),insideV:be("70AD47")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#70AD47"},band1Horz:{backgroundColor:"#E2EFDA"}}}];function Ql(e){return Ef.find(t=>t.id===e)}function ec(){return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"20px",color:"var(--doc-text-muted)"},children:[jsxRuntime.jsx("div",{style:{width:"36px",height:"36px",border:"3px solid var(--doc-border)",borderTopColor:"var(--doc-primary)",borderRadius:"50%",animation:"docx-spin 0.8s linear infinite"}}),jsxRuntime.jsx("style",{children:`
15
+ @keyframes docx-spin {
16
+ to { transform: rotate(360deg); }
17
+ }
18
+ `}),jsxRuntime.jsx("div",{style:{fontSize:"14px"},children:"Loading document..."})]})}function tc(){return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--doc-text-placeholder)"},children:[jsxRuntime.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[jsxRuntime.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),jsxRuntime.jsx("polyline",{points:"14 2 14 8 20 8"})]}),jsxRuntime.jsx("div",{style:{marginTop:"16px"},children:"No document loaded"})]})}function nc({message:e}){return jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"20px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{color:"var(--doc-error)",marginBottom:"16px"},children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10"}),jsxRuntime.jsx("path",{d:"M12 8v4M12 16v.01"})]})}),jsxRuntime.jsx("h3",{style:{color:"var(--doc-error)",marginBottom:"8px"},children:"Failed to Load Document"}),jsxRuntime.jsx("p",{style:{color:"var(--doc-text-muted)",maxWidth:"400px"},children:e})]})}function oa(e){let t=new Set,n=/\{\{([^}]+)\}\}/g,o=i=>{for(let a of i.content||[])if(a.type==="run"){for(let s of a.content||[])if(s.type==="text"){let l;for(;(l=n.exec(s.text))!==null;)t.add(l[1].trim());}}},r=e.package.document;for(let i of r.content||[])i.type==="paragraph"&&o(i);return Array.from(t)}function oc(e){let t={},n=oa(e);for(let o of n)t[o]="";return t}function If(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ff(e,t={}){let{maxEntries:n=100,groupingInterval:o=500,enableKeyboardShortcuts:r=true,isEqual:i=If,onUndo:a,onRedo:s,containerRef:l}=t,[u,c]=fd.useState(e),[d,p]=fd.useState([]),[f,m]=fd.useState([]),b=fd.useRef(0),g=fd.useRef(false),k=fd.useCallback((A,F)=>{if(i(u,A))return;if(g.current){c(A);return}let R=Date.now();R-b.current<o&&d.length>0?p(re=>{let Q=[...re];return Q[Q.length-1]={state:u,timestamp:R,description:F||Q[Q.length-1].description},Q}):p(re=>{let Q={state:u,timestamp:R,description:F},pe=[...re,Q];return pe.length>n?pe.slice(pe.length-n):pe}),m([]),c(A),b.current=R;},[u,i,o,n,d.length]),P=fd.useCallback(()=>{if(d.length===0)return;g.current=true;let A=d[d.length-1];return p(F=>F.slice(0,-1)),m(F=>[...F,{state:u,timestamp:Date.now()}]),c(A.state),setTimeout(()=>{g.current=false;},0),a?.(A.state),A.state},[d,u,a]),S=fd.useCallback(()=>{if(f.length===0)return;g.current=true;let A=f[f.length-1];return m(F=>F.slice(0,-1)),p(F=>[...F,{state:u,timestamp:Date.now()}]),c(A.state),setTimeout(()=>{g.current=false;},0),s?.(A.state),A.state},[f,u,s]),B=fd.useCallback(()=>{p([]),m([]);},[]),E=fd.useCallback(A=>{c(A??e),p([]),m([]),b.current=0;},[e]),J=fd.useCallback(()=>[...d],[d]),Z=fd.useCallback(()=>[...f],[f]);return fd.useEffect(()=>{if(!r)return;let A=R=>{if((R.ctrlKey||R.metaKey)&&R.key==="z"&&!R.shiftKey){R.preventDefault(),P();return}if((R.ctrlKey||R.metaKey)&&R.key==="y"||(R.ctrlKey||R.metaKey)&&R.key==="z"&&R.shiftKey){R.preventDefault(),S();return}},F=l?.current||document;return F.addEventListener("keydown",A),()=>{F.removeEventListener("keydown",A);}},[r,P,S,l]),{state:u,canUndo:d.length>0,canRedo:f.length>0,undoCount:d.length,redoCount:f.length,push:k,undo:P,redo:S,clear:B,reset:E,getUndoStack:J,getRedoStack:Z}}function ic(e,t={}){let n=fd.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 Ff(e,{...t,isEqual:n})}var $f={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function cc(e,t,n,o=[]){let r=n?.getSchema()??he,i=e?ji(e,{styles:t??void 0}):Xi(),a=[...n?.getPlugins()??[],...o];return prosemirrorState.EditorState.create({doc:i,schema:r,plugins:a})}function Wf(e,t){return t?Ml(e.doc,t):null}var _f=fd.forwardRef(function(t,n){let{document:o,styles:r,theme:i,widthPx:a=612,readOnly:s=false,onTransaction:l,onSelectionChange:u,externalPlugins:c=[],extensionManager:d,onEditorViewReady:p,onEditorViewDestroy:f,onKeyDown:m}=t,b=fd.useRef(null),g=fd.useRef(null),k=fd.useRef(o),P=fd.useRef(false),S=fd.useRef(null),B=fd.useRef(false),E=fd.useRef(l),J=fd.useRef(u),Z=fd.useRef(p),A=fd.useRef(f),F=fd.useRef(m);E.current=l,J.current=u,Z.current=p,A.current=f,F.current=m,k.current=o;let R=fd.useCallback(()=>{if(!b.current||P.current)return;let Q={state:cc(o,r,d,c),editable:()=>!s,dispatchTransaction:pe=>{if(!g.current||P.current)return;let L=g.current.state.apply(pe);g.current.updateState(L),E.current?.(pe,L),(pe.selectionSet||pe.docChanged)&&J.current?.(L);},handleKeyDown:(pe,L)=>F.current?.(pe,L)??false,handleDOMEvents:{focus:()=>false,blur:()=>false}};g.current=new prosemirrorView.EditorView(b.current,Q),Z.current?.(g.current);},[o,r,c,d,s]),te=fd.useCallback(()=>{g.current&&!P.current&&(P.current=true,A.current?.(),g.current.destroy(),g.current=null,P.current=false);},[]);return fd.useEffect(()=>(R(),()=>te()),[]),fd.useEffect(()=>{if(!g.current||P.current)return;let Q=(L=>{if(!L)return "empty";let N=L.package?.properties;return `${N?.created||""}-${N?.modified||""}-${N?.title||""}`})(o);if(B.current&&Q===S.current)return;B.current=true,S.current=Q;let pe=cc(o,r,d,c);g.current.updateState(pe),J.current?.(pe);},[o,r,d,c]),fd.useEffect(()=>{g.current;},[s]),fd.useImperativeHandle(n,()=>({getState(){return g.current?.state??null},getView(){return g.current??null},getDocument(){return g.current?Wf(g.current.state,k.current):null},focus(){g.current?.focus();},blur(){g.current?.hasFocus()&&g.current.dom.blur();},isFocused(){return g.current?.hasFocus()??false},dispatch(re){g.current&&!P.current&&g.current.dispatch(re);},executeCommand(re){return g.current?re(g.current.state,g.current.dispatch,g.current):false},undo(){return g.current?prosemirrorHistory.undo(g.current.state,g.current.dispatch):false},redo(){return g.current?prosemirrorHistory.redo(g.current.state,g.current.dispatch):false},canUndo(){return g.current?prosemirrorHistory.undo(g.current.state):false},canRedo(){return g.current?prosemirrorHistory.redo(g.current.state):false},setSelection(re,Q){if(!g.current)return;let{state:pe,dispatch:L}=g.current,N=pe.doc.resolve(re),Y=Q!==void 0?pe.doc.resolve(Q):N,xe=prosemirrorState.TextSelection.between(N,Y);L(pe.tr.setSelection(xe));},setNodeSelection(re){if(!g.current)return;let{state:Q,dispatch:pe}=g.current;try{let L=prosemirrorState.NodeSelection.create(Q.doc,re);pe(Q.tr.setSelection(L));}catch{this.setSelection(re);}},setCellSelection(re,Q){if(!g.current)return;let{state:pe,dispatch:L}=g.current;try{let N=prosemirrorTables.CellSelection.create(pe.doc,re,Q);L(pe.tr.setSelection(N));}catch{this.setSelection(re,Q);}},scrollToSelection(){}}),[]),jsxRuntime.jsx("div",{ref:b,className:"paged-editor__hidden-pm",style:{...$f,width:a>0?`${a}px`:void 0}})}),dc=fd.memo(_f);var Gf="#000",Kf="rgba(66, 133, 244, 0.3)",qf=2,Yf=530,Xf={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},Zf=(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"}),Jf=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),Qf=({position:e,color:t,width:n,blinkInterval:o,isFocused:r})=>{let[i,a]=fd.useState(r),s=fd.useRef(null);return fd.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]),fd.useEffect(()=>{if(r)return a(true),s.current&&window.clearInterval(s.current),o>0&&(s.current=window.setInterval(()=>{a(l=>!l);},o)),()=>{s.current&&window.clearInterval(s.current);}},[e.x,e.y,r,o]),jsxRuntime.jsx("div",{style:Zf(e,t,n,i),"data-testid":"caret"})},em=({rect:e,color:t,index:n})=>jsxRuntime.jsx("div",{style:Jf(e,t),"data-testid":`selection-rect-${n}`,"data-page-index":e.pageIndex}),pc=({selectionRects:e,caretPosition:t,isFocused:n,readOnly:o=false,caretColor:r=Gf,selectionColor:i=Kf,caretWidth:a=qf,blinkInterval:s=Yf})=>{if(o)return null;let l=e.length>0,u=t!==null&&!l;return jsxRuntime.jsxs("div",{style:Xf,"data-testid":"selection-overlay",children:[l&&e.map((c,d)=>jsxRuntime.jsx(em,{rect:c,color:i,index:d},`sel-${c.pageIndex}-${c.x}-${c.y}-${d}`)),u&&t&&jsxRuntime.jsx(Qf,{position:t,color:r,width:a,blinkInterval:s,isFocused:n})]})};var sa=10,cn=sa/2,ho=2,hc="#2563eb",mc={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},nm={position:"absolute",border:`${ho}px solid ${hc}`,pointerEvents:"none",boxSizing:"border-box"},om={position:"absolute",width:`${sa}px`,height:`${sa}px`,backgroundColor:hc,border:"1px solid white",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},rm={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%)"},im={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize"};function am(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 c=Math.max(l/o,u/r);l=o*c,u=r*c;}return {width:Math.max(20,Math.min(2e3,l)),height:Math.max(20,Math.min(2e3,u))}}function bc({imageInfo:e,zoom:t,isFocused:n,onResize:o,onResizeStart:r,onResizeEnd:i,onDragMove:a,onDragStart:s,onDragEnd:l}){let[u,c]=fd.useState(false),[d,p]=fd.useState(false),[f,m]=fd.useState(0),[b,g]=fd.useState(0),[k,P]=fd.useState(null),S=fd.useRef(null),B=fd.useRef(null),E=fd.useRef(o),J=fd.useRef(r),Z=fd.useRef(i),A=fd.useRef(a),F=fd.useRef(s),R=fd.useRef(l);E.current=o,J.current=r,Z.current=i,A.current=a,F.current=s,R.current=l;let te=fd.useRef(e),re=fd.useRef(t);te.current=e,re.current=t;let Q=fd.useCallback(()=>{if(!e||!B.current){P(null);return}let T=B.current.offsetParent;if(!T){P(null);return}let I=T.getBoundingClientRect(),y=e.element.getBoundingClientRect();P({left:(y.left-I.left)/t,top:(y.top-I.top)/t,width:y.width/t,height:y.height/t});},[e,t]);fd.useEffect(()=>{Q();},[Q]),fd.useEffect(()=>{if(!e)return;let T=B.current?.closest('[style*="overflow"]')??B.current?.closest(".paged-editor__container");if(!T)return;let I=()=>{S.current&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(Q);};return T.addEventListener("scroll",I,{passive:true}),window.addEventListener("resize",I,{passive:true}),()=>{T.removeEventListener("scroll",I),window.removeEventListener("resize",I),S.current&&cancelAnimationFrame(S.current);}},[e,Q]);let pe=fd.useCallback((T,I)=>{if(!e||!k)return;I.preventDefault(),I.stopPropagation();let y=k.width,v=k.height,w=I.clientX,M=I.clientY,G=Math.round(y),U=Math.round(v);c(true),m(G),g(U),J.current?.();let H=$=>{let ge=re.current,fe=($.clientX-w)/ge,se=($.clientY-M)/ge,O=!$.shiftKey,ue=am(T,fe,se,y,v,O);G=Math.round(ue.width),U=Math.round(ue.height),m(G),g(U),P(Ce=>{if(!Ce)return Ce;let _e={...Ce};return T.includes("w")&&(_e.left=Ce.left+(Ce.width-ue.width)),T.includes("n")&&(_e.top=Ce.top+(Ce.height-ue.height)),_e.width=ue.width,_e.height=ue.height,_e});},z=()=>{window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",z),c(false);let $=te.current;$&&E.current?.($.pmPos,G,U),Z.current?.();};window.addEventListener("mousemove",H),window.addEventListener("mouseup",z);},[e,k]),L=fd.useCallback(T=>{if(!e||!k)return;T.preventDefault(),T.stopPropagation();let I=4,y=T.clientX,v=T.clientY,w=false,M=null,G=H=>{let z=H.clientX-y,$=H.clientY-v;!w&&Math.sqrt(z*z+$*$)<I||(w||(w=true,p(true),F.current?.(),M=document.createElement("div"),M.style.cssText="position: fixed; pointer-events: none; z-index: 10000; opacity: 0.5; border: 2px dashed #2563eb; border-radius: 4px; background: rgba(37, 99, 235, 0.1);",M.style.width=`${k.width}px`,M.style.height=`${k.height}px`,document.body.appendChild(M)),M&&(M.style.left=`${H.clientX-k.width/2}px`,M.style.top=`${H.clientY-k.height/2}px`));},U=H=>{if(window.removeEventListener("mousemove",G),window.removeEventListener("mouseup",U),M&&(M.remove(),M=null),p(false),w){let z=te.current;z&&A.current?.(z.pmPos,H.clientX,H.clientY),R.current?.();}};window.addEventListener("mousemove",G),window.addEventListener("mouseup",U);},[e,k]);if(!!!(e&&k&&n))return jsxRuntime.jsx("div",{ref:B,style:{...mc,visibility:"hidden"},className:"image-selection-overlay"});let{left:Y,top:xe,width:le,height:Re}=k;return jsxRuntime.jsxs("div",{ref:B,style:mc,className:"image-selection-overlay",children:[jsxRuntime.jsx("div",{style:{...nm,left:Y-ho,top:xe-ho,width:le+ho*2,height:Re+ho*2}}),jsxRuntime.jsx("div",{style:{position:"absolute",left:Y,top:xe,width:le,height:Re,cursor:d?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:L}),jsxRuntime.jsx(Vr,{handle:"nw",style:{left:Y-cn,top:xe-cn},onMouseDown:pe}),jsxRuntime.jsx(Vr,{handle:"ne",style:{left:Y+le-cn,top:xe-cn},onMouseDown:pe}),jsxRuntime.jsx(Vr,{handle:"se",style:{left:Y+le-cn,top:xe+Re-cn},onMouseDown:pe}),jsxRuntime.jsx(Vr,{handle:"sw",style:{left:Y-cn,top:xe+Re-cn},onMouseDown:pe}),u&&jsxRuntime.jsxs("div",{style:{...rm,left:Y+le/2,top:xe+Re+12},children:[f," \xD7 ",b]})]})}function Vr({handle:e,style:t,onMouseDown:n}){return jsxRuntime.jsx("div",{style:{...om,...t,cursor:im[e]},onMouseDown:o=>n(e,o),"data-handle":e})}function sm(e,t,n,o){let r=e-t-n,i=(o.count-1)*o.gap;return (r-i)/o.count}function yc(e){let{pageSize:t,margins:n,columns:o={count:1,gap:0}}=e,r=[],i=[],a=n.top,s=t.h-n.bottom;if(s-a<=0)throw new Error("Paginator: page size and margins yield no content area");let u=sm(t.w,n.left,n.right,o);function c(B){return n.left+B*(u+o.gap)}function d(){let B=r.length+1,E=e.footnoteReservedHeights?.get(B)??0,J=s-E,Z={number:B,fragments:[],margins:{...n},size:{...t},footnoteReservedHeight:E>0?E:void 0},A={page:Z,cursorY:a,columnIndex:0,topMargin:a,contentBottom:J,trailingSpacing:0};return r.push(Z),i.push(A),e.onNewPage&&e.onNewPage(A),A}function p(){return i.length===0?d():i[i.length-1]}function f(B){return B.contentBottom-B.cursorY}function m(B,E){let J=E||p();return f(J)>=B}function b(B){return B.columnIndex<o.count-1?(B.columnIndex+=1,B.cursorY=B.topMargin,B.trailingSpacing=0,B):d()}function g(B){let E=p(),J=Number.isFinite(B)&&B>0?B:0,Z=E.contentBottom-E.topMargin;if(J>Z)return E.cursorY!==E.topMargin&&(E=b(E)),E;for(;!m(J,E);)E=b(E);return E}function k(B,E,J=0,Z=0){let A=Math.max(J,p().trailingSpacing),F=A+E,R=g(F),re=R.cursorY===R.topMargin?0:A,Q=c(R.columnIndex),pe=R.cursorY+re;return B.x=Q,B.y=pe,R.page.fragments.push(B),R.cursorY=pe+E,R.trailingSpacing=Z,{state:R,x:Q,y:pe}}function P(){return d()}function S(){let B=p();return b(B)}return {pages:r,states:i,columnWidth:u,getCurrentState:p,getAvailableHeight:()=>f(p()),fits:B=>m(B),ensureFits:g,addFragment:k,forcePageBreak:P,forceColumnBreak:S,getColumnX:c}}function xc(e){let t=new Map,n=new Set;for(let o=0;o<e.length;o++){if(n.has(o))continue;let r=e[o];if(r.kind!=="paragraph"||!r.attrs?.keepNext)continue;let a=[o],s=o;for(let c=o+1;c<e.length;c++){let d=e[c];if(d.kind==="sectionBreak"||d.kind==="pageBreak"||d.kind==="columnBreak"||d.kind!=="paragraph")break;if(d.attrs?.keepNext)a.push(c),s=c,n.add(c);else break}let l=s+1,u=-1;if(l<e.length){let c=e[l];c.kind!=="sectionBreak"&&c.kind!=="pageBreak"&&c.kind!=="columnBreak"&&(u=l);}t.set(o,{startIndex:o,endIndex:s,memberIndices:a,anchorIndex:u});}return t}function Sc(e,t,n){let o=0;for(let r of e.memberIndices){let i=t[r],a=n[r];if(i.kind!=="paragraph"||a.kind!=="paragraph")continue;let s=i,l=a,u=s.attrs?.spacing?.before??0;o+=u,o+=l.totalHeight;let c=s.attrs?.spacing?.after??0;o+=c;}if(e.anchorIndex!==-1){let r=n[e.anchorIndex];if(r?.kind==="paragraph"){let i=r;i.lines.length>0&&(o+=i.lines[0].lineHeight);}}return o}function kc(e){let t=new Set;for(let n of e.values())for(let o=1;o<n.memberIndices.length;o++)t.add(n.memberIndices[o]);return t}function wc(e){return e.kind!=="paragraph"?false:e.attrs?.pageBreakBefore===true}var lm={w:816,h:1056},_n={top:96,right:96,bottom:96,left:96};function Cc(e){return e.attrs?.spacing?.before??0}function Tc(e){return e.attrs?.spacing?.after??0}function cm(e){for(let t=0;t<e.length-1;t++){let n=e[t],o=e[t+1];if(n.kind!=="paragraph"||o.kind!=="paragraph")continue;let r=n.attrs,i=o.attrs;r?.contextualSpacing&&i?.contextualSpacing&&r.styleId&&r.styleId===i.styleId&&(r.spacing&&(r.spacing={...r.spacing,after:0}),i.spacing&&(i.spacing={...i.spacing,before:0}));}}function jr(e,t,n={}){if(e.length!==t.length)throw new Error(`layoutDocument: expected one measure per block (blocks=${e.length}, measures=${t.length})`);let o=n.pageSize??lm,r={top:n.margins?.top??_n.top,right:n.margins?.right??_n.right,bottom:n.margins?.bottom??_n.bottom,left:n.margins?.left??_n.left,header:n.margins?.header??n.margins?.top??_n.top,footer:n.margins?.footer??n.margins?.bottom??_n.bottom};n.headerContentHeights,n.footerContentHeights,n.titlePage,n.evenAndOddHeaders;let i={...r},a=o.w-i.left-i.right;if(a<=0)throw new Error("layoutDocument: page size and margins yield no content area");let s=yc({pageSize:o,margins:i,columns:n.columns,footnoteReservedHeights:n.footnoteReservedHeights});cm(e);let l=xc(e),u=kc(l);for(let c=0;c<e.length;c++){let d=e[c],p=t[c];wc(d)&&s.forcePageBreak();let f=l.get(c);if(f&&!u.has(c)){let m=Sc(f,e,t),b=s.getCurrentState(),g=s.getAvailableHeight(),k=b.contentBottom-b.topMargin;m<=k&&m>g&&b.page.fragments.length>0&&s.forcePageBreak();}switch(d.kind){case "paragraph":dm(d,p,s,a);break;case "table":d.floating?pm(d,p,s,a):um(d,p,s);break;case "image":fm(d,p,s);break;case "pageBreak":s.forcePageBreak();break;case "columnBreak":s.forceColumnBreak();break;case "sectionBreak":gm(d,s);break}}return s.pages.length===0&&s.getCurrentState(),{pageSize:o,pages:s.pages,columns:n.columns,pageGap:n.pageGap}}function dm(e,t,n,o){if(t.kind!=="paragraph")throw new Error("layoutParagraph: expected paragraph measure");let r=t.lines;if(r.length===0){let l=Cc(e),u=Tc(e),c=n.getCurrentState(),d={kind:"paragraph",blockId:e.id,x:n.getColumnX(c.columnIndex),y:c.cursorY+l,width:o,height:0,fromLine:0,toLine:0,pmStart:e.pmStart,pmEnd:e.pmEnd};n.addFragment(d,0,l,u);return}let i=Cc(e),a=Tc(e),s=0;for(;s<r.length;){let l=n.getCurrentState(),u=n.getAvailableHeight(),c=0,d=0;for(let P=s;P<r.length;P++){let S=r[P].lineHeight,B=c+S;if((s===0&&P===s?B+i:B)<=u||d===0)c=B,d++;else break}let p=s===0,f=s+d>=r.length,m=p?i:0,b=f?a:0,g={kind:"paragraph",blockId:e.id,x:n.getColumnX(l.columnIndex),y:0,width:o,height:c,fromLine:s,toLine:s+d,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!p,continuesOnNext:!f},k=n.addFragment(g,c,m,b);g.y=k.y,s+=d,s<r.length&&n.ensureFits(r[s].lineHeight);}}function um(e,t,n){if(t.kind!=="table")throw new Error("layoutTable: expected table measure");let o=t.rows;if(o.length===0)return;let r=0;for(;r<o.length;){let i=n.getCurrentState(),a=n.getAvailableHeight(),s=0,l=0;for(let m=r;m<o.length;m++){let b=o[m].height,g=s+b;if(g<=a||l===0)s=g,l++;else break}let u=r===0,c=r+l>=o.length,d=n.getColumnX(i.columnIndex);e.justification==="center"?d=d+(n.columnWidth-t.totalWidth)/2:e.justification==="right"&&(d=d+n.columnWidth-t.totalWidth);let p={kind:"table",blockId:e.id,x:d,y:0,width:t.totalWidth,height:s,fromRow:r,toRow:r+l,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!u,continuesOnNext:!c},f=n.addFragment(p,s,0,0);p.y=f.y,p.x=d,r+=l,r<o.length&&n.ensureFits(o[r].height);}}function pm(e,t,n,o){if(t.kind!=="table")throw new Error("layoutFloatingTable: expected table measure");let r=n.getCurrentState(),i=e.floating,a=r.page,s=a.margins,l=t.totalWidth,u=t.totalHeight,c=a.size.h-s.top-s.bottom,d=s.left,p=s.top;i?.horzAnchor==="page"&&(d=0),i?.vertAnchor==="page"&&(p=0);let f=n.getColumnX(r.columnIndex);if(i?.tblpX!==void 0)f=d+i.tblpX;else if(i?.tblpXSpec){let S=i.tblpXSpec;S==="left"||S==="inside"?f=d:S==="right"||S==="outside"?f=d+o-l:S==="center"&&(f=d+(o-l)/2);}else e.justification==="center"?f=d+(o-l)/2:e.justification==="right"&&(f=d+o-l);let m=r.cursorY,b=false;if(i?.tblpY!==void 0)m=p+i.tblpY,b=true;else if(i?.tblpYSpec){b=true;let S=i.tblpYSpec;S==="top"?m=p:S==="bottom"?m=p+c-u:S==="center"&&(m=p+(c-u)/2);}b||(m=n.ensureFits(u).cursorY);let g=s.left,k=s.left+o-l;Number.isFinite(k)&&(f=Math.max(g,Math.min(f,k)));let P={kind:"table",blockId:e.id,x:f,y:m,width:l,height:u,fromRow:0,toRow:e.rows.length,pmStart:e.pmStart,pmEnd:e.pmEnd,isFloating:true};r.page.fragments.push(P);}function fm(e,t,n){if(t.kind!=="image")throw new Error("layoutImage: expected image measure");if(e.anchor?.isAnchored){mm(e,t,n);return}let o=n.ensureFits(t.height),r={kind:"image",blockId:e.id,x:n.getColumnX(o.columnIndex),y:0,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd},i=n.addFragment(r,t.height,0,0);r.y=i.y;}function mm(e,t,n){let o=n.getCurrentState(),r=e.anchor,i=r.offsetH??n.getColumnX(o.columnIndex),a=r.offsetV??o.cursorY,s={kind:"image",blockId:e.id,x:i,y:a,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd,isAnchored:true,zIndex:r.behindDoc?-1:1};o.page.fragments.push(s);}function gm(e,t){switch(e.type??"continuous"){case "nextPage":t.forcePageBreak();break;case "evenPage":{t.forcePageBreak().page.number%2!==0&&t.forcePageBreak();break}case "oddPage":{t.forcePageBreak().page.number%2===0&&t.forcePageBreak();break}}}var hm="Calibri";function la(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 bm=11;function rt(e){return e/1440*96}var ym=0;function Vn(){return `block-${++ym}`}function xm(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 Ur(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?chunkSF53KLDZ_cjs.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=chunkSF53KLDZ_cjs.a({rgb:r.rgb,themeColor:r.themeColor,themeTint:r.themeTint,themeShade:r.themeShade},t));break}case "highlight":n.highlight=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}}return n}function Sm(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=Ur(a.marks,i),c={kind:"text",text:a.text,...u,pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}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 c={kind:"tab",...Ur(a.marks,i),pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="image"){let u=a.attrs,c=la(u.width||100,u.height||100,n.pageContentHeight),d={kind:"image",src:u.src,width:c.width,height:c.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(d);}else if(a.type.name==="field"){let u=a.attrs.fieldType,d={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(d);}else if(a.type.name==="math"){let c={kind:"text",text:a.attrs.plainText||"[equation]",italic:true,fontFamily:"Cambria Math",pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="sdt"){let u=l+1;a.forEach((c,d)=>{let p=u+d;if(c.isText&&c.text){let f=Ur(c.marks,i),m={kind:"text",text:c.text,...f,pmStart:p,pmEnd:p+c.nodeSize};o.push(m);}else if(c.type.name==="hardBreak"){let f={kind:"lineBreak",pmStart:p,pmEnd:p+c.nodeSize};o.push(f);}else if(c.type.name==="tab"){let m={kind:"tab",...Ur(c.marks,i),pmStart:p,pmEnd:p+c.nodeSize};o.push(m);}else if(c.type.name==="image"){let f=c.attrs,m=la(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+c.nodeSize};o.push(b);}});}}),o}function km(e){let t={};if(e.alignment){let a=e.alignment;a==="both"||a==="distribute"?t.alignment="justify":a==="left"?t.alignment="left":a==="center"?t.alignment="center":a==="right"&&(t.alignment="right");}(e.spaceBefore!=null||e.spaceAfter!=null||e.lineSpacing!=null)&&(t.spacing={},e.spaceBefore!=null&&(t.spacing.before=rt(e.spaceBefore)),e.spaceAfter!=null&&(t.spacing.after=rt(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(t.spacing.line=rt(e.lineSpacing),t.spacing.lineUnit="px",t.spacing.lineRule=e.lineSpacingRule):(t.spacing.line=e.lineSpacing/240,t.spacing.lineUnit="multiplier",t.spacing.lineRule="auto")));let n=e.indentLeft,o=e.indentFirstLine,r=e.hangingIndent;if(e.numPr?.numId&&n==null&&(n=((e.numPr.ilvl??0)+1)*720,o==null&&(o=-360,r=true)),(n!=null||e.indentRight!=null||o!=null)&&(t.indent={},n!=null&&(t.indent.left=rt(n)),e.indentRight!=null&&(t.indent.right=rt(e.indentRight)),o!=null&&(r?t.indent.hanging=Math.abs(rt(o)):t.indent.firstLine=rt(o))),e.styleId&&(t.styleId=e.styleId),e.borders){let a=e.borders;t.borders={};let s=l=>{if(!l||l.style==="none"||l.style==="nil")return;let u=l.size?Math.max(1,Math.round(l.size/8*1.333)):1,c="#000000";return l.color?.rgb&&(c=`#${l.color.rgb}`),{style:l.style||"single",width:u,color:c}};a.top&&(t.borders.top=s(a.top)),a.bottom&&(t.borders.bottom=s(a.bottom)),a.left&&(t.borders.left=s(a.left)),a.right&&(t.borders.right=s(a.right)),!t.borders.top&&!t.borders.bottom&&!t.borders.left&&!t.borders.right&&delete t.borders;}e.shading?.fill?.rgb&&(t.shading=`#${e.shading.fill.rgb}`),e.tabs&&e.tabs.length>0&&(t.tabs=e.tabs.map(a=>({val:wm(a.alignment),pos:a.position,leader:a.leader}))),e.pageBreakBefore&&(t.pageBreakBefore=true),e.keepNext&&(t.keepNext=true),e.keepLines&&(t.keepLines=true),e.contextualSpacing&&(t.contextualSpacing=true),e.styleId&&(t.styleId=e.styleId),e.numPr&&(t.numPr={numId:e.numPr.numId,ilvl:e.numPr.ilvl}),e.listMarker&&(t.listMarker=e.listMarker),e.listIsBullet!=null&&(t.listIsBullet=e.listIsBullet);let i=e.defaultTextFormatting;return i&&(i.fontSize!=null&&(t.defaultFontSize=i.fontSize/2),i.fontFamily&&(t.defaultFontFamily=i.fontFamily.ascii||i.fontFamily.hAnsi)),t}function wm(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 Rc(e,t,n){let o=e.attrs,r=Sm(e,t,n),i=km(o);return {kind:"paragraph",id:Vn(),runs:r,attrs:i,pmStart:t,pmEnd:t+e.nodeSize}}function Cm(e){return Math.max(1,Math.round(e/8*1.333))}var Tm={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 Rm(e){let t=e.borders;if(!t)return;let n={},o=["top","bottom","left","right"];for(let r of o){let i=t[r];if(!i||!i.style||i.style==="none"||i.style==="nil"){n[r]={width:0,style:"none"};continue}let a={style:Tm[i.style]||"solid"};i.color?.rgb&&(a.color=`#${i.color.rgb}`),i.size&&(a.width=Cm(i.size)),n[r]=a;}return Object.keys(n).length>0?n:void 0}function vm(e,t,n){let o=[],r=t+1;e.forEach(l=>{l.type.name==="paragraph"?o.push(Rc(l,r,n)):l.type.name==="table"&&o.push(vc(l,r,n)),r+=l.nodeSize;});let i=e.attrs,a=i.margins,s={top:a?.top!=null?rt(a.top):1,right:a?.right!=null?rt(a.right):7,bottom:a?.bottom!=null?rt(a.bottom):1,left:a?.left!=null?rt(a.left):7};return {id:Vn(),blocks:o,colSpan:i.colspan,rowSpan:i.rowspan,width:i.width?rt(i.width):void 0,verticalAlign:i.verticalAlign,background:i.backgroundColor?`#${i.backgroundColor}`:void 0,borders:Rm(i),padding:s}}function Pm(e,t,n){let o=[],r=t+1;e.forEach(a=>{(a.type.name==="tableCell"||a.type.name==="tableHeader")&&o.push(vm(a,r,n)),r+=a.nodeSize;});let i=e.attrs;return {id:Vn(),cells:o,height:i.height?rt(i.height):void 0,heightRule:i.heightRule??void 0,isHeader:i.isHeader}}function vc(e,t,n){let o=[],r=t+1;e.forEach(p=>{p.type.name==="tableRow"&&o.push(Pm(p,r,n)),r+=p.nodeSize;});let a=e.attrs.columnWidths?.map(rt),s=e.attrs.width,l=e.attrs.widthType;if(!a&&o.length>0){let f=o[0].cells.map(m=>m.width);f.every(m=>m!==void 0&&m>0)&&(a=f);}let u=e.attrs.justification,c=e.attrs.floating,d=c?{horzAnchor:c.horzAnchor,vertAnchor:c.vertAnchor,tblpX:c.tblpX!==void 0?rt(c.tblpX):void 0,tblpXSpec:c.tblpXSpec,tblpY:c.tblpY!==void 0?rt(c.tblpY):void 0,tblpYSpec:c.tblpYSpec,topFromText:c.topFromText!==void 0?rt(c.topFromText):void 0,bottomFromText:c.bottomFromText!==void 0?rt(c.bottomFromText):void 0,leftFromText:c.leftFromText!==void 0?rt(c.leftFromText):void 0,rightFromText:c.rightFromText!==void 0?rt(c.rightFromText):void 0}:void 0;return {kind:"table",id:Vn(),rows:o,columnWidths:a,width:s,widthType:l,justification:u,floating:d,pmStart:t,pmEnd:t+e.nodeSize}}function Em(e,t,n){let o=e.attrs,r=o.wrapType,i=r==="behind"||r==="inFront",a=la(o.width||100,o.height||100,n);return {kind:"image",id:Vn(),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,pmStart:t,pmEnd:t+e.nodeSize}}function Pc(e,t={}){let n={...t,defaultFont:t.defaultFont??hm,defaultSize:t.defaultSize??bm},o=[],r=0,i=new Map;return e.forEach((a,s)=>{let l=r+s;switch(a.type.name){case "paragraph":{let u=Rc(a,l,n),c=a.attrs;if(c.numPr&&!c.listMarker){let d=c.numPr.numId;if(d==null||d===0)break;let p=c.numPr.ilvl??0,f=i.get(d)??new Array(9).fill(0);f[p]=(f[p]??0)+1;for(let b=p+1;b<f.length;b+=1)f[b]=0;i.set(d,f);let m=c.listIsBullet?"\u2022":xm(f,p);u.attrs={...u.attrs,listMarker:m};}o.push(u);}break;case "table":o.push(vc(a,l,n));break;case "image":o.push(Em(a,l,n.pageContentHeight));break;case "horizontalRule":case "pageBreak":{let u={kind:"pageBreak",id:Vn(),pmStart:l,pmEnd:l+a.nodeSize};o.push(u);break}}}),o}var Xt=11,bo="Calibri",ca=1.15,jn=.5;function Ec(e){return {fontFamily:e.fontFamily??bo,fontSize:e.fontSize??Xt,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function Lc(e,t,n){let o=chunkY37VT37I_cjs.f(e),r=n?.ascent??o*.8,i=n?.descent??o*.2,a=n?.lineHeight??o*ca,s;return t?.lineRule==="exact"&&t.line!==void 0?s=t.line:t?.lineRule==="atLeast"&&t.line!==void 0?s=Math.max(t.line,a):t?.line!==void 0&&t?.lineUnit==="multiplier"?s=a*t.line:t?.line!==void 0&&t?.lineUnit==="px"?s=t.line:s=a,{ascent:r,descent:i,lineHeight:s}}function Mc(e,t,n){let o=chunkY37VT37I_cjs.b({fontSize:e,fontFamily:n??bo});return Lc(e,t,o)}function Ic(e){return e.kind==="text"}function Mm(e){return e.kind==="tab"}function Im(e){return e.kind==="image"}function Fm(e){return e.kind==="lineBreak"}function Lm(e){return e.kind==="field"}function Bm(e){return !e.text||e.text.length===0}function Am(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 Dm=48;function Fc(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 yo(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,c=l?.right??0,d=(l?.firstLine??0)-(l?.hanging??0),p=Math.max(1,t-u-c),f=Math.max(1,p-d),m=0,b=chunkY37VT37I_cjs.f(Xt)*ca,g=Fc(0,b,a,s),k=Math.max(1,f-g.leftMargin-g.rightMargin),P=[];if(o.length===0){let F=r?.defaultFontSize??Xt,R=r?.defaultFontFamily??bo,te=Mc(F,i,R);return P.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...te}),{kind:"paragraph",lines:P,totalHeight:te.lineHeight}}if(o.length===1&&Ic(o[0])&&Bm(o[0])){let F=o[0],R=F.fontSize??r?.defaultFontSize??Xt,te=F.fontFamily??r?.defaultFontFamily??bo,re=Mc(R,i,te);return P.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...re}),{kind:"paragraph",lines:P,totalHeight:re.lineHeight}}let S={fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,maxFontSize:Xt,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:k,leftOffset:g.leftMargin,rightOffset:g.rightMargin},B=()=>{let F=Lc(S.maxFontSize,i,S.maxFontMetrics),R={...F};S.maxImageHeightPx>R.lineHeight&&(R.lineHeight=S.maxImageHeightPx,R.ascent=S.maxImageHeightPx*.8,R.descent=S.maxImageHeightPx*.2);let te={fromRun:S.fromRun,fromChar:S.fromChar,toRun:S.toRun,toChar:S.toChar,width:S.width,...R};S.leftOffset>0&&(te.leftOffset=S.leftOffset),S.rightOffset>0&&(te.rightOffset=S.rightOffset),P.push(te),m+=F.lineHeight;},E=(F,R)=>{B();let te=chunkY37VT37I_cjs.f(Xt)*ca,re=Fc(m,te,a,s),Q=Math.max(1,p-re.leftMargin-re.rightMargin);S={fromRun:F,fromChar:R,toRun:F,toChar:R,width:0,maxFontSize:Xt,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:Q,leftOffset:re.leftMargin,rightOffset:re.rightMargin};},J=F=>{let R=F.fontSize??Xt;R>S.maxFontSize&&(S.maxFontSize=R,S.maxFontMetrics=chunkY37VT37I_cjs.b(F));};for(let F=0;F<o.length;F++){let R=o[F];if(Fm(R)){S.toRun=F,S.toChar=0,E(F+1,0);continue}if(Mm(R)){let te=Ec(R);J(te);let re=R.width??Dm;S.width+re>S.availableWidth+jn&&(E(F,0),J(te)),S.width+=re,S.toRun=F,S.toChar=1;continue}if(Im(R)){let te=R.wrapType,re=R.displayMode==="float"||te&&["square","tight","through"].includes(te);if(R.position&&re){S.toRun=F,S.toChar=1;continue}if(te==="topAndBottom"||R.displayMode==="block"){S.width>0&&E(F,0);let L=R.height,N=R.distTop??6,Y=R.distBottom??6;S.toRun=F,S.toChar=1,S.maxImageHeightPx=L+N+Y,E(F+1,0);continue}let Q=R.width,pe=R.height;pe>S.maxImageHeightPx&&(S.maxImageHeightPx=pe),S.width+Q>S.availableWidth+jn&&E(F,0),S.width+=Q,S.toRun=F,S.toChar=1;continue}if(Lm(R)){let te=R.fallback||"1",re={fontFamily:R.fontFamily??bo,fontSize:R.fontSize??Xt,bold:R.bold,italic:R.italic};J(re);let Q=chunkY37VT37I_cjs.c(te,re);S.width>0&&S.width+Q>S.availableWidth+jn&&(E(F,0),J(re)),S.width+=Q,S.toRun=F,S.toChar=1;continue}if(Ic(R)){let te=R,re=te.text,Q=Ec(te);if(J(Q),!re||re.length===0){S.toRun=F,S.toChar=0;continue}let pe=Am(re),L=0;for(;L<re.length;){let N=re.length;for(let le of pe)if(le>L){N=le;break}let Y=re.slice(L,N),xe=chunkY37VT37I_cjs.c(Y,Q);if(xe>S.availableWidth+jn){S.width>0&&(E(F,L),J(Q));let{charWidths:le}=chunkY37VT37I_cjs.d(Y,Q),Re=0;for(;Re<Y.length;){let T=0,I=Re;for(;I<Y.length;){let y=le[I]??0;if(T+y>S.availableWidth+jn)break;T+=y,I+=1;}I===Re&&(I=Math.min(Y.length,Re+1),T=le[Re]??0),S.width+=T,S.toRun=F,S.toChar=L+I,Re=I,Re<Y.length&&(E(F,L+Re),J(Q));}L=N;continue}S.width>0&&S.width+xe>S.availableWidth+jn&&(E(F,L),J(Q)),S.width+=xe,S.toRun=F,S.toChar=N,L=N;}}}B();let A=P.reduce((F,R)=>F+R.lineHeight,0);return i?.before&&(A+=i.before),i?.after&&(A+=i.after),{kind:"paragraph",lines:P,totalHeight:A}}var Hm=new Map;function Bc(){Hm.clear();}var Nm=new Map;function Ac(){Nm.clear();}var zm=new Map;function Dc(){zm.clear();}function da(){Bc(),Ac(),Dc();}function Om(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function $m(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,c=i.slice(l,u);c.length>0&&n.push({...r,text:c});}else n.push(r);}}}return n}function Wm(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??"",c=s===t.fromRun?t.fromChar:0,d=s===t.toRun?t.toChar:u.length;a+=d-c;}else (l.kind==="tab"||l.kind==="lineBreak"||l.kind==="image")&&(a+=1);}o=n+a;}return {pmStart:n,pmEnd:o}}function _m(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 Vm(e,t,n,o){let{pmStart:r,pmEnd:i}=Wm(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=$m(e,t);if(u.length===0)return {charOffset:0,pmPosition:r};let c=0,d=0;for(let f of u){if(f.kind==="tab"){let m=f.width??48,b=c+m;if(l<=b){let g=c+m/2;return l<g?{charOffset:d,pmPosition:r+d}:{charOffset:d+1,pmPosition:r+d+1}}c=b,d+=1;continue}if(f.kind==="image"){let m=f.width,b=c+m;if(l<=b){let g=c+m/2;return l<g?{charOffset:d,pmPosition:r+d}:{charOffset:d+1,pmPosition:r+d+1}}c=b,d+=1;continue}if(f.kind==="lineBreak"){if(l>=c)return {charOffset:d,pmPosition:r+d};d+=1;continue}if(f.kind==="text"){let m=f.text??"";if(m.length===0)continue;let b=Om(f),g=chunkY37VT37I_cjs.d(m,b),k=c+g.width;if(l<=k){let P=l-c,S=chunkY37VT37I_cjs.e(P,g.charWidths),B=d+S;return {charOffset:B,pmPosition:r+B}}c=k,d+=m.length;}}return {charOffset:i-r,pmPosition:i}}function Hc(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=_m(l,i,a.fromLine,a.toLine);if(u===null)return null;let c=l.lines[u];if(!c)return null;let d=0;for(let S=a.fromLine;S<u;S++)d+=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:k,pmPosition:P}=Vm(s,c,g,b);return {pmPosition:P,charOffset:k,lineIndex:u}}function jm(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 Hc(i)?.pmPosition??null}function ua(e,t){if(t)return jm(t);if(!e)return null;let{fragment:n}=e;return n.kind==="paragraph"?Hc(e)?.pmPosition??null:n.kind==="image"?n.pmStart??null:null}function Nc(e,t,n,o=1){let r=document.elementsFromPoint(t,n),i=r.find(c=>c.classList.contains("layout-page"));if(!i)return null;let a=r.find(c=>c.tagName==="SPAN"&&c.dataset.pmStart!==void 0&&c.dataset.pmEnd!==void 0);if(a)return pa(a,t);let s=r.find(c=>c.classList.contains("layout-empty-run"));if(s){let c=s.closest(".layout-paragraph");if(c&&c.dataset.pmStart)return Number(c.dataset.pmStart)}let l=r.find(c=>c.classList.contains("layout-paragraph")&&c.dataset.pmStart!==void 0);if(l&&l.dataset.pmStart)return Number(l.dataset.pmStart);let u=r.find(c=>c.classList.contains("layout-table-cell"));return u?Um(u,t,n):Gm(e,i,t,n)}function pa(e,t,n){let o=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(e.classList.contains("layout-run-tab")){let d=e.getBoundingClientRect(),p=(d.left+d.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,c=s;for(;u<c;){let d=Math.floor((u+c)/2),p=l.createRange();p.setStart(a,d),p.setEnd(a,d);let m=p.getBoundingClientRect().left;t<m?c=d:u=d+1;}if(u>0&&u<=s){let d=l.createRange();d.setStart(a,u-1),d.setEnd(a,u-1);let p=d.getBoundingClientRect();d.setStart(a,Math.min(u,s)),d.setEnd(a,Math.min(u,s));let f=d.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 Um(e,t,n){let o=e.querySelector(".layout-empty-run");if(o){let d=o.closest(".layout-paragraph");if(d&&d.dataset.pmStart)return Number(d.dataset.pmStart)}let r=e.querySelectorAll(".layout-line"),i=null,a=1/0;for(let d of Array.from(r)){let p=d,f=p.getBoundingClientRect(),m=(f.top+f.bottom)/2,b=Math.abs(n-m);b<a&&(a=b,i=p);}if(!i){let d=e.querySelector(".layout-paragraph[data-pm-start]");return d?.dataset.pmStart?Number(d.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 d=i.closest(".layout-paragraph");return d?.dataset.pmStart?Number(d.dataset.pmStart):null}let l=null,u=1/0;for(let d of Array.from(s)){let p=d,f=p.getBoundingClientRect();if(t>=f.left&&t<=f.right)return pa(p,t);let m=t<f.left?f.left-t:t-f.right;m<u&&(u=m,l=p);}if(!l)return null;let c=l.getBoundingClientRect();return t<c.left?Number(l.dataset.pmStart):Number(l.dataset.pmEnd)}function Gm(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,k=Math.abs(o-g);k<l&&(l=k,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 c=null,d=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect();if(n>=b.left&&n<=b.right)return pa(m,n);let g=n<b.left?b.left-n:n-b.right;g<d&&(d=g,c=m);}if(!c)return null;let p=c.getBoundingClientRect();return n<p.left?Number(c.dataset.pmStart):Number(c.dataset.pmEnd)}var un={fragment:"layout-fragment",paragraph:"layout-fragment-paragraph",table:"layout-fragment-table",image:"layout-fragment-image"};function Km(e){return e.kind==="paragraph"}function qm(e){return e.kind==="table"}function Ym(e){return e.kind==="image"}function Gr(e){e.style.position="absolute",e.style.overflow="hidden";}function Xm(e,t,n){let o=n.createElement("div");return o.className=`${un.fragment} ${un.paragraph}`,Gr(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 Zm(e,t,n){let o=n.createElement("div");return o.className=`${un.fragment} ${un.table}`,Gr(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 Jm(e,t,n){let o=n.createElement("div");return o.className=`${un.fragment} ${un.image}`,Gr(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 xo(e,t,n={}){let o=n.document??document;if(Km(e))return Xm(e,t,o);if(qm(e))return Zm(e,t,o);if(Ym(e))return Jm(e,t,o);let r=o.createElement("div");r.className=un.fragment,Gr(r);let i=e;return i.blockId!==void 0&&(r.dataset.blockId=String(i.blockId)),i.kind&&(r.dataset.kind=i.kind),r}function fa(e){return e/1440*96}function Qm(e){return e/96*1440}function eg(e){let{explicitStops:t=[],defaultTabInterval:n=720,leftIndent:o=0}=e,r=t.filter(d=>d.val!=="clear").filter(d=>d.pos>=o),i=t.filter(d=>d.val==="clear").map(d=>d.pos),a=r.reduce((d,p)=>Math.max(d,p.pos),0),s=[...r];o>0&&!r.some(d=>d.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,c=o+14400;for(;u<c;){u+=n;let d=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;!d&&!p&&!f&&s.push({val:"start",pos:u,leader:"none"});}return s.sort((d,p)=>d.pos-p.pos)}function zc(e,t,n="",o,r="."){let{defaultTabInterval:i=720}=t,a=Qm(e),l=eg(t).find(d=>d.pos>a);if(!l){let d=fa(i),p=d-e%d;return p<=0&&(p=d),{width:p,alignment:"default"}}let c=fa(l.pos)-e;if(l.val==="center"||l.val==="end"){let d=o?o(n):0;l.val==="center"?c-=d/2:c-=d;}else if(l.val==="decimal"){let d=n.indexOf(r);if(d>=0&&o){let p=n.slice(0,d),f=o(p);c-=f;}}else if(l.val==="bar")return {width:0,leader:l.leader,alignment:"bar"};if(c<1){let d=fa(i),p=d-e%d;return p<=0&&(p=d),{width:p,alignment:"default"}}return {width:c,leader:l.leader,alignment:l.val}}var Pt={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 Kr(e){return e.kind==="tab"}function ma(e){return e.kind==="image"}function ga(e){return e.kind==="lineBreak"}function ha(e){return e.kind==="field"}var $c='"Segoe UI", Arial, sans-serif';function tg(e,t){if(t.fontFamily){let o=t.fontFamily.includes(" ")?`"${t.fontFamily}"`:t.fontFamily;e.style.fontFamily=`${o}, ${$c}`;}if(t.fontSize){let o=t.fontSize*96/72;e.style.fontSize=`${o}px`;}t.bold&&(e.style.fontWeight="bold"),t.italic&&(e.style.fontStyle="italic"),t.color&&(e.style.color=t.color),t.letterSpacing&&(e.style.letterSpacing=`${t.letterSpacing}px`),t.highlight&&(e.style.backgroundColor=t.highlight);let n=[];t.underline&&(n.push("underline"),typeof t.underline=="object"&&(t.underline.style&&(e.style.textDecorationStyle=t.underline.style),t.underline.color&&(e.style.textDecorationColor=t.underline.color))),t.strike&&n.push("line-through"),n.length>0&&(e.style.textDecorationLine=n.join(" ")),t.superscript&&(e.style.verticalAlign="super",e.style.fontSize="0.75em"),t.subscript&&(e.style.verticalAlign="sub",e.style.fontSize="0.75em");}function Un(e,t,n){t!==void 0&&(e.dataset.pmStart=String(t)),n!==void 0&&(e.dataset.pmEnd=String(n));}function ba(e,t){let n=t.createElement("span");if(n.className=`${Pt.run} ${Pt.text}`,tg(n,e),Un(n,e.pmStart,e.pmEnd),e.hyperlink){let o=t.createElement("a");o.href=e.hyperlink.href,e.hyperlink.href.startsWith("#")||(o.target="_blank",o.rel="noopener noreferrer"),e.hyperlink.tooltip&&(o.title=e.hyperlink.tooltip),o.textContent=e.text,o.style.color=e.color||"#0563c1",o.style.textDecoration="underline",n.appendChild(o);}else n.textContent=e.text;return n}function Wc(e,t,n,o){let r=t.createElement("span");if(r.className=`${Pt.run} ${Pt.tab}`,r.style.display="inline-block",r.style.width=`${n}px`,Un(r,e.pmStart,e.pmEnd),o&&o!=="none"){let i=ng(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 ng(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "middleDot":return "\xB7";default:return null}}function og(e,t){let n=t.createElement("img");return n.className=`${Pt.run} ${Pt.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",Un(n,e.pmStart,e.pmEnd),n}function Oc(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),Un(n,e.pmStart,e.pmEnd),n.appendChild(o),n}function _c(e,t){let n=e.displayMode,o=e.wrapType;return n==="float"||o&&["square","tight","through"].includes(o)||n==="block"||o==="topAndBottom"?Oc(e,t):og(e,t)}function Vc(e,t){let n=t.createElement("br");return n.className=`${Pt.run} ${Pt.lineBreak}`,Un(n,e.pmStart,e.pmEnd),n}function jc(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 ba(r,t)}function rg(e,t,n){if(qr(e))return ba(e,t);if(Kr(e))return Wc(e,t,48,void 0);if(ma(e))return _c(e,t);if(ga(e))return Vc(e,t);if(ha(e)&&n)return jc(e,t,n);let o=t.createElement("span");return o.className=Pt.run,o}function Uc(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 ig(e){return {val:e.val,pos:e.pos,leader:e.leader}}function ag(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(ha(i))i.fieldType==="PAGE"&&n?o+=String(n.pageNumber):i.fieldType==="NUMPAGES"&&n?o+=String(n.totalPages):o+=i.fallback??"";else if(Kr(i)||ga(i))break}return o}function sg(e){let n=e.createElement("canvas").getContext("2d");return (o,r=11,i="Calibri")=>{if(!n)return o.length*7;let a=i.includes(" ")?`"${i}"`:i,s=r*96/72;return n.font=`${s}px ${a}, ${$c}`,n.measureText(o).width}}function Gc(e,t,n,o,r){let i=o.createElement("div");i.className=Pt.line,i.style.height=`${t.lineHeight}px`,i.style.lineHeight=`${t.lineHeight}px`;let a=Uc(e,t);if(a.length===0){let m=o.createElement("span");return m.className=`${Pt.run} layout-empty-run`,m.innerHTML="&nbsp;",i.appendChild(m),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",i.style.overflow="visible";let u=a.some(Kr),c,d=sg(o);if(u){let m=r?.tabStops?.map(ig),b=r?.leftIndentPx?Math.round(r.leftIndentPx*15):0;c={explicitStops:m,leftIndent:b};}let p=0,f=r?.leftIndentPx??0;if(r?.isFirstLine){let m=r?.firstLineIndentPx??0;p=f+m;}else p=f;for(let m=0;m<a.length;m++){let b=a[m];if(Kr(b)&&c){let g=ag(a,m,r?.context),k=zc(p,c,g,d),P=Wc(b,o,k.width,k.leader);i.appendChild(P),p+=k.width;}else if(qr(b)){let g=ba(b,o);i.appendChild(g);let k=b.fontSize||11,P=b.fontFamily||"Calibri";p+=d(b.text,k,P);}else if(ma(b)){if(b.displayMode==="float"||b.wrapType&&["square","tight","through"].includes(b.wrapType))continue;let k=_c(b,o);i.appendChild(k),b.displayMode!=="block"&&b.wrapType!=="topAndBottom"&&(p+=b.width);}else if(ga(b)){let g=Vc(b,o);i.appendChild(g);}else if(ha(b)&&r?.context){let g=jc(b,o,r.context);i.appendChild(g);let k=b.fallback??"";b.fieldType==="PAGE"?k=String(r.context.pageNumber):b.fieldType==="NUMPAGES"&&(k=String(r.context.totalPages));let P=b.fontSize||11,S=b.fontFamily||"Calibri";p+=d(k,P,S);}else {let g=rg(b,o,r?.context);i.appendChild(g);}}return i}function Cn(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Pt.fragment,a.style.position="relative",a.dataset.blockId=String(e.blockId),a.dataset.fromLine=String(e.fromLine),a.dataset.toLine=String(e.toLine),Un(a,e.pmStart,e.pmEnd),e.continuesFromPrev&&(a.dataset.continuesFromPrev="true"),e.continuesOnNext&&(a.dataset.continuesOnNext="true");for(let S of t.runs)ma(S)&&(S.displayMode==="float"||S.wrapType&&["square","tight","through"].includes(S.wrapType));let s=n.lines.slice(e.fromLine,e.toLine),l=t.attrs?.alignment;t.attrs?.styleId&&(a.dataset.styleId=t.attrs.styleId),l&&(l==="center"?a.style.textAlign="center":l==="right"?a.style.textAlign="right":a.style.textAlign="left");let u=t.attrs?.indent,c=0,d=0;u&&(u.left&&u.left>0&&(c=u.left),u.right&&u.right>0&&(d=u.right));let p=t.attrs?.borders;if(p){let S=E=>{switch(E){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",p.top&&(a.style.borderTop=`${p.top.width}px ${S(p.top.style)} ${p.top.color}`),p.bottom&&(a.style.borderBottom=`${p.bottom.width}px ${S(p.bottom.style)} ${p.bottom.color}`),p.left&&(a.style.borderLeft=`${p.left.width}px ${S(p.left.style)} ${p.left.color}`),p.right&&(a.style.borderRight=`${p.right.width}px ${S(p.right.style)} ${p.right.color}`),(p.top||p.bottom||p.left||p.right)&&(a.style.paddingLeft=p.left?"4px":"0",a.style.paddingRight=p.right?"4px":"0",a.style.paddingTop=p.top?"2px":"0",a.style.paddingBottom=p.bottom?"6px":"0");}t.attrs?.shading&&(a.style.backgroundColor=t.attrs.shading);let f=e.width-c-d,b=t.runs[t.runs.length-1]?.kind==="lineBreak",g=n.lines.length,k=0;u?.hanging&&u.hanging>0?k=-u.hanging:u?.firstLine&&u.firstLine>0&&(k=u.firstLine);let P=0;for(let S=0;S<s.length;S++){let B=s[S],E=e.fromLine+S,J=E===g-1,Z=E===0&&!e.continuesFromPrev,A=B.leftOffset??0,F=B.rightOffset??0,R=f;if(Z){let pe=u?.hanging&&u.hanging>0,L=u?.firstLine&&u.firstLine>0;pe&&u?.hanging?R=f+u.hanging:L&&u?.firstLine&&(R=f-u.firstLine);}let te=Gc(t,B,l,i,{availableWidth:R-A-F,isLastLine:J,isFirstLine:Z,paragraphEndsWithLineBreak:b,tabStops:t.attrs?.tabs,leftIndentPx:c,firstLineIndentPx:Z?k:0,context:o});A>0&&(te.style.marginLeft=`${A}px`),F>0&&(te.style.marginRight=`${F}px`),P+=B.lineHeight;let re=u?.hanging&&u.hanging>0,Q=u?.firstLine&&u.firstLine>0;if(Z?c>0&&re?(te.style.paddingLeft=`${c}px`,te.style.textIndent=`-${u.hanging}px`):c>0&&Q?(te.style.paddingLeft=`${c}px`,te.style.textIndent=`${u.firstLine}px`):c>0?te.style.paddingLeft=`${c}px`:Q&&(te.style.textIndent=`${u.firstLine}px`):c>0?te.style.paddingLeft=`${c}px`:re&&(te.style.paddingLeft=`${u.hanging}px`),d>0&&(te.style.paddingRight=`${d}px`),Z&&t.attrs?.listMarker){let pe=Math.max(0,c-(u?.hanging??0));te.style.paddingLeft=`${pe}px`,te.style.textIndent="0";let L=lg(t.attrs.listMarker,u,i);te.insertBefore(L,te.firstChild);}a.appendChild(te);}return a}function lg(e,t,n){let o=n.createElement("span");o.className="layout-list-marker",o.style.display="inline-block",o.textContent=e;let r=t?.hanging??24;return o.style.minWidth=`${r}px`,o.style.textAlign="left",o.style.boxSizing="border-box",o}var Gt={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 cg(e,t,n,o){let r=o.createElement("div");r.className=Gt.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`;for(let l=0;l<e.blocks.length;l++){let u=e.blocks[l],c=t.blocks[l];if(u?.kind==="paragraph"&&c?.kind==="paragraph"){let d=u,p=c,f={blockId:d.id,width:s,height:p.totalHeight,fromLine:0,toLine:p.lines.length,pmStart:d.pmStart,pmEnd:d.pmEnd},m=Cn(f,d,p,n,{document:o});m.style.position="relative",r.appendChild(m);}else if(u?.kind==="table"&&c?.kind==="table"){let f=dg(u,c,n,o);f.style.position="relative",r.appendChild(f);}}return r}function dg(e,t,n,o){let r=o.createElement("div");r.className=`${Gt.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"),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 c=e.rows[u],d=t.rows[u];if(!c||!d)continue;let p=Kc(c,d,u,l,t.columnWidths,e.rows.length,n,o,s,i);r.appendChild(p),l+=d.height;}return r.style.height=`${l}px`,r}function Yr(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 ug(e,t,n,o,r,i,a){let s=a.createElement("div");s.className=Gt.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,c=e.padding?.bottom??1,d=e.padding?.left??7;if(s.style.padding=`${l}px ${u}px ${c}px ${d}px`,e.borders&&(r.isFirstRow&&Yr(s,"top",e.borders.top),Yr(s,"right",e.borders.right),Yr(s,"bottom",e.borders.bottom),r.isFirstCol&&Yr(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=cg(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 Kc(e,t,n,o,r,i,a,s,l,u){let c=s.createElement("div");c.className=Gt.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 d=new Set;if(l){for(let[,m]of l)if(m.startRow<n&&m.startRow+m.rowSpan>n)for(let b=0;b<m.colSpan;b++)d.add(m.columnIndex+b);}let p=0,f=0;for(;d.has(f);)p+=r[f]??0,f++;for(let m=0;m<e.cells.length;m++){let b=e.cells[m],g=t.cells[m];if(!b||!g)continue;let k=b.colSpan??1,P=b.rowSpan??1,S=t.height;if(P>1&&u){S=0;for(let F=n;F<n+P&&F<u.length-1;F++)S+=(u[F+1]??0)-(u[F]??0);S===0&&(S=t.height*P);}let B=n===0,J=f===0;f+k>=r.length;let A=ug(b,g,p,S,{isFirstRow:B,isFirstCol:J},a,s);if(A.dataset.cellIndex=String(m),A.dataset.columnIndex=String(f),P>1&&(A.dataset.rowSpan=String(P)),c.appendChild(A),P>1&&l){let F=`${n}-${f}`;l.set(F,{cell:b,cellMeasure:g,columnIndex:f,startRow:n,rowSpan:P,colSpan:k,x:p,totalHeight:S});}for(let F=0;F<k&&f+F<r.length;F++)p+=r[f+F]??0;for(f+=k;d.has(f);)p+=r[f]??0,f++;}return c}function Xr(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Gt.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 f=0;f<n.columnWidths.length-1;f++){s+=n.columnWidths[f]??0;let m=i.createElement("div");m.className=Gt.resizeHandle,m.style.position="absolute",m.style.left=`${s-3}px`,m.style.top="0",m.style.width="6px",m.style.height="100%",m.style.cursor="col-resize",m.style.zIndex="10",m.dataset.columnIndex=String(f),m.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(m.dataset.tablePmStart=String(e.pmStart)),a.appendChild(m);}let l=[],u=0;for(let f=0;f<n.rows.length;f++)l.push(u),u+=n.rows[f]?.height??0;l.push(u);let c=new Map,d=0;for(let f=e.fromRow;f<e.toRow;f++){let m=t.rows[f],b=n.rows[f];if(!m||!b)continue;let g=Kc(m,b,f,d,n.columnWidths,t.rows.length,o,i,c,l);a.appendChild(g),d+=b.height;}let p=0;for(let f=e.fromRow;f<e.toRow;f++)if(p+=n.rows[f]?.height??0,f<e.toRow-1){let m=i.createElement("div");m.className=Gt.rowResizeHandle,m.style.position="absolute",m.style.left="0",m.style.top=`${p-3}px`,m.style.width="100%",m.style.height="6px",m.style.cursor="row-resize",m.style.zIndex="10",m.dataset.rowIndex=String(f),m.dataset.tableBlockId=String(e.blockId),e.pmStart!==void 0&&(m.dataset.tablePmStart=String(e.pmStart)),a.appendChild(m);}if(e.toRow===t.rows.length){let f=i.createElement("div");f.className=Gt.tableEdgeHandleBottom,f.style.position="absolute",f.style.left="0",f.style.top=`${p-3}px`,f.style.width="100%",f.style.height="6px",f.style.cursor="row-resize",f.style.zIndex="10",f.dataset.rowIndex=String(t.rows.length-1),f.dataset.tableBlockId=String(e.blockId),f.dataset.isEdge="bottom",e.pmStart!==void 0&&(f.dataset.tablePmStart=String(e.pmStart)),a.appendChild(f);}if(e.toRow===t.rows.length){let f=n.columnWidths.reduce((b,g)=>b+g,0),m=i.createElement("div");m.className=Gt.tableEdgeHandleRight,m.style.position="absolute",m.style.left=`${f-3}px`,m.style.top="0",m.style.width="6px",m.style.height="100%",m.style.cursor="col-resize",m.style.zIndex="10",m.dataset.columnIndex=String(n.columnWidths.length-1),m.dataset.tableBlockId=String(e.blockId),m.dataset.isEdge="right",e.pmStart!==void 0&&(m.dataset.tablePmStart=String(e.pmStart)),a.appendChild(m);}return a}var ya={image:"layout-image",imageAnchored:"layout-image-anchored"};function Zr(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=ya.image,e.isAnchored&&a.classList.add(ya.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");return 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,a.appendChild(s),a}var Jr={page:"layout-page",content:"layout-page-content",header:"layout-page-header",footer:"layout-page-footer"};function pg(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=An(l,a[s],o.theme);for(let[c,d]of Object.entries(u))e.style[c]=String(d);}}}}function fg(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 mg(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 Qr(e){return e===void 0?0:Math.round(e*96/914400)}function gg(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function hg(e,t,n){let o=[];for(let r of e.runs){if(r.kind!=="image")continue;let i=r;if(!gg(i))continue;let a=i.position,s=i.distTop??0,l=i.distBottom??0,u=i.distLeft??12,c=i.distRight??12,d="left",p=0;if(a?.horizontal){let m=a.horizontal;m.align==="right"?(d="right",p=n-i.width):m.align==="left"?(d="left",p=0):m.align==="center"?(d="left",p=(n-i.width)/2):m.posOffset!==void 0&&(p=Qr(m.posOffset),d=p>n/2?"right":"left");}else i.cssFloat==="right"&&(d="right",p=n-i.width);let f=0;if(a?.vertical){let m=a.vertical;m.align==="top"?f=0:m.align==="bottom"?f=t:m.posOffset!==void 0?f=Qr(m.posOffset):f=t,m.relativeTo==="margin"&&(m.align==="top"||m.posOffset!==void 0)||m.relativeTo==="paragraph"&&(f=t+f);}else f=t;o.push({src:i.src,width:i.width,height:i.height,alt:i.alt,transform:i.transform,side:d,x:p,y:f,distTop:s,distBottom:l,distLeft:u,distRight:c,pmStart:i.pmStart,pmEnd:i.pmEnd});}return o}function bg(e,t){let n=[],o=0,r=0,i=1/0,a=0;for(let s of e){let l=s.x-s.distLeft,u=s.x+s.width+s.distRight,c=s.y-s.distTop,d=s.y+s.height+s.distBottom;s.side==="left"?o=Math.max(o,u):r=Math.max(r,t-l),i=Math.min(i,c),a=Math.max(a,d);}return (o>0||r>0)&&n.push({leftMargin:o,rightMargin:r,topY:i===1/0?0:i,bottomY:a}),n}function yg(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.width=o.width,i.height=o.height,o.alt&&(i.alt=o.alt),o.transform&&(i.style.transform=o.transform),r.appendChild(i),n.appendChild(r);}return n}function qc(e,t,n){let o=n.document??document,r=o.createElement("div");r.style.position="relative";let i=t.contentWidth??600,a=[],s=0;for(let l=0;l<e.blocks.length;l++){let u=e.blocks[l],c=e.measures[l];if(u?.kind==="paragraph"&&c?.kind==="paragraph"){let d=u,p=c,f=s,m=[];for(let P of d.runs)if(P.kind==="image"&&"position"in P&&P.position){let S=P;a.push({src:S.src,width:S.width,height:S.height,alt:S.alt,paragraphY:f,position:S.position});}else m.push(P);let b={...d,runs:m},g={blockId:d.id,width:i,height:p.totalHeight,fromLine:0,toLine:p.lines.length},k=Cn(g,b,p,t,{document:o});k.style.position="relative",k.style.marginBottom="0",r.appendChild(k),s+=p.totalHeight;}}for(let l of a){let u=o.createElement("img");u.src=l.src,u.width=l.width,u.height=l.height,l.alt&&(u.alt=l.alt),u.style.position="absolute";let c=l.position.horizontal;c&&(c.align==="right"?u.style.right="0":c.align==="center"?(u.style.left="50%",u.style.transform="translateX(-50%)"):c.posOffset!==void 0?u.style.left=`${Qr(c.posOffset)}px`:u.style.left="0");let d=l.position.vertical;if(d){let p=l.paragraphY;d.align==="bottom"?u.style.bottom="0":d.align==="center"?(u.style.top="50%",u.style.transform=(u.style.transform||"")+" translateY(-50%)"):d.posOffset!==void 0?u.style.top=`${p+Qr(d.posOffset)}px`:u.style.top=`${p}px`;}else u.style.top=`${l.paragraphY}px`;r.appendChild(u);}return r}function xg(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 Sg(e,t,n={}){let o=n.document??document,r=o.createElement("div");r.className=n.pageClassName??Jr.page,r.dataset.pageNumber=String(e.number),pg(r,e.size.w,e.size.h,n);let i=o.createElement("div");i.className=Jr.content,fg(i,e);let a=e.size.w-e.margins.left-e.margins.right,s=[],l=[];for(let c of e.fragments)if(c.kind==="paragraph"&&n.blockLookup){let d=n.blockLookup.get(String(c.blockId));if(d?.block.kind==="paragraph"){let p=d.block,f=c.y-e.margins.top,m=hg(p,f,a);s.push(...m);}}for(let c of s)l.push({side:c.side,x:c.x,y:c.y,width:c.width,height:c.height,distTop:c.distTop,distBottom:c.distBottom,distLeft:c.distLeft,distRight:c.distRight});if(n.blockLookup)for(let c of e.fragments){if(c.kind!=="table")continue;let d=n.blockLookup.get(String(c.blockId));if(d?.block.kind!=="table")continue;let f=d.block.floating;if(!f)continue;let m=c.x-e.margins.left,b=c.y-e.margins.top,g=f.topFromText??0,k=f.bottomFromText??0,P=f.leftFromText??12,S=f.rightFromText??12,B=m<a/2?"left":"right";l.push({side:B,x:m,y:b,width:c.width,height:c.height,distTop:g,distBottom:k,distLeft:P,distRight:S});}bg(l,a);if(s.length>0){let c=yg(s,o);i.appendChild(c);}for(let c of e.fragments){let d,p={...t,section:"body",contentWidth:a};c.y-e.margins.top;if(n.blockLookup&&c.blockId){let m=n.blockLookup.get(String(c.blockId));c.kind==="paragraph"&&m?.block.kind==="paragraph"&&m?.measure.kind==="paragraph"?d=Cn(c,m.block,m.measure,p,{document:o}):c.kind==="table"&&m?.block.kind==="table"&&m?.measure.kind==="table"?d=Xr(c,m.block,m.measure,p,{document:o}):c.kind==="image"&&m?.block.kind==="image"&&m?.measure.kind==="image"?d=Zr(c,m.block,m.measure,p,{document:o}):d=xo(c,p,{document:o});}else d=xo(c,p,{document:o});mg(d,c,{left:e.margins.left,top:e.margins.top}),i.appendChild(d);}if(n.footnoteArea&&n.footnoteArea.length>0){let c=xg(n.footnoteArea,a,o);c.style.position="absolute";let d=e.footnoteReservedHeight??0,p=e.size.h-e.margins.bottom-e.margins.top;c.style.top=`${p-d}px`,c.style.left="0",c.style.right="0",i.appendChild(c);}r.appendChild(i);{let d=n.headerDistance??e.margins.header??48,p=e.size.w-e.margins.left-e.margins.right,f=Math.max(e.margins.top-d,48),b=(n.headerContent?.height??0)>f,g=o.createElement("div");if(g.className=Jr.header,g.style.position="absolute",g.style.top=`${d}px`,g.style.left=`${e.margins.left}px`,g.style.right=`${e.margins.right}px`,g.style.width=`${p}px`,b||(g.style.maxHeight=`${f}px`,g.style.overflow="hidden"),g.style.minHeight="24px",n.headerContent&&n.headerContent.blocks.length>0){let k=qc(n.headerContent,{...t,section:"header",contentWidth:p},n);g.appendChild(k);}r.appendChild(g);}{let d=n.footerDistance??e.margins.footer??48,p=e.size.w-e.margins.left-e.margins.right,f=Math.max(e.margins.bottom-d,48),b=(n.footerContent?.height??0)>f,g=o.createElement("div");if(g.className=Jr.footer,g.style.position="absolute",g.style.bottom=`${d}px`,g.style.left=`${e.margins.left}px`,g.style.right=`${e.margins.right}px`,g.style.width=`${p}px`,b||(g.style.maxHeight=`${f}px`,g.style.overflow="hidden"),g.style.minHeight="24px",n.footerContent&&n.footerContent.blocks.length>0){let k=qc(n.footerContent,{...t,section:"footer",contentWidth:p},n);g.appendChild(k);}r.appendChild(g);}return r}function Yc(e,t,n={}){let o=e.length,r=n.pageGap??24;t.innerHTML="",t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.gap=`${r}px`,t.style.padding=`${r}px`,t.style.backgroundColor="var(--doc-bg, #f8f9fa)";for(let i=0;i<e.length;i++){let a=e[i],s={pageNumber:a.number,totalPages:o,section:"body"},l={...n};if(n.footnotesByPage){let c=n.footnotesByPage.get(a.number);c&&c.length>0&&(l.footnoteArea=c);}let u=Sg(a,s,l);t.appendChild(u);}}var ei=class{constructor(t={}){chunkRTESADL3_cjs.e(this,"container",null);chunkRTESADL3_cjs.e(this,"blockLookup",new Map);chunkRTESADL3_cjs.e(this,"pageStates",[]);chunkRTESADL3_cjs.e(this,"totalPages",0);chunkRTESADL3_cjs.e(this,"options");chunkRTESADL3_cjs.e(this,"doc");this.options=t,this.doc=t.document??document;}setBlockLookup(t){this.blockLookup=t;}mount(t){this.container=t,this.applyContainerStyles();}unmount(){this.container&&(this.container.innerHTML=""),this.container=null,this.pageStates=[];}applyContainerStyles(){if(!this.container)return;let t=this.options.pageGap??24;this.container.style.display="flex",this.container.style.flexDirection="column",this.container.style.alignItems="center",this.container.style.gap=`${t}px`,this.container.style.padding=`${t}px`,this.container.style.backgroundColor=this.options.containerBackground??"var(--doc-bg, #f8f9fa)",this.container.style.minHeight="100%";}paint(t){if(!this.container)throw new Error("LayoutPainter: not mounted");let{pages:n}=t;this.totalPages=n.length,this.container.innerHTML="",this.pageStates=[];for(let o=0;o<n.length;o++){let r=n[o],i={pageNumber:r.number,totalPages:this.totalPages,section:"body"},a=this.renderPageWithLookup(r,i);this.container.appendChild(a),this.pageStates.push({element:a,pageNumber:r.number,fragmentCount:r.fragments.length});}}renderPageWithLookup(t,n){let o=this.doc.createElement("div");o.className="layout-page",o.dataset.pageNumber=String(t.number),o.style.position="relative",o.style.width=`${t.size.w}px`,o.style.height=`${t.size.h}px`,o.style.backgroundColor=this.options.pageBackground??"#ffffff",o.style.overflow="hidden",this.options.showShadow&&(o.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)");let r=this.doc.createElement("div");r.className="layout-page-content",r.style.position="absolute",r.style.top=`${t.margins.top}px`,r.style.left=`${t.margins.left}px`,r.style.right=`${t.margins.right}px`,r.style.bottom=`${t.margins.bottom}px`,r.style.overflow="visible";for(let i of t.fragments){let a=this.renderFragmentWithLookup(i,n);this.applyFragmentPosition(a,i),r.appendChild(a);}return o.appendChild(r),o}renderFragmentWithLookup(t,n){let o=this.blockLookup.get(String(t.blockId));if(t.kind==="paragraph"&&o){let r=o.block,i=o.measure;return Cn(t,r,i,n,{document:this.doc})}if(t.kind==="table"&&o){let r=o.block,i=o.measure;return Xr(t,r,i,n,{document:this.doc})}if(t.kind==="image"&&o){let r=o.block,i=o.measure;return Zr(t,r,i,n,{document:this.doc})}return xo(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 Zt,pn,fn,Jt,Gn,Tn,Xc,xa,ti=class{constructor(){chunkRTESADL3_cjs.g(this,Tn);chunkRTESADL3_cjs.g(this,Zt,0);chunkRTESADL3_cjs.g(this,pn,0);chunkRTESADL3_cjs.g(this,fn,false);chunkRTESADL3_cjs.g(this,Jt,null);chunkRTESADL3_cjs.g(this,Gn,new Set);}setStateSeq(t){chunkRTESADL3_cjs.h(this,Zt,t);}incrementStateSeq(){return ++chunkRTESADL3_cjs.j(this,Zt)._}getStateSeq(){return chunkRTESADL3_cjs.f(this,Zt)}getRenderSeq(){return chunkRTESADL3_cjs.f(this,pn)}onLayoutStart(){chunkRTESADL3_cjs.h(this,fn,true);}onLayoutComplete(t){chunkRTESADL3_cjs.h(this,pn,t),chunkRTESADL3_cjs.h(this,fn,false),chunkRTESADL3_cjs.i(this,Tn,Xc).call(this);}isSafeToRender(){return !chunkRTESADL3_cjs.f(this,fn)&&chunkRTESADL3_cjs.f(this,pn)>=chunkRTESADL3_cjs.f(this,Zt)}requestRender(){this.isSafeToRender()?chunkRTESADL3_cjs.i(this,Tn,xa).call(this):chunkRTESADL3_cjs.h(this,Jt,()=>chunkRTESADL3_cjs.i(this,Tn,xa).call(this));}onRender(t){return chunkRTESADL3_cjs.f(this,Gn).add(t),()=>{chunkRTESADL3_cjs.f(this,Gn).delete(t);}}reset(){chunkRTESADL3_cjs.h(this,Zt,0),chunkRTESADL3_cjs.h(this,pn,0),chunkRTESADL3_cjs.h(this,fn,false),chunkRTESADL3_cjs.h(this,Jt,null);}getDebugInfo(){return {stateSeq:chunkRTESADL3_cjs.f(this,Zt),renderSeq:chunkRTESADL3_cjs.f(this,pn),layoutUpdating:chunkRTESADL3_cjs.f(this,fn),hasPendingRender:chunkRTESADL3_cjs.f(this,Jt)!==null,isSafe:this.isSafeToRender()}}};Zt=new WeakMap,pn=new WeakMap,fn=new WeakMap,Jt=new WeakMap,Gn=new WeakMap,Tn=new WeakSet,Xc=function(){if(chunkRTESADL3_cjs.f(this,Jt)&&this.isSafeToRender()){let t=chunkRTESADL3_cjs.f(this,Jt);chunkRTESADL3_cjs.h(this,Jt,null),t();}},xa=function(){for(let t of chunkRTESADL3_cjs.f(this,Gn))try{t();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};function Jc({pagesContainerRef:e}){let t=fd.useRef(null),n=fd.useRef(-1),o=fd.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let c of Array.from(l)){let d=c,p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(d.classList.contains("layout-run-tab")){if(s>=p&&s<f)return d.getBoundingClientRect().left;continue}if(s>=p&&s<=f&&c.firstChild?.nodeType===Node.TEXT_NODE){let m=c.firstChild,b=Math.min(s-p,m.length),g=d.ownerDocument;if(!g)continue;let k=g.createRange();return k.setStart(m,b),k.setEnd(m,b),k.getBoundingClientRect().left}}let u=e.current.querySelectorAll(".layout-empty-run");for(let c of Array.from(u)){let d=c.closest(".layout-paragraph");if(!d)continue;let p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(s>=p&&s<=f)return c.getBoundingClientRect().left}return null},[e]),r=fd.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll(".layout-line");for(let u of Array.from(l)){let c=u,d=c.querySelectorAll("span[data-pm-start][data-pm-end]");for(let p of Array.from(d)){let f=p,m=Number(f.dataset.pmStart),b=Number(f.dataset.pmEnd);if(s>=m&&s<=b)return c}}for(let u of Array.from(l)){let c=u,d=c.closest(".layout-paragraph");if(!d)continue;let p=Number(d.dataset.pmStart),f=Number(d.dataset.pmEnd);if(s>=p&&s<=f&&d.querySelector(".layout-line")===c)return c}return null},[e]),i=fd.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),k=Number(m.dataset.pmEnd);if(m.classList.contains("layout-run-tab")){if(l>=b.left&&l<=b.right){let P=(b.left+b.right)/2;return l<P?g:k}continue}if(l>=b.left&&l<=b.right){let P=m.firstChild;if(!P||P.nodeType!==Node.TEXT_NODE)return g;let S=P,B=m.ownerDocument;if(!B)return g;let E=0,J=S.length;for(;E<J;){let Z=Math.floor((E+J)/2),A=B.createRange();A.setStart(S,Z),A.setEnd(S,Z),l<A.getBoundingClientRect().left?J=Z:E=Z+1;}if(E>0&&E<=S.length){let Z=B.createRange();Z.setStart(S,E-1),Z.setEnd(S,E-1);let A=Z.getBoundingClientRect().left;Z.setStart(S,Math.min(E,S.length)),Z.setEnd(S,Math.min(E,S.length));let F=Z.getBoundingClientRect().left;if(Math.abs(l-A)<Math.abs(l-F))return g+(E-1)}return g+Math.min(E,k-g)}}let c=null,d=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<d&&(d=g,c=m);}if(!c)return null;let p=c.getBoundingClientRect();return l<p.left?Number(c.dataset.pmStart):Number(c.dataset.pmEnd)},[]),a=fd.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(".layout-line"));if(u.length===0)return false;let{from:c,anchor:d}=s.state.selection;if(t.current===null){let S=o(c);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(c);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:k}=s,P=Math.max(0,Math.min(b,g.doc.content.size));try{let S=l.shiftKey?prosemirrorState.TextSelection.create(g.doc,d,P):prosemirrorState.TextSelection.create(g.doc,P);k(g.tr.setSelection(S));}catch{let S=g.doc.resolve(P),B=l.shiftKey?prosemirrorState.TextSelection.between(g.doc.resolve(d),S):prosemirrorState.TextSelection.near(S);k(g.tr.setSelection(B));}return true},[e,o,r,i]);return {stickyXRef:t,lastVisualLineIndexRef:n,getCaretClientX:o,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}var kg=12,ri=8;function Qc(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 Sa(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 wg(e,t,n){let o=[];for(let a=0;a<e.content.length;a++){let s=e.content[a],l=[];if(a===0){let c={kind:"text",text:`${t} `,fontSize:ri,superscript:true};l.push(c);}for(let c of s.content){let d=c;if(d.type==="run"&&Array.isArray(d.content)){let p=d.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=ri);for(let m of d.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:ri});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:ri}]});let r=[];for(let a of o)if(a.kind==="paragraph"){let s=yo(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 ed(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=wg(l,i,n);o.set(s.footnoteId,u),i++;}return o}function td(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+=kg,n.set(o,i));}return n}var ka=class{constructor(t,n=1){chunkRTESADL3_cjs.e(this,"pagesContainer");chunkRTESADL3_cjs.e(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(),c=a.closest(".layout-line"),d=c?c.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:d/this.zoom}}continue}if(t>=s&&t<=l&&i.firstChild?.nodeType===Node.TEXT_NODE){let u=i.firstChild,c=Math.min(t-s,u.length),d=a.ownerDocument;if(!d)continue;let p=d.createRange();p.setStart(u,c),p.setEnd(u,c);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(),c=i.closest(".layout-line"),d=c?c.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:d/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 c=a.firstChild,d=s.ownerDocument;if(!d)continue;let p=Math.max(0,t-l),f=Math.min(c.length,n-l);if(p<f){let m=d.createRange();m.setStart(c,p),m.setEnd(c,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 nd(e,t=1){return new ka(e,t)}var vg=816,sd=1056,ii={top:96,right:96,bottom:96,left:96},Pg=24,Eg=[],Mg={position:"relative",width:"100%",height:"100%",overflow:"auto",backgroundColor:"var(--doc-bg, #f8f9fa)"},Ig={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:24,paddingBottom:24},Fg={position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},Lg={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function Kt(e){return Math.round(e/1440*96)}function Bg(e){return {w:e?.pageWidth?Kt(e.pageWidth):vg,h:e?.pageHeight?Kt(e.pageHeight):sd}}function Ag(e){let t=e?.marginTop?Kt(e.marginTop):ii.top,n=e?.marginBottom?Kt(e.marginBottom):ii.bottom;return {top:t,right:e?.marginRight?Kt(e.marginRight):ii.right,bottom:n,left:e?.marginLeft?Kt(e.marginLeft):ii.left,header:e?.headerDistance?Kt(e.headerDistance):48,footer:e?.footerDistance?Kt(e.footerDistance):48}}function Dg(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function rd(e){return e===void 0?0:Math.round(e*96/914400)}function Hg(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 ld(e,t){let i=e.columnWidths??[],a=Hg(e.width,e.widthType,t);if(i.length===0&&e.rows.length>0){let d=e.rows[0].cells.reduce((m,b)=>m+(b.colSpan??1),0),f=(a??t)/Math.max(1,d);i=Array(d).fill(f);}else if(i.length>0&&a){let d=i.reduce((p,f)=>p+f,0);if(d>0&&Math.abs(d-a)>1){let p=a/d;i=i.map(f=>f*p);}}let s=new Map;for(let d=0;d<e.rows.length;d++){let p=e.rows[d];if(!p)continue;let f=0,m=s.get(d)??new Set;for(;m.has(f);)f++;for(let b of p.cells){let g=b.colSpan??1,k=b.rowSpan??1;if(k>1)for(let P=d+1;P<d+k;P++){s.has(P)||s.set(P,new Set);let S=s.get(P);for(let B=0;B<g;B++)S.add(f+B);}for(f+=g;m.has(f);)f++;}}let l=e.rows.map((d,p)=>{let f=0,m=s.get(p)??new Set;for(;m.has(f);)f++;return {cells:d.cells.map(b=>{let g=b.colSpan??1,k=0;for(let E=0;E<g&&f+E<i.length;E++)k+=i[f+E]??0;for(k===0&&(k=b.width??100),f+=g;m.has(f);)f++;let P=b.padding?.left??7,S=b.padding?.right??7,B=Math.max(1,k-P-S);return {blocks:b.blocks.map(E=>cd(E,B)),width:k,height:0,colSpan:b.colSpan,rowSpan:b.rowSpan}}),height:0}});for(let d=0;d<l.length;d++){let p=l[d],f=e.rows[d]?.cells,m=0;for(let P=0;P<p.cells.length;P++){let S=p.cells[P],B=f?.[P];S.height=S.blocks.reduce((Z,A)=>"totalHeight"in A?Z+A.totalHeight:Z,0);let E=B?.padding?.top??1,J=B?.padding?.bottom??1;S.height+=E+J,m=Math.max(m,S.height);}let b=e.rows[d],g=b?.height,k=b?.heightRule;g&&k==="exact"?p.height=g:g&&k==="atLeast"?p.height=Math.max(m,g):p.height=Math.max(m,24);}let u=l.reduce((d,p)=>d+p.height,0),c=i.reduce((d,p)=>d+p,0)||a||t;return {kind:"table",rows:l,columnWidths:i,totalWidth:c,totalHeight:u}}function Ng(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(!Dg(s))continue;let l=0,u=s.position,c=s.distTop??0,d=s.distBottom??0,p=s.distLeft??12,f=s.distRight??12;if(u?.vertical){let k=u.vertical;k.align==="top"&&k.relativeTo==="margin"?l=0:k.posOffset!==void 0&&(l=rd(k.posOffset));}let m=l+s.height,b=0,g=0;if(u?.horizontal){let k=u.horizontal;if(k.align==="left")b=s.width+f;else if(k.align==="right")g=s.width+p;else if(k.posOffset!==void 0){let P=rd(k.posOffset);P<t/2?b=P+s.width+f:g=t-P+p;}}else s.cssFloat==="left"?b=s.width+f:s.cssFloat==="right"&&(g=s.width+p);if(b>0||g>0){let k=u?.vertical?.relativeTo==="margin"||u?.vertical?.relativeTo==="page";n.push({leftMargin:b,rightMargin:g,topY:l-c,bottomY:m+d,anchorBlockIndex:o,isMarginRelative:k});}}}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=ld(i,t),l=s.totalWidth,u=s.totalHeight,c=a.leftFromText??12,d=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+d:b=t-g+c;let k=a.tblpY??0,P=k+u;n.push({leftMargin:m,rightMargin:b,topY:k-p,bottomY:P+f,anchorBlockIndex:o});}return n}function cd(e,t,n,o){switch(e.kind){case "paragraph":return yo(e,t,{floatingZones:n,paragraphYOffset:o??0});case "table":return ld(e,t);case "image":{let r=e;return {kind:"image",width:r.width??100,height:r.height??100}}case "pageBreak":return {kind:"pageBreak"};case "columnBreak":return {kind:"columnBreak"};case "sectionBreak":return {kind:"sectionBreak"};default:return {kind:"paragraph",lines:[],totalHeight:0}}}function dd(e,t){let n=Ng(e,t),o=n.filter(d=>d.isMarginRelative),r=n.filter(d=>!d.isMarginRelative),i=new Map;for(let d of o){let p=i.get(d.topY)??[];p.push(d),i.set(d.topY,p);}let a=[...r];for(let d of i.values()){let p=Math.min(...d.map(f=>f.anchorBlockIndex));for(let f of d)a.push({...f,anchorBlockIndex:p});}let s=new Map;for(let d of a){let p=s.get(d.anchorBlockIndex)??[];p.push({leftMargin:d.leftMargin,rightMargin:d.rightMargin,topY:d.topY,bottomY:d.bottomY}),s.set(d.anchorBlockIndex,p);}let l=new Set(a.map(d=>d.anchorBlockIndex)),u=0,c=[];return e.map((d,p)=>{l.has(p)&&(u=0,c=s.get(p)??[]);let f=c.length>0?c:void 0;try{let m=performance.now(),b=cd(d,t,f,u),g=performance.now()-m;return g>500&&console.warn(`[measureBlocks] Block ${p} (${d.kind}) took ${Math.round(g)}ms`),"totalHeight"in b&&(d.kind==="table"&&d.floating||(u+=b.totalHeight)),b}catch(m){return console.error(`[measureBlocks] Error measuring block ${p} (${d.kind}):`,m),{totalHeight:20}}})}function ai(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,c=m=>Math.round(m/914400*96),d=u?.width?c(u.width):100,p=u?.height?c(u.height):100,f=l.position;t.push({kind:"image",src:l.src||"",width:d,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=ai(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=ai(o.fieldResult);t.push(...a);}}if(o.type==="hyperlink"&&Array.isArray(o.children)){let r=ai(o.children);t.push(...r);}}return t}function id(e,t){if(!e||!e.content||e.content.length===0)return;let n=[];for(let a of e.content){let s=a;if(s.type==="paragraph"&&Array.isArray(s.content)){let l=s.formatting,u={};if(l&&l.alignment){let d=l.alignment;d==="both"?u.alignment="justify":["left","center","right","justify"].includes(d)&&(u.alignment=d);}let c=ai(s.content);if(c.length>0){let d={kind:"paragraph",id:String(n.length),runs:c,attrs:Object.keys(u).length>0?u:void 0};n.push(d);}}}if(n.length===0)return;let o=n.map(a=>{if(a.kind!=="paragraph")return a;let s=a;if(!s.runs.some(c=>c.kind==="image"&&"position"in c&&c.position))return a;let u=s.runs.filter(c=>!(c.kind==="image"&&"position"in c&&c.position));return u.length===0&&u.push({kind:"text",text:""}),{...s,runs:u}}),r=dd(o,t),i=r.reduce((a,s)=>s.kind==="paragraph"?a+s.totalHeight:a,0);return {blocks:n,measures:r,height:i}}function zg(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 d=t.get(l)?.displayNumber??0,p=chunkEPCZ24TY_cjs.d(u);s.push({displayNumber:String(d),text:p});}s.length>0&&o.set(i,s);}return o}var Og=fd.forwardRef(function(t,n){let{document:o,styles:r,theme:i,sectionProperties:a,headerContent:s,footerContent:l,readOnly:u=false,pageGap:c=Pg,zoom:d=1,onDocumentChange:p,onSelectionChange:f,externalPlugins:m=Eg,extensionManager:b,onReady:g,onRenderedDomContextReady:k,pluginOverlays:P,onHeaderFooterDoubleClick:S,hfEditMode:B,onBodyClick:E,className:J,style:Z}=t,A=fd.useRef(null),F=fd.useRef(null),R=fd.useRef(null),te=fd.useRef(null),{handlePMKeyDown:re}=Jc({pagesContainerRef:F}),Q=fd.useRef(f),pe=fd.useRef(p),L=fd.useRef(g),N=fd.useRef(k);Q.current=f,pe.current=p,L.current=g,N.current=k;let[Y,xe]=fd.useState(null),[le,Re]=fd.useState([]),[T,I]=fd.useState([]),[y,v]=fd.useState(false),[w,M]=fd.useState([]),[G,U]=fd.useState(null),[H,z]=fd.useState(null),$=fd.useRef(false),ge=fd.useCallback((C,ne)=>{let j=C.tagName==="IMG"?C:C.querySelector("img"),K=(j??C).getBoundingClientRect();return {element:j??C,pmPos:ne,width:Math.round(K.width/d),height:Math.round(K.height/d)}},[d]),fe=fd.useRef(false),se=fd.useRef(null),O=fd.useRef(false),ue=fd.useRef(0),Ce=fd.useRef(0),_e=fd.useRef(0),Ve=fd.useRef({left:0,right:0}),He=fd.useRef(null),ve=fd.useRef(false),D=fd.useRef(0),nt=fd.useRef(0),Fe=fd.useRef(0),Te=fd.useRef(0),Ue=fd.useRef(null),Me=fd.useRef(false),ot=fd.useRef(false),yt=fd.useRef(0),Ne=fd.useRef(0),mt=fd.useRef(0),Le=fd.useRef(0),at=fd.useRef(null),Dt=fd.useRef(false),Rt=fd.useRef(null),dt=fd.useRef(null),Ht=fd.useRef(null),Be=5,Oe=fd.useMemo(()=>new ti,[]),Nt=fd.useMemo(()=>Bg(a),[a]),kt=fd.useMemo(()=>Ag(a),[a]),Xe=Nt.w-kt.left-kt.right,st=fd.useMemo(()=>new ei({pageGap:c,showShadow:true,pageBackground:"#fff"}),[c]);te.current=st;let Je=fd.useCallback(C=>{let ne=performance.now(),j=Oe.getStateSeq();Oe.onLayoutStart();try{let K=performance.now(),q=Nt.h-kt.top-kt.bottom,W=Pc(C.doc,{theme:i,pageContentHeight:q}),_=performance.now()-K;_>500&&console.warn(`[PagedEditor] toFlowBlocks took ${Math.round(_)}ms (${W.length} blocks)`),Re(W),K=performance.now();let X=dd(W,Xe);_=performance.now()-K,_>1e3&&console.warn(`[PagedEditor] measureBlocks took ${Math.round(_)}ms (${W.length} blocks)`),I(X);let oe=Qc(W),me=oe.length>0&&o?.package?.footnotes,ce=id(s,Xe),Se=id(l,Xe),Pe=kt.header??48,Ee=kt.footer??48,qe=kt.top-Pe,Ge=kt.bottom-Ee,it=ce?.height??0,Ze=Se?.height??0,gt=kt;(it>qe||Ze>Ge)&&(gt={...kt},it>qe&&(gt.top=Pe+it),Ze>Ge&&(gt.bottom=Ee+Ze)),K=performance.now();let vt,qt=new Map,eo=new Map;if(me){let tn=jr(W,X,{pageSize:Nt,margins:gt});qt=Sa(tn.pages,oe),eo=ed(o.package.footnotes,oe,Xe);let Ot=td(qt,eo);if(Ot.size>0){vt=jr(W,X,{pageSize:Nt,margins:gt,footnoteReservedHeights:Ot}),qt=Sa(vt.pages,oe);for(let[$t,bn]of qt){let yn=vt.pages.find(x=>x.number===$t);yn&&(yn.footnoteIds=bn);}}else vt=tn;}else vt=jr(W,X,{pageSize:Nt,margins:gt});if(_=performance.now()-K,_>500&&console.warn(`[PagedEditor] layoutDocument took ${Math.round(_)}ms (${vt.pages.length} pages)`),xe(vt),F.current&&te.current){K=performance.now();let tn=new Map;for(let $t=0;$t<W.length;$t++){let bn=W[$t],yn=X[$t];bn&&yn&&tn.set(String(bn.id),{block:bn,measure:yn});}te.current.setBlockLookup(tn);let Ot=me?zg(qt,eo,o):void 0;if(Yc(vt.pages,F.current,{pageGap:c,showShadow:!0,pageBackground:"#fff",blockLookup:tn,headerContent:ce,footerContent:Se,headerDistance:a?.headerDistance?Kt(a.headerDistance):void 0,footerDistance:a?.footerDistance?Kt(a.footerDistance):void 0,pageBorders:a?.pageBorders,theme:i,footnotesByPage:Ot?.size?Ot:void 0}),_=performance.now()-K,_>500&&console.warn(`[PagedEditor] renderPages took ${Math.round(_)}ms`),k){let $t=nd(F.current,d);k($t);}}let vo=performance.now()-ne;vo>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(vo)}ms total (${W.length} blocks, ${X.length} measures)`);}catch(K){console.error("[PagedEditor] Layout pipeline error:",K);}Oe.onLayoutComplete(j);},[Xe,Nt,kt,c,d,Oe,s,l,a,k,o]),Fn=fd.useCallback(C=>{if(!F.current)return null;let ne=F.current.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!ne)return null;let j=ne.getBoundingClientRect(),K=F.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let W of Array.from(K)){let _=W,X=Number(_.dataset.pmStart),oe=Number(_.dataset.pmEnd);if(_.classList.contains("layout-run-tab")){if(C>=X&&C<oe){let me=_.getBoundingClientRect(),ce=_.closest(".layout-page"),Se=ce?Number(ce.dataset.pageNumber)-1:0,Pe=_.closest(".layout-line"),Ee=Pe?Pe.offsetHeight:16;return {x:me.left-j.left,y:me.top-j.top,height:Ee,pageIndex:Se}}continue}if(C>=X&&C<=oe&&W.firstChild?.nodeType===Node.TEXT_NODE){let me=W.firstChild,ce=Math.min(C-X,me.length),Se=_.ownerDocument;if(!Se)continue;let Pe=Se.createRange();Pe.setStart(me,ce),Pe.setEnd(me,ce);let Ee=Pe.getBoundingClientRect(),qe=_.closest(".layout-page"),Ge=qe?Number(qe.dataset.pageNumber)-1:0,it=_.closest(".layout-line"),Ze=it?it.offsetHeight:16;return {x:Ee.left-j.left,y:Ee.top-j.top,height:Ze,pageIndex:Ge}}}let q=F.current.querySelectorAll(".layout-empty-run");for(let W of Array.from(q)){let _=W.closest(".layout-paragraph");if(!_)continue;let X=Number(_.dataset.pmStart),oe=Number(_.dataset.pmEnd);if(C>=X&&C<=oe){let me=W.getBoundingClientRect(),ce=_.closest(".layout-page"),Se=ce?Number(ce.dataset.pageNumber)-1:0,Pe=W.closest(".layout-line"),Ee=Pe?Pe.offsetHeight:16;return {x:me.left-j.left,y:me.top-j.top,height:Ee,pageIndex:Se}}}return null},[]),ut=fd.useCallback(C=>{let{from:ne,to:j}=C.selection;if(Q.current?.(ne,j),F.current){let K=F.current.querySelectorAll(".layout-table-cell-selected");for(let _ of Array.from(K))_.classList.remove("layout-table-cell-selected");let q=C.selection;if("$anchorCell"in q&&typeof q.forEachCell=="function"){let _=[];q.forEachCell((oe,me)=>{_.push([me,me+oe.nodeSize]);});let X=F.current.querySelectorAll(".layout-table-cell");for(let oe of Array.from(X)){let me=oe,ce=me.dataset.pmStart;if(ce!==void 0){let Se=Number(ce);for(let[Pe,Ee]of _)if(Se>=Pe&&Se<Ee){me.classList.add("layout-table-cell-selected");break}}}}}if(!(!Y||le.length===0))if(ne===j){let K=Fn(ne);if(K)U(K);else {let q=F.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),W=F.current?.querySelector(".layout-page");if(q&&W){let _=q.getBoundingClientRect(),X=W.getBoundingClientRect(),oe=chunkY37VT37I_cjs.j(Y,le,T,ne);U(oe?{...oe,x:oe.x+(X.left-_.left),y:oe.y+(X.top-_.top)}:null);}else U(null);}M([]);}else {let K=F.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(K&&F.current){let q=K.getBoundingClientRect(),W=[],_=F.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let X of Array.from(_)){let oe=X,me=Number(oe.dataset.pmStart);if(Number(oe.dataset.pmEnd)>ne&&me<j){if(oe.classList.contains("layout-run-tab")){let Ge=oe.getBoundingClientRect(),it=oe.closest(".layout-page"),Ze=it?Number(it.dataset.pageNumber)-1:0;W.push({x:Ge.left-q.left,y:Ge.top-q.top,width:Ge.width,height:Ge.height,pageIndex:Ze});continue}if(X.firstChild?.nodeType!==Node.TEXT_NODE)continue;let Se=X.firstChild,Pe=oe.ownerDocument;if(!Pe)continue;let Ee=Math.max(0,ne-me),qe=Math.min(Se.length,j-me);if(Ee<qe){let Ge=Pe.createRange();Ge.setStart(Se,Ee),Ge.setEnd(Se,qe);let it=Ge.getClientRects();for(let Ze of Array.from(it)){let gt=oe.closest(".layout-page"),vt=gt?Number(gt.dataset.pageNumber)-1:0;W.push({x:Ze.left-q.left,y:Ze.top-q.top,width:Ze.width,height:Ze.height,pageIndex:vt});}}}}if(W.length>0)M(W);else {let X=F.current.querySelector(".layout-page");if(X){let oe=X.getBoundingClientRect(),me=oe.left-q.left,ce=oe.top-q.top,Pe=chunkY37VT37I_cjs.i(Y,le,T,ne,j).map(Ee=>({...Ee,x:Ee.x+me,y:Ee.y+ce}));M(Pe);}else M([]);}}else M([]);U(null);}},[Y,le,T,Fn]),fi=fd.useCallback((C,ne)=>{if(C.docChanged){Oe.incrementStateSeq(),Je(ne);let j=R.current?.getDocument();j&&pe.current?.(j);}Oe.requestRender(),ut(ne);},[Je,ut,Oe]),mi=fd.useCallback(C=>{let{selection:ne}=C;ne instanceof prosemirrorState.NodeSelection&&ne.node.type.name==="image"?(M([]),U(null)):ut(C),requestAnimationFrame(()=>{let j=R.current?.getView();if(!j){z(null);return}let{selection:K}=j.state;if(K instanceof prosemirrorState.NodeSelection&&K.node.type.name==="image"){let q=K.from,W=F.current?.querySelector(`[data-pm-start="${q}"]`);if(W){z(ge(W,q));return}}$.current||z(null);});},[ut,d,ge]),Et=fd.useCallback((C,ne)=>{if(!F.current||!Y)return null;let j=Nc(F.current,C,ne,d);if(j!==null)return j;let K=F.current.querySelectorAll(".layout-page"),q=-1,W=null;for(let Se=0;Se<K.length;Se++){let Ee=K[Se].getBoundingClientRect();if(C>=Ee.left&&C<=Ee.right&&ne>=Ee.top&&ne<=Ee.bottom){q=Se,W=Ee;break}}if(q<0||!W)return null;let _=(C-W.left)/d,X=(ne-W.top)/d,oe=Y.pages[q];if(!oe)return null;let me={pageIndex:q,page:oe,pageY:X},ce=chunkY37VT37I_cjs.g(me,le,T,{x:_,y:X});if(!ce)return null;if(ce.fragment.kind==="table"){let Se=chunkY37VT37I_cjs.h(me,le,T,{x:_,y:X});return ua(ce,Se)}return ua(ce)},[Y,le,T,d]),en=fd.useCallback(C=>{let ne=R.current?.getView();if(!ne)return null;try{let j=ne.state.doc.resolve(C);for(let K=j.depth;K>0;K--){let q=j.node(K);if(q.type.name==="tableCell"||q.type.name==="tableHeader")return j.before(K)}}catch{}return null},[]),gi=fd.useCallback(C=>{let ne=["layout-block-image","layout-image","layout-page-floating-image"],j=K=>!!K.dataset.pmStart&&ne.some(q=>K.classList.contains(q));return C.tagName==="IMG"&&C.classList.contains("layout-run-image")?C:C.tagName==="IMG"&&C.parentElement&&j(C.parentElement)?C.parentElement:j(C)?C:null},[]),Ln=fd.useCallback(C=>{let ne=F.current;if(!ne)return;let j=ne.querySelector(`[data-pm-start="${C}"]`);j&&j.scrollIntoView({behavior:"smooth",block:"center"});},[]),hi=fd.useCallback(C=>{if(!R.current||C.button!==0)return;if(C.target.closest('a[href^="#"]')){C.preventDefault(),C.stopPropagation();return}if(u)return;if(B&&E){let W=C.target;if(!(W.closest(".layout-page-header")||W.closest(".layout-page-footer")||W.closest(".hf-inline-editor"))){C.preventDefault(),C.stopPropagation(),E();return}}if(!B){let W=C.target;if(W.closest(".layout-page-header")||W.closest(".layout-page-footer")){C.preventDefault(),R.current&&(R.current.setSelection(0),R.current.focus(),v(true));return}}let j=C.target;if(j.classList.contains("layout-table-resize-handle")){C.preventDefault(),C.stopPropagation(),O.current=true,ue.current=C.clientX,He.current=j,j.classList.add("dragging");let W=parseInt(j.dataset.columnIndex??"0",10);Ce.current=W,_e.current=parseInt(j.dataset.tablePmStart??"0",10);let _=R.current.getView();if(_){let X=_.state.doc.resolve(_e.current+1);for(let oe=X.depth;oe>=0;oe--){let me=X.node(oe);if(me.type.name==="table"){let ce=me.attrs.columnWidths;ce&&ce[W]!==void 0&&ce[W+1]!==void 0&&(Ve.current={left:ce[W],right:ce[W+1]});break}}}return}if(j.classList.contains("layout-table-row-resize-handle")||j.classList.contains("layout-table-edge-handle-bottom")){C.preventDefault(),C.stopPropagation(),ve.current=true,D.current=C.clientY,Ue.current=j,Me.current=j.dataset.isEdge==="bottom",j.classList.add("dragging");let W=parseInt(j.dataset.rowIndex??"0",10);nt.current=W,Fe.current=parseInt(j.dataset.tablePmStart??"0",10);let _=R.current.getView();if(_){let X=_.state.doc.resolve(Fe.current+1);for(let oe=X.depth;oe>=0;oe--){let me=X.node(oe);if(me.type.name==="table"){let ce=null,Se=0;if(me.forEach(Pe=>{Se===W&&(ce=Pe),Se++;}),ce){let Pe=ce.attrs.height;if(Pe)Te.current=Pe;else {let qe=j.closest(".layout-table")?.querySelector(`[data-row-index="${W}"]`),Ge=qe?qe.getBoundingClientRect().height:30;Te.current=Math.round(Ge*15);}}break}}}return}if(j.classList.contains("layout-table-edge-handle-right")){C.preventDefault(),C.stopPropagation(),ot.current=true,yt.current=C.clientX,at.current=j,j.classList.add("dragging");let W=parseInt(j.dataset.columnIndex??"0",10);Ne.current=W,mt.current=parseInt(j.dataset.tablePmStart??"0",10);let _=R.current.getView();if(_){let X=_.state.doc.resolve(mt.current+1);for(let oe=X.depth;oe>=0;oe--){let me=X.node(oe);if(me.type.name==="table"){let ce=me.attrs.columnWidths;ce&&ce[W]!==void 0&&(Le.current=ce[W]);break}}}return}let K=gi(j);if(K){C.preventDefault(),C.stopPropagation();let W=K.dataset.pmStart;if(W!==void 0){let _=parseInt(W,10);R.current.setNodeSelection(_),z(ge(K,_)),M([]),U(null);}R.current.focus(),v(true);return}z(null),C.preventDefault();let q=Et(C.clientX,C.clientY);if(q!==null){let W=en(q);Rt.current=W,Dt.current=false,dt.current=null,Ht.current=null,fe.current=true,se.current=q,R.current.setSelection(q);}else {Rt.current=null,Dt.current=false;let W=R.current.getView();if(W){let _=Math.max(0,W.state.doc.content.size-1);R.current.setSelection(_),se.current=_,fe.current=true;}}R.current.focus(),v(true);},[Et,en,u,B,E,d]),Jn=fd.useCallback(C=>{if(O.current){C.preventDefault();let K=C.clientX-ue.current;if(He.current){let q=parseFloat(He.current.style.left);He.current.style.left=`${q+K}px`,ue.current=C.clientX;let W=Math.round(K*15),_=300,X=Ve.current.left+W,oe=Ve.current.right-W;X>=_&&oe>=_&&(Ve.current={left:X,right:oe});}return}if(ve.current){C.preventDefault();let K=C.clientY-D.current;if(Ue.current){let q=parseFloat(Ue.current.style.top);Ue.current.style.top=`${q+K}px`,D.current=C.clientY;let W=Math.round(K*15),_=200,X=Te.current+W;X>=_&&(Te.current=X);}return}if(ot.current){C.preventDefault();let K=C.clientX-yt.current;if(at.current){let q=parseFloat(at.current.style.left);at.current.style.left=`${q+K}px`,yt.current=C.clientX;let W=Math.round(K*15),_=300,X=Le.current+W;X>=_&&(Le.current=X);}return}if(!fe.current||se.current===null||!R.current||!F.current)return;let ne=Et(C.clientX,C.clientY);if(ne===null)return;if(Rt.current!==null){if(Dt.current){let q=en(ne);if(q!==null){R.current.setCellSelection(Rt.current,q);return}}let K=en(ne);if(K!==null&&K!==Rt.current){Dt.current=true,R.current.setCellSelection(Rt.current,K),Ht.current=null;return}if(dt.current!==null&&ne===dt.current){if(Ht.current===null)Ht.current=C.clientX;else if(Math.abs(C.clientX-Ht.current)>=Be){Dt.current=true,R.current.setCellSelection(Rt.current,Rt.current),Ht.current=null;return}}else Ht.current=null,dt.current=ne;}let j=se.current;R.current.setSelection(j,ne);},[Et,en]),Qn=fd.useCallback(()=>{if(O.current){O.current=false,He.current&&(He.current.classList.remove("dragging"),He.current=null);let C=R.current?.getView();if(C){let ne=_e.current,j=Ce.current,{left:K,right:q}=Ve.current,W=C.state.doc.resolve(ne+1);for(let _=W.depth;_>=0;_--){let X=W.node(_);if(X.type.name==="table"){let oe=W.before(_),me=C.state.tr,ce=[...X.attrs.columnWidths];ce[j]=K,ce[j+1]=q,me.setNodeMarkup(oe,void 0,{...X.attrs,columnWidths:ce});let Se=oe+1;X.forEach(Pe=>{let Ee=Se+1,qe=0;Pe.forEach(Ge=>{let it=Ge.attrs.colspan||1;if(qe===j||qe===j+1){let Ze=qe===j?K:q;me.setNodeMarkup(me.mapping.map(Ee),void 0,{...Ge.attrs,width:Ze,widthType:"dxa",colwidth:null});}Ee+=Ge.nodeSize,qe+=it;}),Se+=Pe.nodeSize;}),C.dispatch(me);break}}}return}if(ve.current){ve.current=false,Ue.current&&(Ue.current.classList.remove("dragging"),Ue.current=null);let C=R.current?.getView();if(C){let ne=Fe.current,j=nt.current,K=Te.current,q=C.state.doc.resolve(ne+1);for(let W=q.depth;W>=0;W--){let _=q.node(W);if(_.type.name==="table"){let X=q.before(W),oe=C.state.tr,me=X+1,ce=0;_.forEach(Se=>{ce===j&&oe.setNodeMarkup(oe.mapping.map(me),void 0,{...Se.attrs,height:K,heightRule:"atLeast"}),me+=Se.nodeSize,ce++;}),C.dispatch(oe);break}}}return}if(ot.current){ot.current=false,at.current&&(at.current.classList.remove("dragging"),at.current=null);let C=R.current?.getView();if(C){let ne=mt.current,j=Ne.current,K=Le.current,q=C.state.doc.resolve(ne+1);for(let W=q.depth;W>=0;W--){let _=q.node(W);if(_.type.name==="table"){let X=q.before(W),oe=C.state.tr,me=[..._.attrs.columnWidths];me[j]=K,oe.setNodeMarkup(X,void 0,{..._.attrs,columnWidths:me});let ce=X+1;_.forEach(Se=>{let Pe=ce+1,Ee=0;Se.forEach(qe=>{let Ge=qe.attrs.colspan||1;Ee===j&&oe.setNodeMarkup(oe.mapping.map(Pe),void 0,{...qe.attrs,width:K,widthType:"dxa",colwidth:null}),Pe+=qe.nodeSize,Ee+=Ge;}),ce+=Se.nodeSize;}),C.dispatch(oe);break}}}return}fe.current=false,Dt.current=false,dt.current=null,Ht.current=null;},[]);fd.useEffect(()=>(window.addEventListener("mousemove",Jn),window.addEventListener("mouseup",Qn),()=>{window.removeEventListener("mousemove",Jn),window.removeEventListener("mouseup",Qn);}),[Jn,Qn]);let bi=fd.useCallback(C=>{let ne=C.target.closest('a[href^="#"]');if(ne){C.preventDefault(),C.stopPropagation();let j=ne.getAttribute("href")?.substring(1);if(j&&R.current){let K=R.current.getView();if(K){let q=null;K.state.doc.descendants((W,_)=>{if(q!==null)return false;if(W.type.name==="paragraph"&&W.attrs.bookmarks?.some(oe=>oe.name===j))return q=_,false}),q!==null&&(Ln(q),R.current.setSelection(q+1));}}return}if(C.detail===2&&S){let j=C.target,K=j.closest(".layout-page-header"),q=j.closest(".layout-page-footer");if(K){C.preventDefault(),C.stopPropagation(),S("header");return}if(q){C.preventDefault(),C.stopPropagation(),S("footer");return}}if(C.detail===2&&R.current){let j=Et(C.clientX,C.clientY);if(j!==null){let K=en(j);if(K!==null){C.preventDefault(),C.stopPropagation(),R.current.setCellSelection(K,K);return}let q=R.current.getView();if(q){let{doc:W}=q.state,_=W.resolve(j),X=_.parent;if(X.isTextblock){let oe=X.textContent,me=_.parentOffset,ce=me;for(;ce>0&&/\w/.test(oe[ce-1]);)ce--;let Se=me;for(;Se<oe.length&&/\w/.test(oe[Se]);)Se++;let Pe=_.start()+ce,Ee=_.start()+Se;Pe<Ee&&R.current.setSelection(Pe,Ee);}}}}if(C.detail===3&&R.current){let j=Et(C.clientX,C.clientY);if(j!==null){let K=R.current.getView();if(K){let{doc:q}=K.state,W=q.resolve(j),_=W.start(W.depth),X=W.end(W.depth);R.current.setSelection(_,X);}}}},[Et,S]),yi=fd.useCallback(()=>{u||(R.current?.focus(),v(true));},[u]),xi=fd.useCallback(C=>{let ne=C.relatedTarget;ne&&A.current?.contains(ne)||v(false);},[]),Si=fd.useCallback((C,ne,j)=>{let K=R.current?.getView();if(K)try{let q=K.state.doc.nodeAt(C);if(!q||q.type.name!=="image")return;let W=K.state.tr.setNodeMarkup(C,void 0,{...q.attrs,width:ne,height:j});K.dispatch(W),R.current?.setNodeSelection(C);}catch{}},[]),ki=fd.useCallback(()=>{$.current=true;},[]),wi=fd.useCallback(()=>{$.current=false;},[]),Ci=fd.useCallback((C,ne,j)=>{let K=R.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 _=F.current?.querySelectorAll(".layout-page");if(!_||_.length===0)return;let X=null;for(let it of _){let Ze=it.getBoundingClientRect();if(j>=Ze.top&&j<=Ze.bottom){X=it.querySelector(".layout-page-content");break}}if(X||(X=_[_.length-1].querySelector(".layout-page-content")),!X)return;let oe=X.getBoundingClientRect(),me=(ne-oe.left)/d,ce=(j-oe.top)/d,Se=914400/96,Pe=Math.round(me*Se),Ee=Math.round(ce*Se),qe={horizontal:{posOffset:Pe,relativeTo:"margin"},vertical:{posOffset:Ee,relativeTo:"margin"}},Ge=K.state.tr.setNodeMarkup(C,void 0,{...q.attrs,position:qe});K.dispatch(Ge),R.current?.setNodeSelection(C);}else {let _=Et(ne,j);if(_===null||_===C||_===C+1)return;let X=K.state.tr;if(_<=C)X=X.delete(C,C+q.nodeSize),X=X.insert(_,q),R.current?.setNodeSelection(_);else {X=X.delete(C,C+q.nodeSize);let oe=_-q.nodeSize;X=X.insert(Math.min(oe,X.doc.content.size),q),R.current?.setNodeSelection(Math.min(oe,X.doc.content.size-1));}K.dispatch(X);}}catch{}},[Et,d]),Ti=fd.useCallback(()=>{$.current=true;},[]),Ri=fd.useCallback(()=>{$.current=false;},[]),vi=fd.useCallback(C=>{if(!u){if(R.current?.isFocused()||(R.current?.focus(),v(true)),C.key===" "&&!C.ctrlKey&&!C.metaKey){C.preventDefault();let ne=R.current?.getView();if(ne){let{state:j,dispatch:K}=ne;K(j.tr.insertText(" "));}return}["PageUp","PageDown"].includes(C.key)&&!C.metaKey&&C.ctrlKey,C.key==="Home"&&(C.metaKey||C.ctrlKey)&&A.current&&(A.current.scrollTop=0),C.key==="End"&&(C.metaKey||C.ctrlKey)&&A.current&&(A.current.scrollTop=A.current.scrollHeight);}},[u]),Pi=fd.useCallback(()=>{u||R.current?.isFocused()||(R.current?.focus(),v(true));},[u]),zt=fd.useCallback(C=>{Je(C.state),ut(C.state),u||requestAnimationFrame(()=>{C.focus(),v(true);});},[Je,ut,u]);fd.useEffect(()=>{let C=()=>{let ne=R.current?.getView();ne&&(chunkY37VT37I_cjs.a(),da(),Je(ne.state),ut(ne.state));};return window.document.fonts.addEventListener("loadingdone",C),()=>{window.document.fonts.removeEventListener("loadingdone",C);}},[]);let Ro=fd.useRef(0);fd.useEffect(()=>{if(Ro.current===0){Ro.current=1;return}let C=R.current?.getView();C&&Je(C.state);},[s,l,Je]),fd.useEffect(()=>{let C=A.current;if(!C)return;let ne=new ResizeObserver(()=>{let j=R.current?.getState();j&&ut(j);});return ne.observe(C),()=>ne.disconnect()},[ut]),fd.useImperativeHandle(n,()=>({getDocument(){return R.current?.getDocument()??null},getState(){return R.current?.getState()??null},getView(){return R.current?.getView()??null},focus(){R.current?.focus(),v(true);},blur(){R.current?.blur(),v(false);},isFocused(){return R.current?.isFocused()??false},dispatch(C){R.current?.dispatch(C);},undo(){return R.current?.undo()??false},redo(){return R.current?.redo()??false},setSelection(C,ne){R.current?.setSelection(C,ne);},getLayout(){return Y},relayout(){let C=R.current?.getState();C&&Je(C);},scrollToPosition:Ln}),[Y,Je,Ln]),fd.useEffect(()=>{let C=R.current?.getState();Y&&C&&ut(C);},[Y,ut]),fd.useEffect(()=>{L.current&&R.current&&L.current({getDocument:()=>R.current?.getDocument()??null,getState:()=>R.current?.getState()??null,getView:()=>R.current?.getView()??null,focus:()=>{R.current?.focus(),v(true);},blur:()=>{R.current?.blur(),v(false);},isFocused:()=>R.current?.isFocused()??false,dispatch:C=>R.current?.dispatch(C),undo:()=>R.current?.undo()??false,redo:()=>R.current?.redo()??false,setSelection:(C,ne)=>R.current?.setSelection(C,ne),getLayout:()=>Y,relayout:()=>{let C=R.current?.getState();C&&Je(C);},scrollToPosition:Ln});},[Y,Je]);let Ei=fd.useMemo(()=>{if(!Y)return sd+48;let C=Y.pages.length;return C*Nt.h+(C-1)*c+48},[Y,Nt.h,c]);return jsxRuntime.jsxs("div",{ref:A,className:`ep-root paged-editor ${J??""}`,style:{...Mg,...Z},tabIndex:0,onFocus:yi,onBlur:xi,onKeyDown:vi,onMouseDown:Pi,children:[jsxRuntime.jsx(dc,{ref:R,document:o,styles:r,widthPx:Xe,readOnly:u,onTransaction:fi,onSelectionChange:mi,externalPlugins:m,extensionManager:b,onEditorViewReady:zt,onKeyDown:re}),jsxRuntime.jsxs("div",{style:{...Ig,minHeight:Ei,transform:d!==1?`scale(${d})`:void 0,transformOrigin:"top center"},children:[jsxRuntime.jsx("div",{ref:F,className:`paged-editor__pages${B?` paged-editor--hf-editing paged-editor--editing-${B}`:""}`,style:Fg,onMouseDown:hi,onClick:bi,"aria-hidden":"true"}),jsxRuntime.jsx(pc,{selectionRects:w,caretPosition:G,isFocused:y,pageGap:c,readOnly:u}),jsxRuntime.jsx(bc,{imageInfo:H,zoom:d,isFocused:y,onResize:Si,onResizeStart:ki,onResizeEnd:wi,onDragMove:Ci,onDragStart:Ti,onDragEnd:Ri}),P&&jsxRuntime.jsx("div",{className:"paged-editor__plugin-overlays",style:Lg,children:P})]})]})}),ud=fd.memo(Og);var Vg=fd.lazy(()=>import('./FindReplaceDialog-BAACAU67.cjs')),jg=fd.lazy(()=>import('./HyperlinkDialog-EG2BSLPD.cjs')),Ug=fd.lazy(()=>import('./TablePropertiesDialog-WRM47JI6.cjs').then(e=>({default:e.TablePropertiesDialog}))),Gg=fd.lazy(()=>import('./ImagePositionDialog-IGYS5KMK.cjs').then(e=>({default:e.ImagePositionDialog}))),Kg=fd.lazy(()=>import('./ImagePropertiesDialog-VGV4E4SN.cjs').then(e=>({default:e.ImagePropertiesDialog}))),qg=fd.lazy(()=>import('./FootnotePropertiesDialog-BC6JIPDA.cjs').then(e=>({default:e.FootnotePropertiesDialog}))),pd=fd.forwardRef(function({documentBuffer:t,document:n,onSave:o,onChange:r,onSelectionChange:i,onError:a,onFontsLoaded:s,theme:l,showToolbar:u=true,showVariablePanel:c=true,showZoomControl:d=true,showPageNumbers:p=true,enablePageNavigation:f=true,pageNumberPosition:m="bottom-center",pageNumberVariant:b="default",showMarginGuides:g=false,marginGuideColor:k,showRuler:P=false,rulerUnit:S="inch",initialZoom:B=1,readOnly:E=false,toolbarExtra:J,variablePanelPosition:Z="right",variableDescriptions:A,className:F="",style:R,placeholder:te,loadingIndicator:re,showOutline:Q=false,showPrintButton:pe=true,printOptions:L,onPrint:N,onCopy:Y,onCut:xe,onPaste:le,externalPlugins:Re,onEditorViewReady:T,onRenderedDomContextReady:I,pluginOverlays:y},v){let[w,M]=fd.useState({isLoading:!!t,parseError:null,zoom:B,variableValues:{},isApplyingVariables:false,selectionFormatting:{},currentPage:1,totalPages:1,paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[G,U]=fd.useState(false),[H,z]=fd.useState(false),[$,ge]=fd.useState(false),[fe,se]=fd.useState(false),[O,ue]=fd.useState(null),[Ce,_e]=fd.useState(Q),Ve=fd.useRef(false);Ve.current=Ce;let[He,ve]=fd.useState([]);fd.useEffect(()=>{if(_e(Q),Q){let x=Fe.current?.getView();x&&ve(Dn(x.state.doc));}},[Q]);let D=ic(n||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),nt=fd.useMemo(()=>{let x=new rn(On());return x.buildSchema(),x.initializeRuntime(),x},[]),Fe=fd.useRef(null),Te=fd.useRef(null),Ue=fd.useRef(null),Me=fd.useRef(null),ot=fd.useRef(null),yt=fd.useRef(null),Ne=fd.useRef(null),mt=fd.useRef(null),Le=fd.useRef(null),[at,Dt]=fd.useState(0),Rt=fd.useRef(D.state);Rt.current=D.state;let dt=fd.useRef({style:"single",size:4,color:{rgb:"000000"}}),Ht=fd.useCallback(x=>{if(mt.current=x,Le.current&&(Le.current.disconnect(),Le.current=null),!x){Dt(0);return}Dt(x.offsetHeight);let h=new ResizeObserver(()=>{Dt(x.offsetHeight);});h.observe(x),Le.current=h;},[]);fd.useEffect(()=>()=>{Le.current?.disconnect();},[]);let Be=fd.useCallback(()=>O&&Te.current?Te.current.getView():Fe.current?.getView(),[O]),Oe=fd.useCallback(()=>{O&&Te.current?Te.current.focus():Fe.current?.focus();},[O]),Nt=fd.useCallback(()=>{O&&Te.current?Te.current.undo():Fe.current?.undo();},[O]),kt=fd.useCallback(()=>{O&&Te.current?Te.current.redo():Fe.current?.redo();},[O]),Xe=chunkCZ7W7MCM_cjs.m(),st=chunkXS2AQFMF_cjs.m();fd.useEffect(()=>{if(!t){n&&(D.reset(n),M(h=>({...h,isLoading:false})),chunkEPCZ24TY_cjs.n(n).catch(h=>{console.warn("Failed to load document fonts:",h);}));return}M(h=>({...h,isLoading:true,parseError:null})),(async()=>{try{let h=await chunkEPCZ24TY_cjs.p(t);if(D.reset(h),M(V=>({...V,isLoading:!1,parseError:null})),h.package.document){let V=oc(h);M(de=>({...de,variableValues:V}));}chunkEPCZ24TY_cjs.n(h).catch(V=>{console.warn("Failed to load document fonts:",V);});}catch(h){let V=h instanceof Error?h.message:"Failed to parse document";M(de=>({...de,isLoading:false,parseError:V})),a?.(h instanceof Error?h:new Error(V));}})();},[t,n,a]),fd.useEffect(()=>{n&&!t&&D.reset(n);},[n,t]),fd.useEffect(()=>{D.state?Ue.current=new chunkPNMZPPPI_cjs.a(D.state):Ue.current=null;},[D.state]),fd.useEffect(()=>chunkEPCZ24TY_cjs.j(()=>{s?.();}),[s]);let Je=fd.useCallback(x=>{if(D.push(x),r?.(x),Ve.current){let h=Fe.current?.getView();h&&ve(Dn(h.state.doc));}},[r,D]),Fn=fd.useCallback(x=>{let h=Be();if(h){let{from:xt,to:wt}=h.state.selection;ot.current={from:xt,to:wt};}let V=null;h&&(V=ze(h.state),V.isInTable||(V=null));let de=null;if(h){let xt=h.state.selection,wt=xt.node;wt?.type.name==="image"&&(de={pos:xt.from,wrapType:wt.attrs.wrapType??"inline",displayMode:wt.attrs.displayMode??"inline",cssFloat:wt.attrs.cssFloat??null,transform:wt.attrs.transform??null,alt:wt.attrs.alt??null,borderWidth:wt.attrs.borderWidth??null,borderColor:wt.attrs.borderColor??null,borderStyle:wt.attrs.borderStyle??null});}if(!x){M(xt=>({...xt,selectionFormatting:{},pmTableContext:V,pmImageContext:de}));return}let{textFormatting:ee,paragraphFormatting:ie}=x,ae=ee.fontFamily?.ascii||ee.fontFamily?.hAnsi,ye=ee.color?.rgb?`#${ee.color.rgb}`:void 0,Ae=ie.numPr,Qe=Ae?{type:Ae.numId===1?"bullet":"numbered",level:Ae.ilvl??0,isInList:true,numId:Ae.numId}:void 0,lt={bold:ee.bold,italic:ee.italic,underline:!!ee.underline,strike:ee.strike,superscript:ee.vertAlign==="superscript",subscript:ee.vertAlign==="subscript",fontFamily:ae,fontSize:ee.fontSize,color:ye,highlight:ee.highlight,alignment:ie.alignment,lineSpacing:ie.lineSpacing,listState:Qe,styleId:x.styleId??void 0,indentLeft:ie.indentLeft};M(xt=>({...xt,selectionFormatting:lt,paragraphIndentLeft:ie.indentLeft??0,paragraphIndentRight:ie.indentRight??0,paragraphFirstLineIndent:ie.indentFirstLine??0,paragraphHangingIndent:ie.hangingIndent??false,paragraphTabs:ie.tabs??null,pmTableContext:V,pmImageContext:de})),i?.(x);},[i]),ut=os({document:D.state,onChange:Je,onSelectionChange:x=>{}});fd.useEffect(()=>{let x=h=>{let de=navigator.platform.toUpperCase().indexOf("MAC")>=0?h.metaKey:h.ctrlKey;if(!de&&!h.shiftKey&&!h.altKey&&(h.key==="Delete"||h.key==="Backspace")){let ee=Fe.current?.getView();if(ee){let ie=ee.state.selection;if("$anchorCell"in ie&&typeof ie.forEachCell=="function"){let ye=ze(ee.state);if(ye.isInTable&&ye.table){let Ae=0;ye.table.descendants(lt=>{(lt.type.name==="tableCell"||lt.type.name==="tableHeader")&&(Ae+=1);});let Qe=0;if(ie.forEachCell(()=>{Qe+=1;}),Ae>0&&Qe>=Ae){h.preventDefault(),po(ee.state,ee.dispatch);return}}}}if(ut.state.tableIndex!==null){h.preventDefault(),ut.handleAction("deleteTable");return}}if(de&&!h.shiftKey&&!h.altKey){if(h.key.toLowerCase()==="f"){h.preventDefault();let ee=window.getSelection(),ie=ee&&!ee.isCollapsed?ee.toString():"";Xe.openFind(ie);}else if(h.key.toLowerCase()==="h"){h.preventDefault();let ee=window.getSelection(),ie=ee&&!ee.isCollapsed?ee.toString():"";Xe.openReplace(ie);}else if(h.key.toLowerCase()==="k"){h.preventDefault();let ee=Fe.current?.getView();if(ee){let ie=Nn(ee.state),ae=Hn(ee.state);ae?st.openEdit({url:ae.href,displayText:ie,tooltip:ae.tooltip}):st.openInsert(ie);}}}};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x);}},[Xe,st,ut]);let fi=fd.useCallback((x,h)=>{let V=Be();V&&(pr(x,h)(V.state,V.dispatch),Oe());},[Be,Oe]),mi=fd.useCallback(()=>{let x=Be();x&&($r(x.state,x.dispatch),Oe());},[Be,Oe]),Et=fd.useCallback(()=>{let x=Be();x&&(ur(x.state,x.dispatch),Oe());},[Be,Oe]),en=fd.useCallback(()=>{_e(x=>{if(!x){let h=Fe.current?.getView();h&&ve(Dn(h.state.doc));}return !x});},[]),gi=fd.useCallback(x=>{Fe.current?.scrollToPosition(x),Fe.current?.setSelection(x+1),Fe.current?.focus();},[]),Ln=fd.useCallback(()=>{yt.current?.click();},[]),hi=fd.useCallback(x=>{let h=x.target.files?.[0];if(!h)return;let V=Be();if(!V)return;let de=new FileReader;de.onload=()=>{let ee=de.result,ie=new Image;ie.onload=()=>{let ae=ie.naturalWidth,ye=ie.naturalHeight,Ae=612;if(ae>Ae){let Hd=Ae/ae;ae=Ae,ye=Math.round(ye*Hd);}let Qe=`rId_img_${Date.now()}`,lt=V.state.schema.nodes.image.create({src:ee,alt:h.name,width:ae,height:ye,rId:Qe,wrapType:"inline",displayMode:"inline"}),{from:xt}=V.state.selection,wt=V.state.tr.insert(xt,lt);V.dispatch(wt.scrollIntoView()),Oe();},ie.src=ee;},de.readAsDataURL(h),x.target.value="";},[Be,Oe]),Jn=fd.useCallback(x=>{let h=Be();if(!h||!w.pmImageContext)return;let V=w.pmImageContext.pos,de=h.state.doc.nodeAt(V);if(!de||de.type.name!=="image")return;let ee="inline",ie=null;switch(x){case "inline":ee="inline",ie=null;break;case "square":case "tight":case "through":ee="float",ie="left";break;case "topAndBottom":ee="block",ie=null;break;case "behind":case "inFront":ee="float",ie="none";break;case "wrapLeft":ee="float",ie="right",x="square";break;case "wrapRight":ee="float",ie="left",x="square";break}let ae=h.state.tr.setNodeMarkup(V,void 0,{...de.attrs,wrapType:x,displayMode:ee,cssFloat:ie});h.dispatch(ae.scrollIntoView()),Oe();},[Be,Oe,w.pmImageContext]),Qn=fd.useCallback(x=>{let h=Be();if(!h||!w.pmImageContext)return;let V=w.pmImageContext.pos,de=h.state.doc.nodeAt(V);if(!de||de.type.name!=="image")return;let ee=de.attrs.transform||"",ie=ee.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),ae=ie?parseFloat(ie[1]):0,ye=/scaleX\(-1\)/.test(ee),Ae=/scaleY\(-1\)/.test(ee);switch(x){case "rotateCW":ae=(ae+90)%360;break;case "rotateCCW":ae=(ae-90+360)%360;break;case "flipH":ye=!ye;break;case "flipV":Ae=!Ae;break}let Qe=[];ae!==0&&Qe.push(`rotate(${ae}deg)`),ye&&Qe.push("scaleX(-1)"),Ae&&Qe.push("scaleY(-1)");let lt=Qe.length>0?Qe.join(" "):null,xt=h.state.tr.setNodeMarkup(V,void 0,{...de.attrs,transform:lt});h.dispatch(xt.scrollIntoView()),Oe();},[Be,Oe,w.pmImageContext]),bi=fd.useCallback(x=>{let h=Be();if(!h||!w.pmImageContext)return;let V=w.pmImageContext.pos,de=h.state.doc.nodeAt(V);if(!de||de.type.name!=="image")return;let ee=h.state.tr.setNodeMarkup(V,void 0,{...de.attrs,position:{horizontal:x.horizontal,vertical:x.vertical},distTop:x.distTop??de.attrs.distTop,distBottom:x.distBottom??de.attrs.distBottom,distLeft:x.distLeft??de.attrs.distLeft,distRight:x.distRight??de.attrs.distRight});h.dispatch(ee.scrollIntoView()),Oe();},[Be,Oe,w.pmImageContext]),yi=fd.useCallback(()=>{ge(true);},[]),xi=fd.useCallback(x=>{let h=Be();if(!h||!w.pmImageContext)return;let V=w.pmImageContext.pos,de=h.state.doc.nodeAt(V);if(!de||de.type.name!=="image")return;let ee=h.state.tr.setNodeMarkup(V,void 0,{...de.attrs,alt:x.alt??null,borderWidth:x.borderWidth??null,borderColor:x.borderColor??null,borderStyle:x.borderStyle??null});h.dispatch(ee.scrollIntoView()),Oe();},[Be,Oe,w.pmImageContext]),Si=fd.useCallback((x,h)=>{if(!D.state?.package)return;let V={...D.state.package.document,finalSectionProperties:{...D.state.package.document.finalSectionProperties,footnotePr:x,endnotePr:h}};D.push({...D.state,package:{...D.state.package,document:V}});},[D]),ki=fd.useCallback(x=>{let h=Be();if(h){switch(x){case "addRowAbove":fr(h.state,h.dispatch);break;case "addRowBelow":mr(h.state,h.dispatch);break;case "addColumnLeft":hr(h.state,h.dispatch);break;case "addColumnRight":br(h.state,h.dispatch);break;case "deleteRow":gr(h.state,h.dispatch);break;case "deleteColumn":yr(h.state,h.dispatch);break;case "deleteTable":po(h.state,h.dispatch);break;case "selectTable":xr(h.state,h.dispatch);break;case "selectRow":Sr(h.state,h.dispatch);break;case "selectColumn":kr(h.state,h.dispatch);break;case "mergeCells":wr(h.state,h.dispatch);break;case "splitCell":Cr(h.state,h.dispatch);break;case "borderAll":Rr(h.state,h.dispatch,dt.current);break;case "borderOutside":vr(h.state,h.dispatch,dt.current);break;case "borderInside":Pr(h.state,h.dispatch,dt.current);break;case "borderNone":Tr(h.state,h.dispatch);break;case "borderTop":sn("top",dt.current)(h.state,h.dispatch);break;case "borderBottom":sn("bottom",dt.current)(h.state,h.dispatch);break;case "borderLeft":sn("left",dt.current)(h.state,h.dispatch);break;case "borderRight":sn("right",dt.current)(h.state,h.dispatch);break;default:if(typeof x=="object"){if(x.type==="cellFillColor")Nr(x.color)(h.state,h.dispatch);else if(x.type==="borderColor"){let V=x.color.replace(/^#/,"");dt.current={...dt.current,color:{rgb:V}},zr(x.color)(h.state,h.dispatch);}else if(x.type==="borderWidth")dt.current={...dt.current,size:x.size},Or(x.size)(h.state,h.dispatch);else if(x.type==="cellBorder")sn(x.side,{style:x.style,size:x.size,color:{rgb:x.color.replace(/^#/,"")}})(h.state,h.dispatch);else if(x.type==="cellVerticalAlign")Er(x.align)(h.state,h.dispatch);else if(x.type==="cellMargins")Mr(x.margins)(h.state,h.dispatch);else if(x.type==="cellTextDirection")Ir(x.direction)(h.state,h.dispatch);else if(x.type==="toggleNoWrap")Fr()(h.state,h.dispatch);else if(x.type==="rowHeight")Lr(x.height,x.rule)(h.state,h.dispatch);else if(x.type==="toggleHeaderRow")Br()(h.state,h.dispatch);else if(x.type==="distributeColumns")Ar()(h.state,h.dispatch);else if(x.type==="autoFitContents")Dr()(h.state,h.dispatch);else if(x.type==="openTableProperties")U(true);else if(x.type==="tableProperties")fo(x.props)(h.state,h.dispatch);else if(x.type==="applyTableStyle"){let V=Ql(x.styleId),de=Rt.current;if(!V&&de?.package.styles){let ie=an(de.package.styles).getStyle(x.styleId);if(ie){if(V={id:ie.styleId,name:ie.name??ie.styleId},ie.tblPr?.borders){let ae=ie.tblPr.borders;V.tableBorders={};for(let ye of ["top","bottom","left","right","insideH","insideV"]){let Ae=ae[ye];Ae&&(V.tableBorders[ye]={style:Ae.style,size:Ae.size,color:Ae.color?.rgb?{rgb:Ae.color.rgb}:void 0});}}if(ie.tblStylePr){V.conditionals={};for(let ae of ie.tblStylePr){let ye={};if(ae.tcPr?.shading?.fill&&(ye.backgroundColor=`#${ae.tcPr.shading.fill}`),ae.tcPr?.borders){let Ae={};for(let Qe of ["top","bottom","left","right"]){let lt=ae.tcPr.borders[Qe];lt&&(Ae[Qe]={style:lt.style,size:lt.size,color:lt.color?.rgb?{rgb:lt.color.rgb}:void 0});}ye.borders=Ae;}ae.rPr?.bold&&(ye.bold=true),ae.rPr?.color?.rgb&&(ye.color=`#${ae.rPr.color.rgb}`),V.conditionals[ae.type]=ye;}}V.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}V&&Hr({styleId:V.id,tableBorders:V.tableBorders,conditionals:V.conditionals,look:V.look})(h.state,h.dispatch);}}else ut.handleAction(x);}Oe();}},[ut,Be,Oe]),wi=fd.useCallback(x=>{let h=Be();if(!h)return;h.focus();let V=h===Fe.current?.getView(),{from:de,to:ee}=h.state.selection,ie=ot.current;if(V&&ie&&(de!==ie.from||ee!==ie.to))try{let ae=h.state.tr.setSelection(prosemirrorState.TextSelection.create(h.state.doc,ie.from,ie.to));h.dispatch(ae);}catch(ae){console.warn("Could not restore selection:",ae);}if(x==="bold"){_o(h.state,h.dispatch);return}if(x==="italic"){Vo(h.state,h.dispatch);return}if(x==="underline"){jo(h.state,h.dispatch);return}if(x==="strikethrough"){Uo(h.state,h.dispatch);return}if(x==="superscript"){Go(h.state,h.dispatch);return}if(x==="subscript"){Ko(h.state,h.dispatch);return}if(x==="bulletList"){ar(h.state,h.dispatch);return}if(x==="numberedList"){sr(h.state,h.dispatch);return}if(x==="indent"){lr(h.state,h.dispatch)||nr()(h.state,h.dispatch);return}if(x==="outdent"){cr(h.state,h.dispatch)||or()(h.state,h.dispatch);return}if(x==="clearFormatting"){ro(h.state,h.dispatch);return}if(x==="insertLink"){let ae=Nn(h.state),ye=Hn(h.state);ye?st.openEdit({url:ye.href,displayText:ae,tooltip:ye.tooltip}):st.openInsert(ae);return}if(typeof x=="object")switch(x.type){case "alignment":er(x.value)(h.state,h.dispatch);break;case "textColor":qo({rgb:x.value.replace("#","")})(h.state,h.dispatch);break;case "highlightColor":{let ae=x.value?chunkBVQ2QRHA_cjs.t(x.value):"";Yo(ae||x.value)(h.state,h.dispatch);break}case "fontSize":Xo(chunkBVQ2QRHA_cjs.e(x.value))(h.state,h.dispatch);break;case "fontFamily":Zo(x.value)(h.state,h.dispatch);break;case "lineSpacing":tr(x.value)(h.state,h.dispatch);break;case "applyStyle":{let ae=Rt.current,ye=ae?.package.styles?an(ae.package.styles):null;if(ye){let Ae=ye.resolveParagraphStyle(x.value);uo(x.value,{paragraphFormatting:Ae.paragraphFormatting,runFormatting:Ae.runFormatting})(h.state,h.dispatch);}else uo(x.value)(h.state,h.dispatch);break}}},[Be]),Ci=fd.useCallback(x=>{M(h=>({...h,variableValues:x}));},[]),Ti=fd.useCallback(async x=>{if(Ue.current){M(h=>({...h,isApplyingVariables:true}));try{let h=Ue.current.setVariables(x).getDocument();Je(h);}catch(h){a?.(h instanceof Error?h:new Error("Failed to apply variables"));}finally{M(h=>({...h,isApplyingVariables:false}));}}},[Je,a]),Ri=fd.useCallback(x=>{M(h=>({...h,zoom:x}));},[]),vi=fd.useCallback(x=>{let h=Be();if(!h)return;let V=x.url||"",de=x.tooltip,{empty:ee}=h.state.selection;ee&&x.displayText?lo(x.displayText,V,de)(h.state,h.dispatch):ee?x.displayText&&lo(x.displayText,V,de)(h.state,h.dispatch):Jo(V,de)(h.state,h.dispatch),st.close(),Oe();},[st,Be,Oe]),Pi=fd.useCallback(()=>{let x=Be();x&&(Qo(x.state,x.dispatch),st.close(),Oe());},[st,Be,Oe]),zt=fd.useCallback(x=>h=>{if(!D.state||E)return;let V={...D.state,package:{...D.state.package,document:{...D.state.package.document,finalSectionProperties:{...D.state.package.document.finalSectionProperties,[x]:h}}}};Je(V);},[D.state,E,Je]),Ro=fd.useMemo(()=>zt("marginLeft"),[zt]),Ei=fd.useMemo(()=>zt("marginRight"),[zt]),C=fd.useMemo(()=>zt("marginTop"),[zt]),ne=fd.useMemo(()=>zt("marginBottom"),[zt]),j=fd.useCallback(x=>{let h=Be();h&&rr(x)(h.state,h.dispatch);},[Be]),K=fd.useCallback(x=>{let h=Be();h&&ir(x)(h.state,h.dispatch);},[Be]),q=fd.useCallback(x=>{let h=Be();h&&(x<0?co(-x,true)(h.state,h.dispatch):co(x,false)(h.state,h.dispatch));},[Be]),W=fd.useCallback(x=>{let h=Be();h&&dr(x)(h.state,h.dispatch);},[Be]),_=fd.useCallback(x=>{},[]),X=fd.useCallback(async()=>{if(!Ue.current)return null;try{let x=await Ue.current.toBuffer();return o?.(x),x}catch(x){return a?.(x instanceof Error?x:new Error("Failed to save document")),null}},[o,a]),oe=fd.useCallback(x=>{a?.(x);},[a]),me=fd.useCallback(()=>{let x=Me.current?.querySelector(".paged-editor__pages");if(!x){window.print(),N?.();return}let h=window.open("","_blank");if(!h){window.print(),N?.();return}let V=[];for(let ee of Array.from(document.styleSheets))try{for(let ie of Array.from(ee.cssRules))ie instanceof CSSFontFaceRule&&V.push(ie.cssText);}catch{}let de=x.cloneNode(true);de.style.cssText="display: block; margin: 0; padding: 0;";for(let ee of Array.from(de.querySelectorAll(".layout-page"))){let ie=ee;ie.style.boxShadow="none",ie.style.margin="0";}h.document.write(`<!DOCTYPE html>
19
+ <html><head><title>Print</title>
20
+ <style>
21
+ ${V.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>${de.outerHTML}</body></html>`),h.document.close(),h.onload=()=>{h.print(),h.close();},setTimeout(()=>{h.closed||(h.print(),h.close());},1e3),N?.();},[N]),ce=fd.useRef(null),Se=fd.useCallback((x,h)=>{if(!D.state||!x.trim())return ce.current=null,null;let V=chunkCZ7W7MCM_cjs.j(D.state,x,h),de={matches:V,totalCount:V.length,currentIndex:0};return ce.current=de,Xe.setMatches(V,0),V.length>0&&Me.current&&chunkCZ7W7MCM_cjs.l(Me.current,V[0]),de},[D.state,Xe]),Pe=fd.useCallback(()=>{if(!ce.current||ce.current.matches.length===0)return null;let x=Xe.goToNextMatch(),h=ce.current.matches[x];return h&&Me.current&&chunkCZ7W7MCM_cjs.l(Me.current,h),h||null},[Xe]),Ee=fd.useCallback(()=>{if(!ce.current||ce.current.matches.length===0)return null;let x=Xe.goToPreviousMatch(),h=ce.current.matches[x];return h&&Me.current&&chunkCZ7W7MCM_cjs.l(Me.current,h),h||null},[Xe]),qe=fd.useCallback(x=>{if(!D.state||!ce.current||ce.current.matches.length===0)return false;let h=ce.current.matches[ce.current.currentIndex];if(!h)return false;try{let V=chunkA7VY2V4X_cjs.a(D.state,{type:"replaceText",range:{start:{paragraphIndex:h.paragraphIndex,offset:h.startOffset},end:{paragraphIndex:h.paragraphIndex,offset:h.endOffset}},text:x});return Je(V),!0}catch(V){return console.error("Replace failed:",V),false}},[D.state,Je]),Ge=fd.useCallback((x,h,V)=>{if(!D.state||!x.trim())return 0;let de=chunkCZ7W7MCM_cjs.j(D.state,x,V);if(de.length===0)return 0;let ee=D.state,ie=[...de].sort((ae,ye)=>ae.paragraphIndex!==ye.paragraphIndex?ye.paragraphIndex-ae.paragraphIndex:ye.startOffset-ae.startOffset);for(let ae of ie)try{ee=chunkA7VY2V4X_cjs.a(ee,{type:"replaceText",range:{start:{paragraphIndex:ae.paragraphIndex,offset:ae.startOffset},end:{paragraphIndex:ae.paragraphIndex,offset:ae.endOffset}},text:h});}catch(ye){console.error("Replace failed for match:",ae,ye);}return Je(ee),ce.current=null,Xe.setMatches([],0),de.length},[D.state,Je,Xe]);fd.useImperativeHandle(v,()=>({getAgent:()=>Ue.current,getDocument:()=>D.state,getEditorRef:()=>Fe.current,save:X,setZoom:x=>M(h=>({...h,zoom:x})),getZoom:()=>w.zoom,focus:()=>{Fe.current?.focus();},getCurrentPage:()=>w.currentPage,getTotalPages:()=>w.totalPages,scrollToPage:x=>{},openPrintPreview:me,print:me}),[D.state,w.zoom,w.currentPage,w.totalPages,X,me]);let it=fd.useMemo(()=>D.state?oa(D.state):[],[D.state]),{headerContent:Ze,footerContent:gt}=fd.useMemo(()=>{if(!D.state?.package)return {headerContent:null,footerContent:null};let x=D.state.package,h=x.document?.finalSectionProperties,V=x.headers,de=x.footers,ee=null,ie=null;if(V&&h?.headerReferences){let ae=h.headerReferences.find(ye=>ye.type==="default");ae?.rId&&(ee=V.get(ae.rId)??null);}if(de&&h?.footerReferences){let ae=h.footerReferences.find(ye=>ye.type==="default");ae?.rId&&(ie=de.get(ae.rId)??null);}return {headerContent:ee,footerContent:ie}},[D.state]),vt=fd.useCallback(x=>{if(x==="header"?Ze:gt){ue(x);return}if(!D.state?.package)return;let V=D.state.package,de=V.document?.finalSectionProperties;if(!de)return;let ee=`rId_new_${x}`,ie={type:x==="header"?"header":"footer",hdrFtrType:"default",content:[{type:"paragraph",content:[]}]},ae=x==="header"?"headers":"footers",ye=new Map(V[ae]??[]);ye.set(ee,ie);let Ae=x==="header"?"headerReferences":"footerReferences",Qe=de[Ae]??[],lt={type:"default",rId:ee},xt={...D.state,package:{...V,[ae]:ye,document:V.document?{...V.document,finalSectionProperties:{...de,[Ae]:[...Qe,lt]}}:V.document}};D.push(xt),ue(x);},[Ze,gt,D]),qt=fd.useCallback(x=>{if(!O||!D.state?.package){ue(null);return}let h=D.state.package,V=h.document?.finalSectionProperties,ee=(O==="header"?V?.headerReferences:V?.footerReferences)?.find(ye=>ye.type==="default"),ie=O==="header"?"headers":"footers",ae=h[ie];if(ee?.rId&&ae){let ye=ae.get(ee.rId),Ae={type:O,hdrFtrType:"default",...ye,content:x},Qe=new Map(ae);Qe.set(ee.rId,Ae);let lt={...D.state,package:{...h,[ie]:Qe}};D.push(lt);}ue(null);},[O,D]),eo=fd.useCallback(()=>{if(!O)return;let x=Te.current?.getView();if(x){let h=Wo(x.state.doc);qt(h);}else ue(null);},[O,qt]),vo=fd.useCallback(()=>{if(!O||!D.state?.package){ue(null);return}let x=D.state.package,h=x.document?.finalSectionProperties,V=O==="header"?"headerReferences":"footerReferences",de=O==="header"?"headers":"footers",ee=h?.[V],ie=ee?.find(ae=>ae.type==="default");if(ie?.rId){let ae=new Map(x[de]??[]);ae.delete(ie.rId);let ye=(ee??[]).filter(Qe=>Qe.rId!==ie.rId),Ae={...D.state,package:{...x,[de]:ae,document:x.document?{...x.document,finalSectionProperties:{...h,[V]:ye}}:x.document}};D.push(Ae);}ue(null);},[O,D]),tn=fd.useCallback(x=>{let h=Me.current?.querySelector(".paged-editor__pages");if(!h)return null;let V=x==="header"?".layout-page-header":".layout-page-footer";return h.querySelector(V)},[]),Ot={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg-subtle)",...R},$t={display:"flex",flex:1,minHeight:0,minWidth:0,flexDirection:Z==="left"?"row-reverse":"row"},bn={flex:1,minHeight:0,minWidth:0,overflow:"auto",position:"relative"},yn={width:"300px",borderLeft:Z==="right"?"1px solid var(--doc-border)":void 0,borderRight:Z==="left"?"1px solid var(--doc-border)":void 0,overflow:"auto",backgroundColor:"white"};return w.isLoading?jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-loading ${F}`,style:Ot,"data-testid":"docx-editor",children:re||jsxRuntime.jsx(ec,{})}):w.parseError?jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-error ${F}`,style:Ot,"data-testid":"docx-editor",children:jsxRuntime.jsx(nc,{message:w.parseError})}):D.state?jsxRuntime.jsx(ts,{children:jsxRuntime.jsx(Ao,{onError:oe,children:jsxRuntime.jsxs("div",{ref:Me,className:`ep-root docx-editor ${F}`,style:Ot,"data-testid":"docx-editor",children:[jsxRuntime.jsxs("div",{style:$t,children:[jsxRuntime.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[jsxRuntime.jsxs("div",{style:bn,children:[u&&!E&&jsxRuntime.jsxs("div",{ref:Ht,className:"sticky top-0 z-50 flex flex-col gap-0 bg-white shadow-sm",children:[jsxRuntime.jsx(chunkBVQ2QRHA_cjs.x,{currentFormatting:w.selectionFormatting,onFormat:wi,onUndo:Nt,onRedo:kt,canUndo:true,canRedo:true,disabled:E,documentStyles:D.state?.package.styles?.styles,theme:D.state?.package.theme||l,showPrintButton:pe,onPrint:me,showZoomControl:d,zoom:w.zoom,onZoomChange:Ri,onRefocusEditor:Oe,onInsertTable:fi,showTableInsert:true,onInsertImage:Ln,onInsertPageBreak:mi,onInsertTOC:Et,imageContext:w.pmImageContext,onImageWrapType:Jn,onImageTransform:Qn,onOpenImageProperties:yi,tableContext:w.pmTableContext,onTableAction:ki,children:J}),P&&jsxRuntime.jsx("div",{className:"flex justify-center px-5 py-1 overflow-x-auto flex-shrink-0 bg-doc-bg",children:jsxRuntime.jsx(chunkBVQ2QRHA_cjs.O,{sectionProps:D.state?.package.document?.finalSectionProperties,zoom:w.zoom,unit:S,editable:!E,onLeftMarginChange:Ro,onRightMarginChange:Ei,indentLeft:w.paragraphIndentLeft,indentRight:w.paragraphIndentRight,onIndentLeftChange:j,onIndentRightChange:K,showFirstLineIndent:true,firstLineIndent:w.paragraphFirstLineIndent,hangingIndent:w.paragraphHangingIndent,onFirstLineIndentChange:q,tabStops:w.paragraphTabs,onTabStopRemove:W})})]}),P&&!E&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,paddingTop:20,zIndex:10},children:jsxRuntime.jsx(ds,{sectionProps:D.state?.package.document?.finalSectionProperties,zoom:w.zoom,unit:S,editable:!E,onTopMarginChange:C,onBottomMarginChange:ne})}),jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative"},children:jsxRuntime.jsxs("div",{ref:Ne,style:{position:"relative",flex:1,minWidth:0},onMouseDown:x=>{x.target===x.currentTarget&&(x.preventDefault(),Fe.current?.focus());},children:[jsxRuntime.jsx(ud,{ref:Fe,document:D.state,styles:D.state?.package.styles,theme:D.state?.package.theme||l,sectionProperties:D.state?.package.document?.finalSectionProperties,headerContent:Ze,footerContent:gt,onHeaderFooterDoubleClick:vt,hfEditMode:O,onBodyClick:eo,zoom:w.zoom,readOnly:E,extensionManager:nt,onDocumentChange:Je,onSelectionChange:(x,h)=>{let V=Fe.current?.getView();if(V){let de=Wn(V.state);Fn(de);}else Fn(null);},externalPlugins:Re,onReady:x=>{T?.(x.getView());},onRenderedDomContextReady:I,pluginOverlays:y}),p&&w.totalPages>0&&(f?jsxRuntime.jsx(chunkBVQ2QRHA_cjs.H,{currentPage:w.currentPage,totalPages:w.totalPages,onNavigate:_,position:m,variant:b,floating:true}):jsxRuntime.jsx(chunkBVQ2QRHA_cjs.z,{currentPage:w.currentPage,totalPages:w.totalPages,position:m,variant:b,floating:true})),O&&(O==="header"?Ze:gt)&&(()=>{let x=tn(O),h=Ne.current;return !x||!h?null:jsxRuntime.jsx(Jl,{ref:Te,headerFooter:O==="header"?Ze:gt,position:O,styles:D.state?.package.styles,targetElement:x,parentElement:h,onSave:qt,onClose:()=>ue(null),onSelectionChange:Fn,onRemove:vo})})()]})})]}),Ce&&jsxRuntime.jsx(is,{headings:He,onHeadingClick:gi,onClose:()=>_e(false),topOffset:at}),!Ce&&jsxRuntime.jsx("button",{className:"docx-outline-nav",onClick:en,onMouseDown:x=>x.stopPropagation(),title:"Show document outline",style:{position:"absolute",left:48,top:at+12,zIndex:20,background:"transparent",border:"none",borderRadius:"50%",padding:6,cursor:"pointer",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(chunkBVQ2QRHA_cjs.d,{name:"format_list_bulleted",size:20,style:{color:"#444746"}})})]}),c&&!E&&it.length>0&&jsxRuntime.jsx("div",{style:yn,children:jsxRuntime.jsx(chunkBVQ2QRHA_cjs.y,{variables:it,values:w.variableValues,onValuesChange:Ci,onApply:Ti,isApplying:w.isApplyingVariables,descriptions:A,disabled:E})})]}),jsxRuntime.jsxs(fd.Suspense,{fallback:null,children:[Xe.state.isOpen&&jsxRuntime.jsx(Vg,{isOpen:Xe.state.isOpen,onClose:Xe.close,onFind:Se,onFindNext:Pe,onFindPrevious:Ee,onReplace:qe,onReplaceAll:Ge,initialSearchText:Xe.state.searchText,replaceMode:Xe.state.replaceMode,currentResult:ce.current}),st.state.isOpen&&jsxRuntime.jsx(jg,{isOpen:st.state.isOpen,onClose:st.close,onSubmit:vi,onRemove:st.state.isEditing?Pi:void 0,initialData:st.state.initialData,selectedText:st.state.selectedText,isEditing:st.state.isEditing}),G&&jsxRuntime.jsx(Ug,{isOpen:G,onClose:()=>U(false),onApply:x=>{let h=Be();h&&fo(x)(h.state,h.dispatch);},currentProps:w.pmTableContext?.table?.attrs}),H&&jsxRuntime.jsx(Gg,{isOpen:H,onClose:()=>z(false),onApply:bi}),$&&jsxRuntime.jsx(Kg,{isOpen:$,onClose:()=>ge(false),onApply:xi,currentData:w.pmImageContext?{alt:w.pmImageContext.alt??void 0,borderWidth:w.pmImageContext.borderWidth??void 0,borderColor:w.pmImageContext.borderColor??void 0,borderStyle:w.pmImageContext.borderStyle??void 0}:void 0}),fe&&jsxRuntime.jsx(qg,{isOpen:fe,onClose:()=>se(false),onApply:Si,footnotePr:D.state?.package.document?.finalSectionProperties?.footnotePr,endnotePr:D.state?.package.document?.finalSectionProperties?.endnotePr})]}),jsxRuntime.jsx("input",{ref:yt,type:"file",accept:"image/*",style:{display:"none"},onChange:hi})]})})}):jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-empty ${F}`,style:Ot,"data-testid":"docx-editor",children:te||jsxRuntime.jsx(tc,{})})});function XC(e,t,n={}){return new Promise((o,r)=>{let i=fd__default.default.createRef(),a=null;try{a=client.createRoot(t);}catch(c){r(c);return}let s={save:()=>i.current?.save()??Promise.resolve(null),getDocument:()=>i.current?.getDocument()??null,focus:()=>i.current?.focus(),setZoom:c=>i.current?.setZoom(c),destroy:()=>{a?.unmount(),a=null;}},l=false,u=fd__default.default.createElement(pd,{...n,documentBuffer:e,onError:c=>{n.onError?.(c),l||(l=true,r(c));},onChange:c=>{n.onChange?.(c),l||(l=true,o(s));},ref:i});a.render(u);})}var md="docx-editor-autosave",Xg=3e4,Zg=1440*60*1e3,Jg=2e3,li=1;function gd(){try{let e="__docx_editor_test__";return localStorage.setItem(e,"test"),localStorage.removeItem(e),!0}catch{return false}}function Qg(e){let t={...e,originalBuffer:null};return JSON.stringify(t)}function eh(e){try{let t=JSON.parse(e);return !t||typeof t!="object"||!t.document||!t.savedAt?null:(t.version!==li&&console.warn("Auto-save data version mismatch, may need migration"),t)}catch{return null}}function th(e,t){let n=new Date(e).getTime();return Date.now()-n>t}function QC(e,t={}){let{storageKey:n=md,interval:o=Xg,enabled:r=true,maxAge:i=Zg,onSave:a,onError:s,onRecoveryAvailable:l,saveOnChange:u=true,debounceDelay:c=Jg}=t,[d,p]=fd.useState("idle"),[f,m]=fd.useState(null),[b,g]=fd.useState(false),[k,P]=fd.useState(r),S=fd.useRef(e),B=fd.useRef(null),E=fd.useRef(null),J=fd.useRef(null),Z=fd.useRef(gd());fd.useEffect(()=>{S.current=e;},[e]);let A=fd.useCallback(async()=>{if(!Z.current)return s?.(new Error("localStorage is not available")),false;let L=S.current;if(!L)return false;p("saving");try{let N=Qg(L);if(N===J.current)return p("saved"),!0;let Y={document:L,savedAt:new Date().toISOString(),version:li},xe={document:{...L,originalBuffer:null},savedAt:Y.savedAt,version:li};localStorage.setItem(n,JSON.stringify(xe)),J.current=N;let le=new Date;return m(le),p("saved"),a?.(le),!0}catch(N){return console.error("Auto-save failed:",N),p("error"),s?.(N),false}},[n,a,s]),F=fd.useCallback(()=>{if(Z.current)try{localStorage.removeItem(n),g(!1),J.current=null;}catch(L){console.error("Failed to clear auto-save:",L);}},[n]),R=fd.useCallback(()=>{if(!Z.current)return null;try{let L=localStorage.getItem(n);if(!L)return null;let N=eh(L);return N?th(N.savedAt,i)?(F(),null):N:null}catch{return null}},[n,i,F]),te=fd.useCallback(()=>{let L=R();return L?(g(false),L.document):null},[R]),re=fd.useCallback(()=>{F(),g(false);},[F]),Q=fd.useCallback(()=>{P(true);},[]),pe=fd.useCallback(()=>{P(false),B.current&&(clearInterval(B.current),B.current=null),E.current&&(clearTimeout(E.current),E.current=null);},[]);return fd.useEffect(()=>{if(!Z.current)return;let L=R();L&&(g(true),l?.(L));},[R,l]),fd.useEffect(()=>{if(!k||!Z.current){B.current&&(clearInterval(B.current),B.current=null);return}return B.current=setInterval(()=>{A();},o),()=>{B.current&&(clearInterval(B.current),B.current=null);}},[k,o,A]),fd.useEffect(()=>{if(!(!k||!u||!e||!Z.current))return E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{A();},c),()=>{E.current&&clearTimeout(E.current);}},[k,u,e,c,A]),fd.useEffect(()=>()=>{if(k&&S.current&&Z.current)try{let N={document:{...S.current,originalBuffer:null},savedAt:new Date().toISOString(),version:li};localStorage.setItem(n,JSON.stringify(N));}catch(L){console.error("Failed to save on unmount:",L);}},[k,n]),{status:d,lastSaveTime:f,save:A,clearAutoSave:F,hasRecoveryData:b,getRecoveryData:R,acceptRecovery:te,dismissRecovery:re,isEnabled:k,enable:Q,disable:pe}}function eT(e){if(!e)return "Never";let n=new Date().getTime()-e.getTime(),o=Math.floor(n/1e3),r=Math.floor(o/60),i=Math.floor(r/60);return o<10?"Just now":o<60?`${o} seconds ago`:r<60?`${r} minute${r===1?"":"s"} ago`:i<24?`${i} hour${i===1?"":"s"} ago`:e.toLocaleDateString()}function tT(e){return {idle:"Ready",saving:"Saving...",saved:"Saved",error:"Save failed"}[e]}function nT(e=md){try{let t=localStorage.getItem(e);return t?new Blob([t]).size:0}catch{return 0}}function oT(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function rT(){return gd()}var rh=1,hd=.25,bd=4,ih=.1,Bt=[.25,.5,.75,1,1.25,1.5,2,3,4];function yd(e,t,n){return Math.max(t,Math.min(n,e))}function xd(e){return Math.round(e*100)/100}function ah(e){let t=Bt[0],n=Math.abs(e-t);for(let o of Bt){let r=Math.abs(e-o);r<n&&(n=r,t=o);}return t}function sh(e){for(let t of Bt)if(t>e+.01)return t;return Bt[Bt.length-1]}function lh(e){for(let t=Bt.length-1;t>=0;t--)if(Bt[t]<e-.01)return Bt[t];return Bt[0]}function sT(e={}){let{initialZoom:t=rh,minZoom:n=hd,maxZoom:o=bd,zoomStep:r=ih,enabled:i=true,containerRef:a,onZoomChange:s,enableKeyboardShortcuts:l=true,preventDefault:u=true}=e,[c,d]=fd.useState(t),p=fd.useRef(c);fd.useEffect(()=>{p.current=c;},[c]);let f=fd.useCallback(E=>{let J=xd(yd(E,n,o));J!==p.current&&(d(J),s?.(J));},[n,o,s]),m=fd.useCallback(()=>{f(p.current+r);},[r,f]),b=fd.useCallback(()=>{f(p.current-r);},[r,f]),g=fd.useCallback(()=>{f(t);},[t,f]),k=fd.useCallback(()=>{f(1);},[f]),P=fd.useCallback((E,J)=>{if(J>0){let Z=E/J;f(Z);}},[f]),S=fd.useCallback(E=>{if(!i||!(E.ctrlKey||E.metaKey))return;u&&E.preventDefault();let Z=E.deltaY;Z<0?f(p.current+r):Z>0&&f(p.current-r);},[i,u,r,f]),B=fd.useCallback(E=>{if(!(!i||!l||!(E.ctrlKey||E.metaKey))){if(E.key==="0"){E.preventDefault(),k();return}if(E.key==="+"||E.key==="="){E.preventDefault(),m();return}if(E.key==="-"){E.preventDefault(),b();return}}},[i,l,m,b,k]);return fd.useEffect(()=>{if(!i)return;let E=a?.current;if(E)return E.addEventListener("wheel",S,{passive:false}),()=>{E.removeEventListener("wheel",S);}},[i,a,S]),fd.useEffect(()=>{if(!(!i||!l))return document.addEventListener("keydown",B),()=>{document.removeEventListener("keydown",B);}},[i,l,B]),{zoom:c,setZoom:f,zoomIn:m,zoomOut:b,resetZoom:g,zoomTo100:k,zoomToFit:P,isMinZoom:c<=n,isMaxZoom:c>=o,zoomPercent:Math.round(c*100),handleWheel:S,handleKeyDown:B}}function lT(){return [...Bt]}function cT(e){return ah(e)}function dT(e){return sh(e)}function uT(e){return lh(e)}function pT(e){return `${Math.round(e*100)}%`}function fT(e){let t=e.match(/(\d+(\.\d+)?)/);if(t){let n=parseFloat(t[1]);if(!isNaN(n))return n/100}return null}function mT(e){return Bt.some(t=>Math.abs(t-e)<.01)}function gT(e,t=hd,n=bd){return xd(yd(e,t,n))}var Yn={backgroundColor:"rgba(26, 115, 232, 0.3)",borderRadius:0,zIndex:0,opacity:1,mixBlendMode:"multiply"},bT={backgroundColor:"rgba(0, 120, 215, 0.4)",borderColor:"rgba(0, 120, 215, 0.6)",borderRadius:1,zIndex:0,opacity:1},yT={backgroundColor:"--docx-selection-bg",borderColor:"--docx-selection-border",textColor:"--docx-selection-text"};function Sd(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 ch(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 Ca(e){let t=Sd(e);return ch(t)}function xT(e,t=Yn){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 ST(e,t=Yn){let n=t.backgroundColor;return `
30
+ ${e}::selection,
31
+ ${e} *::selection {
32
+ background-color: ${n} !important;
33
+ color: inherit !important;
34
+ }
35
+
36
+ ${e}::-moz-selection,
37
+ ${e} *::-moz-selection {
38
+ background-color: ${n} !important;
39
+ color: inherit !important;
40
+ }
41
+ `}function kd(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function wd(){let e=window.getSelection();return e?e.toString():""}function Cd(e){let t=window.getSelection();if(!t||t.rangeCount===0)return false;let n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)}function kT(){let e=window.getSelection();return !e||e.rangeCount===0?null:e.getRangeAt(0).getBoundingClientRect()}function wT(e,t,n,o,r){try{let i=document.createRange();return i.setStart(t,n),i.setEnd(o,r),i}catch{return null}}function CT(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e));}function TT(){let e=window.getSelection();e&&e.removeAllRanges();}function dh(){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 RT(){let e=window.getSelection();if(!e||e.rangeCount===0||!dh())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 gn=null;function Td(e=Yn){uh();let t=`
42
+ /* DOCX Editor Selection Highlighting */
43
+
44
+ /* Base selection style for all editable content */
45
+ .docx-editor [contenteditable="true"]::selection,
46
+ .docx-editor [contenteditable="true"] *::selection,
47
+ .docx-run-editable::selection,
48
+ .docx-run-editable *::selection {
49
+ background-color: ${e.backgroundColor} !important;
50
+ color: inherit !important;
51
+ }
52
+
53
+ /* Firefox selection */
54
+ .docx-editor [contenteditable="true"]::-moz-selection,
55
+ .docx-editor [contenteditable="true"] *::-moz-selection,
56
+ .docx-run-editable::-moz-selection,
57
+ .docx-run-editable *::-moz-selection {
58
+ background-color: ${e.backgroundColor} !important;
59
+ color: inherit !important;
60
+ }
61
+
62
+ /* Ensure selection is visible against all backgrounds */
63
+ .docx-run-highlighted::selection,
64
+ .docx-run-highlighted *::selection {
65
+ /* For highlighted (yellow background) text, use darker selection */
66
+ background-color: rgba(26, 115, 232, 0.5) !important;
67
+ }
68
+
69
+ .docx-run-highlighted::-moz-selection,
70
+ .docx-run-highlighted *::-moz-selection {
71
+ background-color: rgba(26, 115, 232, 0.5) !important;
72
+ }
73
+
74
+ /* Selection in dark text */
75
+ .docx-run-dark-bg::selection,
76
+ .docx-run-dark-bg *::selection {
77
+ /* Use lighter selection for dark backgrounds */
78
+ background-color: rgba(100, 181, 246, 0.5) !important;
79
+ }
80
+
81
+ .docx-run-dark-bg::-moz-selection,
82
+ .docx-run-dark-bg *::-moz-selection {
83
+ background-color: rgba(100, 181, 246, 0.5) !important;
84
+ }
85
+
86
+ /* Programmatic highlight class */
87
+ .docx-selection-highlight {
88
+ background-color: ${e.backgroundColor};
89
+ ${e.borderRadius?`border-radius: ${e.borderRadius}px;`:""}
90
+ ${e.mixBlendMode?`mix-blend-mode: ${e.mixBlendMode};`:""}
91
+ }
92
+
93
+ /* Find/replace highlight */
94
+ .docx-find-highlight {
95
+ background-color: rgba(255, 235, 59, 0.5);
96
+ border-radius: 2px;
97
+ }
98
+
99
+ .docx-find-highlight-current {
100
+ background-color: rgba(255, 152, 0, 0.6);
101
+ border-radius: 2px;
102
+ outline: 2px solid rgba(255, 152, 0, 0.8);
103
+ }
104
+
105
+ /* AI action selection preview */
106
+ .docx-ai-selection-preview {
107
+ background-color: rgba(156, 39, 176, 0.2);
108
+ border-bottom: 2px dashed rgba(156, 39, 176, 0.6);
109
+ }
110
+ `;gn=document.createElement("style"),gn.id="docx-selection-styles",gn.textContent=t,document.head.appendChild(gn);}function uh(){gn&&(gn.remove(),gn=null);let e=document.getElementById("docx-selection-styles");e&&e.remove();}function Rd(){return gn!==null||document.getElementById("docx-selection-styles")!==null}function vT(e,t,n=true){return ()=>{if(!e){t([]);return}let o=n?Ca(e):Sd(e);t(o);}}function LT(e){let{containerRef:t,enabled:n=true,config:o=Yn,useOverlay:r=false,debounceMs:i=16,onSelectionChange:a}=e,[s,l]=fd.useState(false),[u,c]=fd.useState(""),[d,p]=fd.useState([]),[f,m]=fd.useState(false),b=fd.useRef(null),g=fd.useRef(0),k=fd.useCallback(()=>{let E=t.current,J=kd(),Z=wd(),A=E?Cd(E):false;if(l(J),c(Z),m(A),r&&A){let F=Ca(E);p(F);}else p([]);a&&a(J&&A,Z);},[t,r,a]),P=fd.useCallback(()=>{let E=performance.now();if(E-g.current<i){b.current!==null&&clearTimeout(b.current),b.current=window.setTimeout(()=>{g.current=performance.now(),k(),b.current=null;},i);return}g.current=E,k();},[i,k]),S=fd.useCallback(()=>{k();},[k]),B=fd.useCallback(E=>({position:"absolute",left:`${E.left}px`,top:`${E.top}px`,width:`${E.width}px`,height:`${E.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 fd.useEffect(()=>(n&&!Rd()&&Td(o),()=>{}),[n,o]),fd.useEffect(()=>{if(!n)return;let E=()=>{P();};return document.addEventListener("selectionchange",E),document.addEventListener("mouseup",E),k(),()=>{document.removeEventListener("selectionchange",E),document.removeEventListener("mouseup",E),b.current!==null&&clearTimeout(b.current);}},[n,P,k]),{hasSelection:s,selectedText:u,highlightRects:d,isSelectionInContainer:f,refresh:S,getOverlayStyle:B}}function BT(e,t=Yn){return e.map((n,o)=>fd__default.default.createElement("div",{key:`selection-overlay-${o}`,style:{position:"absolute",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,backgroundColor:t.backgroundColor,borderRadius:t.borderRadius?`${t.borderRadius}px`:void 0,border:t.borderColor?`1px solid ${t.borderColor}`:void 0,zIndex:t.zIndex??0,opacity:t.opacity??1,mixBlendMode:t.mixBlendMode,pointerEvents:"none",userSelect:"none"}}))}chunkBVQ2QRHA_cjs.ra();function fh(){let e=window.getSelection();if(!e||e.isCollapsed)return [];let t=[],n=e.getRangeAt(0),o=n.commonAncestorContainer,r=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement;if(!r)return t;if(r.querySelectorAll(".docx-run").forEach(a=>{if(n.intersectsNode(a)){let s=mh(a,n);if(s){let l=gh(a);t.push({type:"run",formatting:l,content:[{type:"text",text:s}]});}}}),t.length===0){let a=e.toString();a&&t.push({type:"run",content:[{type:"text",text:a}]});}return t}function mh(e,t){let n=document.createRange();n.selectNodeContents(e);let o=t.compareBoundaryPoints(Range.START_TO_START,n)>=0&&t.compareBoundaryPoints(Range.START_TO_END,n)<=0,r=t.compareBoundaryPoints(Range.END_TO_START,n)>=0&&t.compareBoundaryPoints(Range.END_TO_END,n)<=0;if(o&&r)return t.toString();if(o){let i=document.createRange();return i.setStart(t.startContainer,t.startOffset),i.selectNodeContents(e),i.setEnd(n.endContainer,n.endOffset),i.toString()}else if(r){let i=document.createRange();return i.selectNodeContents(e),i.setEnd(t.endContainer,t.endOffset),i.setStart(n.startContainer,n.startOffset),i.toString()}else if(t.intersectsNode(e))return e.textContent||"";return ""}function gh(e){let t=window.getComputedStyle(e),n={};(t.fontWeight==="bold"||parseInt(t.fontWeight)>=700)&&(n.bold=true),t.fontStyle==="italic"&&(n.italic=true);let o=t.textDecoration||t.textDecorationLine;o&&o.includes("underline")&&(n.underline={style:"single"}),o&&o.includes("line-through")&&(n.strike=true);let r=parseFloat(t.fontSize);!isNaN(r)&&r>0&&(n.fontSize=Math.round(r/1.333*2));let i=t.fontFamily.replace(/["']/g,"").split(",")[0].trim();i&&(n.fontFamily={ascii:i});let a=t.color;if(a&&a!=="rgb(0, 0, 0)"){let l=Md(a);l&&(n.color={rgb:l});}let s=t.backgroundColor;if(s&&s!=="transparent"&&s!=="rgba(0, 0, 0, 0)"){let l=Md(s);l&&(n.shading={fill:{rgb:l}});}return Object.keys(n).length>0?n:void 0}function Md(e){if(!e||e==="transparent"||e==="inherit")return null;if(e.startsWith("#"))return e.slice(1).toUpperCase();let t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(t){let n=parseInt(t[1]).toString(16).padStart(2,"0"),o=parseInt(t[2]).toString(16).padStart(2,"0"),r=parseInt(t[3]).toString(16).padStart(2,"0");return (n+o+r).toUpperCase()}return null}function Id(){let e=window.getSelection();if(!e||e.isCollapsed)return null;let t=fh();if(t.length===0)return null;let n=e.toString(),o=e.getRangeAt(0),r=Fd(o.startContainer),i=Fd(o.endContainer),a=r?parseInt(r.getAttribute("data-paragraph-index")||"0",10):0,s=i?parseInt(i.getAttribute("data-paragraph-index")||"0",10):0;return {text:n,runs:t,startParagraphIndex:a,startRunIndex:0,startOffset:o.startOffset,endParagraphIndex:s,endRunIndex:0,endOffset:o.endOffset,isMultiParagraph:a!==s}}function Fd(e){let t=e;for(;t;){if(t.nodeType===Node.ELEMENT_NODE){let n=t;if(n.hasAttribute("data-paragraph-index"))return n}t=t.parentNode;}return null}function NT(e={}){let{onCopy:t,onCut:n,onPaste:o,cleanWordFormatting:r=true,editable:i=true,onError:a}=e,s=fd.useRef(false),l=fd.useRef(null),u=fd.useCallback(async g=>{if(s.current)return false;s.current=true;try{let k=await chunkBVQ2QRHA_cjs.da(g.runs,{onError:a});return k&&t?.(g),k}finally{s.current=false;}},[t,a]),c=fd.useCallback(async g=>{if(s.current||!i)return false;s.current=true;try{let k=await chunkBVQ2QRHA_cjs.da(g.runs,{onError:a});return k&&n?.(g),k}finally{s.current=false;}},[n,i,a]),d=fd.useCallback(async(g=false)=>{if(s.current||!i)return null;s.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let k=await navigator.clipboard.read(),P="",S="";for(let E of k)E.types.includes("text/html")&&(P=await(await E.getType("text/html")).text()),E.types.includes("text/plain")&&(S=await(await E.getType("text/plain")).text());g&&(P="");let B=hh(P,S,r);return l.current=B,o?.(B,g),B}return null}catch(k){return a?.(k),null}finally{s.current=false;}},[i,r,o,a]),p=fd.useCallback(g=>{let k=Id();if(!k)return;g.preventDefault();let P=chunkBVQ2QRHA_cjs.fa(k.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",P.plainText),g.clipboardData.setData("text/html",P.html),P.internal&&g.clipboardData.setData("application/x-docx-editor",P.internal)),t?.(k);},[t]),f=fd.useCallback(g=>{if(!i)return;let k=Id();if(!k)return;g.preventDefault();let P=chunkBVQ2QRHA_cjs.fa(k.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",P.plainText),g.clipboardData.setData("text/html",P.html),P.internal&&g.clipboardData.setData("application/x-docx-editor",P.internal)),n?.(k);},[i,n]),m=fd.useCallback(g=>{if(!i)return;g.preventDefault();let k=chunkBVQ2QRHA_cjs.ja(g,{cleanWordFormatting:r});if(k){l.current=k;let P=g.shiftKey??false;o?.(k,P);}},[i,r,o]),b=fd.useCallback(g=>{g.ctrlKey||g.metaKey;},[]);return {copy:u,cut:c,paste:d,handleCopy:p,handleCut:f,handlePaste:m,handleKeyDown:b,isProcessing:s.current,lastPastedContent:l.current}}function hh(e,t,n){let{parseClipboardHtml:o}=(chunkBVQ2QRHA_cjs.ra(),chunkRTESADL3_cjs.d(chunkBVQ2QRHA_cjs.qa));return o(e,t,n)}var pi={position:"right",defaultSize:280,minSize:200,maxSize:500,resizable:true,collapsible:true,defaultCollapsed:false};function Ad(e,t){let n=`plugin-styles-${e}`,o=document.getElementById(n);o&&o.remove();let r=document.createElement("style");return r.id=n,r.textContent=t,document.head.appendChild(r),()=>{let i=document.getElementById(n);i&&i.remove();}}var Dd=`
111
+ .plugin-host {
112
+ display: flex;
113
+ width: 100%;
114
+ height: 100%;
115
+ overflow: visible;
116
+ position: relative;
117
+ }
118
+
119
+ .plugin-host-editor {
120
+ flex: 1;
121
+ display: flex;
122
+ flex-direction: column;
123
+ min-width: 0;
124
+ overflow: visible;
125
+ }
126
+
127
+
128
+ .plugin-panels-left,
129
+ .plugin-panels-right {
130
+ display: flex;
131
+ flex-direction: column;
132
+ flex-shrink: 0;
133
+ background: #f8f9fa;
134
+ border-color: #e9ecef;
135
+ }
136
+
137
+ .plugin-panels-left {
138
+ border-right: 1px solid #e9ecef;
139
+ }
140
+
141
+ .plugin-panels-right {
142
+ border-left: 1px solid #e9ecef;
143
+ }
144
+
145
+ .plugin-panels-bottom {
146
+ border-top: 1px solid #e9ecef;
147
+ background: #f8f9fa;
148
+ }
149
+
150
+ .plugin-panel {
151
+ position: relative;
152
+ display: flex;
153
+ flex-direction: column;
154
+ overflow: hidden;
155
+ transition: width 0.2s ease, height 0.2s ease;
156
+ }
157
+
158
+ .plugin-panel.collapsed {
159
+ overflow: visible;
160
+ }
161
+
162
+ .plugin-panel-toggle {
163
+ display: flex;
164
+ align-items: center;
165
+ gap: 4px;
166
+ padding: 6px 8px;
167
+ background: transparent;
168
+ border: none;
169
+ cursor: pointer;
170
+ font-size: 12px;
171
+ color: #6c757d;
172
+ white-space: nowrap;
173
+ }
174
+
175
+ .plugin-panel.collapsed .plugin-panel-toggle {
176
+ writing-mode: vertical-rl;
177
+ text-orientation: mixed;
178
+ flex-direction: column;
179
+ height: 100%;
180
+ padding: 8px 6px;
181
+ }
182
+
183
+ .plugin-panel-toggle:hover {
184
+ background: #e9ecef;
185
+ color: #495057;
186
+ }
187
+
188
+ .plugin-panel-toggle-icon {
189
+ font-weight: bold;
190
+ font-size: 14px;
191
+ }
192
+
193
+ .plugin-panel.collapsed .plugin-panel-toggle-icon {
194
+ transform: rotate(90deg);
195
+ }
196
+
197
+ .plugin-panel-toggle-label {
198
+ font-weight: 500;
199
+ }
200
+
201
+ .plugin-panel-content {
202
+ flex: 1;
203
+ overflow: auto;
204
+ }
205
+
206
+ /* Right panel rendered inside viewport - scrolls with content */
207
+ .plugin-panel-in-viewport {
208
+ position: absolute;
209
+ top: 0;
210
+ /* Position is set dynamically via inline styles based on page edge */
211
+ width: 220px;
212
+ pointer-events: auto;
213
+ z-index: 10;
214
+ overflow: visible;
215
+ }
216
+
217
+ .plugin-panel-in-viewport.collapsed {
218
+ width: 32px;
219
+ }
220
+
221
+ .plugin-panel-in-viewport .plugin-panel-toggle {
222
+ position: sticky;
223
+ top: 0;
224
+ background: rgba(255, 255, 255, 0.95);
225
+ border-radius: 4px;
226
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
227
+ }
228
+
229
+ .plugin-panel-in-viewport-content {
230
+ overflow: visible;
231
+ position: relative;
232
+ }
233
+
234
+ /* Plugin overlay container for rendering highlights/decorations */
235
+ .plugin-overlays-container {
236
+ position: absolute;
237
+ top: 0;
238
+ left: 0;
239
+ right: 0;
240
+ bottom: 0;
241
+ pointer-events: none;
242
+ overflow: visible;
243
+ z-index: 5;
244
+ }
245
+
246
+ .plugin-overlay {
247
+ position: absolute;
248
+ top: 0;
249
+ left: 0;
250
+ right: 0;
251
+ bottom: 0;
252
+ pointer-events: none;
253
+ }
254
+
255
+ .plugin-overlay > * {
256
+ pointer-events: auto;
257
+ }
258
+ `,Sh=fd.forwardRef(function({plugins:t,children:n,className:o=""},r){let[i,a]=fd.useState(null),s=fd.useRef(n.props);s.current=n.props;let[l,u]=fd.useState(null),c=fd.useRef(new Map),[d,p]=fd.useState(0),f=fd.useCallback(()=>p(L=>L+1),[]),[m,b]=fd.useState(()=>{let L=new Set;for(let N of t)({...pi,...N.panelConfig}).defaultCollapsed&&L.add(N.id);return L}),[g]=fd.useState(()=>{let L=new Map;for(let N of t){let Y={...pi,...N.panelConfig};L.set(N.id,Y.defaultSize);}return L});fd.useEffect(()=>{for(let L of t)L.initialize&&!c.current.has(L.id)&&c.current.set(L.id,L.initialize(i));f();},[t,i]),fd.useEffect(()=>Ad("plugin-host-base",Dd),[]),fd.useEffect(()=>{let L=[];for(let N of t)N.styles&&L.push(Ad(N.id,N.styles));return ()=>{for(let N of L)N();}},[t]),fd.useEffect(()=>()=>{for(let L of t)L.destroy&&L.destroy();},[t]),fd.useEffect(()=>{if(!i)return;let L=()=>{let Re=false;for(let T of t)if(T.onStateChange){let I=T.onStateChange(i);I!==void 0&&(c.current.set(T.id,I),Re=true);}Re&&f();};L();let N=i.dom;N.addEventListener("input",L),N.addEventListener("focus",L),N.addEventListener("click",L);let Y=null,xe=()=>{Y&&cancelAnimationFrame(Y),Y=requestAnimationFrame(L);},le=i.dispatch.bind(i);return i.dispatch=Re=>{le(Re),xe();},()=>{N.removeEventListener("input",L),N.removeEventListener("focus",L),N.removeEventListener("click",L),Y&&cancelAnimationFrame(Y),i.dispatch=le;}},[i,t]);let k=fd.useCallback(L=>{if(!i)return;if(i.coordsAtPos(L)){i.dom.scrollIntoView({block:"center",inline:"nearest"});let{state:Y}=i,xe=Y.doc.resolve(Math.min(L,Y.doc.content.size)),le=Y.tr.setSelection(prosemirrorState.TextSelection.near(xe));i.dispatch(le),i.focus();}},[i]),P=fd.useCallback((L,N)=>{if(!i)return;let{state:Y}=i,xe=Y.doc.content.size,le=Math.max(0,Math.min(L,xe)),Re=Math.max(0,Math.min(N,xe)),T=Y.tr.setSelection(prosemirrorState.TextSelection.create(Y.doc,le,Re));i.dispatch(T),i.focus();},[i]),S=fd.useCallback(L=>c.current.get(L),[]),B=fd.useCallback((L,N)=>{c.current.set(L,N),f();},[]),E=fd.useCallback(()=>{if(i){for(let L of t)if(L.onStateChange){let N=L.onStateChange(i);N!==void 0&&c.current.set(L.id,N);}f();}},[i,t]);fd.useImperativeHandle(r,()=>({getPluginState:S,setPluginState:B,getEditorView:()=>i,refreshPluginStates:E}),[S,B,i,E]);let J=fd.useMemo(()=>{let L=[];for(let N of t)N.proseMirrorPlugins&&L.push(...N.proseMirrorPlugins);return L},[t]),Z=fd.useCallback(L=>{b(N=>{let Y=new Set(N);return Y.has(L)?Y.delete(L):Y.add(L),Y});},[]),[A,F]=fd.useState(null);fd.useEffect(()=>{if(!l){F(null);return}let L=()=>{let xe=l.pagesContainer,le=xe.querySelector(".layout-page");if(!le){F(null);return}let Re=l.getContainerOffset(),T=le.getBoundingClientRect(),I=xe.getBoundingClientRect(),y=(T.right-I.left)/l.zoom,v=Re.x+y+5;F(v);};L();let N=()=>{requestAnimationFrame(L);};window.addEventListener("resize",N);let Y=new ResizeObserver(()=>{requestAnimationFrame(L);});return Y.observe(l.pagesContainer),()=>{window.removeEventListener("resize",N),Y.disconnect();}},[l]);let R=fd.useMemo(()=>{let L=[];if(l){for(let N of t)if(N.renderOverlay){let Y=c.current.get(N.id);L.push(jsxRuntime.jsx("div",{className:"plugin-overlay","data-plugin-id":N.id,children:N.renderOverlay(l,Y,i)},`overlay-${N.id}`));}}for(let N of t){if(!N.Panel||(N.panelConfig?.position??"right")!=="right")continue;let xe={...pi,...N.panelConfig},le=m.has(N.id),Re=g.get(N.id)??xe.defaultSize,T=N.Panel,I=c.current.get(N.id),y=A!==null?`${A}px`:"calc(50% + 428px)";L.push(jsxRuntime.jsxs("div",{className:`plugin-panel-in-viewport ${le?"collapsed":""}`,style:{width:le?"32px":`${Re}px`,left:y},"data-plugin-id":N.id,children:[xe.collapsible&&jsxRuntime.jsx("button",{className:"plugin-panel-toggle",onClick:()=>Z(N.id),title:le?`Show ${N.name}`:`Hide ${N.name}`,"aria-label":le?`Show ${N.name}`:`Hide ${N.name}`,children:jsxRuntime.jsx("span",{className:"plugin-panel-toggle-icon",children:le?"\u2039":"\u203A"})}),!le&&l&&jsxRuntime.jsx("div",{className:"plugin-panel-in-viewport-content",children:jsxRuntime.jsx(T,{editorView:i,doc:i?.state.doc??null,scrollToPosition:k,selectRange:P,pluginState:I,panelWidth:Re,renderedDomContext:l})})]},`panel-overlay-${N.id}`));}return L.length>0?L:null},[l,t,d,i,m,g,k,P,Z,A]),te=fd.useCallback(L=>{u(L);let N=s.current?.onRenderedDomContextReady;typeof N=="function"&&N(L);},[]),re=fd.useMemo(()=>fd.cloneElement(n,{externalPlugins:J,pluginOverlays:R,onRenderedDomContextReady:te,onEditorViewReady:L=>{a(L);let N=s.current?.onEditorViewReady;typeof N=="function"&&N(L);}}),[n,J,R,te]),Q=fd.useMemo(()=>{let L=[],N=[],Y=[];for(let xe of t){if(!xe.Panel)continue;let le=xe.panelConfig?.position??"right";le==="left"?L.push(xe):le==="bottom"?Y.push(xe):N.push(xe);}return {left:L,right:N,bottom:Y}},[t]),pe=L=>{if(!L.Panel)return null;let N={...pi,...L.panelConfig},Y=m.has(L.id),xe=g.get(L.id)??N.defaultSize,le=L.Panel,Re=c.current.get(L.id);return jsxRuntime.jsxs("div",{className:`plugin-panel plugin-panel-${N.position} ${Y?"collapsed":""}`,style:{[N.position==="bottom"?"height":"width"]:Y?"32px":`${xe}px`,minWidth:N.position!=="bottom"?Y?"32px":`${N.minSize}px`:void 0,maxWidth:N.position!=="bottom"?`${N.maxSize}px`:void 0,minHeight:N.position==="bottom"?Y?"32px":`${N.minSize}px`:void 0,maxHeight:N.position==="bottom"?`${N.maxSize}px`:void 0},"data-plugin-id":L.id,children:[N.collapsible&&jsxRuntime.jsxs("button",{className:"plugin-panel-toggle",onClick:()=>Z(L.id),title:Y?`Show ${L.name}`:`Hide ${L.name}`,"aria-label":Y?`Show ${L.name}`:`Hide ${L.name}`,children:[jsxRuntime.jsx("span",{className:"plugin-panel-toggle-icon",children:Y?"\u203A":"\u2039"}),Y&&jsxRuntime.jsx("span",{className:"plugin-panel-toggle-label",children:L.name})]}),!Y&&jsxRuntime.jsx("div",{className:"plugin-panel-content",children:jsxRuntime.jsx(le,{editorView:i,doc:i?.state.doc??null,scrollToPosition:k,selectRange:P,pluginState:Re,panelWidth:xe,renderedDomContext:l??null})})]},L.id)};return jsxRuntime.jsxs("div",{className:`plugin-host ${o}`,children:[Q.left.length>0&&jsxRuntime.jsx("div",{className:"plugin-panels-left",children:Q.left.map(pe)}),jsxRuntime.jsxs("div",{className:"plugin-host-editor",children:[re,Q.bottom.length>0&&jsxRuntime.jsx("div",{className:"plugin-panels-bottom",children:Q.bottom.map(pe)})]})]})});exports.$=Dd;exports.A=gT;exports.B=Yn;exports.C=bT;exports.D=yT;exports.E=Sd;exports.F=ch;exports.G=Ca;exports.H=xT;exports.I=ST;exports.J=kd;exports.K=wd;exports.L=Cd;exports.M=kT;exports.N=wT;exports.O=CT;exports.P=TT;exports.Q=dh;exports.R=RT;exports.S=Td;exports.T=uh;exports.U=Rd;exports.V=vT;exports.W=LT;exports.X=BT;exports.Y=fh;exports.Z=Id;exports._=NT;exports.a=Ch;exports.aa=Sh;exports.b=ts;exports.c=Ao;exports.d=Th;exports.e=Rh;exports.f=vh;exports.g=Ph;exports.h=Bh;exports.i=os;exports.j=pd;exports.k=XC;exports.l=QC;exports.m=eT;exports.n=tT;exports.o=nT;exports.p=oT;exports.q=rT;exports.r=Bt;exports.s=sT;exports.t=lT;exports.u=cT;exports.v=dT;exports.w=uT;exports.x=pT;exports.y=fT;exports.z=mT;