@docx-editor.dev/react 2.20.0 → 2.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -39
- package/dist/index.d.mts +197 -25
- package/dist/index.d.ts +197 -25
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var lt=require('react'),i18n=require('@docx-editor.dev/i18n'),jsxRuntime=require('react/jsx-runtime'),editor=require('@docx-editor.dev/core/editor'),reactDom=require('react-dom'),classVarianceAuthority=require('class-variance-authority'),clsx=require('clsx'),xe=require('@radix-ui/react-select'),editor$1=require('@docx-editor.dev/core/contracts/editor');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var lt__namespace=/*#__PURE__*/_interopNamespace(lt);var xe__namespace=/*#__PURE__*/_interopNamespace(xe);var yu={version:"2.20.0"};var Wb=yu.version;var Yl=lt.createContext(i18n.en),Xl=lt.createContext("en");function bn({i18n:e,children:t}){let o=lt.useContext(Yl),n=lt.useContext(Xl),r=typeof e?._lang=="string"?e._lang:n,i=lt.useMemo(()=>i18n.deepMerge(o,e),[o,e]);return jsxRuntime.jsx(Xl.Provider,{value:r,children:jsxRuntime.jsx(Yl.Provider,{value:i,children:t})})}function L(){let e=lt.useContext(Yl),t=lt.useContext(Xl);return {t:lt.useMemo(()=>i18n.createT(e,t),[e,t]),catalogue:e}}function Su(e){let{t}=L();return lt.useCallback((o,n)=>e?.get(o)??t(o,n),[e,t])}var Qe={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};var Ql=lt.createContext(null);function F(){return lt.useContext(Ql)}var bt=lt.createContext(null);var Jl=0,es=false,ts=false;function Eu(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(es||(es=true,Jl+=1,queueMicrotask(()=>{es=false;}),ts||(ts=true,setTimeout(()=>{ts=false,Jl=0;},0))),Jl>16)}function wu(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};Eu()?setTimeout(o,0):queueMicrotask(o);}}var eh=()=>{},ns=0;function th(){return ns}function lr(e){return wu(e)}function O(e,t=Object.is,o){let n=F(),r=o?.onSubscribe,i=o?.onUnsubscribe,a=lt.useCallback(d=>{if(!n)return eh;let f=false;ns++,r?.();let u=lr(()=>{f||d();}),g=[n.on("change",u),n.on("selectionChange",u),n.on("error",u)];return ()=>{f=true,ns--,i?.();for(let p of g)p();}},[n,r,i]),l=lt.useMemo(()=>{let d=false,f,u;return g=>{if(d&&g===f)return u;let p=e(g);return d&&t(u,p)?(f=g,u):(d=true,f=g,u=p,p)}},[n,e,t]),s=lt.useCallback(()=>l(n?n.snapshot():editor.LOADING_SNAPSHOT),[n,l]),c=lt.useCallback(()=>l(editor.LOADING_SNAPSHOT),[l]);return lt.useSyncExternalStore(a,s,c)}function lh(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason&&e.value===t.value}function rs(e){return typeof e=="string"}function se(e){let t=F(),{t:o}=L(),n=rs(e)?e:editor.editorCommandKey(e),r=lt.useRef(e);r.current=e;let i=lt.useCallback(s=>{let c=r.current;if(rs(c)){let f=editor.toolbarCommandState(t,c);return {active:f.active,enabled:f.enabled,disabledReason:i18n.localizeDisabledReason(f.disabledReason,o),value:f.value??null}}if(!t)return {active:false,enabled:false,disabledReason:null,value:null};let d=t.can(c);return {active:t.isActive(c),enabled:d.ok,disabledReason:d.ok?null:i18n.localizeDisabledReason(d.reason??null,o),value:null}},[t,n,o]),a=O(i,lh),l=lt.useCallback(()=>{let s=r.current;return rs(s)?editor.runToolbarCommand(t,s).ok:t?t.exec(s).ok:false},[t,n]);return lt.useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[l,a])}var uh=()=>()=>{},ph=()=>true,mh=()=>false;function vn(){let e=lt.useSyncExternalStore(uh,ph,mh);return lt.useCallback(t=>e?i18n.platformShortcut(t):t,[e])}var ko=lt.createContext({t:void 0,onSave:void 0});function gh(){return lt.useContext(ko)}function Za(e){let{t}=L();return o=>e?.(o)??t(o)}function ee(){let{t:e}=lt.useContext(ko);return Za(e)}function yh(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function xh(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=yh(t[n],e[n]):n==="className"?o[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(o[n]={...e[n],...t[n]});return o}function j({children:e,...t}){let o=lt.Children.only(e);if(!lt.isValidElement(o))return null;let n=o.props,r=xh(t,n),i=o.ref,a=t.ref;return (i||a)&&(r.ref=l=>{for(let s of [i,a])typeof s=="function"?s(l):s&&typeof s=="object"&&(s.current=l);}),lt.cloneElement(o,r)}function Q(e){for(let t of editor.CHROME_GROUPS)for(let o of t.controls)if(editor.chromeSlotId(t,o)===e)return o;return null}function oe(e){return e?jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:e.map(t=>jsxRuntime.jsx("path",{d:t,fill:"currentColor"},t))}):null}function Z(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Do(e){let{slot:t,icon:o,asChild:n,className:r,children:i,hidden:a}=e,{execute:l,isActive:s,isEnabled:c,disabledReason:d,value:f}=se(t),u=ee(),g=vn();if(a)return null;let p=Q(t),m=g(u(p?.labelKey??t)),b=editor.chromeSlotIsToggle(t),h={onClick:()=>l(),onMouseDown:Z,disabled:!c,"data-slot":t,className:`docx-toolbar__button${r?` ${r}`:""}`,...s?{"data-active":""}:{},...c?{}:{"data-disabled":""},...b?{"aria-pressed":s}:{},...f!==null?{"data-value":f}:{},"aria-label":m,title:d??m};return n?jsxRuntime.jsx(j,{...h,children:i}):jsxRuntime.jsx("button",{type:"button",...h,children:o??i??oe(p?.paths)})}Do.docxToolbarPart=true;function yn({text:e,x:t,y:o,className:n}){return jsxRuntime.jsx("div",{role:"tooltip",className:n,"data-testid":"docx-notes-preview",style:{position:"fixed",left:t,top:o,zIndex:Qe.popover,maxWidth:280,maxHeight:"40vh",overflowY:"auto",padding:"8px 10px",background:"var(--doc-popover-bg)",color:"var(--doc-popover-fg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",fontSize:12,lineHeight:1.4,pointerEvents:"none"},onMouseDown:r=>{r.preventDefault(),r.stopPropagation();},children:e})}function xn({noteKind:e,x:t,y:o,onDelete:n,onConvert:r,onConvertAll:i,onOpenProperties:a,onClose:l,deleteEnabled:s,convertEnabled:c,convertAllEnabled:d,deleteDisabledReason:f,convertDisabledReason:u,convertAllDisabledReason:g,className:p}){let{t:m}=L();return jsxRuntime.jsxs("div",{role:"menu",className:p,onKeyDown:b=>{b.key==="Escape"&&l();},"data-testid":"docx-notes-menu",style:{position:"fixed",left:t,top:o,zIndex:Qe.popover,minWidth:160,background:"var(--doc-popover-bg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",padding:4},onMouseDown:Z,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!s,title:f,onClick:n,children:m("notes.delete")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!c,title:u,onClick:r,children:m(e==="footnote"?"notes.convertToEndnote":"notes.convertToFootnote")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert-all",disabled:!d,title:g,onClick:i,children:m(e==="footnote"?"notes.convertAllFootnotes":"notes.convertAllEndnotes")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",onClick:a,children:m("dialogs.footnoteProperties.title")})]})}function wh(e){return t=>lt.createElement(e,t)}var Du=new WeakMap,Rh=0;function Le(e,t,o){if(e===false)return null;let n=e(t);if(!o)return n;let r=Du.get(o);return r===void 0&&Du.set(o,r=++Rh),lt.createElement(lt.Fragment,{key:r},n)}function ro(e,t,o){let n=e.getBoundingClientRect();return {left:t-n.left-e.clientLeft+e.scrollLeft,top:o-n.top-e.clientTop+e.scrollTop}}function cr(e){return e.paragraphId===""}var Io=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),_h=e=>e;function Nh(){let e=o=>!!o&&(o.width>0||o.height>0);if(typeof document<"u"){let n=document.querySelector("[data-docx-caret]")?.getBoundingClientRect();if(e(n))return {left:n.left,top:n.bottom}}let t=typeof window>"u"?null:window.getSelection();if(t&&t.rangeCount>0){let o=t.getRangeAt(0),n=o.getBoundingClientRect();if(e(n))return {left:n.left,top:n.bottom};let r=o.startContainer,a=(r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.getBoundingClientRect();if(e(a))return {left:a.left,top:a.bottom}}return null}var dr=lt.createContext(null);function as(){let e=lt.useContext(dr),t=za(e===null);return e??t}function za(e=true){let t=F(),[o,n]=lt.useState(Io),r=lt.useRef(null),i=lt.useRef(o);i.current=o;let a=O(_h),l=t?t.can({type:"insertText",text:""}).ok:false,s=lt.useCallback(()=>{let v=r.current;v&&(v.editor.releaseSelection(v.pin),r.current=null);},[]),c=lt.useCallback((v,y)=>{s(),n({mode:v?"reading":"editing",link:v??null,anchor:y??null,text:v?.text??"",url:v?v.kind==="internal"?`#${v.anchor??""}`:v.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,s]),d=lt.useCallback(()=>{s(),n(Io);},[s]);lt.useEffect(()=>s,[s]);let f=lt.useCallback(()=>{let v=Nh();s();let y=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(y&&cr(y)){c(y,v);return}if(y){n({mode:"editing",link:y,anchor:v,text:y.text,url:y.kind==="internal"?`#${y.anchor??""}`:y.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let C=t?.query({type:"selectedText"})??"",T=t?.retainSelection()??null;t&&T&&(r.current={editor:t,pin:T}),n({mode:"editing",link:null,anchor:v,text:C,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,c,s]);lt.useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:v=>c(v.link,{left:v.rect.left,top:v.rect.bottom}),onRequest:f})},[t,e,c,f]),lt.useEffect(()=>{let v=i.current;if(v.mode!=="reading"||!v.link)return;let y=cr(v.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;y&&y.id===v.link.id||n(Io);},[a,t]),lt.useEffect(()=>{let v=i.current;if(v.mode!=="editing"||v.link)return;let y=t?.surface;!y||y.retainedSelection()||n(Io);},[a,t]);let u=lt.useCallback(async()=>{let v=i.current.link?.href;if(!v)return false;try{await navigator.clipboard.writeText(v);}catch{return false}return n(y=>({...y,copied:true})),true},[]),g=lt.useCallback(()=>{n(v=>({...v,mode:"editing",copied:false,error:false}));},[]),p=lt.useCallback(v=>{n(y=>({...y,text:v,copied:false,error:false}));},[]),m=lt.useCallback(v=>{n(y=>({...y,url:v,copied:false,error:false}));},[]),b=lt.useCallback(()=>{let v=i.current,y=t?.surface?.hyperlinks;if(!y)return false;let C=v.url.trim();if(C.length===0)return n(S=>({...S,error:true})),false;let T=C.startsWith("#");return y.applyHyperlink({...T?{anchor:C.slice(1)}:{url:C},...v.text.trim().length>0?{text:v.text}:{}})?(d(),true):(n(S=>({...S,error:true})),false)},[t,d]),h=lt.useCallback(()=>{let v=t?.surface?.hyperlinks,y=i.current.link;if(!v)return false;let C=v.removeHyperlink(y?.id);return C&&d(),C},[t,d]),x=lt.useCallback(()=>{let v=t?.surface?.navigation,y=i.current.link;if(!v||!y)return false;if(y.kind==="internal"){let T=y.anchor?v.goToBookmark(y.anchor):false;return T&&n(Io),T}let C=v.openExternal(y.href);return C&&n(Io),C},[t]);return lt.useMemo(()=>({state:o.mode==="closed"?Io:{...o,canEdit:l},open:c,openAtCaret:f,close:d,copy:u,beginEdit:g,setText:p,setUrl:m,commitEdit:b,unlink:h,openTarget:x}),[o,l,c,f,d,u,g,p,m,b,h,x])}function No(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var Va=e=>jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})}),Zh="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z",qh="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z",Kh="M770-302 656-416l57-57 114 114-57 57ZM603-469 469-603l57-57 134 134-57 57ZM280-280h133v80H280q-83 0-141.5-58.5T80-400q0-83 58.5-141.5T280-600h133v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35Zm40-80v-80h101l80 80H320Zm493-15-57-57q23-11 33.5-32t10.5-36q0-50-35-85t-85-35H547v-80h133q83 0 141.5 58.5T880-400q0 32-11 61.5T813-375ZM792-56 56-792l56-56 736 736-56 56Z",zh="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z";function Vh({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=Rt(),a=lt.useRef(null),{state:l,close:s}=i;lt.useEffect(()=>{if(l.mode==="closed")return;let m=h=>{h.key==="Escape"&&(h.preventDefault(),s());},b=h=>{let x=a.current;x&&h.target instanceof Node&&x.contains(h.target)||s();};return document.addEventListener("keydown",m),document.addEventListener("mousedown",b,true),()=>{document.removeEventListener("keydown",m),document.removeEventListener("mousedown",b,true);}},[l.mode,s]);let[c,d]=lt.useState(null);lt.useLayoutEffect(()=>{let m=l.anchor,b=a.current;if(!m||!b){d(null);return}let h=b.offsetParent;if(!h){d(null);return}let{left:x,top:v}=ro(h,m.left,m.top),y=Math.max(0,h.scrollWidth-b.offsetWidth);d({left:Math.max(0,Math.min(x,y)),top:v});},[l.anchor]);let{t:f}=L(),u=l.mode==="editing"?f(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):f("hyperlinkPopup.editLink"),g=r?jsxRuntime.jsx($h,{children:n}):n;if(o)return l.mode==="closed"?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:n});let p={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:No,style:c??void 0,"aria-label":u};return l.mode==="closed"?null:t?jsxRuntime.jsx(j,{...p,children:n}):jsxRuntime.jsx("div",{...p,children:g})}function $h({children:e}){let{state:t}=Rt(),o=lt.useMemo(()=>Wh(e),[e]),n=(i,a)=>i in o?o[i]:a;if(t.mode==="editing")return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Fields",jsxRuntime.jsx(us,{})),n("Error",jsxRuntime.jsx(ms,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Apply",jsxRuntime.jsx(ps,{})),n("Cancel",jsxRuntime.jsx(fs,{}))]}),o.__extra]});let r=t.canEdit&&!(t.link&&cr(t.link));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Url",jsxRuntime.jsx(ls,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Copy",jsxRuntime.jsx(ss,{})),r?n("Edit",jsxRuntime.jsx(cs,{})):null,r?n("Unlink",jsxRuntime.jsx(ds,{})):null]}),o.__extra]})}function Wh(e){let t={},o=[],n=r=>{if(Array.isArray(r)){r.forEach(n);return}if(!r||typeof r!="object"||!("type"in r)){r&&o.push(r);return}if(r.type===lt.Fragment){n(r.props.children);return}let i=r.type.docxHyperLinkPart;i?t[i]=r:o.push(r);};return n(e),o.length>0&&(t.__extra=o),t}function Rt(){return lt.useContext(dr)??Uh}var Uh={state:{mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:false},open:()=>{},openAtCaret:()=>{},close:()=>{},copy:async()=>false,beginEdit:()=>{},setText:()=>{},setUrl:()=>{},commitEdit:()=>false,unlink:()=>false,openTarget:()=>false};function ls({className:e,asChild:t,hidden:o,children:n}){let{state:r,openTarget:i}=Rt(),{t:a}=L();if(o||!r.link)return null;let l=!r.link.href,s=r.link.kind==="internal",c=s?`#${r.link.anchor??""}`:r.link.authored,d=a(l?"hyperlinkPopup.inertTarget":s?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),f={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...l?{"data-inert":""}:{},title:d,onMouseDown:No,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsxRuntime.jsx(j,{...f,className:e,children:n}):l?jsxRuntime.jsxs("span",{...f,children:[n??c,jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:d})]}):jsxRuntime.jsxs("button",{...f,children:[n??c,Va(zh)]})}ls.docxHyperLinkPart="Url";function ss({className:e,asChild:t,hidden:o,children:n,icon:r}){let{state:i,copy:a}=Rt(),{t:l}=L();if(o||!i.link?.href)return null;let s=i.copied?l("editor.linkCopied"):l("hyperlinkPopup.copyLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...i.copied?{"data-copied":""}:{},"aria-label":s,title:s,onMouseDown:No,onClick:()=>{a();}};return t?jsxRuntime.jsx(j,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:r??n??Va(Zh)})}ss.docxHyperLinkPart="Copy";function cs({className:e,asChild:t,hidden:o,children:n,icon:r}){let{beginEdit:i}=Rt(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.editLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":l,title:l,onMouseDown:No,onClick:()=>i()};return t?jsxRuntime.jsx(j,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:r??n??Va(qh)})}cs.docxHyperLinkPart="Edit";function ds({className:e,asChild:t,hidden:o,children:n,icon:r}){let{unlink:i}=Rt(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.removeLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":l,title:l,onMouseDown:No,onClick:()=>i()};return t?jsxRuntime.jsx(j,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:r??n??Va(Kh)})}ds.docxHyperLinkPart="Unlink";function us({className:e,hidden:t}){let{state:o,setText:n,setUrl:r,commitEdit:i,close:a}=Rt(),{t:l}=L(),s=lt.useRef(null),c=lt.useId(),d=lt.useId();lt.useEffect(()=>{o.mode==="editing"&&(s.current?.focus({preventScroll:true}),s.current?.select());},[o.mode]);let f=lt.useCallback(u=>{if(u.key==="Enter"){u.preventDefault(),i();return}u.key==="Escape"&&(u.preventDefault(),a());},[i,a]);return t?null:jsxRuntime.jsxs("div",{className:`docx-hyperlink-popup__fields${e?` ${e}`:""}`,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:l("hyperlinkPopup.displayTextPlaceholder")}),jsxRuntime.jsx("input",{id:c,"data-testid":"hyperlink-popup-text",className:"docx-hyperlink-popup__input",value:o.text,placeholder:l("hyperlinkPopup.displayTextPlaceholder"),onChange:u=>n(u.target.value),onKeyDown:f}),jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:l("hyperlinkPopup.urlPlaceholder")}),jsxRuntime.jsx("input",{id:d,ref:s,"data-testid":"hyperlink-popup-url-input",className:"docx-hyperlink-popup__input",value:o.url,placeholder:l("hyperlinkPopup.urlPlaceholder"),onChange:u=>r(u.target.value),onKeyDown:f})]})}us.docxHyperLinkPart="Fields";function ps({className:e,asChild:t,hidden:o,children:n}){let{state:r,commitEdit:i}=Rt(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.apply"),s={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:No,onClick:()=>i()};return t?jsxRuntime.jsx(j,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:n??l})}function ms({className:e,hidden:t}){let{state:o}=Rt(),{t:n}=L();return t||!o.error?null:jsxRuntime.jsx("div",{className:`docx-hyperlink-popup__error${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-error",role:"alert",children:n("hyperlinkPopup.refused")})}ms.docxHyperLinkPart="Error";ps.docxHyperLinkPart="Apply";function fs({className:e,asChild:t,hidden:o,children:n}){let{close:r}=Rt(),{t:i}=L();if(o)return null;let a=i("hyperlinkPopup.cancel"),l={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:No,onClick:()=>r()};return t?jsxRuntime.jsx(j,{...l,className:e,children:n}):jsxRuntime.jsx("button",{...l,children:n??a})}fs.docxHyperLinkPart="Cancel";var ur=Object.assign(Vh,{Url:ls,Copy:ss,Edit:cs,Unlink:ds,Fields:us,Error:ms,Apply:ps,Cancel:fs});var et={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function Xh(e){return e==="sdtLocked"||e==="sdtContentLocked"}function Qh(e){return e==="contentLocked"||e==="sdtContentLocked"}function bs(e,t){return !e.ok&&e.code===t}function Mt(){let e=lt.useContext(hs),t=$a();return e??t}function $a(){let e=F(),[t,o]=lt.useState(false),[n,r]=lt.useState(false),[i,a]=lt.useState(false),l=O(w=>w),s=e?.surface??null,c=s?.contentControls;lt.useEffect(()=>{r(c?.showAll()??s?.state().contentControls.showAll??false),a(c?.formFill()??s?.state().contentControls.formFill??false);},[l,c,s]);let d=lt.useMemo(()=>{if(!e)return null;let w=c?.atCaret()??null;if(w){let P=c?.disabledReason(w.id,"edit")??null,k=c?.disabledReason(w.id,"remove")??null;return {id:w.id,tag:w.tag??null,alias:w.alias??null,controlType:w.controlType,locked:Qh(w.effectiveLock)||P==="locked",removalLocked:Xh(w.effectiveLock)||k==="locked",placeholder:w.placeholder,bound:w.bound||P==="bound",effectiveLock:w.effectiveLock}}let S=e.query({type:"contentControlAt"});if(!S)return null;let M=c?.disabledReason(S.id,"edit")??null,R=c?.disabledReason(S.id,"remove")??null,D=e.can({type:"setContentControlValue",value:""}),_=e.can({type:"removeContentControl"}),H=S.locked===true||M==="locked"||bs(D,"locked"),N=M==="bound"||bs(D,"bound"),I=R==="locked"||bs(_,"locked");return {id:S.id,tag:S.tag??null,alias:S.alias??null,controlType:S.controlType,locked:H,removalLocked:I,placeholder:false,bound:N,effectiveLock:null}},[e,l,c]),f=lt.useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=lt.useCallback(w=>{c?.setShowAll(w),r(w);},[c]),g=lt.useCallback(w=>{c?.setFormFill(w),a(w);},[c]),p=lt.useCallback(()=>u(!n),[u,n]),m=lt.useCallback(()=>g(!i),[g,i]),b=lt.useCallback(()=>o(true),[]),h=lt.useCallback(()=>o(false),[]),x=lt.useCallback(()=>o(w=>!w),[]),v=lt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let S=c.disabledReason(d.id,"edit");return S==="locked"?"the content control is locked":S==="bound"?"the content control is bound to external data":S==="notFound"?"the content control was not found":S}if(d.locked)return "the content control is locked";if(d.bound)return "the content control is bound to external data";if(!e)return "no document is loaded";let w=e.can({type:"setContentControlValue",value:""});return w.ok?null:w.reason},[d,c,e]),y=lt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let S=c.disabledReason(d.id,"remove");return S==="locked"?"the content control is locked":S==="notFound"?"the content control was not found":S}if(d.removalLocked)return "the content control is locked";if(!e)return "no document is loaded";let w=e.can({type:"removeContentControl"});return w.ok?null:w.reason},[d,c,e]),C=lt.useCallback(w=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c&&d){let S=c.disabledReason(d.id,"edit");if(S)return {ok:false,code:S==="bound"?"bound":S==="locked"?"locked":"notFound",reason:S==="bound"?"the content control is bound to external data":S==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:w})},[e,c,d]),T=lt.useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c){let w=d?.id;if(!w)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let S=c.disabledReason(w,"remove");return S?{ok:false,code:S==="locked"?"locked":"notFound",reason:S==="locked"?"the content control is locked":"the content control was not found"}:c.remove(w)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,c,d]);return lt.useMemo(()=>({control:d,controls:f,showAll:n,formFill:i,inspectorOpen:t,canSetValue:v===null&&d!==null,canRemove:y===null&&d!==null,setValueDisabledReason:v,removeDisabledReason:y,setShowAll:u,toggleShowAll:p,setFormFill:g,toggleFormFill:m,openInspector:b,closeInspector:h,toggleInspector:x,remove:T,setValue:C}),[d,f,n,i,t,v,y,u,p,g,m,b,h,x,T,C])}var hs=lt.createContext(null);function vs(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var Hu=e=>jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})}),tv="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z",ov="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",nv={position:"absolute",zIndex:20,minWidth:240,maxWidth:320,top:12,right:12,padding:12,borderRadius:8,border:"1px solid var(--doc-border)",backgroundColor:"var(--doc-surface)",boxShadow:"0 4px 16px var(--doc-shadow)",color:"var(--doc-text)",fontSize:13,display:"flex",flexDirection:"column",gap:10},rv={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},av={color:"var(--doc-text-muted)",flexShrink:0},iv={textAlign:"right",wordBreak:"break-word"},lv={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},sv={display:"flex",gap:8,marginTop:4},Ou={display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:4,border:"1px solid var(--doc-border)",backgroundColor:"var(--doc-bg)",color:"var(--doc-text)",font:"inherit",cursor:"pointer"};function cv(e){switch(e){case "plainText":return "contentControl.types.plainText";case "checkbox":return "contentControl.types.checkbox";case "dropdown":return "contentControl.types.dropdown";case "comboBox":return "contentControl.types.comboBox";case "date":return "contentControl.types.date";case "picture":return "contentControl.types.picture";case "repeatingSection":return "contentControl.types.repeatingSection";default:return "contentControl.types.richText"}}function dv(e){return e.effectiveLock==="sdtContentLocked"?"contentControl.lock.sdtContentLocked":e.effectiveLock==="contentLocked"||e.locked?"contentControl.lock.contentLocked":e.effectiveLock==="sdtLocked"||e.removalLocked?"contentControl.lock.sdtLocked":"contentControl.lock.unlocked"}function Tn({label:e,value:t,testId:o}){return jsxRuntime.jsxs("div",{style:rv,"data-testid":o,children:[jsxRuntime.jsx("span",{style:av,children:e}),jsxRuntime.jsx("span",{style:iv,children:t})]})}function uv({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=Mt(),a=lt.useRef(null),l=lt.useId(),{t:s}=L(),{control:c,inspectorOpen:d,closeInspector:f}=i;if(lt.useEffect(()=>{if(!d)return;let m=h=>{h.key==="Escape"&&(h.preventDefault(),f());},b=h=>{let x=a.current;x&&h.target instanceof Node&&x.contains(h.target)||f();};return document.addEventListener("keydown",m),document.addEventListener("mousedown",b,true),()=>{document.removeEventListener("keydown",m),document.removeEventListener("mousedown",b,true);}},[d,f]),lt.useEffect(()=>{d&&!c&&f();},[d,c,f]),o||!d||!c)return null;let u=r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bu,{}),jsxRuntime.jsx(Zu,{}),jsxRuntime.jsx("div",{style:sv,children:jsxRuntime.jsx(qu,{})}),n]}):n,g={ref:a,role:"dialog","aria-modal":false,"aria-labelledby":l,"data-testid":"content-control-inspector","data-control-id":c.id,"data-control-type":c.controlType,...c.locked?{"data-locked":""}:{},...c.bound?{"data-bound":""}:{},...c.placeholder?{"data-placeholder":""}:{},className:`docx-content-control-inspector${e?` ${e}`:""}`,style:nv,onMouseDown:m=>{vs(m),m.stopPropagation();}},p=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{id:l,className:"docx-editor-sr-only",children:s("contentControl.inspectorPanel.title")}),u]});return t?jsxRuntime.jsx(j,{...g,children:p}):jsxRuntime.jsx("div",{...g,children:p})}function Bu({className:e,asChild:t,hidden:o,children:n}){let{closeInspector:r}=Mt(),{t:i}=L();if(o)return null;let a={style:lv,className:e??void 0,"data-testid":"content-control-inspector-header"},l=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:n??i("contentControl.inspectorPanel.title")}),jsxRuntime.jsx("button",{type:"button","data-testid":"content-control-inspector-close","aria-label":i("common.close"),title:i("common.close"),style:{...Ou,padding:4,border:"none",background:"transparent"},onMouseDown:vs,onClick:()=>r(),children:Hu(tv)})]});return t?jsxRuntime.jsx(j,{...a,children:l}):jsxRuntime.jsx("div",{...a,children:l})}function Zu({className:e,asChild:t,hidden:o,children:n}){let{control:r}=Mt(),{t:i}=L();if(o||!r)return null;let a=i("contentControl.inspectorPanel.empty"),l=i("contentControl.inspectorPanel.yes"),s=i("contentControl.inspectorPanel.no"),c=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Tn,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsxRuntime.jsx(Tn,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsxRuntime.jsx(Tn,{label:i("contentControl.inspectorPanel.type"),value:i(cv(r.controlType)),testId:"content-control-inspector-type"}),jsxRuntime.jsx(Tn,{label:i("contentControl.inspectorPanel.lock"),value:i(dv(r)),testId:"content-control-inspector-lock"}),jsxRuntime.jsx(Tn,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsxRuntime.jsx(Tn,{label:i("contentControl.inspectorPanel.bound"),value:r.bound?l:s,testId:"content-control-inspector-bound"}),r.bound?jsxRuntime.jsx("p",{"data-testid":"content-control-inspector-bound-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},children:i("contentControl.inspectorPanel.boundNote")}):null,r.locked?jsxRuntime.jsx("p",{"data-testid":"content-control-inspector-locked-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},"aria-live":"polite",children:i("contentControl.inspectorPanel.lockedNote")}):null]}),d={className:e??void 0,"data-testid":"content-control-inspector-fields",style:{display:"flex",flexDirection:"column",gap:8}};return t?jsxRuntime.jsx(j,{...d,children:c}):jsxRuntime.jsx("div",{...d,children:c})}function qu({className:e,asChild:t,hidden:o,icon:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:s}=Mt(),{t:c}=L();if(o)return null;let d=c("contentControl.remove"),f={type:"button",className:`docx-content-control-inspector__remove${e?` ${e}`:""}`,"data-testid":"content-control-inspector-remove","data-slot":"contentControl.remove",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":d,title:a??d,style:Ou,onMouseDown:vs,onClick:()=>{l().ok&&s();}},u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n??r??Hu(ov),jsxRuntime.jsx("span",{children:d})]});return t?jsxRuntime.jsx(j,{...f,children:u}):jsxRuntime.jsx("button",{...f,children:u})}var fr=Object.assign(uv,{Header:Bu,Fields:Zu,Remove:qu});var gv=e=>e;function Ss(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function gr(){let e=F(),{t}=L(),[o,n]=lt.useState(null),[r,i]=lt.useState(null),a=lt.useRef(null),l=lt.useRef(null),s=lt.useRef(null),c=lt.useId(),d=lt.useId(),f=lt.useId(),u=o?.activation??null,g=O(gv),p=lt.useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let v=e.surface.equations.can(u.equation.id,"replace"),y=e.surface.equations.can(u.equation.id,"remove"),C=v.ok?y.ok?null:y.reason:v.reason;return {replaceEnabled:v.ok,removeEnabled:y.ok,reason:C?i18n.localizeDisabledReason(C,t):null}},[u,e,g,t]),m=lt.useCallback((v=false)=>{s.current?.(),s.current=null,n(null),v&&e&&queueMicrotask(()=>e.focus());},[e]);lt.useEffect(()=>{if(!e)return;let v=e.setEquationChrome({onPopover:y=>{s.current?.();let C=e.surface;if(C&&typeof C.retainSelection=="function"){let T=C.retainSelection();s.current=()=>C.releaseSelection(T);}else s.current=null;n({activation:y,mountGeneration:e.mountGeneration,draft:y.equation.linear,error:false});}});return ()=>{v(),s.current?.(),s.current=null,n(null);}},[e,m]),lt.useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&m();},[e,g,o,m]),lt.useEffect(()=>{if(!o)return;let v=a.current,y=v?.ownerDocument,C=y?.defaultView;if(!v||!y||!C)return;let T=S=>{S.key==="Escape"&&(S.preventDefault(),m(true));},w=S=>{S.target instanceof C.Node&&v.contains(S.target)||m();};return y.addEventListener("keydown",T),y.addEventListener("pointerdown",w,true),()=>{y.removeEventListener("keydown",T),y.removeEventListener("pointerdown",w,true);}},[o,m]),lt.useLayoutEffect(()=>{if(!u){i(null);return}let v=a.current;if(!v)return;let y=v.offsetParent;if(!y){i(null);return}let C=u.rect,T=ro(y,C.left,C.bottom),w=Math.max(0,y.scrollWidth-v.offsetWidth);i({left:Math.max(0,Math.min(T.left,w)),top:T.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[u]);let b=lt.useCallback(()=>{if(!o||!e?.surface||!p.replaceEnabled)return false;let v=e.surface.equations.applyEquation(o.activation.equation.id,o.draft);return v?m(true):n(y=>y&&{...y,error:true}),v},[e,o,m,p.replaceEnabled]),h=lt.useCallback(()=>{if(!o||!e?.surface||!p.removeEnabled)return false;let v=e.surface.equations.removeEquation(o.activation.equation.id);return v?m(true):n(y=>y&&{...y,error:true}),v},[e,o,m,p.removeEnabled]);if(!o)return null;let x=[o.error?d:null,p.reason?f:null].filter(Boolean).join(" ");return jsxRuntime.jsxs("div",{ref:a,className:"docx-equation-popup","data-testid":"equation-popup",role:"dialog","aria-modal":false,"aria-label":t("equationPopup.title"),style:r??void 0,onMouseDown:Ss,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:t("equationPopup.inputLabel")}),jsxRuntime.jsx("input",{id:c,ref:l,className:"docx-equation-popup__input","data-testid":"equation-popup-input",value:o.draft,placeholder:t("equationPopup.placeholder"),spellCheck:false,"aria-describedby":x||void 0,onChange:v=>n(y=>y&&{...y,draft:v.target.value,error:false}),onKeyDown:v=>{v.key!=="Enter"||v.nativeEvent.isComposing||(v.preventDefault(),b());}}),o.error?jsxRuntime.jsx("div",{id:d,className:"docx-equation-popup__error","data-testid":"equation-popup-error",role:"alert",children:t("equationPopup.refused")}):null,p.reason?jsxRuntime.jsx("div",{id:f,className:"docx-equation-popup__error","data-testid":"equation-popup-disabled-reason",role:"status",children:p.reason}):null,jsxRuntime.jsxs("div",{className:"docx-equation-popup__actions",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-equation-popup__apply","data-testid":"equation-popup-apply",disabled:!p.replaceEnabled,title:p.reason??void 0,onMouseDown:Ss,onClick:b,children:t("equationPopup.apply")}),jsxRuntime.jsx("button",{type:"button",className:"docx-equation-popup__delete","data-testid":"equation-popup-delete",disabled:!p.removeEnabled,title:p.reason??void 0,onMouseDown:Ss,onClick:h,children:t("equationPopup.delete")})]})]})}function Pn(e,t){if(!lt.isValidElement(e)||e.type!==lt.Fragment)return null;let n=lt.Children.toArray(e.props.children).map(t).filter(r=>r!==null);return n.length===1?n[0]:null}function Ua({entries:e,children:t,preset:o,keyOfEntry:n,keyOfChild:r,renderEntry:i}){if(!o)return t;let a=new Map,l=[];for(let f of lt.Children.toArray(t)){let u=r(f);u?a.set(u,f):l.push(f);}let s=e.map((f,u)=>{let g=n(f,u),p=a.get(g);return p?jsxRuntime.jsx(lt.Fragment,{children:p},g):jsxRuntime.jsx(lt.Fragment,{children:i(f,u)},g)}),c=new Set(e.map(n)),d=[...a.entries()].filter(([f])=>!c.has(f)).map(([f,u])=>jsxRuntime.jsx(lt.Fragment,{children:u},f));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[s,d,l]})}var br=lt.createContext({t:void 0,openMenu:null,setOpenMenu:()=>{},activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0});function tt(){return lt.useContext(br)}function ke(){let{t:e}=tt(),{t}=L();return o=>e?.(o)??t(o)}var Tv='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Lo(e){return [...e.querySelectorAll(Tv)].filter(t=>t.closest('[role="menu"]')===e)}function Es(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function vt(e,t,o){if(e.length===0)return false;let n=t?e.indexOf(t):-1,r=n===-1?o>0?0:e.length-1:(n+o+e.length)%e.length;return e[r]?.focus(),true}function yt(e,t){let o=t==="first"?e[0]:e[e.length-1];return o?(o.focus(),true):false}var Cv="https://github.com/eigenpal/docx-editor/issues/new";function Sv(){if(typeof window>"u")return "";try{let e=new URL(window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function $u(e={}){let t=e.userAgent??(typeof navigator<"u"?navigator.userAgent:"unknown"),o=e.viewport??(typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0}),r=["### What happened","","### Steps to reproduce","1. ","2. ","3. ","","### Expected","","### Actual","","### Attach the DOCX","Please drag the `.docx` file that reproduces this onto the issue (below this text box). Bugs are much faster to fix with a real file.","","### Environment",`- URL: ${e.pageUrl??Sv()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
|
|
2
|
-
`),i=new URLSearchParams({title:"[Bug] ",body:r});return `${Cv}?${i.toString()}`}function hr(e){typeof window>"u"||window.open($u(e),"_blank","noopener,noreferrer");}var Uu=12700,Wu=96;function Rv(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function Mv(e,t,o,n){let r=e*72/o,i=t*72/n;return {widthPoints:Math.max(1,Math.round(r*100)/100),heightPoints:Math.max(1,Math.round(i*100)/100)}}function Ga(e){let t=editor.DEFAULT_IMAGE_RESOURCE_LIMITS;if(e.byteLength===0)return {ok:false,reasonKey:"imageInsert.errors.emptyFile"};if(e.byteLength>t.maxEncodedBytes)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let o=editor.sniffImageMime(e);if(!Rv(o))return o==="image/svg+xml"||o==="image/tiff"?{ok:false,reasonKey:"imageInsert.errors.unsupportedFormat"}:{ok:false,reasonKey:"imageInsert.errors.invalidSignature"};let n=editor.validateRasterHeader(e,o);if(!n)return {ok:false,reasonKey:"imageInsert.errors.invalidSignature"};if(n.pixelWidth*n.pixelHeight>t.maxPixels||n.pixelWidth>t.maxDimension||n.pixelHeight>t.maxDimension)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let{widthPoints:i,heightPoints:a}=Mv(n.pixelWidth,n.pixelHeight,n.dpiX??Wu,n.dpiY??Wu);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function ao(e){return Math.round(e/Uu*100)/100}function vr(e){return Math.round(e*Uu)}var Lv="image/png,image/jpeg,image/gif",Rs=lt.createContext(null);function Yu(){let e=lt.useContext(Rs);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function yr(){return lt.useContext(Rs)}function ja({children:e}){let t=F(),{t:o}=L(),n=lt.useRef(null),r=lt.useRef(false),i=lt.useCallback(()=>editor.toolbarCommandState(t,"image.insert"),[t]),a=O(i,(m,b)=>m.enabled===b.enabled&&m.disabledReason===b.disabledReason),l=a.enabled,s=i18n.localizeDisabledReason(a.disabledReason,o),c=lt.useCallback(async m=>{if(!t||r.current)return;let b=Ga(m);if(!b.ok){window.alert(o(b.reasonKey));return}let h={type:"insertImage",data:b.bytes,mime:b.mime,widthPoints:b.widthPoints,heightPoints:b.heightPoints},x=t.canExecuteImageCommand?.(h);if(x&&!x.ok){window.alert(x.reason??o("imageInsert.errors.refused"));return}r.current=true;try{let v=await editor.executeImageCommand(t,h);v.ok?t.focus():window.alert(v.reason??o("imageInsert.errors.refused"));}finally{r.current=false;}},[t,o]),d=lt.useCallback(async m=>{let b=m?.[0];if(!b)return;let h=await b.arrayBuffer();await c(new Uint8Array(h));},[c]),f=lt.useCallback(async m=>{if(!m)return;let b=[...m.files].find(h=>h.type.startsWith("image/"));if(b){await d([b]);return}for(let h of m.items){if(h.kind!=="file"||!h.type.startsWith("image/"))continue;let x=h.getAsFile();if(!x)continue;let v=await x.arrayBuffer();await c(new Uint8Array(v));return}},[c,d]),u=lt.useCallback(()=>{l&&n.current?.click();},[l]),g=lt.useCallback(async m=>{let b=m.currentTarget;await d(b.files),b.value="";},[d]),p=lt.useMemo(()=>({openFilePicker:u,insertFromFileList:d,insertFromDataTransfer:f,isEnabled:l,disabledReason:s,inputRef:n,onInputChange:g}),[u,d,f,l,s,g]);return jsxRuntime.jsxs(Rs.Provider,{value:p,children:[jsxRuntime.jsx("input",{ref:n,type:"file",accept:Lv,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:g,onMouseDown:m=>m.stopPropagation()}),e]})}function Ya({className:e,hidden:t,asChild:o,children:n}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=Yu(),l=ee();if(t)return null;let s=Q("image.insert"),c=l(s?.labelKey??"toolbar.image"),d={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":c,title:a??c,onMouseDown:Z,onClick:r};return o?jsxRuntime.jsx(j,{...d,children:n}):jsxRuntime.jsx("button",{...d,children:n??oe(s?.paths)})}Ya.docxSlot="image.insert";var xr=Object.assign(Ya,{docxSlot:"image.insert"});var Ms=6,Qu=6;function De(e){let{icon:t,shortcut:o,disabled:n,title:r,active:i,selected:a,slot:l,onSelect:s,className:c,children:d}=e,f=e["data-value"],u=vn(),g=lt.useId(),p=n&&r?g:void 0;return jsxRuntime.jsxs("button",{type:"button",role:i===void 0?"menuitem":a===void 0?"menuitemcheckbox":"menuitemradio",className:`docx-toolbar__menu-item docx-menubar__item${c?` ${c}`:""}`,tabIndex:-1,...l?{"data-slot":l}:{},...f!==void 0?{"data-value":f}:{},...i?{"data-active":""}:{},...n?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...p?{"aria-describedby":p}:{},...r?{title:r}:{},onMouseDown:Z,onClick:n?void 0:s,children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:t}),jsxRuntime.jsx("span",{className:"docx-menubar__item-label",children:d}),o?jsxRuntime.jsx("span",{className:"docx-menubar__item-shortcut",children:u(o)}):null,p?jsxRuntime.jsx("span",{id:g,className:"docx-editor-sr-only",children:r}):null]})}function Cr({label:e,labelKey:t,className:o,hidden:n,children:r}){let i=ke();if(n)return null;let a=e??(t===void 0?void 0:i(t));return jsxRuntime.jsxs("div",{role:"group",className:`docx-menubar__group${o?` ${o}`:""}`,...a?{"aria-label":a}:{},children:[a?jsxRuntime.jsx("div",{className:"docx-menubar__group-label","aria-hidden":"true",children:a}):null,r]})}function zt({slot:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let{execute:i,isActive:a,isEnabled:l,disabledReason:s,value:c}=se(e),{setOpenMenu:d}=tt(),f=ke();if(r)return null;let u=Q(e),g=f(t??u?.labelKey??e),p=editor.chromeSlotIsToggle(e),m=["setAlignment","setReviewDisplayMode"].includes(editor.commandForSlot(e)?.type??"");return jsxRuntime.jsx(De,{slot:e,icon:oe(u?.paths),...o?{shortcut:f(o)}:{},disabled:!l,...s?{title:s}:{},...p?{active:a}:{},...m?{selected:true}:{},...c!==null?{"data-value":c}:{},onSelect:()=>{i(),d(null);},...n?{className:n}:{},children:g})}zt.docxMenuRow=true;function ep(e,t,o,n){return Object.assign(({className:i,hidden:a})=>{let l=tt(),s=ke(),c=n(l);if(a)return null;let d=Q(e),f=s(t??d?.labelKey??e);return jsxRuntime.jsx(De,{slot:e,icon:oe(d?.paths),...o?{shortcut:s(o)}:{},disabled:!c,onSelect:()=>{c?.(),l.setOpenMenu(null);},...i?{className:i}:{},children:f})},{docxSlot:e})}var Ds=ep("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),Is=ep("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave);function qv({className:e,hidden:t}){let o=F(),n=tt(),r=ke(),i=editor.chromeProbeForSlot("file.pageSetup"),a=o&&i?o.can(i):null,l=a?.ok===true,s=a&&!a.ok?a.reason:null;if(t)return null;let c=Q("file.pageSetup"),d=r(c?.labelKey??"file.pageSetup"),f=l&&!!n.onPageSetup;return jsxRuntime.jsx(De,{slot:"file.pageSetup",icon:oe(c?.paths),disabled:!f,...s?{title:s}:{},onSelect:()=>{n.onPageSetup?.(),n.setOpenMenu(null);},...e?{className:e}:{},children:d})}function Kv({className:e,hidden:t}){let o=F(),n=tt(),r=ke(),i=editor.chromeProbeForSlot("paragraph.dialog"),a=o&&i?o.can(i):null,l=a?.ok===true,s=a&&!a.ok?a.reason:null;if(t)return null;let c=Q("paragraph.dialog"),d=r(c?.labelKey??"lineSpacing.options"),f=l&&!!n.onParagraphDialog;return jsxRuntime.jsx(De,{slot:"paragraph.dialog",icon:oe(c?.paths),disabled:!f,...s?{title:s}:{},onSelect:()=>{n.onParagraphDialog?.(),n.setOpenMenu(null);},...e?{className:e}:{},children:d})}var zv=Object.assign(Kv,{docxSlot:"paragraph.dialog"}),_s=Object.assign(qv,{docxSlot:"file.pageSetup"});function Vv({className:e,hidden:t}){let o=yr(),n=tt(),r=ke();if(t)return null;let i=Q("image.insert"),a=r(i?.labelKey??"toolbar.image"),l=o?.isEnabled??false,s=o?.disabledReason??null;return jsxRuntime.jsx(De,{slot:"image.insert",icon:oe(i?.paths),disabled:!l,...s?{title:s}:{},onSelect:()=>{o?.openFilePicker(),n.setOpenMenu(null);},...e?{className:e}:{},children:a})}var Ns=Object.assign(Vv,{docxSlot:"image.insert"}),Tr=8;function kt({labelKey:e,paths:t,className:o,children:n}){let r=ke(),[i,a]=lt.useState(false),l=lt.useRef(null),s=lt.useRef(null),c=lt.useId(),d=r(e),[f,u]=lt.useState(null);return lt.useLayoutEffect(()=>{if(!i){u(null);return}let g=l.current,p=s.current,m=g?.ownerDocument.defaultView;if(!g||!p||!m)return;let b=g.getBoundingClientRect(),h=p.offsetWidth,x=p.offsetHeight,v=b.right+h>m.innerWidth-Tr;u({left:v?Math.max(Tr,b.left-h):Math.min(b.right,m.innerWidth-h-Tr),top:Math.max(Tr,Math.min(b.top-4,m.innerHeight-x-Tr))});},[i]),jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__submenu${o?` ${o}`:""}`,onMouseEnter:()=>a(true),onMouseLeave:()=>a(false),onKeyDown:g=>{g.key==="ArrowRight"&&document.activeElement===l.current?(g.preventDefault(),a(true),queueMicrotask(()=>{s.current&&yt(Lo(s.current),"first");})):(g.key==="ArrowLeft"||g.key==="Escape")&&i&&(g.preventDefault(),g.stopPropagation(),a(false),l.current?.focus());},onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||a(false);},children:[jsxRuntime.jsxs("button",{ref:l,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?c:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...i?{"data-open":""}:{},onMouseDown:Z,onFocus:()=>a(true),onClick:()=>a(true),children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:oe(t)}),jsxRuntime.jsx("span",{className:"docx-menubar__item-label",children:d}),jsxRuntime.jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),i?jsxRuntime.jsx("div",{ref:s,id:c,className:"docx-toolbar__menu docx-menubar__menu docx-menubar__submenu-panel",role:"menu","aria-label":d,style:f?{position:"fixed",left:f.left,top:f.top}:{position:"fixed",visibility:"hidden"},onKeyDown:g=>{let p=s.current;if(!p)return;let m=Lo(p);g.key==="ArrowDown"?(g.preventDefault(),g.stopPropagation(),vt(m,document.activeElement,1)):g.key==="ArrowUp"&&(g.preventDefault(),g.stopPropagation(),vt(m,document.activeElement,-1));},children:n}):null]})}function Qa({slot:e="table.insert",className:t}){let o=F(),{isEnabled:n}=se(e),{setOpenMenu:r}=tt(),i=ke(),[a,l]=lt.useState(null),[s,c]=lt.useState({rows:1,cols:1}),d=lt.useRef(null),f=lt.useCallback((p,m)=>{if(!o||!n)return;let b={type:"insertTable",rows:p,cols:m};o.can(b).ok&&(o.exec(b),r(null),o.focus());},[o,n,r]),u=lt.useCallback(p=>{c(m=>{let b={rows:Math.min(Qu,Math.max(1,m.rows+(p.rows??0))),cols:Math.min(Ms,Math.max(1,p.toCol??m.cols+(p.cols??0)))};return l(b),queueMicrotask(()=>d.current?.querySelector(`[data-cell="${b.rows}x${b.cols}"]`)?.focus()),b});},[]),g=[];for(let p=1;p<=Qu;p+=1){let m=[];for(let b=1;b<=Ms;b+=1){let h=!!a&&p<=a.rows&&b<=a.cols;m.push(jsxRuntime.jsx("button",{type:"button",role:"gridcell","data-cell":`${p}x${b}`,className:"docx-menubar__grid-cell",tabIndex:s.rows===p&&s.cols===b?0:-1,...h?{"data-filled":""}:{},"aria-label":`${b} \xD7 ${p}`,onMouseDown:Z,onMouseEnter:()=>l({rows:p,cols:b}),onFocus:()=>l({rows:p,cols:b}),onClick:()=>f(p,b)},b));}g.push(jsxRuntime.jsx("div",{role:"row",className:"docx-menubar__grid-row",children:m},p));}return jsxRuntime.jsxs("div",{ref:d,role:"grid","aria-label":i("toolbar.insertTable"),className:`docx-menubar__grid${t?` ${t}`:""}`,onMouseLeave:()=>l(null),onKeyDown:p=>{if(p.key==="ArrowRight")u({cols:1});else if(p.key==="ArrowLeft")u({cols:-1});else if(p.key==="ArrowDown")u({rows:1});else if(p.key==="ArrowUp")u({rows:-1});else if(p.key==="Home")u({toCol:1});else if(p.key==="End")u({toCol:Ms});else return;p.preventDefault(),p.stopPropagation();},children:[jsxRuntime.jsx("div",{className:"docx-menubar__grid-cells",children:g}),jsxRuntime.jsx("div",{className:"docx-menubar__grid-caption","aria-hidden":"true",children:a?`${a.cols} \xD7 ${a.rows}`:""})]})}function $v({entry:e}){let{isEnabled:t}=se(e.slot),o=Q(e.slot);return t?jsxRuntime.jsx(kt,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsxRuntime.jsx(Qa,{slot:e.slot})}):jsxRuntime.jsx(zt,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Ao({className:e}){return jsxRuntime.jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function Sr({entry:e}){return e.kind==="separator"?jsxRuntime.jsx(Ao,{}):e.kind==="submenu"?jsxRuntime.jsx(kt,{labelKey:e.labelKey,paths:e.paths,children:e.items.map((t,o)=>jsxRuntime.jsx(Sr,{entry:t},o))}):e.slot==="file.open"?jsxRuntime.jsx(Ds,{}):e.slot==="file.save"?jsxRuntime.jsx(Is,{}):e.slot==="file.pageSetup"?jsxRuntime.jsx(_s,{}):e.slot==="paragraph.dialog"?jsxRuntime.jsx(zv,{}):e.slot==="image.insert"?jsxRuntime.jsx(Ns,{}):e.picker==="tableGrid"?jsxRuntime.jsx($v,{entry:e}):jsxRuntime.jsx(zt,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function tp(e){if(!lt.isValidElement(e))return null;let t=Pn(e,tp);if(t!==null)return t;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxMenuRow===true){let n=e.props.slot;if(typeof n=="string")return n}return null}function Wv(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function Uv(e,t,o){return Ua({entries:e??[],children:t,preset:o,keyOfEntry:Wv,keyOfChild:tp,renderEntry:n=>jsxRuntime.jsx(Sr,{entry:n})})}function lo({id:e,labelKey:t,label:o,icon:n,className:r,hidden:i,preset:a=true,children:l}){let{openMenu:s,setOpenMenu:c,activeMenu:d}=tt(),f=ke(),u=lt.useId(),g=lt.useRef(null),p=lt.useRef(null),m=lt.useRef(false),b=lt.useRef(false),h=editor.CHROME_MENUS.find(T=>T.id===e),x=s===e;if(i)return null;let v=o??f(t??h?.labelKey??e),y=Uv(h?.entries,l,a),C=()=>{c(null),g.current?.focus();};return jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__menu-root${r?` ${r}`:""}`,"data-menu":e,children:[jsxRuntime.jsxs("button",{ref:g,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":x,"aria-controls":x?u:void 0,className:"docx-menubar__trigger",tabIndex:d===e?0:-1,...x?{"data-open":""}:{},onMouseDown:Z,onKeyDown:T=>{T.key==="ArrowDown"||T.key==="Enter"||T.key===" "||T.key==="ArrowUp"?(T.preventDefault(),m.current=true,c(e)):T.key==="Escape"&&x&&(T.preventDefault(),C());},onClick:()=>{if(b.current){b.current=false;return}c(x?null:e);},onMouseEnter:()=>{s!==null&&s!==e&&(b.current=true,c(e));},onMouseLeave:()=>{b.current=false;},children:[n?jsxRuntime.jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:n}):null,v]}),x?jsxRuntime.jsx("div",{ref:T=>{p.current=T,T&&m.current&&(m.current=false,yt(Lo(T),"first"));},id:u,role:"menu","aria-label":v,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:T=>{let w=p.current;if(!w)return;let S=Lo(w),M=document.activeElement;T.key==="ArrowDown"?(T.preventDefault(),vt(S,M,1)):T.key==="ArrowUp"?(T.preventDefault(),vt(S,M,-1)):T.key==="Home"?(T.preventDefault(),yt(S,"first")):T.key==="End"?(T.preventDefault(),yt(S,"last")):T.key==="Escape"?(T.preventDefault(),T.stopPropagation(),C()):T.key==="Tab"&&c(null);},children:y}):null]})}function Ls(e){return Object.assign(o=>jsxRuntime.jsx(lo,{id:e,...o}),{docxMenu:e})}var Fs=Ls("file"),As=Ls("format"),Hs=Ls("insert");function Gv({className:e,hidden:t,onSelect:o}){let{setOpenMenu:n,onReportIssue:r,reportIssue:i}=tt(),a=ke();if(t||i===false)return null;let l=o??r??hr;return jsxRuntime.jsx(De,{slot:"help.reportIssue",onSelect:()=>{l(),n(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var Ja=Object.assign(Gv,{docxSlot:"help.reportIssue"});function jv({children:e,...t}){let{reportIssue:o}=tt();return e===void 0&&o===false?null:jsxRuntime.jsxs(lo,{id:"help",...t,children:[jsxRuntime.jsx(Ja,{}),e]})}var Os=Object.assign(jv,{docxMenu:"help"});var ei=lt.createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function so(){return lt.useContext(ei)}function np(){return lt.useContext(ei).target}var rp=["M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-560l-80-80 240-240h120v40L600-560ZM240-640q33 0 56.5-23.5T320-720q0-33-23.5-56.5T240-800q-33 0-56.5 23.5T160-720q0 33 23.5 56.5T240-640Zm240 180q8 0 14-6t6-14q0-8-6-14t-14-6q-8 0-14 6t-6 14q0 8 6 14t14 6Zm-240 300q33 0 56.5-23.5T320-240q0-33-23.5-56.5T240-320q-33 0-56.5 23.5T160-240q0 33 23.5 56.5T240-160Z"],ap=["M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"],Bs=["M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h168q13-36 43.5-58t68.5-22q38 0 68.5 22t43.5 58h168q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"],ip=["M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z"],lp=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],sp=["M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"],cp=["M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-120q-33 0-56.5-23.5T120-200h80v80Zm-80-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160q0-33 23.5-56.5T200-840v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z"];function wn(e,t,o){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:l,hidden:s})=>{let c=F(),{close:d}=so(),f=ke(),{isEnabled:u,disabledReason:g}=se(t);return s?null:jsxRuntime.jsx(De,{slot:e,icon:r??oe(o.paths),shortcut:f(a??o.shortcutKey),disabled:!u,...g?{title:g}:{},onSelect:()=>{c?.exec(t),d(true);},...l?{className:l}:{},children:f(i??o.labelKey)})},{docxRow:e})}var Pr=wn("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:rp}),Er=wn("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:ap}),wr=wn("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:ip}),Rr=wn("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:cp});function Rn({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=F(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=so(),c=ke(),d=lt.useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:f,disabledReason:u}=se(d);if(r)return null;let g=l!==null;return jsxRuntime.jsx(De,{slot:"edit.paste",icon:e??oe(Bs),shortcut:c(o??"contextMenu.pasteShortcut"),disabled:!f||g,...l??u?{title:l??u??""}:{},onSelect:()=>{(async()=>{try{let{text:p,html:m}=await Qv();(p||m)&&i?.exec({type:"paste",text:p,...m?{html:m}:{}});}catch(p){s(p instanceof Error?p.message:"the clipboard is not readable");}finally{a(true);}})();},...n?{className:n}:{},children:c(t??"contextMenu.paste")})}Rn.docxRow="edit.paste";async function Qv(){let e=navigator.clipboard;if(typeof e.read=="function"&&typeof ClipboardItem<"u")try{let t=await e.read(),o="",n=null;for(let r of t)r.types.includes("text/plain")&&(o=await(await r.getType("text/plain")).text()),r.types.includes("text/html")&&(n=await(await r.getType("text/html")).text());if(o||n)return {text:o,html:n}}catch{}return {text:await e.readText(),html:null}}function Mn({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=F(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=so(),c=ke(),d=lt.useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:f,disabledReason:u}=se(d);if(r)return null;let g=l!==null;return jsxRuntime.jsx(De,{slot:"edit.pasteWithoutFormatting",icon:e??oe(Bs),shortcut:c(o??"contextMenu.pasteWithoutFormattingShortcut"),disabled:!f||g,...l??u?{title:l??u??""}:{},onSelect:()=>{(async()=>{try{let p=await navigator.clipboard.readText();p&&i?.exec({type:"pasteWithoutFormatting",text:p});}catch(p){s(p instanceof Error?p.message:"the clipboard is not readable");}finally{a(true);}})();},...n?{className:n}:{},children:c(t??"contextMenu.pasteWithoutFormatting")})}Mn.docxRow="edit.pasteWithoutFormatting";var dp=Q("format.painter")?.paths??[],ti=wn("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:dp}),oi=wn("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:dp});function Ho(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l,destructive:s})=>{let{close:c}=so(),d=ke(),f=ni(),{isEnabled:u,disabledReason:g,execute:p}=se(t);return l||!f?null:jsxRuntime.jsx(De,{slot:e,icon:r??oe(o.paths),disabled:!u,...g?{title:g}:{},className:`${s??o.destructive?"docx-table-chrome__destructive-row":""}${a?` ${a}`:""}`,onSelect:()=>{p()&&c(true);},children:d(i??o.labelKey)})},{docxRow:e})}var kn=Ho("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:editor.tableChromeIconPaths("table_rows")}),Dn=Ho("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:editor.tableChromeIconPaths("table_rows")}),In=Ho("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:editor.tableChromeIconPaths("view_column")}),_n=Ho("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:editor.tableChromeIconPaths("view_column")}),Nn=Ho("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:editor.tableChromeIconPaths("delete_sweep"),destructive:true}),Ln=Ho("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:editor.tableChromeIconPaths("view_column"),destructive:true}),Fn=Ho("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:editor.tableChromeIconPaths("delete"),destructive:true}),Jv=[{alignment:"top",labelKey:"tableAdvanced.top",icon:"vertical_align_top"},{alignment:"center",labelKey:"tableAdvanced.middle",icon:"vertical_align_center"},{alignment:"bottom",labelKey:"tableAdvanced.bottom",icon:"vertical_align_bottom"}];function Oo({hidden:e}){let{close:t}=so(),o=ke(),n=ni(),r=se({type:"setTableCellVerticalAlignment",alignment:"top"}),i=se({type:"setTableCellVerticalAlignment",alignment:"center"}),a=se({type:"setTableCellVerticalAlignment",alignment:"bottom"}),l=[r,i,a];return e||!n?null:jsxRuntime.jsxs("div",{className:"docx-contextmenu__table-align",children:[jsxRuntime.jsx("span",{className:"docx-contextmenu__table-align-label",children:o("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{className:"docx-contextmenu__table-align-buttons",role:"group","aria-label":o("tableAdvanced.verticalAlignment"),children:Jv.map((s,c)=>{let d=l[c];return jsxRuntime.jsx("button",{type:"button",role:"menuitemradio","aria-checked":false,"aria-label":o(s.labelKey),title:d.disabledReason??o(s.labelKey),"aria-disabled":!d.isEnabled,className:"docx-contextmenu__table-align-button",onMouseDown:f=>{f.preventDefault(),f.stopPropagation();},onClick:()=>{d.execute()&&t(true);},children:oe(editor.tableChromeIconPaths(s.icon))},s.alignment)})})]})}Oo.docxRow="table.cellVerticalAlignment";function up(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l})=>{let s=F(),{close:c,tocId:d}=so(),f=ke(),u=lt.useMemo(()=>({type:"refreshToc",mode:t,...d?{tocId:d}:{}}),[d]),{isEnabled:g,disabledReason:p}=se(u);return l||d===null?null:jsxRuntime.jsx(De,{slot:e,icon:r??oe(o.paths),disabled:!g,...p?{title:p}:{},onSelect:()=>{s?.exec(u),c(true);},...a?{className:a}:{},children:f(i??o.labelKey)})},{docxRow:e})}var An=up("toc.refresh","entire",{labelKey:"toc.refresh",paths:lp}),Hn=up("toc.refreshPageNumbers","pageNumbers",{labelKey:"toc.refreshPageNumbers",paths:sp});function ni(){return O(lt.useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function ri({label:e,icon:t,shortcut:o,disabled:n,disabledReason:r,active:i,onSelect:a,className:l}){let{close:s}=so();return jsxRuntime.jsx(De,{...t?{icon:t}:{},...o?{shortcut:o}:{},...n?{disabled:n}:{},...n&&r?{title:r}:{},...i!==void 0?{active:i}:{},onSelect:()=>{a?.(),s(true);},...l?{className:l}:{},children:e})}var Bo=lt.createContext(false);function it(){return lt.useContext(Bo)?"":"docx-editor "}var li=8,ay=e=>e.editingMode==="viewing";function iy(){let e=F(),t=lt.useContext(bt),o=tt(),n=ke(),r=e?.can({type:"toggleReviewPane"}),i=O(ay),a=!r?.ok||i||(t?.mounted??0)===0||e?.getSelectionPlacement()===null,l=Q("review.comments");return jsxRuntime.jsx(De,{icon:oe(l?.paths),slot:"review.comments",disabled:a,title:r&&!r.ok?r.reason:i?n("editingMode.viewingHint"):void 0,onSelect:()=>{t?.requestCommentDraft()&&o.setOpenMenu(null);},children:n("comments.addComment")})}function ly(){let e=F(),t=tt(),o=ke();return e?.can({type:"editTextFormField"}).ok?jsxRuntime.jsx(De,{slot:"field.edit",onSelect:()=>{t.setOpenMenu(null),e.exec({type:"editTextFormField"});},children:o("textFormField.edit")}):null}var sy=[{kind:"row",id:"field.edit",render:()=>jsxRuntime.jsx(ly,{})},{kind:"row",id:"edit.cut",render:()=>jsxRuntime.jsx(Pr,{})},{kind:"row",id:"edit.copy",render:()=>jsxRuntime.jsx(Er,{})},{kind:"row",id:"edit.paste",render:()=>jsxRuntime.jsx(Rn,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsxRuntime.jsx(Mn,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsxRuntime.jsx(ti,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsxRuntime.jsx(oi,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsxRuntime.jsx(wr,{})},{kind:"row",id:"edit.selectAll",render:()=>jsxRuntime.jsx(Rr,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsxRuntime.jsx(zt,{slot:"text.link",labelKey:"formattingBar.insertLink"})},{kind:"row",id:"review.comments",render:()=>jsxRuntime.jsx(iy,{})}];function cy(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:kn.docxRow,render:()=>jsxRuntime.jsx(kn,{})},{kind:"row",id:Dn.docxRow,render:()=>jsxRuntime.jsx(Dn,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:In.docxRow,render:()=>jsxRuntime.jsx(In,{})},{kind:"row",id:_n.docxRow,render:()=>jsxRuntime.jsx(_n,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:Nn.docxRow,render:()=>jsxRuntime.jsx(Nn,{})},{kind:"row",id:Ln.docxRow,render:()=>jsxRuntime.jsx(Ln,{})},{kind:"row",id:Fn.docxRow,render:()=>jsxRuntime.jsx(Fn,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:Oo.docxRow,render:()=>jsxRuntime.jsx(Oo,{})}]}function dy(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:An.docxRow,render:()=>jsxRuntime.jsx(An,{})},{kind:"row",id:Hn.docxRow,render:()=>jsxRuntime.jsx(Hn,{})}]}function uy(e,t=false){return [...sy,...e?cy():[],...t?dy():[]]}function bp(e){if(!lt.isValidElement(e))return null;let t=Pn(e,bp);if(t!==null)return t;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxRow=="string")return o.docxRow;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxMenuRow===true){let n=e.props.slot;if(typeof n=="string")return n}return null}function fp(e){if(!lt.isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function py(e){return e?.closest(".docx-editor__scroll-container")??null}function kr({className:e,t,preset:o=true,disabled:n,onOpenChange:r,children:i}){let a=it(),l=F(),{t:s}=L(),c=ni(),d=lt.useRef(null),f=lt.useRef(null),[u,g]=lt.useState(null),[p,m]=lt.useState(null),[b,h]=lt.useState(null),x=lt.useMemo(()=>uy(c,p!==null),[c,p]),[v,y]=lt.useState(null),C=lt.useCallback((H=false)=>{g(null),y(null),m(null),h(null),H&&l?.focus();},[l]);lt.useEffect(()=>{if(n)return;let H=py(d.current);if(!H)return;let N=I=>{I.preventDefault();let P=I.button===-1||I.clientX===0&&I.clientY===0,k=H.getBoundingClientRect();m(l?.snapshot().tocContext?.id??null),h(P||!(I.target instanceof HTMLElement)?null:I.target),g(P?{x:k.left+16,y:k.top+16}:{x:I.clientX,y:I.clientY});};return H.addEventListener("contextmenu",N),()=>H.removeEventListener("contextmenu",N)},[n,l]),lt.useEffect(()=>{n&&C();},[n,C]),lt.useEffect(()=>{if(!u)return;let H=P=>{f.current?.contains(P.target)||C();},N=P=>{P.key==="Escape"?(P.preventDefault(),C(true)):P.key==="Tab"&&C();},I=()=>C();return document.addEventListener("pointerdown",H,true),document.addEventListener("keydown",N),document.addEventListener("scroll",I,{capture:true,passive:true}),window.addEventListener("blur",I),window.addEventListener("resize",I),()=>{document.removeEventListener("pointerdown",H,true),document.removeEventListener("keydown",N),document.removeEventListener("scroll",I,true),window.removeEventListener("blur",I),window.removeEventListener("resize",I);}},[u,C]),lt.useLayoutEffect(()=>{let H=f.current;if(!u||!H)return;let{width:N,height:I}=H.getBoundingClientRect(),P=window.innerWidth-N-li,k=window.innerHeight-I-li,Y=Math.max(li,u.x>P?u.x-N:u.x),z=Math.max(li,u.y>k?u.y-I:u.y);y({x:Y,y:z});},[u]),lt.useLayoutEffect(()=>{v&&f.current?.focus({preventScroll:true});},[v]);let T=lt.useRef(r);T.current=r;let w=lt.useRef(false);lt.useEffect(()=>{let H=u!==null;H!==w.current&&(w.current=H,T.current?.(H));},[u]);let S=lt.useMemo(()=>({t,openMenu:null,setOpenMenu:()=>C(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,C]),[M,R]=lt.useState(null),D=lt.useMemo(()=>({close:C,anchor:u,tocId:p,target:b,clipboardRefusal:M,reportClipboardRefusal:R}),[C,u,p,b,M]),_={position:"fixed",left:(v??u)?.x??0,top:(v??u)?.y??0,visibility:v?"visible":"hidden"};return jsxRuntime.jsx("div",{ref:d,style:{display:"contents"},children:u?jsxRuntime.jsx(br.Provider,{value:S,children:jsxRuntime.jsx(ei.Provider,{value:D,children:jsxRuntime.jsxs("div",{ref:f,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??s("contextMenu.ariaLabel"),tabIndex:-1,className:`${a}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,style:_,onKeyDown:H=>{let N=f.current;if(!N)return;let I=Lo(N);H.key==="ArrowDown"?(H.preventDefault(),vt(I,document.activeElement,1)):H.key==="ArrowUp"?(H.preventDefault(),vt(I,document.activeElement,-1)):H.key==="Home"?(H.preventDefault(),yt(I,"first")):H.key==="End"&&(H.preventDefault(),yt(I,"last"));},children:[lt.Children.toArray(i).filter(fp),Ua({entries:x,children:lt.Children.toArray(i).filter(H=>!fp(H)),preset:o,keyOfEntry:H=>H.id,keyOfChild:bp,renderEntry:H=>H.kind==="separator"?jsxRuntime.jsx(Ao,{}):H.render()})]})})}):null})}var Ks=Object.assign(kr,{Cut:Pr,Copy:Er,Paste:Rn,PasteWithoutFormatting:Mn,Delete:wr,SelectAll:Rr,InsertRowAbove:kn,InsertRowBelow:Dn,InsertColumnLeft:In,InsertColumnRight:_n,DeleteTableRow:Nn,DeleteTableColumn:Ln,DeleteTable:Fn,CellVerticalAlignment:Oo,RefreshToc:An,RefreshTocPageNumbers:Hn,Item:ri,Slot:zt,Row:De,Group:Cr,Separator:Ao,Submenu:kt});var hp=lt.createContext(void 0),vp=hp.Provider,$t=()=>lt.useContext(hp);function yp(){let e=$t(),{t}=L();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e?.hyperlink&&Le(e.hyperlink,{}),e?.contentControl&&Le(e.contentControl,{}),e?.equation&&Le(e.equation,{}),e?.contextMenu&&Le(e.contextMenu,{t:o=>t(o)})]})}function xp(e,t,o,n){return {...e,hyperlink:e?.hyperlink??(t===false?false:r=>jsxRuntime.jsx(ur,{...r})),contentControl:e?.contentControl??(r=>jsxRuntime.jsx(fr,{...r})),equation:e?.equation??(()=>jsxRuntime.jsx(gr,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:r=>e.contextMenu&&Le(e.contextMenu,{...r,t:n??r.t}):o===false?false:r=>jsxRuntime.jsx(kr,{...r,t:n??r.t,...typeof o=="object"?o:{}})}}function vy(e,t){return e===t?true:!e||!t||e.kind!==t.kind?false:e.kind==="note"&&t.kind==="note"?e.id===t.id:e.kind==="headerFooter"&&t.kind==="headerFooter"?e.rId===t.rId:true}function zs(){let e=F(),t=lt.useCallback(n=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),o=O(t,vy);return o?.kind==="note"?o:null}function Tp(e,t){return e===t?true:!e||!t?false:e.pos===t.pos&&e.numFmt===t.numFmt&&e.numStart===t.numStart&&e.numRestart===t.numRestart}function Cp(e,t){return e.resolved.pos===t.resolved.pos&&e.resolved.numFmt===t.resolved.numFmt&&e.resolved.numStart===t.resolved.numStart&&e.resolved.numRestart===t.resolved.numRestart&&Tp(e.documentAuthored,t.documentAuthored)&&Tp(e.sectionAuthored,t.sectionAuthored)}function yy(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&Cp(e.footnote,t.footnote)&&Cp(e.endnote,t.endnote)}function Vs(){let e=F(),t=lt.useCallback(o=>e?.getNotePropertiesState()??null,[e]);return O(t,yy)}function Dr(e,t){let[o,n]=lt.useState(null),r=lt.useCallback(l=>n(l),[]),[i,a]=lt.useState({visibility:"hidden"});return lt.useLayoutEffect(()=>{let l=o?.closest(".docx-editor__scroll-container"),s=l??o?.parentElement?.querySelector(".docx-editor__scroll-container");if(!o||!s)return;let c=0,d=null,f=new ResizeObserver(()=>g()),u=()=>{c=0;let m=e(s);if(m!==d&&(f.disconnect(),f.observe(s),f.observe(o),m&&f.observe(m),d=m),!m||!m.isConnected){a({visibility:"hidden"});return}let b=m.getBoundingClientRect(),h=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,x=t==="story-label"?6:4,v=l===s,y=t==="after"?b.bottom+6:b.top-h-x,C=v?ro(s,b.left,y):{left:b.left,top:y},T=C.left,w=C.top,S=v?s.scrollLeft+8:8;a({position:v?"absolute":"fixed",left:t==="story-label"?T:Math.max(S,T+8),top:t==="story-label"?w:Math.max(v?s.scrollTop+8:8,w),...t==="story-label"?{width:Math.max(240,Math.min(b.width,s.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(b.width-16,s.clientWidth-16))},visibility:"visible"});},g=()=>{c||(c=requestAnimationFrame(u));};f.observe(s),f.observe(o);let p=new MutationObserver(g);return p.observe(s,{subtree:true,childList:true,attributes:true,attributeFilter:["data-docx-hf-active","data-docx-note-scope"]}),s.addEventListener("scroll",g,{passive:true}),window.addEventListener("resize",g),u(),()=>{c&&cancelAnimationFrame(c),f.disconnect(),p.disconnect(),s.removeEventListener("scroll",g),window.removeEventListener("resize",g);}},[o,e,t]),{ref:r,style:i}}var Cy=/^(footnote|endnote):(-?\d{1,10})$/;function Ep(e){let t=Cy.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function Sy(){return typeof window>"u"?false:window.matchMedia("(pointer: coarse)").matches}function Ws(e){let t=F();return lt.useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let o=t.can(e);return o.ok?{enabled:true,reason:null}:{enabled:false,reason:o.reason}},[t,e])}function Py(e){let{t}=L(),[o,n]=lt.useState(false),r=lt.useRef(null);return lt.useEffect(()=>{if(!o)return;let i=a=>{r.current?.contains(a.target)||n(false);};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[o]),jsxRuntime.jsxs("div",{ref:r,className:"docx-hf-chrome__options",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-context-bar__options-trigger","data-testid":"docx-notes-options","aria-expanded":o,"aria-haspopup":"menu",onMouseDown:Z,onClick:()=>n(i=>!i),children:t("headerFooter.options")}),o?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:Z,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-properties",onClick:()=>{e.onOpenProperties(),n(false);},children:t("dialogs.footnoteProperties.title")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-close",onClick:()=>{e.onClose(),n(false);},children:t("common.close")})]}):null]})}function di({className:e}){let t=$t(),o=lt.useRef(null),{t:n}=L(),r=F(),i=zs(),[a,l]=lt.useState(null),[s,c]=lt.useState(null),[d,f]=lt.useState(false),u=lt.useRef(null),g=lt.useCallback(_=>{if(!i)return null;let N=[..._.querySelectorAll("[data-docx-note-scope]")].find(I=>I.matches("[data-docx-note]")&&I.dataset.docxNoteScope===i.id)??null;return N?.closest("[data-docx-notes]")??N},[i]),p=Dr(g,"story-label"),m=lt.useCallback(()=>{u.current&&clearTimeout(u.current),u.current=null,l(null);},[]);lt.useEffect(()=>{if(!r)return;let _=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!_)return;let H=P=>{let k=P.target;if(!k)return;let Y=k.closest("[data-docx-note-ref]");if(Y?.dataset.docxNoteScope){P.preventDefault(),m(),c(null),r.setActiveScope({kind:"note",id:Y.dataset.docxNoteScope});return}k.closest("[data-docx-note-mark-back]")&&(P.preventDefault(),m(),c(null),r.setActiveScope({kind:"body"}));},N=P=>{let k=P,z=k.target?.closest("[data-docx-note-scope]");z?.dataset.docxNoteScope&&(k.preventDefault(),c({scopeId:z.dataset.docxNoteScope,x:k.clientX,y:k.clientY}));},I=P=>{if(Sy())return;let Y=P.target?.closest("[data-docx-note-ref]");if(!Y?.dataset.docxNoteScope){m();return}let z=Y.dataset.docxNoteScope,V=r.getNotePreviewText(z)??Y.getAttribute("aria-description")??n("notes.previewFallback"),te=Y.getBoundingClientRect();u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l({scopeId:z,text:V,x:te.left,y:te.bottom+4});},400);};return _.addEventListener("click",H),_.addEventListener("contextmenu",N),_.addEventListener("pointerover",I),_.addEventListener("scroll",m,true),()=>{_.removeEventListener("click",H),_.removeEventListener("contextmenu",N),_.removeEventListener("pointerover",I),_.removeEventListener("scroll",m,true),m();}},[r,m,n]);let b=lt.useCallback(_=>{r&&(r.exec(_),c(null));},[r]),h=s?Ep(s.scopeId):null,x=lt.useMemo(()=>h?{type:"deleteNote",noteKind:h.noteKind,noteId:h.noteId}:null,[h]),v=lt.useMemo(()=>h?{type:"convertNote",fromKind:h.noteKind,noteId:h.noteId}:null,[h]),y=lt.useMemo(()=>h?{type:"convertAllNotes",fromKind:h.noteKind}:null,[h]),C=Ws(x??{type:"deleteNote",noteKind:"footnote",noteId:0}),T=Ws(v??{type:"convertNote",fromKind:"footnote",noteId:0}),w=Ws(y??{type:"convertAllNotes",fromKind:"footnote"}),S=i?Ep(i.id):null,M=S?n("notes.editingRegion",{kind:S.noteKind==="footnote"?n("notes.footnoteKind"):n("notes.endnoteKind"),number:S.noteId}):null,R=s&&h?{...s,...h,onDelete:()=>{x&&b(x);},onConvert:()=>{v&&b(v);},onConvertAll:()=>{y&&b(y);},onOpenProperties:()=>f(true),onClose:()=>c(null),deleteEnabled:C.enabled,convertEnabled:T.enabled,convertAllEnabled:w.enabled,deleteDisabledReason:C.reason??void 0,convertDisabledReason:T.reason??void 0,convertAllDisabledReason:w.reason??void 0}:null,D={onClose:()=>f(false),onApply:_=>{b(_),f(false);}};return r?jsxRuntime.jsxs("div",{className:e,ref:o,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":i?void 0:true,children:[i&&S?jsxRuntime.jsxs("div",{ref:p.ref,className:"docx-context-bar docx-notes-chrome__banner",role:"region","aria-label":n("notes.chromeAriaLabel"),"data-testid":"docx-notes-banner","data-note-scope":i.id,style:{...p.style,zIndex:Qe.chrome},children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:M}),jsxRuntime.jsx(Py,{onOpenProperties:()=>f(true),onClose:()=>r.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Le(t.notePreview,a):jsxRuntime.jsx(yn,{...a}):null,R&&t?.notesContextMenu!==false?t?.notesContextMenu?Le(t.notesContextMenu,R):jsxRuntime.jsx(xn,{...R}):null,d&&t?.noteProperties!==false?t?.noteProperties?Le(t.noteProperties,D):jsxRuntime.jsx(ui,{...D}):null]}):null}function ui(e){let{t}=L(),o=F(),n=Vs(),[r,i]=lt.useState("document"),[a,l]=lt.useState("decimal"),[s,c]=lt.useState("continuous"),[d,f]=lt.useState("pageBottom"),[u,g]=lt.useState("decimal"),[p,m]=lt.useState("continuous"),[b,h]=lt.useState("docEnd");lt.useEffect(()=>{n&&(l(n.footnote.resolved.numFmt),c(n.footnote.resolved.numRestart),f(n.footnote.resolved.pos),g(n.endnote.resolved.numFmt),m(n.endnote.resolved.numRestart),h(n.endnote.resolved.pos));},[n]);let x=!n?.footnote.documentAuthored&&!n?.footnote.sectionAuthored,v=!n?.endnote.documentAuthored&&!n?.endnote.sectionAuthored;return jsxRuntime.jsx("div",{className:"docx-note-properties",role:"dialog","aria-modal":"true","aria-label":t("dialogs.footnoteProperties.title"),"data-testid":"docx-notes-properties-dialog",style:{zIndex:Qe.modal},onClick:e.onClose,onKeyDown:y=>{y.key==="Escape"&&e.onClose();},children:jsxRuntime.jsxs("div",{className:"docx-note-properties__panel",onClick:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),children:[jsxRuntime.jsx("h2",{className:"docx-note-properties__title",children:t("dialogs.footnoteProperties.title")}),jsxRuntime.jsxs("div",{className:"docx-note-properties__body",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__scope",children:[jsxRuntime.jsx("span",{children:t("notes.scope")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:r,onChange:y=>i(y.target.value),children:[jsxRuntime.jsx("option",{value:"document",children:t("notes.scopeDocument")}),jsxRuntime.jsx("option",{value:"section",children:t("notes.scopeSection")})]})]}),jsxRuntime.jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxRuntime.jsxs("legend",{className:"docx-note-properties__legend",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.footnotes")}),x?jsxRuntime.jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__fields",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:a,onChange:y=>l(y.target.value),children:[jsxRuntime.jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsxRuntime.jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsxRuntime.jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:s,onChange:y=>c(y.target.value),children:[jsxRuntime.jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsxRuntime.jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsxRuntime.jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:d,onChange:y=>f(y.target.value),children:[jsxRuntime.jsx("option",{value:"pageBottom",children:t("dialogs.footnoteProperties.footnotePositions.bottomOfPage")}),jsxRuntime.jsx("option",{value:"beneathText",children:t("dialogs.footnoteProperties.footnotePositions.belowText")})]})]})]})]}),jsxRuntime.jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxRuntime.jsxs("legend",{className:"docx-note-properties__legend",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.endnotes")}),v?jsxRuntime.jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__fields",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:u,onChange:y=>g(y.target.value),children:[jsxRuntime.jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsxRuntime.jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsxRuntime.jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:p,onChange:y=>m(y.target.value),children:[jsxRuntime.jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsxRuntime.jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsxRuntime.jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:b,"data-testid":"docx-notes-endnote-position",onChange:y=>h(y.target.value),children:[jsxRuntime.jsx("option",{value:"docEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfDocument")}),jsxRuntime.jsx("option",{value:"sectEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfSection")})]})]})]})]})]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__footer",children:[jsxRuntime.jsx("button",{className:"docx-note-properties__button",type:"button",onClick:e.onClose,children:t("common.cancel")}),jsxRuntime.jsx("button",{className:"docx-note-properties__button docx-note-properties__button--primary",type:"button","data-testid":"docx-notes-properties-apply",onClick:()=>{if(!o)return;let y={type:"setNoteProperties",scope:r,sectionIndex:r==="section"?n?.sectionIndex:void 0,footnote:{numFmt:a,numRestart:s,position:d},endnote:{numFmt:u,numRestart:p,position:b}};o.can(y).ok&&e.onApply(y);},children:t("common.apply")})]})]})})}var Mp=e=>e.image;function Rp(e){return Array.from(e.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(t=>t.offsetParent!==null||t===document.activeElement)}function Iy(e){e&&!e.closest(".docx-editor")&&e.classList.add("docx-editor");}function _y(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Qs(e){let t=e.position;return !t||e.kind!=="anchored"?{positionMode:"frame",horizontalPoints:"",verticalPoints:"",relativeToH:"page",relativeToV:"line"}:t.mode==="simple"?{positionMode:"simple",horizontalPoints:t.horizontalEmu!==void 0?String(ao(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(ao(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(ao(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(ao(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function Ny(e,t){let o=Qs(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function pi(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=vr(t);return Number.isInteger(o)?o:null}function Ly(e,t){let o=Qs(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,f=c?pi(e.horizontalPoints):t.position?.horizontalEmu,u=d?pi(e.verticalPoints):t.position?.verticalEmu;return c&&f===null?{ok:false}:d&&u===null?{ok:false}:f===void 0||u===void 0?{ok:false}:{ok:true,value:{horizontalEmu:f,verticalEmu:u}}}let n=e.horizontalPoints!==o.horizontalPoints,r=e.verticalPoints!==o.verticalPoints,i=e.relativeToH!==o.relativeToH,a=e.relativeToV!==o.relativeToV,l=n?pi(e.horizontalPoints):t.position?.horizontalEmu,s=r?pi(e.verticalPoints):t.position?.verticalEmu;return n&&l===null?{ok:false}:r&&s===null?{ok:false}:{ok:true,value:{...typeof l=="number"?{horizontalEmu:l}:{},...typeof s=="number"?{verticalEmu:s}:{},...i||n||r?{relativeToH:e.relativeToH}:{},...a||n||r?{relativeToV:e.relativeToV}:{}}}}function mi(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function fi(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function _r({open:e,onClose:t,className:o,triggerRef:n}){let r=F(),{t:i}=L(),a=O(Mp),l=lt.useId(),s=lt.useId(),c=lt.useId(),d=lt.useRef(null),f=lt.useRef(null),u=lt.useRef(null),g=lt.useRef(null),[p,m]=lt.useState(null),[b,h]=lt.useState(null),x=f.current,v=x?.canCrop===false,y=x?.canResize===false,C=x?.locks.changeAspect===true,T=x?.kind==="anchored"&&x.canMove===true,w=x?.kind==="inline",S=x?.kind==="anchored"&&x.canMove===false;lt.useEffect(()=>{if(!e){f.current=null,u.current=null,g.current=null;return}if(!a)return;if(f.current=a,r?.surface){let{anchor:Y}=r.surface.state().selection;u.current={paragraphId:Y.paragraphId,offset:Y.offset},g.current=r.surface.session.packageRevision();}h(null);let P=Qs(a),k=a.crop;m({widthPoints:String(ao(a.widthEmu)),heightPoints:String(ao(a.heightEmu)),cropLeft:String(k.left),cropTop:String(k.top),cropRight:String(k.right),cropBottom:String(k.bottom),title:a.title,description:a.description,hyperlink:a.hyperlink??"",wrap:a.wrap,lockAspect:a.locks.changeAspect,...P});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let M=lt.useCallback(()=>{n?.current?.focus(),r?.focus();},[r,n]),R=lt.useCallback(()=>{t(),M();},[t,M]);lt.useEffect(()=>{if(!e)return;let P=d.current;if(!P)return;let k=Rp(P);(k.find(re=>re.id==="image-prop-width"&&!re.hasAttribute("disabled"))??k.find(re=>!re.hasAttribute("disabled"))??P).focus();let z=re=>{if(re.key==="Escape"){re.preventDefault(),R();return}if(re.key!=="Tab")return;let V=Rp(P);if(V.length===0)return;let te=document.activeElement,B=V.findIndex(de=>de===te);if(B===-1)return;re.preventDefault();let J=re.shiftKey?(B-1+V.length)%V.length:(B+1)%V.length;V[J]?.focus();};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[e,R]);let D=lt.useMemo(()=>{let P=x??a;return !P||P.widthEmu<=0?1:P.widthEmu/P.heightEmu},[a,x]),_=lt.useCallback(P=>{m(k=>{if(!k)return k;if(!k.lockAspect)return {...k,widthPoints:P};let Y=fi(P);if(Y===null)return {...k,widthPoints:P};let z=Math.round(Y/D*100)/100;return {...k,widthPoints:P,heightPoints:String(z)}});},[D]),H=lt.useCallback(P=>{m(k=>{if(!k)return k;if(!k.lockAspect)return {...k,heightPoints:P};let Y=fi(P);if(Y===null)return {...k,heightPoints:P};let z=Math.round(Y*D*100)/100;return {...k,widthPoints:String(z),heightPoints:P}});},[D]),N=lt.useCallback(()=>{let P=f.current;if(!P?.intrinsic)return;let k=P.intrinsic.pixelWidth*72/P.intrinsic.dpiX,Y=P.intrinsic.pixelHeight*72/P.intrinsic.dpiY;m(z=>z&&{...z,widthPoints:String(Math.round(k*100)/100),heightPoints:String(Math.round(Y*100)/100)});},[a]),I=lt.useCallback(()=>{let P=f.current,k=u.current,Y=g.current;if(!r||!P||!p||!k||Y===null)return;let z={type:"setImageProperties",drawingNodeId:P.id,expectedPackageRevision:Y,selectionParagraphId:k.paragraphId,selectionOffset:k.offset};if(!y){let de=fi(p.widthPoints),U=fi(p.heightPoints);if(de===null||U===null){h("imageProperties.errors.invalidDimensions");return}let q=vr(de),Me=vr(U);q!==P.widthEmu&&(z.widthEmu=q),Me!==P.heightEmu&&(z.heightEmu=Me);}if(P.canCrop&&!v){let de=mi(p.cropLeft),U=mi(p.cropTop),q=mi(p.cropRight),Me=mi(p.cropBottom);if(de===null||U===null||q===null||Me===null){h("imageProperties.errors.invalidCrop");return}let We=P.crop;(de!==We.left||U!==We.top||q!==We.right||Me!==We.bottom)&&(z.crop={left:de,top:U,right:q,bottom:Me});}p.title!==P.title&&(z.title=p.title),p.description!==P.description&&(z.description=p.description);let re=p.hyperlink.trim();if(re!==(P.hyperlink??"")&&(z.hyperlink=re===""?null:re),P.canChangeWrap&&p.wrap!==P.wrap&&(z.wrap=p.wrap),P.kind==="anchored"&&P.canMove&&Ny(p,P)){let de=Ly(p,P);if(!de.ok){h("imageProperties.errors.invalidPosition");return}if(!editor.validateDrawingPositionInput(editor.positionInputFromPropertiesCommand(de.value,P))){h("imageProperties.errors.invalidPosition");return}Object.assign(z,de.value);}if(!(z.widthEmu!==void 0||z.heightEmu!==void 0||z.title!==void 0||z.description!==void 0||z.hyperlink!==void 0||z.crop!==void 0||z.wrap!==void 0||z.horizontalEmu!==void 0||z.verticalEmu!==void 0||z.relativeToH!==void 0||z.relativeToV!==void 0)){R();return}if(!r.can(z).ok){h("imageProperties.errors.refused");return}if(!r.exec(z).ok){h("imageProperties.errors.refused");return}R();},[r,p,v,y,R]);return !e||!p?null:jsxRuntime.jsx("div",{ref:Iy,className:`docx-dialog-overlay${o?` ${o}`:""}`,onClick:R,onMouseDown:P=>{P.stopPropagation(),_y(P);},children:jsxRuntime.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-labelledby":l,className:"docx-dialog docx-image-properties-dialog",onClick:P=>P.stopPropagation(),onMouseDown:P=>P.stopPropagation(),children:[jsxRuntime.jsx("div",{id:l,className:"docx-dialog__header",children:i("dialogs.imageProperties.title")}),jsxRuntime.jsxs("div",{className:"docx-dialog__body",children:[b?jsxRuntime.jsx("p",{className:"docx-dialog__error",children:i(b)}):null,jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.dimensions")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-width",children:i("dialogs.imageProperties.widthLabel")}),jsxRuntime.jsx("input",{id:"image-prop-width",className:"docx-dialog__input",value:p.widthPoints,disabled:y,onChange:P=>_(P.target.value)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-height",children:i("dialogs.imageProperties.heightLabel")}),jsxRuntime.jsx("input",{id:"image-prop-height",className:"docx-dialog__input",value:p.heightPoints,disabled:y,onChange:P=>H(P.target.value)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:p.lockAspect,disabled:C,onChange:P=>m(k=>k&&{...k,lockAspect:P.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:v||!x?.intrinsic,onClick:N,children:i("imageProperties.resetNaturalSize")})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.position")}),w?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionUnavailable")}):null,S?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,T?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p.positionMode==="frame"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-h",children:i("imageProperties.relativeToHorizontal")}),jsxRuntime.jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:p.relativeToH??"page",onChange:P=>m(k=>k&&{...k,relativeToH:P.target.value}),children:editor.DRAWING_REL_FROM_H.map(P=>jsxRuntime.jsx("option",{value:P,children:i(`dialogs.imagePosition.relativeOptions.${P}`)},P))})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-v",children:i("imageProperties.relativeToVertical")}),jsxRuntime.jsx("select",{id:"image-pos-rel-v",className:"docx-dialog__select",value:p.relativeToV??"line",onChange:P=>m(k=>k&&{...k,relativeToV:P.target.value}),children:editor.DRAWING_REL_FROM_V.map(P=>jsxRuntime.jsx("option",{value:P,children:i(`dialogs.imagePosition.relativeOptions.${P}`)},P))})]})]}):null,jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-h",children:i("imageProperties.horizontalOffset")}),jsxRuntime.jsx("input",{id:"image-pos-h",className:"docx-dialog__input",value:p.horizontalPoints,onChange:P=>m(k=>k&&{...k,horizontalPoints:P.target.value})}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-v",children:i("imageProperties.verticalOffset")}),jsxRuntime.jsx("input",{id:"image-pos-v",className:"docx-dialog__input",value:p.verticalPoints,onChange:P=>m(k=>k&&{...k,verticalPoints:P.target.value})}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]})]}):null]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.altText")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-title",children:i("imageAltText.title")}),jsxRuntime.jsx("input",{id:"image-prop-title",className:"docx-dialog__input",value:p.title,onChange:P=>m(k=>k&&{...k,title:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-description",children:i("imageAltText.description")}),jsxRuntime.jsx("textarea",{id:"image-prop-description",className:"docx-dialog__textarea",value:p.description,onChange:P=>m(k=>k&&{...k,description:P.target.value}),placeholder:i("dialogs.imageProperties.altTextPlaceholder")})]})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.hyperlink")}),jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:c,children:i("hyperlinkPopup.urlLabel")}),jsxRuntime.jsx("input",{id:c,className:"docx-dialog__input docx-dialog__input--full",value:p.hyperlink,onChange:P=>m(k=>k&&{...k,hyperlink:P.target.value}),placeholder:i("hyperlinkPopup.urlPlaceholder")})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.textWrapping")}),jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:s,children:i("formattingBar.imageWrap")}),jsxRuntime.jsx("select",{id:s,className:"docx-dialog__select docx-dialog__input--full",value:p.wrap,disabled:x?.canChangeWrap===false,onChange:P=>m(k=>k&&{...k,wrap:P.target.value}),children:editor.IMAGE_WRAP_TARGETS.map(P=>jsxRuntime.jsx("option",{value:P,children:i(`imageWrap.targets.${P}`)},P))})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.crop")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-left",children:i("imageProperties.cropLeft")}),jsxRuntime.jsx("input",{id:"image-crop-left",className:"docx-dialog__input",disabled:v,value:p.cropLeft,onChange:P=>m(k=>k&&{...k,cropLeft:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-top",children:i("imageProperties.cropTop")}),jsxRuntime.jsx("input",{id:"image-crop-top",className:"docx-dialog__input",disabled:v,value:p.cropTop,onChange:P=>m(k=>k&&{...k,cropTop:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-right",children:i("imageProperties.cropRight")}),jsxRuntime.jsx("input",{id:"image-crop-right",className:"docx-dialog__input",disabled:v,value:p.cropRight,onChange:P=>m(k=>k&&{...k,cropRight:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-bottom",children:i("imageProperties.cropBottom")}),jsxRuntime.jsx("input",{id:"image-crop-bottom",className:"docx-dialog__input",disabled:v,value:p.cropBottom,onChange:P=>m(k=>k&&{...k,cropBottom:P.target.value})})]}),v?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.nonPictureHint")}):null]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:R,children:i("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:I,children:i("common.apply")})]})]})})}function gi({className:e,hidden:t,asChild:o,children:n}){let r=$t(),i=F(),{t:a}=L(),l=O(Mp),[s,c]=lt.useState(false),d=lt.useRef(null),f={type:"setImageProperties",description:"probe"},u=i&&l?i.can(f):null,g=u?.ok===true,p=u&&!u.ok?u.reason:null;if(t)return null;let m=Q("image.properties"),b={type:"button",ref:d,className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!g,...g?{}:{"data-disabled":""},"aria-label":a("formattingBar.imagePropertiesShortcut"),title:p??a("formattingBar.imagePropertiesShortcut"),onMouseDown:Z,onClick:()=>c(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o?jsxRuntime.jsx(j,{...b,children:n}):jsxRuntime.jsx("button",{...b,children:n??oe(m?.paths)}),s&&r?.imageProperties!==false?r?.imageProperties?Le(r.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):jsxRuntime.jsx(_r,{open:s,onClose:()=>c(false),triggerRef:d}):null]})}gi.docxSlot="image.properties";var Bn=Object.assign(gi,{docxSlot:"image.properties"});function By(e,t){return e.value===t.value&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason}function Nr(e){let t=F(),o=lt.useRef(e);o.current=e;let n=lt.useCallback(l=>{let s=o.current,c=editor.toolbarCommandState(t,s);return {value:c.value??null,enabled:c.enabled,disabledReason:c.disabledReason}},[t,e]),r=O(n,By),i=lt.useMemo(()=>({execute:l=>editor.runToolbarCommand(t,"image.wrap",l),value:r.value??null,options:editor.IMAGE_WRAP_TARGETS,isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,r]),a=lt.useMemo(()=>({execute:l=>editor.runToolbarCommand(t,"image.altText",l),value:r.value,options:[],isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,r]);return e==="image.wrap"?i:a}function bi({className:e,hidden:t,asChild:o,children:n}){let r=$t(),i=ee(),{execute:a,value:l,isEnabled:s,disabledReason:c}=Nr("image.altText"),[d,f]=lt.useState(false),[u,g]=lt.useState(""),p=lt.useRef(null),m=lt.useRef(null),b=lt.useId();lt.useEffect(()=>{d&&g(l??"");},[d,l]),lt.useEffect(()=>{if(!d)return;let T=S=>{let M=p.current;S.target instanceof Node&&(M?.contains(S.target)||M?.ownerDocument.getElementById(b)?.contains(S.target))||f(false);},w=S=>{S.key==="Escape"&&(S.preventDefault(),f(false),m.current?.focus());};return document.addEventListener("mousedown",T,true),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",T,true),document.removeEventListener("keydown",w);}},[d,b]);let h=lt.useCallback(()=>{a(u),f(false);},[u,a]);if(t)return null;let x=Q("image.altText"),v=i(x?.labelKey??"formattingBar.altText"),y={type:"button",ref:m,className:`docx-toolbar__button docx-toolbar__alt-text-trigger${e?` ${e}`:""}`,"data-slot":"image.altText",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?b:void 0,"aria-label":v,title:c??v,onMouseDown:Z,onClick:()=>f(T=>!T)},C={id:b,value:u,onValueChange:g,onApply:h,onClose:()=>f(false),isEnabled:s,anchorRef:m};return jsxRuntime.jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsxRuntime.jsx(j,{...y,children:n}):jsxRuntime.jsx("button",{...y,children:n??v}),d&&r?.imageAltText!==false?r?.imageAltText?Le(r.imageAltText,C):jsxRuntime.jsx(hi,{...C}):null]})}bi.docxSlot="image.altText";var Lr=Object.assign(bi,{docxSlot:"image.altText"});function hi({id:e,value:t,onValueChange:o,onApply:n,onClose:r,isEnabled:i,className:a}){let{t:l}=L();return jsxRuntime.jsxs("div",{id:e,role:"dialog","aria-label":l("imageAltText.panelTitle"),className:`docx-toolbar__alt-text-panel${a?` ${a}`:""}`,onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${e}-description`,children:l("imageAltText.description")}),jsxRuntime.jsx("textarea",{id:`${e}-description`,className:"docx-dialog__textarea",value:t,onChange:s=>o(s.target.value),placeholder:l("dialogs.imageProperties.altTextPlaceholder")}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:l("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",disabled:!i,onClick:n,children:l("common.apply")})]})]})}var Lp=lt.createContext(void 0),Fp=Lp.Provider;function Zn(){let e=lt.useContext(Lp),{t}=L();return lt.useCallback((o,n)=>{let r=e?.(o,n);return r===void 0||r===o?t(o,n):r},[e,t])}var Op=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function qn(){let e=lt.createContext(null),t=new Map,o=b=>{let h=t.get(b.type);return h==="field"?`field:${b.props.name}`:h};function n(b,h){lt.Children.forEach(b,x=>{lt.isValidElement(x)&&(h(x),n(x.props.children,h));});}function r(){let b=lt.useContext(e);if(!b)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return b.state}function i(b,h){return lt.Children.map(b,x=>{if(!lt.isValidElement(x))return x;let v=Op(x.props);return v&&h.has(v)?h.get(v):x.props.children===void 0?x:lt.cloneElement(x,{children:i(x.props.children,h)})})}function a(b){function h(x){let v=lt.useContext(e);if(!v||x.hidden)return null;let y=b==="field"?`field:${x.name}`:b,C=v.defaults.get(y);if(!C)return x.children??null;let{children:T,asChild:w,className:S,style:M,hidden:R,name:D,..._}=x,H={..._,...C.props,className:[C.props.className,S].filter(Boolean).join(" "),style:{...C.props.style,...M}};if(w){let{children:N,className:I,style:P,...k}=H;return jsxRuntime.jsx(j,{...k,...S?{className:S}:{},...M?{style:M}:{},children:T})}return lt.cloneElement(C,H,T===void 0?i(C.props.children,v.overrides):T)}return t.set(h,b),h}let l=a("header"),s=a("title"),c=a("body"),d=a("footer"),f=a("apply"),u=a("cancel"),g=a("error"),p=a("field");function m({defaults:b,children:h,preset:x=true,state:v}){let y=new Map;n(b,S=>{let M=Op(S.props);M&&y.set(M,S);});let C=new Map;n(h,S=>{let M=o(S);M&&C.set(M,S);});let T=S=>lt.Children.toArray(S).flatMap(M=>lt.isValidElement(M)&&M.type===lt.Fragment?T(M.props.children):[M]),w=T(h).filter(S=>!lt.isValidElement(S)||!o(S));return jsxRuntime.jsx(e.Provider,{value:{defaults:y,overrides:C,state:v},children:x?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i(b,C),w]}):h})}return {Header:l,Title:s,Body:c,Footer:d,Apply:f,Cancel:u,Error:g,Field:p,Composition:m,useState:r}}function uo({kind:e,role:t="dialog",className:o,style:n,label:r,onClose:i,onKeyDown:a,panelRef:l,children:s,dismissOutside:c=true,sessionSignal:d,restoreFocus:f=true}){let u=lt.useRef(null),g=l??u,p=lt.useRef(i);return p.current=i,lt.useLayoutEffect(()=>{let m=g.current;if(!m)return;m.parentElement?.closest(".docx-editor")||m.classList.add("docx-editor");let b=m.ownerDocument.activeElement,h=()=>{m.open&&m.close?.();};return d?.addEventListener("abort",h),typeof m.showModal=="function"?m.showModal():m.setAttribute("open",""),m.querySelector('input:not([disabled]),select:not([disabled]),button:not([disabled]),[tabindex="0"]')?.focus({preventScroll:true}),()=>{d?.removeEventListener("abort",h),typeof m.close=="function"&&m.open&&m.close(),f&&b?.isConnected&&b.focus({preventScroll:true});}},[g,d,f]),jsxRuntime.jsx("dialog",{ref:g,role:t,"aria-modal":"true","aria-label":r,className:`docx-dialog${o?` ${o}`:""}`,style:n,"data-docx-dialog":e,onCancel:m=>{m.preventDefault(),p.current();},onMouseDown:m=>m.stopPropagation(),onClick:m=>{if(c&&m.target===m.currentTarget){let b=m.currentTarget.getBoundingClientRect();(m.clientX<b.left||m.clientX>b.right||m.clientY<b.top||m.clientY>b.bottom)&&p.current();}m.stopPropagation();},onKeyDown:m=>{m.key==="Escape"&&!m.nativeEvent.isComposing?(m.preventDefault(),p.current()):editor.trapTabWithin(m.currentTarget,m.nativeEvent)?m.preventDefault():!m.nativeEvent.isComposing&&!m.defaultPrevented&&a?.(m),m.stopPropagation();},children:s})}function yi(e,t){let o=F(),n=nc(),r=lt.useRef(null);return lt.useEffect(()=>{if(!e){r.current=null;return}o?.surface&&(r.current===null?r.current=o.mountGeneration:r.current!==o.mountGeneration&&t());},[e,o,n,t]),()=>!!o?.surface&&r.current===o.mountGeneration}function nc(){let e=F(),t=lt.useCallback(o=>{if(!e)return ()=>{};let n=true,r=lr(()=>{n&&o();}),i=[e.on("change",r),e.on("selectionChange",r),e.on("error",r)];return ()=>{n=false,i.forEach(a=>a());}},[e]);return lt.useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function ac(e){let[t,o]=lt.useState(e.session),[n,r]=lt.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(ox,{...e},n)}function ox({session:e,className:t,style:o,children:n}){let r=Zn(),[i,a]=lt.useState(e.signal.aborted),l=lt.useRef(null);return lt.useEffect(()=>{let s=()=>a(true);return e.signal.addEventListener("abort",s,{once:true}),e.signal.aborted&&s(),()=>e.signal.removeEventListener("abort",s)},[e]),i?null:jsxRuntime.jsx(uo,{kind:"invalidTextFormField",role:"alertdialog",label:r("textFormField.invalidTitle"),className:t,style:o,panelRef:l,dismissOutside:false,onClose:e.acknowledge,sessionSignal:e.signal,restoreFocus:false,onKeyDown:s=>{s.key==="Enter"&&!s.nativeEvent.isComposing&&(s.preventDefault(),e.acknowledge());},children:n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:r("textFormField.invalidTitle")})}),jsxRuntime.jsx("div",{className:"docx-dialog__body",children:r(e.type==="number"?"textFormField.invalidNumber":"textFormField.invalidDate")}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:e.acknowledge,children:r("textFormField.apply")})})]})})}function lc(e){let[t,o]=lt.useState(e.session),[n,r]=lt.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(lx,{...e},n)}function lx({session:e,className:t,style:o,children:n}){let r=Zn(),[i,a]=lt.useState(e.kind==="date"?e.value.slice(0,10):e.value),[l,s]=lt.useState(e.signal.aborted),[c,d]=lt.useState(false),f=lt.useRef(null),[u,g]=lt.useState({}),p=O(()=>e.canApply());if(lt.useEffect(()=>{let h=()=>s(true);return e.signal.addEventListener("abort",h,{once:true}),e.signal.aborted&&h(),()=>e.signal.removeEventListener("abort",h)},[e]),lt.useLayoutEffect(()=>{if(l)return;let h=f.current,x=h?.ownerDocument,v=x?.activeElement,y=h?.closest(".docx-editor__scroll-container"),C=e.anchor;if(C&&y){let T=C.getBoundingClientRect();g(ro(y,T.left,T.bottom));}return h?.querySelector("input,select,button")?.focus({preventScroll:true}),()=>{let T=x?.activeElement;v?.isConnected&&(T===x?.body||T&&h?.contains(T))&&v.focus({preventScroll:true});}},[e,l]),lt.useEffect(()=>{let h=f.current;if(!h||l)return;let x=v=>{h.contains(v.target)||e.cancel();};return h.ownerDocument.addEventListener("pointerdown",x,true),()=>h.ownerDocument.removeEventListener("pointerdown",x,true)},[e,l]),l)return null;let m=()=>d(!e.apply(i)),b=r(`contentControl.types.${e.kind}`);return jsxRuntime.jsx("div",{ref:f,role:"dialog","aria-label":b,className:`docx-content-control-widget-popup${t?` ${t}`:""}`,style:{...u,...o},"data-docx-popup":"contentControlWidget",onPointerDown:h=>h.stopPropagation(),onKeyDown:h=>{h.nativeEvent.isComposing||(h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),e.cancel()),h.key==="Enter"&&h.target instanceof HTMLInputElement&&(h.preventDefault(),m()));},children:n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.kind==="dropdown"?jsxRuntime.jsxs("select",{"aria-label":b,value:i,onChange:h=>a(h.target.value),children:[e.items.some(h=>h.value===i)?null:jsxRuntime.jsx("option",{value:i,disabled:true,children:i}),e.items.map((h,x)=>jsxRuntime.jsx("option",{value:h.value,children:h.displayText},x))]}):jsxRuntime.jsx("input",{type:e.kind==="date"?"date":"text","aria-label":b,value:i,onChange:h=>a(h.target.value)}),e.kind==="comboBox"?e.items.map((h,x)=>jsxRuntime.jsx("button",{type:"button",disabled:!p,onClick:()=>d(!e.apply(h.value)),children:h.displayText},x)):null,c?jsxRuntime.jsx("div",{role:"alert",children:r("disabledReason.invalidValue")}):null,jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:e.cancel,children:r("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",disabled:!p,onClick:m,children:r("common.apply")})]})]})})}var Dt=qn();function dx(){return Dt.useState()}function ux({session:e,...t}){let[o,n]=lt.useState(e),[r,i]=lt.useState(0);return o!==e&&(n(e),i(r+1)),e?jsxRuntime.jsx(px,{session:e,...t},r):null}function px({session:e,children:t,preset:o,className:n,style:r}){let i=Zn(),a=O(()=>e.canApply()),[l,s]=lt.useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=lt.useState(e.signal.aborted),[f,u]=lt.useState(false);lt.useEffect(()=>{let x=()=>d(true);return e.signal.addEventListener("abort",x),e.signal.aborted&&x(),()=>e.signal.removeEventListener("abort",x)},[e]);let g=()=>{if(e.signal.aborted)return;let x=Number.isInteger(l.maxLength)&&l.maxLength>=0&&l.maxLength<=32767&&e.apply(l.defaultText,{type:l.type,maxLength:l.maxLength,format:l.format,enabled:l.enabled});u(!x);},p={values:l,setValue(x,v){s(y=>({...y,[x]:v,...x==="type"?{format:""}:{}})),u(false);},errors:f?{form:i("textFormField.invalidOptions")}:{},isEnabled:!c&&a,apply:g,cancel:e.cancel};if(c)return null;let m=editor.TEXT_FORM_FORMATS[l.type]??[],b={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},h=(x,v)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":x,className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${x}`)}),v]});return jsxRuntime.jsx(uo,{kind:"textFormField",className:n,style:r,label:i("textFormField.title"),onClose:e.cancel,dismissOutside:false,sessionSignal:e.signal,restoreFocus:false,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),e.cancel()),x.key==="Enter"&&x.target instanceof HTMLInputElement&&(x.preventDefault(),g());},children:jsxRuntime.jsx(Dt.Composition,{state:p,preset:o,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:i("textFormField.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[h("defaultText",jsxRuntime.jsx("input",{className:"docx-dialog__input",value:l.defaultText,onChange:x=>p.setValue("defaultText",x.target.value)})),h("type",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:x=>p.setValue("type",x.target.value),children:[["regular","number","date"].map(x=>jsxRuntime.jsx("option",{value:x,children:i(`textFormField.${x}`)},x)),Object.hasOwn(editor.TEXT_FORM_FORMATS,l.type)?null:jsxRuntime.jsx("option",{value:l.type,disabled:true,children:i("textFormField.preservedType")})]})),h("maxLength",jsxRuntime.jsx("input",{className:"docx-dialog__input",type:"number",min:0,max:32767,step:1,value:Number.isNaN(l.maxLength)?"":l.maxLength,onChange:x=>p.setValue("maxLength",x.target.valueAsNumber)})),h("format",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:x=>p.setValue("format",x.target.value),children:[m.map(x=>jsxRuntime.jsx("option",{value:x,children:b[x]?i(b[x]):x||i("textFormField.noFormat")},x)),m.includes(l.format)?null:jsxRuntime.jsx("option",{value:l.format,disabled:true,children:l.format||i("textFormField.noFormat")})]})),jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"enabled",className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:l.enabled,onChange:x=>p.setValue("enabled",x.target.checked)}),i("textFormField.enabled")]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",className:"docx-dialog__error",role:"alert",children:p.errors.form}),jsxRuntime.jsx("button",{"data-docx-part":"cancel",className:"docx-dialog__button",type:"button",onClick:e.cancel,children:i("textFormField.cancel")}),jsxRuntime.jsx("button",{disabled:!a,"data-docx-part":"apply",className:"docx-dialog__button docx-dialog__apply",type:"button",onClick:g,children:i("textFormField.apply")})]})]}),children:t})})}var Ar=Object.assign(ux,{Header:Dt.Header,Title:Dt.Title,Body:Dt.Body,Footer:Dt.Footer,Apply:Dt.Apply,Cancel:Dt.Cancel,Error:Dt.Error,Field:Dt.Field});var qp="(prefers-color-scheme: dark)";function Kp(){return typeof window<"u"&&typeof window.matchMedia=="function"}function zp(){return Kp()?window.matchMedia(qp).matches:false}function Vp(e,t){return e==="dark"||e==="system"&&t}function $p(e){if(!Kp())return ()=>{};let t=window.matchMedia(qp);e(t.matches);let o=n=>e(n.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}function Up(){let e=F(),t=$t(),o=lt.useRef(t);o.current=t;let[n,r]=lt.useState(null),[i,a]=lt.useState(null),l=t?.contentControlWidget!==void 0,s=t?.invalidTextFormField!==void 0;return lt.useEffect(()=>{if(!e||!l)return;let c=true,d=e.setContentControlWidgetChrome({onRequest(f){if(o.current?.contentControlWidget===false)return f.cancel();r(f),f.signal.addEventListener("abort",()=>{c&&r(u=>u===f?null:u);},{once:true});}},{fallback:true});return ()=>{c=false,d(),r(null);}},[e,l]),lt.useEffect(()=>{if(!e||!s)return;let c=true,d=e.setInvalidTextFormFieldChrome({onRequest(f){if(o.current?.invalidTextFormField===false)return f.cancel();a(f),f.signal.addEventListener("abort",()=>{c&&a(u=>u===f?null:u);},{once:true});}},{fallback:true});return ()=>{c=false,d(),a(null);}},[e,s]),lt.useEffect(()=>{t?.contentControlWidget===false&&n?.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,n,i]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&t?.contentControlWidget&&Le(t.contentControlWidget,{session:n},n),i&&t?.invalidTextFormField&&Le(t.invalidTextFormField,{session:i},i)]})}var vx=e=>e.pageSetup??null,yx=e=>e.editable;function zo(){let e=F(),t=O(vx),o=O(yx),n=lt.useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),r=lt.useCallback(i=>e?e.exec({...i.pageWidthTwips!==void 0?{pageWidth:i.pageWidthTwips}:{},...i.pageHeightTwips!==void 0?{pageHeight:i.pageHeightTwips}:{},...i.orientation!==void 0?{orientation:i.orientation}:{},...i.marginTopTwips!==void 0?{marginTop:i.marginTopTwips}:{},...i.marginRightTwips!==void 0?{marginRight:i.marginRightTwips}:{},...i.marginBottomTwips!==void 0?{marginBottom:i.marginBottomTwips}:{},...i.marginLeftTwips!==void 0?{marginLeft:i.marginLeftTwips}:{},...i.scope!==void 0?{scope:i.scope}:{},type:"setPageSetup"}).ok:false,[e]);return lt.useMemo(()=>({pageSetup:t,isEnabled:n,apply:r}),[t,n,r])}var dc=[{labelKey:"dialogs.pageSetup.pageSizes.letter",width:12240,height:15840},{labelKey:"dialogs.pageSetup.pageSizes.a4",width:11906,height:16838},{labelKey:"dialogs.pageSetup.pageSizes.legal",width:12240,height:20160},{labelKey:"dialogs.pageSetup.pageSizes.a3",width:16838,height:23811},{labelKey:"dialogs.pageSetup.pageSizes.a5",width:8391,height:11906},{labelKey:"dialogs.pageSetup.pageSizes.b5",width:9979,height:14175},{labelKey:"dialogs.pageSetup.pageSizes.executive",width:10440,height:15120}],Qp=1440,Tx=e=>Math.round(e/Qp*100)/100,Cx=e=>Math.round(e*Qp);function Sx(e,t){let o=Math.min(e,t),n=Math.max(e,t);return dc.findIndex(r=>Math.abs(r.width-o)<20&&Math.abs(r.height-n)<20)}var Yp=12240,Xp=15840,po=1440;function Px({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=L(),l=yi(e,t),{pageSetup:s,isEnabled:c,apply:d}=zo(),[f,u]=lt.useState(Yp),[g,p]=lt.useState(Xp),[m,b]=lt.useState("portrait"),[h,x]=lt.useState(po),[v,y]=lt.useState(po),[C,T]=lt.useState(po),[w,S]=lt.useState(po),[M,R]=lt.useState(false),[D,_]=lt.useState("document"),H=lt.useRef(null),N=lt.useRef("no");lt.useEffect(()=>{if(!e){N.current="no";return}if(N.current==="yes"&&s===null){N.current="no";return}N.current==="yes"||N.current==="loading"&&s===null||(R(false),u(s?.pageWidthTwips??Yp),p(s?.pageHeightTwips??Xp),b(s?.orientation??"portrait"),x(s?.marginsTwips.top??po),y(s?.marginsTwips.bottom??po),T(s?.marginsTwips.left??po),S(s?.marginsTwips.right??po),_("document"),N.current=s===null?"loading":"yes");},[e,s]);let I=lt.useCallback(B=>{let J=dc[B];J&&(u(m==="landscape"?J.height:J.width),p(m==="landscape"?J.width:J.height));},[m]),P=lt.useCallback(B=>{B!==m&&(b(B),u(g),p(f));},[m,f,g]),k=lt.useCallback(()=>{if(!c)return;if(!l()){t();return}let B=d({pageWidthTwips:f,pageHeightTwips:g,orientation:m,marginTopTwips:h,marginRightTwips:w,marginBottomTwips:v,marginLeftTwips:C,scope:D});R(!B),B&&t();},[c,l,d,f,g,m,h,w,v,C,D,t]);if(!e)return null;let Y=Sx(f,g),z=(B,J,de)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":`margin${B[0].toUpperCase()}${B.slice(1)}`,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a(`dialogs.pageSetup.${B}`)}),jsxRuntime.jsx("input",{type:"number",className:"docx-dialog__input",min:0,max:22,step:.1,value:Tx(J),onChange:U=>de(Math.max(0,Cx(Number(U.target.value)||0))),"aria-label":a(`dialogs.pageSetup.${B}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:"in"})]}),re={pageWidth:f,pageHeight:g,orientation:m,marginTop:h,marginBottom:v,marginLeft:C,marginRight:w,scope:D},V={pageWidth:u,pageHeight:p,orientation:P,marginTop:x,marginBottom:y,marginLeft:T,marginRight:S,scope:_},te={values:re,setValue(B,J){V[B](J);},errors:M?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:k,cancel:t};return jsxRuntime.jsx(uo,{kind:"pageSetup",className:o,style:n,panelRef:H,label:a("dialogs.pageSetup.title"),onClose:t,onKeyDown:B=>{B.key==="Escape"&&t(),B.key==="Enter"&&B.target instanceof HTMLInputElement&&c&&(B.preventDefault(),k());},children:jsxRuntime.jsx(_t.Composition,{state:te,preset:i,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.pageSetup.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.pageSetup.pageSize")}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"pageSize",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.sizeLabel")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:Y,onChange:B=>I(Number(B.target.value)),"aria-label":a("dialogs.pageSetup.sizeLabel"),children:[dc.map((B,J)=>jsxRuntime.jsx("option",{value:J,children:a(B.labelKey)},B.labelKey)),Y<0&&jsxRuntime.jsx("option",{value:-1,children:a("dialogs.pageSetup.custom")})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"orientation",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.orientation")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:m,onChange:B=>P(B.target.value),"aria-label":a("dialogs.pageSetup.orientation"),children:[jsxRuntime.jsx("option",{value:"portrait",children:a("dialogs.pageSetup.portrait")}),jsxRuntime.jsx("option",{value:"landscape",children:a("dialogs.pageSetup.landscape")})]})]}),jsxRuntime.jsx("div",{className:"docx-dialog__section-label docx-dialog__section-label--spaced",children:a("dialogs.pageSetup.margins")}),z("top",h,x),z("bottom",v,y),z("left",C,T),z("right",w,S),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"scope",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.applyTo")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:D,onChange:B=>_(B.target.value),"aria-label":a("dialogs.pageSetup.applyTo"),children:[jsxRuntime.jsx("option",{value:"document",children:a("dialogs.pageSetup.applyToDocument")}),jsxRuntime.jsx("option",{value:"section",children:a("dialogs.pageSetup.applyToSection")})]})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",role:"alert",className:"docx-dialog__error",children:M?a("dialogs.paragraph.refused"):null}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!c,"data-docx-part":"apply",onClick:k,children:a("common.apply")})]})]}),children:r})})}var _t=qn();function Ex(){return _t.useState()}var Vo=Object.assign(Px,{Header:_t.Header,Title:_t.Title,Body:_t.Body,Footer:_t.Footer,Apply:_t.Apply,Cancel:_t.Cancel,Error:_t.Error,Field:_t.Field});var kx={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},Dx=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,n=t.paragraphFlags??kx;return {alignment:t.alignment==="both"?"justify":t.alignment??null,spaceBeforePt:t.spaceBeforePt??null,spaceAfterPt:t.spaceAfterPt??null,lineSpacing:t.lineSpacing??null,indentLeftTwips:o&&!o.mixed.left?o.left:null,indentRightTwips:o&&!o.mixed.right?o.right:null,indentFirstLineTwips:o&&!o.mixed.firstLine?o.firstLine:null,contextualSpacing:n.contextualSpacing,keepNext:n.keepNext,keepLines:n.keepLines,widowControl:n.widowControl,pageBreakBefore:n.pageBreakBefore,tabStops:t.tabStops??null,indentUnknown:!o,disagrees:{alignment:t.disagrees?.alignment??false,spaceBeforePt:t.disagrees?.spaceBeforePt??false,spaceAfterPt:t.disagrees?.spaceAfterPt??false,lineSpacing:t.disagrees?.lineSpacing??false,tabStops:t.disagrees?.tabStops??false,indentLeft:o?.mixed.left??false,indentRight:o?.mixed.right??false,indentFirstLine:o?.mixed.firstLine??false}}},Ix=["alignment","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],_x=(e,t)=>Ix.every(o=>e.disagrees[o]===t.disagrees[o]),Nx=(e,t)=>e===null||t===null?e===t:e.alignment===t.alignment&&e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value&&e.indentLeftTwips===t.indentLeftTwips&&e.indentRightTwips===t.indentRightTwips&&e.indentFirstLineTwips===t.indentFirstLineTwips&&e.contextualSpacing===t.contextualSpacing&&e.keepNext===t.keepNext&&e.keepLines===t.keepLines&&e.widowControl===t.widowControl&&e.pageBreakBefore===t.pageBreakBefore&&_x(e,t)&&e.indentUnknown===t.indentUnknown&&e.tabStops?.length===t.tabStops?.length&&(e.tabStops??[]).every((o,n)=>o.positionTwips===t.tabStops?.[n]?.positionTwips&&o.alignment===t.tabStops?.[n]?.alignment&&(o.leader??"none")===(t.tabStops?.[n]?.leader??"none")),Lx=e=>e.editable;function uc(){let e=F(),t=O(Dx,Nx),o=O(Lx),n=lt.useMemo(()=>o&&e!==null&&e.can({type:"setParagraphFormat",alignment:"left"}).ok,[e,o]),r=lt.useCallback(i=>{if(!e)return false;let a={type:"setParagraphFormat",...i};return e.can(a).ok?e.exec(a).ok:false},[e]);return {format:t,isEnabled:n,apply:r}}function Hx({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=L(),l=yi(e,t),{format:s,isEnabled:c,apply:d}=uc(),[f,u]=lt.useState("left"),[g,p]=lt.useState(0),[m,b]=lt.useState(0),[h,x]=lt.useState("none"),[v,y]=lt.useState(0),[C,T]=lt.useState(0),[w,S]=lt.useState(0),[M,R]=lt.useState("multiple"),[D,_]=lt.useState(1.08),[H,N]=lt.useState(false),[I,P]=lt.useState(false),[k,Y]=lt.useState(false),[z,re]=lt.useState(true),[V,te]=lt.useState(false),[B,J]=lt.useState([]),[de,U]=lt.useState(false),[q,Me]=lt.useState(0),[We,pe]=lt.useState("left"),[Ke,Bt]=lt.useState("none"),[he,wt]=lt.useState(editor.NO_MIXED_FIELDS),[Ul,Gl]=lt.useState(false),gn=K=>a(Ul&&(K==="indentLeft"||K==="indentRight"||K==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),oo=lt.useRef(editor.NO_MIXED_FIELDS),_e=lt.useId(),[Ha,me]=lt.useState(false),ge=lt.useRef(null),Zt=lt.useRef(false),qt=lt.useRef(null);lt.useEffect(()=>{if(!e){Zt.current=false;return}if(Zt.current||s===null)return;let K=editor.seedFields(s);u(K.alignment),p(K.indentLeft),b(K.indentRight),x(K.special),y(K.specialBy),T(K.spaceBefore),S(K.spaceAfter),R(K.lineRule),_(K.lineValue),N(K.contextualSpacing),P(K.keepNext),Y(K.keepLines),re(K.widowControl),te(K.pageBreakBefore),J(K.tabStops),U(false);let fe=editor.mixedFieldsOf(s);wt(fe),Gl(s.indentUnknown),Me(0),pe("left"),Bt("none"),oo.current=fe,me(false),qt.current=K,Zt.current=true;},[e,s]);let rr=lt.useCallback(()=>{if(!c)return;if(!l()){t();return}let K=qt.current,fe=K===null?null:editor.changedFields(K,{alignment:f,indentLeft:g,indentRight:m,special:h,specialBy:v,spaceBefore:C,spaceAfter:w,lineRule:M,lineValue:D,contextualSpacing:H,keepNext:I,keepLines:k,widowControl:z,pageBreakBefore:V,tabStops:B,clearedAllTabStops:de},oo.current,he);if(fe===null){t();return}if(d(fe)){me(false),t();return}me(true);},[c,l,d,t,he,de,f,g,m,h,v,C,w,M,D,H,I,k,z,V,B]),Oa=lt.useCallback(()=>{let K=Math.round(q);return K<=0?false:(wt(fe=>({...fe,tabStops:false})),J(editor.withTabStop(B,{positionTwips:K,alignment:We,...Ke!=="none"?{leader:Ke}:{}})),Me(0),pe("left"),Bt("none"),true)},[B,q,We,Ke]);if(!e)return null;let gt=K=>wt(fe=>({...fe,[K]:false})),jl=(K,fe,no,Ge)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":Ge,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${_e}-${K}`,children:a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("input",{id:`${_e}-${K}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:he[Ge]?"":editor.twipsToInches(fe),placeholder:he[Ge]?gn(Ge):void 0,onChange:ir=>{gt(Ge),no(editor.inchesToTwips(Number(ir.target.value)||0));},"aria-label":a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),vu=(K,fe,no,Ge)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":K,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${_e}-${K}`,children:a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("input",{id:`${_e}-${K}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:he[Ge]?"":fe,placeholder:he[Ge]?gn(Ge):void 0,onChange:ir=>{gt(Ge),no(Math.max(0,Number(ir.target.value)||0));},"aria-label":a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),ar=(K,fe,no)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":K,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:fe,ref:Ge=>{Ge&&(Ge.indeterminate=he[K]);},onChange:Ge=>{wt(ir=>({...ir,[K]:false})),no(Ge.target.checked);}}),a(`dialogs.paragraph.${K}`)]}),Kb={alignment:f,indentLeft:g,indentRight:m,special:h,specialBy:v,spaceBefore:C,spaceAfter:w,lineRule:M,lineValue:D,contextualSpacing:H,keepNext:I,keepLines:k,widowControl:z,pageBreakBefore:V,tabStops:B,clearedAllTabStops:de},zb={alignment:u,indentLeft:p,indentRight:b,special:x,specialBy:y,spaceBefore:T,spaceAfter:S,lineRule:R,lineValue:_,contextualSpacing:N,keepNext:P,keepLines:Y,widowControl:re,pageBreakBefore:te,tabStops:J,clearedAllTabStops:U},Vb={values:Kb,mixed:he,setValue(K,fe){zb[K](fe),K==="lineRule"?(gt("lineSpacing"),_(fe===qt.current?.lineRule?qt.current.lineValue:fe==="multiple"?1.08:12)):K==="specialBy"?gt("special"):K in he&>(K);},errors:Ha?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:rr,cancel:t};return jsxRuntime.jsx(uo,{kind:"paragraph",className:o,style:n,panelRef:ge,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:K=>{K.key==="Escape"&&t();let fe=K.target instanceof HTMLButtonElement||K.target instanceof HTMLSelectElement;if(K.key==="Enter"&&!fe){let no=K.target;if(no instanceof HTMLElement&&no.dataset.docxTabEntry!==void 0){Oa();return}c&&rr();}},children:jsxRuntime.jsx(Nt.Composition,{state:Vb,preset:i,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.paragraph.title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxRuntime.jsxs("div",{className:"docx-dialog__columns",children:[jsxRuntime.jsxs("div",{className:"docx-dialog__column",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.general")}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"alignment",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${_e}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxRuntime.jsxs("select",{id:`${_e}-alignment`,className:"docx-dialog__input",value:he.alignment?"":f,onChange:K=>{gt("alignment"),u(K.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[he.alignment?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"left",children:a("dialogs.paragraph.alignLeft")}),jsxRuntime.jsx("option",{value:"center",children:a("dialogs.paragraph.alignCenter")}),jsxRuntime.jsx("option",{value:"right",children:a("dialogs.paragraph.alignRight")}),jsxRuntime.jsx("option",{value:"justify",children:a("dialogs.paragraph.alignJustify")})]})]}),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.indentation")}),jl("beforeText",g,p,"indentLeft"),jl("afterText",m,b,"indentRight"),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"special",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${_e}-special`,children:a("dialogs.paragraph.special")}),jsxRuntime.jsxs("select",{id:`${_e}-special`,className:"docx-dialog__input",value:he.special?"":h,onChange:K=>{gt("special"),x(K.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[he.special?jsxRuntime.jsx("option",{value:"",children:gn("special")}):null,jsxRuntime.jsx("option",{value:"none",children:a("dialogs.paragraph.specialNone")}),jsxRuntime.jsx("option",{value:"firstLine",children:a("dialogs.paragraph.specialFirstLine")}),jsxRuntime.jsx("option",{value:"hanging",children:a("dialogs.paragraph.specialHanging")})]})]}),h!=="none"?jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"specialBy",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${_e}-by`,children:a("dialogs.paragraph.by")}),jsxRuntime.jsx("input",{id:`${_e}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:he.special?"":editor.twipsToInches(v),placeholder:he.special?gn("special"):void 0,onChange:K=>{gt("special"),y(Math.max(0,editor.inchesToTwips(Number(K.target.value)||0)));},"aria-label":a("dialogs.paragraph.by")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}):null,jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"tabStops",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.tabStops")}),B.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__note",children:a(he.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):B.map(K=>jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label docx-dialog__tab-position",children:a("dialogs.paragraph.tabPositionLabel",{position:editor.formatInches(K.positionTwips)})}),jsxRuntime.jsx("span",{className:"docx-dialog__tab-description",children:a(editor.TAB_ALIGNMENT_LABELS[K.alignment])}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>J(B.filter(fe=>fe!==K)),"aria-label":a("dialogs.paragraph.tabRemoveAt",{position:editor.formatInches(K.positionTwips)}),children:a("dialogs.paragraph.tabRemove")})]},K.positionTwips)),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${_e}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsxRuntime.jsx("input",{id:`${_e}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:editor.twipsToInches(q),onChange:K=>Me(Math.max(0,editor.inchesToTwips(Number(K.target.value)||0))),"aria-label":a("dialogs.paragraph.tabPosition"),"data-docx-tab-entry":""}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${_e}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxRuntime.jsxs("select",{id:`${_e}-tabAlignment`,className:"docx-dialog__input",value:We,onChange:K=>pe(K.target.value),"aria-label":a("dialogs.paragraph.tabAlignment"),"data-docx-tab-entry":"",children:[jsxRuntime.jsx("option",{value:"left",children:a("dialogs.paragraph.tabAlignLeft")}),jsxRuntime.jsx("option",{value:"center",children:a("dialogs.paragraph.tabAlignCenter")}),jsxRuntime.jsx("option",{value:"right",children:a("dialogs.paragraph.tabAlignRight")}),jsxRuntime.jsx("option",{value:"decimal",children:a("dialogs.paragraph.tabAlignDecimal")})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${_e}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxRuntime.jsxs("select",{id:`${_e}-tabLeader`,className:"docx-dialog__input",value:Ke,onChange:K=>Bt(K.target.value),"aria-label":a("dialogs.paragraph.tabLeader"),"data-docx-tab-entry":"",children:[jsxRuntime.jsx("option",{value:"none",children:a("dialogs.paragraph.tabNone")}),jsxRuntime.jsx("option",{value:"dot",children:a("dialogs.paragraph.tabLeaderDot")}),jsxRuntime.jsx("option",{value:"hyphen",children:a("dialogs.paragraph.tabLeaderHyphen")}),jsxRuntime.jsx("option",{value:"underscore",children:a("dialogs.paragraph.tabLeaderUnderscore")})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row docx-dialog__row--actions",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:Oa,children:a("dialogs.paragraph.tabAdd")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{wt(K=>({...K,tabStops:false})),U(true),J([]);},children:a("dialogs.paragraph.tabClearAll")})]})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__column",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.spacing")}),vu("spaceBefore",C,T,"spaceBefore"),vu("spaceAfter",w,S,"spaceAfter"),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"lineRule",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${_e}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxRuntime.jsxs("select",{id:`${_e}-lineSpacing`,className:"docx-dialog__input",value:he.lineSpacing?"":M,onChange:K=>{let fe=K.target.value;gt("lineSpacing"),R(fe),_(fe===qt.current?.lineRule?qt.current.lineValue:fe==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[he.lineSpacing?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"multiple",children:a("dialogs.paragraph.ruleMultiple")}),jsxRuntime.jsx("option",{value:"atLeast",children:a("dialogs.paragraph.ruleAtLeast")}),jsxRuntime.jsx("option",{value:"exact",children:a("dialogs.paragraph.ruleExactly")})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"lineValue",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${_e}-at`,children:a("dialogs.paragraph.at")}),jsxRuntime.jsx("input",{id:`${_e}-at`,type:"number",className:"docx-dialog__input",min:.01,step:M==="multiple"?.01:1,value:he.lineSpacing?"":D,disabled:he.lineSpacing,onChange:K=>{let fe=K.target.value.trim();_(fe===""?M==="multiple"?1.08:12:Number(fe)||0);},"aria-label":a("dialogs.paragraph.at")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:M==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),ar("contextualSpacing",H,N),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),ar("keepNext",I,P),ar("widowControl",z,re),ar("keepLines",k,Y),ar("pageBreakBefore",V,te)]})]})}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{role:"alert","data-docx-part":"error",className:"docx-dialog__error",children:Ha?a("dialogs.paragraph.refused"):null}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("dialogs.paragraph.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!c,"data-docx-part":"apply",onClick:rr,children:a("dialogs.paragraph.ok")})]})]}),children:r})})}var Nt=qn();function Ox(){return Nt.useState()}var Gt=Object.assign(Hx,{Header:Nt.Header,Title:Nt.Title,Body:Nt.Body,Footer:Nt.Footer,Apply:Nt.Apply,Cancel:Nt.Cancel,Error:Nt.Error,Field:Nt.Field});var am=lt.createContext(null),Hr=()=>lt.useContext(am);function im({popups:e,children:t}){let o=F(),n=nc(),[r,i]=lt.useState(null),[a,l]=lt.useState(null),[s,c]=lt.useState(null),d=lt.useRef(e);d.current=e;let f=lt.useRef(null),u=lt.useRef(s);u.current=s;let g=()=>l(null);lt.useEffect(()=>{if(a!==null)return;let h=f.current;f.current=null,h?.isConnected&&h.focus({preventScroll:true});},[a]),lt.useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(h){if(d.current?.textFormField===false){h.cancel();return}l(null),c(h),h.signal.addEventListener("abort",()=>c(x=>x===h?null:x),{once:true});}},{fallback:true})},[o]),lt.useEffect(()=>{l(null),c(null);},[o,n]),lt.useEffect(()=>{e?.textFormField===false&&u.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let p=lt.useMemo(()=>({setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(h,x){u.current?.cancel(),d.current?.[h]!==false&&(f.current=x??r?.ownerDocument.activeElement,l(h));}}),[r,e?.pageSetup]),m={open:true,onClose:g},b=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?Le(e.pageSetup,m):jsxRuntime.jsx(Vo,{...m}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Le(e.paragraph,m):jsxRuntime.jsx(Gt,{...m}):s&&e?.textFormField!==false?e?.textFormField?Le(e.textFormField,{session:s},s):jsxRuntime.jsx(Ar,{session:s}):null;return jsxRuntime.jsxs(am.Provider,{value:p,children:[t,r?reactDom.createPortal(b,r):null]})}function lm(){let e=Hr();return jsxRuntime.jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer})}var oT=["nw","n","ne","e","se","s","sw","w"],um=40,pm=12;function nT(e){return `imageOverlay.handle.${e}`}function rT(e){switch(e){case "nw":case "se":return "nwse-resize";case "ne":case "sw":return "nesw-resize";case "n":case "s":return "ns-resize";default:return "ew-resize"}}function aT(e){return {nw:{x:"0%",y:"0%"},n:{x:"50%",y:"0%"},ne:{x:"100%",y:"0%"},e:{x:"100%",y:"50%"},se:{x:"100%",y:"100%"},s:{x:"50%",y:"100%"},sw:{x:"0%",y:"100%"},w:{x:"0%",y:"50%"}}[e]}function iT(e,t){return e>0&&t>0?"se":e>0&&t<0?"ne":e<0&&t>0?"sw":e<0&&t<0?"nw":e>0?"e":e<0?"w":t>0?"s":"n"}function hc({containerRef:e,portalRef:t,scrollPort:o}){let n=F(),{t:r}=L(),[i,a]=lt.useState(null),[l,s]=lt.useState(null),[c,d]=lt.useState({left:0,top:0}),f=lt.useRef(null);f.current=l;let u=lt.useRef(null),g=lt.useRef(null),p=lt.useRef(null),m=lt.useRef(null),b=lt.useRef(null);lt.useEffect(()=>{let S=e.current;if(!S)return;let M=R=>{let _=(R.target instanceof Element?R.target:null)?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");m.current=_??null,_&&_===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return S.addEventListener("pointerdown",M,{capture:true}),()=>S.removeEventListener("pointerdown",M,{capture:true})},[e,i?.id]),lt.useEffect(()=>{if(!n){a(null);return}let S=()=>{a(editor.selectedDrawingOverlayTargetOf(n.surface));},M=()=>{queueMicrotask(S);};S();let R=[n.on("change",M),n.on("selectionChange",S)];return ()=>{for(let D of R)D();}},[n]);let h=lt.useCallback(()=>{d(S=>{let M=editor.overlayHostOrigin(e.current);return M.left===S.left&&M.top===S.top?S:M});},[e]);lt.useEffect(()=>{h();let S=t.current;if(!S||typeof ResizeObserver!="function")return;let M=new ResizeObserver(h);M.observe(S);let R=e.current;return R&&M.observe(R),()=>M.disconnect()},[e,t,h,i]),lt.useEffect(()=>{if(o){b.current=o;return}let S=e.current;if(!S||!n?.surface)return;let M=S.closest(".docx-editor__scroll-container");if(!M)return;let R=n.surface.overlayCoordinates();return b.current=editor.createImageOverlayScrollPort(M,R.paintScale),()=>{b.current=null;}},[e,n,o]);let x=lt.useCallback(()=>{s(null),u.current=null;let S=g.current;if(g.current=null,S)try{S.releasePointerCapture(S._lastPointerId??0);}catch{}},[]),v=lt.useCallback((S,M,R,D,_,H,N)=>{if(!n?.surface)return;let I=n.surface.layout(),P=editor.captureImageMutationPreconditions(n);if(P){u.current=Object.freeze({x:D,y:_}),g.current=H,H._lastPointerId=N;try{H.setPointerCapture(N);}catch{}s({session:Object.freeze({drawingNodeId:R.id,startBounds:Object.freeze({x:R.x,y:R.y,width:R.width,height:R.height}),startWidthEmu:R.widthEmu,startHeightEmu:R.heightEmu,startPosition:R.position,anchorFrameOrigin:R.anchorFrameOrigin,transform:R.transform,mode:S,handle:M,preconditions:P,layoutRevision:I.revision,packageRevision:n.surface.session.packageRevision(),kind:R.kind}),bounds:R,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});}},[n]),y=lt.useCallback((S,M,R,D,_)=>{if(!n)return;if(editor.isStaleImageInteractionCommit(n,S)){x();return}S.mode==="resize"?n.exec({type:"setImageProperties",widthEmu:M,heightEmu:R,..._?.mode==="simple"?{horizontalEmu:_.horizontalEmu,verticalEmu:_.verticalEmu}:{},..._?.mode==="frame"?{..._.horizontalEmu!==void 0?{horizontalEmu:_.horizontalEmu}:{},..._.verticalEmu!==void 0?{verticalEmu:_.verticalEmu}:{}}:{}}):S.mode==="move"&&_&&n.exec({type:"setImagePosition",..._}),x();},[x,n]),C=lt.useCallback(S=>{if(!n)return;let M=f.current?.bounds??editor.selectedDrawingOverlayTargetOf(n.surface);if(!M)return;if(f.current&&S.key==="Escape"){S.preventDefault(),S.stopPropagation(),x();return}if(f.current)return;let R=S.shiftKey?editor.IMAGE_OVERLAY_NUDGE_SHIFT_PT:editor.IMAGE_OVERLAY_NUDGE_PT;if(S.key==="Delete"||S.key==="Backspace"){S.preventDefault(),S.stopPropagation(),n.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(S.key))return;S.preventDefault(),S.stopPropagation();let D=S.key==="ArrowLeft"?-R:S.key==="ArrowRight"?R:0,_=S.key==="ArrowUp"?-R:S.key==="ArrowDown"?R:0;if(S.altKey){if(!M.canResize)return;let N=iT(D,_),I=editor.computeImageResizeResult({handle:N,startWidthEmu:M.widthEmu,startHeightEmu:M.heightEmu,startBounds:{x:M.x,y:M.y,width:M.width,height:M.height},startPosition:M.position,anchorFrameOrigin:M.anchorFrameOrigin,deltaXPt:D,deltaYPt:_,transform:M.transform,preserveAspect:editor.resizePreservesAspect(N,M.aspectLocked,S.shiftKey),kind:M.kind});n.exec({type:"setImageProperties",widthEmu:I.widthEmu,heightEmu:I.heightEmu,...I.position?.mode==="simple"?{horizontalEmu:I.position.horizontalEmu,verticalEmu:I.position.verticalEmu}:{},...I.position?.mode==="frame"?{...I.position.horizontalEmu!==void 0?{horizontalEmu:I.position.horizontalEmu}:{},...I.position.verticalEmu!==void 0?{verticalEmu:I.position.verticalEmu}:{}}:{}});return}if(M.kind!=="anchored"||!M.canMove||!M.position)return;let H=editor.computeMovedImagePosition(M.position,D,_);n.exec({type:"setImagePosition",...H});},[x,n]);lt.useEffect(()=>{if(!l||!n?.surface)return;let S=n.surface.overlayCoordinates(),M=D=>{let _=f.current,H=u.current;if(!_||!H)return;let N=editor.cssPixelsToLayoutPoints(D.clientX-H.x,S.paintScale),I=editor.cssPixelsToLayoutPoints(D.clientY-H.y,S.paintScale);if(_.session.mode==="move"){let k=0,Y=b.current,z=e.current?.closest(".docx-editor__scroll-container");if(Y&&z){let V=z.getBoundingClientRect();D.clientY>V.bottom-um?k=pm:D.clientY<V.top+um&&(k=-pm),k!==0&&(k=Y.scrollBy(k));}let re=_.accumulatedScrollPt+k;s({..._,accumulatedScrollPt:re,bounds:Object.freeze({..._.bounds,x:_.session.startBounds.x+N,y:_.session.startBounds.y+I+re})});return}if(!_.session.handle)return;let P=editor.computeImageResizeResult({handle:_.session.handle,startWidthEmu:_.session.startWidthEmu,startHeightEmu:_.session.startHeightEmu,startBounds:_.session.startBounds,startPosition:_.session.startPosition,anchorFrameOrigin:_.session.anchorFrameOrigin,deltaXPt:N,deltaYPt:I,transform:_.session.transform,preserveAspect:editor.resizePreservesAspect(_.session.handle,_.bounds.aspectLocked,D.shiftKey),kind:_.session.kind});s({..._,bounds:Object.freeze({..._.bounds,x:P.previewBounds.x,y:P.previewBounds.y,width:P.previewBounds.width,height:P.previewBounds.height,widthEmu:P.widthEmu,heightEmu:P.heightEmu})});},R=D=>{let _=f.current;if(_)if(D.type==="pointerup"){let H=editor.cssPixelsToLayoutPoints(D.clientX-(u.current?.x??D.clientX),S.paintScale),N=editor.cssPixelsToLayoutPoints(D.clientY-(u.current?.y??D.clientY),S.paintScale),I=editor.finalizeImageOverlayInteraction({session:_.session,deltaXPt:H,deltaYPt:N,accumulatedScrollPt:_.accumulatedScrollPt,aspectLocked:_.bounds.aspectLocked,shiftKey:D.shiftKey,anchorFrameOrigin:_.session.anchorFrameOrigin});y(_.session,I.widthEmu,I.heightEmu,I.previewBounds,I.position);}else x();};return window.addEventListener("pointermove",M),window.addEventListener("pointerup",R),window.addEventListener("pointercancel",R),()=>{window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",R),window.removeEventListener("pointercancel",R);}},[x,y,e,n,l]),lt.useEffect(()=>{!i||m.current!==i.id||(m.current=null,p.current?.focus({preventScroll:true}));},[i]);let T=l?.bounds??i,w=lt.useMemo(()=>{if(!n?.surface||!T)return null;let S=n.surface.publishedLayout(),M=n.surface.overlayCoordinates(),R=editor.overlayFrameToSheetCssPixels(S,{pageIndex:T.pageIndex,x:T.x,y:T.y,width:T.width,height:T.height},M),D={left:R.left+c.left,top:R.top+c.top,width:R.width,height:R.height},_=T.canResize,H=T.kind==="anchored"&&T.canMove;return jsxRuntime.jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":T.id,tabIndex:0,onKeyDown:C,children:[jsxRuntime.jsx("div",{className:`docx-image-selection-overlay__frame${H?" docx-editor-one-surface__overlay-control":""}`,role:"group","aria-label":r("imageOverlay.selection"),style:{left:`${D.left}px`,top:`${D.top}px`,width:`${D.width}px`,height:`${D.height}px`,cursor:H?"move":"default"},onPointerDown:N=>{Z(N),!(!H||!T.position)&&N.button===0&&(N.preventDefault(),N.stopPropagation(),v("move",null,T,N.clientX,N.clientY,N.currentTarget,N.pointerId));}}),_?oT.map(N=>{let I=aT(N);return jsxRuntime.jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(nT(N)),tabIndex:0,style:{left:`calc(${D.left}px + ${D.width}px * ${parseFloat(I.x)/100} - 5px)`,top:`calc(${D.top}px + ${D.height}px * ${parseFloat(I.y)/100} - 5px)`,cursor:rT(N)},onPointerDown:P=>{Z(P),P.button===0&&(P.preventDefault(),P.stopPropagation(),v("resize",N,T,P.clientX,P.clientY,P.currentTarget,P.pointerId));}},N)}):null]})},[T,v,n,C,c.left,c.top,r]);return !w||!t.current?null:reactDom.createPortal(w,t.current)}function yc(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function wi({className:e}){let t=F(),o=yr(),n=lt.useRef(null),r=lt.useRef(null);lt.useLayoutEffect(()=>{let s=n.current;if(!(!t||!s))return t.attach(s),()=>{t.detach();}},[t]);let i=lt.useCallback(s=>{if(!o?.isEnabled)return;let c=s.clipboardData;c&&yc(c)&&(editor.clipboardPasteLandsContent(c)||(s.preventDefault(),o.insertFromDataTransfer(c)));},[o]),a=lt.useCallback(s=>{!o?.isEnabled||!yc(s.dataTransfer)||s.preventDefault();},[o]),l=lt.useCallback(s=>{if(o?.isEnabled&&yc(s.dataTransfer)){if(editor.clipboardDropLandsText(s.dataTransfer)){if((s.target instanceof Element?s.target:null)?.closest("[contenteditable]")?.getAttribute("contenteditable")==="true")return;s.preventDefault();return}s.preventDefault(),o.insertFromDataTransfer(s.dataTransfer);}},[o]);return jsxRuntime.jsxs("div",{ref:r,className:"docx-content-mount",children:[jsxRuntime.jsx("div",{ref:n,className:`docx-paginated-surface${e?` ${e}`:""}`,onPaste:i,onDragOver:a,onDrop:l}),jsxRuntime.jsx(lm,{}),jsxRuntime.jsx(yp,{}),jsxRuntime.jsx(Up,{}),t?jsxRuntime.jsx(hc,{containerRef:n,portalRef:r}):null]})}function Ee(e){return e/1440*96}function Ri(e){return e/96*1440}function ot(e){return `${Math.round(e*100)/100}px`}function xc(e){return e/2}var pT=e=>e.isLoading||e.isOpening===true,mT=e=>({width:Ee(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:Ee(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),fT=(e,t)=>e.width===t.width&&e.height===t.height;function Tc({className:e}){return jsxRuntime.jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}function gT({when:e=false,overlay:t=false,className:o,style:n,children:r}){let i=O(pT),a=O(mT,fT),{t:l}=L();if(!e&&!i)return null;let s=`docx-editor docx-editor__loading${t?" docx-editor__loading--overlay":""}${o?` ${o}`:""}`;return jsxRuntime.jsx("div",{className:s,style:n,role:"status","aria-live":"polite",children:r??jsxRuntime.jsx("div",{className:"docx-paginated-surface docx-editor__loading-surface",style:{width:a.width,height:a.height},children:jsxRuntime.jsx("div",{className:"docx-pages",children:jsxRuntime.jsx("div",{className:"docx-page docx-editor__loading-page",children:jsxRuntime.jsxs("div",{className:"docx-editor__loading-page-status",children:[jsxRuntime.jsx(Tc,{}),jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:l("loading.label")})]})})})})})}var Mi=Object.assign(gT,{Spinner:Tc});function gm(){let e=new Set,t=new Map,o=new Map,n=0,r=null,i=false;function a(){if(e.size===0&&t.size===0)return;if(t.size===0)return "kind";let u=Object.create(null),g=[...t].sort((p,m)=>(o.get(p[0])??0)-(o.get(m[0])??0));for(let[,{author:p,style:m}]of g)u[p]=m;return {authors:u,others:e.size>0?"kind":"author"}}let l=null,s=false;function c(u){if(u===void 0)return "none";if(typeof u=="string")return u;let g=Object.entries(u.authors).map(([p,m])=>`${p}\0${JSON.stringify(m)}`).sort();return `${u.others??"kind"}${g.join("")}`}function d(){if(!r)return;let u=a(),g=c(u);if(g!==l){if(u===void 0){i&&(r.setRevisionStyles("author"),i=false,l=g);return}r.setRevisionStyles(u),i=true,l=g;}}function f(){!r||s||(s=true,queueMicrotask(()=>{s=false,d();}));}return {registerScheme(u){e.add(u),f();},register(u,g,p){o.has(u)||o.set(u,n++),t.set(u,{author:g,style:p}),f();},unregister(u){(e.delete(u)||t.delete(u))&&f();},connect(u){r=u;let g=a();i=u!==null&&g!==void 0,l=u===null?null:c(g),f();},current:a}}var Zr=lt.createContext(null);function vm(){let e=lt.useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function Cc(){let e=lt.useContext(Zr),t=vm();return lt.useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function Sc(e){let{author:t,color:o,background:n,activeBackground:r,spanClassName:i,avatarUrl:a}=e,l=lt.useContext(Zr),s=vm();return lt.useEffect(()=>{if(l)return l.register(s,t,{...o!==void 0?{color:o}:{},...n!==void 0?{background:n}:{},...r!==void 0?{activeBackground:r}:{},...i!==void 0?{spanClassName:i}:{},...a!==void 0?{avatarUrl:a}:{}}),()=>l.unregister(s)},[l,s,t,o,n,r,i,a]),null}function ym(){let e=0,t=0,o=null,n=new Set,r=new Set,i=new Set,a=l=>{for(let s of [...l])s();};return {getShift:()=>e,setShift(l){let s=Math.max(0,Math.round(l));s!==e&&(e=s,a(n));},subscribeShift(l){return n.add(l),()=>n.delete(l)},getReservation:()=>t,setReservation(l){let s=Math.max(0,Math.round(l));s!==t&&(t=s,a(r));},subscribeReservation(l){return r.add(l),()=>r.delete(l)},getViewport:()=>o,setViewport(l){l!==o&&(o=l,a(i));},subscribeViewport(l){return i.add(l),()=>i.delete(l)}}}var Ec=lt.createContext(null);function Uo(){return lt.useContext(Ec)}var xm=()=>0,wc=()=>()=>{};function Go(){let e=Uo(),t=lt.useCallback(n=>e?e.subscribeShift(n):wc(),[e]),o=lt.useCallback(()=>e?e.getShift():0,[e]);return lt.useSyncExternalStore(t,o,xm)}function Tm(){let e=Uo(),t=lt.useCallback(n=>e?e.subscribeReservation(n):wc(),[e]),o=lt.useCallback(()=>e?e.getReservation():0,[e]);return lt.useSyncExternalStore(t,o,xm)}function jt(){let e=Uo(),t=lt.useCallback(r=>e?e.subscribeViewport(r):wc(),[e]),o=lt.useCallback(()=>e?e.getViewport():null,[e]),n=lt.useCallback(()=>null,[]);return lt.useSyncExternalStore(t,o,n)}function ET(e,t){if(e===t)return true;let o=editor.resolveZoomMode(e),n=editor.resolveZoomMode(t);return o!==null&&n!==null&&editor.sameZoomMode(o,n)}function wT(e){let t=lt.useRef(e);t.current=e;let[o,n]=lt.useState(null),{onReady:r,onChange:i,onFontError:a,...l}=e,s=lt.useMemo(()=>({onReady:c=>{n(c),t.current.onReady?.(c);},onChange:c=>t.current.onChange?.(c),onFontError:c=>t.current.onFontError?.(c)}),[]);return {DocxEditorRoot:qr,rootProps:l,rootListeners:s,editorRef:o}}function qr(e){let{document:t,fonts:o,author:n,locale:r,translate:i,mode:a,zoom:l,zoomMode:s,tableInteractionLabel:c,imageDecodePort:d,children:f}=e,{t:u}=L(),g=lt.useCallback((D,_)=>u(D,_),[u]),p=lt.useRef(g);p.current=g;let m=lt.useRef(e);m.current=e;let[b,h]=lt.useState(null),x=lt.useRef(null);x.current??=gm();let v=x.current;lt.useEffect(()=>{let D=m.current,_=D.translate??p.current,H=v.current(),N=editor.createDocxEditor({...D.document!==void 0?{document:D.document}:{},...D.fonts?{fonts:D.fonts}:{},...D.author!==void 0?{author:D.author}:{},...D.locale!==void 0?{locale:D.locale}:{},translate:_,...D.mode!==void 0?{mode:D.mode}:{},...H!==void 0?{revisionStyles:H}:{},...D.modules!==void 0?{modules:D.modules}:{},...D.zoom!==void 0?{zoom:D.zoom}:{},...D.zoomMode!==void 0?{zoomMode:D.zoomMode}:{},...D.tableInteractionLabel?{tableInteractionLabel:D.tableInteractionLabel}:{},...D.imageDecodePort?{imageDecodePort:D.imageDecodePort}:{},onFontError:P=>m.current.onFontError?.(P)}),I=N.on("change",P=>m.current.onChange?.(P));return h(N),()=>{I(),N.destroy(),h(P=>P===N?null:P);}},[t,o,d,v]),lt.useEffect(()=>{if(!b)return;if(!b.snapshot().isOpening){m.current.onReady?.(b);return}let D=b.on("change",()=>{D(),m.current.onReady?.(b);});return D},[b]);let y=lt.useRef({editor:null,zoom:void 0,mode:void 0});lt.useEffect(()=>{if(!b)return;y.current.editor!==b&&(y.current={editor:b,zoom:void 0,mode:void 0});let _=false;l!==void 0&&l!==y.current.zoom&&(y.current.zoom=l,b.setZoom(l),_=true);let H=y.current.mode,N=s!==void 0&&(H===void 0||!ET(H,s)),I=s===void 0?null:editor.resolveZoomMode(s),P=_&&s!==void 0&&I!==null&&I.type==="fit";(N||P)&&(y.current.mode=s,b.setZoomMode(s));},[b,l,s]),lt.useEffect(()=>{b&&b.setAuthor(n);},[b,n]);let C=lt.useRef({editor:null,value:void 0});lt.useEffect(()=>{if(b){if(C.current.editor!==b){C.current={editor:b,value:a};return}C.current.value!==a&&(C.current.value=a,b.setMode(a));}},[b,a]),lt.useEffect(()=>{b&&b.setTranslate(i??g);},[b,i,g]),lt.useEffect(()=>{b&&b.setLocale(r);},[b,r]),lt.useEffect(()=>{b&&b.setTableInteractionLabel(c??editor.defaultTableLabel);},[b,c]);let[T,w]=lt.useState(0),S=lt.useRef([]),M=lt.useMemo(()=>({mounted:T,register:()=>(w(D=>D+1),()=>w(D=>Math.max(0,D-1))),registerCommentDraft:D=>(S.current.push(D),()=>{let _=S.current.indexOf(D);_!==-1&&S.current.splice(_,1);}),requestCommentDraft:()=>{let D=S.current.at(-1);return D?(D(),true):false}}),[T]),R=lt.useMemo(ym,[]);return lt.useEffect(()=>(v.connect(b),()=>v.connect(null)),[v,b]),jsxRuntime.jsx(Fp,{value:i??g,children:jsxRuntime.jsx(bt.Provider,{value:M,children:jsxRuntime.jsx(Ql.Provider,{value:b,children:jsxRuntime.jsx(Ec.Provider,{value:R,children:jsxRuntime.jsx(Zr.Provider,{value:v,children:jsxRuntime.jsx(RT,{children:jsxRuntime.jsx(MT,{children:jsxRuntime.jsx(ja,{children:jsxRuntime.jsx(vp,{value:e.popups,children:jsxRuntime.jsx(im,{popups:e.popups,children:f})})})})})})})})})})}function RT({children:e}){let t=za(true);return jsxRuntime.jsx(dr.Provider,{value:t,children:e})}function MT({children:e}){let t=$a();return jsxRuntime.jsx(hs.Provider,{value:t,children:e})}var Ic=316,Dc=44,NT=24,ki={inlineStart:0,inlineEnd:Ic},Cm={inlineStart:Dc,inlineEnd:Dc},LT={inlineStart:0,inlineEnd:0};function Em({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:n=0,docked:r=false}){if(!e)return Cm;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return ki;let i=Number.isFinite(n)&&n>0?n:0;return t-i-o-2*NT>=Ic?ki:Cm}var FT=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,reviewPaneOpen:e.reviewPaneOpen??true,entitledZoom:t?.type==="fit"?t.maxZoom!==void 0&&t.maxZoom<editor.ZOOM_MAX?t.maxZoom:null:e.zoom}},AT=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function wm(){let e=jt(),[t,o]=lt.useState(null);return lt.useEffect(()=>{if(!e){o(null);return}let n=()=>o(e.clientWidth);if(n(),typeof ResizeObserver>"u")return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e]),t}function $n(){let e=lt.useContext(bt),{pageSetup:t,reviewPaneOpen:o,entitledZoom:n}=O(FT,AT),r=jt(),i=Tm(),a=lt.useRef(null);t&&(a.current=t.pageWidthTwips);let l=t?.pageWidthTwips??a.current,s=(e?.mounted??0)>0,c=lt.useCallback(u=>s?Em({open:o,viewportWidth:u??0,pageWidthPx:l===null||n===null?0:Ee(l)*n,inlineStartReservation:i,docked:n===null}):LT,[s,o,l,n,i]),[d,f]=lt.useState(()=>c(r?r.clientWidth:null));return lt.useEffect(()=>{let u=()=>f(c(r?r.clientWidth:null));if(u(),!r||typeof ResizeObserver>"u")return;let g=new ResizeObserver(u);return g.observe(r),()=>g.disconnect()},[r,c]),d}var Di=[.25,.5,.75,1,1.25,1.5,2];function Kr(e,t){return t==="in"?Di.find(n=>n>e+.001)??null:[...Di].reverse().find(n=>n<e-.001)??null}function Rm(e,t){return e==="0"?1:e==="+"||e==="="?Kr(t,"in")??t:e==="-"?Kr(t,"out")??t:null}var OT=e=>e.reviewPaneOpen??true,BT=e=>e.zoomMode?.type==="fit";function Ii({className:e,style:t,children:o}){let n=it(),r=F(),i=O(OT),a=$n(),l=O(BT),c=(lt.useContext(bt)?.mounted??0)>0,d=Uo(),f=Go(),u=lt.useCallback(p=>d?.setViewport(p),[d]),g=lt.useCallback(p=>{if(!r||!(p.metaKey||p.ctrlKey)||p.altKey)return;let m=p.target;if(m instanceof Element&&m.closest('input, textarea, select, [role="dialog"]'))return;let b=Rm(p.key,r.getZoom());b!==null&&(p.preventDefault(),r.setZoom(b));},[r]);return jsxRuntime.jsx("div",{ref:u,"data-testid":"docx-editor-scroll",onKeyDownCapture:g,...c?{"data-review-pane":i?"open":"closed"}:{},...l?{"data-zoom-fit":""}:{},className:`${n}docx-editor-one-surface docx-editor-one-surface__viewport docx-editor__scroll-container${e?` ${e}`:""}`,style:{...t,"--docx-nav-shift":`${f}px`,...c?{"--docx-review-gutter":`${a.inlineEnd}px`,"--docx-review-gutter-start":`${a.inlineStart}px`}:{}},children:jsxRuntime.jsx(Bo.Provider,{value:true,children:o})})}var qT=editor.LOADING_SNAPSHOT;function Dm({ref:e,editorRef:t}){lt.useImperativeHandle(e,()=>({load:o=>t.current?.load(o),save:()=>t.current?.save()??Promise.resolve(null),getDocumentHandle:()=>t.current?.getDocumentHandle()??null,getEditor:()=>t.current,focus:()=>{t.current?.focus();},exec:(o,n)=>t.current?.exec(o,n)??{ok:false,code:"notFound",reason:"no editor is mounted"},snapshot:o=>t.current?.snapshot(o)??qT}),[t]);}var WT=e=>e.editingMode??"editing",Nc='[role="menuitemradio"]:not([disabled])',UT=(e,t)=>e.length===t.length&&e.every((o,n)=>o===t[n]),GT=e=>e.isLoading||e.isOpening===true,zr=[{mode:"editing",labelKey:"editingMode.editing",hintKey:"editingMode.editingHint",path:"M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z"},{mode:"suggesting",labelKey:"editingMode.suggesting",hintKey:"editingMode.suggestingHint",path:"M240-400h122l40-40H240v40Zm0-100h222l40-40H240v40Zm0-100h322l40-40H240v40ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v320h-80v-320H160v525l46-45h274v80H240L80-80Zm520-80v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T943-380L723-160H600Zm300-263-37-37 37 37ZM660-220h38l121-122-19-18-18-19-122 121v38Zm140-141-18-19 37 37-19-18Z"},{mode:"viewing",labelKey:"editingMode.viewing",hintKey:"editingMode.viewingHint",path:"M480-320q75 0 127.5-52.5T660-500q0-75-52.5-127.5T480-680q-75 0-127.5 52.5T300-500q0 75 52.5 127.5T480-320Zm0-72q-45 0-76.5-31.5T372-500q0-45 31.5-76.5T480-608q45 0 76.5 31.5T588-500q0 45-31.5 76.5T480-392Zm0 192q-146 0-266-81.5T40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200Z"}],jT=Object.freeze(zr.map(()=>null));function YT(e){return e?zr.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):jT}var XT="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function Ni({className:e,hidden:t}){let o=F(),n=O(WT),r=O(GT),i=ee(),{t:a}=L(),[l,s]=lt.useState(false),c=lt.useRef(null),d=lt.useRef(null),f=lt.useRef(null);lt.useEffect(()=>{if(!l)return;let v=f.current?.querySelectorAll(Nc);(f.current?.querySelector(`${Nc}[aria-checked="true"]`)??v?.[0]??void 0)?.focus();},[l]);let u=lt.useCallback(v=>{let y=[...f.current?.querySelectorAll(Nc)??[]],C=y.indexOf(document.activeElement),T=w=>{v.preventDefault(),y[(w+y.length)%y.length]?.focus();};v.key==="ArrowDown"?T(C+1):v.key==="ArrowUp"?T(C-1):v.key==="Home"?T(0):v.key==="End"&&T(y.length-1);},[]);lt.useEffect(()=>{if(!l)return;let v=C=>{let T=c.current;T&&C.target instanceof Node&&T.contains(C.target)||s(false);},y=C=>{C.key==="Escape"&&(C.preventDefault(),s(false));};return document.addEventListener("mousedown",v,true),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",v,true),document.removeEventListener("keydown",y);}},[l]);let g=lt.useCallback(v=>{s(false),editor.runToolbarCommand(o,"review.editingMode",v),o?.focus();},[o]),p=editor.toolbarCommandState(o,"review.editingMode"),m=i18n.localizeDisabledReason(p.disabledReason,a),b=O(()=>YT(o),UT),h=lt.useMemo(()=>zr.find(v=>v.mode===n)??zr[0],[n]);if(t)return null;let x=Q("review.editingMode");return jsxRuntime.jsxs("div",{ref:c,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxRuntime.jsxs("button",{ref:d,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":n,"aria-haspopup":"menu","aria-expanded":l,"aria-label":i(x?.labelKey??"editingMode.label"),disabled:r||!p.enabled,...m?{title:m}:{},onMouseDown:Z,onClick:()=>s(v=>!v),children:[Lc(h.path),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:i(h.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsxRuntime.jsx("div",{ref:f,className:"docx-toolbar__mode-menu",role:"menu","aria-label":i(x?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:zr.map((v,y)=>{let C=i18n.localizeDisabledReason(b[y]??null,a);return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":v.mode===n,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${v.mode}`,disabled:C!==null,...C?{title:C}:{},onMouseDown:Z,onClick:()=>g(v.mode),children:[Lc(v.path),jsxRuntime.jsxs("span",{className:"docx-toolbar__mode-text",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__mode-label",children:i(v.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-hint",children:i(v.hintKey)})]}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:v.mode===n?Lc(XT):null})]},v.mode)})}):null]})}Ni.docxSlot="review.editingMode";function Lc(e){return jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})})}var Lm=[],eC=()=>{};function Vr(){let e=F(),t=lt.useCallback(o=>{if(!e)return eC;let n=lr(o),r=e.on("change",n),i=e.on("selectionChange",n);return ()=>{r(),i();}},[e]);return lt.useSyncExternalStore(t,()=>e?.getReviewAuthors()??Lm,()=>Lm)}var iC=e=>e.hiddenReviewAuthors??[];function Fi({className:e,hidden:t,icon:o}){let n=F(),r=Vr(),i=O(iC),a=new Set(i),l=r.every(y=>!a.has(y.author)),[s,c]=lt.useState(false),d=lt.useRef(null),f=lt.useRef(null),u=lt.useRef(null),g=ee(),{t:p}=L();lt.useEffect(()=>{if(!s)return;u.current?.querySelector('[role="menuitemcheckbox"]')?.focus();let y=T=>{d.current?.contains(T.target)||c(false);},C=T=>{T.key==="Escape"&&(T.preventDefault(),c(false),f.current?.focus());};return document.addEventListener("mousedown",y,true),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",y,true),document.removeEventListener("keydown",C);}},[s]);let m=lt.useCallback(y=>{let C=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],T=C.indexOf(document.activeElement),w=S=>{y.preventDefault(),C[(S+C.length)%C.length]?.focus();};y.key==="ArrowDown"?w(T+1):y.key==="ArrowUp"?w(T-1):y.key==="Home"?w(0):y.key==="End"?w(C.length-1):y.key==="Tab"&&c(false);},[]);if(t)return null;let b=Q("review.authors"),h=editor.toolbarCommandState(n,"review.authors"),x=i18n.localizeDisabledReason(h.disabledReason,p),v=g(b?.labelKey??"reviewers.label");return jsxRuntime.jsxs("div",{ref:d,className:`docx-toolbar__reviewers${e?` ${e}`:""}`,"data-slot":"review.authors",children:[jsxRuntime.jsxs("button",{ref:f,type:"button",className:"docx-toolbar__picker","data-testid":"reviewers-trigger","aria-haspopup":"menu","aria-expanded":s,"aria-label":v,disabled:!h.enabled,title:x??v,onMouseDown:Z,onClick:()=>c(y=>!y),children:[o??oe(b?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:v}),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),s?jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__reviewers-menu",role:"menu","aria-label":v,"data-testid":"reviewers-menu",onKeyDown:m,children:[jsxRuntime.jsx(Fm,{checked:l,label:p("reviewers.all"),testId:"reviewer-all",onChoose:()=>n?.setAllReviewAuthorsVisible(!l)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),r.map(y=>jsxRuntime.jsx(Fm,{checked:!a.has(y.author),label:y.author||"\u2014",testId:`reviewer-${y.slot}`,color:y.color,onChoose:()=>n?.setReviewAuthorVisible(y.author,a.has(y.author))},y.author))]}):null]})}Fi.docxSlot="review.authors";function Fm(e){return jsxRuntime.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e.checked,className:"docx-toolbar__reviewer-item","data-testid":e.testId,onMouseDown:Z,onClick:e.onChoose,children:[jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:e.checked?"\u2713":""}),e.color?jsxRuntime.jsx("span",{className:"docx-toolbar__reviewer-swatch",style:{background:e.color}}):null,jsxRuntime.jsx("span",{className:"docx-toolbar__reviewer-name",children:e.label})]})}var Am=lt.createContext(null);function Hm({children:e}){let t=Hr(),[o,n]=lt.useState(false),r=lt.useRef(null),i=lt.useMemo(()=>({open:l=>{if(t){t.open("paragraph",l);return}r.current=l??document.activeElement,n(true);}}),[t]),a=lt.useCallback(()=>{n(false);let l=r.current;r.current=null,l instanceof HTMLElement&&l.isConnected&&l.focus({preventScroll:true});},[]);return jsxRuntime.jsxs(Am.Provider,{value:i,children:[e,jsxRuntime.jsx(Gt,{open:o,onClose:a})]})}function Om(){return lt.useContext(Am)}var gC=["zoom","script","format","list","alignment","styles","font","text","history"],Ac=new Set(["review"]),Hc=24,Zm=new Set;function qm(e,t=gC){let o=t.filter(r=>e.includes(r));return [...e.filter(r=>!t.includes(r)).reverse(),...o]}function Bm(e,t){let{widths:o,groups:n,order:r,fixed:i,more:a}=e,l=i;for(let c of n)l+=o.get(c)??0;if(l<=t)return Zm;l+=a;let s=new Set;for(let c of r){if(l<=t)break;let d=o.get(c);d===void 0||s.has(c)||(s.add(c),l-=d);}return s}function Km(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let o of e)if(!t.has(o))return false;return true}var zm=Km;function Vm(e){if(!(e.available>0))return Zm;let t=Bm(e,e.available),o=e.previous;if(!o||o.size===0||t.size>=o.size)return t;let n=Bm(e,e.available-(e.hysteresis));return Km(n,o)?o:n}function $m(e,t,o,n){return e+t+o+n*2}function Wm(e,t){return e+t}function Bc(e,t){return e+t}function Um(e){let t=Number.parseFloat(e.marginInlineStart||e.marginLeft),o=Number.parseFloat(e.marginInlineEnd||e.marginRight);return {start:Number.isFinite(t)?t:0,end:Number.isFinite(o)?o:0}}function Oc(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Gm(e){return Oc(e.columnGap)}function jm(e,t){return e.clientWidth-Oc(t.paddingLeft)-Oc(t.paddingRight)}var Wn="data-toolbar-group",Wr="data-toolbar-fixed",qc="data-toolbar-more",yC=34,Zc=new Set;function Xm(e,t,o){let n=lt.useRef(null),r=lt.useRef(new Map),i=lt.useRef(yC),[a,l]=lt.useState(Zc),s=lt.useRef(a);s.current=a;let c=lt.useRef({groups:t,order:o});c.current={groups:t,order:o};let d=t.join("\0"),f=o.join("\0"),u=lt.useCallback(()=>{let p=n.current;if(!p||!e)return;let m=getComputedStyle(p),b=Gm(m),h=jm(p,m),x=p.querySelector(".docx-toolbar__separator"),v=b*2;if(x){let S=getComputedStyle(x),M=Um(S);v=$m(x.offsetWidth,M.start,M.end,b);}for(let S of p.querySelectorAll(`[${Wn}]`)){let M=S.getAttribute(Wn);M&&S.offsetWidth>0&&r.current.set(M,Wm(S.offsetWidth,v));}let y=0;for(let S of p.querySelectorAll(`[${Wr}]`))S.offsetWidth>0&&(y+=Bc(S.offsetWidth,b));let C=p.querySelector(`[${qc}]`);C&&C.offsetWidth>0&&(i.current=Bc(C.offsetWidth,b));let T={available:h,widths:r.current,groups:c.current.groups,order:c.current.order,fixed:y,more:i.current,previous:s.current,hysteresis:Hc},w=Vm(T);zm(w,s.current)||(s.current=w,l(w));},[e]),g=lt.useCallback(p=>{n.current=p;},[]);return lt.useLayoutEffect(()=>{if(!e){s.current.size>0&&(s.current=Zc,l(Zc));return}u();},[e,d,u,f]),lt.useEffect(()=>{let p=n.current;if(!e||!p||typeof ResizeObserver>"u")return;let m=0,b=new ResizeObserver(()=>{m===0&&(m=requestAnimationFrame(()=>{m=0,u();}));});b.observe(p);for(let h of p.querySelectorAll(`[${Wn}], [${Wr}]`))b.observe(h);return ()=>{m!==0&&cancelAnimationFrame(m),b.disconnect();}},[e,d,u,f,a]),{attach:g,overflow:a}}var RC=["M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z"],Jm=lt.createContext({close:()=>{}});function MC(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function ef({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"docx-toolbar__more-control",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-control-label",children:e}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-control-body",children:t})]})}function tf({slot:e}){let t=ee(),o=vn(),{close:n}=lt.useContext(Jm),{execute:r,isActive:i,isEnabled:a,disabledReason:l,value:s}=se(e),c=Q(e),d=editor.chromeSlotIsToggle(e),f=o(t(c?.labelKey??e));return jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__more-command","data-slot":e,disabled:!a,...l?{title:l}:{},...d?{"aria-pressed":i}:{},...i?{"data-active":""}:{},...s!==null?{"data-value":s}:{},onMouseDown:Z,onClick:u=>{r(),n(u.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:oe(c?.paths)}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:f})]})}function of({sections:e,className:t}){let o=ee(),[n,r]=lt.useState(false),i=lt.useRef(null),a=lt.useRef(null),l=lt.useRef(null),s=lt.useRef(false),c=lt.useId(),d=o("formattingBar.more"),f=lt.useCallback(p=>{r(false),p&&a.current?.focus();},[]),u=lt.useMemo(()=>({close:f}),[f]);lt.useEffect(()=>{if(!n)return;let p=m=>{let b=m.target;b instanceof Node&&i.current?.contains(b)||r(false);};return document.addEventListener("mousedown",p,true),()=>document.removeEventListener("mousedown",p,true)},[n]),lt.useEffect(()=>{if(!n||!s.current)return;s.current=false;let p=l.current;p&&MC(p);},[n]);let g=p=>{p.key!=="Escape"||p.defaultPrevented||(p.preventDefault(),f(true));};return jsxRuntime.jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[qc]:"",children:[jsxRuntime.jsx("button",{ref:a,type:"button",className:"docx-toolbar__button docx-toolbar__more-trigger","data-slot":"toolbar.more","aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?c:void 0,"aria-label":d,title:d,...n?{"data-active":""}:{},onMouseDown:Z,onClick:()=>r(p=>!p),onKeyDown:p=>{p.key==="ArrowDown"&&(p.preventDefault(),s.current=true,r(true));},children:oe(RC)}),n?jsxRuntime.jsx(Jm.Provider,{value:u,children:jsxRuntime.jsx("div",{ref:l,id:c,role:"dialog","aria-label":d,className:"docx-toolbar__more-panel","data-testid":"toolbar-overflow-panel",onKeyDown:g,children:e.map(p=>jsxRuntime.jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":o(p.labelKey),children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:o(p.labelKey)}),p.children]},p.id))})}):null]})}var zc=[{value:"inline",labelKey:"imageWrap.menu.inLineWithText",iconName:"wrap_text"},{value:"square",labelKey:"imageWrap.square",iconName:"crop_square"},{value:"squareLeft",labelKey:"imageWrap.menu.squareLeft",iconName:"format_image_left"},{value:"squareRight",labelKey:"imageWrap.menu.squareRight",iconName:"format_image_right"},{value:"tight",labelKey:"imageWrap.tight",iconName:"wrap_text"},{value:"through",labelKey:"imageWrap.through",iconName:"wrap_text"},{value:"topAndBottom",labelKey:"imageWrap.topAndBottom",iconName:"vertical_align_center"},{value:"behind",labelKey:"imageWrap.behindText",iconName:"flip_to_back"},{value:"inFront",labelKey:"imageWrap.inFrontOfText",iconName:"flip_to_front"}];function Bi({className:e,hidden:t,asChild:o,children:n}){let{t:r}=L(),i=ee(),{execute:a,value:l,isEnabled:s,disabledReason:c}=Nr("image.wrap"),[d,f]=lt.useState(false),u=lt.useRef(null),g=lt.useRef(null),p=lt.useRef(null),m=lt.useId(),b=lt.useMemo(()=>zc.find(T=>T.value===l)??zc[0],[l]),h=Q("image.wrap"),x=i(h?.labelKey??"formattingBar.imageWrap");lt.useEffect(()=>{if(!d)return;let T=S=>{let M=u.current;M&&S.target instanceof Node&&M.contains(S.target)||f(false);},w=S=>{S.key==="Escape"&&(S.preventDefault(),f(false),g.current?.focus());};return document.addEventListener("mousedown",T,true),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",T,true),document.removeEventListener("keydown",w);}},[d]);let v=lt.useCallback(T=>{f(false),a(T);},[a]);if(t)return null;let y=r("imageWrap.tooltipPrefix",{label:r(b.labelKey)}),C={type:"button",ref:g,className:`docx-toolbar__button docx-toolbar__image-wrap-trigger${e?` ${e}`:""}`,"data-slot":"image.wrap",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?m:void 0,"aria-label":x,title:c??y,onMouseDown:Z,onClick:()=>f(T=>!T)};return jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsxRuntime.jsx(j,{...C,children:n}):jsxRuntime.jsx("button",{...C,children:n??oe(h?.paths)}),d?jsxRuntime.jsx("div",{ref:p,id:m,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:T=>T.stopPropagation(),children:zc.map(T=>jsxRuntime.jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":l===T.value,...l===T.value?{"data-active":""}:{},onMouseDown:Z,onClick:()=>v(T.value),children:r(T.labelKey)},T.value))}):null]})}Bi.docxSlot="image.wrap";var Ur=Object.assign(Bi,{docxSlot:"image.wrap"});function Be(e){return Object.assign(o=>jsxRuntime.jsx(Do,{slot:e,...o}),{docxSlot:e})}var nf=Be("history.undo"),rf=Be("history.redo"),af=Be("text.bold"),lf=Be("text.italic"),sf=Be("text.underline"),cf=Be("text.strike"),df=Be("format.clear"),uf=Be("script.super"),pf=Be("script.sub"),mf=Be("alignment.left"),ff=Be("alignment.center"),gf=Be("alignment.right"),bf=Be("alignment.justify"),hf=Be("list.bullet"),vf=Be("list.numbered"),yf=Be("list.outdent"),xf=Be("list.indent");var Tf=Be("table.insert"),Cf=Be("review.comments");function OC({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=F(),{openAtCaret:a}=as(),l=editor.chromeProbeForSlot("text.link"),s=i&&l?i.can(l):null,c=s?.ok===true,{t:d}=L(),f=i18n.localizeDisabledReason(s&&!s.ok?s.reason:null,d),u=ee();if(t)return null;let g=Q("text.link"),p=u(g?.labelKey??"text.link"),m={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!c,...c?{}:{"data-disabled":""},"aria-label":p,title:f??p,onMouseDown:Z,onClick:()=>a()};return n?jsxRuntime.jsx(j,{...m,children:r}):jsxRuntime.jsx("button",{...m,children:o??r??oe(g?.paths)})}var Vc=Object.assign(OC,{docxSlot:"text.link"});function BC({className:e,hidden:t}){let o=F(),{onSave:n}=lt.useContext(ko),r=ee();if(t)return null;let i=Q("file.save"),a=r(i?.labelKey??"file.save"),l=!o||!n;return jsxRuntime.jsx("button",{type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"file.save",disabled:l,...l?{"data-disabled":""}:{},"aria-label":a,title:a,onMouseDown:Z,onClick:()=>n?.(),children:oe(i?.paths)})}var $c=Object.assign(BC,{docxSlot:"file.save"});function Yo({className:e}){return jsxRuntime.jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}var KC=e=>({zoom:e.zoom,mode:e.zoomMode}),zC=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,Pf={type:"fixed"};function Wc(){let e=F(),{zoom:t,mode:o}=O(KC,zC),n=lt.useCallback(i=>{e?.setZoom(i);},[e]),r=lt.useCallback(i=>{e?.setZoomMode(i);},[e]);return lt.useMemo(()=>{let i=o??Pf,a=Kr(t,"out"),l=Kr(t,"in");return {zoom:t,mode:i,isFit:i.type==="fit",setZoom:n,setMode:r,fitToWidth:()=>r(editor.FIT_WIDTH_ZOOM_MODE),auto:()=>r("auto"),reset:()=>{r(Pf),n(1);},zoomIn:()=>l!==null&&n(l),zoomOut:()=>a!==null&&n(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:Di}},[e,t,o,n,r])}var Yr=2,Xr=3276,jr=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],WC=e=>e.formatting?.fontSizePt??null;function Rf(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function Mf(e,t,o){for(let n=t.length-1;n>=0;n-=1)if(t[n]<e)return t[n];return Math.max(e-1,o)}function Df(e){return jsxRuntime.jsxs("span",{className:`docx-toolbar__stepper${e.className?` ${e.className}`:""}`,...e.slot!==void 0?{"data-slot":e.slot}:{},role:"group","aria-label":e.groupLabel,title:e.title??e.groupLabel,children:[jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canDecrease,"aria-label":e.decreaseLabel,onMouseDown:Z,onClick:e.onDecrease,children:"\u2212"}),e.middle,jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canIncrease,"aria-label":e.increaseLabel,onMouseDown:Z,onClick:e.onIncrease,children:"+"})]})}function UC(e){let t=e.trim().replace(/pt$/i,"").trim();if(t==="")return null;let o=Number(t);if(!Number.isFinite(o))return null;let n=Math.round(o*2);return n<Yr||n>Xr?null:n}function GC({className:e,hidden:t}){let o=F(),n=O(WC),{isEnabled:r,disabledReason:i}=se("font.size"),a=ee(),[l,s]=lt.useState(false),[c,d]=lt.useState(null),f=lt.useRef(null),u=lt.useRef(null),g=lt.useCallback(C=>{if(!o)return;let T=editor.commandForSlotValue("font.size",C);T&&o.can(T).ok&&o.exec(T);},[o]),p=lt.useCallback(C=>{g(Math.min(Xr,Math.max(Yr,Math.round(C*2))));},[g]),m=lt.useCallback(C=>{s(false),d(null),u.current?.blur(),C&&o?.focus();},[o]);if(lt.useEffect(()=>{if(!l)return;let C=T=>{let w=f.current;w&&T.target instanceof Node&&w.contains(T.target)||(s(false),d(null));};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[l]),t)return null;let b=r&&n!==null,h=n===null?"\u2014":String(Math.round(n*2)/2),x=c??h,v=n===null?null:Math.round(n*2)/2,y=()=>{if(c===null)return;let C=UC(c);C!==null&&g(C);};return jsxRuntime.jsxs("span",{ref:f,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsxRuntime.jsx(Df,{className:e,groupLabel:a("fontSize.label"),decreaseLabel:a("fontSize.decrease"),increaseLabel:a("fontSize.increase"),middle:jsxRuntime.jsx("input",{ref:u,type:"text",inputMode:"decimal",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--boxed docx-toolbar__font-size-input",value:x,disabled:!r,role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-label":a("fontSize.label"),autoComplete:"off",onChange:C=>{d(C.target.value),s(true);},onFocus:C=>{C.target.select(),s(true);},onClick:()=>s(true),onKeyDown:C=>{C.key==="Enter"?(C.preventDefault(),y(),m(true)):C.key==="Escape"?(C.preventDefault(),m(true)):(C.key==="ArrowDown"||C.key==="ArrowUp")&&(C.preventDefault(),s(true),n!==null&&p(C.key==="ArrowDown"?Mf(n,jr,Yr/2):Rf(n,jr,Xr/2)));},onBlur:()=>{y(),d(null);}}),canDecrease:b&&Math.round(n*2)>Yr,canIncrease:b&&Math.round(n*2)<Xr,onDecrease:()=>p(Mf(n??0,jr,Yr/2)),onIncrease:()=>p(Rf(n??0,jr,Xr/2))}),l&&r?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox","aria-label":a("fontSize.listLabel"),children:jr.map(C=>{let T=v===C;return jsxRuntime.jsx("button",{type:"button",role:"option","aria-selected":T,...T?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>{p(C),m(true);},children:C},C)})}):null]})}var jc=Object.assign(GC,{docxSlot:"font.size"});function jC({className:e,hidden:t}){let o=F(),{zoom:n,isFit:r,mode:i,setZoom:a,setMode:l,zoomIn:s,zoomOut:c,canZoomIn:d,canZoomOut:f,levels:u}=Wc(),g=ee(),[p,m]=lt.useState(false),b=lt.useRef(null);lt.useEffect(()=>{if(!p)return;let T=w=>{let S=b.current;S&&w.target instanceof Node&&S.contains(w.target)||m(false);};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[p]);let h=lt.useCallback(T=>{m(false),a(T);},[a]),x=lt.useCallback(T=>{m(false),l(T==="auto"?"auto":editor.FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let v=`${Math.round(n*100)}%`,y=editor.sameZoomMode(i,editor.AUTO_ZOOM_MODE),C=editor.sameZoomMode(i,editor.FIT_WIDTH_ZOOM_MODE);return jsxRuntime.jsxs("span",{ref:b,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsxRuntime.jsx(Df,{className:e,groupLabel:g("zoom.zoomLevel"),decreaseLabel:g("zoom.zoomOut"),increaseLabel:g("zoom.zoomIn"),middle:jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--menu",disabled:!o,"aria-haspopup":"listbox","aria-expanded":p,"aria-label":g("zoom.zoomLevel"),onMouseDown:Z,onClick:()=>m(T=>!T),children:[v,jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:f,canIncrease:d,onDecrease:c,onIncrease:s}),p?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__zoom-menu",role:"listbox","aria-label":g("zoom.zoomLevel"),children:[jsxRuntime.jsx("button",{type:"button",role:"option","aria-selected":y,...y?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>x("auto"),children:g("zoom.automatic")}),jsxRuntime.jsx("button",{type:"button",role:"option","aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>x("fit-width"),children:g("zoom.fitWidth")}),jsxRuntime.jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(T=>{let w=!r&&Math.abs(T-n)<.001;return jsxRuntime.jsx("button",{type:"button",role:"option","aria-selected":w,...w?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>h(T),children:`${Math.round(T*100)}%`},T)})]}):null]})}var Yc=Object.assign(jC,{docxSlot:"zoom.level"});var JC=[1,1.15,1.5,2,2.5,3],Nf=10,Lf=0,eS=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),tS=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function oS({className:e,hidden:t}){let o=F(),n=O(eS,tS),{isEnabled:r,disabledReason:i}=se("list.lineSpacing"),a=se("paragraph.dialog"),l=Om(),s=ee(),[c,d]=lt.useState(false),f=lt.useRef(null),u=lt.useRef(null);lt.useEffect(()=>{if(!c)return;let v=y=>{let C=f.current;C&&y.target instanceof Node&&C.contains(y.target)||d(false);};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[c]);let g=lt.useCallback(v=>{if(d(false),!o)return;let y=editor.commandForSlotValue("list.lineSpacing",v);y&&o.can(y).ok&&o.exec(y);},[o]),p=lt.useCallback((v,y)=>{if(d(false),!o)return;let C={type:"setParagraphSpacing",[v]:y};o.can(C).ok&&o.exec(C);},[o]);if(t)return null;let m=Q("list.lineSpacing"),b=(n.spaceBeforePt??0)>0,h=(n.spaceAfterPt??0)>0,x=n.lineSpacing?.rule==="multiple"?n.lineSpacing?.value??null:null;return jsxRuntime.jsxs("span",{ref:f,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxRuntime.jsxs("button",{ref:u,type:"button",className:`docx-toolbar__button docx-toolbar__line-spacing-trigger${e?` ${e}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":c,"aria-label":s("lineSpacing.label"),title:i??s("lineSpacing.label"),onMouseDown:Z,onClick:()=>d(v=>!v),children:[oe(m?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),c&&r?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[JC.map(v=>{let y=x===v;return jsxRuntime.jsx("button",{type:"button",role:"menuitemradio","aria-checked":y,...y?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>g(v),children:Number.isInteger(v*10)?v.toFixed(1):v.toFixed(2)},v)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item","data-slot":"paragraph.dialog",disabled:!a.isEnabled,title:a.disabledReason??void 0,onMouseDown:Z,onClick:()=>{d(false),l?.open(u.current);},children:s("lineSpacing.options")}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>p("beforePt",b?Lf:Nf),children:s(b?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>p("afterPt",h?Lf:Nf),children:s(h?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var Qc=Object.assign(oS,{docxSlot:"list.lineSpacing"});var sS=[{value:"C00000",labelKey:"colorPicker.colors.darkRed",css:"#c00000"},{value:"FF0000",labelKey:"colorPicker.colors.red",css:"#ff0000"},{value:"FFC000",labelKey:"colorPicker.colors.orange",css:"#ffc000"},{value:"FFFF00",labelKey:"colorPicker.colors.yellow",css:"#ffff00"},{value:"92D050",labelKey:"colorPicker.colors.lightGreen",css:"#92d050"},{value:"00B050",labelKey:"colorPicker.colors.green",css:"#00b050"},{value:"00B0F0",labelKey:"colorPicker.colors.lightBlue",css:"#00b0f0"},{value:"0070C0",labelKey:"colorPicker.colors.blue",css:"#0070c0"},{value:"002060",labelKey:"colorPicker.colors.darkBlue",css:"#002060"},{value:"7030A0",labelKey:"colorPicker.colors.purple",css:"#7030a0"}],Ff=[{value:"yellow",labelKey:"colorPicker.colors.yellow",css:"#ffff00"},{value:"green",labelKey:"colorPicker.colors.brightGreen",css:"#00ff00"},{value:"cyan",labelKey:"colorPicker.colors.cyan",css:"#00ffff"},{value:"magenta",labelKey:"colorPicker.colors.magenta",css:"#ff00ff"},{value:"blue",labelKey:"colorPicker.colors.blue",css:"#0000ff"},{value:"red",labelKey:"colorPicker.colors.red",css:"#ff0000"},{value:"darkBlue",labelKey:"colorPicker.colors.darkBlue",css:"#000080"},{value:"darkCyan",labelKey:"colorPicker.colors.darkCyan",css:"#008080"},{value:"darkGreen",labelKey:"colorPicker.colors.darkGreen",css:"#008000"},{value:"darkMagenta",labelKey:"colorPicker.colors.darkMagenta",css:"#800080"},{value:"darkRed",labelKey:"colorPicker.colors.darkRed",css:"#800000"},{value:"darkYellow",labelKey:"colorPicker.colors.darkYellow",css:"#808000"},{value:"darkGray",labelKey:"colorPicker.colors.darkGray",css:"#808080"},{value:"lightGray",labelKey:"colorPicker.colors.lightGray",css:"#c0c0c0"},{value:"black",labelKey:"colorPicker.colors.black",css:"#000000"},{value:"white",labelKey:"colorPicker.colors.white",css:"#ffffff"}],Af=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Zi=["colorPicker.theme.background1","colorPicker.theme.text1","colorPicker.theme.background2","colorPicker.theme.text2","colorPicker.theme.accent1","colorPicker.theme.accent2","colorPicker.theme.accent3","colorPicker.theme.accent4","colorPicker.theme.accent5","colorPicker.theme.accent6"],bo=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),ut=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function cS(e){let t=[0,2,4].map(n=>parseInt(e.slice(n,n+2),16)),o=(Math.max(...t)+Math.min(...t))/2/255;return o===1?[ut(5),ut(15),ut(25),ut(35),ut(50)]:o===0?[bo(50),bo(35),bo(25),bo(15),bo(5)]:o>=.8?[ut(10),ut(25),ut(50),ut(75),ut(90)]:[bo(80),bo(60),bo(40),ut(25),ut(50)]}var dS=/^[0-9A-Fa-f]{6}$/;function uS(e,t){let o="";for(let n=0;n<6;n+=2){let r=Math.round(t(parseInt(e.slice(n,n+2),16)));o+=Math.max(0,Math.min(255,r)).toString(16).padStart(2,"0");}return o.toUpperCase()}function pS(e){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),n=parseInt(e.slice(4,6),16);return .299*t+.587*o+.114*n>230}function qi({value:e,css:t,title:o,selected:n,apply:r}){return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch",style:{backgroundColor:t},"aria-label":o,title:o,"data-value":e,...n?{"data-selected":""}:{},...pS(t.replace("#",""))?{"data-light":""}:{},onMouseDown:Z,onClick:()=>r(e)})}function mS({apply:e,label:t,current:o,themeHexes:n}){let r=n.map(cS),i=[0,1,2,3,4];return jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.themeColors")}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--theme",role:"group",children:[n.map((a,l)=>jsxRuntime.jsx(qi,{value:a,css:`#${a.toLowerCase()}`,title:t(Zi[l]),selected:o===a,apply:e},`base-${l}`)),i.map(a=>n.map((l,s)=>{let c=r[s][a],d=uS(l,c.apply);return jsxRuntime.jsx(qi,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Zi[s])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${s}`)}))]})]})}function fS(e){let{apply:t,label:o,current:n}=e,[r,i]=lt.useState(""),a=dS.test(r);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(mS,{...e}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.standardColors")}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid",role:"group",children:sS.map(l=>jsxRuntime.jsx(qi,{value:l.value,css:l.css,title:o(l.labelKey),selected:n===l.value,apply:t},l.value))})]}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.customColor")}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-custom",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-hash","aria-hidden":"true",children:"#"}),jsxRuntime.jsx("input",{type:"text",className:"docx-toolbar__swatch-hex",value:r,maxLength:6,spellCheck:false,"aria-label":o("colorPicker.customColor"),onChange:l=>i(l.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:l=>{l.key==="Enter"&&a&&t(r.toUpperCase());}}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!a,onMouseDown:Z,onClick:()=>t(r.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function ed({apply:e,current:t}){let o=F(),n=ee(),r=o?.getDocumentThemeColors()??[],i=r.length===Zi.length?r.map(l=>l.hex):Af,a=t?.toUpperCase()??null;return jsxRuntime.jsx(fS,{apply:e,label:n,current:a,themeHexes:i})}var gS=Ff.filter(e=>e.value!=="white");function bS({apply:e,label:t,current:o}){return jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.highlightColors")}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--highlight",role:"group",children:gS.map(n=>jsxRuntime.jsx(qi,{value:n.value,css:n.css,title:t(n.labelKey),selected:o===n.value,apply:e},n.value))})]})}function Hf(e){let{slot:t,defaultValue:o,cssOf:n,clear:r,body:i}=e,a=t==="text.color";return Object.assign(({className:s,hidden:c,icon:d})=>{let f=F(),{isEnabled:u,disabledReason:g}=se(t),p=ee(),[m,b]=lt.useState(false),[h,x]=lt.useState(o),v=lt.useRef(null),y=O(R=>{if(a){let D=R.formatting?.color;return D&&D.kind==="hex"?D.value.toUpperCase():null}return R.formatting?.highlight??null}),C=f?.getDocumentThemeColors()??[],T=C.length===Zi.length?C.map(R=>R.hex):Af;lt.useEffect(()=>{if(!m)return;let R=D=>{let _=v.current;_&&D.target instanceof Node&&_.contains(D.target)||b(false);};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[m]);let w=lt.useCallback(R=>{if(b(false),!f)return;let D=editor.commandForSlotValue(t,R);D&&f.can(D).ok&&(f.exec(D),R!==r.value&&x(R));},[f]),S=lt.useMemo(()=>Q(t),[]);if(c)return null;let M=p(S?.labelKey??t);return jsxRuntime.jsxs("div",{ref:v,className:`docx-toolbar__colorsplit${s?` ${s}`:""}`,"data-slot":t,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__colorsplit-main",disabled:!u,...u?{}:{"data-disabled":""},"aria-label":M,title:g??M,onMouseDown:Z,onClick:()=>w(h),children:[d??oe(S?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:n(h)},"aria-hidden":"true"})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!u,...u?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":m,"aria-label":M,title:g??M,onMouseDown:Z,onClick:()=>b(R=>!R),children:"\u25BE"}),m?jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":M,onMouseDown:Z,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:Z,onClick:()=>w(r.value),children:[jsxRuntime.jsx("span",{className:`docx-toolbar__swatch-clear-chip${r.value==="none"?" docx-toolbar__swatch-clear-chip--none":""}`,"aria-hidden":"true"}),p(r.labelKey)]}),i({apply:w,label:p,current:y,themeHexes:T})]}):null]})},{docxSlot:t})}var hS=new Map(Ff.map(e=>[e.value,e.css])),td=Hf({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsxRuntime.jsx(ed,{apply:e.apply,current:e.current})}),od=Hf({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>hS.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsxRuntime.jsx(bS,{...e})});var CS=["alignment.left","alignment.center","alignment.right","alignment.justify"];function SS({className:e,hidden:t}){let o=se("alignment.left"),n=se("alignment.center"),r=se("alignment.right"),i=se("alignment.justify"),a=ee(),[l,s]=lt.useState(false),c=lt.useRef(null);if(lt.useEffect(()=>{if(!l)return;let m=b=>{let h=c.current;h&&b.target instanceof Node&&h.contains(b.target)||s(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),t)return null;let d=[o,n,r,i],f=CS.map((m,b)=>({slot:m,control:Q(m),state:d[b]})),u=f.find(m=>m.state.isActive)??f[0],g=f.some(m=>m.state.isEnabled),p=a(u.control?.labelKey??u.slot);return jsxRuntime.jsxs("div",{ref:c,className:`docx-toolbar__alignment${e?` ${e}`:""}`,"data-slot":"alignment",children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-trigger",disabled:!g,...g?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":l,"aria-label":p,title:g?p:u.state.disabledReason??p,onMouseDown:Z,onClick:()=>s(m=>!m),children:[oe(u.control?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__alignment-popup",children:f.map(m=>{let b=a(m.control?.labelKey??m.slot);return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-option","data-slot":m.slot,disabled:!m.state.isEnabled,...m.state.isActive?{"data-active":""}:{},"aria-pressed":m.state.isActive,"aria-label":b,title:m.state.disabledReason??b,onMouseDown:Z,onClick:()=>{m.state.execute(),s(false);},children:oe(m.control?.paths)},m.slot)})}):null]})}var Ki=Object.assign(SS,{docxSlot:"alignment"});function rd(e){let{label:t,icon:o,active:n,disabled:r,disabledReason:i,onSelect:a,asChild:l,className:s,children:c}=e,d={type:"button",className:`docx-toolbar__button${s?` ${s}`:""}`,disabled:r,...n?{"data-active":""}:{},...r?{"data-disabled":""}:{},...n!==void 0?{"aria-pressed":n}:{},"aria-label":t,title:r?i??t:t,onMouseDown:f=>Z(f),onClick:r?void 0:a};return l?jsxRuntime.jsx(j,{...d,children:c}):jsxRuntime.jsx("button",{...d,children:o??c})}var kS=Object.freeze([]),DS=e=>e.formatting?.fontFamily??null,IS=e=>e;function Vi(){let e=F(),t=O(DS),o=O(IS),n=lt.useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():kS,[e,o]),{isEnabled:r}=se("font.family"),i=lt.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return lt.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var Kf=lt.createContext(null);function id(){return lt.useContext(Kf)}function ld({asChild:e,className:t,children:o}){let n=id(),r=ee();if(!n)return null;let i=r(Q("font.family")?.labelKey??"font.family"),a={onClick:()=>n.setOpen(!n.open),onMouseDown:Z,disabled:!n.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,"aria-label":i,title:i},l=o??jsxRuntime.jsx("span",{children:n.value??"\u2014"});return e?jsxRuntime.jsx(j,{...a,children:l}):jsxRuntime.jsx("button",{type:"button",...a,children:l})}ld.docxToolbarPart=true;var _S=new Map([["arial","sansSerif"],["calibri","sansSerif"],["helvetica","sansSerif"],["verdana","sansSerif"],["open sans","sansSerif"],["roboto","sansSerif"],["times new roman","serif"],["georgia","serif"],["cambria","serif"],["garamond","serif"],["courier new","monospace"],["consolas","monospace"]]),NS=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function zf({asChild:e,className:t,children:o}){let n=id(),r=ee(),[i,a]=lt.useState("");if(lt.useEffect(()=>{n?.open||a("");},[n?.open]),!n||!n.open)return null;let l={role:"listbox",className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`},s;return o!==void 0?s=o:s=NS.map(d=>({...d,fonts:n.options.filter(f=>f.toLowerCase().includes(i.toLowerCase())&&(_S.get(f.toLowerCase())??"other")===d.category)})).filter(d=>d.fonts.length>0).map((d,f)=>jsxRuntime.jsxs("div",{role:"group",children:[f>0?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}):null,d.labelKey?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-label",children:r(d.labelKey)}):null,d.fonts.map(u=>jsxRuntime.jsx(Vf,{value:u},u))]},d.category)),e?jsxRuntime.jsx(j,{...l,children:s}):o!==void 0?jsxRuntime.jsx("div",{...l,children:s}):jsxRuntime.jsxs("div",{className:l.className,children:[jsxRuntime.jsx("input",{type:"search",className:"docx-toolbar__font-search","aria-label":r("font.search"),placeholder:r("font.search"),value:i,onChange:c=>a(c.target.value)}),jsxRuntime.jsx("div",{role:"listbox",className:"docx-toolbar__font-options",children:s})]})}function Vf({value:e,asChild:t,className:o,children:n}){let r=F(),i=id();if(!i)return null;let a=i.value===e,l={role:"option","aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:Z,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__font-family-item${o?` ${o}`:""}`},s=n??jsxRuntime.jsx("span",{style:{fontFamily:e},children:e});return t?jsxRuntime.jsx(j,{...l,children:s}):jsxRuntime.jsxs("button",{type:"button",...l,children:[s,a?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function LS({hidden:e,asChild:t,className:o,children:n}){let r=Vi(),[i,a]=lt.useState(false),l=lt.useRef(null);lt.useEffect(()=>{if(!i)return;let f=u=>{let g=l.current;g&&u.target instanceof Node&&g.contains(u.target)||a(false);};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i]);let s=lt.useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);if(e)return null;let c={className:`docx-toolbar__font-family${o?` ${o}`:""}`,"data-slot":"font.family"},d=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ld,{}),jsxRuntime.jsx(zf,{})]});return jsxRuntime.jsx(Kf.Provider,{value:s,children:t?jsxRuntime.jsx(j,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var sd=Object.assign(LS,{docxSlot:"font.family",Trigger:ld,Content:zf,Item:Vf});var AS={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},HS=new Set(["Title","Heading1","Heading2","Heading3"]),OS={Subtitle:"666666"},BS="#4a6c8c";function $f(e){let t=AS[e.styleId],n={fontSize:t?`${t}px`:`${Math.min(Math.max(e.fontSize?e.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(e.bold??HS.has(e.styleId))&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic");let r=e.color??OS[e.styleId];return r?n.color=`#${r}`:e.styleId.startsWith("Heading")&&(n.color=BS),n}var ZS=/^heading ([1-9])$/;function cd(e,t){let o=e||t,n=ZS.exec(o);return n?`Heading ${n[1]}`:o}function Wf(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:cd(t.name,t.styleId),priority:99}))}function GS(e){let t=e.fontSizePt;return {...e.fontFamily?{fontFamily:e.fontFamily}:{},...t?{fontSize:`${Math.min(Math.max(t,9),20)}px`}:{},...e.bold?{fontWeight:700}:{},...e.italic?{fontStyle:"italic"}:{},...e.color?{color:`#${e.color}`}:{}}}var jS=Object.freeze([]),YS=e=>e.formatting?.styleId??null,XS=e=>e;function $i(){let e=F(),t=O(YS),o=O(XS),n=lt.useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(a=>a.type==="paragraph").map(a=>({styleId:a.styleId,name:cd(a.name,a.styleId),preview:a.preview})):jS,[e,o]),{isEnabled:r}=se("styles.style"),i=lt.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("styles.style",a);l&&e.can(l).ok&&e.exec(l);},[e]);return lt.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var Uf=lt.createContext(null);function ud(){return lt.useContext(Uf)}function pd({asChild:e,className:t,children:o}){let n=ud(),r=ee();if(!n)return null;let i=Q("styles.style"),a=r(i?.labelKey??"styles.style"),l={onClick:()=>n.setOpen(!n.open),onMouseDown:Z,disabled:!n.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,"aria-label":a,title:a},s=n.options.find(d=>d.styleId===n.value),c=o??(n.value===null?jsxRuntime.jsx("span",{children:i?.valueKey?r(i.valueKey):"\u2014"}):jsxRuntime.jsx("span",{children:s?.name??n.value}));return e?jsxRuntime.jsx(j,{...l,children:c}):jsxRuntime.jsx("button",{type:"button",...l,children:c})}pd.docxToolbarPart=true;function Gf({asChild:e,className:t,children:o}){let n=ud();if(!n||!n.open)return null;let r={role:"listbox",className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`},i=o??n.options.map(a=>jsxRuntime.jsx(jf,{value:a.styleId},a.styleId));return e?jsxRuntime.jsx(j,{...r,children:i}):jsxRuntime.jsx("div",{...r,children:i})}function jf({value:e,asChild:t,className:o,children:n}){let r=ud();if(!r)return null;let i=r.value===e,a=r.options.find(c=>c.styleId===e),l={role:"option","aria-selected":i,...i?{"data-selected":""}:{},onMouseDown:Z,onClick:()=>{r.setValue(e),r.setOpen(false);},className:`docx-toolbar__style-item${o?` ${o}`:""}`},s=n??jsxRuntime.jsx("span",{style:a?GS(a.preview):void 0,children:a?.name??e});return t?jsxRuntime.jsx(j,{...l,children:s}):jsxRuntime.jsxs("button",{type:"button",...l,children:[s,i?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function QS({hidden:e,asChild:t,className:o,children:n}){let r=$i(),[i,a]=lt.useState(false),l=lt.useRef(null);lt.useEffect(()=>{if(!i)return;let f=u=>{let g=l.current;g&&u.target instanceof Node&&g.contains(u.target)||a(false);};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i]);let s=lt.useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);if(e)return null;let c={className:`docx-toolbar__style${o?` ${o}`:""}`,"data-slot":"styles.style"},d=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(pd,{}),jsxRuntime.jsx(Gf,{})]});return jsxRuntime.jsx(Uf.Provider,{value:s,children:t?jsxRuntime.jsx(j,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var md=Object.assign(QS,{docxSlot:"styles.style",Trigger:pd,Content:Gf,Item:jf});function Xf(e,t){let o=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:l,children:s})=>{let{isEnabled:c,disabledReason:d}=se(o),f=Mt(),u=t==="showAll"?f.showAll:f.formFill,g=ee();if(i)return null;let p=Q(o),m=g(p?.labelKey??e),b={type:"button",className:`docx-toolbar__button${r?` ${r}`:""}`,"data-slot":e,disabled:!c,...c?{}:{"data-disabled":""},...u?{"data-active":""}:{},"aria-pressed":u,"aria-label":m,title:d??m,onMouseDown:Z,onClick:()=>{t==="showAll"?f.toggleShowAll():f.toggleFormFill();}};return l?jsxRuntime.jsx(j,{...b,children:s}):jsxRuntime.jsx("button",{...b,children:a??s??oe(p?.paths)})},{docxSlot:o})}function eP({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=et.inspector,{isEnabled:a,disabledReason:l}=se(i),{inspectorOpen:s,openInspector:c}=Mt(),d=ee();if(t)return null;let f=Q(i),u=d(f?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":et.inspector,disabled:!a,...a?{}:{"data-disabled":""},...s?{"data-active":""}:{},"aria-pressed":s,"aria-label":u,title:l??u,onMouseDown:Z,onClick:()=>c()};return n?jsxRuntime.jsx(j,{...g,children:r}):jsxRuntime.jsx("button",{...g,children:o??r??oe(f?.paths)})}function tP({className:e,hidden:t,icon:o,asChild:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l}=Mt(),s=ee();if(t)return null;let c=et.remove,d=Q(c),f=s(d?.labelKey??"contentControl.remove"),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":et.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":f,title:a??f,onMouseDown:Z,onClick:()=>{l();}};return n?jsxRuntime.jsx(j,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??oe(d?.paths)})}var Wi=Xf(et.showAll,"showAll"),Ui=Xf(et.formFill,"formFill"),Gi=Object.assign(tP,{docxSlot:et.remove}),ji=Object.assign(eP,{docxSlot:et.inspector}),Qf={[et.showAll]:Wi,[et.formFill]:Ui,[et.inspector]:ji,[et.remove]:Gi};function fd(e,t){let o=F(),n=lt.useRef(t);n.current=t,lt.useEffect(()=>{if(!o)return;let r=((...i)=>{n.current(...i);});return o.on(e,r)},[o,e]);}var sP=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],bd=lt.createContext(null);function ag(){let e=lt.useContext(bd);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function dP(e,t){let o=t.table,r=(e?.getSelectedTable()??null)?.blockId??"",i=o?`${r}|${o.rows}|${o.columns}|${o.rowIndex}|${o.columnIndex}`:"",a=t.selection,l=a?`${a.from&&"paraId"in a.from?a.from.paraId:""}|${a.to&&"paraId"in a.to?a.to.paraId:""}|${t.selectionCollapsed}`:"",s=e?.getTableCellSelection()??null,c=s?`${s.tableId}|${s.rows.from}-${s.rows.to}|${s.columns.from}-${s.columns.to}|${s.cellIds.join(",")}`:"";return {tableKey:i,selectionKey:l,cellSelectionKey:c,editable:t.editable,editingMode:t.editingMode??"editing"}}function uP(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function pP(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var ng={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function mP(e,t){let o={};for(let n of sP){let r=editor.tableChromeToolbarState(e,n,t);o[n]={enabled:r.enabled,disabledReason:r.disabledReason};}return o}function hd({children:e}){let t=F(),[o,n]=lt.useState(editor.DEFAULT_TABLE_CHROME_DRAFT),[r,i]=lt.useState(ng);lt.useEffect(()=>(()=>{}),[]);let a=O(lt.useCallback(u=>({table:u.table,editable:u.editable,editingMode:u.editingMode??"editing",headParagraphId:u.selection?.to&&"paraId"in u.selection.to?u.selection.to.paraId:u.selection?.from&&"paraId"in u.selection.from?u.selection.from.paraId:""}),[]),uP,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=lt.useCallback(()=>{if(!t){i(ng);return}let u=dP(t,t.snapshot());i(g=>pP(g,u)?g:u);},[t]);lt.useEffect(()=>{l();},[l,a]),fd("selectionChange",lt.useCallback(()=>{l();},[l]));let s=r.tableKey!=="",c=lt.useMemo(()=>t?mP(t,o):{},[t,o,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=lt.useCallback((u,g)=>{if(!t)return;let{result:p,nextDraft:m}=editor.runTableChromeCommand(t,u,g,o);p.ok&&m&&n(m);},[t,o]),f=lt.useMemo(()=>({visible:s,draft:o,setDraft:n,slotState:u=>c[u]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[s,o,c,d]);return jsxRuntime.jsx(bd.Provider,{value:f,children:e})}function fP(){let e=lt.useContext(bd);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function Xi(e){let t=fP(),o=t.slotState(e);return lt.useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:n=>t.apply(e,n)}),[t,e,o])}function Qi(e){let t=e?.closest(".docx-editor")??null;for(;t&&!t.querySelector(".docx-pages");)t=t.parentElement?.closest(".docx-editor")??null;return t}function Ji(e){(Qi(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function yd(e,t,o){lt.useEffect(()=>{if(!e)return;let n=r=>{let i=o.current;i&&r.target instanceof Node&&i.contains(r.target)||t(false);};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[e,t,o]);}function el({enabled:e,disabledReason:t,ariaLabel:o}){let{t:n}=L(),r=i18n.localizeDisabledReason(t,n),i=lt.useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:Z,"aria-label":o,...a?{"aria-describedby":a}:{},...r?{title:r}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:a&&r?jsxRuntime.jsx("span",{id:i,className:"docx-editor-sr-only",children:r}):null}}var vP='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function ig(e,t,o,n){lt.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll(vP)].filter(c=>c.closest('[role="menu"]')===r);queueMicrotask(()=>{let c=a();(c.find(f=>f.hasAttribute("data-selected")||f.hasAttribute("data-active"))??c[0])?.focus();});let s=c=>{let d=a();if(c.key==="Escape"){c.preventDefault(),t(false),i?.focus();return}if(c.key==="ArrowDown"){c.preventDefault(),vt(d,document.activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),vt(d,document.activeElement,-1);return}if(c.key==="Home"){c.preventDefault(),yt(d,"first");return}if(c.key==="End"){c.preventDefault(),yt(d,"last");return}if(c.key==="Enter"||c.key===" "){let f=document.activeElement;f instanceof HTMLElement&&d.includes(f)&&(c.preventDefault(),f.click());}};return r.addEventListener("keydown",s),()=>r.removeEventListener("keydown",s)},[e,t,o,n]);}function lg(e,t,o,n){lt.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll('button:not([aria-disabled="true"])')].filter(s=>s.closest('[role="dialog"]')===r);queueMicrotask(()=>{a()[0]?.focus();});let l=s=>{if(s.key==="Escape"){s.preventDefault(),t(false),i?.focus();return}if(s.key==="Enter"||s.key===" "){let c=document.activeElement,d=a();c instanceof HTMLElement&&d.includes(c)&&(s.preventDefault(),c.click());}};return r.addEventListener("keydown",l),()=>r.removeEventListener("keydown",l)},[e,t,o,n]);}function pg(e,t,o){if(e)return n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),o(!t));}}function EP(e){return oe(editor.tableChromeIconPaths(e))}function mg(){return lt.createContext(null)}function Xt(e){let t=lt.useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function Td(e,t,o){let n=mg();function r({hidden:l,asChild:s,className:c,children:d}){let{visible:f,enabled:u,disabledReason:g,draft:p,apply:m}=Xi(e),[b,h]=lt.useState(false),x=lt.useRef(null),v=lt.useRef(null);yd(b,h,x);let y=lt.useMemo(()=>({open:b,setOpen:h,enabled:u,disabledReason:g,apply:m,draft:p,triggerRef:v}),[b,u,g,m,p]);if(l||!f)return null;let C={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},T=d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(i,{}),jsxRuntime.jsx(a,{})]});return jsxRuntime.jsx(n.Provider,{value:y,children:s?jsxRuntime.jsx(j,{...C,ref:x,children:T}):jsxRuntime.jsx("div",{ref:x,...C,children:T})})}function i({asChild:l,className:s,children:c}){let{open:d,setOpen:f,enabled:u,disabledReason:g,triggerRef:p}=Xt(n),m=ee(),b=Q(e),h=m(b?.labelKey??o),{shared:x,reasonNode:v}=el({enabled:u,disabledReason:g,ariaLabel:h}),y={...x,ref:p,className:`docx-toolbar__button docx-table-chrome__trigger${s?` ${s}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:u?()=>f(!d):void 0,...l?{tabIndex:u?0:-1,role:"button",onKeyDown:pg(u,d,f)}:{}},C=c??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[oe(b?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(j,{...y,children:C}),v]}):jsxRuntime.jsxs("button",{...y,children:[C,v]})}i.docxToolbarPart=true;function a({asChild:l,className:s,children:c}){let{open:d,setOpen:f,enabled:u,triggerRef:g}=Xt(n),p=ee(),m=lt.useRef(null);if(ig(d&&u,f,m,g),!d||!u)return null;let b=Q(e),h=p(b?.labelKey??o),x={ref:m,role:"menu","aria-label":h,className:`docx-table-chrome__panel${s?` ${s}`:""}`,onMouseDown:Z};return l?jsxRuntime.jsx(j,{...x,children:c}):jsxRuntime.jsx("div",{...x,children:c})}return {Root:r,Trigger:i,Content:a,Ctx:n}}var ea=Td("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function fg({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xt(ea.Ctx),l=ee(),s=editor.TABLE_BORDER_TARGET_OPTIONS.find(u=>u.value===e);if(!s)return null;let c=s.value==="none"?false:s.value===a.activeTarget,d={type:"button",role:"menuitemradio","aria-checked":c,"data-value":s.value,className:`docx-table-chrome__target-btn${o?` ${o}`:""}`,...c?{"data-active":""}:{},"aria-label":l(s.labelKey),title:l(s.labelKey),onMouseDown:Z,onClick:()=>{i(false),r(s.value);}},f=n??EP(s.icon);return t?jsxRuntime.jsx(j,{...d,children:f}):jsxRuntime.jsx("button",{...d,children:f})}function gg(e){let{children:t}=e;return jsxRuntime.jsx(ea.Content,{...e,children:t??jsxRuntime.jsx("div",{className:"docx-table-chrome__target-grid",children:editor.TABLE_BORDER_TARGET_OPTIONS.map(o=>jsxRuntime.jsx(fg,{value:o.value},o.value))})})}function wP(e){let{children:t}=e,o=t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ea.Trigger,{}),jsxRuntime.jsx(gg,{})]});return jsxRuntime.jsx(ea.Root,{...e,children:o})}var aa=Object.assign(wP,{docxSlot:"table.borderTarget",Trigger:ea.Trigger,Content:gg,Item:fg}),ta=Td("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function bg({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xt(ta.Ctx),l=ee(),s=editor.TABLE_BORDER_STYLE_OPTIONS.find(u=>u.value===e);if(!s)return null;let c=s.value===a.spec.style,d={type:"button",role:"menuitemradio","aria-checked":c,...c?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:Z,onClick:()=>{i(false),r(s.value);}},f=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:`docx-table-line ${s.previewClass}`,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l(s.labelKey)})]});return t?jsxRuntime.jsx(j,{...d,children:f}):jsxRuntime.jsx("button",{...d,children:f})}function hg(e){let{children:t}=e;return jsxRuntime.jsx(ta.Content,{...e,children:t??editor.TABLE_BORDER_STYLE_OPTIONS.map(o=>jsxRuntime.jsx(bg,{value:o.value},o.value))})}function RP(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ta.Trigger,{}),jsxRuntime.jsx(hg,{})]});return jsxRuntime.jsx(ta.Root,{...e,children:t})}var ia=Object.assign(RP,{docxSlot:"table.borderStyle",Trigger:ta.Trigger,Content:hg,Item:bg}),oa=Td("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function vg({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xt(oa.Ctx),l=ee(),s=Number(e),c=editor.TABLE_BORDER_WIDTH_OPTIONS.find(g=>g.size===s);if(!c)return null;let d=c.size===a.spec.size,f={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:Z,onClick:()=>{i(false),r(c.size);}},u=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"docx-table-line docx-table-line--single",style:{height:`${c.previewThickness}px`},"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l(c.labelKey)})]});return t?jsxRuntime.jsx(j,{...f,children:u}):jsxRuntime.jsx("button",{...f,children:u})}function yg(e){let{children:t}=e;return jsxRuntime.jsx(oa.Content,{...e,children:t??editor.TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsxRuntime.jsx(vg,{value:String(o.size)},o.size))})}function MP(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(oa.Trigger,{}),jsxRuntime.jsx(yg,{})]});return jsxRuntime.jsx(oa.Root,{...e,children:t})}var la=Object.assign(MP,{docxSlot:"table.borderWidth",Trigger:oa.Trigger,Content:yg,Item:vg});function xg(e,t,o){let n=o?.defaultHex??"FF0000",r=mg();function i({hidden:d,asChild:f,className:u,children:g}){let{visible:p,enabled:m,disabledReason:b,draft:h,apply:x}=Xi(e),[v,y]=lt.useState(false),[C,T]=lt.useState(n),w=lt.useRef(null),S=lt.useRef(null);yd(v,y,w);let M=lt.useMemo(()=>({open:v,setOpen:y,enabled:m,disabledReason:b,apply:x,draft:h,triggerRef:S,lastHex:C,setLastHex:T}),[v,m,b,x,h,C]);if(d||!p)return null;let R={className:`docx-toolbar__colorsplit docx-table-chrome${u?` ${u}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},D=g??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(a,{}),jsxRuntime.jsx(l,{}),jsxRuntime.jsx(s,{clearFill:o?.clearFill??false})]});return jsxRuntime.jsx(r.Provider,{value:M,children:f?jsxRuntime.jsx(j,{...R,ref:w,children:D}):jsxRuntime.jsx("div",{ref:w,...R,children:D})})}function a({asChild:d,className:f,children:u}){let{enabled:g,disabledReason:p,apply:m,draft:b,lastHex:h}=Xt(r),x=ee(),v=Q(e),y=x(v?.labelKey??t),{shared:C,reasonNode:T}=el({enabled:g,disabledReason:p,ariaLabel:y}),w=e==="table.borderColor"&&b.spec.color.kind==="hex"?b.spec.color.value:h??n,S={...C,className:`docx-toolbar__button docx-toolbar__colorsplit-main${f?` ${f}`:""}`,onClick:g?()=>m({kind:"hex",value:w}):void 0},M=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[oe(v?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${w.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(j,{...S,children:M}),T]}):jsxRuntime.jsxs("button",{...S,children:[M,T]})}a.docxToolbarPart=true;function l({asChild:d,className:f,children:u}){let{open:g,setOpen:p,enabled:m,disabledReason:b,triggerRef:h}=Xt(r),x=ee(),v=Q(e),y=x(v?.labelKey??t),{shared:C,reasonNode:T}=el({enabled:m,disabledReason:b,ariaLabel:y}),w={...C,ref:h,className:`docx-toolbar__colorsplit-caret${f?` ${f}`:""}`,"aria-haspopup":"dialog","aria-expanded":g,onClick:m?()=>p(!g):void 0,...d?{tabIndex:m?0:-1,role:"button",onKeyDown:pg(m,g,p)}:{}},S=u??"\u25BE";return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(j,{...w,children:S}),T]}):jsxRuntime.jsxs("button",{...w,children:[S,T]})}l.docxToolbarPart=true;function s({asChild:d,className:f,children:u,clearFill:g}){let{open:p,setOpen:m,enabled:b,apply:h,draft:x,triggerRef:v,lastHex:y,setLastHex:C}=Xt(r),T=ee(),w=lt.useRef(null);if(lg(p&&b,m,w,v),!p||!b)return null;let S=T(t),M=e==="table.borderColor"&&x.spec.color.kind==="hex"?x.spec.color.value:y??n,R={ref:w,role:"dialog","aria-label":S,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${f?` ${f}`:""}`,onMouseDown:Z},D=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g?jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:Z,onClick:()=>{m(false),h(null),Ji(v.current);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),T("table.clearCellFill")]}):null,jsxRuntime.jsx(ed,{apply:_=>{m(false),C?.(_),h({kind:"hex",value:_}),Ji(v.current);},current:M})]});return d?jsxRuntime.jsx(j,{...R,children:D}):jsxRuntime.jsx("div",{...R,children:D})}function c({value:d,css:f,labelKey:u,asChild:g,className:p,children:m}){let{apply:b,setOpen:h,setLastHex:x,triggerRef:v}=Xt(r),y=ee(),C=f??`#${d.toLowerCase()}`,T=u?y(u):d,w={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:C},"data-value":d,"aria-label":T,title:T,onMouseDown:Z,onClick:()=>{h(false),x?.(d),b({kind:"hex",value:d}),Ji(v.current);}};return g?jsxRuntime.jsx(j,{...w,children:m}):jsxRuntime.jsx("button",{...w,children:m})}return {Root:i,Main:a,Trigger:l,Content:s,Item:c,Ctx:r}}var na=xg("table.borderColor","table.borderColor",{defaultHex:"000000"});function kP(e){return jsxRuntime.jsx(na.Content,{...e,clearFill:false})}function DP(e){return jsxRuntime.jsx(na.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function IP(e){return jsxRuntime.jsx(na.Root,{...e})}var sa=Object.assign(IP,{docxSlot:"table.borderColor",Trigger:na.Trigger,Content:kP,Item:DP,Main:na.Main}),ra=xg("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function _P(e){return jsxRuntime.jsx(ra.Content,{...e,clearFill:true})}function NP(e){return jsxRuntime.jsx(ra.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function LP(e){return jsxRuntime.jsx(ra.Root,{...e})}var ca=Object.assign(LP,{docxSlot:"table.cellFill",Trigger:ra.Trigger,Content:_P,Item:NP,Main:ra.Main});function Tg({overrides:e=new Map,separator:t=true}){return ag()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx(Yo,{}):null,[aa,sa,ia,la,ca].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(lt.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)})]}):null}function Cg(){let e=ee(),{draft:t}=Xi("table.borderTarget");return e(editor.tableChromeLabelKeyForTarget(t.activeTarget))}var Pd=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],nl="contextual-table",Ed={"zoom.level":Yc,"styles.style":md,"font.family":sd,"font.size":jc,"text.color":td,"text.highlight":od,"text.link":Vc,"list.lineSpacing":Qc,"review.editingMode":Ni,"review.authors":Fi,"file.save":$c,...Qf,"table.borderTarget":aa,"table.borderColor":sa,"table.borderStyle":ia,"table.borderWidth":la,"table.cellFill":ca,"image.insert":xr,"image.properties":Bn,"image.wrap":Ur,"image.altText":Lr},tl={id:nl,labelKey:"formattingBar.groups.table",entries:Pd.map(e=>({slot:e,Part:Ed[e]}))},Sg=new Map;function HP(e){let t=Sg.get(e);return t||(t=o=>jsxRuntime.jsx(Do,{slot:e,...o}),Sg.set(e,t)),t}function OP(e){return editor.formattingBarChromeGroups(e).map(t=>t.id==="alignment"?{id:t.id,labelKey:t.labelKey,entries:[{slot:"alignment",Part:Ki}]}:{id:t.id,labelKey:t.labelKey,entries:t.controls.map(o=>{let n=editor.chromeSlotId(t,o);return {slot:n,Part:Ed[n]??HP(n)}})})}var BP=e=>e.image,ZP=e=>e.isLoading||e.isOpening===true,qP=e=>e.table!==null;function KP(e){return e==="alignment"||e in Ed}function al(e){let t=Pn(e,al);if(t!==null)return t;if(!lt.isValidElement(e))return null;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxToolbarPart===true){let n=e.props.slot;if(typeof n=="string")return n}return null}function Cd(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(Cd);let t=al(e);return t!=null&&Pd.includes(t)?true:lt.isValidElement(e)?lt.Children.toArray(e.props.children).some(Cd):false}function zP(e,t){return t?true:lt.Children.toArray(e).some(Cd)}function VP(e){let t=it(),{className:o,t:n,onSave:r,preset:i=true,overflow:a=true,children:l}=e,s=lt.useMemo(()=>({t:n,onSave:r}),[n,r]),c=Za(n),d=O(BP),f=O(ZP),u=O(qP),g=lt.useMemo(()=>OP(d),[d]),p=lt.useMemo(()=>new Set(g.flatMap(C=>C.entries.map(T=>T.slot))),[g]),m=lt.useMemo(()=>[...g.map(C=>C.id).filter(C=>!Ac.has(C)),...u?[nl]:[]],[g,u]),b=lt.useMemo(()=>qm(m),[m]),h=i&&a,{attach:x,overflow:v}=Xm(h,m,b),y;if(!i)y=l;else {let C=lt.Children.toArray(l),T=new Map,w=new Map,S=[];for(let I of C){let P=al(I);P&&p.has(P)?T.set(P,I):P&&Pd.includes(P)?w.set(P,I):S.push(I);}let M=I=>{let P=T.get(I.slot);if(P)return P;let k=I.Part;return jsxRuntime.jsx(k,{})},R=I=>{let P=w.get(I.slot);if(P)return P;let k=I.Part;return jsxRuntime.jsx(k,{})},D=[],_=[],H=0;for(let I of g){if(v.has(I.id)){let k=I.entries.flatMap(Y=>{let z=Pg(Y,T,c,I.labelKey,M);return z===null?[]:[jsxRuntime.jsx(lt.Fragment,{children:z},Y.slot)]});if(k.length===0)continue;_.push({id:I.id,labelKey:I.labelKey,children:k});continue}H>0&&D.push(jsxRuntime.jsx(Yo,{},`separator-${I.id}`)),H+=1;let P=Ac.has(I.id);D.push(jsxRuntime.jsx("div",{className:"docx-toolbar__group",...P?{[Wr]:""}:{[Wn]:I.id},children:I.entries.map(k=>jsxRuntime.jsx(lt.Fragment,{children:M(k)},k.slot))},I.id));}let N=v.has(nl);if(u&&N){let I=tl.entries.flatMap(P=>{let k=Pg(P,w,c,tl.labelKey,R);return k===null?[]:[jsxRuntime.jsx(lt.Fragment,{children:k},P.slot)]});I.length>0&&_.unshift({id:tl.id,labelKey:tl.labelKey,children:I});}y=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[D,u&&!N?jsxRuntime.jsx(Yo,{},"separator-contextual-table"):null,N?null:jsxRuntime.jsx("div",{className:"docx-toolbar__contextual",[Wn]:nl,children:jsxRuntime.jsx(Tg,{overrides:w,separator:false})}),S.length>0?jsxRuntime.jsx("div",{className:"docx-toolbar__group",[Wr]:"",children:S}):null,_.length>0?jsxRuntime.jsx(of,{sections:_}):null]});}return jsxRuntime.jsx(ko.Provider,{value:s,children:jsxRuntime.jsx(Hm,{children:jsxRuntime.jsx("fieldset",{ref:x,disabled:f,role:"toolbar","data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,...h?{"data-overflow":""}:{},onMouseDown:Z,children:zP(l,i)?jsxRuntime.jsx(hd,{children:y}):y})})})}function Eg(e){if(!e)return false;if(e.type===lt.Fragment){let t=lt.Children.toArray(e.props.children).find(o=>al(o)!==null);return lt.isValidElement(t)?Eg(t):false}return !!e.props.hidden}function Pg(e,t,o,n,r){let i=t.get(e.slot);return Eg(i)?null:i||KP(e.slot)?jsxRuntime.jsx(ef,{label:$P(o,e,n),children:r(e)}):jsxRuntime.jsx(tf,{slot:e.slot})}function $P(e,t,o){let n=t.slot==="alignment"?null:Q(t.slot);return e(n?.labelKey??o)}var ua=Object.assign(VP,{Button:Do,Action:rd,Separator:Yo,Undo:nf,Redo:rf,Bold:af,Italic:lf,Underline:sf,Strike:cf,Link:Vc,ClearFormatting:df,Superscript:uf,Subscript:pf,Alignment:Ki,AlignLeft:mf,AlignCenter:ff,AlignRight:gf,AlignJustify:bf,LineSpacing:Qc,BulletList:hf,NumberedList:vf,Outdent:yf,Indent:xf,ImageInsert:xr,ImageProperties:Bn,ImageWrap:Ur,ImageAltText:Lr,TableInsert:Tf,TableBorderTarget:aa,TableBorderColor:sa,TableBorderStyle:ia,TableBorderWidth:la,TableCellFill:ca,Comments:Cf,FontFamily:sd,FontSize:jc,FontColor:td,Highlight:od,Zoom:Yc,StylePicker:md,EditingMode:Ni,Reviewers:Fi,Save:$c,ContentControlShowAll:Wi,ContentControlFormFill:Ui,ContentControlInspector:ji,ContentControlRemove:Gi});var GP=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i,jP=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g;var wg=new TextEncoder;function YP(e,t){if(wg.encode(e).length<=t)return e;let o=0,n="";for(let r of e){let i=wg.encode(r).length;if(o+i>t)break;o+=i,n+=r;}return n}function Rg(e){let t=YP((e??"").replace(/\.docx$/i,"").replace(jP," ").replace(/\s+/g," ").trim().replace(/^[.\s]+/,"").replace(/[.\s]+$/,""),200).trim();return !t||GP.test(t)?"document.docx":`${t}.docx`}function Mg(e,t){let o=URL.createObjectURL(new Blob([e],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})),n=document.createElement("a");n.href=o,n.download=t,n.click(),setTimeout(()=>URL.revokeObjectURL(o),0);}var JP=e=>e.hiddenReviewAuthors??[];function il({className:e,hidden:t}){let o=F(),n=Vr(),r=O(JP),i=ke(),{t:a}=L();if(t)return null;let l=i("reviewers.label"),s=editor.toolbarCommandState(o,"review.authors"),c=i18n.localizeDisabledReason(s.disabledReason,a);if(!s.enabled)return jsxRuntime.jsx(De,{disabled:true,title:c??void 0,slot:"review.authors",children:l});let d=new Set(r),f=n.every(u=>!d.has(u.author));return jsxRuntime.jsxs(kt,{labelKey:"reviewers.label",className:e,children:[jsxRuntime.jsx(kg,{checked:f,label:i("reviewers.all"),slot:"reviewer-all",onChoose:()=>o?.setAllReviewAuthorsVisible(!f)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),n.map(u=>jsxRuntime.jsx(kg,{checked:!d.has(u.author),label:u.author||"\u2014",slot:`reviewer-${u.slot}`,onChoose:()=>o?.setReviewAuthorVisible(u.author,d.has(u.author))},u.author))]})}function kg(e){return jsxRuntime.jsx(De,{active:e.checked,slot:e.slot,className:"docx-menubar__reviewer-item",icon:jsxRuntime.jsx("span",{className:"docx-menubar__reviewer-check",children:e.checked?"\u2713":""}),onSelect:e.onChoose,children:e.label})}function eE({children:e,...t}){return jsxRuntime.jsxs(lo,{id:"review",...t,children:[jsxRuntime.jsx(kt,{labelKey:"reviewers.markupOptions",className:"docx-menubar__markup-options",children:jsxRuntime.jsx(il,{className:"docx-menubar__reviewers-submenu"})}),e]})}var ll=Object.assign(eE,{docxMenu:"review"});var nE={file:Fs,format:As,insert:Hs,review:ll,help:Os},rE=new Set(editor.CHROME_MENUS.map(e=>e.id));function Hg(e){if(!lt.isValidElement(e))return null;if(e.type===lt.Fragment){let n=lt.Children.toArray(e.props.children).map(Hg).filter(r=>r!==null);return n.length===1?n[0]:null}let t=e.type;if((typeof t=="function"||typeof t=="object")&&typeof t.docxMenu=="string")return t.docxMenu;if(e.type===lo){let o=e.props.id;if(typeof o=="string"&&rE.has(o))return o}return null}function aE(e){let t=Hr(),o=it(),{className:n,t:r,fileName:i,onOpen:a,onOpenFile:l,onSave:s,onPageSetup:c,onReportIssue:d,reportIssue:f,preset:u=true,children:g}=e,p=F(),{t:m}=L(),[b,h]=lt.useState(null),[x,v]=lt.useState(null),[y,C]=lt.useState(null),[T,w]=lt.useState(false),[S,M]=lt.useState(false),R=lt.useRef(null),D=lt.useRef(null);lt.useEffect(()=>{if(b===null)return;let V=B=>{let J=R.current;J&&B.target instanceof Node&&J.contains(B.target)||h(null);},te=B=>{B.key==="Escape"&&h(null);};return document.addEventListener("mousedown",V),document.addEventListener("keydown",te),()=>{document.removeEventListener("mousedown",V),document.removeEventListener("keydown",te);}},[b]);let _=lt.useCallback(V=>{h(V),V!==null&&C(V);},[]),H=lt.useCallback(()=>D.current?.click(),[]),N=lt.useCallback(()=>{p&&p.save().then(V=>Mg(V,Rg(i??x??void 0))).catch(V=>{console.error("[docx-editor] save failed",V);});},[p,i,x]),I=lt.useCallback(()=>t?t.open("pageSetup",R.current?.querySelector('[data-menu="file"] > [role="menuitem"]')):w(true),[t]),P=p?a??H:void 0,k=p?s??N:void 0,Y=p?t?.ownsPageSetup?I:c??I:void 0;lt.useEffect(()=>{let V=te=>{if(!(te.metaKey||te.ctrlKey)||te.altKey||te.shiftKey)return;let B=te.key.toLowerCase();if(B!=="s"&&B!=="o")return;let J=te.target,de=Qi(R.current)??R.current;!J||!de?.contains(J)||(B==="s"&&k?(te.preventDefault(),k()):B==="o"&&P&&(te.preventDefault(),P()));};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[P,k]);let z=lt.useMemo(()=>({t:r,openMenu:b,setOpenMenu:_,activeMenu:y,onOpen:P,onSave:k,onPageSetup:Y,onParagraphDialog:()=>t?t.open("paragraph",R.current?.querySelector('[data-menu="format"] > [role="menuitem"]')):M(true),onReportIssue:d,reportIssue:f}),[r,b,_,y,P,k,Y,t,d,f]),re;if(!u)re=g;else {let V=new Map,te=[];for(let B of lt.Children.toArray(g)){let J=Hg(B);J?V.set(J,B):te.push(B);}re=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[editor.CHROME_MENUS.map(B=>{let J=V.get(B.id);if(J)return jsxRuntime.jsx(lt.Fragment,{children:J},B.id);let de=nE[B.id];return jsxRuntime.jsx(de,{},B.id)}),te]});}return jsxRuntime.jsxs(br.Provider,{value:z,children:[jsxRuntime.jsx("div",{ref:V=>{if(R.current=V,V&&y===null){let te=Es(V)[0]?.closest("[data-menu]")?.getAttribute("data-menu");te&&C(te);}},role:"menubar","aria-label":r?.("titleBar.menuBarAriaLabel")??m("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",className:`${o}docx-menubar${n?` ${n}`:""}`,onMouseDown:Z,onKeyDown:V=>{if(V.key!=="ArrowLeft"&&V.key!=="ArrowRight")return;let te=R.current;if(!te)return;let B=Es(te),J=B.indexOf(document.activeElement);if(J===-1)return;V.preventDefault();let de=V.key==="ArrowRight"?1:-1,U=B[(J+de+B.length)%B.length],q=U?.closest("[data-menu]")?.getAttribute("data-menu");q&&(C(q),U?.focus(),b!==null&&h(q));},children:re}),jsxRuntime.jsx("input",{ref:D,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:V=>{let te=V.target.files?.[0];V.target.value="",!(!te||!p)&&(v(te.name),l?.(te),te.arrayBuffer().then(B=>p.load(new Uint8Array(B))).catch(B=>{console.error("[docx-editor] could not open the file",B);}));}}),jsxRuntime.jsx(Vo,{open:T,onClose:()=>w(false)}),jsxRuntime.jsx(Gt,{open:S,onClose:()=>M(false)})]})}var ma=Object.assign(aE,{Menu:lo,File:Fs,Format:As,Insert:Hs,Review:ll,Help:Os,Item:zt,Row:De,Group:Cr,Separator:Ao,Submenu:kt,TableGrid:Qa,Entry:Sr,Open:Ds,Save:Is,PageSetup:_s,ImageInsert:Ns,Reviewers:il,ReportIssue:Ja});var dE=12240,Zg=1440,zg=1440,Vg=567,Qo=20,Rd=6,kd=Qo+Rd+2,uE="var(--doc-text-muted)",pE="var(--doc-text-subtle)",qg="var(--doc-shadow-subtle)",mE="var(--doc-primary)",fE="var(--doc-primary-hover)",gE="var(--doc-text-subtle)",ga=5,fa=7,bE={left:0,right:0,firstLine:0};function Kg(e,t){return t==="inch"?(e/zg).toFixed(2)+'"':(e/Vg).toFixed(1)+" cm"}function hE(e,t){return t?1:Math.round(e==="cm"?editor.SNAP_TWIPS_CM:editor.SNAP_TWIPS_INCH)}function Jo({pageSetup:e,zoom:t=1,editable:o=false,onLeftMarginChange:n,onRightMarginChange:r,onMarginDragEnd:i,showIndentHandles:a=false,indent:l,indentEditable:s=false,onIndentChange:c,onIndentDragEnd:d,unit:f="inch",className:u="",style:g,tabMarks:p,onTabMarkRemove:m}){let{t:b}=L(),[h,x]=lt.useState(null),[v,y]=lt.useState(null),[C,T]=lt.useState(null),[w,S]=lt.useState(null),M=lt.useRef(null),R=e?.pageWidthTwips??dE,D=e?.marginsTwips.left??Zg,_=e?.marginsTwips.right??Zg,H=e?.gutterTwips??0,N={pageWidth:R,leftMargin:D,rightMargin:_},I=l??bE,P=Ee(R)*t,k=Ee(D)*t,Y=Ee(_)*t,z=lt.useCallback(q=>{let Me=M.current?.getBoundingClientRect();return Me?Ri((q-Me.left)/t):null},[t]),re=lt.useCallback((q,Me,We)=>{let pe=z(Me);if(pe===null)return;if(S(Ee(pe)*t),q==="leftMargin"||q==="rightMargin"){if(q==="leftMargin"){let Bt=R-_-H-720,he=Math.round(Math.max(0,Math.min(pe,Bt)));T(he),n?.(he);}else {let Bt=R-pe,he=R-D-H-720,wt=Math.round(Math.max(0,Math.min(Bt,he)));T(wt),r?.(wt);}return}let Ke=editor.dragIndent(q,pe,I,N,{unit:f,precise:We});T(q==="right"?Ke.right:q==="firstLine"?Ke.firstLine:Ke.left),c?.(Ke);},[z,t,R,D,_,H,n,r,c,I,N,f]),V=lt.useCallback(q=>{q==="leftMargin"||q==="rightMargin"?i?.():d?.(),x(null),T(null),S(null);},[i,d]),te=lt.useCallback((q,Me,We)=>{let pe=editor.handlePosition(q,I,N),Ke=editor.dragIndent(q,pe+Me*hE(f,We),I,N,{unit:f,precise:true});c?.(Ke),d?.();},[I,N,f,c,d]),B=SE(R,t,f),J=a&&s&&c!==void 0,de=q=>Ee(editor.handlePosition(q,I,N))*t,U=(q,Me,We)=>({positionPx:de(q),editable:J,isDragging:h===q,isHovered:v===q,onPointerEnter:()=>y(q),onPointerLeave:()=>y(null),onPointerDown:pe=>{J&&(pe.preventDefault(),pe.stopPropagation(),pe.currentTarget.setPointerCapture(pe.pointerId),x(q));},onPointerMove:pe=>{h===q&&re(q,pe.clientX,pe.altKey);},onPointerUp:pe=>{h===q&&(pe.currentTarget.releasePointerCapture(pe.pointerId),V(q));},onKeyDown:pe=>{J&&(pe.key!=="ArrowLeft"&&pe.key!=="ArrowRight"||(pe.preventDefault(),te(q,pe.key==="ArrowLeft"?-1:1,pe.shiftKey)));},label:b(Me),valueNow:We,valueText:Kg(We,f),pageWidthTwips:R});return jsxRuntime.jsxs("div",{ref:M,className:`docx-horizontal-ruler ${u}`,style:{position:"relative",width:ot(P),height:kd,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:h?"ew-resize":"default",flexShrink:0,marginInline:"auto",...g},role:"group","aria-label":b("ruler.horizontal"),children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,width:ot(k),height:Qo,backgroundColor:qg,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&n?q=>{q.preventDefault(),q.currentTarget.setPointerCapture(q.pointerId),x("leftMargin");}:void 0,onPointerMove:q=>h==="leftMargin"&&re("leftMargin",q.clientX,q.altKey),onPointerUp:q=>{h==="leftMargin"&&(q.currentTarget.releasePointerCapture(q.pointerId),V("leftMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,right:0,width:ot(Y),height:Qo,backgroundColor:qg,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&r?q=>{q.preventDefault(),q.currentTarget.setPointerCapture(q.pointerId),x("rightMargin");}:void 0,onPointerMove:q=>h==="rightMargin"&&re("rightMargin",q.clientX,q.altKey),onPointerUp:q=>{h==="rightMargin"&&(q.currentTarget.releasePointerCapture(q.pointerId),V("rightMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:Qo,pointerEvents:"none"},children:B.map((q,Me)=>jsxRuntime.jsx(vE,{tick:q},Me))}),p?.map(q=>jsxRuntime.jsx(CE,{tabMark:q,positionPx:Ee(q.position)*t,onDoubleClick:()=>m?.(q.position)},q.position)),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(wd,{direction:"down",anchor:"top",...U("firstLine","ruler.firstLineIndent",I.firstLine)}),jsxRuntime.jsx(wd,{direction:"up",anchor:"strip",...U("hanging","ruler.hangingIndent",I.left)}),jsxRuntime.jsx(yE,{...U("left","ruler.leftIndent",I.left)}),jsxRuntime.jsx(wd,{direction:"up",anchor:"strip",...U("right","ruler.rightIndent",I.right)})]}),h&&C!==null&&w!==null&&jsxRuntime.jsx(xE,{value:Kg(C,f),positionPx:w})]})}function vE({tick:e}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:ot(e.position),bottom:0,width:1,height:e.height,backgroundColor:pE}}),e.label&&jsxRuntime.jsx("div",{style:{position:"absolute",left:ot(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:uE,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function $g(e){return e.editable?e.isDragging||e.isHovered?fE:mE:gE}function Wg(e,t,o){return {position:"absolute",left:ot(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...o}}function Ug(e){return {role:"slider","aria-label":e.label,"aria-orientation":"horizontal","aria-valuenow":e.valueNow,"aria-valuemin":-e.pageWidthTwips,"aria-valuemax":e.pageWidthTwips,"aria-valuetext":e.valueText,"aria-disabled":e.editable?void 0:true,tabIndex:e.editable?0:-1}}function wd({direction:e,anchor:t,...o}){let n=$g(o),r=t==="top"?{top:0,height:fa+1}:{top:Qo-fa,height:fa};return jsxRuntime.jsx("div",{className:"docx-ruler-indent",style:Wg(o,ga*2,r),onPointerEnter:o.onPointerEnter,onPointerLeave:o.onPointerLeave,onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onKeyDown:o.onKeyDown,...Ug(o),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${ga}px solid transparent`,borderRight:`${ga}px solid transparent`,...e==="down"?{top:0,borderTop:`${fa}px solid ${n}`}:{bottom:0,borderBottom:`${fa}px solid ${n}`},transition:"border-color 0.1s"}})})}function yE(e){return jsxRuntime.jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:Wg(e,ga*2,{top:Qo+1,height:Rd}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...Ug(e),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:1,top:0,width:ga*2-2,height:Rd,backgroundColor:$g(e),borderRadius:1,transition:"background-color 0.1s"}})})}function xE({value:e,positionPx:t}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:ot(t),top:-22,transform:"translateX(-50%)",backgroundColor:"var(--doc-text)",color:"var(--doc-on-primary)",fontSize:"10px",fontFamily:"sans-serif",padding:"2px 6px",borderRadius:3,whiteSpace:"nowrap",pointerEvents:"none",zIndex:20},children:e})}var TE={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function CE({tabMark:e,positionPx:t,onDoubleClick:o}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:ot(t-5),top:Qo-12,width:10,height:12,display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"var(--doc-text-muted)",cursor:"pointer",userSelect:"none"},onDoubleClick:n=>{n.stopPropagation(),o();},title:`${e.alignment} tab at ${(e.position/1440).toFixed(2)}"`,children:TE[e.alignment]||"L"})}function SE(e,t,o){let n=[];if(o==="inch"){let r=zg/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=Ee(l)*t;a%8===0?n.push({position:s,height:8,label:a/8>0?String(a/8):void 0}):a%4===0?n.push({position:s,height:5}):a%2===0?n.push({position:s,height:3}):n.push({position:s,height:2});}}else {let r=Vg/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=Ee(l)*t;a%10===0?n.push({position:s,height:8,label:a/10>0?String(a/10):void 0}):a%5===0?n.push({position:s,height:5}):n.push({position:s,height:3});}}return n}var wE=15840,Yg=1440,RE=1440,ME=567,Yn=20,kE="var(--doc-text-muted)",DE="var(--doc-text-subtle)",IE="var(--doc-primary)",_E="var(--doc-primary)",NE="var(--doc-primary-hover)";function ba({pageSetup:e,zoom:t=1,editable:o=false,onTopMarginChange:n,onBottomMarginChange:r,onMarginDragEnd:i,unit:a="inch",className:l="",style:s}){let{t:c}=L(),[d,f]=lt.useState(null),[u,g]=lt.useState(null),p=lt.useRef(null),m=e?.pageHeightTwips??wE,b=e?.marginsTwips.top??Yg,h=e?.marginsTwips.bottom??Yg,x=Ee(m)*t,v=Ee(b)*t,y=Ee(h)*t,C=lt.useCallback((R,D)=>{o&&(R.preventDefault(),f(D));},[o]),T=lt.useCallback(R=>{if(!d||!p.current)return;let D=p.current.getBoundingClientRect(),_=R.clientY-D.top,H=Ri(_/t);if(d==="topMargin"){let N=m-h-720,I=Math.max(0,Math.min(H,N));n?.(Math.round(I));}else if(d==="bottomMargin"){let N=m-H,I=m-b-720,P=Math.max(0,Math.min(N,I));r?.(Math.round(P));}},[d,t,m,b,h,n,r]),w=lt.useCallback(()=>{d!==null&&i?.(),f(null);},[d,i]);lt.useEffect(()=>{if(d)return document.addEventListener("mousemove",T),document.addEventListener("mouseup",w),()=>{document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",w);}},[d,T,w]);let S=FE(m,t,a),M={position:"relative",width:Yn,height:ot(x),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:d?"ns-resize":"default",...s};return jsxRuntime.jsxs("div",{ref:p,className:`docx-vertical-ruler ${l}`,style:M,role:"slider","aria-label":c("ruler.vertical"),"aria-orientation":"vertical",children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:S.map((R,D)=>jsxRuntime.jsx(LE,{tick:R},D))}),jsxRuntime.jsx(Xg,{type:"topMargin",position:v,editable:o,isDragging:d==="topMargin",isHovered:u==="topMargin",onMouseEnter:()=>g("topMargin"),onMouseLeave:()=>g(null),onMouseDown:R=>C(R,"topMargin")}),jsxRuntime.jsx(Xg,{type:"bottomMargin",position:x-y,editable:o,isDragging:d==="bottomMargin",isHovered:u==="bottomMargin",onMouseEnter:()=>g("bottomMargin"),onMouseLeave:()=>g(null),onMouseDown:R=>C(R,"bottomMargin")})]})}function LE({tick:e}){let t={position:"absolute",top:ot(e.position),right:0,height:1,width:e.width,backgroundColor:DE},o={position:"absolute",top:ot(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:kE,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:t}),e.label&&jsxRuntime.jsx("div",{style:o,children:e.label})]})}function Xg({type:e,position:t,editable:o,isDragging:n,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:l}){let{t:s}=L(),c=n?NE:r?_E:IE,d={position:"absolute",top:ot(t-5),right:0,width:Yn,height:10,cursor:o?"ns-resize":"default",zIndex:n?10:1},f={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${c}`,transition:"border-right-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:d,onMouseEnter:i,onMouseLeave:a,onMouseDown:l,role:"slider","aria-label":s(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical",tabIndex:o?0:-1,children:jsxRuntime.jsx("div",{style:f})})}function FE(e,t,o){let n=[];if(o==="inch"){let r=RE/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=Ee(l)*t;if(a%8===0){let c=a/8;n.push({position:s,width:10,label:c>0?String(c):void 0});}else a%4===0?n.push({position:s,width:6}):a%2===0?n.push({position:s,width:4}):n.push({position:s,width:2});}}else {let r=ME/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=Ee(l)*t;if(a%10===0){let c=a/10;n.push({position:s,width:10,label:c>0?String(c):void 0});}else a%5===0?n.push({position:s,width:6}):n.push({position:s,width:3});}}return n}var en=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var OE=e=>e.formatting?.indent??null,BE=e=>e.editable;function Id(){let e=F(),t=O(OE),o=O(BE),n=lt.useMemo(()=>o&&e!==null&&e.can({type:"setIndent",left:0}).ok,[e,o]),r=lt.useCallback(i=>e?e.exec({...i.left!==void 0?{left:i.left}:{},...i.right!==void 0?{right:i.right}:{},...i.firstLine!==void 0?{firstLine:i.firstLine}:{},type:"setIndent"}).ok:false,[e]);return lt.useMemo(()=>({indent:t,isEnabled:n,apply:r}),[t,n,r])}var o0=e=>e.zoom,qE=e=>e.isOpening===true;function n0(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function r0(){let{apply:e}=zo(),[t,o]=lt.useState({}),n=lt.useRef({}),r=lt.useCallback(a=>l=>{n.current={...n.current,[a]:Math.round(l)},o(n.current);},[]),i=lt.useCallback(()=>{let a=n.current;n.current={},o({}),Object.keys(a).length!==0&&e({...a.top!==void 0?{marginTopTwips:a.top}:{},...a.right!==void 0?{marginRightTwips:a.right}:{},...a.bottom!==void 0?{marginBottomTwips:a.bottom}:{},...a.left!==void 0?{marginLeftTwips:a.left}:{},scope:"section"});},[e]);return {pending:t,preview:r,commit:i}}function t0(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function KE(){let e=F(),{indent:t,isEnabled:o,apply:n}=Id(),[r,i]=lt.useState(null),a=lt.useRef(null),l=lt.useRef(null),s=lt.useCallback(f=>{l.current===null&&(l.current=t0(e)),a.current=f,i(f);},[e]),c=lt.useCallback(()=>{let f=a.current,u=l.current;a.current=null,l.current=null,i(null),f&&(u!==null&&u!==t0(e)||n({left:f.left,right:f.right,firstLine:f.firstLine}));},[e,n]),d=lt.useMemo(()=>r??(t?{left:t.left,right:t.right,firstLine:t.firstLine}:null),[r,t]);return lt.useMemo(()=>({indent:d,isEnabled:o,preview:s,commit:c}),[d,o,s,c])}function zE(){let e=jt(),[t,o]=lt.useState(0);return lt.useEffect(()=>{if(!e){o(0);return}let n=()=>o(e.scrollLeft);return n(),e.addEventListener("scroll",n,{passive:true}),()=>e.removeEventListener("scroll",n)},[e]),t}function pl(e){let t=O(en),o=O(qE),{pageSetup:n,isEnabled:r}=zo(),i=O(o0),{pending:a,preview:l,commit:s}=r0(),c=KE(),d=Go(),f=$n(),u=zE();return t?null:jsxRuntime.jsx("div",{className:`docx-ruler-frame${o?" docx-ruler-frame--opening":""}`,style:{paddingInlineStart:d+f.inlineStart,paddingRight:f.inlineEnd},children:jsxRuntime.jsx(Jo,{pageSetup:n0(n,a),zoom:i,editable:r,onLeftMarginChange:l("left"),onRightMarginChange:l("right"),onMarginDragEnd:s,showIndentHandles:c.indent!==null,indent:c.indent,indentEditable:c.isEnabled,onIndentChange:c.preview,onIndentDragEnd:c.commit,unit:e.unit??"inch",className:e.className??"",style:{...e.style,transform:`${e.style?.transform?`${e.style.transform} `:""}translateX(${-u}px)`,clipPath:d>0&&u>0?`inset(0 0 0 ${u}px)`:e.style?.clipPath}})})}function ml(e){let t=O(en),{pageSetup:o,isEnabled:n}=zo(),r=O(o0),{pending:i,preview:a,commit:l}=r0(),s=Go(),c=$n(),d=wm();return t||d!==null&&d>0&&o&&Ee(o.pageWidthTwips)*r>d-s-c.inlineStart-c.inlineEnd?null:jsxRuntime.jsx(ba,{pageSetup:n0(o,i),zoom:r,editable:n,onTopMarginChange:a("top"),onBottomMarginChange:a("bottom"),onMarginDragEnd:l,unit:e.unit??"inch",className:e.className??"",style:e.style})}function A({size:e=20,className:t="",style:o,children:n}){return jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 -960 960 960",fill:"currentColor",className:t,style:{display:"inline-flex",flexShrink:0,...o},"aria-hidden":"true",children:n})}function a0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M268-240 42-466l57-56 170 170 56 56-57 56Zm226 0L268-466l56-57 170 170 368-368 57 57-425 424Zm0-226-57-56 198-198 57 56-198 198Z"})})}function i0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m424-296 282-282-56-56-226 226-114-114-56 56 170 170Zm56 216q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Z"})})}function l0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"})})}function s0(e){return jsxRuntime.jsxs(A,{...e,children:[jsxRuntime.jsx("path",{d:"M80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"}),jsxRuntime.jsx("path",{fill:"var(--doc-success)",d:"m421-380 227-227-45-45-182 182-92-91-45 45 137 136Z"})]})}function c0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function d0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"})})}function u0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-400h80v-120h120v-80H520v-120h-80v120H320v80h120v120ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"})})}function p0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M240-400h480v-80H240v80Zm0-120h480v-80H240v80Zm0-120h480v-80H240v80ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"})})}function m0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-400h280v-80H160v80Zm0-160h440v-80H160v80Zm0-160h440v-80H160v80Zm360 360v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T863-380L643-160H520Zm300-263-37-37 37 37ZM580-220h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z"})})}function f0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M240-400h122l200-200q9-9 13.5-20.5T580-643q0-11-5-21.5T562-684l-36-38q-9-9-20-13.5t-23-4.5q-11 0-22.5 4.5T440-722L240-522v122Zm280-243-37-37 37 37ZM300-460v-38l101-101 20 18 18 20-101 101h-38Zm121-121 18 20-38-38 20 18Zm26 181h273v-80H527l-80 80ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"})})}function g0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-320q75 0 127.5-52.5T660-500q0-75-52.5-127.5T480-680q-75 0-127.5 52.5T300-500q0 75 52.5 127.5T480-320Zm0-72q-45 0-76.5-31.5T372-500q0-45 31.5-76.5T480-608q45 0 76.5 31.5T588-500q0 45-31.5 76.5T480-392Zm0 192q-146 0-266-81.5T40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200Zm0-300Zm0 220q113 0 207.5-59.5T832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280Z"})})}function b0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M240-80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h40v-80q0-83 58.5-141.5T480-920q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Zm0-80h480v-400H240v400Zm240-120q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM360-640h240v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80Zm-120 480v-400 400Z"})})}function WE(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"})})}function UE(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"})})}function GE(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M640-640v-120H320v120h-80v-200h480v200h-80Zm-480 80h640-640Zm560 100q17 0 28.5-11.5T760-500q0-17-11.5-28.5T720-540q-17 0-28.5 11.5T680-500q0 17 11.5 28.5T720-460Zm-80 260v-160H320v160h320Zm80 80H240v-160H80v-240q0-51 35-85.5t85-34.5h560q51 0 85.5 34.5T880-520v240H720v160Zm80-240v-160q0-17-11.5-28.5T760-560H200q-17 0-28.5 11.5T160-520v160h80v-80h480v80h80Z"})})}function jE(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-320 280-520l56-58 104 104v-326h80v326l104-104 56 58-200 200ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"})})}function YE(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"})})}function XE(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"})})}function QE(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function JE(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"})})}function e1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z"})})}function t1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"})})}function o1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"})})}function n1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"})})}function r1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-160v-240q-83 0-141.5-58.5T160-600q0-83 58.5-141.5T360-800h360v80h-80v560h-80v-560H440v560h-80Z"})})}function a1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"})})}function i1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function l1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function s1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function c1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function Fd(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z"})})}function d1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z"})})}function u1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"})})}function p1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function m1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function f1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z"})})}function g1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M544-400 440-504 240-304l104 104 200-200Zm-47-161 104 104 199-199-104-104-199 199Zm-84-28 216 216-229 229q-24 24-56 24t-56-24l-2-2-26 26H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0 0 227-227q24-24 56-24t56 24l104 104q24 24 24 56t-24 56L629-373 413-589Z"})})}function b1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M800-436q0 36-8 69t-22 63l-62-60q6-17 9-34.5t3-37.5q0-47-17.5-89T650-600L480-768l-88 86-56-56 144-142 226 222q44 42 69 99.5T800-436Zm-8 380L668-180q-41 29-88 44.5T480-120q-133 0-226.5-92.5T160-436q0-51 16-98t48-90L56-792l56-56 736 736-56 56ZM480-200q36 0 68.5-10t61.5-28L280-566q-21 32-30.5 64t-9.5 66q0 98 70 167t170 69Zm-37-204Zm110-116Z"})})}function h1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function v1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm240-240H200v160h240v-160Zm80 0v160h240v-160H520Zm-80-80v-160H200v160h240Zm80 0h240v-160H520v160ZM200-680h560v-80H200v80Z"})})}function y1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M760-120H200q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120ZM200-640h560v-120H200v120Zm100 80H200v360h100v-360Zm360 0v360h100v-360H660Zm-80 0H380v360h200v-360Z"})})}function x1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133ZM200-413h133v-134H200v134Zm213 0h134v-134H413v134Zm214 0h133v-134H627v134ZM200-627h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133Z"})})}function T1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M760-200v-120H200v120h560Zm0-200v-160H200v160h560Zm0-240v-120H200v120h560ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Z"})})}function C1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M121-280v-400q0-33 23.5-56.5T201-760h559q33 0 56.5 23.5T840-680v400q0 33-23.5 56.5T760-200H201q-33 0-56.5-23.5T121-280Zm79 0h133v-400H200v400Zm213 0h133v-400H413v400Zm213 0h133v-400H626v400Z"})})}function h0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function S1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-200h560v-560H200v560Zm-80 80v-720h720v720H120Zm160-320v-80h80v80h-80Zm160 160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 160v-80h80v80h-80Z"})})}function P1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm320 640v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm-160 0v-80h80v80h-80ZM440-120v-320H120v-80h320v-320h80v320h320v80H520v320h-80Z"})})}function E1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function w1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function R1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function M1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z"})})}function k1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M600-240v-80h160v80H600Zm0-320v-80h280v80H600Zm0 160v-80h240v80H600ZM120-640H80v-80h160v-60h160v60h160v80h-40v360q0 33-23.5 56.5T440-200H200q-33 0-56.5-23.5T120-280v-360Zm80 0v360h240v-360H200Zm0 0v360-360Z"})})}function D1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m296-160-56-56 200-200v-269L337-582l-57-57 200-200 201 201-57 57-104-104v301L296-160Zm368 1L536-286l57-57 127 128-56 56Z"})})}function I1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function _1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-160q-33 0-56.5-23.5T280-240q0-33 23.5-56.5T360-320q33 0 56.5 23.5T440-240q0 33-23.5 56.5T360-160Zm240 0q-33 0-56.5-23.5T520-240q0-33 23.5-56.5T600-320q33 0 56.5 23.5T680-240q0 33-23.5 56.5T600-160ZM360-400q-33 0-56.5-23.5T280-480q0-33 23.5-56.5T360-560q33 0 56.5 23.5T440-480q0 33-23.5 56.5T360-400Zm240 0q-33 0-56.5-23.5T520-480q0-33 23.5-56.5T600-560q33 0 56.5 23.5T680-480q0 33-23.5 56.5T600-400ZM360-640q-33 0-56.5-23.5T280-720q0-33 23.5-56.5T360-800q33 0 56.5 23.5T440-720q0 33-23.5 56.5T360-640Zm240 0q-33 0-56.5-23.5T520-720q0-33 23.5-56.5T600-800q33 0 56.5 23.5T680-720q0 33-23.5 56.5T600-640Z"})})}function N1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"})})}function L1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function F1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function A1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function H1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-480h80v480h480v80H200Zm160-240v80q-33 0-56.5-23.5T280-360h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T360-840v80Zm80 480v-80h80v80h-80Zm0-480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0 480v-80h80v80h-80Zm160-480v-80q33 0 56.5 23.5T840-760h-80Zm0 400h80q0 33-23.5 56.5T760-280v-80Zm0-80v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function O1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-280q-33 0-56.5-23.5T280-360v-400q0-33 23.5-56.5T360-840h400q33 0 56.5 23.5T840-760v400q0 33-23.5 56.5T760-280H360Zm0-80h400v-400H360v400ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function B1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-80 310-250l57-57 73 73v-166h80v165l72-73 58 58L480-80ZM250-310 80-480l169-169 57 57-72 72h166v80H235l73 72-58 58Zm460 0-57-57 73-73H560v-80h165l-73-72 58-58 170 170-170 170ZM440-560v-166l-73 73-57-57 170-170 170 170-57 57-73-73v166h-80Z"})})}function Z1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z"})})}function q1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M522-80v-82q34-5 66.5-18t61.5-34l56 58q-42 32-88 51.5T522-80Zm-80 0Q304-98 213-199.5T122-438q0-75 28.5-140.5t77-114q48.5-48.5 114-77T482-798h6l-62-62 56-58 160 160-160 160-56-56 64-64h-8q-117 0-198.5 81.5T202-438q0 104 68 182.5T442-162v82Zm322-134-58-56q21-29 34-61.5t18-66.5h82q-5 50-24.5 96T764-214Zm76-264h-82q-5-34-18-66.5T706-606l58-56q32 39 51 86t25 98Z"})})}function K1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-80q-50-5-96-24.5T256-156l56-58q29 21 61.5 34t66.5 18v82Zm80 0v-82q104-15 172-93.5T760-438q0-117-81.5-198.5T480-718h-8l64 64-56 56-160-160 160-160 56 58-62 62h6q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-438q0 137-91 238.5T520-80ZM198-214q-32-42-51.5-88T122-398h82q5 34 18 66.5t34 61.5l-58 56Zm-76-264q6-51 25-98t51-86l58 56q-21 29-34 61.5T204-478h-82Z"})})}function z1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M280-160 80-360l200-200 56 57-103 103h287v80H233l103 103-56 57Zm400-240-56-57 103-103H440v-80h287L624-743l56-57 200 200-200 200Z"})})}function V1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M320-440v-287L217-624l-57-56 200-200 200 200-57 56-103-103v287h-80ZM600-80 400-280l57-56 103 103v-287h80v287l103-103 57 56L600-80Z"})})}function $1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M600-360ZM320-242q10 1 19.5 1.5t20.5.5q11 0 20.5-.5T400-242v82h400v-400h-82q1-10 1.5-19.5t.5-20.5q0-11-.5-20.5T718-640h82q33 0 56.5 23.5T880-560v400q0 33-23.5 56.5T800-80H400q-33 0-56.5-23.5T320-160v-82Zm40-78q-117 0-198.5-81.5T80-600q0-117 81.5-198.5T360-880q117 0 198.5 81.5T640-600q0 117-81.5 198.5T360-320Zm0-80q83 0 141.5-58.5T560-600q0-83-58.5-141.5T360-800q-83 0-141.5 58.5T160-600q0 83 58.5 141.5T360-400Zm0-200Z"})})}function W1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-80q-33 0-56.5-23.5T360-160v-160H240q-33 0-56.5-23.5T160-400v-280q0-66 47-113t113-47h480v440q0 33-23.5 56.5T720-320H600v160q0 33-23.5 56.5T520-80h-80ZM240-560h480v-200h-40v160h-80v-160h-40v80h-80v-80H320q-33 0-56.5 23.5T240-680v120Zm0 160h480v-80H240v80Zm0 0v-80 80Z"})})}function U1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function G1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function j1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h720v80H120Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Y1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function X1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h80v720h-80Zm160 0v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Q1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-720h80v720h-80Z"})})}function J1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h720v60H120Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-660v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-660v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-165v-60h60v60h-60Z"})})}function e2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-330v-60h60v60h-60Zm165 660v-720h60v720h-60Zm165 0v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-330v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Z"})})}function t2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M320-600q17 0 28.5-11.5T360-640q0-17-11.5-28.5T320-680q-17 0-28.5 11.5T280-640q0 17 11.5 28.5T320-600Zm160 0q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm160 0q17 0 28.5-11.5T680-640q0-17-11.5-28.5T640-680q-17 0-28.5 11.5T600-640q0 17 11.5 28.5T640-600ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"})})}function o2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-200v-80h528l-42-42 56-56 138 138-138 138-56-56 42-42H160Zm116-200 164-440h80l164 440h-76l-38-112H392l-40 112h-76Zm138-176h132l-64-182h-4l-64 182Z"})})}function n2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M588-132 440-280l148-148 56 58-50 50h96q29 0 49.5-20.5T760-390q0-29-20.5-49.5T690-460H160v-80h530q63 0 106.5 43.5T840-390q0 63-43.5 106.5T690-240h-96l50 50-56 58ZM160-240v-80h200v80H160Zm0-440v-80h640v80H160Z"})})}function r2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-120 320-280l56-56 64 63v-414l-64 63-56-56 160-160 160 160-56 57-64-64v414l64-63 56 56-160 160Z"})})}function a2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function i2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"})})}function l2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M80 0v-160h800V0H80Zm160-320h56l312-311-29-29-28-28-311 312v56Zm-80 80v-170l448-447q11-11 25.5-17t30.5-6q16 0 31 6t27 18l55 56q12 11 17.5 26t5.5 31q0 15-5.5 29.5T777-687L330-240H160Zm560-504-56-56 56 56ZM608-631l-29-29-28-28 57 57Z"})})}function s2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m247-904 57-56 343 343q23 23 23 57t-23 57L457-313q-23 23-57 23t-57-23L153-503q-23-23-23-57t23-57l190-191-96-96Zm153 153L209-560h382L400-751Zm360 471q-33 0-56.5-23.5T680-360q0-21 12.5-45t27.5-45q9-12 19-25t21-25q11 12 21 25t19 25q15 21 27.5 45t12.5 45q0 33-23.5 56.5T760-280ZM80 0v-160h800V0H80Z"})})}function c2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function d2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-80v-168l-64 64-56-56 160-160 160 160-56 56-64-64v168h-80ZM160-440v-80h640v80H160Zm320-120L320-720l56-56 64 64v-168h80v168l64-64 56 56-160 160Z"})})}function u2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function p2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function m2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function f2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function g2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function b2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function h2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"})})}function v2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-440v-80h160v80H120Zm200 0v-80h160v80H320Zm200 0v-80h160v80H520Zm200 0v-80h120v80H720ZM240-120q-33 0-56.5-23.5T160-200v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-120H240Zm-80-520v-120q0-33 23.5-56.5T240-840h480q33 0 56.5 23.5T800-760v120h-80v-120H240v120h-80Z"})})}function y2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm0-80h640v-480H160v480Zm320-60q66 0 113-37t47-93q0-29-13-58t-34-55q-21-26-50-49t-50-31q-21 8-50 31t-50 49q-21 26-34 55t-13 58q0 56 47 93t140 37Z"})})}function x2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function T2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"})})}function C2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function S2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm0-280v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80ZM680-80l-56-56 64-64H120v-80h568l-64-64 56-56 160 160L680-80Z"})})}function P2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm-88 160 64 64-56 56-160-160 160-160 56 56-64 64h568v80H272Zm88-440v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Z"})})}function E2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m760-600-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110Zm0 560-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110ZM360-160 260-380 40-480l220-100 100-220 100 220 220 100-220 100-100 220Zm0-194 40-86 86-40-86-40-40-86-40 86-86 40 86 40 40 86Zm0-126Z"})})}var w2={undo:WE,redo:UE,print:GE,file_download:jE,file_upload:YE,format_bold:XE,format_italic:QE,format_underlined:JE,strikethrough_s:e1,superscript:t1,subscript:o1,link:n1,format_clear:a1,format_paragraph:r1,lock:b0,format_align_left:i1,format_align_center:l1,format_align_right:s1,format_align_justify:c1,format_line_spacing:Fd,format_list_bulleted:d1,format_list_numbered:u1,format_indent_increase:p1,format_indent_decrease:m1,format_color_text:f1,ink_highlighter:g1,format_color_reset:b1,arrow_drop_down:h1,table:v1,table_chart:y1,grid_on:x1,table_rows:T1,view_column:C1,border_all:h0,select_all:h0,border_outer:S1,border_inner:P1,border_clear:E1,add:w1,remove:R1,delete:M1,delete_sweep:k1,call_merge:D1,call_split:I1,drag_indicator:_1,image:N1,format_image_left:L1,format_image_right:F1,horizontal_rule:A1,flip_to_back:H1,flip_to_front:O1,open_with:B1,tune:Z1,rotate_right:q1,rotate_left:K1,swap_horiz:z1,swap_vert:V1,shapes:$1,format_paint:W1,expand_more:U1,expand_less:G1,border_top:j1,border_bottom:Y1,border_left:X1,border_right:Q1,border_horizontal:J1,border_vertical:e2,padding:t2,text_rotation_none:o2,wrap_text:n2,height:r2,fit_width:a2,settings:i2,border_color:l2,format_color_fill:s2,vertical_align_top:c2,vertical_align_center:d2,vertical_align_bottom:u2,line_weight:p2,keyboard_arrow_up:m2,keyboard_arrow_down:f2,keyboard_arrow_left:g2,keyboard_arrow_right:b2,more_vert:h2,page_break:v2,branding_watermark:y2,arrow_back:x2,search:T2,toc:C2,done_all:a0,check_circle:i0,chat_bubble_outline:l0,chat_bubble_check:s0,check:c0,close:d0,add_comment:u0,comment:p0,edit_note:m0,rate_review:f0,visibility:g0,format_textdirection_l_to_r:S2,format_textdirection_r_to_l:P2,"agent-sparkle":E2};function $({name:e,size:t=20,className:o="",style:n}){let r=w2[e];return r?jsxRuntime.jsx(r,{size:t,className:o,style:n}):(console.warn(`Icon not found: ${e}`),jsxRuntime.jsx("span",{className:o,style:{fontSize:t,width:t,height:t,...n},children:e}))}var ha=12,Ad=240,y0=16,D2=24,I2=ha+Ad+y0,Xn=12,_2=36,N2=Xn+_2+y0,va=lt__namespace.default.memo(function({headings:t,onHeadingClick:o,onClose:n,topOffset:r=0,scrollLeft:i=0,leftOffset:a=ha}){let{t:l}=L(),[s,c]=lt.useState(false),d=t.length?Math.min(...t.map(f=>f.level)):0;return lt.useEffect(()=>{requestAnimationFrame(()=>c(true));},[]),jsxRuntime.jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":l("documentOutline.ariaLabel"),style:{position:"absolute",top:r,left:a-i,bottom:0,width:Ad,paddingTop:D2,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:s?"translateX(0)":`translateX(-${a+Ad}px)`,transition:"transform 0.15s ease-out"},onMouseDown:f=>f.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px 0"},children:[jsxRuntime.jsx("button",{onClick:n,"aria-label":l("documentOutline.closeAriaLabel"),style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"var(--doc-text-muted)"},title:l("documentOutline.closeTitle"),children:jsxRuntime.jsx($,{name:"arrow_back",size:20})}),jsxRuntime.jsx("span",{style:{fontWeight:400,fontSize:14,color:"var(--doc-text)",letterSpacing:"0.01em"},children:l("documentOutline.title")})]}),jsxRuntime.jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:4},children:t.length===0?jsxRuntime.jsx("div",{style:{padding:"8px 16px",color:"var(--doc-text-subtle)",fontSize:13,lineHeight:"20px"},children:l("documentOutline.noHeadings")}):t.map((f,u)=>jsxRuntime.jsx("div",{style:{marginLeft:(f.level-d)*16},children:jsxRuntime.jsx("button",{className:"docx-outline-heading-btn",onClick:()=>o(f.blockId),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 8px",fontSize:13,fontWeight:400,color:"var(--doc-text)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:f.text,children:f.text})},`${f.blockId}-${u}`))})]})});var A2=e=>e,H2=Object.freeze([]),O2=()=>{};function Hd(e){let t=F(),o=O(A2),n=lt.useMemo(()=>t&&!o.isLoading?t.getOutline():H2,[t,o]),r=lt.useCallback(i=>{if(!t)return;t.focus();let a={paragraphId:i,offset:0};t.exec({type:"setSelection",range:{anchor:a,head:a}}),t.scrollToBlock(i);},[t]);return en(o)?null:jsxRuntime.jsx(va,{headings:n,onHeadingClick:r,onClose:e.onClose??O2,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var Od=lt.createContext(null);function yo(e){let t=lt.useContext(Od);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var Qn=280,fl=32,x0=16;function on(e=280){return 32+e+16}function gl({viewportWidth:e,pageWidthPx:t,reservation:o,inlineEndReservation:n=0,inlineStartReservation:r=0,docked:i=false}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(n)||n<0||!Number.isFinite(r)||r<0)return 0;let a=(e-n-t)/2,l=a>=o?0:!i&&o<=2*a?2*(o-a):o;return Math.ceil(Math.max(0,l-r))}var V2=Object.freeze([]),$2=e=>e;function bl(){let e=F(),t=O($2),[o,n]=lt.useState(null),r=lt.useMemo(()=>e&&!t.isLoading?e.getOutline():V2,[e,t]),i=lt.useMemo(()=>{if(r.length===0)return [];let l=r[0].level;for(let s of r)s.level<l&&(l=s.level);return r.map(s=>({heading:s,depth:s.level-l}))},[r]),a=lt.useCallback(l=>{if(!e||typeof l!="string"||l.length===0)return;e.focus();let s={paragraphId:l,offset:0};e.exec({type:"setSelection",range:{anchor:s,head:s}}),e.scrollToBlock(l),n(l);},[e]);return {headings:r,items:i,selectedBlockId:o,goTo:a,isEmpty:r.length===0}}var qd=150,Kd=2e3,Zd=Object.freeze([]),G2=e=>e;function hl(){let e=F(),t=O(G2),[o,n]=lt.useState(""),[r,i]=lt.useState(""),[a,l]=lt.useState(false),[s,c]=lt.useState(false),[d,f]=lt.useState(Zd),[u,g]=lt.useState(-1);lt.useEffect(()=>{if(o===r)return;let T=setTimeout(()=>i(o),qd);return ()=>clearTimeout(T)},[o,r]);let p=lt.useMemo(()=>({matchCase:a,wholeWord:s}),[a,s]);lt.useEffect(()=>{if(!e||r.length===0){f(Zd),g(-1);return}let T=e.findMatches(r,p);f(w=>w===T?w:T);},[e,r,p,t]);let m=lt.useRef(d);lt.useEffect(()=>{m.current!==d&&(m.current=d,g(T=>T>=0&&T<d.length?T:-1));},[d]);let b=lt.useCallback(T=>{if(!e)return;let w=d[T];if(!w)return;e.focus(),e.selectMatch(w).ok&&g(T);},[e,d]),h=lt.useCallback(T=>{if(d.length===0)return;let S=((u<0?T>0?-1:0:u)+T+d.length)%d.length;b(S);},[u,b,d.length]),x=lt.useCallback(()=>h(1),[h]),v=lt.useCallback(()=>h(-1),[h]),y=lt.useCallback(T=>n(T),[]),C=lt.useCallback(()=>{n(""),i(""),f(Zd),g(-1);},[]);return {query:o,setQuery:y,matchCase:a,setMatchCase:l,wholeWord:s,setWholeWord:c,matches:d,truncated:d.length>=Kd,activeIndex:u,goTo:b,next:x,previous:v,clear:C,isPending:o!==r}}var ew=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,zoom:e.zoom,reviewPaneOpen:e.reviewPaneOpen??true,fitting:t?.type==="fit"&&e.zoom<(t.maxZoom??editor.ZOOM_MAX)&&e.zoom>(t.minZoom??editor.ZOOM_MIN)}},tw=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function vl(e={}){let{defaultOpen:t=false,defaultTab:o="headings",paneWidth:n=280}=e,[r,i]=lt.useState(t),[a,l]=lt.useState(o),s=e.open??r,c=e.tab??a,{onOpenChange:d,onTabChange:f}=e,u=e.open!==void 0,g=e.tab!==void 0,p=lt.useCallback(k=>{u||i(k),d?.(k);},[u,d]),m=lt.useCallback(()=>p(!s),[s,p]),b=lt.useCallback(k=>{g||l(k),f?.(k);},[g,f]),h=Uo(),x=jt(),v=lt.useContext(bt),{pageSetup:y,zoom:C,reviewPaneOpen:T,fitting:w}=O(ew,tw),[S,M]=lt.useState(0),[R,D]=lt.useState(0),[_,H]=lt.useState(0);lt.useEffect(()=>{if(!x){M(0),D(0),H(0);return}let k=()=>{M(x.clientWidth);let z=getComputedStyle(x),re=Number.parseFloat(z.paddingInlineEnd);D(Number.isFinite(re)?re:0);let V=Number.parseFloat(z.getPropertyValue("--docx-review-gutter-start"));H(Number.isFinite(V)?V:0);};if(k(),typeof ResizeObserver>"u")return;let Y=new ResizeObserver(k);return Y.observe(x),()=>Y.disconnect()},[x,s,T,v?.mounted]);let N=lt.useRef(null);y&&(N.current=y.pageWidthTwips);let I=y?.pageWidthTwips??N.current,P=lt.useMemo(()=>!s||I===null?0:gl({viewportWidth:S,pageWidthPx:Ee(I)*C,reservation:on(n),inlineEndReservation:R,inlineStartReservation:_,docked:w}),[s,I,C,S,n,R,_,w]);return lt.useEffect(()=>{if(h)return h.setShift(P),()=>h.setShift(0)},[h,P]),lt.useEffect(()=>{if(h)return h.setReservation(s?on(n):0),()=>h.setReservation(0)},[h,s,n]),{open:s,setOpen:p,toggle:m,tab:c,setTab:b,paneWidth:n,shift:P}}var xa=["headings","find"],Ft=(...e)=>e.filter(Boolean).join(" ");function Ta({className:e,style:t,children:o}){return jsxRuntime.jsx("div",{className:Ft("docx-nav__header",e),style:t,children:o??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ca,{}),jsxRuntime.jsx(Sa,{})]})})}function Ca({className:e,style:t,children:o}){let{pane:n,t:r}=yo("Close");return jsxRuntime.jsx("button",{type:"button",className:Ft("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:()=>n.setOpen(false),children:o??jsxRuntime.jsx($,{name:"arrow_back",size:20})})}function Sa({className:e,style:t,children:o}){let{t:n}=yo("Title");return jsxRuntime.jsx("h2",{className:Ft("docx-nav__title",e),style:t,children:o??n("navigation.title")})}function Pa({className:e,style:t,children:o}){let{pane:n,t:r}=yo("Tabs"),i=lt.useCallback(a=>{let l=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(l===0)return;a.preventDefault();let s=xa.indexOf(n.tab);n.setTab(xa[(s+l+xa.length)%xa.length]);},[n]);return jsxRuntime.jsx("div",{className:Ft("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:i,children:o??xa.map(a=>jsxRuntime.jsx(Ea,{value:a},a))})}function Ea({value:e,className:t,style:o,children:n}){let{pane:r,t:i}=yo("Tab"),a=r.tab===e;return jsxRuntime.jsx("button",{type:"button",role:"tab",id:`docx-nav-tab-${e}`,"aria-selected":a,"aria-controls":`docx-nav-panel-${e}`,tabIndex:a?0:-1,className:Ft("docx-nav__tab",a&&"docx-nav__tab--selected",t),style:o,onClick:()=>r.setTab(e),children:n??i(`navigation.tabs.${e}`)})}function C0({value:e,onChange:t,onClear:o,placeholder:n,label:r,clearLabel:i,autoFocus:a}){let l=lt.useRef(null);return lt.useEffect(()=>{a&&l.current?.focus();},[a]),jsxRuntime.jsxs("div",{className:"docx-nav__searchbox",children:[jsxRuntime.jsx($,{name:"search",size:18,className:"docx-nav__search-icon"}),jsxRuntime.jsx("input",{ref:l,type:"search",className:"docx-nav__search-input",value:e,placeholder:n,"aria-label":r,autoFocus:a,onChange:s=>t(s.target.value)}),e.length>0&&jsxRuntime.jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":i,onClick:o,children:jsxRuntime.jsx($,{name:"close",size:16})})]})}function wa({className:e,style:t}){let{pane:o,outline:n,t:r}=yo("Headings"),[i,a]=lt.useState(""),l=O(en),s=lt.useMemo(()=>{let d=i.trim().toLowerCase();return d.length===0?n.items:n.items.filter(f=>f.heading.text.toLowerCase().includes(d))},[n.items,i]),c=o.tab!=="headings";return jsxRuntime.jsxs("div",{className:Ft("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:c,children:[jsxRuntime.jsx(C0,{value:i,onChange:a,onClear:()=>a(""),placeholder:r("navigation.find.placeholder"),label:r("navigation.find.inputAriaLabel"),clearLabel:r("navigation.find.clearAriaLabel")}),l?null:n.isEmpty?jsxRuntime.jsx("p",{className:"docx-nav__empty",children:r("navigation.headings.noHeadings")}):s.length===0?jsxRuntime.jsx("p",{className:"docx-nav__empty",children:r("navigation.find.noResults")}):jsxRuntime.jsx("ul",{className:"docx-nav__list",children:s.map((d,f)=>jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:Ft("docx-nav__heading",n.selectedBlockId===d.heading.blockId&&"docx-nav__heading--current"),style:{paddingInlineStart:`${8+d.depth*14}px`},title:d.heading.text,onClick:()=>n.goTo(d.heading.blockId),children:d.heading.text})},`${d.heading.blockId}-${f}`))})]})}function lw({match:e,active:t,onSelect:o}){return jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:Ft("docx-nav__result",t&&"docx-nav__result--active"),"aria-current":t?"true":void 0,onClick:o,children:jsxRuntime.jsxs("span",{className:"docx-nav__result-text",children:[e.contextBefore,jsxRuntime.jsx("mark",{className:"docx-nav__result-hit",children:e.text}),e.contextAfter]})})})}function Ra({className:e,style:t}){let{pane:o,search:n,t:r}=yo("Find"),i=o.tab!=="find",a=n.query.trim().length>0,l=o.open&&!i,s=n.matches.length===0?null:n.activeIndex<0?r(n.truncated?"navigation.find.totalTruncated":"navigation.find.total",{total:n.matches.length}):r(n.truncated?"navigation.find.counterTruncated":"navigation.find.counter",{current:n.activeIndex+1,total:n.matches.length});return jsxRuntime.jsxs("div",{className:Ft("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:i,children:[jsxRuntime.jsx(C0,{value:n.query,onChange:n.setQuery,onClear:n.clear,placeholder:r("navigation.find.placeholder"),label:r("navigation.find.inputAriaLabel"),clearLabel:r("navigation.find.clearAriaLabel"),autoFocus:l}),jsxRuntime.jsxs("div",{className:"docx-nav__options",role:"group","aria-label":r("navigation.find.optionsAriaLabel"),children:[jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.matchCase,onChange:c=>n.setMatchCase(c.target.checked)}),r("navigation.find.matchCase")]}),jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.wholeWord,onChange:c=>n.setWholeWord(c.target.checked)}),r("navigation.find.wholeWord")]})]}),jsxRuntime.jsxs("div",{className:"docx-nav__resultbar",children:[jsxRuntime.jsx("span",{className:"docx-nav__count","aria-live":"polite",children:a?n.isPending?r("navigation.find.searching"):s??r("navigation.find.noResults"):""}),jsxRuntime.jsxs("span",{className:"docx-nav__steppers",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":r("navigation.find.previousAriaLabel"),disabled:n.matches.length===0,onClick:n.previous,children:jsxRuntime.jsx($,{name:"keyboard_arrow_up",size:18})}),jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":r("navigation.find.nextAriaLabel"),disabled:n.matches.length===0,onClick:n.next,children:jsxRuntime.jsx($,{name:"keyboard_arrow_down",size:18})})]})]}),n.matches.length>0&&jsxRuntime.jsx("ul",{className:"docx-nav__list","aria-label":r("navigation.find.resultsAriaLabel"),children:n.matches.map((c,d)=>jsxRuntime.jsx(lw,{match:c,active:d===n.activeIndex,onSelect:()=>n.goTo(d)},`${c.blockId}-${c.start}-${d}`))})]})}function Ma({className:e,style:t,children:o}){let{pane:n,t:r}=yo("Toggle");return jsxRuntime.jsx("button",{type:"button",className:Ft("docx-nav__toggle",e),style:t,"aria-label":r("navigation.openAriaLabel"),"aria-expanded":n.open,title:r("navigation.openTitle"),onMouseDown:i=>i.preventDefault(),onClick:n.toggle,children:o??jsxRuntime.jsx($,{name:"toc",size:20})})}function $d(e){let t=it(),{t:o,toggle:n=true,className:r,style:i,children:a,...l}=e,s=vl(l),c=bl(),d=hl(),{t:f}=L(),u=lt.useMemo(()=>({pane:s,outline:c,search:d,t:o??((p,m)=>f(p,m))}),[s,c,d,o,f]),g=e.paneWidth??280;return jsxRuntime.jsx(Od.Provider,{value:u,children:jsxRuntime.jsxs("div",{className:`${t}docx-nav${s.open?" docx-nav--open":""}${r?` ${r}`:""}`,"data-open":s.open?"true":"false",style:{"--docx-nav-width":`${g}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${on(g)}px`,...i},children:[n!==false&&!s.open&&jsxRuntime.jsx(Ma,{...typeof n=="object"?n:{}}),jsxRuntime.jsx("aside",{className:"docx-nav__panel-shell","aria-label":u.t("navigation.ariaLabel"),inert:!s.open,children:a??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ta,{}),jsxRuntime.jsx(Pa,{}),jsxRuntime.jsx(wa,{}),jsxRuntime.jsx(Ra,{})]})})]})})}var yl=Object.assign($d,{Header:Ta,Close:Ca,Title:Sa,Tabs:Pa,Tab:Ea,Headings:wa,Find:Ra,Toggle:Ma});var fw=600,gw=e=>e.page.total,xl=lt.createContext(null);function Tl({className:e,style:t}){let o=it(),n=F(),r=jt(),i=O(gw),{t:a}=L(),l=lt.useContext(xl),[s,c]=lt.useState(1),[d,f]=lt.useState(false);if(lt.useEffect(()=>{if(f(false),!n||!r||i<=1)return;c(n.getCurrentPage("viewport"));let g=null,p=()=>{c(n.getCurrentPage("viewport")),f(true),g&&clearTimeout(g),g=setTimeout(()=>f(false),fw);};return r.addEventListener("scroll",p,{passive:true}),()=>{r.removeEventListener("scroll",p),g&&clearTimeout(g);}},[n,i,r]),i<=1)return null;let u=l?l("viewer.pageIndicator").replace(/\{current\}/g,String(s)).replace(/\{total\}/g,String(i)):a("viewer.pageIndicator",{current:s,total:i});return jsxRuntime.jsx("div",{className:`${o}docx-editor-shell__page-indicator-chip docx-editor__page-number${e?` ${e}`:""}`,style:t,"data-visible":d?"true":"false",role:"status","aria-live":"polite",children:u})}var vw=[],yw=e=>e.fontSubstitutions??vw;function Cl({className:e,style:t,t:o}){let n=O(yw),{t:r}=L(),i=o??r,[a,l]=lt.useState(null);if(n.length===0)return null;let s=n.join("\0");return a===s?null:jsxRuntime.jsxs("div",{className:e?`docx-font-notice ${e}`:"docx-font-notice",role:"status",...t?{style:t}:{},children:[jsxRuntime.jsx("span",{className:"docx-font-notice__text",children:i("editor.fontSubstitutionNotice",{fonts:n.join(", ")}).replace("{fonts}",n.join(", "))}),jsxRuntime.jsx("button",{type:"button",className:"docx-font-notice__dismiss",onClick:()=>l(s),children:i("common.dismiss")})]})}function Wd(e){return Math.round(e/1440*100)/100}function w0(e){return Math.round(e*1440)}function Cw(e,t){return e===t?true:!e||!t?false:e.editing===t.editing&&e.sectionIndex===t.sectionIndex&&e.variant===t.variant&&e.rId===t.rId&&e.partName===t.partName&&e.inherited===t.inherited&&e.titlePage===t.titlePage&&e.evenAndOddHeaders===t.evenAndOddHeaders&&e.headerDistanceTwips===t.headerDistanceTwips&&e.footerDistanceTwips===t.footerDistanceTwips}function Ud(){let e=F(),t=lt.useCallback(o=>e?.getHeaderFooterState()??null,[e]);return O(t,Cw)}function Ew(e,t){return t==="first"?e==="header"?"headerFooter.firstPageHeader":"headerFooter.firstPageFooter":t==="even"?e==="header"?"headerFooter.evenPageHeader":"headerFooter.evenPageFooter":e==="header"?"headerFooter.header":"headerFooter.footer"}var ww=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function ka(e){let t=F();return lt.useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let o=t.can(e);return o.ok?{enabled:true,reason:null}:{enabled:false,reason:o.reason}},[t,e])}function Rw(e){let{state:t,onMouseDown:o}=e,{t:n}=L(),r=F(),[i,a]=lt.useState(false),l=lt.useRef(null),[s,c]=lt.useState(""),[d,f]=lt.useState("");lt.useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(c(String(Wd(t.headerDistanceTwips))),f(String(Wd(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),lt.useEffect(()=>{if(!i)return;let w=S=>{l.current?.contains(S.target)||a(false);};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]);let u=lt.useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=lt.useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),p=lt.useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),m=lt.useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),b=lt.useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),h=ka(u),x=ka(g),v=ka(p),y=ka(m),C=ka(b),T=(w,S)=>{if(!r)return;let M=Number.parseFloat(S);Number.isFinite(M)&&r.exec({type:"setHeaderFooterOptions",[w]:w0(M)});};return jsxRuntime.jsxs("div",{ref:l,className:"docx-hf-chrome__options",onMouseDown:o,children:[jsxRuntime.jsx("button",{type:"button",className:"docx-context-bar__options-trigger","aria-expanded":i,"aria-haspopup":"menu",onClick:()=>a(w=>!w),onMouseDown:o,children:n("headerFooter.options")}),i?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:o,children:[ww.map(w=>{let S={type:"insertPageField",field:w.field},M=r?.can(S);return jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!M?.ok,title:M&&!M.ok?M.reason:void 0,onClick:()=>{r?.exec(S),a(false);},onMouseDown:o,children:n(w.labelKey)},w.field)}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.titlePage===true,disabled:!h.enabled,title:h.reason??void 0,onChange:()=>r?.exec(u)}),jsxRuntime.jsx("span",{children:n("headerFooter.differentFirstPage")})]}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!x.enabled,title:x.reason??void 0,onChange:()=>r?.exec(g)}),jsxRuntime.jsxs("span",{children:[n("headerFooter.differentOddEven"),jsxRuntime.jsx("span",{className:"docx-hf-chrome__menu-hint",children:n("headerFooter.differentOddEvenHint")})]})]}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),t.inherited?jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!y.enabled,title:y.reason??void 0,onClick:()=>r?.exec(m),onMouseDown:o,children:n("headerFooter.unlinkFromPrevious")}):jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!v.enabled,title:v.reason??void 0,onClick:()=>r?.exec(p),onMouseDown:o,children:n("headerFooter.linkToPrevious")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsxRuntime.jsx("span",{children:n("headerFooter.headerDistance")}),jsxRuntime.jsx("input",{type:"number",min:0,step:.01,"aria-label":n("headerFooter.headerDistance"),value:s,onChange:w=>c(w.target.value),onBlur:()=>T("headerDistanceTwips",s)}),jsxRuntime.jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsxRuntime.jsx("span",{children:n("headerFooter.footerDistance")}),jsxRuntime.jsx("input",{type:"number",min:0,step:.01,"aria-label":n("headerFooter.footerDistance"),value:d,onChange:w=>f(w.target.value),onBlur:()=>T("footerDistanceTwips",d)}),jsxRuntime.jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!C.enabled,title:C.reason??void 0,onClick:()=>r?.exec(b),onMouseDown:o,children:t.editing==="header"?n("headerFooter.removeHeader"):n("headerFooter.removeFooter")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-hf-close",onClick:()=>{r?.exec({type:"exitHeaderFooter"}),a(false);},onMouseDown:o,children:n("common.close")})]}):null]})}function Sl({className:e}){let{t}=L(),o=Ud(),n=lt.useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),r=Dr(n,"story-label"),i=Z;if(!o?.editing)return null;let a=Ew(o.editing,o.variant);return jsxRuntime.jsxs("div",{ref:r.ref,className:`docx-context-bar docx-hf-chrome${e?` ${e}`:""}`,role:"region","aria-label":t("headerFooter.chromeAriaLabel"),"data-testid":"docx-hf-chrome",onMouseDown:i,style:{...r.style,zIndex:Qe.hfInlineEditor},children:[jsxRuntime.jsxs("div",{className:"docx-context-bar__label",children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:t(a)}),o.inherited?jsxRuntime.jsx("span",{className:"docx-context-bar__status","data-testid":"docx-hf-inherited",title:t("headerFooter.sameAsPreviousHint"),children:t("headerFooter.sameAsPrevious")}):null]}),jsxRuntime.jsx(Rw,{state:o,onMouseDown:i})]})}var Iw={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},_w={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},Nw={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},Lw={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},Fw={position:"absolute",top:40,left:0,zIndex:10,pointerEvents:"none"},Aw={flex:"none",display:"flex",flexDirection:"column",position:"relative",zIndex:"var(--doc-z-overlay)",backgroundColor:"var(--doc-surface)",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--doc-border)",boxShadow:"0 1px 3px var(--doc-shadow-subtle)"},Hw={padding:"8px 12px"},Ow={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},Bw={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},Zw={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function qw({forwardedRef:e}){let t=F(),o=lt.useRef(null);return o.current=t,Dm({ref:e,editorRef:o}),null}var Kw=lt.forwardRef(function(t,o){let{document:n,fonts:r,className:i,t:a,chrome:l=true,title:s,onTitleChange:c,renderTitleBarLeft:d,renderTitleBarRight:f,colorMode:u="light",author:g,locale:p,mode:m="edit",modules:b,zoom:h,zoomMode:x,onReady:v,onChange:y,onFontError:C,onOpen:T,onSave:w,hyperlinkPopup:S,contextMenu:M=true,menu:R=true,navigation:D=true,rulers:_=true}=t,[H,N]=lt.useState(zp);lt.useEffect(()=>{if(u==="system")return $p(N)},[u]);let I=Vp(u,H),{t:P}=L(),k=lt.useCallback((V,te)=>a?a(V,te):P(V,te),[a,P]),Y=jsxRuntime.jsxs(Ii,{className:l?I?"dark":void 0:i,style:l?_w:void 0,children:[l?jsxRuntime.jsx(Sl,{}):null,l?jsxRuntime.jsx(di,{}):null,jsxRuntime.jsx(wi,{}),_&&l?jsxRuntime.jsx("div",{style:Fw,"aria-hidden":"true",children:jsxRuntime.jsx(ml,{})}):null,t.children]}),z=l?jsxRuntime.jsxs("div",{className:`docx-editor${I?" dark":""}${i?` ${i}`:""}`,style:Iw,children:[jsxRuntime.jsxs("div",{style:Aw,children:[jsxRuntime.jsxs("div",{style:Ow,children:[d?.(),jsxRuntime.jsxs("div",{style:Bw,children:[c?jsxRuntime.jsx("input",{"aria-label":k("titleBar.documentNameAriaLabel"),value:s??"",placeholder:k("titleBar.untitled"),onChange:V=>c(V.target.value),style:Zw}):jsxRuntime.jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:s??k("titleBar.untitled")}),R!==false?jsxRuntime.jsx(ma,{t:k,...s!==void 0?{fileName:s}:{},...T?{onOpen:T}:{},...w?{onSave:w}:{},...typeof R=="object"?R:{}}):null]}),f?.()]}),jsxRuntime.jsx("div",{style:Hw,children:jsxRuntime.jsx(ua,{t:k})})]}),_?jsxRuntime.jsx("div",{style:Lw,"data-testid":"docx-editor-ruler-row",children:jsxRuntime.jsx(pl,{})}):null,jsxRuntime.jsx(Cl,{t:k}),jsxRuntime.jsxs("div",{style:Nw,children:[D===false?null:jsxRuntime.jsx(yl,{t:k,...typeof D=="object"?D:{}}),Y,jsxRuntime.jsx(xl.Provider,{value:k,children:jsxRuntime.jsx(Tl,{})}),jsxRuntime.jsx(Mi,{overlay:true})]})]}):Y,re=lt.useCallback(V=>k(V),[k]);return jsxRuntime.jsxs(qr,{popups:xp(t.popups,S,M,k),...n!==void 0?{document:n}:{},...r?{fonts:r}:{},...g!==void 0?{author:g}:{},...p!==void 0?{locale:p}:{},translate:k,mode:m,...b!==void 0?{modules:b}:{},...h!==void 0?{zoom:h}:{},...x!==void 0?{zoomMode:x}:{},tableInteractionLabel:re,...v?{onReady:v}:{},...y?{onChange:y}:{},...C?{onFontError:C}:{},children:[jsxRuntime.jsx(qw,{forwardedRef:o}),jsxRuntime.jsx(Bo.Provider,{value:l,children:z})]})}),zw=lt.forwardRef(function(t,o){return jsxRuntime.jsx(bn,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsxRuntime.jsx(Kw,{...t,ref:o})})}),Vw=Object.assign(zw,{Root:qr,Viewport:Ii,Content:wi,Toolbar:ua,Menu:ma,Loading:Mi,ColorByChangeType:Cc,AuthorStyle:Sc,HorizontalRuler:pl,VerticalRuler:ml,DocumentOutline:Hd,Navigation:yl,PageSetupDialog:Vo,ParagraphDialog:Gt,TextFormFieldDialog:Ar,PageNumber:Tl,FontNotice:Cl,HeaderFooterChrome:Sl,NotesChrome:di,Equation:gr,HyperLink:ur,ContextMenu:Ks,ContentControlWidget:lc,InvalidTextFormFieldDialog:ac,ImageAltTextPopup:hi,ImagePropertiesDialog:_r,NotePropertiesDialog:ui,NotePreview:yn,NotesContextMenu:xn,ContentControl:fr});function jw(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}function jd(e){return Array.isArray(e)?e:[e]}function Yw(e){if(typeof e!="function"||editor.isFontResolver(e))return e;let t=e;return editor.defineFontResolver(async()=>t())}function I0(e){return e!==void 0&&jd(e).some(t=>editor.isFontResolver(t))}async function Xw(e){return typeof e!="function"?await e:await e()}function Qw(e,t={}){let[o,n]=lt.useState(void 0),[r,i]=lt.useState(void 0),[a,l]=lt.useState(null),[s,c]=lt.useState(e!=null),d=I0(t.fonts),f=t.fonts===void 0?"absent":d?"on-demand":"eager",[u,g]=lt.useState(t.fonts===void 0),p=lt.useRef(t);p.current=t;let m=lt.useMemo(()=>editor.defineFontResolver(b=>editor.composeFontOrigins(jd(p.current.fonts??[]).map(Yw),b)),[]);return lt.useEffect(()=>{let b=p.current.fonts;if(b===void 0){i(void 0),g(true);return}if(I0(b)){g(true);return}g(false);let h=true;return (async()=>{try{let x=await Promise.allSettled(jd(b).map(Xw)),v=[];for(let y of x){if(y.status==="rejected"){console.warn("[fonts] font loading failed for one origin; the others still compose",y.reason);continue}y.value!==void 0&&v.push(y.value);}h&&v.length>0&&i(editor.composeFontConfiguration(v[0],...v.slice(1)));}catch(x){console.warn("[fonts] font loading failed; the fixed measurer stays in effect",x);}finally{h&&g(true);}})(),()=>{h=false;}},[f]),lt.useEffect(()=>{if(e==null){n(void 0),l(null),c(false);return}let b=jw(e);if(b){n(b),l(null),c(false);return}let h=true,x=new AbortController;return c(true),l(null),(async()=>{try{let v=await fetch(String(e),{...p.current.fetchOptions,signal:x.signal});if(!v.ok)throw new Error(`could not open the document: ${v.status} ${v.statusText}`);let y=new Uint8Array(await v.arrayBuffer());if(!h)return;n(y),c(!1);}catch(v){if(!h||v instanceof Error&&v.name==="AbortError")return;l(v instanceof Error?v:new Error("could not open the document")),c(false);}})(),()=>{h=false,x.abort();}},[e]),{document:u?o:void 0,fonts:d?m:r,error:a,isLoading:s||!u}}function n8(...e){let t=lt.useRef(e);return t.current=e,lt.useMemo(()=>editor.defineFontResolver(o=>editor.composeFontOrigins(t.current,o)),[])}function i8(e){let o=e?.surface?.state?.().selection?.head;return o&&typeof o.paragraphId=="string"&&Number.isFinite(o.offset)?o:null}function l8(){let e=F(),t=lt.useRef(null),o=lt.useCallback(r=>{if(!e)return ()=>{};let i=e.on("selectionChange",r),a=e.on("change",r);return ()=>{i(),a();}},[e]),n=lt.useCallback(()=>{let r=i8(e),i=t.current;return (r===null?i===null:i!==null&&s8(i,r))?i:(t.current=r,r)},[e]);return lt.useSyncExternalStore(o,n,()=>null)}function s8(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function Yd({source:e,scale:t,measurer:o,onStateChange:n,onError:r,className:i,documentFontFamily:a,ref:l}){let s=lt.useRef(null),c=lt.useRef(null),[d,f]=lt.useState(null),u=lt.useRef(n);u.current=n;let g=lt.useRef(r);return g.current=r,lt.useEffect(()=>{let p=s.current;if(!p)return;let m=editor.mountPaginatedSurface(p,e,{...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onChange:h=>{f(h),u.current?.(h);}});if(!m.ok){g.current?.(m.reason,m.detail);return}c.current=m.surface;let b=m.surface.state();return f(b),u.current?.(b),()=>{m.surface.destroy(),c.current=null;}},[e,o]),lt.useImperativeHandle(l,()=>({focus:()=>c.current?.focus(),type:p=>c.current?.type(p),undo:()=>c.current?.undo(),redo:()=>c.current?.redo(),selectAll:()=>c.current?.selectAll(),navigate:(p,m)=>c.current?.navigate(p,m),toggleRunProperty:(p,m)=>c.current?.toggleRunProperty(p,m),setRunProperty:(p,m)=>c.current?.setRunProperty(p,m),setParagraphProperty:(p,m,b)=>c.current?.setParagraphProperty(p,m,b),formatting:()=>c.current?.formatting()??null,sectionProperties:()=>c.current?.sectionProperties()??null,save:()=>c.current?.save()??null}),[]),jsxRuntime.jsx("div",{ref:s,style:{margin:"24px auto",...a?{fontFamily:a}:{}},className:i?`docx-paginated-surface ${i}`:"docx-paginated-surface","data-revision":d?.revision??0,"data-page-count":d?.pageCount??0})}var Ia=lt.createContext(null);function F0(){let e=lt.useContext(Ia);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function h8(e){return "type"in e&&e.type==="separator"}var O0={display:"flex",alignItems:"center",gap:2,padding:"2px 8px",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text)",whiteSpace:"nowrap",height:28,lineHeight:"28px"},v8={...O0,background:"var(--doc-bg-hover)"},B0={display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap"},y8={...B0,opacity:.4,cursor:"default"},x8={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},T8={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},C8={position:"absolute",left:"100%",top:-4,marginLeft:2,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",padding:8,zIndex:1001};function _a({label:e,items:t,disabled:o,showChevron:n=false}){let[r,i]=lt.useState(false),[a,l]=lt.useState(null),s=lt.useRef(null),c=lt.useRef(null),[d,f]=lt.useState({top:0,left:0}),u=lt.useCallback(()=>{i(false),l(null);},[]);lt.useEffect(()=>{if(!r||!s.current)return;let p=s.current.getBoundingClientRect();f({top:p.bottom+2,left:p.left});},[r]),lt.useEffect(()=>{if(!r)return;function p(h){let x=h.target;s.current&&!s.current.contains(x)&&c.current&&!c.current.contains(x)&&u();}function m(h){h.key==="Escape"&&u();}function b(){u();}return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),window.addEventListener("scroll",b,true),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m),window.removeEventListener("scroll",b,true);}},[r,u]);let g=p=>{p.disabled||p.submenuContent||p.onClick&&(p.onClick(),u());};return jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:s,type:"button",onClick:()=>!o&&i(!r),onMouseDown:p=>p.preventDefault(),disabled:o,style:r?v8:O0,children:[e,n&&jsxRuntime.jsx($,{name:"arrow_drop_down",size:16})]}),r&&jsxRuntime.jsx("div",{ref:c,style:{position:"fixed",top:d.top,left:d.left,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",padding:"4px 0",zIndex:1e4,minWidth:200},onMouseDown:p=>p.preventDefault(),children:t.map((p,m)=>{if(h8(p))return jsxRuntime.jsx("div",{style:x8},`sep-${m}`);let b=p;if(b.customContent)return jsxRuntime.jsx("div",{onMouseDown:v=>v.preventDefault(),children:b.customContent},b.label);let h=!!b.submenuContent,x=a===b.label;return jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>h&&l(b.label),onMouseLeave:()=>h&&l(null),children:[jsxRuntime.jsxs("button",{type:"button",style:b.disabled?y8:B0,onClick:()=>g(b),onMouseDown:v=>v.preventDefault(),onMouseOver:v=>{b.disabled||(v.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:v=>{v.currentTarget.style.backgroundColor="transparent";},disabled:b.disabled,children:[b.icon&&jsxRuntime.jsx($,{name:b.icon,size:18}),jsxRuntime.jsx("span",{children:b.label}),b.shortcut&&jsxRuntime.jsx("span",{style:T8,children:b.shortcut}),h&&jsxRuntime.jsx("span",{style:{marginLeft:"auto"},children:jsxRuntime.jsx($,{name:"keyboard_arrow_right",size:16})})]}),h&&x&&jsxRuntime.jsx("div",{style:C8,onMouseDown:v=>v.preventDefault(),children:b.submenuContent(u)})]},b.label)})})]})}var Jd=18,P8=2,q0={width:Jd,height:Jd,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},E8={...q0,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},w8={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function K0({onInsert:e,gridRows:t=6,gridColumns:o=6}){let[n,r]=lt.useState(0),[i,a]=lt.useState(0),l=lt.useCallback(()=>{n>0&&i>0&&e(n,i);},[n,i,e]),s=[];for(let d=1;d<=t;d++)for(let f=1;f<=o;f++){let u=d<=n&&f<=i;s.push(jsxRuntime.jsx("div",{style:u?E8:q0,onMouseEnter:()=>{r(d),a(f);},onClick:l,role:"gridcell","aria-selected":u},`${d}-${f}`));}let c=n>0&&i>0?`${i} \xD7 ${n}`:"Select size";return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"grid",gap:P8,gridTemplateColumns:`repeat(${o}, ${Jd}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:s}),jsxRuntime.jsx("div",{style:w8,children:c})]})}function D8({items:e,closeMenu:t}){return jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",minWidth:220},children:e.map(o=>{let n=!o.onClick;return jsxRuntime.jsxs("button",{type:"button",disabled:n,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:n?"default":"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap",opacity:n?.4:1},onMouseDown:r=>r.preventDefault(),onClick:()=>{n||(o.onClick?.(),t());},onMouseOver:r=>{n||(r.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:r=>{r.currentTarget.style.backgroundColor="transparent";},children:[jsxRuntime.jsx($,{name:o.icon,size:18}),jsxRuntime.jsx("span",{children:o.label})]},o.label)})})}function I8(){return jsxRuntime.jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M2 0C0.9 0 0 0.9 0 2V38C0 39.1 0.9 40 2 40H30C31.1 40 32 39.1 32 38V10L22 0H2Z",fill:"#cbd5e1"}),jsxRuntime.jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsxRuntime.jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function wl({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function _8(e){return e.replace(/\.docx$/i,"")}function tu({value:e,onChange:t,placeholder:o,editable:n=true}){let{t:r}=L(),i=o??r("titleBar.untitled"),a=_8(e)??"";return n?jsxRuntime.jsx("input",{type:"text",value:a,onChange:l=>{let s=l.target.value;t?.(s.endsWith(".docx")?s:s+".docx");},placeholder:i,className:"text-base font-normal text-foreground bg-transparent border-0 outline-none px-2 py-0 rounded hover:bg-muted focus:bg-doc-bg-input focus:ring-1 focus:ring-ring min-w-[100px] max-w-[300px] truncate leading-tight","aria-label":r("titleBar.documentNameAriaLabel")}):jsxRuntime.jsx("span",{className:"text-base font-normal text-foreground px-2 py-0 min-w-[100px] max-w-[300px] truncate leading-tight",children:a||i})}function Rl({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function Ml(){let{t:e}=L(),t=F0(),{disabled:o=false,onFormat:n,onPrint:r,onOpen:i,onSave:a,onPageSetup:l,onInsertImage:s,onInsertTable:c,showTableInsert:d=true,showHelpMenu:f=true,onInsertPageBreak:u,onInsertSectionBreakNextPage:g,onInsertSectionBreakContinuous:p,onInsertTOC:m,onWatermark:b,onRefocusEditor:h}=t,x=lt.useCallback(T=>{!o&&n&&n(T);},[o,n]),v=lt.useCallback((T,w)=>{!o&&c&&(c(T,w),requestAnimationFrame(()=>h?.()));},[o,c,h]),y=!!r||!!l,C=y||i||a;return jsxRuntime.jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[C&&jsxRuntime.jsx(_a,{label:e("toolbar.file"),disabled:o,items:[...i?[{icon:"file_upload",label:e("toolbar.open"),shortcut:e("toolbar.openShortcut"),onClick:i}]:[],...a?[{icon:"file_download",label:e("toolbar.save"),shortcut:e("toolbar.saveShortcut"),onClick:a}]:[],...(i||a)&&y?[{type:"separator"}]:[],...r?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:r}]:[],...l?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:l}]:[]]}),jsxRuntime.jsx(_a,{label:e("toolbar.format"),disabled:o,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>x("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>x("setRtl")}]}),jsxRuntime.jsx(_a,{label:e("toolbar.insert"),disabled:o,items:[...s?[{icon:"image",label:e("toolbar.image"),onClick:s}]:[],...d&&c?[{icon:"grid_on",label:e("toolbar.table"),submenuContent:T=>jsxRuntime.jsx(K0,{onInsert:(w,S)=>{v(w,S),T();}})}]:[],...s||d&&c?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:T=>jsxRuntime.jsx(D8,{closeMenu:T,items:[{icon:"page_break",label:e("toolbar.pageBreak"),onClick:u},{icon:"horizontal_rule",label:e("toolbar.sectionBreakNextPage"),onClick:g},{icon:"border_horizontal",label:e("toolbar.sectionBreakContinuous"),onClick:p}]})},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:m,disabled:!m},...b?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:b}]:[]]}),f&&jsxRuntime.jsx(_a,{label:e("toolbar.help"),disabled:o,items:[{label:e("toolbar.reportIssue"),onClick:()=>hr()}]})]})}function ou({children:e}){let t=null,o=null,n=[],r=[];lt.Children.forEach(e,a=>{lt.isValidElement(a)&&(a.type===wl?t=a:a.type===Rl?o=a:a.type===Ml?r.push(a):n.push(a));});let i=lt.useCallback(a=>{let l=a.target;l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.tagName==="SELECT"||l.tagName==="OPTION"||a.preventDefault();},[]);return jsxRuntime.jsxs("div",{className:"flex items-stretch bg-doc-surface pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsxRuntime.jsx(I8,{})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[n.length>0&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-1",children:n}),r.length>0&&jsxRuntime.jsx("div",{className:"flex items-center px-1",children:r})]}),o&&jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:o})]})}var kl={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},A8={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""},z0={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function H8(e,t){let o=z0[t]??z0[t.toLowerCase()]??t,r=e?.colorScheme?.[o];return typeof r=="string"&&r?r:kl[o]??"000000"}function V0(e){let t=e.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/.test(t))return t;if(/^[0-9A-F]{3}$/.test(t))return t.split("").map(o=>o+o).join("")}function nu(e,t,o="000000"){if(!e||e.kind==="auto")return `#${o}`;if(e.kind==="hex")return `#${V0(e.value)??o}`;let n=Object.entries(t?.colorScheme??kl).map(([i,a])=>({slot:i,hex:String(a)})),r=editor.resolveThemeColorHex(e,n);return `#${r.ok?r.hex:H8(t,e.slot)}`}function Jt(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?V0(e.value):nu(e,t).slice(1)}function $0(e){if(!e||e==="none")return "";let t=A8[e];return t?`#${t}`:""}var O8=[{slot:"lt1",name:"Background 1"},{slot:"dk1",name:"Text 1"},{slot:"lt2",name:"Background 2"},{slot:"dk2",name:"Text 2"},{slot:"accent1",name:"Accent 1"},{slot:"accent2",name:"Accent 2"},{slot:"accent3",name:"Accent 3"},{slot:"accent4",name:"Accent 4"},{slot:"accent5",name:"Accent 5"},{slot:"accent6",name:"Accent 6"}],B8=[{type:"base",keep:1,labelSuffix:""},{type:"tint",keep:.2,labelSuffix:", Lighter 80%"},{type:"tint",keep:.4,labelSuffix:", Lighter 60%"},{type:"tint",keep:.6,labelSuffix:", Lighter 40%"},{type:"shade",keep:.75,labelSuffix:", Darker 25%"},{type:"shade",keep:.5,labelSuffix:", Darker 50%"}];function W0(e){let t=e??kl;return B8.map(o=>O8.map(n=>{let r=t[n.slot]??kl[n.slot]??"000000",a={hex:o.type==="base"?r.toUpperCase():o.type==="tint"?editor.applyThemeTint(r,o.keep):editor.applyThemeShade(r,o.keep),themeSlot:n.slot,label:`${n.name}${o.labelSuffix}`};return o.type==="tint"?a.tint=o.keep:o.type==="shade"&&(a.shade=o.keep),a}))}function ne(...e){return clsx.clsx(e)}var K8=classVarianceAuthority.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-9 w-9","icon-sm":"h-7 w-7"}},defaultVariants:{variant:"default",size:"default"}}),qe=lt__namespace.forwardRef(({className:e,variant:t,size:o,...n},r)=>jsxRuntime.jsx("button",{className:ne(K8({variant:t,size:o,className:e})),ref:r,...n}));qe.displayName="Button";function pt({content:e,children:t,side:o="bottom",delayMs:n=400}){let[r,i]=lt__namespace.useState(false),[a,l]=lt__namespace.useState({x:0,y:0}),s=lt__namespace.useRef(null),c=lt__namespace.useRef(null),d=lt__namespace.useCallback(()=>{c.current=setTimeout(()=>{if(s.current){let p=s.current.getBoundingClientRect(),m=p.left+p.width/2,b=o==="top"?p.top-8:p.bottom+8;l({x:m,y:b});}i(true);},n);},[n,o]),f=lt__namespace.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null),i(false);},[]);lt__namespace.useEffect(()=>()=>{c.current&&clearTimeout(c.current);},[]);let u=t.props,g=lt__namespace.cloneElement(t,{ref:s,onMouseEnter:p=>{d(),u.onMouseEnter?.(p);},onMouseLeave:p=>{f(),u.onMouseLeave?.(p);}});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g,r&&jsxRuntime.jsx("div",{className:"fixed z-50 px-2 py-1 text-xs font-medium text-white bg-foreground dark:bg-muted dark:text-foreground rounded-md shadow-lg",style:{left:a.x,top:a.y,transform:o==="top"?"translate(-50%, -100%)":o==="bottom"?"translate(-50%, 0)":void 0},children:e})]})}var xo=xe__namespace.Root,To=xe__namespace.Group,Dl=xe__namespace.Value;function Co({className:e,children:t,onMouseDown:o,...n}){return jsxRuntime.jsxs(xe__namespace.Trigger,{className:ne("flex h-8 items-center justify-between gap-1 rounded px-2 py-1","text-sm text-foreground bg-transparent","hover:bg-muted/80 focus:outline-none focus:bg-muted/80","disabled:cursor-not-allowed disabled:opacity-50","transition-colors duration-150","[&>span]:truncate",e),onMouseDown:r=>{r.preventDefault(),o?.(r);},...n,children:[t,jsxRuntime.jsx(xe__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(U8,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function So({className:e,children:t,position:o="popper",onCloseAutoFocus:n,...r}){let i=typeof document<"u"&&!!document.querySelector(".docx-editor.dark");return jsxRuntime.jsx(xe__namespace.Portal,{children:jsxRuntime.jsx("div",{className:ne("docx-editor",i&&"dark"),children:jsxRuntime.jsx(xe__namespace.Content,{className:ne("relative z-50 max-h-72 min-w-[8rem] overflow-hidden","rounded-lg border border-border bg-popover text-popover-foreground shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",e),position:o,onCloseAutoFocus:a=>{a.preventDefault(),n?.(a);},...r,children:jsxRuntime.jsx(xe__namespace.Viewport,{className:ne("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:a=>a.preventDefault(),children:t})})})})}function an({className:e,...t}){return jsxRuntime.jsx(xe__namespace.Label,{className:ne("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function mt({className:e,children:t,onMouseDown:o,...n}){return jsxRuntime.jsxs(xe__namespace.Item,{className:ne("relative flex w-full cursor-pointer select-none items-center","rounded px-2 py-1.5 text-sm text-foreground outline-none","hover:bg-muted focus:bg-muted","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onMouseDown:r=>{r.preventDefault(),o?.(r);},...n,children:[jsxRuntime.jsx(xe__namespace.ItemText,{children:t}),jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(xe__namespace.ItemIndicator,{children:jsxRuntime.jsx(G8,{className:"h-4 w-4"})})})]})}function ln({className:e,...t}){return jsxRuntime.jsx(xe__namespace.Separator,{className:ne("-mx-1 my-1 h-px bg-muted",e),...t})}function U8({className:e}){return jsxRuntime.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})}function G8({className:e}){return jsxRuntime.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})}function ru(e){let t=e.trim();if(!t)return "";let o=null,n="";for(let r of t){if((r==='"'||r==="'")&&o===null){o=r,n+=r;continue}if(r===o){o=null,n+=r;continue}if(r===","&&o===null)break;n+=r;}return n.trim().replace(/^['"]|['"]$/g,"")}var j8=[{name:"Arial",fontFamily:"Arial, Helvetica, sans-serif",category:"sans-serif"},{name:"Calibri",fontFamily:'"Calibri", Arial, sans-serif',category:"sans-serif"},{name:"Helvetica",fontFamily:"Helvetica, Arial, sans-serif",category:"sans-serif"},{name:"Verdana",fontFamily:"Verdana, Geneva, sans-serif",category:"sans-serif"},{name:"Open Sans",fontFamily:'"Open Sans", sans-serif',category:"sans-serif"},{name:"Roboto",fontFamily:"Roboto, sans-serif",category:"sans-serif"},{name:"Times New Roman",fontFamily:'"Times New Roman", Times, serif',category:"serif"},{name:"Georgia",fontFamily:"Georgia, serif",category:"serif"},{name:"Cambria",fontFamily:"Cambria, Georgia, serif",category:"serif"},{name:"Garamond",fontFamily:"Garamond, serif",category:"serif"},{name:"Courier New",fontFamily:'"Courier New", Courier, monospace',category:"monospace"},{name:"Consolas",fontFamily:"Consolas, monospace",category:"monospace"}];function j0({value:e,onChange:t,fonts:o=j8,documentFonts:n,disabled:r=false,className:i,placeholder:a="Arial",width:l=120,showPreview:s=true}){let{t:c}=L(),d=lt__namespace.useMemo(()=>{if(!n)return [];let m=new Set(o.map(b=>b.name.toLowerCase()));return n.filter(b=>!m.has(b.name.toLowerCase()))},[n,o]),f=lt__namespace.useMemo(()=>[...d,...o],[d,o]),u=lt__namespace.useMemo(()=>e?f.find(b=>b.fontFamily===e||b.name.toLowerCase()===e.toLowerCase()||ru(b.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,f,a]),g=lt__namespace.useCallback(m=>{let b=f.find(h=>h.name===m);b&&t?.(ru(b.fontFamily)||b.name);},[t,f]),p=lt__namespace.useMemo(()=>{let m={"sans-serif":[],serif:[],monospace:[],other:[]};return o.forEach(b=>{let h=b.category||"other";m[h].push(b);}),m},[o]);return jsxRuntime.jsxs(xo,{value:u,onValueChange:g,disabled:r,children:[jsxRuntime.jsx(Co,{className:ne("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":c("font.selectAriaLabel"),children:jsxRuntime.jsx(Dl,{placeholder:a,children:u})}),jsxRuntime.jsxs(So,{className:"max-h-[300px]",children:[d.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(To,{children:[jsxRuntime.jsx(an,{children:c("font.documentFonts")}),d.map(m=>jsxRuntime.jsx(mt,{value:m.name,style:s?{fontFamily:m.fontFamily}:void 0,children:m.name},`doc-${m.name}`))]}),jsxRuntime.jsx(ln,{})]}),p["sans-serif"].length>0&&jsxRuntime.jsxs(To,{children:[jsxRuntime.jsx(an,{children:c("font.sansSerif")}),p["sans-serif"].map(m=>jsxRuntime.jsx(mt,{value:m.name,style:s?{fontFamily:m.fontFamily}:void 0,children:m.name},m.name))]}),p.serif.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ln,{}),jsxRuntime.jsxs(To,{children:[jsxRuntime.jsx(an,{children:c("font.serif")}),p.serif.map(m=>jsxRuntime.jsx(mt,{value:m.name,style:s?{fontFamily:m.fontFamily}:void 0,children:m.name},m.name))]})]}),p.monospace.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ln,{}),jsxRuntime.jsxs(To,{children:[jsxRuntime.jsx(an,{children:c("font.monospace")}),p.monospace.map(m=>jsxRuntime.jsx(mt,{value:m.name,style:s?{fontFamily:m.fontFamily}:void 0,children:m.name},m.name))]})]}),p.other.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ln,{}),jsxRuntime.jsx(To,{children:p.other.map(m=>jsxRuntime.jsx(mt,{value:m.name,style:s?{fontFamily:m.fontFamily}:void 0,children:m.name},m.name))})]})]})]})}function au(e){if(e===void 0)return;let t=e.map(o=>typeof o=="string"?{name:o,fontFamily:o,category:"other"}:o);return t}function J8(e,t,o,n){let i=Math.max(8,window.innerWidth-o-8),a=Math.max(8,window.innerHeight-n-8);return {top:Math.min(Math.max(8,e),a),left:Math.min(Math.max(8,t),i)}}function rt({isOpen:e,onClose:t,align:o="left"}){let n=lt.useRef(null),r=lt.useRef(null),[i,a]=lt.useState({top:0,left:0});lt.useEffect(()=>{if(!e||!n.current)return;let c=n.current.getBoundingClientRect();o==="right"?requestAnimationFrame(()=>{if(r.current){let d=r.current.getBoundingClientRect(),f=J8(c.bottom+4,c.right-d.width,d.width,d.height);a(f);}else a({top:c.bottom+4,left:c.left});}):a({top:c.bottom+4,left:c.left});},[e,o]),lt.useEffect(()=>{if(!e)return;let c=performance.now()+150,d=g=>{let p=g.target;n.current&&!n.current.contains(p)&&r.current&&!r.current.contains(p)&&t();},f=g=>{g.key==="Escape"&&t();},u=g=>{if(performance.now()<c)return;let p=g.target;p&&r.current&&r.current.contains(p)||p instanceof Element&&p!==document.documentElement&&p!==document.body&&n.current&&p.contains(n.current)||t();};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),window.addEventListener("scroll",u,true),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f),window.removeEventListener("scroll",u,true);}},[e,t]);let l=lt.useCallback(c=>{c.preventDefault(),c.stopPropagation();},[]),s={position:"fixed",top:i.top,left:i.left,zIndex:1e4};return {containerRef:n,dropdownRef:r,dropdownStyle:s,handleMouseDown:l}}var oR=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],nR=1,rR=400;function Q0(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function J0(e,t,o){for(let n=t.length-1;n>=0;n--)if(t[n]<e)return t[n];return Math.max(e-1,o)}function eb({value:e,onChange:t,sizes:o=oR,disabled:n=false,className:r,placeholder:i="11",minSize:a=nR,maxSize:l=rR}){let{t:s}=L(),[c,d]=lt.useState(false),[f,u]=lt.useState(""),[g,p]=lt.useState(false),m=lt.useRef(null),b=lt.useCallback(()=>{p(false),d(false);},[]),{containerRef:h,dropdownRef:x,dropdownStyle:v}=rt({isOpen:g,onClose:b}),y=e??(parseInt(i,10)||11),C=e!==void 0?e.toString():i,T=lt.useCallback(N=>{if(N.preventDefault(),n)return;let I=J0(y,o,a);t?.(I);},[y,o,a,n,t]),w=lt.useCallback(N=>{if(N.preventDefault(),n)return;let I=Q0(y,o,l);t?.(I);},[y,o,l,n,t]),S=lt.useCallback(N=>{N.preventDefault(),!n&&(d(true),u(C),p(true),requestAnimationFrame(()=>{m.current?.focus(),m.current?.select();}));},[n,C]),M=lt.useCallback(N=>{u(N.target.value);},[]),R=lt.useCallback(()=>{d(false);let N=parseFloat(f);if(!isNaN(N)&&N>=a&&N<=l){let I=Math.round(N*2)/2;t?.(I);}},[f,a,l,t]),D=lt.useCallback(N=>{if(N.key==="Enter")N.preventDefault(),R(),p(false);else if(N.key==="Escape")d(false),p(false);else if(N.key==="ArrowUp"){N.preventDefault();let I=Q0(y,o,l);u(I.toString()),t?.(I);}else if(N.key==="ArrowDown"){N.preventDefault();let I=J0(y,o,a);u(I.toString()),t?.(I);}},[R,y,o,l,a,t]),_=lt.useCallback(N=>{t?.(N),p(false),d(false);},[t]),H=lt.useCallback(N=>{N.target.tagName!=="INPUT"&&N.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:h,className:ne("flex items-center",r),onMouseDown:H,children:[jsxRuntime.jsx(qe,{variant:"ghost",size:"icon-sm",className:ne("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:T,disabled:n||y<=a,"aria-label":s("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsxRuntime.jsx($,{name:"remove",size:18})}),jsxRuntime.jsx("div",{className:"relative",children:c?jsxRuntime.jsx("input",{ref:m,type:"text",value:f,onChange:M,onBlur:R,onKeyDown:D,className:ne("h-7 w-10 text-center text-sm border border-input bg-doc-bg-input text-doc-text","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none"),"aria-label":s("fontSize.label"),"data-testid":"font-size-input"}):jsxRuntime.jsx("button",{type:"button",onClick:S,className:ne("h-7 w-10 text-center text-sm border border-border bg-doc-bg-input text-doc-text","hover:border-input hover:bg-doc-bg-hover","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none",n&&"opacity-50 cursor-not-allowed"),disabled:n,"aria-label":s("fontSize.label"),"aria-haspopup":"listbox","aria-expanded":g,"data-testid":"font-size-display",children:C})}),g&&jsxRuntime.jsx("div",{ref:x,style:{...v,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",maxHeight:240,overflowY:"auto",minWidth:60},role:"listbox","aria-label":s("fontSize.listLabel"),children:o.map(N=>jsxRuntime.jsx("button",{type:"button",onClick:()=>_(N),className:ne("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",N===y&&"bg-muted font-medium"),role:"option","aria-selected":N===y,children:N},N))}),jsxRuntime.jsx(qe,{variant:"ghost",size:"icon-sm",className:ne("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:w,disabled:n||y>=l,"aria-label":s("fontSize.increase"),"data-testid":"font-size-increase",children:jsxRuntime.jsx($,{name:"add",size:18})})]})}var lR=[{name:"Dark Red",nameKey:"colorPicker.colors.darkRed",hex:"C00000"},{name:"Red",nameKey:"colorPicker.colors.red",hex:"FF0000"},{name:"Orange",nameKey:"colorPicker.colors.orange",hex:"FFC000"},{name:"Yellow",nameKey:"colorPicker.colors.yellow",hex:"FFFF00"},{name:"Light Green",nameKey:"colorPicker.colors.lightGreen",hex:"92D050"},{name:"Green",nameKey:"colorPicker.colors.green",hex:"00B050"},{name:"Light Blue",nameKey:"colorPicker.colors.lightBlue",hex:"00B0F0"},{name:"Blue",nameKey:"colorPicker.colors.blue",hex:"0070C0"},{name:"Dark Blue",nameKey:"colorPicker.colors.darkBlue",hex:"002060"},{name:"Purple",nameKey:"colorPicker.colors.purple",hex:"7030A0"}],_l=18,sR=2,cR={position:"relative",display:"inline-block"},dR={display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"32px",padding:"2px 6px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},uR={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},su={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},cu={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},nb={display:"grid",gap:`${sR}px`},Nl={width:`${_l}px`,height:`${_l}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},rb={...Nl,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},ab={...Nl,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},pR={display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"5px 8px",border:"1px solid var(--doc-border-dark)",borderRadius:"4px",backgroundColor:"var(--doc-surface)",cursor:"pointer",fontSize:"12px",color:"var(--doc-text)"},mR={display:"flex",alignItems:"center",gap:"6px"},fR={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},gR={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},tb={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},bR={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},hR={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:0,width:"28px",padding:"2px 4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},vR={display:"flex",alignItems:"center",justifyContent:"center",width:"18px",padding:0,border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"};function du(e,t,o){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let n=$0(e);return n||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return nu(e,o)}function ob(e){let t=e.replace(/^#/,"");if(t.length!==6)return false;let o=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return (o*299+n*587+r*114)/1e3>230}function ib(e,t,o){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():Jt(e,o))===t.toUpperCase():false}function yR({matrix:e,selectedColor:t,theme:o,onSelect:n}){let[r,i]=lt.useState(null);return jsxRuntime.jsx("div",{style:{...nb,gridTemplateColumns:`repeat(10, ${_l}px)`},children:e.flatMap((a,l)=>a.map((s,c)=>{let d=`${l}-${c}`,f=r===d,u=ib(t,s.hex,o);return jsxRuntime.jsx("button",{type:"button",style:{...u?ab:f?rb:Nl,backgroundColor:`#${s.hex}`},title:s.label,"aria-label":s.label,"aria-selected":u,onClick:()=>n(s),onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>i(d),onMouseLeave:()=>i(null)},d)}))})}function xR({selectedColor:e,theme:t,onSelect:o}){let[n,r]=lt.useState(null),{t:i}=L();return jsxRuntime.jsx("div",{style:{...nb,gridTemplateColumns:`repeat(10, ${_l}px)`},children:lR.map((a,l)=>{let s=n===l,c=ib(e,a.hex,t),d=i(a.nameKey);return jsxRuntime.jsx("button",{type:"button",style:{...c?ab:s?rb:Nl,backgroundColor:`#${a.hex}`},title:d,"aria-label":d,"aria-selected":c,onClick:()=>o(a.hex),onMouseDown:f=>f.preventDefault(),onMouseEnter:()=>r(l),onMouseLeave:()=>r(null)},a.hex)})})}function dn({mode:e,value:t,onChange:o,theme:n,disabled:r=false,className:i,style:a,title:l,icon:s,autoLabel:c,splitButton:d=true,defaultColor:f}){let[u,g]=lt.useState(false),[p,m]=lt.useState(false),[b,h]=lt.useState(false),[x,v]=lt.useState(false),[y,C]=lt.useState(""),[T,w]=lt.useState(()=>f??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:S}=L();lt.useEffect(()=>{let U=du(t,e,n).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(U)&&C(U.toUpperCase());},[t,e,n]);let M=lt.useCallback(()=>g(false),[]),{containerRef:R,dropdownRef:D,dropdownStyle:_}=rt({isOpen:u,onClose:M}),H=n?.colorScheme??null,N=lt.useMemo(()=>W0(H),[H]),I=lt.useMemo(()=>du(t,e,n),[t,e,n]),P=lt.useMemo(()=>du(T,e,n),[T,e,n]),k=lt.useCallback(()=>{r||g(U=>!U);},[r]),Y=lt.useCallback(U=>{let q;e==="highlight"?q=U.hex:q={kind:"theme",slot:U.themeSlot,...U.tint!==void 0?{tint:U.tint}:{},...U.shade!==void 0?{shade:U.shade}:{}},w(q),o?.(q),g(false);},[e,o]),z=lt.useCallback(U=>{let q=e==="highlight"?U:{kind:"hex",value:U};w(q),o?.(q),g(false);},[e,o]),re=lt.useCallback(()=>{o?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,o]),V=lt.useCallback(()=>{let U=y.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(U)){let q=e==="highlight"?U:{kind:"hex",value:U};w(q),o?.(q),g(false),C("");}},[e,y,o]),te=lt.useCallback(()=>{r||o?.(T);},[r,T,o]),B={...dR,...r?{cursor:"default",opacity:.38}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:p?{backgroundColor:"var(--doc-bg-hover)"}:{}},J=S(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),de=s??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxRuntime.jsxs("div",{ref:R,className:`docx-color-picker ${i||""}`,style:{...cR,...a},children:[d?jsxRuntime.jsxs("div",{className:"docx-color-picker-split",style:{...bR,...r?{opacity:.38,cursor:"default"}:null},children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...hR,...r?{cursor:"default"}:b?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:te,onMouseDown:U=>U.preventDefault(),onMouseEnter:()=>h(true),onMouseLeave:()=>h(false),disabled:r,title:l||J,"aria-label":l||J,children:[jsxRuntime.jsx($,{name:de,size:18}),jsxRuntime.jsx("div",{style:{...tb,backgroundColor:P==="transparent"?"#fff":P,outline:P==="transparent"||ob(P)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...vR,...r?{cursor:"default"}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:x?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:k,onMouseDown:U=>U.preventDefault(),onMouseEnter:()=>v(true),onMouseLeave:()=>v(false),disabled:r,title:l||J,"aria-label":l||J,"aria-haspopup":"true","aria-expanded":u,children:jsxRuntime.jsx($,{name:"arrow_drop_down",size:18})})]}):jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-button",style:B,onClick:k,onMouseDown:U=>U.preventDefault(),onMouseEnter:()=>m(true),onMouseLeave:()=>m(false),disabled:r,title:l||J,"aria-label":l||J,"aria-haspopup":"true","aria-expanded":u,children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsxRuntime.jsx($,{name:de,size:18}),jsxRuntime.jsx("div",{style:{...tb,backgroundColor:I==="transparent"?"#fff":I,outline:I==="transparent"||ob(I)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx($,{name:"arrow_drop_down",size:14})]}),u&&jsxRuntime.jsx("div",{ref:D,className:"docx-color-picker-dropdown",style:{..._,...uR},role:"dialog","aria-label":`${J} picker`,onMouseDown:U=>{U.target.tagName!=="INPUT"&&U.preventDefault();},children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",style:pR,onClick:re,onMouseDown:U=>U.preventDefault(),children:[e==="highlight"?jsxRuntime.jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",border:"1px solid #ccc",borderRadius:"2px",position:"relative",backgroundColor:"#fff"},children:jsxRuntime.jsx("span",{style:{position:"absolute",top:"50%",left:"-1px",right:"-1px",height:"2px",backgroundColor:"#ff0000",transform:"rotate(-45deg)"}})}):jsxRuntime.jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",backgroundColor:"#000",borderRadius:"2px"}}),c??S(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsxRuntime.jsx("div",{style:cu}),jsxRuntime.jsx("div",{style:su,children:S("colorPicker.themeColors")}),jsxRuntime.jsx(yR,{matrix:N,selectedColor:t,theme:n,onSelect:Y}),jsxRuntime.jsx("div",{style:cu}),jsxRuntime.jsx("div",{style:su,children:S("colorPicker.standardColors")}),jsxRuntime.jsx(xR,{selectedColor:t,theme:n,onSelect:z}),jsxRuntime.jsx("div",{style:cu}),jsxRuntime.jsx("div",{style:su,children:S("colorPicker.customColor")}),jsxRuntime.jsxs("div",{style:mR,children:[jsxRuntime.jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsxRuntime.jsx("input",{type:"text",style:fR,value:y,onChange:U=>C(U.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:U=>{U.key==="Enter"&&V();},onMouseDown:U=>{U.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsxRuntime.jsx("button",{type:"button",style:{...gR,opacity:/^[0-9A-Fa-f]{6}$/.test(y)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(y)?"pointer":"default"},onClick:V,onMouseDown:U=>U.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(y),children:S("common.apply")})]})]})})]})}var La=20,uu=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsxRuntime.jsx($,{name:"format_align_left",size:La}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsxRuntime.jsx($,{name:"format_align_center",size:La}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsxRuntime.jsx($,{name:"format_align_right",size:La}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsxRuntime.jsx($,{name:"format_align_justify",size:La}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function cb({value:e="left",onChange:t,disabled:o=false}){let{t:n}=L(),[r,i]=lt.useState(false),a=lt.useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:s,dropdownStyle:c,handleMouseDown:d}=rt({isOpen:r,onClose:a}),f=lt.useCallback(h=>{o||t?.(h),i(false);},[o,t]),u=uu.find(h=>h.value===e)||uu[0],g=n(u.labelKey),p=u.shortcutKey?n(u.shortcutKey):void 0,m=`${g}${p?` (${p})`:""}`,b=jsxRuntime.jsxs(qe,{variant:"ghost",size:"icon-sm",className:ne("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",o&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!o&&i(h=>!h),disabled:o,"aria-label":m,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsxRuntime.jsx($,{name:u.iconName,size:La}),jsxRuntime.jsx($,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[r?b:jsxRuntime.jsx(pt,{content:m,children:b}),r&&!o&&jsxRuntime.jsx("div",{ref:s,style:{...c,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:h=>h.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",gap:2},children:uu.map(h=>{let x=e===h.value,v=n(h.labelKey),y=h.shortcutKey?n(h.shortcutKey):void 0;return jsxRuntime.jsx("button",{type:"button",title:`${v}${y?` (${y})`:""}`,"data-testid":`alignment-${h.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:x?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:x?"var(--doc-primary)":"var(--doc-text)"},onMouseDown:C=>C.preventDefault(),onMouseEnter:C=>{x||(C.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:C=>{C.currentTarget.style.backgroundColor=x?"var(--doc-primary-light)":"transparent";},onClick:()=>f(h.value),children:jsxRuntime.jsx($,{name:h.iconName,size:18})},h.value)})})})]})}function Ll(){return {type:"none",level:0,isInList:false}}var ER={display:"inline-flex",alignItems:"center",gap:"4px"},db={display:"inline-flex",alignItems:"center",gap:"4px"},Ol={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",padding:"4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},wR={...Ol,backgroundColor:"var(--doc-bg-hover)"},RR={...Ol,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},MR={...Ol,cursor:"default",opacity:.38},kR={width:"28px",height:"28px",padding:"2px"},DR={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Fl=20;function Al({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,style:a}){let[l,s]=lt.useState(false),c={...t?MR:e?RR:l?wR:Ol,...a},d=f=>{f.preventDefault();};return jsxRuntime.jsx("button",{type:"button",className:`docx-list-button ${e?"docx-list-button-active":""} ${t?"docx-list-button-disabled":""} ${i||""}`,style:c,onMouseDown:d,onClick:t?void 0:n,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-disabled":t||void 0,tabIndex:t?-1:void 0,title:o,"aria-label":o,"aria-pressed":e,role:"button",children:r})}function ub({listState:e,onBulletList:t,onNumberedList:o,onIndent:n,onOutdent:r,disabled:i=false,className:a,style:l,showIndentButtons:s=true,compact:c=false,hasIndent:d=false}){let{t:f}=L(),u=lt.useCallback(()=>c?{...kR}:{},[c]),g=e?.type==="bullet",p=e?.type==="numbered",b=(e?.isInList||g||p)&&(e?.level??0)>0||d;return jsxRuntime.jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...ER,...l},role:"group","aria-label":f("lists.ariaLabel"),children:[jsxRuntime.jsxs("div",{style:db,role:"group","aria-label":f("lists.typeAriaLabel"),children:[jsxRuntime.jsx(Al,{active:g,disabled:i,title:f("lists.bulletList"),onClick:t,style:u(),children:jsxRuntime.jsx($,{name:"format_list_bulleted",size:Fl})}),jsxRuntime.jsx(Al,{active:p,disabled:i,title:f("lists.numberedList"),onClick:o,style:u(),children:jsxRuntime.jsx($,{name:"format_list_numbered",size:Fl})})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:DR,role:"separator"}),jsxRuntime.jsxs("div",{style:db,role:"group","aria-label":f("lists.indentationAriaLabel"),children:[jsxRuntime.jsx(Al,{active:false,disabled:i||!b,title:f("lists.decreaseIndent"),onClick:r,style:u(),children:jsxRuntime.jsx($,{name:"format_indent_decrease",size:Fl})}),jsxRuntime.jsx(Al,{active:false,disabled:i,title:f("lists.increaseIndent"),onClick:n,style:u(),children:jsxRuntime.jsx($,{name:"format_indent_increase",size:Fl})})]})]})]})}var _R=[{label:"Single",labelKey:"lineSpacing.single",value:1,twipsValue:240},{label:"1.15",value:1.15,twipsValue:276},{label:"1.5",value:1.5,twipsValue:360},{label:"Double",labelKey:"lineSpacing.double",value:2,twipsValue:480}];function mb({value:e,onChange:t,options:o=_R,disabled:n=false,className:r}){let{t:i}=L(),a=lt__namespace.useMemo(()=>e===void 0?o[0]:o.find(c=>c.twipsValue===e)||o[0],[e,o]),l=lt__namespace.useCallback(c=>{let d=parseInt(c,10);isNaN(d)||t?.(d);},[t]),s=c=>c.labelKey?i(c.labelKey):c.label;return jsxRuntime.jsxs(xo,{value:a.twipsValue.toString(),onValueChange:l,disabled:n,children:[jsxRuntime.jsx(Co,{className:ne("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},"aria-label":i("lineSpacing.label"),title:i("lineSpacing.lineSpacingTitle",{label:s(a)}),children:jsxRuntime.jsx(Fd,{className:"h-5 w-5 shrink-0"})}),jsxRuntime.jsxs(So,{children:[o.map(c=>jsxRuntime.jsx(mt,{value:c.twipsValue.toString(),children:s(c)},c.twipsValue)),jsxRuntime.jsx(ln,{}),jsxRuntime.jsx(To,{children:jsxRuntime.jsx(an,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var fb=[{styleId:"Normal",name:"Normal text",nameKey:"styles.normalText",type:"paragraph",isDefault:true,priority:0,qFormat:true,fontSize:22},{styleId:"Title",name:"Title",nameKey:"styles.title",type:"paragraph",priority:1,qFormat:true,fontSize:52,bold:true},{styleId:"Subtitle",name:"Subtitle",nameKey:"styles.subtitle",type:"paragraph",priority:2,qFormat:true,fontSize:30,color:"666666"},{styleId:"Heading1",name:"Heading 1",nameKey:"styles.heading1",type:"paragraph",priority:3,qFormat:true,fontSize:40,bold:true},{styleId:"Heading2",name:"Heading 2",nameKey:"styles.heading2",type:"paragraph",priority:4,qFormat:true,fontSize:32,bold:true},{styleId:"Heading3",name:"Heading 3",nameKey:"styles.heading3",type:"paragraph",priority:5,qFormat:true,fontSize:28,bold:true}];function gb({value:e,onChange:t,styles:o,disabled:n=false,className:r,width:i=120}){let{t:a}=L(),l=lt__namespace.useMemo(()=>{let g=Wf(o);return g.length===0?fb:g.map(p=>({...p,type:"paragraph",nameKey:fb.find(m=>m.styleId===p.styleId)?.nameKey}))},[o]),s=lt__namespace.useCallback(g=>{t?.(g);},[t]),c=g=>g.nameKey?a(g.nameKey):g.name,d=e||"Normal",f=l.find(g=>g.styleId===d),u=f?c(f):d;return jsxRuntime.jsxs(xo,{value:d,onValueChange:s,disabled:n,children:[jsxRuntime.jsx(Co,{className:ne("h-8 text-sm",r),style:{width:typeof i=="number"?`${i}px`:i},"aria-label":a("styles.selectAriaLabel"),children:jsxRuntime.jsx("span",{className:"truncate",children:u})}),jsxRuntime.jsx(So,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsxRuntime.jsx(mt,{value:g.styleId,className:"py-2.5 px-3",children:jsxRuntime.jsx("span",{style:$f(g),children:c(g)})},g.styleId))})]})}var LR=[{value:.5,label:"50%"},{value:.75,label:"75%"},{value:1,label:"100%"},{value:1.25,label:"125%"},{value:1.5,label:"150%"},{value:2,label:"200%"}];function hb({value:e=1,onChange:t,levels:o=LR,disabled:n=false,className:r,compact:i=false}){let{t:a}=L(),l=lt__namespace.useMemo(()=>{let g=o.find(p=>Math.abs(p.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[o,e]),s=lt__namespace.useCallback(g=>{let p=parseFloat(g);isNaN(p)||t?.(p);},[t]),c=lt__namespace.useMemo(()=>[...o].sort((g,p)=>g.value-p.value),[o]),d=lt__namespace.useMemo(()=>[...c].reverse().find(g=>g.value<e-.001),[c,e]),f=lt__namespace.useMemo(()=>c.find(g=>g.value>e+.001),[c,e]),u=i?"h-7 w-7":"h-8 w-8";return jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(qe,{variant:"ghost",size:"icon-sm",className:ne(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",(n||!d)&&"opacity-30 cursor-not-allowed"),onClick:()=>d&&t?.(d.value),disabled:n||!d,"aria-label":a("zoom.zoomOut"),children:jsxRuntime.jsx($,{name:"remove",size:18})}),jsxRuntime.jsxs(xo,{value:e.toString(),onValueChange:s,disabled:n,children:[jsxRuntime.jsx(Co,{className:ne(i?"h-7 min-w-[55px] text-xs":"h-8 min-w-[64px] text-sm","rounded-none",r),"aria-label":a("zoom.ariaLabel",{label:l}),children:jsxRuntime.jsx(Dl,{placeholder:"100%",children:l})}),jsxRuntime.jsx(So,{children:o.map(g=>jsxRuntime.jsx(mt,{value:g.value.toString(),children:g.label},g.value))})]}),jsxRuntime.jsx(qe,{variant:"ghost",size:"icon-sm",className:ne(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(n||!f)&&"opacity-30 cursor-not-allowed"),onClick:()=>f&&t?.(f.value),disabled:n||!f,"aria-label":a("zoom.zoomIn"),children:jsxRuntime.jsx($,{name:"add",size:18})})]})}var AR=[{action:"borderAll",icon:"border_all",labelKey:"table.borders.all"},{action:"borderOutside",icon:"border_outer",labelKey:"table.borders.outside"},{action:"borderInside",icon:"border_inner",labelKey:"table.borders.inside"},{action:"borderTop",icon:"border_top",labelKey:"table.borders.top"},{action:"borderBottom",icon:"border_bottom",labelKey:"table.borders.bottom"},{action:"borderLeft",icon:"border_left",labelKey:"table.borders.left"},{action:"borderRight",icon:"border_right",labelKey:"table.borders.right"},{action:"borderNone",icon:"border_clear",labelKey:"table.borders.none"}];function xb({onAction:e,disabled:t=false}){let{t:o}=L(),[n,r]=lt.useState(false),i=lt.useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=rt({isOpen:n,onClose:i}),d=lt.useCallback(u=>{e(u),r(false);},[e]),f=jsxRuntime.jsxs(qe,{variant:"ghost",size:"icon-sm",className:ne("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&r(u=>!u),disabled:t,"aria-label":o("table.borders.styleAriaLabel"),"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsxRuntime.jsx($,{name:"border_all",size:20}),jsxRuntime.jsx($,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[n?f:jsxRuntime.jsx(pt,{content:o("table.borders.tooltip"),children:f}),n&&!t&&jsxRuntime.jsx("div",{ref:l,style:{...s,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:u=>u.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:AR.map(({action:u,icon:g,labelKey:p})=>jsxRuntime.jsx("button",{type:"button",title:o(p),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:"transparent",cursor:"pointer",color:"var(--doc-text)"},onMouseDown:m=>m.preventDefault(),onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(u),children:jsxRuntime.jsx($,{name:g,size:18})},typeof u=="string"?u:u.type))})})]})}function Tb({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=L(),i=lt.useCallback(a=>{if(typeof a=="string"){e({type:"borderColor",color:a.replace(/^#/,"")});return}let l=a.kind==="auto"?"000000":Jt(a,o);l&&e({type:"borderColor",color:l});},[e,o]);return jsxRuntime.jsx(dn,{mode:"border",value:n,onChange:i,theme:o,disabled:t,title:r("table.borderColor")})}var ZR=[{size:4,label:"0.5 pt",thickness:.5},{size:8,label:"1 pt",thickness:1},{size:12,label:"1.5 pt",thickness:1.5},{size:16,label:"2 pt",thickness:2},{size:24,label:"3 pt",thickness:3}];function Sb({onAction:e,disabled:t=false}){let[o,n]=lt.useState(false),{t:r}=L(),i=lt.useCallback(()=>n(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=rt({isOpen:o,onClose:i}),d=lt.useCallback(u=>{e({type:"borderWidth",size:u}),n(false);},[e]),f=jsxRuntime.jsxs(qe,{variant:"ghost",size:"icon-sm",className:ne("text-muted-foreground hover:text-foreground hover:bg-muted/80",o&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&n(u=>!u),disabled:t,"aria-label":r("table.borderWidth"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsxRuntime.jsx($,{name:"line_weight",size:20}),jsxRuntime.jsx($,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[o?f:jsxRuntime.jsx(pt,{content:r("table.borderWidth"),children:f}),o&&!t&&jsxRuntime.jsx("div",{ref:l,style:{...s,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:"4px 0",minWidth:120},onMouseDown:u=>u.stopPropagation(),children:ZR.map(({size:u,label:g,thickness:p})=>jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",width:"100%",border:"none",backgroundColor:"transparent",cursor:"pointer",fontSize:12,color:"var(--doc-text)"},onMouseDown:m=>m.preventDefault(),onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(u),children:[jsxRuntime.jsx("div",{style:{width:50,height:Math.max(p,1),backgroundColor:"#000",borderRadius:p>2?1:0}}),jsxRuntime.jsx("span",{children:g})]},u))})]})}function Eb({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=L(),i=lt.useCallback(a=>{typeof a=="string"&&e(a==="none"?{type:"cellFillColor",color:null}:{type:"cellFillColor",color:a.replace(/^#/,"")});},[e]);return jsxRuntime.jsx("div",{"data-testid":"toolbar-table-cell-fill",style:{display:"inline-block"},children:jsxRuntime.jsx(dn,{mode:"highlight",value:n,onChange:i,theme:o,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var KR={display:"flex",alignItems:"center",gap:10,padding:"7px 14px",fontSize:13,color:"var(--doc-text)",cursor:"pointer",border:"none",backgroundColor:"transparent",width:"100%",textAlign:"left"},mn={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},Mb={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function kb({onAction:e,disabled:t=false,tableContext:o}){let{t:n}=L(),[r,i]=lt.useState(false),[a,l]=lt.useState(null),s=lt.useCallback(()=>i(false),[]),{containerRef:c,dropdownRef:d,dropdownStyle:f,handleMouseDown:u}=rt({isOpen:r,onClose:s,align:"right"}),g=o?.table?.attrs?.justification??"left",p=lt.useCallback(h=>{e(h),i(false);},[e]),m=(h,x,v,y,C)=>{let T=t||C?.itemDisabled;return jsxRuntime.jsxs("button",{type:"button",role:"menuitem",style:{...KR,backgroundColor:a===h&&!T?"var(--doc-bg-hover)":"transparent",color:T?"var(--doc-text-muted)":C?.danger?"var(--doc-error)":"var(--doc-text)",cursor:T?"not-allowed":"pointer"},onClick:()=>!T&&p(y),onMouseEnter:()=>l(h),onMouseLeave:()=>l(null),disabled:T,children:[jsxRuntime.jsx($,{name:x,size:16,className:C?.danger&&!T?"text-destructive":""}),jsxRuntime.jsx("span",{style:{flex:1},children:v})]},h)},b=jsxRuntime.jsx(qe,{variant:"ghost",size:"icon-sm",className:ne("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!t&&i(h=>!h),disabled:t,"aria-label":n("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsxRuntime.jsx($,{name:"more_vert",size:20})});return jsxRuntime.jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[r?b:jsxRuntime.jsx(pt,{content:n("table.moreOptions"),children:b}),r&&!t&&jsxRuntime.jsxs("div",{ref:d,style:{...f,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:"4px 0",minWidth:200,maxHeight:"70vh",overflowY:"auto"},role:"menu",onMouseDown:h=>h.stopPropagation(),children:[m("addRowAbove","add",n("table.insertRowAbove"),"addRowAbove"),m("addRowBelow","add",n("table.insertRowBelow"),"addRowBelow"),m("addColumnLeft","add",n("table.insertColumnLeft"),"addColumnLeft"),m("addColumnRight","add",n("table.insertColumnRight"),"addColumnRight"),jsxRuntime.jsx("div",{style:mn,role:"separator"}),m("mergeCells","call_merge",n("table.mergeCells"),"mergeCells",{itemDisabled:!o?.hasMultiCellSelection}),m("splitCell","call_split",n("table.splitCell"),"splitCell",{itemDisabled:!o?.canSplitCell}),jsxRuntime.jsx("div",{style:mn,role:"separator"}),m("selectTable","select_all",n("table.selectTable"),"selectTable"),jsxRuntime.jsx("div",{style:mn,role:"separator"}),m("deleteRow","delete",n("table.deleteRow"),"deleteRow",{danger:true,itemDisabled:(o?.rowCount??0)<=1}),m("deleteColumn","delete",n("table.deleteColumn"),"deleteColumn",{danger:true,itemDisabled:(o?.columnCount??0)<=1}),m("deleteTable","delete",n("table.deleteTable"),"deleteTable",{danger:true}),jsxRuntime.jsx("div",{style:mn,role:"separator"}),jsxRuntime.jsx("div",{style:Mb,children:n("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(h=>{let x={top:"vertical_align_top",center:"vertical_align_center",bottom:"vertical_align_bottom"};return jsxRuntime.jsx("button",{type:"button",title:n({top:"tableAdvanced.top",center:"tableAdvanced.middle",bottom:"tableAdvanced.bottom"}[h]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:y=>y.preventDefault(),onMouseEnter:y=>{y.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:y=>{y.currentTarget.style.backgroundColor="transparent";},onClick:()=>p({type:"cellVerticalAlign",align:h}),children:jsxRuntime.jsx($,{name:x[h],size:16})},h)})}),jsxRuntime.jsx("div",{style:mn,role:"separator"}),jsxRuntime.jsx("div",{style:Mb,children:n("tableAdvanced.tableAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(h=>{let x={left:"format_align_left",center:"format_align_center",right:"format_align_right"},v=g===h;return jsxRuntime.jsx("button",{type:"button",title:n({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[h]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:v?"var(--doc-primary-light)":"transparent",borderColor:v?"var(--doc-primary)":"var(--doc-border)",color:v?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:y=>y.preventDefault(),onClick:()=>p({type:"tableProperties",props:{justification:h}}),children:jsxRuntime.jsx($,{name:x[h],size:16})},h)})}),jsxRuntime.jsx("div",{style:mn,role:"separator"}),m("headerRow","table_rows",n("tableAdvanced.toggleHeaderRow"),{type:"toggleHeaderRow"}),m("distribute","view_column",n("tableAdvanced.distributeColumns"),{type:"distributeColumns"}),m("autoFit","fit_width",n("tableAdvanced.autoFit"),{type:"autoFitContents"}),m("noWrap","wrap_text",n("tableAdvanced.toggleNoWrap"),{type:"toggleNoWrap"}),jsxRuntime.jsx("div",{style:mn,role:"separator"}),m("properties","settings",n("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var VR=20;function ql({options:e,activeValue:t,triggerIcon:o,tooltipContent:n,onSelect:r,disabled:i=false,ariaLabel:a,testId:l,showLabels:s=false}){let[c,d]=lt.useState(false),f=lt.useCallback(()=>d(false),[]),{containerRef:u,dropdownRef:g,dropdownStyle:p,handleMouseDown:m}=rt({isOpen:c,onClose:f}),b=lt.useCallback(x=>{i||r(x),d(false);},[i,r]),h=jsxRuntime.jsxs(qe,{variant:"ghost",size:"icon-sm",className:ne("text-muted-foreground hover:text-foreground hover:bg-muted/80",c&&"bg-muted",i&&"opacity-30 cursor-not-allowed"),onMouseDown:m,onClick:()=>!i&&d(x=>!x),disabled:i,"aria-label":a??n,"aria-expanded":c,"aria-haspopup":"true","data-testid":l,children:[jsxRuntime.jsx($,{name:o,size:VR}),jsxRuntime.jsx($,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:u,style:{position:"relative",display:"inline-block"},children:[c?h:jsxRuntime.jsx(pt,{content:n,children:h}),c&&!i&&jsxRuntime.jsx("div",{ref:g,style:{...p,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:x=>x.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:s?"column":"row",gap:s?1:2,minWidth:s?200:void 0},children:e.map(x=>{let v=t===x.value;return jsxRuntime.jsxs("button",{type:"button",title:x.label,"data-testid":l?`${l}-${x.value}`:void 0,style:{display:"flex",alignItems:"center",height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:v?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:v?"var(--doc-primary)":"var(--doc-text)",...s?{width:"100%",gap:10,padding:"0 10px",justifyContent:"flex-start",fontSize:13,textAlign:"left"}:{width:32,justifyContent:"center"}},onMouseDown:y=>y.preventDefault(),onMouseEnter:y=>{v||(y.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:y=>{y.currentTarget.style.backgroundColor=v?"var(--doc-primary-light)":"transparent";},onClick:()=>b(x.value),children:[jsxRuntime.jsx($,{name:x.iconName,size:18}),s&&jsxRuntime.jsx("span",{style:{flex:1},children:x.label})]},x.value)})})})]})}var $R=[{value:"inline",labelKey:"imageWrap.inline",iconName:"wrap_text"},{value:"wrapRight",labelKey:"imageWrap.floatLeft",iconName:"format_image_left"},{value:"wrapLeft",labelKey:"imageWrap.floatRight",iconName:"format_image_right"},{value:"behind",labelKey:"imageWrap.behindText",iconName:"flip_to_back"},{value:"inFront",labelKey:"imageWrap.inFrontOfText",iconName:"flip_to_front"}];function WR(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function Ib({imageContext:e,onChange:t,disabled:o=false}){let{t:n}=L(),r=$R.map(l=>({...l,label:n(l.labelKey)})),i=WR(e),a=r.find(l=>l.value===i)||r[0];return jsxRuntime.jsx(ql,{options:r,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:o,testId:"toolbar-image-wrap",showLabels:true})}var GR=[{value:"rotateCW",labelKey:"imageTransform.rotateClockwise",iconName:"rotate_right"},{value:"rotateCCW",labelKey:"imageTransform.rotateCounterClockwise",iconName:"rotate_left"},{value:"flipH",labelKey:"imageTransform.flipHorizontal",iconName:"swap_horiz"},{value:"flipV",labelKey:"imageTransform.flipVertical",iconName:"swap_vert"}];function _b({onTransform:e,disabled:t=false}){let{t:o}=L(),n=GR.map(r=>({...r,label:o(r.labelKey)}));return jsxRuntime.jsx(ql,{options:n,triggerIcon:"rotate_right",tooltipContent:o("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var St=18;function ft({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,ariaLabel:a}){let l=a?.toLowerCase().replace(/\s+/g,"-")||o?.toLowerCase().replace(/\s+/g,"-").replace(/\([^()]*\)/g,"").trim(),s=d=>{d.preventDefault();},c=jsxRuntime.jsx(qe,{variant:"ghost",size:"icon-sm",className:ne("docx-editor-toolbar-toggle text-muted-foreground",t&&"opacity-30 cursor-not-allowed",i),"data-active":e?"true":void 0,onMouseDown:s,onClick:t?void 0:n,"aria-disabled":t||void 0,tabIndex:t?-1:void 0,"aria-pressed":!!e,"aria-label":a||o,"data-testid":l?`toolbar-${l}`:void 0,children:r});return o?jsxRuntime.jsx(pt,{content:o,children:c}):c}function Pt({label:e,children:t,className:o}){return jsxRuntime.jsx("div",{className:ne("flex items-center gap-px px-1.5 border-r border-border/50 last:border-r-0 first:pl-0",o),role:"group","aria-label":e,children:t})}function JR(e){let t=lt__namespace.default.useContext(Ia);return t?{...t,...eM(e)}:e}function eM(e){let t={};for(let o of Object.keys(e))e[o]!==void 0&&(t[o]=e[o]);return t}function gu(e){let{t}=L(),o=JR(e),{currentFormatting:n={},onFormat:r,onUndo:i,onRedo:a,canUndo:l=false,canRedo:s=false,disabled:c=false,className:d,style:f,enableShortcuts:u=true,editorRef:g,children:p,showFontPicker:m=true,fontFamilies:b,documentFonts:h,showFontSizePicker:x=true,showTextColorPicker:v=true,showHighlightColorPicker:y=true,showAlignmentButtons:C=true,showListButtons:T=true,showLineSpacingPicker:w=true,showStylePicker:S=true,documentStyles:M,theme:R,showZoomControl:D=true,zoom:_,onZoomChange:H,onRefocusEditor:N,imageContext:I,onImageWrapType:P,onImageTransform:k,onOpenImageProperties:Y,tableContext:z,onTableAction:re,inline:V=false}=o,te=lt.useRef(null),B=lt.useCallback(me=>{!c&&r&&r(me);},[c,r]),J=lt.useCallback(()=>{!c&&l&&i&&i();},[c,l,i]),de=lt.useCallback(()=>{!c&&s&&a&&a();},[c,s,a]),U=lt.useCallback(me=>{!c&&r&&r({type:"fontFamily",value:me});},[c,r]),q=lt__namespace.default.useMemo(()=>au(b),[b]),Me=lt.useCallback(me=>{!c&&r&&r({type:"fontSize",value:me});},[c,r]),We=lt.useCallback(me=>{!c&&r&&r({type:"textColor",value:me});},[c,r]),pe=lt.useCallback(me=>{!c&&r&&r({type:"highlightColor",value:typeof me=="string"?me:""});},[c,r]),Ke=lt.useCallback(me=>{!c&&r&&r({type:"alignment",value:me});},[c,r]),Bt=lt.useCallback(()=>{!c&&r&&r("bulletList");},[c,r]),he=lt.useCallback(()=>{!c&&r&&r("numberedList");},[c,r]),wt=lt.useCallback(()=>{!c&&r&&r("indent");},[c,r]),Ul=lt.useCallback(()=>{!c&&r&&r("outdent");},[c,r]),Gl=lt.useCallback(me=>{!c&&r&&(r({type:"lineSpacing",value:me}),requestAnimationFrame(()=>N?.()));},[c,r,N]),gn=lt.useCallback(me=>{!c&&r&&r({type:"applyStyle",value:me});},[c,r]),oo=lt.useCallback(me=>{!c&&re&&(re(me),requestAnimationFrame(()=>N?.()));},[c,re,N]);lt.useEffect(()=>{if(!u)return;let me=ge=>{if(ge.defaultPrevented)return;let Zt=ge.target,qt=g?.current,rr=te.current,Oa=qt?.contains(Zt),gt=rr?.contains(Zt);if(!Oa&&!gt)return;if((ge.ctrlKey||ge.metaKey)&&!ge.altKey)switch(ge.key.toLowerCase()){case "b":ge.preventDefault(),B("bold");break;case "i":ge.preventDefault(),B("italic");break;case "u":ge.preventDefault(),B("underline");break;case "=":ge.shiftKey?(ge.preventDefault(),B("superscript")):(ge.preventDefault(),B("subscript"));break;case "l":ge.preventDefault(),Ke("left");break;case "e":ge.preventDefault(),Ke("center");break;case "r":ge.preventDefault(),Ke("right");break;case "j":ge.preventDefault(),Ke("both");break;case "k":ge.preventDefault(),B("insertLink");break}};return document.addEventListener("keydown",me),()=>{document.removeEventListener("keydown",me);}},[u,B,Ke,g]);let _e=lt.useCallback(me=>{let ge=me.target;ge.tagName==="INPUT"||ge.tagName==="TEXTAREA"||ge.tagName==="SELECT"||ge.tagName==="OPTION"||me.preventDefault();},[]),Ha=lt.useCallback(me=>{let ge=me.target,Zt=document.activeElement;ge.tagName==="SELECT"||ge.tagName==="OPTION"||Zt?.tagName==="SELECT"||requestAnimationFrame(()=>{N?.();});},[N]);return jsxRuntime.jsxs("div",{ref:te,className:ne(!V&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:V?{display:"contents",...f}:f,role:V?void 0:"toolbar","aria-label":V?void 0:t("toolbar.ariaLabel"),"data-testid":V?void 0:"formatting-bar",onMouseDown:V?void 0:_e,onMouseUp:V?void 0:Ha,children:[jsxRuntime.jsxs(Pt,{label:t("formattingBar.groups.history"),children:[jsxRuntime.jsx(ft,{onClick:J,disabled:c||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsxRuntime.jsx($,{name:"undo",size:St})}),jsxRuntime.jsx(ft,{onClick:de,disabled:c||!s,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsxRuntime.jsx($,{name:"redo",size:St})})]}),D&&jsxRuntime.jsx(Pt,{label:t("formattingBar.groups.zoom"),children:jsxRuntime.jsx(hb,{value:_,onChange:H,disabled:c,compact:true})}),S&&jsxRuntime.jsx(Pt,{label:t("formattingBar.groups.styles"),children:jsxRuntime.jsx(gb,{value:n.styleId||"Normal",onChange:gn,styles:M,theme:R,disabled:c,width:120})}),(m||x)&&jsxRuntime.jsxs(Pt,{label:t("formattingBar.groups.font"),children:[m&&jsxRuntime.jsx(j0,{value:n.fontFamily||"Arial",onChange:U,fonts:q,documentFonts:h,disabled:c,width:60,placeholder:"Arial"}),x&&jsxRuntime.jsx(eb,{value:n.fontSize!==void 0?xc(n.fontSize):11,onChange:Me,disabled:c,width:42,placeholder:"11"})]}),jsxRuntime.jsxs(Pt,{label:t("formattingBar.groups.textFormatting"),children:[jsxRuntime.jsx(ft,{onClick:()=>B("bold"),active:n.bold,disabled:c,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsxRuntime.jsx($,{name:"format_bold",size:St})}),jsxRuntime.jsx(ft,{onClick:()=>B("italic"),active:n.italic,disabled:c,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsxRuntime.jsx($,{name:"format_italic",size:St})}),jsxRuntime.jsx(ft,{onClick:()=>B("underline"),active:n.underline,disabled:c,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsxRuntime.jsx($,{name:"format_underlined",size:St})}),jsxRuntime.jsx(ft,{onClick:()=>B("strikethrough"),active:n.strike,disabled:c,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsxRuntime.jsx($,{name:"strikethrough_s",size:St})}),v&&jsxRuntime.jsx(dn,{mode:"text",value:n.color?.replace(/^#/,""),onChange:We,theme:R,disabled:c,title:t("formattingBar.fontColor")}),y&&jsxRuntime.jsx(dn,{mode:"highlight",value:n.highlight,onChange:pe,theme:R,disabled:c,title:t("formattingBar.highlightColor")}),jsxRuntime.jsx(ft,{onClick:()=>B("insertLink"),disabled:c,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsxRuntime.jsx($,{name:"link",size:St})})]}),jsxRuntime.jsxs(Pt,{label:t("formattingBar.groups.script"),children:[jsxRuntime.jsx(ft,{onClick:()=>B("superscript"),active:n.superscript,disabled:c,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsxRuntime.jsx($,{name:"superscript",size:St})}),jsxRuntime.jsx(ft,{onClick:()=>B("subscript"),active:n.subscript,disabled:c,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsxRuntime.jsx($,{name:"subscript",size:St})})]}),C&&jsxRuntime.jsx(Pt,{label:t("formattingBar.groups.alignment"),children:jsxRuntime.jsx(cb,{value:n.alignment||"left",onChange:Ke,disabled:c})}),(T||w)&&jsxRuntime.jsxs(Pt,{label:t("formattingBar.groups.listFormatting"),children:[T&&jsxRuntime.jsx(ub,{listState:n.listState||Ll(),onBulletList:Bt,onNumberedList:he,onIndent:wt,onOutdent:Ul,disabled:c,showIndentButtons:true,compact:true,hasIndent:(n.indentLeft??0)>0}),w&&jsxRuntime.jsx(mb,{value:n.lineSpacing,onChange:Gl,disabled:c})]}),I&&P&&jsxRuntime.jsxs(Pt,{label:t("formattingBar.groups.image"),children:[jsxRuntime.jsx(Ib,{imageContext:I,onChange:P,disabled:c}),k&&jsxRuntime.jsx(_b,{onTransform:k,disabled:c}),Y&&jsxRuntime.jsx(ft,{onClick:Y,disabled:c,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsxRuntime.jsx($,{name:"tune",size:St})})]}),z?.isInTable&&re&&jsxRuntime.jsxs(Pt,{label:t("formattingBar.groups.table"),children:[jsxRuntime.jsx(xb,{onAction:oo,disabled:c}),jsxRuntime.jsx(Tb,{onAction:oo,disabled:c,theme:R,value:Jt(z?.cellBorderColor,R)}),jsxRuntime.jsx(Sb,{onAction:oo,disabled:c}),jsxRuntime.jsx(Eb,{onAction:oo,disabled:c,theme:R,value:z?.cellBackgroundColor}),jsxRuntime.jsx(kb,{onAction:oo,disabled:c,tableContext:z})]}),jsxRuntime.jsx(ft,{onClick:()=>B("clearFormatting"),disabled:c,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsxRuntime.jsx($,{name:"format_clear",size:St})}),p]})}function tM({children:e,className:t,style:o,...n}){return jsxRuntime.jsx(Ia.Provider,{value:n,children:jsxRuntime.jsx("div",{className:ne("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:Qe.toolbar,...o},"data-testid":"editor-toolbar",children:e})})}var at=tM;at.TitleBar=ou;at.Logo=wl;at.DocumentName=tu;at.MenuBar=Ml;at.TitleBarRight=Rl;at.Toolbar=gu;var rM=new Map([["#ffff00","yellow"],["#00ff00","green"],["#00ffff","cyan"],["#ff00ff","magenta"],["#0000ff","blue"],["#ff0000","red"],["#000080","darkBlue"],["#008080","darkCyan"],["#008000","darkGreen"],["#800080","darkMagenta"],["#800000","darkRed"],["#808000","darkYellow"],["#808080","darkGray"],["#c0c0c0","lightGray"],["#ffffff","white"]]),aM=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function iM({source:e,scale:t,measurer:o,documentName:n,onStateChange:r,onError:i,onSave:a,renderTitleBarLeft:l,renderTitleBarRight:s,ref:c,colorMode:d,onZoomChange:f,documentFontFamily:u,className:g}){let p=lt.useRef(null),[m,b]=lt.useState(null),[h,x]=lt.useState({}),[v,y]=lt.useState(null),C=lt.useCallback(M=>{b(M);let R=p.current?.formatting();R&&x({bold:R.bold,italic:R.italic,underline:R.underline,strike:R.strikethrough,superscript:R.superscript,subscript:R.subscript,...R.fontFamily?{fontFamily:R.fontFamily}:{},...R.fontSizeHalfPoints?{fontSize:R.fontSizeHalfPoints}:{},...R.alignment?{alignment:R.alignment}:{},...R.styleId?{styleId:R.styleId}:{},...R.color?{color:`#${R.color}`}:{},...R.highlight?{highlight:R.highlight}:{}}),y(p.current?.sectionProperties()??null),r?.(M);},[r]),T=lt.useCallback(M=>{let R=p.current;if(R){if(typeof M=="string")switch(M){case "bold":return R.toggleRunProperty("b");case "italic":return R.toggleRunProperty("i");case "underline":return R.toggleRunProperty("u",{val:"single"});case "strikethrough":return R.toggleRunProperty("strike");case "superscript":return R.setRunProperty("vertAlign",{val:"superscript"});case "subscript":return R.setRunProperty("vertAlign",{val:"subscript"});case "clearFormatting":R.setRunProperty("b",{val:"0"}),R.setRunProperty("i",{val:"0"}),R.setRunProperty("u",{val:"none"}),R.setRunProperty("strike",{val:"0"}),R.setRunProperty("vertAlign",{val:"baseline"});return;default:return}switch(M.type){case "fontFamily":return R.setRunProperty("rFonts",{ascii:M.value,hAnsi:M.value});case "fontSize":return R.setRunProperty("sz",{val:String(Math.round(M.value*2))});case "textColor":{let D=M.value,_=typeof D=="string"?aM(D):Jt(D,null)??null;return _?R.setRunProperty("color",{val:_}):void 0}case "highlightColor":{let D=M.value.trim().toLowerCase();if(D==="none"||D==="")return R.setRunProperty("highlight",{val:"none"});let _=rM.get(D.startsWith("#")?D:`#${D}`);return _?R.setRunProperty("highlight",{val:_}):void 0}case "alignment":return R.setParagraphProperty("jc",{val:String(M.value)});case "lineSpacing":return R.setParagraphProperty("spacing",{line:String(Math.round(M.value)),lineRule:"auto"},{mergeAttributes:true});case "applyStyle":return R.setParagraphProperty("pStyle",{val:M.value});default:return}}},[]);lt.useImperativeHandle(c,()=>p.current,[]);let w=t===void 0?1:t/(96/72),S=v?{pageWidthTwips:v.pageSize.widthTwips,pageHeightTwips:v.pageSize.heightTwips,orientation:v.landscape?"landscape":"portrait",marginsTwips:{top:v.margins.topTwips,right:v.margins.rightTwips,bottom:v.margins.bottomTwips,left:v.margins.leftTwips}}:null;return jsxRuntime.jsxs("div",{className:["docx-editor docx-paginated-shell",d==="dark"?"dark":"",g??""].filter(Boolean).join(" "),style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,background:"var(--doc-bg)",color:"var(--doc-text)"},"data-testid":"paginated-shell",children:[jsxRuntime.jsxs(at,{currentFormatting:h,onFormat:T,onUndo:()=>p.current?.undo(),onRedo:()=>p.current?.redo(),canUndo:m?.canUndo??false,canRedo:m?.canRedo??false,zoom:w,onZoomChange:f,onSave:()=>{let M=p.current?.save();M&&a?.(M);},children:[jsxRuntime.jsxs(at.TitleBar,{children:[l&&jsxRuntime.jsx(at.Logo,{children:l()}),jsxRuntime.jsx(at.DocumentName,{value:n??"Document",editable:false}),s&&jsxRuntime.jsx(at.TitleBarRight,{children:s()}),jsxRuntime.jsx(at.MenuBar,{})]}),jsxRuntime.jsx(at.Toolbar,{})]}),jsxRuntime.jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[S?jsxRuntime.jsx("div",{style:{padding:"4px 0"},children:jsxRuntime.jsx(Jo,{pageSetup:S,zoom:w})}):null,jsxRuntime.jsx(Yd,{ref:p,source:e,...u?{documentFontFamily:u}:{},...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onStateChange:C,...i?{onError:i}:{}})]})]})}var zl=class{listeners=new Set;snapshot;constructor(t){this.snapshot=t;}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t);});getSnapshot=()=>this.snapshot;setSnapshot(t){this.snapshot=t,this.notify();}notify(){for(let t of this.listeners)t();}};var Vl=class extends zl{notifications=[];idCounter=0;timers=new Set;constructor(){super({notifications:[]});}showError(t,o){return this.addNotification(t,"error",o)}showWarning(t,o){return this.addNotification(t,"warning",o)}showInfo(t,o){return this.addNotification(t,"info",o)}dismiss(t){this.notifications=this.notifications.map(n=>n.id===t?{...n,dismissed:true}:n),this.emitSnapshot();let o=setTimeout(()=>{this.timers.delete(o),this.notifications=this.notifications.filter(n=>n.id!==t),this.emitSnapshot();},300);this.timers.add(o);}clearAll(){this.notifications=[];for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.emitSnapshot();}destroy(){for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.notifications=[];}addNotification(t,o,n){let r=`error-${++this.idCounter}-${Date.now()}`,i={id:r,message:t,severity:o,details:n,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),o!=="error"){let a=setTimeout(()=>{this.timers.delete(a),this.dismiss(r);},5e3);this.timers.add(a);}return r}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var pM=lt.createContext(null);function Hb({children:e}){let t=lt.useMemo(()=>new Vl,[]),o=lt.useSyncExternalStore(t.subscribe,t.getSnapshot),n=lt.useCallback((c,d)=>{t.showError(c,d);},[t]),r=lt.useCallback((c,d)=>{t.showWarning(c,d);},[t]),i=lt.useCallback((c,d)=>{t.showInfo(c,d);},[t]),a=lt.useCallback(c=>{t.dismiss(c);},[t]),l=lt.useCallback(()=>{t.clearAll();},[t]),s=lt.useMemo(()=>({notifications:o.notifications,showError:n,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:l}),[o.notifications,n,r,i,a,l]);return jsxRuntime.jsxs(pM.Provider,{value:s,children:[e,jsxRuntime.jsx(mM,{notifications:o.notifications,onDismiss:a})]})}function mM({notifications:e,onDismiss:t}){let o=e.filter(r=>!r.dismissed);return o.length===0?null:jsxRuntime.jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:o.map(r=>jsxRuntime.jsx(fM,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function fM({notification:e,onDismiss:t}){let{t:o}=L(),[n,r]=lt.useState(false),a=(m=>{switch(m){case "error":return {bg:"var(--doc-error-bg)",border:"var(--doc-error)",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"var(--doc-warning)",text:"var(--doc-warning-text)",icon:"var(--doc-warning)"};case "info":return {bg:"var(--doc-primary-light)",border:"var(--doc-primary)",text:"var(--doc-primary)",icon:"var(--doc-primary)"}}})(e.severity),l={background:a.bg,border:`1px solid ${a.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px var(--doc-shadow)",animation:"docx-notification-slide-in 0.3s ease-out"},s={display:"flex",alignItems:"flex-start",gap:"8px"},c={color:a.icon,flexShrink:0},d={flex:1,minWidth:0},f={color:a.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},u={marginTop:"8px",padding:"8px",background:"var(--doc-shadow-subtle)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:a.text,maxHeight:"200px",overflow:"auto"},g={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:a.text},p=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.jsx("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:l,children:jsxRuntime.jsxs("div",{style:s,children:[jsxRuntime.jsx("span",{style:c,children:p(e.severity)}),jsxRuntime.jsxs("div",{style:d,children:[jsxRuntime.jsx("div",{style:f,children:e.message}),e.details&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>r(!n),style:{...g,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:o(n?"errors.hideDetails":"errors.showDetails")}),n&&jsxRuntime.jsx("div",{style:u,children:e.details})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,style:g,title:o("common.dismiss"),children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}var $l=class extends lt.Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",t,o),this.props.onError&&this.props.onError(t,o);}resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};render(){if(this.state.hasError){let{fallback:t,showDetails:o=true}=this.props,{error:n,errorInfo:r}=this.state;return t?typeof t=="function"?t(n,this.resetError):t:jsxRuntime.jsx(gM,{error:n,errorInfo:r,showDetails:o,onReset:this.resetError})}return this.props.children}};function gM({error:e,errorInfo:t,showDetails:o,onReset:n}){let{t:r}=L(),i={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"var(--doc-surface)",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},a={color:"var(--doc-error)",marginBottom:"16px"},l={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},c={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"},d={padding:"10px 20px",background:"var(--doc-primary)",color:"var(--doc-on-primary)",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:"docx-error-fallback",style:i,children:[jsxRuntime.jsx("div",{style:a,children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsxRuntime.jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h2",{style:l,children:r("errors.somethingWentWrong")}),jsxRuntime.jsx("p",{style:s,children:r("errors.errorDescription")}),o&&jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("strong",{children:r("errors.errorLabel")})," ",e.message,t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[`
|
|
1
|
+
'use strict';var pt=require('react'),i18n=require('@docx-editor.dev/i18n'),jsxRuntime=require('react/jsx-runtime'),editor=require('@docx-editor.dev/core/editor'),store=require('@docx-editor.dev/core/store'),reactDom=require('react-dom'),classVarianceAuthority=require('class-variance-authority'),clsx=require('clsx'),xe=require('@radix-ui/react-select'),editor$1=require('@docx-editor.dev/core/contracts/editor');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var pt__namespace=/*#__PURE__*/_interopNamespace(pt);var xe__namespace=/*#__PURE__*/_interopNamespace(xe);var Ju={version:"2.21.1"};var Dh=Ju.version;var cs=pt.createContext(i18n.en),ds=pt.createContext("en");function Cn({i18n:e,children:t}){let o=pt.useContext(cs),n=pt.useContext(ds),r=typeof e?._lang=="string"?e._lang:n,i=pt.useMemo(()=>i18n.deepMerge(o,e),[o,e]);return jsxRuntime.jsx(ds.Provider,{value:r,children:jsxRuntime.jsx(cs.Provider,{value:i,children:t})})}function L(){let e=pt.useContext(cs),t=pt.useContext(ds);return {t:pt.useMemo(()=>i18n.createT(e,t),[e,t]),catalogue:e}}function np(e){let{t}=L();return pt.useCallback((o,n)=>e?.get(o)??t(o,n),[e,t])}var ot={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};var us=pt.createContext(null);function F(){return pt.useContext(us)}var Ct=pt.createContext(null);var ps=0,ms=false,fs=false;function ap(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(ms||(ms=true,ps+=1,queueMicrotask(()=>{ms=false;}),fs||(fs=true,setTimeout(()=>{fs=false,ps=0;},0))),ps>16)}function ip(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};ap()?setTimeout(o,0):queueMicrotask(o);}}var Hh=()=>{},bs=0;function Oh(){return bs}function pr(e){return ip(e)}function O(e,t=Object.is,o){let n=F(),r=o?.onSubscribe,i=o?.onUnsubscribe,a=pt.useCallback(d=>{if(!n)return Hh;let f=false;bs++,r?.();let u=pr(()=>{f||d();}),g=[n.on("change",u),n.on("selectionChange",u),n.on("error",u)];return ()=>{f=true,bs--,i?.();for(let p of g)p();}},[n,r,i]),l=pt.useMemo(()=>{let d=false,f,u;return g=>{if(d&&g===f)return u;let p=e(g);return d&&t(u,p)?(f=g,u):(d=true,f=g,u=p,p)}},[n,e,t]),s=pt.useCallback(()=>l(n?n.snapshot():editor.LOADING_SNAPSHOT),[n,l]),c=pt.useCallback(()=>l(editor.LOADING_SNAPSHOT),[l]);return pt.useSyncExternalStore(a,s,c)}function Uh(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason&&e.value===t.value}function hs(e){return typeof e=="string"}function se(e){let t=F(),{t:o}=L(),n=hs(e)?e:editor.editorCommandKey(e),r=pt.useRef(e);r.current=e;let i=pt.useCallback(s=>{let c=r.current;if(hs(c)){let f=editor.toolbarCommandState(t,c);return {active:f.active,enabled:f.enabled,disabledReason:i18n.localizeDisabledReason(f.disabledReason,o),value:f.value??null}}if(!t)return {active:false,enabled:false,disabledReason:null,value:null};let d=t.can(c);return {active:t.isActive(c),enabled:d.ok,disabledReason:d.ok?null:i18n.localizeDisabledReason(d.reason??null,o),value:null}},[t,n,o]),a=O(i,Uh),l=pt.useCallback(s=>{let c=editor.commandExecOptions(s),d=r.current;return hs(d)?editor.runToolbarCommand(t,d,void 0,c??{}).ok:t?t.exec(d,c).ok:false},[t]);return pt.useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[l,a])}var Yh=()=>()=>{},jh=()=>true,Xh=()=>false;function Sn(){let e=pt.useSyncExternalStore(Yh,jh,Xh);return pt.useCallback(t=>e?i18n.platformShortcut(t):t,[e])}var No=pt.createContext({t:void 0,onSave:void 0});function Jh(){return pt.useContext(No)}function Va(e){let{t}=L();return o=>e?.(o)??t(o)}function ee(){let{t:e}=pt.useContext(No);return Va(e)}function nv(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function rv(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=nv(t[n],e[n]):n==="className"?o[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(o[n]={...e[n],...t[n]});return o}function Y({children:e,...t}){let o=pt.Children.only(e);if(!pt.isValidElement(o))return null;let n=o.props,r=rv(t,n),i=o.ref,a=t.ref;return (i||a)&&(r.ref=l=>{for(let s of [i,a])typeof s=="function"?s(l):s&&typeof s=="object"&&(s.current=l);}),pt.cloneElement(o,r)}function Q(e){for(let t of editor.CHROME_GROUPS)for(let o of t.controls)if(editor.chromeSlotId(t,o)===e)return o;return null}function oe(e){return e?jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:e.map(t=>jsxRuntime.jsx("path",{d:t,fill:"currentColor"},t))}):null}function Z(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Lo(e){let{slot:t,icon:o,asChild:n,className:r,children:i,hidden:a}=e,{execute:l,isActive:s,isEnabled:c,disabledReason:d,value:f}=se(t),u=ee(),g=Sn();if(a)return null;let p=Q(t),m=g(u(p?.labelKey??t)),b=editor.chromeSlotIsToggle(t),v={onClick:()=>l(),onMouseDown:Z,disabled:!c,"data-slot":t,className:`docx-toolbar__button${r?` ${r}`:""}`,...s?{"data-active":""}:{},...c?{}:{"data-disabled":""},...b?{"aria-pressed":s}:{},...f!==null?{"data-value":f}:{},"aria-label":m,title:d??m};return n?jsxRuntime.jsx(Y,{...v,children:i}):jsxRuntime.jsx("button",{type:"button",...v,children:o??i??oe(p?.paths)})}Lo.docxToolbarPart=true;function Pn({text:e,x:t,y:o,className:n}){return jsxRuntime.jsx("div",{role:"tooltip",className:n,"data-testid":"docx-notes-preview",style:{position:"fixed",left:t,top:o,zIndex:ot.popover,maxWidth:280,maxHeight:"40vh",overflowY:"auto",padding:"8px 10px",background:"var(--doc-popover-bg)",color:"var(--doc-popover-fg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",fontSize:12,lineHeight:1.4,pointerEvents:"none"},onMouseDown:r=>{r.preventDefault(),r.stopPropagation();},children:e})}function En({noteKind:e,x:t,y:o,onDelete:n,onConvert:r,onConvertAll:i,onOpenProperties:a,onClose:l,deleteEnabled:s,convertEnabled:c,convertAllEnabled:d,deleteDisabledReason:f,convertDisabledReason:u,convertAllDisabledReason:g,className:p}){let{t:m}=L();return jsxRuntime.jsxs("div",{role:"menu",className:p,onKeyDown:b=>{b.key==="Escape"&&l();},"data-testid":"docx-notes-menu",style:{position:"fixed",left:t,top:o,zIndex:ot.popover,minWidth:160,background:"var(--doc-popover-bg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",padding:4},onMouseDown:Z,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!s,title:f,onClick:n,children:m("notes.delete")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!c,title:u,onClick:r,children:m(e==="footnote"?"notes.convertToEndnote":"notes.convertToFootnote")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert-all",disabled:!d,title:g,onClick:i,children:m(e==="footnote"?"notes.convertAllFootnotes":"notes.convertAllEndnotes")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",onClick:a,children:m("dialogs.footnoteProperties.title")})]})}function dv(e){return t=>pt.createElement(e,t)}var dp=new WeakMap,uv=0;function Fe(e,t,o){if(e===false)return null;let n=e(t);if(!o)return n;let r=dp.get(o);return r===void 0&&dp.set(o,r=++uv),pt.createElement(pt.Fragment,{key:r},n)}function wn(e,t,o){let n=e.getBoundingClientRect();return {left:t-n.left-e.clientLeft+e.scrollLeft,top:o-n.top-e.clientTop+e.scrollTop}}function fr(e){return e.paragraphId===""}var Fo=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),bv=e=>e;function hv(){let e=o=>!!o&&(o.width>0||o.height>0);if(typeof document<"u"){let n=document.querySelector("[data-docx-caret]")?.getBoundingClientRect();if(e(n))return {left:n.left,top:n.bottom}}let t=typeof window>"u"?null:window.getSelection();if(t&&t.rangeCount>0){let o=t.getRangeAt(0),n=o.getBoundingClientRect();if(e(n))return {left:n.left,top:n.bottom};let r=o.startContainer,a=(r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.getBoundingClientRect();if(e(a))return {left:a.left,top:a.bottom}}return null}var gr=pt.createContext(null);function vs(){let e=pt.useContext(gr),t=ja(e===null);return e??t}function ja(e=true){let t=F(),[o,n]=pt.useState(Fo),r=pt.useRef(null),i=pt.useRef(o);i.current=o;let a=O(bv),l=t?t.can({type:"insertText",text:""}).ok:false,s=pt.useCallback(()=>{let h=r.current;h&&(h.editor.releaseSelection(h.pin),r.current=null);},[]),c=pt.useCallback((h,y)=>{s(),n({mode:h?"reading":"editing",link:h??null,anchor:y??null,text:h?.text??"",url:h?h.kind==="internal"?`#${h.anchor??""}`:h.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,s]),d=pt.useCallback(()=>{s(),n(Fo);},[s]);pt.useEffect(()=>s,[s]);let f=pt.useCallback(()=>{let h=hv();s();let y=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(y&&fr(y)){c(y,h);return}if(y){n({mode:"editing",link:y,anchor:h,text:y.text,url:y.kind==="internal"?`#${y.anchor??""}`:y.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let T=t?.query({type:"selectedText"})??"",C=t?.retainSelection()??null;t&&C&&(r.current={editor:t,pin:C}),n({mode:"editing",link:null,anchor:h,text:T,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,c,s]);pt.useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:h=>c(h.link,{left:h.rect.left,top:h.rect.bottom}),onRequest:f})},[t,e,c,f]),pt.useEffect(()=>{let h=i.current;if(h.mode!=="reading"||!h.link)return;let y=fr(h.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;y&&y.id===h.link.id||n(Fo);},[a,t]),pt.useEffect(()=>{let h=i.current;if(h.mode!=="editing"||h.link)return;let y=t?.surface;!y||y.retainedSelection()||n(Fo);},[a,t]);let u=pt.useCallback(async()=>{let h=i.current.link?.href;if(!h)return false;try{await navigator.clipboard.writeText(h);}catch{return false}return n(y=>({...y,copied:true})),true},[]),g=pt.useCallback(()=>{n(h=>({...h,mode:"editing",copied:false,error:false}));},[]),p=pt.useCallback(h=>{n(y=>({...y,text:h,copied:false,error:false}));},[]),m=pt.useCallback(h=>{n(y=>({...y,url:h,copied:false,error:false}));},[]),b=pt.useCallback(()=>{let h=i.current,y=t?.surface?.hyperlinks;if(!y)return false;let T=h.url.trim();if(T.length===0)return n(S=>({...S,error:true})),false;let C=T.startsWith("#");return y.applyHyperlink({...C?{anchor:T.slice(1)}:{url:T},...h.text.trim().length>0?{text:h.text}:{}})?(d(),true):(n(S=>({...S,error:true})),false)},[t,d]),v=pt.useCallback(()=>{let h=t?.surface?.hyperlinks,y=i.current.link;if(!h)return false;let T=h.removeHyperlink(y?.id);return T&&d(),T},[t,d]),x=pt.useCallback(()=>{let h=t?.surface?.navigation,y=i.current.link;if(!h||!y)return false;if(y.kind==="internal"){let C=y.anchor?h.goToBookmark(y.anchor):false;return C&&n(Fo),C}let T=h.openExternal(y.href);return T&&n(Fo),T},[t]);return pt.useMemo(()=>({state:o.mode==="closed"?Fo:{...o,canEdit:l},open:c,openAtCaret:f,close:d,copy:u,beginEdit:g,setText:p,setUrl:m,commitEdit:b,unlink:v,openTarget:x}),[o,l,c,f,d,u,g,p,m,b,v,x])}function Ho(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var Xa=e=>jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})}),Pv="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z",Ev="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z",wv="M770-302 656-416l57-57 114 114-57 57ZM603-469 469-603l57-57 134 134-57 57ZM280-280h133v80H280q-83 0-141.5-58.5T80-400q0-83 58.5-141.5T280-600h133v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35Zm40-80v-80h101l80 80H320Zm493-15-57-57q23-11 33.5-32t10.5-36q0-50-35-85t-85-35H547v-80h133q83 0 141.5 58.5T880-400q0 32-11 61.5T813-375ZM792-56 56-792l56-56 736 736-56 56Z",Mv="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z";function Rv({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=Nt(),a=pt.useRef(null),{state:l,close:s}=i;pt.useEffect(()=>{if(l.mode==="closed")return;let m=v=>{v.key==="Escape"&&(v.preventDefault(),s());},b=v=>{let x=a.current;x&&v.target instanceof Node&&x.contains(v.target)||s();};return document.addEventListener("keydown",m),document.addEventListener("mousedown",b,true),()=>{document.removeEventListener("keydown",m),document.removeEventListener("mousedown",b,true);}},[l.mode,s]);let[c,d]=pt.useState(null);pt.useLayoutEffect(()=>{let m=l.anchor,b=a.current;if(!m||!b){d(null);return}let v=b.offsetParent;if(!v){d(null);return}let{left:x,top:h}=wn(v,m.left,m.top),y=Math.max(0,v.scrollWidth-b.offsetWidth);d({left:Math.max(0,Math.min(x,y)),top:h});},[l.anchor]);let{t:f}=L(),u=l.mode==="editing"?f(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):f("hyperlinkPopup.editLink"),g=r?jsxRuntime.jsx(Dv,{children:n}):n;if(o)return l.mode==="closed"?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:n});let p={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:Ho,style:c??void 0,"aria-label":u};return l.mode==="closed"?null:t?jsxRuntime.jsx(Y,{...p,children:n}):jsxRuntime.jsx("div",{...p,children:g})}function Dv({children:e}){let{state:t}=Nt(),o=pt.useMemo(()=>kv(e),[e]),n=(i,a)=>i in o?o[i]:a;if(t.mode==="editing")return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Fields",jsxRuntime.jsx(Ps,{})),n("Error",jsxRuntime.jsx(ws,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Apply",jsxRuntime.jsx(Es,{})),n("Cancel",jsxRuntime.jsx(Ms,{}))]}),o.__extra]});let r=t.canEdit&&!(t.link&&fr(t.link));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Url",jsxRuntime.jsx(xs,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Copy",jsxRuntime.jsx(Cs,{})),r?n("Edit",jsxRuntime.jsx(Ts,{})):null,r?n("Unlink",jsxRuntime.jsx(Ss,{})):null]}),o.__extra]})}function kv(e){let t={},o=[],n=r=>{if(Array.isArray(r)){r.forEach(n);return}if(!r||typeof r!="object"||!("type"in r)){r&&o.push(r);return}if(r.type===pt.Fragment){n(r.props.children);return}let i=r.type.docxHyperLinkPart;i?t[i]=r:o.push(r);};return n(e),o.length>0&&(t.__extra=o),t}function Nt(){return pt.useContext(gr)??Iv}var Iv={state:{mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:false},open:()=>{},openAtCaret:()=>{},close:()=>{},copy:async()=>false,beginEdit:()=>{},setText:()=>{},setUrl:()=>{},commitEdit:()=>false,unlink:()=>false,openTarget:()=>false};function xs({className:e,asChild:t,hidden:o,children:n}){let{state:r,openTarget:i}=Nt(),{t:a}=L();if(o||!r.link)return null;let l=!r.link.href,s=r.link.kind==="internal",c=s?`#${r.link.anchor??""}`:r.link.authored,d=a(l?"hyperlinkPopup.inertTarget":s?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),f={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...l?{"data-inert":""}:{},title:d,onMouseDown:Ho,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsxRuntime.jsx(Y,{...f,className:e,children:n}):l?jsxRuntime.jsxs("span",{...f,children:[n??c,jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:d})]}):jsxRuntime.jsxs("button",{...f,children:[n??c,Xa(Mv)]})}xs.docxHyperLinkPart="Url";function Cs({className:e,asChild:t,hidden:o,children:n,icon:r}){let{state:i,copy:a}=Nt(),{t:l}=L();if(o||!i.link?.href)return null;let s=i.copied?l("editor.linkCopied"):l("hyperlinkPopup.copyLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...i.copied?{"data-copied":""}:{},"aria-label":s,title:s,onMouseDown:Ho,onClick:()=>{a();}};return t?jsxRuntime.jsx(Y,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:r??n??Xa(Pv)})}Cs.docxHyperLinkPart="Copy";function Ts({className:e,asChild:t,hidden:o,children:n,icon:r}){let{beginEdit:i}=Nt(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.editLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":l,title:l,onMouseDown:Ho,onClick:()=>i()};return t?jsxRuntime.jsx(Y,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:r??n??Xa(Ev)})}Ts.docxHyperLinkPart="Edit";function Ss({className:e,asChild:t,hidden:o,children:n,icon:r}){let{unlink:i}=Nt(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.removeLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":l,title:l,onMouseDown:Ho,onClick:()=>i()};return t?jsxRuntime.jsx(Y,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:r??n??Xa(wv)})}Ss.docxHyperLinkPart="Unlink";function Ps({className:e,hidden:t}){let{state:o,setText:n,setUrl:r,commitEdit:i,close:a}=Nt(),{t:l}=L(),s=pt.useRef(null),c=pt.useId(),d=pt.useId();pt.useEffect(()=>{o.mode==="editing"&&(s.current?.focus({preventScroll:true}),s.current?.select());},[o.mode]);let f=pt.useCallback(u=>{if(u.key==="Enter"){u.preventDefault(),i();return}u.key==="Escape"&&(u.preventDefault(),a());},[i,a]);return t?null:jsxRuntime.jsxs("div",{className:`docx-hyperlink-popup__fields${e?` ${e}`:""}`,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:l("hyperlinkPopup.displayTextPlaceholder")}),jsxRuntime.jsx("input",{id:c,"data-testid":"hyperlink-popup-text",className:"docx-hyperlink-popup__input",value:o.text,placeholder:l("hyperlinkPopup.displayTextPlaceholder"),onChange:u=>n(u.target.value),onKeyDown:f}),jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:l("hyperlinkPopup.urlPlaceholder")}),jsxRuntime.jsx("input",{id:d,ref:s,"data-testid":"hyperlink-popup-url-input",className:"docx-hyperlink-popup__input",value:o.url,placeholder:l("hyperlinkPopup.urlPlaceholder"),onChange:u=>r(u.target.value),onKeyDown:f})]})}Ps.docxHyperLinkPart="Fields";function Es({className:e,asChild:t,hidden:o,children:n}){let{state:r,commitEdit:i}=Nt(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.apply"),s={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:Ho,onClick:()=>i()};return t?jsxRuntime.jsx(Y,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:n??l})}function ws({className:e,hidden:t}){let{state:o}=Nt(),{t:n}=L();return t||!o.error?null:jsxRuntime.jsx("div",{className:`docx-hyperlink-popup__error${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-error",role:"alert",children:n("hyperlinkPopup.refused")})}ws.docxHyperLinkPart="Error";Es.docxHyperLinkPart="Apply";function Ms({className:e,asChild:t,hidden:o,children:n}){let{close:r}=Nt(),{t:i}=L();if(o)return null;let a=i("hyperlinkPopup.cancel"),l={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:Ho,onClick:()=>r()};return t?jsxRuntime.jsx(Y,{...l,className:e,children:n}):jsxRuntime.jsx("button",{...l,children:n??a})}Ms.docxHyperLinkPart="Cancel";var br=Object.assign(Rv,{Url:xs,Copy:Cs,Edit:Ts,Unlink:Ss,Fields:Ps,Error:ws,Apply:Es,Cancel:Ms});var rt={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function Fv(e){return e==="sdtLocked"||e==="sdtContentLocked"}function Av(e){return e==="contentLocked"||e==="sdtContentLocked"}function Ds(e,t){return !e.ok&&e.code===t}function Lt(){let e=pt.useContext(ks),t=Qa();return e??t}function Qa(){let e=F(),[t,o]=pt.useState(false),[n,r]=pt.useState(false),[i,a]=pt.useState(false),l=O(E=>E),s=e?.surface??null,c=s?.contentControls;pt.useEffect(()=>{r(c?.showAll()??s?.state().contentControls.showAll??false),a(c?.formFill()??s?.state().contentControls.formFill??false);},[l,c,s]);let d=pt.useMemo(()=>{if(!e)return null;let E=c?.atCaret()??null;if(E){let P=c?.disabledReason(E.id,"edit")??null,k=c?.disabledReason(E.id,"remove")??null;return {id:E.id,tag:E.tag??null,alias:E.alias??null,controlType:E.controlType,locked:Av(E.effectiveLock)||P==="locked",removalLocked:Fv(E.effectiveLock)||k==="locked",placeholder:E.placeholder,bound:E.bound||P==="bound",effectiveLock:E.effectiveLock}}let S=e.query({type:"contentControlAt"});if(!S)return null;let D=c?.disabledReason(S.id,"edit")??null,R=c?.disabledReason(S.id,"remove")??null,w=e.can({type:"setContentControlValue",value:""}),I=e.can({type:"removeContentControl"}),H=S.locked===true||D==="locked"||Ds(w,"locked"),N=D==="bound"||Ds(w,"bound"),_=R==="locked"||Ds(I,"locked");return {id:S.id,tag:S.tag??null,alias:S.alias??null,controlType:S.controlType,locked:H,removalLocked:_,placeholder:false,bound:N,effectiveLock:null}},[e,l,c]),f=pt.useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=pt.useCallback(E=>{c?.setShowAll(E),r(E);},[c]),g=pt.useCallback(E=>{c?.setFormFill(E),a(E);},[c]),p=pt.useCallback(()=>u(!n),[u,n]),m=pt.useCallback(()=>g(!i),[g,i]),b=pt.useCallback(()=>o(true),[]),v=pt.useCallback(()=>o(false),[]),x=pt.useCallback(()=>o(E=>!E),[]),h=pt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let S=c.disabledReason(d.id,"edit");return S==="locked"?"the content control is locked":S==="bound"?"the content control is bound to external data":S==="notFound"?"the content control was not found":S}if(d.locked)return "the content control is locked";if(d.bound)return "the content control is bound to external data";if(!e)return "no document is loaded";let E=e.can({type:"setContentControlValue",value:""});return E.ok?null:E.reason},[d,c,e]),y=pt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let S=c.disabledReason(d.id,"remove");return S==="locked"?"the content control is locked":S==="notFound"?"the content control was not found":S}if(d.removalLocked)return "the content control is locked";if(!e)return "no document is loaded";let E=e.can({type:"removeContentControl"});return E.ok?null:E.reason},[d,c,e]),T=pt.useCallback(E=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c&&d){let S=c.disabledReason(d.id,"edit");if(S)return {ok:false,code:S==="bound"?"bound":S==="locked"?"locked":"notFound",reason:S==="bound"?"the content control is bound to external data":S==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:E})},[e,c,d]),C=pt.useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c){let E=d?.id;if(!E)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let S=c.disabledReason(E,"remove");return S?{ok:false,code:S==="locked"?"locked":"notFound",reason:S==="locked"?"the content control is locked":"the content control was not found"}:c.remove(E)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,c,d]);return pt.useMemo(()=>({control:d,controls:f,showAll:n,formFill:i,inspectorOpen:t,canSetValue:h===null&&d!==null,canRemove:y===null&&d!==null,setValueDisabledReason:h,removeDisabledReason:y,setShowAll:u,toggleShowAll:p,setFormFill:g,toggleFormFill:m,openInspector:b,closeInspector:v,toggleInspector:x,remove:C,setValue:T}),[d,f,n,i,t,h,y,u,p,g,m,b,v,x,C,T])}var ks=pt.createContext(null);function Is(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var hp=e=>jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})}),Bv="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z",Zv="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",qv={position:"absolute",zIndex:20,minWidth:240,maxWidth:320,top:12,right:12,padding:12,borderRadius:8,border:"1px solid var(--doc-border)",backgroundColor:"var(--doc-surface)",boxShadow:"0 4px 16px var(--doc-shadow)",color:"var(--doc-text)",fontSize:13,display:"flex",flexDirection:"column",gap:10},Kv={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},Wv={color:"var(--doc-text-muted)",flexShrink:0},zv={textAlign:"right",wordBreak:"break-word"},Uv={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},$v={display:"flex",gap:8,marginTop:4},vp={display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:4,border:"1px solid var(--doc-border)",backgroundColor:"var(--doc-bg)",color:"var(--doc-text)",font:"inherit",cursor:"pointer"};function Vv(e){switch(e){case "plainText":return "contentControl.types.plainText";case "checkbox":return "contentControl.types.checkbox";case "dropdown":return "contentControl.types.dropdown";case "comboBox":return "contentControl.types.comboBox";case "date":return "contentControl.types.date";case "picture":return "contentControl.types.picture";case "buildingBlockGallery":return "contentControl.types.buildingBlockGallery";case "repeatingSection":return "contentControl.types.repeatingSection";default:return "contentControl.types.richText"}}function Gv(e){return e.effectiveLock==="sdtContentLocked"?"contentControl.lock.sdtContentLocked":e.effectiveLock==="contentLocked"||e.locked?"contentControl.lock.contentLocked":e.effectiveLock==="sdtLocked"||e.removalLocked?"contentControl.lock.sdtLocked":"contentControl.lock.unlocked"}function Mn({label:e,value:t,testId:o}){return jsxRuntime.jsxs("div",{style:Kv,"data-testid":o,children:[jsxRuntime.jsx("span",{style:Wv,children:e}),jsxRuntime.jsx("span",{style:zv,children:t})]})}function Yv({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=Lt(),a=pt.useRef(null),l=pt.useId(),{t:s}=L(),{control:c,inspectorOpen:d,closeInspector:f}=i;if(pt.useEffect(()=>{if(!d)return;let m=v=>{v.key==="Escape"&&(v.preventDefault(),f());},b=v=>{let x=a.current;x&&v.target instanceof Node&&x.contains(v.target)||f();};return document.addEventListener("keydown",m),document.addEventListener("mousedown",b,true),()=>{document.removeEventListener("keydown",m),document.removeEventListener("mousedown",b,true);}},[d,f]),pt.useEffect(()=>{d&&!c&&f();},[d,c,f]),o||!d||!c)return null;let u=r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(yp,{}),jsxRuntime.jsx(xp,{}),jsxRuntime.jsx("div",{style:$v,children:jsxRuntime.jsx(Cp,{})}),n]}):n,g={ref:a,role:"dialog","aria-modal":false,"aria-labelledby":l,"data-testid":"content-control-inspector","data-control-id":c.id,"data-control-type":c.controlType,...c.locked?{"data-locked":""}:{},...c.bound?{"data-bound":""}:{},...c.placeholder?{"data-placeholder":""}:{},className:`docx-content-control-inspector${e?` ${e}`:""}`,style:qv,onMouseDown:m=>{Is(m),m.stopPropagation();}},p=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{id:l,className:"docx-editor-sr-only",children:s("contentControl.inspectorPanel.title")}),u]});return t?jsxRuntime.jsx(Y,{...g,children:p}):jsxRuntime.jsx("div",{...g,children:p})}function yp({className:e,asChild:t,hidden:o,children:n}){let{closeInspector:r}=Lt(),{t:i}=L();if(o)return null;let a={style:Uv,className:e??void 0,"data-testid":"content-control-inspector-header"},l=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:n??i("contentControl.inspectorPanel.title")}),jsxRuntime.jsx("button",{type:"button","data-testid":"content-control-inspector-close","aria-label":i("common.close"),title:i("common.close"),style:{...vp,padding:4,border:"none",background:"transparent"},onMouseDown:Is,onClick:()=>r(),children:hp(Bv)})]});return t?jsxRuntime.jsx(Y,{...a,children:l}):jsxRuntime.jsx("div",{...a,children:l})}function xp({className:e,asChild:t,hidden:o,children:n}){let{control:r}=Lt(),{t:i}=L();if(o||!r)return null;let a=i("contentControl.inspectorPanel.empty"),l=i("contentControl.inspectorPanel.yes"),s=i("contentControl.inspectorPanel.no"),c=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Mn,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsxRuntime.jsx(Mn,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsxRuntime.jsx(Mn,{label:i("contentControl.inspectorPanel.type"),value:i(Vv(r.controlType)),testId:"content-control-inspector-type"}),jsxRuntime.jsx(Mn,{label:i("contentControl.inspectorPanel.lock"),value:i(Gv(r)),testId:"content-control-inspector-lock"}),jsxRuntime.jsx(Mn,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsxRuntime.jsx(Mn,{label:i("contentControl.inspectorPanel.bound"),value:r.bound?l:s,testId:"content-control-inspector-bound"}),r.bound?jsxRuntime.jsx("p",{"data-testid":"content-control-inspector-bound-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},children:i("contentControl.inspectorPanel.boundNote")}):null,r.locked?jsxRuntime.jsx("p",{"data-testid":"content-control-inspector-locked-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},"aria-live":"polite",children:i("contentControl.inspectorPanel.lockedNote")}):null]}),d={className:e??void 0,"data-testid":"content-control-inspector-fields",style:{display:"flex",flexDirection:"column",gap:8}};return t?jsxRuntime.jsx(Y,{...d,children:c}):jsxRuntime.jsx("div",{...d,children:c})}function Cp({className:e,asChild:t,hidden:o,icon:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:s}=Lt(),{t:c}=L();if(o)return null;let d=c("contentControl.remove"),f={type:"button",className:`docx-content-control-inspector__remove${e?` ${e}`:""}`,"data-testid":"content-control-inspector-remove","data-slot":"contentControl.remove",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":d,title:a??d,style:vp,onMouseDown:Is,onClick:()=>{l().ok&&s();}},u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n??r??hp(Zv),jsxRuntime.jsx("span",{children:d})]});return t?jsxRuntime.jsx(Y,{...f,children:u}):jsxRuntime.jsx("button",{...f,children:u})}var yr=Object.assign(Yv,{Header:yp,Fields:xp,Remove:Cp});var Jv=e=>e;function As(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function xr(){let e=F(),{t}=L(),[o,n]=pt.useState(null),[r,i]=pt.useState(null),a=pt.useRef(null),l=pt.useRef(null),s=pt.useRef(null),c=pt.useId(),d=pt.useId(),f=pt.useId(),u=o?.activation??null,g=O(Jv),p=pt.useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let h=e.surface.equations.can(u.equation.id,"replace"),y=e.surface.equations.can(u.equation.id,"remove"),T=h.ok?y.ok?null:y.reason:h.reason;return {replaceEnabled:h.ok,removeEnabled:y.ok,reason:T?i18n.localizeDisabledReason(T,t):null}},[u,e,g,t]),m=pt.useCallback((h=false)=>{s.current?.(),s.current=null,n(null),h&&e&&queueMicrotask(()=>e.focus());},[e]);pt.useEffect(()=>{if(!e)return;let h=e.setEquationChrome({onPopover:y=>{s.current?.();let T=e.surface;if(T&&typeof T.retainSelection=="function"){let C=T.retainSelection();s.current=()=>T.releaseSelection(C);}else s.current=null;n({activation:y,mountGeneration:e.mountGeneration,draft:y.equation.linear,error:false});}});return ()=>{h(),s.current?.(),s.current=null,n(null);}},[e,m]),pt.useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&m();},[e,g,o,m]),pt.useEffect(()=>{if(!o)return;let h=a.current,y=h?.ownerDocument,T=y?.defaultView;if(!h||!y||!T)return;let C=S=>{S.key==="Escape"&&(S.preventDefault(),m(true));},E=S=>{S.target instanceof T.Node&&h.contains(S.target)||m();};return y.addEventListener("keydown",C),y.addEventListener("pointerdown",E,true),()=>{y.removeEventListener("keydown",C),y.removeEventListener("pointerdown",E,true);}},[o,m]),pt.useLayoutEffect(()=>{if(!u){i(null);return}let h=a.current;if(!h)return;let y=h.offsetParent;if(!y){i(null);return}let T=u.rect,C=wn(y,T.left,T.bottom),E=Math.max(0,y.scrollWidth-h.offsetWidth);i({left:Math.max(0,Math.min(C.left,E)),top:C.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[u]);let b=pt.useCallback(()=>{if(!o||!e?.surface||!p.replaceEnabled)return false;let h=e.surface.equations.applyEquation(o.activation.equation.id,o.draft);return h?m(true):n(y=>y&&{...y,error:true}),h},[e,o,m,p.replaceEnabled]),v=pt.useCallback(()=>{if(!o||!e?.surface||!p.removeEnabled)return false;let h=e.surface.equations.removeEquation(o.activation.equation.id);return h?m(true):n(y=>y&&{...y,error:true}),h},[e,o,m,p.removeEnabled]);if(!o)return null;let x=[o.error?d:null,p.reason?f:null].filter(Boolean).join(" ");return jsxRuntime.jsxs("div",{ref:a,className:"docx-equation-popup","data-testid":"equation-popup",role:"dialog","aria-modal":false,"aria-label":t("equationPopup.title"),style:r??void 0,onMouseDown:As,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:t("equationPopup.inputLabel")}),jsxRuntime.jsx("input",{id:c,ref:l,className:"docx-equation-popup__input","data-testid":"equation-popup-input",value:o.draft,placeholder:t("equationPopup.placeholder"),spellCheck:false,"aria-describedby":x||void 0,onChange:h=>n(y=>y&&{...y,draft:h.target.value,error:false}),onKeyDown:h=>{h.key!=="Enter"||h.nativeEvent.isComposing||(h.preventDefault(),b());}}),o.error?jsxRuntime.jsx("div",{id:d,className:"docx-equation-popup__error","data-testid":"equation-popup-error",role:"alert",children:t("equationPopup.refused")}):null,p.reason?jsxRuntime.jsx("div",{id:f,className:"docx-equation-popup__error","data-testid":"equation-popup-disabled-reason",role:"status",children:p.reason}):null,jsxRuntime.jsxs("div",{className:"docx-equation-popup__actions",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-equation-popup__apply","data-testid":"equation-popup-apply",disabled:!p.replaceEnabled,title:p.reason??void 0,onMouseDown:As,onClick:b,children:t("equationPopup.apply")}),jsxRuntime.jsx("button",{type:"button",className:"docx-equation-popup__delete","data-testid":"equation-popup-delete",disabled:!p.removeEnabled,title:p.reason??void 0,onMouseDown:As,onClick:v,children:t("equationPopup.delete")})]})]})}function kn(e,t){if(!pt.isValidElement(e)||e.type!==pt.Fragment)return null;let n=pt.Children.toArray(e.props.children).map(t).filter(r=>r!==null);return n.length===1?n[0]:null}function ei({entries:e,children:t,preset:o,keyOfEntry:n,keyOfChild:r,renderEntry:i}){if(!o)return t;let a=new Map,l=[];for(let f of pt.Children.toArray(t)){let u=r(f);u?a.set(u,f):l.push(f);}let s=e.map((f,u)=>{let g=n(f,u),p=a.get(g);return p?jsxRuntime.jsx(pt.Fragment,{children:p},g):jsxRuntime.jsx(pt.Fragment,{children:i(f,u)},g)}),c=new Set(e.map(n)),d=[...a.entries()].filter(([f])=>!c.has(f)).map(([f,u])=>jsxRuntime.jsx(pt.Fragment,{children:u},f));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[s,d,l]})}var Cr=pt.createContext({t:void 0,openMenu:null,setOpenMenu:()=>{},activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0});function at(){return pt.useContext(Cr)}function De(){let{t:e}=at(),{t}=L();return o=>e?.(o)??t(o)}var ay='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Oo(e){return [...e.querySelectorAll(ay)].filter(t=>t.closest('[role="menu"]')===e)}function Os(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function St(e,t,o){if(e.length===0)return false;let n=t?e.indexOf(t):-1,r=n===-1?o>0?0:e.length-1:(n+o+e.length)%e.length;return e[r]?.focus(),true}function Pt(e,t){let o=t==="first"?e[0]:e[e.length-1];return o?(o.focus(),true):false}var iy="https://github.com/eigenpal/docx-editor/issues/new";function ly(){if(typeof window>"u")return "";try{let e=new URL(window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function Ep(e={}){let t=e.userAgent??(typeof navigator<"u"?navigator.userAgent:"unknown"),o=e.viewport??(typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0}),r=["### What happened","","### Steps to reproduce","1. ","2. ","3. ","","### Expected","","### Actual","","### Attach the DOCX","Please drag the `.docx` file that reproduces this onto the issue (below this text box). Bugs are much faster to fix with a real file.","","### Environment",`- URL: ${e.pageUrl??ly()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
|
|
2
|
+
`),i=new URLSearchParams({title:"[Bug] ",body:r});return `${iy}?${i.toString()}`}function Tr(e){typeof window>"u"||window.open(Ep(e),"_blank","noopener,noreferrer");}var Mp=12700,wp=96;function uy(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function py(e,t,o,n){let r=e*72/o,i=t*72/n;return {widthPoints:Math.max(1,Math.round(r*100)/100),heightPoints:Math.max(1,Math.round(i*100)/100)}}function ti(e){let t=editor.DEFAULT_IMAGE_RESOURCE_LIMITS;if(e.byteLength===0)return {ok:false,reasonKey:"imageInsert.errors.emptyFile"};if(e.byteLength>t.maxEncodedBytes)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let o=editor.sniffImageMime(e);if(!uy(o))return o==="image/svg+xml"||o==="image/tiff"?{ok:false,reasonKey:"imageInsert.errors.unsupportedFormat"}:{ok:false,reasonKey:"imageInsert.errors.invalidSignature"};let n=editor.validateRasterHeader(e,o);if(!n)return {ok:false,reasonKey:"imageInsert.errors.invalidSignature"};if(n.pixelWidth*n.pixelHeight>t.maxPixels||n.pixelWidth>t.maxDimension||n.pixelHeight>t.maxDimension)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let{widthPoints:i,heightPoints:a}=py(n.pixelWidth,n.pixelHeight,n.dpiX??wp,n.dpiY??wp);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function co(e){return Math.round(e/Mp*100)/100}function Sr(e){return Math.round(e*Mp)}var vy="image/png,image/jpeg,image/gif",Zs=pt.createContext(null);function kp(){let e=pt.useContext(Zs);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function Pr(){return pt.useContext(Zs)}function oi({children:e}){let t=F(),{t:o}=L(),n=pt.useRef(null),r=pt.useRef(false),i=pt.useCallback(()=>editor.toolbarCommandState(t,"image.insert"),[t]),a=O(i,(m,b)=>m.enabled===b.enabled&&m.disabledReason===b.disabledReason),l=a.enabled,s=i18n.localizeDisabledReason(a.disabledReason,o),c=pt.useCallback(async m=>{if(!t||r.current)return;let b=ti(m);if(!b.ok){window.alert(o(b.reasonKey));return}let v={type:"insertImage",data:b.bytes,mime:b.mime,widthPoints:b.widthPoints,heightPoints:b.heightPoints},x=t.canExecuteImageCommand?.(v);if(x&&!x.ok){window.alert(x.reason??o("imageInsert.errors.refused"));return}r.current=true;try{let h=await editor.executeImageCommand(t,v);h.ok?t.focus():window.alert(h.reason??o("imageInsert.errors.refused"));}finally{r.current=false;}},[t,o]),d=pt.useCallback(async m=>{let b=m?.[0];if(!b)return;let v=await b.arrayBuffer();await c(new Uint8Array(v));},[c]),f=pt.useCallback(async m=>{if(!m)return;let b=[...m.files].find(v=>v.type.startsWith("image/"));if(b){await d([b]);return}for(let v of m.items){if(v.kind!=="file"||!v.type.startsWith("image/"))continue;let x=v.getAsFile();if(!x)continue;let h=await x.arrayBuffer();await c(new Uint8Array(h));return}},[c,d]),u=pt.useCallback(()=>{l&&n.current?.click();},[l]),g=pt.useCallback(async m=>{let b=m.currentTarget;await d(b.files),b.value="";},[d]),p=pt.useMemo(()=>({openFilePicker:u,insertFromFileList:d,insertFromDataTransfer:f,isEnabled:l,disabledReason:s,inputRef:n,onInputChange:g}),[u,d,f,l,s,g]);return jsxRuntime.jsxs(Zs.Provider,{value:p,children:[jsxRuntime.jsx("input",{ref:n,type:"file",accept:vy,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:g,onMouseDown:m=>m.stopPropagation()}),e]})}function ni({className:e,hidden:t,asChild:o,children:n}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=kp(),l=ee();if(t)return null;let s=Q("image.insert"),c=l(s?.labelKey??"toolbar.image"),d={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":c,title:a??c,onMouseDown:Z,onClick:r};return o?jsxRuntime.jsx(Y,{...d,children:n}):jsxRuntime.jsx("button",{...d,children:n??oe(s?.paths)})}ni.docxSlot="image.insert";var Er=Object.assign(ni,{docxSlot:"image.insert"});var qs=6,_p=6;function ke(e){let{icon:t,shortcut:o,disabled:n,title:r,active:i,selected:a,slot:l,onSelect:s,className:c,children:d}=e,f=e["data-value"],u=Sn(),g=pt.useId(),p=n&&r?g:void 0;return jsxRuntime.jsxs("button",{type:"button",role:i===void 0?"menuitem":a===void 0?"menuitemcheckbox":"menuitemradio",className:`docx-toolbar__menu-item docx-menubar__item${c?` ${c}`:""}`,tabIndex:-1,...l?{"data-slot":l}:{},...f!==void 0?{"data-value":f}:{},...i?{"data-active":""}:{},...n?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...p?{"aria-describedby":p}:{},...r?{title:r}:{},onMouseDown:Z,onClick:n?void 0:s,children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:t}),jsxRuntime.jsx("span",{className:"docx-menubar__item-label",children:d}),o?jsxRuntime.jsx("span",{className:"docx-menubar__item-shortcut",children:u(o)}):null,p?jsxRuntime.jsx("span",{id:g,className:"docx-editor-sr-only",children:r}):null]})}function Mr({label:e,labelKey:t,className:o,hidden:n,children:r}){let i=De();if(n)return null;let a=e??(t===void 0?void 0:i(t));return jsxRuntime.jsxs("div",{role:"group",className:`docx-menubar__group${o?` ${o}`:""}`,...a?{"aria-label":a}:{},children:[a?jsxRuntime.jsx("div",{className:"docx-menubar__group-label","aria-hidden":"true",children:a}):null,r]})}function Yt({slot:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let{execute:i,isActive:a,isEnabled:l,disabledReason:s,value:c}=se(e),{setOpenMenu:d}=at(),f=De();if(r)return null;let u=Q(e),g=f(t??u?.labelKey??e),p=editor.chromeSlotIsToggle(e),m=["setAlignment","setReviewDisplayMode"].includes(editor.commandForSlot(e)?.type??"");return jsxRuntime.jsx(ke,{slot:e,icon:oe(u?.paths),...o?{shortcut:f(o)}:{},disabled:!l,...s?{title:s}:{},...p?{active:a}:{},...m?{selected:true}:{},...c!==null?{"data-value":c}:{},onSelect:()=>{i(),d(null);},...n?{className:n}:{},children:g})}Yt.docxMenuRow=true;function Lp(e,t,o,n){return Object.assign(({className:i,hidden:a})=>{let l=at(),s=De(),c=n(l);if(a)return null;let d=Q(e),f=s(t??d?.labelKey??e);return jsxRuntime.jsx(ke,{slot:e,icon:oe(d?.paths),...o?{shortcut:s(o)}:{},disabled:!c,onSelect:()=>{c?.(),l.setOpenMenu(null);},...i?{className:i}:{},children:f})},{docxSlot:e})}var Ws=Lp("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),zs=Lp("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave);function Ey({className:e,hidden:t}){let o=F(),n=at(),r=De(),i=editor.chromeProbeForSlot("file.pageSetup"),a=o&&i?o.can(i):null,l=a?.ok===true,s=a&&!a.ok?a.reason:null;if(t)return null;let c=Q("file.pageSetup"),d=r(c?.labelKey??"file.pageSetup"),f=l&&!!n.onPageSetup;return jsxRuntime.jsx(ke,{slot:"file.pageSetup",icon:oe(c?.paths),disabled:!f,...s?{title:s}:{},onSelect:()=>{n.onPageSetup?.(),n.setOpenMenu(null);},...e?{className:e}:{},children:d})}function wy({className:e,hidden:t}){let o=F(),n=at(),r=De(),i=editor.chromeProbeForSlot("paragraph.dialog"),a=o&&i?o.can(i):null,l=a?.ok===true,s=a&&!a.ok?a.reason:null;if(t)return null;let c=Q("paragraph.dialog"),d=r(c?.labelKey??"lineSpacing.options"),f=l&&!!n.onParagraphDialog;return jsxRuntime.jsx(ke,{slot:"paragraph.dialog",icon:oe(c?.paths),disabled:!f,...s?{title:s}:{},onSelect:()=>{n.onParagraphDialog?.(),n.setOpenMenu(null);},...e?{className:e}:{},children:d})}var My=Object.assign(wy,{docxSlot:"paragraph.dialog"}),Us=Object.assign(Ey,{docxSlot:"file.pageSetup"});function Ry({className:e,hidden:t}){let o=Pr(),n=at(),r=De();if(t)return null;let i=Q("image.insert"),a=r(i?.labelKey??"toolbar.image"),l=o?.isEnabled??false,s=o?.disabledReason??null;return jsxRuntime.jsx(ke,{slot:"image.insert",icon:oe(i?.paths),disabled:!l,...s?{title:s}:{},onSelect:()=>{o?.openFilePicker(),n.setOpenMenu(null);},...e?{className:e}:{},children:a})}var $s=Object.assign(Ry,{docxSlot:"image.insert"}),wr=8;function Ft({labelKey:e,paths:t,className:o,children:n}){let r=De(),[i,a]=pt.useState(false),l=pt.useRef(null),s=pt.useRef(null),c=pt.useId(),d=r(e),[f,u]=pt.useState(null);return pt.useLayoutEffect(()=>{if(!i){u(null);return}let g=l.current,p=s.current,m=g?.ownerDocument.defaultView;if(!g||!p||!m)return;let b=g.getBoundingClientRect(),v=p.offsetWidth,x=p.offsetHeight,h=b.right+v>m.innerWidth-wr;u({left:h?Math.max(wr,b.left-v):Math.min(b.right,m.innerWidth-v-wr),top:Math.max(wr,Math.min(b.top-4,m.innerHeight-x-wr))});},[i]),jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__submenu${o?` ${o}`:""}`,onMouseEnter:()=>a(true),onMouseLeave:()=>a(false),onKeyDown:g=>{g.key==="ArrowRight"&&document.activeElement===l.current?(g.preventDefault(),a(true),queueMicrotask(()=>{s.current&&Pt(Oo(s.current),"first");})):(g.key==="ArrowLeft"||g.key==="Escape")&&i&&(g.preventDefault(),g.stopPropagation(),a(false),l.current?.focus());},onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||a(false);},children:[jsxRuntime.jsxs("button",{ref:l,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?c:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...i?{"data-open":""}:{},onMouseDown:Z,onFocus:()=>a(true),onClick:()=>a(true),children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:oe(t)}),jsxRuntime.jsx("span",{className:"docx-menubar__item-label",children:d}),jsxRuntime.jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),i?jsxRuntime.jsx("div",{ref:s,id:c,className:"docx-toolbar__menu docx-menubar__menu docx-menubar__submenu-panel",role:"menu","aria-label":d,style:f?{position:"fixed",left:f.left,top:f.top}:{position:"fixed",visibility:"hidden"},onKeyDown:g=>{let p=s.current;if(!p)return;let m=Oo(p);g.key==="ArrowDown"?(g.preventDefault(),g.stopPropagation(),St(m,document.activeElement,1)):g.key==="ArrowUp"&&(g.preventDefault(),g.stopPropagation(),St(m,document.activeElement,-1));},children:n}):null]})}function ai({slot:e="table.insert",className:t}){let o=F(),{isEnabled:n}=se(e),{setOpenMenu:r}=at(),i=De(),[a,l]=pt.useState(null),[s,c]=pt.useState({rows:1,cols:1}),d=pt.useRef(null),f=pt.useCallback((p,m)=>{if(!o||!n)return;let b={type:"insertTable",rows:p,cols:m};o.can(b).ok&&(o.exec(b),r(null),o.focus());},[o,n,r]),u=pt.useCallback(p=>{c(m=>{let b={rows:Math.min(_p,Math.max(1,m.rows+(p.rows??0))),cols:Math.min(qs,Math.max(1,p.toCol??m.cols+(p.cols??0)))};return l(b),queueMicrotask(()=>d.current?.querySelector(`[data-cell="${b.rows}x${b.cols}"]`)?.focus()),b});},[]),g=[];for(let p=1;p<=_p;p+=1){let m=[];for(let b=1;b<=qs;b+=1){let v=!!a&&p<=a.rows&&b<=a.cols;m.push(jsxRuntime.jsx("button",{type:"button",role:"gridcell","data-cell":`${p}x${b}`,className:"docx-menubar__grid-cell",tabIndex:s.rows===p&&s.cols===b?0:-1,...v?{"data-filled":""}:{},"aria-label":`${b} \xD7 ${p}`,onMouseDown:Z,onMouseEnter:()=>l({rows:p,cols:b}),onFocus:()=>l({rows:p,cols:b}),onClick:()=>f(p,b)},b));}g.push(jsxRuntime.jsx("div",{role:"row",className:"docx-menubar__grid-row",children:m},p));}return jsxRuntime.jsxs("div",{ref:d,role:"grid","aria-label":i("toolbar.insertTable"),className:`docx-menubar__grid${t?` ${t}`:""}`,onMouseLeave:()=>l(null),onKeyDown:p=>{if(p.key==="ArrowRight")u({cols:1});else if(p.key==="ArrowLeft")u({cols:-1});else if(p.key==="ArrowDown")u({rows:1});else if(p.key==="ArrowUp")u({rows:-1});else if(p.key==="Home")u({toCol:1});else if(p.key==="End")u({toCol:qs});else return;p.preventDefault(),p.stopPropagation();},children:[jsxRuntime.jsx("div",{className:"docx-menubar__grid-cells",children:g}),jsxRuntime.jsx("div",{className:"docx-menubar__grid-caption","aria-hidden":"true",children:a?`${a.cols} \xD7 ${a.rows}`:""})]})}function Dy({entry:e}){let{isEnabled:t}=se(e.slot),o=Q(e.slot);return t?jsxRuntime.jsx(Ft,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsxRuntime.jsx(ai,{slot:e.slot})}):jsxRuntime.jsx(Yt,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Zo({className:e}){return jsxRuntime.jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function Rr({entry:e}){return e.kind==="separator"?jsxRuntime.jsx(Zo,{}):e.kind==="submenu"?jsxRuntime.jsx(Ft,{labelKey:e.labelKey,paths:e.paths,children:e.items.map((t,o)=>jsxRuntime.jsx(Rr,{entry:t},o))}):e.slot==="file.open"?jsxRuntime.jsx(Ws,{}):e.slot==="file.save"?jsxRuntime.jsx(zs,{}):e.slot==="file.pageSetup"?jsxRuntime.jsx(Us,{}):e.slot==="paragraph.dialog"?jsxRuntime.jsx(My,{}):e.slot==="image.insert"?jsxRuntime.jsx($s,{}):e.picker==="tableGrid"?jsxRuntime.jsx(Dy,{entry:e}):jsxRuntime.jsx(Yt,{slot:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Fp(e){if(!pt.isValidElement(e))return null;let t=kn(e,Fp);if(t!==null)return t;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxMenuRow===true){let n=e.props.slot;if(typeof n=="string")return n}return null}function ky(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function Iy(e,t,o){return ei({entries:e??[],children:t,preset:o,keyOfEntry:ky,keyOfChild:Fp,renderEntry:n=>jsxRuntime.jsx(Rr,{entry:n})})}function po({id:e,labelKey:t,label:o,icon:n,className:r,hidden:i,preset:a=true,children:l}){let{openMenu:s,setOpenMenu:c,activeMenu:d}=at(),f=De(),u=pt.useId(),g=pt.useRef(null),p=pt.useRef(null),m=pt.useRef(false),b=pt.useRef(false),v=editor.CHROME_MENUS.find(C=>C.id===e),x=s===e;if(i)return null;let h=o??f(t??v?.labelKey??e),y=Iy(v?.entries,l,a),T=()=>{c(null),g.current?.focus();};return jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__menu-root${r?` ${r}`:""}`,"data-menu":e,children:[jsxRuntime.jsxs("button",{ref:g,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":x,"aria-controls":x?u:void 0,className:"docx-menubar__trigger",tabIndex:d===e?0:-1,...x?{"data-open":""}:{},onMouseDown:Z,onKeyDown:C=>{C.key==="ArrowDown"||C.key==="Enter"||C.key===" "||C.key==="ArrowUp"?(C.preventDefault(),m.current=true,c(e)):C.key==="Escape"&&x&&(C.preventDefault(),T());},onClick:()=>{if(b.current){b.current=false;return}c(x?null:e);},onMouseEnter:()=>{s!==null&&s!==e&&(b.current=true,c(e));},onMouseLeave:()=>{b.current=false;},children:[n?jsxRuntime.jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:n}):null,h]}),x?jsxRuntime.jsx("div",{ref:C=>{p.current=C,C&&m.current&&(m.current=false,Pt(Oo(C),"first"));},id:u,role:"menu","aria-label":h,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:C=>{let E=p.current;if(!E)return;let S=Oo(E),D=document.activeElement;C.key==="ArrowDown"?(C.preventDefault(),St(S,D,1)):C.key==="ArrowUp"?(C.preventDefault(),St(S,D,-1)):C.key==="Home"?(C.preventDefault(),Pt(S,"first")):C.key==="End"?(C.preventDefault(),Pt(S,"last")):C.key==="Escape"?(C.preventDefault(),C.stopPropagation(),T()):C.key==="Tab"&&c(null);},children:y}):null]})}function Vs(e){return Object.assign(o=>jsxRuntime.jsx(po,{id:e,...o}),{docxMenu:e})}var Gs=Vs("file"),Ys=Vs("format"),js=Vs("insert");function _y({className:e,hidden:t,onSelect:o}){let{setOpenMenu:n,onReportIssue:r,reportIssue:i}=at(),a=De();if(t||i===false)return null;let l=o??r??Tr;return jsxRuntime.jsx(ke,{slot:"help.reportIssue",onSelect:()=>{l(),n(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var ii=Object.assign(_y,{docxSlot:"help.reportIssue"});function Ny({children:e,...t}){let{reportIssue:o}=at();return e===void 0&&o===false?null:jsxRuntime.jsxs(po,{id:"help",...t,children:[jsxRuntime.jsx(ii,{}),e]})}var Xs=Object.assign(Ny,{docxMenu:"help"});var li=pt.createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function mo(){return pt.useContext(li)}function Hp(){return pt.useContext(li).target}var Op=["M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-560l-80-80 240-240h120v40L600-560ZM240-640q33 0 56.5-23.5T320-720q0-33-23.5-56.5T240-800q-33 0-56.5 23.5T160-720q0 33 23.5 56.5T240-640Zm240 180q8 0 14-6t6-14q0-8-6-14t-14-6q-8 0-14 6t-6 14q0 8 6 14t14 6Zm-240 300q33 0 56.5-23.5T320-240q0-33-23.5-56.5T240-320q-33 0-56.5 23.5T160-240q0 33 23.5 56.5T240-160Z"],Bp=["M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"],Qs=["M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h168q13-36 43.5-58t68.5-22q38 0 68.5 22t43.5 58h168q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"],Zp=["M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z"],qp=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],Kp=["M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"],Wp=["M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-120q-33 0-56.5-23.5T120-200h80v80Zm-80-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160q0-33 23.5-56.5T200-840v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z"];function _n(e,t,o){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:l,hidden:s})=>{let c=F(),{close:d}=mo(),f=De(),{isEnabled:u,disabledReason:g}=se(t);return s?null:jsxRuntime.jsx(ke,{slot:e,icon:r??oe(o.paths),shortcut:f(a??o.shortcutKey),disabled:!u,...g?{title:g}:{},onSelect:()=>{c?.exec(t),d(true);},...l?{className:l}:{},children:f(i??o.labelKey)})},{docxRow:e})}var Dr=_n("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:Op}),kr=_n("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:Bp}),Ir=_n("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:Zp}),_r=_n("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:Wp});function Nn({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=F(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=mo(),c=De(),d=pt.useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:f,disabledReason:u}=se(d);if(r)return null;let g=l!==null;return jsxRuntime.jsx(ke,{slot:"edit.paste",icon:e??oe(Qs),shortcut:c(o??"contextMenu.pasteShortcut"),disabled:!f||g,...l??u?{title:l??u??""}:{},onSelect:()=>{(async()=>{try{let{text:p,html:m}=await Ay();(p||m)&&i?.exec({type:"paste",text:p,...m?{html:m}:{}});}catch(p){s(p instanceof Error?p.message:"the clipboard is not readable");}finally{a(true);}})();},...n?{className:n}:{},children:c(t??"contextMenu.paste")})}Nn.docxRow="edit.paste";async function Ay(){let e=navigator.clipboard;if(typeof e.read=="function"&&typeof ClipboardItem<"u")try{let t=await e.read(),o="",n=null;for(let r of t)r.types.includes("text/plain")&&(o=await(await r.getType("text/plain")).text()),r.types.includes("text/html")&&(n=await(await r.getType("text/html")).text());if(o||n)return {text:o,html:n}}catch{}return {text:await e.readText(),html:null}}function Ln({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=F(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=mo(),c=De(),d=pt.useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:f,disabledReason:u}=se(d);if(r)return null;let g=l!==null;return jsxRuntime.jsx(ke,{slot:"edit.pasteWithoutFormatting",icon:e??oe(Qs),shortcut:c(o??"contextMenu.pasteWithoutFormattingShortcut"),disabled:!f||g,...l??u?{title:l??u??""}:{},onSelect:()=>{(async()=>{try{let p=await navigator.clipboard.readText();p&&i?.exec({type:"pasteWithoutFormatting",text:p});}catch(p){s(p instanceof Error?p.message:"the clipboard is not readable");}finally{a(true);}})();},...n?{className:n}:{},children:c(t??"contextMenu.pasteWithoutFormatting")})}Ln.docxRow="edit.pasteWithoutFormatting";var zp=Q("format.painter")?.paths??[],si=_n("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:zp}),ci=_n("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:zp});function qo(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l,destructive:s})=>{let{close:c}=mo(),d=De(),f=di(),{isEnabled:u,disabledReason:g,execute:p}=se(t);return l||!f?null:jsxRuntime.jsx(ke,{slot:e,icon:r??oe(o.paths),disabled:!u,...g?{title:g}:{},className:`${s??o.destructive?"docx-table-chrome__destructive-row":""}${a?` ${a}`:""}`,onSelect:()=>{p()&&c(true);},children:d(i??o.labelKey)})},{docxRow:e})}var Fn=qo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:editor.tableChromeIconPaths("table_rows")}),An=qo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:editor.tableChromeIconPaths("table_rows")}),Hn=qo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:editor.tableChromeIconPaths("view_column")}),On=qo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:editor.tableChromeIconPaths("view_column")}),Bn=qo("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:editor.tableChromeIconPaths("delete_sweep"),destructive:true}),Zn=qo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:editor.tableChromeIconPaths("view_column"),destructive:true}),qn=qo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:editor.tableChromeIconPaths("delete"),destructive:true}),Hy=[{alignment:"top",labelKey:"tableAdvanced.top",icon:"vertical_align_top"},{alignment:"center",labelKey:"tableAdvanced.middle",icon:"vertical_align_center"},{alignment:"bottom",labelKey:"tableAdvanced.bottom",icon:"vertical_align_bottom"}];function Ko({hidden:e}){let{close:t}=mo(),o=De(),n=di(),r=se({type:"setTableCellVerticalAlignment",alignment:"top"}),i=se({type:"setTableCellVerticalAlignment",alignment:"center"}),a=se({type:"setTableCellVerticalAlignment",alignment:"bottom"}),l=[r,i,a];return e||!n?null:jsxRuntime.jsxs("div",{className:"docx-contextmenu__table-align",children:[jsxRuntime.jsx("span",{className:"docx-contextmenu__table-align-label",children:o("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{className:"docx-contextmenu__table-align-buttons",role:"group","aria-label":o("tableAdvanced.verticalAlignment"),children:Hy.map((s,c)=>{let d=l[c];return jsxRuntime.jsx("button",{type:"button",role:"menuitemradio","aria-checked":false,"aria-label":o(s.labelKey),title:d.disabledReason??o(s.labelKey),"aria-disabled":!d.isEnabled,className:"docx-contextmenu__table-align-button",onMouseDown:f=>{f.preventDefault(),f.stopPropagation();},onClick:()=>{d.execute()&&t(true);},children:oe(editor.tableChromeIconPaths(s.icon))},s.alignment)})})]})}Ko.docxRow="table.cellVerticalAlignment";function Up(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l})=>{let s=F(),{close:c,tocId:d}=mo(),f=De(),u=pt.useMemo(()=>({type:"refreshToc",mode:t,...d?{tocId:d}:{}}),[d]),{isEnabled:g,disabledReason:p}=se(u);return l||d===null?null:jsxRuntime.jsx(ke,{slot:e,icon:r??oe(o.paths),disabled:!g,...p?{title:p}:{},onSelect:()=>{s?.exec(u),c(true);},...a?{className:a}:{},children:f(i??o.labelKey)})},{docxRow:e})}var Kn=Up("toc.refresh","entire",{labelKey:"toc.refresh",paths:qp}),Wn=Up("toc.refreshPageNumbers","pageNumbers",{labelKey:"toc.refreshPageNumbers",paths:Kp});function di(){return O(pt.useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function ui({label:e,icon:t,shortcut:o,disabled:n,disabledReason:r,active:i,onSelect:a,className:l}){let{close:s}=mo();return jsxRuntime.jsx(ke,{...t?{icon:t}:{},...o?{shortcut:o}:{},...n?{disabled:n}:{},...n&&r?{title:r}:{},...i!==void 0?{active:i}:{},onSelect:()=>{a?.(),s(true);},...l?{className:l}:{},children:e})}var Wo=pt.createContext(false);function dt(){return pt.useContext(Wo)?"":"docx-editor "}var fi=8,Wy=e=>e.editingMode==="viewing";function zy(){let e=F(),t=pt.useContext(Ct),o=at(),n=De(),r=e?.can({type:"toggleReviewPane"}),i=O(Wy),a=!r?.ok||i||(t?.mounted??0)===0||e?.getSelectionPlacement()===null,l=Q("review.comments");return jsxRuntime.jsx(ke,{icon:oe(l?.paths),slot:"review.comments",disabled:a,title:r&&!r.ok?r.reason:i?n("editingMode.viewingHint"):void 0,onSelect:()=>{t?.requestCommentDraft()&&o.setOpenMenu(null);},children:n("comments.addComment")})}function Uy(){let e=F(),t=at(),o=De();return e?.can({type:"editTextFormField"}).ok?jsxRuntime.jsx(ke,{slot:"field.edit",onSelect:()=>{t.setOpenMenu(null),e.exec({type:"editTextFormField"});},children:o("textFormField.edit")}):null}var $y=[{kind:"row",id:"field.edit",render:()=>jsxRuntime.jsx(Uy,{})},{kind:"row",id:"edit.cut",render:()=>jsxRuntime.jsx(Dr,{})},{kind:"row",id:"edit.copy",render:()=>jsxRuntime.jsx(kr,{})},{kind:"row",id:"edit.paste",render:()=>jsxRuntime.jsx(Nn,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsxRuntime.jsx(Ln,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsxRuntime.jsx(si,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsxRuntime.jsx(ci,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsxRuntime.jsx(Ir,{})},{kind:"row",id:"edit.selectAll",render:()=>jsxRuntime.jsx(_r,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsxRuntime.jsx(Yt,{slot:"text.link",labelKey:"formattingBar.insertLink"})},{kind:"row",id:"review.comments",render:()=>jsxRuntime.jsx(zy,{})}];function Vy(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Fn.docxRow,render:()=>jsxRuntime.jsx(Fn,{})},{kind:"row",id:An.docxRow,render:()=>jsxRuntime.jsx(An,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:Hn.docxRow,render:()=>jsxRuntime.jsx(Hn,{})},{kind:"row",id:On.docxRow,render:()=>jsxRuntime.jsx(On,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:Bn.docxRow,render:()=>jsxRuntime.jsx(Bn,{})},{kind:"row",id:Zn.docxRow,render:()=>jsxRuntime.jsx(Zn,{})},{kind:"row",id:qn.docxRow,render:()=>jsxRuntime.jsx(qn,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:Ko.docxRow,render:()=>jsxRuntime.jsx(Ko,{})}]}function Gy(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:Kn.docxRow,render:()=>jsxRuntime.jsx(Kn,{})},{kind:"row",id:Wn.docxRow,render:()=>jsxRuntime.jsx(Wn,{})}]}function Yy(e,t=false){return [...$y,...e?Vy():[],...t?Gy():[]]}function jp(e){if(!pt.isValidElement(e))return null;let t=kn(e,jp);if(t!==null)return t;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxRow=="string")return o.docxRow;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxMenuRow===true){let n=e.props.slot;if(typeof n=="string")return n}return null}function Gp(e){if(!pt.isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function jy(e){return e?.closest(".docx-editor__scroll-container")??null}function Lr({className:e,t,preset:o=true,disabled:n,onOpenChange:r,children:i}){let a=dt(),l=F(),{t:s}=L(),c=di(),d=pt.useRef(null),f=pt.useRef(null),[u,g]=pt.useState(null),[p,m]=pt.useState(null),[b,v]=pt.useState(null),x=pt.useMemo(()=>Yy(c,p!==null),[c,p]),[h,y]=pt.useState(null),T=pt.useCallback((H=false)=>{g(null),y(null),m(null),v(null),H&&l?.focus();},[l]);pt.useEffect(()=>{if(n)return;let H=jy(d.current);if(!H)return;let N=_=>{_.preventDefault();let P=_.button===-1||_.clientX===0&&_.clientY===0,k=H.getBoundingClientRect();m(l?.snapshot().tocContext?.id??null),v(P||!(_.target instanceof HTMLElement)?null:_.target),g(P?{x:k.left+16,y:k.top+16}:{x:_.clientX,y:_.clientY});};return H.addEventListener("contextmenu",N),()=>H.removeEventListener("contextmenu",N)},[n,l]),pt.useEffect(()=>{n&&T();},[n,T]),pt.useEffect(()=>{if(!u)return;let H=P=>{f.current?.contains(P.target)||T();},N=P=>{P.key==="Escape"?(P.preventDefault(),T(true)):P.key==="Tab"&&T();},_=()=>T();return document.addEventListener("pointerdown",H,true),document.addEventListener("keydown",N),document.addEventListener("scroll",_,{capture:true,passive:true}),window.addEventListener("blur",_),window.addEventListener("resize",_),()=>{document.removeEventListener("pointerdown",H,true),document.removeEventListener("keydown",N),document.removeEventListener("scroll",_,true),window.removeEventListener("blur",_),window.removeEventListener("resize",_);}},[u,T]),pt.useLayoutEffect(()=>{let H=f.current;if(!u||!H)return;let{width:N,height:_}=H.getBoundingClientRect(),P=window.innerWidth-N-fi,k=window.innerHeight-_-fi,j=Math.max(fi,u.x>P?u.x-N:u.x),W=Math.max(fi,u.y>k?u.y-_:u.y);y({x:j,y:W});},[u]),pt.useLayoutEffect(()=>{h&&f.current?.focus({preventScroll:true});},[h]);let C=pt.useRef(r);C.current=r;let E=pt.useRef(false);pt.useEffect(()=>{let H=u!==null;H!==E.current&&(E.current=H,C.current?.(H));},[u]);let S=pt.useMemo(()=>({t,openMenu:null,setOpenMenu:()=>T(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,T]),[D,R]=pt.useState(null),w=pt.useMemo(()=>({close:T,anchor:u,tocId:p,target:b,clipboardRefusal:D,reportClipboardRefusal:R}),[T,u,p,b,D]),I={position:"fixed",left:(h??u)?.x??0,top:(h??u)?.y??0,visibility:h?"visible":"hidden"};return jsxRuntime.jsx("div",{ref:d,style:{display:"contents"},children:u?jsxRuntime.jsx(Cr.Provider,{value:S,children:jsxRuntime.jsx(li.Provider,{value:w,children:jsxRuntime.jsxs("div",{ref:f,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??s("contextMenu.ariaLabel"),tabIndex:-1,className:`${a}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,style:I,onKeyDown:H=>{let N=f.current;if(!N)return;let _=Oo(N);H.key==="ArrowDown"?(H.preventDefault(),St(_,document.activeElement,1)):H.key==="ArrowUp"?(H.preventDefault(),St(_,document.activeElement,-1)):H.key==="Home"?(H.preventDefault(),Pt(_,"first")):H.key==="End"&&(H.preventDefault(),Pt(_,"last"));},children:[pt.Children.toArray(i).filter(Gp),ei({entries:x,children:pt.Children.toArray(i).filter(H=>!Gp(H)),preset:o,keyOfEntry:H=>H.id,keyOfChild:jp,renderEntry:H=>H.kind==="separator"?jsxRuntime.jsx(Zo,{}):H.render()})]})})}):null})}var tc=Object.assign(Lr,{Cut:Dr,Copy:kr,Paste:Nn,PasteWithoutFormatting:Ln,Delete:Ir,SelectAll:_r,InsertRowAbove:Fn,InsertRowBelow:An,InsertColumnLeft:Hn,InsertColumnRight:On,DeleteTableRow:Bn,DeleteTableColumn:Zn,DeleteTable:qn,CellVerticalAlignment:Ko,RefreshToc:Kn,RefreshTocPageNumbers:Wn,Item:ui,Slot:Yt,Row:ke,Group:Mr,Separator:Zo,Submenu:Ft});var Xp=pt.createContext(void 0),Qp=Xp.Provider,Xt=()=>pt.useContext(Xp);function Jp(){let e=Xt(),{t}=L();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e?.hyperlink&&Fe(e.hyperlink,{}),e?.contentControl&&Fe(e.contentControl,{}),e?.equation&&Fe(e.equation,{}),e?.contextMenu&&Fe(e.contextMenu,{t:o=>t(o)})]})}function em(e,t,o,n){return {...e,hyperlink:e?.hyperlink??(t===false?false:r=>jsxRuntime.jsx(br,{...r})),contentControl:e?.contentControl??(r=>jsxRuntime.jsx(yr,{...r})),equation:e?.equation??(()=>jsxRuntime.jsx(xr,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:r=>e.contextMenu&&Fe(e.contextMenu,{...r,t:n??r.t}):o===false?false:r=>jsxRuntime.jsx(Lr,{...r,t:n??r.t,...typeof o=="object"?o:{}})}}function ox(e,t){return e===t?true:!e||!t||e.kind!==t.kind?false:e.kind==="note"&&t.kind==="note"?e.id===t.id:e.kind==="headerFooter"&&t.kind==="headerFooter"?e.rId===t.rId:true}function oc(){let e=F(),t=pt.useCallback(n=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),o=O(t,ox);return o?.kind==="note"?o:null}function tm(e,t){return e===t?true:!e||!t?false:e.pos===t.pos&&e.numFmt===t.numFmt&&e.numStart===t.numStart&&e.numRestart===t.numRestart}function om(e,t){return e.resolved.pos===t.resolved.pos&&e.resolved.numFmt===t.resolved.numFmt&&e.resolved.numStart===t.resolved.numStart&&e.resolved.numRestart===t.resolved.numRestart&&tm(e.documentAuthored,t.documentAuthored)&&tm(e.sectionAuthored,t.sectionAuthored)}function nx(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&om(e.footnote,t.footnote)&&om(e.endnote,t.endnote)}function nc(){let e=F(),t=pt.useCallback(o=>e?.getNotePropertiesState()??null,[e]);return O(t,nx)}function Fr(e,t){let[o,n]=pt.useState(null),r=pt.useCallback(l=>n(l),[]),[i,a]=pt.useState({visibility:"hidden"});return pt.useLayoutEffect(()=>{let l=o?.closest(".docx-editor__scroll-container"),s=l??o?.parentElement?.querySelector(".docx-editor__scroll-container");if(!o||!s)return;let c=0,d=null,f=new ResizeObserver(()=>g()),u=()=>{c=0;let m=e(s);if(m!==d&&(f.disconnect(),f.observe(s),f.observe(o),m&&f.observe(m),d=m),!m||!m.isConnected){a({visibility:"hidden"});return}let b=m.getBoundingClientRect(),v=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,x=t==="story-label"?6:4,h=l===s,y=t==="after"?b.bottom+6:b.top-v-x,T=h?wn(s,b.left,y):{left:b.left,top:y},C=T.left,E=T.top,S=h?s.scrollLeft+8:8;a({position:h?"absolute":"fixed",left:t==="story-label"?C:Math.max(S,C+8),top:t==="story-label"?E:Math.max(h?s.scrollTop+8:8,E),...t==="story-label"?{width:Math.max(240,Math.min(b.width,s.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(b.width-16,s.clientWidth-16))},visibility:"visible"});},g=()=>{c||(c=requestAnimationFrame(u));};f.observe(s),f.observe(o);let p=new MutationObserver(g);return p.observe(s,{subtree:true,childList:true,attributes:true,attributeFilter:["data-docx-hf-active","data-docx-note-scope"]}),s.addEventListener("scroll",g,{passive:true}),window.addEventListener("resize",g),u(),()=>{c&&cancelAnimationFrame(c),f.disconnect(),p.disconnect(),s.removeEventListener("scroll",g),window.removeEventListener("resize",g);}},[o,e,t]),{ref:r,style:i}}var ix=/^(footnote|endnote):(-?\d{1,10})$/;function am(e){let t=ix.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function lx(){return typeof window>"u"?false:window.matchMedia("(pointer: coarse)").matches}function ac(e){let t=F();return pt.useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let o=t.can(e);return o.ok?{enabled:true,reason:null}:{enabled:false,reason:o.reason}},[t,e])}function sx(e){let{t}=L(),[o,n]=pt.useState(false),r=pt.useRef(null);return pt.useEffect(()=>{if(!o)return;let i=a=>{r.current?.contains(a.target)||n(false);};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[o]),jsxRuntime.jsxs("div",{ref:r,className:"docx-hf-chrome__options",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-context-bar__options-trigger","data-testid":"docx-notes-options","aria-expanded":o,"aria-haspopup":"menu",onMouseDown:Z,onClick:()=>n(i=>!i),children:t("headerFooter.options")}),o?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:Z,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-properties",onClick:()=>{e.onOpenProperties(),n(false);},children:t("dialogs.footnoteProperties.title")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-close",onClick:()=>{e.onClose(),n(false);},children:t("common.close")})]}):null]})}function hi({className:e}){let t=Xt(),o=pt.useRef(null),{t:n}=L(),r=F(),i=oc(),[a,l]=pt.useState(null),[s,c]=pt.useState(null),[d,f]=pt.useState(false),u=pt.useRef(null),g=pt.useCallback(I=>{if(!i)return null;let N=[...I.querySelectorAll("[data-docx-note-scope]")].find(_=>_.matches("[data-docx-note]")&&_.dataset.docxNoteScope===i.id)??null;return N?.closest("[data-docx-notes]")??N},[i]),p=Fr(g,"story-label"),m=pt.useCallback(()=>{u.current&&clearTimeout(u.current),u.current=null,l(null);},[]);pt.useEffect(()=>{if(!r)return;let I=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!I)return;let H=P=>{let k=P.target;if(!k)return;let j=k.closest("[data-docx-note-ref]");if(j?.dataset.docxNoteScope){P.preventDefault(),m(),c(null),r.setActiveScope({kind:"note",id:j.dataset.docxNoteScope});return}k.closest("[data-docx-note-mark-back]")&&(P.preventDefault(),m(),c(null),r.setActiveScope({kind:"body"}));},N=P=>{let k=P,W=k.target?.closest("[data-docx-note-scope]");W?.dataset.docxNoteScope&&(k.preventDefault(),c({scopeId:W.dataset.docxNoteScope,x:k.clientX,y:k.clientY}));},_=P=>{if(lx())return;let j=P.target?.closest("[data-docx-note-ref]");if(!j?.dataset.docxNoteScope){m();return}let W=j.dataset.docxNoteScope,z=r.getNotePreviewText(W)??j.getAttribute("aria-description")??n("notes.previewFallback"),te=j.getBoundingClientRect();u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l({scopeId:W,text:z,x:te.left,y:te.bottom+4});},400);};return I.addEventListener("click",H),I.addEventListener("contextmenu",N),I.addEventListener("pointerover",_),I.addEventListener("scroll",m,true),()=>{I.removeEventListener("click",H),I.removeEventListener("contextmenu",N),I.removeEventListener("pointerover",_),I.removeEventListener("scroll",m,true),m();}},[r,m,n]);let b=pt.useCallback(I=>{r&&(r.exec(I),c(null));},[r]),v=s?am(s.scopeId):null,x=pt.useMemo(()=>v?{type:"deleteNote",noteKind:v.noteKind,noteId:v.noteId}:null,[v]),h=pt.useMemo(()=>v?{type:"convertNote",fromKind:v.noteKind,noteId:v.noteId}:null,[v]),y=pt.useMemo(()=>v?{type:"convertAllNotes",fromKind:v.noteKind}:null,[v]),T=ac(x??{type:"deleteNote",noteKind:"footnote",noteId:0}),C=ac(h??{type:"convertNote",fromKind:"footnote",noteId:0}),E=ac(y??{type:"convertAllNotes",fromKind:"footnote"}),S=i?am(i.id):null,D=S?n("notes.editingRegion",{kind:S.noteKind==="footnote"?n("notes.footnoteKind"):n("notes.endnoteKind"),number:S.noteId}):null,R=s&&v?{...s,...v,onDelete:()=>{x&&b(x);},onConvert:()=>{h&&b(h);},onConvertAll:()=>{y&&b(y);},onOpenProperties:()=>f(true),onClose:()=>c(null),deleteEnabled:T.enabled,convertEnabled:C.enabled,convertAllEnabled:E.enabled,deleteDisabledReason:T.reason??void 0,convertDisabledReason:C.reason??void 0,convertAllDisabledReason:E.reason??void 0}:null,w={onClose:()=>f(false),onApply:I=>{b(I),f(false);}};return r?jsxRuntime.jsxs("div",{className:e,ref:o,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":i?void 0:true,children:[i&&S?jsxRuntime.jsxs("div",{ref:p.ref,className:"docx-context-bar docx-notes-chrome__banner",role:"region","aria-label":n("notes.chromeAriaLabel"),"data-testid":"docx-notes-banner","data-note-scope":i.id,style:{...p.style,zIndex:ot.chrome},children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:D}),jsxRuntime.jsx(sx,{onOpenProperties:()=>f(true),onClose:()=>r.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Fe(t.notePreview,a):jsxRuntime.jsx(Pn,{...a}):null,R&&t?.notesContextMenu!==false?t?.notesContextMenu?Fe(t.notesContextMenu,R):jsxRuntime.jsx(En,{...R}):null,d&&t?.noteProperties!==false?t?.noteProperties?Fe(t.noteProperties,w):jsxRuntime.jsx(vi,{...w}):null]}):null}function vi(e){let{t}=L(),o=F(),n=nc(),[r,i]=pt.useState("document"),[a,l]=pt.useState("decimal"),[s,c]=pt.useState("continuous"),[d,f]=pt.useState("pageBottom"),[u,g]=pt.useState("decimal"),[p,m]=pt.useState("continuous"),[b,v]=pt.useState("docEnd");pt.useEffect(()=>{n&&(l(n.footnote.resolved.numFmt),c(n.footnote.resolved.numRestart),f(n.footnote.resolved.pos),g(n.endnote.resolved.numFmt),m(n.endnote.resolved.numRestart),v(n.endnote.resolved.pos));},[n]);let x=!n?.footnote.documentAuthored&&!n?.footnote.sectionAuthored,h=!n?.endnote.documentAuthored&&!n?.endnote.sectionAuthored;return jsxRuntime.jsx("div",{className:"docx-note-properties",role:"dialog","aria-modal":"true","aria-label":t("dialogs.footnoteProperties.title"),"data-testid":"docx-notes-properties-dialog",style:{zIndex:ot.modal},onClick:e.onClose,onKeyDown:y=>{y.key==="Escape"&&e.onClose();},children:jsxRuntime.jsxs("div",{className:"docx-note-properties__panel",onClick:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),children:[jsxRuntime.jsx("h2",{className:"docx-note-properties__title",children:t("dialogs.footnoteProperties.title")}),jsxRuntime.jsxs("div",{className:"docx-note-properties__body",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__scope",children:[jsxRuntime.jsx("span",{children:t("notes.scope")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:r,onChange:y=>i(y.target.value),children:[jsxRuntime.jsx("option",{value:"document",children:t("notes.scopeDocument")}),jsxRuntime.jsx("option",{value:"section",children:t("notes.scopeSection")})]})]}),jsxRuntime.jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxRuntime.jsxs("legend",{className:"docx-note-properties__legend",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.footnotes")}),x?jsxRuntime.jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__fields",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:a,onChange:y=>l(y.target.value),children:[jsxRuntime.jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsxRuntime.jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsxRuntime.jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:s,onChange:y=>c(y.target.value),children:[jsxRuntime.jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsxRuntime.jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsxRuntime.jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:d,onChange:y=>f(y.target.value),children:[jsxRuntime.jsx("option",{value:"pageBottom",children:t("dialogs.footnoteProperties.footnotePositions.bottomOfPage")}),jsxRuntime.jsx("option",{value:"beneathText",children:t("dialogs.footnoteProperties.footnotePositions.belowText")})]})]})]})]}),jsxRuntime.jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxRuntime.jsxs("legend",{className:"docx-note-properties__legend",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.endnotes")}),h?jsxRuntime.jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__fields",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:u,onChange:y=>g(y.target.value),children:[jsxRuntime.jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsxRuntime.jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsxRuntime.jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:p,onChange:y=>m(y.target.value),children:[jsxRuntime.jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsxRuntime.jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsxRuntime.jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:b,"data-testid":"docx-notes-endnote-position",onChange:y=>v(y.target.value),children:[jsxRuntime.jsx("option",{value:"docEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfDocument")}),jsxRuntime.jsx("option",{value:"sectEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfSection")})]})]})]})]})]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__footer",children:[jsxRuntime.jsx("button",{className:"docx-note-properties__button",type:"button",onClick:e.onClose,children:t("common.cancel")}),jsxRuntime.jsx("button",{className:"docx-note-properties__button docx-note-properties__button--primary",type:"button","data-testid":"docx-notes-properties-apply",onClick:()=>{if(!o)return;let y={type:"setNoteProperties",scope:r,sectionIndex:r==="section"?n?.sectionIndex:void 0,footnote:{numFmt:a,numRestart:s,position:d},endnote:{numFmt:u,numRestart:p,position:b}};o.can(y).ok&&e.onApply(y);},children:t("common.apply")})]})]})})}var sm=e=>e.image;function lm(e){return Array.from(e.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(t=>t.offsetParent!==null||t===document.activeElement)}function gx(e){e&&!e.closest(".docx-editor")&&e.classList.add("docx-editor");}function bx(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function uc(e){let t=e.position;return !t||e.kind!=="anchored"?{positionMode:"frame",horizontalPoints:"",verticalPoints:"",relativeToH:"page",relativeToV:"line"}:t.mode==="simple"?{positionMode:"simple",horizontalPoints:t.horizontalEmu!==void 0?String(co(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(co(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(co(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(co(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function hx(e,t){let o=uc(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function yi(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=Sr(t);return Number.isInteger(o)?o:null}function vx(e,t){let o=uc(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,f=c?yi(e.horizontalPoints):t.position?.horizontalEmu,u=d?yi(e.verticalPoints):t.position?.verticalEmu;return c&&f===null?{ok:false}:d&&u===null?{ok:false}:f===void 0||u===void 0?{ok:false}:{ok:true,value:{horizontalEmu:f,verticalEmu:u}}}let n=e.horizontalPoints!==o.horizontalPoints,r=e.verticalPoints!==o.verticalPoints,i=e.relativeToH!==o.relativeToH,a=e.relativeToV!==o.relativeToV,l=n?yi(e.horizontalPoints):t.position?.horizontalEmu,s=r?yi(e.verticalPoints):t.position?.verticalEmu;return n&&l===null?{ok:false}:r&&s===null?{ok:false}:{ok:true,value:{...typeof l=="number"?{horizontalEmu:l}:{},...typeof s=="number"?{verticalEmu:s}:{},...i||n||r?{relativeToH:e.relativeToH}:{},...a||n||r?{relativeToV:e.relativeToV}:{}}}}function xi(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function Ci(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function Hr({open:e,onClose:t,className:o,triggerRef:n}){let r=F(),{t:i}=L(),a=O(sm),l=pt.useId(),s=pt.useId(),c=pt.useId(),d=pt.useRef(null),f=pt.useRef(null),u=pt.useRef(null),g=pt.useRef(null),[p,m]=pt.useState(null),[b,v]=pt.useState(null),x=f.current,h=x?.canCrop===false,y=x?.canResize===false,T=x?.locks.changeAspect===true,C=x?.kind==="anchored"&&x.canMove===true,E=x?.kind==="inline",S=x?.kind==="anchored"&&x.canMove===false;pt.useEffect(()=>{if(!e){f.current=null,u.current=null,g.current=null;return}if(!a)return;if(f.current=a,r?.surface){let{anchor:j}=r.surface.state().selection;u.current={paragraphId:j.paragraphId,offset:j.offset},g.current=r.surface.session.packageRevision();}v(null);let P=uc(a),k=a.crop;m({widthPoints:String(co(a.widthEmu)),heightPoints:String(co(a.heightEmu)),cropLeft:String(k.left),cropTop:String(k.top),cropRight:String(k.right),cropBottom:String(k.bottom),title:a.title,description:a.description,hyperlink:a.hyperlink??"",wrap:a.wrap,lockAspect:a.locks.changeAspect,...P});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let D=pt.useCallback(()=>{n?.current?.focus(),r?.focus();},[r,n]),R=pt.useCallback(()=>{t(),D();},[t,D]);pt.useEffect(()=>{if(!e)return;let P=d.current;if(!P)return;let k=lm(P);(k.find(re=>re.id==="image-prop-width"&&!re.hasAttribute("disabled"))??k.find(re=>!re.hasAttribute("disabled"))??P).focus();let W=re=>{if(re.key==="Escape"){re.preventDefault(),R();return}if(re.key!=="Tab")return;let z=lm(P);if(z.length===0)return;let te=document.activeElement,B=z.findIndex(de=>de===te);if(B===-1)return;re.preventDefault();let J=re.shiftKey?(B-1+z.length)%z.length:(B+1)%z.length;z[J]?.focus();};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[e,R]);let w=pt.useMemo(()=>{let P=x??a;return !P||P.widthEmu<=0?1:P.widthEmu/P.heightEmu},[a,x]),I=pt.useCallback(P=>{m(k=>{if(!k)return k;if(!k.lockAspect)return {...k,widthPoints:P};let j=Ci(P);if(j===null)return {...k,widthPoints:P};let W=Math.round(j/w*100)/100;return {...k,widthPoints:P,heightPoints:String(W)}});},[w]),H=pt.useCallback(P=>{m(k=>{if(!k)return k;if(!k.lockAspect)return {...k,heightPoints:P};let j=Ci(P);if(j===null)return {...k,heightPoints:P};let W=Math.round(j*w*100)/100;return {...k,widthPoints:String(W),heightPoints:P}});},[w]),N=pt.useCallback(()=>{let P=f.current;if(!P?.intrinsic)return;let k=P.intrinsic.pixelWidth*72/P.intrinsic.dpiX,j=P.intrinsic.pixelHeight*72/P.intrinsic.dpiY;m(W=>W&&{...W,widthPoints:String(Math.round(k*100)/100),heightPoints:String(Math.round(j*100)/100)});},[a]),_=pt.useCallback(()=>{let P=f.current,k=u.current,j=g.current;if(!r||!P||!p||!k||j===null)return;let W={type:"setImageProperties",drawingNodeId:P.id,expectedPackageRevision:j,selectionParagraphId:k.paragraphId,selectionOffset:k.offset};if(!y){let de=Ci(p.widthPoints),V=Ci(p.heightPoints);if(de===null||V===null){v("imageProperties.errors.invalidDimensions");return}let q=Sr(de),Re=Sr(V);q!==P.widthEmu&&(W.widthEmu=q),Re!==P.heightEmu&&(W.heightEmu=Re);}if(P.canCrop&&!h){let de=xi(p.cropLeft),V=xi(p.cropTop),q=xi(p.cropRight),Re=xi(p.cropBottom);if(de===null||V===null||q===null||Re===null){v("imageProperties.errors.invalidCrop");return}let je=P.crop;(de!==je.left||V!==je.top||q!==je.right||Re!==je.bottom)&&(W.crop={left:de,top:V,right:q,bottom:Re});}p.title!==P.title&&(W.title=p.title),p.description!==P.description&&(W.description=p.description);let re=p.hyperlink.trim();if(re!==(P.hyperlink??"")&&(W.hyperlink=re===""?null:re),P.canChangeWrap&&p.wrap!==P.wrap&&(W.wrap=p.wrap),P.kind==="anchored"&&P.canMove&&hx(p,P)){let de=vx(p,P);if(!de.ok){v("imageProperties.errors.invalidPosition");return}if(!editor.validateDrawingPositionInput(editor.positionInputFromPropertiesCommand(de.value,P))){v("imageProperties.errors.invalidPosition");return}Object.assign(W,de.value);}if(!(W.widthEmu!==void 0||W.heightEmu!==void 0||W.title!==void 0||W.description!==void 0||W.hyperlink!==void 0||W.crop!==void 0||W.wrap!==void 0||W.horizontalEmu!==void 0||W.verticalEmu!==void 0||W.relativeToH!==void 0||W.relativeToV!==void 0)){R();return}if(!r.can(W).ok){v("imageProperties.errors.refused");return}if(!r.exec(W).ok){v("imageProperties.errors.refused");return}R();},[r,p,h,y,R]);return !e||!p?null:jsxRuntime.jsx("div",{ref:gx,className:`docx-dialog-overlay${o?` ${o}`:""}`,onClick:R,onMouseDown:P=>{P.stopPropagation(),bx(P);},children:jsxRuntime.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-labelledby":l,className:"docx-dialog docx-image-properties-dialog",onClick:P=>P.stopPropagation(),onMouseDown:P=>P.stopPropagation(),children:[jsxRuntime.jsx("div",{id:l,className:"docx-dialog__header",children:i("dialogs.imageProperties.title")}),jsxRuntime.jsxs("div",{className:"docx-dialog__body",children:[b?jsxRuntime.jsx("p",{className:"docx-dialog__error",children:i(b)}):null,jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.dimensions")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-width",children:i("dialogs.imageProperties.widthLabel")}),jsxRuntime.jsx("input",{id:"image-prop-width",className:"docx-dialog__input",value:p.widthPoints,disabled:y,onChange:P=>I(P.target.value)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-height",children:i("dialogs.imageProperties.heightLabel")}),jsxRuntime.jsx("input",{id:"image-prop-height",className:"docx-dialog__input",value:p.heightPoints,disabled:y,onChange:P=>H(P.target.value)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:p.lockAspect,disabled:T,onChange:P=>m(k=>k&&{...k,lockAspect:P.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:h||!x?.intrinsic,onClick:N,children:i("imageProperties.resetNaturalSize")})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.position")}),E?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionUnavailable")}):null,S?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p.positionMode==="frame"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-h",children:i("imageProperties.relativeToHorizontal")}),jsxRuntime.jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:p.relativeToH??"page",onChange:P=>m(k=>k&&{...k,relativeToH:P.target.value}),children:editor.DRAWING_REL_FROM_H.map(P=>jsxRuntime.jsx("option",{value:P,children:i(`dialogs.imagePosition.relativeOptions.${P}`)},P))})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-v",children:i("imageProperties.relativeToVertical")}),jsxRuntime.jsx("select",{id:"image-pos-rel-v",className:"docx-dialog__select",value:p.relativeToV??"line",onChange:P=>m(k=>k&&{...k,relativeToV:P.target.value}),children:editor.DRAWING_REL_FROM_V.map(P=>jsxRuntime.jsx("option",{value:P,children:i(`dialogs.imagePosition.relativeOptions.${P}`)},P))})]})]}):null,jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-h",children:i("imageProperties.horizontalOffset")}),jsxRuntime.jsx("input",{id:"image-pos-h",className:"docx-dialog__input",value:p.horizontalPoints,onChange:P=>m(k=>k&&{...k,horizontalPoints:P.target.value})}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-v",children:i("imageProperties.verticalOffset")}),jsxRuntime.jsx("input",{id:"image-pos-v",className:"docx-dialog__input",value:p.verticalPoints,onChange:P=>m(k=>k&&{...k,verticalPoints:P.target.value})}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]})]}):null]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.altText")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-title",children:i("imageAltText.title")}),jsxRuntime.jsx("input",{id:"image-prop-title",className:"docx-dialog__input",value:p.title,onChange:P=>m(k=>k&&{...k,title:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-description",children:i("imageAltText.description")}),jsxRuntime.jsx("textarea",{id:"image-prop-description",className:"docx-dialog__textarea",value:p.description,onChange:P=>m(k=>k&&{...k,description:P.target.value}),placeholder:i("dialogs.imageProperties.altTextPlaceholder")})]})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.hyperlink")}),jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:c,children:i("hyperlinkPopup.urlLabel")}),jsxRuntime.jsx("input",{id:c,className:"docx-dialog__input docx-dialog__input--full",value:p.hyperlink,onChange:P=>m(k=>k&&{...k,hyperlink:P.target.value}),placeholder:i("hyperlinkPopup.urlPlaceholder")})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.textWrapping")}),jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:s,children:i("formattingBar.imageWrap")}),jsxRuntime.jsx("select",{id:s,className:"docx-dialog__select docx-dialog__input--full",value:p.wrap,disabled:x?.canChangeWrap===false,onChange:P=>m(k=>k&&{...k,wrap:P.target.value}),children:editor.IMAGE_WRAP_TARGETS.map(P=>jsxRuntime.jsx("option",{value:P,children:i(`imageWrap.targets.${P}`)},P))})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.crop")}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-left",children:i("imageProperties.cropLeft")}),jsxRuntime.jsx("input",{id:"image-crop-left",className:"docx-dialog__input",disabled:h,value:p.cropLeft,onChange:P=>m(k=>k&&{...k,cropLeft:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-top",children:i("imageProperties.cropTop")}),jsxRuntime.jsx("input",{id:"image-crop-top",className:"docx-dialog__input",disabled:h,value:p.cropTop,onChange:P=>m(k=>k&&{...k,cropTop:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-right",children:i("imageProperties.cropRight")}),jsxRuntime.jsx("input",{id:"image-crop-right",className:"docx-dialog__input",disabled:h,value:p.cropRight,onChange:P=>m(k=>k&&{...k,cropRight:P.target.value})})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-bottom",children:i("imageProperties.cropBottom")}),jsxRuntime.jsx("input",{id:"image-crop-bottom",className:"docx-dialog__input",disabled:h,value:p.cropBottom,onChange:P=>m(k=>k&&{...k,cropBottom:P.target.value})})]}),h?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.nonPictureHint")}):null]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:R,children:i("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:_,children:i("common.apply")})]})]})})}function Ti({className:e,hidden:t,asChild:o,children:n}){let r=Xt(),i=F(),{t:a}=L(),l=O(sm),[s,c]=pt.useState(false),d=pt.useRef(null),f={type:"setImageProperties",description:"probe"},u=i&&l?i.can(f):null,g=u?.ok===true,p=u&&!u.ok?u.reason:null;if(t)return null;let m=Q("image.properties"),b={type:"button",ref:d,className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!g,...g?{}:{"data-disabled":""},"aria-label":a("formattingBar.imagePropertiesShortcut"),title:p??a("formattingBar.imagePropertiesShortcut"),onMouseDown:Z,onClick:()=>c(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o?jsxRuntime.jsx(Y,{...b,children:n}):jsxRuntime.jsx("button",{...b,children:n??oe(m?.paths)}),s&&r?.imageProperties!==false?r?.imageProperties?Fe(r.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):jsxRuntime.jsx(Hr,{open:s,onClose:()=>c(false),triggerRef:d}):null]})}Ti.docxSlot="image.properties";var Un=Object.assign(Ti,{docxSlot:"image.properties"});function Or(e){let t=F(),o=pt.useCallback(()=>editor.toolbarCommandState(t,e),[t,e]),n=O(o,(r,i)=>r.value===i.value&&r.enabled===i.enabled&&r.disabledReason===i.disabledReason);return pt.useMemo(()=>({execute:(r,i)=>editor.runToolbarCommand(t,e,r,i),value:n.value===void 0?null:e==="font.size"||e==="list.lineSpacing"?Number(n.value):n.value,options:e==="image.wrap"?editor.IMAGE_WRAP_TARGETS:[],isEnabled:n.enabled,disabledReason:n.disabledReason}),[t,e,n])}function Si({className:e,hidden:t,asChild:o,children:n}){let r=Xt(),i=ee(),{execute:a,value:l,isEnabled:s,disabledReason:c}=Or("image.altText"),[d,f]=pt.useState(false),[u,g]=pt.useState(""),p=pt.useRef(null),m=pt.useRef(null),b=pt.useId();pt.useEffect(()=>{d&&g(l??"");},[d,l]),pt.useEffect(()=>{if(!d)return;let C=S=>{let D=p.current;S.target instanceof Node&&(D?.contains(S.target)||D?.ownerDocument.getElementById(b)?.contains(S.target))||f(false);},E=S=>{S.key==="Escape"&&(S.preventDefault(),f(false),m.current?.focus());};return document.addEventListener("mousedown",C,true),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",C,true),document.removeEventListener("keydown",E);}},[d,b]);let v=pt.useCallback(()=>{a(u),f(false);},[u,a]);if(t)return null;let x=Q("image.altText"),h=i(x?.labelKey??"formattingBar.altText"),y={type:"button",ref:m,className:`docx-toolbar__button docx-toolbar__alt-text-trigger${e?` ${e}`:""}`,"data-slot":"image.altText",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?b:void 0,"aria-label":h,title:c??h,onMouseDown:Z,onClick:()=>f(C=>!C)},T={id:b,value:u,onValueChange:g,onApply:v,onClose:()=>f(false),isEnabled:s,anchorRef:m};return jsxRuntime.jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsxRuntime.jsx(Y,{...y,children:n}):jsxRuntime.jsx("button",{...y,children:n??h}),d&&r?.imageAltText!==false?r?.imageAltText?Fe(r.imageAltText,T):jsxRuntime.jsx(Pi,{...T}):null]})}Si.docxSlot="image.altText";var Br=Object.assign(Si,{docxSlot:"image.altText"});function Pi({id:e,value:t,onValueChange:o,onApply:n,onClose:r,isEnabled:i,className:a}){let{t:l}=L();return jsxRuntime.jsxs("div",{id:e,role:"dialog","aria-label":l("imageAltText.panelTitle"),className:`docx-toolbar__alt-text-panel${a?` ${a}`:""}`,onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${e}-description`,children:l("imageAltText.description")}),jsxRuntime.jsx("textarea",{id:`${e}-description`,className:"docx-dialog__textarea",value:t,onChange:s=>o(s.target.value),placeholder:l("dialogs.imageProperties.altTextPlaceholder")}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:l("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",disabled:!i,onClick:n,children:l("common.apply")})]})]})}var pm=pt.createContext(void 0),mm=pm.Provider;function Ue(){let e=pt.useContext(pm),{t}=L();return pt.useCallback((o,n)=>{let r=e?.(o,n);return r===void 0||r===o?t(o,n):r},[e,t])}var bm=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function $n(){let e=pt.createContext(null),t=new Map,o=b=>{let v=t.get(b.type);return v==="field"?`field:${b.props.name}`:v};function n(b,v){pt.Children.forEach(b,x=>{pt.isValidElement(x)&&(v(x),n(x.props.children,v));});}function r(){let b=pt.useContext(e);if(!b)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return b.state}function i(b,v){return pt.Children.map(b,x=>{if(!pt.isValidElement(x))return x;let h=bm(x.props);return h&&v.has(h)?v.get(h):x.props.children===void 0?x:pt.cloneElement(x,{children:i(x.props.children,v)})})}function a(b){function v(x){let h=pt.useContext(e);if(!h||x.hidden)return null;let y=b==="field"?`field:${x.name}`:b,T=h.defaults.get(y);if(!T)return x.children??null;let{children:C,asChild:E,className:S,style:D,hidden:R,name:w,...I}=x,H={...I,...T.props,className:[T.props.className,S].filter(Boolean).join(" "),style:{...T.props.style,...D}};if(E){let{children:N,className:_,style:P,...k}=H;return jsxRuntime.jsx(Y,{...k,...S?{className:S}:{},...D?{style:D}:{},children:C})}return pt.cloneElement(T,H,C===void 0?i(T.props.children,h.overrides):C)}return t.set(v,b),v}let l=a("header"),s=a("title"),c=a("body"),d=a("footer"),f=a("apply"),u=a("cancel"),g=a("error"),p=a("field");function m({defaults:b,children:v,preset:x=true,state:h}){let y=new Map;n(b,S=>{let D=bm(S.props);D&&y.set(D,S);});let T=new Map;n(v,S=>{let D=o(S);D&&T.set(D,S);});let C=S=>pt.Children.toArray(S).flatMap(D=>pt.isValidElement(D)&&D.type===pt.Fragment?C(D.props.children):[D]),E=C(v).filter(S=>!pt.isValidElement(S)||!o(S));return jsxRuntime.jsx(e.Provider,{value:{defaults:y,overrides:T,state:h},children:x?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i(b,T),E]}):v})}return {Header:l,Title:s,Body:c,Footer:d,Apply:f,Cancel:u,Error:g,Field:p,Composition:m,useState:r}}function go({kind:e,role:t="dialog",className:o,style:n,label:r,onClose:i,onKeyDown:a,panelRef:l,children:s,dismissOutside:c=true,sessionSignal:d,restoreFocus:f=true}){let u=pt.useRef(null),g=l??u,p=pt.useRef(i);return p.current=i,pt.useLayoutEffect(()=>{let m=g.current;if(!m)return;m.parentElement?.closest(".docx-editor")||m.classList.add("docx-editor");let b=m.ownerDocument.activeElement,v=()=>{m.open&&m.close?.();};return d?.addEventListener("abort",v),typeof m.showModal=="function"?m.showModal():m.setAttribute("open",""),m.querySelector('input:not([disabled]),select:not([disabled]),button:not([disabled]),[tabindex="0"]')?.focus({preventScroll:true}),()=>{d?.removeEventListener("abort",v),typeof m.close=="function"&&m.open&&m.close(),f&&b?.isConnected&&b.focus({preventScroll:true});}},[g,d,f]),jsxRuntime.jsx("dialog",{ref:g,role:t,"aria-modal":"true","aria-label":r,className:`docx-dialog${o?` ${o}`:""}`,style:n,"data-docx-dialog":e,onCancel:m=>{m.preventDefault(),p.current();},onMouseDown:m=>m.stopPropagation(),onClick:m=>{if(c&&m.target===m.currentTarget){let b=m.currentTarget.getBoundingClientRect();(m.clientX<b.left||m.clientX>b.right||m.clientY<b.top||m.clientY>b.bottom)&&p.current();}m.stopPropagation();},onKeyDown:m=>{m.key==="Escape"&&!m.nativeEvent.isComposing?(m.preventDefault(),p.current()):editor.trapTabWithin(m.currentTarget,m.nativeEvent)?m.preventDefault():!m.nativeEvent.isComposing&&!m.defaultPrevented&&a?.(m),m.stopPropagation();},children:s})}function wi(e,t){let o=F(),n=bc(),r=pt.useRef(null);return pt.useEffect(()=>{if(!e){r.current=null;return}o?.surface&&(r.current===null?r.current=o.mountGeneration:r.current!==o.mountGeneration&&t());},[e,o,n,t]),()=>!!o?.surface&&r.current===o.mountGeneration}function bc(){let e=F(),t=pt.useCallback(o=>{if(!e)return ()=>{};let n=true,r=pr(()=>{n&&o();}),i=[e.on("change",r),e.on("selectionChange",r),e.on("error",r)];return ()=>{n=false,i.forEach(a=>a());}},[e]);return pt.useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function vc(e){let[t,o]=pt.useState(e.session),[n,r]=pt.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(Zx,{...e},n)}function Zx({session:e,className:t,style:o,children:n}){let r=Ue(),[i,a]=pt.useState(e.signal.aborted),l=pt.useRef(null);return pt.useEffect(()=>{let s=()=>a(true);return e.signal.addEventListener("abort",s,{once:true}),e.signal.aborted&&s(),()=>e.signal.removeEventListener("abort",s)},[e]),i?null:jsxRuntime.jsx(go,{kind:"invalidTextFormField",role:"alertdialog",label:r("textFormField.invalidTitle"),className:t,style:o,panelRef:l,dismissOutside:false,onClose:e.acknowledge,sessionSignal:e.signal,restoreFocus:false,onKeyDown:s=>{s.key==="Enter"&&!s.nativeEvent.isComposing&&(s.preventDefault(),e.acknowledge());},children:n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:r("textFormField.invalidTitle")})}),jsxRuntime.jsx("div",{className:"docx-dialog__body",children:r(e.type==="number"?"textFormField.invalidNumber":"textFormField.invalidDate")}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:e.acknowledge,children:r("textFormField.apply")})})]})})}var ym=pt.createContext(null),xm=ym.Provider;function $e(){let e=pt.useContext(ym);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function Qx(e){return e.kind==="date"?editor.parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function Cm(e){let t=`docx-cc-list-${pt.useId()}`,[o,n]=pt.useState(()=>Qx(e)),[r,i]=pt.useState(()=>editor.calendarDateText(e.value,e.locale)),a=pt.useMemo(()=>editor.createContentControlListNavigation(e.locale),[e]),[l,s]=pt.useState(false),c=pt.useCallback(w=>{i(w),s(false);},[]),d=O(()=>e.canApply()),f=e.kind==="date"?editor.parseIsoDate(e.value):null,[u,g]=pt.useState(()=>{let w=f??new Date;return {year:w.getFullYear(),month:w.getMonth()}}),p=pt.useCallback(w=>{let I=e.apply(w??o);return s(!I),I},[e,o]),m=pt.useCallback(()=>e.cancel(),[e]),b=pt.useCallback(async w=>{if(!e.replaceImage)return s(true),false;try{let I=w instanceof Uint8Array?w.byteLength:w.size;if(!e.canApply()||I>store.DEFAULT_IMAGE_RESOURCE_LIMITS.maxEncodedBytes)return s(!0),!1;let H=w instanceof Uint8Array?w:new Uint8Array(await w.arrayBuffer()),N=await e.replaceImage(H);return s(!N),N}catch{return s(true),false}},[e]),v=pt.useMemo(()=>editor.calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),x=pt.useCallback(()=>{g(w=>editor.shiftMonth(w.year,w.month,-1)),E(null);},[]),h=pt.useCallback(()=>{g(w=>editor.shiftMonth(w.year,w.month,1)),E(null);},[]),y=pt.useCallback(w=>p(w),[p]),T=pt.useCallback(()=>p(editor.isoDateOf(new Date)),[p]),[C,E]=pt.useState(null),S=pt.useCallback(w=>{let I=editor.parseIsoDate(w);I&&(g({year:I.getFullYear(),month:I.getMonth()}),E(editor.isoDateOf(I)));},[]),D=pt.useCallback(()=>{let w=editor.calendarDateFromText(r,e.locale);return w?p(w):(s(true),false)},[r,e.locale,p]),R=pt.useCallback((w,I)=>{!Number.isInteger(w)||w<100||w>9999||!Number.isInteger(I)||I<0||I>11||(g({year:w,month:I}),E(null));},[]);return pt.useMemo(()=>({session:e,kind:e.kind,items:e.items,value:o,setValue:n,isEnabled:d,refused:l,apply:p,cancel:m,calendar:v,previousMonth:x,nextMonth:h,selectDay:y,selectToday:T,focusIso:C,focusDay:S,dateText:r,setDateText:c,applyDateText:D,showMonth:R,listNavigation:a,listId:t,accept:editor.CONTENT_CONTROL_PICTURE_ACCEPT,replaceImage:b}),[e,b,o,d,l,p,m,v,x,h,y,T,C,S,r,c,D,R,a,t])}function Be(e,t,o,n){if(t.hidden)return null;let{children:r,asChild:i,className:a,style:l,hidden:s,id:c,title:d,"aria-label":f,...u}=t,g=r===void 0?n:r,{key:p,...m}=o,b={...c!==void 0?{id:c}:{},...d!==void 0?{title:d}:{},...f!==void 0?{"aria-label":f}:{}};if(i){let{className:x,style:h,...y}=m;return jsxRuntime.jsx(Y,{...u,...y,...b,...a?{className:a}:{},style:{...h,...l},children:g},p)}return jsxRuntime.jsx(e,{...u,...m,...b,className:[o.className,a].filter(Boolean).join(" "),style:{...o.style,...l},children:g},p)}var $o=e=>e.stopPropagation();function Tc(e){return Be("div",e,{className:"docx-content-control-calendar-header","data-docx-part":"header"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Sc,{}),jsxRuntime.jsx(Nc,{}),jsxRuntime.jsx(Pc,{}),jsxRuntime.jsx(Ec,{className:"docx-content-control-calendar-announcement"})]}))}function Sc(e){let t=$e(),o=Ue();return Be("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"previousMonth","aria-label":o("contentControl.calendar.previousMonth"),onMouseDown:$o,onClick:t.previousMonth},"\u2039")}function Pc(e){let t=$e(),o=Ue();return Be("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"nextMonth","aria-label":o("contentControl.calendar.nextMonth"),onMouseDown:$o,onClick:t.nextMonth},"\u203A")}function Ec(e){let t=$e();return Be("div",e,{className:"docx-content-control-calendar-title","data-docx-part":"title","aria-live":"polite"},t.calendar.title)}function wc(e){let t=$e();return Be("div",e,{className:"docx-content-control-calendar-weekdays","data-docx-part":"weekdays"},t.calendar.weekdays.map((o,n)=>jsxRuntime.jsx("span",{children:o},n)))}function Mc({day:e,...t}){let o=$e(),n=o.calendar.days.find(i=>i.iso===o.focusIso)??o.calendar.days.find(i=>i.selected)??o.calendar.days.find(i=>i.today&&!i.otherMonth)??o.calendar.days.find(i=>!i.otherMonth),r=i=>{if(i.nativeEvent.isComposing||i.altKey||i.ctrlKey||i.metaKey)return;let a=editor.calendarDateForKey(e.iso,i.key,o.session.locale,i.shiftKey);a&&(i.preventDefault(),o.focusDay(a));};return Be("button",t,{type:"button",className:"docx-content-control-calendar-day","data-docx-part":"day","data-iso":e.iso,role:"gridcell",tabIndex:e.iso===n?.iso?0:-1,"aria-label":e.label,...e.selected?{"data-selected":"","aria-selected":true}:{},"aria-current":e.today?"date":void 0,"aria-selected":e.selected,...e.today?{"data-today":""}:{},...e.otherMonth?{"data-other-month":""}:{},disabled:!o.isEnabled,onMouseDown:$o,onClick:()=>o.selectDay(e.iso),onKeyDown:r},String(e.day))}function Rc(e){let t=$e(),o=pt.useRef(null);return pt.useLayoutEffect(()=>{let n=o.current;if(!n||n.ownerDocument.activeElement?.closest("[data-docx-part=previousMonth],[data-docx-part=nextMonth],[data-docx-part=month],[data-docx-part=year]"))return;((t.focusIso?n.querySelector(`[data-iso="${t.focusIso}"]`):null)??n.querySelector("[data-selected]")??n.querySelector("[data-today]:not([data-other-month])")??n.querySelector('[data-docx-part="day"]:not([data-other-month])'))?.focus({preventScroll:true});},[t.focusIso,t.calendar]),Be("div",e,{ref:o,className:"docx-content-control-calendar-grid","data-docx-part":"grid",role:"grid","aria-label":t.calendar.title},Array.from({length:6},(n,r)=>jsxRuntime.jsx("div",{role:"row",className:"docx-content-control-calendar-week",children:t.calendar.days.slice(r*7,r*7+7).map(i=>jsxRuntime.jsx(Mc,{day:i},i.iso))},r)))}function Dc(e){let t=$e(),o=Ue();return Be("button",e,{type:"button",className:"docx-content-control-calendar-today","data-docx-part":"today",disabled:!t.isEnabled,onMouseDown:$o,onClick:t.selectToday},o("contentControl.calendar.today"))}function kc(e){return Be("div",e,{className:"docx-content-control-calendar","data-docx-part":"calendar"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Tc,{}),jsxRuntime.jsx(wc,{}),jsxRuntime.jsx(Rc,{}),jsxRuntime.jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsxRuntime.jsx(Dc,{}),jsxRuntime.jsx(Ri,{})]}),jsxRuntime.jsx(Vn,{}),jsxRuntime.jsx(ki,{})]}))}function Ic({item:e,...t}){let o=$e();return Be("button",t,{type:"button",className:"docx-content-control-menu-item","data-docx-part":"item","data-value":e.value,role:"option",tabIndex:o.items.findIndex(n=>n.value===o.value)<0?o.items[0]===e?0:-1:o.value===e.value?0:-1,"aria-selected":o.value===e.value,disabled:!o.isEnabled,onMouseDown:$o,onClick:()=>o.apply(e.value)},e.displayText)}function Mi(e){let t=$e(),o=Ue();return Be("div",e,{className:"docx-content-control-menu-list","data-docx-part":"list",role:"listbox",id:t.listId,"aria-label":o(`contentControl.types.${t.kind}`)},t.kind==="buildingBlockGallery"&&t.items.length===0?jsxRuntime.jsx("div",{className:"docx-content-control-menu-empty","data-docx-part":"empty",role:"note",tabIndex:0,children:o("contentControl.gallery.empty")}):t.items.map((n,r)=>jsxRuntime.jsx(Ic,{item:n},r)))}function Ri(e){let t=$e(),o=Ue();return Be("input",e,{type:"text",className:"docx-content-control-menu-input","data-docx-part":"input","aria-label":o(`contentControl.types.${t.kind}`),value:t.kind==="date"?t.dateText:t.value,placeholder:t.kind==="date"?editor.calendarDateText("2006-11-22",t.session.locale):void 0,"aria-invalid":t.refused||void 0,role:t.kind==="comboBox"?"combobox":void 0,"aria-expanded":t.kind==="comboBox"?true:void 0,"aria-controls":t.kind==="comboBox"?t.listId:void 0,"aria-autocomplete":t.kind==="comboBox"?"list":void 0,onKeyDown:n=>{n.key!=="Enter"||n.nativeEvent.isComposing||(n.preventDefault(),n.stopPropagation(),t.kind==="date"?t.applyDateText():t.apply());},onMouseDown:$o,onChange:n=>(t.kind==="date"?t.setDateText:t.setValue)(n.target.value)},void 0)}function Vn(e){let t=$e(),o=Ue();return t.refused?Be("div",e,{className:"docx-content-control-widget-error","data-docx-part":"error",role:"alert"},o("disabledReason.invalidValue")):null}function _c(e){let t=$e(),o=Ue();return Be("button",e,{type:"button",className:"docx-dialog__button docx-dialog__button--primary","data-docx-part":"apply",disabled:!t.isEnabled,onClick:()=>t.kind==="date"?t.applyDateText():t.apply()},o("common.apply"))}function Di(e){let t=$e(),o=Ue();return Be("button",e,{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t.cancel},o("common.cancel"))}function ki(e){return Be("div",e,{className:"docx-dialog__footer","data-docx-part":"footer"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Di,{}),jsxRuntime.jsx(_c,{})]}))}function Nc(e){return Be("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Lc,{}),jsxRuntime.jsx(Fc,{})]}))}function Lc(e){let t=$e(),o=Ue();return Be("select",e,{className:"docx-content-control-calendar-month","data-docx-part":"month","aria-label":o("contentControl.calendar.month"),value:t.calendar.month,onChange:n=>t.showMonth(t.calendar.year,Number(n.target.value))},editor.calendarMonthNames(t.session.locale).map((n,r)=>jsxRuntime.jsx("option",{value:r,children:n},r)))}function Fc(e){let t=$e(),o=Ue();return Be("input",e,{type:"number",min:100,max:9999,className:"docx-content-control-calendar-year","data-docx-part":"year","aria-label":o("contentControl.calendar.year"),key:t.calendar.year,defaultValue:t.calendar.year,onBlur:n=>{let r=Number(n.target.value);if(!Number.isInteger(r)||r<100||r>9999){n.target.value=String(t.calendar.year);return}t.showMonth(r,t.calendar.month);},onKeyDown:n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&(n.preventDefault(),n.currentTarget.blur());}},void 0)}function Ac({autoOpen:e,...t}){let o=$e(),n=Ue(),r=pt.useRef(null),i=pt.useRef(false);return pt.useLayoutEffect(()=>{e!==false&&!i.current&&(i.current=true,r.current?.click());},[e]),Be("input",t,{ref:r,type:"file",accept:o.accept,className:"docx-content-control-picture-input","data-docx-part":"picture","aria-label":n("contentControl.types.picture"),"aria-invalid":o.refused||void 0,onMouseDown:$o,onCancel:o.cancel,onChange:a=>{let l=a.target.files?.[0];a.target.value="",l&&o.replaceImage(l);}},void 0)}function lC(e){let[t,o]=pt.useState(e.session),[n,r]=pt.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(sC,{...e},n)}function sC({session:e,className:t,style:o,children:n}){let r=Ue(),i=Cm(e),[a,l]=pt.useState(e.signal.aborted),s=pt.useRef(null),[c]=pt.useState(()=>editor.contentControlPopupOpener(e.anchor)),d=e.kind==="checkbox"&&n===void 0;if(pt.useEffect(()=>{let u=()=>l(true);return e.signal.addEventListener("abort",u,{once:true}),e.signal.aborted&&u(),()=>e.signal.removeEventListener("abort",u)},[e]),pt.useEffect(()=>{!d||e.signal.aborted||e.apply(e.value==="true"?"false":"true");},[d,e]),pt.useLayoutEffect(()=>{if(a||d)return;let u=s.current,g=u?.ownerDocument,p=u&&e.anchor?editor.observeContentControlPopup(u,e.anchor):void 0;return u?.querySelector('[data-docx-part="grid"]')||(u?.querySelector("input")??u?.querySelector('[role=option][tabindex="0"]')??u?.querySelector("select,button,[data-docx-part=empty]"))?.focus({preventScroll:true}),()=>{p?.();let m=g?.activeElement;c?.isConnected&&(m===g?.body||m&&u?.contains(m))&&c.focus({preventScroll:true});}},[e,a,d,c]),pt.useEffect(()=>{let u=s.current;if(!u||a||d)return;let g=p=>{u.contains(p.target)||e.cancel();};return u.ownerDocument.addEventListener("pointerdown",g,true),()=>u.ownerDocument.removeEventListener("pointerdown",g,true)},[e,a,d]),a||d)return null;let f=r(`contentControl.types.${e.kind}`);return jsxRuntime.jsx(xm,{value:i,children:jsxRuntime.jsx("div",{ref:s,role:"dialog","aria-label":f,className:`docx-content-control-widget-popup${t?` ${t}`:""}`,style:o,"data-docx-popup":"contentControlWidget","data-docx-part":"popup","data-kind":e.kind,onPointerDown:u=>u.stopPropagation(),onKeyDown:u=>{editor.contentControlPopupKeyDown(u.currentTarget,u.nativeEvent,e.cancel),i.listNavigation.keyDown(u.nativeEvent,u.currentTarget);},children:n??cC(i)})})}function cC(e){return e.kind==="date"?jsxRuntime.jsx(kc,{}):e.kind==="picture"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ac,{}),jsxRuntime.jsx(Vn,{}),jsxRuntime.jsx(Di,{})]}):e.kind==="comboBox"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ri,{}),jsxRuntime.jsx(Mi,{}),jsxRuntime.jsx(Vn,{}),jsxRuntime.jsx(ki,{})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Mi,{}),jsxRuntime.jsx(Vn,{})]})}var Zc=Object.assign(lC,{Navigation:Nc,Month:Lc,Year:Fc,Calendar:kc,Header:Tc,PreviousMonth:Sc,Title:Ec,NextMonth:Pc,Weekdays:wc,Grid:Rc,Day:Mc,Today:Dc,List:Mi,Item:Ic,Input:Ri,Picture:Ac,Error:Vn,Footer:ki,Apply:_c,Cancel:Di});var At=$n();function uC(){return At.useState()}function pC({session:e,...t}){let[o,n]=pt.useState(e),[r,i]=pt.useState(0);return o!==e&&(n(e),i(r+1)),e?jsxRuntime.jsx(mC,{session:e,...t},r):null}function mC({session:e,children:t,preset:o,className:n,style:r}){let i=Ue(),a=O(()=>e.canApply()),[l,s]=pt.useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=pt.useState(e.signal.aborted),[f,u]=pt.useState(false);pt.useEffect(()=>{let x=()=>d(true);return e.signal.addEventListener("abort",x),e.signal.aborted&&x(),()=>e.signal.removeEventListener("abort",x)},[e]);let g=()=>{if(e.signal.aborted)return;let x=Number.isInteger(l.maxLength)&&l.maxLength>=0&&l.maxLength<=32767&&e.apply(l.defaultText,{type:l.type,maxLength:l.maxLength,format:l.format,enabled:l.enabled});u(!x);},p={values:l,setValue(x,h){s(y=>({...y,[x]:h,...x==="type"?{format:""}:{}})),u(false);},errors:f?{form:i("textFormField.invalidOptions")}:{},isEnabled:!c&&a,apply:g,cancel:e.cancel};if(c)return null;let m=editor.TEXT_FORM_FORMATS[l.type]??[],b={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},v=(x,h)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":x,className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${x}`)}),h]});return jsxRuntime.jsx(go,{kind:"textFormField",className:n,style:r,label:i("textFormField.title"),onClose:e.cancel,dismissOutside:false,sessionSignal:e.signal,restoreFocus:false,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),e.cancel()),x.key==="Enter"&&x.target instanceof HTMLInputElement&&(x.preventDefault(),g());},children:jsxRuntime.jsx(At.Composition,{state:p,preset:o,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:i("textFormField.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[v("defaultText",jsxRuntime.jsx("input",{className:"docx-dialog__input",value:l.defaultText,onChange:x=>p.setValue("defaultText",x.target.value)})),v("type",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:x=>p.setValue("type",x.target.value),children:[["regular","number","date"].map(x=>jsxRuntime.jsx("option",{value:x,children:i(`textFormField.${x}`)},x)),Object.hasOwn(editor.TEXT_FORM_FORMATS,l.type)?null:jsxRuntime.jsx("option",{value:l.type,disabled:true,children:i("textFormField.preservedType")})]})),v("maxLength",jsxRuntime.jsx("input",{className:"docx-dialog__input",type:"number",min:0,max:32767,step:1,value:Number.isNaN(l.maxLength)?"":l.maxLength,onChange:x=>p.setValue("maxLength",x.target.valueAsNumber)})),v("format",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:x=>p.setValue("format",x.target.value),children:[m.map(x=>jsxRuntime.jsx("option",{value:x,children:b[x]?i(b[x]):x||i("textFormField.noFormat")},x)),m.includes(l.format)?null:jsxRuntime.jsx("option",{value:l.format,disabled:true,children:l.format||i("textFormField.noFormat")})]})),jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"enabled",className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:l.enabled,onChange:x=>p.setValue("enabled",x.target.checked)}),i("textFormField.enabled")]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",className:"docx-dialog__error",role:"alert",children:p.errors.form}),jsxRuntime.jsx("button",{"data-docx-part":"cancel",className:"docx-dialog__button",type:"button",onClick:e.cancel,children:i("textFormField.cancel")}),jsxRuntime.jsx("button",{disabled:!a,"data-docx-part":"apply",className:"docx-dialog__button docx-dialog__apply",type:"button",onClick:g,children:i("textFormField.apply")})]})]}),children:t})})}var Wr=Object.assign(pC,{Header:At.Header,Title:At.Title,Body:At.Body,Footer:At.Footer,Apply:At.Apply,Cancel:At.Cancel,Error:At.Error,Field:At.Field});var Pm="(prefers-color-scheme: dark)";function Em(){return typeof window<"u"&&typeof window.matchMedia=="function"}function wm(){return Em()?window.matchMedia(Pm).matches:false}function Mm(e,t){return e==="dark"||e==="system"&&t}function Rm(e){if(!Em())return ()=>{};let t=window.matchMedia(Pm);e(t.matches);let o=n=>e(n.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}function Kc(e){return e==="checkbox"?"contentControlCheckbox":e==="picture"?"contentControlPicture":"contentControlWidget"}function km(){let e=F(),t=Xt(),o=pt.useRef(t);o.current=t;let[n,r]=pt.useState(null),[i,a]=pt.useState(null),l=t?.contentControlWidget!==void 0,s=t?.contentControlCheckbox!==void 0,c=t?.contentControlPicture!==void 0,d=t?.invalidTextFormField!==void 0;pt.useEffect(()=>{if(!e||!l&&!s&&!c)return;let u=true,g=[...l?["dropdown","comboBox","date","buildingBlockGallery"]:[],...s?["checkbox"]:[],...c?["picture"]:[]],p=e.setContentControlWidgetChrome({kinds:g,onRequest(m){if(o.current?.[Kc(m.kind)]===false)return m.cancel();r(m),m.signal.addEventListener("abort",()=>{u&&r(b=>b===m?null:b);},{once:true});}},{fallback:true});return ()=>{u=false,p(),r(null);}},[e,l,s,c]),pt.useEffect(()=>{if(!e||!d)return;let u=true,g=e.setInvalidTextFormFieldChrome({onRequest(p){if(o.current?.invalidTextFormField===false)return p.cancel();a(p),p.signal.addEventListener("abort",()=>{u&&a(m=>m===p?null:m);},{once:true});}},{fallback:true});return ()=>{u=false,g(),a(null);}},[e,d]),pt.useEffect(()=>{n&&t?.[Kc(n.kind)]===false&&n.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,n,i]);let f=n?t?.[Kc(n.kind)]:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&f&&Fe(f,{session:n},n),i&&t?.invalidTextFormField&&Fe(t.invalidTextFormField,{session:i},i)]})}var yC=e=>e.pageSetup??null,xC=e=>e.editable;function Go(){let e=F(),t=O(yC),o=O(xC),n=pt.useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),r=pt.useCallback(i=>e?e.exec({...i.pageWidthTwips!==void 0?{pageWidth:i.pageWidthTwips}:{},...i.pageHeightTwips!==void 0?{pageHeight:i.pageHeightTwips}:{},...i.orientation!==void 0?{orientation:i.orientation}:{},...i.marginTopTwips!==void 0?{marginTop:i.marginTopTwips}:{},...i.marginRightTwips!==void 0?{marginRight:i.marginRightTwips}:{},...i.marginBottomTwips!==void 0?{marginBottom:i.marginBottomTwips}:{},...i.marginLeftTwips!==void 0?{marginLeft:i.marginLeftTwips}:{},...i.scope!==void 0?{scope:i.scope}:{},type:"setPageSetup"}).ok:false,[e]);return pt.useMemo(()=>({pageSetup:t,isEnabled:n,apply:r}),[t,n,r])}var zc=[{labelKey:"dialogs.pageSetup.pageSizes.letter",width:12240,height:15840},{labelKey:"dialogs.pageSetup.pageSizes.a4",width:11906,height:16838},{labelKey:"dialogs.pageSetup.pageSizes.legal",width:12240,height:20160},{labelKey:"dialogs.pageSetup.pageSizes.a3",width:16838,height:23811},{labelKey:"dialogs.pageSetup.pageSizes.a5",width:8391,height:11906},{labelKey:"dialogs.pageSetup.pageSizes.b5",width:9979,height:14175},{labelKey:"dialogs.pageSetup.pageSizes.executive",width:10440,height:15120}],Fm=1440,TC=e=>Math.round(e/Fm*100)/100,SC=e=>Math.round(e*Fm);function PC(e,t){let o=Math.min(e,t),n=Math.max(e,t);return zc.findIndex(r=>Math.abs(r.width-o)<20&&Math.abs(r.height-n)<20)}var Nm=12240,Lm=15840,bo=1440;function EC({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=L(),l=wi(e,t),{pageSetup:s,isEnabled:c,apply:d}=Go(),[f,u]=pt.useState(Nm),[g,p]=pt.useState(Lm),[m,b]=pt.useState("portrait"),[v,x]=pt.useState(bo),[h,y]=pt.useState(bo),[T,C]=pt.useState(bo),[E,S]=pt.useState(bo),[D,R]=pt.useState(false),[w,I]=pt.useState("document"),H=pt.useRef(null),N=pt.useRef("no");pt.useEffect(()=>{if(!e){N.current="no";return}if(N.current==="yes"&&s===null){N.current="no";return}N.current==="yes"||N.current==="loading"&&s===null||(R(false),u(s?.pageWidthTwips??Nm),p(s?.pageHeightTwips??Lm),b(s?.orientation??"portrait"),x(s?.marginsTwips.top??bo),y(s?.marginsTwips.bottom??bo),C(s?.marginsTwips.left??bo),S(s?.marginsTwips.right??bo),I("document"),N.current=s===null?"loading":"yes");},[e,s]);let _=pt.useCallback(B=>{let J=zc[B];J&&(u(m==="landscape"?J.height:J.width),p(m==="landscape"?J.width:J.height));},[m]),P=pt.useCallback(B=>{B!==m&&(b(B),u(g),p(f));},[m,f,g]),k=pt.useCallback(()=>{if(!c)return;if(!l()){t();return}let B=d({pageWidthTwips:f,pageHeightTwips:g,orientation:m,marginTopTwips:v,marginRightTwips:E,marginBottomTwips:h,marginLeftTwips:T,scope:w});R(!B),B&&t();},[c,l,d,f,g,m,v,E,h,T,w,t]);if(!e)return null;let j=PC(f,g),W=(B,J,de)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":`margin${B[0].toUpperCase()}${B.slice(1)}`,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a(`dialogs.pageSetup.${B}`)}),jsxRuntime.jsx("input",{type:"number",className:"docx-dialog__input",min:0,max:22,step:.1,value:TC(J),onChange:V=>de(Math.max(0,SC(Number(V.target.value)||0))),"aria-label":a(`dialogs.pageSetup.${B}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:"in"})]}),re={pageWidth:f,pageHeight:g,orientation:m,marginTop:v,marginBottom:h,marginLeft:T,marginRight:E,scope:w},z={pageWidth:u,pageHeight:p,orientation:P,marginTop:x,marginBottom:y,marginLeft:C,marginRight:S,scope:I},te={values:re,setValue(B,J){z[B](J);},errors:D?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:k,cancel:t};return jsxRuntime.jsx(go,{kind:"pageSetup",className:o,style:n,panelRef:H,label:a("dialogs.pageSetup.title"),onClose:t,onKeyDown:B=>{B.key==="Escape"&&t(),B.key==="Enter"&&B.target instanceof HTMLInputElement&&c&&(B.preventDefault(),k());},children:jsxRuntime.jsx(Ot.Composition,{state:te,preset:i,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.pageSetup.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.pageSetup.pageSize")}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"pageSize",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.sizeLabel")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:j,onChange:B=>_(Number(B.target.value)),"aria-label":a("dialogs.pageSetup.sizeLabel"),children:[zc.map((B,J)=>jsxRuntime.jsx("option",{value:J,children:a(B.labelKey)},B.labelKey)),j<0&&jsxRuntime.jsx("option",{value:-1,children:a("dialogs.pageSetup.custom")})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"orientation",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.orientation")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:m,onChange:B=>P(B.target.value),"aria-label":a("dialogs.pageSetup.orientation"),children:[jsxRuntime.jsx("option",{value:"portrait",children:a("dialogs.pageSetup.portrait")}),jsxRuntime.jsx("option",{value:"landscape",children:a("dialogs.pageSetup.landscape")})]})]}),jsxRuntime.jsx("div",{className:"docx-dialog__section-label docx-dialog__section-label--spaced",children:a("dialogs.pageSetup.margins")}),W("top",v,x),W("bottom",h,y),W("left",T,C),W("right",E,S),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"scope",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.applyTo")}),jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:w,onChange:B=>I(B.target.value),"aria-label":a("dialogs.pageSetup.applyTo"),children:[jsxRuntime.jsx("option",{value:"document",children:a("dialogs.pageSetup.applyToDocument")}),jsxRuntime.jsx("option",{value:"section",children:a("dialogs.pageSetup.applyToSection")})]})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",role:"alert",className:"docx-dialog__error",children:D?a("dialogs.paragraph.refused"):null}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!c,"data-docx-part":"apply",onClick:k,children:a("common.apply")})]})]}),children:r})})}var Ot=$n();function wC(){return Ot.useState()}var Yo=Object.assign(EC,{Header:Ot.Header,Title:Ot.Title,Body:Ot.Body,Footer:Ot.Footer,Apply:Ot.Apply,Cancel:Ot.Cancel,Error:Ot.Error,Field:Ot.Field});var kC={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},IC=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,n=t.paragraphFlags??kC;return {alignment:t.alignment==="both"?"justify":t.alignment??null,spaceBeforePt:t.spaceBeforePt??null,spaceAfterPt:t.spaceAfterPt??null,lineSpacing:t.lineSpacing??null,indentLeftTwips:o&&!o.mixed.left?o.left:null,indentRightTwips:o&&!o.mixed.right?o.right:null,indentFirstLineTwips:o&&!o.mixed.firstLine?o.firstLine:null,contextualSpacing:n.contextualSpacing,keepNext:n.keepNext,keepLines:n.keepLines,widowControl:n.widowControl,pageBreakBefore:n.pageBreakBefore,tabStops:t.tabStops??null,indentUnknown:!o,disagrees:{alignment:t.disagrees?.alignment??false,spaceBeforePt:t.disagrees?.spaceBeforePt??false,spaceAfterPt:t.disagrees?.spaceAfterPt??false,lineSpacing:t.disagrees?.lineSpacing??false,tabStops:t.disagrees?.tabStops??false,indentLeft:o?.mixed.left??false,indentRight:o?.mixed.right??false,indentFirstLine:o?.mixed.firstLine??false}}},_C=["alignment","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],NC=(e,t)=>_C.every(o=>e.disagrees[o]===t.disagrees[o]),LC=(e,t)=>e===null||t===null?e===t:e.alignment===t.alignment&&e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value&&e.indentLeftTwips===t.indentLeftTwips&&e.indentRightTwips===t.indentRightTwips&&e.indentFirstLineTwips===t.indentFirstLineTwips&&e.contextualSpacing===t.contextualSpacing&&e.keepNext===t.keepNext&&e.keepLines===t.keepLines&&e.widowControl===t.widowControl&&e.pageBreakBefore===t.pageBreakBefore&&NC(e,t)&&e.indentUnknown===t.indentUnknown&&e.tabStops?.length===t.tabStops?.length&&(e.tabStops??[]).every((o,n)=>o.positionTwips===t.tabStops?.[n]?.positionTwips&&o.alignment===t.tabStops?.[n]?.alignment&&(o.leader??"none")===(t.tabStops?.[n]?.leader??"none")),FC=e=>e.editable;function Uc(){let e=F(),t=O(IC,LC),o=O(FC),n=pt.useMemo(()=>o&&e!==null&&e.can({type:"setParagraphFormat",alignment:"left"}).ok,[e,o]),r=pt.useCallback(i=>{if(!e)return false;let a={type:"setParagraphFormat",...i};return e.can(a).ok?e.exec(a).ok:false},[e]);return {format:t,isEnabled:n,apply:r}}function OC({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=L(),l=wi(e,t),{format:s,isEnabled:c,apply:d}=Uc(),[f,u]=pt.useState("left"),[g,p]=pt.useState(0),[m,b]=pt.useState(0),[v,x]=pt.useState("none"),[h,y]=pt.useState(0),[T,C]=pt.useState(0),[E,S]=pt.useState(0),[D,R]=pt.useState("multiple"),[w,I]=pt.useState(1.08),[H,N]=pt.useState(false),[_,P]=pt.useState(false),[k,j]=pt.useState(false),[W,re]=pt.useState(true),[z,te]=pt.useState(false),[B,J]=pt.useState([]),[de,V]=pt.useState(false),[q,Re]=pt.useState(0),[je,pe]=pt.useState("left"),[ze,Ut]=pt.useState("none"),[he,_t]=pt.useState(editor.NO_MIXED_FIELDS),[is,ls]=pt.useState(false),xn=K=>a(is&&(K==="indentLeft"||K==="indentRight"||K==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),lo=pt.useRef(editor.NO_MIXED_FIELDS),Ne=pt.useId(),[za,me]=pt.useState(false),ge=pt.useRef(null),$t=pt.useRef(false),Vt=pt.useRef(null);pt.useEffect(()=>{if(!e){$t.current=false;return}if($t.current||s===null)return;let K=editor.seedFields(s);u(K.alignment),p(K.indentLeft),b(K.indentRight),x(K.special),y(K.specialBy),C(K.spaceBefore),S(K.spaceAfter),R(K.lineRule),I(K.lineValue),N(K.contextualSpacing),P(K.keepNext),j(K.keepLines),re(K.widowControl),te(K.pageBreakBefore),J(K.tabStops),V(false);let fe=editor.mixedFieldsOf(s);_t(fe),ls(s.indentUnknown),Re(0),pe("left"),Ut("none"),lo.current=fe,me(false),Vt.current=K,$t.current=true;},[e,s]);let cr=pt.useCallback(()=>{if(!c)return;if(!l()){t();return}let K=Vt.current,fe=K===null?null:editor.changedFields(K,{alignment:f,indentLeft:g,indentRight:m,special:v,specialBy:h,spaceBefore:T,spaceAfter:E,lineRule:D,lineValue:w,contextualSpacing:H,keepNext:_,keepLines:k,widowControl:W,pageBreakBefore:z,tabStops:B,clearedAllTabStops:de},lo.current,he);if(fe===null){t();return}if(d(fe)){me(false),t();return}me(true);},[c,l,d,t,he,de,f,g,m,v,h,T,E,D,w,H,_,k,W,z,B]),Ua=pt.useCallback(()=>{let K=Math.round(q);return K<=0?false:(_t(fe=>({...fe,tabStops:false})),J(editor.withTabStop(B,{positionTwips:K,alignment:je,...ze!=="none"?{leader:ze}:{}})),Re(0),pe("left"),Ut("none"),true)},[B,q,je,ze]);if(!e)return null;let xt=K=>_t(fe=>({...fe,[K]:false})),ss=(K,fe,so,Qe)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":Qe,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${Ne}-${K}`,children:a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("input",{id:`${Ne}-${K}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:he[Qe]?"":editor.twipsToInches(fe),placeholder:he[Qe]?xn(Qe):void 0,onChange:ur=>{xt(Qe),so(editor.inchesToTwips(Number(ur.target.value)||0));},"aria-label":a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),Qu=(K,fe,so,Qe)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":K,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${Ne}-${K}`,children:a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("input",{id:`${Ne}-${K}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:he[Qe]?"":fe,placeholder:he[Qe]?xn(Qe):void 0,onChange:ur=>{xt(Qe),so(Math.max(0,Number(ur.target.value)||0));},"aria-label":a(`dialogs.paragraph.${K}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),dr=(K,fe,so)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":K,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:fe,ref:Qe=>{Qe&&(Qe.indeterminate=he[K]);},onChange:Qe=>{_t(ur=>({...ur,[K]:false})),so(Qe.target.checked);}}),a(`dialogs.paragraph.${K}`)]}),Eh={alignment:f,indentLeft:g,indentRight:m,special:v,specialBy:h,spaceBefore:T,spaceAfter:E,lineRule:D,lineValue:w,contextualSpacing:H,keepNext:_,keepLines:k,widowControl:W,pageBreakBefore:z,tabStops:B,clearedAllTabStops:de},wh={alignment:u,indentLeft:p,indentRight:b,special:x,specialBy:y,spaceBefore:C,spaceAfter:S,lineRule:R,lineValue:I,contextualSpacing:N,keepNext:P,keepLines:j,widowControl:re,pageBreakBefore:te,tabStops:J,clearedAllTabStops:V},Mh={values:Eh,mixed:he,setValue(K,fe){wh[K](fe),K==="lineRule"?(xt("lineSpacing"),I(fe===Vt.current?.lineRule?Vt.current.lineValue:fe==="multiple"?1.08:12)):K==="specialBy"?xt("special"):K in he&&xt(K);},errors:za?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:cr,cancel:t};return jsxRuntime.jsx(go,{kind:"paragraph",className:o,style:n,panelRef:ge,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:K=>{K.key==="Escape"&&t();let fe=K.target instanceof HTMLButtonElement||K.target instanceof HTMLSelectElement;if(K.key==="Enter"&&!fe){let so=K.target;if(so instanceof HTMLElement&&so.dataset.docxTabEntry!==void 0){Ua();return}c&&cr();}},children:jsxRuntime.jsx(Bt.Composition,{state:Mh,preset:i,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsxRuntime.jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.paragraph.title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxRuntime.jsxs("div",{className:"docx-dialog__columns",children:[jsxRuntime.jsxs("div",{className:"docx-dialog__column",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.general")}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"alignment",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${Ne}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxRuntime.jsxs("select",{id:`${Ne}-alignment`,className:"docx-dialog__input",value:he.alignment?"":f,onChange:K=>{xt("alignment"),u(K.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[he.alignment?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"left",children:a("dialogs.paragraph.alignLeft")}),jsxRuntime.jsx("option",{value:"center",children:a("dialogs.paragraph.alignCenter")}),jsxRuntime.jsx("option",{value:"right",children:a("dialogs.paragraph.alignRight")}),jsxRuntime.jsx("option",{value:"justify",children:a("dialogs.paragraph.alignJustify")})]})]}),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.indentation")}),ss("beforeText",g,p,"indentLeft"),ss("afterText",m,b,"indentRight"),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"special",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${Ne}-special`,children:a("dialogs.paragraph.special")}),jsxRuntime.jsxs("select",{id:`${Ne}-special`,className:"docx-dialog__input",value:he.special?"":v,onChange:K=>{xt("special"),x(K.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[he.special?jsxRuntime.jsx("option",{value:"",children:xn("special")}):null,jsxRuntime.jsx("option",{value:"none",children:a("dialogs.paragraph.specialNone")}),jsxRuntime.jsx("option",{value:"firstLine",children:a("dialogs.paragraph.specialFirstLine")}),jsxRuntime.jsx("option",{value:"hanging",children:a("dialogs.paragraph.specialHanging")})]})]}),v!=="none"?jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"specialBy",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${Ne}-by`,children:a("dialogs.paragraph.by")}),jsxRuntime.jsx("input",{id:`${Ne}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:he.special?"":editor.twipsToInches(h),placeholder:he.special?xn("special"):void 0,onChange:K=>{xt("special"),y(Math.max(0,editor.inchesToTwips(Number(K.target.value)||0)));},"aria-label":a("dialogs.paragraph.by")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}):null,jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"tabStops",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.tabStops")}),B.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__note",children:a(he.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):B.map(K=>jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label docx-dialog__tab-position",children:a("dialogs.paragraph.tabPositionLabel",{position:editor.formatInches(K.positionTwips)})}),jsxRuntime.jsx("span",{className:"docx-dialog__tab-description",children:a(editor.TAB_ALIGNMENT_LABELS[K.alignment])}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>J(B.filter(fe=>fe!==K)),"aria-label":a("dialogs.paragraph.tabRemoveAt",{position:editor.formatInches(K.positionTwips)}),children:a("dialogs.paragraph.tabRemove")})]},K.positionTwips)),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${Ne}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsxRuntime.jsx("input",{id:`${Ne}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:editor.twipsToInches(q),onChange:K=>Re(Math.max(0,editor.inchesToTwips(Number(K.target.value)||0))),"aria-label":a("dialogs.paragraph.tabPosition"),"data-docx-tab-entry":""}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${Ne}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxRuntime.jsxs("select",{id:`${Ne}-tabAlignment`,className:"docx-dialog__input",value:je,onChange:K=>pe(K.target.value),"aria-label":a("dialogs.paragraph.tabAlignment"),"data-docx-tab-entry":"",children:[jsxRuntime.jsx("option",{value:"left",children:a("dialogs.paragraph.tabAlignLeft")}),jsxRuntime.jsx("option",{value:"center",children:a("dialogs.paragraph.tabAlignCenter")}),jsxRuntime.jsx("option",{value:"right",children:a("dialogs.paragraph.tabAlignRight")}),jsxRuntime.jsx("option",{value:"decimal",children:a("dialogs.paragraph.tabAlignDecimal")})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${Ne}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxRuntime.jsxs("select",{id:`${Ne}-tabLeader`,className:"docx-dialog__input",value:ze,onChange:K=>Ut(K.target.value),"aria-label":a("dialogs.paragraph.tabLeader"),"data-docx-tab-entry":"",children:[jsxRuntime.jsx("option",{value:"none",children:a("dialogs.paragraph.tabNone")}),jsxRuntime.jsx("option",{value:"dot",children:a("dialogs.paragraph.tabLeaderDot")}),jsxRuntime.jsx("option",{value:"hyphen",children:a("dialogs.paragraph.tabLeaderHyphen")}),jsxRuntime.jsx("option",{value:"underscore",children:a("dialogs.paragraph.tabLeaderUnderscore")})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__row docx-dialog__row--actions",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:Ua,children:a("dialogs.paragraph.tabAdd")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{_t(K=>({...K,tabStops:false})),V(true),J([]);},children:a("dialogs.paragraph.tabClearAll")})]})]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__column",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.spacing")}),Qu("spaceBefore",T,C,"spaceBefore"),Qu("spaceAfter",E,S,"spaceAfter"),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"lineRule",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${Ne}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxRuntime.jsxs("select",{id:`${Ne}-lineSpacing`,className:"docx-dialog__input",value:he.lineSpacing?"":D,onChange:K=>{let fe=K.target.value;xt("lineSpacing"),R(fe),I(fe===Vt.current?.lineRule?Vt.current.lineValue:fe==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[he.lineSpacing?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"multiple",children:a("dialogs.paragraph.ruleMultiple")}),jsxRuntime.jsx("option",{value:"atLeast",children:a("dialogs.paragraph.ruleAtLeast")}),jsxRuntime.jsx("option",{value:"exact",children:a("dialogs.paragraph.ruleExactly")})]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"lineValue",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${Ne}-at`,children:a("dialogs.paragraph.at")}),jsxRuntime.jsx("input",{id:`${Ne}-at`,type:"number",className:"docx-dialog__input",min:.01,step:D==="multiple"?.01:1,value:he.lineSpacing?"":w,disabled:he.lineSpacing,onChange:K=>{let fe=K.target.value.trim();I(fe===""?D==="multiple"?1.08:12:Number(fe)||0);},"aria-label":a("dialogs.paragraph.at")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:D==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),dr("contextualSpacing",H,N),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),dr("keepNext",_,P),dr("widowControl",W,re),dr("keepLines",k,j),dr("pageBreakBefore",z,te)]})]})}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{role:"alert","data-docx-part":"error",className:"docx-dialog__error",children:za?a("dialogs.paragraph.refused"):null}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("dialogs.paragraph.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!c,"data-docx-part":"apply",onClick:cr,children:a("dialogs.paragraph.ok")})]})]}),children:r})})}var Bt=$n();function BC(){return Bt.useState()}var Jt=Object.assign(OC,{Header:Bt.Header,Title:Bt.Title,Body:Bt.Body,Footer:Bt.Footer,Apply:Bt.Apply,Cancel:Bt.Cancel,Error:Bt.Error,Field:Bt.Field});var Km=pt.createContext(null),zr=()=>pt.useContext(Km);function Wm({popups:e,children:t}){let o=F(),n=bc(),[r,i]=pt.useState(null),[a,l]=pt.useState(null),[s,c]=pt.useState(null),d=pt.useRef(e);d.current=e;let f=pt.useRef(null),u=pt.useRef(s);u.current=s;let g=()=>l(null);pt.useEffect(()=>{if(a!==null)return;let v=f.current;f.current=null,v?.isConnected&&v.focus({preventScroll:true});},[a]),pt.useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(v){if(d.current?.textFormField===false){v.cancel();return}l(null),c(v),v.signal.addEventListener("abort",()=>c(x=>x===v?null:x),{once:true});}},{fallback:true})},[o]),pt.useEffect(()=>{l(null),c(null);},[o,n]),pt.useEffect(()=>{e?.textFormField===false&&u.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let p=pt.useMemo(()=>({setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(v,x){u.current?.cancel(),d.current?.[v]!==false&&(f.current=x??r?.ownerDocument.activeElement,l(v));}}),[r,e?.pageSetup]),m={open:true,onClose:g},b=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?Fe(e.pageSetup,m):jsxRuntime.jsx(Yo,{...m}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Fe(e.paragraph,m):jsxRuntime.jsx(Jt,{...m}):s&&e?.textFormField!==false?e?.textFormField?Fe(e.textFormField,{session:s},s):jsxRuntime.jsx(Wr,{session:s}):null;return jsxRuntime.jsxs(Km.Provider,{value:p,children:[t,r?reactDom.createPortal(b,r):null]})}function zm(){let e=zr();return jsxRuntime.jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer})}var nT=["nw","n","ne","e","se","s","sw","w"],Gm=40,Ym=12;function rT(e){return `imageOverlay.handle.${e}`}function aT(e){switch(e){case "nw":case "se":return "nwse-resize";case "ne":case "sw":return "nesw-resize";case "n":case "s":return "ns-resize";default:return "ew-resize"}}function iT(e){return {nw:{x:"0%",y:"0%"},n:{x:"50%",y:"0%"},ne:{x:"100%",y:"0%"},e:{x:"100%",y:"50%"},se:{x:"100%",y:"100%"},s:{x:"50%",y:"100%"},sw:{x:"0%",y:"100%"},w:{x:"0%",y:"50%"}}[e]}function lT(e,t){return e>0&&t>0?"se":e>0&&t<0?"ne":e<0&&t>0?"sw":e<0&&t<0?"nw":e>0?"e":e<0?"w":t>0?"s":"n"}function Xc({containerRef:e,portalRef:t,scrollPort:o}){let n=F(),{t:r}=L(),[i,a]=pt.useState(null),[l,s]=pt.useState(null),[c,d]=pt.useState({left:0,top:0}),f=pt.useRef(null);f.current=l;let u=pt.useRef(null),g=pt.useRef(null),p=pt.useRef(null),m=pt.useRef(null),b=pt.useRef(null);pt.useEffect(()=>{let S=e.current;if(!S)return;let D=R=>{let I=(R.target instanceof Element?R.target:null)?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");m.current=I??null,I&&I===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return S.addEventListener("pointerdown",D,{capture:true}),()=>S.removeEventListener("pointerdown",D,{capture:true})},[e,i?.id]),pt.useEffect(()=>{if(!n){a(null);return}let S=()=>{a(editor.selectedDrawingOverlayTargetOf(n.surface));},D=()=>{queueMicrotask(S);};S();let R=[n.on("change",D),n.on("selectionChange",S)];return ()=>{for(let w of R)w();}},[n]);let v=pt.useCallback(()=>{d(S=>{let D=editor.overlayHostOrigin(e.current);return D.left===S.left&&D.top===S.top?S:D});},[e]);pt.useEffect(()=>{v();let S=t.current;if(!S||typeof ResizeObserver!="function")return;let D=new ResizeObserver(v);D.observe(S);let R=e.current;return R&&D.observe(R),()=>D.disconnect()},[e,t,v,i]),pt.useEffect(()=>{if(o){b.current=o;return}let S=e.current;if(!S||!n?.surface)return;let D=S.closest(".docx-editor__scroll-container");if(!D)return;let R=n.surface.overlayCoordinates();return b.current=editor.createImageOverlayScrollPort(D,R.paintScale),()=>{b.current=null;}},[e,n,o]);let x=pt.useCallback(()=>{s(null),u.current=null;let S=g.current;if(g.current=null,S)try{S.releasePointerCapture(S._lastPointerId??0);}catch{}},[]),h=pt.useCallback((S,D,R,w,I,H,N)=>{if(!n?.surface)return;let _=n.surface.layout(),P=editor.captureImageMutationPreconditions(n);if(P){u.current=Object.freeze({x:w,y:I}),g.current=H,H._lastPointerId=N;try{H.setPointerCapture(N);}catch{}s({session:Object.freeze({drawingNodeId:R.id,startBounds:Object.freeze({x:R.x,y:R.y,width:R.width,height:R.height}),startWidthEmu:R.widthEmu,startHeightEmu:R.heightEmu,startPosition:R.position,anchorFrameOrigin:R.anchorFrameOrigin,transform:R.transform,mode:S,handle:D,preconditions:P,layoutRevision:_.revision,packageRevision:n.surface.session.packageRevision(),kind:R.kind}),bounds:R,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});}},[n]),y=pt.useCallback((S,D,R,w,I)=>{if(!n)return;if(editor.isStaleImageInteractionCommit(n,S)){x();return}S.mode==="resize"?n.exec({type:"setImageProperties",widthEmu:D,heightEmu:R,...I?.mode==="simple"?{horizontalEmu:I.horizontalEmu,verticalEmu:I.verticalEmu}:{},...I?.mode==="frame"?{...I.horizontalEmu!==void 0?{horizontalEmu:I.horizontalEmu}:{},...I.verticalEmu!==void 0?{verticalEmu:I.verticalEmu}:{}}:{}}):S.mode==="move"&&I&&n.exec({type:"setImagePosition",...I}),x();},[x,n]),T=pt.useCallback(S=>{if(!n)return;let D=f.current?.bounds??editor.selectedDrawingOverlayTargetOf(n.surface);if(!D)return;if(f.current&&S.key==="Escape"){S.preventDefault(),S.stopPropagation(),x();return}if(f.current)return;let R=S.shiftKey?editor.IMAGE_OVERLAY_NUDGE_SHIFT_PT:editor.IMAGE_OVERLAY_NUDGE_PT;if(S.key==="Delete"||S.key==="Backspace"){S.preventDefault(),S.stopPropagation(),n.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(S.key))return;S.preventDefault(),S.stopPropagation();let w=S.key==="ArrowLeft"?-R:S.key==="ArrowRight"?R:0,I=S.key==="ArrowUp"?-R:S.key==="ArrowDown"?R:0;if(S.altKey){if(!D.canResize)return;let N=lT(w,I),_=editor.computeImageResizeResult({handle:N,startWidthEmu:D.widthEmu,startHeightEmu:D.heightEmu,startBounds:{x:D.x,y:D.y,width:D.width,height:D.height},startPosition:D.position,anchorFrameOrigin:D.anchorFrameOrigin,deltaXPt:w,deltaYPt:I,transform:D.transform,preserveAspect:editor.resizePreservesAspect(N,D.aspectLocked,S.shiftKey),kind:D.kind});n.exec({type:"setImageProperties",widthEmu:_.widthEmu,heightEmu:_.heightEmu,..._.position?.mode==="simple"?{horizontalEmu:_.position.horizontalEmu,verticalEmu:_.position.verticalEmu}:{},..._.position?.mode==="frame"?{..._.position.horizontalEmu!==void 0?{horizontalEmu:_.position.horizontalEmu}:{},..._.position.verticalEmu!==void 0?{verticalEmu:_.position.verticalEmu}:{}}:{}});return}if(D.kind!=="anchored"||!D.canMove||!D.position)return;let H=editor.computeMovedImagePosition(D.position,w,I);n.exec({type:"setImagePosition",...H});},[x,n]);pt.useEffect(()=>{if(!l||!n?.surface)return;let S=n.surface.overlayCoordinates(),D=w=>{let I=f.current,H=u.current;if(!I||!H)return;let N=editor.cssPixelsToLayoutPoints(w.clientX-H.x,S.paintScale),_=editor.cssPixelsToLayoutPoints(w.clientY-H.y,S.paintScale);if(I.session.mode==="move"){let k=0,j=b.current,W=e.current?.closest(".docx-editor__scroll-container");if(j&&W){let z=W.getBoundingClientRect();w.clientY>z.bottom-Gm?k=Ym:w.clientY<z.top+Gm&&(k=-Ym),k!==0&&(k=j.scrollBy(k));}let re=I.accumulatedScrollPt+k;s({...I,accumulatedScrollPt:re,bounds:Object.freeze({...I.bounds,x:I.session.startBounds.x+N,y:I.session.startBounds.y+_+re})});return}if(!I.session.handle)return;let P=editor.computeImageResizeResult({handle:I.session.handle,startWidthEmu:I.session.startWidthEmu,startHeightEmu:I.session.startHeightEmu,startBounds:I.session.startBounds,startPosition:I.session.startPosition,anchorFrameOrigin:I.session.anchorFrameOrigin,deltaXPt:N,deltaYPt:_,transform:I.session.transform,preserveAspect:editor.resizePreservesAspect(I.session.handle,I.bounds.aspectLocked,w.shiftKey),kind:I.session.kind});s({...I,bounds:Object.freeze({...I.bounds,x:P.previewBounds.x,y:P.previewBounds.y,width:P.previewBounds.width,height:P.previewBounds.height,widthEmu:P.widthEmu,heightEmu:P.heightEmu})});},R=w=>{let I=f.current;if(I)if(w.type==="pointerup"){let H=editor.cssPixelsToLayoutPoints(w.clientX-(u.current?.x??w.clientX),S.paintScale),N=editor.cssPixelsToLayoutPoints(w.clientY-(u.current?.y??w.clientY),S.paintScale),_=editor.finalizeImageOverlayInteraction({session:I.session,deltaXPt:H,deltaYPt:N,accumulatedScrollPt:I.accumulatedScrollPt,aspectLocked:I.bounds.aspectLocked,shiftKey:w.shiftKey,anchorFrameOrigin:I.session.anchorFrameOrigin});y(I.session,_.widthEmu,_.heightEmu,_.previewBounds,_.position);}else x();};return window.addEventListener("pointermove",D),window.addEventListener("pointerup",R),window.addEventListener("pointercancel",R),()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",R),window.removeEventListener("pointercancel",R);}},[x,y,e,n,l]),pt.useEffect(()=>{!i||m.current!==i.id||(m.current=null,p.current?.focus({preventScroll:true}));},[i]);let C=l?.bounds??i,E=pt.useMemo(()=>{if(!n?.surface||!C)return null;let S=n.surface.publishedLayout(),D=n.surface.overlayCoordinates(),R=editor.overlayFrameToSheetCssPixels(S,{pageIndex:C.pageIndex,x:C.x,y:C.y,width:C.width,height:C.height},D),w={left:R.left+c.left,top:R.top+c.top,width:R.width,height:R.height},I=C.canResize,H=C.kind==="anchored"&&C.canMove;return jsxRuntime.jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":C.id,tabIndex:0,onKeyDown:T,children:[jsxRuntime.jsx("div",{className:`docx-image-selection-overlay__frame${H?" docx-editor-one-surface__overlay-control":""}`,role:"group","aria-label":r("imageOverlay.selection"),style:{left:`${w.left}px`,top:`${w.top}px`,width:`${w.width}px`,height:`${w.height}px`,cursor:H?"move":"default"},onPointerDown:N=>{Z(N),!(!H||!C.position)&&N.button===0&&(N.preventDefault(),N.stopPropagation(),h("move",null,C,N.clientX,N.clientY,N.currentTarget,N.pointerId));}}),I?nT.map(N=>{let _=iT(N);return jsxRuntime.jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(rT(N)),tabIndex:0,style:{left:`calc(${w.left}px + ${w.width}px * ${parseFloat(_.x)/100} - 5px)`,top:`calc(${w.top}px + ${w.height}px * ${parseFloat(_.y)/100} - 5px)`,cursor:aT(N)},onPointerDown:P=>{Z(P),P.button===0&&(P.preventDefault(),P.stopPropagation(),h("resize",N,C,P.clientX,P.clientY,P.currentTarget,P.pointerId));}},N)}):null]})},[C,h,n,T,c.left,c.top,r]);return !E||!t.current?null:reactDom.createPortal(E,t.current)}function Jc(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Bi({className:e}){let t=F(),o=Pr(),n=pt.useRef(null),r=pt.useRef(null);pt.useLayoutEffect(()=>{let s=n.current;if(!(!t||!s))return t.attach(s),()=>{t.detach();}},[t]);let i=pt.useCallback(s=>{if(!o?.isEnabled)return;let c=s.clipboardData;c&&Jc(c)&&(editor.clipboardPasteLandsContent(c)||(s.preventDefault(),o.insertFromDataTransfer(c)));},[o]),a=pt.useCallback(s=>{!o?.isEnabled||!Jc(s.dataTransfer)||s.preventDefault();},[o]),l=pt.useCallback(s=>{if(o?.isEnabled&&Jc(s.dataTransfer)){if(editor.clipboardDropLandsText(s.dataTransfer)){if((s.target instanceof Element?s.target:null)?.closest("[contenteditable]")?.getAttribute("contenteditable")==="true")return;s.preventDefault();return}s.preventDefault(),o.insertFromDataTransfer(s.dataTransfer);}},[o]);return jsxRuntime.jsxs("div",{ref:r,className:"docx-content-mount",children:[jsxRuntime.jsx("div",{ref:n,className:`docx-paginated-surface${e?` ${e}`:""}`,onPaste:i,onDragOver:a,onDrop:l}),jsxRuntime.jsx(zm,{}),jsxRuntime.jsx(Jp,{}),jsxRuntime.jsx(km,{}),t?jsxRuntime.jsx(Xc,{containerRef:n,portalRef:r}):null]})}function Ee(e){return e/1440*96}function Zi(e){return e/96*1440}function it(e){return `${Math.round(e*100)/100}px`}function ed(e){return e/2}var mT=e=>e.isLoading||e.isOpening===true,fT=e=>({width:Ee(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:Ee(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),gT=(e,t)=>e.width===t.width&&e.height===t.height;function td({className:e}){return jsxRuntime.jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}function bT({when:e=false,overlay:t=false,className:o,style:n,children:r}){let i=O(mT),a=O(fT,gT),{t:l}=L();if(!e&&!i)return null;let s=`docx-editor docx-editor__loading${t?" docx-editor__loading--overlay":""}${o?` ${o}`:""}`;return jsxRuntime.jsx("div",{className:s,style:n,role:"status","aria-live":"polite",children:r??jsxRuntime.jsx("div",{className:"docx-paginated-surface docx-editor__loading-surface",style:{width:a.width,height:a.height},children:jsxRuntime.jsx("div",{className:"docx-pages",children:jsxRuntime.jsx("div",{className:"docx-page docx-editor__loading-page",children:jsxRuntime.jsxs("div",{className:"docx-editor__loading-page-status",children:[jsxRuntime.jsx(td,{}),jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:l("loading.label")})]})})})})})}var qi=Object.assign(bT,{Spinner:td});function Qm(){let e=new Set,t=new Map,o=new Map,n=0,r=null,i=false;function a(){if(e.size===0&&t.size===0)return;if(t.size===0)return "kind";let u=Object.create(null),g=[...t].sort((p,m)=>(o.get(p[0])??0)-(o.get(m[0])??0));for(let[,{author:p,style:m}]of g)u[p]=m;return {authors:u,others:e.size>0?"kind":"author"}}let l=null,s=false;function c(u){if(u===void 0)return "none";if(typeof u=="string")return u;let g=Object.entries(u.authors).map(([p,m])=>`${p}\0${JSON.stringify(m)}`).sort();return `${u.others??"kind"}${g.join("")}`}function d(){if(!r)return;let u=a(),g=c(u);if(g!==l){if(u===void 0){i&&(r.setRevisionStyles("author"),i=false,l=g);return}r.setRevisionStyles(u),i=true,l=g;}}function f(){!r||s||(s=true,queueMicrotask(()=>{s=false,d();}));}return {registerScheme(u){e.add(u),f();},register(u,g,p){o.has(u)||o.set(u,n++),t.set(u,{author:g,style:p}),f();},unregister(u){(e.delete(u)||t.delete(u))&&f();},connect(u){r=u;let g=a();i=u!==null&&g!==void 0,l=u===null?null:c(g),f();},current:a}}var Vr=pt.createContext(null);function tf(){let e=pt.useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function od(){let e=pt.useContext(Vr),t=tf();return pt.useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function nd(e){let{author:t,color:o,background:n,activeBackground:r,spanClassName:i,avatarUrl:a}=e,l=pt.useContext(Vr),s=tf();return pt.useEffect(()=>{if(l)return l.register(s,t,{...o!==void 0?{color:o}:{},...n!==void 0?{background:n}:{},...r!==void 0?{activeBackground:r}:{},...i!==void 0?{spanClassName:i}:{},...a!==void 0?{avatarUrl:a}:{}}),()=>l.unregister(s)},[l,s,t,o,n,r,i,a]),null}function of(){let e=0,t=0,o=null,n=new Set,r=new Set,i=new Set,a=l=>{for(let s of [...l])s();};return {getShift:()=>e,setShift(l){let s=Math.max(0,Math.round(l));s!==e&&(e=s,a(n));},subscribeShift(l){return n.add(l),()=>n.delete(l)},getReservation:()=>t,setReservation(l){let s=Math.max(0,Math.round(l));s!==t&&(t=s,a(r));},subscribeReservation(l){return r.add(l),()=>r.delete(l)},getViewport:()=>o,setViewport(l){l!==o&&(o=l,a(i));},subscribeViewport(l){return i.add(l),()=>i.delete(l)}}}var ad=pt.createContext(null);function Qo(){return pt.useContext(ad)}var nf=()=>0,id=()=>()=>{};function Jo(){let e=Qo(),t=pt.useCallback(n=>e?e.subscribeShift(n):id(),[e]),o=pt.useCallback(()=>e?e.getShift():0,[e]);return pt.useSyncExternalStore(t,o,nf)}function rf(){let e=Qo(),t=pt.useCallback(n=>e?e.subscribeReservation(n):id(),[e]),o=pt.useCallback(()=>e?e.getReservation():0,[e]);return pt.useSyncExternalStore(t,o,nf)}function eo(){let e=Qo(),t=pt.useCallback(r=>e?e.subscribeViewport(r):id(),[e]),o=pt.useCallback(()=>e?e.getViewport():null,[e]),n=pt.useCallback(()=>null,[]);return pt.useSyncExternalStore(t,o,n)}function wT(e,t){if(e===t)return true;let o=editor.resolveZoomMode(e),n=editor.resolveZoomMode(t);return o!==null&&n!==null&&editor.sameZoomMode(o,n)}function MT(e){let t=pt.useRef(e);t.current=e;let[o,n]=pt.useState(null),{onReady:r,onChange:i,onFontError:a,...l}=e,s=pt.useMemo(()=>({onReady:c=>{n(c),t.current.onReady?.(c);},onChange:c=>t.current.onChange?.(c),onFontError:c=>t.current.onFontError?.(c)}),[]);return {DocxEditorRoot:Gr,rootProps:l,rootListeners:s,editorRef:o}}function Gr(e){let{document:t,fonts:o,author:n,locale:r,translate:i,mode:a,zoom:l,zoomMode:s,tableInteractionLabel:c,imageDecodePort:d,children:f}=e,{t:u}=L(),g=pt.useCallback((w,I)=>u(w,I),[u]),p=pt.useRef(g);p.current=g;let m=pt.useRef(e);m.current=e;let[b,v]=pt.useState(null),x=pt.useRef(null);x.current??=Qm();let h=x.current;pt.useEffect(()=>{let w=m.current,I=w.translate??p.current,H=h.current(),N=editor.createDocxEditor({...w.document!==void 0?{document:w.document}:{},...w.fonts?{fonts:w.fonts}:{},...w.author!==void 0?{author:w.author}:{},...w.locale!==void 0?{locale:w.locale}:{},translate:I,...w.mode!==void 0?{mode:w.mode}:{},...H!==void 0?{revisionStyles:H}:{},...w.modules!==void 0?{modules:w.modules}:{},...w.zoom!==void 0?{zoom:w.zoom}:{},...w.zoomMode!==void 0?{zoomMode:w.zoomMode}:{},...w.tableInteractionLabel?{tableInteractionLabel:w.tableInteractionLabel}:{},...w.imageDecodePort?{imageDecodePort:w.imageDecodePort}:{},onFontError:P=>m.current.onFontError?.(P)}),_=N.on("change",P=>m.current.onChange?.(P));return v(N),()=>{_(),N.destroy(),v(P=>P===N?null:P);}},[t,o,d,h]),pt.useEffect(()=>{if(!b)return;if(!b.snapshot().isOpening){m.current.onReady?.(b);return}let w=b.on("change",()=>{w(),m.current.onReady?.(b);});return w},[b]);let y=pt.useRef({editor:null,zoom:void 0,mode:void 0});pt.useEffect(()=>{if(!b)return;y.current.editor!==b&&(y.current={editor:b,zoom:void 0,mode:void 0});let I=false;l!==void 0&&l!==y.current.zoom&&(y.current.zoom=l,b.setZoom(l),I=true);let H=y.current.mode,N=s!==void 0&&(H===void 0||!wT(H,s)),_=s===void 0?null:editor.resolveZoomMode(s),P=I&&s!==void 0&&_!==null&&_.type==="fit";(N||P)&&(y.current.mode=s,b.setZoomMode(s));},[b,l,s]),pt.useEffect(()=>{b&&b.setAuthor(n);},[b,n]);let T=pt.useRef({editor:null,value:void 0});pt.useEffect(()=>{if(b){if(T.current.editor!==b){T.current={editor:b,value:a};return}T.current.value!==a&&(T.current.value=a,b.setMode(a));}},[b,a]),pt.useEffect(()=>{b&&b.setTranslate(i??g);},[b,i,g]),pt.useEffect(()=>{b&&b.setLocale(r);},[b,r]),pt.useEffect(()=>{b&&b.setTableInteractionLabel(c??editor.defaultTableLabel);},[b,c]);let[C,E]=pt.useState(0),S=pt.useRef([]),D=pt.useMemo(()=>({mounted:C,register:()=>(E(w=>w+1),()=>E(w=>Math.max(0,w-1))),registerCommentDraft:w=>(S.current.push(w),()=>{let I=S.current.indexOf(w);I!==-1&&S.current.splice(I,1);}),requestCommentDraft:()=>{let w=S.current.at(-1);return w?(w(),true):false}}),[C]),R=pt.useMemo(of,[]);return pt.useEffect(()=>(h.connect(b),()=>h.connect(null)),[h,b]),jsxRuntime.jsx(mm,{value:i??g,children:jsxRuntime.jsx(Ct.Provider,{value:D,children:jsxRuntime.jsx(us.Provider,{value:b,children:jsxRuntime.jsx(ad.Provider,{value:R,children:jsxRuntime.jsx(Vr.Provider,{value:h,children:jsxRuntime.jsx(RT,{children:jsxRuntime.jsx(DT,{children:jsxRuntime.jsx(oi,{children:jsxRuntime.jsx(Qp,{value:e.popups,children:jsxRuntime.jsx(Wm,{popups:e.popups,children:f})})})})})})})})})})}function RT({children:e}){let t=ja(true);return jsxRuntime.jsx(gr.Provider,{value:t,children:e})}function DT({children:e}){let t=Qa();return jsxRuntime.jsx(ks.Provider,{value:t,children:e})}var ud=316,dd=44,LT=24,Ki={inlineStart:0,inlineEnd:ud},af={inlineStart:dd,inlineEnd:dd},FT={inlineStart:0,inlineEnd:0};function cf({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:n=0,docked:r=false}){if(!e)return af;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return Ki;let i=Number.isFinite(n)&&n>0?n:0;return t-i-o-2*LT>=ud?Ki:af}var AT=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,reviewPaneOpen:e.reviewPaneOpen??true,entitledZoom:t?.type==="fit"?t.maxZoom!==void 0&&t.maxZoom<editor.ZOOM_MAX?t.maxZoom:null:e.zoom}},HT=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function df(){let e=eo(),[t,o]=pt.useState(null);return pt.useEffect(()=>{if(!e){o(null);return}let n=()=>o(e.clientWidth);if(n(),typeof ResizeObserver>"u")return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e]),t}function jn(){let e=pt.useContext(Ct),{pageSetup:t,reviewPaneOpen:o,entitledZoom:n}=O(AT,HT),r=eo(),i=rf(),a=pt.useRef(null);t&&(a.current=t.pageWidthTwips);let l=t?.pageWidthTwips??a.current,s=(e?.mounted??0)>0,c=pt.useCallback(u=>s?cf({open:o,viewportWidth:u??0,pageWidthPx:l===null||n===null?0:Ee(l)*n,inlineStartReservation:i,docked:n===null}):FT,[s,o,l,n,i]),[d,f]=pt.useState(()=>c(r?r.clientWidth:null));return pt.useEffect(()=>{let u=()=>f(c(r?r.clientWidth:null));if(u(),!r||typeof ResizeObserver>"u")return;let g=new ResizeObserver(u);return g.observe(r),()=>g.disconnect()},[r,c]),d}var Wi=[.25,.5,.75,1,1.25,1.5,2];function Yr(e,t){return t==="in"?Wi.find(n=>n>e+.001)??null:[...Wi].reverse().find(n=>n<e-.001)??null}function uf(e,t){return e==="0"?1:e==="+"||e==="="?Yr(t,"in")??t:e==="-"?Yr(t,"out")??t:null}var BT=e=>e.reviewPaneOpen??true,ZT=e=>e.zoomMode?.type==="fit";function zi({className:e,style:t,children:o}){let n=dt(),r=F(),i=O(BT),a=jn(),l=O(ZT),c=(pt.useContext(Ct)?.mounted??0)>0,d=Qo(),f=Jo(),u=pt.useCallback(p=>d?.setViewport(p),[d]),g=pt.useCallback(p=>{if(!r||!(p.metaKey||p.ctrlKey)||p.altKey)return;let m=p.target;if(m instanceof Element&&m.closest('input, textarea, select, [role="dialog"]'))return;let b=uf(p.key,r.getZoom());b!==null&&(p.preventDefault(),r.setZoom(b));},[r]);return jsxRuntime.jsx("div",{ref:u,"data-testid":"docx-editor-scroll",onKeyDownCapture:g,...c?{"data-review-pane":i?"open":"closed"}:{},...l?{"data-zoom-fit":""}:{},className:`${n}docx-editor-one-surface docx-editor-one-surface__viewport docx-editor__scroll-container${e?` ${e}`:""}`,style:{...t,"--docx-nav-shift":`${f}px`,...c?{"--docx-review-gutter":`${a.inlineEnd}px`,"--docx-review-gutter-start":`${a.inlineStart}px`}:{}},children:jsxRuntime.jsx(Wo.Provider,{value:true,children:o})})}var KT=editor.LOADING_SNAPSHOT;function ff({ref:e,editorRef:t}){pt.useImperativeHandle(e,()=>({load:o=>t.current?.load(o),save:()=>t.current?.save()??Promise.resolve(null),getDocumentHandle:()=>t.current?.getDocumentHandle()??null,getEditor:()=>t.current,focus:()=>{t.current?.focus();},exec:(o,n)=>t.current?.exec(o,n)??{ok:false,code:"notFound",reason:"no editor is mounted"},snapshot:o=>t.current?.snapshot(o)??KT}),[t]);}var VT=e=>e.editingMode??"editing",md='[role="menuitemradio"]:not([disabled])',GT=(e,t)=>e.length===t.length&&e.every((o,n)=>o===t[n]),YT=e=>e.isLoading||e.isOpening===true,jr=[{mode:"editing",labelKey:"editingMode.editing",hintKey:"editingMode.editingHint",path:"M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z"},{mode:"suggesting",labelKey:"editingMode.suggesting",hintKey:"editingMode.suggestingHint",path:"M240-400h122l40-40H240v40Zm0-100h222l40-40H240v40Zm0-100h322l40-40H240v40ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v320h-80v-320H160v525l46-45h274v80H240L80-80Zm520-80v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T943-380L723-160H600Zm300-263-37-37 37 37ZM660-220h38l121-122-19-18-18-19-122 121v38Zm140-141-18-19 37 37-19-18Z"},{mode:"viewing",labelKey:"editingMode.viewing",hintKey:"editingMode.viewingHint",path:"M480-320q75 0 127.5-52.5T660-500q0-75-52.5-127.5T480-680q-75 0-127.5 52.5T300-500q0 75 52.5 127.5T480-320Zm0-72q-45 0-76.5-31.5T372-500q0-45 31.5-76.5T480-608q45 0 76.5 31.5T588-500q0 45-31.5 76.5T480-392Zm0 192q-146 0-266-81.5T40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200Z"}],jT=Object.freeze(jr.map(()=>null));function XT(e){return e?jr.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):jT}var QT="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function $i({className:e,hidden:t}){let o=F(),n=O(VT),r=O(YT),i=ee(),{t:a}=L(),[l,s]=pt.useState(false),c=pt.useRef(null),d=pt.useRef(null),f=pt.useRef(null);pt.useEffect(()=>{if(!l)return;let h=f.current?.querySelectorAll(md);(f.current?.querySelector(`${md}[aria-checked="true"]`)??h?.[0]??void 0)?.focus();},[l]);let u=pt.useCallback(h=>{let y=[...f.current?.querySelectorAll(md)??[]],T=y.indexOf(document.activeElement),C=E=>{h.preventDefault(),y[(E+y.length)%y.length]?.focus();};h.key==="ArrowDown"?C(T+1):h.key==="ArrowUp"?C(T-1):h.key==="Home"?C(0):h.key==="End"&&C(y.length-1);},[]);pt.useEffect(()=>{if(!l)return;let h=T=>{let C=c.current;C&&T.target instanceof Node&&C.contains(T.target)||s(false);},y=T=>{T.key==="Escape"&&(T.preventDefault(),s(false));};return document.addEventListener("mousedown",h,true),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",h,true),document.removeEventListener("keydown",y);}},[l]);let g=pt.useCallback(h=>{s(false),editor.runToolbarCommand(o,"review.editingMode",h),o?.focus();},[o]),p=editor.toolbarCommandState(o,"review.editingMode"),m=i18n.localizeDisabledReason(p.disabledReason,a),b=O(()=>XT(o),GT),v=pt.useMemo(()=>jr.find(h=>h.mode===n)??jr[0],[n]);if(t)return null;let x=Q("review.editingMode");return jsxRuntime.jsxs("div",{ref:c,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxRuntime.jsxs("button",{ref:d,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":n,"aria-haspopup":"menu","aria-expanded":l,"aria-label":i(x?.labelKey??"editingMode.label"),disabled:r||!p.enabled,...m?{title:m}:{},onMouseDown:Z,onClick:()=>s(h=>!h),children:[fd(v.path),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:i(v.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsxRuntime.jsx("div",{ref:f,className:"docx-toolbar__mode-menu",role:"menu","aria-label":i(x?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:jr.map((h,y)=>{let T=i18n.localizeDisabledReason(b[y]??null,a);return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":h.mode===n,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${h.mode}`,disabled:T!==null,...T?{title:T}:{},onMouseDown:Z,onClick:()=>g(h.mode),children:[fd(h.path),jsxRuntime.jsxs("span",{className:"docx-toolbar__mode-text",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__mode-label",children:i(h.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-hint",children:i(h.hintKey)})]}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:h.mode===n?fd(QT):null})]},h.mode)})}):null]})}$i.docxSlot="review.editingMode";function fd(e){return jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})})}var vf=[],tS=()=>{};function Xr(){let e=F(),t=pt.useCallback(o=>{if(!e)return tS;let n=pr(o),r=e.on("change",n),i=e.on("selectionChange",n);return ()=>{r(),i();}},[e]);return pt.useSyncExternalStore(t,()=>e?.getReviewAuthors()??vf,()=>vf)}var lS=e=>e.hiddenReviewAuthors??[];function Gi({className:e,hidden:t,icon:o}){let n=F(),r=Xr(),i=O(lS),a=new Set(i),l=r.every(y=>!a.has(y.author)),[s,c]=pt.useState(false),d=pt.useRef(null),f=pt.useRef(null),u=pt.useRef(null),g=ee(),{t:p}=L();pt.useEffect(()=>{if(!s)return;u.current?.querySelector('[role="menuitemcheckbox"]')?.focus();let y=C=>{d.current?.contains(C.target)||c(false);},T=C=>{C.key==="Escape"&&(C.preventDefault(),c(false),f.current?.focus());};return document.addEventListener("mousedown",y,true),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",y,true),document.removeEventListener("keydown",T);}},[s]);let m=pt.useCallback(y=>{let T=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],C=T.indexOf(document.activeElement),E=S=>{y.preventDefault(),T[(S+T.length)%T.length]?.focus();};y.key==="ArrowDown"?E(C+1):y.key==="ArrowUp"?E(C-1):y.key==="Home"?E(0):y.key==="End"?E(T.length-1):y.key==="Tab"&&c(false);},[]);if(t)return null;let b=Q("review.authors"),v=editor.toolbarCommandState(n,"review.authors"),x=i18n.localizeDisabledReason(v.disabledReason,p),h=g(b?.labelKey??"reviewers.label");return jsxRuntime.jsxs("div",{ref:d,className:`docx-toolbar__reviewers${e?` ${e}`:""}`,"data-slot":"review.authors",children:[jsxRuntime.jsxs("button",{ref:f,type:"button",className:"docx-toolbar__picker","data-testid":"reviewers-trigger","aria-haspopup":"menu","aria-expanded":s,"aria-label":h,disabled:!v.enabled,title:x??h,onMouseDown:Z,onClick:()=>c(y=>!y),children:[o??oe(b?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:h}),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),s?jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__reviewers-menu",role:"menu","aria-label":h,"data-testid":"reviewers-menu",onKeyDown:m,children:[jsxRuntime.jsx(yf,{checked:l,label:p("reviewers.all"),testId:"reviewer-all",onChoose:()=>n?.setAllReviewAuthorsVisible(!l)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),r.map(y=>jsxRuntime.jsx(yf,{checked:!a.has(y.author),label:y.author||"\u2014",testId:`reviewer-${y.slot}`,color:y.color,onChoose:()=>n?.setReviewAuthorVisible(y.author,a.has(y.author))},y.author))]}):null]})}Gi.docxSlot="review.authors";function yf(e){return jsxRuntime.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e.checked,className:"docx-toolbar__reviewer-item","data-testid":e.testId,onMouseDown:Z,onClick:e.onChoose,children:[jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:e.checked?"\u2713":""}),e.color?jsxRuntime.jsx("span",{className:"docx-toolbar__reviewer-swatch",style:{background:e.color}}):null,jsxRuntime.jsx("span",{className:"docx-toolbar__reviewer-name",children:e.label})]})}var xf=pt.createContext(null);function Cf({children:e}){let t=zr(),[o,n]=pt.useState(false),r=pt.useRef(null),i=pt.useMemo(()=>({open:l=>{if(t){t.open("paragraph",l);return}r.current=l??document.activeElement,n(true);}}),[t]),a=pt.useCallback(()=>{n(false);let l=r.current;r.current=null,l instanceof HTMLElement&&l.isConnected&&l.focus({preventScroll:true});},[]);return jsxRuntime.jsxs(xf.Provider,{value:i,children:[e,jsxRuntime.jsx(Jt,{open:o,onClose:a})]})}function Tf(){return pt.useContext(xf)}var bS=["zoom","script","format","list","alignment","styles","font","text","history"],bd=new Set(["review"]),hd=24,Pf=new Set;function Ef(e,t=bS){let o=t.filter(r=>e.includes(r));return [...e.filter(r=>!t.includes(r)).reverse(),...o]}function Sf(e,t){let{widths:o,groups:n,order:r,fixed:i,more:a}=e,l=i;for(let c of n)l+=o.get(c)??0;if(l<=t)return Pf;l+=a;let s=new Set;for(let c of r){if(l<=t)break;let d=o.get(c);d===void 0||s.has(c)||(s.add(c),l-=d);}return s}function wf(e,t){if(e===t)return true;if(e.size!==t.size)return false;for(let o of e)if(!t.has(o))return false;return true}var Mf=wf;function Rf(e){if(!(e.available>0))return Pf;let t=Sf(e,e.available),o=e.previous;if(!o||o.size===0||t.size>=o.size)return t;let n=Sf(e,e.available-(e.hysteresis));return wf(n,o)?o:n}function Df(e,t,o,n){return e+t+o+n*2}function kf(e,t){return e+t}function yd(e,t){return e+t}function If(e){let t=Number.parseFloat(e.marginInlineStart||e.marginLeft),o=Number.parseFloat(e.marginInlineEnd||e.marginRight);return {start:Number.isFinite(t)?t:0,end:Number.isFinite(o)?o:0}}function vd(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function _f(e){return vd(e.columnGap)}function Nf(e,t){return e.clientWidth-vd(t.paddingLeft)-vd(t.paddingRight)}var Xn="data-toolbar-group",Jr="data-toolbar-fixed",Cd="data-toolbar-more",xS=34,xd=new Set;function Ff(e,t,o){let n=pt.useRef(null),r=pt.useRef(new Map),i=pt.useRef(xS),[a,l]=pt.useState(xd),s=pt.useRef(a);s.current=a;let c=pt.useRef({groups:t,order:o});c.current={groups:t,order:o};let d=t.join("\0"),f=o.join("\0"),u=pt.useCallback(()=>{let p=n.current;if(!p||!e)return;let m=getComputedStyle(p),b=_f(m),v=Nf(p,m),x=p.querySelector(".docx-toolbar__separator"),h=b*2;if(x){let S=getComputedStyle(x),D=If(S);h=Df(x.offsetWidth,D.start,D.end,b);}for(let S of p.querySelectorAll(`[${Xn}]`)){let D=S.getAttribute(Xn);D&&S.offsetWidth>0&&r.current.set(D,kf(S.offsetWidth,h));}let y=0;for(let S of p.querySelectorAll(`[${Jr}]`))S.offsetWidth>0&&(y+=yd(S.offsetWidth,b));let T=p.querySelector(`[${Cd}]`);T&&T.offsetWidth>0&&(i.current=yd(T.offsetWidth,b));let C={available:v,widths:r.current,groups:c.current.groups,order:c.current.order,fixed:y,more:i.current,previous:s.current,hysteresis:hd},E=Rf(C);Mf(E,s.current)||(s.current=E,l(E));},[e]),g=pt.useCallback(p=>{n.current=p;},[]);return pt.useLayoutEffect(()=>{if(!e){s.current.size>0&&(s.current=xd,l(xd));return}u();},[e,d,u,f]),pt.useEffect(()=>{let p=n.current;if(!e||!p||typeof ResizeObserver>"u")return;let m=0,b=new ResizeObserver(()=>{m===0&&(m=requestAnimationFrame(()=>{m=0,u();}));});b.observe(p);for(let v of p.querySelectorAll(`[${Xn}], [${Jr}]`))b.observe(v);return ()=>{m!==0&&cancelAnimationFrame(m),b.disconnect();}},[e,d,u,f,a]),{attach:g,overflow:a}}var RS=["M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z"],Hf=pt.createContext({close:()=>{}});function DS(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function Of({label:e,children:t}){return jsxRuntime.jsxs("div",{className:"docx-toolbar__more-control",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-control-label",children:e}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-control-body",children:t})]})}function Bf({slot:e}){let t=ee(),o=Sn(),{close:n}=pt.useContext(Hf),{execute:r,isActive:i,isEnabled:a,disabledReason:l,value:s}=se(e),c=Q(e),d=editor.chromeSlotIsToggle(e),f=o(t(c?.labelKey??e));return jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__more-command","data-slot":e,disabled:!a,...l?{title:l}:{},...d?{"aria-pressed":i}:{},...i?{"data-active":""}:{},...s!==null?{"data-value":s}:{},onMouseDown:Z,onClick:u=>{r(),n(u.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:oe(c?.paths)}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:f})]})}function Zf({sections:e,className:t}){let o=ee(),[n,r]=pt.useState(false),i=pt.useRef(null),a=pt.useRef(null),l=pt.useRef(null),s=pt.useRef(false),c=pt.useId(),d=o("formattingBar.more"),f=pt.useCallback(p=>{r(false),p&&a.current?.focus();},[]),u=pt.useMemo(()=>({close:f}),[f]);pt.useEffect(()=>{if(!n)return;let p=m=>{let b=m.target;b instanceof Node&&i.current?.contains(b)||r(false);};return document.addEventListener("mousedown",p,true),()=>document.removeEventListener("mousedown",p,true)},[n]),pt.useEffect(()=>{if(!n||!s.current)return;s.current=false;let p=l.current;p&&DS(p);},[n]);let g=p=>{p.key!=="Escape"||p.defaultPrevented||(p.preventDefault(),f(true));};return jsxRuntime.jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[Cd]:"",children:[jsxRuntime.jsx("button",{ref:a,type:"button",className:"docx-toolbar__button docx-toolbar__more-trigger","data-slot":"toolbar.more","aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?c:void 0,"aria-label":d,title:d,...n?{"data-active":""}:{},onMouseDown:Z,onClick:()=>r(p=>!p),onKeyDown:p=>{p.key==="ArrowDown"&&(p.preventDefault(),s.current=true,r(true));},children:oe(RS)}),n?jsxRuntime.jsx(Hf.Provider,{value:u,children:jsxRuntime.jsx("div",{ref:l,id:c,role:"dialog","aria-label":d,className:"docx-toolbar__more-panel","data-testid":"toolbar-overflow-panel",onKeyDown:g,children:e.map(p=>jsxRuntime.jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":o(p.labelKey),children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:o(p.labelKey)}),p.children]},p.id))})}):null]})}var Sd=[{value:"inline",labelKey:"imageWrap.menu.inLineWithText",iconName:"wrap_text"},{value:"square",labelKey:"imageWrap.square",iconName:"crop_square"},{value:"squareLeft",labelKey:"imageWrap.menu.squareLeft",iconName:"format_image_left"},{value:"squareRight",labelKey:"imageWrap.menu.squareRight",iconName:"format_image_right"},{value:"tight",labelKey:"imageWrap.tight",iconName:"wrap_text"},{value:"through",labelKey:"imageWrap.through",iconName:"wrap_text"},{value:"topAndBottom",labelKey:"imageWrap.topAndBottom",iconName:"vertical_align_center"},{value:"behind",labelKey:"imageWrap.behindText",iconName:"flip_to_back"},{value:"inFront",labelKey:"imageWrap.inFrontOfText",iconName:"flip_to_front"}];function Qi({className:e,hidden:t,asChild:o,children:n}){let{t:r}=L(),i=ee(),{execute:a,value:l,isEnabled:s,disabledReason:c}=Or("image.wrap"),[d,f]=pt.useState(false),u=pt.useRef(null),g=pt.useRef(null),p=pt.useRef(null),m=pt.useId(),b=pt.useMemo(()=>Sd.find(C=>C.value===l)??Sd[0],[l]),v=Q("image.wrap"),x=i(v?.labelKey??"formattingBar.imageWrap");pt.useEffect(()=>{if(!d)return;let C=S=>{let D=u.current;D&&S.target instanceof Node&&D.contains(S.target)||f(false);},E=S=>{S.key==="Escape"&&(S.preventDefault(),f(false),g.current?.focus());};return document.addEventListener("mousedown",C,true),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",C,true),document.removeEventListener("keydown",E);}},[d]);let h=pt.useCallback(C=>{f(false),a(C);},[a]);if(t)return null;let y=r("imageWrap.tooltipPrefix",{label:r(b.labelKey)}),T={type:"button",ref:g,className:`docx-toolbar__button docx-toolbar__image-wrap-trigger${e?` ${e}`:""}`,"data-slot":"image.wrap",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?m:void 0,"aria-label":x,title:c??y,onMouseDown:Z,onClick:()=>f(C=>!C)};return jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsxRuntime.jsx(Y,{...T,children:n}):jsxRuntime.jsx("button",{...T,children:n??oe(v?.paths)}),d?jsxRuntime.jsx("div",{ref:p,id:m,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:C=>C.stopPropagation(),children:Sd.map(C=>jsxRuntime.jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":l===C.value,...l===C.value?{"data-active":""}:{},onMouseDown:Z,onClick:()=>h(C.value),children:r(C.labelKey)},C.value))}):null]})}Qi.docxSlot="image.wrap";var ea=Object.assign(Qi,{docxSlot:"image.wrap"});function qe(e){return Object.assign(o=>jsxRuntime.jsx(Lo,{slot:e,...o}),{docxSlot:e})}var qf=qe("history.undo"),Kf=qe("history.redo"),Wf=qe("text.bold"),zf=qe("text.italic"),Uf=qe("text.underline"),$f=qe("text.strike"),Vf=qe("format.clear"),Gf=qe("script.super"),Yf=qe("script.sub"),jf=qe("alignment.left"),Xf=qe("alignment.center"),Qf=qe("alignment.right"),Jf=qe("alignment.justify"),eg=qe("list.bullet"),tg=qe("list.numbered"),og=qe("list.outdent"),ng=qe("list.indent");var rg=qe("table.insert"),ag=qe("review.comments");function BS({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=F(),{openAtCaret:a}=vs(),l=editor.chromeProbeForSlot("text.link"),s=i&&l?i.can(l):null,c=s?.ok===true,{t:d}=L(),f=i18n.localizeDisabledReason(s&&!s.ok?s.reason:null,d),u=ee();if(t)return null;let g=Q("text.link"),p=u(g?.labelKey??"text.link"),m={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!c,...c?{}:{"data-disabled":""},"aria-label":p,title:f??p,onMouseDown:Z,onClick:()=>a()};return n?jsxRuntime.jsx(Y,{...m,children:r}):jsxRuntime.jsx("button",{...m,children:o??r??oe(g?.paths)})}var Pd=Object.assign(BS,{docxSlot:"text.link"});function ZS({className:e,hidden:t}){let o=F(),{onSave:n}=pt.useContext(No),r=ee();if(t)return null;let i=Q("file.save"),a=r(i?.labelKey??"file.save"),l=!o||!n;return jsxRuntime.jsx("button",{type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"file.save",disabled:l,...l?{"data-disabled":""}:{},"aria-label":a,title:a,onMouseDown:Z,onClick:()=>n?.(),children:oe(i?.paths)})}var Ed=Object.assign(ZS,{docxSlot:"file.save"});function tn({className:e}){return jsxRuntime.jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}var WS=e=>({zoom:e.zoom,mode:e.zoomMode}),zS=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,lg={type:"fixed"};function wd(){let e=F(),{zoom:t,mode:o}=O(WS,zS),n=pt.useCallback(i=>{e?.setZoom(i);},[e]),r=pt.useCallback(i=>{e?.setZoomMode(i);},[e]);return pt.useMemo(()=>{let i=o??lg,a=Yr(t,"out"),l=Yr(t,"in");return {zoom:t,mode:i,isFit:i.type==="fit",setZoom:n,setMode:r,fitToWidth:()=>r(editor.FIT_WIDTH_ZOOM_MODE),auto:()=>r("auto"),reset:()=>{r(lg),n(1);},zoomIn:()=>l!==null&&n(l),zoomOut:()=>a!==null&&n(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:Wi}},[e,t,o,n,r])}var na=2,ra=3276,oa=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],VS=e=>e.formatting?.fontSizePt??null;function dg(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function ug(e,t,o){for(let n=t.length-1;n>=0;n-=1)if(t[n]<e)return t[n];return Math.max(e-1,o)}function mg(e){return jsxRuntime.jsxs("span",{className:`docx-toolbar__stepper${e.className?` ${e.className}`:""}`,...e.slot!==void 0?{"data-slot":e.slot}:{},role:"group","aria-label":e.groupLabel,title:e.title??e.groupLabel,children:[jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canDecrease,"aria-label":e.decreaseLabel,onMouseDown:Z,onClick:e.onDecrease,children:"\u2212"}),e.middle,jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canIncrease,"aria-label":e.increaseLabel,onMouseDown:Z,onClick:e.onIncrease,children:"+"})]})}function GS(e){let t=e.trim().replace(/pt$/i,"").trim();if(t==="")return null;let o=Number(t);if(!Number.isFinite(o))return null;let n=Math.round(o*2);return n<na||n>ra?null:n}function YS({className:e,hidden:t}){let o=F(),n=O(VS),{isEnabled:r,disabledReason:i}=se("font.size"),a=ee(),[l,s]=pt.useState(false),[c,d]=pt.useState(null),f=pt.useRef(null),u=pt.useRef(null),g=pt.useCallback(T=>{if(!o)return;let C=editor.commandForSlotValue("font.size",T);C&&o.can(C).ok&&o.exec(C);},[o]),p=pt.useCallback(T=>{g(Math.min(ra,Math.max(na,Math.round(T*2))));},[g]),m=pt.useCallback(T=>{s(false),d(null),u.current?.blur(),T&&o?.focus();},[o]);if(pt.useEffect(()=>{if(!l)return;let T=C=>{let E=f.current;E&&C.target instanceof Node&&E.contains(C.target)||(s(false),d(null));};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[l]),t)return null;let b=r&&n!==null,v=n===null?"\u2014":String(Math.round(n*2)/2),x=c??v,h=n===null?null:Math.round(n*2)/2,y=()=>{if(c===null)return;let T=GS(c);T!==null&&g(T);};return jsxRuntime.jsxs("span",{ref:f,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsxRuntime.jsx(mg,{className:e,groupLabel:a("fontSize.label"),decreaseLabel:a("fontSize.decrease"),increaseLabel:a("fontSize.increase"),middle:jsxRuntime.jsx("input",{ref:u,type:"text",inputMode:"decimal",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--boxed docx-toolbar__font-size-input",value:x,disabled:!r,role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-label":a("fontSize.label"),autoComplete:"off",onChange:T=>{d(T.target.value),s(true);},onFocus:T=>{T.target.select(),s(true);},onClick:()=>s(true),onKeyDown:T=>{T.key==="Enter"?(T.preventDefault(),y(),m(true)):T.key==="Escape"?(T.preventDefault(),m(true)):(T.key==="ArrowDown"||T.key==="ArrowUp")&&(T.preventDefault(),s(true),n!==null&&p(T.key==="ArrowDown"?ug(n,oa,na/2):dg(n,oa,ra/2)));},onBlur:()=>{y(),d(null);}}),canDecrease:b&&Math.round(n*2)>na,canIncrease:b&&Math.round(n*2)<ra,onDecrease:()=>p(ug(n??0,oa,na/2)),onIncrease:()=>p(dg(n??0,oa,ra/2))}),l&&r?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox","aria-label":a("fontSize.listLabel"),children:oa.map(T=>{let C=h===T;return jsxRuntime.jsx("button",{type:"button",role:"option","aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>{p(T),m(true);},children:T},T)})}):null]})}var Dd=Object.assign(YS,{docxSlot:"font.size"});function jS({className:e,hidden:t}){let o=F(),{zoom:n,isFit:r,mode:i,setZoom:a,setMode:l,zoomIn:s,zoomOut:c,canZoomIn:d,canZoomOut:f,levels:u}=wd(),g=ee(),[p,m]=pt.useState(false),b=pt.useRef(null);pt.useEffect(()=>{if(!p)return;let C=E=>{let S=b.current;S&&E.target instanceof Node&&S.contains(E.target)||m(false);};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[p]);let v=pt.useCallback(C=>{m(false),a(C);},[a]),x=pt.useCallback(C=>{m(false),l(C==="auto"?"auto":editor.FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let h=`${Math.round(n*100)}%`,y=editor.sameZoomMode(i,editor.AUTO_ZOOM_MODE),T=editor.sameZoomMode(i,editor.FIT_WIDTH_ZOOM_MODE);return jsxRuntime.jsxs("span",{ref:b,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsxRuntime.jsx(mg,{className:e,groupLabel:g("zoom.zoomLevel"),decreaseLabel:g("zoom.zoomOut"),increaseLabel:g("zoom.zoomIn"),middle:jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--menu",disabled:!o,"aria-haspopup":"listbox","aria-expanded":p,"aria-label":g("zoom.zoomLevel"),onMouseDown:Z,onClick:()=>m(C=>!C),children:[h,jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:f,canIncrease:d,onDecrease:c,onIncrease:s}),p?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__zoom-menu",role:"listbox","aria-label":g("zoom.zoomLevel"),children:[jsxRuntime.jsx("button",{type:"button",role:"option","aria-selected":y,...y?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>x("auto"),children:g("zoom.automatic")}),jsxRuntime.jsx("button",{type:"button",role:"option","aria-selected":T,...T?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>x("fit-width"),children:g("zoom.fitWidth")}),jsxRuntime.jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(C=>{let E=!r&&Math.abs(C-n)<.001;return jsxRuntime.jsx("button",{type:"button",role:"option","aria-selected":E,...E?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>v(C),children:`${Math.round(C*100)}%`},C)})]}):null]})}var kd=Object.assign(jS,{docxSlot:"zoom.level"});var eP=[1,1.15,1.5,2,2.5,3],bg=10,hg=0,tP=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),oP=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function nP({className:e,hidden:t}){let o=F(),n=O(tP,oP),{isEnabled:r,disabledReason:i}=se("list.lineSpacing"),a=se("paragraph.dialog"),l=Tf(),s=ee(),[c,d]=pt.useState(false),f=pt.useRef(null),u=pt.useRef(null);pt.useEffect(()=>{if(!c)return;let h=y=>{let T=f.current;T&&y.target instanceof Node&&T.contains(y.target)||d(false);};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[c]);let g=pt.useCallback(h=>{if(d(false),!o)return;let y=editor.commandForSlotValue("list.lineSpacing",h);y&&o.can(y).ok&&o.exec(y);},[o]),p=pt.useCallback((h,y)=>{if(d(false),!o)return;let T={type:"setParagraphSpacing",[h]:y};o.can(T).ok&&o.exec(T);},[o]);if(t)return null;let m=Q("list.lineSpacing"),b=(n.spaceBeforePt??0)>0,v=(n.spaceAfterPt??0)>0,x=n.lineSpacing?.rule==="multiple"?n.lineSpacing?.value??null:null;return jsxRuntime.jsxs("span",{ref:f,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxRuntime.jsxs("button",{ref:u,type:"button",className:`docx-toolbar__button docx-toolbar__line-spacing-trigger${e?` ${e}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":c,"aria-label":s("lineSpacing.label"),title:i??s("lineSpacing.label"),onMouseDown:Z,onClick:()=>d(h=>!h),children:[oe(m?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),c&&r?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[eP.map(h=>{let y=x===h;return jsxRuntime.jsx("button",{type:"button",role:"menuitemradio","aria-checked":y,...y?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>g(h),children:Number.isInteger(h*10)?h.toFixed(1):h.toFixed(2)},h)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item","data-slot":"paragraph.dialog",disabled:!a.isEnabled,title:a.disabledReason??void 0,onMouseDown:Z,onClick:()=>{d(false),l?.open(u.current);},children:s("lineSpacing.options")}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>p("beforePt",b?hg:bg),children:s(b?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:Z,onClick:()=>p("afterPt",v?hg:bg),children:s(v?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var _d=Object.assign(nP,{docxSlot:"list.lineSpacing"});var cP=[{value:"C00000",labelKey:"colorPicker.colors.darkRed",css:"#c00000"},{value:"FF0000",labelKey:"colorPicker.colors.red",css:"#ff0000"},{value:"FFC000",labelKey:"colorPicker.colors.orange",css:"#ffc000"},{value:"FFFF00",labelKey:"colorPicker.colors.yellow",css:"#ffff00"},{value:"92D050",labelKey:"colorPicker.colors.lightGreen",css:"#92d050"},{value:"00B050",labelKey:"colorPicker.colors.green",css:"#00b050"},{value:"00B0F0",labelKey:"colorPicker.colors.lightBlue",css:"#00b0f0"},{value:"0070C0",labelKey:"colorPicker.colors.blue",css:"#0070c0"},{value:"002060",labelKey:"colorPicker.colors.darkBlue",css:"#002060"},{value:"7030A0",labelKey:"colorPicker.colors.purple",css:"#7030a0"}],vg=[{value:"yellow",labelKey:"colorPicker.colors.yellow",css:"#ffff00"},{value:"green",labelKey:"colorPicker.colors.brightGreen",css:"#00ff00"},{value:"cyan",labelKey:"colorPicker.colors.cyan",css:"#00ffff"},{value:"magenta",labelKey:"colorPicker.colors.magenta",css:"#ff00ff"},{value:"blue",labelKey:"colorPicker.colors.blue",css:"#0000ff"},{value:"red",labelKey:"colorPicker.colors.red",css:"#ff0000"},{value:"darkBlue",labelKey:"colorPicker.colors.darkBlue",css:"#000080"},{value:"darkCyan",labelKey:"colorPicker.colors.darkCyan",css:"#008080"},{value:"darkGreen",labelKey:"colorPicker.colors.darkGreen",css:"#008000"},{value:"darkMagenta",labelKey:"colorPicker.colors.darkMagenta",css:"#800080"},{value:"darkRed",labelKey:"colorPicker.colors.darkRed",css:"#800000"},{value:"darkYellow",labelKey:"colorPicker.colors.darkYellow",css:"#808000"},{value:"darkGray",labelKey:"colorPicker.colors.darkGray",css:"#808080"},{value:"lightGray",labelKey:"colorPicker.colors.lightGray",css:"#c0c0c0"},{value:"black",labelKey:"colorPicker.colors.black",css:"#000000"},{value:"white",labelKey:"colorPicker.colors.white",css:"#ffffff"}],yg=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Ji=["colorPicker.theme.background1","colorPicker.theme.text1","colorPicker.theme.background2","colorPicker.theme.text2","colorPicker.theme.accent1","colorPicker.theme.accent2","colorPicker.theme.accent3","colorPicker.theme.accent4","colorPicker.theme.accent5","colorPicker.theme.accent6"],xo=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),bt=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function dP(e){let t=[0,2,4].map(n=>parseInt(e.slice(n,n+2),16)),o=(Math.max(...t)+Math.min(...t))/2/255;return o===1?[bt(5),bt(15),bt(25),bt(35),bt(50)]:o===0?[xo(50),xo(35),xo(25),xo(15),xo(5)]:o>=.8?[bt(10),bt(25),bt(50),bt(75),bt(90)]:[xo(80),xo(60),xo(40),bt(25),bt(50)]}var uP=/^[0-9A-Fa-f]{6}$/;function pP(e,t){let o="";for(let n=0;n<6;n+=2){let r=Math.round(t(parseInt(e.slice(n,n+2),16)));o+=Math.max(0,Math.min(255,r)).toString(16).padStart(2,"0");}return o.toUpperCase()}function mP(e){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),n=parseInt(e.slice(4,6),16);return .299*t+.587*o+.114*n>230}function el({value:e,css:t,title:o,selected:n,apply:r}){return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch",style:{backgroundColor:t},"aria-label":o,title:o,"data-value":e,...n?{"data-selected":""}:{},...mP(t.replace("#",""))?{"data-light":""}:{},onMouseDown:Z,onClick:()=>r(e)})}function fP({apply:e,label:t,current:o,themeHexes:n}){let r=n.map(dP),i=[0,1,2,3,4];return jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.themeColors")}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--theme",role:"group",children:[n.map((a,l)=>jsxRuntime.jsx(el,{value:a,css:`#${a.toLowerCase()}`,title:t(Ji[l]),selected:o===a,apply:e},`base-${l}`)),i.map(a=>n.map((l,s)=>{let c=r[s][a],d=pP(l,c.apply);return jsxRuntime.jsx(el,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Ji[s])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${s}`)}))]})]})}function gP(e){let{apply:t,label:o,current:n}=e,[r,i]=pt.useState(""),a=uP.test(r);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(fP,{...e}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.standardColors")}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid",role:"group",children:cP.map(l=>jsxRuntime.jsx(el,{value:l.value,css:l.css,title:o(l.labelKey),selected:n===l.value,apply:t},l.value))})]}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.customColor")}),jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-custom",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-hash","aria-hidden":"true",children:"#"}),jsxRuntime.jsx("input",{type:"text",className:"docx-toolbar__swatch-hex",value:r,maxLength:6,spellCheck:false,"aria-label":o("colorPicker.customColor"),onChange:l=>i(l.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:l=>{l.key==="Enter"&&a&&t(r.toUpperCase());}}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!a,onMouseDown:Z,onClick:()=>t(r.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function Ld({apply:e,current:t}){let o=F(),n=ee(),r=o?.getDocumentThemeColors()??[],i=r.length===Ji.length?r.map(l=>l.hex):yg,a=t?.toUpperCase()??null;return jsxRuntime.jsx(gP,{apply:e,label:n,current:a,themeHexes:i})}var bP=vg.filter(e=>e.value!=="white");function hP({apply:e,label:t,current:o}){return jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.highlightColors")}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--highlight",role:"group",children:bP.map(n=>jsxRuntime.jsx(el,{value:n.value,css:n.css,title:t(n.labelKey),selected:o===n.value,apply:e},n.value))})]})}function xg(e){let{slot:t,defaultValue:o,cssOf:n,clear:r,body:i}=e,a=t==="text.color";return Object.assign(({className:s,hidden:c,icon:d})=>{let f=F(),{isEnabled:u,disabledReason:g}=se(t),p=ee(),[m,b]=pt.useState(false),[v,x]=pt.useState(o),h=pt.useRef(null),y=O(R=>{if(a){let w=R.formatting?.color;return w&&w.kind==="hex"?w.value.toUpperCase():null}return R.formatting?.highlight??null}),T=f?.getDocumentThemeColors()??[],C=T.length===Ji.length?T.map(R=>R.hex):yg;pt.useEffect(()=>{if(!m)return;let R=w=>{let I=h.current;I&&w.target instanceof Node&&I.contains(w.target)||b(false);};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[m]);let E=pt.useCallback(R=>{if(b(false),!f)return;let w=editor.commandForSlotValue(t,R);w&&f.can(w).ok&&(f.exec(w),R!==r.value&&x(R));},[f]),S=pt.useMemo(()=>Q(t),[]);if(c)return null;let D=p(S?.labelKey??t);return jsxRuntime.jsxs("div",{ref:h,className:`docx-toolbar__colorsplit${s?` ${s}`:""}`,"data-slot":t,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__colorsplit-main",disabled:!u,...u?{}:{"data-disabled":""},"aria-label":D,title:g??D,onMouseDown:Z,onClick:()=>E(v),children:[d??oe(S?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:n(v)},"aria-hidden":"true"})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!u,...u?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":m,"aria-label":D,title:g??D,onMouseDown:Z,onClick:()=>b(R=>!R),children:"\u25BE"}),m?jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":D,onMouseDown:Z,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:Z,onClick:()=>E(r.value),children:[jsxRuntime.jsx("span",{className:`docx-toolbar__swatch-clear-chip${r.value==="none"?" docx-toolbar__swatch-clear-chip--none":""}`,"aria-hidden":"true"}),p(r.labelKey)]}),i({apply:E,label:p,current:y,themeHexes:C})]}):null]})},{docxSlot:t})}var vP=new Map(vg.map(e=>[e.value,e.css])),Fd=xg({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsxRuntime.jsx(Ld,{apply:e.apply,current:e.current})}),Ad=xg({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>vP.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsxRuntime.jsx(hP,{...e})});var SP=["alignment.left","alignment.center","alignment.right","alignment.justify"];function PP({className:e,hidden:t}){let o=se("alignment.left"),n=se("alignment.center"),r=se("alignment.right"),i=se("alignment.justify"),a=ee(),[l,s]=pt.useState(false),c=pt.useRef(null);if(pt.useEffect(()=>{if(!l)return;let m=b=>{let v=c.current;v&&b.target instanceof Node&&v.contains(b.target)||s(false);};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),t)return null;let d=[o,n,r,i],f=SP.map((m,b)=>({slot:m,control:Q(m),state:d[b]})),u=f.find(m=>m.state.isActive)??f[0],g=f.some(m=>m.state.isEnabled),p=a(u.control?.labelKey??u.slot);return jsxRuntime.jsxs("div",{ref:c,className:`docx-toolbar__alignment${e?` ${e}`:""}`,"data-slot":"alignment",children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-trigger",disabled:!g,...g?{}:{"data-disabled":""},"aria-haspopup":"true","aria-expanded":l,"aria-label":p,title:g?p:u.state.disabledReason??p,onMouseDown:Z,onClick:()=>s(m=>!m),children:[oe(u.control?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__alignment-popup",children:f.map(m=>{let b=a(m.control?.labelKey??m.slot);return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-option","data-slot":m.slot,disabled:!m.state.isEnabled,...m.state.isActive?{"data-active":""}:{},"aria-pressed":m.state.isActive,"aria-label":b,title:m.state.disabledReason??b,onMouseDown:Z,onClick:()=>{m.state.execute(),s(false);},children:oe(m.control?.paths)},m.slot)})}):null]})}var tl=Object.assign(PP,{docxSlot:"alignment"});function Od(e){let{label:t,icon:o,active:n,disabled:r,disabledReason:i,onSelect:a,asChild:l,className:s,children:c}=e,d={type:"button",className:`docx-toolbar__button${s?` ${s}`:""}`,disabled:r,...n?{"data-active":""}:{},...r?{"data-disabled":""}:{},...n!==void 0?{"aria-pressed":n}:{},"aria-label":t,title:r?i??t:t,onMouseDown:f=>Z(f),onClick:r?void 0:a};return l?jsxRuntime.jsx(Y,{...d,children:c}):jsxRuntime.jsx("button",{...d,children:o??c})}var kP=Object.freeze([]),IP=e=>e.formatting?.fontFamily??null,_P=e=>e;function nl(){let e=F(),t=O(IP),o=O(_P),n=pt.useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():kP,[e,o]),{isEnabled:r}=se("font.family"),i=pt.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return pt.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var Eg=pt.createContext(null);function Zd(){return pt.useContext(Eg)}function qd({asChild:e,className:t,children:o}){let n=Zd(),r=ee();if(!n)return null;let i=r(Q("font.family")?.labelKey??"font.family"),a={onClick:()=>n.setOpen(!n.open),onMouseDown:Z,disabled:!n.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,"aria-label":i,title:i},l=o??jsxRuntime.jsx("span",{children:n.value??"\u2014"});return e?jsxRuntime.jsx(Y,{...a,children:l}):jsxRuntime.jsx("button",{type:"button",...a,children:l})}qd.docxToolbarPart=true;var NP=new Map([["arial","sansSerif"],["calibri","sansSerif"],["helvetica","sansSerif"],["verdana","sansSerif"],["open sans","sansSerif"],["roboto","sansSerif"],["times new roman","serif"],["georgia","serif"],["cambria","serif"],["garamond","serif"],["courier new","monospace"],["consolas","monospace"]]),LP=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function wg({asChild:e,className:t,children:o}){let n=Zd(),r=ee(),[i,a]=pt.useState("");if(pt.useEffect(()=>{n?.open||a("");},[n?.open]),!n||!n.open)return null;let l={role:"listbox",className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`},s;return o!==void 0?s=o:s=LP.map(d=>({...d,fonts:n.options.filter(f=>f.toLowerCase().includes(i.toLowerCase())&&(NP.get(f.toLowerCase())??"other")===d.category)})).filter(d=>d.fonts.length>0).map((d,f)=>jsxRuntime.jsxs("div",{role:"group",children:[f>0?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}):null,d.labelKey?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-label",children:r(d.labelKey)}):null,d.fonts.map(u=>jsxRuntime.jsx(Mg,{value:u},u))]},d.category)),e?jsxRuntime.jsx(Y,{...l,children:s}):o!==void 0?jsxRuntime.jsx("div",{...l,children:s}):jsxRuntime.jsxs("div",{className:l.className,children:[jsxRuntime.jsx("input",{type:"search",className:"docx-toolbar__font-search","aria-label":r("font.search"),placeholder:r("font.search"),value:i,onChange:c=>a(c.target.value)}),jsxRuntime.jsx("div",{role:"listbox",className:"docx-toolbar__font-options",children:s})]})}function Mg({value:e,asChild:t,className:o,children:n}){let r=F(),i=Zd();if(!i)return null;let a=i.value===e,l={role:"option","aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:Z,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__font-family-item${o?` ${o}`:""}`},s=n??jsxRuntime.jsx("span",{style:{fontFamily:e},children:e});return t?jsxRuntime.jsx(Y,{...l,children:s}):jsxRuntime.jsxs("button",{type:"button",...l,children:[s,a?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function FP({hidden:e,asChild:t,className:o,children:n}){let r=nl(),[i,a]=pt.useState(false),l=pt.useRef(null);pt.useEffect(()=>{if(!i)return;let f=u=>{let g=l.current;g&&u.target instanceof Node&&g.contains(u.target)||a(false);};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i]);let s=pt.useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);if(e)return null;let c={className:`docx-toolbar__font-family${o?` ${o}`:""}`,"data-slot":"font.family"},d=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(qd,{}),jsxRuntime.jsx(wg,{})]});return jsxRuntime.jsx(Eg.Provider,{value:s,children:t?jsxRuntime.jsx(Y,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Kd=Object.assign(FP,{docxSlot:"font.family",Trigger:qd,Content:wg,Item:Mg});var HP={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},OP=new Set(["Title","Heading1","Heading2","Heading3"]),BP={Subtitle:"666666"},ZP="#4a6c8c";function Rg(e){let t=HP[e.styleId],n={fontSize:t?`${t}px`:`${Math.min(Math.max(e.fontSize?e.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(e.bold??OP.has(e.styleId))&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic");let r=e.color??BP[e.styleId];return r?n.color=`#${r}`:e.styleId.startsWith("Heading")&&(n.color=ZP),n}var qP=/^heading ([1-9])$/;function Wd(e,t){let o=e||t,n=qP.exec(o);return n?`Heading ${n[1]}`:o}function Dg(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:Wd(t.name,t.styleId),priority:99}))}function YP(e){let t=e.fontSizePt;return {...e.fontFamily?{fontFamily:e.fontFamily}:{},...t?{fontSize:`${Math.min(Math.max(t,9),20)}px`}:{},...e.bold?{fontWeight:700}:{},...e.italic?{fontStyle:"italic"}:{},...e.color?{color:`#${e.color}`}:{}}}var jP=Object.freeze([]),XP=e=>e.formatting?.styleId??null,QP=e=>e;function rl(){let e=F(),t=O(XP),o=O(QP),n=pt.useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(a=>a.type==="paragraph").map(a=>({styleId:a.styleId,name:Wd(a.name,a.styleId),preview:a.preview})):jP,[e,o]),{isEnabled:r}=se("styles.style"),i=pt.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("styles.style",a);l&&e.can(l).ok&&e.exec(l);},[e]);return pt.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var kg=pt.createContext(null);function Ud(){return pt.useContext(kg)}function $d({asChild:e,className:t,children:o}){let n=Ud(),r=ee();if(!n)return null;let i=Q("styles.style"),a=r(i?.labelKey??"styles.style"),l={onClick:()=>n.setOpen(!n.open),onMouseDown:Z,disabled:!n.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,"aria-label":a,title:a},s=n.options.find(d=>d.styleId===n.value),c=o??(n.value===null?jsxRuntime.jsx("span",{children:i?.valueKey?r(i.valueKey):"\u2014"}):jsxRuntime.jsx("span",{children:s?.name??n.value}));return e?jsxRuntime.jsx(Y,{...l,children:c}):jsxRuntime.jsx("button",{type:"button",...l,children:c})}$d.docxToolbarPart=true;function Ig({asChild:e,className:t,children:o}){let n=Ud();if(!n||!n.open)return null;let r={role:"listbox",className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`},i=o??n.options.map(a=>jsxRuntime.jsx(_g,{value:a.styleId},a.styleId));return e?jsxRuntime.jsx(Y,{...r,children:i}):jsxRuntime.jsx("div",{...r,children:i})}function _g({value:e,asChild:t,className:o,children:n}){let r=Ud();if(!r)return null;let i=r.value===e,a=r.options.find(c=>c.styleId===e),l={role:"option","aria-selected":i,...i?{"data-selected":""}:{},onMouseDown:Z,onClick:()=>{r.setValue(e),r.setOpen(false);},className:`docx-toolbar__style-item${o?` ${o}`:""}`},s=n??jsxRuntime.jsx("span",{style:a?YP(a.preview):void 0,children:a?.name??e});return t?jsxRuntime.jsx(Y,{...l,children:s}):jsxRuntime.jsxs("button",{type:"button",...l,children:[s,i?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function JP({hidden:e,asChild:t,className:o,children:n}){let r=rl(),[i,a]=pt.useState(false),l=pt.useRef(null);pt.useEffect(()=>{if(!i)return;let f=u=>{let g=l.current;g&&u.target instanceof Node&&g.contains(u.target)||a(false);};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[i]);let s=pt.useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);if(e)return null;let c={className:`docx-toolbar__style${o?` ${o}`:""}`,"data-slot":"styles.style"},d=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx($d,{}),jsxRuntime.jsx(Ig,{})]});return jsxRuntime.jsx(kg.Provider,{value:s,children:t?jsxRuntime.jsx(Y,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Vd=Object.assign(JP,{docxSlot:"styles.style",Trigger:$d,Content:Ig,Item:_g});function Lg(e,t){let o=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:l,children:s})=>{let{isEnabled:c,disabledReason:d}=se(o),f=Lt(),u=t==="showAll"?f.showAll:f.formFill,g=ee();if(i)return null;let p=Q(o),m=g(p?.labelKey??e),b={type:"button",className:`docx-toolbar__button${r?` ${r}`:""}`,"data-slot":e,disabled:!c,...c?{}:{"data-disabled":""},...u?{"data-active":""}:{},"aria-pressed":u,"aria-label":m,title:d??m,onMouseDown:Z,onClick:()=>{t==="showAll"?f.toggleShowAll():f.toggleFormFill();}};return l?jsxRuntime.jsx(Y,{...b,children:s}):jsxRuntime.jsx("button",{...b,children:a??s??oe(p?.paths)})},{docxSlot:o})}function tE({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=rt.inspector,{isEnabled:a,disabledReason:l}=se(i),{inspectorOpen:s,openInspector:c}=Lt(),d=ee();if(t)return null;let f=Q(i),u=d(f?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":rt.inspector,disabled:!a,...a?{}:{"data-disabled":""},...s?{"data-active":""}:{},"aria-pressed":s,"aria-label":u,title:l??u,onMouseDown:Z,onClick:()=>c()};return n?jsxRuntime.jsx(Y,{...g,children:r}):jsxRuntime.jsx("button",{...g,children:o??r??oe(f?.paths)})}function oE({className:e,hidden:t,icon:o,asChild:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l}=Lt(),s=ee();if(t)return null;let c=rt.remove,d=Q(c),f=s(d?.labelKey??"contentControl.remove"),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":rt.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":f,title:a??f,onMouseDown:Z,onClick:()=>{l();}};return n?jsxRuntime.jsx(Y,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??oe(d?.paths)})}var al=Lg(rt.showAll,"showAll"),il=Lg(rt.formFill,"formFill"),ll=Object.assign(oE,{docxSlot:rt.remove}),sl=Object.assign(tE,{docxSlot:rt.inspector}),Fg={[rt.showAll]:al,[rt.formFill]:il,[rt.inspector]:sl,[rt.remove]:ll};function Gd(e,t){let o=F(),n=pt.useRef(t);n.current=t,pt.useEffect(()=>{if(!o)return;let r=((...i)=>{n.current(...i);});return o.on(e,r)},[o,e]);}var cE=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],jd=pt.createContext(null);function Kg(){let e=pt.useContext(jd);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function uE(e,t){let o=t.table,r=(e?.getSelectedTable()??null)?.blockId??"",i=o?`${r}|${o.rows}|${o.columns}|${o.rowIndex}|${o.columnIndex}`:"",a=t.selection,l=a?`${a.from&&"paraId"in a.from?a.from.paraId:""}|${a.to&&"paraId"in a.to?a.to.paraId:""}|${t.selectionCollapsed}`:"",s=e?.getTableCellSelection()??null,c=s?`${s.tableId}|${s.rows.from}-${s.rows.to}|${s.columns.from}-${s.columns.to}|${s.cellIds.join(",")}`:"";return {tableKey:i,selectionKey:l,cellSelectionKey:c,editable:t.editable,editingMode:t.editingMode??"editing"}}function pE(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function mE(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var Zg={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function fE(e,t){let o={};for(let n of cE){let r=editor.tableChromeToolbarState(e,n,t);o[n]={enabled:r.enabled,disabledReason:r.disabledReason};}return o}function Xd({children:e}){let t=F(),[o,n]=pt.useState(editor.DEFAULT_TABLE_CHROME_DRAFT),[r,i]=pt.useState(Zg);pt.useEffect(()=>(()=>{}),[]);let a=O(pt.useCallback(u=>({table:u.table,editable:u.editable,editingMode:u.editingMode??"editing",headParagraphId:u.selection?.to&&"paraId"in u.selection.to?u.selection.to.paraId:u.selection?.from&&"paraId"in u.selection.from?u.selection.from.paraId:""}),[]),pE,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=pt.useCallback(()=>{if(!t){i(Zg);return}let u=uE(t,t.snapshot());i(g=>mE(g,u)?g:u);},[t]);pt.useEffect(()=>{l();},[l,a]),Gd("selectionChange",pt.useCallback(()=>{l();},[l]));let s=r.tableKey!=="",c=pt.useMemo(()=>t?fE(t,o):{},[t,o,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=pt.useCallback((u,g)=>{if(!t)return;let{result:p,nextDraft:m}=editor.runTableChromeCommand(t,u,g,o);p.ok&&m&&n(m);},[t,o]),f=pt.useMemo(()=>({visible:s,draft:o,setDraft:n,slotState:u=>c[u]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[s,o,c,d]);return jsxRuntime.jsx(jd.Provider,{value:f,children:e})}function gE(){let e=pt.useContext(jd);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function dl(e){let t=gE(),o=t.slotState(e);return pt.useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:n=>t.apply(e,n)}),[t,e,o])}function ul(e){let t=e?.closest(".docx-editor")??null;for(;t&&!t.querySelector(".docx-pages");)t=t.parentElement?.closest(".docx-editor")??null;return t}function pl(e){(ul(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function Jd(e,t,o){pt.useEffect(()=>{if(!e)return;let n=r=>{let i=o.current;i&&r.target instanceof Node&&i.contains(r.target)||t(false);};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[e,t,o]);}function ml({enabled:e,disabledReason:t,ariaLabel:o}){let{t:n}=L(),r=i18n.localizeDisabledReason(t,n),i=pt.useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:Z,"aria-label":o,...a?{"aria-describedby":a}:{},...r?{title:r}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:a&&r?jsxRuntime.jsx("span",{id:i,className:"docx-editor-sr-only",children:r}):null}}var yE='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function Wg(e,t,o,n){pt.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll(yE)].filter(c=>c.closest('[role="menu"]')===r);queueMicrotask(()=>{let c=a();(c.find(f=>f.hasAttribute("data-selected")||f.hasAttribute("data-active"))??c[0])?.focus();});let s=c=>{let d=a();if(c.key==="Escape"){c.preventDefault(),t(false),i?.focus();return}if(c.key==="ArrowDown"){c.preventDefault(),St(d,document.activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),St(d,document.activeElement,-1);return}if(c.key==="Home"){c.preventDefault(),Pt(d,"first");return}if(c.key==="End"){c.preventDefault(),Pt(d,"last");return}if(c.key==="Enter"||c.key===" "){let f=document.activeElement;f instanceof HTMLElement&&d.includes(f)&&(c.preventDefault(),f.click());}};return r.addEventListener("keydown",s),()=>r.removeEventListener("keydown",s)},[e,t,o,n]);}function zg(e,t,o,n){pt.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll('button:not([aria-disabled="true"])')].filter(s=>s.closest('[role="dialog"]')===r);queueMicrotask(()=>{a()[0]?.focus();});let l=s=>{if(s.key==="Escape"){s.preventDefault(),t(false),i?.focus();return}if(s.key==="Enter"||s.key===" "){let c=document.activeElement,d=a();c instanceof HTMLElement&&d.includes(c)&&(s.preventDefault(),c.click());}};return r.addEventListener("keydown",l),()=>r.removeEventListener("keydown",l)},[e,t,o,n]);}function Yg(e,t,o){if(e)return n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),o(!t));}}function wE(e){return oe(editor.tableChromeIconPaths(e))}function jg(){return pt.createContext(null)}function oo(e){let t=pt.useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function tu(e,t,o){let n=jg();function r({hidden:l,asChild:s,className:c,children:d}){let{visible:f,enabled:u,disabledReason:g,draft:p,apply:m}=dl(e),[b,v]=pt.useState(false),x=pt.useRef(null),h=pt.useRef(null);Jd(b,v,x);let y=pt.useMemo(()=>({open:b,setOpen:v,enabled:u,disabledReason:g,apply:m,draft:p,triggerRef:h}),[b,u,g,m,p]);if(l||!f)return null;let T={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},C=d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(i,{}),jsxRuntime.jsx(a,{})]});return jsxRuntime.jsx(n.Provider,{value:y,children:s?jsxRuntime.jsx(Y,{...T,ref:x,children:C}):jsxRuntime.jsx("div",{ref:x,...T,children:C})})}function i({asChild:l,className:s,children:c}){let{open:d,setOpen:f,enabled:u,disabledReason:g,triggerRef:p}=oo(n),m=ee(),b=Q(e),v=m(b?.labelKey??o),{shared:x,reasonNode:h}=ml({enabled:u,disabledReason:g,ariaLabel:v}),y={...x,ref:p,className:`docx-toolbar__button docx-table-chrome__trigger${s?` ${s}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:u?()=>f(!d):void 0,...l?{tabIndex:u?0:-1,role:"button",onKeyDown:Yg(u,d,f)}:{}},T=c??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[oe(b?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Y,{...y,children:T}),h]}):jsxRuntime.jsxs("button",{...y,children:[T,h]})}i.docxToolbarPart=true;function a({asChild:l,className:s,children:c}){let{open:d,setOpen:f,enabled:u,triggerRef:g}=oo(n),p=ee(),m=pt.useRef(null);if(Wg(d&&u,f,m,g),!d||!u)return null;let b=Q(e),v=p(b?.labelKey??o),x={ref:m,role:"menu","aria-label":v,className:`docx-table-chrome__panel${s?` ${s}`:""}`,onMouseDown:Z};return l?jsxRuntime.jsx(Y,{...x,children:c}):jsxRuntime.jsx("div",{...x,children:c})}return {Root:r,Trigger:i,Content:a,Ctx:n}}var la=tu("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function Xg({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=oo(la.Ctx),l=ee(),s=editor.TABLE_BORDER_TARGET_OPTIONS.find(u=>u.value===e);if(!s)return null;let c=s.value==="none"?false:s.value===a.activeTarget,d={type:"button",role:"menuitemradio","aria-checked":c,"data-value":s.value,className:`docx-table-chrome__target-btn${o?` ${o}`:""}`,...c?{"data-active":""}:{},"aria-label":l(s.labelKey),title:l(s.labelKey),onMouseDown:Z,onClick:()=>{i(false),r(s.value);}},f=n??wE(s.icon);return t?jsxRuntime.jsx(Y,{...d,children:f}):jsxRuntime.jsx("button",{...d,children:f})}function Qg(e){let{children:t}=e;return jsxRuntime.jsx(la.Content,{...e,children:t??jsxRuntime.jsx("div",{className:"docx-table-chrome__target-grid",children:editor.TABLE_BORDER_TARGET_OPTIONS.map(o=>jsxRuntime.jsx(Xg,{value:o.value},o.value))})})}function ME(e){let{children:t}=e,o=t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(la.Trigger,{}),jsxRuntime.jsx(Qg,{})]});return jsxRuntime.jsx(la.Root,{...e,children:o})}var pa=Object.assign(ME,{docxSlot:"table.borderTarget",Trigger:la.Trigger,Content:Qg,Item:Xg}),sa=tu("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function Jg({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=oo(sa.Ctx),l=ee(),s=editor.TABLE_BORDER_STYLE_OPTIONS.find(u=>u.value===e);if(!s)return null;let c=s.value===a.spec.style,d={type:"button",role:"menuitemradio","aria-checked":c,...c?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:Z,onClick:()=>{i(false),r(s.value);}},f=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:`docx-table-line ${s.previewClass}`,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l(s.labelKey)})]});return t?jsxRuntime.jsx(Y,{...d,children:f}):jsxRuntime.jsx("button",{...d,children:f})}function e0(e){let{children:t}=e;return jsxRuntime.jsx(sa.Content,{...e,children:t??editor.TABLE_BORDER_STYLE_OPTIONS.map(o=>jsxRuntime.jsx(Jg,{value:o.value},o.value))})}function RE(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(sa.Trigger,{}),jsxRuntime.jsx(e0,{})]});return jsxRuntime.jsx(sa.Root,{...e,children:t})}var ma=Object.assign(RE,{docxSlot:"table.borderStyle",Trigger:sa.Trigger,Content:e0,Item:Jg}),ca=tu("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function t0({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=oo(ca.Ctx),l=ee(),s=Number(e),c=editor.TABLE_BORDER_WIDTH_OPTIONS.find(g=>g.size===s);if(!c)return null;let d=c.size===a.spec.size,f={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:Z,onClick:()=>{i(false),r(c.size);}},u=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"docx-table-line docx-table-line--single",style:{height:`${c.previewThickness}px`},"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l(c.labelKey)})]});return t?jsxRuntime.jsx(Y,{...f,children:u}):jsxRuntime.jsx("button",{...f,children:u})}function o0(e){let{children:t}=e;return jsxRuntime.jsx(ca.Content,{...e,children:t??editor.TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsxRuntime.jsx(t0,{value:String(o.size)},o.size))})}function DE(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ca.Trigger,{}),jsxRuntime.jsx(o0,{})]});return jsxRuntime.jsx(ca.Root,{...e,children:t})}var fa=Object.assign(DE,{docxSlot:"table.borderWidth",Trigger:ca.Trigger,Content:o0,Item:t0});function n0(e,t,o){let n=o?.defaultHex??"FF0000",r=jg();function i({hidden:d,asChild:f,className:u,children:g}){let{visible:p,enabled:m,disabledReason:b,draft:v,apply:x}=dl(e),[h,y]=pt.useState(false),[T,C]=pt.useState(n),E=pt.useRef(null),S=pt.useRef(null);Jd(h,y,E);let D=pt.useMemo(()=>({open:h,setOpen:y,enabled:m,disabledReason:b,apply:x,draft:v,triggerRef:S,lastHex:T,setLastHex:C}),[h,m,b,x,v,T]);if(d||!p)return null;let R={className:`docx-toolbar__colorsplit docx-table-chrome${u?` ${u}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},w=g??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(a,{}),jsxRuntime.jsx(l,{}),jsxRuntime.jsx(s,{clearFill:o?.clearFill??false})]});return jsxRuntime.jsx(r.Provider,{value:D,children:f?jsxRuntime.jsx(Y,{...R,ref:E,children:w}):jsxRuntime.jsx("div",{ref:E,...R,children:w})})}function a({asChild:d,className:f,children:u}){let{enabled:g,disabledReason:p,apply:m,draft:b,lastHex:v}=oo(r),x=ee(),h=Q(e),y=x(h?.labelKey??t),{shared:T,reasonNode:C}=ml({enabled:g,disabledReason:p,ariaLabel:y}),E=e==="table.borderColor"&&b.spec.color.kind==="hex"?b.spec.color.value:v??n,S={...T,className:`docx-toolbar__button docx-toolbar__colorsplit-main${f?` ${f}`:""}`,onClick:g?()=>m({kind:"hex",value:E}):void 0},D=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[oe(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${E.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Y,{...S,children:D}),C]}):jsxRuntime.jsxs("button",{...S,children:[D,C]})}a.docxToolbarPart=true;function l({asChild:d,className:f,children:u}){let{open:g,setOpen:p,enabled:m,disabledReason:b,triggerRef:v}=oo(r),x=ee(),h=Q(e),y=x(h?.labelKey??t),{shared:T,reasonNode:C}=ml({enabled:m,disabledReason:b,ariaLabel:y}),E={...T,ref:v,className:`docx-toolbar__colorsplit-caret${f?` ${f}`:""}`,"aria-haspopup":"dialog","aria-expanded":g,onClick:m?()=>p(!g):void 0,...d?{tabIndex:m?0:-1,role:"button",onKeyDown:Yg(m,g,p)}:{}},S=u??"\u25BE";return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Y,{...E,children:S}),C]}):jsxRuntime.jsxs("button",{...E,children:[S,C]})}l.docxToolbarPart=true;function s({asChild:d,className:f,children:u,clearFill:g}){let{open:p,setOpen:m,enabled:b,apply:v,draft:x,triggerRef:h,lastHex:y,setLastHex:T}=oo(r),C=ee(),E=pt.useRef(null);if(zg(p&&b,m,E,h),!p||!b)return null;let S=C(t),D=e==="table.borderColor"&&x.spec.color.kind==="hex"?x.spec.color.value:y??n,R={ref:E,role:"dialog","aria-label":S,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${f?` ${f}`:""}`,onMouseDown:Z},w=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g?jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:Z,onClick:()=>{m(false),v(null),pl(h.current);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),C("table.clearCellFill")]}):null,jsxRuntime.jsx(Ld,{apply:I=>{m(false),T?.(I),v({kind:"hex",value:I}),pl(h.current);},current:D})]});return d?jsxRuntime.jsx(Y,{...R,children:w}):jsxRuntime.jsx("div",{...R,children:w})}function c({value:d,css:f,labelKey:u,asChild:g,className:p,children:m}){let{apply:b,setOpen:v,setLastHex:x,triggerRef:h}=oo(r),y=ee(),T=f??`#${d.toLowerCase()}`,C=u?y(u):d,E={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:T},"data-value":d,"aria-label":C,title:C,onMouseDown:Z,onClick:()=>{v(false),x?.(d),b({kind:"hex",value:d}),pl(h.current);}};return g?jsxRuntime.jsx(Y,{...E,children:m}):jsxRuntime.jsx("button",{...E,children:m})}return {Root:i,Main:a,Trigger:l,Content:s,Item:c,Ctx:r}}var da=n0("table.borderColor","table.borderColor",{defaultHex:"000000"});function kE(e){return jsxRuntime.jsx(da.Content,{...e,clearFill:false})}function IE(e){return jsxRuntime.jsx(da.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function _E(e){return jsxRuntime.jsx(da.Root,{...e})}var ga=Object.assign(_E,{docxSlot:"table.borderColor",Trigger:da.Trigger,Content:kE,Item:IE,Main:da.Main}),ua=n0("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function NE(e){return jsxRuntime.jsx(ua.Content,{...e,clearFill:true})}function LE(e){return jsxRuntime.jsx(ua.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function FE(e){return jsxRuntime.jsx(ua.Root,{...e})}var ba=Object.assign(FE,{docxSlot:"table.cellFill",Trigger:ua.Trigger,Content:NE,Item:LE,Main:ua.Main});function r0({overrides:e=new Map,separator:t=true}){return Kg()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx(tn,{}):null,[pa,ga,ma,fa,ba].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(pt.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)})]}):null}function a0(){let e=ee(),{draft:t}=dl("table.borderTarget");return e(editor.tableChromeLabelKeyForTarget(t.activeTarget))}var ru=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],bl="contextual-table",au={"zoom.level":kd,"styles.style":Vd,"font.family":Kd,"font.size":Dd,"text.color":Fd,"text.highlight":Ad,"text.link":Pd,"list.lineSpacing":_d,"review.editingMode":$i,"review.authors":Gi,"file.save":Ed,...Fg,"table.borderTarget":pa,"table.borderColor":ga,"table.borderStyle":ma,"table.borderWidth":fa,"table.cellFill":ba,"image.insert":Er,"image.properties":Un,"image.wrap":ea,"image.altText":Br},fl={id:bl,labelKey:"formattingBar.groups.table",entries:ru.map(e=>({slot:e,Part:au[e]}))},i0=new Map;function OE(e){let t=i0.get(e);return t||(t=o=>jsxRuntime.jsx(Lo,{slot:e,...o}),i0.set(e,t)),t}function BE(e){return editor.formattingBarChromeGroups(e).map(t=>t.id==="alignment"?{id:t.id,labelKey:t.labelKey,entries:[{slot:"alignment",Part:tl}]}:{id:t.id,labelKey:t.labelKey,entries:t.controls.map(o=>{let n=editor.chromeSlotId(t,o);return {slot:n,Part:au[n]??OE(n)}})})}var ZE=e=>e.image,qE=e=>e.isLoading||e.isOpening===true,KE=e=>e.table!==null;function WE(e){return e==="alignment"||e in au}function vl(e){let t=kn(e,vl);if(t!==null)return t;if(!pt.isValidElement(e))return null;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxToolbarPart===true){let n=e.props.slot;if(typeof n=="string")return n}return null}function ou(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(ou);let t=vl(e);return t!=null&&ru.includes(t)?true:pt.isValidElement(e)?pt.Children.toArray(e.props.children).some(ou):false}function zE(e,t){return t?true:pt.Children.toArray(e).some(ou)}function UE(e){let t=dt(),{className:o,t:n,onSave:r,preset:i=true,overflow:a=true,children:l}=e,s=pt.useMemo(()=>({t:n,onSave:r}),[n,r]),c=Va(n),d=O(ZE),f=O(qE),u=O(KE),g=pt.useMemo(()=>BE(d),[d]),p=pt.useMemo(()=>new Set(g.flatMap(T=>T.entries.map(C=>C.slot))),[g]),m=pt.useMemo(()=>[...g.map(T=>T.id).filter(T=>!bd.has(T)),...u?[bl]:[]],[g,u]),b=pt.useMemo(()=>Ef(m),[m]),v=i&&a,{attach:x,overflow:h}=Ff(v,m,b),y;if(!i)y=l;else {let T=pt.Children.toArray(l),C=new Map,E=new Map,S=[];for(let _ of T){let P=vl(_);P&&p.has(P)?C.set(P,_):P&&ru.includes(P)?E.set(P,_):S.push(_);}let D=_=>{let P=C.get(_.slot);if(P)return P;let k=_.Part;return jsxRuntime.jsx(k,{})},R=_=>{let P=E.get(_.slot);if(P)return P;let k=_.Part;return jsxRuntime.jsx(k,{})},w=[],I=[],H=0;for(let _ of g){if(h.has(_.id)){let k=_.entries.flatMap(j=>{let W=l0(j,C,c,_.labelKey,D);return W===null?[]:[jsxRuntime.jsx(pt.Fragment,{children:W},j.slot)]});if(k.length===0)continue;I.push({id:_.id,labelKey:_.labelKey,children:k});continue}H>0&&w.push(jsxRuntime.jsx(tn,{},`separator-${_.id}`)),H+=1;let P=bd.has(_.id);w.push(jsxRuntime.jsx("div",{className:"docx-toolbar__group",...P?{[Jr]:""}:{[Xn]:_.id},children:_.entries.map(k=>jsxRuntime.jsx(pt.Fragment,{children:D(k)},k.slot))},_.id));}let N=h.has(bl);if(u&&N){let _=fl.entries.flatMap(P=>{let k=l0(P,E,c,fl.labelKey,R);return k===null?[]:[jsxRuntime.jsx(pt.Fragment,{children:k},P.slot)]});_.length>0&&I.unshift({id:fl.id,labelKey:fl.labelKey,children:_});}y=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[w,u&&!N?jsxRuntime.jsx(tn,{},"separator-contextual-table"):null,N?null:jsxRuntime.jsx("div",{className:"docx-toolbar__contextual",[Xn]:bl,children:jsxRuntime.jsx(r0,{overrides:E,separator:false})}),S.length>0?jsxRuntime.jsx("div",{className:"docx-toolbar__group",[Jr]:"",children:S}):null,I.length>0?jsxRuntime.jsx(Zf,{sections:I}):null]});}return jsxRuntime.jsx(No.Provider,{value:s,children:jsxRuntime.jsx(Cf,{children:jsxRuntime.jsx("fieldset",{ref:x,disabled:f,role:"toolbar","data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,...v?{"data-overflow":""}:{},onMouseDown:Z,children:zE(l,i)?jsxRuntime.jsx(Xd,{children:y}):y})})})}function s0(e){if(!e)return false;if(e.type===pt.Fragment){let t=pt.Children.toArray(e.props.children).find(o=>vl(o)!==null);return pt.isValidElement(t)?s0(t):false}return !!e.props.hidden}function l0(e,t,o,n,r){let i=t.get(e.slot);return s0(i)?null:i||WE(e.slot)?jsxRuntime.jsx(Of,{label:$E(o,e,n),children:r(e)}):jsxRuntime.jsx(Bf,{slot:e.slot})}function $E(e,t,o){let n=t.slot==="alignment"?null:Q(t.slot);return e(n?.labelKey??o)}var va=Object.assign(UE,{Button:Lo,Action:Od,Separator:tn,Undo:qf,Redo:Kf,Bold:Wf,Italic:zf,Underline:Uf,Strike:$f,Link:Pd,ClearFormatting:Vf,Superscript:Gf,Subscript:Yf,Alignment:tl,AlignLeft:jf,AlignCenter:Xf,AlignRight:Qf,AlignJustify:Jf,LineSpacing:_d,BulletList:eg,NumberedList:tg,Outdent:og,Indent:ng,ImageInsert:Er,ImageProperties:Un,ImageWrap:ea,ImageAltText:Br,TableInsert:rg,TableBorderTarget:pa,TableBorderColor:ga,TableBorderStyle:ma,TableBorderWidth:fa,TableCellFill:ba,Comments:ag,FontFamily:Kd,FontSize:Dd,FontColor:Fd,Highlight:Ad,Zoom:kd,StylePicker:Vd,EditingMode:$i,Reviewers:Gi,Save:Ed,ContentControlShowAll:al,ContentControlFormFill:il,ContentControlInspector:sl,ContentControlRemove:ll});var YE=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i,jE=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g;var c0=new TextEncoder;function XE(e,t){if(c0.encode(e).length<=t)return e;let o=0,n="";for(let r of e){let i=c0.encode(r).length;if(o+i>t)break;o+=i,n+=r;}return n}function d0(e){let t=XE((e??"").replace(/\.docx$/i,"").replace(jE," ").replace(/\s+/g," ").trim().replace(/^[.\s]+/,"").replace(/[.\s]+$/,""),200).trim();return !t||YE.test(t)?"document.docx":`${t}.docx`}function u0(e,t){let o=URL.createObjectURL(new Blob([e],{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})),n=document.createElement("a");n.href=o,n.download=t,n.click(),setTimeout(()=>URL.revokeObjectURL(o),0);}var e1=e=>e.hiddenReviewAuthors??[];function yl({className:e,hidden:t}){let o=F(),n=Xr(),r=O(e1),i=De(),{t:a}=L();if(t)return null;let l=i("reviewers.label"),s=editor.toolbarCommandState(o,"review.authors"),c=i18n.localizeDisabledReason(s.disabledReason,a);if(!s.enabled)return jsxRuntime.jsx(ke,{disabled:true,title:c??void 0,slot:"review.authors",children:l});let d=new Set(r),f=n.every(u=>!d.has(u.author));return jsxRuntime.jsxs(Ft,{labelKey:"reviewers.label",className:e,children:[jsxRuntime.jsx(p0,{checked:f,label:i("reviewers.all"),slot:"reviewer-all",onChoose:()=>o?.setAllReviewAuthorsVisible(!f)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),n.map(u=>jsxRuntime.jsx(p0,{checked:!d.has(u.author),label:u.author||"\u2014",slot:`reviewer-${u.slot}`,onChoose:()=>o?.setReviewAuthorVisible(u.author,d.has(u.author))},u.author))]})}function p0(e){return jsxRuntime.jsx(ke,{active:e.checked,slot:e.slot,className:"docx-menubar__reviewer-item",icon:jsxRuntime.jsx("span",{className:"docx-menubar__reviewer-check",children:e.checked?"\u2713":""}),onSelect:e.onChoose,children:e.label})}function t1({children:e,...t}){return jsxRuntime.jsxs(po,{id:"review",...t,children:[jsxRuntime.jsx(Ft,{labelKey:"reviewers.markupOptions",className:"docx-menubar__markup-options",children:jsxRuntime.jsx(yl,{className:"docx-menubar__reviewers-submenu"})}),e]})}var xl=Object.assign(t1,{docxMenu:"review"});var r1={file:Gs,format:Ys,insert:js,review:xl,help:Xs},a1=new Set(editor.CHROME_MENUS.map(e=>e.id));function x0(e){if(!pt.isValidElement(e))return null;if(e.type===pt.Fragment){let n=pt.Children.toArray(e.props.children).map(x0).filter(r=>r!==null);return n.length===1?n[0]:null}let t=e.type;if((typeof t=="function"||typeof t=="object")&&typeof t.docxMenu=="string")return t.docxMenu;if(e.type===po){let o=e.props.id;if(typeof o=="string"&&a1.has(o))return o}return null}function i1(e){let t=zr(),o=dt(),{className:n,t:r,fileName:i,onOpen:a,onOpenFile:l,onSave:s,onPageSetup:c,onReportIssue:d,reportIssue:f,preset:u=true,children:g}=e,p=F(),{t:m}=L(),[b,v]=pt.useState(null),[x,h]=pt.useState(null),[y,T]=pt.useState(null),[C,E]=pt.useState(false),[S,D]=pt.useState(false),R=pt.useRef(null),w=pt.useRef(null);pt.useEffect(()=>{if(b===null)return;let z=B=>{let J=R.current;J&&B.target instanceof Node&&J.contains(B.target)||v(null);},te=B=>{B.key==="Escape"&&v(null);};return document.addEventListener("mousedown",z),document.addEventListener("keydown",te),()=>{document.removeEventListener("mousedown",z),document.removeEventListener("keydown",te);}},[b]);let I=pt.useCallback(z=>{v(z),z!==null&&T(z);},[]),H=pt.useCallback(()=>w.current?.click(),[]),N=pt.useCallback(()=>{p&&p.save().then(z=>u0(z,d0(i??x??void 0))).catch(z=>{console.error("[docx-editor] save failed",z);});},[p,i,x]),_=pt.useCallback(()=>t?t.open("pageSetup",R.current?.querySelector('[data-menu="file"] > [role="menuitem"]')):E(true),[t]),P=p?a??H:void 0,k=p?s??N:void 0,j=p?t?.ownsPageSetup?_:c??_:void 0;pt.useEffect(()=>{let z=te=>{if(!(te.metaKey||te.ctrlKey)||te.altKey||te.shiftKey)return;let B=te.key.toLowerCase();if(B!=="s"&&B!=="o")return;let J=te.target,de=ul(R.current)??R.current;!J||!de?.contains(J)||(B==="s"&&k?(te.preventDefault(),k()):B==="o"&&P&&(te.preventDefault(),P()));};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[P,k]);let W=pt.useMemo(()=>({t:r,openMenu:b,setOpenMenu:I,activeMenu:y,onOpen:P,onSave:k,onPageSetup:j,onParagraphDialog:()=>t?t.open("paragraph",R.current?.querySelector('[data-menu="format"] > [role="menuitem"]')):D(true),onReportIssue:d,reportIssue:f}),[r,b,I,y,P,k,j,t,d,f]),re;if(!u)re=g;else {let z=new Map,te=[];for(let B of pt.Children.toArray(g)){let J=x0(B);J?z.set(J,B):te.push(B);}re=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[editor.CHROME_MENUS.map(B=>{let J=z.get(B.id);if(J)return jsxRuntime.jsx(pt.Fragment,{children:J},B.id);let de=r1[B.id];return jsxRuntime.jsx(de,{},B.id)}),te]});}return jsxRuntime.jsxs(Cr.Provider,{value:W,children:[jsxRuntime.jsx("div",{ref:z=>{if(R.current=z,z&&y===null){let te=Os(z)[0]?.closest("[data-menu]")?.getAttribute("data-menu");te&&T(te);}},role:"menubar","aria-label":r?.("titleBar.menuBarAriaLabel")??m("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",className:`${o}docx-menubar${n?` ${n}`:""}`,onMouseDown:Z,onKeyDown:z=>{if(z.key!=="ArrowLeft"&&z.key!=="ArrowRight")return;let te=R.current;if(!te)return;let B=Os(te),J=B.indexOf(document.activeElement);if(J===-1)return;z.preventDefault();let de=z.key==="ArrowRight"?1:-1,V=B[(J+de+B.length)%B.length],q=V?.closest("[data-menu]")?.getAttribute("data-menu");q&&(T(q),V?.focus(),b!==null&&v(q));},children:re}),jsxRuntime.jsx("input",{ref:w,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:z=>{let te=z.target.files?.[0];z.target.value="",!(!te||!p)&&(h(te.name),l?.(te),te.arrayBuffer().then(B=>p.load(new Uint8Array(B))).catch(B=>{console.error("[docx-editor] could not open the file",B);}));}}),jsxRuntime.jsx(Yo,{open:C,onClose:()=>E(false)}),jsxRuntime.jsx(Jt,{open:S,onClose:()=>D(false)})]})}var xa=Object.assign(i1,{Menu:po,File:Gs,Format:Ys,Insert:js,Review:xl,Help:Xs,Item:Yt,Row:ke,Group:Mr,Separator:Zo,Submenu:Ft,TableGrid:ai,Entry:Rr,Open:Ws,Save:zs,PageSetup:Us,ImageInsert:$s,Reviewers:yl,ReportIssue:ii});var u1=12240,S0=1440,w0=1440,M0=567,nn=20,lu=6,cu=nn+lu+2,p1="var(--doc-text-muted)",m1="var(--doc-text-subtle)",P0="var(--doc-shadow-subtle)",f1="var(--doc-primary)",g1="var(--doc-primary-hover)",b1="var(--doc-text-subtle)",Ta=5,Ca=7,h1={left:0,right:0,firstLine:0};function E0(e,t){return t==="inch"?(e/w0).toFixed(2)+'"':(e/M0).toFixed(1)+" cm"}function v1(e,t){return t?1:Math.round(e==="cm"?editor.SNAP_TWIPS_CM:editor.SNAP_TWIPS_INCH)}function rn({pageSetup:e,zoom:t=1,editable:o=false,onLeftMarginChange:n,onRightMarginChange:r,onMarginDragEnd:i,showIndentHandles:a=false,indent:l,indentEditable:s=false,onIndentChange:c,onIndentDragEnd:d,unit:f="inch",className:u="",style:g,tabMarks:p,onTabMarkRemove:m}){let{t:b}=L(),[v,x]=pt.useState(null),[h,y]=pt.useState(null),[T,C]=pt.useState(null),[E,S]=pt.useState(null),D=pt.useRef(null),R=e?.pageWidthTwips??u1,w=e?.marginsTwips.left??S0,I=e?.marginsTwips.right??S0,H=e?.gutterTwips??0,N={pageWidth:R,leftMargin:w,rightMargin:I},_=l??h1,P=Ee(R)*t,k=Ee(w)*t,j=Ee(I)*t,W=pt.useCallback(q=>{let Re=D.current?.getBoundingClientRect();return Re?Zi((q-Re.left)/t):null},[t]),re=pt.useCallback((q,Re,je)=>{let pe=W(Re);if(pe===null)return;if(S(Ee(pe)*t),q==="leftMargin"||q==="rightMargin"){if(q==="leftMargin"){let Ut=R-I-H-720,he=Math.round(Math.max(0,Math.min(pe,Ut)));C(he),n?.(he);}else {let Ut=R-pe,he=R-w-H-720,_t=Math.round(Math.max(0,Math.min(Ut,he)));C(_t),r?.(_t);}return}let ze=editor.dragIndent(q,pe,_,N,{unit:f,precise:je});C(q==="right"?ze.right:q==="firstLine"?ze.firstLine:ze.left),c?.(ze);},[W,t,R,w,I,H,n,r,c,_,N,f]),z=pt.useCallback(q=>{q==="leftMargin"||q==="rightMargin"?i?.():d?.(),x(null),C(null),S(null);},[i,d]),te=pt.useCallback((q,Re,je)=>{let pe=editor.handlePosition(q,_,N),ze=editor.dragIndent(q,pe+Re*v1(f,je),_,N,{unit:f,precise:true});c?.(ze),d?.();},[_,N,f,c,d]),B=P1(R,t,f),J=a&&s&&c!==void 0,de=q=>Ee(editor.handlePosition(q,_,N))*t,V=(q,Re,je)=>({positionPx:de(q),editable:J,isDragging:v===q,isHovered:h===q,onPointerEnter:()=>y(q),onPointerLeave:()=>y(null),onPointerDown:pe=>{J&&(pe.preventDefault(),pe.stopPropagation(),pe.currentTarget.setPointerCapture(pe.pointerId),x(q));},onPointerMove:pe=>{v===q&&re(q,pe.clientX,pe.altKey);},onPointerUp:pe=>{v===q&&(pe.currentTarget.releasePointerCapture(pe.pointerId),z(q));},onKeyDown:pe=>{J&&(pe.key!=="ArrowLeft"&&pe.key!=="ArrowRight"||(pe.preventDefault(),te(q,pe.key==="ArrowLeft"?-1:1,pe.shiftKey)));},label:b(Re),valueNow:je,valueText:E0(je,f),pageWidthTwips:R});return jsxRuntime.jsxs("div",{ref:D,className:`docx-horizontal-ruler ${u}`,style:{position:"relative",width:it(P),height:cu,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:v?"ew-resize":"default",flexShrink:0,marginInline:"auto",...g},role:"group","aria-label":b("ruler.horizontal"),children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,width:it(k),height:nn,backgroundColor:P0,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&n?q=>{q.preventDefault(),q.currentTarget.setPointerCapture(q.pointerId),x("leftMargin");}:void 0,onPointerMove:q=>v==="leftMargin"&&re("leftMargin",q.clientX,q.altKey),onPointerUp:q=>{v==="leftMargin"&&(q.currentTarget.releasePointerCapture(q.pointerId),z("leftMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,right:0,width:it(j),height:nn,backgroundColor:P0,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&r?q=>{q.preventDefault(),q.currentTarget.setPointerCapture(q.pointerId),x("rightMargin");}:void 0,onPointerMove:q=>v==="rightMargin"&&re("rightMargin",q.clientX,q.altKey),onPointerUp:q=>{v==="rightMargin"&&(q.currentTarget.releasePointerCapture(q.pointerId),z("rightMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:nn,pointerEvents:"none"},children:B.map((q,Re)=>jsxRuntime.jsx(y1,{tick:q},Re))}),p?.map(q=>jsxRuntime.jsx(S1,{tabMark:q,positionPx:Ee(q.position)*t,onDoubleClick:()=>m?.(q.position)},q.position)),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(iu,{direction:"down",anchor:"top",...V("firstLine","ruler.firstLineIndent",_.firstLine)}),jsxRuntime.jsx(iu,{direction:"up",anchor:"strip",...V("hanging","ruler.hangingIndent",_.left)}),jsxRuntime.jsx(x1,{...V("left","ruler.leftIndent",_.left)}),jsxRuntime.jsx(iu,{direction:"up",anchor:"strip",...V("right","ruler.rightIndent",_.right)})]}),v&&T!==null&&E!==null&&jsxRuntime.jsx(C1,{value:E0(T,f),positionPx:E})]})}function y1({tick:e}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:it(e.position),bottom:0,width:1,height:e.height,backgroundColor:m1}}),e.label&&jsxRuntime.jsx("div",{style:{position:"absolute",left:it(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:p1,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function R0(e){return e.editable?e.isDragging||e.isHovered?g1:f1:b1}function D0(e,t,o){return {position:"absolute",left:it(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...o}}function k0(e){return {role:"slider","aria-label":e.label,"aria-orientation":"horizontal","aria-valuenow":e.valueNow,"aria-valuemin":-e.pageWidthTwips,"aria-valuemax":e.pageWidthTwips,"aria-valuetext":e.valueText,"aria-disabled":e.editable?void 0:true,tabIndex:e.editable?0:-1}}function iu({direction:e,anchor:t,...o}){let n=R0(o),r=t==="top"?{top:0,height:Ca+1}:{top:nn-Ca,height:Ca};return jsxRuntime.jsx("div",{className:"docx-ruler-indent",style:D0(o,Ta*2,r),onPointerEnter:o.onPointerEnter,onPointerLeave:o.onPointerLeave,onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onKeyDown:o.onKeyDown,...k0(o),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${Ta}px solid transparent`,borderRight:`${Ta}px solid transparent`,...e==="down"?{top:0,borderTop:`${Ca}px solid ${n}`}:{bottom:0,borderBottom:`${Ca}px solid ${n}`},transition:"border-color 0.1s"}})})}function x1(e){return jsxRuntime.jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:D0(e,Ta*2,{top:nn+1,height:lu}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...k0(e),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:1,top:0,width:Ta*2-2,height:lu,backgroundColor:R0(e),borderRadius:1,transition:"background-color 0.1s"}})})}function C1({value:e,positionPx:t}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:it(t),top:-22,transform:"translateX(-50%)",backgroundColor:"var(--doc-text)",color:"var(--doc-on-primary)",fontSize:"10px",fontFamily:"sans-serif",padding:"2px 6px",borderRadius:3,whiteSpace:"nowrap",pointerEvents:"none",zIndex:20},children:e})}var T1={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function S1({tabMark:e,positionPx:t,onDoubleClick:o}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:it(t-5),top:nn-12,width:10,height:12,display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"var(--doc-text-muted)",cursor:"pointer",userSelect:"none"},onDoubleClick:n=>{n.stopPropagation(),o();},title:`${e.alignment} tab at ${(e.position/1440).toFixed(2)}"`,children:T1[e.alignment]||"L"})}function P1(e,t,o){let n=[];if(o==="inch"){let r=w0/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=Ee(l)*t;a%8===0?n.push({position:s,height:8,label:a/8>0?String(a/8):void 0}):a%4===0?n.push({position:s,height:5}):a%2===0?n.push({position:s,height:3}):n.push({position:s,height:2});}}else {let r=M0/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=Ee(l)*t;a%10===0?n.push({position:s,height:8,label:a/10>0?String(a/10):void 0}):a%5===0?n.push({position:s,height:5}):n.push({position:s,height:3});}}return n}var M1=15840,N0=1440,R1=1440,D1=567,tr=20,k1="var(--doc-text-muted)",I1="var(--doc-text-subtle)",_1="var(--doc-primary)",N1="var(--doc-primary)",L1="var(--doc-primary-hover)";function Sa({pageSetup:e,zoom:t=1,editable:o=false,onTopMarginChange:n,onBottomMarginChange:r,onMarginDragEnd:i,unit:a="inch",className:l="",style:s}){let{t:c}=L(),[d,f]=pt.useState(null),[u,g]=pt.useState(null),p=pt.useRef(null),m=e?.pageHeightTwips??M1,b=e?.marginsTwips.top??N0,v=e?.marginsTwips.bottom??N0,x=Ee(m)*t,h=Ee(b)*t,y=Ee(v)*t,T=pt.useCallback((R,w)=>{o&&(R.preventDefault(),f(w));},[o]),C=pt.useCallback(R=>{if(!d||!p.current)return;let w=p.current.getBoundingClientRect(),I=R.clientY-w.top,H=Zi(I/t);if(d==="topMargin"){let N=m-v-720,_=Math.max(0,Math.min(H,N));n?.(Math.round(_));}else if(d==="bottomMargin"){let N=m-H,_=m-b-720,P=Math.max(0,Math.min(N,_));r?.(Math.round(P));}},[d,t,m,b,v,n,r]),E=pt.useCallback(()=>{d!==null&&i?.(),f(null);},[d,i]);pt.useEffect(()=>{if(d)return document.addEventListener("mousemove",C),document.addEventListener("mouseup",E),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",E);}},[d,C,E]);let S=A1(m,t,a),D={position:"relative",width:tr,height:it(x),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:d?"ns-resize":"default",...s};return jsxRuntime.jsxs("div",{ref:p,className:`docx-vertical-ruler ${l}`,style:D,role:"slider","aria-label":c("ruler.vertical"),"aria-orientation":"vertical",children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none"},children:S.map((R,w)=>jsxRuntime.jsx(F1,{tick:R},w))}),jsxRuntime.jsx(L0,{type:"topMargin",position:h,editable:o,isDragging:d==="topMargin",isHovered:u==="topMargin",onMouseEnter:()=>g("topMargin"),onMouseLeave:()=>g(null),onMouseDown:R=>T(R,"topMargin")}),jsxRuntime.jsx(L0,{type:"bottomMargin",position:x-y,editable:o,isDragging:d==="bottomMargin",isHovered:u==="bottomMargin",onMouseEnter:()=>g("bottomMargin"),onMouseLeave:()=>g(null),onMouseDown:R=>T(R,"bottomMargin")})]})}function F1({tick:e}){let t={position:"absolute",top:it(e.position),right:0,height:1,width:e.width,backgroundColor:I1},o={position:"absolute",top:it(e.position),left:2,transform:"translateY(-50%)",fontSize:"9px",color:k1,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:t}),e.label&&jsxRuntime.jsx("div",{style:o,children:e.label})]})}function L0({type:e,position:t,editable:o,isDragging:n,isHovered:r,onMouseEnter:i,onMouseLeave:a,onMouseDown:l}){let{t:s}=L(),c=n?L1:r?N1:_1,d={position:"absolute",top:it(t-5),right:0,width:tr,height:10,cursor:o?"ns-resize":"default",zIndex:n?10:1},f={position:"absolute",top:0,right:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderRight:`8px solid ${c}`,transition:"border-right-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:d,onMouseEnter:i,onMouseLeave:a,onMouseDown:l,role:"slider","aria-label":s(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical",tabIndex:o?0:-1,children:jsxRuntime.jsx("div",{style:f})})}function A1(e,t,o){let n=[];if(o==="inch"){let r=R1/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=Ee(l)*t;if(a%8===0){let c=a/8;n.push({position:s,width:10,label:c>0?String(c):void 0});}else a%4===0?n.push({position:s,width:6}):a%2===0?n.push({position:s,width:4}):n.push({position:s,width:2});}}else {let r=D1/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=Ee(l)*t;if(a%10===0){let c=a/10;n.push({position:s,width:10,label:c>0?String(c):void 0});}else a%5===0?n.push({position:s,width:6}):n.push({position:s,width:3});}}return n}var an=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var B1=e=>e.formatting?.indent??null,Z1=e=>e.editable;function uu(){let e=F(),t=O(B1),o=O(Z1),n=pt.useMemo(()=>o&&e!==null&&e.can({type:"setIndent",left:0}).ok,[e,o]),r=pt.useCallback(i=>e?e.exec({...i.left!==void 0?{left:i.left}:{},...i.right!==void 0?{right:i.right}:{},...i.firstLine!==void 0?{firstLine:i.firstLine}:{},type:"setIndent"}).ok:false,[e]);return pt.useMemo(()=>({indent:t,isEnabled:n,apply:r}),[t,n,r])}var B0=e=>e.zoom,K1=e=>e.isOpening===true;function Z0(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function q0(){let{apply:e}=Go(),[t,o]=pt.useState({}),n=pt.useRef({}),r=pt.useCallback(a=>l=>{n.current={...n.current,[a]:Math.round(l)},o(n.current);},[]),i=pt.useCallback(()=>{let a=n.current;n.current={},o({}),Object.keys(a).length!==0&&e({...a.top!==void 0?{marginTopTwips:a.top}:{},...a.right!==void 0?{marginRightTwips:a.right}:{},...a.bottom!==void 0?{marginBottomTwips:a.bottom}:{},...a.left!==void 0?{marginLeftTwips:a.left}:{},scope:"section"});},[e]);return {pending:t,preview:r,commit:i}}function O0(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function W1(){let e=F(),{indent:t,isEnabled:o,apply:n}=uu(),[r,i]=pt.useState(null),a=pt.useRef(null),l=pt.useRef(null),s=pt.useCallback(f=>{l.current===null&&(l.current=O0(e)),a.current=f,i(f);},[e]),c=pt.useCallback(()=>{let f=a.current,u=l.current;a.current=null,l.current=null,i(null),f&&(u!==null&&u!==O0(e)||n({left:f.left,right:f.right,firstLine:f.firstLine}));},[e,n]),d=pt.useMemo(()=>r??(t?{left:t.left,right:t.right,firstLine:t.firstLine}:null),[r,t]);return pt.useMemo(()=>({indent:d,isEnabled:o,preview:s,commit:c}),[d,o,s,c])}function z1(){let e=eo(),[t,o]=pt.useState(0);return pt.useEffect(()=>{if(!e){o(0);return}let n=()=>o(e.scrollLeft);return n(),e.addEventListener("scroll",n,{passive:true}),()=>e.removeEventListener("scroll",n)},[e]),t}function El(e){let t=O(an),o=O(K1),{pageSetup:n,isEnabled:r}=Go(),i=O(B0),{pending:a,preview:l,commit:s}=q0(),c=W1(),d=Jo(),f=jn(),u=z1();return t?null:jsxRuntime.jsx("div",{className:`docx-ruler-frame${o?" docx-ruler-frame--opening":""}`,style:{paddingInlineStart:d+f.inlineStart,paddingRight:f.inlineEnd},children:jsxRuntime.jsx(rn,{pageSetup:Z0(n,a),zoom:i,editable:r,onLeftMarginChange:l("left"),onRightMarginChange:l("right"),onMarginDragEnd:s,showIndentHandles:c.indent!==null,indent:c.indent,indentEditable:c.isEnabled,onIndentChange:c.preview,onIndentDragEnd:c.commit,unit:e.unit??"inch",className:e.className??"",style:{...e.style,transform:`${e.style?.transform?`${e.style.transform} `:""}translateX(${-u}px)`,clipPath:d>0&&u>0?`inset(0 0 0 ${u}px)`:e.style?.clipPath}})})}function wl(e){let t=O(an),{pageSetup:o,isEnabled:n}=Go(),r=O(B0),{pending:i,preview:a,commit:l}=q0(),s=Jo(),c=jn(),d=df();return t||d!==null&&d>0&&o&&Ee(o.pageWidthTwips)*r>d-s-c.inlineStart-c.inlineEnd?null:jsxRuntime.jsx(Sa,{pageSetup:Z0(o,i),zoom:r,editable:n,onTopMarginChange:a("top"),onBottomMarginChange:a("bottom"),onMarginDragEnd:l,unit:e.unit??"inch",className:e.className??"",style:e.style})}function A({size:e=20,className:t="",style:o,children:n}){return jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 -960 960 960",fill:"currentColor",className:t,style:{display:"inline-flex",flexShrink:0,...o},"aria-hidden":"true",children:n})}function K0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M268-240 42-466l57-56 170 170 56 56-57 56Zm226 0L268-466l56-57 170 170 368-368 57 57-425 424Zm0-226-57-56 198-198 57 56-198 198Z"})})}function W0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m424-296 282-282-56-56-226 226-114-114-56 56 170 170Zm56 216q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Z"})})}function z0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"})})}function U0(e){return jsxRuntime.jsxs(A,{...e,children:[jsxRuntime.jsx("path",{d:"M80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"}),jsxRuntime.jsx("path",{fill:"var(--doc-success)",d:"m421-380 227-227-45-45-182 182-92-91-45 45 137 136Z"})]})}function $0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function V0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"})})}function G0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-400h80v-120h120v-80H520v-120h-80v120H320v80h120v120ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"})})}function Y0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M240-400h480v-80H240v80Zm0-120h480v-80H240v80Zm0-120h480v-80H240v80ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"})})}function j0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-400h280v-80H160v80Zm0-160h440v-80H160v80Zm0-160h440v-80H160v80Zm360 360v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T863-380L643-160H520Zm300-263-37-37 37 37ZM580-220h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z"})})}function X0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M240-400h122l200-200q9-9 13.5-20.5T580-643q0-11-5-21.5T562-684l-36-38q-9-9-20-13.5t-23-4.5q-11 0-22.5 4.5T440-722L240-522v122Zm280-243-37-37 37 37ZM300-460v-38l101-101 20 18 18 20-101 101h-38Zm121-121 18 20-38-38 20 18Zm26 181h273v-80H527l-80 80ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"})})}function Q0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-320q75 0 127.5-52.5T660-500q0-75-52.5-127.5T480-680q-75 0-127.5 52.5T300-500q0 75 52.5 127.5T480-320Zm0-72q-45 0-76.5-31.5T372-500q0-45 31.5-76.5T480-608q45 0 76.5 31.5T588-500q0 45-31.5 76.5T480-392Zm0 192q-146 0-266-81.5T40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200Zm0-300Zm0 220q113 0 207.5-59.5T832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280Z"})})}function J0(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M240-80q-33 0-56.5-23.5T160-160v-400q0-33 23.5-56.5T240-640h40v-80q0-83 58.5-141.5T480-920q83 0 141.5 58.5T680-720v80h40q33 0 56.5 23.5T800-560v400q0 33-23.5 56.5T720-80H240Zm0-80h480v-400H240v400Zm240-120q33 0 56.5-23.5T560-360q0-33-23.5-56.5T480-440q-33 0-56.5 23.5T400-360q0 33 23.5 56.5T480-280ZM360-640h240v-80q0-50-35-85t-85-35q-50 0-85 35t-35 85v80Zm-120 480v-400 400Z"})})}function V1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z"})})}function G1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z"})})}function Y1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M640-640v-120H320v120h-80v-200h480v200h-80Zm-480 80h640-640Zm560 100q17 0 28.5-11.5T760-500q0-17-11.5-28.5T720-540q-17 0-28.5 11.5T680-500q0 17 11.5 28.5T720-460Zm-80 260v-160H320v160h320Zm80 80H240v-160H80v-240q0-51 35-85.5t85-34.5h560q51 0 85.5 34.5T880-520v240H720v160Zm80-240v-160q0-17-11.5-28.5T760-560H200q-17 0-28.5 11.5T160-520v160h80v-80h480v80h80Z"})})}function j1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-320 280-520l56-58 104 104v-326h80v326l104-104 56 58-200 200ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"})})}function X1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"})})}function Q1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z"})})}function J1(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function ew(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-120v-80h560v80H200Zm123-223q-56-63-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63q-101 0-157-63Z"})})}function tw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z"})})}function ow(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z"})})}function nw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z"})})}function rw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm200 160v-80h160q50 0 85-35t35-85q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H520Z"})})}function aw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-160v-240q-83 0-141.5-58.5T160-600q0-83 58.5-141.5T360-800h360v80h-80v560h-80v-560H440v560h-80Z"})})}function iw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"})})}function lw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function sw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function cw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function dw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function gu(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M240-160 80-320l56-56 64 62v-332l-64 62-56-56 160-160 160 160-56 56-64-62v332l64-62 56 56-160 160Zm240-40v-80h400v80H480Zm0-240v-80h400v80H480Zm0-240v-80h400v80H480Z"})})}function uw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z"})})}function pw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"})})}function mw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function fw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function gw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z"})})}function bw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M544-400 440-504 240-304l104 104 200-200Zm-47-161 104 104 199-199-104-104-199 199Zm-84-28 216 216-229 229q-24 24-56 24t-56-24l-2-2-26 26H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0 0 227-227q24-24 56-24t56 24l104 104q24 24 24 56t-24 56L629-373 413-589Z"})})}function hw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M800-436q0 36-8 69t-22 63l-62-60q6-17 9-34.5t3-37.5q0-47-17.5-89T650-600L480-768l-88 86-56-56 144-142 226 222q44 42 69 99.5T800-436Zm-8 380L668-180q-41 29-88 44.5T480-120q-133 0-226.5-92.5T160-436q0-51 16-98t48-90L56-792l56-56 736 736-56 56ZM480-200q36 0 68.5-10t61.5-28L280-566q-21 32-30.5 64t-9.5 66q0 98 70 167t170 69Zm-37-204Zm110-116Z"})})}function vw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function yw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm240-240H200v160h240v-160Zm80 0v160h240v-160H520Zm-80-80v-160H200v160h240Zm80 0h240v-160H520v160ZM200-680h560v-80H200v80Z"})})}function xw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M760-120H200q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120ZM200-640h560v-120H200v120Zm100 80H200v360h100v-360Zm360 0v360h100v-360H660Zm-80 0H380v360h200v-360Z"})})}function Cw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133ZM200-413h133v-134H200v134Zm213 0h134v-134H413v134Zm214 0h133v-134H627v134ZM200-627h133v-133H200v133Zm213 0h134v-133H413v133Zm214 0h133v-133H627v133Z"})})}function Tw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M760-200v-120H200v120h560Zm0-200v-160H200v160h560Zm0-240v-120H200v120h560ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Z"})})}function Sw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M121-280v-400q0-33 23.5-56.5T201-760h559q33 0 56.5 23.5T840-680v400q0 33-23.5 56.5T760-200H201q-33 0-56.5-23.5T121-280Zm79 0h133v-400H200v400Zm213 0h133v-400H413v400Zm213 0h133v-400H626v400Z"})})}function eb(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function Pw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-200h560v-560H200v560Zm-80 80v-720h720v720H120Zm160-320v-80h80v80h-80Zm160 160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 160v-80h80v80h-80Z"})})}function Ew(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm320 640v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm-160 0v-80h80v80h-80ZM440-120v-320H120v-80h320v-320h80v320h320v80H520v320h-80Z"})})}function ww(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Mw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function Rw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function Dw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z"})})}function kw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M600-240v-80h160v80H600Zm0-320v-80h280v80H600Zm0 160v-80h240v80H600ZM120-640H80v-80h160v-60h160v60h160v80h-40v360q0 33-23.5 56.5T440-200H200q-33 0-56.5-23.5T120-280v-360Zm80 0v360h240v-360H200Zm0 0v360-360Z"})})}function Iw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m296-160-56-56 200-200v-269L337-582l-57-57 200-200 201 201-57 57-104-104v301L296-160Zm368 1L536-286l57-57 127 128-56 56Z"})})}function _w(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function Nw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-160q-33 0-56.5-23.5T280-240q0-33 23.5-56.5T360-320q33 0 56.5 23.5T440-240q0 33-23.5 56.5T360-160Zm240 0q-33 0-56.5-23.5T520-240q0-33 23.5-56.5T600-320q33 0 56.5 23.5T680-240q0 33-23.5 56.5T600-160ZM360-400q-33 0-56.5-23.5T280-480q0-33 23.5-56.5T360-560q33 0 56.5 23.5T440-480q0 33-23.5 56.5T360-400Zm240 0q-33 0-56.5-23.5T520-480q0-33 23.5-56.5T600-560q33 0 56.5 23.5T680-480q0 33-23.5 56.5T600-400ZM360-640q-33 0-56.5-23.5T280-720q0-33 23.5-56.5T360-800q33 0 56.5 23.5T440-720q0 33-23.5 56.5T360-640Zm240 0q-33 0-56.5-23.5T520-720q0-33 23.5-56.5T600-800q33 0 56.5 23.5T680-720q0 33-23.5 56.5T600-640Z"})})}function Lw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"})})}function Fw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function Aw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function Hw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function Ow(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-480h80v480h480v80H200Zm160-240v80q-33 0-56.5-23.5T280-360h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T360-840v80Zm80 480v-80h80v80h-80Zm0-480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm0 480v-80h80v80h-80Zm160-480v-80q33 0 56.5 23.5T840-760h-80Zm0 400h80q0 33-23.5 56.5T760-280v-80Zm0-80v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Bw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-280q-33 0-56.5-23.5T280-360v-400q0-33 23.5-56.5T360-840h400q33 0 56.5 23.5T840-760v400q0 33-23.5 56.5T760-280H360Zm0-80h400v-400H360v400ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function Zw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-80 310-250l57-57 73 73v-166h80v165l72-73 58 58L480-80ZM250-310 80-480l169-169 57 57-72 72h166v80H235l73 72-58 58Zm460 0-57-57 73-73H560v-80h165l-73-72 58-58 170 170-170 170ZM440-560v-166l-73 73-57-57 170-170 170 170-57 57-73-73v166h-80Z"})})}function qw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z"})})}function Kw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M522-80v-82q34-5 66.5-18t61.5-34l56 58q-42 32-88 51.5T522-80Zm-80 0Q304-98 213-199.5T122-438q0-75 28.5-140.5t77-114q48.5-48.5 114-77T482-798h6l-62-62 56-58 160 160-160 160-56-56 64-64h-8q-117 0-198.5 81.5T202-438q0 104 68 182.5T442-162v82Zm322-134-58-56q21-29 34-61.5t18-66.5h82q-5 50-24.5 96T764-214Zm76-264h-82q-5-34-18-66.5T706-606l58-56q32 39 51 86t25 98Z"})})}function Ww(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-80q-50-5-96-24.5T256-156l56-58q29 21 61.5 34t66.5 18v82Zm80 0v-82q104-15 172-93.5T760-438q0-117-81.5-198.5T480-718h-8l64 64-56 56-160-160 160-160 56 58-62 62h6q75 0 140.5 28.5t114 77q48.5 48.5 77 114T840-438q0 137-91 238.5T520-80ZM198-214q-32-42-51.5-88T122-398h82q5 34 18 66.5t34 61.5l-58 56Zm-76-264q6-51 25-98t51-86l58 56q-21 29-34 61.5T204-478h-82Z"})})}function zw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M280-160 80-360l200-200 56 57-103 103h287v80H233l103 103-56 57Zm400-240-56-57 103-103H440v-80h287L624-743l56-57 200 200-200 200Z"})})}function Uw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M320-440v-287L217-624l-57-56 200-200 200 200-57 56-103-103v287h-80ZM600-80 400-280l57-56 103 103v-287h80v287l103-103 57 56L600-80Z"})})}function $w(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M600-360ZM320-242q10 1 19.5 1.5t20.5.5q11 0 20.5-.5T400-242v82h400v-400h-82q1-10 1.5-19.5t.5-20.5q0-11-.5-20.5T718-640h82q33 0 56.5 23.5T880-560v400q0 33-23.5 56.5T800-80H400q-33 0-56.5-23.5T320-160v-82Zm40-78q-117 0-198.5-81.5T80-600q0-117 81.5-198.5T360-880q117 0 198.5 81.5T640-600q0 117-81.5 198.5T360-320Zm0-80q83 0 141.5-58.5T560-600q0-83-58.5-141.5T360-800q-83 0-141.5 58.5T160-600q0 83 58.5 141.5T360-400Zm0-200Z"})})}function Vw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-80q-33 0-56.5-23.5T360-160v-160H240q-33 0-56.5-23.5T160-400v-280q0-66 47-113t113-47h480v440q0 33-23.5 56.5T720-320H600v160q0 33-23.5 56.5T520-80h-80ZM240-560h480v-200h-40v160h-80v-160h-40v80h-80v-80H320q-33 0-56.5 23.5T240-680v120Zm0 160h480v-80H240v80Zm0 0v-80 80Z"})})}function Gw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function Yw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function jw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h720v80H120Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Xw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 480v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Qw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h80v720h-80Zm160 0v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Z"})})}function Jw(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-320v-80h80v80h-80Zm0-320v-80h80v80h-80Zm160 640v-720h80v720h-80Z"})})}function e2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h720v60H120Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-660v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-660v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-165v-60h60v60h-60Z"})})}function t2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-330v-60h60v60h-60Zm165 660v-720h60v720h-60Zm165 0v-60h60v60h-60Zm0-330v-60h60v60h-60Zm0-330v-60h60v60h-60Zm165 660v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Zm0-165v-60h60v60h-60Z"})})}function o2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M320-600q17 0 28.5-11.5T360-640q0-17-11.5-28.5T320-680q-17 0-28.5 11.5T280-640q0 17 11.5 28.5T320-600Zm160 0q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm160 0q17 0 28.5-11.5T680-640q0-17-11.5-28.5T640-680q-17 0-28.5 11.5T600-640q0 17 11.5 28.5T640-600ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"})})}function n2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-200v-80h528l-42-42 56-56 138 138-138 138-56-56 42-42H160Zm116-200 164-440h80l164 440h-76l-38-112H392l-40 112h-76Zm138-176h132l-64-182h-4l-64 182Z"})})}function r2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M588-132 440-280l148-148 56 58-50 50h96q29 0 49.5-20.5T760-390q0-29-20.5-49.5T690-460H160v-80h530q63 0 106.5 43.5T840-390q0 63-43.5 106.5T690-240h-96l50 50-56 58ZM160-240v-80h200v80H160Zm0-440v-80h640v80H160Z"})})}function a2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-120 320-280l56-56 64 63v-414l-64 63-56-56 160-160 160 160-56 57-64-64v414l64-63 56 56-160 160Z"})})}function i2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function l2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"})})}function s2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M80 0v-160h800V0H80Zm160-320h56l312-311-29-29-28-28-311 312v56Zm-80 80v-170l448-447q11-11 25.5-17t30.5-6q16 0 31 6t27 18l55 56q12 11 17.5 26t5.5 31q0 15-5.5 29.5T777-687L330-240H160Zm560-504-56-56 56 56ZM608-631l-29-29-28-28 57 57Z"})})}function c2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m247-904 57-56 343 343q23 23 23 57t-23 57L457-313q-23 23-57 23t-57-23L153-503q-23-23-23-57t23-57l190-191-96-96Zm153 153L209-560h382L400-751Zm360 471q-33 0-56.5-23.5T680-360q0-21 12.5-45t27.5-45q9-12 19-25t21-25q11 12 21 25t19 25q15 21 27.5 45t12.5 45q0 33-23.5 56.5T760-280ZM80 0v-160h800V0H80Z"})})}function d2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function u2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M440-80v-168l-64 64-56-56 160-160 160 160-56 56-64-64v168h-80ZM160-440v-80h640v80H160Zm320-120L320-720l56-56 64 64v-168h80v168l64-64 56 56-160 160Z"})})}function p2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function m2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function f2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function g2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function b2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function h2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function v2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"})})}function y2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-440v-80h160v80H120Zm200 0v-80h160v80H320Zm200 0v-80h160v80H520Zm200 0v-80h120v80H720ZM240-120q-33 0-56.5-23.5T160-200v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-120H240Zm-80-520v-120q0-33 23.5-56.5T240-840h480q33 0 56.5 23.5T800-760v120h-80v-120H240v120h-80Z"})})}function x2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h640q33 0 56.5 23.5T880-720v480q0 33-23.5 56.5T800-160H160Zm0-80h640v-480H160v480Zm320-60q66 0 113-37t47-93q0-29-13-58t-34-55q-21-26-50-49t-50-31q-21 8-50 31t-50 49q-21 26-34 55t-13 58q0 56 47 93t140 37Z"})})}function C2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function T2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"})})}function S2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function P2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm0-280v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80ZM680-80l-56-56 64-64H120v-80h568l-64-64 56-56 160 160L680-80Z"})})}function E2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"M360-360v-200q-66 0-113-47t-47-113q0-66 47-113t113-47h320v80h-80v440h-80v-440h-80v440h-80Zm-88 160 64 64-56 56-160-160 160-160 56 56-64 64h568v80H272Zm88-440v-160q-33 0-56.5 23.5T280-720q0 33 23.5 56.5T360-640Zm0-80Z"})})}function w2(e){return jsxRuntime.jsx(A,{...e,children:jsxRuntime.jsx("path",{d:"m760-600-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110Zm0 560-50-110-110-50 110-50 50-110 50 110 110 50-110 50-50 110ZM360-160 260-380 40-480l220-100 100-220 100 220 220 100-220 100-100 220Zm0-194 40-86 86-40-86-40-40-86-40 86-86 40 86 40 40 86Zm0-126Z"})})}var M2={undo:V1,redo:G1,print:Y1,file_download:j1,file_upload:X1,format_bold:Q1,format_italic:J1,format_underlined:ew,strikethrough_s:tw,superscript:ow,subscript:nw,link:rw,format_clear:iw,format_paragraph:aw,lock:J0,format_align_left:lw,format_align_center:sw,format_align_right:cw,format_align_justify:dw,format_line_spacing:gu,format_list_bulleted:uw,format_list_numbered:pw,format_indent_increase:mw,format_indent_decrease:fw,format_color_text:gw,ink_highlighter:bw,format_color_reset:hw,arrow_drop_down:vw,table:yw,table_chart:xw,grid_on:Cw,table_rows:Tw,view_column:Sw,border_all:eb,select_all:eb,border_outer:Pw,border_inner:Ew,border_clear:ww,add:Mw,remove:Rw,delete:Dw,delete_sweep:kw,call_merge:Iw,call_split:_w,drag_indicator:Nw,image:Lw,format_image_left:Fw,format_image_right:Aw,horizontal_rule:Hw,flip_to_back:Ow,flip_to_front:Bw,open_with:Zw,tune:qw,rotate_right:Kw,rotate_left:Ww,swap_horiz:zw,swap_vert:Uw,shapes:$w,format_paint:Vw,expand_more:Gw,expand_less:Yw,border_top:jw,border_bottom:Xw,border_left:Qw,border_right:Jw,border_horizontal:e2,border_vertical:t2,padding:o2,text_rotation_none:n2,wrap_text:r2,height:a2,fit_width:i2,settings:l2,border_color:s2,format_color_fill:c2,vertical_align_top:d2,vertical_align_center:u2,vertical_align_bottom:p2,line_weight:m2,keyboard_arrow_up:f2,keyboard_arrow_down:g2,keyboard_arrow_left:b2,keyboard_arrow_right:h2,more_vert:v2,page_break:y2,branding_watermark:x2,arrow_back:C2,search:T2,toc:S2,done_all:K0,check_circle:W0,chat_bubble_outline:z0,chat_bubble_check:U0,check:$0,close:V0,add_comment:G0,comment:Y0,edit_note:j0,rate_review:X0,visibility:Q0,format_textdirection_l_to_r:P2,format_textdirection_r_to_l:E2,"agent-sparkle":w2};function U({name:e,size:t=20,className:o="",style:n}){let r=M2[e];return r?jsxRuntime.jsx(r,{size:t,className:o,style:n}):(console.warn(`Icon not found: ${e}`),jsxRuntime.jsx("span",{className:o,style:{fontSize:t,width:t,height:t,...n},children:e}))}var Pa=12,bu=240,ob=16,I2=24,_2=Pa+bu+ob,or=12,N2=36,L2=or+N2+ob,Ea=pt__namespace.default.memo(function({headings:t,onHeadingClick:o,onClose:n,topOffset:r=0,scrollLeft:i=0,leftOffset:a=Pa}){let{t:l}=L(),[s,c]=pt.useState(false),d=t.length?Math.min(...t.map(f=>f.level)):0;return pt.useEffect(()=>{requestAnimationFrame(()=>c(true));},[]),jsxRuntime.jsxs("nav",{className:"docx-outline-nav",role:"navigation","aria-label":l("documentOutline.ariaLabel"),style:{position:"absolute",top:r,left:a-i,bottom:0,width:bu,paddingTop:I2,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:s?"translateX(0)":`translateX(-${a+bu}px)`,transition:"transform 0.15s ease-out"},onMouseDown:f=>f.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px 0"},children:[jsxRuntime.jsx("button",{onClick:n,"aria-label":l("documentOutline.closeAriaLabel"),style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"var(--doc-text-muted)"},title:l("documentOutline.closeTitle"),children:jsxRuntime.jsx(U,{name:"arrow_back",size:20})}),jsxRuntime.jsx("span",{style:{fontWeight:400,fontSize:14,color:"var(--doc-text)",letterSpacing:"0.01em"},children:l("documentOutline.title")})]}),jsxRuntime.jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:4},children:t.length===0?jsxRuntime.jsx("div",{style:{padding:"8px 16px",color:"var(--doc-text-subtle)",fontSize:13,lineHeight:"20px"},children:l("documentOutline.noHeadings")}):t.map((f,u)=>jsxRuntime.jsx("div",{style:{marginLeft:(f.level-d)*16},children:jsxRuntime.jsx("button",{className:"docx-outline-heading-btn",onClick:()=>o(f.blockId),style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"5px 8px",fontSize:13,fontWeight:400,color:"var(--doc-text)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",borderRadius:0,letterSpacing:"0.01em"},title:f.text,children:f.text})},`${f.blockId}-${u}`))})]})});var H2=e=>e,O2=Object.freeze([]),B2=()=>{};function hu(e){let t=F(),o=O(H2),n=pt.useMemo(()=>t&&!o.isLoading?t.getOutline():O2,[t,o]),r=pt.useCallback(i=>{if(!t)return;t.focus();let a={paragraphId:i,offset:0};t.exec({type:"setSelection",range:{anchor:a,head:a}}),t.scrollToBlock(i);},[t]);return an(o)?null:jsxRuntime.jsx(Ea,{headings:n,onHeadingClick:r,onClose:e.onClose??B2,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var vu=pt.createContext(null);function So(e){let t=pt.useContext(vu);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var nr=280,Ml=32,nb=16;function sn(e=280){return 32+e+16}function Rl({viewportWidth:e,pageWidthPx:t,reservation:o,inlineEndReservation:n=0,inlineStartReservation:r=0,docked:i=false}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(n)||n<0||!Number.isFinite(r)||r<0)return 0;let a=(e-n-t)/2,l=a>=o?0:!i&&o<=2*a?2*(o-a):o;return Math.ceil(Math.max(0,l-r))}var U2=Object.freeze([]),$2=e=>e;function Dl(){let e=F(),t=O($2),[o,n]=pt.useState(null),r=pt.useMemo(()=>e&&!t.isLoading?e.getOutline():U2,[e,t]),i=pt.useMemo(()=>{if(r.length===0)return [];let l=r[0].level;for(let s of r)s.level<l&&(l=s.level);return r.map(s=>({heading:s,depth:s.level-l}))},[r]),a=pt.useCallback(l=>{if(!e||typeof l!="string"||l.length===0)return;e.focus();let s={paragraphId:l,offset:0};e.exec({type:"setSelection",range:{anchor:s,head:s}}),e.scrollToBlock(l),n(l);},[e]);return {headings:r,items:i,selectedBlockId:o,goTo:a,isEmpty:r.length===0}}var Cu=150,Tu=2e3,xu=Object.freeze([]),Y2=e=>e;function kl(){let e=F(),t=O(Y2),[o,n]=pt.useState(""),[r,i]=pt.useState(""),[a,l]=pt.useState(false),[s,c]=pt.useState(false),[d,f]=pt.useState(xu),[u,g]=pt.useState(-1);pt.useEffect(()=>{if(o===r)return;let C=setTimeout(()=>i(o),Cu);return ()=>clearTimeout(C)},[o,r]);let p=pt.useMemo(()=>({matchCase:a,wholeWord:s}),[a,s]);pt.useEffect(()=>{if(!e||r.length===0){f(xu),g(-1);return}let C=e.findMatches(r,p);f(E=>E===C?E:C);},[e,r,p,t]);let m=pt.useRef(d);pt.useEffect(()=>{m.current!==d&&(m.current=d,g(C=>C>=0&&C<d.length?C:-1));},[d]);let b=pt.useCallback(C=>{if(!e)return;let E=d[C];if(!E)return;e.focus(),e.selectMatch(E).ok&&g(C);},[e,d]),v=pt.useCallback(C=>{if(d.length===0)return;let S=((u<0?C>0?-1:0:u)+C+d.length)%d.length;b(S);},[u,b,d.length]),x=pt.useCallback(()=>v(1),[v]),h=pt.useCallback(()=>v(-1),[v]),y=pt.useCallback(C=>n(C),[]),T=pt.useCallback(()=>{n(""),i(""),f(xu),g(-1);},[]);return {query:o,setQuery:y,matchCase:a,setMatchCase:l,wholeWord:s,setWholeWord:c,matches:d,truncated:d.length>=Tu,activeIndex:u,goTo:b,next:x,previous:h,clear:T,isPending:o!==r}}var t8=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,zoom:e.zoom,reviewPaneOpen:e.reviewPaneOpen??true,fitting:t?.type==="fit"&&e.zoom<(t.maxZoom??editor.ZOOM_MAX)&&e.zoom>(t.minZoom??editor.ZOOM_MIN)}},o8=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function Il(e={}){let{defaultOpen:t=false,defaultTab:o="headings",paneWidth:n=280}=e,[r,i]=pt.useState(t),[a,l]=pt.useState(o),s=e.open??r,c=e.tab??a,{onOpenChange:d,onTabChange:f}=e,u=e.open!==void 0,g=e.tab!==void 0,p=pt.useCallback(k=>{u||i(k),d?.(k);},[u,d]),m=pt.useCallback(()=>p(!s),[s,p]),b=pt.useCallback(k=>{g||l(k),f?.(k);},[g,f]),v=Qo(),x=eo(),h=pt.useContext(Ct),{pageSetup:y,zoom:T,reviewPaneOpen:C,fitting:E}=O(t8,o8),[S,D]=pt.useState(0),[R,w]=pt.useState(0),[I,H]=pt.useState(0);pt.useEffect(()=>{if(!x){D(0),w(0),H(0);return}let k=()=>{D(x.clientWidth);let W=getComputedStyle(x),re=Number.parseFloat(W.paddingInlineEnd);w(Number.isFinite(re)?re:0);let z=Number.parseFloat(W.getPropertyValue("--docx-review-gutter-start"));H(Number.isFinite(z)?z:0);};if(k(),typeof ResizeObserver>"u")return;let j=new ResizeObserver(k);return j.observe(x),()=>j.disconnect()},[x,s,C,h?.mounted]);let N=pt.useRef(null);y&&(N.current=y.pageWidthTwips);let _=y?.pageWidthTwips??N.current,P=pt.useMemo(()=>!s||_===null?0:Rl({viewportWidth:S,pageWidthPx:Ee(_)*T,reservation:sn(n),inlineEndReservation:R,inlineStartReservation:I,docked:E}),[s,_,T,S,n,R,I,E]);return pt.useEffect(()=>{if(v)return v.setShift(P),()=>v.setShift(0)},[v,P]),pt.useEffect(()=>{if(v)return v.setReservation(s?sn(n):0),()=>v.setReservation(0)},[v,s,n]),{open:s,setOpen:p,toggle:m,tab:c,setTab:b,paneWidth:n,shift:P}}var Ma=["headings","find"],qt=(...e)=>e.filter(Boolean).join(" ");function Ra({className:e,style:t,children:o}){return jsxRuntime.jsx("div",{className:qt("docx-nav__header",e),style:t,children:o??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Da,{}),jsxRuntime.jsx(ka,{})]})})}function Da({className:e,style:t,children:o}){let{pane:n,t:r}=So("Close");return jsxRuntime.jsx("button",{type:"button",className:qt("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:()=>n.setOpen(false),children:o??jsxRuntime.jsx(U,{name:"arrow_back",size:20})})}function ka({className:e,style:t,children:o}){let{t:n}=So("Title");return jsxRuntime.jsx("h2",{className:qt("docx-nav__title",e),style:t,children:o??n("navigation.title")})}function Ia({className:e,style:t,children:o}){let{pane:n,t:r}=So("Tabs"),i=pt.useCallback(a=>{let l=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(l===0)return;a.preventDefault();let s=Ma.indexOf(n.tab);n.setTab(Ma[(s+l+Ma.length)%Ma.length]);},[n]);return jsxRuntime.jsx("div",{className:qt("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:i,children:o??Ma.map(a=>jsxRuntime.jsx(_a,{value:a},a))})}function _a({value:e,className:t,style:o,children:n}){let{pane:r,t:i}=So("Tab"),a=r.tab===e;return jsxRuntime.jsx("button",{type:"button",role:"tab",id:`docx-nav-tab-${e}`,"aria-selected":a,"aria-controls":`docx-nav-panel-${e}`,tabIndex:a?0:-1,className:qt("docx-nav__tab",a&&"docx-nav__tab--selected",t),style:o,onClick:()=>r.setTab(e),children:n??i(`navigation.tabs.${e}`)})}function ab({value:e,onChange:t,onClear:o,placeholder:n,label:r,clearLabel:i,autoFocus:a}){let l=pt.useRef(null);return pt.useEffect(()=>{a&&l.current?.focus();},[a]),jsxRuntime.jsxs("div",{className:"docx-nav__searchbox",children:[jsxRuntime.jsx(U,{name:"search",size:18,className:"docx-nav__search-icon"}),jsxRuntime.jsx("input",{ref:l,type:"search",className:"docx-nav__search-input",value:e,placeholder:n,"aria-label":r,autoFocus:a,onChange:s=>t(s.target.value)}),e.length>0&&jsxRuntime.jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":i,onClick:o,children:jsxRuntime.jsx(U,{name:"close",size:16})})]})}function Na({className:e,style:t}){let{pane:o,outline:n,t:r}=So("Headings"),[i,a]=pt.useState(""),l=O(an),s=pt.useMemo(()=>{let d=i.trim().toLowerCase();return d.length===0?n.items:n.items.filter(f=>f.heading.text.toLowerCase().includes(d))},[n.items,i]),c=o.tab!=="headings";return jsxRuntime.jsxs("div",{className:qt("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:c,children:[jsxRuntime.jsx(ab,{value:i,onChange:a,onClear:()=>a(""),placeholder:r("navigation.find.placeholder"),label:r("navigation.find.inputAriaLabel"),clearLabel:r("navigation.find.clearAriaLabel")}),l?null:n.isEmpty?jsxRuntime.jsx("p",{className:"docx-nav__empty",children:r("navigation.headings.noHeadings")}):s.length===0?jsxRuntime.jsx("p",{className:"docx-nav__empty",children:r("navigation.find.noResults")}):jsxRuntime.jsx("ul",{className:"docx-nav__list",children:s.map((d,f)=>jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:qt("docx-nav__heading",n.selectedBlockId===d.heading.blockId&&"docx-nav__heading--current"),style:{paddingInlineStart:`${8+d.depth*14}px`},title:d.heading.text,onClick:()=>n.goTo(d.heading.blockId),children:d.heading.text})},`${d.heading.blockId}-${f}`))})]})}function s8({match:e,active:t,onSelect:o}){return jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:qt("docx-nav__result",t&&"docx-nav__result--active"),"aria-current":t?"true":void 0,onClick:o,children:jsxRuntime.jsxs("span",{className:"docx-nav__result-text",children:[e.contextBefore,jsxRuntime.jsx("mark",{className:"docx-nav__result-hit",children:e.text}),e.contextAfter]})})})}function La({className:e,style:t}){let{pane:o,search:n,t:r}=So("Find"),i=o.tab!=="find",a=n.query.trim().length>0,l=o.open&&!i,s=n.matches.length===0?null:n.activeIndex<0?r(n.truncated?"navigation.find.totalTruncated":"navigation.find.total",{total:n.matches.length}):r(n.truncated?"navigation.find.counterTruncated":"navigation.find.counter",{current:n.activeIndex+1,total:n.matches.length});return jsxRuntime.jsxs("div",{className:qt("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:i,children:[jsxRuntime.jsx(ab,{value:n.query,onChange:n.setQuery,onClear:n.clear,placeholder:r("navigation.find.placeholder"),label:r("navigation.find.inputAriaLabel"),clearLabel:r("navigation.find.clearAriaLabel"),autoFocus:l}),jsxRuntime.jsxs("div",{className:"docx-nav__options",role:"group","aria-label":r("navigation.find.optionsAriaLabel"),children:[jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.matchCase,onChange:c=>n.setMatchCase(c.target.checked)}),r("navigation.find.matchCase")]}),jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.wholeWord,onChange:c=>n.setWholeWord(c.target.checked)}),r("navigation.find.wholeWord")]})]}),jsxRuntime.jsxs("div",{className:"docx-nav__resultbar",children:[jsxRuntime.jsx("span",{className:"docx-nav__count","aria-live":"polite",children:a?n.isPending?r("navigation.find.searching"):s??r("navigation.find.noResults"):""}),jsxRuntime.jsxs("span",{className:"docx-nav__steppers",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":r("navigation.find.previousAriaLabel"),disabled:n.matches.length===0,onClick:n.previous,children:jsxRuntime.jsx(U,{name:"keyboard_arrow_up",size:18})}),jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":r("navigation.find.nextAriaLabel"),disabled:n.matches.length===0,onClick:n.next,children:jsxRuntime.jsx(U,{name:"keyboard_arrow_down",size:18})})]})]}),n.matches.length>0&&jsxRuntime.jsx("ul",{className:"docx-nav__list","aria-label":r("navigation.find.resultsAriaLabel"),children:n.matches.map((c,d)=>jsxRuntime.jsx(s8,{match:c,active:d===n.activeIndex,onSelect:()=>n.goTo(d)},`${c.blockId}-${c.start}-${d}`))})]})}function Fa({className:e,style:t,children:o}){let{pane:n,t:r}=So("Toggle");return jsxRuntime.jsx("button",{type:"button",className:qt("docx-nav__toggle",e),style:t,"aria-label":r("navigation.openAriaLabel"),"aria-expanded":n.open,title:r("navigation.openTitle"),onMouseDown:i=>i.preventDefault(),onClick:n.toggle,children:o??jsxRuntime.jsx(U,{name:"toc",size:20})})}function Eu(e){let t=dt(),{t:o,toggle:n=true,className:r,style:i,children:a,...l}=e,s=Il(l),c=Dl(),d=kl(),{t:f}=L(),u=pt.useMemo(()=>({pane:s,outline:c,search:d,t:o??((p,m)=>f(p,m))}),[s,c,d,o,f]),g=e.paneWidth??280;return jsxRuntime.jsx(vu.Provider,{value:u,children:jsxRuntime.jsxs("div",{className:`${t}docx-nav${s.open?" docx-nav--open":""}${r?` ${r}`:""}`,"data-open":s.open?"true":"false",style:{"--docx-nav-width":`${g}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${sn(g)}px`,...i},children:[n!==false&&!s.open&&jsxRuntime.jsx(Fa,{...typeof n=="object"?n:{}}),jsxRuntime.jsx("aside",{className:"docx-nav__panel-shell","aria-label":u.t("navigation.ariaLabel"),inert:!s.open,children:a??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ra,{}),jsxRuntime.jsx(Ia,{}),jsxRuntime.jsx(Na,{}),jsxRuntime.jsx(La,{})]})})]})})}var _l=Object.assign(Eu,{Header:Ra,Close:Da,Title:ka,Tabs:Ia,Tab:_a,Headings:Na,Find:La,Toggle:Fa});var g8=600,b8=e=>e.page.total,Nl=pt.createContext(null);function Ll({className:e,style:t}){let o=dt(),n=F(),r=eo(),i=O(b8),{t:a}=L(),l=pt.useContext(Nl),[s,c]=pt.useState(1),[d,f]=pt.useState(false);if(pt.useEffect(()=>{if(f(false),!n||!r||i<=1)return;c(n.getCurrentPage("viewport"));let g=null,p=()=>{c(n.getCurrentPage("viewport")),f(true),g&&clearTimeout(g),g=setTimeout(()=>f(false),g8);};return r.addEventListener("scroll",p,{passive:true}),()=>{r.removeEventListener("scroll",p),g&&clearTimeout(g);}},[n,i,r]),i<=1)return null;let u=l?l("viewer.pageIndicator").replace(/\{current\}/g,String(s)).replace(/\{total\}/g,String(i)):a("viewer.pageIndicator",{current:s,total:i});return jsxRuntime.jsx("div",{className:`${o}docx-editor-shell__page-indicator-chip docx-editor__page-number${e?` ${e}`:""}`,style:t,"data-visible":d?"true":"false",role:"status","aria-live":"polite",children:u})}var y8=[],x8=e=>e.fontSubstitutions??y8;function Fl({className:e,style:t,t:o}){let n=O(x8),{t:r}=L(),i=o??r,[a,l]=pt.useState(null);if(n.length===0)return null;let s=n.join("\0");return a===s?null:jsxRuntime.jsxs("div",{className:e?`docx-font-notice ${e}`:"docx-font-notice",role:"status",...t?{style:t}:{},children:[jsxRuntime.jsx("span",{className:"docx-font-notice__text",children:i("editor.fontSubstitutionNotice",{fonts:n.join(", ")}).replace("{fonts}",n.join(", "))}),jsxRuntime.jsx("button",{type:"button",className:"docx-font-notice__dismiss",onClick:()=>l(s),children:i("common.dismiss")})]})}function wu(e){return Math.round(e/1440*100)/100}function cb(e){return Math.round(e*1440)}function S8(e,t){return e===t?true:!e||!t?false:e.editing===t.editing&&e.sectionIndex===t.sectionIndex&&e.variant===t.variant&&e.rId===t.rId&&e.partName===t.partName&&e.inherited===t.inherited&&e.titlePage===t.titlePage&&e.evenAndOddHeaders===t.evenAndOddHeaders&&e.headerDistanceTwips===t.headerDistanceTwips&&e.footerDistanceTwips===t.footerDistanceTwips}function Mu(){let e=F(),t=pt.useCallback(o=>e?.getHeaderFooterState()??null,[e]);return O(t,S8)}function w8(e,t){return t==="first"?e==="header"?"headerFooter.firstPageHeader":"headerFooter.firstPageFooter":t==="even"?e==="header"?"headerFooter.evenPageHeader":"headerFooter.evenPageFooter":e==="header"?"headerFooter.header":"headerFooter.footer"}var M8=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function Aa(e){let t=F();return pt.useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let o=t.can(e);return o.ok?{enabled:true,reason:null}:{enabled:false,reason:o.reason}},[t,e])}function R8(e){let{state:t,onMouseDown:o}=e,{t:n}=L(),r=F(),[i,a]=pt.useState(false),l=pt.useRef(null),[s,c]=pt.useState(""),[d,f]=pt.useState("");pt.useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(c(String(wu(t.headerDistanceTwips))),f(String(wu(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),pt.useEffect(()=>{if(!i)return;let E=S=>{l.current?.contains(S.target)||a(false);};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[i]);let u=pt.useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=pt.useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),p=pt.useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),m=pt.useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),b=pt.useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),v=Aa(u),x=Aa(g),h=Aa(p),y=Aa(m),T=Aa(b),C=(E,S)=>{if(!r)return;let D=Number.parseFloat(S);Number.isFinite(D)&&r.exec({type:"setHeaderFooterOptions",[E]:cb(D)});};return jsxRuntime.jsxs("div",{ref:l,className:"docx-hf-chrome__options",onMouseDown:o,children:[jsxRuntime.jsx("button",{type:"button",className:"docx-context-bar__options-trigger","aria-expanded":i,"aria-haspopup":"menu",onClick:()=>a(E=>!E),onMouseDown:o,children:n("headerFooter.options")}),i?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:o,children:[M8.map(E=>{let S={type:"insertPageField",field:E.field},D=r?.can(S);return jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!D?.ok,title:D&&!D.ok?D.reason:void 0,onClick:()=>{r?.exec(S),a(false);},onMouseDown:o,children:n(E.labelKey)},E.field)}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.titlePage===true,disabled:!v.enabled,title:v.reason??void 0,onChange:()=>r?.exec(u)}),jsxRuntime.jsx("span",{children:n("headerFooter.differentFirstPage")})]}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!x.enabled,title:x.reason??void 0,onChange:()=>r?.exec(g)}),jsxRuntime.jsxs("span",{children:[n("headerFooter.differentOddEven"),jsxRuntime.jsx("span",{className:"docx-hf-chrome__menu-hint",children:n("headerFooter.differentOddEvenHint")})]})]}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),t.inherited?jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!y.enabled,title:y.reason??void 0,onClick:()=>r?.exec(m),onMouseDown:o,children:n("headerFooter.unlinkFromPrevious")}):jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!h.enabled,title:h.reason??void 0,onClick:()=>r?.exec(p),onMouseDown:o,children:n("headerFooter.linkToPrevious")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsxRuntime.jsx("span",{children:n("headerFooter.headerDistance")}),jsxRuntime.jsx("input",{type:"number",min:0,step:.01,"aria-label":n("headerFooter.headerDistance"),value:s,onChange:E=>c(E.target.value),onBlur:()=>C("headerDistanceTwips",s)}),jsxRuntime.jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsxRuntime.jsx("span",{children:n("headerFooter.footerDistance")}),jsxRuntime.jsx("input",{type:"number",min:0,step:.01,"aria-label":n("headerFooter.footerDistance"),value:d,onChange:E=>f(E.target.value),onBlur:()=>C("footerDistanceTwips",d)}),jsxRuntime.jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!T.enabled,title:T.reason??void 0,onClick:()=>r?.exec(b),onMouseDown:o,children:t.editing==="header"?n("headerFooter.removeHeader"):n("headerFooter.removeFooter")}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-hf-close",onClick:()=>{r?.exec({type:"exitHeaderFooter"}),a(false);},onMouseDown:o,children:n("common.close")})]}):null]})}function Al({className:e}){let{t}=L(),o=Mu(),n=pt.useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),r=Fr(n,"story-label"),i=Z;if(!o?.editing)return null;let a=w8(o.editing,o.variant);return jsxRuntime.jsxs("div",{ref:r.ref,className:`docx-context-bar docx-hf-chrome${e?` ${e}`:""}`,role:"region","aria-label":t("headerFooter.chromeAriaLabel"),"data-testid":"docx-hf-chrome",onMouseDown:i,style:{...r.style,zIndex:ot.hfInlineEditor},children:[jsxRuntime.jsxs("div",{className:"docx-context-bar__label",children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:t(a)}),o.inherited?jsxRuntime.jsx("span",{className:"docx-context-bar__status","data-testid":"docx-hf-inherited",title:t("headerFooter.sameAsPreviousHint"),children:t("headerFooter.sameAsPrevious")}):null]}),jsxRuntime.jsx(R8,{state:o,onMouseDown:i})]})}var _8={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},N8={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},L8={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},F8={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},A8={position:"absolute",top:40,left:0,zIndex:10,pointerEvents:"none"},H8={flex:"none",display:"flex",flexDirection:"column",position:"relative",zIndex:"var(--doc-z-overlay)",backgroundColor:"var(--doc-surface)",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--doc-border)",boxShadow:"0 1px 3px var(--doc-shadow-subtle)"},O8={padding:"8px 12px"},B8={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},Z8={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},q8={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function K8({forwardedRef:e}){let t=F(),o=pt.useRef(null);return o.current=t,ff({ref:e,editorRef:o}),null}var W8=pt.forwardRef(function(t,o){let{document:n,fonts:r,className:i,t:a,chrome:l=true,title:s,onTitleChange:c,renderTitleBarLeft:d,renderTitleBarRight:f,colorMode:u="light",author:g,locale:p,mode:m="edit",modules:b,zoom:v,zoomMode:x,onReady:h,onChange:y,onFontError:T,onOpen:C,onSave:E,hyperlinkPopup:S,contextMenu:D=true,menu:R=true,navigation:w=true,rulers:I=true}=t,[H,N]=pt.useState(wm);pt.useEffect(()=>{if(u==="system")return Rm(N)},[u]);let _=Mm(u,H),{t:P}=L(),k=pt.useCallback((z,te)=>a?a(z,te):P(z,te),[a,P]),j=jsxRuntime.jsxs(zi,{className:l?_?"dark":void 0:i,style:l?N8:void 0,children:[l?jsxRuntime.jsx(Al,{}):null,l?jsxRuntime.jsx(hi,{}):null,jsxRuntime.jsx(Bi,{}),I&&l?jsxRuntime.jsx("div",{style:A8,"aria-hidden":"true",children:jsxRuntime.jsx(wl,{})}):null,t.children]}),W=l?jsxRuntime.jsxs("div",{className:`docx-editor${_?" dark":""}${i?` ${i}`:""}`,style:_8,children:[jsxRuntime.jsxs("div",{style:H8,children:[jsxRuntime.jsxs("div",{style:B8,children:[d?.(),jsxRuntime.jsxs("div",{style:Z8,children:[c?jsxRuntime.jsx("input",{"aria-label":k("titleBar.documentNameAriaLabel"),value:s??"",placeholder:k("titleBar.untitled"),onChange:z=>c(z.target.value),style:q8}):jsxRuntime.jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:s??k("titleBar.untitled")}),R!==false?jsxRuntime.jsx(xa,{t:k,...s!==void 0?{fileName:s}:{},...C?{onOpen:C}:{},...E?{onSave:E}:{},...typeof R=="object"?R:{}}):null]}),f?.()]}),jsxRuntime.jsx("div",{style:O8,children:jsxRuntime.jsx(va,{t:k})})]}),I?jsxRuntime.jsx("div",{style:F8,"data-testid":"docx-editor-ruler-row",children:jsxRuntime.jsx(El,{})}):null,jsxRuntime.jsx(Fl,{t:k}),jsxRuntime.jsxs("div",{style:L8,children:[w===false?null:jsxRuntime.jsx(_l,{t:k,...typeof w=="object"?w:{}}),j,jsxRuntime.jsx(Nl.Provider,{value:k,children:jsxRuntime.jsx(Ll,{})}),jsxRuntime.jsx(qi,{overlay:true})]})]}):j,re=pt.useCallback(z=>k(z),[k]);return jsxRuntime.jsxs(Gr,{popups:em(t.popups,S,D,k),...n!==void 0?{document:n}:{},...r?{fonts:r}:{},...g!==void 0?{author:g}:{},...p!==void 0?{locale:p}:{},translate:k,mode:m,...b!==void 0?{modules:b}:{},...v!==void 0?{zoom:v}:{},...x!==void 0?{zoomMode:x}:{},tableInteractionLabel:re,...h?{onReady:h}:{},...y?{onChange:y}:{},...T?{onFontError:T}:{},children:[jsxRuntime.jsx(K8,{forwardedRef:o}),jsxRuntime.jsx(Wo.Provider,{value:l,children:W})]})}),z8=pt.forwardRef(function(t,o){return jsxRuntime.jsx(Cn,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsxRuntime.jsx(W8,{...t,ref:o})})}),U8=Object.assign(z8,{Root:Gr,Viewport:zi,Content:Bi,Toolbar:va,Menu:xa,Loading:qi,ColorByChangeType:od,AuthorStyle:nd,HorizontalRuler:El,VerticalRuler:wl,DocumentOutline:hu,Navigation:_l,PageSetupDialog:Yo,ParagraphDialog:Jt,TextFormFieldDialog:Wr,PageNumber:Ll,FontNotice:Fl,HeaderFooterChrome:Al,NotesChrome:hi,Equation:xr,HyperLink:br,ContextMenu:tc,ContentControlWidget:Zc,InvalidTextFormFieldDialog:vc,ImageAltTextPopup:Pi,ImagePropertiesDialog:Hr,NotePropertiesDialog:vi,NotePreview:Pn,NotesContextMenu:En,ContentControl:yr});function j8(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}function Du(e){return Array.isArray(e)?e:[e]}function X8(e){if(typeof e!="function"||editor.isFontResolver(e))return e;let t=e;return editor.defineFontResolver(async()=>t())}function fb(e){return e!==void 0&&Du(e).some(t=>editor.isFontResolver(t))}async function Q8(e){return typeof e!="function"?await e:await e()}function J8(e,t={}){let[o,n]=pt.useState(void 0),[r,i]=pt.useState(void 0),[a,l]=pt.useState(null),[s,c]=pt.useState(e!=null),d=fb(t.fonts),f=t.fonts===void 0?"absent":d?"on-demand":"eager",[u,g]=pt.useState(t.fonts===void 0),p=pt.useRef(t);p.current=t;let m=pt.useMemo(()=>editor.defineFontResolver(b=>editor.composeFontOrigins(Du(p.current.fonts??[]).map(X8),b)),[]);return pt.useEffect(()=>{let b=p.current.fonts;if(b===void 0){i(void 0),g(true);return}if(fb(b)){g(true);return}g(false);let v=true;return (async()=>{try{let x=await Promise.allSettled(Du(b).map(Q8)),h=[];for(let y of x){if(y.status==="rejected"){console.warn("[fonts] font loading failed for one origin; the others still compose",y.reason);continue}y.value!==void 0&&h.push(y.value);}v&&h.length>0&&i(editor.composeFontConfiguration(h[0],...h.slice(1)));}catch(x){console.warn("[fonts] font loading failed; the fixed measurer stays in effect",x);}finally{v&&g(true);}})(),()=>{v=false;}},[f]),pt.useEffect(()=>{if(e==null){n(void 0),l(null),c(false);return}let b=j8(e);if(b){n(b),l(null),c(false);return}let v=true,x=new AbortController;return c(true),l(null),(async()=>{try{let h=await fetch(String(e),{...p.current.fetchOptions,signal:x.signal});if(!h.ok)throw new Error(`could not open the document: ${h.status} ${h.statusText}`);let y=new Uint8Array(await h.arrayBuffer());if(!v)return;n(y),c(!1);}catch(h){if(!v||h instanceof Error&&h.name==="AbortError")return;l(h instanceof Error?h:new Error("could not open the document")),c(false);}})(),()=>{v=false,x.abort();}},[e]),{document:u?o:void 0,fonts:d?m:r,error:a,isLoading:s||!u}}function rM(...e){let t=pt.useRef(e);return t.current=e,pt.useMemo(()=>editor.defineFontResolver(o=>editor.composeFontOrigins(t.current,o)),[])}function lM(e){let o=e?.surface?.state?.().selection?.head;return o&&typeof o.paragraphId=="string"&&Number.isFinite(o.offset)?o:null}function sM(){let e=F(),t=pt.useRef(null),o=pt.useCallback(r=>{if(!e)return ()=>{};let i=e.on("selectionChange",r),a=e.on("change",r);return ()=>{i(),a();}},[e]),n=pt.useCallback(()=>{let r=lM(e),i=t.current;return (r===null?i===null:i!==null&&cM(i,r))?i:(t.current=r,r)},[e]);return pt.useSyncExternalStore(o,n,()=>null)}function cM(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function ku({source:e,scale:t,measurer:o,onStateChange:n,onError:r,className:i,documentFontFamily:a,ref:l}){let s=pt.useRef(null),c=pt.useRef(null),[d,f]=pt.useState(null),u=pt.useRef(n);u.current=n;let g=pt.useRef(r);return g.current=r,pt.useEffect(()=>{let p=s.current;if(!p)return;let m=editor.mountPaginatedSurface(p,e,{...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onChange:v=>{f(v),u.current?.(v);}});if(!m.ok){g.current?.(m.reason,m.detail);return}c.current=m.surface;let b=m.surface.state();return f(b),u.current?.(b),()=>{m.surface.destroy(),c.current=null;}},[e,o]),pt.useImperativeHandle(l,()=>({focus:()=>c.current?.focus(),type:p=>c.current?.type(p),undo:()=>c.current?.undo(),redo:()=>c.current?.redo(),selectAll:()=>c.current?.selectAll(),navigate:(p,m)=>c.current?.navigate(p,m),toggleRunProperty:(p,m)=>c.current?.toggleRunProperty(p,m),setRunProperty:(p,m)=>c.current?.setRunProperty(p,m),setParagraphProperty:(p,m,b)=>c.current?.setParagraphProperty(p,m,b),formatting:()=>c.current?.formatting()??null,sectionProperties:()=>c.current?.sectionProperties()??null,save:()=>c.current?.save()??null}),[]),jsxRuntime.jsx("div",{ref:s,style:{margin:"24px auto",...a?{fontFamily:a}:{}},className:i?`docx-paginated-surface ${i}`:"docx-paginated-surface","data-revision":d?.revision??0,"data-page-count":d?.pageCount??0})}var Oa=pt.createContext(null);function vb(){let e=pt.useContext(Oa);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function vM(e){return "type"in e&&e.type==="separator"}var Cb={display:"flex",alignItems:"center",gap:2,padding:"2px 8px",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text)",whiteSpace:"nowrap",height:28,lineHeight:"28px"},yM={...Cb,background:"var(--doc-bg-hover)"},Tb={display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap"},xM={...Tb,opacity:.4,cursor:"default"},CM={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},TM={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},SM={position:"absolute",left:"100%",top:-4,marginLeft:2,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",padding:8,zIndex:1001};function Ba({label:e,items:t,disabled:o,showChevron:n=false}){let[r,i]=pt.useState(false),[a,l]=pt.useState(null),s=pt.useRef(null),c=pt.useRef(null),[d,f]=pt.useState({top:0,left:0}),u=pt.useCallback(()=>{i(false),l(null);},[]);pt.useEffect(()=>{if(!r||!s.current)return;let p=s.current.getBoundingClientRect();f({top:p.bottom+2,left:p.left});},[r]),pt.useEffect(()=>{if(!r)return;function p(v){let x=v.target;s.current&&!s.current.contains(x)&&c.current&&!c.current.contains(x)&&u();}function m(v){v.key==="Escape"&&u();}function b(){u();}return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),window.addEventListener("scroll",b,true),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m),window.removeEventListener("scroll",b,true);}},[r,u]);let g=p=>{p.disabled||p.submenuContent||p.onClick&&(p.onClick(),u());};return jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{ref:s,type:"button",onClick:()=>!o&&i(!r),onMouseDown:p=>p.preventDefault(),disabled:o,style:r?yM:Cb,children:[e,n&&jsxRuntime.jsx(U,{name:"arrow_drop_down",size:16})]}),r&&jsxRuntime.jsx("div",{ref:c,style:{position:"fixed",top:d.top,left:d.left,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",padding:"4px 0",zIndex:1e4,minWidth:200},onMouseDown:p=>p.preventDefault(),children:t.map((p,m)=>{if(vM(p))return jsxRuntime.jsx("div",{style:CM},`sep-${m}`);let b=p;if(b.customContent)return jsxRuntime.jsx("div",{onMouseDown:h=>h.preventDefault(),children:b.customContent},b.label);let v=!!b.submenuContent,x=a===b.label;return jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>v&&l(b.label),onMouseLeave:()=>v&&l(null),children:[jsxRuntime.jsxs("button",{type:"button",style:b.disabled?xM:Tb,onClick:()=>g(b),onMouseDown:h=>h.preventDefault(),onMouseOver:h=>{b.disabled||(h.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:h=>{h.currentTarget.style.backgroundColor="transparent";},disabled:b.disabled,children:[b.icon&&jsxRuntime.jsx(U,{name:b.icon,size:18}),jsxRuntime.jsx("span",{children:b.label}),b.shortcut&&jsxRuntime.jsx("span",{style:TM,children:b.shortcut}),v&&jsxRuntime.jsx("span",{style:{marginLeft:"auto"},children:jsxRuntime.jsx(U,{name:"keyboard_arrow_right",size:16})})]}),v&&x&&jsxRuntime.jsx("div",{style:SM,onMouseDown:h=>h.preventDefault(),children:b.submenuContent(u)})]},b.label)})})]})}var Nu=18,EM=2,Pb={width:Nu,height:Nu,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},wM={...Pb,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},MM={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function Eb({onInsert:e,gridRows:t=6,gridColumns:o=6}){let[n,r]=pt.useState(0),[i,a]=pt.useState(0),l=pt.useCallback(()=>{n>0&&i>0&&e(n,i);},[n,i,e]),s=[];for(let d=1;d<=t;d++)for(let f=1;f<=o;f++){let u=d<=n&&f<=i;s.push(jsxRuntime.jsx("div",{style:u?wM:Pb,onMouseEnter:()=>{r(d),a(f);},onClick:l,role:"gridcell","aria-selected":u},`${d}-${f}`));}let c=n>0&&i>0?`${i} \xD7 ${n}`:"Select size";return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"grid",gap:EM,gridTemplateColumns:`repeat(${o}, ${Nu}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:s}),jsxRuntime.jsx("div",{style:MM,children:c})]})}function IM({items:e,closeMenu:t}){return jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",minWidth:220},children:e.map(o=>{let n=!o.onClick;return jsxRuntime.jsxs("button",{type:"button",disabled:n,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:n?"default":"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap",opacity:n?.4:1},onMouseDown:r=>r.preventDefault(),onClick:()=>{n||(o.onClick?.(),t());},onMouseOver:r=>{n||(r.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:r=>{r.currentTarget.style.backgroundColor="transparent";},children:[jsxRuntime.jsx(U,{name:o.icon,size:18}),jsxRuntime.jsx("span",{children:o.label})]},o.label)})})}function _M(){return jsxRuntime.jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[jsxRuntime.jsx("path",{d:"M2 0C0.9 0 0 0.9 0 2V38C0 39.1 0.9 40 2 40H30C31.1 40 32 39.1 32 38V10L22 0H2Z",fill:"#cbd5e1"}),jsxRuntime.jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsxRuntime.jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsxRuntime.jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function Bl({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function NM(e){return e.replace(/\.docx$/i,"")}function Fu({value:e,onChange:t,placeholder:o,editable:n=true}){let{t:r}=L(),i=o??r("titleBar.untitled"),a=NM(e)??"";return n?jsxRuntime.jsx("input",{type:"text",value:a,onChange:l=>{let s=l.target.value;t?.(s.endsWith(".docx")?s:s+".docx");},placeholder:i,className:"text-base font-normal text-foreground bg-transparent border-0 outline-none px-2 py-0 rounded hover:bg-muted focus:bg-doc-bg-input focus:ring-1 focus:ring-ring min-w-[100px] max-w-[300px] truncate leading-tight","aria-label":r("titleBar.documentNameAriaLabel")}):jsxRuntime.jsx("span",{className:"text-base font-normal text-foreground px-2 py-0 min-w-[100px] max-w-[300px] truncate leading-tight",children:a||i})}function Zl({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function ql(){let{t:e}=L(),t=vb(),{disabled:o=false,onFormat:n,onPrint:r,onOpen:i,onSave:a,onPageSetup:l,onInsertImage:s,onInsertTable:c,showTableInsert:d=true,showHelpMenu:f=true,onInsertPageBreak:u,onInsertSectionBreakNextPage:g,onInsertSectionBreakContinuous:p,onInsertTOC:m,onWatermark:b,onRefocusEditor:v}=t,x=pt.useCallback(C=>{!o&&n&&n(C);},[o,n]),h=pt.useCallback((C,E)=>{!o&&c&&(c(C,E),requestAnimationFrame(()=>v?.()));},[o,c,v]),y=!!r||!!l,T=y||i||a;return jsxRuntime.jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[T&&jsxRuntime.jsx(Ba,{label:e("toolbar.file"),disabled:o,items:[...i?[{icon:"file_upload",label:e("toolbar.open"),shortcut:e("toolbar.openShortcut"),onClick:i}]:[],...a?[{icon:"file_download",label:e("toolbar.save"),shortcut:e("toolbar.saveShortcut"),onClick:a}]:[],...(i||a)&&y?[{type:"separator"}]:[],...r?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:r}]:[],...l?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:l}]:[]]}),jsxRuntime.jsx(Ba,{label:e("toolbar.format"),disabled:o,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>x("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>x("setRtl")}]}),jsxRuntime.jsx(Ba,{label:e("toolbar.insert"),disabled:o,items:[...s?[{icon:"image",label:e("toolbar.image"),onClick:s}]:[],...d&&c?[{icon:"grid_on",label:e("toolbar.table"),submenuContent:C=>jsxRuntime.jsx(Eb,{onInsert:(E,S)=>{h(E,S),C();}})}]:[],...s||d&&c?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:C=>jsxRuntime.jsx(IM,{closeMenu:C,items:[{icon:"page_break",label:e("toolbar.pageBreak"),onClick:u},{icon:"horizontal_rule",label:e("toolbar.sectionBreakNextPage"),onClick:g},{icon:"border_horizontal",label:e("toolbar.sectionBreakContinuous"),onClick:p}]})},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:m,disabled:!m},...b?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:b}]:[]]}),f&&jsxRuntime.jsx(Ba,{label:e("toolbar.help"),disabled:o,items:[{label:e("toolbar.reportIssue"),onClick:()=>Tr()}]})]})}function Au({children:e}){let t=null,o=null,n=[],r=[];pt.Children.forEach(e,a=>{pt.isValidElement(a)&&(a.type===Bl?t=a:a.type===Zl?o=a:a.type===ql?r.push(a):n.push(a));});let i=pt.useCallback(a=>{let l=a.target;l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.tagName==="SELECT"||l.tagName==="OPTION"||a.preventDefault();},[]);return jsxRuntime.jsxs("div",{className:"flex items-stretch bg-doc-surface pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsxRuntime.jsx(_M,{})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[n.length>0&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-1",children:n}),r.length>0&&jsxRuntime.jsx("div",{className:"flex items-center px-1",children:r})]}),o&&jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:o})]})}var Kl={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},HM={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""},wb={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function OM(e,t){let o=wb[t]??wb[t.toLowerCase()]??t,r=e?.colorScheme?.[o];return typeof r=="string"&&r?r:Kl[o]??"000000"}function Mb(e){let t=e.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/.test(t))return t;if(/^[0-9A-F]{3}$/.test(t))return t.split("").map(o=>o+o).join("")}function Hu(e,t,o="000000"){if(!e||e.kind==="auto")return `#${o}`;if(e.kind==="hex")return `#${Mb(e.value)??o}`;let n=Object.entries(t?.colorScheme??Kl).map(([i,a])=>({slot:i,hex:String(a)})),r=editor.resolveThemeColorHex(e,n);return `#${r.ok?r.hex:OM(t,e.slot)}`}function ro(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?Mb(e.value):Hu(e,t).slice(1)}function Rb(e){if(!e||e==="none")return "";let t=HM[e];return t?`#${t}`:""}var BM=[{slot:"lt1",name:"Background 1"},{slot:"dk1",name:"Text 1"},{slot:"lt2",name:"Background 2"},{slot:"dk2",name:"Text 2"},{slot:"accent1",name:"Accent 1"},{slot:"accent2",name:"Accent 2"},{slot:"accent3",name:"Accent 3"},{slot:"accent4",name:"Accent 4"},{slot:"accent5",name:"Accent 5"},{slot:"accent6",name:"Accent 6"}],ZM=[{type:"base",keep:1,labelSuffix:""},{type:"tint",keep:.2,labelSuffix:", Lighter 80%"},{type:"tint",keep:.4,labelSuffix:", Lighter 60%"},{type:"tint",keep:.6,labelSuffix:", Lighter 40%"},{type:"shade",keep:.75,labelSuffix:", Darker 25%"},{type:"shade",keep:.5,labelSuffix:", Darker 50%"}];function Db(e){let t=e??Kl;return ZM.map(o=>BM.map(n=>{let r=t[n.slot]??Kl[n.slot]??"000000",a={hex:o.type==="base"?r.toUpperCase():o.type==="tint"?editor.applyThemeTint(r,o.keep):editor.applyThemeShade(r,o.keep),themeSlot:n.slot,label:`${n.name}${o.labelSuffix}`};return o.type==="tint"?a.tint=o.keep:o.type==="shade"&&(a.shade=o.keep),a}))}function ne(...e){return clsx.clsx(e)}var WM=classVarianceAuthority.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-9 w-9","icon-sm":"h-7 w-7"}},defaultVariants:{variant:"default",size:"default"}}),We=pt__namespace.forwardRef(({className:e,variant:t,size:o,...n},r)=>jsxRuntime.jsx("button",{className:ne(WM({variant:t,size:o,className:e})),ref:r,...n}));We.displayName="Button";function ht({content:e,children:t,side:o="bottom",delayMs:n=400}){let[r,i]=pt__namespace.useState(false),[a,l]=pt__namespace.useState({x:0,y:0}),s=pt__namespace.useRef(null),c=pt__namespace.useRef(null),d=pt__namespace.useCallback(()=>{c.current=setTimeout(()=>{if(s.current){let p=s.current.getBoundingClientRect(),m=p.left+p.width/2,b=o==="top"?p.top-8:p.bottom+8;l({x:m,y:b});}i(true);},n);},[n,o]),f=pt__namespace.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null),i(false);},[]);pt__namespace.useEffect(()=>()=>{c.current&&clearTimeout(c.current);},[]);let u=t.props,g=pt__namespace.cloneElement(t,{ref:s,onMouseEnter:p=>{d(),u.onMouseEnter?.(p);},onMouseLeave:p=>{f(),u.onMouseLeave?.(p);}});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g,r&&jsxRuntime.jsx("div",{className:"fixed z-50 px-2 py-1 text-xs font-medium text-white bg-foreground dark:bg-muted dark:text-foreground rounded-md shadow-lg",style:{left:a.x,top:a.y,transform:o==="top"?"translate(-50%, -100%)":o==="bottom"?"translate(-50%, 0)":void 0},children:e})]})}var Po=xe__namespace.Root,Eo=xe__namespace.Group,Wl=xe__namespace.Value;function wo({className:e,children:t,onMouseDown:o,...n}){return jsxRuntime.jsxs(xe__namespace.Trigger,{className:ne("flex h-8 items-center justify-between gap-1 rounded px-2 py-1","text-sm text-foreground bg-transparent","hover:bg-muted/80 focus:outline-none focus:bg-muted/80","disabled:cursor-not-allowed disabled:opacity-50","transition-colors duration-150","[&>span]:truncate",e),onMouseDown:r=>{r.preventDefault(),o?.(r);},...n,children:[t,jsxRuntime.jsx(xe__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(GM,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function Mo({className:e,children:t,position:o="popper",onCloseAutoFocus:n,...r}){let i=typeof document<"u"&&!!document.querySelector(".docx-editor.dark");return jsxRuntime.jsx(xe__namespace.Portal,{children:jsxRuntime.jsx("div",{className:ne("docx-editor",i&&"dark"),children:jsxRuntime.jsx(xe__namespace.Content,{className:ne("relative z-50 max-h-72 min-w-[8rem] overflow-hidden","rounded-lg border border-border bg-popover text-popover-foreground shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",e),position:o,onCloseAutoFocus:a=>{a.preventDefault(),n?.(a);},...r,children:jsxRuntime.jsx(xe__namespace.Viewport,{className:ne("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:a=>a.preventDefault(),children:t})})})})}function un({className:e,...t}){return jsxRuntime.jsx(xe__namespace.Label,{className:ne("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function vt({className:e,children:t,onMouseDown:o,...n}){return jsxRuntime.jsxs(xe__namespace.Item,{className:ne("relative flex w-full cursor-pointer select-none items-center","rounded px-2 py-1.5 text-sm text-foreground outline-none","hover:bg-muted focus:bg-muted","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onMouseDown:r=>{r.preventDefault(),o?.(r);},...n,children:[jsxRuntime.jsx(xe__namespace.ItemText,{children:t}),jsxRuntime.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsxRuntime.jsx(xe__namespace.ItemIndicator,{children:jsxRuntime.jsx(YM,{className:"h-4 w-4"})})})]})}function pn({className:e,...t}){return jsxRuntime.jsx(xe__namespace.Separator,{className:ne("-mx-1 my-1 h-px bg-muted",e),...t})}function GM({className:e}){return jsxRuntime.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})}function YM({className:e}){return jsxRuntime.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:jsxRuntime.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})}function Ou(e){let t=e.trim();if(!t)return "";let o=null,n="";for(let r of t){if((r==='"'||r==="'")&&o===null){o=r,n+=r;continue}if(r===o){o=null,n+=r;continue}if(r===","&&o===null)break;n+=r;}return n.trim().replace(/^['"]|['"]$/g,"")}var jM=[{name:"Arial",fontFamily:"Arial, Helvetica, sans-serif",category:"sans-serif"},{name:"Calibri",fontFamily:'"Calibri", Arial, sans-serif',category:"sans-serif"},{name:"Helvetica",fontFamily:"Helvetica, Arial, sans-serif",category:"sans-serif"},{name:"Verdana",fontFamily:"Verdana, Geneva, sans-serif",category:"sans-serif"},{name:"Open Sans",fontFamily:'"Open Sans", sans-serif',category:"sans-serif"},{name:"Roboto",fontFamily:"Roboto, sans-serif",category:"sans-serif"},{name:"Times New Roman",fontFamily:'"Times New Roman", Times, serif',category:"serif"},{name:"Georgia",fontFamily:"Georgia, serif",category:"serif"},{name:"Cambria",fontFamily:"Cambria, Georgia, serif",category:"serif"},{name:"Garamond",fontFamily:"Garamond, serif",category:"serif"},{name:"Courier New",fontFamily:'"Courier New", Courier, monospace',category:"monospace"},{name:"Consolas",fontFamily:"Consolas, monospace",category:"monospace"}];function _b({value:e,onChange:t,fonts:o=jM,documentFonts:n,disabled:r=false,className:i,placeholder:a="Arial",width:l=120,showPreview:s=true}){let{t:c}=L(),d=pt__namespace.useMemo(()=>{if(!n)return [];let m=new Set(o.map(b=>b.name.toLowerCase()));return n.filter(b=>!m.has(b.name.toLowerCase()))},[n,o]),f=pt__namespace.useMemo(()=>[...d,...o],[d,o]),u=pt__namespace.useMemo(()=>e?f.find(b=>b.fontFamily===e||b.name.toLowerCase()===e.toLowerCase()||Ou(b.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,f,a]),g=pt__namespace.useCallback(m=>{let b=f.find(v=>v.name===m);b&&t?.(Ou(b.fontFamily)||b.name);},[t,f]),p=pt__namespace.useMemo(()=>{let m={"sans-serif":[],serif:[],monospace:[],other:[]};return o.forEach(b=>{let v=b.category||"other";m[v].push(b);}),m},[o]);return jsxRuntime.jsxs(Po,{value:u,onValueChange:g,disabled:r,children:[jsxRuntime.jsx(wo,{className:ne("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":c("font.selectAriaLabel"),children:jsxRuntime.jsx(Wl,{placeholder:a,children:u})}),jsxRuntime.jsxs(Mo,{className:"max-h-[300px]",children:[d.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Eo,{children:[jsxRuntime.jsx(un,{children:c("font.documentFonts")}),d.map(m=>jsxRuntime.jsx(vt,{value:m.name,style:s?{fontFamily:m.fontFamily}:void 0,children:m.name},`doc-${m.name}`))]}),jsxRuntime.jsx(pn,{})]}),p["sans-serif"].length>0&&jsxRuntime.jsxs(Eo,{children:[jsxRuntime.jsx(un,{children:c("font.sansSerif")}),p["sans-serif"].map(m=>jsxRuntime.jsx(vt,{value:m.name,style:s?{fontFamily:m.fontFamily}:void 0,children:m.name},m.name))]}),p.serif.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(pn,{}),jsxRuntime.jsxs(Eo,{children:[jsxRuntime.jsx(un,{children:c("font.serif")}),p.serif.map(m=>jsxRuntime.jsx(vt,{value:m.name,style:s?{fontFamily:m.fontFamily}:void 0,children:m.name},m.name))]})]}),p.monospace.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(pn,{}),jsxRuntime.jsxs(Eo,{children:[jsxRuntime.jsx(un,{children:c("font.monospace")}),p.monospace.map(m=>jsxRuntime.jsx(vt,{value:m.name,style:s?{fontFamily:m.fontFamily}:void 0,children:m.name},m.name))]})]}),p.other.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(pn,{}),jsxRuntime.jsx(Eo,{children:p.other.map(m=>jsxRuntime.jsx(vt,{value:m.name,style:s?{fontFamily:m.fontFamily}:void 0,children:m.name},m.name))})]})]})]})}function Bu(e){if(e===void 0)return;let t=e.map(o=>typeof o=="string"?{name:o,fontFamily:o,category:"other"}:o);return t}function eR(e,t,o,n){let i=Math.max(8,window.innerWidth-o-8),a=Math.max(8,window.innerHeight-n-8);return {top:Math.min(Math.max(8,e),a),left:Math.min(Math.max(8,t),i)}}function st({isOpen:e,onClose:t,align:o="left"}){let n=pt.useRef(null),r=pt.useRef(null),[i,a]=pt.useState({top:0,left:0});pt.useEffect(()=>{if(!e||!n.current)return;let c=n.current.getBoundingClientRect();o==="right"?requestAnimationFrame(()=>{if(r.current){let d=r.current.getBoundingClientRect(),f=eR(c.bottom+4,c.right-d.width,d.width,d.height);a(f);}else a({top:c.bottom+4,left:c.left});}):a({top:c.bottom+4,left:c.left});},[e,o]),pt.useEffect(()=>{if(!e)return;let c=performance.now()+150,d=g=>{let p=g.target;n.current&&!n.current.contains(p)&&r.current&&!r.current.contains(p)&&t();},f=g=>{g.key==="Escape"&&t();},u=g=>{if(performance.now()<c)return;let p=g.target;p&&r.current&&r.current.contains(p)||p instanceof Element&&p!==document.documentElement&&p!==document.body&&n.current&&p.contains(n.current)||t();};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),window.addEventListener("scroll",u,true),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f),window.removeEventListener("scroll",u,true);}},[e,t]);let l=pt.useCallback(c=>{c.preventDefault(),c.stopPropagation();},[]),s={position:"fixed",top:i.top,left:i.left,zIndex:1e4};return {containerRef:n,dropdownRef:r,dropdownStyle:s,handleMouseDown:l}}var nR=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],rR=1,aR=400;function Fb(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function Ab(e,t,o){for(let n=t.length-1;n>=0;n--)if(t[n]<e)return t[n];return Math.max(e-1,o)}function Hb({value:e,onChange:t,sizes:o=nR,disabled:n=false,className:r,placeholder:i="11",minSize:a=rR,maxSize:l=aR}){let{t:s}=L(),[c,d]=pt.useState(false),[f,u]=pt.useState(""),[g,p]=pt.useState(false),m=pt.useRef(null),b=pt.useCallback(()=>{p(false),d(false);},[]),{containerRef:v,dropdownRef:x,dropdownStyle:h}=st({isOpen:g,onClose:b}),y=e??(parseInt(i,10)||11),T=e!==void 0?e.toString():i,C=pt.useCallback(N=>{if(N.preventDefault(),n)return;let _=Ab(y,o,a);t?.(_);},[y,o,a,n,t]),E=pt.useCallback(N=>{if(N.preventDefault(),n)return;let _=Fb(y,o,l);t?.(_);},[y,o,l,n,t]),S=pt.useCallback(N=>{N.preventDefault(),!n&&(d(true),u(T),p(true),requestAnimationFrame(()=>{m.current?.focus(),m.current?.select();}));},[n,T]),D=pt.useCallback(N=>{u(N.target.value);},[]),R=pt.useCallback(()=>{d(false);let N=parseFloat(f);if(!isNaN(N)&&N>=a&&N<=l){let _=Math.round(N*2)/2;t?.(_);}},[f,a,l,t]),w=pt.useCallback(N=>{if(N.key==="Enter")N.preventDefault(),R(),p(false);else if(N.key==="Escape")d(false),p(false);else if(N.key==="ArrowUp"){N.preventDefault();let _=Fb(y,o,l);u(_.toString()),t?.(_);}else if(N.key==="ArrowDown"){N.preventDefault();let _=Ab(y,o,a);u(_.toString()),t?.(_);}},[R,y,o,l,a,t]),I=pt.useCallback(N=>{t?.(N),p(false),d(false);},[t]),H=pt.useCallback(N=>{N.target.tagName!=="INPUT"&&N.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:v,className:ne("flex items-center",r),onMouseDown:H,children:[jsxRuntime.jsx(We,{variant:"ghost",size:"icon-sm",className:ne("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:C,disabled:n||y<=a,"aria-label":s("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsxRuntime.jsx(U,{name:"remove",size:18})}),jsxRuntime.jsx("div",{className:"relative",children:c?jsxRuntime.jsx("input",{ref:m,type:"text",value:f,onChange:D,onBlur:R,onKeyDown:w,className:ne("h-7 w-10 text-center text-sm border border-input bg-doc-bg-input text-doc-text","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none"),"aria-label":s("fontSize.label"),"data-testid":"font-size-input"}):jsxRuntime.jsx("button",{type:"button",onClick:S,className:ne("h-7 w-10 text-center text-sm border border-border bg-doc-bg-input text-doc-text","hover:border-input hover:bg-doc-bg-hover","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none",n&&"opacity-50 cursor-not-allowed"),disabled:n,"aria-label":s("fontSize.label"),"aria-haspopup":"listbox","aria-expanded":g,"data-testid":"font-size-display",children:T})}),g&&jsxRuntime.jsx("div",{ref:x,style:{...h,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",maxHeight:240,overflowY:"auto",minWidth:60},role:"listbox","aria-label":s("fontSize.listLabel"),children:o.map(N=>jsxRuntime.jsx("button",{type:"button",onClick:()=>I(N),className:ne("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",N===y&&"bg-muted font-medium"),role:"option","aria-selected":N===y,children:N},N))}),jsxRuntime.jsx(We,{variant:"ghost",size:"icon-sm",className:ne("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:E,disabled:n||y>=l,"aria-label":s("fontSize.increase"),"data-testid":"font-size-increase",children:jsxRuntime.jsx(U,{name:"add",size:18})})]})}var sR=[{name:"Dark Red",nameKey:"colorPicker.colors.darkRed",hex:"C00000"},{name:"Red",nameKey:"colorPicker.colors.red",hex:"FF0000"},{name:"Orange",nameKey:"colorPicker.colors.orange",hex:"FFC000"},{name:"Yellow",nameKey:"colorPicker.colors.yellow",hex:"FFFF00"},{name:"Light Green",nameKey:"colorPicker.colors.lightGreen",hex:"92D050"},{name:"Green",nameKey:"colorPicker.colors.green",hex:"00B050"},{name:"Light Blue",nameKey:"colorPicker.colors.lightBlue",hex:"00B0F0"},{name:"Blue",nameKey:"colorPicker.colors.blue",hex:"0070C0"},{name:"Dark Blue",nameKey:"colorPicker.colors.darkBlue",hex:"002060"},{name:"Purple",nameKey:"colorPicker.colors.purple",hex:"7030A0"}],Ul=18,cR=2,dR={position:"relative",display:"inline-block"},uR={display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"32px",padding:"2px 6px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},pR={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},Ku={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},Wu={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},Zb={display:"grid",gap:`${cR}px`},$l={width:`${Ul}px`,height:`${Ul}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},qb={...$l,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},Kb={...$l,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},mR={display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"5px 8px",border:"1px solid var(--doc-border-dark)",borderRadius:"4px",backgroundColor:"var(--doc-surface)",cursor:"pointer",fontSize:"12px",color:"var(--doc-text)"},fR={display:"flex",alignItems:"center",gap:"6px"},gR={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},bR={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},Ob={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},hR={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},vR={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:0,width:"28px",padding:"2px 4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},yR={display:"flex",alignItems:"center",justifyContent:"center",width:"18px",padding:0,border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"};function zu(e,t,o){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let n=Rb(e);return n||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return Hu(e,o)}function Bb(e){let t=e.replace(/^#/,"");if(t.length!==6)return false;let o=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return (o*299+n*587+r*114)/1e3>230}function Wb(e,t,o){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():ro(e,o))===t.toUpperCase():false}function xR({matrix:e,selectedColor:t,theme:o,onSelect:n}){let[r,i]=pt.useState(null);return jsxRuntime.jsx("div",{style:{...Zb,gridTemplateColumns:`repeat(10, ${Ul}px)`},children:e.flatMap((a,l)=>a.map((s,c)=>{let d=`${l}-${c}`,f=r===d,u=Wb(t,s.hex,o);return jsxRuntime.jsx("button",{type:"button",style:{...u?Kb:f?qb:$l,backgroundColor:`#${s.hex}`},title:s.label,"aria-label":s.label,"aria-selected":u,onClick:()=>n(s),onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>i(d),onMouseLeave:()=>i(null)},d)}))})}function CR({selectedColor:e,theme:t,onSelect:o}){let[n,r]=pt.useState(null),{t:i}=L();return jsxRuntime.jsx("div",{style:{...Zb,gridTemplateColumns:`repeat(10, ${Ul}px)`},children:sR.map((a,l)=>{let s=n===l,c=Wb(e,a.hex,t),d=i(a.nameKey);return jsxRuntime.jsx("button",{type:"button",style:{...c?Kb:s?qb:$l,backgroundColor:`#${a.hex}`},title:d,"aria-label":d,"aria-selected":c,onClick:()=>o(a.hex),onMouseDown:f=>f.preventDefault(),onMouseEnter:()=>r(l),onMouseLeave:()=>r(null)},a.hex)})})}function gn({mode:e,value:t,onChange:o,theme:n,disabled:r=false,className:i,style:a,title:l,icon:s,autoLabel:c,splitButton:d=true,defaultColor:f}){let[u,g]=pt.useState(false),[p,m]=pt.useState(false),[b,v]=pt.useState(false),[x,h]=pt.useState(false),[y,T]=pt.useState(""),[C,E]=pt.useState(()=>f??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:S}=L();pt.useEffect(()=>{let V=zu(t,e,n).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(V)&&T(V.toUpperCase());},[t,e,n]);let D=pt.useCallback(()=>g(false),[]),{containerRef:R,dropdownRef:w,dropdownStyle:I}=st({isOpen:u,onClose:D}),H=n?.colorScheme??null,N=pt.useMemo(()=>Db(H),[H]),_=pt.useMemo(()=>zu(t,e,n),[t,e,n]),P=pt.useMemo(()=>zu(C,e,n),[C,e,n]),k=pt.useCallback(()=>{r||g(V=>!V);},[r]),j=pt.useCallback(V=>{let q;e==="highlight"?q=V.hex:q={kind:"theme",slot:V.themeSlot,...V.tint!==void 0?{tint:V.tint}:{},...V.shade!==void 0?{shade:V.shade}:{}},E(q),o?.(q),g(false);},[e,o]),W=pt.useCallback(V=>{let q=e==="highlight"?V:{kind:"hex",value:V};E(q),o?.(q),g(false);},[e,o]),re=pt.useCallback(()=>{o?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,o]),z=pt.useCallback(()=>{let V=y.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(V)){let q=e==="highlight"?V:{kind:"hex",value:V};E(q),o?.(q),g(false),T("");}},[e,y,o]),te=pt.useCallback(()=>{r||o?.(C);},[r,C,o]),B={...uR,...r?{cursor:"default",opacity:.38}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:p?{backgroundColor:"var(--doc-bg-hover)"}:{}},J=S(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),de=s??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxRuntime.jsxs("div",{ref:R,className:`docx-color-picker ${i||""}`,style:{...dR,...a},children:[d?jsxRuntime.jsxs("div",{className:"docx-color-picker-split",style:{...hR,...r?{opacity:.38,cursor:"default"}:null},children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...vR,...r?{cursor:"default"}:b?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:te,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>v(true),onMouseLeave:()=>v(false),disabled:r,title:l||J,"aria-label":l||J,children:[jsxRuntime.jsx(U,{name:de,size:18}),jsxRuntime.jsx("div",{style:{...Ob,backgroundColor:P==="transparent"?"#fff":P,outline:P==="transparent"||Bb(P)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...yR,...r?{cursor:"default"}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:x?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:k,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>h(true),onMouseLeave:()=>h(false),disabled:r,title:l||J,"aria-label":l||J,"aria-haspopup":"true","aria-expanded":u,children:jsxRuntime.jsx(U,{name:"arrow_drop_down",size:18})})]}):jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-button",style:B,onClick:k,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>m(true),onMouseLeave:()=>m(false),disabled:r,title:l||J,"aria-label":l||J,"aria-haspopup":"true","aria-expanded":u,children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsxRuntime.jsx(U,{name:de,size:18}),jsxRuntime.jsx("div",{style:{...Ob,backgroundColor:_==="transparent"?"#fff":_,outline:_==="transparent"||Bb(_)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx(U,{name:"arrow_drop_down",size:14})]}),u&&jsxRuntime.jsx("div",{ref:w,className:"docx-color-picker-dropdown",style:{...I,...pR},role:"dialog","aria-label":`${J} picker`,onMouseDown:V=>{V.target.tagName!=="INPUT"&&V.preventDefault();},children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",style:mR,onClick:re,onMouseDown:V=>V.preventDefault(),children:[e==="highlight"?jsxRuntime.jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",border:"1px solid #ccc",borderRadius:"2px",position:"relative",backgroundColor:"#fff"},children:jsxRuntime.jsx("span",{style:{position:"absolute",top:"50%",left:"-1px",right:"-1px",height:"2px",backgroundColor:"#ff0000",transform:"rotate(-45deg)"}})}):jsxRuntime.jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",backgroundColor:"#000",borderRadius:"2px"}}),c??S(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsxRuntime.jsx("div",{style:Wu}),jsxRuntime.jsx("div",{style:Ku,children:S("colorPicker.themeColors")}),jsxRuntime.jsx(xR,{matrix:N,selectedColor:t,theme:n,onSelect:j}),jsxRuntime.jsx("div",{style:Wu}),jsxRuntime.jsx("div",{style:Ku,children:S("colorPicker.standardColors")}),jsxRuntime.jsx(CR,{selectedColor:t,theme:n,onSelect:W}),jsxRuntime.jsx("div",{style:Wu}),jsxRuntime.jsx("div",{style:Ku,children:S("colorPicker.customColor")}),jsxRuntime.jsxs("div",{style:fR,children:[jsxRuntime.jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsxRuntime.jsx("input",{type:"text",style:gR,value:y,onChange:V=>T(V.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:V=>{V.key==="Enter"&&z();},onMouseDown:V=>{V.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsxRuntime.jsx("button",{type:"button",style:{...bR,opacity:/^[0-9A-Fa-f]{6}$/.test(y)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(y)?"pointer":"default"},onClick:z,onMouseDown:V=>V.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(y),children:S("common.apply")})]})]})})]})}var qa=20,Uu=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsxRuntime.jsx(U,{name:"format_align_left",size:qa}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsxRuntime.jsx(U,{name:"format_align_center",size:qa}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsxRuntime.jsx(U,{name:"format_align_right",size:qa}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsxRuntime.jsx(U,{name:"format_align_justify",size:qa}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function $b({value:e="left",onChange:t,disabled:o=false}){let{t:n}=L(),[r,i]=pt.useState(false),a=pt.useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:s,dropdownStyle:c,handleMouseDown:d}=st({isOpen:r,onClose:a}),f=pt.useCallback(v=>{o||t?.(v),i(false);},[o,t]),u=Uu.find(v=>v.value===e)||Uu[0],g=n(u.labelKey),p=u.shortcutKey?n(u.shortcutKey):void 0,m=`${g}${p?` (${p})`:""}`,b=jsxRuntime.jsxs(We,{variant:"ghost",size:"icon-sm",className:ne("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",o&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!o&&i(v=>!v),disabled:o,"aria-label":m,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsxRuntime.jsx(U,{name:u.iconName,size:qa}),jsxRuntime.jsx(U,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[r?b:jsxRuntime.jsx(ht,{content:m,children:b}),r&&!o&&jsxRuntime.jsx("div",{ref:s,style:{...c,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:v=>v.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",gap:2},children:Uu.map(v=>{let x=e===v.value,h=n(v.labelKey),y=v.shortcutKey?n(v.shortcutKey):void 0;return jsxRuntime.jsx("button",{type:"button",title:`${h}${y?` (${y})`:""}`,"data-testid":`alignment-${v.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:x?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:x?"var(--doc-primary)":"var(--doc-text)"},onMouseDown:T=>T.preventDefault(),onMouseEnter:T=>{x||(T.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:T=>{T.currentTarget.style.backgroundColor=x?"var(--doc-primary-light)":"transparent";},onClick:()=>f(v.value),children:jsxRuntime.jsx(U,{name:v.iconName,size:18})},v.value)})})})]})}function Vl(){return {type:"none",level:0,isInList:false}}var wR={display:"inline-flex",alignItems:"center",gap:"4px"},Vb={display:"inline-flex",alignItems:"center",gap:"4px"},Xl={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",padding:"4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},MR={...Xl,backgroundColor:"var(--doc-bg-hover)"},RR={...Xl,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},DR={...Xl,cursor:"default",opacity:.38},kR={width:"28px",height:"28px",padding:"2px"},IR={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Gl=20;function Yl({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,style:a}){let[l,s]=pt.useState(false),c={...t?DR:e?RR:l?MR:Xl,...a},d=f=>{f.preventDefault();};return jsxRuntime.jsx("button",{type:"button",className:`docx-list-button ${e?"docx-list-button-active":""} ${t?"docx-list-button-disabled":""} ${i||""}`,style:c,onMouseDown:d,onClick:t?void 0:n,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-disabled":t||void 0,tabIndex:t?-1:void 0,title:o,"aria-label":o,"aria-pressed":e,role:"button",children:r})}function Gb({listState:e,onBulletList:t,onNumberedList:o,onIndent:n,onOutdent:r,disabled:i=false,className:a,style:l,showIndentButtons:s=true,compact:c=false,hasIndent:d=false}){let{t:f}=L(),u=pt.useCallback(()=>c?{...kR}:{},[c]),g=e?.type==="bullet",p=e?.type==="numbered",b=(e?.isInList||g||p)&&(e?.level??0)>0||d;return jsxRuntime.jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...wR,...l},role:"group","aria-label":f("lists.ariaLabel"),children:[jsxRuntime.jsxs("div",{style:Vb,role:"group","aria-label":f("lists.typeAriaLabel"),children:[jsxRuntime.jsx(Yl,{active:g,disabled:i,title:f("lists.bulletList"),onClick:t,style:u(),children:jsxRuntime.jsx(U,{name:"format_list_bulleted",size:Gl})}),jsxRuntime.jsx(Yl,{active:p,disabled:i,title:f("lists.numberedList"),onClick:o,style:u(),children:jsxRuntime.jsx(U,{name:"format_list_numbered",size:Gl})})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:IR,role:"separator"}),jsxRuntime.jsxs("div",{style:Vb,role:"group","aria-label":f("lists.indentationAriaLabel"),children:[jsxRuntime.jsx(Yl,{active:false,disabled:i||!b,title:f("lists.decreaseIndent"),onClick:r,style:u(),children:jsxRuntime.jsx(U,{name:"format_indent_decrease",size:Gl})}),jsxRuntime.jsx(Yl,{active:false,disabled:i,title:f("lists.increaseIndent"),onClick:n,style:u(),children:jsxRuntime.jsx(U,{name:"format_indent_increase",size:Gl})})]})]})]})}var NR=[{label:"Single",labelKey:"lineSpacing.single",value:1,twipsValue:240},{label:"1.15",value:1.15,twipsValue:276},{label:"1.5",value:1.5,twipsValue:360},{label:"Double",labelKey:"lineSpacing.double",value:2,twipsValue:480}];function jb({value:e,onChange:t,options:o=NR,disabled:n=false,className:r}){let{t:i}=L(),a=pt__namespace.useMemo(()=>e===void 0?o[0]:o.find(c=>c.twipsValue===e)||o[0],[e,o]),l=pt__namespace.useCallback(c=>{let d=parseInt(c,10);isNaN(d)||t?.(d);},[t]),s=c=>c.labelKey?i(c.labelKey):c.label;return jsxRuntime.jsxs(Po,{value:a.twipsValue.toString(),onValueChange:l,disabled:n,children:[jsxRuntime.jsx(wo,{className:ne("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},"aria-label":i("lineSpacing.label"),title:i("lineSpacing.lineSpacingTitle",{label:s(a)}),children:jsxRuntime.jsx(gu,{className:"h-5 w-5 shrink-0"})}),jsxRuntime.jsxs(Mo,{children:[o.map(c=>jsxRuntime.jsx(vt,{value:c.twipsValue.toString(),children:s(c)},c.twipsValue)),jsxRuntime.jsx(pn,{}),jsxRuntime.jsx(Eo,{children:jsxRuntime.jsx(un,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var Xb=[{styleId:"Normal",name:"Normal text",nameKey:"styles.normalText",type:"paragraph",isDefault:true,priority:0,qFormat:true,fontSize:22},{styleId:"Title",name:"Title",nameKey:"styles.title",type:"paragraph",priority:1,qFormat:true,fontSize:52,bold:true},{styleId:"Subtitle",name:"Subtitle",nameKey:"styles.subtitle",type:"paragraph",priority:2,qFormat:true,fontSize:30,color:"666666"},{styleId:"Heading1",name:"Heading 1",nameKey:"styles.heading1",type:"paragraph",priority:3,qFormat:true,fontSize:40,bold:true},{styleId:"Heading2",name:"Heading 2",nameKey:"styles.heading2",type:"paragraph",priority:4,qFormat:true,fontSize:32,bold:true},{styleId:"Heading3",name:"Heading 3",nameKey:"styles.heading3",type:"paragraph",priority:5,qFormat:true,fontSize:28,bold:true}];function Qb({value:e,onChange:t,styles:o,disabled:n=false,className:r,width:i=120}){let{t:a}=L(),l=pt__namespace.useMemo(()=>{let g=Dg(o);return g.length===0?Xb:g.map(p=>({...p,type:"paragraph",nameKey:Xb.find(m=>m.styleId===p.styleId)?.nameKey}))},[o]),s=pt__namespace.useCallback(g=>{t?.(g);},[t]),c=g=>g.nameKey?a(g.nameKey):g.name,d=e||"Normal",f=l.find(g=>g.styleId===d),u=f?c(f):d;return jsxRuntime.jsxs(Po,{value:d,onValueChange:s,disabled:n,children:[jsxRuntime.jsx(wo,{className:ne("h-8 text-sm",r),style:{width:typeof i=="number"?`${i}px`:i},"aria-label":a("styles.selectAriaLabel"),children:jsxRuntime.jsx("span",{className:"truncate",children:u})}),jsxRuntime.jsx(Mo,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsxRuntime.jsx(vt,{value:g.styleId,className:"py-2.5 px-3",children:jsxRuntime.jsx("span",{style:Rg(g),children:c(g)})},g.styleId))})]})}var FR=[{value:.5,label:"50%"},{value:.75,label:"75%"},{value:1,label:"100%"},{value:1.25,label:"125%"},{value:1.5,label:"150%"},{value:2,label:"200%"}];function eh({value:e=1,onChange:t,levels:o=FR,disabled:n=false,className:r,compact:i=false}){let{t:a}=L(),l=pt__namespace.useMemo(()=>{let g=o.find(p=>Math.abs(p.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[o,e]),s=pt__namespace.useCallback(g=>{let p=parseFloat(g);isNaN(p)||t?.(p);},[t]),c=pt__namespace.useMemo(()=>[...o].sort((g,p)=>g.value-p.value),[o]),d=pt__namespace.useMemo(()=>[...c].reverse().find(g=>g.value<e-.001),[c,e]),f=pt__namespace.useMemo(()=>c.find(g=>g.value>e+.001),[c,e]),u=i?"h-7 w-7":"h-8 w-8";return jsxRuntime.jsxs("div",{className:"flex items-center",children:[jsxRuntime.jsx(We,{variant:"ghost",size:"icon-sm",className:ne(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",(n||!d)&&"opacity-30 cursor-not-allowed"),onClick:()=>d&&t?.(d.value),disabled:n||!d,"aria-label":a("zoom.zoomOut"),children:jsxRuntime.jsx(U,{name:"remove",size:18})}),jsxRuntime.jsxs(Po,{value:e.toString(),onValueChange:s,disabled:n,children:[jsxRuntime.jsx(wo,{className:ne(i?"h-7 min-w-[55px] text-xs":"h-8 min-w-[64px] text-sm","rounded-none",r),"aria-label":a("zoom.ariaLabel",{label:l}),children:jsxRuntime.jsx(Wl,{placeholder:"100%",children:l})}),jsxRuntime.jsx(Mo,{children:o.map(g=>jsxRuntime.jsx(vt,{value:g.value.toString(),children:g.label},g.value))})]}),jsxRuntime.jsx(We,{variant:"ghost",size:"icon-sm",className:ne(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(n||!f)&&"opacity-30 cursor-not-allowed"),onClick:()=>f&&t?.(f.value),disabled:n||!f,"aria-label":a("zoom.zoomIn"),children:jsxRuntime.jsx(U,{name:"add",size:18})})]})}var HR=[{action:"borderAll",icon:"border_all",labelKey:"table.borders.all"},{action:"borderOutside",icon:"border_outer",labelKey:"table.borders.outside"},{action:"borderInside",icon:"border_inner",labelKey:"table.borders.inside"},{action:"borderTop",icon:"border_top",labelKey:"table.borders.top"},{action:"borderBottom",icon:"border_bottom",labelKey:"table.borders.bottom"},{action:"borderLeft",icon:"border_left",labelKey:"table.borders.left"},{action:"borderRight",icon:"border_right",labelKey:"table.borders.right"},{action:"borderNone",icon:"border_clear",labelKey:"table.borders.none"}];function nh({onAction:e,disabled:t=false}){let{t:o}=L(),[n,r]=pt.useState(false),i=pt.useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=st({isOpen:n,onClose:i}),d=pt.useCallback(u=>{e(u),r(false);},[e]),f=jsxRuntime.jsxs(We,{variant:"ghost",size:"icon-sm",className:ne("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&r(u=>!u),disabled:t,"aria-label":o("table.borders.styleAriaLabel"),"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsxRuntime.jsx(U,{name:"border_all",size:20}),jsxRuntime.jsx(U,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[n?f:jsxRuntime.jsx(ht,{content:o("table.borders.tooltip"),children:f}),n&&!t&&jsxRuntime.jsx("div",{ref:l,style:{...s,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:u=>u.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:HR.map(({action:u,icon:g,labelKey:p})=>jsxRuntime.jsx("button",{type:"button",title:o(p),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:"transparent",cursor:"pointer",color:"var(--doc-text)"},onMouseDown:m=>m.preventDefault(),onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(u),children:jsxRuntime.jsx(U,{name:g,size:18})},typeof u=="string"?u:u.type))})})]})}function rh({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=L(),i=pt.useCallback(a=>{if(typeof a=="string"){e({type:"borderColor",color:a.replace(/^#/,"")});return}let l=a.kind==="auto"?"000000":ro(a,o);l&&e({type:"borderColor",color:l});},[e,o]);return jsxRuntime.jsx(gn,{mode:"border",value:n,onChange:i,theme:o,disabled:t,title:r("table.borderColor")})}var qR=[{size:4,label:"0.5 pt",thickness:.5},{size:8,label:"1 pt",thickness:1},{size:12,label:"1.5 pt",thickness:1.5},{size:16,label:"2 pt",thickness:2},{size:24,label:"3 pt",thickness:3}];function ih({onAction:e,disabled:t=false}){let[o,n]=pt.useState(false),{t:r}=L(),i=pt.useCallback(()=>n(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=st({isOpen:o,onClose:i}),d=pt.useCallback(u=>{e({type:"borderWidth",size:u}),n(false);},[e]),f=jsxRuntime.jsxs(We,{variant:"ghost",size:"icon-sm",className:ne("text-muted-foreground hover:text-foreground hover:bg-muted/80",o&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&n(u=>!u),disabled:t,"aria-label":r("table.borderWidth"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsxRuntime.jsx(U,{name:"line_weight",size:20}),jsxRuntime.jsx(U,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[o?f:jsxRuntime.jsx(ht,{content:r("table.borderWidth"),children:f}),o&&!t&&jsxRuntime.jsx("div",{ref:l,style:{...s,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:"4px 0",minWidth:120},onMouseDown:u=>u.stopPropagation(),children:qR.map(({size:u,label:g,thickness:p})=>jsxRuntime.jsxs("button",{type:"button",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",width:"100%",border:"none",backgroundColor:"transparent",cursor:"pointer",fontSize:12,color:"var(--doc-text)"},onMouseDown:m=>m.preventDefault(),onMouseEnter:m=>{m.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(u),children:[jsxRuntime.jsx("div",{style:{width:50,height:Math.max(p,1),backgroundColor:"#000",borderRadius:p>2?1:0}}),jsxRuntime.jsx("span",{children:g})]},u))})]})}function sh({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=L(),i=pt.useCallback(a=>{typeof a=="string"&&e(a==="none"?{type:"cellFillColor",color:null}:{type:"cellFillColor",color:a.replace(/^#/,"")});},[e]);return jsxRuntime.jsx("div",{"data-testid":"toolbar-table-cell-fill",style:{display:"inline-block"},children:jsxRuntime.jsx(gn,{mode:"highlight",value:n,onChange:i,theme:o,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var WR={display:"flex",alignItems:"center",gap:10,padding:"7px 14px",fontSize:13,color:"var(--doc-text)",cursor:"pointer",border:"none",backgroundColor:"transparent",width:"100%",textAlign:"left"},vn={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},uh={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function ph({onAction:e,disabled:t=false,tableContext:o}){let{t:n}=L(),[r,i]=pt.useState(false),[a,l]=pt.useState(null),s=pt.useCallback(()=>i(false),[]),{containerRef:c,dropdownRef:d,dropdownStyle:f,handleMouseDown:u}=st({isOpen:r,onClose:s,align:"right"}),g=o?.table?.attrs?.justification??"left",p=pt.useCallback(v=>{e(v),i(false);},[e]),m=(v,x,h,y,T)=>{let C=t||T?.itemDisabled;return jsxRuntime.jsxs("button",{type:"button",role:"menuitem",style:{...WR,backgroundColor:a===v&&!C?"var(--doc-bg-hover)":"transparent",color:C?"var(--doc-text-muted)":T?.danger?"var(--doc-error)":"var(--doc-text)",cursor:C?"not-allowed":"pointer"},onClick:()=>!C&&p(y),onMouseEnter:()=>l(v),onMouseLeave:()=>l(null),disabled:C,children:[jsxRuntime.jsx(U,{name:x,size:16,className:T?.danger&&!C?"text-destructive":""}),jsxRuntime.jsx("span",{style:{flex:1},children:h})]},v)},b=jsxRuntime.jsx(We,{variant:"ghost",size:"icon-sm",className:ne("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!t&&i(v=>!v),disabled:t,"aria-label":n("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsxRuntime.jsx(U,{name:"more_vert",size:20})});return jsxRuntime.jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[r?b:jsxRuntime.jsx(ht,{content:n("table.moreOptions"),children:b}),r&&!t&&jsxRuntime.jsxs("div",{ref:d,style:{...f,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:"4px 0",minWidth:200,maxHeight:"70vh",overflowY:"auto"},role:"menu",onMouseDown:v=>v.stopPropagation(),children:[m("addRowAbove","add",n("table.insertRowAbove"),"addRowAbove"),m("addRowBelow","add",n("table.insertRowBelow"),"addRowBelow"),m("addColumnLeft","add",n("table.insertColumnLeft"),"addColumnLeft"),m("addColumnRight","add",n("table.insertColumnRight"),"addColumnRight"),jsxRuntime.jsx("div",{style:vn,role:"separator"}),m("mergeCells","call_merge",n("table.mergeCells"),"mergeCells",{itemDisabled:!o?.hasMultiCellSelection}),m("splitCell","call_split",n("table.splitCell"),"splitCell",{itemDisabled:!o?.canSplitCell}),jsxRuntime.jsx("div",{style:vn,role:"separator"}),m("selectTable","select_all",n("table.selectTable"),"selectTable"),jsxRuntime.jsx("div",{style:vn,role:"separator"}),m("deleteRow","delete",n("table.deleteRow"),"deleteRow",{danger:true,itemDisabled:(o?.rowCount??0)<=1}),m("deleteColumn","delete",n("table.deleteColumn"),"deleteColumn",{danger:true,itemDisabled:(o?.columnCount??0)<=1}),m("deleteTable","delete",n("table.deleteTable"),"deleteTable",{danger:true}),jsxRuntime.jsx("div",{style:vn,role:"separator"}),jsxRuntime.jsx("div",{style:uh,children:n("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(v=>{let x={top:"vertical_align_top",center:"vertical_align_center",bottom:"vertical_align_bottom"};return jsxRuntime.jsx("button",{type:"button",title:n({top:"tableAdvanced.top",center:"tableAdvanced.middle",bottom:"tableAdvanced.bottom"}[v]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:y=>y.preventDefault(),onMouseEnter:y=>{y.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:y=>{y.currentTarget.style.backgroundColor="transparent";},onClick:()=>p({type:"cellVerticalAlign",align:v}),children:jsxRuntime.jsx(U,{name:x[v],size:16})},v)})}),jsxRuntime.jsx("div",{style:vn,role:"separator"}),jsxRuntime.jsx("div",{style:uh,children:n("tableAdvanced.tableAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(v=>{let x={left:"format_align_left",center:"format_align_center",right:"format_align_right"},h=g===v;return jsxRuntime.jsx("button",{type:"button",title:n({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[v]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:h?"var(--doc-primary-light)":"transparent",borderColor:h?"var(--doc-primary)":"var(--doc-border)",color:h?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:y=>y.preventDefault(),onClick:()=>p({type:"tableProperties",props:{justification:v}}),children:jsxRuntime.jsx(U,{name:x[v],size:16})},v)})}),jsxRuntime.jsx("div",{style:vn,role:"separator"}),m("headerRow","table_rows",n("tableAdvanced.toggleHeaderRow"),{type:"toggleHeaderRow"}),m("distribute","view_column",n("tableAdvanced.distributeColumns"),{type:"distributeColumns"}),m("autoFit","fit_width",n("tableAdvanced.autoFit"),{type:"autoFitContents"}),m("noWrap","wrap_text",n("tableAdvanced.toggleNoWrap"),{type:"toggleNoWrap"}),jsxRuntime.jsx("div",{style:vn,role:"separator"}),m("properties","settings",n("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var UR=20;function es({options:e,activeValue:t,triggerIcon:o,tooltipContent:n,onSelect:r,disabled:i=false,ariaLabel:a,testId:l,showLabels:s=false}){let[c,d]=pt.useState(false),f=pt.useCallback(()=>d(false),[]),{containerRef:u,dropdownRef:g,dropdownStyle:p,handleMouseDown:m}=st({isOpen:c,onClose:f}),b=pt.useCallback(x=>{i||r(x),d(false);},[i,r]),v=jsxRuntime.jsxs(We,{variant:"ghost",size:"icon-sm",className:ne("text-muted-foreground hover:text-foreground hover:bg-muted/80",c&&"bg-muted",i&&"opacity-30 cursor-not-allowed"),onMouseDown:m,onClick:()=>!i&&d(x=>!x),disabled:i,"aria-label":a??n,"aria-expanded":c,"aria-haspopup":"true","data-testid":l,children:[jsxRuntime.jsx(U,{name:o,size:UR}),jsxRuntime.jsx(U,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:u,style:{position:"relative",display:"inline-block"},children:[c?v:jsxRuntime.jsx(ht,{content:n,children:v}),c&&!i&&jsxRuntime.jsx("div",{ref:g,style:{...p,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:x=>x.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:s?"column":"row",gap:s?1:2,minWidth:s?200:void 0},children:e.map(x=>{let h=t===x.value;return jsxRuntime.jsxs("button",{type:"button",title:x.label,"data-testid":l?`${l}-${x.value}`:void 0,style:{display:"flex",alignItems:"center",height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:h?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:h?"var(--doc-primary)":"var(--doc-text)",...s?{width:"100%",gap:10,padding:"0 10px",justifyContent:"flex-start",fontSize:13,textAlign:"left"}:{width:32,justifyContent:"center"}},onMouseDown:y=>y.preventDefault(),onMouseEnter:y=>{h||(y.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:y=>{y.currentTarget.style.backgroundColor=h?"var(--doc-primary-light)":"transparent";},onClick:()=>b(x.value),children:[jsxRuntime.jsx(U,{name:x.iconName,size:18}),s&&jsxRuntime.jsx("span",{style:{flex:1},children:x.label})]},x.value)})})})]})}var $R=[{value:"inline",labelKey:"imageWrap.inline",iconName:"wrap_text"},{value:"wrapRight",labelKey:"imageWrap.floatLeft",iconName:"format_image_left"},{value:"wrapLeft",labelKey:"imageWrap.floatRight",iconName:"format_image_right"},{value:"behind",labelKey:"imageWrap.behindText",iconName:"flip_to_back"},{value:"inFront",labelKey:"imageWrap.inFrontOfText",iconName:"flip_to_front"}];function VR(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function fh({imageContext:e,onChange:t,disabled:o=false}){let{t:n}=L(),r=$R.map(l=>({...l,label:n(l.labelKey)})),i=VR(e),a=r.find(l=>l.value===i)||r[0];return jsxRuntime.jsx(es,{options:r,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:o,testId:"toolbar-image-wrap",showLabels:true})}var YR=[{value:"rotateCW",labelKey:"imageTransform.rotateClockwise",iconName:"rotate_right"},{value:"rotateCCW",labelKey:"imageTransform.rotateCounterClockwise",iconName:"rotate_left"},{value:"flipH",labelKey:"imageTransform.flipHorizontal",iconName:"swap_horiz"},{value:"flipV",labelKey:"imageTransform.flipVertical",iconName:"swap_vert"}];function gh({onTransform:e,disabled:t=false}){let{t:o}=L(),n=YR.map(r=>({...r,label:o(r.labelKey)}));return jsxRuntime.jsx(es,{options:n,triggerIcon:"rotate_right",tooltipContent:o("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var Dt=18;function yt({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,ariaLabel:a}){let l=a?.toLowerCase().replace(/\s+/g,"-")||o?.toLowerCase().replace(/\s+/g,"-").replace(/\([^()]*\)/g,"").trim(),s=d=>{d.preventDefault();},c=jsxRuntime.jsx(We,{variant:"ghost",size:"icon-sm",className:ne("docx-editor-toolbar-toggle text-muted-foreground",t&&"opacity-30 cursor-not-allowed",i),"data-active":e?"true":void 0,onMouseDown:s,onClick:t?void 0:n,"aria-disabled":t||void 0,tabIndex:t?-1:void 0,"aria-pressed":!!e,"aria-label":a||o,"data-testid":l?`toolbar-${l}`:void 0,children:r});return o?jsxRuntime.jsx(ht,{content:o,children:c}):c}function kt({label:e,children:t,className:o}){return jsxRuntime.jsx("div",{className:ne("flex items-center gap-px px-1.5 border-r border-border/50 last:border-r-0 first:pl-0",o),role:"group","aria-label":e,children:t})}function eD(e){let t=pt__namespace.default.useContext(Oa);return t?{...t,...tD(e)}:e}function tD(e){let t={};for(let o of Object.keys(e))e[o]!==void 0&&(t[o]=e[o]);return t}function Yu(e){let{t}=L(),o=eD(e),{currentFormatting:n={},onFormat:r,onUndo:i,onRedo:a,canUndo:l=false,canRedo:s=false,disabled:c=false,className:d,style:f,enableShortcuts:u=true,editorRef:g,children:p,showFontPicker:m=true,fontFamilies:b,documentFonts:v,showFontSizePicker:x=true,showTextColorPicker:h=true,showHighlightColorPicker:y=true,showAlignmentButtons:T=true,showListButtons:C=true,showLineSpacingPicker:E=true,showStylePicker:S=true,documentStyles:D,theme:R,showZoomControl:w=true,zoom:I,onZoomChange:H,onRefocusEditor:N,imageContext:_,onImageWrapType:P,onImageTransform:k,onOpenImageProperties:j,tableContext:W,onTableAction:re,inline:z=false}=o,te=pt.useRef(null),B=pt.useCallback(me=>{!c&&r&&r(me);},[c,r]),J=pt.useCallback(()=>{!c&&l&&i&&i();},[c,l,i]),de=pt.useCallback(()=>{!c&&s&&a&&a();},[c,s,a]),V=pt.useCallback(me=>{!c&&r&&r({type:"fontFamily",value:me});},[c,r]),q=pt__namespace.default.useMemo(()=>Bu(b),[b]),Re=pt.useCallback(me=>{!c&&r&&r({type:"fontSize",value:me});},[c,r]),je=pt.useCallback(me=>{!c&&r&&r({type:"textColor",value:me});},[c,r]),pe=pt.useCallback(me=>{!c&&r&&r({type:"highlightColor",value:typeof me=="string"?me:""});},[c,r]),ze=pt.useCallback(me=>{!c&&r&&r({type:"alignment",value:me});},[c,r]),Ut=pt.useCallback(()=>{!c&&r&&r("bulletList");},[c,r]),he=pt.useCallback(()=>{!c&&r&&r("numberedList");},[c,r]),_t=pt.useCallback(()=>{!c&&r&&r("indent");},[c,r]),is=pt.useCallback(()=>{!c&&r&&r("outdent");},[c,r]),ls=pt.useCallback(me=>{!c&&r&&(r({type:"lineSpacing",value:me}),requestAnimationFrame(()=>N?.()));},[c,r,N]),xn=pt.useCallback(me=>{!c&&r&&r({type:"applyStyle",value:me});},[c,r]),lo=pt.useCallback(me=>{!c&&re&&(re(me),requestAnimationFrame(()=>N?.()));},[c,re,N]);pt.useEffect(()=>{if(!u)return;let me=ge=>{if(ge.defaultPrevented)return;let $t=ge.target,Vt=g?.current,cr=te.current,Ua=Vt?.contains($t),xt=cr?.contains($t);if(!Ua&&!xt)return;if((ge.ctrlKey||ge.metaKey)&&!ge.altKey)switch(ge.key.toLowerCase()){case "b":ge.preventDefault(),B("bold");break;case "i":ge.preventDefault(),B("italic");break;case "u":ge.preventDefault(),B("underline");break;case "=":ge.shiftKey?(ge.preventDefault(),B("superscript")):(ge.preventDefault(),B("subscript"));break;case "l":ge.preventDefault(),ze("left");break;case "e":ge.preventDefault(),ze("center");break;case "r":ge.preventDefault(),ze("right");break;case "j":ge.preventDefault(),ze("both");break;case "k":ge.preventDefault(),B("insertLink");break}};return document.addEventListener("keydown",me),()=>{document.removeEventListener("keydown",me);}},[u,B,ze,g]);let Ne=pt.useCallback(me=>{let ge=me.target;ge.tagName==="INPUT"||ge.tagName==="TEXTAREA"||ge.tagName==="SELECT"||ge.tagName==="OPTION"||me.preventDefault();},[]),za=pt.useCallback(me=>{let ge=me.target,$t=document.activeElement;ge.tagName==="SELECT"||ge.tagName==="OPTION"||$t?.tagName==="SELECT"||requestAnimationFrame(()=>{N?.();});},[N]);return jsxRuntime.jsxs("div",{ref:te,className:ne(!z&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:z?{display:"contents",...f}:f,role:z?void 0:"toolbar","aria-label":z?void 0:t("toolbar.ariaLabel"),"data-testid":z?void 0:"formatting-bar",onMouseDown:z?void 0:Ne,onMouseUp:z?void 0:za,children:[jsxRuntime.jsxs(kt,{label:t("formattingBar.groups.history"),children:[jsxRuntime.jsx(yt,{onClick:J,disabled:c||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsxRuntime.jsx(U,{name:"undo",size:Dt})}),jsxRuntime.jsx(yt,{onClick:de,disabled:c||!s,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsxRuntime.jsx(U,{name:"redo",size:Dt})})]}),w&&jsxRuntime.jsx(kt,{label:t("formattingBar.groups.zoom"),children:jsxRuntime.jsx(eh,{value:I,onChange:H,disabled:c,compact:true})}),S&&jsxRuntime.jsx(kt,{label:t("formattingBar.groups.styles"),children:jsxRuntime.jsx(Qb,{value:n.styleId||"Normal",onChange:xn,styles:D,theme:R,disabled:c,width:120})}),(m||x)&&jsxRuntime.jsxs(kt,{label:t("formattingBar.groups.font"),children:[m&&jsxRuntime.jsx(_b,{value:n.fontFamily||"Arial",onChange:V,fonts:q,documentFonts:v,disabled:c,width:60,placeholder:"Arial"}),x&&jsxRuntime.jsx(Hb,{value:n.fontSize!==void 0?ed(n.fontSize):11,onChange:Re,disabled:c,width:42,placeholder:"11"})]}),jsxRuntime.jsxs(kt,{label:t("formattingBar.groups.textFormatting"),children:[jsxRuntime.jsx(yt,{onClick:()=>B("bold"),active:n.bold,disabled:c,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsxRuntime.jsx(U,{name:"format_bold",size:Dt})}),jsxRuntime.jsx(yt,{onClick:()=>B("italic"),active:n.italic,disabled:c,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsxRuntime.jsx(U,{name:"format_italic",size:Dt})}),jsxRuntime.jsx(yt,{onClick:()=>B("underline"),active:n.underline,disabled:c,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsxRuntime.jsx(U,{name:"format_underlined",size:Dt})}),jsxRuntime.jsx(yt,{onClick:()=>B("strikethrough"),active:n.strike,disabled:c,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsxRuntime.jsx(U,{name:"strikethrough_s",size:Dt})}),h&&jsxRuntime.jsx(gn,{mode:"text",value:n.color?.replace(/^#/,""),onChange:je,theme:R,disabled:c,title:t("formattingBar.fontColor")}),y&&jsxRuntime.jsx(gn,{mode:"highlight",value:n.highlight,onChange:pe,theme:R,disabled:c,title:t("formattingBar.highlightColor")}),jsxRuntime.jsx(yt,{onClick:()=>B("insertLink"),disabled:c,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsxRuntime.jsx(U,{name:"link",size:Dt})})]}),jsxRuntime.jsxs(kt,{label:t("formattingBar.groups.script"),children:[jsxRuntime.jsx(yt,{onClick:()=>B("superscript"),active:n.superscript,disabled:c,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsxRuntime.jsx(U,{name:"superscript",size:Dt})}),jsxRuntime.jsx(yt,{onClick:()=>B("subscript"),active:n.subscript,disabled:c,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsxRuntime.jsx(U,{name:"subscript",size:Dt})})]}),T&&jsxRuntime.jsx(kt,{label:t("formattingBar.groups.alignment"),children:jsxRuntime.jsx($b,{value:n.alignment||"left",onChange:ze,disabled:c})}),(C||E)&&jsxRuntime.jsxs(kt,{label:t("formattingBar.groups.listFormatting"),children:[C&&jsxRuntime.jsx(Gb,{listState:n.listState||Vl(),onBulletList:Ut,onNumberedList:he,onIndent:_t,onOutdent:is,disabled:c,showIndentButtons:true,compact:true,hasIndent:(n.indentLeft??0)>0}),E&&jsxRuntime.jsx(jb,{value:n.lineSpacing,onChange:ls,disabled:c})]}),_&&P&&jsxRuntime.jsxs(kt,{label:t("formattingBar.groups.image"),children:[jsxRuntime.jsx(fh,{imageContext:_,onChange:P,disabled:c}),k&&jsxRuntime.jsx(gh,{onTransform:k,disabled:c}),j&&jsxRuntime.jsx(yt,{onClick:j,disabled:c,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsxRuntime.jsx(U,{name:"tune",size:Dt})})]}),W?.isInTable&&re&&jsxRuntime.jsxs(kt,{label:t("formattingBar.groups.table"),children:[jsxRuntime.jsx(nh,{onAction:lo,disabled:c}),jsxRuntime.jsx(rh,{onAction:lo,disabled:c,theme:R,value:ro(W?.cellBorderColor,R)}),jsxRuntime.jsx(ih,{onAction:lo,disabled:c}),jsxRuntime.jsx(sh,{onAction:lo,disabled:c,theme:R,value:W?.cellBackgroundColor}),jsxRuntime.jsx(ph,{onAction:lo,disabled:c,tableContext:W})]}),jsxRuntime.jsx(yt,{onClick:()=>B("clearFormatting"),disabled:c,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsxRuntime.jsx(U,{name:"format_clear",size:Dt})}),p]})}function oD({children:e,className:t,style:o,...n}){return jsxRuntime.jsx(Oa.Provider,{value:n,children:jsxRuntime.jsx("div",{className:ne("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:ot.toolbar,...o},"data-testid":"editor-toolbar",children:e})})}var ct=oD;ct.TitleBar=Au;ct.Logo=Bl;ct.DocumentName=Fu;ct.MenuBar=ql;ct.TitleBarRight=Zl;ct.Toolbar=Yu;var aD=new Map([["#ffff00","yellow"],["#00ff00","green"],["#00ffff","cyan"],["#ff00ff","magenta"],["#0000ff","blue"],["#ff0000","red"],["#000080","darkBlue"],["#008080","darkCyan"],["#008000","darkGreen"],["#800080","darkMagenta"],["#800000","darkRed"],["#808000","darkYellow"],["#808080","darkGray"],["#c0c0c0","lightGray"],["#ffffff","white"]]),iD=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function lD({source:e,scale:t,measurer:o,documentName:n,onStateChange:r,onError:i,onSave:a,renderTitleBarLeft:l,renderTitleBarRight:s,ref:c,colorMode:d,onZoomChange:f,documentFontFamily:u,className:g}){let p=pt.useRef(null),[m,b]=pt.useState(null),[v,x]=pt.useState({}),[h,y]=pt.useState(null),T=pt.useCallback(D=>{b(D);let R=p.current?.formatting();R&&x({bold:R.bold,italic:R.italic,underline:R.underline,strike:R.strikethrough,superscript:R.superscript,subscript:R.subscript,...R.fontFamily?{fontFamily:R.fontFamily}:{},...R.fontSizeHalfPoints?{fontSize:R.fontSizeHalfPoints}:{},...R.alignment?{alignment:R.alignment}:{},...R.styleId?{styleId:R.styleId}:{},...R.color?{color:`#${R.color}`}:{},...R.highlight?{highlight:R.highlight}:{}}),y(p.current?.sectionProperties()??null),r?.(D);},[r]),C=pt.useCallback(D=>{let R=p.current;if(R){if(typeof D=="string")switch(D){case "bold":return R.toggleRunProperty("b");case "italic":return R.toggleRunProperty("i");case "underline":return R.toggleRunProperty("u",{val:"single"});case "strikethrough":return R.toggleRunProperty("strike");case "superscript":return R.setRunProperty("vertAlign",{val:"superscript"});case "subscript":return R.setRunProperty("vertAlign",{val:"subscript"});case "clearFormatting":R.setRunProperty("b",{val:"0"}),R.setRunProperty("i",{val:"0"}),R.setRunProperty("u",{val:"none"}),R.setRunProperty("strike",{val:"0"}),R.setRunProperty("vertAlign",{val:"baseline"});return;default:return}switch(D.type){case "fontFamily":return R.setRunProperty("rFonts",{ascii:D.value,hAnsi:D.value});case "fontSize":return R.setRunProperty("sz",{val:String(Math.round(D.value*2))});case "textColor":{let w=D.value,I=typeof w=="string"?iD(w):ro(w,null)??null;return I?R.setRunProperty("color",{val:I}):void 0}case "highlightColor":{let w=D.value.trim().toLowerCase();if(w==="none"||w==="")return R.setRunProperty("highlight",{val:"none"});let I=aD.get(w.startsWith("#")?w:`#${w}`);return I?R.setRunProperty("highlight",{val:I}):void 0}case "alignment":return R.setParagraphProperty("jc",{val:String(D.value)});case "lineSpacing":return R.setParagraphProperty("spacing",{line:String(Math.round(D.value)),lineRule:"auto"},{mergeAttributes:true});case "applyStyle":return R.setParagraphProperty("pStyle",{val:D.value});default:return}}},[]);pt.useImperativeHandle(c,()=>p.current,[]);let E=t===void 0?1:t/(96/72),S=h?{pageWidthTwips:h.pageSize.widthTwips,pageHeightTwips:h.pageSize.heightTwips,orientation:h.landscape?"landscape":"portrait",marginsTwips:{top:h.margins.topTwips,right:h.margins.rightTwips,bottom:h.margins.bottomTwips,left:h.margins.leftTwips}}:null;return jsxRuntime.jsxs("div",{className:["docx-editor docx-paginated-shell",d==="dark"?"dark":"",g??""].filter(Boolean).join(" "),style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,background:"var(--doc-bg)",color:"var(--doc-text)"},"data-testid":"paginated-shell",children:[jsxRuntime.jsxs(ct,{currentFormatting:v,onFormat:C,onUndo:()=>p.current?.undo(),onRedo:()=>p.current?.redo(),canUndo:m?.canUndo??false,canRedo:m?.canRedo??false,zoom:E,onZoomChange:f,onSave:()=>{let D=p.current?.save();D&&a?.(D);},children:[jsxRuntime.jsxs(ct.TitleBar,{children:[l&&jsxRuntime.jsx(ct.Logo,{children:l()}),jsxRuntime.jsx(ct.DocumentName,{value:n??"Document",editable:false}),s&&jsxRuntime.jsx(ct.TitleBarRight,{children:s()}),jsxRuntime.jsx(ct.MenuBar,{})]}),jsxRuntime.jsx(ct.Toolbar,{})]}),jsxRuntime.jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[S?jsxRuntime.jsx("div",{style:{padding:"4px 0"},children:jsxRuntime.jsx(rn,{pageSetup:S,zoom:E})}):null,jsxRuntime.jsx(ku,{ref:p,source:e,...u?{documentFontFamily:u}:{},...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onStateChange:T,...i?{onError:i}:{}})]})]})}var os=class{listeners=new Set;snapshot;constructor(t){this.snapshot=t;}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t);});getSnapshot=()=>this.snapshot;setSnapshot(t){this.snapshot=t,this.notify();}notify(){for(let t of this.listeners)t();}};var ns=class extends os{notifications=[];idCounter=0;timers=new Set;constructor(){super({notifications:[]});}showError(t,o){return this.addNotification(t,"error",o)}showWarning(t,o){return this.addNotification(t,"warning",o)}showInfo(t,o){return this.addNotification(t,"info",o)}dismiss(t){this.notifications=this.notifications.map(n=>n.id===t?{...n,dismissed:true}:n),this.emitSnapshot();let o=setTimeout(()=>{this.timers.delete(o),this.notifications=this.notifications.filter(n=>n.id!==t),this.emitSnapshot();},300);this.timers.add(o);}clearAll(){this.notifications=[];for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.emitSnapshot();}destroy(){for(let t of this.timers)clearTimeout(t);this.timers.clear(),this.notifications=[];}addNotification(t,o,n){let r=`error-${++this.idCounter}-${Date.now()}`,i={id:r,message:t,severity:o,details:n,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),o!=="error"){let a=setTimeout(()=>{this.timers.delete(a),this.dismiss(r);},5e3);this.timers.add(a);}return r}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var mD=pt.createContext(null);function xh({children:e}){let t=pt.useMemo(()=>new ns,[]),o=pt.useSyncExternalStore(t.subscribe,t.getSnapshot),n=pt.useCallback((c,d)=>{t.showError(c,d);},[t]),r=pt.useCallback((c,d)=>{t.showWarning(c,d);},[t]),i=pt.useCallback((c,d)=>{t.showInfo(c,d);},[t]),a=pt.useCallback(c=>{t.dismiss(c);},[t]),l=pt.useCallback(()=>{t.clearAll();},[t]),s=pt.useMemo(()=>({notifications:o.notifications,showError:n,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:l}),[o.notifications,n,r,i,a,l]);return jsxRuntime.jsxs(mD.Provider,{value:s,children:[e,jsxRuntime.jsx(fD,{notifications:o.notifications,onDismiss:a})]})}function fD({notifications:e,onDismiss:t}){let o=e.filter(r=>!r.dismissed);return o.length===0?null:jsxRuntime.jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:o.map(r=>jsxRuntime.jsx(gD,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function gD({notification:e,onDismiss:t}){let{t:o}=L(),[n,r]=pt.useState(false),a=(m=>{switch(m){case "error":return {bg:"var(--doc-error-bg)",border:"var(--doc-error)",text:"var(--doc-error)",icon:"var(--doc-error)"};case "warning":return {bg:"var(--doc-warning-bg)",border:"var(--doc-warning)",text:"var(--doc-warning-text)",icon:"var(--doc-warning)"};case "info":return {bg:"var(--doc-primary-light)",border:"var(--doc-primary)",text:"var(--doc-primary)",icon:"var(--doc-primary)"}}})(e.severity),l={background:a.bg,border:`1px solid ${a.border}`,borderRadius:"8px",padding:"12px 16px",boxShadow:"0 2px 8px var(--doc-shadow)",animation:"docx-notification-slide-in 0.3s ease-out"},s={display:"flex",alignItems:"flex-start",gap:"8px"},c={color:a.icon,flexShrink:0},d={flex:1,minWidth:0},f={color:a.text,fontSize:"14px",fontWeight:500,wordBreak:"break-word"},u={marginTop:"8px",padding:"8px",background:"var(--doc-shadow-subtle)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word",color:a.text,maxHeight:"200px",overflow:"auto"},g={background:"transparent",border:"none",cursor:"pointer",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:a.text},p=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.jsx("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:l,children:jsxRuntime.jsxs("div",{style:s,children:[jsxRuntime.jsx("span",{style:c,children:p(e.severity)}),jsxRuntime.jsxs("div",{style:d,children:[jsxRuntime.jsx("div",{style:f,children:e.message}),e.details&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>r(!n),style:{...g,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:o(n?"errors.hideDetails":"errors.showDetails")}),n&&jsxRuntime.jsx("div",{style:u,children:e.details})]})]}),jsxRuntime.jsx("button",{type:"button",onClick:t,style:g,title:o("common.dismiss"),children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsxRuntime.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}var rs=class extends pt.Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",t,o),this.props.onError&&this.props.onError(t,o);}resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};render(){if(this.state.hasError){let{fallback:t,showDetails:o=true}=this.props,{error:n,errorInfo:r}=this.state;return t?typeof t=="function"?t(n,this.resetError):t:jsxRuntime.jsx(bD,{error:n,errorInfo:r,showDetails:o,onReset:this.resetError})}return this.props.children}};function bD({error:e,errorInfo:t,showDetails:o,onReset:n}){let{t:r}=L(),i={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"var(--doc-surface)",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},a={color:"var(--doc-error)",marginBottom:"16px"},l={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},c={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"},d={padding:"10px 20px",background:"var(--doc-primary)",color:"var(--doc-on-primary)",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:"docx-error-fallback",style:i,children:[jsxRuntime.jsx("div",{style:a,children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsxRuntime.jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h2",{style:l,children:r("errors.somethingWentWrong")}),jsxRuntime.jsx("p",{style:s,children:r("errors.errorDescription")}),o&&jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("strong",{children:r("errors.errorLabel")})," ",e.message,t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[`
|
|
3
3
|
|
|
4
|
-
`,jsxRuntime.jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:n,style:d,children:r("errors.tryAgain")})]})}function Zb({onClick:e,topPx:t,scrollLeft:o=0,leftOffset:n=Xn}){let{t:r}=L();return jsxRuntime.jsx("button",{className:"docx-outline-toggle",onClick:e,onMouseDown:i=>i.stopPropagation(),title:r("editor.showDocumentOutline"),"aria-label":r("editor.showDocumentOutline"),style:{position:"absolute",left:n-o,top:t,zIndex:Qe.outline},children:jsxRuntime.jsx($,{name:"format_list_bulleted",size:20})})}function hu({currentPage:e,totalPages:t,visible:o}){let{t:n}=L();return jsxRuntime.jsx("div",{style:{position:"absolute",right:24,top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--doc-overlay)",color:"#fff",padding:"6px 12px",borderRadius:"4px",fontSize:"12px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:500,whiteSpace:"nowrap",pointerEvents:"none",zIndex:1e3,opacity:o?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:n("viewer.pageIndicator",{current:e,total:t})})}function hM({i18n:e,isDark:t,onEditorError:o,containerRef:n,scrollContainerRef:r,editorContentRef:i,className:a,containerStyle:l,mainContentStyle:s,editorContainerStyle:c,showRuler:d,readOnlyProp:f,showOutline:u,showOutlineButton:g,sidebarOpen:p,minLayoutWidth:m,toolbarHeight:b,editorScrollLeft:h,onScrollContainerMouseDown:x,onEditorBgMouseDown:v,onEditorContextMenu:y,horizontalRulerProps:C,verticalRulerProps:T,outlineProps:w,onToggleOutline:S,scrollPageInfo:M,toolbar:R,pagedArea:D,overlays:_,dialogs:H,fileInputs:N}){let I=d&&!f;return jsxRuntime.jsx(Bo.Provider,{value:true,children:jsxRuntime.jsx(bn,{i18n:e,children:jsxRuntime.jsx(Hb,{children:jsxRuntime.jsx($l,{onError:o,children:jsxRuntime.jsxs("div",{ref:n,className:ne("docx-editor",t&&"dark",a),style:l,"data-testid":"docx-editor",children:[jsxRuntime.jsx("div",{style:s,children:jsxRuntime.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[R,jsxRuntime.jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:c,onMouseDown:x,children:[d&&jsxRuntime.jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:Qe.ruler,paddingLeft:20,paddingRight:20+(p?352:0),minWidth:m,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(Jo,{...C})}),jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:m},children:jsxRuntime.jsxs("div",{ref:i,style:{position:"relative",flex:1,minWidth:0},onMouseDown:v,onContextMenu:y,children:[I&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:Qe.ruler,paddingTop:48},children:jsxRuntime.jsx(ba,{...T})}),D]})})]}),M.totalPages>1&&jsxRuntime.jsx(hu,{currentPage:M.currentPage,totalPages:M.totalPages,visible:M.visible}),u&&jsxRuntime.jsx(va,{...w,leftOffset:ha+(I?Yn:0)}),g&&!u&&jsxRuntime.jsx(Zb,{onClick:S,topPx:b+(d?kd+8:0)+48,scrollLeft:h,leftOffset:Xn+(I?Yn:0)})]})}),_,H,N]})})})})})}function PM(e){let[t,o]=lt.useState(0);return lt.useEffect(()=>{if(!e)return;let n=()=>o(a=>a+1),r=e.on("change",n),i=e.on("selectionChange",n);return n(),()=>{r(),i();}},[e]),t}Object.defineProperty(exports,"CHROME_GROUPS",{enumerable:true,get:function(){return editor.CHROME_GROUPS}});Object.defineProperty(exports,"CHROME_MENUS",{enumerable:true,get:function(){return editor.CHROME_MENUS}});Object.defineProperty(exports,"LOADING_SNAPSHOT",{enumerable:true,get:function(){return editor.LOADING_SNAPSHOT}});Object.defineProperty(exports,"MAX_RESOLVER_FAMILIES",{enumerable:true,get:function(){return editor.MAX_RESOLVER_FAMILIES}});Object.defineProperty(exports,"PX_PER_CM",{enumerable:true,get:function(){return editor.PX_PER_CM}});Object.defineProperty(exports,"PX_PER_INCH",{enumerable:true,get:function(){return editor.PX_PER_INCH}});Object.defineProperty(exports,"WORD_DEFAULT_FONT",{enumerable:true,get:function(){return editor.WORD_DEFAULT_FONT}});Object.defineProperty(exports,"chromeMenuSlots",{enumerable:true,get:function(){return editor.chromeMenuSlots}});Object.defineProperty(exports,"commandForSlot",{enumerable:true,get:function(){return editor.commandForSlot}});Object.defineProperty(exports,"composeFontConfiguration",{enumerable:true,get:function(){return editor.composeFontConfiguration}});Object.defineProperty(exports,"composeFontOrigins",{enumerable:true,get:function(){return editor.composeFontOrigins}});Object.defineProperty(exports,"createFontSource",{enumerable:true,get:function(){return editor.createFontSource}});Object.defineProperty(exports,"defineFontResolver",{enumerable:true,get:function(){return editor.defineFontResolver}});Object.defineProperty(exports,"generateRulerTicks",{enumerable:true,get:function(){return editor.generateRulerTicks}});Object.defineProperty(exports,"isFontResolver",{enumerable:true,get:function(){return editor.isFontResolver}});Object.defineProperty(exports,"loadFonts",{enumerable:true,get:function(){return editor.loadFonts}});Object.defineProperty(exports,"rulerPageBox",{enumerable:true,get:function(){return editor.rulerPageBox}});Object.defineProperty(exports,"runToolbarCommand",{enumerable:true,get:function(){return editor.runToolbarCommand}});Object.defineProperty(exports,"toolbarCommandState",{enumerable:true,get:function(){return editor.toolbarCommandState}});Object.defineProperty(exports,"EditorFontError",{enumerable:true,get:function(){return editor$1.EditorFontError}});exports.CONTENT_CONTROL_SLOTS=et;exports.ContextMenuCellVerticalAlignment=Oo;exports.ContextMenuCopy=Er;exports.ContextMenuCopyFormatting=ti;exports.ContextMenuCut=Pr;exports.ContextMenuDelete=wr;exports.ContextMenuDeleteTable=Fn;exports.ContextMenuDeleteTableColumn=Ln;exports.ContextMenuDeleteTableRow=Nn;exports.ContextMenuInsertColumnLeft=In;exports.ContextMenuInsertColumnRight=_n;exports.ContextMenuInsertRowAbove=kn;exports.ContextMenuInsertRowBelow=Dn;exports.ContextMenuItem=ri;exports.ContextMenuPaste=Rn;exports.ContextMenuPasteFormatting=oi;exports.ContextMenuPasteWithoutFormatting=Mn;exports.ContextMenuRefreshToc=An;exports.ContextMenuRefreshTocPageNumbers=Hn;exports.ContextMenuSelectAll=Rr;exports.DocumentName=tu;exports.DocumentOutline=va;exports.DocxEditor=Vw;exports.DocxEditorAuthorStyle=Sc;exports.DocxEditorColorByChangeType=Cc;exports.DocxEditorContent=wi;exports.DocxEditorContentControl=fr;exports.DocxEditorContentControlWidget=lc;exports.DocxEditorContextMenu=kr;exports.DocxEditorDocumentOutline=Hd;exports.DocxEditorEquation=gr;exports.DocxEditorFontNotice=Cl;exports.DocxEditorHeaderFooterChrome=Sl;exports.DocxEditorHorizontalRuler=pl;exports.DocxEditorHyperLink=ur;exports.DocxEditorImageAltTextPopup=hi;exports.DocxEditorImagePropertiesDialog=_r;exports.DocxEditorInvalidTextFormFieldDialog=ac;exports.DocxEditorLoading=Mi;exports.DocxEditorLoadingSpinner=Tc;exports.DocxEditorMenu=ma;exports.DocxEditorNavigation=$d;exports.DocxEditorNotePreview=yn;exports.DocxEditorNotePropertiesDialog=ui;exports.DocxEditorNotesChrome=di;exports.DocxEditorNotesContextMenu=xn;exports.DocxEditorPageNumber=Tl;exports.DocxEditorPageSetupDialog=Vo;exports.DocxEditorParagraphDialog=Gt;exports.DocxEditorRoot=qr;exports.DocxEditorShell=hM;exports.DocxEditorTextFormFieldDialog=Ar;exports.DocxEditorToolbar=ua;exports.DocxEditorVerticalRuler=ml;exports.DocxEditorViewport=Ii;exports.HorizontalRuler=Jo;exports.ImageAltText=bi;exports.ImageInsertProvider=ja;exports.ImageInsertTrigger=Ya;exports.ImagePropertiesTrigger=gi;exports.ImageWrap=Bi;exports.LocaleProvider=bn;exports.Logo=wl;exports.MenuBar=Ml;exports.NAVIGATION_PANE_GAP=x0;exports.NAVIGATION_PANE_INSET=fl;exports.NAVIGATION_PANE_WIDTH=Qn;exports.NavigationClose=Ca;exports.NavigationFind=Ra;exports.NavigationHeader=Ta;exports.NavigationHeadings=wa;exports.NavigationTab=Ea;exports.NavigationTabs=Pa;exports.NavigationTitle=Sa;exports.NavigationToggle=Ma;exports.OUTLINE_BUTTON_LEFT_OFFSET=Xn;exports.OUTLINE_BUTTON_RESERVED_SPACE=N2;exports.OUTLINE_LEFT_OFFSET=ha;exports.OUTLINE_RESERVED_SPACE=I2;exports.PageIndicator=hu;exports.PageNumberTranslationContext=xl;exports.PaginatedDocxEditor=Yd;exports.PaginatedDocxEditorShell=iM;exports.REVIEW_MARKERS_GUTTER=Dc;exports.REVIEW_PANE_GUTTER=Ic;exports.RULER_WIDTH=Yn;exports.ReviewRailContext=bt;exports.SEARCH_DEBOUNCE_MS=qd;exports.SEARCH_MATCH_LIMIT=Kd;exports.Slot=j;exports.TitleBar=ou;exports.TitleBarRight=Rl;exports.Toolbar=gu;exports.ToolbarButton=ft;exports.ToolbarContext=ko;exports.ToolbarGroup=Pt;exports.ToolbarImageProperties=Bn;exports.VERSION=Wb;exports.VerticalRuler=ba;exports.definePopup=wh;exports.editorStateActiveSubscriptionCount=th;exports.isFieldLink=cr;exports.navigationPaneReservation=on;exports.navigationShift=gl;exports.normalizeImageBytes=Ga;exports.notificationYieldsToTask=Eu;exports.provideDocxEditor=wT;exports.reviewGutter=Em;exports.useChromeTranslate=Su;exports.useContentControl=Mt;exports.useContentControlInstance=$a;exports.useContextMenuTarget=np;exports.useDocumentOutline=bl;exports.useDocumentSearch=hl;exports.useDocxEditor=F;exports.useDocxSource=Qw;exports.useEditorCaret=l8;exports.useEditorCommand=se;exports.useEditorEvent=fd;exports.useEditorSnapshot=PM;exports.useEditorState=O;exports.useEditorValueCommand=Nr;exports.useFontFamily=Vi;exports.useFonts=n8;exports.useHeaderFooterState=Ud;exports.useHyperlinkPopup=as;exports.useHyperlinkPopupInstance=za;exports.useNavigationPane=vl;exports.useNavigationShift=Go;exports.useNotePropertiesState=Vs;exports.useNoteScopeState=zs;exports.usePageSetup=zo;exports.usePageSetupDialog=Ex;exports.useParagraphDialog=Ox;exports.useParagraphFormat=uc;exports.useParagraphIndent=Id;exports.useParagraphStyle=$i;exports.useReviewAuthors=Vr;exports.useReviewGutter=$n;exports.useScopeClassName=it;exports.useScopedChromeAnchor=Dr;exports.useTableBorderTargetLabel=Cg;exports.useTextFormFieldDialog=dx;exports.useToolbarContext=gh;exports.useToolbarLabel=ee;exports.useToolbarLabelFor=Za;exports.useTranslation=L;exports.useZoom=Wc;
|
|
4
|
+
`,jsxRuntime.jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:n,style:d,children:r("errors.tryAgain")})]})}function Sh({onClick:e,topPx:t,scrollLeft:o=0,leftOffset:n=or}){let{t:r}=L();return jsxRuntime.jsx("button",{className:"docx-outline-toggle",onClick:e,onMouseDown:i=>i.stopPropagation(),title:r("editor.showDocumentOutline"),"aria-label":r("editor.showDocumentOutline"),style:{position:"absolute",left:n-o,top:t,zIndex:ot.outline},children:jsxRuntime.jsx(U,{name:"format_list_bulleted",size:20})})}function Xu({currentPage:e,totalPages:t,visible:o}){let{t:n}=L();return jsxRuntime.jsx("div",{style:{position:"absolute",right:24,top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--doc-overlay)",color:"#fff",padding:"6px 12px",borderRadius:"4px",fontSize:"12px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:500,whiteSpace:"nowrap",pointerEvents:"none",zIndex:1e3,opacity:o?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:n("viewer.pageIndicator",{current:e,total:t})})}function vD({i18n:e,isDark:t,onEditorError:o,containerRef:n,scrollContainerRef:r,editorContentRef:i,className:a,containerStyle:l,mainContentStyle:s,editorContainerStyle:c,showRuler:d,readOnlyProp:f,showOutline:u,showOutlineButton:g,sidebarOpen:p,minLayoutWidth:m,toolbarHeight:b,editorScrollLeft:v,onScrollContainerMouseDown:x,onEditorBgMouseDown:h,onEditorContextMenu:y,horizontalRulerProps:T,verticalRulerProps:C,outlineProps:E,onToggleOutline:S,scrollPageInfo:D,toolbar:R,pagedArea:w,overlays:I,dialogs:H,fileInputs:N}){let _=d&&!f;return jsxRuntime.jsx(Wo.Provider,{value:true,children:jsxRuntime.jsx(Cn,{i18n:e,children:jsxRuntime.jsx(xh,{children:jsxRuntime.jsx(rs,{onError:o,children:jsxRuntime.jsxs("div",{ref:n,className:ne("docx-editor",t&&"dark",a),style:l,"data-testid":"docx-editor",children:[jsxRuntime.jsx("div",{style:s,children:jsxRuntime.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[R,jsxRuntime.jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:c,onMouseDown:x,children:[d&&jsxRuntime.jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:ot.ruler,paddingLeft:20,paddingRight:20+(p?352:0),minWidth:m,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(rn,{...T})}),jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:m},children:jsxRuntime.jsxs("div",{ref:i,style:{position:"relative",flex:1,minWidth:0},onMouseDown:h,onContextMenu:y,children:[_&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:ot.ruler,paddingTop:48},children:jsxRuntime.jsx(Sa,{...C})}),w]})})]}),D.totalPages>1&&jsxRuntime.jsx(Xu,{currentPage:D.currentPage,totalPages:D.totalPages,visible:D.visible}),u&&jsxRuntime.jsx(Ea,{...E,leftOffset:Pa+(_?tr:0)}),g&&!u&&jsxRuntime.jsx(Sh,{onClick:S,topPx:b+(d?cu+8:0)+48,scrollLeft:v,leftOffset:or+(_?tr:0)})]})}),I,H,N]})})})})})}function ED(e){let[t,o]=pt.useState(0);return pt.useEffect(()=>{if(!e)return;let n=()=>o(a=>a+1),r=e.on("change",n),i=e.on("selectionChange",n);return n(),()=>{r(),i();}},[e]),t}function ID({kind:e}){let t=F(),[o,n]=pt.useState(null),r=pt.useRef(null);pt.useLayoutEffect(()=>{if(!t||!o)return;let a=editor.bindHistoryGroup(t,o,{kind:e});return r.current=a,()=>{a.dispose(),r.current=null;}},[t,o,e]);let i=pt.useCallback(()=>{if(!r.current)throw new Error("history group control is not mounted");return r.current.options()},[]);return {ref:n,options:i}}Object.defineProperty(exports,"CHROME_GROUPS",{enumerable:true,get:function(){return editor.CHROME_GROUPS}});Object.defineProperty(exports,"CHROME_MENUS",{enumerable:true,get:function(){return editor.CHROME_MENUS}});Object.defineProperty(exports,"LOADING_SNAPSHOT",{enumerable:true,get:function(){return editor.LOADING_SNAPSHOT}});Object.defineProperty(exports,"MAX_RESOLVER_FAMILIES",{enumerable:true,get:function(){return editor.MAX_RESOLVER_FAMILIES}});Object.defineProperty(exports,"PX_PER_CM",{enumerable:true,get:function(){return editor.PX_PER_CM}});Object.defineProperty(exports,"PX_PER_INCH",{enumerable:true,get:function(){return editor.PX_PER_INCH}});Object.defineProperty(exports,"WORD_DEFAULT_FONT",{enumerable:true,get:function(){return editor.WORD_DEFAULT_FONT}});Object.defineProperty(exports,"chromeMenuSlots",{enumerable:true,get:function(){return editor.chromeMenuSlots}});Object.defineProperty(exports,"commandForSlot",{enumerable:true,get:function(){return editor.commandForSlot}});Object.defineProperty(exports,"composeFontConfiguration",{enumerable:true,get:function(){return editor.composeFontConfiguration}});Object.defineProperty(exports,"composeFontOrigins",{enumerable:true,get:function(){return editor.composeFontOrigins}});Object.defineProperty(exports,"createFontSource",{enumerable:true,get:function(){return editor.createFontSource}});Object.defineProperty(exports,"defineFontResolver",{enumerable:true,get:function(){return editor.defineFontResolver}});Object.defineProperty(exports,"generateRulerTicks",{enumerable:true,get:function(){return editor.generateRulerTicks}});Object.defineProperty(exports,"isFontResolver",{enumerable:true,get:function(){return editor.isFontResolver}});Object.defineProperty(exports,"loadFonts",{enumerable:true,get:function(){return editor.loadFonts}});Object.defineProperty(exports,"rulerPageBox",{enumerable:true,get:function(){return editor.rulerPageBox}});Object.defineProperty(exports,"runToolbarCommand",{enumerable:true,get:function(){return editor.runToolbarCommand}});Object.defineProperty(exports,"toolbarCommandState",{enumerable:true,get:function(){return editor.toolbarCommandState}});Object.defineProperty(exports,"EditorFontError",{enumerable:true,get:function(){return editor$1.EditorFontError}});exports.CONTENT_CONTROL_SLOTS=rt;exports.ContextMenuCellVerticalAlignment=Ko;exports.ContextMenuCopy=kr;exports.ContextMenuCopyFormatting=si;exports.ContextMenuCut=Dr;exports.ContextMenuDelete=Ir;exports.ContextMenuDeleteTable=qn;exports.ContextMenuDeleteTableColumn=Zn;exports.ContextMenuDeleteTableRow=Bn;exports.ContextMenuInsertColumnLeft=Hn;exports.ContextMenuInsertColumnRight=On;exports.ContextMenuInsertRowAbove=Fn;exports.ContextMenuInsertRowBelow=An;exports.ContextMenuItem=ui;exports.ContextMenuPaste=Nn;exports.ContextMenuPasteFormatting=ci;exports.ContextMenuPasteWithoutFormatting=Ln;exports.ContextMenuRefreshToc=Kn;exports.ContextMenuRefreshTocPageNumbers=Wn;exports.ContextMenuSelectAll=_r;exports.DocumentName=Fu;exports.DocumentOutline=Ea;exports.DocxEditor=U8;exports.DocxEditorAuthorStyle=nd;exports.DocxEditorColorByChangeType=od;exports.DocxEditorContent=Bi;exports.DocxEditorContentControl=yr;exports.DocxEditorContentControlWidget=Zc;exports.DocxEditorContextMenu=Lr;exports.DocxEditorDocumentOutline=hu;exports.DocxEditorEquation=xr;exports.DocxEditorFontNotice=Fl;exports.DocxEditorHeaderFooterChrome=Al;exports.DocxEditorHorizontalRuler=El;exports.DocxEditorHyperLink=br;exports.DocxEditorImageAltTextPopup=Pi;exports.DocxEditorImagePropertiesDialog=Hr;exports.DocxEditorInvalidTextFormFieldDialog=vc;exports.DocxEditorLoading=qi;exports.DocxEditorLoadingSpinner=td;exports.DocxEditorMenu=xa;exports.DocxEditorNavigation=Eu;exports.DocxEditorNotePreview=Pn;exports.DocxEditorNotePropertiesDialog=vi;exports.DocxEditorNotesChrome=hi;exports.DocxEditorNotesContextMenu=En;exports.DocxEditorPageNumber=Ll;exports.DocxEditorPageSetupDialog=Yo;exports.DocxEditorParagraphDialog=Jt;exports.DocxEditorRoot=Gr;exports.DocxEditorShell=vD;exports.DocxEditorTextFormFieldDialog=Wr;exports.DocxEditorToolbar=va;exports.DocxEditorVerticalRuler=wl;exports.DocxEditorViewport=zi;exports.HorizontalRuler=rn;exports.ImageAltText=Si;exports.ImageInsertProvider=oi;exports.ImageInsertTrigger=ni;exports.ImagePropertiesTrigger=Ti;exports.ImageWrap=Qi;exports.LocaleProvider=Cn;exports.Logo=Bl;exports.MenuBar=ql;exports.NAVIGATION_PANE_GAP=nb;exports.NAVIGATION_PANE_INSET=Ml;exports.NAVIGATION_PANE_WIDTH=nr;exports.NavigationClose=Da;exports.NavigationFind=La;exports.NavigationHeader=Ra;exports.NavigationHeadings=Na;exports.NavigationTab=_a;exports.NavigationTabs=Ia;exports.NavigationTitle=ka;exports.NavigationToggle=Fa;exports.OUTLINE_BUTTON_LEFT_OFFSET=or;exports.OUTLINE_BUTTON_RESERVED_SPACE=L2;exports.OUTLINE_LEFT_OFFSET=Pa;exports.OUTLINE_RESERVED_SPACE=_2;exports.PageIndicator=Xu;exports.PageNumberTranslationContext=Nl;exports.PaginatedDocxEditor=ku;exports.PaginatedDocxEditorShell=lD;exports.REVIEW_MARKERS_GUTTER=dd;exports.REVIEW_PANE_GUTTER=ud;exports.RULER_WIDTH=tr;exports.ReviewRailContext=Ct;exports.SEARCH_DEBOUNCE_MS=Cu;exports.SEARCH_MATCH_LIMIT=Tu;exports.Slot=Y;exports.TitleBar=Au;exports.TitleBarRight=Zl;exports.Toolbar=Yu;exports.ToolbarButton=yt;exports.ToolbarContext=No;exports.ToolbarGroup=kt;exports.ToolbarImageProperties=Un;exports.VERSION=Dh;exports.VerticalRuler=Sa;exports.definePopup=dv;exports.editorStateActiveSubscriptionCount=Oh;exports.isFieldLink=fr;exports.navigationPaneReservation=sn;exports.navigationShift=Rl;exports.normalizeImageBytes=ti;exports.notificationYieldsToTask=ap;exports.provideDocxEditor=MT;exports.reviewGutter=cf;exports.useChromeTranslate=np;exports.useContentControl=Lt;exports.useContentControlInstance=Qa;exports.useContentControlWidget=$e;exports.useContextMenuTarget=Hp;exports.useDocumentOutline=Dl;exports.useDocumentSearch=kl;exports.useDocxEditor=F;exports.useDocxSource=J8;exports.useEditorCaret=sM;exports.useEditorCommand=se;exports.useEditorEvent=Gd;exports.useEditorSnapshot=ED;exports.useEditorState=O;exports.useEditorValueCommand=Or;exports.useFontFamily=nl;exports.useFonts=rM;exports.useHeaderFooterState=Mu;exports.useHistoryGroup=ID;exports.useHyperlinkPopup=vs;exports.useHyperlinkPopupInstance=ja;exports.useNavigationPane=Il;exports.useNavigationShift=Jo;exports.useNotePropertiesState=nc;exports.useNoteScopeState=oc;exports.usePageSetup=Go;exports.usePageSetupDialog=wC;exports.useParagraphDialog=BC;exports.useParagraphFormat=Uc;exports.useParagraphIndent=uu;exports.useParagraphStyle=rl;exports.useReviewAuthors=Xr;exports.useReviewGutter=jn;exports.useScopeClassName=dt;exports.useScopedChromeAnchor=Fr;exports.useTableBorderTargetLabel=a0;exports.useTextFormFieldDialog=uC;exports.useToolbarContext=Jh;exports.useToolbarLabel=ee;exports.useToolbarLabelFor=Va;exports.useTranslation=L;exports.useZoom=wd;
|