@docx-editor.dev/react 2.35.0-canary.20261105032738.sha-5993bd2 → 2.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var Zt=require('react'),editor=require('@docx-editor.dev/core/editor'),reactDom=require('react-dom'),jsxRuntime=require('react/jsx-runtime'),i18n=require('@docx-editor.dev/i18n'),store=require('@docx-editor.dev/core/store'),classVarianceAuthority=require('class-variance-authority'),clsx=require('clsx'),Ae=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 Zt__namespace=/*#__PURE__*/_interopNamespace(Zt);var Ae__namespace=/*#__PURE__*/_interopNamespace(Ae);var mg={version:"2.35.0-canary.20261105032738.sha-5993bd2"};var fE=mg.version;function fg(){let e=new Map,t=new Map,o=new Set,n=0,r=0,i=null,a=[],l,s=false,c=()=>[...e].sort((u,g)=>t.get(u[0])-t.get(g[0])),d=()=>{r++;for(let u of o)u();},m=()=>{d(),!s&&(s=true,queueMicrotask(()=>{s=false,i?.setUnsupportedElementRules(c().map(([,u])=>u));}));};return {register(u,g){t.has(u)||t.set(u,n++),e.set(u,g),m();},unregister(u){e.delete(u)&&m();},connect(u){i=u,u&&m();},current:()=>c().map(([,u])=>u),setContainer(u){l?.();for(let g of a)g.setCustomized(false);a=[],l=u?editor.observeUnsupportedElements(u,g=>{a=g,d();}):void 0,d();},subscribe(u){return o.add(u),()=>o.delete(u)},snapshot:()=>r,hosts(u){let g=c();return a.filter(p=>g.find(([,f])=>editor.unsupportedElementRuleMatches(f,p.unsupported))?.[0]===u)}}}var Rr=Zt.createContext(null);function gg(e){return Zt.Children.toArray(e).some(t=>Zt.isValidElement(t)&&t.type===Zt.Fragment?gg(t.props.children):typeof t!="string"||t.trim().length>0)}function bg({host:e,children:t}){let o=gg(t);return Zt.useLayoutEffect(()=>(e.setCustomized(o),()=>{e.setCustomized(false);}),[e,o]),o?reactDom.createPortal(t,e.slot):null}function Fd({match:e,layout:t,includePartial:o,children:n}){let r=Zt.useContext(Rr);if(!r)throw new Error("DocxEditor.UnsupportedElement must render inside DocxEditor.Root.");let i=Zt.useRef(Symbol("unsupported-element-declaration")).current;return Zt.useSyncExternalStore(r.subscribe,r.snapshot,r.snapshot),Zt.useLayoutEffect(()=>{r.register(i,{includePartial:o,...e?{match:e}:{},...t?{layout:t}:{}});},[r,i,e,t,o]),Zt.useLayoutEffect(()=>()=>r.unregister(i),[r,i]),r.hosts(i).map(a=>jsxRuntime.jsx(bg,{host:a,children:n({element:a.unsupported})},a.key))}var Ld=Zt.createContext(i18n.en),Hd=Zt.createContext("en"),Ad=Zt.createContext("ltr"),Od=Zt.createContext(void 0);function Mr({i18n:e,dir:t,children:o}){let n=Zt.useContext(Ld),r=Zt.useContext(Hd),i=Zt.useContext(Ad),a=Zt.useContext(Od),l=typeof e?._lang=="string"?e._lang:r,s=i18n.chromeDirection(t,e,a),c=s??i18n.catalogDirection(e)??i,d=Zt.useMemo(()=>i18n.deepMerge(n,e),[n,e]);return jsxRuntime.jsx(Hd.Provider,{value:l,children:jsxRuntime.jsx(Ad.Provider,{value:c,children:jsxRuntime.jsx(Od.Provider,{value:s,children:jsxRuntime.jsx(Ld.Provider,{value:d,children:o})})})})}function H(){let e=Zt.useContext(Ld),t=Zt.useContext(Hd),o=Zt.useContext(Ad);return {t:Zt.useMemo(()=>i18n.createT(e,t),[e,t]),catalogue:e,lang:t,dir:o}}function lt(){return Zt.useContext(Od)}function xg(e){let{t}=H();return Zt.useCallback((o,n)=>e?.get(o)??t(o,n),[e,t])}var Bd=Zt.createContext(null);function A(){return Zt.useContext(Bd)}function Wl(e){return (e?.mounted??0)+(e?.gutters??0)>0}var At=Zt.createContext(null);var Wd=0,Zd=false,Kd=false,Zl=[],Kl=null;function Cg(e){if(typeof MessageChannel!="function"){globalThis.setTimeout(e,0);return}Kl||(Kl=new MessageChannel,Kl.port1.onmessage=()=>{let t=Zl;Zl=[];for(let o of t)try{o();}catch(n){queueMicrotask(()=>{throw n});}}),Zl.push(e),Zl.length===1&&Kl.port2.postMessage(null);}function Tg(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(Zd||(Zd=true,Wd+=1,queueMicrotask(()=>{Zd=false;}),Kd||(Kd=true,Cg(()=>{Kd=false,Wd=0;}))),Wd>16)}function Eg(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};Tg()?Cg(o):queueMicrotask(o);}}var HE=()=>{},Ud=0;function AE(){return Ud}function Za(e){return Eg(e)}function W(e,t=Object.is,o){let n=A(),r=o?.onSubscribe,i=o?.onUnsubscribe,a=Zt.useCallback(d=>{if(!n)return HE;let m=false;Ud++,r?.();let u=Za(()=>{m||d();}),g=[n.on("change",u),n.on("selectionChange",u),n.on("error",u)];return ()=>{m=true,Ud--,i?.();for(let p of g)p();}},[n,r,i]),l=Zt.useMemo(()=>{let d=false,m,u;return g=>{if(d&&g===m)return u;let p=e(g);return d&&t(u,p)?(m=g,u):(d=true,m=g,u=p,p)}},[n,e,t]),s=Zt.useCallback(()=>l(n?n.snapshot():editor.LOADING_SNAPSHOT),[n,l]),c=Zt.useCallback(()=>l(editor.LOADING_SNAPSHOT),[l]);return Zt.useSyncExternalStore(a,s,c)}function ZE(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function KE(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=ZE(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 Q({children:e,...t}){let o=Zt.Children.only(e);if(!Zt.isValidElement(o))return null;let n=o.props,r=KE(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);}),Zt.cloneElement(o,r)}var Sg="(prefers-color-scheme: dark)";function Pg(){return typeof globalThis.window<"u"&&typeof globalThis.window.matchMedia=="function"}function kg(){return Pg()?globalThis.window.matchMedia(Sg).matches:false}function wg(e,t){return e==="dark"||e==="system"&&t}function Dg(e){if(!Pg())return ()=>{};let t=globalThis.window.matchMedia(Sg);e(t.matches);let o=n=>e(n.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}var Wo=Zt.createContext(false),qn=Zt.createContext(false);function qE(){let e=Zt.useContext(Wo),t=Zt.useContext(qn);return e?"":t?"docx-editor dark ":"docx-editor "}function Ul(e){let t=e==="system",o=Zt.useSyncExternalStore(t?$E:zE,t?kg:_g,_g);return wg(e??"light",o)}function $E(e){return Dg(()=>e())}function zE(){return ()=>{}}function _g(){return false}function Ut(){return Zt.useContext(qn)}function $t(){let e=Zt.useContext(Wo),t=Zt.useContext(qn);return e?"":t?"docx-editor dark ":"docx-editor "}function VE(){return Zt.useContext(qn)?jE:GE}var GE=Object.freeze({colorMode:"light"}),jE=Object.freeze({colorMode:"dark"});var Fg=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function yt(){let e=Zt.createContext(null),t=new Map,o=y=>{let v=t.get(y.type);return v==="field"?`field:${y.props.name}`:v};function n(y,v){Zt.Children.forEach(y,x=>{Zt.isValidElement(x)&&(v(x),n(x.props.children,v));});}function r(){let y=Zt.useContext(e);if(!y)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return y.state}function i(y,v){return Zt.Children.map(y,x=>{if(!Zt.isValidElement(x))return x;let h=Fg(x.props);return h&&v.has(h)?v.get(h):x.props.children===void 0?x:Zt.cloneElement(x,{children:i(x.props.children,v)})})}function a(y){function v(x){let h=Zt.useContext(e);if(!h||x.hidden)return null;let k=y==="field"?`field:${x.name}`:y,E=h.defaults.get(k);if(!E)return x.children??null;let{children:C,asChild:T,className:S,style:P,hidden:w,name:_,...L}=x,N={...L,...E.props,className:[E.props.className,S].filter(Boolean).join(" "),style:{...E.props.style,...P}};if(T){let{children:B,className:F,style:D,...R}=N;return jsxRuntime.jsx(Q,{...R,...S?{className:S}:{},...P?{style:P}:{},children:C})}return Zt.cloneElement(E,N,C===void 0?i(E.props.children,h.overrides):C)}return t.set(v,y),v}let l=a("header"),s=a("title"),c=a("body"),d=a("footer"),m=a("apply"),u=a("cancel"),g=a("reset"),p=a("error"),f=a("field");function b({defaults:y,children:v,preset:x=true,state:h}){let k=new Map;n(y,S=>{let P=Fg(S.props);P&&k.set(P,S);});let E=new Map;n(v,S=>{let P=o(S);P&&E.set(P,S);});let C=S=>Zt.Children.toArray(S).flatMap(P=>Zt.isValidElement(P)&&P.type===Zt.Fragment?C(P.props.children):[P]),T=C(v).filter(S=>!Zt.isValidElement(S)||!o(S));return jsxRuntime.jsx(e.Provider,{value:{defaults:k,overrides:E,state:h},children:x?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i(y,E),T]}):v})}return {Header:l,Title:s,Body:c,Footer:d,Apply:m,Cancel:u,Reset:g,Error:p,Field:f,Composition:b,useState:r,part:y=>a(y)}}function Fe({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:m=true,describedBy:u,busy:g}){let p=Zt.useRef(null),f=l??p,b=Zt.useRef(i);b.current=i;let[y,v]=Zt.useState(false),x=Ut();return Zt.useLayoutEffect(()=>{let h=f.current;if(!h)return;v(!h.parentElement?.closest(".docx-editor"));let k=h.ownerDocument.activeElement,E=k===h.ownerDocument.body?null:k,C=()=>{h.open&&h.close?.();};return d?.addEventListener("abort",C),typeof h.showModal=="function"?h.showModal():h.setAttribute("open",""),(h.querySelector('input:not([disabled]),select:not([disabled]),button:not([disabled]),[tabindex="0"]')??h.querySelector("a[href]"))?.focus({preventScroll:true}),()=>{d?.removeEventListener("abort",C),typeof h.close=="function"&&h.open&&h.close(),m&&E?.isConnected&&E.focus({preventScroll:true});}},[f,d,m]),jsxRuntime.jsx("dialog",{ref:f,role:t,"aria-modal":"true","aria-label":r,"aria-describedby":u,"data-docx-busy":g?"":void 0,className:`docx-dialog${y?` docx-editor${x?" dark":""}`:""}${o?` ${o}`:""}`,style:n,"data-docx-dialog":e,onCancel:h=>{h.preventDefault(),b.current();},onMouseDown:h=>h.stopPropagation(),onClick:h=>{if(c&&h.target===h.currentTarget){let k=h.currentTarget.getBoundingClientRect();(h.clientX<k.left||h.clientX>k.right||h.clientY<k.top||h.clientY>k.bottom)&&b.current();}h.stopPropagation();},onKeyDown:h=>{h.key==="Escape"&&!h.nativeEvent.isComposing?(h.preventDefault(),b.current()):editor.trapTabWithin(h.currentTarget,h.nativeEvent)?h.preventDefault():!h.nativeEvent.isComposing&&!h.defaultPrevented&&a?.(h),h.stopPropagation();},children:s})}function Co(e,t){let o=A(),n=Gd(),r=Zt.useRef(null);return Zt.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 Gd(){let e=A(),t=Zt.useCallback(o=>{if(!e)return ()=>{};let n=true,r=Za(()=>{n&&o();}),i=[e.on("change",r),e.on("selectionChange",r),e.on("error",r)];return ()=>{n=false,i.forEach(a=>a());}},[e]);return Zt.useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function Lg(){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 Yd=Zt.createContext(null);function $n(){return Zt.useContext(Yd)}var Hg=()=>0,Xd=()=>()=>{};function zn(){let e=$n(),t=Zt.useCallback(n=>e?e.subscribeShift(n):Xd(),[e]),o=Zt.useCallback(()=>e?e.getShift():0,[e]);return Zt.useSyncExternalStore(t,o,Hg)}function Ag(){let e=$n(),t=Zt.useCallback(n=>e?e.subscribeReservation(n):Xd(),[e]),o=Zt.useCallback(()=>e?e.getReservation():0,[e]);return Zt.useSyncExternalStore(t,o,Hg)}function we(){let e=$n(),t=Zt.useCallback(r=>e?e.subscribeViewport(r):Xd(),[e]),o=Zt.useCallback(()=>e?e.getViewport():null,[e]),n=Zt.useCallback(()=>null,[]);return Zt.useSyncExternalStore(t,o,n)}function Zo(e,t,o){let n=we(),r=Zt.useRef({close:o,viewport:n});r.current={close:o,viewport:n},Zt.useEffect(()=>{let i=e.current;if(!(!t||!i))return fS(i,()=>r.current.close(),()=>r.current.viewport)},[e,t]);}function fS(e,t,o){let n=l=>{if(l.defaultPrevented||l.altKey||l.ctrlKey||l.metaKey)return;let s=l.target;if(s.matches('input[role="combobox"]')||s.matches("input, textarea, select")&&l.key!=="ArrowDown"&&l.key!=="ArrowUp")return;let d=Array.from(e.querySelectorAll('[role="option"]')).filter(g=>!g.matches(':disabled, [aria-disabled="true"]'));if(d.length===0)return;let m=d.indexOf(s),u;if(l.key==="Home")u=0;else if(l.key==="End")u=d.length-1;else if(l.key==="ArrowDown")u=(m+1)%d.length;else if(l.key==="ArrowUp")u=m<0?d.length-1:(m-1+d.length)%d.length;else return;l.preventDefault(),l.stopPropagation(),d[u]?.focus();},r=l=>{editor.isDomNode(l.relatedTarget)&&!e.contains(l.relatedTarget)&&t();},i=editor.listenForPopupEscape({popup:e,contains:l=>e.contains(l),chromeRoot:()=>e.closest(".docx-editor"),editorElements:()=>[o()],skip:l=>editor.isElementNode(l.target)&&e.contains(l.target)&&l.target.matches('input[role="combobox"]'),close:l=>{l&&e.querySelector("[aria-haspopup]")?.focus(),t();}}),a=editor.listenForPopupFocusLeave({popup:e,contains:l=>e.contains(l),close:t});return e.addEventListener("keydown",n),e.addEventListener("focusout",r),()=>{e.removeEventListener("keydown",n),e.removeEventListener("focusout",r),i(),a();}}function CS(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason&&e.value===t.value}function Jd(e){return typeof e=="string"}function re(e){let t=A(),{t:o}=H(),n=Jd(e)?e:editor.editorCommandKey(e),r=Zt.useRef(e);r.current=e;let i=Zt.useCallback(s=>{let c=r.current;if(Jd(c)){let m=editor.toolbarCommandState(t,c);return {active:m.active,enabled:m.enabled,disabledReason:i18n.localizeDisabledReason(m.disabledReason,o),value:m.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=W(i,CS),l=Zt.useCallback(s=>{let c=editor.commandExecOptions(s),d=r.current;return Jd(d)?editor.runToolbarCommand(t,d,void 0,c??{}).ok:t?t.exec(d,c).ok:false},[t]);return Zt.useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[l,a])}var Vn=Zt.createContext({t:void 0,onSave:void 0});function ES(){return Zt.useContext(Vn)}function zl(e){let{t}=H();return o=>e?.(o)??t(o)}function ae(){let{t:e}=Zt.useContext(Vn);return zl(e)}var wS=()=>()=>{},DS=()=>true,RS=()=>false;function eo(){let e=Zt.useSyncExternalStore(wS,DS,RS);return Zt.useCallback(t=>e?i18n.platformShortcut(t):t,[e])}function MS(e){let t=e.viteEnv?.DEV;return typeof t=="boolean"?t:e.hasProcess&&e.nodeEnv!=="production"}function _S(){try{return undefined}catch{return}}function xt(){let e=typeof process<"u";return MS({viteEnv:_S(),nodeEnv:e?"production":void 0,hasProcess:e})}var Zg=new Set;function un(e){!xt()||Zg.has(e)||(Zg.add(e),console.warn(`[docx-editor] ${e}`));}function Kg(e){un(`Menu.Item and ContextMenu.Slot take the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function qg(e){un(`A hidden context-menu override names "${e}", but no packaged row has that id, so nothing is removed.`);}function Ug(){un("A Menu.Item or ContextMenu.Slot has no slotId, so it renders nothing.");}function $g(){un("A Menu.Submenu has neither label nor labelKey, so its row has no name.");}function zg(e){un(`Toolbar.Button takes the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function Vg(){un("A Toolbar.Button has no slotId, so it renders nothing.");}function te(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 $(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function LS(e){if(e.slotId)return e.slotId;if(e.slot)return zg(e.slot),e.slot;Vg();}function Ko(e){let{icon:t,asChild:o,className:n,children:r,hidden:i}=e,a=LS(e)??"",{execute:l,isActive:s,isEnabled:c,disabledReason:d,value:m}=re(a),u=ae(),g=eo();if(i||!a)return null;let p=te(a),f=g(u(p?.labelKey??a)),b=editor.chromeSlotIsToggle(a),y={onClick:()=>l(),onMouseDown:$,disabled:!c,"data-slot":a,className:`docx-toolbar__button${n?` ${n}`:""}`,...s?{"data-active":""}:{},...c?{}:{"data-disabled":""},...b?{"aria-pressed":s}:{},...m!==null?{"data-value":m}:{},"aria-label":f,title:d??f};return o?jsxRuntime.jsx(Q,{...y,children:r}):jsxRuntime.jsx("button",{type:"button",...y,children:t??r??oe(p?.paths)})}Ko.docxToolbarPart=true;var KS=[{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"}],Gg=[{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"}],jg=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Gl=["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"],pn=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),zt=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function qS(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?[zt(5),zt(15),zt(25),zt(35),zt(50)]:o===0?[pn(50),pn(35),pn(25),pn(15),pn(5)]:o>=.8?[zt(10),zt(25),zt(50),zt(75),zt(90)]:[pn(80),pn(60),pn(40),zt(25),zt(50)]}var US=/^[0-9A-Fa-f]{6}$/;function $S(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 zS(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 Ir({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,"aria-pressed":n,title:o,"data-value":e,...n?{"data-selected":""}:{},...t.startsWith("var(")||zS(t.replace("#",""))?{"data-light":""}:{},onMouseDown:$,onClick:()=>r(e)})}function VS({apply:e,label:t,current:o,themeHexes:n}){let r=n.map(qS),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(Ir,{value:a,css:`#${a.toLowerCase()}`,title:t(Gl[l]),selected:o===a,apply:e},`base-${l}`)),i.map(a=>n.map((l,s)=>{let c=r[s][a],d=$S(l,c.apply);return jsxRuntime.jsx(Ir,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Gl[s])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${s}`)}))]})]})}function GS(e){let{apply:t,label:o,current:n}=e,[r,i]=Zt.useState(""),a=US.test(r);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(VS,{...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:KS.map(l=>jsxRuntime.jsx(Ir,{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:$,onClick:()=>t(r.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function eu({apply:e,current:t}){let o=A(),n=ae(),r=o?.getDocumentThemeColors()??[],i=r.length===Gl.length?r.map(l=>l.hex):jg,a=t?.toUpperCase()??null;return jsxRuntime.jsx(GS,{apply:e,label:n,current:a,themeHexes:i})}var jS=Gg.filter(e=>e.value!=="white");function YS({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:jS.map(n=>jsxRuntime.jsx(Ir,{value:n.value,css:n.css,title:t(n.labelKey),selected:o===n.value,apply:e},n.value))})]})}function Yg(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 m=A(),{isEnabled:u,disabledReason:g}=re(t),p=ae(),[f,b]=Zt.useState(false),[y,v]=Zt.useState(o),x=Zt.useRef(null);Zo(x,f,()=>b(false));let h=W(P=>{if(a){let w=P.formatting?.color;return w&&w.kind==="hex"?w.value.toUpperCase():null}return P.formatting?.highlight??null}),k=m?.getDocumentThemeColors()??[],E=k.length===Gl.length?k.map(P=>P.hex):jg;Zt.useEffect(()=>{if(f)return editor.listenForOutsidePress({popup:x.current,close:()=>b(false)})},[f]);let C=Zt.useCallback(P=>{if(b(false),!m)return;m.focus();let w=editor.commandForSlotValue(t,P);w&&m.can(w).ok&&(m.exec(w),P!==r.value&&v(P));},[m]),T=Zt.useMemo(()=>te(t),[]);if(c)return null;let S=p(T?.labelKey??t);return jsxRuntime.jsxs("div",{ref:x,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":S,title:g??S,onMouseDown:$,onClick:()=>C(y),children:[d??oe(T?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:n(y)},"aria-hidden":"true"})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!u,...u?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":f,"aria-label":S,title:g??S,onMouseDown:$,onClick:()=>b(P=>!P),children:"\u25BE"}),f?jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":S,onMouseDown:$,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:$,onClick:()=>C(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:C,label:p,current:h,themeHexes:E})]}):null]})},{docxSlot:t})}var XS=new Map(Gg.map(e=>[e.value,e.css])),tu=Yg({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsxRuntime.jsx(eu,{apply:e.apply,current:e.current})}),ou=Yg({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>XS.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsxRuntime.jsx(YS,{...e})});var ru=e=>e==="auto"?"currentColor":e==="byAuthor"?"var(--doc-review-author-0)":e==="none"?"transparent":`var(--doc-revision-color-${e})`;function Yl({label:e,value:t,values:o,disabled:n,change:r,t:i}){let a=Zt.useId(),[l,s]=Zt.useState(false),c=Zt.useRef(null),d=Zt.useRef(null),m=Zt.useRef(null);Zt.useLayoutEffect(()=>{if(!l||!m.current||!d.current)return;let g=editor.observeContentControlPopup(m.current,d.current);return (m.current.querySelector("[data-selected]")??m.current.querySelector("button"))?.focus(),g},[l]),Zt.useEffect(()=>{if(n&&s(false),!l)return;let g=c.current?.ownerDocument,p=f=>{c.current?.contains(f.target)||s(false);};return g?.addEventListener("pointerdown",p),()=>g?.removeEventListener("pointerdown",p)},[l,n]);let u=()=>{s(false),d.current?.focus();};return jsxRuntime.jsxs("div",{ref:c,className:"docx-revision-color-picker",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||s(false);},children:[jsxRuntime.jsx("span",{id:`${a}-label`,children:e}),jsxRuntime.jsxs("button",{ref:d,type:"button",className:"docx-revision-color-trigger",disabled:n,"aria-labelledby":`${a}-label ${a}-value`,"aria-expanded":l&&!n,"aria-controls":`${a}-options`,onClick:()=>s(!l),children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:ru(t)}}),jsxRuntime.jsx("span",{id:`${a}-value`,children:i(`values.${t}`)})]}),jsxRuntime.jsxs("div",{ref:m,id:`${a}-options`,className:"docx-revision-color-options",hidden:!l||n,role:"group","aria-labelledby":`${a}-label`,onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),u());let p=Array.from(g.currentTarget.querySelectorAll("button")),f=p.indexOf(g.target),b=g.key==="Home"?0:g.key==="End"?p.length-1:["ArrowRight","ArrowDown"].includes(g.key)?(f+1)%p.length:["ArrowLeft","ArrowUp"].includes(g.key)?(f-1+p.length)%p.length:null;b!==null&&(g.preventDefault(),g.stopPropagation(),p[b]?.focus());},children:[jsxRuntime.jsx("div",{className:"docx-revision-color-special",children:o.filter(g=>["auto","none","byAuthor"].includes(g)).map(g=>jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear","aria-pressed":t===g,"data-selected":t===g?"":void 0,onClick:()=>{r(g),u();},children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:ru(g)}}),i(`values.${g}`)]},g))}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid",children:o.filter(g=>!["auto","none","byAuthor"].includes(g)).map(g=>jsxRuntime.jsx(Ir,{value:g,css:ru(g),title:i(`values.${g}`),selected:t===g,apply:p=>{r(p),u();}},g))})]})]})}var Xg=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],rP=["byAuthor","auto",...editor.REVISION_MARKUP_COLORS];function Jg(e,t,o){let{values:n}=e,r=a=>{let l=a==="changedLines"?["none","leftBorder","rightBorder","outsideBorder"]:a==="deletions"||a==="movedFrom"?[...Xg,"hidden","caret","pound"]:Xg,s=(a==="movedFrom"||a==="movedTo")&&!n.trackMoves;return jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxRuntime.jsxs("div",{className:"docx-revision-markup-row",children:[jsxRuntime.jsx("span",{className:"docx-revision-markup-row-title","aria-hidden":"true",children:t(a)}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("span",{className:"docx-revision-markup-field-label",children:t(a)}),jsxRuntime.jsx("select",{value:n[a].mark,disabled:s,onChange:c=>e.setValue(a,{...n[a],mark:c.target.value}),children:l.map(c=>jsxRuntime.jsx("option",{value:c,children:t(`values.${c}`)},c))})]}),jsxRuntime.jsx(Yl,{label:t(`${a}Color`),value:n[a].color,values:rP,disabled:s,t,change:c=>e.setValue(a,{...n[a],color:c})})]}),a!=="changedLines"&&jsxRuntime.jsx("div",{className:"docx-revision-markup-background",children:jsxRuntime.jsx(Yl,{label:t(`${a}Background`),value:n[a].background,values:["none","byAuthor",...editor.REVISION_MARKUP_COLORS],disabled:s,t,change:c=>e.setValue(a,{...n[a],background:c})})})]})},i=a=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n[a],"aria-describedby":`${o}-${a}`,onChange:l=>e.setValue(a,l.target.checked)}),t(a)]}),jsxRuntime.jsx("p",{id:`${o}-${a}`,children:t(`${a}Note`)})]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("markup")}),r("insertions"),r("deletions"),r("changedLines")]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("moves")}),i("trackMoves"),r("movedFrom"),r("movedTo")]}),jsxRuntime.jsxs("fieldset",{"data-docx-part":"field","data-docx-field":"cells",className:"docx-revision-markup-tableCells",children:[jsxRuntime.jsx("legend",{children:t("tableCells")}),["inserted","deleted","merged","split"].map(a=>jsxRuntime.jsx(Yl,{label:t(`${a}Cells`),value:n.cells[a],values:["byAuthor","none",...editor.REVISION_MARKUP_COLORS],t,change:l=>e.setValue("cells",{...n.cells,[a]:l})},a))]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("formatting")}),i("trackFormatting"),r("formatting")]})]})}var oo=yt();function uP(){return oo.useState()}function pP({session:e,...t}){return e?jsxRuntime.jsx(mP,{session:e,...t}):null}function mP({session:e,children:t,preset:o,className:n,style:r}){let i=Zt.useId(),{t:a}=H(),l=f=>a(`revisionMarkup.${f}`),s=Zt.useCallback(f=>e.subscribe(f),[e]),c=Zt.useCallback(()=>e.get(),[e]),d=Zt.useSyncExternalStore(s,c,c),[m,u]=Zt.useState(e.signal.aborted),g=Zt.useRef(null);Zt.useEffect(()=>{g.current=e;let f=()=>u(true);return u(e.signal.aborted),e.signal.addEventListener("abort",f),()=>{e.signal.removeEventListener("abort",f),g.current=null,queueMicrotask(()=>{g.current!==e&&e.cancel();});}},[e]);let p={values:d,setValue(f,b){e.set({[f]:b});},errors:{},isEnabled:!m&&e.canApply(),apply(){e.apply();},cancel(){e.cancel();},reset(){e.reset();}};return m?null:jsxRuntime.jsx(Fe,{kind:"revisionMarkup",label:l("title"),className:["docx-revision-markup-dialog",n].filter(Boolean).join(" "),style:r,onClose:p.cancel,dismissOutside:false,sessionSignal:e.signal,children:jsxRuntime.jsx(oo.Composition,{state:p,preset:o,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",children:jsxRuntime.jsx("h2",{"data-docx-part":"title",children:l("title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-revision-markup-body",children:Jg(p,l,i)}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-revision-markup-actions",children:[jsxRuntime.jsx("button",{"data-docx-part":"reset",type:"button",onClick:p.reset,children:l("reset")}),jsxRuntime.jsx("span",{"data-docx-part":"error",role:"alert",children:p.errors.form}),jsxRuntime.jsx("button",{"data-docx-part":"cancel",type:"button",onClick:p.cancel,children:l("cancel")}),jsxRuntime.jsx("button",{"data-docx-part":"apply",type:"button",disabled:!p.isEnabled,onClick:p.apply,children:l("ok")})]})]}),children:t})})}var Ka=Object.assign(pP,{Header:oo.Header,Title:oo.Title,Body:oo.Body,Footer:oo.Footer,Apply:oo.Apply,Cancel:oo.Cancel,Error:oo.Error,Field:oo.Field,Reset:oo.Reset});var Vt=yt();function EP(){return Vt.useState()}var tb=new WeakMap,SP=0,PP=e=>{let t=tb.get(e);return t===void 0&&tb.set(e,t=SP++),t};function kP({session:e,...t}){return e?jsxRuntime.jsx(wP,{session:e,...t},PP(e)):null}function wP({session:e,children:t,preset:o,className:n,style:r}){let i=Zt.useId(),{t:a}=H(),l=L=>a(`compareDocuments.${L}`),[s,c]=Zt.useState(()=>({revised:null,authorName:e.defaultAuthor,detectFormatChanges:true,removeDateAndTime:false})),[d,m]=Zt.useState(),[u,g]=Zt.useState(),[p,f]=Zt.useState(false),[b,y]=Zt.useState(null),[v,x]=Zt.useState(e.signal.aborted),h=Zt.useRef(null),[k,E]=Zt.useState(null);Zt.useLayoutEffect(()=>{k&&editor.focusCompareDocumentsControl(h.current,k.moment);},[k]);let C=W(Zt.useCallback(()=>e.canApply(),[e]),Object.is),T=Zt.useRef(false),S=Zt.useRef(null);Zt.useEffect(()=>{S.current=e;let L=()=>x(true);return x(e.signal.aborted),e.signal.addEventListener("abort",L),()=>{e.signal.removeEventListener("abort",L),S.current=null,queueMicrotask(()=>{S.current!==e&&e.cancel();});}},[e]);let P=async()=>{let L=s.revised;if(!L){m(l("fileRequired"));return}if(!T.current){T.current=true,f(true),E({moment:"busy"}),m(void 0),g(void 0);try{let N;try{N=new Uint8Array(await L.arrayBuffer());}catch{e.signal.aborted||(m(l("readFailed")),f(!1),E({moment:"refused"}));return}if(e.signal.aborted)return;let B=await e.apply({revised:N,authorName:s.authorName,detectFormatChanges:s.detectFormatChanges,...s.removeDateAndTime?{removeDateAndTime:!0}:{}},{onProgress:y});if(e.signal.aborted)return;y(null),B.ok?g(a("compareDocuments.noDifferences")):m(a(editor.compareDocumentsErrorKey(B))),f(!1),E({moment:B.ok?"unchanged":"refused"});}finally{T.current=false;}}},w=b?a(`compareDocuments.phases.${b.phase}`):l("comparing"),_={values:s,setValue(L,N){m(void 0),g(void 0),c(B=>({...B,[L]:N}));},errors:d===void 0?{}:{form:d},isEnabled:!v&&!p&&s.revised!==null&&C,busy:p,progress:b,cancelable:e.cancelable,notice:u,originalHasTrackedChanges:e.originalHasTrackedChanges,apply(){P();},cancel(){(!p||e.cancelable)&&e.cancel();}};return v?null:jsxRuntime.jsx(Fe,{kind:"compareDocuments",label:l("title"),className:["docx-compare-documents-dialog",n].filter(Boolean).join(" "),style:r,onClose:_.cancel,panelRef:h,dismissOutside:false,sessionSignal:e.signal,describedBy:o===false?void 0:`${i}-description${e.originalHasTrackedChanges?` ${i}-tracked`:""}`,busy:p,children:jsxRuntime.jsx(Vt.Composition,{state:_,preset:o,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{"data-docx-part":"header",children:[jsxRuntime.jsx("h2",{"data-docx-part":"title",children:l("title")}),jsxRuntime.jsx("p",{id:`${i}-description`,children:l("description")}),e.originalHasTrackedChanges?jsxRuntime.jsx("p",{id:`${i}-tracked`,"data-docx-part":"trackedChanges",className:"docx-compare-documents-tracked",children:l("trackedChangesAccepted")}):null]}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-compare-documents-body",children:[jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"revised",children:[jsxRuntime.jsx("span",{children:l("revisedFile")}),jsxRuntime.jsx("input",{type:"file",accept:editor.COMPARE_DOCUMENTS_ACCEPT,disabled:p,onChange:L=>_.setValue("revised",L.currentTarget.files?.[0]??null)})]}),jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"authorName",children:[jsxRuntime.jsx("span",{children:l("author")}),jsxRuntime.jsx("input",{type:"text",autoComplete:"off",value:s.authorName,disabled:p,onChange:L=>_.setValue("authorName",L.currentTarget.value)})]}),jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"detectFormatChanges",className:"docx-compare-documents-check",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:s.detectFormatChanges,disabled:p,onChange:L=>_.setValue("detectFormatChanges",L.currentTarget.checked)}),l("detectFormatting")]})]}),p?jsxRuntime.jsxs("div",{"data-docx-part":"progress","aria-busy":"true",children:[jsxRuntime.jsx("progress",{className:"docx-compare-documents-progress",max:1,value:b?.fraction,"aria-label":l("comparing"),"aria-valuetext":w}),jsxRuntime.jsx("span",{className:"docx-compare-documents-phase",tabIndex:-1,[editor.COMPARE_DOCUMENTS_PHASE_ATTRIBUTE]:"",children:w})]}):null,jsxRuntime.jsx("p",{"data-docx-part":"error",role:"alert",className:"docx-compare-documents-error",children:_.errors.form}),jsxRuntime.jsx("p",{"data-docx-part":"notice",role:"status",className:"docx-compare-documents-notice",children:u}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-compare-documents-actions",children:[jsxRuntime.jsx("button",{"data-docx-part":"cancel",type:"button",disabled:p&&!e.cancelable,onClick:_.cancel,children:u?a("common.close"):l("cancel")}),jsxRuntime.jsx("button",{"data-docx-part":"apply",type:"button",disabled:!_.isEnabled,onClick:_.apply,children:l(p?"comparing":"compare")})]})]}),children:t})})}var qa=Object.assign(kP,{Header:Vt.Header,Title:Vt.Title,Body:Vt.Body,Footer:Vt.Footer,Apply:Vt.Apply,Cancel:Vt.Cancel,Error:Vt.Error,Field:Vt.Field,Progress:Vt.part("progress"),Notice:Vt.part("notice")});function lu(e){let t=A(),o=Zt.useRef(e.onRevisionMarkupChange);o.current=e.onRevisionMarkupChange;let{onRevisionMarkupChange:n,...r}=e,i=JSON.stringify(r);return Zt.useEffect(()=>t?.on("revisionMarkupChange",a=>o.current?.(a)),[t]),Zt.useEffect(()=>{t&&t.setRevisionMarkup(JSON.parse(i));},[t,i]),null}function Ua({open:e,format:t,pending:o,error:n,onClose:r,className:i,style:a,children:l}){let{t:s}=H();if(!e)return null;let c=s(n?t==="pdf"?"toolbar.exportPdfFailed":"toolbar.exportMarkdownFailed":t==="pdf"?"toolbar.exportingPdf":"toolbar.exportingMarkdown");return jsxRuntime.jsx(Fe,{kind:"export",label:c,role:n?"alertdialog":"dialog",className:`docx-export-dialog${o?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:r,children:l??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"docx-dialog__header",children:[o&&jsxRuntime.jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsxRuntime.jsx("span",{className:"docx-export-dialog__spinner"})}),jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:c})]}),jsxRuntime.jsx("div",{className:"docx-dialog__body",children:jsxRuntime.jsx("p",{className:"docx-export-dialog__message",role:n?"alert":"status",children:n||s("toolbar.exportDownloadHint")})}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:s(n?"common.close":"toolbar.exportContinueEditing")})})]})})}function $a({open:e,pending:t,error:o,url:n,onClose:r,choosing:i=false,settings:a,onSettingsChange:l,onPrint:s,className:c,style:d,children:m}){let{t:u}=H();if(!e)return null;let g=i&&a&&l&&s,p=u(o?"toolbar.printFailed":g?"toolbar.print":"toolbar.printPreparing"),f=n.startsWith("blob:")?n:"";return jsxRuntime.jsx(Fe,{kind:"print",label:p,role:o?"alertdialog":"dialog",className:`docx-export-dialog docx-print-dialog${t?" docx-export-dialog--pending":""}${c?` ${c}`:""}`,style:d,dismissOutside:false,onClose:r,onKeyDown:b=>{editor.isChromePrintShortcut(b.nativeEvent)&&(b.preventDefault(),g&&!b.repeat&&s());},children:m??(g?jsxRuntime.jsx(HP,{title:p,settings:a,onSettingsChange:l,onPrint:s,onClose:r}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"docx-dialog__header",children:[t&&jsxRuntime.jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsxRuntime.jsx("span",{className:"docx-export-dialog__spinner"})}),jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:p})]}),o&&jsxRuntime.jsx("div",{className:"docx-dialog__body",children:jsxRuntime.jsx("p",{className:"docx-export-dialog__message",role:"alert",children:o})}),jsxRuntime.jsxs("footer",{className:"docx-dialog__footer",children:[o&&f&&jsxRuntime.jsx("a",{className:"docx-dialog__link-button docx-print-dialog__open",href:f,target:"_blank",rel:"noopener noreferrer",children:u("toolbar.printOpenPdf")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",ref:LP,onClick:r,children:u(o?"common.close":"common.cancel")})]})]}))})}function LP(e){if(!editor.isHTMLElementNode(e))return;let t=e.ownerDocument.activeElement;(!t||!e.closest("dialog")?.contains(t))&&e.focus({preventScroll:true});}function HP({title:e,settings:t,onSettingsChange:o,onPrint:n,onClose:r}){let{t:i}=H(),a=Zt.useId(),l=t.displayMode==="all-markup";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header","data-docx-part":"print-settings",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:e})}),jsxRuntime.jsxs("div",{className:"docx-dialog__body",children:[jsxRuntime.jsxs("fieldset",{className:"docx-dialog__fieldset",children:[jsxRuntime.jsx("legend",{className:"docx-dialog__section-label",children:i("toolbar.printMarkup")}),editor.CHROME_PRINT_DISPLAY_MODES.map(({mode:s,labelKey:c})=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":s,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${a}-mode`,checked:t.displayMode===s,onChange:()=>o({displayMode:s})}),i(c)]},s))]}),jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"comments",className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.comments,"aria-describedby":l?void 0:`${a}-comments-note`,onChange:s=>o({comments:s.target.checked})}),i("toolbar.printComments")]}),!l&&jsxRuntime.jsx("p",{id:`${a}-comments-note`,className:"docx-dialog__note",children:i("toolbar.printCommentsNote",{mode:i("review.allMarkup")})})]}),jsxRuntime.jsxs("footer",{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:n,children:i("toolbar.print")})]})]})}var St={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function Nr({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:St.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 Fr({noteKind:e,x:t,y:o,onDelete:n,onConvert:r,onConvertAll:i,onOpenProperties:a,onClose:l,deleteEnabled:s,convertEnabled:c,convertAllEnabled:d,deleteDisabledReason:m,convertDisabledReason:u,convertAllDisabledReason:g,className:p}){let{t:f}=H();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:St.popover,minWidth:160,background:"var(--doc-popover-bg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",padding:4},onMouseDown:$,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!s,title:m,onClick:n,children:f("notes.delete")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!c,title:u,onClick:r,children:f(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:f(e==="footnote"?"notes.convertAllFootnotes":"notes.convertAllEndnotes")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",onClick:a,children:f("dialogs.footnoteProperties.title")})]})}function BP(e){return t=>Zt.createElement(e,t)}var ab=new WeakMap,WP=0;function Te(e,t,o){if(e===false)return null;let n=e(t);if(!o)return n;let r=ab.get(o);return r===void 0&&ab.set(o,r=++WP),Zt.createElement(Zt.Fragment,{key:r},n)}var su=Zt.createContext(void 0),Rt=()=>Zt.useContext(su);function Lr(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 ja(e){return e.paragraphId===""}var GP=4096,Hr=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),jP=e=>e;function YP(e){let t=r=>!!r&&(r.width>0||r.height>0),o=editor.hostDocumentOf(e);if(o){let i=o.querySelector("[data-docx-caret]")?.getBoundingClientRect();if(t(i))return {left:i.left,top:i.bottom}}let n=o?o.getSelection():null;if(n&&n.rangeCount>0){let r=n.getRangeAt(0),i=r.getBoundingClientRect();if(t(i))return {left:i.left,top:i.bottom};let a=r.startContainer,s=(editor.isElementNode(a)?a:a.parentElement)?.getBoundingClientRect();if(t(s))return {left:s.left,top:s.bottom}}return null}var Ya=Zt.createContext(null),cu=Zt.createContext(null);function du(){let e=Zt.useContext(cu);Zt.useEffect(()=>e?.(),[e]);}function XP(){let e=Zt.useContext(Ya);du();let t=Xl(e===null);return e??t}function Xl(e=true){let t=A(),o=we(),n=Zt.useRef(o);n.current=o;let[r,i]=Zt.useState(Hr),a=Zt.useRef(null),l=Zt.useRef(""),s=Zt.useRef(false),c=Zt.useRef(r);c.current=r;let d=W(jP),m=t?t.can({type:"insertText",text:""}).ok:false,u=Zt.useCallback(()=>{l.current="",s.current=false;let T=a.current;T&&(T.editor.releaseSelection(T.pin),a.current=null);},[]),g=Zt.useCallback((T=false)=>{let S=l.current;return S===""||!t?false:!s.current&&t.surface?.hyperlinks.selectionIsPendingDeletion()===true?true:T&&S.length>GP?false:t.query({type:"selectedText"})!==S},[t]),p=Zt.useCallback((T,S)=>{u(),i({mode:T?"reading":"editing",link:T??null,anchor:S??null,text:T?.text??"",url:T?T.kind==="internal"?`#${T.anchor??""}`:T.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,u]),f=Zt.useCallback(()=>{u(),i(Hr);},[u]);Zt.useEffect(()=>u,[u]);let b=Zt.useCallback(()=>{let T=YP(n.current);u();let S=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(S&&ja(S)){p(S,T);return}if(S){i({mode:"editing",link:S,anchor:T,text:S.text,url:S.kind==="internal"?`#${S.anchor??""}`:S.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let P=t?.surface?.hyperlinks.wordAtCaret()??null;P&&t?.surface?.setSelection({anchor:P.from,head:P.to});let w=t?.query({type:"selectedText"})??"",_=t?.retainSelection()??null;t&&_&&(a.current={editor:t,pin:_}),l.current=w,s.current=t?.surface?.hyperlinks.selectionIsPendingDeletion()===true,i({mode:"editing",link:null,anchor:T,text:w,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,p,u]);Zt.useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:T=>p(T.link,{left:T.rect.left,top:T.rect.bottom}),onRequest:b})},[t,e,p,b]),Zt.useEffect(()=>{let T=c.current;if(T.mode!=="reading"||!T.link)return;let S=ja(T.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;S&&S.id===T.link.id||i(Hr);},[d,t]),Zt.useEffect(()=>{let T=c.current;if(T.mode!=="editing"||T.link)return;let S=t?.surface;S&&(S.retainedSelection()&&!g(true)||f());},[d,t,g,f]);let y=Zt.useCallback(async()=>{let T=c.current.link?.href;if(!T)return false;try{await editor.hostWindowOf(n.current).navigator.clipboard.writeText(T);}catch{return false}return i(S=>({...S,copied:true})),true},[]),v=Zt.useCallback(()=>{i(T=>({...T,mode:"editing",copied:false,error:false}));},[]),x=Zt.useCallback(T=>{i(S=>({...S,text:T,copied:false,error:false}));},[]),h=Zt.useCallback(T=>{i(S=>({...S,url:T,copied:false,error:false}));},[]),k=Zt.useCallback(()=>{let T=c.current,S=t?.surface?.hyperlinks;if(!S)return false;if(!T.link&&g())return f(),false;let P=T.url.trim();if(P.length===0)return i(L=>({...L,error:true})),false;let w=P.startsWith("#");return S.applyHyperlink({...w?{anchor:P.slice(1)}:{url:P},...T.text.trim().length>0?{text:T.text}:{}})?(f(),true):(i(L=>({...L,error:true})),false)},[t,f,g]),E=Zt.useCallback(()=>{let T=t?.surface?.hyperlinks,S=c.current.link;if(!T)return false;let P=T.removeHyperlink(S?.id);return P&&f(),P},[t,f]),C=Zt.useCallback(()=>{let T=t?.surface?.navigation,S=c.current.link;if(!T||!S)return false;if(S.kind==="internal"){let w=S.anchor?T.goToBookmark(S.anchor):false;return w&&i(Hr),w}let P=T.openExternal(S.href);return P&&i(Hr),P},[t]);return Zt.useMemo(()=>({state:r.mode==="closed"?Hr:{...r,canEdit:m},open:p,openAtCaret:b,close:f,copy:y,beginEdit:v,setText:x,setUrl:h,commitEdit:k,unlink:E,openTarget:C}),[r,m,p,b,f,y,v,x,h,k,E,C])}function Xn(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Xa(){let e=A();return Zt.useCallback(()=>{e?.focus();},[e])}var Jl=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"})}),ak="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",ik="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",lk="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",sk="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 ck({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=So();du();let a=Zt.useRef(null),{state:l,close:s}=i,c=Xa();Zt.useEffect(()=>{if(l.mode==="closed")return;let b=x=>{x.key==="Escape"&&(x.preventDefault(),s(),c());},y=editor.hostDocumentOf(a.current);y.addEventListener("keydown",b);let v=editor.listenForOutsidePress({popup:y,contains:x=>a.current?.contains(x)===true,close:s});return ()=>{y.removeEventListener("keydown",b),v();}},[l.mode,s,c]);let[d,m]=Zt.useState(null);Zt.useLayoutEffect(()=>{let b=l.anchor,y=a.current;if(!b||!y){m(null);return}let v=y.offsetParent;if(!v){m(null);return}let{left:x,top:h}=Lr(v,b.left,b.top),k=Math.max(0,v.scrollWidth-y.offsetWidth);m({left:Math.max(0,Math.min(x,k)),top:h});},[l.anchor]);let{t:u}=H(),g=l.mode==="editing"?u(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):u("hyperlinkPopup.editLink"),p=r?jsxRuntime.jsx(dk,{children:n}):n;if(o)return l.mode==="closed"?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:n});let f={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:Xn,style:d??void 0,"aria-label":g};return l.mode==="closed"?null:t?jsxRuntime.jsx(Q,{...f,children:n}):jsxRuntime.jsx("div",{...f,children:p})}function dk({children:e}){let{state:t}=So(),o=Zt.useMemo(()=>uk(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(bu,{})),n("Error",jsxRuntime.jsx(yu,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Apply",jsxRuntime.jsx(hu,{})),n("Cancel",jsxRuntime.jsx(xu,{}))]}),o.__extra]});let r=t.canEdit&&!(t.link&&ja(t.link));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Url",jsxRuntime.jsx(pu,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Copy",jsxRuntime.jsx(mu,{})),r?n("Edit",jsxRuntime.jsx(fu,{})):null,r?n("Unlink",jsxRuntime.jsx(gu,{})):null]}),o.__extra]})}function uk(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===Zt.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 So(){return Zt.useContext(Ya)??pk}var pk={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 pu({className:e,asChild:t,hidden:o,children:n}){let{state:r,openTarget:i}=So(),{t:a}=H();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=jsxRuntime.jsx("bdi",{dir:s?void 0:"ltr",children:c}),m=a(l?"hyperlinkPopup.inertTarget":s?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),u={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...l?{"data-inert":""}:{},title:m,onMouseDown:Xn,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsxRuntime.jsx(Q,{...u,className:e,children:n}):l?jsxRuntime.jsxs("span",{...u,children:[n??d,jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:m})]}):jsxRuntime.jsxs("button",{...u,children:[n??d,Jl(sk)]})}pu.docxHyperLinkPart="Url";function mu({className:e,asChild:t,hidden:o,children:n,icon:r}){let{state:i,copy:a}=So(),{t:l}=H();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:Xn,onClick:()=>{a();}};return t?jsxRuntime.jsx(Q,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:r??n??Jl(ak)})}mu.docxHyperLinkPart="Copy";function fu({className:e,asChild:t,hidden:o,children:n,icon:r}){let{beginEdit:i}=So(),{t:a}=H();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:Xn,onClick:()=>i()};return t?jsxRuntime.jsx(Q,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:r??n??Jl(ik)})}fu.docxHyperLinkPart="Edit";function gu({className:e,asChild:t,hidden:o,children:n,icon:r}){let{unlink:i}=So(),a=Xa(),{t:l}=H();if(o)return null;let s=l("hyperlinkPopup.removeLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":s,title:s,onMouseDown:Xn,onClick:()=>{i()&&a();}};return t?jsxRuntime.jsx(Q,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:r??n??Jl(lk)})}gu.docxHyperLinkPart="Unlink";function bu({className:e,hidden:t}){let{state:o,setText:n,setUrl:r,commitEdit:i,close:a}=So(),l=Xa(),{t:s}=H(),c=Zt.useRef(null),d=Zt.useId(),m=Zt.useId();Zt.useEffect(()=>{o.mode==="editing"&&(c.current?.focus({preventScroll:true}),c.current?.select());},[o.mode]);let u=Zt.useCallback(g=>{if(g.key==="Enter"){g.preventDefault(),i()&&l();return}g.key==="Escape"&&(g.preventDefault(),a(),l());},[i,a,l]);return t?null:jsxRuntime.jsxs("div",{className:`docx-hyperlink-popup__fields${e?` ${e}`:""}`,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:s("hyperlinkPopup.displayTextPlaceholder")}),jsxRuntime.jsx("input",{id:d,"data-testid":"hyperlink-popup-text",className:"docx-hyperlink-popup__input",value:o.text,dir:o.text?"auto":void 0,placeholder:s("hyperlinkPopup.displayTextPlaceholder"),onChange:g=>n(g.target.value),onKeyDown:u}),jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:m,children:s("hyperlinkPopup.urlLabel")}),jsxRuntime.jsx("input",{id:m,ref:c,"data-testid":"hyperlink-popup-url-input",className:"docx-hyperlink-popup__input",value:o.url,dir:"ltr",placeholder:s("hyperlinkPopup.urlPlaceholder"),onChange:g=>r(g.target.value),onKeyDown:u})]})}bu.docxHyperLinkPart="Fields";function hu({className:e,asChild:t,hidden:o,children:n}){let{state:r,commitEdit:i}=So(),a=Xa(),{t:l}=H();if(o)return null;let s=l("hyperlinkPopup.apply"),c={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:Xn,onClick:()=>{i()&&a();}};return t?jsxRuntime.jsx(Q,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:n??s})}function yu({className:e,hidden:t}){let{state:o}=So(),{t:n}=H();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")})}yu.docxHyperLinkPart="Error";hu.docxHyperLinkPart="Apply";function xu({className:e,asChild:t,hidden:o,children:n}){let{close:r}=So(),i=Xa(),{t:a}=H();if(o)return null;let l=a("hyperlinkPopup.cancel"),s={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:Xn,onClick:()=>{r(),i();}};return t?jsxRuntime.jsx(Q,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:n??l})}xu.docxHyperLinkPart="Cancel";var Ja=Object.assign(ck,{Url:pu,Copy:mu,Edit:fu,Unlink:gu,Fields:bu,Error:yu,Apply:hu,Cancel:xu});var Mt={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function bk(e){return e==="sdtLocked"||e==="sdtContentLocked"}function hk(e){return e==="contentLocked"||e==="sdtContentLocked"}function Cu(e,t){return !e.ok&&e.code===t}function Po(){let e=Zt.useContext(Tu),t=Ql();return e??t}function Ql(){let e=A(),[t,o]=Zt.useState(false),[n,r]=Zt.useState(false),[i,a]=Zt.useState(false),l=W(C=>C),s=e?.surface??null,c=s?.contentControls;Zt.useEffect(()=>{r(c?.showAll()??s?.state().contentControls.showAll??false),a(c?.formFill()??s?.state().contentControls.formFill??false);},[l,c,s]);let d=Zt.useMemo(()=>{if(!e)return null;let C=c?.atCaret()??null;if(C){let F=c?.disabledReason(C.id,"edit")??null,D=c?.disabledReason(C.id,"remove")??null;return {id:C.id,tag:C.tag??null,alias:C.alias??null,controlType:C.controlType,locked:hk(C.effectiveLock)||F==="locked",removalLocked:bk(C.effectiveLock)||D==="locked",placeholder:C.placeholder,bound:C.bound||F==="bound",effectiveLock:C.effectiveLock}}let T=e.query({type:"contentControlAt"});if(!T)return null;let S=c?.disabledReason(T.id,"edit")??null,P=c?.disabledReason(T.id,"remove")??null,w=e.can({type:"setContentControlValue",value:""}),_=e.can({type:"removeContentControl"}),L=T.locked===true||S==="locked"||Cu(w,"locked"),N=S==="bound"||Cu(w,"bound"),B=P==="locked"||Cu(_,"locked");return {id:T.id,tag:T.tag??null,alias:T.alias??null,controlType:T.controlType,locked:L,removalLocked:B,placeholder:false,bound:N,effectiveLock:null}},[e,l,c]),m=Zt.useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=Zt.useCallback(C=>{c?.setShowAll(C),r(C);},[c]),g=Zt.useCallback(C=>{c?.setFormFill(C),a(C);},[c]),p=Zt.useCallback(()=>u(!n),[u,n]),f=Zt.useCallback(()=>g(!i),[g,i]),b=Zt.useCallback(()=>o(true),[]),y=Zt.useCallback(()=>o(false),[]),v=Zt.useCallback(()=>o(C=>!C),[]),x=Zt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let T=c.disabledReason(d.id,"edit");return T==="locked"?"the content control is locked":T==="bound"?"the content control is bound to external data":T==="notFound"?"the content control was not found":T}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 C=e.can({type:"setContentControlValue",value:""});return C.ok?null:C.reason},[d,c,e]),h=Zt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let T=c.disabledReason(d.id,"remove");return T==="locked"?"the content control is locked":T==="notFound"?"the content control was not found":T}if(d.removalLocked)return "the content control is locked";if(!e)return "no document is loaded";let C=e.can({type:"removeContentControl"});return C.ok?null:C.reason},[d,c,e]),k=Zt.useCallback(C=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c&&d){let T=c.disabledReason(d.id,"edit");if(T)return {ok:false,code:T==="bound"?"bound":T==="locked"?"locked":"notFound",reason:T==="bound"?"the content control is bound to external data":T==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:C})},[e,c,d]),E=Zt.useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c){let C=d?.id;if(!C)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let T=c.disabledReason(C,"remove");return T?{ok:false,code:T==="locked"?"locked":"notFound",reason:T==="locked"?"the content control is locked":"the content control was not found"}:c.remove(C)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,c,d]);return Zt.useMemo(()=>({control:d,controls:m,showAll:n,formFill:i,inspectorOpen:t,canSetValue:x===null&&d!==null,canRemove:h===null&&d!==null,setValueDisabledReason:x,removeDisabledReason:h,setShowAll:u,toggleShowAll:p,setFormFill:g,toggleFormFill:f,openInspector:b,closeInspector:y,toggleInspector:v,remove:E,setValue:k}),[d,m,n,i,t,x,h,u,p,g,f,b,y,v,E,k])}var Tu=Zt.createContext(null);function Eu(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var fb=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"})}),Tk="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",Ek="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",Sk={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},Pk={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},kk={color:"var(--doc-text-muted)",flexShrink:0},wk={textAlign:"right",wordBreak:"break-word"},Dk={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},Rk={display:"flex",gap:8,marginTop:4},gb={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 Mk(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 _k(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 Ar({label:e,value:t,testId:o}){return jsxRuntime.jsxs("div",{style:Pk,"data-testid":o,children:[jsxRuntime.jsx("span",{style:kk,children:e}),jsxRuntime.jsx("span",{style:wk,children:t})]})}function Ik({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=Po(),a=Zt.useRef(null),l=Zt.useId(),{t:s}=H(),{control:c,inspectorOpen:d,closeInspector:m}=i;if(Zt.useEffect(()=>{if(!d)return;let f=v=>{v.key==="Escape"&&(v.preventDefault(),m());},b=editor.hostDocumentOf(a.current);b.addEventListener("keydown",f);let y=editor.listenForOutsidePress({popup:b,contains:v=>a.current?.contains(v)===true,close:m});return ()=>{b.removeEventListener("keydown",f),y();}},[d,m]),Zt.useEffect(()=>{d&&!c&&m();},[d,c,m]),o||!d||!c)return null;let u=r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(bb,{}),jsxRuntime.jsx(hb,{}),jsxRuntime.jsx("div",{style:Rk,children:jsxRuntime.jsx(yb,{})}),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:Sk,onMouseDown:f=>{Eu(f),f.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(Q,{...g,children:p}):jsxRuntime.jsx("div",{...g,children:p})}function bb({className:e,asChild:t,hidden:o,children:n}){let{closeInspector:r}=Po(),{t:i}=H();if(o)return null;let a={style:Dk,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:{...gb,padding:4,border:"none",background:"transparent"},onMouseDown:Eu,onClick:()=>r(),children:fb(Tk)})]});return t?jsxRuntime.jsx(Q,{...a,children:l}):jsxRuntime.jsx("div",{...a,children:l})}function hb({className:e,asChild:t,hidden:o,children:n}){let{control:r}=Po(),{t:i}=H();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(Ar,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsxRuntime.jsx(Ar,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsxRuntime.jsx(Ar,{label:i("contentControl.inspectorPanel.type"),value:i(Mk(r.controlType)),testId:"content-control-inspector-type"}),jsxRuntime.jsx(Ar,{label:i("contentControl.inspectorPanel.lock"),value:i(_k(r)),testId:"content-control-inspector-lock"}),jsxRuntime.jsx(Ar,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsxRuntime.jsx(Ar,{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(Q,{...d,children:c}):jsxRuntime.jsx("div",{...d,children:c})}function yb({className:e,asChild:t,hidden:o,icon:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:s}=Po(),{t:c}=H();if(o)return null;let d=c("contentControl.remove"),m={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:gb,onMouseDown:Eu,onClick:()=>{l().ok&&s();}},u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n??r??fb(Ek),jsxRuntime.jsx("span",{children:d})]});return t?jsxRuntime.jsx(Q,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}var ti=Object.assign(Ik,{Header:bb,Fields:hb,Remove:yb});var Ak=e=>e;function Du(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function oi(){let e=A(),{t}=H(),[o,n]=Zt.useState(null),[r,i]=Zt.useState(null),a=Zt.useRef(null),l=Zt.useRef(null),s=Zt.useRef(null),c=Zt.useId(),d=Zt.useId(),m=Zt.useId(),u=o?.activation??null,g=W(Ak),p=Zt.useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let x=e.surface.equations.can(u.equation.id,"replace"),h=e.surface.equations.can(u.equation.id,"remove"),k=x.ok?h.ok?null:h.reason:x.reason;return {replaceEnabled:x.ok,removeEnabled:h.ok,reason:k?i18n.localizeDisabledReason(k,t):null}},[u,e,g,t]),f=Zt.useCallback((x=false)=>{s.current?.(),s.current=null,n(null),x&&e&&queueMicrotask(()=>e.focus());},[e]);Zt.useEffect(()=>{if(!e)return;let x=e.setEquationChrome({onPopover:h=>{s.current?.();let k=e.surface;if(k&&typeof k.retainSelection=="function"){let E=k.retainSelection();s.current=()=>k.releaseSelection(E);}else s.current=null;n({activation:h,mountGeneration:e.mountGeneration,draft:h.equation.linear,error:false});}});return ()=>{x(),s.current?.(),s.current=null,n(null);}},[e,f]),Zt.useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&f();},[e,g,o,f]),Zt.useEffect(()=>{if(!o)return;let x=a.current,h=x?.ownerDocument,k=h?.defaultView;if(!x||!h||!k)return;let E=T=>{T.key==="Escape"&&(T.preventDefault(),f(true));},C=T=>{editor.isDomNode(T.target)&&x.contains(T.target)||f();};return h.addEventListener("keydown",E),h.addEventListener("pointerdown",C,true),()=>{h.removeEventListener("keydown",E),h.removeEventListener("pointerdown",C,true);}},[o,f]),Zt.useLayoutEffect(()=>{if(!u){i(null);return}let x=a.current;if(!x)return;let h=x.offsetParent;if(!h){i(null);return}let k=u.rect,E=Lr(h,k.left,k.bottom),C=Math.max(0,h.scrollWidth-x.offsetWidth);i({left:Math.max(0,Math.min(E.left,C)),top:E.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[u]);let b=Zt.useCallback(()=>{if(!o||!e?.surface||!p.replaceEnabled)return false;let x=e.surface.equations.applyEquation(o.activation.equation.id,o.draft);return x?f(true):n(h=>h&&{...h,error:true}),x},[e,o,f,p.replaceEnabled]),y=Zt.useCallback(()=>{if(!o||!e?.surface||!p.removeEnabled)return false;let x=e.surface.equations.removeEquation(o.activation.equation.id);return x?f(true):n(h=>h&&{...h,error:true}),x},[e,o,f,p.removeEnabled]);if(!o)return null;let v=[o.error?d:null,p.reason?m: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:Du,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":v||void 0,onChange:x=>n(h=>h&&{...h,draft:x.target.value,error:false}),onKeyDown:x=>{x.key!=="Enter"||x.nativeEvent.isComposing||(x.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:m,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:Du,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:Du,onClick:y,children:t("equationPopup.delete")})]})]})}var Cb="review.comments",Ru="review.addComment";function Tb(e){return e!==Cb?e:(un(`The context-menu row "${Cb}" is now "${Ru}". The old id still works in this release; write "${Ru}".`),Ru)}var Bk="input, textarea, select",Wk="[data-docx-form-dropdown]",Zk=".docx-paginated-surface:not(.docx-editor__loading-surface)",Kk=".docx-image-selection-overlay";function Eb(e,t){if(!editor.isElementNode(t))return false;let o=t.closest(Bk);if(o&&!o.matches(Wk))return false;let n=e.querySelector(Zk);return n?n.contains(t)||t.contains(n)||!!t.closest(Kk):true}function Wr(e,t){if(!Zt.isValidElement(e)||e.type!==Zt.Fragment)return null;let n=Zt.Children.toArray(e.props.children).map(t).filter(r=>r!==null);return n.length===1?n[0]:null}function es({entries:e,children:t,preset:o,keyOfEntry:n,keyOfChild:r,renderEntry:i,childrenOfEntry:a,onUnmatched:l}){if(!o)return t;let s=new Map,c=[];for(let p of Zt.Children.toArray(t)){let f=r(p);f?s.set(f,p):c.push(p);}let d=new Set,m=p=>p.map((f,b)=>{let y=n(f,b);d.add(y);let v=a?.(f),x=v?m(v):void 0,h=s.get(y);return jsxRuntime.jsx(Zt.Fragment,{children:h??i(f,b,x)},y)}),u=m(e),g=[...s.entries()].filter(([p])=>!d.has(p)).map(([p,f])=>(l?.(p,f),jsxRuntime.jsx(Zt.Fragment,{children:f},p)));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u,g,c]})}var zk="review.addComment",Vk=e=>e.editingMode==="viewing";function ts(e){let{isEnabled:t,disabledReason:o}=re(zk),n=W(Vk);return t?{isEnabled:t,reason:null}:{isEnabled:t,reason:n?e("editingMode.viewingHint"):o}}var ni=Zt.createContext({t:void 0,openMenu:null,setOpenMenu:()=>{},activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onWatermarkDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),Zr="docx-menubar-more",os=Zt.createContext({measuring:false,overflow:new Set,inMore:false});function wb(){return Zt.useContext(os)}function et(){return Zt.useContext(ni)}function Pe(){let{t:e}=et(),{t}=H();return o=>e?.(o)??t(o)}var Kr=Zt.createContext(-1);var Gk='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Jn(e){return [...e.querySelectorAll(Gk)].filter(t=>t.closest('[role="menu"]')===e)}function Iu(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function no(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 ro(e,t){let o=t==="first"?e[0]:e[e.length-1];return o?(o.focus(),true):false}function Nu(e){let t=e?.ownerDocument.activeElement;((t&&e?.contains(t)?t.closest("[data-menu]"):null)?.querySelector(':scope > [role="menuitem"]')??e?.querySelector('.docx-menubar__trigger[aria-expanded="true"]'))?.focus({preventScroll:true});}function Db(e,t,o){return !o||o.ownerDocument===t?false:o.contains(e)}var qr="data-toolbar-group",_b=editor.TOOLBAR_ITEM_ATTRIBUTE,Ur="data-toolbar-fixed",rs="data-toolbar-more",iw=34,ns=new Map;function Fu(e,t,o){let n=Zt.useRef(null),r=Zt.useRef({itemWidths:new Map,groupBases:new Map,groupGaps:new Map,more:iw}),[i,a]=Zt.useState(ns),l=Zt.useRef(i);l.current=i;let s=Zt.useRef({groups:t,order:o});s.current={groups:t,order:o};let c=editor.toolbarGroupsKey(t),d=Zt.useRef(c),m=o.join("\0"),u=Zt.useCallback(()=>{let p=n.current;if(!p||!e)return;let f=editor.readToolbarRow(p,r.current,editor.toolbarItemKey),b=l.current.size===0&&f.overflowing===false,y=editor.toolbarGroupsKey(s.current.groups),v=d.current===y;d.current=y;let x=b?ns:editor.toolbarOverflowItems({...f,groups:s.current.groups,order:s.current.order,itemWidths:r.current.itemWidths,groupBases:r.current.groupBases,groupGaps:r.current.groupGaps,...v?{previous:l.current}:{},hysteresis:editor.TOOLBAR_OVERFLOW_HYSTERESIS});editor.sameItemOverflow(x,l.current)||(l.current=x,a(x));},[e]),g=Zt.useCallback(p=>{n.current=p;},[]);return Zt.useLayoutEffect(()=>{if(!e){l.current.size>0&&(l.current=ns,a(ns));return}u();},[e,c,u,m]),Zt.useEffect(()=>{let p=n.current,f=p?editor.hostWindowOf(p):null;if(!e||!p||!f||typeof f.ResizeObserver>"u")return;let b=0,y=new f.ResizeObserver(()=>{b===0&&(b=f.requestAnimationFrame(()=>{b=0,u();}));});y.observe(p),p.parentElement&&y.observe(p.parentElement);for(let v of p.querySelectorAll(`[${qr}], [${Ur}]`))y.observe(v);return ()=>{b!==0&&f.cancelAnimationFrame(b),y.disconnect();}},[e,c,u,m,i]),{attach:g,overflow:i}}function Ib(e,t,o){let n=t.map(l=>({id:l,items:[l]})),{attach:r,overflow:i}=Fu(e,n,o),a=Zt.useMemo(()=>new Set(i.keys()),[i]);return {attach:r,overflow:a}}function Nb(e,t,o){let n=e.overflow.has(t),r=t===Zr;return {skip:e.inMore?!n:n,asSubmenu:e.inMore&&n,iconOnly:r,rootAttributes:{...e.measuring&&!r?{[qr]:t}:{},...r?{[rs]:""}:{}},tabStop:o===t||r&&o!==null&&e.overflow.has(o)}}function Fb(e,t,o){let[n,r]=Zt.useState(void 0);return Zt.useLayoutEffect(()=>{if(!e){r(void 0);return}let i=()=>{let l=t.current,s=o.current,c=l?.parentElement,d=l?.ownerDocument.defaultView;if(!l||!s||!c||!d)return;let m=l.getBoundingClientRect(),u=editor.toolbarPanelPlacement({triggerLeft:m.left,triggerRight:m.right,panelWidth:s.offsetWidth,viewportWidth:d.innerWidth});r({left:u.left-c.getBoundingClientRect().left,right:"auto",maxInlineSize:u.maxWidth});};i();let a=t.current?.ownerDocument.defaultView;return a?.addEventListener("resize",i),()=>a?.removeEventListener("resize",i)},[e,o,t]),n}var Hb=12700,Lb=96;function mw(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function fw(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 as(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(!mw(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}=fw(n.pixelWidth,n.pixelHeight,n.dpiX??Lb,n.dpiY??Lb);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function gn(e){return Math.round(e/Hb*100)/100}function ai(e){return Math.round(e*Hb)}function is(e,t){return e.label!==void 0?e.label:e.labelKey!==void 0?t(e.labelKey):e.id}function Lu(e){let t=ae();return e.hidden?null:jsxRuntime.jsx("div",{role:"group","aria-label":is(e,t),className:`docx-toolbar__group${e.className?` ${e.className}`:""}`,"data-toolbar-host-group":e.id,children:e.children})}Lu.docxToolbarGroup=true;function ii(e){return e.hidden?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.children})}ii.docxToolbarSlot=true;var ls=Zt.createContext("bar");function ss(){return Zt.useContext(ls)}function bn(e,t){return ss()==="panel"&&!e&&t===void 0}function hn(e){return e?"docx-toolbar__more-command":"docx-toolbar__button"}function yn({icon:e,label:t}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:e}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:t})]})}function Hu({message:e,onClose:t,className:o,style:n,children:r}){let{t:i}=H();return jsxRuntime.jsx(Fe,{kind:"imageInsertError",role:"alertdialog",label:i("imageInsert.errors.title"),className:o,style:n,onClose:t,onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing&&(a.preventDefault(),t());},children:r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:i("imageInsert.errors.title")})}),jsxRuntime.jsx("div",{className:"docx-dialog__body","data-docx-part":"message",children:e}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:t,children:i("common.close")})})]})})}var Wb="image/png,image/jpeg,image/gif",Ou=Zt.createContext(null);function Kb(){let e=Zt.useContext(Ou);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function si(){return Zt.useContext(Ou)}function cs({children:e}){let t=A(),{t:o}=H(),n=Zt.useRef(null),r=Zt.useRef(false),i=Rt(),[a,l]=Zt.useState(null),s=Zt.useRef(null),c=Zt.useCallback(()=>editor.toolbarCommandState(t,"image.insert"),[t]),d=W(c,(x,h)=>x.enabled===h.enabled&&x.disabledReason===h.disabledReason),m=d.enabled,u=i18n.localizeDisabledReason(d.disabledReason,o),g=Zt.useCallback(async x=>{if(!t||r.current)return;let h=as(x);if(!h.ok){l(o(h.reasonKey));return}let k={type:"insertImage",data:h.bytes,mime:h.mime,widthPoints:h.widthPoints,heightPoints:h.heightPoints};r.current=true;try{let E=await editor.executeImageCommand(t,k);E.ok?t.focus():l(i18n.localizeDisabledReason(Dw(E.reason)??null,o)??o("imageInsert.errors.refused"));}finally{r.current=false;}},[t,o]),p=Zt.useCallback(async x=>{let h=x?.[0];if(!h)return;let k=await h.arrayBuffer();await g(new Uint8Array(k));},[g]),f=Zt.useCallback(async x=>{if(!x)return;let h=[...x.files].find(k=>k.type.startsWith("image/"));if(h){await p([h]);return}for(let k of x.items){if(k.kind!=="file"||!k.type.startsWith("image/"))continue;let E=k.getAsFile();if(!E)continue;let C=await E.arrayBuffer();await g(new Uint8Array(C));return}},[g,p]),b=Zt.useCallback(()=>{if(!m)return;let x=n.current,h=t?editor.editorHostDocument(t):null;if(!h||!x||x.ownerDocument===h){x?.click();return}s.current?.remove();let k=h.createElement("input");k.type="file",k.accept=Wb,k.hidden=true,k.tabIndex=-1,k.setAttribute("aria-hidden","true");let E=()=>{k.remove(),s.current===k&&(s.current=null);};k.addEventListener("change",()=>{p(k.files).finally(E);},{once:true}),k.addEventListener("cancel",E,{once:true}),h.body.append(k),s.current=k,k.click();},[t,m,p]),y=Zt.useCallback(async x=>{let h=x.currentTarget;await p(h.files),h.value="";},[p]),v=Zt.useMemo(()=>({openFilePicker:b,insertFromFileList:p,insertFromDataTransfer:f,isEnabled:m,disabledReason:u,inputRef:n,onInputChange:y}),[b,p,f,m,u,y]);return jsxRuntime.jsxs(Ou.Provider,{value:v,children:[jsxRuntime.jsx("input",{ref:n,type:"file",accept:Wb,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:y,onMouseDown:x=>x.stopPropagation()}),e,a!==null&&(i?.imageInsertError!==void 0?Te(i.imageInsertError,{message:a,onClose:()=>l(null)}):jsxRuntime.jsx(Hu,{message:a,onClose:()=>l(null)}))]})}function ds({className:e,hidden:t,asChild:o,children:n}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=Kb(),l=ae(),s=bn(o,n);if(t)return null;let c=te("image.insert"),d=l(c?.labelKey??"toolbar.image"),m={type:"button",className:`${hn(s)}${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":d,title:a??d,onMouseDown:$,onClick:r};if(o)return jsxRuntime.jsx(Q,{...m,children:n});let u=oe(c?.paths);return jsxRuntime.jsx("button",{...m,children:s?jsxRuntime.jsx(yn,{icon:u,label:d}):n??u})}ds.docxSlot="image.insert";var ci=Object.assign(ds,{docxSlot:"image.insert"});function Dw(e){return e&&/\s/.test(e)?e:void 0}var Bu=6,$b=6;function ps({slot:e,label:t,onInserted:o,className:n}){let r=A(),{isEnabled:i}=re(e),[a,l]=Zt.useState(null),[s,c]=Zt.useState({rows:1,cols:1}),d=Zt.useRef(null),m=Zt.useCallback((p,f)=>{if(!r||!i)return;let b={type:"insertTable",rows:p,cols:f};r.can(b).ok&&(r.exec(b),o(),r.focus());},[r,i,o]),u=Zt.useCallback(p=>{c(f=>{let b={rows:Math.min($b,Math.max(1,f.rows+(p.rows??0))),cols:Math.min(Bu,Math.max(1,p.toCol??f.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<=$b;p+=1){let f=[];for(let b=1;b<=Bu;b+=1){let y=!!a&&p<=a.rows&&b<=a.cols;f.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,...y?{"data-filled":""}:{},"aria-label":`${b} \xD7 ${p}`,onMouseDown:$,onMouseEnter:()=>l({rows:p,cols:b}),onFocus:()=>l({rows:p,cols:b}),onClick:()=>m(p,b)},b));}g.push(jsxRuntime.jsx("div",{role:"row",className:"docx-menubar__grid-row",children:f},p));}return jsxRuntime.jsxs("div",{ref:d,role:"grid","aria-label":t,className:`docx-menubar__grid${n?` ${n}`:""}`,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:Bu});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 Vr({slot:e="table.insert",className:t}){let{setOpenMenu:o}=et(),n=Pe(),r=Zt.useCallback(()=>o(null),[o]);return jsxRuntime.jsx(ps,{slot:e,label:n("toolbar.insertTable"),onInserted:r,className:t})}function Lw({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=re(editor.chromeProbeForSlot("insert.watermark")),r=et(),i=Pe();if(t)return null;let a=te("insert.watermark"),l=i(a?.labelKey??"toolbar.watermark"),s=o&&!!r.onWatermarkDialog;return jsxRuntime.jsx(De,{slot:"insert.watermark",icon:oe(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onWatermarkDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var ms=Object.assign(Lw,{docxSlot:"insert.watermark"});var Ow={type:"openGoTo",fromShortcut:true};function zb(){let e=re(Ow),t=i18n.isApplePlatform()?"toolbar.goToBookmarkShortcutApple":"toolbar.goToBookmarkShortcut";return jsxRuntime.jsx(ao,{slotId:"insert.goToBookmark",...e.isEnabled?{shortcutKey:t}:{}})}function Bw({className:e,hidden:t}){return jsxRuntime.jsx(ao,{slotId:"insert.bookmark",shortcutKey:"toolbar.bookmarkShortcut",...e?{className:e}:{},...t?{hidden:t}:{}})}var fs=Object.assign(Bw,{docxSlot:"insert.bookmark"});var qw=e=>e;function gs({labelKey:e,shortcutKey:t,className:o,hidden:n}){let r=A(),i=et(),a=Pe();if(W(qw),n)return null;let l=editor.toolbarCommandState(r,"text.link"),s=i18n.localizeDisabledReason(l.disabledReason,a),c=te("text.link"),d=r?.surface?.hyperlinks.linkAtCaret()!=null,m=a(e??(d?"hyperlinkPopup.editLink":"formattingBar.insertLink"));return jsxRuntime.jsx(De,{icon:oe(c?.paths),slot:"text.link",...t?{shortcut:a(t)}:{},disabled:!l.enabled,title:s??void 0,onSelect:()=>{i.setOpenMenu(null),editor.runToolbarCommand(r,"text.link");},...o?{className:o}:{},children:m})}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,m=e["data-value"],u=eo(),g=Zt.useId(),p=Zt.useContext(Kr),f=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:p,...l?{"data-slot":l}:{},...m!==void 0?{"data-value":m}:{},...i?{"data-active":""}:{},...n?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...f?{"aria-describedby":f}:{},...r?{title:r}:{},onMouseDown:$,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,f?jsxRuntime.jsx("span",{id:g,className:"docx-editor-sr-only",children:r}):null]})}function di({label:e,labelKey:t,className:o,hidden:n,children:r}){let i=Pe();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 hs(e){if(e.slotId)return e.slotId;if(e.slot)return Kg(e.slot),e.slot;Ug();}function ao(e){return (e.slotId??e.slot)==="text.link"?jsxRuntime.jsx(gs,{...e}):jsxRuntime.jsx(eD,{...e})}function eD(e){let{labelKey:t,shortcutKey:o,className:n,hidden:r}=e,i=hs(e)??"",{execute:a,isActive:l,isEnabled:s,disabledReason:c,value:d}=re(i),{setOpenMenu:m}=et(),u=Pe();if(r||!i)return null;let g=te(i),p=u(t??g?.labelKey??i),f=editor.chromeSlotIsToggle(i),b=["setAlignment","setParagraphDirection","setReviewDisplayMode"].includes(editor.commandForSlot(i)?.type??"");return jsxRuntime.jsx(De,{slot:i,icon:oe(g?.paths),...o?{shortcut:u(o)}:{},disabled:!s,...c?{title:c}:{},...f?{active:l}:{},...b?{selected:true}:{},...d!==null?{"data-value":d}:{},onSelect:()=>{a(),m(null);},...n?{className:n}:{},children:p})}ao.docxMenuRow=true;function ui(e,t,o,n,r=()=>true){return Object.assign(({className:a,hidden:l})=>{let s=et(),c=Pe(),d=n(s),m=o&&r(s)?o:void 0;if(l)return null;let u=te(e),g=c(t??u?.labelKey??e);return jsxRuntime.jsx(De,{slot:e,icon:oe(u?.paths),...m?{shortcut:c(m)}:{},disabled:!d,onSelect:()=>{d?.(),s.setOpenMenu(null);},...a?{className:a}:{},children:g})},{docxSlot:e})}var Zu=ui("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),Ku=ui("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave),qu=ui("file.exportMarkdown",void 0,void 0,e=>e.onExport?()=>e.onExport?.("markdown"):void 0),Uu=ui("file.exportPdf",void 0,void 0,e=>e.onExport?()=>e.onExport?.("pdf"):void 0),$u=ui("file.print",void 0,"toolbar.printShortcut",e=>e.onPrint,e=>e.printShortcut===true);function tD({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=re(editor.chromeProbeForSlot("file.pageSetup")),r=et(),i=Pe();if(t)return null;let a=te("file.pageSetup"),l=i(a?.labelKey??"file.pageSetup"),s=o&&!!r.onPageSetup;return jsxRuntime.jsx(De,{slot:"file.pageSetup",icon:oe(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onPageSetup?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}function oD({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=re(editor.chromeProbeForSlot("paragraph.dialog")),r=et(),i=Pe();if(t)return null;let a=te("paragraph.dialog"),l=i(a?.labelKey??"lineSpacing.options"),s=o&&!!r.onParagraphDialog;return jsxRuntime.jsx(De,{slot:"paragraph.dialog",icon:oe(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onParagraphDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var nD=Object.assign(oD,{docxSlot:"paragraph.dialog"}),zu=Object.assign(tD,{docxSlot:"file.pageSetup"});function rD({className:e,hidden:t}){let o=si(),n=et(),r=Pe();if(t)return null;let i=te("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 Vu=Object.assign(rD,{docxSlot:"image.insert"});function io({labelKey:e,label:t,paths:o,className:n,children:r}){let i=Pe(),[a,l]=Zt.useState(false),s=Zt.useRef(null),c=Zt.useRef(null),d=Zt.useId();t===void 0&&e===void 0&&$g();let m=t??i(e??""),[u,g]=Zt.useState(null);return Zt.useLayoutEffect(()=>{if(!a){g(null);return}let p=s.current,f=c.current,b=p?.ownerDocument.defaultView;!p||!f||!b||g(editor.placeSubmenu(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:b.innerWidth,height:b.innerHeight},b.getComputedStyle(p).direction==="rtl"));},[a]),jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__submenu${n?` ${n}`:""}`,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),onKeyDown:p=>{let f=editor.submenuKeys(editor.hostWindowOf(p.currentTarget).getComputedStyle(p.currentTarget).direction==="rtl");p.key===f.open&&editor.hostDocumentOf(s.current).activeElement===s.current?(p.preventDefault(),l(true),queueMicrotask(()=>{c.current&&ro(Jn(c.current),"first");})):(p.key===f.close||p.key==="Escape")&&a&&(p.preventDefault(),p.stopPropagation(),l(false),s.current?.focus());},onBlur:p=>{p.currentTarget.contains(p.relatedTarget)||l(false);},children:[jsxRuntime.jsxs("button",{ref:s,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?d:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...a?{"data-open":""}:{},onMouseDown:$,onFocus:()=>l(true),onClick:()=>l(true),children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:oe(o)}),jsxRuntime.jsx("span",{className:"docx-menubar__item-label",children:m}),jsxRuntime.jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),a?jsxRuntime.jsx("div",{ref:c,id:d,className:"docx-toolbar__menu docx-menubar__menu docx-menubar__submenu-panel",role:"menu","aria-label":m,style:u?{position:"fixed",left:u.left,top:u.top}:{position:"fixed",visibility:"hidden"},onKeyDown:p=>{let f=c.current;if(!f)return;let b=Jn(f);p.key==="ArrowDown"?(p.preventDefault(),p.stopPropagation(),no(b,editor.hostDocumentOf(f).activeElement,1)):p.key==="ArrowUp"&&(p.preventDefault(),p.stopPropagation(),no(b,editor.hostDocumentOf(f).activeElement,-1));},children:jsxRuntime.jsx(Kr.Provider,{value:-1,children:r})}):null]})}function aD({entry:e}){let{isEnabled:t}=re(e.slot),o=te(e.slot);return t?jsxRuntime.jsx(io,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsxRuntime.jsx(Vr,{slot:e.slot})}):jsxRuntime.jsx(ao,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Qn({className:e}){return jsxRuntime.jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function pi({entry:e,children:t}){return e.kind==="separator"?jsxRuntime.jsx(Qn,{}):e.kind==="submenu"?jsxRuntime.jsx(io,{labelKey:e.labelKey,paths:e.paths,children:t??e.items.map((o,n)=>jsxRuntime.jsx(pi,{entry:o},n))}):e.slot==="file.open"?jsxRuntime.jsx(Zu,{}):e.slot==="file.save"?jsxRuntime.jsx(Ku,{}):e.slot==="file.exportMarkdown"?jsxRuntime.jsx(qu,{}):e.slot==="file.exportPdf"?jsxRuntime.jsx(Uu,{}):e.slot==="file.print"?jsxRuntime.jsx($u,{}):e.slot==="file.pageSetup"?jsxRuntime.jsx(zu,{}):e.slot==="paragraph.dialog"?jsxRuntime.jsx(nD,{}):e.slot==="insert.watermark"?jsxRuntime.jsx(ms,{}):e.slot==="insert.bookmark"?jsxRuntime.jsx(fs,{}):e.slot==="insert.goToBookmark"?jsxRuntime.jsx(zb,{}):e.slot==="image.insert"?jsxRuntime.jsx(Vu,{}):e.picker==="tableGrid"?jsxRuntime.jsx(aD,{entry:e}):jsxRuntime.jsx(ao,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Xb(e){if(!Zt.isValidElement(e))return null;let t=Wr(e,Xb);if(t!==null)return t;let o=e.type;return typeof o!="function"&&typeof o!="object"?null:typeof o.docxSlot=="string"?o.docxSlot:o.docxMenuRow===true?hs(e.props)??null:null}function iD(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function jb(e,t,o){return es({entries:e??[],children:t,preset:o,keyOfEntry:iD,keyOfChild:Xb,childrenOfEntry:n=>n.kind==="submenu"?n.items:void 0,renderEntry:(n,r,i)=>jsxRuntime.jsx(pi,{entry:n,children:i})})}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,opening:m}=et(),u=wb(),g=Pe(),p=Zt.useId(),f=Zt.useRef(null),b=Zt.useRef(null),y=Zt.useRef(false),v=Zt.useRef(false),x=editor.CHROME_MENUS.find(w=>w.id===e),h=s===e,k=Fb(h&&e===Zr,f,b);if(i)return null;let E=o??g(t??x?.labelKey??e),C=Nb(u,e,d);if(C.skip)return null;if(C.asSubmenu)return jsxRuntime.jsx(io,{labelKey:t??x?.labelKey??e,label:E,children:jb(x?.entries,l,a)});let T=jb(x?.entries,l,a),S=C.iconOnly,P=()=>{c(null),f.current?.focus();};return jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__menu-root${r?` ${r}`:""}`,"data-menu":e,...C.rootAttributes,children:[jsxRuntime.jsxs("button",{ref:f,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":h,"aria-controls":h?p:void 0,className:"docx-menubar__trigger",disabled:m===true,tabIndex:C.tabStop?0:-1,...h?{"data-open":""}:{},...S?{"aria-label":E,title:E}:{},onMouseDown:$,onKeyDown:w=>{w.key==="ArrowDown"||w.key==="Enter"||w.key===" "||w.key==="ArrowUp"?(w.preventDefault(),y.current=true,c(e)):w.key==="Escape"&&h&&(w.preventDefault(),P());},onClick:()=>{if(v.current){v.current=false;return}c(h?null:e);},onMouseEnter:()=>{s!==null&&s!==e&&(v.current=true,c(e));},onMouseLeave:()=>{v.current=false;},children:[n?jsxRuntime.jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:n}):null,S?null:E]}),h?jsxRuntime.jsx("div",{ref:w=>{b.current=w,w&&y.current&&(y.current=false,ro(Jn(w),"first"));},id:p,role:"menu","aria-label":E,style:k,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:w=>{let _=b.current;if(!_)return;let L=Jn(_),N=editor.hostDocumentOf(_).activeElement;w.key==="ArrowDown"?(w.preventDefault(),no(L,N,1)):w.key==="ArrowUp"?(w.preventDefault(),no(L,N,-1)):w.key==="Home"?(w.preventDefault(),ro(L,"first")):w.key==="End"?(w.preventDefault(),ro(L,"last")):w.key==="Escape"?(w.preventDefault(),w.stopPropagation(),P()):w.key==="Tab"&&c(null);},children:jsxRuntime.jsx(Kr.Provider,{value:-1,children:T})}):null]})}function Gu(e){return Object.assign(o=>jsxRuntime.jsx(lo,{id:e,...o}),{docxMenu:e})}var ju=Gu("file"),Yu=Gu("format"),Xu=Gu("insert");var ys=Zt.createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function $o(){return Zt.useContext(ys)}function Qb(){return Zt.useContext(ys).target}var cD=e=>e.pageSetup??null,dD=e=>e.editable;function er(){let e=A(),t=W(cD),o=W(dD),n=Zt.useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),r=Zt.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 Zt.useMemo(()=>({pageSetup:t,isEnabled:n,apply:r}),[t,n,r])}var Qu=[{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}],rh=1440,mD=e=>Math.round(e/rh*100)/100,fD=e=>Math.round(e*rh);function gD(e,t){let o=Math.min(e,t),n=Math.max(e,t);return Qu.findIndex(r=>Math.abs(r.width-o)<20&&Math.abs(r.height-n)<20)}var oh=12240,nh=15840,xn=1440;function bD({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=Co(e,t),{pageSetup:s,isEnabled:c,apply:d}=er(),[m,u]=Zt.useState(oh),[g,p]=Zt.useState(nh),[f,b]=Zt.useState("portrait"),[y,v]=Zt.useState(xn),[x,h]=Zt.useState(xn),[k,E]=Zt.useState(xn),[C,T]=Zt.useState(xn),[S,P]=Zt.useState(false),[w,_]=Zt.useState("document"),L=Zt.useRef(null),N=Zt.useRef("no");Zt.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||(P(false),u(s?.pageWidthTwips??oh),p(s?.pageHeightTwips??nh),b(s?.orientation??"portrait"),v(s?.marginsTwips.top??xn),h(s?.marginsTwips.bottom??xn),E(s?.marginsTwips.left??xn),T(s?.marginsTwips.right??xn),_("document"),N.current=s===null?"loading":"yes");},[e,s]);let B=Zt.useCallback(q=>{let X=Qu[q];X&&(u(f==="landscape"?X.height:X.width),p(f==="landscape"?X.width:X.height));},[f]),F=Zt.useCallback(q=>{q!==f&&(b(q),u(g),p(m));},[f,m,g]),D=Zt.useCallback(()=>{if(!c)return;if(!l()){t();return}let q=d({pageWidthTwips:m,pageHeightTwips:g,orientation:f,marginTopTwips:y,marginRightTwips:C,marginBottomTwips:x,marginLeftTwips:k,scope:w});P(!q),q&&t();},[c,l,d,m,g,f,y,C,x,k,w,t]);if(!e)return null;let R=gD(m,g),U=(q,X,ee)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":`margin${q[0].toUpperCase()}${q.slice(1)}`,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a(`dialogs.pageSetup.${q}`)}),jsxRuntime.jsx("input",{type:"number",className:"docx-dialog__input",min:0,max:22,step:.1,value:mD(X),onChange:O=>ee(Math.max(0,fD(Number(O.target.value)||0))),"aria-label":a(`dialogs.pageSetup.${q}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),V={pageWidth:m,pageHeight:g,orientation:f,marginTop:y,marginBottom:x,marginLeft:k,marginRight:C,scope:w},Y={pageWidth:u,pageHeight:p,orientation:F,marginTop:v,marginBottom:h,marginLeft:E,marginRight:T,scope:_},j={values:V,setValue(q,X){Y[q](X);},errors:S?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:D,cancel:t};return jsxRuntime.jsx(Fe,{kind:"pageSetup",className:o,style:n,panelRef:L,label:a("dialogs.pageSetup.title"),onClose:t,onKeyDown:q=>{q.key==="Escape"&&t(),q.key==="Enter"&&editor.isHTMLElementNode(q.target)&&q.target.localName==="input"&&c&&(q.preventDefault(),D());},children:jsxRuntime.jsx(wo.Composition,{state:j,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:R,onChange:q=>B(Number(q.target.value)),"aria-label":a("dialogs.pageSetup.sizeLabel"),children:[Qu.map((q,X)=>jsxRuntime.jsx("option",{value:X,children:a(q.labelKey)},q.labelKey)),R<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:f,onChange:q=>F(q.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")}),U("top",y,v),U("bottom",x,h),U("left",k,E),U("right",C,T),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:q=>_(q.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:S?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:D,children:a("common.apply")})]})]}),children:r})})}var wo=yt();function hD(){return wo.useState()}var tr=Object.assign(bD,{Header:wo.Header,Title:wo.Title,Body:wo.Body,Footer:wo.Footer,Apply:wo.Apply,Cancel:wo.Cancel,Error:wo.Error,Field:wo.Field});var vD={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},CD=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,n=t.paragraphFlags??vD;return {alignment:t.alignment==="both"?"justify":t.alignment??null,direction:t.direction??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,direction:t.disagrees?.direction??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}}},TD=["alignment","direction","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],ED=(e,t)=>TD.every(o=>e.disagrees[o]===t.disagrees[o]),SD=(e,t)=>e===null||t===null?e===t:e.alignment===t.alignment&&e.direction===t.direction&&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&&ED(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")),PD=e=>e.editable,kD={type:"setParagraphFormat",alignment:"left"};function ep(){let e=A(),t=W(CD,SD),o=W(PD),{isEnabled:n}=re(kD),r=o&&n,i=Zt.useCallback(a=>{if(!e)return false;let l={type:"setParagraphFormat",...a};return e.can(l).ok?e.exec(l).ok:false},[e]);return {format:t,isEnabled:r,apply:i}}function RD({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=Co(e,t),{format:s,isEnabled:c,apply:d}=ep(),[m,u]=Zt.useState("left"),[g,p]=Zt.useState("ltr"),[f,b]=Zt.useState(0),[y,v]=Zt.useState(0),[x,h]=Zt.useState("none"),[k,E]=Zt.useState(0),[C,T]=Zt.useState(0),[S,P]=Zt.useState(0),[w,_]=Zt.useState("multiple"),[L,N]=Zt.useState(1.08),[B,F]=Zt.useState(false),[D,R]=Zt.useState(false),[U,V]=Zt.useState(false),[Y,j]=Zt.useState(true),[q,X]=Zt.useState(false),[ee,O]=Zt.useState([]),[I,ie]=Zt.useState(false),[ge,K]=Zt.useState(0),[de,ke]=Zt.useState("left"),[Ze,at]=Zt.useState("none"),[Ce,Ye]=Zt.useState(editor.NO_MIXED_FIELDS),[Wn,wt]=Zt.useState(false),qt=z=>a(Wn&&(z==="indentLeft"||z==="indentRight"||z==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),Zn=Zt.useRef(editor.NO_MIXED_FIELDS),se=Zt.useId(),[Ge,Ie]=Zt.useState(false),Kn=Zt.useRef(null),xo=Zt.useRef(false),Qt=Zt.useRef(null);Zt.useEffect(()=>{if(!e){xo.current=false;return}if(xo.current||s===null)return;let z=editor.seedFields(s);u(z.alignment),p(z.direction),b(z.indentLeft),v(z.indentRight),h(z.special),E(z.specialBy),T(z.spaceBefore),P(z.spaceAfter),_(z.lineRule),N(z.lineValue),F(z.contextualSpacing),R(z.keepNext),V(z.keepLines),j(z.widowControl),X(z.pageBreakBefore),O(z.tabStops),ie(false);let xe=editor.mixedFieldsOf(s);Ye(xe),wt(s.indentUnknown),K(0),ke("left"),at("none"),Zn.current=xe,Ie(false),Qt.current=z,xo.current=true;},[e,s]);let vo=Zt.useCallback(()=>{if(!c)return;if(!l()){t();return}let z=Qt.current,xe=z===null?null:editor.changedFields(z,{alignment:m,direction:g,indentLeft:f,indentRight:y,special:x,specialBy:k,spaceBefore:C,spaceAfter:S,lineRule:w,lineValue:L,contextualSpacing:B,keepNext:D,keepLines:U,widowControl:Y,pageBreakBefore:q,tabStops:ee,clearedAllTabStops:I},Zn.current,Ce);if(xe===null){t();return}if(d(xe)){Ie(false),t();return}Ie(true);},[c,l,d,t,Ce,I,m,g,f,y,x,k,C,S,w,L,B,D,U,Y,q,ee]),an=Zt.useCallback(()=>{let z=Math.round(ge);return z<=0?false:(Ye(xe=>({...xe,tabStops:false})),O(editor.withTabStop(ee,{positionTwips:z,alignment:de,...Ze!=="none"?{leader:Ze}:{}})),K(0),ke("left"),at("none"),true)},[ee,ge,de,Ze]);if(!e)return null;let Ht=z=>Ye(xe=>({...xe,[z]:false})),ce=(z,xe,cn,ht)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":ht,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("input",{id:`${se}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Ce[ht]?"":editor.twipsToInches(xe),placeholder:Ce[ht]?qt(ht):void 0,onChange:Wa=>{Ht(ht),cn(editor.inchesToTwips(Number(Wa.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),be=(z,xe,cn,ht)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("input",{id:`${se}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:Ce[ht]?"":xe,placeholder:Ce[ht]?qt(ht):void 0,onChange:Wa=>{Ht(ht),cn(Math.max(0,Number(Wa.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),Ne=(z,xe,cn)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:xe,ref:ht=>{ht&&(ht.indeterminate=Ce[z]);},onChange:ht=>{Ye(Wa=>({...Wa,[z]:false})),cn(ht.target.checked);}}),a(`dialogs.paragraph.${z}`)]}),Se={alignment:m,direction:g,indentLeft:f,indentRight:y,special:x,specialBy:k,spaceBefore:C,spaceAfter:S,lineRule:w,lineValue:L,contextualSpacing:B,keepNext:D,keepLines:U,widowControl:Y,pageBreakBefore:q,tabStops:ee,clearedAllTabStops:I},Et=z=>{let xe=Zn.current;z!==g&&!xe.direction&&!xe.alignment&&u(editor.alignmentAfterDirectionChange),p(z);},ln={alignment:u,direction:Et,indentLeft:b,indentRight:v,special:h,specialBy:E,spaceBefore:T,spaceAfter:P,lineRule:_,lineValue:N,contextualSpacing:F,keepNext:R,keepLines:V,widowControl:j,pageBreakBefore:X,tabStops:O,clearedAllTabStops:ie},sn={values:Se,mixed:Ce,setValue(z,xe){ln[z](xe),z==="lineRule"?(Ht("lineSpacing"),N(xe===Qt.current?.lineRule?Qt.current.lineValue:xe==="multiple"?1.08:12)):z==="specialBy"?Ht("special"):z in Ce&&Ht(z);},errors:Ge?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:vo,cancel:t};return jsxRuntime.jsx(Fe,{kind:"paragraph",className:o,style:n,panelRef:Kn,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:z=>{z.key==="Escape"&&t();let xe=editor.isHTMLElementNode(z.target)&&(z.target.localName==="button"||z.target.localName==="select");if(z.key==="Enter"&&!xe){let cn=z.target;if(editor.isHTMLElementNode(cn)&&cn.dataset.docxTabEntry!==void 0){an();return}c&&vo();}},children:jsxRuntime.jsx(Do.Composition,{state:sn,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:`${se}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxRuntime.jsxs("select",{id:`${se}-alignment`,className:"docx-dialog__input",value:Ce.alignment?"":m,onChange:z=>{Ht("alignment"),u(z.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[Ce.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.jsxs("div",{"data-docx-part":"field","data-docx-field":"direction",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-direction`,children:a("dialogs.paragraph.direction")}),jsxRuntime.jsxs("select",{id:`${se}-direction`,className:"docx-dialog__input",value:Ce.direction?"":g,onChange:z=>{Ht("direction"),Et(z.target.value);},"aria-label":a("dialogs.paragraph.direction"),children:[Ce.direction?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"rtl",children:a("dialogs.paragraph.directionRtl")}),jsxRuntime.jsx("option",{value:"ltr",children:a("dialogs.paragraph.directionLtr")})]})]}),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.indentation")}),ce("beforeText",f,b,"indentLeft"),ce("afterText",y,v,"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:`${se}-special`,children:a("dialogs.paragraph.special")}),jsxRuntime.jsxs("select",{id:`${se}-special`,className:"docx-dialog__input",value:Ce.special?"":x,onChange:z=>{Ht("special"),h(z.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[Ce.special?jsxRuntime.jsx("option",{value:"",children:qt("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")})]})]}),x!=="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:`${se}-by`,children:a("dialogs.paragraph.by")}),jsxRuntime.jsx("input",{id:`${se}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Ce.special?"":editor.twipsToInches(k),placeholder:Ce.special?qt("special"):void 0,onChange:z=>{Ht("special"),E(Math.max(0,editor.inchesToTwips(Number(z.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")}),ee.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__note",children:a(Ce.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):ee.map(z=>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(z.positionTwips)})}),jsxRuntime.jsx("span",{className:"docx-dialog__tab-description",children:a(editor.TAB_ALIGNMENT_LABELS[z.alignment])}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>O(ee.filter(xe=>xe!==z)),"aria-label":a("dialogs.paragraph.tabRemoveAt",{position:editor.formatInches(z.positionTwips)}),children:a("dialogs.paragraph.tabRemove")})]},z.positionTwips)),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsxRuntime.jsx("input",{id:`${se}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:editor.twipsToInches(ge),onChange:z=>K(Math.max(0,editor.inchesToTwips(Number(z.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:`${se}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxRuntime.jsxs("select",{id:`${se}-tabAlignment`,className:"docx-dialog__input",value:de,onChange:z=>ke(z.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:`${se}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxRuntime.jsxs("select",{id:`${se}-tabLeader`,className:"docx-dialog__input",value:Ze,onChange:z=>at(z.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:an,children:a("dialogs.paragraph.tabAdd")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{Ye(z=>({...z,tabStops:false})),ie(true),O([]);},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")}),be("spaceBefore",C,T,"spaceBefore"),be("spaceAfter",S,P,"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:`${se}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxRuntime.jsxs("select",{id:`${se}-lineSpacing`,className:"docx-dialog__input",value:Ce.lineSpacing?"":w,onChange:z=>{let xe=z.target.value;Ht("lineSpacing"),_(xe),N(xe===Qt.current?.lineRule?Qt.current.lineValue:xe==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[Ce.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:`${se}-at`,children:a("dialogs.paragraph.at")}),jsxRuntime.jsx("input",{id:`${se}-at`,type:"number",className:"docx-dialog__input",min:.01,step:w==="multiple"?.01:1,value:Ce.lineSpacing?"":L,disabled:Ce.lineSpacing,onChange:z=>{let xe=z.target.value.trim();N(xe===""?w==="multiple"?1.08:12:Number(xe)||0);},"aria-label":a("dialogs.paragraph.at")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:w==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),Ne("contextualSpacing",B,F),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),Ne("keepNext",D,R),Ne("widowControl",Y,j),Ne("keepLines",U,V),Ne("pageBreakBefore",q,X)]})]})}),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:Ge?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:vo,children:a("dialogs.paragraph.ok")})]})]}),children:r})})}var Do=yt();function MD(){return Do.useState()}var Vo=Object.assign(RD,{Header:Do.Header,Title:Do.Title,Body:Do.Body,Footer:Do.Footer,Apply:Do.Apply,Cancel:Do.Cancel,Error:Do.Error,Field:Do.Field});var so=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var np=["ASAP","CONFIDENTIAL","COPY","DO NOT COPY","DRAFT","ORIGINAL","PERSONAL","SAMPLE","TOP SECRET","URGENT"],rp=[null,.5,1,1.5,2,5],ap=[null,36,40,44,48,54,60,66,72,80,90,96,105,120,144],hh="image/png,image/jpeg,image/gif,image/bmp,image/webp",ip={kind:"none",imageData:null,imageName:null,scale:null,washout:true,text:"DRAFT",fontFamily:"Calibri",fontSizePt:null,bold:false,italic:false,transparency:.5,color:"C0C0C0",layout:"diagonal"},Ts=/^[0-9A-Fa-f]{6}$/;function yh(e,t){let o={...ip};return e?e.kind==="image"?{...o,kind:t?.imageData?"picture":"none",imageData:t?.imageData??null,scale:t?.scale??null,washout:e.washout??t?.washout??true}:{...o,kind:"text",text:e.text??o.text,fontFamily:e.fontFamily??o.fontFamily,fontSizePt:e.fontSizePt??null,bold:e.bold??false,italic:e.italic??false,transparency:e.transparency??o.transparency,color:e.color&&Ts.test(e.color)?e.color.toUpperCase():o.color,layout:e.layout??o.layout}:o}function xh(e){if(e.kind==="none")return null;if(e.kind==="picture")return e.imageData?{imageData:e.imageData,scale:e.scale,washout:e.washout}:void 0;if(e.text.trim()!=="")return {text:e.text,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,color:e.color,transparency:e.transparency,layout:e.layout}}var vh=e=>`#${Ts.test(e)?e.toLowerCase():"c0c0c0"}`;function Ch(e){let t=e.startsWith("#")?e.slice(1):e;return Ts.test(t)?t.toUpperCase():null}var lp=e=>Math.round(Math.min(1,Math.max(0,e))*100);function sp(e,t){let o=Number(e);return e.trim()===""||!Number.isFinite(o)?t:Math.min(100,Math.max(0,Math.round(o)))/100}function Th(e,t){return e===t?true:!e||!t?false:e.kind===t.kind&&e.text===t.text&&e.fontFamily===t.fontFamily&&e.fontSizePt===t.fontSizePt&&e.bold===t.bold&&e.italic===t.italic&&e.color===t.color&&e.transparency===t.transparency&&e.layout===t.layout&&e.washout===t.washout}function Eh(e,t){return e!==null&&t.kind==="none"?null:t}function Sh(e,t){return e.kind!==t.kind?false:e.kind==="none"?true:e.kind==="picture"?e.imageData===t.imageData&&e.scale===t.scale&&e.washout===t.washout:e.text===t.text&&e.fontFamily===t.fontFamily&&e.fontSizePt===t.fontSizePt&&e.bold===t.bold&&e.italic===t.italic&&e.color.toUpperCase()===t.color.toUpperCase()&&e.transparency===t.transparency&&e.layout===t.layout}var Ph=(e,t)=>t.includes(e)?e:"",ID={pageWidthTwips:12240,pageHeightTwips:15840,marginsTwips:{top:1440,right:1440,bottom:1440,left:1440}};function Es(e){let t=e&&e.pageWidthTwips>0&&e.pageHeightTwips>0?e:null,{pageWidthTwips:o,pageHeightTwips:n,marginsTwips:r}=t??ID,i=o/20,a=n/20,l=Math.max(72,(o-r.left-r.right)/20),s=Math.max(72,(n-r.top-r.bottom)/20);return {width:i,height:a,area:{x:r.left/20,y:r.top/20,width:l,height:s}}}var mh=12,fh=[.55,1,1,.9,0,1,1,.6,0,1,.95,1,.45];function kh(e){let{area:t}=e,o=36,n=[];for(let r=0,i=t.y;i+mh<=t.y+t.height;r++){let a=fh[r%fh.length];a>0&&n.push({x:t.x,y:i,width:t.width*a,height:mh}),i+=o;}return n}var wh="contrast(0.157068) brightness(1.91)",cp=100,Go=e=>Math.round(e*100)/100,Dh=e=>({cx:e.area.x+e.area.width/2,cy:e.area.y+e.area.height/2});function Rh(e,t=Es(null)){if(e.kind!=="text")return null;let o=e.text.trim();if(o==="")return null;let n=editor.watermarkShapeBox({text:o,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,layout:e.layout},t.area);if(!n)return null;let{cx:r,cy:i}=Dh(t);return {text:o,fontFamily:`"${e.fontFamily.replace(/["\\]/g,"")}", sans-serif`,fontWeight:e.bold?"bold":"normal",fontStyle:e.italic?"italic":"normal",fill:`#${Ts.test(e.color)?e.color.toUpperCase():"C0C0C0"}`,opacity:Go(1-Math.min(1,Math.max(0,e.transparency))),box:{x:Go(r-n.width/2),y:Go(i-n.height/2),width:Go(n.width),height:Go(n.height)},rotation:e.layout==="diagonal"?-45:0}}var gh=new WeakMap;function ND(e){if(!e)return null;let t=gh.get(e);if(t===void 0){try{t=e.createElement("canvas").getContext("2d");}catch{t=null;}gh.set(e,t);}return t}function Mh(e,t){let o=cp,n=ND(t);if(n){n.font=`${e.fontStyle} ${e.fontWeight} ${o}px ${e.fontFamily}`;let r=n.measureText(e.text),i=-(r.actualBoundingBoxLeft??0),a=r.actualBoundingBoxRight??r.width,l=-(r.actualBoundingBoxAscent??0),s=r.actualBoundingBoxDescent??0;if(a>i&&s>l)return {left:i,right:a,top:l,bottom:s}}return {left:0,right:.55*o*Array.from(e.text).length,top:-0.7*o,bottom:0}}function _h(e,t){let{x:o,y:n,width:r,height:i}=e.box,a=r>4*7.2?7.2:0,l=i>4*3.6?3.6:0,s=(r-2*a)/(t.right-t.left),c=(i-2*l)/(t.bottom-t.top),d=o+a-t.left*s,m=n+l-t.top*c,u=p=>String(Math.round(p*1e4)/1e4),g=`matrix(${u(s)} 0 0 ${u(c)} ${u(d)} ${u(m)})`;return e.rotation?`rotate(${e.rotation} ${u(o+r/2)} ${u(n+i/2)}) ${g}`:g}function Ih(e,t=Es(null)){if(e.kind!=="picture"||!e.imageData)return null;let o=editor.watermarkShapeBox({imageData:e.imageData,scale:e.scale},t.area);if(!o)return null;let{cx:n,cy:r}=Dh(t);return {x:Go(n-o.width/2),y:Go(r-o.height/2),width:Go(o.width),height:Go(o.height)}}var FD=e=>e.editable,LD={ok:false,code:"unsupported",reason:"editor is not ready"};function up(){let e=A(),t=Zt.useCallback(l=>e?.getWatermark()??null,[e]),o=W(t,Th),n=W(FD),r=Zt.useMemo(()=>n&&e!==null&&e.can({type:"setWatermark",watermark:{text:"DRAFT"}}).ok,[e,n]),i=Zt.useCallback(()=>e?.query({type:"watermark"})??null,[e]),a=Zt.useCallback(l=>e?e.exec({type:"setWatermark",watermark:l}):LD,[e]);return Zt.useMemo(()=>({watermark:o,isEnabled:r,read:i,apply:a}),[o,r,i,a])}var WD=e=>e.pageSetup??null,co=yt(),ZD=co.part("preview");function Hh(){return co.useState()}var Fh=e=>`${Math.round(e*100)}%`;function KD(e){let[t,o]=Zt.useState(null);return Zt.useEffect(()=>{if(!e||typeof URL.createObjectURL!="function"){o(null);return}let n=URL.createObjectURL(new Blob([e]));return o(n),()=>URL.revokeObjectURL(n)},[e]),t}function qD({className:e,style:t,"data-docx-part":o,...n}){let{values:r}=Hh(),i=A(),a=W(WD),l=Zt.useMemo(()=>Es(a),[a]),s=KD(r.kind==="picture"?r.imageData:null),c=Rh(r,l),d=s?Ih(r,l):null;return jsxRuntime.jsx("div",{...n,"data-docx-part":"preview","aria-hidden":"true",className:["docx-dialog__preview",e].filter(Boolean).join(" "),style:t,children:jsxRuntime.jsxs("svg",{className:"docx-dialog__preview-page",viewBox:`0 0 ${l.width} ${l.height}`,focusable:"false",children:[jsxRuntime.jsx("rect",{className:"docx-dialog__preview-sheet",x:0,y:0,width:l.width,height:l.height}),c?jsxRuntime.jsx("text",{"data-docx-watermark-preview":"text",x:0,y:0,fontFamily:c.fontFamily,fontSize:cp,fontWeight:c.fontWeight,fontStyle:c.fontStyle,fill:c.fill,fillOpacity:c.opacity,transform:_h(c,Mh(c,i?editor.editorHostDocument(i):null)),children:c.text}):null,s&&d?jsxRuntime.jsx("image",{"data-docx-watermark-preview":"picture",className:"docx-dialog__preview-picture",href:s,x:d.x,y:d.y,width:d.width,height:d.height,preserveAspectRatio:"none",style:r.washout?{filter:wh}:void 0}):null,kh(l).map(m=>jsxRuntime.jsx("rect",{className:"docx-dialog__preview-line",x:m.x,y:m.y,width:m.width,height:m.height},m.y))]})})}function UD({open:e,onClose:t,presets:o=np,className:n,style:r,children:i,preset:a=true}){let{t:l}=H(),s=A(),c=Co(e,t),{isEnabled:d,read:m,apply:u}=up(),g=W(so),[p,f]=Zt.useState({...ip}),[b,y]=Zt.useState([]),[v,x]=Zt.useState(null),[h,k]=Zt.useState(false),[E,C]=Zt.useState(0),T=Zt.useRef(null),S=Zt.useRef(null),P=Zt.useRef(null),w=Zt.useId(),_=Zt.useRef(false);Zt.useEffect(()=>{if(!e||g||!s){_.current=false;return}if(_.current)return;_.current=true;let I=s.getWatermark(),ie=yh(I,m());T.current=Eh(I,ie),f(ie),y(s.getAvailableFonts()),x(null),k(false),C(ge=>ge+1);},[e,g,s,m]),Zt.useEffect(()=>{E!==0&&S.current?.querySelector(`input[name="${w}-kind"]:checked`)?.focus({preventScroll:true});},[E,w]);let L=Zt.useCallback((I,ie)=>{x(null),f(ge=>({...ge,[I]:ie}));},[]),N=xh(p),B=d&&N!==void 0,F=Zt.useCallback(()=>{if(!B||N===void 0)return;if(!c()){t();return}if(T.current&&Sh(T.current,p)){t();return}let I=u(N);I.ok?t():x(I.reason);},[B,N,p,c,u,t]),D=Zt.useCallback(I=>{I&&(k(false),I.arrayBuffer().then(ie=>{f(ge=>({...ge,kind:"picture",imageData:new Uint8Array(ie),imageName:I.name})),x(null);}).catch(()=>k(true)));},[]);if(!e)return null;let R=p.kind==="picture",U=p.kind==="text",V=b.includes(p.fontFamily)?b:[p.fontFamily,...b],Y=p.imageData?p.imageName??l("dialogs.watermark.currentPicture"):l("dialogs.watermark.noPictureSelected"),j=v!==null?l("dialogs.watermark.refused"):null,q=(I,ie,ge)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":I,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${w}-kind`,checked:p.kind===ie,onChange:()=>L("kind",ie)}),jsxRuntime.jsx("span",{id:`${w}-${I}-label`,children:ge})]}),X=(I,ie,ge)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":I,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${w}-${I}`,children:ie}),ge]}),ee=(I,ie,ge)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":I,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",disabled:!ge,checked:p[I],onChange:K=>L(I,K.target.checked)}),jsxRuntime.jsx("span",{children:ie})]}),O={values:p,setValue:L,errors:j?{form:j}:{},isEnabled:B,apply:F,cancel:t};return jsxRuntime.jsx(Fe,{kind:"watermark",className:n,style:r,panelRef:S,label:l("dialogs.watermark.title"),onClose:t,onKeyDown:I=>{let ie=I.target;I.key==="Enter"&&editor.isHTMLElementNode(ie)&&ie.localName==="input"&&(ie.type==="text"||ie.type==="number")&&B&&(I.preventDefault(),F());},children:jsxRuntime.jsx(co.Composition,{state:O,preset:a,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:l("dialogs.watermark.title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxRuntime.jsxs("div",{className:"docx-dialog__watermark-layout",children:[jsxRuntime.jsx(qD,{"data-docx-part":"preview"}),jsxRuntime.jsxs("fieldset",{className:"docx-dialog__fieldset",children:[jsxRuntime.jsx("legend",{className:"docx-editor-sr-only",children:l("dialogs.watermark.kind")}),q("noWatermark","none",l("dialogs.watermark.noWatermark")),q("pictureWatermark","picture",l("dialogs.watermark.picture")),jsxRuntime.jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${w}-pictureWatermark-label`,children:[jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"picture",className:"docx-dialog__row",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{L("kind","picture"),P.current?.click();},children:l("dialogs.watermark.selectPicture")}),jsxRuntime.jsx("span",{className:"docx-dialog__hint","data-docx-watermark-picture":"",children:h?l("dialogs.watermark.pictureFailed"):Y}),jsxRuntime.jsx("input",{ref:P,type:"file",accept:hh,hidden:true,"aria-label":l("dialogs.watermark.selectPicture"),onChange:I=>{let ie=I.target.files?.[0];I.target.value="",D(ie);}})]}),X("scale",l("dialogs.watermark.scale"),jsxRuntime.jsxs("select",{id:`${w}-scale`,className:"docx-dialog__select",disabled:!R,value:p.scale===null?"auto":String(p.scale),onChange:I=>L("scale",I.target.value==="auto"?null:Number(I.target.value)),children:[rp.map(I=>jsxRuntime.jsx("option",{value:I===null?"auto":String(I),children:I===null?l("dialogs.watermark.auto"):Fh(I)},String(I))),p.scale!==null&&!rp.includes(p.scale)?jsxRuntime.jsx("option",{value:String(p.scale),children:Fh(p.scale)}):null]})),ee("washout",l("dialogs.watermark.washout"),R)]}),q("textWatermark","text",l("dialogs.watermark.text")),jsxRuntime.jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${w}-textWatermark-label`,children:[X("preset",l("dialogs.watermark.preset"),jsxRuntime.jsxs("select",{id:`${w}-preset`,className:"docx-dialog__select",disabled:!U,value:Ph(p.text,o),onChange:I=>{I.target.value!==""&&L("text",I.target.value);},children:[jsxRuntime.jsx("option",{value:"",children:l("dialogs.watermark.custom")}),o.map(I=>jsxRuntime.jsx("option",{value:I,children:I},I))]})),X("text",l("dialogs.watermark.textLabel"),jsxRuntime.jsx("input",{id:`${w}-text`,type:"text",className:"docx-dialog__input",disabled:!U,maxLength:256,value:p.text,onChange:I=>L("text",I.target.value)})),X("fontFamily",l("dialogs.watermark.font"),jsxRuntime.jsx("select",{id:`${w}-fontFamily`,className:"docx-dialog__select",disabled:!U,value:p.fontFamily,onChange:I=>L("fontFamily",I.target.value),children:V.map(I=>jsxRuntime.jsx("option",{value:I,children:I},I))})),X("fontSizePt",l("dialogs.watermark.size"),jsxRuntime.jsxs("select",{id:`${w}-fontSizePt`,className:"docx-dialog__select",disabled:!U,value:p.fontSizePt===null?"auto":String(p.fontSizePt),onChange:I=>L("fontSizePt",I.target.value==="auto"?null:Number(I.target.value)),children:[ap.map(I=>jsxRuntime.jsx("option",{value:I===null?"auto":String(I),children:I===null?l("dialogs.watermark.auto"):String(I)},String(I))),p.fontSizePt!==null&&!ap.includes(p.fontSizePt)?jsxRuntime.jsx("option",{value:String(p.fontSizePt),children:p.fontSizePt}):null]})),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[ee("bold",l("dialogs.watermark.bold"),U),ee("italic",l("dialogs.watermark.italic"),U)]}),X("transparency",l("dialogs.watermark.transparency"),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("input",{type:"range",className:"docx-dialog__range",min:0,max:100,step:1,disabled:!U,"aria-label":l("dialogs.watermark.transparency"),value:lp(p.transparency),onChange:I=>L("transparency",sp(I.target.value,p.transparency))}),jsxRuntime.jsx("input",{id:`${w}-transparency`,type:"number",className:"docx-dialog__input docx-dialog__input--narrow",min:0,max:100,step:1,disabled:!U,value:lp(p.transparency),onChange:I=>L("transparency",sp(I.target.value,p.transparency))}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:"%"})]})),X("color",l("dialogs.watermark.color"),jsxRuntime.jsx("input",{id:`${w}-color`,type:"color",className:"docx-dialog__color",disabled:!U,value:vh(p.color),onChange:I=>{let ie=Ch(I.target.value);ie&&L("color",ie);}})),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"layout",className:"docx-dialog__row",role:"radiogroup","aria-label":l("dialogs.watermark.layout"),children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:l("dialogs.watermark.layout")}),["diagonal","horizontal"].map(I=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${w}-layout`,disabled:!U,checked:p.layout===I,onChange:()=>L("layout",I)}),jsxRuntime.jsx("span",{children:l(`dialogs.watermark.${I}`)})]},I))]})]})]})]})}),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",...v?{title:v}:{},children:j}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:l("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!B,"data-docx-part":"apply",onClick:F,children:l("common.apply")})]})]}),children:i})})}var or=Object.assign(UD,{Header:co.Header,Title:co.Title,Body:co.Body,Preview:ZD,Footer:co.Footer,Apply:co.Apply,Cancel:co.Cancel,Error:co.Error,Field:co.Field});var Ps={ok:false,code:"unsupported",reason:"editor is not ready"},zD=Object.freeze([]);function fp(e,t){return e.length===t.length&&e.every((o,n)=>o.name===t[n].name&&o.order===t[n].order&&o.story===t[n].story&&o.empty===t[n].empty&&o.atSelection===t[n].atSelection&&o.duplicates===t[n].duplicates&&o.hidden===t[n].hidden&&o.place===t[n].place)}function gp(){let e=A(),t=Zt.useCallback(c=>e?.query({type:"bookmarks"})??zD,[e]),o=W(t,fp),n=Zt.useCallback(c=>c.editable&&e!==null&&e.can({type:"insertBookmark",name:"Bookmark"}).ok,[e]),r=W(n),i=Zt.useCallback(c=>e?e.exec({type:"insertBookmark",name:c}):Ps,[e]),a=Zt.useCallback(c=>e?e.exec({type:"deleteBookmark",name:c}):Ps,[e]),l=Zt.useCallback(c=>e?e.exec({type:"goToBookmark",name:c}):Ps,[e]),s=Zt.useCallback(c=>e?e.exec({type:"keepFirstBookmark",name:c}):Ps,[e]);return Zt.useMemo(()=>({bookmarks:o,isWritable:r,insert:i,remove:a,goTo:l,keepFirst:s}),[o,r,i,a,l,s])}var Oh={empty:"dialogs.bookmark.nameEmpty",tooLong:"dialogs.bookmark.nameTooLong",invalidStart:"dialogs.bookmark.nameInvalidStart",invalidCharacter:"dialogs.bookmark.nameInvalidCharacter"};function JD(e){return e.open?jsxRuntime.jsx(QD,{...e}):null}function QD({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=Co(e,t),{bookmarks:s,isWritable:c,insert:d,remove:m,goTo:u,keepFirst:g}=gp(),[p,f]=Zt.useState(()=>editor.bookmarkDialogInitialName(s)),[b,y]=Zt.useState("name"),[v,x]=Zt.useState(false),[h,k]=Zt.useState(false),[E,C]=Zt.useState(false),[T,S]=Zt.useState(false),P=Zt.useRef(null),w=Zt.useRef(null),_=Zt.useId(),L=Zt.useId(),N=Zt.useId(),B=editor.bookmarkDialogRows(s,{sortBy:b,showHidden:v}),F=editor.bookmarkDialogNameState(s,p,c),D=F.problem&&!F.existing&&(E||p.length>0)?F.problem:null,R=F.existing?.duplicates??0,U=h?a("dialogs.bookmark.refused"):D?a(Oh[D]):R>0?a("dialogs.bookmark.duplicates",{count:R}):F.existing&&F.canAdd?a("dialogs.bookmark.nameExists"):null,V=Zt.useCallback(()=>{if(C(true),!F.canAdd)return;if(!l()){t();return}let O=d(p);k(!O.ok),O.ok&&t();},[F.canAdd,l,d,p,t]),Y=Zt.useCallback(()=>{if(!F.canDelete||!F.existing)return;let O=m(F.existing.name);k(!O.ok),O.ok&&f("");},[F,m]),j=Zt.useCallback(()=>{if(!F.canGoTo||!F.existing)return;let O=u(F.existing.name);k(!O.ok),O.ok&&S(true);},[F,u]),q=Zt.useCallback(()=>{let O=F.existing;!O||!c||k(!g(O.name).ok);},[F.existing,c,g]),X=F.existing?.name??"";Zt.useLayoutEffect(()=>{!X&&w.current&&(w.current.selectedIndex=-1);});let ee={values:{name:p,sortBy:b,showHidden:v},setValue(O,I){O==="name"?f(I):O==="sortBy"?y(I):x(I),k(false);},errors:D?{name:a(Oh[D])}:h?{form:a("dialogs.bookmark.refused")}:{},isEnabled:F.canAdd,apply:V,cancel:t,rows:B,canDelete:F.canDelete,canGoTo:F.canGoTo,duplicates:R,remove:Y,goTo:j,keepFirst:q};return jsxRuntime.jsx(Fe,{kind:"bookmark",className:o,style:n,panelRef:P,label:a("dialogs.bookmark.title"),onClose:t,onKeyDown:O=>{O.key==="Enter"&&!O.nativeEvent.isComposing&&O.keyCode!==229&&editor.isHTMLElementNode(O.target)&&O.target.localName==="input"&&O.target.getAttribute("type")==="text"&&(O.preventDefault(),V());},children:jsxRuntime.jsx(Ot.Composition,{state:ee,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.bookmark.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"name",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:_,children:a("dialogs.bookmark.name")}),jsxRuntime.jsx("input",{id:_,type:"text",className:"docx-dialog__input",value:p,maxLength:40,autoComplete:"off",spellCheck:false,"aria-invalid":D?true:void 0,"aria-describedby":L,onChange:O=>ee.setValue("name",O.target.value)})]}),jsxRuntime.jsx("div",{"data-docx-part":"field","data-docx-field":"list",className:"docx-dialog__row",children:jsxRuntime.jsx("select",{ref:w,className:"docx-dialog__input docx-dialog__input--full docx-bookmark-dialog__list",size:8,value:X,"aria-label":a("dialogs.bookmark.list"),onChange:O=>ee.setValue("name",O.target.value),onDoubleClick:j,children:B.map(O=>jsxRuntime.jsx("option",{value:O.name,children:O.name},O.name))})}),B.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__hint",children:a("dialogs.bookmark.empty")}):null,jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"sortBy",className:"docx-dialog__row",role:"radiogroup","aria-label":a("dialogs.bookmark.sortBy"),children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:a("dialogs.bookmark.sortBy")}),["name","location"].map(O=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:N,checked:b===O,onChange:()=>ee.setValue("sortBy",O)}),a(O==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},O))]}),jsxRuntime.jsx("div",{"data-docx-part":"field","data-docx-field":"showHidden",className:"docx-dialog__row",children:jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:v,onChange:O=>ee.setValue("showHidden",O.target.checked)}),a("dialogs.bookmark.showHidden")]})}),jsxRuntime.jsxs("div",{className:"docx-dialog__row docx-bookmark-dialog__status",children:[jsxRuntime.jsx("span",{id:L,"data-docx-part":"error",role:"status",className:D||h?"docx-dialog__error":"docx-dialog__hint",children:U}),R>0?jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"keepfirst",disabled:!c,onClick:q,children:a("dialogs.bookmark.keepFirst")}):null]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply","data-docx-part":"apply",disabled:!F.canAdd,onClick:V,children:a("dialogs.bookmark.add")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"delete",disabled:!F.canDelete,onClick:Y,children:a("dialogs.bookmark.delete")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"goto",disabled:!F.canGoTo,onClick:j,children:a("dialogs.bookmark.goTo")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a(T?"common.close":"common.cancel")})]})]}),children:r})})}var Ot=yt();function eR(){return Ot.useState()}var mi=Object.assign(JD,{Header:Ot.Header,Title:Ot.Title,Body:Ot.Body,Footer:Ot.Footer,Apply:Ot.Apply,Cancel:Ot.Cancel,Error:Ot.Error,Field:Ot.Field,Delete:Ot.part("delete"),GoTo:Ot.part("goto"),KeepFirst:Ot.part("keepfirst")});var Wh=editor.SPLIT_CELL_FALLBACK_MAX;function sR(e){return e.open?jsxRuntime.jsx(dR,{...e}):null}var cR=e=>e;function dR({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=A(),s=Co(e,t),c=Zt.useMemo(()=>l?.query({type:"splitCellConfig"})??null,[l]),[d]=Zt.useState(()=>editor.initialSplitCellCounts(c,F=>l?l.can(F):{ok:false,code:"unsupported",reason:""})),[m,u]=Zt.useState(d.columns),[g,p]=Zt.useState(d.rows),[f,b]=Zt.useState(null),y=Zt.useId(),v=Zt.useId(),x=Zt.useId(),{counts:h,problem:k}=editor.readSplitCellCounts(m,g,c),E=h?.cols??null,C=h?.rows??null;W(cR);let T=l&&h?l.can({type:"splitCell",...h}):null,S=k?.kind==="range"?a("dialogs.splitCell.range",{max:k.max}):k?.kind==="oneCell"?a("dialogs.splitCell.oneCell"):T&&!T.ok?i18n.localizeDisabledReason(T.reason??null,a):null,P=T?.ok===true,w=f??S,_=k?.kind==="range"?k.field:null,L=Zt.useCallback(()=>{if(!P||!l)return;if(!s()){t();return}let F=l.exec({type:"splitCell",rows:C,cols:E});F.ok?t():b(i18n.localizeDisabledReason(F.reason??null,a));},[P,l,s,t,C,E,a]),N={values:{columns:m,rows:g},setValue(F,D){F==="columns"?u(D):p(D),b(null);},errors:w?{form:w}:{},isEnabled:P,apply:L,cancel:t,limits:c},B=(F,D,R,U,V)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":F,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:D,children:a(R)}),jsxRuntime.jsx("input",{id:D,type:"number",inputMode:"numeric",className:"docx-dialog__input",min:1,max:V,step:1,value:U,"aria-invalid":_===F?true:void 0,"aria-describedby":x,onChange:Y=>N.setValue(F,Y.target.value)})]});return jsxRuntime.jsx(Fe,{kind:"splitCell",className:o,style:n,label:a("table.splitCell"),onClose:t,onKeyDown:F=>{F.key==="Enter"&&!F.nativeEvent.isComposing&&F.keyCode!==229&&editor.isHTMLElementNode(F.target)&&F.target.localName==="input"&&(F.preventDefault(),L());},children:jsxRuntime.jsx(Ro.Composition,{state:N,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("table.splitCell")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[B("columns",y,"dialogs.splitCell.columns",m,c?.maxCols??Wh),B("rows",v,"dialogs.splitCell.rows",g,c?.maxRows??Wh),jsxRuntime.jsx("div",{className:"docx-dialog__row",children:jsxRuntime.jsx("span",{id:x,"data-docx-part":"error",role:"status",className:"docx-dialog__error",children:w})})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply","data-docx-part":"apply",disabled:!P,onClick:L,children:a("dialogs.splitCell.submit")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("common.cancel")})]})]}),children:r})})}var Ro=yt();function uR(){return Ro.useState()}var fi=Object.assign(sR,{Header:Ro.Header,Title:Ro.Title,Body:Ro.Body,Footer:Ro.Footer,Apply:Ro.Apply,Cancel:Ro.Cancel,Error:Ro.Error,Field:Ro.Field});var Zh=Zt.createContext(void 0),Kh=Zh.Provider;function tt(){let e=Zt.useContext(Zh),{t}=H();return Zt.useCallback((o,n)=>{let r=e?.(o,n);return r===void 0||r===o?t(o,n):r},[e,t])}var Mo=yt();function yR(){return Mo.useState()}function xR({session:e,...t}){let[o,n]=Zt.useState(e),[r,i]=Zt.useState(0);return o!==e&&(n(e),i(r+1)),e?jsxRuntime.jsx(vR,{session:e,...t},r):null}function vR({session:e,children:t,preset:o,className:n,style:r}){let i=tt(),a=W(()=>e.canApply()),[l,s]=Zt.useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=Zt.useState(e.signal.aborted),[m,u]=Zt.useState(false);Zt.useEffect(()=>{let v=()=>d(true);return e.signal.addEventListener("abort",v),e.signal.aborted&&v(),()=>e.signal.removeEventListener("abort",v)},[e]);let g=()=>{if(e.signal.aborted)return;let v=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(!v);},p={values:l,setValue(v,x){s(h=>({...h,[v]:x,...v==="type"?{format:""}:{}})),u(false);},errors:m?{form:i("textFormField.invalidOptions")}:{},isEnabled:!c&&a,apply:g,cancel:e.cancel};if(c)return null;let f=editor.TEXT_FORM_FORMATS[l.type]??[],b={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},y=(v,x)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":v,className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${v}`)}),x]});return jsxRuntime.jsx(Fe,{kind:"textFormField",className:n,style:r,label:i("textFormField.title"),onClose:e.cancel,dismissOutside:false,sessionSignal:e.signal,restoreFocus:false,onKeyDown:v=>{v.key==="Escape"&&(v.preventDefault(),e.cancel()),v.key==="Enter"&&editor.isHTMLElementNode(v.target)&&v.target.localName==="input"&&(v.preventDefault(),g());},children:jsxRuntime.jsx(Mo.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:[y("defaultText",jsxRuntime.jsx("input",{className:"docx-dialog__input",value:l.defaultText,onChange:v=>p.setValue("defaultText",v.target.value)})),y("type",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:v=>p.setValue("type",v.target.value),children:[["regular","number","date"].map(v=>jsxRuntime.jsx("option",{value:v,children:i(`textFormField.${v}`)},v)),Object.hasOwn(editor.TEXT_FORM_FORMATS,l.type)?null:jsxRuntime.jsx("option",{value:l.type,disabled:true,children:i("textFormField.preservedType")})]})),y("maxLength",jsxRuntime.jsx("input",{className:"docx-dialog__input",type:"number",min:0,max:32767,step:1,value:Number.isNaN(l.maxLength)?"":l.maxLength,onChange:v=>p.setValue("maxLength",v.target.valueAsNumber)})),y("format",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:v=>p.setValue("format",v.target.value),children:[f.map(v=>jsxRuntime.jsx("option",{value:v,children:b[v]?i(b[v]):v||i("textFormField.noFormat")},v)),f.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:v=>p.setValue("enabled",v.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 bi=Object.assign(xR,{Header:Mo.Header,Title:Mo.Title,Body:Mo.Body,Footer:Mo.Footer,Apply:Mo.Apply,Cancel:Mo.Cancel,Error:Mo.Error,Field:Mo.Field});var $h=Zt.createContext(null),_o=()=>Zt.useContext($h);function zh({popups:e,children:t}){let o=A(),n=Gd(),[r,i]=Zt.useState(null),[a,l]=Zt.useState(null),[s,c]=Zt.useState(null),[d,m]=Zt.useState(null),u=Zt.useRef(d);u.current=d;let[g,p]=Zt.useState(null),f=Zt.useRef(g);f.current=g;let b=Zt.useRef(e);b.current=e;let y=Zt.useRef(null),v=Zt.useRef(s);v.current=s;let x=()=>l(null);Zt.useEffect(()=>{if(a!==null)return;let T=y.current;y.current=null,T?.isConnected&&T.focus({preventScroll:true});},[a]),Zt.useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(T){if(b.current?.textFormField===false){T.cancel();return}u.current?.cancel(),f.current?.cancel(),l(null),c(T),T.signal.addEventListener("abort",()=>c(S=>S===T?null:S),{once:true});}},{fallback:true})},[o]),Zt.useEffect(()=>{if(!o||!r&&e?.revisionMarkup!==false)return;let T=o.setRevisionMarkupChrome({onRequest(S){if(b.current?.revisionMarkup===false){S.cancel();return}v.current?.cancel(),f.current?.cancel(),l(null),m(S),S.signal.addEventListener("abort",()=>m(P=>P===S?null:P),{once:true});}},{fallback:true});return ()=>{u.current?.cancel(),T();}},[o,r,e?.revisionMarkup===false]),Zt.useEffect(()=>{if(!o||!r&&e?.compareDocuments!==false)return;let T=o.setCompareDocumentsChrome({onRequest(S){if(b.current?.compareDocuments===false){S.cancel();return}v.current?.cancel(),u.current?.cancel(),l(null),p(S),S.signal.addEventListener("abort",()=>p(P=>P===S?null:P),{once:true});}},{fallback:true});return ()=>{f.current?.cancel(),T();}},[o,r,e?.compareDocuments===false]),Zt.useEffect(()=>{l(null),c(null),m(null),p(null);},[o,n]);let h=e?.bookmark===false;Zt.useEffect(()=>{if(!(!o||!r||h))return o.setBookmarkChrome({onRequest(){v.current?.cancel(),u.current?.cancel(),f.current?.cancel(),y.current=PR(r.ownerDocument.activeElement),l("bookmark");}})},[o,r,h]),Zt.useEffect(()=>{e?.revisionMarkup===false&&u.current?.cancel(),e?.compareDocuments===false&&f.current?.cancel(),e?.textFormField===false&&v.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let k=Zt.useMemo(()=>({container:r,setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(T,S){v.current?.cancel(),u.current?.cancel(),f.current?.cancel(),b.current?.[T]!==false&&(y.current=S??r?.ownerDocument.activeElement,l(T));}}),[r,e?.pageSetup]),E={open:true,onClose:x},C=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?Te(e.pageSetup,E):jsxRuntime.jsx(tr,{...E}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Te(e.paragraph,E):jsxRuntime.jsx(Vo,{...E}):a==="watermark"&&e?.watermark!==false?e?.watermark?Te(e.watermark,E):jsxRuntime.jsx(or,{...E}):a==="bookmark"&&e?.bookmark!==false?e?.bookmark?Te(e.bookmark,E):jsxRuntime.jsx(mi,{...E}):a==="splitCell"&&e?.splitCell!==false?e?.splitCell?Te(e.splitCell,E):jsxRuntime.jsx(fi,{...E}):d&&e?.revisionMarkup!==false?e?.revisionMarkup?Te(e.revisionMarkup,{session:d},d):jsxRuntime.jsx(Ka,{session:d}):g&&e?.compareDocuments!==false?e?.compareDocuments?Te(e.compareDocuments,{session:g},g):jsxRuntime.jsx(qa,{session:g}):s&&e?.textFormField!==false?e?.textFormField?Te(e.textFormField,{session:s},s):jsxRuntime.jsx(bi,{session:s}):null;return jsxRuntime.jsxs($h.Provider,{value:k,children:[t,r?reactDom.createPortal(C,r):null]})}function PR(e){return e?.closest("[data-menu]")?.querySelector(':scope > [role="menuitem"]')??e}function Vh(){let e=_o();return jsxRuntime.jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer,dir:lt()})}function Gh({children:e}){let t=_o();return t?.container?reactDom.createPortal(e,t.container):e}var jh=["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"],Yh=["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"],yp=["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"],xp=["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"],Xh=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],Jh=["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"],Qh=["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 Qr(e,t,o){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:l,hidden:s})=>{let c=A(),{close:d}=$o(),m=Pe(),{isEnabled:u,disabledReason:g}=re(t);return s?null:jsxRuntime.jsx(De,{slot:e,icon:r??oe(o.paths),shortcut:m(a??o.shortcutKey),disabled:!u,...g?{title:g}:{},onSelect:()=>{c?.exec(t),d(true);},...l?{className:l}:{},children:m(i??o.labelKey)})},{docxRow:e})}var xi=Qr("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:jh}),vi=Qr("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:Yh}),Ci=Qr("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:xp}),Ti=Qr("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:Qh});function ea({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=A(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=$o(),c=we(),d=Pe(),m=Zt.useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:u,disabledReason:g}=re(m);if(r)return null;let p=l!==null;return jsxRuntime.jsx(De,{slot:"edit.paste",icon:e??oe(yp),shortcut:d(o??"contextMenu.pasteShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let{text:f,html:b}=await DR(c);(f||b)&&i?.exec({type:"paste",text:f,...b?{html:b}:{}});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...n?{className:n}:{},children:d(t??"contextMenu.paste")})}ea.docxRow="edit.paste";async function DR(e){let t=editor.hostWindowOf(e),o=t.navigator.clipboard;if(typeof o.read=="function"&&typeof t.ClipboardItem<"u")try{let n=await o.read(),r="",i=null;for(let a of n)a.types.includes("text/plain")&&(r=await(await a.getType("text/plain")).text()),a.types.includes("text/html")&&(i=await(await a.getType("text/html")).text());if(r||i)return {text:r,html:i}}catch{}return {text:await o.readText(),html:null}}function ta({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=A(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=$o(),c=we(),d=Pe(),m=Zt.useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:u,disabledReason:g}=re(m);if(r)return null;let p=l!==null;return jsxRuntime.jsx(De,{slot:"edit.pasteWithoutFormatting",icon:e??oe(yp),shortcut:d(o??"contextMenu.pasteWithoutFormattingShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let f=await editor.hostWindowOf(c).navigator.clipboard.readText();f&&i?.exec({type:"pasteWithoutFormatting",text:f});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...n?{className:n}:{},children:d(t??"contextMenu.pasteWithoutFormatting")})}ta.docxRow="edit.pasteWithoutFormatting";var t0=te("format.painter")?.paths??[],Rs=Qr("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:t0}),Ms=Qr("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:t0});function Yo(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l,destructive:s})=>{let{close:c}=$o(),d=Pe(),m=Ei(),{isEnabled:u,disabledReason:g,execute:p}=re(t);return l||!m?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 oa=Yo("table.selectTable",{type:"selectTableRegion",region:"table"},{labelKey:"table.selectTable",paths:editor.tableChromeIconPaths("select_all")}),na=Yo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:editor.tableChromeIconPaths("table_rows")}),ra=Yo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:editor.tableChromeIconPaths("table_rows")}),aa=Yo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:editor.tableChromeIconPaths("view_column")}),ia=Yo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:editor.tableChromeIconPaths("view_column")}),la=Yo("table.mergeCells",{type:"mergeCells"},{labelKey:"table.mergeCells",paths:editor.tableChromeIconPaths("call_merge")}),sa=Object.assign(({icon:e,labelKey:t,className:o,hidden:n})=>{let{close:r}=$o(),i=Pe(),a=Ei(),l=_o(),{isEnabled:s,disabledReason:c}=re("table.splitCell");return n||!a||!l?null:jsxRuntime.jsx(De,{slot:"table.splitCell",icon:e??oe(editor.tableChromeIconPaths("call_split")),disabled:!s,...c?{title:c}:{},...o?{className:o}:{},onSelect:()=>{r(true),l.open("splitCell");},children:i(t??"table.splitCell")})},{docxRow:"table.splitCell"}),ca=Yo("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:editor.tableChromeIconPaths("delete_sweep"),destructive:true}),da=Yo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:editor.tableChromeIconPaths("view_column"),destructive:true}),ua=Yo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:editor.tableChromeIconPaths("delete"),destructive:true}),RR=[{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 ar({hidden:e}){let{close:t}=$o(),o=Pe(),n=Ei(),r=re({type:"setTableCellVerticalAlignment",alignment:"top"}),i=re({type:"setTableCellVerticalAlignment",alignment:"center"}),a=re({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:RR.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:m=>{m.preventDefault(),m.stopPropagation();},onClick:()=>{d.execute()&&t(true);},children:oe(editor.tableChromeIconPaths(s.icon))},s.alignment)})})]})}ar.docxRow="table.cellVerticalAlignment";var o0=e=>e?{tocId:e}:{},n0=e=>t=>({type:"refreshToc",mode:e,...o0(t)}),MR=e=>({type:"removeToc",...o0(e)});function Cp(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l})=>{let s=A(),{close:c,tocId:d}=$o(),m=Pe(),u=Zt.useMemo(()=>t(d),[d]),{isEnabled:g,disabledReason:p}=re(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:m(i??o.labelKey)})},{docxRow:e})}var pa=Cp("toc.refresh",n0("entire"),{labelKey:"toc.refresh",paths:Xh}),ma=Cp("toc.refreshPageNumbers",n0("pageNumbers"),{labelKey:"toc.refreshPageNumbers",paths:Jh}),fa=Cp("toc.remove",MR,{labelKey:"toc.remove",paths:xp});function Ei(){return W(Zt.useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function _s({label:e,icon:t,shortcut:o,disabled:n,disabledReason:r,active:i,onSelect:a,className:l}){let{close:s}=$o();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 Pi=8;function LR(){let e=Zt.useContext(At),t=et(),o=Pe(),{isEnabled:n,reason:r}=ts(o);if((e?.mounted??0)===0)return null;let i=te("review.addComment");return jsxRuntime.jsx(De,{icon:oe(i?.paths),slot:"review.addComment",disabled:!n,title:r??void 0,onSelect:()=>{e?.requestCommentDraft()&&t.setOpenMenu(null);},children:o("comments.addComment")})}function HR(){let e=A(),t=et(),o=Pe();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 AR=[{kind:"row",id:"field.edit",render:()=>jsxRuntime.jsx(HR,{})},{kind:"row",id:"edit.cut",render:()=>jsxRuntime.jsx(xi,{})},{kind:"row",id:"edit.copy",render:()=>jsxRuntime.jsx(vi,{})},{kind:"row",id:"edit.paste",render:()=>jsxRuntime.jsx(ea,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsxRuntime.jsx(ta,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsxRuntime.jsx(Rs,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsxRuntime.jsx(Ms,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsxRuntime.jsx(Ci,{})},{kind:"row",id:"edit.selectAll",render:()=>jsxRuntime.jsx(Ti,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsxRuntime.jsx(gs,{shortcutKey:"contextMenu.insertLinkShortcut"})},{kind:"row",id:"review.addComment",render:()=>jsxRuntime.jsx(LR,{})}];function OR(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:oa.docxRow,render:()=>jsxRuntime.jsx(oa,{})},{kind:"row",id:na.docxRow,render:()=>jsxRuntime.jsx(na,{})},{kind:"row",id:ra.docxRow,render:()=>jsxRuntime.jsx(ra,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:aa.docxRow,render:()=>jsxRuntime.jsx(aa,{})},{kind:"row",id:ia.docxRow,render:()=>jsxRuntime.jsx(ia,{})},{kind:"separator",id:"sep.table.cells"},{kind:"row",id:la.docxRow,render:()=>jsxRuntime.jsx(la,{})},{kind:"row",id:sa.docxRow,render:()=>jsxRuntime.jsx(sa,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:ca.docxRow,render:()=>jsxRuntime.jsx(ca,{})},{kind:"row",id:da.docxRow,render:()=>jsxRuntime.jsx(da,{})},{kind:"row",id:ua.docxRow,render:()=>jsxRuntime.jsx(ua,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:ar.docxRow,render:()=>jsxRuntime.jsx(ar,{})}]}function BR(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:pa.docxRow,render:()=>jsxRuntime.jsx(pa,{})},{kind:"row",id:ma.docxRow,render:()=>jsxRuntime.jsx(ma,{})},{kind:"row",id:fa.docxRow,render:()=>jsxRuntime.jsx(fa,{})}]}function WR(e,t=false){return [...AR,...e?OR():[],...t?BR():[]]}function c0(e){if(!Zt.isValidElement(e))return null;let t=Wr(e,c0);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=hs(e.props);if(n)return n}return null}function l0(e){if(!Zt.isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function ZR(e){return e?.closest(".docx-editor__scroll-container")??null}function ki({className:e,t,preset:o=true,disabled:n,onOpenChange:r,children:i}){let a=$t(),l=lt(),s=A(),{t:c}=H(),d=Ei(),m=Zt.useRef(null),u=Zt.useRef(null),[g,p]=Zt.useState(null),[f,b]=Zt.useState(null),[y,v]=Zt.useState(null),x=Zt.useMemo(()=>WR(d,f!==null),[d,f]),[h,k]=Zt.useState(null),E=Zt.useCallback((N=false)=>{p(null),k(null),b(null),v(null),N&&s?.focus();},[s]);Zt.useEffect(()=>{if(n)return;let N=ZR(m.current);if(!N)return;let B=F=>{if(u.current?.contains(F.target)){F.preventDefault();return}if(!Eb(N,F.target))return;F.preventDefault();let D=F.button===-1||F.clientX===0&&F.clientY===0,R=N.getBoundingClientRect();b(s?.snapshot().tocContext?.id??null),v(D||!editor.isHTMLElementNode(F.target)?null:F.target),p(D?{x:R.left+16,y:R.top+16}:{x:F.clientX,y:F.clientY});};return N.addEventListener("contextmenu",B),()=>N.removeEventListener("contextmenu",B)},[n,s]),Zt.useEffect(()=>{n&&E();},[n,E]),Zt.useEffect(()=>{if(!g)return;let N=U=>{u.current?.contains(U.target)||E();},B=U=>{U.key==="Escape"?(U.preventDefault(),E(true)):U.key==="Tab"&&E();},F=()=>E(),D=editor.hostDocumentOf(m.current??u.current),R=editor.hostWindowOf(m.current??u.current);return D.addEventListener("pointerdown",N,true),D.addEventListener("keydown",B),D.addEventListener("scroll",F,{capture:true,passive:true}),R.addEventListener("blur",F),R.addEventListener("resize",F),()=>{D.removeEventListener("pointerdown",N,true),D.removeEventListener("keydown",B),D.removeEventListener("scroll",F,true),R.removeEventListener("blur",F),R.removeEventListener("resize",F);}},[g,E]),Zt.useLayoutEffect(()=>{let N=u.current;if(!g||!N)return;let{width:B,height:F}=N.getBoundingClientRect(),D=editor.hostWindowOf(N),R=D.innerWidth-B-Pi,U=D.innerHeight-F-Pi,Y=D.getComputedStyle(N).direction==="rtl"?g.x-B>=Pi:g.x>R,j=Math.max(Pi,Math.min(Y?g.x-B:g.x,R)),q=Math.max(Pi,g.y>U?g.y-F:g.y);k({x:j,y:q});},[g]),Zt.useLayoutEffect(()=>{h&&u.current?.focus({preventScroll:true});},[h]);let C=Zt.useRef(r);C.current=r;let T=Zt.useRef(false);Zt.useEffect(()=>{let N=g!==null;N!==T.current&&(T.current=N,C.current?.(N));},[g]);let S=Zt.useMemo(()=>({t,openMenu:null,setOpenMenu:()=>E(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,E]),[P,w]=Zt.useState(null),_=Zt.useMemo(()=>({close:E,anchor:g,tocId:f,target:y,clipboardRefusal:P,reportClipboardRefusal:w}),[E,g,f,y,P]),L={position:"fixed",left:(h??g)?.x??0,top:(h??g)?.y??0,visibility:h?"visible":"hidden"};return jsxRuntime.jsx("div",{ref:m,style:{display:"contents"},children:g?jsxRuntime.jsx(ni.Provider,{value:S,children:jsxRuntime.jsx(ys.Provider,{value:_,children:jsxRuntime.jsxs("div",{ref:u,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??c("contextMenu.ariaLabel"),tabIndex:-1,className:`${a}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,dir:l,style:L,onKeyDown:N=>{let B=u.current;if(!B)return;let F=Jn(B);N.key==="ArrowDown"?(N.preventDefault(),no(F,editor.hostDocumentOf(B).activeElement,1)):N.key==="ArrowUp"?(N.preventDefault(),no(F,editor.hostDocumentOf(B).activeElement,-1)):N.key==="Home"?(N.preventDefault(),ro(F,"first")):N.key==="End"&&(N.preventDefault(),ro(F,"last"));},children:[Zt.Children.toArray(i).filter(l0),es({entries:x,children:Zt.Children.toArray(i).filter(N=>!l0(N)),preset:o,keyOfEntry:N=>N.id,keyOfChild:N=>Tb(c0(N)),renderEntry:N=>N.kind==="separator"?jsxRuntime.jsx(Qn,{}):N.render(),onUnmatched:(N,B)=>{B.props.hidden&&qg(N);}})]})})}):null})}var Sp=Object.assign(ki,{Cut:xi,Copy:vi,Paste:ea,PasteWithoutFormatting:ta,Delete:Ci,SelectAll:Ti,SelectTable:oa,InsertRowAbove:na,InsertRowBelow:ra,InsertColumnLeft:aa,InsertColumnRight:ia,MergeCells:la,SplitCell:sa,DeleteTableRow:ca,DeleteTableColumn:da,DeleteTable:ua,CellVerticalAlignment:ar,RefreshToc:pa,RefreshTocPageNumbers:ma,RemoveToc:fa,Item:_s,Slot:ao,Row:De,Group:di,Separator:Qn,Submenu:io});var d0=su.Provider;function u0(){let e=Rt(),{t}=H();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e?.hyperlink&&Te(e.hyperlink,{}),e?.contentControl&&Te(e.contentControl,{}),e?.equation&&Te(e.equation,{}),e?.contextMenu&&Te(e.contextMenu,{t:o=>t(o)})]})}function p0(e,t,o,n){return {...e,hyperlink:e?.hyperlink??(t===false?false:r=>jsxRuntime.jsx(Ja,{...r})),contentControl:e?.contentControl??(r=>jsxRuntime.jsx(ti,{...r})),equation:e?.equation??(()=>jsxRuntime.jsx(oi,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:r=>e.contextMenu&&Te(e.contextMenu,{...r,t:n??r.t}):o===false?false:r=>jsxRuntime.jsx(ki,{...r,t:n??r.t,...typeof o=="object"?o:{}})}}function $R(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 Pp(){let e=A(),t=Zt.useCallback(n=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),o=W(t,$R);return o?.kind==="note"?o:null}function m0(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 f0(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&&m0(e.documentAuthored,t.documentAuthored)&&m0(e.sectionAuthored,t.sectionAuthored)}function zR(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&f0(e.footnote,t.footnote)&&f0(e.endnote,t.endnote)}function kp(){let e=A(),t=Zt.useCallback(o=>e?.getNotePropertiesState()??null,[e]);return W(t,zR)}function wi(e,t){let[o,n]=Zt.useState(null),r=Zt.useCallback(l=>n(l),[]),[i,a]=Zt.useState({visibility:"hidden"});return Zt.useLayoutEffect(()=>{let l=o?.closest(".docx-editor__scroll-container"),s=l??o?.parentElement?.querySelector(".docx-editor__scroll-container");if(!o||!s)return;let c=editor.hostWindowOf(s),d=0,m=null,u=new c.ResizeObserver(()=>p()),g=()=>{d=0;let b=e(s);if(b!==m&&(u.disconnect(),u.observe(s),u.observe(o),b&&u.observe(b),m=b),!b||!b.isConnected){a({visibility:"hidden"});return}let y=b.getBoundingClientRect(),v=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,x=t==="story-label"?6:4,h=l===s,k=t==="after"?y.bottom+6:t==="story-label"?editor.storyLabelTop(y,b.closest(".docx-page")?.getBoundingClientRect().top,v,x):y.top-v-x,E=h?Lr(s,y.left,k):{left:y.left,top:k},C=E.left,T=E.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"?T:Math.max(h?s.scrollTop+8:8,T),...t==="story-label"?{width:Math.max(240,Math.min(y.width,s.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(y.width-16,s.clientWidth-16))},visibility:"visible"});},p=()=>{d||(d=c.requestAnimationFrame(g));};u.observe(s),u.observe(o);let f=new c.MutationObserver(p);return f.observe(s,{subtree:true,childList:true,attributes:true,attributeFilter:["data-docx-hf-active","data-docx-note-scope"]}),s.addEventListener("scroll",p,{passive:true}),c.addEventListener("resize",p),g(),()=>{d&&c.cancelAnimationFrame(d),u.disconnect(),f.disconnect(),s.removeEventListener("scroll",p),c.removeEventListener("resize",p);}},[o,e,t]),{ref:r,style:i}}var JR=/^(footnote|endnote):(-?\d{1,10})$/;function h0(e){let t=JR.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function QR(e){let t=editor.hostWindowOf(e);return typeof t.matchMedia!="function"?false:t.matchMedia("(pointer: coarse)").matches}function Dp(e){let t=A();return Zt.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 eM(e){let{t}=H(),[o,n]=Zt.useState(false),r=Zt.useRef(null);return Zt.useEffect(()=>{if(o)return editor.listenForOutsidePress({popup:r.current,close:()=>n(false)})},[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:$,onClick:()=>n(i=>!i),children:t("headerFooter.options")}),o?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:$,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 Hs({className:e}){let t=Rt(),o=Zt.useRef(null),{t:n}=H(),r=A(),i=Pp(),[a,l]=Zt.useState(null),[s,c]=Zt.useState(null),[d,m]=Zt.useState(false),u=Zt.useRef(null),g=Zt.useCallback(_=>{if(!i)return null;let N=[..._.querySelectorAll("[data-docx-note-scope]")].find(B=>B.matches("[data-docx-note]")&&B.dataset.docxNoteScope===i.id)??null;return N?.closest("[data-docx-notes]")??N},[i]),p=wi(g,"story-label"),f=Zt.useCallback(()=>{u.current&&u.current.win.clearTimeout(u.current.handle),u.current=null,l(null);},[]);Zt.useEffect(()=>{if(!r)return;let _=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!_)return;let L=F=>{let D=F.target;if(!D)return;let R=D.closest("[data-docx-note-ref]");if(R?.dataset.docxNoteScope){F.preventDefault(),f(),c(null),r.setActiveScope({kind:"note",id:R.dataset.docxNoteScope});return}D.closest("[data-docx-note-mark-back]")&&(F.preventDefault(),f(),c(null),r.setActiveScope({kind:"body"}));},N=F=>{let D=F,U=D.target?.closest("[data-docx-note-scope]");U?.dataset.docxNoteScope&&(D.preventDefault(),c({scopeId:U.dataset.docxNoteScope,x:D.clientX,y:D.clientY}));},B=F=>{let D=F.target;if(QR(D))return;let R=D?.closest("[data-docx-note-ref]");if(!R?.dataset.docxNoteScope){f();return}let U=R.dataset.docxNoteScope,Y=r.getNotePreviewText(U)??R.getAttribute("aria-description")??n("notes.previewFallback"),j=R.getBoundingClientRect();u.current&&u.current.win.clearTimeout(u.current.handle);let q=editor.hostWindowOf(R),X=q.setTimeout(()=>{l({scopeId:U,text:Y,x:j.left,y:j.bottom+4});},400);u.current={win:q,handle:X};};return _.addEventListener("click",L),_.addEventListener("contextmenu",N),_.addEventListener("pointerover",B),_.addEventListener("scroll",f,true),()=>{_.removeEventListener("click",L),_.removeEventListener("contextmenu",N),_.removeEventListener("pointerover",B),_.removeEventListener("scroll",f,true),f();}},[r,f,n]);let b=Zt.useCallback(_=>{r&&(r.exec(_),c(null));},[r]),y=s?h0(s.scopeId):null,v=Zt.useMemo(()=>y?{type:"deleteNote",noteKind:y.noteKind,noteId:y.noteId}:null,[y]),x=Zt.useMemo(()=>y?{type:"convertNote",fromKind:y.noteKind,noteId:y.noteId}:null,[y]),h=Zt.useMemo(()=>y?{type:"convertAllNotes",fromKind:y.noteKind}:null,[y]),k=Dp(v??{type:"deleteNote",noteKind:"footnote",noteId:0}),E=Dp(x??{type:"convertNote",fromKind:"footnote",noteId:0}),C=Dp(h??{type:"convertAllNotes",fromKind:"footnote"}),T=i?h0(i.id):null,S=T?n("notes.editingRegion",{kind:T.noteKind==="footnote"?n("notes.footnoteKind"):n("notes.endnoteKind"),number:T.noteId}):null,P=s&&y?{...s,...y,onDelete:()=>{v&&b(v);},onConvert:()=>{x&&b(x);},onConvertAll:()=>{h&&b(h);},onOpenProperties:()=>m(true),onClose:()=>c(null),deleteEnabled:k.enabled,convertEnabled:E.enabled,convertAllEnabled:C.enabled,deleteDisabledReason:k.reason??void 0,convertDisabledReason:E.reason??void 0,convertAllDisabledReason:C.reason??void 0}:null,w={onClose:()=>m(false),onApply:_=>{b(_),m(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&&T?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:St.chrome},children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:S}),jsxRuntime.jsx(eM,{onOpenProperties:()=>m(true),onClose:()=>r.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Te(t.notePreview,a):jsxRuntime.jsx(Nr,{...a}):null,P&&t?.notesContextMenu!==false?t?.notesContextMenu?Te(t.notesContextMenu,P):jsxRuntime.jsx(Fr,{...P}):null,d&&t?.noteProperties!==false?t?.noteProperties?Te(t.noteProperties,w):jsxRuntime.jsx(As,{...w}):null]}):null}function As(e){let{t}=H(),o=A(),n=kp(),[r,i]=Zt.useState("document"),[a,l]=Zt.useState("decimal"),[s,c]=Zt.useState("continuous"),[d,m]=Zt.useState("pageBottom"),[u,g]=Zt.useState("decimal"),[p,f]=Zt.useState("continuous"),[b,y]=Zt.useState("docEnd");Zt.useEffect(()=>{n&&(l(n.footnote.resolved.numFmt),c(n.footnote.resolved.numRestart),m(n.footnote.resolved.pos),g(n.endnote.resolved.numFmt),f(n.endnote.resolved.numRestart),y(n.endnote.resolved.pos));},[n]);let v=!n?.footnote.sectionAuthored,x=!n?.endnote.sectionAuthored&&n?.endnote.documentAuthored?.pos===void 0;return jsxRuntime.jsx("div",{className:"docx-note-properties",role:"dialog","aria-modal":"true","data-docx-modal":"","aria-label":t("dialogs.footnoteProperties.title"),"data-testid":"docx-notes-properties-dialog",style:{zIndex:St.modal},onClick:e.onClose,onKeyDown:h=>{h.key==="Escape"&&e.onClose();},children:jsxRuntime.jsxs("div",{className:"docx-note-properties__panel",onClick:h=>h.stopPropagation(),onMouseDown:h=>h.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:h=>i(h.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")}),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:a,onChange:h=>l(h.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:h=>c(h.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:h=>m(h.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")}),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:u,onChange:h=>g(h.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:h=>f(h.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:h=>y(h.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 h={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(h).ok&&e.onApply(h);},children:t("common.apply")})]})]})})}var C0=e=>e.image;function v0(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===editor.hostDocumentOf(e).activeElement)}function lM(){let e=Ut(),[t,o]=Zt.useState(false);return {ref:Zt.useCallback(r=>{r&&o(!r.parentElement?.closest(e?".docx-editor.dark":".docx-editor"));},[e]),className:t?`docx-editor ${e?"dark ":""}`:""}}function sM(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Fp(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(gn(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(gn(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(gn(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(gn(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function cM(e,t){let o=Fp(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function Os(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=ai(t);return Number.isInteger(o)?o:null}function dM(e,t){let o=Fp(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,m=c?Os(e.horizontalPoints):t.position?.horizontalEmu,u=d?Os(e.verticalPoints):t.position?.verticalEmu;return c&&m===null?{ok:false}:d&&u===null?{ok:false}:m===void 0||u===void 0?{ok:false}:{ok:true,value:{horizontalEmu:m,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?Os(e.horizontalPoints):t.position?.horizontalEmu,s=r?Os(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 Bs(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function Ws(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function Ri({open:e,onClose:t,className:o,triggerRef:n}){let r=A(),{t:i}=H(),a=W(C0),l=Zt.useId(),s=Zt.useId(),c=Zt.useId(),d=Zt.useRef(null),m=Zt.useRef(null),u=Zt.useRef(null),g=Zt.useRef(null),[p,f]=Zt.useState(null),[b,y]=Zt.useState(null),v=lM(),x=m.current,h=x?.canCrop===false,k=x?.canResize===false,E=x?.locks.changeAspect===true,C=x?.kind==="anchored"&&x.canMove===true,T=x?.kind==="inline",S=x?.kind==="anchored"&&x.canMove===false;Zt.useEffect(()=>{if(!e){m.current=null,u.current=null,g.current=null;return}if(!a)return;if(m.current=a,r?.surface){let{anchor:U}=r.surface.state().selection;u.current={paragraphId:U.paragraphId,offset:U.offset},g.current=r.surface.session.packageRevision();}y(null);let D=Fp(a),R=a.crop;f({widthPoints:String(gn(a.widthEmu)),heightPoints:String(gn(a.heightEmu)),cropLeft:String(R.left),cropTop:String(R.top),cropRight:String(R.right),cropBottom:String(R.bottom),title:a.title,description:a.description,hyperlink:a.hyperlink??"",wrap:a.wrap,lockAspect:a.locks.changeAspect,...D});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let P=Zt.useCallback(()=>{n?.current?.focus(),r?.focus();},[r,n]),w=Zt.useCallback(()=>{t(),P();},[t,P]);Zt.useEffect(()=>{if(!e)return;let D=d.current;if(!D)return;let R=v0(D);(R.find(j=>j.id==="image-prop-width"&&!j.hasAttribute("disabled"))??R.find(j=>!j.hasAttribute("disabled"))??D).focus();let V=j=>{if(j.key==="Escape"){j.preventDefault(),w();return}if(j.key!=="Tab")return;let q=v0(D);if(q.length===0)return;let X=editor.hostDocumentOf(D).activeElement,ee=q.findIndex(I=>I===X);if(ee===-1)return;j.preventDefault();let O=j.shiftKey?(ee-1+q.length)%q.length:(ee+1)%q.length;q[O]?.focus();},Y=editor.hostDocumentOf(D);return Y.addEventListener("keydown",V),()=>Y.removeEventListener("keydown",V)},[e,w]);let _=Zt.useMemo(()=>{let D=x??a;return !D||D.widthEmu<=0?1:D.widthEmu/D.heightEmu},[a,x]),L=Zt.useCallback(D=>{f(R=>{if(!R)return R;if(!R.lockAspect)return {...R,widthPoints:D};let U=Ws(D);if(U===null)return {...R,widthPoints:D};let V=Math.round(U/_*100)/100;return {...R,widthPoints:D,heightPoints:String(V)}});},[_]),N=Zt.useCallback(D=>{f(R=>{if(!R)return R;if(!R.lockAspect)return {...R,heightPoints:D};let U=Ws(D);if(U===null)return {...R,heightPoints:D};let V=Math.round(U*_*100)/100;return {...R,widthPoints:String(V),heightPoints:D}});},[_]),B=Zt.useCallback(()=>{let D=m.current;if(!D?.intrinsic)return;let R=D.intrinsic.pixelWidth*72/D.intrinsic.dpiX,U=D.intrinsic.pixelHeight*72/D.intrinsic.dpiY;f(V=>V&&{...V,widthPoints:String(Math.round(R*100)/100),heightPoints:String(Math.round(U*100)/100)});},[a]),F=Zt.useCallback(()=>{let D=m.current,R=u.current,U=g.current;if(!r||!D||!p||!R||U===null)return;let V={type:"setImageProperties",drawingNodeId:D.id,expectedPackageRevision:U,selectionParagraphId:R.paragraphId,selectionOffset:R.offset};if(!k){let O=Ws(p.widthPoints),I=Ws(p.heightPoints);if(O===null||I===null){y("imageProperties.errors.invalidDimensions");return}let ie=ai(O),ge=ai(I);ie!==D.widthEmu&&(V.widthEmu=ie),ge!==D.heightEmu&&(V.heightEmu=ge);}if(D.canCrop&&!h){let O=Bs(p.cropLeft),I=Bs(p.cropTop),ie=Bs(p.cropRight),ge=Bs(p.cropBottom);if(O===null||I===null||ie===null||ge===null){y("imageProperties.errors.invalidCrop");return}let K=D.crop;(O!==K.left||I!==K.top||ie!==K.right||ge!==K.bottom)&&(V.crop={left:O,top:I,right:ie,bottom:ge});}p.title!==D.title&&(V.title=p.title),p.description!==D.description&&(V.description=p.description);let Y=p.hyperlink.trim();if(Y!==(D.hyperlink??"")&&(V.hyperlink=Y===""?null:Y),D.canChangeWrap&&p.wrap!==D.wrap&&(V.wrap=p.wrap),D.kind==="anchored"&&D.canMove&&cM(p,D)){let O=dM(p,D);if(!O.ok){y("imageProperties.errors.invalidPosition");return}if(!editor.validateDrawingPositionInput(editor.positionInputFromPropertiesCommand(O.value,D))){y("imageProperties.errors.invalidPosition");return}Object.assign(V,O.value);}if(!(V.widthEmu!==void 0||V.heightEmu!==void 0||V.title!==void 0||V.description!==void 0||V.hyperlink!==void 0||V.crop!==void 0||V.wrap!==void 0||V.horizontalEmu!==void 0||V.verticalEmu!==void 0||V.relativeToH!==void 0||V.relativeToV!==void 0)){w();return}if(!r.can(V).ok){y("imageProperties.errors.refused");return}if(!r.exec(V).ok){y("imageProperties.errors.refused");return}w();},[r,p,h,k,w]);return !e||!p?null:jsxRuntime.jsx("div",{ref:v.ref,className:`${v.className}docx-dialog-overlay${o?` ${o}`:""}`,onClick:w,onMouseDown:D=>{D.stopPropagation(),sM(D);},children:jsxRuntime.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","data-docx-modal":"","aria-labelledby":l,className:"docx-dialog docx-image-properties-dialog",onClick:D=>D.stopPropagation(),onMouseDown:D=>D.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:k,onChange:D=>L(D.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:k,onChange:D=>N(D.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:E,onChange:D=>f(R=>R&&{...R,lockAspect:D.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:h||!x?.intrinsic,onClick:B,children:i("imageProperties.resetNaturalSize")})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.position")}),T?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:D=>f(R=>R&&{...R,relativeToH:D.target.value}),children:editor.DRAWING_REL_FROM_H.map(D=>jsxRuntime.jsx("option",{value:D,children:i(`dialogs.imagePosition.relativeOptions.${D}`)},D))})]}),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:D=>f(R=>R&&{...R,relativeToV:D.target.value}),children:editor.DRAWING_REL_FROM_V.map(D=>jsxRuntime.jsx("option",{value:D,children:i(`dialogs.imagePosition.relativeOptions.${D}`)},D))})]})]}):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:D=>f(R=>R&&{...R,horizontalPoints:D.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:D=>f(R=>R&&{...R,verticalPoints:D.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:D=>f(R=>R&&{...R,title:D.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:D=>f(R=>R&&{...R,description:D.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:D=>f(R=>R&&{...R,hyperlink:D.target.value}),placeholder:i("hyperlinkPopup.urlPlaceholder"),dir:"ltr"})]}),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:D=>f(R=>R&&{...R,wrap:D.target.value}),children:editor.IMAGE_WRAP_TARGETS.map(D=>jsxRuntime.jsx("option",{value:D,children:i(`imageWrap.targets.${D}`)},D))})]}),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:D=>f(R=>R&&{...R,cropLeft:D.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:D=>f(R=>R&&{...R,cropTop:D.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:D=>f(R=>R&&{...R,cropRight:D.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:D=>f(R=>R&&{...R,cropBottom:D.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:w,children:i("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:F,children:i("common.apply")})]})]})})}function Ks({className:e,hidden:t,asChild:o,children:n}){let r=Rt(),i=A(),{t:a}=H(),l=W(C0),[s,c]=Zt.useState(false),d=Zt.useRef(null),m={type:"setImageProperties",description:"probe"},u=i&&l?i.can(m):null,g=u?.ok===true,p=u&&!u.ok?u.reason:null,f=bn(o,n);if(t)return null;let b=te("image.properties"),y=a("formattingBar.imagePropertiesShortcut"),v={type:"button",ref:d,className:`${hn(f)}${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!g,...g?{}:{"data-disabled":""},"aria-label":y,title:p??y,onMouseDown:$,onClick:()=>c(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o?jsxRuntime.jsx(Q,{...v,children:n}):jsxRuntime.jsx("button",{...v,children:f?jsxRuntime.jsx(yn,{icon:oe(b?.paths),label:y}):n??oe(b?.paths)}),s&&r?.imageProperties!==false?r?.imageProperties?Te(r.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):jsxRuntime.jsx(Ri,{open:s,onClose:()=>c(false),triggerRef:d}):null]})}Ks.docxSlot="image.properties";var ga=Object.assign(Ks,{docxSlot:"image.properties"});function Mi(e){let t=A(),o=Zt.useCallback(()=>editor.toolbarCommandState(t,e),[t,e]),n=W(o,(r,i)=>r.value===i.value&&r.enabled===i.enabled&&r.disabledReason===i.disabledReason);return Zt.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 qs({className:e,hidden:t,asChild:o,children:n}){let r=Rt(),i=ae(),{execute:a,value:l,isEnabled:s,disabledReason:c}=Mi("image.altText"),[d,m]=Zt.useState(false),[u,g]=Zt.useState(""),p=Zt.useRef(null),f=Zt.useRef(null),b=Zt.useId(),y=bn(o,n);Zt.useEffect(()=>{d&&g(l??"");},[d,l]),Zt.useEffect(()=>{if(!d)return;let C=P=>{let w=p.current;editor.isDomNode(P.target)&&(w?.contains(P.target)||w?.ownerDocument.getElementById(b)?.contains(P.target))||m(false);},T=P=>{P.key==="Escape"&&(P.preventDefault(),m(false),f.current?.focus());},S=editor.hostDocumentOf(p.current);return S.addEventListener("mousedown",C,true),S.addEventListener("keydown",T),()=>{S.removeEventListener("mousedown",C,true),S.removeEventListener("keydown",T);}},[d,b]);let v=Zt.useCallback(()=>{a(u),m(false);},[u,a]);if(t)return null;let x=te("image.altText"),h=i(x?.labelKey??"formattingBar.altText"),k={type:"button",ref:f,className:`${hn(y)} 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:$,onClick:()=>m(C=>!C)},E={id:b,value:u,onValueChange:g,onApply:v,onClose:()=>m(false),isEnabled:s,anchorRef:f};return jsxRuntime.jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsxRuntime.jsx(Q,{...k,children:n}):jsxRuntime.jsx("button",{...k,children:y?jsxRuntime.jsx(yn,{icon:null,label:h}):n??h}),d&&r?.imageAltText!==false?r?.imageAltText?Te(r.imageAltText,E):jsxRuntime.jsx(Us,{...E}):null]})}qs.docxSlot="image.altText";var _i=Object.assign(qs,{docxSlot:"image.altText"});function Us({id:e,value:t,onValueChange:o,onApply:n,onClose:r,isEnabled:i,className:a}){let{t:l}=H();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")})]})]})}function Ap(e){let[t,o]=Zt.useState(e.session),[n,r]=Zt.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(TM,{...e},n)}function TM({session:e,className:t,style:o,children:n}){let r=tt(),[i,a]=Zt.useState(e.signal.aborted),l=Zt.useRef(null);return Zt.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(Fe,{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 w0=Zt.createContext(null),D0=w0.Provider;function ct(){let e=Zt.useContext(w0);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function FM(e){return e.kind==="date"?editor.parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function R0(e){let t=`docx-cc-list-${Zt.useId()}`,[o,n]=Zt.useState(()=>FM(e)),[r,i]=Zt.useState(()=>editor.calendarDateText(e.value,e.locale)),a=Zt.useMemo(()=>editor.createContentControlListNavigation(e.locale),[e]),[l,s]=Zt.useState(false),c=Zt.useCallback(w=>{i(w),s(false);},[]),d=W(()=>e.canApply()),m=e.kind==="date"?editor.parseIsoDate(e.value):null,[u,g]=Zt.useState(()=>{let w=m??new Date;return {year:w.getFullYear(),month:w.getMonth()}}),p=Zt.useCallback(w=>{let _=e.apply(w??o);return s(!_),_},[e,o]),f=Zt.useCallback(()=>e.cancel(),[e]),b=Zt.useCallback(async w=>{if(!e.replaceImage)return s(true),false;try{let _=w instanceof Uint8Array?w.byteLength:w.size;if(!e.canApply()||_>store.DEFAULT_IMAGE_RESOURCE_LIMITS.maxEncodedBytes)return s(!0),!1;let L=w instanceof Uint8Array?w:new Uint8Array(await w.arrayBuffer()),N=await e.replaceImage(L);return s(!N),N}catch{return s(true),false}},[e]),y=Zt.useMemo(()=>editor.calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),v=Zt.useCallback(()=>{g(w=>editor.shiftMonth(w.year,w.month,-1)),C(null);},[]),x=Zt.useCallback(()=>{g(w=>editor.shiftMonth(w.year,w.month,1)),C(null);},[]),h=Zt.useCallback(w=>p(w),[p]),k=Zt.useCallback(()=>p(editor.isoDateOf(new Date)),[p]),[E,C]=Zt.useState(null),T=Zt.useCallback(w=>{let _=editor.parseIsoDate(w);_&&(g({year:_.getFullYear(),month:_.getMonth()}),C(editor.isoDateOf(_)));},[]),S=Zt.useCallback(()=>{let w=editor.calendarDateFromText(r,e.locale);return w?p(w):(s(true),false)},[r,e.locale,p]),P=Zt.useCallback((w,_)=>{!Number.isInteger(w)||w<100||w>9999||!Number.isInteger(_)||_<0||_>11||(g({year:w,month:_}),C(null));},[]);return Zt.useMemo(()=>({session:e,kind:e.kind,items:e.items,value:o,setValue:n,isEnabled:d,refused:l,apply:p,cancel:f,calendar:y,previousMonth:v,nextMonth:x,selectDay:h,selectToday:k,focusIso:E,focusDay:T,dateText:r,setDateText:c,applyDateText:S,showMonth:P,listNavigation:a,listId:t,accept:editor.CONTENT_CONTROL_PICTURE_ACCEPT,replaceImage:b}),[e,b,o,d,l,p,f,y,v,x,h,k,E,T,r,c,S,P,a,t])}function ot(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":m,...u}=t,g=r===void 0?n:r,{key:p,...f}=o,b={...c!==void 0?{id:c}:{},...d!==void 0?{title:d}:{},...m!==void 0?{"aria-label":m}:{}};if(i){let{className:v,style:x,...h}=f;return jsxRuntime.jsx(Q,{...u,...h,...b,...a?{className:a}:{},style:{...x,...l},children:g},p)}return jsxRuntime.jsx(e,{...u,...f,...b,className:[o.className,a].filter(Boolean).join(" "),style:{...o.style,...l},children:g},p)}var sr=e=>e.stopPropagation();function Zp(e){return ot("div",e,{className:"docx-content-control-calendar-header","data-docx-part":"header"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Kp,{}),jsxRuntime.jsx(Jp,{}),jsxRuntime.jsx(qp,{}),jsxRuntime.jsx(Up,{className:"docx-content-control-calendar-announcement"})]}))}function Kp(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"previousMonth","aria-label":o("contentControl.calendar.previousMonth"),onMouseDown:sr,onClick:t.previousMonth},"\u2039")}function qp(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"nextMonth","aria-label":o("contentControl.calendar.nextMonth"),onMouseDown:sr,onClick:t.nextMonth},"\u203A")}function Up(e){let t=ct();return ot("div",e,{className:"docx-content-control-calendar-title","data-docx-part":"title","aria-live":"polite"},t.calendar.title)}function $p(e){let t=ct();return ot("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 zp({day:e,...t}){let o=ct(),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 ot("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:sr,onClick:()=>o.selectDay(e.iso),onKeyDown:r},String(e.day))}function Vp(e){let t=ct(),o=Zt.useRef(null);return Zt.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]),ot("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(zp,{day:i},i.iso))},r)))}function Gp(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-content-control-calendar-today","data-docx-part":"today",disabled:!t.isEnabled,onMouseDown:sr,onClick:t.selectToday},o("contentControl.calendar.today"))}function jp(e){return ot("div",e,{className:"docx-content-control-calendar","data-docx-part":"calendar"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Zp,{}),jsxRuntime.jsx($p,{}),jsxRuntime.jsx(Vp,{}),jsxRuntime.jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsxRuntime.jsx(Gp,{}),jsxRuntime.jsx(zs,{})]}),jsxRuntime.jsx(ba,{}),jsxRuntime.jsx(Gs,{})]}))}function Yp({item:e,...t}){let o=ct();return ot("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:sr,onClick:()=>o.apply(e.value)},e.displayText)}function $s(e){let t=ct(),o=tt();return ot("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(Yp,{item:n},r)))}function zs(e){let t=ct(),o=tt();return ot("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:sr,onChange:n=>(t.kind==="date"?t.setDateText:t.setValue)(n.target.value)},void 0)}function ba(e){let t=ct(),o=tt();return t.refused?ot("div",e,{className:"docx-content-control-widget-error","data-docx-part":"error",role:"alert"},o("disabledReason.invalidValue")):null}function Xp(e){let t=ct(),o=tt();return ot("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 Vs(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t.cancel},o("common.cancel"))}function Gs(e){return ot("div",e,{className:"docx-dialog__footer","data-docx-part":"footer"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Vs,{}),jsxRuntime.jsx(Xp,{})]}))}function Jp(e){return ot("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Qp,{}),jsxRuntime.jsx(em,{})]}))}function Qp(e){let t=ct(),o=tt();return ot("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 em(e){let t=ct(),o=tt();return ot("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 tm({autoOpen:e,...t}){let o=ct(),n=tt(),r=Zt.useRef(null),i=Zt.useRef(false);return Zt.useLayoutEffect(()=>{e!==false&&!i.current&&(i.current=true,r.current?.click());},[e]),ot("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:sr,onCancel:o.cancel,onChange:a=>{let l=a.target.files?.[0];a.target.value="",l&&o.replaceImage(l);}},void 0)}function qM(e){let[t,o]=Zt.useState(e.session),[n,r]=Zt.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(UM,{...e},n)}function UM({session:e,className:t,style:o,children:n}){let r=tt(),i=R0(e),[a,l]=Zt.useState(e.signal.aborted),s=Zt.useRef(null),[c]=Zt.useState(()=>editor.contentControlPopupOpener(e.anchor)),d=e.kind==="checkbox"&&n===void 0;if(Zt.useEffect(()=>{let u=()=>l(true);return e.signal.addEventListener("abort",u,{once:true}),e.signal.aborted&&u(),()=>e.signal.removeEventListener("abort",u)},[e]),Zt.useEffect(()=>{!d||e.signal.aborted||e.apply(e.value==="true"?"false":"true");},[d,e]),Zt.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 f=g?.activeElement;c?.isConnected&&(f===g?.body||f&&u?.contains(f))&&c.focus({preventScroll:true});}},[e,a,d,c]),Zt.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 m=r(`contentControl.types.${e.kind}`);return jsxRuntime.jsx(D0,{value:i,children:jsxRuntime.jsx("div",{ref:s,role:"dialog","aria-label":m,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??$M(i)})})}function $M(e){return e.kind==="date"?jsxRuntime.jsx(jp,{}):e.kind==="picture"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(tm,{}),jsxRuntime.jsx(ba,{}),jsxRuntime.jsx(Vs,{})]}):e.kind==="comboBox"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(zs,{}),jsxRuntime.jsx($s,{}),jsxRuntime.jsx(ba,{}),jsxRuntime.jsx(Gs,{})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx($s,{}),jsxRuntime.jsx(ba,{})]})}var am=Object.assign(qM,{Navigation:Jp,Month:Qp,Year:em,Calendar:jp,Header:Zp,PreviousMonth:Kp,Title:Up,NextMonth:qp,Weekdays:$p,Grid:Vp,Day:zp,Today:Gp,List:$s,Item:Yp,Input:zs,Picture:tm,Error:ba,Footer:Gs,Apply:Xp,Cancel:Vs});function lm(e){return e==="checkbox"?"contentControlCheckbox":e==="picture"?"contentControlPicture":"contentControlWidget"}function I0(){let e=A(),t=Rt(),o=Zt.useRef(t);o.current=t;let[n,r]=Zt.useState(null),[i,a]=Zt.useState(null),l=t?.contentControlWidget!==void 0,s=t?.contentControlCheckbox!==void 0,c=t?.contentControlPicture!==void 0,d=t?.invalidTextFormField!==void 0;Zt.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(f){if(o.current?.[lm(f.kind)]===false)return f.cancel();r(f),f.signal.addEventListener("abort",()=>{u&&r(b=>b===f?null:b);},{once:true});}},{fallback:true});return ()=>{u=false,p(),r(null);}},[e,l,s,c]),Zt.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(f=>f===p?null:f);},{once:true});}},{fallback:true});return ()=>{u=false,g(),a(null);}},[e,d]),Zt.useEffect(()=>{n&&t?.[lm(n.kind)]===false&&n.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,n,i]);let m=n?t?.[lm(n.kind)]:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&m&&Te(m,{session:n},n),i&&t?.invalidTextFormField&&Te(t.invalidTextFormField,{session:i},i)]})}var c1=["nw","n","ne","e","se","s","sw","w"],A0=40,O0=12;function d1(e){return `imageOverlay.handle.${e}`}function u1(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 p1(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 m1(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 cm({containerRef:e,portalRef:t,scrollPort:o}){let n=A(),{t:r}=H(),[i,a]=Zt.useState(null),[l,s]=Zt.useState(null),[c,d]=Zt.useState({left:0,top:0}),m=Zt.useRef(null);m.current=l;let u=Zt.useRef(null),g=Zt.useRef(null),p=Zt.useRef(null),f=Zt.useRef(null),b=Zt.useRef(null);Zt.useEffect(()=>{let T=e.current;if(!T)return;let S=P=>{let w=editor.isElementNode(P.target)?P.target:null;if(w?.closest(".docx-drawing-textbox-content")){f.current=null;return}let _=w?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");f.current=_??null,_&&_===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return T.addEventListener("pointerdown",S,{capture:true}),()=>T.removeEventListener("pointerdown",S,{capture:true})},[e,i?.id]),Zt.useEffect(()=>{if(!n){a(null);return}let T=()=>{a(editor.selectedDrawingOverlayTargetOf(n.surface));},S=()=>{queueMicrotask(T);};T();let P=[n.on("change",S),n.on("selectionChange",T)];return ()=>{for(let w of P)w();}},[n]);let y=Zt.useCallback(()=>{d(T=>{let S=editor.overlayHostOrigin(e.current);return S.left===T.left&&S.top===T.top?T:S});},[e]);Zt.useEffect(()=>{y();let T=t.current,S=editor.hostWindowOf(T).ResizeObserver;if(!T||typeof S!="function")return;let P=new S(y);P.observe(T);let w=e.current;return w&&P.observe(w),()=>P.disconnect()},[e,t,y,i]),Zt.useEffect(()=>{if(o){b.current=o;return}let T=e.current;if(!T||!n?.surface)return;let S=T.closest(".docx-editor__scroll-container");if(!S)return;let P=n.surface.overlayCoordinates();return b.current=editor.createImageOverlayScrollPort(S,P.paintScale),()=>{b.current=null;}},[e,n,o]);let v=Zt.useCallback(()=>{s(null),u.current=null;let T=g.current;if(g.current=null,T)try{T.releasePointerCapture(T._lastPointerId??0);}catch{}},[]),x=Zt.useCallback((T,S,P,w,_,L,N)=>{if(!n?.surface)return;let B=n.surface.activeScope();if(B.kind==="frame"&&!n.surface.selectDrawing(P.id,B.hostParagraphId))return;let F=n.surface.layout(),D=editor.captureImageMutationPreconditions(n);if(D){u.current=Object.freeze({x:w,y:_}),g.current=L,L._lastPointerId=N;try{L.setPointerCapture(N);}catch{}s({session:Object.freeze({drawingNodeId:P.id,startBounds:Object.freeze({x:P.x,y:P.y,width:P.width,height:P.height}),startWidthEmu:P.widthEmu,startHeightEmu:P.heightEmu,startPosition:P.position,anchorFrameOrigin:P.anchorFrameOrigin,transform:P.transform,mode:T,handle:S,preconditions:D,layoutRevision:F.revision,packageRevision:n.surface.session.packageRevision(),kind:P.kind}),bounds:P,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});}},[n]),h=Zt.useCallback((T,S,P,w,_)=>{if(!n)return;if(editor.isStaleImageInteractionCommit(n,T)){v();return}T.mode==="resize"?n.exec({type:"setImageProperties",widthEmu:S,heightEmu:P,..._?.mode==="simple"?{horizontalEmu:_.horizontalEmu,verticalEmu:_.verticalEmu}:{},..._?.mode==="frame"?{..._.horizontalEmu!==void 0?{horizontalEmu:_.horizontalEmu}:{},..._.verticalEmu!==void 0?{verticalEmu:_.verticalEmu}:{}}:{}}):T.mode==="move"&&_&&n.exec({type:"setImagePosition",..._}),v();},[v,n]),k=Zt.useCallback(T=>{if(!n)return;let S=m.current?.bounds??editor.selectedDrawingOverlayTargetOf(n.surface);if(!S)return;if(m.current&&T.key==="Escape"){T.preventDefault(),T.stopPropagation(),v();return}if(m.current)return;let P=editor.historyShortcutOf(T);if(P){T.preventDefault(),T.stopPropagation(),n.exec({type:P});return}let w=T.shiftKey?editor.IMAGE_OVERLAY_NUDGE_SHIFT_PT:editor.IMAGE_OVERLAY_NUDGE_PT;if(T.key==="Delete"||T.key==="Backspace"){T.preventDefault(),T.stopPropagation(),n.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(T.key))return;T.preventDefault(),T.stopPropagation();let _=T.key==="ArrowLeft"?-w:T.key==="ArrowRight"?w:0,L=T.key==="ArrowUp"?-w:T.key==="ArrowDown"?w:0;if(T.altKey){if(!S.canResize)return;let B=m1(_,L),F=editor.computeImageResizeResult({handle:B,startWidthEmu:S.widthEmu,startHeightEmu:S.heightEmu,startBounds:{x:S.x,y:S.y,width:S.width,height:S.height},startPosition:S.position,anchorFrameOrigin:S.anchorFrameOrigin,deltaXPt:_,deltaYPt:L,transform:S.transform,preserveAspect:editor.resizePreservesAspect(B,S.aspectLocked,T.shiftKey,S.textbox),kind:S.kind});n.exec({type:"setImageProperties",widthEmu:F.widthEmu,heightEmu:F.heightEmu,...F.position?.mode==="simple"?{horizontalEmu:F.position.horizontalEmu,verticalEmu:F.position.verticalEmu}:{},...F.position?.mode==="frame"?{...F.position.horizontalEmu!==void 0?{horizontalEmu:F.position.horizontalEmu}:{},...F.position.verticalEmu!==void 0?{verticalEmu:F.position.verticalEmu}:{}}:{}});return}if(S.kind!=="anchored"||!S.canMove||!S.position)return;let N=editor.computeMovedImagePosition(S.position,_,L);n.exec({type:"setImagePosition",...N});},[v,n]);Zt.useEffect(()=>{if(!l||!n?.surface)return;let T=n.surface.overlayCoordinates(),S=_=>{let L=m.current,N=u.current;if(!L||!N)return;let B=editor.cssPixelsToLayoutPoints(_.clientX-N.x,T.paintScale),F=editor.cssPixelsToLayoutPoints(_.clientY-N.y,T.paintScale);if(L.session.mode==="move"){let R=0,U=b.current,V=e.current?.closest(".docx-editor__scroll-container");if(U&&V){let j=V.getBoundingClientRect();_.clientY>j.bottom-A0?R=O0:_.clientY<j.top+A0&&(R=-O0),R!==0&&(R=U.scrollBy(R));}let Y=L.accumulatedScrollPt+R;s({...L,accumulatedScrollPt:Y,bounds:Object.freeze({...L.bounds,x:L.session.startBounds.x+B,y:L.session.startBounds.y+F+Y})});return}if(!L.session.handle)return;let D=editor.computeImageResizeResult({handle:L.session.handle,startWidthEmu:L.session.startWidthEmu,startHeightEmu:L.session.startHeightEmu,startBounds:L.session.startBounds,startPosition:L.session.startPosition,anchorFrameOrigin:L.session.anchorFrameOrigin,deltaXPt:B,deltaYPt:F,transform:L.session.transform,preserveAspect:editor.resizePreservesAspect(L.session.handle,L.bounds.aspectLocked,_.shiftKey,L.bounds.textbox),kind:L.session.kind});s({...L,bounds:Object.freeze({...L.bounds,x:D.previewBounds.x,y:D.previewBounds.y,width:D.previewBounds.width,height:D.previewBounds.height,widthEmu:D.widthEmu,heightEmu:D.heightEmu})});},P=_=>{let L=m.current;if(L)if(_.type==="pointerup"){let N=editor.cssPixelsToLayoutPoints(_.clientX-(u.current?.x??_.clientX),T.paintScale),B=editor.cssPixelsToLayoutPoints(_.clientY-(u.current?.y??_.clientY),T.paintScale),F=editor.finalizeImageOverlayInteraction({session:L.session,deltaXPt:N,deltaYPt:B,accumulatedScrollPt:L.accumulatedScrollPt,aspectLocked:L.bounds.aspectLocked,textbox:L.bounds.textbox,shiftKey:_.shiftKey,anchorFrameOrigin:L.session.anchorFrameOrigin});h(L.session,F.widthEmu,F.heightEmu,F.previewBounds,F.position);}else v();},w=editor.hostWindowOf(e.current);return w.addEventListener("pointermove",S),w.addEventListener("pointerup",P),w.addEventListener("pointercancel",P),()=>{w.removeEventListener("pointermove",S),w.removeEventListener("pointerup",P),w.removeEventListener("pointercancel",P);}},[v,h,e,n,l]),Zt.useEffect(()=>{!i||f.current!==i.id||(f.current=null,p.current?.focus({preventScroll:true}));},[i]);let E=l?.bounds??i,C=Zt.useMemo(()=>{if(!n?.surface||!E)return null;let T=n.surface.publishedLayout(),S=n.surface.overlayCoordinates(),P=editor.overlayFrameToSheetCssPixels(T,{pageIndex:E.pageIndex,x:E.x,y:E.y,width:E.width,height:E.height},S),w={left:P.left+c.left,top:P.top+c.top,width:P.width,height:P.height},_=E.canResize,L=E.kind==="anchored"&&E.canMove,N=editor.textboxFrameReason(E,n.surface.editingMode()),B=N?r(N):void 0;return jsxRuntime.jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":E.id,tabIndex:0,onKeyDown:k,children:[jsxRuntime.jsx("div",{className:`docx-image-selection-overlay__frame${L?" docx-editor-one-surface__overlay-control":""}`,"data-textbox":E.textbox?"true":void 0,title:B,"aria-description":B,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:L?"move":"default"},onPointerDown:F=>{$(F),!(!L||!E.position)&&F.button===0&&(F.preventDefault(),F.stopPropagation(),x("move",null,E,F.clientX,F.clientY,F.currentTarget,F.pointerId));}}),_?c1.map(F=>{let D=p1(F);return jsxRuntime.jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(d1(F)),tabIndex:0,style:{left:`calc(${w.left}px + ${w.width}px * ${parseFloat(D.x)/100} - 5px)`,top:`calc(${w.top}px + ${w.height}px * ${parseFloat(D.y)/100} - 5px)`,cursor:u1(F)},onPointerDown:R=>{$(R),R.button===0&&(R.preventDefault(),R.stopPropagation(),x("resize",F,E,R.clientX,R.clientY,R.currentTarget,R.pointerId));}},F)}):null]})},[E,x,n,k,c.left,c.top,r]);return !C||!t.current?null:reactDom.createPortal(C,t.current)}function dm(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Qs({className:e}){let t=A(),o=si(),n=Zt.useRef(null),r=Zt.useContext(Rr),i=Zt.useCallback(d=>{n.current=d,r?.setContainer(d);},[r]),a=Zt.useRef(null);Zt.useLayoutEffect(()=>{let d=n.current;if(!(!t||!d)){try{t.attach(d);}catch(m){if(t.snapshot().openFailure?.code!=="open.failed")throw m;console.error("[docx-editor] The document failed to open.",m);}return ()=>{t.detach();}}},[t]);let l=Zt.useCallback(d=>{if(!o?.isEnabled)return;let m=d.clipboardData;m&&dm(m)&&(editor.clipboardPasteLandsContent(m)||(d.preventDefault(),o.insertFromDataTransfer(m)));},[o]),s=Zt.useCallback(d=>{!o?.isEnabled||!dm(d.dataTransfer)||d.preventDefault();},[o]),c=Zt.useCallback(d=>{if(o?.isEnabled&&dm(d.dataTransfer)){if(editor.clipboardDropLandsText(d.dataTransfer)){if((editor.isElementNode(d.target)?d.target:null)?.closest("[contenteditable]")?.getAttribute("contenteditable")==="true")return;d.preventDefault();return}d.preventDefault(),o.insertFromDataTransfer(d.dataTransfer);}},[o]);return jsxRuntime.jsxs("div",{ref:a,className:"docx-content-mount",children:[jsxRuntime.jsx("div",{ref:i,className:`docx-paginated-surface${e?` ${e}`:""}`,onPaste:l,onDragOver:s,onDrop:c}),jsxRuntime.jsx(Vh,{}),jsxRuntime.jsx(u0,{}),jsxRuntime.jsx(I0,{}),t?jsxRuntime.jsx(cm,{containerRef:n,portalRef:a}):null]})}function pm({open:e,onClose:t,children:o,url:n,name:r,features:i,title:a,styles:l}){let[s,c]=Zt.useState(null),{dir:d}=H(),m=Ut(),u=Zt.useRef(t);u.current=t;let g=Zt.useRef({url:n,name:r,features:i,title:a,styles:l});g.current={url:n,name:r,features:i,title:a,styles:l};let p=Zt.useRef(null);return Zt.useEffect(()=>{if(!e)return;let f=p.current;if(f)f.claimed=true;else {let{url:x,name:h,features:k,title:E,styles:C}=g.current;f={claimed:true,promise:editor.openEditorWindow({...x!==void 0?{url:x}:{},...h!==void 0?{name:h}:{},...k!==void 0?{features:k}:{},...E!==void 0?{title:E}:{},...C!==void 0?{styles:C}:{}})},p.current=f;}let b=f,y=true,v;return b.promise.then(x=>{if(y){if(!x){p.current=null,u.current?.();return}v=x.onClose(()=>{y&&(p.current=null,reactDom.flushSync(()=>c(null)),u.current?.());}),c(x);}}),()=>{y=false,v?.(),b.claimed=false,c(null),queueMicrotask(()=>{b.claimed||(p.current===b&&(p.current=null),b.promise.then(x=>x?.close()));});}},[e]),!s||!e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:o}):reactDom.createPortal(jsxRuntime.jsx("div",{className:`docx-editor${m?" dark":""}`,style:{height:"100%"},dir:d,children:o}),s.element)}function $e(e){return e/1440*96}function ec(e){return e/96*1440}function _t(e){return `${Math.round(e*100)/100}px`}function mm(e){return e/2}var N1=e=>e.isLoading||e.isOpening===true,F1=e=>({width:$e(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:$e(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),L1=(e,t)=>e.width===t.width&&e.height===t.height;function fm({className:e}){return jsxRuntime.jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}var K0=false;function q0(){K0||!xt()||(K0=true,console.warn("[docx-editor] loadingIndicator is ignored with chrome={false}, which renders no loading screen. Compose <DocxEditor.Loading overlay indicator={...} /> in a positioned box instead."));}function H1(e){let t=A(),[o,n]=Zt.useState(null);return Zt.useEffect(()=>{if(!(!t||!e))return t.setOpeningIndicatorHost({publish:n}),()=>{t.setOpeningIndicatorHost(null),n(null);}},[t,e]),o}function A1({when:e=false,overlay:t=false,className:o,style:n,indicator:r,children:i}){let a=W(N1),l=W(F1,L1),s=H1(t),c=A(),d=Zt.useRef({visible:false,editor:null}),[,m]=Zt.useReducer(v=>v+1,0),u=d.current.visible&&d.current.editor!==c,g=s===null&&(e||a||u);Zt.useLayoutEffect(()=>{d.current={visible:g,editor:c},u&&m();},[g,c,u]);let{t:p}=H(),f=Ut(),b=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(fm,{}),jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:p("loading.label")})]});if(s)return reactDom.createPortal(b,s);if(!g)return null;let y=`docx-editor${f?" dark":""} docx-editor__loading${t?" docx-editor__loading--overlay":""}${o?` ${o}`:""}`;return jsxRuntime.jsx("div",{className:y,style:n,role:"status","aria-live":"polite",children:i??jsxRuntime.jsx("div",{className:"docx-paginated-surface docx-editor__loading-surface",style:{width:l.width,height:l.height},children:jsxRuntime.jsx("div",{className:"docx-pages",children:jsxRuntime.jsx("div",{className:"docx-page docx-editor__loading-page",children:jsxRuntime.jsx("div",{className:"docx-editor__loading-page-status",children:b})})})})})}var tc=Object.assign(A1,{Spinner:fm});function U0(){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,f)=>(o.get(p[0])??0)-(o.get(f[0])??0));for(let[,{author:p,style:f}]of g)u[p]=f;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,f])=>`${p}\0${JSON.stringify(f)}`).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 m(){!r||s||(s=true,queueMicrotask(()=>{s=false,d();}));}return {registerScheme(u){e.add(u),m();},register(u,g,p){o.has(u)||o.set(u,n++),t.set(u,{author:g,style:p}),m();},unregister(u){(e.delete(u)||t.delete(u))&&m();},connect(u){r=u;let g=a();i=u!==null&&g!==void 0,l=u===null?null:c(g),m();},current:a}}var Hi=Zt.createContext(null);function V0(){let e=Zt.useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function gm(){let e=Zt.useContext(Hi),t=V0();return Zt.useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function bm(e){let{author:t,color:o,background:n,activeBackground:r,spanClassName:i,avatarUrl:a}=e,l=Zt.useContext(Hi),s=V0();return Zt.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}var G0=false;function j0(e,t){e===t||G0||!xt()||(G0=true,console.warn("[docx-editor] fieldResults changed after the editor was created, so the change is ignored. The editor reads fieldResults once; create a new editor to change it."));}var Y0=false,X0=e=>e?.allowFormattingInLockedContent===true;function J0(e,t){X0(e)===X0(t)||Y0||!xt()||(Y0=true,console.warn("[docx-editor] contentLockPolicy changed after the editor was created, so the change is ignored. The editor reads contentLockPolicy once; create a new editor to change it."));}var Q0=false;function ey(e){return e===void 0?"characters":e}function ty(e,t){ey(e)===ey(t)||Q0||!xt()||(Q0=true,console.warn("[docx-editor] lockedControlNavigation changed after the editor was created, so the change is ignored. The editor reads lockedControlNavigation once; create a new editor to change it."));}function V1(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 G1(e){let t=Zt.useRef(e);t.current=e;let[o,n]=Zt.useState(null),{onReady:r,onChange:i,onFontError:a,onRevisionMarkupChange:l,...s}=e,c=Zt.useMemo(()=>({onReady:d=>{n(d),t.current.onReady?.(d);},onChange:d=>t.current.onChange?.(d),onFontError:d=>t.current.onFontError?.(d),onRevisionMarkupChange:d=>t.current.onRevisionMarkupChange?.(d)}),[]);return {DocxEditorRoot:Ai,rootProps:s,rootListeners:c,editorRef:o}}function Ai(e){let{document:t,fonts:o,fontShaping:n,author:r,locale:i,translate:a,mode:l,zoom:s,zoomMode:c,tableInteractionLabel:d,imageDecodePort:m,colorMode:u,children:g}=e,p=Ul(u),{t:f}=H(),b=Zt.useCallback((K,de)=>f(K,de),[f]),y=Zt.useRef(b);y.current=b;let v=Zt.useRef(false),[x,h]=Zt.useState(0),k=Zt.useRef(e);k.current=e;let E=n?.maxFontBytes,[C,T]=Zt.useState(null),S=Zt.useRef(e.fieldResults),P=Zt.useRef(e.contentLockPolicy),w=Zt.useRef(e.lockedControlNavigation),_=Zt.useRef(e.fonts),L=Zt.useRef(null);L.current??=U0();let N=L.current,B=Zt.useRef(null);B.current??=fg();let F=B.current;Zt.useEffect(()=>{let K=k.current,de=K.translate??y.current,ke=N.current();S.current=K.fieldResults,P.current=K.contentLockPolicy,w.current=K.lockedControlNavigation;let Ze=editor.createDocxEditor({unsupportedElementRules:F.current(),...K.document!==void 0?{document:K.document}:{},...K.fonts?{fonts:K.fonts}:{},...K.fontShaping?{fontShaping:K.fontShaping}:{},...K.author!==void 0?{author:K.author}:{},...K.locale!==void 0?{locale:K.locale}:{},translate:de,...K.revisionMarkup!==void 0?{revisionMarkup:K.revisionMarkup}:{},...K.reviewDisplayMode!==void 0?{reviewDisplayMode:K.reviewDisplayMode}:{},...K.fieldResults!==void 0?{fieldResults:K.fieldResults}:{},...K.contentLockPolicy!==void 0?{contentLockPolicy:K.contentLockPolicy}:{},...K.lockedControlNavigation!==void 0?{lockedControlNavigation:K.lockedControlNavigation}:{},...K.mode!==void 0?{mode:K.mode}:{},...ke!==void 0?{revisionStyles:ke}:{},...K.modules!==void 0?{modules:K.modules}:{},...K.zoom!==void 0?{zoom:K.zoom}:{},...K.zoomMode!==void 0?{zoomMode:K.zoomMode}:{},...K.tableInteractionLabel?{tableInteractionLabel:K.tableInteractionLabel}:{},...K.imageDecodePort?{imageDecodePort:K.imageDecodePort}:{},onFontError:Ye=>k.current.onFontError?.(Ye)});_.current=K.fonts;let at=Ze.on("revisionMarkupChange",Ye=>{v.current||(k.current.onRevisionMarkupChange?.(Ye),h(Wn=>Wn+1));}),Ce=Ze.on("change",Ye=>k.current.onChange?.(Ye));return T(Ze),()=>{at(),Ce(),Ze.destroy(),T(Ye=>Ye===Ze?null:Ye);}},[t,E,m,N,F]),Zt.useEffect(()=>{!C||_.current===o||(_.current=o,C.setFonts(o).catch(()=>{}));},[C,o]),Zt.useEffect(()=>{if(!C)return;if(!C.snapshot().isOpening){k.current.onReady?.(C);return}let K=C.on("change",()=>{K(),k.current.onReady?.(C);});return K},[C]);let D=Zt.useRef({editor:null,zoom:void 0,mode:void 0});Zt.useEffect(()=>{if(!C)return;D.current.editor!==C&&(D.current={editor:C,zoom:void 0,mode:void 0});let de=false;s!==void 0&&s!==D.current.zoom&&(D.current.zoom=s,C.setZoom(s),de=true);let ke=D.current.mode,Ze=c!==void 0&&(ke===void 0||!V1(ke,c)),at=c===void 0?null:editor.resolveZoomMode(c),Ce=de&&c!==void 0&&at!==null&&at.type==="fit";(Ze||Ce)&&(D.current.mode=c,C.setZoomMode(c));},[C,s,c]),Zt.useEffect(()=>{if(!C||e.revisionMarkup===void 0)return;let K=editor.resolveRevisionMarkup(e.revisionMarkup);if(JSON.stringify(K)!==JSON.stringify(C.snapshot().revisionMarkup)){v.current=true;try{C.setRevisionMarkup(K);}finally{v.current=false;}}},[C,e.revisionMarkup,x]),Zt.useEffect(()=>{C&&C.setAuthor(r);},[C,r]);let R=Zt.useRef({editor:null,value:void 0});Zt.useEffect(()=>{if(C){if(R.current.editor!==C){R.current={editor:C,value:l};return}R.current.value!==l&&(R.current.value=l,C.setMode(l));}},[C,l]),Zt.useEffect(()=>{C&&C.setTranslate(a??b);},[C,a,b]),Zt.useEffect(()=>{C&&C.setLocale(i);},[C,i]),Zt.useEffect(()=>{C&&j0(S.current,e.fieldResults);},[C,e.fieldResults]),Zt.useEffect(()=>{C&&J0(P.current,e.contentLockPolicy);},[C,e.contentLockPolicy]),Zt.useEffect(()=>{C&&ty(w.current,e.lockedControlNavigation);},[C,e.lockedControlNavigation]),Zt.useEffect(()=>{C&&C.setTableInteractionLabel(d??editor.defaultTableLabel);},[C,d]);let[U,V]=Zt.useState(0),[Y,j]=Zt.useState(0),q=Zt.useRef([]),[X,ee]=Zt.useState(0),O=X>0,I=Zt.useRef(C);I.current=C,Zt.useEffect(()=>{if(!(!C||!O))return C.setCommentDraftChrome({onRequest:()=>q.current.at(-1)?.()})},[C,O]);let ie=Zt.useMemo(()=>({mounted:U,register:()=>(V(K=>K+1),()=>V(K=>Math.max(0,K-1))),gutters:Y,reserveGutter:()=>(j(K=>K+1),()=>j(K=>Math.max(0,K-1))),registerCommentDraft:K=>(q.current.push(K),ee(de=>de+1),()=>{let de=q.current.indexOf(K);de!==-1&&(q.current.splice(de,1),ee(ke=>Math.max(0,ke-1)));}),requestCommentDraft:()=>{let K=I.current;return K!==null&&editor.runToolbarCommand(K,"review.addComment").ok}}),[U,Y]),ge=Zt.useMemo(Lg,[]);return Zt.useEffect(()=>(N.connect(C),()=>N.connect(null)),[N,C]),Zt.useEffect(()=>(F.connect(C),()=>F.connect(null)),[F,C]),jsxRuntime.jsx(qn.Provider,{value:p,children:jsxRuntime.jsx(Rr.Provider,{value:F,children:jsxRuntime.jsx(Kh,{value:a??b,children:jsxRuntime.jsx(At.Provider,{value:ie,children:jsxRuntime.jsx(Bd.Provider,{value:C,children:jsxRuntime.jsx(Yd.Provider,{value:ge,children:jsxRuntime.jsx(Hi.Provider,{value:N,children:jsxRuntime.jsx(j1,{children:jsxRuntime.jsx(Y1,{children:jsxRuntime.jsx(d0,{value:e.popups,children:jsxRuntime.jsx(cs,{children:jsxRuntime.jsx(zh,{popups:e.popups,children:g})})})})})})})})})})})})}function j1({children:e}){let[t,o]=Zt.useState(0),n=Zt.useCallback(()=>(o(i=>i+1),()=>o(i=>i-1)),[]),r=Xl(t>0);return jsxRuntime.jsx(cu.Provider,{value:n,children:jsxRuntime.jsx(Ya.Provider,{value:r,children:e})})}function Y1({children:e}){let t=Ql();return jsxRuntime.jsx(Tu.Provider,{value:t,children:e})}var Oi=316,xa=editor.REVIEW_MARKERS_GUTTER_PX,iy=24,oc={inlineStart:0,inlineEnd:Oi},ny={inlineStart:xa,inlineEnd:xa},a2={inlineStart:0,inlineEnd:0},xm={inlineStart:iy,inlineEnd:Oi};function i2(e){return e.inlineStart===xm.inlineStart&&e.inlineEnd===xm.inlineEnd}function ly(e,t){return i2(e)?Math.max(0,t-(Oi-xa)):t}function nc(){let e=lt(),t=we(),[o,n]=Zt.useState("ltr");return Zt.useLayoutEffect(()=>{let r=t?.parentElement;if(e||!r)return;let i=()=>n(editor.hostDirectionOf(r));return i(),editor.observeHostDirection(r,i)},[e,t]),(e??o)==="rtl"?"left":"right"}function sy(e,t){return t==="left"?{left:e.inlineEnd,right:e.inlineStart}:{left:e.inlineStart,right:e.inlineEnd}}function cy({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:n=0,docked:r=false,scroll:i=false}){if(!e)return ny;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return oc;let a=Number.isFinite(n)&&n>0?n:0;return t-a-o-2*iy>=Oi?oc:i?xm:ny}var l2=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,reviewPaneOpen:e.reviewPaneOpen??true,entitledZoom:editor.reviewPaneEntitledZoom(t,e.zoom,e.reviewPane.overflow),scroll:e.reviewPane.overflow==="scroll"}},s2=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.scroll===t.scroll&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function dy(){let e=we(),[t,o]=Zt.useState(null);return Zt.useEffect(()=>{if(!e){o(null);return}let n=()=>o(e.clientWidth);n();let r=editor.hostWindowOf(e).ResizeObserver;if(typeof r>"u")return;let i=new r(n);return i.observe(e),()=>i.disconnect()},[e]),t}function En(){let e=Zt.useContext(At),{pageSetup:t,reviewPaneOpen:o,entitledZoom:n,scroll:r}=W(l2,s2),i=we(),a=Ag(),l=Zt.useRef(null);t&&(l.current=t.pageWidthTwips);let s=t?.pageWidthTwips??l.current,c=Wl(e),d=Zt.useCallback(f=>c?cy({open:o,viewportWidth:f??0,pageWidthPx:s===null||n===null?0:$e(s)*n,inlineStartReservation:a,docked:n===null,scroll:r}):a2,[c,o,s,n,a,r]),m=()=>d(i?i.clientWidth:null),[u,g]=Zt.useState(()=>({compute:d,viewport:i,gutter:m()})),p=u;return (u.compute!==d||u.viewport!==i)&&(p={compute:d,viewport:i,gutter:m()},g(p)),Zt.useEffect(()=>{let f=i?editor.hostWindowOf(i).ResizeObserver:void 0;if(!i||typeof f>"u")return;let b=()=>g(v=>{let x=d(i.clientWidth);return x===v.gutter?v:{compute:d,viewport:i,gutter:x}}),y=new f(b);return y.observe(i),()=>y.disconnect()},[i,d]),p.gutter}var rc=[.25,.5,.75,1,1.25,1.5,2];function Bi(e,t){return t==="in"?rc.find(n=>n>e+.001)??null:[...rc].reverse().find(n=>n<e-.001)??null}function uy(e,t){return e==="0"?1:e==="+"||e==="="?Bi(t,"in")??t:e==="-"?Bi(t,"out")??t:null}var Cm=Zt.createContext(false);function py(e){let t=Zt.useContext(Cm),[o,n]=Zt.useState(null);return Zt.useLayoutEffect(()=>{let r=t?e?.parentElement??null:null;n(r?{host:r,scoped:r.closest(".docx-editor")!==null}:null);},[t,e]),{inside:t,host:o?.host??null,hostScoped:o?.scoped??false}}var b2=e=>e.reviewPaneOpen??true,h2=e=>e.zoomMode?.type==="fit";function ac({className:e,style:t,children:o}){let{t:n}=H(),r=$t(),i=A(),a=W(b2),l=En(),s=nc(),c=W(h2),d=Zt.useContext(At),m=Wl(d),u=$n(),g=zn(),p=Zt.useRef(null),f=Zt.useCallback(y=>{p.current=y,u?.setViewport(y);},[u]),b=Zt.useCallback(y=>{if(!i||!(y.metaKey||y.ctrlKey)||y.altKey)return;let v=y.target;if(editor.isElementNode(v)&&v.closest('input, textarea, select, [role="dialog"]'))return;let x=uy(y.key,i.getZoom());x!==null&&(y.preventDefault(),i.setZoom(x));},[i]);return jsxRuntime.jsx("div",{ref:f,"data-testid":"docx-editor-scroll",tabIndex:0,role:"region","aria-label":n("editor.documentViewport"),onKeyDownCapture:b,...m?{"data-review-pane":a?"open":"closed"}:{},...s==="left"?{"data-chrome-dir":"rtl"}:{},...m&&s==="left"?{"data-review-side":"left"}:{},...c?{"data-zoom-fit":""}:{},className:`${r}docx-editor-one-surface docx-editor-one-surface__viewport docx-editor__scroll-container${e?` ${e}`:""}`,style:{...t,"--docx-nav-shift":`${g}px`,...m?{"--docx-review-gutter":`${l.inlineEnd}px`,"--docx-review-gutter-start":`${l.inlineStart}px`,"--docx-review-strip":`${2*xa}px`}:{}},children:jsxRuntime.jsx(Wo.Provider,{value:true,children:jsxRuntime.jsx(Cm.Provider,{value:true,children:o})})})}var x2=editor.LOADING_SNAPSHOT;function fy({ref:e,editorRef:t}){Zt.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)??x2}),[t]);}function va(e,t,o,n){let r=we(),i=Zt.useRef({close:o,skip:n,viewport:r});i.current={close:o,skip:n,viewport:r},Zt.useEffect(()=>{let a=t.current;if(!e||!a)return;let l=d=>a.contains(d),s=editor.listenForPopupEscape({popup:a,contains:l,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current.viewport],skip:d=>i.current.skip?.(d)===true,close:d=>i.current.close(d)}),c=editor.listenForPopupFocusLeave({popup:a,contains:l,close:()=>i.current.close(false)});return ()=>{s(),c();}},[e,t]);}var M2=e=>e.editingMode??"editing",Sm='[role="menuitemradio"]:not([disabled])',_2=(e,t)=>e.length===t.length&&e.every((o,n)=>o===t[n]),I2=e=>e.isLoading||e.isOpening===true,Wi=[{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"}],N2=Object.freeze(Wi.map(()=>null));function F2(e){return e?Wi.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):N2}var L2="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function lc({className:e,hidden:t}){let o=A(),n=W(M2),r=W(I2),i=ae(),{t:a}=H(),[l,s]=Zt.useState(false),c=Zt.useRef(null),d=Zt.useRef(null),m=Zt.useRef(null);Zt.useEffect(()=>{if(!l)return;let x=m.current?.querySelectorAll(Sm);(m.current?.querySelector(`${Sm}[aria-checked="true"]`)??x?.[0]??void 0)?.focus();},[l]);let u=Zt.useCallback(x=>{let h=[...m.current?.querySelectorAll(Sm)??[]],k=h.indexOf(editor.hostDocumentOf(m.current).activeElement),E=C=>{x.preventDefault(),h[(C+h.length)%h.length]?.focus();};x.key==="ArrowDown"?E(k+1):x.key==="ArrowUp"?E(k-1):x.key==="Home"?E(0):x.key==="End"&&E(h.length-1);},[]);Zt.useEffect(()=>{if(l)return editor.listenForOutsidePress({popup:c.current,close:()=>s(false)})},[l]),va(l,c,x=>{s(false),x&&d.current?.focus();});let g=Zt.useCallback(x=>{s(false),editor.runToolbarCommand(o,"review.editingMode",x),o?.focus();},[o]),p=editor.toolbarCommandState(o,"review.editingMode"),f=i18n.localizeDisabledReason(p.disabledReason,a),b=W(()=>F2(o),_2),y=Zt.useMemo(()=>Wi.find(x=>x.mode===n)??Wi[0],[n]);if(t)return null;let v=te("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(v?.labelKey??"editingMode.label"),disabled:r||!p.enabled,...f?{title:f}:{},onMouseDown:$,onClick:()=>s(x=>!x),children:[Pm(y.path),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:i(y.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsxRuntime.jsx("div",{ref:m,className:"docx-toolbar__mode-menu",role:"menu","aria-label":i(v?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:Wi.map((x,h)=>{let k=i18n.localizeDisabledReason(b[h]??null,a);return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":x.mode===n,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${x.mode}`,disabled:k!==null,...k?{title:k}:{},onMouseDown:$,onClick:()=>g(x.mode),children:[Pm(x.path),jsxRuntime.jsxs("span",{className:"docx-toolbar__mode-text",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__mode-label",children:i(x.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-hint",children:i(x.hintKey)})]}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:x.mode===n?Pm(L2):null})]},x.mode)})}):null]})}lc.docxSlot="review.editingMode";function Pm(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 yy=[],O2=()=>{};function Zi(){let e=A(),t=Zt.useCallback(o=>{if(!e)return O2;let n=Za(o),r=e.on("change",n),i=e.on("selectionChange",n);return ()=>{r(),i();}},[e]);return Zt.useSyncExternalStore(t,()=>e?.getReviewAuthors()??yy,()=>yy)}var z2=e=>e.hiddenReviewAuthors??[];function cc({className:e,hidden:t,icon:o}){let n=A(),r=Zi(),i=W(z2),a=new Set(i),l=r.every(h=>!a.has(h.author)),[s,c]=Zt.useState(false),d=Zt.useRef(null),m=Zt.useRef(null),u=Zt.useRef(null),g=ae(),{t:p}=H();Zt.useEffect(()=>{if(s)return u.current?.querySelector('[role="menuitemcheckbox"]')?.focus(),editor.listenForOutsidePress({popup:d.current,close:()=>c(false)})},[s]),va(s,d,h=>{c(false),h&&m.current?.focus();});let f=Zt.useCallback(h=>{let k=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],E=k.indexOf(editor.hostDocumentOf(u.current).activeElement),C=T=>{h.preventDefault(),k[(T+k.length)%k.length]?.focus();};h.key==="ArrowDown"?C(E+1):h.key==="ArrowUp"?C(E-1):h.key==="Home"?C(0):h.key==="End"?C(k.length-1):h.key==="Tab"&&c(false);},[]);if(t)return null;let b=te("review.authors"),y=editor.toolbarCommandState(n,"review.authors"),v=i18n.localizeDisabledReason(y.disabledReason,p),x=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:m,type:"button",className:"docx-toolbar__picker","data-testid":"reviewers-trigger","aria-haspopup":"menu","aria-expanded":s,"aria-label":x,disabled:!y.enabled,title:v??x,onMouseDown:$,onClick:()=>c(h=>!h),children:[o??oe(b?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:x}),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":x,"data-testid":"reviewers-menu",onKeyDown:f,children:[jsxRuntime.jsx(xy,{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(h=>jsxRuntime.jsx(xy,{checked:!a.has(h.author),label:h.author||"\u2014",testId:`reviewer-${h.slot}`,color:h.color,onChoose:()=>n?.setReviewAuthorVisible(h.author,a.has(h.author))},h.author))]}):null]})}cc.docxSlot="review.authors";function xy(e){return jsxRuntime.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e.checked,className:"docx-toolbar__reviewer-item","data-testid":e.testId,onMouseDown:$,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 Cy=Zt.createContext(null);function Ty({children:e}){let t=_o(),[o,n]=Zt.useState(false),r=Zt.useRef(null),i=we(),a=Zt.useRef(i);a.current=i;let l=Zt.useMemo(()=>({open:c=>{if(t){t.open("paragraph",c);return}r.current=c??editor.hostDocumentOf(a.current).activeElement,n(true);}}),[t]),s=Zt.useCallback(()=>{n(false);let c=r.current;r.current=null,editor.isHTMLElementNode(c)&&c.isConnected&&c.focus({preventScroll:true});},[]);return jsxRuntime.jsxs(Cy.Provider,{value:l,children:[e,jsxRuntime.jsx(Vo,{open:o,onClose:s})]})}function Ey(){return Zt.useContext(Cy)}var wm=["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"],Dm=Zt.createContext({close:()=>{}});function Ca(){return Zt.useContext(Dm).close}function m_(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function wy({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 Dy({slot:e}){let t=ae(),o=eo(),{close:n}=Zt.useContext(Dm),{execute:r,isActive:i,isEnabled:a,disabledReason:l,value:s}=re(e),c=te(e),d=editor.chromeSlotIsToggle(e),m=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:$,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:m})]})}function Ry({sections:e,className:t}){let o=ae(),[n,r]=Zt.useState(false),i=Zt.useRef(null),a=Zt.useRef(null),l=Zt.useRef(null),s=Zt.useRef(false),c=Zt.useId(),d=we(),m=Zt.useRef(d);m.current=d;let u=o("formattingBar.more"),g=Zt.useCallback(v=>{r(false),v&&a.current?.focus();},[]),p=Zt.useMemo(()=>({close:g}),[g]);Zt.useEffect(()=>{if(!n)return;let v=i.current,x=C=>i.current?.contains(C)===true||l.current?.contains(C)===true,h=v?editor.listenForPopupEscape({popup:v,contains:x,chromeRoot:()=>i.current?.closest(".docx-editor"),editorElements:()=>[m.current],skip:()=>editor.hasOpenNestedPopup(l.current),close:g}):void 0,k=v?editor.listenForPopupFocusLeave({popup:v,contains:x,close:()=>r(false)}):void 0,E=editor.listenForOutsidePress({popup:v,close:()=>r(false)});return ()=>{E(),h?.(),k?.();}},[n,g]);let[f,b]=Zt.useState(null);Zt.useLayoutEffect(()=>{if(!n){b(null);return}let v=()=>{let h=i.current,k=l.current,E=a.current,C=h?.ownerDocument.defaultView;if(!h||!k||!E||!C)return;let T=E.getBoundingClientRect(),S=editor.toolbarPanelPlacement({triggerLeft:T.left,triggerRight:T.right,panelWidth:k.offsetWidth,viewportWidth:C.innerWidth}),P=S.left-h.getBoundingClientRect().left;b(w=>w&&w.left===P&&w.maxWidth===S.maxWidth&&w.anchor===S.anchor?w:{...S,left:P});};v();let x=i.current?.ownerDocument.defaultView;return x?.addEventListener("resize",v),()=>x?.removeEventListener("resize",v)},[n]),Zt.useEffect(()=>{if(!n||!s.current)return;s.current=false;let v=l.current;v&&m_(v);},[n]);let y=v=>{v.key!=="Escape"||v.defaultPrevented||(v.preventDefault(),g(true));};return jsxRuntime.jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[rs]:"",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":u,title:u,...n?{"data-active":""}:{},onMouseDown:$,onClick:()=>r(v=>!v),onKeyDown:v=>{v.key==="ArrowDown"&&(v.preventDefault(),s.current=true,r(true));},children:oe(wm)}),n?jsxRuntime.jsx(Dm.Provider,{value:p,children:jsxRuntime.jsx("div",{ref:l,id:c,role:"dialog","aria-label":u,className:"docx-toolbar__more-panel","data-testid":"toolbar-overflow-panel",...f?{"data-anchor":f.anchor}:{},style:f?{left:f.left,right:"auto",maxInlineSize:f.maxWidth}:void 0,onKeyDown:y,children:e.map(v=>jsxRuntime.jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":v.label??o(v.labelKey),children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:v.label??o(v.labelKey)}),v.children]},v.id))})}):null]})}function g_(e){if(!Zt.isValidElement(e))return false;let t=e.type;return (typeof t=="function"||typeof t=="object")&&t.docxToolbarGroup===true}function _y(e,t,o,n){let r=new Map,i=new Map,a=new Map,l=[];for(let s of Zt.Children.toArray(e)){if(g_(s)){a.delete(s.props.id),a.set(s.props.id,s.props);continue}let c=t(s);if(c&&o(c))r.set(c,s);else if(c&&n(c))i.set(c,s);else {if(c&&Zt.isValidElement(s)&&s.props.hidden===true)continue;l.push(s);}}return {overrides:r,tableOverrides:i,groups:[...a.values()],appended:l}}var uc="review.addComment";function h_({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=Zt.useContext(At),a=ae(),{isEnabled:l,reason:s}=ts(a),c=Ca();if(t||(i?.mounted??0)===0)return null;let d=te(uc),m=a(d?.labelKey??uc),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":uc,disabled:!l,...l?{}:{"data-disabled":""},"aria-label":m,title:s??m,onMouseDown:$,onClick:()=>{i?.requestCommentDraft()&&c(false);}};return n?jsxRuntime.jsx(Q,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??oe(d?.paths)})}var Rm=Object.assign(h_,{docxSlot:uc});var Ny=new Set;function pc(e){!xt()||Ny.has(e)||(Ny.add(e),console.warn(`[docx-editor] ${e}`));}function Fy(e,t,o){pc(`Toolbar.Group "${e}" has after="${t}", but no group has that id. The group is placed after every other group. Known ids: ${o.join(", ")}.`);}function Ly(e,t){pc(`Toolbar.Group "${e}" is a built-in group, so its ${t} is ignored. A built-in group keeps its own label and place in the bar.`);}function Hy(e){pc(`Toolbar.Group "${e}" uses the id of the contextual table group, so it is ignored. Give the group another id.`);}function Ay(e,t){pc(t?`Toolbar slot "${e}" is not part of the preset arrangement, so its content is appended after the groups. Put it in a Toolbar.Group to give it a place.`:`"${e}" is not a toolbar slot id. Its content is appended after the groups. Use a ChromeSlotId such as "text.bold".`);}var _m=[{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 mc({className:e,hidden:t,asChild:o,children:n}){let{t:r}=H(),i=ae(),{execute:a,value:l,isEnabled:s,disabledReason:c}=Mi("image.wrap"),[d,m]=Zt.useState(false),u=Zt.useRef(null),g=Zt.useRef(null),p=Zt.useRef(null),f=Zt.useId(),b=bn(o,n),y=Zt.useMemo(()=>_m.find(C=>C.value===l)??_m[0],[l]),v=te("image.wrap"),x=i(v?.labelKey??"formattingBar.imageWrap");Zt.useEffect(()=>{if(!d)return;let C=P=>{let w=u.current;w&&editor.isDomNode(P.target)&&w.contains(P.target)||m(false);},T=P=>{P.key==="Escape"&&(P.preventDefault(),m(false),g.current?.focus());},S=editor.hostDocumentOf(u.current);return S.addEventListener("mousedown",C,true),S.addEventListener("keydown",T),()=>{S.removeEventListener("mousedown",C,true),S.removeEventListener("keydown",T);}},[d]);let h=Zt.useCallback(C=>{m(false),a(C);},[a]);if(t)return null;let k=r("imageWrap.tooltipPrefix",{label:r(y.labelKey)}),E={type:"button",ref:g,className:`${hn(b)} 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?f:void 0,"aria-label":x,title:c??k,onMouseDown:$,onClick:()=>m(C=>!C)};return jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsxRuntime.jsx(Q,{...E,children:n}):jsxRuntime.jsx("button",{...E,children:b?jsxRuntime.jsx(yn,{icon:oe(v?.paths),label:x}):n??oe(v?.paths)}),d?jsxRuntime.jsx("div",{ref:p,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:C=>C.stopPropagation(),children:_m.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:$,onClick:()=>h(C.value),children:r(C.labelKey)},C.value))}):null]})}mc.docxSlot="image.wrap";var Ui=Object.assign(mc,{docxSlot:"image.wrap"});var Ta="table.insert";function N_({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=A(),{isEnabled:a,disabledReason:l}=re(Ta),s=ae(),[c,d]=Zt.useState(false),m=Zt.useRef(null),u=Zt.useRef(null),g=Zt.useRef(null),p=Zt.useId(),f=Ca();Zt.useEffect(()=>{if(!(!c||!m.current))return editor.listenForOutsidePress({popup:m.current,close:()=>d(false)})},[c]),Zt.useEffect(()=>{c&&m.current?.querySelector('[role="gridcell"][tabindex="0"]')?.focus();},[c]);let b=c&&a;Zt.useLayoutEffect(()=>{let k=g.current,E=m.current,C=E?.ownerDocument.defaultView;if(!b||!k||!E||!C||E.closest(".docx-toolbar__more-panel"))return;let T=E.getBoundingClientRect(),S=editor.toolbarPopupLeft({anchorLeft:T.left,popupWidth:k.offsetWidth,viewportWidth:C.innerWidth});k.style.left=`${S-T.left}px`;},[b]);let y=Zt.useCallback(()=>{d(false),f(false);},[f]);if(t)return null;let v=te(Ta),x=s(v?.labelKey??Ta),h={ref:u,type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Ta,disabled:!a,...a?{}:{"data-disabled":""},...b?{"data-active":""}:{},"aria-haspopup":"grid","aria-expanded":b,"aria-controls":b?p:void 0,"aria-label":x,title:l??x,onMouseDown:$,onClick:()=>{if(!c){d(true);return}d(false),i?.focus();},onKeyDown:k=>{k.key==="ArrowDown"&&(k.preventDefault(),d(true));}};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__table-insert",children:[n?jsxRuntime.jsx(Q,{...h,children:r}):jsxRuntime.jsx("button",{...h,children:o??r??oe(v?.paths)}),b?jsxRuntime.jsx("div",{ref:g,id:p,className:"docx-toolbar__menu docx-toolbar__table-insert-menu",onBlur:k=>{let E=k.relatedTarget;editor.isDomNode(E)&&!m.current?.contains(E)&&d(false);},onKeyDown:k=>{k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),d(false),u.current?.focus());},children:jsxRuntime.jsx(ps,{slot:Ta,label:s("toolbar.insertTable"),onInserted:y})}):null]})}var Nm=Object.assign(N_,{docxSlot:Ta});function nt(e){return Object.assign(o=>jsxRuntime.jsx(Ko,{slotId:e,...o}),{docxSlot:e})}var By=nt("history.undo"),Wy=nt("history.redo"),Zy=nt("text.bold"),Ky=nt("text.italic"),qy=nt("text.underline"),Uy=nt("text.strike"),$y=nt("format.clear"),zy=nt("script.super"),Vy=nt("script.sub"),Gy=nt("alignment.left"),jy=nt("alignment.center"),Yy=nt("alignment.right"),Xy=nt("alignment.justify"),Jy=nt("direction.ltr"),Qy=nt("direction.rtl"),ex=nt("list.bullet"),tx=nt("list.numbered"),ox=nt("list.outdent"),nx=nt("list.indent");var rx=nt("review.comments");function H_({className:e,hidden:t,icon:o,asChild:n,children:r}){let{execute:i,isEnabled:a,disabledReason:l}=re("text.link"),s=ae(),c=eo();if(t)return null;let d=te("text.link"),m=c(s(d?.labelKey??"text.link")),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!a,...a?{}:{"data-disabled":""},"aria-label":m,title:l??m,onMouseDown:$,onClick:()=>i()};return n?jsxRuntime.jsx(Q,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??oe(d?.paths)})}var Fm=Object.assign(H_,{docxSlot:"text.link"});function A_({className:e,hidden:t}){let o=A(),{onSave:n}=Zt.useContext(Vn),r=ae();if(t)return null;let i=te("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:$,onClick:()=>n?.(),children:oe(i?.paths)})}var Lm=Object.assign(A_,{docxSlot:"file.save"});function dr({className:e}){return jsxRuntime.jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}var W_=e=>({zoom:e.zoom,mode:e.zoomMode}),Z_=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,ix={type:"fixed"};function Hm(){let e=A(),{zoom:t,mode:o}=W(W_,Z_),n=Zt.useCallback(i=>{e?.setZoom(i);},[e]),r=Zt.useCallback(i=>{e?.setZoomMode(i);},[e]);return Zt.useMemo(()=>{let i=o??ix,a=Bi(t,"out"),l=Bi(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(ix),n(1);},zoomIn:()=>l!==null&&n(l),zoomOut:()=>a!==null&&n(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:rc}},[e,t,o,n,r])}var Vi=2,Gi=3276,zi=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],$_=e=>e.formatting?.fontSizePt??null;function cx(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function dx(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 mx(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:$,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:$,onClick:e.onIncrease,children:"+"})]})}function z_(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<Vi||n>Gi?null:n}function V_({className:e,hidden:t}){let o=A(),n=W($_),{isEnabled:r,disabledReason:i}=re("font.size"),a=ae(),[l,s]=Zt.useState(false),[c,d]=Zt.useState(null),m=Zt.useRef(null);Zo(m,l,()=>s(false));let u=Zt.useRef(null),g=Zt.useId(),p=Zt.useCallback(E=>{if(!o)return;let C=editor.commandForSlotValue("font.size",E);C&&o.can(C).ok&&o.exec(C);},[o]),f=Zt.useCallback(E=>{p(Math.min(Gi,Math.max(Vi,Math.round(E*2))));},[p]),b=Zt.useCallback(E=>{s(false),d(null),u.current?.blur(),E&&o?.focus();},[o]);if(Zt.useEffect(()=>{if(l)return editor.listenForOutsidePress({popup:m.current,close:()=>{s(false),d(null);}})},[l]),t)return null;let y=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,k=()=>{if(c===null)return;let E=z_(c);E!==null&&p(E);};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsxRuntime.jsx(mx,{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"),"aria-controls":l?g:void 0,autoComplete:"off",onChange:E=>{d(E.target.value),s(true);},onFocus:E=>{E.target.select(),s(true);},onClick:()=>s(true),onKeyDown:E=>{E.key==="Enter"?(E.preventDefault(),k(),b(true)):E.key==="Escape"?(E.preventDefault(),b(true)):(E.key==="ArrowDown"||E.key==="ArrowUp")&&(E.preventDefault(),s(true),n!==null&&f(E.key==="ArrowDown"?dx(n,zi,Vi/2):cx(n,zi,Gi/2)));},onBlur:()=>{k(),d(null);}}),canDecrease:y&&Math.round(n*2)>Vi,canIncrease:y&&Math.round(n*2)<Gi,onDecrease:()=>f(dx(n??0,zi,Vi/2)),onIncrease:()=>f(cx(n??0,zi,Gi/2))}),l&&r?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox",tabIndex:0,"aria-label":a("fontSize.listLabel"),id:g,children:zi.map(E=>{let C=h===E;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>{f(E),b(true);},children:E},E)})}):null]})}var Bm=Object.assign(V_,{docxSlot:"font.size"});function G_({className:e,hidden:t}){let o=A(),{zoom:n,isFit:r,mode:i,setZoom:a,setMode:l,zoomIn:s,zoomOut:c,canZoomIn:d,canZoomOut:m,levels:u}=Hm(),g=ae(),[p,f]=Zt.useState(false),b=Zt.useRef(null);Zo(b,p,()=>f(false)),Zt.useEffect(()=>{if(p)return editor.listenForOutsidePress({popup:b.current,close:()=>f(false)})},[p]);let y=Zt.useCallback(E=>{b.current?.querySelector("[aria-haspopup]")?.focus(),f(false),a(E);},[a]),v=Zt.useCallback(E=>{b.current?.querySelector("[aria-haspopup]")?.focus(),f(false),l(E==="auto"?"auto":editor.FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let x=`${Math.round(n*100)}%`,h=editor.sameZoomMode(i,editor.AUTO_ZOOM_MODE),k=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(mx,{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")}: ${x}`,onMouseDown:$,onClick:()=>f(E=>!E),children:[x,jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:m,canIncrease:d,onDecrease:c,onIncrease:s}),p?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__zoom-menu",role:"listbox",tabIndex:0,"aria-label":g("zoom.zoomLevel"),children:[jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":h,...h?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>v("auto"),children:g("zoom.automatic")}),jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":k,...k?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>v("fit-width"),children:g("zoom.fitWidth")}),jsxRuntime.jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(E=>{let C=!r&&Math.abs(E-n)<.001;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>y(E),children:`${Math.round(E*100)}%`},E)})]}):null]})}var Wm=Object.assign(G_,{docxSlot:"zoom.level"});function ur(e,t,o,n=false){let r=we(),i=Zt.useRef(r);i.current=r,Zt.useEffect(()=>{e&&n&&t(false);},[e,n,t]),Zt.useEffect(()=>{let a=o.current;if(!e||n||!a)return;let l=m=>a.contains(m),s=editor.listenForPopupEscape({popup:a,contains:l,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current],close:m=>{t(false),m&&a.querySelector("[aria-haspopup]")?.focus();}}),c=editor.listenForPopupFocusLeave({popup:a,contains:l,close:()=>t(false)}),d=editor.listenForOutsidePress({popup:a,contains:l,close:()=>t(false)});return ()=>{d(),s(),c();}},[e,n,t,o]);}var hx=10,yx=0,oI=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),nI=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function rI({className:e,hidden:t}){let o=A(),n=W(oI,nI),{isEnabled:r,disabledReason:i}=re("list.lineSpacing"),a=re("paragraph.dialog"),l=Ey(),s=ae(),{lang:c}=H(),[d,m]=Zt.useState(false),u=Zt.useRef(null),g=Zt.useRef(null);ur(d,m,u,t);let p=Zt.useCallback(h=>{m(false),!(!o||!h.command)&&o.can(h.command).ok&&o.exec(h.command);},[o]),f=Zt.useCallback((h,k)=>{if(m(false),!o)return;let E={type:"setParagraphSpacing",[h]:k};o.can(E).ok&&o.exec(E);},[o]);if(t)return null;let b=te("list.lineSpacing"),y=(n.spaceBeforePt??0)>0,v=(n.spaceAfterPt??0)>0,x=editor.lineSpacingMenuRows(n.lineSpacing);return jsxRuntime.jsxs("span",{ref:u,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxRuntime.jsxs("button",{ref:g,type:"button",className:`docx-toolbar__button docx-toolbar__line-spacing-trigger${e?` ${e}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-label":s("lineSpacing.label"),title:i??s("lineSpacing.label"),onMouseDown:$,onClick:()=>m(h=>!h),children:[oe(b?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),d&&r?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[x.map(h=>{let k=h.selected;return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":k,...k?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>p(h),children:[editor.lineSpacingMenuRowLabel(h,s,c),k?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]},`${h.spacing.rule}:${h.spacing.value}`)}),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:$,onClick:()=>{m(false),l?.open(g.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:$,onClick:()=>f("beforePt",y?yx:hx),children:s(y?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>f("afterPt",v?yx:hx),children:s(v?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var Zm=Object.assign(rI,{docxSlot:"list.lineSpacing"});var lI=["alignment.left","alignment.center","alignment.right","alignment.justify"];function sI({className:e,hidden:t}){let o=re("alignment.left"),n=re("alignment.center"),r=re("alignment.right"),i=re("alignment.justify"),a=ae(),[l,s]=Zt.useState(false),c=Zt.useRef(null);if(ur(l,s,c,t),t)return null;let d=[o,n,r,i],m=lI.map((f,b)=>({slot:f,control:te(f),state:d[b]})),u=m.find(f=>f.state.isActive)??m[0],g=m.some(f=>f.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:$,onClick:()=>s(f=>!f),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:m.map(f=>{let b=a(f.control?.labelKey??f.slot);return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-option","data-slot":f.slot,disabled:!f.state.isEnabled,...f.state.isActive?{"data-active":""}:{},"aria-pressed":f.state.isActive,"aria-label":b,title:f.state.disabledReason??b,onMouseDown:$,onClick:()=>{f.state.execute(),s(false);},children:oe(f.control?.paths)},f.slot)})}):null]})}var bc=Object.assign(sI,{docxSlot:"alignment"});function qm(e){let{label:t,icon:o,active:n,disabled:r,disabledReason:i,onSelect:a,asChild:l,className:s,children:c}=e,d=ss(),m=Ca();if(d==="panel"&&!l)return jsxRuntime.jsxs("button",{type:"button",className:`docx-toolbar__more-command${s?` ${s}`:""}`,disabled:r,...n?{"data-active":""}:{},...n!==void 0?{"aria-pressed":n}:{},...r&&i?{title:i}:{},onMouseDown:g=>$(g),onClick:g=>{a?.(),m(g.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:o??c}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:t})]});let u={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:g=>$(g),onClick:r?void 0:a};return l?jsxRuntime.jsx(Q,{...u,children:c}):jsxRuntime.jsx("button",{...u,children:o??c})}var bI=Object.freeze([]),hI=e=>e.formatting?.fontFamily??null,yI=e=>e;function xc(){let e=A(),t=W(hI),o=W(yI),n=Zt.useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():bI,[e,o]),{isEnabled:r}=re("font.family"),i=Zt.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return Zt.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var Tx=Zt.createContext(null);function $m(){return Zt.useContext(Tx)}function zm({asChild:e,className:t,children:o}){let n=$m(),r=ae();if(!n)return null;let i=r(te("font.family")?.labelKey??"font.family"),a={onClick:()=>n.setOpen(!n.open),onMouseDown:$,disabled:!n.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,"aria-label":o!==void 0?void 0:`${i}: ${n.value??"\u2014"}`,title:i},l=o??jsxRuntime.jsx("span",{children:n.value??"\u2014"});return e?jsxRuntime.jsx(Q,{...a,children:l}):jsxRuntime.jsx("button",{type:"button",...a,children:l})}zm.docxToolbarPart=true;var xI=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"]]),vI=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function Ex({asChild:e,className:t,children:o}){let n=$m(),r=ae(),[i,a]=Zt.useState("");if(Zt.useEffect(()=>{n?.open||a("");},[n?.open]),!n||!n.open)return null;let l={role:"listbox",tabIndex:0,"aria-label":r("font.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`},s;return o!==void 0?s=o:s=vI.map(d=>({...d,fonts:n.options.filter(m=>m.toLowerCase().includes(i.toLowerCase())&&(xI.get(m.toLowerCase())??"other")===d.category)})).filter(d=>d.fonts.length>0).map((d,m)=>jsxRuntime.jsxs("div",{role:"group",children:[m>0?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator","aria-hidden":"true"}):null,d.labelKey?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-label",children:r(d.labelKey)}):null,d.fonts.map(u=>jsxRuntime.jsx(Sx,{value:u},u))]},d.category)),e?jsxRuntime.jsx(Q,{...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",tabIndex:0,"aria-label":r("font.selectAriaLabel"),className:"docx-toolbar__font-options",children:s})]})}function Sx({value:e,asChild:t,className:o,children:n}){let r=A(),i=$m();if(!i)return null;let a=i.value===e,l={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:$,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(Q,{...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 CI({hidden:e,asChild:t,className:o,children:n}){let r=xc(),[i,a]=Zt.useState(false),l=Zt.useRef(null);Zo(l,i,()=>a(false)),Zt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=Zt.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(zm,{}),jsxRuntime.jsx(Ex,{})]});return jsxRuntime.jsx(Tx.Provider,{value:s,children:t?jsxRuntime.jsx(Q,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Vm=Object.assign(CI,{docxSlot:"font.family",Trigger:zm,Content:Ex,Item:Sx});var EI={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},SI=new Set(["Title","Heading1","Heading2","Heading3"]),PI={Subtitle:"666666"},kI="#4a6c8c";function Px(e){let t=EI[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??SI.has(e.styleId))&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic");let r=e.color??PI[e.styleId];return r?n.color=`#${r}`:e.styleId.startsWith("Heading")&&(n.color=kI),n}var kx=/^heading ([1-9])$/;function Gm(e,t){let o=e||t,n=kx.exec(o);return n?`Heading ${n[1]}`:o}var wI=new Map([["normal","styles.normal"],["title","styles.title"],["subtitle","styles.subtitle"],["no spacing","styles.noSpacing"],["quote","styles.quote"],["intense quote","styles.intenseQuote"],["list paragraph","styles.listParagraph"]]);function vc(e){let t=e.toLowerCase(),o=wI.get(t);if(o)return {key:o};let n=kx.exec(t);return n?{key:"styles.headingLevel",vars:{level:Number(n[1])}}:null}function wx(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:Gm(t.name,t.styleId),priority:99}))}function HI(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 AI=Object.freeze([]),OI=e=>e.formatting?.styleId??null,BI=e=>e;function Cc(){let e=A(),t=W(OI),o=W(BI),{t:n}=H(),r=Zt.useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(l=>l.type==="paragraph").map(l=>{let s=vc(l.name);return {styleId:l.styleId,name:s?n(s.key,s.vars):Gm(l.name,l.styleId),preview:l.preview}}):AI,[e,o,n]),{isEnabled:i}=re("styles.style"),a=Zt.useCallback(l=>{if(!e)return;let s=editor.commandForSlotValue("styles.style",l);s&&e.can(s).ok&&e.exec(s);},[e]);return Zt.useMemo(()=>({value:t,setValue:a,options:r,isEnabled:i}),[t,a,r,i])}var Dx=Zt.createContext(null);function Ym(){return Zt.useContext(Dx)}function Xm({asChild:e,className:t,children:o}){let n=Ym(),r=ae();if(!n)return null;let i=te("styles.style"),a=r(i?.labelKey??"styles.style"),l={onClick:()=>n.setOpen(!n.open),onMouseDown:$,disabled:!n.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,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(Q,{...l,children:c}):jsxRuntime.jsx("button",{type:"button",...l,children:c})}Xm.docxToolbarPart=true;function Rx({asChild:e,className:t,children:o}){let n=ae(),r=Ym();if(!r||!r.open)return null;let i={role:"listbox",tabIndex:0,"aria-label":n("styles.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`},a=o??r.options.map(l=>jsxRuntime.jsx(Mx,{value:l.styleId},l.styleId));return e?jsxRuntime.jsx(Q,{...i,children:a}):jsxRuntime.jsx("div",{...i,children:a})}function Mx({value:e,asChild:t,className:o,children:n}){let r=A(),i=Ym();if(!i)return null;let a=i.value===e,l=i.options.find(d=>d.styleId===e),s={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:$,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__style-item${o?` ${o}`:""}`},c=n??jsxRuntime.jsx("span",{style:l?HI(l.preview):void 0,children:l?.name??e});return t?jsxRuntime.jsx(Q,{...s,children:c}):jsxRuntime.jsxs("button",{type:"button",...s,children:[c,a?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function WI({hidden:e,asChild:t,className:o,children:n}){let r=Cc(),[i,a]=Zt.useState(false),l=Zt.useRef(null);Zo(l,i,()=>a(false)),Zt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=Zt.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(Xm,{}),jsxRuntime.jsx(Rx,{})]});return jsxRuntime.jsx(Dx.Provider,{value:s,children:t?jsxRuntime.jsx(Q,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Jm=Object.assign(WI,{docxSlot:"styles.style",Trigger:Xm,Content:Rx,Item:Mx});function Ix(e,t){let o=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:l,children:s})=>{let{isEnabled:c,disabledReason:d}=re(o),m=Po(),u=t==="showAll"?m.showAll:m.formFill,g=ae();if(i)return null;let p=te(o),f=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":f,title:d??f,onMouseDown:$,onClick:()=>{t==="showAll"?m.toggleShowAll():m.toggleFormFill();}};return l?jsxRuntime.jsx(Q,{...b,children:s}):jsxRuntime.jsx("button",{...b,children:a??s??oe(p?.paths)})},{docxSlot:o})}function KI({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=Mt.inspector,{isEnabled:a,disabledReason:l}=re(i),{inspectorOpen:s,openInspector:c}=Po(),d=ae();if(t)return null;let m=te(i),u=d(m?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Mt.inspector,disabled:!a,...a?{}:{"data-disabled":""},...s?{"data-active":""}:{},"aria-pressed":s,"aria-label":u,title:l??u,onMouseDown:$,onClick:()=>c()};return n?jsxRuntime.jsx(Q,{...g,children:r}):jsxRuntime.jsx("button",{...g,children:o??r??oe(m?.paths)})}function qI({className:e,hidden:t,icon:o,asChild:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l}=Po(),s=ae();if(t)return null;let c=Mt.remove,d=te(c),m=s(d?.labelKey??"contentControl.remove"),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Mt.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":m,title:a??m,onMouseDown:$,onClick:()=>{l();}};return n?jsxRuntime.jsx(Q,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??oe(d?.paths)})}var Tc=Ix(Mt.showAll,"showAll"),Ec=Ix(Mt.formFill,"formFill"),Sc=Object.assign(qI,{docxSlot:Mt.remove}),Pc=Object.assign(KI,{docxSlot:Mt.inspector}),Nx={[Mt.showAll]:Tc,[Mt.formFill]:Ec,[Mt.inspector]:Pc,[Mt.remove]:Sc};var Sa=Object.assign(e=>jsxRuntime.jsx(Ko,{slotId:"table.mergeCells",...e}),{docxSlot:"table.mergeCells"});function UI({icon:e,className:t,children:o,hidden:n}){let{isEnabled:r,disabledReason:i}=re("table.splitCell"),a=_o(),l=ae();if(n||!a)return null;let s=l(te("table.splitCell")?.labelKey??"table.splitCell");return jsxRuntime.jsx("button",{type:"button","data-slot":"table.splitCell",className:`docx-toolbar__button${t?` ${t}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-label":s,"aria-haspopup":"dialog",title:i??s,onMouseDown:$,onClick:c=>a.open("splitCell",c.currentTarget),children:e??o??oe(te("table.splitCell")?.paths)})}var Pa=Object.assign(UI,{docxSlot:"table.splitCell"});function Qm(e,t){let o=A(),n=Zt.useRef(t);n.current=t,Zt.useEffect(()=>{if(!o)return;let r=((...i)=>{n.current(...i);});return o.on(e,r)},[o,e]);}var XI=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],tf=Zt.createContext(null);function Zx(){let e=Zt.useContext(tf);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function QI(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 e8(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function t8(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var Bx={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function o8(e,t){let o={};for(let n of XI){let r=editor.tableChromeToolbarState(e,n,t);o[n]={enabled:r.enabled,disabledReason:r.disabledReason};}return o}function of({children:e}){let t=A(),[o,n]=Zt.useState(editor.DEFAULT_TABLE_CHROME_DRAFT),[r,i]=Zt.useState(Bx);Zt.useEffect(()=>(()=>{}),[]);let a=W(Zt.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:""}),[]),e8,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=Zt.useCallback(()=>{if(!t){i(Bx);return}let u=QI(t,t.snapshot());i(g=>t8(g,u)?g:u);},[t]);Zt.useEffect(()=>{l();},[l,a]),Qm("selectionChange",Zt.useCallback(()=>{l();},[l]));let s=r.tableKey!=="",c=Zt.useMemo(()=>t?o8(t,o):{},[t,o,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=Zt.useCallback((u,g)=>{if(!t)return;let{result:p,nextDraft:f}=editor.runTableChromeCommand(t,u,g,o);p.ok&&f&&n(f);},[t,o]),m=Zt.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(tf.Provider,{value:m,children:e})}function n8(){let e=Zt.useContext(tf);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function wc(e){let t=n8(),o=t.slotState(e);return Zt.useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:n=>t.apply(e,n)}),[t,e,o])}function Rc(e){(editor.editorInstanceScope(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function Mc({enabled:e,disabledReason:t,ariaLabel:o}){let{t:n}=H(),r=i18n.localizeDisabledReason(t,n),i=Zt.useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:$,"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 s8='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function Ux(e,t,o,n){Zt.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll(s8)].filter(c=>c.closest('[role="menu"]')===r);queueMicrotask(()=>{let c=a();(c.find(m=>m.hasAttribute("data-selected")||m.hasAttribute("data-active"))??c[0])?.focus();});let s=c=>{if(c.defaultPrevented||c.isComposing||c.keyCode===229)return;let d=a();if(c.key==="Escape"){c.preventDefault(),t(false),i?.focus();return}if(c.key==="ArrowDown"){c.preventDefault(),no(d,editor.hostDocumentOf(r).activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),no(d,editor.hostDocumentOf(r).activeElement,-1);return}if(c.key==="Home"){c.preventDefault(),ro(d,"first");return}if(c.key==="End"){c.preventDefault(),ro(d,"last");return}if(c.key==="Enter"||c.key===" "){let m=editor.hostDocumentOf(c.target).activeElement;editor.isHTMLElementNode(m)&&d.includes(m)&&(c.preventDefault(),m.click());}};return r.addEventListener("keydown",s),()=>r.removeEventListener("keydown",s)},[e,t,o,n]);}function $x(e,t,o,n){Zt.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=editor.hostDocumentOf(s.target).activeElement,d=a();editor.isHTMLElementNode(c)&&d.includes(c)&&(s.preventDefault(),c.click());}};return r.addEventListener("keydown",l),()=>r.removeEventListener("keydown",l)},[e,t,o,n]);}function Xx(e,t,o){if(e)return n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),o(!t));}}function f8(e){return oe(editor.tableChromeIconPaths(e))}function Jx(){return Zt.createContext(null)}function Xo(e){let t=Zt.useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function rf(e,t,o){let n=Jx();function r({hidden:l,asChild:s,className:c,children:d}){let{visible:m,enabled:u,disabledReason:g,draft:p,apply:f}=wc(e),[b,y]=Zt.useState(false),v=Zt.useRef(null),x=Zt.useRef(null);ur(b,y,v,l||!m);let h=Zt.useMemo(()=>({open:b,setOpen:y,enabled:u,disabledReason:g,apply:f,draft:p,triggerRef:x}),[b,u,g,f,p]);if(l||!m)return null;let k={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},E=d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(i,{}),jsxRuntime.jsx(a,{})]});return jsxRuntime.jsx(n.Provider,{value:h,children:s?jsxRuntime.jsx(Q,{...k,ref:v,children:E}):jsxRuntime.jsx("div",{ref:v,...k,children:E})})}function i({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,disabledReason:g,triggerRef:p}=Xo(n),f=ae(),b=te(e),y=f(b?.labelKey??o),{shared:v,reasonNode:x}=Mc({enabled:u,disabledReason:g,ariaLabel:y}),h={...v,ref:p,className:`docx-toolbar__button docx-table-chrome__trigger${s?` ${s}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:u?()=>m(!d):void 0,...l?{tabIndex:u?0:-1,role:"button",onKeyDown:Xx(u,d,m)}:{}},k=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(Q,{...h,children:k}),x]}):jsxRuntime.jsxs("button",{...h,children:[k,x]})}i.docxToolbarPart=true;function a({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,triggerRef:g}=Xo(n),p=ae(),f=Zt.useRef(null);if(Ux(d&&u,m,f,g),!d||!u)return null;let b=te(e),y=p(b?.labelKey??o),v={ref:f,role:"menu","aria-label":y,className:`docx-table-chrome__panel${s?` ${s}`:""}`,onMouseDown:$};return l?jsxRuntime.jsx(Q,{...v,children:c}):jsxRuntime.jsx("div",{...v,children:c})}return {Root:r,Trigger:i,Content:a,Ctx:n}}var Xi=rf("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function Qx({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xo(Xi.Ctx),l=ae(),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:$,onClick:()=>{i(false),r(s.value);}},m=n??f8(s.icon);return t?jsxRuntime.jsx(Q,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function ev(e){let{children:t}=e;return jsxRuntime.jsx(Xi.Content,{...e,children:t??jsxRuntime.jsx("div",{className:"docx-table-chrome__target-grid",children:editor.TABLE_BORDER_TARGET_OPTIONS.map(o=>jsxRuntime.jsx(Qx,{value:o.value},o.value))})})}function g8(e){let{children:t}=e,o=t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xi.Trigger,{}),jsxRuntime.jsx(ev,{})]});return jsxRuntime.jsx(Xi.Root,{...e,children:o})}var ol=Object.assign(g8,{docxSlot:"table.borderTarget",Trigger:Xi.Trigger,Content:ev,Item:Qx}),Ji=rf("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function tv({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xo(Ji.Ctx),l=ae(),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:$,onClick:()=>{i(false),r(s.value);}},m=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(Q,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function ov(e){let{children:t}=e;return jsxRuntime.jsx(Ji.Content,{...e,children:t??editor.TABLE_BORDER_STYLE_OPTIONS.map(o=>jsxRuntime.jsx(tv,{value:o.value},o.value))})}function b8(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ji.Trigger,{}),jsxRuntime.jsx(ov,{})]});return jsxRuntime.jsx(Ji.Root,{...e,children:t})}var nl=Object.assign(b8,{docxSlot:"table.borderStyle",Trigger:Ji.Trigger,Content:ov,Item:tv}),Qi=rf("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function nv({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xo(Qi.Ctx),l=ae(),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,m={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:$,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(Q,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}function rv(e){let{children:t}=e;return jsxRuntime.jsx(Qi.Content,{...e,children:t??editor.TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsxRuntime.jsx(nv,{value:String(o.size)},o.size))})}function h8(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Qi.Trigger,{}),jsxRuntime.jsx(rv,{})]});return jsxRuntime.jsx(Qi.Root,{...e,children:t})}var rl=Object.assign(h8,{docxSlot:"table.borderWidth",Trigger:Qi.Trigger,Content:rv,Item:nv});function av(e,t,o){let n=o?.defaultHex??"FF0000",r=Jx();function i({hidden:d,asChild:m,className:u,children:g}){let{visible:p,enabled:f,disabledReason:b,draft:y,apply:v}=wc(e),[x,h]=Zt.useState(false),[k,E]=Zt.useState(n),C=Zt.useRef(null),T=Zt.useRef(null);ur(x,h,C,d||!p);let S=Zt.useMemo(()=>({open:x,setOpen:h,enabled:f,disabledReason:b,apply:v,draft:y,triggerRef:T,lastHex:k,setLastHex:E}),[x,f,b,v,y,k]);if(d||!p)return null;let P={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:S,children:m?jsxRuntime.jsx(Q,{...P,ref:C,children:w}):jsxRuntime.jsx("div",{ref:C,...P,children:w})})}function a({asChild:d,className:m,children:u}){let{enabled:g,disabledReason:p,apply:f,draft:b,lastHex:y}=Xo(r),v=ae(),x=te(e),h=v(x?.labelKey??t),{shared:k,reasonNode:E}=Mc({enabled:g,disabledReason:p,ariaLabel:h}),C=e==="table.borderColor"&&b.spec.color.kind==="hex"?b.spec.color.value:y??n,T={...k,className:`docx-toolbar__button docx-toolbar__colorsplit-main${m?` ${m}`:""}`,onClick:g?()=>f({kind:"hex",value:C}):void 0},S=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[oe(x?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${C.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Q,{...T,children:S}),E]}):jsxRuntime.jsxs("button",{...T,children:[S,E]})}a.docxToolbarPart=true;function l({asChild:d,className:m,children:u}){let{open:g,setOpen:p,enabled:f,disabledReason:b,triggerRef:y}=Xo(r),v=ae(),x=te(e),h=v(x?.labelKey??t),{shared:k,reasonNode:E}=Mc({enabled:f,disabledReason:b,ariaLabel:h}),C={...k,ref:y,className:`docx-toolbar__colorsplit-caret${m?` ${m}`:""}`,"aria-haspopup":"dialog","aria-expanded":g,onClick:f?()=>p(!g):void 0,...d?{tabIndex:f?0:-1,role:"button",onKeyDown:Xx(f,g,p)}:{}},T=u??"\u25BE";return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Q,{...C,children:T}),E]}):jsxRuntime.jsxs("button",{...C,children:[T,E]})}l.docxToolbarPart=true;function s({asChild:d,className:m,children:u,clearFill:g}){let{open:p,setOpen:f,enabled:b,apply:y,draft:v,triggerRef:x,lastHex:h,setLastHex:k}=Xo(r),E=ae(),C=Zt.useRef(null);if($x(p&&b,f,C,x),!p||!b)return null;let T=E(t),S=e==="table.borderColor"&&v.spec.color.kind==="hex"?v.spec.color.value:h??n,P={ref:C,role:"dialog","aria-label":T,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${m?` ${m}`:""}`,onMouseDown:$},w=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g?jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:$,onClick:()=>{f(false),y(null),Rc(x.current);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),E("table.clearCellFill")]}):null,jsxRuntime.jsx(eu,{apply:_=>{f(false),k?.(_),y({kind:"hex",value:_}),Rc(x.current);},current:S})]});return d?jsxRuntime.jsx(Q,{...P,children:w}):jsxRuntime.jsx("div",{...P,children:w})}function c({value:d,css:m,labelKey:u,asChild:g,className:p,children:f}){let{apply:b,setOpen:y,setLastHex:v,triggerRef:x}=Xo(r),h=ae(),k=m??`#${d.toLowerCase()}`,E=u?h(u):d,C={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:k},"data-value":d,"aria-label":E,title:E,onMouseDown:$,onClick:()=>{y(false),v?.(d),b({kind:"hex",value:d}),Rc(x.current);}};return g?jsxRuntime.jsx(Q,{...C,children:f}):jsxRuntime.jsx("button",{...C,children:f})}return {Root:i,Main:a,Trigger:l,Content:s,Item:c,Ctx:r}}var el=av("table.borderColor","table.borderColor",{defaultHex:"000000"});function y8(e){return jsxRuntime.jsx(el.Content,{...e,clearFill:false})}function x8(e){return jsxRuntime.jsx(el.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function v8(e){return jsxRuntime.jsx(el.Root,{...e})}var al=Object.assign(v8,{docxSlot:"table.borderColor",Trigger:el.Trigger,Content:y8,Item:x8,Main:el.Main}),tl=av("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function C8(e){return jsxRuntime.jsx(tl.Content,{...e,clearFill:true})}function T8(e){return jsxRuntime.jsx(tl.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function E8(e){return jsxRuntime.jsx(tl.Root,{...e})}var il=Object.assign(E8,{docxSlot:"table.cellFill",Trigger:tl.Trigger,Content:C8,Item:T8,Main:tl.Main});function iv({overrides:e=new Map,separator:t=true}){return Zx()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx(dr,{}):null,[ol,al,nl,rl,il].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(Zt.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)}),[Sa,Pa].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(Zt.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)})]}):null}function lv(){let e=ae(),{draft:t}=wc("table.borderTarget");return e(editor.tableChromeLabelKeyForTarget(t.activeTarget))}var lf=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill","table.mergeCells","table.splitCell"],fr="contextual-table",sf={"zoom.level":Wm,"styles.style":Jm,"font.family":Vm,"font.size":Bm,"text.color":tu,"text.highlight":ou,"text.link":Fm,"list.lineSpacing":Zm,"review.editingMode":lc,"review.authors":cc,"file.save":Lm,...Nx,"table.borderTarget":ol,"table.borderColor":al,"table.borderStyle":nl,"table.borderWidth":rl,"table.cellFill":il,"table.splitCell":Pa,"image.insert":ci,"image.properties":ga,"image.wrap":Ui,"image.altText":_i},N8=new Set(["image.insert","image.properties","image.wrap","image.altText"]),_c={id:fr,labelKey:"formattingBar.groups.table",entries:lf.map(e=>({slot:e,Part:e==="table.mergeCells"?Sa:sf[e]}))},sv=new Map;function F8(e){let t=sv.get(e);return t||(t=o=>jsxRuntime.jsx(Ko,{slotId:e,...o}),sv.set(e,t)),t}function L8(e,t){return editor.formattingBarChromeGroups(e,{direction:t}).map(o=>o.id==="alignment"?{id:o.id,labelKey:o.labelKey,entries:[{slot:"alignment",Part:bc}]}:{id:o.id,labelKey:o.labelKey,entries:o.controls.map(n=>{let r=editor.chromeSlotId(o,n);return {slot:r,Part:sf[r]??F8(r)}})})}var H8=e=>e.image,A8=e=>e.isLoading||e.isOpening===true,O8=e=>e.table!==null;function B8(e){return e==="alignment"||e in sf}function Fc(e){let t=Wr(e,Fc);if(t!==null)return t;if(!Zt.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.docxToolbarSlot===true){let n=e.props.slotId;return typeof n=="string"?n:null}if(o.docxToolbarPart===true){let n=e.props,r=n.slotId??n.slot;if(typeof r=="string")return r}return null}function af(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(af);let t=Fc(e);return t!=null&&lf.includes(t)?true:Zt.isValidElement(e)?Zt.Children.toArray(e.props.children).some(af):false}function W8(e,t){return t?true:Zt.Children.toArray(e).some(af)}function Z8(e){let t=$t(),{className:o,t:n,onSave:r,preset:i=true,overflow:a=true,children:l}=e,s=Zt.useMemo(()=>({t:n,onSave:r}),[n,r]),c=zl(n),d=W(H8),m=W(A8),u=W(O8),g=lt(),p=g==="rtl",f=Zt.useMemo(()=>L8(d,p),[d,p]),b=Zt.useMemo(()=>new Set(f.flatMap(S=>S.entries.map(P=>P.slot))),[f]),y=Zt.useMemo(()=>i?_y(l,Fc,S=>b.has(S),S=>lf.includes(S)):null,[i,l,b]),v=Zt.useMemo(()=>y?K8(f,y):[],[f,y]),x=Zt.useMemo(()=>[...v.filter(S=>!S.pinned).map(S=>({id:S.id,items:cv(S,y?.overrides)})),...u?[{id:fr,items:[fr]}]:[]],[v,y,u]),h=Zt.useMemo(()=>{let S=new Map;for(let P of v)P.priority!==void 0&&S.set(P.id,P.priority);return editor.collapseOrder(x.map(P=>P.id),editor.TOOLBAR_COLLAPSE_ORDER,S)},[v,x]),k=i&&a,{attach:E,overflow:C}=Fu(k,x,h),T;if(!y)T=l;else {let{overrides:S,tableOverrides:P,appended:w}=y,_=R=>{let U=S.get(R.slot);if(U)return U;let V=R.Part;return jsxRuntime.jsx(V,{})},L=R=>{let U=P.get(R.slot);if(U)return U;let V=R.Part;return jsxRuntime.jsx(V,{})},N=[],B=[],F=0;for(let R of v){let U=cv(R,S),V=new Map(R.entries.map(q=>[q.slot,q])),Y=R.pinned?U.length:editor.toolbarShownCount(C,R.id,U.length),j=U.slice(Y);if(j.length>0){let q=j.flatMap(ee=>{let O=V.get(ee);if(!O)return [];let I=dv(O,S,c,R.labelKey,_);return I===null?[]:[jsxRuntime.jsx(Zt.Fragment,{children:I},O.slot)]}),X=editor.toolbarHostPanelShown(R.extras.length>0,j)?U8(R):null;X!==null&&q.push(jsxRuntime.jsx(Zt.Fragment,{children:X},"host")),q.length>0&&B.push({id:R.id,labelKey:R.labelKey,...R.heading?{label:is(R.heading,c)}:{},children:q});}Y!==0&&(F>0&&N.push(jsxRuntime.jsx(dr,{},`separator-${R.id}`)),F+=1,N.push(jsxRuntime.jsx("div",{className:`docx-toolbar__group${R.className?` ${R.className}`:""}`,...R.heading?{role:"group","aria-label":is(R.heading,c)}:{},...R.pinned?{[Ur]:""}:{[qr]:R.id},children:U.slice(0,Y).map(q=>{let X=V.get(q);return jsxRuntime.jsx("div",{className:"docx-toolbar__item",[_b]:q,children:X?_(X):R.extras},q)})},R.id)));}let D=C.has(fr);if(u&&D){let R=_c.entries.flatMap(U=>{let V=dv(U,P,c,_c.labelKey,L);return V===null?[]:[jsxRuntime.jsx(Zt.Fragment,{children:V},U.slot)]});R.length>0&&B.unshift({id:_c.id,labelKey:_c.labelKey,children:R});}T=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[N,u&&!D?jsxRuntime.jsx(dr,{},"separator-contextual-table"):null,D?null:jsxRuntime.jsx("div",{className:"docx-toolbar__contextual",[qr]:fr,children:jsxRuntime.jsx(iv,{overrides:P,separator:false})}),w.length>0?jsxRuntime.jsx("div",{className:"docx-toolbar__group",[Ur]:"",children:w}):null,B.length>0?jsxRuntime.jsx(Ry,{sections:B}):null]});}return jsxRuntime.jsx(Vn.Provider,{value:s,children:jsxRuntime.jsx(Ty,{children:jsxRuntime.jsx("fieldset",{ref:E,disabled:m,"aria-label":c("formattingBar.label"),"data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,dir:g,...k?{"data-overflow":""}:{},onMouseDown:$,children:W8(l,i)?jsxRuntime.jsx(of,{children:T}):T})})})}function Lc(e){if(!e)return false;if(e.type===Zt.Fragment){let t=Zt.Children.toArray(e.props.children).find(o=>Fc(o)!==null);return Zt.isValidElement(t)?Lc(t):false}return !!e.props.hidden}function cv(e,t){let o=e.entries.filter(n=>!Lc(t?.get(n.slot))).map(n=>n.slot);return editor.toolbarGroupItems(o,e.extras.length>0)}function K8(e,t){let o=new Map(t.groups.map(s=>[s.id,s])),n=new Set(e.map(s=>s.id)),r=new Map;for(let s of e){let c=o.get(s.id);if(c&&q8(c),c?.hidden)continue;let d=Zt.Children.toArray(c?.children);!s.entries.some(u=>!Lc(t.overrides.get(u.slot)))&&d.length===0||r.set(s.id,{id:s.id,labelKey:s.labelKey,heading:void 0,entries:s.entries,extras:d,pinned:c?.pinned??editor.TOOLBAR_PINNED_GROUPS.has(s.id),priority:c?.priority,overflowContent:c?.overflowContent,className:c?.className,host:false});}for(let s of t.groups)s.id===fr&&Hy(s.id);let i=t.groups.filter(s=>!n.has(s.id)&&s.id!==fr);for(let s of i){let c=Zt.Children.toArray(s.children);s.hidden||c.length===0||r.set(s.id,{id:s.id,labelKey:s.labelKey??s.id,heading:{id:s.id,label:s.label,labelKey:s.labelKey},entries:[],extras:c,pinned:s.pinned===true,priority:s.priority,overflowContent:s.overflowContent,className:s.className,host:true});}let a=[...n,...i.map(s=>s.id)];for(let s of i)s.after!==void 0&&!a.includes(s.after)&&Fy(s.id,s.after,a);for(let s of t.appended){if(!Zt.isValidElement(s)||s.type!==ii)continue;let c=s.props.slotId;Ay(c,te(c)!==null);}return editor.arrangeToolbarGroups(e.map(s=>s.id),i.map(s=>({id:s.id,after:s.after}))).flatMap(s=>{let c=r.get(s);return c?[c]:[]})}function q8(e){for(let t of ["label","labelKey","after"])e[t]!==void 0&&Ly(e.id,t);}function U8(e){return e.overflowContent?e.overflowContent():e.extras.length===0?null:jsxRuntime.jsx(ls.Provider,{value:"panel",children:jsxRuntime.jsx("div",{className:"docx-toolbar__more-host",children:e.extras})})}function dv(e,t,o,n,r){let i=t.get(e.slot);if(Lc(i))return null;let a=i?.type===ii?i.props.overflowContent:void 0;return !i&&N8.has(e.slot)?jsxRuntime.jsx(ls.Provider,{value:"panel",children:r(e)}):i||B8(e.slot)?jsxRuntime.jsx(wy,{label:$8(o,e,n),children:a?a():r(e)}):jsxRuntime.jsx(Dy,{slot:e.slot})}function $8(e,t,o){let n=t.slot==="alignment"?null:te(t.slot);return e(n?.labelKey??o)}var sl=Object.assign(Z8,{Button:Ko,Action:qm,Separator:dr,Group:Lu,Slot:ii,AddComment:Rm,Undo:By,Redo:Wy,Bold:Zy,Italic:Ky,Underline:qy,Strike:Uy,Link:Fm,ClearFormatting:$y,Superscript:zy,Subscript:Vy,Alignment:bc,AlignLeft:Gy,AlignCenter:jy,AlignRight:Yy,AlignJustify:Xy,LeftToRight:Jy,RightToLeft:Qy,LineSpacing:Zm,BulletList:ex,NumberedList:tx,Outdent:ox,Indent:nx,ImageInsert:ci,ImageProperties:ga,ImageWrap:Ui,ImageAltText:_i,TableInsert:Nm,TableBorderTarget:ol,TableBorderColor:al,TableBorderStyle:nl,TableBorderWidth:rl,TableCellFill:il,TableMergeCells:Sa,TableSplitCell:Pa,Comments:rx,FontFamily:Vm,FontSize:Bm,FontColor:tu,Highlight:ou,Zoom:Wm,StylePicker:Jm,EditingMode:lc,Reviewers:cc,Save:Lm,ContentControlShowAll:Tc,ContentControlFormFill:Ec,ContentControlInspector:Pc,ContentControlRemove:Sc});var uv=/^(con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])$/i,Y8=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g,X8=200,pv=new TextEncoder;function J8(e,t){if(pv.encode(e).length<=t)return e;let o=0,n="";for(let r of e){let i=pv.encode(r).length;if(o+i>t)break;o+=i,n+=r;}return n}function mv(e){let t=e.length;for(;t>0;){let o=e.charCodeAt(t-1);if(o!==46&&o!==32)break;t-=1;}return e.slice(0,t)}function fv(e){return mv(mv(e).replace(/\.docx$/i,""))}function Hc(e){let t=(e??"").replace(Y8," ").replace(/\s+/g," ").trim(),o=fv(t).replace(/^[. ]+/,""),n=J8(o,X8),r=n===o?o:fv(n);return !r||uv.test(r)?"document.docx":uv.test(r.split(".",1)[0].trim())?`_${r}.docx`:`${r}.docx`}function Ac(e,t,o="application/vnd.openxmlformats-officedocument.wordprocessingml.document",n){let r=URL.createObjectURL(new Blob([e],{type:o})),i=editor.hostDocumentOf(n).createElement("a");i.href=r,i.download=t,i.click(),editor.hostWindowOf(n).setTimeout(()=>URL.revokeObjectURL(r),0);}function gv(e,t,o){let{t:n}=H(),r=Zt.useRef(false),[i,a]=Zt.useState(false),[l,s]=Zt.useState(""),[c,d]=Zt.useState("pdf"),[m,u]=Zt.useState(false),[g,p]=Zt.useState({});return {pending:i,error:l,format:c,visible:m,session:g,dismiss:()=>u(false),execute:async b=>{if(!(!e||r.current)){r.current=true,p({}),d(b),u(true),a(true),s("");try{let y=await editor.runChromeExport(e,b,t);Ac(y.bytes.slice().buffer,Hc(o).replace(/\.docx$/,`.${y.extension}`),y.mimeType),u(!1);}catch(y){u(true),s(y instanceof editor.ChromeExportError?n(y.format==="markdown"?"toolbar.exportMarkdownMissing":"toolbar.exportPdfMissing"):n("toolbar.exportFailed",{message:y instanceof Error?y.message:String(y)}));}finally{r.current=false,a(false);}}}}}function yv(e,t,o,n=false){let{t:r}=H(),i=Zt.useRef({editor:e,exporters:t,feedback:o,t:r,settingsStep:n});i.current={editor:e,exporters:t,feedback:o,t:r,settingsStep:n};let a=Zt.useRef(null),l=Zt.useRef(null),[s,c]=Zt.useState(false),[d,m]=Zt.useState(""),[u,g]=Zt.useState(""),[p,f]=Zt.useState(false),[b,y]=Zt.useState(false),[v,x]=Zt.useState({}),[h,k]=Zt.useState(false),[E,C]=Zt.useState(()=>editor.initialChromePrintSettings(null)),T=Zt.useRef(E),S=Zt.useRef(void 0),P=Zt.useRef(null),w=Zt.useCallback(D=>{let{t:R}=i.current;if(D instanceof editor.ChromeExportError)return R("toolbar.printPdfMissing");if(D instanceof editor.ChromePrintError){if(D.code==="pdf-viewer-unavailable")return R("toolbar.printNoViewer");if(D.code==="pdf-load-failed")return R("toolbar.printLoadFailed");if(D.code==="print-refused")return R("toolbar.printRefused")}return R("toolbar.printFailedMessage",{message:D instanceof Error?D.message:String(D)})},[]),_=Zt.useCallback(()=>{a.current=null,y(false),f(false),c(false),k(false);},[]),L=Zt.useCallback(async(D,R)=>{let{editor:U,exporters:V}=i.current;if(!(!U||a.current!==D||P.current===D)){P.current=D,k(false),c(true);try{let Y=await editor.runChromePrint(U,V,S.current??editor.hostDocumentOf(null),R);if(a.current!==D){Y.dispose();return}l.current=Y,await Y.print({beforePrint:()=>{if(a.current!==D)throw new editor.ChromePrintError("print-ended");reactDom.flushSync(()=>f(!1));}}),a.current===D&&_();}catch(Y){if(a.current!==D)return;if(!i.current.feedback){console.error("[docx-editor] print failed",Y),_();return}c(false),g(l.current?.url??""),m(w(Y)),f(true);}}},[_,w]),N=Zt.useCallback(async D=>{let{editor:R,exporters:U,feedback:V,settingsStep:Y}=i.current;if(!R||a.current)return;let j={};if(a.current=j,S.current=D,l.current?.dispose(),l.current=null,x(j),y(true),f(true),m(""),g(""),!Y||!V||!U?.pdf){await L(j,{});return}let q=editor.initialChromePrintSettings(R.snapshot());T.current=q,C(q),c(false),k(true);},[L]),B=Zt.useCallback(D=>{let R={...T.current,...D};T.current=R,C(R);},[]),F=Zt.useCallback(()=>{let D=a.current;D&&L(D,T.current);},[L]);return Zt.useEffect(()=>()=>{a.current=null,l.current?.dispose(),l.current=null;},[]),{pending:s,error:d,url:u,visible:p,active:b,session:v,choosing:h,settings:E,execute:N,changeSettings:B,confirm:F,close:_}}var cN=()=>{};function cf(){let e=A(),t=Zt.useCallback(n=>e?e.on("hostChange",n):cN,[e]),o=Zt.useCallback(()=>e?editor.editorHostDocument(e):typeof globalThis.document>"u"?null:globalThis.document,[e]);return Zt.useSyncExternalStore(t,o,()=>null)}var dN="https://github.com/eigenpal/docx-editor/issues/new";function uN(){if(typeof globalThis.window>"u")return "";try{let e=new URL(globalThis.window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function vv(e={}){let t=e.userAgent??(typeof globalThis.navigator<"u"?globalThis.navigator.userAgent:"unknown"),o=e.viewport??(typeof globalThis.window<"u"?{width:globalThis.window.innerWidth,height:globalThis.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??uN()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
1
+ 'use strict';var Zt=require('react'),editor=require('@docx-editor.dev/core/editor'),reactDom=require('react-dom'),jsxRuntime=require('react/jsx-runtime'),i18n=require('@docx-editor.dev/i18n'),store=require('@docx-editor.dev/core/store'),classVarianceAuthority=require('class-variance-authority'),clsx=require('clsx'),Ae=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 Zt__namespace=/*#__PURE__*/_interopNamespace(Zt);var Ae__namespace=/*#__PURE__*/_interopNamespace(Ae);var mg={version:"2.35.0"};var fE=mg.version;function fg(){let e=new Map,t=new Map,o=new Set,n=0,r=0,i=null,a=[],l,s=false,c=()=>[...e].sort((u,g)=>t.get(u[0])-t.get(g[0])),d=()=>{r++;for(let u of o)u();},m=()=>{d(),!s&&(s=true,queueMicrotask(()=>{s=false,i?.setUnsupportedElementRules(c().map(([,u])=>u));}));};return {register(u,g){t.has(u)||t.set(u,n++),e.set(u,g),m();},unregister(u){e.delete(u)&&m();},connect(u){i=u,u&&m();},current:()=>c().map(([,u])=>u),setContainer(u){l?.();for(let g of a)g.setCustomized(false);a=[],l=u?editor.observeUnsupportedElements(u,g=>{a=g,d();}):void 0,d();},subscribe(u){return o.add(u),()=>o.delete(u)},snapshot:()=>r,hosts(u){let g=c();return a.filter(p=>g.find(([,f])=>editor.unsupportedElementRuleMatches(f,p.unsupported))?.[0]===u)}}}var Rr=Zt.createContext(null);function gg(e){return Zt.Children.toArray(e).some(t=>Zt.isValidElement(t)&&t.type===Zt.Fragment?gg(t.props.children):typeof t!="string"||t.trim().length>0)}function bg({host:e,children:t}){let o=gg(t);return Zt.useLayoutEffect(()=>(e.setCustomized(o),()=>{e.setCustomized(false);}),[e,o]),o?reactDom.createPortal(t,e.slot):null}function Fd({match:e,layout:t,includePartial:o,children:n}){let r=Zt.useContext(Rr);if(!r)throw new Error("DocxEditor.UnsupportedElement must render inside DocxEditor.Root.");let i=Zt.useRef(Symbol("unsupported-element-declaration")).current;return Zt.useSyncExternalStore(r.subscribe,r.snapshot,r.snapshot),Zt.useLayoutEffect(()=>{r.register(i,{includePartial:o,...e?{match:e}:{},...t?{layout:t}:{}});},[r,i,e,t,o]),Zt.useLayoutEffect(()=>()=>r.unregister(i),[r,i]),r.hosts(i).map(a=>jsxRuntime.jsx(bg,{host:a,children:n({element:a.unsupported})},a.key))}var Ld=Zt.createContext(i18n.en),Hd=Zt.createContext("en"),Ad=Zt.createContext("ltr"),Od=Zt.createContext(void 0);function Mr({i18n:e,dir:t,children:o}){let n=Zt.useContext(Ld),r=Zt.useContext(Hd),i=Zt.useContext(Ad),a=Zt.useContext(Od),l=typeof e?._lang=="string"?e._lang:r,s=i18n.chromeDirection(t,e,a),c=s??i18n.catalogDirection(e)??i,d=Zt.useMemo(()=>i18n.deepMerge(n,e),[n,e]);return jsxRuntime.jsx(Hd.Provider,{value:l,children:jsxRuntime.jsx(Ad.Provider,{value:c,children:jsxRuntime.jsx(Od.Provider,{value:s,children:jsxRuntime.jsx(Ld.Provider,{value:d,children:o})})})})}function H(){let e=Zt.useContext(Ld),t=Zt.useContext(Hd),o=Zt.useContext(Ad);return {t:Zt.useMemo(()=>i18n.createT(e,t),[e,t]),catalogue:e,lang:t,dir:o}}function lt(){return Zt.useContext(Od)}function xg(e){let{t}=H();return Zt.useCallback((o,n)=>e?.get(o)??t(o,n),[e,t])}var Bd=Zt.createContext(null);function A(){return Zt.useContext(Bd)}function Wl(e){return (e?.mounted??0)+(e?.gutters??0)>0}var At=Zt.createContext(null);var Wd=0,Zd=false,Kd=false,Zl=[],Kl=null;function Cg(e){if(typeof MessageChannel!="function"){globalThis.setTimeout(e,0);return}Kl||(Kl=new MessageChannel,Kl.port1.onmessage=()=>{let t=Zl;Zl=[];for(let o of t)try{o();}catch(n){queueMicrotask(()=>{throw n});}}),Zl.push(e),Zl.length===1&&Kl.port2.postMessage(null);}function Tg(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(Zd||(Zd=true,Wd+=1,queueMicrotask(()=>{Zd=false;}),Kd||(Kd=true,Cg(()=>{Kd=false,Wd=0;}))),Wd>16)}function Eg(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};Tg()?Cg(o):queueMicrotask(o);}}var HE=()=>{},Ud=0;function AE(){return Ud}function Za(e){return Eg(e)}function W(e,t=Object.is,o){let n=A(),r=o?.onSubscribe,i=o?.onUnsubscribe,a=Zt.useCallback(d=>{if(!n)return HE;let m=false;Ud++,r?.();let u=Za(()=>{m||d();}),g=[n.on("change",u),n.on("selectionChange",u),n.on("error",u)];return ()=>{m=true,Ud--,i?.();for(let p of g)p();}},[n,r,i]),l=Zt.useMemo(()=>{let d=false,m,u;return g=>{if(d&&g===m)return u;let p=e(g);return d&&t(u,p)?(m=g,u):(d=true,m=g,u=p,p)}},[n,e,t]),s=Zt.useCallback(()=>l(n?n.snapshot():editor.LOADING_SNAPSHOT),[n,l]),c=Zt.useCallback(()=>l(editor.LOADING_SNAPSHOT),[l]);return Zt.useSyncExternalStore(a,s,c)}function ZE(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function KE(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=ZE(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 Q({children:e,...t}){let o=Zt.Children.only(e);if(!Zt.isValidElement(o))return null;let n=o.props,r=KE(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);}),Zt.cloneElement(o,r)}var Sg="(prefers-color-scheme: dark)";function Pg(){return typeof globalThis.window<"u"&&typeof globalThis.window.matchMedia=="function"}function kg(){return Pg()?globalThis.window.matchMedia(Sg).matches:false}function wg(e,t){return e==="dark"||e==="system"&&t}function Dg(e){if(!Pg())return ()=>{};let t=globalThis.window.matchMedia(Sg);e(t.matches);let o=n=>e(n.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}var Wo=Zt.createContext(false),qn=Zt.createContext(false);function qE(){let e=Zt.useContext(Wo),t=Zt.useContext(qn);return e?"":t?"docx-editor dark ":"docx-editor "}function Ul(e){let t=e==="system",o=Zt.useSyncExternalStore(t?$E:zE,t?kg:_g,_g);return wg(e??"light",o)}function $E(e){return Dg(()=>e())}function zE(){return ()=>{}}function _g(){return false}function Ut(){return Zt.useContext(qn)}function $t(){let e=Zt.useContext(Wo),t=Zt.useContext(qn);return e?"":t?"docx-editor dark ":"docx-editor "}function VE(){return Zt.useContext(qn)?jE:GE}var GE=Object.freeze({colorMode:"light"}),jE=Object.freeze({colorMode:"dark"});var Fg=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function yt(){let e=Zt.createContext(null),t=new Map,o=y=>{let v=t.get(y.type);return v==="field"?`field:${y.props.name}`:v};function n(y,v){Zt.Children.forEach(y,x=>{Zt.isValidElement(x)&&(v(x),n(x.props.children,v));});}function r(){let y=Zt.useContext(e);if(!y)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return y.state}function i(y,v){return Zt.Children.map(y,x=>{if(!Zt.isValidElement(x))return x;let h=Fg(x.props);return h&&v.has(h)?v.get(h):x.props.children===void 0?x:Zt.cloneElement(x,{children:i(x.props.children,v)})})}function a(y){function v(x){let h=Zt.useContext(e);if(!h||x.hidden)return null;let k=y==="field"?`field:${x.name}`:y,E=h.defaults.get(k);if(!E)return x.children??null;let{children:C,asChild:T,className:S,style:P,hidden:w,name:_,...L}=x,N={...L,...E.props,className:[E.props.className,S].filter(Boolean).join(" "),style:{...E.props.style,...P}};if(T){let{children:B,className:F,style:D,...R}=N;return jsxRuntime.jsx(Q,{...R,...S?{className:S}:{},...P?{style:P}:{},children:C})}return Zt.cloneElement(E,N,C===void 0?i(E.props.children,h.overrides):C)}return t.set(v,y),v}let l=a("header"),s=a("title"),c=a("body"),d=a("footer"),m=a("apply"),u=a("cancel"),g=a("reset"),p=a("error"),f=a("field");function b({defaults:y,children:v,preset:x=true,state:h}){let k=new Map;n(y,S=>{let P=Fg(S.props);P&&k.set(P,S);});let E=new Map;n(v,S=>{let P=o(S);P&&E.set(P,S);});let C=S=>Zt.Children.toArray(S).flatMap(P=>Zt.isValidElement(P)&&P.type===Zt.Fragment?C(P.props.children):[P]),T=C(v).filter(S=>!Zt.isValidElement(S)||!o(S));return jsxRuntime.jsx(e.Provider,{value:{defaults:k,overrides:E,state:h},children:x?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i(y,E),T]}):v})}return {Header:l,Title:s,Body:c,Footer:d,Apply:m,Cancel:u,Reset:g,Error:p,Field:f,Composition:b,useState:r,part:y=>a(y)}}function Fe({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:m=true,describedBy:u,busy:g}){let p=Zt.useRef(null),f=l??p,b=Zt.useRef(i);b.current=i;let[y,v]=Zt.useState(false),x=Ut();return Zt.useLayoutEffect(()=>{let h=f.current;if(!h)return;v(!h.parentElement?.closest(".docx-editor"));let k=h.ownerDocument.activeElement,E=k===h.ownerDocument.body?null:k,C=()=>{h.open&&h.close?.();};return d?.addEventListener("abort",C),typeof h.showModal=="function"?h.showModal():h.setAttribute("open",""),(h.querySelector('input:not([disabled]),select:not([disabled]),button:not([disabled]),[tabindex="0"]')??h.querySelector("a[href]"))?.focus({preventScroll:true}),()=>{d?.removeEventListener("abort",C),typeof h.close=="function"&&h.open&&h.close(),m&&E?.isConnected&&E.focus({preventScroll:true});}},[f,d,m]),jsxRuntime.jsx("dialog",{ref:f,role:t,"aria-modal":"true","aria-label":r,"aria-describedby":u,"data-docx-busy":g?"":void 0,className:`docx-dialog${y?` docx-editor${x?" dark":""}`:""}${o?` ${o}`:""}`,style:n,"data-docx-dialog":e,onCancel:h=>{h.preventDefault(),b.current();},onMouseDown:h=>h.stopPropagation(),onClick:h=>{if(c&&h.target===h.currentTarget){let k=h.currentTarget.getBoundingClientRect();(h.clientX<k.left||h.clientX>k.right||h.clientY<k.top||h.clientY>k.bottom)&&b.current();}h.stopPropagation();},onKeyDown:h=>{h.key==="Escape"&&!h.nativeEvent.isComposing?(h.preventDefault(),b.current()):editor.trapTabWithin(h.currentTarget,h.nativeEvent)?h.preventDefault():!h.nativeEvent.isComposing&&!h.defaultPrevented&&a?.(h),h.stopPropagation();},children:s})}function Co(e,t){let o=A(),n=Gd(),r=Zt.useRef(null);return Zt.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 Gd(){let e=A(),t=Zt.useCallback(o=>{if(!e)return ()=>{};let n=true,r=Za(()=>{n&&o();}),i=[e.on("change",r),e.on("selectionChange",r),e.on("error",r)];return ()=>{n=false,i.forEach(a=>a());}},[e]);return Zt.useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function Lg(){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 Yd=Zt.createContext(null);function $n(){return Zt.useContext(Yd)}var Hg=()=>0,Xd=()=>()=>{};function zn(){let e=$n(),t=Zt.useCallback(n=>e?e.subscribeShift(n):Xd(),[e]),o=Zt.useCallback(()=>e?e.getShift():0,[e]);return Zt.useSyncExternalStore(t,o,Hg)}function Ag(){let e=$n(),t=Zt.useCallback(n=>e?e.subscribeReservation(n):Xd(),[e]),o=Zt.useCallback(()=>e?e.getReservation():0,[e]);return Zt.useSyncExternalStore(t,o,Hg)}function we(){let e=$n(),t=Zt.useCallback(r=>e?e.subscribeViewport(r):Xd(),[e]),o=Zt.useCallback(()=>e?e.getViewport():null,[e]),n=Zt.useCallback(()=>null,[]);return Zt.useSyncExternalStore(t,o,n)}function Zo(e,t,o){let n=we(),r=Zt.useRef({close:o,viewport:n});r.current={close:o,viewport:n},Zt.useEffect(()=>{let i=e.current;if(!(!t||!i))return fS(i,()=>r.current.close(),()=>r.current.viewport)},[e,t]);}function fS(e,t,o){let n=l=>{if(l.defaultPrevented||l.altKey||l.ctrlKey||l.metaKey)return;let s=l.target;if(s.matches('input[role="combobox"]')||s.matches("input, textarea, select")&&l.key!=="ArrowDown"&&l.key!=="ArrowUp")return;let d=Array.from(e.querySelectorAll('[role="option"]')).filter(g=>!g.matches(':disabled, [aria-disabled="true"]'));if(d.length===0)return;let m=d.indexOf(s),u;if(l.key==="Home")u=0;else if(l.key==="End")u=d.length-1;else if(l.key==="ArrowDown")u=(m+1)%d.length;else if(l.key==="ArrowUp")u=m<0?d.length-1:(m-1+d.length)%d.length;else return;l.preventDefault(),l.stopPropagation(),d[u]?.focus();},r=l=>{editor.isDomNode(l.relatedTarget)&&!e.contains(l.relatedTarget)&&t();},i=editor.listenForPopupEscape({popup:e,contains:l=>e.contains(l),chromeRoot:()=>e.closest(".docx-editor"),editorElements:()=>[o()],skip:l=>editor.isElementNode(l.target)&&e.contains(l.target)&&l.target.matches('input[role="combobox"]'),close:l=>{l&&e.querySelector("[aria-haspopup]")?.focus(),t();}}),a=editor.listenForPopupFocusLeave({popup:e,contains:l=>e.contains(l),close:t});return e.addEventListener("keydown",n),e.addEventListener("focusout",r),()=>{e.removeEventListener("keydown",n),e.removeEventListener("focusout",r),i(),a();}}function CS(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason&&e.value===t.value}function Jd(e){return typeof e=="string"}function re(e){let t=A(),{t:o}=H(),n=Jd(e)?e:editor.editorCommandKey(e),r=Zt.useRef(e);r.current=e;let i=Zt.useCallback(s=>{let c=r.current;if(Jd(c)){let m=editor.toolbarCommandState(t,c);return {active:m.active,enabled:m.enabled,disabledReason:i18n.localizeDisabledReason(m.disabledReason,o),value:m.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=W(i,CS),l=Zt.useCallback(s=>{let c=editor.commandExecOptions(s),d=r.current;return Jd(d)?editor.runToolbarCommand(t,d,void 0,c??{}).ok:t?t.exec(d,c).ok:false},[t]);return Zt.useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[l,a])}var Vn=Zt.createContext({t:void 0,onSave:void 0});function ES(){return Zt.useContext(Vn)}function zl(e){let{t}=H();return o=>e?.(o)??t(o)}function ae(){let{t:e}=Zt.useContext(Vn);return zl(e)}var wS=()=>()=>{},DS=()=>true,RS=()=>false;function eo(){let e=Zt.useSyncExternalStore(wS,DS,RS);return Zt.useCallback(t=>e?i18n.platformShortcut(t):t,[e])}function MS(e){let t=e.viteEnv?.DEV;return typeof t=="boolean"?t:e.hasProcess&&e.nodeEnv!=="production"}function _S(){try{return undefined}catch{return}}function xt(){let e=typeof process<"u";return MS({viteEnv:_S(),nodeEnv:e?"production":void 0,hasProcess:e})}var Zg=new Set;function un(e){!xt()||Zg.has(e)||(Zg.add(e),console.warn(`[docx-editor] ${e}`));}function Kg(e){un(`Menu.Item and ContextMenu.Slot take the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function qg(e){un(`A hidden context-menu override names "${e}", but no packaged row has that id, so nothing is removed.`);}function Ug(){un("A Menu.Item or ContextMenu.Slot has no slotId, so it renders nothing.");}function $g(){un("A Menu.Submenu has neither label nor labelKey, so its row has no name.");}function zg(e){un(`Toolbar.Button takes the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function Vg(){un("A Toolbar.Button has no slotId, so it renders nothing.");}function te(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 $(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function LS(e){if(e.slotId)return e.slotId;if(e.slot)return zg(e.slot),e.slot;Vg();}function Ko(e){let{icon:t,asChild:o,className:n,children:r,hidden:i}=e,a=LS(e)??"",{execute:l,isActive:s,isEnabled:c,disabledReason:d,value:m}=re(a),u=ae(),g=eo();if(i||!a)return null;let p=te(a),f=g(u(p?.labelKey??a)),b=editor.chromeSlotIsToggle(a),y={onClick:()=>l(),onMouseDown:$,disabled:!c,"data-slot":a,className:`docx-toolbar__button${n?` ${n}`:""}`,...s?{"data-active":""}:{},...c?{}:{"data-disabled":""},...b?{"aria-pressed":s}:{},...m!==null?{"data-value":m}:{},"aria-label":f,title:d??f};return o?jsxRuntime.jsx(Q,{...y,children:r}):jsxRuntime.jsx("button",{type:"button",...y,children:t??r??oe(p?.paths)})}Ko.docxToolbarPart=true;var KS=[{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"}],Gg=[{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"}],jg=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Gl=["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"],pn=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),zt=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function qS(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?[zt(5),zt(15),zt(25),zt(35),zt(50)]:o===0?[pn(50),pn(35),pn(25),pn(15),pn(5)]:o>=.8?[zt(10),zt(25),zt(50),zt(75),zt(90)]:[pn(80),pn(60),pn(40),zt(25),zt(50)]}var US=/^[0-9A-Fa-f]{6}$/;function $S(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 zS(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 Ir({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,"aria-pressed":n,title:o,"data-value":e,...n?{"data-selected":""}:{},...t.startsWith("var(")||zS(t.replace("#",""))?{"data-light":""}:{},onMouseDown:$,onClick:()=>r(e)})}function VS({apply:e,label:t,current:o,themeHexes:n}){let r=n.map(qS),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(Ir,{value:a,css:`#${a.toLowerCase()}`,title:t(Gl[l]),selected:o===a,apply:e},`base-${l}`)),i.map(a=>n.map((l,s)=>{let c=r[s][a],d=$S(l,c.apply);return jsxRuntime.jsx(Ir,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Gl[s])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${s}`)}))]})]})}function GS(e){let{apply:t,label:o,current:n}=e,[r,i]=Zt.useState(""),a=US.test(r);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(VS,{...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:KS.map(l=>jsxRuntime.jsx(Ir,{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:$,onClick:()=>t(r.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function eu({apply:e,current:t}){let o=A(),n=ae(),r=o?.getDocumentThemeColors()??[],i=r.length===Gl.length?r.map(l=>l.hex):jg,a=t?.toUpperCase()??null;return jsxRuntime.jsx(GS,{apply:e,label:n,current:a,themeHexes:i})}var jS=Gg.filter(e=>e.value!=="white");function YS({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:jS.map(n=>jsxRuntime.jsx(Ir,{value:n.value,css:n.css,title:t(n.labelKey),selected:o===n.value,apply:e},n.value))})]})}function Yg(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 m=A(),{isEnabled:u,disabledReason:g}=re(t),p=ae(),[f,b]=Zt.useState(false),[y,v]=Zt.useState(o),x=Zt.useRef(null);Zo(x,f,()=>b(false));let h=W(P=>{if(a){let w=P.formatting?.color;return w&&w.kind==="hex"?w.value.toUpperCase():null}return P.formatting?.highlight??null}),k=m?.getDocumentThemeColors()??[],E=k.length===Gl.length?k.map(P=>P.hex):jg;Zt.useEffect(()=>{if(f)return editor.listenForOutsidePress({popup:x.current,close:()=>b(false)})},[f]);let C=Zt.useCallback(P=>{if(b(false),!m)return;m.focus();let w=editor.commandForSlotValue(t,P);w&&m.can(w).ok&&(m.exec(w),P!==r.value&&v(P));},[m]),T=Zt.useMemo(()=>te(t),[]);if(c)return null;let S=p(T?.labelKey??t);return jsxRuntime.jsxs("div",{ref:x,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":S,title:g??S,onMouseDown:$,onClick:()=>C(y),children:[d??oe(T?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:n(y)},"aria-hidden":"true"})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!u,...u?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":f,"aria-label":S,title:g??S,onMouseDown:$,onClick:()=>b(P=>!P),children:"\u25BE"}),f?jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":S,onMouseDown:$,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:$,onClick:()=>C(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:C,label:p,current:h,themeHexes:E})]}):null]})},{docxSlot:t})}var XS=new Map(Gg.map(e=>[e.value,e.css])),tu=Yg({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsxRuntime.jsx(eu,{apply:e.apply,current:e.current})}),ou=Yg({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>XS.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsxRuntime.jsx(YS,{...e})});var ru=e=>e==="auto"?"currentColor":e==="byAuthor"?"var(--doc-review-author-0)":e==="none"?"transparent":`var(--doc-revision-color-${e})`;function Yl({label:e,value:t,values:o,disabled:n,change:r,t:i}){let a=Zt.useId(),[l,s]=Zt.useState(false),c=Zt.useRef(null),d=Zt.useRef(null),m=Zt.useRef(null);Zt.useLayoutEffect(()=>{if(!l||!m.current||!d.current)return;let g=editor.observeContentControlPopup(m.current,d.current);return (m.current.querySelector("[data-selected]")??m.current.querySelector("button"))?.focus(),g},[l]),Zt.useEffect(()=>{if(n&&s(false),!l)return;let g=c.current?.ownerDocument,p=f=>{c.current?.contains(f.target)||s(false);};return g?.addEventListener("pointerdown",p),()=>g?.removeEventListener("pointerdown",p)},[l,n]);let u=()=>{s(false),d.current?.focus();};return jsxRuntime.jsxs("div",{ref:c,className:"docx-revision-color-picker",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||s(false);},children:[jsxRuntime.jsx("span",{id:`${a}-label`,children:e}),jsxRuntime.jsxs("button",{ref:d,type:"button",className:"docx-revision-color-trigger",disabled:n,"aria-labelledby":`${a}-label ${a}-value`,"aria-expanded":l&&!n,"aria-controls":`${a}-options`,onClick:()=>s(!l),children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:ru(t)}}),jsxRuntime.jsx("span",{id:`${a}-value`,children:i(`values.${t}`)})]}),jsxRuntime.jsxs("div",{ref:m,id:`${a}-options`,className:"docx-revision-color-options",hidden:!l||n,role:"group","aria-labelledby":`${a}-label`,onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),u());let p=Array.from(g.currentTarget.querySelectorAll("button")),f=p.indexOf(g.target),b=g.key==="Home"?0:g.key==="End"?p.length-1:["ArrowRight","ArrowDown"].includes(g.key)?(f+1)%p.length:["ArrowLeft","ArrowUp"].includes(g.key)?(f-1+p.length)%p.length:null;b!==null&&(g.preventDefault(),g.stopPropagation(),p[b]?.focus());},children:[jsxRuntime.jsx("div",{className:"docx-revision-color-special",children:o.filter(g=>["auto","none","byAuthor"].includes(g)).map(g=>jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear","aria-pressed":t===g,"data-selected":t===g?"":void 0,onClick:()=>{r(g),u();},children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:ru(g)}}),i(`values.${g}`)]},g))}),jsxRuntime.jsx("div",{className:"docx-toolbar__swatch-grid",children:o.filter(g=>!["auto","none","byAuthor"].includes(g)).map(g=>jsxRuntime.jsx(Ir,{value:g,css:ru(g),title:i(`values.${g}`),selected:t===g,apply:p=>{r(p),u();}},g))})]})]})}var Xg=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],rP=["byAuthor","auto",...editor.REVISION_MARKUP_COLORS];function Jg(e,t,o){let{values:n}=e,r=a=>{let l=a==="changedLines"?["none","leftBorder","rightBorder","outsideBorder"]:a==="deletions"||a==="movedFrom"?[...Xg,"hidden","caret","pound"]:Xg,s=(a==="movedFrom"||a==="movedTo")&&!n.trackMoves;return jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxRuntime.jsxs("div",{className:"docx-revision-markup-row",children:[jsxRuntime.jsx("span",{className:"docx-revision-markup-row-title","aria-hidden":"true",children:t(a)}),jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("span",{className:"docx-revision-markup-field-label",children:t(a)}),jsxRuntime.jsx("select",{value:n[a].mark,disabled:s,onChange:c=>e.setValue(a,{...n[a],mark:c.target.value}),children:l.map(c=>jsxRuntime.jsx("option",{value:c,children:t(`values.${c}`)},c))})]}),jsxRuntime.jsx(Yl,{label:t(`${a}Color`),value:n[a].color,values:rP,disabled:s,t,change:c=>e.setValue(a,{...n[a],color:c})})]}),a!=="changedLines"&&jsxRuntime.jsx("div",{className:"docx-revision-markup-background",children:jsxRuntime.jsx(Yl,{label:t(`${a}Background`),value:n[a].background,values:["none","byAuthor",...editor.REVISION_MARKUP_COLORS],disabled:s,t,change:c=>e.setValue(a,{...n[a],background:c})})})]})},i=a=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxRuntime.jsxs("label",{children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n[a],"aria-describedby":`${o}-${a}`,onChange:l=>e.setValue(a,l.target.checked)}),t(a)]}),jsxRuntime.jsx("p",{id:`${o}-${a}`,children:t(`${a}Note`)})]});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("markup")}),r("insertions"),r("deletions"),r("changedLines")]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("moves")}),i("trackMoves"),r("movedFrom"),r("movedTo")]}),jsxRuntime.jsxs("fieldset",{"data-docx-part":"field","data-docx-field":"cells",className:"docx-revision-markup-tableCells",children:[jsxRuntime.jsx("legend",{children:t("tableCells")}),["inserted","deleted","merged","split"].map(a=>jsxRuntime.jsx(Yl,{label:t(`${a}Cells`),value:n.cells[a],values:["byAuthor","none",...editor.REVISION_MARKUP_COLORS],t,change:l=>e.setValue("cells",{...n.cells,[a]:l})},a))]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("formatting")}),i("trackFormatting"),r("formatting")]})]})}var oo=yt();function uP(){return oo.useState()}function pP({session:e,...t}){return e?jsxRuntime.jsx(mP,{session:e,...t}):null}function mP({session:e,children:t,preset:o,className:n,style:r}){let i=Zt.useId(),{t:a}=H(),l=f=>a(`revisionMarkup.${f}`),s=Zt.useCallback(f=>e.subscribe(f),[e]),c=Zt.useCallback(()=>e.get(),[e]),d=Zt.useSyncExternalStore(s,c,c),[m,u]=Zt.useState(e.signal.aborted),g=Zt.useRef(null);Zt.useEffect(()=>{g.current=e;let f=()=>u(true);return u(e.signal.aborted),e.signal.addEventListener("abort",f),()=>{e.signal.removeEventListener("abort",f),g.current=null,queueMicrotask(()=>{g.current!==e&&e.cancel();});}},[e]);let p={values:d,setValue(f,b){e.set({[f]:b});},errors:{},isEnabled:!m&&e.canApply(),apply(){e.apply();},cancel(){e.cancel();},reset(){e.reset();}};return m?null:jsxRuntime.jsx(Fe,{kind:"revisionMarkup",label:l("title"),className:["docx-revision-markup-dialog",n].filter(Boolean).join(" "),style:r,onClose:p.cancel,dismissOutside:false,sessionSignal:e.signal,children:jsxRuntime.jsx(oo.Composition,{state:p,preset:o,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{"data-docx-part":"header",children:jsxRuntime.jsx("h2",{"data-docx-part":"title",children:l("title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-revision-markup-body",children:Jg(p,l,i)}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-revision-markup-actions",children:[jsxRuntime.jsx("button",{"data-docx-part":"reset",type:"button",onClick:p.reset,children:l("reset")}),jsxRuntime.jsx("span",{"data-docx-part":"error",role:"alert",children:p.errors.form}),jsxRuntime.jsx("button",{"data-docx-part":"cancel",type:"button",onClick:p.cancel,children:l("cancel")}),jsxRuntime.jsx("button",{"data-docx-part":"apply",type:"button",disabled:!p.isEnabled,onClick:p.apply,children:l("ok")})]})]}),children:t})})}var Ka=Object.assign(pP,{Header:oo.Header,Title:oo.Title,Body:oo.Body,Footer:oo.Footer,Apply:oo.Apply,Cancel:oo.Cancel,Error:oo.Error,Field:oo.Field,Reset:oo.Reset});var Vt=yt();function EP(){return Vt.useState()}var tb=new WeakMap,SP=0,PP=e=>{let t=tb.get(e);return t===void 0&&tb.set(e,t=SP++),t};function kP({session:e,...t}){return e?jsxRuntime.jsx(wP,{session:e,...t},PP(e)):null}function wP({session:e,children:t,preset:o,className:n,style:r}){let i=Zt.useId(),{t:a}=H(),l=L=>a(`compareDocuments.${L}`),[s,c]=Zt.useState(()=>({revised:null,authorName:e.defaultAuthor,detectFormatChanges:true,removeDateAndTime:false})),[d,m]=Zt.useState(),[u,g]=Zt.useState(),[p,f]=Zt.useState(false),[b,y]=Zt.useState(null),[v,x]=Zt.useState(e.signal.aborted),h=Zt.useRef(null),[k,E]=Zt.useState(null);Zt.useLayoutEffect(()=>{k&&editor.focusCompareDocumentsControl(h.current,k.moment);},[k]);let C=W(Zt.useCallback(()=>e.canApply(),[e]),Object.is),T=Zt.useRef(false),S=Zt.useRef(null);Zt.useEffect(()=>{S.current=e;let L=()=>x(true);return x(e.signal.aborted),e.signal.addEventListener("abort",L),()=>{e.signal.removeEventListener("abort",L),S.current=null,queueMicrotask(()=>{S.current!==e&&e.cancel();});}},[e]);let P=async()=>{let L=s.revised;if(!L){m(l("fileRequired"));return}if(!T.current){T.current=true,f(true),E({moment:"busy"}),m(void 0),g(void 0);try{let N;try{N=new Uint8Array(await L.arrayBuffer());}catch{e.signal.aborted||(m(l("readFailed")),f(!1),E({moment:"refused"}));return}if(e.signal.aborted)return;let B=await e.apply({revised:N,authorName:s.authorName,detectFormatChanges:s.detectFormatChanges,...s.removeDateAndTime?{removeDateAndTime:!0}:{}},{onProgress:y});if(e.signal.aborted)return;y(null),B.ok?g(a("compareDocuments.noDifferences")):m(a(editor.compareDocumentsErrorKey(B))),f(!1),E({moment:B.ok?"unchanged":"refused"});}finally{T.current=false;}}},w=b?a(`compareDocuments.phases.${b.phase}`):l("comparing"),_={values:s,setValue(L,N){m(void 0),g(void 0),c(B=>({...B,[L]:N}));},errors:d===void 0?{}:{form:d},isEnabled:!v&&!p&&s.revised!==null&&C,busy:p,progress:b,cancelable:e.cancelable,notice:u,originalHasTrackedChanges:e.originalHasTrackedChanges,apply(){P();},cancel(){(!p||e.cancelable)&&e.cancel();}};return v?null:jsxRuntime.jsx(Fe,{kind:"compareDocuments",label:l("title"),className:["docx-compare-documents-dialog",n].filter(Boolean).join(" "),style:r,onClose:_.cancel,panelRef:h,dismissOutside:false,sessionSignal:e.signal,describedBy:o===false?void 0:`${i}-description${e.originalHasTrackedChanges?` ${i}-tracked`:""}`,busy:p,children:jsxRuntime.jsx(Vt.Composition,{state:_,preset:o,defaults:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{"data-docx-part":"header",children:[jsxRuntime.jsx("h2",{"data-docx-part":"title",children:l("title")}),jsxRuntime.jsx("p",{id:`${i}-description`,children:l("description")}),e.originalHasTrackedChanges?jsxRuntime.jsx("p",{id:`${i}-tracked`,"data-docx-part":"trackedChanges",className:"docx-compare-documents-tracked",children:l("trackedChangesAccepted")}):null]}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-compare-documents-body",children:[jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"revised",children:[jsxRuntime.jsx("span",{children:l("revisedFile")}),jsxRuntime.jsx("input",{type:"file",accept:editor.COMPARE_DOCUMENTS_ACCEPT,disabled:p,onChange:L=>_.setValue("revised",L.currentTarget.files?.[0]??null)})]}),jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"authorName",children:[jsxRuntime.jsx("span",{children:l("author")}),jsxRuntime.jsx("input",{type:"text",autoComplete:"off",value:s.authorName,disabled:p,onChange:L=>_.setValue("authorName",L.currentTarget.value)})]}),jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"detectFormatChanges",className:"docx-compare-documents-check",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:s.detectFormatChanges,disabled:p,onChange:L=>_.setValue("detectFormatChanges",L.currentTarget.checked)}),l("detectFormatting")]})]}),p?jsxRuntime.jsxs("div",{"data-docx-part":"progress","aria-busy":"true",children:[jsxRuntime.jsx("progress",{className:"docx-compare-documents-progress",max:1,value:b?.fraction,"aria-label":l("comparing"),"aria-valuetext":w}),jsxRuntime.jsx("span",{className:"docx-compare-documents-phase",tabIndex:-1,[editor.COMPARE_DOCUMENTS_PHASE_ATTRIBUTE]:"",children:w})]}):null,jsxRuntime.jsx("p",{"data-docx-part":"error",role:"alert",className:"docx-compare-documents-error",children:_.errors.form}),jsxRuntime.jsx("p",{"data-docx-part":"notice",role:"status",className:"docx-compare-documents-notice",children:u}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-compare-documents-actions",children:[jsxRuntime.jsx("button",{"data-docx-part":"cancel",type:"button",disabled:p&&!e.cancelable,onClick:_.cancel,children:u?a("common.close"):l("cancel")}),jsxRuntime.jsx("button",{"data-docx-part":"apply",type:"button",disabled:!_.isEnabled,onClick:_.apply,children:l(p?"comparing":"compare")})]})]}),children:t})})}var qa=Object.assign(kP,{Header:Vt.Header,Title:Vt.Title,Body:Vt.Body,Footer:Vt.Footer,Apply:Vt.Apply,Cancel:Vt.Cancel,Error:Vt.Error,Field:Vt.Field,Progress:Vt.part("progress"),Notice:Vt.part("notice")});function lu(e){let t=A(),o=Zt.useRef(e.onRevisionMarkupChange);o.current=e.onRevisionMarkupChange;let{onRevisionMarkupChange:n,...r}=e,i=JSON.stringify(r);return Zt.useEffect(()=>t?.on("revisionMarkupChange",a=>o.current?.(a)),[t]),Zt.useEffect(()=>{t&&t.setRevisionMarkup(JSON.parse(i));},[t,i]),null}function Ua({open:e,format:t,pending:o,error:n,onClose:r,className:i,style:a,children:l}){let{t:s}=H();if(!e)return null;let c=s(n?t==="pdf"?"toolbar.exportPdfFailed":"toolbar.exportMarkdownFailed":t==="pdf"?"toolbar.exportingPdf":"toolbar.exportingMarkdown");return jsxRuntime.jsx(Fe,{kind:"export",label:c,role:n?"alertdialog":"dialog",className:`docx-export-dialog${o?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:r,children:l??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"docx-dialog__header",children:[o&&jsxRuntime.jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsxRuntime.jsx("span",{className:"docx-export-dialog__spinner"})}),jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:c})]}),jsxRuntime.jsx("div",{className:"docx-dialog__body",children:jsxRuntime.jsx("p",{className:"docx-export-dialog__message",role:n?"alert":"status",children:n||s("toolbar.exportDownloadHint")})}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:s(n?"common.close":"toolbar.exportContinueEditing")})})]})})}function $a({open:e,pending:t,error:o,url:n,onClose:r,choosing:i=false,settings:a,onSettingsChange:l,onPrint:s,className:c,style:d,children:m}){let{t:u}=H();if(!e)return null;let g=i&&a&&l&&s,p=u(o?"toolbar.printFailed":g?"toolbar.print":"toolbar.printPreparing"),f=n.startsWith("blob:")?n:"";return jsxRuntime.jsx(Fe,{kind:"print",label:p,role:o?"alertdialog":"dialog",className:`docx-export-dialog docx-print-dialog${t?" docx-export-dialog--pending":""}${c?` ${c}`:""}`,style:d,dismissOutside:false,onClose:r,onKeyDown:b=>{editor.isChromePrintShortcut(b.nativeEvent)&&(b.preventDefault(),g&&!b.repeat&&s());},children:m??(g?jsxRuntime.jsx(HP,{title:p,settings:a,onSettingsChange:l,onPrint:s,onClose:r}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("header",{className:"docx-dialog__header",children:[t&&jsxRuntime.jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsxRuntime.jsx("span",{className:"docx-export-dialog__spinner"})}),jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:p})]}),o&&jsxRuntime.jsx("div",{className:"docx-dialog__body",children:jsxRuntime.jsx("p",{className:"docx-export-dialog__message",role:"alert",children:o})}),jsxRuntime.jsxs("footer",{className:"docx-dialog__footer",children:[o&&f&&jsxRuntime.jsx("a",{className:"docx-dialog__link-button docx-print-dialog__open",href:f,target:"_blank",rel:"noopener noreferrer",children:u("toolbar.printOpenPdf")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",ref:LP,onClick:r,children:u(o?"common.close":"common.cancel")})]})]}))})}function LP(e){if(!editor.isHTMLElementNode(e))return;let t=e.ownerDocument.activeElement;(!t||!e.closest("dialog")?.contains(t))&&e.focus({preventScroll:true});}function HP({title:e,settings:t,onSettingsChange:o,onPrint:n,onClose:r}){let{t:i}=H(),a=Zt.useId(),l=t.displayMode==="all-markup";return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header","data-docx-part":"print-settings",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:e})}),jsxRuntime.jsxs("div",{className:"docx-dialog__body",children:[jsxRuntime.jsxs("fieldset",{className:"docx-dialog__fieldset",children:[jsxRuntime.jsx("legend",{className:"docx-dialog__section-label",children:i("toolbar.printMarkup")}),editor.CHROME_PRINT_DISPLAY_MODES.map(({mode:s,labelKey:c})=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":s,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${a}-mode`,checked:t.displayMode===s,onChange:()=>o({displayMode:s})}),i(c)]},s))]}),jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":"comments",className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.comments,"aria-describedby":l?void 0:`${a}-comments-note`,onChange:s=>o({comments:s.target.checked})}),i("toolbar.printComments")]}),!l&&jsxRuntime.jsx("p",{id:`${a}-comments-note`,className:"docx-dialog__note",children:i("toolbar.printCommentsNote",{mode:i("review.allMarkup")})})]}),jsxRuntime.jsxs("footer",{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:n,children:i("toolbar.print")})]})]})}var St={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function Nr({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:St.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 Fr({noteKind:e,x:t,y:o,onDelete:n,onConvert:r,onConvertAll:i,onOpenProperties:a,onClose:l,deleteEnabled:s,convertEnabled:c,convertAllEnabled:d,deleteDisabledReason:m,convertDisabledReason:u,convertAllDisabledReason:g,className:p}){let{t:f}=H();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:St.popover,minWidth:160,background:"var(--doc-popover-bg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",padding:4},onMouseDown:$,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!s,title:m,onClick:n,children:f("notes.delete")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!c,title:u,onClick:r,children:f(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:f(e==="footnote"?"notes.convertAllFootnotes":"notes.convertAllEndnotes")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",onClick:a,children:f("dialogs.footnoteProperties.title")})]})}function BP(e){return t=>Zt.createElement(e,t)}var ab=new WeakMap,WP=0;function Te(e,t,o){if(e===false)return null;let n=e(t);if(!o)return n;let r=ab.get(o);return r===void 0&&ab.set(o,r=++WP),Zt.createElement(Zt.Fragment,{key:r},n)}var su=Zt.createContext(void 0),Rt=()=>Zt.useContext(su);function Lr(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 ja(e){return e.paragraphId===""}var GP=4096,Hr=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),jP=e=>e;function YP(e){let t=r=>!!r&&(r.width>0||r.height>0),o=editor.hostDocumentOf(e);if(o){let i=o.querySelector("[data-docx-caret]")?.getBoundingClientRect();if(t(i))return {left:i.left,top:i.bottom}}let n=o?o.getSelection():null;if(n&&n.rangeCount>0){let r=n.getRangeAt(0),i=r.getBoundingClientRect();if(t(i))return {left:i.left,top:i.bottom};let a=r.startContainer,s=(editor.isElementNode(a)?a:a.parentElement)?.getBoundingClientRect();if(t(s))return {left:s.left,top:s.bottom}}return null}var Ya=Zt.createContext(null),cu=Zt.createContext(null);function du(){let e=Zt.useContext(cu);Zt.useEffect(()=>e?.(),[e]);}function XP(){let e=Zt.useContext(Ya);du();let t=Xl(e===null);return e??t}function Xl(e=true){let t=A(),o=we(),n=Zt.useRef(o);n.current=o;let[r,i]=Zt.useState(Hr),a=Zt.useRef(null),l=Zt.useRef(""),s=Zt.useRef(false),c=Zt.useRef(r);c.current=r;let d=W(jP),m=t?t.can({type:"insertText",text:""}).ok:false,u=Zt.useCallback(()=>{l.current="",s.current=false;let T=a.current;T&&(T.editor.releaseSelection(T.pin),a.current=null);},[]),g=Zt.useCallback((T=false)=>{let S=l.current;return S===""||!t?false:!s.current&&t.surface?.hyperlinks.selectionIsPendingDeletion()===true?true:T&&S.length>GP?false:t.query({type:"selectedText"})!==S},[t]),p=Zt.useCallback((T,S)=>{u(),i({mode:T?"reading":"editing",link:T??null,anchor:S??null,text:T?.text??"",url:T?T.kind==="internal"?`#${T.anchor??""}`:T.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,u]),f=Zt.useCallback(()=>{u(),i(Hr);},[u]);Zt.useEffect(()=>u,[u]);let b=Zt.useCallback(()=>{let T=YP(n.current);u();let S=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(S&&ja(S)){p(S,T);return}if(S){i({mode:"editing",link:S,anchor:T,text:S.text,url:S.kind==="internal"?`#${S.anchor??""}`:S.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let P=t?.surface?.hyperlinks.wordAtCaret()??null;P&&t?.surface?.setSelection({anchor:P.from,head:P.to});let w=t?.query({type:"selectedText"})??"",_=t?.retainSelection()??null;t&&_&&(a.current={editor:t,pin:_}),l.current=w,s.current=t?.surface?.hyperlinks.selectionIsPendingDeletion()===true,i({mode:"editing",link:null,anchor:T,text:w,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,p,u]);Zt.useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:T=>p(T.link,{left:T.rect.left,top:T.rect.bottom}),onRequest:b})},[t,e,p,b]),Zt.useEffect(()=>{let T=c.current;if(T.mode!=="reading"||!T.link)return;let S=ja(T.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;S&&S.id===T.link.id||i(Hr);},[d,t]),Zt.useEffect(()=>{let T=c.current;if(T.mode!=="editing"||T.link)return;let S=t?.surface;S&&(S.retainedSelection()&&!g(true)||f());},[d,t,g,f]);let y=Zt.useCallback(async()=>{let T=c.current.link?.href;if(!T)return false;try{await editor.hostWindowOf(n.current).navigator.clipboard.writeText(T);}catch{return false}return i(S=>({...S,copied:true})),true},[]),v=Zt.useCallback(()=>{i(T=>({...T,mode:"editing",copied:false,error:false}));},[]),x=Zt.useCallback(T=>{i(S=>({...S,text:T,copied:false,error:false}));},[]),h=Zt.useCallback(T=>{i(S=>({...S,url:T,copied:false,error:false}));},[]),k=Zt.useCallback(()=>{let T=c.current,S=t?.surface?.hyperlinks;if(!S)return false;if(!T.link&&g())return f(),false;let P=T.url.trim();if(P.length===0)return i(L=>({...L,error:true})),false;let w=P.startsWith("#");return S.applyHyperlink({...w?{anchor:P.slice(1)}:{url:P},...T.text.trim().length>0?{text:T.text}:{}})?(f(),true):(i(L=>({...L,error:true})),false)},[t,f,g]),E=Zt.useCallback(()=>{let T=t?.surface?.hyperlinks,S=c.current.link;if(!T)return false;let P=T.removeHyperlink(S?.id);return P&&f(),P},[t,f]),C=Zt.useCallback(()=>{let T=t?.surface?.navigation,S=c.current.link;if(!T||!S)return false;if(S.kind==="internal"){let w=S.anchor?T.goToBookmark(S.anchor):false;return w&&i(Hr),w}let P=T.openExternal(S.href);return P&&i(Hr),P},[t]);return Zt.useMemo(()=>({state:r.mode==="closed"?Hr:{...r,canEdit:m},open:p,openAtCaret:b,close:f,copy:y,beginEdit:v,setText:x,setUrl:h,commitEdit:k,unlink:E,openTarget:C}),[r,m,p,b,f,y,v,x,h,k,E,C])}function Xn(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Xa(){let e=A();return Zt.useCallback(()=>{e?.focus();},[e])}var Jl=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"})}),ak="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",ik="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",lk="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",sk="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 ck({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=So();du();let a=Zt.useRef(null),{state:l,close:s}=i,c=Xa();Zt.useEffect(()=>{if(l.mode==="closed")return;let b=x=>{x.key==="Escape"&&(x.preventDefault(),s(),c());},y=editor.hostDocumentOf(a.current);y.addEventListener("keydown",b);let v=editor.listenForOutsidePress({popup:y,contains:x=>a.current?.contains(x)===true,close:s});return ()=>{y.removeEventListener("keydown",b),v();}},[l.mode,s,c]);let[d,m]=Zt.useState(null);Zt.useLayoutEffect(()=>{let b=l.anchor,y=a.current;if(!b||!y){m(null);return}let v=y.offsetParent;if(!v){m(null);return}let{left:x,top:h}=Lr(v,b.left,b.top),k=Math.max(0,v.scrollWidth-y.offsetWidth);m({left:Math.max(0,Math.min(x,k)),top:h});},[l.anchor]);let{t:u}=H(),g=l.mode==="editing"?u(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):u("hyperlinkPopup.editLink"),p=r?jsxRuntime.jsx(dk,{children:n}):n;if(o)return l.mode==="closed"?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:n});let f={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:Xn,style:d??void 0,"aria-label":g};return l.mode==="closed"?null:t?jsxRuntime.jsx(Q,{...f,children:n}):jsxRuntime.jsx("div",{...f,children:p})}function dk({children:e}){let{state:t}=So(),o=Zt.useMemo(()=>uk(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(bu,{})),n("Error",jsxRuntime.jsx(yu,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Apply",jsxRuntime.jsx(hu,{})),n("Cancel",jsxRuntime.jsx(xu,{}))]}),o.__extra]});let r=t.canEdit&&!(t.link&&ja(t.link));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n("Url",jsxRuntime.jsx(pu,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Copy",jsxRuntime.jsx(mu,{})),r?n("Edit",jsxRuntime.jsx(fu,{})):null,r?n("Unlink",jsxRuntime.jsx(gu,{})):null]}),o.__extra]})}function uk(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===Zt.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 So(){return Zt.useContext(Ya)??pk}var pk={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 pu({className:e,asChild:t,hidden:o,children:n}){let{state:r,openTarget:i}=So(),{t:a}=H();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=jsxRuntime.jsx("bdi",{dir:s?void 0:"ltr",children:c}),m=a(l?"hyperlinkPopup.inertTarget":s?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),u={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...l?{"data-inert":""}:{},title:m,onMouseDown:Xn,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsxRuntime.jsx(Q,{...u,className:e,children:n}):l?jsxRuntime.jsxs("span",{...u,children:[n??d,jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:m})]}):jsxRuntime.jsxs("button",{...u,children:[n??d,Jl(sk)]})}pu.docxHyperLinkPart="Url";function mu({className:e,asChild:t,hidden:o,children:n,icon:r}){let{state:i,copy:a}=So(),{t:l}=H();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:Xn,onClick:()=>{a();}};return t?jsxRuntime.jsx(Q,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:r??n??Jl(ak)})}mu.docxHyperLinkPart="Copy";function fu({className:e,asChild:t,hidden:o,children:n,icon:r}){let{beginEdit:i}=So(),{t:a}=H();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:Xn,onClick:()=>i()};return t?jsxRuntime.jsx(Q,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:r??n??Jl(ik)})}fu.docxHyperLinkPart="Edit";function gu({className:e,asChild:t,hidden:o,children:n,icon:r}){let{unlink:i}=So(),a=Xa(),{t:l}=H();if(o)return null;let s=l("hyperlinkPopup.removeLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":s,title:s,onMouseDown:Xn,onClick:()=>{i()&&a();}};return t?jsxRuntime.jsx(Q,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:r??n??Jl(lk)})}gu.docxHyperLinkPart="Unlink";function bu({className:e,hidden:t}){let{state:o,setText:n,setUrl:r,commitEdit:i,close:a}=So(),l=Xa(),{t:s}=H(),c=Zt.useRef(null),d=Zt.useId(),m=Zt.useId();Zt.useEffect(()=>{o.mode==="editing"&&(c.current?.focus({preventScroll:true}),c.current?.select());},[o.mode]);let u=Zt.useCallback(g=>{if(g.key==="Enter"){g.preventDefault(),i()&&l();return}g.key==="Escape"&&(g.preventDefault(),a(),l());},[i,a,l]);return t?null:jsxRuntime.jsxs("div",{className:`docx-hyperlink-popup__fields${e?` ${e}`:""}`,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:s("hyperlinkPopup.displayTextPlaceholder")}),jsxRuntime.jsx("input",{id:d,"data-testid":"hyperlink-popup-text",className:"docx-hyperlink-popup__input",value:o.text,dir:o.text?"auto":void 0,placeholder:s("hyperlinkPopup.displayTextPlaceholder"),onChange:g=>n(g.target.value),onKeyDown:u}),jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:m,children:s("hyperlinkPopup.urlLabel")}),jsxRuntime.jsx("input",{id:m,ref:c,"data-testid":"hyperlink-popup-url-input",className:"docx-hyperlink-popup__input",value:o.url,dir:"ltr",placeholder:s("hyperlinkPopup.urlPlaceholder"),onChange:g=>r(g.target.value),onKeyDown:u})]})}bu.docxHyperLinkPart="Fields";function hu({className:e,asChild:t,hidden:o,children:n}){let{state:r,commitEdit:i}=So(),a=Xa(),{t:l}=H();if(o)return null;let s=l("hyperlinkPopup.apply"),c={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:Xn,onClick:()=>{i()&&a();}};return t?jsxRuntime.jsx(Q,{...c,className:e,children:n}):jsxRuntime.jsx("button",{...c,children:n??s})}function yu({className:e,hidden:t}){let{state:o}=So(),{t:n}=H();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")})}yu.docxHyperLinkPart="Error";hu.docxHyperLinkPart="Apply";function xu({className:e,asChild:t,hidden:o,children:n}){let{close:r}=So(),i=Xa(),{t:a}=H();if(o)return null;let l=a("hyperlinkPopup.cancel"),s={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:Xn,onClick:()=>{r(),i();}};return t?jsxRuntime.jsx(Q,{...s,className:e,children:n}):jsxRuntime.jsx("button",{...s,children:n??l})}xu.docxHyperLinkPart="Cancel";var Ja=Object.assign(ck,{Url:pu,Copy:mu,Edit:fu,Unlink:gu,Fields:bu,Error:yu,Apply:hu,Cancel:xu});var Mt={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function bk(e){return e==="sdtLocked"||e==="sdtContentLocked"}function hk(e){return e==="contentLocked"||e==="sdtContentLocked"}function Cu(e,t){return !e.ok&&e.code===t}function Po(){let e=Zt.useContext(Tu),t=Ql();return e??t}function Ql(){let e=A(),[t,o]=Zt.useState(false),[n,r]=Zt.useState(false),[i,a]=Zt.useState(false),l=W(C=>C),s=e?.surface??null,c=s?.contentControls;Zt.useEffect(()=>{r(c?.showAll()??s?.state().contentControls.showAll??false),a(c?.formFill()??s?.state().contentControls.formFill??false);},[l,c,s]);let d=Zt.useMemo(()=>{if(!e)return null;let C=c?.atCaret()??null;if(C){let F=c?.disabledReason(C.id,"edit")??null,D=c?.disabledReason(C.id,"remove")??null;return {id:C.id,tag:C.tag??null,alias:C.alias??null,controlType:C.controlType,locked:hk(C.effectiveLock)||F==="locked",removalLocked:bk(C.effectiveLock)||D==="locked",placeholder:C.placeholder,bound:C.bound||F==="bound",effectiveLock:C.effectiveLock}}let T=e.query({type:"contentControlAt"});if(!T)return null;let S=c?.disabledReason(T.id,"edit")??null,P=c?.disabledReason(T.id,"remove")??null,w=e.can({type:"setContentControlValue",value:""}),_=e.can({type:"removeContentControl"}),L=T.locked===true||S==="locked"||Cu(w,"locked"),N=S==="bound"||Cu(w,"bound"),B=P==="locked"||Cu(_,"locked");return {id:T.id,tag:T.tag??null,alias:T.alias??null,controlType:T.controlType,locked:L,removalLocked:B,placeholder:false,bound:N,effectiveLock:null}},[e,l,c]),m=Zt.useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=Zt.useCallback(C=>{c?.setShowAll(C),r(C);},[c]),g=Zt.useCallback(C=>{c?.setFormFill(C),a(C);},[c]),p=Zt.useCallback(()=>u(!n),[u,n]),f=Zt.useCallback(()=>g(!i),[g,i]),b=Zt.useCallback(()=>o(true),[]),y=Zt.useCallback(()=>o(false),[]),v=Zt.useCallback(()=>o(C=>!C),[]),x=Zt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let T=c.disabledReason(d.id,"edit");return T==="locked"?"the content control is locked":T==="bound"?"the content control is bound to external data":T==="notFound"?"the content control was not found":T}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 C=e.can({type:"setContentControlValue",value:""});return C.ok?null:C.reason},[d,c,e]),h=Zt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let T=c.disabledReason(d.id,"remove");return T==="locked"?"the content control is locked":T==="notFound"?"the content control was not found":T}if(d.removalLocked)return "the content control is locked";if(!e)return "no document is loaded";let C=e.can({type:"removeContentControl"});return C.ok?null:C.reason},[d,c,e]),k=Zt.useCallback(C=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c&&d){let T=c.disabledReason(d.id,"edit");if(T)return {ok:false,code:T==="bound"?"bound":T==="locked"?"locked":"notFound",reason:T==="bound"?"the content control is bound to external data":T==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:C})},[e,c,d]),E=Zt.useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c){let C=d?.id;if(!C)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let T=c.disabledReason(C,"remove");return T?{ok:false,code:T==="locked"?"locked":"notFound",reason:T==="locked"?"the content control is locked":"the content control was not found"}:c.remove(C)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,c,d]);return Zt.useMemo(()=>({control:d,controls:m,showAll:n,formFill:i,inspectorOpen:t,canSetValue:x===null&&d!==null,canRemove:h===null&&d!==null,setValueDisabledReason:x,removeDisabledReason:h,setShowAll:u,toggleShowAll:p,setFormFill:g,toggleFormFill:f,openInspector:b,closeInspector:y,toggleInspector:v,remove:E,setValue:k}),[d,m,n,i,t,x,h,u,p,g,f,b,y,v,E,k])}var Tu=Zt.createContext(null);function Eu(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var fb=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"})}),Tk="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",Ek="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",Sk={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},Pk={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},kk={color:"var(--doc-text-muted)",flexShrink:0},wk={textAlign:"right",wordBreak:"break-word"},Dk={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},Rk={display:"flex",gap:8,marginTop:4},gb={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 Mk(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 _k(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 Ar({label:e,value:t,testId:o}){return jsxRuntime.jsxs("div",{style:Pk,"data-testid":o,children:[jsxRuntime.jsx("span",{style:kk,children:e}),jsxRuntime.jsx("span",{style:wk,children:t})]})}function Ik({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=Po(),a=Zt.useRef(null),l=Zt.useId(),{t:s}=H(),{control:c,inspectorOpen:d,closeInspector:m}=i;if(Zt.useEffect(()=>{if(!d)return;let f=v=>{v.key==="Escape"&&(v.preventDefault(),m());},b=editor.hostDocumentOf(a.current);b.addEventListener("keydown",f);let y=editor.listenForOutsidePress({popup:b,contains:v=>a.current?.contains(v)===true,close:m});return ()=>{b.removeEventListener("keydown",f),y();}},[d,m]),Zt.useEffect(()=>{d&&!c&&m();},[d,c,m]),o||!d||!c)return null;let u=r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(bb,{}),jsxRuntime.jsx(hb,{}),jsxRuntime.jsx("div",{style:Rk,children:jsxRuntime.jsx(yb,{})}),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:Sk,onMouseDown:f=>{Eu(f),f.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(Q,{...g,children:p}):jsxRuntime.jsx("div",{...g,children:p})}function bb({className:e,asChild:t,hidden:o,children:n}){let{closeInspector:r}=Po(),{t:i}=H();if(o)return null;let a={style:Dk,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:{...gb,padding:4,border:"none",background:"transparent"},onMouseDown:Eu,onClick:()=>r(),children:fb(Tk)})]});return t?jsxRuntime.jsx(Q,{...a,children:l}):jsxRuntime.jsx("div",{...a,children:l})}function hb({className:e,asChild:t,hidden:o,children:n}){let{control:r}=Po(),{t:i}=H();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(Ar,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsxRuntime.jsx(Ar,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsxRuntime.jsx(Ar,{label:i("contentControl.inspectorPanel.type"),value:i(Mk(r.controlType)),testId:"content-control-inspector-type"}),jsxRuntime.jsx(Ar,{label:i("contentControl.inspectorPanel.lock"),value:i(_k(r)),testId:"content-control-inspector-lock"}),jsxRuntime.jsx(Ar,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsxRuntime.jsx(Ar,{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(Q,{...d,children:c}):jsxRuntime.jsx("div",{...d,children:c})}function yb({className:e,asChild:t,hidden:o,icon:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:s}=Po(),{t:c}=H();if(o)return null;let d=c("contentControl.remove"),m={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:gb,onMouseDown:Eu,onClick:()=>{l().ok&&s();}},u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n??r??fb(Ek),jsxRuntime.jsx("span",{children:d})]});return t?jsxRuntime.jsx(Q,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}var ti=Object.assign(Ik,{Header:bb,Fields:hb,Remove:yb});var Ak=e=>e;function Du(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function oi(){let e=A(),{t}=H(),[o,n]=Zt.useState(null),[r,i]=Zt.useState(null),a=Zt.useRef(null),l=Zt.useRef(null),s=Zt.useRef(null),c=Zt.useId(),d=Zt.useId(),m=Zt.useId(),u=o?.activation??null,g=W(Ak),p=Zt.useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let x=e.surface.equations.can(u.equation.id,"replace"),h=e.surface.equations.can(u.equation.id,"remove"),k=x.ok?h.ok?null:h.reason:x.reason;return {replaceEnabled:x.ok,removeEnabled:h.ok,reason:k?i18n.localizeDisabledReason(k,t):null}},[u,e,g,t]),f=Zt.useCallback((x=false)=>{s.current?.(),s.current=null,n(null),x&&e&&queueMicrotask(()=>e.focus());},[e]);Zt.useEffect(()=>{if(!e)return;let x=e.setEquationChrome({onPopover:h=>{s.current?.();let k=e.surface;if(k&&typeof k.retainSelection=="function"){let E=k.retainSelection();s.current=()=>k.releaseSelection(E);}else s.current=null;n({activation:h,mountGeneration:e.mountGeneration,draft:h.equation.linear,error:false});}});return ()=>{x(),s.current?.(),s.current=null,n(null);}},[e,f]),Zt.useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&f();},[e,g,o,f]),Zt.useEffect(()=>{if(!o)return;let x=a.current,h=x?.ownerDocument,k=h?.defaultView;if(!x||!h||!k)return;let E=T=>{T.key==="Escape"&&(T.preventDefault(),f(true));},C=T=>{editor.isDomNode(T.target)&&x.contains(T.target)||f();};return h.addEventListener("keydown",E),h.addEventListener("pointerdown",C,true),()=>{h.removeEventListener("keydown",E),h.removeEventListener("pointerdown",C,true);}},[o,f]),Zt.useLayoutEffect(()=>{if(!u){i(null);return}let x=a.current;if(!x)return;let h=x.offsetParent;if(!h){i(null);return}let k=u.rect,E=Lr(h,k.left,k.bottom),C=Math.max(0,h.scrollWidth-x.offsetWidth);i({left:Math.max(0,Math.min(E.left,C)),top:E.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[u]);let b=Zt.useCallback(()=>{if(!o||!e?.surface||!p.replaceEnabled)return false;let x=e.surface.equations.applyEquation(o.activation.equation.id,o.draft);return x?f(true):n(h=>h&&{...h,error:true}),x},[e,o,f,p.replaceEnabled]),y=Zt.useCallback(()=>{if(!o||!e?.surface||!p.removeEnabled)return false;let x=e.surface.equations.removeEquation(o.activation.equation.id);return x?f(true):n(h=>h&&{...h,error:true}),x},[e,o,f,p.removeEnabled]);if(!o)return null;let v=[o.error?d:null,p.reason?m: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:Du,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":v||void 0,onChange:x=>n(h=>h&&{...h,draft:x.target.value,error:false}),onKeyDown:x=>{x.key!=="Enter"||x.nativeEvent.isComposing||(x.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:m,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:Du,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:Du,onClick:y,children:t("equationPopup.delete")})]})]})}var Cb="review.comments",Ru="review.addComment";function Tb(e){return e!==Cb?e:(un(`The context-menu row "${Cb}" is now "${Ru}". The old id still works in this release; write "${Ru}".`),Ru)}var Bk="input, textarea, select",Wk="[data-docx-form-dropdown]",Zk=".docx-paginated-surface:not(.docx-editor__loading-surface)",Kk=".docx-image-selection-overlay";function Eb(e,t){if(!editor.isElementNode(t))return false;let o=t.closest(Bk);if(o&&!o.matches(Wk))return false;let n=e.querySelector(Zk);return n?n.contains(t)||t.contains(n)||!!t.closest(Kk):true}function Wr(e,t){if(!Zt.isValidElement(e)||e.type!==Zt.Fragment)return null;let n=Zt.Children.toArray(e.props.children).map(t).filter(r=>r!==null);return n.length===1?n[0]:null}function es({entries:e,children:t,preset:o,keyOfEntry:n,keyOfChild:r,renderEntry:i,childrenOfEntry:a,onUnmatched:l}){if(!o)return t;let s=new Map,c=[];for(let p of Zt.Children.toArray(t)){let f=r(p);f?s.set(f,p):c.push(p);}let d=new Set,m=p=>p.map((f,b)=>{let y=n(f,b);d.add(y);let v=a?.(f),x=v?m(v):void 0,h=s.get(y);return jsxRuntime.jsx(Zt.Fragment,{children:h??i(f,b,x)},y)}),u=m(e),g=[...s.entries()].filter(([p])=>!d.has(p)).map(([p,f])=>(l?.(p,f),jsxRuntime.jsx(Zt.Fragment,{children:f},p)));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u,g,c]})}var zk="review.addComment",Vk=e=>e.editingMode==="viewing";function ts(e){let{isEnabled:t,disabledReason:o}=re(zk),n=W(Vk);return t?{isEnabled:t,reason:null}:{isEnabled:t,reason:n?e("editingMode.viewingHint"):o}}var ni=Zt.createContext({t:void 0,openMenu:null,setOpenMenu:()=>{},activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onWatermarkDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),Zr="docx-menubar-more",os=Zt.createContext({measuring:false,overflow:new Set,inMore:false});function wb(){return Zt.useContext(os)}function et(){return Zt.useContext(ni)}function Pe(){let{t:e}=et(),{t}=H();return o=>e?.(o)??t(o)}var Kr=Zt.createContext(-1);var Gk='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Jn(e){return [...e.querySelectorAll(Gk)].filter(t=>t.closest('[role="menu"]')===e)}function Iu(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function no(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 ro(e,t){let o=t==="first"?e[0]:e[e.length-1];return o?(o.focus(),true):false}function Nu(e){let t=e?.ownerDocument.activeElement;((t&&e?.contains(t)?t.closest("[data-menu]"):null)?.querySelector(':scope > [role="menuitem"]')??e?.querySelector('.docx-menubar__trigger[aria-expanded="true"]'))?.focus({preventScroll:true});}function Db(e,t,o){return !o||o.ownerDocument===t?false:o.contains(e)}var qr="data-toolbar-group",_b=editor.TOOLBAR_ITEM_ATTRIBUTE,Ur="data-toolbar-fixed",rs="data-toolbar-more",iw=34,ns=new Map;function Fu(e,t,o){let n=Zt.useRef(null),r=Zt.useRef({itemWidths:new Map,groupBases:new Map,groupGaps:new Map,more:iw}),[i,a]=Zt.useState(ns),l=Zt.useRef(i);l.current=i;let s=Zt.useRef({groups:t,order:o});s.current={groups:t,order:o};let c=editor.toolbarGroupsKey(t),d=Zt.useRef(c),m=o.join("\0"),u=Zt.useCallback(()=>{let p=n.current;if(!p||!e)return;let f=editor.readToolbarRow(p,r.current,editor.toolbarItemKey),b=l.current.size===0&&f.overflowing===false,y=editor.toolbarGroupsKey(s.current.groups),v=d.current===y;d.current=y;let x=b?ns:editor.toolbarOverflowItems({...f,groups:s.current.groups,order:s.current.order,itemWidths:r.current.itemWidths,groupBases:r.current.groupBases,groupGaps:r.current.groupGaps,...v?{previous:l.current}:{},hysteresis:editor.TOOLBAR_OVERFLOW_HYSTERESIS});editor.sameItemOverflow(x,l.current)||(l.current=x,a(x));},[e]),g=Zt.useCallback(p=>{n.current=p;},[]);return Zt.useLayoutEffect(()=>{if(!e){l.current.size>0&&(l.current=ns,a(ns));return}u();},[e,c,u,m]),Zt.useEffect(()=>{let p=n.current,f=p?editor.hostWindowOf(p):null;if(!e||!p||!f||typeof f.ResizeObserver>"u")return;let b=0,y=new f.ResizeObserver(()=>{b===0&&(b=f.requestAnimationFrame(()=>{b=0,u();}));});y.observe(p),p.parentElement&&y.observe(p.parentElement);for(let v of p.querySelectorAll(`[${qr}], [${Ur}]`))y.observe(v);return ()=>{b!==0&&f.cancelAnimationFrame(b),y.disconnect();}},[e,c,u,m,i]),{attach:g,overflow:i}}function Ib(e,t,o){let n=t.map(l=>({id:l,items:[l]})),{attach:r,overflow:i}=Fu(e,n,o),a=Zt.useMemo(()=>new Set(i.keys()),[i]);return {attach:r,overflow:a}}function Nb(e,t,o){let n=e.overflow.has(t),r=t===Zr;return {skip:e.inMore?!n:n,asSubmenu:e.inMore&&n,iconOnly:r,rootAttributes:{...e.measuring&&!r?{[qr]:t}:{},...r?{[rs]:""}:{}},tabStop:o===t||r&&o!==null&&e.overflow.has(o)}}function Fb(e,t,o){let[n,r]=Zt.useState(void 0);return Zt.useLayoutEffect(()=>{if(!e){r(void 0);return}let i=()=>{let l=t.current,s=o.current,c=l?.parentElement,d=l?.ownerDocument.defaultView;if(!l||!s||!c||!d)return;let m=l.getBoundingClientRect(),u=editor.toolbarPanelPlacement({triggerLeft:m.left,triggerRight:m.right,panelWidth:s.offsetWidth,viewportWidth:d.innerWidth});r({left:u.left-c.getBoundingClientRect().left,right:"auto",maxInlineSize:u.maxWidth});};i();let a=t.current?.ownerDocument.defaultView;return a?.addEventListener("resize",i),()=>a?.removeEventListener("resize",i)},[e,o,t]),n}var Hb=12700,Lb=96;function mw(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function fw(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 as(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(!mw(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}=fw(n.pixelWidth,n.pixelHeight,n.dpiX??Lb,n.dpiY??Lb);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function gn(e){return Math.round(e/Hb*100)/100}function ai(e){return Math.round(e*Hb)}function is(e,t){return e.label!==void 0?e.label:e.labelKey!==void 0?t(e.labelKey):e.id}function Lu(e){let t=ae();return e.hidden?null:jsxRuntime.jsx("div",{role:"group","aria-label":is(e,t),className:`docx-toolbar__group${e.className?` ${e.className}`:""}`,"data-toolbar-host-group":e.id,children:e.children})}Lu.docxToolbarGroup=true;function ii(e){return e.hidden?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.children})}ii.docxToolbarSlot=true;var ls=Zt.createContext("bar");function ss(){return Zt.useContext(ls)}function bn(e,t){return ss()==="panel"&&!e&&t===void 0}function hn(e){return e?"docx-toolbar__more-command":"docx-toolbar__button"}function yn({icon:e,label:t}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:e}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:t})]})}function Hu({message:e,onClose:t,className:o,style:n,children:r}){let{t:i}=H();return jsxRuntime.jsx(Fe,{kind:"imageInsertError",role:"alertdialog",label:i("imageInsert.errors.title"),className:o,style:n,onClose:t,onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing&&(a.preventDefault(),t());},children:r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:i("imageInsert.errors.title")})}),jsxRuntime.jsx("div",{className:"docx-dialog__body","data-docx-part":"message",children:e}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:t,children:i("common.close")})})]})})}var Wb="image/png,image/jpeg,image/gif",Ou=Zt.createContext(null);function Kb(){let e=Zt.useContext(Ou);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function si(){return Zt.useContext(Ou)}function cs({children:e}){let t=A(),{t:o}=H(),n=Zt.useRef(null),r=Zt.useRef(false),i=Rt(),[a,l]=Zt.useState(null),s=Zt.useRef(null),c=Zt.useCallback(()=>editor.toolbarCommandState(t,"image.insert"),[t]),d=W(c,(x,h)=>x.enabled===h.enabled&&x.disabledReason===h.disabledReason),m=d.enabled,u=i18n.localizeDisabledReason(d.disabledReason,o),g=Zt.useCallback(async x=>{if(!t||r.current)return;let h=as(x);if(!h.ok){l(o(h.reasonKey));return}let k={type:"insertImage",data:h.bytes,mime:h.mime,widthPoints:h.widthPoints,heightPoints:h.heightPoints};r.current=true;try{let E=await editor.executeImageCommand(t,k);E.ok?t.focus():l(i18n.localizeDisabledReason(Dw(E.reason)??null,o)??o("imageInsert.errors.refused"));}finally{r.current=false;}},[t,o]),p=Zt.useCallback(async x=>{let h=x?.[0];if(!h)return;let k=await h.arrayBuffer();await g(new Uint8Array(k));},[g]),f=Zt.useCallback(async x=>{if(!x)return;let h=[...x.files].find(k=>k.type.startsWith("image/"));if(h){await p([h]);return}for(let k of x.items){if(k.kind!=="file"||!k.type.startsWith("image/"))continue;let E=k.getAsFile();if(!E)continue;let C=await E.arrayBuffer();await g(new Uint8Array(C));return}},[g,p]),b=Zt.useCallback(()=>{if(!m)return;let x=n.current,h=t?editor.editorHostDocument(t):null;if(!h||!x||x.ownerDocument===h){x?.click();return}s.current?.remove();let k=h.createElement("input");k.type="file",k.accept=Wb,k.hidden=true,k.tabIndex=-1,k.setAttribute("aria-hidden","true");let E=()=>{k.remove(),s.current===k&&(s.current=null);};k.addEventListener("change",()=>{p(k.files).finally(E);},{once:true}),k.addEventListener("cancel",E,{once:true}),h.body.append(k),s.current=k,k.click();},[t,m,p]),y=Zt.useCallback(async x=>{let h=x.currentTarget;await p(h.files),h.value="";},[p]),v=Zt.useMemo(()=>({openFilePicker:b,insertFromFileList:p,insertFromDataTransfer:f,isEnabled:m,disabledReason:u,inputRef:n,onInputChange:y}),[b,p,f,m,u,y]);return jsxRuntime.jsxs(Ou.Provider,{value:v,children:[jsxRuntime.jsx("input",{ref:n,type:"file",accept:Wb,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:y,onMouseDown:x=>x.stopPropagation()}),e,a!==null&&(i?.imageInsertError!==void 0?Te(i.imageInsertError,{message:a,onClose:()=>l(null)}):jsxRuntime.jsx(Hu,{message:a,onClose:()=>l(null)}))]})}function ds({className:e,hidden:t,asChild:o,children:n}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=Kb(),l=ae(),s=bn(o,n);if(t)return null;let c=te("image.insert"),d=l(c?.labelKey??"toolbar.image"),m={type:"button",className:`${hn(s)}${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":d,title:a??d,onMouseDown:$,onClick:r};if(o)return jsxRuntime.jsx(Q,{...m,children:n});let u=oe(c?.paths);return jsxRuntime.jsx("button",{...m,children:s?jsxRuntime.jsx(yn,{icon:u,label:d}):n??u})}ds.docxSlot="image.insert";var ci=Object.assign(ds,{docxSlot:"image.insert"});function Dw(e){return e&&/\s/.test(e)?e:void 0}var Bu=6,$b=6;function ps({slot:e,label:t,onInserted:o,className:n}){let r=A(),{isEnabled:i}=re(e),[a,l]=Zt.useState(null),[s,c]=Zt.useState({rows:1,cols:1}),d=Zt.useRef(null),m=Zt.useCallback((p,f)=>{if(!r||!i)return;let b={type:"insertTable",rows:p,cols:f};r.can(b).ok&&(r.exec(b),o(),r.focus());},[r,i,o]),u=Zt.useCallback(p=>{c(f=>{let b={rows:Math.min($b,Math.max(1,f.rows+(p.rows??0))),cols:Math.min(Bu,Math.max(1,p.toCol??f.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<=$b;p+=1){let f=[];for(let b=1;b<=Bu;b+=1){let y=!!a&&p<=a.rows&&b<=a.cols;f.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,...y?{"data-filled":""}:{},"aria-label":`${b} \xD7 ${p}`,onMouseDown:$,onMouseEnter:()=>l({rows:p,cols:b}),onFocus:()=>l({rows:p,cols:b}),onClick:()=>m(p,b)},b));}g.push(jsxRuntime.jsx("div",{role:"row",className:"docx-menubar__grid-row",children:f},p));}return jsxRuntime.jsxs("div",{ref:d,role:"grid","aria-label":t,className:`docx-menubar__grid${n?` ${n}`:""}`,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:Bu});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 Vr({slot:e="table.insert",className:t}){let{setOpenMenu:o}=et(),n=Pe(),r=Zt.useCallback(()=>o(null),[o]);return jsxRuntime.jsx(ps,{slot:e,label:n("toolbar.insertTable"),onInserted:r,className:t})}function Lw({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=re(editor.chromeProbeForSlot("insert.watermark")),r=et(),i=Pe();if(t)return null;let a=te("insert.watermark"),l=i(a?.labelKey??"toolbar.watermark"),s=o&&!!r.onWatermarkDialog;return jsxRuntime.jsx(De,{slot:"insert.watermark",icon:oe(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onWatermarkDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var ms=Object.assign(Lw,{docxSlot:"insert.watermark"});var Ow={type:"openGoTo",fromShortcut:true};function zb(){let e=re(Ow),t=i18n.isApplePlatform()?"toolbar.goToBookmarkShortcutApple":"toolbar.goToBookmarkShortcut";return jsxRuntime.jsx(ao,{slotId:"insert.goToBookmark",...e.isEnabled?{shortcutKey:t}:{}})}function Bw({className:e,hidden:t}){return jsxRuntime.jsx(ao,{slotId:"insert.bookmark",shortcutKey:"toolbar.bookmarkShortcut",...e?{className:e}:{},...t?{hidden:t}:{}})}var fs=Object.assign(Bw,{docxSlot:"insert.bookmark"});var qw=e=>e;function gs({labelKey:e,shortcutKey:t,className:o,hidden:n}){let r=A(),i=et(),a=Pe();if(W(qw),n)return null;let l=editor.toolbarCommandState(r,"text.link"),s=i18n.localizeDisabledReason(l.disabledReason,a),c=te("text.link"),d=r?.surface?.hyperlinks.linkAtCaret()!=null,m=a(e??(d?"hyperlinkPopup.editLink":"formattingBar.insertLink"));return jsxRuntime.jsx(De,{icon:oe(c?.paths),slot:"text.link",...t?{shortcut:a(t)}:{},disabled:!l.enabled,title:s??void 0,onSelect:()=>{i.setOpenMenu(null),editor.runToolbarCommand(r,"text.link");},...o?{className:o}:{},children:m})}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,m=e["data-value"],u=eo(),g=Zt.useId(),p=Zt.useContext(Kr),f=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:p,...l?{"data-slot":l}:{},...m!==void 0?{"data-value":m}:{},...i?{"data-active":""}:{},...n?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...f?{"aria-describedby":f}:{},...r?{title:r}:{},onMouseDown:$,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,f?jsxRuntime.jsx("span",{id:g,className:"docx-editor-sr-only",children:r}):null]})}function di({label:e,labelKey:t,className:o,hidden:n,children:r}){let i=Pe();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 hs(e){if(e.slotId)return e.slotId;if(e.slot)return Kg(e.slot),e.slot;Ug();}function ao(e){return (e.slotId??e.slot)==="text.link"?jsxRuntime.jsx(gs,{...e}):jsxRuntime.jsx(eD,{...e})}function eD(e){let{labelKey:t,shortcutKey:o,className:n,hidden:r}=e,i=hs(e)??"",{execute:a,isActive:l,isEnabled:s,disabledReason:c,value:d}=re(i),{setOpenMenu:m}=et(),u=Pe();if(r||!i)return null;let g=te(i),p=u(t??g?.labelKey??i),f=editor.chromeSlotIsToggle(i),b=["setAlignment","setParagraphDirection","setReviewDisplayMode"].includes(editor.commandForSlot(i)?.type??"");return jsxRuntime.jsx(De,{slot:i,icon:oe(g?.paths),...o?{shortcut:u(o)}:{},disabled:!s,...c?{title:c}:{},...f?{active:l}:{},...b?{selected:true}:{},...d!==null?{"data-value":d}:{},onSelect:()=>{a(),m(null);},...n?{className:n}:{},children:p})}ao.docxMenuRow=true;function ui(e,t,o,n,r=()=>true){return Object.assign(({className:a,hidden:l})=>{let s=et(),c=Pe(),d=n(s),m=o&&r(s)?o:void 0;if(l)return null;let u=te(e),g=c(t??u?.labelKey??e);return jsxRuntime.jsx(De,{slot:e,icon:oe(u?.paths),...m?{shortcut:c(m)}:{},disabled:!d,onSelect:()=>{d?.(),s.setOpenMenu(null);},...a?{className:a}:{},children:g})},{docxSlot:e})}var Zu=ui("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),Ku=ui("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave),qu=ui("file.exportMarkdown",void 0,void 0,e=>e.onExport?()=>e.onExport?.("markdown"):void 0),Uu=ui("file.exportPdf",void 0,void 0,e=>e.onExport?()=>e.onExport?.("pdf"):void 0),$u=ui("file.print",void 0,"toolbar.printShortcut",e=>e.onPrint,e=>e.printShortcut===true);function tD({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=re(editor.chromeProbeForSlot("file.pageSetup")),r=et(),i=Pe();if(t)return null;let a=te("file.pageSetup"),l=i(a?.labelKey??"file.pageSetup"),s=o&&!!r.onPageSetup;return jsxRuntime.jsx(De,{slot:"file.pageSetup",icon:oe(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onPageSetup?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}function oD({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=re(editor.chromeProbeForSlot("paragraph.dialog")),r=et(),i=Pe();if(t)return null;let a=te("paragraph.dialog"),l=i(a?.labelKey??"lineSpacing.options"),s=o&&!!r.onParagraphDialog;return jsxRuntime.jsx(De,{slot:"paragraph.dialog",icon:oe(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onParagraphDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var nD=Object.assign(oD,{docxSlot:"paragraph.dialog"}),zu=Object.assign(tD,{docxSlot:"file.pageSetup"});function rD({className:e,hidden:t}){let o=si(),n=et(),r=Pe();if(t)return null;let i=te("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 Vu=Object.assign(rD,{docxSlot:"image.insert"});function io({labelKey:e,label:t,paths:o,className:n,children:r}){let i=Pe(),[a,l]=Zt.useState(false),s=Zt.useRef(null),c=Zt.useRef(null),d=Zt.useId();t===void 0&&e===void 0&&$g();let m=t??i(e??""),[u,g]=Zt.useState(null);return Zt.useLayoutEffect(()=>{if(!a){g(null);return}let p=s.current,f=c.current,b=p?.ownerDocument.defaultView;!p||!f||!b||g(editor.placeSubmenu(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:b.innerWidth,height:b.innerHeight},b.getComputedStyle(p).direction==="rtl"));},[a]),jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__submenu${n?` ${n}`:""}`,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),onKeyDown:p=>{let f=editor.submenuKeys(editor.hostWindowOf(p.currentTarget).getComputedStyle(p.currentTarget).direction==="rtl");p.key===f.open&&editor.hostDocumentOf(s.current).activeElement===s.current?(p.preventDefault(),l(true),queueMicrotask(()=>{c.current&&ro(Jn(c.current),"first");})):(p.key===f.close||p.key==="Escape")&&a&&(p.preventDefault(),p.stopPropagation(),l(false),s.current?.focus());},onBlur:p=>{p.currentTarget.contains(p.relatedTarget)||l(false);},children:[jsxRuntime.jsxs("button",{ref:s,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?d:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...a?{"data-open":""}:{},onMouseDown:$,onFocus:()=>l(true),onClick:()=>l(true),children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:oe(o)}),jsxRuntime.jsx("span",{className:"docx-menubar__item-label",children:m}),jsxRuntime.jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),a?jsxRuntime.jsx("div",{ref:c,id:d,className:"docx-toolbar__menu docx-menubar__menu docx-menubar__submenu-panel",role:"menu","aria-label":m,style:u?{position:"fixed",left:u.left,top:u.top}:{position:"fixed",visibility:"hidden"},onKeyDown:p=>{let f=c.current;if(!f)return;let b=Jn(f);p.key==="ArrowDown"?(p.preventDefault(),p.stopPropagation(),no(b,editor.hostDocumentOf(f).activeElement,1)):p.key==="ArrowUp"&&(p.preventDefault(),p.stopPropagation(),no(b,editor.hostDocumentOf(f).activeElement,-1));},children:jsxRuntime.jsx(Kr.Provider,{value:-1,children:r})}):null]})}function aD({entry:e}){let{isEnabled:t}=re(e.slot),o=te(e.slot);return t?jsxRuntime.jsx(io,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsxRuntime.jsx(Vr,{slot:e.slot})}):jsxRuntime.jsx(ao,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Qn({className:e}){return jsxRuntime.jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function pi({entry:e,children:t}){return e.kind==="separator"?jsxRuntime.jsx(Qn,{}):e.kind==="submenu"?jsxRuntime.jsx(io,{labelKey:e.labelKey,paths:e.paths,children:t??e.items.map((o,n)=>jsxRuntime.jsx(pi,{entry:o},n))}):e.slot==="file.open"?jsxRuntime.jsx(Zu,{}):e.slot==="file.save"?jsxRuntime.jsx(Ku,{}):e.slot==="file.exportMarkdown"?jsxRuntime.jsx(qu,{}):e.slot==="file.exportPdf"?jsxRuntime.jsx(Uu,{}):e.slot==="file.print"?jsxRuntime.jsx($u,{}):e.slot==="file.pageSetup"?jsxRuntime.jsx(zu,{}):e.slot==="paragraph.dialog"?jsxRuntime.jsx(nD,{}):e.slot==="insert.watermark"?jsxRuntime.jsx(ms,{}):e.slot==="insert.bookmark"?jsxRuntime.jsx(fs,{}):e.slot==="insert.goToBookmark"?jsxRuntime.jsx(zb,{}):e.slot==="image.insert"?jsxRuntime.jsx(Vu,{}):e.picker==="tableGrid"?jsxRuntime.jsx(aD,{entry:e}):jsxRuntime.jsx(ao,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Xb(e){if(!Zt.isValidElement(e))return null;let t=Wr(e,Xb);if(t!==null)return t;let o=e.type;return typeof o!="function"&&typeof o!="object"?null:typeof o.docxSlot=="string"?o.docxSlot:o.docxMenuRow===true?hs(e.props)??null:null}function iD(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function jb(e,t,o){return es({entries:e??[],children:t,preset:o,keyOfEntry:iD,keyOfChild:Xb,childrenOfEntry:n=>n.kind==="submenu"?n.items:void 0,renderEntry:(n,r,i)=>jsxRuntime.jsx(pi,{entry:n,children:i})})}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,opening:m}=et(),u=wb(),g=Pe(),p=Zt.useId(),f=Zt.useRef(null),b=Zt.useRef(null),y=Zt.useRef(false),v=Zt.useRef(false),x=editor.CHROME_MENUS.find(w=>w.id===e),h=s===e,k=Fb(h&&e===Zr,f,b);if(i)return null;let E=o??g(t??x?.labelKey??e),C=Nb(u,e,d);if(C.skip)return null;if(C.asSubmenu)return jsxRuntime.jsx(io,{labelKey:t??x?.labelKey??e,label:E,children:jb(x?.entries,l,a)});let T=jb(x?.entries,l,a),S=C.iconOnly,P=()=>{c(null),f.current?.focus();};return jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__menu-root${r?` ${r}`:""}`,"data-menu":e,...C.rootAttributes,children:[jsxRuntime.jsxs("button",{ref:f,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":h,"aria-controls":h?p:void 0,className:"docx-menubar__trigger",disabled:m===true,tabIndex:C.tabStop?0:-1,...h?{"data-open":""}:{},...S?{"aria-label":E,title:E}:{},onMouseDown:$,onKeyDown:w=>{w.key==="ArrowDown"||w.key==="Enter"||w.key===" "||w.key==="ArrowUp"?(w.preventDefault(),y.current=true,c(e)):w.key==="Escape"&&h&&(w.preventDefault(),P());},onClick:()=>{if(v.current){v.current=false;return}c(h?null:e);},onMouseEnter:()=>{s!==null&&s!==e&&(v.current=true,c(e));},onMouseLeave:()=>{v.current=false;},children:[n?jsxRuntime.jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:n}):null,S?null:E]}),h?jsxRuntime.jsx("div",{ref:w=>{b.current=w,w&&y.current&&(y.current=false,ro(Jn(w),"first"));},id:p,role:"menu","aria-label":E,style:k,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:w=>{let _=b.current;if(!_)return;let L=Jn(_),N=editor.hostDocumentOf(_).activeElement;w.key==="ArrowDown"?(w.preventDefault(),no(L,N,1)):w.key==="ArrowUp"?(w.preventDefault(),no(L,N,-1)):w.key==="Home"?(w.preventDefault(),ro(L,"first")):w.key==="End"?(w.preventDefault(),ro(L,"last")):w.key==="Escape"?(w.preventDefault(),w.stopPropagation(),P()):w.key==="Tab"&&c(null);},children:jsxRuntime.jsx(Kr.Provider,{value:-1,children:T})}):null]})}function Gu(e){return Object.assign(o=>jsxRuntime.jsx(lo,{id:e,...o}),{docxMenu:e})}var ju=Gu("file"),Yu=Gu("format"),Xu=Gu("insert");var ys=Zt.createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function $o(){return Zt.useContext(ys)}function Qb(){return Zt.useContext(ys).target}var cD=e=>e.pageSetup??null,dD=e=>e.editable;function er(){let e=A(),t=W(cD),o=W(dD),n=Zt.useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),r=Zt.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 Zt.useMemo(()=>({pageSetup:t,isEnabled:n,apply:r}),[t,n,r])}var Qu=[{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}],rh=1440,mD=e=>Math.round(e/rh*100)/100,fD=e=>Math.round(e*rh);function gD(e,t){let o=Math.min(e,t),n=Math.max(e,t);return Qu.findIndex(r=>Math.abs(r.width-o)<20&&Math.abs(r.height-n)<20)}var oh=12240,nh=15840,xn=1440;function bD({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=Co(e,t),{pageSetup:s,isEnabled:c,apply:d}=er(),[m,u]=Zt.useState(oh),[g,p]=Zt.useState(nh),[f,b]=Zt.useState("portrait"),[y,v]=Zt.useState(xn),[x,h]=Zt.useState(xn),[k,E]=Zt.useState(xn),[C,T]=Zt.useState(xn),[S,P]=Zt.useState(false),[w,_]=Zt.useState("document"),L=Zt.useRef(null),N=Zt.useRef("no");Zt.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||(P(false),u(s?.pageWidthTwips??oh),p(s?.pageHeightTwips??nh),b(s?.orientation??"portrait"),v(s?.marginsTwips.top??xn),h(s?.marginsTwips.bottom??xn),E(s?.marginsTwips.left??xn),T(s?.marginsTwips.right??xn),_("document"),N.current=s===null?"loading":"yes");},[e,s]);let B=Zt.useCallback(q=>{let X=Qu[q];X&&(u(f==="landscape"?X.height:X.width),p(f==="landscape"?X.width:X.height));},[f]),F=Zt.useCallback(q=>{q!==f&&(b(q),u(g),p(m));},[f,m,g]),D=Zt.useCallback(()=>{if(!c)return;if(!l()){t();return}let q=d({pageWidthTwips:m,pageHeightTwips:g,orientation:f,marginTopTwips:y,marginRightTwips:C,marginBottomTwips:x,marginLeftTwips:k,scope:w});P(!q),q&&t();},[c,l,d,m,g,f,y,C,x,k,w,t]);if(!e)return null;let R=gD(m,g),U=(q,X,ee)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":`margin${q[0].toUpperCase()}${q.slice(1)}`,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",children:a(`dialogs.pageSetup.${q}`)}),jsxRuntime.jsx("input",{type:"number",className:"docx-dialog__input",min:0,max:22,step:.1,value:mD(X),onChange:O=>ee(Math.max(0,fD(Number(O.target.value)||0))),"aria-label":a(`dialogs.pageSetup.${q}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),V={pageWidth:m,pageHeight:g,orientation:f,marginTop:y,marginBottom:x,marginLeft:k,marginRight:C,scope:w},Y={pageWidth:u,pageHeight:p,orientation:F,marginTop:v,marginBottom:h,marginLeft:E,marginRight:T,scope:_},j={values:V,setValue(q,X){Y[q](X);},errors:S?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:D,cancel:t};return jsxRuntime.jsx(Fe,{kind:"pageSetup",className:o,style:n,panelRef:L,label:a("dialogs.pageSetup.title"),onClose:t,onKeyDown:q=>{q.key==="Escape"&&t(),q.key==="Enter"&&editor.isHTMLElementNode(q.target)&&q.target.localName==="input"&&c&&(q.preventDefault(),D());},children:jsxRuntime.jsx(wo.Composition,{state:j,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:R,onChange:q=>B(Number(q.target.value)),"aria-label":a("dialogs.pageSetup.sizeLabel"),children:[Qu.map((q,X)=>jsxRuntime.jsx("option",{value:X,children:a(q.labelKey)},q.labelKey)),R<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:f,onChange:q=>F(q.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")}),U("top",y,v),U("bottom",x,h),U("left",k,E),U("right",C,T),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:q=>_(q.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:S?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:D,children:a("common.apply")})]})]}),children:r})})}var wo=yt();function hD(){return wo.useState()}var tr=Object.assign(bD,{Header:wo.Header,Title:wo.Title,Body:wo.Body,Footer:wo.Footer,Apply:wo.Apply,Cancel:wo.Cancel,Error:wo.Error,Field:wo.Field});var vD={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},CD=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,n=t.paragraphFlags??vD;return {alignment:t.alignment==="both"?"justify":t.alignment??null,direction:t.direction??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,direction:t.disagrees?.direction??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}}},TD=["alignment","direction","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],ED=(e,t)=>TD.every(o=>e.disagrees[o]===t.disagrees[o]),SD=(e,t)=>e===null||t===null?e===t:e.alignment===t.alignment&&e.direction===t.direction&&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&&ED(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")),PD=e=>e.editable,kD={type:"setParagraphFormat",alignment:"left"};function ep(){let e=A(),t=W(CD,SD),o=W(PD),{isEnabled:n}=re(kD),r=o&&n,i=Zt.useCallback(a=>{if(!e)return false;let l={type:"setParagraphFormat",...a};return e.can(l).ok?e.exec(l).ok:false},[e]);return {format:t,isEnabled:r,apply:i}}function RD({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=Co(e,t),{format:s,isEnabled:c,apply:d}=ep(),[m,u]=Zt.useState("left"),[g,p]=Zt.useState("ltr"),[f,b]=Zt.useState(0),[y,v]=Zt.useState(0),[x,h]=Zt.useState("none"),[k,E]=Zt.useState(0),[C,T]=Zt.useState(0),[S,P]=Zt.useState(0),[w,_]=Zt.useState("multiple"),[L,N]=Zt.useState(1.08),[B,F]=Zt.useState(false),[D,R]=Zt.useState(false),[U,V]=Zt.useState(false),[Y,j]=Zt.useState(true),[q,X]=Zt.useState(false),[ee,O]=Zt.useState([]),[I,ie]=Zt.useState(false),[ge,K]=Zt.useState(0),[de,ke]=Zt.useState("left"),[Ze,at]=Zt.useState("none"),[Ce,Ye]=Zt.useState(editor.NO_MIXED_FIELDS),[Wn,wt]=Zt.useState(false),qt=z=>a(Wn&&(z==="indentLeft"||z==="indentRight"||z==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),Zn=Zt.useRef(editor.NO_MIXED_FIELDS),se=Zt.useId(),[Ge,Ie]=Zt.useState(false),Kn=Zt.useRef(null),xo=Zt.useRef(false),Qt=Zt.useRef(null);Zt.useEffect(()=>{if(!e){xo.current=false;return}if(xo.current||s===null)return;let z=editor.seedFields(s);u(z.alignment),p(z.direction),b(z.indentLeft),v(z.indentRight),h(z.special),E(z.specialBy),T(z.spaceBefore),P(z.spaceAfter),_(z.lineRule),N(z.lineValue),F(z.contextualSpacing),R(z.keepNext),V(z.keepLines),j(z.widowControl),X(z.pageBreakBefore),O(z.tabStops),ie(false);let xe=editor.mixedFieldsOf(s);Ye(xe),wt(s.indentUnknown),K(0),ke("left"),at("none"),Zn.current=xe,Ie(false),Qt.current=z,xo.current=true;},[e,s]);let vo=Zt.useCallback(()=>{if(!c)return;if(!l()){t();return}let z=Qt.current,xe=z===null?null:editor.changedFields(z,{alignment:m,direction:g,indentLeft:f,indentRight:y,special:x,specialBy:k,spaceBefore:C,spaceAfter:S,lineRule:w,lineValue:L,contextualSpacing:B,keepNext:D,keepLines:U,widowControl:Y,pageBreakBefore:q,tabStops:ee,clearedAllTabStops:I},Zn.current,Ce);if(xe===null){t();return}if(d(xe)){Ie(false),t();return}Ie(true);},[c,l,d,t,Ce,I,m,g,f,y,x,k,C,S,w,L,B,D,U,Y,q,ee]),an=Zt.useCallback(()=>{let z=Math.round(ge);return z<=0?false:(Ye(xe=>({...xe,tabStops:false})),O(editor.withTabStop(ee,{positionTwips:z,alignment:de,...Ze!=="none"?{leader:Ze}:{}})),K(0),ke("left"),at("none"),true)},[ee,ge,de,Ze]);if(!e)return null;let Ht=z=>Ye(xe=>({...xe,[z]:false})),ce=(z,xe,cn,ht)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":ht,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("input",{id:`${se}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Ce[ht]?"":editor.twipsToInches(xe),placeholder:Ce[ht]?qt(ht):void 0,onChange:Wa=>{Ht(ht),cn(editor.inchesToTwips(Number(Wa.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),be=(z,xe,cn,ht)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("input",{id:`${se}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:Ce[ht]?"":xe,placeholder:Ce[ht]?qt(ht):void 0,onChange:Wa=>{Ht(ht),cn(Math.max(0,Number(Wa.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),Ne=(z,xe,cn)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:xe,ref:ht=>{ht&&(ht.indeterminate=Ce[z]);},onChange:ht=>{Ye(Wa=>({...Wa,[z]:false})),cn(ht.target.checked);}}),a(`dialogs.paragraph.${z}`)]}),Se={alignment:m,direction:g,indentLeft:f,indentRight:y,special:x,specialBy:k,spaceBefore:C,spaceAfter:S,lineRule:w,lineValue:L,contextualSpacing:B,keepNext:D,keepLines:U,widowControl:Y,pageBreakBefore:q,tabStops:ee,clearedAllTabStops:I},Et=z=>{let xe=Zn.current;z!==g&&!xe.direction&&!xe.alignment&&u(editor.alignmentAfterDirectionChange),p(z);},ln={alignment:u,direction:Et,indentLeft:b,indentRight:v,special:h,specialBy:E,spaceBefore:T,spaceAfter:P,lineRule:_,lineValue:N,contextualSpacing:F,keepNext:R,keepLines:V,widowControl:j,pageBreakBefore:X,tabStops:O,clearedAllTabStops:ie},sn={values:Se,mixed:Ce,setValue(z,xe){ln[z](xe),z==="lineRule"?(Ht("lineSpacing"),N(xe===Qt.current?.lineRule?Qt.current.lineValue:xe==="multiple"?1.08:12)):z==="specialBy"?Ht("special"):z in Ce&&Ht(z);},errors:Ge?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:vo,cancel:t};return jsxRuntime.jsx(Fe,{kind:"paragraph",className:o,style:n,panelRef:Kn,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:z=>{z.key==="Escape"&&t();let xe=editor.isHTMLElementNode(z.target)&&(z.target.localName==="button"||z.target.localName==="select");if(z.key==="Enter"&&!xe){let cn=z.target;if(editor.isHTMLElementNode(cn)&&cn.dataset.docxTabEntry!==void 0){an();return}c&&vo();}},children:jsxRuntime.jsx(Do.Composition,{state:sn,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:`${se}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxRuntime.jsxs("select",{id:`${se}-alignment`,className:"docx-dialog__input",value:Ce.alignment?"":m,onChange:z=>{Ht("alignment"),u(z.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[Ce.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.jsxs("div",{"data-docx-part":"field","data-docx-field":"direction",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-direction`,children:a("dialogs.paragraph.direction")}),jsxRuntime.jsxs("select",{id:`${se}-direction`,className:"docx-dialog__input",value:Ce.direction?"":g,onChange:z=>{Ht("direction"),Et(z.target.value);},"aria-label":a("dialogs.paragraph.direction"),children:[Ce.direction?jsxRuntime.jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsxRuntime.jsx("option",{value:"rtl",children:a("dialogs.paragraph.directionRtl")}),jsxRuntime.jsx("option",{value:"ltr",children:a("dialogs.paragraph.directionLtr")})]})]}),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.indentation")}),ce("beforeText",f,b,"indentLeft"),ce("afterText",y,v,"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:`${se}-special`,children:a("dialogs.paragraph.special")}),jsxRuntime.jsxs("select",{id:`${se}-special`,className:"docx-dialog__input",value:Ce.special?"":x,onChange:z=>{Ht("special"),h(z.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[Ce.special?jsxRuntime.jsx("option",{value:"",children:qt("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")})]})]}),x!=="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:`${se}-by`,children:a("dialogs.paragraph.by")}),jsxRuntime.jsx("input",{id:`${se}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Ce.special?"":editor.twipsToInches(k),placeholder:Ce.special?qt("special"):void 0,onChange:z=>{Ht("special"),E(Math.max(0,editor.inchesToTwips(Number(z.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")}),ee.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__note",children:a(Ce.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):ee.map(z=>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(z.positionTwips)})}),jsxRuntime.jsx("span",{className:"docx-dialog__tab-description",children:a(editor.TAB_ALIGNMENT_LABELS[z.alignment])}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>O(ee.filter(xe=>xe!==z)),"aria-label":a("dialogs.paragraph.tabRemoveAt",{position:editor.formatInches(z.positionTwips)}),children:a("dialogs.paragraph.tabRemove")})]},z.positionTwips)),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsxRuntime.jsx("input",{id:`${se}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:editor.twipsToInches(ge),onChange:z=>K(Math.max(0,editor.inchesToTwips(Number(z.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:`${se}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxRuntime.jsxs("select",{id:`${se}-tabAlignment`,className:"docx-dialog__input",value:de,onChange:z=>ke(z.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:`${se}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxRuntime.jsxs("select",{id:`${se}-tabLeader`,className:"docx-dialog__input",value:Ze,onChange:z=>at(z.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:an,children:a("dialogs.paragraph.tabAdd")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{Ye(z=>({...z,tabStops:false})),ie(true),O([]);},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")}),be("spaceBefore",C,T,"spaceBefore"),be("spaceAfter",S,P,"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:`${se}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxRuntime.jsxs("select",{id:`${se}-lineSpacing`,className:"docx-dialog__input",value:Ce.lineSpacing?"":w,onChange:z=>{let xe=z.target.value;Ht("lineSpacing"),_(xe),N(xe===Qt.current?.lineRule?Qt.current.lineValue:xe==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[Ce.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:`${se}-at`,children:a("dialogs.paragraph.at")}),jsxRuntime.jsx("input",{id:`${se}-at`,type:"number",className:"docx-dialog__input",min:.01,step:w==="multiple"?.01:1,value:Ce.lineSpacing?"":L,disabled:Ce.lineSpacing,onChange:z=>{let xe=z.target.value.trim();N(xe===""?w==="multiple"?1.08:12:Number(xe)||0);},"aria-label":a("dialogs.paragraph.at")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:w==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),Ne("contextualSpacing",B,F),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),Ne("keepNext",D,R),Ne("widowControl",Y,j),Ne("keepLines",U,V),Ne("pageBreakBefore",q,X)]})]})}),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:Ge?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:vo,children:a("dialogs.paragraph.ok")})]})]}),children:r})})}var Do=yt();function MD(){return Do.useState()}var Vo=Object.assign(RD,{Header:Do.Header,Title:Do.Title,Body:Do.Body,Footer:Do.Footer,Apply:Do.Apply,Cancel:Do.Cancel,Error:Do.Error,Field:Do.Field});var so=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var np=["ASAP","CONFIDENTIAL","COPY","DO NOT COPY","DRAFT","ORIGINAL","PERSONAL","SAMPLE","TOP SECRET","URGENT"],rp=[null,.5,1,1.5,2,5],ap=[null,36,40,44,48,54,60,66,72,80,90,96,105,120,144],hh="image/png,image/jpeg,image/gif,image/bmp,image/webp",ip={kind:"none",imageData:null,imageName:null,scale:null,washout:true,text:"DRAFT",fontFamily:"Calibri",fontSizePt:null,bold:false,italic:false,transparency:.5,color:"C0C0C0",layout:"diagonal"},Ts=/^[0-9A-Fa-f]{6}$/;function yh(e,t){let o={...ip};return e?e.kind==="image"?{...o,kind:t?.imageData?"picture":"none",imageData:t?.imageData??null,scale:t?.scale??null,washout:e.washout??t?.washout??true}:{...o,kind:"text",text:e.text??o.text,fontFamily:e.fontFamily??o.fontFamily,fontSizePt:e.fontSizePt??null,bold:e.bold??false,italic:e.italic??false,transparency:e.transparency??o.transparency,color:e.color&&Ts.test(e.color)?e.color.toUpperCase():o.color,layout:e.layout??o.layout}:o}function xh(e){if(e.kind==="none")return null;if(e.kind==="picture")return e.imageData?{imageData:e.imageData,scale:e.scale,washout:e.washout}:void 0;if(e.text.trim()!=="")return {text:e.text,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,color:e.color,transparency:e.transparency,layout:e.layout}}var vh=e=>`#${Ts.test(e)?e.toLowerCase():"c0c0c0"}`;function Ch(e){let t=e.startsWith("#")?e.slice(1):e;return Ts.test(t)?t.toUpperCase():null}var lp=e=>Math.round(Math.min(1,Math.max(0,e))*100);function sp(e,t){let o=Number(e);return e.trim()===""||!Number.isFinite(o)?t:Math.min(100,Math.max(0,Math.round(o)))/100}function Th(e,t){return e===t?true:!e||!t?false:e.kind===t.kind&&e.text===t.text&&e.fontFamily===t.fontFamily&&e.fontSizePt===t.fontSizePt&&e.bold===t.bold&&e.italic===t.italic&&e.color===t.color&&e.transparency===t.transparency&&e.layout===t.layout&&e.washout===t.washout}function Eh(e,t){return e!==null&&t.kind==="none"?null:t}function Sh(e,t){return e.kind!==t.kind?false:e.kind==="none"?true:e.kind==="picture"?e.imageData===t.imageData&&e.scale===t.scale&&e.washout===t.washout:e.text===t.text&&e.fontFamily===t.fontFamily&&e.fontSizePt===t.fontSizePt&&e.bold===t.bold&&e.italic===t.italic&&e.color.toUpperCase()===t.color.toUpperCase()&&e.transparency===t.transparency&&e.layout===t.layout}var Ph=(e,t)=>t.includes(e)?e:"",ID={pageWidthTwips:12240,pageHeightTwips:15840,marginsTwips:{top:1440,right:1440,bottom:1440,left:1440}};function Es(e){let t=e&&e.pageWidthTwips>0&&e.pageHeightTwips>0?e:null,{pageWidthTwips:o,pageHeightTwips:n,marginsTwips:r}=t??ID,i=o/20,a=n/20,l=Math.max(72,(o-r.left-r.right)/20),s=Math.max(72,(n-r.top-r.bottom)/20);return {width:i,height:a,area:{x:r.left/20,y:r.top/20,width:l,height:s}}}var mh=12,fh=[.55,1,1,.9,0,1,1,.6,0,1,.95,1,.45];function kh(e){let{area:t}=e,o=36,n=[];for(let r=0,i=t.y;i+mh<=t.y+t.height;r++){let a=fh[r%fh.length];a>0&&n.push({x:t.x,y:i,width:t.width*a,height:mh}),i+=o;}return n}var wh="contrast(0.157068) brightness(1.91)",cp=100,Go=e=>Math.round(e*100)/100,Dh=e=>({cx:e.area.x+e.area.width/2,cy:e.area.y+e.area.height/2});function Rh(e,t=Es(null)){if(e.kind!=="text")return null;let o=e.text.trim();if(o==="")return null;let n=editor.watermarkShapeBox({text:o,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,layout:e.layout},t.area);if(!n)return null;let{cx:r,cy:i}=Dh(t);return {text:o,fontFamily:`"${e.fontFamily.replace(/["\\]/g,"")}", sans-serif`,fontWeight:e.bold?"bold":"normal",fontStyle:e.italic?"italic":"normal",fill:`#${Ts.test(e.color)?e.color.toUpperCase():"C0C0C0"}`,opacity:Go(1-Math.min(1,Math.max(0,e.transparency))),box:{x:Go(r-n.width/2),y:Go(i-n.height/2),width:Go(n.width),height:Go(n.height)},rotation:e.layout==="diagonal"?-45:0}}var gh=new WeakMap;function ND(e){if(!e)return null;let t=gh.get(e);if(t===void 0){try{t=e.createElement("canvas").getContext("2d");}catch{t=null;}gh.set(e,t);}return t}function Mh(e,t){let o=cp,n=ND(t);if(n){n.font=`${e.fontStyle} ${e.fontWeight} ${o}px ${e.fontFamily}`;let r=n.measureText(e.text),i=-(r.actualBoundingBoxLeft??0),a=r.actualBoundingBoxRight??r.width,l=-(r.actualBoundingBoxAscent??0),s=r.actualBoundingBoxDescent??0;if(a>i&&s>l)return {left:i,right:a,top:l,bottom:s}}return {left:0,right:.55*o*Array.from(e.text).length,top:-0.7*o,bottom:0}}function _h(e,t){let{x:o,y:n,width:r,height:i}=e.box,a=r>4*7.2?7.2:0,l=i>4*3.6?3.6:0,s=(r-2*a)/(t.right-t.left),c=(i-2*l)/(t.bottom-t.top),d=o+a-t.left*s,m=n+l-t.top*c,u=p=>String(Math.round(p*1e4)/1e4),g=`matrix(${u(s)} 0 0 ${u(c)} ${u(d)} ${u(m)})`;return e.rotation?`rotate(${e.rotation} ${u(o+r/2)} ${u(n+i/2)}) ${g}`:g}function Ih(e,t=Es(null)){if(e.kind!=="picture"||!e.imageData)return null;let o=editor.watermarkShapeBox({imageData:e.imageData,scale:e.scale},t.area);if(!o)return null;let{cx:n,cy:r}=Dh(t);return {x:Go(n-o.width/2),y:Go(r-o.height/2),width:Go(o.width),height:Go(o.height)}}var FD=e=>e.editable,LD={ok:false,code:"unsupported",reason:"editor is not ready"};function up(){let e=A(),t=Zt.useCallback(l=>e?.getWatermark()??null,[e]),o=W(t,Th),n=W(FD),r=Zt.useMemo(()=>n&&e!==null&&e.can({type:"setWatermark",watermark:{text:"DRAFT"}}).ok,[e,n]),i=Zt.useCallback(()=>e?.query({type:"watermark"})??null,[e]),a=Zt.useCallback(l=>e?e.exec({type:"setWatermark",watermark:l}):LD,[e]);return Zt.useMemo(()=>({watermark:o,isEnabled:r,read:i,apply:a}),[o,r,i,a])}var WD=e=>e.pageSetup??null,co=yt(),ZD=co.part("preview");function Hh(){return co.useState()}var Fh=e=>`${Math.round(e*100)}%`;function KD(e){let[t,o]=Zt.useState(null);return Zt.useEffect(()=>{if(!e||typeof URL.createObjectURL!="function"){o(null);return}let n=URL.createObjectURL(new Blob([e]));return o(n),()=>URL.revokeObjectURL(n)},[e]),t}function qD({className:e,style:t,"data-docx-part":o,...n}){let{values:r}=Hh(),i=A(),a=W(WD),l=Zt.useMemo(()=>Es(a),[a]),s=KD(r.kind==="picture"?r.imageData:null),c=Rh(r,l),d=s?Ih(r,l):null;return jsxRuntime.jsx("div",{...n,"data-docx-part":"preview","aria-hidden":"true",className:["docx-dialog__preview",e].filter(Boolean).join(" "),style:t,children:jsxRuntime.jsxs("svg",{className:"docx-dialog__preview-page",viewBox:`0 0 ${l.width} ${l.height}`,focusable:"false",children:[jsxRuntime.jsx("rect",{className:"docx-dialog__preview-sheet",x:0,y:0,width:l.width,height:l.height}),c?jsxRuntime.jsx("text",{"data-docx-watermark-preview":"text",x:0,y:0,fontFamily:c.fontFamily,fontSize:cp,fontWeight:c.fontWeight,fontStyle:c.fontStyle,fill:c.fill,fillOpacity:c.opacity,transform:_h(c,Mh(c,i?editor.editorHostDocument(i):null)),children:c.text}):null,s&&d?jsxRuntime.jsx("image",{"data-docx-watermark-preview":"picture",className:"docx-dialog__preview-picture",href:s,x:d.x,y:d.y,width:d.width,height:d.height,preserveAspectRatio:"none",style:r.washout?{filter:wh}:void 0}):null,kh(l).map(m=>jsxRuntime.jsx("rect",{className:"docx-dialog__preview-line",x:m.x,y:m.y,width:m.width,height:m.height},m.y))]})})}function UD({open:e,onClose:t,presets:o=np,className:n,style:r,children:i,preset:a=true}){let{t:l}=H(),s=A(),c=Co(e,t),{isEnabled:d,read:m,apply:u}=up(),g=W(so),[p,f]=Zt.useState({...ip}),[b,y]=Zt.useState([]),[v,x]=Zt.useState(null),[h,k]=Zt.useState(false),[E,C]=Zt.useState(0),T=Zt.useRef(null),S=Zt.useRef(null),P=Zt.useRef(null),w=Zt.useId(),_=Zt.useRef(false);Zt.useEffect(()=>{if(!e||g||!s){_.current=false;return}if(_.current)return;_.current=true;let I=s.getWatermark(),ie=yh(I,m());T.current=Eh(I,ie),f(ie),y(s.getAvailableFonts()),x(null),k(false),C(ge=>ge+1);},[e,g,s,m]),Zt.useEffect(()=>{E!==0&&S.current?.querySelector(`input[name="${w}-kind"]:checked`)?.focus({preventScroll:true});},[E,w]);let L=Zt.useCallback((I,ie)=>{x(null),f(ge=>({...ge,[I]:ie}));},[]),N=xh(p),B=d&&N!==void 0,F=Zt.useCallback(()=>{if(!B||N===void 0)return;if(!c()){t();return}if(T.current&&Sh(T.current,p)){t();return}let I=u(N);I.ok?t():x(I.reason);},[B,N,p,c,u,t]),D=Zt.useCallback(I=>{I&&(k(false),I.arrayBuffer().then(ie=>{f(ge=>({...ge,kind:"picture",imageData:new Uint8Array(ie),imageName:I.name})),x(null);}).catch(()=>k(true)));},[]);if(!e)return null;let R=p.kind==="picture",U=p.kind==="text",V=b.includes(p.fontFamily)?b:[p.fontFamily,...b],Y=p.imageData?p.imageName??l("dialogs.watermark.currentPicture"):l("dialogs.watermark.noPictureSelected"),j=v!==null?l("dialogs.watermark.refused"):null,q=(I,ie,ge)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":I,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${w}-kind`,checked:p.kind===ie,onChange:()=>L("kind",ie)}),jsxRuntime.jsx("span",{id:`${w}-${I}-label`,children:ge})]}),X=(I,ie,ge)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":I,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${w}-${I}`,children:ie}),ge]}),ee=(I,ie,ge)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":I,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",disabled:!ge,checked:p[I],onChange:K=>L(I,K.target.checked)}),jsxRuntime.jsx("span",{children:ie})]}),O={values:p,setValue:L,errors:j?{form:j}:{},isEnabled:B,apply:F,cancel:t};return jsxRuntime.jsx(Fe,{kind:"watermark",className:n,style:r,panelRef:S,label:l("dialogs.watermark.title"),onClose:t,onKeyDown:I=>{let ie=I.target;I.key==="Enter"&&editor.isHTMLElementNode(ie)&&ie.localName==="input"&&(ie.type==="text"||ie.type==="number")&&B&&(I.preventDefault(),F());},children:jsxRuntime.jsx(co.Composition,{state:O,preset:a,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:l("dialogs.watermark.title")})}),jsxRuntime.jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxRuntime.jsxs("div",{className:"docx-dialog__watermark-layout",children:[jsxRuntime.jsx(qD,{"data-docx-part":"preview"}),jsxRuntime.jsxs("fieldset",{className:"docx-dialog__fieldset",children:[jsxRuntime.jsx("legend",{className:"docx-editor-sr-only",children:l("dialogs.watermark.kind")}),q("noWatermark","none",l("dialogs.watermark.noWatermark")),q("pictureWatermark","picture",l("dialogs.watermark.picture")),jsxRuntime.jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${w}-pictureWatermark-label`,children:[jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"picture",className:"docx-dialog__row",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{L("kind","picture"),P.current?.click();},children:l("dialogs.watermark.selectPicture")}),jsxRuntime.jsx("span",{className:"docx-dialog__hint","data-docx-watermark-picture":"",children:h?l("dialogs.watermark.pictureFailed"):Y}),jsxRuntime.jsx("input",{ref:P,type:"file",accept:hh,hidden:true,"aria-label":l("dialogs.watermark.selectPicture"),onChange:I=>{let ie=I.target.files?.[0];I.target.value="",D(ie);}})]}),X("scale",l("dialogs.watermark.scale"),jsxRuntime.jsxs("select",{id:`${w}-scale`,className:"docx-dialog__select",disabled:!R,value:p.scale===null?"auto":String(p.scale),onChange:I=>L("scale",I.target.value==="auto"?null:Number(I.target.value)),children:[rp.map(I=>jsxRuntime.jsx("option",{value:I===null?"auto":String(I),children:I===null?l("dialogs.watermark.auto"):Fh(I)},String(I))),p.scale!==null&&!rp.includes(p.scale)?jsxRuntime.jsx("option",{value:String(p.scale),children:Fh(p.scale)}):null]})),ee("washout",l("dialogs.watermark.washout"),R)]}),q("textWatermark","text",l("dialogs.watermark.text")),jsxRuntime.jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${w}-textWatermark-label`,children:[X("preset",l("dialogs.watermark.preset"),jsxRuntime.jsxs("select",{id:`${w}-preset`,className:"docx-dialog__select",disabled:!U,value:Ph(p.text,o),onChange:I=>{I.target.value!==""&&L("text",I.target.value);},children:[jsxRuntime.jsx("option",{value:"",children:l("dialogs.watermark.custom")}),o.map(I=>jsxRuntime.jsx("option",{value:I,children:I},I))]})),X("text",l("dialogs.watermark.textLabel"),jsxRuntime.jsx("input",{id:`${w}-text`,type:"text",className:"docx-dialog__input",disabled:!U,maxLength:256,value:p.text,onChange:I=>L("text",I.target.value)})),X("fontFamily",l("dialogs.watermark.font"),jsxRuntime.jsx("select",{id:`${w}-fontFamily`,className:"docx-dialog__select",disabled:!U,value:p.fontFamily,onChange:I=>L("fontFamily",I.target.value),children:V.map(I=>jsxRuntime.jsx("option",{value:I,children:I},I))})),X("fontSizePt",l("dialogs.watermark.size"),jsxRuntime.jsxs("select",{id:`${w}-fontSizePt`,className:"docx-dialog__select",disabled:!U,value:p.fontSizePt===null?"auto":String(p.fontSizePt),onChange:I=>L("fontSizePt",I.target.value==="auto"?null:Number(I.target.value)),children:[ap.map(I=>jsxRuntime.jsx("option",{value:I===null?"auto":String(I),children:I===null?l("dialogs.watermark.auto"):String(I)},String(I))),p.fontSizePt!==null&&!ap.includes(p.fontSizePt)?jsxRuntime.jsx("option",{value:String(p.fontSizePt),children:p.fontSizePt}):null]})),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[ee("bold",l("dialogs.watermark.bold"),U),ee("italic",l("dialogs.watermark.italic"),U)]}),X("transparency",l("dialogs.watermark.transparency"),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("input",{type:"range",className:"docx-dialog__range",min:0,max:100,step:1,disabled:!U,"aria-label":l("dialogs.watermark.transparency"),value:lp(p.transparency),onChange:I=>L("transparency",sp(I.target.value,p.transparency))}),jsxRuntime.jsx("input",{id:`${w}-transparency`,type:"number",className:"docx-dialog__input docx-dialog__input--narrow",min:0,max:100,step:1,disabled:!U,value:lp(p.transparency),onChange:I=>L("transparency",sp(I.target.value,p.transparency))}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:"%"})]})),X("color",l("dialogs.watermark.color"),jsxRuntime.jsx("input",{id:`${w}-color`,type:"color",className:"docx-dialog__color",disabled:!U,value:vh(p.color),onChange:I=>{let ie=Ch(I.target.value);ie&&L("color",ie);}})),jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"layout",className:"docx-dialog__row",role:"radiogroup","aria-label":l("dialogs.watermark.layout"),children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:l("dialogs.watermark.layout")}),["diagonal","horizontal"].map(I=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${w}-layout`,disabled:!U,checked:p.layout===I,onChange:()=>L("layout",I)}),jsxRuntime.jsx("span",{children:l(`dialogs.watermark.${I}`)})]},I))]})]})]})]})}),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",...v?{title:v}:{},children:j}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:l("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!B,"data-docx-part":"apply",onClick:F,children:l("common.apply")})]})]}),children:i})})}var or=Object.assign(UD,{Header:co.Header,Title:co.Title,Body:co.Body,Preview:ZD,Footer:co.Footer,Apply:co.Apply,Cancel:co.Cancel,Error:co.Error,Field:co.Field});var Ps={ok:false,code:"unsupported",reason:"editor is not ready"},zD=Object.freeze([]);function fp(e,t){return e.length===t.length&&e.every((o,n)=>o.name===t[n].name&&o.order===t[n].order&&o.story===t[n].story&&o.empty===t[n].empty&&o.atSelection===t[n].atSelection&&o.duplicates===t[n].duplicates&&o.hidden===t[n].hidden&&o.place===t[n].place)}function gp(){let e=A(),t=Zt.useCallback(c=>e?.query({type:"bookmarks"})??zD,[e]),o=W(t,fp),n=Zt.useCallback(c=>c.editable&&e!==null&&e.can({type:"insertBookmark",name:"Bookmark"}).ok,[e]),r=W(n),i=Zt.useCallback(c=>e?e.exec({type:"insertBookmark",name:c}):Ps,[e]),a=Zt.useCallback(c=>e?e.exec({type:"deleteBookmark",name:c}):Ps,[e]),l=Zt.useCallback(c=>e?e.exec({type:"goToBookmark",name:c}):Ps,[e]),s=Zt.useCallback(c=>e?e.exec({type:"keepFirstBookmark",name:c}):Ps,[e]);return Zt.useMemo(()=>({bookmarks:o,isWritable:r,insert:i,remove:a,goTo:l,keepFirst:s}),[o,r,i,a,l,s])}var Oh={empty:"dialogs.bookmark.nameEmpty",tooLong:"dialogs.bookmark.nameTooLong",invalidStart:"dialogs.bookmark.nameInvalidStart",invalidCharacter:"dialogs.bookmark.nameInvalidCharacter"};function JD(e){return e.open?jsxRuntime.jsx(QD,{...e}):null}function QD({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=Co(e,t),{bookmarks:s,isWritable:c,insert:d,remove:m,goTo:u,keepFirst:g}=gp(),[p,f]=Zt.useState(()=>editor.bookmarkDialogInitialName(s)),[b,y]=Zt.useState("name"),[v,x]=Zt.useState(false),[h,k]=Zt.useState(false),[E,C]=Zt.useState(false),[T,S]=Zt.useState(false),P=Zt.useRef(null),w=Zt.useRef(null),_=Zt.useId(),L=Zt.useId(),N=Zt.useId(),B=editor.bookmarkDialogRows(s,{sortBy:b,showHidden:v}),F=editor.bookmarkDialogNameState(s,p,c),D=F.problem&&!F.existing&&(E||p.length>0)?F.problem:null,R=F.existing?.duplicates??0,U=h?a("dialogs.bookmark.refused"):D?a(Oh[D]):R>0?a("dialogs.bookmark.duplicates",{count:R}):F.existing&&F.canAdd?a("dialogs.bookmark.nameExists"):null,V=Zt.useCallback(()=>{if(C(true),!F.canAdd)return;if(!l()){t();return}let O=d(p);k(!O.ok),O.ok&&t();},[F.canAdd,l,d,p,t]),Y=Zt.useCallback(()=>{if(!F.canDelete||!F.existing)return;let O=m(F.existing.name);k(!O.ok),O.ok&&f("");},[F,m]),j=Zt.useCallback(()=>{if(!F.canGoTo||!F.existing)return;let O=u(F.existing.name);k(!O.ok),O.ok&&S(true);},[F,u]),q=Zt.useCallback(()=>{let O=F.existing;!O||!c||k(!g(O.name).ok);},[F.existing,c,g]),X=F.existing?.name??"";Zt.useLayoutEffect(()=>{!X&&w.current&&(w.current.selectedIndex=-1);});let ee={values:{name:p,sortBy:b,showHidden:v},setValue(O,I){O==="name"?f(I):O==="sortBy"?y(I):x(I),k(false);},errors:D?{name:a(Oh[D])}:h?{form:a("dialogs.bookmark.refused")}:{},isEnabled:F.canAdd,apply:V,cancel:t,rows:B,canDelete:F.canDelete,canGoTo:F.canGoTo,duplicates:R,remove:Y,goTo:j,keepFirst:q};return jsxRuntime.jsx(Fe,{kind:"bookmark",className:o,style:n,panelRef:P,label:a("dialogs.bookmark.title"),onClose:t,onKeyDown:O=>{O.key==="Enter"&&!O.nativeEvent.isComposing&&O.keyCode!==229&&editor.isHTMLElementNode(O.target)&&O.target.localName==="input"&&O.target.getAttribute("type")==="text"&&(O.preventDefault(),V());},children:jsxRuntime.jsx(Ot.Composition,{state:ee,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.bookmark.title")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"name",className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:_,children:a("dialogs.bookmark.name")}),jsxRuntime.jsx("input",{id:_,type:"text",className:"docx-dialog__input",value:p,maxLength:40,autoComplete:"off",spellCheck:false,"aria-invalid":D?true:void 0,"aria-describedby":L,onChange:O=>ee.setValue("name",O.target.value)})]}),jsxRuntime.jsx("div",{"data-docx-part":"field","data-docx-field":"list",className:"docx-dialog__row",children:jsxRuntime.jsx("select",{ref:w,className:"docx-dialog__input docx-dialog__input--full docx-bookmark-dialog__list",size:8,value:X,"aria-label":a("dialogs.bookmark.list"),onChange:O=>ee.setValue("name",O.target.value),onDoubleClick:j,children:B.map(O=>jsxRuntime.jsx("option",{value:O.name,children:O.name},O.name))})}),B.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__hint",children:a("dialogs.bookmark.empty")}):null,jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":"sortBy",className:"docx-dialog__row",role:"radiogroup","aria-label":a("dialogs.bookmark.sortBy"),children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:a("dialogs.bookmark.sortBy")}),["name","location"].map(O=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:N,checked:b===O,onChange:()=>ee.setValue("sortBy",O)}),a(O==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},O))]}),jsxRuntime.jsx("div",{"data-docx-part":"field","data-docx-field":"showHidden",className:"docx-dialog__row",children:jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:v,onChange:O=>ee.setValue("showHidden",O.target.checked)}),a("dialogs.bookmark.showHidden")]})}),jsxRuntime.jsxs("div",{className:"docx-dialog__row docx-bookmark-dialog__status",children:[jsxRuntime.jsx("span",{id:L,"data-docx-part":"error",role:"status",className:D||h?"docx-dialog__error":"docx-dialog__hint",children:U}),R>0?jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"keepfirst",disabled:!c,onClick:q,children:a("dialogs.bookmark.keepFirst")}):null]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply","data-docx-part":"apply",disabled:!F.canAdd,onClick:V,children:a("dialogs.bookmark.add")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"delete",disabled:!F.canDelete,onClick:Y,children:a("dialogs.bookmark.delete")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"goto",disabled:!F.canGoTo,onClick:j,children:a("dialogs.bookmark.goTo")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a(T?"common.close":"common.cancel")})]})]}),children:r})})}var Ot=yt();function eR(){return Ot.useState()}var mi=Object.assign(JD,{Header:Ot.Header,Title:Ot.Title,Body:Ot.Body,Footer:Ot.Footer,Apply:Ot.Apply,Cancel:Ot.Cancel,Error:Ot.Error,Field:Ot.Field,Delete:Ot.part("delete"),GoTo:Ot.part("goto"),KeepFirst:Ot.part("keepfirst")});var Wh=editor.SPLIT_CELL_FALLBACK_MAX;function sR(e){return e.open?jsxRuntime.jsx(dR,{...e}):null}var cR=e=>e;function dR({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=A(),s=Co(e,t),c=Zt.useMemo(()=>l?.query({type:"splitCellConfig"})??null,[l]),[d]=Zt.useState(()=>editor.initialSplitCellCounts(c,F=>l?l.can(F):{ok:false,code:"unsupported",reason:""})),[m,u]=Zt.useState(d.columns),[g,p]=Zt.useState(d.rows),[f,b]=Zt.useState(null),y=Zt.useId(),v=Zt.useId(),x=Zt.useId(),{counts:h,problem:k}=editor.readSplitCellCounts(m,g,c),E=h?.cols??null,C=h?.rows??null;W(cR);let T=l&&h?l.can({type:"splitCell",...h}):null,S=k?.kind==="range"?a("dialogs.splitCell.range",{max:k.max}):k?.kind==="oneCell"?a("dialogs.splitCell.oneCell"):T&&!T.ok?i18n.localizeDisabledReason(T.reason??null,a):null,P=T?.ok===true,w=f??S,_=k?.kind==="range"?k.field:null,L=Zt.useCallback(()=>{if(!P||!l)return;if(!s()){t();return}let F=l.exec({type:"splitCell",rows:C,cols:E});F.ok?t():b(i18n.localizeDisabledReason(F.reason??null,a));},[P,l,s,t,C,E,a]),N={values:{columns:m,rows:g},setValue(F,D){F==="columns"?u(D):p(D),b(null);},errors:w?{form:w}:{},isEnabled:P,apply:L,cancel:t,limits:c},B=(F,D,R,U,V)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":F,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:D,children:a(R)}),jsxRuntime.jsx("input",{id:D,type:"number",inputMode:"numeric",className:"docx-dialog__input",min:1,max:V,step:1,value:U,"aria-invalid":_===F?true:void 0,"aria-describedby":x,onChange:Y=>N.setValue(F,Y.target.value)})]});return jsxRuntime.jsx(Fe,{kind:"splitCell",className:o,style:n,label:a("table.splitCell"),onClose:t,onKeyDown:F=>{F.key==="Enter"&&!F.nativeEvent.isComposing&&F.keyCode!==229&&editor.isHTMLElementNode(F.target)&&F.target.localName==="input"&&(F.preventDefault(),L());},children:jsxRuntime.jsx(Ro.Composition,{state:N,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("table.splitCell")})}),jsxRuntime.jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[B("columns",y,"dialogs.splitCell.columns",m,c?.maxCols??Wh),B("rows",v,"dialogs.splitCell.rows",g,c?.maxRows??Wh),jsxRuntime.jsx("div",{className:"docx-dialog__row",children:jsxRuntime.jsx("span",{id:x,"data-docx-part":"error",role:"status",className:"docx-dialog__error",children:w})})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply","data-docx-part":"apply",disabled:!P,onClick:L,children:a("dialogs.splitCell.submit")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("common.cancel")})]})]}),children:r})})}var Ro=yt();function uR(){return Ro.useState()}var fi=Object.assign(sR,{Header:Ro.Header,Title:Ro.Title,Body:Ro.Body,Footer:Ro.Footer,Apply:Ro.Apply,Cancel:Ro.Cancel,Error:Ro.Error,Field:Ro.Field});var Zh=Zt.createContext(void 0),Kh=Zh.Provider;function tt(){let e=Zt.useContext(Zh),{t}=H();return Zt.useCallback((o,n)=>{let r=e?.(o,n);return r===void 0||r===o?t(o,n):r},[e,t])}var Mo=yt();function yR(){return Mo.useState()}function xR({session:e,...t}){let[o,n]=Zt.useState(e),[r,i]=Zt.useState(0);return o!==e&&(n(e),i(r+1)),e?jsxRuntime.jsx(vR,{session:e,...t},r):null}function vR({session:e,children:t,preset:o,className:n,style:r}){let i=tt(),a=W(()=>e.canApply()),[l,s]=Zt.useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=Zt.useState(e.signal.aborted),[m,u]=Zt.useState(false);Zt.useEffect(()=>{let v=()=>d(true);return e.signal.addEventListener("abort",v),e.signal.aborted&&v(),()=>e.signal.removeEventListener("abort",v)},[e]);let g=()=>{if(e.signal.aborted)return;let v=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(!v);},p={values:l,setValue(v,x){s(h=>({...h,[v]:x,...v==="type"?{format:""}:{}})),u(false);},errors:m?{form:i("textFormField.invalidOptions")}:{},isEnabled:!c&&a,apply:g,cancel:e.cancel};if(c)return null;let f=editor.TEXT_FORM_FORMATS[l.type]??[],b={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},y=(v,x)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":v,className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${v}`)}),x]});return jsxRuntime.jsx(Fe,{kind:"textFormField",className:n,style:r,label:i("textFormField.title"),onClose:e.cancel,dismissOutside:false,sessionSignal:e.signal,restoreFocus:false,onKeyDown:v=>{v.key==="Escape"&&(v.preventDefault(),e.cancel()),v.key==="Enter"&&editor.isHTMLElementNode(v.target)&&v.target.localName==="input"&&(v.preventDefault(),g());},children:jsxRuntime.jsx(Mo.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:[y("defaultText",jsxRuntime.jsx("input",{className:"docx-dialog__input",value:l.defaultText,onChange:v=>p.setValue("defaultText",v.target.value)})),y("type",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:v=>p.setValue("type",v.target.value),children:[["regular","number","date"].map(v=>jsxRuntime.jsx("option",{value:v,children:i(`textFormField.${v}`)},v)),Object.hasOwn(editor.TEXT_FORM_FORMATS,l.type)?null:jsxRuntime.jsx("option",{value:l.type,disabled:true,children:i("textFormField.preservedType")})]})),y("maxLength",jsxRuntime.jsx("input",{className:"docx-dialog__input",type:"number",min:0,max:32767,step:1,value:Number.isNaN(l.maxLength)?"":l.maxLength,onChange:v=>p.setValue("maxLength",v.target.valueAsNumber)})),y("format",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:v=>p.setValue("format",v.target.value),children:[f.map(v=>jsxRuntime.jsx("option",{value:v,children:b[v]?i(b[v]):v||i("textFormField.noFormat")},v)),f.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:v=>p.setValue("enabled",v.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 bi=Object.assign(xR,{Header:Mo.Header,Title:Mo.Title,Body:Mo.Body,Footer:Mo.Footer,Apply:Mo.Apply,Cancel:Mo.Cancel,Error:Mo.Error,Field:Mo.Field});var $h=Zt.createContext(null),_o=()=>Zt.useContext($h);function zh({popups:e,children:t}){let o=A(),n=Gd(),[r,i]=Zt.useState(null),[a,l]=Zt.useState(null),[s,c]=Zt.useState(null),[d,m]=Zt.useState(null),u=Zt.useRef(d);u.current=d;let[g,p]=Zt.useState(null),f=Zt.useRef(g);f.current=g;let b=Zt.useRef(e);b.current=e;let y=Zt.useRef(null),v=Zt.useRef(s);v.current=s;let x=()=>l(null);Zt.useEffect(()=>{if(a!==null)return;let T=y.current;y.current=null,T?.isConnected&&T.focus({preventScroll:true});},[a]),Zt.useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(T){if(b.current?.textFormField===false){T.cancel();return}u.current?.cancel(),f.current?.cancel(),l(null),c(T),T.signal.addEventListener("abort",()=>c(S=>S===T?null:S),{once:true});}},{fallback:true})},[o]),Zt.useEffect(()=>{if(!o||!r&&e?.revisionMarkup!==false)return;let T=o.setRevisionMarkupChrome({onRequest(S){if(b.current?.revisionMarkup===false){S.cancel();return}v.current?.cancel(),f.current?.cancel(),l(null),m(S),S.signal.addEventListener("abort",()=>m(P=>P===S?null:P),{once:true});}},{fallback:true});return ()=>{u.current?.cancel(),T();}},[o,r,e?.revisionMarkup===false]),Zt.useEffect(()=>{if(!o||!r&&e?.compareDocuments!==false)return;let T=o.setCompareDocumentsChrome({onRequest(S){if(b.current?.compareDocuments===false){S.cancel();return}v.current?.cancel(),u.current?.cancel(),l(null),p(S),S.signal.addEventListener("abort",()=>p(P=>P===S?null:P),{once:true});}},{fallback:true});return ()=>{f.current?.cancel(),T();}},[o,r,e?.compareDocuments===false]),Zt.useEffect(()=>{l(null),c(null),m(null),p(null);},[o,n]);let h=e?.bookmark===false;Zt.useEffect(()=>{if(!(!o||!r||h))return o.setBookmarkChrome({onRequest(){v.current?.cancel(),u.current?.cancel(),f.current?.cancel(),y.current=PR(r.ownerDocument.activeElement),l("bookmark");}})},[o,r,h]),Zt.useEffect(()=>{e?.revisionMarkup===false&&u.current?.cancel(),e?.compareDocuments===false&&f.current?.cancel(),e?.textFormField===false&&v.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let k=Zt.useMemo(()=>({container:r,setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(T,S){v.current?.cancel(),u.current?.cancel(),f.current?.cancel(),b.current?.[T]!==false&&(y.current=S??r?.ownerDocument.activeElement,l(T));}}),[r,e?.pageSetup]),E={open:true,onClose:x},C=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?Te(e.pageSetup,E):jsxRuntime.jsx(tr,{...E}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Te(e.paragraph,E):jsxRuntime.jsx(Vo,{...E}):a==="watermark"&&e?.watermark!==false?e?.watermark?Te(e.watermark,E):jsxRuntime.jsx(or,{...E}):a==="bookmark"&&e?.bookmark!==false?e?.bookmark?Te(e.bookmark,E):jsxRuntime.jsx(mi,{...E}):a==="splitCell"&&e?.splitCell!==false?e?.splitCell?Te(e.splitCell,E):jsxRuntime.jsx(fi,{...E}):d&&e?.revisionMarkup!==false?e?.revisionMarkup?Te(e.revisionMarkup,{session:d},d):jsxRuntime.jsx(Ka,{session:d}):g&&e?.compareDocuments!==false?e?.compareDocuments?Te(e.compareDocuments,{session:g},g):jsxRuntime.jsx(qa,{session:g}):s&&e?.textFormField!==false?e?.textFormField?Te(e.textFormField,{session:s},s):jsxRuntime.jsx(bi,{session:s}):null;return jsxRuntime.jsxs($h.Provider,{value:k,children:[t,r?reactDom.createPortal(C,r):null]})}function PR(e){return e?.closest("[data-menu]")?.querySelector(':scope > [role="menuitem"]')??e}function Vh(){let e=_o();return jsxRuntime.jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer,dir:lt()})}function Gh({children:e}){let t=_o();return t?.container?reactDom.createPortal(e,t.container):e}var jh=["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"],Yh=["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"],yp=["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"],xp=["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"],Xh=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],Jh=["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"],Qh=["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 Qr(e,t,o){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:l,hidden:s})=>{let c=A(),{close:d}=$o(),m=Pe(),{isEnabled:u,disabledReason:g}=re(t);return s?null:jsxRuntime.jsx(De,{slot:e,icon:r??oe(o.paths),shortcut:m(a??o.shortcutKey),disabled:!u,...g?{title:g}:{},onSelect:()=>{c?.exec(t),d(true);},...l?{className:l}:{},children:m(i??o.labelKey)})},{docxRow:e})}var xi=Qr("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:jh}),vi=Qr("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:Yh}),Ci=Qr("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:xp}),Ti=Qr("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:Qh});function ea({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=A(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=$o(),c=we(),d=Pe(),m=Zt.useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:u,disabledReason:g}=re(m);if(r)return null;let p=l!==null;return jsxRuntime.jsx(De,{slot:"edit.paste",icon:e??oe(yp),shortcut:d(o??"contextMenu.pasteShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let{text:f,html:b}=await DR(c);(f||b)&&i?.exec({type:"paste",text:f,...b?{html:b}:{}});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...n?{className:n}:{},children:d(t??"contextMenu.paste")})}ea.docxRow="edit.paste";async function DR(e){let t=editor.hostWindowOf(e),o=t.navigator.clipboard;if(typeof o.read=="function"&&typeof t.ClipboardItem<"u")try{let n=await o.read(),r="",i=null;for(let a of n)a.types.includes("text/plain")&&(r=await(await a.getType("text/plain")).text()),a.types.includes("text/html")&&(i=await(await a.getType("text/html")).text());if(r||i)return {text:r,html:i}}catch{}return {text:await o.readText(),html:null}}function ta({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=A(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=$o(),c=we(),d=Pe(),m=Zt.useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:u,disabledReason:g}=re(m);if(r)return null;let p=l!==null;return jsxRuntime.jsx(De,{slot:"edit.pasteWithoutFormatting",icon:e??oe(yp),shortcut:d(o??"contextMenu.pasteWithoutFormattingShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let f=await editor.hostWindowOf(c).navigator.clipboard.readText();f&&i?.exec({type:"pasteWithoutFormatting",text:f});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...n?{className:n}:{},children:d(t??"contextMenu.pasteWithoutFormatting")})}ta.docxRow="edit.pasteWithoutFormatting";var t0=te("format.painter")?.paths??[],Rs=Qr("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:t0}),Ms=Qr("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:t0});function Yo(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l,destructive:s})=>{let{close:c}=$o(),d=Pe(),m=Ei(),{isEnabled:u,disabledReason:g,execute:p}=re(t);return l||!m?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 oa=Yo("table.selectTable",{type:"selectTableRegion",region:"table"},{labelKey:"table.selectTable",paths:editor.tableChromeIconPaths("select_all")}),na=Yo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:editor.tableChromeIconPaths("table_rows")}),ra=Yo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:editor.tableChromeIconPaths("table_rows")}),aa=Yo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:editor.tableChromeIconPaths("view_column")}),ia=Yo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:editor.tableChromeIconPaths("view_column")}),la=Yo("table.mergeCells",{type:"mergeCells"},{labelKey:"table.mergeCells",paths:editor.tableChromeIconPaths("call_merge")}),sa=Object.assign(({icon:e,labelKey:t,className:o,hidden:n})=>{let{close:r}=$o(),i=Pe(),a=Ei(),l=_o(),{isEnabled:s,disabledReason:c}=re("table.splitCell");return n||!a||!l?null:jsxRuntime.jsx(De,{slot:"table.splitCell",icon:e??oe(editor.tableChromeIconPaths("call_split")),disabled:!s,...c?{title:c}:{},...o?{className:o}:{},onSelect:()=>{r(true),l.open("splitCell");},children:i(t??"table.splitCell")})},{docxRow:"table.splitCell"}),ca=Yo("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:editor.tableChromeIconPaths("delete_sweep"),destructive:true}),da=Yo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:editor.tableChromeIconPaths("view_column"),destructive:true}),ua=Yo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:editor.tableChromeIconPaths("delete"),destructive:true}),RR=[{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 ar({hidden:e}){let{close:t}=$o(),o=Pe(),n=Ei(),r=re({type:"setTableCellVerticalAlignment",alignment:"top"}),i=re({type:"setTableCellVerticalAlignment",alignment:"center"}),a=re({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:RR.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:m=>{m.preventDefault(),m.stopPropagation();},onClick:()=>{d.execute()&&t(true);},children:oe(editor.tableChromeIconPaths(s.icon))},s.alignment)})})]})}ar.docxRow="table.cellVerticalAlignment";var o0=e=>e?{tocId:e}:{},n0=e=>t=>({type:"refreshToc",mode:e,...o0(t)}),MR=e=>({type:"removeToc",...o0(e)});function Cp(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l})=>{let s=A(),{close:c,tocId:d}=$o(),m=Pe(),u=Zt.useMemo(()=>t(d),[d]),{isEnabled:g,disabledReason:p}=re(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:m(i??o.labelKey)})},{docxRow:e})}var pa=Cp("toc.refresh",n0("entire"),{labelKey:"toc.refresh",paths:Xh}),ma=Cp("toc.refreshPageNumbers",n0("pageNumbers"),{labelKey:"toc.refreshPageNumbers",paths:Jh}),fa=Cp("toc.remove",MR,{labelKey:"toc.remove",paths:xp});function Ei(){return W(Zt.useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function _s({label:e,icon:t,shortcut:o,disabled:n,disabledReason:r,active:i,onSelect:a,className:l}){let{close:s}=$o();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 Pi=8;function LR(){let e=Zt.useContext(At),t=et(),o=Pe(),{isEnabled:n,reason:r}=ts(o);if((e?.mounted??0)===0)return null;let i=te("review.addComment");return jsxRuntime.jsx(De,{icon:oe(i?.paths),slot:"review.addComment",disabled:!n,title:r??void 0,onSelect:()=>{e?.requestCommentDraft()&&t.setOpenMenu(null);},children:o("comments.addComment")})}function HR(){let e=A(),t=et(),o=Pe();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 AR=[{kind:"row",id:"field.edit",render:()=>jsxRuntime.jsx(HR,{})},{kind:"row",id:"edit.cut",render:()=>jsxRuntime.jsx(xi,{})},{kind:"row",id:"edit.copy",render:()=>jsxRuntime.jsx(vi,{})},{kind:"row",id:"edit.paste",render:()=>jsxRuntime.jsx(ea,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsxRuntime.jsx(ta,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsxRuntime.jsx(Rs,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsxRuntime.jsx(Ms,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsxRuntime.jsx(Ci,{})},{kind:"row",id:"edit.selectAll",render:()=>jsxRuntime.jsx(Ti,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsxRuntime.jsx(gs,{shortcutKey:"contextMenu.insertLinkShortcut"})},{kind:"row",id:"review.addComment",render:()=>jsxRuntime.jsx(LR,{})}];function OR(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:oa.docxRow,render:()=>jsxRuntime.jsx(oa,{})},{kind:"row",id:na.docxRow,render:()=>jsxRuntime.jsx(na,{})},{kind:"row",id:ra.docxRow,render:()=>jsxRuntime.jsx(ra,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:aa.docxRow,render:()=>jsxRuntime.jsx(aa,{})},{kind:"row",id:ia.docxRow,render:()=>jsxRuntime.jsx(ia,{})},{kind:"separator",id:"sep.table.cells"},{kind:"row",id:la.docxRow,render:()=>jsxRuntime.jsx(la,{})},{kind:"row",id:sa.docxRow,render:()=>jsxRuntime.jsx(sa,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:ca.docxRow,render:()=>jsxRuntime.jsx(ca,{})},{kind:"row",id:da.docxRow,render:()=>jsxRuntime.jsx(da,{})},{kind:"row",id:ua.docxRow,render:()=>jsxRuntime.jsx(ua,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:ar.docxRow,render:()=>jsxRuntime.jsx(ar,{})}]}function BR(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:pa.docxRow,render:()=>jsxRuntime.jsx(pa,{})},{kind:"row",id:ma.docxRow,render:()=>jsxRuntime.jsx(ma,{})},{kind:"row",id:fa.docxRow,render:()=>jsxRuntime.jsx(fa,{})}]}function WR(e,t=false){return [...AR,...e?OR():[],...t?BR():[]]}function c0(e){if(!Zt.isValidElement(e))return null;let t=Wr(e,c0);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=hs(e.props);if(n)return n}return null}function l0(e){if(!Zt.isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function ZR(e){return e?.closest(".docx-editor__scroll-container")??null}function ki({className:e,t,preset:o=true,disabled:n,onOpenChange:r,children:i}){let a=$t(),l=lt(),s=A(),{t:c}=H(),d=Ei(),m=Zt.useRef(null),u=Zt.useRef(null),[g,p]=Zt.useState(null),[f,b]=Zt.useState(null),[y,v]=Zt.useState(null),x=Zt.useMemo(()=>WR(d,f!==null),[d,f]),[h,k]=Zt.useState(null),E=Zt.useCallback((N=false)=>{p(null),k(null),b(null),v(null),N&&s?.focus();},[s]);Zt.useEffect(()=>{if(n)return;let N=ZR(m.current);if(!N)return;let B=F=>{if(u.current?.contains(F.target)){F.preventDefault();return}if(!Eb(N,F.target))return;F.preventDefault();let D=F.button===-1||F.clientX===0&&F.clientY===0,R=N.getBoundingClientRect();b(s?.snapshot().tocContext?.id??null),v(D||!editor.isHTMLElementNode(F.target)?null:F.target),p(D?{x:R.left+16,y:R.top+16}:{x:F.clientX,y:F.clientY});};return N.addEventListener("contextmenu",B),()=>N.removeEventListener("contextmenu",B)},[n,s]),Zt.useEffect(()=>{n&&E();},[n,E]),Zt.useEffect(()=>{if(!g)return;let N=U=>{u.current?.contains(U.target)||E();},B=U=>{U.key==="Escape"?(U.preventDefault(),E(true)):U.key==="Tab"&&E();},F=()=>E(),D=editor.hostDocumentOf(m.current??u.current),R=editor.hostWindowOf(m.current??u.current);return D.addEventListener("pointerdown",N,true),D.addEventListener("keydown",B),D.addEventListener("scroll",F,{capture:true,passive:true}),R.addEventListener("blur",F),R.addEventListener("resize",F),()=>{D.removeEventListener("pointerdown",N,true),D.removeEventListener("keydown",B),D.removeEventListener("scroll",F,true),R.removeEventListener("blur",F),R.removeEventListener("resize",F);}},[g,E]),Zt.useLayoutEffect(()=>{let N=u.current;if(!g||!N)return;let{width:B,height:F}=N.getBoundingClientRect(),D=editor.hostWindowOf(N),R=D.innerWidth-B-Pi,U=D.innerHeight-F-Pi,Y=D.getComputedStyle(N).direction==="rtl"?g.x-B>=Pi:g.x>R,j=Math.max(Pi,Math.min(Y?g.x-B:g.x,R)),q=Math.max(Pi,g.y>U?g.y-F:g.y);k({x:j,y:q});},[g]),Zt.useLayoutEffect(()=>{h&&u.current?.focus({preventScroll:true});},[h]);let C=Zt.useRef(r);C.current=r;let T=Zt.useRef(false);Zt.useEffect(()=>{let N=g!==null;N!==T.current&&(T.current=N,C.current?.(N));},[g]);let S=Zt.useMemo(()=>({t,openMenu:null,setOpenMenu:()=>E(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,E]),[P,w]=Zt.useState(null),_=Zt.useMemo(()=>({close:E,anchor:g,tocId:f,target:y,clipboardRefusal:P,reportClipboardRefusal:w}),[E,g,f,y,P]),L={position:"fixed",left:(h??g)?.x??0,top:(h??g)?.y??0,visibility:h?"visible":"hidden"};return jsxRuntime.jsx("div",{ref:m,style:{display:"contents"},children:g?jsxRuntime.jsx(ni.Provider,{value:S,children:jsxRuntime.jsx(ys.Provider,{value:_,children:jsxRuntime.jsxs("div",{ref:u,role:"menu","aria-label":t?.("contextMenu.ariaLabel")??c("contextMenu.ariaLabel"),tabIndex:-1,className:`${a}docx-toolbar__menu docx-contextmenu${e?` ${e}`:""}`,dir:l,style:L,onKeyDown:N=>{let B=u.current;if(!B)return;let F=Jn(B);N.key==="ArrowDown"?(N.preventDefault(),no(F,editor.hostDocumentOf(B).activeElement,1)):N.key==="ArrowUp"?(N.preventDefault(),no(F,editor.hostDocumentOf(B).activeElement,-1)):N.key==="Home"?(N.preventDefault(),ro(F,"first")):N.key==="End"&&(N.preventDefault(),ro(F,"last"));},children:[Zt.Children.toArray(i).filter(l0),es({entries:x,children:Zt.Children.toArray(i).filter(N=>!l0(N)),preset:o,keyOfEntry:N=>N.id,keyOfChild:N=>Tb(c0(N)),renderEntry:N=>N.kind==="separator"?jsxRuntime.jsx(Qn,{}):N.render(),onUnmatched:(N,B)=>{B.props.hidden&&qg(N);}})]})})}):null})}var Sp=Object.assign(ki,{Cut:xi,Copy:vi,Paste:ea,PasteWithoutFormatting:ta,Delete:Ci,SelectAll:Ti,SelectTable:oa,InsertRowAbove:na,InsertRowBelow:ra,InsertColumnLeft:aa,InsertColumnRight:ia,MergeCells:la,SplitCell:sa,DeleteTableRow:ca,DeleteTableColumn:da,DeleteTable:ua,CellVerticalAlignment:ar,RefreshToc:pa,RefreshTocPageNumbers:ma,RemoveToc:fa,Item:_s,Slot:ao,Row:De,Group:di,Separator:Qn,Submenu:io});var d0=su.Provider;function u0(){let e=Rt(),{t}=H();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e?.hyperlink&&Te(e.hyperlink,{}),e?.contentControl&&Te(e.contentControl,{}),e?.equation&&Te(e.equation,{}),e?.contextMenu&&Te(e.contextMenu,{t:o=>t(o)})]})}function p0(e,t,o,n){return {...e,hyperlink:e?.hyperlink??(t===false?false:r=>jsxRuntime.jsx(Ja,{...r})),contentControl:e?.contentControl??(r=>jsxRuntime.jsx(ti,{...r})),equation:e?.equation??(()=>jsxRuntime.jsx(oi,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:r=>e.contextMenu&&Te(e.contextMenu,{...r,t:n??r.t}):o===false?false:r=>jsxRuntime.jsx(ki,{...r,t:n??r.t,...typeof o=="object"?o:{}})}}function $R(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 Pp(){let e=A(),t=Zt.useCallback(n=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),o=W(t,$R);return o?.kind==="note"?o:null}function m0(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 f0(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&&m0(e.documentAuthored,t.documentAuthored)&&m0(e.sectionAuthored,t.sectionAuthored)}function zR(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&f0(e.footnote,t.footnote)&&f0(e.endnote,t.endnote)}function kp(){let e=A(),t=Zt.useCallback(o=>e?.getNotePropertiesState()??null,[e]);return W(t,zR)}function wi(e,t){let[o,n]=Zt.useState(null),r=Zt.useCallback(l=>n(l),[]),[i,a]=Zt.useState({visibility:"hidden"});return Zt.useLayoutEffect(()=>{let l=o?.closest(".docx-editor__scroll-container"),s=l??o?.parentElement?.querySelector(".docx-editor__scroll-container");if(!o||!s)return;let c=editor.hostWindowOf(s),d=0,m=null,u=new c.ResizeObserver(()=>p()),g=()=>{d=0;let b=e(s);if(b!==m&&(u.disconnect(),u.observe(s),u.observe(o),b&&u.observe(b),m=b),!b||!b.isConnected){a({visibility:"hidden"});return}let y=b.getBoundingClientRect(),v=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,x=t==="story-label"?6:4,h=l===s,k=t==="after"?y.bottom+6:t==="story-label"?editor.storyLabelTop(y,b.closest(".docx-page")?.getBoundingClientRect().top,v,x):y.top-v-x,E=h?Lr(s,y.left,k):{left:y.left,top:k},C=E.left,T=E.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"?T:Math.max(h?s.scrollTop+8:8,T),...t==="story-label"?{width:Math.max(240,Math.min(y.width,s.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(y.width-16,s.clientWidth-16))},visibility:"visible"});},p=()=>{d||(d=c.requestAnimationFrame(g));};u.observe(s),u.observe(o);let f=new c.MutationObserver(p);return f.observe(s,{subtree:true,childList:true,attributes:true,attributeFilter:["data-docx-hf-active","data-docx-note-scope"]}),s.addEventListener("scroll",p,{passive:true}),c.addEventListener("resize",p),g(),()=>{d&&c.cancelAnimationFrame(d),u.disconnect(),f.disconnect(),s.removeEventListener("scroll",p),c.removeEventListener("resize",p);}},[o,e,t]),{ref:r,style:i}}var JR=/^(footnote|endnote):(-?\d{1,10})$/;function h0(e){let t=JR.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function QR(e){let t=editor.hostWindowOf(e);return typeof t.matchMedia!="function"?false:t.matchMedia("(pointer: coarse)").matches}function Dp(e){let t=A();return Zt.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 eM(e){let{t}=H(),[o,n]=Zt.useState(false),r=Zt.useRef(null);return Zt.useEffect(()=>{if(o)return editor.listenForOutsidePress({popup:r.current,close:()=>n(false)})},[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:$,onClick:()=>n(i=>!i),children:t("headerFooter.options")}),o?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:$,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 Hs({className:e}){let t=Rt(),o=Zt.useRef(null),{t:n}=H(),r=A(),i=Pp(),[a,l]=Zt.useState(null),[s,c]=Zt.useState(null),[d,m]=Zt.useState(false),u=Zt.useRef(null),g=Zt.useCallback(_=>{if(!i)return null;let N=[..._.querySelectorAll("[data-docx-note-scope]")].find(B=>B.matches("[data-docx-note]")&&B.dataset.docxNoteScope===i.id)??null;return N?.closest("[data-docx-notes]")??N},[i]),p=wi(g,"story-label"),f=Zt.useCallback(()=>{u.current&&u.current.win.clearTimeout(u.current.handle),u.current=null,l(null);},[]);Zt.useEffect(()=>{if(!r)return;let _=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!_)return;let L=F=>{let D=F.target;if(!D)return;let R=D.closest("[data-docx-note-ref]");if(R?.dataset.docxNoteScope){F.preventDefault(),f(),c(null),r.setActiveScope({kind:"note",id:R.dataset.docxNoteScope});return}D.closest("[data-docx-note-mark-back]")&&(F.preventDefault(),f(),c(null),r.setActiveScope({kind:"body"}));},N=F=>{let D=F,U=D.target?.closest("[data-docx-note-scope]");U?.dataset.docxNoteScope&&(D.preventDefault(),c({scopeId:U.dataset.docxNoteScope,x:D.clientX,y:D.clientY}));},B=F=>{let D=F.target;if(QR(D))return;let R=D?.closest("[data-docx-note-ref]");if(!R?.dataset.docxNoteScope){f();return}let U=R.dataset.docxNoteScope,Y=r.getNotePreviewText(U)??R.getAttribute("aria-description")??n("notes.previewFallback"),j=R.getBoundingClientRect();u.current&&u.current.win.clearTimeout(u.current.handle);let q=editor.hostWindowOf(R),X=q.setTimeout(()=>{l({scopeId:U,text:Y,x:j.left,y:j.bottom+4});},400);u.current={win:q,handle:X};};return _.addEventListener("click",L),_.addEventListener("contextmenu",N),_.addEventListener("pointerover",B),_.addEventListener("scroll",f,true),()=>{_.removeEventListener("click",L),_.removeEventListener("contextmenu",N),_.removeEventListener("pointerover",B),_.removeEventListener("scroll",f,true),f();}},[r,f,n]);let b=Zt.useCallback(_=>{r&&(r.exec(_),c(null));},[r]),y=s?h0(s.scopeId):null,v=Zt.useMemo(()=>y?{type:"deleteNote",noteKind:y.noteKind,noteId:y.noteId}:null,[y]),x=Zt.useMemo(()=>y?{type:"convertNote",fromKind:y.noteKind,noteId:y.noteId}:null,[y]),h=Zt.useMemo(()=>y?{type:"convertAllNotes",fromKind:y.noteKind}:null,[y]),k=Dp(v??{type:"deleteNote",noteKind:"footnote",noteId:0}),E=Dp(x??{type:"convertNote",fromKind:"footnote",noteId:0}),C=Dp(h??{type:"convertAllNotes",fromKind:"footnote"}),T=i?h0(i.id):null,S=T?n("notes.editingRegion",{kind:T.noteKind==="footnote"?n("notes.footnoteKind"):n("notes.endnoteKind"),number:T.noteId}):null,P=s&&y?{...s,...y,onDelete:()=>{v&&b(v);},onConvert:()=>{x&&b(x);},onConvertAll:()=>{h&&b(h);},onOpenProperties:()=>m(true),onClose:()=>c(null),deleteEnabled:k.enabled,convertEnabled:E.enabled,convertAllEnabled:C.enabled,deleteDisabledReason:k.reason??void 0,convertDisabledReason:E.reason??void 0,convertAllDisabledReason:C.reason??void 0}:null,w={onClose:()=>m(false),onApply:_=>{b(_),m(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&&T?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:St.chrome},children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:S}),jsxRuntime.jsx(eM,{onOpenProperties:()=>m(true),onClose:()=>r.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Te(t.notePreview,a):jsxRuntime.jsx(Nr,{...a}):null,P&&t?.notesContextMenu!==false?t?.notesContextMenu?Te(t.notesContextMenu,P):jsxRuntime.jsx(Fr,{...P}):null,d&&t?.noteProperties!==false?t?.noteProperties?Te(t.noteProperties,w):jsxRuntime.jsx(As,{...w}):null]}):null}function As(e){let{t}=H(),o=A(),n=kp(),[r,i]=Zt.useState("document"),[a,l]=Zt.useState("decimal"),[s,c]=Zt.useState("continuous"),[d,m]=Zt.useState("pageBottom"),[u,g]=Zt.useState("decimal"),[p,f]=Zt.useState("continuous"),[b,y]=Zt.useState("docEnd");Zt.useEffect(()=>{n&&(l(n.footnote.resolved.numFmt),c(n.footnote.resolved.numRestart),m(n.footnote.resolved.pos),g(n.endnote.resolved.numFmt),f(n.endnote.resolved.numRestart),y(n.endnote.resolved.pos));},[n]);let v=!n?.footnote.sectionAuthored,x=!n?.endnote.sectionAuthored&&n?.endnote.documentAuthored?.pos===void 0;return jsxRuntime.jsx("div",{className:"docx-note-properties",role:"dialog","aria-modal":"true","data-docx-modal":"","aria-label":t("dialogs.footnoteProperties.title"),"data-testid":"docx-notes-properties-dialog",style:{zIndex:St.modal},onClick:e.onClose,onKeyDown:h=>{h.key==="Escape"&&e.onClose();},children:jsxRuntime.jsxs("div",{className:"docx-note-properties__panel",onClick:h=>h.stopPropagation(),onMouseDown:h=>h.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:h=>i(h.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")}),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:a,onChange:h=>l(h.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:h=>c(h.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:h=>m(h.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")}),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:u,onChange:h=>g(h.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:h=>f(h.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:h=>y(h.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 h={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(h).ok&&e.onApply(h);},children:t("common.apply")})]})]})})}var C0=e=>e.image;function v0(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===editor.hostDocumentOf(e).activeElement)}function lM(){let e=Ut(),[t,o]=Zt.useState(false);return {ref:Zt.useCallback(r=>{r&&o(!r.parentElement?.closest(e?".docx-editor.dark":".docx-editor"));},[e]),className:t?`docx-editor ${e?"dark ":""}`:""}}function sM(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Fp(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(gn(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(gn(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(gn(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(gn(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function cM(e,t){let o=Fp(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function Os(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=ai(t);return Number.isInteger(o)?o:null}function dM(e,t){let o=Fp(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,m=c?Os(e.horizontalPoints):t.position?.horizontalEmu,u=d?Os(e.verticalPoints):t.position?.verticalEmu;return c&&m===null?{ok:false}:d&&u===null?{ok:false}:m===void 0||u===void 0?{ok:false}:{ok:true,value:{horizontalEmu:m,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?Os(e.horizontalPoints):t.position?.horizontalEmu,s=r?Os(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 Bs(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function Ws(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function Ri({open:e,onClose:t,className:o,triggerRef:n}){let r=A(),{t:i}=H(),a=W(C0),l=Zt.useId(),s=Zt.useId(),c=Zt.useId(),d=Zt.useRef(null),m=Zt.useRef(null),u=Zt.useRef(null),g=Zt.useRef(null),[p,f]=Zt.useState(null),[b,y]=Zt.useState(null),v=lM(),x=m.current,h=x?.canCrop===false,k=x?.canResize===false,E=x?.locks.changeAspect===true,C=x?.kind==="anchored"&&x.canMove===true,T=x?.kind==="inline",S=x?.kind==="anchored"&&x.canMove===false;Zt.useEffect(()=>{if(!e){m.current=null,u.current=null,g.current=null;return}if(!a)return;if(m.current=a,r?.surface){let{anchor:U}=r.surface.state().selection;u.current={paragraphId:U.paragraphId,offset:U.offset},g.current=r.surface.session.packageRevision();}y(null);let D=Fp(a),R=a.crop;f({widthPoints:String(gn(a.widthEmu)),heightPoints:String(gn(a.heightEmu)),cropLeft:String(R.left),cropTop:String(R.top),cropRight:String(R.right),cropBottom:String(R.bottom),title:a.title,description:a.description,hyperlink:a.hyperlink??"",wrap:a.wrap,lockAspect:a.locks.changeAspect,...D});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let P=Zt.useCallback(()=>{n?.current?.focus(),r?.focus();},[r,n]),w=Zt.useCallback(()=>{t(),P();},[t,P]);Zt.useEffect(()=>{if(!e)return;let D=d.current;if(!D)return;let R=v0(D);(R.find(j=>j.id==="image-prop-width"&&!j.hasAttribute("disabled"))??R.find(j=>!j.hasAttribute("disabled"))??D).focus();let V=j=>{if(j.key==="Escape"){j.preventDefault(),w();return}if(j.key!=="Tab")return;let q=v0(D);if(q.length===0)return;let X=editor.hostDocumentOf(D).activeElement,ee=q.findIndex(I=>I===X);if(ee===-1)return;j.preventDefault();let O=j.shiftKey?(ee-1+q.length)%q.length:(ee+1)%q.length;q[O]?.focus();},Y=editor.hostDocumentOf(D);return Y.addEventListener("keydown",V),()=>Y.removeEventListener("keydown",V)},[e,w]);let _=Zt.useMemo(()=>{let D=x??a;return !D||D.widthEmu<=0?1:D.widthEmu/D.heightEmu},[a,x]),L=Zt.useCallback(D=>{f(R=>{if(!R)return R;if(!R.lockAspect)return {...R,widthPoints:D};let U=Ws(D);if(U===null)return {...R,widthPoints:D};let V=Math.round(U/_*100)/100;return {...R,widthPoints:D,heightPoints:String(V)}});},[_]),N=Zt.useCallback(D=>{f(R=>{if(!R)return R;if(!R.lockAspect)return {...R,heightPoints:D};let U=Ws(D);if(U===null)return {...R,heightPoints:D};let V=Math.round(U*_*100)/100;return {...R,widthPoints:String(V),heightPoints:D}});},[_]),B=Zt.useCallback(()=>{let D=m.current;if(!D?.intrinsic)return;let R=D.intrinsic.pixelWidth*72/D.intrinsic.dpiX,U=D.intrinsic.pixelHeight*72/D.intrinsic.dpiY;f(V=>V&&{...V,widthPoints:String(Math.round(R*100)/100),heightPoints:String(Math.round(U*100)/100)});},[a]),F=Zt.useCallback(()=>{let D=m.current,R=u.current,U=g.current;if(!r||!D||!p||!R||U===null)return;let V={type:"setImageProperties",drawingNodeId:D.id,expectedPackageRevision:U,selectionParagraphId:R.paragraphId,selectionOffset:R.offset};if(!k){let O=Ws(p.widthPoints),I=Ws(p.heightPoints);if(O===null||I===null){y("imageProperties.errors.invalidDimensions");return}let ie=ai(O),ge=ai(I);ie!==D.widthEmu&&(V.widthEmu=ie),ge!==D.heightEmu&&(V.heightEmu=ge);}if(D.canCrop&&!h){let O=Bs(p.cropLeft),I=Bs(p.cropTop),ie=Bs(p.cropRight),ge=Bs(p.cropBottom);if(O===null||I===null||ie===null||ge===null){y("imageProperties.errors.invalidCrop");return}let K=D.crop;(O!==K.left||I!==K.top||ie!==K.right||ge!==K.bottom)&&(V.crop={left:O,top:I,right:ie,bottom:ge});}p.title!==D.title&&(V.title=p.title),p.description!==D.description&&(V.description=p.description);let Y=p.hyperlink.trim();if(Y!==(D.hyperlink??"")&&(V.hyperlink=Y===""?null:Y),D.canChangeWrap&&p.wrap!==D.wrap&&(V.wrap=p.wrap),D.kind==="anchored"&&D.canMove&&cM(p,D)){let O=dM(p,D);if(!O.ok){y("imageProperties.errors.invalidPosition");return}if(!editor.validateDrawingPositionInput(editor.positionInputFromPropertiesCommand(O.value,D))){y("imageProperties.errors.invalidPosition");return}Object.assign(V,O.value);}if(!(V.widthEmu!==void 0||V.heightEmu!==void 0||V.title!==void 0||V.description!==void 0||V.hyperlink!==void 0||V.crop!==void 0||V.wrap!==void 0||V.horizontalEmu!==void 0||V.verticalEmu!==void 0||V.relativeToH!==void 0||V.relativeToV!==void 0)){w();return}if(!r.can(V).ok){y("imageProperties.errors.refused");return}if(!r.exec(V).ok){y("imageProperties.errors.refused");return}w();},[r,p,h,k,w]);return !e||!p?null:jsxRuntime.jsx("div",{ref:v.ref,className:`${v.className}docx-dialog-overlay${o?` ${o}`:""}`,onClick:w,onMouseDown:D=>{D.stopPropagation(),sM(D);},children:jsxRuntime.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","data-docx-modal":"","aria-labelledby":l,className:"docx-dialog docx-image-properties-dialog",onClick:D=>D.stopPropagation(),onMouseDown:D=>D.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:k,onChange:D=>L(D.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:k,onChange:D=>N(D.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:E,onChange:D=>f(R=>R&&{...R,lockAspect:D.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:h||!x?.intrinsic,onClick:B,children:i("imageProperties.resetNaturalSize")})]}),jsxRuntime.jsxs("section",{className:"docx-dialog__section",children:[jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.position")}),T?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:D=>f(R=>R&&{...R,relativeToH:D.target.value}),children:editor.DRAWING_REL_FROM_H.map(D=>jsxRuntime.jsx("option",{value:D,children:i(`dialogs.imagePosition.relativeOptions.${D}`)},D))})]}),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:D=>f(R=>R&&{...R,relativeToV:D.target.value}),children:editor.DRAWING_REL_FROM_V.map(D=>jsxRuntime.jsx("option",{value:D,children:i(`dialogs.imagePosition.relativeOptions.${D}`)},D))})]})]}):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:D=>f(R=>R&&{...R,horizontalPoints:D.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:D=>f(R=>R&&{...R,verticalPoints:D.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:D=>f(R=>R&&{...R,title:D.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:D=>f(R=>R&&{...R,description:D.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:D=>f(R=>R&&{...R,hyperlink:D.target.value}),placeholder:i("hyperlinkPopup.urlPlaceholder"),dir:"ltr"})]}),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:D=>f(R=>R&&{...R,wrap:D.target.value}),children:editor.IMAGE_WRAP_TARGETS.map(D=>jsxRuntime.jsx("option",{value:D,children:i(`imageWrap.targets.${D}`)},D))})]}),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:D=>f(R=>R&&{...R,cropLeft:D.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:D=>f(R=>R&&{...R,cropTop:D.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:D=>f(R=>R&&{...R,cropRight:D.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:D=>f(R=>R&&{...R,cropBottom:D.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:w,children:i("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:F,children:i("common.apply")})]})]})})}function Ks({className:e,hidden:t,asChild:o,children:n}){let r=Rt(),i=A(),{t:a}=H(),l=W(C0),[s,c]=Zt.useState(false),d=Zt.useRef(null),m={type:"setImageProperties",description:"probe"},u=i&&l?i.can(m):null,g=u?.ok===true,p=u&&!u.ok?u.reason:null,f=bn(o,n);if(t)return null;let b=te("image.properties"),y=a("formattingBar.imagePropertiesShortcut"),v={type:"button",ref:d,className:`${hn(f)}${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!g,...g?{}:{"data-disabled":""},"aria-label":y,title:p??y,onMouseDown:$,onClick:()=>c(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o?jsxRuntime.jsx(Q,{...v,children:n}):jsxRuntime.jsx("button",{...v,children:f?jsxRuntime.jsx(yn,{icon:oe(b?.paths),label:y}):n??oe(b?.paths)}),s&&r?.imageProperties!==false?r?.imageProperties?Te(r.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):jsxRuntime.jsx(Ri,{open:s,onClose:()=>c(false),triggerRef:d}):null]})}Ks.docxSlot="image.properties";var ga=Object.assign(Ks,{docxSlot:"image.properties"});function Mi(e){let t=A(),o=Zt.useCallback(()=>editor.toolbarCommandState(t,e),[t,e]),n=W(o,(r,i)=>r.value===i.value&&r.enabled===i.enabled&&r.disabledReason===i.disabledReason);return Zt.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 qs({className:e,hidden:t,asChild:o,children:n}){let r=Rt(),i=ae(),{execute:a,value:l,isEnabled:s,disabledReason:c}=Mi("image.altText"),[d,m]=Zt.useState(false),[u,g]=Zt.useState(""),p=Zt.useRef(null),f=Zt.useRef(null),b=Zt.useId(),y=bn(o,n);Zt.useEffect(()=>{d&&g(l??"");},[d,l]),Zt.useEffect(()=>{if(!d)return;let C=P=>{let w=p.current;editor.isDomNode(P.target)&&(w?.contains(P.target)||w?.ownerDocument.getElementById(b)?.contains(P.target))||m(false);},T=P=>{P.key==="Escape"&&(P.preventDefault(),m(false),f.current?.focus());},S=editor.hostDocumentOf(p.current);return S.addEventListener("mousedown",C,true),S.addEventListener("keydown",T),()=>{S.removeEventListener("mousedown",C,true),S.removeEventListener("keydown",T);}},[d,b]);let v=Zt.useCallback(()=>{a(u),m(false);},[u,a]);if(t)return null;let x=te("image.altText"),h=i(x?.labelKey??"formattingBar.altText"),k={type:"button",ref:f,className:`${hn(y)} 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:$,onClick:()=>m(C=>!C)},E={id:b,value:u,onValueChange:g,onApply:v,onClose:()=>m(false),isEnabled:s,anchorRef:f};return jsxRuntime.jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsxRuntime.jsx(Q,{...k,children:n}):jsxRuntime.jsx("button",{...k,children:y?jsxRuntime.jsx(yn,{icon:null,label:h}):n??h}),d&&r?.imageAltText!==false?r?.imageAltText?Te(r.imageAltText,E):jsxRuntime.jsx(Us,{...E}):null]})}qs.docxSlot="image.altText";var _i=Object.assign(qs,{docxSlot:"image.altText"});function Us({id:e,value:t,onValueChange:o,onApply:n,onClose:r,isEnabled:i,className:a}){let{t:l}=H();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")})]})]})}function Ap(e){let[t,o]=Zt.useState(e.session),[n,r]=Zt.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(TM,{...e},n)}function TM({session:e,className:t,style:o,children:n}){let r=tt(),[i,a]=Zt.useState(e.signal.aborted),l=Zt.useRef(null);return Zt.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(Fe,{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 w0=Zt.createContext(null),D0=w0.Provider;function ct(){let e=Zt.useContext(w0);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function FM(e){return e.kind==="date"?editor.parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function R0(e){let t=`docx-cc-list-${Zt.useId()}`,[o,n]=Zt.useState(()=>FM(e)),[r,i]=Zt.useState(()=>editor.calendarDateText(e.value,e.locale)),a=Zt.useMemo(()=>editor.createContentControlListNavigation(e.locale),[e]),[l,s]=Zt.useState(false),c=Zt.useCallback(w=>{i(w),s(false);},[]),d=W(()=>e.canApply()),m=e.kind==="date"?editor.parseIsoDate(e.value):null,[u,g]=Zt.useState(()=>{let w=m??new Date;return {year:w.getFullYear(),month:w.getMonth()}}),p=Zt.useCallback(w=>{let _=e.apply(w??o);return s(!_),_},[e,o]),f=Zt.useCallback(()=>e.cancel(),[e]),b=Zt.useCallback(async w=>{if(!e.replaceImage)return s(true),false;try{let _=w instanceof Uint8Array?w.byteLength:w.size;if(!e.canApply()||_>store.DEFAULT_IMAGE_RESOURCE_LIMITS.maxEncodedBytes)return s(!0),!1;let L=w instanceof Uint8Array?w:new Uint8Array(await w.arrayBuffer()),N=await e.replaceImage(L);return s(!N),N}catch{return s(true),false}},[e]),y=Zt.useMemo(()=>editor.calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),v=Zt.useCallback(()=>{g(w=>editor.shiftMonth(w.year,w.month,-1)),C(null);},[]),x=Zt.useCallback(()=>{g(w=>editor.shiftMonth(w.year,w.month,1)),C(null);},[]),h=Zt.useCallback(w=>p(w),[p]),k=Zt.useCallback(()=>p(editor.isoDateOf(new Date)),[p]),[E,C]=Zt.useState(null),T=Zt.useCallback(w=>{let _=editor.parseIsoDate(w);_&&(g({year:_.getFullYear(),month:_.getMonth()}),C(editor.isoDateOf(_)));},[]),S=Zt.useCallback(()=>{let w=editor.calendarDateFromText(r,e.locale);return w?p(w):(s(true),false)},[r,e.locale,p]),P=Zt.useCallback((w,_)=>{!Number.isInteger(w)||w<100||w>9999||!Number.isInteger(_)||_<0||_>11||(g({year:w,month:_}),C(null));},[]);return Zt.useMemo(()=>({session:e,kind:e.kind,items:e.items,value:o,setValue:n,isEnabled:d,refused:l,apply:p,cancel:f,calendar:y,previousMonth:v,nextMonth:x,selectDay:h,selectToday:k,focusIso:E,focusDay:T,dateText:r,setDateText:c,applyDateText:S,showMonth:P,listNavigation:a,listId:t,accept:editor.CONTENT_CONTROL_PICTURE_ACCEPT,replaceImage:b}),[e,b,o,d,l,p,f,y,v,x,h,k,E,T,r,c,S,P,a,t])}function ot(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":m,...u}=t,g=r===void 0?n:r,{key:p,...f}=o,b={...c!==void 0?{id:c}:{},...d!==void 0?{title:d}:{},...m!==void 0?{"aria-label":m}:{}};if(i){let{className:v,style:x,...h}=f;return jsxRuntime.jsx(Q,{...u,...h,...b,...a?{className:a}:{},style:{...x,...l},children:g},p)}return jsxRuntime.jsx(e,{...u,...f,...b,className:[o.className,a].filter(Boolean).join(" "),style:{...o.style,...l},children:g},p)}var sr=e=>e.stopPropagation();function Zp(e){return ot("div",e,{className:"docx-content-control-calendar-header","data-docx-part":"header"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Kp,{}),jsxRuntime.jsx(Jp,{}),jsxRuntime.jsx(qp,{}),jsxRuntime.jsx(Up,{className:"docx-content-control-calendar-announcement"})]}))}function Kp(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"previousMonth","aria-label":o("contentControl.calendar.previousMonth"),onMouseDown:sr,onClick:t.previousMonth},"\u2039")}function qp(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"nextMonth","aria-label":o("contentControl.calendar.nextMonth"),onMouseDown:sr,onClick:t.nextMonth},"\u203A")}function Up(e){let t=ct();return ot("div",e,{className:"docx-content-control-calendar-title","data-docx-part":"title","aria-live":"polite"},t.calendar.title)}function $p(e){let t=ct();return ot("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 zp({day:e,...t}){let o=ct(),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 ot("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:sr,onClick:()=>o.selectDay(e.iso),onKeyDown:r},String(e.day))}function Vp(e){let t=ct(),o=Zt.useRef(null);return Zt.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]),ot("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(zp,{day:i},i.iso))},r)))}function Gp(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-content-control-calendar-today","data-docx-part":"today",disabled:!t.isEnabled,onMouseDown:sr,onClick:t.selectToday},o("contentControl.calendar.today"))}function jp(e){return ot("div",e,{className:"docx-content-control-calendar","data-docx-part":"calendar"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Zp,{}),jsxRuntime.jsx($p,{}),jsxRuntime.jsx(Vp,{}),jsxRuntime.jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsxRuntime.jsx(Gp,{}),jsxRuntime.jsx(zs,{})]}),jsxRuntime.jsx(ba,{}),jsxRuntime.jsx(Gs,{})]}))}function Yp({item:e,...t}){let o=ct();return ot("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:sr,onClick:()=>o.apply(e.value)},e.displayText)}function $s(e){let t=ct(),o=tt();return ot("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(Yp,{item:n},r)))}function zs(e){let t=ct(),o=tt();return ot("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:sr,onChange:n=>(t.kind==="date"?t.setDateText:t.setValue)(n.target.value)},void 0)}function ba(e){let t=ct(),o=tt();return t.refused?ot("div",e,{className:"docx-content-control-widget-error","data-docx-part":"error",role:"alert"},o("disabledReason.invalidValue")):null}function Xp(e){let t=ct(),o=tt();return ot("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 Vs(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t.cancel},o("common.cancel"))}function Gs(e){return ot("div",e,{className:"docx-dialog__footer","data-docx-part":"footer"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Vs,{}),jsxRuntime.jsx(Xp,{})]}))}function Jp(e){return ot("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Qp,{}),jsxRuntime.jsx(em,{})]}))}function Qp(e){let t=ct(),o=tt();return ot("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 em(e){let t=ct(),o=tt();return ot("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 tm({autoOpen:e,...t}){let o=ct(),n=tt(),r=Zt.useRef(null),i=Zt.useRef(false);return Zt.useLayoutEffect(()=>{e!==false&&!i.current&&(i.current=true,r.current?.click());},[e]),ot("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:sr,onCancel:o.cancel,onChange:a=>{let l=a.target.files?.[0];a.target.value="",l&&o.replaceImage(l);}},void 0)}function qM(e){let[t,o]=Zt.useState(e.session),[n,r]=Zt.useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsxRuntime.jsx(UM,{...e},n)}function UM({session:e,className:t,style:o,children:n}){let r=tt(),i=R0(e),[a,l]=Zt.useState(e.signal.aborted),s=Zt.useRef(null),[c]=Zt.useState(()=>editor.contentControlPopupOpener(e.anchor)),d=e.kind==="checkbox"&&n===void 0;if(Zt.useEffect(()=>{let u=()=>l(true);return e.signal.addEventListener("abort",u,{once:true}),e.signal.aborted&&u(),()=>e.signal.removeEventListener("abort",u)},[e]),Zt.useEffect(()=>{!d||e.signal.aborted||e.apply(e.value==="true"?"false":"true");},[d,e]),Zt.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 f=g?.activeElement;c?.isConnected&&(f===g?.body||f&&u?.contains(f))&&c.focus({preventScroll:true});}},[e,a,d,c]),Zt.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 m=r(`contentControl.types.${e.kind}`);return jsxRuntime.jsx(D0,{value:i,children:jsxRuntime.jsx("div",{ref:s,role:"dialog","aria-label":m,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??$M(i)})})}function $M(e){return e.kind==="date"?jsxRuntime.jsx(jp,{}):e.kind==="picture"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(tm,{}),jsxRuntime.jsx(ba,{}),jsxRuntime.jsx(Vs,{})]}):e.kind==="comboBox"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(zs,{}),jsxRuntime.jsx($s,{}),jsxRuntime.jsx(ba,{}),jsxRuntime.jsx(Gs,{})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx($s,{}),jsxRuntime.jsx(ba,{})]})}var am=Object.assign(qM,{Navigation:Jp,Month:Qp,Year:em,Calendar:jp,Header:Zp,PreviousMonth:Kp,Title:Up,NextMonth:qp,Weekdays:$p,Grid:Vp,Day:zp,Today:Gp,List:$s,Item:Yp,Input:zs,Picture:tm,Error:ba,Footer:Gs,Apply:Xp,Cancel:Vs});function lm(e){return e==="checkbox"?"contentControlCheckbox":e==="picture"?"contentControlPicture":"contentControlWidget"}function I0(){let e=A(),t=Rt(),o=Zt.useRef(t);o.current=t;let[n,r]=Zt.useState(null),[i,a]=Zt.useState(null),l=t?.contentControlWidget!==void 0,s=t?.contentControlCheckbox!==void 0,c=t?.contentControlPicture!==void 0,d=t?.invalidTextFormField!==void 0;Zt.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(f){if(o.current?.[lm(f.kind)]===false)return f.cancel();r(f),f.signal.addEventListener("abort",()=>{u&&r(b=>b===f?null:b);},{once:true});}},{fallback:true});return ()=>{u=false,p(),r(null);}},[e,l,s,c]),Zt.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(f=>f===p?null:f);},{once:true});}},{fallback:true});return ()=>{u=false,g(),a(null);}},[e,d]),Zt.useEffect(()=>{n&&t?.[lm(n.kind)]===false&&n.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,n,i]);let m=n?t?.[lm(n.kind)]:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&m&&Te(m,{session:n},n),i&&t?.invalidTextFormField&&Te(t.invalidTextFormField,{session:i},i)]})}var c1=["nw","n","ne","e","se","s","sw","w"],A0=40,O0=12;function d1(e){return `imageOverlay.handle.${e}`}function u1(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 p1(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 m1(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 cm({containerRef:e,portalRef:t,scrollPort:o}){let n=A(),{t:r}=H(),[i,a]=Zt.useState(null),[l,s]=Zt.useState(null),[c,d]=Zt.useState({left:0,top:0}),m=Zt.useRef(null);m.current=l;let u=Zt.useRef(null),g=Zt.useRef(null),p=Zt.useRef(null),f=Zt.useRef(null),b=Zt.useRef(null);Zt.useEffect(()=>{let T=e.current;if(!T)return;let S=P=>{let w=editor.isElementNode(P.target)?P.target:null;if(w?.closest(".docx-drawing-textbox-content")){f.current=null;return}let _=w?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");f.current=_??null,_&&_===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return T.addEventListener("pointerdown",S,{capture:true}),()=>T.removeEventListener("pointerdown",S,{capture:true})},[e,i?.id]),Zt.useEffect(()=>{if(!n){a(null);return}let T=()=>{a(editor.selectedDrawingOverlayTargetOf(n.surface));},S=()=>{queueMicrotask(T);};T();let P=[n.on("change",S),n.on("selectionChange",T)];return ()=>{for(let w of P)w();}},[n]);let y=Zt.useCallback(()=>{d(T=>{let S=editor.overlayHostOrigin(e.current);return S.left===T.left&&S.top===T.top?T:S});},[e]);Zt.useEffect(()=>{y();let T=t.current,S=editor.hostWindowOf(T).ResizeObserver;if(!T||typeof S!="function")return;let P=new S(y);P.observe(T);let w=e.current;return w&&P.observe(w),()=>P.disconnect()},[e,t,y,i]),Zt.useEffect(()=>{if(o){b.current=o;return}let T=e.current;if(!T||!n?.surface)return;let S=T.closest(".docx-editor__scroll-container");if(!S)return;let P=n.surface.overlayCoordinates();return b.current=editor.createImageOverlayScrollPort(S,P.paintScale),()=>{b.current=null;}},[e,n,o]);let v=Zt.useCallback(()=>{s(null),u.current=null;let T=g.current;if(g.current=null,T)try{T.releasePointerCapture(T._lastPointerId??0);}catch{}},[]),x=Zt.useCallback((T,S,P,w,_,L,N)=>{if(!n?.surface)return;let B=n.surface.activeScope();if(B.kind==="frame"&&!n.surface.selectDrawing(P.id,B.hostParagraphId))return;let F=n.surface.layout(),D=editor.captureImageMutationPreconditions(n);if(D){u.current=Object.freeze({x:w,y:_}),g.current=L,L._lastPointerId=N;try{L.setPointerCapture(N);}catch{}s({session:Object.freeze({drawingNodeId:P.id,startBounds:Object.freeze({x:P.x,y:P.y,width:P.width,height:P.height}),startWidthEmu:P.widthEmu,startHeightEmu:P.heightEmu,startPosition:P.position,anchorFrameOrigin:P.anchorFrameOrigin,transform:P.transform,mode:T,handle:S,preconditions:D,layoutRevision:F.revision,packageRevision:n.surface.session.packageRevision(),kind:P.kind}),bounds:P,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});}},[n]),h=Zt.useCallback((T,S,P,w,_)=>{if(!n)return;if(editor.isStaleImageInteractionCommit(n,T)){v();return}T.mode==="resize"?n.exec({type:"setImageProperties",widthEmu:S,heightEmu:P,..._?.mode==="simple"?{horizontalEmu:_.horizontalEmu,verticalEmu:_.verticalEmu}:{},..._?.mode==="frame"?{..._.horizontalEmu!==void 0?{horizontalEmu:_.horizontalEmu}:{},..._.verticalEmu!==void 0?{verticalEmu:_.verticalEmu}:{}}:{}}):T.mode==="move"&&_&&n.exec({type:"setImagePosition",..._}),v();},[v,n]),k=Zt.useCallback(T=>{if(!n)return;let S=m.current?.bounds??editor.selectedDrawingOverlayTargetOf(n.surface);if(!S)return;if(m.current&&T.key==="Escape"){T.preventDefault(),T.stopPropagation(),v();return}if(m.current)return;let P=editor.historyShortcutOf(T);if(P){T.preventDefault(),T.stopPropagation(),n.exec({type:P});return}let w=T.shiftKey?editor.IMAGE_OVERLAY_NUDGE_SHIFT_PT:editor.IMAGE_OVERLAY_NUDGE_PT;if(T.key==="Delete"||T.key==="Backspace"){T.preventDefault(),T.stopPropagation(),n.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(T.key))return;T.preventDefault(),T.stopPropagation();let _=T.key==="ArrowLeft"?-w:T.key==="ArrowRight"?w:0,L=T.key==="ArrowUp"?-w:T.key==="ArrowDown"?w:0;if(T.altKey){if(!S.canResize)return;let B=m1(_,L),F=editor.computeImageResizeResult({handle:B,startWidthEmu:S.widthEmu,startHeightEmu:S.heightEmu,startBounds:{x:S.x,y:S.y,width:S.width,height:S.height},startPosition:S.position,anchorFrameOrigin:S.anchorFrameOrigin,deltaXPt:_,deltaYPt:L,transform:S.transform,preserveAspect:editor.resizePreservesAspect(B,S.aspectLocked,T.shiftKey,S.textbox),kind:S.kind});n.exec({type:"setImageProperties",widthEmu:F.widthEmu,heightEmu:F.heightEmu,...F.position?.mode==="simple"?{horizontalEmu:F.position.horizontalEmu,verticalEmu:F.position.verticalEmu}:{},...F.position?.mode==="frame"?{...F.position.horizontalEmu!==void 0?{horizontalEmu:F.position.horizontalEmu}:{},...F.position.verticalEmu!==void 0?{verticalEmu:F.position.verticalEmu}:{}}:{}});return}if(S.kind!=="anchored"||!S.canMove||!S.position)return;let N=editor.computeMovedImagePosition(S.position,_,L);n.exec({type:"setImagePosition",...N});},[v,n]);Zt.useEffect(()=>{if(!l||!n?.surface)return;let T=n.surface.overlayCoordinates(),S=_=>{let L=m.current,N=u.current;if(!L||!N)return;let B=editor.cssPixelsToLayoutPoints(_.clientX-N.x,T.paintScale),F=editor.cssPixelsToLayoutPoints(_.clientY-N.y,T.paintScale);if(L.session.mode==="move"){let R=0,U=b.current,V=e.current?.closest(".docx-editor__scroll-container");if(U&&V){let j=V.getBoundingClientRect();_.clientY>j.bottom-A0?R=O0:_.clientY<j.top+A0&&(R=-O0),R!==0&&(R=U.scrollBy(R));}let Y=L.accumulatedScrollPt+R;s({...L,accumulatedScrollPt:Y,bounds:Object.freeze({...L.bounds,x:L.session.startBounds.x+B,y:L.session.startBounds.y+F+Y})});return}if(!L.session.handle)return;let D=editor.computeImageResizeResult({handle:L.session.handle,startWidthEmu:L.session.startWidthEmu,startHeightEmu:L.session.startHeightEmu,startBounds:L.session.startBounds,startPosition:L.session.startPosition,anchorFrameOrigin:L.session.anchorFrameOrigin,deltaXPt:B,deltaYPt:F,transform:L.session.transform,preserveAspect:editor.resizePreservesAspect(L.session.handle,L.bounds.aspectLocked,_.shiftKey,L.bounds.textbox),kind:L.session.kind});s({...L,bounds:Object.freeze({...L.bounds,x:D.previewBounds.x,y:D.previewBounds.y,width:D.previewBounds.width,height:D.previewBounds.height,widthEmu:D.widthEmu,heightEmu:D.heightEmu})});},P=_=>{let L=m.current;if(L)if(_.type==="pointerup"){let N=editor.cssPixelsToLayoutPoints(_.clientX-(u.current?.x??_.clientX),T.paintScale),B=editor.cssPixelsToLayoutPoints(_.clientY-(u.current?.y??_.clientY),T.paintScale),F=editor.finalizeImageOverlayInteraction({session:L.session,deltaXPt:N,deltaYPt:B,accumulatedScrollPt:L.accumulatedScrollPt,aspectLocked:L.bounds.aspectLocked,textbox:L.bounds.textbox,shiftKey:_.shiftKey,anchorFrameOrigin:L.session.anchorFrameOrigin});h(L.session,F.widthEmu,F.heightEmu,F.previewBounds,F.position);}else v();},w=editor.hostWindowOf(e.current);return w.addEventListener("pointermove",S),w.addEventListener("pointerup",P),w.addEventListener("pointercancel",P),()=>{w.removeEventListener("pointermove",S),w.removeEventListener("pointerup",P),w.removeEventListener("pointercancel",P);}},[v,h,e,n,l]),Zt.useEffect(()=>{!i||f.current!==i.id||(f.current=null,p.current?.focus({preventScroll:true}));},[i]);let E=l?.bounds??i,C=Zt.useMemo(()=>{if(!n?.surface||!E)return null;let T=n.surface.publishedLayout(),S=n.surface.overlayCoordinates(),P=editor.overlayFrameToSheetCssPixels(T,{pageIndex:E.pageIndex,x:E.x,y:E.y,width:E.width,height:E.height},S),w={left:P.left+c.left,top:P.top+c.top,width:P.width,height:P.height},_=E.canResize,L=E.kind==="anchored"&&E.canMove,N=editor.textboxFrameReason(E,n.surface.editingMode()),B=N?r(N):void 0;return jsxRuntime.jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":E.id,tabIndex:0,onKeyDown:k,children:[jsxRuntime.jsx("div",{className:`docx-image-selection-overlay__frame${L?" docx-editor-one-surface__overlay-control":""}`,"data-textbox":E.textbox?"true":void 0,title:B,"aria-description":B,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:L?"move":"default"},onPointerDown:F=>{$(F),!(!L||!E.position)&&F.button===0&&(F.preventDefault(),F.stopPropagation(),x("move",null,E,F.clientX,F.clientY,F.currentTarget,F.pointerId));}}),_?c1.map(F=>{let D=p1(F);return jsxRuntime.jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(d1(F)),tabIndex:0,style:{left:`calc(${w.left}px + ${w.width}px * ${parseFloat(D.x)/100} - 5px)`,top:`calc(${w.top}px + ${w.height}px * ${parseFloat(D.y)/100} - 5px)`,cursor:u1(F)},onPointerDown:R=>{$(R),R.button===0&&(R.preventDefault(),R.stopPropagation(),x("resize",F,E,R.clientX,R.clientY,R.currentTarget,R.pointerId));}},F)}):null]})},[E,x,n,k,c.left,c.top,r]);return !C||!t.current?null:reactDom.createPortal(C,t.current)}function dm(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Qs({className:e}){let t=A(),o=si(),n=Zt.useRef(null),r=Zt.useContext(Rr),i=Zt.useCallback(d=>{n.current=d,r?.setContainer(d);},[r]),a=Zt.useRef(null);Zt.useLayoutEffect(()=>{let d=n.current;if(!(!t||!d)){try{t.attach(d);}catch(m){if(t.snapshot().openFailure?.code!=="open.failed")throw m;console.error("[docx-editor] The document failed to open.",m);}return ()=>{t.detach();}}},[t]);let l=Zt.useCallback(d=>{if(!o?.isEnabled)return;let m=d.clipboardData;m&&dm(m)&&(editor.clipboardPasteLandsContent(m)||(d.preventDefault(),o.insertFromDataTransfer(m)));},[o]),s=Zt.useCallback(d=>{!o?.isEnabled||!dm(d.dataTransfer)||d.preventDefault();},[o]),c=Zt.useCallback(d=>{if(o?.isEnabled&&dm(d.dataTransfer)){if(editor.clipboardDropLandsText(d.dataTransfer)){if((editor.isElementNode(d.target)?d.target:null)?.closest("[contenteditable]")?.getAttribute("contenteditable")==="true")return;d.preventDefault();return}d.preventDefault(),o.insertFromDataTransfer(d.dataTransfer);}},[o]);return jsxRuntime.jsxs("div",{ref:a,className:"docx-content-mount",children:[jsxRuntime.jsx("div",{ref:i,className:`docx-paginated-surface${e?` ${e}`:""}`,onPaste:l,onDragOver:s,onDrop:c}),jsxRuntime.jsx(Vh,{}),jsxRuntime.jsx(u0,{}),jsxRuntime.jsx(I0,{}),t?jsxRuntime.jsx(cm,{containerRef:n,portalRef:a}):null]})}function pm({open:e,onClose:t,children:o,url:n,name:r,features:i,title:a,styles:l}){let[s,c]=Zt.useState(null),{dir:d}=H(),m=Ut(),u=Zt.useRef(t);u.current=t;let g=Zt.useRef({url:n,name:r,features:i,title:a,styles:l});g.current={url:n,name:r,features:i,title:a,styles:l};let p=Zt.useRef(null);return Zt.useEffect(()=>{if(!e)return;let f=p.current;if(f)f.claimed=true;else {let{url:x,name:h,features:k,title:E,styles:C}=g.current;f={claimed:true,promise:editor.openEditorWindow({...x!==void 0?{url:x}:{},...h!==void 0?{name:h}:{},...k!==void 0?{features:k}:{},...E!==void 0?{title:E}:{},...C!==void 0?{styles:C}:{}})},p.current=f;}let b=f,y=true,v;return b.promise.then(x=>{if(y){if(!x){p.current=null,u.current?.();return}v=x.onClose(()=>{y&&(p.current=null,reactDom.flushSync(()=>c(null)),u.current?.());}),c(x);}}),()=>{y=false,v?.(),b.claimed=false,c(null),queueMicrotask(()=>{b.claimed||(p.current===b&&(p.current=null),b.promise.then(x=>x?.close()));});}},[e]),!s||!e?jsxRuntime.jsx(jsxRuntime.Fragment,{children:o}):reactDom.createPortal(jsxRuntime.jsx("div",{className:`docx-editor${m?" dark":""}`,style:{height:"100%"},dir:d,children:o}),s.element)}function $e(e){return e/1440*96}function ec(e){return e/96*1440}function _t(e){return `${Math.round(e*100)/100}px`}function mm(e){return e/2}var N1=e=>e.isLoading||e.isOpening===true,F1=e=>({width:$e(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:$e(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),L1=(e,t)=>e.width===t.width&&e.height===t.height;function fm({className:e}){return jsxRuntime.jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}var K0=false;function q0(){K0||!xt()||(K0=true,console.warn("[docx-editor] loadingIndicator is ignored with chrome={false}, which renders no loading screen. Compose <DocxEditor.Loading overlay indicator={...} /> in a positioned box instead."));}function H1(e){let t=A(),[o,n]=Zt.useState(null);return Zt.useEffect(()=>{if(!(!t||!e))return t.setOpeningIndicatorHost({publish:n}),()=>{t.setOpeningIndicatorHost(null),n(null);}},[t,e]),o}function A1({when:e=false,overlay:t=false,className:o,style:n,indicator:r,children:i}){let a=W(N1),l=W(F1,L1),s=H1(t),c=A(),d=Zt.useRef({visible:false,editor:null}),[,m]=Zt.useReducer(v=>v+1,0),u=d.current.visible&&d.current.editor!==c,g=s===null&&(e||a||u);Zt.useLayoutEffect(()=>{d.current={visible:g,editor:c},u&&m();},[g,c,u]);let{t:p}=H(),f=Ut(),b=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(fm,{}),jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:p("loading.label")})]});if(s)return reactDom.createPortal(b,s);if(!g)return null;let y=`docx-editor${f?" dark":""} docx-editor__loading${t?" docx-editor__loading--overlay":""}${o?` ${o}`:""}`;return jsxRuntime.jsx("div",{className:y,style:n,role:"status","aria-live":"polite",children:i??jsxRuntime.jsx("div",{className:"docx-paginated-surface docx-editor__loading-surface",style:{width:l.width,height:l.height},children:jsxRuntime.jsx("div",{className:"docx-pages",children:jsxRuntime.jsx("div",{className:"docx-page docx-editor__loading-page",children:jsxRuntime.jsx("div",{className:"docx-editor__loading-page-status",children:b})})})})})}var tc=Object.assign(A1,{Spinner:fm});function U0(){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,f)=>(o.get(p[0])??0)-(o.get(f[0])??0));for(let[,{author:p,style:f}]of g)u[p]=f;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,f])=>`${p}\0${JSON.stringify(f)}`).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 m(){!r||s||(s=true,queueMicrotask(()=>{s=false,d();}));}return {registerScheme(u){e.add(u),m();},register(u,g,p){o.has(u)||o.set(u,n++),t.set(u,{author:g,style:p}),m();},unregister(u){(e.delete(u)||t.delete(u))&&m();},connect(u){r=u;let g=a();i=u!==null&&g!==void 0,l=u===null?null:c(g),m();},current:a}}var Hi=Zt.createContext(null);function V0(){let e=Zt.useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function gm(){let e=Zt.useContext(Hi),t=V0();return Zt.useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function bm(e){let{author:t,color:o,background:n,activeBackground:r,spanClassName:i,avatarUrl:a}=e,l=Zt.useContext(Hi),s=V0();return Zt.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}var G0=false;function j0(e,t){e===t||G0||!xt()||(G0=true,console.warn("[docx-editor] fieldResults changed after the editor was created, so the change is ignored. The editor reads fieldResults once; create a new editor to change it."));}var Y0=false,X0=e=>e?.allowFormattingInLockedContent===true;function J0(e,t){X0(e)===X0(t)||Y0||!xt()||(Y0=true,console.warn("[docx-editor] contentLockPolicy changed after the editor was created, so the change is ignored. The editor reads contentLockPolicy once; create a new editor to change it."));}var Q0=false;function ey(e){return e===void 0?"characters":e}function ty(e,t){ey(e)===ey(t)||Q0||!xt()||(Q0=true,console.warn("[docx-editor] lockedControlNavigation changed after the editor was created, so the change is ignored. The editor reads lockedControlNavigation once; create a new editor to change it."));}function V1(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 G1(e){let t=Zt.useRef(e);t.current=e;let[o,n]=Zt.useState(null),{onReady:r,onChange:i,onFontError:a,onRevisionMarkupChange:l,...s}=e,c=Zt.useMemo(()=>({onReady:d=>{n(d),t.current.onReady?.(d);},onChange:d=>t.current.onChange?.(d),onFontError:d=>t.current.onFontError?.(d),onRevisionMarkupChange:d=>t.current.onRevisionMarkupChange?.(d)}),[]);return {DocxEditorRoot:Ai,rootProps:s,rootListeners:c,editorRef:o}}function Ai(e){let{document:t,fonts:o,fontShaping:n,author:r,locale:i,translate:a,mode:l,zoom:s,zoomMode:c,tableInteractionLabel:d,imageDecodePort:m,colorMode:u,children:g}=e,p=Ul(u),{t:f}=H(),b=Zt.useCallback((K,de)=>f(K,de),[f]),y=Zt.useRef(b);y.current=b;let v=Zt.useRef(false),[x,h]=Zt.useState(0),k=Zt.useRef(e);k.current=e;let E=n?.maxFontBytes,[C,T]=Zt.useState(null),S=Zt.useRef(e.fieldResults),P=Zt.useRef(e.contentLockPolicy),w=Zt.useRef(e.lockedControlNavigation),_=Zt.useRef(e.fonts),L=Zt.useRef(null);L.current??=U0();let N=L.current,B=Zt.useRef(null);B.current??=fg();let F=B.current;Zt.useEffect(()=>{let K=k.current,de=K.translate??y.current,ke=N.current();S.current=K.fieldResults,P.current=K.contentLockPolicy,w.current=K.lockedControlNavigation;let Ze=editor.createDocxEditor({unsupportedElementRules:F.current(),...K.document!==void 0?{document:K.document}:{},...K.fonts?{fonts:K.fonts}:{},...K.fontShaping?{fontShaping:K.fontShaping}:{},...K.author!==void 0?{author:K.author}:{},...K.locale!==void 0?{locale:K.locale}:{},translate:de,...K.revisionMarkup!==void 0?{revisionMarkup:K.revisionMarkup}:{},...K.reviewDisplayMode!==void 0?{reviewDisplayMode:K.reviewDisplayMode}:{},...K.fieldResults!==void 0?{fieldResults:K.fieldResults}:{},...K.contentLockPolicy!==void 0?{contentLockPolicy:K.contentLockPolicy}:{},...K.lockedControlNavigation!==void 0?{lockedControlNavigation:K.lockedControlNavigation}:{},...K.mode!==void 0?{mode:K.mode}:{},...ke!==void 0?{revisionStyles:ke}:{},...K.modules!==void 0?{modules:K.modules}:{},...K.zoom!==void 0?{zoom:K.zoom}:{},...K.zoomMode!==void 0?{zoomMode:K.zoomMode}:{},...K.tableInteractionLabel?{tableInteractionLabel:K.tableInteractionLabel}:{},...K.imageDecodePort?{imageDecodePort:K.imageDecodePort}:{},onFontError:Ye=>k.current.onFontError?.(Ye)});_.current=K.fonts;let at=Ze.on("revisionMarkupChange",Ye=>{v.current||(k.current.onRevisionMarkupChange?.(Ye),h(Wn=>Wn+1));}),Ce=Ze.on("change",Ye=>k.current.onChange?.(Ye));return T(Ze),()=>{at(),Ce(),Ze.destroy(),T(Ye=>Ye===Ze?null:Ye);}},[t,E,m,N,F]),Zt.useEffect(()=>{!C||_.current===o||(_.current=o,C.setFonts(o).catch(()=>{}));},[C,o]),Zt.useEffect(()=>{if(!C)return;if(!C.snapshot().isOpening){k.current.onReady?.(C);return}let K=C.on("change",()=>{K(),k.current.onReady?.(C);});return K},[C]);let D=Zt.useRef({editor:null,zoom:void 0,mode:void 0});Zt.useEffect(()=>{if(!C)return;D.current.editor!==C&&(D.current={editor:C,zoom:void 0,mode:void 0});let de=false;s!==void 0&&s!==D.current.zoom&&(D.current.zoom=s,C.setZoom(s),de=true);let ke=D.current.mode,Ze=c!==void 0&&(ke===void 0||!V1(ke,c)),at=c===void 0?null:editor.resolveZoomMode(c),Ce=de&&c!==void 0&&at!==null&&at.type==="fit";(Ze||Ce)&&(D.current.mode=c,C.setZoomMode(c));},[C,s,c]),Zt.useEffect(()=>{if(!C||e.revisionMarkup===void 0)return;let K=editor.resolveRevisionMarkup(e.revisionMarkup);if(JSON.stringify(K)!==JSON.stringify(C.snapshot().revisionMarkup)){v.current=true;try{C.setRevisionMarkup(K);}finally{v.current=false;}}},[C,e.revisionMarkup,x]),Zt.useEffect(()=>{C&&C.setAuthor(r);},[C,r]);let R=Zt.useRef({editor:null,value:void 0});Zt.useEffect(()=>{if(C){if(R.current.editor!==C){R.current={editor:C,value:l};return}R.current.value!==l&&(R.current.value=l,C.setMode(l));}},[C,l]),Zt.useEffect(()=>{C&&C.setTranslate(a??b);},[C,a,b]),Zt.useEffect(()=>{C&&C.setLocale(i);},[C,i]),Zt.useEffect(()=>{C&&j0(S.current,e.fieldResults);},[C,e.fieldResults]),Zt.useEffect(()=>{C&&J0(P.current,e.contentLockPolicy);},[C,e.contentLockPolicy]),Zt.useEffect(()=>{C&&ty(w.current,e.lockedControlNavigation);},[C,e.lockedControlNavigation]),Zt.useEffect(()=>{C&&C.setTableInteractionLabel(d??editor.defaultTableLabel);},[C,d]);let[U,V]=Zt.useState(0),[Y,j]=Zt.useState(0),q=Zt.useRef([]),[X,ee]=Zt.useState(0),O=X>0,I=Zt.useRef(C);I.current=C,Zt.useEffect(()=>{if(!(!C||!O))return C.setCommentDraftChrome({onRequest:()=>q.current.at(-1)?.()})},[C,O]);let ie=Zt.useMemo(()=>({mounted:U,register:()=>(V(K=>K+1),()=>V(K=>Math.max(0,K-1))),gutters:Y,reserveGutter:()=>(j(K=>K+1),()=>j(K=>Math.max(0,K-1))),registerCommentDraft:K=>(q.current.push(K),ee(de=>de+1),()=>{let de=q.current.indexOf(K);de!==-1&&(q.current.splice(de,1),ee(ke=>Math.max(0,ke-1)));}),requestCommentDraft:()=>{let K=I.current;return K!==null&&editor.runToolbarCommand(K,"review.addComment").ok}}),[U,Y]),ge=Zt.useMemo(Lg,[]);return Zt.useEffect(()=>(N.connect(C),()=>N.connect(null)),[N,C]),Zt.useEffect(()=>(F.connect(C),()=>F.connect(null)),[F,C]),jsxRuntime.jsx(qn.Provider,{value:p,children:jsxRuntime.jsx(Rr.Provider,{value:F,children:jsxRuntime.jsx(Kh,{value:a??b,children:jsxRuntime.jsx(At.Provider,{value:ie,children:jsxRuntime.jsx(Bd.Provider,{value:C,children:jsxRuntime.jsx(Yd.Provider,{value:ge,children:jsxRuntime.jsx(Hi.Provider,{value:N,children:jsxRuntime.jsx(j1,{children:jsxRuntime.jsx(Y1,{children:jsxRuntime.jsx(d0,{value:e.popups,children:jsxRuntime.jsx(cs,{children:jsxRuntime.jsx(zh,{popups:e.popups,children:g})})})})})})})})})})})})}function j1({children:e}){let[t,o]=Zt.useState(0),n=Zt.useCallback(()=>(o(i=>i+1),()=>o(i=>i-1)),[]),r=Xl(t>0);return jsxRuntime.jsx(cu.Provider,{value:n,children:jsxRuntime.jsx(Ya.Provider,{value:r,children:e})})}function Y1({children:e}){let t=Ql();return jsxRuntime.jsx(Tu.Provider,{value:t,children:e})}var Oi=316,xa=editor.REVIEW_MARKERS_GUTTER_PX,iy=24,oc={inlineStart:0,inlineEnd:Oi},ny={inlineStart:xa,inlineEnd:xa},a2={inlineStart:0,inlineEnd:0},xm={inlineStart:iy,inlineEnd:Oi};function i2(e){return e.inlineStart===xm.inlineStart&&e.inlineEnd===xm.inlineEnd}function ly(e,t){return i2(e)?Math.max(0,t-(Oi-xa)):t}function nc(){let e=lt(),t=we(),[o,n]=Zt.useState("ltr");return Zt.useLayoutEffect(()=>{let r=t?.parentElement;if(e||!r)return;let i=()=>n(editor.hostDirectionOf(r));return i(),editor.observeHostDirection(r,i)},[e,t]),(e??o)==="rtl"?"left":"right"}function sy(e,t){return t==="left"?{left:e.inlineEnd,right:e.inlineStart}:{left:e.inlineStart,right:e.inlineEnd}}function cy({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:n=0,docked:r=false,scroll:i=false}){if(!e)return ny;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return oc;let a=Number.isFinite(n)&&n>0?n:0;return t-a-o-2*iy>=Oi?oc:i?xm:ny}var l2=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,reviewPaneOpen:e.reviewPaneOpen??true,entitledZoom:editor.reviewPaneEntitledZoom(t,e.zoom,e.reviewPane.overflow),scroll:e.reviewPane.overflow==="scroll"}},s2=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.scroll===t.scroll&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function dy(){let e=we(),[t,o]=Zt.useState(null);return Zt.useEffect(()=>{if(!e){o(null);return}let n=()=>o(e.clientWidth);n();let r=editor.hostWindowOf(e).ResizeObserver;if(typeof r>"u")return;let i=new r(n);return i.observe(e),()=>i.disconnect()},[e]),t}function En(){let e=Zt.useContext(At),{pageSetup:t,reviewPaneOpen:o,entitledZoom:n,scroll:r}=W(l2,s2),i=we(),a=Ag(),l=Zt.useRef(null);t&&(l.current=t.pageWidthTwips);let s=t?.pageWidthTwips??l.current,c=Wl(e),d=Zt.useCallback(f=>c?cy({open:o,viewportWidth:f??0,pageWidthPx:s===null||n===null?0:$e(s)*n,inlineStartReservation:a,docked:n===null,scroll:r}):a2,[c,o,s,n,a,r]),m=()=>d(i?i.clientWidth:null),[u,g]=Zt.useState(()=>({compute:d,viewport:i,gutter:m()})),p=u;return (u.compute!==d||u.viewport!==i)&&(p={compute:d,viewport:i,gutter:m()},g(p)),Zt.useEffect(()=>{let f=i?editor.hostWindowOf(i).ResizeObserver:void 0;if(!i||typeof f>"u")return;let b=()=>g(v=>{let x=d(i.clientWidth);return x===v.gutter?v:{compute:d,viewport:i,gutter:x}}),y=new f(b);return y.observe(i),()=>y.disconnect()},[i,d]),p.gutter}var rc=[.25,.5,.75,1,1.25,1.5,2];function Bi(e,t){return t==="in"?rc.find(n=>n>e+.001)??null:[...rc].reverse().find(n=>n<e-.001)??null}function uy(e,t){return e==="0"?1:e==="+"||e==="="?Bi(t,"in")??t:e==="-"?Bi(t,"out")??t:null}var Cm=Zt.createContext(false);function py(e){let t=Zt.useContext(Cm),[o,n]=Zt.useState(null);return Zt.useLayoutEffect(()=>{let r=t?e?.parentElement??null:null;n(r?{host:r,scoped:r.closest(".docx-editor")!==null}:null);},[t,e]),{inside:t,host:o?.host??null,hostScoped:o?.scoped??false}}var b2=e=>e.reviewPaneOpen??true,h2=e=>e.zoomMode?.type==="fit";function ac({className:e,style:t,children:o}){let{t:n}=H(),r=$t(),i=A(),a=W(b2),l=En(),s=nc(),c=W(h2),d=Zt.useContext(At),m=Wl(d),u=$n(),g=zn(),p=Zt.useRef(null),f=Zt.useCallback(y=>{p.current=y,u?.setViewport(y);},[u]),b=Zt.useCallback(y=>{if(!i||!(y.metaKey||y.ctrlKey)||y.altKey)return;let v=y.target;if(editor.isElementNode(v)&&v.closest('input, textarea, select, [role="dialog"]'))return;let x=uy(y.key,i.getZoom());x!==null&&(y.preventDefault(),i.setZoom(x));},[i]);return jsxRuntime.jsx("div",{ref:f,"data-testid":"docx-editor-scroll",tabIndex:0,role:"region","aria-label":n("editor.documentViewport"),onKeyDownCapture:b,...m?{"data-review-pane":a?"open":"closed"}:{},...s==="left"?{"data-chrome-dir":"rtl"}:{},...m&&s==="left"?{"data-review-side":"left"}:{},...c?{"data-zoom-fit":""}:{},className:`${r}docx-editor-one-surface docx-editor-one-surface__viewport docx-editor__scroll-container${e?` ${e}`:""}`,style:{...t,"--docx-nav-shift":`${g}px`,...m?{"--docx-review-gutter":`${l.inlineEnd}px`,"--docx-review-gutter-start":`${l.inlineStart}px`,"--docx-review-strip":`${2*xa}px`}:{}},children:jsxRuntime.jsx(Wo.Provider,{value:true,children:jsxRuntime.jsx(Cm.Provider,{value:true,children:o})})})}var x2=editor.LOADING_SNAPSHOT;function fy({ref:e,editorRef:t}){Zt.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)??x2}),[t]);}function va(e,t,o,n){let r=we(),i=Zt.useRef({close:o,skip:n,viewport:r});i.current={close:o,skip:n,viewport:r},Zt.useEffect(()=>{let a=t.current;if(!e||!a)return;let l=d=>a.contains(d),s=editor.listenForPopupEscape({popup:a,contains:l,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current.viewport],skip:d=>i.current.skip?.(d)===true,close:d=>i.current.close(d)}),c=editor.listenForPopupFocusLeave({popup:a,contains:l,close:()=>i.current.close(false)});return ()=>{s(),c();}},[e,t]);}var M2=e=>e.editingMode??"editing",Sm='[role="menuitemradio"]:not([disabled])',_2=(e,t)=>e.length===t.length&&e.every((o,n)=>o===t[n]),I2=e=>e.isLoading||e.isOpening===true,Wi=[{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"}],N2=Object.freeze(Wi.map(()=>null));function F2(e){return e?Wi.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):N2}var L2="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function lc({className:e,hidden:t}){let o=A(),n=W(M2),r=W(I2),i=ae(),{t:a}=H(),[l,s]=Zt.useState(false),c=Zt.useRef(null),d=Zt.useRef(null),m=Zt.useRef(null);Zt.useEffect(()=>{if(!l)return;let x=m.current?.querySelectorAll(Sm);(m.current?.querySelector(`${Sm}[aria-checked="true"]`)??x?.[0]??void 0)?.focus();},[l]);let u=Zt.useCallback(x=>{let h=[...m.current?.querySelectorAll(Sm)??[]],k=h.indexOf(editor.hostDocumentOf(m.current).activeElement),E=C=>{x.preventDefault(),h[(C+h.length)%h.length]?.focus();};x.key==="ArrowDown"?E(k+1):x.key==="ArrowUp"?E(k-1):x.key==="Home"?E(0):x.key==="End"&&E(h.length-1);},[]);Zt.useEffect(()=>{if(l)return editor.listenForOutsidePress({popup:c.current,close:()=>s(false)})},[l]),va(l,c,x=>{s(false),x&&d.current?.focus();});let g=Zt.useCallback(x=>{s(false),editor.runToolbarCommand(o,"review.editingMode",x),o?.focus();},[o]),p=editor.toolbarCommandState(o,"review.editingMode"),f=i18n.localizeDisabledReason(p.disabledReason,a),b=W(()=>F2(o),_2),y=Zt.useMemo(()=>Wi.find(x=>x.mode===n)??Wi[0],[n]);if(t)return null;let v=te("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(v?.labelKey??"editingMode.label"),disabled:r||!p.enabled,...f?{title:f}:{},onMouseDown:$,onClick:()=>s(x=>!x),children:[Pm(y.path),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:i(y.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsxRuntime.jsx("div",{ref:m,className:"docx-toolbar__mode-menu",role:"menu","aria-label":i(v?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:Wi.map((x,h)=>{let k=i18n.localizeDisabledReason(b[h]??null,a);return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":x.mode===n,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${x.mode}`,disabled:k!==null,...k?{title:k}:{},onMouseDown:$,onClick:()=>g(x.mode),children:[Pm(x.path),jsxRuntime.jsxs("span",{className:"docx-toolbar__mode-text",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__mode-label",children:i(x.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-hint",children:i(x.hintKey)})]}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:x.mode===n?Pm(L2):null})]},x.mode)})}):null]})}lc.docxSlot="review.editingMode";function Pm(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 yy=[],O2=()=>{};function Zi(){let e=A(),t=Zt.useCallback(o=>{if(!e)return O2;let n=Za(o),r=e.on("change",n),i=e.on("selectionChange",n);return ()=>{r(),i();}},[e]);return Zt.useSyncExternalStore(t,()=>e?.getReviewAuthors()??yy,()=>yy)}var z2=e=>e.hiddenReviewAuthors??[];function cc({className:e,hidden:t,icon:o}){let n=A(),r=Zi(),i=W(z2),a=new Set(i),l=r.every(h=>!a.has(h.author)),[s,c]=Zt.useState(false),d=Zt.useRef(null),m=Zt.useRef(null),u=Zt.useRef(null),g=ae(),{t:p}=H();Zt.useEffect(()=>{if(s)return u.current?.querySelector('[role="menuitemcheckbox"]')?.focus(),editor.listenForOutsidePress({popup:d.current,close:()=>c(false)})},[s]),va(s,d,h=>{c(false),h&&m.current?.focus();});let f=Zt.useCallback(h=>{let k=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],E=k.indexOf(editor.hostDocumentOf(u.current).activeElement),C=T=>{h.preventDefault(),k[(T+k.length)%k.length]?.focus();};h.key==="ArrowDown"?C(E+1):h.key==="ArrowUp"?C(E-1):h.key==="Home"?C(0):h.key==="End"?C(k.length-1):h.key==="Tab"&&c(false);},[]);if(t)return null;let b=te("review.authors"),y=editor.toolbarCommandState(n,"review.authors"),v=i18n.localizeDisabledReason(y.disabledReason,p),x=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:m,type:"button",className:"docx-toolbar__picker","data-testid":"reviewers-trigger","aria-haspopup":"menu","aria-expanded":s,"aria-label":x,disabled:!y.enabled,title:v??x,onMouseDown:$,onClick:()=>c(h=>!h),children:[o??oe(b?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:x}),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":x,"data-testid":"reviewers-menu",onKeyDown:f,children:[jsxRuntime.jsx(xy,{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(h=>jsxRuntime.jsx(xy,{checked:!a.has(h.author),label:h.author||"\u2014",testId:`reviewer-${h.slot}`,color:h.color,onChoose:()=>n?.setReviewAuthorVisible(h.author,a.has(h.author))},h.author))]}):null]})}cc.docxSlot="review.authors";function xy(e){return jsxRuntime.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e.checked,className:"docx-toolbar__reviewer-item","data-testid":e.testId,onMouseDown:$,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 Cy=Zt.createContext(null);function Ty({children:e}){let t=_o(),[o,n]=Zt.useState(false),r=Zt.useRef(null),i=we(),a=Zt.useRef(i);a.current=i;let l=Zt.useMemo(()=>({open:c=>{if(t){t.open("paragraph",c);return}r.current=c??editor.hostDocumentOf(a.current).activeElement,n(true);}}),[t]),s=Zt.useCallback(()=>{n(false);let c=r.current;r.current=null,editor.isHTMLElementNode(c)&&c.isConnected&&c.focus({preventScroll:true});},[]);return jsxRuntime.jsxs(Cy.Provider,{value:l,children:[e,jsxRuntime.jsx(Vo,{open:o,onClose:s})]})}function Ey(){return Zt.useContext(Cy)}var wm=["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"],Dm=Zt.createContext({close:()=>{}});function Ca(){return Zt.useContext(Dm).close}function m_(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function wy({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 Dy({slot:e}){let t=ae(),o=eo(),{close:n}=Zt.useContext(Dm),{execute:r,isActive:i,isEnabled:a,disabledReason:l,value:s}=re(e),c=te(e),d=editor.chromeSlotIsToggle(e),m=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:$,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:m})]})}function Ry({sections:e,className:t}){let o=ae(),[n,r]=Zt.useState(false),i=Zt.useRef(null),a=Zt.useRef(null),l=Zt.useRef(null),s=Zt.useRef(false),c=Zt.useId(),d=we(),m=Zt.useRef(d);m.current=d;let u=o("formattingBar.more"),g=Zt.useCallback(v=>{r(false),v&&a.current?.focus();},[]),p=Zt.useMemo(()=>({close:g}),[g]);Zt.useEffect(()=>{if(!n)return;let v=i.current,x=C=>i.current?.contains(C)===true||l.current?.contains(C)===true,h=v?editor.listenForPopupEscape({popup:v,contains:x,chromeRoot:()=>i.current?.closest(".docx-editor"),editorElements:()=>[m.current],skip:()=>editor.hasOpenNestedPopup(l.current),close:g}):void 0,k=v?editor.listenForPopupFocusLeave({popup:v,contains:x,close:()=>r(false)}):void 0,E=editor.listenForOutsidePress({popup:v,close:()=>r(false)});return ()=>{E(),h?.(),k?.();}},[n,g]);let[f,b]=Zt.useState(null);Zt.useLayoutEffect(()=>{if(!n){b(null);return}let v=()=>{let h=i.current,k=l.current,E=a.current,C=h?.ownerDocument.defaultView;if(!h||!k||!E||!C)return;let T=E.getBoundingClientRect(),S=editor.toolbarPanelPlacement({triggerLeft:T.left,triggerRight:T.right,panelWidth:k.offsetWidth,viewportWidth:C.innerWidth}),P=S.left-h.getBoundingClientRect().left;b(w=>w&&w.left===P&&w.maxWidth===S.maxWidth&&w.anchor===S.anchor?w:{...S,left:P});};v();let x=i.current?.ownerDocument.defaultView;return x?.addEventListener("resize",v),()=>x?.removeEventListener("resize",v)},[n]),Zt.useEffect(()=>{if(!n||!s.current)return;s.current=false;let v=l.current;v&&m_(v);},[n]);let y=v=>{v.key!=="Escape"||v.defaultPrevented||(v.preventDefault(),g(true));};return jsxRuntime.jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[rs]:"",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":u,title:u,...n?{"data-active":""}:{},onMouseDown:$,onClick:()=>r(v=>!v),onKeyDown:v=>{v.key==="ArrowDown"&&(v.preventDefault(),s.current=true,r(true));},children:oe(wm)}),n?jsxRuntime.jsx(Dm.Provider,{value:p,children:jsxRuntime.jsx("div",{ref:l,id:c,role:"dialog","aria-label":u,className:"docx-toolbar__more-panel","data-testid":"toolbar-overflow-panel",...f?{"data-anchor":f.anchor}:{},style:f?{left:f.left,right:"auto",maxInlineSize:f.maxWidth}:void 0,onKeyDown:y,children:e.map(v=>jsxRuntime.jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":v.label??o(v.labelKey),children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:v.label??o(v.labelKey)}),v.children]},v.id))})}):null]})}function g_(e){if(!Zt.isValidElement(e))return false;let t=e.type;return (typeof t=="function"||typeof t=="object")&&t.docxToolbarGroup===true}function _y(e,t,o,n){let r=new Map,i=new Map,a=new Map,l=[];for(let s of Zt.Children.toArray(e)){if(g_(s)){a.delete(s.props.id),a.set(s.props.id,s.props);continue}let c=t(s);if(c&&o(c))r.set(c,s);else if(c&&n(c))i.set(c,s);else {if(c&&Zt.isValidElement(s)&&s.props.hidden===true)continue;l.push(s);}}return {overrides:r,tableOverrides:i,groups:[...a.values()],appended:l}}var uc="review.addComment";function h_({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=Zt.useContext(At),a=ae(),{isEnabled:l,reason:s}=ts(a),c=Ca();if(t||(i?.mounted??0)===0)return null;let d=te(uc),m=a(d?.labelKey??uc),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":uc,disabled:!l,...l?{}:{"data-disabled":""},"aria-label":m,title:s??m,onMouseDown:$,onClick:()=>{i?.requestCommentDraft()&&c(false);}};return n?jsxRuntime.jsx(Q,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??oe(d?.paths)})}var Rm=Object.assign(h_,{docxSlot:uc});var Ny=new Set;function pc(e){!xt()||Ny.has(e)||(Ny.add(e),console.warn(`[docx-editor] ${e}`));}function Fy(e,t,o){pc(`Toolbar.Group "${e}" has after="${t}", but no group has that id. The group is placed after every other group. Known ids: ${o.join(", ")}.`);}function Ly(e,t){pc(`Toolbar.Group "${e}" is a built-in group, so its ${t} is ignored. A built-in group keeps its own label and place in the bar.`);}function Hy(e){pc(`Toolbar.Group "${e}" uses the id of the contextual table group, so it is ignored. Give the group another id.`);}function Ay(e,t){pc(t?`Toolbar slot "${e}" is not part of the preset arrangement, so its content is appended after the groups. Put it in a Toolbar.Group to give it a place.`:`"${e}" is not a toolbar slot id. Its content is appended after the groups. Use a ChromeSlotId such as "text.bold".`);}var _m=[{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 mc({className:e,hidden:t,asChild:o,children:n}){let{t:r}=H(),i=ae(),{execute:a,value:l,isEnabled:s,disabledReason:c}=Mi("image.wrap"),[d,m]=Zt.useState(false),u=Zt.useRef(null),g=Zt.useRef(null),p=Zt.useRef(null),f=Zt.useId(),b=bn(o,n),y=Zt.useMemo(()=>_m.find(C=>C.value===l)??_m[0],[l]),v=te("image.wrap"),x=i(v?.labelKey??"formattingBar.imageWrap");Zt.useEffect(()=>{if(!d)return;let C=P=>{let w=u.current;w&&editor.isDomNode(P.target)&&w.contains(P.target)||m(false);},T=P=>{P.key==="Escape"&&(P.preventDefault(),m(false),g.current?.focus());},S=editor.hostDocumentOf(u.current);return S.addEventListener("mousedown",C,true),S.addEventListener("keydown",T),()=>{S.removeEventListener("mousedown",C,true),S.removeEventListener("keydown",T);}},[d]);let h=Zt.useCallback(C=>{m(false),a(C);},[a]);if(t)return null;let k=r("imageWrap.tooltipPrefix",{label:r(y.labelKey)}),E={type:"button",ref:g,className:`${hn(b)} 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?f:void 0,"aria-label":x,title:c??k,onMouseDown:$,onClick:()=>m(C=>!C)};return jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsxRuntime.jsx(Q,{...E,children:n}):jsxRuntime.jsx("button",{...E,children:b?jsxRuntime.jsx(yn,{icon:oe(v?.paths),label:x}):n??oe(v?.paths)}),d?jsxRuntime.jsx("div",{ref:p,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:C=>C.stopPropagation(),children:_m.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:$,onClick:()=>h(C.value),children:r(C.labelKey)},C.value))}):null]})}mc.docxSlot="image.wrap";var Ui=Object.assign(mc,{docxSlot:"image.wrap"});var Ta="table.insert";function N_({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=A(),{isEnabled:a,disabledReason:l}=re(Ta),s=ae(),[c,d]=Zt.useState(false),m=Zt.useRef(null),u=Zt.useRef(null),g=Zt.useRef(null),p=Zt.useId(),f=Ca();Zt.useEffect(()=>{if(!(!c||!m.current))return editor.listenForOutsidePress({popup:m.current,close:()=>d(false)})},[c]),Zt.useEffect(()=>{c&&m.current?.querySelector('[role="gridcell"][tabindex="0"]')?.focus();},[c]);let b=c&&a;Zt.useLayoutEffect(()=>{let k=g.current,E=m.current,C=E?.ownerDocument.defaultView;if(!b||!k||!E||!C||E.closest(".docx-toolbar__more-panel"))return;let T=E.getBoundingClientRect(),S=editor.toolbarPopupLeft({anchorLeft:T.left,popupWidth:k.offsetWidth,viewportWidth:C.innerWidth});k.style.left=`${S-T.left}px`;},[b]);let y=Zt.useCallback(()=>{d(false),f(false);},[f]);if(t)return null;let v=te(Ta),x=s(v?.labelKey??Ta),h={ref:u,type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Ta,disabled:!a,...a?{}:{"data-disabled":""},...b?{"data-active":""}:{},"aria-haspopup":"grid","aria-expanded":b,"aria-controls":b?p:void 0,"aria-label":x,title:l??x,onMouseDown:$,onClick:()=>{if(!c){d(true);return}d(false),i?.focus();},onKeyDown:k=>{k.key==="ArrowDown"&&(k.preventDefault(),d(true));}};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__table-insert",children:[n?jsxRuntime.jsx(Q,{...h,children:r}):jsxRuntime.jsx("button",{...h,children:o??r??oe(v?.paths)}),b?jsxRuntime.jsx("div",{ref:g,id:p,className:"docx-toolbar__menu docx-toolbar__table-insert-menu",onBlur:k=>{let E=k.relatedTarget;editor.isDomNode(E)&&!m.current?.contains(E)&&d(false);},onKeyDown:k=>{k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),d(false),u.current?.focus());},children:jsxRuntime.jsx(ps,{slot:Ta,label:s("toolbar.insertTable"),onInserted:y})}):null]})}var Nm=Object.assign(N_,{docxSlot:Ta});function nt(e){return Object.assign(o=>jsxRuntime.jsx(Ko,{slotId:e,...o}),{docxSlot:e})}var By=nt("history.undo"),Wy=nt("history.redo"),Zy=nt("text.bold"),Ky=nt("text.italic"),qy=nt("text.underline"),Uy=nt("text.strike"),$y=nt("format.clear"),zy=nt("script.super"),Vy=nt("script.sub"),Gy=nt("alignment.left"),jy=nt("alignment.center"),Yy=nt("alignment.right"),Xy=nt("alignment.justify"),Jy=nt("direction.ltr"),Qy=nt("direction.rtl"),ex=nt("list.bullet"),tx=nt("list.numbered"),ox=nt("list.outdent"),nx=nt("list.indent");var rx=nt("review.comments");function H_({className:e,hidden:t,icon:o,asChild:n,children:r}){let{execute:i,isEnabled:a,disabledReason:l}=re("text.link"),s=ae(),c=eo();if(t)return null;let d=te("text.link"),m=c(s(d?.labelKey??"text.link")),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!a,...a?{}:{"data-disabled":""},"aria-label":m,title:l??m,onMouseDown:$,onClick:()=>i()};return n?jsxRuntime.jsx(Q,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??oe(d?.paths)})}var Fm=Object.assign(H_,{docxSlot:"text.link"});function A_({className:e,hidden:t}){let o=A(),{onSave:n}=Zt.useContext(Vn),r=ae();if(t)return null;let i=te("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:$,onClick:()=>n?.(),children:oe(i?.paths)})}var Lm=Object.assign(A_,{docxSlot:"file.save"});function dr({className:e}){return jsxRuntime.jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}var W_=e=>({zoom:e.zoom,mode:e.zoomMode}),Z_=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,ix={type:"fixed"};function Hm(){let e=A(),{zoom:t,mode:o}=W(W_,Z_),n=Zt.useCallback(i=>{e?.setZoom(i);},[e]),r=Zt.useCallback(i=>{e?.setZoomMode(i);},[e]);return Zt.useMemo(()=>{let i=o??ix,a=Bi(t,"out"),l=Bi(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(ix),n(1);},zoomIn:()=>l!==null&&n(l),zoomOut:()=>a!==null&&n(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:rc}},[e,t,o,n,r])}var Vi=2,Gi=3276,zi=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],$_=e=>e.formatting?.fontSizePt??null;function cx(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function dx(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 mx(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:$,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:$,onClick:e.onIncrease,children:"+"})]})}function z_(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<Vi||n>Gi?null:n}function V_({className:e,hidden:t}){let o=A(),n=W($_),{isEnabled:r,disabledReason:i}=re("font.size"),a=ae(),[l,s]=Zt.useState(false),[c,d]=Zt.useState(null),m=Zt.useRef(null);Zo(m,l,()=>s(false));let u=Zt.useRef(null),g=Zt.useId(),p=Zt.useCallback(E=>{if(!o)return;let C=editor.commandForSlotValue("font.size",E);C&&o.can(C).ok&&o.exec(C);},[o]),f=Zt.useCallback(E=>{p(Math.min(Gi,Math.max(Vi,Math.round(E*2))));},[p]),b=Zt.useCallback(E=>{s(false),d(null),u.current?.blur(),E&&o?.focus();},[o]);if(Zt.useEffect(()=>{if(l)return editor.listenForOutsidePress({popup:m.current,close:()=>{s(false),d(null);}})},[l]),t)return null;let y=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,k=()=>{if(c===null)return;let E=z_(c);E!==null&&p(E);};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsxRuntime.jsx(mx,{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"),"aria-controls":l?g:void 0,autoComplete:"off",onChange:E=>{d(E.target.value),s(true);},onFocus:E=>{E.target.select(),s(true);},onClick:()=>s(true),onKeyDown:E=>{E.key==="Enter"?(E.preventDefault(),k(),b(true)):E.key==="Escape"?(E.preventDefault(),b(true)):(E.key==="ArrowDown"||E.key==="ArrowUp")&&(E.preventDefault(),s(true),n!==null&&f(E.key==="ArrowDown"?dx(n,zi,Vi/2):cx(n,zi,Gi/2)));},onBlur:()=>{k(),d(null);}}),canDecrease:y&&Math.round(n*2)>Vi,canIncrease:y&&Math.round(n*2)<Gi,onDecrease:()=>f(dx(n??0,zi,Vi/2)),onIncrease:()=>f(cx(n??0,zi,Gi/2))}),l&&r?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox",tabIndex:0,"aria-label":a("fontSize.listLabel"),id:g,children:zi.map(E=>{let C=h===E;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>{f(E),b(true);},children:E},E)})}):null]})}var Bm=Object.assign(V_,{docxSlot:"font.size"});function G_({className:e,hidden:t}){let o=A(),{zoom:n,isFit:r,mode:i,setZoom:a,setMode:l,zoomIn:s,zoomOut:c,canZoomIn:d,canZoomOut:m,levels:u}=Hm(),g=ae(),[p,f]=Zt.useState(false),b=Zt.useRef(null);Zo(b,p,()=>f(false)),Zt.useEffect(()=>{if(p)return editor.listenForOutsidePress({popup:b.current,close:()=>f(false)})},[p]);let y=Zt.useCallback(E=>{b.current?.querySelector("[aria-haspopup]")?.focus(),f(false),a(E);},[a]),v=Zt.useCallback(E=>{b.current?.querySelector("[aria-haspopup]")?.focus(),f(false),l(E==="auto"?"auto":editor.FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let x=`${Math.round(n*100)}%`,h=editor.sameZoomMode(i,editor.AUTO_ZOOM_MODE),k=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(mx,{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")}: ${x}`,onMouseDown:$,onClick:()=>f(E=>!E),children:[x,jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:m,canIncrease:d,onDecrease:c,onIncrease:s}),p?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__zoom-menu",role:"listbox",tabIndex:0,"aria-label":g("zoom.zoomLevel"),children:[jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":h,...h?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>v("auto"),children:g("zoom.automatic")}),jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":k,...k?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>v("fit-width"),children:g("zoom.fitWidth")}),jsxRuntime.jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(E=>{let C=!r&&Math.abs(E-n)<.001;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>y(E),children:`${Math.round(E*100)}%`},E)})]}):null]})}var Wm=Object.assign(G_,{docxSlot:"zoom.level"});function ur(e,t,o,n=false){let r=we(),i=Zt.useRef(r);i.current=r,Zt.useEffect(()=>{e&&n&&t(false);},[e,n,t]),Zt.useEffect(()=>{let a=o.current;if(!e||n||!a)return;let l=m=>a.contains(m),s=editor.listenForPopupEscape({popup:a,contains:l,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current],close:m=>{t(false),m&&a.querySelector("[aria-haspopup]")?.focus();}}),c=editor.listenForPopupFocusLeave({popup:a,contains:l,close:()=>t(false)}),d=editor.listenForOutsidePress({popup:a,contains:l,close:()=>t(false)});return ()=>{d(),s(),c();}},[e,n,t,o]);}var hx=10,yx=0,oI=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),nI=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function rI({className:e,hidden:t}){let o=A(),n=W(oI,nI),{isEnabled:r,disabledReason:i}=re("list.lineSpacing"),a=re("paragraph.dialog"),l=Ey(),s=ae(),{lang:c}=H(),[d,m]=Zt.useState(false),u=Zt.useRef(null),g=Zt.useRef(null);ur(d,m,u,t);let p=Zt.useCallback(h=>{m(false),!(!o||!h.command)&&o.can(h.command).ok&&o.exec(h.command);},[o]),f=Zt.useCallback((h,k)=>{if(m(false),!o)return;let E={type:"setParagraphSpacing",[h]:k};o.can(E).ok&&o.exec(E);},[o]);if(t)return null;let b=te("list.lineSpacing"),y=(n.spaceBeforePt??0)>0,v=(n.spaceAfterPt??0)>0,x=editor.lineSpacingMenuRows(n.lineSpacing);return jsxRuntime.jsxs("span",{ref:u,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxRuntime.jsxs("button",{ref:g,type:"button",className:`docx-toolbar__button docx-toolbar__line-spacing-trigger${e?` ${e}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-label":s("lineSpacing.label"),title:i??s("lineSpacing.label"),onMouseDown:$,onClick:()=>m(h=>!h),children:[oe(b?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),d&&r?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[x.map(h=>{let k=h.selected;return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":k,...k?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>p(h),children:[editor.lineSpacingMenuRowLabel(h,s,c),k?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]},`${h.spacing.rule}:${h.spacing.value}`)}),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:$,onClick:()=>{m(false),l?.open(g.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:$,onClick:()=>f("beforePt",y?yx:hx),children:s(y?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>f("afterPt",v?yx:hx),children:s(v?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var Zm=Object.assign(rI,{docxSlot:"list.lineSpacing"});var lI=["alignment.left","alignment.center","alignment.right","alignment.justify"];function sI({className:e,hidden:t}){let o=re("alignment.left"),n=re("alignment.center"),r=re("alignment.right"),i=re("alignment.justify"),a=ae(),[l,s]=Zt.useState(false),c=Zt.useRef(null);if(ur(l,s,c,t),t)return null;let d=[o,n,r,i],m=lI.map((f,b)=>({slot:f,control:te(f),state:d[b]})),u=m.find(f=>f.state.isActive)??m[0],g=m.some(f=>f.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:$,onClick:()=>s(f=>!f),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:m.map(f=>{let b=a(f.control?.labelKey??f.slot);return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__button docx-toolbar__alignment-option","data-slot":f.slot,disabled:!f.state.isEnabled,...f.state.isActive?{"data-active":""}:{},"aria-pressed":f.state.isActive,"aria-label":b,title:f.state.disabledReason??b,onMouseDown:$,onClick:()=>{f.state.execute(),s(false);},children:oe(f.control?.paths)},f.slot)})}):null]})}var bc=Object.assign(sI,{docxSlot:"alignment"});function qm(e){let{label:t,icon:o,active:n,disabled:r,disabledReason:i,onSelect:a,asChild:l,className:s,children:c}=e,d=ss(),m=Ca();if(d==="panel"&&!l)return jsxRuntime.jsxs("button",{type:"button",className:`docx-toolbar__more-command${s?` ${s}`:""}`,disabled:r,...n?{"data-active":""}:{},...n!==void 0?{"aria-pressed":n}:{},...r&&i?{title:i}:{},onMouseDown:g=>$(g),onClick:g=>{a?.(),m(g.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:o??c}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:t})]});let u={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:g=>$(g),onClick:r?void 0:a};return l?jsxRuntime.jsx(Q,{...u,children:c}):jsxRuntime.jsx("button",{...u,children:o??c})}var bI=Object.freeze([]),hI=e=>e.formatting?.fontFamily??null,yI=e=>e;function xc(){let e=A(),t=W(hI),o=W(yI),n=Zt.useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():bI,[e,o]),{isEnabled:r}=re("font.family"),i=Zt.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return Zt.useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var Tx=Zt.createContext(null);function $m(){return Zt.useContext(Tx)}function zm({asChild:e,className:t,children:o}){let n=$m(),r=ae();if(!n)return null;let i=r(te("font.family")?.labelKey??"font.family"),a={onClick:()=>n.setOpen(!n.open),onMouseDown:$,disabled:!n.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,"aria-label":o!==void 0?void 0:`${i}: ${n.value??"\u2014"}`,title:i},l=o??jsxRuntime.jsx("span",{children:n.value??"\u2014"});return e?jsxRuntime.jsx(Q,{...a,children:l}):jsxRuntime.jsx("button",{type:"button",...a,children:l})}zm.docxToolbarPart=true;var xI=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"]]),vI=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function Ex({asChild:e,className:t,children:o}){let n=$m(),r=ae(),[i,a]=Zt.useState("");if(Zt.useEffect(()=>{n?.open||a("");},[n?.open]),!n||!n.open)return null;let l={role:"listbox",tabIndex:0,"aria-label":r("font.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`},s;return o!==void 0?s=o:s=vI.map(d=>({...d,fonts:n.options.filter(m=>m.toLowerCase().includes(i.toLowerCase())&&(xI.get(m.toLowerCase())??"other")===d.category)})).filter(d=>d.fonts.length>0).map((d,m)=>jsxRuntime.jsxs("div",{role:"group",children:[m>0?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator","aria-hidden":"true"}):null,d.labelKey?jsxRuntime.jsx("div",{className:"docx-toolbar__menu-label",children:r(d.labelKey)}):null,d.fonts.map(u=>jsxRuntime.jsx(Sx,{value:u},u))]},d.category)),e?jsxRuntime.jsx(Q,{...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",tabIndex:0,"aria-label":r("font.selectAriaLabel"),className:"docx-toolbar__font-options",children:s})]})}function Sx({value:e,asChild:t,className:o,children:n}){let r=A(),i=$m();if(!i)return null;let a=i.value===e,l={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:$,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(Q,{...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 CI({hidden:e,asChild:t,className:o,children:n}){let r=xc(),[i,a]=Zt.useState(false),l=Zt.useRef(null);Zo(l,i,()=>a(false)),Zt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=Zt.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(zm,{}),jsxRuntime.jsx(Ex,{})]});return jsxRuntime.jsx(Tx.Provider,{value:s,children:t?jsxRuntime.jsx(Q,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Vm=Object.assign(CI,{docxSlot:"font.family",Trigger:zm,Content:Ex,Item:Sx});var EI={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},SI=new Set(["Title","Heading1","Heading2","Heading3"]),PI={Subtitle:"666666"},kI="#4a6c8c";function Px(e){let t=EI[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??SI.has(e.styleId))&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic");let r=e.color??PI[e.styleId];return r?n.color=`#${r}`:e.styleId.startsWith("Heading")&&(n.color=kI),n}var kx=/^heading ([1-9])$/;function Gm(e,t){let o=e||t,n=kx.exec(o);return n?`Heading ${n[1]}`:o}var wI=new Map([["normal","styles.normal"],["title","styles.title"],["subtitle","styles.subtitle"],["no spacing","styles.noSpacing"],["quote","styles.quote"],["intense quote","styles.intenseQuote"],["list paragraph","styles.listParagraph"]]);function vc(e){let t=e.toLowerCase(),o=wI.get(t);if(o)return {key:o};let n=kx.exec(t);return n?{key:"styles.headingLevel",vars:{level:Number(n[1])}}:null}function wx(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:Gm(t.name,t.styleId),priority:99}))}function HI(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 AI=Object.freeze([]),OI=e=>e.formatting?.styleId??null,BI=e=>e;function Cc(){let e=A(),t=W(OI),o=W(BI),{t:n}=H(),r=Zt.useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(l=>l.type==="paragraph").map(l=>{let s=vc(l.name);return {styleId:l.styleId,name:s?n(s.key,s.vars):Gm(l.name,l.styleId),preview:l.preview}}):AI,[e,o,n]),{isEnabled:i}=re("styles.style"),a=Zt.useCallback(l=>{if(!e)return;let s=editor.commandForSlotValue("styles.style",l);s&&e.can(s).ok&&e.exec(s);},[e]);return Zt.useMemo(()=>({value:t,setValue:a,options:r,isEnabled:i}),[t,a,r,i])}var Dx=Zt.createContext(null);function Ym(){return Zt.useContext(Dx)}function Xm({asChild:e,className:t,children:o}){let n=Ym(),r=ae();if(!n)return null;let i=te("styles.style"),a=r(i?.labelKey??"styles.style"),l={onClick:()=>n.setOpen(!n.open),onMouseDown:$,disabled:!n.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,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(Q,{...l,children:c}):jsxRuntime.jsx("button",{type:"button",...l,children:c})}Xm.docxToolbarPart=true;function Rx({asChild:e,className:t,children:o}){let n=ae(),r=Ym();if(!r||!r.open)return null;let i={role:"listbox",tabIndex:0,"aria-label":n("styles.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`},a=o??r.options.map(l=>jsxRuntime.jsx(Mx,{value:l.styleId},l.styleId));return e?jsxRuntime.jsx(Q,{...i,children:a}):jsxRuntime.jsx("div",{...i,children:a})}function Mx({value:e,asChild:t,className:o,children:n}){let r=A(),i=Ym();if(!i)return null;let a=i.value===e,l=i.options.find(d=>d.styleId===e),s={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:$,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__style-item${o?` ${o}`:""}`},c=n??jsxRuntime.jsx("span",{style:l?HI(l.preview):void 0,children:l?.name??e});return t?jsxRuntime.jsx(Q,{...s,children:c}):jsxRuntime.jsxs("button",{type:"button",...s,children:[c,a?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function WI({hidden:e,asChild:t,className:o,children:n}){let r=Cc(),[i,a]=Zt.useState(false),l=Zt.useRef(null);Zo(l,i,()=>a(false)),Zt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=Zt.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(Xm,{}),jsxRuntime.jsx(Rx,{})]});return jsxRuntime.jsx(Dx.Provider,{value:s,children:t?jsxRuntime.jsx(Q,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Jm=Object.assign(WI,{docxSlot:"styles.style",Trigger:Xm,Content:Rx,Item:Mx});function Ix(e,t){let o=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:l,children:s})=>{let{isEnabled:c,disabledReason:d}=re(o),m=Po(),u=t==="showAll"?m.showAll:m.formFill,g=ae();if(i)return null;let p=te(o),f=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":f,title:d??f,onMouseDown:$,onClick:()=>{t==="showAll"?m.toggleShowAll():m.toggleFormFill();}};return l?jsxRuntime.jsx(Q,{...b,children:s}):jsxRuntime.jsx("button",{...b,children:a??s??oe(p?.paths)})},{docxSlot:o})}function KI({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=Mt.inspector,{isEnabled:a,disabledReason:l}=re(i),{inspectorOpen:s,openInspector:c}=Po(),d=ae();if(t)return null;let m=te(i),u=d(m?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Mt.inspector,disabled:!a,...a?{}:{"data-disabled":""},...s?{"data-active":""}:{},"aria-pressed":s,"aria-label":u,title:l??u,onMouseDown:$,onClick:()=>c()};return n?jsxRuntime.jsx(Q,{...g,children:r}):jsxRuntime.jsx("button",{...g,children:o??r??oe(m?.paths)})}function qI({className:e,hidden:t,icon:o,asChild:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l}=Po(),s=ae();if(t)return null;let c=Mt.remove,d=te(c),m=s(d?.labelKey??"contentControl.remove"),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Mt.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":m,title:a??m,onMouseDown:$,onClick:()=>{l();}};return n?jsxRuntime.jsx(Q,{...u,children:r}):jsxRuntime.jsx("button",{...u,children:o??r??oe(d?.paths)})}var Tc=Ix(Mt.showAll,"showAll"),Ec=Ix(Mt.formFill,"formFill"),Sc=Object.assign(qI,{docxSlot:Mt.remove}),Pc=Object.assign(KI,{docxSlot:Mt.inspector}),Nx={[Mt.showAll]:Tc,[Mt.formFill]:Ec,[Mt.inspector]:Pc,[Mt.remove]:Sc};var Sa=Object.assign(e=>jsxRuntime.jsx(Ko,{slotId:"table.mergeCells",...e}),{docxSlot:"table.mergeCells"});function UI({icon:e,className:t,children:o,hidden:n}){let{isEnabled:r,disabledReason:i}=re("table.splitCell"),a=_o(),l=ae();if(n||!a)return null;let s=l(te("table.splitCell")?.labelKey??"table.splitCell");return jsxRuntime.jsx("button",{type:"button","data-slot":"table.splitCell",className:`docx-toolbar__button${t?` ${t}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-label":s,"aria-haspopup":"dialog",title:i??s,onMouseDown:$,onClick:c=>a.open("splitCell",c.currentTarget),children:e??o??oe(te("table.splitCell")?.paths)})}var Pa=Object.assign(UI,{docxSlot:"table.splitCell"});function Qm(e,t){let o=A(),n=Zt.useRef(t);n.current=t,Zt.useEffect(()=>{if(!o)return;let r=((...i)=>{n.current(...i);});return o.on(e,r)},[o,e]);}var XI=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],tf=Zt.createContext(null);function Zx(){let e=Zt.useContext(tf);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function QI(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 e8(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function t8(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var Bx={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function o8(e,t){let o={};for(let n of XI){let r=editor.tableChromeToolbarState(e,n,t);o[n]={enabled:r.enabled,disabledReason:r.disabledReason};}return o}function of({children:e}){let t=A(),[o,n]=Zt.useState(editor.DEFAULT_TABLE_CHROME_DRAFT),[r,i]=Zt.useState(Bx);Zt.useEffect(()=>(()=>{}),[]);let a=W(Zt.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:""}),[]),e8,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=Zt.useCallback(()=>{if(!t){i(Bx);return}let u=QI(t,t.snapshot());i(g=>t8(g,u)?g:u);},[t]);Zt.useEffect(()=>{l();},[l,a]),Qm("selectionChange",Zt.useCallback(()=>{l();},[l]));let s=r.tableKey!=="",c=Zt.useMemo(()=>t?o8(t,o):{},[t,o,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=Zt.useCallback((u,g)=>{if(!t)return;let{result:p,nextDraft:f}=editor.runTableChromeCommand(t,u,g,o);p.ok&&f&&n(f);},[t,o]),m=Zt.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(tf.Provider,{value:m,children:e})}function n8(){let e=Zt.useContext(tf);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function wc(e){let t=n8(),o=t.slotState(e);return Zt.useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:n=>t.apply(e,n)}),[t,e,o])}function Rc(e){(editor.editorInstanceScope(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function Mc({enabled:e,disabledReason:t,ariaLabel:o}){let{t:n}=H(),r=i18n.localizeDisabledReason(t,n),i=Zt.useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:$,"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 s8='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function Ux(e,t,o,n){Zt.useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll(s8)].filter(c=>c.closest('[role="menu"]')===r);queueMicrotask(()=>{let c=a();(c.find(m=>m.hasAttribute("data-selected")||m.hasAttribute("data-active"))??c[0])?.focus();});let s=c=>{if(c.defaultPrevented||c.isComposing||c.keyCode===229)return;let d=a();if(c.key==="Escape"){c.preventDefault(),t(false),i?.focus();return}if(c.key==="ArrowDown"){c.preventDefault(),no(d,editor.hostDocumentOf(r).activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),no(d,editor.hostDocumentOf(r).activeElement,-1);return}if(c.key==="Home"){c.preventDefault(),ro(d,"first");return}if(c.key==="End"){c.preventDefault(),ro(d,"last");return}if(c.key==="Enter"||c.key===" "){let m=editor.hostDocumentOf(c.target).activeElement;editor.isHTMLElementNode(m)&&d.includes(m)&&(c.preventDefault(),m.click());}};return r.addEventListener("keydown",s),()=>r.removeEventListener("keydown",s)},[e,t,o,n]);}function $x(e,t,o,n){Zt.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=editor.hostDocumentOf(s.target).activeElement,d=a();editor.isHTMLElementNode(c)&&d.includes(c)&&(s.preventDefault(),c.click());}};return r.addEventListener("keydown",l),()=>r.removeEventListener("keydown",l)},[e,t,o,n]);}function Xx(e,t,o){if(e)return n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),o(!t));}}function f8(e){return oe(editor.tableChromeIconPaths(e))}function Jx(){return Zt.createContext(null)}function Xo(e){let t=Zt.useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function rf(e,t,o){let n=Jx();function r({hidden:l,asChild:s,className:c,children:d}){let{visible:m,enabled:u,disabledReason:g,draft:p,apply:f}=wc(e),[b,y]=Zt.useState(false),v=Zt.useRef(null),x=Zt.useRef(null);ur(b,y,v,l||!m);let h=Zt.useMemo(()=>({open:b,setOpen:y,enabled:u,disabledReason:g,apply:f,draft:p,triggerRef:x}),[b,u,g,f,p]);if(l||!m)return null;let k={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},E=d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(i,{}),jsxRuntime.jsx(a,{})]});return jsxRuntime.jsx(n.Provider,{value:h,children:s?jsxRuntime.jsx(Q,{...k,ref:v,children:E}):jsxRuntime.jsx("div",{ref:v,...k,children:E})})}function i({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,disabledReason:g,triggerRef:p}=Xo(n),f=ae(),b=te(e),y=f(b?.labelKey??o),{shared:v,reasonNode:x}=Mc({enabled:u,disabledReason:g,ariaLabel:y}),h={...v,ref:p,className:`docx-toolbar__button docx-table-chrome__trigger${s?` ${s}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:u?()=>m(!d):void 0,...l?{tabIndex:u?0:-1,role:"button",onKeyDown:Xx(u,d,m)}:{}},k=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(Q,{...h,children:k}),x]}):jsxRuntime.jsxs("button",{...h,children:[k,x]})}i.docxToolbarPart=true;function a({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,triggerRef:g}=Xo(n),p=ae(),f=Zt.useRef(null);if(Ux(d&&u,m,f,g),!d||!u)return null;let b=te(e),y=p(b?.labelKey??o),v={ref:f,role:"menu","aria-label":y,className:`docx-table-chrome__panel${s?` ${s}`:""}`,onMouseDown:$};return l?jsxRuntime.jsx(Q,{...v,children:c}):jsxRuntime.jsx("div",{...v,children:c})}return {Root:r,Trigger:i,Content:a,Ctx:n}}var Xi=rf("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function Qx({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xo(Xi.Ctx),l=ae(),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:$,onClick:()=>{i(false),r(s.value);}},m=n??f8(s.icon);return t?jsxRuntime.jsx(Q,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function ev(e){let{children:t}=e;return jsxRuntime.jsx(Xi.Content,{...e,children:t??jsxRuntime.jsx("div",{className:"docx-table-chrome__target-grid",children:editor.TABLE_BORDER_TARGET_OPTIONS.map(o=>jsxRuntime.jsx(Qx,{value:o.value},o.value))})})}function g8(e){let{children:t}=e,o=t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xi.Trigger,{}),jsxRuntime.jsx(ev,{})]});return jsxRuntime.jsx(Xi.Root,{...e,children:o})}var ol=Object.assign(g8,{docxSlot:"table.borderTarget",Trigger:Xi.Trigger,Content:ev,Item:Qx}),Ji=rf("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function tv({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xo(Ji.Ctx),l=ae(),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:$,onClick:()=>{i(false),r(s.value);}},m=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(Q,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function ov(e){let{children:t}=e;return jsxRuntime.jsx(Ji.Content,{...e,children:t??editor.TABLE_BORDER_STYLE_OPTIONS.map(o=>jsxRuntime.jsx(tv,{value:o.value},o.value))})}function b8(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ji.Trigger,{}),jsxRuntime.jsx(ov,{})]});return jsxRuntime.jsx(Ji.Root,{...e,children:t})}var nl=Object.assign(b8,{docxSlot:"table.borderStyle",Trigger:Ji.Trigger,Content:ov,Item:tv}),Qi=rf("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function nv({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xo(Qi.Ctx),l=ae(),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,m={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:$,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(Q,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}function rv(e){let{children:t}=e;return jsxRuntime.jsx(Qi.Content,{...e,children:t??editor.TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsxRuntime.jsx(nv,{value:String(o.size)},o.size))})}function h8(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Qi.Trigger,{}),jsxRuntime.jsx(rv,{})]});return jsxRuntime.jsx(Qi.Root,{...e,children:t})}var rl=Object.assign(h8,{docxSlot:"table.borderWidth",Trigger:Qi.Trigger,Content:rv,Item:nv});function av(e,t,o){let n=o?.defaultHex??"FF0000",r=Jx();function i({hidden:d,asChild:m,className:u,children:g}){let{visible:p,enabled:f,disabledReason:b,draft:y,apply:v}=wc(e),[x,h]=Zt.useState(false),[k,E]=Zt.useState(n),C=Zt.useRef(null),T=Zt.useRef(null);ur(x,h,C,d||!p);let S=Zt.useMemo(()=>({open:x,setOpen:h,enabled:f,disabledReason:b,apply:v,draft:y,triggerRef:T,lastHex:k,setLastHex:E}),[x,f,b,v,y,k]);if(d||!p)return null;let P={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:S,children:m?jsxRuntime.jsx(Q,{...P,ref:C,children:w}):jsxRuntime.jsx("div",{ref:C,...P,children:w})})}function a({asChild:d,className:m,children:u}){let{enabled:g,disabledReason:p,apply:f,draft:b,lastHex:y}=Xo(r),v=ae(),x=te(e),h=v(x?.labelKey??t),{shared:k,reasonNode:E}=Mc({enabled:g,disabledReason:p,ariaLabel:h}),C=e==="table.borderColor"&&b.spec.color.kind==="hex"?b.spec.color.value:y??n,T={...k,className:`docx-toolbar__button docx-toolbar__colorsplit-main${m?` ${m}`:""}`,onClick:g?()=>f({kind:"hex",value:C}):void 0},S=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[oe(x?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${C.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Q,{...T,children:S}),E]}):jsxRuntime.jsxs("button",{...T,children:[S,E]})}a.docxToolbarPart=true;function l({asChild:d,className:m,children:u}){let{open:g,setOpen:p,enabled:f,disabledReason:b,triggerRef:y}=Xo(r),v=ae(),x=te(e),h=v(x?.labelKey??t),{shared:k,reasonNode:E}=Mc({enabled:f,disabledReason:b,ariaLabel:h}),C={...k,ref:y,className:`docx-toolbar__colorsplit-caret${m?` ${m}`:""}`,"aria-haspopup":"dialog","aria-expanded":g,onClick:f?()=>p(!g):void 0,...d?{tabIndex:f?0:-1,role:"button",onKeyDown:Xx(f,g,p)}:{}},T=u??"\u25BE";return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Q,{...C,children:T}),E]}):jsxRuntime.jsxs("button",{...C,children:[T,E]})}l.docxToolbarPart=true;function s({asChild:d,className:m,children:u,clearFill:g}){let{open:p,setOpen:f,enabled:b,apply:y,draft:v,triggerRef:x,lastHex:h,setLastHex:k}=Xo(r),E=ae(),C=Zt.useRef(null);if($x(p&&b,f,C,x),!p||!b)return null;let T=E(t),S=e==="table.borderColor"&&v.spec.color.kind==="hex"?v.spec.color.value:h??n,P={ref:C,role:"dialog","aria-label":T,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${m?` ${m}`:""}`,onMouseDown:$},w=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g?jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:$,onClick:()=>{f(false),y(null),Rc(x.current);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),E("table.clearCellFill")]}):null,jsxRuntime.jsx(eu,{apply:_=>{f(false),k?.(_),y({kind:"hex",value:_}),Rc(x.current);},current:S})]});return d?jsxRuntime.jsx(Q,{...P,children:w}):jsxRuntime.jsx("div",{...P,children:w})}function c({value:d,css:m,labelKey:u,asChild:g,className:p,children:f}){let{apply:b,setOpen:y,setLastHex:v,triggerRef:x}=Xo(r),h=ae(),k=m??`#${d.toLowerCase()}`,E=u?h(u):d,C={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:k},"data-value":d,"aria-label":E,title:E,onMouseDown:$,onClick:()=>{y(false),v?.(d),b({kind:"hex",value:d}),Rc(x.current);}};return g?jsxRuntime.jsx(Q,{...C,children:f}):jsxRuntime.jsx("button",{...C,children:f})}return {Root:i,Main:a,Trigger:l,Content:s,Item:c,Ctx:r}}var el=av("table.borderColor","table.borderColor",{defaultHex:"000000"});function y8(e){return jsxRuntime.jsx(el.Content,{...e,clearFill:false})}function x8(e){return jsxRuntime.jsx(el.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function v8(e){return jsxRuntime.jsx(el.Root,{...e})}var al=Object.assign(v8,{docxSlot:"table.borderColor",Trigger:el.Trigger,Content:y8,Item:x8,Main:el.Main}),tl=av("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function C8(e){return jsxRuntime.jsx(tl.Content,{...e,clearFill:true})}function T8(e){return jsxRuntime.jsx(tl.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function E8(e){return jsxRuntime.jsx(tl.Root,{...e})}var il=Object.assign(E8,{docxSlot:"table.cellFill",Trigger:tl.Trigger,Content:C8,Item:T8,Main:tl.Main});function iv({overrides:e=new Map,separator:t=true}){return Zx()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx(dr,{}):null,[ol,al,nl,rl,il].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(Zt.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)}),[Sa,Pa].map(r=>{let i=e.get(r.docxSlot);return i?jsxRuntime.jsx(Zt.Fragment,{children:i},r.docxSlot):jsxRuntime.jsx(r,{},r.docxSlot)})]}):null}function lv(){let e=ae(),{draft:t}=wc("table.borderTarget");return e(editor.tableChromeLabelKeyForTarget(t.activeTarget))}var lf=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill","table.mergeCells","table.splitCell"],fr="contextual-table",sf={"zoom.level":Wm,"styles.style":Jm,"font.family":Vm,"font.size":Bm,"text.color":tu,"text.highlight":ou,"text.link":Fm,"list.lineSpacing":Zm,"review.editingMode":lc,"review.authors":cc,"file.save":Lm,...Nx,"table.borderTarget":ol,"table.borderColor":al,"table.borderStyle":nl,"table.borderWidth":rl,"table.cellFill":il,"table.splitCell":Pa,"image.insert":ci,"image.properties":ga,"image.wrap":Ui,"image.altText":_i},N8=new Set(["image.insert","image.properties","image.wrap","image.altText"]),_c={id:fr,labelKey:"formattingBar.groups.table",entries:lf.map(e=>({slot:e,Part:e==="table.mergeCells"?Sa:sf[e]}))},sv=new Map;function F8(e){let t=sv.get(e);return t||(t=o=>jsxRuntime.jsx(Ko,{slotId:e,...o}),sv.set(e,t)),t}function L8(e,t){return editor.formattingBarChromeGroups(e,{direction:t}).map(o=>o.id==="alignment"?{id:o.id,labelKey:o.labelKey,entries:[{slot:"alignment",Part:bc}]}:{id:o.id,labelKey:o.labelKey,entries:o.controls.map(n=>{let r=editor.chromeSlotId(o,n);return {slot:r,Part:sf[r]??F8(r)}})})}var H8=e=>e.image,A8=e=>e.isLoading||e.isOpening===true,O8=e=>e.table!==null;function B8(e){return e==="alignment"||e in sf}function Fc(e){let t=Wr(e,Fc);if(t!==null)return t;if(!Zt.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.docxToolbarSlot===true){let n=e.props.slotId;return typeof n=="string"?n:null}if(o.docxToolbarPart===true){let n=e.props,r=n.slotId??n.slot;if(typeof r=="string")return r}return null}function af(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(af);let t=Fc(e);return t!=null&&lf.includes(t)?true:Zt.isValidElement(e)?Zt.Children.toArray(e.props.children).some(af):false}function W8(e,t){return t?true:Zt.Children.toArray(e).some(af)}function Z8(e){let t=$t(),{className:o,t:n,onSave:r,preset:i=true,overflow:a=true,children:l}=e,s=Zt.useMemo(()=>({t:n,onSave:r}),[n,r]),c=zl(n),d=W(H8),m=W(A8),u=W(O8),g=lt(),p=g==="rtl",f=Zt.useMemo(()=>L8(d,p),[d,p]),b=Zt.useMemo(()=>new Set(f.flatMap(S=>S.entries.map(P=>P.slot))),[f]),y=Zt.useMemo(()=>i?_y(l,Fc,S=>b.has(S),S=>lf.includes(S)):null,[i,l,b]),v=Zt.useMemo(()=>y?K8(f,y):[],[f,y]),x=Zt.useMemo(()=>[...v.filter(S=>!S.pinned).map(S=>({id:S.id,items:cv(S,y?.overrides)})),...u?[{id:fr,items:[fr]}]:[]],[v,y,u]),h=Zt.useMemo(()=>{let S=new Map;for(let P of v)P.priority!==void 0&&S.set(P.id,P.priority);return editor.collapseOrder(x.map(P=>P.id),editor.TOOLBAR_COLLAPSE_ORDER,S)},[v,x]),k=i&&a,{attach:E,overflow:C}=Fu(k,x,h),T;if(!y)T=l;else {let{overrides:S,tableOverrides:P,appended:w}=y,_=R=>{let U=S.get(R.slot);if(U)return U;let V=R.Part;return jsxRuntime.jsx(V,{})},L=R=>{let U=P.get(R.slot);if(U)return U;let V=R.Part;return jsxRuntime.jsx(V,{})},N=[],B=[],F=0;for(let R of v){let U=cv(R,S),V=new Map(R.entries.map(q=>[q.slot,q])),Y=R.pinned?U.length:editor.toolbarShownCount(C,R.id,U.length),j=U.slice(Y);if(j.length>0){let q=j.flatMap(ee=>{let O=V.get(ee);if(!O)return [];let I=dv(O,S,c,R.labelKey,_);return I===null?[]:[jsxRuntime.jsx(Zt.Fragment,{children:I},O.slot)]}),X=editor.toolbarHostPanelShown(R.extras.length>0,j)?U8(R):null;X!==null&&q.push(jsxRuntime.jsx(Zt.Fragment,{children:X},"host")),q.length>0&&B.push({id:R.id,labelKey:R.labelKey,...R.heading?{label:is(R.heading,c)}:{},children:q});}Y!==0&&(F>0&&N.push(jsxRuntime.jsx(dr,{},`separator-${R.id}`)),F+=1,N.push(jsxRuntime.jsx("div",{className:`docx-toolbar__group${R.className?` ${R.className}`:""}`,...R.heading?{role:"group","aria-label":is(R.heading,c)}:{},...R.pinned?{[Ur]:""}:{[qr]:R.id},children:U.slice(0,Y).map(q=>{let X=V.get(q);return jsxRuntime.jsx("div",{className:"docx-toolbar__item",[_b]:q,children:X?_(X):R.extras},q)})},R.id)));}let D=C.has(fr);if(u&&D){let R=_c.entries.flatMap(U=>{let V=dv(U,P,c,_c.labelKey,L);return V===null?[]:[jsxRuntime.jsx(Zt.Fragment,{children:V},U.slot)]});R.length>0&&B.unshift({id:_c.id,labelKey:_c.labelKey,children:R});}T=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[N,u&&!D?jsxRuntime.jsx(dr,{},"separator-contextual-table"):null,D?null:jsxRuntime.jsx("div",{className:"docx-toolbar__contextual",[qr]:fr,children:jsxRuntime.jsx(iv,{overrides:P,separator:false})}),w.length>0?jsxRuntime.jsx("div",{className:"docx-toolbar__group",[Ur]:"",children:w}):null,B.length>0?jsxRuntime.jsx(Ry,{sections:B}):null]});}return jsxRuntime.jsx(Vn.Provider,{value:s,children:jsxRuntime.jsx(Ty,{children:jsxRuntime.jsx("fieldset",{ref:E,disabled:m,"aria-label":c("formattingBar.label"),"data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,dir:g,...k?{"data-overflow":""}:{},onMouseDown:$,children:W8(l,i)?jsxRuntime.jsx(of,{children:T}):T})})})}function Lc(e){if(!e)return false;if(e.type===Zt.Fragment){let t=Zt.Children.toArray(e.props.children).find(o=>Fc(o)!==null);return Zt.isValidElement(t)?Lc(t):false}return !!e.props.hidden}function cv(e,t){let o=e.entries.filter(n=>!Lc(t?.get(n.slot))).map(n=>n.slot);return editor.toolbarGroupItems(o,e.extras.length>0)}function K8(e,t){let o=new Map(t.groups.map(s=>[s.id,s])),n=new Set(e.map(s=>s.id)),r=new Map;for(let s of e){let c=o.get(s.id);if(c&&q8(c),c?.hidden)continue;let d=Zt.Children.toArray(c?.children);!s.entries.some(u=>!Lc(t.overrides.get(u.slot)))&&d.length===0||r.set(s.id,{id:s.id,labelKey:s.labelKey,heading:void 0,entries:s.entries,extras:d,pinned:c?.pinned??editor.TOOLBAR_PINNED_GROUPS.has(s.id),priority:c?.priority,overflowContent:c?.overflowContent,className:c?.className,host:false});}for(let s of t.groups)s.id===fr&&Hy(s.id);let i=t.groups.filter(s=>!n.has(s.id)&&s.id!==fr);for(let s of i){let c=Zt.Children.toArray(s.children);s.hidden||c.length===0||r.set(s.id,{id:s.id,labelKey:s.labelKey??s.id,heading:{id:s.id,label:s.label,labelKey:s.labelKey},entries:[],extras:c,pinned:s.pinned===true,priority:s.priority,overflowContent:s.overflowContent,className:s.className,host:true});}let a=[...n,...i.map(s=>s.id)];for(let s of i)s.after!==void 0&&!a.includes(s.after)&&Fy(s.id,s.after,a);for(let s of t.appended){if(!Zt.isValidElement(s)||s.type!==ii)continue;let c=s.props.slotId;Ay(c,te(c)!==null);}return editor.arrangeToolbarGroups(e.map(s=>s.id),i.map(s=>({id:s.id,after:s.after}))).flatMap(s=>{let c=r.get(s);return c?[c]:[]})}function q8(e){for(let t of ["label","labelKey","after"])e[t]!==void 0&&Ly(e.id,t);}function U8(e){return e.overflowContent?e.overflowContent():e.extras.length===0?null:jsxRuntime.jsx(ls.Provider,{value:"panel",children:jsxRuntime.jsx("div",{className:"docx-toolbar__more-host",children:e.extras})})}function dv(e,t,o,n,r){let i=t.get(e.slot);if(Lc(i))return null;let a=i?.type===ii?i.props.overflowContent:void 0;return !i&&N8.has(e.slot)?jsxRuntime.jsx(ls.Provider,{value:"panel",children:r(e)}):i||B8(e.slot)?jsxRuntime.jsx(wy,{label:$8(o,e,n),children:a?a():r(e)}):jsxRuntime.jsx(Dy,{slot:e.slot})}function $8(e,t,o){let n=t.slot==="alignment"?null:te(t.slot);return e(n?.labelKey??o)}var sl=Object.assign(Z8,{Button:Ko,Action:qm,Separator:dr,Group:Lu,Slot:ii,AddComment:Rm,Undo:By,Redo:Wy,Bold:Zy,Italic:Ky,Underline:qy,Strike:Uy,Link:Fm,ClearFormatting:$y,Superscript:zy,Subscript:Vy,Alignment:bc,AlignLeft:Gy,AlignCenter:jy,AlignRight:Yy,AlignJustify:Xy,LeftToRight:Jy,RightToLeft:Qy,LineSpacing:Zm,BulletList:ex,NumberedList:tx,Outdent:ox,Indent:nx,ImageInsert:ci,ImageProperties:ga,ImageWrap:Ui,ImageAltText:_i,TableInsert:Nm,TableBorderTarget:ol,TableBorderColor:al,TableBorderStyle:nl,TableBorderWidth:rl,TableCellFill:il,TableMergeCells:Sa,TableSplitCell:Pa,Comments:rx,FontFamily:Vm,FontSize:Bm,FontColor:tu,Highlight:ou,Zoom:Wm,StylePicker:Jm,EditingMode:lc,Reviewers:cc,Save:Lm,ContentControlShowAll:Tc,ContentControlFormFill:Ec,ContentControlInspector:Pc,ContentControlRemove:Sc});var uv=/^(con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])$/i,Y8=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g,X8=200,pv=new TextEncoder;function J8(e,t){if(pv.encode(e).length<=t)return e;let o=0,n="";for(let r of e){let i=pv.encode(r).length;if(o+i>t)break;o+=i,n+=r;}return n}function mv(e){let t=e.length;for(;t>0;){let o=e.charCodeAt(t-1);if(o!==46&&o!==32)break;t-=1;}return e.slice(0,t)}function fv(e){return mv(mv(e).replace(/\.docx$/i,""))}function Hc(e){let t=(e??"").replace(Y8," ").replace(/\s+/g," ").trim(),o=fv(t).replace(/^[. ]+/,""),n=J8(o,X8),r=n===o?o:fv(n);return !r||uv.test(r)?"document.docx":uv.test(r.split(".",1)[0].trim())?`_${r}.docx`:`${r}.docx`}function Ac(e,t,o="application/vnd.openxmlformats-officedocument.wordprocessingml.document",n){let r=URL.createObjectURL(new Blob([e],{type:o})),i=editor.hostDocumentOf(n).createElement("a");i.href=r,i.download=t,i.click(),editor.hostWindowOf(n).setTimeout(()=>URL.revokeObjectURL(r),0);}function gv(e,t,o){let{t:n}=H(),r=Zt.useRef(false),[i,a]=Zt.useState(false),[l,s]=Zt.useState(""),[c,d]=Zt.useState("pdf"),[m,u]=Zt.useState(false),[g,p]=Zt.useState({});return {pending:i,error:l,format:c,visible:m,session:g,dismiss:()=>u(false),execute:async b=>{if(!(!e||r.current)){r.current=true,p({}),d(b),u(true),a(true),s("");try{let y=await editor.runChromeExport(e,b,t);Ac(y.bytes.slice().buffer,Hc(o).replace(/\.docx$/,`.${y.extension}`),y.mimeType),u(!1);}catch(y){u(true),s(y instanceof editor.ChromeExportError?n(y.format==="markdown"?"toolbar.exportMarkdownMissing":"toolbar.exportPdfMissing"):n("toolbar.exportFailed",{message:y instanceof Error?y.message:String(y)}));}finally{r.current=false,a(false);}}}}}function yv(e,t,o,n=false){let{t:r}=H(),i=Zt.useRef({editor:e,exporters:t,feedback:o,t:r,settingsStep:n});i.current={editor:e,exporters:t,feedback:o,t:r,settingsStep:n};let a=Zt.useRef(null),l=Zt.useRef(null),[s,c]=Zt.useState(false),[d,m]=Zt.useState(""),[u,g]=Zt.useState(""),[p,f]=Zt.useState(false),[b,y]=Zt.useState(false),[v,x]=Zt.useState({}),[h,k]=Zt.useState(false),[E,C]=Zt.useState(()=>editor.initialChromePrintSettings(null)),T=Zt.useRef(E),S=Zt.useRef(void 0),P=Zt.useRef(null),w=Zt.useCallback(D=>{let{t:R}=i.current;if(D instanceof editor.ChromeExportError)return R("toolbar.printPdfMissing");if(D instanceof editor.ChromePrintError){if(D.code==="pdf-viewer-unavailable")return R("toolbar.printNoViewer");if(D.code==="pdf-load-failed")return R("toolbar.printLoadFailed");if(D.code==="print-refused")return R("toolbar.printRefused")}return R("toolbar.printFailedMessage",{message:D instanceof Error?D.message:String(D)})},[]),_=Zt.useCallback(()=>{a.current=null,y(false),f(false),c(false),k(false);},[]),L=Zt.useCallback(async(D,R)=>{let{editor:U,exporters:V}=i.current;if(!(!U||a.current!==D||P.current===D)){P.current=D,k(false),c(true);try{let Y=await editor.runChromePrint(U,V,S.current??editor.hostDocumentOf(null),R);if(a.current!==D){Y.dispose();return}l.current=Y,await Y.print({beforePrint:()=>{if(a.current!==D)throw new editor.ChromePrintError("print-ended");reactDom.flushSync(()=>f(!1));}}),a.current===D&&_();}catch(Y){if(a.current!==D)return;if(!i.current.feedback){console.error("[docx-editor] print failed",Y),_();return}c(false),g(l.current?.url??""),m(w(Y)),f(true);}}},[_,w]),N=Zt.useCallback(async D=>{let{editor:R,exporters:U,feedback:V,settingsStep:Y}=i.current;if(!R||a.current)return;let j={};if(a.current=j,S.current=D,l.current?.dispose(),l.current=null,x(j),y(true),f(true),m(""),g(""),!Y||!V||!U?.pdf){await L(j,{});return}let q=editor.initialChromePrintSettings(R.snapshot());T.current=q,C(q),c(false),k(true);},[L]),B=Zt.useCallback(D=>{let R={...T.current,...D};T.current=R,C(R);},[]),F=Zt.useCallback(()=>{let D=a.current;D&&L(D,T.current);},[L]);return Zt.useEffect(()=>()=>{a.current=null,l.current?.dispose(),l.current=null;},[]),{pending:s,error:d,url:u,visible:p,active:b,session:v,choosing:h,settings:E,execute:N,changeSettings:B,confirm:F,close:_}}var cN=()=>{};function cf(){let e=A(),t=Zt.useCallback(n=>e?e.on("hostChange",n):cN,[e]),o=Zt.useCallback(()=>e?editor.editorHostDocument(e):typeof globalThis.document>"u"?null:globalThis.document,[e]);return Zt.useSyncExternalStore(t,o,()=>null)}var dN="https://github.com/eigenpal/docx-editor/issues/new";function uN(){if(typeof globalThis.window>"u")return "";try{let e=new URL(globalThis.window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function vv(e={}){let t=e.userAgent??(typeof globalThis.navigator<"u"?globalThis.navigator.userAgent:"unknown"),o=e.viewport??(typeof globalThis.window<"u"?{width:globalThis.window.innerWidth,height:globalThis.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??uN()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
2
2
  `),i=new URLSearchParams({title:"[Bug] ",body:r});return `${dN}?${i.toString()}`}function dl(e){typeof globalThis.window>"u"||globalThis.window.open(vv(e),"_blank","noopener,noreferrer");}function pN({className:e,hidden:t,onSelect:o}){let{setOpenMenu:n,onReportIssue:r,reportIssue:i}=et(),a=Pe();if(t||i===false)return null;let l=o??r??dl;return jsxRuntime.jsx(De,{slot:"help.reportIssue",onSelect:()=>{l(),n(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var Oc=Object.assign(pN,{docxSlot:"help.reportIssue"});function mN({children:e,...t}){let{reportIssue:o}=et();return e===void 0&&o===false?null:jsxRuntime.jsxs(lo,{id:"help",...t,children:[jsxRuntime.jsx(Oc,{}),e]})}var df=Object.assign(mN,{docxMenu:"help"});var hN=e=>e.hiddenReviewAuthors??[];function Bc({className:e,hidden:t}){let o=A(),n=Zi(),r=W(hN),i=Pe(),{t:a}=H();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),m=n.every(u=>!d.has(u.author));return jsxRuntime.jsxs(io,{labelKey:"reviewers.label",className:e,children:[jsxRuntime.jsx(Tv,{checked:m,label:i("reviewers.all"),slot:"reviewer-all",onChoose:()=>o?.setAllReviewAuthorsVisible(!m)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),n.map(u=>jsxRuntime.jsx(Tv,{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 Tv(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 yN({children:e,...t}){return jsxRuntime.jsxs(lo,{id:"review",...t,children:[jsxRuntime.jsx(io,{labelKey:"reviewers.markupOptions",className:"docx-menubar__markup-options",children:jsxRuntime.jsx(Bc,{className:"docx-menubar__reviewers-submenu"})}),e]})}var Wc=Object.assign(yN,{docxMenu:"review"});var SN={file:ju,format:Yu,insert:Xu,review:Wc,help:df};function ul(e,t=false){if(!Zt.isValidElement(e))return null;if(e.type===Zt.Fragment){let i=Zt.Children.toArray(e.props.children).map(a=>ul(a,t)).filter(a=>a!==null);return i.length===1?i[0]:null}let o=e.props;if(o.hidden===true&&!t)return null;let n=e.type;return (typeof n=="function"||typeof n=="object")&&typeof n.docxMenu=="string"?n.docxMenu:e.type===lo&&typeof o.id=="string"?o.id:null}var PN=new Set(editor.CHROME_MENUS.map(e=>e.id));function Uc(e){if(!Zt.isValidElement(e))return null;if(e.type===Zt.Fragment){let n=Zt.Children.toArray(e.props.children).map(Uc).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"&&PN.has(o))return o}return null}var kN=e=>e.isOpening===true;function wN(e){let t=_o(),o=Rt(),n=$t(),r=lt(),{className:i,t:a,fileName:l,exporters:s,printSettings:c,onOpen:d,onOpenFile:m,onSave:u,onPageSetup:g,onReportIssue:p,reportIssue:f,preset:b=true,overflow:y=true,children:v}=e,x=A(),{t:h}=H(),[k,E]=Zt.useState(null),C=W(kN);Zt.useEffect(()=>{C&&E(null);},[C]);let[T,S]=Zt.useState(null),P=gv(x,s,l??T??void 0),{pending:w,execute:_}=P,L=yv(x,s,o?.print!==false,c??o?.print===void 0),{active:N,execute:B}=L,F=L.visible&&o?.print!==false,[D,R]=Zt.useState(null),[U,V]=Zt.useState(false),[Y,j]=Zt.useState(false),[q,X]=Zt.useState(false),ee=Zt.useRef(null),O=Zt.useRef(null);Zt.useEffect(()=>{if(k!==null)return editor.listenForOutsidePress({popup:ee.current,close:()=>E(null)})},[k]),va(k!==null,ee,()=>E(null),ce=>editor.isDomNode(ce.target)&&ee.current?.contains(ce.target)===true);let I=Zt.useCallback(ce=>{E(ce),ce!==null&&R(ce);},[]),ie=Zt.useCallback(()=>O.current?.click(),[]),ge=Zt.useCallback(()=>{x&&x.save().then(ce=>Ac(ce,Hc(l??T??void 0),void 0,ee.current)).catch(ce=>{console.error("[docx-editor] save failed",ce);});},[x,l,T]),K=Zt.useCallback(()=>t?t.open("pageSetup",ee.current?.querySelector('[data-menu="file"] > [role="menuitem"]')):V(true),[t]),de=x?d??ie:void 0,ke=x?u??ge:void 0,Ze=!!s?.pdf,at=Zt.useMemo(()=>x&&!N?()=>{Nu(ee.current),B(editor.editorInstanceScope(ee.current)??ee.current??void 0);}:void 0,[x,N,B]),Ce=x?t?.ownsPageSetup?K:g??K:void 0,Ye=cf();Zt.useEffect(()=>{let ce=Se=>{if(!(Se.metaKey||Se.ctrlKey)||Se.altKey||Se.shiftKey)return;let Et=Se.key.toLowerCase(),ln=editor.isChromePrintShortcut(Se);if(Et!=="s"&&Et!=="o"&&!ln)return;let sn=Se.target,z=editor.editorInstanceScope(ee.current)??ee.current;if(!(!sn||!((z?.contains(sn)??false)||Db(sn,editor.hostDocumentOf(ee.current),x?editor.editorHostElement(x):null))))if(ln){if(!Ze||!x||!at&&!F)return;Se.preventDefault(),at?.();}else Et==="s"&&ke?(Se.preventDefault(),ke()):Et==="o"&&de&&(Se.preventDefault(),de());},be=editor.hostDocumentOf(ee.current),Ne=Ye&&Ye!==be?[be,Ye]:[be];for(let Se of Ne)Se.addEventListener("keydown",ce);return ()=>{for(let Se of Ne)Se.removeEventListener("keydown",ce);}},[de,ke,at,F,Ze,x,Ye]);let Wn=Zt.useMemo(()=>({t:a,openMenu:k,setOpenMenu:I,activeMenu:D,onOpen:de,onSave:ke,onExport:x&&!w?ce=>(Nu(ee.current),_(ce)):void 0,onPrint:at,printShortcut:Ze,onPageSetup:Ce,onParagraphDialog:()=>t?t.open("paragraph",ee.current?.querySelector('[data-menu="format"] > [role="menuitem"]')):j(true),onWatermarkDialog:x?()=>t?t.open("watermark",ee.current?.querySelector('[data-menu="insert"] > [role="menuitem"]')):X(true):void 0,onReportIssue:p,reportIssue:f,opening:C}),[C,x,w,_,at,Ze,a,k,I,D,de,ke,Ce,t,p,f]),wt=Zt.Children.toArray(v),qt=[];if(b){let ce=new Map(wt.map(be=>[Uc(be),be]));for(let be of editor.CHROME_MENUS){let Ne=ce.get(be.id);(Ne===void 0||ul(Ne)!==null)&&qt.push(be.id);}for(let be of wt){if(Uc(be)!==null)continue;let Ne=ul(be);Ne!==null&&qt.push(Ne);}}else for(let ce of wt){let be=ul(ce);be!==null&&qt.push(be);}let Zn=[...qt].reverse(),{attach:se,overflow:Ge}=Ib(y,qt,Zn),Ie=Zt.useMemo(()=>({measuring:y,overflow:Ge,inMore:false}),[y,Ge]),Kn=Zt.useMemo(()=>({measuring:false,overflow:Ge,inMore:true}),[Ge]),xo=ce=>ul(ce,true)!==null,Qt=(ce,be)=>jsxRuntime.jsx("div",{role:"none",className:"docx-menubar__host",[Ur]:"",children:ce},be),vo,an;if(!b)vo=wt.filter(xo),an=y?wt.map((ce,be)=>xo(ce)?ce:Qt([ce],`host-${be}`)):v;else {let ce=new Map,be=[];for(let Se of wt){let Et=Uc(Se);Et?ce.set(Et,Se):be.push(Se);}vo=[...editor.CHROME_MENUS.map(Se=>{let Et=ce.get(Se.id);if(Et)return jsxRuntime.jsx(Zt.Fragment,{children:Et},Se.id);let ln=SN[Se.id];return jsxRuntime.jsx(ln,{},Se.id)}),...be.filter(xo)];let Ne=be.filter(Se=>!xo(Se));an=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[vo,Ne.length>0?Qt(Ne,"host"):null]});}let Ht=a?.("formattingBar.more")??h("formattingBar.more");return jsxRuntime.jsxs(ni.Provider,{value:Wn,children:[jsxRuntime.jsx("div",{ref:ce=>{if(ee.current=ce,se(ce),ce&&D===null){let be=Iu(ce)[0]?.closest("[data-menu]")?.getAttribute("data-menu");be&&R(be);}},role:"menubar","aria-label":a?.("titleBar.menuBarAriaLabel")??h("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",...y?{"data-overflow":""}:{},className:`${n}docx-menubar${i?` ${i}`:""}`,dir:r,onMouseDown:$,onKeyDown:ce=>{if(ce.key!=="ArrowLeft"&&ce.key!=="ArrowRight")return;let be=ee.current;if(!be)return;let Ne=Iu(be),Se=Ne.indexOf(editor.hostDocumentOf(be).activeElement);if(Se===-1)return;ce.preventDefault();let Et=editor.hostWindowOf(be).getComputedStyle(be).direction==="rtl",ln=(ce.key==="ArrowRight"?1:-1)*(Et?-1:1),sn=Ne[(Se+ln+Ne.length)%Ne.length],z=sn?.closest("[data-menu]")?.getAttribute("data-menu");z&&(R(z),sn?.focus(),k!==null&&E(z));},children:jsxRuntime.jsxs(os.Provider,{value:Ie,children:[jsxRuntime.jsx(Kr.Provider,{value:0,children:an}),Ge.size>0?jsxRuntime.jsx(lo,{id:Zr,label:Ht,icon:oe(wm),preset:false,children:jsxRuntime.jsx(os.Provider,{value:Kn,children:vo})}):null]})}),jsxRuntime.jsxs(Gh,{children:[P.visible&&o?.export!==false?o?.export?Te(o.export,{open:true,format:P.format,pending:P.pending,error:P.error,onClose:P.dismiss},P.session):jsxRuntime.jsx(Ua,{open:true,format:P.format,pending:P.pending,error:P.error,onClose:P.dismiss}):null,L.visible&&o?.print!==false?o?.print?Te(o.print,{open:true,pending:L.pending,error:L.error,url:L.url,onClose:L.close,choosing:L.choosing,settings:L.settings,onSettingsChange:L.changeSettings,onPrint:L.confirm},L.session):jsxRuntime.jsx($a,{open:true,pending:L.pending,error:L.error,url:L.url,onClose:L.close,choosing:L.choosing,settings:L.settings,onSettingsChange:L.changeSettings,onPrint:L.confirm}):null]}),jsxRuntime.jsx("input",{ref:O,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:ce=>{let be=ce.target.files?.[0];ce.target.value="",!(!be||!x)&&(S(be.name),m?.(be),be.arrayBuffer().then(Ne=>x.load(new Uint8Array(Ne))).catch(Ne=>{console.error("[docx-editor] could not open the file",Ne);}));}}),jsxRuntime.jsx(tr,{open:U,onClose:()=>V(false)}),jsxRuntime.jsx(Vo,{open:Y,onClose:()=>j(false)}),jsxRuntime.jsx(or,{open:q,onClose:()=>X(false)})]})}var pl=Object.assign(wN,{Menu:lo,File:ju,Format:Yu,Insert:Xu,Review:Wc,Help:df,Item:ao,Row:De,Group:di,Separator:Qn,Submenu:io,TableGrid:Vr,Entry:pi,Open:Zu,Save:Ku,ExportMarkdown:qu,ExportPdf:Uu,Print:$u,PageSetup:zu,ImageInsert:Vu,Watermark:ms,Bookmark:fs,Reviewers:Bc,ReportIssue:Oc});var FN=12240,Rv=1440,LN=1440,HN=567,gr=20,hf=6,xf=gr+hf+2,AN="var(--doc-text-muted)",ON="var(--doc-text-subtle)",Mv="var(--doc-shadow-subtle)",BN="var(--doc-primary)",WN="var(--doc-primary-hover)",ZN="var(--doc-text-subtle)",fl=5,ml=7,KN={left:0,right:0,firstLine:0};function _v(e,t){return t==="inch"?(e/LN).toFixed(2)+'"':(e/HN).toFixed(1)+" cm"}function qN(e,t){return t?1:Math.round(e==="cm"?editor.SNAP_TWIPS_CM:editor.SNAP_TWIPS_INCH)}function br({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:m="inch",className:u="",style:g,tabMarks:p,onTabMarkRemove:f}){let{t:b}=H(),[y,v]=Zt.useState(null),[x,h]=Zt.useState(null),[k,E]=Zt.useState(null),[C,T]=Zt.useState(null),S=Zt.useRef(null),P=e?.pageWidthTwips??FN,w=e?.marginsTwips.left??Rv,_=e?.marginsTwips.right??Rv,L=e?.gutterTwips??0,N={pageWidth:P,leftMargin:w,rightMargin:_},B=l??KN,F=$e(P)*t,D=$e(w)*t,R=$e(_)*t,U=Zt.useCallback(I=>{let ie=S.current?.getBoundingClientRect();return ie?ec((I-ie.left)/t):null},[t]),V=Zt.useCallback((I,ie,ge)=>{let K=U(ie);if(K===null)return;if(T($e(K)*t),I==="leftMargin"||I==="rightMargin"){if(I==="leftMargin"){let ke=P-_-L-720,Ze=Math.round(Math.max(0,Math.min(K,ke)));E(Ze),n?.(Ze);}else {let ke=P-K,Ze=P-w-L-720,at=Math.round(Math.max(0,Math.min(ke,Ze)));E(at),r?.(at);}return}let de=editor.dragIndent(I,K,B,N,{unit:m,precise:ge});E(I==="right"?de.right:I==="firstLine"?de.firstLine:de.left),c?.(de);},[U,t,P,w,_,L,n,r,c,B,N,m]),Y=Zt.useCallback(I=>{I==="leftMargin"||I==="rightMargin"?i?.():d?.(),v(null),E(null),T(null);},[i,d]),j=Zt.useCallback((I,ie,ge)=>{let K=editor.handlePosition(I,B,N),de=editor.dragIndent(I,K+ie*qN(m,ge),B,N,{unit:m,precise:true});c?.(de),d?.();},[B,N,m,c,d]),q=editor.rulerMarginTicks(N,B,m).map(I=>({...I,position:$e(I.position)*t})),X=a&&s&&c!==void 0,ee=I=>$e(editor.handlePosition(I,B,N))*t,O=(I,ie,ge)=>({positionPx:ee(I),editable:X,isDragging:y===I,isHovered:x===I,onPointerEnter:()=>h(I),onPointerLeave:()=>h(null),onPointerDown:K=>{X&&(K.preventDefault(),K.stopPropagation(),K.currentTarget.setPointerCapture(K.pointerId),v(I));},onPointerMove:K=>{y===I&&V(I,K.clientX,K.altKey);},onPointerUp:K=>{y===I&&(K.currentTarget.releasePointerCapture(K.pointerId),Y(I));},onKeyDown:K=>{X&&(K.key!=="ArrowLeft"&&K.key!=="ArrowRight"||(K.preventDefault(),j(I,K.key==="ArrowLeft"?-1:1,K.shiftKey)));},label:b(ie),valueNow:ge,valueText:_v(ge,m),pageWidthTwips:P});return jsxRuntime.jsxs("div",{ref:S,className:`docx-horizontal-ruler ${u}`,style:{position:"relative",width:_t(F),height:xf,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:y?"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:_t(D),height:gr,backgroundColor:Mv,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&n?I=>{I.preventDefault(),I.currentTarget.setPointerCapture(I.pointerId),v("leftMargin");}:void 0,onPointerMove:I=>y==="leftMargin"&&V("leftMargin",I.clientX,I.altKey),onPointerUp:I=>{y==="leftMargin"&&(I.currentTarget.releasePointerCapture(I.pointerId),Y("leftMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,right:0,width:_t(R),height:gr,backgroundColor:Mv,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&r?I=>{I.preventDefault(),I.currentTarget.setPointerCapture(I.pointerId),v("rightMargin");}:void 0,onPointerMove:I=>y==="rightMargin"&&V("rightMargin",I.clientX,I.altKey),onPointerUp:I=>{y==="rightMargin"&&(I.currentTarget.releasePointerCapture(I.pointerId),Y("rightMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:gr,pointerEvents:"none"},children:q.map((I,ie)=>jsxRuntime.jsx(UN,{tick:I},ie))}),p?.map(I=>jsxRuntime.jsx(GN,{tabMark:I,positionPx:$e(editor.rulerTabPosition(I.position,N,B))*t,onDoubleClick:()=>f?.(I.position)},I.position)),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(bf,{direction:"down",anchor:"top",...O("firstLine","ruler.firstLineIndent",B.firstLine)}),jsxRuntime.jsx(bf,{direction:"up",anchor:"strip",...O("hanging","ruler.hangingIndent",B.left)}),jsxRuntime.jsx($N,{...O("left","ruler.leftIndent",B.left)}),jsxRuntime.jsx(bf,{direction:"up",anchor:"strip",...O("right","ruler.rightIndent",B.right)})]}),y&&k!==null&&C!==null&&jsxRuntime.jsx(zN,{value:_v(k,m),positionPx:C})]})}function UN({tick:e}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:_t(e.position),bottom:0,width:1,height:e.height,backgroundColor:ON}}),e.label&&jsxRuntime.jsx("div",{style:{position:"absolute",left:_t(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:AN,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function Iv(e){return e.editable?e.isDragging||e.isHovered?WN:BN:ZN}function Nv(e,t,o){return {position:"absolute",left:_t(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...o}}function Fv(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 bf({direction:e,anchor:t,...o}){let n=Iv(o),r=t==="top"?{top:0,height:ml+1}:{top:gr-ml,height:ml};return jsxRuntime.jsx("div",{className:"docx-ruler-indent",style:Nv(o,fl*2,r),onPointerEnter:o.onPointerEnter,onPointerLeave:o.onPointerLeave,onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onKeyDown:o.onKeyDown,...Fv(o),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${fl}px solid transparent`,borderRight:`${fl}px solid transparent`,...e==="down"?{top:0,borderTop:`${ml}px solid ${n}`}:{bottom:0,borderBottom:`${ml}px solid ${n}`},transition:"border-color 0.1s"}})})}function $N(e){return jsxRuntime.jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:Nv(e,fl*2,{top:gr+1,height:hf}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...Fv(e),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:1,top:0,width:fl*2-2,height:hf,backgroundColor:Iv(e),borderRadius:1,transition:"background-color 0.1s"}})})}function zN({value:e,positionPx:t}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:_t(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 VN={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function GN({tabMark:e,positionPx:t,onDoubleClick:o}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:_t(t-5),top:gr-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:VN[e.alignment]||"L"})}var JN=15840,Av=1440,Vc=1440,Gc=567,Ma=20,QN="var(--doc-text-muted)",e5="var(--doc-text-subtle)",t5="var(--doc-primary)",o5="var(--doc-primary)",n5="var(--doc-primary-hover)";function gl({pageSetup:e,zoom:t=1,editable:o=false,onTopMarginChange:n,onBottomMarginChange:r,onMarginDragEnd:i,unit:a="inch",className:l="",style:s}){let{t:c}=H(),d=lt(),[m,u]=Zt.useState(null),[g,p]=Zt.useState(null),f=Zt.useRef(null),b=e?.pageHeightTwips??JN,y=e?.marginsTwips.top??Av,v=e?.marginsTwips.bottom??Av,x=(_,L)=>{if(!o||_.altKey||_.ctrlKey||_.metaKey||!["ArrowUp","ArrowDown","Home","End"].includes(_.key))return;_.preventDefault();let N=L==="topMargin"?y:v,F=Math.max(0,b-(L==="topMargin"?v:y)-720),D=_.shiftKey?1:Math.round(a==="cm"?Gc/10:Vc/8),R=_.key==="Home"?0:_.key==="End"?F:Math.max(0,Math.min(F,N+(_.key==="ArrowUp"?D:-D)));R!==N&&((L==="topMargin"?n:r)?.(R),i?.());},h=$e(b)*t,k=$e(y)*t,E=$e(v)*t,C=Zt.useCallback((_,L)=>{o&&(_.preventDefault(),u(L));},[o]),T=Zt.useCallback(_=>{if(!m||!f.current)return;let L=f.current.getBoundingClientRect(),N=_.clientY-L.top,B=ec(N/t);if(m==="topMargin"){let F=b-v-720,D=Math.max(0,Math.min(B,F));n?.(Math.round(D));}else if(m==="bottomMargin"){let F=b-B,D=b-y-720,R=Math.max(0,Math.min(F,D));r?.(Math.round(R));}},[m,t,b,y,v,n,r]),S=Zt.useCallback(()=>{m!==null&&i?.(),u(null);},[m,i]);Zt.useEffect(()=>{if(m){let _=editor.hostDocumentOf(f.current);return _.addEventListener("mousemove",T),_.addEventListener("mouseup",S),()=>{_.removeEventListener("mousemove",T),_.removeEventListener("mouseup",S);}}},[m,T,S]);let P=a5(b,t,a),w={position:"relative",width:Ma,height:_t(h),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:m?"ns-resize":"default",...s};return jsxRuntime.jsxs("div",{ref:f,className:`docx-vertical-ruler ${l}`,style:w,dir:d,role:"group","aria-label":c("ruler.vertical"),children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,insetInlineStart:0,insetInlineEnd:0,bottom:0,pointerEvents:"none"},children:P.map((_,L)=>jsxRuntime.jsx(r5,{tick:_},L))}),jsxRuntime.jsx(Ov,{type:"topMargin",value:y,maximum:Math.max(0,b-v-720),valueText:y/(a==="cm"?Gc:Vc),unit:a,onKeyDown:_=>x(_,"topMargin"),position:k,editable:o,isDragging:m==="topMargin",isHovered:g==="topMargin",onMouseEnter:()=>p("topMargin"),onMouseLeave:()=>p(null),onMouseDown:_=>C(_,"topMargin")}),jsxRuntime.jsx(Ov,{type:"bottomMargin",value:v,maximum:Math.max(0,b-y-720),valueText:v/(a==="cm"?Gc:Vc),unit:a,onKeyDown:_=>x(_,"bottomMargin"),position:h-E,editable:o,isDragging:m==="bottomMargin",isHovered:g==="bottomMargin",onMouseEnter:()=>p("bottomMargin"),onMouseLeave:()=>p(null),onMouseDown:_=>C(_,"bottomMargin")})]})}function r5({tick:e}){let t={position:"absolute",top:_t(e.position),insetInlineEnd:0,height:1,width:e.width,backgroundColor:e5},o={position:"absolute",top:_t(e.position),insetInlineStart:2,transform:"translateY(-50%)",fontSize:"9px",color:QN,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 Ov({type:e,position:t,value:o,maximum:n,valueText:r,unit:i,onKeyDown:a,editable:l,isDragging:s,isHovered:c,onMouseEnter:d,onMouseLeave:m,onMouseDown:u}){let{t:g}=H(),p=s?n5:c?o5:t5,f={position:"absolute",top:_t(t-5),insetInlineEnd:0,width:Ma,height:10,cursor:l?"ns-resize":"default",zIndex:s?10:1},b={position:"absolute",top:0,insetInlineEnd:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderInlineEnd:`8px solid ${p}`,transition:"border-inline-end-color 0.1s"};return jsxRuntime.jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:f,onMouseEnter:d,onMouseLeave:m,onMouseDown:u,role:"slider","aria-label":g(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":n,"aria-valuetext":`${r.toFixed(2)} ${i==="cm"?"cm":"in"}`,"aria-disabled":!l,onKeyDown:a,tabIndex:l?0:-1,children:jsxRuntime.jsx("div",{style:b})})}function a5(e,t,o){let n=[];if(o==="inch"){let r=Vc/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=$e(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=Gc/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=$e(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 c5=e=>e.formatting?.indent??null,d5=e=>e.editable,u5={type:"setIndent",left:0};function Cf(){let e=A(),t=W(c5),o=W(d5),{isEnabled:n}=re(u5),r=o&&n,i=Zt.useCallback(a=>e?e.exec({...a.left!==void 0?{left:a.left}:{},...a.right!==void 0?{right:a.right}:{},...a.firstLine!==void 0?{firstLine:a.firstLine}:{},type:"setIndent"}).ok:false,[e]);return Zt.useMemo(()=>({indent:t,isEnabled:r,apply:i}),[t,r,i])}var Kv=e=>e.zoom,m5=e=>e.isOpening===true;function qv(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function Uv(){let{apply:e}=er(),[t,o]=Zt.useState({}),n=Zt.useRef({}),r=Zt.useCallback(a=>l=>{n.current={...n.current,[a]:Math.round(l)},o(n.current);},[]),i=Zt.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 Zv(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function f5(){let e=A(),{indent:t,isEnabled:o,apply:n}=Cf(),[r,i]=Zt.useState(null),a=Zt.useRef(null),l=Zt.useRef(null),s=Zt.useCallback(m=>{l.current===null&&(l.current=Zv(e)),a.current=m,i(m);},[e]),c=Zt.useCallback(()=>{let m=a.current,u=l.current;a.current=null,l.current=null,i(null),m&&(u!==null&&u!==Zv(e)||n({left:m.left,right:m.right,firstLine:m.firstLine}));},[e,n]),d=Zt.useMemo(()=>r??(t?{left:t.left,right:t.right,firstLine:t.firstLine,...t.rtl?{rtl:true}:{}}:null),[r,t]);return Zt.useMemo(()=>({indent:d,isEnabled:o,preview:s,commit:c}),[d,o,s,c])}function g5(){let e=we(),[t,o]=Zt.useState(0);return Zt.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 Yc(e){let t=W(so),o=W(m5),{pageSetup:n,isEnabled:r}=er(),i=W(Kv),{pending:a,preview:l,commit:s}=Uv(),c=f5(),d=zn(),m=nc(),u=m==="left",g=sy(En(),m),p=g5();return t?null:jsxRuntime.jsx("div",{className:`docx-ruler-frame${o?" docx-ruler-frame--opening":""}`,...u?{"data-chrome-dir":"rtl"}:{},style:{paddingLeft:(u?0:d)+g.left,paddingRight:(u?d:0)+g.right},children:jsxRuntime.jsx(br,{pageSetup:qv(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(${-p}px)`,clipPath:d>0&&p!==0?p>0?`inset(0 0 0 ${p}px)`:`inset(0 ${-p}px 0 0)`:e.style?.clipPath}})})}function Xc(e){let t=W(so),{pageSetup:o,isEnabled:n}=er(),r=W(Kv),{pending:i,preview:a,commit:l}=Uv(),s=zn(),c=En(),d=dy();return t||d!==null&&d>0&&o&&$e(o.pageWidthTwips)*r>d-s-c.inlineStart-c.inlineEnd?null:jsxRuntime.jsx(gl,{pageSetup:qv(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 Z({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 $v(e){return jsxRuntime.jsx(Z,{...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 zv(e){return jsxRuntime.jsx(Z,{...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 Vv(e){return jsxRuntime.jsx(Z,{...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 Gv(e){return jsxRuntime.jsxs(Z,{...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 jv(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function Yv(e){return jsxRuntime.jsx(Z,{...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 Xv(e){return jsxRuntime.jsx(Z,{...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 Jv(e){return jsxRuntime.jsx(Z,{...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 Qv(e){return jsxRuntime.jsx(Z,{...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 eC(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M500-520h80v-80h80v-80h-80v-80h-80v80h-80v80h80v80Zm-80 160h240v-80H420v80ZM320-200q-33 0-56.5-23.5T240-280v-560q0-33 23.5-56.5T320-920h280l240 240v400q0 33-23.5 56.5T760-200H320Zm0-80h440v-360L560-840H320v560ZM160-40q-33 0-56.5-23.5T80-120v-560h80v560h440v80H160Zm160-240v-560 560Z"})})}function tC(e){return jsxRuntime.jsx(Z,{...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 oC(e){return jsxRuntime.jsx(Z,{...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 nC(e){return jsxRuntime.jsx(Z,{...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 y5(e){return jsxRuntime.jsx(Z,{...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 x5(e){return jsxRuntime.jsx(Z,{...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 v5(e){return jsxRuntime.jsx(Z,{...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 C5(e){return jsxRuntime.jsx(Z,{...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 T5(e){return jsxRuntime.jsx(Z,{...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 E5(e){return jsxRuntime.jsx(Z,{...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 S5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function P5(e){return jsxRuntime.jsx(Z,{...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 k5(e){return jsxRuntime.jsx(Z,{...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 w5(e){return jsxRuntime.jsx(Z,{...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 D5(e){return jsxRuntime.jsx(Z,{...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 R5(e){return jsxRuntime.jsx(Z,{...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 M5(e){return jsxRuntime.jsx(Z,{...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 _5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M40-40v-240h80v-400H40v-240h240v80h400v-80h240v240h-80v400h80v240H680v-80H280v80H40Zm240-160h400v-80h80v-400h-80v-80H280v80h-80v400h80v80Zm32-120 136-360h64l136 360h-62l-32-92H408l-32 92h-64Zm114-144h108l-52-150h-4l-52 150ZM120-760h80v-80h-80v80Zm640 0h80v-80h-80v80Zm0 640h80v-80h-80v80Zm-640 0h80v-80h-80v80Zm80-640Zm560 0Zm0 560Zm-560 0Z"})})}function I5(e){return jsxRuntime.jsx(Z,{...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 N5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function F5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function L5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function H5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function Pf(e){return jsxRuntime.jsx(Z,{...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 A5(e){return jsxRuntime.jsx(Z,{...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 O5(e){return jsxRuntime.jsx(Z,{...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 B5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function W5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function Z5(e){return jsxRuntime.jsx(Z,{...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 K5(e){return jsxRuntime.jsx(Z,{...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 q5(e){return jsxRuntime.jsx(Z,{...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 U5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function $5(e){return jsxRuntime.jsx(Z,{...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 z5(e){return jsxRuntime.jsx(Z,{...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 V5(e){return jsxRuntime.jsx(Z,{...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 G5(e){return jsxRuntime.jsx(Z,{...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 j5(e){return jsxRuntime.jsx(Z,{...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 rC(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function Y5(e){return jsxRuntime.jsx(Z,{...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 X5(e){return jsxRuntime.jsx(Z,{...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 J5(e){return jsxRuntime.jsx(Z,{...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 Q5(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function e6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function t6(e){return jsxRuntime.jsx(Z,{...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 o6(e){return jsxRuntime.jsx(Z,{...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 n6(e){return jsxRuntime.jsx(Z,{...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 r6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function a6(e){return jsxRuntime.jsx(Z,{...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 i6(e){return jsxRuntime.jsx(Z,{...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 l6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function s6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function c6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function d6(e){return jsxRuntime.jsx(Z,{...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 u6(e){return jsxRuntime.jsx(Z,{...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 p6(e){return jsxRuntime.jsx(Z,{...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 m6(e){return jsxRuntime.jsx(Z,{...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 f6(e){return jsxRuntime.jsx(Z,{...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 g6(e){return jsxRuntime.jsx(Z,{...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 b6(e){return jsxRuntime.jsx(Z,{...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 h6(e){return jsxRuntime.jsx(Z,{...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 y6(e){return jsxRuntime.jsx(Z,{...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 x6(e){return jsxRuntime.jsx(Z,{...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 v6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function C6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function T6(e){return jsxRuntime.jsx(Z,{...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 E6(e){return jsxRuntime.jsx(Z,{...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 S6(e){return jsxRuntime.jsx(Z,{...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 P6(e){return jsxRuntime.jsx(Z,{...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 k6(e){return jsxRuntime.jsx(Z,{...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 w6(e){return jsxRuntime.jsx(Z,{...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 D6(e){return jsxRuntime.jsx(Z,{...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 R6(e){return jsxRuntime.jsx(Z,{...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 M6(e){return jsxRuntime.jsx(Z,{...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 _6(e){return jsxRuntime.jsx(Z,{...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 I6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function N6(e){return jsxRuntime.jsx(Z,{...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 F6(e){return jsxRuntime.jsx(Z,{...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 L6(e){return jsxRuntime.jsx(Z,{...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 H6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function A6(e){return jsxRuntime.jsx(Z,{...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 O6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function B6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function W6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function Z6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function K6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function q6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function U6(e){return jsxRuntime.jsx(Z,{...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 $6(e){return jsxRuntime.jsx(Z,{...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 z6(e){return jsxRuntime.jsx(Z,{...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 V6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function G6(e){return jsxRuntime.jsx(Z,{...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 j6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function Y6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M200-120v-640q0-33 23.5-56.5T280-840h400q33 0 56.5 23.5T760-760v640L480-240 200-120Zm80-122 200-86 200 86v-518H280v518Zm0-518h400-400Z"})})}function X6(e){return jsxRuntime.jsx(Z,{...e,children:jsxRuntime.jsx("path",{d:"M120-40v-640q0-33 23.5-56.5T200-760h400q33 0 56.5 23.5T680-680v640L400-160 120-40Zm80-122 200-86 200 86v-518H200v518Zm560 2v-680H240v-80h520q33 0 56.5 23.5T840-840v680h-80ZM200-680h400-400Z"})})}function J6(e){return jsxRuntime.jsx(Z,{...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 Q6(e){return jsxRuntime.jsx(Z,{...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 eF(e){return jsxRuntime.jsx(Z,{...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 tF={undo:y5,redo:x5,print:v5,file_download:C5,file_upload:T5,format_bold:E5,format_italic:S5,format_underlined:P5,strikethrough_s:k5,superscript:w5,subscript:D5,link:R5,format_clear:I5,format_paragraph:M5,format_shapes:_5,lock:nC,format_align_left:N5,format_align_center:F5,format_align_right:L5,format_align_justify:H5,format_line_spacing:Pf,format_list_bulleted:A5,format_list_numbered:O5,format_indent_increase:B5,format_indent_decrease:W5,format_color_text:Z5,ink_highlighter:K5,format_color_reset:q5,arrow_drop_down:U5,table:$5,table_chart:z5,grid_on:V5,table_rows:G5,view_column:j5,border_all:rC,select_all:rC,border_outer:Y5,border_inner:X5,border_clear:J5,add:Q5,remove:e6,delete:t6,delete_sweep:o6,call_merge:n6,call_split:r6,drag_indicator:a6,image:i6,format_image_left:l6,format_image_right:s6,horizontal_rule:c6,flip_to_back:d6,flip_to_front:u6,open_with:p6,tune:m6,rotate_right:f6,rotate_left:g6,swap_horiz:b6,swap_vert:h6,shapes:y6,format_paint:x6,expand_more:v6,expand_less:C6,border_top:T6,border_bottom:E6,border_left:S6,border_right:P6,border_horizontal:k6,border_vertical:w6,padding:D6,text_rotation_none:R6,wrap_text:M6,height:_6,fit_width:I6,settings:N6,border_color:F6,format_color_fill:L6,vertical_align_top:H6,vertical_align_center:A6,vertical_align_bottom:O6,line_weight:B6,keyboard_arrow_up:W6,keyboard_arrow_down:Z6,keyboard_arrow_left:K6,keyboard_arrow_right:q6,more_vert:U6,page_break:$6,branding_watermark:z6,arrow_back:V6,search:G6,toc:j6,bookmark:Y6,bookmarks:X6,done_all:$v,check_circle:zv,chat_bubble_outline:Vv,chat_bubble_check:Gv,check:jv,close:Yv,add_comment:Xv,comment:Jv,edit_note:Qv,difference:eC,rate_review:tC,visibility:oC,format_textdirection_l_to_r:J6,format_textdirection_r_to_l:Q6,"agent-sparkle":eF};function G({name:e,size:t=20,className:o="",style:n}){let r=tF[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 bl=12,kf=240,iC=16,lF=24,sF=bl+kf+iC,_a=12,cF=36,dF=_a+cF+iC,hl=Zt__namespace.default.memo(function({headings:t,onHeadingClick:o,onClose:n,topOffset:r=0,scrollLeft:i=0,leftOffset:a=bl}){let{t:l}=H(),[s,c]=Zt.useState(false),d=Zt.useRef(null),m=t.length?Math.min(...t.map(u=>u.level)):0;return Zt.useEffect(()=>{editor.hostWindowOf(d.current).requestAnimationFrame(()=>c(true));},[]),jsxRuntime.jsxs("nav",{ref:d,className:"docx-outline-nav",role:"navigation","aria-label":l("documentOutline.ariaLabel"),style:{position:"absolute",top:r,left:a-i,bottom:0,width:kf,paddingTop:lF,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:s?"translateX(0)":`translateX(-${a+kf}px)`,transition:"transform 0.15s ease-out"},onMouseDown:u=>u.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(G,{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((u,g)=>jsxRuntime.jsx("div",{style:{marginLeft:(u.level-m)*16},children:jsxRuntime.jsx("button",{className:"docx-outline-heading-btn",onClick:()=>o(u.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:u.text,children:u.text})},`${u.blockId}-${g}`))})]})});var mF=e=>e,fF=Object.freeze([]),gF=()=>{};function wf(e){let t=A(),o=W(mF),n=Zt.useMemo(()=>t&&!o.isLoading?t.getOutline():fF,[t,o]),r=Zt.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 so(o)?null:jsxRuntime.jsx(hl,{headings:n,onHeadingClick:r,onClose:e.onClose??gF,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var Df=Zt.createContext(null);function No(e){let t=Zt.useContext(Df);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var CF={ok:false,code:"unsupported",reason:"editor is not ready"},sC=Object.freeze([]);function Jc(e={}){let t=e.enabled??true,o=A(),n=Zt.useCallback(S=>t?o?.query({type:"bookmarks"})??sC:sC,[o,t]),r=W(n,fp),[i,a]=Zt.useState(""),[l,s]=Zt.useState("name"),[c,d]=Zt.useState(false),[m,u]=Zt.useState(null),[g,p]=Zt.useState(null),[f,b]=Zt.useState(""),y=Zt.useMemo(()=>editor.goToBookmarkRows(r,{query:i,sortBy:l,showHidden:c}),[r,i,l,c]),v=Zt.useMemo(()=>m===null?-1:y.findIndex(S=>S.name===m),[y,m]),x=Zt.useCallback(S=>{a(S),u(null),p(null);},[]),h=Zt.useCallback(S=>{s(S),u(null),p(null);},[]),k=Zt.useCallback(S=>{d(S),u(null),p(null);},[]),E=Zt.useCallback(S=>{if(y.length===0)return;let P=v<0?S>0?-1:0:v;u(y[(P+S+y.length)%y.length].name);},[y,v]),C=Zt.useCallback(S=>u(y[S]?.name??null),[y]),T=Zt.useCallback(S=>{if(!o)return CF;let P=S??y[v]?.name??editor.goToBookmarkTarget(r,i,y)?.name;if(P===void 0||P.trim().length===0){let _=i.trim();return p(_.length===0?"empty":"notFound"),b(_),{ok:false,code:"notFound",reason:"no bookmark is named that"}}let w=o.exec({type:"goToBookmark",name:P});return p(w.ok?null:w.code==="notFound"?"notFound":"failed"),b(w.ok?"":P),w},[o,y,v,r,i]);return {query:i,setQuery:x,sortBy:l,setSortBy:h,showHidden:c,setShowHidden:k,rows:y,bookmarks:r,activeIndex:v,move:E,setActiveIndex:C,go:T,problem:g,problemName:f}}var cC=(...e)=>e.filter(Boolean).join(" "),wF={header:"navigation.goTo.places.header",footer:"navigation.goTo.places.footer",footnote:"navigation.goTo.places.footnote",endnote:"navigation.goTo.places.endnote"},DF={body:"navigation.goTo.groups.body",header:"navigation.goTo.groups.header",footer:"navigation.goTo.groups.footer",footnote:"navigation.goTo.groups.footnote",endnote:"navigation.goTo.groups.endnote"};function RF(){return jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:"M5.5 2.5h5M5.5 13.5h5M8 2.5v11",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})})}function MF({name:e,query:t}){let o=editor.goToBookmarkMatch(e,t);return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e.slice(0,o.start),jsxRuntime.jsx("span",{className:"docx-nav__goto-match",children:e.slice(o.start,o.end)}),e.slice(o.end)]}):e}function yl({className:e,style:t}){let{pane:o,intents:n,t:r}=No("GoTo"),i=A(),a=o.tab!=="goto",l=Jc({enabled:o.open&&!a}),s=re("insert.bookmark"),c=W(so),d=Zt.useId(),m=`${d}-list`,u=`${d}-label`,g=`${d}-hint`,p=C=>`${d}-option-${C}`,f=Zt.useRef(null);Zt.useEffect(()=>{if(l.activeIndex<0)return;let C=`${d}-option-${l.activeIndex}`;f.current?.querySelector(`[id="${C}"]`)?.scrollIntoView?.({block:"nearest"});},[l.activeIndex,d]);let b=C=>{l.go(C).ok&&(n.picked(),i?.focus());},y=C=>{C.nativeEvent.isComposing||(C.key==="ArrowDown"||C.key==="ArrowUp"?(C.preventDefault(),l.move(C.key==="ArrowDown"?1:-1)):(C.key==="Home"||C.key==="End")&&l.activeIndex>=0?(C.preventDefault(),l.setActiveIndex(C.key==="Home"?0:l.rows.length-1)):C.key==="Enter"?(C.preventDefault(),b()):C.key==="Escape"&&l.query.length>0&&(C.preventDefault(),l.setQuery("")));},v=l.problem==="notFound"?r("navigation.goTo.notFound",{name:l.problemName}):l.problem==="failed"?r("navigation.goTo.failed"):l.problem==="empty"?r("navigation.goTo.typeName"):l.bookmarks.length>0&&l.rows.length===0?r("navigation.goTo.noMatches"):"",x=l.activeIndex>=0?p(l.activeIndex):void 0,h=l.sortBy==="location",k=l.bookmarks.length===0,E=(C,T)=>{let S=T===l.activeIndex;return jsxRuntime.jsxs("li",{id:p(T),role:"option","aria-selected":S,className:cC("docx-nav__goto-row",S&&"docx-nav__goto-row--active"),"data-point":C.empty||void 0,onMouseDown:P=>P.preventDefault(),onClick:()=>b(C.name),children:[jsxRuntime.jsx("span",{className:"docx-nav__goto-icon","aria-hidden":"true",children:C.empty?jsxRuntime.jsx(RF,{}):jsxRuntime.jsx(G,{name:"bookmark",size:16})}),jsxRuntime.jsx("span",{className:"docx-nav__result-text",children:jsxRuntime.jsx("bdi",{children:jsxRuntime.jsx(MF,{name:C.name,query:l.query})})}),C.atSelection&&jsxRuntime.jsx("span",{className:"docx-nav__goto-here",title:r("navigation.goTo.atCaret"),children:jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:r("navigation.goTo.atCaret")})}),!h&&C.place!=="body"&&jsxRuntime.jsx("span",{className:"docx-nav__goto-place",children:r(wF[C.place])})]},C.name)};return jsxRuntime.jsxs("div",{className:cC("docx-nav__panel docx-nav__panel--goto",e),style:t,role:"tabpanel",id:"docx-nav-panel-goto","aria-labelledby":"docx-nav-tab-goto",hidden:a,children:[jsxRuntime.jsxs("div",{className:"docx-nav__searchbox",children:[jsxRuntime.jsx(G,{name:"bookmark",size:18,className:"docx-nav__search-icon"}),jsxRuntime.jsx("input",{type:"text",role:"combobox",className:"docx-nav__search-input",value:l.query,placeholder:r("navigation.goTo.placeholder"),"aria-label":r("navigation.goTo.label"),"aria-describedby":x?g:void 0,"aria-expanded":l.rows.length>0,"aria-controls":l.rows.length>0?m:void 0,"aria-autocomplete":"list","aria-activedescendant":x,autoComplete:"off",spellCheck:false,onChange:C=>l.setQuery(C.target.value),onKeyDown:y}),x&&jsxRuntime.jsx("kbd",{className:"docx-nav__goto-enter","aria-hidden":"true",children:"\u21B5"}),jsxRuntime.jsx("span",{id:g,className:"docx-editor-sr-only",children:r("navigation.goTo.enterHint")})]}),jsxRuntime.jsxs("div",{className:"docx-nav__goto-controls",children:[jsxRuntime.jsx("div",{className:"docx-nav__segmented",role:"radiogroup","aria-label":r("dialogs.bookmark.sortBy"),children:["name","location"].map(C=>jsxRuntime.jsxs("label",{className:"docx-nav__segment","data-checked":l.sortBy===C||void 0,children:[jsxRuntime.jsx("input",{type:"radio",className:"docx-nav__segment-input",name:`${d}-sort`,checked:l.sortBy===C,onChange:()=>l.setSortBy(C)}),r(C==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},C))}),jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:l.showHidden,onChange:C=>l.setShowHidden(C.target.checked)}),r("dialogs.bookmark.showHidden")]})]}),k&&!c&&jsxRuntime.jsxs("div",{className:"docx-nav__goto-empty",children:[jsxRuntime.jsx(G,{name:"bookmark",size:24,className:"docx-nav__goto-empty-icon"}),jsxRuntime.jsx("p",{className:"docx-nav__goto-empty-title",children:r("navigation.goTo.empty")}),jsxRuntime.jsx("p",{className:"docx-nav__goto-empty-hint",children:r("navigation.goTo.emptyHint")}),jsxRuntime.jsx("button",{type:"button",className:"docx-nav__goto-add",disabled:!s.isEnabled,title:s.disabledReason??void 0,onClick:()=>s.execute(),children:r("navigation.goTo.add")})]}),!k&&jsxRuntime.jsxs("div",{className:"docx-nav__goto-heading",children:[jsxRuntime.jsx("span",{id:u,children:r("navigation.goTo.listAriaLabel")}),jsxRuntime.jsx("span",{className:"docx-nav__goto-count",children:l.query.trim().length>0?r("navigation.goTo.countFiltered",{shown:l.rows.length,total:l.bookmarks.filter(C=>l.showHidden||!C.hidden).length}):l.rows.length})]}),jsxRuntime.jsx("p",{className:"docx-nav__goto-message",role:"status",children:v}),l.rows.length>0&&jsxRuntime.jsx("ul",{ref:f,id:m,className:"docx-nav__list docx-nav__goto-list",role:"listbox","aria-labelledby":u,children:h?editor.goToBookmarkGroups(l.rows).map(C=>jsxRuntime.jsxs("li",{role:"group","aria-labelledby":`${d}-group-${C.place}`,className:"docx-nav__goto-group",children:[jsxRuntime.jsx("div",{id:`${d}-group-${C.place}`,className:"docx-nav__goto-group-label",children:r(DF[C.place])}),jsxRuntime.jsx("ul",{role:"none",className:"docx-nav__goto-sublist",children:C.rows.map(({row:T,index:S})=>E(T,S))})]},C.place)):l.rows.map((C,T)=>E(C,T))})]})}var Na=280,Qc=32,dC=16;function Fa(e=280){return 32+e+16}function ed({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 Rf=320;function td(e,t){return !Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?false:e-t<Rf}var FF=Object.freeze([]),LF=e=>e;function od(){let e=A(),t=W(LF),[o,n]=Zt.useState(null),r=Zt.useMemo(()=>e&&!t.isLoading?e.getOutline():FF,[e,t]),i=Zt.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=Zt.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 hC=Object.freeze({query:"",matchCase:false,wholeWord:false,matches:Object.freeze([]),truncated:false,activeIndex:-1,activeMatch:null,isPending:false}),BF=()=>()=>{},pC=()=>hC;function nd(e={}){let t=e.highlight??"all",o=A(),n=Zt.useMemo(()=>o?editor.createDocumentSearch(o):null,[o]),r=Zt.useSyncExternalStore(n?n.subscribe:BF,n?n.getState:pC,n?n.getState:pC);Zt.useEffect(()=>{if(!(!n||t==="none"))return n.showHighlights(t)},[n,t]);let i=Zt.useMemo(()=>({setQuery:a=>n?.setQuery(a),find:(a,l)=>n?.find(a,l)??hC.matches,setMatchCase:a=>n?.setMatchCase(a),setWholeWord:a=>n?.setWholeWord(a),goTo:a=>n?.goTo(a)??false,next:()=>n?.next()??false,previous:()=>n?.previous()??false,clear:()=>n?.clear()}),[n]);return Zt.useMemo(()=>({...r,...i}),[r,i])}function TC(e,t=i18n.isApplePlatform()){return e.altKey||e.shiftKey||e.isComposing||(t?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey)?false:editor.chordLetter(e)==="f"}var EC=editor.isGoToChord;function SC(e=i18n.isApplePlatform()){return e?"Ctrl+Alt+G":"Ctrl+G"}function PC(e=i18n.isApplePlatform()){return e?"Meta+Alt+G":"Control+G"}function kC(e){return e.startsWith("Ctrl")?"Control+F":"Meta+F"}function wC(e,t,o){if(e?.isConnected){o&&e.closest(".docx-pages")?o():e.focus({preventScroll:true});return}if(e&&o){o();return}t?t.focus({preventScroll:true}):o?.();}function DC(e,t,o){if(!editor.isDomNode(e))return false;if(t?.contains(e))return true;if(!o)return false;if(o.contains(e))return true;let n=editor.isElementNode(e)?e:e.parentElement;if(!n)return false;let r=editor.editorInstanceScope(o);if(r&&r!==o&&r.contains(n))return true;if(!n.closest(".docx-editor")||editor.editorInstanceScope(n)!==null)return false;let i=o.ownerDocument.querySelectorAll(".docx-editor__scroll-container");return i.length===1&&i[0]===o}function If(e,t){let o=e?.querySelector(`#docx-nav-panel-${t}`);if(!o)return null;if(t==="headings"){let n=o.querySelector(".docx-nav__heading--current")??o.querySelector(".docx-nav__heading");if(n)return n}return o.querySelector(".docx-nav__search-input")}function Nf(e){e.focus(),e.localName==="input"&&e.select();}function UF(e){let o=e.querySelector('[role="tab"][aria-selected="true"]')?.id??"",r=If(e,o==="docx-nav-tab-find"?"find":o==="docx-nav-tab-goto"?"goto":"headings");if(r){Nf(r);return}editor.isHTMLElementNode(e)&&(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus());}function $F(e,t){let o=[];if(t.contains(e)){let i=e;for(;i!==t&&i.parentElement;){for(let a of i.parentElement.children)a!==i&&o.push(a);i=i.parentElement;}}else o.push(...t.children);let n=e.ownerDocument.activeElement;n&&o.some(i=>i.contains(n))&&UF(e);let r=[];for(let i of o)i.hasAttribute("inert")||(i.setAttribute("inert",""),r.push(i));return ()=>{for(let i of r)i.removeAttribute("inert");r.length=0;}}function RC(e,t,o){let n=$F(e,t),r=i=>{editor.isDomNode(i.target)&&e.contains(i.target)||o();};return t.addEventListener("pointerdown",r),()=>{t.removeEventListener("pointerdown",r),n();}}function vC(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function MC(e,t){let o=()=>{let i=editor.hostWindowOf(t).getComputedStyle(t),a=t.clientHeight-vC(i.paddingTop)-vC(i.paddingBottom);e.style.setProperty("--docx-nav-block-size",`${Math.max(0,Math.round(a))}px`),e.style.setProperty("--docx-nav-inline-size",`${Math.round(t.clientWidth)}px`);};o();let n=editor.hostWindowOf(t).ResizeObserver;if(typeof n>"u")return ()=>{};let r=new n(o);return r.observe(t),()=>r.disconnect()}function IC(e,t=true,o=true){let n=A(),r=we(),i=Zt.useRef(null),a=Zt.useRef(null),l=Zt.useRef(false),s=Zt.useRef(false),c=Zt.useRef(false),d=Zt.useRef(0),m=Zt.useCallback(()=>{let E=++d.current;editor.hostWindowOf(i.current).setTimeout(()=>{d.current===E&&(l.current=false,s.current=false,c.current=false);},0);},[]),u=Zt.useRef(e);u.current=e;let g=Zt.useCallback(()=>{l.current=false;let E=If(i.current,u.current.tab);E&&Nf(E);},[]),p=Zt.useCallback(()=>{s.current=false;let E=a.current;a.current=null;let C=i.current?.querySelector(".docx-nav__toggle")??null;wC(E,C,n?()=>n.focus():null);},[n]),f=Zt.useRef(p);f.current=p,Zt.useEffect(()=>()=>{s.current&&f.current();},[]);let b=Zt.useCallback(()=>{l.current=false,s.current=true,u.current.setOpen(false),m();},[m]),y=Zt.useCallback((E,C)=>{C&&!i.current?.contains(C)&&(a.current=C),s.current=false;let T=u.current;if(T.open&&T.tab===E){g();return}l.current=true,T.tab!==E&&T.setTab(E),T.open||T.setOpen(true),m();},[g,m]),v=Zt.useMemo(()=>({openTab:E=>{let C=i.current?.ownerDocument.activeElement;y(E,editor.isHTMLElementNode(C)?C:null);},toggle:()=>{if(u.current.open){b();return}a.current=null,s.current=false,l.current=true,u.current.setOpen(true),m();},close:b,picked:()=>{let E=u.current;if(!E.overlay)return;let C=i.current?.ownerDocument.activeElement;c.current=!!C&&!!i.current?.contains(C),E.setOpen(false),m();}}),[b,m,y]),x=Zt.useRef(v);x.current=v,Zt.useEffect(()=>{let E=i.current?.ownerDocument;if(!E||!t&&!o)return;let C=T=>{if(T.defaultPrevented)return;let S=t&&TC(T)?"find":o&&EC(T)?"goto":null;if(!S||!DC(T.target,i.current,r))return;if(S==="goto"&&n?.can({type:"openGoTo"}).ok){n.exec({type:"openGoTo",fromShortcut:true}).ok&&T.preventDefault();return}T.preventDefault();let P=E.activeElement;y(S,editor.isHTMLElementNode(P)?P:null);};return E.addEventListener("keydown",C),()=>E.removeEventListener("keydown",C)},[r,t,o,y,n]),Zt.useEffect(()=>{l.current&&(u.current.open?g():l.current=false),s.current&&(u.current.open?s.current=false:p()),c.current&&(c.current=false,u.current.open||n?.focus());});let h=e.open&&e.overlay;Zt.useEffect(()=>{let E=i.current;if(!(!h||!E||!r))return RC(E,r,()=>x.current.close())},[h,r]),Zt.useEffect(()=>{let E=i.current;if(!(!E||!r||!r.contains(E)))return MC(E,r)},[r]);let k=Zt.useCallback(E=>{E.key!=="Escape"||E.defaultPrevented||E.nativeEvent.isComposing||u.current.open&&(E.preventDefault(),b());},[b]);return {rootRef:i,intents:v,onKeyDown:k}}var jF=150;function YF(e){return e.source!==void 0?true:(e.created?.length??0)>0||(e.deleted?.length??0)>0}function XF(e){let t=0;for(let o of e)t=Math.max(t,o.box.width);return t>0?t:null}function NC(e,t,o=()=>null){let n=editor.hostTimers(o),r=null,i=false,a=()=>{r=null,i||t(XF(e.getPageGeometry()));},l=()=>{i||(n.clearTimeout(r),r=n.setTimeout(a,jF));},s=e.on("change",c=>{YF(c)&&l();});return a(),{nudge:l,dispose(){i=true,n.clearTimeout(r),r=null,s();}}}var oL=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)}},nL=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips,rL=e=>e.page.total;function rd(e={}){let{defaultOpen:t=false,defaultTab:o="headings",paneWidth:n=280}=e,[r,i]=Zt.useState(t),[a,l]=Zt.useState(o),s=e.open??r,c=e.tab??a,{onOpenChange:d,onTabChange:m}=e,u=e.open!==void 0,g=e.tab!==void 0,p=Zt.useCallback(O=>{u||i(O),d?.(O);},[u,d]),f=Zt.useCallback(()=>p(!s),[s,p]),b=Zt.useCallback(O=>{g||l(O),m?.(O);},[g,m]),y=$n(),v=we(),x=Zt.useContext(At),{pageSetup:h,zoom:k,reviewPaneOpen:E,fitting:C}=W(oL,nL),T=A(),S=W(rL),[P,w]=Zt.useState(0),[_,L]=Zt.useState(null),[N,B]=Zt.useState(0),[F,D]=Zt.useState(0),R=En();Zt.useEffect(()=>{if(!v){w(0),B(0),D(0);return}let O=()=>{w(v.clientWidth);let ge=editor.hostWindowOf(v).getComputedStyle(v),K=v.getAttribute("data-chrome-dir")==="rtl",de=Number.parseFloat(K?ge.paddingLeft:ge.paddingInlineEnd);B(Number.isFinite(de)?de:0);let ke=Number.parseFloat(ge.getPropertyValue("--docx-review-gutter-start"));D(Number.isFinite(ke)?ke:0);};O();let I=editor.hostWindowOf(v).ResizeObserver;if(typeof I>"u")return;let ie=new I(O);return ie.observe(v),()=>ie.disconnect()},[v,s,E,x?.mounted,x?.gutters,R]);let U=Zt.useRef(null);h&&(U.current=h.pageWidthTwips);let V=h?.pageWidthTwips??U.current,Y=Zt.useRef(null);Zt.useEffect(()=>{if(!s||!T)return;let O=NC(T,L,()=>v);return Y.current=O,()=>{O.dispose(),Y.current===O&&(Y.current=null);}},[s,T,v]),Zt.useEffect(()=>Y.current?.nudge(),[S,V]);let j=Fa(n),q=ly(R,N),X=s&&td(P-q,j),ee=Zt.useMemo(()=>!s||X||V===null?0:ed({viewportWidth:P,pageWidthPx:Math.max(_??0,$e(V))*k,reservation:j,inlineEndReservation:N,inlineStartReservation:F,docked:C}),[s,X,V,_,k,P,j,N,F,C]);return Zt.useEffect(()=>{if(y)return y.setShift(ee),()=>y.setShift(0)},[y,ee]),Zt.useEffect(()=>{if(y)return y.setReservation(s&&!X?j:0),()=>y.setReservation(0)},[y,s,X,j]),{open:s,setOpen:p,toggle:f,tab:c,setTab:b,paneWidth:n,shift:ee,overlay:X}}var Cl=["headings","find","goto"],Ho=(...e)=>e.filter(Boolean).join(" ");function Tl({className:e,style:t,children:o}){return jsxRuntime.jsx("div",{className:Ho("docx-nav__header",e),style:t,children:o??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(El,{}),jsxRuntime.jsx(Sl,{})]})})}function El({className:e,style:t,children:o}){let{intents:n,t:r}=No("Close");return jsxRuntime.jsx("button",{type:"button",className:Ho("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:n.close,children:o??jsxRuntime.jsx(G,{name:"arrow_back",size:20})})}function Sl({className:e,style:t,children:o}){let{t:n}=No("Title");return jsxRuntime.jsx("h2",{className:Ho("docx-nav__title",e),style:t,children:o??n("navigation.title")})}function Pl({className:e,style:t,children:o}){let{pane:n,t:r}=No("Tabs"),i=Zt.useCallback(a=>{let l=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(l===0)return;a.preventDefault();let s=Cl.indexOf(n.tab);n.setTab(Cl[(s+l+Cl.length)%Cl.length]);},[n]);return jsxRuntime.jsx("div",{className:Ho("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:i,children:o??Cl.map(a=>jsxRuntime.jsx(kl,{value:a},a))})}function kl({value:e,className:t,style:o,children:n}){let{pane:r,t:i,goToShortcut:a}=No("Tab"),l=eo(),s=r.tab===e,c=e==="goto"&&a?i("navigation.goTo.tabTitle",{shortcut:l(SC())}):void 0;return jsxRuntime.jsx("button",{type:"button",role:"tab",id:`docx-nav-tab-${e}`,"aria-selected":s,"aria-controls":`docx-nav-panel-${e}`,tabIndex:s?0:-1,className:Ho("docx-nav__tab",s&&"docx-nav__tab--selected",t),style:o,...c?{title:c,"aria-keyshortcuts":PC()}:{},onClick:()=>r.setTab(e),children:n??i(`navigation.tabs.${e}`)})}function HC({value:e,onChange:t,onClear:o,placeholder:n,label:r,clearLabel:i,autoFocus:a,onEnter:l}){let s=Zt.useRef(null);return Zt.useEffect(()=>{a&&s.current?.focus();},[a]),jsxRuntime.jsxs("div",{className:"docx-nav__searchbox",children:[jsxRuntime.jsx(G,{name:"search",size:18,className:"docx-nav__search-icon"}),jsxRuntime.jsx("input",{ref:s,type:"search",className:"docx-nav__search-input",value:e,placeholder:n,"aria-label":r,autoFocus:a,onChange:c=>t(c.target.value),onKeyDown:c=>{!l||c.key!=="Enter"||c.nativeEvent.isComposing||(c.preventDefault(),l(c.shiftKey));}}),e.length>0&&jsxRuntime.jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":i,onClick:o,children:jsxRuntime.jsx(G,{name:"close",size:16})})]})}function wl({className:e,style:t}){let{pane:o,outline:n,intents:r,t:i}=No("Headings"),[a,l]=Zt.useState(""),s=W(so),c=Zt.useMemo(()=>{let m=a.trim().toLowerCase();return m.length===0?n.items:n.items.filter(u=>u.heading.text.toLowerCase().includes(m))},[n.items,a]),d=o.tab!=="headings";return jsxRuntime.jsxs("div",{className:Ho("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:d,children:[jsxRuntime.jsx(HC,{value:a,onChange:l,onClear:()=>l(""),placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel")}),s?null:n.isEmpty?jsxRuntime.jsx("p",{className:"docx-nav__empty",children:i("navigation.headings.noHeadings")}):c.length===0?jsxRuntime.jsx("p",{className:"docx-nav__empty",children:i("navigation.find.noResults")}):jsxRuntime.jsx("ul",{className:"docx-nav__list",children:c.map((m,u)=>jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:Ho("docx-nav__heading",n.selectedBlockId===m.heading.blockId&&"docx-nav__heading--current"),style:{paddingInlineStart:`${8+m.depth*14}px`},title:m.heading.text,onClick:()=>{n.goTo(m.heading.blockId),r.picked();},children:jsxRuntime.jsx("bdi",{children:m.heading.text})})},`${m.heading.blockId}-${u}`))})]})}function dL({match:e,active:t,onSelect:o}){return jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:Ho("docx-nav__result",t&&"docx-nav__result--active"),"aria-current":t?"true":void 0,onClick:o,children:jsxRuntime.jsx("span",{className:"docx-nav__result-text",children:jsxRuntime.jsxs("bdi",{children:[e.contextBefore,jsxRuntime.jsx("mark",{className:"docx-nav__result-hit",children:e.text}),e.contextAfter]})})})})}function Dl({className:e,style:t}){let{pane:o,search:n,intents:r,t:i}=No("Find"),a=o.tab!=="find",l=n.query.trim().length>0,s=o.open&&!a,c=n.matches.length===0?null:n.activeIndex<0?i(n.truncated?"navigation.find.totalTruncated":"navigation.find.total",{total:n.matches.length}):i(n.truncated?"navigation.find.counterTruncated":"navigation.find.counter",{current:n.activeIndex+1,total:n.matches.length});return jsxRuntime.jsxs("div",{className:Ho("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:a,children:[jsxRuntime.jsx(HC,{value:n.query,onChange:n.setQuery,onClear:n.clear,placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel"),autoFocus:s,onEnter:d=>{n.isPending&&n.find(n.query),d?n.previous():n.next();}}),jsxRuntime.jsxs("div",{className:"docx-nav__options",role:"group","aria-label":i("navigation.find.optionsAriaLabel"),children:[jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.matchCase,onChange:d=>n.setMatchCase(d.target.checked)}),i("navigation.find.matchCase")]}),jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:n.wholeWord,onChange:d=>n.setWholeWord(d.target.checked)}),i("navigation.find.wholeWord")]})]}),jsxRuntime.jsxs("div",{className:"docx-nav__resultbar",children:[jsxRuntime.jsx("span",{className:"docx-nav__count","aria-live":"polite",children:l?n.isPending?i("navigation.find.searching"):c??i("navigation.find.noResults"):""}),jsxRuntime.jsxs("span",{className:"docx-nav__steppers",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.previousAriaLabel"),disabled:n.matches.length===0,onClick:n.previous,children:jsxRuntime.jsx(G,{name:"keyboard_arrow_up",size:18})}),jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.nextAriaLabel"),disabled:n.matches.length===0,onClick:n.next,children:jsxRuntime.jsx(G,{name:"keyboard_arrow_down",size:18})})]})]}),n.matches.length>0&&jsxRuntime.jsx("ul",{className:"docx-nav__list","aria-label":i("navigation.find.resultsAriaLabel"),children:n.matches.map((d,m)=>jsxRuntime.jsx(dL,{match:d,active:m===n.activeIndex,onSelect:()=>{n.goTo(m),r.picked();}},`${d.blockId}-${d.start}-${m}`))})]})}function Rl({className:e,style:t,children:o}){let{pane:n,intents:r,findShortcut:i,t:a}=No("Toggle"),s=eo()("Ctrl+F"),c=i?kC(s):void 0,d=i?a("navigation.openShortcutTitle",{shortcut:s}):a("navigation.openTitle");return jsxRuntime.jsx("button",{type:"button",className:Ho("docx-nav__toggle",e),style:t,"aria-label":a("navigation.openAriaLabel"),"aria-expanded":n.open,"aria-keyshortcuts":c,title:d,onMouseDown:m=>m.preventDefault(),onClick:r.toggle,children:o??jsxRuntime.jsx(G,{name:"toc",size:20})})}function Lf(e){let t=$t(),o=lt(),{t:n,toggle:r=true,searchHighlight:i="all",findShortcut:a=true,goToShortcut:l=true,className:s,style:c,children:d,...m}=e,u=rd(m),g=od(),p=u.open&&u.tab==="find"?i:"none",f=nd({highlight:p}),b=tt(),y=Zt.useMemo(()=>n??((T,S)=>b(T,S)),[n,b]),v=IC(u,a,l),x=Zt.useMemo(()=>({pane:u,outline:g,search:f,t:y,intents:v.intents,findShortcut:a,goToShortcut:l}),[u,g,f,y,v.intents,a,l]),h=A(),k=Zt.useRef(v.intents);k.current=v.intents;let E=Zt.useRef(l);E.current=l,Zt.useEffect(()=>{if(h)return h.setGoToChrome({onRequest:()=>k.current.openTab("goto"),get shortcut(){return E.current}})},[h]);let C=e.paneWidth??280;return jsxRuntime.jsx(Df.Provider,{value:x,children:jsxRuntime.jsxs("div",{ref:v.rootRef,className:`${t}docx-nav${u.open?" docx-nav--open":""}${u.overlay?" docx-nav--overlay":""}${s?` ${s}`:""}`,"data-open":u.open?"true":"false",dir:o,onKeyDown:v.onKeyDown,style:{"--docx-nav-width":`${C}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${Fa(C)}px`,...c},children:[r!==false&&!u.open&&jsxRuntime.jsx(Rl,{...typeof r=="object"?r:{}}),jsxRuntime.jsx("aside",{className:"docx-nav__panel-shell","aria-label":x.t("navigation.ariaLabel"),inert:!u.open,children:d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Tl,{}),jsxRuntime.jsx(Pl,{}),jsxRuntime.jsx(wl,{}),jsxRuntime.jsx(Dl,{}),jsxRuntime.jsx(yl,{})]})})]})})}var ad=Object.assign(Lf,{Header:Tl,Close:El,Title:Sl,Tabs:Pl,Tab:kl,Headings:wl,Find:Dl,GoTo:yl,Toggle:Rl});var xL=600,vL=e=>e.isOpening===true?0:e.page.total,id=Zt.createContext(null);function ld({className:e,style:t}){let o=$t(),n=Ut(),r=A(),i=we(),{inside:a,host:l,hostScoped:s}=py(i),c=W(vL),{t:d}=H(),m=Zt.useContext(id),[u,g]=Zt.useState(1),[p,f]=Zt.useState(false);if(Zt.useEffect(()=>{if(f(false),!r||!i||c<=1)return;g(r.getCurrentPage("viewport"));let x=editor.hostWindowOf(i),h=null,k=()=>{g(r.getCurrentPage("viewport")),f(true),h!==null&&x.clearTimeout(h),h=x.setTimeout(()=>f(false),xL);};return i.addEventListener("scroll",k,{passive:true}),()=>{i.removeEventListener("scroll",k),h!==null&&x.clearTimeout(h);}},[r,c,i]),c<=1)return null;let b=l?s?"":`docx-editor ${n?"dark ":""}`:o,y=m?m("viewer.pageIndicator").replace(/\{current\}/g,String(u)).replace(/\{total\}/g,String(c)):d("viewer.pageIndicator",{current:u,total:c}),v=jsxRuntime.jsx("div",{className:`${b}docx-editor-shell__page-indicator-chip docx-editor__page-number${e?` ${e}`:""}`,style:t,"data-visible":p?"true":"false",role:"status","aria-live":"polite",children:y});return a?l?reactDom.createPortal(v,l):null:v}var EL=[],SL=e=>e.fontSubstitutions??EL;function sd({className:e,style:t,t:o}){let n=W(SL),{t:r}=H(),i=o??r,[a,l]=Zt.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")})]})}var FL={damaged:"openFailure.reasons.damaged","not-docx":"openFailure.reasons.notDocx","too-large":"openFailure.reasons.tooLarge",blocked:"openFailure.reasons.blocked",unknown:"openFailure.reasons.unknown"};function LL(e,t){return typeof e=="object"&&e!==null&&"reason"in e&&e!==t}var HL=e=>e.openFailure??null;function qC(e={}){let t=W(HL),{t:o}=H(),n=e.t??o,[r,i]=Zt.useState(null),a=t!==null&&t!==r?t:null,l=Zt.useCallback(s=>{LL(s,t)||i(t);},[t]);return {failure:a,message:a?n(FL[a.reason]):null,dismiss:l}}var UC=Zt.createContext(null);function Af({variant:e="secondary",dismiss:t=false,asChild:o=false,className:n,onClick:r,children:i,type:a,...l}){let s=Zt.useContext(UC),c=`docx-dialog__button${e==="primary"?" docx-dialog__button--primary":""}${n?` ${n}`:""}`,d=m=>{r?.(m),t&&!m.defaultPrevented&&s?.dismiss();};return o?jsxRuntime.jsx(Q,{...l,className:c,onClick:d,children:i}):jsxRuntime.jsx("button",{...l,type:a??"button",className:c,onClick:d,children:i})}var KC=new Set;function $C(e,t){if(!t||!xt())return;let o=e===false?"disabled":typeof e=="object"&&e.actions?"both":null;o===null||KC.has(o)||(KC.add(o),console.warn(o==="both"?"[docx-editor] renderOpenFailureActions replaces openFailure.actions. Pass only one.":"[docx-editor] renderOpenFailureActions is ignored with openFailure={false}, which renders no dialog."));}function zC(e){return Zt.Children.toArray(e).some(t=>Zt.isValidElement(t)&&t.type===Zt.Fragment?zC(t.props.children):true)}function AL({title:e,message:t,showCode:o=true,actions:n,closeLabel:r,showClose:i=true,onDismiss:a,children:l,className:s,style:c,t:d}){let{t:m}=H(),u=d??m,{failure:g,message:p,dismiss:f}=qC({t:u}),b=Zt.useId();if(!g||p===null)return null;let y=()=>{f(g),a?.(g);},v={failure:g,message:p,dismiss:y},x=e??u("openFailure.title"),h=typeof t=="function"?t(g):t??p,k=n?.(v),E=zC(k);return jsxRuntime.jsx(UC.Provider,{value:v,children:jsxRuntime.jsx(Fe,{kind:"openFailure",role:"alertdialog",label:x,className:s,style:c,onClose:y,dismissOutside:false,...l?{}:{describedBy:b},children:l?l(v):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:x})}),jsxRuntime.jsxs("div",{className:"docx-dialog__body",children:[jsxRuntime.jsx("div",{id:b,className:"docx-dialog__message",children:h}),o?jsxRuntime.jsx("p",{className:"docx-dialog__code",children:u("openFailure.code",{code:g.code}).replace("{code}",g.code)}):null]}),E||i?jsxRuntime.jsxs("footer",{className:"docx-dialog__footer",children:[k,i?jsxRuntime.jsx(Af,{variant:E?"secondary":"primary",dismiss:true,children:r??u("common.close")}):null]}):null]})})})}var cd=Object.assign(AL,{Action:Af});function Of(e){return Math.round(e/1440*100)/100}function VC(e){return Math.round(e*1440)}function WL(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 Bf(){let e=A(),t=Zt.useCallback(o=>e?.getHeaderFooterState()??null,[e]);return W(t,WL)}function UL(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 $L=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function Ml(e){let t=A();return Zt.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 zL(e){let{state:t,onMouseDown:o}=e,{t:n}=H(),r=A(),[i,a]=Zt.useState(false),l=Zt.useRef(null),[s,c]=Zt.useState(""),[d,m]=Zt.useState("");Zt.useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(c(String(Of(t.headerDistanceTwips))),m(String(Of(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),Zt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let u=Zt.useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=Zt.useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),p=Zt.useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),f=Zt.useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),b=Zt.useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),y=Ml(u),v=Ml(g),x=Ml(p),h=Ml(f),k=Ml(b),E=(C,T)=>{if(!r)return;let S=Number.parseFloat(T);Number.isFinite(S)&&r.exec({type:"setHeaderFooterOptions",[C]:VC(S)});};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(C=>!C),onMouseDown:o,children:n("headerFooter.options")}),i?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:o,children:[$L.map(C=>{let T={type:"insertPageField",field:C.field},S=r?.can(T);return jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!S?.ok,title:S&&!S.ok?S.reason:void 0,onClick:()=>{r?.exec(T),a(false);},onMouseDown:o,children:n(C.labelKey)},C.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:!y.enabled,title:y.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:!v.enabled,title:v.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:!h.enabled,title:h.reason??void 0,onClick:()=>r?.exec(f),onMouseDown:o,children:n("headerFooter.unlinkFromPrevious")}):jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!x.enabled,title:x.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:C=>c(C.target.value),onBlur:()=>E("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:C=>m(C.target.value),onBlur:()=>E("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:!k.enabled,title:k.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 dd({className:e}){let{t}=H(),o=Bf(),n=Zt.useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),r=wi(n,"story-label"),i=$;if(!o?.editing)return null;let a=UL(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:St.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(zL,{state:o,onMouseDown:i})]})}var GL={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},jL={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},YL={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},XL={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},JL={position:"absolute",top:40,insetInlineStart:0,zIndex:10,pointerEvents:"none"},QL={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)"},e4={padding:"8px 12px"},t4={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},o4={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},n4={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function r4({forwardedRef:e}){let t=A(),o=Zt.useRef(null);return o.current=t,fy({ref:e,editorRef:o}),null}function a4(...e){let t=e.filter(Boolean).join(" ");return t===""?void 0:t}var i4=Zt.forwardRef(function(t,o){let{document:n,fonts:r,fontShaping:i,imageDecodePort:a,className:l,t:s,chrome:c=true,title:d,onTitleChange:m,renderTitleBarLeft:u,renderTitleBarRight:g,renderOpenFailureActions:p,loadingIndicator:f,colorMode:b="light",author:y,locale:v,mode:x="edit",modules:h,zoom:k,zoomMode:E,revisionMarkup:C,onRevisionMarkupChange:T,reviewDisplayMode:S,fieldResults:P,contentLockPolicy:w,lockedControlNavigation:_,onReady:L,onChange:N,onFontError:B,onOpen:F,onSave:D,hyperlinkPopup:R,contextMenu:U=true,menu:V=true,navigation:Y=true,openFailure:j=true,rulers:q=true}=t;!c&&f!==void 0&&q0(),$C(j,p!==void 0);let X=Ul(b),{t:ee}=H(),O=lt(),I=Zt.useCallback((de,ke)=>s?s(de,ke):ee(de,ke),[s,ee]),ie=jsxRuntime.jsxs(ac,{className:c?X?"dark":void 0:l,style:c?jL:void 0,children:[c?jsxRuntime.jsx(dd,{}):null,c?jsxRuntime.jsx(Hs,{}):null,jsxRuntime.jsx(Qs,{}),q&&c?jsxRuntime.jsx("div",{style:JL,dir:O,children:jsxRuntime.jsx(Xc,{})}):null,t.children]}),ge=c?jsxRuntime.jsxs("div",{className:`docx-editor${X?" dark":""}${l?` ${l}`:""}`,style:GL,dir:O,children:[jsxRuntime.jsxs("div",{style:QL,children:[jsxRuntime.jsxs("div",{style:t4,children:[u?.(),jsxRuntime.jsxs("div",{style:o4,children:[m?jsxRuntime.jsx("input",{"aria-label":I("titleBar.documentNameAriaLabel"),value:d??"",placeholder:I("titleBar.untitled"),onChange:de=>m(de.target.value),style:n4}):jsxRuntime.jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:d??I("titleBar.untitled")}),V!==false?jsxRuntime.jsx(pl,{t:I,...d!==void 0?{fileName:d}:{},...F?{onOpen:F}:{},...D?{onSave:D}:{},...typeof V=="object"?V:{}}):null]}),g?.()]}),jsxRuntime.jsx("div",{style:e4,children:jsxRuntime.jsx(sl,{t:I})})]}),q?jsxRuntime.jsx("div",{style:XL,"data-testid":"docx-editor-ruler-row",children:jsxRuntime.jsx(Yc,{})}):null,jsxRuntime.jsx(sd,{t:I}),jsxRuntime.jsxs("div",{style:YL,children:[Y===false?null:jsxRuntime.jsx(ad,{t:I,...typeof Y=="object"?Y:{}}),ie,jsxRuntime.jsx(id.Provider,{value:I,children:jsxRuntime.jsx(ld,{})}),jsxRuntime.jsx(tc,{overlay:true,indicator:f})]})]}):ie,K=Zt.useCallback(de=>I(de),[I]);return jsxRuntime.jsxs(Ai,{popups:p0(t.popups,R,U,I),...n!==void 0?{document:n}:{},...r?{fonts:r}:{},...i?{fontShaping:i}:{},...a?{imageDecodePort:a}:{},...y!==void 0?{author:y}:{},...v!==void 0?{locale:v}:{},translate:I,...c?{colorMode:X?"dark":"light"}:{},mode:x,...h!==void 0?{modules:h}:{},...k!==void 0?{zoom:k}:{},revisionMarkup:C,onRevisionMarkupChange:T,reviewDisplayMode:S,...P!==void 0?{fieldResults:P}:{},...w!==void 0?{contentLockPolicy:w}:{},..._!==void 0?{lockedControlNavigation:_}:{},...E!==void 0?{zoomMode:E}:{},tableInteractionLabel:K,...L?{onReady:L}:{},...N?{onChange:N}:{},...B?{onFontError:B}:{},children:[jsxRuntime.jsx(r4,{forwardedRef:o}),jsxRuntime.jsx(Wo.Provider,{value:c,children:ge}),j===false?null:jsxRuntime.jsx(cd,{t:I,...typeof j=="object"?j:{},...p?{actions:p}:{},className:a4(X?"dark":void 0,typeof j=="object"?j.className:void 0)})]})}),l4=Zt.forwardRef(function(t,o){return jsxRuntime.jsx(Mr,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsxRuntime.jsx(i4,{...t,ref:o})})}),s4=Object.assign(l4,{Root:Ai,Viewport:ac,Content:Qs,Window:pm,Toolbar:sl,Menu:pl,Loading:tc,ColorByChangeType:gm,RevisionMarkup:lu,RevisionMarkupDialog:Ka,CompareDocumentsDialog:qa,UnsupportedElement:Fd,AuthorStyle:bm,HorizontalRuler:Yc,VerticalRuler:Xc,DocumentOutline:wf,Navigation:ad,ExportDialog:Ua,PrintDialog:$a,PageSetupDialog:tr,WatermarkDialog:or,BookmarkDialog:mi,SplitCellDialog:fi,ParagraphDialog:Vo,TextFormFieldDialog:bi,PageNumber:ld,FontNotice:sd,OpenFailure:cd,HeaderFooterChrome:dd,NotesChrome:Hs,Equation:oi,HyperLink:Ja,ContextMenu:Sp,ContentControlWidget:am,InvalidTextFormFieldDialog:Ap,ImageAltTextPopup:Us,ImagePropertiesDialog:Ri,NotePropertiesDialog:As,NotePreview:Nr,NotesContextMenu:Fr,ContentControl:ti});function m4(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}function Zf(e){return Array.isArray(e)?e:[e]}function f4(e){if(typeof e!="function"||editor.isFontResolver(e))return e;let t=e;return editor.defineFontResolver(async()=>t())}function JC(e){return e!==void 0&&Zf(e).some(t=>editor.isFontResolver(t))}async function g4(e){return typeof e!="function"?await e:await e()}function b4(e,t={}){let[o,n]=Zt.useState(void 0),[r,i]=Zt.useState(void 0),[a,l]=Zt.useState(null),[s,c]=Zt.useState(e!=null),d=JC(t.fonts),m=t.fonts===void 0?"absent":d?"on-demand":"eager",[u,g]=Zt.useState(t.fonts===void 0),p=Zt.useRef(t);p.current=t;let f=Zt.useMemo(()=>editor.defineFontResolver(b=>editor.composeFontOrigins(Zf(p.current.fonts??[]).map(f4),b)),[]);return Zt.useEffect(()=>{let b=p.current.fonts;if(b===void 0){i(void 0),g(true);return}if(JC(b)){g(true);return}g(false);let y=true;return (async()=>{try{let v=await Promise.allSettled(Zf(b).map(g4)),x=[];for(let h of v){if(h.status==="rejected"){console.warn("[fonts] font loading failed for one origin; the others still compose",h.reason);continue}h.value!==void 0&&x.push(h.value);}y&&x.length>0&&i(editor.composeFontConfiguration(x[0],...x.slice(1)));}catch(v){console.warn("[fonts] font loading failed; the fixed measurer stays in effect",v);}finally{y&&g(true);}})(),()=>{y=false;}},[m]),Zt.useEffect(()=>{if(e==null){n(void 0),l(null),c(false);return}let b=m4(e);if(b){n(b),l(null),c(false);return}let y=true,v=new AbortController;return c(true),l(null),(async()=>{try{let x=await fetch(String(e),{...p.current.fetchOptions,signal:v.signal});if(!x.ok)throw new Error(`could not open the document: ${x.status} ${x.statusText}`);let h=new Uint8Array(await x.arrayBuffer());if(!y)return;n(h),c(!1);}catch(x){if(!y||x instanceof Error&&x.name==="AbortError")return;l(x instanceof Error?x:new Error("could not open the document")),c(false);}})(),()=>{y=false,v.abort();}},[e]),{document:u?o:void 0,fonts:d?f:r,error:a,isLoading:s||!u}}function C4(...e){let t=Zt.useRef(e);return t.current=e,Zt.useMemo(()=>editor.defineFontResolver(o=>editor.composeFontOrigins(t.current,o)),[])}function S4(e){let o=e?.surface?.state?.().selection?.head;return o&&typeof o.paragraphId=="string"&&Number.isFinite(o.offset)?o:null}function P4(){let e=A(),t=Zt.useRef(null),o=Zt.useCallback(r=>{if(!e)return ()=>{};let i=e.on("selectionChange",r),a=e.on("change",r);return ()=>{i(),a();}},[e]),n=Zt.useCallback(()=>{let r=S4(e),i=t.current;return (r===null?i===null:i!==null&&k4(i,r))?i:(t.current=r,r)},[e]);return Zt.useSyncExternalStore(o,n,()=>null)}function k4(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function R4(e){let t=A(),o=Zt.useRef(e);o.current=e;let n=typeof e=="function";Zt.useEffect(()=>{if(!(!t||!n))return t.setCommentDraftChrome({onRequest:()=>o.current?.()})},[t,n]);}var nT=Object.freeze({applied:0,unavailable:0});function rT(e){if(!e)return "";let{color:t,activeColor:o,activeIndex:n,className:r,priority:i}=e;return JSON.stringify([t,o,n,r,i])}function N4(e,t,o){let n=A(),[r,i]=Zt.useState(nT),a=Zt.useRef(null),l=Zt.useRef(o);l.current=o;let s=Zt.useRef(t);s.current=t;let c=rT(o);return Zt.useEffect(()=>{if(!n){i(nT);return}let d=editor.watchHighlights(n,e,s.current,{...l.current,onResult:i});return a.current={watch:d,source:s.current,key:rT(l.current)},i(d.result),()=>{d.stop(),a.current=null;}},[n,e]),Zt.useEffect(()=>{let d=a.current;!d||d.source===t&&d.key===c||(d.source=t,d.key=c,d.watch.update(t,l.current??{}));},[t,c]),r}function B4(e,t){return e===t?true:!e||!t?false:e.name===t.name&&e.index===t.index&&e.range===t.range&&e.active===t.active&&e.rect.left===t.rect.left&&e.rect.top===t.rect.top&&e.rect.width===t.rect.width&&e.rect.height===t.rect.height}function W4(e){let t=A(),o=we(),[n,r]=Zt.useState(null);return Zt.useEffect(()=>{if(!t){r(null);return}let i=editor.hostDocumentOf(o),a=editor.hostWindowOf(o),l=0,s=null,c=()=>{l=0;let p=s?t.getHighlightsAt(s.x,s.y).find(f=>e===void 0||f.name===e)??null:null;r(f=>B4(f,p)?f:p);},d=()=>{l===0&&(l=a.requestAnimationFrame(c));},m=p=>{let f=p.target;s=editor.isElementNode(f)&&f.closest("[data-page-index]")!==null?{x:p.clientX,y:p.clientY}:null,d();},u=p=>{p.relatedTarget||(s=null,d());};i.addEventListener("pointermove",m,{passive:true}),i.addEventListener("pointerout",u,{passive:true}),i.addEventListener("scroll",d,{passive:true,capture:true});let g=t.on("change",d);return ()=>{i.removeEventListener("pointermove",m),i.removeEventListener("pointerout",u),i.removeEventListener("scroll",d,{capture:true}),g(),l!==0&&a.cancelAnimationFrame(l);}},[t,e,o]),n}function qf({source:e,scale:t,measurer:o,onStateChange:n,onError:r,className:i,documentFontFamily:a,ref:l}){let s=Zt.useRef(null),c=Zt.useRef(null),[d,m]=Zt.useState(null),u=Zt.useRef(n);u.current=n;let g=Zt.useRef(r);return g.current=r,Zt.useEffect(()=>{let p=s.current;if(!p)return;let f=editor.mountPaginatedSurface(p,e,{...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onChange:y=>{m(y),u.current?.(y);}});if(!f.ok){g.current?.(f.reason,f.detail);return}c.current=f.surface;let b=f.surface.state();return m(b),u.current?.(b),()=>{f.surface.destroy(),c.current=null;}},[e,o]),Zt.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,f)=>c.current?.navigate(p,f),toggleRunProperty:(p,f)=>c.current?.toggleRunProperty(p,f),setRunProperty:(p,f)=>c.current?.setRunProperty(p,f),setParagraphProperty:(p,f,b)=>c.current?.setParagraphProperty(p,f,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 Il=Zt.createContext(null);function aT(){let e=Zt.useContext(Il);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function J4(e){return "type"in e&&e.type==="separator"}var sT={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"},Q4={...sT,background:"var(--doc-bg-hover)"},cT={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"},e3={...cT,opacity:.4,cursor:"default"},t3={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},o3={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},n3={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 Nl({label:e,items:t,disabled:o,showChevron:n=false}){let[r,i]=Zt.useState(false),[a,l]=Zt.useState(null),s=Zt.useRef(null),c=Zt.useRef(null),[d,m]=Zt.useState({top:0,left:0}),u=Zt.useCallback(()=>{i(false),l(null);},[]);Zt.useEffect(()=>{if(!r||!s.current)return;let p=s.current.getBoundingClientRect();m({top:p.bottom+2,left:p.left});},[r]),Zt.useEffect(()=>{if(!r)return;function p(x){x.key==="Escape"&&u();}function f(){u();}let b=editor.hostDocumentOf(s.current),y=editor.hostWindowOf(s.current),v=editor.listenForOutsidePress({popup:s.current,contains:x=>!s.current||!c.current||s.current.contains(x)||c.current.contains(x),close:u});return b.addEventListener("keydown",p),y.addEventListener("scroll",f,true),()=>{v(),b.removeEventListener("keydown",p),y.removeEventListener("scroll",f,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?Q4:sT,children:[e,n&&jsxRuntime.jsx(G,{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,f)=>{if(J4(p))return jsxRuntime.jsx("div",{style:t3},`sep-${f}`);let b=p;if(b.customContent)return jsxRuntime.jsx("div",{onMouseDown:x=>x.preventDefault(),children:b.customContent},b.label);let y=!!b.submenuContent,v=a===b.label;return jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>y&&l(b.label),onMouseLeave:()=>y&&l(null),children:[jsxRuntime.jsxs("button",{type:"button",style:b.disabled?e3:cT,onClick:()=>g(b),onMouseDown:x=>x.preventDefault(),onMouseOver:x=>{b.disabled||(x.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent";},disabled:b.disabled,children:[b.icon&&jsxRuntime.jsx(G,{name:b.icon,size:18}),jsxRuntime.jsx("span",{children:b.label}),b.shortcut&&jsxRuntime.jsx("span",{style:o3,children:b.shortcut}),y&&jsxRuntime.jsx("span",{style:{marginLeft:"auto"},children:jsxRuntime.jsx(G,{name:"keyboard_arrow_right",size:16})})]}),y&&v&&jsxRuntime.jsx("div",{style:n3,onMouseDown:x=>x.preventDefault(),children:b.submenuContent(u)})]},b.label)})})]})}var zf=18,a3=2,uT={width:zf,height:zf,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},i3={...uT,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},l3={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function pT({onInsert:e,gridRows:t=6,gridColumns:o=6}){let[n,r]=Zt.useState(0),[i,a]=Zt.useState(0),l=Zt.useCallback(()=>{n>0&&i>0&&e(n,i);},[n,i,e]),s=[];for(let d=1;d<=t;d++)for(let m=1;m<=o;m++){let u=d<=n&&m<=i;s.push(jsxRuntime.jsx("div",{style:u?i3:uT,onMouseEnter:()=>{r(d),a(m);},onClick:l,role:"gridcell","aria-selected":u},`${d}-${m}`));}let c=n>0&&i>0?`${i} \xD7 ${n}`:"Select size";return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"grid",gap:a3,gridTemplateColumns:`repeat(${o}, ${zf}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:s}),jsxRuntime.jsx("div",{style:l3,children:c})]})}function p3({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(G,{name:o.icon,size:18}),jsxRuntime.jsx("span",{children:o.label})]},o.label)})})}function m3(){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 md({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function f3(e){return e.replace(/\.docx$/i,"")}function Gf({value:e,onChange:t,placeholder:o,editable:n=true}){let{t:r}=H(),i=o??r("titleBar.untitled"),a=f3(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 fd({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function gd(){let{t:e}=H(),t=aT(),{disabled:o=false,onFormat:n,onPrint:r,onOpen:i,onSave:a,onPageSetup:l,onInsertImage:s,onInsertTable:c,showTableInsert:d=true,showHelpMenu:m=true,onInsertPageBreak:u,onInsertSectionBreakNextPage:g,onInsertSectionBreakContinuous:p,onInsertTOC:f,onWatermark:b,onRefocusEditor:y}=t,v=Zt.useCallback(E=>{!o&&n&&n(E);},[o,n]),x=Zt.useCallback((E,C)=>{!o&&c&&(c(E,C),editor.hostWindowOf(t.editorRef?.current).requestAnimationFrame(()=>y?.()));},[o,c,y,t.editorRef]),h=!!r||!!l,k=h||i||a;return jsxRuntime.jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[k&&jsxRuntime.jsx(Nl,{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)&&h?[{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(Nl,{label:e("toolbar.format"),disabled:o,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>v("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>v("setRtl")}]}),jsxRuntime.jsx(Nl,{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:E=>jsxRuntime.jsx(pT,{onInsert:(C,T)=>{x(C,T),E();}})}]:[],...s||d&&c?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:E=>jsxRuntime.jsx(p3,{closeMenu:E,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:f,disabled:!f},...b?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:b}]:[]]}),m&&jsxRuntime.jsx(Nl,{label:e("toolbar.help"),disabled:o,items:[{label:e("toolbar.reportIssue"),onClick:()=>dl()}]})]})}function jf({children:e}){let t=null,o=null,n=[],r=[];Zt.Children.forEach(e,a=>{Zt.isValidElement(a)&&(a.type===md?t=a:a.type===fd?o=a:a.type===gd?r.push(a):n.push(a));});let i=Zt.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(m3,{})}),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 bd={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},y3={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:""},mT={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 x3(e,t){let o=mT[t]??mT[t.toLowerCase()]??t,r=e?.colorScheme?.[o];return typeof r=="string"&&r?r:bd[o]??"000000"}function fT(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 Yf(e,t,o="000000"){if(!e||e.kind==="auto")return `#${o}`;if(e.kind==="hex")return `#${fT(e.value)??o}`;let n=Object.entries(t?.colorScheme??bd).map(([i,a])=>({slot:i,hex:String(a)})),r=editor.resolveThemeColorHex(e,n);return `#${r.ok?r.hex:x3(t,e.slot)}`}function tn(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?fT(e.value):Yf(e,t).slice(1)}function gT(e){if(!e||e==="none")return "";let t=y3[e];return t?`#${t}`:""}var v3=[{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"}],C3=[{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 bT(e){let t=e??bd;return C3.map(o=>v3.map(n=>{let r=t[n.slot]??bd[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 ue(...e){return clsx.clsx(e)}var S3=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"}}),it=Zt__namespace.forwardRef(({className:e,variant:t,size:o,...n},r)=>jsxRuntime.jsx("button",{className:ue(S3({variant:t,size:o,className:e})),ref:r,...n}));it.displayName="Button";function Yt({content:e,children:t,side:o="bottom",delayMs:n=400}){let[r,i]=Zt__namespace.useState(false),[a,l]=Zt__namespace.useState({x:0,y:0}),s=Zt__namespace.useRef(null),c=Zt__namespace.useRef(null),d=Zt__namespace.useCallback(()=>{let p=editor.hostWindowOf(s.current),f=p.setTimeout(()=>{if(s.current){let b=s.current.getBoundingClientRect(),y=b.left+b.width/2,v=o==="top"?b.top-8:b.bottom+8;l({x:y,y:v});}i(true);},n);c.current={win:p,handle:f};},[n,o]),m=Zt__namespace.useCallback(()=>{c.current&&(c.current.win.clearTimeout(c.current.handle),c.current=null),i(false);},[]);Zt__namespace.useEffect(()=>()=>{c.current&&c.current.win.clearTimeout(c.current.handle);},[]);let u=t.props,g=Zt__namespace.cloneElement(t,{ref:s,onMouseEnter:p=>{d(),u.onMouseEnter?.(p);},onMouseLeave:p=>{m(),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 Xf=Zt__namespace.createContext(null);function _n(e){let[t,o]=Zt__namespace.useState(null),n=Zt__namespace.useMemo(()=>({trigger:t,setTrigger:o}),[t]);return jsxRuntime.jsx(Xf.Provider,{value:n,children:jsxRuntime.jsx(Ae__namespace.Root,{...e})})}var In=Ae__namespace.Group,hd=Ae__namespace.Value;function Nn({className:e,children:t,onMouseDown:o,...n}){let r=Zt__namespace.useContext(Xf)?.setTrigger;return jsxRuntime.jsxs(Ae__namespace.Trigger,{ref:r,className:ue("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:i=>{i.preventDefault(),o?.(i);},...n,children:[t,jsxRuntime.jsx(Ae__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(N3,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function Fn({className:e,children:t,position:o="popper",onCloseAutoFocus:n,onKeyDown:r,...i}){let a=Zt__namespace.useContext(Xf)?.trigger??null,l=typeof globalThis.document>"u"&&!a?null:editor.hostDocumentOf(a),c=Ut()||!!a?.closest(".docx-editor.dark");return jsxRuntime.jsx(Ae__namespace.Portal,{...l?.body?{container:l.body}:{},children:jsxRuntime.jsx("div",{className:ue("docx-editor",c&&"dark"),children:jsxRuntime.jsx(Ae__namespace.Content,{className:ue("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:d=>{d.preventDefault(),n?.(d);},onKeyDown:d=>{r?.(d),d.defaultPrevented||I3(d);},...i,children:jsxRuntime.jsx(Ae__namespace.Viewport,{className:ue("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:d=>d.preventDefault(),children:t})})})})}var _3=new Set(["ArrowDown","ArrowUp","Home","End"]);function I3(e){let t=e.currentTarget;if(t.ownerDocument===globalThis.document||!_3.has(e.key))return;e.preventDefault();let o=Array.from(t.querySelectorAll('[role="option"]:not([data-disabled])'));if(o.length===0)return;let n=o.indexOf(t.ownerDocument.activeElement),r=n>=0?n:o.findIndex(a=>a.dataset.state==="checked"),i=e.key==="Home"?0:e.key==="End"?o.length-1:e.key==="ArrowDown"?Math.min(o.length-1,r+1):Math.max(0,r<0?0:r-1);o[i].focus({preventScroll:false});}function vr({className:e,...t}){return jsxRuntime.jsx(Ae__namespace.Label,{className:ue("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function Xt({className:e,children:t,onMouseDown:o,...n}){return jsxRuntime.jsxs(Ae__namespace.Item,{className:ue("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(Ae__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(Ae__namespace.ItemIndicator,{children:jsxRuntime.jsx(F3,{className:"h-4 w-4"})})})]})}function Cr({className:e,...t}){return jsxRuntime.jsx(Ae__namespace.Separator,{className:ue("-mx-1 my-1 h-px bg-muted",e),...t})}function N3({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 F3({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 Jf(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 L3=[{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 xT({value:e,onChange:t,fonts:o=L3,documentFonts:n,disabled:r=false,className:i,placeholder:a="Arial",width:l=120,showPreview:s=true}){let{t:c}=H(),d=Zt__namespace.useMemo(()=>{if(!n)return [];let f=new Set(o.map(b=>b.name.toLowerCase()));return n.filter(b=>!f.has(b.name.toLowerCase()))},[n,o]),m=Zt__namespace.useMemo(()=>[...d,...o],[d,o]),u=Zt__namespace.useMemo(()=>e?m.find(b=>b.fontFamily===e||b.name.toLowerCase()===e.toLowerCase()||Jf(b.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,m,a]),g=Zt__namespace.useCallback(f=>{let b=m.find(y=>y.name===f);b&&t?.(Jf(b.fontFamily)||b.name);},[t,m]),p=Zt__namespace.useMemo(()=>{let f={"sans-serif":[],serif:[],monospace:[],other:[]};return o.forEach(b=>{let y=b.category||"other";f[y].push(b);}),f},[o]);return jsxRuntime.jsxs(_n,{value:u,onValueChange:g,disabled:r,children:[jsxRuntime.jsx(Nn,{className:ue("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":c("font.selectAriaLabel"),children:jsxRuntime.jsx(hd,{placeholder:a,children:u})}),jsxRuntime.jsxs(Fn,{className:"max-h-[300px]",children:[d.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(In,{children:[jsxRuntime.jsx(vr,{children:c("font.documentFonts")}),d.map(f=>jsxRuntime.jsx(Xt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},`doc-${f.name}`))]}),jsxRuntime.jsx(Cr,{})]}),p["sans-serif"].length>0&&jsxRuntime.jsxs(In,{children:[jsxRuntime.jsx(vr,{children:c("font.sansSerif")}),p["sans-serif"].map(f=>jsxRuntime.jsx(Xt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]}),p.serif.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Cr,{}),jsxRuntime.jsxs(In,{children:[jsxRuntime.jsx(vr,{children:c("font.serif")}),p.serif.map(f=>jsxRuntime.jsx(Xt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.monospace.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Cr,{}),jsxRuntime.jsxs(In,{children:[jsxRuntime.jsx(vr,{children:c("font.monospace")}),p.monospace.map(f=>jsxRuntime.jsx(Xt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.other.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Cr,{}),jsxRuntime.jsx(In,{children:p.other.map(f=>jsxRuntime.jsx(Xt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))})]})]})]})}function Qf(e){if(e===void 0)return;let t=e.map(o=>typeof o=="string"?{name:o,fontFamily:o,category:"other"}:o);if(xt()){let o=new Set,n=new Set;for(let r of t)n.has(r.name)&&!o.has(r.name)&&(console.warn(`[DocxEditor] Duplicate font name in fontFamilies: "${r.name}"`),o.add(r.name)),n.add(r.name);}return t}function Z3(e,t,o,n,r){let a=Math.max(8,e.innerWidth-n-8),l=Math.max(8,e.innerHeight-r-8);return {top:Math.min(Math.max(8,t),l),left:Math.min(Math.max(8,o),a)}}function Ft({isOpen:e,onClose:t,align:o="left"}){let n=Zt.useRef(null),r=Zt.useRef(null),[i,a]=Zt.useState({top:0,left:0});Zt.useEffect(()=>{if(!e||!n.current)return;let c=n.current.getBoundingClientRect();if(o==="right"){let d=editor.hostWindowOf(n.current);d.requestAnimationFrame(()=>{if(r.current){let m=r.current.getBoundingClientRect(),u=Z3(d,c.bottom+4,c.right-m.width,m.width,m.height);a(u);}else a({top:c.bottom+4,left:c.left});});}else a({top:c.bottom+4,left:c.left});},[e,o]),Zt.useEffect(()=>{if(!e)return;let c=performance.now()+150,d=f=>{f.key==="Escape"&&t();},m=f=>{if(performance.now()<c)return;let b=f.target;b&&r.current&&r.current.contains(b)||editor.isElementNode(b)&&b!==b.ownerDocument.documentElement&&b!==b.ownerDocument.body&&n.current&&b.contains(n.current)||t();},u=editor.hostDocumentOf(n.current),g=editor.hostWindowOf(n.current),p=editor.listenForOutsidePress({popup:n.current,contains:f=>!n.current||!r.current||n.current.contains(f)||r.current.contains(f),close:()=>t()});return u.addEventListener("keydown",d),g.addEventListener("scroll",m,true),()=>{p(),u.removeEventListener("keydown",d),g.removeEventListener("scroll",m,true);}},[e,t]);let l=Zt.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 $3=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],z3=1,V3=400;function ET(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function ST(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 PT({value:e,onChange:t,sizes:o=$3,disabled:n=false,className:r,placeholder:i="11",minSize:a=z3,maxSize:l=V3}){let{t:s}=H(),[c,d]=Zt.useState(false),[m,u]=Zt.useState(""),[g,p]=Zt.useState(false),f=Zt.useRef(null),b=Zt.useCallback(()=>{p(false),d(false);},[]),{containerRef:y,dropdownRef:v,dropdownStyle:x}=Ft({isOpen:g,onClose:b}),h=e??(parseInt(i,10)||11),k=e!==void 0?e.toString():i,E=Zt.useCallback(N=>{if(N.preventDefault(),n)return;let B=ST(h,o,a);t?.(B);},[h,o,a,n,t]),C=Zt.useCallback(N=>{if(N.preventDefault(),n)return;let B=ET(h,o,l);t?.(B);},[h,o,l,n,t]),T=Zt.useCallback(N=>{N.preventDefault(),!n&&(d(true),u(k),p(true),editor.hostWindowOf(f.current).requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();}));},[n,k]),S=Zt.useCallback(N=>{u(N.target.value);},[]),P=Zt.useCallback(()=>{d(false);let N=parseFloat(m);if(!isNaN(N)&&N>=a&&N<=l){let B=Math.round(N*2)/2;t?.(B);}},[m,a,l,t]),w=Zt.useCallback(N=>{if(N.key==="Enter")N.preventDefault(),P(),p(false);else if(N.key==="Escape")d(false),p(false);else if(N.key==="ArrowUp"){N.preventDefault();let B=ET(h,o,l);u(B.toString()),t?.(B);}else if(N.key==="ArrowDown"){N.preventDefault();let B=ST(h,o,a);u(B.toString()),t?.(B);}},[P,h,o,l,a,t]),_=Zt.useCallback(N=>{t?.(N),p(false),d(false);},[t]),L=Zt.useCallback(N=>{N.target.tagName!=="INPUT"&&N.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:y,className:ue("flex items-center",r),onMouseDown:L,children:[jsxRuntime.jsx(it,{variant:"ghost",size:"icon-sm",className:ue("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:E,disabled:n||h<=a,"aria-label":s("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsxRuntime.jsx(G,{name:"remove",size:18})}),jsxRuntime.jsx("div",{className:"relative",children:c?jsxRuntime.jsx("input",{ref:f,type:"text",value:m,onChange:S,onBlur:P,onKeyDown:w,className:ue("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:T,className:ue("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:k})}),g&&jsxRuntime.jsx("div",{ref:v,style:{...x,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:ue("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",N===h&&"bg-muted font-medium"),role:"option","aria-selected":N===h,children:N},N))}),jsxRuntime.jsx(it,{variant:"ghost",size:"icon-sm",className:ue("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:C,disabled:n||h>=l,"aria-label":s("fontSize.increase"),"data-testid":"font-size-increase",children:jsxRuntime.jsx(G,{name:"add",size:18})})]})}var Y3=[{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"}],xd=18,X3=2,J3={position:"relative",display:"inline-block"},Q3={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)"},eH={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},og={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},ng={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},DT={display:"grid",gap:`${X3}px`},vd={width:`${xd}px`,height:`${xd}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},RT={...vd,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},MT={...vd,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},tH={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)"},oH={display:"flex",alignItems:"center",gap:"6px"},nH={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},rH={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},kT={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},aH={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},iH={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)"},lH={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 rg(e,t,o){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let n=gT(e);return n||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return Yf(e,o)}function wT(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 _T(e,t,o){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():tn(e,o))===t.toUpperCase():false}function sH({matrix:e,selectedColor:t,theme:o,onSelect:n}){let[r,i]=Zt.useState(null);return jsxRuntime.jsx("div",{style:{...DT,gridTemplateColumns:`repeat(10, ${xd}px)`},children:e.flatMap((a,l)=>a.map((s,c)=>{let d=`${l}-${c}`,m=r===d,u=_T(t,s.hex,o);return jsxRuntime.jsx("button",{type:"button",style:{...u?MT:m?RT:vd,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 cH({selectedColor:e,theme:t,onSelect:o}){let[n,r]=Zt.useState(null),{t:i}=H();return jsxRuntime.jsx("div",{style:{...DT,gridTemplateColumns:`repeat(10, ${xd}px)`},children:Y3.map((a,l)=>{let s=n===l,c=_T(e,a.hex,t),d=i(a.nameKey);return jsxRuntime.jsx("button",{type:"button",style:{...c?MT:s?RT:vd,backgroundColor:`#${a.hex}`},title:d,"aria-label":d,"aria-selected":c,onClick:()=>o(a.hex),onMouseDown:m=>m.preventDefault(),onMouseEnter:()=>r(l),onMouseLeave:()=>r(null)},a.hex)})})}function Sr({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:m}){let[u,g]=Zt.useState(false),[p,f]=Zt.useState(false),[b,y]=Zt.useState(false),[v,x]=Zt.useState(false),[h,k]=Zt.useState(""),[E,C]=Zt.useState(()=>m??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:T}=H();Zt.useEffect(()=>{let O=rg(t,e,n).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(O)&&k(O.toUpperCase());},[t,e,n]);let S=Zt.useCallback(()=>g(false),[]),{containerRef:P,dropdownRef:w,dropdownStyle:_}=Ft({isOpen:u,onClose:S}),L=n?.colorScheme??null,N=Zt.useMemo(()=>bT(L),[L]),B=Zt.useMemo(()=>rg(t,e,n),[t,e,n]),F=Zt.useMemo(()=>rg(E,e,n),[E,e,n]),D=Zt.useCallback(()=>{r||g(O=>!O);},[r]),R=Zt.useCallback(O=>{let I;e==="highlight"?I=O.hex:I={kind:"theme",slot:O.themeSlot,...O.tint!==void 0?{tint:O.tint}:{},...O.shade!==void 0?{shade:O.shade}:{}},C(I),o?.(I),g(false);},[e,o]),U=Zt.useCallback(O=>{let I=e==="highlight"?O:{kind:"hex",value:O};C(I),o?.(I),g(false);},[e,o]),V=Zt.useCallback(()=>{o?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,o]),Y=Zt.useCallback(()=>{let O=h.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(O)){let I=e==="highlight"?O:{kind:"hex",value:O};C(I),o?.(I),g(false),k("");}},[e,h,o]),j=Zt.useCallback(()=>{r||o?.(E);},[r,E,o]),q={...Q3,...r?{cursor:"default",opacity:.38}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:p?{backgroundColor:"var(--doc-bg-hover)"}:{}},X=T(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),ee=s??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxRuntime.jsxs("div",{ref:P,className:`docx-color-picker ${i||""}`,style:{...J3,...a},children:[d?jsxRuntime.jsxs("div",{className:"docx-color-picker-split",style:{...aH,...r?{opacity:.38,cursor:"default"}:null},children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...iH,...r?{cursor:"default"}:b?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:j,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>y(true),onMouseLeave:()=>y(false),disabled:r,title:l||X,"aria-label":l||X,children:[jsxRuntime.jsx(G,{name:ee,size:18}),jsxRuntime.jsx("div",{style:{...kT,backgroundColor:F==="transparent"?"#fff":F,outline:F==="transparent"||wT(F)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...lH,...r?{cursor:"default"}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:v?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:D,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>x(true),onMouseLeave:()=>x(false),disabled:r,title:l||X,"aria-label":l||X,"aria-haspopup":"true","aria-expanded":u,children:jsxRuntime.jsx(G,{name:"arrow_drop_down",size:18})})]}):jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-button",style:q,onClick:D,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>f(true),onMouseLeave:()=>f(false),disabled:r,title:l||X,"aria-label":l||X,"aria-haspopup":"true","aria-expanded":u,children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsxRuntime.jsx(G,{name:ee,size:18}),jsxRuntime.jsx("div",{style:{...kT,backgroundColor:B==="transparent"?"#fff":B,outline:B==="transparent"||wT(B)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx(G,{name:"arrow_drop_down",size:14})]}),u&&jsxRuntime.jsx("div",{ref:w,className:"docx-color-picker-dropdown",style:{..._,...eH},role:"dialog","aria-label":`${X} picker`,onMouseDown:O=>{O.target.tagName!=="INPUT"&&O.preventDefault();},children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",style:tH,onClick:V,onMouseDown:O=>O.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??T(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsxRuntime.jsx("div",{style:ng}),jsxRuntime.jsx("div",{style:og,children:T("colorPicker.themeColors")}),jsxRuntime.jsx(sH,{matrix:N,selectedColor:t,theme:n,onSelect:R}),jsxRuntime.jsx("div",{style:ng}),jsxRuntime.jsx("div",{style:og,children:T("colorPicker.standardColors")}),jsxRuntime.jsx(cH,{selectedColor:t,theme:n,onSelect:U}),jsxRuntime.jsx("div",{style:ng}),jsxRuntime.jsx("div",{style:og,children:T("colorPicker.customColor")}),jsxRuntime.jsxs("div",{style:oH,children:[jsxRuntime.jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsxRuntime.jsx("input",{type:"text",style:nH,value:h,onChange:O=>k(O.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:O=>{O.key==="Enter"&&Y();},onMouseDown:O=>{O.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsxRuntime.jsx("button",{type:"button",style:{...rH,opacity:/^[0-9A-Fa-f]{6}$/.test(h)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(h)?"pointer":"default"},onClick:Y,onMouseDown:O=>O.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(h),children:T("common.apply")})]})]})})]})}var Ll=20,ag=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsxRuntime.jsx(G,{name:"format_align_left",size:Ll}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsxRuntime.jsx(G,{name:"format_align_center",size:Ll}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsxRuntime.jsx(G,{name:"format_align_right",size:Ll}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsxRuntime.jsx(G,{name:"format_align_justify",size:Ll}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function FT({value:e="left",onChange:t,disabled:o=false}){let{t:n}=H(),[r,i]=Zt.useState(false),a=Zt.useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:s,dropdownStyle:c,handleMouseDown:d}=Ft({isOpen:r,onClose:a}),m=Zt.useCallback(y=>{o||t?.(y),i(false);},[o,t]),u=ag.find(y=>y.value===e)||ag[0],g=n(u.labelKey),p=u.shortcutKey?n(u.shortcutKey):void 0,f=`${g}${p?` (${p})`:""}`,b=jsxRuntime.jsxs(it,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",o&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!o&&i(y=>!y),disabled:o,"aria-label":f,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsxRuntime.jsx(G,{name:u.iconName,size:Ll}),jsxRuntime.jsx(G,{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(Yt,{content:f,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:y=>y.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",gap:2},children:ag.map(y=>{let v=e===y.value,x=n(y.labelKey),h=y.shortcutKey?n(y.shortcutKey):void 0;return jsxRuntime.jsx("button",{type:"button",title:`${x}${h?` (${h})`:""}`,"data-testid":`alignment-${y.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,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)"},onMouseDown:k=>k.preventDefault(),onMouseEnter:k=>{v||(k.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:k=>{k.currentTarget.style.backgroundColor=v?"var(--doc-primary-light)":"transparent";},onClick:()=>m(y.value),children:jsxRuntime.jsx(G,{name:y.iconName,size:18})},y.value)})})})]})}function Cd(){return {type:"none",level:0,isInList:false}}var fH={display:"inline-flex",alignItems:"center",gap:"4px"},LT={display:"inline-flex",alignItems:"center",gap:"4px"},Pd={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)"},gH={...Pd,backgroundColor:"var(--doc-bg-hover)"},bH={...Pd,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},hH={...Pd,cursor:"default",opacity:.38},yH={width:"28px",height:"28px",padding:"2px"},xH={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Td=20;function Ed({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,style:a}){let[l,s]=Zt.useState(false),c={...t?hH:e?bH:l?gH:Pd,...a},d=m=>{m.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 HT({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:m}=H(),u=Zt.useCallback(()=>c?{...yH}:{},[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:{...fH,...l},role:"group","aria-label":m("lists.ariaLabel"),children:[jsxRuntime.jsxs("div",{style:LT,role:"group","aria-label":m("lists.typeAriaLabel"),children:[jsxRuntime.jsx(Ed,{active:g,disabled:i,title:m("lists.bulletList"),onClick:t,style:u(),children:jsxRuntime.jsx(G,{name:"format_list_bulleted",size:Td})}),jsxRuntime.jsx(Ed,{active:p,disabled:i,title:m("lists.numberedList"),onClick:o,style:u(),children:jsxRuntime.jsx(G,{name:"format_list_numbered",size:Td})})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:xH,role:"separator"}),jsxRuntime.jsxs("div",{style:LT,role:"group","aria-label":m("lists.indentationAriaLabel"),children:[jsxRuntime.jsx(Ed,{active:false,disabled:i||!b,title:m("lists.decreaseIndent"),onClick:r,style:u(),children:jsxRuntime.jsx(G,{name:"format_indent_decrease",size:Td})}),jsxRuntime.jsx(Ed,{active:false,disabled:i,title:m("lists.increaseIndent"),onClick:n,style:u(),children:jsxRuntime.jsx(G,{name:"format_indent_increase",size:Td})})]})]})]})}var CH=[{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 OT({value:e,onChange:t,options:o=CH,disabled:n=false,className:r}){let{t:i}=H(),a=Zt__namespace.useMemo(()=>e===void 0?o[0]:o.find(c=>c.twipsValue===e)||o[0],[e,o]),l=Zt__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(_n,{value:a.twipsValue.toString(),onValueChange:l,disabled:n,children:[jsxRuntime.jsx(Nn,{className:ue("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(Pf,{className:"h-5 w-5 shrink-0"})}),jsxRuntime.jsxs(Fn,{children:[o.map(c=>jsxRuntime.jsx(Xt,{value:c.twipsValue.toString(),children:s(c)},c.twipsValue)),jsxRuntime.jsx(Cr,{}),jsxRuntime.jsx(In,{children:jsxRuntime.jsx(vr,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var TH=[{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 BT({value:e,onChange:t,styles:o,disabled:n=false,className:r,width:i=120}){let{t:a}=H(),l=Zt__namespace.useMemo(()=>{let g=wx(o);return g.length===0?TH:g.map(p=>{let f=vc(p.name);if(!f)return {...p,type:"paragraph"};let b=f.key==="styles.normal"?a("styles.normalText"):a(f.key,f.vars);return {...p,type:"paragraph",name:b}})},[o,a]),s=Zt__namespace.useCallback(g=>{t?.(g);},[t]),c=g=>g.nameKey?a(g.nameKey):g.name,d=e||"Normal",m=l.find(g=>g.styleId===d),u=m?c(m):d;return jsxRuntime.jsxs(_n,{value:d,onValueChange:s,disabled:n,children:[jsxRuntime.jsx(Nn,{className:ue("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(Fn,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsxRuntime.jsx(Xt,{value:g.styleId,className:"py-2.5 px-3",children:jsxRuntime.jsx("span",{style:Px(g),children:c(g)})},g.styleId))})]})}var SH=[{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 ZT({value:e=1,onChange:t,levels:o=SH,disabled:n=false,className:r,compact:i=false}){let{t:a}=H(),l=Zt__namespace.useMemo(()=>{let g=o.find(p=>Math.abs(p.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[o,e]),s=Zt__namespace.useCallback(g=>{let p=parseFloat(g);isNaN(p)||t?.(p);},[t]),c=Zt__namespace.useMemo(()=>[...o].sort((g,p)=>g.value-p.value),[o]),d=Zt__namespace.useMemo(()=>[...c].reverse().find(g=>g.value<e-.001),[c,e]),m=Zt__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(it,{variant:"ghost",size:"icon-sm",className:ue(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(G,{name:"remove",size:18})}),jsxRuntime.jsxs(_n,{value:e.toString(),onValueChange:s,disabled:n,children:[jsxRuntime.jsx(Nn,{className:ue(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(hd,{placeholder:"100%",children:l})}),jsxRuntime.jsx(Fn,{children:o.map(g=>jsxRuntime.jsx(Xt,{value:g.value.toString(),children:g.label},g.value))})]}),jsxRuntime.jsx(it,{variant:"ghost",size:"icon-sm",className:ue(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(n||!m)&&"opacity-30 cursor-not-allowed"),onClick:()=>m&&t?.(m.value),disabled:n||!m,"aria-label":a("zoom.zoomIn"),children:jsxRuntime.jsx(G,{name:"add",size:18})})]})}var kH=[{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 UT({onAction:e,disabled:t=false}){let{t:o}=H(),[n,r]=Zt.useState(false),i=Zt.useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=Ft({isOpen:n,onClose:i}),d=Zt.useCallback(u=>{e(u),r(false);},[e]),m=jsxRuntime.jsxs(it,{variant:"ghost",size:"icon-sm",className:ue("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(G,{name:"border_all",size:20}),jsxRuntime.jsx(G,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[n?m:jsxRuntime.jsx(Yt,{content:o("table.borders.tooltip"),children:m}),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:kH.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:f=>f.preventDefault(),onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:f=>{f.currentTarget.style.backgroundColor="transparent";},onClick:()=>d(u),children:jsxRuntime.jsx(G,{name:g,size:18})},typeof u=="string"?u:u.type))})})]})}function $T({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=H(),i=Zt.useCallback(a=>{if(typeof a=="string"){e({type:"borderColor",color:a.replace(/^#/,"")});return}let l=a.kind==="auto"?"000000":tn(a,o);l&&e({type:"borderColor",color:l});},[e,o]);return jsxRuntime.jsx(Sr,{mode:"border",value:n,onChange:i,theme:o,disabled:t,title:r("table.borderColor")})}var MH=[{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 VT({onAction:e,disabled:t=false}){let[o,n]=Zt.useState(false),{t:r}=H(),i=Zt.useCallback(()=>n(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=Ft({isOpen:o,onClose:i}),d=Zt.useCallback(u=>{e({type:"borderWidth",size:u}),n(false);},[e]),m=jsxRuntime.jsxs(it,{variant:"ghost",size:"icon-sm",className:ue("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(G,{name:"line_weight",size:20}),jsxRuntime.jsx(G,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[o?m:jsxRuntime.jsx(Yt,{content:r("table.borderWidth"),children:m}),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:MH.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:f=>f.preventDefault(),onMouseEnter:f=>{f.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:f=>{f.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 jT({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=H(),i=Zt.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(Sr,{mode:"highlight",value:n,onChange:i,theme:o,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var IH={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"},wr={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},JT={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function QT({onAction:e,disabled:t=false,tableContext:o}){let{t:n}=H(),[r,i]=Zt.useState(false),[a,l]=Zt.useState(null),s=Zt.useCallback(()=>i(false),[]),{containerRef:c,dropdownRef:d,dropdownStyle:m,handleMouseDown:u}=Ft({isOpen:r,onClose:s,align:"right"}),g=o?.table?.attrs?.justification??"left",p=Zt.useCallback(y=>{e(y),i(false);},[e]),f=(y,v,x,h,k)=>{let E=t||k?.itemDisabled;return jsxRuntime.jsxs("button",{type:"button",role:"menuitem",style:{...IH,backgroundColor:a===y&&!E?"var(--doc-bg-hover)":"transparent",color:E?"var(--doc-text-muted)":k?.danger?"var(--doc-error)":"var(--doc-text)",cursor:E?"not-allowed":"pointer"},onClick:()=>!E&&p(h),onMouseEnter:()=>l(y),onMouseLeave:()=>l(null),disabled:E,children:[jsxRuntime.jsx(G,{name:v,size:16,className:k?.danger&&!E?"text-destructive":""}),jsxRuntime.jsx("span",{style:{flex:1},children:x})]},y)},b=jsxRuntime.jsx(it,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!t&&i(y=>!y),disabled:t,"aria-label":n("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsxRuntime.jsx(G,{name:"more_vert",size:20})});return jsxRuntime.jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[r?b:jsxRuntime.jsx(Yt,{content:n("table.moreOptions"),children:b}),r&&!t&&jsxRuntime.jsxs("div",{ref:d,style:{...m,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:y=>y.stopPropagation(),children:[f("addRowAbove","add",n("table.insertRowAbove"),"addRowAbove"),f("addRowBelow","add",n("table.insertRowBelow"),"addRowBelow"),f("addColumnLeft","add",n("table.insertColumnLeft"),"addColumnLeft"),f("addColumnRight","add",n("table.insertColumnRight"),"addColumnRight"),jsxRuntime.jsx("div",{style:wr,role:"separator"}),f("mergeCells","call_merge",n("table.mergeCells"),"mergeCells",{itemDisabled:!o?.hasMultiCellSelection}),f("splitCell","call_split",n("table.splitCell"),"splitCell",{itemDisabled:!o?.canSplitCell}),jsxRuntime.jsx("div",{style:wr,role:"separator"}),f("selectTable","select_all",n("table.selectTable"),"selectTable"),jsxRuntime.jsx("div",{style:wr,role:"separator"}),f("deleteRow","delete",n("table.deleteRow"),"deleteRow",{danger:true,itemDisabled:(o?.rowCount??0)<=1}),f("deleteColumn","delete",n("table.deleteColumn"),"deleteColumn",{danger:true,itemDisabled:(o?.columnCount??0)<=1}),f("deleteTable","delete",n("table.deleteTable"),"deleteTable",{danger:true}),jsxRuntime.jsx("div",{style:wr,role:"separator"}),jsxRuntime.jsx("div",{style:JT,children:n("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(y=>{let v={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"}[y]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:h=>h.preventDefault(),onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},onClick:()=>p({type:"cellVerticalAlign",align:y}),children:jsxRuntime.jsx(G,{name:v[y],size:16})},y)})}),jsxRuntime.jsx("div",{style:wr,role:"separator"}),jsxRuntime.jsx("div",{style:JT,children:n("tableAdvanced.tableAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(y=>{let v={left:"format_align_left",center:"format_align_center",right:"format_align_right"},x=g===y;return jsxRuntime.jsx("button",{type:"button",title:n({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[y]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:x?"var(--doc-primary-light)":"transparent",borderColor:x?"var(--doc-primary)":"var(--doc-border)",color:x?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:h=>h.preventDefault(),onClick:()=>p({type:"tableProperties",props:{justification:y}}),children:jsxRuntime.jsx(G,{name:v[y],size:16})},y)})}),jsxRuntime.jsx("div",{style:wr,role:"separator"}),f("headerRow","table_rows",n("tableAdvanced.toggleHeaderRow"),{type:"toggleHeaderRow"}),f("distribute","view_column",n("tableAdvanced.distributeColumns"),{type:"distributeColumns"}),f("autoFit","fit_width",n("tableAdvanced.autoFit"),{type:"autoFitContents"}),f("noWrap","wrap_text",n("tableAdvanced.toggleNoWrap"),{type:"toggleNoWrap"}),jsxRuntime.jsx("div",{style:wr,role:"separator"}),f("properties","settings",n("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var FH=20;function Dd({options:e,activeValue:t,triggerIcon:o,tooltipContent:n,onSelect:r,disabled:i=false,ariaLabel:a,testId:l,showLabels:s=false}){let[c,d]=Zt.useState(false),m=Zt.useCallback(()=>d(false),[]),{containerRef:u,dropdownRef:g,dropdownStyle:p,handleMouseDown:f}=Ft({isOpen:c,onClose:m}),b=Zt.useCallback(v=>{i||r(v),d(false);},[i,r]),y=jsxRuntime.jsxs(it,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",c&&"bg-muted",i&&"opacity-30 cursor-not-allowed"),onMouseDown:f,onClick:()=>!i&&d(v=>!v),disabled:i,"aria-label":a??n,"aria-expanded":c,"aria-haspopup":"true","data-testid":l,children:[jsxRuntime.jsx(G,{name:o,size:FH}),jsxRuntime.jsx(G,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:u,style:{position:"relative",display:"inline-block"},children:[c?y:jsxRuntime.jsx(Yt,{content:n,children:y}),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:v=>v.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:s?"column":"row",gap:s?1:2,minWidth:s?200:void 0},children:e.map(v=>{let x=t===v.value;return jsxRuntime.jsxs("button",{type:"button",title:v.label,"data-testid":l?`${l}-${v.value}`:void 0,style:{display:"flex",alignItems:"center",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)",...s?{width:"100%",gap:10,padding:"0 10px",justifyContent:"flex-start",fontSize:13,textAlign:"left"}:{width:32,justifyContent:"center"}},onMouseDown:h=>h.preventDefault(),onMouseEnter:h=>{x||(h.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:h=>{h.currentTarget.style.backgroundColor=x?"var(--doc-primary-light)":"transparent";},onClick:()=>b(v.value),children:[jsxRuntime.jsx(G,{name:v.iconName,size:18}),s&&jsxRuntime.jsx("span",{style:{flex:1},children:v.label})]},v.value)})})})]})}var LH=[{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 HH(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function tE({imageContext:e,onChange:t,disabled:o=false}){let{t:n}=H(),r=LH.map(l=>({...l,label:n(l.labelKey)})),i=HH(e),a=r.find(l=>l.value===i)||r[0];return jsxRuntime.jsx(Dd,{options:r,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:o,testId:"toolbar-image-wrap",showLabels:true})}var OH=[{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 oE({onTransform:e,disabled:t=false}){let{t:o}=H(),n=OH.map(r=>({...r,label:o(r.labelKey)}));return jsxRuntime.jsx(Dd,{options:n,triggerIcon:"rotate_right",tooltipContent:o("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var bo=18;function Jt({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(it,{variant:"ghost",size:"icon-sm",className:ue("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(Yt,{content:o,children:c}):c}function ho({label:e,children:t,className:o}){return jsxRuntime.jsx("div",{className:ue("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 qH(e){let t=Zt__namespace.default.useContext(Il);return t?{...t,...UH(e)}:e}function UH(e){let t={};for(let o of Object.keys(e))e[o]!==void 0&&(t[o]=e[o]);return t}function dg(e){let{t}=H(),o=qH(e),{currentFormatting:n={},onFormat:r,onUndo:i,onRedo:a,canUndo:l=false,canRedo:s=false,disabled:c=false,className:d,style:m,enableShortcuts:u=true,editorRef:g,children:p,showFontPicker:f=true,fontFamilies:b,documentFonts:y,showFontSizePicker:v=true,showTextColorPicker:x=true,showHighlightColorPicker:h=true,showAlignmentButtons:k=true,showListButtons:E=true,showLineSpacingPicker:C=true,showStylePicker:T=true,documentStyles:S,theme:P,showZoomControl:w=true,zoom:_,onZoomChange:L,onRefocusEditor:N,imageContext:B,onImageWrapType:F,onImageTransform:D,onOpenImageProperties:R,tableContext:U,onTableAction:V,inline:Y=false}=o,j=Zt.useRef(null),q=Zt.useCallback(se=>{!c&&r&&r(se);},[c,r]),X=Zt.useCallback(()=>{!c&&l&&i&&i();},[c,l,i]),ee=Zt.useCallback(()=>{!c&&s&&a&&a();},[c,s,a]),O=Zt.useCallback(se=>{!c&&r&&r({type:"fontFamily",value:se});},[c,r]),I=Zt__namespace.default.useMemo(()=>Qf(b),[b]),ie=Zt.useCallback(se=>{!c&&r&&r({type:"fontSize",value:se});},[c,r]),ge=Zt.useCallback(se=>{!c&&r&&r({type:"textColor",value:se});},[c,r]),K=Zt.useCallback(se=>{!c&&r&&r({type:"highlightColor",value:typeof se=="string"?se:""});},[c,r]),de=Zt.useCallback(se=>{!c&&r&&r({type:"alignment",value:se});},[c,r]),ke=Zt.useCallback(()=>{!c&&r&&r("bulletList");},[c,r]),Ze=Zt.useCallback(()=>{!c&&r&&r("numberedList");},[c,r]),at=Zt.useCallback(()=>{!c&&r&&r("indent");},[c,r]),Ce=Zt.useCallback(()=>{!c&&r&&r("outdent");},[c,r]),Ye=Zt.useCallback(se=>{!c&&r&&(r({type:"lineSpacing",value:se}),editor.hostWindowOf(j.current).requestAnimationFrame(()=>N?.()));},[c,r,N]),Wn=Zt.useCallback(se=>{!c&&r&&r({type:"applyStyle",value:se});},[c,r]),wt=Zt.useCallback(se=>{!c&&V&&(V(se),editor.hostWindowOf(j.current).requestAnimationFrame(()=>N?.()));},[c,V,N]);Zt.useEffect(()=>{if(!u)return;let se=Ie=>{if(Ie.defaultPrevented)return;let Kn=Ie.target,xo=g?.current,Qt=j.current,vo=xo?.contains(Kn),an=Qt?.contains(Kn);if(!vo&&!an)return;if((Ie.ctrlKey||Ie.metaKey)&&!Ie.altKey)switch(Ie.key.toLowerCase()){case "b":Ie.preventDefault(),q("bold");break;case "i":Ie.preventDefault(),q("italic");break;case "u":Ie.preventDefault(),q("underline");break;case "=":Ie.shiftKey?(Ie.preventDefault(),q("superscript")):(Ie.preventDefault(),q("subscript"));break;case "l":Ie.preventDefault(),de("left");break;case "e":Ie.preventDefault(),de("center");break;case "r":Ie.preventDefault(),de("right");break;case "j":Ie.preventDefault(),de("both");break;case "k":Ie.preventDefault(),q("insertLink");break}},Ge=editor.hostDocumentOf(g?.current??j.current);return Ge.addEventListener("keydown",se),()=>{Ge.removeEventListener("keydown",se);}},[u,q,de,g]);let qt=Zt.useCallback(se=>{let Ge=se.target;Ge.tagName==="INPUT"||Ge.tagName==="TEXTAREA"||Ge.tagName==="SELECT"||Ge.tagName==="OPTION"||se.preventDefault();},[]),Zn=Zt.useCallback(se=>{let Ge=se.target,Ie=editor.hostDocumentOf(Ge).activeElement;Ge.tagName==="SELECT"||Ge.tagName==="OPTION"||Ie?.tagName==="SELECT"||editor.hostWindowOf(Ge).requestAnimationFrame(()=>{N?.();});},[N]);return jsxRuntime.jsxs("div",{ref:j,className:ue(!Y&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:Y?{display:"contents",...m}:m,role:Y?void 0:"toolbar","aria-label":Y?void 0:t("toolbar.ariaLabel"),"data-testid":Y?void 0:"formatting-bar",onMouseDown:Y?void 0:qt,onMouseUp:Y?void 0:Zn,children:[jsxRuntime.jsxs(ho,{label:t("formattingBar.groups.history"),children:[jsxRuntime.jsx(Jt,{onClick:X,disabled:c||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsxRuntime.jsx(G,{name:"undo",size:bo})}),jsxRuntime.jsx(Jt,{onClick:ee,disabled:c||!s,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsxRuntime.jsx(G,{name:"redo",size:bo})})]}),w&&jsxRuntime.jsx(ho,{label:t("formattingBar.groups.zoom"),children:jsxRuntime.jsx(ZT,{value:_,onChange:L,disabled:c,compact:true})}),T&&jsxRuntime.jsx(ho,{label:t("formattingBar.groups.styles"),children:jsxRuntime.jsx(BT,{value:n.styleId||"Normal",onChange:Wn,styles:S,theme:P,disabled:c,width:120})}),(f||v)&&jsxRuntime.jsxs(ho,{label:t("formattingBar.groups.font"),children:[f&&jsxRuntime.jsx(xT,{value:n.fontFamily||"Arial",onChange:O,fonts:I,documentFonts:y,disabled:c,width:60,placeholder:"Arial"}),v&&jsxRuntime.jsx(PT,{value:n.fontSize!==void 0?mm(n.fontSize):11,onChange:ie,disabled:c,width:42,placeholder:"11"})]}),jsxRuntime.jsxs(ho,{label:t("formattingBar.groups.textFormatting"),children:[jsxRuntime.jsx(Jt,{onClick:()=>q("bold"),active:n.bold,disabled:c,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsxRuntime.jsx(G,{name:"format_bold",size:bo})}),jsxRuntime.jsx(Jt,{onClick:()=>q("italic"),active:n.italic,disabled:c,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsxRuntime.jsx(G,{name:"format_italic",size:bo})}),jsxRuntime.jsx(Jt,{onClick:()=>q("underline"),active:n.underline,disabled:c,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsxRuntime.jsx(G,{name:"format_underlined",size:bo})}),jsxRuntime.jsx(Jt,{onClick:()=>q("strikethrough"),active:n.strike,disabled:c,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsxRuntime.jsx(G,{name:"strikethrough_s",size:bo})}),x&&jsxRuntime.jsx(Sr,{mode:"text",value:n.color?.replace(/^#/,""),onChange:ge,theme:P,disabled:c,title:t("formattingBar.fontColor")}),h&&jsxRuntime.jsx(Sr,{mode:"highlight",value:n.highlight,onChange:K,theme:P,disabled:c,title:t("formattingBar.highlightColor")}),jsxRuntime.jsx(Jt,{onClick:()=>q("insertLink"),disabled:c,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsxRuntime.jsx(G,{name:"link",size:bo})})]}),jsxRuntime.jsxs(ho,{label:t("formattingBar.groups.script"),children:[jsxRuntime.jsx(Jt,{onClick:()=>q("superscript"),active:n.superscript,disabled:c,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsxRuntime.jsx(G,{name:"superscript",size:bo})}),jsxRuntime.jsx(Jt,{onClick:()=>q("subscript"),active:n.subscript,disabled:c,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsxRuntime.jsx(G,{name:"subscript",size:bo})})]}),k&&jsxRuntime.jsx(ho,{label:t("formattingBar.groups.alignment"),children:jsxRuntime.jsx(FT,{value:n.alignment||"left",onChange:de,disabled:c})}),(E||C)&&jsxRuntime.jsxs(ho,{label:t("formattingBar.groups.listFormatting"),children:[E&&jsxRuntime.jsx(HT,{listState:n.listState||Cd(),onBulletList:ke,onNumberedList:Ze,onIndent:at,onOutdent:Ce,disabled:c,showIndentButtons:true,compact:true,hasIndent:(n.indentLeft??0)>0}),C&&jsxRuntime.jsx(OT,{value:n.lineSpacing,onChange:Ye,disabled:c})]}),B&&F&&jsxRuntime.jsxs(ho,{label:t("formattingBar.groups.image"),children:[jsxRuntime.jsx(tE,{imageContext:B,onChange:F,disabled:c}),D&&jsxRuntime.jsx(oE,{onTransform:D,disabled:c}),R&&jsxRuntime.jsx(Jt,{onClick:R,disabled:c,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsxRuntime.jsx(G,{name:"tune",size:bo})})]}),U?.isInTable&&V&&jsxRuntime.jsxs(ho,{label:t("formattingBar.groups.table"),children:[jsxRuntime.jsx(UT,{onAction:wt,disabled:c}),jsxRuntime.jsx($T,{onAction:wt,disabled:c,theme:P,value:tn(U?.cellBorderColor,P)}),jsxRuntime.jsx(VT,{onAction:wt,disabled:c}),jsxRuntime.jsx(jT,{onAction:wt,disabled:c,theme:P,value:U?.cellBackgroundColor}),jsxRuntime.jsx(QT,{onAction:wt,disabled:c,tableContext:U})]}),jsxRuntime.jsx(Jt,{onClick:()=>q("clearFormatting"),disabled:c,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsxRuntime.jsx(G,{name:"format_clear",size:bo})}),p]})}function $H({children:e,className:t,style:o,...n}){return jsxRuntime.jsx(Il.Provider,{value:n,children:jsxRuntime.jsx("div",{className:ue("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:St.toolbar,...o},"data-testid":"editor-toolbar",children:e})})}var Lt=$H;Lt.TitleBar=jf;Lt.Logo=md;Lt.DocumentName=Gf;Lt.MenuBar=gd;Lt.TitleBarRight=fd;Lt.Toolbar=dg;var GH=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"]]),jH=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function YH({source:e,scale:t,measurer:o,documentName:n,onStateChange:r,onError:i,onSave:a,renderTitleBarLeft:l,renderTitleBarRight:s,ref:c,colorMode:d,onZoomChange:m,documentFontFamily:u,className:g}){let p=Zt.useRef(null),[f,b]=Zt.useState(null),[y,v]=Zt.useState({}),[x,h]=Zt.useState(null),k=Zt.useCallback(S=>{b(S);let P=p.current?.formatting();P&&v({bold:P.bold,italic:P.italic,underline:P.underline,strike:P.strikethrough,superscript:P.superscript,subscript:P.subscript,...P.fontFamily?{fontFamily:P.fontFamily}:{},...P.fontSizeHalfPoints?{fontSize:P.fontSizeHalfPoints}:{},...P.alignment?{alignment:P.alignment}:{},...P.styleId?{styleId:P.styleId}:{},...P.color?{color:`#${P.color}`}:{},...P.highlight?{highlight:P.highlight}:{}}),h(p.current?.sectionProperties()??null),r?.(S);},[r]),E=Zt.useCallback(S=>{let P=p.current;if(P){if(typeof S=="string")switch(S){case "bold":return P.toggleRunProperty("b");case "italic":return P.toggleRunProperty("i");case "underline":return P.toggleRunProperty("u",{val:"single"});case "strikethrough":return P.toggleRunProperty("strike");case "superscript":return P.setRunProperty("vertAlign",{val:"superscript"});case "subscript":return P.setRunProperty("vertAlign",{val:"subscript"});case "clearFormatting":P.setRunProperty("b",{val:"0"}),P.setRunProperty("i",{val:"0"}),P.setRunProperty("u",{val:"none"}),P.setRunProperty("strike",{val:"0"}),P.setRunProperty("vertAlign",{val:"baseline"});return;case "setRtl":case "setLtr":return P.setParagraphProperty("bidi",void 0,{paragraphDirection:S==="setRtl"?"rtl":"ltr"});default:return}switch(S.type){case "fontFamily":return P.setRunProperty("rFonts",{ascii:S.value,hAnsi:S.value});case "fontSize":return P.setRunProperty("sz",{val:String(Math.round(S.value*2))});case "textColor":{let w=S.value,_=typeof w=="string"?jH(w):tn(w,null)??null;return _?P.setRunProperty("color",{val:_}):void 0}case "highlightColor":{let w=S.value.trim().toLowerCase();if(w==="none"||w==="")return P.setRunProperty("highlight",{val:"none"});let _=GH.get(w.startsWith("#")?w:`#${w}`);return _?P.setRunProperty("highlight",{val:_}):void 0}case "alignment":return P.setParagraphProperty("jc",{val:String(S.value)},{physicalAlignment:true});case "lineSpacing":return P.setParagraphProperty("spacing",{line:String(Math.round(S.value)),lineRule:"auto"},{mergeAttributes:true});case "applyStyle":return P.setParagraphProperty("pStyle",{val:S.value});default:return}}},[]);Zt.useImperativeHandle(c,()=>p.current,[]);let C=t===void 0?1:t/(96/72),T=x?{pageWidthTwips:x.pageSize.widthTwips,pageHeightTwips:x.pageSize.heightTwips,orientation:x.landscape?"landscape":"portrait",marginsTwips:{top:x.margins.topTwips,right:x.margins.rightTwips,bottom:x.margins.bottomTwips,left:x.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(Lt,{currentFormatting:y,onFormat:E,onUndo:()=>p.current?.undo(),onRedo:()=>p.current?.redo(),canUndo:f?.canUndo??false,canRedo:f?.canRedo??false,zoom:C,onZoomChange:m,onSave:()=>{let S=p.current?.save();S&&a?.(S);},children:[jsxRuntime.jsxs(Lt.TitleBar,{children:[l&&jsxRuntime.jsx(Lt.Logo,{children:l()}),jsxRuntime.jsx(Lt.DocumentName,{value:n??"Document",editable:false}),s&&jsxRuntime.jsx(Lt.TitleBarRight,{children:s()}),jsxRuntime.jsx(Lt.MenuBar,{})]}),jsxRuntime.jsx(Lt.Toolbar,{})]}),jsxRuntime.jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[T?jsxRuntime.jsx("div",{style:{padding:"4px 0"},children:jsxRuntime.jsx(br,{pageSetup:T,zoom:C})}):null,jsxRuntime.jsx(qf,{ref:p,source:e,...u?{documentFontFamily:u}:{},...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onStateChange:k,...i?{onError:i}:{}})]})]})}var Md=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 _d=class extends Md{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=globalThis.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)globalThis.clearTimeout(t);this.timers.clear(),this.emitSnapshot();}destroy(){for(let t of this.timers)globalThis.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=globalThis.setTimeout(()=>{this.timers.delete(a),this.dismiss(r);},5e3);this.timers.add(a);}return r}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var oA=Zt.createContext(null);function sE({children:e}){let t=Zt.useMemo(()=>new _d,[]),o=Zt.useSyncExternalStore(t.subscribe,t.getSnapshot),n=Zt.useCallback((c,d)=>{t.showError(c,d);},[t]),r=Zt.useCallback((c,d)=>{t.showWarning(c,d);},[t]),i=Zt.useCallback((c,d)=>{t.showInfo(c,d);},[t]),a=Zt.useCallback(c=>{t.dismiss(c);},[t]),l=Zt.useCallback(()=>{t.clearAll();},[t]),s=Zt.useMemo(()=>({notifications:o.notifications,showError:n,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:l}),[o.notifications,n,r,i,a,l]);return jsxRuntime.jsxs(oA.Provider,{value:s,children:[e,jsxRuntime.jsx(nA,{notifications:o.notifications,onDismiss:a})]})}function nA({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(rA,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function rA({notification:e,onDismiss:t}){let{t:o}=H(),[n,r]=Zt.useState(false),a=(f=>{switch(f){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},m={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=f=>{switch(f){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:m,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 Id=class extends Zt.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(aA,{error:n,errorInfo:r,showDetails:o,onReset:this.resetError})}return this.props.children}};function aA({error:e,errorInfo:t,showDetails:o,onReset:n}){let{t:r}=H(),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
4
  `,jsxRuntime.jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:n,style:d,children:r("errors.tryAgain")})]})}function uE({onClick:e,topPx:t,scrollLeft:o=0,leftOffset:n=_a}){let{t:r}=H();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:St.outline},children:jsxRuntime.jsx(G,{name:"format_list_bulleted",size:20})})}function pg({currentPage:e,totalPages:t,visible:o}){let{t:n}=H();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 lA({i18n:e,isDark:t,onEditorError:o,containerRef:n,scrollContainerRef:r,editorContentRef:i,className:a,containerStyle:l,mainContentStyle:s,editorContainerStyle:c,showRuler:d,readOnlyProp:m,showOutline:u,showOutlineButton:g,sidebarOpen:p,minLayoutWidth:f,toolbarHeight:b,editorScrollLeft:y,onScrollContainerMouseDown:v,onEditorBgMouseDown:x,onEditorContextMenu:h,horizontalRulerProps:k,verticalRulerProps:E,outlineProps:C,onToggleOutline:T,scrollPageInfo:S,toolbar:P,pagedArea:w,overlays:_,dialogs:L,fileInputs:N}){let B=d&&!m;return jsxRuntime.jsx(Wo.Provider,{value:true,children:jsxRuntime.jsx(Mr,{i18n:e,children:jsxRuntime.jsx(sE,{children:jsxRuntime.jsx(Id,{onError:o,children:jsxRuntime.jsxs("div",{ref:n,className:ue("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:[P,jsxRuntime.jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:c,onMouseDown:v,children:[d&&jsxRuntime.jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:St.ruler,paddingLeft:20,paddingRight:20+(p?352:0),minWidth:f,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(br,{...k})}),jsxRuntime.jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:f},children:jsxRuntime.jsxs("div",{ref:i,style:{position:"relative",flex:1,minWidth:0},onMouseDown:x,onContextMenu:h,children:[B&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:St.ruler,paddingTop:48},children:jsxRuntime.jsx(gl,{...E})}),w]})})]}),S.totalPages>1&&jsxRuntime.jsx(pg,{currentPage:S.currentPage,totalPages:S.totalPages,visible:S.visible}),u&&jsxRuntime.jsx(hl,{...C,leftOffset:bl+(B?Ma:0)}),g&&!u&&jsxRuntime.jsx(uE,{onClick:T,topPx:b+(d?xf+8:0)+48,scrollLeft:y,leftOffset:_a+(B?Ma:0)})]})}),_,L,N]})})})})})}function fA(e){let[t,o]=Zt.useState(0);return Zt.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 vA({kind:e}){let t=A(),[o,n]=Zt.useState(null),r=Zt.useRef(null);Zt.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=Zt.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,"DEFAULT_FONT",{enumerable:true,get:function(){return editor.DEFAULT_FONT}});Object.defineProperty(exports,"DocumentRefreshError",{enumerable:true,get:function(){return editor.DocumentRefreshError}});Object.defineProperty(exports,"HIGHLIGHT_REFRESH_MS",{enumerable:true,get:function(){return editor.HIGHLIGHT_REFRESH_MS}});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,"SEARCH_DEBOUNCE_MS",{enumerable:true,get:function(){return editor.SEARCH_DEBOUNCE_MS}});Object.defineProperty(exports,"SEARCH_HIGHLIGHT_PRIORITY",{enumerable:true,get:function(){return editor.SEARCH_HIGHLIGHT_PRIORITY}});Object.defineProperty(exports,"SEARCH_HIGHLIGHT_SET",{enumerable:true,get:function(){return editor.SEARCH_HIGHLIGHT_SET}});Object.defineProperty(exports,"SEARCH_MATCH_LIMIT",{enumerable:true,get:function(){return editor.SEARCH_MATCH_LIMIT}});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,"createDocumentRefresh",{enumerable:true,get:function(){return editor.createDocumentRefresh}});Object.defineProperty(exports,"createFontSource",{enumerable:true,get:function(){return editor.createFontSource}});Object.defineProperty(exports,"deferFonts",{enumerable:true,get:function(){return editor.deferFonts}});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=Mt;exports.ContextMenuCellVerticalAlignment=ar;exports.ContextMenuCopy=vi;exports.ContextMenuCopyFormatting=Rs;exports.ContextMenuCut=xi;exports.ContextMenuDelete=Ci;exports.ContextMenuDeleteTable=ua;exports.ContextMenuDeleteTableColumn=da;exports.ContextMenuDeleteTableRow=ca;exports.ContextMenuInsertColumnLeft=aa;exports.ContextMenuInsertColumnRight=ia;exports.ContextMenuInsertRowAbove=na;exports.ContextMenuInsertRowBelow=ra;exports.ContextMenuItem=_s;exports.ContextMenuMergeCells=la;exports.ContextMenuPaste=ea;exports.ContextMenuPasteFormatting=Ms;exports.ContextMenuPasteWithoutFormatting=ta;exports.ContextMenuRefreshToc=pa;exports.ContextMenuRefreshTocPageNumbers=ma;exports.ContextMenuRemoveToc=fa;exports.ContextMenuSelectAll=Ti;exports.ContextMenuSelectTable=oa;exports.ContextMenuSplitCell=sa;exports.DEFAULT_WATERMARK_PRESETS=np;exports.DocumentName=Gf;exports.DocumentOutline=hl;exports.DocxEditor=s4;exports.DocxEditorAuthorStyle=bm;exports.DocxEditorBookmarkDialog=mi;exports.DocxEditorColorByChangeType=gm;exports.DocxEditorCompareDocumentsDialog=qa;exports.DocxEditorContent=Qs;exports.DocxEditorContentControl=ti;exports.DocxEditorContentControlWidget=am;exports.DocxEditorContextMenu=ki;exports.DocxEditorDocumentOutline=wf;exports.DocxEditorEquation=oi;exports.DocxEditorExportDialog=Ua;exports.DocxEditorFontNotice=sd;exports.DocxEditorHeaderFooterChrome=dd;exports.DocxEditorHorizontalRuler=Yc;exports.DocxEditorHyperLink=Ja;exports.DocxEditorImageAltTextPopup=Us;exports.DocxEditorImageInsertErrorDialog=Hu;exports.DocxEditorImagePropertiesDialog=Ri;exports.DocxEditorInvalidTextFormFieldDialog=Ap;exports.DocxEditorLoading=tc;exports.DocxEditorLoadingSpinner=fm;exports.DocxEditorMenu=pl;exports.DocxEditorNavigation=Lf;exports.DocxEditorNotePreview=Nr;exports.DocxEditorNotePropertiesDialog=As;exports.DocxEditorNotesChrome=Hs;exports.DocxEditorNotesContextMenu=Fr;exports.DocxEditorOpenFailure=cd;exports.DocxEditorOpenFailureAction=Af;exports.DocxEditorPageNumber=ld;exports.DocxEditorPageSetupDialog=tr;exports.DocxEditorParagraphDialog=Vo;exports.DocxEditorPrintDialog=$a;exports.DocxEditorRevisionMarkup=lu;exports.DocxEditorRevisionMarkupDialog=Ka;exports.DocxEditorRoot=Ai;exports.DocxEditorShell=lA;exports.DocxEditorSplitCellDialog=fi;exports.DocxEditorTextFormFieldDialog=bi;exports.DocxEditorToolbar=sl;exports.DocxEditorUnsupportedElement=Fd;exports.DocxEditorVerticalRuler=Xc;exports.DocxEditorViewport=ac;exports.DocxEditorWatermarkDialog=or;exports.DocxEditorWindow=pm;exports.HorizontalRuler=br;exports.ImageAltText=qs;exports.ImageInsertProvider=cs;exports.ImageInsertTrigger=ds;exports.ImagePropertiesTrigger=Ks;exports.ImageWrap=mc;exports.LocaleProvider=Mr;exports.Logo=md;exports.MenuBar=gd;exports.NAVIGATION_PANE_GAP=dC;exports.NAVIGATION_PANE_INSET=Qc;exports.NAVIGATION_PANE_MIN_PAGE_ROOM=Rf;exports.NAVIGATION_PANE_WIDTH=Na;exports.NavigationClose=El;exports.NavigationFind=Dl;exports.NavigationGoTo=yl;exports.NavigationHeader=Tl;exports.NavigationHeadings=wl;exports.NavigationTab=kl;exports.NavigationTabs=Pl;exports.NavigationTitle=Sl;exports.NavigationToggle=Rl;exports.OUTLINE_BUTTON_LEFT_OFFSET=_a;exports.OUTLINE_BUTTON_RESERVED_SPACE=dF;exports.OUTLINE_LEFT_OFFSET=bl;exports.OUTLINE_RESERVED_SPACE=sF;exports.PageIndicator=pg;exports.PageNumberTranslationContext=id;exports.PaginatedDocxEditor=qf;exports.PaginatedDocxEditorShell=YH;exports.REVIEW_MARKERS_GUTTER=xa;exports.REVIEW_PANE_GUTTER=Oi;exports.RULER_WIDTH=Ma;exports.ReviewRailContext=At;exports.Slot=Q;exports.TitleBar=jf;exports.TitleBarRight=fd;exports.Toolbar=dg;exports.ToolbarButton=Jt;exports.ToolbarContext=Vn;exports.ToolbarGroup=ho;exports.ToolbarImageProperties=ga;exports.VERSION=fE;exports.VerticalRuler=gl;exports.definePopup=BP;exports.editorStateActiveSubscriptionCount=AE;exports.isFieldLink=ja;exports.navigationPaneOverlays=td;exports.navigationPaneReservation=Fa;exports.navigationShift=ed;exports.normalizeImageBytes=as;exports.notificationYieldsToTask=Tg;exports.provideDocxEditor=G1;exports.reviewGutter=cy;exports.useBookmarkDialog=eR;exports.useBookmarks=gp;exports.useChromeDir=lt;exports.useChromeTranslate=xg;exports.useCommentDraftRequest=R4;exports.useCompareDocumentsDialog=EP;exports.useContentControl=Po;exports.useContentControlInstance=Ql;exports.useContentControlWidget=ct;exports.useContextMenuTarget=Qb;exports.useDocumentOutline=od;exports.useDocumentSearch=nd;exports.useDocxEditor=A;exports.useDocxSource=b4;exports.useEditorCaret=P4;exports.useEditorColorMode=VE;exports.useEditorCommand=re;exports.useEditorEvent=Qm;exports.useEditorHostDocument=cf;exports.useEditorSnapshot=fA;exports.useEditorState=W;exports.useEditorValueCommand=Mi;exports.useFontFamily=xc;exports.useFonts=C4;exports.useGoToBookmark=Jc;exports.useHeaderFooterState=Bf;exports.useHighlightAt=W4;exports.useHighlights=N4;exports.useHistoryGroup=vA;exports.useHyperlinkPopup=XP;exports.useHyperlinkPopupInstance=Xl;exports.useNavigationPane=rd;exports.useNavigationShift=zn;exports.useNotePropertiesState=kp;exports.useNoteScopeState=Pp;exports.useOpenFailure=qC;exports.usePageSetup=er;exports.usePageSetupDialog=hD;exports.useParagraphDialog=MD;exports.useParagraphFormat=ep;exports.useParagraphIndent=Cf;exports.useParagraphStyle=Cc;exports.useReviewAuthors=Zi;exports.useReviewGutter=En;exports.useRevisionMarkupDialog=uP;exports.useScopeClassName=qE;exports.useScopedChromeAnchor=wi;exports.useSplitCellDialog=uR;exports.useTableBorderTargetLabel=lv;exports.useTextFormFieldDialog=yR;exports.useToolbarContext=ES;exports.useToolbarLabel=ae;exports.useToolbarLabelFor=zl;exports.useTranslation=H;exports.useWatermark=up;exports.useWatermarkDialog=Hh;exports.useZoom=Hm;