@docx-editor.dev/react 2.34.0 → 2.35.0-canary.20261102190412.sha-b9a04a3

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 Bt=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'),Fe=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 Bt__namespace=/*#__PURE__*/_interopNamespace(Bt);var Fe__namespace=/*#__PURE__*/_interopNamespace(Fe);var rg={version:"2.34.0"};var eE=rg.version;function ng(){let e=new Map,t=new Map,o=new Set,r=0,n=0,i=null,a=[],l,s=false,c=()=>[...e].sort((u,g)=>t.get(u[0])-t.get(g[0])),d=()=>{n++;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,r++),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:()=>n,hosts(u){let g=c();return a.filter(p=>g.find(([,f])=>editor.unsupportedElementRuleMatches(f,p.unsupported))?.[0]===u)}}}var xn=Bt.createContext(null);function ag(e){return Bt.Children.toArray(e).some(t=>Bt.isValidElement(t)&&t.type===Bt.Fragment?ag(t.props.children):typeof t!="string"||t.trim().length>0)}function ig({host:e,children:t}){let o=ag(t);return Bt.useLayoutEffect(()=>(e.setCustomized(o),()=>{e.setCustomized(false);}),[e,o]),o?reactDom.createPortal(t,e.slot):null}function Cd({match:e,layout:t,includePartial:o,children:r}){let n=Bt.useContext(xn);if(!n)throw new Error("DocxEditor.UnsupportedElement must render inside DocxEditor.Root.");let i=Bt.useRef(Symbol("unsupported-element-declaration")).current;return Bt.useSyncExternalStore(n.subscribe,n.snapshot,n.snapshot),Bt.useLayoutEffect(()=>{n.register(i,{includePartial:o,...e?{match:e}:{},...t?{layout:t}:{}});},[n,i,e,t,o]),Bt.useLayoutEffect(()=>()=>n.unregister(i),[n,i]),n.hosts(i).map(a=>jsxRuntime.jsx(ig,{host:a,children:r({element:a.unsupported})},a.key))}var Td=Bt.createContext(i18n.en),Ed=Bt.createContext("en"),Sd=Bt.createContext("ltr"),Pd=Bt.createContext(void 0);function vn({i18n:e,dir:t,children:o}){let r=Bt.useContext(Td),n=Bt.useContext(Ed),i=Bt.useContext(Sd),a=Bt.useContext(Pd),l=typeof e?._lang=="string"?e._lang:n,s=i18n.chromeDirection(t,e,a),c=s??i18n.catalogDirection(e)??i,d=Bt.useMemo(()=>i18n.deepMerge(r,e),[r,e]);return jsxRuntime.jsx(Ed.Provider,{value:l,children:jsxRuntime.jsx(Sd.Provider,{value:c,children:jsxRuntime.jsx(Pd.Provider,{value:s,children:jsxRuntime.jsx(Td.Provider,{value:d,children:o})})})})}function L(){let e=Bt.useContext(Td),t=Bt.useContext(Ed),o=Bt.useContext(Sd);return {t:Bt.useMemo(()=>i18n.createT(e,t),[e,t]),catalogue:e,lang:t,dir:o}}function it(){return Bt.useContext(Pd)}function cg(e){let{t}=L();return Bt.useCallback((o,r)=>e?.get(o)??t(o,r),[e,t])}var kd=Bt.createContext(null);function H(){return Bt.useContext(kd)}function Pl(e){return (e?.mounted??0)+(e?.gutters??0)>0}var Lt=Bt.createContext(null);var wd=0,Dd=false,Rd=false,kl=[],wl=null;function ug(e){if(typeof MessageChannel!="function"){globalThis.setTimeout(e,0);return}wl||(wl=new MessageChannel,wl.port1.onmessage=()=>{let t=kl;kl=[];for(let o of t)try{o();}catch(r){queueMicrotask(()=>{throw r});}}),kl.push(e),kl.length===1&&wl.port2.postMessage(null);}function pg(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(Dd||(Dd=true,wd+=1,queueMicrotask(()=>{Dd=false;}),Rd||(Rd=true,ug(()=>{Rd=false,wd=0;}))),wd>16)}function mg(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};pg()?ug(o):queueMicrotask(o);}}var TE=()=>{},_d=0;function EE(){return _d}function _a(e){return mg(e)}function W(e,t=Object.is,o){let r=H(),n=o?.onSubscribe,i=o?.onUnsubscribe,a=Bt.useCallback(d=>{if(!r)return TE;let m=false;_d++,n?.();let u=_a(()=>{m||d();}),g=[r.on("change",u),r.on("selectionChange",u),r.on("error",u)];return ()=>{m=true,_d--,i?.();for(let p of g)p();}},[r,n,i]),l=Bt.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)}},[r,e,t]),s=Bt.useCallback(()=>l(r?r.snapshot():editor.LOADING_SNAPSHOT),[r,l]),c=Bt.useCallback(()=>l(editor.LOADING_SNAPSHOT),[l]);return Bt.useSyncExternalStore(a,s,c)}function wE(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function DE(e,t){let o={...e,...t};for(let r of Object.keys(e))/^on[A-Z]/.test(r)?o[r]=wE(t[r],e[r]):r==="className"?o[r]=[e[r],t[r]].filter(Boolean).join(" "):r==="style"&&(o[r]={...e[r],...t[r]});return o}function J({children:e,...t}){let o=Bt.Children.only(e);if(!Bt.isValidElement(o))return null;let r=o.props,n=DE(t,r),i=o.ref,a=t.ref;return (i||a)&&(n.ref=l=>{for(let s of [i,a])typeof s=="function"?s(l):s&&typeof s=="object"&&(s.current=l);}),Bt.cloneElement(o,n)}var fg="(prefers-color-scheme: dark)";function gg(){return typeof globalThis.window<"u"&&typeof globalThis.window.matchMedia=="function"}function bg(){return gg()?globalThis.window.matchMedia(fg).matches:false}function hg(e,t){return e==="dark"||e==="system"&&t}function yg(e){if(!gg())return ()=>{};let t=globalThis.window.matchMedia(fg);e(t.matches);let o=r=>e(r.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}var Ao=Bt.createContext(false),Ir=Bt.createContext(false);function RE(){let e=Bt.useContext(Ao),t=Bt.useContext(Ir);return e?"":t?"docx-editor dark ":"docx-editor "}function Rl(e){let t=e==="system",o=Bt.useSyncExternalStore(t?_E:IE,t?bg:Cg,Cg);return hg(e??"light",o)}function _E(e){return yg(()=>e())}function IE(){return ()=>{}}function Cg(){return false}function Kt(){return Bt.useContext(Ir)}function qt(){let e=Bt.useContext(Ao),t=Bt.useContext(Ir);return e?"":t?"docx-editor dark ":"docx-editor "}function NE(){return Bt.useContext(Ir)?LE:FE}var FE=Object.freeze({colorMode:"light"}),LE=Object.freeze({colorMode:"dark"});var Sg=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function St(){let e=Bt.createContext(null),t=new Map,o=y=>{let x=t.get(y.type);return x==="field"?`field:${y.props.name}`:x};function r(y,x){Bt.Children.forEach(y,b=>{Bt.isValidElement(b)&&(x(b),r(b.props.children,x));});}function n(){let y=Bt.useContext(e);if(!y)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return y.state}function i(y,x){return Bt.Children.map(y,b=>{if(!Bt.isValidElement(b))return b;let v=Sg(b.props);return v&&x.has(v)?x.get(v):b.props.children===void 0?b:Bt.cloneElement(b,{children:i(b.props.children,x)})})}function a(y){function x(b){let v=Bt.useContext(e);if(!v||b.hidden)return null;let P=y==="field"?`field:${b.name}`:y,T=v.defaults.get(P);if(!T)return b.children??null;let{children:C,asChild:E,className:S,style:k,hidden:w,name:I,...O}=b,N={...O,...T.props,className:[T.props.className,S].filter(Boolean).join(" "),style:{...T.props.style,...k}};if(E){let{children:B,className:F,style:D,...R}=N;return jsxRuntime.jsx(J,{...R,...S?{className:S}:{},...k?{style:k}:{},children:C})}return Bt.cloneElement(T,N,C===void 0?i(T.props.children,v.overrides):C)}return t.set(x,y),x}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 h({defaults:y,children:x,preset:b=true,state:v}){let P=new Map;r(y,S=>{let k=Sg(S.props);k&&P.set(k,S);});let T=new Map;r(x,S=>{let k=o(S);k&&T.set(k,S);});let C=S=>Bt.Children.toArray(S).flatMap(k=>Bt.isValidElement(k)&&k.type===Bt.Fragment?C(k.props.children):[k]),E=C(x).filter(S=>!Bt.isValidElement(S)||!o(S));return jsxRuntime.jsx(e.Provider,{value:{defaults:P,overrides:T,state:v},children:b?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i(y,T),E]}):x})}return {Header:l,Title:s,Body:c,Footer:d,Apply:m,Cancel:u,Reset:g,Error:p,Field:f,Composition:h,useState:n,part:y=>a(y)}}function Be({kind:e,role:t="dialog",className:o,style:r,label:n,onClose:i,onKeyDown:a,panelRef:l,children:s,dismissOutside:c=true,sessionSignal:d,restoreFocus:m=true,describedBy:u}){let g=Bt.useRef(null),p=l??g,f=Bt.useRef(i);f.current=i;let[h,y]=Bt.useState(false),x=Kt();return Bt.useLayoutEffect(()=>{let b=p.current;if(!b)return;y(!b.parentElement?.closest(".docx-editor"));let v=b.ownerDocument.activeElement,P=()=>{b.open&&b.close?.();};return d?.addEventListener("abort",P),typeof b.showModal=="function"?b.showModal():b.setAttribute("open",""),(b.querySelector('input:not([disabled]),select:not([disabled]),button:not([disabled]),[tabindex="0"]')??b.querySelector("a[href]"))?.focus({preventScroll:true}),()=>{d?.removeEventListener("abort",P),typeof b.close=="function"&&b.open&&b.close(),m&&v?.isConnected&&v.focus({preventScroll:true});}},[p,d,m]),jsxRuntime.jsx("dialog",{ref:p,role:t,"aria-modal":"true","aria-label":n,"aria-describedby":u,className:`docx-dialog${h?` docx-editor${x?" dark":""}`:""}${o?` ${o}`:""}`,style:r,"data-docx-dialog":e,onCancel:b=>{b.preventDefault(),f.current();},onMouseDown:b=>b.stopPropagation(),onClick:b=>{if(c&&b.target===b.currentTarget){let v=b.currentTarget.getBoundingClientRect();(b.clientX<v.left||b.clientX>v.right||b.clientY<v.top||b.clientY>v.bottom)&&f.current();}b.stopPropagation();},onKeyDown:b=>{b.key==="Escape"&&!b.nativeEvent.isComposing?(b.preventDefault(),f.current()):editor.trapTabWithin(b.currentTarget,b.nativeEvent)?b.preventDefault():!b.nativeEvent.isComposing&&!b.defaultPrevented&&a?.(b),b.stopPropagation();},children:s})}function bo(e,t){let o=H(),r=Ld(),n=Bt.useRef(null);return Bt.useEffect(()=>{if(!e){n.current=null;return}o?.surface&&(n.current===null?n.current=o.mountGeneration:n.current!==o.mountGeneration&&t());},[e,o,r,t]),()=>!!o?.surface&&n.current===o.mountGeneration}function Ld(){let e=H(),t=Bt.useCallback(o=>{if(!e)return ()=>{};let r=true,n=_a(()=>{r&&o();}),i=[e.on("change",n),e.on("selectionChange",n),e.on("error",n)];return ()=>{r=false,i.forEach(a=>a());}},[e]);return Bt.useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function Pg(){let e=0,t=0,o=null,r=new Set,n=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(r));},subscribeShift(l){return r.add(l),()=>r.delete(l)},getReservation:()=>t,setReservation(l){let s=Math.max(0,Math.round(l));s!==t&&(t=s,a(n));},subscribeReservation(l){return n.add(l),()=>n.delete(l)},getViewport:()=>o,setViewport(l){l!==o&&(o=l,a(i));},subscribeViewport(l){return i.add(l),()=>i.delete(l)}}}var Ad=Bt.createContext(null);function Fr(){return Bt.useContext(Ad)}var kg=()=>0,Od=()=>()=>{};function Lr(){let e=Fr(),t=Bt.useCallback(r=>e?e.subscribeShift(r):Od(),[e]),o=Bt.useCallback(()=>e?e.getShift():0,[e]);return Bt.useSyncExternalStore(t,o,kg)}function wg(){let e=Fr(),t=Bt.useCallback(r=>e?e.subscribeReservation(r):Od(),[e]),o=Bt.useCallback(()=>e?e.getReservation():0,[e]);return Bt.useSyncExternalStore(t,o,kg)}function ke(){let e=Fr(),t=Bt.useCallback(n=>e?e.subscribeViewport(n):Od(),[e]),o=Bt.useCallback(()=>e?e.getViewport():null,[e]),r=Bt.useCallback(()=>null,[]);return Bt.useSyncExternalStore(t,o,r)}function Oo(e,t,o){let r=ke(),n=Bt.useRef({close:o,viewport:r});n.current={close:o,viewport:r},Bt.useEffect(()=>{let i=e.current;if(!(!t||!i))return eS(i,()=>n.current.close(),()=>n.current.viewport)},[e,t]);}function eS(e,t,o){let r=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();},n=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",r),e.addEventListener("focusout",n),()=>{e.removeEventListener("keydown",r),e.removeEventListener("focusout",n),i(),a();}}function lS(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason&&e.value===t.value}function Bd(e){return typeof e=="string"}function oe(e){let t=H(),{t:o}=L(),r=Bd(e)?e:editor.editorCommandKey(e),n=Bt.useRef(e);n.current=e;let i=Bt.useCallback(s=>{let c=n.current;if(Bd(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,r,o]),a=W(i,lS),l=Bt.useCallback(s=>{let c=editor.commandExecOptions(s),d=n.current;return Bd(d)?editor.runToolbarCommand(t,d,void 0,c??{}).ok:t?t.exec(d,c).ok:false},[t]);return Bt.useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[l,a])}var Hr=Bt.createContext({t:void 0,onSave:void 0});function cS(){return Bt.useContext(Hr)}function _l(e){let{t}=L();return o=>e?.(o)??t(o)}function ne(){let{t:e}=Bt.useContext(Hr);return _l(e)}var mS=()=>()=>{},fS=()=>true,gS=()=>false;function Yt(){let e=Bt.useSyncExternalStore(mS,fS,gS);return Bt.useCallback(t=>e?i18n.platformShortcut(t):t,[e])}function bS(e){let t=e.viteEnv?.DEV;return typeof t=="boolean"?t:e.hasProcess&&e.nodeEnv!=="production"}function hS(){try{return undefined}catch{return}}function bt(){let e=typeof process<"u";return bS({viteEnv:hS(),nodeEnv:e?"production":void 0,hasProcess:e})}var _g=new Set;function ar(e){!bt()||_g.has(e)||(_g.add(e),console.warn(`[docx-editor] ${e}`));}function Ig(e){ar(`Menu.Item and ContextMenu.Slot take the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function Ng(e){ar(`A hidden context-menu override names "${e}", but no packaged row has that id, so nothing is removed.`);}function Fg(){ar("A Menu.Item or ContextMenu.Slot has no slotId, so it renders nothing.");}function Lg(){ar("A Menu.Submenu has neither label nor labelKey, so its row has no name.");}function Hg(e){ar(`Toolbar.Button takes the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function Ag(){ar("A Toolbar.Button has no slotId, so it renders nothing.");}function Q(e){for(let t of editor.CHROME_GROUPS)for(let o of t.controls)if(editor.chromeSlotId(t,o)===e)return o;return null}function re(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 U(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function CS(e){if(e.slotId)return e.slotId;if(e.slot)return Hg(e.slot),e.slot;Ag();}function Bo(e){let{icon:t,asChild:o,className:r,children:n,hidden:i}=e,a=CS(e)??"",{execute:l,isActive:s,isEnabled:c,disabledReason:d,value:m}=oe(a),u=ne(),g=Yt();if(i||!a)return null;let p=Q(a),f=g(u(p?.labelKey??a)),h=editor.chromeSlotIsToggle(a),y={onClick:()=>l(),onMouseDown:U,disabled:!c,"data-slot":a,className:`docx-toolbar__button${r?` ${r}`:""}`,...s?{"data-active":""}:{},...c?{}:{"data-disabled":""},...h?{"aria-pressed":s}:{},...m!==null?{"data-value":m}:{},"aria-label":f,title:d??f};return o?jsxRuntime.jsx(J,{...y,children:n}):jsxRuntime.jsx("button",{type:"button",...y,children:t??n??re(p?.paths)})}Bo.docxToolbarPart=true;var DS=[{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"}],Og=[{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"}],Bg=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Nl=["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"],ir=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),Ut=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function RS(e){let t=[0,2,4].map(r=>parseInt(e.slice(r,r+2),16)),o=(Math.max(...t)+Math.min(...t))/2/255;return o===1?[Ut(5),Ut(15),Ut(25),Ut(35),Ut(50)]:o===0?[ir(50),ir(35),ir(25),ir(15),ir(5)]:o>=.8?[Ut(10),Ut(25),Ut(50),Ut(75),Ut(90)]:[ir(80),ir(60),ir(40),Ut(25),Ut(50)]}var MS=/^[0-9A-Fa-f]{6}$/;function _S(e,t){let o="";for(let r=0;r<6;r+=2){let n=Math.round(t(parseInt(e.slice(r,r+2),16)));o+=Math.max(0,Math.min(255,n)).toString(16).padStart(2,"0");}return o.toUpperCase()}function IS(e){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);return .299*t+.587*o+.114*r>230}function Tn({value:e,css:t,title:o,selected:r,apply:n}){return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch",style:{backgroundColor:t},"aria-label":o,"aria-pressed":r,title:o,"data-value":e,...r?{"data-selected":""}:{},...t.startsWith("var(")||IS(t.replace("#",""))?{"data-light":""}:{},onMouseDown:U,onClick:()=>n(e)})}function NS({apply:e,label:t,current:o,themeHexes:r}){let n=r.map(RS),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:[r.map((a,l)=>jsxRuntime.jsx(Tn,{value:a,css:`#${a.toLowerCase()}`,title:t(Nl[l]),selected:o===a,apply:e},`base-${l}`)),i.map(a=>r.map((l,s)=>{let c=n[s][a],d=_S(l,c.apply);return jsxRuntime.jsx(Tn,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Nl[s])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${s}`)}))]})]})}function FS(e){let{apply:t,label:o,current:r}=e,[n,i]=Bt.useState(""),a=MS.test(n);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(NS,{...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:DS.map(l=>jsxRuntime.jsx(Tn,{value:l.value,css:l.css,title:o(l.labelKey),selected:r===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:n,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(n.toUpperCase());}}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!a,onMouseDown:U,onClick:()=>t(n.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function Zd({apply:e,current:t}){let o=H(),r=ne(),n=o?.getDocumentThemeColors()??[],i=n.length===Nl.length?n.map(l=>l.hex):Bg,a=t?.toUpperCase()??null;return jsxRuntime.jsx(FS,{apply:e,label:r,current:a,themeHexes:i})}var LS=Og.filter(e=>e.value!=="white");function HS({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:LS.map(r=>jsxRuntime.jsx(Tn,{value:r.value,css:r.css,title:t(r.labelKey),selected:o===r.value,apply:e},r.value))})]})}function Wg(e){let{slot:t,defaultValue:o,cssOf:r,clear:n,body:i}=e,a=t==="text.color";return Object.assign(({className:s,hidden:c,icon:d})=>{let m=H(),{isEnabled:u,disabledReason:g}=oe(t),p=ne(),[f,h]=Bt.useState(false),[y,x]=Bt.useState(o),b=Bt.useRef(null);Oo(b,f,()=>h(false));let v=W(k=>{if(a){let w=k.formatting?.color;return w&&w.kind==="hex"?w.value.toUpperCase():null}return k.formatting?.highlight??null}),P=m?.getDocumentThemeColors()??[],T=P.length===Nl.length?P.map(k=>k.hex):Bg;Bt.useEffect(()=>{if(f)return editor.listenForOutsidePress({popup:b.current,close:()=>h(false)})},[f]);let C=Bt.useCallback(k=>{if(h(false),!m)return;m.focus();let w=editor.commandForSlotValue(t,k);w&&m.can(w).ok&&(m.exec(w),k!==n.value&&x(k));},[m]),E=Bt.useMemo(()=>Q(t),[]);if(c)return null;let S=p(E?.labelKey??t);return jsxRuntime.jsxs("div",{ref:b,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:U,onClick:()=>C(y),children:[d??re(E?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:r(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:U,onClick:()=>h(k=>!k),children:"\u25BE"}),f?jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":S,onMouseDown:U,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:U,onClick:()=>C(n.value),children:[jsxRuntime.jsx("span",{className:`docx-toolbar__swatch-clear-chip${n.value==="none"?" docx-toolbar__swatch-clear-chip--none":""}`,"aria-hidden":"true"}),p(n.labelKey)]}),i({apply:C,label:p,current:v,themeHexes:T})]}):null]})},{docxSlot:t})}var AS=new Map(Og.map(e=>[e.value,e.css])),Kd=Wg({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsxRuntime.jsx(Zd,{apply:e.apply,current:e.current})}),qd=Wg({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>AS.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsxRuntime.jsx(HS,{...e})});var zd=e=>e==="auto"?"currentColor":e==="byAuthor"?"var(--doc-review-author-0)":e==="none"?"transparent":`var(--doc-revision-color-${e})`;function Ll({label:e,value:t,values:o,disabled:r,change:n,t:i}){let a=Bt.useId(),[l,s]=Bt.useState(false),c=Bt.useRef(null),d=Bt.useRef(null),m=Bt.useRef(null);Bt.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]),Bt.useEffect(()=>{if(r&&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,r]);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:r,"aria-labelledby":`${a}-label ${a}-value`,"aria-expanded":l&&!r,"aria-controls":`${a}-options`,onClick:()=>s(!l),children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:zd(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||r,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),h=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;h!==null&&(g.preventDefault(),g.stopPropagation(),p[h]?.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:()=>{n(g),u();},children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:zd(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(Tn,{value:g,css:zd(g),title:i(`values.${g}`),selected:t===g,apply:p=>{n(p),u();}},g))})]})]})}var Zg=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],US=["byAuthor","auto",...editor.REVISION_MARKUP_COLORS];function Kg(e,t,o){let{values:r}=e,n=a=>{let l=a==="changedLines"?["none","leftBorder","rightBorder","outsideBorder"]:a==="deletions"||a==="movedFrom"?[...Zg,"hidden","caret","pound"]:Zg,s=(a==="movedFrom"||a==="movedTo")&&!r.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:r[a].mark,disabled:s,onChange:c=>e.setValue(a,{...r[a],mark:c.target.value}),children:l.map(c=>jsxRuntime.jsx("option",{value:c,children:t(`values.${c}`)},c))})]}),jsxRuntime.jsx(Ll,{label:t(`${a}Color`),value:r[a].color,values:US,disabled:s,t,change:c=>e.setValue(a,{...r[a],color:c})})]}),a!=="changedLines"&&jsxRuntime.jsx("div",{className:"docx-revision-markup-background",children:jsxRuntime.jsx(Ll,{label:t(`${a}Background`),value:r[a].background,values:["none","byAuthor",...editor.REVISION_MARKUP_COLORS],disabled:s,t,change:c=>e.setValue(a,{...r[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:r[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")}),n("insertions"),n("deletions"),n("changedLines")]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("moves")}),i("trackMoves"),n("movedFrom"),n("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(Ll,{label:t(`${a}Cells`),value:r.cells[a],values:["byAuthor","none",...editor.REVISION_MARKUP_COLORS],t,change:l=>e.setValue("cells",{...r.cells,[a]:l})},a))]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("formatting")}),i("trackFormatting"),n("formatting")]})]})}var Jt=St();function XS(){return Jt.useState()}function JS({session:e,...t}){return e?jsxRuntime.jsx(QS,{session:e,...t}):null}function QS({session:e,children:t,preset:o,className:r,style:n}){let i=Bt.useId(),{t:a}=L(),l=f=>a(`revisionMarkup.${f}`),s=Bt.useCallback(f=>e.subscribe(f),[e]),c=Bt.useCallback(()=>e.get(),[e]),d=Bt.useSyncExternalStore(s,c,c),[m,u]=Bt.useState(e.signal.aborted),g=Bt.useRef(null);Bt.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,h){e.set({[f]:h});},errors:{},isEnabled:!m&&e.canApply(),apply(){e.apply();},cancel(){e.cancel();},reset(){e.reset();}};return m?null:jsxRuntime.jsx(Be,{kind:"revisionMarkup",label:l("title"),className:["docx-revision-markup-dialog",r].filter(Boolean).join(" "),style:n,onClose:p.cancel,dismissOutside:false,sessionSignal:e.signal,children:jsxRuntime.jsx(Jt.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:Kg(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 Ia=Object.assign(JS,{Header:Jt.Header,Title:Jt.Title,Body:Jt.Body,Footer:Jt.Footer,Apply:Jt.Apply,Cancel:Jt.Cancel,Error:Jt.Error,Field:Jt.Field,Reset:Jt.Reset});function Vd(e){let t=H(),o=Bt.useRef(e.onRevisionMarkupChange);o.current=e.onRevisionMarkupChange;let{onRevisionMarkupChange:r,...n}=e,i=JSON.stringify(n);return Bt.useEffect(()=>t?.on("revisionMarkupChange",a=>o.current?.(a)),[t]),Bt.useEffect(()=>{t&&t.setRevisionMarkup(JSON.parse(i));},[t,i]),null}function Na({open:e,format:t,pending:o,error:r,onClose:n,className:i,style:a,children:l}){let{t:s}=L();if(!e)return null;let c=s(r?t==="pdf"?"toolbar.exportPdfFailed":"toolbar.exportMarkdownFailed":t==="pdf"?"toolbar.exportingPdf":"toolbar.exportingMarkdown");return jsxRuntime.jsx(Be,{kind:"export",label:c,role:r?"alertdialog":"dialog",className:`docx-export-dialog${o?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:n,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:r?"alert":"status",children:r||s("toolbar.exportDownloadHint")})}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:n,children:s(r?"common.close":"toolbar.exportContinueEditing")})})]})})}function Fa({open:e,pending:t,error:o,url:r,onClose:n,className:i,style:a,children:l}){let{t:s}=L();if(!e)return null;let c=s(o?"toolbar.printFailed":"toolbar.printPreparing"),d=r.startsWith("blob:")?r:"";return jsxRuntime.jsx(Be,{kind:"print",label:c,role:o?"alertdialog":"dialog",className:`docx-export-dialog docx-print-dialog${t?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:n,onKeyDown:m=>{editor.isChromePrintShortcut(m.nativeEvent)&&m.preventDefault();},children:l??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:c})]}),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&&d&&jsxRuntime.jsx("a",{className:"docx-dialog__link-button docx-print-dialog__open",href:d,target:"_blank",rel:"noopener noreferrer",children:s("toolbar.printOpenPdf")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:n,children:s(o?"common.close":"common.cancel")})]})]})})}var vt={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function En({text:e,x:t,y:o,className:r}){return jsxRuntime.jsx("div",{role:"tooltip",className:r,"data-testid":"docx-notes-preview",style:{position:"fixed",left:t,top:o,zIndex:vt.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:n=>{n.preventDefault(),n.stopPropagation();},children:e})}function Sn({noteKind:e,x:t,y:o,onDelete:r,onConvert:n,onConvertAll:i,onOpenProperties:a,onClose:l,deleteEnabled:s,convertEnabled:c,convertAllEnabled:d,deleteDisabledReason:m,convertDisabledReason:u,convertAllDisabledReason:g,className:p}){let{t:f}=L();return jsxRuntime.jsxs("div",{role:"menu",className:p,onKeyDown:h=>{h.key==="Escape"&&l();},"data-testid":"docx-notes-menu",style:{position:"fixed",left:t,top:o,zIndex:vt.popover,minWidth:160,background:"var(--doc-popover-bg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",padding:4},onMouseDown:U,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!s,title:m,onClick:r,children:f("notes.delete")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!c,title:u,onClick:n,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 lP(e){return t=>Bt.createElement(e,t)}var Vg=new WeakMap,sP=0;function Se(e,t,o){if(e===false)return null;let r=e(t);if(!o)return r;let n=Vg.get(o);return n===void 0&&Vg.set(o,n=++sP),Bt.createElement(Bt.Fragment,{key:n},r)}var jd=Bt.createContext(void 0),kt=()=>Bt.useContext(jd);function Pn(e,t,o){let r=e.getBoundingClientRect();return {left:t-r.left-e.clientLeft+e.scrollLeft,top:o-r.top-e.clientTop+e.scrollTop}}function Oa(e){return e.paragraphId===""}var bP=4096,kn=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),hP=e=>e;function yP(e){let t=n=>!!n&&(n.width>0||n.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 r=o?o.getSelection():null;if(r&&r.rangeCount>0){let n=r.getRangeAt(0),i=n.getBoundingClientRect();if(t(i))return {left:i.left,top:i.bottom};let a=n.startContainer,s=(editor.isElementNode(a)?a:a.parentElement)?.getBoundingClientRect();if(t(s))return {left:s.left,top:s.bottom}}return null}var Ba=Bt.createContext(null),Yd=Bt.createContext(null);function Xd(){let e=Bt.useContext(Yd);Bt.useEffect(()=>e?.(),[e]);}function xP(){let e=Bt.useContext(Ba);Xd();let t=Hl(e===null);return e??t}function Hl(e=true){let t=H(),o=ke(),r=Bt.useRef(o);r.current=o;let[n,i]=Bt.useState(kn),a=Bt.useRef(null),l=Bt.useRef(""),s=Bt.useRef(false),c=Bt.useRef(n);c.current=n;let d=W(hP),m=t?t.can({type:"insertText",text:""}).ok:false,u=Bt.useCallback(()=>{l.current="",s.current=false;let E=a.current;E&&(E.editor.releaseSelection(E.pin),a.current=null);},[]),g=Bt.useCallback((E=false)=>{let S=l.current;return S===""||!t?false:!s.current&&t.surface?.hyperlinks.selectionIsPendingDeletion()===true?true:E&&S.length>bP?false:t.query({type:"selectedText"})!==S},[t]),p=Bt.useCallback((E,S)=>{u(),i({mode:E?"reading":"editing",link:E??null,anchor:S??null,text:E?.text??"",url:E?E.kind==="internal"?`#${E.anchor??""}`:E.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,u]),f=Bt.useCallback(()=>{u(),i(kn);},[u]);Bt.useEffect(()=>u,[u]);let h=Bt.useCallback(()=>{let E=yP(r.current);u();let S=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(S&&Oa(S)){p(S,E);return}if(S){i({mode:"editing",link:S,anchor:E,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 k=t?.surface?.hyperlinks.wordAtCaret()??null;k&&t?.surface?.setSelection({anchor:k.from,head:k.to});let w=t?.query({type:"selectedText"})??"",I=t?.retainSelection()??null;t&&I&&(a.current={editor:t,pin:I}),l.current=w,s.current=t?.surface?.hyperlinks.selectionIsPendingDeletion()===true,i({mode:"editing",link:null,anchor:E,text:w,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,p,u]);Bt.useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:E=>p(E.link,{left:E.rect.left,top:E.rect.bottom}),onRequest:h})},[t,e,p,h]),Bt.useEffect(()=>{let E=c.current;if(E.mode!=="reading"||!E.link)return;let S=Oa(E.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;S&&S.id===E.link.id||i(kn);},[d,t]),Bt.useEffect(()=>{let E=c.current;if(E.mode!=="editing"||E.link)return;let S=t?.surface;S&&(S.retainedSelection()&&!g(true)||f());},[d,t,g,f]);let y=Bt.useCallback(async()=>{let E=c.current.link?.href;if(!E)return false;try{await editor.hostWindowOf(r.current).navigator.clipboard.writeText(E);}catch{return false}return i(S=>({...S,copied:true})),true},[]),x=Bt.useCallback(()=>{i(E=>({...E,mode:"editing",copied:false,error:false}));},[]),b=Bt.useCallback(E=>{i(S=>({...S,text:E,copied:false,error:false}));},[]),v=Bt.useCallback(E=>{i(S=>({...S,url:E,copied:false,error:false}));},[]),P=Bt.useCallback(()=>{let E=c.current,S=t?.surface?.hyperlinks;if(!S)return false;if(!E.link&&g())return f(),false;let k=E.url.trim();if(k.length===0)return i(O=>({...O,error:true})),false;let w=k.startsWith("#");return S.applyHyperlink({...w?{anchor:k.slice(1)}:{url:k},...E.text.trim().length>0?{text:E.text}:{}})?(f(),true):(i(O=>({...O,error:true})),false)},[t,f,g]),T=Bt.useCallback(()=>{let E=t?.surface?.hyperlinks,S=c.current.link;if(!E)return false;let k=E.removeHyperlink(S?.id);return k&&f(),k},[t,f]),C=Bt.useCallback(()=>{let E=t?.surface?.navigation,S=c.current.link;if(!E||!S)return false;if(S.kind==="internal"){let w=S.anchor?E.goToBookmark(S.anchor):false;return w&&i(kn),w}let k=E.openExternal(S.href);return k&&i(kn),k},[t]);return Bt.useMemo(()=>({state:n.mode==="closed"?kn:{...n,canEdit:m},open:p,openAtCaret:h,close:f,copy:y,beginEdit:x,setText:b,setUrl:v,commitEdit:P,unlink:T,openTarget:C}),[n,m,p,h,f,y,x,b,v,P,T,C])}function Br(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Wa(){let e=H();return Bt.useCallback(()=>{e?.focus();},[e])}var Al=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"})}),wP="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",DP="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",RP="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",MP="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 _P({className:e,asChild:t,hidden:o,children:r,preset:n=true}){let i=xo();Xd();let a=Bt.useRef(null),{state:l,close:s}=i,c=Wa();Bt.useEffect(()=>{if(l.mode==="closed")return;let h=b=>{b.key==="Escape"&&(b.preventDefault(),s(),c());},y=editor.hostDocumentOf(a.current);y.addEventListener("keydown",h);let x=editor.listenForOutsidePress({popup:y,contains:b=>a.current?.contains(b)===true,close:s});return ()=>{y.removeEventListener("keydown",h),x();}},[l.mode,s,c]);let[d,m]=Bt.useState(null);Bt.useLayoutEffect(()=>{let h=l.anchor,y=a.current;if(!h||!y){m(null);return}let x=y.offsetParent;if(!x){m(null);return}let{left:b,top:v}=Pn(x,h.left,h.top),P=Math.max(0,x.scrollWidth-y.offsetWidth);m({left:Math.max(0,Math.min(b,P)),top:v});},[l.anchor]);let{t:u}=L(),g=l.mode==="editing"?u(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):u("hyperlinkPopup.editLink"),p=n?jsxRuntime.jsx(IP,{children:r}):r;if(o)return l.mode==="closed"?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:r});let f={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:Br,style:d??void 0,"aria-label":g};return l.mode==="closed"?null:t?jsxRuntime.jsx(J,{...f,children:r}):jsxRuntime.jsx("div",{...f,children:p})}function IP({children:e}){let{state:t}=xo(),o=Bt.useMemo(()=>NP(e),[e]),r=(i,a)=>i in o?o[i]:a;if(t.mode==="editing")return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r("Fields",jsxRuntime.jsx(ru,{})),r("Error",jsxRuntime.jsx(au,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[r("Apply",jsxRuntime.jsx(nu,{})),r("Cancel",jsxRuntime.jsx(iu,{}))]}),o.__extra]});let n=t.canEdit&&!(t.link&&Oa(t.link));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r("Url",jsxRuntime.jsx(Qd,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[r("Copy",jsxRuntime.jsx(eu,{})),n?r("Edit",jsxRuntime.jsx(tu,{})):null,n?r("Unlink",jsxRuntime.jsx(ou,{})):null]}),o.__extra]})}function NP(e){let t={},o=[],r=n=>{if(Array.isArray(n)){n.forEach(r);return}if(!n||typeof n!="object"||!("type"in n)){n&&o.push(n);return}if(n.type===Bt.Fragment){r(n.props.children);return}let i=n.type.docxHyperLinkPart;i?t[i]=n:o.push(n);};return r(e),o.length>0&&(t.__extra=o),t}function xo(){return Bt.useContext(Ba)??FP}var FP={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 Qd({className:e,asChild:t,hidden:o,children:r}){let{state:n,openTarget:i}=xo(),{t:a}=L();if(o||!n.link)return null;let l=!n.link.href,s=n.link.kind==="internal",c=s?`#${n.link.anchor??""}`:n.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:Br,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsxRuntime.jsx(J,{...u,className:e,children:r}):l?jsxRuntime.jsxs("span",{...u,children:[r??d,jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:m})]}):jsxRuntime.jsxs("button",{...u,children:[r??d,Al(MP)]})}Qd.docxHyperLinkPart="Url";function eu({className:e,asChild:t,hidden:o,children:r,icon:n}){let{state:i,copy:a}=xo(),{t:l}=L();if(o||!i.link?.href)return null;let s=i.copied?l("editor.linkCopied"):l("hyperlinkPopup.copyLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...i.copied?{"data-copied":""}:{},"aria-label":s,title:s,onMouseDown:Br,onClick:()=>{a();}};return t?jsxRuntime.jsx(J,{...c,className:e,children:r}):jsxRuntime.jsx("button",{...c,children:n??r??Al(wP)})}eu.docxHyperLinkPart="Copy";function tu({className:e,asChild:t,hidden:o,children:r,icon:n}){let{beginEdit:i}=xo(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.editLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":l,title:l,onMouseDown:Br,onClick:()=>i()};return t?jsxRuntime.jsx(J,{...s,className:e,children:r}):jsxRuntime.jsx("button",{...s,children:n??r??Al(DP)})}tu.docxHyperLinkPart="Edit";function ou({className:e,asChild:t,hidden:o,children:r,icon:n}){let{unlink:i}=xo(),a=Wa(),{t:l}=L();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:Br,onClick:()=>{i()&&a();}};return t?jsxRuntime.jsx(J,{...c,className:e,children:r}):jsxRuntime.jsx("button",{...c,children:n??r??Al(RP)})}ou.docxHyperLinkPart="Unlink";function ru({className:e,hidden:t}){let{state:o,setText:r,setUrl:n,commitEdit:i,close:a}=xo(),l=Wa(),{t:s}=L(),c=Bt.useRef(null),d=Bt.useId(),m=Bt.useId();Bt.useEffect(()=>{o.mode==="editing"&&(c.current?.focus({preventScroll:true}),c.current?.select());},[o.mode]);let u=Bt.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=>r(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=>n(g.target.value),onKeyDown:u})]})}ru.docxHyperLinkPart="Fields";function nu({className:e,asChild:t,hidden:o,children:r}){let{state:n,commitEdit:i}=xo(),a=Wa(),{t:l}=L();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:n.url.trim().length===0,onMouseDown:Br,onClick:()=>{i()&&a();}};return t?jsxRuntime.jsx(J,{...c,className:e,children:r}):jsxRuntime.jsx("button",{...c,children:r??s})}function au({className:e,hidden:t}){let{state:o}=xo(),{t:r}=L();return t||!o.error?null:jsxRuntime.jsx("div",{className:`docx-hyperlink-popup__error${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-error",role:"alert",children:r("hyperlinkPopup.refused")})}au.docxHyperLinkPart="Error";nu.docxHyperLinkPart="Apply";function iu({className:e,asChild:t,hidden:o,children:r}){let{close:n}=xo(),i=Wa(),{t:a}=L();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:Br,onClick:()=>{n(),i();}};return t?jsxRuntime.jsx(J,{...s,className:e,children:r}):jsxRuntime.jsx("button",{...s,children:r??l})}iu.docxHyperLinkPart="Cancel";var Za=Object.assign(_P,{Url:Qd,Copy:eu,Edit:tu,Unlink:ou,Fields:ru,Error:au,Apply:nu,Cancel:iu});var wt={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function OP(e){return e==="sdtLocked"||e==="sdtContentLocked"}function BP(e){return e==="contentLocked"||e==="sdtContentLocked"}function su(e,t){return !e.ok&&e.code===t}function vo(){let e=Bt.useContext(cu),t=Ol();return e??t}function Ol(){let e=H(),[t,o]=Bt.useState(false),[r,n]=Bt.useState(false),[i,a]=Bt.useState(false),l=W(C=>C),s=e?.surface??null,c=s?.contentControls;Bt.useEffect(()=>{n(c?.showAll()??s?.state().contentControls.showAll??false),a(c?.formFill()??s?.state().contentControls.formFill??false);},[l,c,s]);let d=Bt.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:BP(C.effectiveLock)||F==="locked",removalLocked:OP(C.effectiveLock)||D==="locked",placeholder:C.placeholder,bound:C.bound||F==="bound",effectiveLock:C.effectiveLock}}let E=e.query({type:"contentControlAt"});if(!E)return null;let S=c?.disabledReason(E.id,"edit")??null,k=c?.disabledReason(E.id,"remove")??null,w=e.can({type:"setContentControlValue",value:""}),I=e.can({type:"removeContentControl"}),O=E.locked===true||S==="locked"||su(w,"locked"),N=S==="bound"||su(w,"bound"),B=k==="locked"||su(I,"locked");return {id:E.id,tag:E.tag??null,alias:E.alias??null,controlType:E.controlType,locked:O,removalLocked:B,placeholder:false,bound:N,effectiveLock:null}},[e,l,c]),m=Bt.useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=Bt.useCallback(C=>{c?.setShowAll(C),n(C);},[c]),g=Bt.useCallback(C=>{c?.setFormFill(C),a(C);},[c]),p=Bt.useCallback(()=>u(!r),[u,r]),f=Bt.useCallback(()=>g(!i),[g,i]),h=Bt.useCallback(()=>o(true),[]),y=Bt.useCallback(()=>o(false),[]),x=Bt.useCallback(()=>o(C=>!C),[]),b=Bt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let E=c.disabledReason(d.id,"edit");return E==="locked"?"the content control is locked":E==="bound"?"the content control is bound to external data":E==="notFound"?"the content control was not found":E}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]),v=Bt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let E=c.disabledReason(d.id,"remove");return E==="locked"?"the content control is locked":E==="notFound"?"the content control was not found":E}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]),P=Bt.useCallback(C=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c&&d){let E=c.disabledReason(d.id,"edit");if(E)return {ok:false,code:E==="bound"?"bound":E==="locked"?"locked":"notFound",reason:E==="bound"?"the content control is bound to external data":E==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:C})},[e,c,d]),T=Bt.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 E=c.disabledReason(C,"remove");return E?{ok:false,code:E==="locked"?"locked":"notFound",reason:E==="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 Bt.useMemo(()=>({control:d,controls:m,showAll:r,formFill:i,inspectorOpen:t,canSetValue:b===null&&d!==null,canRemove:v===null&&d!==null,setValueDisabledReason:b,removeDisabledReason:v,setShowAll:u,toggleShowAll:p,setFormFill:g,toggleFormFill:f,openInspector:h,closeInspector:y,toggleInspector:x,remove:T,setValue:P}),[d,m,r,i,t,b,v,u,p,g,f,h,y,x,T,P])}var cu=Bt.createContext(null);function du(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var ob=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"})}),UP="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",zP="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",$P={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},VP={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},GP={color:"var(--doc-text-muted)",flexShrink:0},jP={textAlign:"right",wordBreak:"break-word"},YP={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},XP={display:"flex",gap:8,marginTop:4},rb={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 JP(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 QP(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 wn({label:e,value:t,testId:o}){return jsxRuntime.jsxs("div",{style:VP,"data-testid":o,children:[jsxRuntime.jsx("span",{style:GP,children:e}),jsxRuntime.jsx("span",{style:jP,children:t})]})}function ek({className:e,asChild:t,hidden:o,children:r,preset:n=true}){let i=vo(),a=Bt.useRef(null),l=Bt.useId(),{t:s}=L(),{control:c,inspectorOpen:d,closeInspector:m}=i;if(Bt.useEffect(()=>{if(!d)return;let f=x=>{x.key==="Escape"&&(x.preventDefault(),m());},h=editor.hostDocumentOf(a.current);h.addEventListener("keydown",f);let y=editor.listenForOutsidePress({popup:h,contains:x=>a.current?.contains(x)===true,close:m});return ()=>{h.removeEventListener("keydown",f),y();}},[d,m]),Bt.useEffect(()=>{d&&!c&&m();},[d,c,m]),o||!d||!c)return null;let u=n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(nb,{}),jsxRuntime.jsx(ab,{}),jsxRuntime.jsx("div",{style:XP,children:jsxRuntime.jsx(ib,{})}),r]}):r,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:$P,onMouseDown:f=>{du(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(J,{...g,children:p}):jsxRuntime.jsx("div",{...g,children:p})}function nb({className:e,asChild:t,hidden:o,children:r}){let{closeInspector:n}=vo(),{t:i}=L();if(o)return null;let a={style:YP,className:e??void 0,"data-testid":"content-control-inspector-header"},l=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r??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:{...rb,padding:4,border:"none",background:"transparent"},onMouseDown:du,onClick:()=>n(),children:ob(UP)})]});return t?jsxRuntime.jsx(J,{...a,children:l}):jsxRuntime.jsx("div",{...a,children:l})}function ab({className:e,asChild:t,hidden:o,children:r}){let{control:n}=vo(),{t:i}=L();if(o||!n)return null;let a=i("contentControl.inspectorPanel.empty"),l=i("contentControl.inspectorPanel.yes"),s=i("contentControl.inspectorPanel.no"),c=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.alias"),value:n.alias??a,testId:"content-control-inspector-alias"}),jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.tag"),value:n.tag??a,testId:"content-control-inspector-tag"}),jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.type"),value:i(JP(n.controlType)),testId:"content-control-inspector-type"}),jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.lock"),value:i(QP(n)),testId:"content-control-inspector-lock"}),jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.placeholder"),value:n.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.bound"),value:n.bound?l:s,testId:"content-control-inspector-bound"}),n.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,n.locked?jsxRuntime.jsx("p",{"data-testid":"content-control-inspector-locked-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},"aria-live":"polite",children:i("contentControl.inspectorPanel.lockedNote")}):null]}),d={className:e??void 0,"data-testid":"content-control-inspector-fields",style:{display:"flex",flexDirection:"column",gap:8}};return t?jsxRuntime.jsx(J,{...d,children:c}):jsxRuntime.jsx("div",{...d,children:c})}function ib({className:e,asChild:t,hidden:o,icon:r,children:n}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:s}=vo(),{t:c}=L();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:rb,onMouseDown:du,onClick:()=>{l().ok&&s();}},u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r??n??ob(zP),jsxRuntime.jsx("span",{children:d})]});return t?jsxRuntime.jsx(J,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}var Ua=Object.assign(ek,{Header:nb,Fields:ab,Remove:ib});var ak=e=>e;function gu(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function za(){let e=H(),{t}=L(),[o,r]=Bt.useState(null),[n,i]=Bt.useState(null),a=Bt.useRef(null),l=Bt.useRef(null),s=Bt.useRef(null),c=Bt.useId(),d=Bt.useId(),m=Bt.useId(),u=o?.activation??null,g=W(ak),p=Bt.useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let b=e.surface.equations.can(u.equation.id,"replace"),v=e.surface.equations.can(u.equation.id,"remove"),P=b.ok?v.ok?null:v.reason:b.reason;return {replaceEnabled:b.ok,removeEnabled:v.ok,reason:P?i18n.localizeDisabledReason(P,t):null}},[u,e,g,t]),f=Bt.useCallback((b=false)=>{s.current?.(),s.current=null,r(null),b&&e&&queueMicrotask(()=>e.focus());},[e]);Bt.useEffect(()=>{if(!e)return;let b=e.setEquationChrome({onPopover:v=>{s.current?.();let P=e.surface;if(P&&typeof P.retainSelection=="function"){let T=P.retainSelection();s.current=()=>P.releaseSelection(T);}else s.current=null;r({activation:v,mountGeneration:e.mountGeneration,draft:v.equation.linear,error:false});}});return ()=>{b(),s.current?.(),s.current=null,r(null);}},[e,f]),Bt.useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&f();},[e,g,o,f]),Bt.useEffect(()=>{if(!o)return;let b=a.current,v=b?.ownerDocument,P=v?.defaultView;if(!b||!v||!P)return;let T=E=>{E.key==="Escape"&&(E.preventDefault(),f(true));},C=E=>{editor.isDomNode(E.target)&&b.contains(E.target)||f();};return v.addEventListener("keydown",T),v.addEventListener("pointerdown",C,true),()=>{v.removeEventListener("keydown",T),v.removeEventListener("pointerdown",C,true);}},[o,f]),Bt.useLayoutEffect(()=>{if(!u){i(null);return}let b=a.current;if(!b)return;let v=b.offsetParent;if(!v){i(null);return}let P=u.rect,T=Pn(v,P.left,P.bottom),C=Math.max(0,v.scrollWidth-b.offsetWidth);i({left:Math.max(0,Math.min(T.left,C)),top:T.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[u]);let h=Bt.useCallback(()=>{if(!o||!e?.surface||!p.replaceEnabled)return false;let b=e.surface.equations.applyEquation(o.activation.equation.id,o.draft);return b?f(true):r(v=>v&&{...v,error:true}),b},[e,o,f,p.replaceEnabled]),y=Bt.useCallback(()=>{if(!o||!e?.surface||!p.removeEnabled)return false;let b=e.surface.equations.removeEquation(o.activation.equation.id);return b?f(true):r(v=>v&&{...v,error:true}),b},[e,o,f,p.removeEnabled]);if(!o)return null;let x=[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:n??void 0,onMouseDown:gu,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:t("equationPopup.inputLabel")}),jsxRuntime.jsx("input",{id:c,ref:l,className:"docx-equation-popup__input","data-testid":"equation-popup-input",value:o.draft,placeholder:t("equationPopup.placeholder"),spellCheck:false,"aria-describedby":x||void 0,onChange:b=>r(v=>v&&{...v,draft:b.target.value,error:false}),onKeyDown:b=>{b.key!=="Enter"||b.nativeEvent.isComposing||(b.preventDefault(),h());}}),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:gu,onClick:h,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:gu,onClick:y,children:t("equationPopup.delete")})]})]})}var cb="review.comments",bu="review.addComment";function db(e){return e!==cb?e:(ar(`The context-menu row "${cb}" is now "${bu}". The old id still works in this release; write "${bu}".`),bu)}var lk="input, textarea, select",sk="[data-docx-form-dropdown]",ck=".docx-paginated-surface:not(.docx-editor__loading-surface)",dk=".docx-image-selection-overlay";function ub(e,t){if(!editor.isElementNode(t))return false;let o=t.closest(lk);if(o&&!o.matches(sk))return false;let r=e.querySelector(ck);return r?r.contains(t)||t.contains(r)||!!t.closest(dk):true}function Mn(e,t){if(!Bt.isValidElement(e)||e.type!==Bt.Fragment)return null;let r=Bt.Children.toArray(e.props.children).map(t).filter(n=>n!==null);return r.length===1?r[0]:null}function Bl({entries:e,children:t,preset:o,keyOfEntry:r,keyOfChild:n,renderEntry:i,childrenOfEntry:a,onUnmatched:l}){if(!o)return t;let s=new Map,c=[];for(let p of Bt.Children.toArray(t)){let f=n(p);f?s.set(f,p):c.push(p);}let d=new Set,m=p=>p.map((f,h)=>{let y=r(f,h);d.add(y);let x=a?.(f),b=x?m(x):void 0,v=s.get(y);return jsxRuntime.jsx(Bt.Fragment,{children:v??i(f,h,b)},y)}),u=m(e),g=[...s.entries()].filter(([p])=>!d.has(p)).map(([p,f])=>(l?.(p,f),jsxRuntime.jsx(Bt.Fragment,{children:f},p)));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u,g,c]})}var fk="review.addComment",gk=e=>e.editingMode==="viewing";function Wl(e){let{isEnabled:t,disabledReason:o}=oe(fk),r=W(gk);return t?{isEnabled:t,reason:null}:{isEnabled:t,reason:r?e("editingMode.viewingHint"):o}}var $a=Bt.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}),_n="docx-menubar-more",Zl=Bt.createContext({measuring:false,overflow:new Set,inMore:false});function gb(){return Bt.useContext(Zl)}function Je(){return Bt.useContext($a)}function Pe(){let{t:e}=Je(),{t}=L();return o=>e?.(o)??t(o)}var In=Bt.createContext(-1);var bk='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Wr(e){return [...e.querySelectorAll(bk)].filter(t=>t.closest('[role="menu"]')===e)}function xu(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function Qt(e,t,o){if(e.length===0)return false;let r=t?e.indexOf(t):-1,n=r===-1?o>0?0:e.length-1:(r+o+e.length)%e.length;return e[n]?.focus(),true}function eo(e,t){let o=t==="first"?e[0]:e[e.length-1];return o?(o.focus(),true):false}function vu(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 bb(e,t,o){return !o||o.ownerDocument===t?false:o.contains(e)}var Nn="data-toolbar-group",xb=editor.TOOLBAR_ITEM_ATTRIBUTE,Fn="data-toolbar-fixed",ql="data-toolbar-more",Dk=34,Kl=new Map;function Cu(e,t,o){let r=Bt.useRef(null),n=Bt.useRef({itemWidths:new Map,groupBases:new Map,groupGaps:new Map,more:Dk}),[i,a]=Bt.useState(Kl),l=Bt.useRef(i);l.current=i;let s=Bt.useRef({groups:t,order:o});s.current={groups:t,order:o};let c=editor.toolbarGroupsKey(t),d=Bt.useRef(c),m=o.join("\0"),u=Bt.useCallback(()=>{let p=r.current;if(!p||!e)return;let f=editor.readToolbarRow(p,n.current,editor.toolbarItemKey),h=l.current.size===0&&f.overflowing===false,y=editor.toolbarGroupsKey(s.current.groups),x=d.current===y;d.current=y;let b=h?Kl:editor.toolbarOverflowItems({...f,groups:s.current.groups,order:s.current.order,itemWidths:n.current.itemWidths,groupBases:n.current.groupBases,groupGaps:n.current.groupGaps,...x?{previous:l.current}:{},hysteresis:editor.TOOLBAR_OVERFLOW_HYSTERESIS});editor.sameItemOverflow(b,l.current)||(l.current=b,a(b));},[e]),g=Bt.useCallback(p=>{r.current=p;},[]);return Bt.useLayoutEffect(()=>{if(!e){l.current.size>0&&(l.current=Kl,a(Kl));return}u();},[e,c,u,m]),Bt.useEffect(()=>{let p=r.current,f=p?editor.hostWindowOf(p):null;if(!e||!p||!f||typeof f.ResizeObserver>"u")return;let h=0,y=new f.ResizeObserver(()=>{h===0&&(h=f.requestAnimationFrame(()=>{h=0,u();}));});y.observe(p),p.parentElement&&y.observe(p.parentElement);for(let x of p.querySelectorAll(`[${Nn}], [${Fn}]`))y.observe(x);return ()=>{h!==0&&f.cancelAnimationFrame(h),y.disconnect();}},[e,c,u,m,i]),{attach:g,overflow:i}}function vb(e,t,o){let r=t.map(l=>({id:l,items:[l]})),{attach:n,overflow:i}=Cu(e,r,o),a=Bt.useMemo(()=>new Set(i.keys()),[i]);return {attach:n,overflow:a}}function Cb(e,t,o){let r=e.overflow.has(t),n=t===_n;return {skip:e.inMore?!r:r,asSubmenu:e.inMore&&r,iconOnly:n,rootAttributes:{...e.measuring&&!n?{[Nn]:t}:{},...n?{[ql]:""}:{}},tabStop:o===t||n&&o!==null&&e.overflow.has(o)}}function Tb(e,t,o){let[r,n]=Bt.useState(void 0);return Bt.useLayoutEffect(()=>{if(!e){n(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});n({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]),r}var Sb=12700,Eb=96;function Lk(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function Hk(e,t,o,r){let n=e*72/o,i=t*72/r;return {widthPoints:Math.max(1,Math.round(n*100)/100),heightPoints:Math.max(1,Math.round(i*100)/100)}}function Ul(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(!Lk(o))return o==="image/svg+xml"||o==="image/tiff"?{ok:false,reasonKey:"imageInsert.errors.unsupportedFormat"}:{ok:false,reasonKey:"imageInsert.errors.invalidSignature"};let r=editor.validateRasterHeader(e,o);if(!r)return {ok:false,reasonKey:"imageInsert.errors.invalidSignature"};if(r.pixelWidth*r.pixelHeight>t.maxPixels||r.pixelWidth>t.maxDimension||r.pixelHeight>t.maxDimension)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let{widthPoints:i,heightPoints:a}=Hk(r.pixelWidth,r.pixelHeight,r.dpiX??Eb,r.dpiY??Eb);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function cr(e){return Math.round(e/Sb*100)/100}function Ga(e){return Math.round(e*Sb)}function Tu({message:e,onClose:t,className:o,style:r,children:n}){let{t:i}=L();return jsxRuntime.jsx(Be,{kind:"imageInsertError",role:"alertdialog",label:i("imageInsert.errors.title"),className:o,style:r,onClose:t,onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing&&(a.preventDefault(),t());},children:n??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 kb="image/png,image/jpeg,image/gif",Su=Bt.createContext(null);function Db(){let e=Bt.useContext(Su);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function ja(){return Bt.useContext(Su)}function $l({children:e}){let t=H(),{t:o}=L(),r=Bt.useRef(null),n=Bt.useRef(false),i=kt(),[a,l]=Bt.useState(null),s=Bt.useRef(null),c=Bt.useCallback(()=>editor.toolbarCommandState(t,"image.insert"),[t]),d=W(c,(b,v)=>b.enabled===v.enabled&&b.disabledReason===v.disabledReason),m=d.enabled,u=i18n.localizeDisabledReason(d.disabledReason,o),g=Bt.useCallback(async b=>{if(!t||n.current)return;let v=Ul(b);if(!v.ok){l(o(v.reasonKey));return}let P={type:"insertImage",data:v.bytes,mime:v.mime,widthPoints:v.widthPoints,heightPoints:v.heightPoints};n.current=true;try{let T=await editor.executeImageCommand(t,P);T.ok?t.focus():l(i18n.localizeDisabledReason(zk(T.reason)??null,o)??o("imageInsert.errors.refused"));}finally{n.current=false;}},[t,o]),p=Bt.useCallback(async b=>{let v=b?.[0];if(!v)return;let P=await v.arrayBuffer();await g(new Uint8Array(P));},[g]),f=Bt.useCallback(async b=>{if(!b)return;let v=[...b.files].find(P=>P.type.startsWith("image/"));if(v){await p([v]);return}for(let P of b.items){if(P.kind!=="file"||!P.type.startsWith("image/"))continue;let T=P.getAsFile();if(!T)continue;let C=await T.arrayBuffer();await g(new Uint8Array(C));return}},[g,p]),h=Bt.useCallback(()=>{if(!m)return;let b=r.current,v=t?editor.editorHostDocument(t):null;if(!v||!b||b.ownerDocument===v){b?.click();return}s.current?.remove();let P=v.createElement("input");P.type="file",P.accept=kb,P.hidden=true,P.tabIndex=-1,P.setAttribute("aria-hidden","true");let T=()=>{P.remove(),s.current===P&&(s.current=null);};P.addEventListener("change",()=>{p(P.files).finally(T);},{once:true}),P.addEventListener("cancel",T,{once:true}),v.body.append(P),s.current=P,P.click();},[t,m,p]),y=Bt.useCallback(async b=>{let v=b.currentTarget;await p(v.files),v.value="";},[p]),x=Bt.useMemo(()=>({openFilePicker:h,insertFromFileList:p,insertFromDataTransfer:f,isEnabled:m,disabledReason:u,inputRef:r,onInputChange:y}),[h,p,f,m,u,y]);return jsxRuntime.jsxs(Su.Provider,{value:x,children:[jsxRuntime.jsx("input",{ref:r,type:"file",accept:kb,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:y,onMouseDown:b=>b.stopPropagation()}),e,a!==null&&(i?.imageInsertError!==void 0?Se(i.imageInsertError,{message:a,onClose:()=>l(null)}):jsxRuntime.jsx(Tu,{message:a,onClose:()=>l(null)}))]})}function Vl({className:e,hidden:t,asChild:o,children:r}){let{openFilePicker:n,isEnabled:i,disabledReason:a}=Db(),l=ne();if(t)return null;let s=Q("image.insert"),c=l(s?.labelKey??"toolbar.image"),d={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":c,title:a??c,onMouseDown:U,onClick:n};return o?jsxRuntime.jsx(J,{...d,children:r}):jsxRuntime.jsx("button",{...d,children:r??re(s?.paths)})}Vl.docxSlot="image.insert";var Ya=Object.assign(Vl,{docxSlot:"image.insert"});function zk(e){return e&&/\s/.test(e)?e:void 0}var Pu=6,_b=6;function jl({slot:e,label:t,onInserted:o,className:r}){let n=H(),{isEnabled:i}=oe(e),[a,l]=Bt.useState(null),[s,c]=Bt.useState({rows:1,cols:1}),d=Bt.useRef(null),m=Bt.useCallback((p,f)=>{if(!n||!i)return;let h={type:"insertTable",rows:p,cols:f};n.can(h).ok&&(n.exec(h),o(),n.focus());},[n,i,o]),u=Bt.useCallback(p=>{c(f=>{let h={rows:Math.min(_b,Math.max(1,f.rows+(p.rows??0))),cols:Math.min(Pu,Math.max(1,p.toCol??f.cols+(p.cols??0)))};return l(h),queueMicrotask(()=>d.current?.querySelector(`[data-cell="${h.rows}x${h.cols}"]`)?.focus()),h});},[]),g=[];for(let p=1;p<=_b;p+=1){let f=[];for(let h=1;h<=Pu;h+=1){let y=!!a&&p<=a.rows&&h<=a.cols;f.push(jsxRuntime.jsx("button",{type:"button",role:"gridcell","data-cell":`${p}x${h}`,className:"docx-menubar__grid-cell",tabIndex:s.rows===p&&s.cols===h?0:-1,...y?{"data-filled":""}:{},"aria-label":`${h} \xD7 ${p}`,onMouseDown:U,onMouseEnter:()=>l({rows:p,cols:h}),onFocus:()=>l({rows:p,cols:h}),onClick:()=>m(p,h)},h));}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${r?` ${r}`:""}`,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:Pu});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 An({slot:e="table.insert",className:t}){let{setOpenMenu:o}=Je(),r=Pe(),n=Bt.useCallback(()=>o(null),[o]);return jsxRuntime.jsx(jl,{slot:e,label:r("toolbar.insertTable"),onInserted:n,className:t})}function Jk({className:e,hidden:t}){let{isEnabled:o,disabledReason:r}=oe(editor.chromeProbeForSlot("insert.watermark")),n=Je(),i=Pe();if(t)return null;let a=Q("insert.watermark"),l=i(a?.labelKey??"toolbar.watermark"),s=o&&!!n.onWatermarkDialog;return jsxRuntime.jsx(we,{slot:"insert.watermark",icon:re(a?.paths),disabled:!s,...r?{title:r}:{},onSelect:()=>{n.onWatermarkDialog?.(),n.setOpenMenu(null);},...e?{className:e}:{},children:l})}var Yl=Object.assign(Jk,{docxSlot:"insert.watermark"});var tw={type:"openGoTo",fromShortcut:true};function Ib(){let e=oe(tw),t=i18n.isApplePlatform()?"toolbar.goToBookmarkShortcutApple":"toolbar.goToBookmarkShortcut";return jsxRuntime.jsx(to,{slotId:"insert.goToBookmark",...e.isEnabled?{shortcutKey:t}:{}})}function ow({className:e,hidden:t}){return jsxRuntime.jsx(to,{slotId:"insert.bookmark",shortcutKey:"toolbar.bookmarkShortcut",...e?{className:e}:{},...t?{hidden:t}:{}})}var Xl=Object.assign(ow,{docxSlot:"insert.bookmark"});var iw=e=>e;function Jl({labelKey:e,shortcutKey:t,className:o,hidden:r}){let n=H(),i=Je(),a=Pe();if(W(iw),r)return null;let l=editor.toolbarCommandState(n,"text.link"),s=i18n.localizeDisabledReason(l.disabledReason,a),c=Q("text.link"),d=n?.surface?.hyperlinks.linkAtCaret()!=null,m=a(e??(d?"hyperlinkPopup.editLink":"formattingBar.insertLink"));return jsxRuntime.jsx(we,{icon:re(c?.paths),slot:"text.link",...t?{shortcut:a(t)}:{},disabled:!l.enabled,title:s??void 0,onSelect:()=>{i.setOpenMenu(null),editor.runToolbarCommand(n,"text.link");},...o?{className:o}:{},children:m})}function we(e){let{icon:t,shortcut:o,disabled:r,title:n,active:i,selected:a,slot:l,onSelect:s,className:c,children:d}=e,m=e["data-value"],u=Yt(),g=Bt.useId(),p=Bt.useContext(In),f=r&&n?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":""}:{},...r?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...f?{"aria-describedby":f}:{},...n?{title:n}:{},onMouseDown:U,onClick:r?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:n}):null]})}function Xa({label:e,labelKey:t,className:o,hidden:r,children:n}){let i=Pe();if(r)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,n]})}function es(e){if(e.slotId)return e.slotId;if(e.slot)return Ig(e.slot),e.slot;Fg();}function to(e){return (e.slotId??e.slot)==="text.link"?jsxRuntime.jsx(Jl,{...e}):jsxRuntime.jsx(hw,{...e})}function hw(e){let{labelKey:t,shortcutKey:o,className:r,hidden:n}=e,i=es(e)??"",{execute:a,isActive:l,isEnabled:s,disabledReason:c,value:d}=oe(i),{setOpenMenu:m}=Je(),u=Pe();if(n||!i)return null;let g=Q(i),p=u(t??g?.labelKey??i),f=editor.chromeSlotIsToggle(i),h=["setAlignment","setParagraphDirection","setReviewDisplayMode"].includes(editor.commandForSlot(i)?.type??"");return jsxRuntime.jsx(we,{slot:i,icon:re(g?.paths),...o?{shortcut:u(o)}:{},disabled:!s,...c?{title:c}:{},...f?{active:l}:{},...h?{selected:true}:{},...d!==null?{"data-value":d}:{},onSelect:()=>{a(),m(null);},...r?{className:r}:{},children:p})}to.docxMenuRow=true;function Ja(e,t,o,r,n=()=>true){return Object.assign(({className:a,hidden:l})=>{let s=Je(),c=Pe(),d=r(s),m=o&&n(s)?o:void 0;if(l)return null;let u=Q(e),g=c(t??u?.labelKey??e);return jsxRuntime.jsx(we,{slot:e,icon:re(u?.paths),...m?{shortcut:c(m)}:{},disabled:!d,onSelect:()=>{d?.(),s.setOpenMenu(null);},...a?{className:a}:{},children:g})},{docxSlot:e})}var wu=Ja("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),Du=Ja("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave),Ru=Ja("file.exportMarkdown",void 0,void 0,e=>e.onExport?()=>e.onExport?.("markdown"):void 0),Mu=Ja("file.exportPdf",void 0,void 0,e=>e.onExport?()=>e.onExport?.("pdf"):void 0),_u=Ja("file.print",void 0,"toolbar.printShortcut",e=>e.onPrint,e=>e.printShortcut===true);function yw({className:e,hidden:t}){let{isEnabled:o,disabledReason:r}=oe(editor.chromeProbeForSlot("file.pageSetup")),n=Je(),i=Pe();if(t)return null;let a=Q("file.pageSetup"),l=i(a?.labelKey??"file.pageSetup"),s=o&&!!n.onPageSetup;return jsxRuntime.jsx(we,{slot:"file.pageSetup",icon:re(a?.paths),disabled:!s,...r?{title:r}:{},onSelect:()=>{n.onPageSetup?.(),n.setOpenMenu(null);},...e?{className:e}:{},children:l})}function xw({className:e,hidden:t}){let{isEnabled:o,disabledReason:r}=oe(editor.chromeProbeForSlot("paragraph.dialog")),n=Je(),i=Pe();if(t)return null;let a=Q("paragraph.dialog"),l=i(a?.labelKey??"lineSpacing.options"),s=o&&!!n.onParagraphDialog;return jsxRuntime.jsx(we,{slot:"paragraph.dialog",icon:re(a?.paths),disabled:!s,...r?{title:r}:{},onSelect:()=>{n.onParagraphDialog?.(),n.setOpenMenu(null);},...e?{className:e}:{},children:l})}var vw=Object.assign(xw,{docxSlot:"paragraph.dialog"}),Iu=Object.assign(yw,{docxSlot:"file.pageSetup"});function Cw({className:e,hidden:t}){let o=ja(),r=Je(),n=Pe();if(t)return null;let i=Q("image.insert"),a=n(i?.labelKey??"toolbar.image"),l=o?.isEnabled??false,s=o?.disabledReason??null;return jsxRuntime.jsx(we,{slot:"image.insert",icon:re(i?.paths),disabled:!l,...s?{title:s}:{},onSelect:()=>{o?.openFilePicker(),r.setOpenMenu(null);},...e?{className:e}:{},children:a})}var Nu=Object.assign(Cw,{docxSlot:"image.insert"});function oo({labelKey:e,label:t,paths:o,className:r,children:n}){let i=Pe(),[a,l]=Bt.useState(false),s=Bt.useRef(null),c=Bt.useRef(null),d=Bt.useId();t===void 0&&e===void 0&&Lg();let m=t??i(e??""),[u,g]=Bt.useState(null);return Bt.useLayoutEffect(()=>{if(!a){g(null);return}let p=s.current,f=c.current,h=p?.ownerDocument.defaultView;!p||!f||!h||g(editor.placeSubmenu(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:h.innerWidth,height:h.innerHeight},h.getComputedStyle(p).direction==="rtl"));},[a]),jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__submenu${r?` ${r}`:""}`,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&&eo(Wr(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:U,onFocus:()=>l(true),onClick:()=>l(true),children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:re(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 h=Wr(f);p.key==="ArrowDown"?(p.preventDefault(),p.stopPropagation(),Qt(h,editor.hostDocumentOf(f).activeElement,1)):p.key==="ArrowUp"&&(p.preventDefault(),p.stopPropagation(),Qt(h,editor.hostDocumentOf(f).activeElement,-1));},children:jsxRuntime.jsx(In.Provider,{value:-1,children:n})}):null]})}function Tw({entry:e}){let{isEnabled:t}=oe(e.slot),o=Q(e.slot);return t?jsxRuntime.jsx(oo,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsxRuntime.jsx(An,{slot:e.slot})}):jsxRuntime.jsx(to,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Zr({className:e}){return jsxRuntime.jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function Qa({entry:e,children:t}){return e.kind==="separator"?jsxRuntime.jsx(Zr,{}):e.kind==="submenu"?jsxRuntime.jsx(oo,{labelKey:e.labelKey,paths:e.paths,children:t??e.items.map((o,r)=>jsxRuntime.jsx(Qa,{entry:o},r))}):e.slot==="file.open"?jsxRuntime.jsx(wu,{}):e.slot==="file.save"?jsxRuntime.jsx(Du,{}):e.slot==="file.exportMarkdown"?jsxRuntime.jsx(Ru,{}):e.slot==="file.exportPdf"?jsxRuntime.jsx(Mu,{}):e.slot==="file.print"?jsxRuntime.jsx(_u,{}):e.slot==="file.pageSetup"?jsxRuntime.jsx(Iu,{}):e.slot==="paragraph.dialog"?jsxRuntime.jsx(vw,{}):e.slot==="insert.watermark"?jsxRuntime.jsx(Yl,{}):e.slot==="insert.bookmark"?jsxRuntime.jsx(Xl,{}):e.slot==="insert.goToBookmark"?jsxRuntime.jsx(Ib,{}):e.slot==="image.insert"?jsxRuntime.jsx(Nu,{}):e.picker==="tableGrid"?jsxRuntime.jsx(Tw,{entry:e}):jsxRuntime.jsx(to,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Ab(e){if(!Bt.isValidElement(e))return null;let t=Mn(e,Ab);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?es(e.props)??null:null}function Ew(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function Lb(e,t,o){return Bl({entries:e??[],children:t,preset:o,keyOfEntry:Ew,keyOfChild:Ab,childrenOfEntry:r=>r.kind==="submenu"?r.items:void 0,renderEntry:(r,n,i)=>jsxRuntime.jsx(Qa,{entry:r,children:i})})}function ro({id:e,labelKey:t,label:o,icon:r,className:n,hidden:i,preset:a=true,children:l}){let{openMenu:s,setOpenMenu:c,activeMenu:d,opening:m}=Je(),u=gb(),g=Pe(),p=Bt.useId(),f=Bt.useRef(null),h=Bt.useRef(null),y=Bt.useRef(false),x=Bt.useRef(false),b=editor.CHROME_MENUS.find(w=>w.id===e),v=s===e,P=Tb(v&&e===_n,f,h);if(i)return null;let T=o??g(t??b?.labelKey??e),C=Cb(u,e,d);if(C.skip)return null;if(C.asSubmenu)return jsxRuntime.jsx(oo,{labelKey:t??b?.labelKey??e,label:T,children:Lb(b?.entries,l,a)});let E=Lb(b?.entries,l,a),S=C.iconOnly,k=()=>{c(null),f.current?.focus();};return jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__menu-root${n?` ${n}`:""}`,"data-menu":e,...C.rootAttributes,children:[jsxRuntime.jsxs("button",{ref:f,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":v,"aria-controls":v?p:void 0,className:"docx-menubar__trigger",disabled:m===true,tabIndex:C.tabStop?0:-1,...v?{"data-open":""}:{},...S?{"aria-label":T,title:T}:{},onMouseDown:U,onKeyDown:w=>{w.key==="ArrowDown"||w.key==="Enter"||w.key===" "||w.key==="ArrowUp"?(w.preventDefault(),y.current=true,c(e)):w.key==="Escape"&&v&&(w.preventDefault(),k());},onClick:()=>{if(x.current){x.current=false;return}c(v?null:e);},onMouseEnter:()=>{s!==null&&s!==e&&(x.current=true,c(e));},onMouseLeave:()=>{x.current=false;},children:[r?jsxRuntime.jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:r}):null,S?null:T]}),v?jsxRuntime.jsx("div",{ref:w=>{h.current=w,w&&y.current&&(y.current=false,eo(Wr(w),"first"));},id:p,role:"menu","aria-label":T,style:P,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:w=>{let I=h.current;if(!I)return;let O=Wr(I),N=editor.hostDocumentOf(I).activeElement;w.key==="ArrowDown"?(w.preventDefault(),Qt(O,N,1)):w.key==="ArrowUp"?(w.preventDefault(),Qt(O,N,-1)):w.key==="Home"?(w.preventDefault(),eo(O,"first")):w.key==="End"?(w.preventDefault(),eo(O,"last")):w.key==="Escape"?(w.preventDefault(),w.stopPropagation(),k()):w.key==="Tab"&&c(null);},children:jsxRuntime.jsx(In.Provider,{value:-1,children:E})}):null]})}function Fu(e){return Object.assign(o=>jsxRuntime.jsx(ro,{id:e,...o}),{docxMenu:e})}var Lu=Fu("file"),Hu=Fu("format"),Au=Fu("insert");var ts=Bt.createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function Zo(){return Bt.useContext(ts)}function Bb(){return Bt.useContext(ts).target}var kw=e=>e.pageSetup??null,ww=e=>e.editable;function Kr(){let e=H(),t=W(kw),o=W(ww),r=Bt.useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),n=Bt.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 Bt.useMemo(()=>({pageSetup:t,isEnabled:r,apply:n}),[t,r,n])}var Bu=[{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}],Ub=1440,Mw=e=>Math.round(e/Ub*100)/100,_w=e=>Math.round(e*Ub);function Iw(e,t){let o=Math.min(e,t),r=Math.max(e,t);return Bu.findIndex(n=>Math.abs(n.width-o)<20&&Math.abs(n.height-r)<20)}var Kb=12240,qb=15840,dr=1440;function Nw({open:e,onClose:t,className:o,style:r,children:n,preset:i=true}){let{t:a}=L(),l=bo(e,t),{pageSetup:s,isEnabled:c,apply:d}=Kr(),[m,u]=Bt.useState(Kb),[g,p]=Bt.useState(qb),[f,h]=Bt.useState("portrait"),[y,x]=Bt.useState(dr),[b,v]=Bt.useState(dr),[P,T]=Bt.useState(dr),[C,E]=Bt.useState(dr),[S,k]=Bt.useState(false),[w,I]=Bt.useState("document"),O=Bt.useRef(null),N=Bt.useRef("no");Bt.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||(k(false),u(s?.pageWidthTwips??Kb),p(s?.pageHeightTwips??qb),h(s?.orientation??"portrait"),x(s?.marginsTwips.top??dr),v(s?.marginsTwips.bottom??dr),T(s?.marginsTwips.left??dr),E(s?.marginsTwips.right??dr),I("document"),N.current=s===null?"loading":"yes");},[e,s]);let B=Bt.useCallback(q=>{let G=Bu[q];G&&(u(f==="landscape"?G.height:G.width),p(f==="landscape"?G.width:G.height));},[f]),F=Bt.useCallback(q=>{q!==f&&(h(q),u(g),p(m));},[f,m,g]),D=Bt.useCallback(()=>{if(!c)return;if(!l()){t();return}let q=d({pageWidthTwips:m,pageHeightTwips:g,orientation:f,marginTopTwips:y,marginRightTwips:C,marginBottomTwips:b,marginLeftTwips:P,scope:w});k(!q),q&&t();},[c,l,d,m,g,f,y,C,b,P,w,t]);if(!e)return null;let R=Iw(m,g),z=(q,G,ce)=>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:Mw(G),onChange:A=>ce(Math.max(0,_w(Number(A.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:b,marginLeft:P,marginRight:C,scope:w},ee={pageWidth:u,pageHeight:p,orientation:F,marginTop:x,marginBottom:v,marginLeft:T,marginRight:E,scope:I},Y={values:V,setValue(q,G){ee[q](G);},errors:S?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:D,cancel:t};return jsxRuntime.jsx(Be,{kind:"pageSetup",className:o,style:r,panelRef:O,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(To.Composition,{state:Y,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:[Bu.map((q,G)=>jsxRuntime.jsx("option",{value:G,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")}),z("top",y,x),z("bottom",b,v),z("left",P,T),z("right",C,E),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=>I(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:n})})}var To=St();function Fw(){return To.useState()}var qr=Object.assign(Nw,{Header:To.Header,Title:To.Title,Body:To.Body,Footer:To.Footer,Apply:To.Apply,Cancel:To.Cancel,Error:To.Error,Field:To.Field});var Aw={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},Ow=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,r=t.paragraphFlags??Aw;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:r.contextualSpacing,keepNext:r.keepNext,keepLines:r.keepLines,widowControl:r.widowControl,pageBreakBefore:r.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}}},Bw=["alignment","direction","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],Ww=(e,t)=>Bw.every(o=>e.disagrees[o]===t.disagrees[o]),Zw=(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&&Ww(e,t)&&e.indentUnknown===t.indentUnknown&&e.tabStops?.length===t.tabStops?.length&&(e.tabStops??[]).every((o,r)=>o.positionTwips===t.tabStops?.[r]?.positionTwips&&o.alignment===t.tabStops?.[r]?.alignment&&(o.leader??"none")===(t.tabStops?.[r]?.leader??"none")),Kw=e=>e.editable,qw={type:"setParagraphFormat",alignment:"left"};function Wu(){let e=H(),t=W(Ow,Zw),o=W(Kw),{isEnabled:r}=oe(qw),n=o&&r,i=Bt.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:n,apply:i}}function $w({open:e,onClose:t,className:o,style:r,children:n,preset:i=true}){let{t:a}=L(),l=bo(e,t),{format:s,isEnabled:c,apply:d}=Wu(),[m,u]=Bt.useState("left"),[g,p]=Bt.useState("ltr"),[f,h]=Bt.useState(0),[y,x]=Bt.useState(0),[b,v]=Bt.useState("none"),[P,T]=Bt.useState(0),[C,E]=Bt.useState(0),[S,k]=Bt.useState(0),[w,I]=Bt.useState("multiple"),[O,N]=Bt.useState(1.08),[B,F]=Bt.useState(false),[D,R]=Bt.useState(false),[z,V]=Bt.useState(false),[ee,Y]=Bt.useState(true),[q,G]=Bt.useState(false),[ce,A]=Bt.useState([]),[_,ae]=Bt.useState(false),[fe,Z]=Bt.useState(0),[de,Re]=Bt.useState("left"),[Ae,ft]=Bt.useState("none"),[ve,nt]=Bt.useState(editor.NO_MIXED_FIELDS),[Zt,Nt]=Bt.useState(false),er=$=>a(Zt&&($==="indentLeft"||$==="indentRight"||$==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),Mr=Bt.useRef(editor.NO_MIXED_FIELDS),ie=Bt.useId(),[at,Ie]=Bt.useState(false),go=Bt.useRef(null),tr=Bt.useRef(false),Ft=Bt.useRef(null);Bt.useEffect(()=>{if(!e){tr.current=false;return}if(tr.current||s===null)return;let $=editor.seedFields(s);u($.alignment),p($.direction),h($.indentLeft),x($.indentRight),v($.special),T($.specialBy),E($.spaceBefore),k($.spaceAfter),I($.lineRule),N($.lineValue),F($.contextualSpacing),R($.keepNext),V($.keepLines),Y($.widowControl),G($.pageBreakBefore),A($.tabStops),ae(false);let Ce=editor.mixedFieldsOf(s);nt(Ce),Nt(s.indentUnknown),Z(0),Re("left"),ft("none"),Mr.current=Ce,Ie(false),Ft.current=$,tr.current=true;},[e,s]);let Lo=Bt.useCallback(()=>{if(!c)return;if(!l()){t();return}let $=Ft.current,Ce=$===null?null:editor.changedFields($,{alignment:m,direction:g,indentLeft:f,indentRight:y,special:b,specialBy:P,spaceBefore:C,spaceAfter:S,lineRule:w,lineValue:O,contextualSpacing:B,keepNext:D,keepLines:z,widowControl:ee,pageBreakBefore:q,tabStops:ce,clearedAllTabStops:_},Mr.current,ve);if(Ce===null){t();return}if(d(Ce)){Ie(false),t();return}Ie(true);},[c,l,d,t,ve,_,m,g,f,y,b,P,C,S,w,O,B,D,z,ee,q,ce]),yn=Bt.useCallback(()=>{let $=Math.round(fe);return $<=0?false:(nt(Ce=>({...Ce,tabStops:false})),A(editor.withTabStop(ce,{positionTwips:$,alignment:de,...Ae!=="none"?{leader:Ae}:{}})),Z(0),Re("left"),ft("none"),true)},[ce,fe,de,Ae]);if(!e)return null;let le=$=>nt(Ce=>({...Ce,[$]:false})),be=($,Ce,rr,gt)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":gt,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-${$}`,children:a(`dialogs.paragraph.${$}`)}),jsxRuntime.jsx("input",{id:`${ie}-${$}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:ve[gt]?"":editor.twipsToInches(Ce),placeholder:ve[gt]?er(gt):void 0,onChange:Ma=>{le(gt),rr(editor.inchesToTwips(Number(Ma.target.value)||0));},"aria-label":a(`dialogs.paragraph.${$}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),Ke=($,Ce,rr,gt)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":$,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-${$}`,children:a(`dialogs.paragraph.${$}`)}),jsxRuntime.jsx("input",{id:`${ie}-${$}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:ve[gt]?"":Ce,placeholder:ve[gt]?er(gt):void 0,onChange:Ma=>{le(gt),rr(Math.max(0,Number(Ma.target.value)||0));},"aria-label":a(`dialogs.paragraph.${$}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),xe=($,Ce,rr)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":$,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:Ce,ref:gt=>{gt&&(gt.indeterminate=ve[$]);},onChange:gt=>{nt(Ma=>({...Ma,[$]:false})),rr(gt.target.checked);}}),a(`dialogs.paragraph.${$}`)]}),Et={alignment:m,direction:g,indentLeft:f,indentRight:y,special:b,specialBy:P,spaceBefore:C,spaceAfter:S,lineRule:w,lineValue:O,contextualSpacing:B,keepNext:D,keepLines:z,widowControl:ee,pageBreakBefore:q,tabStops:ce,clearedAllTabStops:_},Ho=$=>{let Ce=Mr.current;$!==g&&!Ce.direction&&!Ce.alignment&&u(editor.alignmentAfterDirectionChange),p($);},or={alignment:u,direction:Ho,indentLeft:h,indentRight:x,special:v,specialBy:T,spaceBefore:E,spaceAfter:k,lineRule:I,lineValue:N,contextualSpacing:F,keepNext:R,keepLines:V,widowControl:Y,pageBreakBefore:G,tabStops:A,clearedAllTabStops:ae},_r={values:Et,mixed:ve,setValue($,Ce){or[$](Ce),$==="lineRule"?(le("lineSpacing"),N(Ce===Ft.current?.lineRule?Ft.current.lineValue:Ce==="multiple"?1.08:12)):$==="specialBy"?le("special"):$ in ve&&le($);},errors:at?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:Lo,cancel:t};return jsxRuntime.jsx(Be,{kind:"paragraph",className:o,style:r,panelRef:go,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:$=>{$.key==="Escape"&&t();let Ce=editor.isHTMLElementNode($.target)&&($.target.localName==="button"||$.target.localName==="select");if($.key==="Enter"&&!Ce){let rr=$.target;if(editor.isHTMLElementNode(rr)&&rr.dataset.docxTabEntry!==void 0){yn();return}c&&Lo();}},children:jsxRuntime.jsx(Eo.Composition,{state:_r,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:`${ie}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxRuntime.jsxs("select",{id:`${ie}-alignment`,className:"docx-dialog__input",value:ve.alignment?"":m,onChange:$=>{le("alignment"),u($.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[ve.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:`${ie}-direction`,children:a("dialogs.paragraph.direction")}),jsxRuntime.jsxs("select",{id:`${ie}-direction`,className:"docx-dialog__input",value:ve.direction?"":g,onChange:$=>{le("direction"),Ho($.target.value);},"aria-label":a("dialogs.paragraph.direction"),children:[ve.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")}),be("beforeText",f,h,"indentLeft"),be("afterText",y,x,"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:`${ie}-special`,children:a("dialogs.paragraph.special")}),jsxRuntime.jsxs("select",{id:`${ie}-special`,className:"docx-dialog__input",value:ve.special?"":b,onChange:$=>{le("special"),v($.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[ve.special?jsxRuntime.jsx("option",{value:"",children:er("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")})]})]}),b!=="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:`${ie}-by`,children:a("dialogs.paragraph.by")}),jsxRuntime.jsx("input",{id:`${ie}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:ve.special?"":editor.twipsToInches(P),placeholder:ve.special?er("special"):void 0,onChange:$=>{le("special"),T(Math.max(0,editor.inchesToTwips(Number($.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")}),ce.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__note",children:a(ve.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):ce.map($=>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($.positionTwips)})}),jsxRuntime.jsx("span",{className:"docx-dialog__tab-description",children:a(editor.TAB_ALIGNMENT_LABELS[$.alignment])}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>A(ce.filter(Ce=>Ce!==$)),"aria-label":a("dialogs.paragraph.tabRemoveAt",{position:editor.formatInches($.positionTwips)}),children:a("dialogs.paragraph.tabRemove")})]},$.positionTwips)),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsxRuntime.jsx("input",{id:`${ie}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:editor.twipsToInches(fe),onChange:$=>Z(Math.max(0,editor.inchesToTwips(Number($.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:`${ie}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxRuntime.jsxs("select",{id:`${ie}-tabAlignment`,className:"docx-dialog__input",value:de,onChange:$=>Re($.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:`${ie}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxRuntime.jsxs("select",{id:`${ie}-tabLeader`,className:"docx-dialog__input",value:Ae,onChange:$=>ft($.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:yn,children:a("dialogs.paragraph.tabAdd")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{nt($=>({...$,tabStops:false})),ae(true),A([]);},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")}),Ke("spaceBefore",C,E,"spaceBefore"),Ke("spaceAfter",S,k,"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:`${ie}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxRuntime.jsxs("select",{id:`${ie}-lineSpacing`,className:"docx-dialog__input",value:ve.lineSpacing?"":w,onChange:$=>{let Ce=$.target.value;le("lineSpacing"),I(Ce),N(Ce===Ft.current?.lineRule?Ft.current.lineValue:Ce==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[ve.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:`${ie}-at`,children:a("dialogs.paragraph.at")}),jsxRuntime.jsx("input",{id:`${ie}-at`,type:"number",className:"docx-dialog__input",min:.01,step:w==="multiple"?.01:1,value:ve.lineSpacing?"":O,disabled:ve.lineSpacing,onChange:$=>{let Ce=$.target.value.trim();N(Ce===""?w==="multiple"?1.08:12:Number(Ce)||0);},"aria-label":a("dialogs.paragraph.at")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:w==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),xe("contextualSpacing",B,F),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),xe("keepNext",D,R),xe("widowControl",ee,Y),xe("keepLines",z,V),xe("pageBreakBefore",q,G)]})]})}),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:at?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:Lo,children:a("dialogs.paragraph.ok")})]})]}),children:n})})}var Eo=St();function Vw(){return Eo.useState()}var qo=Object.assign($w,{Header:Eo.Header,Title:Eo.Title,Body:Eo.Body,Footer:Eo.Footer,Apply:Eo.Apply,Cancel:Eo.Cancel,Error:Eo.Error,Field:Eo.Field});var no=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var qu=["ASAP","CONFIDENTIAL","COPY","DO NOT COPY","DRAFT","ORIGINAL","PERSONAL","SAMPLE","TOP SECRET","URGENT"],Uu=[null,.5,1,1.5,2,5],zu=[null,36,40,44,48,54,60,66,72,80,90,96,105,120,144],rh="image/png,image/jpeg,image/gif,image/bmp,image/webp",$u={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"},as=/^[0-9A-Fa-f]{6}$/;function nh(e,t){let o={...$u};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&&as.test(e.color)?e.color.toUpperCase():o.color,layout:e.layout??o.layout}:o}function ah(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 ih=e=>`#${as.test(e)?e.toLowerCase():"c0c0c0"}`;function lh(e){let t=e.startsWith("#")?e.slice(1):e;return as.test(t)?t.toUpperCase():null}var Vu=e=>Math.round(Math.min(1,Math.max(0,e))*100);function Gu(e,t){let o=Number(e);return e.trim()===""||!Number.isFinite(o)?t:Math.min(100,Math.max(0,Math.round(o)))/100}function sh(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 ch(e,t){return e!==null&&t.kind==="none"?null:t}function dh(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 uh=(e,t)=>t.includes(e)?e:"",jw={pageWidthTwips:12240,pageHeightTwips:15840,marginsTwips:{top:1440,right:1440,bottom:1440,left:1440}};function is(e){let t=e&&e.pageWidthTwips>0&&e.pageHeightTwips>0?e:null,{pageWidthTwips:o,pageHeightTwips:r,marginsTwips:n}=t??jw,i=o/20,a=r/20,l=Math.max(72,(o-n.left-n.right)/20),s=Math.max(72,(r-n.top-n.bottom)/20);return {width:i,height:a,area:{x:n.left/20,y:n.top/20,width:l,height:s}}}var Qb=12,eh=[.55,1,1,.9,0,1,1,.6,0,1,.95,1,.45];function ph(e){let{area:t}=e,o=36,r=[];for(let n=0,i=t.y;i+Qb<=t.y+t.height;n++){let a=eh[n%eh.length];a>0&&r.push({x:t.x,y:i,width:t.width*a,height:Qb}),i+=o;}return r}var mh="contrast(0.157068) brightness(1.91)",ju=100,Uo=e=>Math.round(e*100)/100,fh=e=>({cx:e.area.x+e.area.width/2,cy:e.area.y+e.area.height/2});function gh(e,t=is(null)){if(e.kind!=="text")return null;let o=e.text.trim();if(o==="")return null;let r=editor.watermarkShapeBox({text:o,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,layout:e.layout},t.area);if(!r)return null;let{cx:n,cy:i}=fh(t);return {text:o,fontFamily:`"${e.fontFamily.replace(/["\\]/g,"")}", sans-serif`,fontWeight:e.bold?"bold":"normal",fontStyle:e.italic?"italic":"normal",fill:`#${as.test(e.color)?e.color.toUpperCase():"C0C0C0"}`,opacity:Uo(1-Math.min(1,Math.max(0,e.transparency))),box:{x:Uo(n-r.width/2),y:Uo(i-r.height/2),width:Uo(r.width),height:Uo(r.height)},rotation:e.layout==="diagonal"?-45:0}}var th=new WeakMap;function Yw(e){if(!e)return null;let t=th.get(e);if(t===void 0){try{t=e.createElement("canvas").getContext("2d");}catch{t=null;}th.set(e,t);}return t}function bh(e,t){let o=ju,r=Yw(t);if(r){r.font=`${e.fontStyle} ${e.fontWeight} ${o}px ${e.fontFamily}`;let n=r.measureText(e.text),i=-(n.actualBoundingBoxLeft??0),a=n.actualBoundingBoxRight??n.width,l=-(n.actualBoundingBoxAscent??0),s=n.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 hh(e,t){let{x:o,y:r,width:n,height:i}=e.box,a=n>4*7.2?7.2:0,l=i>4*3.6?3.6:0,s=(n-2*a)/(t.right-t.left),c=(i-2*l)/(t.bottom-t.top),d=o+a-t.left*s,m=r+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+n/2)} ${u(r+i/2)}) ${g}`:g}function yh(e,t=is(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:r,cy:n}=fh(t);return {x:Uo(r-o.width/2),y:Uo(n-o.height/2),width:Uo(o.width),height:Uo(o.height)}}var Xw=e=>e.editable,Jw={ok:false,code:"unsupported",reason:"editor is not ready"};function Xu(){let e=H(),t=Bt.useCallback(l=>e?.getWatermark()??null,[e]),o=W(t,sh),r=W(Xw),n=Bt.useMemo(()=>r&&e!==null&&e.can({type:"setWatermark",watermark:{text:"DRAFT"}}).ok,[e,r]),i=Bt.useCallback(()=>e?.query({type:"watermark"})??null,[e]),a=Bt.useCallback(l=>e?e.exec({type:"setWatermark",watermark:l}):Jw,[e]);return Bt.useMemo(()=>({watermark:o,isEnabled:n,read:i,apply:a}),[o,n,i,a])}var rD=e=>e.pageSetup??null,ao=St(),nD=ao.part("preview");function Th(){return ao.useState()}var vh=e=>`${Math.round(e*100)}%`;function aD(e){let[t,o]=Bt.useState(null);return Bt.useEffect(()=>{if(!e||typeof URL.createObjectURL!="function"){o(null);return}let r=URL.createObjectURL(new Blob([e]));return o(r),()=>URL.revokeObjectURL(r)},[e]),t}function iD({className:e,style:t,"data-docx-part":o,...r}){let{values:n}=Th(),i=H(),a=W(rD),l=Bt.useMemo(()=>is(a),[a]),s=aD(n.kind==="picture"?n.imageData:null),c=gh(n,l),d=s?yh(n,l):null;return jsxRuntime.jsx("div",{...r,"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:ju,fontWeight:c.fontWeight,fontStyle:c.fontStyle,fill:c.fill,fillOpacity:c.opacity,transform:hh(c,bh(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:n.washout?{filter:mh}:void 0}):null,ph(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 lD({open:e,onClose:t,presets:o=qu,className:r,style:n,children:i,preset:a=true}){let{t:l}=L(),s=H(),c=bo(e,t),{isEnabled:d,read:m,apply:u}=Xu(),g=W(no),[p,f]=Bt.useState({...$u}),[h,y]=Bt.useState([]),[x,b]=Bt.useState(null),[v,P]=Bt.useState(false),[T,C]=Bt.useState(0),E=Bt.useRef(null),S=Bt.useRef(null),k=Bt.useRef(null),w=Bt.useId(),I=Bt.useRef(false);Bt.useEffect(()=>{if(!e||g||!s){I.current=false;return}if(I.current)return;I.current=true;let _=s.getWatermark(),ae=nh(_,m());E.current=ch(_,ae),f(ae),y(s.getAvailableFonts()),b(null),P(false),C(fe=>fe+1);},[e,g,s,m]),Bt.useEffect(()=>{T!==0&&S.current?.querySelector(`input[name="${w}-kind"]:checked`)?.focus({preventScroll:true});},[T,w]);let O=Bt.useCallback((_,ae)=>{b(null),f(fe=>({...fe,[_]:ae}));},[]),N=ah(p),B=d&&N!==void 0,F=Bt.useCallback(()=>{if(!B||N===void 0)return;if(!c()){t();return}if(E.current&&dh(E.current,p)){t();return}let _=u(N);_.ok?t():b(_.reason);},[B,N,p,c,u,t]),D=Bt.useCallback(_=>{_&&(P(false),_.arrayBuffer().then(ae=>{f(fe=>({...fe,kind:"picture",imageData:new Uint8Array(ae),imageName:_.name})),b(null);}).catch(()=>P(true)));},[]);if(!e)return null;let R=p.kind==="picture",z=p.kind==="text",V=h.includes(p.fontFamily)?h:[p.fontFamily,...h],ee=p.imageData?p.imageName??l("dialogs.watermark.currentPicture"):l("dialogs.watermark.noPictureSelected"),Y=x!==null?l("dialogs.watermark.refused"):null,q=(_,ae,fe)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${w}-kind`,checked:p.kind===ae,onChange:()=>O("kind",ae)}),jsxRuntime.jsx("span",{id:`${w}-${_}-label`,children:fe})]}),G=(_,ae,fe)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${w}-${_}`,children:ae}),fe]}),ce=(_,ae,fe)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",disabled:!fe,checked:p[_],onChange:Z=>O(_,Z.target.checked)}),jsxRuntime.jsx("span",{children:ae})]}),A={values:p,setValue:O,errors:Y?{form:Y}:{},isEnabled:B,apply:F,cancel:t};return jsxRuntime.jsx(Be,{kind:"watermark",className:r,style:n,panelRef:S,label:l("dialogs.watermark.title"),onClose:t,onKeyDown:_=>{let ae=_.target;_.key==="Enter"&&editor.isHTMLElementNode(ae)&&ae.localName==="input"&&(ae.type==="text"||ae.type==="number")&&B&&(_.preventDefault(),F());},children:jsxRuntime.jsx(ao.Composition,{state:A,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(iD,{"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:()=>{O("kind","picture"),k.current?.click();},children:l("dialogs.watermark.selectPicture")}),jsxRuntime.jsx("span",{className:"docx-dialog__hint","data-docx-watermark-picture":"",children:v?l("dialogs.watermark.pictureFailed"):ee}),jsxRuntime.jsx("input",{ref:k,type:"file",accept:rh,hidden:true,"aria-label":l("dialogs.watermark.selectPicture"),onChange:_=>{let ae=_.target.files?.[0];_.target.value="",D(ae);}})]}),G("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:_=>O("scale",_.target.value==="auto"?null:Number(_.target.value)),children:[Uu.map(_=>jsxRuntime.jsx("option",{value:_===null?"auto":String(_),children:_===null?l("dialogs.watermark.auto"):vh(_)},String(_))),p.scale!==null&&!Uu.includes(p.scale)?jsxRuntime.jsx("option",{value:String(p.scale),children:vh(p.scale)}):null]})),ce("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:[G("preset",l("dialogs.watermark.preset"),jsxRuntime.jsxs("select",{id:`${w}-preset`,className:"docx-dialog__select",disabled:!z,value:uh(p.text,o),onChange:_=>{_.target.value!==""&&O("text",_.target.value);},children:[jsxRuntime.jsx("option",{value:"",children:l("dialogs.watermark.custom")}),o.map(_=>jsxRuntime.jsx("option",{value:_,children:_},_))]})),G("text",l("dialogs.watermark.textLabel"),jsxRuntime.jsx("input",{id:`${w}-text`,type:"text",className:"docx-dialog__input",disabled:!z,maxLength:256,value:p.text,onChange:_=>O("text",_.target.value)})),G("fontFamily",l("dialogs.watermark.font"),jsxRuntime.jsx("select",{id:`${w}-fontFamily`,className:"docx-dialog__select",disabled:!z,value:p.fontFamily,onChange:_=>O("fontFamily",_.target.value),children:V.map(_=>jsxRuntime.jsx("option",{value:_,children:_},_))})),G("fontSizePt",l("dialogs.watermark.size"),jsxRuntime.jsxs("select",{id:`${w}-fontSizePt`,className:"docx-dialog__select",disabled:!z,value:p.fontSizePt===null?"auto":String(p.fontSizePt),onChange:_=>O("fontSizePt",_.target.value==="auto"?null:Number(_.target.value)),children:[zu.map(_=>jsxRuntime.jsx("option",{value:_===null?"auto":String(_),children:_===null?l("dialogs.watermark.auto"):String(_)},String(_))),p.fontSizePt!==null&&!zu.includes(p.fontSizePt)?jsxRuntime.jsx("option",{value:String(p.fontSizePt),children:p.fontSizePt}):null]})),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[ce("bold",l("dialogs.watermark.bold"),z),ce("italic",l("dialogs.watermark.italic"),z)]}),G("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:!z,"aria-label":l("dialogs.watermark.transparency"),value:Vu(p.transparency),onChange:_=>O("transparency",Gu(_.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:!z,value:Vu(p.transparency),onChange:_=>O("transparency",Gu(_.target.value,p.transparency))}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:"%"})]})),G("color",l("dialogs.watermark.color"),jsxRuntime.jsx("input",{id:`${w}-color`,type:"color",className:"docx-dialog__color",disabled:!z,value:ih(p.color),onChange:_=>{let ae=lh(_.target.value);ae&&O("color",ae);}})),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(_=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${w}-layout`,disabled:!z,checked:p.layout===_,onChange:()=>O("layout",_)}),jsxRuntime.jsx("span",{children:l(`dialogs.watermark.${_}`)})]},_))]})]})]})]})}),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",...x?{title:x}:{},children:Y}),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 Ur=Object.assign(lD,{Header:ao.Header,Title:ao.Title,Body:ao.Body,Preview:nD,Footer:ao.Footer,Apply:ao.Apply,Cancel:ao.Cancel,Error:ao.Error,Field:ao.Field});var ss={ok:false,code:"unsupported",reason:"editor is not ready"},cD=Object.freeze([]);function ep(e,t){return e.length===t.length&&e.every((o,r)=>o.name===t[r].name&&o.order===t[r].order&&o.story===t[r].story&&o.empty===t[r].empty&&o.atSelection===t[r].atSelection&&o.duplicates===t[r].duplicates&&o.hidden===t[r].hidden&&o.place===t[r].place)}function tp(){let e=H(),t=Bt.useCallback(c=>e?.query({type:"bookmarks"})??cD,[e]),o=W(t,ep),r=Bt.useCallback(c=>c.editable&&e!==null&&e.can({type:"insertBookmark",name:"Bookmark"}).ok,[e]),n=W(r),i=Bt.useCallback(c=>e?e.exec({type:"insertBookmark",name:c}):ss,[e]),a=Bt.useCallback(c=>e?e.exec({type:"deleteBookmark",name:c}):ss,[e]),l=Bt.useCallback(c=>e?e.exec({type:"goToBookmark",name:c}):ss,[e]),s=Bt.useCallback(c=>e?e.exec({type:"keepFirstBookmark",name:c}):ss,[e]);return Bt.useMemo(()=>({bookmarks:o,isWritable:n,insert:i,remove:a,goTo:l,keepFirst:s}),[o,n,i,a,l,s])}var Sh={empty:"dialogs.bookmark.nameEmpty",tooLong:"dialogs.bookmark.nameTooLong",invalidStart:"dialogs.bookmark.nameInvalidStart",invalidCharacter:"dialogs.bookmark.nameInvalidCharacter"};function gD(e){return e.open?jsxRuntime.jsx(bD,{...e}):null}function bD({open:e,onClose:t,className:o,style:r,children:n,preset:i=true}){let{t:a}=L(),l=bo(e,t),{bookmarks:s,isWritable:c,insert:d,remove:m,goTo:u,keepFirst:g}=tp(),[p,f]=Bt.useState(()=>editor.bookmarkDialogInitialName(s)),[h,y]=Bt.useState("name"),[x,b]=Bt.useState(false),[v,P]=Bt.useState(false),[T,C]=Bt.useState(false),[E,S]=Bt.useState(false),k=Bt.useRef(null),w=Bt.useRef(null),I=Bt.useId(),O=Bt.useId(),N=Bt.useId(),B=editor.bookmarkDialogRows(s,{sortBy:h,showHidden:x}),F=editor.bookmarkDialogNameState(s,p,c),D=F.problem&&!F.existing&&(T||p.length>0)?F.problem:null,R=F.existing?.duplicates??0,z=v?a("dialogs.bookmark.refused"):D?a(Sh[D]):R>0?a("dialogs.bookmark.duplicates",{count:R}):F.existing&&F.canAdd?a("dialogs.bookmark.nameExists"):null,V=Bt.useCallback(()=>{if(C(true),!F.canAdd)return;if(!l()){t();return}let A=d(p);P(!A.ok),A.ok&&t();},[F.canAdd,l,d,p,t]),ee=Bt.useCallback(()=>{if(!F.canDelete||!F.existing)return;let A=m(F.existing.name);P(!A.ok),A.ok&&f("");},[F,m]),Y=Bt.useCallback(()=>{if(!F.canGoTo||!F.existing)return;let A=u(F.existing.name);P(!A.ok),A.ok&&S(true);},[F,u]),q=Bt.useCallback(()=>{let A=F.existing;!A||!c||P(!g(A.name).ok);},[F.existing,c,g]),G=F.existing?.name??"";Bt.useLayoutEffect(()=>{!G&&w.current&&(w.current.selectedIndex=-1);});let ce={values:{name:p,sortBy:h,showHidden:x},setValue(A,_){A==="name"?f(_):A==="sortBy"?y(_):b(_),P(false);},errors:D?{name:a(Sh[D])}:v?{form:a("dialogs.bookmark.refused")}:{},isEnabled:F.canAdd,apply:V,cancel:t,rows:B,canDelete:F.canDelete,canGoTo:F.canGoTo,duplicates:R,remove:ee,goTo:Y,keepFirst:q};return jsxRuntime.jsx(Be,{kind:"bookmark",className:o,style:r,panelRef:k,label:a("dialogs.bookmark.title"),onClose:t,onKeyDown:A=>{A.key==="Enter"&&!A.nativeEvent.isComposing&&A.keyCode!==229&&editor.isHTMLElementNode(A.target)&&A.target.localName==="input"&&A.target.getAttribute("type")==="text"&&(A.preventDefault(),V());},children:jsxRuntime.jsx(Ht.Composition,{state:ce,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:I,children:a("dialogs.bookmark.name")}),jsxRuntime.jsx("input",{id:I,type:"text",className:"docx-dialog__input",value:p,maxLength:40,autoComplete:"off",spellCheck:false,"aria-invalid":D?true:void 0,"aria-describedby":O,onChange:A=>ce.setValue("name",A.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:G,"aria-label":a("dialogs.bookmark.list"),onChange:A=>ce.setValue("name",A.target.value),onDoubleClick:Y,children:B.map(A=>jsxRuntime.jsx("option",{value:A.name,children:A.name},A.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(A=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:N,checked:h===A,onChange:()=>ce.setValue("sortBy",A)}),a(A==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},A))]}),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:x,onChange:A=>ce.setValue("showHidden",A.target.checked)}),a("dialogs.bookmark.showHidden")]})}),jsxRuntime.jsxs("div",{className:"docx-dialog__row docx-bookmark-dialog__status",children:[jsxRuntime.jsx("span",{id:O,"data-docx-part":"error",role:"status",className:D||v?"docx-dialog__error":"docx-dialog__hint",children:z}),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:ee,children:a("dialogs.bookmark.delete")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"goto",disabled:!F.canGoTo,onClick:Y,children:a("dialogs.bookmark.goTo")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a(E?"common.close":"common.cancel")})]})]}),children:n})})}var Ht=St();function hD(){return Ht.useState()}var ei=Object.assign(gD,{Header:Ht.Header,Title:Ht.Title,Body:Ht.Body,Footer:Ht.Footer,Apply:Ht.Apply,Cancel:Ht.Cancel,Error:Ht.Error,Field:Ht.Field,Delete:Ht.part("delete"),GoTo:Ht.part("goto"),KeepFirst:Ht.part("keepfirst")});var kh=editor.SPLIT_CELL_FALLBACK_MAX;function PD(e){return e.open?jsxRuntime.jsx(wD,{...e}):null}var kD=e=>e;function wD({open:e,onClose:t,className:o,style:r,children:n,preset:i=true}){let{t:a}=L(),l=H(),s=bo(e,t),c=Bt.useMemo(()=>l?.query({type:"splitCellConfig"})??null,[l]),[d]=Bt.useState(()=>editor.initialSplitCellCounts(c,F=>l?l.can(F):{ok:false,code:"unsupported",reason:""})),[m,u]=Bt.useState(d.columns),[g,p]=Bt.useState(d.rows),[f,h]=Bt.useState(null),y=Bt.useId(),x=Bt.useId(),b=Bt.useId(),{counts:v,problem:P}=editor.readSplitCellCounts(m,g,c),T=v?.cols??null,C=v?.rows??null;W(kD);let E=l&&v?l.can({type:"splitCell",...v}):null,S=P?.kind==="range"?a("dialogs.splitCell.range",{max:P.max}):P?.kind==="oneCell"?a("dialogs.splitCell.oneCell"):E&&!E.ok?i18n.localizeDisabledReason(E.reason??null,a):null,k=E?.ok===true,w=f??S,I=P?.kind==="range"?P.field:null,O=Bt.useCallback(()=>{if(!k||!l)return;if(!s()){t();return}let F=l.exec({type:"splitCell",rows:C,cols:T});F.ok?t():h(i18n.localizeDisabledReason(F.reason??null,a));},[k,l,s,t,C,T,a]),N={values:{columns:m,rows:g},setValue(F,D){F==="columns"?u(D):p(D),h(null);},errors:w?{form:w}:{},isEnabled:k,apply:O,cancel:t,limits:c},B=(F,D,R,z,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:z,"aria-invalid":I===F?true:void 0,"aria-describedby":b,onChange:ee=>N.setValue(F,ee.target.value)})]});return jsxRuntime.jsx(Be,{kind:"splitCell",className:o,style:r,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(),O());},children:jsxRuntime.jsx(So.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??kh),B("rows",x,"dialogs.splitCell.rows",g,c?.maxRows??kh),jsxRuntime.jsx("div",{className:"docx-dialog__row",children:jsxRuntime.jsx("span",{id:b,"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:!k,onClick:O,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:n})})}var So=St();function DD(){return So.useState()}var ti=Object.assign(PD,{Header:So.Header,Title:So.Title,Body:So.Body,Footer:So.Footer,Apply:So.Apply,Cancel:So.Cancel,Error:So.Error,Field:So.Field});var wh=Bt.createContext(void 0),Dh=wh.Provider;function Qe(){let e=Bt.useContext(wh),{t}=L();return Bt.useCallback((o,r)=>{let n=e?.(o,r);return n===void 0||n===o?t(o,r):n},[e,t])}var Po=St();function LD(){return Po.useState()}function HD({session:e,...t}){let[o,r]=Bt.useState(e),[n,i]=Bt.useState(0);return o!==e&&(r(e),i(n+1)),e?jsxRuntime.jsx(AD,{session:e,...t},n):null}function AD({session:e,children:t,preset:o,className:r,style:n}){let i=Qe(),a=W(()=>e.canApply()),[l,s]=Bt.useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=Bt.useState(e.signal.aborted),[m,u]=Bt.useState(false);Bt.useEffect(()=>{let x=()=>d(true);return e.signal.addEventListener("abort",x),e.signal.aborted&&x(),()=>e.signal.removeEventListener("abort",x)},[e]);let g=()=>{if(e.signal.aborted)return;let x=Number.isInteger(l.maxLength)&&l.maxLength>=0&&l.maxLength<=32767&&e.apply(l.defaultText,{type:l.type,maxLength:l.maxLength,format:l.format,enabled:l.enabled});u(!x);},p={values:l,setValue(x,b){s(v=>({...v,[x]:b,...x==="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]??[],h={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},y=(x,b)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":x,className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${x}`)}),b]});return jsxRuntime.jsx(Be,{kind:"textFormField",className:r,style:n,label:i("textFormField.title"),onClose:e.cancel,dismissOutside:false,sessionSignal:e.signal,restoreFocus:false,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),e.cancel()),x.key==="Enter"&&editor.isHTMLElementNode(x.target)&&x.target.localName==="input"&&(x.preventDefault(),g());},children:jsxRuntime.jsx(Po.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:x=>p.setValue("defaultText",x.target.value)})),y("type",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:x=>p.setValue("type",x.target.value),children:[["regular","number","date"].map(x=>jsxRuntime.jsx("option",{value:x,children:i(`textFormField.${x}`)},x)),Object.hasOwn(editor.TEXT_FORM_FORMATS,l.type)?null:jsxRuntime.jsx("option",{value:l.type,disabled:true,children:i("textFormField.preservedType")})]})),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:x=>p.setValue("maxLength",x.target.valueAsNumber)})),y("format",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:x=>p.setValue("format",x.target.value),children:[f.map(x=>jsxRuntime.jsx("option",{value:x,children:h[x]?i(h[x]):x||i("textFormField.noFormat")},x)),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:x=>p.setValue("enabled",x.target.checked)}),i("textFormField.enabled")]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",className:"docx-dialog__error",role:"alert",children:p.errors.form}),jsxRuntime.jsx("button",{"data-docx-part":"cancel",className:"docx-dialog__button",type:"button",onClick:e.cancel,children:i("textFormField.cancel")}),jsxRuntime.jsx("button",{disabled:!a,"data-docx-part":"apply",className:"docx-dialog__button docx-dialog__apply",type:"button",onClick:g,children:i("textFormField.apply")})]})]}),children:t})})}var ri=Object.assign(HD,{Header:Po.Header,Title:Po.Title,Body:Po.Body,Footer:Po.Footer,Apply:Po.Apply,Cancel:Po.Cancel,Error:Po.Error,Field:Po.Field});var _h=Bt.createContext(null),ko=()=>Bt.useContext(_h);function Ih({popups:e,children:t}){let o=H(),r=Ld(),[n,i]=Bt.useState(null),[a,l]=Bt.useState(null),[s,c]=Bt.useState(null),[d,m]=Bt.useState(null),u=Bt.useRef(d);u.current=d;let g=Bt.useRef(e);g.current=e;let p=Bt.useRef(null),f=Bt.useRef(s);f.current=s;let h=()=>l(null);Bt.useEffect(()=>{if(a!==null)return;let P=p.current;p.current=null,P?.isConnected&&P.focus({preventScroll:true});},[a]),Bt.useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(P){if(g.current?.textFormField===false){P.cancel();return}u.current?.cancel(),l(null),c(P),P.signal.addEventListener("abort",()=>c(T=>T===P?null:T),{once:true});}},{fallback:true})},[o]),Bt.useEffect(()=>{if(!o||!n&&e?.revisionMarkup!==false)return;let P=o.setRevisionMarkupChrome({onRequest(T){if(g.current?.revisionMarkup===false){T.cancel();return}f.current?.cancel(),l(null),m(T),T.signal.addEventListener("abort",()=>m(C=>C===T?null:C),{once:true});}},{fallback:true});return ()=>{u.current?.cancel(),P();}},[o,n,e?.revisionMarkup===false]),Bt.useEffect(()=>{l(null),c(null),m(null);},[o,r]);let y=e?.bookmark===false;Bt.useEffect(()=>{if(!(!o||!n||y))return o.setBookmarkChrome({onRequest(){f.current?.cancel(),u.current?.cancel(),p.current=KD(n.ownerDocument.activeElement),l("bookmark");}})},[o,n,y]),Bt.useEffect(()=>{e?.revisionMarkup===false&&u.current?.cancel(),e?.textFormField===false&&f.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let x=Bt.useMemo(()=>({container:n,setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(P,T){f.current?.cancel(),u.current?.cancel(),g.current?.[P]!==false&&(p.current=T??n?.ownerDocument.activeElement,l(P));}}),[n,e?.pageSetup]),b={open:true,onClose:h},v=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?Se(e.pageSetup,b):jsxRuntime.jsx(qr,{...b}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Se(e.paragraph,b):jsxRuntime.jsx(qo,{...b}):a==="watermark"&&e?.watermark!==false?e?.watermark?Se(e.watermark,b):jsxRuntime.jsx(Ur,{...b}):a==="bookmark"&&e?.bookmark!==false?e?.bookmark?Se(e.bookmark,b):jsxRuntime.jsx(ei,{...b}):a==="splitCell"&&e?.splitCell!==false?e?.splitCell?Se(e.splitCell,b):jsxRuntime.jsx(ti,{...b}):d&&e?.revisionMarkup!==false?e?.revisionMarkup?Se(e.revisionMarkup,{session:d},d):jsxRuntime.jsx(Ia,{session:d}):s&&e?.textFormField!==false?e?.textFormField?Se(e.textFormField,{session:s},s):jsxRuntime.jsx(ri,{session:s}):null;return jsxRuntime.jsxs(_h.Provider,{value:x,children:[t,n?reactDom.createPortal(v,n):null]})}function KD(e){return e?.closest("[data-menu]")?.querySelector(':scope > [role="menuitem"]')??e}function Nh(){let e=ko();return jsxRuntime.jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer,dir:it()})}function Fh({children:e}){let t=ko();return t?.container?reactDom.createPortal(e,t.container):e}var Lh=["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"],Hh=["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"],np=["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"],ap=["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"],Ah=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],Oh=["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"],Bh=["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 Un(e,t,o){return Object.assign(({icon:n,labelKey:i,shortcutKey:a,className:l,hidden:s})=>{let c=H(),{close:d}=Zo(),m=Pe(),{isEnabled:u,disabledReason:g}=oe(t);return s?null:jsxRuntime.jsx(we,{slot:e,icon:n??re(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 ni=Un("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:Lh}),ai=Un("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:Hh}),ii=Un("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:ap}),li=Un("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:Bh});function zn({icon:e,labelKey:t,shortcutKey:o,className:r,hidden:n}){let i=H(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=Zo(),c=ke(),d=Pe(),m=Bt.useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:u,disabledReason:g}=oe(m);if(n)return null;let p=l!==null;return jsxRuntime.jsx(we,{slot:"edit.paste",icon:e??re(np),shortcut:d(o??"contextMenu.pasteShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let{text:f,html:h}=await zD(c);(f||h)&&i?.exec({type:"paste",text:f,...h?{html:h}:{}});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...r?{className:r}:{},children:d(t??"contextMenu.paste")})}zn.docxRow="edit.paste";async function zD(e){let t=editor.hostWindowOf(e),o=t.navigator.clipboard;if(typeof o.read=="function"&&typeof t.ClipboardItem<"u")try{let r=await o.read(),n="",i=null;for(let a of r)a.types.includes("text/plain")&&(n=await(await a.getType("text/plain")).text()),a.types.includes("text/html")&&(i=await(await a.getType("text/html")).text());if(n||i)return {text:n,html:i}}catch{}return {text:await o.readText(),html:null}}function $n({icon:e,labelKey:t,shortcutKey:o,className:r,hidden:n}){let i=H(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=Zo(),c=ke(),d=Pe(),m=Bt.useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:u,disabledReason:g}=oe(m);if(n)return null;let p=l!==null;return jsxRuntime.jsx(we,{slot:"edit.pasteWithoutFormatting",icon:e??re(np),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");}})();},...r?{className:r}:{},children:d(t??"contextMenu.pasteWithoutFormatting")})}$n.docxRow="edit.pasteWithoutFormatting";var Zh=Q("format.painter")?.paths??[],fs=Un("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:Zh}),gs=Un("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:Zh});function zo(e,t,o){return Object.assign(({icon:n,labelKey:i,className:a,hidden:l,destructive:s})=>{let{close:c}=Zo(),d=Pe(),m=si(),{isEnabled:u,disabledReason:g,execute:p}=oe(t);return l||!m?null:jsxRuntime.jsx(we,{slot:e,icon:n??re(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 Vn=zo("table.selectTable",{type:"selectTableRegion",region:"table"},{labelKey:"table.selectTable",paths:editor.tableChromeIconPaths("select_all")}),Gn=zo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:editor.tableChromeIconPaths("table_rows")}),jn=zo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:editor.tableChromeIconPaths("table_rows")}),Yn=zo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:editor.tableChromeIconPaths("view_column")}),Xn=zo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:editor.tableChromeIconPaths("view_column")}),Jn=zo("table.mergeCells",{type:"mergeCells"},{labelKey:"table.mergeCells",paths:editor.tableChromeIconPaths("call_merge")}),Qn=Object.assign(({icon:e,labelKey:t,className:o,hidden:r})=>{let{close:n}=Zo(),i=Pe(),a=si(),l=ko(),{isEnabled:s,disabledReason:c}=oe("table.splitCell");return r||!a||!l?null:jsxRuntime.jsx(we,{slot:"table.splitCell",icon:e??re(editor.tableChromeIconPaths("call_split")),disabled:!s,...c?{title:c}:{},...o?{className:o}:{},onSelect:()=>{n(true),l.open("splitCell");},children:i(t??"table.splitCell")})},{docxRow:"table.splitCell"}),ea=zo("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:editor.tableChromeIconPaths("delete_sweep"),destructive:true}),ta=zo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:editor.tableChromeIconPaths("view_column"),destructive:true}),oa=zo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:editor.tableChromeIconPaths("delete"),destructive:true}),$D=[{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 $r({hidden:e}){let{close:t}=Zo(),o=Pe(),r=si(),n=oe({type:"setTableCellVerticalAlignment",alignment:"top"}),i=oe({type:"setTableCellVerticalAlignment",alignment:"center"}),a=oe({type:"setTableCellVerticalAlignment",alignment:"bottom"}),l=[n,i,a];return e||!r?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:$D.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:re(editor.tableChromeIconPaths(s.icon))},s.alignment)})})]})}$r.docxRow="table.cellVerticalAlignment";var Kh=e=>e?{tocId:e}:{},qh=e=>t=>({type:"refreshToc",mode:e,...Kh(t)}),VD=e=>({type:"removeToc",...Kh(e)});function lp(e,t,o){return Object.assign(({icon:n,labelKey:i,className:a,hidden:l})=>{let s=H(),{close:c,tocId:d}=Zo(),m=Pe(),u=Bt.useMemo(()=>t(d),[d]),{isEnabled:g,disabledReason:p}=oe(u);return l||d===null?null:jsxRuntime.jsx(we,{slot:e,icon:n??re(o.paths),disabled:!g,...p?{title:p}:{},onSelect:()=>{s?.exec(u),c(true);},...a?{className:a}:{},children:m(i??o.labelKey)})},{docxRow:e})}var ra=lp("toc.refresh",qh("entire"),{labelKey:"toc.refresh",paths:Ah}),na=lp("toc.refreshPageNumbers",qh("pageNumbers"),{labelKey:"toc.refreshPageNumbers",paths:Oh}),aa=lp("toc.remove",VD,{labelKey:"toc.remove",paths:ap});function si(){return W(Bt.useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function bs({label:e,icon:t,shortcut:o,disabled:r,disabledReason:n,active:i,onSelect:a,className:l}){let{close:s}=Zo();return jsxRuntime.jsx(we,{...t?{icon:t}:{},...o?{shortcut:o}:{},...r?{disabled:r}:{},...r&&n?{title:n}:{},...i!==void 0?{active:i}:{},onSelect:()=>{a?.(),s(true);},...l?{className:l}:{},children:e})}var di=8;function JD(){let e=Bt.useContext(Lt),t=Je(),o=Pe(),{isEnabled:r,reason:n}=Wl(o);if((e?.mounted??0)===0)return null;let i=Q("review.addComment");return jsxRuntime.jsx(we,{icon:re(i?.paths),slot:"review.addComment",disabled:!r,title:n??void 0,onSelect:()=>{e?.requestCommentDraft()&&t.setOpenMenu(null);},children:o("comments.addComment")})}function QD(){let e=H(),t=Je(),o=Pe();return e?.can({type:"editTextFormField"}).ok?jsxRuntime.jsx(we,{slot:"field.edit",onSelect:()=>{t.setOpenMenu(null),e.exec({type:"editTextFormField"});},children:o("textFormField.edit")}):null}var eR=[{kind:"row",id:"field.edit",render:()=>jsxRuntime.jsx(QD,{})},{kind:"row",id:"edit.cut",render:()=>jsxRuntime.jsx(ni,{})},{kind:"row",id:"edit.copy",render:()=>jsxRuntime.jsx(ai,{})},{kind:"row",id:"edit.paste",render:()=>jsxRuntime.jsx(zn,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsxRuntime.jsx($n,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsxRuntime.jsx(fs,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsxRuntime.jsx(gs,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsxRuntime.jsx(ii,{})},{kind:"row",id:"edit.selectAll",render:()=>jsxRuntime.jsx(li,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsxRuntime.jsx(Jl,{shortcutKey:"contextMenu.insertLinkShortcut"})},{kind:"row",id:"review.addComment",render:()=>jsxRuntime.jsx(JD,{})}];function tR(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Vn.docxRow,render:()=>jsxRuntime.jsx(Vn,{})},{kind:"row",id:Gn.docxRow,render:()=>jsxRuntime.jsx(Gn,{})},{kind:"row",id:jn.docxRow,render:()=>jsxRuntime.jsx(jn,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:Yn.docxRow,render:()=>jsxRuntime.jsx(Yn,{})},{kind:"row",id:Xn.docxRow,render:()=>jsxRuntime.jsx(Xn,{})},{kind:"separator",id:"sep.table.cells"},{kind:"row",id:Jn.docxRow,render:()=>jsxRuntime.jsx(Jn,{})},{kind:"row",id:Qn.docxRow,render:()=>jsxRuntime.jsx(Qn,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:ea.docxRow,render:()=>jsxRuntime.jsx(ea,{})},{kind:"row",id:ta.docxRow,render:()=>jsxRuntime.jsx(ta,{})},{kind:"row",id:oa.docxRow,render:()=>jsxRuntime.jsx(oa,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:$r.docxRow,render:()=>jsxRuntime.jsx($r,{})}]}function oR(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:ra.docxRow,render:()=>jsxRuntime.jsx(ra,{})},{kind:"row",id:na.docxRow,render:()=>jsxRuntime.jsx(na,{})},{kind:"row",id:aa.docxRow,render:()=>jsxRuntime.jsx(aa,{})}]}function rR(e,t=false){return [...eR,...e?tR():[],...t?oR():[]]}function jh(e){if(!Bt.isValidElement(e))return null;let t=Mn(e,jh);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 r=es(e.props);if(r)return r}return null}function Vh(e){if(!Bt.isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function nR(e){return e?.closest(".docx-editor__scroll-container")??null}function ui({className:e,t,preset:o=true,disabled:r,onOpenChange:n,children:i}){let a=qt(),l=it(),s=H(),{t:c}=L(),d=si(),m=Bt.useRef(null),u=Bt.useRef(null),[g,p]=Bt.useState(null),[f,h]=Bt.useState(null),[y,x]=Bt.useState(null),b=Bt.useMemo(()=>rR(d,f!==null),[d,f]),[v,P]=Bt.useState(null),T=Bt.useCallback((N=false)=>{p(null),P(null),h(null),x(null),N&&s?.focus();},[s]);Bt.useEffect(()=>{if(r)return;let N=nR(m.current);if(!N)return;let B=F=>{if(u.current?.contains(F.target)){F.preventDefault();return}if(!ub(N,F.target))return;F.preventDefault();let D=F.button===-1||F.clientX===0&&F.clientY===0,R=N.getBoundingClientRect();h(s?.snapshot().tocContext?.id??null),x(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)},[r,s]),Bt.useEffect(()=>{r&&T();},[r,T]),Bt.useEffect(()=>{if(!g)return;let N=z=>{u.current?.contains(z.target)||T();},B=z=>{z.key==="Escape"?(z.preventDefault(),T(true)):z.key==="Tab"&&T();},F=()=>T(),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,T]),Bt.useLayoutEffect(()=>{let N=u.current;if(!g||!N)return;let{width:B,height:F}=N.getBoundingClientRect(),D=editor.hostWindowOf(N),R=D.innerWidth-B-di,z=D.innerHeight-F-di,ee=D.getComputedStyle(N).direction==="rtl"?g.x-B>=di:g.x>R,Y=Math.max(di,Math.min(ee?g.x-B:g.x,R)),q=Math.max(di,g.y>z?g.y-F:g.y);P({x:Y,y:q});},[g]),Bt.useLayoutEffect(()=>{v&&u.current?.focus({preventScroll:true});},[v]);let C=Bt.useRef(n);C.current=n;let E=Bt.useRef(false);Bt.useEffect(()=>{let N=g!==null;N!==E.current&&(E.current=N,C.current?.(N));},[g]);let S=Bt.useMemo(()=>({t,openMenu:null,setOpenMenu:()=>T(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,T]),[k,w]=Bt.useState(null),I=Bt.useMemo(()=>({close:T,anchor:g,tocId:f,target:y,clipboardRefusal:k,reportClipboardRefusal:w}),[T,g,f,y,k]),O={position:"fixed",left:(v??g)?.x??0,top:(v??g)?.y??0,visibility:v?"visible":"hidden"};return jsxRuntime.jsx("div",{ref:m,style:{display:"contents"},children:g?jsxRuntime.jsx($a.Provider,{value:S,children:jsxRuntime.jsx(ts.Provider,{value:I,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:O,onKeyDown:N=>{let B=u.current;if(!B)return;let F=Wr(B);N.key==="ArrowDown"?(N.preventDefault(),Qt(F,editor.hostDocumentOf(B).activeElement,1)):N.key==="ArrowUp"?(N.preventDefault(),Qt(F,editor.hostDocumentOf(B).activeElement,-1)):N.key==="Home"?(N.preventDefault(),eo(F,"first")):N.key==="End"&&(N.preventDefault(),eo(F,"last"));},children:[Bt.Children.toArray(i).filter(Vh),Bl({entries:b,children:Bt.Children.toArray(i).filter(N=>!Vh(N)),preset:o,keyOfEntry:N=>N.id,keyOfChild:N=>db(jh(N)),renderEntry:N=>N.kind==="separator"?jsxRuntime.jsx(Zr,{}):N.render(),onUnmatched:(N,B)=>{B.props.hidden&&Ng(N);}})]})})}):null})}var dp=Object.assign(ui,{Cut:ni,Copy:ai,Paste:zn,PasteWithoutFormatting:$n,Delete:ii,SelectAll:li,SelectTable:Vn,InsertRowAbove:Gn,InsertRowBelow:jn,InsertColumnLeft:Yn,InsertColumnRight:Xn,MergeCells:Jn,SplitCell:Qn,DeleteTableRow:ea,DeleteTableColumn:ta,DeleteTable:oa,CellVerticalAlignment:$r,RefreshToc:ra,RefreshTocPageNumbers:na,RemoveToc:aa,Item:bs,Slot:to,Row:we,Group:Xa,Separator:Zr,Submenu:oo});var Yh=jd.Provider;function Xh(){let e=kt(),{t}=L();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e?.hyperlink&&Se(e.hyperlink,{}),e?.contentControl&&Se(e.contentControl,{}),e?.equation&&Se(e.equation,{}),e?.contextMenu&&Se(e.contextMenu,{t:o=>t(o)})]})}function Jh(e,t,o,r){return {...e,hyperlink:e?.hyperlink??(t===false?false:n=>jsxRuntime.jsx(Za,{...n})),contentControl:e?.contentControl??(n=>jsxRuntime.jsx(Ua,{...n})),equation:e?.equation??(()=>jsxRuntime.jsx(za,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:n=>e.contextMenu&&Se(e.contextMenu,{...n,t:r??n.t}):o===false?false:n=>jsxRuntime.jsx(ui,{...n,t:r??n.t,...typeof o=="object"?o:{}})}}function sR(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 up(){let e=H(),t=Bt.useCallback(r=>{let n=e?.getActiveScope();return n?.kind==="note"?n:null},[e]),o=W(t,sR);return o?.kind==="note"?o:null}function Qh(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 e0(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&&Qh(e.documentAuthored,t.documentAuthored)&&Qh(e.sectionAuthored,t.sectionAuthored)}function cR(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&e0(e.footnote,t.footnote)&&e0(e.endnote,t.endnote)}function pp(){let e=H(),t=Bt.useCallback(o=>e?.getNotePropertiesState()??null,[e]);return W(t,cR)}function pi(e,t){let[o,r]=Bt.useState(null),n=Bt.useCallback(l=>r(l),[]),[i,a]=Bt.useState({visibility:"hidden"});return Bt.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 h=e(s);if(h!==m&&(u.disconnect(),u.observe(s),u.observe(o),h&&u.observe(h),m=h),!h||!h.isConnected){a({visibility:"hidden"});return}let y=h.getBoundingClientRect(),x=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,b=t==="story-label"?6:4,v=l===s,P=t==="after"?y.bottom+6:t==="story-label"?editor.storyLabelTop(y,h.closest(".docx-page")?.getBoundingClientRect().top,x,b):y.top-x-b,T=v?Pn(s,y.left,P):{left:y.left,top:P},C=T.left,E=T.top,S=v?s.scrollLeft+8:8;a({position:v?"absolute":"fixed",left:t==="story-label"?C:Math.max(S,C+8),top:t==="story-label"?E:Math.max(v?s.scrollTop+8:8,E),...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:n,style:i}}var gR=/^(footnote|endnote):(-?\d{1,10})$/;function r0(e){let t=gR.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function bR(e){let t=editor.hostWindowOf(e);return typeof t.matchMedia!="function"?false:t.matchMedia("(pointer: coarse)").matches}function fp(e){let t=H();return Bt.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 hR(e){let{t}=L(),[o,r]=Bt.useState(false),n=Bt.useRef(null);return Bt.useEffect(()=>{if(o)return editor.listenForOutsidePress({popup:n.current,close:()=>r(false)})},[o]),jsxRuntime.jsxs("div",{ref:n,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:U,onClick:()=>r(i=>!i),children:t("headerFooter.options")}),o?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:U,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-properties",onClick:()=>{e.onOpenProperties(),r(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(),r(false);},children:t("common.close")})]}):null]})}function Cs({className:e}){let t=kt(),o=Bt.useRef(null),{t:r}=L(),n=H(),i=up(),[a,l]=Bt.useState(null),[s,c]=Bt.useState(null),[d,m]=Bt.useState(false),u=Bt.useRef(null),g=Bt.useCallback(I=>{if(!i)return null;let N=[...I.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=pi(g,"story-label"),f=Bt.useCallback(()=>{u.current&&u.current.win.clearTimeout(u.current.handle),u.current=null,l(null);},[]);Bt.useEffect(()=>{if(!n)return;let I=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!I)return;let O=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),n.setActiveScope({kind:"note",id:R.dataset.docxNoteScope});return}D.closest("[data-docx-note-mark-back]")&&(F.preventDefault(),f(),c(null),n.setActiveScope({kind:"body"}));},N=F=>{let D=F,z=D.target?.closest("[data-docx-note-scope]");z?.dataset.docxNoteScope&&(D.preventDefault(),c({scopeId:z.dataset.docxNoteScope,x:D.clientX,y:D.clientY}));},B=F=>{let D=F.target;if(bR(D))return;let R=D?.closest("[data-docx-note-ref]");if(!R?.dataset.docxNoteScope){f();return}let z=R.dataset.docxNoteScope,ee=n.getNotePreviewText(z)??R.getAttribute("aria-description")??r("notes.previewFallback"),Y=R.getBoundingClientRect();u.current&&u.current.win.clearTimeout(u.current.handle);let q=editor.hostWindowOf(R),G=q.setTimeout(()=>{l({scopeId:z,text:ee,x:Y.left,y:Y.bottom+4});},400);u.current={win:q,handle:G};};return I.addEventListener("click",O),I.addEventListener("contextmenu",N),I.addEventListener("pointerover",B),I.addEventListener("scroll",f,true),()=>{I.removeEventListener("click",O),I.removeEventListener("contextmenu",N),I.removeEventListener("pointerover",B),I.removeEventListener("scroll",f,true),f();}},[n,f,r]);let h=Bt.useCallback(I=>{n&&(n.exec(I),c(null));},[n]),y=s?r0(s.scopeId):null,x=Bt.useMemo(()=>y?{type:"deleteNote",noteKind:y.noteKind,noteId:y.noteId}:null,[y]),b=Bt.useMemo(()=>y?{type:"convertNote",fromKind:y.noteKind,noteId:y.noteId}:null,[y]),v=Bt.useMemo(()=>y?{type:"convertAllNotes",fromKind:y.noteKind}:null,[y]),P=fp(x??{type:"deleteNote",noteKind:"footnote",noteId:0}),T=fp(b??{type:"convertNote",fromKind:"footnote",noteId:0}),C=fp(v??{type:"convertAllNotes",fromKind:"footnote"}),E=i?r0(i.id):null,S=E?r("notes.editingRegion",{kind:E.noteKind==="footnote"?r("notes.footnoteKind"):r("notes.endnoteKind"),number:E.noteId}):null,k=s&&y?{...s,...y,onDelete:()=>{x&&h(x);},onConvert:()=>{b&&h(b);},onConvertAll:()=>{v&&h(v);},onOpenProperties:()=>m(true),onClose:()=>c(null),deleteEnabled:P.enabled,convertEnabled:T.enabled,convertAllEnabled:C.enabled,deleteDisabledReason:P.reason??void 0,convertDisabledReason:T.reason??void 0,convertAllDisabledReason:C.reason??void 0}:null,w={onClose:()=>m(false),onApply:I=>{h(I),m(false);}};return n?jsxRuntime.jsxs("div",{className:e,ref:o,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":i?void 0:true,children:[i&&E?jsxRuntime.jsxs("div",{ref:p.ref,className:"docx-context-bar docx-notes-chrome__banner",role:"region","aria-label":r("notes.chromeAriaLabel"),"data-testid":"docx-notes-banner","data-note-scope":i.id,style:{...p.style,zIndex:vt.chrome},children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:S}),jsxRuntime.jsx(hR,{onOpenProperties:()=>m(true),onClose:()=>n.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Se(t.notePreview,a):jsxRuntime.jsx(En,{...a}):null,k&&t?.notesContextMenu!==false?t?.notesContextMenu?Se(t.notesContextMenu,k):jsxRuntime.jsx(Sn,{...k}):null,d&&t?.noteProperties!==false?t?.noteProperties?Se(t.noteProperties,w):jsxRuntime.jsx(Ts,{...w}):null]}):null}function Ts(e){let{t}=L(),o=H(),r=pp(),[n,i]=Bt.useState("document"),[a,l]=Bt.useState("decimal"),[s,c]=Bt.useState("continuous"),[d,m]=Bt.useState("pageBottom"),[u,g]=Bt.useState("decimal"),[p,f]=Bt.useState("continuous"),[h,y]=Bt.useState("docEnd");Bt.useEffect(()=>{r&&(l(r.footnote.resolved.numFmt),c(r.footnote.resolved.numRestart),m(r.footnote.resolved.pos),g(r.endnote.resolved.numFmt),f(r.endnote.resolved.numRestart),y(r.endnote.resolved.pos));},[r]);let x=!r?.footnote.sectionAuthored,b=!r?.endnote.sectionAuthored&&r?.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:vt.modal},onClick:e.onClose,onKeyDown:v=>{v.key==="Escape"&&e.onClose();},children:jsxRuntime.jsxs("div",{className:"docx-note-properties__panel",onClick:v=>v.stopPropagation(),onMouseDown:v=>v.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:n,onChange:v=>i(v.target.value),children:[jsxRuntime.jsx("option",{value:"document",children:t("notes.scopeDocument")}),jsxRuntime.jsx("option",{value:"section",children:t("notes.scopeSection")})]})]}),jsxRuntime.jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxRuntime.jsxs("legend",{className:"docx-note-properties__legend",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.footnotes")}),x?jsxRuntime.jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__fields",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:a,onChange:v=>l(v.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:v=>c(v.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:v=>m(v.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")}),b?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:v=>g(v.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:v=>f(v.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:h,"data-testid":"docx-notes-endnote-position",onChange:v=>y(v.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 v={type:"setNoteProperties",scope:n,sectionIndex:n==="section"?r?.sectionIndex:void 0,footnote:{numFmt:a,numRestart:s,position:d},endnote:{numFmt:u,numRestart:p,position:h}};o.can(v).ok&&e.onApply(v);},children:t("common.apply")})]})]})})}var l0=e=>e.image;function i0(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 SR(){let e=Kt(),[t,o]=Bt.useState(false);return {ref:Bt.useCallback(n=>{n&&o(!n.parentElement?.closest(e?".docx-editor.dark":".docx-editor"));},[e]),className:t?`docx-editor ${e?"dark ":""}`:""}}function PR(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function vp(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(cr(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(cr(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(cr(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(cr(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function kR(e,t){let o=vp(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function Es(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=Ga(t);return Number.isInteger(o)?o:null}function wR(e,t){let o=vp(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,m=c?Es(e.horizontalPoints):t.position?.horizontalEmu,u=d?Es(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 r=e.horizontalPoints!==o.horizontalPoints,n=e.verticalPoints!==o.verticalPoints,i=e.relativeToH!==o.relativeToH,a=e.relativeToV!==o.relativeToV,l=r?Es(e.horizontalPoints):t.position?.horizontalEmu,s=n?Es(e.verticalPoints):t.position?.verticalEmu;return r&&l===null?{ok:false}:n&&s===null?{ok:false}:{ok:true,value:{...typeof l=="number"?{horizontalEmu:l}:{},...typeof s=="number"?{verticalEmu:s}:{},...i||r||n?{relativeToH:e.relativeToH}:{},...a||r||n?{relativeToV:e.relativeToV}:{}}}}function Ss(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function Ps(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function fi({open:e,onClose:t,className:o,triggerRef:r}){let n=H(),{t:i}=L(),a=W(l0),l=Bt.useId(),s=Bt.useId(),c=Bt.useId(),d=Bt.useRef(null),m=Bt.useRef(null),u=Bt.useRef(null),g=Bt.useRef(null),[p,f]=Bt.useState(null),[h,y]=Bt.useState(null),x=SR(),b=m.current,v=b?.canCrop===false,P=b?.canResize===false,T=b?.locks.changeAspect===true,C=b?.kind==="anchored"&&b.canMove===true,E=b?.kind==="inline",S=b?.kind==="anchored"&&b.canMove===false;Bt.useEffect(()=>{if(!e){m.current=null,u.current=null,g.current=null;return}if(!a)return;if(m.current=a,n?.surface){let{anchor:z}=n.surface.state().selection;u.current={paragraphId:z.paragraphId,offset:z.offset},g.current=n.surface.session.packageRevision();}y(null);let D=vp(a),R=a.crop;f({widthPoints:String(cr(a.widthEmu)),heightPoints:String(cr(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,n]);let k=Bt.useCallback(()=>{r?.current?.focus(),n?.focus();},[n,r]),w=Bt.useCallback(()=>{t(),k();},[t,k]);Bt.useEffect(()=>{if(!e)return;let D=d.current;if(!D)return;let R=i0(D);(R.find(Y=>Y.id==="image-prop-width"&&!Y.hasAttribute("disabled"))??R.find(Y=>!Y.hasAttribute("disabled"))??D).focus();let V=Y=>{if(Y.key==="Escape"){Y.preventDefault(),w();return}if(Y.key!=="Tab")return;let q=i0(D);if(q.length===0)return;let G=editor.hostDocumentOf(D).activeElement,ce=q.findIndex(_=>_===G);if(ce===-1)return;Y.preventDefault();let A=Y.shiftKey?(ce-1+q.length)%q.length:(ce+1)%q.length;q[A]?.focus();},ee=editor.hostDocumentOf(D);return ee.addEventListener("keydown",V),()=>ee.removeEventListener("keydown",V)},[e,w]);let I=Bt.useMemo(()=>{let D=b??a;return !D||D.widthEmu<=0?1:D.widthEmu/D.heightEmu},[a,b]),O=Bt.useCallback(D=>{f(R=>{if(!R)return R;if(!R.lockAspect)return {...R,widthPoints:D};let z=Ps(D);if(z===null)return {...R,widthPoints:D};let V=Math.round(z/I*100)/100;return {...R,widthPoints:D,heightPoints:String(V)}});},[I]),N=Bt.useCallback(D=>{f(R=>{if(!R)return R;if(!R.lockAspect)return {...R,heightPoints:D};let z=Ps(D);if(z===null)return {...R,heightPoints:D};let V=Math.round(z*I*100)/100;return {...R,widthPoints:String(V),heightPoints:D}});},[I]),B=Bt.useCallback(()=>{let D=m.current;if(!D?.intrinsic)return;let R=D.intrinsic.pixelWidth*72/D.intrinsic.dpiX,z=D.intrinsic.pixelHeight*72/D.intrinsic.dpiY;f(V=>V&&{...V,widthPoints:String(Math.round(R*100)/100),heightPoints:String(Math.round(z*100)/100)});},[a]),F=Bt.useCallback(()=>{let D=m.current,R=u.current,z=g.current;if(!n||!D||!p||!R||z===null)return;let V={type:"setImageProperties",drawingNodeId:D.id,expectedPackageRevision:z,selectionParagraphId:R.paragraphId,selectionOffset:R.offset};if(!P){let A=Ps(p.widthPoints),_=Ps(p.heightPoints);if(A===null||_===null){y("imageProperties.errors.invalidDimensions");return}let ae=Ga(A),fe=Ga(_);ae!==D.widthEmu&&(V.widthEmu=ae),fe!==D.heightEmu&&(V.heightEmu=fe);}if(D.canCrop&&!v){let A=Ss(p.cropLeft),_=Ss(p.cropTop),ae=Ss(p.cropRight),fe=Ss(p.cropBottom);if(A===null||_===null||ae===null||fe===null){y("imageProperties.errors.invalidCrop");return}let Z=D.crop;(A!==Z.left||_!==Z.top||ae!==Z.right||fe!==Z.bottom)&&(V.crop={left:A,top:_,right:ae,bottom:fe});}p.title!==D.title&&(V.title=p.title),p.description!==D.description&&(V.description=p.description);let ee=p.hyperlink.trim();if(ee!==(D.hyperlink??"")&&(V.hyperlink=ee===""?null:ee),D.canChangeWrap&&p.wrap!==D.wrap&&(V.wrap=p.wrap),D.kind==="anchored"&&D.canMove&&kR(p,D)){let A=wR(p,D);if(!A.ok){y("imageProperties.errors.invalidPosition");return}if(!editor.validateDrawingPositionInput(editor.positionInputFromPropertiesCommand(A.value,D))){y("imageProperties.errors.invalidPosition");return}Object.assign(V,A.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(!n.can(V).ok){y("imageProperties.errors.refused");return}if(!n.exec(V).ok){y("imageProperties.errors.refused");return}w();},[n,p,v,P,w]);return !e||!p?null:jsxRuntime.jsx("div",{ref:x.ref,className:`${x.className}docx-dialog-overlay${o?` ${o}`:""}`,onClick:w,onMouseDown:D=>{D.stopPropagation(),PR(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:[h?jsxRuntime.jsx("p",{className:"docx-dialog__error",children:i(h)}):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:P,onChange:D=>O(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:P,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:T,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:v||!b?.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")}),E?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionUnavailable")}):null,S?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p.positionMode==="frame"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-h",children:i("imageProperties.relativeToHorizontal")}),jsxRuntime.jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:p.relativeToH??"page",onChange: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:b?.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:v,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:v,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:v,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:v,value:p.cropBottom,onChange:D=>f(R=>R&&{...R,cropBottom:D.target.value})})]}),v?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.nonPictureHint")}):null]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick: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 ws({className:e,hidden:t,asChild:o,children:r}){let n=kt(),i=H(),{t:a}=L(),l=W(l0),[s,c]=Bt.useState(false),d=Bt.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;if(t)return null;let f=Q("image.properties"),h={type:"button",ref:d,className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!g,...g?{}:{"data-disabled":""},"aria-label":a("formattingBar.imagePropertiesShortcut"),title:p??a("formattingBar.imagePropertiesShortcut"),onMouseDown:U,onClick:()=>c(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o?jsxRuntime.jsx(J,{...h,children:r}):jsxRuntime.jsx("button",{...h,children:r??re(f?.paths)}),s&&n?.imageProperties!==false?n?.imageProperties?Se(n.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):jsxRuntime.jsx(fi,{open:s,onClose:()=>c(false),triggerRef:d}):null]})}ws.docxSlot="image.properties";var ia=Object.assign(ws,{docxSlot:"image.properties"});function gi(e){let t=H(),o=Bt.useCallback(()=>editor.toolbarCommandState(t,e),[t,e]),r=W(o,(n,i)=>n.value===i.value&&n.enabled===i.enabled&&n.disabledReason===i.disabledReason);return Bt.useMemo(()=>({execute:(n,i)=>editor.runToolbarCommand(t,e,n,i),value:r.value===void 0?null:e==="font.size"||e==="list.lineSpacing"?Number(r.value):r.value,options:e==="image.wrap"?editor.IMAGE_WRAP_TARGETS:[],isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,e,r])}function Ds({className:e,hidden:t,asChild:o,children:r}){let n=kt(),i=ne(),{execute:a,value:l,isEnabled:s,disabledReason:c}=gi("image.altText"),[d,m]=Bt.useState(false),[u,g]=Bt.useState(""),p=Bt.useRef(null),f=Bt.useRef(null),h=Bt.useId();Bt.useEffect(()=>{d&&g(l??"");},[d,l]),Bt.useEffect(()=>{if(!d)return;let T=S=>{let k=p.current;editor.isDomNode(S.target)&&(k?.contains(S.target)||k?.ownerDocument.getElementById(h)?.contains(S.target))||m(false);},C=S=>{S.key==="Escape"&&(S.preventDefault(),m(false),f.current?.focus());},E=editor.hostDocumentOf(p.current);return E.addEventListener("mousedown",T,true),E.addEventListener("keydown",C),()=>{E.removeEventListener("mousedown",T,true),E.removeEventListener("keydown",C);}},[d,h]);let y=Bt.useCallback(()=>{a(u),m(false);},[u,a]);if(t)return null;let x=Q("image.altText"),b=i(x?.labelKey??"formattingBar.altText"),v={type:"button",ref:f,className:`docx-toolbar__button docx-toolbar__alt-text-trigger${e?` ${e}`:""}`,"data-slot":"image.altText",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?h:void 0,"aria-label":b,title:c??b,onMouseDown:U,onClick:()=>m(T=>!T)},P={id:h,value:u,onValueChange:g,onApply:y,onClose:()=>m(false),isEnabled:s,anchorRef:f};return jsxRuntime.jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsxRuntime.jsx(J,{...v,children:r}):jsxRuntime.jsx("button",{...v,children:r??b}),d&&n?.imageAltText!==false?n?.imageAltText?Se(n.imageAltText,P):jsxRuntime.jsx(Rs,{...P}):null]})}Ds.docxSlot="image.altText";var bi=Object.assign(Ds,{docxSlot:"image.altText"});function Rs({id:e,value:t,onValueChange:o,onApply:r,onClose:n,isEnabled:i,className:a}){let{t:l}=L();return jsxRuntime.jsxs("div",{id:e,role:"dialog","aria-label":l("imageAltText.panelTitle"),className:`docx-toolbar__alt-text-panel${a?` ${a}`:""}`,onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${e}-description`,children:l("imageAltText.description")}),jsxRuntime.jsx("textarea",{id:`${e}-description`,className:"docx-dialog__textarea",value:t,onChange:s=>o(s.target.value),placeholder:l("dialogs.imageProperties.altTextPlaceholder")}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:n,children:l("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",disabled:!i,onClick:r,children:l("common.apply")})]})]})}function Ep(e){let[t,o]=Bt.useState(e.session),[r,n]=Bt.useState(0);return t!==e.session&&(o(e.session),n(r+1)),jsxRuntime.jsx(BR,{...e},r)}function BR({session:e,className:t,style:o,children:r}){let n=Qe(),[i,a]=Bt.useState(e.signal.aborted),l=Bt.useRef(null);return Bt.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(Be,{kind:"invalidTextFormField",role:"alertdialog",label:n("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:r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:n("textFormField.invalidTitle")})}),jsxRuntime.jsx("div",{className:"docx-dialog__body",children:n(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:n("textFormField.apply")})})]})})}var m0=Bt.createContext(null),f0=m0.Provider;function st(){let e=Bt.useContext(m0);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function XR(e){return e.kind==="date"?editor.parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function g0(e){let t=`docx-cc-list-${Bt.useId()}`,[o,r]=Bt.useState(()=>XR(e)),[n,i]=Bt.useState(()=>editor.calendarDateText(e.value,e.locale)),a=Bt.useMemo(()=>editor.createContentControlListNavigation(e.locale),[e]),[l,s]=Bt.useState(false),c=Bt.useCallback(w=>{i(w),s(false);},[]),d=W(()=>e.canApply()),m=e.kind==="date"?editor.parseIsoDate(e.value):null,[u,g]=Bt.useState(()=>{let w=m??new Date;return {year:w.getFullYear(),month:w.getMonth()}}),p=Bt.useCallback(w=>{let I=e.apply(w??o);return s(!I),I},[e,o]),f=Bt.useCallback(()=>e.cancel(),[e]),h=Bt.useCallback(async w=>{if(!e.replaceImage)return s(true),false;try{let I=w instanceof Uint8Array?w.byteLength:w.size;if(!e.canApply()||I>store.DEFAULT_IMAGE_RESOURCE_LIMITS.maxEncodedBytes)return s(!0),!1;let O=w instanceof Uint8Array?w:new Uint8Array(await w.arrayBuffer()),N=await e.replaceImage(O);return s(!N),N}catch{return s(true),false}},[e]),y=Bt.useMemo(()=>editor.calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),x=Bt.useCallback(()=>{g(w=>editor.shiftMonth(w.year,w.month,-1)),C(null);},[]),b=Bt.useCallback(()=>{g(w=>editor.shiftMonth(w.year,w.month,1)),C(null);},[]),v=Bt.useCallback(w=>p(w),[p]),P=Bt.useCallback(()=>p(editor.isoDateOf(new Date)),[p]),[T,C]=Bt.useState(null),E=Bt.useCallback(w=>{let I=editor.parseIsoDate(w);I&&(g({year:I.getFullYear(),month:I.getMonth()}),C(editor.isoDateOf(I)));},[]),S=Bt.useCallback(()=>{let w=editor.calendarDateFromText(n,e.locale);return w?p(w):(s(true),false)},[n,e.locale,p]),k=Bt.useCallback((w,I)=>{!Number.isInteger(w)||w<100||w>9999||!Number.isInteger(I)||I<0||I>11||(g({year:w,month:I}),C(null));},[]);return Bt.useMemo(()=>({session:e,kind:e.kind,items:e.items,value:o,setValue:r,isEnabled:d,refused:l,apply:p,cancel:f,calendar:y,previousMonth:x,nextMonth:b,selectDay:v,selectToday:P,focusIso:T,focusDay:E,dateText:n,setDateText:c,applyDateText:S,showMonth:k,listNavigation:a,listId:t,accept:editor.CONTENT_CONTROL_PICTURE_ACCEPT,replaceImage:h}),[e,h,o,d,l,p,f,y,x,b,v,P,T,E,n,c,S,k,a,t])}function et(e,t,o,r){if(t.hidden)return null;let{children:n,asChild:i,className:a,style:l,hidden:s,id:c,title:d,"aria-label":m,...u}=t,g=n===void 0?r:n,{key:p,...f}=o,h={...c!==void 0?{id:c}:{},...d!==void 0?{title:d}:{},...m!==void 0?{"aria-label":m}:{}};if(i){let{className:x,style:b,...v}=f;return jsxRuntime.jsx(J,{...u,...v,...h,...a?{className:a}:{},style:{...b,...l},children:g},p)}return jsxRuntime.jsx(e,{...u,...f,...h,className:[o.className,a].filter(Boolean).join(" "),style:{...o.style,...l},children:g},p)}var Yr=e=>e.stopPropagation();function wp(e){return et("div",e,{className:"docx-content-control-calendar-header","data-docx-part":"header"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dp,{}),jsxRuntime.jsx(Op,{}),jsxRuntime.jsx(Rp,{}),jsxRuntime.jsx(Mp,{className:"docx-content-control-calendar-announcement"})]}))}function Dp(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"previousMonth","aria-label":o("contentControl.calendar.previousMonth"),onMouseDown:Yr,onClick:t.previousMonth},"\u2039")}function Rp(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"nextMonth","aria-label":o("contentControl.calendar.nextMonth"),onMouseDown:Yr,onClick:t.nextMonth},"\u203A")}function Mp(e){let t=st();return et("div",e,{className:"docx-content-control-calendar-title","data-docx-part":"title","aria-live":"polite"},t.calendar.title)}function _p(e){let t=st();return et("div",e,{className:"docx-content-control-calendar-weekdays","data-docx-part":"weekdays"},t.calendar.weekdays.map((o,r)=>jsxRuntime.jsx("span",{children:o},r)))}function Ip({day:e,...t}){let o=st(),r=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),n=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 et("button",t,{type:"button",className:"docx-content-control-calendar-day","data-docx-part":"day","data-iso":e.iso,role:"gridcell",tabIndex:e.iso===r?.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:Yr,onClick:()=>o.selectDay(e.iso),onKeyDown:n},String(e.day))}function Np(e){let t=st(),o=Bt.useRef(null);return Bt.useLayoutEffect(()=>{let r=o.current;if(!r||r.ownerDocument.activeElement?.closest("[data-docx-part=previousMonth],[data-docx-part=nextMonth],[data-docx-part=month],[data-docx-part=year]"))return;((t.focusIso?r.querySelector(`[data-iso="${t.focusIso}"]`):null)??r.querySelector("[data-selected]")??r.querySelector("[data-today]:not([data-other-month])")??r.querySelector('[data-docx-part="day"]:not([data-other-month])'))?.focus({preventScroll:true});},[t.focusIso,t.calendar]),et("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},(r,n)=>jsxRuntime.jsx("div",{role:"row",className:"docx-content-control-calendar-week",children:t.calendar.days.slice(n*7,n*7+7).map(i=>jsxRuntime.jsx(Ip,{day:i},i.iso))},n)))}function Fp(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-content-control-calendar-today","data-docx-part":"today",disabled:!t.isEnabled,onMouseDown:Yr,onClick:t.selectToday},o("contentControl.calendar.today"))}function Lp(e){return et("div",e,{className:"docx-content-control-calendar","data-docx-part":"calendar"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(wp,{}),jsxRuntime.jsx(_p,{}),jsxRuntime.jsx(Np,{}),jsxRuntime.jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsxRuntime.jsx(Fp,{}),jsxRuntime.jsx(_s,{})]}),jsxRuntime.jsx(la,{}),jsxRuntime.jsx(Ns,{})]}))}function Hp({item:e,...t}){let o=st();return et("button",t,{type:"button",className:"docx-content-control-menu-item","data-docx-part":"item","data-value":e.value,role:"option",tabIndex:o.items.findIndex(r=>r.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:Yr,onClick:()=>o.apply(e.value)},e.displayText)}function Ms(e){let t=st(),o=Qe();return et("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((r,n)=>jsxRuntime.jsx(Hp,{item:r},n)))}function _s(e){let t=st(),o=Qe();return et("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:r=>{r.key!=="Enter"||r.nativeEvent.isComposing||(r.preventDefault(),r.stopPropagation(),t.kind==="date"?t.applyDateText():t.apply());},onMouseDown:Yr,onChange:r=>(t.kind==="date"?t.setDateText:t.setValue)(r.target.value)},void 0)}function la(e){let t=st(),o=Qe();return t.refused?et("div",e,{className:"docx-content-control-widget-error","data-docx-part":"error",role:"alert"},o("disabledReason.invalidValue")):null}function Ap(e){let t=st(),o=Qe();return et("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 Is(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t.cancel},o("common.cancel"))}function Ns(e){return et("div",e,{className:"docx-dialog__footer","data-docx-part":"footer"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Is,{}),jsxRuntime.jsx(Ap,{})]}))}function Op(e){return et("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bp,{}),jsxRuntime.jsx(Wp,{})]}))}function Bp(e){let t=st(),o=Qe();return et("select",e,{className:"docx-content-control-calendar-month","data-docx-part":"month","aria-label":o("contentControl.calendar.month"),value:t.calendar.month,onChange:r=>t.showMonth(t.calendar.year,Number(r.target.value))},editor.calendarMonthNames(t.session.locale).map((r,n)=>jsxRuntime.jsx("option",{value:n,children:r},n)))}function Wp(e){let t=st(),o=Qe();return et("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:r=>{let n=Number(r.target.value);if(!Number.isInteger(n)||n<100||n>9999){r.target.value=String(t.calendar.year);return}t.showMonth(n,t.calendar.month);},onKeyDown:r=>{r.key==="Enter"&&!r.nativeEvent.isComposing&&(r.preventDefault(),r.currentTarget.blur());}},void 0)}function Zp({autoOpen:e,...t}){let o=st(),r=Qe(),n=Bt.useRef(null),i=Bt.useRef(false);return Bt.useLayoutEffect(()=>{e!==false&&!i.current&&(i.current=true,n.current?.click());},[e]),et("input",t,{ref:n,type:"file",accept:o.accept,className:"docx-content-control-picture-input","data-docx-part":"picture","aria-label":r("contentControl.types.picture"),"aria-invalid":o.refused||void 0,onMouseDown:Yr,onCancel:o.cancel,onChange:a=>{let l=a.target.files?.[0];a.target.value="",l&&o.replaceImage(l);}},void 0)}function iM(e){let[t,o]=Bt.useState(e.session),[r,n]=Bt.useState(0);return t!==e.session&&(o(e.session),n(r+1)),jsxRuntime.jsx(lM,{...e},r)}function lM({session:e,className:t,style:o,children:r}){let n=Qe(),i=g0(e),[a,l]=Bt.useState(e.signal.aborted),s=Bt.useRef(null),[c]=Bt.useState(()=>editor.contentControlPopupOpener(e.anchor)),d=e.kind==="checkbox"&&r===void 0;if(Bt.useEffect(()=>{let u=()=>l(true);return e.signal.addEventListener("abort",u,{once:true}),e.signal.aborted&&u(),()=>e.signal.removeEventListener("abort",u)},[e]),Bt.useEffect(()=>{!d||e.signal.aborted||e.apply(e.value==="true"?"false":"true");},[d,e]),Bt.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]),Bt.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=n(`contentControl.types.${e.kind}`);return jsxRuntime.jsx(f0,{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:r??sM(i)})})}function sM(e){return e.kind==="date"?jsxRuntime.jsx(Lp,{}):e.kind==="picture"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Zp,{}),jsxRuntime.jsx(la,{}),jsxRuntime.jsx(Is,{})]}):e.kind==="comboBox"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(_s,{}),jsxRuntime.jsx(Ms,{}),jsxRuntime.jsx(la,{}),jsxRuntime.jsx(Ns,{})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ms,{}),jsxRuntime.jsx(la,{})]})}var zp=Object.assign(iM,{Navigation:Op,Month:Bp,Year:Wp,Calendar:Lp,Header:wp,PreviousMonth:Dp,Title:Mp,NextMonth:Rp,Weekdays:_p,Grid:Np,Day:Ip,Today:Fp,List:Ms,Item:Hp,Input:_s,Picture:Zp,Error:la,Footer:Ns,Apply:Ap,Cancel:Is});function Vp(e){return e==="checkbox"?"contentControlCheckbox":e==="picture"?"contentControlPicture":"contentControlWidget"}function y0(){let e=H(),t=kt(),o=Bt.useRef(t);o.current=t;let[r,n]=Bt.useState(null),[i,a]=Bt.useState(null),l=t?.contentControlWidget!==void 0,s=t?.contentControlCheckbox!==void 0,c=t?.contentControlPicture!==void 0,d=t?.invalidTextFormField!==void 0;Bt.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?.[Vp(f.kind)]===false)return f.cancel();n(f),f.signal.addEventListener("abort",()=>{u&&n(h=>h===f?null:h);},{once:true});}},{fallback:true});return ()=>{u=false,p(),n(null);}},[e,l,s,c]),Bt.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]),Bt.useEffect(()=>{r&&t?.[Vp(r.kind)]===false&&r.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,r,i]);let m=r?t?.[Vp(r.kind)]:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r&&m&&Se(m,{session:r},r),i&&t?.invalidTextFormField&&Se(t.invalidTextFormField,{session:i},i)]})}var kM=["nw","n","ne","e","se","s","sw","w"],E0=40,S0=12;function wM(e){return `imageOverlay.handle.${e}`}function DM(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 RM(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 MM(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 jp({containerRef:e,portalRef:t,scrollPort:o}){let r=H(),{t:n}=L(),[i,a]=Bt.useState(null),[l,s]=Bt.useState(null),[c,d]=Bt.useState({left:0,top:0}),m=Bt.useRef(null);m.current=l;let u=Bt.useRef(null),g=Bt.useRef(null),p=Bt.useRef(null),f=Bt.useRef(null),h=Bt.useRef(null);Bt.useEffect(()=>{let E=e.current;if(!E)return;let S=k=>{let w=editor.isElementNode(k.target)?k.target:null;if(w?.closest(".docx-drawing-textbox-content")){f.current=null;return}let I=w?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");f.current=I??null,I&&I===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return E.addEventListener("pointerdown",S,{capture:true}),()=>E.removeEventListener("pointerdown",S,{capture:true})},[e,i?.id]),Bt.useEffect(()=>{if(!r){a(null);return}let E=()=>{a(editor.selectedDrawingOverlayTargetOf(r.surface));},S=()=>{queueMicrotask(E);};E();let k=[r.on("change",S),r.on("selectionChange",E)];return ()=>{for(let w of k)w();}},[r]);let y=Bt.useCallback(()=>{d(E=>{let S=editor.overlayHostOrigin(e.current);return S.left===E.left&&S.top===E.top?E:S});},[e]);Bt.useEffect(()=>{y();let E=t.current,S=editor.hostWindowOf(E).ResizeObserver;if(!E||typeof S!="function")return;let k=new S(y);k.observe(E);let w=e.current;return w&&k.observe(w),()=>k.disconnect()},[e,t,y,i]),Bt.useEffect(()=>{if(o){h.current=o;return}let E=e.current;if(!E||!r?.surface)return;let S=E.closest(".docx-editor__scroll-container");if(!S)return;let k=r.surface.overlayCoordinates();return h.current=editor.createImageOverlayScrollPort(S,k.paintScale),()=>{h.current=null;}},[e,r,o]);let x=Bt.useCallback(()=>{s(null),u.current=null;let E=g.current;if(g.current=null,E)try{E.releasePointerCapture(E._lastPointerId??0);}catch{}},[]),b=Bt.useCallback((E,S,k,w,I,O,N)=>{if(!r?.surface)return;let B=r.surface.activeScope();if(B.kind==="frame"&&!r.surface.selectDrawing(k.id,B.hostParagraphId))return;let F=r.surface.layout(),D=editor.captureImageMutationPreconditions(r);if(D){u.current=Object.freeze({x:w,y:I}),g.current=O,O._lastPointerId=N;try{O.setPointerCapture(N);}catch{}s({session:Object.freeze({drawingNodeId:k.id,startBounds:Object.freeze({x:k.x,y:k.y,width:k.width,height:k.height}),startWidthEmu:k.widthEmu,startHeightEmu:k.heightEmu,startPosition:k.position,anchorFrameOrigin:k.anchorFrameOrigin,transform:k.transform,mode:E,handle:S,preconditions:D,layoutRevision:F.revision,packageRevision:r.surface.session.packageRevision(),kind:k.kind}),bounds:k,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});}},[r]),v=Bt.useCallback((E,S,k,w,I)=>{if(!r)return;if(editor.isStaleImageInteractionCommit(r,E)){x();return}E.mode==="resize"?r.exec({type:"setImageProperties",widthEmu:S,heightEmu:k,...I?.mode==="simple"?{horizontalEmu:I.horizontalEmu,verticalEmu:I.verticalEmu}:{},...I?.mode==="frame"?{...I.horizontalEmu!==void 0?{horizontalEmu:I.horizontalEmu}:{},...I.verticalEmu!==void 0?{verticalEmu:I.verticalEmu}:{}}:{}}):E.mode==="move"&&I&&r.exec({type:"setImagePosition",...I}),x();},[x,r]),P=Bt.useCallback(E=>{if(!r)return;let S=m.current?.bounds??editor.selectedDrawingOverlayTargetOf(r.surface);if(!S)return;if(m.current&&E.key==="Escape"){E.preventDefault(),E.stopPropagation(),x();return}if(m.current)return;let k=editor.historyShortcutOf(E);if(k){E.preventDefault(),E.stopPropagation(),r.exec({type:k});return}let w=E.shiftKey?editor.IMAGE_OVERLAY_NUDGE_SHIFT_PT:editor.IMAGE_OVERLAY_NUDGE_PT;if(E.key==="Delete"||E.key==="Backspace"){E.preventDefault(),E.stopPropagation(),r.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(E.key))return;E.preventDefault(),E.stopPropagation();let I=E.key==="ArrowLeft"?-w:E.key==="ArrowRight"?w:0,O=E.key==="ArrowUp"?-w:E.key==="ArrowDown"?w:0;if(E.altKey){if(!S.canResize)return;let B=MM(I,O),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:I,deltaYPt:O,transform:S.transform,preserveAspect:editor.resizePreservesAspect(B,S.aspectLocked,E.shiftKey,S.textbox),kind:S.kind});r.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,I,O);r.exec({type:"setImagePosition",...N});},[x,r]);Bt.useEffect(()=>{if(!l||!r?.surface)return;let E=r.surface.overlayCoordinates(),S=I=>{let O=m.current,N=u.current;if(!O||!N)return;let B=editor.cssPixelsToLayoutPoints(I.clientX-N.x,E.paintScale),F=editor.cssPixelsToLayoutPoints(I.clientY-N.y,E.paintScale);if(O.session.mode==="move"){let R=0,z=h.current,V=e.current?.closest(".docx-editor__scroll-container");if(z&&V){let Y=V.getBoundingClientRect();I.clientY>Y.bottom-E0?R=S0:I.clientY<Y.top+E0&&(R=-S0),R!==0&&(R=z.scrollBy(R));}let ee=O.accumulatedScrollPt+R;s({...O,accumulatedScrollPt:ee,bounds:Object.freeze({...O.bounds,x:O.session.startBounds.x+B,y:O.session.startBounds.y+F+ee})});return}if(!O.session.handle)return;let D=editor.computeImageResizeResult({handle:O.session.handle,startWidthEmu:O.session.startWidthEmu,startHeightEmu:O.session.startHeightEmu,startBounds:O.session.startBounds,startPosition:O.session.startPosition,anchorFrameOrigin:O.session.anchorFrameOrigin,deltaXPt:B,deltaYPt:F,transform:O.session.transform,preserveAspect:editor.resizePreservesAspect(O.session.handle,O.bounds.aspectLocked,I.shiftKey,O.bounds.textbox),kind:O.session.kind});s({...O,bounds:Object.freeze({...O.bounds,x:D.previewBounds.x,y:D.previewBounds.y,width:D.previewBounds.width,height:D.previewBounds.height,widthEmu:D.widthEmu,heightEmu:D.heightEmu})});},k=I=>{let O=m.current;if(O)if(I.type==="pointerup"){let N=editor.cssPixelsToLayoutPoints(I.clientX-(u.current?.x??I.clientX),E.paintScale),B=editor.cssPixelsToLayoutPoints(I.clientY-(u.current?.y??I.clientY),E.paintScale),F=editor.finalizeImageOverlayInteraction({session:O.session,deltaXPt:N,deltaYPt:B,accumulatedScrollPt:O.accumulatedScrollPt,aspectLocked:O.bounds.aspectLocked,textbox:O.bounds.textbox,shiftKey:I.shiftKey,anchorFrameOrigin:O.session.anchorFrameOrigin});v(O.session,F.widthEmu,F.heightEmu,F.previewBounds,F.position);}else x();},w=editor.hostWindowOf(e.current);return w.addEventListener("pointermove",S),w.addEventListener("pointerup",k),w.addEventListener("pointercancel",k),()=>{w.removeEventListener("pointermove",S),w.removeEventListener("pointerup",k),w.removeEventListener("pointercancel",k);}},[x,v,e,r,l]),Bt.useEffect(()=>{!i||f.current!==i.id||(f.current=null,p.current?.focus({preventScroll:true}));},[i]);let T=l?.bounds??i,C=Bt.useMemo(()=>{if(!r?.surface||!T)return null;let E=r.surface.publishedLayout(),S=r.surface.overlayCoordinates(),k=editor.overlayFrameToSheetCssPixels(E,{pageIndex:T.pageIndex,x:T.x,y:T.y,width:T.width,height:T.height},S),w={left:k.left+c.left,top:k.top+c.top,width:k.width,height:k.height},I=T.canResize,O=T.kind==="anchored"&&T.canMove,N=editor.textboxFrameReason(T,r.surface.editingMode()),B=N?n(N):void 0;return jsxRuntime.jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":T.id,tabIndex:0,onKeyDown:P,children:[jsxRuntime.jsx("div",{className:`docx-image-selection-overlay__frame${O?" docx-editor-one-surface__overlay-control":""}`,"data-textbox":T.textbox?"true":void 0,title:B,"aria-description":B,role:"group","aria-label":n("imageOverlay.selection"),style:{left:`${w.left}px`,top:`${w.top}px`,width:`${w.width}px`,height:`${w.height}px`,cursor:O?"move":"default"},onPointerDown:F=>{U(F),!(!O||!T.position)&&F.button===0&&(F.preventDefault(),F.stopPropagation(),b("move",null,T,F.clientX,F.clientY,F.currentTarget,F.pointerId));}}),I?kM.map(F=>{let D=RM(F);return jsxRuntime.jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":n(wM(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:DM(F)},onPointerDown:R=>{U(R),R.button===0&&(R.preventDefault(),R.stopPropagation(),b("resize",F,T,R.clientX,R.clientY,R.currentTarget,R.pointerId));}},F)}):null]})},[T,b,r,P,c.left,c.top,n]);return !C||!t.current?null:reactDom.createPortal(C,t.current)}function Yp(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Os({className:e}){let t=H(),o=ja(),r=Bt.useRef(null),n=Bt.useContext(xn),i=Bt.useCallback(d=>{r.current=d,n?.setContainer(d);},[n]),a=Bt.useRef(null);Bt.useLayoutEffect(()=>{let d=r.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=Bt.useCallback(d=>{if(!o?.isEnabled)return;let m=d.clipboardData;m&&Yp(m)&&(editor.clipboardPasteLandsContent(m)||(d.preventDefault(),o.insertFromDataTransfer(m)));},[o]),s=Bt.useCallback(d=>{!o?.isEnabled||!Yp(d.dataTransfer)||d.preventDefault();},[o]),c=Bt.useCallback(d=>{if(o?.isEnabled&&Yp(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(Nh,{}),jsxRuntime.jsx(Xh,{}),jsxRuntime.jsx(y0,{}),t?jsxRuntime.jsx(jp,{containerRef:r,portalRef:a}):null]})}function Jp({open:e,onClose:t,children:o,url:r,name:n,features:i,title:a,styles:l}){let[s,c]=Bt.useState(null),{dir:d}=L(),m=Kt(),u=Bt.useRef(t);u.current=t;let g=Bt.useRef({url:r,name:n,features:i,title:a,styles:l});g.current={url:r,name:n,features:i,title:a,styles:l};let p=Bt.useRef(null);return Bt.useEffect(()=>{if(!e)return;let f=p.current;if(f)f.claimed=true;else {let{url:b,name:v,features:P,title:T,styles:C}=g.current;f={claimed:true,promise:editor.openEditorWindow({...b!==void 0?{url:b}:{},...v!==void 0?{name:v}:{},...P!==void 0?{features:P}:{},...T!==void 0?{title:T}:{},...C!==void 0?{styles:C}:{}})},p.current=f;}let h=f,y=true,x;return h.promise.then(b=>{if(y){if(!b){p.current=null,u.current?.();return}x=b.onClose(()=>{y&&(p.current=null,reactDom.flushSync(()=>c(null)),u.current?.());}),c(b);}}),()=>{y=false,x?.(),h.claimed=false,c(null),queueMicrotask(()=>{h.claimed||(p.current===h&&(p.current=null),h.promise.then(b=>b?.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 ze(e){return e/1440*96}function Bs(e){return e/96*1440}function Dt(e){return `${Math.round(e*100)/100}px`}function Qp(e){return e/2}var YM=e=>e.isLoading||e.isOpening===true,XM=e=>({width:ze(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:ze(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),JM=(e,t)=>e.width===t.width&&e.height===t.height;function em({className:e}){return jsxRuntime.jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}var D0=false;function R0(){D0||!bt()||(D0=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 QM(e){let t=H(),[o,r]=Bt.useState(null);return Bt.useEffect(()=>{if(!(!t||!e))return t.setOpeningIndicatorHost({publish:r}),()=>{t.setOpeningIndicatorHost(null),r(null);}},[t,e]),o}function e1({when:e=false,overlay:t=false,className:o,style:r,indicator:n,children:i}){let a=W(YM),l=W(XM,JM),s=QM(t),c=H(),d=Bt.useRef({visible:false,editor:null}),[,m]=Bt.useReducer(x=>x+1,0),u=d.current.visible&&d.current.editor!==c,g=s===null&&(e||a||u);Bt.useLayoutEffect(()=>{d.current={visible:g,editor:c},u&&m();},[g,c,u]);let{t:p}=L(),f=Kt(),h=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(em,{}),jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:p("loading.label")})]});if(s)return reactDom.createPortal(h,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:r,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:h})})})})})}var Ws=Object.assign(e1,{Spinner:em});function M0(){let e=new Set,t=new Map,o=new Map,r=0,n=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(!n)return;let u=a(),g=c(u);if(g!==l){if(u===void 0){i&&(n.setRevisionStyles("author"),i=false,l=g);return}n.setRevisionStyles(u),i=true,l=g;}}function m(){!n||s||(s=true,queueMicrotask(()=>{s=false,d();}));}return {registerScheme(u){e.add(u),m();},register(u,g,p){o.has(u)||o.set(u,r++),t.set(u,{author:g,style:p}),m();},unregister(u){(e.delete(u)||t.delete(u))&&m();},connect(u){n=u;let g=a();i=u!==null&&g!==void 0,l=u===null?null:c(g),m();},current:a}}var Ci=Bt.createContext(null);function N0(){let e=Bt.useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function tm(){let e=Bt.useContext(Ci),t=N0();return Bt.useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function om(e){let{author:t,color:o,background:r,activeBackground:n,spanClassName:i,avatarUrl:a}=e,l=Bt.useContext(Ci),s=N0();return Bt.useEffect(()=>{if(l)return l.register(s,t,{...o!==void 0?{color:o}:{},...r!==void 0?{background:r}:{},...n!==void 0?{activeBackground:n}:{},...i!==void 0?{spanClassName:i}:{},...a!==void 0?{avatarUrl:a}:{}}),()=>l.unregister(s)},[l,s,t,o,r,n,i,a]),null}var F0=false;function L0(e,t){e===t||F0||!bt()||(F0=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 H0=false,A0=e=>e?.allowFormattingInLockedContent===true;function O0(e,t){A0(e)===A0(t)||H0||!bt()||(H0=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 B0=false;function W0(e){return e===void 0?"characters":e}function Z0(e,t){W0(e)===W0(t)||B0||!bt()||(B0=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 d1(e,t){if(e===t)return true;let o=editor.resolveZoomMode(e),r=editor.resolveZoomMode(t);return o!==null&&r!==null&&editor.sameZoomMode(o,r)}function u1(e){let t=Bt.useRef(e);t.current=e;let[o,r]=Bt.useState(null),{onReady:n,onChange:i,onFontError:a,onRevisionMarkupChange:l,...s}=e,c=Bt.useMemo(()=>({onReady:d=>{r(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:Ti,rootProps:s,rootListeners:c,editorRef:o}}function Ti(e){let{document:t,fonts:o,fontShaping:r,author:n,locale:i,translate:a,mode:l,zoom:s,zoomMode:c,tableInteractionLabel:d,imageDecodePort:m,colorMode:u,children:g}=e,p=Rl(u),{t:f}=L(),h=Bt.useCallback((Z,de)=>f(Z,de),[f]),y=Bt.useRef(h);y.current=h;let x=Bt.useRef(false),[b,v]=Bt.useState(0),P=Bt.useRef(e);P.current=e;let T=r?.maxFontBytes,[C,E]=Bt.useState(null),S=Bt.useRef(e.fieldResults),k=Bt.useRef(e.contentLockPolicy),w=Bt.useRef(e.lockedControlNavigation),I=Bt.useRef(e.fonts),O=Bt.useRef(null);O.current??=M0();let N=O.current,B=Bt.useRef(null);B.current??=ng();let F=B.current;Bt.useEffect(()=>{let Z=P.current,de=Z.translate??y.current,Re=N.current();S.current=Z.fieldResults,k.current=Z.contentLockPolicy,w.current=Z.lockedControlNavigation;let Ae=editor.createDocxEditor({unsupportedElementRules:F.current(),...Z.document!==void 0?{document:Z.document}:{},...Z.fonts?{fonts:Z.fonts}:{},...Z.fontShaping?{fontShaping:Z.fontShaping}:{},...Z.author!==void 0?{author:Z.author}:{},...Z.locale!==void 0?{locale:Z.locale}:{},translate:de,...Z.revisionMarkup!==void 0?{revisionMarkup:Z.revisionMarkup}:{},...Z.reviewDisplayMode!==void 0?{reviewDisplayMode:Z.reviewDisplayMode}:{},...Z.fieldResults!==void 0?{fieldResults:Z.fieldResults}:{},...Z.contentLockPolicy!==void 0?{contentLockPolicy:Z.contentLockPolicy}:{},...Z.lockedControlNavigation!==void 0?{lockedControlNavigation:Z.lockedControlNavigation}:{},...Z.mode!==void 0?{mode:Z.mode}:{},...Re!==void 0?{revisionStyles:Re}:{},...Z.modules!==void 0?{modules:Z.modules}:{},...Z.zoom!==void 0?{zoom:Z.zoom}:{},...Z.zoomMode!==void 0?{zoomMode:Z.zoomMode}:{},...Z.tableInteractionLabel?{tableInteractionLabel:Z.tableInteractionLabel}:{},...Z.imageDecodePort?{imageDecodePort:Z.imageDecodePort}:{},onFontError:nt=>P.current.onFontError?.(nt)});I.current=Z.fonts;let ft=Ae.on("revisionMarkupChange",nt=>{x.current||(P.current.onRevisionMarkupChange?.(nt),v(Zt=>Zt+1));}),ve=Ae.on("change",nt=>P.current.onChange?.(nt));return E(Ae),()=>{ft(),ve(),Ae.destroy(),E(nt=>nt===Ae?null:nt);}},[t,T,m,N,F]),Bt.useEffect(()=>{!C||I.current===o||(I.current=o,C.setFonts(o).catch(()=>{}));},[C,o]),Bt.useEffect(()=>{if(!C)return;if(!C.snapshot().isOpening){P.current.onReady?.(C);return}let Z=C.on("change",()=>{Z(),P.current.onReady?.(C);});return Z},[C]);let D=Bt.useRef({editor:null,zoom:void 0,mode:void 0});Bt.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 Re=D.current.mode,Ae=c!==void 0&&(Re===void 0||!d1(Re,c)),ft=c===void 0?null:editor.resolveZoomMode(c),ve=de&&c!==void 0&&ft!==null&&ft.type==="fit";(Ae||ve)&&(D.current.mode=c,C.setZoomMode(c));},[C,s,c]),Bt.useEffect(()=>{if(!C||e.revisionMarkup===void 0)return;let Z=editor.resolveRevisionMarkup(e.revisionMarkup);if(JSON.stringify(Z)!==JSON.stringify(C.snapshot().revisionMarkup)){x.current=true;try{C.setRevisionMarkup(Z);}finally{x.current=false;}}},[C,e.revisionMarkup,b]),Bt.useEffect(()=>{C&&C.setAuthor(n);},[C,n]);let R=Bt.useRef({editor:null,value:void 0});Bt.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]),Bt.useEffect(()=>{C&&C.setTranslate(a??h);},[C,a,h]),Bt.useEffect(()=>{C&&C.setLocale(i);},[C,i]),Bt.useEffect(()=>{C&&L0(S.current,e.fieldResults);},[C,e.fieldResults]),Bt.useEffect(()=>{C&&O0(k.current,e.contentLockPolicy);},[C,e.contentLockPolicy]),Bt.useEffect(()=>{C&&Z0(w.current,e.lockedControlNavigation);},[C,e.lockedControlNavigation]),Bt.useEffect(()=>{C&&C.setTableInteractionLabel(d??editor.defaultTableLabel);},[C,d]);let[z,V]=Bt.useState(0),[ee,Y]=Bt.useState(0),q=Bt.useRef([]),[G,ce]=Bt.useState(0),A=G>0,_=Bt.useRef(C);_.current=C,Bt.useEffect(()=>{if(!(!C||!A))return C.setCommentDraftChrome({onRequest:()=>q.current.at(-1)?.()})},[C,A]);let ae=Bt.useMemo(()=>({mounted:z,register:()=>(V(Z=>Z+1),()=>V(Z=>Math.max(0,Z-1))),gutters:ee,reserveGutter:()=>(Y(Z=>Z+1),()=>Y(Z=>Math.max(0,Z-1))),registerCommentDraft:Z=>(q.current.push(Z),ce(de=>de+1),()=>{let de=q.current.indexOf(Z);de!==-1&&(q.current.splice(de,1),ce(Re=>Math.max(0,Re-1)));}),requestCommentDraft:()=>{let Z=_.current;return Z!==null&&editor.runToolbarCommand(Z,"review.addComment").ok}}),[z,ee]),fe=Bt.useMemo(Pg,[]);return Bt.useEffect(()=>(N.connect(C),()=>N.connect(null)),[N,C]),Bt.useEffect(()=>(F.connect(C),()=>F.connect(null)),[F,C]),jsxRuntime.jsx(Ir.Provider,{value:p,children:jsxRuntime.jsx(xn.Provider,{value:F,children:jsxRuntime.jsx(Dh,{value:a??h,children:jsxRuntime.jsx(Lt.Provider,{value:ae,children:jsxRuntime.jsx(kd.Provider,{value:C,children:jsxRuntime.jsx(Ad.Provider,{value:fe,children:jsxRuntime.jsx(Ci.Provider,{value:N,children:jsxRuntime.jsx(p1,{children:jsxRuntime.jsx(m1,{children:jsxRuntime.jsx(Yh,{value:e.popups,children:jsxRuntime.jsx($l,{children:jsxRuntime.jsx(Ih,{popups:e.popups,children:g})})})})})})})})})})})})}function p1({children:e}){let[t,o]=Bt.useState(0),r=Bt.useCallback(()=>(o(i=>i+1),()=>o(i=>i-1)),[]),n=Hl(t>0);return jsxRuntime.jsx(Yd.Provider,{value:r,children:jsxRuntime.jsx(Ba.Provider,{value:n,children:e})})}function m1({children:e}){let t=Ol();return jsxRuntime.jsx(cu.Provider,{value:t,children:e})}var Ei=316,da=editor.REVIEW_MARKERS_GUTTER_PX,$0=24,Zs={inlineStart:0,inlineEnd:Ei},q0={inlineStart:da,inlineEnd:da},T1={inlineStart:0,inlineEnd:0},am={inlineStart:$0,inlineEnd:Ei};function E1(e){return e.inlineStart===am.inlineStart&&e.inlineEnd===am.inlineEnd}function V0(e,t){return E1(e)?Math.max(0,t-(Ei-da)):t}function Ks(){let e=it(),t=ke(),[o,r]=Bt.useState("ltr");return Bt.useLayoutEffect(()=>{let n=t?.parentElement;if(e||!n)return;let i=()=>r(editor.hostDirectionOf(n));return i(),editor.observeHostDirection(n,i)},[e,t]),(e??o)==="rtl"?"left":"right"}function G0(e,t){return t==="left"?{left:e.inlineEnd,right:e.inlineStart}:{left:e.inlineStart,right:e.inlineEnd}}function j0({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:r=0,docked:n=false,scroll:i=false}){if(!e)return q0;if(n||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return Zs;let a=Number.isFinite(r)&&r>0?r:0;return t-a-o-2*$0>=Ei?Zs:i?am:q0}var S1=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"}},P1=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.scroll===t.scroll&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function Y0(){let e=ke(),[t,o]=Bt.useState(null);return Bt.useEffect(()=>{if(!e){o(null);return}let r=()=>o(e.clientWidth);r();let n=editor.hostWindowOf(e).ResizeObserver;if(typeof n>"u")return;let i=new n(r);return i.observe(e),()=>i.disconnect()},[e]),t}function fr(){let e=Bt.useContext(Lt),{pageSetup:t,reviewPaneOpen:o,entitledZoom:r,scroll:n}=W(S1,P1),i=ke(),a=wg(),l=Bt.useRef(null);t&&(l.current=t.pageWidthTwips);let s=t?.pageWidthTwips??l.current,c=Pl(e),d=Bt.useCallback(f=>c?j0({open:o,viewportWidth:f??0,pageWidthPx:s===null||r===null?0:ze(s)*r,inlineStartReservation:a,docked:r===null,scroll:n}):T1,[c,o,s,r,a,n]),m=()=>d(i?i.clientWidth:null),[u,g]=Bt.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)),Bt.useEffect(()=>{let f=i?editor.hostWindowOf(i).ResizeObserver:void 0;if(!i||typeof f>"u")return;let h=()=>g(x=>{let b=d(i.clientWidth);return b===x.gutter?x:{compute:d,viewport:i,gutter:b}}),y=new f(h);return y.observe(i),()=>y.disconnect()},[i,d]),p.gutter}var qs=[.25,.5,.75,1,1.25,1.5,2];function Si(e,t){return t==="in"?qs.find(r=>r>e+.001)??null:[...qs].reverse().find(r=>r<e-.001)??null}function X0(e,t){return e==="0"?1:e==="+"||e==="="?Si(t,"in")??t:e==="-"?Si(t,"out")??t:null}var lm=Bt.createContext(false);function J0(e){let t=Bt.useContext(lm),[o,r]=Bt.useState(null);return Bt.useLayoutEffect(()=>{let n=t?e?.parentElement??null:null;r(n?{host:n,scoped:n.closest(".docx-editor")!==null}:null);},[t,e]),{inside:t,host:o?.host??null,hostScoped:o?.scoped??false}}var N1=e=>e.reviewPaneOpen??true,F1=e=>e.zoomMode?.type==="fit";function Us({className:e,style:t,children:o}){let{t:r}=L(),n=qt(),i=H(),a=W(N1),l=fr(),s=Ks(),c=W(F1),d=Bt.useContext(Lt),m=Pl(d),u=Fr(),g=Lr(),p=Bt.useRef(null),f=Bt.useCallback(y=>{p.current=y,u?.setViewport(y);},[u]),h=Bt.useCallback(y=>{if(!i||!(y.metaKey||y.ctrlKey)||y.altKey)return;let x=y.target;if(editor.isElementNode(x)&&x.closest('input, textarea, select, [role="dialog"]'))return;let b=X0(y.key,i.getZoom());b!==null&&(y.preventDefault(),i.setZoom(b));},[i]);return jsxRuntime.jsx("div",{ref:f,"data-testid":"docx-editor-scroll",tabIndex:0,role:"region","aria-label":r("editor.documentViewport"),onKeyDownCapture:h,...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:`${n}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*da}px`}:{}},children:jsxRuntime.jsx(Ao.Provider,{value:true,children:jsxRuntime.jsx(lm.Provider,{value:true,children:o})})})}var H1=editor.LOADING_SNAPSHOT;function ey({ref:e,editorRef:t}){Bt.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,r)=>t.current?.exec(o,r)??{ok:false,code:"notFound",reason:"no editor is mounted"},snapshot:o=>t.current?.snapshot(o)??H1}),[t]);}function ua(e,t,o,r){let n=ke(),i=Bt.useRef({close:o,skip:r,viewport:n});i.current={close:o,skip:r,viewport:n},Bt.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 V1=e=>e.editingMode??"editing",dm='[role="menuitemradio"]:not([disabled])',G1=(e,t)=>e.length===t.length&&e.every((o,r)=>o===t[r]),j1=e=>e.isLoading||e.isOpening===true,Pi=[{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"}],Y1=Object.freeze(Pi.map(()=>null));function X1(e){return e?Pi.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):Y1}var J1="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function $s({className:e,hidden:t}){let o=H(),r=W(V1),n=W(j1),i=ne(),{t:a}=L(),[l,s]=Bt.useState(false),c=Bt.useRef(null),d=Bt.useRef(null),m=Bt.useRef(null);Bt.useEffect(()=>{if(!l)return;let b=m.current?.querySelectorAll(dm);(m.current?.querySelector(`${dm}[aria-checked="true"]`)??b?.[0]??void 0)?.focus();},[l]);let u=Bt.useCallback(b=>{let v=[...m.current?.querySelectorAll(dm)??[]],P=v.indexOf(editor.hostDocumentOf(m.current).activeElement),T=C=>{b.preventDefault(),v[(C+v.length)%v.length]?.focus();};b.key==="ArrowDown"?T(P+1):b.key==="ArrowUp"?T(P-1):b.key==="Home"?T(0):b.key==="End"&&T(v.length-1);},[]);Bt.useEffect(()=>{if(l)return editor.listenForOutsidePress({popup:c.current,close:()=>s(false)})},[l]),ua(l,c,b=>{s(false),b&&d.current?.focus();});let g=Bt.useCallback(b=>{s(false),editor.runToolbarCommand(o,"review.editingMode",b),o?.focus();},[o]),p=editor.toolbarCommandState(o,"review.editingMode"),f=i18n.localizeDisabledReason(p.disabledReason,a),h=W(()=>X1(o),G1),y=Bt.useMemo(()=>Pi.find(b=>b.mode===r)??Pi[0],[r]);if(t)return null;let x=Q("review.editingMode");return jsxRuntime.jsxs("div",{ref:c,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxRuntime.jsxs("button",{ref:d,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":r,"aria-haspopup":"menu","aria-expanded":l,"aria-label":i(x?.labelKey??"editingMode.label"),disabled:n||!p.enabled,...f?{title:f}:{},onMouseDown:U,onClick:()=>s(b=>!b),children:[um(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(x?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:Pi.map((b,v)=>{let P=i18n.localizeDisabledReason(h[v]??null,a);return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":b.mode===r,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${b.mode}`,disabled:P!==null,...P?{title:P}:{},onMouseDown:U,onClick:()=>g(b.mode),children:[um(b.path),jsxRuntime.jsxs("span",{className:"docx-toolbar__mode-text",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__mode-label",children:i(b.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-hint",children:i(b.hintKey)})]}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:b.mode===r?um(J1):null})]},b.mode)})}):null]})}$s.docxSlot="review.editingMode";function um(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 ny=[],t2=()=>{};function ki(){let e=H(),t=Bt.useCallback(o=>{if(!e)return t2;let r=_a(o),n=e.on("change",r),i=e.on("selectionChange",r);return ()=>{n(),i();}},[e]);return Bt.useSyncExternalStore(t,()=>e?.getReviewAuthors()??ny,()=>ny)}var c2=e=>e.hiddenReviewAuthors??[];function Gs({className:e,hidden:t,icon:o}){let r=H(),n=ki(),i=W(c2),a=new Set(i),l=n.every(v=>!a.has(v.author)),[s,c]=Bt.useState(false),d=Bt.useRef(null),m=Bt.useRef(null),u=Bt.useRef(null),g=ne(),{t:p}=L();Bt.useEffect(()=>{if(s)return u.current?.querySelector('[role="menuitemcheckbox"]')?.focus(),editor.listenForOutsidePress({popup:d.current,close:()=>c(false)})},[s]),ua(s,d,v=>{c(false),v&&m.current?.focus();});let f=Bt.useCallback(v=>{let P=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],T=P.indexOf(editor.hostDocumentOf(u.current).activeElement),C=E=>{v.preventDefault(),P[(E+P.length)%P.length]?.focus();};v.key==="ArrowDown"?C(T+1):v.key==="ArrowUp"?C(T-1):v.key==="Home"?C(0):v.key==="End"?C(P.length-1):v.key==="Tab"&&c(false);},[]);if(t)return null;let h=Q("review.authors"),y=editor.toolbarCommandState(r,"review.authors"),x=i18n.localizeDisabledReason(y.disabledReason,p),b=g(h?.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":b,disabled:!y.enabled,title:x??b,onMouseDown:U,onClick:()=>c(v=>!v),children:[o??re(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:b}),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":b,"data-testid":"reviewers-menu",onKeyDown:f,children:[jsxRuntime.jsx(ay,{checked:l,label:p("reviewers.all"),testId:"reviewer-all",onChoose:()=>r?.setAllReviewAuthorsVisible(!l)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),n.map(v=>jsxRuntime.jsx(ay,{checked:!a.has(v.author),label:v.author||"\u2014",testId:`reviewer-${v.slot}`,color:v.color,onChoose:()=>r?.setReviewAuthorVisible(v.author,a.has(v.author))},v.author))]}):null]})}Gs.docxSlot="review.authors";function ay(e){return jsxRuntime.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e.checked,className:"docx-toolbar__reviewer-item","data-testid":e.testId,onMouseDown:U,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 ly=Bt.createContext(null);function sy({children:e}){let t=ko(),[o,r]=Bt.useState(false),n=Bt.useRef(null),i=ke(),a=Bt.useRef(i);a.current=i;let l=Bt.useMemo(()=>({open:c=>{if(t){t.open("paragraph",c);return}n.current=c??editor.hostDocumentOf(a.current).activeElement,r(true);}}),[t]),s=Bt.useCallback(()=>{r(false);let c=n.current;n.current=null,editor.isHTMLElementNode(c)&&c.isConnected&&c.focus({preventScroll:true});},[]);return jsxRuntime.jsxs(ly.Provider,{value:l,children:[e,jsxRuntime.jsx(qo,{open:o,onClose:s})]})}function cy(){return Bt.useContext(ly)}var mm=["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"],fm=Bt.createContext({close:()=>{}});function pa(){return Bt.useContext(fm).close}function M2(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function my({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 fy({slot:e}){let t=ne(),o=Yt(),{close:r}=Bt.useContext(fm),{execute:n,isActive:i,isEnabled:a,disabledReason:l,value:s}=oe(e),c=Q(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:U,onClick:u=>{n(),r(u.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:re(c?.paths)}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:m})]})}function gy({sections:e,className:t}){let o=ne(),[r,n]=Bt.useState(false),i=Bt.useRef(null),a=Bt.useRef(null),l=Bt.useRef(null),s=Bt.useRef(false),c=Bt.useId(),d=ke(),m=Bt.useRef(d);m.current=d;let u=o("formattingBar.more"),g=Bt.useCallback(x=>{n(false),x&&a.current?.focus();},[]),p=Bt.useMemo(()=>({close:g}),[g]);Bt.useEffect(()=>{if(!r)return;let x=i.current,b=C=>i.current?.contains(C)===true||l.current?.contains(C)===true,v=x?editor.listenForPopupEscape({popup:x,contains:b,chromeRoot:()=>i.current?.closest(".docx-editor"),editorElements:()=>[m.current],skip:()=>editor.hasOpenNestedPopup(l.current),close:g}):void 0,P=x?editor.listenForPopupFocusLeave({popup:x,contains:b,close:()=>n(false)}):void 0,T=editor.listenForOutsidePress({popup:x,close:()=>n(false)});return ()=>{T(),v?.(),P?.();}},[r,g]);let[f,h]=Bt.useState(null);Bt.useLayoutEffect(()=>{if(!r){h(null);return}let x=()=>{let v=i.current,P=l.current,T=a.current,C=v?.ownerDocument.defaultView;if(!v||!P||!T||!C)return;let E=T.getBoundingClientRect(),S=editor.toolbarPanelPlacement({triggerLeft:E.left,triggerRight:E.right,panelWidth:P.offsetWidth,viewportWidth:C.innerWidth}),k=S.left-v.getBoundingClientRect().left;h(w=>w&&w.left===k&&w.maxWidth===S.maxWidth&&w.anchor===S.anchor?w:{...S,left:k});};x();let b=i.current?.ownerDocument.defaultView;return b?.addEventListener("resize",x),()=>b?.removeEventListener("resize",x)},[r]),Bt.useEffect(()=>{if(!r||!s.current)return;s.current=false;let x=l.current;x&&M2(x);},[r]);let y=x=>{x.key!=="Escape"||x.defaultPrevented||(x.preventDefault(),g(true));};return jsxRuntime.jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[ql]:"",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":r,"aria-controls":r?c:void 0,"aria-label":u,title:u,...r?{"data-active":""}:{},onMouseDown:U,onClick:()=>n(x=>!x),onKeyDown:x=>{x.key==="ArrowDown"&&(x.preventDefault(),s.current=true,n(true));},children:re(mm)}),r?jsxRuntime.jsx(fm.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(x=>jsxRuntime.jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":x.label??o(x.labelKey),children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:x.label??o(x.labelKey)}),x.children]},x.id))})}):null]})}function I2(e){if(!Bt.isValidElement(e))return false;let t=e.type;return (typeof t=="function"||typeof t=="object")&&t.docxToolbarGroup===true}function hy(e,t,o,r){let n=new Map,i=new Map,a=new Map,l=[];for(let s of Bt.Children.toArray(e)){if(I2(s)){a.delete(s.props.id),a.set(s.props.id,s.props);continue}let c=t(s);if(c&&o(c))n.set(c,s);else if(c&&r(c))i.set(c,s);else {if(c&&Bt.isValidElement(s)&&s.props.hidden===true)continue;l.push(s);}}return {overrides:n,tableOverrides:i,groups:[...a.values()],appended:l}}function Ys(e,t){return e.label!==void 0?e.label:e.labelKey!==void 0?t(e.labelKey):e.id}function gm(e){let t=ne();return e.hidden?null:jsxRuntime.jsx("div",{role:"group","aria-label":Ys(e,t),className:`docx-toolbar__group${e.className?` ${e.className}`:""}`,"data-toolbar-host-group":e.id,children:e.children})}gm.docxToolbarGroup=true;function Di(e){return e.hidden?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.children})}Di.docxToolbarSlot=true;var bm=Bt.createContext("bar");function yy(){return Bt.useContext(bm)}var Xs="review.addComment";function A2({className:e,hidden:t,icon:o,asChild:r,children:n}){let i=Bt.useContext(Lt),a=ne(),{isEnabled:l,reason:s}=Wl(a),c=pa();if(t||(i?.mounted??0)===0)return null;let d=Q(Xs),m=a(d?.labelKey??Xs),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Xs,disabled:!l,...l?{}:{"data-disabled":""},"aria-label":m,title:s??m,onMouseDown:U,onClick:()=>{i?.requestCommentDraft()&&c(false);}};return r?jsxRuntime.jsx(J,{...u,children:n}):jsxRuntime.jsx("button",{...u,children:o??n??re(d?.paths)})}var hm=Object.assign(A2,{docxSlot:Xs});var Cy=new Set;function Js(e){!bt()||Cy.has(e)||(Cy.add(e),console.warn(`[docx-editor] ${e}`));}function Ty(e,t,o){Js(`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 Ey(e,t){Js(`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 Sy(e){Js(`Toolbar.Group "${e}" uses the id of the contextual table group, so it is ignored. Give the group another id.`);}function Py(e,t){Js(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 xm=[{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 ec({className:e,hidden:t,asChild:o,children:r}){let{t:n}=L(),i=ne(),{execute:a,value:l,isEnabled:s,disabledReason:c}=gi("image.wrap"),[d,m]=Bt.useState(false),u=Bt.useRef(null),g=Bt.useRef(null),p=Bt.useRef(null),f=Bt.useId(),h=Bt.useMemo(()=>xm.find(T=>T.value===l)??xm[0],[l]),y=Q("image.wrap"),x=i(y?.labelKey??"formattingBar.imageWrap");Bt.useEffect(()=>{if(!d)return;let T=S=>{let k=u.current;k&&editor.isDomNode(S.target)&&k.contains(S.target)||m(false);},C=S=>{S.key==="Escape"&&(S.preventDefault(),m(false),g.current?.focus());},E=editor.hostDocumentOf(u.current);return E.addEventListener("mousedown",T,true),E.addEventListener("keydown",C),()=>{E.removeEventListener("mousedown",T,true),E.removeEventListener("keydown",C);}},[d]);let b=Bt.useCallback(T=>{m(false),a(T);},[a]);if(t)return null;let v=n("imageWrap.tooltipPrefix",{label:n(h.labelKey)}),P={type:"button",ref:g,className:`docx-toolbar__button docx-toolbar__image-wrap-trigger${e?` ${e}`:""}`,"data-slot":"image.wrap",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?f:void 0,"aria-label":x,title:c??v,onMouseDown:U,onClick:()=>m(T=>!T)};return jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsxRuntime.jsx(J,{...P,children:r}):jsxRuntime.jsx("button",{...P,children:r??re(y?.paths)}),d?jsxRuntime.jsx("div",{ref:p,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":n("imageWrap.menu.ariaLabel"),onMouseDown:T=>T.stopPropagation(),children:xm.map(T=>jsxRuntime.jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":l===T.value,...l===T.value?{"data-active":""}:{},onMouseDown:U,onClick:()=>b(T.value),children:n(T.labelKey)},T.value))}):null]})}ec.docxSlot="image.wrap";var Ri=Object.assign(ec,{docxSlot:"image.wrap"});var ma="table.insert";function Q2({className:e,hidden:t,icon:o,asChild:r,children:n}){let i=H(),{isEnabled:a,disabledReason:l}=oe(ma),s=ne(),[c,d]=Bt.useState(false),m=Bt.useRef(null),u=Bt.useRef(null),g=Bt.useRef(null),p=Bt.useId(),f=pa();Bt.useEffect(()=>{if(!(!c||!m.current))return editor.listenForOutsidePress({popup:m.current,close:()=>d(false)})},[c]),Bt.useEffect(()=>{c&&m.current?.querySelector('[role="gridcell"][tabindex="0"]')?.focus();},[c]);let h=c&&a;Bt.useLayoutEffect(()=>{let P=g.current,T=m.current,C=T?.ownerDocument.defaultView;if(!h||!P||!T||!C||T.closest(".docx-toolbar__more-panel"))return;let E=T.getBoundingClientRect(),S=editor.toolbarPopupLeft({anchorLeft:E.left,popupWidth:P.offsetWidth,viewportWidth:C.innerWidth});P.style.left=`${S-E.left}px`;},[h]);let y=Bt.useCallback(()=>{d(false),f(false);},[f]);if(t)return null;let x=Q(ma),b=s(x?.labelKey??ma),v={ref:u,type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":ma,disabled:!a,...a?{}:{"data-disabled":""},...h?{"data-active":""}:{},"aria-haspopup":"grid","aria-expanded":h,"aria-controls":h?p:void 0,"aria-label":b,title:l??b,onMouseDown:U,onClick:()=>{if(!c){d(true);return}d(false),i?.focus();},onKeyDown:P=>{P.key==="ArrowDown"&&(P.preventDefault(),d(true));}};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__table-insert",children:[r?jsxRuntime.jsx(J,{...v,children:n}):jsxRuntime.jsx("button",{...v,children:o??n??re(x?.paths)}),h?jsxRuntime.jsx("div",{ref:g,id:p,className:"docx-toolbar__menu docx-toolbar__table-insert-menu",onBlur:P=>{let T=P.relatedTarget;editor.isDomNode(T)&&!m.current?.contains(T)&&d(false);},onKeyDown:P=>{P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),d(false),u.current?.focus());},children:jsxRuntime.jsx(jl,{slot:ma,label:s("toolbar.insertTable"),onInserted:y})}):null]})}var Cm=Object.assign(Q2,{docxSlot:ma});function tt(e){return Object.assign(o=>jsxRuntime.jsx(Bo,{slotId:e,...o}),{docxSlot:e})}var wy=tt("history.undo"),Dy=tt("history.redo"),Ry=tt("text.bold"),My=tt("text.italic"),_y=tt("text.underline"),Iy=tt("text.strike"),Ny=tt("format.clear"),Fy=tt("script.super"),Ly=tt("script.sub"),Hy=tt("alignment.left"),Ay=tt("alignment.center"),Oy=tt("alignment.right"),By=tt("alignment.justify"),Wy=tt("direction.ltr"),Zy=tt("direction.rtl"),Ky=tt("list.bullet"),qy=tt("list.numbered"),Uy=tt("list.outdent"),zy=tt("list.indent");var $y=tt("review.comments");function o_({className:e,hidden:t,icon:o,asChild:r,children:n}){let{execute:i,isEnabled:a,disabledReason:l}=oe("text.link"),s=ne(),c=Yt();if(t)return null;let d=Q("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:U,onClick:()=>i()};return r?jsxRuntime.jsx(J,{...u,children:n}):jsxRuntime.jsx("button",{...u,children:o??n??re(d?.paths)})}var Tm=Object.assign(o_,{docxSlot:"text.link"});function r_({className:e,hidden:t}){let o=H(),{onSave:r}=Bt.useContext(Hr),n=ne();if(t)return null;let i=Q("file.save"),a=n(i?.labelKey??"file.save"),l=!o||!r;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:U,onClick:()=>r?.(),children:re(i?.paths)})}var Em=Object.assign(r_,{docxSlot:"file.save"});function Jr({className:e}){return jsxRuntime.jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}var i_=e=>({zoom:e.zoom,mode:e.zoomMode}),l_=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,Gy={type:"fixed"};function Sm(){let e=H(),{zoom:t,mode:o}=W(i_,l_),r=Bt.useCallback(i=>{e?.setZoom(i);},[e]),n=Bt.useCallback(i=>{e?.setZoomMode(i);},[e]);return Bt.useMemo(()=>{let i=o??Gy,a=Si(t,"out"),l=Si(t,"in");return {zoom:t,mode:i,isFit:i.type==="fit",setZoom:r,setMode:n,fitToWidth:()=>n(editor.FIT_WIDTH_ZOOM_MODE),auto:()=>n("auto"),reset:()=>{n(Gy),r(1);},zoomIn:()=>l!==null&&r(l),zoomOut:()=>a!==null&&r(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:qs}},[e,t,o,r,n])}var Ii=2,Ni=3276,_i=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],u_=e=>e.formatting?.fontSizePt??null;function Xy(e,t,o){for(let r of t)if(r>e)return r;return Math.min(e+1,o)}function Jy(e,t,o){for(let r=t.length-1;r>=0;r-=1)if(t[r]<e)return t[r];return Math.max(e-1,o)}function tx(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:U,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:U,onClick:e.onIncrease,children:"+"})]})}function p_(e){let t=e.trim().replace(/pt$/i,"").trim();if(t==="")return null;let o=Number(t);if(!Number.isFinite(o))return null;let r=Math.round(o*2);return r<Ii||r>Ni?null:r}function m_({className:e,hidden:t}){let o=H(),r=W(u_),{isEnabled:n,disabledReason:i}=oe("font.size"),a=ne(),[l,s]=Bt.useState(false),[c,d]=Bt.useState(null),m=Bt.useRef(null);Oo(m,l,()=>s(false));let u=Bt.useRef(null),g=Bt.useId(),p=Bt.useCallback(T=>{if(!o)return;let C=editor.commandForSlotValue("font.size",T);C&&o.can(C).ok&&o.exec(C);},[o]),f=Bt.useCallback(T=>{p(Math.min(Ni,Math.max(Ii,Math.round(T*2))));},[p]),h=Bt.useCallback(T=>{s(false),d(null),u.current?.blur(),T&&o?.focus();},[o]);if(Bt.useEffect(()=>{if(l)return editor.listenForOutsidePress({popup:m.current,close:()=>{s(false),d(null);}})},[l]),t)return null;let y=n&&r!==null,x=r===null?"\u2014":String(Math.round(r*2)/2),b=c??x,v=r===null?null:Math.round(r*2)/2,P=()=>{if(c===null)return;let T=p_(c);T!==null&&p(T);};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsxRuntime.jsx(tx,{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:b,disabled:!n,role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-label":a("fontSize.label"),"aria-controls":l?g:void 0,autoComplete:"off",onChange:T=>{d(T.target.value),s(true);},onFocus:T=>{T.target.select(),s(true);},onClick:()=>s(true),onKeyDown:T=>{T.key==="Enter"?(T.preventDefault(),P(),h(true)):T.key==="Escape"?(T.preventDefault(),h(true)):(T.key==="ArrowDown"||T.key==="ArrowUp")&&(T.preventDefault(),s(true),r!==null&&f(T.key==="ArrowDown"?Jy(r,_i,Ii/2):Xy(r,_i,Ni/2)));},onBlur:()=>{P(),d(null);}}),canDecrease:y&&Math.round(r*2)>Ii,canIncrease:y&&Math.round(r*2)<Ni,onDecrease:()=>f(Jy(r??0,_i,Ii/2)),onIncrease:()=>f(Xy(r??0,_i,Ni/2))}),l&&n?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox",tabIndex:0,"aria-label":a("fontSize.listLabel"),id:g,children:_i.map(T=>{let C=v===T;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>{f(T),h(true);},children:T},T)})}):null]})}var wm=Object.assign(m_,{docxSlot:"font.size"});function f_({className:e,hidden:t}){let o=H(),{zoom:r,isFit:n,mode:i,setZoom:a,setMode:l,zoomIn:s,zoomOut:c,canZoomIn:d,canZoomOut:m,levels:u}=Sm(),g=ne(),[p,f]=Bt.useState(false),h=Bt.useRef(null);Oo(h,p,()=>f(false)),Bt.useEffect(()=>{if(p)return editor.listenForOutsidePress({popup:h.current,close:()=>f(false)})},[p]);let y=Bt.useCallback(T=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),a(T);},[a]),x=Bt.useCallback(T=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),l(T==="auto"?"auto":editor.FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let b=`${Math.round(r*100)}%`,v=editor.sameZoomMode(i,editor.AUTO_ZOOM_MODE),P=editor.sameZoomMode(i,editor.FIT_WIDTH_ZOOM_MODE);return jsxRuntime.jsxs("span",{ref:h,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsxRuntime.jsx(tx,{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")}: ${b}`,onMouseDown:U,onClick:()=>f(T=>!T),children:[b,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":v,...v?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>x("auto"),children:g("zoom.automatic")}),jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":P,...P?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>x("fit-width"),children:g("zoom.fitWidth")}),jsxRuntime.jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(T=>{let C=!n&&Math.abs(T-r)<.001;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>y(T),children:`${Math.round(T*100)}%`},T)})]}):null]})}var Dm=Object.assign(f_,{docxSlot:"zoom.level"});function Qr(e,t,o,r=false){let n=ke(),i=Bt.useRef(n);i.current=n,Bt.useEffect(()=>{e&&r&&t(false);},[e,r,t]),Bt.useEffect(()=>{let a=o.current;if(!e||r||!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,r,t,o]);}var ax=10,ix=0,T_=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),E_=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function S_({className:e,hidden:t}){let o=H(),r=W(T_,E_),{isEnabled:n,disabledReason:i}=oe("list.lineSpacing"),a=oe("paragraph.dialog"),l=cy(),s=ne(),{lang:c}=L(),[d,m]=Bt.useState(false),u=Bt.useRef(null),g=Bt.useRef(null);Qr(d,m,u,t);let p=Bt.useCallback(v=>{m(false),!(!o||!v.command)&&o.can(v.command).ok&&o.exec(v.command);},[o]),f=Bt.useCallback((v,P)=>{if(m(false),!o)return;let T={type:"setParagraphSpacing",[v]:P};o.can(T).ok&&o.exec(T);},[o]);if(t)return null;let h=Q("list.lineSpacing"),y=(r.spaceBeforePt??0)>0,x=(r.spaceAfterPt??0)>0,b=editor.lineSpacingMenuRows(r.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:!n,...n?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-label":s("lineSpacing.label"),title:i??s("lineSpacing.label"),onMouseDown:U,onClick:()=>m(v=>!v),children:[re(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),d&&n?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[b.map(v=>{let P=v.selected;return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":P,...P?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>p(v),children:[editor.lineSpacingMenuRowLabel(v,s,c),P?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]},`${v.spacing.rule}:${v.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:U,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:U,onClick:()=>f("beforePt",y?ix:ax),children:s(y?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>f("afterPt",x?ix:ax),children:s(x?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var Rm=Object.assign(S_,{docxSlot:"list.lineSpacing"});var w_=["alignment.left","alignment.center","alignment.right","alignment.justify"];function D_({className:e,hidden:t}){let o=oe("alignment.left"),r=oe("alignment.center"),n=oe("alignment.right"),i=oe("alignment.justify"),a=ne(),[l,s]=Bt.useState(false),c=Bt.useRef(null);if(Qr(l,s,c,t),t)return null;let d=[o,r,n,i],m=w_.map((f,h)=>({slot:f,control:Q(f),state:d[h]})),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:U,onClick:()=>s(f=>!f),children:[re(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 h=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":h,title:f.state.disabledReason??h,onMouseDown:U,onClick:()=>{f.state.execute(),s(false);},children:re(f.control?.paths)},f.slot)})}):null]})}var rc=Object.assign(D_,{docxSlot:"alignment"});function _m(e){let{label:t,icon:o,active:r,disabled:n,disabledReason:i,onSelect:a,asChild:l,className:s,children:c}=e,d=yy(),m=pa();if(d==="panel"&&!l)return jsxRuntime.jsxs("button",{type:"button",className:`docx-toolbar__more-command${s?` ${s}`:""}`,disabled:n,...r?{"data-active":""}:{},...r!==void 0?{"aria-pressed":r}:{},...n&&i?{title:i}:{},onMouseDown:g=>U(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:n,...r?{"data-active":""}:{},...n?{"data-disabled":""}:{},...r!==void 0?{"aria-pressed":r}:{},"aria-label":t,title:n?i??t:t,onMouseDown:g=>U(g),onClick:n?void 0:a};return l?jsxRuntime.jsx(J,{...u,children:c}):jsxRuntime.jsx("button",{...u,children:o??c})}var H_=Object.freeze([]),A_=e=>e.formatting?.fontFamily??null,O_=e=>e;function ic(){let e=H(),t=W(A_),o=W(O_),r=Bt.useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():H_,[e,o]),{isEnabled:n}=oe("font.family"),i=Bt.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return Bt.useMemo(()=>({value:t,setValue:i,options:r,isEnabled:n}),[t,i,r,n])}var dx=Bt.createContext(null);function Nm(){return Bt.useContext(dx)}function Fm({asChild:e,className:t,children:o}){let r=Nm(),n=ne();if(!r)return null;let i=n(Q("font.family")?.labelKey??"font.family"),a={onClick:()=>r.setOpen(!r.open),onMouseDown:U,disabled:!r.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...r.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":r.open,"aria-label":o!==void 0?void 0:`${i}: ${r.value??"\u2014"}`,title:i},l=o??jsxRuntime.jsx("span",{children:r.value??"\u2014"});return e?jsxRuntime.jsx(J,{...a,children:l}):jsxRuntime.jsx("button",{type:"button",...a,children:l})}Fm.docxToolbarPart=true;var B_=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"]]),W_=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function ux({asChild:e,className:t,children:o}){let r=Nm(),n=ne(),[i,a]=Bt.useState("");if(Bt.useEffect(()=>{r?.open||a("");},[r?.open]),!r||!r.open)return null;let l={role:"listbox",tabIndex:0,"aria-label":n("font.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`},s;return o!==void 0?s=o:s=W_.map(d=>({...d,fonts:r.options.filter(m=>m.toLowerCase().includes(i.toLowerCase())&&(B_.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:n(d.labelKey)}):null,d.fonts.map(u=>jsxRuntime.jsx(px,{value:u},u))]},d.category)),e?jsxRuntime.jsx(J,{...l,children:s}):o!==void 0?jsxRuntime.jsx("div",{...l,children:s}):jsxRuntime.jsxs("div",{className:l.className,children:[jsxRuntime.jsx("input",{type:"search",className:"docx-toolbar__font-search","aria-label":n("font.search"),placeholder:n("font.search"),value:i,onChange:c=>a(c.target.value)}),jsxRuntime.jsx("div",{role:"listbox",tabIndex:0,"aria-label":n("font.selectAriaLabel"),className:"docx-toolbar__font-options",children:s})]})}function px({value:e,asChild:t,className:o,children:r}){let n=H(),i=Nm();if(!i)return null;let a=i.value===e,l={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:U,onClick:()=>{i.setValue(e),i.setOpen(false),n?.focus();},className:`docx-toolbar__font-family-item${o?` ${o}`:""}`},s=r??jsxRuntime.jsx("span",{style:{fontFamily:e},children:e});return t?jsxRuntime.jsx(J,{...l,children:s}):jsxRuntime.jsxs("button",{type:"button",...l,children:[s,a?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function Z_({hidden:e,asChild:t,className:o,children:r}){let n=ic(),[i,a]=Bt.useState(false),l=Bt.useRef(null);Oo(l,i,()=>a(false)),Bt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=Bt.useMemo(()=>({...n,open:i,setOpen:a}),[n,i]);if(e)return null;let c={className:`docx-toolbar__font-family${o?` ${o}`:""}`,"data-slot":"font.family"},d=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Fm,{}),jsxRuntime.jsx(ux,{})]});return jsxRuntime.jsx(dx.Provider,{value:s,children:t?jsxRuntime.jsx(J,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Lm=Object.assign(Z_,{docxSlot:"font.family",Trigger:Fm,Content:ux,Item:px});var q_={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},U_=new Set(["Title","Heading1","Heading2","Heading3"]),z_={Subtitle:"666666"},$_="#4a6c8c";function mx(e){let t=q_[e.styleId],r={fontSize:t?`${t}px`:`${Math.min(Math.max(e.fontSize?e.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(e.bold??U_.has(e.styleId))&&(r.fontWeight="bold"),e.italic&&(r.fontStyle="italic");let n=e.color??z_[e.styleId];return n?r.color=`#${n}`:e.styleId.startsWith("Heading")&&(r.color=$_),r}var fx=/^heading ([1-9])$/;function Hm(e,t){let o=e||t,r=fx.exec(o);return r?`Heading ${r[1]}`:o}var V_=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 lc(e){let t=e.toLowerCase(),o=V_.get(t);if(o)return {key:o};let r=fx.exec(t);return r?{key:"styles.headingLevel",vars:{level:Number(r[1])}}:null}function gx(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:Hm(t.name,t.styleId),priority:99}))}function oI(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 rI=Object.freeze([]),nI=e=>e.formatting?.styleId??null,aI=e=>e;function sc(){let e=H(),t=W(nI),o=W(aI),{t:r}=L(),n=Bt.useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(l=>l.type==="paragraph").map(l=>{let s=lc(l.name);return {styleId:l.styleId,name:s?r(s.key,s.vars):Hm(l.name,l.styleId),preview:l.preview}}):rI,[e,o,r]),{isEnabled:i}=oe("styles.style"),a=Bt.useCallback(l=>{if(!e)return;let s=editor.commandForSlotValue("styles.style",l);s&&e.can(s).ok&&e.exec(s);},[e]);return Bt.useMemo(()=>({value:t,setValue:a,options:n,isEnabled:i}),[t,a,n,i])}var bx=Bt.createContext(null);function Om(){return Bt.useContext(bx)}function Bm({asChild:e,className:t,children:o}){let r=Om(),n=ne();if(!r)return null;let i=Q("styles.style"),a=n(i?.labelKey??"styles.style"),l={onClick:()=>r.setOpen(!r.open),onMouseDown:U,disabled:!r.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...r.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":r.open,title:a},s=r.options.find(d=>d.styleId===r.value),c=o??(r.value===null?jsxRuntime.jsx("span",{children:i?.valueKey?n(i.valueKey):"\u2014"}):jsxRuntime.jsx("span",{children:s?.name??r.value}));return e?jsxRuntime.jsx(J,{...l,children:c}):jsxRuntime.jsx("button",{type:"button",...l,children:c})}Bm.docxToolbarPart=true;function hx({asChild:e,className:t,children:o}){let r=ne(),n=Om();if(!n||!n.open)return null;let i={role:"listbox",tabIndex:0,"aria-label":r("styles.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`},a=o??n.options.map(l=>jsxRuntime.jsx(yx,{value:l.styleId},l.styleId));return e?jsxRuntime.jsx(J,{...i,children:a}):jsxRuntime.jsx("div",{...i,children:a})}function yx({value:e,asChild:t,className:o,children:r}){let n=H(),i=Om();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:U,onClick:()=>{i.setValue(e),i.setOpen(false),n?.focus();},className:`docx-toolbar__style-item${o?` ${o}`:""}`},c=r??jsxRuntime.jsx("span",{style:l?oI(l.preview):void 0,children:l?.name??e});return t?jsxRuntime.jsx(J,{...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 iI({hidden:e,asChild:t,className:o,children:r}){let n=sc(),[i,a]=Bt.useState(false),l=Bt.useRef(null);Oo(l,i,()=>a(false)),Bt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=Bt.useMemo(()=>({...n,open:i,setOpen:a}),[n,i]);if(e)return null;let c={className:`docx-toolbar__style${o?` ${o}`:""}`,"data-slot":"styles.style"},d=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bm,{}),jsxRuntime.jsx(hx,{})]});return jsxRuntime.jsx(bx.Provider,{value:s,children:t?jsxRuntime.jsx(J,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Wm=Object.assign(iI,{docxSlot:"styles.style",Trigger:Bm,Content:hx,Item:yx});function vx(e,t){let o=e;return Object.assign(({className:n,hidden:i,icon:a,asChild:l,children:s})=>{let{isEnabled:c,disabledReason:d}=oe(o),m=vo(),u=t==="showAll"?m.showAll:m.formFill,g=ne();if(i)return null;let p=Q(o),f=g(p?.labelKey??e),h={type:"button",className:`docx-toolbar__button${n?` ${n}`:""}`,"data-slot":e,disabled:!c,...c?{}:{"data-disabled":""},...u?{"data-active":""}:{},"aria-pressed":u,"aria-label":f,title:d??f,onMouseDown:U,onClick:()=>{t==="showAll"?m.toggleShowAll():m.toggleFormFill();}};return l?jsxRuntime.jsx(J,{...h,children:s}):jsxRuntime.jsx("button",{...h,children:a??s??re(p?.paths)})},{docxSlot:o})}function sI({className:e,hidden:t,icon:o,asChild:r,children:n}){let i=wt.inspector,{isEnabled:a,disabledReason:l}=oe(i),{inspectorOpen:s,openInspector:c}=vo(),d=ne();if(t)return null;let m=Q(i),u=d(m?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":wt.inspector,disabled:!a,...a?{}:{"data-disabled":""},...s?{"data-active":""}:{},"aria-pressed":s,"aria-label":u,title:l??u,onMouseDown:U,onClick:()=>c()};return r?jsxRuntime.jsx(J,{...g,children:n}):jsxRuntime.jsx("button",{...g,children:o??n??re(m?.paths)})}function cI({className:e,hidden:t,icon:o,asChild:r,children:n}){let{canRemove:i,removeDisabledReason:a,remove:l}=vo(),s=ne();if(t)return null;let c=wt.remove,d=Q(c),m=s(d?.labelKey??"contentControl.remove"),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":wt.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":m,title:a??m,onMouseDown:U,onClick:()=>{l();}};return r?jsxRuntime.jsx(J,{...u,children:n}):jsxRuntime.jsx("button",{...u,children:o??n??re(d?.paths)})}var cc=vx(wt.showAll,"showAll"),dc=vx(wt.formFill,"formFill"),uc=Object.assign(cI,{docxSlot:wt.remove}),pc=Object.assign(sI,{docxSlot:wt.inspector}),Cx={[wt.showAll]:cc,[wt.formFill]:dc,[wt.inspector]:pc,[wt.remove]:uc};var ga=Object.assign(e=>jsxRuntime.jsx(Bo,{slotId:"table.mergeCells",...e}),{docxSlot:"table.mergeCells"});function dI({icon:e,className:t,children:o,hidden:r}){let{isEnabled:n,disabledReason:i}=oe("table.splitCell"),a=ko(),l=ne();if(r||!a)return null;let s=l(Q("table.splitCell")?.labelKey??"table.splitCell");return jsxRuntime.jsx("button",{type:"button","data-slot":"table.splitCell",className:`docx-toolbar__button${t?` ${t}`:""}`,disabled:!n,...n?{}:{"data-disabled":""},"aria-label":s,"aria-haspopup":"dialog",title:i??s,onMouseDown:U,onClick:c=>a.open("splitCell",c.currentTarget),children:e??o??re(Q("table.splitCell")?.paths)})}var ba=Object.assign(dI,{docxSlot:"table.splitCell"});function Zm(e,t){let o=H(),r=Bt.useRef(t);r.current=t,Bt.useEffect(()=>{if(!o)return;let n=((...i)=>{r.current(...i);});return o.on(e,n)},[o,e]);}var hI=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],qm=Bt.createContext(null);function Rx(){let e=Bt.useContext(qm);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function xI(e,t){let o=t.table,n=(e?.getSelectedTable()??null)?.blockId??"",i=o?`${n}|${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 vI(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function CI(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var wx={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function TI(e,t){let o={};for(let r of hI){let n=editor.tableChromeToolbarState(e,r,t);o[r]={enabled:n.enabled,disabledReason:n.disabledReason};}return o}function Um({children:e}){let t=H(),[o,r]=Bt.useState(editor.DEFAULT_TABLE_CHROME_DRAFT),[n,i]=Bt.useState(wx);Bt.useEffect(()=>(()=>{}),[]);let a=W(Bt.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:""}),[]),vI,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=Bt.useCallback(()=>{if(!t){i(wx);return}let u=xI(t,t.snapshot());i(g=>CI(g,u)?g:u);},[t]);Bt.useEffect(()=>{l();},[l,a]),Zm("selectionChange",Bt.useCallback(()=>{l();},[l]));let s=n.tableKey!=="",c=Bt.useMemo(()=>t?TI(t,o):{},[t,o,n.tableKey,n.selectionKey,n.cellSelectionKey,n.editable,n.editingMode]),d=Bt.useCallback((u,g)=>{if(!t)return;let{result:p,nextDraft:f}=editor.runTableChromeCommand(t,u,g,o);p.ok&&f&&r(f);},[t,o]),m=Bt.useMemo(()=>({visible:s,draft:o,setDraft:r,slotState:u=>c[u]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[s,o,c,d]);return jsxRuntime.jsx(qm.Provider,{value:m,children:e})}function EI(){let e=Bt.useContext(qm);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function fc(e){let t=EI(),o=t.slotState(e);return Bt.useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:r=>t.apply(e,r)}),[t,e,o])}function bc(e){(editor.editorInstanceScope(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function hc({enabled:e,disabledReason:t,ariaLabel:o}){let{t:r}=L(),n=i18n.localizeDisabledReason(t,r),i=Bt.useId(),a=!e&&n?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:U,"aria-label":o,...a?{"aria-describedby":a}:{},...n?{title:n}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:a&&n?jsxRuntime.jsx("span",{id:i,className:"docx-editor-sr-only",children:n}):null}}var DI='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function Ix(e,t,o,r){Bt.useEffect(()=>{if(!e)return;let n=o.current,i=r.current;if(!n)return;let a=()=>[...n.querySelectorAll(DI)].filter(c=>c.closest('[role="menu"]')===n);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(),Qt(d,editor.hostDocumentOf(n).activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),Qt(d,editor.hostDocumentOf(n).activeElement,-1);return}if(c.key==="Home"){c.preventDefault(),eo(d,"first");return}if(c.key==="End"){c.preventDefault(),eo(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 n.addEventListener("keydown",s),()=>n.removeEventListener("keydown",s)},[e,t,o,r]);}function Nx(e,t,o,r){Bt.useEffect(()=>{if(!e)return;let n=o.current,i=r.current;if(!n)return;let a=()=>[...n.querySelectorAll('button:not([aria-disabled="true"])')].filter(s=>s.closest('[role="dialog"]')===n);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 n.addEventListener("keydown",l),()=>n.removeEventListener("keydown",l)},[e,t,o,r]);}function Bx(e,t,o){if(e)return r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),o(!t));}}function FI(e){return re(editor.tableChromeIconPaths(e))}function Wx(){return Bt.createContext(null)}function $o(e){let t=Bt.useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function $m(e,t,o){let r=Wx();function n({hidden:l,asChild:s,className:c,children:d}){let{visible:m,enabled:u,disabledReason:g,draft:p,apply:f}=fc(e),[h,y]=Bt.useState(false),x=Bt.useRef(null),b=Bt.useRef(null);Qr(h,y,x,l||!m);let v=Bt.useMemo(()=>({open:h,setOpen:y,enabled:u,disabledReason:g,apply:f,draft:p,triggerRef:b}),[h,u,g,f,p]);if(l||!m)return null;let P={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},T=d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(i,{}),jsxRuntime.jsx(a,{})]});return jsxRuntime.jsx(r.Provider,{value:v,children:s?jsxRuntime.jsx(J,{...P,ref:x,children:T}):jsxRuntime.jsx("div",{ref:x,...P,children:T})})}function i({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,disabledReason:g,triggerRef:p}=$o(r),f=ne(),h=Q(e),y=f(h?.labelKey??o),{shared:x,reasonNode:b}=hc({enabled:u,disabledReason:g,ariaLabel:y}),v={...x,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:Bx(u,d,m)}:{}},P=c??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[re(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(J,{...v,children:P}),b]}):jsxRuntime.jsxs("button",{...v,children:[P,b]})}i.docxToolbarPart=true;function a({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,triggerRef:g}=$o(r),p=ne(),f=Bt.useRef(null);if(Ix(d&&u,m,f,g),!d||!u)return null;let h=Q(e),y=p(h?.labelKey??o),x={ref:f,role:"menu","aria-label":y,className:`docx-table-chrome__panel${s?` ${s}`:""}`,onMouseDown:U};return l?jsxRuntime.jsx(J,{...x,children:c}):jsxRuntime.jsx("div",{...x,children:c})}return {Root:n,Trigger:i,Content:a,Ctx:r}}var Hi=$m("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function Zx({value:e,asChild:t,className:o,children:r}){let{apply:n,setOpen:i,draft:a}=$o(Hi.Ctx),l=ne(),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:U,onClick:()=>{i(false),n(s.value);}},m=r??FI(s.icon);return t?jsxRuntime.jsx(J,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function Kx(e){let{children:t}=e;return jsxRuntime.jsx(Hi.Content,{...e,children:t??jsxRuntime.jsx("div",{className:"docx-table-chrome__target-grid",children:editor.TABLE_BORDER_TARGET_OPTIONS.map(o=>jsxRuntime.jsx(Zx,{value:o.value},o.value))})})}function LI(e){let{children:t}=e,o=t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Hi.Trigger,{}),jsxRuntime.jsx(Kx,{})]});return jsxRuntime.jsx(Hi.Root,{...e,children:o})}var Zi=Object.assign(LI,{docxSlot:"table.borderTarget",Trigger:Hi.Trigger,Content:Kx,Item:Zx}),Ai=$m("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function qx({value:e,asChild:t,className:o,children:r}){let{apply:n,setOpen:i,draft:a}=$o(Ai.Ctx),l=ne(),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:U,onClick:()=>{i(false),n(s.value);}},m=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:`docx-table-line ${s.previewClass}`,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l(s.labelKey)})]});return t?jsxRuntime.jsx(J,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function Ux(e){let{children:t}=e;return jsxRuntime.jsx(Ai.Content,{...e,children:t??editor.TABLE_BORDER_STYLE_OPTIONS.map(o=>jsxRuntime.jsx(qx,{value:o.value},o.value))})}function HI(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ai.Trigger,{}),jsxRuntime.jsx(Ux,{})]});return jsxRuntime.jsx(Ai.Root,{...e,children:t})}var Ki=Object.assign(HI,{docxSlot:"table.borderStyle",Trigger:Ai.Trigger,Content:Ux,Item:qx}),Oi=$m("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function zx({value:e,asChild:t,className:o,children:r}){let{apply:n,setOpen:i,draft:a}=$o(Oi.Ctx),l=ne(),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:U,onClick:()=>{i(false),n(c.size);}},u=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"docx-table-line docx-table-line--single",style:{height:`${c.previewThickness}px`},"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l(c.labelKey)})]});return t?jsxRuntime.jsx(J,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}function $x(e){let{children:t}=e;return jsxRuntime.jsx(Oi.Content,{...e,children:t??editor.TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsxRuntime.jsx(zx,{value:String(o.size)},o.size))})}function AI(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Oi.Trigger,{}),jsxRuntime.jsx($x,{})]});return jsxRuntime.jsx(Oi.Root,{...e,children:t})}var qi=Object.assign(AI,{docxSlot:"table.borderWidth",Trigger:Oi.Trigger,Content:$x,Item:zx});function Vx(e,t,o){let r=o?.defaultHex??"FF0000",n=Wx();function i({hidden:d,asChild:m,className:u,children:g}){let{visible:p,enabled:f,disabledReason:h,draft:y,apply:x}=fc(e),[b,v]=Bt.useState(false),[P,T]=Bt.useState(r),C=Bt.useRef(null),E=Bt.useRef(null);Qr(b,v,C,d||!p);let S=Bt.useMemo(()=>({open:b,setOpen:v,enabled:f,disabledReason:h,apply:x,draft:y,triggerRef:E,lastHex:P,setLastHex:T}),[b,f,h,x,y,P]);if(d||!p)return null;let k={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(n.Provider,{value:S,children:m?jsxRuntime.jsx(J,{...k,ref:C,children:w}):jsxRuntime.jsx("div",{ref:C,...k,children:w})})}function a({asChild:d,className:m,children:u}){let{enabled:g,disabledReason:p,apply:f,draft:h,lastHex:y}=$o(n),x=ne(),b=Q(e),v=x(b?.labelKey??t),{shared:P,reasonNode:T}=hc({enabled:g,disabledReason:p,ariaLabel:v}),C=e==="table.borderColor"&&h.spec.color.kind==="hex"?h.spec.color.value:y??r,E={...P,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:[re(b?.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(J,{...E,children:S}),T]}):jsxRuntime.jsxs("button",{...E,children:[S,T]})}a.docxToolbarPart=true;function l({asChild:d,className:m,children:u}){let{open:g,setOpen:p,enabled:f,disabledReason:h,triggerRef:y}=$o(n),x=ne(),b=Q(e),v=x(b?.labelKey??t),{shared:P,reasonNode:T}=hc({enabled:f,disabledReason:h,ariaLabel:v}),C={...P,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:Bx(f,g,p)}:{}},E=u??"\u25BE";return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(J,{...C,children:E}),T]}):jsxRuntime.jsxs("button",{...C,children:[E,T]})}l.docxToolbarPart=true;function s({asChild:d,className:m,children:u,clearFill:g}){let{open:p,setOpen:f,enabled:h,apply:y,draft:x,triggerRef:b,lastHex:v,setLastHex:P}=$o(n),T=ne(),C=Bt.useRef(null);if(Nx(p&&h,f,C,b),!p||!h)return null;let E=T(t),S=e==="table.borderColor"&&x.spec.color.kind==="hex"?x.spec.color.value:v??r,k={ref:C,role:"dialog","aria-label":E,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${m?` ${m}`:""}`,onMouseDown:U},w=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g?jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:U,onClick:()=>{f(false),y(null),bc(b.current);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),T("table.clearCellFill")]}):null,jsxRuntime.jsx(Zd,{apply:I=>{f(false),P?.(I),y({kind:"hex",value:I}),bc(b.current);},current:S})]});return d?jsxRuntime.jsx(J,{...k,children:w}):jsxRuntime.jsx("div",{...k,children:w})}function c({value:d,css:m,labelKey:u,asChild:g,className:p,children:f}){let{apply:h,setOpen:y,setLastHex:x,triggerRef:b}=$o(n),v=ne(),P=m??`#${d.toLowerCase()}`,T=u?v(u):d,C={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:P},"data-value":d,"aria-label":T,title:T,onMouseDown:U,onClick:()=>{y(false),x?.(d),h({kind:"hex",value:d}),bc(b.current);}};return g?jsxRuntime.jsx(J,{...C,children:f}):jsxRuntime.jsx("button",{...C,children:f})}return {Root:i,Main:a,Trigger:l,Content:s,Item:c,Ctx:n}}var Bi=Vx("table.borderColor","table.borderColor",{defaultHex:"000000"});function OI(e){return jsxRuntime.jsx(Bi.Content,{...e,clearFill:false})}function BI(e){return jsxRuntime.jsx(Bi.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function WI(e){return jsxRuntime.jsx(Bi.Root,{...e})}var Ui=Object.assign(WI,{docxSlot:"table.borderColor",Trigger:Bi.Trigger,Content:OI,Item:BI,Main:Bi.Main}),Wi=Vx("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function ZI(e){return jsxRuntime.jsx(Wi.Content,{...e,clearFill:true})}function KI(e){return jsxRuntime.jsx(Wi.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function qI(e){return jsxRuntime.jsx(Wi.Root,{...e})}var zi=Object.assign(qI,{docxSlot:"table.cellFill",Trigger:Wi.Trigger,Content:ZI,Item:KI,Main:Wi.Main});function Gx({overrides:e=new Map,separator:t=true}){return Rx()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx(Jr,{}):null,[Zi,Ui,Ki,qi,zi].map(n=>{let i=e.get(n.docxSlot);return i?jsxRuntime.jsx(Bt.Fragment,{children:i},n.docxSlot):jsxRuntime.jsx(n,{},n.docxSlot)}),[ga,ba].map(n=>{let i=e.get(n.docxSlot);return i?jsxRuntime.jsx(Bt.Fragment,{children:i},n.docxSlot):jsxRuntime.jsx(n,{},n.docxSlot)})]}):null}function jx(){let e=ne(),{draft:t}=fc("table.borderTarget");return e(editor.tableChromeLabelKeyForTarget(t.activeTarget))}var Gm=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill","table.mergeCells","table.splitCell"],on="contextual-table",jm={"zoom.level":Dm,"styles.style":Wm,"font.family":Lm,"font.size":wm,"text.color":Kd,"text.highlight":qd,"text.link":Tm,"list.lineSpacing":Rm,"review.editingMode":$s,"review.authors":Gs,"file.save":Em,...Cx,"table.borderTarget":Zi,"table.borderColor":Ui,"table.borderStyle":Ki,"table.borderWidth":qi,"table.cellFill":zi,"table.splitCell":ba,"image.insert":Ya,"image.properties":ia,"image.wrap":Ri,"image.altText":bi},yc={id:on,labelKey:"formattingBar.groups.table",entries:Gm.map(e=>({slot:e,Part:e==="table.mergeCells"?ga:jm[e]}))},Yx=new Map;function QI(e){let t=Yx.get(e);return t||(t=o=>jsxRuntime.jsx(Bo,{slotId:e,...o}),Yx.set(e,t)),t}function e8(e,t){return editor.formattingBarChromeGroups(e,{direction:t}).map(o=>o.id==="alignment"?{id:o.id,labelKey:o.labelKey,entries:[{slot:"alignment",Part:rc}]}:{id:o.id,labelKey:o.labelKey,entries:o.controls.map(r=>{let n=editor.chromeSlotId(o,r);return {slot:n,Part:jm[n]??QI(n)}})})}var t8=e=>e.image,o8=e=>e.isLoading||e.isOpening===true,r8=e=>e.table!==null;function n8(e){return e==="alignment"||e in jm}function Cc(e){let t=Mn(e,Cc);if(t!==null)return t;if(!Bt.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 r=e.props.slotId;return typeof r=="string"?r:null}if(o.docxToolbarPart===true){let r=e.props,n=r.slotId??r.slot;if(typeof n=="string")return n}return null}function Vm(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(Vm);let t=Cc(e);return t!=null&&Gm.includes(t)?true:Bt.isValidElement(e)?Bt.Children.toArray(e.props.children).some(Vm):false}function a8(e,t){return t?true:Bt.Children.toArray(e).some(Vm)}function i8(e){let t=qt(),{className:o,t:r,onSave:n,preset:i=true,overflow:a=true,children:l}=e,s=Bt.useMemo(()=>({t:r,onSave:n}),[r,n]),c=_l(r),d=W(t8),m=W(o8),u=W(r8),g=it(),p=g==="rtl",f=Bt.useMemo(()=>e8(d,p),[d,p]),h=Bt.useMemo(()=>new Set(f.flatMap(S=>S.entries.map(k=>k.slot))),[f]),y=Bt.useMemo(()=>i?hy(l,Cc,S=>h.has(S),S=>Gm.includes(S)):null,[i,l,h]),x=Bt.useMemo(()=>y?l8(f,y):[],[f,y]),b=Bt.useMemo(()=>[...x.filter(S=>!S.pinned).map(S=>({id:S.id,items:Xx(S,y?.overrides)})),...u?[{id:on,items:[on]}]:[]],[x,y,u]),v=Bt.useMemo(()=>{let S=new Map;for(let k of x)k.priority!==void 0&&S.set(k.id,k.priority);return editor.collapseOrder(b.map(k=>k.id),editor.TOOLBAR_COLLAPSE_ORDER,S)},[x,b]),P=i&&a,{attach:T,overflow:C}=Cu(P,b,v),E;if(!y)E=l;else {let{overrides:S,tableOverrides:k,appended:w}=y,I=R=>{let z=S.get(R.slot);if(z)return z;let V=R.Part;return jsxRuntime.jsx(V,{})},O=R=>{let z=k.get(R.slot);if(z)return z;let V=R.Part;return jsxRuntime.jsx(V,{})},N=[],B=[],F=0;for(let R of x){let z=Xx(R,S),V=new Map(R.entries.map(q=>[q.slot,q])),ee=R.pinned?z.length:editor.toolbarShownCount(C,R.id,z.length),Y=z.slice(ee);if(Y.length>0){let q=Y.flatMap(ce=>{let A=V.get(ce);if(!A)return [];let _=Jx(A,S,c,R.labelKey,I);return _===null?[]:[jsxRuntime.jsx(Bt.Fragment,{children:_},A.slot)]}),G=editor.toolbarHostPanelShown(R.extras.length>0,Y)?c8(R):null;G!==null&&q.push(jsxRuntime.jsx(Bt.Fragment,{children:G},"host")),q.length>0&&B.push({id:R.id,labelKey:R.labelKey,...R.heading?{label:Ys(R.heading,c)}:{},children:q});}ee!==0&&(F>0&&N.push(jsxRuntime.jsx(Jr,{},`separator-${R.id}`)),F+=1,N.push(jsxRuntime.jsx("div",{className:`docx-toolbar__group${R.className?` ${R.className}`:""}`,...R.heading?{role:"group","aria-label":Ys(R.heading,c)}:{},...R.pinned?{[Fn]:""}:{[Nn]:R.id},children:z.slice(0,ee).map(q=>{let G=V.get(q);return jsxRuntime.jsx("div",{className:"docx-toolbar__item",[xb]:q,children:G?I(G):R.extras},q)})},R.id)));}let D=C.has(on);if(u&&D){let R=yc.entries.flatMap(z=>{let V=Jx(z,k,c,yc.labelKey,O);return V===null?[]:[jsxRuntime.jsx(Bt.Fragment,{children:V},z.slot)]});R.length>0&&B.unshift({id:yc.id,labelKey:yc.labelKey,children:R});}E=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[N,u&&!D?jsxRuntime.jsx(Jr,{},"separator-contextual-table"):null,D?null:jsxRuntime.jsx("div",{className:"docx-toolbar__contextual",[Nn]:on,children:jsxRuntime.jsx(Gx,{overrides:k,separator:false})}),w.length>0?jsxRuntime.jsx("div",{className:"docx-toolbar__group",[Fn]:"",children:w}):null,B.length>0?jsxRuntime.jsx(gy,{sections:B}):null]});}return jsxRuntime.jsx(Hr.Provider,{value:s,children:jsxRuntime.jsx(sy,{children:jsxRuntime.jsx("fieldset",{ref:T,disabled:m,"aria-label":c("formattingBar.label"),"data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,dir:g,...P?{"data-overflow":""}:{},onMouseDown:U,children:a8(l,i)?jsxRuntime.jsx(Um,{children:E}):E})})})}function Tc(e){if(!e)return false;if(e.type===Bt.Fragment){let t=Bt.Children.toArray(e.props.children).find(o=>Cc(o)!==null);return Bt.isValidElement(t)?Tc(t):false}return !!e.props.hidden}function Xx(e,t){let o=e.entries.filter(r=>!Tc(t?.get(r.slot))).map(r=>r.slot);return editor.toolbarGroupItems(o,e.extras.length>0)}function l8(e,t){let o=new Map(t.groups.map(s=>[s.id,s])),r=new Set(e.map(s=>s.id)),n=new Map;for(let s of e){let c=o.get(s.id);if(c&&s8(c),c?.hidden)continue;let d=Bt.Children.toArray(c?.children);!s.entries.some(u=>!Tc(t.overrides.get(u.slot)))&&d.length===0||n.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===on&&Sy(s.id);let i=t.groups.filter(s=>!r.has(s.id)&&s.id!==on);for(let s of i){let c=Bt.Children.toArray(s.children);s.hidden||c.length===0||n.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=[...r,...i.map(s=>s.id)];for(let s of i)s.after!==void 0&&!a.includes(s.after)&&Ty(s.id,s.after,a);for(let s of t.appended){if(!Bt.isValidElement(s)||s.type!==Di)continue;let c=s.props.slotId;Py(c,Q(c)!==null);}return editor.arrangeToolbarGroups(e.map(s=>s.id),i.map(s=>({id:s.id,after:s.after}))).flatMap(s=>{let c=n.get(s);return c?[c]:[]})}function s8(e){for(let t of ["label","labelKey","after"])e[t]!==void 0&&Ey(e.id,t);}function c8(e){return e.overflowContent?e.overflowContent():e.extras.length===0?null:jsxRuntime.jsx(bm.Provider,{value:"panel",children:jsxRuntime.jsx("div",{className:"docx-toolbar__more-host",children:e.extras})})}function Jx(e,t,o,r,n){let i=t.get(e.slot);if(Tc(i))return null;let a=i?.type===Di?i.props.overflowContent:void 0;return i||n8(e.slot)?jsxRuntime.jsx(my,{label:d8(o,e,r),children:a?a():n(e)}):jsxRuntime.jsx(fy,{slot:e.slot})}function d8(e,t,o){let r=t.slot==="alignment"?null:Q(t.slot);return e(r?.labelKey??o)}var Vi=Object.assign(i8,{Button:Bo,Action:_m,Separator:Jr,Group:gm,Slot:Di,AddComment:hm,Undo:wy,Redo:Dy,Bold:Ry,Italic:My,Underline:_y,Strike:Iy,Link:Tm,ClearFormatting:Ny,Superscript:Fy,Subscript:Ly,Alignment:rc,AlignLeft:Hy,AlignCenter:Ay,AlignRight:Oy,AlignJustify:By,LeftToRight:Wy,RightToLeft:Zy,LineSpacing:Rm,BulletList:Ky,NumberedList:qy,Outdent:Uy,Indent:zy,ImageInsert:Ya,ImageProperties:ia,ImageWrap:Ri,ImageAltText:bi,TableInsert:Cm,TableBorderTarget:Zi,TableBorderColor:Ui,TableBorderStyle:Ki,TableBorderWidth:qi,TableCellFill:zi,TableMergeCells:ga,TableSplitCell:ba,Comments:$y,FontFamily:Lm,FontSize:wm,FontColor:Kd,Highlight:qd,Zoom:Dm,StylePicker:Wm,EditingMode:$s,Reviewers:Gs,Save:Em,ContentControlShowAll:cc,ContentControlFormFill:dc,ContentControlInspector:pc,ContentControlRemove:uc});var Qx=/^(con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])$/i,g8=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g,b8=200,ev=new TextEncoder;function h8(e,t){if(ev.encode(e).length<=t)return e;let o=0,r="";for(let n of e){let i=ev.encode(n).length;if(o+i>t)break;o+=i,r+=n;}return r}function tv(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 ov(e){return tv(tv(e).replace(/\.docx$/i,""))}function Ec(e){let t=(e??"").replace(g8," ").replace(/\s+/g," ").trim(),o=ov(t).replace(/^[. ]+/,""),r=h8(o,b8),n=r===o?o:ov(r);return !n||Qx.test(n)?"document.docx":Qx.test(n.split(".",1)[0].trim())?`_${n}.docx`:`${n}.docx`}function Sc(e,t,o="application/vnd.openxmlformats-officedocument.wordprocessingml.document",r){let n=URL.createObjectURL(new Blob([e],{type:o})),i=editor.hostDocumentOf(r).createElement("a");i.href=n,i.download=t,i.click(),editor.hostWindowOf(r).setTimeout(()=>URL.revokeObjectURL(n),0);}function rv(e,t,o){let{t:r}=L(),n=Bt.useRef(false),[i,a]=Bt.useState(false),[l,s]=Bt.useState(""),[c,d]=Bt.useState("pdf"),[m,u]=Bt.useState(false),[g,p]=Bt.useState({});return {pending:i,error:l,format:c,visible:m,session:g,dismiss:()=>u(false),execute:async h=>{if(!(!e||n.current)){n.current=true,p({}),d(h),u(true),a(true),s("");try{let y=await editor.runChromeExport(e,h,t);Sc(y.bytes.slice().buffer,Ec(o).replace(/\.docx$/,`.${y.extension}`),y.mimeType),u(!1);}catch(y){u(true),s(y instanceof editor.ChromeExportError?r(y.format==="markdown"?"toolbar.exportMarkdownMissing":"toolbar.exportPdfMissing"):r("toolbar.exportFailed",{message:y instanceof Error?y.message:String(y)}));}finally{n.current=false,a(false);}}}}}function av(e,t,o){let{t:r}=L(),n=Bt.useRef({editor:e,exporters:t,feedback:o,t:r});n.current={editor:e,exporters:t,feedback:o,t:r};let i=Bt.useRef(null),a=Bt.useRef(null),[l,s]=Bt.useState(false),[c,d]=Bt.useState(""),[m,u]=Bt.useState(""),[g,p]=Bt.useState(false),[f,h]=Bt.useState(false),[y,x]=Bt.useState({}),b=Bt.useCallback(T=>{let{t:C}=n.current;if(T instanceof editor.ChromeExportError)return C("toolbar.printPdfMissing");if(T instanceof editor.ChromePrintError){if(T.code==="pdf-viewer-unavailable")return C("toolbar.printNoViewer");if(T.code==="pdf-load-failed")return C("toolbar.printLoadFailed");if(T.code==="print-refused")return C("toolbar.printRefused")}return C("toolbar.printFailedMessage",{message:T instanceof Error?T.message:String(T)})},[]),v=Bt.useCallback(()=>{i.current=null,h(false),p(false),s(false);},[]),P=Bt.useCallback(async T=>{let{editor:C,exporters:E}=n.current;if(!C||i.current)return;let S={};i.current=S,a.current?.dispose(),a.current=null,x(S),h(true),p(true),s(true),d(""),u("");try{let k=await editor.runChromePrint(C,E,T??editor.hostDocumentOf(null));if(i.current!==S){k.dispose();return}a.current=k,await k.print({beforePrint:()=>{if(i.current!==S)throw new editor.ChromePrintError("print-ended");reactDom.flushSync(()=>p(!1));}}),i.current===S&&v();}catch(k){if(i.current!==S)return;if(!n.current.feedback){console.error("[docx-editor] print failed",k),v();return}s(false),u(a.current?.url??""),d(b(k)),p(true);}},[v,b]);return Bt.useEffect(()=>()=>{i.current=null,a.current?.dispose(),a.current=null;},[]),{pending:l,error:c,url:m,visible:g,active:f,session:y,execute:P,close:v}}var D8=()=>{};function Jm(){let e=H(),t=Bt.useCallback(r=>e?e.on("hostChange",r):D8,[e]),o=Bt.useCallback(()=>e?editor.editorHostDocument(e):typeof globalThis.document>"u"?null:globalThis.document,[e]);return Bt.useSyncExternalStore(t,o,()=>null)}var R8="https://github.com/eigenpal/docx-editor/issues/new";function M8(){if(typeof globalThis.window>"u")return "";try{let e=new URL(globalThis.window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function lv(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}),n=["### 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??M8()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
1
+ 'use strict';var Bt=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'),Fe=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 Bt__namespace=/*#__PURE__*/_interopNamespace(Bt);var Fe__namespace=/*#__PURE__*/_interopNamespace(Fe);var rg={version:"2.35.0-canary.20261102190412.sha-b9a04a3"};var eE=rg.version;function ng(){let e=new Map,t=new Map,o=new Set,r=0,n=0,i=null,a=[],l,s=false,c=()=>[...e].sort((u,g)=>t.get(u[0])-t.get(g[0])),d=()=>{n++;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,r++),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:()=>n,hosts(u){let g=c();return a.filter(p=>g.find(([,f])=>editor.unsupportedElementRuleMatches(f,p.unsupported))?.[0]===u)}}}var xn=Bt.createContext(null);function ag(e){return Bt.Children.toArray(e).some(t=>Bt.isValidElement(t)&&t.type===Bt.Fragment?ag(t.props.children):typeof t!="string"||t.trim().length>0)}function ig({host:e,children:t}){let o=ag(t);return Bt.useLayoutEffect(()=>(e.setCustomized(o),()=>{e.setCustomized(false);}),[e,o]),o?reactDom.createPortal(t,e.slot):null}function Cd({match:e,layout:t,includePartial:o,children:r}){let n=Bt.useContext(xn);if(!n)throw new Error("DocxEditor.UnsupportedElement must render inside DocxEditor.Root.");let i=Bt.useRef(Symbol("unsupported-element-declaration")).current;return Bt.useSyncExternalStore(n.subscribe,n.snapshot,n.snapshot),Bt.useLayoutEffect(()=>{n.register(i,{includePartial:o,...e?{match:e}:{},...t?{layout:t}:{}});},[n,i,e,t,o]),Bt.useLayoutEffect(()=>()=>n.unregister(i),[n,i]),n.hosts(i).map(a=>jsxRuntime.jsx(ig,{host:a,children:r({element:a.unsupported})},a.key))}var Td=Bt.createContext(i18n.en),Ed=Bt.createContext("en"),Sd=Bt.createContext("ltr"),Pd=Bt.createContext(void 0);function vn({i18n:e,dir:t,children:o}){let r=Bt.useContext(Td),n=Bt.useContext(Ed),i=Bt.useContext(Sd),a=Bt.useContext(Pd),l=typeof e?._lang=="string"?e._lang:n,s=i18n.chromeDirection(t,e,a),c=s??i18n.catalogDirection(e)??i,d=Bt.useMemo(()=>i18n.deepMerge(r,e),[r,e]);return jsxRuntime.jsx(Ed.Provider,{value:l,children:jsxRuntime.jsx(Sd.Provider,{value:c,children:jsxRuntime.jsx(Pd.Provider,{value:s,children:jsxRuntime.jsx(Td.Provider,{value:d,children:o})})})})}function L(){let e=Bt.useContext(Td),t=Bt.useContext(Ed),o=Bt.useContext(Sd);return {t:Bt.useMemo(()=>i18n.createT(e,t),[e,t]),catalogue:e,lang:t,dir:o}}function it(){return Bt.useContext(Pd)}function cg(e){let{t}=L();return Bt.useCallback((o,r)=>e?.get(o)??t(o,r),[e,t])}var kd=Bt.createContext(null);function H(){return Bt.useContext(kd)}function Pl(e){return (e?.mounted??0)+(e?.gutters??0)>0}var Lt=Bt.createContext(null);var wd=0,Dd=false,Rd=false,kl=[],wl=null;function ug(e){if(typeof MessageChannel!="function"){globalThis.setTimeout(e,0);return}wl||(wl=new MessageChannel,wl.port1.onmessage=()=>{let t=kl;kl=[];for(let o of t)try{o();}catch(r){queueMicrotask(()=>{throw r});}}),kl.push(e),kl.length===1&&wl.port2.postMessage(null);}function pg(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(Dd||(Dd=true,wd+=1,queueMicrotask(()=>{Dd=false;}),Rd||(Rd=true,ug(()=>{Rd=false,wd=0;}))),wd>16)}function mg(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};pg()?ug(o):queueMicrotask(o);}}var TE=()=>{},_d=0;function EE(){return _d}function _a(e){return mg(e)}function W(e,t=Object.is,o){let r=H(),n=o?.onSubscribe,i=o?.onUnsubscribe,a=Bt.useCallback(d=>{if(!r)return TE;let m=false;_d++,n?.();let u=_a(()=>{m||d();}),g=[r.on("change",u),r.on("selectionChange",u),r.on("error",u)];return ()=>{m=true,_d--,i?.();for(let p of g)p();}},[r,n,i]),l=Bt.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)}},[r,e,t]),s=Bt.useCallback(()=>l(r?r.snapshot():editor.LOADING_SNAPSHOT),[r,l]),c=Bt.useCallback(()=>l(editor.LOADING_SNAPSHOT),[l]);return Bt.useSyncExternalStore(a,s,c)}function wE(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function DE(e,t){let o={...e,...t};for(let r of Object.keys(e))/^on[A-Z]/.test(r)?o[r]=wE(t[r],e[r]):r==="className"?o[r]=[e[r],t[r]].filter(Boolean).join(" "):r==="style"&&(o[r]={...e[r],...t[r]});return o}function J({children:e,...t}){let o=Bt.Children.only(e);if(!Bt.isValidElement(o))return null;let r=o.props,n=DE(t,r),i=o.ref,a=t.ref;return (i||a)&&(n.ref=l=>{for(let s of [i,a])typeof s=="function"?s(l):s&&typeof s=="object"&&(s.current=l);}),Bt.cloneElement(o,n)}var fg="(prefers-color-scheme: dark)";function gg(){return typeof globalThis.window<"u"&&typeof globalThis.window.matchMedia=="function"}function bg(){return gg()?globalThis.window.matchMedia(fg).matches:false}function hg(e,t){return e==="dark"||e==="system"&&t}function yg(e){if(!gg())return ()=>{};let t=globalThis.window.matchMedia(fg);e(t.matches);let o=r=>e(r.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}var Ao=Bt.createContext(false),Ir=Bt.createContext(false);function RE(){let e=Bt.useContext(Ao),t=Bt.useContext(Ir);return e?"":t?"docx-editor dark ":"docx-editor "}function Rl(e){let t=e==="system",o=Bt.useSyncExternalStore(t?_E:IE,t?bg:Cg,Cg);return hg(e??"light",o)}function _E(e){return yg(()=>e())}function IE(){return ()=>{}}function Cg(){return false}function Kt(){return Bt.useContext(Ir)}function qt(){let e=Bt.useContext(Ao),t=Bt.useContext(Ir);return e?"":t?"docx-editor dark ":"docx-editor "}function NE(){return Bt.useContext(Ir)?LE:FE}var FE=Object.freeze({colorMode:"light"}),LE=Object.freeze({colorMode:"dark"});var Sg=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function St(){let e=Bt.createContext(null),t=new Map,o=y=>{let x=t.get(y.type);return x==="field"?`field:${y.props.name}`:x};function r(y,x){Bt.Children.forEach(y,b=>{Bt.isValidElement(b)&&(x(b),r(b.props.children,x));});}function n(){let y=Bt.useContext(e);if(!y)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return y.state}function i(y,x){return Bt.Children.map(y,b=>{if(!Bt.isValidElement(b))return b;let v=Sg(b.props);return v&&x.has(v)?x.get(v):b.props.children===void 0?b:Bt.cloneElement(b,{children:i(b.props.children,x)})})}function a(y){function x(b){let v=Bt.useContext(e);if(!v||b.hidden)return null;let P=y==="field"?`field:${b.name}`:y,T=v.defaults.get(P);if(!T)return b.children??null;let{children:C,asChild:E,className:S,style:k,hidden:w,name:I,...O}=b,N={...O,...T.props,className:[T.props.className,S].filter(Boolean).join(" "),style:{...T.props.style,...k}};if(E){let{children:B,className:F,style:D,...R}=N;return jsxRuntime.jsx(J,{...R,...S?{className:S}:{},...k?{style:k}:{},children:C})}return Bt.cloneElement(T,N,C===void 0?i(T.props.children,v.overrides):C)}return t.set(x,y),x}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 h({defaults:y,children:x,preset:b=true,state:v}){let P=new Map;r(y,S=>{let k=Sg(S.props);k&&P.set(k,S);});let T=new Map;r(x,S=>{let k=o(S);k&&T.set(k,S);});let C=S=>Bt.Children.toArray(S).flatMap(k=>Bt.isValidElement(k)&&k.type===Bt.Fragment?C(k.props.children):[k]),E=C(x).filter(S=>!Bt.isValidElement(S)||!o(S));return jsxRuntime.jsx(e.Provider,{value:{defaults:P,overrides:T,state:v},children:b?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i(y,T),E]}):x})}return {Header:l,Title:s,Body:c,Footer:d,Apply:m,Cancel:u,Reset:g,Error:p,Field:f,Composition:h,useState:n,part:y=>a(y)}}function Be({kind:e,role:t="dialog",className:o,style:r,label:n,onClose:i,onKeyDown:a,panelRef:l,children:s,dismissOutside:c=true,sessionSignal:d,restoreFocus:m=true,describedBy:u}){let g=Bt.useRef(null),p=l??g,f=Bt.useRef(i);f.current=i;let[h,y]=Bt.useState(false),x=Kt();return Bt.useLayoutEffect(()=>{let b=p.current;if(!b)return;y(!b.parentElement?.closest(".docx-editor"));let v=b.ownerDocument.activeElement,P=()=>{b.open&&b.close?.();};return d?.addEventListener("abort",P),typeof b.showModal=="function"?b.showModal():b.setAttribute("open",""),(b.querySelector('input:not([disabled]),select:not([disabled]),button:not([disabled]),[tabindex="0"]')??b.querySelector("a[href]"))?.focus({preventScroll:true}),()=>{d?.removeEventListener("abort",P),typeof b.close=="function"&&b.open&&b.close(),m&&v?.isConnected&&v.focus({preventScroll:true});}},[p,d,m]),jsxRuntime.jsx("dialog",{ref:p,role:t,"aria-modal":"true","aria-label":n,"aria-describedby":u,className:`docx-dialog${h?` docx-editor${x?" dark":""}`:""}${o?` ${o}`:""}`,style:r,"data-docx-dialog":e,onCancel:b=>{b.preventDefault(),f.current();},onMouseDown:b=>b.stopPropagation(),onClick:b=>{if(c&&b.target===b.currentTarget){let v=b.currentTarget.getBoundingClientRect();(b.clientX<v.left||b.clientX>v.right||b.clientY<v.top||b.clientY>v.bottom)&&f.current();}b.stopPropagation();},onKeyDown:b=>{b.key==="Escape"&&!b.nativeEvent.isComposing?(b.preventDefault(),f.current()):editor.trapTabWithin(b.currentTarget,b.nativeEvent)?b.preventDefault():!b.nativeEvent.isComposing&&!b.defaultPrevented&&a?.(b),b.stopPropagation();},children:s})}function bo(e,t){let o=H(),r=Ld(),n=Bt.useRef(null);return Bt.useEffect(()=>{if(!e){n.current=null;return}o?.surface&&(n.current===null?n.current=o.mountGeneration:n.current!==o.mountGeneration&&t());},[e,o,r,t]),()=>!!o?.surface&&n.current===o.mountGeneration}function Ld(){let e=H(),t=Bt.useCallback(o=>{if(!e)return ()=>{};let r=true,n=_a(()=>{r&&o();}),i=[e.on("change",n),e.on("selectionChange",n),e.on("error",n)];return ()=>{r=false,i.forEach(a=>a());}},[e]);return Bt.useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function Pg(){let e=0,t=0,o=null,r=new Set,n=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(r));},subscribeShift(l){return r.add(l),()=>r.delete(l)},getReservation:()=>t,setReservation(l){let s=Math.max(0,Math.round(l));s!==t&&(t=s,a(n));},subscribeReservation(l){return n.add(l),()=>n.delete(l)},getViewport:()=>o,setViewport(l){l!==o&&(o=l,a(i));},subscribeViewport(l){return i.add(l),()=>i.delete(l)}}}var Ad=Bt.createContext(null);function Fr(){return Bt.useContext(Ad)}var kg=()=>0,Od=()=>()=>{};function Lr(){let e=Fr(),t=Bt.useCallback(r=>e?e.subscribeShift(r):Od(),[e]),o=Bt.useCallback(()=>e?e.getShift():0,[e]);return Bt.useSyncExternalStore(t,o,kg)}function wg(){let e=Fr(),t=Bt.useCallback(r=>e?e.subscribeReservation(r):Od(),[e]),o=Bt.useCallback(()=>e?e.getReservation():0,[e]);return Bt.useSyncExternalStore(t,o,kg)}function ke(){let e=Fr(),t=Bt.useCallback(n=>e?e.subscribeViewport(n):Od(),[e]),o=Bt.useCallback(()=>e?e.getViewport():null,[e]),r=Bt.useCallback(()=>null,[]);return Bt.useSyncExternalStore(t,o,r)}function Oo(e,t,o){let r=ke(),n=Bt.useRef({close:o,viewport:r});n.current={close:o,viewport:r},Bt.useEffect(()=>{let i=e.current;if(!(!t||!i))return eS(i,()=>n.current.close(),()=>n.current.viewport)},[e,t]);}function eS(e,t,o){let r=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();},n=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",r),e.addEventListener("focusout",n),()=>{e.removeEventListener("keydown",r),e.removeEventListener("focusout",n),i(),a();}}function lS(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason&&e.value===t.value}function Bd(e){return typeof e=="string"}function oe(e){let t=H(),{t:o}=L(),r=Bd(e)?e:editor.editorCommandKey(e),n=Bt.useRef(e);n.current=e;let i=Bt.useCallback(s=>{let c=n.current;if(Bd(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,r,o]),a=W(i,lS),l=Bt.useCallback(s=>{let c=editor.commandExecOptions(s),d=n.current;return Bd(d)?editor.runToolbarCommand(t,d,void 0,c??{}).ok:t?t.exec(d,c).ok:false},[t]);return Bt.useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[l,a])}var Hr=Bt.createContext({t:void 0,onSave:void 0});function cS(){return Bt.useContext(Hr)}function _l(e){let{t}=L();return o=>e?.(o)??t(o)}function ne(){let{t:e}=Bt.useContext(Hr);return _l(e)}var mS=()=>()=>{},fS=()=>true,gS=()=>false;function Yt(){let e=Bt.useSyncExternalStore(mS,fS,gS);return Bt.useCallback(t=>e?i18n.platformShortcut(t):t,[e])}function bS(e){let t=e.viteEnv?.DEV;return typeof t=="boolean"?t:e.hasProcess&&e.nodeEnv!=="production"}function hS(){try{return undefined}catch{return}}function bt(){let e=typeof process<"u";return bS({viteEnv:hS(),nodeEnv:e?"production":void 0,hasProcess:e})}var _g=new Set;function ar(e){!bt()||_g.has(e)||(_g.add(e),console.warn(`[docx-editor] ${e}`));}function Ig(e){ar(`Menu.Item and ContextMenu.Slot take the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function Ng(e){ar(`A hidden context-menu override names "${e}", but no packaged row has that id, so nothing is removed.`);}function Fg(){ar("A Menu.Item or ContextMenu.Slot has no slotId, so it renders nothing.");}function Lg(){ar("A Menu.Submenu has neither label nor labelKey, so its row has no name.");}function Hg(e){ar(`Toolbar.Button takes the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function Ag(){ar("A Toolbar.Button has no slotId, so it renders nothing.");}function Q(e){for(let t of editor.CHROME_GROUPS)for(let o of t.controls)if(editor.chromeSlotId(t,o)===e)return o;return null}function re(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 U(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function CS(e){if(e.slotId)return e.slotId;if(e.slot)return Hg(e.slot),e.slot;Ag();}function Bo(e){let{icon:t,asChild:o,className:r,children:n,hidden:i}=e,a=CS(e)??"",{execute:l,isActive:s,isEnabled:c,disabledReason:d,value:m}=oe(a),u=ne(),g=Yt();if(i||!a)return null;let p=Q(a),f=g(u(p?.labelKey??a)),h=editor.chromeSlotIsToggle(a),y={onClick:()=>l(),onMouseDown:U,disabled:!c,"data-slot":a,className:`docx-toolbar__button${r?` ${r}`:""}`,...s?{"data-active":""}:{},...c?{}:{"data-disabled":""},...h?{"aria-pressed":s}:{},...m!==null?{"data-value":m}:{},"aria-label":f,title:d??f};return o?jsxRuntime.jsx(J,{...y,children:n}):jsxRuntime.jsx("button",{type:"button",...y,children:t??n??re(p?.paths)})}Bo.docxToolbarPart=true;var DS=[{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"}],Og=[{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"}],Bg=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Nl=["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"],ir=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),Ut=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function RS(e){let t=[0,2,4].map(r=>parseInt(e.slice(r,r+2),16)),o=(Math.max(...t)+Math.min(...t))/2/255;return o===1?[Ut(5),Ut(15),Ut(25),Ut(35),Ut(50)]:o===0?[ir(50),ir(35),ir(25),ir(15),ir(5)]:o>=.8?[Ut(10),Ut(25),Ut(50),Ut(75),Ut(90)]:[ir(80),ir(60),ir(40),Ut(25),Ut(50)]}var MS=/^[0-9A-Fa-f]{6}$/;function _S(e,t){let o="";for(let r=0;r<6;r+=2){let n=Math.round(t(parseInt(e.slice(r,r+2),16)));o+=Math.max(0,Math.min(255,n)).toString(16).padStart(2,"0");}return o.toUpperCase()}function IS(e){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);return .299*t+.587*o+.114*r>230}function Tn({value:e,css:t,title:o,selected:r,apply:n}){return jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch",style:{backgroundColor:t},"aria-label":o,"aria-pressed":r,title:o,"data-value":e,...r?{"data-selected":""}:{},...t.startsWith("var(")||IS(t.replace("#",""))?{"data-light":""}:{},onMouseDown:U,onClick:()=>n(e)})}function NS({apply:e,label:t,current:o,themeHexes:r}){let n=r.map(RS),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:[r.map((a,l)=>jsxRuntime.jsx(Tn,{value:a,css:`#${a.toLowerCase()}`,title:t(Nl[l]),selected:o===a,apply:e},`base-${l}`)),i.map(a=>r.map((l,s)=>{let c=n[s][a],d=_S(l,c.apply);return jsxRuntime.jsx(Tn,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Nl[s])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${s}`)}))]})]})}function FS(e){let{apply:t,label:o,current:r}=e,[n,i]=Bt.useState(""),a=MS.test(n);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(NS,{...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:DS.map(l=>jsxRuntime.jsx(Tn,{value:l.value,css:l.css,title:o(l.labelKey),selected:r===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:n,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(n.toUpperCase());}}),jsxRuntime.jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!a,onMouseDown:U,onClick:()=>t(n.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function Zd({apply:e,current:t}){let o=H(),r=ne(),n=o?.getDocumentThemeColors()??[],i=n.length===Nl.length?n.map(l=>l.hex):Bg,a=t?.toUpperCase()??null;return jsxRuntime.jsx(FS,{apply:e,label:r,current:a,themeHexes:i})}var LS=Og.filter(e=>e.value!=="white");function HS({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:LS.map(r=>jsxRuntime.jsx(Tn,{value:r.value,css:r.css,title:t(r.labelKey),selected:o===r.value,apply:e},r.value))})]})}function Wg(e){let{slot:t,defaultValue:o,cssOf:r,clear:n,body:i}=e,a=t==="text.color";return Object.assign(({className:s,hidden:c,icon:d})=>{let m=H(),{isEnabled:u,disabledReason:g}=oe(t),p=ne(),[f,h]=Bt.useState(false),[y,x]=Bt.useState(o),b=Bt.useRef(null);Oo(b,f,()=>h(false));let v=W(k=>{if(a){let w=k.formatting?.color;return w&&w.kind==="hex"?w.value.toUpperCase():null}return k.formatting?.highlight??null}),P=m?.getDocumentThemeColors()??[],T=P.length===Nl.length?P.map(k=>k.hex):Bg;Bt.useEffect(()=>{if(f)return editor.listenForOutsidePress({popup:b.current,close:()=>h(false)})},[f]);let C=Bt.useCallback(k=>{if(h(false),!m)return;m.focus();let w=editor.commandForSlotValue(t,k);w&&m.can(w).ok&&(m.exec(w),k!==n.value&&x(k));},[m]),E=Bt.useMemo(()=>Q(t),[]);if(c)return null;let S=p(E?.labelKey??t);return jsxRuntime.jsxs("div",{ref:b,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:U,onClick:()=>C(y),children:[d??re(E?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:r(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:U,onClick:()=>h(k=>!k),children:"\u25BE"}),f?jsxRuntime.jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":S,onMouseDown:U,children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:U,onClick:()=>C(n.value),children:[jsxRuntime.jsx("span",{className:`docx-toolbar__swatch-clear-chip${n.value==="none"?" docx-toolbar__swatch-clear-chip--none":""}`,"aria-hidden":"true"}),p(n.labelKey)]}),i({apply:C,label:p,current:v,themeHexes:T})]}):null]})},{docxSlot:t})}var AS=new Map(Og.map(e=>[e.value,e.css])),Kd=Wg({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsxRuntime.jsx(Zd,{apply:e.apply,current:e.current})}),qd=Wg({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>AS.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsxRuntime.jsx(HS,{...e})});var zd=e=>e==="auto"?"currentColor":e==="byAuthor"?"var(--doc-review-author-0)":e==="none"?"transparent":`var(--doc-revision-color-${e})`;function Ll({label:e,value:t,values:o,disabled:r,change:n,t:i}){let a=Bt.useId(),[l,s]=Bt.useState(false),c=Bt.useRef(null),d=Bt.useRef(null),m=Bt.useRef(null);Bt.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]),Bt.useEffect(()=>{if(r&&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,r]);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:r,"aria-labelledby":`${a}-label ${a}-value`,"aria-expanded":l&&!r,"aria-controls":`${a}-options`,onClick:()=>s(!l),children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:zd(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||r,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),h=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;h!==null&&(g.preventDefault(),g.stopPropagation(),p[h]?.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:()=>{n(g),u();},children:[jsxRuntime.jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:zd(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(Tn,{value:g,css:zd(g),title:i(`values.${g}`),selected:t===g,apply:p=>{n(p),u();}},g))})]})]})}var Zg=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],US=["byAuthor","auto",...editor.REVISION_MARKUP_COLORS];function Kg(e,t,o){let{values:r}=e,n=a=>{let l=a==="changedLines"?["none","leftBorder","rightBorder","outsideBorder"]:a==="deletions"||a==="movedFrom"?[...Zg,"hidden","caret","pound"]:Zg,s=(a==="movedFrom"||a==="movedTo")&&!r.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:r[a].mark,disabled:s,onChange:c=>e.setValue(a,{...r[a],mark:c.target.value}),children:l.map(c=>jsxRuntime.jsx("option",{value:c,children:t(`values.${c}`)},c))})]}),jsxRuntime.jsx(Ll,{label:t(`${a}Color`),value:r[a].color,values:US,disabled:s,t,change:c=>e.setValue(a,{...r[a],color:c})})]}),a!=="changedLines"&&jsxRuntime.jsx("div",{className:"docx-revision-markup-background",children:jsxRuntime.jsx(Ll,{label:t(`${a}Background`),value:r[a].background,values:["none","byAuthor",...editor.REVISION_MARKUP_COLORS],disabled:s,t,change:c=>e.setValue(a,{...r[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:r[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")}),n("insertions"),n("deletions"),n("changedLines")]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("moves")}),i("trackMoves"),n("movedFrom"),n("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(Ll,{label:t(`${a}Cells`),value:r.cells[a],values:["byAuthor","none",...editor.REVISION_MARKUP_COLORS],t,change:l=>e.setValue("cells",{...r.cells,[a]:l})},a))]}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx("legend",{children:t("formatting")}),i("trackFormatting"),n("formatting")]})]})}var Jt=St();function XS(){return Jt.useState()}function JS({session:e,...t}){return e?jsxRuntime.jsx(QS,{session:e,...t}):null}function QS({session:e,children:t,preset:o,className:r,style:n}){let i=Bt.useId(),{t:a}=L(),l=f=>a(`revisionMarkup.${f}`),s=Bt.useCallback(f=>e.subscribe(f),[e]),c=Bt.useCallback(()=>e.get(),[e]),d=Bt.useSyncExternalStore(s,c,c),[m,u]=Bt.useState(e.signal.aborted),g=Bt.useRef(null);Bt.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,h){e.set({[f]:h});},errors:{},isEnabled:!m&&e.canApply(),apply(){e.apply();},cancel(){e.cancel();},reset(){e.reset();}};return m?null:jsxRuntime.jsx(Be,{kind:"revisionMarkup",label:l("title"),className:["docx-revision-markup-dialog",r].filter(Boolean).join(" "),style:n,onClose:p.cancel,dismissOutside:false,sessionSignal:e.signal,children:jsxRuntime.jsx(Jt.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:Kg(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 Ia=Object.assign(JS,{Header:Jt.Header,Title:Jt.Title,Body:Jt.Body,Footer:Jt.Footer,Apply:Jt.Apply,Cancel:Jt.Cancel,Error:Jt.Error,Field:Jt.Field,Reset:Jt.Reset});function Vd(e){let t=H(),o=Bt.useRef(e.onRevisionMarkupChange);o.current=e.onRevisionMarkupChange;let{onRevisionMarkupChange:r,...n}=e,i=JSON.stringify(n);return Bt.useEffect(()=>t?.on("revisionMarkupChange",a=>o.current?.(a)),[t]),Bt.useEffect(()=>{t&&t.setRevisionMarkup(JSON.parse(i));},[t,i]),null}function Na({open:e,format:t,pending:o,error:r,onClose:n,className:i,style:a,children:l}){let{t:s}=L();if(!e)return null;let c=s(r?t==="pdf"?"toolbar.exportPdfFailed":"toolbar.exportMarkdownFailed":t==="pdf"?"toolbar.exportingPdf":"toolbar.exportingMarkdown");return jsxRuntime.jsx(Be,{kind:"export",label:c,role:r?"alertdialog":"dialog",className:`docx-export-dialog${o?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:n,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:r?"alert":"status",children:r||s("toolbar.exportDownloadHint")})}),jsxRuntime.jsx("footer",{className:"docx-dialog__footer",children:jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:n,children:s(r?"common.close":"toolbar.exportContinueEditing")})})]})})}function Fa({open:e,pending:t,error:o,url:r,onClose:n,className:i,style:a,children:l}){let{t:s}=L();if(!e)return null;let c=s(o?"toolbar.printFailed":"toolbar.printPreparing"),d=r.startsWith("blob:")?r:"";return jsxRuntime.jsx(Be,{kind:"print",label:c,role:o?"alertdialog":"dialog",className:`docx-export-dialog docx-print-dialog${t?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:n,onKeyDown:m=>{editor.isChromePrintShortcut(m.nativeEvent)&&m.preventDefault();},children:l??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:c})]}),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&&d&&jsxRuntime.jsx("a",{className:"docx-dialog__link-button docx-print-dialog__open",href:d,target:"_blank",rel:"noopener noreferrer",children:s("toolbar.printOpenPdf")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:n,children:s(o?"common.close":"common.cancel")})]})]})})}var vt={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function En({text:e,x:t,y:o,className:r}){return jsxRuntime.jsx("div",{role:"tooltip",className:r,"data-testid":"docx-notes-preview",style:{position:"fixed",left:t,top:o,zIndex:vt.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:n=>{n.preventDefault(),n.stopPropagation();},children:e})}function Sn({noteKind:e,x:t,y:o,onDelete:r,onConvert:n,onConvertAll:i,onOpenProperties:a,onClose:l,deleteEnabled:s,convertEnabled:c,convertAllEnabled:d,deleteDisabledReason:m,convertDisabledReason:u,convertAllDisabledReason:g,className:p}){let{t:f}=L();return jsxRuntime.jsxs("div",{role:"menu",className:p,onKeyDown:h=>{h.key==="Escape"&&l();},"data-testid":"docx-notes-menu",style:{position:"fixed",left:t,top:o,zIndex:vt.popover,minWidth:160,background:"var(--doc-popover-bg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",padding:4},onMouseDown:U,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!s,title:m,onClick:r,children:f("notes.delete")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!c,title:u,onClick:n,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 lP(e){return t=>Bt.createElement(e,t)}var Vg=new WeakMap,sP=0;function Se(e,t,o){if(e===false)return null;let r=e(t);if(!o)return r;let n=Vg.get(o);return n===void 0&&Vg.set(o,n=++sP),Bt.createElement(Bt.Fragment,{key:n},r)}var jd=Bt.createContext(void 0),kt=()=>Bt.useContext(jd);function Pn(e,t,o){let r=e.getBoundingClientRect();return {left:t-r.left-e.clientLeft+e.scrollLeft,top:o-r.top-e.clientTop+e.scrollTop}}function Oa(e){return e.paragraphId===""}var bP=4096,kn=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),hP=e=>e;function yP(e){let t=n=>!!n&&(n.width>0||n.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 r=o?o.getSelection():null;if(r&&r.rangeCount>0){let n=r.getRangeAt(0),i=n.getBoundingClientRect();if(t(i))return {left:i.left,top:i.bottom};let a=n.startContainer,s=(editor.isElementNode(a)?a:a.parentElement)?.getBoundingClientRect();if(t(s))return {left:s.left,top:s.bottom}}return null}var Ba=Bt.createContext(null),Yd=Bt.createContext(null);function Xd(){let e=Bt.useContext(Yd);Bt.useEffect(()=>e?.(),[e]);}function xP(){let e=Bt.useContext(Ba);Xd();let t=Hl(e===null);return e??t}function Hl(e=true){let t=H(),o=ke(),r=Bt.useRef(o);r.current=o;let[n,i]=Bt.useState(kn),a=Bt.useRef(null),l=Bt.useRef(""),s=Bt.useRef(false),c=Bt.useRef(n);c.current=n;let d=W(hP),m=t?t.can({type:"insertText",text:""}).ok:false,u=Bt.useCallback(()=>{l.current="",s.current=false;let E=a.current;E&&(E.editor.releaseSelection(E.pin),a.current=null);},[]),g=Bt.useCallback((E=false)=>{let S=l.current;return S===""||!t?false:!s.current&&t.surface?.hyperlinks.selectionIsPendingDeletion()===true?true:E&&S.length>bP?false:t.query({type:"selectedText"})!==S},[t]),p=Bt.useCallback((E,S)=>{u(),i({mode:E?"reading":"editing",link:E??null,anchor:S??null,text:E?.text??"",url:E?E.kind==="internal"?`#${E.anchor??""}`:E.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,u]),f=Bt.useCallback(()=>{u(),i(kn);},[u]);Bt.useEffect(()=>u,[u]);let h=Bt.useCallback(()=>{let E=yP(r.current);u();let S=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(S&&Oa(S)){p(S,E);return}if(S){i({mode:"editing",link:S,anchor:E,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 k=t?.surface?.hyperlinks.wordAtCaret()??null;k&&t?.surface?.setSelection({anchor:k.from,head:k.to});let w=t?.query({type:"selectedText"})??"",I=t?.retainSelection()??null;t&&I&&(a.current={editor:t,pin:I}),l.current=w,s.current=t?.surface?.hyperlinks.selectionIsPendingDeletion()===true,i({mode:"editing",link:null,anchor:E,text:w,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,p,u]);Bt.useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:E=>p(E.link,{left:E.rect.left,top:E.rect.bottom}),onRequest:h})},[t,e,p,h]),Bt.useEffect(()=>{let E=c.current;if(E.mode!=="reading"||!E.link)return;let S=Oa(E.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;S&&S.id===E.link.id||i(kn);},[d,t]),Bt.useEffect(()=>{let E=c.current;if(E.mode!=="editing"||E.link)return;let S=t?.surface;S&&(S.retainedSelection()&&!g(true)||f());},[d,t,g,f]);let y=Bt.useCallback(async()=>{let E=c.current.link?.href;if(!E)return false;try{await editor.hostWindowOf(r.current).navigator.clipboard.writeText(E);}catch{return false}return i(S=>({...S,copied:true})),true},[]),x=Bt.useCallback(()=>{i(E=>({...E,mode:"editing",copied:false,error:false}));},[]),b=Bt.useCallback(E=>{i(S=>({...S,text:E,copied:false,error:false}));},[]),v=Bt.useCallback(E=>{i(S=>({...S,url:E,copied:false,error:false}));},[]),P=Bt.useCallback(()=>{let E=c.current,S=t?.surface?.hyperlinks;if(!S)return false;if(!E.link&&g())return f(),false;let k=E.url.trim();if(k.length===0)return i(O=>({...O,error:true})),false;let w=k.startsWith("#");return S.applyHyperlink({...w?{anchor:k.slice(1)}:{url:k},...E.text.trim().length>0?{text:E.text}:{}})?(f(),true):(i(O=>({...O,error:true})),false)},[t,f,g]),T=Bt.useCallback(()=>{let E=t?.surface?.hyperlinks,S=c.current.link;if(!E)return false;let k=E.removeHyperlink(S?.id);return k&&f(),k},[t,f]),C=Bt.useCallback(()=>{let E=t?.surface?.navigation,S=c.current.link;if(!E||!S)return false;if(S.kind==="internal"){let w=S.anchor?E.goToBookmark(S.anchor):false;return w&&i(kn),w}let k=E.openExternal(S.href);return k&&i(kn),k},[t]);return Bt.useMemo(()=>({state:n.mode==="closed"?kn:{...n,canEdit:m},open:p,openAtCaret:h,close:f,copy:y,beginEdit:x,setText:b,setUrl:v,commitEdit:P,unlink:T,openTarget:C}),[n,m,p,h,f,y,x,b,v,P,T,C])}function Br(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Wa(){let e=H();return Bt.useCallback(()=>{e?.focus();},[e])}var Al=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"})}),wP="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",DP="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",RP="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",MP="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 _P({className:e,asChild:t,hidden:o,children:r,preset:n=true}){let i=xo();Xd();let a=Bt.useRef(null),{state:l,close:s}=i,c=Wa();Bt.useEffect(()=>{if(l.mode==="closed")return;let h=b=>{b.key==="Escape"&&(b.preventDefault(),s(),c());},y=editor.hostDocumentOf(a.current);y.addEventListener("keydown",h);let x=editor.listenForOutsidePress({popup:y,contains:b=>a.current?.contains(b)===true,close:s});return ()=>{y.removeEventListener("keydown",h),x();}},[l.mode,s,c]);let[d,m]=Bt.useState(null);Bt.useLayoutEffect(()=>{let h=l.anchor,y=a.current;if(!h||!y){m(null);return}let x=y.offsetParent;if(!x){m(null);return}let{left:b,top:v}=Pn(x,h.left,h.top),P=Math.max(0,x.scrollWidth-y.offsetWidth);m({left:Math.max(0,Math.min(b,P)),top:v});},[l.anchor]);let{t:u}=L(),g=l.mode==="editing"?u(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):u("hyperlinkPopup.editLink"),p=n?jsxRuntime.jsx(IP,{children:r}):r;if(o)return l.mode==="closed"?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:r});let f={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:Br,style:d??void 0,"aria-label":g};return l.mode==="closed"?null:t?jsxRuntime.jsx(J,{...f,children:r}):jsxRuntime.jsx("div",{...f,children:p})}function IP({children:e}){let{state:t}=xo(),o=Bt.useMemo(()=>NP(e),[e]),r=(i,a)=>i in o?o[i]:a;if(t.mode==="editing")return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r("Fields",jsxRuntime.jsx(ru,{})),r("Error",jsxRuntime.jsx(au,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[r("Apply",jsxRuntime.jsx(nu,{})),r("Cancel",jsxRuntime.jsx(iu,{}))]}),o.__extra]});let n=t.canEdit&&!(t.link&&Oa(t.link));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r("Url",jsxRuntime.jsx(Qd,{})),jsxRuntime.jsxs("div",{className:"docx-hyperlink-popup__actions",children:[r("Copy",jsxRuntime.jsx(eu,{})),n?r("Edit",jsxRuntime.jsx(tu,{})):null,n?r("Unlink",jsxRuntime.jsx(ou,{})):null]}),o.__extra]})}function NP(e){let t={},o=[],r=n=>{if(Array.isArray(n)){n.forEach(r);return}if(!n||typeof n!="object"||!("type"in n)){n&&o.push(n);return}if(n.type===Bt.Fragment){r(n.props.children);return}let i=n.type.docxHyperLinkPart;i?t[i]=n:o.push(n);};return r(e),o.length>0&&(t.__extra=o),t}function xo(){return Bt.useContext(Ba)??FP}var FP={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 Qd({className:e,asChild:t,hidden:o,children:r}){let{state:n,openTarget:i}=xo(),{t:a}=L();if(o||!n.link)return null;let l=!n.link.href,s=n.link.kind==="internal",c=s?`#${n.link.anchor??""}`:n.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:Br,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsxRuntime.jsx(J,{...u,className:e,children:r}):l?jsxRuntime.jsxs("span",{...u,children:[r??d,jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:m})]}):jsxRuntime.jsxs("button",{...u,children:[r??d,Al(MP)]})}Qd.docxHyperLinkPart="Url";function eu({className:e,asChild:t,hidden:o,children:r,icon:n}){let{state:i,copy:a}=xo(),{t:l}=L();if(o||!i.link?.href)return null;let s=i.copied?l("editor.linkCopied"):l("hyperlinkPopup.copyLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...i.copied?{"data-copied":""}:{},"aria-label":s,title:s,onMouseDown:Br,onClick:()=>{a();}};return t?jsxRuntime.jsx(J,{...c,className:e,children:r}):jsxRuntime.jsx("button",{...c,children:n??r??Al(wP)})}eu.docxHyperLinkPart="Copy";function tu({className:e,asChild:t,hidden:o,children:r,icon:n}){let{beginEdit:i}=xo(),{t:a}=L();if(o)return null;let l=a("hyperlinkPopup.editLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":l,title:l,onMouseDown:Br,onClick:()=>i()};return t?jsxRuntime.jsx(J,{...s,className:e,children:r}):jsxRuntime.jsx("button",{...s,children:n??r??Al(DP)})}tu.docxHyperLinkPart="Edit";function ou({className:e,asChild:t,hidden:o,children:r,icon:n}){let{unlink:i}=xo(),a=Wa(),{t:l}=L();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:Br,onClick:()=>{i()&&a();}};return t?jsxRuntime.jsx(J,{...c,className:e,children:r}):jsxRuntime.jsx("button",{...c,children:n??r??Al(RP)})}ou.docxHyperLinkPart="Unlink";function ru({className:e,hidden:t}){let{state:o,setText:r,setUrl:n,commitEdit:i,close:a}=xo(),l=Wa(),{t:s}=L(),c=Bt.useRef(null),d=Bt.useId(),m=Bt.useId();Bt.useEffect(()=>{o.mode==="editing"&&(c.current?.focus({preventScroll:true}),c.current?.select());},[o.mode]);let u=Bt.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=>r(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=>n(g.target.value),onKeyDown:u})]})}ru.docxHyperLinkPart="Fields";function nu({className:e,asChild:t,hidden:o,children:r}){let{state:n,commitEdit:i}=xo(),a=Wa(),{t:l}=L();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:n.url.trim().length===0,onMouseDown:Br,onClick:()=>{i()&&a();}};return t?jsxRuntime.jsx(J,{...c,className:e,children:r}):jsxRuntime.jsx("button",{...c,children:r??s})}function au({className:e,hidden:t}){let{state:o}=xo(),{t:r}=L();return t||!o.error?null:jsxRuntime.jsx("div",{className:`docx-hyperlink-popup__error${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-error",role:"alert",children:r("hyperlinkPopup.refused")})}au.docxHyperLinkPart="Error";nu.docxHyperLinkPart="Apply";function iu({className:e,asChild:t,hidden:o,children:r}){let{close:n}=xo(),i=Wa(),{t:a}=L();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:Br,onClick:()=>{n(),i();}};return t?jsxRuntime.jsx(J,{...s,className:e,children:r}):jsxRuntime.jsx("button",{...s,children:r??l})}iu.docxHyperLinkPart="Cancel";var Za=Object.assign(_P,{Url:Qd,Copy:eu,Edit:tu,Unlink:ou,Fields:ru,Error:au,Apply:nu,Cancel:iu});var wt={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function OP(e){return e==="sdtLocked"||e==="sdtContentLocked"}function BP(e){return e==="contentLocked"||e==="sdtContentLocked"}function su(e,t){return !e.ok&&e.code===t}function vo(){let e=Bt.useContext(cu),t=Ol();return e??t}function Ol(){let e=H(),[t,o]=Bt.useState(false),[r,n]=Bt.useState(false),[i,a]=Bt.useState(false),l=W(C=>C),s=e?.surface??null,c=s?.contentControls;Bt.useEffect(()=>{n(c?.showAll()??s?.state().contentControls.showAll??false),a(c?.formFill()??s?.state().contentControls.formFill??false);},[l,c,s]);let d=Bt.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:BP(C.effectiveLock)||F==="locked",removalLocked:OP(C.effectiveLock)||D==="locked",placeholder:C.placeholder,bound:C.bound||F==="bound",effectiveLock:C.effectiveLock}}let E=e.query({type:"contentControlAt"});if(!E)return null;let S=c?.disabledReason(E.id,"edit")??null,k=c?.disabledReason(E.id,"remove")??null,w=e.can({type:"setContentControlValue",value:""}),I=e.can({type:"removeContentControl"}),O=E.locked===true||S==="locked"||su(w,"locked"),N=S==="bound"||su(w,"bound"),B=k==="locked"||su(I,"locked");return {id:E.id,tag:E.tag??null,alias:E.alias??null,controlType:E.controlType,locked:O,removalLocked:B,placeholder:false,bound:N,effectiveLock:null}},[e,l,c]),m=Bt.useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=Bt.useCallback(C=>{c?.setShowAll(C),n(C);},[c]),g=Bt.useCallback(C=>{c?.setFormFill(C),a(C);},[c]),p=Bt.useCallback(()=>u(!r),[u,r]),f=Bt.useCallback(()=>g(!i),[g,i]),h=Bt.useCallback(()=>o(true),[]),y=Bt.useCallback(()=>o(false),[]),x=Bt.useCallback(()=>o(C=>!C),[]),b=Bt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let E=c.disabledReason(d.id,"edit");return E==="locked"?"the content control is locked":E==="bound"?"the content control is bound to external data":E==="notFound"?"the content control was not found":E}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]),v=Bt.useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let E=c.disabledReason(d.id,"remove");return E==="locked"?"the content control is locked":E==="notFound"?"the content control was not found":E}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]),P=Bt.useCallback(C=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c&&d){let E=c.disabledReason(d.id,"edit");if(E)return {ok:false,code:E==="bound"?"bound":E==="locked"?"locked":"notFound",reason:E==="bound"?"the content control is bound to external data":E==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:C})},[e,c,d]),T=Bt.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 E=c.disabledReason(C,"remove");return E?{ok:false,code:E==="locked"?"locked":"notFound",reason:E==="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 Bt.useMemo(()=>({control:d,controls:m,showAll:r,formFill:i,inspectorOpen:t,canSetValue:b===null&&d!==null,canRemove:v===null&&d!==null,setValueDisabledReason:b,removeDisabledReason:v,setShowAll:u,toggleShowAll:p,setFormFill:g,toggleFormFill:f,openInspector:h,closeInspector:y,toggleInspector:x,remove:T,setValue:P}),[d,m,r,i,t,b,v,u,p,g,f,h,y,x,T,P])}var cu=Bt.createContext(null);function du(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var ob=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"})}),UP="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",zP="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",$P={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},VP={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},GP={color:"var(--doc-text-muted)",flexShrink:0},jP={textAlign:"right",wordBreak:"break-word"},YP={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},XP={display:"flex",gap:8,marginTop:4},rb={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 JP(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 QP(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 wn({label:e,value:t,testId:o}){return jsxRuntime.jsxs("div",{style:VP,"data-testid":o,children:[jsxRuntime.jsx("span",{style:GP,children:e}),jsxRuntime.jsx("span",{style:jP,children:t})]})}function ek({className:e,asChild:t,hidden:o,children:r,preset:n=true}){let i=vo(),a=Bt.useRef(null),l=Bt.useId(),{t:s}=L(),{control:c,inspectorOpen:d,closeInspector:m}=i;if(Bt.useEffect(()=>{if(!d)return;let f=x=>{x.key==="Escape"&&(x.preventDefault(),m());},h=editor.hostDocumentOf(a.current);h.addEventListener("keydown",f);let y=editor.listenForOutsidePress({popup:h,contains:x=>a.current?.contains(x)===true,close:m});return ()=>{h.removeEventListener("keydown",f),y();}},[d,m]),Bt.useEffect(()=>{d&&!c&&m();},[d,c,m]),o||!d||!c)return null;let u=n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(nb,{}),jsxRuntime.jsx(ab,{}),jsxRuntime.jsx("div",{style:XP,children:jsxRuntime.jsx(ib,{})}),r]}):r,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:$P,onMouseDown:f=>{du(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(J,{...g,children:p}):jsxRuntime.jsx("div",{...g,children:p})}function nb({className:e,asChild:t,hidden:o,children:r}){let{closeInspector:n}=vo(),{t:i}=L();if(o)return null;let a={style:YP,className:e??void 0,"data-testid":"content-control-inspector-header"},l=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{children:r??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:{...rb,padding:4,border:"none",background:"transparent"},onMouseDown:du,onClick:()=>n(),children:ob(UP)})]});return t?jsxRuntime.jsx(J,{...a,children:l}):jsxRuntime.jsx("div",{...a,children:l})}function ab({className:e,asChild:t,hidden:o,children:r}){let{control:n}=vo(),{t:i}=L();if(o||!n)return null;let a=i("contentControl.inspectorPanel.empty"),l=i("contentControl.inspectorPanel.yes"),s=i("contentControl.inspectorPanel.no"),c=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.alias"),value:n.alias??a,testId:"content-control-inspector-alias"}),jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.tag"),value:n.tag??a,testId:"content-control-inspector-tag"}),jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.type"),value:i(JP(n.controlType)),testId:"content-control-inspector-type"}),jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.lock"),value:i(QP(n)),testId:"content-control-inspector-lock"}),jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.placeholder"),value:n.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsxRuntime.jsx(wn,{label:i("contentControl.inspectorPanel.bound"),value:n.bound?l:s,testId:"content-control-inspector-bound"}),n.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,n.locked?jsxRuntime.jsx("p",{"data-testid":"content-control-inspector-locked-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},"aria-live":"polite",children:i("contentControl.inspectorPanel.lockedNote")}):null]}),d={className:e??void 0,"data-testid":"content-control-inspector-fields",style:{display:"flex",flexDirection:"column",gap:8}};return t?jsxRuntime.jsx(J,{...d,children:c}):jsxRuntime.jsx("div",{...d,children:c})}function ib({className:e,asChild:t,hidden:o,icon:r,children:n}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:s}=vo(),{t:c}=L();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:rb,onMouseDown:du,onClick:()=>{l().ok&&s();}},u=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r??n??ob(zP),jsxRuntime.jsx("span",{children:d})]});return t?jsxRuntime.jsx(J,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}var Ua=Object.assign(ek,{Header:nb,Fields:ab,Remove:ib});var ak=e=>e;function gu(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function za(){let e=H(),{t}=L(),[o,r]=Bt.useState(null),[n,i]=Bt.useState(null),a=Bt.useRef(null),l=Bt.useRef(null),s=Bt.useRef(null),c=Bt.useId(),d=Bt.useId(),m=Bt.useId(),u=o?.activation??null,g=W(ak),p=Bt.useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let b=e.surface.equations.can(u.equation.id,"replace"),v=e.surface.equations.can(u.equation.id,"remove"),P=b.ok?v.ok?null:v.reason:b.reason;return {replaceEnabled:b.ok,removeEnabled:v.ok,reason:P?i18n.localizeDisabledReason(P,t):null}},[u,e,g,t]),f=Bt.useCallback((b=false)=>{s.current?.(),s.current=null,r(null),b&&e&&queueMicrotask(()=>e.focus());},[e]);Bt.useEffect(()=>{if(!e)return;let b=e.setEquationChrome({onPopover:v=>{s.current?.();let P=e.surface;if(P&&typeof P.retainSelection=="function"){let T=P.retainSelection();s.current=()=>P.releaseSelection(T);}else s.current=null;r({activation:v,mountGeneration:e.mountGeneration,draft:v.equation.linear,error:false});}});return ()=>{b(),s.current?.(),s.current=null,r(null);}},[e,f]),Bt.useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&f();},[e,g,o,f]),Bt.useEffect(()=>{if(!o)return;let b=a.current,v=b?.ownerDocument,P=v?.defaultView;if(!b||!v||!P)return;let T=E=>{E.key==="Escape"&&(E.preventDefault(),f(true));},C=E=>{editor.isDomNode(E.target)&&b.contains(E.target)||f();};return v.addEventListener("keydown",T),v.addEventListener("pointerdown",C,true),()=>{v.removeEventListener("keydown",T),v.removeEventListener("pointerdown",C,true);}},[o,f]),Bt.useLayoutEffect(()=>{if(!u){i(null);return}let b=a.current;if(!b)return;let v=b.offsetParent;if(!v){i(null);return}let P=u.rect,T=Pn(v,P.left,P.bottom),C=Math.max(0,v.scrollWidth-b.offsetWidth);i({left:Math.max(0,Math.min(T.left,C)),top:T.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[u]);let h=Bt.useCallback(()=>{if(!o||!e?.surface||!p.replaceEnabled)return false;let b=e.surface.equations.applyEquation(o.activation.equation.id,o.draft);return b?f(true):r(v=>v&&{...v,error:true}),b},[e,o,f,p.replaceEnabled]),y=Bt.useCallback(()=>{if(!o||!e?.surface||!p.removeEnabled)return false;let b=e.surface.equations.removeEquation(o.activation.equation.id);return b?f(true):r(v=>v&&{...v,error:true}),b},[e,o,f,p.removeEnabled]);if(!o)return null;let x=[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:n??void 0,onMouseDown:gu,children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:t("equationPopup.inputLabel")}),jsxRuntime.jsx("input",{id:c,ref:l,className:"docx-equation-popup__input","data-testid":"equation-popup-input",value:o.draft,placeholder:t("equationPopup.placeholder"),spellCheck:false,"aria-describedby":x||void 0,onChange:b=>r(v=>v&&{...v,draft:b.target.value,error:false}),onKeyDown:b=>{b.key!=="Enter"||b.nativeEvent.isComposing||(b.preventDefault(),h());}}),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:gu,onClick:h,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:gu,onClick:y,children:t("equationPopup.delete")})]})]})}var cb="review.comments",bu="review.addComment";function db(e){return e!==cb?e:(ar(`The context-menu row "${cb}" is now "${bu}". The old id still works in this release; write "${bu}".`),bu)}var lk="input, textarea, select",sk="[data-docx-form-dropdown]",ck=".docx-paginated-surface:not(.docx-editor__loading-surface)",dk=".docx-image-selection-overlay";function ub(e,t){if(!editor.isElementNode(t))return false;let o=t.closest(lk);if(o&&!o.matches(sk))return false;let r=e.querySelector(ck);return r?r.contains(t)||t.contains(r)||!!t.closest(dk):true}function Mn(e,t){if(!Bt.isValidElement(e)||e.type!==Bt.Fragment)return null;let r=Bt.Children.toArray(e.props.children).map(t).filter(n=>n!==null);return r.length===1?r[0]:null}function Bl({entries:e,children:t,preset:o,keyOfEntry:r,keyOfChild:n,renderEntry:i,childrenOfEntry:a,onUnmatched:l}){if(!o)return t;let s=new Map,c=[];for(let p of Bt.Children.toArray(t)){let f=n(p);f?s.set(f,p):c.push(p);}let d=new Set,m=p=>p.map((f,h)=>{let y=r(f,h);d.add(y);let x=a?.(f),b=x?m(x):void 0,v=s.get(y);return jsxRuntime.jsx(Bt.Fragment,{children:v??i(f,h,b)},y)}),u=m(e),g=[...s.entries()].filter(([p])=>!d.has(p)).map(([p,f])=>(l?.(p,f),jsxRuntime.jsx(Bt.Fragment,{children:f},p)));return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u,g,c]})}var fk="review.addComment",gk=e=>e.editingMode==="viewing";function Wl(e){let{isEnabled:t,disabledReason:o}=oe(fk),r=W(gk);return t?{isEnabled:t,reason:null}:{isEnabled:t,reason:r?e("editingMode.viewingHint"):o}}var $a=Bt.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}),_n="docx-menubar-more",Zl=Bt.createContext({measuring:false,overflow:new Set,inMore:false});function gb(){return Bt.useContext(Zl)}function Je(){return Bt.useContext($a)}function Pe(){let{t:e}=Je(),{t}=L();return o=>e?.(o)??t(o)}var In=Bt.createContext(-1);var bk='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Wr(e){return [...e.querySelectorAll(bk)].filter(t=>t.closest('[role="menu"]')===e)}function xu(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function Qt(e,t,o){if(e.length===0)return false;let r=t?e.indexOf(t):-1,n=r===-1?o>0?0:e.length-1:(r+o+e.length)%e.length;return e[n]?.focus(),true}function eo(e,t){let o=t==="first"?e[0]:e[e.length-1];return o?(o.focus(),true):false}function vu(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 bb(e,t,o){return !o||o.ownerDocument===t?false:o.contains(e)}var Nn="data-toolbar-group",xb=editor.TOOLBAR_ITEM_ATTRIBUTE,Fn="data-toolbar-fixed",ql="data-toolbar-more",Dk=34,Kl=new Map;function Cu(e,t,o){let r=Bt.useRef(null),n=Bt.useRef({itemWidths:new Map,groupBases:new Map,groupGaps:new Map,more:Dk}),[i,a]=Bt.useState(Kl),l=Bt.useRef(i);l.current=i;let s=Bt.useRef({groups:t,order:o});s.current={groups:t,order:o};let c=editor.toolbarGroupsKey(t),d=Bt.useRef(c),m=o.join("\0"),u=Bt.useCallback(()=>{let p=r.current;if(!p||!e)return;let f=editor.readToolbarRow(p,n.current,editor.toolbarItemKey),h=l.current.size===0&&f.overflowing===false,y=editor.toolbarGroupsKey(s.current.groups),x=d.current===y;d.current=y;let b=h?Kl:editor.toolbarOverflowItems({...f,groups:s.current.groups,order:s.current.order,itemWidths:n.current.itemWidths,groupBases:n.current.groupBases,groupGaps:n.current.groupGaps,...x?{previous:l.current}:{},hysteresis:editor.TOOLBAR_OVERFLOW_HYSTERESIS});editor.sameItemOverflow(b,l.current)||(l.current=b,a(b));},[e]),g=Bt.useCallback(p=>{r.current=p;},[]);return Bt.useLayoutEffect(()=>{if(!e){l.current.size>0&&(l.current=Kl,a(Kl));return}u();},[e,c,u,m]),Bt.useEffect(()=>{let p=r.current,f=p?editor.hostWindowOf(p):null;if(!e||!p||!f||typeof f.ResizeObserver>"u")return;let h=0,y=new f.ResizeObserver(()=>{h===0&&(h=f.requestAnimationFrame(()=>{h=0,u();}));});y.observe(p),p.parentElement&&y.observe(p.parentElement);for(let x of p.querySelectorAll(`[${Nn}], [${Fn}]`))y.observe(x);return ()=>{h!==0&&f.cancelAnimationFrame(h),y.disconnect();}},[e,c,u,m,i]),{attach:g,overflow:i}}function vb(e,t,o){let r=t.map(l=>({id:l,items:[l]})),{attach:n,overflow:i}=Cu(e,r,o),a=Bt.useMemo(()=>new Set(i.keys()),[i]);return {attach:n,overflow:a}}function Cb(e,t,o){let r=e.overflow.has(t),n=t===_n;return {skip:e.inMore?!r:r,asSubmenu:e.inMore&&r,iconOnly:n,rootAttributes:{...e.measuring&&!n?{[Nn]:t}:{},...n?{[ql]:""}:{}},tabStop:o===t||n&&o!==null&&e.overflow.has(o)}}function Tb(e,t,o){let[r,n]=Bt.useState(void 0);return Bt.useLayoutEffect(()=>{if(!e){n(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});n({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]),r}var Sb=12700,Eb=96;function Lk(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function Hk(e,t,o,r){let n=e*72/o,i=t*72/r;return {widthPoints:Math.max(1,Math.round(n*100)/100),heightPoints:Math.max(1,Math.round(i*100)/100)}}function Ul(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(!Lk(o))return o==="image/svg+xml"||o==="image/tiff"?{ok:false,reasonKey:"imageInsert.errors.unsupportedFormat"}:{ok:false,reasonKey:"imageInsert.errors.invalidSignature"};let r=editor.validateRasterHeader(e,o);if(!r)return {ok:false,reasonKey:"imageInsert.errors.invalidSignature"};if(r.pixelWidth*r.pixelHeight>t.maxPixels||r.pixelWidth>t.maxDimension||r.pixelHeight>t.maxDimension)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let{widthPoints:i,heightPoints:a}=Hk(r.pixelWidth,r.pixelHeight,r.dpiX??Eb,r.dpiY??Eb);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function cr(e){return Math.round(e/Sb*100)/100}function Ga(e){return Math.round(e*Sb)}function Tu({message:e,onClose:t,className:o,style:r,children:n}){let{t:i}=L();return jsxRuntime.jsx(Be,{kind:"imageInsertError",role:"alertdialog",label:i("imageInsert.errors.title"),className:o,style:r,onClose:t,onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing&&(a.preventDefault(),t());},children:n??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 kb="image/png,image/jpeg,image/gif",Su=Bt.createContext(null);function Db(){let e=Bt.useContext(Su);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function ja(){return Bt.useContext(Su)}function $l({children:e}){let t=H(),{t:o}=L(),r=Bt.useRef(null),n=Bt.useRef(false),i=kt(),[a,l]=Bt.useState(null),s=Bt.useRef(null),c=Bt.useCallback(()=>editor.toolbarCommandState(t,"image.insert"),[t]),d=W(c,(b,v)=>b.enabled===v.enabled&&b.disabledReason===v.disabledReason),m=d.enabled,u=i18n.localizeDisabledReason(d.disabledReason,o),g=Bt.useCallback(async b=>{if(!t||n.current)return;let v=Ul(b);if(!v.ok){l(o(v.reasonKey));return}let P={type:"insertImage",data:v.bytes,mime:v.mime,widthPoints:v.widthPoints,heightPoints:v.heightPoints};n.current=true;try{let T=await editor.executeImageCommand(t,P);T.ok?t.focus():l(i18n.localizeDisabledReason(zk(T.reason)??null,o)??o("imageInsert.errors.refused"));}finally{n.current=false;}},[t,o]),p=Bt.useCallback(async b=>{let v=b?.[0];if(!v)return;let P=await v.arrayBuffer();await g(new Uint8Array(P));},[g]),f=Bt.useCallback(async b=>{if(!b)return;let v=[...b.files].find(P=>P.type.startsWith("image/"));if(v){await p([v]);return}for(let P of b.items){if(P.kind!=="file"||!P.type.startsWith("image/"))continue;let T=P.getAsFile();if(!T)continue;let C=await T.arrayBuffer();await g(new Uint8Array(C));return}},[g,p]),h=Bt.useCallback(()=>{if(!m)return;let b=r.current,v=t?editor.editorHostDocument(t):null;if(!v||!b||b.ownerDocument===v){b?.click();return}s.current?.remove();let P=v.createElement("input");P.type="file",P.accept=kb,P.hidden=true,P.tabIndex=-1,P.setAttribute("aria-hidden","true");let T=()=>{P.remove(),s.current===P&&(s.current=null);};P.addEventListener("change",()=>{p(P.files).finally(T);},{once:true}),P.addEventListener("cancel",T,{once:true}),v.body.append(P),s.current=P,P.click();},[t,m,p]),y=Bt.useCallback(async b=>{let v=b.currentTarget;await p(v.files),v.value="";},[p]),x=Bt.useMemo(()=>({openFilePicker:h,insertFromFileList:p,insertFromDataTransfer:f,isEnabled:m,disabledReason:u,inputRef:r,onInputChange:y}),[h,p,f,m,u,y]);return jsxRuntime.jsxs(Su.Provider,{value:x,children:[jsxRuntime.jsx("input",{ref:r,type:"file",accept:kb,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:y,onMouseDown:b=>b.stopPropagation()}),e,a!==null&&(i?.imageInsertError!==void 0?Se(i.imageInsertError,{message:a,onClose:()=>l(null)}):jsxRuntime.jsx(Tu,{message:a,onClose:()=>l(null)}))]})}function Vl({className:e,hidden:t,asChild:o,children:r}){let{openFilePicker:n,isEnabled:i,disabledReason:a}=Db(),l=ne();if(t)return null;let s=Q("image.insert"),c=l(s?.labelKey??"toolbar.image"),d={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":c,title:a??c,onMouseDown:U,onClick:n};return o?jsxRuntime.jsx(J,{...d,children:r}):jsxRuntime.jsx("button",{...d,children:r??re(s?.paths)})}Vl.docxSlot="image.insert";var Ya=Object.assign(Vl,{docxSlot:"image.insert"});function zk(e){return e&&/\s/.test(e)?e:void 0}var Pu=6,_b=6;function jl({slot:e,label:t,onInserted:o,className:r}){let n=H(),{isEnabled:i}=oe(e),[a,l]=Bt.useState(null),[s,c]=Bt.useState({rows:1,cols:1}),d=Bt.useRef(null),m=Bt.useCallback((p,f)=>{if(!n||!i)return;let h={type:"insertTable",rows:p,cols:f};n.can(h).ok&&(n.exec(h),o(),n.focus());},[n,i,o]),u=Bt.useCallback(p=>{c(f=>{let h={rows:Math.min(_b,Math.max(1,f.rows+(p.rows??0))),cols:Math.min(Pu,Math.max(1,p.toCol??f.cols+(p.cols??0)))};return l(h),queueMicrotask(()=>d.current?.querySelector(`[data-cell="${h.rows}x${h.cols}"]`)?.focus()),h});},[]),g=[];for(let p=1;p<=_b;p+=1){let f=[];for(let h=1;h<=Pu;h+=1){let y=!!a&&p<=a.rows&&h<=a.cols;f.push(jsxRuntime.jsx("button",{type:"button",role:"gridcell","data-cell":`${p}x${h}`,className:"docx-menubar__grid-cell",tabIndex:s.rows===p&&s.cols===h?0:-1,...y?{"data-filled":""}:{},"aria-label":`${h} \xD7 ${p}`,onMouseDown:U,onMouseEnter:()=>l({rows:p,cols:h}),onFocus:()=>l({rows:p,cols:h}),onClick:()=>m(p,h)},h));}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${r?` ${r}`:""}`,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:Pu});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 An({slot:e="table.insert",className:t}){let{setOpenMenu:o}=Je(),r=Pe(),n=Bt.useCallback(()=>o(null),[o]);return jsxRuntime.jsx(jl,{slot:e,label:r("toolbar.insertTable"),onInserted:n,className:t})}function Jk({className:e,hidden:t}){let{isEnabled:o,disabledReason:r}=oe(editor.chromeProbeForSlot("insert.watermark")),n=Je(),i=Pe();if(t)return null;let a=Q("insert.watermark"),l=i(a?.labelKey??"toolbar.watermark"),s=o&&!!n.onWatermarkDialog;return jsxRuntime.jsx(we,{slot:"insert.watermark",icon:re(a?.paths),disabled:!s,...r?{title:r}:{},onSelect:()=>{n.onWatermarkDialog?.(),n.setOpenMenu(null);},...e?{className:e}:{},children:l})}var Yl=Object.assign(Jk,{docxSlot:"insert.watermark"});var tw={type:"openGoTo",fromShortcut:true};function Ib(){let e=oe(tw),t=i18n.isApplePlatform()?"toolbar.goToBookmarkShortcutApple":"toolbar.goToBookmarkShortcut";return jsxRuntime.jsx(to,{slotId:"insert.goToBookmark",...e.isEnabled?{shortcutKey:t}:{}})}function ow({className:e,hidden:t}){return jsxRuntime.jsx(to,{slotId:"insert.bookmark",shortcutKey:"toolbar.bookmarkShortcut",...e?{className:e}:{},...t?{hidden:t}:{}})}var Xl=Object.assign(ow,{docxSlot:"insert.bookmark"});var iw=e=>e;function Jl({labelKey:e,shortcutKey:t,className:o,hidden:r}){let n=H(),i=Je(),a=Pe();if(W(iw),r)return null;let l=editor.toolbarCommandState(n,"text.link"),s=i18n.localizeDisabledReason(l.disabledReason,a),c=Q("text.link"),d=n?.surface?.hyperlinks.linkAtCaret()!=null,m=a(e??(d?"hyperlinkPopup.editLink":"formattingBar.insertLink"));return jsxRuntime.jsx(we,{icon:re(c?.paths),slot:"text.link",...t?{shortcut:a(t)}:{},disabled:!l.enabled,title:s??void 0,onSelect:()=>{i.setOpenMenu(null),editor.runToolbarCommand(n,"text.link");},...o?{className:o}:{},children:m})}function we(e){let{icon:t,shortcut:o,disabled:r,title:n,active:i,selected:a,slot:l,onSelect:s,className:c,children:d}=e,m=e["data-value"],u=Yt(),g=Bt.useId(),p=Bt.useContext(In),f=r&&n?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":""}:{},...r?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...f?{"aria-describedby":f}:{},...n?{title:n}:{},onMouseDown:U,onClick:r?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:n}):null]})}function Xa({label:e,labelKey:t,className:o,hidden:r,children:n}){let i=Pe();if(r)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,n]})}function es(e){if(e.slotId)return e.slotId;if(e.slot)return Ig(e.slot),e.slot;Fg();}function to(e){return (e.slotId??e.slot)==="text.link"?jsxRuntime.jsx(Jl,{...e}):jsxRuntime.jsx(hw,{...e})}function hw(e){let{labelKey:t,shortcutKey:o,className:r,hidden:n}=e,i=es(e)??"",{execute:a,isActive:l,isEnabled:s,disabledReason:c,value:d}=oe(i),{setOpenMenu:m}=Je(),u=Pe();if(n||!i)return null;let g=Q(i),p=u(t??g?.labelKey??i),f=editor.chromeSlotIsToggle(i),h=["setAlignment","setParagraphDirection","setReviewDisplayMode"].includes(editor.commandForSlot(i)?.type??"");return jsxRuntime.jsx(we,{slot:i,icon:re(g?.paths),...o?{shortcut:u(o)}:{},disabled:!s,...c?{title:c}:{},...f?{active:l}:{},...h?{selected:true}:{},...d!==null?{"data-value":d}:{},onSelect:()=>{a(),m(null);},...r?{className:r}:{},children:p})}to.docxMenuRow=true;function Ja(e,t,o,r,n=()=>true){return Object.assign(({className:a,hidden:l})=>{let s=Je(),c=Pe(),d=r(s),m=o&&n(s)?o:void 0;if(l)return null;let u=Q(e),g=c(t??u?.labelKey??e);return jsxRuntime.jsx(we,{slot:e,icon:re(u?.paths),...m?{shortcut:c(m)}:{},disabled:!d,onSelect:()=>{d?.(),s.setOpenMenu(null);},...a?{className:a}:{},children:g})},{docxSlot:e})}var wu=Ja("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),Du=Ja("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave),Ru=Ja("file.exportMarkdown",void 0,void 0,e=>e.onExport?()=>e.onExport?.("markdown"):void 0),Mu=Ja("file.exportPdf",void 0,void 0,e=>e.onExport?()=>e.onExport?.("pdf"):void 0),_u=Ja("file.print",void 0,"toolbar.printShortcut",e=>e.onPrint,e=>e.printShortcut===true);function yw({className:e,hidden:t}){let{isEnabled:o,disabledReason:r}=oe(editor.chromeProbeForSlot("file.pageSetup")),n=Je(),i=Pe();if(t)return null;let a=Q("file.pageSetup"),l=i(a?.labelKey??"file.pageSetup"),s=o&&!!n.onPageSetup;return jsxRuntime.jsx(we,{slot:"file.pageSetup",icon:re(a?.paths),disabled:!s,...r?{title:r}:{},onSelect:()=>{n.onPageSetup?.(),n.setOpenMenu(null);},...e?{className:e}:{},children:l})}function xw({className:e,hidden:t}){let{isEnabled:o,disabledReason:r}=oe(editor.chromeProbeForSlot("paragraph.dialog")),n=Je(),i=Pe();if(t)return null;let a=Q("paragraph.dialog"),l=i(a?.labelKey??"lineSpacing.options"),s=o&&!!n.onParagraphDialog;return jsxRuntime.jsx(we,{slot:"paragraph.dialog",icon:re(a?.paths),disabled:!s,...r?{title:r}:{},onSelect:()=>{n.onParagraphDialog?.(),n.setOpenMenu(null);},...e?{className:e}:{},children:l})}var vw=Object.assign(xw,{docxSlot:"paragraph.dialog"}),Iu=Object.assign(yw,{docxSlot:"file.pageSetup"});function Cw({className:e,hidden:t}){let o=ja(),r=Je(),n=Pe();if(t)return null;let i=Q("image.insert"),a=n(i?.labelKey??"toolbar.image"),l=o?.isEnabled??false,s=o?.disabledReason??null;return jsxRuntime.jsx(we,{slot:"image.insert",icon:re(i?.paths),disabled:!l,...s?{title:s}:{},onSelect:()=>{o?.openFilePicker(),r.setOpenMenu(null);},...e?{className:e}:{},children:a})}var Nu=Object.assign(Cw,{docxSlot:"image.insert"});function oo({labelKey:e,label:t,paths:o,className:r,children:n}){let i=Pe(),[a,l]=Bt.useState(false),s=Bt.useRef(null),c=Bt.useRef(null),d=Bt.useId();t===void 0&&e===void 0&&Lg();let m=t??i(e??""),[u,g]=Bt.useState(null);return Bt.useLayoutEffect(()=>{if(!a){g(null);return}let p=s.current,f=c.current,h=p?.ownerDocument.defaultView;!p||!f||!h||g(editor.placeSubmenu(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:h.innerWidth,height:h.innerHeight},h.getComputedStyle(p).direction==="rtl"));},[a]),jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__submenu${r?` ${r}`:""}`,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&&eo(Wr(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:U,onFocus:()=>l(true),onClick:()=>l(true),children:[jsxRuntime.jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:re(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 h=Wr(f);p.key==="ArrowDown"?(p.preventDefault(),p.stopPropagation(),Qt(h,editor.hostDocumentOf(f).activeElement,1)):p.key==="ArrowUp"&&(p.preventDefault(),p.stopPropagation(),Qt(h,editor.hostDocumentOf(f).activeElement,-1));},children:jsxRuntime.jsx(In.Provider,{value:-1,children:n})}):null]})}function Tw({entry:e}){let{isEnabled:t}=oe(e.slot),o=Q(e.slot);return t?jsxRuntime.jsx(oo,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsxRuntime.jsx(An,{slot:e.slot})}):jsxRuntime.jsx(to,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Zr({className:e}){return jsxRuntime.jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function Qa({entry:e,children:t}){return e.kind==="separator"?jsxRuntime.jsx(Zr,{}):e.kind==="submenu"?jsxRuntime.jsx(oo,{labelKey:e.labelKey,paths:e.paths,children:t??e.items.map((o,r)=>jsxRuntime.jsx(Qa,{entry:o},r))}):e.slot==="file.open"?jsxRuntime.jsx(wu,{}):e.slot==="file.save"?jsxRuntime.jsx(Du,{}):e.slot==="file.exportMarkdown"?jsxRuntime.jsx(Ru,{}):e.slot==="file.exportPdf"?jsxRuntime.jsx(Mu,{}):e.slot==="file.print"?jsxRuntime.jsx(_u,{}):e.slot==="file.pageSetup"?jsxRuntime.jsx(Iu,{}):e.slot==="paragraph.dialog"?jsxRuntime.jsx(vw,{}):e.slot==="insert.watermark"?jsxRuntime.jsx(Yl,{}):e.slot==="insert.bookmark"?jsxRuntime.jsx(Xl,{}):e.slot==="insert.goToBookmark"?jsxRuntime.jsx(Ib,{}):e.slot==="image.insert"?jsxRuntime.jsx(Nu,{}):e.picker==="tableGrid"?jsxRuntime.jsx(Tw,{entry:e}):jsxRuntime.jsx(to,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Ab(e){if(!Bt.isValidElement(e))return null;let t=Mn(e,Ab);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?es(e.props)??null:null}function Ew(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function Lb(e,t,o){return Bl({entries:e??[],children:t,preset:o,keyOfEntry:Ew,keyOfChild:Ab,childrenOfEntry:r=>r.kind==="submenu"?r.items:void 0,renderEntry:(r,n,i)=>jsxRuntime.jsx(Qa,{entry:r,children:i})})}function ro({id:e,labelKey:t,label:o,icon:r,className:n,hidden:i,preset:a=true,children:l}){let{openMenu:s,setOpenMenu:c,activeMenu:d,opening:m}=Je(),u=gb(),g=Pe(),p=Bt.useId(),f=Bt.useRef(null),h=Bt.useRef(null),y=Bt.useRef(false),x=Bt.useRef(false),b=editor.CHROME_MENUS.find(w=>w.id===e),v=s===e,P=Tb(v&&e===_n,f,h);if(i)return null;let T=o??g(t??b?.labelKey??e),C=Cb(u,e,d);if(C.skip)return null;if(C.asSubmenu)return jsxRuntime.jsx(oo,{labelKey:t??b?.labelKey??e,label:T,children:Lb(b?.entries,l,a)});let E=Lb(b?.entries,l,a),S=C.iconOnly,k=()=>{c(null),f.current?.focus();};return jsxRuntime.jsxs("div",{role:"none",className:`docx-menubar__menu-root${n?` ${n}`:""}`,"data-menu":e,...C.rootAttributes,children:[jsxRuntime.jsxs("button",{ref:f,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":v,"aria-controls":v?p:void 0,className:"docx-menubar__trigger",disabled:m===true,tabIndex:C.tabStop?0:-1,...v?{"data-open":""}:{},...S?{"aria-label":T,title:T}:{},onMouseDown:U,onKeyDown:w=>{w.key==="ArrowDown"||w.key==="Enter"||w.key===" "||w.key==="ArrowUp"?(w.preventDefault(),y.current=true,c(e)):w.key==="Escape"&&v&&(w.preventDefault(),k());},onClick:()=>{if(x.current){x.current=false;return}c(v?null:e);},onMouseEnter:()=>{s!==null&&s!==e&&(x.current=true,c(e));},onMouseLeave:()=>{x.current=false;},children:[r?jsxRuntime.jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:r}):null,S?null:T]}),v?jsxRuntime.jsx("div",{ref:w=>{h.current=w,w&&y.current&&(y.current=false,eo(Wr(w),"first"));},id:p,role:"menu","aria-label":T,style:P,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:w=>{let I=h.current;if(!I)return;let O=Wr(I),N=editor.hostDocumentOf(I).activeElement;w.key==="ArrowDown"?(w.preventDefault(),Qt(O,N,1)):w.key==="ArrowUp"?(w.preventDefault(),Qt(O,N,-1)):w.key==="Home"?(w.preventDefault(),eo(O,"first")):w.key==="End"?(w.preventDefault(),eo(O,"last")):w.key==="Escape"?(w.preventDefault(),w.stopPropagation(),k()):w.key==="Tab"&&c(null);},children:jsxRuntime.jsx(In.Provider,{value:-1,children:E})}):null]})}function Fu(e){return Object.assign(o=>jsxRuntime.jsx(ro,{id:e,...o}),{docxMenu:e})}var Lu=Fu("file"),Hu=Fu("format"),Au=Fu("insert");var ts=Bt.createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function Zo(){return Bt.useContext(ts)}function Bb(){return Bt.useContext(ts).target}var kw=e=>e.pageSetup??null,ww=e=>e.editable;function Kr(){let e=H(),t=W(kw),o=W(ww),r=Bt.useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),n=Bt.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 Bt.useMemo(()=>({pageSetup:t,isEnabled:r,apply:n}),[t,r,n])}var Bu=[{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}],Ub=1440,Mw=e=>Math.round(e/Ub*100)/100,_w=e=>Math.round(e*Ub);function Iw(e,t){let o=Math.min(e,t),r=Math.max(e,t);return Bu.findIndex(n=>Math.abs(n.width-o)<20&&Math.abs(n.height-r)<20)}var Kb=12240,qb=15840,dr=1440;function Nw({open:e,onClose:t,className:o,style:r,children:n,preset:i=true}){let{t:a}=L(),l=bo(e,t),{pageSetup:s,isEnabled:c,apply:d}=Kr(),[m,u]=Bt.useState(Kb),[g,p]=Bt.useState(qb),[f,h]=Bt.useState("portrait"),[y,x]=Bt.useState(dr),[b,v]=Bt.useState(dr),[P,T]=Bt.useState(dr),[C,E]=Bt.useState(dr),[S,k]=Bt.useState(false),[w,I]=Bt.useState("document"),O=Bt.useRef(null),N=Bt.useRef("no");Bt.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||(k(false),u(s?.pageWidthTwips??Kb),p(s?.pageHeightTwips??qb),h(s?.orientation??"portrait"),x(s?.marginsTwips.top??dr),v(s?.marginsTwips.bottom??dr),T(s?.marginsTwips.left??dr),E(s?.marginsTwips.right??dr),I("document"),N.current=s===null?"loading":"yes");},[e,s]);let B=Bt.useCallback(q=>{let G=Bu[q];G&&(u(f==="landscape"?G.height:G.width),p(f==="landscape"?G.width:G.height));},[f]),F=Bt.useCallback(q=>{q!==f&&(h(q),u(g),p(m));},[f,m,g]),D=Bt.useCallback(()=>{if(!c)return;if(!l()){t();return}let q=d({pageWidthTwips:m,pageHeightTwips:g,orientation:f,marginTopTwips:y,marginRightTwips:C,marginBottomTwips:b,marginLeftTwips:P,scope:w});k(!q),q&&t();},[c,l,d,m,g,f,y,C,b,P,w,t]);if(!e)return null;let R=Iw(m,g),z=(q,G,ce)=>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:Mw(G),onChange:A=>ce(Math.max(0,_w(Number(A.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:b,marginLeft:P,marginRight:C,scope:w},ee={pageWidth:u,pageHeight:p,orientation:F,marginTop:x,marginBottom:v,marginLeft:T,marginRight:E,scope:I},Y={values:V,setValue(q,G){ee[q](G);},errors:S?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:D,cancel:t};return jsxRuntime.jsx(Be,{kind:"pageSetup",className:o,style:r,panelRef:O,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(To.Composition,{state:Y,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:[Bu.map((q,G)=>jsxRuntime.jsx("option",{value:G,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")}),z("top",y,x),z("bottom",b,v),z("left",P,T),z("right",C,E),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=>I(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:n})})}var To=St();function Fw(){return To.useState()}var qr=Object.assign(Nw,{Header:To.Header,Title:To.Title,Body:To.Body,Footer:To.Footer,Apply:To.Apply,Cancel:To.Cancel,Error:To.Error,Field:To.Field});var Aw={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},Ow=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,r=t.paragraphFlags??Aw;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:r.contextualSpacing,keepNext:r.keepNext,keepLines:r.keepLines,widowControl:r.widowControl,pageBreakBefore:r.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}}},Bw=["alignment","direction","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],Ww=(e,t)=>Bw.every(o=>e.disagrees[o]===t.disagrees[o]),Zw=(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&&Ww(e,t)&&e.indentUnknown===t.indentUnknown&&e.tabStops?.length===t.tabStops?.length&&(e.tabStops??[]).every((o,r)=>o.positionTwips===t.tabStops?.[r]?.positionTwips&&o.alignment===t.tabStops?.[r]?.alignment&&(o.leader??"none")===(t.tabStops?.[r]?.leader??"none")),Kw=e=>e.editable,qw={type:"setParagraphFormat",alignment:"left"};function Wu(){let e=H(),t=W(Ow,Zw),o=W(Kw),{isEnabled:r}=oe(qw),n=o&&r,i=Bt.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:n,apply:i}}function $w({open:e,onClose:t,className:o,style:r,children:n,preset:i=true}){let{t:a}=L(),l=bo(e,t),{format:s,isEnabled:c,apply:d}=Wu(),[m,u]=Bt.useState("left"),[g,p]=Bt.useState("ltr"),[f,h]=Bt.useState(0),[y,x]=Bt.useState(0),[b,v]=Bt.useState("none"),[P,T]=Bt.useState(0),[C,E]=Bt.useState(0),[S,k]=Bt.useState(0),[w,I]=Bt.useState("multiple"),[O,N]=Bt.useState(1.08),[B,F]=Bt.useState(false),[D,R]=Bt.useState(false),[z,V]=Bt.useState(false),[ee,Y]=Bt.useState(true),[q,G]=Bt.useState(false),[ce,A]=Bt.useState([]),[_,ae]=Bt.useState(false),[fe,Z]=Bt.useState(0),[de,Re]=Bt.useState("left"),[Ae,ft]=Bt.useState("none"),[ve,nt]=Bt.useState(editor.NO_MIXED_FIELDS),[Zt,Nt]=Bt.useState(false),er=$=>a(Zt&&($==="indentLeft"||$==="indentRight"||$==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),Mr=Bt.useRef(editor.NO_MIXED_FIELDS),ie=Bt.useId(),[at,Ie]=Bt.useState(false),go=Bt.useRef(null),tr=Bt.useRef(false),Ft=Bt.useRef(null);Bt.useEffect(()=>{if(!e){tr.current=false;return}if(tr.current||s===null)return;let $=editor.seedFields(s);u($.alignment),p($.direction),h($.indentLeft),x($.indentRight),v($.special),T($.specialBy),E($.spaceBefore),k($.spaceAfter),I($.lineRule),N($.lineValue),F($.contextualSpacing),R($.keepNext),V($.keepLines),Y($.widowControl),G($.pageBreakBefore),A($.tabStops),ae(false);let Ce=editor.mixedFieldsOf(s);nt(Ce),Nt(s.indentUnknown),Z(0),Re("left"),ft("none"),Mr.current=Ce,Ie(false),Ft.current=$,tr.current=true;},[e,s]);let Lo=Bt.useCallback(()=>{if(!c)return;if(!l()){t();return}let $=Ft.current,Ce=$===null?null:editor.changedFields($,{alignment:m,direction:g,indentLeft:f,indentRight:y,special:b,specialBy:P,spaceBefore:C,spaceAfter:S,lineRule:w,lineValue:O,contextualSpacing:B,keepNext:D,keepLines:z,widowControl:ee,pageBreakBefore:q,tabStops:ce,clearedAllTabStops:_},Mr.current,ve);if(Ce===null){t();return}if(d(Ce)){Ie(false),t();return}Ie(true);},[c,l,d,t,ve,_,m,g,f,y,b,P,C,S,w,O,B,D,z,ee,q,ce]),yn=Bt.useCallback(()=>{let $=Math.round(fe);return $<=0?false:(nt(Ce=>({...Ce,tabStops:false})),A(editor.withTabStop(ce,{positionTwips:$,alignment:de,...Ae!=="none"?{leader:Ae}:{}})),Z(0),Re("left"),ft("none"),true)},[ce,fe,de,Ae]);if(!e)return null;let le=$=>nt(Ce=>({...Ce,[$]:false})),be=($,Ce,rr,gt)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":gt,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-${$}`,children:a(`dialogs.paragraph.${$}`)}),jsxRuntime.jsx("input",{id:`${ie}-${$}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:ve[gt]?"":editor.twipsToInches(Ce),placeholder:ve[gt]?er(gt):void 0,onChange:Ma=>{le(gt),rr(editor.inchesToTwips(Number(Ma.target.value)||0));},"aria-label":a(`dialogs.paragraph.${$}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),Ke=($,Ce,rr,gt)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":$,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-${$}`,children:a(`dialogs.paragraph.${$}`)}),jsxRuntime.jsx("input",{id:`${ie}-${$}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:ve[gt]?"":Ce,placeholder:ve[gt]?er(gt):void 0,onChange:Ma=>{le(gt),rr(Math.max(0,Number(Ma.target.value)||0));},"aria-label":a(`dialogs.paragraph.${$}`)}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),xe=($,Ce,rr)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":$,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:Ce,ref:gt=>{gt&&(gt.indeterminate=ve[$]);},onChange:gt=>{nt(Ma=>({...Ma,[$]:false})),rr(gt.target.checked);}}),a(`dialogs.paragraph.${$}`)]}),Et={alignment:m,direction:g,indentLeft:f,indentRight:y,special:b,specialBy:P,spaceBefore:C,spaceAfter:S,lineRule:w,lineValue:O,contextualSpacing:B,keepNext:D,keepLines:z,widowControl:ee,pageBreakBefore:q,tabStops:ce,clearedAllTabStops:_},Ho=$=>{let Ce=Mr.current;$!==g&&!Ce.direction&&!Ce.alignment&&u(editor.alignmentAfterDirectionChange),p($);},or={alignment:u,direction:Ho,indentLeft:h,indentRight:x,special:v,specialBy:T,spaceBefore:E,spaceAfter:k,lineRule:I,lineValue:N,contextualSpacing:F,keepNext:R,keepLines:V,widowControl:Y,pageBreakBefore:G,tabStops:A,clearedAllTabStops:ae},_r={values:Et,mixed:ve,setValue($,Ce){or[$](Ce),$==="lineRule"?(le("lineSpacing"),N(Ce===Ft.current?.lineRule?Ft.current.lineValue:Ce==="multiple"?1.08:12)):$==="specialBy"?le("special"):$ in ve&&le($);},errors:at?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:Lo,cancel:t};return jsxRuntime.jsx(Be,{kind:"paragraph",className:o,style:r,panelRef:go,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:$=>{$.key==="Escape"&&t();let Ce=editor.isHTMLElementNode($.target)&&($.target.localName==="button"||$.target.localName==="select");if($.key==="Enter"&&!Ce){let rr=$.target;if(editor.isHTMLElementNode(rr)&&rr.dataset.docxTabEntry!==void 0){yn();return}c&&Lo();}},children:jsxRuntime.jsx(Eo.Composition,{state:_r,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:`${ie}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxRuntime.jsxs("select",{id:`${ie}-alignment`,className:"docx-dialog__input",value:ve.alignment?"":m,onChange:$=>{le("alignment"),u($.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[ve.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:`${ie}-direction`,children:a("dialogs.paragraph.direction")}),jsxRuntime.jsxs("select",{id:`${ie}-direction`,className:"docx-dialog__input",value:ve.direction?"":g,onChange:$=>{le("direction"),Ho($.target.value);},"aria-label":a("dialogs.paragraph.direction"),children:[ve.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")}),be("beforeText",f,h,"indentLeft"),be("afterText",y,x,"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:`${ie}-special`,children:a("dialogs.paragraph.special")}),jsxRuntime.jsxs("select",{id:`${ie}-special`,className:"docx-dialog__input",value:ve.special?"":b,onChange:$=>{le("special"),v($.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[ve.special?jsxRuntime.jsx("option",{value:"",children:er("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")})]})]}),b!=="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:`${ie}-by`,children:a("dialogs.paragraph.by")}),jsxRuntime.jsx("input",{id:`${ie}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:ve.special?"":editor.twipsToInches(P),placeholder:ve.special?er("special"):void 0,onChange:$=>{le("special"),T(Math.max(0,editor.inchesToTwips(Number($.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")}),ce.length===0?jsxRuntime.jsx("div",{className:"docx-dialog__note",children:a(ve.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):ce.map($=>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($.positionTwips)})}),jsxRuntime.jsx("span",{className:"docx-dialog__tab-description",children:a(editor.TAB_ALIGNMENT_LABELS[$.alignment])}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>A(ce.filter(Ce=>Ce!==$)),"aria-label":a("dialogs.paragraph.tabRemoveAt",{position:editor.formatInches($.positionTwips)}),children:a("dialogs.paragraph.tabRemove")})]},$.positionTwips)),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsxRuntime.jsx("input",{id:`${ie}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:editor.twipsToInches(fe),onChange:$=>Z(Math.max(0,editor.inchesToTwips(Number($.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:`${ie}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxRuntime.jsxs("select",{id:`${ie}-tabAlignment`,className:"docx-dialog__input",value:de,onChange:$=>Re($.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:`${ie}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxRuntime.jsxs("select",{id:`${ie}-tabLeader`,className:"docx-dialog__input",value:Ae,onChange:$=>ft($.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:yn,children:a("dialogs.paragraph.tabAdd")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{nt($=>({...$,tabStops:false})),ae(true),A([]);},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")}),Ke("spaceBefore",C,E,"spaceBefore"),Ke("spaceAfter",S,k,"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:`${ie}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxRuntime.jsxs("select",{id:`${ie}-lineSpacing`,className:"docx-dialog__input",value:ve.lineSpacing?"":w,onChange:$=>{let Ce=$.target.value;le("lineSpacing"),I(Ce),N(Ce===Ft.current?.lineRule?Ft.current.lineValue:Ce==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[ve.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:`${ie}-at`,children:a("dialogs.paragraph.at")}),jsxRuntime.jsx("input",{id:`${ie}-at`,type:"number",className:"docx-dialog__input",min:.01,step:w==="multiple"?.01:1,value:ve.lineSpacing?"":O,disabled:ve.lineSpacing,onChange:$=>{let Ce=$.target.value.trim();N(Ce===""?w==="multiple"?1.08:12:Number(Ce)||0);},"aria-label":a("dialogs.paragraph.at")}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:w==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),xe("contextualSpacing",B,F),jsxRuntime.jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),xe("keepNext",D,R),xe("widowControl",ee,Y),xe("keepLines",z,V),xe("pageBreakBefore",q,G)]})]})}),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:at?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:Lo,children:a("dialogs.paragraph.ok")})]})]}),children:n})})}var Eo=St();function Vw(){return Eo.useState()}var qo=Object.assign($w,{Header:Eo.Header,Title:Eo.Title,Body:Eo.Body,Footer:Eo.Footer,Apply:Eo.Apply,Cancel:Eo.Cancel,Error:Eo.Error,Field:Eo.Field});var no=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var qu=["ASAP","CONFIDENTIAL","COPY","DO NOT COPY","DRAFT","ORIGINAL","PERSONAL","SAMPLE","TOP SECRET","URGENT"],Uu=[null,.5,1,1.5,2,5],zu=[null,36,40,44,48,54,60,66,72,80,90,96,105,120,144],rh="image/png,image/jpeg,image/gif,image/bmp,image/webp",$u={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"},as=/^[0-9A-Fa-f]{6}$/;function nh(e,t){let o={...$u};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&&as.test(e.color)?e.color.toUpperCase():o.color,layout:e.layout??o.layout}:o}function ah(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 ih=e=>`#${as.test(e)?e.toLowerCase():"c0c0c0"}`;function lh(e){let t=e.startsWith("#")?e.slice(1):e;return as.test(t)?t.toUpperCase():null}var Vu=e=>Math.round(Math.min(1,Math.max(0,e))*100);function Gu(e,t){let o=Number(e);return e.trim()===""||!Number.isFinite(o)?t:Math.min(100,Math.max(0,Math.round(o)))/100}function sh(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 ch(e,t){return e!==null&&t.kind==="none"?null:t}function dh(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 uh=(e,t)=>t.includes(e)?e:"",jw={pageWidthTwips:12240,pageHeightTwips:15840,marginsTwips:{top:1440,right:1440,bottom:1440,left:1440}};function is(e){let t=e&&e.pageWidthTwips>0&&e.pageHeightTwips>0?e:null,{pageWidthTwips:o,pageHeightTwips:r,marginsTwips:n}=t??jw,i=o/20,a=r/20,l=Math.max(72,(o-n.left-n.right)/20),s=Math.max(72,(r-n.top-n.bottom)/20);return {width:i,height:a,area:{x:n.left/20,y:n.top/20,width:l,height:s}}}var Qb=12,eh=[.55,1,1,.9,0,1,1,.6,0,1,.95,1,.45];function ph(e){let{area:t}=e,o=36,r=[];for(let n=0,i=t.y;i+Qb<=t.y+t.height;n++){let a=eh[n%eh.length];a>0&&r.push({x:t.x,y:i,width:t.width*a,height:Qb}),i+=o;}return r}var mh="contrast(0.157068) brightness(1.91)",ju=100,Uo=e=>Math.round(e*100)/100,fh=e=>({cx:e.area.x+e.area.width/2,cy:e.area.y+e.area.height/2});function gh(e,t=is(null)){if(e.kind!=="text")return null;let o=e.text.trim();if(o==="")return null;let r=editor.watermarkShapeBox({text:o,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,layout:e.layout},t.area);if(!r)return null;let{cx:n,cy:i}=fh(t);return {text:o,fontFamily:`"${e.fontFamily.replace(/["\\]/g,"")}", sans-serif`,fontWeight:e.bold?"bold":"normal",fontStyle:e.italic?"italic":"normal",fill:`#${as.test(e.color)?e.color.toUpperCase():"C0C0C0"}`,opacity:Uo(1-Math.min(1,Math.max(0,e.transparency))),box:{x:Uo(n-r.width/2),y:Uo(i-r.height/2),width:Uo(r.width),height:Uo(r.height)},rotation:e.layout==="diagonal"?-45:0}}var th=new WeakMap;function Yw(e){if(!e)return null;let t=th.get(e);if(t===void 0){try{t=e.createElement("canvas").getContext("2d");}catch{t=null;}th.set(e,t);}return t}function bh(e,t){let o=ju,r=Yw(t);if(r){r.font=`${e.fontStyle} ${e.fontWeight} ${o}px ${e.fontFamily}`;let n=r.measureText(e.text),i=-(n.actualBoundingBoxLeft??0),a=n.actualBoundingBoxRight??n.width,l=-(n.actualBoundingBoxAscent??0),s=n.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 hh(e,t){let{x:o,y:r,width:n,height:i}=e.box,a=n>4*7.2?7.2:0,l=i>4*3.6?3.6:0,s=(n-2*a)/(t.right-t.left),c=(i-2*l)/(t.bottom-t.top),d=o+a-t.left*s,m=r+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+n/2)} ${u(r+i/2)}) ${g}`:g}function yh(e,t=is(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:r,cy:n}=fh(t);return {x:Uo(r-o.width/2),y:Uo(n-o.height/2),width:Uo(o.width),height:Uo(o.height)}}var Xw=e=>e.editable,Jw={ok:false,code:"unsupported",reason:"editor is not ready"};function Xu(){let e=H(),t=Bt.useCallback(l=>e?.getWatermark()??null,[e]),o=W(t,sh),r=W(Xw),n=Bt.useMemo(()=>r&&e!==null&&e.can({type:"setWatermark",watermark:{text:"DRAFT"}}).ok,[e,r]),i=Bt.useCallback(()=>e?.query({type:"watermark"})??null,[e]),a=Bt.useCallback(l=>e?e.exec({type:"setWatermark",watermark:l}):Jw,[e]);return Bt.useMemo(()=>({watermark:o,isEnabled:n,read:i,apply:a}),[o,n,i,a])}var rD=e=>e.pageSetup??null,ao=St(),nD=ao.part("preview");function Th(){return ao.useState()}var vh=e=>`${Math.round(e*100)}%`;function aD(e){let[t,o]=Bt.useState(null);return Bt.useEffect(()=>{if(!e||typeof URL.createObjectURL!="function"){o(null);return}let r=URL.createObjectURL(new Blob([e]));return o(r),()=>URL.revokeObjectURL(r)},[e]),t}function iD({className:e,style:t,"data-docx-part":o,...r}){let{values:n}=Th(),i=H(),a=W(rD),l=Bt.useMemo(()=>is(a),[a]),s=aD(n.kind==="picture"?n.imageData:null),c=gh(n,l),d=s?yh(n,l):null;return jsxRuntime.jsx("div",{...r,"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:ju,fontWeight:c.fontWeight,fontStyle:c.fontStyle,fill:c.fill,fillOpacity:c.opacity,transform:hh(c,bh(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:n.washout?{filter:mh}:void 0}):null,ph(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 lD({open:e,onClose:t,presets:o=qu,className:r,style:n,children:i,preset:a=true}){let{t:l}=L(),s=H(),c=bo(e,t),{isEnabled:d,read:m,apply:u}=Xu(),g=W(no),[p,f]=Bt.useState({...$u}),[h,y]=Bt.useState([]),[x,b]=Bt.useState(null),[v,P]=Bt.useState(false),[T,C]=Bt.useState(0),E=Bt.useRef(null),S=Bt.useRef(null),k=Bt.useRef(null),w=Bt.useId(),I=Bt.useRef(false);Bt.useEffect(()=>{if(!e||g||!s){I.current=false;return}if(I.current)return;I.current=true;let _=s.getWatermark(),ae=nh(_,m());E.current=ch(_,ae),f(ae),y(s.getAvailableFonts()),b(null),P(false),C(fe=>fe+1);},[e,g,s,m]),Bt.useEffect(()=>{T!==0&&S.current?.querySelector(`input[name="${w}-kind"]:checked`)?.focus({preventScroll:true});},[T,w]);let O=Bt.useCallback((_,ae)=>{b(null),f(fe=>({...fe,[_]:ae}));},[]),N=ah(p),B=d&&N!==void 0,F=Bt.useCallback(()=>{if(!B||N===void 0)return;if(!c()){t();return}if(E.current&&dh(E.current,p)){t();return}let _=u(N);_.ok?t():b(_.reason);},[B,N,p,c,u,t]),D=Bt.useCallback(_=>{_&&(P(false),_.arrayBuffer().then(ae=>{f(fe=>({...fe,kind:"picture",imageData:new Uint8Array(ae),imageName:_.name})),b(null);}).catch(()=>P(true)));},[]);if(!e)return null;let R=p.kind==="picture",z=p.kind==="text",V=h.includes(p.fontFamily)?h:[p.fontFamily,...h],ee=p.imageData?p.imageName??l("dialogs.watermark.currentPicture"):l("dialogs.watermark.noPictureSelected"),Y=x!==null?l("dialogs.watermark.refused"):null,q=(_,ae,fe)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${w}-kind`,checked:p.kind===ae,onChange:()=>O("kind",ae)}),jsxRuntime.jsx("span",{id:`${w}-${_}-label`,children:fe})]}),G=(_,ae,fe)=>jsxRuntime.jsxs("div",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${w}-${_}`,children:ae}),fe]}),ce=(_,ae,fe)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"checkbox",disabled:!fe,checked:p[_],onChange:Z=>O(_,Z.target.checked)}),jsxRuntime.jsx("span",{children:ae})]}),A={values:p,setValue:O,errors:Y?{form:Y}:{},isEnabled:B,apply:F,cancel:t};return jsxRuntime.jsx(Be,{kind:"watermark",className:r,style:n,panelRef:S,label:l("dialogs.watermark.title"),onClose:t,onKeyDown:_=>{let ae=_.target;_.key==="Enter"&&editor.isHTMLElementNode(ae)&&ae.localName==="input"&&(ae.type==="text"||ae.type==="number")&&B&&(_.preventDefault(),F());},children:jsxRuntime.jsx(ao.Composition,{state:A,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(iD,{"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:()=>{O("kind","picture"),k.current?.click();},children:l("dialogs.watermark.selectPicture")}),jsxRuntime.jsx("span",{className:"docx-dialog__hint","data-docx-watermark-picture":"",children:v?l("dialogs.watermark.pictureFailed"):ee}),jsxRuntime.jsx("input",{ref:k,type:"file",accept:rh,hidden:true,"aria-label":l("dialogs.watermark.selectPicture"),onChange:_=>{let ae=_.target.files?.[0];_.target.value="",D(ae);}})]}),G("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:_=>O("scale",_.target.value==="auto"?null:Number(_.target.value)),children:[Uu.map(_=>jsxRuntime.jsx("option",{value:_===null?"auto":String(_),children:_===null?l("dialogs.watermark.auto"):vh(_)},String(_))),p.scale!==null&&!Uu.includes(p.scale)?jsxRuntime.jsx("option",{value:String(p.scale),children:vh(p.scale)}):null]})),ce("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:[G("preset",l("dialogs.watermark.preset"),jsxRuntime.jsxs("select",{id:`${w}-preset`,className:"docx-dialog__select",disabled:!z,value:uh(p.text,o),onChange:_=>{_.target.value!==""&&O("text",_.target.value);},children:[jsxRuntime.jsx("option",{value:"",children:l("dialogs.watermark.custom")}),o.map(_=>jsxRuntime.jsx("option",{value:_,children:_},_))]})),G("text",l("dialogs.watermark.textLabel"),jsxRuntime.jsx("input",{id:`${w}-text`,type:"text",className:"docx-dialog__input",disabled:!z,maxLength:256,value:p.text,onChange:_=>O("text",_.target.value)})),G("fontFamily",l("dialogs.watermark.font"),jsxRuntime.jsx("select",{id:`${w}-fontFamily`,className:"docx-dialog__select",disabled:!z,value:p.fontFamily,onChange:_=>O("fontFamily",_.target.value),children:V.map(_=>jsxRuntime.jsx("option",{value:_,children:_},_))})),G("fontSizePt",l("dialogs.watermark.size"),jsxRuntime.jsxs("select",{id:`${w}-fontSizePt`,className:"docx-dialog__select",disabled:!z,value:p.fontSizePt===null?"auto":String(p.fontSizePt),onChange:_=>O("fontSizePt",_.target.value==="auto"?null:Number(_.target.value)),children:[zu.map(_=>jsxRuntime.jsx("option",{value:_===null?"auto":String(_),children:_===null?l("dialogs.watermark.auto"):String(_)},String(_))),p.fontSizePt!==null&&!zu.includes(p.fontSizePt)?jsxRuntime.jsx("option",{value:String(p.fontSizePt),children:p.fontSizePt}):null]})),jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[ce("bold",l("dialogs.watermark.bold"),z),ce("italic",l("dialogs.watermark.italic"),z)]}),G("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:!z,"aria-label":l("dialogs.watermark.transparency"),value:Vu(p.transparency),onChange:_=>O("transparency",Gu(_.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:!z,value:Vu(p.transparency),onChange:_=>O("transparency",Gu(_.target.value,p.transparency))}),jsxRuntime.jsx("span",{className:"docx-dialog__unit",children:"%"})]})),G("color",l("dialogs.watermark.color"),jsxRuntime.jsx("input",{id:`${w}-color`,type:"color",className:"docx-dialog__color",disabled:!z,value:ih(p.color),onChange:_=>{let ae=lh(_.target.value);ae&&O("color",ae);}})),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(_=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:`${w}-layout`,disabled:!z,checked:p.layout===_,onChange:()=>O("layout",_)}),jsxRuntime.jsx("span",{children:l(`dialogs.watermark.${_}`)})]},_))]})]})]})]})}),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",...x?{title:x}:{},children:Y}),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 Ur=Object.assign(lD,{Header:ao.Header,Title:ao.Title,Body:ao.Body,Preview:nD,Footer:ao.Footer,Apply:ao.Apply,Cancel:ao.Cancel,Error:ao.Error,Field:ao.Field});var ss={ok:false,code:"unsupported",reason:"editor is not ready"},cD=Object.freeze([]);function ep(e,t){return e.length===t.length&&e.every((o,r)=>o.name===t[r].name&&o.order===t[r].order&&o.story===t[r].story&&o.empty===t[r].empty&&o.atSelection===t[r].atSelection&&o.duplicates===t[r].duplicates&&o.hidden===t[r].hidden&&o.place===t[r].place)}function tp(){let e=H(),t=Bt.useCallback(c=>e?.query({type:"bookmarks"})??cD,[e]),o=W(t,ep),r=Bt.useCallback(c=>c.editable&&e!==null&&e.can({type:"insertBookmark",name:"Bookmark"}).ok,[e]),n=W(r),i=Bt.useCallback(c=>e?e.exec({type:"insertBookmark",name:c}):ss,[e]),a=Bt.useCallback(c=>e?e.exec({type:"deleteBookmark",name:c}):ss,[e]),l=Bt.useCallback(c=>e?e.exec({type:"goToBookmark",name:c}):ss,[e]),s=Bt.useCallback(c=>e?e.exec({type:"keepFirstBookmark",name:c}):ss,[e]);return Bt.useMemo(()=>({bookmarks:o,isWritable:n,insert:i,remove:a,goTo:l,keepFirst:s}),[o,n,i,a,l,s])}var Sh={empty:"dialogs.bookmark.nameEmpty",tooLong:"dialogs.bookmark.nameTooLong",invalidStart:"dialogs.bookmark.nameInvalidStart",invalidCharacter:"dialogs.bookmark.nameInvalidCharacter"};function gD(e){return e.open?jsxRuntime.jsx(bD,{...e}):null}function bD({open:e,onClose:t,className:o,style:r,children:n,preset:i=true}){let{t:a}=L(),l=bo(e,t),{bookmarks:s,isWritable:c,insert:d,remove:m,goTo:u,keepFirst:g}=tp(),[p,f]=Bt.useState(()=>editor.bookmarkDialogInitialName(s)),[h,y]=Bt.useState("name"),[x,b]=Bt.useState(false),[v,P]=Bt.useState(false),[T,C]=Bt.useState(false),[E,S]=Bt.useState(false),k=Bt.useRef(null),w=Bt.useRef(null),I=Bt.useId(),O=Bt.useId(),N=Bt.useId(),B=editor.bookmarkDialogRows(s,{sortBy:h,showHidden:x}),F=editor.bookmarkDialogNameState(s,p,c),D=F.problem&&!F.existing&&(T||p.length>0)?F.problem:null,R=F.existing?.duplicates??0,z=v?a("dialogs.bookmark.refused"):D?a(Sh[D]):R>0?a("dialogs.bookmark.duplicates",{count:R}):F.existing&&F.canAdd?a("dialogs.bookmark.nameExists"):null,V=Bt.useCallback(()=>{if(C(true),!F.canAdd)return;if(!l()){t();return}let A=d(p);P(!A.ok),A.ok&&t();},[F.canAdd,l,d,p,t]),ee=Bt.useCallback(()=>{if(!F.canDelete||!F.existing)return;let A=m(F.existing.name);P(!A.ok),A.ok&&f("");},[F,m]),Y=Bt.useCallback(()=>{if(!F.canGoTo||!F.existing)return;let A=u(F.existing.name);P(!A.ok),A.ok&&S(true);},[F,u]),q=Bt.useCallback(()=>{let A=F.existing;!A||!c||P(!g(A.name).ok);},[F.existing,c,g]),G=F.existing?.name??"";Bt.useLayoutEffect(()=>{!G&&w.current&&(w.current.selectedIndex=-1);});let ce={values:{name:p,sortBy:h,showHidden:x},setValue(A,_){A==="name"?f(_):A==="sortBy"?y(_):b(_),P(false);},errors:D?{name:a(Sh[D])}:v?{form:a("dialogs.bookmark.refused")}:{},isEnabled:F.canAdd,apply:V,cancel:t,rows:B,canDelete:F.canDelete,canGoTo:F.canGoTo,duplicates:R,remove:ee,goTo:Y,keepFirst:q};return jsxRuntime.jsx(Be,{kind:"bookmark",className:o,style:r,panelRef:k,label:a("dialogs.bookmark.title"),onClose:t,onKeyDown:A=>{A.key==="Enter"&&!A.nativeEvent.isComposing&&A.keyCode!==229&&editor.isHTMLElementNode(A.target)&&A.target.localName==="input"&&A.target.getAttribute("type")==="text"&&(A.preventDefault(),V());},children:jsxRuntime.jsx(Ht.Composition,{state:ce,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:I,children:a("dialogs.bookmark.name")}),jsxRuntime.jsx("input",{id:I,type:"text",className:"docx-dialog__input",value:p,maxLength:40,autoComplete:"off",spellCheck:false,"aria-invalid":D?true:void 0,"aria-describedby":O,onChange:A=>ce.setValue("name",A.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:G,"aria-label":a("dialogs.bookmark.list"),onChange:A=>ce.setValue("name",A.target.value),onDoubleClick:Y,children:B.map(A=>jsxRuntime.jsx("option",{value:A.name,children:A.name},A.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(A=>jsxRuntime.jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsxRuntime.jsx("input",{type:"radio",name:N,checked:h===A,onChange:()=>ce.setValue("sortBy",A)}),a(A==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},A))]}),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:x,onChange:A=>ce.setValue("showHidden",A.target.checked)}),a("dialogs.bookmark.showHidden")]})}),jsxRuntime.jsxs("div",{className:"docx-dialog__row docx-bookmark-dialog__status",children:[jsxRuntime.jsx("span",{id:O,"data-docx-part":"error",role:"status",className:D||v?"docx-dialog__error":"docx-dialog__hint",children:z}),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:ee,children:a("dialogs.bookmark.delete")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"goto",disabled:!F.canGoTo,onClick:Y,children:a("dialogs.bookmark.goTo")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a(E?"common.close":"common.cancel")})]})]}),children:n})})}var Ht=St();function hD(){return Ht.useState()}var ei=Object.assign(gD,{Header:Ht.Header,Title:Ht.Title,Body:Ht.Body,Footer:Ht.Footer,Apply:Ht.Apply,Cancel:Ht.Cancel,Error:Ht.Error,Field:Ht.Field,Delete:Ht.part("delete"),GoTo:Ht.part("goto"),KeepFirst:Ht.part("keepfirst")});var kh=editor.SPLIT_CELL_FALLBACK_MAX;function PD(e){return e.open?jsxRuntime.jsx(wD,{...e}):null}var kD=e=>e;function wD({open:e,onClose:t,className:o,style:r,children:n,preset:i=true}){let{t:a}=L(),l=H(),s=bo(e,t),c=Bt.useMemo(()=>l?.query({type:"splitCellConfig"})??null,[l]),[d]=Bt.useState(()=>editor.initialSplitCellCounts(c,F=>l?l.can(F):{ok:false,code:"unsupported",reason:""})),[m,u]=Bt.useState(d.columns),[g,p]=Bt.useState(d.rows),[f,h]=Bt.useState(null),y=Bt.useId(),x=Bt.useId(),b=Bt.useId(),{counts:v,problem:P}=editor.readSplitCellCounts(m,g,c),T=v?.cols??null,C=v?.rows??null;W(kD);let E=l&&v?l.can({type:"splitCell",...v}):null,S=P?.kind==="range"?a("dialogs.splitCell.range",{max:P.max}):P?.kind==="oneCell"?a("dialogs.splitCell.oneCell"):E&&!E.ok?i18n.localizeDisabledReason(E.reason??null,a):null,k=E?.ok===true,w=f??S,I=P?.kind==="range"?P.field:null,O=Bt.useCallback(()=>{if(!k||!l)return;if(!s()){t();return}let F=l.exec({type:"splitCell",rows:C,cols:T});F.ok?t():h(i18n.localizeDisabledReason(F.reason??null,a));},[k,l,s,t,C,T,a]),N={values:{columns:m,rows:g},setValue(F,D){F==="columns"?u(D):p(D),h(null);},errors:w?{form:w}:{},isEnabled:k,apply:O,cancel:t,limits:c},B=(F,D,R,z,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:z,"aria-invalid":I===F?true:void 0,"aria-describedby":b,onChange:ee=>N.setValue(F,ee.target.value)})]});return jsxRuntime.jsx(Be,{kind:"splitCell",className:o,style:r,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(),O());},children:jsxRuntime.jsx(So.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??kh),B("rows",x,"dialogs.splitCell.rows",g,c?.maxRows??kh),jsxRuntime.jsx("div",{className:"docx-dialog__row",children:jsxRuntime.jsx("span",{id:b,"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:!k,onClick:O,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:n})})}var So=St();function DD(){return So.useState()}var ti=Object.assign(PD,{Header:So.Header,Title:So.Title,Body:So.Body,Footer:So.Footer,Apply:So.Apply,Cancel:So.Cancel,Error:So.Error,Field:So.Field});var wh=Bt.createContext(void 0),Dh=wh.Provider;function Qe(){let e=Bt.useContext(wh),{t}=L();return Bt.useCallback((o,r)=>{let n=e?.(o,r);return n===void 0||n===o?t(o,r):n},[e,t])}var Po=St();function LD(){return Po.useState()}function HD({session:e,...t}){let[o,r]=Bt.useState(e),[n,i]=Bt.useState(0);return o!==e&&(r(e),i(n+1)),e?jsxRuntime.jsx(AD,{session:e,...t},n):null}function AD({session:e,children:t,preset:o,className:r,style:n}){let i=Qe(),a=W(()=>e.canApply()),[l,s]=Bt.useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=Bt.useState(e.signal.aborted),[m,u]=Bt.useState(false);Bt.useEffect(()=>{let x=()=>d(true);return e.signal.addEventListener("abort",x),e.signal.aborted&&x(),()=>e.signal.removeEventListener("abort",x)},[e]);let g=()=>{if(e.signal.aborted)return;let x=Number.isInteger(l.maxLength)&&l.maxLength>=0&&l.maxLength<=32767&&e.apply(l.defaultText,{type:l.type,maxLength:l.maxLength,format:l.format,enabled:l.enabled});u(!x);},p={values:l,setValue(x,b){s(v=>({...v,[x]:b,...x==="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]??[],h={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},y=(x,b)=>jsxRuntime.jsxs("label",{"data-docx-part":"field","data-docx-field":x,className:"docx-dialog__row",children:[jsxRuntime.jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${x}`)}),b]});return jsxRuntime.jsx(Be,{kind:"textFormField",className:r,style:n,label:i("textFormField.title"),onClose:e.cancel,dismissOutside:false,sessionSignal:e.signal,restoreFocus:false,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),e.cancel()),x.key==="Enter"&&editor.isHTMLElementNode(x.target)&&x.target.localName==="input"&&(x.preventDefault(),g());},children:jsxRuntime.jsx(Po.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:x=>p.setValue("defaultText",x.target.value)})),y("type",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:x=>p.setValue("type",x.target.value),children:[["regular","number","date"].map(x=>jsxRuntime.jsx("option",{value:x,children:i(`textFormField.${x}`)},x)),Object.hasOwn(editor.TEXT_FORM_FORMATS,l.type)?null:jsxRuntime.jsx("option",{value:l.type,disabled:true,children:i("textFormField.preservedType")})]})),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:x=>p.setValue("maxLength",x.target.valueAsNumber)})),y("format",jsxRuntime.jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:x=>p.setValue("format",x.target.value),children:[f.map(x=>jsxRuntime.jsx("option",{value:x,children:h[x]?i(h[x]):x||i("textFormField.noFormat")},x)),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:x=>p.setValue("enabled",x.target.checked)}),i("textFormField.enabled")]})]}),jsxRuntime.jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsxRuntime.jsx("span",{"data-docx-part":"error",className:"docx-dialog__error",role:"alert",children:p.errors.form}),jsxRuntime.jsx("button",{"data-docx-part":"cancel",className:"docx-dialog__button",type:"button",onClick:e.cancel,children:i("textFormField.cancel")}),jsxRuntime.jsx("button",{disabled:!a,"data-docx-part":"apply",className:"docx-dialog__button docx-dialog__apply",type:"button",onClick:g,children:i("textFormField.apply")})]})]}),children:t})})}var ri=Object.assign(HD,{Header:Po.Header,Title:Po.Title,Body:Po.Body,Footer:Po.Footer,Apply:Po.Apply,Cancel:Po.Cancel,Error:Po.Error,Field:Po.Field});var _h=Bt.createContext(null),ko=()=>Bt.useContext(_h);function Ih({popups:e,children:t}){let o=H(),r=Ld(),[n,i]=Bt.useState(null),[a,l]=Bt.useState(null),[s,c]=Bt.useState(null),[d,m]=Bt.useState(null),u=Bt.useRef(d);u.current=d;let g=Bt.useRef(e);g.current=e;let p=Bt.useRef(null),f=Bt.useRef(s);f.current=s;let h=()=>l(null);Bt.useEffect(()=>{if(a!==null)return;let P=p.current;p.current=null,P?.isConnected&&P.focus({preventScroll:true});},[a]),Bt.useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(P){if(g.current?.textFormField===false){P.cancel();return}u.current?.cancel(),l(null),c(P),P.signal.addEventListener("abort",()=>c(T=>T===P?null:T),{once:true});}},{fallback:true})},[o]),Bt.useEffect(()=>{if(!o||!n&&e?.revisionMarkup!==false)return;let P=o.setRevisionMarkupChrome({onRequest(T){if(g.current?.revisionMarkup===false){T.cancel();return}f.current?.cancel(),l(null),m(T),T.signal.addEventListener("abort",()=>m(C=>C===T?null:C),{once:true});}},{fallback:true});return ()=>{u.current?.cancel(),P();}},[o,n,e?.revisionMarkup===false]),Bt.useEffect(()=>{l(null),c(null),m(null);},[o,r]);let y=e?.bookmark===false;Bt.useEffect(()=>{if(!(!o||!n||y))return o.setBookmarkChrome({onRequest(){f.current?.cancel(),u.current?.cancel(),p.current=KD(n.ownerDocument.activeElement),l("bookmark");}})},[o,n,y]),Bt.useEffect(()=>{e?.revisionMarkup===false&&u.current?.cancel(),e?.textFormField===false&&f.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let x=Bt.useMemo(()=>({container:n,setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(P,T){f.current?.cancel(),u.current?.cancel(),g.current?.[P]!==false&&(p.current=T??n?.ownerDocument.activeElement,l(P));}}),[n,e?.pageSetup]),b={open:true,onClose:h},v=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?Se(e.pageSetup,b):jsxRuntime.jsx(qr,{...b}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Se(e.paragraph,b):jsxRuntime.jsx(qo,{...b}):a==="watermark"&&e?.watermark!==false?e?.watermark?Se(e.watermark,b):jsxRuntime.jsx(Ur,{...b}):a==="bookmark"&&e?.bookmark!==false?e?.bookmark?Se(e.bookmark,b):jsxRuntime.jsx(ei,{...b}):a==="splitCell"&&e?.splitCell!==false?e?.splitCell?Se(e.splitCell,b):jsxRuntime.jsx(ti,{...b}):d&&e?.revisionMarkup!==false?e?.revisionMarkup?Se(e.revisionMarkup,{session:d},d):jsxRuntime.jsx(Ia,{session:d}):s&&e?.textFormField!==false?e?.textFormField?Se(e.textFormField,{session:s},s):jsxRuntime.jsx(ri,{session:s}):null;return jsxRuntime.jsxs(_h.Provider,{value:x,children:[t,n?reactDom.createPortal(v,n):null]})}function KD(e){return e?.closest("[data-menu]")?.querySelector(':scope > [role="menuitem"]')??e}function Nh(){let e=ko();return jsxRuntime.jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer,dir:it()})}function Fh({children:e}){let t=ko();return t?.container?reactDom.createPortal(e,t.container):e}var Lh=["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"],Hh=["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"],np=["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"],ap=["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"],Ah=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],Oh=["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"],Bh=["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 Un(e,t,o){return Object.assign(({icon:n,labelKey:i,shortcutKey:a,className:l,hidden:s})=>{let c=H(),{close:d}=Zo(),m=Pe(),{isEnabled:u,disabledReason:g}=oe(t);return s?null:jsxRuntime.jsx(we,{slot:e,icon:n??re(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 ni=Un("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:Lh}),ai=Un("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:Hh}),ii=Un("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:ap}),li=Un("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:Bh});function zn({icon:e,labelKey:t,shortcutKey:o,className:r,hidden:n}){let i=H(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=Zo(),c=ke(),d=Pe(),m=Bt.useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:u,disabledReason:g}=oe(m);if(n)return null;let p=l!==null;return jsxRuntime.jsx(we,{slot:"edit.paste",icon:e??re(np),shortcut:d(o??"contextMenu.pasteShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let{text:f,html:h}=await zD(c);(f||h)&&i?.exec({type:"paste",text:f,...h?{html:h}:{}});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...r?{className:r}:{},children:d(t??"contextMenu.paste")})}zn.docxRow="edit.paste";async function zD(e){let t=editor.hostWindowOf(e),o=t.navigator.clipboard;if(typeof o.read=="function"&&typeof t.ClipboardItem<"u")try{let r=await o.read(),n="",i=null;for(let a of r)a.types.includes("text/plain")&&(n=await(await a.getType("text/plain")).text()),a.types.includes("text/html")&&(i=await(await a.getType("text/html")).text());if(n||i)return {text:n,html:i}}catch{}return {text:await o.readText(),html:null}}function $n({icon:e,labelKey:t,shortcutKey:o,className:r,hidden:n}){let i=H(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=Zo(),c=ke(),d=Pe(),m=Bt.useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:u,disabledReason:g}=oe(m);if(n)return null;let p=l!==null;return jsxRuntime.jsx(we,{slot:"edit.pasteWithoutFormatting",icon:e??re(np),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");}})();},...r?{className:r}:{},children:d(t??"contextMenu.pasteWithoutFormatting")})}$n.docxRow="edit.pasteWithoutFormatting";var Zh=Q("format.painter")?.paths??[],fs=Un("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:Zh}),gs=Un("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:Zh});function zo(e,t,o){return Object.assign(({icon:n,labelKey:i,className:a,hidden:l,destructive:s})=>{let{close:c}=Zo(),d=Pe(),m=si(),{isEnabled:u,disabledReason:g,execute:p}=oe(t);return l||!m?null:jsxRuntime.jsx(we,{slot:e,icon:n??re(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 Vn=zo("table.selectTable",{type:"selectTableRegion",region:"table"},{labelKey:"table.selectTable",paths:editor.tableChromeIconPaths("select_all")}),Gn=zo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:editor.tableChromeIconPaths("table_rows")}),jn=zo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:editor.tableChromeIconPaths("table_rows")}),Yn=zo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:editor.tableChromeIconPaths("view_column")}),Xn=zo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:editor.tableChromeIconPaths("view_column")}),Jn=zo("table.mergeCells",{type:"mergeCells"},{labelKey:"table.mergeCells",paths:editor.tableChromeIconPaths("call_merge")}),Qn=Object.assign(({icon:e,labelKey:t,className:o,hidden:r})=>{let{close:n}=Zo(),i=Pe(),a=si(),l=ko(),{isEnabled:s,disabledReason:c}=oe("table.splitCell");return r||!a||!l?null:jsxRuntime.jsx(we,{slot:"table.splitCell",icon:e??re(editor.tableChromeIconPaths("call_split")),disabled:!s,...c?{title:c}:{},...o?{className:o}:{},onSelect:()=>{n(true),l.open("splitCell");},children:i(t??"table.splitCell")})},{docxRow:"table.splitCell"}),ea=zo("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:editor.tableChromeIconPaths("delete_sweep"),destructive:true}),ta=zo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:editor.tableChromeIconPaths("view_column"),destructive:true}),oa=zo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:editor.tableChromeIconPaths("delete"),destructive:true}),$D=[{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 $r({hidden:e}){let{close:t}=Zo(),o=Pe(),r=si(),n=oe({type:"setTableCellVerticalAlignment",alignment:"top"}),i=oe({type:"setTableCellVerticalAlignment",alignment:"center"}),a=oe({type:"setTableCellVerticalAlignment",alignment:"bottom"}),l=[n,i,a];return e||!r?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:$D.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:re(editor.tableChromeIconPaths(s.icon))},s.alignment)})})]})}$r.docxRow="table.cellVerticalAlignment";var Kh=e=>e?{tocId:e}:{},qh=e=>t=>({type:"refreshToc",mode:e,...Kh(t)}),VD=e=>({type:"removeToc",...Kh(e)});function lp(e,t,o){return Object.assign(({icon:n,labelKey:i,className:a,hidden:l})=>{let s=H(),{close:c,tocId:d}=Zo(),m=Pe(),u=Bt.useMemo(()=>t(d),[d]),{isEnabled:g,disabledReason:p}=oe(u);return l||d===null?null:jsxRuntime.jsx(we,{slot:e,icon:n??re(o.paths),disabled:!g,...p?{title:p}:{},onSelect:()=>{s?.exec(u),c(true);},...a?{className:a}:{},children:m(i??o.labelKey)})},{docxRow:e})}var ra=lp("toc.refresh",qh("entire"),{labelKey:"toc.refresh",paths:Ah}),na=lp("toc.refreshPageNumbers",qh("pageNumbers"),{labelKey:"toc.refreshPageNumbers",paths:Oh}),aa=lp("toc.remove",VD,{labelKey:"toc.remove",paths:ap});function si(){return W(Bt.useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function bs({label:e,icon:t,shortcut:o,disabled:r,disabledReason:n,active:i,onSelect:a,className:l}){let{close:s}=Zo();return jsxRuntime.jsx(we,{...t?{icon:t}:{},...o?{shortcut:o}:{},...r?{disabled:r}:{},...r&&n?{title:n}:{},...i!==void 0?{active:i}:{},onSelect:()=>{a?.(),s(true);},...l?{className:l}:{},children:e})}var di=8;function JD(){let e=Bt.useContext(Lt),t=Je(),o=Pe(),{isEnabled:r,reason:n}=Wl(o);if((e?.mounted??0)===0)return null;let i=Q("review.addComment");return jsxRuntime.jsx(we,{icon:re(i?.paths),slot:"review.addComment",disabled:!r,title:n??void 0,onSelect:()=>{e?.requestCommentDraft()&&t.setOpenMenu(null);},children:o("comments.addComment")})}function QD(){let e=H(),t=Je(),o=Pe();return e?.can({type:"editTextFormField"}).ok?jsxRuntime.jsx(we,{slot:"field.edit",onSelect:()=>{t.setOpenMenu(null),e.exec({type:"editTextFormField"});},children:o("textFormField.edit")}):null}var eR=[{kind:"row",id:"field.edit",render:()=>jsxRuntime.jsx(QD,{})},{kind:"row",id:"edit.cut",render:()=>jsxRuntime.jsx(ni,{})},{kind:"row",id:"edit.copy",render:()=>jsxRuntime.jsx(ai,{})},{kind:"row",id:"edit.paste",render:()=>jsxRuntime.jsx(zn,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsxRuntime.jsx($n,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsxRuntime.jsx(fs,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsxRuntime.jsx(gs,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsxRuntime.jsx(ii,{})},{kind:"row",id:"edit.selectAll",render:()=>jsxRuntime.jsx(li,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsxRuntime.jsx(Jl,{shortcutKey:"contextMenu.insertLinkShortcut"})},{kind:"row",id:"review.addComment",render:()=>jsxRuntime.jsx(JD,{})}];function tR(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Vn.docxRow,render:()=>jsxRuntime.jsx(Vn,{})},{kind:"row",id:Gn.docxRow,render:()=>jsxRuntime.jsx(Gn,{})},{kind:"row",id:jn.docxRow,render:()=>jsxRuntime.jsx(jn,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:Yn.docxRow,render:()=>jsxRuntime.jsx(Yn,{})},{kind:"row",id:Xn.docxRow,render:()=>jsxRuntime.jsx(Xn,{})},{kind:"separator",id:"sep.table.cells"},{kind:"row",id:Jn.docxRow,render:()=>jsxRuntime.jsx(Jn,{})},{kind:"row",id:Qn.docxRow,render:()=>jsxRuntime.jsx(Qn,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:ea.docxRow,render:()=>jsxRuntime.jsx(ea,{})},{kind:"row",id:ta.docxRow,render:()=>jsxRuntime.jsx(ta,{})},{kind:"row",id:oa.docxRow,render:()=>jsxRuntime.jsx(oa,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:$r.docxRow,render:()=>jsxRuntime.jsx($r,{})}]}function oR(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:ra.docxRow,render:()=>jsxRuntime.jsx(ra,{})},{kind:"row",id:na.docxRow,render:()=>jsxRuntime.jsx(na,{})},{kind:"row",id:aa.docxRow,render:()=>jsxRuntime.jsx(aa,{})}]}function rR(e,t=false){return [...eR,...e?tR():[],...t?oR():[]]}function jh(e){if(!Bt.isValidElement(e))return null;let t=Mn(e,jh);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 r=es(e.props);if(r)return r}return null}function Vh(e){if(!Bt.isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function nR(e){return e?.closest(".docx-editor__scroll-container")??null}function ui({className:e,t,preset:o=true,disabled:r,onOpenChange:n,children:i}){let a=qt(),l=it(),s=H(),{t:c}=L(),d=si(),m=Bt.useRef(null),u=Bt.useRef(null),[g,p]=Bt.useState(null),[f,h]=Bt.useState(null),[y,x]=Bt.useState(null),b=Bt.useMemo(()=>rR(d,f!==null),[d,f]),[v,P]=Bt.useState(null),T=Bt.useCallback((N=false)=>{p(null),P(null),h(null),x(null),N&&s?.focus();},[s]);Bt.useEffect(()=>{if(r)return;let N=nR(m.current);if(!N)return;let B=F=>{if(u.current?.contains(F.target)){F.preventDefault();return}if(!ub(N,F.target))return;F.preventDefault();let D=F.button===-1||F.clientX===0&&F.clientY===0,R=N.getBoundingClientRect();h(s?.snapshot().tocContext?.id??null),x(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)},[r,s]),Bt.useEffect(()=>{r&&T();},[r,T]),Bt.useEffect(()=>{if(!g)return;let N=z=>{u.current?.contains(z.target)||T();},B=z=>{z.key==="Escape"?(z.preventDefault(),T(true)):z.key==="Tab"&&T();},F=()=>T(),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,T]),Bt.useLayoutEffect(()=>{let N=u.current;if(!g||!N)return;let{width:B,height:F}=N.getBoundingClientRect(),D=editor.hostWindowOf(N),R=D.innerWidth-B-di,z=D.innerHeight-F-di,ee=D.getComputedStyle(N).direction==="rtl"?g.x-B>=di:g.x>R,Y=Math.max(di,Math.min(ee?g.x-B:g.x,R)),q=Math.max(di,g.y>z?g.y-F:g.y);P({x:Y,y:q});},[g]),Bt.useLayoutEffect(()=>{v&&u.current?.focus({preventScroll:true});},[v]);let C=Bt.useRef(n);C.current=n;let E=Bt.useRef(false);Bt.useEffect(()=>{let N=g!==null;N!==E.current&&(E.current=N,C.current?.(N));},[g]);let S=Bt.useMemo(()=>({t,openMenu:null,setOpenMenu:()=>T(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,T]),[k,w]=Bt.useState(null),I=Bt.useMemo(()=>({close:T,anchor:g,tocId:f,target:y,clipboardRefusal:k,reportClipboardRefusal:w}),[T,g,f,y,k]),O={position:"fixed",left:(v??g)?.x??0,top:(v??g)?.y??0,visibility:v?"visible":"hidden"};return jsxRuntime.jsx("div",{ref:m,style:{display:"contents"},children:g?jsxRuntime.jsx($a.Provider,{value:S,children:jsxRuntime.jsx(ts.Provider,{value:I,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:O,onKeyDown:N=>{let B=u.current;if(!B)return;let F=Wr(B);N.key==="ArrowDown"?(N.preventDefault(),Qt(F,editor.hostDocumentOf(B).activeElement,1)):N.key==="ArrowUp"?(N.preventDefault(),Qt(F,editor.hostDocumentOf(B).activeElement,-1)):N.key==="Home"?(N.preventDefault(),eo(F,"first")):N.key==="End"&&(N.preventDefault(),eo(F,"last"));},children:[Bt.Children.toArray(i).filter(Vh),Bl({entries:b,children:Bt.Children.toArray(i).filter(N=>!Vh(N)),preset:o,keyOfEntry:N=>N.id,keyOfChild:N=>db(jh(N)),renderEntry:N=>N.kind==="separator"?jsxRuntime.jsx(Zr,{}):N.render(),onUnmatched:(N,B)=>{B.props.hidden&&Ng(N);}})]})})}):null})}var dp=Object.assign(ui,{Cut:ni,Copy:ai,Paste:zn,PasteWithoutFormatting:$n,Delete:ii,SelectAll:li,SelectTable:Vn,InsertRowAbove:Gn,InsertRowBelow:jn,InsertColumnLeft:Yn,InsertColumnRight:Xn,MergeCells:Jn,SplitCell:Qn,DeleteTableRow:ea,DeleteTableColumn:ta,DeleteTable:oa,CellVerticalAlignment:$r,RefreshToc:ra,RefreshTocPageNumbers:na,RemoveToc:aa,Item:bs,Slot:to,Row:we,Group:Xa,Separator:Zr,Submenu:oo});var Yh=jd.Provider;function Xh(){let e=kt(),{t}=L();return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[e?.hyperlink&&Se(e.hyperlink,{}),e?.contentControl&&Se(e.contentControl,{}),e?.equation&&Se(e.equation,{}),e?.contextMenu&&Se(e.contextMenu,{t:o=>t(o)})]})}function Jh(e,t,o,r){return {...e,hyperlink:e?.hyperlink??(t===false?false:n=>jsxRuntime.jsx(Za,{...n})),contentControl:e?.contentControl??(n=>jsxRuntime.jsx(Ua,{...n})),equation:e?.equation??(()=>jsxRuntime.jsx(za,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:n=>e.contextMenu&&Se(e.contextMenu,{...n,t:r??n.t}):o===false?false:n=>jsxRuntime.jsx(ui,{...n,t:r??n.t,...typeof o=="object"?o:{}})}}function sR(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 up(){let e=H(),t=Bt.useCallback(r=>{let n=e?.getActiveScope();return n?.kind==="note"?n:null},[e]),o=W(t,sR);return o?.kind==="note"?o:null}function Qh(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 e0(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&&Qh(e.documentAuthored,t.documentAuthored)&&Qh(e.sectionAuthored,t.sectionAuthored)}function cR(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&e0(e.footnote,t.footnote)&&e0(e.endnote,t.endnote)}function pp(){let e=H(),t=Bt.useCallback(o=>e?.getNotePropertiesState()??null,[e]);return W(t,cR)}function pi(e,t){let[o,r]=Bt.useState(null),n=Bt.useCallback(l=>r(l),[]),[i,a]=Bt.useState({visibility:"hidden"});return Bt.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 h=e(s);if(h!==m&&(u.disconnect(),u.observe(s),u.observe(o),h&&u.observe(h),m=h),!h||!h.isConnected){a({visibility:"hidden"});return}let y=h.getBoundingClientRect(),x=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,b=t==="story-label"?6:4,v=l===s,P=t==="after"?y.bottom+6:t==="story-label"?editor.storyLabelTop(y,h.closest(".docx-page")?.getBoundingClientRect().top,x,b):y.top-x-b,T=v?Pn(s,y.left,P):{left:y.left,top:P},C=T.left,E=T.top,S=v?s.scrollLeft+8:8;a({position:v?"absolute":"fixed",left:t==="story-label"?C:Math.max(S,C+8),top:t==="story-label"?E:Math.max(v?s.scrollTop+8:8,E),...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:n,style:i}}var gR=/^(footnote|endnote):(-?\d{1,10})$/;function r0(e){let t=gR.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function bR(e){let t=editor.hostWindowOf(e);return typeof t.matchMedia!="function"?false:t.matchMedia("(pointer: coarse)").matches}function fp(e){let t=H();return Bt.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 hR(e){let{t}=L(),[o,r]=Bt.useState(false),n=Bt.useRef(null);return Bt.useEffect(()=>{if(o)return editor.listenForOutsidePress({popup:n.current,close:()=>r(false)})},[o]),jsxRuntime.jsxs("div",{ref:n,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:U,onClick:()=>r(i=>!i),children:t("headerFooter.options")}),o?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:U,children:[jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-properties",onClick:()=>{e.onOpenProperties(),r(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(),r(false);},children:t("common.close")})]}):null]})}function Cs({className:e}){let t=kt(),o=Bt.useRef(null),{t:r}=L(),n=H(),i=up(),[a,l]=Bt.useState(null),[s,c]=Bt.useState(null),[d,m]=Bt.useState(false),u=Bt.useRef(null),g=Bt.useCallback(I=>{if(!i)return null;let N=[...I.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=pi(g,"story-label"),f=Bt.useCallback(()=>{u.current&&u.current.win.clearTimeout(u.current.handle),u.current=null,l(null);},[]);Bt.useEffect(()=>{if(!n)return;let I=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!I)return;let O=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),n.setActiveScope({kind:"note",id:R.dataset.docxNoteScope});return}D.closest("[data-docx-note-mark-back]")&&(F.preventDefault(),f(),c(null),n.setActiveScope({kind:"body"}));},N=F=>{let D=F,z=D.target?.closest("[data-docx-note-scope]");z?.dataset.docxNoteScope&&(D.preventDefault(),c({scopeId:z.dataset.docxNoteScope,x:D.clientX,y:D.clientY}));},B=F=>{let D=F.target;if(bR(D))return;let R=D?.closest("[data-docx-note-ref]");if(!R?.dataset.docxNoteScope){f();return}let z=R.dataset.docxNoteScope,ee=n.getNotePreviewText(z)??R.getAttribute("aria-description")??r("notes.previewFallback"),Y=R.getBoundingClientRect();u.current&&u.current.win.clearTimeout(u.current.handle);let q=editor.hostWindowOf(R),G=q.setTimeout(()=>{l({scopeId:z,text:ee,x:Y.left,y:Y.bottom+4});},400);u.current={win:q,handle:G};};return I.addEventListener("click",O),I.addEventListener("contextmenu",N),I.addEventListener("pointerover",B),I.addEventListener("scroll",f,true),()=>{I.removeEventListener("click",O),I.removeEventListener("contextmenu",N),I.removeEventListener("pointerover",B),I.removeEventListener("scroll",f,true),f();}},[n,f,r]);let h=Bt.useCallback(I=>{n&&(n.exec(I),c(null));},[n]),y=s?r0(s.scopeId):null,x=Bt.useMemo(()=>y?{type:"deleteNote",noteKind:y.noteKind,noteId:y.noteId}:null,[y]),b=Bt.useMemo(()=>y?{type:"convertNote",fromKind:y.noteKind,noteId:y.noteId}:null,[y]),v=Bt.useMemo(()=>y?{type:"convertAllNotes",fromKind:y.noteKind}:null,[y]),P=fp(x??{type:"deleteNote",noteKind:"footnote",noteId:0}),T=fp(b??{type:"convertNote",fromKind:"footnote",noteId:0}),C=fp(v??{type:"convertAllNotes",fromKind:"footnote"}),E=i?r0(i.id):null,S=E?r("notes.editingRegion",{kind:E.noteKind==="footnote"?r("notes.footnoteKind"):r("notes.endnoteKind"),number:E.noteId}):null,k=s&&y?{...s,...y,onDelete:()=>{x&&h(x);},onConvert:()=>{b&&h(b);},onConvertAll:()=>{v&&h(v);},onOpenProperties:()=>m(true),onClose:()=>c(null),deleteEnabled:P.enabled,convertEnabled:T.enabled,convertAllEnabled:C.enabled,deleteDisabledReason:P.reason??void 0,convertDisabledReason:T.reason??void 0,convertAllDisabledReason:C.reason??void 0}:null,w={onClose:()=>m(false),onApply:I=>{h(I),m(false);}};return n?jsxRuntime.jsxs("div",{className:e,ref:o,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":i?void 0:true,children:[i&&E?jsxRuntime.jsxs("div",{ref:p.ref,className:"docx-context-bar docx-notes-chrome__banner",role:"region","aria-label":r("notes.chromeAriaLabel"),"data-testid":"docx-notes-banner","data-note-scope":i.id,style:{...p.style,zIndex:vt.chrome},children:[jsxRuntime.jsx("span",{className:"docx-context-bar__title",children:S}),jsxRuntime.jsx(hR,{onOpenProperties:()=>m(true),onClose:()=>n.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Se(t.notePreview,a):jsxRuntime.jsx(En,{...a}):null,k&&t?.notesContextMenu!==false?t?.notesContextMenu?Se(t.notesContextMenu,k):jsxRuntime.jsx(Sn,{...k}):null,d&&t?.noteProperties!==false?t?.noteProperties?Se(t.noteProperties,w):jsxRuntime.jsx(Ts,{...w}):null]}):null}function Ts(e){let{t}=L(),o=H(),r=pp(),[n,i]=Bt.useState("document"),[a,l]=Bt.useState("decimal"),[s,c]=Bt.useState("continuous"),[d,m]=Bt.useState("pageBottom"),[u,g]=Bt.useState("decimal"),[p,f]=Bt.useState("continuous"),[h,y]=Bt.useState("docEnd");Bt.useEffect(()=>{r&&(l(r.footnote.resolved.numFmt),c(r.footnote.resolved.numRestart),m(r.footnote.resolved.pos),g(r.endnote.resolved.numFmt),f(r.endnote.resolved.numRestart),y(r.endnote.resolved.pos));},[r]);let x=!r?.footnote.sectionAuthored,b=!r?.endnote.sectionAuthored&&r?.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:vt.modal},onClick:e.onClose,onKeyDown:v=>{v.key==="Escape"&&e.onClose();},children:jsxRuntime.jsxs("div",{className:"docx-note-properties__panel",onClick:v=>v.stopPropagation(),onMouseDown:v=>v.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:n,onChange:v=>i(v.target.value),children:[jsxRuntime.jsx("option",{value:"document",children:t("notes.scopeDocument")}),jsxRuntime.jsx("option",{value:"section",children:t("notes.scopeSection")})]})]}),jsxRuntime.jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxRuntime.jsxs("legend",{className:"docx-note-properties__legend",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.footnotes")}),x?jsxRuntime.jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxRuntime.jsxs("div",{className:"docx-note-properties__fields",children:[jsxRuntime.jsxs("label",{className:"docx-note-properties__field",children:[jsxRuntime.jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxRuntime.jsxs("select",{className:"docx-note-properties__select",value:a,onChange:v=>l(v.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:v=>c(v.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:v=>m(v.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")}),b?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:v=>g(v.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:v=>f(v.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:h,"data-testid":"docx-notes-endnote-position",onChange:v=>y(v.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 v={type:"setNoteProperties",scope:n,sectionIndex:n==="section"?r?.sectionIndex:void 0,footnote:{numFmt:a,numRestart:s,position:d},endnote:{numFmt:u,numRestart:p,position:h}};o.can(v).ok&&e.onApply(v);},children:t("common.apply")})]})]})})}var l0=e=>e.image;function i0(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 SR(){let e=Kt(),[t,o]=Bt.useState(false);return {ref:Bt.useCallback(n=>{n&&o(!n.parentElement?.closest(e?".docx-editor.dark":".docx-editor"));},[e]),className:t?`docx-editor ${e?"dark ":""}`:""}}function PR(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function vp(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(cr(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(cr(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(cr(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(cr(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function kR(e,t){let o=vp(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function Es(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=Ga(t);return Number.isInteger(o)?o:null}function wR(e,t){let o=vp(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,m=c?Es(e.horizontalPoints):t.position?.horizontalEmu,u=d?Es(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 r=e.horizontalPoints!==o.horizontalPoints,n=e.verticalPoints!==o.verticalPoints,i=e.relativeToH!==o.relativeToH,a=e.relativeToV!==o.relativeToV,l=r?Es(e.horizontalPoints):t.position?.horizontalEmu,s=n?Es(e.verticalPoints):t.position?.verticalEmu;return r&&l===null?{ok:false}:n&&s===null?{ok:false}:{ok:true,value:{...typeof l=="number"?{horizontalEmu:l}:{},...typeof s=="number"?{verticalEmu:s}:{},...i||r||n?{relativeToH:e.relativeToH}:{},...a||r||n?{relativeToV:e.relativeToV}:{}}}}function Ss(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function Ps(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function fi({open:e,onClose:t,className:o,triggerRef:r}){let n=H(),{t:i}=L(),a=W(l0),l=Bt.useId(),s=Bt.useId(),c=Bt.useId(),d=Bt.useRef(null),m=Bt.useRef(null),u=Bt.useRef(null),g=Bt.useRef(null),[p,f]=Bt.useState(null),[h,y]=Bt.useState(null),x=SR(),b=m.current,v=b?.canCrop===false,P=b?.canResize===false,T=b?.locks.changeAspect===true,C=b?.kind==="anchored"&&b.canMove===true,E=b?.kind==="inline",S=b?.kind==="anchored"&&b.canMove===false;Bt.useEffect(()=>{if(!e){m.current=null,u.current=null,g.current=null;return}if(!a)return;if(m.current=a,n?.surface){let{anchor:z}=n.surface.state().selection;u.current={paragraphId:z.paragraphId,offset:z.offset},g.current=n.surface.session.packageRevision();}y(null);let D=vp(a),R=a.crop;f({widthPoints:String(cr(a.widthEmu)),heightPoints:String(cr(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,n]);let k=Bt.useCallback(()=>{r?.current?.focus(),n?.focus();},[n,r]),w=Bt.useCallback(()=>{t(),k();},[t,k]);Bt.useEffect(()=>{if(!e)return;let D=d.current;if(!D)return;let R=i0(D);(R.find(Y=>Y.id==="image-prop-width"&&!Y.hasAttribute("disabled"))??R.find(Y=>!Y.hasAttribute("disabled"))??D).focus();let V=Y=>{if(Y.key==="Escape"){Y.preventDefault(),w();return}if(Y.key!=="Tab")return;let q=i0(D);if(q.length===0)return;let G=editor.hostDocumentOf(D).activeElement,ce=q.findIndex(_=>_===G);if(ce===-1)return;Y.preventDefault();let A=Y.shiftKey?(ce-1+q.length)%q.length:(ce+1)%q.length;q[A]?.focus();},ee=editor.hostDocumentOf(D);return ee.addEventListener("keydown",V),()=>ee.removeEventListener("keydown",V)},[e,w]);let I=Bt.useMemo(()=>{let D=b??a;return !D||D.widthEmu<=0?1:D.widthEmu/D.heightEmu},[a,b]),O=Bt.useCallback(D=>{f(R=>{if(!R)return R;if(!R.lockAspect)return {...R,widthPoints:D};let z=Ps(D);if(z===null)return {...R,widthPoints:D};let V=Math.round(z/I*100)/100;return {...R,widthPoints:D,heightPoints:String(V)}});},[I]),N=Bt.useCallback(D=>{f(R=>{if(!R)return R;if(!R.lockAspect)return {...R,heightPoints:D};let z=Ps(D);if(z===null)return {...R,heightPoints:D};let V=Math.round(z*I*100)/100;return {...R,widthPoints:String(V),heightPoints:D}});},[I]),B=Bt.useCallback(()=>{let D=m.current;if(!D?.intrinsic)return;let R=D.intrinsic.pixelWidth*72/D.intrinsic.dpiX,z=D.intrinsic.pixelHeight*72/D.intrinsic.dpiY;f(V=>V&&{...V,widthPoints:String(Math.round(R*100)/100),heightPoints:String(Math.round(z*100)/100)});},[a]),F=Bt.useCallback(()=>{let D=m.current,R=u.current,z=g.current;if(!n||!D||!p||!R||z===null)return;let V={type:"setImageProperties",drawingNodeId:D.id,expectedPackageRevision:z,selectionParagraphId:R.paragraphId,selectionOffset:R.offset};if(!P){let A=Ps(p.widthPoints),_=Ps(p.heightPoints);if(A===null||_===null){y("imageProperties.errors.invalidDimensions");return}let ae=Ga(A),fe=Ga(_);ae!==D.widthEmu&&(V.widthEmu=ae),fe!==D.heightEmu&&(V.heightEmu=fe);}if(D.canCrop&&!v){let A=Ss(p.cropLeft),_=Ss(p.cropTop),ae=Ss(p.cropRight),fe=Ss(p.cropBottom);if(A===null||_===null||ae===null||fe===null){y("imageProperties.errors.invalidCrop");return}let Z=D.crop;(A!==Z.left||_!==Z.top||ae!==Z.right||fe!==Z.bottom)&&(V.crop={left:A,top:_,right:ae,bottom:fe});}p.title!==D.title&&(V.title=p.title),p.description!==D.description&&(V.description=p.description);let ee=p.hyperlink.trim();if(ee!==(D.hyperlink??"")&&(V.hyperlink=ee===""?null:ee),D.canChangeWrap&&p.wrap!==D.wrap&&(V.wrap=p.wrap),D.kind==="anchored"&&D.canMove&&kR(p,D)){let A=wR(p,D);if(!A.ok){y("imageProperties.errors.invalidPosition");return}if(!editor.validateDrawingPositionInput(editor.positionInputFromPropertiesCommand(A.value,D))){y("imageProperties.errors.invalidPosition");return}Object.assign(V,A.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(!n.can(V).ok){y("imageProperties.errors.refused");return}if(!n.exec(V).ok){y("imageProperties.errors.refused");return}w();},[n,p,v,P,w]);return !e||!p?null:jsxRuntime.jsx("div",{ref:x.ref,className:`${x.className}docx-dialog-overlay${o?` ${o}`:""}`,onClick:w,onMouseDown:D=>{D.stopPropagation(),PR(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:[h?jsxRuntime.jsx("p",{className:"docx-dialog__error",children:i(h)}):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:P,onChange:D=>O(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:P,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:T,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:v||!b?.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")}),E?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionUnavailable")}):null,S?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,C?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p.positionMode==="frame"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"docx-dialog__row",children:[jsxRuntime.jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-h",children:i("imageProperties.relativeToHorizontal")}),jsxRuntime.jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:p.relativeToH??"page",onChange: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:b?.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:v,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:v,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:v,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:v,value:p.cropBottom,onChange:D=>f(R=>R&&{...R,cropBottom:D.target.value})})]}),v?jsxRuntime.jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.nonPictureHint")}):null]})]}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick: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 ws({className:e,hidden:t,asChild:o,children:r}){let n=kt(),i=H(),{t:a}=L(),l=W(l0),[s,c]=Bt.useState(false),d=Bt.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;if(t)return null;let f=Q("image.properties"),h={type:"button",ref:d,className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!g,...g?{}:{"data-disabled":""},"aria-label":a("formattingBar.imagePropertiesShortcut"),title:p??a("formattingBar.imagePropertiesShortcut"),onMouseDown:U,onClick:()=>c(true)};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[o?jsxRuntime.jsx(J,{...h,children:r}):jsxRuntime.jsx("button",{...h,children:r??re(f?.paths)}),s&&n?.imageProperties!==false?n?.imageProperties?Se(n.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):jsxRuntime.jsx(fi,{open:s,onClose:()=>c(false),triggerRef:d}):null]})}ws.docxSlot="image.properties";var ia=Object.assign(ws,{docxSlot:"image.properties"});function gi(e){let t=H(),o=Bt.useCallback(()=>editor.toolbarCommandState(t,e),[t,e]),r=W(o,(n,i)=>n.value===i.value&&n.enabled===i.enabled&&n.disabledReason===i.disabledReason);return Bt.useMemo(()=>({execute:(n,i)=>editor.runToolbarCommand(t,e,n,i),value:r.value===void 0?null:e==="font.size"||e==="list.lineSpacing"?Number(r.value):r.value,options:e==="image.wrap"?editor.IMAGE_WRAP_TARGETS:[],isEnabled:r.enabled,disabledReason:r.disabledReason}),[t,e,r])}function Ds({className:e,hidden:t,asChild:o,children:r}){let n=kt(),i=ne(),{execute:a,value:l,isEnabled:s,disabledReason:c}=gi("image.altText"),[d,m]=Bt.useState(false),[u,g]=Bt.useState(""),p=Bt.useRef(null),f=Bt.useRef(null),h=Bt.useId();Bt.useEffect(()=>{d&&g(l??"");},[d,l]),Bt.useEffect(()=>{if(!d)return;let T=S=>{let k=p.current;editor.isDomNode(S.target)&&(k?.contains(S.target)||k?.ownerDocument.getElementById(h)?.contains(S.target))||m(false);},C=S=>{S.key==="Escape"&&(S.preventDefault(),m(false),f.current?.focus());},E=editor.hostDocumentOf(p.current);return E.addEventListener("mousedown",T,true),E.addEventListener("keydown",C),()=>{E.removeEventListener("mousedown",T,true),E.removeEventListener("keydown",C);}},[d,h]);let y=Bt.useCallback(()=>{a(u),m(false);},[u,a]);if(t)return null;let x=Q("image.altText"),b=i(x?.labelKey??"formattingBar.altText"),v={type:"button",ref:f,className:`docx-toolbar__button docx-toolbar__alt-text-trigger${e?` ${e}`:""}`,"data-slot":"image.altText",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?h:void 0,"aria-label":b,title:c??b,onMouseDown:U,onClick:()=>m(T=>!T)},P={id:h,value:u,onValueChange:g,onApply:y,onClose:()=>m(false),isEnabled:s,anchorRef:f};return jsxRuntime.jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsxRuntime.jsx(J,{...v,children:r}):jsxRuntime.jsx("button",{...v,children:r??b}),d&&n?.imageAltText!==false?n?.imageAltText?Se(n.imageAltText,P):jsxRuntime.jsx(Rs,{...P}):null]})}Ds.docxSlot="image.altText";var bi=Object.assign(Ds,{docxSlot:"image.altText"});function Rs({id:e,value:t,onValueChange:o,onApply:r,onClose:n,isEnabled:i,className:a}){let{t:l}=L();return jsxRuntime.jsxs("div",{id:e,role:"dialog","aria-label":l("imageAltText.panelTitle"),className:`docx-toolbar__alt-text-panel${a?` ${a}`:""}`,onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsx("label",{className:"docx-dialog__label",htmlFor:`${e}-description`,children:l("imageAltText.description")}),jsxRuntime.jsx("textarea",{id:`${e}-description`,className:"docx-dialog__textarea",value:t,onChange:s=>o(s.target.value),placeholder:l("dialogs.imageProperties.altTextPlaceholder")}),jsxRuntime.jsxs("div",{className:"docx-dialog__footer",children:[jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button",onClick:n,children:l("common.cancel")}),jsxRuntime.jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",disabled:!i,onClick:r,children:l("common.apply")})]})]})}function Ep(e){let[t,o]=Bt.useState(e.session),[r,n]=Bt.useState(0);return t!==e.session&&(o(e.session),n(r+1)),jsxRuntime.jsx(BR,{...e},r)}function BR({session:e,className:t,style:o,children:r}){let n=Qe(),[i,a]=Bt.useState(e.signal.aborted),l=Bt.useRef(null);return Bt.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(Be,{kind:"invalidTextFormField",role:"alertdialog",label:n("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:r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:n("textFormField.invalidTitle")})}),jsxRuntime.jsx("div",{className:"docx-dialog__body",children:n(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:n("textFormField.apply")})})]})})}var m0=Bt.createContext(null),f0=m0.Provider;function st(){let e=Bt.useContext(m0);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function XR(e){return e.kind==="date"?editor.parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function g0(e){let t=`docx-cc-list-${Bt.useId()}`,[o,r]=Bt.useState(()=>XR(e)),[n,i]=Bt.useState(()=>editor.calendarDateText(e.value,e.locale)),a=Bt.useMemo(()=>editor.createContentControlListNavigation(e.locale),[e]),[l,s]=Bt.useState(false),c=Bt.useCallback(w=>{i(w),s(false);},[]),d=W(()=>e.canApply()),m=e.kind==="date"?editor.parseIsoDate(e.value):null,[u,g]=Bt.useState(()=>{let w=m??new Date;return {year:w.getFullYear(),month:w.getMonth()}}),p=Bt.useCallback(w=>{let I=e.apply(w??o);return s(!I),I},[e,o]),f=Bt.useCallback(()=>e.cancel(),[e]),h=Bt.useCallback(async w=>{if(!e.replaceImage)return s(true),false;try{let I=w instanceof Uint8Array?w.byteLength:w.size;if(!e.canApply()||I>store.DEFAULT_IMAGE_RESOURCE_LIMITS.maxEncodedBytes)return s(!0),!1;let O=w instanceof Uint8Array?w:new Uint8Array(await w.arrayBuffer()),N=await e.replaceImage(O);return s(!N),N}catch{return s(true),false}},[e]),y=Bt.useMemo(()=>editor.calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),x=Bt.useCallback(()=>{g(w=>editor.shiftMonth(w.year,w.month,-1)),C(null);},[]),b=Bt.useCallback(()=>{g(w=>editor.shiftMonth(w.year,w.month,1)),C(null);},[]),v=Bt.useCallback(w=>p(w),[p]),P=Bt.useCallback(()=>p(editor.isoDateOf(new Date)),[p]),[T,C]=Bt.useState(null),E=Bt.useCallback(w=>{let I=editor.parseIsoDate(w);I&&(g({year:I.getFullYear(),month:I.getMonth()}),C(editor.isoDateOf(I)));},[]),S=Bt.useCallback(()=>{let w=editor.calendarDateFromText(n,e.locale);return w?p(w):(s(true),false)},[n,e.locale,p]),k=Bt.useCallback((w,I)=>{!Number.isInteger(w)||w<100||w>9999||!Number.isInteger(I)||I<0||I>11||(g({year:w,month:I}),C(null));},[]);return Bt.useMemo(()=>({session:e,kind:e.kind,items:e.items,value:o,setValue:r,isEnabled:d,refused:l,apply:p,cancel:f,calendar:y,previousMonth:x,nextMonth:b,selectDay:v,selectToday:P,focusIso:T,focusDay:E,dateText:n,setDateText:c,applyDateText:S,showMonth:k,listNavigation:a,listId:t,accept:editor.CONTENT_CONTROL_PICTURE_ACCEPT,replaceImage:h}),[e,h,o,d,l,p,f,y,x,b,v,P,T,E,n,c,S,k,a,t])}function et(e,t,o,r){if(t.hidden)return null;let{children:n,asChild:i,className:a,style:l,hidden:s,id:c,title:d,"aria-label":m,...u}=t,g=n===void 0?r:n,{key:p,...f}=o,h={...c!==void 0?{id:c}:{},...d!==void 0?{title:d}:{},...m!==void 0?{"aria-label":m}:{}};if(i){let{className:x,style:b,...v}=f;return jsxRuntime.jsx(J,{...u,...v,...h,...a?{className:a}:{},style:{...b,...l},children:g},p)}return jsxRuntime.jsx(e,{...u,...f,...h,className:[o.className,a].filter(Boolean).join(" "),style:{...o.style,...l},children:g},p)}var Yr=e=>e.stopPropagation();function wp(e){return et("div",e,{className:"docx-content-control-calendar-header","data-docx-part":"header"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Dp,{}),jsxRuntime.jsx(Op,{}),jsxRuntime.jsx(Rp,{}),jsxRuntime.jsx(Mp,{className:"docx-content-control-calendar-announcement"})]}))}function Dp(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"previousMonth","aria-label":o("contentControl.calendar.previousMonth"),onMouseDown:Yr,onClick:t.previousMonth},"\u2039")}function Rp(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"nextMonth","aria-label":o("contentControl.calendar.nextMonth"),onMouseDown:Yr,onClick:t.nextMonth},"\u203A")}function Mp(e){let t=st();return et("div",e,{className:"docx-content-control-calendar-title","data-docx-part":"title","aria-live":"polite"},t.calendar.title)}function _p(e){let t=st();return et("div",e,{className:"docx-content-control-calendar-weekdays","data-docx-part":"weekdays"},t.calendar.weekdays.map((o,r)=>jsxRuntime.jsx("span",{children:o},r)))}function Ip({day:e,...t}){let o=st(),r=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),n=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 et("button",t,{type:"button",className:"docx-content-control-calendar-day","data-docx-part":"day","data-iso":e.iso,role:"gridcell",tabIndex:e.iso===r?.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:Yr,onClick:()=>o.selectDay(e.iso),onKeyDown:n},String(e.day))}function Np(e){let t=st(),o=Bt.useRef(null);return Bt.useLayoutEffect(()=>{let r=o.current;if(!r||r.ownerDocument.activeElement?.closest("[data-docx-part=previousMonth],[data-docx-part=nextMonth],[data-docx-part=month],[data-docx-part=year]"))return;((t.focusIso?r.querySelector(`[data-iso="${t.focusIso}"]`):null)??r.querySelector("[data-selected]")??r.querySelector("[data-today]:not([data-other-month])")??r.querySelector('[data-docx-part="day"]:not([data-other-month])'))?.focus({preventScroll:true});},[t.focusIso,t.calendar]),et("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},(r,n)=>jsxRuntime.jsx("div",{role:"row",className:"docx-content-control-calendar-week",children:t.calendar.days.slice(n*7,n*7+7).map(i=>jsxRuntime.jsx(Ip,{day:i},i.iso))},n)))}function Fp(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-content-control-calendar-today","data-docx-part":"today",disabled:!t.isEnabled,onMouseDown:Yr,onClick:t.selectToday},o("contentControl.calendar.today"))}function Lp(e){return et("div",e,{className:"docx-content-control-calendar","data-docx-part":"calendar"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(wp,{}),jsxRuntime.jsx(_p,{}),jsxRuntime.jsx(Np,{}),jsxRuntime.jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsxRuntime.jsx(Fp,{}),jsxRuntime.jsx(_s,{})]}),jsxRuntime.jsx(la,{}),jsxRuntime.jsx(Ns,{})]}))}function Hp({item:e,...t}){let o=st();return et("button",t,{type:"button",className:"docx-content-control-menu-item","data-docx-part":"item","data-value":e.value,role:"option",tabIndex:o.items.findIndex(r=>r.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:Yr,onClick:()=>o.apply(e.value)},e.displayText)}function Ms(e){let t=st(),o=Qe();return et("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((r,n)=>jsxRuntime.jsx(Hp,{item:r},n)))}function _s(e){let t=st(),o=Qe();return et("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:r=>{r.key!=="Enter"||r.nativeEvent.isComposing||(r.preventDefault(),r.stopPropagation(),t.kind==="date"?t.applyDateText():t.apply());},onMouseDown:Yr,onChange:r=>(t.kind==="date"?t.setDateText:t.setValue)(r.target.value)},void 0)}function la(e){let t=st(),o=Qe();return t.refused?et("div",e,{className:"docx-content-control-widget-error","data-docx-part":"error",role:"alert"},o("disabledReason.invalidValue")):null}function Ap(e){let t=st(),o=Qe();return et("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 Is(e){let t=st(),o=Qe();return et("button",e,{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t.cancel},o("common.cancel"))}function Ns(e){return et("div",e,{className:"docx-dialog__footer","data-docx-part":"footer"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Is,{}),jsxRuntime.jsx(Ap,{})]}))}function Op(e){return et("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bp,{}),jsxRuntime.jsx(Wp,{})]}))}function Bp(e){let t=st(),o=Qe();return et("select",e,{className:"docx-content-control-calendar-month","data-docx-part":"month","aria-label":o("contentControl.calendar.month"),value:t.calendar.month,onChange:r=>t.showMonth(t.calendar.year,Number(r.target.value))},editor.calendarMonthNames(t.session.locale).map((r,n)=>jsxRuntime.jsx("option",{value:n,children:r},n)))}function Wp(e){let t=st(),o=Qe();return et("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:r=>{let n=Number(r.target.value);if(!Number.isInteger(n)||n<100||n>9999){r.target.value=String(t.calendar.year);return}t.showMonth(n,t.calendar.month);},onKeyDown:r=>{r.key==="Enter"&&!r.nativeEvent.isComposing&&(r.preventDefault(),r.currentTarget.blur());}},void 0)}function Zp({autoOpen:e,...t}){let o=st(),r=Qe(),n=Bt.useRef(null),i=Bt.useRef(false);return Bt.useLayoutEffect(()=>{e!==false&&!i.current&&(i.current=true,n.current?.click());},[e]),et("input",t,{ref:n,type:"file",accept:o.accept,className:"docx-content-control-picture-input","data-docx-part":"picture","aria-label":r("contentControl.types.picture"),"aria-invalid":o.refused||void 0,onMouseDown:Yr,onCancel:o.cancel,onChange:a=>{let l=a.target.files?.[0];a.target.value="",l&&o.replaceImage(l);}},void 0)}function iM(e){let[t,o]=Bt.useState(e.session),[r,n]=Bt.useState(0);return t!==e.session&&(o(e.session),n(r+1)),jsxRuntime.jsx(lM,{...e},r)}function lM({session:e,className:t,style:o,children:r}){let n=Qe(),i=g0(e),[a,l]=Bt.useState(e.signal.aborted),s=Bt.useRef(null),[c]=Bt.useState(()=>editor.contentControlPopupOpener(e.anchor)),d=e.kind==="checkbox"&&r===void 0;if(Bt.useEffect(()=>{let u=()=>l(true);return e.signal.addEventListener("abort",u,{once:true}),e.signal.aborted&&u(),()=>e.signal.removeEventListener("abort",u)},[e]),Bt.useEffect(()=>{!d||e.signal.aborted||e.apply(e.value==="true"?"false":"true");},[d,e]),Bt.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]),Bt.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=n(`contentControl.types.${e.kind}`);return jsxRuntime.jsx(f0,{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:r??sM(i)})})}function sM(e){return e.kind==="date"?jsxRuntime.jsx(Lp,{}):e.kind==="picture"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Zp,{}),jsxRuntime.jsx(la,{}),jsxRuntime.jsx(Is,{})]}):e.kind==="comboBox"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(_s,{}),jsxRuntime.jsx(Ms,{}),jsxRuntime.jsx(la,{}),jsxRuntime.jsx(Ns,{})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ms,{}),jsxRuntime.jsx(la,{})]})}var zp=Object.assign(iM,{Navigation:Op,Month:Bp,Year:Wp,Calendar:Lp,Header:wp,PreviousMonth:Dp,Title:Mp,NextMonth:Rp,Weekdays:_p,Grid:Np,Day:Ip,Today:Fp,List:Ms,Item:Hp,Input:_s,Picture:Zp,Error:la,Footer:Ns,Apply:Ap,Cancel:Is});function Vp(e){return e==="checkbox"?"contentControlCheckbox":e==="picture"?"contentControlPicture":"contentControlWidget"}function y0(){let e=H(),t=kt(),o=Bt.useRef(t);o.current=t;let[r,n]=Bt.useState(null),[i,a]=Bt.useState(null),l=t?.contentControlWidget!==void 0,s=t?.contentControlCheckbox!==void 0,c=t?.contentControlPicture!==void 0,d=t?.invalidTextFormField!==void 0;Bt.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?.[Vp(f.kind)]===false)return f.cancel();n(f),f.signal.addEventListener("abort",()=>{u&&n(h=>h===f?null:h);},{once:true});}},{fallback:true});return ()=>{u=false,p(),n(null);}},[e,l,s,c]),Bt.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]),Bt.useEffect(()=>{r&&t?.[Vp(r.kind)]===false&&r.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,r,i]);let m=r?t?.[Vp(r.kind)]:void 0;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[r&&m&&Se(m,{session:r},r),i&&t?.invalidTextFormField&&Se(t.invalidTextFormField,{session:i},i)]})}var kM=["nw","n","ne","e","se","s","sw","w"],E0=40,S0=12;function wM(e){return `imageOverlay.handle.${e}`}function DM(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 RM(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 MM(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 jp({containerRef:e,portalRef:t,scrollPort:o}){let r=H(),{t:n}=L(),[i,a]=Bt.useState(null),[l,s]=Bt.useState(null),[c,d]=Bt.useState({left:0,top:0}),m=Bt.useRef(null);m.current=l;let u=Bt.useRef(null),g=Bt.useRef(null),p=Bt.useRef(null),f=Bt.useRef(null),h=Bt.useRef(null);Bt.useEffect(()=>{let E=e.current;if(!E)return;let S=k=>{let w=editor.isElementNode(k.target)?k.target:null;if(w?.closest(".docx-drawing-textbox-content")){f.current=null;return}let I=w?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");f.current=I??null,I&&I===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return E.addEventListener("pointerdown",S,{capture:true}),()=>E.removeEventListener("pointerdown",S,{capture:true})},[e,i?.id]),Bt.useEffect(()=>{if(!r){a(null);return}let E=()=>{a(editor.selectedDrawingOverlayTargetOf(r.surface));},S=()=>{queueMicrotask(E);};E();let k=[r.on("change",S),r.on("selectionChange",E)];return ()=>{for(let w of k)w();}},[r]);let y=Bt.useCallback(()=>{d(E=>{let S=editor.overlayHostOrigin(e.current);return S.left===E.left&&S.top===E.top?E:S});},[e]);Bt.useEffect(()=>{y();let E=t.current,S=editor.hostWindowOf(E).ResizeObserver;if(!E||typeof S!="function")return;let k=new S(y);k.observe(E);let w=e.current;return w&&k.observe(w),()=>k.disconnect()},[e,t,y,i]),Bt.useEffect(()=>{if(o){h.current=o;return}let E=e.current;if(!E||!r?.surface)return;let S=E.closest(".docx-editor__scroll-container");if(!S)return;let k=r.surface.overlayCoordinates();return h.current=editor.createImageOverlayScrollPort(S,k.paintScale),()=>{h.current=null;}},[e,r,o]);let x=Bt.useCallback(()=>{s(null),u.current=null;let E=g.current;if(g.current=null,E)try{E.releasePointerCapture(E._lastPointerId??0);}catch{}},[]),b=Bt.useCallback((E,S,k,w,I,O,N)=>{if(!r?.surface)return;let B=r.surface.activeScope();if(B.kind==="frame"&&!r.surface.selectDrawing(k.id,B.hostParagraphId))return;let F=r.surface.layout(),D=editor.captureImageMutationPreconditions(r);if(D){u.current=Object.freeze({x:w,y:I}),g.current=O,O._lastPointerId=N;try{O.setPointerCapture(N);}catch{}s({session:Object.freeze({drawingNodeId:k.id,startBounds:Object.freeze({x:k.x,y:k.y,width:k.width,height:k.height}),startWidthEmu:k.widthEmu,startHeightEmu:k.heightEmu,startPosition:k.position,anchorFrameOrigin:k.anchorFrameOrigin,transform:k.transform,mode:E,handle:S,preconditions:D,layoutRevision:F.revision,packageRevision:r.surface.session.packageRevision(),kind:k.kind}),bounds:k,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});}},[r]),v=Bt.useCallback((E,S,k,w,I)=>{if(!r)return;if(editor.isStaleImageInteractionCommit(r,E)){x();return}E.mode==="resize"?r.exec({type:"setImageProperties",widthEmu:S,heightEmu:k,...I?.mode==="simple"?{horizontalEmu:I.horizontalEmu,verticalEmu:I.verticalEmu}:{},...I?.mode==="frame"?{...I.horizontalEmu!==void 0?{horizontalEmu:I.horizontalEmu}:{},...I.verticalEmu!==void 0?{verticalEmu:I.verticalEmu}:{}}:{}}):E.mode==="move"&&I&&r.exec({type:"setImagePosition",...I}),x();},[x,r]),P=Bt.useCallback(E=>{if(!r)return;let S=m.current?.bounds??editor.selectedDrawingOverlayTargetOf(r.surface);if(!S)return;if(m.current&&E.key==="Escape"){E.preventDefault(),E.stopPropagation(),x();return}if(m.current)return;let k=editor.historyShortcutOf(E);if(k){E.preventDefault(),E.stopPropagation(),r.exec({type:k});return}let w=E.shiftKey?editor.IMAGE_OVERLAY_NUDGE_SHIFT_PT:editor.IMAGE_OVERLAY_NUDGE_PT;if(E.key==="Delete"||E.key==="Backspace"){E.preventDefault(),E.stopPropagation(),r.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(E.key))return;E.preventDefault(),E.stopPropagation();let I=E.key==="ArrowLeft"?-w:E.key==="ArrowRight"?w:0,O=E.key==="ArrowUp"?-w:E.key==="ArrowDown"?w:0;if(E.altKey){if(!S.canResize)return;let B=MM(I,O),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:I,deltaYPt:O,transform:S.transform,preserveAspect:editor.resizePreservesAspect(B,S.aspectLocked,E.shiftKey,S.textbox),kind:S.kind});r.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,I,O);r.exec({type:"setImagePosition",...N});},[x,r]);Bt.useEffect(()=>{if(!l||!r?.surface)return;let E=r.surface.overlayCoordinates(),S=I=>{let O=m.current,N=u.current;if(!O||!N)return;let B=editor.cssPixelsToLayoutPoints(I.clientX-N.x,E.paintScale),F=editor.cssPixelsToLayoutPoints(I.clientY-N.y,E.paintScale);if(O.session.mode==="move"){let R=0,z=h.current,V=e.current?.closest(".docx-editor__scroll-container");if(z&&V){let Y=V.getBoundingClientRect();I.clientY>Y.bottom-E0?R=S0:I.clientY<Y.top+E0&&(R=-S0),R!==0&&(R=z.scrollBy(R));}let ee=O.accumulatedScrollPt+R;s({...O,accumulatedScrollPt:ee,bounds:Object.freeze({...O.bounds,x:O.session.startBounds.x+B,y:O.session.startBounds.y+F+ee})});return}if(!O.session.handle)return;let D=editor.computeImageResizeResult({handle:O.session.handle,startWidthEmu:O.session.startWidthEmu,startHeightEmu:O.session.startHeightEmu,startBounds:O.session.startBounds,startPosition:O.session.startPosition,anchorFrameOrigin:O.session.anchorFrameOrigin,deltaXPt:B,deltaYPt:F,transform:O.session.transform,preserveAspect:editor.resizePreservesAspect(O.session.handle,O.bounds.aspectLocked,I.shiftKey,O.bounds.textbox),kind:O.session.kind});s({...O,bounds:Object.freeze({...O.bounds,x:D.previewBounds.x,y:D.previewBounds.y,width:D.previewBounds.width,height:D.previewBounds.height,widthEmu:D.widthEmu,heightEmu:D.heightEmu})});},k=I=>{let O=m.current;if(O)if(I.type==="pointerup"){let N=editor.cssPixelsToLayoutPoints(I.clientX-(u.current?.x??I.clientX),E.paintScale),B=editor.cssPixelsToLayoutPoints(I.clientY-(u.current?.y??I.clientY),E.paintScale),F=editor.finalizeImageOverlayInteraction({session:O.session,deltaXPt:N,deltaYPt:B,accumulatedScrollPt:O.accumulatedScrollPt,aspectLocked:O.bounds.aspectLocked,textbox:O.bounds.textbox,shiftKey:I.shiftKey,anchorFrameOrigin:O.session.anchorFrameOrigin});v(O.session,F.widthEmu,F.heightEmu,F.previewBounds,F.position);}else x();},w=editor.hostWindowOf(e.current);return w.addEventListener("pointermove",S),w.addEventListener("pointerup",k),w.addEventListener("pointercancel",k),()=>{w.removeEventListener("pointermove",S),w.removeEventListener("pointerup",k),w.removeEventListener("pointercancel",k);}},[x,v,e,r,l]),Bt.useEffect(()=>{!i||f.current!==i.id||(f.current=null,p.current?.focus({preventScroll:true}));},[i]);let T=l?.bounds??i,C=Bt.useMemo(()=>{if(!r?.surface||!T)return null;let E=r.surface.publishedLayout(),S=r.surface.overlayCoordinates(),k=editor.overlayFrameToSheetCssPixels(E,{pageIndex:T.pageIndex,x:T.x,y:T.y,width:T.width,height:T.height},S),w={left:k.left+c.left,top:k.top+c.top,width:k.width,height:k.height},I=T.canResize,O=T.kind==="anchored"&&T.canMove,N=editor.textboxFrameReason(T,r.surface.editingMode()),B=N?n(N):void 0;return jsxRuntime.jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":T.id,tabIndex:0,onKeyDown:P,children:[jsxRuntime.jsx("div",{className:`docx-image-selection-overlay__frame${O?" docx-editor-one-surface__overlay-control":""}`,"data-textbox":T.textbox?"true":void 0,title:B,"aria-description":B,role:"group","aria-label":n("imageOverlay.selection"),style:{left:`${w.left}px`,top:`${w.top}px`,width:`${w.width}px`,height:`${w.height}px`,cursor:O?"move":"default"},onPointerDown:F=>{U(F),!(!O||!T.position)&&F.button===0&&(F.preventDefault(),F.stopPropagation(),b("move",null,T,F.clientX,F.clientY,F.currentTarget,F.pointerId));}}),I?kM.map(F=>{let D=RM(F);return jsxRuntime.jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":n(wM(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:DM(F)},onPointerDown:R=>{U(R),R.button===0&&(R.preventDefault(),R.stopPropagation(),b("resize",F,T,R.clientX,R.clientY,R.currentTarget,R.pointerId));}},F)}):null]})},[T,b,r,P,c.left,c.top,n]);return !C||!t.current?null:reactDom.createPortal(C,t.current)}function Yp(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Os({className:e}){let t=H(),o=ja(),r=Bt.useRef(null),n=Bt.useContext(xn),i=Bt.useCallback(d=>{r.current=d,n?.setContainer(d);},[n]),a=Bt.useRef(null);Bt.useLayoutEffect(()=>{let d=r.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=Bt.useCallback(d=>{if(!o?.isEnabled)return;let m=d.clipboardData;m&&Yp(m)&&(editor.clipboardPasteLandsContent(m)||(d.preventDefault(),o.insertFromDataTransfer(m)));},[o]),s=Bt.useCallback(d=>{!o?.isEnabled||!Yp(d.dataTransfer)||d.preventDefault();},[o]),c=Bt.useCallback(d=>{if(o?.isEnabled&&Yp(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(Nh,{}),jsxRuntime.jsx(Xh,{}),jsxRuntime.jsx(y0,{}),t?jsxRuntime.jsx(jp,{containerRef:r,portalRef:a}):null]})}function Jp({open:e,onClose:t,children:o,url:r,name:n,features:i,title:a,styles:l}){let[s,c]=Bt.useState(null),{dir:d}=L(),m=Kt(),u=Bt.useRef(t);u.current=t;let g=Bt.useRef({url:r,name:n,features:i,title:a,styles:l});g.current={url:r,name:n,features:i,title:a,styles:l};let p=Bt.useRef(null);return Bt.useEffect(()=>{if(!e)return;let f=p.current;if(f)f.claimed=true;else {let{url:b,name:v,features:P,title:T,styles:C}=g.current;f={claimed:true,promise:editor.openEditorWindow({...b!==void 0?{url:b}:{},...v!==void 0?{name:v}:{},...P!==void 0?{features:P}:{},...T!==void 0?{title:T}:{},...C!==void 0?{styles:C}:{}})},p.current=f;}let h=f,y=true,x;return h.promise.then(b=>{if(y){if(!b){p.current=null,u.current?.();return}x=b.onClose(()=>{y&&(p.current=null,reactDom.flushSync(()=>c(null)),u.current?.());}),c(b);}}),()=>{y=false,x?.(),h.claimed=false,c(null),queueMicrotask(()=>{h.claimed||(p.current===h&&(p.current=null),h.promise.then(b=>b?.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 ze(e){return e/1440*96}function Bs(e){return e/96*1440}function Dt(e){return `${Math.round(e*100)/100}px`}function Qp(e){return e/2}var YM=e=>e.isLoading||e.isOpening===true,XM=e=>({width:ze(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:ze(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),JM=(e,t)=>e.width===t.width&&e.height===t.height;function em({className:e}){return jsxRuntime.jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}var D0=false;function R0(){D0||!bt()||(D0=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 QM(e){let t=H(),[o,r]=Bt.useState(null);return Bt.useEffect(()=>{if(!(!t||!e))return t.setOpeningIndicatorHost({publish:r}),()=>{t.setOpeningIndicatorHost(null),r(null);}},[t,e]),o}function e1({when:e=false,overlay:t=false,className:o,style:r,indicator:n,children:i}){let a=W(YM),l=W(XM,JM),s=QM(t),c=H(),d=Bt.useRef({visible:false,editor:null}),[,m]=Bt.useReducer(x=>x+1,0),u=d.current.visible&&d.current.editor!==c,g=s===null&&(e||a||u);Bt.useLayoutEffect(()=>{d.current={visible:g,editor:c},u&&m();},[g,c,u]);let{t:p}=L(),f=Kt(),h=n??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(em,{}),jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:p("loading.label")})]});if(s)return reactDom.createPortal(h,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:r,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:h})})})})})}var Ws=Object.assign(e1,{Spinner:em});function M0(){let e=new Set,t=new Map,o=new Map,r=0,n=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(!n)return;let u=a(),g=c(u);if(g!==l){if(u===void 0){i&&(n.setRevisionStyles("author"),i=false,l=g);return}n.setRevisionStyles(u),i=true,l=g;}}function m(){!n||s||(s=true,queueMicrotask(()=>{s=false,d();}));}return {registerScheme(u){e.add(u),m();},register(u,g,p){o.has(u)||o.set(u,r++),t.set(u,{author:g,style:p}),m();},unregister(u){(e.delete(u)||t.delete(u))&&m();},connect(u){n=u;let g=a();i=u!==null&&g!==void 0,l=u===null?null:c(g),m();},current:a}}var Ci=Bt.createContext(null);function N0(){let e=Bt.useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function tm(){let e=Bt.useContext(Ci),t=N0();return Bt.useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function om(e){let{author:t,color:o,background:r,activeBackground:n,spanClassName:i,avatarUrl:a}=e,l=Bt.useContext(Ci),s=N0();return Bt.useEffect(()=>{if(l)return l.register(s,t,{...o!==void 0?{color:o}:{},...r!==void 0?{background:r}:{},...n!==void 0?{activeBackground:n}:{},...i!==void 0?{spanClassName:i}:{},...a!==void 0?{avatarUrl:a}:{}}),()=>l.unregister(s)},[l,s,t,o,r,n,i,a]),null}var F0=false;function L0(e,t){e===t||F0||!bt()||(F0=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 H0=false,A0=e=>e?.allowFormattingInLockedContent===true;function O0(e,t){A0(e)===A0(t)||H0||!bt()||(H0=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 B0=false;function W0(e){return e===void 0?"characters":e}function Z0(e,t){W0(e)===W0(t)||B0||!bt()||(B0=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 d1(e,t){if(e===t)return true;let o=editor.resolveZoomMode(e),r=editor.resolveZoomMode(t);return o!==null&&r!==null&&editor.sameZoomMode(o,r)}function u1(e){let t=Bt.useRef(e);t.current=e;let[o,r]=Bt.useState(null),{onReady:n,onChange:i,onFontError:a,onRevisionMarkupChange:l,...s}=e,c=Bt.useMemo(()=>({onReady:d=>{r(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:Ti,rootProps:s,rootListeners:c,editorRef:o}}function Ti(e){let{document:t,fonts:o,fontShaping:r,author:n,locale:i,translate:a,mode:l,zoom:s,zoomMode:c,tableInteractionLabel:d,imageDecodePort:m,colorMode:u,children:g}=e,p=Rl(u),{t:f}=L(),h=Bt.useCallback((Z,de)=>f(Z,de),[f]),y=Bt.useRef(h);y.current=h;let x=Bt.useRef(false),[b,v]=Bt.useState(0),P=Bt.useRef(e);P.current=e;let T=r?.maxFontBytes,[C,E]=Bt.useState(null),S=Bt.useRef(e.fieldResults),k=Bt.useRef(e.contentLockPolicy),w=Bt.useRef(e.lockedControlNavigation),I=Bt.useRef(e.fonts),O=Bt.useRef(null);O.current??=M0();let N=O.current,B=Bt.useRef(null);B.current??=ng();let F=B.current;Bt.useEffect(()=>{let Z=P.current,de=Z.translate??y.current,Re=N.current();S.current=Z.fieldResults,k.current=Z.contentLockPolicy,w.current=Z.lockedControlNavigation;let Ae=editor.createDocxEditor({unsupportedElementRules:F.current(),...Z.document!==void 0?{document:Z.document}:{},...Z.fonts?{fonts:Z.fonts}:{},...Z.fontShaping?{fontShaping:Z.fontShaping}:{},...Z.author!==void 0?{author:Z.author}:{},...Z.locale!==void 0?{locale:Z.locale}:{},translate:de,...Z.revisionMarkup!==void 0?{revisionMarkup:Z.revisionMarkup}:{},...Z.reviewDisplayMode!==void 0?{reviewDisplayMode:Z.reviewDisplayMode}:{},...Z.fieldResults!==void 0?{fieldResults:Z.fieldResults}:{},...Z.contentLockPolicy!==void 0?{contentLockPolicy:Z.contentLockPolicy}:{},...Z.lockedControlNavigation!==void 0?{lockedControlNavigation:Z.lockedControlNavigation}:{},...Z.mode!==void 0?{mode:Z.mode}:{},...Re!==void 0?{revisionStyles:Re}:{},...Z.modules!==void 0?{modules:Z.modules}:{},...Z.zoom!==void 0?{zoom:Z.zoom}:{},...Z.zoomMode!==void 0?{zoomMode:Z.zoomMode}:{},...Z.tableInteractionLabel?{tableInteractionLabel:Z.tableInteractionLabel}:{},...Z.imageDecodePort?{imageDecodePort:Z.imageDecodePort}:{},onFontError:nt=>P.current.onFontError?.(nt)});I.current=Z.fonts;let ft=Ae.on("revisionMarkupChange",nt=>{x.current||(P.current.onRevisionMarkupChange?.(nt),v(Zt=>Zt+1));}),ve=Ae.on("change",nt=>P.current.onChange?.(nt));return E(Ae),()=>{ft(),ve(),Ae.destroy(),E(nt=>nt===Ae?null:nt);}},[t,T,m,N,F]),Bt.useEffect(()=>{!C||I.current===o||(I.current=o,C.setFonts(o).catch(()=>{}));},[C,o]),Bt.useEffect(()=>{if(!C)return;if(!C.snapshot().isOpening){P.current.onReady?.(C);return}let Z=C.on("change",()=>{Z(),P.current.onReady?.(C);});return Z},[C]);let D=Bt.useRef({editor:null,zoom:void 0,mode:void 0});Bt.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 Re=D.current.mode,Ae=c!==void 0&&(Re===void 0||!d1(Re,c)),ft=c===void 0?null:editor.resolveZoomMode(c),ve=de&&c!==void 0&&ft!==null&&ft.type==="fit";(Ae||ve)&&(D.current.mode=c,C.setZoomMode(c));},[C,s,c]),Bt.useEffect(()=>{if(!C||e.revisionMarkup===void 0)return;let Z=editor.resolveRevisionMarkup(e.revisionMarkup);if(JSON.stringify(Z)!==JSON.stringify(C.snapshot().revisionMarkup)){x.current=true;try{C.setRevisionMarkup(Z);}finally{x.current=false;}}},[C,e.revisionMarkup,b]),Bt.useEffect(()=>{C&&C.setAuthor(n);},[C,n]);let R=Bt.useRef({editor:null,value:void 0});Bt.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]),Bt.useEffect(()=>{C&&C.setTranslate(a??h);},[C,a,h]),Bt.useEffect(()=>{C&&C.setLocale(i);},[C,i]),Bt.useEffect(()=>{C&&L0(S.current,e.fieldResults);},[C,e.fieldResults]),Bt.useEffect(()=>{C&&O0(k.current,e.contentLockPolicy);},[C,e.contentLockPolicy]),Bt.useEffect(()=>{C&&Z0(w.current,e.lockedControlNavigation);},[C,e.lockedControlNavigation]),Bt.useEffect(()=>{C&&C.setTableInteractionLabel(d??editor.defaultTableLabel);},[C,d]);let[z,V]=Bt.useState(0),[ee,Y]=Bt.useState(0),q=Bt.useRef([]),[G,ce]=Bt.useState(0),A=G>0,_=Bt.useRef(C);_.current=C,Bt.useEffect(()=>{if(!(!C||!A))return C.setCommentDraftChrome({onRequest:()=>q.current.at(-1)?.()})},[C,A]);let ae=Bt.useMemo(()=>({mounted:z,register:()=>(V(Z=>Z+1),()=>V(Z=>Math.max(0,Z-1))),gutters:ee,reserveGutter:()=>(Y(Z=>Z+1),()=>Y(Z=>Math.max(0,Z-1))),registerCommentDraft:Z=>(q.current.push(Z),ce(de=>de+1),()=>{let de=q.current.indexOf(Z);de!==-1&&(q.current.splice(de,1),ce(Re=>Math.max(0,Re-1)));}),requestCommentDraft:()=>{let Z=_.current;return Z!==null&&editor.runToolbarCommand(Z,"review.addComment").ok}}),[z,ee]),fe=Bt.useMemo(Pg,[]);return Bt.useEffect(()=>(N.connect(C),()=>N.connect(null)),[N,C]),Bt.useEffect(()=>(F.connect(C),()=>F.connect(null)),[F,C]),jsxRuntime.jsx(Ir.Provider,{value:p,children:jsxRuntime.jsx(xn.Provider,{value:F,children:jsxRuntime.jsx(Dh,{value:a??h,children:jsxRuntime.jsx(Lt.Provider,{value:ae,children:jsxRuntime.jsx(kd.Provider,{value:C,children:jsxRuntime.jsx(Ad.Provider,{value:fe,children:jsxRuntime.jsx(Ci.Provider,{value:N,children:jsxRuntime.jsx(p1,{children:jsxRuntime.jsx(m1,{children:jsxRuntime.jsx(Yh,{value:e.popups,children:jsxRuntime.jsx($l,{children:jsxRuntime.jsx(Ih,{popups:e.popups,children:g})})})})})})})})})})})})}function p1({children:e}){let[t,o]=Bt.useState(0),r=Bt.useCallback(()=>(o(i=>i+1),()=>o(i=>i-1)),[]),n=Hl(t>0);return jsxRuntime.jsx(Yd.Provider,{value:r,children:jsxRuntime.jsx(Ba.Provider,{value:n,children:e})})}function m1({children:e}){let t=Ol();return jsxRuntime.jsx(cu.Provider,{value:t,children:e})}var Ei=316,da=editor.REVIEW_MARKERS_GUTTER_PX,$0=24,Zs={inlineStart:0,inlineEnd:Ei},q0={inlineStart:da,inlineEnd:da},T1={inlineStart:0,inlineEnd:0},am={inlineStart:$0,inlineEnd:Ei};function E1(e){return e.inlineStart===am.inlineStart&&e.inlineEnd===am.inlineEnd}function V0(e,t){return E1(e)?Math.max(0,t-(Ei-da)):t}function Ks(){let e=it(),t=ke(),[o,r]=Bt.useState("ltr");return Bt.useLayoutEffect(()=>{let n=t?.parentElement;if(e||!n)return;let i=()=>r(editor.hostDirectionOf(n));return i(),editor.observeHostDirection(n,i)},[e,t]),(e??o)==="rtl"?"left":"right"}function G0(e,t){return t==="left"?{left:e.inlineEnd,right:e.inlineStart}:{left:e.inlineStart,right:e.inlineEnd}}function j0({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:r=0,docked:n=false,scroll:i=false}){if(!e)return q0;if(n||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return Zs;let a=Number.isFinite(r)&&r>0?r:0;return t-a-o-2*$0>=Ei?Zs:i?am:q0}var S1=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"}},P1=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.scroll===t.scroll&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function Y0(){let e=ke(),[t,o]=Bt.useState(null);return Bt.useEffect(()=>{if(!e){o(null);return}let r=()=>o(e.clientWidth);r();let n=editor.hostWindowOf(e).ResizeObserver;if(typeof n>"u")return;let i=new n(r);return i.observe(e),()=>i.disconnect()},[e]),t}function fr(){let e=Bt.useContext(Lt),{pageSetup:t,reviewPaneOpen:o,entitledZoom:r,scroll:n}=W(S1,P1),i=ke(),a=wg(),l=Bt.useRef(null);t&&(l.current=t.pageWidthTwips);let s=t?.pageWidthTwips??l.current,c=Pl(e),d=Bt.useCallback(f=>c?j0({open:o,viewportWidth:f??0,pageWidthPx:s===null||r===null?0:ze(s)*r,inlineStartReservation:a,docked:r===null,scroll:n}):T1,[c,o,s,r,a,n]),m=()=>d(i?i.clientWidth:null),[u,g]=Bt.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)),Bt.useEffect(()=>{let f=i?editor.hostWindowOf(i).ResizeObserver:void 0;if(!i||typeof f>"u")return;let h=()=>g(x=>{let b=d(i.clientWidth);return b===x.gutter?x:{compute:d,viewport:i,gutter:b}}),y=new f(h);return y.observe(i),()=>y.disconnect()},[i,d]),p.gutter}var qs=[.25,.5,.75,1,1.25,1.5,2];function Si(e,t){return t==="in"?qs.find(r=>r>e+.001)??null:[...qs].reverse().find(r=>r<e-.001)??null}function X0(e,t){return e==="0"?1:e==="+"||e==="="?Si(t,"in")??t:e==="-"?Si(t,"out")??t:null}var lm=Bt.createContext(false);function J0(e){let t=Bt.useContext(lm),[o,r]=Bt.useState(null);return Bt.useLayoutEffect(()=>{let n=t?e?.parentElement??null:null;r(n?{host:n,scoped:n.closest(".docx-editor")!==null}:null);},[t,e]),{inside:t,host:o?.host??null,hostScoped:o?.scoped??false}}var N1=e=>e.reviewPaneOpen??true,F1=e=>e.zoomMode?.type==="fit";function Us({className:e,style:t,children:o}){let{t:r}=L(),n=qt(),i=H(),a=W(N1),l=fr(),s=Ks(),c=W(F1),d=Bt.useContext(Lt),m=Pl(d),u=Fr(),g=Lr(),p=Bt.useRef(null),f=Bt.useCallback(y=>{p.current=y,u?.setViewport(y);},[u]),h=Bt.useCallback(y=>{if(!i||!(y.metaKey||y.ctrlKey)||y.altKey)return;let x=y.target;if(editor.isElementNode(x)&&x.closest('input, textarea, select, [role="dialog"]'))return;let b=X0(y.key,i.getZoom());b!==null&&(y.preventDefault(),i.setZoom(b));},[i]);return jsxRuntime.jsx("div",{ref:f,"data-testid":"docx-editor-scroll",tabIndex:0,role:"region","aria-label":r("editor.documentViewport"),onKeyDownCapture:h,...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:`${n}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*da}px`}:{}},children:jsxRuntime.jsx(Ao.Provider,{value:true,children:jsxRuntime.jsx(lm.Provider,{value:true,children:o})})})}var H1=editor.LOADING_SNAPSHOT;function ey({ref:e,editorRef:t}){Bt.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,r)=>t.current?.exec(o,r)??{ok:false,code:"notFound",reason:"no editor is mounted"},snapshot:o=>t.current?.snapshot(o)??H1}),[t]);}function ua(e,t,o,r){let n=ke(),i=Bt.useRef({close:o,skip:r,viewport:n});i.current={close:o,skip:r,viewport:n},Bt.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 V1=e=>e.editingMode??"editing",dm='[role="menuitemradio"]:not([disabled])',G1=(e,t)=>e.length===t.length&&e.every((o,r)=>o===t[r]),j1=e=>e.isLoading||e.isOpening===true,Pi=[{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"}],Y1=Object.freeze(Pi.map(()=>null));function X1(e){return e?Pi.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):Y1}var J1="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function $s({className:e,hidden:t}){let o=H(),r=W(V1),n=W(j1),i=ne(),{t:a}=L(),[l,s]=Bt.useState(false),c=Bt.useRef(null),d=Bt.useRef(null),m=Bt.useRef(null);Bt.useEffect(()=>{if(!l)return;let b=m.current?.querySelectorAll(dm);(m.current?.querySelector(`${dm}[aria-checked="true"]`)??b?.[0]??void 0)?.focus();},[l]);let u=Bt.useCallback(b=>{let v=[...m.current?.querySelectorAll(dm)??[]],P=v.indexOf(editor.hostDocumentOf(m.current).activeElement),T=C=>{b.preventDefault(),v[(C+v.length)%v.length]?.focus();};b.key==="ArrowDown"?T(P+1):b.key==="ArrowUp"?T(P-1):b.key==="Home"?T(0):b.key==="End"&&T(v.length-1);},[]);Bt.useEffect(()=>{if(l)return editor.listenForOutsidePress({popup:c.current,close:()=>s(false)})},[l]),ua(l,c,b=>{s(false),b&&d.current?.focus();});let g=Bt.useCallback(b=>{s(false),editor.runToolbarCommand(o,"review.editingMode",b),o?.focus();},[o]),p=editor.toolbarCommandState(o,"review.editingMode"),f=i18n.localizeDisabledReason(p.disabledReason,a),h=W(()=>X1(o),G1),y=Bt.useMemo(()=>Pi.find(b=>b.mode===r)??Pi[0],[r]);if(t)return null;let x=Q("review.editingMode");return jsxRuntime.jsxs("div",{ref:c,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxRuntime.jsxs("button",{ref:d,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":r,"aria-haspopup":"menu","aria-expanded":l,"aria-label":i(x?.labelKey??"editingMode.label"),disabled:n||!p.enabled,...f?{title:f}:{},onMouseDown:U,onClick:()=>s(b=>!b),children:[um(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(x?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:Pi.map((b,v)=>{let P=i18n.localizeDisabledReason(h[v]??null,a);return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":b.mode===r,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${b.mode}`,disabled:P!==null,...P?{title:P}:{},onMouseDown:U,onClick:()=>g(b.mode),children:[um(b.path),jsxRuntime.jsxs("span",{className:"docx-toolbar__mode-text",children:[jsxRuntime.jsx("span",{className:"docx-toolbar__mode-label",children:i(b.labelKey)}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-hint",children:i(b.hintKey)})]}),jsxRuntime.jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:b.mode===r?um(J1):null})]},b.mode)})}):null]})}$s.docxSlot="review.editingMode";function um(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 ny=[],t2=()=>{};function ki(){let e=H(),t=Bt.useCallback(o=>{if(!e)return t2;let r=_a(o),n=e.on("change",r),i=e.on("selectionChange",r);return ()=>{n(),i();}},[e]);return Bt.useSyncExternalStore(t,()=>e?.getReviewAuthors()??ny,()=>ny)}var c2=e=>e.hiddenReviewAuthors??[];function Gs({className:e,hidden:t,icon:o}){let r=H(),n=ki(),i=W(c2),a=new Set(i),l=n.every(v=>!a.has(v.author)),[s,c]=Bt.useState(false),d=Bt.useRef(null),m=Bt.useRef(null),u=Bt.useRef(null),g=ne(),{t:p}=L();Bt.useEffect(()=>{if(s)return u.current?.querySelector('[role="menuitemcheckbox"]')?.focus(),editor.listenForOutsidePress({popup:d.current,close:()=>c(false)})},[s]),ua(s,d,v=>{c(false),v&&m.current?.focus();});let f=Bt.useCallback(v=>{let P=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],T=P.indexOf(editor.hostDocumentOf(u.current).activeElement),C=E=>{v.preventDefault(),P[(E+P.length)%P.length]?.focus();};v.key==="ArrowDown"?C(T+1):v.key==="ArrowUp"?C(T-1):v.key==="Home"?C(0):v.key==="End"?C(P.length-1):v.key==="Tab"&&c(false);},[]);if(t)return null;let h=Q("review.authors"),y=editor.toolbarCommandState(r,"review.authors"),x=i18n.localizeDisabledReason(y.disabledReason,p),b=g(h?.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":b,disabled:!y.enabled,title:x??b,onMouseDown:U,onClick:()=>c(v=>!v),children:[o??re(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-value",children:b}),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":b,"data-testid":"reviewers-menu",onKeyDown:f,children:[jsxRuntime.jsx(ay,{checked:l,label:p("reviewers.all"),testId:"reviewer-all",onChoose:()=>r?.setAllReviewAuthorsVisible(!l)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),n.map(v=>jsxRuntime.jsx(ay,{checked:!a.has(v.author),label:v.author||"\u2014",testId:`reviewer-${v.slot}`,color:v.color,onChoose:()=>r?.setReviewAuthorVisible(v.author,a.has(v.author))},v.author))]}):null]})}Gs.docxSlot="review.authors";function ay(e){return jsxRuntime.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e.checked,className:"docx-toolbar__reviewer-item","data-testid":e.testId,onMouseDown:U,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 ly=Bt.createContext(null);function sy({children:e}){let t=ko(),[o,r]=Bt.useState(false),n=Bt.useRef(null),i=ke(),a=Bt.useRef(i);a.current=i;let l=Bt.useMemo(()=>({open:c=>{if(t){t.open("paragraph",c);return}n.current=c??editor.hostDocumentOf(a.current).activeElement,r(true);}}),[t]),s=Bt.useCallback(()=>{r(false);let c=n.current;n.current=null,editor.isHTMLElementNode(c)&&c.isConnected&&c.focus({preventScroll:true});},[]);return jsxRuntime.jsxs(ly.Provider,{value:l,children:[e,jsxRuntime.jsx(qo,{open:o,onClose:s})]})}function cy(){return Bt.useContext(ly)}var mm=["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"],fm=Bt.createContext({close:()=>{}});function pa(){return Bt.useContext(fm).close}function M2(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function my({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 fy({slot:e}){let t=ne(),o=Yt(),{close:r}=Bt.useContext(fm),{execute:n,isActive:i,isEnabled:a,disabledReason:l,value:s}=oe(e),c=Q(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:U,onClick:u=>{n(),r(u.detail===0);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:re(c?.paths)}),jsxRuntime.jsx("span",{className:"docx-toolbar__more-command-label",children:m})]})}function gy({sections:e,className:t}){let o=ne(),[r,n]=Bt.useState(false),i=Bt.useRef(null),a=Bt.useRef(null),l=Bt.useRef(null),s=Bt.useRef(false),c=Bt.useId(),d=ke(),m=Bt.useRef(d);m.current=d;let u=o("formattingBar.more"),g=Bt.useCallback(x=>{n(false),x&&a.current?.focus();},[]),p=Bt.useMemo(()=>({close:g}),[g]);Bt.useEffect(()=>{if(!r)return;let x=i.current,b=C=>i.current?.contains(C)===true||l.current?.contains(C)===true,v=x?editor.listenForPopupEscape({popup:x,contains:b,chromeRoot:()=>i.current?.closest(".docx-editor"),editorElements:()=>[m.current],skip:()=>editor.hasOpenNestedPopup(l.current),close:g}):void 0,P=x?editor.listenForPopupFocusLeave({popup:x,contains:b,close:()=>n(false)}):void 0,T=editor.listenForOutsidePress({popup:x,close:()=>n(false)});return ()=>{T(),v?.(),P?.();}},[r,g]);let[f,h]=Bt.useState(null);Bt.useLayoutEffect(()=>{if(!r){h(null);return}let x=()=>{let v=i.current,P=l.current,T=a.current,C=v?.ownerDocument.defaultView;if(!v||!P||!T||!C)return;let E=T.getBoundingClientRect(),S=editor.toolbarPanelPlacement({triggerLeft:E.left,triggerRight:E.right,panelWidth:P.offsetWidth,viewportWidth:C.innerWidth}),k=S.left-v.getBoundingClientRect().left;h(w=>w&&w.left===k&&w.maxWidth===S.maxWidth&&w.anchor===S.anchor?w:{...S,left:k});};x();let b=i.current?.ownerDocument.defaultView;return b?.addEventListener("resize",x),()=>b?.removeEventListener("resize",x)},[r]),Bt.useEffect(()=>{if(!r||!s.current)return;s.current=false;let x=l.current;x&&M2(x);},[r]);let y=x=>{x.key!=="Escape"||x.defaultPrevented||(x.preventDefault(),g(true));};return jsxRuntime.jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[ql]:"",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":r,"aria-controls":r?c:void 0,"aria-label":u,title:u,...r?{"data-active":""}:{},onMouseDown:U,onClick:()=>n(x=>!x),onKeyDown:x=>{x.key==="ArrowDown"&&(x.preventDefault(),s.current=true,n(true));},children:re(mm)}),r?jsxRuntime.jsx(fm.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(x=>jsxRuntime.jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":x.label??o(x.labelKey),children:[jsxRuntime.jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:x.label??o(x.labelKey)}),x.children]},x.id))})}):null]})}function I2(e){if(!Bt.isValidElement(e))return false;let t=e.type;return (typeof t=="function"||typeof t=="object")&&t.docxToolbarGroup===true}function hy(e,t,o,r){let n=new Map,i=new Map,a=new Map,l=[];for(let s of Bt.Children.toArray(e)){if(I2(s)){a.delete(s.props.id),a.set(s.props.id,s.props);continue}let c=t(s);if(c&&o(c))n.set(c,s);else if(c&&r(c))i.set(c,s);else {if(c&&Bt.isValidElement(s)&&s.props.hidden===true)continue;l.push(s);}}return {overrides:n,tableOverrides:i,groups:[...a.values()],appended:l}}function Ys(e,t){return e.label!==void 0?e.label:e.labelKey!==void 0?t(e.labelKey):e.id}function gm(e){let t=ne();return e.hidden?null:jsxRuntime.jsx("div",{role:"group","aria-label":Ys(e,t),className:`docx-toolbar__group${e.className?` ${e.className}`:""}`,"data-toolbar-host-group":e.id,children:e.children})}gm.docxToolbarGroup=true;function Di(e){return e.hidden?null:jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.children})}Di.docxToolbarSlot=true;var bm=Bt.createContext("bar");function yy(){return Bt.useContext(bm)}var Xs="review.addComment";function A2({className:e,hidden:t,icon:o,asChild:r,children:n}){let i=Bt.useContext(Lt),a=ne(),{isEnabled:l,reason:s}=Wl(a),c=pa();if(t||(i?.mounted??0)===0)return null;let d=Q(Xs),m=a(d?.labelKey??Xs),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Xs,disabled:!l,...l?{}:{"data-disabled":""},"aria-label":m,title:s??m,onMouseDown:U,onClick:()=>{i?.requestCommentDraft()&&c(false);}};return r?jsxRuntime.jsx(J,{...u,children:n}):jsxRuntime.jsx("button",{...u,children:o??n??re(d?.paths)})}var hm=Object.assign(A2,{docxSlot:Xs});var Cy=new Set;function Js(e){!bt()||Cy.has(e)||(Cy.add(e),console.warn(`[docx-editor] ${e}`));}function Ty(e,t,o){Js(`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 Ey(e,t){Js(`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 Sy(e){Js(`Toolbar.Group "${e}" uses the id of the contextual table group, so it is ignored. Give the group another id.`);}function Py(e,t){Js(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 xm=[{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 ec({className:e,hidden:t,asChild:o,children:r}){let{t:n}=L(),i=ne(),{execute:a,value:l,isEnabled:s,disabledReason:c}=gi("image.wrap"),[d,m]=Bt.useState(false),u=Bt.useRef(null),g=Bt.useRef(null),p=Bt.useRef(null),f=Bt.useId(),h=Bt.useMemo(()=>xm.find(T=>T.value===l)??xm[0],[l]),y=Q("image.wrap"),x=i(y?.labelKey??"formattingBar.imageWrap");Bt.useEffect(()=>{if(!d)return;let T=S=>{let k=u.current;k&&editor.isDomNode(S.target)&&k.contains(S.target)||m(false);},C=S=>{S.key==="Escape"&&(S.preventDefault(),m(false),g.current?.focus());},E=editor.hostDocumentOf(u.current);return E.addEventListener("mousedown",T,true),E.addEventListener("keydown",C),()=>{E.removeEventListener("mousedown",T,true),E.removeEventListener("keydown",C);}},[d]);let b=Bt.useCallback(T=>{m(false),a(T);},[a]);if(t)return null;let v=n("imageWrap.tooltipPrefix",{label:n(h.labelKey)}),P={type:"button",ref:g,className:`docx-toolbar__button docx-toolbar__image-wrap-trigger${e?` ${e}`:""}`,"data-slot":"image.wrap",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?f:void 0,"aria-label":x,title:c??v,onMouseDown:U,onClick:()=>m(T=>!T)};return jsxRuntime.jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsxRuntime.jsx(J,{...P,children:r}):jsxRuntime.jsx("button",{...P,children:r??re(y?.paths)}),d?jsxRuntime.jsx("div",{ref:p,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":n("imageWrap.menu.ariaLabel"),onMouseDown:T=>T.stopPropagation(),children:xm.map(T=>jsxRuntime.jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":l===T.value,...l===T.value?{"data-active":""}:{},onMouseDown:U,onClick:()=>b(T.value),children:n(T.labelKey)},T.value))}):null]})}ec.docxSlot="image.wrap";var Ri=Object.assign(ec,{docxSlot:"image.wrap"});var ma="table.insert";function Q2({className:e,hidden:t,icon:o,asChild:r,children:n}){let i=H(),{isEnabled:a,disabledReason:l}=oe(ma),s=ne(),[c,d]=Bt.useState(false),m=Bt.useRef(null),u=Bt.useRef(null),g=Bt.useRef(null),p=Bt.useId(),f=pa();Bt.useEffect(()=>{if(!(!c||!m.current))return editor.listenForOutsidePress({popup:m.current,close:()=>d(false)})},[c]),Bt.useEffect(()=>{c&&m.current?.querySelector('[role="gridcell"][tabindex="0"]')?.focus();},[c]);let h=c&&a;Bt.useLayoutEffect(()=>{let P=g.current,T=m.current,C=T?.ownerDocument.defaultView;if(!h||!P||!T||!C||T.closest(".docx-toolbar__more-panel"))return;let E=T.getBoundingClientRect(),S=editor.toolbarPopupLeft({anchorLeft:E.left,popupWidth:P.offsetWidth,viewportWidth:C.innerWidth});P.style.left=`${S-E.left}px`;},[h]);let y=Bt.useCallback(()=>{d(false),f(false);},[f]);if(t)return null;let x=Q(ma),b=s(x?.labelKey??ma),v={ref:u,type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":ma,disabled:!a,...a?{}:{"data-disabled":""},...h?{"data-active":""}:{},"aria-haspopup":"grid","aria-expanded":h,"aria-controls":h?p:void 0,"aria-label":b,title:l??b,onMouseDown:U,onClick:()=>{if(!c){d(true);return}d(false),i?.focus();},onKeyDown:P=>{P.key==="ArrowDown"&&(P.preventDefault(),d(true));}};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__table-insert",children:[r?jsxRuntime.jsx(J,{...v,children:n}):jsxRuntime.jsx("button",{...v,children:o??n??re(x?.paths)}),h?jsxRuntime.jsx("div",{ref:g,id:p,className:"docx-toolbar__menu docx-toolbar__table-insert-menu",onBlur:P=>{let T=P.relatedTarget;editor.isDomNode(T)&&!m.current?.contains(T)&&d(false);},onKeyDown:P=>{P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),d(false),u.current?.focus());},children:jsxRuntime.jsx(jl,{slot:ma,label:s("toolbar.insertTable"),onInserted:y})}):null]})}var Cm=Object.assign(Q2,{docxSlot:ma});function tt(e){return Object.assign(o=>jsxRuntime.jsx(Bo,{slotId:e,...o}),{docxSlot:e})}var wy=tt("history.undo"),Dy=tt("history.redo"),Ry=tt("text.bold"),My=tt("text.italic"),_y=tt("text.underline"),Iy=tt("text.strike"),Ny=tt("format.clear"),Fy=tt("script.super"),Ly=tt("script.sub"),Hy=tt("alignment.left"),Ay=tt("alignment.center"),Oy=tt("alignment.right"),By=tt("alignment.justify"),Wy=tt("direction.ltr"),Zy=tt("direction.rtl"),Ky=tt("list.bullet"),qy=tt("list.numbered"),Uy=tt("list.outdent"),zy=tt("list.indent");var $y=tt("review.comments");function o_({className:e,hidden:t,icon:o,asChild:r,children:n}){let{execute:i,isEnabled:a,disabledReason:l}=oe("text.link"),s=ne(),c=Yt();if(t)return null;let d=Q("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:U,onClick:()=>i()};return r?jsxRuntime.jsx(J,{...u,children:n}):jsxRuntime.jsx("button",{...u,children:o??n??re(d?.paths)})}var Tm=Object.assign(o_,{docxSlot:"text.link"});function r_({className:e,hidden:t}){let o=H(),{onSave:r}=Bt.useContext(Hr),n=ne();if(t)return null;let i=Q("file.save"),a=n(i?.labelKey??"file.save"),l=!o||!r;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:U,onClick:()=>r?.(),children:re(i?.paths)})}var Em=Object.assign(r_,{docxSlot:"file.save"});function Jr({className:e}){return jsxRuntime.jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}var i_=e=>({zoom:e.zoom,mode:e.zoomMode}),l_=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,Gy={type:"fixed"};function Sm(){let e=H(),{zoom:t,mode:o}=W(i_,l_),r=Bt.useCallback(i=>{e?.setZoom(i);},[e]),n=Bt.useCallback(i=>{e?.setZoomMode(i);},[e]);return Bt.useMemo(()=>{let i=o??Gy,a=Si(t,"out"),l=Si(t,"in");return {zoom:t,mode:i,isFit:i.type==="fit",setZoom:r,setMode:n,fitToWidth:()=>n(editor.FIT_WIDTH_ZOOM_MODE),auto:()=>n("auto"),reset:()=>{n(Gy),r(1);},zoomIn:()=>l!==null&&r(l),zoomOut:()=>a!==null&&r(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:qs}},[e,t,o,r,n])}var Ii=2,Ni=3276,_i=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],u_=e=>e.formatting?.fontSizePt??null;function Xy(e,t,o){for(let r of t)if(r>e)return r;return Math.min(e+1,o)}function Jy(e,t,o){for(let r=t.length-1;r>=0;r-=1)if(t[r]<e)return t[r];return Math.max(e-1,o)}function tx(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:U,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:U,onClick:e.onIncrease,children:"+"})]})}function p_(e){let t=e.trim().replace(/pt$/i,"").trim();if(t==="")return null;let o=Number(t);if(!Number.isFinite(o))return null;let r=Math.round(o*2);return r<Ii||r>Ni?null:r}function m_({className:e,hidden:t}){let o=H(),r=W(u_),{isEnabled:n,disabledReason:i}=oe("font.size"),a=ne(),[l,s]=Bt.useState(false),[c,d]=Bt.useState(null),m=Bt.useRef(null);Oo(m,l,()=>s(false));let u=Bt.useRef(null),g=Bt.useId(),p=Bt.useCallback(T=>{if(!o)return;let C=editor.commandForSlotValue("font.size",T);C&&o.can(C).ok&&o.exec(C);},[o]),f=Bt.useCallback(T=>{p(Math.min(Ni,Math.max(Ii,Math.round(T*2))));},[p]),h=Bt.useCallback(T=>{s(false),d(null),u.current?.blur(),T&&o?.focus();},[o]);if(Bt.useEffect(()=>{if(l)return editor.listenForOutsidePress({popup:m.current,close:()=>{s(false),d(null);}})},[l]),t)return null;let y=n&&r!==null,x=r===null?"\u2014":String(Math.round(r*2)/2),b=c??x,v=r===null?null:Math.round(r*2)/2,P=()=>{if(c===null)return;let T=p_(c);T!==null&&p(T);};return jsxRuntime.jsxs("span",{ref:m,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsxRuntime.jsx(tx,{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:b,disabled:!n,role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-label":a("fontSize.label"),"aria-controls":l?g:void 0,autoComplete:"off",onChange:T=>{d(T.target.value),s(true);},onFocus:T=>{T.target.select(),s(true);},onClick:()=>s(true),onKeyDown:T=>{T.key==="Enter"?(T.preventDefault(),P(),h(true)):T.key==="Escape"?(T.preventDefault(),h(true)):(T.key==="ArrowDown"||T.key==="ArrowUp")&&(T.preventDefault(),s(true),r!==null&&f(T.key==="ArrowDown"?Jy(r,_i,Ii/2):Xy(r,_i,Ni/2)));},onBlur:()=>{P(),d(null);}}),canDecrease:y&&Math.round(r*2)>Ii,canIncrease:y&&Math.round(r*2)<Ni,onDecrease:()=>f(Jy(r??0,_i,Ii/2)),onIncrease:()=>f(Xy(r??0,_i,Ni/2))}),l&&n?jsxRuntime.jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox",tabIndex:0,"aria-label":a("fontSize.listLabel"),id:g,children:_i.map(T=>{let C=v===T;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>{f(T),h(true);},children:T},T)})}):null]})}var wm=Object.assign(m_,{docxSlot:"font.size"});function f_({className:e,hidden:t}){let o=H(),{zoom:r,isFit:n,mode:i,setZoom:a,setMode:l,zoomIn:s,zoomOut:c,canZoomIn:d,canZoomOut:m,levels:u}=Sm(),g=ne(),[p,f]=Bt.useState(false),h=Bt.useRef(null);Oo(h,p,()=>f(false)),Bt.useEffect(()=>{if(p)return editor.listenForOutsidePress({popup:h.current,close:()=>f(false)})},[p]);let y=Bt.useCallback(T=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),a(T);},[a]),x=Bt.useCallback(T=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),l(T==="auto"?"auto":editor.FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let b=`${Math.round(r*100)}%`,v=editor.sameZoomMode(i,editor.AUTO_ZOOM_MODE),P=editor.sameZoomMode(i,editor.FIT_WIDTH_ZOOM_MODE);return jsxRuntime.jsxs("span",{ref:h,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsxRuntime.jsx(tx,{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")}: ${b}`,onMouseDown:U,onClick:()=>f(T=>!T),children:[b,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":v,...v?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>x("auto"),children:g("zoom.automatic")}),jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":P,...P?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>x("fit-width"),children:g("zoom.fitWidth")}),jsxRuntime.jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(T=>{let C=!n&&Math.abs(T-r)<.001;return jsxRuntime.jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>y(T),children:`${Math.round(T*100)}%`},T)})]}):null]})}var Dm=Object.assign(f_,{docxSlot:"zoom.level"});function Qr(e,t,o,r=false){let n=ke(),i=Bt.useRef(n);i.current=n,Bt.useEffect(()=>{e&&r&&t(false);},[e,r,t]),Bt.useEffect(()=>{let a=o.current;if(!e||r||!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,r,t,o]);}var ax=10,ix=0,T_=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),E_=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function S_({className:e,hidden:t}){let o=H(),r=W(T_,E_),{isEnabled:n,disabledReason:i}=oe("list.lineSpacing"),a=oe("paragraph.dialog"),l=cy(),s=ne(),{lang:c}=L(),[d,m]=Bt.useState(false),u=Bt.useRef(null),g=Bt.useRef(null);Qr(d,m,u,t);let p=Bt.useCallback(v=>{m(false),!(!o||!v.command)&&o.can(v.command).ok&&o.exec(v.command);},[o]),f=Bt.useCallback((v,P)=>{if(m(false),!o)return;let T={type:"setParagraphSpacing",[v]:P};o.can(T).ok&&o.exec(T);},[o]);if(t)return null;let h=Q("list.lineSpacing"),y=(r.spaceBeforePt??0)>0,x=(r.spaceAfterPt??0)>0,b=editor.lineSpacingMenuRows(r.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:!n,...n?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-label":s("lineSpacing.label"),title:i??s("lineSpacing.label"),onMouseDown:U,onClick:()=>m(v=>!v),children:[re(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),d&&n?jsxRuntime.jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[b.map(v=>{let P=v.selected;return jsxRuntime.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":P,...P?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>p(v),children:[editor.lineSpacingMenuRowLabel(v,s,c),P?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]},`${v.spacing.rule}:${v.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:U,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:U,onClick:()=>f("beforePt",y?ix:ax),children:s(y?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>f("afterPt",x?ix:ax),children:s(x?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var Rm=Object.assign(S_,{docxSlot:"list.lineSpacing"});var w_=["alignment.left","alignment.center","alignment.right","alignment.justify"];function D_({className:e,hidden:t}){let o=oe("alignment.left"),r=oe("alignment.center"),n=oe("alignment.right"),i=oe("alignment.justify"),a=ne(),[l,s]=Bt.useState(false),c=Bt.useRef(null);if(Qr(l,s,c,t),t)return null;let d=[o,r,n,i],m=w_.map((f,h)=>({slot:f,control:Q(f),state:d[h]})),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:U,onClick:()=>s(f=>!f),children:[re(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 h=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":h,title:f.state.disabledReason??h,onMouseDown:U,onClick:()=>{f.state.execute(),s(false);},children:re(f.control?.paths)},f.slot)})}):null]})}var rc=Object.assign(D_,{docxSlot:"alignment"});function _m(e){let{label:t,icon:o,active:r,disabled:n,disabledReason:i,onSelect:a,asChild:l,className:s,children:c}=e,d=yy(),m=pa();if(d==="panel"&&!l)return jsxRuntime.jsxs("button",{type:"button",className:`docx-toolbar__more-command${s?` ${s}`:""}`,disabled:n,...r?{"data-active":""}:{},...r!==void 0?{"aria-pressed":r}:{},...n&&i?{title:i}:{},onMouseDown:g=>U(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:n,...r?{"data-active":""}:{},...n?{"data-disabled":""}:{},...r!==void 0?{"aria-pressed":r}:{},"aria-label":t,title:n?i??t:t,onMouseDown:g=>U(g),onClick:n?void 0:a};return l?jsxRuntime.jsx(J,{...u,children:c}):jsxRuntime.jsx("button",{...u,children:o??c})}var H_=Object.freeze([]),A_=e=>e.formatting?.fontFamily??null,O_=e=>e;function ic(){let e=H(),t=W(A_),o=W(O_),r=Bt.useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():H_,[e,o]),{isEnabled:n}=oe("font.family"),i=Bt.useCallback(a=>{if(!e)return;let l=editor.commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return Bt.useMemo(()=>({value:t,setValue:i,options:r,isEnabled:n}),[t,i,r,n])}var dx=Bt.createContext(null);function Nm(){return Bt.useContext(dx)}function Fm({asChild:e,className:t,children:o}){let r=Nm(),n=ne();if(!r)return null;let i=n(Q("font.family")?.labelKey??"font.family"),a={onClick:()=>r.setOpen(!r.open),onMouseDown:U,disabled:!r.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...r.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":r.open,"aria-label":o!==void 0?void 0:`${i}: ${r.value??"\u2014"}`,title:i},l=o??jsxRuntime.jsx("span",{children:r.value??"\u2014"});return e?jsxRuntime.jsx(J,{...a,children:l}):jsxRuntime.jsx("button",{type:"button",...a,children:l})}Fm.docxToolbarPart=true;var B_=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"]]),W_=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function ux({asChild:e,className:t,children:o}){let r=Nm(),n=ne(),[i,a]=Bt.useState("");if(Bt.useEffect(()=>{r?.open||a("");},[r?.open]),!r||!r.open)return null;let l={role:"listbox",tabIndex:0,"aria-label":n("font.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`},s;return o!==void 0?s=o:s=W_.map(d=>({...d,fonts:r.options.filter(m=>m.toLowerCase().includes(i.toLowerCase())&&(B_.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:n(d.labelKey)}):null,d.fonts.map(u=>jsxRuntime.jsx(px,{value:u},u))]},d.category)),e?jsxRuntime.jsx(J,{...l,children:s}):o!==void 0?jsxRuntime.jsx("div",{...l,children:s}):jsxRuntime.jsxs("div",{className:l.className,children:[jsxRuntime.jsx("input",{type:"search",className:"docx-toolbar__font-search","aria-label":n("font.search"),placeholder:n("font.search"),value:i,onChange:c=>a(c.target.value)}),jsxRuntime.jsx("div",{role:"listbox",tabIndex:0,"aria-label":n("font.selectAriaLabel"),className:"docx-toolbar__font-options",children:s})]})}function px({value:e,asChild:t,className:o,children:r}){let n=H(),i=Nm();if(!i)return null;let a=i.value===e,l={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:U,onClick:()=>{i.setValue(e),i.setOpen(false),n?.focus();},className:`docx-toolbar__font-family-item${o?` ${o}`:""}`},s=r??jsxRuntime.jsx("span",{style:{fontFamily:e},children:e});return t?jsxRuntime.jsx(J,{...l,children:s}):jsxRuntime.jsxs("button",{type:"button",...l,children:[s,a?jsxRuntime.jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function Z_({hidden:e,asChild:t,className:o,children:r}){let n=ic(),[i,a]=Bt.useState(false),l=Bt.useRef(null);Oo(l,i,()=>a(false)),Bt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=Bt.useMemo(()=>({...n,open:i,setOpen:a}),[n,i]);if(e)return null;let c={className:`docx-toolbar__font-family${o?` ${o}`:""}`,"data-slot":"font.family"},d=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Fm,{}),jsxRuntime.jsx(ux,{})]});return jsxRuntime.jsx(dx.Provider,{value:s,children:t?jsxRuntime.jsx(J,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Lm=Object.assign(Z_,{docxSlot:"font.family",Trigger:Fm,Content:ux,Item:px});var q_={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},U_=new Set(["Title","Heading1","Heading2","Heading3"]),z_={Subtitle:"666666"},$_="#4a6c8c";function mx(e){let t=q_[e.styleId],r={fontSize:t?`${t}px`:`${Math.min(Math.max(e.fontSize?e.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(e.bold??U_.has(e.styleId))&&(r.fontWeight="bold"),e.italic&&(r.fontStyle="italic");let n=e.color??z_[e.styleId];return n?r.color=`#${n}`:e.styleId.startsWith("Heading")&&(r.color=$_),r}var fx=/^heading ([1-9])$/;function Hm(e,t){let o=e||t,r=fx.exec(o);return r?`Heading ${r[1]}`:o}var V_=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 lc(e){let t=e.toLowerCase(),o=V_.get(t);if(o)return {key:o};let r=fx.exec(t);return r?{key:"styles.headingLevel",vars:{level:Number(r[1])}}:null}function gx(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:Hm(t.name,t.styleId),priority:99}))}function oI(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 rI=Object.freeze([]),nI=e=>e.formatting?.styleId??null,aI=e=>e;function sc(){let e=H(),t=W(nI),o=W(aI),{t:r}=L(),n=Bt.useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(l=>l.type==="paragraph").map(l=>{let s=lc(l.name);return {styleId:l.styleId,name:s?r(s.key,s.vars):Hm(l.name,l.styleId),preview:l.preview}}):rI,[e,o,r]),{isEnabled:i}=oe("styles.style"),a=Bt.useCallback(l=>{if(!e)return;let s=editor.commandForSlotValue("styles.style",l);s&&e.can(s).ok&&e.exec(s);},[e]);return Bt.useMemo(()=>({value:t,setValue:a,options:n,isEnabled:i}),[t,a,n,i])}var bx=Bt.createContext(null);function Om(){return Bt.useContext(bx)}function Bm({asChild:e,className:t,children:o}){let r=Om(),n=ne();if(!r)return null;let i=Q("styles.style"),a=n(i?.labelKey??"styles.style"),l={onClick:()=>r.setOpen(!r.open),onMouseDown:U,disabled:!r.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...r.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":r.open,title:a},s=r.options.find(d=>d.styleId===r.value),c=o??(r.value===null?jsxRuntime.jsx("span",{children:i?.valueKey?n(i.valueKey):"\u2014"}):jsxRuntime.jsx("span",{children:s?.name??r.value}));return e?jsxRuntime.jsx(J,{...l,children:c}):jsxRuntime.jsx("button",{type:"button",...l,children:c})}Bm.docxToolbarPart=true;function hx({asChild:e,className:t,children:o}){let r=ne(),n=Om();if(!n||!n.open)return null;let i={role:"listbox",tabIndex:0,"aria-label":r("styles.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`},a=o??n.options.map(l=>jsxRuntime.jsx(yx,{value:l.styleId},l.styleId));return e?jsxRuntime.jsx(J,{...i,children:a}):jsxRuntime.jsx("div",{...i,children:a})}function yx({value:e,asChild:t,className:o,children:r}){let n=H(),i=Om();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:U,onClick:()=>{i.setValue(e),i.setOpen(false),n?.focus();},className:`docx-toolbar__style-item${o?` ${o}`:""}`},c=r??jsxRuntime.jsx("span",{style:l?oI(l.preview):void 0,children:l?.name??e});return t?jsxRuntime.jsx(J,{...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 iI({hidden:e,asChild:t,className:o,children:r}){let n=sc(),[i,a]=Bt.useState(false),l=Bt.useRef(null);Oo(l,i,()=>a(false)),Bt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=Bt.useMemo(()=>({...n,open:i,setOpen:a}),[n,i]);if(e)return null;let c={className:`docx-toolbar__style${o?` ${o}`:""}`,"data-slot":"styles.style"},d=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Bm,{}),jsxRuntime.jsx(hx,{})]});return jsxRuntime.jsx(bx.Provider,{value:s,children:t?jsxRuntime.jsx(J,{...c,ref:l,children:d}):jsxRuntime.jsx("div",{ref:l,...c,children:d})})}var Wm=Object.assign(iI,{docxSlot:"styles.style",Trigger:Bm,Content:hx,Item:yx});function vx(e,t){let o=e;return Object.assign(({className:n,hidden:i,icon:a,asChild:l,children:s})=>{let{isEnabled:c,disabledReason:d}=oe(o),m=vo(),u=t==="showAll"?m.showAll:m.formFill,g=ne();if(i)return null;let p=Q(o),f=g(p?.labelKey??e),h={type:"button",className:`docx-toolbar__button${n?` ${n}`:""}`,"data-slot":e,disabled:!c,...c?{}:{"data-disabled":""},...u?{"data-active":""}:{},"aria-pressed":u,"aria-label":f,title:d??f,onMouseDown:U,onClick:()=>{t==="showAll"?m.toggleShowAll():m.toggleFormFill();}};return l?jsxRuntime.jsx(J,{...h,children:s}):jsxRuntime.jsx("button",{...h,children:a??s??re(p?.paths)})},{docxSlot:o})}function sI({className:e,hidden:t,icon:o,asChild:r,children:n}){let i=wt.inspector,{isEnabled:a,disabledReason:l}=oe(i),{inspectorOpen:s,openInspector:c}=vo(),d=ne();if(t)return null;let m=Q(i),u=d(m?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":wt.inspector,disabled:!a,...a?{}:{"data-disabled":""},...s?{"data-active":""}:{},"aria-pressed":s,"aria-label":u,title:l??u,onMouseDown:U,onClick:()=>c()};return r?jsxRuntime.jsx(J,{...g,children:n}):jsxRuntime.jsx("button",{...g,children:o??n??re(m?.paths)})}function cI({className:e,hidden:t,icon:o,asChild:r,children:n}){let{canRemove:i,removeDisabledReason:a,remove:l}=vo(),s=ne();if(t)return null;let c=wt.remove,d=Q(c),m=s(d?.labelKey??"contentControl.remove"),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":wt.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":m,title:a??m,onMouseDown:U,onClick:()=>{l();}};return r?jsxRuntime.jsx(J,{...u,children:n}):jsxRuntime.jsx("button",{...u,children:o??n??re(d?.paths)})}var cc=vx(wt.showAll,"showAll"),dc=vx(wt.formFill,"formFill"),uc=Object.assign(cI,{docxSlot:wt.remove}),pc=Object.assign(sI,{docxSlot:wt.inspector}),Cx={[wt.showAll]:cc,[wt.formFill]:dc,[wt.inspector]:pc,[wt.remove]:uc};var ga=Object.assign(e=>jsxRuntime.jsx(Bo,{slotId:"table.mergeCells",...e}),{docxSlot:"table.mergeCells"});function dI({icon:e,className:t,children:o,hidden:r}){let{isEnabled:n,disabledReason:i}=oe("table.splitCell"),a=ko(),l=ne();if(r||!a)return null;let s=l(Q("table.splitCell")?.labelKey??"table.splitCell");return jsxRuntime.jsx("button",{type:"button","data-slot":"table.splitCell",className:`docx-toolbar__button${t?` ${t}`:""}`,disabled:!n,...n?{}:{"data-disabled":""},"aria-label":s,"aria-haspopup":"dialog",title:i??s,onMouseDown:U,onClick:c=>a.open("splitCell",c.currentTarget),children:e??o??re(Q("table.splitCell")?.paths)})}var ba=Object.assign(dI,{docxSlot:"table.splitCell"});function Zm(e,t){let o=H(),r=Bt.useRef(t);r.current=t,Bt.useEffect(()=>{if(!o)return;let n=((...i)=>{r.current(...i);});return o.on(e,n)},[o,e]);}var hI=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],qm=Bt.createContext(null);function Rx(){let e=Bt.useContext(qm);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function xI(e,t){let o=t.table,n=(e?.getSelectedTable()??null)?.blockId??"",i=o?`${n}|${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 vI(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function CI(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var wx={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function TI(e,t){let o={};for(let r of hI){let n=editor.tableChromeToolbarState(e,r,t);o[r]={enabled:n.enabled,disabledReason:n.disabledReason};}return o}function Um({children:e}){let t=H(),[o,r]=Bt.useState(editor.DEFAULT_TABLE_CHROME_DRAFT),[n,i]=Bt.useState(wx);Bt.useEffect(()=>(()=>{}),[]);let a=W(Bt.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:""}),[]),vI,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=Bt.useCallback(()=>{if(!t){i(wx);return}let u=xI(t,t.snapshot());i(g=>CI(g,u)?g:u);},[t]);Bt.useEffect(()=>{l();},[l,a]),Zm("selectionChange",Bt.useCallback(()=>{l();},[l]));let s=n.tableKey!=="",c=Bt.useMemo(()=>t?TI(t,o):{},[t,o,n.tableKey,n.selectionKey,n.cellSelectionKey,n.editable,n.editingMode]),d=Bt.useCallback((u,g)=>{if(!t)return;let{result:p,nextDraft:f}=editor.runTableChromeCommand(t,u,g,o);p.ok&&f&&r(f);},[t,o]),m=Bt.useMemo(()=>({visible:s,draft:o,setDraft:r,slotState:u=>c[u]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[s,o,c,d]);return jsxRuntime.jsx(qm.Provider,{value:m,children:e})}function EI(){let e=Bt.useContext(qm);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function fc(e){let t=EI(),o=t.slotState(e);return Bt.useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:r=>t.apply(e,r)}),[t,e,o])}function bc(e){(editor.editorInstanceScope(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function hc({enabled:e,disabledReason:t,ariaLabel:o}){let{t:r}=L(),n=i18n.localizeDisabledReason(t,r),i=Bt.useId(),a=!e&&n?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:U,"aria-label":o,...a?{"aria-describedby":a}:{},...n?{title:n}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:a&&n?jsxRuntime.jsx("span",{id:i,className:"docx-editor-sr-only",children:n}):null}}var DI='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function Ix(e,t,o,r){Bt.useEffect(()=>{if(!e)return;let n=o.current,i=r.current;if(!n)return;let a=()=>[...n.querySelectorAll(DI)].filter(c=>c.closest('[role="menu"]')===n);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(),Qt(d,editor.hostDocumentOf(n).activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),Qt(d,editor.hostDocumentOf(n).activeElement,-1);return}if(c.key==="Home"){c.preventDefault(),eo(d,"first");return}if(c.key==="End"){c.preventDefault(),eo(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 n.addEventListener("keydown",s),()=>n.removeEventListener("keydown",s)},[e,t,o,r]);}function Nx(e,t,o,r){Bt.useEffect(()=>{if(!e)return;let n=o.current,i=r.current;if(!n)return;let a=()=>[...n.querySelectorAll('button:not([aria-disabled="true"])')].filter(s=>s.closest('[role="dialog"]')===n);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 n.addEventListener("keydown",l),()=>n.removeEventListener("keydown",l)},[e,t,o,r]);}function Bx(e,t,o){if(e)return r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),o(!t));}}function FI(e){return re(editor.tableChromeIconPaths(e))}function Wx(){return Bt.createContext(null)}function $o(e){let t=Bt.useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function $m(e,t,o){let r=Wx();function n({hidden:l,asChild:s,className:c,children:d}){let{visible:m,enabled:u,disabledReason:g,draft:p,apply:f}=fc(e),[h,y]=Bt.useState(false),x=Bt.useRef(null),b=Bt.useRef(null);Qr(h,y,x,l||!m);let v=Bt.useMemo(()=>({open:h,setOpen:y,enabled:u,disabledReason:g,apply:f,draft:p,triggerRef:b}),[h,u,g,f,p]);if(l||!m)return null;let P={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},T=d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(i,{}),jsxRuntime.jsx(a,{})]});return jsxRuntime.jsx(r.Provider,{value:v,children:s?jsxRuntime.jsx(J,{...P,ref:x,children:T}):jsxRuntime.jsx("div",{ref:x,...P,children:T})})}function i({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,disabledReason:g,triggerRef:p}=$o(r),f=ne(),h=Q(e),y=f(h?.labelKey??o),{shared:x,reasonNode:b}=hc({enabled:u,disabledReason:g,ariaLabel:y}),v={...x,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:Bx(u,d,m)}:{}},P=c??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[re(h?.paths),jsxRuntime.jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(J,{...v,children:P}),b]}):jsxRuntime.jsxs("button",{...v,children:[P,b]})}i.docxToolbarPart=true;function a({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,triggerRef:g}=$o(r),p=ne(),f=Bt.useRef(null);if(Ix(d&&u,m,f,g),!d||!u)return null;let h=Q(e),y=p(h?.labelKey??o),x={ref:f,role:"menu","aria-label":y,className:`docx-table-chrome__panel${s?` ${s}`:""}`,onMouseDown:U};return l?jsxRuntime.jsx(J,{...x,children:c}):jsxRuntime.jsx("div",{...x,children:c})}return {Root:n,Trigger:i,Content:a,Ctx:r}}var Hi=$m("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function Zx({value:e,asChild:t,className:o,children:r}){let{apply:n,setOpen:i,draft:a}=$o(Hi.Ctx),l=ne(),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:U,onClick:()=>{i(false),n(s.value);}},m=r??FI(s.icon);return t?jsxRuntime.jsx(J,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function Kx(e){let{children:t}=e;return jsxRuntime.jsx(Hi.Content,{...e,children:t??jsxRuntime.jsx("div",{className:"docx-table-chrome__target-grid",children:editor.TABLE_BORDER_TARGET_OPTIONS.map(o=>jsxRuntime.jsx(Zx,{value:o.value},o.value))})})}function LI(e){let{children:t}=e,o=t??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Hi.Trigger,{}),jsxRuntime.jsx(Kx,{})]});return jsxRuntime.jsx(Hi.Root,{...e,children:o})}var Zi=Object.assign(LI,{docxSlot:"table.borderTarget",Trigger:Hi.Trigger,Content:Kx,Item:Zx}),Ai=$m("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function qx({value:e,asChild:t,className:o,children:r}){let{apply:n,setOpen:i,draft:a}=$o(Ai.Ctx),l=ne(),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:U,onClick:()=>{i(false),n(s.value);}},m=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:`docx-table-line ${s.previewClass}`,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l(s.labelKey)})]});return t?jsxRuntime.jsx(J,{...d,children:m}):jsxRuntime.jsx("button",{...d,children:m})}function Ux(e){let{children:t}=e;return jsxRuntime.jsx(Ai.Content,{...e,children:t??editor.TABLE_BORDER_STYLE_OPTIONS.map(o=>jsxRuntime.jsx(qx,{value:o.value},o.value))})}function HI(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ai.Trigger,{}),jsxRuntime.jsx(Ux,{})]});return jsxRuntime.jsx(Ai.Root,{...e,children:t})}var Ki=Object.assign(HI,{docxSlot:"table.borderStyle",Trigger:Ai.Trigger,Content:Ux,Item:qx}),Oi=$m("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function zx({value:e,asChild:t,className:o,children:r}){let{apply:n,setOpen:i,draft:a}=$o(Oi.Ctx),l=ne(),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:U,onClick:()=>{i(false),n(c.size);}},u=r??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"docx-table-line docx-table-line--single",style:{height:`${c.previewThickness}px`},"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:l(c.labelKey)})]});return t?jsxRuntime.jsx(J,{...m,children:u}):jsxRuntime.jsx("button",{...m,children:u})}function $x(e){let{children:t}=e;return jsxRuntime.jsx(Oi.Content,{...e,children:t??editor.TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsxRuntime.jsx(zx,{value:String(o.size)},o.size))})}function AI(e){let t=e.children??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Oi.Trigger,{}),jsxRuntime.jsx($x,{})]});return jsxRuntime.jsx(Oi.Root,{...e,children:t})}var qi=Object.assign(AI,{docxSlot:"table.borderWidth",Trigger:Oi.Trigger,Content:$x,Item:zx});function Vx(e,t,o){let r=o?.defaultHex??"FF0000",n=Wx();function i({hidden:d,asChild:m,className:u,children:g}){let{visible:p,enabled:f,disabledReason:h,draft:y,apply:x}=fc(e),[b,v]=Bt.useState(false),[P,T]=Bt.useState(r),C=Bt.useRef(null),E=Bt.useRef(null);Qr(b,v,C,d||!p);let S=Bt.useMemo(()=>({open:b,setOpen:v,enabled:f,disabledReason:h,apply:x,draft:y,triggerRef:E,lastHex:P,setLastHex:T}),[b,f,h,x,y,P]);if(d||!p)return null;let k={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(n.Provider,{value:S,children:m?jsxRuntime.jsx(J,{...k,ref:C,children:w}):jsxRuntime.jsx("div",{ref:C,...k,children:w})})}function a({asChild:d,className:m,children:u}){let{enabled:g,disabledReason:p,apply:f,draft:h,lastHex:y}=$o(n),x=ne(),b=Q(e),v=x(b?.labelKey??t),{shared:P,reasonNode:T}=hc({enabled:g,disabledReason:p,ariaLabel:v}),C=e==="table.borderColor"&&h.spec.color.kind==="hex"?h.spec.color.value:y??r,E={...P,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:[re(b?.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(J,{...E,children:S}),T]}):jsxRuntime.jsxs("button",{...E,children:[S,T]})}a.docxToolbarPart=true;function l({asChild:d,className:m,children:u}){let{open:g,setOpen:p,enabled:f,disabledReason:h,triggerRef:y}=$o(n),x=ne(),b=Q(e),v=x(b?.labelKey??t),{shared:P,reasonNode:T}=hc({enabled:f,disabledReason:h,ariaLabel:v}),C={...P,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:Bx(f,g,p)}:{}},E=u??"\u25BE";return d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(J,{...C,children:E}),T]}):jsxRuntime.jsxs("button",{...C,children:[E,T]})}l.docxToolbarPart=true;function s({asChild:d,className:m,children:u,clearFill:g}){let{open:p,setOpen:f,enabled:h,apply:y,draft:x,triggerRef:b,lastHex:v,setLastHex:P}=$o(n),T=ne(),C=Bt.useRef(null);if(Nx(p&&h,f,C,b),!p||!h)return null;let E=T(t),S=e==="table.borderColor"&&x.spec.color.kind==="hex"?x.spec.color.value:v??r,k={ref:C,role:"dialog","aria-label":E,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${m?` ${m}`:""}`,onMouseDown:U},w=u??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g?jsxRuntime.jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:U,onClick:()=>{f(false),y(null),bc(b.current);},children:[jsxRuntime.jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),T("table.clearCellFill")]}):null,jsxRuntime.jsx(Zd,{apply:I=>{f(false),P?.(I),y({kind:"hex",value:I}),bc(b.current);},current:S})]});return d?jsxRuntime.jsx(J,{...k,children:w}):jsxRuntime.jsx("div",{...k,children:w})}function c({value:d,css:m,labelKey:u,asChild:g,className:p,children:f}){let{apply:h,setOpen:y,setLastHex:x,triggerRef:b}=$o(n),v=ne(),P=m??`#${d.toLowerCase()}`,T=u?v(u):d,C={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:P},"data-value":d,"aria-label":T,title:T,onMouseDown:U,onClick:()=>{y(false),x?.(d),h({kind:"hex",value:d}),bc(b.current);}};return g?jsxRuntime.jsx(J,{...C,children:f}):jsxRuntime.jsx("button",{...C,children:f})}return {Root:i,Main:a,Trigger:l,Content:s,Item:c,Ctx:n}}var Bi=Vx("table.borderColor","table.borderColor",{defaultHex:"000000"});function OI(e){return jsxRuntime.jsx(Bi.Content,{...e,clearFill:false})}function BI(e){return jsxRuntime.jsx(Bi.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function WI(e){return jsxRuntime.jsx(Bi.Root,{...e})}var Ui=Object.assign(WI,{docxSlot:"table.borderColor",Trigger:Bi.Trigger,Content:OI,Item:BI,Main:Bi.Main}),Wi=Vx("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function ZI(e){return jsxRuntime.jsx(Wi.Content,{...e,clearFill:true})}function KI(e){return jsxRuntime.jsx(Wi.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function qI(e){return jsxRuntime.jsx(Wi.Root,{...e})}var zi=Object.assign(qI,{docxSlot:"table.cellFill",Trigger:Wi.Trigger,Content:ZI,Item:KI,Main:Wi.Main});function Gx({overrides:e=new Map,separator:t=true}){return Rx()?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t?jsxRuntime.jsx(Jr,{}):null,[Zi,Ui,Ki,qi,zi].map(n=>{let i=e.get(n.docxSlot);return i?jsxRuntime.jsx(Bt.Fragment,{children:i},n.docxSlot):jsxRuntime.jsx(n,{},n.docxSlot)}),[ga,ba].map(n=>{let i=e.get(n.docxSlot);return i?jsxRuntime.jsx(Bt.Fragment,{children:i},n.docxSlot):jsxRuntime.jsx(n,{},n.docxSlot)})]}):null}function jx(){let e=ne(),{draft:t}=fc("table.borderTarget");return e(editor.tableChromeLabelKeyForTarget(t.activeTarget))}var Gm=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill","table.mergeCells","table.splitCell"],on="contextual-table",jm={"zoom.level":Dm,"styles.style":Wm,"font.family":Lm,"font.size":wm,"text.color":Kd,"text.highlight":qd,"text.link":Tm,"list.lineSpacing":Rm,"review.editingMode":$s,"review.authors":Gs,"file.save":Em,...Cx,"table.borderTarget":Zi,"table.borderColor":Ui,"table.borderStyle":Ki,"table.borderWidth":qi,"table.cellFill":zi,"table.splitCell":ba,"image.insert":Ya,"image.properties":ia,"image.wrap":Ri,"image.altText":bi},yc={id:on,labelKey:"formattingBar.groups.table",entries:Gm.map(e=>({slot:e,Part:e==="table.mergeCells"?ga:jm[e]}))},Yx=new Map;function QI(e){let t=Yx.get(e);return t||(t=o=>jsxRuntime.jsx(Bo,{slotId:e,...o}),Yx.set(e,t)),t}function e8(e,t){return editor.formattingBarChromeGroups(e,{direction:t}).map(o=>o.id==="alignment"?{id:o.id,labelKey:o.labelKey,entries:[{slot:"alignment",Part:rc}]}:{id:o.id,labelKey:o.labelKey,entries:o.controls.map(r=>{let n=editor.chromeSlotId(o,r);return {slot:n,Part:jm[n]??QI(n)}})})}var t8=e=>e.image,o8=e=>e.isLoading||e.isOpening===true,r8=e=>e.table!==null;function n8(e){return e==="alignment"||e in jm}function Cc(e){let t=Mn(e,Cc);if(t!==null)return t;if(!Bt.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 r=e.props.slotId;return typeof r=="string"?r:null}if(o.docxToolbarPart===true){let r=e.props,n=r.slotId??r.slot;if(typeof n=="string")return n}return null}function Vm(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(Vm);let t=Cc(e);return t!=null&&Gm.includes(t)?true:Bt.isValidElement(e)?Bt.Children.toArray(e.props.children).some(Vm):false}function a8(e,t){return t?true:Bt.Children.toArray(e).some(Vm)}function i8(e){let t=qt(),{className:o,t:r,onSave:n,preset:i=true,overflow:a=true,children:l}=e,s=Bt.useMemo(()=>({t:r,onSave:n}),[r,n]),c=_l(r),d=W(t8),m=W(o8),u=W(r8),g=it(),p=g==="rtl",f=Bt.useMemo(()=>e8(d,p),[d,p]),h=Bt.useMemo(()=>new Set(f.flatMap(S=>S.entries.map(k=>k.slot))),[f]),y=Bt.useMemo(()=>i?hy(l,Cc,S=>h.has(S),S=>Gm.includes(S)):null,[i,l,h]),x=Bt.useMemo(()=>y?l8(f,y):[],[f,y]),b=Bt.useMemo(()=>[...x.filter(S=>!S.pinned).map(S=>({id:S.id,items:Xx(S,y?.overrides)})),...u?[{id:on,items:[on]}]:[]],[x,y,u]),v=Bt.useMemo(()=>{let S=new Map;for(let k of x)k.priority!==void 0&&S.set(k.id,k.priority);return editor.collapseOrder(b.map(k=>k.id),editor.TOOLBAR_COLLAPSE_ORDER,S)},[x,b]),P=i&&a,{attach:T,overflow:C}=Cu(P,b,v),E;if(!y)E=l;else {let{overrides:S,tableOverrides:k,appended:w}=y,I=R=>{let z=S.get(R.slot);if(z)return z;let V=R.Part;return jsxRuntime.jsx(V,{})},O=R=>{let z=k.get(R.slot);if(z)return z;let V=R.Part;return jsxRuntime.jsx(V,{})},N=[],B=[],F=0;for(let R of x){let z=Xx(R,S),V=new Map(R.entries.map(q=>[q.slot,q])),ee=R.pinned?z.length:editor.toolbarShownCount(C,R.id,z.length),Y=z.slice(ee);if(Y.length>0){let q=Y.flatMap(ce=>{let A=V.get(ce);if(!A)return [];let _=Jx(A,S,c,R.labelKey,I);return _===null?[]:[jsxRuntime.jsx(Bt.Fragment,{children:_},A.slot)]}),G=editor.toolbarHostPanelShown(R.extras.length>0,Y)?c8(R):null;G!==null&&q.push(jsxRuntime.jsx(Bt.Fragment,{children:G},"host")),q.length>0&&B.push({id:R.id,labelKey:R.labelKey,...R.heading?{label:Ys(R.heading,c)}:{},children:q});}ee!==0&&(F>0&&N.push(jsxRuntime.jsx(Jr,{},`separator-${R.id}`)),F+=1,N.push(jsxRuntime.jsx("div",{className:`docx-toolbar__group${R.className?` ${R.className}`:""}`,...R.heading?{role:"group","aria-label":Ys(R.heading,c)}:{},...R.pinned?{[Fn]:""}:{[Nn]:R.id},children:z.slice(0,ee).map(q=>{let G=V.get(q);return jsxRuntime.jsx("div",{className:"docx-toolbar__item",[xb]:q,children:G?I(G):R.extras},q)})},R.id)));}let D=C.has(on);if(u&&D){let R=yc.entries.flatMap(z=>{let V=Jx(z,k,c,yc.labelKey,O);return V===null?[]:[jsxRuntime.jsx(Bt.Fragment,{children:V},z.slot)]});R.length>0&&B.unshift({id:yc.id,labelKey:yc.labelKey,children:R});}E=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[N,u&&!D?jsxRuntime.jsx(Jr,{},"separator-contextual-table"):null,D?null:jsxRuntime.jsx("div",{className:"docx-toolbar__contextual",[Nn]:on,children:jsxRuntime.jsx(Gx,{overrides:k,separator:false})}),w.length>0?jsxRuntime.jsx("div",{className:"docx-toolbar__group",[Fn]:"",children:w}):null,B.length>0?jsxRuntime.jsx(gy,{sections:B}):null]});}return jsxRuntime.jsx(Hr.Provider,{value:s,children:jsxRuntime.jsx(sy,{children:jsxRuntime.jsx("fieldset",{ref:T,disabled:m,"aria-label":c("formattingBar.label"),"data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,dir:g,...P?{"data-overflow":""}:{},onMouseDown:U,children:a8(l,i)?jsxRuntime.jsx(Um,{children:E}):E})})})}function Tc(e){if(!e)return false;if(e.type===Bt.Fragment){let t=Bt.Children.toArray(e.props.children).find(o=>Cc(o)!==null);return Bt.isValidElement(t)?Tc(t):false}return !!e.props.hidden}function Xx(e,t){let o=e.entries.filter(r=>!Tc(t?.get(r.slot))).map(r=>r.slot);return editor.toolbarGroupItems(o,e.extras.length>0)}function l8(e,t){let o=new Map(t.groups.map(s=>[s.id,s])),r=new Set(e.map(s=>s.id)),n=new Map;for(let s of e){let c=o.get(s.id);if(c&&s8(c),c?.hidden)continue;let d=Bt.Children.toArray(c?.children);!s.entries.some(u=>!Tc(t.overrides.get(u.slot)))&&d.length===0||n.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===on&&Sy(s.id);let i=t.groups.filter(s=>!r.has(s.id)&&s.id!==on);for(let s of i){let c=Bt.Children.toArray(s.children);s.hidden||c.length===0||n.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=[...r,...i.map(s=>s.id)];for(let s of i)s.after!==void 0&&!a.includes(s.after)&&Ty(s.id,s.after,a);for(let s of t.appended){if(!Bt.isValidElement(s)||s.type!==Di)continue;let c=s.props.slotId;Py(c,Q(c)!==null);}return editor.arrangeToolbarGroups(e.map(s=>s.id),i.map(s=>({id:s.id,after:s.after}))).flatMap(s=>{let c=n.get(s);return c?[c]:[]})}function s8(e){for(let t of ["label","labelKey","after"])e[t]!==void 0&&Ey(e.id,t);}function c8(e){return e.overflowContent?e.overflowContent():e.extras.length===0?null:jsxRuntime.jsx(bm.Provider,{value:"panel",children:jsxRuntime.jsx("div",{className:"docx-toolbar__more-host",children:e.extras})})}function Jx(e,t,o,r,n){let i=t.get(e.slot);if(Tc(i))return null;let a=i?.type===Di?i.props.overflowContent:void 0;return i||n8(e.slot)?jsxRuntime.jsx(my,{label:d8(o,e,r),children:a?a():n(e)}):jsxRuntime.jsx(fy,{slot:e.slot})}function d8(e,t,o){let r=t.slot==="alignment"?null:Q(t.slot);return e(r?.labelKey??o)}var Vi=Object.assign(i8,{Button:Bo,Action:_m,Separator:Jr,Group:gm,Slot:Di,AddComment:hm,Undo:wy,Redo:Dy,Bold:Ry,Italic:My,Underline:_y,Strike:Iy,Link:Tm,ClearFormatting:Ny,Superscript:Fy,Subscript:Ly,Alignment:rc,AlignLeft:Hy,AlignCenter:Ay,AlignRight:Oy,AlignJustify:By,LeftToRight:Wy,RightToLeft:Zy,LineSpacing:Rm,BulletList:Ky,NumberedList:qy,Outdent:Uy,Indent:zy,ImageInsert:Ya,ImageProperties:ia,ImageWrap:Ri,ImageAltText:bi,TableInsert:Cm,TableBorderTarget:Zi,TableBorderColor:Ui,TableBorderStyle:Ki,TableBorderWidth:qi,TableCellFill:zi,TableMergeCells:ga,TableSplitCell:ba,Comments:$y,FontFamily:Lm,FontSize:wm,FontColor:Kd,Highlight:qd,Zoom:Dm,StylePicker:Wm,EditingMode:$s,Reviewers:Gs,Save:Em,ContentControlShowAll:cc,ContentControlFormFill:dc,ContentControlInspector:pc,ContentControlRemove:uc});var Qx=/^(con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])$/i,g8=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g,b8=200,ev=new TextEncoder;function h8(e,t){if(ev.encode(e).length<=t)return e;let o=0,r="";for(let n of e){let i=ev.encode(n).length;if(o+i>t)break;o+=i,r+=n;}return r}function tv(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 ov(e){return tv(tv(e).replace(/\.docx$/i,""))}function Ec(e){let t=(e??"").replace(g8," ").replace(/\s+/g," ").trim(),o=ov(t).replace(/^[. ]+/,""),r=h8(o,b8),n=r===o?o:ov(r);return !n||Qx.test(n)?"document.docx":Qx.test(n.split(".",1)[0].trim())?`_${n}.docx`:`${n}.docx`}function Sc(e,t,o="application/vnd.openxmlformats-officedocument.wordprocessingml.document",r){let n=URL.createObjectURL(new Blob([e],{type:o})),i=editor.hostDocumentOf(r).createElement("a");i.href=n,i.download=t,i.click(),editor.hostWindowOf(r).setTimeout(()=>URL.revokeObjectURL(n),0);}function rv(e,t,o){let{t:r}=L(),n=Bt.useRef(false),[i,a]=Bt.useState(false),[l,s]=Bt.useState(""),[c,d]=Bt.useState("pdf"),[m,u]=Bt.useState(false),[g,p]=Bt.useState({});return {pending:i,error:l,format:c,visible:m,session:g,dismiss:()=>u(false),execute:async h=>{if(!(!e||n.current)){n.current=true,p({}),d(h),u(true),a(true),s("");try{let y=await editor.runChromeExport(e,h,t);Sc(y.bytes.slice().buffer,Ec(o).replace(/\.docx$/,`.${y.extension}`),y.mimeType),u(!1);}catch(y){u(true),s(y instanceof editor.ChromeExportError?r(y.format==="markdown"?"toolbar.exportMarkdownMissing":"toolbar.exportPdfMissing"):r("toolbar.exportFailed",{message:y instanceof Error?y.message:String(y)}));}finally{n.current=false,a(false);}}}}}function av(e,t,o){let{t:r}=L(),n=Bt.useRef({editor:e,exporters:t,feedback:o,t:r});n.current={editor:e,exporters:t,feedback:o,t:r};let i=Bt.useRef(null),a=Bt.useRef(null),[l,s]=Bt.useState(false),[c,d]=Bt.useState(""),[m,u]=Bt.useState(""),[g,p]=Bt.useState(false),[f,h]=Bt.useState(false),[y,x]=Bt.useState({}),b=Bt.useCallback(T=>{let{t:C}=n.current;if(T instanceof editor.ChromeExportError)return C("toolbar.printPdfMissing");if(T instanceof editor.ChromePrintError){if(T.code==="pdf-viewer-unavailable")return C("toolbar.printNoViewer");if(T.code==="pdf-load-failed")return C("toolbar.printLoadFailed");if(T.code==="print-refused")return C("toolbar.printRefused")}return C("toolbar.printFailedMessage",{message:T instanceof Error?T.message:String(T)})},[]),v=Bt.useCallback(()=>{i.current=null,h(false),p(false),s(false);},[]),P=Bt.useCallback(async T=>{let{editor:C,exporters:E}=n.current;if(!C||i.current)return;let S={};i.current=S,a.current?.dispose(),a.current=null,x(S),h(true),p(true),s(true),d(""),u("");try{let k=await editor.runChromePrint(C,E,T??editor.hostDocumentOf(null));if(i.current!==S){k.dispose();return}a.current=k,await k.print({beforePrint:()=>{if(i.current!==S)throw new editor.ChromePrintError("print-ended");reactDom.flushSync(()=>p(!1));}}),i.current===S&&v();}catch(k){if(i.current!==S)return;if(!n.current.feedback){console.error("[docx-editor] print failed",k),v();return}s(false),u(a.current?.url??""),d(b(k)),p(true);}},[v,b]);return Bt.useEffect(()=>()=>{i.current=null,a.current?.dispose(),a.current=null;},[]),{pending:l,error:c,url:m,visible:g,active:f,session:y,execute:P,close:v}}var D8=()=>{};function Jm(){let e=H(),t=Bt.useCallback(r=>e?e.on("hostChange",r):D8,[e]),o=Bt.useCallback(()=>e?editor.editorHostDocument(e):typeof globalThis.document>"u"?null:globalThis.document,[e]);return Bt.useSyncExternalStore(t,o,()=>null)}var R8="https://github.com/eigenpal/docx-editor/issues/new";function M8(){if(typeof globalThis.window>"u")return "";try{let e=new URL(globalThis.window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function lv(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}),n=["### 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??M8()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
2
2
  `),i=new URLSearchParams({title:"[Bug] ",body:n});return `${R8}?${i.toString()}`}function ji(e){typeof globalThis.window>"u"||globalThis.window.open(lv(e),"_blank","noopener,noreferrer");}function _8({className:e,hidden:t,onSelect:o}){let{setOpenMenu:r,onReportIssue:n,reportIssue:i}=Je(),a=Pe();if(t||i===false)return null;let l=o??n??ji;return jsxRuntime.jsx(we,{slot:"help.reportIssue",onSelect:()=>{l(),r(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var Pc=Object.assign(_8,{docxSlot:"help.reportIssue"});function I8({children:e,...t}){let{reportIssue:o}=Je();return e===void 0&&o===false?null:jsxRuntime.jsxs(ro,{id:"help",...t,children:[jsxRuntime.jsx(Pc,{}),e]})}var Qm=Object.assign(I8,{docxMenu:"help"});var H8=e=>e.hiddenReviewAuthors??[];function kc({className:e,hidden:t}){let o=H(),r=ki(),n=W(H8),i=Pe(),{t:a}=L();if(t)return null;let l=i("reviewers.label"),s=editor.toolbarCommandState(o,"review.authors"),c=i18n.localizeDisabledReason(s.disabledReason,a);if(!s.enabled)return jsxRuntime.jsx(we,{disabled:true,title:c??void 0,slot:"review.authors",children:l});let d=new Set(n),m=r.every(u=>!d.has(u.author));return jsxRuntime.jsxs(oo,{labelKey:"reviewers.label",className:e,children:[jsxRuntime.jsx(cv,{checked:m,label:i("reviewers.all"),slot:"reviewer-all",onChoose:()=>o?.setAllReviewAuthorsVisible(!m)}),jsxRuntime.jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),r.map(u=>jsxRuntime.jsx(cv,{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 cv(e){return jsxRuntime.jsx(we,{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 A8({children:e,...t}){return jsxRuntime.jsxs(ro,{id:"review",...t,children:[jsxRuntime.jsx(oo,{labelKey:"reviewers.markupOptions",className:"docx-menubar__markup-options",children:jsxRuntime.jsx(kc,{className:"docx-menubar__reviewers-submenu"})}),e]})}var wc=Object.assign(A8,{docxMenu:"review"});var q8={file:Lu,format:Hu,insert:Au,review:wc,help:Qm};function Yi(e,t=false){if(!Bt.isValidElement(e))return null;if(e.type===Bt.Fragment){let i=Bt.Children.toArray(e.props.children).map(a=>Yi(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 r=e.type;return (typeof r=="function"||typeof r=="object")&&typeof r.docxMenu=="string"?r.docxMenu:e.type===ro&&typeof o.id=="string"?o.id:null}var U8=new Set(editor.CHROME_MENUS.map(e=>e.id));function _c(e){if(!Bt.isValidElement(e))return null;if(e.type===Bt.Fragment){let r=Bt.Children.toArray(e.props.children).map(_c).filter(n=>n!==null);return r.length===1?r[0]:null}let t=e.type;if((typeof t=="function"||typeof t=="object")&&typeof t.docxMenu=="string")return t.docxMenu;if(e.type===ro){let o=e.props.id;if(typeof o=="string"&&U8.has(o))return o}return null}var z8=e=>e.isOpening===true;function $8(e){let t=ko(),o=kt(),r=qt(),n=it(),{className:i,t:a,fileName:l,exporters:s,onOpen:c,onOpenFile:d,onSave:m,onPageSetup:u,onReportIssue:g,reportIssue:p,preset:f=true,overflow:h=true,children:y}=e,x=H(),{t:b}=L(),[v,P]=Bt.useState(null),T=W(z8);Bt.useEffect(()=>{T&&P(null);},[T]);let[C,E]=Bt.useState(null),S=rv(x,s,l??C??void 0),{pending:k,execute:w}=S,I=av(x,s,o?.print!==false),{active:O,execute:N}=I,B=I.visible&&o?.print!==false,[F,D]=Bt.useState(null),[R,z]=Bt.useState(false),[V,ee]=Bt.useState(false),[Y,q]=Bt.useState(false),G=Bt.useRef(null),ce=Bt.useRef(null);Bt.useEffect(()=>{if(v!==null)return editor.listenForOutsidePress({popup:G.current,close:()=>P(null)})},[v]),ua(v!==null,G,()=>P(null),le=>editor.isDomNode(le.target)&&G.current?.contains(le.target)===true);let A=Bt.useCallback(le=>{P(le),le!==null&&D(le);},[]),_=Bt.useCallback(()=>ce.current?.click(),[]),ae=Bt.useCallback(()=>{x&&x.save().then(le=>Sc(le,Ec(l??C??void 0),void 0,G.current)).catch(le=>{console.error("[docx-editor] save failed",le);});},[x,l,C]),fe=Bt.useCallback(()=>t?t.open("pageSetup",G.current?.querySelector('[data-menu="file"] > [role="menuitem"]')):z(true),[t]),Z=x?c??_:void 0,de=x?m??ae:void 0,Re=!!s?.pdf,Ae=Bt.useMemo(()=>x&&!O?()=>{vu(G.current),N(editor.editorInstanceScope(G.current)??G.current??void 0);}:void 0,[x,O,N]),ft=x?t?.ownsPageSetup?fe:u??fe:void 0,ve=Jm();Bt.useEffect(()=>{let le=xe=>{if(!(xe.metaKey||xe.ctrlKey)||xe.altKey||xe.shiftKey)return;let Et=xe.key.toLowerCase(),Ho=editor.isChromePrintShortcut(xe);if(Et!=="s"&&Et!=="o"&&!Ho)return;let or=xe.target,_r=editor.editorInstanceScope(G.current)??G.current;if(!(!or||!((_r?.contains(or)??false)||bb(or,editor.hostDocumentOf(G.current),x?editor.editorHostElement(x):null))))if(Ho){if(!Re||!x||!Ae&&!B)return;xe.preventDefault(),Ae?.();}else Et==="s"&&de?(xe.preventDefault(),de()):Et==="o"&&Z&&(xe.preventDefault(),Z());},be=editor.hostDocumentOf(G.current),Ke=ve&&ve!==be?[be,ve]:[be];for(let xe of Ke)xe.addEventListener("keydown",le);return ()=>{for(let xe of Ke)xe.removeEventListener("keydown",le);}},[Z,de,Ae,B,Re,x,ve]);let nt=Bt.useMemo(()=>({t:a,openMenu:v,setOpenMenu:A,activeMenu:F,onOpen:Z,onSave:de,onExport:x&&!k?le=>(vu(G.current),w(le)):void 0,onPrint:Ae,printShortcut:Re,onPageSetup:ft,onParagraphDialog:()=>t?t.open("paragraph",G.current?.querySelector('[data-menu="format"] > [role="menuitem"]')):ee(true),onWatermarkDialog:x?()=>t?t.open("watermark",G.current?.querySelector('[data-menu="insert"] > [role="menuitem"]')):q(true):void 0,onReportIssue:g,reportIssue:p,opening:T}),[T,x,k,w,Ae,Re,a,v,A,F,Z,de,ft,t,g,p]),Zt=Bt.Children.toArray(y),Nt=[];if(f){let le=new Map(Zt.map(be=>[_c(be),be]));for(let be of editor.CHROME_MENUS){let Ke=le.get(be.id);(Ke===void 0||Yi(Ke)!==null)&&Nt.push(be.id);}for(let be of Zt){if(_c(be)!==null)continue;let Ke=Yi(be);Ke!==null&&Nt.push(Ke);}}else for(let le of Zt){let be=Yi(le);be!==null&&Nt.push(be);}let er=[...Nt].reverse(),{attach:Mr,overflow:ie}=vb(h,Nt,er),at=Bt.useMemo(()=>({measuring:h,overflow:ie,inMore:false}),[h,ie]),Ie=Bt.useMemo(()=>({measuring:false,overflow:ie,inMore:true}),[ie]),go=le=>Yi(le,true)!==null,tr=(le,be)=>jsxRuntime.jsx("div",{role:"none",className:"docx-menubar__host",[Fn]:"",children:le},be),Ft,Lo;if(!f)Ft=Zt.filter(go),Lo=h?Zt.map((le,be)=>go(le)?le:tr([le],`host-${be}`)):y;else {let le=new Map,be=[];for(let xe of Zt){let Et=_c(xe);Et?le.set(Et,xe):be.push(xe);}Ft=[...editor.CHROME_MENUS.map(xe=>{let Et=le.get(xe.id);if(Et)return jsxRuntime.jsx(Bt.Fragment,{children:Et},xe.id);let Ho=q8[xe.id];return jsxRuntime.jsx(Ho,{},xe.id)}),...be.filter(go)];let Ke=be.filter(xe=>!go(xe));Lo=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Ft,Ke.length>0?tr(Ke,"host"):null]});}let yn=a?.("formattingBar.more")??b("formattingBar.more");return jsxRuntime.jsxs($a.Provider,{value:nt,children:[jsxRuntime.jsx("div",{ref:le=>{if(G.current=le,Mr(le),le&&F===null){let be=xu(le)[0]?.closest("[data-menu]")?.getAttribute("data-menu");be&&D(be);}},role:"menubar","aria-label":a?.("titleBar.menuBarAriaLabel")??b("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",...h?{"data-overflow":""}:{},className:`${r}docx-menubar${i?` ${i}`:""}`,dir:n,onMouseDown:U,onKeyDown:le=>{if(le.key!=="ArrowLeft"&&le.key!=="ArrowRight")return;let be=G.current;if(!be)return;let Ke=xu(be),xe=Ke.indexOf(editor.hostDocumentOf(be).activeElement);if(xe===-1)return;le.preventDefault();let Et=editor.hostWindowOf(be).getComputedStyle(be).direction==="rtl",Ho=(le.key==="ArrowRight"?1:-1)*(Et?-1:1),or=Ke[(xe+Ho+Ke.length)%Ke.length],_r=or?.closest("[data-menu]")?.getAttribute("data-menu");_r&&(D(_r),or?.focus(),v!==null&&P(_r));},children:jsxRuntime.jsxs(Zl.Provider,{value:at,children:[jsxRuntime.jsx(In.Provider,{value:0,children:Lo}),ie.size>0?jsxRuntime.jsx(ro,{id:_n,label:yn,icon:re(mm),preset:false,children:jsxRuntime.jsx(Zl.Provider,{value:Ie,children:Ft})}):null]})}),jsxRuntime.jsxs(Fh,{children:[S.visible&&o?.export!==false?o?.export?Se(o.export,{open:true,format:S.format,pending:S.pending,error:S.error,onClose:S.dismiss},S.session):jsxRuntime.jsx(Na,{open:true,format:S.format,pending:S.pending,error:S.error,onClose:S.dismiss}):null,I.visible&&o?.print!==false?o?.print?Se(o.print,{open:true,pending:I.pending,error:I.error,url:I.url,onClose:I.close},I.session):jsxRuntime.jsx(Fa,{open:true,pending:I.pending,error:I.error,url:I.url,onClose:I.close}):null]}),jsxRuntime.jsx("input",{ref:ce,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:le=>{let be=le.target.files?.[0];le.target.value="",!(!be||!x)&&(E(be.name),d?.(be),be.arrayBuffer().then(Ke=>x.load(new Uint8Array(Ke))).catch(Ke=>{console.error("[docx-editor] could not open the file",Ke);}));}}),jsxRuntime.jsx(qr,{open:R,onClose:()=>z(false)}),jsxRuntime.jsx(qo,{open:V,onClose:()=>ee(false)}),jsxRuntime.jsx(Ur,{open:Y,onClose:()=>q(false)})]})}var Xi=Object.assign($8,{Menu:ro,File:Lu,Format:Hu,Insert:Au,Review:wc,Help:Qm,Item:to,Row:we,Group:Xa,Separator:Zr,Submenu:oo,TableGrid:An,Entry:Qa,Open:wu,Save:Du,ExportMarkdown:Ru,ExportPdf:Mu,Print:_u,PageSetup:Iu,ImageInsert:Nu,Watermark:Yl,Bookmark:Xl,Reviewers:kc,ReportIssue:Pc});var Q8=12240,bv=1440,eN=1440,tN=567,rn=20,lf=6,cf=rn+lf+2,oN="var(--doc-text-muted)",rN="var(--doc-text-subtle)",hv="var(--doc-shadow-subtle)",nN="var(--doc-primary)",aN="var(--doc-primary-hover)",iN="var(--doc-text-subtle)",Qi=5,Ji=7,lN={left:0,right:0,firstLine:0};function yv(e,t){return t==="inch"?(e/eN).toFixed(2)+'"':(e/tN).toFixed(1)+" cm"}function sN(e,t){return t?1:Math.round(e==="cm"?editor.SNAP_TWIPS_CM:editor.SNAP_TWIPS_INCH)}function nn({pageSetup:e,zoom:t=1,editable:o=false,onLeftMarginChange:r,onRightMarginChange:n,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:h}=L(),[y,x]=Bt.useState(null),[b,v]=Bt.useState(null),[P,T]=Bt.useState(null),[C,E]=Bt.useState(null),S=Bt.useRef(null),k=e?.pageWidthTwips??Q8,w=e?.marginsTwips.left??bv,I=e?.marginsTwips.right??bv,O=e?.gutterTwips??0,N={pageWidth:k,leftMargin:w,rightMargin:I},B=l??lN,F=ze(k)*t,D=ze(w)*t,R=ze(I)*t,z=Bt.useCallback(_=>{let ae=S.current?.getBoundingClientRect();return ae?Bs((_-ae.left)/t):null},[t]),V=Bt.useCallback((_,ae,fe)=>{let Z=z(ae);if(Z===null)return;if(E(ze(Z)*t),_==="leftMargin"||_==="rightMargin"){if(_==="leftMargin"){let Re=k-I-O-720,Ae=Math.round(Math.max(0,Math.min(Z,Re)));T(Ae),r?.(Ae);}else {let Re=k-Z,Ae=k-w-O-720,ft=Math.round(Math.max(0,Math.min(Re,Ae)));T(ft),n?.(ft);}return}let de=editor.dragIndent(_,Z,B,N,{unit:m,precise:fe});T(_==="right"?de.right:_==="firstLine"?de.firstLine:de.left),c?.(de);},[z,t,k,w,I,O,r,n,c,B,N,m]),ee=Bt.useCallback(_=>{_==="leftMargin"||_==="rightMargin"?i?.():d?.(),x(null),T(null),E(null);},[i,d]),Y=Bt.useCallback((_,ae,fe)=>{let Z=editor.handlePosition(_,B,N),de=editor.dragIndent(_,Z+ae*sN(m,fe),B,N,{unit:m,precise:true});c?.(de),d?.();},[B,N,m,c,d]),q=editor.rulerMarginTicks(N,B,m).map(_=>({..._,position:ze(_.position)*t})),G=a&&s&&c!==void 0,ce=_=>ze(editor.handlePosition(_,B,N))*t,A=(_,ae,fe)=>({positionPx:ce(_),editable:G,isDragging:y===_,isHovered:b===_,onPointerEnter:()=>v(_),onPointerLeave:()=>v(null),onPointerDown:Z=>{G&&(Z.preventDefault(),Z.stopPropagation(),Z.currentTarget.setPointerCapture(Z.pointerId),x(_));},onPointerMove:Z=>{y===_&&V(_,Z.clientX,Z.altKey);},onPointerUp:Z=>{y===_&&(Z.currentTarget.releasePointerCapture(Z.pointerId),ee(_));},onKeyDown:Z=>{G&&(Z.key!=="ArrowLeft"&&Z.key!=="ArrowRight"||(Z.preventDefault(),Y(_,Z.key==="ArrowLeft"?-1:1,Z.shiftKey)));},label:h(ae),valueNow:fe,valueText:yv(fe,m),pageWidthTwips:k});return jsxRuntime.jsxs("div",{ref:S,className:`docx-horizontal-ruler ${u}`,style:{position:"relative",width:Dt(F),height:cf,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:y?"ew-resize":"default",flexShrink:0,marginInline:"auto",...g},role:"group","aria-label":h("ruler.horizontal"),children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,width:Dt(D),height:rn,backgroundColor:hv,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&r?_=>{_.preventDefault(),_.currentTarget.setPointerCapture(_.pointerId),x("leftMargin");}:void 0,onPointerMove:_=>y==="leftMargin"&&V("leftMargin",_.clientX,_.altKey),onPointerUp:_=>{y==="leftMargin"&&(_.currentTarget.releasePointerCapture(_.pointerId),ee("leftMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,right:0,width:Dt(R),height:rn,backgroundColor:hv,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&n?_=>{_.preventDefault(),_.currentTarget.setPointerCapture(_.pointerId),x("rightMargin");}:void 0,onPointerMove:_=>y==="rightMargin"&&V("rightMargin",_.clientX,_.altKey),onPointerUp:_=>{y==="rightMargin"&&(_.currentTarget.releasePointerCapture(_.pointerId),ee("rightMargin"));}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:rn,pointerEvents:"none"},children:q.map((_,ae)=>jsxRuntime.jsx(cN,{tick:_},ae))}),p?.map(_=>jsxRuntime.jsx(mN,{tabMark:_,positionPx:ze(editor.rulerTabPosition(_.position,N,B))*t,onDoubleClick:()=>f?.(_.position)},_.position)),a&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(af,{direction:"down",anchor:"top",...A("firstLine","ruler.firstLineIndent",B.firstLine)}),jsxRuntime.jsx(af,{direction:"up",anchor:"strip",...A("hanging","ruler.hangingIndent",B.left)}),jsxRuntime.jsx(dN,{...A("left","ruler.leftIndent",B.left)}),jsxRuntime.jsx(af,{direction:"up",anchor:"strip",...A("right","ruler.rightIndent",B.right)})]}),y&&P!==null&&C!==null&&jsxRuntime.jsx(uN,{value:yv(P,m),positionPx:C})]})}function cN({tick:e}){return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:Dt(e.position),bottom:0,width:1,height:e.height,backgroundColor:rN}}),e.label&&jsxRuntime.jsx("div",{style:{position:"absolute",left:Dt(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:oN,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function xv(e){return e.editable?e.isDragging||e.isHovered?aN:nN:iN}function vv(e,t,o){return {position:"absolute",left:Dt(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...o}}function Cv(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 af({direction:e,anchor:t,...o}){let r=xv(o),n=t==="top"?{top:0,height:Ji+1}:{top:rn-Ji,height:Ji};return jsxRuntime.jsx("div",{className:"docx-ruler-indent",style:vv(o,Qi*2,n),onPointerEnter:o.onPointerEnter,onPointerLeave:o.onPointerLeave,onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onKeyDown:o.onKeyDown,...Cv(o),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${Qi}px solid transparent`,borderRight:`${Qi}px solid transparent`,...e==="down"?{top:0,borderTop:`${Ji}px solid ${r}`}:{bottom:0,borderBottom:`${Ji}px solid ${r}`},transition:"border-color 0.1s"}})})}function dN(e){return jsxRuntime.jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:vv(e,Qi*2,{top:rn+1,height:lf}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...Cv(e),children:jsxRuntime.jsx("div",{style:{position:"absolute",left:1,top:0,width:Qi*2-2,height:lf,backgroundColor:xv(e),borderRadius:1,transition:"background-color 0.1s"}})})}function uN({value:e,positionPx:t}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:Dt(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 pN={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function mN({tabMark:e,positionPx:t,onDoubleClick:o}){return jsxRuntime.jsx("div",{style:{position:"absolute",left:Dt(t-5),top:rn-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:r=>{r.stopPropagation(),o();},title:`${e.alignment} tab at ${(e.position/1440).toFixed(2)}"`,children:pN[e.alignment]||"L"})}var hN=15840,Sv=1440,Fc=1440,Lc=567,va=20,yN="var(--doc-text-muted)",xN="var(--doc-text-subtle)",vN="var(--doc-primary)",CN="var(--doc-primary)",TN="var(--doc-primary-hover)";function el({pageSetup:e,zoom:t=1,editable:o=false,onTopMarginChange:r,onBottomMarginChange:n,onMarginDragEnd:i,unit:a="inch",className:l="",style:s}){let{t:c}=L(),d=it(),[m,u]=Bt.useState(null),[g,p]=Bt.useState(null),f=Bt.useRef(null),h=e?.pageHeightTwips??hN,y=e?.marginsTwips.top??Sv,x=e?.marginsTwips.bottom??Sv,b=(I,O)=>{if(!o||I.altKey||I.ctrlKey||I.metaKey||!["ArrowUp","ArrowDown","Home","End"].includes(I.key))return;I.preventDefault();let N=O==="topMargin"?y:x,F=Math.max(0,h-(O==="topMargin"?x:y)-720),D=I.shiftKey?1:Math.round(a==="cm"?Lc/10:Fc/8),R=I.key==="Home"?0:I.key==="End"?F:Math.max(0,Math.min(F,N+(I.key==="ArrowUp"?D:-D)));R!==N&&((O==="topMargin"?r:n)?.(R),i?.());},v=ze(h)*t,P=ze(y)*t,T=ze(x)*t,C=Bt.useCallback((I,O)=>{o&&(I.preventDefault(),u(O));},[o]),E=Bt.useCallback(I=>{if(!m||!f.current)return;let O=f.current.getBoundingClientRect(),N=I.clientY-O.top,B=Bs(N/t);if(m==="topMargin"){let F=h-x-720,D=Math.max(0,Math.min(B,F));r?.(Math.round(D));}else if(m==="bottomMargin"){let F=h-B,D=h-y-720,R=Math.max(0,Math.min(F,D));n?.(Math.round(R));}},[m,t,h,y,x,r,n]),S=Bt.useCallback(()=>{m!==null&&i?.(),u(null);},[m,i]);Bt.useEffect(()=>{if(m){let I=editor.hostDocumentOf(f.current);return I.addEventListener("mousemove",E),I.addEventListener("mouseup",S),()=>{I.removeEventListener("mousemove",E),I.removeEventListener("mouseup",S);}}},[m,E,S]);let k=SN(h,t,a),w={position:"relative",width:va,height:Dt(v),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:k.map((I,O)=>jsxRuntime.jsx(EN,{tick:I},O))}),jsxRuntime.jsx(Pv,{type:"topMargin",value:y,maximum:Math.max(0,h-x-720),valueText:y/(a==="cm"?Lc:Fc),unit:a,onKeyDown:I=>b(I,"topMargin"),position:P,editable:o,isDragging:m==="topMargin",isHovered:g==="topMargin",onMouseEnter:()=>p("topMargin"),onMouseLeave:()=>p(null),onMouseDown:I=>C(I,"topMargin")}),jsxRuntime.jsx(Pv,{type:"bottomMargin",value:x,maximum:Math.max(0,h-y-720),valueText:x/(a==="cm"?Lc:Fc),unit:a,onKeyDown:I=>b(I,"bottomMargin"),position:v-T,editable:o,isDragging:m==="bottomMargin",isHovered:g==="bottomMargin",onMouseEnter:()=>p("bottomMargin"),onMouseLeave:()=>p(null),onMouseDown:I=>C(I,"bottomMargin")})]})}function EN({tick:e}){let t={position:"absolute",top:Dt(e.position),insetInlineEnd:0,height:1,width:e.width,backgroundColor:xN},o={position:"absolute",top:Dt(e.position),insetInlineStart:2,transform:"translateY(-50%)",fontSize:"9px",color:yN,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 Pv({type:e,position:t,value:o,maximum:r,valueText:n,unit:i,onKeyDown:a,editable:l,isDragging:s,isHovered:c,onMouseEnter:d,onMouseLeave:m,onMouseDown:u}){let{t:g}=L(),p=s?TN:c?CN:vN,f={position:"absolute",top:Dt(t-5),insetInlineEnd:0,width:va,height:10,cursor:l?"ns-resize":"default",zIndex:s?10:1},h={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":r,"aria-valuetext":`${n.toFixed(2)} ${i==="cm"?"cm":"in"}`,"aria-disabled":!l,onKeyDown:a,tabIndex:l?0:-1,children:jsxRuntime.jsx("div",{style:h})})}function SN(e,t,o){let r=[];if(o==="inch"){let n=Fc/8,i=Math.ceil(e/n);for(let a=0;a<=i;a++){let l=a*n;if(l>e)break;let s=ze(l)*t;if(a%8===0){let c=a/8;r.push({position:s,width:10,label:c>0?String(c):void 0});}else a%4===0?r.push({position:s,width:6}):a%2===0?r.push({position:s,width:4}):r.push({position:s,width:2});}}else {let n=Lc/10,i=Math.ceil(e/n);for(let a=0;a<=i;a++){let l=a*n;if(l>e)break;let s=ze(l)*t;if(a%10===0){let c=a/10;r.push({position:s,width:10,label:c>0?String(c):void 0});}else a%5===0?r.push({position:s,width:6}):r.push({position:s,width:3});}}return r}var DN=e=>e.formatting?.indent??null,RN=e=>e.editable,MN={type:"setIndent",left:0};function uf(){let e=H(),t=W(DN),o=W(RN),{isEnabled:r}=oe(MN),n=o&&r,i=Bt.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 Bt.useMemo(()=>({indent:t,isEnabled:n,apply:i}),[t,n,i])}var Rv=e=>e.zoom,IN=e=>e.isOpening===true;function Mv(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function _v(){let{apply:e}=Kr(),[t,o]=Bt.useState({}),r=Bt.useRef({}),n=Bt.useCallback(a=>l=>{r.current={...r.current,[a]:Math.round(l)},o(r.current);},[]),i=Bt.useCallback(()=>{let a=r.current;r.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:n,commit:i}}function Dv(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function NN(){let e=H(),{indent:t,isEnabled:o,apply:r}=uf(),[n,i]=Bt.useState(null),a=Bt.useRef(null),l=Bt.useRef(null),s=Bt.useCallback(m=>{l.current===null&&(l.current=Dv(e)),a.current=m,i(m);},[e]),c=Bt.useCallback(()=>{let m=a.current,u=l.current;a.current=null,l.current=null,i(null),m&&(u!==null&&u!==Dv(e)||r({left:m.left,right:m.right,firstLine:m.firstLine}));},[e,r]),d=Bt.useMemo(()=>n??(t?{left:t.left,right:t.right,firstLine:t.firstLine,...t.rtl?{rtl:true}:{}}:null),[n,t]);return Bt.useMemo(()=>({indent:d,isEnabled:o,preview:s,commit:c}),[d,o,s,c])}function FN(){let e=ke(),[t,o]=Bt.useState(0);return Bt.useEffect(()=>{if(!e){o(0);return}let r=()=>o(e.scrollLeft);return r(),e.addEventListener("scroll",r,{passive:true}),()=>e.removeEventListener("scroll",r)},[e]),t}function Ac(e){let t=W(no),o=W(IN),{pageSetup:r,isEnabled:n}=Kr(),i=W(Rv),{pending:a,preview:l,commit:s}=_v(),c=NN(),d=Lr(),m=Ks(),u=m==="left",g=G0(fr(),m),p=FN();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(nn,{pageSetup:Mv(r,a),zoom:i,editable:n,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 Oc(e){let t=W(no),{pageSetup:o,isEnabled:r}=Kr(),n=W(Rv),{pending:i,preview:a,commit:l}=_v(),s=Lr(),c=fr(),d=Y0();return t||d!==null&&d>0&&o&&ze(o.pageWidthTwips)*n>d-s-c.inlineStart-c.inlineEnd?null:jsxRuntime.jsx(el,{pageSetup:Mv(o,i),zoom:n,editable:r,onTopMarginChange:a("top"),onBottomMarginChange:a("bottom"),onMarginDragEnd:l,unit:e.unit??"inch",className:e.className??"",style:e.style})}function K({size:e=20,className:t="",style:o,children:r}){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:r})}function Iv(e){return jsxRuntime.jsx(K,{...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 Nv(e){return jsxRuntime.jsx(K,{...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 Fv(e){return jsxRuntime.jsx(K,{...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 Lv(e){return jsxRuntime.jsxs(K,{...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 Hv(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function Av(e){return jsxRuntime.jsx(K,{...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 Ov(e){return jsxRuntime.jsx(K,{...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 Bv(e){return jsxRuntime.jsx(K,{...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 Wv(e){return jsxRuntime.jsx(K,{...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 Zv(e){return jsxRuntime.jsx(K,{...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 Kv(e){return jsxRuntime.jsx(K,{...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 qv(e){return jsxRuntime.jsx(K,{...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 AN(e){return jsxRuntime.jsx(K,{...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 ON(e){return jsxRuntime.jsx(K,{...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 BN(e){return jsxRuntime.jsx(K,{...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 WN(e){return jsxRuntime.jsx(K,{...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 ZN(e){return jsxRuntime.jsx(K,{...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 KN(e){return jsxRuntime.jsx(K,{...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 qN(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function UN(e){return jsxRuntime.jsx(K,{...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 zN(e){return jsxRuntime.jsx(K,{...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 $N(e){return jsxRuntime.jsx(K,{...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 VN(e){return jsxRuntime.jsx(K,{...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 GN(e){return jsxRuntime.jsx(K,{...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 jN(e){return jsxRuntime.jsx(K,{...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 YN(e){return jsxRuntime.jsx(K,{...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 XN(e){return jsxRuntime.jsx(K,{...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 JN(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function QN(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function e5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function t5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function gf(e){return jsxRuntime.jsx(K,{...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 o5(e){return jsxRuntime.jsx(K,{...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 r5(e){return jsxRuntime.jsx(K,{...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 n5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function a5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function i5(e){return jsxRuntime.jsx(K,{...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 l5(e){return jsxRuntime.jsx(K,{...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 s5(e){return jsxRuntime.jsx(K,{...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 c5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function d5(e){return jsxRuntime.jsx(K,{...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 u5(e){return jsxRuntime.jsx(K,{...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 p5(e){return jsxRuntime.jsx(K,{...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 m5(e){return jsxRuntime.jsx(K,{...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 f5(e){return jsxRuntime.jsx(K,{...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 Uv(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function g5(e){return jsxRuntime.jsx(K,{...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 b5(e){return jsxRuntime.jsx(K,{...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 h5(e){return jsxRuntime.jsx(K,{...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 y5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function x5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function v5(e){return jsxRuntime.jsx(K,{...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 C5(e){return jsxRuntime.jsx(K,{...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 T5(e){return jsxRuntime.jsx(K,{...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 E5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function S5(e){return jsxRuntime.jsx(K,{...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 P5(e){return jsxRuntime.jsx(K,{...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 k5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function w5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function D5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function R5(e){return jsxRuntime.jsx(K,{...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 M5(e){return jsxRuntime.jsx(K,{...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 _5(e){return jsxRuntime.jsx(K,{...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 I5(e){return jsxRuntime.jsx(K,{...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 N5(e){return jsxRuntime.jsx(K,{...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 F5(e){return jsxRuntime.jsx(K,{...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 L5(e){return jsxRuntime.jsx(K,{...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 H5(e){return jsxRuntime.jsx(K,{...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 A5(e){return jsxRuntime.jsx(K,{...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 O5(e){return jsxRuntime.jsx(K,{...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 B5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function W5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function Z5(e){return jsxRuntime.jsx(K,{...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 K5(e){return jsxRuntime.jsx(K,{...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 q5(e){return jsxRuntime.jsx(K,{...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 U5(e){return jsxRuntime.jsx(K,{...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 z5(e){return jsxRuntime.jsx(K,{...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 $5(e){return jsxRuntime.jsx(K,{...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 V5(e){return jsxRuntime.jsx(K,{...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 G5(e){return jsxRuntime.jsx(K,{...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 j5(e){return jsxRuntime.jsx(K,{...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 Y5(e){return jsxRuntime.jsx(K,{...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 X5(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function J5(e){return jsxRuntime.jsx(K,{...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 Q5(e){return jsxRuntime.jsx(K,{...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 e6(e){return jsxRuntime.jsx(K,{...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 t6(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function o6(e){return jsxRuntime.jsx(K,{...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 r6(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function n6(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function a6(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function i6(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function l6(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function s6(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function c6(e){return jsxRuntime.jsx(K,{...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 d6(e){return jsxRuntime.jsx(K,{...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 u6(e){return jsxRuntime.jsx(K,{...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 p6(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function m6(e){return jsxRuntime.jsx(K,{...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 f6(e){return jsxRuntime.jsx(K,{...e,children:jsxRuntime.jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function g6(e){return jsxRuntime.jsx(K,{...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 b6(e){return jsxRuntime.jsx(K,{...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 h6(e){return jsxRuntime.jsx(K,{...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 y6(e){return jsxRuntime.jsx(K,{...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 x6(e){return jsxRuntime.jsx(K,{...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 v6={undo:AN,redo:ON,print:BN,file_download:WN,file_upload:ZN,format_bold:KN,format_italic:qN,format_underlined:UN,strikethrough_s:zN,superscript:$N,subscript:VN,link:GN,format_clear:XN,format_paragraph:jN,format_shapes:YN,lock:qv,format_align_left:JN,format_align_center:QN,format_align_right:e5,format_align_justify:t5,format_line_spacing:gf,format_list_bulleted:o5,format_list_numbered:r5,format_indent_increase:n5,format_indent_decrease:a5,format_color_text:i5,ink_highlighter:l5,format_color_reset:s5,arrow_drop_down:c5,table:d5,table_chart:u5,grid_on:p5,table_rows:m5,view_column:f5,border_all:Uv,select_all:Uv,border_outer:g5,border_inner:b5,border_clear:h5,add:y5,remove:x5,delete:v5,delete_sweep:C5,call_merge:T5,call_split:E5,drag_indicator:S5,image:P5,format_image_left:k5,format_image_right:w5,horizontal_rule:D5,flip_to_back:R5,flip_to_front:M5,open_with:_5,tune:I5,rotate_right:N5,rotate_left:F5,swap_horiz:L5,swap_vert:H5,shapes:A5,format_paint:O5,expand_more:B5,expand_less:W5,border_top:Z5,border_bottom:K5,border_left:q5,border_right:U5,border_horizontal:z5,border_vertical:$5,padding:V5,text_rotation_none:G5,wrap_text:j5,height:Y5,fit_width:X5,settings:J5,border_color:Q5,format_color_fill:e6,vertical_align_top:t6,vertical_align_center:o6,vertical_align_bottom:r6,line_weight:n6,keyboard_arrow_up:a6,keyboard_arrow_down:i6,keyboard_arrow_left:l6,keyboard_arrow_right:s6,more_vert:c6,page_break:d6,branding_watermark:u6,arrow_back:p6,search:m6,toc:f6,bookmark:g6,bookmarks:b6,done_all:Iv,check_circle:Nv,chat_bubble_outline:Fv,chat_bubble_check:Lv,check:Hv,close:Av,add_comment:Ov,comment:Bv,edit_note:Wv,rate_review:Zv,visibility:Kv,format_textdirection_l_to_r:h6,format_textdirection_r_to_l:y6,"agent-sparkle":x6};function j({name:e,size:t=20,className:o="",style:r}){let n=v6[e];return n?jsxRuntime.jsx(n,{size:t,className:o,style:r}):(console.warn(`Icon not found: ${e}`),jsxRuntime.jsx("span",{className:o,style:{fontSize:t,width:t,height:t,...r},children:e}))}var tl=12,bf=240,$v=16,k6=24,w6=tl+bf+$v,Ca=12,D6=36,R6=Ca+D6+$v,ol=Bt__namespace.default.memo(function({headings:t,onHeadingClick:o,onClose:r,topOffset:n=0,scrollLeft:i=0,leftOffset:a=tl}){let{t:l}=L(),[s,c]=Bt.useState(false),d=Bt.useRef(null),m=t.length?Math.min(...t.map(u=>u.level)):0;return Bt.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:n,left:a-i,bottom:0,width:bf,paddingTop:k6,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:s?"translateX(0)":`translateX(-${a+bf}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:r,"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(j,{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 I6=e=>e,N6=Object.freeze([]),F6=()=>{};function hf(e){let t=H(),o=W(I6),r=Bt.useMemo(()=>t&&!o.isLoading?t.getOutline():N6,[t,o]),n=Bt.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 no(o)?null:jsxRuntime.jsx(ol,{headings:r,onHeadingClick:n,onClose:e.onClose??F6,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var yf=Bt.createContext(null);function Do(e){let t=Bt.useContext(yf);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var W6={ok:false,code:"unsupported",reason:"editor is not ready"},Gv=Object.freeze([]);function Bc(e={}){let t=e.enabled??true,o=H(),r=Bt.useCallback(S=>t?o?.query({type:"bookmarks"})??Gv:Gv,[o,t]),n=W(r,ep),[i,a]=Bt.useState(""),[l,s]=Bt.useState("name"),[c,d]=Bt.useState(false),[m,u]=Bt.useState(null),[g,p]=Bt.useState(null),[f,h]=Bt.useState(""),y=Bt.useMemo(()=>editor.goToBookmarkRows(n,{query:i,sortBy:l,showHidden:c}),[n,i,l,c]),x=Bt.useMemo(()=>m===null?-1:y.findIndex(S=>S.name===m),[y,m]),b=Bt.useCallback(S=>{a(S),u(null),p(null);},[]),v=Bt.useCallback(S=>{s(S),u(null),p(null);},[]),P=Bt.useCallback(S=>{d(S),u(null),p(null);},[]),T=Bt.useCallback(S=>{if(y.length===0)return;let k=x<0?S>0?-1:0:x;u(y[(k+S+y.length)%y.length].name);},[y,x]),C=Bt.useCallback(S=>u(y[S]?.name??null),[y]),E=Bt.useCallback(S=>{if(!o)return W6;let k=S??y[x]?.name??editor.goToBookmarkTarget(n,i,y)?.name;if(k===void 0||k.trim().length===0){let I=i.trim();return p(I.length===0?"empty":"notFound"),h(I),{ok:false,code:"notFound",reason:"no bookmark is named that"}}let w=o.exec({type:"goToBookmark",name:k});return p(w.ok?null:w.code==="notFound"?"notFound":"failed"),h(w.ok?"":k),w},[o,y,x,n,i]);return {query:i,setQuery:b,sortBy:l,setSortBy:v,showHidden:c,setShowHidden:P,rows:y,bookmarks:n,activeIndex:x,move:T,setActiveIndex:C,go:E,problem:g,problemName:f}}var jv=(...e)=>e.filter(Boolean).join(" "),$6={header:"navigation.goTo.places.header",footer:"navigation.goTo.places.footer",footnote:"navigation.goTo.places.footnote",endnote:"navigation.goTo.places.endnote"},V6={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 G6(){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 j6({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 rl({className:e,style:t}){let{pane:o,intents:r,t:n}=Do("GoTo"),i=H(),a=o.tab!=="goto",l=Bc({enabled:o.open&&!a}),s=oe("insert.bookmark"),c=W(no),d=Bt.useId(),m=`${d}-list`,u=`${d}-label`,g=`${d}-hint`,p=C=>`${d}-option-${C}`,f=Bt.useRef(null);Bt.useEffect(()=>{if(l.activeIndex<0)return;let C=`${d}-option-${l.activeIndex}`;f.current?.querySelector(`[id="${C}"]`)?.scrollIntoView?.({block:"nearest"});},[l.activeIndex,d]);let h=C=>{l.go(C).ok&&(r.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(),h()):C.key==="Escape"&&l.query.length>0&&(C.preventDefault(),l.setQuery("")));},x=l.problem==="notFound"?n("navigation.goTo.notFound",{name:l.problemName}):l.problem==="failed"?n("navigation.goTo.failed"):l.problem==="empty"?n("navigation.goTo.typeName"):l.bookmarks.length>0&&l.rows.length===0?n("navigation.goTo.noMatches"):"",b=l.activeIndex>=0?p(l.activeIndex):void 0,v=l.sortBy==="location",P=l.bookmarks.length===0,T=(C,E)=>{let S=E===l.activeIndex;return jsxRuntime.jsxs("li",{id:p(E),role:"option","aria-selected":S,className:jv("docx-nav__goto-row",S&&"docx-nav__goto-row--active"),"data-point":C.empty||void 0,onMouseDown:k=>k.preventDefault(),onClick:()=>h(C.name),children:[jsxRuntime.jsx("span",{className:"docx-nav__goto-icon","aria-hidden":"true",children:C.empty?jsxRuntime.jsx(G6,{}):jsxRuntime.jsx(j,{name:"bookmark",size:16})}),jsxRuntime.jsx("span",{className:"docx-nav__result-text",children:jsxRuntime.jsx("bdi",{children:jsxRuntime.jsx(j6,{name:C.name,query:l.query})})}),C.atSelection&&jsxRuntime.jsx("span",{className:"docx-nav__goto-here",title:n("navigation.goTo.atCaret"),children:jsxRuntime.jsx("span",{className:"docx-editor-sr-only",children:n("navigation.goTo.atCaret")})}),!v&&C.place!=="body"&&jsxRuntime.jsx("span",{className:"docx-nav__goto-place",children:n($6[C.place])})]},C.name)};return jsxRuntime.jsxs("div",{className:jv("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(j,{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:n("navigation.goTo.placeholder"),"aria-label":n("navigation.goTo.label"),"aria-describedby":b?g:void 0,"aria-expanded":l.rows.length>0,"aria-controls":l.rows.length>0?m:void 0,"aria-autocomplete":"list","aria-activedescendant":b,autoComplete:"off",spellCheck:false,onChange:C=>l.setQuery(C.target.value),onKeyDown:y}),b&&jsxRuntime.jsx("kbd",{className:"docx-nav__goto-enter","aria-hidden":"true",children:"\u21B5"}),jsxRuntime.jsx("span",{id:g,className:"docx-editor-sr-only",children:n("navigation.goTo.enterHint")})]}),jsxRuntime.jsxs("div",{className:"docx-nav__goto-controls",children:[jsxRuntime.jsx("div",{className:"docx-nav__segmented",role:"radiogroup","aria-label":n("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)}),n(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)}),n("dialogs.bookmark.showHidden")]})]}),P&&!c&&jsxRuntime.jsxs("div",{className:"docx-nav__goto-empty",children:[jsxRuntime.jsx(j,{name:"bookmark",size:24,className:"docx-nav__goto-empty-icon"}),jsxRuntime.jsx("p",{className:"docx-nav__goto-empty-title",children:n("navigation.goTo.empty")}),jsxRuntime.jsx("p",{className:"docx-nav__goto-empty-hint",children:n("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:n("navigation.goTo.add")})]}),!P&&jsxRuntime.jsxs("div",{className:"docx-nav__goto-heading",children:[jsxRuntime.jsx("span",{id:u,children:n("navigation.goTo.listAriaLabel")}),jsxRuntime.jsx("span",{className:"docx-nav__goto-count",children:l.query.trim().length>0?n("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:x}),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:v?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:n(V6[C.place])}),jsxRuntime.jsx("ul",{role:"none",className:"docx-nav__goto-sublist",children:C.rows.map(({row:E,index:S})=>T(E,S))})]},C.place)):l.rows.map((C,E)=>T(C,E))})]})}var Ea=280,Wc=32,Yv=16;function Sa(e=280){return 32+e+16}function Zc({viewportWidth:e,pageWidthPx:t,reservation:o,inlineEndReservation:r=0,inlineStartReservation:n=0,docked:i=false}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(r)||r<0||!Number.isFinite(n)||n<0)return 0;let a=(e-r-t)/2,l=a>=o?0:!i&&o<=2*a?2*(o-a):o;return Math.ceil(Math.max(0,l-n))}var xf=320;function Kc(e,t){return !Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?false:e-t<xf}var Q6=Object.freeze([]),eF=e=>e;function qc(){let e=H(),t=W(eF),[o,r]=Bt.useState(null),n=Bt.useMemo(()=>e&&!t.isLoading?e.getOutline():Q6,[e,t]),i=Bt.useMemo(()=>{if(n.length===0)return [];let l=n[0].level;for(let s of n)s.level<l&&(l=s.level);return n.map(s=>({heading:s,depth:s.level-l}))},[n]),a=Bt.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),r(l);},[e]);return {headings:n,items:i,selectedBlockId:o,goTo:a,isEmpty:n.length===0}}var rC=Object.freeze({query:"",matchCase:false,wholeWord:false,matches:Object.freeze([]),truncated:false,activeIndex:-1,activeMatch:null,isPending:false}),nF=()=>()=>{},Jv=()=>rC;function Uc(e={}){let t=e.highlight??"all",o=H(),r=Bt.useMemo(()=>o?editor.createDocumentSearch(o):null,[o]),n=Bt.useSyncExternalStore(r?r.subscribe:nF,r?r.getState:Jv,r?r.getState:Jv);Bt.useEffect(()=>{if(!(!r||t==="none"))return r.showHighlights(t)},[r,t]);let i=Bt.useMemo(()=>({setQuery:a=>r?.setQuery(a),find:(a,l)=>r?.find(a,l)??rC.matches,setMatchCase:a=>r?.setMatchCase(a),setWholeWord:a=>r?.setWholeWord(a),goTo:a=>r?.goTo(a)??false,next:()=>r?.next()??false,previous:()=>r?.previous()??false,clear:()=>r?.clear()}),[r]);return Bt.useMemo(()=>({...n,...i}),[n,i])}function sC(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 cC=editor.isGoToChord;function dC(e=i18n.isApplePlatform()){return e?"Ctrl+Alt+G":"Ctrl+G"}function uC(e=i18n.isApplePlatform()){return e?"Meta+Alt+G":"Control+G"}function pC(e){return e.startsWith("Ctrl")?"Control+F":"Meta+F"}function mC(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 fC(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 r=editor.isElementNode(e)?e:e.parentElement;if(!r)return false;let n=editor.editorInstanceScope(o);if(n&&n!==o&&n.contains(r))return true;if(!r.closest(".docx-editor")||editor.editorInstanceScope(r)!==null)return false;let i=o.ownerDocument.querySelectorAll(".docx-editor__scroll-container");return i.length===1&&i[0]===o}function Tf(e,t){let o=e?.querySelector(`#docx-nav-panel-${t}`);if(!o)return null;if(t==="headings"){let r=o.querySelector(".docx-nav__heading--current")??o.querySelector(".docx-nav__heading");if(r)return r}return o.querySelector(".docx-nav__search-input")}function Ef(e){e.focus(),e.localName==="input"&&e.select();}function cF(e){let o=e.querySelector('[role="tab"][aria-selected="true"]')?.id??"",n=Tf(e,o==="docx-nav-tab-find"?"find":o==="docx-nav-tab-goto"?"goto":"headings");if(n){Ef(n);return}editor.isHTMLElementNode(e)&&(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus());}function dF(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 r=e.ownerDocument.activeElement;r&&o.some(i=>i.contains(r))&&cF(e);let n=[];for(let i of o)i.hasAttribute("inert")||(i.setAttribute("inert",""),n.push(i));return ()=>{for(let i of n)i.removeAttribute("inert");n.length=0;}}function gC(e,t,o){let r=dF(e,t),n=i=>{editor.isDomNode(i.target)&&e.contains(i.target)||o();};return t.addEventListener("pointerdown",n),()=>{t.removeEventListener("pointerdown",n),r();}}function iC(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function bC(e,t){let o=()=>{let i=editor.hostWindowOf(t).getComputedStyle(t),a=t.clientHeight-iC(i.paddingTop)-iC(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 r=editor.hostWindowOf(t).ResizeObserver;if(typeof r>"u")return ()=>{};let n=new r(o);return n.observe(t),()=>n.disconnect()}function yC(e,t=true,o=true){let r=H(),n=ke(),i=Bt.useRef(null),a=Bt.useRef(null),l=Bt.useRef(false),s=Bt.useRef(false),c=Bt.useRef(false),d=Bt.useRef(0),m=Bt.useCallback(()=>{let T=++d.current;editor.hostWindowOf(i.current).setTimeout(()=>{d.current===T&&(l.current=false,s.current=false,c.current=false);},0);},[]),u=Bt.useRef(e);u.current=e;let g=Bt.useCallback(()=>{l.current=false;let T=Tf(i.current,u.current.tab);T&&Ef(T);},[]),p=Bt.useCallback(()=>{s.current=false;let T=a.current;a.current=null;let C=i.current?.querySelector(".docx-nav__toggle")??null;mC(T,C,r?()=>r.focus():null);},[r]),f=Bt.useRef(p);f.current=p,Bt.useEffect(()=>()=>{s.current&&f.current();},[]);let h=Bt.useCallback(()=>{l.current=false,s.current=true,u.current.setOpen(false),m();},[m]),y=Bt.useCallback((T,C)=>{C&&!i.current?.contains(C)&&(a.current=C),s.current=false;let E=u.current;if(E.open&&E.tab===T){g();return}l.current=true,E.tab!==T&&E.setTab(T),E.open||E.setOpen(true),m();},[g,m]),x=Bt.useMemo(()=>({openTab:T=>{let C=i.current?.ownerDocument.activeElement;y(T,editor.isHTMLElementNode(C)?C:null);},toggle:()=>{if(u.current.open){h();return}a.current=null,s.current=false,l.current=true,u.current.setOpen(true),m();},close:h,picked:()=>{let T=u.current;if(!T.overlay)return;let C=i.current?.ownerDocument.activeElement;c.current=!!C&&!!i.current?.contains(C),T.setOpen(false),m();}}),[h,m,y]),b=Bt.useRef(x);b.current=x,Bt.useEffect(()=>{let T=i.current?.ownerDocument;if(!T||!t&&!o)return;let C=E=>{if(E.defaultPrevented)return;let S=t&&sC(E)?"find":o&&cC(E)?"goto":null;if(!S||!fC(E.target,i.current,n))return;if(S==="goto"&&r?.can({type:"openGoTo"}).ok){r.exec({type:"openGoTo",fromShortcut:true}).ok&&E.preventDefault();return}E.preventDefault();let k=T.activeElement;y(S,editor.isHTMLElementNode(k)?k:null);};return T.addEventListener("keydown",C),()=>T.removeEventListener("keydown",C)},[n,t,o,y,r]),Bt.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||r?.focus());});let v=e.open&&e.overlay;Bt.useEffect(()=>{let T=i.current;if(!(!v||!T||!n))return gC(T,n,()=>b.current.close())},[v,n]),Bt.useEffect(()=>{let T=i.current;if(!(!T||!n||!n.contains(T)))return bC(T,n)},[n]);let P=Bt.useCallback(T=>{T.key!=="Escape"||T.defaultPrevented||T.nativeEvent.isComposing||u.current.open&&(T.preventDefault(),h());},[h]);return {rootRef:i,intents:x,onKeyDown:P}}var fF=150;function gF(e){return e.source!==void 0?true:(e.created?.length??0)>0||(e.deleted?.length??0)>0}function bF(e){let t=0;for(let o of e)t=Math.max(t,o.box.width);return t>0?t:null}function xC(e,t,o=()=>null){let r=editor.hostTimers(o),n=null,i=false,a=()=>{n=null,i||t(bF(e.getPageGeometry()));},l=()=>{i||(r.clearTimeout(n),n=r.setTimeout(a,fF));},s=e.on("change",c=>{gF(c)&&l();});return a(),{nudge:l,dispose(){i=true,r.clearTimeout(n),n=null,s();}}}var CF=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)}},TF=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips,EF=e=>e.page.total;function zc(e={}){let{defaultOpen:t=false,defaultTab:o="headings",paneWidth:r=280}=e,[n,i]=Bt.useState(t),[a,l]=Bt.useState(o),s=e.open??n,c=e.tab??a,{onOpenChange:d,onTabChange:m}=e,u=e.open!==void 0,g=e.tab!==void 0,p=Bt.useCallback(A=>{u||i(A),d?.(A);},[u,d]),f=Bt.useCallback(()=>p(!s),[s,p]),h=Bt.useCallback(A=>{g||l(A),m?.(A);},[g,m]),y=Fr(),x=ke(),b=Bt.useContext(Lt),{pageSetup:v,zoom:P,reviewPaneOpen:T,fitting:C}=W(CF,TF),E=H(),S=W(EF),[k,w]=Bt.useState(0),[I,O]=Bt.useState(null),[N,B]=Bt.useState(0),[F,D]=Bt.useState(0),R=fr();Bt.useEffect(()=>{if(!x){w(0),B(0),D(0);return}let A=()=>{w(x.clientWidth);let fe=editor.hostWindowOf(x).getComputedStyle(x),Z=x.getAttribute("data-chrome-dir")==="rtl",de=Number.parseFloat(Z?fe.paddingLeft:fe.paddingInlineEnd);B(Number.isFinite(de)?de:0);let Re=Number.parseFloat(fe.getPropertyValue("--docx-review-gutter-start"));D(Number.isFinite(Re)?Re:0);};A();let _=editor.hostWindowOf(x).ResizeObserver;if(typeof _>"u")return;let ae=new _(A);return ae.observe(x),()=>ae.disconnect()},[x,s,T,b?.mounted,b?.gutters,R]);let z=Bt.useRef(null);v&&(z.current=v.pageWidthTwips);let V=v?.pageWidthTwips??z.current,ee=Bt.useRef(null);Bt.useEffect(()=>{if(!s||!E)return;let A=xC(E,O,()=>x);return ee.current=A,()=>{A.dispose(),ee.current===A&&(ee.current=null);}},[s,E,x]),Bt.useEffect(()=>ee.current?.nudge(),[S,V]);let Y=Sa(r),q=V0(R,N),G=s&&Kc(k-q,Y),ce=Bt.useMemo(()=>!s||G||V===null?0:Zc({viewportWidth:k,pageWidthPx:Math.max(I??0,ze(V))*P,reservation:Y,inlineEndReservation:N,inlineStartReservation:F,docked:C}),[s,G,V,I,P,k,Y,N,F,C]);return Bt.useEffect(()=>{if(y)return y.setShift(ce),()=>y.setShift(0)},[y,ce]),Bt.useEffect(()=>{if(y)return y.setReservation(s&&!G?Y:0),()=>y.setReservation(0)},[y,s,G,Y]),{open:s,setOpen:p,toggle:f,tab:c,setTab:h,paneWidth:r,shift:ce,overlay:G}}var il=["headings","find","goto"],_o=(...e)=>e.filter(Boolean).join(" ");function ll({className:e,style:t,children:o}){return jsxRuntime.jsx("div",{className:_o("docx-nav__header",e),style:t,children:o??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(sl,{}),jsxRuntime.jsx(cl,{})]})})}function sl({className:e,style:t,children:o}){let{intents:r,t:n}=Do("Close");return jsxRuntime.jsx("button",{type:"button",className:_o("docx-nav__close",e),style:t,"aria-label":n("navigation.closeAriaLabel"),title:n("navigation.closeTitle"),onClick:r.close,children:o??jsxRuntime.jsx(j,{name:"arrow_back",size:20})})}function cl({className:e,style:t,children:o}){let{t:r}=Do("Title");return jsxRuntime.jsx("h2",{className:_o("docx-nav__title",e),style:t,children:o??r("navigation.title")})}function dl({className:e,style:t,children:o}){let{pane:r,t:n}=Do("Tabs"),i=Bt.useCallback(a=>{let l=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(l===0)return;a.preventDefault();let s=il.indexOf(r.tab);r.setTab(il[(s+l+il.length)%il.length]);},[r]);return jsxRuntime.jsx("div",{className:_o("docx-nav__tabs",e),style:t,role:"tablist","aria-label":n("navigation.title"),onKeyDown:i,children:o??il.map(a=>jsxRuntime.jsx(ul,{value:a},a))})}function ul({value:e,className:t,style:o,children:r}){let{pane:n,t:i,goToShortcut:a}=Do("Tab"),l=Yt(),s=n.tab===e,c=e==="goto"&&a?i("navigation.goTo.tabTitle",{shortcut:l(dC())}):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:_o("docx-nav__tab",s&&"docx-nav__tab--selected",t),style:o,...c?{title:c,"aria-keyshortcuts":uC()}:{},onClick:()=>n.setTab(e),children:r??i(`navigation.tabs.${e}`)})}function TC({value:e,onChange:t,onClear:o,placeholder:r,label:n,clearLabel:i,autoFocus:a,onEnter:l}){let s=Bt.useRef(null);return Bt.useEffect(()=>{a&&s.current?.focus();},[a]),jsxRuntime.jsxs("div",{className:"docx-nav__searchbox",children:[jsxRuntime.jsx(j,{name:"search",size:18,className:"docx-nav__search-icon"}),jsxRuntime.jsx("input",{ref:s,type:"search",className:"docx-nav__search-input",value:e,placeholder:r,"aria-label":n,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(j,{name:"close",size:16})})]})}function pl({className:e,style:t}){let{pane:o,outline:r,intents:n,t:i}=Do("Headings"),[a,l]=Bt.useState(""),s=W(no),c=Bt.useMemo(()=>{let m=a.trim().toLowerCase();return m.length===0?r.items:r.items.filter(u=>u.heading.text.toLowerCase().includes(m))},[r.items,a]),d=o.tab!=="headings";return jsxRuntime.jsxs("div",{className:_o("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:d,children:[jsxRuntime.jsx(TC,{value:a,onChange:l,onClear:()=>l(""),placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel")}),s?null:r.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:_o("docx-nav__heading",r.selectedBlockId===m.heading.blockId&&"docx-nav__heading--current"),style:{paddingInlineStart:`${8+m.depth*14}px`},title:m.heading.text,onClick:()=>{r.goTo(m.heading.blockId),n.picked();},children:jsxRuntime.jsx("bdi",{children:m.heading.text})})},`${m.heading.blockId}-${u}`))})]})}function RF({match:e,active:t,onSelect:o}){return jsxRuntime.jsx("li",{children:jsxRuntime.jsx("button",{type:"button",className:_o("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 ml({className:e,style:t}){let{pane:o,search:r,intents:n,t:i}=Do("Find"),a=o.tab!=="find",l=r.query.trim().length>0,s=o.open&&!a,c=r.matches.length===0?null:r.activeIndex<0?i(r.truncated?"navigation.find.totalTruncated":"navigation.find.total",{total:r.matches.length}):i(r.truncated?"navigation.find.counterTruncated":"navigation.find.counter",{current:r.activeIndex+1,total:r.matches.length});return jsxRuntime.jsxs("div",{className:_o("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:a,children:[jsxRuntime.jsx(TC,{value:r.query,onChange:r.setQuery,onClear:r.clear,placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel"),autoFocus:s,onEnter:d=>{r.isPending&&r.find(r.query),d?r.previous():r.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:r.matchCase,onChange:d=>r.setMatchCase(d.target.checked)}),i("navigation.find.matchCase")]}),jsxRuntime.jsxs("label",{className:"docx-nav__option",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:r.wholeWord,onChange:d=>r.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?r.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:r.matches.length===0,onClick:r.previous,children:jsxRuntime.jsx(j,{name:"keyboard_arrow_up",size:18})}),jsxRuntime.jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.nextAriaLabel"),disabled:r.matches.length===0,onClick:r.next,children:jsxRuntime.jsx(j,{name:"keyboard_arrow_down",size:18})})]})]}),r.matches.length>0&&jsxRuntime.jsx("ul",{className:"docx-nav__list","aria-label":i("navigation.find.resultsAriaLabel"),children:r.matches.map((d,m)=>jsxRuntime.jsx(RF,{match:d,active:m===r.activeIndex,onSelect:()=>{r.goTo(m),n.picked();}},`${d.blockId}-${d.start}-${m}`))})]})}function fl({className:e,style:t,children:o}){let{pane:r,intents:n,findShortcut:i,t:a}=Do("Toggle"),s=Yt()("Ctrl+F"),c=i?pC(s):void 0,d=i?a("navigation.openShortcutTitle",{shortcut:s}):a("navigation.openTitle");return jsxRuntime.jsx("button",{type:"button",className:_o("docx-nav__toggle",e),style:t,"aria-label":a("navigation.openAriaLabel"),"aria-expanded":r.open,"aria-keyshortcuts":c,title:d,onMouseDown:m=>m.preventDefault(),onClick:n.toggle,children:o??jsxRuntime.jsx(j,{name:"toc",size:20})})}function Pf(e){let t=qt(),o=it(),{t:r,toggle:n=true,searchHighlight:i="all",findShortcut:a=true,goToShortcut:l=true,className:s,style:c,children:d,...m}=e,u=zc(m),g=qc(),p=u.open&&u.tab==="find"?i:"none",f=Uc({highlight:p}),h=Qe(),y=Bt.useMemo(()=>r??((E,S)=>h(E,S)),[r,h]),x=yC(u,a,l),b=Bt.useMemo(()=>({pane:u,outline:g,search:f,t:y,intents:x.intents,findShortcut:a,goToShortcut:l}),[u,g,f,y,x.intents,a,l]),v=H(),P=Bt.useRef(x.intents);P.current=x.intents;let T=Bt.useRef(l);T.current=l,Bt.useEffect(()=>{if(v)return v.setGoToChrome({onRequest:()=>P.current.openTab("goto"),get shortcut(){return T.current}})},[v]);let C=e.paneWidth??280;return jsxRuntime.jsx(yf.Provider,{value:b,children:jsxRuntime.jsxs("div",{ref:x.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:x.onKeyDown,style:{"--docx-nav-width":`${C}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${Sa(C)}px`,...c},children:[n!==false&&!u.open&&jsxRuntime.jsx(fl,{...typeof n=="object"?n:{}}),jsxRuntime.jsx("aside",{className:"docx-nav__panel-shell","aria-label":b.t("navigation.ariaLabel"),inert:!u.open,children:d??jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ll,{}),jsxRuntime.jsx(dl,{}),jsxRuntime.jsx(pl,{}),jsxRuntime.jsx(ml,{}),jsxRuntime.jsx(rl,{})]})})]})})}var $c=Object.assign(Pf,{Header:ll,Close:sl,Title:cl,Tabs:dl,Tab:ul,Headings:pl,Find:ml,GoTo:rl,Toggle:fl});var OF=600,BF=e=>e.isOpening===true?0:e.page.total,Vc=Bt.createContext(null);function Gc({className:e,style:t}){let o=qt(),r=Kt(),n=H(),i=ke(),{inside:a,host:l,hostScoped:s}=J0(i),c=W(BF),{t:d}=L(),m=Bt.useContext(Vc),[u,g]=Bt.useState(1),[p,f]=Bt.useState(false);if(Bt.useEffect(()=>{if(f(false),!n||!i||c<=1)return;g(n.getCurrentPage("viewport"));let b=editor.hostWindowOf(i),v=null,P=()=>{g(n.getCurrentPage("viewport")),f(true),v!==null&&b.clearTimeout(v),v=b.setTimeout(()=>f(false),OF);};return i.addEventListener("scroll",P,{passive:true}),()=>{i.removeEventListener("scroll",P),v!==null&&b.clearTimeout(v);}},[n,c,i]),c<=1)return null;let h=l?s?"":`docx-editor ${r?"dark ":""}`:o,y=m?m("viewer.pageIndicator").replace(/\{current\}/g,String(u)).replace(/\{total\}/g,String(c)):d("viewer.pageIndicator",{current:u,total:c}),x=jsxRuntime.jsx("div",{className:`${h}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(x,l):null:x}var KF=[],qF=e=>e.fontSubstitutions??KF;function jc({className:e,style:t,t:o}){let r=W(qF),{t:n}=L(),i=o??n,[a,l]=Bt.useState(null);if(r.length===0)return null;let s=r.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:r.join(", ")}).replace("{fonts}",r.join(", "))}),jsxRuntime.jsx("button",{type:"button",className:"docx-font-notice__dismiss",onClick:()=>l(s),children:i("common.dismiss")})]})}var QF={damaged:"openFailure.reasons.damaged","not-docx":"openFailure.reasons.notDocx","too-large":"openFailure.reasons.tooLarge",blocked:"openFailure.reasons.blocked",unknown:"openFailure.reasons.unknown"};function eL(e,t){return typeof e=="object"&&e!==null&&"reason"in e&&e!==t}var tL=e=>e.openFailure??null;function RC(e={}){let t=W(tL),{t:o}=L(),r=e.t??o,[n,i]=Bt.useState(null),a=t!==null&&t!==n?t:null,l=Bt.useCallback(s=>{eL(s,t)||i(t);},[t]);return {failure:a,message:a?r(QF[a.reason]):null,dismiss:l}}var MC=Bt.createContext(null);function wf({variant:e="secondary",dismiss:t=false,asChild:o=false,className:r,onClick:n,children:i,type:a,...l}){let s=Bt.useContext(MC),c=`docx-dialog__button${e==="primary"?" docx-dialog__button--primary":""}${r?` ${r}`:""}`,d=m=>{n?.(m),t&&!m.defaultPrevented&&s?.dismiss();};return o?jsxRuntime.jsx(J,{...l,className:c,onClick:d,children:i}):jsxRuntime.jsx("button",{...l,type:a??"button",className:c,onClick:d,children:i})}var DC=new Set;function _C(e,t){if(!t||!bt())return;let o=e===false?"disabled":typeof e=="object"&&e.actions?"both":null;o===null||DC.has(o)||(DC.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 IC(e){return Bt.Children.toArray(e).some(t=>Bt.isValidElement(t)&&t.type===Bt.Fragment?IC(t.props.children):true)}function oL({title:e,message:t,showCode:o=true,actions:r,closeLabel:n,showClose:i=true,onDismiss:a,children:l,className:s,style:c,t:d}){let{t:m}=L(),u=d??m,{failure:g,message:p,dismiss:f}=RC({t:u}),h=Bt.useId();if(!g||p===null)return null;let y=()=>{f(g),a?.(g);},x={failure:g,message:p,dismiss:y},b=e??u("openFailure.title"),v=typeof t=="function"?t(g):t??p,P=r?.(x),T=IC(P);return jsxRuntime.jsx(MC.Provider,{value:x,children:jsxRuntime.jsx(Be,{kind:"openFailure",role:"alertdialog",label:b,className:s,style:c,onClose:y,dismissOutside:false,...l?{}:{describedBy:h},children:l?l(x):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("header",{className:"docx-dialog__header",children:jsxRuntime.jsx("h2",{className:"docx-dialog__title",children:b})}),jsxRuntime.jsxs("div",{className:"docx-dialog__body",children:[jsxRuntime.jsx("div",{id:h,className:"docx-dialog__message",children:v}),o?jsxRuntime.jsx("p",{className:"docx-dialog__code",children:u("openFailure.code",{code:g.code}).replace("{code}",g.code)}):null]}),T||i?jsxRuntime.jsxs("footer",{className:"docx-dialog__footer",children:[P,i?jsxRuntime.jsx(wf,{variant:T?"secondary":"primary",dismiss:true,children:n??u("common.close")}):null]}):null]})})})}var Yc=Object.assign(oL,{Action:wf});function Df(e){return Math.round(e/1440*100)/100}function NC(e){return Math.round(e*1440)}function aL(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 Rf(){let e=H(),t=Bt.useCallback(o=>e?.getHeaderFooterState()??null,[e]);return W(t,aL)}function cL(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 dL=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function gl(e){let t=H();return Bt.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 uL(e){let{state:t,onMouseDown:o}=e,{t:r}=L(),n=H(),[i,a]=Bt.useState(false),l=Bt.useRef(null),[s,c]=Bt.useState(""),[d,m]=Bt.useState("");Bt.useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(c(String(Df(t.headerDistanceTwips))),m(String(Df(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),Bt.useEffect(()=>{if(i)return editor.listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let u=Bt.useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=Bt.useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),p=Bt.useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),f=Bt.useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),h=Bt.useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),y=gl(u),x=gl(g),b=gl(p),v=gl(f),P=gl(h),T=(C,E)=>{if(!n)return;let S=Number.parseFloat(E);Number.isFinite(S)&&n.exec({type:"setHeaderFooterOptions",[C]:NC(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:r("headerFooter.options")}),i?jsxRuntime.jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:o,children:[dL.map(C=>{let E={type:"insertPageField",field:C.field},S=n?.can(E);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:()=>{n?.exec(E),a(false);},onMouseDown:o,children:r(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:()=>n?.exec(u)}),jsxRuntime.jsx("span",{children:r("headerFooter.differentFirstPage")})]}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!x.enabled,title:x.reason??void 0,onChange:()=>n?.exec(g)}),jsxRuntime.jsxs("span",{children:[r("headerFooter.differentOddEven"),jsxRuntime.jsx("span",{className:"docx-hf-chrome__menu-hint",children:r("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:!v.enabled,title:v.reason??void 0,onClick:()=>n?.exec(f),onMouseDown:o,children:r("headerFooter.unlinkFromPrevious")}):jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!b.enabled,title:b.reason??void 0,onClick:()=>n?.exec(p),onMouseDown:o,children:r("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:r("headerFooter.headerDistance")}),jsxRuntime.jsx("input",{type:"number",min:0,step:.01,"aria-label":r("headerFooter.headerDistance"),value:s,onChange:C=>c(C.target.value),onBlur:()=>T("headerDistanceTwips",s)}),jsxRuntime.jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxRuntime.jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsxRuntime.jsx("span",{children:r("headerFooter.footerDistance")}),jsxRuntime.jsx("input",{type:"number",min:0,step:.01,"aria-label":r("headerFooter.footerDistance"),value:d,onChange:C=>m(C.target.value),onBlur:()=>T("footerDistanceTwips",d)}),jsxRuntime.jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxRuntime.jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxRuntime.jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!P.enabled,title:P.reason??void 0,onClick:()=>n?.exec(h),onMouseDown:o,children:t.editing==="header"?r("headerFooter.removeHeader"):r("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:()=>{n?.exec({type:"exitHeaderFooter"}),a(false);},onMouseDown:o,children:r("common.close")})]}):null]})}function Xc({className:e}){let{t}=L(),o=Rf(),r=Bt.useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),n=pi(r,"story-label"),i=U;if(!o?.editing)return null;let a=cL(o.editing,o.variant);return jsxRuntime.jsxs("div",{ref:n.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:{...n.style,zIndex:vt.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(uL,{state:o,onMouseDown:i})]})}var mL={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},fL={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},gL={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},bL={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},hL={position:"absolute",top:40,insetInlineStart:0,zIndex:10,pointerEvents:"none"},yL={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)"},xL={padding:"8px 12px"},vL={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},CL={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},TL={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function EL({forwardedRef:e}){let t=H(),o=Bt.useRef(null);return o.current=t,ey({ref:e,editorRef:o}),null}function SL(...e){let t=e.filter(Boolean).join(" ");return t===""?void 0:t}var PL=Bt.forwardRef(function(t,o){let{document:r,fonts:n,fontShaping:i,imageDecodePort:a,className:l,t:s,chrome:c=true,title:d,onTitleChange:m,renderTitleBarLeft:u,renderTitleBarRight:g,renderOpenFailureActions:p,loadingIndicator:f,colorMode:h="light",author:y,locale:x,mode:b="edit",modules:v,zoom:P,zoomMode:T,revisionMarkup:C,onRevisionMarkupChange:E,reviewDisplayMode:S,fieldResults:k,contentLockPolicy:w,lockedControlNavigation:I,onReady:O,onChange:N,onFontError:B,onOpen:F,onSave:D,hyperlinkPopup:R,contextMenu:z=true,menu:V=true,navigation:ee=true,openFailure:Y=true,rulers:q=true}=t;!c&&f!==void 0&&R0(),_C(Y,p!==void 0);let G=Rl(h),{t:ce}=L(),A=it(),_=Bt.useCallback((de,Re)=>s?s(de,Re):ce(de,Re),[s,ce]),ae=jsxRuntime.jsxs(Us,{className:c?G?"dark":void 0:l,style:c?fL:void 0,children:[c?jsxRuntime.jsx(Xc,{}):null,c?jsxRuntime.jsx(Cs,{}):null,jsxRuntime.jsx(Os,{}),q&&c?jsxRuntime.jsx("div",{style:hL,dir:A,children:jsxRuntime.jsx(Oc,{})}):null,t.children]}),fe=c?jsxRuntime.jsxs("div",{className:`docx-editor${G?" dark":""}${l?` ${l}`:""}`,style:mL,dir:A,children:[jsxRuntime.jsxs("div",{style:yL,children:[jsxRuntime.jsxs("div",{style:vL,children:[u?.(),jsxRuntime.jsxs("div",{style:CL,children:[m?jsxRuntime.jsx("input",{"aria-label":_("titleBar.documentNameAriaLabel"),value:d??"",placeholder:_("titleBar.untitled"),onChange:de=>m(de.target.value),style:TL}):jsxRuntime.jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:d??_("titleBar.untitled")}),V!==false?jsxRuntime.jsx(Xi,{t:_,...d!==void 0?{fileName:d}:{},...F?{onOpen:F}:{},...D?{onSave:D}:{},...typeof V=="object"?V:{}}):null]}),g?.()]}),jsxRuntime.jsx("div",{style:xL,children:jsxRuntime.jsx(Vi,{t:_})})]}),q?jsxRuntime.jsx("div",{style:bL,"data-testid":"docx-editor-ruler-row",children:jsxRuntime.jsx(Ac,{})}):null,jsxRuntime.jsx(jc,{t:_}),jsxRuntime.jsxs("div",{style:gL,children:[ee===false?null:jsxRuntime.jsx($c,{t:_,...typeof ee=="object"?ee:{}}),ae,jsxRuntime.jsx(Vc.Provider,{value:_,children:jsxRuntime.jsx(Gc,{})}),jsxRuntime.jsx(Ws,{overlay:true,indicator:f})]})]}):ae,Z=Bt.useCallback(de=>_(de),[_]);return jsxRuntime.jsxs(Ti,{popups:Jh(t.popups,R,z,_),...r!==void 0?{document:r}:{},...n?{fonts:n}:{},...i?{fontShaping:i}:{},...a?{imageDecodePort:a}:{},...y!==void 0?{author:y}:{},...x!==void 0?{locale:x}:{},translate:_,...c?{colorMode:G?"dark":"light"}:{},mode:b,...v!==void 0?{modules:v}:{},...P!==void 0?{zoom:P}:{},revisionMarkup:C,onRevisionMarkupChange:E,reviewDisplayMode:S,...k!==void 0?{fieldResults:k}:{},...w!==void 0?{contentLockPolicy:w}:{},...I!==void 0?{lockedControlNavigation:I}:{},...T!==void 0?{zoomMode:T}:{},tableInteractionLabel:Z,...O?{onReady:O}:{},...N?{onChange:N}:{},...B?{onFontError:B}:{},children:[jsxRuntime.jsx(EL,{forwardedRef:o}),jsxRuntime.jsx(Ao.Provider,{value:c,children:fe}),Y===false?null:jsxRuntime.jsx(Yc,{t:_,...typeof Y=="object"?Y:{},...p?{actions:p}:{},className:SL(G?"dark":void 0,typeof Y=="object"?Y.className:void 0)})]})}),kL=Bt.forwardRef(function(t,o){return jsxRuntime.jsx(vn,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsxRuntime.jsx(PL,{...t,ref:o})})}),wL=Object.assign(kL,{Root:Ti,Viewport:Us,Content:Os,Window:Jp,Toolbar:Vi,Menu:Xi,Loading:Ws,ColorByChangeType:tm,RevisionMarkup:Vd,RevisionMarkupDialog:Ia,UnsupportedElement:Cd,AuthorStyle:om,HorizontalRuler:Ac,VerticalRuler:Oc,DocumentOutline:hf,Navigation:$c,ExportDialog:Na,PrintDialog:Fa,PageSetupDialog:qr,WatermarkDialog:Ur,BookmarkDialog:ei,SplitCellDialog:ti,ParagraphDialog:qo,TextFormFieldDialog:ri,PageNumber:Gc,FontNotice:jc,OpenFailure:Yc,HeaderFooterChrome:Xc,NotesChrome:Cs,Equation:za,HyperLink:Za,ContextMenu:dp,ContentControlWidget:zp,InvalidTextFormFieldDialog:Ep,ImageAltTextPopup:Rs,ImagePropertiesDialog:fi,NotePropertiesDialog:Ts,NotePreview:En,NotesContextMenu:Sn,ContentControl:Ua});function IL(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}function _f(e){return Array.isArray(e)?e:[e]}function NL(e){if(typeof e!="function"||editor.isFontResolver(e))return e;let t=e;return editor.defineFontResolver(async()=>t())}function OC(e){return e!==void 0&&_f(e).some(t=>editor.isFontResolver(t))}async function FL(e){return typeof e!="function"?await e:await e()}function LL(e,t={}){let[o,r]=Bt.useState(void 0),[n,i]=Bt.useState(void 0),[a,l]=Bt.useState(null),[s,c]=Bt.useState(e!=null),d=OC(t.fonts),m=t.fonts===void 0?"absent":d?"on-demand":"eager",[u,g]=Bt.useState(t.fonts===void 0),p=Bt.useRef(t);p.current=t;let f=Bt.useMemo(()=>editor.defineFontResolver(h=>editor.composeFontOrigins(_f(p.current.fonts??[]).map(NL),h)),[]);return Bt.useEffect(()=>{let h=p.current.fonts;if(h===void 0){i(void 0),g(true);return}if(OC(h)){g(true);return}g(false);let y=true;return (async()=>{try{let x=await Promise.allSettled(_f(h).map(FL)),b=[];for(let v of x){if(v.status==="rejected"){console.warn("[fonts] font loading failed for one origin; the others still compose",v.reason);continue}v.value!==void 0&&b.push(v.value);}y&&b.length>0&&i(editor.composeFontConfiguration(b[0],...b.slice(1)));}catch(x){console.warn("[fonts] font loading failed; the fixed measurer stays in effect",x);}finally{y&&g(true);}})(),()=>{y=false;}},[m]),Bt.useEffect(()=>{if(e==null){r(void 0),l(null),c(false);return}let h=IL(e);if(h){r(h),l(null),c(false);return}let y=true,x=new AbortController;return c(true),l(null),(async()=>{try{let b=await fetch(String(e),{...p.current.fetchOptions,signal:x.signal});if(!b.ok)throw new Error(`could not open the document: ${b.status} ${b.statusText}`);let v=new Uint8Array(await b.arrayBuffer());if(!y)return;r(v),c(!1);}catch(b){if(!y||b instanceof Error&&b.name==="AbortError")return;l(b instanceof Error?b:new Error("could not open the document")),c(false);}})(),()=>{y=false,x.abort();}},[e]),{document:u?o:void 0,fonts:d?f:n,error:a,isLoading:s||!u}}function WL(...e){let t=Bt.useRef(e);return t.current=e,Bt.useMemo(()=>editor.defineFontResolver(o=>editor.composeFontOrigins(t.current,o)),[])}function qL(e){let o=e?.surface?.state?.().selection?.head;return o&&typeof o.paragraphId=="string"&&Number.isFinite(o.offset)?o:null}function UL(){let e=H(),t=Bt.useRef(null),o=Bt.useCallback(n=>{if(!e)return ()=>{};let i=e.on("selectionChange",n),a=e.on("change",n);return ()=>{i(),a();}},[e]),r=Bt.useCallback(()=>{let n=qL(e),i=t.current;return (n===null?i===null:i!==null&&zL(i,n))?i:(t.current=n,n)},[e]);return Bt.useSyncExternalStore(o,r,()=>null)}function zL(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function GL(e){let t=H(),o=Bt.useRef(e);o.current=e;let r=typeof e=="function";Bt.useEffect(()=>{if(!(!t||!r))return t.setCommentDraftChrome({onRequest:()=>o.current?.()})},[t,r]);}var qC=Object.freeze({applied:0,unavailable:0});function UC(e){if(!e)return "";let{color:t,activeColor:o,activeIndex:r,className:n,priority:i}=e;return JSON.stringify([t,o,r,n,i])}function JL(e,t,o){let r=H(),[n,i]=Bt.useState(qC),a=Bt.useRef(null),l=Bt.useRef(o);l.current=o;let s=Bt.useRef(t);s.current=t;let c=UC(o);return Bt.useEffect(()=>{if(!r){i(qC);return}let d=editor.watchHighlights(r,e,s.current,{...l.current,onResult:i});return a.current={watch:d,source:s.current,key:UC(l.current)},i(d.result),()=>{d.stop(),a.current=null;}},[r,e]),Bt.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]),n}function n4(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 a4(e){let t=H(),o=ke(),[r,n]=Bt.useState(null);return Bt.useEffect(()=>{if(!t){n(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;n(f=>n4(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]),r}function Nf({source:e,scale:t,measurer:o,onStateChange:r,onError:n,className:i,documentFontFamily:a,ref:l}){let s=Bt.useRef(null),c=Bt.useRef(null),[d,m]=Bt.useState(null),u=Bt.useRef(r);u.current=r;let g=Bt.useRef(n);return g.current=n,Bt.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 h=f.surface.state();return m(h),u.current?.(h),()=>{f.surface.destroy(),c.current=null;}},[e,o]),Bt.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,h)=>c.current?.setParagraphProperty(p,f,h),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 hl=Bt.createContext(null);function zC(){let e=Bt.useContext(hl);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function h4(e){return "type"in e&&e.type==="separator"}var GC={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"},y4={...GC,background:"var(--doc-bg-hover)"},jC={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"},x4={...jC,opacity:.4,cursor:"default"},v4={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},C4={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},T4={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 yl({label:e,items:t,disabled:o,showChevron:r=false}){let[n,i]=Bt.useState(false),[a,l]=Bt.useState(null),s=Bt.useRef(null),c=Bt.useRef(null),[d,m]=Bt.useState({top:0,left:0}),u=Bt.useCallback(()=>{i(false),l(null);},[]);Bt.useEffect(()=>{if(!n||!s.current)return;let p=s.current.getBoundingClientRect();m({top:p.bottom+2,left:p.left});},[n]),Bt.useEffect(()=>{if(!n)return;function p(b){b.key==="Escape"&&u();}function f(){u();}let h=editor.hostDocumentOf(s.current),y=editor.hostWindowOf(s.current),x=editor.listenForOutsidePress({popup:s.current,contains:b=>!s.current||!c.current||s.current.contains(b)||c.current.contains(b),close:u});return h.addEventListener("keydown",p),y.addEventListener("scroll",f,true),()=>{x(),h.removeEventListener("keydown",p),y.removeEventListener("scroll",f,true);}},[n,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(!n),onMouseDown:p=>p.preventDefault(),disabled:o,style:n?y4:GC,children:[e,r&&jsxRuntime.jsx(j,{name:"arrow_drop_down",size:16})]}),n&&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(h4(p))return jsxRuntime.jsx("div",{style:v4},`sep-${f}`);let h=p;if(h.customContent)return jsxRuntime.jsx("div",{onMouseDown:b=>b.preventDefault(),children:h.customContent},h.label);let y=!!h.submenuContent,x=a===h.label;return jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>y&&l(h.label),onMouseLeave:()=>y&&l(null),children:[jsxRuntime.jsxs("button",{type:"button",style:h.disabled?x4:jC,onClick:()=>g(h),onMouseDown:b=>b.preventDefault(),onMouseOver:b=>{h.disabled||(b.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:b=>{b.currentTarget.style.backgroundColor="transparent";},disabled:h.disabled,children:[h.icon&&jsxRuntime.jsx(j,{name:h.icon,size:18}),jsxRuntime.jsx("span",{children:h.label}),h.shortcut&&jsxRuntime.jsx("span",{style:C4,children:h.shortcut}),y&&jsxRuntime.jsx("span",{style:{marginLeft:"auto"},children:jsxRuntime.jsx(j,{name:"keyboard_arrow_right",size:16})})]}),y&&x&&jsxRuntime.jsx("div",{style:T4,onMouseDown:b=>b.preventDefault(),children:h.submenuContent(u)})]},h.label)})})]})}var Hf=18,S4=2,XC={width:Hf,height:Hf,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},P4={...XC,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},k4={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function JC({onInsert:e,gridRows:t=6,gridColumns:o=6}){let[r,n]=Bt.useState(0),[i,a]=Bt.useState(0),l=Bt.useCallback(()=>{r>0&&i>0&&e(r,i);},[r,i,e]),s=[];for(let d=1;d<=t;d++)for(let m=1;m<=o;m++){let u=d<=r&&m<=i;s.push(jsxRuntime.jsx("div",{style:u?P4:XC,onMouseEnter:()=>{n(d),a(m);},onClick:l,role:"gridcell","aria-selected":u},`${d}-${m}`));}let c=r>0&&i>0?`${i} \xD7 ${r}`:"Select size";return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"grid",gap:S4,gridTemplateColumns:`repeat(${o}, ${Hf}px)`},onMouseLeave:()=>{n(0),a(0);},role:"grid","aria-label":"Table size selector",children:s}),jsxRuntime.jsx("div",{style:k4,children:c})]})}function _4({items:e,closeMenu:t}){return jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",minWidth:220},children:e.map(o=>{let r=!o.onClick;return jsxRuntime.jsxs("button",{type:"button",disabled:r,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:r?"default":"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap",opacity:r?.4:1},onMouseDown:n=>n.preventDefault(),onClick:()=>{r||(o.onClick?.(),t());},onMouseOver:n=>{r||(n.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:n=>{n.currentTarget.style.backgroundColor="transparent";},children:[jsxRuntime.jsx(j,{name:o.icon,size:18}),jsxRuntime.jsx("span",{children:o.label})]},o.label)})})}function I4(){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 ed({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function N4(e){return e.replace(/\.docx$/i,"")}function Of({value:e,onChange:t,placeholder:o,editable:r=true}){let{t:n}=L(),i=o??n("titleBar.untitled"),a=N4(e)??"";return r?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":n("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 td({children:e}){return jsxRuntime.jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function od(){let{t:e}=L(),t=zC(),{disabled:o=false,onFormat:r,onPrint:n,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:h,onRefocusEditor:y}=t,x=Bt.useCallback(T=>{!o&&r&&r(T);},[o,r]),b=Bt.useCallback((T,C)=>{!o&&c&&(c(T,C),editor.hostWindowOf(t.editorRef?.current).requestAnimationFrame(()=>y?.()));},[o,c,y,t.editorRef]),v=!!n||!!l,P=v||i||a;return jsxRuntime.jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[P&&jsxRuntime.jsx(yl,{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)&&v?[{type:"separator"}]:[],...n?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:n}]:[],...l?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:l}]:[]]}),jsxRuntime.jsx(yl,{label:e("toolbar.format"),disabled:o,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>x("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>x("setRtl")}]}),jsxRuntime.jsx(yl,{label:e("toolbar.insert"),disabled:o,items:[...s?[{icon:"image",label:e("toolbar.image"),onClick:s}]:[],...d&&c?[{icon:"grid_on",label:e("toolbar.table"),submenuContent:T=>jsxRuntime.jsx(JC,{onInsert:(C,E)=>{b(C,E),T();}})}]:[],...s||d&&c?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:T=>jsxRuntime.jsx(_4,{closeMenu:T,items:[{icon:"page_break",label:e("toolbar.pageBreak"),onClick:u},{icon:"horizontal_rule",label:e("toolbar.sectionBreakNextPage"),onClick:g},{icon:"border_horizontal",label:e("toolbar.sectionBreakContinuous"),onClick:p}]})},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:f,disabled:!f},...h?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:h}]:[]]}),m&&jsxRuntime.jsx(yl,{label:e("toolbar.help"),disabled:o,items:[{label:e("toolbar.reportIssue"),onClick:()=>ji()}]})]})}function Bf({children:e}){let t=null,o=null,r=[],n=[];Bt.Children.forEach(e,a=>{Bt.isValidElement(a)&&(a.type===ed?t=a:a.type===td?o=a:a.type===od?n.push(a):r.push(a));});let i=Bt.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(I4,{})}),jsxRuntime.jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[r.length>0&&jsxRuntime.jsx("div",{className:"flex items-center gap-2 px-1",children:r}),n.length>0&&jsxRuntime.jsx("div",{className:"flex items-center px-1",children:n})]}),o&&jsxRuntime.jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:o})]})}var rd={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},A4={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:""},QC={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 O4(e,t){let o=QC[t]??QC[t.toLowerCase()]??t,n=e?.colorScheme?.[o];return typeof n=="string"&&n?n:rd[o]??"000000"}function eT(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 Wf(e,t,o="000000"){if(!e||e.kind==="auto")return `#${o}`;if(e.kind==="hex")return `#${eT(e.value)??o}`;let r=Object.entries(t?.colorScheme??rd).map(([i,a])=>({slot:i,hex:String(a)})),n=editor.resolveThemeColorHex(e,r);return `#${n.ok?n.hex:O4(t,e.slot)}`}function Yo(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?eT(e.value):Wf(e,t).slice(1)}function tT(e){if(!e||e==="none")return "";let t=A4[e];return t?`#${t}`:""}var B4=[{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"}],W4=[{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 oT(e){let t=e??rd;return W4.map(o=>B4.map(r=>{let n=t[r.slot]??rd[r.slot]??"000000",a={hex:o.type==="base"?n.toUpperCase():o.type==="tint"?editor.applyThemeTint(n,o.keep):editor.applyThemeShade(n,o.keep),themeSlot:r.slot,label:`${r.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 q4=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"}}),rt=Bt__namespace.forwardRef(({className:e,variant:t,size:o,...r},n)=>jsxRuntime.jsx("button",{className:ue(q4({variant:t,size:o,className:e})),ref:n,...r}));rt.displayName="Button";function Vt({content:e,children:t,side:o="bottom",delayMs:r=400}){let[n,i]=Bt__namespace.useState(false),[a,l]=Bt__namespace.useState({x:0,y:0}),s=Bt__namespace.useRef(null),c=Bt__namespace.useRef(null),d=Bt__namespace.useCallback(()=>{let p=editor.hostWindowOf(s.current),f=p.setTimeout(()=>{if(s.current){let h=s.current.getBoundingClientRect(),y=h.left+h.width/2,x=o==="top"?h.top-8:h.bottom+8;l({x:y,y:x});}i(true);},r);c.current={win:p,handle:f};},[r,o]),m=Bt__namespace.useCallback(()=>{c.current&&(c.current.win.clearTimeout(c.current.handle),c.current=null),i(false);},[]);Bt__namespace.useEffect(()=>()=>{c.current&&c.current.win.clearTimeout(c.current.handle);},[]);let u=t.props,g=Bt__namespace.cloneElement(t,{ref:s,onMouseEnter:p=>{d(),u.onMouseEnter?.(p);},onMouseLeave:p=>{m(),u.onMouseLeave?.(p);}});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[g,n&&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 Zf=Bt__namespace.createContext(null);function Cr(e){let[t,o]=Bt__namespace.useState(null),r=Bt__namespace.useMemo(()=>({trigger:t,setTrigger:o}),[t]);return jsxRuntime.jsx(Zf.Provider,{value:r,children:jsxRuntime.jsx(Fe__namespace.Root,{...e})})}var Tr=Fe__namespace.Group,nd=Fe__namespace.Value;function Er({className:e,children:t,onMouseDown:o,...r}){let n=Bt__namespace.useContext(Zf)?.setTrigger;return jsxRuntime.jsxs(Fe__namespace.Trigger,{ref:n,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);},...r,children:[t,jsxRuntime.jsx(Fe__namespace.Icon,{asChild:true,children:jsxRuntime.jsx(J4,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function Sr({className:e,children:t,position:o="popper",onCloseAutoFocus:r,onKeyDown:n,...i}){let a=Bt__namespace.useContext(Zf)?.trigger??null,l=typeof globalThis.document>"u"&&!a?null:editor.hostDocumentOf(a),c=Kt()||!!a?.closest(".docx-editor.dark");return jsxRuntime.jsx(Fe__namespace.Portal,{...l?.body?{container:l.body}:{},children:jsxRuntime.jsx("div",{className:ue("docx-editor",c&&"dark"),children:jsxRuntime.jsx(Fe__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(),r?.(d);},onKeyDown:d=>{n?.(d),d.defaultPrevented||X4(d);},...i,children:jsxRuntime.jsx(Fe__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 Y4=new Set(["ArrowDown","ArrowUp","Home","End"]);function X4(e){let t=e.currentTarget;if(t.ownerDocument===globalThis.document||!Y4.has(e.key))return;e.preventDefault();let o=Array.from(t.querySelectorAll('[role="option"]:not([data-disabled])'));if(o.length===0)return;let r=o.indexOf(t.ownerDocument.activeElement),n=r>=0?r: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,n+1):Math.max(0,n<0?0:n-1);o[i].focus({preventScroll:false});}function cn({className:e,...t}){return jsxRuntime.jsx(Fe__namespace.Label,{className:ue("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function Gt({className:e,children:t,onMouseDown:o,...r}){return jsxRuntime.jsxs(Fe__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:n=>{n.preventDefault(),o?.(n);},...r,children:[jsxRuntime.jsx(Fe__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(Fe__namespace.ItemIndicator,{children:jsxRuntime.jsx(Q4,{className:"h-4 w-4"})})})]})}function dn({className:e,...t}){return jsxRuntime.jsx(Fe__namespace.Separator,{className:ue("-mx-1 my-1 h-px bg-muted",e),...t})}function J4({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 Q4({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 Kf(e){let t=e.trim();if(!t)return "";let o=null,r="";for(let n of t){if((n==='"'||n==="'")&&o===null){o=n,r+=n;continue}if(n===o){o=null,r+=n;continue}if(n===","&&o===null)break;r+=n;}return r.trim().replace(/^['"]|['"]$/g,"")}var e3=[{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 aT({value:e,onChange:t,fonts:o=e3,documentFonts:r,disabled:n=false,className:i,placeholder:a="Arial",width:l=120,showPreview:s=true}){let{t:c}=L(),d=Bt__namespace.useMemo(()=>{if(!r)return [];let f=new Set(o.map(h=>h.name.toLowerCase()));return r.filter(h=>!f.has(h.name.toLowerCase()))},[r,o]),m=Bt__namespace.useMemo(()=>[...d,...o],[d,o]),u=Bt__namespace.useMemo(()=>e?m.find(h=>h.fontFamily===e||h.name.toLowerCase()===e.toLowerCase()||Kf(h.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,m,a]),g=Bt__namespace.useCallback(f=>{let h=m.find(y=>y.name===f);h&&t?.(Kf(h.fontFamily)||h.name);},[t,m]),p=Bt__namespace.useMemo(()=>{let f={"sans-serif":[],serif:[],monospace:[],other:[]};return o.forEach(h=>{let y=h.category||"other";f[y].push(h);}),f},[o]);return jsxRuntime.jsxs(Cr,{value:u,onValueChange:g,disabled:n,children:[jsxRuntime.jsx(Er,{className:ue("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":c("font.selectAriaLabel"),children:jsxRuntime.jsx(nd,{placeholder:a,children:u})}),jsxRuntime.jsxs(Sr,{className:"max-h-[300px]",children:[d.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(Tr,{children:[jsxRuntime.jsx(cn,{children:c("font.documentFonts")}),d.map(f=>jsxRuntime.jsx(Gt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},`doc-${f.name}`))]}),jsxRuntime.jsx(dn,{})]}),p["sans-serif"].length>0&&jsxRuntime.jsxs(Tr,{children:[jsxRuntime.jsx(cn,{children:c("font.sansSerif")}),p["sans-serif"].map(f=>jsxRuntime.jsx(Gt,{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(dn,{}),jsxRuntime.jsxs(Tr,{children:[jsxRuntime.jsx(cn,{children:c("font.serif")}),p.serif.map(f=>jsxRuntime.jsx(Gt,{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(dn,{}),jsxRuntime.jsxs(Tr,{children:[jsxRuntime.jsx(cn,{children:c("font.monospace")}),p.monospace.map(f=>jsxRuntime.jsx(Gt,{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(dn,{}),jsxRuntime.jsx(Tr,{children:p.other.map(f=>jsxRuntime.jsx(Gt,{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(bt()){let o=new Set,r=new Set;for(let n of t)r.has(n.name)&&!o.has(n.name)&&(console.warn(`[DocxEditor] Duplicate font name in fontFamilies: "${n.name}"`),o.add(n.name)),r.add(n.name);}return t}function i3(e,t,o,r,n){let a=Math.max(8,e.innerWidth-r-8),l=Math.max(8,e.innerHeight-n-8);return {top:Math.min(Math.max(8,t),l),left:Math.min(Math.max(8,o),a)}}function _t({isOpen:e,onClose:t,align:o="left"}){let r=Bt.useRef(null),n=Bt.useRef(null),[i,a]=Bt.useState({top:0,left:0});Bt.useEffect(()=>{if(!e||!r.current)return;let c=r.current.getBoundingClientRect();if(o==="right"){let d=editor.hostWindowOf(r.current);d.requestAnimationFrame(()=>{if(n.current){let m=n.current.getBoundingClientRect(),u=i3(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]),Bt.useEffect(()=>{if(!e)return;let c=performance.now()+150,d=f=>{f.key==="Escape"&&t();},m=f=>{if(performance.now()<c)return;let h=f.target;h&&n.current&&n.current.contains(h)||editor.isElementNode(h)&&h!==h.ownerDocument.documentElement&&h!==h.ownerDocument.body&&r.current&&h.contains(r.current)||t();},u=editor.hostDocumentOf(r.current),g=editor.hostWindowOf(r.current),p=editor.listenForOutsidePress({popup:r.current,contains:f=>!r.current||!n.current||r.current.contains(f)||n.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=Bt.useCallback(c=>{c.preventDefault(),c.stopPropagation();},[]),s={position:"fixed",top:i.top,left:i.left,zIndex:1e4};return {containerRef:r,dropdownRef:n,dropdownStyle:s,handleMouseDown:l}}var d3=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],u3=1,p3=400;function cT(e,t,o){for(let r of t)if(r>e)return r;return Math.min(e+1,o)}function dT(e,t,o){for(let r=t.length-1;r>=0;r--)if(t[r]<e)return t[r];return Math.max(e-1,o)}function uT({value:e,onChange:t,sizes:o=d3,disabled:r=false,className:n,placeholder:i="11",minSize:a=u3,maxSize:l=p3}){let{t:s}=L(),[c,d]=Bt.useState(false),[m,u]=Bt.useState(""),[g,p]=Bt.useState(false),f=Bt.useRef(null),h=Bt.useCallback(()=>{p(false),d(false);},[]),{containerRef:y,dropdownRef:x,dropdownStyle:b}=_t({isOpen:g,onClose:h}),v=e??(parseInt(i,10)||11),P=e!==void 0?e.toString():i,T=Bt.useCallback(N=>{if(N.preventDefault(),r)return;let B=dT(v,o,a);t?.(B);},[v,o,a,r,t]),C=Bt.useCallback(N=>{if(N.preventDefault(),r)return;let B=cT(v,o,l);t?.(B);},[v,o,l,r,t]),E=Bt.useCallback(N=>{N.preventDefault(),!r&&(d(true),u(P),p(true),editor.hostWindowOf(f.current).requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();}));},[r,P]),S=Bt.useCallback(N=>{u(N.target.value);},[]),k=Bt.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=Bt.useCallback(N=>{if(N.key==="Enter")N.preventDefault(),k(),p(false);else if(N.key==="Escape")d(false),p(false);else if(N.key==="ArrowUp"){N.preventDefault();let B=cT(v,o,l);u(B.toString()),t?.(B);}else if(N.key==="ArrowDown"){N.preventDefault();let B=dT(v,o,a);u(B.toString()),t?.(B);}},[k,v,o,l,a,t]),I=Bt.useCallback(N=>{t?.(N),p(false),d(false);},[t]),O=Bt.useCallback(N=>{N.target.tagName!=="INPUT"&&N.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:y,className:ue("flex items-center",n),onMouseDown:O,children:[jsxRuntime.jsx(rt,{variant:"ghost",size:"icon-sm",className:ue("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",r&&"opacity-30 cursor-not-allowed"),onMouseDown:T,disabled:r||v<=a,"aria-label":s("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsxRuntime.jsx(j,{name:"remove",size:18})}),jsxRuntime.jsx("div",{className:"relative",children:c?jsxRuntime.jsx("input",{ref:f,type:"text",value:m,onChange:S,onBlur:k,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:E,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",r&&"opacity-50 cursor-not-allowed"),disabled:r,"aria-label":s("fontSize.label"),"aria-haspopup":"listbox","aria-expanded":g,"data-testid":"font-size-display",children:P})}),g&&jsxRuntime.jsx("div",{ref:x,style:{...b,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",maxHeight:240,overflowY:"auto",minWidth:60},role:"listbox","aria-label":s("fontSize.listLabel"),children:o.map(N=>jsxRuntime.jsx("button",{type:"button",onClick:()=>I(N),className:ue("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",N===v&&"bg-muted font-medium"),role:"option","aria-selected":N===v,children:N},N))}),jsxRuntime.jsx(rt,{variant:"ghost",size:"icon-sm",className:ue("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",r&&"opacity-30 cursor-not-allowed"),onMouseDown:C,disabled:r||v>=l,"aria-label":s("fontSize.increase"),"data-testid":"font-size-increase",children:jsxRuntime.jsx(j,{name:"add",size:18})})]})}var g3=[{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"}],id=18,b3=2,h3={position:"relative",display:"inline-block"},y3={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)"},x3={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},$f={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},Vf={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},fT={display:"grid",gap:`${b3}px`},ld={width:`${id}px`,height:`${id}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},gT={...ld,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},bT={...ld,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},v3={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)"},C3={display:"flex",alignItems:"center",gap:"6px"},T3={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},E3={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},pT={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},S3={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},P3={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)"},k3={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 Gf(e,t,o){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let r=tT(e);return r||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return Wf(e,o)}function mT(e){let t=e.replace(/^#/,"");if(t.length!==6)return false;let o=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);return (o*299+r*587+n*114)/1e3>230}function hT(e,t,o){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():Yo(e,o))===t.toUpperCase():false}function w3({matrix:e,selectedColor:t,theme:o,onSelect:r}){let[n,i]=Bt.useState(null);return jsxRuntime.jsx("div",{style:{...fT,gridTemplateColumns:`repeat(10, ${id}px)`},children:e.flatMap((a,l)=>a.map((s,c)=>{let d=`${l}-${c}`,m=n===d,u=hT(t,s.hex,o);return jsxRuntime.jsx("button",{type:"button",style:{...u?bT:m?gT:ld,backgroundColor:`#${s.hex}`},title:s.label,"aria-label":s.label,"aria-selected":u,onClick:()=>r(s),onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>i(d),onMouseLeave:()=>i(null)},d)}))})}function D3({selectedColor:e,theme:t,onSelect:o}){let[r,n]=Bt.useState(null),{t:i}=L();return jsxRuntime.jsx("div",{style:{...fT,gridTemplateColumns:`repeat(10, ${id}px)`},children:g3.map((a,l)=>{let s=r===l,c=hT(e,a.hex,t),d=i(a.nameKey);return jsxRuntime.jsx("button",{type:"button",style:{...c?bT:s?gT:ld,backgroundColor:`#${a.hex}`},title:d,"aria-label":d,"aria-selected":c,onClick:()=>o(a.hex),onMouseDown:m=>m.preventDefault(),onMouseEnter:()=>n(l),onMouseLeave:()=>n(null)},a.hex)})})}function mn({mode:e,value:t,onChange:o,theme:r,disabled:n=false,className:i,style:a,title:l,icon:s,autoLabel:c,splitButton:d=true,defaultColor:m}){let[u,g]=Bt.useState(false),[p,f]=Bt.useState(false),[h,y]=Bt.useState(false),[x,b]=Bt.useState(false),[v,P]=Bt.useState(""),[T,C]=Bt.useState(()=>m??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:E}=L();Bt.useEffect(()=>{let A=Gf(t,e,r).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(A)&&P(A.toUpperCase());},[t,e,r]);let S=Bt.useCallback(()=>g(false),[]),{containerRef:k,dropdownRef:w,dropdownStyle:I}=_t({isOpen:u,onClose:S}),O=r?.colorScheme??null,N=Bt.useMemo(()=>oT(O),[O]),B=Bt.useMemo(()=>Gf(t,e,r),[t,e,r]),F=Bt.useMemo(()=>Gf(T,e,r),[T,e,r]),D=Bt.useCallback(()=>{n||g(A=>!A);},[n]),R=Bt.useCallback(A=>{let _;e==="highlight"?_=A.hex:_={kind:"theme",slot:A.themeSlot,...A.tint!==void 0?{tint:A.tint}:{},...A.shade!==void 0?{shade:A.shade}:{}},C(_),o?.(_),g(false);},[e,o]),z=Bt.useCallback(A=>{let _=e==="highlight"?A:{kind:"hex",value:A};C(_),o?.(_),g(false);},[e,o]),V=Bt.useCallback(()=>{o?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,o]),ee=Bt.useCallback(()=>{let A=v.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(A)){let _=e==="highlight"?A:{kind:"hex",value:A};C(_),o?.(_),g(false),P("");}},[e,v,o]),Y=Bt.useCallback(()=>{n||o?.(T);},[n,T,o]),q={...y3,...n?{cursor:"default",opacity:.38}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:p?{backgroundColor:"var(--doc-bg-hover)"}:{}},G=E(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),ce=s??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxRuntime.jsxs("div",{ref:k,className:`docx-color-picker ${i||""}`,style:{...h3,...a},children:[d?jsxRuntime.jsxs("div",{className:"docx-color-picker-split",style:{...S3,...n?{opacity:.38,cursor:"default"}:null},children:[jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...P3,...n?{cursor:"default"}:h?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:Y,onMouseDown:A=>A.preventDefault(),onMouseEnter:()=>y(true),onMouseLeave:()=>y(false),disabled:n,title:l||G,"aria-label":l||G,children:[jsxRuntime.jsx(j,{name:ce,size:18}),jsxRuntime.jsx("div",{style:{...pT,backgroundColor:F==="transparent"?"#fff":F,outline:F==="transparent"||mT(F)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...k3,...n?{cursor:"default"}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:x?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:D,onMouseDown:A=>A.preventDefault(),onMouseEnter:()=>b(true),onMouseLeave:()=>b(false),disabled:n,title:l||G,"aria-label":l||G,"aria-haspopup":"true","aria-expanded":u,children:jsxRuntime.jsx(j,{name:"arrow_drop_down",size:18})})]}):jsxRuntime.jsxs("button",{type:"button",className:"docx-color-picker-button",style:q,onClick:D,onMouseDown:A=>A.preventDefault(),onMouseEnter:()=>f(true),onMouseLeave:()=>f(false),disabled:n,title:l||G,"aria-label":l||G,"aria-haspopup":"true","aria-expanded":u,children:[jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsxRuntime.jsx(j,{name:ce,size:18}),jsxRuntime.jsx("div",{style:{...pT,backgroundColor:B==="transparent"?"#fff":B,outline:B==="transparent"||mT(B)?"1px solid #bbb":"none"}})]}),jsxRuntime.jsx(j,{name:"arrow_drop_down",size:14})]}),u&&jsxRuntime.jsx("div",{ref:w,className:"docx-color-picker-dropdown",style:{...I,...x3},role:"dialog","aria-label":`${G} picker`,onMouseDown:A=>{A.target.tagName!=="INPUT"&&A.preventDefault();},children:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{type:"button",style:v3,onClick:V,onMouseDown:A=>A.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??E(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsxRuntime.jsx("div",{style:Vf}),jsxRuntime.jsx("div",{style:$f,children:E("colorPicker.themeColors")}),jsxRuntime.jsx(w3,{matrix:N,selectedColor:t,theme:r,onSelect:R}),jsxRuntime.jsx("div",{style:Vf}),jsxRuntime.jsx("div",{style:$f,children:E("colorPicker.standardColors")}),jsxRuntime.jsx(D3,{selectedColor:t,theme:r,onSelect:z}),jsxRuntime.jsx("div",{style:Vf}),jsxRuntime.jsx("div",{style:$f,children:E("colorPicker.customColor")}),jsxRuntime.jsxs("div",{style:C3,children:[jsxRuntime.jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsxRuntime.jsx("input",{type:"text",style:T3,value:v,onChange:A=>P(A.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:A=>{A.key==="Enter"&&ee();},onMouseDown:A=>{A.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsxRuntime.jsx("button",{type:"button",style:{...E3,opacity:/^[0-9A-Fa-f]{6}$/.test(v)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(v)?"pointer":"default"},onClick:ee,onMouseDown:A=>A.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(v),children:E("common.apply")})]})]})})]})}var vl=20,jf=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsxRuntime.jsx(j,{name:"format_align_left",size:vl}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsxRuntime.jsx(j,{name:"format_align_center",size:vl}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsxRuntime.jsx(j,{name:"format_align_right",size:vl}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsxRuntime.jsx(j,{name:"format_align_justify",size:vl}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function vT({value:e="left",onChange:t,disabled:o=false}){let{t:r}=L(),[n,i]=Bt.useState(false),a=Bt.useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:s,dropdownStyle:c,handleMouseDown:d}=_t({isOpen:n,onClose:a}),m=Bt.useCallback(y=>{o||t?.(y),i(false);},[o,t]),u=jf.find(y=>y.value===e)||jf[0],g=r(u.labelKey),p=u.shortcutKey?r(u.shortcutKey):void 0,f=`${g}${p?` (${p})`:""}`,h=jsxRuntime.jsxs(rt,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",o&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!o&&i(y=>!y),disabled:o,"aria-label":f,"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsxRuntime.jsx(j,{name:u.iconName,size:vl}),jsxRuntime.jsx(j,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[n?h:jsxRuntime.jsx(Vt,{content:f,children:h}),n&&!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:jf.map(y=>{let x=e===y.value,b=r(y.labelKey),v=y.shortcutKey?r(y.shortcutKey):void 0;return jsxRuntime.jsx("button",{type:"button",title:`${b}${v?` (${v})`:""}`,"data-testid":`alignment-${y.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:x?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:x?"var(--doc-primary)":"var(--doc-text)"},onMouseDown:P=>P.preventDefault(),onMouseEnter:P=>{x||(P.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:P=>{P.currentTarget.style.backgroundColor=x?"var(--doc-primary-light)":"transparent";},onClick:()=>m(y.value),children:jsxRuntime.jsx(j,{name:y.iconName,size:18})},y.value)})})})]})}function sd(){return {type:"none",level:0,isInList:false}}var N3={display:"inline-flex",alignItems:"center",gap:"4px"},CT={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)"},F3={...pd,backgroundColor:"var(--doc-bg-hover)"},L3={...pd,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},H3={...pd,cursor:"default",opacity:.38},A3={width:"28px",height:"28px",padding:"2px"},O3={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},cd=20;function dd({active:e=false,disabled:t=false,title:o,onClick:r,children:n,className:i,style:a}){let[l,s]=Bt.useState(false),c={...t?H3:e?L3:l?F3: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:r,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:n})}function TT({listState:e,onBulletList:t,onNumberedList:o,onIndent:r,onOutdent:n,disabled:i=false,className:a,style:l,showIndentButtons:s=true,compact:c=false,hasIndent:d=false}){let{t:m}=L(),u=Bt.useCallback(()=>c?{...A3}:{},[c]),g=e?.type==="bullet",p=e?.type==="numbered",h=(e?.isInList||g||p)&&(e?.level??0)>0||d;return jsxRuntime.jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...N3,...l},role:"group","aria-label":m("lists.ariaLabel"),children:[jsxRuntime.jsxs("div",{style:CT,role:"group","aria-label":m("lists.typeAriaLabel"),children:[jsxRuntime.jsx(dd,{active:g,disabled:i,title:m("lists.bulletList"),onClick:t,style:u(),children:jsxRuntime.jsx(j,{name:"format_list_bulleted",size:cd})}),jsxRuntime.jsx(dd,{active:p,disabled:i,title:m("lists.numberedList"),onClick:o,style:u(),children:jsxRuntime.jsx(j,{name:"format_list_numbered",size:cd})})]}),s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:O3,role:"separator"}),jsxRuntime.jsxs("div",{style:CT,role:"group","aria-label":m("lists.indentationAriaLabel"),children:[jsxRuntime.jsx(dd,{active:false,disabled:i||!h,title:m("lists.decreaseIndent"),onClick:n,style:u(),children:jsxRuntime.jsx(j,{name:"format_indent_decrease",size:cd})}),jsxRuntime.jsx(dd,{active:false,disabled:i,title:m("lists.increaseIndent"),onClick:r,style:u(),children:jsxRuntime.jsx(j,{name:"format_indent_increase",size:cd})})]})]})]})}var W3=[{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 ST({value:e,onChange:t,options:o=W3,disabled:r=false,className:n}){let{t:i}=L(),a=Bt__namespace.useMemo(()=>e===void 0?o[0]:o.find(c=>c.twipsValue===e)||o[0],[e,o]),l=Bt__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(Cr,{value:a.twipsValue.toString(),onValueChange:l,disabled:r,children:[jsxRuntime.jsx(Er,{className:ue("h-8 text-sm gap-0.5 px-2",n),style:{width:"auto"},"aria-label":i("lineSpacing.label"),title:i("lineSpacing.lineSpacingTitle",{label:s(a)}),children:jsxRuntime.jsx(gf,{className:"h-5 w-5 shrink-0"})}),jsxRuntime.jsxs(Sr,{children:[o.map(c=>jsxRuntime.jsx(Gt,{value:c.twipsValue.toString(),children:s(c)},c.twipsValue)),jsxRuntime.jsx(dn,{}),jsxRuntime.jsx(Tr,{children:jsxRuntime.jsx(cn,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var Z3=[{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 PT({value:e,onChange:t,styles:o,disabled:r=false,className:n,width:i=120}){let{t:a}=L(),l=Bt__namespace.useMemo(()=>{let g=gx(o);return g.length===0?Z3:g.map(p=>{let f=lc(p.name);if(!f)return {...p,type:"paragraph"};let h=f.key==="styles.normal"?a("styles.normalText"):a(f.key,f.vars);return {...p,type:"paragraph",name:h}})},[o,a]),s=Bt__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(Cr,{value:d,onValueChange:s,disabled:r,children:[jsxRuntime.jsx(Er,{className:ue("h-8 text-sm",n),style:{width:typeof i=="number"?`${i}px`:i},"aria-label":a("styles.selectAriaLabel"),children:jsxRuntime.jsx("span",{className:"truncate",children:u})}),jsxRuntime.jsx(Sr,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsxRuntime.jsx(Gt,{value:g.styleId,className:"py-2.5 px-3",children:jsxRuntime.jsx("span",{style:mx(g),children:c(g)})},g.styleId))})]})}var q3=[{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 wT({value:e=1,onChange:t,levels:o=q3,disabled:r=false,className:n,compact:i=false}){let{t:a}=L(),l=Bt__namespace.useMemo(()=>{let g=o.find(p=>Math.abs(p.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[o,e]),s=Bt__namespace.useCallback(g=>{let p=parseFloat(g);isNaN(p)||t?.(p);},[t]),c=Bt__namespace.useMemo(()=>[...o].sort((g,p)=>g.value-p.value),[o]),d=Bt__namespace.useMemo(()=>[...c].reverse().find(g=>g.value<e-.001),[c,e]),m=Bt__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(rt,{variant:"ghost",size:"icon-sm",className:ue(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",(r||!d)&&"opacity-30 cursor-not-allowed"),onClick:()=>d&&t?.(d.value),disabled:r||!d,"aria-label":a("zoom.zoomOut"),children:jsxRuntime.jsx(j,{name:"remove",size:18})}),jsxRuntime.jsxs(Cr,{value:e.toString(),onValueChange:s,disabled:r,children:[jsxRuntime.jsx(Er,{className:ue(i?"h-7 min-w-[55px] text-xs":"h-8 min-w-[64px] text-sm","rounded-none",n),"aria-label":a("zoom.ariaLabel",{label:l}),children:jsxRuntime.jsx(nd,{placeholder:"100%",children:l})}),jsxRuntime.jsx(Sr,{children:o.map(g=>jsxRuntime.jsx(Gt,{value:g.value.toString(),children:g.label},g.value))})]}),jsxRuntime.jsx(rt,{variant:"ghost",size:"icon-sm",className:ue(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(r||!m)&&"opacity-30 cursor-not-allowed"),onClick:()=>m&&t?.(m.value),disabled:r||!m,"aria-label":a("zoom.zoomIn"),children:jsxRuntime.jsx(j,{name:"add",size:18})})]})}var z3=[{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 MT({onAction:e,disabled:t=false}){let{t:o}=L(),[r,n]=Bt.useState(false),i=Bt.useCallback(()=>n(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=_t({isOpen:r,onClose:i}),d=Bt.useCallback(u=>{e(u),n(false);},[e]),m=jsxRuntime.jsxs(rt,{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:c,onClick:()=>!t&&n(u=>!u),disabled:t,"aria-label":o("table.borders.styleAriaLabel"),"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsxRuntime.jsx(j,{name:"border_all",size:20}),jsxRuntime.jsx(j,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxRuntime.jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[r?m:jsxRuntime.jsx(Vt,{content:o("table.borders.tooltip"),children:m}),r&&!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:z3.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(j,{name:g,size:18})},typeof u=="string"?u:u.type))})})]})}function _T({onAction:e,disabled:t=false,theme:o,value:r}){let{t:n}=L(),i=Bt.useCallback(a=>{if(typeof a=="string"){e({type:"borderColor",color:a.replace(/^#/,"")});return}let l=a.kind==="auto"?"000000":Yo(a,o);l&&e({type:"borderColor",color:l});},[e,o]);return jsxRuntime.jsx(mn,{mode:"border",value:r,onChange:i,theme:o,disabled:t,title:n("table.borderColor")})}var j3=[{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 NT({onAction:e,disabled:t=false}){let[o,r]=Bt.useState(false),{t:n}=L(),i=Bt.useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=_t({isOpen:o,onClose:i}),d=Bt.useCallback(u=>{e({type:"borderWidth",size:u}),r(false);},[e]),m=jsxRuntime.jsxs(rt,{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&&r(u=>!u),disabled:t,"aria-label":n("table.borderWidth"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsxRuntime.jsx(j,{name:"line_weight",size:20}),jsxRuntime.jsx(j,{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(Vt,{content:n("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:j3.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 LT({onAction:e,disabled:t=false,theme:o,value:r}){let{t:n}=L(),i=Bt.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(mn,{mode:"highlight",value:r,onChange:i,theme:o,disabled:t,title:n("table.cellFillColor"),icon:"format_color_fill",autoLabel:n("colorPicker.noColor")})})}var X3={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"},bn={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},OT={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function BT({onAction:e,disabled:t=false,tableContext:o}){let{t:r}=L(),[n,i]=Bt.useState(false),[a,l]=Bt.useState(null),s=Bt.useCallback(()=>i(false),[]),{containerRef:c,dropdownRef:d,dropdownStyle:m,handleMouseDown:u}=_t({isOpen:n,onClose:s,align:"right"}),g=o?.table?.attrs?.justification??"left",p=Bt.useCallback(y=>{e(y),i(false);},[e]),f=(y,x,b,v,P)=>{let T=t||P?.itemDisabled;return jsxRuntime.jsxs("button",{type:"button",role:"menuitem",style:{...X3,backgroundColor:a===y&&!T?"var(--doc-bg-hover)":"transparent",color:T?"var(--doc-text-muted)":P?.danger?"var(--doc-error)":"var(--doc-text)",cursor:T?"not-allowed":"pointer"},onClick:()=>!T&&p(v),onMouseEnter:()=>l(y),onMouseLeave:()=>l(null),disabled:T,children:[jsxRuntime.jsx(j,{name:x,size:16,className:P?.danger&&!T?"text-destructive":""}),jsxRuntime.jsx("span",{style:{flex:1},children:b})]},y)},h=jsxRuntime.jsx(rt,{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:u,onClick:()=>!t&&i(y=>!y),disabled:t,"aria-label":r("table.moreOptions"),"aria-expanded":n,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsxRuntime.jsx(j,{name:"more_vert",size:20})});return jsxRuntime.jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[n?h:jsxRuntime.jsx(Vt,{content:r("table.moreOptions"),children:h}),n&&!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",r("table.insertRowAbove"),"addRowAbove"),f("addRowBelow","add",r("table.insertRowBelow"),"addRowBelow"),f("addColumnLeft","add",r("table.insertColumnLeft"),"addColumnLeft"),f("addColumnRight","add",r("table.insertColumnRight"),"addColumnRight"),jsxRuntime.jsx("div",{style:bn,role:"separator"}),f("mergeCells","call_merge",r("table.mergeCells"),"mergeCells",{itemDisabled:!o?.hasMultiCellSelection}),f("splitCell","call_split",r("table.splitCell"),"splitCell",{itemDisabled:!o?.canSplitCell}),jsxRuntime.jsx("div",{style:bn,role:"separator"}),f("selectTable","select_all",r("table.selectTable"),"selectTable"),jsxRuntime.jsx("div",{style:bn,role:"separator"}),f("deleteRow","delete",r("table.deleteRow"),"deleteRow",{danger:true,itemDisabled:(o?.rowCount??0)<=1}),f("deleteColumn","delete",r("table.deleteColumn"),"deleteColumn",{danger:true,itemDisabled:(o?.columnCount??0)<=1}),f("deleteTable","delete",r("table.deleteTable"),"deleteTable",{danger:true}),jsxRuntime.jsx("div",{style:bn,role:"separator"}),jsxRuntime.jsx("div",{style:OT,children:r("tableAdvanced.verticalAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(y=>{let x={top:"vertical_align_top",center:"vertical_align_center",bottom:"vertical_align_bottom"};return jsxRuntime.jsx("button",{type:"button",title:r({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:v=>v.preventDefault(),onMouseEnter:v=>{v.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:v=>{v.currentTarget.style.backgroundColor="transparent";},onClick:()=>p({type:"cellVerticalAlign",align:y}),children:jsxRuntime.jsx(j,{name:x[y],size:16})},y)})}),jsxRuntime.jsx("div",{style:bn,role:"separator"}),jsxRuntime.jsx("div",{style:OT,children:r("tableAdvanced.tableAlignment")}),jsxRuntime.jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(y=>{let x={left:"format_align_left",center:"format_align_center",right:"format_align_right"},b=g===y;return jsxRuntime.jsx("button",{type:"button",title:r({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:b?"var(--doc-primary-light)":"transparent",borderColor:b?"var(--doc-primary)":"var(--doc-border)",color:b?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:v=>v.preventDefault(),onClick:()=>p({type:"tableProperties",props:{justification:y}}),children:jsxRuntime.jsx(j,{name:x[y],size:16})},y)})}),jsxRuntime.jsx("div",{style:bn,role:"separator"}),f("headerRow","table_rows",r("tableAdvanced.toggleHeaderRow"),{type:"toggleHeaderRow"}),f("distribute","view_column",r("tableAdvanced.distributeColumns"),{type:"distributeColumns"}),f("autoFit","fit_width",r("tableAdvanced.autoFit"),{type:"autoFitContents"}),f("noWrap","wrap_text",r("tableAdvanced.toggleNoWrap"),{type:"toggleNoWrap"}),jsxRuntime.jsx("div",{style:bn,role:"separator"}),f("properties","settings",r("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var Q3=20;function gd({options:e,activeValue:t,triggerIcon:o,tooltipContent:r,onSelect:n,disabled:i=false,ariaLabel:a,testId:l,showLabels:s=false}){let[c,d]=Bt.useState(false),m=Bt.useCallback(()=>d(false),[]),{containerRef:u,dropdownRef:g,dropdownStyle:p,handleMouseDown:f}=_t({isOpen:c,onClose:m}),h=Bt.useCallback(x=>{i||n(x),d(false);},[i,n]),y=jsxRuntime.jsxs(rt,{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(x=>!x),disabled:i,"aria-label":a??r,"aria-expanded":c,"aria-haspopup":"true","data-testid":l,children:[jsxRuntime.jsx(j,{name:o,size:Q3}),jsxRuntime.jsx(j,{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(Vt,{content:r,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:x=>x.stopPropagation(),children:jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:s?"column":"row",gap:s?1:2,minWidth:s?200:void 0},children:e.map(x=>{let b=t===x.value;return jsxRuntime.jsxs("button",{type:"button",title:x.label,"data-testid":l?`${l}-${x.value}`:void 0,style:{display:"flex",alignItems:"center",height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:b?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:b?"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:v=>v.preventDefault(),onMouseEnter:v=>{b||(v.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:v=>{v.currentTarget.style.backgroundColor=b?"var(--doc-primary-light)":"transparent";},onClick:()=>h(x.value),children:[jsxRuntime.jsx(j,{name:x.iconName,size:18}),s&&jsxRuntime.jsx("span",{style:{flex:1},children:x.label})]},x.value)})})})]})}var eH=[{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 tH(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function ZT({imageContext:e,onChange:t,disabled:o=false}){let{t:r}=L(),n=eH.map(l=>({...l,label:r(l.labelKey)})),i=tH(e),a=n.find(l=>l.value===i)||n[0];return jsxRuntime.jsx(gd,{options:n,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:o,testId:"toolbar-image-wrap",showLabels:true})}var rH=[{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 KT({onTransform:e,disabled:t=false}){let{t:o}=L(),r=rH.map(n=>({...n,label:o(n.labelKey)}));return jsxRuntime.jsx(gd,{options:r,triggerIcon:"rotate_right",tooltipContent:o("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var po=18;function jt({active:e=false,disabled:t=false,title:o,onClick:r,children:n,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(rt,{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:r,"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:n});return o?jsxRuntime.jsx(Vt,{content:o,children:c}):c}function mo({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 sH(e){let t=Bt__namespace.default.useContext(hl);return t?{...t,...cH(e)}:e}function cH(e){let t={};for(let o of Object.keys(e))e[o]!==void 0&&(t[o]=e[o]);return t}function eg(e){let{t}=L(),o=sH(e),{currentFormatting:r={},onFormat:n,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:h,documentFonts:y,showFontSizePicker:x=true,showTextColorPicker:b=true,showHighlightColorPicker:v=true,showAlignmentButtons:P=true,showListButtons:T=true,showLineSpacingPicker:C=true,showStylePicker:E=true,documentStyles:S,theme:k,showZoomControl:w=true,zoom:I,onZoomChange:O,onRefocusEditor:N,imageContext:B,onImageWrapType:F,onImageTransform:D,onOpenImageProperties:R,tableContext:z,onTableAction:V,inline:ee=false}=o,Y=Bt.useRef(null),q=Bt.useCallback(ie=>{!c&&n&&n(ie);},[c,n]),G=Bt.useCallback(()=>{!c&&l&&i&&i();},[c,l,i]),ce=Bt.useCallback(()=>{!c&&s&&a&&a();},[c,s,a]),A=Bt.useCallback(ie=>{!c&&n&&n({type:"fontFamily",value:ie});},[c,n]),_=Bt__namespace.default.useMemo(()=>qf(h),[h]),ae=Bt.useCallback(ie=>{!c&&n&&n({type:"fontSize",value:ie});},[c,n]),fe=Bt.useCallback(ie=>{!c&&n&&n({type:"textColor",value:ie});},[c,n]),Z=Bt.useCallback(ie=>{!c&&n&&n({type:"highlightColor",value:typeof ie=="string"?ie:""});},[c,n]),de=Bt.useCallback(ie=>{!c&&n&&n({type:"alignment",value:ie});},[c,n]),Re=Bt.useCallback(()=>{!c&&n&&n("bulletList");},[c,n]),Ae=Bt.useCallback(()=>{!c&&n&&n("numberedList");},[c,n]),ft=Bt.useCallback(()=>{!c&&n&&n("indent");},[c,n]),ve=Bt.useCallback(()=>{!c&&n&&n("outdent");},[c,n]),nt=Bt.useCallback(ie=>{!c&&n&&(n({type:"lineSpacing",value:ie}),editor.hostWindowOf(Y.current).requestAnimationFrame(()=>N?.()));},[c,n,N]),Zt=Bt.useCallback(ie=>{!c&&n&&n({type:"applyStyle",value:ie});},[c,n]),Nt=Bt.useCallback(ie=>{!c&&V&&(V(ie),editor.hostWindowOf(Y.current).requestAnimationFrame(()=>N?.()));},[c,V,N]);Bt.useEffect(()=>{if(!u)return;let ie=Ie=>{if(Ie.defaultPrevented)return;let go=Ie.target,tr=g?.current,Ft=Y.current,Lo=tr?.contains(go),yn=Ft?.contains(go);if(!Lo&&!yn)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}},at=editor.hostDocumentOf(g?.current??Y.current);return at.addEventListener("keydown",ie),()=>{at.removeEventListener("keydown",ie);}},[u,q,de,g]);let er=Bt.useCallback(ie=>{let at=ie.target;at.tagName==="INPUT"||at.tagName==="TEXTAREA"||at.tagName==="SELECT"||at.tagName==="OPTION"||ie.preventDefault();},[]),Mr=Bt.useCallback(ie=>{let at=ie.target,Ie=editor.hostDocumentOf(at).activeElement;at.tagName==="SELECT"||at.tagName==="OPTION"||Ie?.tagName==="SELECT"||editor.hostWindowOf(at).requestAnimationFrame(()=>{N?.();});},[N]);return jsxRuntime.jsxs("div",{ref:Y,className:ue(!ee&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:ee?{display:"contents",...m}:m,role:ee?void 0:"toolbar","aria-label":ee?void 0:t("toolbar.ariaLabel"),"data-testid":ee?void 0:"formatting-bar",onMouseDown:ee?void 0:er,onMouseUp:ee?void 0:Mr,children:[jsxRuntime.jsxs(mo,{label:t("formattingBar.groups.history"),children:[jsxRuntime.jsx(jt,{onClick:G,disabled:c||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsxRuntime.jsx(j,{name:"undo",size:po})}),jsxRuntime.jsx(jt,{onClick:ce,disabled:c||!s,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsxRuntime.jsx(j,{name:"redo",size:po})})]}),w&&jsxRuntime.jsx(mo,{label:t("formattingBar.groups.zoom"),children:jsxRuntime.jsx(wT,{value:I,onChange:O,disabled:c,compact:true})}),E&&jsxRuntime.jsx(mo,{label:t("formattingBar.groups.styles"),children:jsxRuntime.jsx(PT,{value:r.styleId||"Normal",onChange:Zt,styles:S,theme:k,disabled:c,width:120})}),(f||x)&&jsxRuntime.jsxs(mo,{label:t("formattingBar.groups.font"),children:[f&&jsxRuntime.jsx(aT,{value:r.fontFamily||"Arial",onChange:A,fonts:_,documentFonts:y,disabled:c,width:60,placeholder:"Arial"}),x&&jsxRuntime.jsx(uT,{value:r.fontSize!==void 0?Qp(r.fontSize):11,onChange:ae,disabled:c,width:42,placeholder:"11"})]}),jsxRuntime.jsxs(mo,{label:t("formattingBar.groups.textFormatting"),children:[jsxRuntime.jsx(jt,{onClick:()=>q("bold"),active:r.bold,disabled:c,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsxRuntime.jsx(j,{name:"format_bold",size:po})}),jsxRuntime.jsx(jt,{onClick:()=>q("italic"),active:r.italic,disabled:c,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsxRuntime.jsx(j,{name:"format_italic",size:po})}),jsxRuntime.jsx(jt,{onClick:()=>q("underline"),active:r.underline,disabled:c,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsxRuntime.jsx(j,{name:"format_underlined",size:po})}),jsxRuntime.jsx(jt,{onClick:()=>q("strikethrough"),active:r.strike,disabled:c,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsxRuntime.jsx(j,{name:"strikethrough_s",size:po})}),b&&jsxRuntime.jsx(mn,{mode:"text",value:r.color?.replace(/^#/,""),onChange:fe,theme:k,disabled:c,title:t("formattingBar.fontColor")}),v&&jsxRuntime.jsx(mn,{mode:"highlight",value:r.highlight,onChange:Z,theme:k,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(j,{name:"link",size:po})})]}),jsxRuntime.jsxs(mo,{label:t("formattingBar.groups.script"),children:[jsxRuntime.jsx(jt,{onClick:()=>q("superscript"),active:r.superscript,disabled:c,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsxRuntime.jsx(j,{name:"superscript",size:po})}),jsxRuntime.jsx(jt,{onClick:()=>q("subscript"),active:r.subscript,disabled:c,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsxRuntime.jsx(j,{name:"subscript",size:po})})]}),P&&jsxRuntime.jsx(mo,{label:t("formattingBar.groups.alignment"),children:jsxRuntime.jsx(vT,{value:r.alignment||"left",onChange:de,disabled:c})}),(T||C)&&jsxRuntime.jsxs(mo,{label:t("formattingBar.groups.listFormatting"),children:[T&&jsxRuntime.jsx(TT,{listState:r.listState||sd(),onBulletList:Re,onNumberedList:Ae,onIndent:ft,onOutdent:ve,disabled:c,showIndentButtons:true,compact:true,hasIndent:(r.indentLeft??0)>0}),C&&jsxRuntime.jsx(ST,{value:r.lineSpacing,onChange:nt,disabled:c})]}),B&&F&&jsxRuntime.jsxs(mo,{label:t("formattingBar.groups.image"),children:[jsxRuntime.jsx(ZT,{imageContext:B,onChange:F,disabled:c}),D&&jsxRuntime.jsx(KT,{onTransform:D,disabled:c}),R&&jsxRuntime.jsx(jt,{onClick:R,disabled:c,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsxRuntime.jsx(j,{name:"tune",size:po})})]}),z?.isInTable&&V&&jsxRuntime.jsxs(mo,{label:t("formattingBar.groups.table"),children:[jsxRuntime.jsx(MT,{onAction:Nt,disabled:c}),jsxRuntime.jsx(_T,{onAction:Nt,disabled:c,theme:k,value:Yo(z?.cellBorderColor,k)}),jsxRuntime.jsx(NT,{onAction:Nt,disabled:c}),jsxRuntime.jsx(LT,{onAction:Nt,disabled:c,theme:k,value:z?.cellBackgroundColor}),jsxRuntime.jsx(BT,{onAction:Nt,disabled:c,tableContext:z})]}),jsxRuntime.jsx(jt,{onClick:()=>q("clearFormatting"),disabled:c,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsxRuntime.jsx(j,{name:"format_clear",size:po})}),p]})}function dH({children:e,className:t,style:o,...r}){return jsxRuntime.jsx(hl.Provider,{value:r,children:jsxRuntime.jsx("div",{className:ue("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:vt.toolbar,...o},"data-testid":"editor-toolbar",children:e})})}var It=dH;It.TitleBar=Bf;It.Logo=ed;It.DocumentName=Of;It.MenuBar=od;It.TitleBarRight=td;It.Toolbar=eg;var mH=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"]]),fH=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function gH({source:e,scale:t,measurer:o,documentName:r,onStateChange:n,onError:i,onSave:a,renderTitleBarLeft:l,renderTitleBarRight:s,ref:c,colorMode:d,onZoomChange:m,documentFontFamily:u,className:g}){let p=Bt.useRef(null),[f,h]=Bt.useState(null),[y,x]=Bt.useState({}),[b,v]=Bt.useState(null),P=Bt.useCallback(S=>{h(S);let k=p.current?.formatting();k&&x({bold:k.bold,italic:k.italic,underline:k.underline,strike:k.strikethrough,superscript:k.superscript,subscript:k.subscript,...k.fontFamily?{fontFamily:k.fontFamily}:{},...k.fontSizeHalfPoints?{fontSize:k.fontSizeHalfPoints}:{},...k.alignment?{alignment:k.alignment}:{},...k.styleId?{styleId:k.styleId}:{},...k.color?{color:`#${k.color}`}:{},...k.highlight?{highlight:k.highlight}:{}}),v(p.current?.sectionProperties()??null),n?.(S);},[n]),T=Bt.useCallback(S=>{let k=p.current;if(k){if(typeof S=="string")switch(S){case "bold":return k.toggleRunProperty("b");case "italic":return k.toggleRunProperty("i");case "underline":return k.toggleRunProperty("u",{val:"single"});case "strikethrough":return k.toggleRunProperty("strike");case "superscript":return k.setRunProperty("vertAlign",{val:"superscript"});case "subscript":return k.setRunProperty("vertAlign",{val:"subscript"});case "clearFormatting":k.setRunProperty("b",{val:"0"}),k.setRunProperty("i",{val:"0"}),k.setRunProperty("u",{val:"none"}),k.setRunProperty("strike",{val:"0"}),k.setRunProperty("vertAlign",{val:"baseline"});return;case "setRtl":case "setLtr":return k.setParagraphProperty("bidi",void 0,{paragraphDirection:S==="setRtl"?"rtl":"ltr"});default:return}switch(S.type){case "fontFamily":return k.setRunProperty("rFonts",{ascii:S.value,hAnsi:S.value});case "fontSize":return k.setRunProperty("sz",{val:String(Math.round(S.value*2))});case "textColor":{let w=S.value,I=typeof w=="string"?fH(w):Yo(w,null)??null;return I?k.setRunProperty("color",{val:I}):void 0}case "highlightColor":{let w=S.value.trim().toLowerCase();if(w==="none"||w==="")return k.setRunProperty("highlight",{val:"none"});let I=mH.get(w.startsWith("#")?w:`#${w}`);return I?k.setRunProperty("highlight",{val:I}):void 0}case "alignment":return k.setParagraphProperty("jc",{val:String(S.value)},{physicalAlignment:true});case "lineSpacing":return k.setParagraphProperty("spacing",{line:String(Math.round(S.value)),lineRule:"auto"},{mergeAttributes:true});case "applyStyle":return k.setParagraphProperty("pStyle",{val:S.value});default:return}}},[]);Bt.useImperativeHandle(c,()=>p.current,[]);let C=t===void 0?1:t/(96/72),E=b?{pageWidthTwips:b.pageSize.widthTwips,pageHeightTwips:b.pageSize.heightTwips,orientation:b.landscape?"landscape":"portrait",marginsTwips:{top:b.margins.topTwips,right:b.margins.rightTwips,bottom:b.margins.bottomTwips,left:b.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(It,{currentFormatting:y,onFormat:T,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(It.TitleBar,{children:[l&&jsxRuntime.jsx(It.Logo,{children:l()}),jsxRuntime.jsx(It.DocumentName,{value:r??"Document",editable:false}),s&&jsxRuntime.jsx(It.TitleBarRight,{children:s()}),jsxRuntime.jsx(It.MenuBar,{})]}),jsxRuntime.jsx(It.Toolbar,{})]}),jsxRuntime.jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[E?jsxRuntime.jsx("div",{style:{padding:"4px 0"},children:jsxRuntime.jsx(nn,{pageSetup:E,zoom:C})}):null,jsxRuntime.jsx(Nf,{ref:p,source:e,...u?{documentFontFamily:u}:{},...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onStateChange:P,...i?{onError:i}:{}})]})]})}var hd=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 yd=class extends hd{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(r=>r.id===t?{...r,dismissed:true}:r),this.emitSnapshot();let o=globalThis.setTimeout(()=>{this.timers.delete(o),this.notifications=this.notifications.filter(r=>r.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,r){let n=`error-${++this.idCounter}-${Date.now()}`,i={id:n,message:t,severity:o,details:r,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),o!=="error"){let a=globalThis.setTimeout(()=>{this.timers.delete(a),this.dismiss(n);},5e3);this.timers.add(a);}return n}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var CH=Bt.createContext(null);function GT({children:e}){let t=Bt.useMemo(()=>new yd,[]),o=Bt.useSyncExternalStore(t.subscribe,t.getSnapshot),r=Bt.useCallback((c,d)=>{t.showError(c,d);},[t]),n=Bt.useCallback((c,d)=>{t.showWarning(c,d);},[t]),i=Bt.useCallback((c,d)=>{t.showInfo(c,d);},[t]),a=Bt.useCallback(c=>{t.dismiss(c);},[t]),l=Bt.useCallback(()=>{t.clearAll();},[t]),s=Bt.useMemo(()=>({notifications:o.notifications,showError:r,showWarning:n,showInfo:i,dismissNotification:a,clearNotifications:l}),[o.notifications,r,n,i,a,l]);return jsxRuntime.jsxs(CH.Provider,{value:s,children:[e,jsxRuntime.jsx(TH,{notifications:o.notifications,onDismiss:a})]})}function TH({notifications:e,onDismiss:t}){let o=e.filter(n=>!n.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(n=>jsxRuntime.jsx(EH,{notification:n,onDismiss:()=>t(n.id)},n.id))})}function EH({notification:e,onDismiss:t}){let{t:o}=L(),[r,n]=Bt.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:()=>n(!r),style:{...g,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:o(r?"errors.hideDetails":"errors.showDetails")}),r&&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 xd=class extends Bt.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:r,errorInfo:n}=this.state;return t?typeof t=="function"?t(r,this.resetError):t:jsxRuntime.jsx(SH,{error:r,errorInfo:n,showDetails:o,onReset:this.resetError})}return this.props.children}};function SH({error:e,errorInfo:t,showDetails:o,onReset:r}){let{t:n}=L(),i={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"var(--doc-surface)",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},a={color:"var(--doc-error)",marginBottom:"16px"},l={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},c={width:"100%",maxWidth:"600px",marginBottom:"16px",padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"200px",overflow:"auto"},d={padding:"10px 20px",background:"var(--doc-primary)",color:"var(--doc-on-primary)",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return jsxRuntime.jsxs("div",{className:"docx-error-fallback",style:i,children:[jsxRuntime.jsx("div",{style:a,children:jsxRuntime.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsxRuntime.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsxRuntime.jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsxRuntime.jsx("h2",{style:l,children:n("errors.somethingWentWrong")}),jsxRuntime.jsx("p",{style:s,children:n("errors.errorDescription")}),o&&jsxRuntime.jsxs("div",{style:c,children:[jsxRuntime.jsx("strong",{children:n("errors.errorLabel")})," ",e.message,t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[`
3
3
 
4
4
  `,jsxRuntime.jsx("strong",{children:n("errors.componentStack")}),t.componentStack]})]}),jsxRuntime.jsx("button",{type:"button",onClick:r,style:d,children:n("errors.tryAgain")})]})}function XT({onClick:e,topPx:t,scrollLeft:o=0,leftOffset:r=Ca}){let{t:n}=L();return jsxRuntime.jsx("button",{className:"docx-outline-toggle",onClick:e,onMouseDown:i=>i.stopPropagation(),title:n("editor.showDocumentOutline"),"aria-label":n("editor.showDocumentOutline"),style:{position:"absolute",left:r-o,top:t,zIndex:vt.outline},children:jsxRuntime.jsx(j,{name:"format_list_bulleted",size:20})})}function og({currentPage:e,totalPages:t,visible:o}){let{t:r}=L();return jsxRuntime.jsx("div",{style:{position:"absolute",right:24,top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--doc-overlay)",color:"#fff",padding:"6px 12px",borderRadius:"4px",fontSize:"12px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:500,whiteSpace:"nowrap",pointerEvents:"none",zIndex:1e3,opacity:o?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:r("viewer.pageIndicator",{current:e,total:t})})}function kH({i18n:e,isDark:t,onEditorError:o,containerRef:r,scrollContainerRef:n,editorContentRef:i,className:a,containerStyle:l,mainContentStyle:s,editorContainerStyle:c,showRuler:d,readOnlyProp:m,showOutline:u,showOutlineButton:g,sidebarOpen:p,minLayoutWidth:f,toolbarHeight:h,editorScrollLeft:y,onScrollContainerMouseDown:x,onEditorBgMouseDown:b,onEditorContextMenu:v,horizontalRulerProps:P,verticalRulerProps:T,outlineProps:C,onToggleOutline:E,scrollPageInfo:S,toolbar:k,pagedArea:w,overlays:I,dialogs:O,fileInputs:N}){let B=d&&!m;return jsxRuntime.jsx(Ao.Provider,{value:true,children:jsxRuntime.jsx(vn,{i18n:e,children:jsxRuntime.jsx(GT,{children:jsxRuntime.jsx(xd,{onError:o,children:jsxRuntime.jsxs("div",{ref:r,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:[k,jsxRuntime.jsxs("div",{ref:n,className:"docx-editor__scroll-container",style:c,onMouseDown:x,children:[d&&jsxRuntime.jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:vt.ruler,paddingLeft:20,paddingRight:20+(p?352:0),minWidth:f,transition:"padding 0.2s ease"},children:jsxRuntime.jsx(nn,{...P})}),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:b,onContextMenu:v,children:[B&&jsxRuntime.jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:vt.ruler,paddingTop:48},children:jsxRuntime.jsx(el,{...T})}),w]})})]}),S.totalPages>1&&jsxRuntime.jsx(og,{currentPage:S.currentPage,totalPages:S.totalPages,visible:S.visible}),u&&jsxRuntime.jsx(ol,{...C,leftOffset:tl+(B?va:0)}),g&&!u&&jsxRuntime.jsx(XT,{onClick:E,topPx:h+(d?cf+8:0)+48,scrollLeft:y,leftOffset:Ca+(B?va:0)})]})}),I,O,N]})})})})})}function NH(e){let[t,o]=Bt.useState(0);return Bt.useEffect(()=>{if(!e)return;let r=()=>o(a=>a+1),n=e.on("change",r),i=e.on("selectionChange",r);return r(),()=>{n(),i();}},[e]),t}function BH({kind:e}){let t=H(),[o,r]=Bt.useState(null),n=Bt.useRef(null);Bt.useLayoutEffect(()=>{if(!t||!o)return;let a=editor.bindHistoryGroup(t,o,{kind:e});return n.current=a,()=>{a.dispose(),n.current=null;}},[t,o,e]);let i=Bt.useCallback(()=>{if(!n.current)throw new Error("history group control is not mounted");return n.current.options()},[]);return {ref:r,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=wt;exports.ContextMenuCellVerticalAlignment=$r;exports.ContextMenuCopy=ai;exports.ContextMenuCopyFormatting=fs;exports.ContextMenuCut=ni;exports.ContextMenuDelete=ii;exports.ContextMenuDeleteTable=oa;exports.ContextMenuDeleteTableColumn=ta;exports.ContextMenuDeleteTableRow=ea;exports.ContextMenuInsertColumnLeft=Yn;exports.ContextMenuInsertColumnRight=Xn;exports.ContextMenuInsertRowAbove=Gn;exports.ContextMenuInsertRowBelow=jn;exports.ContextMenuItem=bs;exports.ContextMenuMergeCells=Jn;exports.ContextMenuPaste=zn;exports.ContextMenuPasteFormatting=gs;exports.ContextMenuPasteWithoutFormatting=$n;exports.ContextMenuRefreshToc=ra;exports.ContextMenuRefreshTocPageNumbers=na;exports.ContextMenuRemoveToc=aa;exports.ContextMenuSelectAll=li;exports.ContextMenuSelectTable=Vn;exports.ContextMenuSplitCell=Qn;exports.DEFAULT_WATERMARK_PRESETS=qu;exports.DocumentName=Of;exports.DocumentOutline=ol;exports.DocxEditor=wL;exports.DocxEditorAuthorStyle=om;exports.DocxEditorBookmarkDialog=ei;exports.DocxEditorColorByChangeType=tm;exports.DocxEditorContent=Os;exports.DocxEditorContentControl=Ua;exports.DocxEditorContentControlWidget=zp;exports.DocxEditorContextMenu=ui;exports.DocxEditorDocumentOutline=hf;exports.DocxEditorEquation=za;exports.DocxEditorExportDialog=Na;exports.DocxEditorFontNotice=jc;exports.DocxEditorHeaderFooterChrome=Xc;exports.DocxEditorHorizontalRuler=Ac;exports.DocxEditorHyperLink=Za;exports.DocxEditorImageAltTextPopup=Rs;exports.DocxEditorImageInsertErrorDialog=Tu;exports.DocxEditorImagePropertiesDialog=fi;exports.DocxEditorInvalidTextFormFieldDialog=Ep;exports.DocxEditorLoading=Ws;exports.DocxEditorLoadingSpinner=em;exports.DocxEditorMenu=Xi;exports.DocxEditorNavigation=Pf;exports.DocxEditorNotePreview=En;exports.DocxEditorNotePropertiesDialog=Ts;exports.DocxEditorNotesChrome=Cs;exports.DocxEditorNotesContextMenu=Sn;exports.DocxEditorOpenFailure=Yc;exports.DocxEditorOpenFailureAction=wf;exports.DocxEditorPageNumber=Gc;exports.DocxEditorPageSetupDialog=qr;exports.DocxEditorParagraphDialog=qo;exports.DocxEditorPrintDialog=Fa;exports.DocxEditorRevisionMarkup=Vd;exports.DocxEditorRevisionMarkupDialog=Ia;exports.DocxEditorRoot=Ti;exports.DocxEditorShell=kH;exports.DocxEditorSplitCellDialog=ti;exports.DocxEditorTextFormFieldDialog=ri;exports.DocxEditorToolbar=Vi;exports.DocxEditorUnsupportedElement=Cd;exports.DocxEditorVerticalRuler=Oc;exports.DocxEditorViewport=Us;exports.DocxEditorWatermarkDialog=Ur;exports.DocxEditorWindow=Jp;exports.HorizontalRuler=nn;exports.ImageAltText=Ds;exports.ImageInsertProvider=$l;exports.ImageInsertTrigger=Vl;exports.ImagePropertiesTrigger=ws;exports.ImageWrap=ec;exports.LocaleProvider=vn;exports.Logo=ed;exports.MenuBar=od;exports.NAVIGATION_PANE_GAP=Yv;exports.NAVIGATION_PANE_INSET=Wc;exports.NAVIGATION_PANE_MIN_PAGE_ROOM=xf;exports.NAVIGATION_PANE_WIDTH=Ea;exports.NavigationClose=sl;exports.NavigationFind=ml;exports.NavigationGoTo=rl;exports.NavigationHeader=ll;exports.NavigationHeadings=pl;exports.NavigationTab=ul;exports.NavigationTabs=dl;exports.NavigationTitle=cl;exports.NavigationToggle=fl;exports.OUTLINE_BUTTON_LEFT_OFFSET=Ca;exports.OUTLINE_BUTTON_RESERVED_SPACE=R6;exports.OUTLINE_LEFT_OFFSET=tl;exports.OUTLINE_RESERVED_SPACE=w6;exports.PageIndicator=og;exports.PageNumberTranslationContext=Vc;exports.PaginatedDocxEditor=Nf;exports.PaginatedDocxEditorShell=gH;exports.REVIEW_MARKERS_GUTTER=da;exports.REVIEW_PANE_GUTTER=Ei;exports.RULER_WIDTH=va;exports.ReviewRailContext=Lt;exports.Slot=J;exports.TitleBar=Bf;exports.TitleBarRight=td;exports.Toolbar=eg;exports.ToolbarButton=jt;exports.ToolbarContext=Hr;exports.ToolbarGroup=mo;exports.ToolbarImageProperties=ia;exports.VERSION=eE;exports.VerticalRuler=el;exports.definePopup=lP;exports.editorStateActiveSubscriptionCount=EE;exports.isFieldLink=Oa;exports.navigationPaneOverlays=Kc;exports.navigationPaneReservation=Sa;exports.navigationShift=Zc;exports.normalizeImageBytes=Ul;exports.notificationYieldsToTask=pg;exports.provideDocxEditor=u1;exports.reviewGutter=j0;exports.useBookmarkDialog=hD;exports.useBookmarks=tp;exports.useChromeDir=it;exports.useChromeTranslate=cg;exports.useCommentDraftRequest=GL;exports.useContentControl=vo;exports.useContentControlInstance=Ol;exports.useContentControlWidget=st;exports.useContextMenuTarget=Bb;exports.useDocumentOutline=qc;exports.useDocumentSearch=Uc;exports.useDocxEditor=H;exports.useDocxSource=LL;exports.useEditorCaret=UL;exports.useEditorColorMode=NE;exports.useEditorCommand=oe;exports.useEditorEvent=Zm;exports.useEditorHostDocument=Jm;exports.useEditorSnapshot=NH;exports.useEditorState=W;exports.useEditorValueCommand=gi;exports.useFontFamily=ic;exports.useFonts=WL;exports.useGoToBookmark=Bc;exports.useHeaderFooterState=Rf;exports.useHighlightAt=a4;exports.useHighlights=JL;exports.useHistoryGroup=BH;exports.useHyperlinkPopup=xP;exports.useHyperlinkPopupInstance=Hl;exports.useNavigationPane=zc;exports.useNavigationShift=Lr;exports.useNotePropertiesState=pp;exports.useNoteScopeState=up;exports.useOpenFailure=RC;exports.usePageSetup=Kr;exports.usePageSetupDialog=Fw;exports.useParagraphDialog=Vw;exports.useParagraphFormat=Wu;exports.useParagraphIndent=uf;exports.useParagraphStyle=sc;exports.useReviewAuthors=ki;exports.useReviewGutter=fr;exports.useRevisionMarkupDialog=XS;exports.useScopeClassName=RE;exports.useScopedChromeAnchor=pi;exports.useSplitCellDialog=DD;exports.useTableBorderTargetLabel=jx;exports.useTextFormFieldDialog=LD;exports.useToolbarContext=cS;exports.useToolbarLabel=ne;exports.useToolbarLabelFor=_l;exports.useTranslation=L;exports.useWatermark=Xu;exports.useWatermarkDialog=Th;exports.useZoom=Sm;