@eigenpal/docx-js-editor 0.0.20 → 0.0.21

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 (200) hide show
  1. package/dist/{ClipboardManager-EZ0C6Onq.d.cts → ClipboardManager-B1jZrC6h.d.cts} +1 -1
  2. package/dist/{ClipboardManager-D6dkOFg6.d.ts → ClipboardManager-jqJVxB6g.d.ts} +1 -1
  3. package/dist/{DocumentAgent-BcCDg7i2.d.ts → DocumentAgent-CnJ9AEl_.d.cts} +31 -3
  4. package/dist/{DocumentAgent-B0EC8lPC.d.cts → DocumentAgent-CrbsDniO.d.ts} +31 -3
  5. package/dist/{FindReplaceDialog-AWQXKEUQ.js → FindReplaceDialog-AQFR4OCT.js} +1 -2
  6. package/dist/FindReplaceDialog-J3DI3U5I.cjs +1 -0
  7. package/dist/{FootnotePropertiesDialog-73VT2ZVZ.cjs → FootnotePropertiesDialog-DO5DCAW6.cjs} +1 -2
  8. package/dist/{FootnotePropertiesDialog-ZM3EF3EF.js → FootnotePropertiesDialog-YYIZU5U6.js} +1 -2
  9. package/dist/{HyperlinkDialog-BA25XUT5.js → HyperlinkDialog-HGZ2S37Z.js} +1 -2
  10. package/dist/HyperlinkDialog-PEPS3C2G.cjs +1 -0
  11. package/dist/{ImagePositionDialog-AIAMKPFK.js → ImagePositionDialog-DQ4JWS4F.js} +1 -2
  12. package/dist/{ImagePositionDialog-KMK7ROV2.cjs → ImagePositionDialog-UYXYHSP4.cjs} +1 -2
  13. package/dist/{ImagePropertiesDialog-ERFCUVCW.js → ImagePropertiesDialog-GJMGLM6G.js} +1 -2
  14. package/dist/{ImagePropertiesDialog-USMMRK6X.cjs → ImagePropertiesDialog-V6SVKINO.cjs} +1 -2
  15. package/dist/{TablePropertiesDialog-72CIUAZT.cjs → TablePropertiesDialog-A36OXG3A.cjs} +1 -2
  16. package/dist/{TablePropertiesDialog-EMUEVYB3.js → TablePropertiesDialog-STZOGHJB.js} +1 -2
  17. package/dist/{agentApi-BFVyKagE.d.cts → agentApi-DfsWRyrP.d.cts} +1 -1
  18. package/dist/{agentApi-BFVyKagE.d.ts → agentApi-DfsWRyrP.d.ts} +1 -1
  19. package/dist/{chunk-FDANI5P4.cjs → chunk-2VHQ7YOQ.cjs} +1 -2
  20. package/dist/chunk-2Y6FLZ5Q.js +3 -0
  21. package/dist/chunk-32HMU2UV.js +111 -0
  22. package/dist/chunk-4CUGBNL2.cjs +1 -0
  23. package/dist/chunk-5GFXHUMP.js +1 -0
  24. package/dist/chunk-6NDMKJIE.js +9 -0
  25. package/dist/chunk-6NYA53QC.cjs +258 -0
  26. package/dist/chunk-7KJ3YVDQ.js +10 -0
  27. package/dist/{chunk-JOYPFQW2.js → chunk-AARNCPWR.js} +1 -2
  28. package/dist/{chunk-4QT5LPBA.cjs → chunk-B7TICMXD.cjs} +16 -17
  29. package/dist/{chunk-2QOEHCBX.js → chunk-BUEMG4NW.js} +1 -2
  30. package/dist/{chunk-CV5WFE7K.js → chunk-CLDB6TL7.js} +2 -3
  31. package/dist/{chunk-M2T6XKT5.js → chunk-CTYOM6BE.js} +1 -2
  32. package/dist/chunk-EH3NY2DQ.cjs +26 -0
  33. package/dist/{chunk-FGVGZLBL.js → chunk-FVUGBRDD.js} +1 -2
  34. package/dist/chunk-FXJAIFPR.js +59 -0
  35. package/dist/chunk-GICVJSFJ.cjs +9 -0
  36. package/dist/{chunk-Y6VCTLCJ.js → chunk-H5NTJZO4.js} +1 -2
  37. package/dist/chunk-HT2Z33YM.cjs +111 -0
  38. package/dist/chunk-JRRTZZ72.cjs +1 -0
  39. package/dist/{chunk-T2HQYRA7.cjs → chunk-NVAQQYBJ.cjs} +1 -2
  40. package/dist/chunk-P3AEZKQO.cjs +3 -0
  41. package/dist/{chunk-GWBTKVFD.cjs → chunk-P7ZF45KZ.cjs} +1 -2
  42. package/dist/{chunk-QEBO3EQP.cjs → chunk-PCJ5ACUV.cjs} +1 -2
  43. package/dist/{chunk-Q6HUGWO6.js → chunk-PJVI53AH.js} +1 -2
  44. package/dist/chunk-Q7YYC75E.js +258 -0
  45. package/dist/{chunk-7JSPKVOW.js → chunk-QVPR2W5S.js} +1 -2
  46. package/dist/{chunk-XZNOV52K.cjs → chunk-TAF6KYDM.cjs} +4 -5
  47. package/dist/chunk-USRMBYI6.js +3 -0
  48. package/dist/chunk-UTWPV2I4.js +26 -0
  49. package/dist/{chunk-DJAEBZ33.cjs → chunk-VTAS7VZ6.cjs} +1 -2
  50. package/dist/chunk-XQNCLN4T.cjs +3 -0
  51. package/dist/{chunk-S26DZVRQ.cjs → chunk-XS2AQFMF.cjs} +1 -2
  52. package/dist/chunk-Y6QBJGMO.cjs +59 -0
  53. package/dist/{chunk-WD2HTKRR.cjs → chunk-YS7FDEZ4.cjs} +1 -2
  54. package/dist/chunk-ZTVQA46Q.js +1 -0
  55. package/dist/{clipboard-beGtyabO.d.ts → clipboard-BE8E-szx.d.ts} +1 -1
  56. package/dist/{clipboard-CqE-UZ2d.d.cts → clipboard-DkfAv07F.d.cts} +1 -1
  57. package/dist/{colorResolver-B5YbO_a4.d.ts → colorResolver-CYttioMe.d.ts} +46 -3
  58. package/dist/{colorResolver-Cu46bSKr.d.cts → colorResolver-Dr8kQZAQ.d.cts} +46 -3
  59. package/dist/core-plugins-reexport.cjs +1 -2
  60. package/dist/core-plugins-reexport.d.cts +4 -4
  61. package/dist/core-plugins-reexport.d.ts +4 -4
  62. package/dist/core-plugins-reexport.js +1 -2
  63. package/dist/core-reexport.cjs +1 -2
  64. package/dist/core-reexport.d.cts +10 -10
  65. package/dist/core-reexport.d.ts +10 -10
  66. package/dist/core-reexport.js +1 -2
  67. package/dist/executor-JGWZ7S6Z.cjs +1 -0
  68. package/dist/executor-L2MVKMXO.js +1 -0
  69. package/dist/{fontLoader-CFKpg0Ri.d.ts → fontLoader-BsqQnB4v.d.ts} +1 -1
  70. package/dist/{fontLoader-HZYfILUm.d.cts → fontLoader-DECXIoMr.d.cts} +1 -1
  71. package/dist/headless-reexport.cjs +4 -5
  72. package/dist/headless-reexport.d.cts +7 -7
  73. package/dist/headless-reexport.d.ts +7 -7
  74. package/dist/headless-reexport.js +4 -5
  75. package/dist/index.cjs +6 -7
  76. package/dist/index.css +0 -1
  77. package/dist/index.d.cts +12 -12
  78. package/dist/index.d.ts +12 -12
  79. package/dist/index.js +6 -7
  80. package/dist/lib-GD2QD2JK.js +1 -0
  81. package/dist/lib-HOLGQI5K.cjs +1 -0
  82. package/dist/mcp-reexport.cjs +9 -10
  83. package/dist/mcp-reexport.d.cts +2 -2
  84. package/dist/mcp-reexport.d.ts +2 -2
  85. package/dist/mcp-reexport.js +4 -5
  86. package/dist/{processTemplate-G37IM66O.js → processTemplate-3HN7Q3KT.js} +1 -2
  87. package/dist/processTemplate-BXZKWRQD.cjs +1 -0
  88. package/dist/{react-BjOCdeTs.d.ts → react-C6bgHDFl.d.ts} +8 -6
  89. package/dist/{react-UzAn4o7l.d.cts → react-CAlVCYa4.d.cts} +8 -6
  90. package/dist/react.cjs +1 -2
  91. package/dist/react.css +0 -1
  92. package/dist/react.d.cts +5 -5
  93. package/dist/react.d.ts +5 -5
  94. package/dist/react.js +1 -2
  95. package/dist/{registry-DjacfR6Q.d.cts → registry-BU-FbHh-.d.cts} +1 -1
  96. package/dist/{registry-CV6nYWqP.d.ts → registry-gRbkCooh.d.ts} +1 -1
  97. package/dist/selectionRects-7QU337P5.cjs +1 -0
  98. package/dist/selectionRects-V5RC2BYX.js +1 -0
  99. package/dist/styles.css +1 -1
  100. package/dist/{types-DwZ3xysp.d.ts → types-7wjInVMW.d.ts} +1 -1
  101. package/dist/{types-Bnp8rvJn.d.cts → types-DEEpBL9H.d.cts} +1 -1
  102. package/dist/ui.cjs +1 -2
  103. package/dist/ui.d.cts +32 -85
  104. package/dist/ui.d.ts +32 -85
  105. package/dist/ui.js +1 -2
  106. package/dist/{variableDetector-CMhJtM96.d.cts → variableDetector-B4oQJa2e.d.cts} +33 -2
  107. package/dist/{variableDetector-BaDeXz7D.d.ts → variableDetector-BXJaTkiB.d.ts} +33 -2
  108. package/package.json +1 -1
  109. package/dist/FindReplaceDialog-AWQXKEUQ.js.map +0 -1
  110. package/dist/FindReplaceDialog-I4SZDSVP.cjs +0 -2
  111. package/dist/FindReplaceDialog-I4SZDSVP.cjs.map +0 -1
  112. package/dist/FootnotePropertiesDialog-73VT2ZVZ.cjs.map +0 -1
  113. package/dist/FootnotePropertiesDialog-ZM3EF3EF.js.map +0 -1
  114. package/dist/HyperlinkDialog-BA25XUT5.js.map +0 -1
  115. package/dist/HyperlinkDialog-V63LPOT2.cjs +0 -2
  116. package/dist/HyperlinkDialog-V63LPOT2.cjs.map +0 -1
  117. package/dist/ImagePositionDialog-AIAMKPFK.js.map +0 -1
  118. package/dist/ImagePositionDialog-KMK7ROV2.cjs.map +0 -1
  119. package/dist/ImagePropertiesDialog-ERFCUVCW.js.map +0 -1
  120. package/dist/ImagePropertiesDialog-USMMRK6X.cjs.map +0 -1
  121. package/dist/TablePropertiesDialog-72CIUAZT.cjs.map +0 -1
  122. package/dist/TablePropertiesDialog-EMUEVYB3.js.map +0 -1
  123. package/dist/chunk-2CHPKB5A.cjs +0 -112
  124. package/dist/chunk-2CHPKB5A.cjs.map +0 -1
  125. package/dist/chunk-2QOEHCBX.js.map +0 -1
  126. package/dist/chunk-4QT5LPBA.cjs.map +0 -1
  127. package/dist/chunk-5DYSI4O4.cjs +0 -60
  128. package/dist/chunk-5DYSI4O4.cjs.map +0 -1
  129. package/dist/chunk-5FJXHXFV.cjs +0 -2
  130. package/dist/chunk-5FJXHXFV.cjs.map +0 -1
  131. package/dist/chunk-6FEWNF6B.js +0 -4
  132. package/dist/chunk-6FEWNF6B.js.map +0 -1
  133. package/dist/chunk-6LF5HZCV.js +0 -10
  134. package/dist/chunk-6LF5HZCV.js.map +0 -1
  135. package/dist/chunk-7JSPKVOW.js.map +0 -1
  136. package/dist/chunk-C33XDRDJ.cjs +0 -28
  137. package/dist/chunk-C33XDRDJ.cjs.map +0 -1
  138. package/dist/chunk-CV5WFE7K.js.map +0 -1
  139. package/dist/chunk-CXJRNISO.js +0 -2
  140. package/dist/chunk-CXJRNISO.js.map +0 -1
  141. package/dist/chunk-DJAEBZ33.cjs.map +0 -1
  142. package/dist/chunk-DP6Q75ZD.js +0 -28
  143. package/dist/chunk-DP6Q75ZD.js.map +0 -1
  144. package/dist/chunk-FDANI5P4.cjs.map +0 -1
  145. package/dist/chunk-FGVGZLBL.js.map +0 -1
  146. package/dist/chunk-GJ4GKSDU.cjs +0 -2
  147. package/dist/chunk-GJ4GKSDU.cjs.map +0 -1
  148. package/dist/chunk-GWBTKVFD.cjs.map +0 -1
  149. package/dist/chunk-JOYPFQW2.js.map +0 -1
  150. package/dist/chunk-L54YNLSE.js +0 -2
  151. package/dist/chunk-L54YNLSE.js.map +0 -1
  152. package/dist/chunk-LPGMLJMO.js +0 -259
  153. package/dist/chunk-LPGMLJMO.js.map +0 -1
  154. package/dist/chunk-M2T6XKT5.js.map +0 -1
  155. package/dist/chunk-OHG7ROFC.js +0 -11
  156. package/dist/chunk-OHG7ROFC.js.map +0 -1
  157. package/dist/chunk-PANKMCFX.cjs +0 -4
  158. package/dist/chunk-PANKMCFX.cjs.map +0 -1
  159. package/dist/chunk-Q6HUGWO6.js.map +0 -1
  160. package/dist/chunk-QDV75OJ4.js +0 -112
  161. package/dist/chunk-QDV75OJ4.js.map +0 -1
  162. package/dist/chunk-QEBO3EQP.cjs.map +0 -1
  163. package/dist/chunk-QVIZ775M.cjs +0 -259
  164. package/dist/chunk-QVIZ775M.cjs.map +0 -1
  165. package/dist/chunk-RMUMR42R.cjs +0 -10
  166. package/dist/chunk-RMUMR42R.cjs.map +0 -1
  167. package/dist/chunk-S26DZVRQ.cjs.map +0 -1
  168. package/dist/chunk-T2HQYRA7.cjs.map +0 -1
  169. package/dist/chunk-ULXNEG66.js +0 -60
  170. package/dist/chunk-ULXNEG66.js.map +0 -1
  171. package/dist/chunk-WD2HTKRR.cjs.map +0 -1
  172. package/dist/chunk-XZNOV52K.cjs.map +0 -1
  173. package/dist/chunk-Y6VCTLCJ.js.map +0 -1
  174. package/dist/core-plugins-reexport.cjs.map +0 -1
  175. package/dist/core-plugins-reexport.js.map +0 -1
  176. package/dist/core-reexport.cjs.map +0 -1
  177. package/dist/core-reexport.js.map +0 -1
  178. package/dist/executor-K5RXUTTR.js +0 -2
  179. package/dist/executor-K5RXUTTR.js.map +0 -1
  180. package/dist/executor-XIPIU3H4.cjs +0 -2
  181. package/dist/executor-XIPIU3H4.cjs.map +0 -1
  182. package/dist/headless-reexport.cjs.map +0 -1
  183. package/dist/headless-reexport.js.map +0 -1
  184. package/dist/index.cjs.map +0 -1
  185. package/dist/index.css.map +0 -1
  186. package/dist/index.js.map +0 -1
  187. package/dist/mcp-reexport.cjs.map +0 -1
  188. package/dist/mcp-reexport.js.map +0 -1
  189. package/dist/processTemplate-G37IM66O.js.map +0 -1
  190. package/dist/processTemplate-RFBGVH7T.cjs +0 -2
  191. package/dist/processTemplate-RFBGVH7T.cjs.map +0 -1
  192. package/dist/react.cjs.map +0 -1
  193. package/dist/react.css.map +0 -1
  194. package/dist/react.js.map +0 -1
  195. package/dist/selectionRects-6DU7HN7E.js +0 -2
  196. package/dist/selectionRects-6DU7HN7E.js.map +0 -1
  197. package/dist/selectionRects-YZSC24ZP.cjs +0 -2
  198. package/dist/selectionRects-YZSC24ZP.cjs.map +0 -1
  199. package/dist/ui.cjs.map +0 -1
  200. package/dist/ui.js.map +0 -1
@@ -1,259 +0,0 @@
1
- 'use strict';var chunk5FJXHXFV_cjs=require('./chunk-5FJXHXFV.cjs'),chunkPANKMCFX_cjs=require('./chunk-PANKMCFX.cjs'),chunkDJAEBZ33_cjs=require('./chunk-DJAEBZ33.cjs'),chunkS26DZVRQ_cjs=require('./chunk-S26DZVRQ.cjs'),chunkFDANI5P4_cjs=require('./chunk-FDANI5P4.cjs'),chunkRMUMR42R_cjs=require('./chunk-RMUMR42R.cjs'),chunkGJ4GKSDU_cjs=require('./chunk-GJ4GKSDU.cjs'),chunkGWBTKVFD_cjs=require('./chunk-GWBTKVFD.cjs'),chunkC33XDRDJ_cjs=require('./chunk-C33XDRDJ.cjs'),chunkQEBO3EQP_cjs=require('./chunk-QEBO3EQP.cjs'),Mu=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 Mu__default=/*#__PURE__*/_interopDefault(Mu);var dl=Mu.createContext(null);function Yb(){let e=Mu.useContext(dl);if(!e)throw new Error("useErrorNotifications must be used within an ErrorProvider");return e}function ul({children:e}){let t=Mu.useMemo(()=>new chunkFDANI5P4_cjs.H,[]),n=Mu.useSyncExternalStore(t.subscribe,t.getSnapshot),o=Mu.useCallback((u,d)=>{t.showError(u,d);},[t]),r=Mu.useCallback((u,d)=>{t.showWarning(u,d);},[t]),i=Mu.useCallback((u,d)=>{t.showInfo(u,d);},[t]),a=Mu.useCallback(u=>{t.dismiss(u);},[t]),s=Mu.useCallback(()=>{t.clearAll();},[t]),l=Mu.useMemo(()=>({notifications:n.notifications,showError:o,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:s}),[n.notifications,o,r,i,a,s]);return jsxRuntime.jsxs(dl.Provider,{value:l,children:[e,jsxRuntime.jsx(up,{notifications:n.notifications,onDismiss:a})]})}function up({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(pp,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function pp({notification:e,onDismiss:t}){let[n,o]=Mu.useState(false),i=(m=>{switch(m){case "error":return {bg:"var(--doc-error-bg)",border:"#f5c6cb",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"#ffeeba",text:"#856404",icon:"var(--doc-warning)"};case "info":return {bg:"#e8f4fd",border:"#b8daff",text:"#0c5460",icon:"var(--doc-primary)"}}})(e.severity),a={background:i.bg,border:`1px solid ${i.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",animation:"slideIn 0.3s ease-out"},s={display:"flex",alignItems:"flex-start",gap:"8px"},l={color:i.icon,flexShrink:0},u={flex:1,minWidth:0},d={color:i.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},c={marginTop:"8px",padding:"8px",background:"rgba(0, 0, 0, 0.05)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:i.text,maxHeight:"200px",overflow:"auto"},p={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:i.text},f=m=>{switch(m){case "error":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsxRuntime.jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxRuntime.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsxRuntime.jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsxRuntime.jsxs("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:a,children:[jsxRuntime.jsx("style",{children:`
2
- @keyframes slideIn {
3
- from {
4
- opacity: 0;
5
- transform: translateX(100%);
6
- }
7
- to {
8
- opacity: 1;
9
- transform: translateX(0);
10
- }
11
- }
12
- `}),jsxRuntime.jsxs("div",{style:s,children:[jsxRuntime.jsx("span",{style:l,children:f(e.severity)}),jsxRuntime.jsxs("div",{style:u,children:[jsxRuntime.jsx("div",{style:d,children:e.message}),e.details&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>o(!n),style:{...p,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:n?"Hide details":"Show details"}),n&&jsxRuntime.jsx("div",{style:c,children:e.details})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,style:p,title:"Dismiss",children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var sr=class extends Mu.Component{constructor(n){super(n);chunkQEBO3EQP_cjs.d(this,"resetError",()=>{this.setState({hasError:false,error:null,errorInfo:null});});this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(n){return {hasError:true,error:n}}componentDidCatch(n,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",n,o),this.props.onError&&this.props.onError(n,o);}render(){if(this.state.hasError){let{fallback:n,showDetails:o=true}=this.props,{error:r,errorInfo:i}=this.state;return n?typeof n=="function"?n(r,this.resetError):n:jsxRuntime.jsx(fp,{error:r,errorInfo:i,showDetails:o,onReset:this.resetError})}return this.props.children}};function fp({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 qb({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 Xb({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 Zb(e){return e.message.includes("parse")||e.message.includes("Parse")||e.message.includes("XML")||e.message.includes("DOCX")||e.message.includes("Invalid")}function Jb(e){let t=e.message.toLowerCase();return t.includes("network")||t.includes("fetch")?"Network error. Please check your internet connection and try again.":t.includes("parse")||t.includes("xml")||t.includes("invalid")?"The document could not be parsed. It may be corrupted or in an unsupported format.":t.includes("permission")||t.includes("access")?"Access denied. You may not have permission to access this file.":t.includes("not found")||t.includes("404")?"The requested file was not found.":t.includes("timeout")?"The operation timed out. Please try again.":"An unexpected error occurred. Please try again."}function fl({document:e,onChange:t,onSelectionChange:n}){let o=Mu.useMemo(()=>new chunkFDANI5P4_cjs.C,[]),[r,i]=Mu.useState({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),a=Mu.useCallback((d,c,p)=>{if(!e)return;let f=chunkFDANI5P4_cjs.z(e,d);if(!f){o.clearSelection(),i({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null});return}o.selectCell({tableIndex:d,rowIndex:c,columnIndex:p});let b=chunkPANKMCFX_cjs.T(f,{tableIndex:d,rowIndex:c,columnIndex:p});i({context:b,table:f,tableIndex:d,rowIndex:c,columnIndex:p}),n?.(b);},[e,o,n]),s=Mu.useCallback(()=>{o.clearSelection(),i({context:null,table:null,tableIndex:null,rowIndex:null,columnIndex:null}),n?.(null);},[o,n]),l=Mu.useCallback(d=>{if(!e||!r.context||r.tableIndex===null||r.rowIndex===null||r.columnIndex===null)return;let c=r.table;if(!c)return;let p=null,f=null,m=r.rowIndex,b=r.columnIndex;switch(d){case "addRowAbove":p=chunkPANKMCFX_cjs.W(c,r.rowIndex,"before"),m=r.rowIndex+1;break;case "addRowBelow":p=chunkPANKMCFX_cjs.W(c,r.rowIndex,"after");break;case "addColumnLeft":p=chunkPANKMCFX_cjs.Y(c,r.columnIndex,"before"),b=r.columnIndex+1;break;case "addColumnRight":p=chunkPANKMCFX_cjs.Y(c,r.columnIndex,"after");break;case "deleteRow":c.rows.length>1&&(p=chunkPANKMCFX_cjs.X(c,r.rowIndex),m>=p.rows.length&&(m=p.rows.length-1));break;case "deleteColumn":{if(chunkPANKMCFX_cjs.U(c)>1){p=chunkPANKMCFX_cjs.Z(c,r.columnIndex);let S=chunkPANKMCFX_cjs.U(p);b>=S&&(b=S-1);}break}case "mergeCells":r.context.selection.selectedCells&&(p=chunkPANKMCFX_cjs._(c,r.context.selection));break;case "splitCell":r.context.canSplitCell&&(p=chunkPANKMCFX_cjs.$(c,r.rowIndex,r.columnIndex));break;case "deleteTable":f=chunkFDANI5P4_cjs.B(e,r.tableIndex),s(),t?.(f);return}p&&(f=chunkFDANI5P4_cjs.A(e,r.tableIndex,p),t?.(f),f&&a(r.tableIndex,m,b));},[e,r,t,s,a]),u=Mu.useCallback((d,c,p)=>o.isCellSelected(d,c,p),[o,r]);return {state:r,handleCellClick:a,handleAction:l,clearSelection:s,isCellSelected:u,tableContext:r.context}}var gl=({headings:e,onHeadingClick:t,onClose:n,topOffset:o=0})=>{let[r,i]=Mu.useState(false);return Mu.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(chunkPANKMCFX_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}`))})]})};function bl(e){return e?.length?e.flatMap(t=>t.content.filter(n=>n.type==="run").flatMap(n=>"content"in n?n.content:[]).filter(n=>n.type==="text").map(n=>"text"in n?n.text:"")).join(""):""}function Ta(e){return e?new Date(e).toLocaleString(void 0,{hour:"numeric",minute:"2-digit",month:"short",day:"numeric"}):""}function va(e){return e.split(/\s+/).map(t=>t[0]).join("").toUpperCase().slice(0,2)}var yl=["#6DCCB1","#79AAD9","#EE789D","#A987D1","#E6A85F","#F2CC8F","#68B3A2","#B07AA1","#59A14F","#FF9DA7","#E15759","#76B7B2"];function xp(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return yl[Math.abs(t)%yl.length]}var Sp=340,kp=8,dr={background:"none",border:"none",cursor:"pointer",padding:4,color:"#5f6368",display:"flex",borderRadius:"50%"},xl={padding:"6px 16px",fontSize:14,border:"none",background:"none",color:"#1a73e8",cursor:"pointer",fontWeight:500,fontFamily:"inherit"},Sl=({comments:e,trackedChanges:t,onCommentClick:n,onCommentReply:o,onCommentResolve:r,onCommentDelete:i,onAddComment:a,onCancelAddComment:s,onAcceptChange:l,onRejectChange:u,onTrackedChangeReply:d,topOffset:c=0,showResolved:p=false,isAddingComment:f=false,addCommentYPosition:m=null,pageWidth:b=816,editorContainerRef:g})=>{let[S,w]=Mu.useState(null),[k,E]=Mu.useState(""),[R,_]=Mu.useState(""),[V,$]=Mu.useState(null),[L,W]=Mu.useState(null),[O,K]=Mu.useState(new Map),[C,B]=Mu.useState(false),ee=Mu.useRef(new Set),ge=Mu.useRef(null),pe=Mu.useRef(new Map),Ee=Mu.useMemo(()=>e.filter(v=>!(v.parentId!=null||v.done&&!p)),[e,p]),Te=Mu.useMemo(()=>{let v=new Map;for(let z of e)if(z.parentId!=null){let A=v.get(z.parentId);A?A.push(z):v.set(z.parentId,[z]);}return v},[e]),Re=v=>Te.get(v)??[],P=Mu.useCallback(()=>{let v=g?.current;if(!v)return;let z=v.querySelector(".paged-editor__pages");if(!z)return;let A=v.getBoundingClientRect(),te=v.scrollTop,de=[];for(let me of Ee){let Se=z.querySelector(`[data-comment-id="${me.id}"]`);if(Se){let ue=Se.getBoundingClientRect();de.push({id:`comment-${me.id}`,targetY:ue.top-A.top+te,height:pe.current.get(`comment-${me.id}`)?.offsetHeight||80});}}t.forEach((me,Se)=>{let ue=`tc-${me.revisionId}-${Se}`,ze=z.querySelector(`[data-revision-id="${me.revisionId}"]`);if(ze){let tt=ze.getBoundingClientRect();de.push({id:ue,targetY:tt.top-A.top+te,height:pe.current.get(ue)?.offsetHeight||80});}}),f&&m!=null&&de.push({id:"new-comment-input",targetY:m,height:pe.current.get("new-comment-input")?.offsetHeight||120}),de.sort((me,Se)=>me.targetY-Se.targetY);let he=new Map,Be=0;for(let me of de){let Se=Math.max(me.targetY,Be+kp);he.set(me.id,Se),Be=Se+me.height;}K(he);},[Ee,t,g,f,m]);Mu.useEffect(()=>{let v=g?.current;if(!v)return;let z=v.querySelector(".paged-editor__pages");if(!z)return;let A=te=>{let de=te.target;if(!ge.current?.contains(de)){if(z.contains(de)){let he=de.closest("[data-comment-id]");if(he?.dataset.commentId){$(`comment-${he.dataset.commentId}`),n?.(Number(he.dataset.commentId));return}let Be=de.closest(".docx-insertion")||de.closest(".docx-deletion");if(Be?.dataset.revisionId){let me=Number(Be.dataset.revisionId),Se=t.findIndex(ue=>ue.revisionId===me);if(Se>=0){$(`tc-${t[Se].revisionId}-${Se}`);return}}}$(null),W(null);}};return v.addEventListener("click",A),()=>v.removeEventListener("click",A)},[g,t,n]),Mu.useEffect(()=>{let v=g?.current;if(!v)return;let z=setTimeout(P,50),A=setTimeout(()=>{P(),B(true);},400),te=new ResizeObserver(()=>{requestAnimationFrame(P);});return te.observe(v),()=>{clearTimeout(z),clearTimeout(A),te.disconnect();}},[P,g]),Mu.useEffect(()=>{let v=requestAnimationFrame(P);return ()=>cancelAnimationFrame(v)},[V,f,P]),Mu.useEffect(()=>{let v=[];if(V){let de=pe.current.get(V);de&&v.push(de);}let z=pe.current.get("new-comment-input");if(z&&v.push(z),v.length===0)return;let A,te=new ResizeObserver(()=>{cancelAnimationFrame(A),A=requestAnimationFrame(P);});for(let de of v)te.observe(de);return ()=>{cancelAnimationFrame(A),te.disconnect();}},[V,P]);let I=()=>{R.trim()&&(a?.(R.trim()),_(""));},y=(v,z)=>{$(V===v?null:v),W(null),z!==void 0&&n?.(z);},M=O.size>0,F=(v,z=32)=>({width:z,height:z,borderRadius:"50%",backgroundColor:xp(v),color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:z===32?13:11,fontWeight:500,flexShrink:0}),D=v=>({padding:"6px 16px",fontSize:14,border:"none",borderRadius:20,background:v?"#1a73e8":"#f1f3f4",color:v?"#fff":"#80868b",cursor:v?"pointer":"default",fontWeight:500,fontFamily:"inherit"}),j=(v,z,A)=>{let te=ee.current.has(v);return A!==void 0&&ee.current.add(v),{...M?A!==void 0?{position:"absolute",top:A,left:0,right:0,opacity:1}:{position:"absolute",top:0,left:0,right:0,opacity:0,visibility:"hidden"}:{marginBottom:6},padding:z?"10px 12px":"8px 10px",borderRadius:8,backgroundColor:z?"#fff":"#f8fbff",cursor:"pointer",boxShadow:z?"0 1px 3px rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15)":"0 1px 3px rgba(60,64,67,0.2), 0 2px 6px rgba(60,64,67,0.08)",transition:M&&A===void 0?"none":!te&&A!==void 0?"opacity 0.2s ease, box-shadow 0.2s ease":C?"opacity 0.2s ease, box-shadow 0.2s ease, top 0.15s ease":"none"}},J=(v,z)=>v.length===0?null:jsxRuntime.jsxs("div",{style:{marginTop:8},children:[(z?v:v.slice(-1)).map(A=>jsxRuntime.jsxs("div",{style:{marginBottom:z?8:0,paddingTop:8,borderTop:"1px solid #e8eaed"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:F(A.author||"U",28),children:va(A.author||"U")}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:A.author||"Unknown"}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Ta(A.date)})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:4,...z?{}:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"}},children:bl(A.content)})]},A.id)),!z&&v.length>1&&jsxRuntime.jsxs("div",{style:{fontSize:12,color:"#5f6368",marginTop:4},children:[v.length-1," more ",v.length-1===1?"reply":"replies"]})]}),N=(v,z)=>jsxRuntime.jsx("div",{onClick:A=>A.stopPropagation(),style:{marginTop:12},children:S===v?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("input",{ref:A=>A?.focus({preventScroll:true}),type:"text",value:k,onChange:A=>E(A.target.value),onMouseDown:A=>A.stopPropagation(),onKeyDown:A=>{A.stopPropagation(),A.key==="Enter"&&(A.preventDefault(),k.trim()&&z&&z(v,k.trim()),E(""),w(null)),A.key==="Escape"&&(w(null),E(""));},placeholder:"Reply or add others with @",style:{width:"100%",border:"1px solid #1a73e8",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",boxSizing:"border-box",color:"#202124"}}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsxRuntime.jsx("button",{onClick:A=>{A.stopPropagation(),w(null),E("");},style:xl,children:"Cancel"}),jsxRuntime.jsx("button",{onClick:A=>{A.stopPropagation(),k.trim()&&z&&z(v,k.trim()),E(""),w(null);},disabled:!k.trim(),style:D(!!k.trim()),children:"Reply"})]})]}):jsxRuntime.jsx("input",{readOnly:true,onMouseDown:A=>A.stopPropagation(),onClick:A=>{A.stopPropagation(),w(v);},placeholder:"Reply or add others with @",style:{width:"100%",border:"1px solid #dadce0",borderRadius:20,outline:"none",fontSize:14,padding:"8px 16px",fontFamily:"inherit",color:"#80868b",cursor:"text",backgroundColor:"#fff",boxSizing:"border-box"}})}),U=v=>{let z=Re(v.id),A=`comment-${v.id}`,te=V===A,de=O.get(A);return jsxRuntime.jsxs("div",{ref:he=>{he?pe.current.set(A,he):pe.current.delete(A);},"data-comment-id":v.id,className:"docx-comment-card",onClick:()=>y(A,v.id),onMouseDown:he=>he.stopPropagation(),style:{...j(A,te,de),opacity:M&&de===void 0?0:v.done?.6:1},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:F(v.author||"U"),children:va(v.author||"U")}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:v.author||"Unknown"}),jsxRuntime.jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Ta(v.date)})]}),te&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:4,marginTop:2,position:"relative"},children:[jsxRuntime.jsx("button",{onClick:he=>{he.stopPropagation(),r?.(v.id);},title:"Resolve",style:dr,children:jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:"check",size:20})}),jsxRuntime.jsx("button",{onClick:he=>{he.stopPropagation(),W(L===A?null:A);},title:"More options",style:dr,children:jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:"more_vert",size:20})}),L===A&&jsxRuntime.jsx("div",{onClick:he=>he.stopPropagation(),onMouseDown:he=>he.stopPropagation(),style:{position:"absolute",top:32,right:0,background:"#fff",borderRadius:8,boxShadow:"0 2px 6px rgba(60,64,67,0.3), 0 1px 2px rgba(60,64,67,0.15)",zIndex:100,minWidth:120,padding:"4px 0"},children:jsxRuntime.jsx("button",{onClick:()=>{W(null),i?.(v.id);},style:{display:"block",width:"100%",padding:"8px 16px",border:"none",background:"none",textAlign:"left",fontSize:14,color:"#202124",cursor:"pointer",fontFamily:"inherit"},onMouseOver:he=>{he.target.style.backgroundColor="#f1f3f4";},onMouseOut:he=>{he.target.style.backgroundColor="transparent";},children:"Delete"})})]})]}),jsxRuntime.jsx("div",{style:{fontSize:13,color:"#202124",lineHeight:"20px",marginTop:6},children:bl(v.content)}),J(z,te),te&&!v.done&&N(v.id,o)]},v.id)},G=v=>Te.get(v)??[],xe=(v,z)=>{let A=v.author||"Unknown",te=`tc-${v.revisionId}-${z}`,de=V===te,he=O.get(te),Be=G(v.revisionId);return jsxRuntime.jsxs("div",{ref:me=>{me?pe.current.set(te,me):pe.current.delete(te);},className:"docx-tracked-change-card",onClick:()=>y(te),onMouseDown:me=>me.stopPropagation(),style:j(te,de,he),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[jsxRuntime.jsx("div",{style:F(A),children:va(A)}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:{fontSize:13,fontWeight:600,color:"#202124"},children:A}),v.date&&jsxRuntime.jsx("div",{style:{fontSize:11,color:"#5f6368"},children:Ta(v.date)})]}),de&&jsxRuntime.jsxs("div",{style:{display:"flex",gap:4,marginTop:2},children:[jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),l?.(v.from,v.to);},title:"Accept",style:dr,children:jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:"check",size:20})}),jsxRuntime.jsx("button",{onClick:me=>{me.stopPropagation(),u?.(v.from,v.to);},title:"Reject",style:dr,children:jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:"close",size:20})})]})]}),jsxRuntime.jsxs("div",{style:{fontSize:13,lineHeight:"20px",color:"#202124",marginTop:6},children:[v.type==="insertion"?"Added":"Deleted"," ",jsxRuntime.jsxs("span",{style:{color:v.type==="insertion"?"#137333":"#c5221f",fontWeight:500},children:['"',v.text.length>50?v.text.slice(0,50)+"...":v.text,'"']})]}),J(Be,de),de&&N(v.revisionId,d)]},te)};return jsxRuntime.jsx("aside",{ref:ge,className:"docx-comments-sidebar",role:"complementary","aria-label":"Comments and changes",style:{position:"absolute",top:c,left:`calc(50% - 120px + ${b/2+12}px)`,bottom:0,width:Sp,fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,backgroundColor:"transparent",overflowY:M?"visible":"auto",overflowX:"visible",opacity:M?1:0,transition:"opacity 0.15s ease"},onMouseDown:v=>v.stopPropagation(),children:jsxRuntime.jsxs("div",{style:{position:"relative"},children:[f&&jsxRuntime.jsxs("div",{ref:v=>{v?pe.current.set("new-comment-input",v):pe.current.delete("new-comment-input");},style:{...M?O.get("new-comment-input")!==void 0?{position:"absolute",top:O.get("new-comment-input"),left:0,right:0}:{position:"absolute",top:0,left:0,right:0,visibility:"hidden"}:{marginBottom:8},padding:12,borderRadius:8,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15)",zIndex:50},children:[jsxRuntime.jsx("textarea",{ref:v=>v?.focus({preventScroll:true}),value:R,onChange:v=>_(v.target.value),onMouseDown:v=>v.stopPropagation(),onKeyDown:v=>{v.stopPropagation(),v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),I()),v.key==="Escape"&&(s?.(),_(""));},placeholder:"Add a comment...",style:{width:"100%",border:"1px solid #1a73e8",borderRadius:20,outline:"none",resize:"none",fontSize:14,lineHeight:"20px",padding:"8px 16px",fontFamily:"inherit",minHeight:40,boxSizing:"border-box",color:"#202124"}}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:8},children:[jsxRuntime.jsx("button",{onClick:()=>{s?.(),_("");},style:xl,children:"Cancel"}),jsxRuntime.jsx("button",{onClick:I,disabled:!R.trim(),style:D(!!R.trim()),children:"Comment"})]})]}),Ee.map(v=>U(v)),t.map((v,z)=>xe(v,z)),Ee.length===0&&t.length===0&&!f&&jsxRuntime.jsx("div",{style:{padding:"24px 16px",textAlign:"center",color:"#80868b",fontSize:13},children:"No comments or changes yet."})]})})};var Tp=15840,wl=1440,vp=1440,Rp=567,Tl=20,Pp="var(--doc-text-muted)",Mp="var(--doc-text-subtle)",Ep="var(--doc-primary)",Ip="var(--doc-primary)",Fp="var(--doc-primary-hover)";function vl({sectionProps:e,zoom:t=1,editable:n=false,onTopMarginChange:o,onBottomMarginChange:r,unit:i="inch",className:a="",style:s}){let[l,u]=Mu.useState(null),[d,c]=Mu.useState(null),p=Mu.useRef(null),f=e?.pageHeight??Tp,m=e?.marginTop??wl,b=e?.marginBottom??wl,g=chunkGJ4GKSDU_cjs.n(f)*t,S=chunkGJ4GKSDU_cjs.n(m)*t,w=chunkGJ4GKSDU_cjs.n(b)*t,k=Mu.useCallback(($,L)=>{n&&($.preventDefault(),u(L));},[n]),E=Mu.useCallback($=>{if(!l||!p.current)return;let L=p.current.getBoundingClientRect(),W=$.clientY-L.top,O=chunkGJ4GKSDU_cjs.o(W/t);if(l==="topMargin"){let K=f-b-720,C=Math.max(0,Math.min(O,K));o?.(Math.round(C));}else if(l==="bottomMargin"){let K=f-O,C=f-m-720,B=Math.max(0,Math.min(K,C));r?.(Math.round(B));}},[l,t,f,m,b,o,r]),R=Mu.useCallback(()=>{u(null);},[]);Mu.useEffect(()=>{if(l)return document.addEventListener("mousemove",E),document.addEventListener("mouseup",R),()=>{document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",R);}},[l,E,R]);let _=Bp(f,t,i),V={position:"relative",width:Tl,height:chunkGJ4GKSDU_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:V,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:_.map(($,L)=>jsxRuntime.jsx(Lp,{tick:$},L))}),jsxRuntime.jsx(Cl,{type:"topMargin",position:S,editable:n,isDragging:l==="topMargin",isHovered:d==="topMargin",onMouseEnter:()=>c("topMargin"),onMouseLeave:()=>c(null),onMouseDown:$=>k($,"topMargin")}),jsxRuntime.jsx(Cl,{type:"bottomMargin",position:g-w,editable:n,isDragging:l==="bottomMargin",isHovered:d==="bottomMargin",onMouseEnter:()=>c("bottomMargin"),onMouseLeave:()=>c(null),onMouseDown:$=>k($,"bottomMargin")})]})}function Lp({tick:e}){let t={position:"absolute",top:chunkGJ4GKSDU_cjs.x(e.position),right:0,height:1,width:e.width,backgroundColor:Mp},n={position:"absolute",top:chunkGJ4GKSDU_cjs.x(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:Pp,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 Cl({type:e,position:t,editable:n,isDragging:o,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:s}){let l=o?Fp:r?Ip:Ep,u={position:"absolute",top:chunkGJ4GKSDU_cjs.x(t-5),right:0,width:Tl,height:10,cursor:n?"ns-resize":"default",zIndex:o?10:1},d={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${l}`,transition:"border-right-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:u,onMouseEnter:i,onMouseLeave:a,onMouseDown:s,role:"slider","aria-label":e==="topMargin"?"Top margin":"Bottom margin","aria-orientation":"vertical",tabIndex:n?0:-1,children:jsxRuntime.jsx("div",{style:d})})}function Bp(e,t,n){let o=[];if(n==="inch"){let r=vp/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=chunkGJ4GKSDU_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=Rp/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let s=a*r;if(s>e)break;let l=chunkGJ4GKSDU_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 yn={High:50,Default:100,Low:150};function Rt(e){return t=>{let n={...e.defaultOptions,...t};return {type:"extension",config:{name:e.name,priority:e.priority??yn.Default,options:n},onSchemaReady(o){return e.onSchemaReady(o,n)}}}}function Ve(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??yn.Default,options:n,schemaNodeName:e.schemaNodeName,nodeSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}function Le(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??yn.Default,options:n,schemaMarkName:e.schemaMarkName,markSpec:o},onSchemaReady(r){return e.onSchemaReady?.(r,n)??{}}}}}var Pl=Ve({name:"doc",schemaNodeName:"doc",nodeSpec:{content:"(paragraph | horizontalRule | pageBreak | table)+"}});var Ml=Ve({name:"text",schemaNodeName:"text",nodeSpec:{group:"inline"}});function El(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=chunk5FJXHXFV_cjs.a(a);n.fontFamily=s.cssFallback;}}if(e.fontSize!==void 0&&(n.fontSize=`${chunkGJ4GKSDU_cjs.v(e.fontSize)}pt`),e.bold&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic"),e.color&&(n.color=chunkGJ4GKSDU_cjs.a(e.color,t)),e.highlight&&e.highlight!=="none"){let a=chunkGJ4GKSDU_cjs.b(e.highlight);a&&(n.backgroundColor=a);}if(e.shading){let a=Fl(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=Dp(e.underline.style);a!=="solid"&&r.push(a),e.underline.color&&i.push(chunkGJ4GKSDU_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=chunkGJ4GKSDU_cjs.u(e.position);n.position="relative",n.top=chunkGJ4GKSDU_cjs.x(-a);}return e.allCaps?n.textTransform="uppercase":e.smallCaps&&(n.fontVariant="small-caps"),e.spacing!==void 0&&e.spacing!==0&&(n.letterSpacing=chunkGJ4GKSDU_cjs.x(chunkGJ4GKSDU_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 Il(e,t){if(!e)return {};let n={};if(e.alignment&&(n.textAlign=Hp(e.alignment)),e.spaceBefore!==void 0&&(n.marginTop=chunkGJ4GKSDU_cjs.x(chunkGJ4GKSDU_cjs.n(e.spaceBefore))),e.spaceAfter!==void 0&&(n.marginBottom=chunkGJ4GKSDU_cjs.x(chunkGJ4GKSDU_cjs.n(e.spaceAfter))),e.lineSpacing!==void 0&&e.lineSpacing>0)switch(e.lineSpacingRule){case "exact":{let o=chunkGJ4GKSDU_cjs.n(e.lineSpacing);o>0&&(n.lineHeight=chunkGJ4GKSDU_cjs.x(o));break}case "atLeast":{let o=chunkGJ4GKSDU_cjs.n(e.lineSpacing);o>0&&(n.minHeight=chunkGJ4GKSDU_cjs.x(o),n.lineHeight=chunkGJ4GKSDU_cjs.x(o));break}default:{let o=e.lineSpacing/240;o>0&&(n.lineHeight=o.toString());break}}if(e.indentLeft!==void 0&&(n.marginLeft=chunkGJ4GKSDU_cjs.x(chunkGJ4GKSDU_cjs.n(e.indentLeft))),e.indentRight!==void 0&&(n.marginRight=chunkGJ4GKSDU_cjs.x(chunkGJ4GKSDU_cjs.n(e.indentRight))),e.indentFirstLine!==void 0&&(e.hangingIndent?n.textIndent=chunkGJ4GKSDU_cjs.x(chunkGJ4GKSDU_cjs.n(e.indentFirstLine)):n.textIndent=chunkGJ4GKSDU_cjs.x(chunkGJ4GKSDU_cjs.n(e.indentFirstLine))),e.borders&&(e.borders.top&&Object.assign(n,eo(e.borders.top,"Top",t)),e.borders.bottom&&Object.assign(n,eo(e.borders.bottom,"Bottom",t)),e.borders.left&&Object.assign(n,eo(e.borders.left,"Left",t)),e.borders.right&&Object.assign(n,eo(e.borders.right,"Right",t))),e.shading){let o=Fl(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 eo(e,t="",n){if(!e||e.style==="none"||e.style==="nil")return {};let o={},r=e.size?chunkGJ4GKSDU_cjs.w(e.size):1,i=e.color?chunkGJ4GKSDU_cjs.a(e.color,n):"#000000",a=Np(e.style),s=`border${t}Width`,l=`border${t}Style`,u=`border${t}Color`;return o[s]=chunkGJ4GKSDU_cjs.x(Math.max(1,r)),o[l]=a,o[u]=i,o}function Fl(e,t){return !e||e.pattern==="clear"||e.pattern==="nil"?"":e.fill?e.fill.auto||e.fill.rgb==="auto"||e.fill.rgb==="FFFFFF"?"":chunkGJ4GKSDU_cjs.c(e.fill,t):e.pattern==="solid"&&e.color?chunkGJ4GKSDU_cjs.c(e.color,t):e.pattern&&e.pattern.startsWith("pct")&&e.color?chunkGJ4GKSDU_cjs.c(e.color,t):""}function Dp(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 Hp(e){switch(e){case "center":return "center";case "right":return "right";case "both":case "distribute":return "justify";default:return "left"}}function Np(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 to(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 Op(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=Il(n);return Object.entries(o).map(([r,i])=>`${r.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${i}`).join("; ")}function $p(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 Wp(e,t,n){if(!e?.numId)return "";let o=e.ilvl??0;return t?`docx-list-bullet docx-list-level-${o}`:`docx-list-numbered ${$p(n)} docx-list-level-${o}`}var _p={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=Op(t),o=Wp(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 jt(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 Ll(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 Ro(e){return (t,n)=>jt("alignment",e)(t,n)}function ur(e,t="auto"){return (n,o)=>Ll({lineSpacing:e,lineSpacingRule:t})(n,o)}function Vp(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 jp(e=720){return (t,n)=>{let{$from:o,$to:r}=t.selection;if(!n)return true;let i=t.tr,a=new Set;return t.doc.nodesBetween(o.pos,r.pos,(s,l)=>{if(s.type.name==="paragraph"&&!a.has(l)){a.add(l);let u=s.attrs.indentLeft||0,d=Math.max(0,u-e);i=i.setNodeMarkup(l,void 0,{...s.attrs,indentLeft:d>0?d:null});}}),n(i.scrollIntoView()),true}}function Up(e){return (t,n)=>(o,r)=>{let{$from:i,$to:a}=o.selection;if(!r)return true;let s=o.tr,l=new Set,u=[];if(n?.runFormatting){let c=n.runFormatting;c.bold&&u.push(e.marks.bold.create()),c.italic&&u.push(e.marks.italic.create()),c.fontSize&&u.push(e.marks.fontSize.create({size:c.fontSize})),c.fontFamily&&u.push(e.marks.fontFamily.create({ascii:c.fontFamily.ascii,hAnsi:c.fontFamily.hAnsi,asciiTheme:c.fontFamily.asciiTheme})),c.color&&!c.color.auto&&u.push(e.marks.textColor.create({rgb:c.color.rgb,themeColor:c.color.themeColor,themeTint:c.color.themeTint,themeShade:c.color.themeShade})),c.underline&&c.underline.style!=="none"&&u.push(e.marks.underline.create({style:c.underline.style,color:c.underline.color})),(c.strike||c.doubleStrike)&&u.push(e.marks.strike.create({double:c.doubleStrike||false}));}let d=[e.marks.bold,e.marks.italic,e.marks.fontSize,e.marks.fontFamily,e.marks.textColor,e.marks.underline,e.marks.strike].filter(Boolean);return o.doc.nodesBetween(i.pos,a.pos,(c,p)=>{if(c.type.name==="paragraph"&&!l.has(p)){l.add(p);let f={...c.attrs,styleId:t};if(n?.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+c.nodeSize-1;if(b>m){for(let g of d)s=s.removeMark(m,b,g);for(let g of u)s=s.addMark(m,b,g);}}}}),u.length>0&&(s=s.setStoredMarks(u)),r(s.scrollIntoView()),true}}var Bl=Ve({name:"paragraph",schemaNodeName:"paragraph",nodeSpec:_p,onSchemaReady(e){let t=Up(e.schema);return {commands:{setAlignment:n=>Ro(n),alignLeft:()=>Ro("left"),alignCenter:()=>Ro("center"),alignRight:()=>Ro("right"),alignJustify:()=>Ro("both"),setLineSpacing:(n,o)=>ur(n,o),singleSpacing:()=>ur(240),oneAndHalfSpacing:()=>ur(360),doubleSpacing:()=>ur(480),setSpaceBefore:n=>jt("spaceBefore",n),setSpaceAfter:n=>jt("spaceAfter",n),increaseIndent:n=>Vp(n),decreaseIndent:n=>jp(n),setIndentLeft:n=>jt("indentLeft",n>0?n:null),setIndentRight:n=>jt("indentRight",n>0?n:null),setIndentFirstLine:(n,o)=>Ll({indentFirstLine:n>0?n:null,hangingIndent:o??false}),applyStyle:(n,o)=>t(n,o),clearStyle:()=>jt("styleId",null),insertSectionBreak:n=>jt("sectionBreakType",n),removeSectionBreak:()=>jt("sectionBreakType",null),generateTOC:()=>(n,o)=>{let r=to(n.doc);if(r.length===0)return false;if(!o)return true;let{schema:i}=n,a=n.tr,s=[];for(let d of r){let c=`_Toc${Math.floor(1e8+Math.random()*9e8)}`;s.push({name:c,level:d.level,text:d.text});let p=a.mapping.map(d.pmPos),m=a.doc.resolve(p).nodeAfter;if(m&&m.type.name==="paragraph"){let S=[...(m.attrs.bookmarks||[]).filter(w=>!w.name.startsWith("_Toc")),{id:Math.floor(Math.random()*2147483647),name:c}];a.setNodeMarkup(p,void 0,{...m.attrs,bookmarks:S});}}let l=[];l.push(i.node("paragraph",{styleId:"TOCHeading",alignment:"center"},[i.text("Table of Contents",[i.marks.bold.create()])]));for(let d of s){let c=d.level*720,p=`TOC${d.level+1}`,f=i.marks.hyperlink.create({href:`#${d.name}`});l.push(i.node("paragraph",{styleId:p,indentLeft:c>0?c:null},[i.text(d.text,[f])]));}let u=a.mapping.map(n.selection.from);return a.insert(u,prosemirrorModel.Fragment.from(l)),o(a.scrollIntoView()),true},setTabs:n=>jt("tabs",n.length>0?n:null),addTabStop:(n,o="left",r="none")=>(i,a)=>{let{$from:s}=i.selection,l=s.parent;if(l.type.name!=="paragraph")return false;let c=[...(l.attrs.tabs||[]).filter(p=>p.position!==n),{position:n,alignment:o,leader:r}].sort((p,f)=>p.position-f.position);return jt("tabs",c)(i,a)},removeTabStop:n=>(o,r)=>{let{$from:i}=o.selection,a=i.parent;if(a.type.name!=="paragraph")return false;let l=(a.attrs.tabs||[]).filter(u=>u.position!==n);return jt("tabs",l.length>0?l:null)(o,r)}}}}});var Dl=Rt({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 Nl=Le({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 Ol=Le({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 Kp(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 $l(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=Kp(r);return t.setNodeMarkup(n.before(),void 0,{...o.attrs,defaultTextFormatting:i})}function en(e,t){return (n,o)=>{let{from:r,to:i,empty:a}=n.selection,s=e.create(t);if(a){if(o){let l=e.isInSet(n.storedMarks||n.selection.$from.marks())?(n.storedMarks||n.selection.$from.marks()).filter(d=>d.type!==e):n.storedMarks||n.selection.$from.marks(),u=n.tr.setStoredMarks([...l,s]);u=$l(n,u),o(u);}return true}return o&&o(n.tr.addMark(r,i,s).scrollIntoView()),true}}function tn(e){return (t,n)=>{let{from:o,to:r,empty:i}=t.selection;if(i){if(n){let a=(t.storedMarks||t.selection.$from.marks()).filter(l=>l.type!==e),s=t.tr.setStoredMarks(a);s=$l(t,s),n(s);}return true}return n&&n(t.tr.removeMark(o,r,e).scrollIntoView()),true}}function Ma(e,t){let n=[];return e.bold&&n.push(t.marks.bold.create()),e.italic&&n.push(t.marks.italic.create()),e.underline&&n.push(t.marks.underline.create({style:e.underline.style||"single",color:e.underline.color})),e.strike&&n.push(t.marks.strike.create()),e.doubleStrike&&n.push(t.marks.strike.create({double:true})),e.color&&n.push(t.marks.textColor.create({rgb:e.color.rgb,themeColor:e.color.themeColor,themeTint:e.color.themeTint,themeShade:e.color.themeShade})),e.highlight&&n.push(t.marks.highlight.create({color:e.highlight})),e.fontSize&&n.push(t.marks.fontSize.create({size:e.fontSize})),e.fontFamily&&n.push(t.marks.fontFamily.create({ascii:e.fontFamily.ascii,hAnsi:e.fontFamily.hAnsi,asciiTheme:e.fontFamily.asciiTheme})),e.vertAlign==="superscript"&&n.push(t.marks.superscript.create()),e.vertAlign==="subscript"&&n.push(t.marks.subscript.create()),n}var Po=(e,t)=>{let{from:n,to:o,empty:r}=e.selection;if(r)return t&&t(e.tr.setStoredMarks([])),true;if(t){let i=e.tr;e.doc.nodesBetween(n,o,(a,s)=>{if(a.isText&&a.marks.length>0){let l=Math.max(n,s),u=Math.min(o,s+a.nodeSize);for(let d of a.marks)i=i.removeMark(l,u,d.type);}}),t(i.scrollIntoView());}return true};var _l=Le({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)=>en(e.schema.marks.underline,{style:t,color:n})},keyboardShortcuts:{"Mod-u":prosemirrorCommands.toggleMark(e.schema.marks.underline)}}}});var Vl=Le({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 jl=Le({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=El({color:t});return ["span",{style:n.color?`color: ${n.color}`:""},0]}},onSchemaReady(e){return {commands:{setTextColor:t=>!t.rgb&&!t.themeColor?tn(e.schema.marks.textColor):en(e.schema.marks.textColor,t),clearTextColor:()=>tn(e.schema.marks.textColor)}}}});var Ul=Le({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: ${chunkGJ4GKSDU_cjs.b(t)||(t.startsWith("#")?t:`#${t}`)}`},0]}},onSchemaReady(e){return {commands:{setHighlight:t=>!t||t==="none"?tn(e.schema.marks.highlight):en(e.schema.marks.highlight,{color:t}),clearHighlight:()=>tn(e.schema.marks.highlight)}}}});var Gl=Le({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=>en(e.schema.marks.fontSize,{size:t}),clearFontSize:()=>tn(e.schema.marks.fontSize)}}}});var Kl=Le({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=>en(e.schema.marks.fontFamily,{ascii:t,hAnsi:t}),clearFontFamily:()=>tn(e.schema.marks.fontFamily)}}}});var Yl=Le({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 ql=Le({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 no(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 oo(e){let{from:t,to:n,empty:o}=e.selection;return o?"":e.doc.textBetween(t,n,"")}var Xl=Le({name:"hyperlink",schemaMarkName:"hyperlink",markSpec:{attrs:{href:{},tooltip:{default:null},rId:{default:null}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs:e=>{let t=e;return {href:t.getAttribute("href")||"",tooltip:t.getAttribute("title")||void 0}}}],toDOM(e){let t=e.attrs,n={href:t.href,target:"_blank",rel:"noopener noreferrer"};return t.tooltip&&(n.title=t.tooltip),["a",n,0]}},onSchemaReady(e){let t=e.schema.marks.hyperlink,n=(i,a)=>(s,l)=>{let{from:u,to:d,empty:c}=s.selection;if(c)return false;if(l){let p=t.create({href:i,tooltip:a||null});l(s.tr.addMark(u,d,p).scrollIntoView());}return true},o=(i,a)=>{let{from:s,to:l,empty:u}=i.selection;if(u){let d=i.selection.$from;if(!d.marks().find(g=>g.type===t))return false;let f=d.pos,m=d.pos;return d.parent.forEach((g,S)=>{if(g.isText){let w=d.start()+S,k=w+g.nodeSize;w<=d.pos&&d.pos<=k&&g.marks.some(R=>R.type===t)&&(f=Math.min(f,w),m=Math.max(m,k));}}),a&&a(i.tr.removeMark(f,m,t).scrollIntoView()),true}return a&&a(i.tr.removeMark(s,l,t).scrollIntoView()),true};return {commands:{setHyperlink:n,removeHyperlink:()=>o,insertHyperlink:(i,a,s)=>(l,u)=>{if(u){let d=t.create({href:a,tooltip:s||null}),c=l.schema.text(i,[d]);u(l.tr.replaceSelectionWith(c,false).scrollIntoView());}return true}}}}});var Zl=Le({name:"allCaps",schemaMarkName:"allCaps",markSpec:{parseDOM:[{style:"text-transform",getAttrs:e=>e==="uppercase"?{}:false}],toDOM(){return ["span",{style:"text-transform: uppercase"},0]}}});var Jl=Le({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 Ql=Le({name:"footnoteRef",schemaMarkName:"footnoteRef",markSpec:{attrs:{id:{},noteType:{default:"footnote"}},parseDOM:[{tag:"sup.docx-footnote-ref",getAttrs:e=>{let t=e;return {id:t.dataset.id||"",noteType:t.dataset.noteType||"footnote"}}}],toDOM(e){let t=e.attrs;return ["sup",{class:`docx-${t.noteType}-ref`,"data-id":t.id,"data-note-type":t.noteType},0]}},onSchemaReady(e){let{schema:t}=e;function n(r){return i=>(a,s)=>{if(!s)return true;let l=t.marks.footnoteRef.create({id:String(i),noteType:r}),u=t.text(String(i),[l]),d=a.tr.replaceSelectionWith(u,false);return s(d.scrollIntoView()),true}}let o=(r,i)=>{let{$from:a,$to:s}=r.selection;if(!i)return true;let l=r.tr,u=t.marks.footnoteRef;return l=l.removeMark(a.pos,s.pos,u),i(l.scrollIntoView()),true};return {commands:{insertFootnote:n("footnote"),insertEndnote:n("endnote"),deleteNoteRef:()=>o}}}});function Zp(e){return e/2*(96/72)}var ec=Le({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: ${chunkGJ4GKSDU_cjs.x(chunkGJ4GKSDU_cjs.n(t.spacing))}`),o["data-spacing"]=String(t.spacing)),t.position!=null&&t.position!==0){let r=Zp(t.position);n.push(`vertical-align: ${chunkGJ4GKSDU_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 tc=Le({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 nc=Le({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]}}}),oc=Le({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 rc=Le({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]}}}),ic=Le({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]}}}),ac=Le({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]}}}),sc=Le({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]}}}),lc=Le({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 cc=Ve({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 dc=Ve({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 uc=Ve({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 pc=Ve({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 Jp(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 Qp(e,t){let n="";try{n=JSON.parse(t.gradientStops||"[]").map(c=>`<stop offset="${Math.round(c.position/1e3)}%" stop-color="${c.color}" />`).join("");}catch{return ""}let o=t.gradientType||"linear";if(o==="radial"||o==="rectangular"||o==="path")return `<radialGradient id="${e}" cx="50%" cy="50%" r="50%">${n}</radialGradient>`;let i=((t.gradientAngle||0)-90)*Math.PI/180,a=Math.round(50+50*Math.cos(i+Math.PI)),s=Math.round(50+50*Math.sin(i+Math.PI)),l=Math.round(50+50*Math.cos(i)),u=Math.round(50+50*Math.sin(i));return `<linearGradient id="${e}" x1="${a}%" y1="${s}%" x2="${l}%" y2="${u}%">${n}</linearGradient>`}var fc=Ve({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=Qp(m,t);}else s=t.fillType==="none"?"none":t.fillColor||"#ffffff";let l=t.outlineWidth||1,u=t.outlineColor||"#000000",d=t.outlineStyle==="dashed"?' stroke-dasharray="8 4"':t.outlineStyle==="dotted"?' stroke-dasharray="2 2"':"",c=Jp(t.shapeType||"rect",n,o),p=`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${o}" viewBox="0 0 ${n} ${o}" style="fill:${s};stroke:${u};stroke-width:${l}${d}">`+(a?`<defs>${a}</defs>`:"")+c+"</svg>",f=document.createElement("span");return Object.entries(r).forEach(([m,b])=>{f.setAttribute(m,b);}),f.innerHTML=p,{dom:f}}}});var mc=Ve({name:"horizontalRule",schemaNodeName:"horizontalRule",nodeSpec:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return ["hr"]}}});var gc=Ve({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 hc=Ve({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 bc=Ve({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 yc=Ve({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 cf={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]]}},df={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]}},uf={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 xc(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=uf[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 Sc(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 kc(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 wc(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 pf={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(...Sc(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...wc(t)),o.push(...xc(t)),o.push(...kc(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]}},ff={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(...Sc(t)),t.noWrap?o.push("white-space: nowrap"):o.push("word-wrap: break-word","overflow-wrap: break-word","overflow: hidden"),o.push(...wc(t)),o.push(...xc(t)),o.push(...kc(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 We(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((S,w,k)=>{g||(k===n.index(p-1)?(s=b,g=true):b+=S.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,d=0;r.forEach(p=>{if(p.type.name==="tableRow"){u++;let f=0;p.forEach(m=>{f+=m.attrs.colspan||1;}),d=Math.max(d,f);}});let c=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:d,hasMultiCellSelection:o,canSplitCell:!!c}}function Mo(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 Cc(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 Tc(){return (e,t)=>{if(!Mo(e))return false;let n=Cc(e);if(!n)return false;let{$from:o}=e.selection,r=o.node(n.tableDepth),i=o.node(n.rowDepth),a=o.index(n.rowDepth),s=o.index(n.tableDepth);if(a<i.childCount-1){let l=n.cellPos+o.node(n.cellDepth).nodeSize;if(t){let u=l+1+1,d=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(u)));t(d.scrollIntoView());}return true}if(s<r.childCount-1){let u=o.before(n.rowDepth)+i.nodeSize;if(t){let d=u+1+1+1,c=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(d)));t(c.scrollIntoView());}return true}return false}}function vc(){return (e,t)=>{if(!Mo(e))return false;let n=Cc(e);if(!n)return false;let{$from:o}=e.selection,r=o.node(n.tableDepth),i=o.index(n.rowDepth),a=o.index(n.tableDepth);if(i>0){let l=o.node(n.rowDepth).child(i-1),u=n.cellPos-l.nodeSize;if(t){let d=u+l.nodeSize-2,c=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(d),-1));t(c.scrollIntoView());}return true}if(a>0){let s=r.child(a-1),u=o.before(n.rowDepth)-s.nodeSize;if(t){let c=u+s.nodeSize-1-1,p=e.tr.setSelection(prosemirrorState.Selection.near(e.doc.resolve(c),-1));t(p.scrollIntoView());}return true}return false}}var mf=Ve({name:"table",schemaNodeName:"table",nodeSpec:cf}),gf=Ve({name:"tableRow",schemaNodeName:"tableRow",nodeSpec:df}),hf=Ve({name:"tableCell",schemaNodeName:"tableCell",nodeSpec:pf}),bf=Ve({name:"tableHeader",schemaNodeName:"tableHeader",nodeSpec:ff}),yf=Rt({name:"tablePlugin",onSchemaReady(e){let{schema:t}=e;function n(...P){return (I,y,M)=>{for(let F of P)if(F(I,y,M))return true;return false}}function o(P,I={}){let y=P?.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(P,I,y="000000",M=9360){let F=[],D=Math.floor(M/I),j=360,J="atLeast",N={style:"single",size:4,color:{rgb:y}},U={top:N,bottom:N,left:N,right:N};for(let xe=0;xe<P;xe++){let v=[];for(let z=0;z<I;z++){let A=t.nodes.paragraph.create(),te={colspan:1,rowspan:1,borders:U,width:D,widthType:"dxa"};v.push(t.nodes.tableCell.create(te,A));}F.push(t.nodes.tableRow.create({height:j,heightRule:J},v));}let G=Array(I).fill(D);return t.nodes.table.create({columnWidths:G,width:M,widthType:"dxa"},F)}function i(P,I){return (y,M)=>{let{$from:F}=y.selection,D="000000",j=y.storedMarks||F.marks();for(let N of j)if(N.type.name==="textColor"&&N.attrs.rgb){D=N.attrs.rgb;break}let J=F.pos;for(let N=F.depth;N>0;N--){let U=F.node(N);if(U.type.name==="paragraph"||U.type.name==="table"){J=F.after(N);break}}if(M){let N=9360;for(let Be=F.depth;Be>0;Be--){let me=F.node(Be);if(me.type.name==="tableCell"||me.type.name==="tableHeader"){let Se=me.attrs.width;Se&&Se>0&&(N=Math.max(Se-216,360));break}}let U=r(P,I,D,N),G=t.nodes.paragraph.create(),v=y.doc.resolve(J).nodeBefore?.type.name==="table",z=v?[G,U,G]:[U,G],A=y.tr.insert(J,z),te=J+1;v&&(te+=G.nodeSize);let he=te+1+1;A.setSelection(prosemirrorState.TextSelection.create(A.doc,he)),M(A.scrollIntoView());}return true}}function a(P,I){let y=We(P);if(!y.isInTable||y.rowIndex===void 0||!y.table||y.tablePos===void 0)return false;if(I){let M=P.tr,F=y.table.child(y.rowIndex),D=[];F.forEach(N=>{let U=t.nodes.paragraph.create(),G=o(N);D.push(t.nodes.tableCell.create(G,U));});let j=t.nodes.tableRow.create({height:F.attrs.height??360,heightRule:F.attrs.heightRule??"atLeast"},D),J=y.tablePos+1;for(let N=0;N<y.rowIndex;N++)J+=y.table.child(N).nodeSize;M.insert(J,j),I(M.scrollIntoView());}return true}function s(P,I){let y=We(P);if(!y.isInTable||y.rowIndex===void 0||!y.table||y.tablePos===void 0)return false;if(I){let M=P.tr,F=y.table.child(y.rowIndex),D=[];F.forEach(N=>{let U=t.nodes.paragraph.create(),G=o(N);D.push(t.nodes.tableCell.create(G,U));});let j=t.nodes.tableRow.create({height:F.attrs.height??360,heightRule:F.attrs.heightRule??"atLeast"},D),J=y.tablePos+1;for(let N=0;N<=y.rowIndex;N++)J+=y.table.child(N).nodeSize;M.insert(J,j),I(M.scrollIntoView());}return true}function l(P,I){let y=We(P);if(!y.isInTable||y.rowIndex===void 0||!y.table||y.tablePos===void 0||(y.rowCount||0)<=1)return false;if(I){let M=P.tr,F=y.tablePos+1;for(let j=0;j<y.rowIndex;j++)F+=y.table.child(j).nodeSize;let D=F+y.table.child(y.rowIndex).nodeSize;M.delete(F,D),I(M.scrollIntoView());}return true}function u(P,I){let y=We(P);if(!y.isInTable||y.columnIndex===void 0||!y.table||y.tablePos===void 0)return false;if(I){let M=P.tr,F=(y.columnCount||1)+1,D=Math.floor(100/F),j=y.tablePos+1,J=0;y.table.forEach(U=>{if(U.type.name==="tableRow"){let G=j+1,xe=0;if(U.forEach(v=>{if(xe===y.columnIndex){let z=t.nodes.paragraph.create(),A=o(v,{colspan:1,rowspan:1});J===0&&(A.width=D,A.widthType="pct");let te=t.nodes.tableCell.create(A,z);M=M.insert(G,te);}G+=v.nodeSize,xe+=v.attrs.colspan||1;}),xe<=y.columnIndex){let v=t.nodes.paragraph.create(),z=o(U.child(U.childCount-1)??null,{colspan:1,rowspan:1});J===0&&(z.width=D,z.widthType="pct");let A=t.nodes.tableCell.create(z,v);M=M.insert(G,A);}J++;}j+=U.nodeSize;});let N=M.doc.nodeAt(y.tablePos);if(N&&N.type.name==="table"){let U=N.child(0);if(U&&U.type.name==="tableRow"){let z=y.tablePos+2;U.forEach(A=>{(A.type.name==="tableCell"||A.type.name==="tableHeader")&&(M=M.setNodeMarkup(z,void 0,{...A.attrs,width:D,widthType:"pct"})),z+=A.nodeSize;});}let G=U?.childCount??F,xe=N.attrs.width||9360,v=Math.floor(xe/Math.max(1,G));M=M.setNodeMarkup(y.tablePos,void 0,{...N.attrs,columnWidths:Array(G).fill(v)});}I(M.scrollIntoView());}return true}function d(P,I){let y=We(P);if(!y.isInTable||y.columnIndex===void 0||!y.table||y.tablePos===void 0)return false;if(I){let M=P.tr,F=(y.columnCount||1)+1,D=Math.floor(100/F),j=y.tablePos+1,J=0;y.table.forEach(U=>{if(U.type.name==="tableRow"){let G=j+1,xe=0,v=false;if(U.forEach(z=>{if(G+=z.nodeSize,xe+=z.attrs.colspan||1,!v&&xe>y.columnIndex){let A=t.nodes.paragraph.create(),te=o(z,{colspan:1,rowspan:1});J===0&&(te.width=D,te.widthType="pct");let de=t.nodes.tableCell.create(te,A);M=M.insert(G,de),v=true;}}),!v){let z=t.nodes.paragraph.create(),A=o(U.child(U.childCount-1)??null,{colspan:1,rowspan:1});J===0&&(A.width=D,A.widthType="pct");let te=t.nodes.tableCell.create(A,z);M=M.insert(G,te);}J++;}j+=U.nodeSize;});let N=M.doc.nodeAt(y.tablePos);if(N&&N.type.name==="table"){let U=N.child(0);if(U&&U.type.name==="tableRow"){let z=y.tablePos+2;U.forEach(A=>{(A.type.name==="tableCell"||A.type.name==="tableHeader")&&(M=M.setNodeMarkup(z,void 0,{...A.attrs,width:D,widthType:"pct"})),z+=A.nodeSize;});}let G=U?.childCount??F,xe=N.attrs.width||9360,v=Math.floor(xe/Math.max(1,G));M=M.setNodeMarkup(y.tablePos,void 0,{...N.attrs,columnWidths:Array(G).fill(v)});}I(M.scrollIntoView());}return true}function c(P,I){let y=We(P);if(!y.isInTable||y.columnIndex===void 0||!y.table||y.tablePos===void 0||(y.columnCount||0)<=1)return false;if(I){let M=P.tr,F=(y.columnCount||2)-1,D=Math.floor(100/F),j=[],J=y.tablePos+1;y.table.forEach(U=>{if(U.type.name==="tableRow"){let G=J+1,xe=0;U.forEach(v=>{let z=G,A=G+v.nodeSize,te=v.attrs.colspan||1;xe<=y.columnIndex&&y.columnIndex<xe+te&&j.push({start:z,end:A}),G=A,xe+=te;});}J+=U.nodeSize;}),j.reverse().forEach(({start:U,end:G})=>{M=M.delete(U,G);});let N=M.doc.nodeAt(y.tablePos);if(N&&N.type.name==="table"){let U=N.child(0);if(U&&U.type.name==="tableRow"){let z=y.tablePos+2;U.forEach(A=>{(A.type.name==="tableCell"||A.type.name==="tableHeader")&&(M=M.setNodeMarkup(z,void 0,{...A.attrs,width:D,widthType:"pct"})),z+=A.nodeSize;});}let G=U?.childCount??F,xe=N.attrs.width||9360,v=Math.floor(xe/Math.max(1,G));M=M.setNodeMarkup(y.tablePos,void 0,{...N.attrs,columnWidths:Array(G).fill(v)});}I(M.scrollIntoView());}return true}function p(P,I){let y=We(P);if(!y.isInTable||y.tablePos===void 0||!y.table)return false;if(I){let M=P.tr;M.delete(y.tablePos,y.tablePos+y.table.nodeSize),I(M.scrollIntoView());}return true}function f(P,I){let y=We(P);if(!y.isInTable||y.tablePos===void 0||!y.table)return false;if(I){let M=y.tablePos+1,F=P.doc.resolve(M),D=P.doc.resolve(y.tablePos+y.table.nodeSize-2),j=prosemirrorTables.CellSelection.create(P.doc,F.pos,D.pos);I(P.tr.setSelection(j));}return true}function m(P,I){let y=We(P);if(!y.isInTable||y.tablePos===void 0||!y.table||y.rowIndex===void 0)return false;if(I){let F=y.tablePos+1;for(let U=0;U<y.rowIndex;U++){let G=y.table.child(U);F+=G.nodeSize;}let D=y.table.child(y.rowIndex),j=F+1,J=F+D.nodeSize-2,N=prosemirrorTables.CellSelection.create(P.doc,j,J);I(P.tr.setSelection(N));}return true}function b(P,I){let y=We(P);if(!y.isInTable||y.tablePos===void 0||!y.table||y.columnIndex===void 0)return false;if(I){let M=y.tablePos+1,F=y.table.child(0),D=y.table.child(y.table.childCount-1),j=M+1;for(let G=0;G<y.columnIndex&&G<F.childCount;G++)j+=F.child(G).nodeSize;let J=M;for(let G=0;G<y.table.childCount-1;G++)J+=y.table.child(G).nodeSize;let N=J+1;for(let G=0;G<y.columnIndex&&G<D.childCount;G++)N+=D.child(G).nodeSize;let U=prosemirrorTables.CellSelection.create(P.doc,j,N);I(P.tr.setSelection(U));}return true}function g(P){let I=P.selection,y=[];if(I instanceof prosemirrorTables.CellSelection)return I.forEachCell((F,D)=>{y.push({pos:D,node:F});}),y;let{$from:M}=I;for(let F=M.depth;F>0;F--){let D=M.node(F);if(D.type.name==="tableCell"||D.type.name==="tableHeader"){y.push({pos:M.before(F),node:D});break}}return y}function S(P,I){let y=new Map,M=new Map,F=P.childCount,D=0;return P.forEach((j,J,N)=>{if(j.type.name!=="tableRow")return;let U=0;j.forEach((G,xe)=>{let v=I+J+xe+2,z=G.attrs.colspan||1;y.set(v,{rowIdx:N,colIdx:U,colspan:z,pos:v,node:G}),M.set(`${N},${U}`,v),U+=z;}),D=Math.max(D,U);}),{cellByPos:y,cellByRC:M,totalRows:F,totalCols:D}}function w(P,I){return (y,M)=>{let F=We(y);if(!F.isInTable||F.tablePos===void 0||!F.table)return false;if(M){let D=y.tr,j=F.table,J=F.tablePos,N=I??{style:"single",size:4,color:{rgb:"000000"}},U={style:"none"},{cellByPos:G,cellByRC:xe}=S(j,J),v=g(y),z=1/0,A=-1,te=1/0,de=-1;for(let{pos:Se}of v){let ue=G.get(Se);ue&&(z=Math.min(z,ue.rowIdx),A=Math.max(A,ue.rowIdx),te=Math.min(te,ue.colIdx),de=Math.max(de,ue.colIdx+ue.colspan-1));}let he=new Map,Be=(Se,ue)=>he.get(Se)??{...ue.attrs},me=(Se,ue)=>{he.set(Se,ue);};for(let{pos:Se}of v){let ue=G.get(Se);if(!ue)continue;let ze=ue.rowIdx===z,tt=ue.rowIdx===A,Ue=ue.colIdx===te,rt=ue.colIdx+ue.colspan-1===de,Oe;switch(P){case "all":Oe={top:N,bottom:N,left:N,right:N};break;case "outside":Oe={top:ze?N:U,bottom:tt?N:U,left:Ue?N:U,right:rt?N:U};break;case "inside":Oe={top:ze?U:N,bottom:tt?U:N,left:Ue?U:N,right:rt?U:N};break;case "none":Oe={top:U,bottom:U,left:U,right:U};break}let Qe=Be(Se,ue.node),dt=Qe.borders||{};if(me(Se,{...Qe,borders:{...dt,...Oe}}),Oe.top){let Ge=xe.get(`${ue.rowIdx-1},${ue.colIdx}`);if(Ge!==void 0){let pt=G.get(Ge),$e=Be(Ge,pt.node),Ht=$e.borders||{};me(Ge,{...$e,borders:{...Ht,bottom:Oe.top}});}}if(Oe.bottom){let Ge=xe.get(`${ue.rowIdx+1},${ue.colIdx}`);if(Ge!==void 0){let pt=G.get(Ge),$e=Be(Ge,pt.node),Ht=$e.borders||{};me(Ge,{...$e,borders:{...Ht,top:Oe.bottom}});}}if(Oe.left){let Ge=xe.get(`${ue.rowIdx},${ue.colIdx-1}`);if(Ge!==void 0){let pt=G.get(Ge),$e=Be(Ge,pt.node),Ht=$e.borders||{};me(Ge,{...$e,borders:{...Ht,right:Oe.left}});}}if(Oe.right){let Ge=xe.get(`${ue.rowIdx},${ue.colIdx+ue.colspan}`);if(Ge!==void 0){let pt=G.get(Ge),$e=Be(Ge,pt.node),Ht=$e.borders||{};me(Ge,{...$e,borders:{...Ht,left:Oe.right}});}}}for(let[Se,ue]of he)D.setNodeMarkup(D.mapping.map(Se),void 0,ue);M(D.scrollIntoView());}return true}}function k(P){return (I,y)=>{let M=We(I);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(y){let F=I.tr,D=g(I),j=P?P.replace(/^#/,""):null;for(let{pos:J,node:N}of D)F.setNodeMarkup(F.mapping.map(J),void 0,{...N.attrs,backgroundColor:j});y(F.scrollIntoView());}return true}}function E(P,I){return (y,M)=>{let F=We(y);if(!F.isInTable||F.tablePos===void 0||!F.table)return false;if(M){let D=y.tr,j=g(y),J=I||{style:"none"},{cellByPos:N,cellByRC:U}=S(F.table,F.tablePos),G=new Map,xe=(A,te)=>G.get(A)??{...te.attrs},v=(A,te)=>G.set(A,te),z={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:A,node:te}of j){let de=N.get(A),he=xe(A,te),Be=he.borders||{},me=P==="all"?["top","bottom","left","right"]:[P],Se={...Be};for(let ue of me)if(Se[ue]=J,de){let ze=z[ue],tt=ue==="right"?de.colIdx+de.colspan:de.colIdx+ze.dCol,Ue=U.get(`${de.rowIdx+ze.dRow},${tt}`);if(Ue!==void 0){let rt=N.get(Ue),Oe=xe(Ue,rt.node),Qe=Oe.borders||{};v(Ue,{...Oe,borders:{...Qe,[ze.adjSide]:J}});}}v(A,{...he,borders:Se});}for(let[A,te]of G)D.setNodeMarkup(D.mapping.map(A),void 0,te);M(D.scrollIntoView());}return true}}function R(P){return (I,y)=>{let M=We(I);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(y){let F=I.tr,D=g(I);for(let{pos:j,node:J}of D)F.setNodeMarkup(F.mapping.map(j),void 0,{...J.attrs,verticalAlign:P});y(F.scrollIntoView());}return true}}function _(P){return (I,y)=>{let M=We(I);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(y){let F=I.tr,D=g(I);for(let{pos:j,node:J}of D){let U={...J.attrs.margins||{},...P};F.setNodeMarkup(F.mapping.map(j),void 0,{...J.attrs,margins:U});}y(F.scrollIntoView());}return true}}function V(P){return (I,y)=>{let M=We(I);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(y){let F=I.tr,D=g(I);for(let{pos:j,node:J}of D)F.setNodeMarkup(F.mapping.map(j),void 0,{...J.attrs,textDirection:P});y(F.scrollIntoView());}return true}}function $(){return (P,I)=>{let y=We(P);if(!y.isInTable||y.tablePos===void 0||!y.table)return false;if(I){let M=P.tr,F=g(P);for(let{pos:D,node:j}of F)M.setNodeMarkup(M.mapping.map(D),void 0,{...j.attrs,noWrap:!j.attrs.noWrap});I(M.scrollIntoView());}return true}}function L(P,I){return (y,M)=>{let F=We(y);if(!F.isInTable||F.tablePos===void 0||!F.table)return false;if(M){let D=y.tr,{$from:j}=y.selection;for(let J=j.depth;J>0;J--){let N=j.node(J);if(N.type.name==="tableRow"){let U=j.before(J),G={...N.attrs,height:P,heightRule:P?I||"atLeast":null};return D.setNodeMarkup(U,void 0,G),M(D.scrollIntoView()),true}}}return true}}function W(){return (P,I)=>{let y=We(P);if(!y.isInTable||y.tablePos===void 0||!y.table||!y.columnCount)return false;if(I){let M=P.tr,F=y.table,D=y.columnCount,j=F.attrs.columnWidths,J=j?j.reduce((xe,v)=>xe+v,0):9360,N=Math.floor(J/D),U=y.tablePos+1;F.forEach(xe=>{if(xe.type.name==="tableRow"){let v=U+1;xe.forEach(z=>{(z.type.name==="tableCell"||z.type.name==="tableHeader")&&(M=M.setNodeMarkup(v,void 0,{...z.attrs,width:N,widthType:"dxa",colwidth:null})),v+=z.nodeSize;});}U+=xe.nodeSize;});let G=Array(D).fill(N);M=M.setNodeMarkup(y.tablePos,void 0,{...F.attrs,columnWidths:G}),I(M.scrollIntoView());}return true}}function O(){return (P,I)=>{let y=We(P);if(!y.isInTable||y.tablePos===void 0||!y.table)return false;if(I){let M=P.tr,F=y.table,D=y.tablePos+1;F.forEach(j=>{if(j.type.name==="tableRow"){let J=D+1;j.forEach(N=>{(N.type.name==="tableCell"||N.type.name==="tableHeader")&&(M=M.setNodeMarkup(J,void 0,{...N.attrs,width:null,widthType:null,colwidth:null})),J+=N.nodeSize;});}D+=j.nodeSize;}),M=M.setNodeMarkup(y.tablePos,void 0,{...F.attrs,columnWidths:null,width:null,widthType:"auto"}),I(M.scrollIntoView());}return true}}function K(P){return (I,y)=>{let M=We(I);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(y){let F=I.tr,D=M.table,j=M.tablePos,J=D.childCount,N=P.look??{firstRow:true,lastRow:false,noHBand:false},U=P.conditionals??{},G=P.tableBorders;F=F.setNodeMarkup(j,void 0,{...D.attrs,styleId:P.styleId});let xe=0,v=j+1;for(let z=0;z<J;z++){let A=D.child(z),te=z===0&&!!N.firstRow,de=z===J-1&&!!N.lastRow,he=N.noHBand!==true,Be=A.childCount,me;te?me="firstRow":de?me="lastRow":(he&&(me=xe%2===0?"band1Horz":"band2Horz"),xe++);let Se=v+1;for(let ue=0;ue<Be;ue++){let ze=A.child(ue),tt=F.mapping.map(Se),Ue=me,rt=ue===0&&!!N.firstCol,Oe=ue===Be-1&&!!N.lastCol;te&&rt&&U.nwCell?Ue="nwCell":te&&Oe&&U.neCell?Ue="neCell":de&&rt&&U.swCell?Ue="swCell":de&&Oe&&U.seCell?Ue="seCell":rt?Ue="firstCol":Oe&&(Ue="lastCol");let Qe=Ue?U[Ue]:void 0,dt={...ze.attrs};Qe?.backgroundColor?dt.backgroundColor=Qe.backgroundColor:dt.backgroundColor=null;let Ge={},pt=["top","bottom","left","right"];for(let $e of pt)Qe?.borders&&Qe.borders[$e]!==void 0?Ge[$e]=Qe.borders[$e]:G&&($e==="top"&&z>0||$e==="bottom"&&z<J-1?Ge[$e]=G.insideH??G[$e]:$e==="left"&&ue>0||$e==="right"&&ue<Be-1?Ge[$e]=G.insideV??G[$e]:Ge[$e]=G[$e]);Object.keys(Ge).length>0?dt.borders=Ge:dt.borders=null,F=F.setNodeMarkup(tt,void 0,dt),Se+=ze.nodeSize;}v+=A.nodeSize;}y(F.scrollIntoView());}return true}}function C(P){return (I,y)=>{let M=We(I);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(y){let F=I.tr,D={...M.table.attrs};"width"in P&&(D.width=P.width),"widthType"in P&&(D.widthType=P.widthType),"justification"in P&&(D.justification=P.justification),F.setNodeMarkup(M.tablePos,void 0,D),y(F.scrollIntoView());}return true}}function B(){return (P,I)=>{let y=We(P);if(!y.isInTable||y.tablePos===void 0||!y.table)return false;if(I){let M=P.tr,{$from:F}=P.selection;for(let D=F.depth;D>0;D--){let j=F.node(D);if(j.type.name==="tableRow"){let J=F.before(D),N={...j.attrs,isHeader:!j.attrs.isHeader};return M.setNodeMarkup(J,void 0,N),I(M.scrollIntoView()),true}}}return true}}function ee(P){return (I,y)=>{let M=We(I);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(y){let F=I.tr,D=g(I),j=P.replace(/^#/,""),J={style:"single",size:4},{cellByPos:N,cellByRC:U}=S(M.table,M.tablePos),G=new Map,xe=(A,te)=>G.get(A)??{...te.attrs},v=(A,te)=>G.set(A,te),z={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:A,node:te}of D){let de=N.get(A),he=xe(A,te),Be=he.borders||{},me={};for(let Se of ["top","bottom","left","right"]){let ue={...J,...Be[Se],color:{rgb:j}};if(me[Se]=ue,de){let ze=z[Se],tt=Se==="right"?de.colIdx+de.colspan:de.colIdx+ze.dCol,Ue=U.get(`${de.rowIdx+ze.dRow},${tt}`);if(Ue!==void 0){let rt=N.get(Ue),Oe=xe(Ue,rt.node),Qe=Oe.borders||{};v(Ue,{...Oe,borders:{...Qe,[ze.adjSide]:ue}});}}}v(A,{...he,borders:{...Be,...me}});}for(let[A,te]of G)F.setNodeMarkup(F.mapping.map(A),void 0,te);y(F.scrollIntoView());}return true}}function ge(P){return (I,y)=>{let M=We(I);if(!M.isInTable||M.tablePos===void 0||!M.table)return false;if(y){let F=I.tr,D=g(I),j={style:"single",color:{rgb:"000000"}},{cellByPos:J,cellByRC:N}=S(M.table,M.tablePos),U=new Map,G=(z,A)=>U.get(z)??{...A.attrs},xe=(z,A)=>U.set(z,A),v={top:{adjSide:"bottom",dRow:-1,dCol:0},bottom:{adjSide:"top",dRow:1,dCol:0},left:{adjSide:"right",dRow:0,dCol:-1},right:{adjSide:"left",dRow:0,dCol:1}};for(let{pos:z,node:A}of D){let te=J.get(z),de=G(z,A),he=de.borders||{},Be={};for(let me of ["top","bottom","left","right"]){let Se={...j,...he[me],size:P};if(Be[me]=Se,te){let ue=v[me],ze=me==="right"?te.colIdx+te.colspan:te.colIdx+ue.dCol,tt=N.get(`${te.rowIdx+ue.dRow},${ze}`);if(tt!==void 0){let Ue=J.get(tt),rt=G(tt,Ue.node),Oe=rt.borders||{};xe(tt,{...rt,borders:{...Oe,[ue.adjSide]:Se}});}}}xe(z,{...de,borders:{...he,...Be}});}for(let[z,A]of U)F.setNodeMarkup(F.mapping.map(z),void 0,A);y(F.scrollIntoView());}return true}}function pe(){return (P,I)=>{let y=P.selection;if(!("$anchorCell"in y&&typeof y.forEachCell=="function"))return false;let F=We(P);if(!F.isInTable||F.tablePos===void 0||!F.table)return false;let D=0;F.table.descendants(N=>{(N.type.name==="tableCell"||N.type.name==="tableHeader")&&(D+=1);});let j=0;if(y.forEachCell(()=>{j+=1;}),!(D>0&&j>=D))return false;if(I){let N=P.tr.delete(F.tablePos,F.tablePos+F.table.nodeSize);I(N.scrollIntoView());}return true}}function Ee(){return P=>{let{$from:I,empty:y}=P.selection;if(!y)return false;let M=I.parent;if(M.type.name!=="paragraph"||M.textContent.length>0)return false;let F=I.depth;if(F<1)return false;let D=I.node(F-1),j=I.index(F-1),J=j>0?D.child(j-1):null,N=j+1<D.childCount?D.child(j+1):null,U=J?.type.name==="table",G=N?.type.name==="table";return !!(U||G)}}let Te=new prosemirrorState.PluginKey("activeCell"),Re=new prosemirrorState.Plugin({key:Te,props:{decorations(P){let{selection:I}=P;if(I instanceof prosemirrorTables.CellSelection)return prosemirrorView.DecorationSet.empty;let{$from:y}=I;for(let M=y.depth;M>0;M--){let F=y.node(M);if(F.type.name==="tableCell"||F.type.name==="tableHeader"){let D=y.before(M);return prosemirrorView.DecorationSet.create(P.doc,[prosemirrorView.Decoration.node(D,D+F.nodeSize,{class:"activeCell"})])}}return prosemirrorView.DecorationSet.empty}}});return {plugins:[prosemirrorTables.columnResizing({handleWidth:5,cellMinWidth:25,lastColumnResizable:true}),prosemirrorTables.tableEditing(),Re],keyboardShortcuts:{Backspace:n(pe(),Ee()),Delete:n(pe(),Ee())},commands:{insertTable:(P,I)=>i(P,I),addRowAbove:()=>a,addRowBelow:()=>s,deleteRow:()=>l,addColumnLeft:()=>u,addColumnRight:()=>d,deleteColumn:()=>c,deleteTable:()=>p,selectTable:()=>f,selectRow:()=>m,selectColumn:()=>b,mergeCells:()=>prosemirrorTables.mergeCells,splitCell:()=>prosemirrorTables.splitCell,setCellBorder:(P,I)=>E(P,I),setTableBorders:(P,I)=>w(P,I),setCellVerticalAlign:P=>R(P),setCellMargins:P=>_(P),setCellTextDirection:P=>V(P),toggleNoWrap:()=>$(),setRowHeight:(P,I)=>L(P,I),toggleHeaderRow:()=>B(),distributeColumns:()=>W(),autoFitContents:()=>O(),setTableProperties:P=>C(P),applyTableStyle:P=>K(P),setCellFillColor:P=>k(P),setTableBorderColor:P=>ee(P),setTableBorderWidth:P=>ge(P),removeTableBorders:()=>w("none"),setAllTableBorders:P=>w("all",P),setOutsideTableBorders:P=>w("outside",P),setInsideTableBorders:P=>w("inside",P)}}}});function Rc(){return [mf(),gf(),hf(),bf(),yf()]}function Fa(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}function Pc(e){return (t,n)=>{let{$from:o,$to:r}=t.selection,i=o.parent;if(i.type.name!=="paragraph")return false;let s=i.attrs.numPr?.numId===e;if(!n)return true;let l=t.tr,u=new Set;return t.doc.nodesBetween(o.pos,r.pos,(d,c)=>{if(d.type.name==="paragraph"&&!u.has(c))if(u.add(c),s)l=l.setNodeMarkup(c,void 0,{...d.attrs,numPr:null,listIsBullet:null,listNumFmt:null,listMarker:null});else {let p=e===1;l=l.setNodeMarkup(c,void 0,{...d.attrs,numPr:{numId:e,ilvl:d.attrs.numPr?.ilvl||0},listIsBullet:p,listNumFmt:p?null:"decimal",listMarker:null});}}),n(l.scrollIntoView()),true}}var xf=(e,t)=>Pc(1)(e,t),Sf=(e,t)=>Pc(2)(e,t),kf=(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},wf=(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},Cf=(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 Tf(){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 vf(){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 Rf(){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 Pf(){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 Mf(){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 Ef(){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 Mc=Rt({name:"list",priority:yn.High,onSchemaReady(){return {commands:{toggleBulletList:()=>xf,toggleNumberedList:()=>Sf,increaseListLevel:()=>kf,decreaseListLevel:()=>wf,removeList:()=>Cf},keyboardShortcuts:{Tab:Fa(Tc(),Pf(),Ef()),"Shift-Tab":Fa(vc(),Mf()),"Shift-Enter":()=>false,Enter:Fa(Tf(),vf()),Backspace:Rf()}}}});function Ic(...e){return (t,n,o)=>{for(let r of e)if(r(t,n,o))return true;return false}}var Hf=(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},Nf=["defaultTextFormatting","styleId","lineSpacing","lineSpacingRule","spaceAfter","spaceBefore","contextualSpacing"],Fc=new Set(["fontFamily","fontSize","textColor"]),zf=(e,t,n)=>{let{$from:o}=e.selection,r=o.parent.type.name==="paragraph"?o.parent:null,a=(e.storedMarks||o.marks()).filter(u=>Fc.has(u.type.name)),s=null;if(!prosemirrorCommands.splitBlock(e,t?u=>{s=u;}:void 0,n))return false;if(t&&s!==null){let u=s,{$from:d}=u.selection,c=d.parent;if(c.type.name==="paragraph"){let p={...c.attrs},f=false;if(r)for(let m of Nf){let b=r.attrs[m];b!=null&&p[m]==null&&(p[m]=b,f=true);}if(p.borders&&(p.borders=null,f=true),f&&u.setNodeMarkup(d.before(),void 0,p),c.textContent.length===0){let m=a;if(m.length===0&&r){let b=r.attrs.defaultTextFormatting;b&&(m=Ma(b,e.schema).filter(S=>Fc.has(S.type.name)));}if(m.length>0){let b={...p.defaultTextFormatting??{}},g=false;for(let S of m)if(S.type.name==="fontSize"&&S.attrs.size!==b.fontSize&&(b.fontSize=S.attrs.size,g=true),S.type.name==="fontFamily"){let w=S.attrs.ascii;w&&(!b.fontFamily||b.fontFamily.ascii!==w)&&(b.fontFamily={...b.fontFamily,ascii:w,hAnsi:S.attrs.hAnsi},g=true);}g&&u.setNodeMarkup(d.before(),void 0,{...p,defaultTextFormatting:b}),u.setStoredMarks(m);}}}t(u.scrollIntoView());}return true},Lc=Rt({name:"baseKeymap",priority:yn.Low,onSchemaReady(e){return {keyboardShortcuts:{...prosemirrorCommands.baseKeymap,Enter:zf,Backspace:Ic(prosemirrorCommands.deleteSelection,Hf,prosemirrorCommands.joinBackward),Delete:Ic(prosemirrorCommands.deleteSelection,prosemirrorCommands.joinForward),"Mod-a":prosemirrorCommands.selectAll,Escape:prosemirrorCommands.selectParentNode}}}});var fr=new prosemirrorState.PluginKey("selectionTracker");function io(e){let{selection:t,doc:n}=e,{from:o,to:r,empty:i}=t,a=n.resolve(o),s=0,l=0;n.forEach((E,R,_)=>{if(R>r)return false;R<=o&&(s=_),R<=r&&(l=_);});let u=Wf(e),d=a.parent,c={};d.type.name==="paragraph"&&(d.attrs.alignment&&(c.alignment=d.attrs.alignment),d.attrs.lineSpacing&&(c.lineSpacing=d.attrs.lineSpacing,c.lineSpacingRule=d.attrs.lineSpacingRule),d.attrs.indentLeft&&(c.indentLeft=d.attrs.indentLeft),d.attrs.indentRight&&(c.indentRight=d.attrs.indentRight),d.attrs.indentFirstLine&&(c.indentFirstLine=d.attrs.indentFirstLine),d.attrs.hangingIndent&&(c.hangingIndent=d.attrs.hangingIndent),d.attrs.tabs&&(c.tabs=d.attrs.tabs),d.attrs.numPr&&(c.numPr=d.attrs.numPr));let p=d.attrs?.numPr,f=!!p?.numId,m=p?.numId===1?"bullet":p?.numId?"numbered":void 0,b=p?.ilvl,g=e.storedMarks||(i?a.marks():[]),S=[],w=false,k=false;for(let E of g)E.type.name==="comment"&&E.attrs.commentId&&S.push(E.attrs.commentId),E.type.name==="insertion"&&(w=true),E.type.name==="deletion"&&(k=true);return {hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:c,startParagraphIndex:s,endParagraphIndex:l,inList:f,listType:m,listLevel:b,activeCommentIds:S,inInsertion:w,inDeletion:k}}function Wf(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 mr(e){return new prosemirrorState.Plugin({key:fr,state:{init(t,n){return io(n)},apply(t,n,o,r){if(!t.selectionSet&&!t.docChanged)return n;let i=io(r);return e&&!Vf(n,i)&&setTimeout(()=>e(i),0),i}},view(){return {update(t,n){if(!e||t.state.selection.eq(n.selection)&&t.state.doc.eq(n.doc))return;let o=fr.getState(t.state);o&&e(o);}}}})}function _f(e,t){if(e===t)return true;if(!e||!t||e.length!==t.length)return false;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return false;return true}function Vf(e,t){return e.hasSelection===t.hasSelection&&e.isMultiParagraph===t.isMultiParagraph&&e.startParagraphIndex===t.startParagraphIndex&&e.endParagraphIndex===t.endParagraphIndex&&e.inList===t.inList&&e.listType===t.listType&&e.listLevel===t.listLevel&&e.inInsertion===t.inInsertion&&e.inDeletion===t.inDeletion&&_f(e.activeCommentIds,t.activeCommentIds)&&JSON.stringify(e.textFormatting)===JSON.stringify(t.textFormatting)&&JSON.stringify(e.paragraphFormatting)===JSON.stringify(t.paragraphFormatting)}var Bc=Rt({name:"selectionTracker",defaultOptions:{},onSchemaReady(e,t){return {plugins:[mr(t.onSelectionChange)],commands:{extractSelectionContext:()=>(n,o)=>(io(n),true)}}}});var Gf=new prosemirrorState.PluginKey("imageDrag"),Dc=Rt({name:"imageDrag",onSchemaReady(e){return {plugins:[new prosemirrorState.Plugin({key:Gf,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 Hc=Rt({name:"dropCursor",onSchemaReady(){return {plugins:[prosemirrorDropcursor.dropCursor({color:"var(--doc-primary, #4285f4)",width:2})]}}});function ao(e={}){let t=new Set(e.disable||[]),n=[];function o(r,i){t.has(r)||n.push(i);}return o("doc",Pl()),o("text",Ml()),o("paragraph",Bl()),o("history",Dl({depth:e.historyDepth,newGroupDelay:e.historyNewGroupDelay})),o("bold",Nl()),o("italic",Ol()),o("underline",_l()),o("strike",Vl()),o("textColor",jl()),o("highlight",Ul()),o("fontSize",Gl()),o("fontFamily",Kl()),o("superscript",Yl()),o("subscript",ql()),o("hyperlink",Xl()),o("allCaps",Zl()),o("smallCaps",Jl()),o("footnoteRef",Ql()),o("characterSpacing",ec()),o("emboss",rc()),o("imprint",ic()),o("textShadow",ac()),o("emphasisMark",sc()),o("textOutline",lc()),o("comment",tc()),o("insertion",nc()),o("deletion",oc()),o("hardBreak",cc()),o("tab",dc()),o("image",uc()),o("textBox",pc()),o("shape",fc()),o("imageDrag",Dc()),o("dropCursor",Hc()),o("horizontalRule",mc()),o("pageBreak",gc()),o("field",hc()),o("sdt",bc()),o("math",yc()),t.has("table")||n.push(...Rc()),o("list",Mc()),o("baseKeymap",Lc()),o("selectionTracker",Bc({onSelectionChange:e.onSelectionChange})),n}var xn=class{constructor(t){chunkQEBO3EQP_cjs.d(this,"extensions");chunkQEBO3EQP_cjs.d(this,"schema",null);chunkQEBO3EQP_cjs.d(this,"plugins",[]);chunkQEBO3EQP_cjs.d(this,"commands",{});this.extensions=[...t].sort((n,o)=>n.config.priority-o.config.priority);}buildSchema(){let t={},n={};for(let o of this.extensions)o.type==="node"?t[o.config.schemaNodeName]=o.config.nodeSpec:o.type==="mark"&&(n[o.config.schemaMarkName]=o.config.markSpec);this.schema=new prosemirrorModel.Schema({nodes:t,marks:n});}initializeRuntime(){if(!this.schema)throw new Error("ExtensionManager: buildSchema() must be called before initializeRuntime()");let t={schema:this.schema},n=[],o=[],r={};for(let i of this.extensions){let a=i.onSchemaReady(t);a.commands&&Object.assign(r,a.commands),a.keyboardShortcuts&&n.push(a.keyboardShortcuts),a.plugins&&o.push(...a.plugins);}this.plugins=[...o,...n.map(i=>prosemirrorKeymap.keymap(i))],this.commands=r;}getSchema(){if(!this.schema)throw new Error("ExtensionManager: buildSchema() must be called first");return this.schema}getPlugins(){return this.plugins}getCommands(){return this.commands}getCommand(t){return this.commands[t]}destroy(){this.plugins=[],this.commands={};}};var gr=new xn(ao());gr.buildSchema();gr.initializeRuntime();var _n=gr,ye=gr.getSchema();var Eo=class{constructor(t){chunkQEBO3EQP_cjs.d(this,"stylesById");chunkQEBO3EQP_cjs.d(this,"docDefaults");chunkQEBO3EQP_cjs.d(this,"defaultParagraphStyle");if(this.stylesById=new Map,this.docDefaults=t?.docDefaults,t?.styles)for(let n of t.styles)n.styleId&&this.stylesById.set(n.styleId,n);this.defaultParagraphStyle=this.findDefaultStyle("paragraph");}getStyle(t){return this.stylesById.get(t)}getParagraphStyles(){let t=[];for(let n of this.stylesById.values())n.type==="paragraph"&&!n.hidden&&!n.semiHidden&&t.push(n);return t.sort((n,o)=>{let r=n.uiPriority??99,i=o.uiPriority??99;return r!==i?r-i:(n.name??n.styleId).localeCompare(o.name??o.styleId)})}resolveParagraphStyle(t){let n={};if(this.docDefaults?.pPr&&(n.paragraphFormatting={...this.docDefaults.pPr}),this.docDefaults?.rPr&&(n.runFormatting={...this.docDefaults.rPr}),!t)return this.defaultParagraphStyle&&this.mergeStyleIntoResult(n,this.defaultParagraphStyle),n;let o=this.stylesById.get(t);return o?(this.mergeStyleIntoResult(n,o),n):(this.defaultParagraphStyle&&this.mergeStyleIntoResult(n,this.defaultParagraphStyle),n)}getTableStyles(){let t=[];for(let n of this.stylesById.values())n.type==="table"&&!n.hidden&&!n.semiHidden&&t.push(n);return t.sort((n,o)=>{let r=n.uiPriority??99,i=o.uiPriority??99;return r!==i?r-i:(n.name??n.styleId).localeCompare(o.name??o.styleId)})}resolveRunStyle(t){let n={};if(this.docDefaults?.rPr&&(n={...this.docDefaults.rPr}),!t)return Object.keys(n).length>0?n:void 0;let o=this.stylesById.get(t);if(!o?.rPr)return Object.keys(n).length>0?n:void 0;let r=this.mergeTextFormatting(n,o.rPr);return r&&Object.keys(r).length>0?r:void 0}getRunStyleOwnProperties(t){if(!t)return;let n=this.stylesById.get(t);if(n?.rPr)return Object.keys(n.rPr).length>0?{...n.rPr}:void 0}getDocDefaults(){return this.docDefaults}getDefaultParagraphStyle(){return this.defaultParagraphStyle}hasStyle(t){return this.stylesById.has(t)}findDefaultStyle(t){for(let n of this.stylesById.values())if(n.type===t&&n.default)return n;if(t==="paragraph")return this.stylesById.get("Normal")}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 Sn(e){return new Eo(e)}function yr(e,t){let n=e.package.document.content,o=[],r=t?.styles?Sn(t.styles):null;for(let i of n)if(i.type==="paragraph"){let a=Nc(i),s=xr(i,r);o.push(s);for(let l of a)o.push(zc(l,r));sm(i)&&o.push(ye.node("pageBreak"));}else if(i.type==="table"){let a=La(i,r);o.push(a);}return o.length===0&&o.push(ye.node("paragraph",{},[])),ye.node("doc",null,o)}function xr(e,t,n,o){let r=Zf(e,t),i=[],a,s=new Set,l;t&&(l=t.resolveParagraphStyle(e.formatting?.styleId).runFormatting);let u=on(l,o);for(let d of e.content){if(d.type==="commentRangeStart")s.add(d.id);else if(d.type==="commentRangeEnd")s.delete(d.id);else if(d.type==="run"){let c=Ba(d,u,t);s.size>0&&(c=Xf(c,s)),i.push(...c);}else if(d.type==="hyperlink"){let c=Aa(d,u,t);i.push(...c);}else if(d.type==="simpleField"||d.type==="complexField"){let c=tm(d,u);c&&i.push(c);}else if(d.type==="inlineSdt"){let c=om(d,u,t);c&&i.push(c);}else if(d.type==="insertion"){let c=hr(d,"insertion",u,t);i.push(...c);}else if(d.type==="deletion"){let c=hr(d,"deletion",u,t);i.push(...c);}else if(d.type==="moveFrom"){let c=hr(d,"deletion",u,t);i.push(...c);}else if(d.type==="moveTo"){let c=hr(d,"insertion",u,t);i.push(...c);}else if(d.type==="mathEquation"){let c=nm(d);c&&i.push(c);}d.type==="bookmarkStart"&&(a||(a=[]),a.push({id:d.id,name:d.name}));}return a&&(r.bookmarks=a),ye.node("paragraph",r,i)}function Xf(e,t){if(t.size===0)return e;let n=[...t][0],o=ye.marks.comment.create({commentId:n});return e.map(r=>r.isText?r.mark(o.addToSet(r.marks)):r)}function hr(e,t,n,o){let r=[];for(let a of e.content)a.type==="run"?r.push(...Ba(a,n,o)):a.type==="hyperlink"&&r.push(...Aa(a,n,o));let i=ye.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 Zf(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=br(n?.runProperties,t);if(r.defaultTextFormatting=on(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=br(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 Dt(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=br(r.pPr?.runProperties,e),a=br(r.rPr,e),s=on(i,a);return {tcPr:r.tcPr,rPr:s}}function nn(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=on(e.rPr,t.rPr),n}function br(e,t){if(!e)return;if(!e.styleId||!t)return e;let n=t.resolveRunStyle(e.styleId);return on(n,e)}function Jf(e){let t=new Map,n=e.rows.length,o=new Map;for(let r=0;r<n;r++){let i=e.rows[r],a=0;for(let s=0;s<i.cells.length;s++){let l=i.cells[s],u=l.formatting?.gridSpan??1,d=l.formatting?.vMerge,c=`${r}-${a}`;if(d==="restart")o.set(a,r),t.set(c,{rowSpan:1,skip:false});else if(d==="continue"){let p=o.get(a);if(p!==void 0){let f=`${p}-${a}`,m=t.get(f);m&&m.rowSpan++;}t.set(c,{rowSpan:1,skip:true});}else o.delete(a),t.set(c,{rowSpan:1,skip:false});a+=u;}}return t}function La(e,t){let n=Jf(e),o=e.columnWidths,r=o?.reduce((k,E)=>k+E,0)??0,i=e.formatting?.styleId,a=e.formatting?.look,s=i?t?.getStyle(i):void 0,l=e.formatting?.borders??s?.tblPr?.borders,u=e.formatting?.cellMargins??s?.tblPr?.cellMargins??void 0,d=u?{top:u.top?.value,bottom:u.bottom?.value,left:u.left?.value,right:u.right?.value}:void 0,c={styleId:e.formatting?.styleId,width:e.formatting?.width?.value,widthType:e.formatting?.width?.type,justification:e.formatting?.justification,columnWidths:o,floating:e.formatting?.floating,cellMargins:d,look:e.formatting?.look,_originalFormatting:e.formatting||void 0},p={wholeTable:Dt(t,i,"wholeTable"),firstRow:Dt(t,i,"firstRow"),lastRow:Dt(t,i,"lastRow"),firstCol:Dt(t,i,"firstCol"),lastCol:Dt(t,i,"lastCol"),band1Horz:Dt(t,i,"band1Horz"),band2Horz:Dt(t,i,"band2Horz"),band1Vert:Dt(t,i,"band1Vert"),band2Vert:Dt(t,i,"band2Vert"),nwCell:Dt(t,i,"nwCell"),neCell:Dt(t,i,"neCell"),swCell:Dt(t,i,"swCell"),seCell:Dt(t,i,"seCell")},f=a?.noHBand!==true,m=a?.noVBand!==true,b=0,g=e.rows.length,S=o?.length??e.rows[0]?.cells.reduce((k,E)=>k+(E.formatting?.gridSpan??1),0)??0,w=e.rows.map((k,E)=>{let R=E===0&&!!a?.firstRow,_=E===g-1&&!!a?.lastRow,V=f&&!R&&!_?b%2===0?p.band1Horz:p.band2Horz:void 0;return f&&!R&&!_&&b++,Qf(k,t,R,o,r,p,V,m,a,l,E,g,S,n,d)});return ye.node("table",c,w)}function Qf(e,t,n,o,r,i,a,s,l,u,d,c,p,f,m){let b={height:e.formatting?.height?.value,heightRule:e.formatting?.heightRule,isHeader:n||e.formatting?.header,_originalFormatting:e.formatting||void 0},g=e.cells.length,S=d===0,w=d===(c??1)-1,k=e.formatting?.conditionalFormat,E=k?.firstRow??S,R=k?.lastRow??w,_=p??g,V=0,$=[];for(let L=0;L<e.cells.length;L++){let W=e.cells[L],O=W.formatting?.gridSpan??1,K=`${d??0}-${V}`,C=f?.get(K),B=C?.skip??false,ee=C?.rowSpan??1,ge;if(o&&r&&r>0){let j=0;for(let J=0;J<O&&V+J<o.length;J++)j+=o[V+J];ge=Math.round(j/r*100);}if(V+=O,B)continue;let pe=V-O===0,Ee=V===_,Te=W.formatting?.conditionalFormat,Re=Te?.firstRow??E,P=Te?.lastRow??R,I=Te?.firstColumn??pe,y=Te?.lastColumn??Ee,M;if(s){let j=l?.firstColumn?1:0,J=V-O-j;J>=0&&!(l?.lastColumn&&y)&&!(l?.firstColumn&&I)&&(M=J%2===0?i?.band1Vert:i?.band2Vert);}Te?.oddVBand?M=i?.band1Vert:Te?.evenVBand&&(M=i?.band2Vert);let F=a;k?.oddHBand?F=i?.band1Horz:k?.evenHBand&&(F=i?.band2Horz),Te?.oddHBand?F=i?.band1Horz:Te?.evenHBand&&(F=i?.band2Horz);let D=i?.wholeTable;D=nn(D,F),D=nn(D,M),Re&&(l?.firstRow||k?.firstRow||Te?.firstRow)&&(D=nn(D,i?.firstRow)),P&&(l?.lastRow||k?.lastRow||Te?.lastRow)&&(D=nn(D,i?.lastRow)),I&&(l?.firstColumn||k?.firstColumn||Te?.firstColumn)&&(D=nn(D,i?.firstCol)),y&&(l?.lastColumn||k?.lastColumn||Te?.lastColumn)&&(D=nn(D,i?.lastCol)),Re&&I&&(l?.firstRow||k?.firstRow||Te?.firstRow)&&(l?.firstColumn||k?.firstColumn||Te?.firstColumn)&&(D=nn(D,i?.nwCell)),Re&&y&&(l?.firstRow||k?.firstRow||Te?.firstRow)&&(l?.lastColumn||k?.lastColumn||Te?.lastColumn)&&(D=nn(D,i?.neCell)),P&&I&&(l?.lastRow||k?.lastRow||Te?.lastRow)&&(l?.firstColumn||k?.firstColumn||Te?.firstColumn)&&(D=nn(D,i?.swCell)),P&&y&&(l?.lastRow||k?.lastRow||Te?.lastRow)&&(l?.lastColumn||k?.lastColumn||Te?.lastColumn)&&(D=nn(D,i?.seCell)),$.push(em(W,t,n,ge,D,u,S,w,pe,Ee,ee,m));}return ye.node("tableRow",b,$)}function em(e,t,n,o,r,i,a,s,l,u,d,c){let p=e.formatting,f=d??1,m=p?.width?.value,b=p?.width?.type;m===void 0&&o!==void 0&&(m=o,b="pct");let g=p?.shading?.fill?.rgb??r?.tcPr?.shading?.fill?.rgb,S=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,w=r?.tcPr?.borders,k=p?.borders,E=S||w||k?{...S??{},...w??{},...k??{}}:void 0,R={colspan:p?.gridSpan??1,rowspan:f,width:m,widthType:b,verticalAlign:p?.verticalAlign,backgroundColor:g,textDirection:p?.textDirection,noWrap:p?.noWrap,borders:E,margins:p?.margins?{top:p.margins.top?.value,bottom:p.margins.bottom?.value,left:p.margins.left?.value,right:p.margins.right?.value}:r?.tcPr?.margins?{top:r.tcPr.margins.top?.value,bottom:r.tcPr.margins.bottom?.value,left:r.tcPr.margins.left?.value,right:r.tcPr.margins.right?.value}:c,_originalFormatting:p||void 0},_=[];for(let $ of e.content)$.type==="paragraph"?_.push(xr($,t,void 0,r?.rPr)):$.type==="table"&&_.push(La($,t));_.length===0&&_.push(ye.node("paragraph",{},[]));let V=n?"tableHeader":"tableCell";return ye.node(V,R,_)}function tm(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=on(t,o),a=Da(i);return ye.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 nm(e){return ye.node("math",{display:e.display,ommlXml:e.ommlXml,plainText:e.plainText||""})}function om(e,t,n){let o=e.properties,r=[];for(let i of e.content)if(i.type==="run"){let a=Ba(i,t,n);r.push(...a);}else if(i.type==="hyperlink"){let a=Aa(i,t,n);r.push(...a);}return ye.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 Ba(e,t,n){let o=[],r=e.formatting?.styleId?n?.getRunStyleOwnProperties(e.formatting.styleId):void 0,i=on(on(t,r),e.formatting),a=Da(i);for(let s of e.content){let l=rm(s,a);o.push(...l);}return o}function on(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 rm(e,t){switch(e.type){case "text":return e.text?[ye.text(e.text,t)]:[];case "break":return e.breakType==="textWrapping"||!e.breakType?[ye.node("hardBreak")]:[];case "tab":return [ye.node("tab")];case "drawing":return e.image?[im(e.image)]:[];case "shape":{let r=e.shape;return r.textBody&&r.textBody.content.length>0?[]:[am(r)]}case "footnoteRef":let n=ye.mark("footnoteRef",{id:e.id.toString(),noteType:"footnote"});return [ye.text(e.id.toString(),[...t,n])];case "endnoteRef":let o=ye.mark("footnoteRef",{id:e.id.toString(),noteType:"endnote"});return [ye.text(e.id.toString(),[...t,o])];default:return []}}function im(e){let t=e.size?.width?chunkC33XDRDJ_cjs.c(e.size.width):void 0,n=e.size?.height?chunkC33XDRDJ_cjs.c(e.size.height):void 0,o=e.wrap.type,r=e.wrap.wrapText,i=e.position?.horizontal?.alignment,a;o==="inline"||o==="topAndBottom"?a="none":o==="square"||o==="tight"||o==="through"?r==="left"?a="right":r==="right"||i==="left"?a="left":i==="right"?a="right":a="none":a="none";let s="inline";o==="inline"?s="inline":a&&a!=="none"?s="float":s="block";let l;if(e.transform){let S=[];e.transform.rotation&&S.push(`rotate(${e.transform.rotation}deg)`),e.transform.flipH&&S.push("scaleX(-1)"),e.transform.flipV&&S.push("scaleY(-1)"),S.length>0&&(l=S.join(" "));}let u=e.wrap.distT?chunkC33XDRDJ_cjs.c(e.wrap.distT):void 0,d=e.wrap.distB?chunkC33XDRDJ_cjs.c(e.wrap.distB):void 0,c=e.wrap.distL?chunkC33XDRDJ_cjs.c(e.wrap.distL):void 0,p=e.wrap.distR?chunkC33XDRDJ_cjs.c(e.wrap.distR):void 0,f;e.position&&(f={horizontal:e.position.horizontal?{relativeTo:e.position.horizontal.relativeTo,posOffset:e.position.horizontal.posOffset,align:e.position.horizontal.alignment}:void 0,vertical:e.position.vertical?{relativeTo:e.position.vertical.relativeTo,posOffset:e.position.vertical.posOffset,align:e.position.vertical.alignment}:void 0});let m,b,g;if(e.outline&&e.outline.width){m=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(b=`#${e.outline.color.rgb}`);let S={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&&S[e.outline.style]||"solid";}return ye.node("image",{src:e.src||"",alt:e.alt,title:e.title,width:t,height:n,rId:e.rId,wrapType:o,displayMode:s,cssFloat:a,transform:l,distTop:u,distBottom:d,distLeft:c,distRight:p,position:f,borderWidth:m,borderColor:b,borderStyle:g,wrapText:r})}function Aa(e,t,n){let o=[],r=e.href||(e.anchor?`#${e.anchor}`:""),i=ye.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=on(on(t,s),a.formatting),d=[...Da(l),i];for(let c of a.content)c.type==="text"&&c.text&&o.push(ye.text(c.text,d));}return o}function Da(e){if(!e)return [];let t=[];return e.bold&&t.push(ye.mark("bold")),e.italic&&t.push(ye.mark("italic")),e.underline&&e.underline.style!=="none"&&t.push(ye.mark("underline",{style:e.underline.style,color:e.underline.color})),(e.strike||e.doubleStrike)&&t.push(ye.mark("strike",{double:e.doubleStrike||false})),e.color&&!e.color.auto&&t.push(ye.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(ye.mark("highlight",{color:e.highlight})),e.fontSize&&t.push(ye.mark("fontSize",{size:e.fontSize})),e.fontFamily&&t.push(ye.mark("fontFamily",{ascii:e.fontFamily.ascii,hAnsi:e.fontFamily.hAnsi,asciiTheme:e.fontFamily.asciiTheme})),e.vertAlign==="superscript"?t.push(ye.mark("superscript")):e.vertAlign==="subscript"&&t.push(ye.mark("subscript")),e.allCaps&&t.push(ye.mark("allCaps")),e.smallCaps&&t.push(ye.mark("smallCaps")),(e.spacing!=null||e.position!=null||e.scale!=null||e.kerning!=null)&&t.push(ye.mark("characterSpacing",{spacing:e.spacing??null,position:e.position??null,scale:e.scale??null,kerning:e.kerning??null})),e.emboss&&t.push(ye.mark("emboss")),e.imprint&&t.push(ye.mark("imprint")),e.shadow&&t.push(ye.mark("textShadow")),e.emphasisMark&&e.emphasisMark!=="none"&&t.push(ye.mark("emphasisMark",{type:e.emphasisMark})),e.outline&&t.push(ye.mark("textOutline")),t}function am(e){let t=e.size?.width?chunkC33XDRDJ_cjs.c(e.size.width):100,n=e.size?.height?chunkC33XDRDJ_cjs.c(e.size.height):80,o,r="solid",i,a,s;if(e.fill&&(r=e.fill.type,e.fill.color?.rgb&&(o=`#${e.fill.color.rgb}`),e.fill.type==="gradient"&&e.fill.gradient)){let p=e.fill.gradient;i=p.type,a=p.angle,s=JSON.stringify(p.stops.map(f=>({position:f.position,color:f.color.rgb?`#${f.color.rgb}`:"#000000"})));}let l,u,d;e.outline&&(e.outline.width&&(l=Math.round(e.outline.width/914400*96*100)/100),e.outline.color?.rgb&&(u=`#${e.outline.color.rgb}`),d=e.outline.style||"solid");let c;if(e.transform){let p=[];e.transform.rotation&&p.push(`rotate(${e.transform.rotation}deg)`),e.transform.flipH&&p.push("scaleX(-1)"),e.transform.flipV&&p.push("scaleY(-1)"),p.length>0&&(c=p.join(" "));}return ye.node("shape",{shapeType:e.shapeType||"rect",shapeId:e.id,width:t,height:n,fillColor:o,fillType:r,gradientType:i,gradientAngle:a,gradientStops:s,outlineWidth:l,outlineColor:u,outlineStyle:d,transform:c})}function Nc(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 zc(e,t){let n=e.size?.width?chunkC33XDRDJ_cjs.c(e.size.width):200,o=e.size?.height?chunkC33XDRDJ_cjs.c(e.size.height):void 0,r;e.fill?.color?.rgb&&(r=`#${e.fill.color.rgb}`);let i,a,s;e.outline&&e.outline.width&&(i=Math.round(e.outline.width/914400*96*100)/100,e.outline.color?.rgb&&(a=`#${e.outline.color.rgb}`),s=e.outline.style||"solid");let l=e.margins?.top!=null?chunkC33XDRDJ_cjs.c(e.margins.top):4,u=e.margins?.bottom!=null?chunkC33XDRDJ_cjs.c(e.margins.bottom):4,d=e.margins?.left!=null?chunkC33XDRDJ_cjs.c(e.margins.left):7,c=e.margins?.right!=null?chunkC33XDRDJ_cjs.c(e.margins.right):7,p=[];for(let f of e.content)p.push(xr(f,t));return p.length===0&&p.push(ye.node("paragraph",{},[])),ye.node("textBox",{width:n,height:o,textBoxId:e.id,fillColor:r,outlineWidth:i,outlineColor:a,outlineStyle:s,marginTop:l,marginBottom:u,marginLeft:d,marginRight:c},p)}function Ha(e,t){let n=[],o=t?.styles?Sn(t.styles):null;for(let r of e)if(r.type==="paragraph"){let i=Nc(r);n.push(xr(r,o));for(let a of i)n.push(zc(a,o));}else r.type==="table"&&n.push(La(r,o));return n.length===0&&n.push(ye.node("paragraph",{},[])),ye.node("doc",null,n)}function sm(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 Sr(){return ye.node("doc",null,[ye.node("paragraph",{},[])])}function kr(e,t){let o={content:$c(e),finalSectionProperties:t?.package.document.finalSectionProperties,sections:t?.package.document.sections,comments:t?.package.document.comments};return t?{...t,package:{...t.package,document:o}}:{package:{document:o}}}function $c(e){let t=[],n=_c(e);return e.forEach(o=>{o.type.name==="paragraph"?t.push(Na(o,n)):o.type.name==="table"?t.push(jc(o,n)):o.type.name==="textBox"?t.push(Mm(o)):o.type.name==="pageBreak"&&t.push(lm());}),t}function lm(){return {type:"paragraph",content:[{type:"run",content:[{type:"break",breakType:"page"}]}]}}function Na(e,t){let n=e.attrs,o=cm(Wc(e,t),e),r=n.bookmarks;if(r&&r.length>0){let a=r.map(l=>({type:"bookmarkStart",id:l.id,name:l.name})),s=r.map(l=>({type:"bookmarkEnd",id:l.id}));o=[...a,...o,...s];}let i={type:"paragraph",paraId:n.paraId||void 0,textId:n.textId||void 0,formatting:dm(n),content:o};return n.sectionBreakType&&(i.sectionProperties={sectionStart:n.sectionBreakType}),i}function cm(e,t){let n=new Set;if(t.forEach(a=>{for(let s of a.marks)s.type.name==="comment"&&n.add(s.attrs.commentId);}),n.size===0)return e;let o=[],r=new Set,i=0;t.forEach(a=>{let s=new Set;for(let l of a.marks)l.type.name==="comment"&&s.add(l.attrs.commentId);for(let l of [...r])s.has(l)||(o.push({type:"commentRangeEnd",id:l}),r.delete(l));for(let l of s)r.has(l)||(o.push({type:"commentRangeStart",id:l}),r.add(l));i<e.length&&o.push(e[i]),i++;});for(let a of r)o.push({type:"commentRangeEnd",id:a});return o}function dm(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 Wc(e,t){let n=[],o=t??_c(e),r=null,i=null,a=null;return e.forEach(s=>{let l=s.marks.find(p=>p.type.name==="footnoteRef");if(l){r&&(n.push(r),r=null,i=null),a&&(n.push(a),a=null);let f={type:l.attrs.noteType==="endnote"?"endnoteRef":"footnoteRef",id:parseInt(l.attrs.id,10)||0};n.push({type:"run",content:[f]});return}let u=s.marks.find(p=>p.type.name==="insertion"),d=s.marks.find(p=>p.type.name==="deletion");if(u||d){r&&(n.push(r),r=null,i=null),a&&(n.push(a),a=null);let p=u||d,f=s.marks.filter(R=>R.type.name!=="insertion"&&R.type.name!=="deletion"),m=za(f),b={type:"run",content:s.isText&&s.text?[{type:"text",text:s.text}]:[],...Object.keys(m).length>0?{formatting:m}:{}},g={id:p.attrs.revisionId,author:p.attrs.author||"Unknown",date:p.attrs.date||void 0},S=g.id,w=(o.insertionById.get(S)??0)>0,k=(o.deletionById.get(S)??0)>0,E=w&&k;u?E?n.push({type:"moveTo",info:g,content:[b]}):n.push({type:"insertion",info:g,content:[b]}):E?n.push({type:"moveFrom",info:g,content:[b]}):n.push({type:"deletion",info:g,content:[b]});return}let c=s.marks.find(p=>p.type.name==="hyperlink");if(c){let p=um(c),f=a?.href||(a?.anchor?`#${a.anchor}`:"");a&&f===p||(r&&(n.push(r),r=null,i=null),a&&n.push(a),a=fm(c)),Oc(a,s);return}if(a&&(n.push(a),a=null),s.isText){let p=pm(s.marks);r&&i===p?mm(r,s.text||""):(r&&n.push(r),r=Vc(s.text||"",s.marks),i=p);}else s.type.name==="hardBreak"?(r&&(n.push(r),r=null,i=null),n.push(gm())):s.type.name==="image"?(r&&(n.push(r),r=null,i=null),n.push(Sm(s))):s.type.name==="shape"?(r&&(n.push(r),r=null,i=null),n.push(km(s))):s.type.name==="tab"?(r&&(n.push(r),r=null,i=null),n.push(hm())):s.type.name==="field"?(r&&(n.push(r),r=null,i=null),n.push(bm(s,s.marks))):s.type.name==="sdt"?(r&&(n.push(r),r=null,i=null),n.push(xm(s))):s.type.name==="math"&&(r&&(n.push(r),r=null,i=null),n.push(ym(s)));}),r&&n.push(r),a&&n.push(a),n}function _c(e){let t=new Map,n=new Map;return e.descendants(o=>{let r=o.marks.find(a=>a.type.name==="insertion"),i=o.marks.find(a=>a.type.name==="deletion");if(r){let a=Number(r.attrs.revisionId);Number.isFinite(a)&&t.set(a,(t.get(a)??0)+1);}if(i){let a=Number(i.attrs.revisionId);Number.isFinite(a)&&n.set(a,(n.get(a)??0)+1);}}),{insertionById:t,deletionById:n}}function um(e){return e.attrs.href||""}function pm(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 fm(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 Oc(e,t){if(t.isText&&t.text){let n=t.marks.filter(r=>r.type.name!=="hyperlink"),o=Vc(t.text,n);e.children.push(o);}}function Vc(e,t){let n=za(t),o={type:"text",text:e};return {type:"run",formatting:Object.keys(n).length>0?n:void 0,content:[o]}}function mm(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 gm(){return {type:"run",content:[{type:"break",breakType:"textWrapping"}]}}function hm(){return {type:"run",content:[{type:"tab"}]}}function bm(e,t){let n=e.attrs,o=t&&t.length>0?za(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 ym(e){let t=e.attrs;return {type:"mathEquation",display:t.display||"inline",ommlXml:t.ommlXml,plainText:t.plainText||void 0}}function xm(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=Wc(e).filter(i=>i.type==="run"||i.type==="hyperlink");return {type:"inlineSdt",properties:n,content:r}}function Sm(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:chunkC33XDRDJ_cjs.d(t.width||0),height:chunkC33XDRDJ_cjs.d(t.height||0)},wrap:r};if(t.transform){let s=t.transform,l={},u=s.match(/rotate\(([-\d.]+)deg\)/);u&&(l.rotation=parseFloat(u[1])),s.includes("scaleX(-1)")&&(l.flipH=true),s.includes("scaleY(-1)")&&(l.flipV=true),(l.rotation||l.flipH||l.flipV)&&(i.transform=l);}if(t.position?.horizontal&&t.position?.vertical){let s=t.position;i.position={horizontal:{relativeTo:s.horizontal.relativeTo||"column",alignment:s.horizontal.align,posOffset:s.horizontal.posOffset},vertical:{relativeTo:s.vertical.relativeTo||"paragraph",alignment:s.vertical.align,posOffset:s.vertical.posOffset}};}if(t.borderWidth&&t.borderWidth>0){let s={solid:"solid",dotted:"dot",dashed:"dash",double:"solid",groove:"solid",ridge:"solid",inset:"solid",outset:"solid"};i.outline={width:Math.round(t.borderWidth*(914400/96)),color:t.borderColor?{rgb:t.borderColor.replace("#","")}:void 0,style:t.borderStyle&&s[t.borderStyle]||"solid"};}return {type:"run",content:[{type:"drawing",image:i}]}}function km(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 za(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 wm(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 jc(e,t){let n=e.attrs,o=[];e.forEach(i=>{i.type.name==="tableRow"&&o.push(Tm(i,t));});let r=Cm(n)||void 0;if(!r?.borders){let i=wm(o);if(i)if(r)r.borders=i;else return {type:"table",columnWidths:n.columnWidths||void 0,formatting:{borders:i},rows:o}}return {type:"table",columnWidths:n.columnWidths||void 0,formatting:r,rows:o}}function Cm(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 Tm(e,t){let n=e.attrs,o=[];return e.forEach(r=>{(r.type.name==="tableCell"||r.type.name==="tableHeader")&&o.push(Rm(r,t));}),{type:"tableRow",formatting:vm(n),cells:o}}function vm(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 Rm(e,t){let n=e.attrs,o=[];return e.forEach(r=>{r.type.name==="paragraph"?o.push(Na(r,t)):r.type.name==="table"&&o.push(jc(r,t));}),{type:"tableCell",formatting:Pm(n),content:o}}function Pm(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 Mm(e){let t=e.attrs,n=[];e.forEach(a=>{a.type.name==="paragraph"&&n.push(Na(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 Io(e){return $c(e)}function so(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,S,w)=>{S<=o&&(s=w),S<=r&&(l=w);});let u={},d=a.parent,c=d.type.name==="paragraph"&&d.textContent.length===0,p=d.attrs?.defaultTextFormatting,f=e.storedMarks||t.$from.marks();c&&f.length===0&&p&&(u={...p});for(let g of f)switch(g.type.name){case "bold":u.bold=true;break;case "italic":u.italic=true;break;case "underline":u.underline={style:g.attrs.style||"single",color:g.attrs.color};break;case "strike":g.attrs.double?u.doubleStrike=true:u.strike=true;break;case "textColor":u.color={rgb:g.attrs.rgb,themeColor:g.attrs.themeColor};break;case "highlight":u.highlight=g.attrs.color;break;case "fontSize":u.fontSize=g.attrs.size;break;case "fontFamily":u.fontFamily={ascii:g.attrs.ascii,hAnsi:g.attrs.hAnsi};break;case "superscript":u.vertAlign="superscript";break;case "subscript":u.vertAlign="subscript";break}let m={},b=null;return d.type.name==="paragraph"&&(d.attrs.alignment&&(m.alignment=d.attrs.alignment),d.attrs.lineSpacing&&(m.lineSpacing=d.attrs.lineSpacing,m.lineSpacingRule=d.attrs.lineSpacingRule),d.attrs.numPr&&(m.numPr=d.attrs.numPr),d.attrs.indentLeft&&(m.indentLeft=d.attrs.indentLeft),d.attrs.indentRight&&(m.indentRight=d.attrs.indentRight),d.attrs.indentFirstLine&&(m.indentFirstLine=d.attrs.indentFirstLine),d.attrs.hangingIndent&&(m.hangingIndent=d.attrs.hangingIndent),d.attrs.tabs&&(m.tabs=d.attrs.tabs),d.attrs.styleId&&(b=d.attrs.styleId)),{hasSelection:!i,isMultiParagraph:s!==l,textFormatting:u,paragraphFormatting:m,styleId:b,startParagraphIndex:s,endParagraphIndex:l}}var St=_n.getCommands(),wr=St.toggleBold(),Cr=St.toggleItalic(),Tr=St.toggleUnderline(),vr=St.toggleStrike(),Rr=St.toggleSuperscript(),Pr=St.toggleSubscript();function Mr(e){return St.setTextColor(e)}St.clearTextColor();function Er(e){return St.setHighlight(e)}St.clearHighlight();function Ir(e){return St.setFontSize(e)}St.clearFontSize();function Fr(e){return St.setFontFamily(e)}St.clearFontFamily();function Lr(e,t){return St.setHyperlink(e,t)}var Br=St.removeHyperlink();function Fo(e,t,n){return St.insertHyperlink(e,t,n)}var Je=_n.getCommands();function Ar(e){return Je.setAlignment(e)}Je.alignLeft();Je.alignCenter();Je.alignRight();Je.alignJustify();function Dr(e,t="auto"){return Je.setLineSpacing(e,t)}Je.singleSpacing();Je.oneAndHalfSpacing();Je.doubleSpacing();function Hr(e=720){return Je.increaseIndent(e)}function Nr(e=720){return Je.decreaseIndent(e)}function zr(e){return Je.setIndentLeft(e)}function Or(e){return Je.setIndentRight(e)}function Lo(e,t){return Je.setIndentFirstLine(e,t)}var $r=Je.toggleBulletList(),Wr=Je.toggleNumberedList(),_r=Je.increaseListLevel(),Vr=Je.decreaseListLevel();Je.removeList();function Bo(e,t){return Je.applyStyle(e,t)}Je.clearStyle();Je.removeSectionBreak();function jr(e){return Je.removeTabStop(e)}var Ur=Je.generateTOC();var je=_n.getCommands();function Gr(e,t){return je.insertTable(e,t)}function Kr(e,t){return je.addRowAbove()(e,t)}function Yr(e,t){return je.addRowBelow()(e,t)}function qr(e,t){return je.deleteRow()(e,t)}function Xr(e,t){return je.addColumnLeft()(e,t)}function Zr(e,t){return je.addColumnRight()(e,t)}function Jr(e,t){return je.deleteColumn()(e,t)}function Ao(e,t){return je.deleteTable()(e,t)}function Qr(e,t){return je.selectTable()(e,t)}function ei(e,t){return je.selectRow()(e,t)}function ti(e,t){return je.selectColumn()(e,t)}function ni(e,t){return je.mergeCells()(e,t)}function oi(e,t){return je.splitCell()(e,t)}function kn(e,t){return je.setCellBorder(e,t)}function ri(e,t){return je.removeTableBorders()(e,t)}function ii(e,t,n){return je.setAllTableBorders(n)(e,t)}function ai(e,t,n){return je.setOutsideTableBorders(n)(e,t)}function si(e,t,n){return je.setInsideTableBorders(n)(e,t)}function li(e){return je.setCellVerticalAlign(e)}function ci(e){return je.setCellMargins(e)}function di(e){return je.setCellTextDirection(e)}function ui(){return je.toggleNoWrap()}function pi(e,t){return je.setRowHeight(e,t)}function fi(){return je.toggleHeaderRow()}function mi(){return je.distributeColumns()}function gi(){return je.autoFitContents()}function Do(e){return je.setTableProperties(e)}function hi(e){return je.applyTableStyle(e)}function bi(e){return je.setCellFillColor(e)}function yi(e){return je.setTableBorderColor(e)}function xi(e){return je.setTableBorderWidth(e)}var Si=(e,t)=>{let{schema:n}=e,o=n.nodes.pageBreak,r=n.nodes.paragraph;if(!o||!r)return false;if(t){let{$from:i}=e.selection,a=e.tr,s=o.create(),l=s.nodeSize,u;if(i.parent.isTextblock)if(i.parentOffset>0&&i.parentOffset<i.parent.content.size){a.split(i.pos);let d=a.mapping.map(i.pos);a.insert(d,prosemirrorModel.Fragment.from([s,r.create()])),u=d+l+1;}else if(i.parentOffset===i.parent.content.size){let d=i.after();a.insert(d,prosemirrorModel.Fragment.from([s,r.create()])),u=d+l+1;}else {let d=i.before();a.insert(d,s),u=d+l+1;}else {let d=i.pos;a.insert(d,prosemirrorModel.Fragment.from([s,r.create()])),u=d+l+1;}a.setSelection(prosemirrorState.TextSelection.create(a.doc,u)),t(a.scrollIntoView());}return true};function sd(e,t,n){return (o,r)=>{let i=o.schema.marks.insertion,a=o.schema.marks.deletion;if(!i&&!a)return false;let s=n==="accept"?i:a,l=n==="accept"?a:i;if(r){let u=o.tr,d=[];o.doc.nodesBetween(e,t,(c,p)=>{if(!c.isText)return;let f=p+c.nodeSize,m=Math.max(e,p),b=Math.min(t,f);l&&c.marks.some(g=>g.type===l)&&d.push({from:m,to:b}),s&&c.marks.some(g=>g.type===s)&&u.removeMark(m,b,s);});for(let c of d.reverse())u.delete(c.from,c.to);u.steps.length>0&&r(u);}return true}}function $a(e,t){return sd(e,t,"accept")}function Wa(e,t){return sd(e,t,"reject")}var cd={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"2px 0",fontSize:11,color:"#4285f4",userSelect:"none"},dd={fontWeight:500,letterSpacing:.3},Gm={background:"none",border:"none",color:"#4285f4",cursor:"pointer",fontSize:11,padding:"2px 6px",borderRadius:3},Km={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"},ki={display:"block",width:"100%",padding:"6px 12px",border:"none",background:"none",textAlign:"left",cursor:"pointer",fontSize:12,color:"#3c4043"},pd=Mu.forwardRef(function({headerFooter:t,position:n,styles:o,targetElement:r,parentElement:i,onSave:a,onClose:s,onSelectionChange:l,onRemove:u},d){let c=Mu.useRef(null),p=Mu.useRef(null),[f,m]=Mu.useState(false),[b,g]=Mu.useState(false),S=Mu.useRef(null),[w,k]=Mu.useState(null);Mu.useLayoutEffect(()=>{let $=()=>{let W=i.getBoundingClientRect(),O=r.getBoundingClientRect();k({top:O.top-W.top+i.scrollTop,left:O.left-W.left+i.scrollLeft,width:O.width});};$();let L=i.closest('[style*="overflow"]')||i;return L.addEventListener("scroll",$),window.addEventListener("resize",$),()=>{L.removeEventListener("scroll",$),window.removeEventListener("resize",$);}},[r,i]),Mu.useEffect(()=>{if(!c.current||p.current)return;let $=Ha(t.content,{styles:o||void 0}),L=new xn(ao());L.buildSchema(),L.initializeRuntime();let W=L.getPlugins(),O=prosemirrorState.EditorState.create({doc:$,schema:ye,plugins:W}),K=new prosemirrorView.EditorView(c.current,{state:O,dispatchTransaction(C){let B=K.state.apply(C);if(K.updateState(B),C.docChanged&&m(true),C.selectionSet||C.docChanged){let ee=so(B);l?.(ee);}}});return p.current=K,requestAnimationFrame(()=>{K.focus();let C=so(K.state);l?.(C);}),()=>{K.destroy(),p.current=null;}},[w]);let E=Mu.useCallback(()=>{if(!p.current)return;let $=Io(p.current.state.doc);a($);},[a]),R=Mu.useCallback(()=>{f?E():s();},[f,E,s]);Mu.useEffect(()=>{function $(L){L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),R());}return document.addEventListener("keydown",$,true),()=>document.removeEventListener("keydown",$,true)},[R]),Mu.useEffect(()=>{if(!b)return;function $(L){S.current&&!S.current.contains(L.target)&&g(false);}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[b]),Mu.useImperativeHandle(d,()=>({getView:()=>p.current,focus:()=>p.current?.focus(),undo:()=>{let $=p.current;return $?prosemirrorHistory.undo($.state,$.dispatch):false},redo:()=>{let $=p.current;return $?prosemirrorHistory.redo($.state,$.dispatch):false}}));let _=n==="header"?"Header":"Footer";if(!w)return null;let V={position:"absolute",top:w.top,left:w.left,width:w.width,zIndex:10};return jsxRuntime.jsxs("div",{className:"hf-inline-editor",style:V,onMouseDown:$=>{$.stopPropagation();},children:[n==="footer"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:cd,children:[jsxRuntime.jsx("span",{style:dd,children:_}),jsxRuntime.jsx(ud,{label:_,showOptions:b,setShowOptions:g,optionsRef:S,onRemove:u,onClose:R,viewRef:p})]}),jsxRuntime.jsx("div",{ref:c,className:"hf-editor-pm",style:{minHeight:40,outline:"none"}}),n==="header"&&jsxRuntime.jsxs("div",{className:"hf-separator-bar",style:cd,children:[jsxRuntime.jsx("span",{style:dd,children:_}),jsxRuntime.jsx(ud,{label:_,showOptions:b,setShowOptions:g,optionsRef:S,onRemove:u,onClose:R,viewRef:p})]})]})});function ud({label:e,showOptions:t,setShowOptions:n,optionsRef:o,onRemove:r,onClose:i,viewRef:a}){let s=l=>{let u=a.current;if(!u)return;let{$from:d,from:c}=u.state.selection,p=u.state.storedMarks||d.marks(),f=ye.nodes.field.create({fieldType:l,instruction:` ${l} \\* MERGEFORMAT `,fieldKind:"simple",dirty:true}),m=u.state.tr.insert(c,f.mark(p));u.dispatch(m),u.focus();};return jsxRuntime.jsxs("div",{style:{position:"relative"},ref:o,children:[jsxRuntime.jsx("button",{type:"button",style:Gm,onClick:l=>{l.stopPropagation(),n(u=>!u);},onMouseDown:l=>l.stopPropagation(),children:"Options \u25BE"}),t&&jsxRuntime.jsxs("div",{style:Km,children:[jsxRuntime.jsx("button",{type:"button",style:ki,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:ki,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:ki,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:ki,onClick:()=>{n(false),i();},onMouseOver:l=>{l.target.style.backgroundColor="#f1f3f4";},onMouseOut:l=>{l.target.style.backgroundColor="transparent";},children:["Close ",e.toLowerCase()," editing"]})]})]})}var ke=e=>({style:"single",size:4,color:{rgb:e}}),Ym=[{id:"TableNormal",name:"Normal Table",look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGrid",name:"Table Grid",tableBorders:{top:ke("000000"),bottom:ke("000000"),left:ke("000000"),right:ke("000000"),insideH:ke("000000"),insideV:ke("000000")},look:{firstRow:false,lastRow:false,noHBand:true,noVBand:true}},{id:"TableGridLight",name:"Grid Table Light",tableBorders:{top:ke("BFBFBF"),bottom:ke("BFBFBF"),left:ke("BFBFBF"),right:ke("BFBFBF"),insideH:ke("BFBFBF"),insideV:ke("BFBFBF")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:ke("000000")}}}},{id:"PlainTable1",name:"Plain Table 1",tableBorders:{top:ke("BFBFBF"),bottom:ke("BFBFBF"),insideH:ke("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:ke("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:ke("B4C6E7"),bottom:ke("B4C6E7"),left:ke("B4C6E7"),right:ke("B4C6E7"),insideH:ke("B4C6E7"),insideV:ke("B4C6E7")},look:{firstRow:true,lastRow:false,noHBand:true,noVBand:true},conditionals:{firstRow:{bold:true,borders:{bottom:ke("4472C4")}}}},{id:"GridTable4-Accent1",name:"Grid Table 4 Accent 1",tableBorders:{top:ke("4472C4"),bottom:ke("4472C4"),left:ke("4472C4"),right:ke("4472C4"),insideH:ke("4472C4"),insideV:ke("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:ke("FFFFFF"),bottom:ke("FFFFFF"),left:ke("FFFFFF"),right:ke("FFFFFF"),insideH:ke("FFFFFF"),insideV:ke("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:ke("ED7D31"),bottom:ke("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:ke("A5A5A5"),bottom:ke("A5A5A5"),insideH:ke("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:ke("5B9BD5"),bottom:ke("5B9BD5"),left:ke("5B9BD5"),right:ke("5B9BD5"),insideH:ke("5B9BD5"),insideV:ke("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:ke("70AD47"),bottom:ke("70AD47"),left:ke("70AD47"),right:ke("70AD47"),insideH:ke("70AD47"),insideV:ke("70AD47")},look:{firstRow:true,lastRow:false,noHBand:false,noVBand:true},conditionals:{firstRow:{bold:true,color:"#FFFFFF",backgroundColor:"#70AD47"},band1Horz:{backgroundColor:"#E2EFDA"}}}];function fd(e){return Ym.find(t=>t.id===e)}function md(){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 gd(){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 hd({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 Xm(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Zm(e,t={}){let{maxEntries:n=100,groupingInterval:o=500,enableKeyboardShortcuts:r=true,isEqual:i=Xm,onUndo:a,onRedo:s,containerRef:l}=t,[u,d]=Mu.useState(e),[c,p]=Mu.useState([]),[f,m]=Mu.useState([]),b=Mu.useRef(0),g=Mu.useRef(false),S=Mu.useCallback((L,W)=>{if(i(u,L))return;if(g.current){d(L);return}let O=Date.now();O-b.current<o&&c.length>0?p(C=>{let B=[...C];return B[B.length-1]={state:u,timestamp:O,description:W||B[B.length-1].description},B}):p(C=>{let B={state:u,timestamp:O,description:W},ee=[...C,B];return ee.length>n?ee.slice(ee.length-n):ee}),m([]),d(L),b.current=O;},[u,i,o,n,c.length]),w=Mu.useCallback(()=>{if(c.length===0)return;g.current=true;let L=c[c.length-1];return p(W=>W.slice(0,-1)),m(W=>[...W,{state:u,timestamp:Date.now()}]),d(L.state),setTimeout(()=>{g.current=false;},0),a?.(L.state),L.state},[c,u,a]),k=Mu.useCallback(()=>{if(f.length===0)return;g.current=true;let L=f[f.length-1];return m(W=>W.slice(0,-1)),p(W=>[...W,{state:u,timestamp:Date.now()}]),d(L.state),setTimeout(()=>{g.current=false;},0),s?.(L.state),L.state},[f,u,s]),E=Mu.useCallback(()=>{p([]),m([]);},[]),R=Mu.useCallback(L=>{d(L??e),p([]),m([]),b.current=0;},[e]),_=Mu.useCallback(()=>[...c],[c]),V=Mu.useCallback(()=>[...f],[f]),$=Mu.useCallback(L=>{d(W=>L(W)),p(W=>W.map(O=>({...O,state:L(O.state)}))),m(W=>W.map(O=>({...O,state:L(O.state)})));},[]);return Mu.useEffect(()=>{if(!r)return;let L=O=>{if((O.ctrlKey||O.metaKey)&&O.key==="z"&&!O.shiftKey){O.preventDefault(),w();return}if((O.ctrlKey||O.metaKey)&&O.key==="y"||(O.ctrlKey||O.metaKey)&&O.key==="z"&&O.shiftKey){O.preventDefault(),k();return}},W=l?.current||document;return W.addEventListener("keydown",L),()=>{W.removeEventListener("keydown",L);}},[r,w,k,l]),{state:u,canUndo:c.length>0,canRedo:f.length>0,undoCount:c.length,redoCount:f.length,push:S,undo:w,redo:k,clear:E,reset:R,getUndoStack:_,getRedoStack:V,transformAll:$}}function yd(e,t={}){let n=Mu.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 Zm(e,{...t,isEqual:n})}var wn=new prosemirrorState.PluginKey("suggestionMode"),wi="suggestionModeApplied",eg=Date.now();function Ci(e){return {revisionId:eg++,author:e.author,date:new Date().toISOString()}}function Ya(e,t,n,o){try{let r=e.resolve(t);for(let i of [r.nodeBefore,r.nodeAfter])if(i?.isText){let a=i.marks.find(s=>s.type.name===n&&s.attrs.author===o);if(a)return a.attrs}}catch{}return null}function kd(e,t,n,o,r,i,a){let s=[];if(t.nodesBetween(n,o,(u,d)=>{if(!u.isText)return;let c=Math.max(d,n),p=Math.min(d+u.nodeSize,o);if(c>=p)return;let f=u.marks.some(m=>m.type===r&&m.attrs.author===a.author);s.push({from:c,to:p,isOwnInsert:f});}),s.length===0)return;let l=Ya(t,n,"deletion",a.author)||Ci(a);for(let u=s.length-1;u>=0;u--){let d=s[u];d.isOwnInsert?e.delete(d.from,d.to):e.addMark(d.from,d.to,i.create(l));}}function xd(e,t,n,o,r){let i=e.state.schema.marks.insertion;if(!i)return false;let a=e.state.tr;a.setMeta(wi,true);let s=Ya(e.state.doc,t,"insertion",r.author)||Ci(r);if(t!==n){let u=e.state.schema.marks.deletion;u&&kd(a,e.state.doc,t,n,i,u,r);}let l=a.mapping.map(n);return a.insertText(o,l,l),a.addMark(l,l+o.length,i.create(s)),e.dispatch(a.scrollIntoView()),true}function Sd(e,t,n){let o=wn.getState(e);if(!o?.active)return false;let{$from:r,$to:i,empty:a}=e.selection,s=e.schema.marks.insertion,l=e.schema.marks.deletion;if(!s||!l)return false;if(!t)return true;let u=e.tr;if(u.setMeta(wi,true),!a){kd(u,e.doc,r.pos,i.pos,s,l,o);let S=u.mapping.map(i.pos);return u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(S))),t(u.scrollIntoView()),true}let d=n==="backward",c=d?r.pos-1:r.pos,p=d?r.pos:r.pos+1;if(c<0||p>e.doc.content.size)return true;let m=e.doc.resolve(c).nodeAfter;if(!m?.isText)return false;let b=m.marks.some(S=>S.type===s&&S.attrs.author===o.author);if(m.marks.some(S=>S.type===l)){let S=d?c:p;u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(S)));}else if(b)u.delete(c,p);else {let S=Ya(e.doc,c,"deletion",o.author)||Ci(o);u.addMark(c,p,l.create(S));let w=d?c:p;u.setSelection(prosemirrorState.TextSelection.near(u.doc.resolve(w)));}return t(u.scrollIntoView()),true}function wd(e=false,t="User"){return new prosemirrorState.Plugin({key:wn,state:{init(){return {active:e,author:t}},apply(n,o){let r=n.getMeta(wn);return r?{...o,...r}:o}},props:{handleDOMEvents:{beforeinput(n,o){let r=wn.getState(n.state);if(!r?.active)return false;if(o.inputType==="insertText"&&o.data){o.preventDefault();let{from:i,to:a}=n.state.selection;return xd(n,i,a,o.data,r)}return false}},handleKeyDown(n,o){return wn.getState(n.state)?.active?o.key==="Backspace"?Sd(n.state,n.dispatch,"backward"):o.key==="Delete"?Sd(n.state,n.dispatch,"forward"):false:false},handleTextInput(n,o,r,i){let a=wn.getState(n.state);return a?.active?xd(n,o,r,i,a):false}},appendTransaction(n,o,r){let i=wn.getState(r);if(!i?.active)return null;let a=n.find(c=>c.docChanged&&!c.getMeta(wi));if(!a)return null;let s=r.schema.marks.insertion;if(!s)return null;let l=Ci(i),u=r.tr;u.setMeta(wi,true);let d=r.schema.marks.deletion;return a.steps.forEach(c=>{c.getMap().forEach((f,m,b,g)=>{g>b&&r.doc.nodesBetween(b,g,(S,w)=>{if(!S.isText)return;if(!S.marks.some(E=>E.type===s||d&&E.type===d)){let E=Math.max(w,b),R=Math.min(w+S.nodeSize,g);u.addMark(E,R,s.create(l));}});});}),u.steps.length>0?u:null}})}function Cd(e,t,n,o){if(n){let r={active:e};o!==void 0&&(r.author=o);let i=t.tr.setMeta(wn,r);n(i);}return true}var cg={position:"fixed",left:"-9999px",top:"0",opacity:0,zIndex:-1,pointerEvents:"none",userSelect:"none",overflowAnchor:"none"};function Pd(e,t,n,o=[]){let r=n?.getSchema()??ye,i=e?yr(e,{styles:t??void 0}):Sr(),a=[...o,...n?.getPlugins()??[]];return prosemirrorState.EditorState.create({doc:i,schema:r,plugins:a})}function dg(e,t){return t?kr(e.doc,t):null}var ug=Mu.forwardRef(function(t,n){let{document:o,styles:r,theme:i,widthPx:a=612,readOnly:s=false,onTransaction:l,onSelectionChange:u,externalPlugins:d=[],extensionManager:c,onEditorViewReady:p,onEditorViewDestroy:f,onKeyDown:m}=t,b=Mu.useRef(null),g=Mu.useRef(null),S=Mu.useRef(o),w=Mu.useRef(false),k=Mu.useRef(null),E=Mu.useRef(false),R=Mu.useRef(l),_=Mu.useRef(u),V=Mu.useRef(p),$=Mu.useRef(f),L=Mu.useRef(m);R.current=l,_.current=u,V.current=p,$.current=f,L.current=m,S.current=o;let W=Mu.useCallback(()=>{if(!b.current||w.current)return;let C={state:Pd(o,r,c,d),editable:()=>!s,dispatchTransaction:B=>{if(!g.current||w.current)return;let ee=g.current.state.apply(B);g.current.updateState(ee),R.current?.(B,ee),(B.selectionSet||B.docChanged)&&_.current?.(ee);},handleKeyDown:(B,ee)=>L.current?.(B,ee)??false,handleDOMEvents:{focus:()=>false,blur:()=>false}};g.current=new prosemirrorView.EditorView(b.current,C),V.current?.(g.current);},[o,r,d,c,s]),O=Mu.useCallback(()=>{g.current&&!w.current&&(w.current=true,$.current?.(),g.current.destroy(),g.current=null,w.current=false);},[]);return Mu.useEffect(()=>(W(),()=>O()),[]),Mu.useEffect(()=>{if(!g.current||w.current)return;let C=(ee=>{if(!ee)return "empty";let ge=ee.package?.properties;return `${ge?.created||""}-${ge?.modified||""}-${ge?.title||""}`})(o);if(E.current&&C===k.current)return;E.current=true,k.current=C;let B=Pd(o,r,c,d);g.current.updateState(B),_.current?.(B);},[o,r,c,d]),Mu.useEffect(()=>{g.current;},[s]),Mu.useImperativeHandle(n,()=>({getState(){return g.current?.state??null},getView(){return g.current??null},getDocument(){return g.current?dg(g.current.state,S.current):null},focus(){g.current?.focus();},blur(){g.current?.hasFocus()&&g.current.dom.blur();},isFocused(){return g.current?.hasFocus()??false},dispatch(K){g.current&&!w.current&&g.current.dispatch(K);},executeCommand(K){return g.current?K(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(K,C){if(!g.current)return;let{state:B,dispatch:ee}=g.current,ge=B.doc.resolve(K),pe=C!==void 0?B.doc.resolve(C):ge,Ee=prosemirrorState.TextSelection.between(ge,pe);ee(B.tr.setSelection(Ee));},setNodeSelection(K){if(!g.current)return;let{state:C,dispatch:B}=g.current;try{let ee=prosemirrorState.NodeSelection.create(C.doc,K);B(C.tr.setSelection(ee));}catch{this.setSelection(K);}},setCellSelection(K,C){if(!g.current)return;let{state:B,dispatch:ee}=g.current;try{let ge=prosemirrorTables.CellSelection.create(B.doc,K,C);ee(B.tr.setSelection(ge));}catch{this.setSelection(K,C);}},scrollToSelection(){}}),[]),jsxRuntime.jsx("div",{ref:b,className:"paged-editor__hidden-pm",style:{...cg,width:a>0?`${a}px`:void 0}})}),Md=Mu.memo(ug);var gg="#000",hg="rgba(66, 133, 244, 0.3)",bg=2,yg=530,xg={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:10,overflow:"hidden"},Sg=(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"}),kg=(e,t)=>({position:"absolute",left:e.x,top:e.y,width:e.width,height:e.height,backgroundColor:t,pointerEvents:"none"}),wg=({position:e,color:t,width:n,blinkInterval:o,isFocused:r})=>{let[i,a]=Mu.useState(r),s=Mu.useRef(null);return Mu.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]),Mu.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:Sg(e,t,n,i),"data-testid":"caret"})},Cg=({rect:e,color:t,index:n})=>jsxRuntime.jsx("div",{style:kg(e,t),"data-testid":`selection-rect-${n}`,"data-page-index":e.pageIndex}),Id=({selectionRects:e,caretPosition:t,isFocused:n,readOnly:o=false,caretColor:r=gg,selectionColor:i=hg,caretWidth:a=bg,blinkInterval:s=yg})=>{if(o)return null;let l=e.length>0,u=t!==null&&!l;return jsxRuntime.jsxs("div",{style:xg,"data-testid":"selection-overlay",children:[l&&e.map((d,c)=>jsxRuntime.jsx(Cg,{rect:d,color:i,index:c},`sel-${d.pageIndex}-${d.x}-${d.y}-${c}`)),u&&t&&jsxRuntime.jsx(wg,{position:t,color:r,width:a,blinkInterval:s,isFocused:n})]})};var Za=10,Cn=Za/2,zo=2,Ad="#2563eb",Ld={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:15,overflow:"visible"},vg={position:"absolute",border:`${zo}px solid ${Ad}`,pointerEvents:"none",boxSizing:"border-box"},Rg={position:"absolute",width:`${Za}px`,height:`${Za}px`,backgroundColor:Ad,border:"1px solid white",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",boxSizing:"border-box",pointerEvents:"auto",zIndex:16},Pg={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%)"},Mg={nw:"nw-resize",ne:"ne-resize",se:"se-resize",sw:"sw-resize"};function Eg(e,t,n,o,r,i){let a=e.includes("w")?-1:1,s=e.includes("n")?-1:1,l=o+t*a,u=r+n*s;if(i){let d=Math.max(l/o,u/r);l=o*d,u=r*d;}return {width:Math.max(20,Math.min(2e3,l)),height:Math.max(20,Math.min(2e3,u))}}function Dd({imageInfo:e,zoom:t,isFocused:n,onResize:o,onResizeStart:r,onResizeEnd:i,onDragMove:a,onDragStart:s,onDragEnd:l}){let[u,d]=Mu.useState(false),[c,p]=Mu.useState(false),[f,m]=Mu.useState(0),[b,g]=Mu.useState(0),[S,w]=Mu.useState(null),k=Mu.useRef(null),E=Mu.useRef(null),R=Mu.useRef(o),_=Mu.useRef(r),V=Mu.useRef(i),$=Mu.useRef(a),L=Mu.useRef(s),W=Mu.useRef(l);R.current=o,_.current=r,V.current=i,$.current=a,L.current=s,W.current=l;let O=Mu.useRef(e),K=Mu.useRef(t);O.current=e,K.current=t;let C=Mu.useCallback(()=>{if(!e||!E.current){w(null);return}let P=E.current.offsetParent;if(!P){w(null);return}let I=P.getBoundingClientRect(),y=e.element.getBoundingClientRect();w({left:(y.left-I.left)/t,top:(y.top-I.top)/t,width:y.width/t,height:y.height/t});},[e,t]);Mu.useEffect(()=>{C();},[C]),Mu.useEffect(()=>{if(!e)return;let P=E.current?.closest('[style*="overflow"]')??E.current?.closest(".paged-editor__container");if(!P)return;let I=()=>{k.current&&cancelAnimationFrame(k.current),k.current=requestAnimationFrame(C);};return P.addEventListener("scroll",I,{passive:true}),window.addEventListener("resize",I,{passive:true}),()=>{P.removeEventListener("scroll",I),window.removeEventListener("resize",I),k.current&&cancelAnimationFrame(k.current);}},[e,C]);let B=Mu.useCallback((P,I)=>{if(!e||!S)return;I.preventDefault(),I.stopPropagation();let y=S.width,M=S.height,F=I.clientX,D=I.clientY,j=Math.round(y),J=Math.round(M);d(true),m(j),g(J),_.current?.();let N=G=>{let xe=K.current,v=(G.clientX-F)/xe,z=(G.clientY-D)/xe,A=!G.shiftKey,te=Eg(P,v,z,y,M,A);j=Math.round(te.width),J=Math.round(te.height),m(j),g(J),w(de=>{if(!de)return de;let he={...de};return P.includes("w")&&(he.left=de.left+(de.width-te.width)),P.includes("n")&&(he.top=de.top+(de.height-te.height)),he.width=te.width,he.height=te.height,he});},U=()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",U),d(false);let G=O.current;G&&R.current?.(G.pmPos,j,J),V.current?.();};window.addEventListener("mousemove",N),window.addEventListener("mouseup",U);},[e,S]),ee=Mu.useCallback(P=>{if(!e||!S)return;P.preventDefault(),P.stopPropagation();let I=4,y=P.clientX,M=P.clientY,F=false,D=null,j=N=>{let U=N.clientX-y,G=N.clientY-M;!F&&Math.sqrt(U*U+G*G)<I||(F||(F=true,p(true),L.current?.(),D=document.createElement("div"),D.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);",D.style.width=`${S.width}px`,D.style.height=`${S.height}px`,document.body.appendChild(D)),D&&(D.style.left=`${N.clientX-S.width/2}px`,D.style.top=`${N.clientY-S.height/2}px`));},J=N=>{if(window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",J),D&&(D.remove(),D=null),p(false),F){let U=O.current;U&&$.current?.(U.pmPos,N.clientX,N.clientY),W.current?.();}};window.addEventListener("mousemove",j),window.addEventListener("mouseup",J);},[e,S]);if(!!!(e&&S&&n))return jsxRuntime.jsx("div",{ref:E,style:{...Ld,visibility:"hidden"},className:"image-selection-overlay"});let{left:pe,top:Ee,width:Te,height:Re}=S;return jsxRuntime.jsxs("div",{ref:E,style:Ld,className:"image-selection-overlay",children:[jsxRuntime.jsx("div",{style:{...vg,left:pe-zo,top:Ee-zo,width:Te+zo*2,height:Re+zo*2}}),jsxRuntime.jsx("div",{style:{position:"absolute",left:pe,top:Ee,width:Te,height:Re,cursor:c?"grabbing":"grab",pointerEvents:"auto",zIndex:15},onMouseDown:ee}),jsxRuntime.jsx(vi,{handle:"nw",style:{left:pe-Cn,top:Ee-Cn},onMouseDown:B}),jsxRuntime.jsx(vi,{handle:"ne",style:{left:pe+Te-Cn,top:Ee-Cn},onMouseDown:B}),jsxRuntime.jsx(vi,{handle:"se",style:{left:pe+Te-Cn,top:Ee+Re-Cn},onMouseDown:B}),jsxRuntime.jsx(vi,{handle:"sw",style:{left:pe-Cn,top:Ee+Re-Cn},onMouseDown:B}),u&&jsxRuntime.jsxs("div",{style:{...Pg,left:pe+Te/2,top:Ee+Re+12},children:[f," \xD7 ",b]})]})}function vi({handle:e,style:t,onMouseDown:n}){return jsxRuntime.jsx("div",{style:{...Rg,...t,cursor:Mg[e]},onMouseDown:o=>n(e,o),"data-handle":e})}function Ig(e,t,n,o){let r=e-t-n,i=(o.count-1)*o.gap;return (r-i)/o.count}function Ja(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=Ig(t.w,n.left,n.right,o);function d(E){return n.left+E*(u+o.gap)}function c(){let E=r.length+1,R=e.footnoteReservedHeights?.get(E)??0,_=s-R,V={number:E,fragments:[],margins:{...n},size:{...t},footnoteReservedHeight:R>0?R:void 0},$={page:V,cursorY:a,columnIndex:0,topMargin:a,contentBottom:_,trailingSpacing:0};return r.push(V),i.push($),e.onNewPage&&e.onNewPage($),$}function p(){return i.length===0?c():i[i.length-1]}function f(E){return E.contentBottom-E.cursorY}function m(E,R){let _=R||p();return f(_)>=E}function b(E){return E.columnIndex<o.count-1?(E.columnIndex+=1,E.cursorY=E.topMargin,E.trailingSpacing=0,E):c()}function g(E){let R=p(),_=Number.isFinite(E)&&E>0?E:0,V=R.contentBottom-R.topMargin;if(_>V)return R.cursorY!==R.topMargin&&(R=b(R)),R;for(;!m(_,R);)R=b(R);return R}function S(E,R,_=0,V=0){let $=Math.max(_,p().trailingSpacing),L=$+R,W=g(L),K=W.cursorY===W.topMargin?0:$,C=d(W.columnIndex),B=W.cursorY+K;return E.x=C,E.y=B,W.page.fragments.push(E),W.cursorY=B+R,W.trailingSpacing=V,{state:W,x:C,y:B}}function w(){return c()}function k(){let E=p();return b(E)}return {pages:r,states:i,columnWidth:u,getCurrentState:p,getAvailableHeight:()=>f(p()),fits:E=>m(E),ensureFits:g,addFragment:S,forcePageBreak:w,forceColumnBreak:k,getColumnX:d}}function Qa(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 d=o+1;d<e.length;d++){let c=e[d];if(c.kind==="sectionBreak"||c.kind==="pageBreak"||c.kind==="columnBreak"||c.kind!=="paragraph")break;if(c.attrs?.keepNext)a.push(d),s=d,n.add(d);else break}let l=s+1,u=-1;if(l<e.length){let d=e[l];d.kind!=="sectionBreak"&&d.kind!=="pageBreak"&&d.kind!=="columnBreak"&&(u=l);}t.set(o,{startIndex:o,endIndex:s,memberIndices:a,anchorIndex:u});}return t}function es(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 d=s.attrs?.spacing?.after??0;o+=d;}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 ts(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 ns(e){return e.kind!=="paragraph"?false:e.attrs?.pageBreakBefore===true}var Fg={w:816,h:1056},lo={top:96,right:96,bottom:96,left:96};function Hd(e){return e.attrs?.spacing?.before??0}function Nd(e){return e.attrs?.spacing?.after??0}function Lg(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 Ri(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??Fg,r={top:n.margins?.top??lo.top,right:n.margins?.right??lo.right,bottom:n.margins?.bottom??lo.bottom,left:n.margins?.left??lo.left,header:n.margins?.header??n.margins?.top??lo.top,footer:n.margins?.footer??n.margins?.bottom??lo.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=Ja({pageSize:o,margins:i,columns:n.columns,footnoteReservedHeights:n.footnoteReservedHeights});Lg(e);let l=Qa(e),u=ts(l);for(let d=0;d<e.length;d++){let c=e[d],p=t[d];ns(c)&&s.forcePageBreak();let f=l.get(d);if(f&&!u.has(d)){let m=es(f,e,t),b=s.getCurrentState(),g=s.getAvailableHeight(),S=b.contentBottom-b.topMargin;m<=S&&m>g&&b.page.fragments.length>0&&s.forcePageBreak();}switch(c.kind){case "paragraph":Bg(c,p,s,a);break;case "table":c.floating?Dg(c,p,s,a):Ag(c,p,s);break;case "image":Hg(c,p,s);break;case "pageBreak":s.forcePageBreak();break;case "columnBreak":s.forceColumnBreak();break;case "sectionBreak":zg(c,s);break}}return s.pages.length===0&&s.getCurrentState(),{pageSize:o,pages:s.pages,columns:n.columns,pageGap:n.pageGap}}function Bg(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=Hd(e),u=Nd(e),d=n.getCurrentState(),c={kind:"paragraph",blockId:e.id,x:n.getColumnX(d.columnIndex),y:d.cursorY+l,width:o,height:0,fromLine:0,toLine:0,pmStart:e.pmStart,pmEnd:e.pmEnd};n.addFragment(c,0,l,u);return}let i=Hd(e),a=Nd(e),s=0;for(;s<r.length;){let l=n.getCurrentState(),u=n.getAvailableHeight(),d=0,c=0;for(let w=s;w<r.length;w++){let k=r[w].lineHeight,E=d+k;if((s===0&&w===s?E+i:E)<=u||c===0)d=E,c++;else break}let p=s===0,f=s+c>=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:d,fromLine:s,toLine:s+c,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!p,continuesOnNext:!f},S=n.addFragment(g,d,m,b);g.y=S.y,s+=c,s<r.length&&n.ensureFits(r[s].lineHeight);}}function Ag(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,d=r+l>=o.length,c=n.getColumnX(i.columnIndex);e.justification==="center"?c=c+(n.columnWidth-t.totalWidth)/2:e.justification==="right"&&(c=c+n.columnWidth-t.totalWidth);let p={kind:"table",blockId:e.id,x:c,y:0,width:t.totalWidth,height:s,fromRow:r,toRow:r+l,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!u,continuesOnNext:!d},f=n.addFragment(p,s,0,0);p.y=f.y,p.x=c,r+=l,r<o.length&&n.ensureFits(o[r].height);}}function Dg(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,d=a.size.h-s.top-s.bottom,c=s.left,p=s.top;i?.horzAnchor==="page"&&(c=0),i?.vertAnchor==="page"&&(p=0);let f=n.getColumnX(r.columnIndex);if(i?.tblpX!==void 0)f=c+i.tblpX;else if(i?.tblpXSpec){let k=i.tblpXSpec;k==="left"||k==="inside"?f=c:k==="right"||k==="outside"?f=c+o-l:k==="center"&&(f=c+(o-l)/2);}else e.justification==="center"?f=c+(o-l)/2:e.justification==="right"&&(f=c+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 k=i.tblpYSpec;k==="top"?m=p:k==="bottom"?m=p+d-u:k==="center"&&(m=p+(d-u)/2);}b||(m=n.ensureFits(u).cursorY);let g=s.left,S=s.left+o-l;Number.isFinite(S)&&(f=Math.max(g,Math.min(f,S)));let w={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(w);}function Hg(e,t,n){if(t.kind!=="image")throw new Error("layoutImage: expected image measure");if(e.anchor?.isAnchored){Ng(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 Ng(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 zg(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 Og="Calibri";function os(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 $g=11;function lt(e){return e/1440*96}var Wg=0;function co(){return `block-${++Wg}`}function _g(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 Pi(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?chunkGJ4GKSDU_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=chunkGJ4GKSDU_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}case "comment":{let r=o.attrs.commentId;r&&(n.commentIds||(n.commentIds=[]),n.commentIds.push(r));break}case "insertion":n.isInsertion=true,n.changeAuthor=o.attrs.author,n.changeDate=o.attrs.date,n.changeRevisionId=o.attrs.revisionId;break;case "deletion":n.isDeletion=true,n.changeAuthor=o.attrs.author,n.changeDate=o.attrs.date,n.changeRevisionId=o.attrs.revisionId;break}return n}function Vg(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=Pi(a.marks,i),d={kind:"text",text:a.text,...u,pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="hardBreak"){let u={kind:"lineBreak",pmStart:l,pmEnd:l+a.nodeSize};o.push(u);}else if(a.type.name==="tab"){let d={kind:"tab",...Pi(a.marks,i),pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="image"){let u=a.attrs,d=os(u.width||100,u.height||100,n.pageContentHeight),c={kind:"image",src:u.src,width:d.width,height:d.height,alt:u.alt,transform:u.transform,wrapType:u.wrapType,displayMode:u.displayMode,cssFloat:u.cssFloat,distTop:u.distTop,distBottom:u.distBottom,distLeft:u.distLeft,distRight:u.distRight,position:u.position,pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="field"){let u=a.attrs.fieldType,c={kind:"field",fieldType:u==="PAGE"?"PAGE":u==="NUMPAGES"?"NUMPAGES":u==="DATE"?"DATE":u==="TIME"?"TIME":"OTHER",fallback:a.attrs.displayText||"",pmStart:l,pmEnd:l+a.nodeSize};o.push(c);}else if(a.type.name==="math"){let d={kind:"text",text:a.attrs.plainText||"[equation]",italic:true,fontFamily:"Cambria Math",pmStart:l,pmEnd:l+a.nodeSize};o.push(d);}else if(a.type.name==="sdt"){let u=l+1;a.forEach((d,c)=>{let p=u+c;if(d.isText&&d.text){let f=Pi(d.marks,i),m={kind:"text",text:d.text,...f,pmStart:p,pmEnd:p+d.nodeSize};o.push(m);}else if(d.type.name==="hardBreak"){let f={kind:"lineBreak",pmStart:p,pmEnd:p+d.nodeSize};o.push(f);}else if(d.type.name==="tab"){let m={kind:"tab",...Pi(d.marks,i),pmStart:p,pmEnd:p+d.nodeSize};o.push(m);}else if(d.type.name==="image"){let f=d.attrs,m=os(f.width||100,f.height||100,n.pageContentHeight),b={kind:"image",src:f.src,width:m.width,height:m.height,alt:f.alt,transform:f.transform,wrapType:f.wrapType,displayMode:f.displayMode,cssFloat:f.cssFloat,distTop:f.distTop,distBottom:f.distBottom,distLeft:f.distLeft,distRight:f.distRight,position:f.position,pmStart:p,pmEnd:p+d.nodeSize};o.push(b);}});}}),o}function jg(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=lt(e.spaceBefore)),e.spaceAfter!=null&&(t.spacing.after=lt(e.spaceAfter)),e.lineSpacing!=null&&(e.lineSpacingRule==="exact"||e.lineSpacingRule==="atLeast"?(t.spacing.line=lt(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=lt(n)),e.indentRight!=null&&(t.indent.right=lt(e.indentRight)),o!=null&&(r?t.indent.hanging=Math.abs(lt(o)):t.indent.firstLine=lt(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,d="#000000";return l.color?.rgb&&(d=`#${l.color.rgb}`),{style:l.style||"single",width:u,color:d}};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)),a.between&&(t.borders.between=s(a.between)),!t.borders.top&&!t.borders.bottom&&!t.borders.left&&!t.borders.right&&!t.borders.between&&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:Ug(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 Ug(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 zd(e,t,n){let o=e.attrs,r=Vg(e,t,n),i=jg(o);return {kind:"paragraph",id:co(),runs:r,attrs:i,pmStart:t,pmEnd:t+e.nodeSize}}function Gg(e){return Math.max(1,Math.round(e/8*1.333))}var Kg={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 Yg(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:Kg[i.style]||"solid"};i.color?.rgb&&(a.color=`#${i.color.rgb}`),i.size&&(a.width=Gg(i.size)),n[r]=a;}return Object.keys(n).length>0?n:void 0}function qg(e,t,n){let o=[],r=t+1;e.forEach(l=>{l.type.name==="paragraph"?o.push(zd(l,r,n)):l.type.name==="table"&&o.push(Od(l,r,n)),r+=l.nodeSize;});let i=e.attrs,a=i.margins,s={top:a?.top!=null?lt(a.top):1,right:a?.right!=null?lt(a.right):7,bottom:a?.bottom!=null?lt(a.bottom):1,left:a?.left!=null?lt(a.left):7};return {id:co(),blocks:o,colSpan:i.colspan,rowSpan:i.rowspan,width:i.width?lt(i.width):void 0,verticalAlign:i.verticalAlign,background:i.backgroundColor?`#${i.backgroundColor}`:void 0,borders:Yg(i),padding:s}}function Xg(e,t,n){let o=[],r=t+1;e.forEach(a=>{(a.type.name==="tableCell"||a.type.name==="tableHeader")&&o.push(qg(a,r,n)),r+=a.nodeSize;});let i=e.attrs;return {id:co(),cells:o,height:i.height?lt(i.height):void 0,heightRule:i.heightRule??void 0,isHeader:i.isHeader}}function Od(e,t,n){let o=[],r=t+1;e.forEach(p=>{p.type.name==="tableRow"&&o.push(Xg(p,r,n)),r+=p.nodeSize;});let a=e.attrs.columnWidths?.map(lt),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,d=e.attrs.floating,c=d?{horzAnchor:d.horzAnchor,vertAnchor:d.vertAnchor,tblpX:d.tblpX!==void 0?lt(d.tblpX):void 0,tblpXSpec:d.tblpXSpec,tblpY:d.tblpY!==void 0?lt(d.tblpY):void 0,tblpYSpec:d.tblpYSpec,topFromText:d.topFromText!==void 0?lt(d.topFromText):void 0,bottomFromText:d.bottomFromText!==void 0?lt(d.bottomFromText):void 0,leftFromText:d.leftFromText!==void 0?lt(d.leftFromText):void 0,rightFromText:d.rightFromText!==void 0?lt(d.rightFromText):void 0}:void 0;return {kind:"table",id:co(),rows:o,columnWidths:a,width:s,widthType:l,justification:u,floating:c,pmStart:t,pmEnd:t+e.nodeSize}}function Zg(e,t,n){let o=e.attrs,r=o.wrapType,i=r==="behind"||r==="inFront",a=os(o.width||100,o.height||100,n);return {kind:"image",id:co(),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 $d(e,t={}){let n={...t,defaultFont:t.defaultFont??Og,defaultSize:t.defaultSize??$g},o=[],r=0,i=new Map;return e.forEach((a,s)=>{let l=r+s;switch(a.type.name){case "paragraph":{let u=zd(a,l,n),d=a.attrs;if(d.numPr&&!d.listMarker){let c=d.numPr.numId;if(c==null||c===0)break;let p=d.numPr.ilvl??0,f=i.get(c)??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(c,f);let m=d.listIsBullet?"\u2022":_g(f,p);u.attrs={...u.attrs,listMarker:m};}o.push(u);}break;case "table":o.push(Od(a,l,n));break;case "image":o.push(Zg(a,l,n.pageContentHeight));break;case "horizontalRule":case "pageBreak":{let u={kind:"pageBreak",id:co(),pmStart:l,pmEnd:l+a.nodeSize};o.push(u);break}}}),o}var un=11,Oo="Calibri",Mi=1.15,uo=.5;function Wd(e){return {fontFamily:e.fontFamily??Oo,fontSize:e.fontSize??un,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function Ud(e,t,n){let o=chunk5FJXHXFV_cjs.h(e),r=n?.ascent??o*.8,i=n?.descent??o*.2,a=n?.singleLineRatio??1.15,s=o*a,l;if(t?.lineRule==="exact"&&t.line!==void 0)l=t.line;else if(t?.lineRule==="atLeast"&&t.line!==void 0){let u=s*Mi;l=Math.max(t.line,u);}else t?.line!==void 0&&t?.lineUnit==="multiplier"?l=s*t.line:t?.line!==void 0&&t?.lineUnit==="px"?l=t.line:l=s*Mi;return {ascent:r,descent:i,lineHeight:l}}function _d(e,t,n){let o=chunk5FJXHXFV_cjs.d({fontSize:e,fontFamily:n??Oo});return Ud(e,t,o)}function Vd(e){return e.kind==="text"}function Qg(e){return e.kind==="tab"}function eh(e){return e.kind==="image"}function th(e){return e.kind==="lineBreak"}function nh(e){return e.kind==="field"}function oh(e){return !e.text||e.text.length===0}function rh(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 ih=48;function jd(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 $o(e,t,n){let o=e.runs,r=e.attrs,i=r?.spacing,a=n?.floatingZones,s=n?.paragraphYOffset??0,l=r?.indent,u=l?.left??0,d=l?.right??0,c=(l?.firstLine??0)-(l?.hanging??0),p=Math.max(1,t-u-d),f=Math.max(1,p-c),m=0,b=chunk5FJXHXFV_cjs.h(un)*Mi,g=jd(0,b,a,s),S=Math.max(1,f-g.leftMargin-g.rightMargin),w=[];if(o.length===0){let L=r?.defaultFontSize??un,W=r?.defaultFontFamily??Oo,O=_d(L,i,W);return w.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...O}),{kind:"paragraph",lines:w,totalHeight:O.lineHeight}}if(o.length===1&&Vd(o[0])&&oh(o[0])){let L=o[0],W=L.fontSize??r?.defaultFontSize??un,O=L.fontFamily??r?.defaultFontFamily??Oo,K=_d(W,i,O);return w.push({fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,...K}),{kind:"paragraph",lines:w,totalHeight:K.lineHeight}}let k={fromRun:0,fromChar:0,toRun:0,toChar:0,width:0,maxFontSize:un,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:S,leftOffset:g.leftMargin,rightOffset:g.rightMargin},E=()=>{let L=Ud(k.maxFontSize,i,k.maxFontMetrics),W={...L};k.maxImageHeightPx>W.lineHeight&&(W.lineHeight=k.maxImageHeightPx,W.ascent=k.maxImageHeightPx*.8,W.descent=k.maxImageHeightPx*.2);let O={fromRun:k.fromRun,fromChar:k.fromChar,toRun:k.toRun,toChar:k.toChar,width:k.width,...W};k.leftOffset>0&&(O.leftOffset=k.leftOffset),k.rightOffset>0&&(O.rightOffset=k.rightOffset),w.push(O),m+=L.lineHeight;},R=(L,W)=>{E();let O=chunk5FJXHXFV_cjs.h(un)*Mi,K=jd(m,O,a,s),C=Math.max(1,p-K.leftMargin-K.rightMargin);k={fromRun:L,fromChar:W,toRun:L,toChar:W,width:0,maxFontSize:un,maxFontMetrics:null,maxImageHeightPx:0,availableWidth:C,leftOffset:K.leftMargin,rightOffset:K.rightMargin};},_=L=>{let W=L.fontSize??un;(!k.maxFontMetrics||W>k.maxFontSize)&&(k.maxFontSize=W,k.maxFontMetrics=chunk5FJXHXFV_cjs.d(L));};for(let L=0;L<o.length;L++){let W=o[L];if(th(W)){k.toRun=L,k.toChar=0,R(L+1,0);continue}if(Qg(W)){let O=Wd(W);_(O);let K=W.width??ih;k.width+K>k.availableWidth+uo&&(R(L,0),_(O)),k.width+=K,k.toRun=L,k.toChar=1;continue}if(eh(W)){let O=W.wrapType,K=W.displayMode==="float"||O&&["square","tight","through"].includes(O);if(W.position&&K){k.toRun=L,k.toChar=1;continue}if(O==="topAndBottom"||W.displayMode==="block"){k.width>0&&R(L,0);let ee=W.height,ge=W.distTop??6,pe=W.distBottom??6;k.toRun=L,k.toChar=1,k.maxImageHeightPx=ee+ge+pe,R(L+1,0);continue}let C=W.width,B=W.height;B>k.maxImageHeightPx&&(k.maxImageHeightPx=B),k.width+C>k.availableWidth+uo&&R(L,0),k.width+=C,k.toRun=L,k.toChar=1;continue}if(nh(W)){let O=W.fallback||"1",K={fontFamily:W.fontFamily??Oo,fontSize:W.fontSize??un,bold:W.bold,italic:W.italic};_(K);let C=chunk5FJXHXFV_cjs.e(O,K);k.width>0&&k.width+C>k.availableWidth+uo&&(R(L,0),_(K)),k.width+=C,k.toRun=L,k.toChar=1;continue}if(Vd(W)){let O=W,K=O.text,C=Wd(O);if(_(C),!K||K.length===0){k.toRun=L,k.toChar=0;continue}let B=rh(K),ee=0;for(;ee<K.length;){let ge=K.length;for(let Te of B)if(Te>ee){ge=Te;break}let pe=K.slice(ee,ge),Ee=chunk5FJXHXFV_cjs.e(pe,C);if(Ee>k.availableWidth+uo){k.width>0&&(R(L,ee),_(C));let{charWidths:Te}=chunk5FJXHXFV_cjs.f(pe,C),Re=0;for(;Re<pe.length;){let P=0,I=Re;for(;I<pe.length;){let y=Te[I]??0;if(P+y>k.availableWidth+uo)break;P+=y,I+=1;}I===Re&&(I=Math.min(pe.length,Re+1),P=Te[Re]??0),k.width+=P,k.toRun=L,k.toChar=ee+I,Re=I,Re<pe.length&&(R(L,ee+Re),_(C));}ee=ge;continue}k.width>0&&k.width+Ee>k.availableWidth+uo&&(R(L,ee),_(C)),k.width+=Ee,k.toRun=L,k.toChar=ge,ee=ge;}}}E();let $=w.reduce((L,W)=>L+W.lineHeight,0);return i?.before&&($+=i.before),i?.after&&($+=i.after),{kind:"paragraph",lines:w,totalHeight:$}}var ah=new Map;function Gd(){ah.clear();}var sh=new Map;function Kd(){sh.clear();}var lh=5e3,ch=lh,vn=new Map;function rs(e){let t=[];for(let o of e.runs)o.kind==="text"?t.push(`t:${o.text}|${o.fontFamily}|${o.fontSize}|${o.bold}|${o.italic}`):o.kind==="tab"?t.push(`tab:${o.width}`):o.kind==="image"?t.push(`img:${o.width}x${o.height}`):o.kind==="lineBreak"&&t.push("br");let n=e.attrs;return n&&(n.alignment&&t.push(`align:${n.alignment}`),n.indent&&t.push(`indent:${n.indent.left}|${n.indent.right}|${n.indent.firstLine}|${n.indent.hanging}`),n.spacing&&t.push(`spacing:${n.spacing.before}|${n.spacing.after}|${n.spacing.line}|${n.spacing.lineRule}`)),t.join("||")}function dh(){for(;vn.size>ch;){let e=vn.keys().next().value;if(e===void 0)break;vn.delete(e);}}function is(e,t){let n=rs(e),o=vn.get(n);if(o!==void 0&&o.maxWidth===t)return vn.delete(n),vn.set(n,o),o.measure}function as(e,t,n){let o=rs(e);vn.set(o,{measure:n,maxWidth:t}),dh();}function Yd(){vn.clear();}function ss(){Gd(),Kd(),Yd();}function uh(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function ph(e,t){let n=[];for(let o=t.fromRun;o<=t.toRun&&o<e.runs.length;o++){let r=e.runs[o];if(r){if(r.kind==="tab"||r.kind==="image"||r.kind==="lineBreak"){n.push(r);continue}if(r.kind==="text"){let i=r.text??"",a=o===t.fromRun,s=o===t.toRun;if(a||s){let l=a?t.fromChar:0,u=s?t.toChar:i.length,d=i.slice(l,u);d.length>0&&n.push({...r,text:d});}else n.push(r);}}}return n}function fh(e,t){let n,o,r=e.pmStart??0,i=0;for(let a=0;a<e.runs.length&&a<=t.toRun;a++){let s=e.runs[a];s&&(a<t.fromRun?s.kind==="text"?i+=(s.text??"").length:(s.kind==="tab"||s.kind==="lineBreak"||s.kind==="image")&&(i+=1):a===t.fromRun&&(i+=t.fromChar,n=r+i,s.kind==="text"&&(i=t.fromChar)));}if(n!==void 0){let a=0;for(let s=t.fromRun;s<=t.toRun&&s<e.runs.length;s++){let l=e.runs[s];if(l)if(l.kind==="text"){let u=l.text??"",d=s===t.fromRun?t.fromChar:0,c=s===t.toRun?t.toChar:u.length;a+=c-d;}else (l.kind==="tab"||l.kind==="lineBreak"||l.kind==="image")&&(a+=1);}o=n+a;}return {pmStart:n,pmEnd:o}}function mh(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 gh(e,t,n,o){let{pmStart:r,pmEnd:i}=fh(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=ph(e,t);if(u.length===0)return {charOffset:0,pmPosition:r};let d=0,c=0;for(let f of u){if(f.kind==="tab"){let m=f.width??48,b=d+m;if(l<=b){let g=d+m/2;return l<g?{charOffset:c,pmPosition:r+c}:{charOffset:c+1,pmPosition:r+c+1}}d=b,c+=1;continue}if(f.kind==="image"){let m=f.width,b=d+m;if(l<=b){let g=d+m/2;return l<g?{charOffset:c,pmPosition:r+c}:{charOffset:c+1,pmPosition:r+c+1}}d=b,c+=1;continue}if(f.kind==="lineBreak"){if(l>=d)return {charOffset:c,pmPosition:r+c};c+=1;continue}if(f.kind==="text"){let m=f.text??"";if(m.length===0)continue;let b=uh(f),g=chunk5FJXHXFV_cjs.f(m,b),S=d+g.width;if(l<=S){let w=l-d,k=chunk5FJXHXFV_cjs.g(w,g.charWidths),E=c+k;return {charOffset:E,pmPosition:r+E}}d=S,c+=m.length;}}return {charOffset:i-r,pmPosition:i}}function qd(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=mh(l,i,a.fromLine,a.toLine);if(u===null)return null;let d=l.lines[u];if(!d)return null;let c=0;for(let k=a.fromLine;k<u;k++)c+=l.lines[k]?.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:S,pmPosition:w}=gh(s,d,g,b);return {pmPosition:w,charOffset:S,lineIndex:u}}function hh(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 qd(i)?.pmPosition??null}function ls(e,t){if(t)return hh(t);if(!e)return null;let{fragment:n}=e;return n.kind==="paragraph"?qd(e)?.pmPosition??null:n.kind==="image"?n.pmStart??null:null}function Zd(e,t,n,o=1){let r=document.elementsFromPoint(t,n),i=r.find(d=>d.classList.contains("layout-page"));if(!i)return null;let a=r.find(d=>d.tagName==="SPAN"&&d.dataset.pmStart!==void 0&&d.dataset.pmEnd!==void 0);if(a)return cs(a,t);let s=r.find(d=>d.classList.contains("layout-empty-run"));if(s){let d=s.closest(".layout-paragraph");if(d&&d.dataset.pmStart)return Number(d.dataset.pmStart)}let l=r.find(d=>d.classList.contains("layout-paragraph")&&d.dataset.pmStart!==void 0);if(l&&l.dataset.pmStart){let d=Xd(l,t,n);return d!==null?d:Number(l.dataset.pmStart)}let u=r.find(d=>d.classList.contains("layout-table-cell"));return u?Xd(u,t,n):bh(e,i,t,n)}function cs(e,t,n){let o=Number(e.dataset.pmStart),r=Number(e.dataset.pmEnd);if(e.classList.contains("layout-run-tab")){let c=e.getBoundingClientRect(),p=(c.left+c.right)/2;return t<p?o:r}let i=e.firstChild;if(!i||i.nodeType!==Node.TEXT_NODE)return o;let a=i,s=a.length;if(s===0)return o;let l=e.ownerDocument;if(!l)return o;let u=0,d=s;for(;u<d;){let c=Math.floor((u+d)/2),p=l.createRange();p.setStart(a,c),p.setEnd(a,c);let m=p.getBoundingClientRect().left;t<m?d=c:u=c+1;}if(u>0&&u<=s){let c=l.createRange();c.setStart(a,u-1),c.setEnd(a,u-1);let p=c.getBoundingClientRect();c.setStart(a,Math.min(u,s)),c.setEnd(a,Math.min(u,s));let f=c.getBoundingClientRect(),m=Math.abs(t-p.left),b=Math.abs(t-f.left);if(m<b)return o+(u-1)}return o+Math.min(u,r-o)}function Xd(e,t,n){let o=e.querySelector(".layout-empty-run");if(o){let c=o.closest(".layout-paragraph");if(c&&c.dataset.pmStart)return Number(c.dataset.pmStart)}let r=e.querySelectorAll(".layout-line"),i=null,a=1/0;for(let c of Array.from(r)){let p=c,f=p.getBoundingClientRect(),m=(f.top+f.bottom)/2,b=Math.abs(n-m);b<a&&(a=b,i=p);}if(!i){let c=e.querySelector(".layout-paragraph[data-pm-start]");return c?.dataset.pmStart?Number(c.dataset.pmStart):e.dataset.pmStart?Number(e.dataset.pmStart):null}let s=i.querySelectorAll("span[data-pm-start][data-pm-end]");if(s.length===0){let c=i.closest(".layout-paragraph");return c?.dataset.pmStart?Number(c.dataset.pmStart):null}let l=null,u=1/0;for(let c of Array.from(s)){let p=c,f=p.getBoundingClientRect();if(t>=f.left&&t<=f.right)return cs(p,t);let m=t<f.left?f.left-t:t-f.right;m<u&&(u=m,l=p);}if(!l)return null;let d=l.getBoundingClientRect();return t<d.left?Number(l.dataset.pmStart):Number(l.dataset.pmEnd)}function bh(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,S=Math.abs(o-g);S<l&&(l=S,s=m);}if(!s)return null;let u=s.querySelectorAll("span[data-pm-start][data-pm-end]");if(u.length===0){let f=s.closest(".layout-paragraph");return f?.dataset.pmStart?Number(f.dataset.pmStart):null}let d=null,c=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect();if(n>=b.left&&n<=b.right)return cs(m,n);let g=n<b.left?b.left-n:n-b.right;g<c&&(c=g,d=m);}if(!d)return null;let p=d.getBoundingClientRect();return n<p.left?Number(d.dataset.pmStart):Number(d.dataset.pmEnd)}var Rn={fragment:"layout-fragment",paragraph:"layout-fragment-paragraph",table:"layout-fragment-table",image:"layout-fragment-image"};function yh(e){return e.kind==="paragraph"}function xh(e){return e.kind==="table"}function Sh(e){return e.kind==="image"}function Ei(e){e.style.position="absolute",e.style.overflow="hidden";}function kh(e,t,n){let o=n.createElement("div");return o.className=`${Rn.fragment} ${Rn.paragraph}`,Ei(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 wh(e,t,n){let o=n.createElement("div");return o.className=`${Rn.fragment} ${Rn.table}`,Ei(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 Ch(e,t,n){let o=n.createElement("div");return o.className=`${Rn.fragment} ${Rn.image}`,Ei(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 Wo(e,t,n={}){let o=n.document??document;if(yh(e))return kh(e,t,o);if(xh(e))return wh(e,t,o);if(Sh(e))return Ch(e,t,o);let r=o.createElement("div");r.className=Rn.fragment,Ei(r);let i=e;return i.blockId!==void 0&&(r.dataset.blockId=String(i.blockId)),i.kind&&(r.dataset.kind=i.kind),r}function ds(e){return e/1440*96}function Th(e){return e/96*1440}function vh(e){let{explicitStops:t=[],defaultTabInterval:n=720,leftIndent:o=0}=e,r=t.filter(c=>c.val!=="clear").filter(c=>c.pos>=o),i=t.filter(c=>c.val==="clear").map(c=>c.pos),a=r.reduce((c,p)=>Math.max(c,p.pos),0),s=[...r];o>0&&!r.some(c=>c.pos<=o)&&(i.some(p=>Math.abs(p-o)<20)||s.push({val:"start",pos:o,leader:"none"}));let u=a>0?Math.max(a,o):o,d=o+14400;for(;u<d;){u+=n;let c=r.some(m=>Math.abs(m.pos-u)<20),p=i.some(m=>Math.abs(m-u)<20),f=o>0&&Math.abs(u-o)<20;!c&&!p&&!f&&s.push({val:"start",pos:u,leader:"none"});}return s.sort((c,p)=>c.pos-p.pos)}function Jd(e,t,n="",o,r="."){let{defaultTabInterval:i=720}=t,a=Th(e),l=vh(t).find(c=>c.pos>a);if(!l){let c=ds(i),p=c-e%c;return p<=0&&(p=c),{width:p,alignment:"default"}}let d=ds(l.pos)-e;if(l.val==="center"||l.val==="end"){let c=o?o(n):0;l.val==="center"?d-=c/2:d-=c;}else if(l.val==="decimal"){let c=n.indexOf(r);if(c>=0&&o){let p=n.slice(0,c),f=o(p);d-=f;}}else if(l.val==="bar")return {width:0,leader:l.leader,alignment:"bar"};if(d<1){let c=ds(i),p=c-e%c;return p<=0&&(p=c),{width:p,alignment:"default"}}return {width:d,leader:l.leader,alignment:l.val}}var Ot={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 Fi(e){return e.kind==="text"}function Ii(e){return e.kind==="tab"}function us(e){return e.kind==="image"}function ps(e){return e.kind==="lineBreak"}function fs(e){return e.kind==="field"}function Rh(e,t){if(t.fontFamily&&(e.style.fontFamily=chunk5FJXHXFV_cjs.a(t.fontFamily).cssFallback),t.fontSize){let o=t.fontSize*96/72;e.style.fontSize=`${o}px`;}t.bold&&(e.style.fontWeight="bold"),t.italic&&(e.style.fontStyle="italic"),t.color&&(e.style.color=t.color),t.letterSpacing&&(e.style.letterSpacing=`${t.letterSpacing}px`),t.highlight&&(e.style.backgroundColor=t.highlight);let n=[];t.underline&&(n.push("underline"),typeof t.underline=="object"&&(t.underline.style&&(e.style.textDecorationStyle=t.underline.style),t.underline.color&&(e.style.textDecorationColor=t.underline.color))),t.strike&&n.push("line-through"),t.commentIds&&t.commentIds.length>0&&(e.style.backgroundColor="rgba(255, 212, 0, 0.25)",e.style.borderBottom="2px solid rgba(255, 212, 0, 0.6)",e.dataset.commentId=String(t.commentIds[0])),t.isInsertion&&(e.style.backgroundColor="rgba(52, 168, 83, 0.08)",e.style.borderBottom="2px dashed #2e7d32",e.style.paddingBottom="1px",e.classList.add("docx-insertion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId&&(e.dataset.revisionId=String(t.changeRevisionId))),t.isDeletion&&(e.style.backgroundColor="rgba(211, 47, 47, 0.08)",e.style.color="#c62828",n.includes("line-through")||n.push("line-through"),e.style.textDecorationColor="#c62828",e.classList.add("docx-deletion"),t.changeAuthor&&(e.dataset.changeAuthor=t.changeAuthor),t.changeDate&&(e.dataset.changeDate=t.changeDate),t.changeRevisionId&&(e.dataset.revisionId=String(t.changeRevisionId))),n.length>0&&(e.style.textDecorationLine=n.join(" ")),t.superscript&&(e.style.verticalAlign="super",e.style.fontSize="0.75em"),t.subscript&&(e.style.verticalAlign="sub",e.style.fontSize="0.75em");}function po(e,t,n){t!==void 0&&(e.dataset.pmStart=String(t)),n!==void 0&&(e.dataset.pmEnd=String(n));}function ms(e,t){let n=t.createElement("span");if(n.className=`${Ot.run} ${Ot.text}`,Rh(n,e),po(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 tu(e,t,n,o){let r=t.createElement("span");if(r.className=`${Ot.run} ${Ot.tab}`,r.style.display="inline-block",r.style.width=`${n}px`,po(r,e.pmStart,e.pmEnd),o&&o!=="none"){let i=Ph(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 Ph(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "middleDot":return "\xB7";default:return null}}function Mh(e,t){let n=t.createElement("img");return n.className=`${Ot.run} ${Ot.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",po(n,e.pmStart,e.pmEnd),n}function Qd(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),po(n,e.pmStart,e.pmEnd),n.appendChild(o),n}function nu(e,t){let n=e.displayMode,o=e.wrapType;return n==="float"||o&&["square","tight","through"].includes(o)||n==="block"||o==="topAndBottom"?Qd(e,t):Mh(e,t)}function ou(e,t){let n=t.createElement("br");return n.className=`${Ot.run} ${Ot.lineBreak}`,po(n,e.pmStart,e.pmEnd),n}function ru(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 ms(r,t)}function Eh(e,t,n){if(Fi(e))return ms(e,t);if(Ii(e))return tu(e,t,48,void 0);if(us(e))return nu(e,t);if(ps(e))return ou(e,t);if(fs(e)&&n)return ru(e,t,n);let o=t.createElement("span");return o.className=Ot.run,o}function iu(e,t){let n=[],o=e.runs;for(let r=t.fromRun;r<=t.toRun;r++){let i=o[r];if(i)if(Fi(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 Ih(e){return {val:e.val,pos:e.pos,leader:e.leader}}function Fh(e,t,n){let o="";for(let r=t+1;r<e.length;r++){let i=e[r];if(Fi(i))o+=i.text;else if(fs(i))i.fieldType==="PAGE"&&n?o+=String(n.pageNumber):i.fieldType==="NUMPAGES"&&n?o+=String(n.totalPages):o+=i.fallback??"";else if(Ii(i)||ps(i))break}return o}function Lh(e){let n=e.createElement("canvas").getContext("2d");return (o,r=11,i="Calibri")=>{if(!n)return o.length*7;let a=chunk5FJXHXFV_cjs.a(i).cssFallback,s=r*96/72;return n.font=`${s}px ${a}`,n.measureText(o).width}}function au(e,t,n,o,r){let i=o.createElement("div");i.className=Ot.line,i.style.height=`${t.lineHeight}px`,i.style.lineHeight=`${t.lineHeight}px`;let a=iu(e,t);if(a.length===0){let m=o.createElement("span");return m.className=`${Ot.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(Ii),d,c=Lh(o);if(u){let m=r?.tabStops?.map(Ih),b=r?.leftIndentPx?Math.round(r.leftIndentPx*15):0;d={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(Ii(b)&&d){let g=Fh(a,m,r?.context),S=Jd(p,d,g,c),w=tu(b,o,S.width,S.leader);i.appendChild(w),p+=S.width;}else if(Fi(b)){let g=ms(b,o);i.appendChild(g);let S=b.fontSize||11,w=b.fontFamily||"Calibri";p+=c(b.text,S,w);}else if(us(b)){if(b.displayMode==="float"||b.wrapType&&["square","tight","through"].includes(b.wrapType))continue;let S=nu(b,o);i.appendChild(S),b.displayMode!=="block"&&b.wrapType!=="topAndBottom"&&(p+=b.width);}else if(ps(b)){let g=ou(b,o);i.appendChild(g);}else if(fs(b)&&r?.context){let g=ru(b,o,r.context);i.appendChild(g);let S=b.fallback??"";b.fieldType==="PAGE"?S=String(r.context.pageNumber):b.fieldType==="NUMPAGES"&&(S=String(r.context.totalPages));let w=b.fontSize||11,k=b.fontFamily||"Calibri";p+=c(S,w,k);}else {let g=Eh(b,o,r?.context);i.appendChild(g);}}return i}function _o(e,t){return !e&&!t?true:!e||!t?false:e.style===t.style&&e.width===t.width&&e.color===t.color}function eu(e,t){return !e&&!t||!e||!t?false:_o(e.top,t.top)&&_o(e.bottom,t.bottom)&&_o(e.left,t.left)&&_o(e.right,t.right)&&_o(e.between,t.between)}function jn(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=Ot.fragment,a.style.position="relative",a.dataset.blockId=String(e.blockId),a.dataset.fromLine=String(e.fromLine),a.dataset.toLine=String(e.toLine),po(a,e.pmStart,e.pmEnd),e.continuesFromPrev&&(a.dataset.continuesFromPrev="true"),e.continuesOnNext&&(a.dataset.continuesOnNext="true");for(let k of t.runs)us(k)&&(k.displayMode==="float"||k.wrapType&&["square","tight","through"].includes(k.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,d=0,c=0;u&&(u.left&&u.left>0&&(d=u.left),u.right&&u.right>0&&(c=u.right));let p=t.attrs?.borders;if(p){let k=$=>{switch($){case "single":return "solid";case "double":return "double";case "dotted":return "dotted";case "dashed":return "dashed";case "thick":return "solid";case "wave":return "wavy";case "dashSmallGap":return "dashed";case "nil":case "none":return "none";default:return "solid"}};a.style.boxSizing="border-box";let E=$=>`${$.width}px ${k($.style)} ${$.color}`,R=eu(r.prevBorders,p),_=eu(p,r.nextBorders);R&&p.between?a.style.borderTop=E(p.between):p.top&&!R&&(a.style.borderTop=E(p.top)),p.bottom&&!_&&(a.style.borderBottom=E(p.bottom)),p.left&&(a.style.borderLeft=E(p.left)),p.right&&(a.style.borderRight=E(p.right)),(p.top||p.bottom||p.left||p.right||p.between)&&(a.style.paddingLeft=p.left?"4px":"0",a.style.paddingRight=p.right?"4px":"0",a.style.paddingTop=p.top||p.between?"2px":"0",a.style.paddingBottom=p.bottom?"6px":"0");}t.attrs?.shading&&(a.style.backgroundColor=t.attrs.shading);let f=e.width-d-c,b=t.runs[t.runs.length-1]?.kind==="lineBreak",g=n.lines.length,S=0;u?.hanging&&u.hanging>0?S=-u.hanging:u?.firstLine&&u.firstLine>0&&(S=u.firstLine);let w=0;for(let k=0;k<s.length;k++){let E=s[k],R=e.fromLine+k,_=R===g-1,V=R===0&&!e.continuesFromPrev,$=E.leftOffset??0,L=E.rightOffset??0,W=f;if(V){let B=u?.hanging&&u.hanging>0,ee=u?.firstLine&&u.firstLine>0;B&&u?.hanging?W=f+u.hanging:ee&&u?.firstLine&&(W=f-u.firstLine);}let O=au(t,E,l,i,{availableWidth:W-$-L,isLastLine:_,isFirstLine:V,paragraphEndsWithLineBreak:b,tabStops:t.attrs?.tabs,leftIndentPx:d,firstLineIndentPx:V?S:0,context:o});$>0&&(O.style.marginLeft=`${$}px`),L>0&&(O.style.marginRight=`${L}px`),w+=E.lineHeight;let K=u?.hanging&&u.hanging>0,C=u?.firstLine&&u.firstLine>0;if(V?d>0&&K?(O.style.paddingLeft=`${d}px`,O.style.textIndent=`-${u.hanging}px`):d>0&&C?(O.style.paddingLeft=`${d}px`,O.style.textIndent=`${u.firstLine}px`):d>0?O.style.paddingLeft=`${d}px`:C&&(O.style.textIndent=`${u.firstLine}px`):d>0?O.style.paddingLeft=`${d}px`:K&&(O.style.paddingLeft=`${u.hanging}px`),c>0&&(O.style.paddingRight=`${c}px`),V&&t.attrs?.listMarker){let B=Math.max(0,d-(u?.hanging??0));O.style.paddingLeft=`${B}px`,O.style.textIndent="0";let ee=Bh(t.attrs.listMarker,u,i);O.insertBefore(ee,O.firstChild);}a.appendChild(O);}return a}function Bh(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 an={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 Ah(e,t,n,o){let r=o.createElement("div");r.className=an.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],d=t.blocks[l];if(u?.kind==="paragraph"&&d?.kind==="paragraph"){let c=u,p=d,f={blockId:c.id,width:s,height:p.totalHeight,fromLine:0,toLine:p.lines.length,pmStart:c.pmStart,pmEnd:c.pmEnd},m=jn(f,c,p,n,{document:o});m.style.position="relative",r.appendChild(m);}else if(u?.kind==="table"&&d?.kind==="table"){let f=Dh(u,d,n,o);f.style.position="relative",r.appendChild(f);}}return r}function Dh(e,t,n,o){let r=o.createElement("div");r.className=`${an.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 d=e.rows[u],c=t.rows[u];if(!d||!c)continue;let p=su(d,c,u,l,t.columnWidths,e.rows.length,n,o,s,i);r.appendChild(p),l+=c.height;}return r.style.height=`${l}px`,r}function Li(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 Hh(e,t,n,o,r,i,a){let s=a.createElement("div");s.className=an.cell,s.style.position="absolute",s.style.left=`${n}px`,s.style.top="0",s.style.width=`${t.width}px`,s.style.height=`${o}px`,s.style.overflow="hidden",s.style.boxSizing="border-box";let l=e.padding?.top??1,u=e.padding?.right??7,d=e.padding?.bottom??1,c=e.padding?.left??7;if(s.style.padding=`${l}px ${u}px ${d}px ${c}px`,e.borders&&(r.isFirstRow&&Li(s,"top",e.borders.top),Li(s,"right",e.borders.right),Li(s,"bottom",e.borders.bottom),r.isFirstCol&&Li(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=Ah(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 su(e,t,n,o,r,i,a,s,l,u){let d=s.createElement("div");d.className=an.row,d.style.position="absolute",d.style.left="0",d.style.top=`${o}px`,d.style.width="100%",d.style.height=`${t.height}px`,d.dataset.rowIndex=String(n);let c=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++)c.add(m.columnIndex+b);}let p=0,f=0;for(;c.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 S=b.colSpan??1,w=b.rowSpan??1,k=t.height;if(w>1&&u){k=0;for(let L=n;L<n+w&&L<u.length-1;L++)k+=(u[L+1]??0)-(u[L]??0);k===0&&(k=t.height*w);}let E=n===0,_=f===0;f+S>=r.length;let $=Hh(b,g,p,k,{isFirstRow:E,isFirstCol:_},a,s);if($.dataset.cellIndex=String(m),$.dataset.columnIndex=String(f),w>1&&($.dataset.rowSpan=String(w)),d.appendChild($),w>1&&l){let L=`${n}-${f}`;l.set(L,{cell:b,cellMeasure:g,columnIndex:f,startRow:n,rowSpan:w,colSpan:S,x:p,totalHeight:k});}for(let L=0;L<S&&f+L<r.length;L++)p+=r[f+L]??0;for(f+=S;c.has(f);)p+=r[f]??0,f++;}return d}function Bi(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=an.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=an.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 d=new Map,c=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=su(m,b,f,c,n.columnWidths,t.rows.length,o,i,d,l);a.appendChild(g),c+=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=an.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=an.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=an.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 gs={image:"layout-image",imageAnchored:"layout-image-anchored"};function Ai(e,t,n,o,r={}){let i=r.document??document,a=i.createElement("div");a.className=gs.image,e.isAnchored&&a.classList.add(gs.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 Pn={page:"layout-page",content:"layout-page-content",header:"layout-page-header",footer:"layout-page-footer"};function Hi(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=eo(l,a[s],o.theme);for(let[d,c]of Object.entries(u))e.style[d]=String(c);}}}}function Nh(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 zh(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 zi(e){return e===void 0?0:Math.round(e*96/914400)}function Oh(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function $h(e,t,n){let o=[];for(let r of e.runs){if(r.kind!=="image")continue;let i=r;if(!Oh(i))continue;let a=i.position,s=i.distTop??0,l=i.distBottom??0,u=i.distLeft??12,d=i.distRight??12,c="left",p=0;if(a?.horizontal){let m=a.horizontal;m.align==="right"?(c="right",p=n-i.width):m.align==="left"?(c="left",p=0):m.align==="center"?(c="left",p=(n-i.width)/2):m.posOffset!==void 0&&(p=zi(m.posOffset),c=p>n/2?"right":"left");}else i.cssFloat==="right"&&(c="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=zi(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:c,x:p,y:f,distTop:s,distBottom:l,distLeft:u,distRight:d,pmStart:i.pmStart,pmEnd:i.pmEnd});}return o}function Wh(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,d=s.y-s.distTop,c=s.y+s.height+s.distBottom;s.side==="left"?o=Math.max(o,u):r=Math.max(r,t-l),i=Math.min(i,d),a=Math.max(a,c);}return (o>0||r>0)&&n.push({leftMargin:o,rightMargin:r,topY:i===1/0?0:i,bottomY:a}),n}function _h(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 lu(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],d=e.measures[l];if(u?.kind==="paragraph"&&d?.kind==="paragraph"){let c=u,p=d,f=s,m=[];for(let w of c.runs)if(w.kind==="image"&&"position"in w&&w.position){let k=w;a.push({src:k.src,width:k.width,height:k.height,alt:k.alt,paragraphY:f,position:k.position});}else m.push(w);let b={...c,runs:m},g={blockId:c.id,width:i,height:p.totalHeight,fromLine:0,toLine:p.lines.length},S=jn(g,b,p,t,{document:o});S.style.position="relative",S.style.marginBottom="0",r.appendChild(S),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 d=l.position.horizontal;d&&(d.align==="right"?u.style.right="0":d.align==="center"?(u.style.left="50%",u.style.transform="translateX(-50%)"):d.posOffset!==void 0?u.style.left=`${zi(d.posOffset)}px`:u.style.left="0");let c=l.position.vertical;if(c){let p=l.paragraphY;c.align==="bottom"?u.style.bottom="0":c.align==="center"?(u.style.top="50%",u.style.transform=(u.style.transform||"")+" translateY(-50%)"):c.posOffset!==void 0?u.style.top=`${p+zi(c.posOffset)}px`:u.style.top=`${p}px`;}else u.style.top=`${l.paragraphY}px`;r.appendChild(u);}return r}function Vh(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 Oi(e,t,n={}){let o=n.document??document,r=o.createElement("div");r.className=n.pageClassName??Pn.page,r.dataset.pageNumber=String(e.number),Hi(r,e.size.w,e.size.h,n);let i=o.createElement("div");i.className=Pn.content,Nh(i,e);let a=e.size.w-e.margins.left-e.margins.right,s=[],l=[];for(let p of e.fragments)if(p.kind==="paragraph"&&n.blockLookup){let f=n.blockLookup.get(String(p.blockId));if(f?.block.kind==="paragraph"){let m=f.block,b=p.y-e.margins.top,g=$h(m,b,a);s.push(...g);}}for(let p of s)l.push({side:p.side,x:p.x,y:p.y,width:p.width,height:p.height,distTop:p.distTop,distBottom:p.distBottom,distLeft:p.distLeft,distRight:p.distRight});if(n.blockLookup)for(let p of e.fragments){if(p.kind!=="table")continue;let f=n.blockLookup.get(String(p.blockId));if(f?.block.kind!=="table")continue;let b=f.block.floating;if(!b)continue;let g=p.x-e.margins.left,S=p.y-e.margins.top,w=b.topFromText??0,k=b.bottomFromText??0,E=b.leftFromText??12,R=b.rightFromText??12,_=g<a/2?"left":"right";l.push({side:_,x:g,y:S,width:p.width,height:p.height,distTop:w,distBottom:k,distLeft:E,distRight:R});}Wh(l,a);if(s.length>0){let p=_h(s,o);i.appendChild(p);}let d=p=>{if(p.kind!=="paragraph"||!n.blockLookup||!p.blockId)return;let f=n.blockLookup.get(String(p.blockId));if(f?.block.kind==="paragraph")return f.block.attrs?.borders},c;for(let p=0;p<e.fragments.length;p++){let f=e.fragments[p],m,b={...t,section:"body",contentWidth:a};f.y-e.margins.top;if(n.blockLookup&&f.blockId){let S=n.blockLookup.get(String(f.blockId));if(f.kind==="paragraph"&&S?.block.kind==="paragraph"&&S?.measure.kind==="paragraph"){let w=S.block,k=p+1<e.fragments.length?d(e.fragments[p+1]):void 0;m=jn(f,w,S.measure,b,{document:o,prevBorders:c,nextBorders:k}),c=w.attrs?.borders;}else f.kind==="table"&&S?.block.kind==="table"&&S?.measure.kind==="table"?(m=Bi(f,S.block,S.measure,b,{document:o}),c=void 0):f.kind==="image"&&S?.block.kind==="image"&&S?.measure.kind==="image"?(m=Ai(f,S.block,S.measure,b,{document:o}),c=void 0):(m=Wo(f,b,{document:o}),c=void 0);}else m=Wo(f,b,{document:o}),c=void 0;zh(m,f,{left:e.margins.left,top:e.margins.top}),i.appendChild(m);}if(n.footnoteArea&&n.footnoteArea.length>0){let p=Vh(n.footnoteArea,a,o);p.style.position="absolute";let f=e.footnoteReservedHeight??0,m=e.size.h-e.margins.bottom-e.margins.top;p.style.top=`${m-f}px`,p.style.left="0",p.style.right="0",i.appendChild(p);}r.appendChild(i);{let f=n.headerDistance??e.margins.header??48,m=e.size.w-e.margins.left-e.margins.right,b=Math.max(e.margins.top-f,48),S=(n.headerContent?.height??0)>b,w=o.createElement("div");if(w.className=Pn.header,w.style.position="absolute",w.style.top=`${f}px`,w.style.left=`${e.margins.left}px`,w.style.right=`${e.margins.right}px`,w.style.width=`${m}px`,S||(w.style.maxHeight=`${b}px`,w.style.overflow="hidden"),w.style.minHeight="24px",n.headerContent&&n.headerContent.blocks.length>0){let k=lu(n.headerContent,{...t,section:"header",contentWidth:m},n);w.appendChild(k);}r.appendChild(w);}{let f=n.footerDistance??e.margins.footer??48,m=e.size.w-e.margins.left-e.margins.right,b=Math.max(e.margins.bottom-f,48),S=(n.footerContent?.height??0)>b,w=o.createElement("div");if(w.className=Pn.footer,w.style.position="absolute",w.style.bottom=`${f}px`,w.style.left=`${e.margins.left}px`,w.style.right=`${e.margins.right}px`,w.style.width=`${m}px`,S||(w.style.maxHeight=`${b}px`,w.style.overflow="hidden"),w.style.minHeight="24px",n.footerContent&&n.footerContent.blocks.length>0){let k=lu(n.footerContent,{...t,section:"footer",contentWidth:m},n);w.appendChild(k);}r.appendChild(w);}return r}function hs(e,t,n){let o={pageNumber:e.number,totalPages:t,section:"body"},r={...n};if(n.footnotesByPage){let i=n.footnotesByPage.get(e.number);i&&i.length>0&&(r.footnoteArea=i);}return {context:o,pageOptions:r}}function cu(e){let t=[];t.push(`s:${e.size.w},${e.size.h}`),t.push(`m:${e.margins.top},${e.margins.right},${e.margins.bottom},${e.margins.left}`),t.push(`n:${e.number}`),e.footnoteReservedHeight&&t.push(`fn:${e.footnoteReservedHeight}`);for(let n of e.fragments){let o=`${n.kind}:${n.blockId},${n.x},${n.y},${n.width},${n.height}`;n.pmStart!==void 0&&(o+=`,ps:${n.pmStart}`),n.pmEnd!==void 0&&(o+=`,pe:${n.pmEnd}`),n.kind==="paragraph"?o+=`,fl:${n.fromLine},tl:${n.toLine}`:n.kind==="table"&&(o+=`,fr:${n.fromRow},tr:${n.toRow}`),t.push(o);}return t.join("|")}function jh(e){let t=[];return e.headerContent&&t.push(`hdr:${e.headerContent.blocks.length},${e.headerContent.height}`),e.footerContent&&t.push(`ftr:${e.footerContent.blocks.length},${e.footerContent.height}`),e.theme&&t.push(`thm:${e.theme.name??"default"}`),e.pageBorders&&t.push(`pb:${JSON.stringify(e.pageBorders)}`),e.headerDistance!==void 0&&t.push(`hd:${e.headerDistance}`),e.footerDistance!==void 0&&t.push(`fd:${e.footerDistance}`),t.join("|")}function Uh(e,t){e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.gap=`${t}px`,e.style.padding=`${t}px`,e.style.backgroundColor="var(--doc-bg, #f8f9fa)";}var Di=2,Gh=8;function bs(e,t,n={}){let o=e.length,r=n.pageGap??24,i=t,a=i.__pageRenderState,s=jh(n),l=o>=Gh;if(a&&a.optionsHash===s&&l){let g=a.pageStates,S=a.pageDataMap,w=i.__pageObserver,k=[];for(let _ of e)k.push(cu(_));let E=a.totalPages!==o,R=Math.min(g.length,e.length);for(let _=0;_<R;_++){let V=g[_],$=k[_];if(V.fingerprint===$&&!E){let O=S.get(V.element);O&&(O.page=e[_]);continue}let L=V.element,W=S.get(L);W&&(W.page=e[_],W.rendered&&Kh(L,S,o,n)),V.fingerprint=$,Hi(L,e[_].size.w,e[_].size.h,n),L.dataset.pageNumber=String(e[_].number);}if(e.length>g.length){let _=n.document??document;for(let V=g.length;V<e.length;V++){let $=e[V],L=_.createElement("div");L.className=n.pageClassName??Pn.page,L.dataset.pageNumber=String($.number),L.dataset.pageIndex=String(V),Hi(L,$.size.w,$.size.h,n),t.appendChild(L),g.push({element:L,fingerprint:k[V]}),S.set(L,{page:$,index:V,rendered:false}),w&&w.observe(L);}}if(e.length<g.length){for(let _=g.length-1;_>=e.length;_--){let V=g[_].element;w&&w.unobserve(V),S.delete(V),t.removeChild(V);}g.length=e.length;}for(let _=0;_<g.length;_++){let V=S.get(g[_].element);V&&(V.index=_);}a.totalPages=o,a.currentOptions=n;return}let d=i.__pageObserver;d&&(d.disconnect(),i.__pageObserver=void 0),t.innerHTML="",i.__pageRenderState=void 0,Uh(t,r);let c=[],p=[];for(let g=0;g<e.length;g++){let S=e[g];if(p.push(cu(S)),l){let k=(n.document??document).createElement("div");k.className=n.pageClassName??Pn.page,k.dataset.pageNumber=String(S.number),k.dataset.pageIndex=String(g),Hi(k,S.size.w,S.size.h,n),t.appendChild(k),c.push(k);}else {let{context:w,pageOptions:k}=hs(S,o,n),E=Oi(S,w,k);t.appendChild(E),c.push(E);}}if(!l)return;let f=new Map;for(let g=0;g<e.length;g++)f.set(c[g],{page:e[g],index:g,rendered:false});let m=new IntersectionObserver(g=>{let S=i.__pageRenderState;if(!S)return;let{currentOptions:w,totalPages:k,pageDataMap:E}=S;for(let $ of g){let L=$.target,W=E.get(L);if(W&&$.isIntersecting){Ni(L,E,k,w);for(let O=-Di;O<=Di;O++){let K=W.index+O;K>=0&&K<S.pageStates.length&&K!==W.index&&Ni(S.pageStates[K].element,E,k,w);}}}let R=window.innerHeight,_=R*3,V=new Set;for(let[$,L]of E){if(!L.rendered)continue;let W=$.getBoundingClientRect();W.bottom>-_&&W.top<R+_&&V.add(L.index);}for(let[$,L]of E){if(!L.rendered)continue;let W=false;for(let O of V)if(Math.abs(L.index-O)<=Di+1){W=true;break}!W&&V.size>0&&Yh($,E);}},{root:null,rootMargin:"1500px 0px 1500px 0px"});for(let g of c)m.observe(g);i.__pageObserver=m,i.__pageRenderState={pageStates:c.map((g,S)=>({element:g,fingerprint:p[S]})),totalPages:o,optionsHash:s,pageDataMap:f,currentOptions:n};let b=Math.min(e.length,Di+3);for(let g=0;g<b;g++)Ni(c[g],f,o,n);}function Ni(e,t,n,o){let r=t.get(e);if(!r||r.rendered)return;let{context:i,pageOptions:a}=hs(r.page,n,o),s=Oi(r.page,i,a);for(;s.firstChild;)e.appendChild(s.firstChild);r.rendered=true;}function Kh(e,t,n,o){let r=t.get(e);if(!r)return;let{context:i,pageOptions:a}=hs(r.page,n,o),l=Oi(r.page,i,a).querySelector(`.${Pn.content}`),u=e.querySelector(`.${Pn.content}`);l&&u?e.replaceChild(l,u):(e.innerHTML="",r.rendered=false,Ni(e,t,n,o));}function Yh(e,t){let n=t.get(e);!n||!n.rendered||(e.innerHTML="",n.rendered=false);}var $i=class{constructor(t={}){chunkQEBO3EQP_cjs.d(this,"container",null);chunkQEBO3EQP_cjs.d(this,"blockLookup",new Map);chunkQEBO3EQP_cjs.d(this,"pageStates",[]);chunkQEBO3EQP_cjs.d(this,"totalPages",0);chunkQEBO3EQP_cjs.d(this,"options");chunkQEBO3EQP_cjs.d(this,"doc");this.options=t,this.doc=t.document??document;}setBlockLookup(t){this.blockLookup=t;}mount(t){this.container=t,this.applyContainerStyles();}unmount(){this.container&&(this.container.innerHTML=""),this.container=null,this.pageStates=[];}applyContainerStyles(){if(!this.container)return;let t=this.options.pageGap??24;this.container.style.display="flex",this.container.style.flexDirection="column",this.container.style.alignItems="center",this.container.style.gap=`${t}px`,this.container.style.padding=`${t}px`,this.container.style.backgroundColor=this.options.containerBackground??"var(--doc-bg, #f8f9fa)",this.container.style.minHeight="100%";}paint(t){if(!this.container)throw new Error("LayoutPainter: not mounted");let{pages:n}=t;this.totalPages=n.length,this.container.innerHTML="",this.pageStates=[];for(let o=0;o<n.length;o++){let r=n[o],i={pageNumber:r.number,totalPages:this.totalPages,section:"body"},a=this.renderPageWithLookup(r,i);this.container.appendChild(a),this.pageStates.push({element:a,pageNumber:r.number,fragmentCount:r.fragments.length});}}renderPageWithLookup(t,n){let o=this.doc.createElement("div");o.className="layout-page",o.dataset.pageNumber=String(t.number),o.style.position="relative",o.style.width=`${t.size.w}px`,o.style.height=`${t.size.h}px`,o.style.backgroundColor=this.options.pageBackground??"#ffffff",o.style.overflow="hidden",this.options.showShadow&&(o.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.15)");let r=this.doc.createElement("div");r.className="layout-page-content",r.style.position="absolute",r.style.top=`${t.margins.top}px`,r.style.left=`${t.margins.left}px`,r.style.right=`${t.margins.right}px`,r.style.bottom=`${t.margins.bottom}px`,r.style.overflow="visible";for(let i of t.fragments){let a=this.renderFragmentWithLookup(i,n);this.applyFragmentPosition(a,i),r.appendChild(a);}return o.appendChild(r),o}renderFragmentWithLookup(t,n){let o=this.blockLookup.get(String(t.blockId));if(t.kind==="paragraph"&&o){let r=o.block,i=o.measure;return jn(t,r,i,n,{document:this.doc})}if(t.kind==="table"&&o){let r=o.block,i=o.measure;return Bi(t,r,i,n,{document:this.doc})}if(t.kind==="image"&&o){let r=o.block,i=o.measure;return Ai(t,r,i,n,{document:this.doc})}return Wo(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 pn,Mn,En,fn,fo,Un,du,ys,Wi=class{constructor(){chunkQEBO3EQP_cjs.f(this,Un);chunkQEBO3EQP_cjs.f(this,pn,0);chunkQEBO3EQP_cjs.f(this,Mn,0);chunkQEBO3EQP_cjs.f(this,En,false);chunkQEBO3EQP_cjs.f(this,fn,null);chunkQEBO3EQP_cjs.f(this,fo,new Set);}setStateSeq(t){chunkQEBO3EQP_cjs.g(this,pn,t);}incrementStateSeq(){return ++chunkQEBO3EQP_cjs.i(this,pn)._}getStateSeq(){return chunkQEBO3EQP_cjs.e(this,pn)}getRenderSeq(){return chunkQEBO3EQP_cjs.e(this,Mn)}onLayoutStart(){chunkQEBO3EQP_cjs.g(this,En,true);}onLayoutComplete(t){chunkQEBO3EQP_cjs.g(this,Mn,t),chunkQEBO3EQP_cjs.g(this,En,false),chunkQEBO3EQP_cjs.h(this,Un,du).call(this);}isSafeToRender(){return !chunkQEBO3EQP_cjs.e(this,En)&&chunkQEBO3EQP_cjs.e(this,Mn)>=chunkQEBO3EQP_cjs.e(this,pn)}requestRender(){this.isSafeToRender()?chunkQEBO3EQP_cjs.h(this,Un,ys).call(this):chunkQEBO3EQP_cjs.g(this,fn,()=>chunkQEBO3EQP_cjs.h(this,Un,ys).call(this));}onRender(t){return chunkQEBO3EQP_cjs.e(this,fo).add(t),()=>{chunkQEBO3EQP_cjs.e(this,fo).delete(t);}}reset(){chunkQEBO3EQP_cjs.g(this,pn,0),chunkQEBO3EQP_cjs.g(this,Mn,0),chunkQEBO3EQP_cjs.g(this,En,false),chunkQEBO3EQP_cjs.g(this,fn,null);}getDebugInfo(){return {stateSeq:chunkQEBO3EQP_cjs.e(this,pn),renderSeq:chunkQEBO3EQP_cjs.e(this,Mn),layoutUpdating:chunkQEBO3EQP_cjs.e(this,En),hasPendingRender:chunkQEBO3EQP_cjs.e(this,fn)!==null,isSafe:this.isSafeToRender()}}};pn=new WeakMap,Mn=new WeakMap,En=new WeakMap,fn=new WeakMap,fo=new WeakMap,Un=new WeakSet,du=function(){if(chunkQEBO3EQP_cjs.e(this,fn)&&this.isSafeToRender()){let t=chunkQEBO3EQP_cjs.e(this,fn);chunkQEBO3EQP_cjs.g(this,fn,null),t();}},ys=function(){for(let t of chunkQEBO3EQP_cjs.e(this,fo))try{t();}catch(n){console.error("LayoutSelectionGate: render callback error",n);}};function pu({pagesContainerRef:e}){let t=Mu.useRef(null),n=Mu.useRef(-1),o=Mu.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let d of Array.from(l)){let c=d,p=Number(c.dataset.pmStart),f=Number(c.dataset.pmEnd);if(c.classList.contains("layout-run-tab")){if(s>=p&&s<f)return c.getBoundingClientRect().left;continue}if(s>=p&&s<=f&&d.firstChild?.nodeType===Node.TEXT_NODE){let m=d.firstChild,b=Math.min(s-p,m.length),g=c.ownerDocument;if(!g)continue;let S=g.createRange();return S.setStart(m,b),S.setEnd(m,b),S.getBoundingClientRect().left}}let u=e.current.querySelectorAll(".layout-empty-run");for(let d of Array.from(u)){let c=d.closest(".layout-paragraph");if(!c)continue;let p=Number(c.dataset.pmStart),f=Number(c.dataset.pmEnd);if(s>=p&&s<=f)return d.getBoundingClientRect().left}return null},[e]),r=Mu.useCallback(s=>{if(!e.current)return null;let l=e.current.querySelectorAll(".layout-line");for(let u of Array.from(l)){let d=u,c=d.querySelectorAll("span[data-pm-start][data-pm-end]");for(let p of Array.from(c)){let f=p,m=Number(f.dataset.pmStart),b=Number(f.dataset.pmEnd);if(s>=m&&s<=b)return d}}for(let u of Array.from(l)){let d=u,c=d.closest(".layout-paragraph");if(!c)continue;let p=Number(c.dataset.pmStart),f=Number(c.dataset.pmEnd);if(s>=p&&s<=f&&c.querySelector(".layout-line")===d)return d}return null},[e]),i=Mu.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),S=Number(m.dataset.pmEnd);if(m.classList.contains("layout-run-tab")){if(l>=b.left&&l<=b.right){let w=(b.left+b.right)/2;return l<w?g:S}continue}if(l>=b.left&&l<=b.right){let w=m.firstChild;if(!w||w.nodeType!==Node.TEXT_NODE)return g;let k=w,E=m.ownerDocument;if(!E)return g;let R=0,_=k.length;for(;R<_;){let V=Math.floor((R+_)/2),$=E.createRange();$.setStart(k,V),$.setEnd(k,V),l<$.getBoundingClientRect().left?_=V:R=V+1;}if(R>0&&R<=k.length){let V=E.createRange();V.setStart(k,R-1),V.setEnd(k,R-1);let $=V.getBoundingClientRect().left;V.setStart(k,Math.min(R,k.length)),V.setEnd(k,Math.min(R,k.length));let L=V.getBoundingClientRect().left;if(Math.abs(l-$)<Math.abs(l-L))return g+(R-1)}return g+Math.min(R,S-g)}}let d=null,c=1/0;for(let f of Array.from(u)){let m=f,b=m.getBoundingClientRect(),g=l<b.left?b.left-l:l-b.right;g<c&&(c=g,d=m);}if(!d)return null;let p=d.getBoundingClientRect();return l<p.left?Number(d.dataset.pmStart):Number(d.dataset.pmEnd)},[]),a=Mu.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:d,anchor:c}=s.state.selection;if(t.current===null){let k=o(d);if(k===null)return false;t.current=k;}let p;if(n.current>=0&&n.current<u.length)p=n.current;else {let k=r(d);if(!k||(p=u.indexOf(k),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:S}=s,w=Math.max(0,Math.min(b,g.doc.content.size));try{let k=l.shiftKey?prosemirrorState.TextSelection.create(g.doc,c,w):prosemirrorState.TextSelection.create(g.doc,w);S(g.tr.setSelection(k));}catch{let k=g.doc.resolve(w),E=l.shiftKey?prosemirrorState.TextSelection.between(g.doc.resolve(c),k):prosemirrorState.TextSelection.near(k);S(g.tr.setSelection(E));}return true},[e,o,r,i]);return {stickyXRef:t,lastVisualLineIndexRef:n,getCaretClientX:o,findLineElementAtPosition:r,findPositionOnLineAtClientX:i,handlePMKeyDown:a}}var qh=12,ji=8;function fu(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 xs(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 Xh(e,t,n){let o=[];for(let a=0;a<e.content.length;a++){let s=e.content[a],l=[];if(a===0){let d={kind:"text",text:`${t} `,fontSize:ji,superscript:true};l.push(d);}for(let d of s.content){let c=d;if(c.type==="run"&&Array.isArray(c.content)){let p=c.formatting,f={};if(p){if(p.bold&&(f.bold=true),p.italic&&(f.italic=true),p.underline&&(f.underline=true),p.strike&&(f.strike=true),p.color){let m=p.color;m.val?f.color=`#${m.val}`:m.rgb&&(f.color=`#${m.rgb}`);}if(p.fontSize&&(f.fontSize=p.fontSize/2),p.fontFamily){let m=p.fontFamily;f.fontFamily=m.ascii||m.hAnsi;}}f.fontSize||(f.fontSize=ji);for(let m of c.content){let b=m;b.type==="text"&&typeof b.text=="string"?l.push({kind:"text",text:b.text,...f}):b.type==="tab"?l.push({kind:"tab",...f}):b.type==="break"?l.push({kind:"lineBreak"}):b.type;}}}l.length===0&&l.push({kind:"text",text:"",fontSize:ji});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:ji}]});let r=[];for(let a of o)if(a.kind==="paragraph"){let s=$o(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 mu(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=Xh(l,i,n);o.set(s.footnoteId,u),i++;}return o}function gu(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+=qh,n.set(o,i));}return n}var Ss=class{constructor(t,n=1){chunkQEBO3EQP_cjs.d(this,"pagesContainer");chunkQEBO3EQP_cjs.d(this,"zoom");this.pagesContainer=t,this.zoom=n;}getCoordinatesForPosition(t){let n=this.pagesContainer.getBoundingClientRect(),o=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(o)){let a=i,s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(a.classList.contains("layout-run-tab")){if(t>=s&&t<l){let u=a.getBoundingClientRect(),d=a.closest(".layout-line"),c=d?d.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:c/this.zoom}}continue}if(t>=s&&t<=l&&i.firstChild?.nodeType===Node.TEXT_NODE){let u=i.firstChild,d=Math.min(t-s,u.length),c=a.ownerDocument;if(!c)continue;let p=c.createRange();p.setStart(u,d),p.setEnd(u,d);let f=p.getBoundingClientRect(),m=a.closest(".layout-line"),b=m?m.offsetHeight:16;return {x:(f.left-n.left)/this.zoom,y:(f.top-n.top)/this.zoom,height:b/this.zoom}}}let r=this.pagesContainer.querySelectorAll(".layout-empty-run");for(let i of Array.from(r)){let a=i.closest(".layout-paragraph");if(!a)continue;let s=Number(a.dataset.pmStart),l=Number(a.dataset.pmEnd);if(t>=s&&t<=l){let u=i.getBoundingClientRect(),d=i.closest(".layout-line"),c=d?d.offsetHeight:16;return {x:(u.left-n.left)/this.zoom,y:(u.top-n.top)/this.zoom,height:c/this.zoom}}}return null}findElementsForRange(t,n){let o=[],r=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let i of Array.from(r)){let a=i,s=Number(a.dataset.pmStart);Number(a.dataset.pmEnd)>t&&s<n&&o.push(a);}return o}getRectsForRange(t,n){let o=this.pagesContainer.getBoundingClientRect(),r=[],i=this.pagesContainer.querySelectorAll("span[data-pm-start][data-pm-end]");for(let a of Array.from(i)){let s=a,l=Number(s.dataset.pmStart);if(Number(s.dataset.pmEnd)>t&&l<n){if(s.classList.contains("layout-run-tab")){let m=s.getBoundingClientRect();r.push({x:(m.left-o.left)/this.zoom,y:(m.top-o.top)/this.zoom,width:m.width/this.zoom,height:m.height/this.zoom});continue}if(a.firstChild?.nodeType!==Node.TEXT_NODE)continue;let d=a.firstChild,c=s.ownerDocument;if(!c)continue;let p=Math.max(0,t-l),f=Math.min(d.length,n-l);if(p<f){let m=c.createRange();m.setStart(d,p),m.setEnd(d,f);let b=m.getClientRects();for(let g of Array.from(b))r.push({x:(g.left-o.left)/this.zoom,y:(g.top-o.top)/this.zoom,width:g.width/this.zoom,height:g.height/this.zoom});}}}return r}getContainerOffset(){let t=this.pagesContainer.parentElement;if(!t)return {x:0,y:0};let n=this.pagesContainer.getBoundingClientRect(),o=t.getBoundingClientRect();return {x:(n.left-o.left)/this.zoom,y:(n.top-o.top)/this.zoom}}};function hu(e,t=1){return new Ss(e,t)}var eb=816,ku=1056,Ui={top:96,right:96,bottom:96,left:96},tb=24,nb=[],ob={position:"relative",width:"100%",height:"100%",overflow:"auto",backgroundColor:"var(--doc-bg, #f8f9fa)"},rb={position:"relative",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:24,paddingBottom:24},ib={position:"relative",display:"flex",flexDirection:"column",alignItems:"center"},ab={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",overflow:"visible",zIndex:8};function sn(e){return Math.round(e/1440*96)}function sb(e){return {w:e?.pageWidth?sn(e.pageWidth):eb,h:e?.pageHeight?sn(e.pageHeight):ku}}function lb(e){let t=e?.marginTop?sn(e.marginTop):Ui.top,n=e?.marginBottom?sn(e.marginBottom):Ui.bottom;return {top:t,right:e?.marginRight?sn(e.marginRight):Ui.right,bottom:n,left:e?.marginLeft?sn(e.marginLeft):Ui.left,header:e?.headerDistance?sn(e.headerDistance):48,footer:e?.footerDistance?sn(e.footerDistance):48}}function cb(e){let t=e.wrapType,n=e.displayMode;return !!(t&&["square","tight","through"].includes(t)||n==="float")}function yu(e){return e===void 0?0:Math.round(e*96/914400)}function db(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 wu(e,t){let i=e.columnWidths??[],a=db(e.width,e.widthType,t);if(i.length===0&&e.rows.length>0){let c=e.rows[0].cells.reduce((m,b)=>m+(b.colSpan??1),0),f=(a??t)/Math.max(1,c);i=Array(c).fill(f);}else if(i.length>0&&a){let c=i.reduce((p,f)=>p+f,0);if(c>0&&Math.abs(c-a)>1){let p=a/c;i=i.map(f=>f*p);}}let s=new Map;for(let c=0;c<e.rows.length;c++){let p=e.rows[c];if(!p)continue;let f=0,m=s.get(c)??new Set;for(;m.has(f);)f++;for(let b of p.cells){let g=b.colSpan??1,S=b.rowSpan??1;if(S>1)for(let w=c+1;w<c+S;w++){s.has(w)||s.set(w,new Set);let k=s.get(w);for(let E=0;E<g;E++)k.add(f+E);}for(f+=g;m.has(f);)f++;}}let l=e.rows.map((c,p)=>{let f=0,m=s.get(p)??new Set;for(;m.has(f);)f++;return {cells:c.cells.map(b=>{let g=b.colSpan??1,S=0;for(let R=0;R<g&&f+R<i.length;R++)S+=i[f+R]??0;for(S===0&&(S=b.width??100),f+=g;m.has(f);)f++;let w=b.padding?.left??7,k=b.padding?.right??7,E=Math.max(1,S-w-k);return {blocks:b.blocks.map(R=>Cu(R,E)),width:S,height:0,colSpan:b.colSpan,rowSpan:b.rowSpan}}),height:0}});for(let c=0;c<l.length;c++){let p=l[c],f=e.rows[c]?.cells,m=0;for(let w=0;w<p.cells.length;w++){let k=p.cells[w],E=f?.[w];k.height=k.blocks.reduce((V,$)=>"totalHeight"in $?V+$.totalHeight:V,0);let R=E?.padding?.top??1,_=E?.padding?.bottom??1;k.height+=R+_,m=Math.max(m,k.height);}let b=e.rows[c],g=b?.height,S=b?.heightRule;g&&S==="exact"?p.height=g:g&&S==="atLeast"?p.height=Math.max(m,g):p.height=Math.max(m,24);}let u=l.reduce((c,p)=>c+p.height,0),d=i.reduce((c,p)=>c+p,0)||a||t;return {kind:"table",rows:l,columnWidths:i,totalWidth:d,totalHeight:u}}function ub(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(!cb(s))continue;let l=0,u=s.position,d=s.distTop??0,c=s.distBottom??0,p=s.distLeft??12,f=s.distRight??12;if(u?.vertical){let S=u.vertical;S.align==="top"&&S.relativeTo==="margin"?l=0:S.posOffset!==void 0&&(l=yu(S.posOffset));}let m=l+s.height,b=0,g=0;if(u?.horizontal){let S=u.horizontal;if(S.align==="left")b=s.width+f;else if(S.align==="right")g=s.width+p;else if(S.posOffset!==void 0){let w=yu(S.posOffset);w<t/2?b=w+s.width+f:g=t-w+p;}}else s.cssFloat==="left"?b=s.width+f:s.cssFloat==="right"&&(g=s.width+p);if(b>0||g>0){let S=u?.vertical?.relativeTo==="margin"||u?.vertical?.relativeTo==="page";n.push({leftMargin:b,rightMargin:g,topY:l-d,bottomY:m+c,anchorBlockIndex:o,isMarginRelative:S});}}}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=wu(i,t),l=s.totalWidth,u=s.totalHeight,d=a.leftFromText??12,c=a.rightFromText??12,p=a.topFromText??0,f=a.bottomFromText??0,m=0,b=0,g=0;a.tblpX!==void 0?g=a.tblpX:a.tblpXSpec?a.tblpXSpec==="left"||a.tblpXSpec==="inside"?g=0:a.tblpXSpec==="right"||a.tblpXSpec==="outside"?g=t-l:a.tblpXSpec==="center"&&(g=(t-l)/2):i.justification==="center"?g=(t-l)/2:i.justification==="right"&&(g=t-l),g<t/2?m=g+l+c:b=t-g+d;let S=a.tblpY??0,w=S+u;n.push({leftMargin:m,rightMargin:b,topY:S-p,bottomY:w+f,anchorBlockIndex:o});}return n}function Cu(e,t,n,o){switch(e.kind){case "paragraph":{let r=e;if(!n||n.length===0){let a=is(r,t);if(a)return a}let i=$o(r,t,{floatingZones:n,paragraphYOffset:o??0});return (!n||n.length===0)&&as(r,t,i),i}case "table":return wu(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 Tu(e,t){let n=ub(e,t),o=n.filter(c=>c.isMarginRelative),r=n.filter(c=>!c.isMarginRelative),i=new Map;for(let c of o){let p=i.get(c.topY)??[];p.push(c),i.set(c.topY,p);}let a=[...r];for(let c of i.values()){let p=Math.min(...c.map(f=>f.anchorBlockIndex));for(let f of c)a.push({...f,anchorBlockIndex:p});}let s=new Map;for(let c of a){let p=s.get(c.anchorBlockIndex)??[];p.push({leftMargin:c.leftMargin,rightMargin:c.rightMargin,topY:c.topY,bottomY:c.bottomY}),s.set(c.anchorBlockIndex,p);}let l=new Set(a.map(c=>c.anchorBlockIndex)),u=0,d=[];return e.map((c,p)=>{l.has(p)&&(u=0,d=s.get(p)??[]);let f=d.length>0?d:void 0;try{let m=performance.now(),b=Cu(c,t,f,u),g=performance.now()-m;return g>500&&console.warn(`[measureBlocks] Block ${p} (${c.kind}) took ${Math.round(g)}ms`),"totalHeight"in b&&(c.kind==="table"&&c.floating||(u+=b.totalHeight)),b}catch(m){return console.error(`[measureBlocks] Error measuring block ${p} (${c.kind}):`,m),{totalHeight:20}}})}function Gi(e){let t=[];for(let n of e){let o=n;if(o.type==="run"&&Array.isArray(o.content)){let r=o.formatting,i={};if(r){if(r.bold&&(i.bold=true),r.italic&&(i.italic=true),r.underline&&(i.underline=true),r.strike&&(i.strike=true),r.color){let a=r.color;a.val?i.color=`#${a.val}`:a.rgb&&(i.color=`#${a.rgb}`);}if(r.fontSize&&(i.fontSize=r.fontSize/2),r.fontFamily){let a=r.fontFamily;i.fontFamily=a.ascii||a.hAnsi;}}for(let a of o.content){let s=a;if(s.type==="text"&&typeof s.text=="string")t.push({kind:"text",text:s.text,...i});else if(s.type==="tab")t.push({kind:"tab",...i});else if(s.type==="break")t.push({kind:"lineBreak"});else if(s.type==="drawing"&&s.image){let l=s.image,u=l.size,d=m=>Math.round(m/914400*96),c=u?.width?d(u.width):100,p=u?.height?d(u.height):100,f=l.position;t.push({kind:"image",src:l.src||"",width:c,height:p,alt:l.alt||void 0,position:f?{horizontal:f.horizontal,vertical:f.vertical}:void 0});}}}if(o.type==="simpleField"){let r=o.fieldType,i={};if(Array.isArray(o.content)&&o.content.length>0){let a=o.content[0];if(a?.type==="run"&&a.formatting){let s=a.formatting;if(s.fontSize&&(i.fontSize=s.fontSize/2),s.fontFamily){let l=s.fontFamily;i.fontFamily=l.ascii||l.hAnsi;}if(s.bold&&(i.bold=true),s.italic&&(i.italic=true),s.color){let l=s.color,u=l.rgb||l.val;u&&(i.color=u.startsWith("#")?u:`#${u}`);}}}if(r==="PAGE")t.push({kind:"field",fieldType:"PAGE",fallback:"1",...i});else if(r==="NUMPAGES")t.push({kind:"field",fieldType:"NUMPAGES",fallback:"1",...i});else if(Array.isArray(o.content)){let a=Gi(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=Gi(o.fieldResult);t.push(...a);}}if(o.type==="hyperlink"&&Array.isArray(o.children)){let r=Gi(o.children);t.push(...r);}}return t}function xu(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 c=l.alignment;c==="both"?u.alignment="justify":["left","center","right","justify"].includes(c)&&(u.alignment=c);}let d=Gi(s.content);if(d.length>0){let c={kind:"paragraph",id:String(n.length),runs:d,attrs:Object.keys(u).length>0?u:void 0};n.push(c);}}}if(n.length===0)return;let o=n.map(a=>{if(a.kind!=="paragraph")return a;let s=a;if(!s.runs.some(d=>d.kind==="image"&&"position"in d&&d.position))return a;let u=s.runs.filter(d=>!(d.kind==="image"&&"position"in d&&d.position));return u.length===0&&u.push({kind:"text",text:""}),{...s,runs:u}}),r=Tu(o,t),i=r.reduce((a,s)=>s.kind==="paragraph"?a+s.totalHeight:a,0);return {blocks:n,measures:r,height:i}}function pb(e,t,n){let o=new Map;if(!n?.package?.footnotes)return o;let r=new Map;for(let i of n.package.footnotes)i.noteType&&i.noteType!=="normal"||r.set(i.id,i);for(let[i,a]of e){let s=[];for(let l of a){let u=r.get(l);if(!u)continue;let c=t.get(l)?.displayNumber??0,p=chunkC33XDRDJ_cjs.e(u);s.push({displayNumber:String(c),text:p});}s.length>0&&o.set(i,s);}return o}var fb=Mu.forwardRef(function(t,n){let{document:o,styles:r,theme:i,sectionProperties:a,headerContent:s,footerContent:l,readOnly:u=false,pageGap:d=tb,zoom:c=1,onDocumentChange:p,onSelectionChange:f,externalPlugins:m=nb,extensionManager:b,onReady:g,onRenderedDomContextReady:S,pluginOverlays:w,onHeaderFooterDoubleClick:k,hfEditMode:E,onBodyClick:R,className:_,style:V,commentsSidebarOpen:$=false,sidebarOverlay:L,scrollContainerRef:W}=t,O=Mu.useRef(null),K=Mu.useRef(null),C=Mu.useRef(null),B=Mu.useRef(null),{handlePMKeyDown:ee}=pu({pagesContainerRef:K}),ge=Mu.useRef(f),pe=Mu.useRef(p),Ee=Mu.useRef(g),Te=Mu.useRef(S);ge.current=f,pe.current=p,Ee.current=g,Te.current=S;let[Re,P]=Mu.useState(null),[I,y]=Mu.useState([]),[M,F]=Mu.useState([]),[D,j]=Mu.useState(false),[J,N]=Mu.useState([]),[U,G]=Mu.useState(null),[xe,v]=Mu.useState(null),z=Mu.useRef(false),A=Mu.useCallback((T,oe)=>{let q=T.tagName==="IMG"?T:T.querySelector("img"),X=(q??T).getBoundingClientRect();return {element:q??T,pmPos:oe,width:Math.round(X.width/c),height:Math.round(X.height/c)}},[c]),te=Mu.useRef(false),de=Mu.useRef(null),he=Mu.useRef(false),Be=Mu.useRef(0),me=Mu.useRef(0),Se=Mu.useRef(0),ue=Mu.useRef({left:0,right:0}),ze=Mu.useRef(null),tt=Mu.useRef(false),Ue=Mu.useRef(0),rt=Mu.useRef(0),Oe=Mu.useRef(0),Qe=Mu.useRef(0),dt=Mu.useRef(null),Ge=Mu.useRef(false),pt=Mu.useRef(false),$e=Mu.useRef(0),Ht=Mu.useRef(0),mn=Mu.useRef(0),ln=Mu.useRef(0),Mt=Mu.useRef(null),Et=Mu.useRef(false),le=Mu.useRef(null),gn=Mu.useRef(null),Xt=Mu.useRef(null),qo=5,$t=Mu.useMemo(()=>new Wi,[]),Ne=Mu.useMemo(()=>sb(a),[a]),nt=Mu.useMemo(()=>lb(a),[a]),It=Ne.w-nt.left-nt.right,Wt=Mu.useMemo(()=>new $i({pageGap:d,showShadow:true,pageBackground:"#fff"}),[d]);B.current=Wt;let vt=Mu.useCallback(T=>{let oe=performance.now(),q=$t.getStateSeq();$t.onLayoutStart();try{let X=performance.now(),ne=Ne.h-nt.top-nt.bottom,Y=$d(T.doc,{theme:i,pageContentHeight:ne}),Z=performance.now()-X;Z>500&&console.warn(`[PagedEditor] toFlowBlocks took ${Math.round(Z)}ms (${Y.length} blocks)`),y(Y),X=performance.now();let Q=Tu(Y,It);Z=performance.now()-X,Z>1e3&&console.warn(`[PagedEditor] measureBlocks took ${Math.round(Z)}ms (${Y.length} blocks)`),F(Q);let ce=fu(Y),we=ce.length>0&&o?.package?.footnotes,be=xu(s,It),Ce=xu(l,It),Ie=nt.header??48,Fe=nt.footer??48,Ye=nt.top-Ie,Xe=nt.bottom-Fe,yt=be?.height??0,at=Ce?.height??0,At=nt;(yt>Ye||at>Xe)&&(At={...nt},yt>Ye&&(At.top=Ie+yt),at>Xe&&(At.bottom=Fe+at)),X=performance.now();let zt,Dn=new Map,yo=new Map;if(we){let hn=Ri(Y,Q,{pageSize:Ne,margins:At});Dn=xs(hn.pages,ce),yo=mu(o.package.footnotes,ce,It);let Qt=gu(Dn,yo);if(Qt.size>0){zt=Ri(Y,Q,{pageSize:Ne,margins:At,footnoteReservedHeights:Qt}),Dn=xs(zt.pages,ce);for(let[et,Hn]of Dn){let Nn=zt.pages.find(na=>na.number===et);Nn&&(Nn.footnoteIds=Hn);}}else zt=hn;}else zt=Ri(Y,Q,{pageSize:Ne,margins:At});if(Z=performance.now()-X,Z>500&&console.warn(`[PagedEditor] layoutDocument took ${Math.round(Z)}ms (${zt.pages.length} pages)`),P(zt),K.current&&B.current){X=performance.now();let hn=new Map;for(let et=0;et<Y.length;et++){let Hn=Y[et],Nn=Q[et];Hn&&Nn&&hn.set(String(Hn.id),{block:Hn,measure:Nn});}B.current.setBlockLookup(hn);let Qt=we?pb(Dn,yo,o):void 0;if(bs(zt.pages,K.current,{pageGap:d,showShadow:!0,pageBackground:"#fff",blockLookup:hn,headerContent:be,footerContent:Ce,headerDistance:a?.headerDistance?sn(a.headerDistance):void 0,footerDistance:a?.footerDistance?sn(a.footerDistance):void 0,pageBorders:a?.pageBorders,theme:i,footnotesByPage:Qt?.size?Qt:void 0}),Z=performance.now()-X,Z>500&&console.warn(`[PagedEditor] renderPages took ${Math.round(Z)}ms`),S){let et=hu(K.current,c);S(et);}}let xo=performance.now()-oe;xo>2e3&&console.warn(`[PagedEditor] Layout pipeline took ${Math.round(xo)}ms total (${Y.length} blocks, ${Q.length} measures)`);}catch(X){console.error("[PagedEditor] Layout pipeline error:",X);}$t.onLayoutComplete(q);},[It,Ne,nt,d,c,$t,s,l,a,S,o]),_t=Mu.useRef(null),Zn=Mu.useCallback(T=>{if(_t.current){_t.current.state=T;return}let oe=requestAnimationFrame(()=>{let q=_t.current;_t.current=null,q&&vt(q.state);});_t.current={rafId:oe,state:T};},[vt]);Mu.useEffect(()=>()=>{_t.current&&(cancelAnimationFrame(_t.current.rafId),_t.current=null);},[]);let Jn=Mu.useCallback((T,oe=1)=>{if(!K.current)return null;let q=K.current.parentElement?.querySelector('[data-testid="selection-overlay"]');if(!q)return null;let X=q.getBoundingClientRect(),ne=K.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let Z of Array.from(ne)){let Q=Z,ce=Number(Q.dataset.pmStart),we=Number(Q.dataset.pmEnd);if(Q.classList.contains("layout-run-tab")){if(T>=ce&&T<we){let be=Q.getBoundingClientRect(),Ce=Q.closest(".layout-page"),Ie=Ce?Number(Ce.dataset.pageNumber)-1:0,Fe=Q.closest(".layout-line"),Ye=Fe?Fe.offsetHeight:16;return {x:(be.left-X.left)/oe,y:(be.top-X.top)/oe,height:Ye,pageIndex:Ie}}continue}if(T>=ce&&T<=we&&Z.firstChild?.nodeType===Node.TEXT_NODE){let be=Z.firstChild,Ce=Math.min(T-ce,be.length),Ie=Q.ownerDocument;if(!Ie)continue;let Fe=Ie.createRange();Fe.setStart(be,Ce),Fe.setEnd(be,Ce);let Ye=Fe.getBoundingClientRect(),Xe=Q.closest(".layout-page"),yt=Xe?Number(Xe.dataset.pageNumber)-1:0,at=Q.closest(".layout-line"),At=at?at.offsetHeight:16;return {x:(Ye.left-X.left)/oe,y:(Ye.top-X.top)/oe,height:At,pageIndex:yt}}}let Y=K.current.querySelectorAll(".layout-empty-run");for(let Z of Array.from(Y)){let Q=Z.closest(".layout-paragraph");if(!Q)continue;let ce=Number(Q.dataset.pmStart),we=Number(Q.dataset.pmEnd);if(T>=ce&&T<=we){let be=Z.getBoundingClientRect(),Ce=Q.closest(".layout-page"),Ie=Ce?Number(Ce.dataset.pageNumber)-1:0,Fe=Z.closest(".layout-line"),Ye=Fe?Fe.offsetHeight:16;return {x:(be.left-X.left)/oe,y:(be.top-X.top)/oe,height:Ye,pageIndex:Ie}}}return null},[]),Ft=Mu.useCallback(T=>{let{from:oe,to:q}=T.selection;if(ge.current?.(oe,q),K.current){let X=K.current.querySelectorAll(".layout-table-cell-selected");for(let Z of Array.from(X))Z.classList.remove("layout-table-cell-selected");let ne=T.selection;if("$anchorCell"in ne&&typeof ne.forEachCell=="function"){let Z=[];ne.forEachCell((ce,we)=>{Z.push([we,we+ce.nodeSize]);});let Q=K.current.querySelectorAll(".layout-table-cell");for(let ce of Array.from(Q)){let we=ce,be=we.dataset.pmStart;if(be!==void 0){let Ce=Number(be);for(let[Ie,Fe]of Z)if(Ce>=Ie&&Ce<Fe){we.classList.add("layout-table-cell-selected");break}}}}}if(!(!Re||I.length===0))if(oe===q){let X=Jn(oe,c);if(X)G(X);else {let ne=K.current?.parentElement?.querySelector('[data-testid="selection-overlay"]'),Y=K.current?.querySelector(".layout-page");if(ne&&Y){let Z=ne.getBoundingClientRect(),Q=Y.getBoundingClientRect(),ce=chunk5FJXHXFV_cjs.l(Re,I,M,oe);G(ce?{...ce,x:ce.x+(Q.left-Z.left)/c,y:ce.y+(Q.top-Z.top)/c}:null);}else G(null);}N([]);}else {let X=K.current?.parentElement?.querySelector('[data-testid="selection-overlay"]');if(X&&K.current){let ne=X.getBoundingClientRect(),Y=[],Z=K.current.querySelectorAll("span[data-pm-start][data-pm-end]");for(let Q of Array.from(Z)){let ce=Q,we=Number(ce.dataset.pmStart);if(Number(ce.dataset.pmEnd)>oe&&we<q){if(ce.classList.contains("layout-run-tab")){let Xe=ce.getBoundingClientRect(),yt=ce.closest(".layout-page"),at=yt?Number(yt.dataset.pageNumber)-1:0;Y.push({x:(Xe.left-ne.left)/c,y:(Xe.top-ne.top)/c,width:Xe.width/c,height:Xe.height/c,pageIndex:at});continue}if(Q.firstChild?.nodeType!==Node.TEXT_NODE)continue;let Ce=Q.firstChild,Ie=ce.ownerDocument;if(!Ie)continue;let Fe=Math.max(0,oe-we),Ye=Math.min(Ce.length,q-we);if(Fe<Ye){let Xe=Ie.createRange();Xe.setStart(Ce,Fe),Xe.setEnd(Ce,Ye);let yt=Xe.getClientRects();for(let at of Array.from(yt)){let At=ce.closest(".layout-page"),zt=At?Number(At.dataset.pageNumber)-1:0;Y.push({x:(at.left-ne.left)/c,y:(at.top-ne.top)/c,width:at.width/c,height:at.height/c,pageIndex:zt});}}}}if(Y.length>0)N(Y);else {let Q=K.current.querySelector(".layout-page");if(Q){let ce=Q.getBoundingClientRect(),we=(ce.left-ne.left)/c,be=(ce.top-ne.top)/c,Ie=chunk5FJXHXFV_cjs.k(Re,I,M,oe,q).map(Fe=>({...Fe,x:Fe.x+we,y:Fe.y+be}));N(Ie);}else N([]);}}else N([]);G(null);}},[Re,I,M,Jn,c]),Bn=Mu.useCallback((T,oe)=>{if(T.docChanged){$t.incrementStateSeq(),Zn(oe);let q=C.current?.getDocument();q&&pe.current?.(q);}$t.requestRender(),T.docChanged||Ft(oe);},[Zn,Ft,$t]),Xo=Mu.useCallback(T=>{let{selection:oe}=T;oe instanceof prosemirrorState.NodeSelection&&oe.node.type.name==="image"?(N([]),G(null)):$t.isSafeToRender()&&Ft(T),requestAnimationFrame(()=>{let q=C.current?.getView();if(!q){v(null);return}let{selection:X}=q.state;if(X instanceof prosemirrorState.NodeSelection&&X.node.type.name==="image"){let ne=X.from,Y=K.current?.querySelector(`[data-pm-start="${ne}"]`);if(Y){v(A(Y,ne));return}}z.current||v(null);});},[Ft,c,A,$t]),Lt=Mu.useCallback((T,oe)=>{if(!K.current||!Re)return null;let q=Zd(K.current,T,oe,c);if(q!==null)return q;let X=K.current.querySelectorAll(".layout-page"),ne=-1,Y=null;for(let Ce=0;Ce<X.length;Ce++){let Fe=X[Ce].getBoundingClientRect();if(T>=Fe.left&&T<=Fe.right&&oe>=Fe.top&&oe<=Fe.bottom){ne=Ce,Y=Fe;break}}if(ne<0||!Y)return null;let Z=(T-Y.left)/c,Q=(oe-Y.top)/c,ce=Re.pages[ne];if(!ce)return null;let we={pageIndex:ne,page:ce,pageY:Q},be=chunk5FJXHXFV_cjs.i(we,I,M,{x:Z,y:Q});if(!be)return null;if(be.fragment.kind==="table"){let Ce=chunk5FJXHXFV_cjs.j(we,I,M,{x:Z,y:Q});return ls(be,Ce)}return ls(be)},[Re,I,M,c]),Zt=Mu.useCallback(T=>{let oe=C.current?.getView();if(!oe)return null;try{let q=oe.state.doc.resolve(T);for(let X=q.depth;X>0;X--){let ne=q.node(X);if(ne.type.name==="tableCell"||ne.type.name==="tableHeader")return q.before(X)}}catch{}return null},[]),Bt=Mu.useCallback(T=>{let oe=["layout-block-image","layout-image","layout-page-floating-image"],q=X=>!!X.dataset.pmStart&&oe.some(ne=>X.classList.contains(ne));return T.tagName==="IMG"&&T.classList.contains("layout-run-image")?T:T.tagName==="IMG"&&T.parentElement&&q(T.parentElement)?T.parentElement:q(T)?T:null},[]),Qn=Mu.useCallback(T=>{let oe=K.current;if(!oe)return;let q=oe.querySelector(`[data-pm-start="${T}"]`);q&&q.scrollIntoView({behavior:"smooth",block:"center"});},[]),De=Mu.useCallback(T=>{if(!C.current||T.button!==0)return;if(T.target.closest('a[href^="#"]')){T.preventDefault(),T.stopPropagation();return}if(u)return;if(E&&R){let Y=T.target;if(!(Y.closest(".layout-page-header")||Y.closest(".layout-page-footer")||Y.closest(".hf-inline-editor"))){T.preventDefault(),T.stopPropagation(),R();return}}if(!E){let Y=T.target;if(Y.closest(".layout-page-header")||Y.closest(".layout-page-footer")){T.preventDefault(),C.current&&(C.current.setSelection(0),C.current.focus(),j(true));return}}let q=T.target;if(q.classList.contains("layout-table-resize-handle")){T.preventDefault(),T.stopPropagation(),he.current=true,Be.current=T.clientX,ze.current=q,q.classList.add("dragging");let Y=parseInt(q.dataset.columnIndex??"0",10);me.current=Y,Se.current=parseInt(q.dataset.tablePmStart??"0",10);let Z=C.current.getView();if(Z){let Q=Z.state.doc.resolve(Se.current+1);for(let ce=Q.depth;ce>=0;ce--){let we=Q.node(ce);if(we.type.name==="table"){let be=we.attrs.columnWidths;be&&be[Y]!==void 0&&be[Y+1]!==void 0&&(ue.current={left:be[Y],right:be[Y+1]});break}}}return}if(q.classList.contains("layout-table-row-resize-handle")||q.classList.contains("layout-table-edge-handle-bottom")){T.preventDefault(),T.stopPropagation(),tt.current=true,Ue.current=T.clientY,dt.current=q,Ge.current=q.dataset.isEdge==="bottom",q.classList.add("dragging");let Y=parseInt(q.dataset.rowIndex??"0",10);rt.current=Y,Oe.current=parseInt(q.dataset.tablePmStart??"0",10);let Z=C.current.getView();if(Z){let Q=Z.state.doc.resolve(Oe.current+1);for(let ce=Q.depth;ce>=0;ce--){let we=Q.node(ce);if(we.type.name==="table"){let be=null,Ce=0;if(we.forEach(Ie=>{Ce===Y&&(be=Ie),Ce++;}),be){let Ie=be.attrs.height;if(Ie)Qe.current=Ie;else {let Ye=q.closest(".layout-table")?.querySelector(`[data-row-index="${Y}"]`),Xe=Ye?Ye.getBoundingClientRect().height:30;Qe.current=Math.round(Xe*15);}}break}}}return}if(q.classList.contains("layout-table-edge-handle-right")){T.preventDefault(),T.stopPropagation(),pt.current=true,$e.current=T.clientX,Mt.current=q,q.classList.add("dragging");let Y=parseInt(q.dataset.columnIndex??"0",10);Ht.current=Y,mn.current=parseInt(q.dataset.tablePmStart??"0",10);let Z=C.current.getView();if(Z){let Q=Z.state.doc.resolve(mn.current+1);for(let ce=Q.depth;ce>=0;ce--){let we=Q.node(ce);if(we.type.name==="table"){let be=we.attrs.columnWidths;be&&be[Y]!==void 0&&(ln.current=be[Y]);break}}}return}let X=Bt(q);if(X){T.preventDefault(),T.stopPropagation();let Y=X.dataset.pmStart;if(Y!==void 0){let Z=parseInt(Y,10);C.current.setNodeSelection(Z),v(A(X,Z)),N([]),G(null);}C.current.focus(),j(true);return}v(null),T.preventDefault();let ne=Lt(T.clientX,T.clientY);if(ne!==null){let Y=Zt(ne);le.current=Y,Et.current=false,gn.current=null,Xt.current=null,te.current=true,de.current=ne,C.current.setSelection(ne);}else {le.current=null,Et.current=false;let Y=C.current.getView();if(Y){let Z=Math.max(0,Y.state.doc.content.size-1);C.current.setSelection(Z),de.current=Z,te.current=true;}}C.current.focus(),j(true);},[Lt,Zt,u,E,R,c]),qe=Mu.useCallback(T=>{if(he.current){T.preventDefault();let X=T.clientX-Be.current;if(ze.current){let ne=parseFloat(ze.current.style.left);ze.current.style.left=`${ne+X}px`,Be.current=T.clientX;let Y=Math.round(X*15),Z=300,Q=ue.current.left+Y,ce=ue.current.right-Y;Q>=Z&&ce>=Z&&(ue.current={left:Q,right:ce});}return}if(tt.current){T.preventDefault();let X=T.clientY-Ue.current;if(dt.current){let ne=parseFloat(dt.current.style.top);dt.current.style.top=`${ne+X}px`,Ue.current=T.clientY;let Y=Math.round(X*15),Z=200,Q=Qe.current+Y;Q>=Z&&(Qe.current=Q);}return}if(pt.current){T.preventDefault();let X=T.clientX-$e.current;if(Mt.current){let ne=parseFloat(Mt.current.style.left);Mt.current.style.left=`${ne+X}px`,$e.current=T.clientX;let Y=Math.round(X*15),Z=300,Q=ln.current+Y;Q>=Z&&(ln.current=Q);}return}if(!te.current||de.current===null||!C.current||!K.current)return;let oe=Lt(T.clientX,T.clientY);if(oe===null)return;if(le.current!==null){if(Et.current){let ne=Zt(oe);if(ne!==null){C.current.setCellSelection(le.current,ne);return}}let X=Zt(oe);if(X!==null&&X!==le.current){Et.current=true,C.current.setCellSelection(le.current,X),Xt.current=null;return}if(gn.current!==null&&oe===gn.current){if(Xt.current===null)Xt.current=T.clientX;else if(Math.abs(T.clientX-Xt.current)>=qo){Et.current=true,C.current.setCellSelection(le.current,le.current),Xt.current=null;return}}else Xt.current=null,gn.current=oe;}let q=de.current;C.current.setSelection(q,oe);},[Lt,Zt]),ho=Mu.useCallback(()=>{if(he.current){he.current=false,ze.current&&(ze.current.classList.remove("dragging"),ze.current=null);let T=C.current?.getView();if(T){let oe=Se.current,q=me.current,{left:X,right:ne}=ue.current,Y=T.state.doc.resolve(oe+1);for(let Z=Y.depth;Z>=0;Z--){let Q=Y.node(Z);if(Q.type.name==="table"){let ce=Y.before(Z),we=T.state.tr,be=[...Q.attrs.columnWidths];be[q]=X,be[q+1]=ne,we.setNodeMarkup(ce,void 0,{...Q.attrs,columnWidths:be});let Ce=ce+1;Q.forEach(Ie=>{let Fe=Ce+1,Ye=0;Ie.forEach(Xe=>{let yt=Xe.attrs.colspan||1;if(Ye===q||Ye===q+1){let at=Ye===q?X:ne;we.setNodeMarkup(we.mapping.map(Fe),void 0,{...Xe.attrs,width:at,widthType:"dxa",colwidth:null});}Fe+=Xe.nodeSize,Ye+=yt;}),Ce+=Ie.nodeSize;}),T.dispatch(we);break}}}return}if(tt.current){tt.current=false,dt.current&&(dt.current.classList.remove("dragging"),dt.current=null);let T=C.current?.getView();if(T){let oe=Oe.current,q=rt.current,X=Qe.current,ne=T.state.doc.resolve(oe+1);for(let Y=ne.depth;Y>=0;Y--){let Z=ne.node(Y);if(Z.type.name==="table"){let Q=ne.before(Y),ce=T.state.tr,we=Q+1,be=0;Z.forEach(Ce=>{be===q&&ce.setNodeMarkup(ce.mapping.map(we),void 0,{...Ce.attrs,height:X,heightRule:"atLeast"}),we+=Ce.nodeSize,be++;}),T.dispatch(ce);break}}}return}if(pt.current){pt.current=false,Mt.current&&(Mt.current.classList.remove("dragging"),Mt.current=null);let T=C.current?.getView();if(T){let oe=mn.current,q=Ht.current,X=ln.current,ne=T.state.doc.resolve(oe+1);for(let Y=ne.depth;Y>=0;Y--){let Z=ne.node(Y);if(Z.type.name==="table"){let Q=ne.before(Y),ce=T.state.tr,we=[...Z.attrs.columnWidths];we[q]=X,ce.setNodeMarkup(Q,void 0,{...Z.attrs,columnWidths:we});let be=Q+1;Z.forEach(Ce=>{let Ie=be+1,Fe=0;Ce.forEach(Ye=>{let Xe=Ye.attrs.colspan||1;Fe===q&&ce.setNodeMarkup(ce.mapping.map(Ie),void 0,{...Ye.attrs,width:X,widthType:"dxa",colwidth:null}),Ie+=Ye.nodeSize,Fe+=Xe;}),be+=Ce.nodeSize;}),T.dispatch(ce);break}}}return}te.current=false,Et.current=false,gn.current=null,Xt.current=null;},[]);Mu.useEffect(()=>(window.addEventListener("mousemove",qe),window.addEventListener("mouseup",ho),()=>{window.removeEventListener("mousemove",qe),window.removeEventListener("mouseup",ho);}),[qe,ho]);let Xi=Mu.useCallback(T=>{let oe=T.target.closest('a[href^="#"]');if(oe){T.preventDefault(),T.stopPropagation();let q=oe.getAttribute("href")?.substring(1);if(q&&C.current){let X=C.current.getView();if(X){let ne=null;X.state.doc.descendants((Y,Z)=>{if(ne!==null)return false;if(Y.type.name==="paragraph"&&Y.attrs.bookmarks?.some(ce=>ce.name===q))return ne=Z,false}),ne!==null&&(Qn(ne),C.current.setSelection(ne+1));}}return}if(T.detail===2&&k){let q=T.target,X=q.closest(".layout-page-header"),ne=q.closest(".layout-page-footer");if(X){T.preventDefault(),T.stopPropagation(),k("header");return}if(ne){T.preventDefault(),T.stopPropagation(),k("footer");return}}if(T.detail===2&&C.current){let q=Lt(T.clientX,T.clientY);if(q!==null){let X=Zt(q);if(X!==null){T.preventDefault(),T.stopPropagation(),C.current.setCellSelection(X,X);return}let ne=C.current.getView();if(ne){let{doc:Y}=ne.state,Z=Y.resolve(q),Q=Z.parent;if(Q.isTextblock){let ce=Q.textContent,we=Z.parentOffset,be=we;for(;be>0&&/\w/.test(ce[be-1]);)be--;let Ce=we;for(;Ce<ce.length&&/\w/.test(ce[Ce]);)Ce++;let Ie=Z.start()+be,Fe=Z.start()+Ce;Ie<Fe&&C.current.setSelection(Ie,Fe);}}}}if(T.detail===3&&C.current){let q=Lt(T.clientX,T.clientY);if(q!==null){let X=C.current.getView();if(X){let{doc:ne}=X.state,Y=ne.resolve(q),Z=Y.start(Y.depth),Q=Y.end(Y.depth);C.current.setSelection(Z,Q);}}}},[Lt,k]),ft=Mu.useCallback(T=>{u||T.target.closest(".docx-comments-sidebar")||(C.current?.focus(),j(true));},[u]),mt=Mu.useCallback(T=>{let oe=T.relatedTarget;oe&&O.current?.contains(oe)||j(false);},[]),Zo=Mu.useCallback((T,oe,q)=>{let X=C.current?.getView();if(X)try{let ne=X.state.doc.nodeAt(T);if(!ne||ne.type.name!=="image")return;let Y=X.state.tr.setNodeMarkup(T,void 0,{...ne.attrs,width:oe,height:q});X.dispatch(Y),C.current?.setNodeSelection(T);}catch{}},[]),Nt=Mu.useCallback(()=>{z.current=true;},[]),Jt=Mu.useCallback(()=>{z.current=false;},[]),bo=Mu.useCallback((T,oe,q)=>{let X=C.current?.getView();if(X)try{let ne=X.state.doc.nodeAt(T);if(!ne||ne.type.name!=="image")return;if(ne.attrs.displayMode==="float"||ne.attrs.wrapType&&["square","tight","through"].includes(ne.attrs.wrapType)){let Z=K.current?.querySelectorAll(".layout-page");if(!Z||Z.length===0)return;let Q=null;for(let yt of Z){let at=yt.getBoundingClientRect();if(q>=at.top&&q<=at.bottom){Q=yt.querySelector(".layout-page-content");break}}if(Q||(Q=Z[Z.length-1].querySelector(".layout-page-content")),!Q)return;let ce=Q.getBoundingClientRect(),we=(oe-ce.left)/c,be=(q-ce.top)/c,Ce=914400/96,Ie=Math.round(we*Ce),Fe=Math.round(be*Ce),Ye={horizontal:{posOffset:Ie,relativeTo:"margin"},vertical:{posOffset:Fe,relativeTo:"margin"}},Xe=X.state.tr.setNodeMarkup(T,void 0,{...ne.attrs,position:Ye});X.dispatch(Xe),C.current?.setNodeSelection(T);}else {let Z=Lt(oe,q);if(Z===null||Z===T||Z===T+1)return;let Q=X.state.tr;if(Z<=T)Q=Q.delete(T,T+ne.nodeSize),Q=Q.insert(Z,ne),C.current?.setNodeSelection(Z);else {Q=Q.delete(T,T+ne.nodeSize);let ce=Z-ne.nodeSize;Q=Q.insert(Math.min(ce,Q.doc.content.size),ne),C.current?.setNodeSelection(Math.min(ce,Q.doc.content.size-1));}X.dispatch(Q);}}catch{}},[Lt,c]),An=Mu.useCallback(()=>{z.current=true;},[]),Zi=Mu.useCallback(()=>{z.current=false;},[]),Ji=Mu.useCallback(T=>{if(!u){if(C.current?.isFocused()||(C.current?.focus(),j(true)),T.key===" "&&!T.ctrlKey&&!T.metaKey){T.preventDefault();let oe=C.current?.getView();if(oe){let{from:q,to:X}=oe.state.selection;oe.someProp("handleTextInput",Y=>Y(oe,q,X," "))||oe.dispatch(oe.state.tr.insertText(" "));}return}["PageUp","PageDown"].includes(T.key)&&!T.metaKey&&T.ctrlKey,T.key==="Home"&&(T.metaKey||T.ctrlKey)&&O.current&&(O.current.scrollTop=0),T.key==="End"&&(T.metaKey||T.ctrlKey)&&O.current&&(O.current.scrollTop=O.current.scrollHeight);}},[u]),Qi=Mu.useCallback(T=>{u||T.target.closest(".docx-comments-sidebar")||C.current?.isFocused()||(C.current?.focus(),j(true));},[u]),ea=Mu.useCallback(T=>{vt(T.state),Ft(T.state),u||requestAnimationFrame(()=>{T.focus(),j(true);});},[vt,Ft,u]);Mu.useEffect(()=>{let T=()=>{let oe=C.current?.getView();oe&&(chunk5FJXHXFV_cjs.c(),ss(),vt(oe.state),Ft(oe.state));};return window.document.fonts.addEventListener("loadingdone",T),()=>{window.document.fonts.removeEventListener("loadingdone",T);}},[]);let Jo=Mu.useRef(0);Mu.useEffect(()=>{if(Jo.current===0){Jo.current=1;return}let T=C.current?.getView();T&&vt(T.state);},[s,l,vt]),Mu.useEffect(()=>{let T=O.current;if(!T)return;let oe=new ResizeObserver(()=>{let q=C.current?.getState();q&&Ft(q);});return oe.observe(T),()=>oe.disconnect()},[Ft]),Mu.useImperativeHandle(n,()=>({getDocument(){return C.current?.getDocument()??null},getState(){return C.current?.getState()??null},getView(){return C.current?.getView()??null},focus(){C.current?.focus(),j(true);},blur(){C.current?.blur(),j(false);},isFocused(){return C.current?.isFocused()??false},dispatch(T){C.current?.dispatch(T);},undo(){return C.current?.undo()??false},redo(){return C.current?.redo()??false},setSelection(T,oe){C.current?.setSelection(T,oe);},getLayout(){return Re},relayout(){let T=C.current?.getState();T&&vt(T);},scrollToPosition:Qn}),[Re,vt,Qn]),Mu.useEffect(()=>{let T=C.current?.getState();Re&&T&&Ft(T);},[Re,Ft]),Mu.useEffect(()=>{Ee.current&&C.current&&Ee.current({getDocument:()=>C.current?.getDocument()??null,getState:()=>C.current?.getState()??null,getView:()=>C.current?.getView()??null,focus:()=>{C.current?.focus(),j(true);},blur:()=>{C.current?.blur(),j(false);},isFocused:()=>C.current?.isFocused()??false,dispatch:T=>C.current?.dispatch(T),undo:()=>C.current?.undo()??false,redo:()=>C.current?.redo()??false,setSelection:(T,oe)=>C.current?.setSelection(T,oe),getLayout:()=>Re,relayout:()=>{let T=C.current?.getState();T&&vt(T);},scrollToPosition:Qn});},[Re,vt]);let ta=Mu.useMemo(()=>{if(!Re)return ku+48;let T=Re.pages.length;return T*Ne.h+(T-1)*d+48},[Re,Ne.h,d]);return jsxRuntime.jsxs("div",{ref:T=>{O.current=T,typeof W=="function"?W(T):W&&typeof W=="object"&&(W.current=T);},className:`ep-root paged-editor ${_??""}`,style:{...ob,...V},tabIndex:0,onFocus:ft,onBlur:mt,onKeyDown:Ji,onMouseDown:Qi,children:[jsxRuntime.jsx(Md,{ref:C,document:o,styles:r,widthPx:It,readOnly:u,onTransaction:Bn,onSelectionChange:Xo,externalPlugins:m,extensionManager:b,onEditorViewReady:ea,onKeyDown:ee}),jsxRuntime.jsxs("div",{style:{...rb,minHeight:ta,transform:(()=>{let T=[];return $&&T.push("translateX(-120px)"),c!==1&&T.push(`scale(${c})`),T.length>0?T.join(" "):void 0})(),transformOrigin:"top center",transition:"transform 0.2s ease"},children:[jsxRuntime.jsx("div",{ref:K,className:`paged-editor__pages${u?" paged-editor--readonly":""}${E?` paged-editor--hf-editing paged-editor--editing-${E}`:""}`,style:ib,onMouseDown:De,onClick:Xi,"aria-hidden":"true"}),jsxRuntime.jsx(Id,{selectionRects:J,caretPosition:U,isFocused:D,pageGap:d,readOnly:u}),jsxRuntime.jsx(Dd,{imageInfo:xe,zoom:c,isFocused:D,onResize:Zo,onResizeStart:Nt,onResizeEnd:Jt,onDragMove:bo,onDragStart:An,onDragEnd:Zi}),w&&jsxRuntime.jsx("div",{className:"paged-editor__plugin-overlays",style:ab,children:w})]}),L]})}),vu=Mu.memo(fb);var bb=Mu.lazy(()=>import('./FindReplaceDialog-I4SZDSVP.cjs')),yb=Mu.lazy(()=>import('./HyperlinkDialog-V63LPOT2.cjs')),xb=Mu.lazy(()=>import('./TablePropertiesDialog-72CIUAZT.cjs').then(e=>({default:e.TablePropertiesDialog}))),Sb=Mu.lazy(()=>import('./ImagePositionDialog-KMK7ROV2.cjs').then(e=>({default:e.ImagePositionDialog}))),kb=Mu.lazy(()=>import('./ImagePropertiesDialog-USMMRK6X.cjs').then(e=>({default:e.ImagePropertiesDialog}))),wb=Mu.lazy(()=>import('./FootnotePropertiesDialog-73VT2ZVZ.cjs').then(e=>({default:e.FootnotePropertiesDialog}))),Ru=[{value:"editing",label:"Editing",icon:"edit_note",desc:"Edit document directly"},{value:"suggesting",label:"Suggesting",icon:"edit_note",desc:"Edits become suggestions"}];function Cb({mode:e,onModeChange:t}){let[n,o]=Mu.useState(false),[r,i]=Mu.useState(false),a=Mu.useRef(null),s=Mu.useRef(null),[l,u]=Mu.useState({top:0,left:0}),d=Ru.find(c=>c.value===e);return Mu.useEffect(()=>{let c=window.matchMedia("(max-width: 1400px)");i(c.matches);let p=f=>i(f.matches);return c.addEventListener("change",p),()=>c.removeEventListener("change",p)},[]),Mu.useEffect(()=>{if(!n||!a.current)return;let c=a.current.getBoundingClientRect();u({top:c.bottom+2,left:c.right-220});},[n]),Mu.useEffect(()=>{if(!n)return;let c=f=>{!a.current?.contains(f.target)&&!s.current?.contains(f.target)&&o(false);},p=f=>{f.key==="Escape"&&o(false);};return document.addEventListener("mousedown",c),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",p);}},[n]),jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:a,type:"button",onMouseDown:c=>c.preventDefault(),onClick:()=>o(!n),title:`${d.label} (Ctrl+Shift+E)`,style:{display:"flex",alignItems:"center",gap:r?0:4,padding:r?"2px 4px":"2px 6px 2px 4px",border:"none",background:n?"var(--doc-hover, #f3f4f6)":"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text, #374151)",whiteSpace:"nowrap",height:28},children:[jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:d.icon,size:18}),!r&&jsxRuntime.jsx("span",{children:d.label}),jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:"arrow_drop_down",size:16})]}),n&&jsxRuntime.jsx("div",{ref:s,onMouseDown:c=>c.preventDefault(),style:{position:"fixed",top:l.top,left:l.left,backgroundColor:"white",border:"1px solid var(--doc-border, #d1d5db)",borderRadius:8,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.12)",padding:"4px 0",zIndex:1e4,minWidth:220},children:Ru.map(c=>jsxRuntime.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>{t(c.value),o(false);},onMouseOver:p=>{p.currentTarget.style.backgroundColor="var(--doc-hover, #f3f4f6)";},onMouseOut:p=>{p.currentTarget.style.backgroundColor="transparent";},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text, #374151)",width:"100%",textAlign:"left"},children:[jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:c.icon,size:20}),jsxRuntime.jsxs("span",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[jsxRuntime.jsx("span",{style:{fontWeight:500},children:c.label}),jsxRuntime.jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted, #9ca3af)"},children:c.desc})]}),c.value===e&&jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:"check",size:18,style:{marginLeft:"auto",color:"#1a73e8"}})]},c.value))})]})}var Tb=Date.now(),ks=-1;function ws(e,t,n){return {id:Tb++,author:t,date:new Date().toISOString(),content:[{type:"paragraph",formatting:{},content:[{type:"run",formatting:{},content:[{type:"text",text:e}]}]}],...n!==void 0&&{parentId:n}}}var Pu=Mu.forwardRef(function({documentBuffer:t,document:n,onSave:o,author:r="User",onChange:i,onSelectionChange:a,onError:s,onFontsLoaded:l,theme:u,showToolbar:d=true,showZoomControl:c=true,showPageNumbers:p=true,enablePageNavigation:f=true,pageNumberPosition:m="bottom-center",pageNumberVariant:b="default",showMarginGuides:g=false,marginGuideColor:S,showRuler:w=false,rulerUnit:k="inch",initialZoom:E=1,readOnly:R=false,toolbarExtra:_,className:V="",style:$,placeholder:L,loadingIndicator:W,showOutline:O=false,showPrintButton:K=true,printOptions:C,onPrint:B,onCopy:ee,onCut:ge,onPaste:pe,externalPlugins:Ee,onEditorViewReady:Te,onRenderedDomContextReady:Re,pluginOverlays:P},I){let[y,M]=Mu.useState({isLoading:!!t,parseError:null,zoom:E,selectionFormatting:{},currentPage:1,totalPages:1,paragraphIndentLeft:0,paragraphIndentRight:0,paragraphFirstLineIndent:0,paragraphHangingIndent:false,paragraphTabs:null,pmTableContext:null,pmImageContext:null}),[F,D]=Mu.useState(false),[j,J]=Mu.useState(false),[N,U]=Mu.useState(false),[G,xe]=Mu.useState(false),[v,z]=Mu.useState(null),[A,te]=Mu.useState(O),de=Mu.useRef(false);de.current=A;let[he,Be]=Mu.useState([]),[me,Se]=Mu.useState(false),[ue,ze]=Mu.useState([]),[tt,Ue]=Mu.useState([]),[rt,Oe]=Mu.useState(false),[Qe,dt]=Mu.useState(null),[Ge,pt]=Mu.useState(null),[$e,Ht]=Mu.useState("editing"),[mn,ln]=Mu.useState(null),Mt=Mu.useRef(null),Et=Mu.useCallback(()=>{let x=Ne.current?.getView();if(!x)return;let{doc:h,schema:H}=x.state,ie=H.marks.insertion,re=H.marks.deletion;if(!ie&&!re)return;let ae=[];h.descendants((fe,Pe)=>{if(fe.isText)for(let Ke of fe.marks)(Ke.type===ie||Ke.type===re)&&ae.push({type:Ke.type===ie?"insertion":"deletion",text:fe.text||"",author:Ke.attrs.author||"",date:Ke.attrs.date,from:Pe,to:Pe+fe.nodeSize,revisionId:Ke.attrs.revisionId});});let se=[];for(let fe of ae){let Pe=se[se.length-1];Pe&&Pe.revisionId===fe.revisionId&&Pe.type===fe.type&&Pe.to===fe.from?(Pe.text+=fe.text,Pe.to=fe.to):se.push({...fe});}Ue(se);},[]);Mu.useEffect(()=>()=>{Mt.current&&clearTimeout(Mt.current);},[]),Mu.useEffect(()=>{if(te(O),O){let x=Ne.current?.getView();x&&Be(to(x.state.doc));}},[O]);let le=yd(n||null,{maxEntries:100,groupingInterval:500,enableKeyboardShortcuts:true}),gn=Mu.useRef(false);Mu.useEffect(()=>{if(gn.current)return;let x=le.state;if(!x)return;let h=x.package?.document?.comments;h&&h.length>0&&(ze(h),Se(true),gn.current=true);},[le.state]);let Xt=Mu.useMemo(()=>{let x=new xn(ao());return x.buildSchema(),x.initializeRuntime(),x},[]),qo=Mu.useMemo(()=>wd(false,r),[]),$t=Mu.useMemo(()=>[qo,...Ee??[]],[qo,Ee]),Ne=Mu.useRef(null),nt=Mu.useRef(null),It=Mu.useRef(null),Wt=Mu.useRef(null),vt=Mu.useRef(null),_t=Mu.useRef(null),Zn=Mu.useRef(null),Jn=Mu.useRef(null),Ft=Mu.useRef(null),Bn=Mu.useRef(null),[Xo,Lt]=Mu.useState(0),Zt=Mu.useRef(le.state);Zt.current=le.state;let Bt=Mu.useRef({style:"single",size:4,color:{rgb:"000000"}}),Qn=Mu.useCallback(x=>{if(Ft.current=x,Bn.current&&(Bn.current.disconnect(),Bn.current=null),!x){Lt(0);return}Lt(x.offsetHeight);let h=new ResizeObserver(()=>{Lt(x.offsetHeight);});h.observe(x),Bn.current=h;},[]);Mu.useEffect(()=>()=>{Bn.current?.disconnect();},[]);let De=Mu.useCallback(()=>v&&nt.current?nt.current.getView():Ne.current?.getView(),[v]),qe=Mu.useCallback(()=>{v&&nt.current?nt.current.focus():Ne.current?.focus();},[v]),ho=Mu.useCallback(()=>{v&&nt.current?nt.current.undo():Ne.current?.undo();},[v]),Xi=Mu.useCallback(()=>{v&&nt.current?nt.current.redo():Ne.current?.redo();},[v]),ft=chunkDJAEBZ33_cjs.m(),mt=chunkS26DZVRQ_cjs.m();Mu.useEffect(()=>{if(!t){n&&(le.reset(n),M(h=>({...h,isLoading:false})),chunkC33XDRDJ_cjs.o(n).catch(h=>{console.warn("Failed to load document fonts:",h);}));return}M(h=>({...h,isLoading:true,parseError:null})),(async()=>{try{let h=await chunkC33XDRDJ_cjs.q(t);le.reset(h),M(H=>({...H,isLoading:!1,parseError:null})),chunkC33XDRDJ_cjs.o(h).catch(H=>{console.warn("Failed to load document fonts:",H);});}catch(h){let H=h instanceof Error?h.message:"Failed to parse document";M(ie=>({...ie,isLoading:false,parseError:H})),s?.(h instanceof Error?h:new Error(H));}})();},[t,n,s]),Mu.useEffect(()=>{n&&!t&&le.reset(n);},[n,t]),Mu.useEffect(()=>{le.state?It.current=new chunkRMUMR42R_cjs.c(le.state):It.current=null;},[le.state]);let Zo=Mu.useRef(false);Mu.useEffect(()=>{if(!y.isLoading&&le.state){let x=setTimeout(()=>{Et(),Zo.current||(Zo.current=true,Ue(h=>(h.length>0&&Se(true),h)));},200);return ()=>clearTimeout(x)}},[y.isLoading,le.state,Et]),Mu.useEffect(()=>chunkC33XDRDJ_cjs.k(()=>{l?.();}),[l]),Mu.useEffect(()=>{let x=Ne.current?.getView();x&&Cd($e==="suggesting",x.state,x.dispatch,r);},[$e,r]);let Nt=Mu.useCallback(x=>(le.push(x),x),[le]),Jt=Mu.useCallback(x=>{if(Nt(x),i?.(x),de.current){let h=Ne.current?.getView();h&&Be(to(h.state.doc));}Mt.current&&clearTimeout(Mt.current),Mt.current=setTimeout(Et,300);},[i,Nt,Et]),bo=Mu.useCallback(x=>{let h=De();if(h){let{from:ht,to:kt}=h.state.selection;vt.current={from:ht,to:kt};}let H=null;h&&(H=We(h.state),H.isInTable||(H=null));let ie=null;if(h){let ht=h.state.selection,kt=ht.node;kt?.type.name==="image"&&(ie={pos:ht.from,wrapType:kt.attrs.wrapType??"inline",displayMode:kt.attrs.displayMode??"inline",cssFloat:kt.attrs.cssFloat??null,transform:kt.attrs.transform??null,alt:kt.attrs.alt??null,borderWidth:kt.attrs.borderWidth??null,borderColor:kt.attrs.borderColor??null,borderStyle:kt.attrs.borderStyle??null});}if(!x){ln(null),M(ht=>({...ht,selectionFormatting:{},pmTableContext:H,pmImageContext:ie}));return}let{textFormatting:re,paragraphFormatting:ae}=x,se=re.fontFamily?.ascii||re.fontFamily?.hAnsi,fe=re.color?.rgb?`#${re.color.rgb}`:void 0,Pe=ae.numPr,Ke=Pe?{type:Pe.numId===1?"bullet":"numbered",level:Pe.ilvl??0,isInList:true,numId:Pe.numId}:void 0,gt={bold:re.bold,italic:re.italic,underline:!!re.underline,strike:re.strike,superscript:re.vertAlign==="superscript",subscript:re.vertAlign==="subscript",fontFamily:se,fontSize:re.fontSize,color:fe,highlight:re.highlight,alignment:ae.alignment,lineSpacing:ae.lineSpacing,listState:Ke,styleId:x.styleId??void 0,indentLeft:ae.indentLeft};if(M(ht=>({...ht,selectionFormatting:gt,paragraphIndentLeft:ae.indentLeft??0,paragraphIndentRight:ae.indentRight??0,paragraphFirstLineIndent:ae.indentFirstLine??0,paragraphHangingIndent:ae.hangingIndent??false,paragraphTabs:ae.tabs??null,pmTableContext:H,pmImageContext:ie})),h&&x.hasSelection&&!rt&&!R){let ht=Jn.current,kt=Zn.current;if(ht&&kt){let{from:er}=h.state.selection,ra=ht.querySelector(".paged-editor__pages");if(ra){let Rs=ra.querySelector(".layout-page"),Qu=ra.querySelectorAll("span[data-pm-start]");for(let ep of Qu){let ia=ep,tp=Number(ia.dataset.pmStart),np=Number(ia.dataset.pmEnd);if(er>=tp&&er<=np){let op=ia.getBoundingClientRect(),aa=kt.getBoundingClientRect(),rp=op.top-aa.top+ht.scrollTop,ip=Rs?Rs.getBoundingClientRect().right-aa.left:aa.width/2+408;ln({top:rp,left:ip});break}}}}}else ln(null);a?.(x);},[a,rt,R]),An=fl({document:le.state,onChange:Jt,onSelectionChange:x=>{}});Mu.useEffect(()=>{let x=h=>{let ie=navigator.platform.toUpperCase().indexOf("MAC")>=0?h.metaKey:h.ctrlKey;if(!ie&&!h.shiftKey&&!h.altKey&&(h.key==="Delete"||h.key==="Backspace")){let re=Ne.current?.getView();if(re){let ae=re.state.selection;if("$anchorCell"in ae&&typeof ae.forEachCell=="function"){let fe=We(re.state);if(fe.isInTable&&fe.table){let Pe=0;fe.table.descendants(gt=>{(gt.type.name==="tableCell"||gt.type.name==="tableHeader")&&(Pe+=1);});let Ke=0;if(ae.forEachCell(()=>{Ke+=1;}),Pe>0&&Ke>=Pe){h.preventDefault(),Ao(re.state,re.dispatch);return}}}}if(An.state.tableIndex!==null){h.preventDefault(),An.handleAction("deleteTable");return}}if(ie&&!h.shiftKey&&!h.altKey){if(h.key.toLowerCase()==="f"){h.preventDefault();let re=window.getSelection(),ae=re&&!re.isCollapsed?re.toString():"";ft.openFind(ae);}else if(h.key.toLowerCase()==="h"){h.preventDefault();let re=window.getSelection(),ae=re&&!re.isCollapsed?re.toString():"";ft.openReplace(ae);}else if(h.key.toLowerCase()==="k"){h.preventDefault();let re=Ne.current?.getView();if(re){let ae=oo(re.state),se=no(re.state);se?mt.openEdit({url:se.href,displayText:ae,tooltip:se.tooltip}):mt.openInsert(ae);}}}};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x);}},[ft,mt,An]);let Zi=Mu.useCallback((x,h)=>{let H=De();H&&(Gr(x,h)(H.state,H.dispatch),qe());},[De,qe]),Ji=Mu.useCallback(()=>{let x=De();x&&(Si(x.state,x.dispatch),qe());},[De,qe]),Qi=Mu.useCallback(()=>{let x=De();x&&(Ur(x.state,x.dispatch),qe());},[De,qe]),ea=Mu.useCallback(()=>{te(x=>{if(!x){let h=Ne.current?.getView();h&&Be(to(h.state.doc));}return !x});},[]),Jo=Mu.useCallback(x=>{Ne.current?.scrollToPosition(x),Ne.current?.setSelection(x+1),Ne.current?.focus();},[]),ta=Mu.useCallback(()=>{_t.current?.click();},[]),T=Mu.useCallback(x=>{let h=x.target.files?.[0];if(!h)return;let H=De();if(!H)return;let ie=new FileReader;ie.onload=()=>{let re=ie.result,ae=new Image;ae.onload=()=>{let se=ae.naturalWidth,fe=ae.naturalHeight,Pe=612;if(se>Pe){let er=Pe/se;se=Pe,fe=Math.round(fe*er);}let Ke=`rId_img_${Date.now()}`,gt=H.state.schema.nodes.image.create({src:re,alt:h.name,width:se,height:fe,rId:Ke,wrapType:"inline",displayMode:"inline"}),{from:ht}=H.state.selection,kt=H.state.tr.insert(ht,gt);H.dispatch(kt.scrollIntoView()),qe();},ae.src=re;},ie.readAsDataURL(h),x.target.value="";},[De,qe]),oe=Mu.useCallback(x=>{let h=De();if(!h||!y.pmImageContext)return;let H=y.pmImageContext.pos,ie=h.state.doc.nodeAt(H);if(!ie||ie.type.name!=="image")return;let re="inline",ae=null;switch(x){case "inline":re="inline",ae=null;break;case "square":case "tight":case "through":re="float",ae="left";break;case "topAndBottom":re="block",ae=null;break;case "behind":case "inFront":re="float",ae="none";break;case "wrapLeft":re="float",ae="right",x="square";break;case "wrapRight":re="float",ae="left",x="square";break}let se=h.state.tr.setNodeMarkup(H,void 0,{...ie.attrs,wrapType:x,displayMode:re,cssFloat:ae});h.dispatch(se.scrollIntoView()),qe();},[De,qe,y.pmImageContext]),q=Mu.useCallback(x=>{let h=De();if(!h||!y.pmImageContext)return;let H=y.pmImageContext.pos,ie=h.state.doc.nodeAt(H);if(!ie||ie.type.name!=="image")return;let re=ie.attrs.transform||"",ae=re.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/),se=ae?parseFloat(ae[1]):0,fe=/scaleX\(-1\)/.test(re),Pe=/scaleY\(-1\)/.test(re);switch(x){case "rotateCW":se=(se+90)%360;break;case "rotateCCW":se=(se-90+360)%360;break;case "flipH":fe=!fe;break;case "flipV":Pe=!Pe;break}let Ke=[];se!==0&&Ke.push(`rotate(${se}deg)`),fe&&Ke.push("scaleX(-1)"),Pe&&Ke.push("scaleY(-1)");let gt=Ke.length>0?Ke.join(" "):null,ht=h.state.tr.setNodeMarkup(H,void 0,{...ie.attrs,transform:gt});h.dispatch(ht.scrollIntoView()),qe();},[De,qe,y.pmImageContext]),X=Mu.useCallback(x=>{let h=De();if(!h||!y.pmImageContext)return;let H=y.pmImageContext.pos,ie=h.state.doc.nodeAt(H);if(!ie||ie.type.name!=="image")return;let re=h.state.tr.setNodeMarkup(H,void 0,{...ie.attrs,position:{horizontal:x.horizontal,vertical:x.vertical},distTop:x.distTop??ie.attrs.distTop,distBottom:x.distBottom??ie.attrs.distBottom,distLeft:x.distLeft??ie.attrs.distLeft,distRight:x.distRight??ie.attrs.distRight});h.dispatch(re.scrollIntoView()),qe();},[De,qe,y.pmImageContext]),ne=Mu.useCallback(()=>{U(true);},[]),Y=Mu.useCallback(x=>{let h=De();if(!h||!y.pmImageContext)return;let H=y.pmImageContext.pos,ie=h.state.doc.nodeAt(H);if(!ie||ie.type.name!=="image")return;let re=h.state.tr.setNodeMarkup(H,void 0,{...ie.attrs,alt:x.alt??null,borderWidth:x.borderWidth??null,borderColor:x.borderColor??null,borderStyle:x.borderStyle??null});h.dispatch(re.scrollIntoView()),qe();},[De,qe,y.pmImageContext]),Z=Mu.useCallback((x,h)=>{if(!le.state?.package)return;let H={...le.state.package.document,finalSectionProperties:{...le.state.package.document.finalSectionProperties,footnotePr:x,endnotePr:h}};Nt({...le.state,package:{...le.state.package,document:H}});},[le,Nt]),Q=Mu.useCallback(x=>{let h=De();if(h){switch(x){case "addRowAbove":Kr(h.state,h.dispatch);break;case "addRowBelow":Yr(h.state,h.dispatch);break;case "addColumnLeft":Xr(h.state,h.dispatch);break;case "addColumnRight":Zr(h.state,h.dispatch);break;case "deleteRow":qr(h.state,h.dispatch);break;case "deleteColumn":Jr(h.state,h.dispatch);break;case "deleteTable":Ao(h.state,h.dispatch);break;case "selectTable":Qr(h.state,h.dispatch);break;case "selectRow":ei(h.state,h.dispatch);break;case "selectColumn":ti(h.state,h.dispatch);break;case "mergeCells":ni(h.state,h.dispatch);break;case "splitCell":oi(h.state,h.dispatch);break;case "borderAll":ii(h.state,h.dispatch,Bt.current);break;case "borderOutside":ai(h.state,h.dispatch,Bt.current);break;case "borderInside":si(h.state,h.dispatch,Bt.current);break;case "borderNone":ri(h.state,h.dispatch);break;case "borderTop":kn("top",Bt.current)(h.state,h.dispatch);break;case "borderBottom":kn("bottom",Bt.current)(h.state,h.dispatch);break;case "borderLeft":kn("left",Bt.current)(h.state,h.dispatch);break;case "borderRight":kn("right",Bt.current)(h.state,h.dispatch);break;default:if(typeof x=="object"){if(x.type==="cellFillColor")bi(x.color)(h.state,h.dispatch);else if(x.type==="borderColor"){let H=x.color.replace(/^#/,"");Bt.current={...Bt.current,color:{rgb:H}},yi(x.color)(h.state,h.dispatch);}else if(x.type==="borderWidth")Bt.current={...Bt.current,size:x.size},xi(x.size)(h.state,h.dispatch);else if(x.type==="cellBorder")kn(x.side,{style:x.style,size:x.size,color:{rgb:x.color.replace(/^#/,"")}})(h.state,h.dispatch);else if(x.type==="cellVerticalAlign")li(x.align)(h.state,h.dispatch);else if(x.type==="cellMargins")ci(x.margins)(h.state,h.dispatch);else if(x.type==="cellTextDirection")di(x.direction)(h.state,h.dispatch);else if(x.type==="toggleNoWrap")ui()(h.state,h.dispatch);else if(x.type==="rowHeight")pi(x.height,x.rule)(h.state,h.dispatch);else if(x.type==="toggleHeaderRow")fi()(h.state,h.dispatch);else if(x.type==="distributeColumns")mi()(h.state,h.dispatch);else if(x.type==="autoFitContents")gi()(h.state,h.dispatch);else if(x.type==="openTableProperties")D(true);else if(x.type==="tableProperties")Do(x.props)(h.state,h.dispatch);else if(x.type==="applyTableStyle"){let H=fd(x.styleId),ie=Zt.current;if(!H&&ie?.package.styles){let ae=Sn(ie.package.styles).getStyle(x.styleId);if(ae){if(H={id:ae.styleId,name:ae.name??ae.styleId},ae.tblPr?.borders){let se=ae.tblPr.borders;H.tableBorders={};for(let fe of ["top","bottom","left","right","insideH","insideV"]){let Pe=se[fe];Pe&&(H.tableBorders[fe]={style:Pe.style,size:Pe.size,color:Pe.color?.rgb?{rgb:Pe.color.rgb}:void 0});}}if(ae.tblStylePr){H.conditionals={};for(let se of ae.tblStylePr){let fe={};if(se.tcPr?.shading?.fill&&(fe.backgroundColor=`#${se.tcPr.shading.fill}`),se.tcPr?.borders){let Pe={};for(let Ke of ["top","bottom","left","right"]){let gt=se.tcPr.borders[Ke];gt&&(Pe[Ke]={style:gt.style,size:gt.size,color:gt.color?.rgb?{rgb:gt.color.rgb}:void 0});}fe.borders=Pe;}se.rPr?.bold&&(fe.bold=true),se.rPr?.color?.rgb&&(fe.color=`#${se.rPr.color.rgb}`),H.conditionals[se.type]=fe;}}H.look={firstRow:true,lastRow:false,noHBand:false,noVBand:true};}}H&&hi({styleId:H.id,tableBorders:H.tableBorders,conditionals:H.conditionals,look:H.look})(h.state,h.dispatch);}}else An.handleAction(x);}qe();}},[An,De,qe]),ce=Mu.useCallback(x=>{let h=De();if(!h)return;h.focus();let H=h===Ne.current?.getView(),{from:ie,to:re}=h.state.selection,ae=vt.current;if(H&&ae&&(ie!==ae.from||re!==ae.to))try{let se=h.state.tr.setSelection(prosemirrorState.TextSelection.create(h.state.doc,ae.from,ae.to));h.dispatch(se);}catch(se){console.warn("Could not restore selection:",se);}if(x==="bold"){wr(h.state,h.dispatch);return}if(x==="italic"){Cr(h.state,h.dispatch);return}if(x==="underline"){Tr(h.state,h.dispatch);return}if(x==="strikethrough"){vr(h.state,h.dispatch);return}if(x==="superscript"){Rr(h.state,h.dispatch);return}if(x==="subscript"){Pr(h.state,h.dispatch);return}if(x==="bulletList"){$r(h.state,h.dispatch);return}if(x==="numberedList"){Wr(h.state,h.dispatch);return}if(x==="indent"){_r(h.state,h.dispatch)||Hr()(h.state,h.dispatch);return}if(x==="outdent"){Vr(h.state,h.dispatch)||Nr()(h.state,h.dispatch);return}if(x==="clearFormatting"){Po(h.state,h.dispatch);return}if(x==="insertLink"){let se=oo(h.state),fe=no(h.state);fe?mt.openEdit({url:fe.href,displayText:se,tooltip:fe.tooltip}):mt.openInsert(se);return}if(typeof x=="object")switch(x.type){case "alignment":Ar(x.value)(h.state,h.dispatch);break;case "textColor":Mr({rgb:x.value.replace("#","")})(h.state,h.dispatch);break;case "highlightColor":{let se=x.value?chunkPANKMCFX_cjs.t(x.value):"";Er(se||x.value)(h.state,h.dispatch);break}case "fontSize":Ir(chunkPANKMCFX_cjs.e(x.value))(h.state,h.dispatch);break;case "fontFamily":Fr(x.value)(h.state,h.dispatch);break;case "lineSpacing":Dr(x.value)(h.state,h.dispatch);break;case "applyStyle":{let se=Zt.current,fe=se?.package.styles?Sn(se.package.styles):null;if(fe){let Pe=fe.resolveParagraphStyle(x.value);Bo(x.value,{paragraphFormatting:Pe.paragraphFormatting,runFormatting:Pe.runFormatting})(h.state,h.dispatch);}else Bo(x.value)(h.state,h.dispatch);break}}},[De]),we=Mu.useCallback(x=>{M(h=>({...h,zoom:x}));},[]),be=Mu.useCallback(x=>{let h=De();if(!h)return;let H=x.url||"",ie=x.tooltip,{empty:re}=h.state.selection;re&&x.displayText?Fo(x.displayText,H,ie)(h.state,h.dispatch):re?x.displayText&&Fo(x.displayText,H,ie)(h.state,h.dispatch):Lr(H,ie)(h.state,h.dispatch),mt.close(),qe();},[mt,De,qe]),Ce=Mu.useCallback(()=>{let x=De();x&&(Br(x.state,x.dispatch),mt.close(),qe());},[mt,De,qe]),Ie=Mu.useCallback(x=>h=>{if(!le.state||R)return;let H={...le.state,package:{...le.state.package,document:{...le.state.package.document,finalSectionProperties:{...le.state.package.document.finalSectionProperties,[x]:h}}}};Jt(H);},[le.state,R,Jt]),Fe=Mu.useMemo(()=>Ie("marginLeft"),[Ie]),Ye=Mu.useMemo(()=>Ie("marginRight"),[Ie]),Xe=Mu.useMemo(()=>Ie("marginTop"),[Ie]),yt=Mu.useMemo(()=>Ie("marginBottom"),[Ie]),at=Mu.useCallback(x=>{let h=De();h&&zr(x)(h.state,h.dispatch);},[De]),At=Mu.useCallback(x=>{let h=De();h&&Or(x)(h.state,h.dispatch);},[De]),zt=Mu.useCallback(x=>{let h=De();h&&(x<0?Lo(-x,true)(h.state,h.dispatch):Lo(x,false)(h.state,h.dispatch));},[De]),Dn=Mu.useCallback(x=>{let h=De();h&&jr(x)(h.state,h.dispatch);},[De]),yo=Mu.useCallback(x=>{},[]),xo=Mu.useCallback(async()=>{if(!It.current)return null;try{let x=It.current.getDocument(),h=Ne.current?.getDocument();h?.package?.document&&(x.package.document.content=h.package.document.content),x.package.document.comments=ue;let H=await It.current.toBuffer();return o?.(H),H}catch(x){return s?.(x instanceof Error?x:new Error("Failed to save document")),null}},[o,s,ue]),hn=Mu.useCallback(x=>{s?.(x);},[s]),Qt=Mu.useCallback(()=>{let x=Wt.current?.querySelector(".paged-editor__pages");if(!x){window.print(),B?.();return}let h=window.open("","_blank");if(!h){window.print(),B?.();return}let H=[];for(let re of Array.from(document.styleSheets))try{for(let ae of Array.from(re.cssRules))ae instanceof CSSFontFaceRule&&H.push(ae.cssText);}catch{}let ie=x.cloneNode(true);ie.style.cssText="display: block; margin: 0; padding: 0;";for(let re of Array.from(ie.querySelectorAll(".layout-page"))){let ae=re;ae.style.boxShadow="none",ae.style.margin="0";}h.document.write(`<!DOCTYPE html>
19
- <html><head><title>Print</title>
20
- <style>
21
- ${H.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>${ie.outerHTML}</body></html>`),h.document.close(),h.onload=()=>{h.print(),h.close();},setTimeout(()=>{h.closed||(h.print(),h.close());},1e3),B?.();},[B]),et=Mu.useRef(null),Hn=Mu.useCallback((x,h)=>{if(!le.state||!x.trim())return et.current=null,null;let H=chunkDJAEBZ33_cjs.j(le.state,x,h),ie={matches:H,totalCount:H.length,currentIndex:0};return et.current=ie,ft.setMatches(H,0),H.length>0&&Wt.current&&chunkDJAEBZ33_cjs.l(Wt.current,H[0]),ie},[le.state,ft]),Nn=Mu.useCallback(()=>{if(!et.current||et.current.matches.length===0)return null;let x=ft.goToNextMatch(),h=et.current.matches[x];return h&&Wt.current&&chunkDJAEBZ33_cjs.l(Wt.current,h),h||null},[ft]),na=Mu.useCallback(()=>{if(!et.current||et.current.matches.length===0)return null;let x=ft.goToPreviousMatch(),h=et.current.matches[x];return h&&Wt.current&&chunkDJAEBZ33_cjs.l(Wt.current,h),h||null},[ft]),Uu=Mu.useCallback(x=>{if(!le.state||!et.current||et.current.matches.length===0)return false;let h=et.current.matches[et.current.currentIndex];if(!h)return false;try{let H=chunkGWBTKVFD_cjs.a(le.state,{type:"replaceText",range:{start:{paragraphIndex:h.paragraphIndex,offset:h.startOffset},end:{paragraphIndex:h.paragraphIndex,offset:h.endOffset}},text:x});return Jt(H),!0}catch(H){return console.error("Replace failed:",H),false}},[le.state,Jt]),Gu=Mu.useCallback((x,h,H)=>{if(!le.state||!x.trim())return 0;let ie=chunkDJAEBZ33_cjs.j(le.state,x,H);if(ie.length===0)return 0;let re=le.state,ae=[...ie].sort((se,fe)=>se.paragraphIndex!==fe.paragraphIndex?fe.paragraphIndex-se.paragraphIndex:fe.startOffset-se.startOffset);for(let se of ae)try{re=chunkGWBTKVFD_cjs.a(re,{type:"replaceText",range:{start:{paragraphIndex:se.paragraphIndex,offset:se.startOffset},end:{paragraphIndex:se.paragraphIndex,offset:se.endOffset}},text:h});}catch(fe){console.error("Replace failed for match:",se,fe);}return Jt(re),et.current=null,ft.setMatches([],0),ie.length},[le.state,Jt,ft]);Mu.useImperativeHandle(I,()=>({getAgent:()=>It.current,getDocument:()=>le.state,getEditorRef:()=>Ne.current,save:xo,setZoom:x=>M(h=>({...h,zoom:x})),getZoom:()=>y.zoom,focus:()=>{Ne.current?.focus();},getCurrentPage:()=>y.currentPage,getTotalPages:()=>y.totalPages,scrollToPage:x=>{},openPrintPreview:Qt,print:Qt}),[le.state,y.zoom,y.currentPage,y.totalPages,xo,Qt]);let{headerContent:So,footerContent:ko}=Mu.useMemo(()=>{if(!le.state?.package)return {headerContent:null,footerContent:null};let x=le.state.package,h=x.document?.finalSectionProperties,H=x.headers,ie=x.footers,re=null,ae=null;if(H&&h?.headerReferences){let se=h.headerReferences.find(fe=>fe.type==="default");se?.rId&&(re=H.get(se.rId)??null);}if(ie&&h?.footerReferences){let se=h.footerReferences.find(fe=>fe.type==="default");se?.rId&&(ae=ie.get(se.rId)??null);}return {headerContent:re,footerContent:ae}},[le.state]),Ku=Mu.useCallback(x=>{if(x==="header"?So:ko){z(x);return}if(!le.state?.package)return;let H=le.state.package,ie=H.document?.finalSectionProperties;if(!ie)return;let re=`rId_new_${x}`,ae={type:x==="header"?"header":"footer",hdrFtrType:"default",content:[{type:"paragraph",content:[]}]},se=x==="header"?"headers":"footers",fe=new Map(H[se]??[]);fe.set(re,ae);let Pe=x==="header"?"headerReferences":"footerReferences",Ke=ie[Pe]??[],gt={type:"default",rId:re},ht={...le.state,package:{...H,[se]:fe,document:H.document?{...H.document,finalSectionProperties:{...ie,[Pe]:[...Ke,gt]}}:H.document}};Nt(ht),z(x);},[So,ko,le,Nt]),oa=Mu.useCallback(x=>{if(!v||!le.state?.package){z(null);return}let h=le.state.package,H=h.document?.finalSectionProperties,re=(v==="header"?H?.headerReferences:H?.footerReferences)?.find(fe=>fe.type==="default"),ae=v==="header"?"headers":"footers",se=h[ae];if(re?.rId&&se){let fe=se.get(re.rId),Pe={type:v,hdrFtrType:"default",...fe,content:x},Ke=new Map(se);Ke.set(re.rId,Pe);let gt={...le.state,package:{...h,[ae]:Ke}};Nt(gt);}z(null);},[v,le,Nt]),Yu=Mu.useCallback(()=>{if(!v)return;let x=nt.current?.getView();if(x){let h=Io(x.state.doc);oa(h);}else z(null);},[v,oa]),qu=Mu.useCallback(()=>{if(!v||!le.state?.package){z(null);return}let x=le.state.package,h=x.document?.finalSectionProperties,H=v==="header"?"headerReferences":"footerReferences",ie=v==="header"?"headers":"footers",re=h?.[H],ae=re?.find(se=>se.type==="default");if(ae?.rId){let se=new Map(x[ie]??[]);se.delete(ae.rId);let fe=(re??[]).filter(Ke=>Ke.rId!==ae.rId),Pe={...le.state,package:{...x,[ie]:se,document:x.document?{...x.document,finalSectionProperties:{...h,[H]:fe}}:x.document}};Nt(Pe);}z(null);},[v,le,Nt]),Xu=Mu.useCallback(x=>{let h=Wt.current?.querySelector(".paged-editor__pages");if(!h)return null;let H=x==="header"?".layout-page-header":".layout-page-footer";return h.querySelector(H)},[]),Qo={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg-subtle)",...$},Zu={display:"flex",flex:1,minHeight:0,minWidth:0,flexDirection:"row"},Ju={flex:1,minHeight:0,minWidth:0,overflow:"auto",position:"relative"};return y.isLoading?jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-loading ${V}`,style:Qo,"data-testid":"docx-editor",children:W||jsxRuntime.jsx(md,{})}):y.parseError?jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-error ${V}`,style:Qo,"data-testid":"docx-editor",children:jsxRuntime.jsx(hd,{message:y.parseError})}):le.state?jsxRuntime.jsx(ul,{children:jsxRuntime.jsx(sr,{onError:hn,children:jsxRuntime.jsxs("div",{ref:Wt,className:`ep-root docx-editor ${V}`,style:Qo,"data-testid":"docx-editor",children:[jsxRuntime.jsx("div",{style:Zu,children:jsxRuntime.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[jsxRuntime.jsxs("div",{style:Ju,children:[d&&!R&&jsxRuntime.jsxs("div",{ref:Qn,className:"sticky top-0 z-50 flex flex-col gap-0 bg-white shadow-sm",children:[jsxRuntime.jsxs(chunkPANKMCFX_cjs.x,{currentFormatting:y.selectionFormatting,onFormat:ce,onUndo:ho,onRedo:Xi,canUndo:true,canRedo:true,disabled:R,documentStyles:le.state?.package.styles?.styles,theme:le.state?.package.theme||u,showPrintButton:K,onPrint:Qt,showZoomControl:c,zoom:y.zoom,onZoomChange:we,onRefocusEditor:qe,onInsertTable:Zi,showTableInsert:true,onInsertImage:ta,onInsertPageBreak:Ji,onInsertTOC:Qi,imageContext:y.pmImageContext,onImageWrapType:oe,onImageTransform:q,onOpenImageProperties:ne,tableContext:y.pmTableContext,onTableAction:Q,children:[jsxRuntime.jsx(chunkPANKMCFX_cjs.w,{}),jsxRuntime.jsx(chunkPANKMCFX_cjs.u,{onClick:()=>Se(!me),active:me,title:"Toggle comments sidebar",ariaLabel:"Toggle comments sidebar",children:jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:"comment",size:20})}),jsxRuntime.jsx(chunkPANKMCFX_cjs.w,{}),jsxRuntime.jsx(Cb,{mode:$e,onModeChange:x=>{Ht(x),x==="suggesting"&&Se(true);}}),_]}),w&&jsxRuntime.jsx("div",{className:"flex justify-center px-5 py-1 overflow-x-auto flex-shrink-0 bg-doc-bg",style:{paddingRight:me?"calc(20px + 240px)":void 0,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(chunkPANKMCFX_cjs.N,{sectionProps:le.state?.package.document?.finalSectionProperties,zoom:y.zoom,unit:k,editable:!R,onLeftMarginChange:Fe,onRightMarginChange:Ye,indentLeft:y.paragraphIndentLeft,indentRight:y.paragraphIndentRight,onIndentLeftChange:at,onIndentRightChange:At,showFirstLineIndent:true,firstLineIndent:y.paragraphFirstLineIndent,hangingIndent:y.paragraphHangingIndent,onFirstLineIndentChange:zt,tabStops:y.paragraphTabs,onTabStopRemove:Dn})})]}),jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative"},children:jsxRuntime.jsxs("div",{ref:Zn,style:{position:"relative",flex:1,minWidth:0},onMouseDown:x=>{x.target===x.currentTarget&&(x.preventDefault(),Ne.current?.focus());},children:[w&&!R&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:10,paddingTop:48},children:jsxRuntime.jsx(vl,{sectionProps:le.state?.package.document?.finalSectionProperties,zoom:y.zoom,unit:k,editable:!R,onTopMarginChange:Xe,onBottomMarginChange:yt})}),jsxRuntime.jsx(vu,{ref:Ne,document:le.state,styles:le.state?.package.styles,theme:le.state?.package.theme||u,sectionProperties:le.state?.package.document?.finalSectionProperties,headerContent:So,footerContent:ko,onHeaderFooterDoubleClick:Ku,hfEditMode:v,onBodyClick:Yu,zoom:y.zoom,readOnly:R,extensionManager:Xt,onDocumentChange:Jt,onSelectionChange:(x,h)=>{let H=Ne.current?.getView();if(H){let ie=so(H.state);bo(ie);}else bo(null);},externalPlugins:$t,onReady:x=>{Te?.(x.getView());},onRenderedDomContextReady:Re,pluginOverlays:P,commentsSidebarOpen:me,scrollContainerRef:Jn,sidebarOverlay:me?jsxRuntime.jsx(Sl,{comments:ue,trackedChanges:tt,pageWidth:(()=>{let x=le.state?.package?.document?.finalSectionProperties;return x?.pageWidth?Math.round(x.pageWidth/15):816})(),editorContainerRef:Jn,onCommentResolve:x=>{ze(h=>h.map(H=>H.id===x?{...H,done:true}:H));},onCommentDelete:x=>{ze(h=>h.filter(H=>H.id!==x&&H.parentId!==x));},onCommentReply:(x,h)=>{ze(H=>[...H,ws(h,r,x)]);},onAddComment:x=>{let h=ws(x,r),H=Ne.current?.getView();if(H&&Qe){let{from:ie,to:re}=Qe,ae=H.state.schema.marks.comment.create({commentId:ks}),se=H.state.schema.marks.comment.create({commentId:h.id}),fe=H.state.tr.removeMark(ie,re,ae).addMark(ie,re,se);H.dispatch(fe);}ze(ie=>[...ie,h]),Oe(false),dt(null),pt(null);},onTrackedChangeReply:(x,h)=>{ze(H=>[...H,ws(h,r,x)]);},onCancelAddComment:()=>{let x=Ne.current?.getView();if(x&&Qe){let{from:h,to:H}=Qe,ie=x.state.schema.marks.comment.create({commentId:ks});x.dispatch(x.state.tr.removeMark(h,H,ie));}Oe(false),dt(null),pt(null);},onAcceptChange:(x,h)=>{let H=Ne.current?.getView();H&&($a(x,h)(H.state,H.dispatch),Et());},onRejectChange:(x,h)=>{let H=Ne.current?.getView();H&&(Wa(x,h)(H.state,H.dispatch),Et());},isAddingComment:rt,addCommentYPosition:Ge,topOffset:0}):void 0}),mn!=null&&!rt&&!R&&jsxRuntime.jsx(chunkPANKMCFX_cjs.h,{content:"Add comment",side:"bottom",delayMs:300,children:jsxRuntime.jsx("button",{type:"button",onMouseDown:x=>{x.preventDefault(),x.stopPropagation();let h=Ne.current?.getView();if(h){let{from:H,to:ie}=h.state.selection;if(H!==ie){dt({from:H,to:ie});let re=h.state.schema.marks.comment.create({commentId:ks}),ae=h.state.tr.addMark(H,ie,re);ae.setSelection(prosemirrorState.TextSelection.create(ae.doc,ie)),h.dispatch(ae);}}pt(mn.top),me||Se(true),Oe(true),ln(null);},style:{position:"absolute",top:mn.top,left:mn.left,transform:"translate(-50%, -50%)",zIndex:50,width:28,height:28,borderRadius:6,border:"1px solid rgba(26, 115, 232, 0.3)",backgroundColor:"#fff",color:"#1a73e8",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(60,64,67,0.2)",transition:"background-color 0.15s ease, box-shadow 0.15s ease"},onMouseOver:x=>{x.currentTarget.style.backgroundColor="rgba(26, 115, 232, 0.08)",x.currentTarget.style.boxShadow="0 1px 4px rgba(26, 115, 232, 0.3)";},onMouseOut:x=>{x.currentTarget.style.backgroundColor="#fff",x.currentTarget.style.boxShadow="0 1px 3px rgba(60,64,67,0.2)";},children:jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:"add_comment",size:16})})}),p&&y.totalPages>0&&(f?jsxRuntime.jsx(chunkPANKMCFX_cjs.G,{currentPage:y.currentPage,totalPages:y.totalPages,onNavigate:yo,position:m,variant:b,floating:true}):jsxRuntime.jsx(chunkPANKMCFX_cjs.y,{currentPage:y.currentPage,totalPages:y.totalPages,position:m,variant:b,floating:true})),v&&(v==="header"?So:ko)&&(()=>{let x=Xu(v),h=Zn.current;return !x||!h?null:jsxRuntime.jsx(pd,{ref:nt,headerFooter:v==="header"?So:ko,position:v,styles:le.state?.package.styles,targetElement:x,parentElement:h,onSave:oa,onClose:()=>z(null),onSelectionChange:bo,onRemove:qu})})()]})})]}),A&&jsxRuntime.jsx(gl,{headings:he,onHeadingClick:Jo,onClose:()=>te(false),topOffset:Xo}),!A&&jsxRuntime.jsx("button",{className:"docx-outline-nav",onClick:ea,onMouseDown:x=>x.stopPropagation(),title:"Show document outline",style:{position:"absolute",left:48,top:Xo+12,zIndex:20,background:"transparent",border:"none",borderRadius:"50%",padding:6,cursor:"pointer",display:"flex",alignItems:"center"},children:jsxRuntime.jsx(chunkPANKMCFX_cjs.d,{name:"format_list_bulleted",size:20,style:{color:"#444746"}})})]})}),jsxRuntime.jsxs(Mu.Suspense,{fallback:null,children:[ft.state.isOpen&&jsxRuntime.jsx(bb,{isOpen:ft.state.isOpen,onClose:ft.close,onFind:Hn,onFindNext:Nn,onFindPrevious:na,onReplace:Uu,onReplaceAll:Gu,initialSearchText:ft.state.searchText,replaceMode:ft.state.replaceMode,currentResult:et.current}),mt.state.isOpen&&jsxRuntime.jsx(yb,{isOpen:mt.state.isOpen,onClose:mt.close,onSubmit:be,onRemove:mt.state.isEditing?Ce:void 0,initialData:mt.state.initialData,selectedText:mt.state.selectedText,isEditing:mt.state.isEditing}),F&&jsxRuntime.jsx(xb,{isOpen:F,onClose:()=>D(false),onApply:x=>{let h=De();h&&Do(x)(h.state,h.dispatch);},currentProps:y.pmTableContext?.table?.attrs}),j&&jsxRuntime.jsx(Sb,{isOpen:j,onClose:()=>J(false),onApply:X}),N&&jsxRuntime.jsx(kb,{isOpen:N,onClose:()=>U(false),onApply:Y,currentData:y.pmImageContext?{alt:y.pmImageContext.alt??void 0,borderWidth:y.pmImageContext.borderWidth??void 0,borderColor:y.pmImageContext.borderColor??void 0,borderStyle:y.pmImageContext.borderStyle??void 0}:void 0}),G&&jsxRuntime.jsx(wb,{isOpen:G,onClose:()=>xe(false),onApply:Z,footnotePr:le.state?.package.document?.finalSectionProperties?.footnotePr,endnotePr:le.state?.package.document?.finalSectionProperties?.endnotePr})]}),jsxRuntime.jsx("input",{ref:_t,type:"file",accept:"image/*",style:{display:"none"},onChange:T})]})})}):jsxRuntime.jsx("div",{className:`ep-root docx-editor docx-editor-empty ${V}`,style:Qo,"data-testid":"docx-editor",children:L||jsxRuntime.jsx(gd,{})})});function d0(e,t,n={}){return new Promise((o,r)=>{let i=Mu__default.default.createRef(),a=null;try{a=client.createRoot(t);}catch(d){r(d);return}let s={save:async()=>{let d=await(i.current?.save()??Promise.resolve(null));return d?new Blob([d],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}):null},getDocument:()=>i.current?.getDocument()??null,focus:()=>i.current?.focus(),setZoom:d=>i.current?.setZoom(d),destroy:()=>{a?.unmount(),a=null;}},l=false,u=Mu__default.default.createElement(Pu,{...n,documentBuffer:e,onError:d=>{n.onError?.(d),l||(l=true,r(d));},onChange:d=>{n.onChange?.(d),l||(l=true,o(s));},ref:i});a.render(u);})}function x0(e,t={}){let{storageKey:n,interval:o,enabled:r=true,maxAge:i,onSave:a,onError:s,onRecoveryAvailable:l,saveOnChange:u,debounceDelay:d}=t,c=Mu.useMemo(()=>new chunkFDANI5P4_cjs.r({storageKey:n,interval:o,maxAge:i,saveOnChange:u,debounceDelay:d,onSave:a,onError:s,onRecoveryAvailable:l}),[n]);Mu.useEffect(()=>{r?(c.enable(),c.startInterval()):c.disable();},[c,r]),Mu.useEffect(()=>{c.onDocumentChanged(e??null);},[c,e]),Mu.useEffect(()=>()=>{c.destroy();},[c]);let p=Mu.useSyncExternalStore(c.subscribe,c.getSnapshot),f=Mu.useCallback(()=>c.save(),[c]),m=Mu.useCallback(()=>c.clear(),[c]),b=Mu.useCallback(()=>c.getRecoveryData(),[c]),g=Mu.useCallback(()=>c.acceptRecovery(),[c]),S=Mu.useCallback(()=>c.dismissRecovery(),[c]),w=Mu.useCallback(()=>c.enable(),[c]),k=Mu.useCallback(()=>c.disable(),[c]);return {status:p.status,lastSaveTime:p.lastSaveTime,save:f,clearAutoSave:m,hasRecoveryData:p.hasRecoveryData,getRecoveryData:b,acceptRecovery:g,dismissRecovery:S,isEnabled:p.isEnabled,enable:w,disable:k}}var Ib=1,Eu=.25,Iu=4,Fb=.1,Yt=[.25,.5,.75,1,1.25,1.5,2,3,4];function Fu(e,t,n){return Math.max(t,Math.min(n,e))}function Lu(e){return Math.round(e*100)/100}function Lb(e){let t=Yt[0],n=Math.abs(e-t);for(let o of Yt){let r=Math.abs(e-o);r<n&&(n=r,t=o);}return t}function Bb(e){for(let t of Yt)if(t>e+.01)return t;return Yt[Yt.length-1]}function Ab(e){for(let t=Yt.length-1;t>=0;t--)if(Yt[t]<e-.01)return Yt[t];return Yt[0]}function w0(e={}){let{initialZoom:t=Ib,minZoom:n=Eu,maxZoom:o=Iu,zoomStep:r=Fb,enabled:i=true,containerRef:a,onZoomChange:s,enableKeyboardShortcuts:l=true,preventDefault:u=true}=e,[d,c]=Mu.useState(t),p=Mu.useRef(d);Mu.useEffect(()=>{p.current=d;},[d]);let f=Mu.useCallback(R=>{let _=Lu(Fu(R,n,o));_!==p.current&&(c(_),s?.(_));},[n,o,s]),m=Mu.useCallback(()=>{f(p.current+r);},[r,f]),b=Mu.useCallback(()=>{f(p.current-r);},[r,f]),g=Mu.useCallback(()=>{f(t);},[t,f]),S=Mu.useCallback(()=>{f(1);},[f]),w=Mu.useCallback((R,_)=>{if(_>0){let V=R/_;f(V);}},[f]),k=Mu.useCallback(R=>{if(!i||!(R.ctrlKey||R.metaKey))return;u&&R.preventDefault();let V=R.deltaY;V<0?f(p.current+r):V>0&&f(p.current-r);},[i,u,r,f]),E=Mu.useCallback(R=>{if(!(!i||!l||!(R.ctrlKey||R.metaKey))){if(R.key==="0"){R.preventDefault(),S();return}if(R.key==="+"||R.key==="="){R.preventDefault(),m();return}if(R.key==="-"){R.preventDefault(),b();return}}},[i,l,m,b,S]);return Mu.useEffect(()=>{if(!i)return;let R=a?.current;if(R)return R.addEventListener("wheel",k,{passive:false}),()=>{R.removeEventListener("wheel",k);}},[i,a,k]),Mu.useEffect(()=>{if(!(!i||!l))return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E);}},[i,l,E]),{zoom:d,setZoom:f,zoomIn:m,zoomOut:b,resetZoom:g,zoomTo100:S,zoomToFit:w,isMinZoom:d<=n,isMaxZoom:d>=o,zoomPercent:Math.round(d*100),handleWheel:k,handleKeyDown:E}}function C0(){return [...Yt]}function T0(e){return Lb(e)}function v0(e){return Bb(e)}function R0(e){return Ab(e)}function P0(e){return `${Math.round(e*100)}%`}function M0(e){let t=e.match(/(\d+(\.\d+)?)/);if(t){let n=parseFloat(t[1]);if(!isNaN(n))return n/100}return null}function E0(e){return Yt.some(t=>Math.abs(t-e)<.01)}function I0(e,t=Eu,n=Iu){return Lu(Fu(e,t,n))}var go={backgroundColor:"rgba(26, 115, 232, 0.3)",borderRadius:0,zIndex:0,opacity:1,mixBlendMode:"multiply"},L0={backgroundColor:"rgba(0, 120, 215, 0.4)",borderColor:"rgba(0, 120, 215, 0.6)",borderRadius:1,zIndex:0,opacity:1},B0={backgroundColor:"--docx-selection-bg",borderColor:"--docx-selection-border",textColor:"--docx-selection-text"};function Bu(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 Db(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 vs(e){let t=Bu(e);return Db(t)}function A0(e,t=go){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 D0(e,t=go){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 Au(){let e=window.getSelection();return e!==null&&!e.isCollapsed&&e.rangeCount>0}function Du(){let e=window.getSelection();return e?e.toString():""}function Hu(e){let t=window.getSelection();if(!t||t.rangeCount===0)return false;let n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)}function H0(){let e=window.getSelection();return !e||e.rangeCount===0?null:e.getRangeAt(0).getBoundingClientRect()}function N0(e,t,n,o,r){try{let i=document.createRange();return i.setStart(t,n),i.setEnd(o,r),i}catch{return null}}function z0(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e));}function O0(){let e=window.getSelection();e&&e.removeAllRanges();}function Hb(){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 $0(){let e=window.getSelection();if(!e||e.rangeCount===0||!Hb())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 Ln=null;function Nu(e=go){Nb();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
- `;Ln=document.createElement("style"),Ln.id="docx-selection-styles",Ln.textContent=t,document.head.appendChild(Ln);}function Nb(){Ln&&(Ln.remove(),Ln=null);let e=document.getElementById("docx-selection-styles");e&&e.remove();}function zu(){return Ln!==null||document.getElementById("docx-selection-styles")!==null}function W0(e,t,n=true){return ()=>{if(!e){t([]);return}let o=n?vs(e):Bu(e);t(o);}}function K0(e){let{containerRef:t,enabled:n=true,config:o=go,useOverlay:r=false,debounceMs:i=16,onSelectionChange:a}=e,[s,l]=Mu.useState(false),[u,d]=Mu.useState(""),[c,p]=Mu.useState([]),[f,m]=Mu.useState(false),b=Mu.useRef(null),g=Mu.useRef(0),S=Mu.useCallback(()=>{let R=t.current,_=Au(),V=Du(),$=R?Hu(R):false;if(l(_),d(V),m($),r&&$){let L=vs(R);p(L);}else p([]);a&&a(_&&$,V);},[t,r,a]),w=Mu.useCallback(()=>{let R=performance.now();if(R-g.current<i){b.current!==null&&clearTimeout(b.current),b.current=window.setTimeout(()=>{g.current=performance.now(),S(),b.current=null;},i);return}g.current=R,S();},[i,S]),k=Mu.useCallback(()=>{S();},[S]),E=Mu.useCallback(R=>({position:"absolute",left:`${R.left}px`,top:`${R.top}px`,width:`${R.width}px`,height:`${R.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 Mu.useEffect(()=>(n&&!zu()&&Nu(o),()=>{}),[n,o]),Mu.useEffect(()=>{if(!n)return;let R=()=>{w();};return document.addEventListener("selectionchange",R),document.addEventListener("mouseup",R),S(),()=>{document.removeEventListener("selectionchange",R),document.removeEventListener("mouseup",R),b.current!==null&&clearTimeout(b.current);}},[n,w,S]),{hasSelection:s,selectedText:u,highlightRects:c,isSelectionInContainer:f,refresh:k,getOverlayStyle:E}}function Y0(e,t=go){return e.map((n,o)=>Mu__default.default.createElement("div",{key:`selection-overlay-${o}`,style:{position:"absolute",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,backgroundColor:t.backgroundColor,borderRadius:t.borderRadius?`${t.borderRadius}px`:void 0,border:t.borderColor?`1px solid ${t.borderColor}`:void 0,zIndex:t.zIndex??0,opacity:t.opacity??1,mixBlendMode:t.mixBlendMode,pointerEvents:"none",userSelect:"none"}}))}function eR(e={}){let{onCopy:t,onCut:n,onPaste:o,cleanWordFormatting:r=true,editable:i=true,onError:a}=e,s=Mu.useRef(false),l=Mu.useRef(null),u=Mu.useCallback(async g=>{if(s.current)return false;s.current=true;try{let S=await chunkPANKMCFX_cjs.ca(g.runs,{onError:a});return S&&t?.(g),S}finally{s.current=false;}},[t,a]),d=Mu.useCallback(async g=>{if(s.current||!i)return false;s.current=true;try{let S=await chunkPANKMCFX_cjs.ca(g.runs,{onError:a});return S&&n?.(g),S}finally{s.current=false;}},[n,i,a]),c=Mu.useCallback(async(g=false)=>{if(s.current||!i)return null;s.current=true;try{if(navigator.clipboard&&navigator.clipboard.read){let S=await navigator.clipboard.read(),w="",k="";for(let R of S)R.types.includes("text/html")&&(w=await(await R.getType("text/html")).text()),R.types.includes("text/plain")&&(k=await(await R.getType("text/plain")).text());g&&(w="");let E=chunkPANKMCFX_cjs.ja(w,k,r);return l.current=E,o?.(E,g),E}return null}catch(S){return a?.(S),null}finally{s.current=false;}},[i,r,o,a]),p=Mu.useCallback(g=>{let S=chunkFDANI5P4_cjs.F();if(!S)return;g.preventDefault();let w=chunkPANKMCFX_cjs.ea(S.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",w.plainText),g.clipboardData.setData("text/html",w.html),w.internal&&g.clipboardData.setData("application/x-docx-editor",w.internal)),t?.(S);},[t]),f=Mu.useCallback(g=>{if(!i)return;let S=chunkFDANI5P4_cjs.F();if(!S)return;g.preventDefault();let w=chunkPANKMCFX_cjs.ea(S.runs);g.clipboardData&&(g.clipboardData.setData("text/plain",w.plainText),g.clipboardData.setData("text/html",w.html),w.internal&&g.clipboardData.setData("application/x-docx-editor",w.internal)),n?.(S);},[i,n]),m=Mu.useCallback(g=>{if(!i)return;g.preventDefault();let S=chunkPANKMCFX_cjs.ia(g,{cleanWordFormatting:r});if(S){l.current=S;let w=g.shiftKey??false;o?.(S,w);}},[i,r,o]),b=Mu.useCallback(g=>{},[]);return {copy:u,cut:d,paste:c,handleCopy:p,handleCut:f,handlePaste:m,handleKeyDown:b,isProcessing:s.current,lastPastedContent:l.current}}var qi={position:"right",defaultSize:280,minSize:200,maxSize:500,resizable:true,collapsible:true,defaultCollapsed:false},Vu=chunkFDANI5P4_cjs.I,ju=`
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
- `,jb=Mu.forwardRef(function({plugins:t,children:n,className:o=""},r){let[i,a]=Mu.useState(null),s=Mu.useRef(n.props);s.current=n.props;let[l,u]=Mu.useState(null),d=Mu.useMemo(()=>new chunkFDANI5P4_cjs.J,[]),c=Mu.useSyncExternalStore(d.subscribe,d.getSnapshot),[p,f]=Mu.useState(()=>{let C=new Set;for(let B of t)({...qi,...B.panelConfig}).defaultCollapsed&&C.add(B.id);return C}),[m]=Mu.useState(()=>{let C=new Map;for(let B of t){let ee={...qi,...B.panelConfig};C.set(B.id,ee.defaultSize);}return C});Mu.useEffect(()=>{if(!i)return;let C=t.map(B=>({id:B.id,styles:B.styles,initialize:B.initialize,onStateChange:B.onStateChange,destroy:B.destroy}));return d.initialize(C,i),()=>{d.destroy();}},[d,i,t]),Mu.useEffect(()=>{let C=t.filter(B=>B.styles).map(B=>Vu(B.id,B.styles));return ()=>C.forEach(B=>B())},[t]),Mu.useEffect(()=>{if(!i?.dom)return;let C=()=>{d.updateStates(i);},B=null,ee=()=>{B&&cancelAnimationFrame(B),B=requestAnimationFrame(C);};C();let ge=i.dom;ge.addEventListener("input",ee),ge.addEventListener("focus",C),ge.addEventListener("click",C);let pe=i.dispatch.bind(i);return i.dispatch=Ee=>{pe(Ee),ee();},()=>{ge.removeEventListener("input",ee),ge.removeEventListener("focus",C),ge.removeEventListener("click",C),B&&cancelAnimationFrame(B),i.dispatch=pe;}},[i,d]),Mu.useEffect(()=>Vu("plugin-host-base",ju),[]);let b=Mu.useCallback(C=>{if(!i)return;if(i.coordsAtPos(C)){i.dom.scrollIntoView({block:"center",inline:"nearest"});let{state:ee}=i,ge=ee.doc.resolve(Math.min(C,ee.doc.content.size)),pe=ee.tr.setSelection(prosemirrorState.TextSelection.near(ge));i.dispatch(pe),i.focus();}},[i]),g=Mu.useCallback((C,B)=>{if(!i)return;let{state:ee}=i,ge=ee.doc.content.size,pe=Math.max(0,Math.min(C,ge)),Ee=Math.max(0,Math.min(B,ge)),Te=ee.tr.setSelection(prosemirrorState.TextSelection.create(ee.doc,pe,Ee));i.dispatch(Te),i.focus();},[i]),S=Mu.useCallback(C=>d.getPluginState(C),[d]),w=Mu.useCallback((C,B)=>{d.setPluginState(C,B);},[d]),k=Mu.useCallback(()=>{i&&d.updateStates(i);},[i,d]);Mu.useImperativeHandle(r,()=>({getPluginState:S,setPluginState:w,getEditorView:()=>i,refreshPluginStates:k}),[S,w,i,k]);let E=Mu.useMemo(()=>{let C=[];for(let B of t)B.proseMirrorPlugins&&C.push(...B.proseMirrorPlugins);return C},[t]),R=Mu.useCallback(C=>{f(B=>{let ee=new Set(B);return ee.has(C)?ee.delete(C):ee.add(C),ee});},[]),[_,V]=Mu.useState(null);Mu.useEffect(()=>{if(!l){V(null);return}let C=()=>{let ge=l.pagesContainer,pe=ge.querySelector(".layout-page");if(!pe){V(null);return}let Ee=l.getContainerOffset(),Te=pe.getBoundingClientRect(),Re=ge.getBoundingClientRect(),P=(Te.right-Re.left)/l.zoom,I=Ee.x+P+5;V(I);};C();let B=()=>{requestAnimationFrame(C);};window.addEventListener("resize",B);let ee=new ResizeObserver(()=>{requestAnimationFrame(C);});return ee.observe(l.pagesContainer),()=>{window.removeEventListener("resize",B),ee.disconnect();}},[l]);let $=Mu.useMemo(()=>{let C=[];if(l){for(let B of t)if(B.renderOverlay){let ee=c.states.get(B.id);C.push(jsxRuntime.jsx("div",{className:"plugin-overlay","data-plugin-id":B.id,children:B.renderOverlay(l,ee,i)},`overlay-${B.id}`));}}for(let B of t){if(!B.Panel||(B.panelConfig?.position??"right")!=="right")continue;let ge={...qi,...B.panelConfig},pe=p.has(B.id),Ee=m.get(B.id)??ge.defaultSize,Te=B.Panel,Re=c.states.get(B.id),P=_!==null?`${_}px`:"calc(50% + 428px)";C.push(jsxRuntime.jsxs("div",{className:`plugin-panel-in-viewport ${pe?"collapsed":""}`,style:{width:pe?"32px":`${Ee}px`,left:P},"data-plugin-id":B.id,children:[ge.collapsible&&jsxRuntime.jsx("button",{className:"plugin-panel-toggle",onClick:()=>R(B.id),title:pe?`Show ${B.name}`:`Hide ${B.name}`,"aria-label":pe?`Show ${B.name}`:`Hide ${B.name}`,children:jsxRuntime.jsx("span",{className:"plugin-panel-toggle-icon",children:pe?"\u2039":"\u203A"})}),!pe&&l&&jsxRuntime.jsx("div",{className:"plugin-panel-in-viewport-content",children:jsxRuntime.jsx(Te,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:g,pluginState:Re,panelWidth:Ee,renderedDomContext:l})})]},`panel-overlay-${B.id}`));}return C.length>0?C:null},[l,t,c.version,i,p,m,b,g,R,_]),L=Mu.useCallback(C=>{u(C);let B=s.current?.onRenderedDomContextReady;typeof B=="function"&&B(C);},[]),W=Mu.useMemo(()=>Mu.cloneElement(n,{externalPlugins:E,pluginOverlays:$,onRenderedDomContextReady:L,onEditorViewReady:C=>{a(C);let B=s.current?.onEditorViewReady;typeof B=="function"&&B(C);}}),[n,E,$,L]),O=Mu.useMemo(()=>{let C=[],B=[],ee=[];for(let ge of t){if(!ge.Panel)continue;let pe=ge.panelConfig?.position??"right";pe==="left"?C.push(ge):pe==="bottom"?ee.push(ge):B.push(ge);}return {left:C,right:B,bottom:ee}},[t]),K=C=>{if(!C.Panel)return null;let B={...qi,...C.panelConfig},ee=p.has(C.id),ge=m.get(C.id)??B.defaultSize,pe=C.Panel,Ee=c.states.get(C.id);return jsxRuntime.jsxs("div",{className:`plugin-panel plugin-panel-${B.position} ${ee?"collapsed":""}`,style:{[B.position==="bottom"?"height":"width"]:ee?"32px":`${ge}px`,minWidth:B.position!=="bottom"?ee?"32px":`${B.minSize}px`:void 0,maxWidth:B.position!=="bottom"?`${B.maxSize}px`:void 0,minHeight:B.position==="bottom"?ee?"32px":`${B.minSize}px`:void 0,maxHeight:B.position==="bottom"?`${B.maxSize}px`:void 0},"data-plugin-id":C.id,children:[B.collapsible&&jsxRuntime.jsxs("button",{className:"plugin-panel-toggle",onClick:()=>R(C.id),title:ee?`Show ${C.name}`:`Hide ${C.name}`,"aria-label":ee?`Show ${C.name}`:`Hide ${C.name}`,children:[jsxRuntime.jsx("span",{className:"plugin-panel-toggle-icon",children:ee?"\u203A":"\u2039"}),ee&&jsxRuntime.jsx("span",{className:"plugin-panel-toggle-label",children:C.name})]}),!ee&&jsxRuntime.jsx("div",{className:"plugin-panel-content",children:jsxRuntime.jsx(pe,{editorView:i,doc:i?.state.doc??null,scrollToPosition:b,selectRange:g,pluginState:Ee,panelWidth:ge,renderedDomContext:l??null})})]},C.id)};return jsxRuntime.jsxs("div",{className:`plugin-host ${o}`,children:[O.left.length>0&&jsxRuntime.jsx("div",{className:"plugin-panels-left",children:O.left.map(K)}),jsxRuntime.jsxs("div",{className:"plugin-host-editor",children:[W,O.bottom.length>0&&jsxRuntime.jsx("div",{className:"plugin-panels-bottom",children:O.bottom.map(K)})]})]})});exports.A=vs;exports.B=A0;exports.C=D0;exports.D=Au;exports.E=Du;exports.F=Hu;exports.G=H0;exports.H=N0;exports.I=z0;exports.J=O0;exports.K=Hb;exports.L=$0;exports.M=Nu;exports.N=Nb;exports.O=zu;exports.P=W0;exports.Q=K0;exports.R=Y0;exports.S=eR;exports.T=ju;exports.U=jb;exports.a=Yb;exports.b=ul;exports.c=sr;exports.d=qb;exports.e=Xb;exports.f=Zb;exports.g=Jb;exports.h=fl;exports.i=Pu;exports.j=d0;exports.k=x0;exports.l=Yt;exports.m=w0;exports.n=C0;exports.o=T0;exports.p=v0;exports.q=R0;exports.r=P0;exports.s=M0;exports.t=E0;exports.u=I0;exports.v=go;exports.w=L0;exports.x=B0;exports.y=Bu;exports.z=Db;//# sourceMappingURL=chunk-QVIZ775M.cjs.map
259
- //# sourceMappingURL=chunk-QVIZ775M.cjs.map