@docx-editor.dev/react 2.33.0 → 2.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import*as Bt from'react';import Bt__default,{createContext,useCallback,useState,useRef,useEffect,forwardRef,useMemo,useLayoutEffect,useId,useContext,useSyncExternalStore,Children,useReducer,Fragment as Fragment$1,isValidElement,cloneElement,createElement,useImperativeHandle,Component}from'react';import {REVISION_MARKUP_COLORS,tableChromeIconPaths,CHROME_MENUS,hostWindowOf,listenForOutsidePress,commandForSlotValue,hostDocumentOf,chromeProbeForSlot,isHTMLElementNode,NO_MIXED_FIELDS,seedFields,mixedFieldsOf,changedFields,withTabStop,inchesToTwips,twipsToInches,formatInches,TAB_ALIGNMENT_LABELS,CHROME_GROUPS,chromeSlotId,editorCommandKey,toolbarCommandState,commandExecOptions,runToolbarCommand,LOADING_SNAPSHOT,placeSubmenu,submenuKeys,chromeSlotIsToggle,commandForSlot,calendarDateText,calendarMonthNames,toolbarPopupLeft,isDomNode,FIT_WIDTH_ZOOM_MODE,sameZoomMode,AUTO_ZOOM_MODE,lineSpacingMenuRows,lineSpacingMenuRowLabel,TABLE_BORDER_TARGET_OPTIONS,TABLE_BORDER_STYLE_OPTIONS,TABLE_BORDER_WIDTH_OPTIONS,collapseOrder,TOOLBAR_COLLAPSE_ORDER,editorInstanceScope,goToBookmarkGroups,keepScrollAtInlineEnd,isElementNode,clipboardPasteLandsContent,clipboardDropLandsText,createDocxEditor,resolveZoomMode,resolveRevisionMarkup,defaultTableLabel,validateDrawingPositionInput,positionInputFromPropertiesCommand,DRAWING_REL_FROM_H,DRAWING_REL_FROM_V,IMAGE_WRAP_TARGETS,isChromePrintShortcut,openEditorWindow,trapTabWithin,alignmentAfterDirectionChange,editorHostDocument,bookmarkDialogInitialName,bookmarkDialogRows,bookmarkDialogNameState,initialSplitCellCounts,readSplitCellCounts,TEXT_FORM_FORMATS,contentControlPopupOpener,observeContentControlPopup,contentControlPopupKeyDown,listenForPopupEscape,listenForPopupFocusLeave,formattingBarChromeGroups,TOOLBAR_PINNED_GROUPS,arrangeToolbarGroups,readColumnGap,readAvailableWidth,readInlineMargins,separatorLeadingCost,collapsibleGroupCost,trailingGapCost,controlsOverflow,toolbarOverflowGroups,TOOLBAR_OVERFLOW_HYSTERESIS,sameOverflow,hasOpenNestedPopup,DEFAULT_TABLE_CHROME_DRAFT,runTableChromeCommand,runChromeExport,ChromeExportError,ChromePrintError,runChromePrint,editorHostElement,createDocumentSearch,goToBookmarkRows,goToBookmarkTarget,observeHostDirection,REVIEW_MARKERS_GUTTER_PX,overlayHostOrigin,createImageOverlayScrollPort,captureImageMutationPreconditions,isStaleImageInteractionCommit,selectedDrawingOverlayTargetOf,historyShortcutOf,IMAGE_OVERLAY_NUDGE_SHIFT_PT,IMAGE_OVERLAY_NUDGE_PT,computeImageResizeResult,resizePreservesAspect,computeMovedImagePosition,overlayFrameToSheetCssPixels,textboxFrameReason,dragIndent,handlePosition,rulerMarginTicks,rulerTabPosition,unsupportedElementRuleMatches,observeUnsupportedElements,executeImageCommand,watermarkShapeBox,SPLIT_CELL_FALLBACK_MAX,createContentControlListNavigation,parseIsoDate,calendarMonth,shiftMonth,isoDateOf,calendarDateFromText,CONTENT_CONTROL_PICTURE_ACCEPT,toolbarPanelPlacement,tableChromeToolbarState,ZOOM_MAX,ZOOM_MIN,hostTimers,goToBookmarkMatch,reviewPaneEntitledZoom,hostDirectionOf,storyLabelTop,cssPixelsToLayoutPoints,finalizeImageOverlayInteraction,SNAP_TWIPS_CM,SNAP_TWIPS_INCH,DEFAULT_IMAGE_RESOURCE_LIMITS as DEFAULT_IMAGE_RESOURCE_LIMITS$1,sniffImageMime,validateRasterHeader,chordLetter,isGoToChord,tableChromeLabelKeyForTarget,defineFontResolver,composeFontOrigins,composeFontConfiguration,watchHighlights,mountPaginatedSurface,bindHistoryGroup,calendarDateForKey,isFontResolver,applyThemeTint,applyThemeShade,resolveThemeColorHex}from'@docx-editor.dev/core/editor';export{CHROME_GROUPS,CHROME_MENUS,DEFAULT_FONT,DocumentRefreshError,HIGHLIGHT_REFRESH_MS,LOADING_SNAPSHOT,MAX_RESOLVER_FAMILIES,PX_PER_CM,PX_PER_INCH,SEARCH_DEBOUNCE_MS,SEARCH_HIGHLIGHT_PRIORITY,SEARCH_HIGHLIGHT_SET,SEARCH_MATCH_LIMIT,WORD_DEFAULT_FONT,chromeMenuSlots,commandForSlot,composeFontConfiguration,composeFontOrigins,createDocumentRefresh,createFontSource,deferFonts,defineFontResolver,generateRulerTicks,isFontResolver,loadFonts,rulerPageBox,runToolbarCommand,toolbarCommandState}from'@docx-editor.dev/core/editor';import {createPortal,flushSync}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {en,localizeDisabledReason,createT,chromeDirection,catalogDirection,deepMerge,platformShortcut,isApplePlatform}from'@docx-editor.dev/i18n';import {DEFAULT_IMAGE_RESOURCE_LIMITS}from'@docx-editor.dev/core/store';import {cva}from'class-variance-authority';import {clsx}from'clsx';import*as Fe from'@radix-ui/react-select';export{EditorFontError}from'@docx-editor.dev/core/contracts/editor';var $f={version:"2.33.0"};var LT=$f.version;function Vf(){let e=new Map,t=new Map,o=new Set,n=0,r=0,i=null,a=[],l,s=false,c=()=>[...e].sort((u,g)=>t.get(u[0])-t.get(g[0])),d=()=>{r++;for(let u of o)u();},m=()=>{d(),!s&&(s=true,queueMicrotask(()=>{s=false,i?.setUnsupportedElementRules(c().map(([,u])=>u));}));};return {register(u,g){t.has(u)||t.set(u,n++),e.set(u,g),m();},unregister(u){e.delete(u)&&m();},connect(u){i=u,u&&m();},current:()=>c().map(([,u])=>u),setContainer(u){l?.();for(let g of a)g.setCustomized(false);a=[],l=u?observeUnsupportedElements(u,g=>{a=g,d();}):void 0,d();},subscribe(u){return o.add(u),()=>o.delete(u)},snapshot:()=>r,hosts(u){let g=c();return a.filter(p=>g.find(([,f])=>unsupportedElementRuleMatches(f,p.unsupported))?.[0]===u)}}}var hr=createContext(null);function Gf(e){return Children.toArray(e).some(t=>isValidElement(t)&&t.type===Fragment$1?Gf(t.props.children):typeof t!="string"||t.trim().length>0)}function jf({host:e,children:t}){let o=Gf(t);return useLayoutEffect(()=>(e.setCustomized(o),()=>{e.setCustomized(false);}),[e,o]),o?createPortal(t,e.slot):null}function dd({match:e,layout:t,includePartial:o,children:n}){let r=useContext(hr);if(!r)throw new Error("DocxEditor.UnsupportedElement must render inside DocxEditor.Root.");let i=useRef(Symbol("unsupported-element-declaration")).current;return useSyncExternalStore(r.subscribe,r.snapshot,r.snapshot),useLayoutEffect(()=>{r.register(i,{includePartial:o,...e?{match:e}:{},...t?{layout:t}:{}});},[r,i,e,t,o]),useLayoutEffect(()=>()=>r.unregister(i),[r,i]),r.hosts(i).map(a=>jsx(jf,{host:a,children:n({element:a.unsupported})},a.key))}var ud=createContext(en),pd=createContext("en"),md=createContext("ltr"),fd=createContext(void 0);function yr({i18n:e,dir:t,children:o}){let n=useContext(ud),r=useContext(pd),i=useContext(md),a=useContext(fd),l=typeof e?._lang=="string"?e._lang:r,s=chromeDirection(t,e,a),c=s??catalogDirection(e)??i,d=useMemo(()=>deepMerge(n,e),[n,e]);return jsx(pd.Provider,{value:l,children:jsx(md.Provider,{value:c,children:jsx(fd.Provider,{value:s,children:jsx(ud.Provider,{value:d,children:o})})})})}function F(){let e=useContext(ud),t=useContext(pd),o=useContext(md);return {t:useMemo(()=>createT(e,t),[e,t]),catalogue:e,lang:t,dir:o}}function at(){return useContext(fd)}function Jf(e){let{t}=F();return useCallback((o,n)=>e?.get(o)??t(o,n),[e,t])}var gd=createContext(null);function L(){return useContext(gd)}function vl(e){return (e?.mounted??0)+(e?.gutters??0)>0}var Nt=createContext(null);var bd=0,hd=false,yd=false,Cl=[],Tl=null;function eg(e){if(typeof MessageChannel!="function"){globalThis.setTimeout(e,0);return}Tl||(Tl=new MessageChannel,Tl.port1.onmessage=()=>{let t=Cl;Cl=[];for(let o of t)try{o();}catch(n){queueMicrotask(()=>{throw n});}}),Cl.push(e),Cl.length===1&&Tl.port2.postMessage(null);}function tg(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(hd||(hd=true,bd+=1,queueMicrotask(()=>{hd=false;}),yd||(yd=true,eg(()=>{yd=false,bd=0;}))),bd>16)}function og(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};tg()?eg(o):queueMicrotask(o);}}var nE=()=>{},vd=0;function rE(){return vd}function Da(e){return og(e)}function K(e,t=Object.is,o){let n=L(),r=o?.onSubscribe,i=o?.onUnsubscribe,a=useCallback(d=>{if(!n)return nE;let m=false;vd++,r?.();let u=Da(()=>{m||d();}),g=[n.on("change",u),n.on("selectionChange",u),n.on("error",u)];return ()=>{m=true,vd--,i?.();for(let p of g)p();}},[n,r,i]),l=useMemo(()=>{let d=false,m,u;return g=>{if(d&&g===m)return u;let p=e(g);return d&&t(u,p)?(m=g,u):(d=true,m=g,u=p,p)}},[n,e,t]),s=useCallback(()=>l(n?n.snapshot():LOADING_SNAPSHOT),[n,l]),c=useCallback(()=>l(LOADING_SNAPSHOT),[l]);return useSyncExternalStore(a,s,c)}function sE(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function cE(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=sE(t[n],e[n]):n==="className"?o[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(o[n]={...e[n],...t[n]});return o}function X({children:e,...t}){let o=Children.only(e);if(!isValidElement(o))return null;let n=o.props,r=cE(t,n),i=o.ref,a=t.ref;return (i||a)&&(r.ref=l=>{for(let s of [i,a])typeof s=="function"?s(l):s&&typeof s=="object"&&(s.current=l);}),cloneElement(o,r)}var ag=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function Tt(){let e=createContext(null),t=new Map,o=v=>{let b=t.get(v.type);return b==="field"?`field:${v.props.name}`:b};function n(v,b){Children.forEach(v,y=>{isValidElement(y)&&(b(y),n(y.props.children,b));});}function r(){let v=useContext(e);if(!v)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return v.state}function i(v,b){return Children.map(v,y=>{if(!isValidElement(y))return y;let C=ag(y.props);return C&&b.has(C)?b.get(C):y.props.children===void 0?y:cloneElement(y,{children:i(y.props.children,b)})})}function a(v){function b(y){let C=useContext(e);if(!C||y.hidden)return null;let T=v==="field"?`field:${y.name}`:v,x=C.defaults.get(T);if(!x)return y.children??null;let{children:E,asChild:P,className:k,style:w,hidden:D,name:M,...H}=y,I={...H,...x.props,className:[x.props.className,k].filter(Boolean).join(" "),style:{...x.props.style,...w}};if(P){let{children:A,className:S,style:_,...B}=I;return jsx(X,{...B,...k?{className:k}:{},...w?{style:w}:{},children:E})}return cloneElement(x,I,E===void 0?i(x.props.children,C.overrides):E)}return t.set(b,v),b}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:v,children:b,preset:y=true,state:C}){let T=new Map;n(v,k=>{let w=ag(k.props);w&&T.set(w,k);});let x=new Map;n(b,k=>{let w=o(k);w&&x.set(w,k);});let E=k=>Children.toArray(k).flatMap(w=>isValidElement(w)&&w.type===Fragment$1?E(w.props.children):[w]),P=E(b).filter(k=>!isValidElement(k)||!o(k));return jsx(e.Provider,{value:{defaults:T,overrides:x,state:C},children:y?jsxs(Fragment,{children:[i(v,x),P]}):b})}return {Header:l,Title:s,Body:c,Footer:d,Apply:m,Cancel:u,Reset:g,Error:p,Field:f,Composition:h,useState:r,part:v=>a(v)}}function Be({kind:e,role:t="dialog",className:o,style:n,label:r,onClose:i,onKeyDown:a,panelRef:l,children:s,dismissOutside:c=true,sessionSignal:d,restoreFocus:m=true,describedBy:u}){let g=useRef(null),p=l??g,f=useRef(i);f.current=i;let[h,v]=useState(false);return useLayoutEffect(()=>{let b=p.current;if(!b)return;v(!b.parentElement?.closest(".docx-editor"));let y=b.ownerDocument.activeElement,C=()=>{b.open&&b.close?.();};return d?.addEventListener("abort",C),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",C),typeof b.close=="function"&&b.open&&b.close(),m&&y?.isConnected&&y.focus({preventScroll:true});}},[p,d,m]),jsx("dialog",{ref:p,role:t,"aria-modal":"true","aria-label":r,"aria-describedby":u,className:`docx-dialog${h?" docx-editor":""}${o?` ${o}`:""}`,style:n,"data-docx-dialog":e,onCancel:b=>{b.preventDefault(),f.current();},onMouseDown:b=>b.stopPropagation(),onClick:b=>{if(c&&b.target===b.currentTarget){let y=b.currentTarget.getBoundingClientRect();(b.clientX<y.left||b.clientX>y.right||b.clientY<y.top||b.clientY>y.bottom)&&f.current();}b.stopPropagation();},onKeyDown:b=>{b.key==="Escape"&&!b.nativeEvent.isComposing?(b.preventDefault(),f.current()):trapTabWithin(b.currentTarget,b.nativeEvent)?b.preventDefault():!b.nativeEvent.isComposing&&!b.defaultPrevented&&a?.(b),b.stopPropagation();},children:s})}function po(e,t){let o=L(),n=Sd(),r=useRef(null);return useEffect(()=>{if(!e){r.current=null;return}o?.surface&&(r.current===null?r.current=o.mountGeneration:r.current!==o.mountGeneration&&t());},[e,o,n,t]),()=>!!o?.surface&&r.current===o.mountGeneration}function Sd(){let e=L(),t=useCallback(o=>{if(!e)return ()=>{};let n=true,r=Da(()=>{n&&o();}),i=[e.on("change",r),e.on("selectionChange",r),e.on("error",r)];return ()=>{n=false,i.forEach(a=>a());}},[e]);return useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function ig(){let e=0,t=0,o=null,n=new Set,r=new Set,i=new Set,a=l=>{for(let s of [...l])s();};return {getShift:()=>e,setShift(l){let s=Math.max(0,Math.round(l));s!==e&&(e=s,a(n));},subscribeShift(l){return n.add(l),()=>n.delete(l)},getReservation:()=>t,setReservation(l){let s=Math.max(0,Math.round(l));s!==t&&(t=s,a(r));},subscribeReservation(l){return r.add(l),()=>r.delete(l)},getViewport:()=>o,setViewport(l){l!==o&&(o=l,a(i));},subscribeViewport(l){return i.add(l),()=>i.delete(l)}}}var kd=createContext(null);function Nn(){return useContext(kd)}var lg=()=>0,wd=()=>()=>{};function Fn(){let e=Nn(),t=useCallback(n=>e?e.subscribeShift(n):wd(),[e]),o=useCallback(()=>e?e.getShift():0,[e]);return useSyncExternalStore(t,o,lg)}function sg(){let e=Nn(),t=useCallback(n=>e?e.subscribeReservation(n):wd(),[e]),o=useCallback(()=>e?e.getReservation():0,[e]);return useSyncExternalStore(t,o,lg)}function Se(){let e=Nn(),t=useCallback(r=>e?e.subscribeViewport(r):wd(),[e]),o=useCallback(()=>e?e.getViewport():null,[e]),n=useCallback(()=>null,[]);return useSyncExternalStore(t,o,n)}function Lo(e,t,o){let n=Se(),r=useRef({close:o,viewport:n});r.current={close:o,viewport:n},useEffect(()=>{let i=e.current;if(!(!t||!i))return DE(i,()=>r.current.close(),()=>r.current.viewport)},[e,t]);}function DE(e,t,o){let n=l=>{if(l.defaultPrevented||l.altKey||l.ctrlKey||l.metaKey)return;let s=l.target;if(s.matches('input[role="combobox"]')||s.matches("input, textarea, select")&&l.key!=="ArrowDown"&&l.key!=="ArrowUp")return;let d=Array.from(e.querySelectorAll('[role="option"]')).filter(g=>!g.matches(':disabled, [aria-disabled="true"]'));if(d.length===0)return;let m=d.indexOf(s),u;if(l.key==="Home")u=0;else if(l.key==="End")u=d.length-1;else if(l.key==="ArrowDown")u=(m+1)%d.length;else if(l.key==="ArrowUp")u=m<0?d.length-1:(m-1+d.length)%d.length;else return;l.preventDefault(),l.stopPropagation(),d[u]?.focus();},r=l=>{isDomNode(l.relatedTarget)&&!e.contains(l.relatedTarget)&&t();},i=listenForPopupEscape({popup:e,contains:l=>e.contains(l),chromeRoot:()=>e.closest(".docx-editor"),editorElements:()=>[o()],skip:l=>isElementNode(l.target)&&e.contains(l.target)&&l.target.matches('input[role="combobox"]'),close:l=>{l&&e.querySelector("[aria-haspopup]")?.focus(),t();}}),a=listenForPopupFocusLeave({popup:e,contains:l=>e.contains(l),close:t});return e.addEventListener("keydown",n),e.addEventListener("focusout",r),()=>{e.removeEventListener("keydown",n),e.removeEventListener("focusout",r),i(),a();}}function LE(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason&&e.value===t.value}function Dd(e){return typeof e=="string"}function se(e){let t=L(),{t:o}=F(),n=Dd(e)?e:editorCommandKey(e),r=useRef(e);r.current=e;let i=useCallback(s=>{let c=r.current;if(Dd(c)){let m=toolbarCommandState(t,c);return {active:m.active,enabled:m.enabled,disabledReason: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:localizeDisabledReason(d.reason??null,o),value:null}},[t,n,o]),a=K(i,LE),l=useCallback(s=>{let c=commandExecOptions(s),d=r.current;return Dd(d)?runToolbarCommand(t,d,void 0,c??{}).ok:t?t.exec(d,c).ok:false},[t]);return useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[l,a])}var Ln=createContext({t:void 0,onSave:void 0});function AE(){return useContext(Ln)}function Sl(e){let{t}=F();return o=>e?.(o)??t(o)}function ne(){let{t:e}=useContext(Ln);return Sl(e)}var ZE=()=>()=>{},KE=()=>true,qE=()=>false;function Ho(){let e=useSyncExternalStore(ZE,KE,qE);return useCallback(t=>e?platformShortcut(t):t,[e])}function UE(e){let t=e.viteEnv?.DEV;return typeof t=="boolean"?t:e.hasProcess&&e.nodeEnv!=="production"}function zE(){try{return import.meta.env}catch{return}}function gt(){let e=typeof process<"u";return UE({viteEnv:zE(),nodeEnv:e?"production":void 0,hasProcess:e})}var pg=new Set;function on(e){!gt()||pg.has(e)||(pg.add(e),console.warn(`[docx-editor] ${e}`));}function mg(e){on(`Menu.Item and ContextMenu.Slot take the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function fg(e){on(`A hidden context-menu override names "${e}", but no packaged row has that id, so nothing is removed.`);}function gg(){on("A Menu.Item or ContextMenu.Slot has no slotId, so it renders nothing.");}function bg(){on("A Menu.Submenu has neither label nor labelKey, so its row has no name.");}function hg(e){on(`Toolbar.Button takes the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function yg(){on("A Toolbar.Button has no slotId, so it renders nothing.");}function te(e){for(let t of CHROME_GROUPS)for(let o of t.controls)if(chromeSlotId(t,o)===e)return o;return null}function re(e){return e?jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:e.map(t=>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 jE(e){if(e.slotId)return e.slotId;if(e.slot)return hg(e.slot),e.slot;yg();}function Ao(e){let{icon:t,asChild:o,className:n,children:r,hidden:i}=e,a=jE(e)??"",{execute:l,isActive:s,isEnabled:c,disabledReason:d,value:m}=se(a),u=ne(),g=Ho();if(i||!a)return null;let p=te(a),f=g(u(p?.labelKey??a)),h=chromeSlotIsToggle(a),v={onClick:()=>l(),onMouseDown:U,disabled:!c,"data-slot":a,className:`docx-toolbar__button${n?` ${n}`:""}`,...s?{"data-active":""}:{},...c?{}:{"data-disabled":""},...h?{"aria-pressed":s}:{},...m!==null?{"data-value":m}:{},"aria-label":f,title:d??f};return o?jsx(X,{...v,children:r}):jsx("button",{type:"button",...v,children:t??r??re(p?.paths)})}Ao.docxToolbarPart=true;var oS=[{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"}],xg=[{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"}],vg=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],kl=["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"],nn=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),Zt=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function nS(e){let t=[0,2,4].map(n=>parseInt(e.slice(n,n+2),16)),o=(Math.max(...t)+Math.min(...t))/2/255;return o===1?[Zt(5),Zt(15),Zt(25),Zt(35),Zt(50)]:o===0?[nn(50),nn(35),nn(25),nn(15),nn(5)]:o>=.8?[Zt(10),Zt(25),Zt(50),Zt(75),Zt(90)]:[nn(80),nn(60),nn(40),Zt(25),Zt(50)]}var rS=/^[0-9A-Fa-f]{6}$/;function aS(e,t){let o="";for(let n=0;n<6;n+=2){let r=Math.round(t(parseInt(e.slice(n,n+2),16)));o+=Math.max(0,Math.min(255,r)).toString(16).padStart(2,"0");}return o.toUpperCase()}function iS(e){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),n=parseInt(e.slice(4,6),16);return .299*t+.587*o+.114*n>230}function vr({value:e,css:t,title:o,selected:n,apply:r}){return jsx("button",{type:"button",className:"docx-toolbar__swatch",style:{backgroundColor:t},"aria-label":o,"aria-pressed":n,title:o,"data-value":e,...n?{"data-selected":""}:{},...t.startsWith("var(")||iS(t.replace("#",""))?{"data-light":""}:{},onMouseDown:U,onClick:()=>r(e)})}function lS({apply:e,label:t,current:o,themeHexes:n}){let r=n.map(nS),i=[0,1,2,3,4];return jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.themeColors")}),jsxs("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--theme",role:"group",children:[n.map((a,l)=>jsx(vr,{value:a,css:`#${a.toLowerCase()}`,title:t(kl[l]),selected:o===a,apply:e},`base-${l}`)),i.map(a=>n.map((l,s)=>{let c=r[s][a],d=aS(l,c.apply);return jsx(vr,{value:d,css:`#${d.toLowerCase()}`,title:`${t(kl[s])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${s}`)}))]})]})}function sS(e){let{apply:t,label:o,current:n}=e,[r,i]=useState(""),a=rS.test(r);return jsxs(Fragment,{children:[jsx(lS,{...e}),jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.standardColors")}),jsx("div",{className:"docx-toolbar__swatch-grid",role:"group",children:oS.map(l=>jsx(vr,{value:l.value,css:l.css,title:o(l.labelKey),selected:n===l.value,apply:t},l.value))})]}),jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.customColor")}),jsxs("div",{className:"docx-toolbar__swatch-custom",children:[jsx("span",{className:"docx-toolbar__swatch-hash","aria-hidden":"true",children:"#"}),jsx("input",{type:"text",className:"docx-toolbar__swatch-hex",value:r,maxLength:6,spellCheck:false,"aria-label":o("colorPicker.customColor"),onChange:l=>i(l.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:l=>{l.key==="Enter"&&a&&t(r.toUpperCase());}}),jsx("button",{type:"button",className:"docx-toolbar__swatch-apply",disabled:!a,onMouseDown:U,onClick:()=>t(r.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function Md({apply:e,current:t}){let o=L(),n=ne(),r=o?.getDocumentThemeColors()??[],i=r.length===kl.length?r.map(l=>l.hex):vg,a=t?.toUpperCase()??null;return jsx(sS,{apply:e,label:n,current:a,themeHexes:i})}var cS=xg.filter(e=>e.value!=="white");function dS({apply:e,label:t,current:o}){return jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.highlightColors")}),jsx("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--highlight",role:"group",children:cS.map(n=>jsx(vr,{value:n.value,css:n.css,title:t(n.labelKey),selected:o===n.value,apply:e},n.value))})]})}function Cg(e){let{slot:t,defaultValue:o,cssOf:n,clear:r,body:i}=e,a=t==="text.color";return Object.assign(({className:s,hidden:c,icon:d})=>{let m=L(),{isEnabled:u,disabledReason:g}=se(t),p=ne(),[f,h]=useState(false),[v,b]=useState(o),y=useRef(null);Lo(y,f,()=>h(false));let C=K(w=>{if(a){let D=w.formatting?.color;return D&&D.kind==="hex"?D.value.toUpperCase():null}return w.formatting?.highlight??null}),T=m?.getDocumentThemeColors()??[],x=T.length===kl.length?T.map(w=>w.hex):vg;useEffect(()=>{if(f)return listenForOutsidePress({popup:y.current,close:()=>h(false)})},[f]);let E=useCallback(w=>{if(h(false),!m)return;m.focus();let D=commandForSlotValue(t,w);D&&m.can(D).ok&&(m.exec(D),w!==r.value&&b(w));},[m]),P=useMemo(()=>te(t),[]);if(c)return null;let k=p(P?.labelKey??t);return jsxs("div",{ref:y,className:`docx-toolbar__colorsplit${s?` ${s}`:""}`,"data-slot":t,children:[jsxs("button",{type:"button",className:"docx-toolbar__button docx-toolbar__colorsplit-main",disabled:!u,...u?{}:{"data-disabled":""},"aria-label":k,title:g??k,onMouseDown:U,onClick:()=>E(v),children:[d??re(P?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:n(v)},"aria-hidden":"true"})]}),jsx("button",{type:"button",className:"docx-toolbar__colorsplit-caret",disabled:!u,...u?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":f,"aria-label":k,title:g??k,onMouseDown:U,onClick:()=>h(w=>!w),children:"\u25BE"}),f?jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":k,onMouseDown:U,children:[jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:U,onClick:()=>E(r.value),children:[jsx("span",{className:`docx-toolbar__swatch-clear-chip${r.value==="none"?" docx-toolbar__swatch-clear-chip--none":""}`,"aria-hidden":"true"}),p(r.labelKey)]}),i({apply:E,label:p,current:C,themeHexes:x})]}):null]})},{docxSlot:t})}var uS=new Map(xg.map(e=>[e.value,e.css])),_d=Cg({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsx(Md,{apply:e.apply,current:e.current})}),Id=Cg({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>uS.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsx(dS,{...e})});var Fd=e=>e==="auto"?"currentColor":e==="byAuthor"?"var(--doc-review-author-0)":e==="none"?"transparent":`var(--doc-revision-color-${e})`;function Dl({label:e,value:t,values:o,disabled:n,change:r,t:i}){let a=useId(),[l,s]=useState(false),c=useRef(null),d=useRef(null),m=useRef(null);useLayoutEffect(()=>{if(!l||!m.current||!d.current)return;let g=observeContentControlPopup(m.current,d.current);return (m.current.querySelector("[data-selected]")??m.current.querySelector("button"))?.focus(),g},[l]),useEffect(()=>{if(n&&s(false),!l)return;let g=c.current?.ownerDocument,p=f=>{c.current?.contains(f.target)||s(false);};return g?.addEventListener("pointerdown",p),()=>g?.removeEventListener("pointerdown",p)},[l,n]);let u=()=>{s(false),d.current?.focus();};return jsxs("div",{ref:c,className:"docx-revision-color-picker",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||s(false);},children:[jsx("span",{id:`${a}-label`,children:e}),jsxs("button",{ref:d,type:"button",className:"docx-revision-color-trigger",disabled:n,"aria-labelledby":`${a}-label ${a}-value`,"aria-expanded":l&&!n,"aria-controls":`${a}-options`,onClick:()=>s(!l),children:[jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:Fd(t)}}),jsx("span",{id:`${a}-value`,children:i(`values.${t}`)})]}),jsxs("div",{ref:m,id:`${a}-options`,className:"docx-revision-color-options",hidden:!l||n,role:"group","aria-labelledby":`${a}-label`,onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),u());let p=Array.from(g.currentTarget.querySelectorAll("button")),f=p.indexOf(g.target),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:[jsx("div",{className:"docx-revision-color-special",children:o.filter(g=>["auto","none","byAuthor"].includes(g)).map(g=>jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear","aria-pressed":t===g,"data-selected":t===g?"":void 0,onClick:()=>{r(g),u();},children:[jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:Fd(g)}}),i(`values.${g}`)]},g))}),jsx("div",{className:"docx-toolbar__swatch-grid",children:o.filter(g=>!["auto","none","byAuthor"].includes(g)).map(g=>jsx(vr,{value:g,css:Fd(g),title:i(`values.${g}`),selected:t===g,apply:p=>{r(p),u();}},g))})]})]})}var Tg=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],yS=["byAuthor","auto",...REVISION_MARKUP_COLORS];function Eg(e,t,o){let{values:n}=e,r=a=>{let l=a==="changedLines"?["none","leftBorder","rightBorder","outsideBorder"]:a==="deletions"||a==="movedFrom"?[...Tg,"hidden","caret","pound"]:Tg,s=(a==="movedFrom"||a==="movedTo")&&!n.trackMoves;return jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxs("div",{className:"docx-revision-markup-row",children:[jsx("span",{className:"docx-revision-markup-row-title","aria-hidden":"true",children:t(a)}),jsxs("label",{children:[jsx("span",{className:"docx-revision-markup-field-label",children:t(a)}),jsx("select",{value:n[a].mark,disabled:s,onChange:c=>e.setValue(a,{...n[a],mark:c.target.value}),children:l.map(c=>jsx("option",{value:c,children:t(`values.${c}`)},c))})]}),jsx(Dl,{label:t(`${a}Color`),value:n[a].color,values:yS,disabled:s,t,change:c=>e.setValue(a,{...n[a],color:c})})]}),a!=="changedLines"&&jsx("div",{className:"docx-revision-markup-background",children:jsx(Dl,{label:t(`${a}Background`),value:n[a].background,values:["none","byAuthor",...REVISION_MARKUP_COLORS],disabled:s,t,change:c=>e.setValue(a,{...n[a],background:c})})})]})},i=a=>jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxs("label",{children:[jsx("input",{type:"checkbox",checked:n[a],"aria-describedby":`${o}-${a}`,onChange:l=>e.setValue(a,l.target.checked)}),t(a)]}),jsx("p",{id:`${o}-${a}`,children:t(`${a}Note`)})]});return jsxs(Fragment,{children:[jsxs("fieldset",{children:[jsx("legend",{children:t("markup")}),r("insertions"),r("deletions"),r("changedLines")]}),jsxs("fieldset",{children:[jsx("legend",{children:t("moves")}),i("trackMoves"),r("movedFrom"),r("movedTo")]}),jsxs("fieldset",{"data-docx-part":"field","data-docx-field":"cells",className:"docx-revision-markup-tableCells",children:[jsx("legend",{children:t("tableCells")}),["inserted","deleted","merged","split"].map(a=>jsx(Dl,{label:t(`${a}Cells`),value:n.cells[a],values:["byAuthor","none",...REVISION_MARKUP_COLORS],t,change:l=>e.setValue("cells",{...n.cells,[a]:l})},a))]}),jsxs("fieldset",{children:[jsx("legend",{children:t("formatting")}),i("trackFormatting"),r("formatting")]})]})}var Gt=Tt();function PS(){return Gt.useState()}function kS({session:e,...t}){return e?jsx(wS,{session:e,...t}):null}function wS({session:e,children:t,preset:o,className:n,style:r}){let i=useId(),{t:a}=F(),l=f=>a(`revisionMarkup.${f}`),s=useCallback(f=>e.subscribe(f),[e]),c=useCallback(()=>e.get(),[e]),d=useSyncExternalStore(s,c,c),[m,u]=useState(e.signal.aborted),g=useRef(null);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:jsx(Be,{kind:"revisionMarkup",label:l("title"),className:["docx-revision-markup-dialog",n].filter(Boolean).join(" "),style:r,onClose:p.cancel,dismissOutside:false,sessionSignal:e.signal,children:jsx(Gt.Composition,{state:p,preset:o,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",children:jsx("h2",{"data-docx-part":"title",children:l("title")})}),jsx("div",{"data-docx-part":"body",className:"docx-revision-markup-body",children:Eg(p,l,i)}),jsxs("div",{"data-docx-part":"footer",className:"docx-revision-markup-actions",children:[jsx("button",{"data-docx-part":"reset",type:"button",onClick:p.reset,children:l("reset")}),jsx("span",{"data-docx-part":"error",role:"alert",children:p.errors.form}),jsx("button",{"data-docx-part":"cancel",type:"button",onClick:p.cancel,children:l("cancel")}),jsx("button",{"data-docx-part":"apply",type:"button",disabled:!p.isEnabled,onClick:p.apply,children:l("ok")})]})]}),children:t})})}var Ra=Object.assign(kS,{Header:Gt.Header,Title:Gt.Title,Body:Gt.Body,Footer:Gt.Footer,Apply:Gt.Apply,Cancel:Gt.Cancel,Error:Gt.Error,Field:Gt.Field,Reset:Gt.Reset});function Hd(e){let t=L(),o=useRef(e.onRevisionMarkupChange);o.current=e.onRevisionMarkupChange;let{onRevisionMarkupChange:n,...r}=e,i=JSON.stringify(r);return useEffect(()=>t?.on("revisionMarkupChange",a=>o.current?.(a)),[t]),useEffect(()=>{t&&t.setRevisionMarkup(JSON.parse(i));},[t,i]),null}function Ma({open:e,format:t,pending:o,error:n,onClose:r,className:i,style:a,children:l}){let{t:s}=F();if(!e)return null;let c=s(n?t==="pdf"?"toolbar.exportPdfFailed":"toolbar.exportMarkdownFailed":t==="pdf"?"toolbar.exportingPdf":"toolbar.exportingMarkdown");return jsx(Be,{kind:"export",label:c,role:n?"alertdialog":"dialog",className:`docx-export-dialog${o?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:r,children:l??jsxs(Fragment,{children:[jsxs("header",{className:"docx-dialog__header",children:[o&&jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsx("span",{className:"docx-export-dialog__spinner"})}),jsx("h2",{className:"docx-dialog__title",children:c})]}),jsx("div",{className:"docx-dialog__body",children:jsx("p",{className:"docx-export-dialog__message",role:n?"alert":"status",children:n||s("toolbar.exportDownloadHint")})}),jsx("footer",{className:"docx-dialog__footer",children:jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:s(n?"common.close":"toolbar.exportContinueEditing")})})]})})}function _a({open:e,pending:t,error:o,url:n,onClose:r,className:i,style:a,children:l}){let{t:s}=F();if(!e)return null;let c=s(o?"toolbar.printFailed":"toolbar.printPreparing"),d=n.startsWith("blob:")?n:"";return 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:r,onKeyDown:m=>{isChromePrintShortcut(m.nativeEvent)&&m.preventDefault();},children:l??jsxs(Fragment,{children:[jsxs("header",{className:"docx-dialog__header",children:[t&&jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsx("span",{className:"docx-export-dialog__spinner"})}),jsx("h2",{className:"docx-dialog__title",children:c})]}),o&&jsx("div",{className:"docx-dialog__body",children:jsx("p",{className:"docx-export-dialog__message",role:"alert",children:o})}),jsxs("footer",{className:"docx-dialog__footer",children:[o&&d&&jsx("a",{className:"docx-dialog__link-button docx-print-dialog__open",href:d,target:"_blank",rel:"noopener noreferrer",children:s("toolbar.printOpenPdf")}),jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:s(o?"common.close":"common.cancel")})]})]})})}var xt={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function Cr({text:e,x:t,y:o,className:n}){return jsx("div",{role:"tooltip",className:n,"data-testid":"docx-notes-preview",style:{position:"fixed",left:t,top:o,zIndex:xt.popover,maxWidth:280,maxHeight:"40vh",overflowY:"auto",padding:"8px 10px",background:"var(--doc-popover-bg)",color:"var(--doc-popover-fg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",fontSize:12,lineHeight:1.4,pointerEvents:"none"},onMouseDown:r=>{r.preventDefault(),r.stopPropagation();},children:e})}function Tr({noteKind:e,x:t,y:o,onDelete:n,onConvert:r,onConvertAll:i,onOpenProperties:a,onClose:l,deleteEnabled:s,convertEnabled:c,convertAllEnabled:d,deleteDisabledReason:m,convertDisabledReason:u,convertAllDisabledReason:g,className:p}){let{t:f}=F();return 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:xt.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:[jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!s,title:m,onClick:n,children:f("notes.delete")}),jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-convert",disabled:!c,title:u,onClick:r,children:f(e==="footnote"?"notes.convertToEndnote":"notes.convertToFootnote")}),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")}),jsx("button",{type:"button",role:"menuitem",onClick:a,children:f("dialogs.footnoteProperties.title")})]})}function LS(e){return t=>createElement(e,t)}var Dg=new WeakMap,HS=0;function Ee(e,t,o){if(e===false)return null;let n=e(t);if(!o)return n;let r=Dg.get(o);return r===void 0&&Dg.set(o,r=++HS),createElement(Fragment$1,{key:r},n)}var Od=createContext(void 0),St=()=>useContext(Od);function Er(e,t,o){let n=e.getBoundingClientRect();return {left:t-n.left-e.clientLeft+e.scrollLeft,top:o-n.top-e.clientTop+e.scrollTop}}function Na(e){return e.paragraphId===""}var An=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),$S=e=>e;function VS(e){let t=r=>!!r&&(r.width>0||r.height>0),o=hostDocumentOf(e);if(o){let i=o.querySelector("[data-docx-caret]")?.getBoundingClientRect();if(t(i))return {left:i.left,top:i.bottom}}let n=o?o.getSelection():null;if(n&&n.rangeCount>0){let r=n.getRangeAt(0),i=r.getBoundingClientRect();if(t(i))return {left:i.left,top:i.bottom};let a=r.startContainer,s=(isElementNode(a)?a:a.parentElement)?.getBoundingClientRect();if(t(s))return {left:s.left,top:s.bottom}}return null}var Fa=createContext(null);function Wd(){let e=useContext(Fa),t=Ml(e===null);return e??t}function Ml(e=true){let t=L(),o=Se(),n=useRef(o);n.current=o;let[r,i]=useState(An),a=useRef(null),l=useRef(r);l.current=r;let s=K($S),c=t?t.can({type:"insertText",text:""}).ok:false,d=useCallback(()=>{let T=a.current;T&&(T.editor.releaseSelection(T.pin),a.current=null);},[]),m=useCallback((T,x)=>{d(),i({mode:T?"reading":"editing",link:T??null,anchor:x??null,text:T?.text??"",url:T?T.kind==="internal"?`#${T.anchor??""}`:T.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,d]),u=useCallback(()=>{d(),i(An);},[d]);useEffect(()=>d,[d]);let g=useCallback(()=>{let T=VS(n.current);d();let x=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(x&&Na(x)){m(x,T);return}if(x){i({mode:"editing",link:x,anchor:T,text:x.text,url:x.kind==="internal"?`#${x.anchor??""}`:x.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let E=t?.query({type:"selectedText"})??"",P=t?.retainSelection()??null;t&&P&&(a.current={editor:t,pin:P}),i({mode:"editing",link:null,anchor:T,text:E,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,m,d]);useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:T=>m(T.link,{left:T.rect.left,top:T.rect.bottom}),onRequest:g})},[t,e,m,g]),useEffect(()=>{let T=l.current;if(T.mode!=="reading"||!T.link)return;let x=Na(T.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;x&&x.id===T.link.id||i(An);},[s,t]),useEffect(()=>{let T=l.current;if(T.mode!=="editing"||T.link)return;let x=t?.surface;!x||x.retainedSelection()||i(An);},[s,t]);let p=useCallback(async()=>{let T=l.current.link?.href;if(!T)return false;try{await hostWindowOf(n.current).navigator.clipboard.writeText(T);}catch{return false}return i(x=>({...x,copied:true})),true},[]),f=useCallback(()=>{i(T=>({...T,mode:"editing",copied:false,error:false}));},[]),h=useCallback(T=>{i(x=>({...x,text:T,copied:false,error:false}));},[]),v=useCallback(T=>{i(x=>({...x,url:T,copied:false,error:false}));},[]),b=useCallback(()=>{let T=l.current,x=t?.surface?.hyperlinks;if(!x)return false;let E=T.url.trim();if(E.length===0)return i(w=>({...w,error:true})),false;let P=E.startsWith("#");return x.applyHyperlink({...P?{anchor:E.slice(1)}:{url:E},...T.text.trim().length>0?{text:T.text}:{}})?(u(),true):(i(w=>({...w,error:true})),false)},[t,u]),y=useCallback(()=>{let T=t?.surface?.hyperlinks,x=l.current.link;if(!T)return false;let E=T.removeHyperlink(x?.id);return E&&u(),E},[t,u]),C=useCallback(()=>{let T=t?.surface?.navigation,x=l.current.link;if(!T||!x)return false;if(x.kind==="internal"){let P=x.anchor?T.goToBookmark(x.anchor):false;return P&&i(An),P}let E=T.openExternal(x.href);return E&&i(An),E},[t]);return useMemo(()=>({state:r.mode==="closed"?An:{...r,canEdit:c},open:m,openAtCaret:g,close:u,copy:p,beginEdit:f,setText:h,setUrl:v,commitEdit:b,unlink:y,openTarget:C}),[r,c,m,g,u,p,f,h,v,b,y,C])}function Bn(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var _l=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),oP="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-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",aP="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 iP({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=go(),a=useRef(null),{state:l,close:s}=i;useEffect(()=>{if(l.mode==="closed")return;let f=b=>{b.key==="Escape"&&(b.preventDefault(),s());},h=hostDocumentOf(a.current);h.addEventListener("keydown",f);let v=listenForOutsidePress({popup:h,contains:b=>a.current?.contains(b)===true,close:s});return ()=>{h.removeEventListener("keydown",f),v();}},[l.mode,s]);let[c,d]=useState(null);useLayoutEffect(()=>{let f=l.anchor,h=a.current;if(!f||!h){d(null);return}let v=h.offsetParent;if(!v){d(null);return}let{left:b,top:y}=Er(v,f.left,f.top),C=Math.max(0,v.scrollWidth-h.offsetWidth);d({left:Math.max(0,Math.min(b,C)),top:y});},[l.anchor]);let{t:m}=F(),u=l.mode==="editing"?m(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):m("hyperlinkPopup.editLink"),g=r?jsx(lP,{children:n}):n;if(o)return l.mode==="closed"?null:jsx(Fragment,{children:n});let p={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:Bn,style:c??void 0,"aria-label":u};return l.mode==="closed"?null:t?jsx(X,{...p,children:n}):jsx("div",{...p,children:g})}function lP({children:e}){let{state:t}=go(),o=useMemo(()=>sP(e),[e]),n=(i,a)=>i in o?o[i]:a;if(t.mode==="editing")return jsxs(Fragment,{children:[n("Fields",jsx($d,{})),n("Error",jsx(Gd,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Apply",jsx(Vd,{})),n("Cancel",jsx(jd,{}))]}),o.__extra]});let r=t.canEdit&&!(t.link&&Na(t.link));return jsxs(Fragment,{children:[n("Url",jsx(Kd,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Copy",jsx(qd,{})),r?n("Edit",jsx(Ud,{})):null,r?n("Unlink",jsx(zd,{})):null]}),o.__extra]})}function sP(e){let t={},o=[],n=r=>{if(Array.isArray(r)){r.forEach(n);return}if(!r||typeof r!="object"||!("type"in r)){r&&o.push(r);return}if(r.type===Fragment$1){n(r.props.children);return}let i=r.type.docxHyperLinkPart;i?t[i]=r:o.push(r);};return n(e),o.length>0&&(t.__extra=o),t}function go(){return useContext(Fa)??cP}var cP={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 Kd({className:e,asChild:t,hidden:o,children:n}){let{state:r,openTarget:i}=go(),{t:a}=F();if(o||!r.link)return null;let l=!r.link.href,s=r.link.kind==="internal",c=s?`#${r.link.anchor??""}`:r.link.authored,d=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:Bn,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsx(X,{...u,className:e,children:n}):l?jsxs("span",{...u,children:[n??d,jsx("span",{className:"docx-editor-sr-only",children:m})]}):jsxs("button",{...u,children:[n??d,_l(aP)]})}Kd.docxHyperLinkPart="Url";function qd({className:e,asChild:t,hidden:o,children:n,icon:r}){let{state:i,copy:a}=go(),{t:l}=F();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:Bn,onClick:()=>{a();}};return t?jsx(X,{...c,className:e,children:n}):jsx("button",{...c,children:r??n??_l(oP)})}qd.docxHyperLinkPart="Copy";function Ud({className:e,asChild:t,hidden:o,children:n,icon:r}){let{beginEdit:i}=go(),{t:a}=F();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:Bn,onClick:()=>i()};return t?jsx(X,{...s,className:e,children:n}):jsx("button",{...s,children:r??n??_l(nP)})}Ud.docxHyperLinkPart="Edit";function zd({className:e,asChild:t,hidden:o,children:n,icon:r}){let{unlink:i}=go(),{t:a}=F();if(o)return null;let l=a("hyperlinkPopup.removeLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":l,title:l,onMouseDown:Bn,onClick:()=>i()};return t?jsx(X,{...s,className:e,children:n}):jsx("button",{...s,children:r??n??_l(rP)})}zd.docxHyperLinkPart="Unlink";function $d({className:e,hidden:t}){let{state:o,setText:n,setUrl:r,commitEdit:i,close:a}=go(),{t:l}=F(),s=useRef(null),c=useId(),d=useId();useEffect(()=>{o.mode==="editing"&&(s.current?.focus({preventScroll:true}),s.current?.select());},[o.mode]);let m=useCallback(u=>{if(u.key==="Enter"){u.preventDefault(),i();return}u.key==="Escape"&&(u.preventDefault(),a());},[i,a]);return t?null:jsxs("div",{className:`docx-hyperlink-popup__fields${e?` ${e}`:""}`,children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:l("hyperlinkPopup.displayTextPlaceholder")}),jsx("input",{id:c,"data-testid":"hyperlink-popup-text",className:"docx-hyperlink-popup__input",value:o.text,dir:o.text?"auto":void 0,placeholder:l("hyperlinkPopup.displayTextPlaceholder"),onChange:u=>n(u.target.value),onKeyDown:m}),jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:l("hyperlinkPopup.urlPlaceholder")}),jsx("input",{id:d,ref:s,"data-testid":"hyperlink-popup-url-input",className:"docx-hyperlink-popup__input",value:o.url,dir:"ltr",placeholder:l("hyperlinkPopup.urlPlaceholder"),onChange:u=>r(u.target.value),onKeyDown:m})]})}$d.docxHyperLinkPart="Fields";function Vd({className:e,asChild:t,hidden:o,children:n}){let{state:r,commitEdit:i}=go(),{t:a}=F();if(o)return null;let l=a("hyperlinkPopup.apply"),s={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:Bn,onClick:()=>i()};return t?jsx(X,{...s,className:e,children:n}):jsx("button",{...s,children:n??l})}function Gd({className:e,hidden:t}){let{state:o}=go(),{t:n}=F();return t||!o.error?null:jsx("div",{className:`docx-hyperlink-popup__error${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-error",role:"alert",children:n("hyperlinkPopup.refused")})}Gd.docxHyperLinkPart="Error";Vd.docxHyperLinkPart="Apply";function jd({className:e,asChild:t,hidden:o,children:n}){let{close:r}=go(),{t:i}=F();if(o)return null;let a=i("hyperlinkPopup.cancel"),l={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:Bn,onClick:()=>r()};return t?jsx(X,{...l,className:e,children:n}):jsx("button",{...l,children:n??a})}jd.docxHyperLinkPart="Cancel";var La=Object.assign(iP,{Url:Kd,Copy:qd,Edit:Ud,Unlink:zd,Fields:$d,Error:Gd,Apply:Vd,Cancel:jd});var Pt={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function mP(e){return e==="sdtLocked"||e==="sdtContentLocked"}function fP(e){return e==="contentLocked"||e==="sdtContentLocked"}function Xd(e,t){return !e.ok&&e.code===t}function bo(){let e=useContext(Jd),t=Il();return e??t}function Il(){let e=L(),[t,o]=useState(false),[n,r]=useState(false),[i,a]=useState(false),l=K(E=>E),s=e?.surface??null,c=s?.contentControls;useEffect(()=>{r(c?.showAll()??s?.state().contentControls.showAll??false),a(c?.formFill()??s?.state().contentControls.formFill??false);},[l,c,s]);let d=useMemo(()=>{if(!e)return null;let E=c?.atCaret()??null;if(E){let S=c?.disabledReason(E.id,"edit")??null,_=c?.disabledReason(E.id,"remove")??null;return {id:E.id,tag:E.tag??null,alias:E.alias??null,controlType:E.controlType,locked:fP(E.effectiveLock)||S==="locked",removalLocked:mP(E.effectiveLock)||_==="locked",placeholder:E.placeholder,bound:E.bound||S==="bound",effectiveLock:E.effectiveLock}}let P=e.query({type:"contentControlAt"});if(!P)return null;let k=c?.disabledReason(P.id,"edit")??null,w=c?.disabledReason(P.id,"remove")??null,D=e.can({type:"setContentControlValue",value:""}),M=e.can({type:"removeContentControl"}),H=P.locked===true||k==="locked"||Xd(D,"locked"),I=k==="bound"||Xd(D,"bound"),A=w==="locked"||Xd(M,"locked");return {id:P.id,tag:P.tag??null,alias:P.alias??null,controlType:P.controlType,locked:H,removalLocked:A,placeholder:false,bound:I,effectiveLock:null}},[e,l,c]),m=useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=useCallback(E=>{c?.setShowAll(E),r(E);},[c]),g=useCallback(E=>{c?.setFormFill(E),a(E);},[c]),p=useCallback(()=>u(!n),[u,n]),f=useCallback(()=>g(!i),[g,i]),h=useCallback(()=>o(true),[]),v=useCallback(()=>o(false),[]),b=useCallback(()=>o(E=>!E),[]),y=useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let P=c.disabledReason(d.id,"edit");return P==="locked"?"the content control is locked":P==="bound"?"the content control is bound to external data":P==="notFound"?"the content control was not found":P}if(d.locked)return "the content control is locked";if(d.bound)return "the content control is bound to external data";if(!e)return "no document is loaded";let E=e.can({type:"setContentControlValue",value:""});return E.ok?null:E.reason},[d,c,e]),C=useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let P=c.disabledReason(d.id,"remove");return P==="locked"?"the content control is locked":P==="notFound"?"the content control was not found":P}if(d.removalLocked)return "the content control is locked";if(!e)return "no document is loaded";let E=e.can({type:"removeContentControl"});return E.ok?null:E.reason},[d,c,e]),T=useCallback(E=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c&&d){let P=c.disabledReason(d.id,"edit");if(P)return {ok:false,code:P==="bound"?"bound":P==="locked"?"locked":"notFound",reason:P==="bound"?"the content control is bound to external data":P==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:E})},[e,c,d]),x=useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c){let E=d?.id;if(!E)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let P=c.disabledReason(E,"remove");return P?{ok:false,code:P==="locked"?"locked":"notFound",reason:P==="locked"?"the content control is locked":"the content control was not found"}:c.remove(E)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,c,d]);return useMemo(()=>({control:d,controls:m,showAll:n,formFill:i,inspectorOpen:t,canSetValue:y===null&&d!==null,canRemove:C===null&&d!==null,setValueDisabledReason:y,removeDisabledReason:C,setShowAll:u,toggleShowAll:p,setFormFill:g,toggleFormFill:f,openInspector:h,closeInspector:v,toggleInspector:b,remove:x,setValue:T}),[d,m,n,i,t,y,C,u,p,g,f,h,v,b,x,T])}var Jd=createContext(null);function Qd(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var Fg=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),xP="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",vP="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",CP={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},TP={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},EP={color:"var(--doc-text-muted)",flexShrink:0},SP={textAlign:"right",wordBreak:"break-word"},PP={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},kP={display:"flex",gap:8,marginTop:4},Lg={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 wP(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 DP(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 Sr({label:e,value:t,testId:o}){return jsxs("div",{style:TP,"data-testid":o,children:[jsx("span",{style:EP,children:e}),jsx("span",{style:SP,children:t})]})}function RP({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=bo(),a=useRef(null),l=useId(),{t:s}=F(),{control:c,inspectorOpen:d,closeInspector:m}=i;if(useEffect(()=>{if(!d)return;let f=b=>{b.key==="Escape"&&(b.preventDefault(),m());},h=hostDocumentOf(a.current);h.addEventListener("keydown",f);let v=listenForOutsidePress({popup:h,contains:b=>a.current?.contains(b)===true,close:m});return ()=>{h.removeEventListener("keydown",f),v();}},[d,m]),useEffect(()=>{d&&!c&&m();},[d,c,m]),o||!d||!c)return null;let u=r?jsxs(Fragment,{children:[jsx(Hg,{}),jsx(Ag,{}),jsx("div",{style:kP,children:jsx(Og,{})}),n]}):n,g={ref:a,role:"dialog","aria-modal":false,"aria-labelledby":l,"data-testid":"content-control-inspector","data-control-id":c.id,"data-control-type":c.controlType,...c.locked?{"data-locked":""}:{},...c.bound?{"data-bound":""}:{},...c.placeholder?{"data-placeholder":""}:{},className:`docx-content-control-inspector${e?` ${e}`:""}`,style:CP,onMouseDown:f=>{Qd(f),f.stopPropagation();}},p=jsxs(Fragment,{children:[jsx("span",{id:l,className:"docx-editor-sr-only",children:s("contentControl.inspectorPanel.title")}),u]});return t?jsx(X,{...g,children:p}):jsx("div",{...g,children:p})}function Hg({className:e,asChild:t,hidden:o,children:n}){let{closeInspector:r}=bo(),{t:i}=F();if(o)return null;let a={style:PP,className:e??void 0,"data-testid":"content-control-inspector-header"},l=jsxs(Fragment,{children:[jsx("span",{children:n??i("contentControl.inspectorPanel.title")}),jsx("button",{type:"button","data-testid":"content-control-inspector-close","aria-label":i("common.close"),title:i("common.close"),style:{...Lg,padding:4,border:"none",background:"transparent"},onMouseDown:Qd,onClick:()=>r(),children:Fg(xP)})]});return t?jsx(X,{...a,children:l}):jsx("div",{...a,children:l})}function Ag({className:e,asChild:t,hidden:o,children:n}){let{control:r}=bo(),{t:i}=F();if(o||!r)return null;let a=i("contentControl.inspectorPanel.empty"),l=i("contentControl.inspectorPanel.yes"),s=i("contentControl.inspectorPanel.no"),c=n??jsxs(Fragment,{children:[jsx(Sr,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsx(Sr,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsx(Sr,{label:i("contentControl.inspectorPanel.type"),value:i(wP(r.controlType)),testId:"content-control-inspector-type"}),jsx(Sr,{label:i("contentControl.inspectorPanel.lock"),value:i(DP(r)),testId:"content-control-inspector-lock"}),jsx(Sr,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsx(Sr,{label:i("contentControl.inspectorPanel.bound"),value:r.bound?l:s,testId:"content-control-inspector-bound"}),r.bound?jsx("p",{"data-testid":"content-control-inspector-bound-note",style:{margin:0,color:"var(--doc-text-muted)",fontSize:12},children:i("contentControl.inspectorPanel.boundNote")}):null,r.locked?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?jsx(X,{...d,children:c}):jsx("div",{...d,children:c})}function Og({className:e,asChild:t,hidden:o,icon:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:s}=bo(),{t:c}=F();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:Lg,onMouseDown:Qd,onClick:()=>{l().ok&&s();}},u=jsxs(Fragment,{children:[n??r??Fg(vP),jsx("span",{children:d})]});return t?jsx(X,{...m,children:u}):jsx("button",{...m,children:u})}var Oa=Object.assign(RP,{Header:Hg,Fields:Ag,Remove:Og});var FP=e=>e;function ru(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Ba(){let e=L(),{t}=F(),[o,n]=useState(null),[r,i]=useState(null),a=useRef(null),l=useRef(null),s=useRef(null),c=useId(),d=useId(),m=useId(),u=o?.activation??null,g=K(FP),p=useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let y=e.surface.equations.can(u.equation.id,"replace"),C=e.surface.equations.can(u.equation.id,"remove"),T=y.ok?C.ok?null:C.reason:y.reason;return {replaceEnabled:y.ok,removeEnabled:C.ok,reason:T?localizeDisabledReason(T,t):null}},[u,e,g,t]),f=useCallback((y=false)=>{s.current?.(),s.current=null,n(null),y&&e&&queueMicrotask(()=>e.focus());},[e]);useEffect(()=>{if(!e)return;let y=e.setEquationChrome({onPopover:C=>{s.current?.();let T=e.surface;if(T&&typeof T.retainSelection=="function"){let x=T.retainSelection();s.current=()=>T.releaseSelection(x);}else s.current=null;n({activation:C,mountGeneration:e.mountGeneration,draft:C.equation.linear,error:false});}});return ()=>{y(),s.current?.(),s.current=null,n(null);}},[e,f]),useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&f();},[e,g,o,f]),useEffect(()=>{if(!o)return;let y=a.current,C=y?.ownerDocument,T=C?.defaultView;if(!y||!C||!T)return;let x=P=>{P.key==="Escape"&&(P.preventDefault(),f(true));},E=P=>{isDomNode(P.target)&&y.contains(P.target)||f();};return C.addEventListener("keydown",x),C.addEventListener("pointerdown",E,true),()=>{C.removeEventListener("keydown",x),C.removeEventListener("pointerdown",E,true);}},[o,f]),useLayoutEffect(()=>{if(!u){i(null);return}let y=a.current;if(!y)return;let C=y.offsetParent;if(!C){i(null);return}let T=u.rect,x=Er(C,T.left,T.bottom),E=Math.max(0,C.scrollWidth-y.offsetWidth);i({left:Math.max(0,Math.min(x.left,E)),top:x.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[u]);let h=useCallback(()=>{if(!o||!e?.surface||!p.replaceEnabled)return false;let y=e.surface.equations.applyEquation(o.activation.equation.id,o.draft);return y?f(true):n(C=>C&&{...C,error:true}),y},[e,o,f,p.replaceEnabled]),v=useCallback(()=>{if(!o||!e?.surface||!p.removeEnabled)return false;let y=e.surface.equations.removeEquation(o.activation.equation.id);return y?f(true):n(C=>C&&{...C,error:true}),y},[e,o,f,p.removeEnabled]);if(!o)return null;let b=[o.error?d:null,p.reason?m:null].filter(Boolean).join(" ");return jsxs("div",{ref:a,className:"docx-equation-popup","data-testid":"equation-popup",role:"dialog","aria-modal":false,"aria-label":t("equationPopup.title"),style:r??void 0,onMouseDown:ru,children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:t("equationPopup.inputLabel")}),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":b||void 0,onChange:y=>n(C=>C&&{...C,draft:y.target.value,error:false}),onKeyDown:y=>{y.key!=="Enter"||y.nativeEvent.isComposing||(y.preventDefault(),h());}}),o.error?jsx("div",{id:d,className:"docx-equation-popup__error","data-testid":"equation-popup-error",role:"alert",children:t("equationPopup.refused")}):null,p.reason?jsx("div",{id:m,className:"docx-equation-popup__error","data-testid":"equation-popup-disabled-reason",role:"status",children:p.reason}):null,jsxs("div",{className:"docx-equation-popup__actions",children:[jsx("button",{type:"button",className:"docx-equation-popup__apply","data-testid":"equation-popup-apply",disabled:!p.replaceEnabled,title:p.reason??void 0,onMouseDown:ru,onClick:h,children:t("equationPopup.apply")}),jsx("button",{type:"button",className:"docx-equation-popup__delete","data-testid":"equation-popup-delete",disabled:!p.removeEnabled,title:p.reason??void 0,onMouseDown:ru,onClick:v,children:t("equationPopup.delete")})]})]})}var Zg="review.comments",au="review.addComment";function Kg(e){return e!==Zg?e:(on(`The context-menu row "${Zg}" is now "${au}". The old id still works in this release; write "${au}".`),au)}function wr(e,t){if(!isValidElement(e)||e.type!==Fragment$1)return null;let n=Children.toArray(e.props.children).map(t).filter(r=>r!==null);return n.length===1?n[0]:null}function Nl({entries:e,children:t,preset:o,keyOfEntry:n,keyOfChild:r,renderEntry:i,childrenOfEntry:a,onUnmatched:l}){if(!o)return t;let s=new Map,c=[];for(let p of Children.toArray(t)){let f=r(p);f?s.set(f,p):c.push(p);}let d=new Set,m=p=>p.map((f,h)=>{let v=n(f,h);d.add(v);let b=a?.(f),y=b?m(b):void 0,C=s.get(v);return jsx(Fragment$1,{children:C??i(f,h,y)},v)}),u=m(e),g=[...s.entries()].filter(([p])=>!d.has(p)).map(([p,f])=>(l?.(p,f),jsx(Fragment$1,{children:f},p)));return jsxs(Fragment,{children:[u,g,c]})}var OP="review.addComment",BP=e=>e.editingMode==="viewing";function Fl(e){let{isEnabled:t,disabledReason:o}=se(OP),n=K(BP);return t?{isEnabled:t,reason:null}:{isEnabled:t,reason:n?e("editingMode.viewingHint"):o}}var Wa=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}),Dr="docx-menubar-more",Ll=createContext({measuring:false,overflow:new Set,inMore:false});function $g(){return useContext(Ll)}function it(){return useContext(Wa)}function Re(){let{t:e}=it(),{t}=F();return o=>e?.(o)??t(o)}var Rr=createContext(-1);var WP='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Wn(e){return [...e.querySelectorAll(WP)].filter(t=>t.closest('[role="menu"]')===e)}function su(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function Yt(e,t,o){if(e.length===0)return false;let n=t?e.indexOf(t):-1,r=n===-1?o>0?0:e.length-1:(n+o+e.length)%e.length;return e[r]?.focus(),true}function Xt(e,t){let o=t==="first"?e[0]:e[e.length-1];return o?(o.focus(),true):false}function cu(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 Vg(e,t,o){return !o||o.ownerDocument===t?false:o.contains(e)}var ln="data-toolbar-group",Zn="data-toolbar-fixed",Ka="data-toolbar-more",QP=34,Hl=new Set;function Al(e,t,o){let n=useRef(null),r=useRef(new Map),i=useRef(QP),[a,l]=useState(Hl),s=useRef(a);s.current=a;let c=useRef({groups:t,order:o});c.current={groups:t,order:o};let d=t.join("\0"),m=o.join("\0"),u=useCallback(()=>{let p=n.current;if(!p||!e)return;let f=hostWindowOf(p),h=f.getComputedStyle(p),v=readColumnGap(h),b=readAvailableWidth(p,h),y=p.querySelector(".docx-toolbar__separator"),C=v*2;if(y){let w=f.getComputedStyle(y),D=readInlineMargins(w);C=separatorLeadingCost(y.offsetWidth,D.start,D.end,v);}for(let w of p.querySelectorAll(`[${ln}]`)){let D=w.getAttribute(ln);D&&w.offsetWidth>0&&r.current.set(D,collapsibleGroupCost(w.offsetWidth,C));}let T=0;for(let w of p.querySelectorAll(`[${Zn}]`))w.offsetWidth>0&&(T+=trailingGapCost(w.offsetWidth,v));let x=p.querySelector(`[${Ka}]`);x&&x.offsetWidth>0&&(i.current=trailingGapCost(x.offsetWidth,v));let E={available:b,widths:r.current,groups:c.current.groups,order:c.current.order,fixed:T,more:i.current,previous:s.current,hysteresis:TOOLBAR_OVERFLOW_HYSTERESIS},k=s.current.size===0&&controlsOverflow(p,h)===false?Hl:toolbarOverflowGroups(E);sameOverflow(k,s.current)||(s.current=k,l(k));},[e]),g=useCallback(p=>{n.current=p;},[]);return useLayoutEffect(()=>{if(!e){s.current.size>0&&(s.current=Hl,l(Hl));return}u();},[e,d,u,m]),useEffect(()=>{let p=n.current,f=p?hostWindowOf(p):null;if(!e||!p||!f||typeof f.ResizeObserver>"u")return;let h=0,v=new f.ResizeObserver(()=>{h===0&&(h=f.requestAnimationFrame(()=>{h=0,u();}));});v.observe(p),p.parentElement&&v.observe(p.parentElement);for(let b of p.querySelectorAll(`[${ln}], [${Zn}]`))v.observe(b);return ()=>{h!==0&&f.cancelAnimationFrame(h),v.disconnect();}},[e,d,u,m,a]),{attach:g,overflow:a}}function Xg(e,t,o){let n=e.overflow.has(t),r=t===Dr;return {skip:e.inMore?!n:n,asSubmenu:e.inMore&&n,iconOnly:r,rootAttributes:{...e.measuring&&!r?{[ln]:t}:{},...r?{[Ka]:""}:{}},tabStop:o===t||r&&o!==null&&e.overflow.has(o)}}function Jg(e,t,o){let[n,r]=useState(void 0);return useLayoutEffect(()=>{if(!e){r(void 0);return}let i=()=>{let l=t.current,s=o.current,c=l?.parentElement,d=l?.ownerDocument.defaultView;if(!l||!s||!c||!d)return;let m=l.getBoundingClientRect(),u=toolbarPanelPlacement({triggerLeft:m.left,triggerRight:m.right,panelWidth:s.offsetWidth,viewportWidth:d.innerWidth});r({left:u.left-c.getBoundingClientRect().left,right:"auto",maxInlineSize:u.maxWidth});};i();let a=t.current?.ownerDocument.defaultView;return a?.addEventListener("resize",i),()=>a?.removeEventListener("resize",i)},[e,o,t]),n}var eb=12700,Qg=96;function ik(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function lk(e,t,o,n){let r=e*72/o,i=t*72/n;return {widthPoints:Math.max(1,Math.round(r*100)/100),heightPoints:Math.max(1,Math.round(i*100)/100)}}function Ol(e){let t=DEFAULT_IMAGE_RESOURCE_LIMITS$1;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=sniffImageMime(e);if(!ik(o))return o==="image/svg+xml"||o==="image/tiff"?{ok:false,reasonKey:"imageInsert.errors.unsupportedFormat"}:{ok:false,reasonKey:"imageInsert.errors.invalidSignature"};let n=validateRasterHeader(e,o);if(!n)return {ok:false,reasonKey:"imageInsert.errors.invalidSignature"};if(n.pixelWidth*n.pixelHeight>t.maxPixels||n.pixelWidth>t.maxDimension||n.pixelHeight>t.maxDimension)return {ok:false,reasonKey:"imageInsert.errors.oversize"};let{widthPoints:i,heightPoints:a}=lk(n.pixelWidth,n.pixelHeight,n.dpiX??Qg,n.dpiY??Qg);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function sn(e){return Math.round(e/eb*100)/100}function qa(e){return Math.round(e*eb)}function du({message:e,onClose:t,className:o,style:n,children:r}){let{t:i}=F();return jsx(Be,{kind:"imageInsertError",role:"alertdialog",label:i("imageInsert.errors.title"),className:o,style:n,onClose:t,onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing&&(a.preventDefault(),t());},children:r??jsxs(Fragment,{children:[jsx("header",{className:"docx-dialog__header",children:jsx("h2",{className:"docx-dialog__title",children:i("imageInsert.errors.title")})}),jsx("div",{className:"docx-dialog__body","data-docx-part":"message",children:e}),jsx("footer",{className:"docx-dialog__footer",children:jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:t,children:i("common.close")})})]})})}var ob="image/png,image/jpeg,image/gif",pu=createContext(null);function rb(){let e=useContext(pu);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function Ua(){return useContext(pu)}function Wl({children:e}){let t=L(),{t:o}=F(),n=useRef(null),r=useRef(false),i=St(),[a,l]=useState(null),s=useRef(null),c=useCallback(()=>toolbarCommandState(t,"image.insert"),[t]),d=K(c,(y,C)=>y.enabled===C.enabled&&y.disabledReason===C.disabledReason),m=d.enabled,u=localizeDisabledReason(d.disabledReason,o),g=useCallback(async y=>{if(!t||r.current)return;let C=Ol(y);if(!C.ok){l(o(C.reasonKey));return}let T={type:"insertImage",data:C.bytes,mime:C.mime,widthPoints:C.widthPoints,heightPoints:C.heightPoints};r.current=true;try{let x=await executeImageCommand(t,T);x.ok?t.focus():l(localizeDisabledReason(bk(x.reason)??null,o)??o("imageInsert.errors.refused"));}finally{r.current=false;}},[t,o]),p=useCallback(async y=>{let C=y?.[0];if(!C)return;let T=await C.arrayBuffer();await g(new Uint8Array(T));},[g]),f=useCallback(async y=>{if(!y)return;let C=[...y.files].find(T=>T.type.startsWith("image/"));if(C){await p([C]);return}for(let T of y.items){if(T.kind!=="file"||!T.type.startsWith("image/"))continue;let x=T.getAsFile();if(!x)continue;let E=await x.arrayBuffer();await g(new Uint8Array(E));return}},[g,p]),h=useCallback(()=>{if(!m)return;let y=n.current,C=t?editorHostDocument(t):null;if(!C||!y||y.ownerDocument===C){y?.click();return}s.current?.remove();let T=C.createElement("input");T.type="file",T.accept=ob,T.hidden=true,T.tabIndex=-1,T.setAttribute("aria-hidden","true");let x=()=>{T.remove(),s.current===T&&(s.current=null);};T.addEventListener("change",()=>{p(T.files).finally(x);},{once:true}),T.addEventListener("cancel",x,{once:true}),C.body.append(T),s.current=T,T.click();},[t,m,p]),v=useCallback(async y=>{let C=y.currentTarget;await p(C.files),C.value="";},[p]),b=useMemo(()=>({openFilePicker:h,insertFromFileList:p,insertFromDataTransfer:f,isEnabled:m,disabledReason:u,inputRef:n,onInputChange:v}),[h,p,f,m,u,v]);return jsxs(pu.Provider,{value:b,children:[jsx("input",{ref:n,type:"file",accept:ob,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:v,onMouseDown:y=>y.stopPropagation()}),e,a!==null&&(i?.imageInsertError!==void 0?Ee(i.imageInsertError,{message:a,onClose:()=>l(null)}):jsx(du,{message:a,onClose:()=>l(null)}))]})}function Zl({className:e,hidden:t,asChild:o,children:n}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=rb(),l=ne();if(t)return null;let s=te("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:r};return o?jsx(X,{...d,children:n}):jsx("button",{...d,children:n??re(s?.paths)})}Zl.docxSlot="image.insert";var za=Object.assign(Zl,{docxSlot:"image.insert"});function bk(e){return e&&/\s/.test(e)?e:void 0}var mu=6,lb=6;function ql({slot:e,label:t,onInserted:o,className:n}){let r=L(),{isEnabled:i}=se(e),[a,l]=useState(null),[s,c]=useState({rows:1,cols:1}),d=useRef(null),m=useCallback((p,f)=>{if(!r||!i)return;let h={type:"insertTable",rows:p,cols:f};r.can(h).ok&&(r.exec(h),o(),r.focus());},[r,i,o]),u=useCallback(p=>{c(f=>{let h={rows:Math.min(lb,Math.max(1,f.rows+(p.rows??0))),cols:Math.min(mu,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<=lb;p+=1){let f=[];for(let h=1;h<=mu;h+=1){let v=!!a&&p<=a.rows&&h<=a.cols;f.push(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,...v?{"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(jsx("div",{role:"row",className:"docx-menubar__grid-row",children:f},p));}return jsxs("div",{ref:d,role:"grid","aria-label":t,className:`docx-menubar__grid${n?` ${n}`:""}`,onMouseLeave:()=>l(null),onKeyDown:p=>{if(p.key==="ArrowRight")u({cols:1});else if(p.key==="ArrowLeft")u({cols:-1});else if(p.key==="ArrowDown")u({rows:1});else if(p.key==="ArrowUp")u({rows:-1});else if(p.key==="Home")u({toCol:1});else if(p.key==="End")u({toCol:mu});else return;p.preventDefault(),p.stopPropagation();},children:[jsx("div",{className:"docx-menubar__grid-cells",children:g}),jsx("div",{className:"docx-menubar__grid-caption","aria-hidden":"true",children:a?`${a.cols} \xD7 ${a.rows}`:""})]})}function Ir({slot:e="table.insert",className:t}){let{setOpenMenu:o}=it(),n=Re(),r=useCallback(()=>o(null),[o]);return jsx(ql,{slot:e,label:n("toolbar.insertTable"),onInserted:r,className:t})}function Ek({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=se(chromeProbeForSlot("insert.watermark")),r=it(),i=Re();if(t)return null;let a=te("insert.watermark"),l=i(a?.labelKey??"toolbar.watermark"),s=o&&!!r.onWatermarkDialog;return jsx(Me,{slot:"insert.watermark",icon:re(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onWatermarkDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var Ul=Object.assign(Ek,{docxSlot:"insert.watermark"});var kk={type:"openGoTo",fromShortcut:true};function sb(){let e=se(kk),t=isApplePlatform()?"toolbar.goToBookmarkShortcutApple":"toolbar.goToBookmarkShortcut";return jsx(Kt,{slotId:"insert.goToBookmark",...e.isEnabled?{shortcutKey:t}:{}})}function wk({className:e,hidden:t}){return jsx(Kt,{slotId:"insert.bookmark",shortcutKey:"toolbar.bookmarkShortcut",...e?{className:e}:{},...t?{hidden:t}:{}})}var zl=Object.assign(wk,{docxSlot:"insert.bookmark"});function Me(e){let{icon:t,shortcut:o,disabled:n,title:r,active:i,selected:a,slot:l,onSelect:s,className:c,children:d}=e,m=e["data-value"],u=Ho(),g=useId(),p=useContext(Rr),f=n&&r?g:void 0;return jsxs("button",{type:"button",role:i===void 0?"menuitem":a===void 0?"menuitemcheckbox":"menuitemradio",className:`docx-toolbar__menu-item docx-menubar__item${c?` ${c}`:""}`,tabIndex:p,...l?{"data-slot":l}:{},...m!==void 0?{"data-value":m}:{},...i?{"data-active":""}:{},...n?{"data-disabled":"","aria-disabled":true}:{},...i!==void 0?{"aria-checked":i}:{},...f?{"aria-describedby":f}:{},...r?{title:r}:{},onMouseDown:U,onClick:n?void 0:s,children:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:t}),jsx("span",{className:"docx-menubar__item-label",children:d}),o?jsx("span",{className:"docx-menubar__item-shortcut",children:u(o)}):null,f?jsx("span",{id:g,className:"docx-editor-sr-only",children:r}):null]})}function $a({label:e,labelKey:t,className:o,hidden:n,children:r}){let i=Re();if(n)return null;let a=e??(t===void 0?void 0:i(t));return jsxs("div",{role:"group",className:`docx-menubar__group${o?` ${o}`:""}`,...a?{"aria-label":a}:{},children:[a?jsx("div",{className:"docx-menubar__group-label","aria-hidden":"true",children:a}):null,r]})}function Vl(e){if(e.slotId)return e.slotId;if(e.slot)return mg(e.slot),e.slot;gg();}function Kt(e){let{labelKey:t,shortcutKey:o,className:n,hidden:r}=e,i=Vl(e)??"",{execute:a,isActive:l,isEnabled:s,disabledReason:c,value:d}=se(i),{setOpenMenu:m}=it(),u=Re();if(r||!i)return null;let g=te(i),p=u(t??g?.labelKey??i),f=chromeSlotIsToggle(i),h=["setAlignment","setParagraphDirection","setReviewDisplayMode"].includes(commandForSlot(i)?.type??"");return jsx(Me,{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);},...n?{className:n}:{},children:p})}Kt.docxMenuRow=true;function Va(e,t,o,n,r=()=>true){return Object.assign(({className:a,hidden:l})=>{let s=it(),c=Re(),d=n(s),m=o&&r(s)?o:void 0;if(l)return null;let u=te(e),g=c(t??u?.labelKey??e);return jsx(Me,{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 gu=Va("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),bu=Va("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave),hu=Va("file.exportMarkdown",void 0,void 0,e=>e.onExport?()=>e.onExport?.("markdown"):void 0),yu=Va("file.exportPdf",void 0,void 0,e=>e.onExport?()=>e.onExport?.("pdf"):void 0),xu=Va("file.print",void 0,"toolbar.printShortcut",e=>e.onPrint,e=>e.printShortcut===true);function Ak({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=se(chromeProbeForSlot("file.pageSetup")),r=it(),i=Re();if(t)return null;let a=te("file.pageSetup"),l=i(a?.labelKey??"file.pageSetup"),s=o&&!!r.onPageSetup;return jsx(Me,{slot:"file.pageSetup",icon:re(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onPageSetup?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}function Ok({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=se(chromeProbeForSlot("paragraph.dialog")),r=it(),i=Re();if(t)return null;let a=te("paragraph.dialog"),l=i(a?.labelKey??"lineSpacing.options"),s=o&&!!r.onParagraphDialog;return jsx(Me,{slot:"paragraph.dialog",icon:re(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onParagraphDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var Bk=Object.assign(Ok,{docxSlot:"paragraph.dialog"}),vu=Object.assign(Ak,{docxSlot:"file.pageSetup"});function Wk({className:e,hidden:t}){let o=Ua(),n=it(),r=Re();if(t)return null;let i=te("image.insert"),a=r(i?.labelKey??"toolbar.image"),l=o?.isEnabled??false,s=o?.disabledReason??null;return jsx(Me,{slot:"image.insert",icon:re(i?.paths),disabled:!l,...s?{title:s}:{},onSelect:()=>{o?.openFilePicker(),n.setOpenMenu(null);},...e?{className:e}:{},children:a})}var Cu=Object.assign(Wk,{docxSlot:"image.insert"});function Jt({labelKey:e,label:t,paths:o,className:n,children:r}){let i=Re(),[a,l]=useState(false),s=useRef(null),c=useRef(null),d=useId();t===void 0&&e===void 0&&bg();let m=t??i(e??""),[u,g]=useState(null);return useLayoutEffect(()=>{if(!a){g(null);return}let p=s.current,f=c.current,h=p?.ownerDocument.defaultView;!p||!f||!h||g(placeSubmenu(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:h.innerWidth,height:h.innerHeight},h.getComputedStyle(p).direction==="rtl"));},[a]),jsxs("div",{role:"none",className:`docx-menubar__submenu${n?` ${n}`:""}`,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),onKeyDown:p=>{let f=submenuKeys(hostWindowOf(p.currentTarget).getComputedStyle(p.currentTarget).direction==="rtl");p.key===f.open&&hostDocumentOf(s.current).activeElement===s.current?(p.preventDefault(),l(true),queueMicrotask(()=>{c.current&&Xt(Wn(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:[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:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:re(o)}),jsx("span",{className:"docx-menubar__item-label",children:m}),jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),a?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=Wn(f);p.key==="ArrowDown"?(p.preventDefault(),p.stopPropagation(),Yt(h,hostDocumentOf(f).activeElement,1)):p.key==="ArrowUp"&&(p.preventDefault(),p.stopPropagation(),Yt(h,hostDocumentOf(f).activeElement,-1));},children:jsx(Rr.Provider,{value:-1,children:r})}):null]})}function Zk({entry:e}){let{isEnabled:t}=se(e.slot),o=te(e.slot);return t?jsx(Jt,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsx(Ir,{slot:e.slot})}):jsx(Kt,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Kn({className:e}){return jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function Ga({entry:e,children:t}){return e.kind==="separator"?jsx(Kn,{}):e.kind==="submenu"?jsx(Jt,{labelKey:e.labelKey,paths:e.paths,children:t??e.items.map((o,n)=>jsx(Ga,{entry:o},n))}):e.slot==="file.open"?jsx(gu,{}):e.slot==="file.save"?jsx(bu,{}):e.slot==="file.exportMarkdown"?jsx(hu,{}):e.slot==="file.exportPdf"?jsx(yu,{}):e.slot==="file.print"?jsx(xu,{}):e.slot==="file.pageSetup"?jsx(vu,{}):e.slot==="paragraph.dialog"?jsx(Bk,{}):e.slot==="insert.watermark"?jsx(Ul,{}):e.slot==="insert.bookmark"?jsx(zl,{}):e.slot==="insert.goToBookmark"?jsx(sb,{}):e.slot==="image.insert"?jsx(Cu,{}):e.picker==="tableGrid"?jsx(Zk,{entry:e}):jsx(Kt,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function mb(e){if(!isValidElement(e))return null;let t=wr(e,mb);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?Vl(e.props)??null:null}function Kk(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function ub(e,t,o){return Nl({entries:e??[],children:t,preset:o,keyOfEntry:Kk,keyOfChild:mb,childrenOfEntry:n=>n.kind==="submenu"?n.items:void 0,renderEntry:(n,r,i)=>jsx(Ga,{entry:n,children:i})})}function Qt({id:e,labelKey:t,label:o,icon:n,className:r,hidden:i,preset:a=true,children:l}){let{openMenu:s,setOpenMenu:c,activeMenu:d,opening:m}=it(),u=$g(),g=Re(),p=useId(),f=useRef(null),h=useRef(null),v=useRef(false),b=useRef(false),y=CHROME_MENUS.find(D=>D.id===e),C=s===e,T=Jg(C&&e===Dr,f,h);if(i)return null;let x=o??g(t??y?.labelKey??e),E=Xg(u,e,d);if(E.skip)return null;if(E.asSubmenu)return jsx(Jt,{labelKey:t??y?.labelKey??e,label:x,children:ub(y?.entries,l,a)});let P=ub(y?.entries,l,a),k=E.iconOnly,w=()=>{c(null),f.current?.focus();};return jsxs("div",{role:"none",className:`docx-menubar__menu-root${r?` ${r}`:""}`,"data-menu":e,...E.rootAttributes,children:[jsxs("button",{ref:f,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":C,"aria-controls":C?p:void 0,className:"docx-menubar__trigger",disabled:m===true,tabIndex:E.tabStop?0:-1,...C?{"data-open":""}:{},...k?{"aria-label":x,title:x}:{},onMouseDown:U,onKeyDown:D=>{D.key==="ArrowDown"||D.key==="Enter"||D.key===" "||D.key==="ArrowUp"?(D.preventDefault(),v.current=true,c(e)):D.key==="Escape"&&C&&(D.preventDefault(),w());},onClick:()=>{if(b.current){b.current=false;return}c(C?null:e);},onMouseEnter:()=>{s!==null&&s!==e&&(b.current=true,c(e));},onMouseLeave:()=>{b.current=false;},children:[n?jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:n}):null,k?null:x]}),C?jsx("div",{ref:D=>{h.current=D,D&&v.current&&(v.current=false,Xt(Wn(D),"first"));},id:p,role:"menu","aria-label":x,style:T,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:D=>{let M=h.current;if(!M)return;let H=Wn(M),I=hostDocumentOf(M).activeElement;D.key==="ArrowDown"?(D.preventDefault(),Yt(H,I,1)):D.key==="ArrowUp"?(D.preventDefault(),Yt(H,I,-1)):D.key==="Home"?(D.preventDefault(),Xt(H,"first")):D.key==="End"?(D.preventDefault(),Xt(H,"last")):D.key==="Escape"?(D.preventDefault(),D.stopPropagation(),w()):D.key==="Tab"&&c(null);},children:jsx(Rr.Provider,{value:-1,children:P})}):null]})}function Tu(e){return Object.assign(o=>jsx(Qt,{id:e,...o}),{docxMenu:e})}var Eu=Tu("file"),Su=Tu("format"),Pu=Tu("insert");var Gl=createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function Bo(){return useContext(Gl)}function gb(){return useContext(Gl).target}var zk=e=>e.pageSetup??null,$k=e=>e.editable;function qn(){let e=L(),t=K(zk),o=K($k),n=useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),r=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 useMemo(()=>({pageSetup:t,isEnabled:n,apply:r}),[t,n,r])}var wu=[{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}],vb=1440,jk=e=>Math.round(e/vb*100)/100,Yk=e=>Math.round(e*vb);function Xk(e,t){let o=Math.min(e,t),n=Math.max(e,t);return wu.findIndex(r=>Math.abs(r.width-o)<20&&Math.abs(r.height-n)<20)}var yb=12240,xb=15840,cn=1440;function Jk({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=F(),l=po(e,t),{pageSetup:s,isEnabled:c,apply:d}=qn(),[m,u]=useState(yb),[g,p]=useState(xb),[f,h]=useState("portrait"),[v,b]=useState(cn),[y,C]=useState(cn),[T,x]=useState(cn),[E,P]=useState(cn),[k,w]=useState(false),[D,M]=useState("document"),H=useRef(null),I=useRef("no");useEffect(()=>{if(!e){I.current="no";return}if(I.current==="yes"&&s===null){I.current="no";return}I.current==="yes"||I.current==="loading"&&s===null||(w(false),u(s?.pageWidthTwips??yb),p(s?.pageHeightTwips??xb),h(s?.orientation??"portrait"),b(s?.marginsTwips.top??cn),C(s?.marginsTwips.bottom??cn),x(s?.marginsTwips.left??cn),P(s?.marginsTwips.right??cn),M("document"),I.current=s===null?"loading":"yes");},[e,s]);let A=useCallback($=>{let V=wu[$];V&&(u(f==="landscape"?V.height:V.width),p(f==="landscape"?V.width:V.height));},[f]),S=useCallback($=>{$!==f&&(h($),u(g),p(m));},[f,m,g]),_=useCallback(()=>{if(!c)return;if(!l()){t();return}let $=d({pageWidthTwips:m,pageHeightTwips:g,orientation:f,marginTopTwips:v,marginRightTwips:E,marginBottomTwips:y,marginLeftTwips:T,scope:D});w(!$),$&&t();},[c,l,d,m,g,f,v,E,y,T,D,t]);if(!e)return null;let B=Xk(m,g),Z=($,V,ce)=>jsxs("div",{"data-docx-part":"field","data-docx-field":`margin${$[0].toUpperCase()}${$.slice(1)}`,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",children:a(`dialogs.pageSetup.${$}`)}),jsx("input",{type:"number",className:"docx-dialog__input",min:0,max:22,step:.1,value:jk(V),onChange:O=>ce(Math.max(0,Yk(Number(O.target.value)||0))),"aria-label":a(`dialogs.pageSetup.${$}`)}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),ee={pageWidth:m,pageHeight:g,orientation:f,marginTop:v,marginBottom:y,marginLeft:T,marginRight:E,scope:D},j={pageWidth:u,pageHeight:p,orientation:S,marginTop:b,marginBottom:C,marginLeft:x,marginRight:P,scope:M},oe={values:ee,setValue($,V){j[$](V);},errors:k?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:_,cancel:t};return jsx(Be,{kind:"pageSetup",className:o,style:n,panelRef:H,label:a("dialogs.pageSetup.title"),onClose:t,onKeyDown:$=>{$.key==="Escape"&&t(),$.key==="Enter"&&isHTMLElementNode($.target)&&$.target.localName==="input"&&c&&($.preventDefault(),_());},children:jsx(yo.Composition,{state:oe,preset:i,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.pageSetup.title")})}),jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.pageSetup.pageSize")}),jsxs("div",{"data-docx-part":"field","data-docx-field":"pageSize",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.sizeLabel")}),jsxs("select",{className:"docx-dialog__input",value:B,onChange:$=>A(Number($.target.value)),"aria-label":a("dialogs.pageSetup.sizeLabel"),children:[wu.map(($,V)=>jsx("option",{value:V,children:a($.labelKey)},$.labelKey)),B<0&&jsx("option",{value:-1,children:a("dialogs.pageSetup.custom")})]})]}),jsxs("div",{"data-docx-part":"field","data-docx-field":"orientation",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.orientation")}),jsxs("select",{className:"docx-dialog__input",value:f,onChange:$=>S($.target.value),"aria-label":a("dialogs.pageSetup.orientation"),children:[jsx("option",{value:"portrait",children:a("dialogs.pageSetup.portrait")}),jsx("option",{value:"landscape",children:a("dialogs.pageSetup.landscape")})]})]}),jsx("div",{className:"docx-dialog__section-label docx-dialog__section-label--spaced",children:a("dialogs.pageSetup.margins")}),Z("top",v,b),Z("bottom",y,C),Z("left",T,x),Z("right",E,P),jsxs("div",{"data-docx-part":"field","data-docx-field":"scope",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.applyTo")}),jsxs("select",{className:"docx-dialog__input",value:D,onChange:$=>M($.target.value),"aria-label":a("dialogs.pageSetup.applyTo"),children:[jsx("option",{value:"document",children:a("dialogs.pageSetup.applyToDocument")}),jsx("option",{value:"section",children:a("dialogs.pageSetup.applyToSection")})]})]})]}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("span",{"data-docx-part":"error",role:"alert",className:"docx-dialog__error",children:k?a("dialogs.paragraph.refused"):null}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!c,"data-docx-part":"apply",onClick:_,children:a("common.apply")})]})]}),children:r})})}var yo=Tt();function Qk(){return yo.useState()}var Un=Object.assign(Jk,{Header:yo.Header,Title:yo.Title,Body:yo.Body,Footer:yo.Footer,Apply:yo.Apply,Cancel:yo.Cancel,Error:yo.Error,Field:yo.Field});var nw={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},rw=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,n=t.paragraphFlags??nw;return {alignment:t.alignment==="both"?"justify":t.alignment??null,direction:t.direction??null,spaceBeforePt:t.spaceBeforePt??null,spaceAfterPt:t.spaceAfterPt??null,lineSpacing:t.lineSpacing??null,indentLeftTwips:o&&!o.mixed.left?o.left:null,indentRightTwips:o&&!o.mixed.right?o.right:null,indentFirstLineTwips:o&&!o.mixed.firstLine?o.firstLine:null,contextualSpacing:n.contextualSpacing,keepNext:n.keepNext,keepLines:n.keepLines,widowControl:n.widowControl,pageBreakBefore:n.pageBreakBefore,tabStops:t.tabStops??null,indentUnknown:!o,disagrees:{alignment:t.disagrees?.alignment??false,direction:t.disagrees?.direction??false,spaceBeforePt:t.disagrees?.spaceBeforePt??false,spaceAfterPt:t.disagrees?.spaceAfterPt??false,lineSpacing:t.disagrees?.lineSpacing??false,tabStops:t.disagrees?.tabStops??false,indentLeft:o?.mixed.left??false,indentRight:o?.mixed.right??false,indentFirstLine:o?.mixed.firstLine??false}}},aw=["alignment","direction","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],iw=(e,t)=>aw.every(o=>e.disagrees[o]===t.disagrees[o]),lw=(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&&iw(e,t)&&e.indentUnknown===t.indentUnknown&&e.tabStops?.length===t.tabStops?.length&&(e.tabStops??[]).every((o,n)=>o.positionTwips===t.tabStops?.[n]?.positionTwips&&o.alignment===t.tabStops?.[n]?.alignment&&(o.leader??"none")===(t.tabStops?.[n]?.leader??"none")),sw=e=>e.editable;function Du(){let e=L(),t=K(rw,lw),o=K(sw),n=useMemo(()=>o&&e!==null&&e.can({type:"setParagraphFormat",alignment:"left"}).ok,[e,o]),r=useCallback(i=>{if(!e)return false;let a={type:"setParagraphFormat",...i};return e.can(a).ok?e.exec(a).ok:false},[e]);return {format:t,isEnabled:n,apply:r}}function uw({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=F(),l=po(e,t),{format:s,isEnabled:c,apply:d}=Du(),[m,u]=useState("left"),[g,p]=useState("ltr"),[f,h]=useState(0),[v,b]=useState(0),[y,C]=useState("none"),[T,x]=useState(0),[E,P]=useState(0),[k,w]=useState(0),[D,M]=useState("multiple"),[H,I]=useState(1.08),[A,S]=useState(false),[_,B]=useState(false),[Z,ee]=useState(false),[j,oe]=useState(true),[$,V]=useState(false),[ce,O]=useState([]),[N,W]=useState(false),[J,de]=useState(0),[he,Oe]=useState("left"),[we,Ke]=useState("none"),[Te,Io]=useState(NO_MIXED_FIELDS),[co,_t]=useState(false),Xo=z=>a(co&&(z==="indentLeft"||z==="indentRight"||z==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),Mn=useRef(NO_MIXED_FIELDS),ae=useId(),[rt,Ie]=useState(false),uo=useRef(null),Jo=useRef(false),It=useRef(null);useEffect(()=>{if(!e){Jo.current=false;return}if(Jo.current||s===null)return;let z=seedFields(s);u(z.alignment),p(z.direction),h(z.indentLeft),b(z.indentRight),C(z.special),x(z.specialBy),P(z.spaceBefore),w(z.spaceAfter),M(z.lineRule),I(z.lineValue),S(z.contextualSpacing),B(z.keepNext),ee(z.keepLines),oe(z.widowControl),V(z.pageBreakBefore),O(z.tabStops),W(false);let ve=mixedFieldsOf(s);Io(ve),_t(s.indentUnknown),de(0),Oe("left"),Ke("none"),Mn.current=ve,Ie(false),It.current=z,Jo.current=true;},[e,s]);let No=useCallback(()=>{if(!c)return;if(!l()){t();return}let z=It.current,ve=z===null?null:changedFields(z,{alignment:m,direction:g,indentLeft:f,indentRight:v,special:y,specialBy:T,spaceBefore:E,spaceAfter:k,lineRule:D,lineValue:H,contextualSpacing:A,keepNext:_,keepLines:Z,widowControl:j,pageBreakBefore:$,tabStops:ce,clearedAllTabStops:N},Mn.current,Te);if(ve===null){t();return}if(d(ve)){Ie(false),t();return}Ie(true);},[c,l,d,t,Te,N,m,g,f,v,y,T,E,k,D,H,A,_,Z,j,$,ce]),br=useCallback(()=>{let z=Math.round(J);return z<=0?false:(Io(ve=>({...ve,tabStops:false})),O(withTabStop(ce,{positionTwips:z,alignment:he,...we!=="none"?{leader:we}:{}})),de(0),Oe("left"),Ke("none"),true)},[ce,J,he,we]);if(!e)return null;let ie=z=>Io(ve=>({...ve,[z]:false})),ge=(z,ve,en,ft)=>jsxs("div",{"data-docx-part":"field","data-docx-field":ft,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsx("input",{id:`${ae}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Te[ft]?"":twipsToInches(ve),placeholder:Te[ft]?Xo(ft):void 0,onChange:wa=>{ie(ft),en(inchesToTwips(Number(wa.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),qe=(z,ve,en,ft)=>jsxs("div",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsx("input",{id:`${ae}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:Te[ft]?"":ve,placeholder:Te[ft]?Xo(ft):void 0,onChange:wa=>{ie(ft),en(Math.max(0,Number(wa.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),xe=(z,ve,en)=>jsxs("label",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:ve,ref:ft=>{ft&&(ft.indeterminate=Te[z]);},onChange:ft=>{Io(wa=>({...wa,[z]:false})),en(ft.target.checked);}}),a(`dialogs.paragraph.${z}`)]}),Ct={alignment:m,direction:g,indentLeft:f,indentRight:v,special:y,specialBy:T,spaceBefore:E,spaceAfter:k,lineRule:D,lineValue:H,contextualSpacing:A,keepNext:_,keepLines:Z,widowControl:j,pageBreakBefore:$,tabStops:ce,clearedAllTabStops:N},Fo=z=>{let ve=Mn.current;z!==g&&!ve.direction&&!ve.alignment&&u(alignmentAfterDirectionChange),p(z);},Qo={alignment:u,direction:Fo,indentLeft:h,indentRight:b,special:C,specialBy:x,spaceBefore:P,spaceAfter:w,lineRule:M,lineValue:I,contextualSpacing:S,keepNext:B,keepLines:ee,widowControl:oe,pageBreakBefore:V,tabStops:O,clearedAllTabStops:W},_n={values:Ct,mixed:Te,setValue(z,ve){Qo[z](ve),z==="lineRule"?(ie("lineSpacing"),I(ve===It.current?.lineRule?It.current.lineValue:ve==="multiple"?1.08:12)):z==="specialBy"?ie("special"):z in Te&&ie(z);},errors:rt?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:No,cancel:t};return jsx(Be,{kind:"paragraph",className:o,style:n,panelRef:uo,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:z=>{z.key==="Escape"&&t();let ve=isHTMLElementNode(z.target)&&(z.target.localName==="button"||z.target.localName==="select");if(z.key==="Enter"&&!ve){let en=z.target;if(isHTMLElementNode(en)&&en.dataset.docxTabEntry!==void 0){br();return}c&&No();}},children:jsx(xo.Composition,{state:_n,preset:i,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.paragraph.title")})}),jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxs("div",{className:"docx-dialog__columns",children:[jsxs("div",{className:"docx-dialog__column",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.general")}),jsxs("div",{"data-docx-part":"field","data-docx-field":"alignment",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxs("select",{id:`${ae}-alignment`,className:"docx-dialog__input",value:Te.alignment?"":m,onChange:z=>{ie("alignment"),u(z.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[Te.alignment?jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsx("option",{value:"left",children:a("dialogs.paragraph.alignLeft")}),jsx("option",{value:"center",children:a("dialogs.paragraph.alignCenter")}),jsx("option",{value:"right",children:a("dialogs.paragraph.alignRight")}),jsx("option",{value:"justify",children:a("dialogs.paragraph.alignJustify")})]})]}),jsxs("div",{"data-docx-part":"field","data-docx-field":"direction",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-direction`,children:a("dialogs.paragraph.direction")}),jsxs("select",{id:`${ae}-direction`,className:"docx-dialog__input",value:Te.direction?"":g,onChange:z=>{ie("direction"),Fo(z.target.value);},"aria-label":a("dialogs.paragraph.direction"),children:[Te.direction?jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsx("option",{value:"rtl",children:a("dialogs.paragraph.directionRtl")}),jsx("option",{value:"ltr",children:a("dialogs.paragraph.directionLtr")})]})]}),jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.indentation")}),ge("beforeText",f,h,"indentLeft"),ge("afterText",v,b,"indentRight"),jsxs("div",{"data-docx-part":"field","data-docx-field":"special",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-special`,children:a("dialogs.paragraph.special")}),jsxs("select",{id:`${ae}-special`,className:"docx-dialog__input",value:Te.special?"":y,onChange:z=>{ie("special"),C(z.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[Te.special?jsx("option",{value:"",children:Xo("special")}):null,jsx("option",{value:"none",children:a("dialogs.paragraph.specialNone")}),jsx("option",{value:"firstLine",children:a("dialogs.paragraph.specialFirstLine")}),jsx("option",{value:"hanging",children:a("dialogs.paragraph.specialHanging")})]})]}),y!=="none"?jsxs("div",{"data-docx-part":"field","data-docx-field":"specialBy",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-by`,children:a("dialogs.paragraph.by")}),jsx("input",{id:`${ae}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Te.special?"":twipsToInches(T),placeholder:Te.special?Xo("special"):void 0,onChange:z=>{ie("special"),x(Math.max(0,inchesToTwips(Number(z.target.value)||0)));},"aria-label":a("dialogs.paragraph.by")}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}):null,jsxs("div",{"data-docx-part":"field","data-docx-field":"tabStops",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.tabStops")}),ce.length===0?jsx("div",{className:"docx-dialog__note",children:a(Te.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):ce.map(z=>jsxs("div",{className:"docx-dialog__row",children:[jsx("span",{className:"docx-dialog__label docx-dialog__tab-position",children:a("dialogs.paragraph.tabPositionLabel",{position:formatInches(z.positionTwips)})}),jsx("span",{className:"docx-dialog__tab-description",children:a(TAB_ALIGNMENT_LABELS[z.alignment])}),jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>O(ce.filter(ve=>ve!==z)),"aria-label":a("dialogs.paragraph.tabRemoveAt",{position:formatInches(z.positionTwips)}),children:a("dialogs.paragraph.tabRemove")})]},z.positionTwips)),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsx("input",{id:`${ae}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:twipsToInches(J),onChange:z=>de(Math.max(0,inchesToTwips(Number(z.target.value)||0))),"aria-label":a("dialogs.paragraph.tabPosition"),"data-docx-tab-entry":""}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxs("select",{id:`${ae}-tabAlignment`,className:"docx-dialog__input",value:he,onChange:z=>Oe(z.target.value),"aria-label":a("dialogs.paragraph.tabAlignment"),"data-docx-tab-entry":"",children:[jsx("option",{value:"left",children:a("dialogs.paragraph.tabAlignLeft")}),jsx("option",{value:"center",children:a("dialogs.paragraph.tabAlignCenter")}),jsx("option",{value:"right",children:a("dialogs.paragraph.tabAlignRight")}),jsx("option",{value:"decimal",children:a("dialogs.paragraph.tabAlignDecimal")})]})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxs("select",{id:`${ae}-tabLeader`,className:"docx-dialog__input",value:we,onChange:z=>Ke(z.target.value),"aria-label":a("dialogs.paragraph.tabLeader"),"data-docx-tab-entry":"",children:[jsx("option",{value:"none",children:a("dialogs.paragraph.tabNone")}),jsx("option",{value:"dot",children:a("dialogs.paragraph.tabLeaderDot")}),jsx("option",{value:"hyphen",children:a("dialogs.paragraph.tabLeaderHyphen")}),jsx("option",{value:"underscore",children:a("dialogs.paragraph.tabLeaderUnderscore")})]})]}),jsxs("div",{className:"docx-dialog__row docx-dialog__row--actions",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:br,children:a("dialogs.paragraph.tabAdd")}),jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{Io(z=>({...z,tabStops:false})),W(true),O([]);},children:a("dialogs.paragraph.tabClearAll")})]})]})]}),jsxs("div",{className:"docx-dialog__column",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.spacing")}),qe("spaceBefore",E,P,"spaceBefore"),qe("spaceAfter",k,w,"spaceAfter"),jsxs("div",{"data-docx-part":"field","data-docx-field":"lineRule",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxs("select",{id:`${ae}-lineSpacing`,className:"docx-dialog__input",value:Te.lineSpacing?"":D,onChange:z=>{let ve=z.target.value;ie("lineSpacing"),M(ve),I(ve===It.current?.lineRule?It.current.lineValue:ve==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[Te.lineSpacing?jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsx("option",{value:"multiple",children:a("dialogs.paragraph.ruleMultiple")}),jsx("option",{value:"atLeast",children:a("dialogs.paragraph.ruleAtLeast")}),jsx("option",{value:"exact",children:a("dialogs.paragraph.ruleExactly")})]})]}),jsxs("div",{"data-docx-part":"field","data-docx-field":"lineValue",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ae}-at`,children:a("dialogs.paragraph.at")}),jsx("input",{id:`${ae}-at`,type:"number",className:"docx-dialog__input",min:.01,step:D==="multiple"?.01:1,value:Te.lineSpacing?"":H,disabled:Te.lineSpacing,onChange:z=>{let ve=z.target.value.trim();I(ve===""?D==="multiple"?1.08:12:Number(ve)||0);},"aria-label":a("dialogs.paragraph.at")}),jsx("span",{className:"docx-dialog__unit",children:D==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),xe("contextualSpacing",A,S),jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),xe("keepNext",_,B),xe("widowControl",j,oe),xe("keepLines",Z,ee),xe("pageBreakBefore",$,V)]})]})}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("span",{role:"alert","data-docx-part":"error",className:"docx-dialog__error",children:rt?a("dialogs.paragraph.refused"):null}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("dialogs.paragraph.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!c,"data-docx-part":"apply",onClick:No,children:a("dialogs.paragraph.ok")})]})]}),children:r})})}var xo=Tt();function pw(){return xo.useState()}var Zo=Object.assign(uw,{Header:xo.Header,Title:xo.Title,Body:xo.Body,Footer:xo.Footer,Apply:xo.Apply,Cancel:xo.Cancel,Error:xo.Error,Field:xo.Field});var eo=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var _u=["ASAP","CONFIDENTIAL","COPY","DO NOT COPY","DRAFT","ORIGINAL","PERSONAL","SAMPLE","TOP SECRET","URGENT"],Iu=[null,.5,1,1.5,2,5],Nu=[null,36,40,44,48,54,60,66,72,80,90,96,105,120,144],Nb="image/png,image/jpeg,image/gif,image/bmp,image/webp",Fu={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"},Jl=/^[0-9A-Fa-f]{6}$/;function Fb(e,t){let o={...Fu};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&&Jl.test(e.color)?e.color.toUpperCase():o.color,layout:e.layout??o.layout}:o}function Lb(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 Hb=e=>`#${Jl.test(e)?e.toLowerCase():"c0c0c0"}`;function Ab(e){let t=e.startsWith("#")?e.slice(1):e;return Jl.test(t)?t.toUpperCase():null}var Lu=e=>Math.round(Math.min(1,Math.max(0,e))*100);function Hu(e,t){let o=Number(e);return e.trim()===""||!Number.isFinite(o)?t:Math.min(100,Math.max(0,Math.round(o)))/100}function Ob(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 Bb(e,t){return e!==null&&t.kind==="none"?null:t}function Wb(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 Zb=(e,t)=>t.includes(e)?e:"",fw={pageWidthTwips:12240,pageHeightTwips:15840,marginsTwips:{top:1440,right:1440,bottom:1440,left:1440}};function Ql(e){let t=e&&e.pageWidthTwips>0&&e.pageHeightTwips>0?e:null,{pageWidthTwips:o,pageHeightTwips:n,marginsTwips:r}=t??fw,i=o/20,a=n/20,l=Math.max(72,(o-r.left-r.right)/20),s=Math.max(72,(n-r.top-r.bottom)/20);return {width:i,height:a,area:{x:r.left/20,y:r.top/20,width:l,height:s}}}var Rb=12,Mb=[.55,1,1,.9,0,1,1,.6,0,1,.95,1,.45];function Kb(e){let{area:t}=e,o=36,n=[];for(let r=0,i=t.y;i+Rb<=t.y+t.height;r++){let a=Mb[r%Mb.length];a>0&&n.push({x:t.x,y:i,width:t.width*a,height:Rb}),i+=o;}return n}var qb="contrast(0.157068) brightness(1.91)",Au=100,Ko=e=>Math.round(e*100)/100,Ub=e=>({cx:e.area.x+e.area.width/2,cy:e.area.y+e.area.height/2});function zb(e,t=Ql(null)){if(e.kind!=="text")return null;let o=e.text.trim();if(o==="")return null;let n=watermarkShapeBox({text:o,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,layout:e.layout},t.area);if(!n)return null;let{cx:r,cy:i}=Ub(t);return {text:o,fontFamily:`"${e.fontFamily.replace(/["\\]/g,"")}", sans-serif`,fontWeight:e.bold?"bold":"normal",fontStyle:e.italic?"italic":"normal",fill:`#${Jl.test(e.color)?e.color.toUpperCase():"C0C0C0"}`,opacity:Ko(1-Math.min(1,Math.max(0,e.transparency))),box:{x:Ko(r-n.width/2),y:Ko(i-n.height/2),width:Ko(n.width),height:Ko(n.height)},rotation:e.layout==="diagonal"?-45:0}}var _b=new WeakMap;function gw(e){if(!e)return null;let t=_b.get(e);if(t===void 0){try{t=e.createElement("canvas").getContext("2d");}catch{t=null;}_b.set(e,t);}return t}function $b(e,t){let o=Au,n=gw(t);if(n){n.font=`${e.fontStyle} ${e.fontWeight} ${o}px ${e.fontFamily}`;let r=n.measureText(e.text),i=-(r.actualBoundingBoxLeft??0),a=r.actualBoundingBoxRight??r.width,l=-(r.actualBoundingBoxAscent??0),s=r.actualBoundingBoxDescent??0;if(a>i&&s>l)return {left:i,right:a,top:l,bottom:s}}return {left:0,right:.55*o*Array.from(e.text).length,top:-0.7*o,bottom:0}}function Vb(e,t){let{x:o,y:n,width:r,height:i}=e.box,a=r>4*7.2?7.2:0,l=i>4*3.6?3.6:0,s=(r-2*a)/(t.right-t.left),c=(i-2*l)/(t.bottom-t.top),d=o+a-t.left*s,m=n+l-t.top*c,u=p=>String(Math.round(p*1e4)/1e4),g=`matrix(${u(s)} 0 0 ${u(c)} ${u(d)} ${u(m)})`;return e.rotation?`rotate(${e.rotation} ${u(o+r/2)} ${u(n+i/2)}) ${g}`:g}function Gb(e,t=Ql(null)){if(e.kind!=="picture"||!e.imageData)return null;let o=watermarkShapeBox({imageData:e.imageData,scale:e.scale},t.area);if(!o)return null;let{cx:n,cy:r}=Ub(t);return {x:Ko(n-o.width/2),y:Ko(r-o.height/2),width:Ko(o.width),height:Ko(o.height)}}var bw=e=>e.editable,hw={ok:false,code:"unsupported",reason:"editor is not ready"};function Bu(){let e=L(),t=useCallback(l=>e?.getWatermark()??null,[e]),o=K(t,Ob),n=K(bw),r=useMemo(()=>n&&e!==null&&e.can({type:"setWatermark",watermark:{text:"DRAFT"}}).ok,[e,n]),i=useCallback(()=>e?.query({type:"watermark"})??null,[e]),a=useCallback(l=>e?e.exec({type:"setWatermark",watermark:l}):hw,[e]);return useMemo(()=>({watermark:o,isEnabled:r,read:i,apply:a}),[o,r,i,a])}var Tw=e=>e.pageSetup??null,to=Tt(),Ew=to.part("preview");function Jb(){return to.useState()}var Yb=e=>`${Math.round(e*100)}%`;function Sw(e){let[t,o]=useState(null);return useEffect(()=>{if(!e||typeof URL.createObjectURL!="function"){o(null);return}let n=URL.createObjectURL(new Blob([e]));return o(n),()=>URL.revokeObjectURL(n)},[e]),t}function Pw({className:e,style:t,"data-docx-part":o,...n}){let{values:r}=Jb(),i=L(),a=K(Tw),l=useMemo(()=>Ql(a),[a]),s=Sw(r.kind==="picture"?r.imageData:null),c=zb(r,l),d=s?Gb(r,l):null;return jsx("div",{...n,"data-docx-part":"preview","aria-hidden":"true",className:["docx-dialog__preview",e].filter(Boolean).join(" "),style:t,children:jsxs("svg",{className:"docx-dialog__preview-page",viewBox:`0 0 ${l.width} ${l.height}`,focusable:"false",children:[jsx("rect",{className:"docx-dialog__preview-sheet",x:0,y:0,width:l.width,height:l.height}),c?jsx("text",{"data-docx-watermark-preview":"text",x:0,y:0,fontFamily:c.fontFamily,fontSize:Au,fontWeight:c.fontWeight,fontStyle:c.fontStyle,fill:c.fill,fillOpacity:c.opacity,transform:Vb(c,$b(c,i?editorHostDocument(i):null)),children:c.text}):null,s&&d?jsx("image",{"data-docx-watermark-preview":"picture",className:"docx-dialog__preview-picture",href:s,x:d.x,y:d.y,width:d.width,height:d.height,preserveAspectRatio:"none",style:r.washout?{filter:qb}:void 0}):null,Kb(l).map(m=>jsx("rect",{className:"docx-dialog__preview-line",x:m.x,y:m.y,width:m.width,height:m.height},m.y))]})})}function kw({open:e,onClose:t,presets:o=_u,className:n,style:r,children:i,preset:a=true}){let{t:l}=F(),s=L(),c=po(e,t),{isEnabled:d,read:m,apply:u}=Bu(),g=K(eo),[p,f]=useState({...Fu}),[h,v]=useState([]),[b,y]=useState(null),[C,T]=useState(false),[x,E]=useState(0),P=useRef(null),k=useRef(null),w=useRef(null),D=useId(),M=useRef(false);useEffect(()=>{if(!e||g||!s){M.current=false;return}if(M.current)return;M.current=true;let N=s.getWatermark(),W=Fb(N,m());P.current=Bb(N,W),f(W),v(s.getAvailableFonts()),y(null),T(false),E(J=>J+1);},[e,g,s,m]),useEffect(()=>{x!==0&&k.current?.querySelector(`input[name="${D}-kind"]:checked`)?.focus({preventScroll:true});},[x,D]);let H=useCallback((N,W)=>{y(null),f(J=>({...J,[N]:W}));},[]),I=Lb(p),A=d&&I!==void 0,S=useCallback(()=>{if(!A||I===void 0)return;if(!c()){t();return}if(P.current&&Wb(P.current,p)){t();return}let N=u(I);N.ok?t():y(N.reason);},[A,I,p,c,u,t]),_=useCallback(N=>{N&&(T(false),N.arrayBuffer().then(W=>{f(J=>({...J,kind:"picture",imageData:new Uint8Array(W),imageName:N.name})),y(null);}).catch(()=>T(true)));},[]);if(!e)return null;let B=p.kind==="picture",Z=p.kind==="text",ee=h.includes(p.fontFamily)?h:[p.fontFamily,...h],j=p.imageData?p.imageName??l("dialogs.watermark.currentPicture"):l("dialogs.watermark.noPictureSelected"),oe=b!==null?l("dialogs.watermark.refused"):null,$=(N,W,J)=>jsxs("label",{"data-docx-part":"field","data-docx-field":N,className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"radio",name:`${D}-kind`,checked:p.kind===W,onChange:()=>H("kind",W)}),jsx("span",{id:`${D}-${N}-label`,children:J})]}),V=(N,W,J)=>jsxs("div",{"data-docx-part":"field","data-docx-field":N,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${D}-${N}`,children:W}),J]}),ce=(N,W,J)=>jsxs("label",{"data-docx-part":"field","data-docx-field":N,className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",disabled:!J,checked:p[N],onChange:de=>H(N,de.target.checked)}),jsx("span",{children:W})]}),O={values:p,setValue:H,errors:oe?{form:oe}:{},isEnabled:A,apply:S,cancel:t};return jsx(Be,{kind:"watermark",className:n,style:r,panelRef:k,label:l("dialogs.watermark.title"),onClose:t,onKeyDown:N=>{let W=N.target;N.key==="Enter"&&isHTMLElementNode(W)&&W.localName==="input"&&(W.type==="text"||W.type==="number")&&A&&(N.preventDefault(),S());},children:jsx(to.Composition,{state:O,preset:a,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:l("dialogs.watermark.title")})}),jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxs("div",{className:"docx-dialog__watermark-layout",children:[jsx(Pw,{"data-docx-part":"preview"}),jsxs("fieldset",{className:"docx-dialog__fieldset",children:[jsx("legend",{className:"docx-editor-sr-only",children:l("dialogs.watermark.kind")}),$("noWatermark","none",l("dialogs.watermark.noWatermark")),$("pictureWatermark","picture",l("dialogs.watermark.picture")),jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${D}-pictureWatermark-label`,children:[jsxs("div",{"data-docx-part":"field","data-docx-field":"picture",className:"docx-dialog__row",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{H("kind","picture"),w.current?.click();},children:l("dialogs.watermark.selectPicture")}),jsx("span",{className:"docx-dialog__hint","data-docx-watermark-picture":"",children:C?l("dialogs.watermark.pictureFailed"):j}),jsx("input",{ref:w,type:"file",accept:Nb,hidden:true,"aria-label":l("dialogs.watermark.selectPicture"),onChange:N=>{let W=N.target.files?.[0];N.target.value="",_(W);}})]}),V("scale",l("dialogs.watermark.scale"),jsxs("select",{id:`${D}-scale`,className:"docx-dialog__select",disabled:!B,value:p.scale===null?"auto":String(p.scale),onChange:N=>H("scale",N.target.value==="auto"?null:Number(N.target.value)),children:[Iu.map(N=>jsx("option",{value:N===null?"auto":String(N),children:N===null?l("dialogs.watermark.auto"):Yb(N)},String(N))),p.scale!==null&&!Iu.includes(p.scale)?jsx("option",{value:String(p.scale),children:Yb(p.scale)}):null]})),ce("washout",l("dialogs.watermark.washout"),B)]}),$("textWatermark","text",l("dialogs.watermark.text")),jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${D}-textWatermark-label`,children:[V("preset",l("dialogs.watermark.preset"),jsxs("select",{id:`${D}-preset`,className:"docx-dialog__select",disabled:!Z,value:Zb(p.text,o),onChange:N=>{N.target.value!==""&&H("text",N.target.value);},children:[jsx("option",{value:"",children:l("dialogs.watermark.custom")}),o.map(N=>jsx("option",{value:N,children:N},N))]})),V("text",l("dialogs.watermark.textLabel"),jsx("input",{id:`${D}-text`,type:"text",className:"docx-dialog__input",disabled:!Z,maxLength:256,value:p.text,onChange:N=>H("text",N.target.value)})),V("fontFamily",l("dialogs.watermark.font"),jsx("select",{id:`${D}-fontFamily`,className:"docx-dialog__select",disabled:!Z,value:p.fontFamily,onChange:N=>H("fontFamily",N.target.value),children:ee.map(N=>jsx("option",{value:N,children:N},N))})),V("fontSizePt",l("dialogs.watermark.size"),jsxs("select",{id:`${D}-fontSizePt`,className:"docx-dialog__select",disabled:!Z,value:p.fontSizePt===null?"auto":String(p.fontSizePt),onChange:N=>H("fontSizePt",N.target.value==="auto"?null:Number(N.target.value)),children:[Nu.map(N=>jsx("option",{value:N===null?"auto":String(N),children:N===null?l("dialogs.watermark.auto"):String(N)},String(N))),p.fontSizePt!==null&&!Nu.includes(p.fontSizePt)?jsx("option",{value:String(p.fontSizePt),children:p.fontSizePt}):null]})),jsxs("div",{className:"docx-dialog__row",children:[ce("bold",l("dialogs.watermark.bold"),Z),ce("italic",l("dialogs.watermark.italic"),Z)]}),V("transparency",l("dialogs.watermark.transparency"),jsxs(Fragment,{children:[jsx("input",{type:"range",className:"docx-dialog__range",min:0,max:100,step:1,disabled:!Z,"aria-label":l("dialogs.watermark.transparency"),value:Lu(p.transparency),onChange:N=>H("transparency",Hu(N.target.value,p.transparency))}),jsx("input",{id:`${D}-transparency`,type:"number",className:"docx-dialog__input docx-dialog__input--narrow",min:0,max:100,step:1,disabled:!Z,value:Lu(p.transparency),onChange:N=>H("transparency",Hu(N.target.value,p.transparency))}),jsx("span",{className:"docx-dialog__unit",children:"%"})]})),V("color",l("dialogs.watermark.color"),jsx("input",{id:`${D}-color`,type:"color",className:"docx-dialog__color",disabled:!Z,value:Hb(p.color),onChange:N=>{let W=Ab(N.target.value);W&&H("color",W);}})),jsxs("div",{"data-docx-part":"field","data-docx-field":"layout",className:"docx-dialog__row",role:"radiogroup","aria-label":l("dialogs.watermark.layout"),children:[jsx("span",{className:"docx-dialog__label",children:l("dialogs.watermark.layout")}),["diagonal","horizontal"].map(N=>jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"radio",name:`${D}-layout`,disabled:!Z,checked:p.layout===N,onChange:()=>H("layout",N)}),jsx("span",{children:l(`dialogs.watermark.${N}`)})]},N))]})]})]})]})}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("span",{"data-docx-part":"error",role:"alert",className:"docx-dialog__error",...b?{title:b}:{},children:oe}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:l("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply",disabled:!A,"data-docx-part":"apply",onClick:S,children:l("common.apply")})]})]}),children:i})})}var zn=Object.assign(kw,{Header:to.Header,Title:to.Title,Body:to.Body,Preview:Ew,Footer:to.Footer,Apply:to.Apply,Cancel:to.Cancel,Error:to.Error,Field:to.Field});var ts={ok:false,code:"unsupported",reason:"editor is not ready"},Dw=Object.freeze([]);function Ku(e,t){return e.length===t.length&&e.every((o,n)=>o.name===t[n].name&&o.order===t[n].order&&o.story===t[n].story&&o.empty===t[n].empty&&o.atSelection===t[n].atSelection&&o.duplicates===t[n].duplicates&&o.hidden===t[n].hidden&&o.place===t[n].place)}function qu(){let e=L(),t=useCallback(c=>e?.query({type:"bookmarks"})??Dw,[e]),o=K(t,Ku),n=useCallback(c=>c.editable&&e!==null&&e.can({type:"insertBookmark",name:"Bookmark"}).ok,[e]),r=K(n),i=useCallback(c=>e?e.exec({type:"insertBookmark",name:c}):ts,[e]),a=useCallback(c=>e?e.exec({type:"deleteBookmark",name:c}):ts,[e]),l=useCallback(c=>e?e.exec({type:"goToBookmark",name:c}):ts,[e]),s=useCallback(c=>e?e.exec({type:"keepFirstBookmark",name:c}):ts,[e]);return useMemo(()=>({bookmarks:o,isWritable:r,insert:i,remove:a,goTo:l,keepFirst:s}),[o,r,i,a,l,s])}var eh={empty:"dialogs.bookmark.nameEmpty",tooLong:"dialogs.bookmark.nameTooLong",invalidStart:"dialogs.bookmark.nameInvalidStart",invalidCharacter:"dialogs.bookmark.nameInvalidCharacter"};function Fw(e){return e.open?jsx(Lw,{...e}):null}function Lw({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=F(),l=po(e,t),{bookmarks:s,isWritable:c,insert:d,remove:m,goTo:u,keepFirst:g}=qu(),[p,f]=useState(()=>bookmarkDialogInitialName(s)),[h,v]=useState("name"),[b,y]=useState(false),[C,T]=useState(false),[x,E]=useState(false),[P,k]=useState(false),w=useRef(null),D=useRef(null),M=useId(),H=useId(),I=useId(),A=bookmarkDialogRows(s,{sortBy:h,showHidden:b}),S=bookmarkDialogNameState(s,p,c),_=S.problem&&!S.existing&&(x||p.length>0)?S.problem:null,B=S.existing?.duplicates??0,Z=C?a("dialogs.bookmark.refused"):_?a(eh[_]):B>0?a("dialogs.bookmark.duplicates",{count:B}):S.existing&&S.canAdd?a("dialogs.bookmark.nameExists"):null,ee=useCallback(()=>{if(E(true),!S.canAdd)return;if(!l()){t();return}let O=d(p);T(!O.ok),O.ok&&t();},[S.canAdd,l,d,p,t]),j=useCallback(()=>{if(!S.canDelete||!S.existing)return;let O=m(S.existing.name);T(!O.ok),O.ok&&f("");},[S,m]),oe=useCallback(()=>{if(!S.canGoTo||!S.existing)return;let O=u(S.existing.name);T(!O.ok),O.ok&&k(true);},[S,u]),$=useCallback(()=>{let O=S.existing;!O||!c||T(!g(O.name).ok);},[S.existing,c,g]),V=S.existing?.name??"";useLayoutEffect(()=>{!V&&D.current&&(D.current.selectedIndex=-1);});let ce={values:{name:p,sortBy:h,showHidden:b},setValue(O,N){O==="name"?f(N):O==="sortBy"?v(N):y(N),T(false);},errors:_?{name:a(eh[_])}:C?{form:a("dialogs.bookmark.refused")}:{},isEnabled:S.canAdd,apply:ee,cancel:t,rows:A,canDelete:S.canDelete,canGoTo:S.canGoTo,duplicates:B,remove:j,goTo:oe,keepFirst:$};return jsx(Be,{kind:"bookmark",className:o,style:n,panelRef:w,label:a("dialogs.bookmark.title"),onClose:t,onKeyDown:O=>{O.key==="Enter"&&!O.nativeEvent.isComposing&&O.keyCode!==229&&isHTMLElementNode(O.target)&&O.target.localName==="input"&&O.target.getAttribute("type")==="text"&&(O.preventDefault(),ee());},children:jsx(Ft.Composition,{state:ce,preset:i,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.bookmark.title")})}),jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsxs("div",{"data-docx-part":"field","data-docx-field":"name",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:M,children:a("dialogs.bookmark.name")}),jsx("input",{id:M,type:"text",className:"docx-dialog__input",value:p,maxLength:40,autoComplete:"off",spellCheck:false,"aria-invalid":_?true:void 0,"aria-describedby":H,onChange:O=>ce.setValue("name",O.target.value)})]}),jsx("div",{"data-docx-part":"field","data-docx-field":"list",className:"docx-dialog__row",children:jsx("select",{ref:D,className:"docx-dialog__input docx-dialog__input--full docx-bookmark-dialog__list",size:8,value:V,"aria-label":a("dialogs.bookmark.list"),onChange:O=>ce.setValue("name",O.target.value),onDoubleClick:oe,children:A.map(O=>jsx("option",{value:O.name,children:O.name},O.name))})}),A.length===0?jsx("div",{className:"docx-dialog__hint",children:a("dialogs.bookmark.empty")}):null,jsxs("div",{"data-docx-part":"field","data-docx-field":"sortBy",className:"docx-dialog__row",role:"radiogroup","aria-label":a("dialogs.bookmark.sortBy"),children:[jsx("span",{className:"docx-dialog__label",children:a("dialogs.bookmark.sortBy")}),["name","location"].map(O=>jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"radio",name:I,checked:h===O,onChange:()=>ce.setValue("sortBy",O)}),a(O==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},O))]}),jsx("div",{"data-docx-part":"field","data-docx-field":"showHidden",className:"docx-dialog__row",children:jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:b,onChange:O=>ce.setValue("showHidden",O.target.checked)}),a("dialogs.bookmark.showHidden")]})}),jsxs("div",{className:"docx-dialog__row docx-bookmark-dialog__status",children:[jsx("span",{id:H,"data-docx-part":"error",role:"status",className:_||C?"docx-dialog__error":"docx-dialog__hint",children:Z}),B>0?jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"keepfirst",disabled:!c,onClick:$,children:a("dialogs.bookmark.keepFirst")}):null]})]}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply","data-docx-part":"apply",disabled:!S.canAdd,onClick:ee,children:a("dialogs.bookmark.add")}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"delete",disabled:!S.canDelete,onClick:j,children:a("dialogs.bookmark.delete")}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"goto",disabled:!S.canGoTo,onClick:oe,children:a("dialogs.bookmark.goTo")}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a(P?"common.close":"common.cancel")})]})]}),children:r})})}var Ft=Tt();function Hw(){return Ft.useState()}var ja=Object.assign(Fw,{Header:Ft.Header,Title:Ft.Title,Body:Ft.Body,Footer:Ft.Footer,Apply:Ft.Apply,Cancel:Ft.Cancel,Error:Ft.Error,Field:Ft.Field,Delete:Ft.part("delete"),GoTo:Ft.part("goto"),KeepFirst:Ft.part("keepfirst")});var oh=SPLIT_CELL_FALLBACK_MAX;function Uw(e){return e.open?jsx($w,{...e}):null}var zw=e=>e;function $w({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=F(),l=L(),s=po(e,t),c=useMemo(()=>l?.query({type:"splitCellConfig"})??null,[l]),[d]=useState(()=>initialSplitCellCounts(c,S=>l?l.can(S):{ok:false,code:"unsupported",reason:""})),[m,u]=useState(d.columns),[g,p]=useState(d.rows),[f,h]=useState(null),v=useId(),b=useId(),y=useId(),{counts:C,problem:T}=readSplitCellCounts(m,g,c),x=C?.cols??null,E=C?.rows??null;K(zw);let P=l&&C?l.can({type:"splitCell",...C}):null,k=T?.kind==="range"?a("dialogs.splitCell.range",{max:T.max}):T?.kind==="oneCell"?a("dialogs.splitCell.oneCell"):P&&!P.ok?localizeDisabledReason(P.reason??null,a):null,w=P?.ok===true,D=f??k,M=T?.kind==="range"?T.field:null,H=useCallback(()=>{if(!w||!l)return;if(!s()){t();return}let S=l.exec({type:"splitCell",rows:E,cols:x});S.ok?t():h(localizeDisabledReason(S.reason??null,a));},[w,l,s,t,E,x,a]),I={values:{columns:m,rows:g},setValue(S,_){S==="columns"?u(_):p(_),h(null);},errors:D?{form:D}:{},isEnabled:w,apply:H,cancel:t,limits:c},A=(S,_,B,Z,ee)=>jsxs("div",{"data-docx-part":"field","data-docx-field":S,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:_,children:a(B)}),jsx("input",{id:_,type:"number",inputMode:"numeric",className:"docx-dialog__input",min:1,max:ee,step:1,value:Z,"aria-invalid":M===S?true:void 0,"aria-describedby":y,onChange:j=>I.setValue(S,j.target.value)})]});return jsx(Be,{kind:"splitCell",className:o,style:n,label:a("table.splitCell"),onClose:t,onKeyDown:S=>{S.key==="Enter"&&!S.nativeEvent.isComposing&&S.keyCode!==229&&isHTMLElementNode(S.target)&&S.target.localName==="input"&&(S.preventDefault(),H());},children:jsx(vo.Composition,{state:I,preset:i,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("table.splitCell")})}),jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[A("columns",v,"dialogs.splitCell.columns",m,c?.maxCols??oh),A("rows",b,"dialogs.splitCell.rows",g,c?.maxRows??oh),jsx("div",{className:"docx-dialog__row",children:jsx("span",{id:y,"data-docx-part":"error",role:"status",className:"docx-dialog__error",children:D})})]}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply","data-docx-part":"apply",disabled:!w,onClick:H,children:a("dialogs.splitCell.submit")}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("common.cancel")})]})]}),children:r})})}var vo=Tt();function Vw(){return vo.useState()}var Ya=Object.assign(Uw,{Header:vo.Header,Title:vo.Title,Body:vo.Body,Footer:vo.Footer,Apply:vo.Apply,Cancel:vo.Cancel,Error:vo.Error,Field:vo.Field});var nh=createContext(void 0),rh=nh.Provider;function Qe(){let e=useContext(nh),{t}=F();return useCallback((o,n)=>{let r=e?.(o,n);return r===void 0||r===o?t(o,n):r},[e,t])}var Co=Tt();function eD(){return Co.useState()}function tD({session:e,...t}){let[o,n]=useState(e),[r,i]=useState(0);return o!==e&&(n(e),i(r+1)),e?jsx(oD,{session:e,...t},r):null}function oD({session:e,children:t,preset:o,className:n,style:r}){let i=Qe(),a=K(()=>e.canApply()),[l,s]=useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=useState(e.signal.aborted),[m,u]=useState(false);useEffect(()=>{let b=()=>d(true);return e.signal.addEventListener("abort",b),e.signal.aborted&&b(),()=>e.signal.removeEventListener("abort",b)},[e]);let g=()=>{if(e.signal.aborted)return;let b=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(!b);},p={values:l,setValue(b,y){s(C=>({...C,[b]:y,...b==="type"?{format:""}:{}})),u(false);},errors:m?{form:i("textFormField.invalidOptions")}:{},isEnabled:!c&&a,apply:g,cancel:e.cancel};if(c)return null;let f=TEXT_FORM_FORMATS[l.type]??[],h={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},v=(b,y)=>jsxs("label",{"data-docx-part":"field","data-docx-field":b,className:"docx-dialog__row",children:[jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${b}`)}),y]});return jsx(Be,{kind:"textFormField",className:n,style:r,label:i("textFormField.title"),onClose:e.cancel,dismissOutside:false,sessionSignal:e.signal,restoreFocus:false,onKeyDown:b=>{b.key==="Escape"&&(b.preventDefault(),e.cancel()),b.key==="Enter"&&isHTMLElementNode(b.target)&&b.target.localName==="input"&&(b.preventDefault(),g());},children:jsx(Co.Composition,{state:p,preset:o,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:i("textFormField.title")})}),jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[v("defaultText",jsx("input",{className:"docx-dialog__input",value:l.defaultText,onChange:b=>p.setValue("defaultText",b.target.value)})),v("type",jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:b=>p.setValue("type",b.target.value),children:[["regular","number","date"].map(b=>jsx("option",{value:b,children:i(`textFormField.${b}`)},b)),Object.hasOwn(TEXT_FORM_FORMATS,l.type)?null:jsx("option",{value:l.type,disabled:true,children:i("textFormField.preservedType")})]})),v("maxLength",jsx("input",{className:"docx-dialog__input",type:"number",min:0,max:32767,step:1,value:Number.isNaN(l.maxLength)?"":l.maxLength,onChange:b=>p.setValue("maxLength",b.target.valueAsNumber)})),v("format",jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:b=>p.setValue("format",b.target.value),children:[f.map(b=>jsx("option",{value:b,children:h[b]?i(h[b]):b||i("textFormField.noFormat")},b)),f.includes(l.format)?null:jsx("option",{value:l.format,disabled:true,children:l.format||i("textFormField.noFormat")})]})),jsxs("label",{"data-docx-part":"field","data-docx-field":"enabled",className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:l.enabled,onChange:b=>p.setValue("enabled",b.target.checked)}),i("textFormField.enabled")]})]}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("span",{"data-docx-part":"error",className:"docx-dialog__error",role:"alert",children:p.errors.form}),jsx("button",{"data-docx-part":"cancel",className:"docx-dialog__button",type:"button",onClick:e.cancel,children:i("textFormField.cancel")}),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 Ja=Object.assign(tD,{Header:Co.Header,Title:Co.Title,Body:Co.Body,Footer:Co.Footer,Apply:Co.Apply,Cancel:Co.Cancel,Error:Co.Error,Field:Co.Field});var lh=createContext(null),To=()=>useContext(lh);function sh({popups:e,children:t}){let o=L(),n=Sd(),[r,i]=useState(null),[a,l]=useState(null),[s,c]=useState(null),[d,m]=useState(null),u=useRef(d);u.current=d;let g=useRef(e);g.current=e;let p=useRef(null),f=useRef(s);f.current=s;let h=()=>l(null);useEffect(()=>{if(a!==null)return;let T=p.current;p.current=null,T?.isConnected&&T.focus({preventScroll:true});},[a]),useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(T){if(g.current?.textFormField===false){T.cancel();return}u.current?.cancel(),l(null),c(T),T.signal.addEventListener("abort",()=>c(x=>x===T?null:x),{once:true});}},{fallback:true})},[o]),useEffect(()=>{if(!o||!r&&e?.revisionMarkup!==false)return;let T=o.setRevisionMarkupChrome({onRequest(x){if(g.current?.revisionMarkup===false){x.cancel();return}f.current?.cancel(),l(null),m(x),x.signal.addEventListener("abort",()=>m(E=>E===x?null:E),{once:true});}},{fallback:true});return ()=>{u.current?.cancel(),T();}},[o,r,e?.revisionMarkup===false]),useEffect(()=>{l(null),c(null),m(null);},[o,n]);let v=e?.bookmark===false;useEffect(()=>{if(!(!o||!r||v))return o.setBookmarkChrome({onRequest(){f.current?.cancel(),u.current?.cancel(),p.current=lD(r.ownerDocument.activeElement),l("bookmark");}})},[o,r,v]),useEffect(()=>{e?.revisionMarkup===false&&u.current?.cancel(),e?.textFormField===false&&f.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let b=useMemo(()=>({container:r,setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(T,x){f.current?.cancel(),u.current?.cancel(),g.current?.[T]!==false&&(p.current=x??r?.ownerDocument.activeElement,l(T));}}),[r,e?.pageSetup]),y={open:true,onClose:h},C=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?Ee(e.pageSetup,y):jsx(Un,{...y}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Ee(e.paragraph,y):jsx(Zo,{...y}):a==="watermark"&&e?.watermark!==false?e?.watermark?Ee(e.watermark,y):jsx(zn,{...y}):a==="bookmark"&&e?.bookmark!==false?e?.bookmark?Ee(e.bookmark,y):jsx(ja,{...y}):a==="splitCell"&&e?.splitCell!==false?e?.splitCell?Ee(e.splitCell,y):jsx(Ya,{...y}):d&&e?.revisionMarkup!==false?e?.revisionMarkup?Ee(e.revisionMarkup,{session:d},d):jsx(Ra,{session:d}):s&&e?.textFormField!==false?e?.textFormField?Ee(e.textFormField,{session:s},s):jsx(Ja,{session:s}):null;return jsxs(lh.Provider,{value:b,children:[t,r?createPortal(C,r):null]})}function lD(e){return e?.closest("[data-menu]")?.querySelector(':scope > [role="menuitem"]')??e}function ch(){let e=To();return jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer,dir:at()})}function dh({children:e}){let t=To();return t?.container?createPortal(e,t.container):e}var uh=["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"],ph=["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"],$u=["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"],mh=["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"],fh=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],gh=["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 Br(e,t,o){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:l,hidden:s})=>{let c=L(),{close:d}=Bo(),m=Re(),{isEnabled:u,disabledReason:g}=se(t);return s?null:jsx(Me,{slot:e,icon:r??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 Qa=Br("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:uh}),ei=Br("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:ph}),ti=Br("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:mh}),oi=Br("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:bh});function Wr({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=L(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=Bo(),c=Se(),d=Re(),m=useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:u,disabledReason:g}=se(m);if(r)return null;let p=l!==null;return jsx(Me,{slot:"edit.paste",icon:e??re($u),shortcut:d(o??"contextMenu.pasteShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let{text:f,html:h}=await dD(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");}})();},...n?{className:n}:{},children:d(t??"contextMenu.paste")})}Wr.docxRow="edit.paste";async function dD(e){let t=hostWindowOf(e),o=t.navigator.clipboard;if(typeof o.read=="function"&&typeof t.ClipboardItem<"u")try{let n=await o.read(),r="",i=null;for(let a of n)a.types.includes("text/plain")&&(r=await(await a.getType("text/plain")).text()),a.types.includes("text/html")&&(i=await(await a.getType("text/html")).text());if(r||i)return {text:r,html:i}}catch{}return {text:await o.readText(),html:null}}function Zr({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=L(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=Bo(),c=Se(),d=Re(),m=useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:u,disabledReason:g}=se(m);if(r)return null;let p=l!==null;return jsx(Me,{slot:"edit.pasteWithoutFormatting",icon:e??re($u),shortcut:d(o??"contextMenu.pasteWithoutFormattingShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let f=await hostWindowOf(c).navigator.clipboard.readText();f&&i?.exec({type:"pasteWithoutFormatting",text:f});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...n?{className:n}:{},children:d(t??"contextMenu.pasteWithoutFormatting")})}Zr.docxRow="edit.pasteWithoutFormatting";var yh=te("format.painter")?.paths??[],ls=Br("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:yh}),ss=Br("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:yh});function pn(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l,destructive:s})=>{let{close:c}=Bo(),d=Re(),m=ni(),{isEnabled:u,disabledReason:g,execute:p}=se(t);return l||!m?null:jsx(Me,{slot:e,icon:r??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 Kr=pn("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:tableChromeIconPaths("table_rows")}),qr=pn("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:tableChromeIconPaths("table_rows")}),Ur=pn("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:tableChromeIconPaths("view_column")}),zr=pn("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:tableChromeIconPaths("view_column")}),$r=pn("table.mergeCells",{type:"mergeCells"},{labelKey:"table.mergeCells",paths:tableChromeIconPaths("call_merge")}),Vr=Object.assign(({icon:e,labelKey:t,className:o,hidden:n})=>{let{close:r}=Bo(),i=Re(),a=ni(),l=To(),{isEnabled:s,disabledReason:c}=se("table.splitCell");return n||!a||!l?null:jsx(Me,{slot:"table.splitCell",icon:e??re(tableChromeIconPaths("call_split")),disabled:!s,...c?{title:c}:{},...o?{className:o}:{},onSelect:()=>{r(true),l.open("splitCell");},children:i(t??"table.splitCell")})},{docxRow:"table.splitCell"}),Gr=pn("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:tableChromeIconPaths("delete_sweep"),destructive:true}),jr=pn("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:tableChromeIconPaths("view_column"),destructive:true}),Yr=pn("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:tableChromeIconPaths("delete"),destructive:true}),uD=[{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 Vn({hidden:e}){let{close:t}=Bo(),o=Re(),n=ni(),r=se({type:"setTableCellVerticalAlignment",alignment:"top"}),i=se({type:"setTableCellVerticalAlignment",alignment:"center"}),a=se({type:"setTableCellVerticalAlignment",alignment:"bottom"}),l=[r,i,a];return e||!n?null:jsxs("div",{className:"docx-contextmenu__table-align",children:[jsx("span",{className:"docx-contextmenu__table-align-label",children:o("tableAdvanced.verticalAlignment")}),jsx("div",{className:"docx-contextmenu__table-align-buttons",role:"group","aria-label":o("tableAdvanced.verticalAlignment"),children:uD.map((s,c)=>{let d=l[c];return 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(tableChromeIconPaths(s.icon))},s.alignment)})})]})}Vn.docxRow="table.cellVerticalAlignment";function xh(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l})=>{let s=L(),{close:c,tocId:d}=Bo(),m=Re(),u=useMemo(()=>({type:"refreshToc",mode:t,...d?{tocId:d}:{}}),[d]),{isEnabled:g,disabledReason:p}=se(u);return l||d===null?null:jsx(Me,{slot:e,icon:r??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 Xr=xh("toc.refresh","entire",{labelKey:"toc.refresh",paths:fh}),Jr=xh("toc.refreshPageNumbers","pageNumbers",{labelKey:"toc.refreshPageNumbers",paths:gh});function ni(){return K(useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function cs({label:e,icon:t,shortcut:o,disabled:n,disabledReason:r,active:i,onSelect:a,className:l}){let{close:s}=Bo();return jsx(Me,{...t?{icon:t}:{},...o?{shortcut:o}:{},...n?{disabled:n}:{},...n&&r?{title:r}:{},...i!==void 0?{active:i}:{},onSelect:()=>{a?.(),s(true);},...l?{className:l}:{},children:e})}var Gn=createContext(false);function Lt(){return useContext(Gn)?"":"docx-editor "}var ai=8;function yD(){let e=useContext(Nt),t=it(),o=Re(),{isEnabled:n,reason:r}=Fl(o);if((e?.mounted??0)===0)return null;let i=te("review.addComment");return jsx(Me,{icon:re(i?.paths),slot:"review.addComment",disabled:!n,title:r??void 0,onSelect:()=>{e?.requestCommentDraft()&&t.setOpenMenu(null);},children:o("comments.addComment")})}function xD(){let e=L(),t=it(),o=Re();return e?.can({type:"editTextFormField"}).ok?jsx(Me,{slot:"field.edit",onSelect:()=>{t.setOpenMenu(null),e.exec({type:"editTextFormField"});},children:o("textFormField.edit")}):null}var vD=[{kind:"row",id:"field.edit",render:()=>jsx(xD,{})},{kind:"row",id:"edit.cut",render:()=>jsx(Qa,{})},{kind:"row",id:"edit.copy",render:()=>jsx(ei,{})},{kind:"row",id:"edit.paste",render:()=>jsx(Wr,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsx(Zr,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsx(ls,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsx(ss,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsx(ti,{})},{kind:"row",id:"edit.selectAll",render:()=>jsx(oi,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsx(Kt,{slotId:"text.link",labelKey:"formattingBar.insertLink"})},{kind:"row",id:"review.addComment",render:()=>jsx(yD,{})}];function CD(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Kr.docxRow,render:()=>jsx(Kr,{})},{kind:"row",id:qr.docxRow,render:()=>jsx(qr,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:Ur.docxRow,render:()=>jsx(Ur,{})},{kind:"row",id:zr.docxRow,render:()=>jsx(zr,{})},{kind:"separator",id:"sep.table.cells"},{kind:"row",id:$r.docxRow,render:()=>jsx($r,{})},{kind:"row",id:Vr.docxRow,render:()=>jsx(Vr,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:Gr.docxRow,render:()=>jsx(Gr,{})},{kind:"row",id:jr.docxRow,render:()=>jsx(jr,{})},{kind:"row",id:Yr.docxRow,render:()=>jsx(Yr,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:Vn.docxRow,render:()=>jsx(Vn,{})}]}function TD(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:Xr.docxRow,render:()=>jsx(Xr,{})},{kind:"row",id:Jr.docxRow,render:()=>jsx(Jr,{})}]}function ED(e,t=false){return [...vD,...e?CD():[],...t?TD():[]]}function Ph(e){if(!isValidElement(e))return null;let t=wr(e,Ph);if(t!==null)return t;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxRow=="string")return o.docxRow;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxMenuRow===true){let n=Vl(e.props);if(n)return n}return null}function Eh(e){if(!isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function SD(e){return e?.closest(".docx-editor__scroll-container")??null}function ii({className:e,t,preset:o=true,disabled:n,onOpenChange:r,children:i}){let a=Lt(),l=at(),s=L(),{t:c}=F(),d=ni(),m=useRef(null),u=useRef(null),[g,p]=useState(null),[f,h]=useState(null),[v,b]=useState(null),y=useMemo(()=>ED(d,f!==null),[d,f]),[C,T]=useState(null),x=useCallback((I=false)=>{p(null),T(null),h(null),b(null),I&&s?.focus();},[s]);useEffect(()=>{if(n)return;let I=SD(m.current);if(!I)return;let A=S=>{S.preventDefault();let _=S.button===-1||S.clientX===0&&S.clientY===0,B=I.getBoundingClientRect();h(s?.snapshot().tocContext?.id??null),b(_||!isHTMLElementNode(S.target)?null:S.target),p(_?{x:B.left+16,y:B.top+16}:{x:S.clientX,y:S.clientY});};return I.addEventListener("contextmenu",A),()=>I.removeEventListener("contextmenu",A)},[n,s]),useEffect(()=>{n&&x();},[n,x]),useEffect(()=>{if(!g)return;let I=Z=>{u.current?.contains(Z.target)||x();},A=Z=>{Z.key==="Escape"?(Z.preventDefault(),x(true)):Z.key==="Tab"&&x();},S=()=>x(),_=hostDocumentOf(m.current??u.current),B=hostWindowOf(m.current??u.current);return _.addEventListener("pointerdown",I,true),_.addEventListener("keydown",A),_.addEventListener("scroll",S,{capture:true,passive:true}),B.addEventListener("blur",S),B.addEventListener("resize",S),()=>{_.removeEventListener("pointerdown",I,true),_.removeEventListener("keydown",A),_.removeEventListener("scroll",S,true),B.removeEventListener("blur",S),B.removeEventListener("resize",S);}},[g,x]),useLayoutEffect(()=>{let I=u.current;if(!g||!I)return;let{width:A,height:S}=I.getBoundingClientRect(),_=hostWindowOf(I),B=_.innerWidth-A-ai,Z=_.innerHeight-S-ai,j=_.getComputedStyle(I).direction==="rtl"?g.x-A>=ai:g.x>B,oe=Math.max(ai,Math.min(j?g.x-A:g.x,B)),$=Math.max(ai,g.y>Z?g.y-S:g.y);T({x:oe,y:$});},[g]),useLayoutEffect(()=>{C&&u.current?.focus({preventScroll:true});},[C]);let E=useRef(r);E.current=r;let P=useRef(false);useEffect(()=>{let I=g!==null;I!==P.current&&(P.current=I,E.current?.(I));},[g]);let k=useMemo(()=>({t,openMenu:null,setOpenMenu:()=>x(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,x]),[w,D]=useState(null),M=useMemo(()=>({close:x,anchor:g,tocId:f,target:v,clipboardRefusal:w,reportClipboardRefusal:D}),[x,g,f,v,w]),H={position:"fixed",left:(C??g)?.x??0,top:(C??g)?.y??0,visibility:C?"visible":"hidden"};return jsx("div",{ref:m,style:{display:"contents"},children:g?jsx(Wa.Provider,{value:k,children:jsx(Gl.Provider,{value:M,children: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:H,onKeyDown:I=>{let A=u.current;if(!A)return;let S=Wn(A);I.key==="ArrowDown"?(I.preventDefault(),Yt(S,hostDocumentOf(A).activeElement,1)):I.key==="ArrowUp"?(I.preventDefault(),Yt(S,hostDocumentOf(A).activeElement,-1)):I.key==="Home"?(I.preventDefault(),Xt(S,"first")):I.key==="End"&&(I.preventDefault(),Xt(S,"last"));},children:[Children.toArray(i).filter(Eh),Nl({entries:y,children:Children.toArray(i).filter(I=>!Eh(I)),preset:o,keyOfEntry:I=>I.id,keyOfChild:I=>Kg(Ph(I)),renderEntry:I=>I.kind==="separator"?jsx(Kn,{}):I.render(),onUnmatched:(I,A)=>{A.props.hidden&&fg(I);}})]})})}):null})}var Yu=Object.assign(ii,{Cut:Qa,Copy:ei,Paste:Wr,PasteWithoutFormatting:Zr,Delete:ti,SelectAll:oi,InsertRowAbove:Kr,InsertRowBelow:qr,InsertColumnLeft:Ur,InsertColumnRight:zr,MergeCells:$r,SplitCell:Vr,DeleteTableRow:Gr,DeleteTableColumn:jr,DeleteTable:Yr,CellVerticalAlignment:Vn,RefreshToc:Xr,RefreshTocPageNumbers:Jr,Item:cs,Slot:Kt,Row:Me,Group:$a,Separator:Kn,Submenu:Jt});var kh=Od.Provider;function wh(){let e=St(),{t}=F();return jsxs(Fragment,{children:[e?.hyperlink&&Ee(e.hyperlink,{}),e?.contentControl&&Ee(e.contentControl,{}),e?.equation&&Ee(e.equation,{}),e?.contextMenu&&Ee(e.contextMenu,{t:o=>t(o)})]})}function Dh(e,t,o,n){return {...e,hyperlink:e?.hyperlink??(t===false?false:r=>jsx(La,{...r})),contentControl:e?.contentControl??(r=>jsx(Oa,{...r})),equation:e?.equation??(()=>jsx(Ba,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:r=>e.contextMenu&&Ee(e.contextMenu,{...r,t:n??r.t}):o===false?false:r=>jsx(ii,{...r,t:n??r.t,...typeof o=="object"?o:{}})}}function DD(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 Xu(){let e=L(),t=useCallback(n=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),o=K(t,DD);return o?.kind==="note"?o:null}function Rh(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 Mh(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&&Rh(e.documentAuthored,t.documentAuthored)&&Rh(e.sectionAuthored,t.sectionAuthored)}function RD(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&Mh(e.footnote,t.footnote)&&Mh(e.endnote,t.endnote)}function Ju(){let e=L(),t=useCallback(o=>e?.getNotePropertiesState()??null,[e]);return K(t,RD)}function li(e,t){let[o,n]=useState(null),r=useCallback(l=>n(l),[]),[i,a]=useState({visibility:"hidden"});return useLayoutEffect(()=>{let l=o?.closest(".docx-editor__scroll-container"),s=l??o?.parentElement?.querySelector(".docx-editor__scroll-container");if(!o||!s)return;let c=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 v=h.getBoundingClientRect(),b=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,y=t==="story-label"?6:4,C=l===s,T=t==="after"?v.bottom+6:t==="story-label"?storyLabelTop(v,h.closest(".docx-page")?.getBoundingClientRect().top,b,y):v.top-b-y,x=C?Er(s,v.left,T):{left:v.left,top:T},E=x.left,P=x.top,k=C?s.scrollLeft+8:8;a({position:C?"absolute":"fixed",left:t==="story-label"?E:Math.max(k,E+8),top:t==="story-label"?P:Math.max(C?s.scrollTop+8:8,P),...t==="story-label"?{width:Math.max(240,Math.min(v.width,s.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(v.width-16,s.clientWidth-16))},visibility:"visible"});},p=()=>{d||(d=c.requestAnimationFrame(g));};u.observe(s),u.observe(o);let f=new c.MutationObserver(p);return f.observe(s,{subtree:true,childList:true,attributes:true,attributeFilter:["data-docx-hf-active","data-docx-note-scope"]}),s.addEventListener("scroll",p,{passive:true}),c.addEventListener("resize",p),g(),()=>{d&&c.cancelAnimationFrame(d),u.disconnect(),f.disconnect(),s.removeEventListener("scroll",p),c.removeEventListener("resize",p);}},[o,e,t]),{ref:r,style:i}}var LD=/^(footnote|endnote):(-?\d{1,10})$/;function Nh(e){let t=LD.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function HD(e){let t=hostWindowOf(e);return typeof t.matchMedia!="function"?false:t.matchMedia("(pointer: coarse)").matches}function ep(e){let t=L();return 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 AD(e){let{t}=F(),[o,n]=useState(false),r=useRef(null);return useEffect(()=>{if(o)return listenForOutsidePress({popup:r.current,close:()=>n(false)})},[o]),jsxs("div",{ref:r,className:"docx-hf-chrome__options",children:[jsx("button",{type:"button",className:"docx-context-bar__options-trigger","data-testid":"docx-notes-options","aria-expanded":o,"aria-haspopup":"menu",onMouseDown:U,onClick:()=>n(i=>!i),children:t("headerFooter.options")}),o?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:U,children:[jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-properties",onClick:()=>{e.onOpenProperties(),n(false);},children:t("dialogs.footnoteProperties.title")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-notes-close",onClick:()=>{e.onClose(),n(false);},children:t("common.close")})]}):null]})}function fs({className:e}){let t=St(),o=useRef(null),{t:n}=F(),r=L(),i=Xu(),[a,l]=useState(null),[s,c]=useState(null),[d,m]=useState(false),u=useRef(null),g=useCallback(M=>{if(!i)return null;let I=[...M.querySelectorAll("[data-docx-note-scope]")].find(A=>A.matches("[data-docx-note]")&&A.dataset.docxNoteScope===i.id)??null;return I?.closest("[data-docx-notes]")??I},[i]),p=li(g,"story-label"),f=useCallback(()=>{u.current&&u.current.win.clearTimeout(u.current.handle),u.current=null,l(null);},[]);useEffect(()=>{if(!r)return;let M=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!M)return;let H=S=>{let _=S.target;if(!_)return;let B=_.closest("[data-docx-note-ref]");if(B?.dataset.docxNoteScope){S.preventDefault(),f(),c(null),r.setActiveScope({kind:"note",id:B.dataset.docxNoteScope});return}_.closest("[data-docx-note-mark-back]")&&(S.preventDefault(),f(),c(null),r.setActiveScope({kind:"body"}));},I=S=>{let _=S,Z=_.target?.closest("[data-docx-note-scope]");Z?.dataset.docxNoteScope&&(_.preventDefault(),c({scopeId:Z.dataset.docxNoteScope,x:_.clientX,y:_.clientY}));},A=S=>{let _=S.target;if(HD(_))return;let B=_?.closest("[data-docx-note-ref]");if(!B?.dataset.docxNoteScope){f();return}let Z=B.dataset.docxNoteScope,j=r.getNotePreviewText(Z)??B.getAttribute("aria-description")??n("notes.previewFallback"),oe=B.getBoundingClientRect();u.current&&u.current.win.clearTimeout(u.current.handle);let $=hostWindowOf(B),V=$.setTimeout(()=>{l({scopeId:Z,text:j,x:oe.left,y:oe.bottom+4});},400);u.current={win:$,handle:V};};return M.addEventListener("click",H),M.addEventListener("contextmenu",I),M.addEventListener("pointerover",A),M.addEventListener("scroll",f,true),()=>{M.removeEventListener("click",H),M.removeEventListener("contextmenu",I),M.removeEventListener("pointerover",A),M.removeEventListener("scroll",f,true),f();}},[r,f,n]);let h=useCallback(M=>{r&&(r.exec(M),c(null));},[r]),v=s?Nh(s.scopeId):null,b=useMemo(()=>v?{type:"deleteNote",noteKind:v.noteKind,noteId:v.noteId}:null,[v]),y=useMemo(()=>v?{type:"convertNote",fromKind:v.noteKind,noteId:v.noteId}:null,[v]),C=useMemo(()=>v?{type:"convertAllNotes",fromKind:v.noteKind}:null,[v]),T=ep(b??{type:"deleteNote",noteKind:"footnote",noteId:0}),x=ep(y??{type:"convertNote",fromKind:"footnote",noteId:0}),E=ep(C??{type:"convertAllNotes",fromKind:"footnote"}),P=i?Nh(i.id):null,k=P?n("notes.editingRegion",{kind:P.noteKind==="footnote"?n("notes.footnoteKind"):n("notes.endnoteKind"),number:P.noteId}):null,w=s&&v?{...s,...v,onDelete:()=>{b&&h(b);},onConvert:()=>{y&&h(y);},onConvertAll:()=>{C&&h(C);},onOpenProperties:()=>m(true),onClose:()=>c(null),deleteEnabled:T.enabled,convertEnabled:x.enabled,convertAllEnabled:E.enabled,deleteDisabledReason:T.reason??void 0,convertDisabledReason:x.reason??void 0,convertAllDisabledReason:E.reason??void 0}:null,D={onClose:()=>m(false),onApply:M=>{h(M),m(false);}};return r?jsxs("div",{className:e,ref:o,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":i?void 0:true,children:[i&&P?jsxs("div",{ref:p.ref,className:"docx-context-bar docx-notes-chrome__banner",role:"region","aria-label":n("notes.chromeAriaLabel"),"data-testid":"docx-notes-banner","data-note-scope":i.id,style:{...p.style,zIndex:xt.chrome},children:[jsx("span",{className:"docx-context-bar__title",children:k}),jsx(AD,{onOpenProperties:()=>m(true),onClose:()=>r.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Ee(t.notePreview,a):jsx(Cr,{...a}):null,w&&t?.notesContextMenu!==false?t?.notesContextMenu?Ee(t.notesContextMenu,w):jsx(Tr,{...w}):null,d&&t?.noteProperties!==false?t?.noteProperties?Ee(t.noteProperties,D):jsx(gs,{...D}):null]}):null}function gs(e){let{t}=F(),o=L(),n=Ju(),[r,i]=useState("document"),[a,l]=useState("decimal"),[s,c]=useState("continuous"),[d,m]=useState("pageBottom"),[u,g]=useState("decimal"),[p,f]=useState("continuous"),[h,v]=useState("docEnd");useEffect(()=>{n&&(l(n.footnote.resolved.numFmt),c(n.footnote.resolved.numRestart),m(n.footnote.resolved.pos),g(n.endnote.resolved.numFmt),f(n.endnote.resolved.numRestart),v(n.endnote.resolved.pos));},[n]);let b=!n?.footnote.documentAuthored&&!n?.footnote.sectionAuthored,y=!n?.endnote.documentAuthored&&!n?.endnote.sectionAuthored;return 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:xt.modal},onClick:e.onClose,onKeyDown:C=>{C.key==="Escape"&&e.onClose();},children:jsxs("div",{className:"docx-note-properties__panel",onClick:C=>C.stopPropagation(),onMouseDown:C=>C.stopPropagation(),children:[jsx("h2",{className:"docx-note-properties__title",children:t("dialogs.footnoteProperties.title")}),jsxs("div",{className:"docx-note-properties__body",children:[jsxs("label",{className:"docx-note-properties__scope",children:[jsx("span",{children:t("notes.scope")}),jsxs("select",{className:"docx-note-properties__select",value:r,onChange:C=>i(C.target.value),children:[jsx("option",{value:"document",children:t("notes.scopeDocument")}),jsx("option",{value:"section",children:t("notes.scopeSection")})]})]}),jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxs("legend",{className:"docx-note-properties__legend",children:[jsx("span",{children:t("dialogs.footnoteProperties.footnotes")}),b?jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxs("div",{className:"docx-note-properties__fields",children:[jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxs("select",{className:"docx-note-properties__select",value:a,onChange:C=>l(C.target.value),children:[jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxs("select",{className:"docx-note-properties__select",value:s,onChange:C=>c(C.target.value),children:[jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxs("select",{className:"docx-note-properties__select",value:d,onChange:C=>m(C.target.value),children:[jsx("option",{value:"pageBottom",children:t("dialogs.footnoteProperties.footnotePositions.bottomOfPage")}),jsx("option",{value:"beneathText",children:t("dialogs.footnoteProperties.footnotePositions.belowText")})]})]})]})]}),jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxs("legend",{className:"docx-note-properties__legend",children:[jsx("span",{children:t("dialogs.footnoteProperties.endnotes")}),y?jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxs("div",{className:"docx-note-properties__fields",children:[jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxs("select",{className:"docx-note-properties__select",value:u,onChange:C=>g(C.target.value),children:[jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxs("select",{className:"docx-note-properties__select",value:p,onChange:C=>f(C.target.value),children:[jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxs("select",{className:"docx-note-properties__select",value:h,"data-testid":"docx-notes-endnote-position",onChange:C=>v(C.target.value),children:[jsx("option",{value:"docEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfDocument")}),jsx("option",{value:"sectEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfSection")})]})]})]})]})]}),jsxs("div",{className:"docx-note-properties__footer",children:[jsx("button",{className:"docx-note-properties__button",type:"button",onClick:e.onClose,children:t("common.cancel")}),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 C={type:"setNoteProperties",scope:r,sectionIndex:r==="section"?n?.sectionIndex:void 0,footnote:{numFmt:a,numRestart:s,position:d},endnote:{numFmt:u,numRestart:p,position:h}};o.can(C).ok&&e.onApply(C);},children:t("common.apply")})]})]})})}var Ah=e=>e.image;function Hh(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===hostDocumentOf(e).activeElement)}function UD(e){e&&!e.closest(".docx-editor")&&e.classList.add("docx-editor");}function zD(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function lp(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(sn(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(sn(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(sn(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(sn(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function $D(e,t){let o=lp(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function bs(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=qa(t);return Number.isInteger(o)?o:null}function VD(e,t){let o=lp(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,m=c?bs(e.horizontalPoints):t.position?.horizontalEmu,u=d?bs(e.verticalPoints):t.position?.verticalEmu;return c&&m===null?{ok:false}:d&&u===null?{ok:false}:m===void 0||u===void 0?{ok:false}:{ok:true,value:{horizontalEmu:m,verticalEmu:u}}}let n=e.horizontalPoints!==o.horizontalPoints,r=e.verticalPoints!==o.verticalPoints,i=e.relativeToH!==o.relativeToH,a=e.relativeToV!==o.relativeToV,l=n?bs(e.horizontalPoints):t.position?.horizontalEmu,s=r?bs(e.verticalPoints):t.position?.verticalEmu;return n&&l===null?{ok:false}:r&&s===null?{ok:false}:{ok:true,value:{...typeof l=="number"?{horizontalEmu:l}:{},...typeof s=="number"?{verticalEmu:s}:{},...i||n||r?{relativeToH:e.relativeToH}:{},...a||n||r?{relativeToV:e.relativeToV}:{}}}}function hs(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function ys(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function ci({open:e,onClose:t,className:o,triggerRef:n}){let r=L(),{t:i}=F(),a=K(Ah),l=useId(),s=useId(),c=useId(),d=useRef(null),m=useRef(null),u=useRef(null),g=useRef(null),[p,f]=useState(null),[h,v]=useState(null),b=m.current,y=b?.canCrop===false,C=b?.canResize===false,T=b?.locks.changeAspect===true,x=b?.kind==="anchored"&&b.canMove===true,E=b?.kind==="inline",P=b?.kind==="anchored"&&b.canMove===false;useEffect(()=>{if(!e){m.current=null,u.current=null,g.current=null;return}if(!a)return;if(m.current=a,r?.surface){let{anchor:B}=r.surface.state().selection;u.current={paragraphId:B.paragraphId,offset:B.offset},g.current=r.surface.session.packageRevision();}v(null);let S=lp(a),_=a.crop;f({widthPoints:String(sn(a.widthEmu)),heightPoints:String(sn(a.heightEmu)),cropLeft:String(_.left),cropTop:String(_.top),cropRight:String(_.right),cropBottom:String(_.bottom),title:a.title,description:a.description,hyperlink:a.hyperlink??"",wrap:a.wrap,lockAspect:a.locks.changeAspect,...S});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let k=useCallback(()=>{n?.current?.focus(),r?.focus();},[r,n]),w=useCallback(()=>{t(),k();},[t,k]);useEffect(()=>{if(!e)return;let S=d.current;if(!S)return;let _=Hh(S);(_.find(j=>j.id==="image-prop-width"&&!j.hasAttribute("disabled"))??_.find(j=>!j.hasAttribute("disabled"))??S).focus();let Z=j=>{if(j.key==="Escape"){j.preventDefault(),w();return}if(j.key!=="Tab")return;let oe=Hh(S);if(oe.length===0)return;let $=hostDocumentOf(S).activeElement,V=oe.findIndex(O=>O===$);if(V===-1)return;j.preventDefault();let ce=j.shiftKey?(V-1+oe.length)%oe.length:(V+1)%oe.length;oe[ce]?.focus();},ee=hostDocumentOf(S);return ee.addEventListener("keydown",Z),()=>ee.removeEventListener("keydown",Z)},[e,w]);let D=useMemo(()=>{let S=b??a;return !S||S.widthEmu<=0?1:S.widthEmu/S.heightEmu},[a,b]),M=useCallback(S=>{f(_=>{if(!_)return _;if(!_.lockAspect)return {..._,widthPoints:S};let B=ys(S);if(B===null)return {..._,widthPoints:S};let Z=Math.round(B/D*100)/100;return {..._,widthPoints:S,heightPoints:String(Z)}});},[D]),H=useCallback(S=>{f(_=>{if(!_)return _;if(!_.lockAspect)return {..._,heightPoints:S};let B=ys(S);if(B===null)return {..._,heightPoints:S};let Z=Math.round(B*D*100)/100;return {..._,widthPoints:String(Z),heightPoints:S}});},[D]),I=useCallback(()=>{let S=m.current;if(!S?.intrinsic)return;let _=S.intrinsic.pixelWidth*72/S.intrinsic.dpiX,B=S.intrinsic.pixelHeight*72/S.intrinsic.dpiY;f(Z=>Z&&{...Z,widthPoints:String(Math.round(_*100)/100),heightPoints:String(Math.round(B*100)/100)});},[a]),A=useCallback(()=>{let S=m.current,_=u.current,B=g.current;if(!r||!S||!p||!_||B===null)return;let Z={type:"setImageProperties",drawingNodeId:S.id,expectedPackageRevision:B,selectionParagraphId:_.paragraphId,selectionOffset:_.offset};if(!C){let ce=ys(p.widthPoints),O=ys(p.heightPoints);if(ce===null||O===null){v("imageProperties.errors.invalidDimensions");return}let N=qa(ce),W=qa(O);N!==S.widthEmu&&(Z.widthEmu=N),W!==S.heightEmu&&(Z.heightEmu=W);}if(S.canCrop&&!y){let ce=hs(p.cropLeft),O=hs(p.cropTop),N=hs(p.cropRight),W=hs(p.cropBottom);if(ce===null||O===null||N===null||W===null){v("imageProperties.errors.invalidCrop");return}let J=S.crop;(ce!==J.left||O!==J.top||N!==J.right||W!==J.bottom)&&(Z.crop={left:ce,top:O,right:N,bottom:W});}p.title!==S.title&&(Z.title=p.title),p.description!==S.description&&(Z.description=p.description);let ee=p.hyperlink.trim();if(ee!==(S.hyperlink??"")&&(Z.hyperlink=ee===""?null:ee),S.canChangeWrap&&p.wrap!==S.wrap&&(Z.wrap=p.wrap),S.kind==="anchored"&&S.canMove&&$D(p,S)){let ce=VD(p,S);if(!ce.ok){v("imageProperties.errors.invalidPosition");return}if(!validateDrawingPositionInput(positionInputFromPropertiesCommand(ce.value,S))){v("imageProperties.errors.invalidPosition");return}Object.assign(Z,ce.value);}if(!(Z.widthEmu!==void 0||Z.heightEmu!==void 0||Z.title!==void 0||Z.description!==void 0||Z.hyperlink!==void 0||Z.crop!==void 0||Z.wrap!==void 0||Z.horizontalEmu!==void 0||Z.verticalEmu!==void 0||Z.relativeToH!==void 0||Z.relativeToV!==void 0)){w();return}if(!r.can(Z).ok){v("imageProperties.errors.refused");return}if(!r.exec(Z).ok){v("imageProperties.errors.refused");return}w();},[r,p,y,C,w]);return !e||!p?null:jsx("div",{ref:UD,className:`docx-dialog-overlay${o?` ${o}`:""}`,onClick:w,onMouseDown:S=>{S.stopPropagation(),zD(S);},children:jsxs("div",{ref:d,role:"dialog","aria-modal":"true","data-docx-modal":"","aria-labelledby":l,className:"docx-dialog docx-image-properties-dialog",onClick:S=>S.stopPropagation(),onMouseDown:S=>S.stopPropagation(),children:[jsx("div",{id:l,className:"docx-dialog__header",children:i("dialogs.imageProperties.title")}),jsxs("div",{className:"docx-dialog__body",children:[h?jsx("p",{className:"docx-dialog__error",children:i(h)}):null,jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.dimensions")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-width",children:i("dialogs.imageProperties.widthLabel")}),jsx("input",{id:"image-prop-width",className:"docx-dialog__input",value:p.widthPoints,disabled:C,onChange:S=>M(S.target.value)}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-height",children:i("dialogs.imageProperties.heightLabel")}),jsx("input",{id:"image-prop-height",className:"docx-dialog__input",value:p.heightPoints,disabled:C,onChange:S=>H(S.target.value)}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:p.lockAspect,disabled:T,onChange:S=>f(_=>_&&{..._,lockAspect:S.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:y||!b?.intrinsic,onClick:I,children:i("imageProperties.resetNaturalSize")})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.position")}),E?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionUnavailable")}):null,P?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,x?jsxs(Fragment,{children:[p.positionMode==="frame"?jsxs(Fragment,{children:[jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-h",children:i("imageProperties.relativeToHorizontal")}),jsx("select",{id:"image-pos-rel-h",className:"docx-dialog__select",value:p.relativeToH??"page",onChange:S=>f(_=>_&&{..._,relativeToH:S.target.value}),children:DRAWING_REL_FROM_H.map(S=>jsx("option",{value:S,children:i(`dialogs.imagePosition.relativeOptions.${S}`)},S))})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-v",children:i("imageProperties.relativeToVertical")}),jsx("select",{id:"image-pos-rel-v",className:"docx-dialog__select",value:p.relativeToV??"line",onChange:S=>f(_=>_&&{..._,relativeToV:S.target.value}),children:DRAWING_REL_FROM_V.map(S=>jsx("option",{value:S,children:i(`dialogs.imagePosition.relativeOptions.${S}`)},S))})]})]}):null,jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-h",children:i("imageProperties.horizontalOffset")}),jsx("input",{id:"image-pos-h",className:"docx-dialog__input",value:p.horizontalPoints,onChange:S=>f(_=>_&&{..._,horizontalPoints:S.target.value})}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-v",children:i("imageProperties.verticalOffset")}),jsx("input",{id:"image-pos-v",className:"docx-dialog__input",value:p.verticalPoints,onChange:S=>f(_=>_&&{..._,verticalPoints:S.target.value})}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]})]}):null]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.altText")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-title",children:i("imageAltText.title")}),jsx("input",{id:"image-prop-title",className:"docx-dialog__input",value:p.title,onChange:S=>f(_=>_&&{..._,title:S.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-description",children:i("imageAltText.description")}),jsx("textarea",{id:"image-prop-description",className:"docx-dialog__textarea",value:p.description,onChange:S=>f(_=>_&&{..._,description:S.target.value}),placeholder:i("dialogs.imageProperties.altTextPlaceholder")})]})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.hyperlink")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:c,children:i("hyperlinkPopup.urlLabel")}),jsx("input",{id:c,className:"docx-dialog__input docx-dialog__input--full",value:p.hyperlink,onChange:S=>f(_=>_&&{..._,hyperlink:S.target.value}),placeholder:i("hyperlinkPopup.urlPlaceholder"),dir:"ltr"})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.textWrapping")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:s,children:i("formattingBar.imageWrap")}),jsx("select",{id:s,className:"docx-dialog__select docx-dialog__input--full",value:p.wrap,disabled:b?.canChangeWrap===false,onChange:S=>f(_=>_&&{..._,wrap:S.target.value}),children:IMAGE_WRAP_TARGETS.map(S=>jsx("option",{value:S,children:i(`imageWrap.targets.${S}`)},S))})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.crop")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-left",children:i("imageProperties.cropLeft")}),jsx("input",{id:"image-crop-left",className:"docx-dialog__input",disabled:y,value:p.cropLeft,onChange:S=>f(_=>_&&{..._,cropLeft:S.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-top",children:i("imageProperties.cropTop")}),jsx("input",{id:"image-crop-top",className:"docx-dialog__input",disabled:y,value:p.cropTop,onChange:S=>f(_=>_&&{..._,cropTop:S.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-right",children:i("imageProperties.cropRight")}),jsx("input",{id:"image-crop-right",className:"docx-dialog__input",disabled:y,value:p.cropRight,onChange:S=>f(_=>_&&{..._,cropRight:S.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-bottom",children:i("imageProperties.cropBottom")}),jsx("input",{id:"image-crop-bottom",className:"docx-dialog__input",disabled:y,value:p.cropBottom,onChange:S=>f(_=>_&&{..._,cropBottom:S.target.value})})]}),y?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.nonPictureHint")}):null]})]}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:w,children:i("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:A,children:i("common.apply")})]})]})})}function xs({className:e,hidden:t,asChild:o,children:n}){let r=St(),i=L(),{t:a}=F(),l=K(Ah),[s,c]=useState(false),d=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=te("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 jsxs(Fragment,{children:[o?jsx(X,{...h,children:n}):jsx("button",{...h,children:n??re(f?.paths)}),s&&r?.imageProperties!==false?r?.imageProperties?Ee(r.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):jsx(ci,{open:s,onClose:()=>c(false),triggerRef:d}):null]})}xs.docxSlot="image.properties";var ea=Object.assign(xs,{docxSlot:"image.properties"});function di(e){let t=L(),o=useCallback(()=>toolbarCommandState(t,e),[t,e]),n=K(o,(r,i)=>r.value===i.value&&r.enabled===i.enabled&&r.disabledReason===i.disabledReason);return useMemo(()=>({execute:(r,i)=>runToolbarCommand(t,e,r,i),value:n.value===void 0?null:e==="font.size"||e==="list.lineSpacing"?Number(n.value):n.value,options:e==="image.wrap"?IMAGE_WRAP_TARGETS:[],isEnabled:n.enabled,disabledReason:n.disabledReason}),[t,e,n])}function vs({className:e,hidden:t,asChild:o,children:n}){let r=St(),i=ne(),{execute:a,value:l,isEnabled:s,disabledReason:c}=di("image.altText"),[d,m]=useState(false),[u,g]=useState(""),p=useRef(null),f=useRef(null),h=useId();useEffect(()=>{d&&g(l??"");},[d,l]),useEffect(()=>{if(!d)return;let x=k=>{let w=p.current;isDomNode(k.target)&&(w?.contains(k.target)||w?.ownerDocument.getElementById(h)?.contains(k.target))||m(false);},E=k=>{k.key==="Escape"&&(k.preventDefault(),m(false),f.current?.focus());},P=hostDocumentOf(p.current);return P.addEventListener("mousedown",x,true),P.addEventListener("keydown",E),()=>{P.removeEventListener("mousedown",x,true),P.removeEventListener("keydown",E);}},[d,h]);let v=useCallback(()=>{a(u),m(false);},[u,a]);if(t)return null;let b=te("image.altText"),y=i(b?.labelKey??"formattingBar.altText"),C={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":y,title:c??y,onMouseDown:U,onClick:()=>m(x=>!x)},T={id:h,value:u,onValueChange:g,onApply:v,onClose:()=>m(false),isEnabled:s,anchorRef:f};return jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsx(X,{...C,children:n}):jsx("button",{...C,children:n??y}),d&&r?.imageAltText!==false?r?.imageAltText?Ee(r.imageAltText,T):jsx(Cs,{...T}):null]})}vs.docxSlot="image.altText";var ui=Object.assign(vs,{docxSlot:"image.altText"});function Cs({id:e,value:t,onValueChange:o,onApply:n,onClose:r,isEnabled:i,className:a}){let{t:l}=F();return jsxs("div",{id:e,role:"dialog","aria-label":l("imageAltText.panelTitle"),className:`docx-toolbar__alt-text-panel${a?` ${a}`:""}`,onMouseDown:s=>s.stopPropagation(),children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${e}-description`,children:l("imageAltText.description")}),jsx("textarea",{id:`${e}-description`,className:"docx-dialog__textarea",value:t,onChange:s=>o(s.target.value),placeholder:l("dialogs.imageProperties.altTextPlaceholder")}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:l("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",disabled:!i,onClick:n,children:l("common.apply")})]})]})}function dp(e){let[t,o]=useState(e.session),[n,r]=useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsx(aR,{...e},n)}function aR({session:e,className:t,style:o,children:n}){let r=Qe(),[i,a]=useState(e.signal.aborted),l=useRef(null);return 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:jsx(Be,{kind:"invalidTextFormField",role:"alertdialog",label:r("textFormField.invalidTitle"),className:t,style:o,panelRef:l,dismissOutside:false,onClose:e.acknowledge,sessionSignal:e.signal,restoreFocus:false,onKeyDown:s=>{s.key==="Enter"&&!s.nativeEvent.isComposing&&(s.preventDefault(),e.acknowledge());},children:n??jsxs(Fragment,{children:[jsx("header",{className:"docx-dialog__header",children:jsx("h2",{className:"docx-dialog__title",children:r("textFormField.invalidTitle")})}),jsx("div",{className:"docx-dialog__body",children:r(e.type==="number"?"textFormField.invalidNumber":"textFormField.invalidDate")}),jsx("footer",{className:"docx-dialog__footer",children:jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:e.acknowledge,children:r("textFormField.apply")})})]})})}var qh=createContext(null),Uh=qh.Provider;function st(){let e=useContext(qh);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function hR(e){return e.kind==="date"?parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function zh(e){let t=`docx-cc-list-${useId()}`,[o,n]=useState(()=>hR(e)),[r,i]=useState(()=>calendarDateText(e.value,e.locale)),a=useMemo(()=>createContentControlListNavigation(e.locale),[e]),[l,s]=useState(false),c=useCallback(D=>{i(D),s(false);},[]),d=K(()=>e.canApply()),m=e.kind==="date"?parseIsoDate(e.value):null,[u,g]=useState(()=>{let D=m??new Date;return {year:D.getFullYear(),month:D.getMonth()}}),p=useCallback(D=>{let M=e.apply(D??o);return s(!M),M},[e,o]),f=useCallback(()=>e.cancel(),[e]),h=useCallback(async D=>{if(!e.replaceImage)return s(true),false;try{let M=D instanceof Uint8Array?D.byteLength:D.size;if(!e.canApply()||M>DEFAULT_IMAGE_RESOURCE_LIMITS.maxEncodedBytes)return s(!0),!1;let H=D instanceof Uint8Array?D:new Uint8Array(await D.arrayBuffer()),I=await e.replaceImage(H);return s(!I),I}catch{return s(true),false}},[e]),v=useMemo(()=>calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),b=useCallback(()=>{g(D=>shiftMonth(D.year,D.month,-1)),E(null);},[]),y=useCallback(()=>{g(D=>shiftMonth(D.year,D.month,1)),E(null);},[]),C=useCallback(D=>p(D),[p]),T=useCallback(()=>p(isoDateOf(new Date)),[p]),[x,E]=useState(null),P=useCallback(D=>{let M=parseIsoDate(D);M&&(g({year:M.getFullYear(),month:M.getMonth()}),E(isoDateOf(M)));},[]),k=useCallback(()=>{let D=calendarDateFromText(r,e.locale);return D?p(D):(s(true),false)},[r,e.locale,p]),w=useCallback((D,M)=>{!Number.isInteger(D)||D<100||D>9999||!Number.isInteger(M)||M<0||M>11||(g({year:D,month:M}),E(null));},[]);return useMemo(()=>({session:e,kind:e.kind,items:e.items,value:o,setValue:n,isEnabled:d,refused:l,apply:p,cancel:f,calendar:v,previousMonth:b,nextMonth:y,selectDay:C,selectToday:T,focusIso:x,focusDay:P,dateText:r,setDateText:c,applyDateText:k,showMonth:w,listNavigation:a,listId:t,accept:CONTENT_CONTROL_PICTURE_ACCEPT,replaceImage:h}),[e,h,o,d,l,p,f,v,b,y,C,T,x,P,r,c,k,w,a,t])}function et(e,t,o,n){if(t.hidden)return null;let{children:r,asChild:i,className:a,style:l,hidden:s,id:c,title:d,"aria-label":m,...u}=t,g=r===void 0?n:r,{key:p,...f}=o,h={...c!==void 0?{id:c}:{},...d!==void 0?{title:d}:{},...m!==void 0?{"aria-label":m}:{}};if(i){let{className:b,style:y,...C}=f;return jsx(X,{...u,...C,...h,...a?{className:a}:{},style:{...y,...l},children:g},p)}return jsx(e,{...u,...f,...h,className:[o.className,a].filter(Boolean).join(" "),style:{...o.style,...l},children:g},p)}var Xn=e=>e.stopPropagation();function fp(e){return et("div",e,{className:"docx-content-control-calendar-header","data-docx-part":"header"},jsxs(Fragment,{children:[jsx(gp,{}),jsx(Pp,{}),jsx(bp,{}),jsx(hp,{className:"docx-content-control-calendar-announcement"})]}))}function gp(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:Xn,onClick:t.previousMonth},"\u2039")}function bp(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:Xn,onClick:t.nextMonth},"\u203A")}function hp(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 yp(e){let t=st();return et("div",e,{className:"docx-content-control-calendar-weekdays","data-docx-part":"weekdays"},t.calendar.weekdays.map((o,n)=>jsx("span",{children:o},n)))}function xp({day:e,...t}){let o=st(),n=o.calendar.days.find(i=>i.iso===o.focusIso)??o.calendar.days.find(i=>i.selected)??o.calendar.days.find(i=>i.today&&!i.otherMonth)??o.calendar.days.find(i=>!i.otherMonth),r=i=>{if(i.nativeEvent.isComposing||i.altKey||i.ctrlKey||i.metaKey)return;let a=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===n?.iso?0:-1,"aria-label":e.label,...e.selected?{"data-selected":"","aria-selected":true}:{},"aria-current":e.today?"date":void 0,"aria-selected":e.selected,...e.today?{"data-today":""}:{},...e.otherMonth?{"data-other-month":""}:{},disabled:!o.isEnabled,onMouseDown:Xn,onClick:()=>o.selectDay(e.iso),onKeyDown:r},String(e.day))}function vp(e){let t=st(),o=useRef(null);return useLayoutEffect(()=>{let n=o.current;if(!n||n.ownerDocument.activeElement?.closest("[data-docx-part=previousMonth],[data-docx-part=nextMonth],[data-docx-part=month],[data-docx-part=year]"))return;((t.focusIso?n.querySelector(`[data-iso="${t.focusIso}"]`):null)??n.querySelector("[data-selected]")??n.querySelector("[data-today]:not([data-other-month])")??n.querySelector('[data-docx-part="day"]:not([data-other-month])'))?.focus({preventScroll:true});},[t.focusIso,t.calendar]),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},(n,r)=>jsx("div",{role:"row",className:"docx-content-control-calendar-week",children:t.calendar.days.slice(r*7,r*7+7).map(i=>jsx(xp,{day:i},i.iso))},r)))}function Cp(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:Xn,onClick:t.selectToday},o("contentControl.calendar.today"))}function Tp(e){return et("div",e,{className:"docx-content-control-calendar","data-docx-part":"calendar"},jsxs(Fragment,{children:[jsx(fp,{}),jsx(yp,{}),jsx(vp,{}),jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsx(Cp,{}),jsx(Es,{})]}),jsx(ta,{}),jsx(Ps,{})]}))}function Ep({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(n=>n.value===o.value)<0?o.items[0]===e?0:-1:o.value===e.value?0:-1,"aria-selected":o.value===e.value,disabled:!o.isEnabled,onMouseDown:Xn,onClick:()=>o.apply(e.value)},e.displayText)}function Ts(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?jsx("div",{className:"docx-content-control-menu-empty","data-docx-part":"empty",role:"note",tabIndex:0,children:o("contentControl.gallery.empty")}):t.items.map((n,r)=>jsx(Ep,{item:n},r)))}function Es(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"?calendarDateText("2006-11-22",t.session.locale):void 0,"aria-invalid":t.refused||void 0,role:t.kind==="comboBox"?"combobox":void 0,"aria-expanded":t.kind==="comboBox"?true:void 0,"aria-controls":t.kind==="comboBox"?t.listId:void 0,"aria-autocomplete":t.kind==="comboBox"?"list":void 0,onKeyDown:n=>{n.key!=="Enter"||n.nativeEvent.isComposing||(n.preventDefault(),n.stopPropagation(),t.kind==="date"?t.applyDateText():t.apply());},onMouseDown:Xn,onChange:n=>(t.kind==="date"?t.setDateText:t.setValue)(n.target.value)},void 0)}function ta(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 Sp(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 Ss(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 Ps(e){return et("div",e,{className:"docx-dialog__footer","data-docx-part":"footer"},jsxs(Fragment,{children:[jsx(Ss,{}),jsx(Sp,{})]}))}function Pp(e){return et("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxs(Fragment,{children:[jsx(kp,{}),jsx(wp,{})]}))}function kp(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:n=>t.showMonth(t.calendar.year,Number(n.target.value))},calendarMonthNames(t.session.locale).map((n,r)=>jsx("option",{value:r,children:n},r)))}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:n=>{let r=Number(n.target.value);if(!Number.isInteger(r)||r<100||r>9999){n.target.value=String(t.calendar.year);return}t.showMonth(r,t.calendar.month);},onKeyDown:n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&(n.preventDefault(),n.currentTarget.blur());}},void 0)}function Dp({autoOpen:e,...t}){let o=st(),n=Qe(),r=useRef(null),i=useRef(false);return useLayoutEffect(()=>{e!==false&&!i.current&&(i.current=true,r.current?.click());},[e]),et("input",t,{ref:r,type:"file",accept:o.accept,className:"docx-content-control-picture-input","data-docx-part":"picture","aria-label":n("contentControl.types.picture"),"aria-invalid":o.refused||void 0,onMouseDown:Xn,onCancel:o.cancel,onChange:a=>{let l=a.target.files?.[0];a.target.value="",l&&o.replaceImage(l);}},void 0)}function kR(e){let[t,o]=useState(e.session),[n,r]=useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsx(wR,{...e},n)}function wR({session:e,className:t,style:o,children:n}){let r=Qe(),i=zh(e),[a,l]=useState(e.signal.aborted),s=useRef(null),[c]=useState(()=>contentControlPopupOpener(e.anchor)),d=e.kind==="checkbox"&&n===void 0;if(useEffect(()=>{let u=()=>l(true);return e.signal.addEventListener("abort",u,{once:true}),e.signal.aborted&&u(),()=>e.signal.removeEventListener("abort",u)},[e]),useEffect(()=>{!d||e.signal.aborted||e.apply(e.value==="true"?"false":"true");},[d,e]),useLayoutEffect(()=>{if(a||d)return;let u=s.current,g=u?.ownerDocument,p=u&&e.anchor?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]),useEffect(()=>{let u=s.current;if(!u||a||d)return;let g=p=>{u.contains(p.target)||e.cancel();};return u.ownerDocument.addEventListener("pointerdown",g,true),()=>u.ownerDocument.removeEventListener("pointerdown",g,true)},[e,a,d]),a||d)return null;let m=r(`contentControl.types.${e.kind}`);return jsx(Uh,{value:i,children: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=>{contentControlPopupKeyDown(u.currentTarget,u.nativeEvent,e.cancel),i.listNavigation.keyDown(u.nativeEvent,u.currentTarget);},children:n??DR(i)})})}function DR(e){return e.kind==="date"?jsx(Tp,{}):e.kind==="picture"?jsxs(Fragment,{children:[jsx(Dp,{}),jsx(ta,{}),jsx(Ss,{})]}):e.kind==="comboBox"?jsxs(Fragment,{children:[jsx(Es,{}),jsx(Ts,{}),jsx(ta,{}),jsx(Ps,{})]}):jsxs(Fragment,{children:[jsx(Ts,{}),jsx(ta,{})]})}var Ip=Object.assign(kR,{Navigation:Pp,Month:kp,Year:wp,Calendar:Tp,Header:fp,PreviousMonth:gp,Title:hp,NextMonth:bp,Weekdays:yp,Grid:vp,Day:xp,Today:Cp,List:Ts,Item:Ep,Input:Es,Picture:Dp,Error:ta,Footer:Ps,Apply:Sp,Cancel:Ss});var Vh="(prefers-color-scheme: dark)";function Gh(){return typeof globalThis.window<"u"&&typeof globalThis.window.matchMedia=="function"}function jh(){return Gh()?globalThis.window.matchMedia(Vh).matches:false}function Yh(e,t){return e==="dark"||e==="system"&&t}function Xh(e){if(!Gh())return ()=>{};let t=globalThis.window.matchMedia(Vh);e(t.matches);let o=n=>e(n.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}function Fp(e){return e==="checkbox"?"contentControlCheckbox":e==="picture"?"contentControlPicture":"contentControlWidget"}function Qh(){let e=L(),t=St(),o=useRef(t);o.current=t;let[n,r]=useState(null),[i,a]=useState(null),l=t?.contentControlWidget!==void 0,s=t?.contentControlCheckbox!==void 0,c=t?.contentControlPicture!==void 0,d=t?.invalidTextFormField!==void 0;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?.[Fp(f.kind)]===false)return f.cancel();r(f),f.signal.addEventListener("abort",()=>{u&&r(h=>h===f?null:h);},{once:true});}},{fallback:true});return ()=>{u=false,p(),r(null);}},[e,l,s,c]),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]),useEffect(()=>{n&&t?.[Fp(n.kind)]===false&&n.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,n,i]);let m=n?t?.[Fp(n.kind)]:void 0;return jsxs(Fragment,{children:[n&&m&&Ee(m,{session:n},n),i&&t?.invalidTextFormField&&Ee(t.invalidTextFormField,{session:i},i)]})}var $R=["nw","n","ne","e","se","s","sw","w"],r0=40,a0=12;function VR(e){return `imageOverlay.handle.${e}`}function GR(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 jR(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 YR(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 Hp({containerRef:e,portalRef:t,scrollPort:o}){let n=L(),{t:r}=F(),[i,a]=useState(null),[l,s]=useState(null),[c,d]=useState({left:0,top:0}),m=useRef(null);m.current=l;let u=useRef(null),g=useRef(null),p=useRef(null),f=useRef(null),h=useRef(null);useEffect(()=>{let P=e.current;if(!P)return;let k=w=>{let D=isElementNode(w.target)?w.target:null;if(D?.closest(".docx-drawing-textbox-content")){f.current=null;return}let M=D?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");f.current=M??null,M&&M===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return P.addEventListener("pointerdown",k,{capture:true}),()=>P.removeEventListener("pointerdown",k,{capture:true})},[e,i?.id]),useEffect(()=>{if(!n){a(null);return}let P=()=>{a(selectedDrawingOverlayTargetOf(n.surface));},k=()=>{queueMicrotask(P);};P();let w=[n.on("change",k),n.on("selectionChange",P)];return ()=>{for(let D of w)D();}},[n]);let v=useCallback(()=>{d(P=>{let k=overlayHostOrigin(e.current);return k.left===P.left&&k.top===P.top?P:k});},[e]);useEffect(()=>{v();let P=t.current,k=hostWindowOf(P).ResizeObserver;if(!P||typeof k!="function")return;let w=new k(v);w.observe(P);let D=e.current;return D&&w.observe(D),()=>w.disconnect()},[e,t,v,i]),useEffect(()=>{if(o){h.current=o;return}let P=e.current;if(!P||!n?.surface)return;let k=P.closest(".docx-editor__scroll-container");if(!k)return;let w=n.surface.overlayCoordinates();return h.current=createImageOverlayScrollPort(k,w.paintScale),()=>{h.current=null;}},[e,n,o]);let b=useCallback(()=>{s(null),u.current=null;let P=g.current;if(g.current=null,P)try{P.releasePointerCapture(P._lastPointerId??0);}catch{}},[]),y=useCallback((P,k,w,D,M,H,I)=>{if(!n?.surface)return;let A=n.surface.activeScope();if(A.kind==="frame"&&!n.surface.selectDrawing(w.id,A.hostParagraphId))return;let S=n.surface.layout(),_=captureImageMutationPreconditions(n);if(_){u.current=Object.freeze({x:D,y:M}),g.current=H,H._lastPointerId=I;try{H.setPointerCapture(I);}catch{}s({session:Object.freeze({drawingNodeId:w.id,startBounds:Object.freeze({x:w.x,y:w.y,width:w.width,height:w.height}),startWidthEmu:w.widthEmu,startHeightEmu:w.heightEmu,startPosition:w.position,anchorFrameOrigin:w.anchorFrameOrigin,transform:w.transform,mode:P,handle:k,preconditions:_,layoutRevision:S.revision,packageRevision:n.surface.session.packageRevision(),kind:w.kind}),bounds:w,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});}},[n]),C=useCallback((P,k,w,D,M)=>{if(!n)return;if(isStaleImageInteractionCommit(n,P)){b();return}P.mode==="resize"?n.exec({type:"setImageProperties",widthEmu:k,heightEmu:w,...M?.mode==="simple"?{horizontalEmu:M.horizontalEmu,verticalEmu:M.verticalEmu}:{},...M?.mode==="frame"?{...M.horizontalEmu!==void 0?{horizontalEmu:M.horizontalEmu}:{},...M.verticalEmu!==void 0?{verticalEmu:M.verticalEmu}:{}}:{}}):P.mode==="move"&&M&&n.exec({type:"setImagePosition",...M}),b();},[b,n]),T=useCallback(P=>{if(!n)return;let k=m.current?.bounds??selectedDrawingOverlayTargetOf(n.surface);if(!k)return;if(m.current&&P.key==="Escape"){P.preventDefault(),P.stopPropagation(),b();return}if(m.current)return;let w=historyShortcutOf(P);if(w){P.preventDefault(),P.stopPropagation(),n.exec({type:w});return}let D=P.shiftKey?IMAGE_OVERLAY_NUDGE_SHIFT_PT:IMAGE_OVERLAY_NUDGE_PT;if(P.key==="Delete"||P.key==="Backspace"){P.preventDefault(),P.stopPropagation(),n.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(P.key))return;P.preventDefault(),P.stopPropagation();let M=P.key==="ArrowLeft"?-D:P.key==="ArrowRight"?D:0,H=P.key==="ArrowUp"?-D:P.key==="ArrowDown"?D:0;if(P.altKey){if(!k.canResize)return;let A=YR(M,H),S=computeImageResizeResult({handle:A,startWidthEmu:k.widthEmu,startHeightEmu:k.heightEmu,startBounds:{x:k.x,y:k.y,width:k.width,height:k.height},startPosition:k.position,anchorFrameOrigin:k.anchorFrameOrigin,deltaXPt:M,deltaYPt:H,transform:k.transform,preserveAspect:resizePreservesAspect(A,k.aspectLocked,P.shiftKey,k.textbox),kind:k.kind});n.exec({type:"setImageProperties",widthEmu:S.widthEmu,heightEmu:S.heightEmu,...S.position?.mode==="simple"?{horizontalEmu:S.position.horizontalEmu,verticalEmu:S.position.verticalEmu}:{},...S.position?.mode==="frame"?{...S.position.horizontalEmu!==void 0?{horizontalEmu:S.position.horizontalEmu}:{},...S.position.verticalEmu!==void 0?{verticalEmu:S.position.verticalEmu}:{}}:{}});return}if(k.kind!=="anchored"||!k.canMove||!k.position)return;let I=computeMovedImagePosition(k.position,M,H);n.exec({type:"setImagePosition",...I});},[b,n]);useEffect(()=>{if(!l||!n?.surface)return;let P=n.surface.overlayCoordinates(),k=M=>{let H=m.current,I=u.current;if(!H||!I)return;let A=cssPixelsToLayoutPoints(M.clientX-I.x,P.paintScale),S=cssPixelsToLayoutPoints(M.clientY-I.y,P.paintScale);if(H.session.mode==="move"){let B=0,Z=h.current,ee=e.current?.closest(".docx-editor__scroll-container");if(Z&&ee){let oe=ee.getBoundingClientRect();M.clientY>oe.bottom-r0?B=a0:M.clientY<oe.top+r0&&(B=-a0),B!==0&&(B=Z.scrollBy(B));}let j=H.accumulatedScrollPt+B;s({...H,accumulatedScrollPt:j,bounds:Object.freeze({...H.bounds,x:H.session.startBounds.x+A,y:H.session.startBounds.y+S+j})});return}if(!H.session.handle)return;let _=computeImageResizeResult({handle:H.session.handle,startWidthEmu:H.session.startWidthEmu,startHeightEmu:H.session.startHeightEmu,startBounds:H.session.startBounds,startPosition:H.session.startPosition,anchorFrameOrigin:H.session.anchorFrameOrigin,deltaXPt:A,deltaYPt:S,transform:H.session.transform,preserveAspect:resizePreservesAspect(H.session.handle,H.bounds.aspectLocked,M.shiftKey,H.bounds.textbox),kind:H.session.kind});s({...H,bounds:Object.freeze({...H.bounds,x:_.previewBounds.x,y:_.previewBounds.y,width:_.previewBounds.width,height:_.previewBounds.height,widthEmu:_.widthEmu,heightEmu:_.heightEmu})});},w=M=>{let H=m.current;if(H)if(M.type==="pointerup"){let I=cssPixelsToLayoutPoints(M.clientX-(u.current?.x??M.clientX),P.paintScale),A=cssPixelsToLayoutPoints(M.clientY-(u.current?.y??M.clientY),P.paintScale),S=finalizeImageOverlayInteraction({session:H.session,deltaXPt:I,deltaYPt:A,accumulatedScrollPt:H.accumulatedScrollPt,aspectLocked:H.bounds.aspectLocked,textbox:H.bounds.textbox,shiftKey:M.shiftKey,anchorFrameOrigin:H.session.anchorFrameOrigin});C(H.session,S.widthEmu,S.heightEmu,S.previewBounds,S.position);}else b();},D=hostWindowOf(e.current);return D.addEventListener("pointermove",k),D.addEventListener("pointerup",w),D.addEventListener("pointercancel",w),()=>{D.removeEventListener("pointermove",k),D.removeEventListener("pointerup",w),D.removeEventListener("pointercancel",w);}},[b,C,e,n,l]),useEffect(()=>{!i||f.current!==i.id||(f.current=null,p.current?.focus({preventScroll:true}));},[i]);let x=l?.bounds??i,E=useMemo(()=>{if(!n?.surface||!x)return null;let P=n.surface.publishedLayout(),k=n.surface.overlayCoordinates(),w=overlayFrameToSheetCssPixels(P,{pageIndex:x.pageIndex,x:x.x,y:x.y,width:x.width,height:x.height},k),D={left:w.left+c.left,top:w.top+c.top,width:w.width,height:w.height},M=x.canResize,H=x.kind==="anchored"&&x.canMove,I=textboxFrameReason(x,n.surface.editingMode()),A=I?r(I):void 0;return jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":x.id,tabIndex:0,onKeyDown:T,children:[jsx("div",{className:`docx-image-selection-overlay__frame${H?" docx-editor-one-surface__overlay-control":""}`,"data-textbox":x.textbox?"true":void 0,title:A,"aria-description":A,role:"group","aria-label":r("imageOverlay.selection"),style:{left:`${D.left}px`,top:`${D.top}px`,width:`${D.width}px`,height:`${D.height}px`,cursor:H?"move":"default"},onPointerDown:S=>{U(S),!(!H||!x.position)&&S.button===0&&(S.preventDefault(),S.stopPropagation(),y("move",null,x,S.clientX,S.clientY,S.currentTarget,S.pointerId));}}),M?$R.map(S=>{let _=jR(S);return jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(VR(S)),tabIndex:0,style:{left:`calc(${D.left}px + ${D.width}px * ${parseFloat(_.x)/100} - 5px)`,top:`calc(${D.top}px + ${D.height}px * ${parseFloat(_.y)/100} - 5px)`,cursor:GR(S)},onPointerDown:B=>{U(B),B.button===0&&(B.preventDefault(),B.stopPropagation(),y("resize",S,x,B.clientX,B.clientY,B.currentTarget,B.pointerId));}},S)}):null]})},[x,y,n,T,c.left,c.top,r]);return !E||!t.current?null:createPortal(E,t.current)}function Ap(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Ms({className:e}){let t=L(),o=Ua(),n=useRef(null),r=useContext(hr),i=useCallback(d=>{n.current=d,r?.setContainer(d);},[r]),a=useRef(null);useLayoutEffect(()=>{let d=n.current;if(!(!t||!d)){try{t.attach(d);}catch(m){if(t.snapshot().openFailure?.code!=="open.failed")throw m;console.error("[docx-editor] The document failed to open.",m);}return ()=>{t.detach();}}},[t]);let l=useCallback(d=>{if(!o?.isEnabled)return;let m=d.clipboardData;m&&Ap(m)&&(clipboardPasteLandsContent(m)||(d.preventDefault(),o.insertFromDataTransfer(m)));},[o]),s=useCallback(d=>{!o?.isEnabled||!Ap(d.dataTransfer)||d.preventDefault();},[o]),c=useCallback(d=>{if(o?.isEnabled&&Ap(d.dataTransfer)){if(clipboardDropLandsText(d.dataTransfer)){if((isElementNode(d.target)?d.target:null)?.closest("[contenteditable]")?.getAttribute("contenteditable")==="true")return;d.preventDefault();return}d.preventDefault(),o.insertFromDataTransfer(d.dataTransfer);}},[o]);return jsxs("div",{ref:a,className:"docx-content-mount",children:[jsx("div",{ref:i,className:`docx-paginated-surface${e?` ${e}`:""}`,onPaste:l,onDragOver:s,onDrop:c}),jsx(ch,{}),jsx(wh,{}),jsx(Qh,{}),t?jsx(Hp,{containerRef:n,portalRef:a}):null]})}function Bp({open:e,onClose:t,children:o,url:n,name:r,features:i,title:a,styles:l}){let[s,c]=useState(null),{dir:d}=F(),m=useRef(t);m.current=t;let u=useRef({url:n,name:r,features:i,title:a,styles:l});u.current={url:n,name:r,features:i,title:a,styles:l};let g=useRef(null);return useEffect(()=>{if(!e)return;let p=g.current;if(p)p.claimed=true;else {let{url:b,name:y,features:C,title:T,styles:x}=u.current;p={claimed:true,promise:openEditorWindow({...b!==void 0?{url:b}:{},...y!==void 0?{name:y}:{},...C!==void 0?{features:C}:{},...T!==void 0?{title:T}:{},...x!==void 0?{styles:x}:{}})},g.current=p;}let f=p,h=true,v;return f.promise.then(b=>{if(h){if(!b){g.current=null,m.current?.();return}v=b.onClose(()=>{h&&(g.current=null,flushSync(()=>c(null)),m.current?.());}),c(b);}}),()=>{h=false,v?.(),f.claimed=false,c(null),queueMicrotask(()=>{f.claimed||(g.current===f&&(g.current=null),f.promise.then(b=>b?.close()));});}},[e]),!s||!e?jsx(Fragment,{children:o}):createPortal(jsx("div",{className:"docx-editor",style:{height:"100%"},dir:d,children:o}),s.element)}function $e(e){return e/1440*96}function _s(e){return e/96*1440}function kt(e){return `${Math.round(e*100)/100}px`}function Wp(e){return e/2}var bM=e=>e.isLoading||e.isOpening===true,hM=e=>({width:$e(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:$e(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),yM=(e,t)=>e.width===t.width&&e.height===t.height;function Zp({className:e}){return jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}var c0=false;function d0(){c0||!gt()||(c0=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 xM(e){let t=L(),[o,n]=useState(null);return useEffect(()=>{if(!(!t||!e))return t.setOpeningIndicatorHost({publish:n}),()=>{t.setOpeningIndicatorHost(null),n(null);}},[t,e]),o}function vM({when:e=false,overlay:t=false,className:o,style:n,indicator:r,children:i}){let a=K(bM),l=K(hM,yM),s=xM(t),c=L(),d=useRef({visible:false,editor:null}),[,m]=useReducer(v=>v+1,0),u=d.current.visible&&d.current.editor!==c,g=s===null&&(e||a||u);useLayoutEffect(()=>{d.current={visible:g,editor:c},u&&m();},[g,c,u]);let{t:p}=F(),f=r??jsxs(Fragment,{children:[jsx(Zp,{}),jsx("span",{className:"docx-editor-sr-only",children:p("loading.label")})]});if(s)return createPortal(f,s);if(!g)return null;let h=`docx-editor docx-editor__loading${t?" docx-editor__loading--overlay":""}${o?` ${o}`:""}`;return jsx("div",{className:h,style:n,role:"status","aria-live":"polite",children:i??jsx("div",{className:"docx-paginated-surface docx-editor__loading-surface",style:{width:l.width,height:l.height},children:jsx("div",{className:"docx-pages",children:jsx("div",{className:"docx-page docx-editor__loading-page",children:jsx("div",{className:"docx-editor__loading-page-status",children:f})})})})})}var Is=Object.assign(vM,{Spinner:Zp});function u0(){let e=new Set,t=new Map,o=new Map,n=0,r=null,i=false;function a(){if(e.size===0&&t.size===0)return;if(t.size===0)return "kind";let u=Object.create(null),g=[...t].sort((p,f)=>(o.get(p[0])??0)-(o.get(f[0])??0));for(let[,{author:p,style:f}]of g)u[p]=f;return {authors:u,others:e.size>0?"kind":"author"}}let l=null,s=false;function c(u){if(u===void 0)return "none";if(typeof u=="string")return u;let g=Object.entries(u.authors).map(([p,f])=>`${p}\0${JSON.stringify(f)}`).sort();return `${u.others??"kind"}${g.join("")}`}function d(){if(!r)return;let u=a(),g=c(u);if(g!==l){if(u===void 0){i&&(r.setRevisionStyles("author"),i=false,l=g);return}r.setRevisionStyles(u),i=true,l=g;}}function m(){!r||s||(s=true,queueMicrotask(()=>{s=false,d();}));}return {registerScheme(u){e.add(u),m();},register(u,g,p){o.has(u)||o.set(u,n++),t.set(u,{author:g,style:p}),m();},unregister(u){(e.delete(u)||t.delete(u))&&m();},connect(u){r=u;let g=a();i=u!==null&&g!==void 0,l=u===null?null:c(g),m();},current:a}}var bi=createContext(null);function f0(){let e=useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function Kp(){let e=useContext(bi),t=f0();return useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function qp(e){let{author:t,color:o,background:n,activeBackground:r,spanClassName:i,avatarUrl:a}=e,l=useContext(bi),s=f0();return useEffect(()=>{if(l)return l.register(s,t,{...o!==void 0?{color:o}:{},...n!==void 0?{background:n}:{},...r!==void 0?{activeBackground:r}:{},...i!==void 0?{spanClassName:i}:{},...a!==void 0?{avatarUrl:a}:{}}),()=>l.unregister(s)},[l,s,t,o,n,r,i,a]),null}var g0=false;function b0(e,t){e===t||g0||!gt()||(g0=true,console.warn("[docx-editor] fieldResults changed after the editor was created, so the change is ignored. The editor reads fieldResults once; create a new editor to change it."));}var h0=false,y0=e=>e?.allowFormattingInLockedContent===true;function x0(e,t){y0(e)===y0(t)||h0||!gt()||(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 v0=false;function C0(e){return e===void 0?"characters":e}function T0(e,t){C0(e)===C0(t)||v0||!gt()||(v0=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 _M(e,t){if(e===t)return true;let o=resolveZoomMode(e),n=resolveZoomMode(t);return o!==null&&n!==null&&sameZoomMode(o,n)}function IM(e){let t=useRef(e);t.current=e;let[o,n]=useState(null),{onReady:r,onChange:i,onFontError:a,onRevisionMarkupChange:l,...s}=e,c=useMemo(()=>({onReady:d=>{n(d),t.current.onReady?.(d);},onChange:d=>t.current.onChange?.(d),onFontError:d=>t.current.onFontError?.(d),onRevisionMarkupChange:d=>t.current.onRevisionMarkupChange?.(d)}),[]);return {DocxEditorRoot:hi,rootProps:s,rootListeners:c,editorRef:o}}function hi(e){let{document:t,fonts:o,fontShaping:n,author:r,locale:i,translate:a,mode:l,zoom:s,zoomMode:c,tableInteractionLabel:d,imageDecodePort:m,children:u}=e,{t:g}=F(),p=useCallback((W,J)=>g(W,J),[g]),f=useRef(p);f.current=p;let h=useRef(false),[v,b]=useState(0),y=useRef(e);y.current=e;let C=n?.maxFontBytes,[T,x]=useState(null),E=useRef(e.fieldResults),P=useRef(e.contentLockPolicy),k=useRef(e.lockedControlNavigation),w=useRef(e.fonts),D=useRef(null);D.current??=u0();let M=D.current,H=useRef(null);H.current??=Vf();let I=H.current;useEffect(()=>{let W=y.current,J=W.translate??f.current,de=M.current();E.current=W.fieldResults,P.current=W.contentLockPolicy,k.current=W.lockedControlNavigation;let he=createDocxEditor({unsupportedElementRules:I.current(),...W.document!==void 0?{document:W.document}:{},...W.fonts?{fonts:W.fonts}:{},...W.fontShaping?{fontShaping:W.fontShaping}:{},...W.author!==void 0?{author:W.author}:{},...W.locale!==void 0?{locale:W.locale}:{},translate:J,...W.revisionMarkup!==void 0?{revisionMarkup:W.revisionMarkup}:{},...W.reviewDisplayMode!==void 0?{reviewDisplayMode:W.reviewDisplayMode}:{},...W.fieldResults!==void 0?{fieldResults:W.fieldResults}:{},...W.contentLockPolicy!==void 0?{contentLockPolicy:W.contentLockPolicy}:{},...W.lockedControlNavigation!==void 0?{lockedControlNavigation:W.lockedControlNavigation}:{},...W.mode!==void 0?{mode:W.mode}:{},...de!==void 0?{revisionStyles:de}:{},...W.modules!==void 0?{modules:W.modules}:{},...W.zoom!==void 0?{zoom:W.zoom}:{},...W.zoomMode!==void 0?{zoomMode:W.zoomMode}:{},...W.tableInteractionLabel?{tableInteractionLabel:W.tableInteractionLabel}:{},...W.imageDecodePort?{imageDecodePort:W.imageDecodePort}:{},onFontError:Ke=>y.current.onFontError?.(Ke)});w.current=W.fonts;let Oe=he.on("revisionMarkupChange",Ke=>{h.current||(y.current.onRevisionMarkupChange?.(Ke),b(Te=>Te+1));}),we=he.on("change",Ke=>y.current.onChange?.(Ke));return x(he),()=>{Oe(),we(),he.destroy(),x(Ke=>Ke===he?null:Ke);}},[t,C,m,M,I]),useEffect(()=>{!T||w.current===o||(w.current=o,T.setFonts(o).catch(()=>{}));},[T,o]),useEffect(()=>{if(!T)return;if(!T.snapshot().isOpening){y.current.onReady?.(T);return}let W=T.on("change",()=>{W(),y.current.onReady?.(T);});return W},[T]);let A=useRef({editor:null,zoom:void 0,mode:void 0});useEffect(()=>{if(!T)return;A.current.editor!==T&&(A.current={editor:T,zoom:void 0,mode:void 0});let J=false;s!==void 0&&s!==A.current.zoom&&(A.current.zoom=s,T.setZoom(s),J=true);let de=A.current.mode,he=c!==void 0&&(de===void 0||!_M(de,c)),Oe=c===void 0?null:resolveZoomMode(c),we=J&&c!==void 0&&Oe!==null&&Oe.type==="fit";(he||we)&&(A.current.mode=c,T.setZoomMode(c));},[T,s,c]),useEffect(()=>{if(!T||e.revisionMarkup===void 0)return;let W=resolveRevisionMarkup(e.revisionMarkup);if(JSON.stringify(W)!==JSON.stringify(T.snapshot().revisionMarkup)){h.current=true;try{T.setRevisionMarkup(W);}finally{h.current=false;}}},[T,e.revisionMarkup,v]),useEffect(()=>{T&&T.setAuthor(r);},[T,r]);let S=useRef({editor:null,value:void 0});useEffect(()=>{if(T){if(S.current.editor!==T){S.current={editor:T,value:l};return}S.current.value!==l&&(S.current.value=l,T.setMode(l));}},[T,l]),useEffect(()=>{T&&T.setTranslate(a??p);},[T,a,p]),useEffect(()=>{T&&T.setLocale(i);},[T,i]),useEffect(()=>{T&&b0(E.current,e.fieldResults);},[T,e.fieldResults]),useEffect(()=>{T&&x0(P.current,e.contentLockPolicy);},[T,e.contentLockPolicy]),useEffect(()=>{T&&T0(k.current,e.lockedControlNavigation);},[T,e.lockedControlNavigation]),useEffect(()=>{T&&T.setTableInteractionLabel(d??defaultTableLabel);},[T,d]);let[_,B]=useState(0),[Z,ee]=useState(0),j=useRef([]),[oe,$]=useState(0),V=oe>0,ce=useRef(T);ce.current=T,useEffect(()=>{if(!(!T||!V))return T.setCommentDraftChrome({onRequest:()=>j.current.at(-1)?.()})},[T,V]);let O=useMemo(()=>({mounted:_,register:()=>(B(W=>W+1),()=>B(W=>Math.max(0,W-1))),gutters:Z,reserveGutter:()=>(ee(W=>W+1),()=>ee(W=>Math.max(0,W-1))),registerCommentDraft:W=>(j.current.push(W),$(J=>J+1),()=>{let J=j.current.indexOf(W);J!==-1&&(j.current.splice(J,1),$(de=>Math.max(0,de-1)));}),requestCommentDraft:()=>{let W=ce.current;return W!==null&&runToolbarCommand(W,"review.addComment").ok}}),[_,Z]),N=useMemo(ig,[]);return useEffect(()=>(M.connect(T),()=>M.connect(null)),[M,T]),useEffect(()=>(I.connect(T),()=>I.connect(null)),[I,T]),jsx(hr.Provider,{value:I,children:jsx(rh,{value:a??p,children:jsx(Nt.Provider,{value:O,children:jsx(gd.Provider,{value:T,children:jsx(kd.Provider,{value:N,children:jsx(bi.Provider,{value:M,children:jsx(NM,{children:jsx(FM,{children:jsx(kh,{value:e.popups,children:jsx(Wl,{children:jsx(sh,{popups:e.popups,children:u})})})})})})})})})})})}function NM({children:e}){let t=Ml(true);return jsx(Fa.Provider,{value:t,children:e})}function FM({children:e}){let t=Il();return jsx(Jd.Provider,{value:t,children:e})}var yi=316,aa=REVIEW_MARKERS_GUTTER_PX,k0=24,Ns={inlineStart:0,inlineEnd:yi},E0={inlineStart:aa,inlineEnd:aa},qM={inlineStart:0,inlineEnd:0},$p={inlineStart:k0,inlineEnd:yi};function Gp(e){return e.inlineStart===$p.inlineStart&&e.inlineEnd===$p.inlineEnd}function w0(e,t){return Gp(e)?Math.max(0,t-(yi-aa)):t}function Fs(){let e=at(),t=Se(),[o,n]=useState("ltr");return useLayoutEffect(()=>{let r=t?.parentElement;if(e||!r)return;let i=()=>n(hostDirectionOf(r));return i(),observeHostDirection(r,i)},[e,t]),(e??o)==="rtl"?"left":"right"}function D0(e,t){return t==="left"?{left:e.inlineEnd,right:e.inlineStart}:{left:e.inlineStart,right:e.inlineEnd}}function R0({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:n=0,docked:r=false,scroll:i=false}){if(!e)return E0;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return Ns;let a=Number.isFinite(n)&&n>0?n:0;return t-a-o-2*k0>=yi?Ns:i?$p:E0}var UM=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,reviewPaneOpen:e.reviewPaneOpen??true,entitledZoom:reviewPaneEntitledZoom(t,e.zoom,e.reviewPane.overflow),scroll:e.reviewPane.overflow==="scroll"}},zM=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.scroll===t.scroll&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function M0(){let e=Se(),[t,o]=useState(null);return useEffect(()=>{if(!e){o(null);return}let n=()=>o(e.clientWidth);n();let r=hostWindowOf(e).ResizeObserver;if(typeof r>"u")return;let i=new r(n);return i.observe(e),()=>i.disconnect()},[e]),t}function fn(){let e=useContext(Nt),{pageSetup:t,reviewPaneOpen:o,entitledZoom:n,scroll:r}=K(UM,zM),i=Se(),a=sg(),l=useRef(null);t&&(l.current=t.pageWidthTwips);let s=t?.pageWidthTwips??l.current,c=vl(e),d=useCallback(f=>c?R0({open:o,viewportWidth:f??0,pageWidthPx:s===null||n===null?0:$e(s)*n,inlineStartReservation:a,docked:n===null,scroll:r}):qM,[c,o,s,n,a,r]),m=()=>d(i?i.clientWidth:null),[u,g]=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)),useEffect(()=>{let f=i?hostWindowOf(i).ResizeObserver:void 0;if(!i||typeof f>"u")return;let h=()=>g(b=>{let y=d(i.clientWidth);return y===b.gutter?b:{compute:d,viewport:i,gutter:y}}),v=new f(h);return v.observe(i),()=>v.disconnect()},[i,d]),p.gutter}var Ls=[.25,.5,.75,1,1.25,1.5,2];function xi(e,t){return t==="in"?Ls.find(n=>n>e+.001)??null:[...Ls].reverse().find(n=>n<e-.001)??null}function _0(e,t){return e==="0"?1:e==="+"||e==="="?xi(t,"in")??t:e==="-"?xi(t,"out")??t:null}var jp=createContext(false);function I0(e){let t=useContext(jp),[o,n]=useState(null);return useLayoutEffect(()=>{let r=t?e?.parentElement??null:null;n(r?{host:r,scoped:r.closest(".docx-editor")!==null}:null);},[t,e]),{inside:t,host:o?.host??null,hostScoped:o?.scoped??false}}var t1=e=>e.reviewPaneOpen??true,o1=e=>e.zoomMode?.type==="fit";function Hs({className:e,style:t,children:o}){let{t:n}=F(),r=Lt(),i=L(),a=K(t1),l=fn(),s=Fs(),c=K(o1),d=useContext(Nt),m=vl(d),u=Nn(),g=Fn(),p=useRef(null),f=useCallback(b=>{p.current=b,u?.setViewport(b);},[u]),h=s==="left"&&m&&Gp(l);useLayoutEffect(()=>{let b=p.current;return h&&b?keepScrollAtInlineEnd(b):void 0},[h]);let v=useCallback(b=>{if(!i||!(b.metaKey||b.ctrlKey)||b.altKey)return;let y=b.target;if(isElementNode(y)&&y.closest('input, textarea, select, [role="dialog"]'))return;let C=_0(b.key,i.getZoom());C!==null&&(b.preventDefault(),i.setZoom(C));},[i]);return jsx("div",{ref:f,"data-testid":"docx-editor-scroll",tabIndex:0,role:"region","aria-label":n("editor.documentViewport"),onKeyDownCapture:v,...m?{"data-review-pane":a?"open":"closed"}:{},...s==="left"?{"data-chrome-dir":"rtl"}:{},...m&&s==="left"?{"data-review-side":"left"}:{},...c?{"data-zoom-fit":""}:{},className:`${r}docx-editor-one-surface docx-editor-one-surface__viewport docx-editor__scroll-container${e?` ${e}`:""}`,style:{...t,"--docx-nav-shift":`${g}px`,...m?{"--docx-review-gutter":`${l.inlineEnd}px`,"--docx-review-gutter-start":`${l.inlineStart}px`,"--docx-review-strip":`${2*aa}px`}:{}},children:jsx(Gn.Provider,{value:true,children:jsx(jp.Provider,{value:true,children:o})})})}var r1=LOADING_SNAPSHOT;function F0({ref:e,editorRef:t}){useImperativeHandle(e,()=>({load:o=>t.current?.load(o),save:()=>t.current?.save()??Promise.resolve(null),getDocumentHandle:()=>t.current?.getDocumentHandle()??null,getEditor:()=>t.current,focus:()=>{t.current?.focus();},exec:(o,n)=>t.current?.exec(o,n)??{ok:false,code:"notFound",reason:"no editor is mounted"},snapshot:o=>t.current?.snapshot(o)??r1}),[t]);}function ia(e,t,o,n){let r=Se(),i=useRef({close:o,skip:n,viewport:r});i.current={close:o,skip:n,viewport:r},useEffect(()=>{let a=t.current;if(!e||!a)return;let l=d=>a.contains(d),s=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=listenForPopupFocusLeave({popup:a,contains:l,close:()=>i.current.close(false)});return ()=>{s(),c();}},[e,t]);}var g1=e=>e.editingMode??"editing",Jp='[role="menuitemradio"]:not([disabled])',b1=(e,t)=>e.length===t.length&&e.every((o,n)=>o===t[n]),h1=e=>e.isLoading||e.isOpening===true,vi=[{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(vi.map(()=>null));function x1(e){return e?vi.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):y1}var v1="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function Os({className:e,hidden:t}){let o=L(),n=K(g1),r=K(h1),i=ne(),{t:a}=F(),[l,s]=useState(false),c=useRef(null),d=useRef(null),m=useRef(null);useEffect(()=>{if(!l)return;let y=m.current?.querySelectorAll(Jp);(m.current?.querySelector(`${Jp}[aria-checked="true"]`)??y?.[0]??void 0)?.focus();},[l]);let u=useCallback(y=>{let C=[...m.current?.querySelectorAll(Jp)??[]],T=C.indexOf(hostDocumentOf(m.current).activeElement),x=E=>{y.preventDefault(),C[(E+C.length)%C.length]?.focus();};y.key==="ArrowDown"?x(T+1):y.key==="ArrowUp"?x(T-1):y.key==="Home"?x(0):y.key==="End"&&x(C.length-1);},[]);useEffect(()=>{if(l)return listenForOutsidePress({popup:c.current,close:()=>s(false)})},[l]),ia(l,c,y=>{s(false),y&&d.current?.focus();});let g=useCallback(y=>{s(false),runToolbarCommand(o,"review.editingMode",y),o?.focus();},[o]),p=toolbarCommandState(o,"review.editingMode"),f=localizeDisabledReason(p.disabledReason,a),h=K(()=>x1(o),b1),v=useMemo(()=>vi.find(y=>y.mode===n)??vi[0],[n]);if(t)return null;let b=te("review.editingMode");return jsxs("div",{ref:c,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[jsxs("button",{ref:d,type:"button",className:"docx-toolbar__picker","data-testid":"editing-mode-trigger","data-mode":n,"aria-haspopup":"menu","aria-expanded":l,"aria-label":i(b?.labelKey??"editingMode.label"),disabled:r||!p.enabled,...f?{title:f}:{},onMouseDown:U,onClick:()=>s(y=>!y),children:[Qp(v.path),jsx("span",{className:"docx-toolbar__picker-value",children:i(v.labelKey)}),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsx("div",{ref:m,className:"docx-toolbar__mode-menu",role:"menu","aria-label":i(b?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:vi.map((y,C)=>{let T=localizeDisabledReason(h[C]??null,a);return jsxs("button",{type:"button",role:"menuitemradio","aria-checked":y.mode===n,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${y.mode}`,disabled:T!==null,...T?{title:T}:{},onMouseDown:U,onClick:()=>g(y.mode),children:[Qp(y.path),jsxs("span",{className:"docx-toolbar__mode-text",children:[jsx("span",{className:"docx-toolbar__mode-label",children:i(y.labelKey)}),jsx("span",{className:"docx-toolbar__mode-hint",children:i(y.hintKey)})]}),jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:y.mode===n?Qp(v1):null})]},y.mode)})}):null]})}Os.docxSlot="review.editingMode";function Qp(e){return jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})})}var O0=[],E1=()=>{};function Ci(){let e=L(),t=useCallback(o=>{if(!e)return E1;let n=Da(o),r=e.on("change",n),i=e.on("selectionChange",n);return ()=>{r(),i();}},[e]);return useSyncExternalStore(t,()=>e?.getReviewAuthors()??O0,()=>O0)}var _1=e=>e.hiddenReviewAuthors??[];function Ws({className:e,hidden:t,icon:o}){let n=L(),r=Ci(),i=K(_1),a=new Set(i),l=r.every(C=>!a.has(C.author)),[s,c]=useState(false),d=useRef(null),m=useRef(null),u=useRef(null),g=ne(),{t:p}=F();useEffect(()=>{if(s)return u.current?.querySelector('[role="menuitemcheckbox"]')?.focus(),listenForOutsidePress({popup:d.current,close:()=>c(false)})},[s]),ia(s,d,C=>{c(false),C&&m.current?.focus();});let f=useCallback(C=>{let T=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],x=T.indexOf(hostDocumentOf(u.current).activeElement),E=P=>{C.preventDefault(),T[(P+T.length)%T.length]?.focus();};C.key==="ArrowDown"?E(x+1):C.key==="ArrowUp"?E(x-1):C.key==="Home"?E(0):C.key==="End"?E(T.length-1):C.key==="Tab"&&c(false);},[]);if(t)return null;let h=te("review.authors"),v=toolbarCommandState(n,"review.authors"),b=localizeDisabledReason(v.disabledReason,p),y=g(h?.labelKey??"reviewers.label");return jsxs("div",{ref:d,className:`docx-toolbar__reviewers${e?` ${e}`:""}`,"data-slot":"review.authors",children:[jsxs("button",{ref:m,type:"button",className:"docx-toolbar__picker","data-testid":"reviewers-trigger","aria-haspopup":"menu","aria-expanded":s,"aria-label":y,disabled:!v.enabled,title:b??y,onMouseDown:U,onClick:()=>c(C=>!C),children:[o??re(h?.paths),jsx("span",{className:"docx-toolbar__picker-value",children:y}),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),s?jsxs("div",{ref:u,className:"docx-toolbar__reviewers-menu",role:"menu","aria-label":y,"data-testid":"reviewers-menu",onKeyDown:f,children:[jsx(B0,{checked:l,label:p("reviewers.all"),testId:"reviewer-all",onChoose:()=>n?.setAllReviewAuthorsVisible(!l)}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),r.map(C=>jsx(B0,{checked:!a.has(C.author),label:C.author||"\u2014",testId:`reviewer-${C.slot}`,color:C.color,onChoose:()=>n?.setReviewAuthorVisible(C.author,a.has(C.author))},C.author))]}):null]})}Ws.docxSlot="review.authors";function B0(e){return 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:[jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:e.checked?"\u2713":""}),e.color?jsx("span",{className:"docx-toolbar__reviewer-swatch",style:{background:e.color}}):null,jsx("span",{className:"docx-toolbar__reviewer-name",children:e.label})]})}var Z0=createContext(null);function K0({children:e}){let t=To(),[o,n]=useState(false),r=useRef(null),i=Se(),a=useRef(i);a.current=i;let l=useMemo(()=>({open:c=>{if(t){t.open("paragraph",c);return}r.current=c??hostDocumentOf(a.current).activeElement,n(true);}}),[t]),s=useCallback(()=>{n(false);let c=r.current;r.current=null,isHTMLElementNode(c)&&c.isConnected&&c.focus({preventScroll:true});},[]);return jsxs(Z0.Provider,{value:l,children:[e,jsx(Zo,{open:o,onClose:s})]})}function q0(){return useContext(Z0)}var tm=["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"],om=createContext({close:()=>{}});function la(){return useContext(om).close}function J1(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function V0({label:e,children:t}){return jsxs("div",{className:"docx-toolbar__more-control",children:[jsx("span",{className:"docx-toolbar__more-control-label",children:e}),jsx("span",{className:"docx-toolbar__more-control-body",children:t})]})}function G0({slot:e}){let t=ne(),o=Ho(),{close:n}=useContext(om),{execute:r,isActive:i,isEnabled:a,disabledReason:l,value:s}=se(e),c=te(e),d=chromeSlotIsToggle(e),m=o(t(c?.labelKey??e));return 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=>{r(),n(u.detail===0);},children:[jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:re(c?.paths)}),jsx("span",{className:"docx-toolbar__more-command-label",children:m})]})}function j0({sections:e,className:t}){let o=ne(),[n,r]=useState(false),i=useRef(null),a=useRef(null),l=useRef(null),s=useRef(false),c=useId(),d=Se(),m=useRef(d);m.current=d;let u=o("formattingBar.more"),g=useCallback(b=>{r(false),b&&a.current?.focus();},[]),p=useMemo(()=>({close:g}),[g]);useEffect(()=>{if(!n)return;let b=i.current,y=E=>i.current?.contains(E)===true||l.current?.contains(E)===true,C=b?listenForPopupEscape({popup:b,contains:y,chromeRoot:()=>i.current?.closest(".docx-editor"),editorElements:()=>[m.current],skip:()=>hasOpenNestedPopup(l.current),close:g}):void 0,T=b?listenForPopupFocusLeave({popup:b,contains:y,close:()=>r(false)}):void 0,x=listenForOutsidePress({popup:b,close:()=>r(false)});return ()=>{x(),C?.(),T?.();}},[n,g]);let[f,h]=useState(null);useLayoutEffect(()=>{if(!n){h(null);return}let b=()=>{let C=i.current,T=l.current,x=a.current,E=C?.ownerDocument.defaultView;if(!C||!T||!x||!E)return;let P=x.getBoundingClientRect(),k=toolbarPanelPlacement({triggerLeft:P.left,triggerRight:P.right,panelWidth:T.offsetWidth,viewportWidth:E.innerWidth}),w=k.left-C.getBoundingClientRect().left;h(D=>D&&D.left===w&&D.maxWidth===k.maxWidth&&D.anchor===k.anchor?D:{...k,left:w});};b();let y=i.current?.ownerDocument.defaultView;return y?.addEventListener("resize",b),()=>y?.removeEventListener("resize",b)},[n]),useEffect(()=>{if(!n||!s.current)return;s.current=false;let b=l.current;b&&J1(b);},[n]);let v=b=>{b.key!=="Escape"||b.defaultPrevented||(b.preventDefault(),g(true));};return jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[Ka]:"",children:[jsx("button",{ref:a,type:"button",className:"docx-toolbar__button docx-toolbar__more-trigger","data-slot":"toolbar.more","aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?c:void 0,"aria-label":u,title:u,...n?{"data-active":""}:{},onMouseDown:U,onClick:()=>r(b=>!b),onKeyDown:b=>{b.key==="ArrowDown"&&(b.preventDefault(),s.current=true,r(true));},children:re(tm)}),n?jsx(om.Provider,{value:p,children: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:v,children:e.map(b=>jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":b.label??o(b.labelKey),children:[jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:b.label??o(b.labelKey)}),b.children]},b.id))})}):null]})}function e2(e){if(!isValidElement(e))return false;let t=e.type;return (typeof t=="function"||typeof t=="object")&&t.docxToolbarGroup===true}function X0(e,t,o,n){let r=new Map,i=new Map,a=new Map,l=[];for(let s of Children.toArray(e)){if(e2(s)){a.delete(s.props.id),a.set(s.props.id,s.props);continue}let c=t(s);if(c&&o(c))r.set(c,s);else if(c&&n(c))i.set(c,s);else {if(c&&isValidElement(s)&&s.props.hidden===true)continue;l.push(s);}}return {overrides:r,tableOverrides:i,groups:[...a.values()],appended:l}}function Ks(e,t){return e.label!==void 0?e.label:e.labelKey!==void 0?t(e.labelKey):e.id}function nm(e){let t=ne();return e.hidden?null:jsx("div",{role:"group","aria-label":Ks(e,t),className:`docx-toolbar__group${e.className?` ${e.className}`:""}`,"data-toolbar-host-group":e.id,children:e.children})}nm.docxToolbarGroup=true;function Ei(e){return e.hidden?null:jsx(Fragment,{children:e.children})}Ei.docxToolbarSlot=true;var rm=createContext("bar");function J0(){return useContext(rm)}var qs="review.addComment";function a2({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=useContext(Nt),a=ne(),{isEnabled:l,reason:s}=Fl(a),c=la();if(t||(i?.mounted??0)===0)return null;let d=te(qs),m=a(d?.labelKey??qs),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":qs,disabled:!l,...l?{}:{"data-disabled":""},"aria-label":m,title:s??m,onMouseDown:U,onClick:()=>{i?.requestCommentDraft()&&c(false);}};return n?jsx(X,{...u,children:r}):jsx("button",{...u,children:o??r??re(d?.paths)})}var am=Object.assign(a2,{docxSlot:qs});var ty=new Set;function Us(e){!gt()||ty.has(e)||(ty.add(e),console.warn(`[docx-editor] ${e}`));}function oy(e,t,o){Us(`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 ny(e,t){Us(`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 ry(e){Us(`Toolbar.Group "${e}" uses the id of the contextual table group, so it is ignored. Give the group another id.`);}function ay(e,t){Us(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 lm=[{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 $s({className:e,hidden:t,asChild:o,children:n}){let{t:r}=F(),i=ne(),{execute:a,value:l,isEnabled:s,disabledReason:c}=di("image.wrap"),[d,m]=useState(false),u=useRef(null),g=useRef(null),p=useRef(null),f=useId(),h=useMemo(()=>lm.find(x=>x.value===l)??lm[0],[l]),v=te("image.wrap"),b=i(v?.labelKey??"formattingBar.imageWrap");useEffect(()=>{if(!d)return;let x=k=>{let w=u.current;w&&isDomNode(k.target)&&w.contains(k.target)||m(false);},E=k=>{k.key==="Escape"&&(k.preventDefault(),m(false),g.current?.focus());},P=hostDocumentOf(u.current);return P.addEventListener("mousedown",x,true),P.addEventListener("keydown",E),()=>{P.removeEventListener("mousedown",x,true),P.removeEventListener("keydown",E);}},[d]);let y=useCallback(x=>{m(false),a(x);},[a]);if(t)return null;let C=r("imageWrap.tooltipPrefix",{label:r(h.labelKey)}),T={type:"button",ref:g,className:`docx-toolbar__button docx-toolbar__image-wrap-trigger${e?` ${e}`:""}`,"data-slot":"image.wrap",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?f:void 0,"aria-label":b,title:c??C,onMouseDown:U,onClick:()=>m(x=>!x)};return jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsx(X,{...T,children:n}):jsx("button",{...T,children:n??re(v?.paths)}),d?jsx("div",{ref:p,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:x=>x.stopPropagation(),children:lm.map(x=>jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":l===x.value,...l===x.value?{"data-active":""}:{},onMouseDown:U,onClick:()=>y(x.value),children:r(x.labelKey)},x.value))}):null]})}$s.docxSlot="image.wrap";var Si=Object.assign($s,{docxSlot:"image.wrap"});var sa="table.insert";function C2({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=L(),{isEnabled:a,disabledReason:l}=se(sa),s=ne(),[c,d]=useState(false),m=useRef(null),u=useRef(null),g=useRef(null),p=useId(),f=la();useEffect(()=>{if(!(!c||!m.current))return listenForOutsidePress({popup:m.current,close:()=>d(false)})},[c]),useEffect(()=>{c&&m.current?.querySelector('[role="gridcell"][tabindex="0"]')?.focus();},[c]);let h=c&&a;useLayoutEffect(()=>{let T=g.current,x=m.current,E=x?.ownerDocument.defaultView;if(!h||!T||!x||!E||x.closest(".docx-toolbar__more-panel"))return;let P=x.getBoundingClientRect(),k=toolbarPopupLeft({anchorLeft:P.left,popupWidth:T.offsetWidth,viewportWidth:E.innerWidth});T.style.left=`${k-P.left}px`;},[h]);let v=useCallback(()=>{d(false),f(false);},[f]);if(t)return null;let b=te(sa),y=s(b?.labelKey??sa),C={ref:u,type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":sa,disabled:!a,...a?{}:{"data-disabled":""},...h?{"data-active":""}:{},"aria-haspopup":"grid","aria-expanded":h,"aria-controls":h?p:void 0,"aria-label":y,title:l??y,onMouseDown:U,onClick:()=>{if(!c){d(true);return}d(false),i?.focus();},onKeyDown:T=>{T.key==="ArrowDown"&&(T.preventDefault(),d(true));}};return jsxs("span",{ref:m,className:"docx-toolbar__table-insert",children:[n?jsx(X,{...C,children:r}):jsx("button",{...C,children:o??r??re(b?.paths)}),h?jsx("div",{ref:g,id:p,className:"docx-toolbar__menu docx-toolbar__table-insert-menu",onBlur:T=>{let x=T.relatedTarget;isDomNode(x)&&!m.current?.contains(x)&&d(false);},onKeyDown:T=>{T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),d(false),u.current?.focus());},children:jsx(ql,{slot:sa,label:s("toolbar.insertTable"),onInserted:v})}):null]})}var cm=Object.assign(C2,{docxSlot:sa});function tt(e){return Object.assign(o=>jsx(Ao,{slotId:e,...o}),{docxSlot:e})}var ly=tt("history.undo"),sy=tt("history.redo"),cy=tt("text.bold"),dy=tt("text.italic"),uy=tt("text.underline"),py=tt("text.strike"),my=tt("format.clear"),fy=tt("script.super"),gy=tt("script.sub"),by=tt("alignment.left"),hy=tt("alignment.center"),yy=tt("alignment.right"),xy=tt("alignment.justify"),vy=tt("direction.ltr"),Cy=tt("direction.rtl"),Ty=tt("list.bullet"),Ey=tt("list.numbered"),Sy=tt("list.outdent"),Py=tt("list.indent");var ky=tt("review.comments");function k2({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=L(),{openAtCaret:a}=Wd(),l=chromeProbeForSlot("text.link"),s=i&&l?i.can(l):null,c=s?.ok===true,{t:d}=F(),m=localizeDisabledReason(s&&!s.ok?s.reason:null,d),u=ne();if(t)return null;let g=te("text.link"),p=u(g?.labelKey??"text.link"),f={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!c,...c?{}:{"data-disabled":""},"aria-label":p,title:m??p,onMouseDown:U,onClick:()=>a()};return n?jsx(X,{...f,children:r}):jsx("button",{...f,children:o??r??re(g?.paths)})}var dm=Object.assign(k2,{docxSlot:"text.link"});function w2({className:e,hidden:t}){let o=L(),{onSave:n}=useContext(Ln),r=ne();if(t)return null;let i=te("file.save"),a=r(i?.labelKey??"file.save"),l=!o||!n;return 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:()=>n?.(),children:re(i?.paths)})}var um=Object.assign(w2,{docxSlot:"file.save"});function Jn({className:e}){return jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}var M2=e=>({zoom:e.zoom,mode:e.zoomMode}),_2=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,Dy={type:"fixed"};function pm(){let e=L(),{zoom:t,mode:o}=K(M2,_2),n=useCallback(i=>{e?.setZoom(i);},[e]),r=useCallback(i=>{e?.setZoomMode(i);},[e]);return useMemo(()=>{let i=o??Dy,a=xi(t,"out"),l=xi(t,"in");return {zoom:t,mode:i,isFit:i.type==="fit",setZoom:n,setMode:r,fitToWidth:()=>r(FIT_WIDTH_ZOOM_MODE),auto:()=>r("auto"),reset:()=>{r(Dy),n(1);},zoomIn:()=>l!==null&&n(l),zoomOut:()=>a!==null&&n(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:Ls}},[e,t,o,n,r])}var wi=2,Di=3276,ki=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],L2=e=>e.formatting?.fontSizePt??null;function _y(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function Iy(e,t,o){for(let n=t.length-1;n>=0;n-=1)if(t[n]<e)return t[n];return Math.max(e-1,o)}function Ly(e){return 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:[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,jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canIncrease,"aria-label":e.increaseLabel,onMouseDown:U,onClick:e.onIncrease,children:"+"})]})}function H2(e){let t=e.trim().replace(/pt$/i,"").trim();if(t==="")return null;let o=Number(t);if(!Number.isFinite(o))return null;let n=Math.round(o*2);return n<wi||n>Di?null:n}function A2({className:e,hidden:t}){let o=L(),n=K(L2),{isEnabled:r,disabledReason:i}=se("font.size"),a=ne(),[l,s]=useState(false),[c,d]=useState(null),m=useRef(null);Lo(m,l,()=>s(false));let u=useRef(null),g=useId(),p=useCallback(x=>{if(!o)return;let E=commandForSlotValue("font.size",x);E&&o.can(E).ok&&o.exec(E);},[o]),f=useCallback(x=>{p(Math.min(Di,Math.max(wi,Math.round(x*2))));},[p]),h=useCallback(x=>{s(false),d(null),u.current?.blur(),x&&o?.focus();},[o]);if(useEffect(()=>{if(l)return listenForOutsidePress({popup:m.current,close:()=>{s(false),d(null);}})},[l]),t)return null;let v=r&&n!==null,b=n===null?"\u2014":String(Math.round(n*2)/2),y=c??b,C=n===null?null:Math.round(n*2)/2,T=()=>{if(c===null)return;let x=H2(c);x!==null&&p(x);};return jsxs("span",{ref:m,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsx(Ly,{className:e,groupLabel:a("fontSize.label"),decreaseLabel:a("fontSize.decrease"),increaseLabel:a("fontSize.increase"),middle:jsx("input",{ref:u,type:"text",inputMode:"decimal",className:"docx-toolbar__stepper-value docx-toolbar__stepper-value--boxed docx-toolbar__font-size-input",value:y,disabled:!r,role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-label":a("fontSize.label"),"aria-controls":l?g:void 0,autoComplete:"off",onChange:x=>{d(x.target.value),s(true);},onFocus:x=>{x.target.select(),s(true);},onClick:()=>s(true),onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),T(),h(true)):x.key==="Escape"?(x.preventDefault(),h(true)):(x.key==="ArrowDown"||x.key==="ArrowUp")&&(x.preventDefault(),s(true),n!==null&&f(x.key==="ArrowDown"?Iy(n,ki,wi/2):_y(n,ki,Di/2)));},onBlur:()=>{T(),d(null);}}),canDecrease:v&&Math.round(n*2)>wi,canIncrease:v&&Math.round(n*2)<Di,onDecrease:()=>f(Iy(n??0,ki,wi/2)),onIncrease:()=>f(_y(n??0,ki,Di/2))}),l&&r?jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox",tabIndex:0,"aria-label":a("fontSize.listLabel"),id:g,children:ki.map(x=>{let E=C===x;return jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":E,...E?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>{f(x),h(true);},children:x},x)})}):null]})}var gm=Object.assign(A2,{docxSlot:"font.size"});function O2({className:e,hidden:t}){let o=L(),{zoom:n,isFit:r,mode:i,setZoom:a,setMode:l,zoomIn:s,zoomOut:c,canZoomIn:d,canZoomOut:m,levels:u}=pm(),g=ne(),[p,f]=useState(false),h=useRef(null);Lo(h,p,()=>f(false)),useEffect(()=>{if(p)return listenForOutsidePress({popup:h.current,close:()=>f(false)})},[p]);let v=useCallback(x=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),a(x);},[a]),b=useCallback(x=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),l(x==="auto"?"auto":FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let y=`${Math.round(n*100)}%`,C=sameZoomMode(i,AUTO_ZOOM_MODE),T=sameZoomMode(i,FIT_WIDTH_ZOOM_MODE);return jsxs("span",{ref:h,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsx(Ly,{className:e,groupLabel:g("zoom.zoomLevel"),decreaseLabel:g("zoom.zoomOut"),increaseLabel:g("zoom.zoomIn"),middle: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")}: ${y}`,onMouseDown:U,onClick:()=>f(x=>!x),children:[y,jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:m,canIncrease:d,onDecrease:c,onIncrease:s}),p?jsxs("div",{className:"docx-toolbar__menu docx-toolbar__zoom-menu",role:"listbox",tabIndex:0,"aria-label":g("zoom.zoomLevel"),children:[jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>b("auto"),children:g("zoom.automatic")}),jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":T,...T?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>b("fit-width"),children:g("zoom.fitWidth")}),jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(x=>{let E=!r&&Math.abs(x-n)<.001;return jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":E,...E?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>v(x),children:`${Math.round(x*100)}%`},x)})]}):null]})}var bm=Object.assign(O2,{docxSlot:"zoom.level"});function Qn(e,t,o,n=false){let r=Se(),i=useRef(r);i.current=r,useEffect(()=>{e&&n&&t(false);},[e,n,t]),useEffect(()=>{let a=o.current;if(!e||n||!a)return;let l=m=>a.contains(m),s=listenForPopupEscape({popup:a,contains:l,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current],close:m=>{t(false),m&&a.querySelector("[aria-haspopup]")?.focus();}}),c=listenForPopupFocusLeave({popup:a,contains:l,close:()=>t(false)}),d=listenForOutsidePress({popup:a,contains:l,close:()=>t(false)});return ()=>{d(),s(),c();}},[e,n,t,o]);}var By=10,Wy=0,$2=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),V2=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function G2({className:e,hidden:t}){let o=L(),n=K($2,V2),{isEnabled:r,disabledReason:i}=se("list.lineSpacing"),a=se("paragraph.dialog"),l=q0(),s=ne(),{lang:c}=F(),[d,m]=useState(false),u=useRef(null),g=useRef(null);Qn(d,m,u,t);let p=useCallback(C=>{m(false),!(!o||!C.command)&&o.can(C.command).ok&&o.exec(C.command);},[o]),f=useCallback((C,T)=>{if(m(false),!o)return;let x={type:"setParagraphSpacing",[C]:T};o.can(x).ok&&o.exec(x);},[o]);if(t)return null;let h=te("list.lineSpacing"),v=(n.spaceBeforePt??0)>0,b=(n.spaceAfterPt??0)>0,y=lineSpacingMenuRows(n.lineSpacing);return jsxs("span",{ref:u,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[jsxs("button",{ref:g,type:"button",className:`docx-toolbar__button docx-toolbar__line-spacing-trigger${e?` ${e}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-label":s("lineSpacing.label"),title:i??s("lineSpacing.label"),onMouseDown:U,onClick:()=>m(C=>!C),children:[re(h?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),d&&r?jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[y.map(C=>{let T=C.selected;return jsxs("button",{type:"button",role:"menuitemradio","aria-checked":T,...T?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>p(C),children:[lineSpacingMenuRowLabel(C,s,c),T?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]},`${C.spacing.rule}:${C.spacing.value}`)}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),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")}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>f("beforePt",v?Wy:By),children:s(v?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>f("afterPt",b?Wy:By),children:s(b?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var hm=Object.assign(G2,{docxSlot:"list.lineSpacing"});var X2=["alignment.left","alignment.center","alignment.right","alignment.justify"];function J2({className:e,hidden:t}){let o=se("alignment.left"),n=se("alignment.center"),r=se("alignment.right"),i=se("alignment.justify"),a=ne(),[l,s]=useState(false),c=useRef(null);if(Qn(l,s,c,t),t)return null;let d=[o,n,r,i],m=X2.map((f,h)=>({slot:f,control:te(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 jsxs("div",{ref:c,className:`docx-toolbar__alignment${e?` ${e}`:""}`,"data-slot":"alignment",children:[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),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsx("div",{className:"docx-toolbar__menu docx-toolbar__alignment-popup",children:m.map(f=>{let h=a(f.control?.labelKey??f.slot);return 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 js=Object.assign(J2,{docxSlot:"alignment"});function xm(e){let{label:t,icon:o,active:n,disabled:r,disabledReason:i,onSelect:a,asChild:l,className:s,children:c}=e,d=J0(),m=la();if(d==="panel"&&!l)return jsxs("button",{type:"button",className:`docx-toolbar__more-command${s?` ${s}`:""}`,disabled:r,...n?{"data-active":""}:{},...n!==void 0?{"aria-pressed":n}:{},...r&&i?{title:i}:{},onMouseDown:g=>U(g),onClick:g=>{a?.(),m(g.detail===0);},children:[jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:o??c}),jsx("span",{className:"docx-toolbar__more-command-label",children:t})]});let u={type:"button",className:`docx-toolbar__button${s?` ${s}`:""}`,disabled:r,...n?{"data-active":""}:{},...r?{"data-disabled":""}:{},...n!==void 0?{"aria-pressed":n}:{},"aria-label":t,title:r?i??t:t,onMouseDown:g=>U(g),onClick:r?void 0:a};return l?jsx(X,{...u,children:c}):jsx("button",{...u,children:o??c})}var i_=Object.freeze([]),l_=e=>e.formatting?.fontFamily??null,s_=e=>e;function Js(){let e=L(),t=K(l_),o=K(s_),n=useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():i_,[e,o]),{isEnabled:r}=se("font.family"),i=useCallback(a=>{if(!e)return;let l=commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var Uy=createContext(null);function Cm(){return useContext(Uy)}function Tm({asChild:e,className:t,children:o}){let n=Cm(),r=ne();if(!n)return null;let i=r(te("font.family")?.labelKey??"font.family"),a={onClick:()=>n.setOpen(!n.open),onMouseDown:U,disabled:!n.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,"aria-label":o!==void 0?void 0:`${i}: ${n.value??"\u2014"}`,title:i},l=o??jsx("span",{children:n.value??"\u2014"});return e?jsx(X,{...a,children:l}):jsx("button",{type:"button",...a,children:l})}Tm.docxToolbarPart=true;var c_=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"]]),d_=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function zy({asChild:e,className:t,children:o}){let n=Cm(),r=ne(),[i,a]=useState("");if(useEffect(()=>{n?.open||a("");},[n?.open]),!n||!n.open)return null;let l={role:"listbox",tabIndex:0,"aria-label":r("font.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__font-family-content${t?` ${t}`:""}`},s;return o!==void 0?s=o:s=d_.map(d=>({...d,fonts:n.options.filter(m=>m.toLowerCase().includes(i.toLowerCase())&&(c_.get(m.toLowerCase())??"other")===d.category)})).filter(d=>d.fonts.length>0).map((d,m)=>jsxs("div",{role:"group",children:[m>0?jsx("div",{className:"docx-toolbar__menu-separator","aria-hidden":"true"}):null,d.labelKey?jsx("div",{className:"docx-toolbar__menu-label",children:r(d.labelKey)}):null,d.fonts.map(u=>jsx($y,{value:u},u))]},d.category)),e?jsx(X,{...l,children:s}):o!==void 0?jsx("div",{...l,children:s}):jsxs("div",{className:l.className,children:[jsx("input",{type:"search",className:"docx-toolbar__font-search","aria-label":r("font.search"),placeholder:r("font.search"),value:i,onChange:c=>a(c.target.value)}),jsx("div",{role:"listbox",tabIndex:0,"aria-label":r("font.selectAriaLabel"),className:"docx-toolbar__font-options",children:s})]})}function $y({value:e,asChild:t,className:o,children:n}){let r=L(),i=Cm();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),r?.focus();},className:`docx-toolbar__font-family-item${o?` ${o}`:""}`},s=n??jsx("span",{style:{fontFamily:e},children:e});return t?jsx(X,{...l,children:s}):jsxs("button",{type:"button",...l,children:[s,a?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function u_({hidden:e,asChild:t,className:o,children:n}){let r=Js(),[i,a]=useState(false),l=useRef(null);Lo(l,i,()=>a(false)),useEffect(()=>{if(i)return listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);if(e)return null;let c={className:`docx-toolbar__font-family${o?` ${o}`:""}`,"data-slot":"font.family"},d=n??jsxs(Fragment,{children:[jsx(Tm,{}),jsx(zy,{})]});return jsx(Uy.Provider,{value:s,children:t?jsx(X,{...c,ref:l,children:d}):jsx("div",{ref:l,...c,children:d})})}var Em=Object.assign(u_,{docxSlot:"font.family",Trigger:Tm,Content:zy,Item:$y});var m_={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},f_=new Set(["Title","Heading1","Heading2","Heading3"]),g_={Subtitle:"666666"},b_="#4a6c8c";function Vy(e){let t=m_[e.styleId],n={fontSize:t?`${t}px`:`${Math.min(Math.max(e.fontSize?e.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(e.bold??f_.has(e.styleId))&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic");let r=e.color??g_[e.styleId];return r?n.color=`#${r}`:e.styleId.startsWith("Heading")&&(n.color=b_),n}var h_=/^heading ([1-9])$/;function Sm(e,t){let o=e||t,n=h_.exec(o);return n?`Heading ${n[1]}`:o}function Gy(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:Sm(t.name,t.styleId),priority:99}))}function k_(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 w_=Object.freeze([]),D_=e=>e.formatting?.styleId??null,R_=e=>e;function Qs(){let e=L(),t=K(D_),o=K(R_),n=useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(a=>a.type==="paragraph").map(a=>({styleId:a.styleId,name:Sm(a.name,a.styleId),preview:a.preview})):w_,[e,o]),{isEnabled:r}=se("styles.style"),i=useCallback(a=>{if(!e)return;let l=commandForSlotValue("styles.style",a);l&&e.can(l).ok&&e.exec(l);},[e]);return useMemo(()=>({value:t,setValue:i,options:n,isEnabled:r}),[t,i,n,r])}var jy=createContext(null);function km(){return useContext(jy)}function wm({asChild:e,className:t,children:o}){let n=km(),r=ne();if(!n)return null;let i=te("styles.style"),a=r(i?.labelKey??"styles.style"),l={onClick:()=>n.setOpen(!n.open),onMouseDown:U,disabled:!n.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,title:a},s=n.options.find(d=>d.styleId===n.value),c=o??(n.value===null?jsx("span",{children:i?.valueKey?r(i.valueKey):"\u2014"}):jsx("span",{children:s?.name??n.value}));return e?jsx(X,{...l,children:c}):jsx("button",{type:"button",...l,children:c})}wm.docxToolbarPart=true;function Yy({asChild:e,className:t,children:o}){let n=ne(),r=km();if(!r||!r.open)return null;let i={role:"listbox",tabIndex:0,"aria-label":n("styles.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`},a=o??r.options.map(l=>jsx(Xy,{value:l.styleId},l.styleId));return e?jsx(X,{...i,children:a}):jsx("div",{...i,children:a})}function Xy({value:e,asChild:t,className:o,children:n}){let r=L(),i=km();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),r?.focus();},className:`docx-toolbar__style-item${o?` ${o}`:""}`},c=n??jsx("span",{style:l?k_(l.preview):void 0,children:l?.name??e});return t?jsx(X,{...s,children:c}):jsxs("button",{type:"button",...s,children:[c,a?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]})}function M_({hidden:e,asChild:t,className:o,children:n}){let r=Qs(),[i,a]=useState(false),l=useRef(null);Lo(l,i,()=>a(false)),useEffect(()=>{if(i)return listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=useMemo(()=>({...r,open:i,setOpen:a}),[r,i]);if(e)return null;let c={className:`docx-toolbar__style${o?` ${o}`:""}`,"data-slot":"styles.style"},d=n??jsxs(Fragment,{children:[jsx(wm,{}),jsx(Yy,{})]});return jsx(jy.Provider,{value:s,children:t?jsx(X,{...c,ref:l,children:d}):jsx("div",{ref:l,...c,children:d})})}var Dm=Object.assign(M_,{docxSlot:"styles.style",Trigger:wm,Content:Yy,Item:Xy});function Qy(e,t){let o=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:l,children:s})=>{let{isEnabled:c,disabledReason:d}=se(o),m=bo(),u=t==="showAll"?m.showAll:m.formFill,g=ne();if(i)return null;let p=te(o),f=g(p?.labelKey??e),h={type:"button",className:`docx-toolbar__button${r?` ${r}`:""}`,"data-slot":e,disabled:!c,...c?{}:{"data-disabled":""},...u?{"data-active":""}:{},"aria-pressed":u,"aria-label":f,title:d??f,onMouseDown:U,onClick:()=>{t==="showAll"?m.toggleShowAll():m.toggleFormFill();}};return l?jsx(X,{...h,children:s}):jsx("button",{...h,children:a??s??re(p?.paths)})},{docxSlot:o})}function I_({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=Pt.inspector,{isEnabled:a,disabledReason:l}=se(i),{inspectorOpen:s,openInspector:c}=bo(),d=ne();if(t)return null;let m=te(i),u=d(m?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Pt.inspector,disabled:!a,...a?{}:{"data-disabled":""},...s?{"data-active":""}:{},"aria-pressed":s,"aria-label":u,title:l??u,onMouseDown:U,onClick:()=>c()};return n?jsx(X,{...g,children:r}):jsx("button",{...g,children:o??r??re(m?.paths)})}function N_({className:e,hidden:t,icon:o,asChild:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l}=bo(),s=ne();if(t)return null;let c=Pt.remove,d=te(c),m=s(d?.labelKey??"contentControl.remove"),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Pt.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":m,title:a??m,onMouseDown:U,onClick:()=>{l();}};return n?jsx(X,{...u,children:r}):jsx("button",{...u,children:o??r??re(d?.paths)})}var ec=Qy(Pt.showAll,"showAll"),tc=Qy(Pt.formFill,"formFill"),oc=Object.assign(N_,{docxSlot:Pt.remove}),nc=Object.assign(I_,{docxSlot:Pt.inspector}),ex={[Pt.showAll]:ec,[Pt.formFill]:tc,[Pt.inspector]:nc,[Pt.remove]:oc};var da=Object.assign(e=>jsx(Ao,{slotId:"table.mergeCells",...e}),{docxSlot:"table.mergeCells"});function F_({icon:e,className:t,children:o,hidden:n}){let{isEnabled:r,disabledReason:i}=se("table.splitCell"),a=To(),l=ne();if(n||!a)return null;let s=l(te("table.splitCell")?.labelKey??"table.splitCell");return jsx("button",{type:"button","data-slot":"table.splitCell",className:`docx-toolbar__button${t?` ${t}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-label":s,"aria-haspopup":"dialog",title:i??s,onMouseDown:U,onClick:c=>a.open("splitCell",c.currentTarget),children:e??o??re(te("table.splitCell")?.paths)})}var ua=Object.assign(F_,{docxSlot:"table.splitCell"});function Rm(e,t){let o=L(),n=useRef(t);n.current=t,useEffect(()=>{if(!o)return;let r=((...i)=>{n.current(...i);});return o.on(e,r)},[o,e]);}var Z_=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],_m=createContext(null);function sx(){let e=useContext(_m);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function q_(e,t){let o=t.table,r=(e?.getSelectedTable()??null)?.blockId??"",i=o?`${r}|${o.rows}|${o.columns}|${o.rowIndex}|${o.columnIndex}`:"",a=t.selection,l=a?`${a.from&&"paraId"in a.from?a.from.paraId:""}|${a.to&&"paraId"in a.to?a.to.paraId:""}|${t.selectionCollapsed}`:"",s=e?.getTableCellSelection()??null,c=s?`${s.tableId}|${s.rows.from}-${s.rows.to}|${s.columns.from}-${s.columns.to}|${s.cellIds.join(",")}`:"";return {tableKey:i,selectionKey:l,cellSelectionKey:c,editable:t.editable,editingMode:t.editingMode??"editing"}}function U_(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function z_(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var ix={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function $_(e,t){let o={};for(let n of Z_){let r=tableChromeToolbarState(e,n,t);o[n]={enabled:r.enabled,disabledReason:r.disabledReason};}return o}function Im({children:e}){let t=L(),[o,n]=useState(DEFAULT_TABLE_CHROME_DRAFT),[r,i]=useState(ix);useEffect(()=>(()=>{}),[]);let a=K(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:""}),[]),U_,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=useCallback(()=>{if(!t){i(ix);return}let u=q_(t,t.snapshot());i(g=>z_(g,u)?g:u);},[t]);useEffect(()=>{l();},[l,a]),Rm("selectionChange",useCallback(()=>{l();},[l]));let s=r.tableKey!=="",c=useMemo(()=>t?$_(t,o):{},[t,o,r.tableKey,r.selectionKey,r.cellSelectionKey,r.editable,r.editingMode]),d=useCallback((u,g)=>{if(!t)return;let{result:p,nextDraft:f}=runTableChromeCommand(t,u,g,o);p.ok&&f&&n(f);},[t,o]),m=useMemo(()=>({visible:s,draft:o,setDraft:n,slotState:u=>c[u]??{enabled:false,disabledReason:"editor is not ready"},apply:d}),[s,o,c,d]);return jsx(_m.Provider,{value:m,children:e})}function V_(){let e=useContext(_m);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function ac(e){let t=V_(),o=t.slotState(e);return useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:n=>t.apply(e,n)}),[t,e,o])}function lc(e){(editorInstanceScope(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function sc({enabled:e,disabledReason:t,ariaLabel:o}){let{t:n}=F(),r=localizeDisabledReason(t,n),i=useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:U,"aria-label":o,...a?{"aria-describedby":a}:{},...r?{title:r}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:a&&r?jsx("span",{id:i,className:"docx-editor-sr-only",children:r}):null}}var J_='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function ux(e,t,o,n){useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll(J_)].filter(c=>c.closest('[role="menu"]')===r);queueMicrotask(()=>{let c=a();(c.find(m=>m.hasAttribute("data-selected")||m.hasAttribute("data-active"))??c[0])?.focus();});let s=c=>{if(c.defaultPrevented||c.isComposing||c.keyCode===229)return;let d=a();if(c.key==="Escape"){c.preventDefault(),t(false),i?.focus();return}if(c.key==="ArrowDown"){c.preventDefault(),Yt(d,hostDocumentOf(r).activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),Yt(d,hostDocumentOf(r).activeElement,-1);return}if(c.key==="Home"){c.preventDefault(),Xt(d,"first");return}if(c.key==="End"){c.preventDefault(),Xt(d,"last");return}if(c.key==="Enter"||c.key===" "){let m=hostDocumentOf(c.target).activeElement;isHTMLElementNode(m)&&d.includes(m)&&(c.preventDefault(),m.click());}};return r.addEventListener("keydown",s),()=>r.removeEventListener("keydown",s)},[e,t,o,n]);}function px(e,t,o,n){useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll('button:not([aria-disabled="true"])')].filter(s=>s.closest('[role="dialog"]')===r);queueMicrotask(()=>{a()[0]?.focus();});let l=s=>{if(s.key==="Escape"){s.preventDefault(),t(false),i?.focus();return}if(s.key==="Enter"||s.key===" "){let c=hostDocumentOf(s.target).activeElement,d=a();isHTMLElementNode(c)&&d.includes(c)&&(s.preventDefault(),c.click());}};return r.addEventListener("keydown",l),()=>r.removeEventListener("keydown",l)},[e,t,o,n]);}function yx(e,t,o){if(e)return n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),o(!t));}}function rI(e){return re(tableChromeIconPaths(e))}function xx(){return createContext(null)}function qo(e){let t=useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function Fm(e,t,o){let n=xx();function r({hidden:l,asChild:s,className:c,children:d}){let{visible:m,enabled:u,disabledReason:g,draft:p,apply:f}=ac(e),[h,v]=useState(false),b=useRef(null),y=useRef(null);Qn(h,v,b,l||!m);let C=useMemo(()=>({open:h,setOpen:v,enabled:u,disabledReason:g,apply:f,draft:p,triggerRef:y}),[h,u,g,f,p]);if(l||!m)return null;let T={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},x=d??jsxs(Fragment,{children:[jsx(i,{}),jsx(a,{})]});return jsx(n.Provider,{value:C,children:s?jsx(X,{...T,ref:b,children:x}):jsx("div",{ref:b,...T,children:x})})}function i({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,disabledReason:g,triggerRef:p}=qo(n),f=ne(),h=te(e),v=f(h?.labelKey??o),{shared:b,reasonNode:y}=sc({enabled:u,disabledReason:g,ariaLabel:v}),C={...b,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:yx(u,d,m)}:{}},T=c??jsxs(Fragment,{children:[re(h?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxs(Fragment,{children:[jsx(X,{...C,children:T}),y]}):jsxs("button",{...C,children:[T,y]})}i.docxToolbarPart=true;function a({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,triggerRef:g}=qo(n),p=ne(),f=useRef(null);if(ux(d&&u,m,f,g),!d||!u)return null;let h=te(e),v=p(h?.labelKey??o),b={ref:f,role:"menu","aria-label":v,className:`docx-table-chrome__panel${s?` ${s}`:""}`,onMouseDown:U};return l?jsx(X,{...b,children:c}):jsx("div",{...b,children:c})}return {Root:r,Trigger:i,Content:a,Ctx:n}}var _i=Fm("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function vx({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=qo(_i.Ctx),l=ne(),s=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),r(s.value);}},m=n??rI(s.icon);return t?jsx(X,{...d,children:m}):jsx("button",{...d,children:m})}function Cx(e){let{children:t}=e;return jsx(_i.Content,{...e,children:t??jsx("div",{className:"docx-table-chrome__target-grid",children:TABLE_BORDER_TARGET_OPTIONS.map(o=>jsx(vx,{value:o.value},o.value))})})}function aI(e){let{children:t}=e,o=t??jsxs(Fragment,{children:[jsx(_i.Trigger,{}),jsx(Cx,{})]});return jsx(_i.Root,{...e,children:o})}var Hi=Object.assign(aI,{docxSlot:"table.borderTarget",Trigger:_i.Trigger,Content:Cx,Item:vx}),Ii=Fm("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function Tx({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=qo(Ii.Ctx),l=ne(),s=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),r(s.value);}},m=n??jsxs(Fragment,{children:[jsx("span",{className:`docx-table-line ${s.previewClass}`,"aria-hidden":"true"}),jsx("span",{children:l(s.labelKey)})]});return t?jsx(X,{...d,children:m}):jsx("button",{...d,children:m})}function Ex(e){let{children:t}=e;return jsx(Ii.Content,{...e,children:t??TABLE_BORDER_STYLE_OPTIONS.map(o=>jsx(Tx,{value:o.value},o.value))})}function iI(e){let t=e.children??jsxs(Fragment,{children:[jsx(Ii.Trigger,{}),jsx(Ex,{})]});return jsx(Ii.Root,{...e,children:t})}var Ai=Object.assign(iI,{docxSlot:"table.borderStyle",Trigger:Ii.Trigger,Content:Ex,Item:Tx}),Ni=Fm("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function Sx({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=qo(Ni.Ctx),l=ne(),s=Number(e),c=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),r(c.size);}},u=n??jsxs(Fragment,{children:[jsx("span",{className:"docx-table-line docx-table-line--single",style:{height:`${c.previewThickness}px`},"aria-hidden":"true"}),jsx("span",{children:l(c.labelKey)})]});return t?jsx(X,{...m,children:u}):jsx("button",{...m,children:u})}function Px(e){let{children:t}=e;return jsx(Ni.Content,{...e,children:t??TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsx(Sx,{value:String(o.size)},o.size))})}function lI(e){let t=e.children??jsxs(Fragment,{children:[jsx(Ni.Trigger,{}),jsx(Px,{})]});return jsx(Ni.Root,{...e,children:t})}var Oi=Object.assign(lI,{docxSlot:"table.borderWidth",Trigger:Ni.Trigger,Content:Px,Item:Sx});function kx(e,t,o){let n=o?.defaultHex??"FF0000",r=xx();function i({hidden:d,asChild:m,className:u,children:g}){let{visible:p,enabled:f,disabledReason:h,draft:v,apply:b}=ac(e),[y,C]=useState(false),[T,x]=useState(n),E=useRef(null),P=useRef(null);Qn(y,C,E,d||!p);let k=useMemo(()=>({open:y,setOpen:C,enabled:f,disabledReason:h,apply:b,draft:v,triggerRef:P,lastHex:T,setLastHex:x}),[y,f,h,b,v,T]);if(d||!p)return null;let w={className:`docx-toolbar__colorsplit docx-table-chrome${u?` ${u}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},D=g??jsxs(Fragment,{children:[jsx(a,{}),jsx(l,{}),jsx(s,{clearFill:o?.clearFill??false})]});return jsx(r.Provider,{value:k,children:m?jsx(X,{...w,ref:E,children:D}):jsx("div",{ref:E,...w,children:D})})}function a({asChild:d,className:m,children:u}){let{enabled:g,disabledReason:p,apply:f,draft:h,lastHex:v}=qo(r),b=ne(),y=te(e),C=b(y?.labelKey??t),{shared:T,reasonNode:x}=sc({enabled:g,disabledReason:p,ariaLabel:C}),E=e==="table.borderColor"&&h.spec.color.kind==="hex"?h.spec.color.value:v??n,P={...T,className:`docx-toolbar__button docx-toolbar__colorsplit-main${m?` ${m}`:""}`,onClick:g?()=>f({kind:"hex",value:E}):void 0},k=u??jsxs(Fragment,{children:[re(y?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${E.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxs(Fragment,{children:[jsx(X,{...P,children:k}),x]}):jsxs("button",{...P,children:[k,x]})}a.docxToolbarPart=true;function l({asChild:d,className:m,children:u}){let{open:g,setOpen:p,enabled:f,disabledReason:h,triggerRef:v}=qo(r),b=ne(),y=te(e),C=b(y?.labelKey??t),{shared:T,reasonNode:x}=sc({enabled:f,disabledReason:h,ariaLabel:C}),E={...T,ref:v,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:yx(f,g,p)}:{}},P=u??"\u25BE";return d?jsxs(Fragment,{children:[jsx(X,{...E,children:P}),x]}):jsxs("button",{...E,children:[P,x]})}l.docxToolbarPart=true;function s({asChild:d,className:m,children:u,clearFill:g}){let{open:p,setOpen:f,enabled:h,apply:v,draft:b,triggerRef:y,lastHex:C,setLastHex:T}=qo(r),x=ne(),E=useRef(null);if(px(p&&h,f,E,y),!p||!h)return null;let P=x(t),k=e==="table.borderColor"&&b.spec.color.kind==="hex"?b.spec.color.value:C??n,w={ref:E,role:"dialog","aria-label":P,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${m?` ${m}`:""}`,onMouseDown:U},D=u??jsxs(Fragment,{children:[g?jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:U,onClick:()=>{f(false),v(null),lc(y.current);},children:[jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),x("table.clearCellFill")]}):null,jsx(Md,{apply:M=>{f(false),T?.(M),v({kind:"hex",value:M}),lc(y.current);},current:k})]});return d?jsx(X,{...w,children:D}):jsx("div",{...w,children:D})}function c({value:d,css:m,labelKey:u,asChild:g,className:p,children:f}){let{apply:h,setOpen:v,setLastHex:b,triggerRef:y}=qo(r),C=ne(),T=m??`#${d.toLowerCase()}`,x=u?C(u):d,E={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:T},"data-value":d,"aria-label":x,title:x,onMouseDown:U,onClick:()=>{v(false),b?.(d),h({kind:"hex",value:d}),lc(y.current);}};return g?jsx(X,{...E,children:f}):jsx("button",{...E,children:f})}return {Root:i,Main:a,Trigger:l,Content:s,Item:c,Ctx:r}}var Fi=kx("table.borderColor","table.borderColor",{defaultHex:"000000"});function sI(e){return jsx(Fi.Content,{...e,clearFill:false})}function cI(e){return jsx(Fi.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function dI(e){return jsx(Fi.Root,{...e})}var Bi=Object.assign(dI,{docxSlot:"table.borderColor",Trigger:Fi.Trigger,Content:sI,Item:cI,Main:Fi.Main}),Li=kx("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function uI(e){return jsx(Li.Content,{...e,clearFill:true})}function pI(e){return jsx(Li.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function mI(e){return jsx(Li.Root,{...e})}var Wi=Object.assign(mI,{docxSlot:"table.cellFill",Trigger:Li.Trigger,Content:uI,Item:pI,Main:Li.Main});function wx({overrides:e=new Map,separator:t=true}){return sx()?jsxs(Fragment,{children:[t?jsx(Jn,{}):null,[Hi,Bi,Ai,Oi,Wi].map(r=>{let i=e.get(r.docxSlot);return i?jsx(Fragment$1,{children:i},r.docxSlot):jsx(r,{},r.docxSlot)}),[da,ua].map(r=>{let i=e.get(r.docxSlot);return i?jsx(Fragment$1,{children:i},r.docxSlot):jsx(r,{},r.docxSlot)})]}):null}function Dx(){let e=ne(),{draft:t}=ac("table.borderTarget");return e(tableChromeLabelKeyForTarget(t.activeTarget))}var Hm=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill","table.mergeCells","table.splitCell"],fa="contextual-table",Am={"zoom.level":bm,"styles.style":Dm,"font.family":Em,"font.size":gm,"text.color":_d,"text.highlight":Id,"text.link":dm,"list.lineSpacing":hm,"review.editingMode":Os,"review.authors":Ws,"file.save":um,...ex,"table.borderTarget":Hi,"table.borderColor":Bi,"table.borderStyle":Ai,"table.borderWidth":Oi,"table.cellFill":Wi,"table.splitCell":ua,"image.insert":za,"image.properties":ea,"image.wrap":Si,"image.altText":ui},cc={id:fa,labelKey:"formattingBar.groups.table",entries:Hm.map(e=>({slot:e,Part:e==="table.mergeCells"?da:Am[e]}))},Rx=new Map;function vI(e){let t=Rx.get(e);return t||(t=o=>jsx(Ao,{slotId:e,...o}),Rx.set(e,t)),t}function CI(e,t){return formattingBarChromeGroups(e,{direction:t}).map(o=>o.id==="alignment"?{id:o.id,labelKey:o.labelKey,entries:[{slot:"alignment",Part:js}]}:{id:o.id,labelKey:o.labelKey,entries:o.controls.map(n=>{let r=chromeSlotId(o,n);return {slot:r,Part:Am[r]??vI(r)}})})}var TI=e=>e.image,EI=e=>e.isLoading||e.isOpening===true,SI=e=>e.table!==null;function PI(e){return e==="alignment"||e in Am}function uc(e){let t=wr(e,uc);if(t!==null)return t;if(!isValidElement(e))return null;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxToolbarSlot===true){let n=e.props.slotId;return typeof n=="string"?n:null}if(o.docxToolbarPart===true){let n=e.props,r=n.slotId??n.slot;if(typeof r=="string")return r}return null}function Lm(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(Lm);let t=uc(e);return t!=null&&Hm.includes(t)?true:isValidElement(e)?Children.toArray(e.props.children).some(Lm):false}function kI(e,t){return t?true:Children.toArray(e).some(Lm)}function wI(e){let t=Lt(),{className:o,t:n,onSave:r,preset:i=true,overflow:a=true,children:l}=e,s=useMemo(()=>({t:n,onSave:r}),[n,r]),c=Sl(n),d=K(TI),m=K(EI),u=K(SI),g=at(),p=g==="rtl",f=useMemo(()=>CI(d,p),[d,p]),h=useMemo(()=>new Set(f.flatMap(k=>k.entries.map(w=>w.slot))),[f]),v=useMemo(()=>i?X0(l,uc,k=>h.has(k),k=>Hm.includes(k)):null,[i,l,h]),b=useMemo(()=>v?DI(f,v):[],[f,v]),y=useMemo(()=>[...b.filter(k=>!k.pinned).map(k=>k.id),...u?[fa]:[]],[b,u]),C=useMemo(()=>{let k=new Map;for(let w of b)w.priority!==void 0&&k.set(w.id,w.priority);return collapseOrder(y,TOOLBAR_COLLAPSE_ORDER,k)},[b,y]),T=i&&a,{attach:x,overflow:E}=Al(T,y,C),P;if(!v)P=l;else {let{overrides:k,tableOverrides:w,appended:D}=v,M=B=>{let Z=k.get(B.slot);if(Z)return Z;let ee=B.Part;return jsx(ee,{})},H=B=>{let Z=w.get(B.slot);if(Z)return Z;let ee=B.Part;return jsx(ee,{})},I=[],A=[],S=0;for(let B of b){if(E.has(B.id)){let Z=B.entries.flatMap(j=>{let oe=Mx(j,k,c,B.labelKey,M);return oe===null?[]:[jsx(Fragment$1,{children:oe},j.slot)]}),ee=MI(B);if(ee!==null&&Z.push(jsx(Fragment$1,{children:ee},"host")),Z.length===0)continue;A.push({id:B.id,labelKey:B.labelKey,...B.heading?{label:Ks(B.heading,c)}:{},children:Z});continue}S>0&&I.push(jsx(Jn,{},`separator-${B.id}`)),S+=1,I.push(jsxs("div",{className:`docx-toolbar__group${B.className?` ${B.className}`:""}`,...B.heading?{role:"group","aria-label":Ks(B.heading,c)}:{},...B.pinned?{[Zn]:""}:{[ln]:B.id},children:[B.entries.map(Z=>jsx(Fragment$1,{children:M(Z)},Z.slot)),B.extras.length>0?jsx(Fragment$1,{children:B.extras},"host"):null]},B.id));}let _=E.has(fa);if(u&&_){let B=cc.entries.flatMap(Z=>{let ee=Mx(Z,w,c,cc.labelKey,H);return ee===null?[]:[jsx(Fragment$1,{children:ee},Z.slot)]});B.length>0&&A.unshift({id:cc.id,labelKey:cc.labelKey,children:B});}P=jsxs(Fragment,{children:[I,u&&!_?jsx(Jn,{},"separator-contextual-table"):null,_?null:jsx("div",{className:"docx-toolbar__contextual",[ln]:fa,children:jsx(wx,{overrides:w,separator:false})}),D.length>0?jsx("div",{className:"docx-toolbar__group",[Zn]:"",children:D}):null,A.length>0?jsx(j0,{sections:A}):null]});}return jsx(Ln.Provider,{value:s,children:jsx(K0,{children:jsx("fieldset",{ref:x,disabled:m,"aria-label":c("formattingBar.label"),"data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,dir:g,...T?{"data-overflow":""}:{},onMouseDown:U,children:kI(l,i)?jsx(Im,{children:P}):P})})})}function Om(e){if(!e)return false;if(e.type===Fragment$1){let t=Children.toArray(e.props.children).find(o=>uc(o)!==null);return isValidElement(t)?Om(t):false}return !!e.props.hidden}function DI(e,t){let o=new Map(t.groups.map(s=>[s.id,s])),n=new Set(e.map(s=>s.id)),r=new Map;for(let s of e){let c=o.get(s.id);if(c&&RI(c),c?.hidden)continue;let d=Children.toArray(c?.children);!s.entries.some(u=>!Om(t.overrides.get(u.slot)))&&d.length===0||r.set(s.id,{id:s.id,labelKey:s.labelKey,heading:void 0,entries:s.entries,extras:d,pinned:c?.pinned??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===fa&&ry(s.id);let i=t.groups.filter(s=>!n.has(s.id)&&s.id!==fa);for(let s of i){let c=Children.toArray(s.children);s.hidden||c.length===0||r.set(s.id,{id:s.id,labelKey:s.labelKey??s.id,heading:{id:s.id,label:s.label,labelKey:s.labelKey},entries:[],extras:c,pinned:s.pinned===true,priority:s.priority,overflowContent:s.overflowContent,className:s.className,host:true});}let a=[...n,...i.map(s=>s.id)];for(let s of i)s.after!==void 0&&!a.includes(s.after)&&oy(s.id,s.after,a);for(let s of t.appended){if(!isValidElement(s)||s.type!==Ei)continue;let c=s.props.slotId;ay(c,te(c)!==null);}return arrangeToolbarGroups(e.map(s=>s.id),i.map(s=>({id:s.id,after:s.after}))).flatMap(s=>{let c=r.get(s);return c?[c]:[]})}function RI(e){for(let t of ["label","labelKey","after"])e[t]!==void 0&&ny(e.id,t);}function MI(e){return e.overflowContent?e.overflowContent():e.extras.length===0?null:jsx(rm.Provider,{value:"panel",children:jsx("div",{className:"docx-toolbar__more-host",children:e.extras})})}function Mx(e,t,o,n,r){let i=t.get(e.slot);if(Om(i))return null;let a=i?.type===Ei?i.props.overflowContent:void 0;return i||PI(e.slot)?jsx(V0,{label:_I(o,e,n),children:a?a():r(e)}):jsx(G0,{slot:e.slot})}function _I(e,t,o){let n=t.slot==="alignment"?null:te(t.slot);return e(n?.labelKey??o)}var Ki=Object.assign(wI,{Button:Ao,Action:xm,Separator:Jn,Group:nm,Slot:Ei,AddComment:am,Undo:ly,Redo:sy,Bold:cy,Italic:dy,Underline:uy,Strike:py,Link:dm,ClearFormatting:my,Superscript:fy,Subscript:gy,Alignment:js,AlignLeft:by,AlignCenter:hy,AlignRight:yy,AlignJustify:xy,LeftToRight:vy,RightToLeft:Cy,LineSpacing:hm,BulletList:Ty,NumberedList:Ey,Outdent:Sy,Indent:Py,ImageInsert:za,ImageProperties:ea,ImageWrap:Si,ImageAltText:ui,TableInsert:cm,TableBorderTarget:Hi,TableBorderColor:Bi,TableBorderStyle:Ai,TableBorderWidth:Oi,TableCellFill:Wi,TableMergeCells:da,TableSplitCell:ua,Comments:ky,FontFamily:Em,FontSize:gm,FontColor:_d,Highlight:Id,Zoom:bm,StylePicker:Dm,EditingMode:Os,Reviewers:Ws,Save:um,ContentControlShowAll:ec,ContentControlFormFill:tc,ContentControlInspector:nc,ContentControlRemove:oc});var Ix=/^(con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])$/i,LI=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g,HI=200,Nx=new TextEncoder;function AI(e,t){if(Nx.encode(e).length<=t)return e;let o=0,n="";for(let r of e){let i=Nx.encode(r).length;if(o+i>t)break;o+=i,n+=r;}return n}function Fx(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 Lx(e){return Fx(Fx(e).replace(/\.docx$/i,""))}function pc(e){let t=(e??"").replace(LI," ").replace(/\s+/g," ").trim(),o=Lx(t).replace(/^[. ]+/,""),n=AI(o,HI),r=n===o?o:Lx(n);return !r||Ix.test(r)?"document.docx":Ix.test(r.split(".",1)[0].trim())?`_${r}.docx`:`${r}.docx`}function mc(e,t,o="application/vnd.openxmlformats-officedocument.wordprocessingml.document",n){let r=URL.createObjectURL(new Blob([e],{type:o})),i=hostDocumentOf(n).createElement("a");i.href=r,i.download=t,i.click(),hostWindowOf(n).setTimeout(()=>URL.revokeObjectURL(r),0);}function Hx(e,t,o){let{t:n}=F(),r=useRef(false),[i,a]=useState(false),[l,s]=useState(""),[c,d]=useState("pdf"),[m,u]=useState(false),[g,p]=useState({});return {pending:i,error:l,format:c,visible:m,session:g,dismiss:()=>u(false),execute:async h=>{if(!(!e||r.current)){r.current=true,p({}),d(h),u(true),a(true),s("");try{let v=await runChromeExport(e,h,t);mc(v.bytes.slice().buffer,pc(o).replace(/\.docx$/,`.${v.extension}`),v.mimeType),u(!1);}catch(v){u(true),s(v instanceof ChromeExportError?n(v.format==="markdown"?"toolbar.exportMarkdownMissing":"toolbar.exportPdfMissing"):n("toolbar.exportFailed",{message:v instanceof Error?v.message:String(v)}));}finally{r.current=false,a(false);}}}}}function Ox(e,t,o){let{t:n}=F(),r=useRef({editor:e,exporters:t,feedback:o,t:n});r.current={editor:e,exporters:t,feedback:o,t:n};let i=useRef(null),a=useRef(null),[l,s]=useState(false),[c,d]=useState(""),[m,u]=useState(""),[g,p]=useState(false),[f,h]=useState(false),[v,b]=useState({}),y=useCallback(x=>{let{t:E}=r.current;if(x instanceof ChromeExportError)return E("toolbar.printPdfMissing");if(x instanceof ChromePrintError){if(x.code==="pdf-viewer-unavailable")return E("toolbar.printNoViewer");if(x.code==="pdf-load-failed")return E("toolbar.printLoadFailed");if(x.code==="print-refused")return E("toolbar.printRefused")}return E("toolbar.printFailedMessage",{message:x instanceof Error?x.message:String(x)})},[]),C=useCallback(()=>{i.current=null,h(false),p(false),s(false);},[]),T=useCallback(async x=>{let{editor:E,exporters:P}=r.current;if(!E||i.current)return;let k={};i.current=k,a.current?.dispose(),a.current=null,b(k),h(true),p(true),s(true),d(""),u("");try{let w=await runChromePrint(E,P,x??hostDocumentOf(null));if(i.current!==k){w.dispose();return}a.current=w,await w.print({beforePrint:()=>{if(i.current!==k)throw new ChromePrintError("print-ended");flushSync(()=>p(!1));}}),i.current===k&&C();}catch(w){if(i.current!==k)return;if(!r.current.feedback){console.error("[docx-editor] print failed",w),C();return}s(false),u(a.current?.url??""),d(y(w)),p(true);}},[C,y]);return useEffect(()=>()=>{i.current=null,a.current?.dispose(),a.current=null;},[]),{pending:l,error:c,url:m,visible:g,active:f,session:v,execute:T,close:C}}var GI=()=>{};function Zm(){let e=L(),t=useCallback(n=>e?e.on("hostChange",n):GI,[e]),o=useCallback(()=>e?editorHostDocument(e):typeof globalThis.document>"u"?null:globalThis.document,[e]);return useSyncExternalStore(t,o,()=>null)}var jI="https://github.com/eigenpal/docx-editor/issues/new";function YI(){if(typeof globalThis.window>"u")return "";try{let e=new URL(globalThis.window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function Wx(e={}){let t=e.userAgent??(typeof globalThis.navigator<"u"?globalThis.navigator.userAgent:"unknown"),o=e.viewport??(typeof globalThis.window<"u"?{width:globalThis.window.innerWidth,height:globalThis.window.innerHeight}:{width:0,height:0}),r=["### What happened","","### Steps to reproduce","1. ","2. ","3. ","","### Expected","","### Actual","","### Attach the DOCX","Please drag the `.docx` file that reproduces this onto the issue (below this text box). Bugs are much faster to fix with a real file.","","### Environment",`- URL: ${e.pageUrl??YI()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
2
- `),i=new URLSearchParams({title:"[Bug] ",body:r});return `${jI}?${i.toString()}`}function Ui(e){typeof globalThis.window>"u"||globalThis.window.open(Wx(e),"_blank","noopener,noreferrer");}function XI({className:e,hidden:t,onSelect:o}){let{setOpenMenu:n,onReportIssue:r,reportIssue:i}=it(),a=Re();if(t||i===false)return null;let l=o??r??Ui;return jsx(Me,{slot:"help.reportIssue",onSelect:()=>{l(),n(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var fc=Object.assign(XI,{docxSlot:"help.reportIssue"});function JI({children:e,...t}){let{reportIssue:o}=it();return e===void 0&&o===false?null:jsxs(Qt,{id:"help",...t,children:[jsx(fc,{}),e]})}var Km=Object.assign(JI,{docxMenu:"help"});var o8=e=>e.hiddenReviewAuthors??[];function gc({className:e,hidden:t}){let o=L(),n=Ci(),r=K(o8),i=Re(),{t:a}=F();if(t)return null;let l=i("reviewers.label"),s=toolbarCommandState(o,"review.authors"),c=localizeDisabledReason(s.disabledReason,a);if(!s.enabled)return jsx(Me,{disabled:true,title:c??void 0,slot:"review.authors",children:l});let d=new Set(r),m=n.every(u=>!d.has(u.author));return jsxs(Jt,{labelKey:"reviewers.label",className:e,children:[jsx(Kx,{checked:m,label:i("reviewers.all"),slot:"reviewer-all",onChoose:()=>o?.setAllReviewAuthorsVisible(!m)}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),n.map(u=>jsx(Kx,{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 Kx(e){return jsx(Me,{active:e.checked,slot:e.slot,className:"docx-menubar__reviewer-item",icon:jsx("span",{className:"docx-menubar__reviewer-check",children:e.checked?"\u2713":""}),onSelect:e.onChoose,children:e.label})}function n8({children:e,...t}){return jsxs(Qt,{id:"review",...t,children:[jsx(Jt,{labelKey:"reviewers.markupOptions",className:"docx-menubar__markup-options",children:jsx(gc,{className:"docx-menubar__reviewers-submenu"})}),e]})}var bc=Object.assign(n8,{docxMenu:"review"});var c8={file:Eu,format:Su,insert:Pu,review:bc,help:Km};function zi(e,t=false){if(!isValidElement(e))return null;if(e.type===Fragment$1){let i=Children.toArray(e.props.children).map(a=>zi(a,t)).filter(a=>a!==null);return i.length===1?i[0]:null}let o=e.props;if(o.hidden===true&&!t)return null;let n=e.type;return (typeof n=="function"||typeof n=="object")&&typeof n.docxMenu=="string"?n.docxMenu:e.type===Qt&&typeof o.id=="string"?o.id:null}var d8=new Set(CHROME_MENUS.map(e=>e.id));function vc(e){if(!isValidElement(e))return null;if(e.type===Fragment$1){let n=Children.toArray(e.props.children).map(vc).filter(r=>r!==null);return n.length===1?n[0]:null}let t=e.type;if((typeof t=="function"||typeof t=="object")&&typeof t.docxMenu=="string")return t.docxMenu;if(e.type===Qt){let o=e.props.id;if(typeof o=="string"&&d8.has(o))return o}return null}var u8=e=>e.isOpening===true;function p8(e){let t=To(),o=St(),n=Lt(),r=at(),{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:v}=e,b=L(),{t:y}=F(),[C,T]=useState(null),x=K(u8);useEffect(()=>{x&&T(null);},[x]);let[E,P]=useState(null),k=Hx(b,s,l??E??void 0),{pending:w,execute:D}=k,M=Ox(b,s,o?.print!==false),{active:H,execute:I}=M,A=M.visible&&o?.print!==false,[S,_]=useState(null),[B,Z]=useState(false),[ee,j]=useState(false),[oe,$]=useState(false),V=useRef(null),ce=useRef(null);useEffect(()=>{if(C!==null)return listenForOutsidePress({popup:V.current,close:()=>T(null)})},[C]),ia(C!==null,V,()=>T(null),ie=>isDomNode(ie.target)&&V.current?.contains(ie.target)===true);let O=useCallback(ie=>{T(ie),ie!==null&&_(ie);},[]),N=useCallback(()=>ce.current?.click(),[]),W=useCallback(()=>{b&&b.save().then(ie=>mc(ie,pc(l??E??void 0),void 0,V.current)).catch(ie=>{console.error("[docx-editor] save failed",ie);});},[b,l,E]),J=useCallback(()=>t?t.open("pageSetup",V.current?.querySelector('[data-menu="file"] > [role="menuitem"]')):Z(true),[t]),de=b?c??N:void 0,he=b?m??W:void 0,Oe=!!s?.pdf,we=useMemo(()=>b&&!H?()=>{cu(V.current),I(editorInstanceScope(V.current)??V.current??void 0);}:void 0,[b,H,I]),Ke=b?t?.ownsPageSetup?J:u??J:void 0,Te=Zm();useEffect(()=>{let ie=xe=>{if(!(xe.metaKey||xe.ctrlKey)||xe.altKey||xe.shiftKey)return;let Ct=xe.key.toLowerCase(),Fo=isChromePrintShortcut(xe);if(Ct!=="s"&&Ct!=="o"&&!Fo)return;let Qo=xe.target,_n=editorInstanceScope(V.current)??V.current;if(!(!Qo||!((_n?.contains(Qo)??false)||Vg(Qo,hostDocumentOf(V.current),b?editorHostElement(b):null))))if(Fo){if(!Oe||!b||!we&&!A)return;xe.preventDefault(),we?.();}else Ct==="s"&&he?(xe.preventDefault(),he()):Ct==="o"&&de&&(xe.preventDefault(),de());},ge=hostDocumentOf(V.current),qe=Te&&Te!==ge?[ge,Te]:[ge];for(let xe of qe)xe.addEventListener("keydown",ie);return ()=>{for(let xe of qe)xe.removeEventListener("keydown",ie);}},[de,he,we,A,Oe,b,Te]);let Io=useMemo(()=>({t:a,openMenu:C,setOpenMenu:O,activeMenu:S,onOpen:de,onSave:he,onExport:b&&!w?ie=>(cu(V.current),D(ie)):void 0,onPrint:we,printShortcut:Oe,onPageSetup:Ke,onParagraphDialog:()=>t?t.open("paragraph",V.current?.querySelector('[data-menu="format"] > [role="menuitem"]')):j(true),onWatermarkDialog:b?()=>t?t.open("watermark",V.current?.querySelector('[data-menu="insert"] > [role="menuitem"]')):$(true):void 0,onReportIssue:g,reportIssue:p,opening:x}),[x,b,w,D,we,Oe,a,C,O,S,de,he,Ke,t,g,p]),co=Children.toArray(v),_t=[];if(f){let ie=new Map(co.map(ge=>[vc(ge),ge]));for(let ge of CHROME_MENUS){let qe=ie.get(ge.id);(qe===void 0||zi(qe)!==null)&&_t.push(ge.id);}for(let ge of co){if(vc(ge)!==null)continue;let qe=zi(ge);qe!==null&&_t.push(qe);}}else for(let ie of co){let ge=zi(ie);ge!==null&&_t.push(ge);}let Xo=[..._t].reverse(),{attach:Mn,overflow:ae}=Al(h,_t,Xo),rt=useMemo(()=>({measuring:h,overflow:ae,inMore:false}),[h,ae]),Ie=useMemo(()=>({measuring:false,overflow:ae,inMore:true}),[ae]),uo=ie=>zi(ie,true)!==null,Jo=(ie,ge)=>jsx("div",{role:"none",className:"docx-menubar__host",[Zn]:"",children:ie},ge),It,No;if(!f)It=co.filter(uo),No=h?co.map((ie,ge)=>uo(ie)?ie:Jo([ie],`host-${ge}`)):v;else {let ie=new Map,ge=[];for(let xe of co){let Ct=vc(xe);Ct?ie.set(Ct,xe):ge.push(xe);}It=[...CHROME_MENUS.map(xe=>{let Ct=ie.get(xe.id);if(Ct)return jsx(Fragment$1,{children:Ct},xe.id);let Fo=c8[xe.id];return jsx(Fo,{},xe.id)}),...ge.filter(uo)];let qe=ge.filter(xe=>!uo(xe));No=jsxs(Fragment,{children:[It,qe.length>0?Jo(qe,"host"):null]});}let br=a?.("formattingBar.more")??y("formattingBar.more");return jsxs(Wa.Provider,{value:Io,children:[jsx("div",{ref:ie=>{if(V.current=ie,Mn(ie),ie&&S===null){let ge=su(ie)[0]?.closest("[data-menu]")?.getAttribute("data-menu");ge&&_(ge);}},role:"menubar","aria-label":a?.("titleBar.menuBarAriaLabel")??y("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",...h?{"data-overflow":""}:{},className:`${n}docx-menubar${i?` ${i}`:""}`,dir:r,onMouseDown:U,onKeyDown:ie=>{if(ie.key!=="ArrowLeft"&&ie.key!=="ArrowRight")return;let ge=V.current;if(!ge)return;let qe=su(ge),xe=qe.indexOf(hostDocumentOf(ge).activeElement);if(xe===-1)return;ie.preventDefault();let Ct=hostWindowOf(ge).getComputedStyle(ge).direction==="rtl",Fo=(ie.key==="ArrowRight"?1:-1)*(Ct?-1:1),Qo=qe[(xe+Fo+qe.length)%qe.length],_n=Qo?.closest("[data-menu]")?.getAttribute("data-menu");_n&&(_(_n),Qo?.focus(),C!==null&&T(_n));},children:jsxs(Ll.Provider,{value:rt,children:[jsx(Rr.Provider,{value:0,children:No}),ae.size>0?jsx(Qt,{id:Dr,label:br,icon:re(tm),preset:false,children:jsx(Ll.Provider,{value:Ie,children:It})}):null]})}),jsxs(dh,{children:[k.visible&&o?.export!==false?o?.export?Ee(o.export,{open:true,format:k.format,pending:k.pending,error:k.error,onClose:k.dismiss},k.session):jsx(Ma,{open:true,format:k.format,pending:k.pending,error:k.error,onClose:k.dismiss}):null,M.visible&&o?.print!==false?o?.print?Ee(o.print,{open:true,pending:M.pending,error:M.error,url:M.url,onClose:M.close},M.session):jsx(_a,{open:true,pending:M.pending,error:M.error,url:M.url,onClose:M.close}):null]}),jsx("input",{ref:ce,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:ie=>{let ge=ie.target.files?.[0];ie.target.value="",!(!ge||!b)&&(P(ge.name),d?.(ge),ge.arrayBuffer().then(qe=>b.load(new Uint8Array(qe))).catch(qe=>{console.error("[docx-editor] could not open the file",qe);}));}}),jsx(Un,{open:B,onClose:()=>Z(false)}),jsx(Zo,{open:ee,onClose:()=>j(false)}),jsx(zn,{open:oe,onClose:()=>$(false)})]})}var $i=Object.assign(p8,{Menu:Qt,File:Eu,Format:Su,Insert:Pu,Review:bc,Help:Km,Item:Kt,Row:Me,Group:$a,Separator:Kn,Submenu:Jt,TableGrid:Ir,Entry:Ga,Open:gu,Save:bu,ExportMarkdown:hu,ExportPdf:yu,Print:xu,PageSetup:vu,ImageInsert:Cu,Watermark:Ul,Bookmark:zl,Reviewers:gc,ReportIssue:fc});var x8=12240,jx=1440,v8=1440,C8=567,or=20,jm=6,Xm=or+jm+2,T8="var(--doc-text-muted)",E8="var(--doc-text-subtle)",Yx="var(--doc-shadow-subtle)",S8="var(--doc-primary)",P8="var(--doc-primary-hover)",k8="var(--doc-text-subtle)",Gi=5,Vi=7,w8={left:0,right:0,firstLine:0};function Xx(e,t){return t==="inch"?(e/v8).toFixed(2)+'"':(e/C8).toFixed(1)+" cm"}function D8(e,t){return t?1:Math.round(e==="cm"?SNAP_TWIPS_CM:SNAP_TWIPS_INCH)}function nr({pageSetup:e,zoom:t=1,editable:o=false,onLeftMarginChange:n,onRightMarginChange:r,onMarginDragEnd:i,showIndentHandles:a=false,indent:l,indentEditable:s=false,onIndentChange:c,onIndentDragEnd:d,unit:m="inch",className:u="",style:g,tabMarks:p,onTabMarkRemove:f}){let{t:h}=F(),[v,b]=useState(null),[y,C]=useState(null),[T,x]=useState(null),[E,P]=useState(null),k=useRef(null),w=e?.pageWidthTwips??x8,D=e?.marginsTwips.left??jx,M=e?.marginsTwips.right??jx,H=e?.gutterTwips??0,I={pageWidth:w,leftMargin:D,rightMargin:M},A=l??w8,S=$e(w)*t,_=$e(D)*t,B=$e(M)*t,Z=useCallback(N=>{let W=k.current?.getBoundingClientRect();return W?_s((N-W.left)/t):null},[t]),ee=useCallback((N,W,J)=>{let de=Z(W);if(de===null)return;if(P($e(de)*t),N==="leftMargin"||N==="rightMargin"){if(N==="leftMargin"){let Oe=w-M-H-720,we=Math.round(Math.max(0,Math.min(de,Oe)));x(we),n?.(we);}else {let Oe=w-de,we=w-D-H-720,Ke=Math.round(Math.max(0,Math.min(Oe,we)));x(Ke),r?.(Ke);}return}let he=dragIndent(N,de,A,I,{unit:m,precise:J});x(N==="right"?he.right:N==="firstLine"?he.firstLine:he.left),c?.(he);},[Z,t,w,D,M,H,n,r,c,A,I,m]),j=useCallback(N=>{N==="leftMargin"||N==="rightMargin"?i?.():d?.(),b(null),x(null),P(null);},[i,d]),oe=useCallback((N,W,J)=>{let de=handlePosition(N,A,I),he=dragIndent(N,de+W*D8(m,J),A,I,{unit:m,precise:true});c?.(he),d?.();},[A,I,m,c,d]),$=rulerMarginTicks(I,A,m).map(N=>({...N,position:$e(N.position)*t})),V=a&&s&&c!==void 0,ce=N=>$e(handlePosition(N,A,I))*t,O=(N,W,J)=>({positionPx:ce(N),editable:V,isDragging:v===N,isHovered:y===N,onPointerEnter:()=>C(N),onPointerLeave:()=>C(null),onPointerDown:de=>{V&&(de.preventDefault(),de.stopPropagation(),de.currentTarget.setPointerCapture(de.pointerId),b(N));},onPointerMove:de=>{v===N&&ee(N,de.clientX,de.altKey);},onPointerUp:de=>{v===N&&(de.currentTarget.releasePointerCapture(de.pointerId),j(N));},onKeyDown:de=>{V&&(de.key!=="ArrowLeft"&&de.key!=="ArrowRight"||(de.preventDefault(),oe(N,de.key==="ArrowLeft"?-1:1,de.shiftKey)));},label:h(W),valueNow:J,valueText:Xx(J,m),pageWidthTwips:w});return jsxs("div",{ref:k,className:`docx-horizontal-ruler ${u}`,style:{position:"relative",width:kt(S),height:Xm,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:v?"ew-resize":"default",flexShrink:0,marginInline:"auto",...g},role:"group","aria-label":h("ruler.horizontal"),children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:kt(_),height:or,backgroundColor:Yx,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&n?N=>{N.preventDefault(),N.currentTarget.setPointerCapture(N.pointerId),b("leftMargin");}:void 0,onPointerMove:N=>v==="leftMargin"&&ee("leftMargin",N.clientX,N.altKey),onPointerUp:N=>{v==="leftMargin"&&(N.currentTarget.releasePointerCapture(N.pointerId),j("leftMargin"));}}),jsx("div",{style:{position:"absolute",top:0,right:0,width:kt(B),height:or,backgroundColor:Yx,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&r?N=>{N.preventDefault(),N.currentTarget.setPointerCapture(N.pointerId),b("rightMargin");}:void 0,onPointerMove:N=>v==="rightMargin"&&ee("rightMargin",N.clientX,N.altKey),onPointerUp:N=>{v==="rightMargin"&&(N.currentTarget.releasePointerCapture(N.pointerId),j("rightMargin"));}}),jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:or,pointerEvents:"none"},children:$.map((N,W)=>jsx(R8,{tick:N},W))}),p?.map(N=>jsx(N8,{tabMark:N,positionPx:$e(rulerTabPosition(N.position,I,A))*t,onDoubleClick:()=>f?.(N.position)},N.position)),a&&jsxs(Fragment,{children:[jsx(Gm,{direction:"down",anchor:"top",...O("firstLine","ruler.firstLineIndent",A.firstLine)}),jsx(Gm,{direction:"up",anchor:"strip",...O("hanging","ruler.hangingIndent",A.left)}),jsx(M8,{...O("left","ruler.leftIndent",A.left)}),jsx(Gm,{direction:"up",anchor:"strip",...O("right","ruler.rightIndent",A.right)})]}),v&&T!==null&&E!==null&&jsx(_8,{value:Xx(T,m),positionPx:E})]})}function R8({tick:e}){return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:kt(e.position),bottom:0,width:1,height:e.height,backgroundColor:E8}}),e.label&&jsx("div",{style:{position:"absolute",left:kt(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:T8,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function Jx(e){return e.editable?e.isDragging||e.isHovered?P8:S8:k8}function Qx(e,t,o){return {position:"absolute",left:kt(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...o}}function ev(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 Gm({direction:e,anchor:t,...o}){let n=Jx(o),r=t==="top"?{top:0,height:Vi+1}:{top:or-Vi,height:Vi};return jsx("div",{className:"docx-ruler-indent",style:Qx(o,Gi*2,r),onPointerEnter:o.onPointerEnter,onPointerLeave:o.onPointerLeave,onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onKeyDown:o.onKeyDown,...ev(o),children:jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${Gi}px solid transparent`,borderRight:`${Gi}px solid transparent`,...e==="down"?{top:0,borderTop:`${Vi}px solid ${n}`}:{bottom:0,borderBottom:`${Vi}px solid ${n}`},transition:"border-color 0.1s"}})})}function M8(e){return jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:Qx(e,Gi*2,{top:or+1,height:jm}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...ev(e),children:jsx("div",{style:{position:"absolute",left:1,top:0,width:Gi*2-2,height:jm,backgroundColor:Jx(e),borderRadius:1,transition:"background-color 0.1s"}})})}function _8({value:e,positionPx:t}){return jsx("div",{style:{position:"absolute",left:kt(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 I8={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function N8({tabMark:e,positionPx:t,onDoubleClick:o}){return jsx("div",{style:{position:"absolute",left:kt(t-5),top:or-12,width:10,height:12,display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"var(--doc-text-muted)",cursor:"pointer",userSelect:"none"},onDoubleClick:n=>{n.stopPropagation(),o();},title:`${e.alignment} tab at ${(e.position/1440).toFixed(2)}"`,children:I8[e.alignment]||"L"})}var A8=15840,nv=1440,Ec=1440,Sc=567,ha=20,O8="var(--doc-text-muted)",B8="var(--doc-text-subtle)",W8="var(--doc-primary)",Z8="var(--doc-primary)",K8="var(--doc-primary-hover)";function ji({pageSetup:e,zoom:t=1,editable:o=false,onTopMarginChange:n,onBottomMarginChange:r,onMarginDragEnd:i,unit:a="inch",className:l="",style:s}){let{t:c}=F(),d=at(),[m,u]=useState(null),[g,p]=useState(null),f=useRef(null),h=e?.pageHeightTwips??A8,v=e?.marginsTwips.top??nv,b=e?.marginsTwips.bottom??nv,y=(M,H)=>{if(!o||M.altKey||M.ctrlKey||M.metaKey||!["ArrowUp","ArrowDown","Home","End"].includes(M.key))return;M.preventDefault();let I=H==="topMargin"?v:b,S=Math.max(0,h-(H==="topMargin"?b:v)-720),_=M.shiftKey?1:Math.round(a==="cm"?Sc/10:Ec/8),B=M.key==="Home"?0:M.key==="End"?S:Math.max(0,Math.min(S,I+(M.key==="ArrowUp"?_:-_)));B!==I&&((H==="topMargin"?n:r)?.(B),i?.());},C=$e(h)*t,T=$e(v)*t,x=$e(b)*t,E=useCallback((M,H)=>{o&&(M.preventDefault(),u(H));},[o]),P=useCallback(M=>{if(!m||!f.current)return;let H=f.current.getBoundingClientRect(),I=M.clientY-H.top,A=_s(I/t);if(m==="topMargin"){let S=h-b-720,_=Math.max(0,Math.min(A,S));n?.(Math.round(_));}else if(m==="bottomMargin"){let S=h-A,_=h-v-720,B=Math.max(0,Math.min(S,_));r?.(Math.round(B));}},[m,t,h,v,b,n,r]),k=useCallback(()=>{m!==null&&i?.(),u(null);},[m,i]);useEffect(()=>{if(m){let M=hostDocumentOf(f.current);return M.addEventListener("mousemove",P),M.addEventListener("mouseup",k),()=>{M.removeEventListener("mousemove",P),M.removeEventListener("mouseup",k);}}},[m,P,k]);let w=U8(h,t,a),D={position:"relative",width:ha,height:kt(C),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:m?"ns-resize":"default",...s};return jsxs("div",{ref:f,className:`docx-vertical-ruler ${l}`,style:D,dir:d,role:"group","aria-label":c("ruler.vertical"),children:[jsx("div",{style:{position:"absolute",top:0,insetInlineStart:0,insetInlineEnd:0,bottom:0,pointerEvents:"none"},children:w.map((M,H)=>jsx(q8,{tick:M},H))}),jsx(rv,{type:"topMargin",value:v,maximum:Math.max(0,h-b-720),valueText:v/(a==="cm"?Sc:Ec),unit:a,onKeyDown:M=>y(M,"topMargin"),position:T,editable:o,isDragging:m==="topMargin",isHovered:g==="topMargin",onMouseEnter:()=>p("topMargin"),onMouseLeave:()=>p(null),onMouseDown:M=>E(M,"topMargin")}),jsx(rv,{type:"bottomMargin",value:b,maximum:Math.max(0,h-v-720),valueText:b/(a==="cm"?Sc:Ec),unit:a,onKeyDown:M=>y(M,"bottomMargin"),position:C-x,editable:o,isDragging:m==="bottomMargin",isHovered:g==="bottomMargin",onMouseEnter:()=>p("bottomMargin"),onMouseLeave:()=>p(null),onMouseDown:M=>E(M,"bottomMargin")})]})}function q8({tick:e}){let t={position:"absolute",top:kt(e.position),insetInlineEnd:0,height:1,width:e.width,backgroundColor:B8},o={position:"absolute",top:kt(e.position),insetInlineStart:2,transform:"translateY(-50%)",fontSize:"9px",color:O8,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxs(Fragment,{children:[jsx("div",{style:t}),e.label&&jsx("div",{style:o,children:e.label})]})}function rv({type:e,position:t,value:o,maximum:n,valueText:r,unit:i,onKeyDown:a,editable:l,isDragging:s,isHovered:c,onMouseEnter:d,onMouseLeave:m,onMouseDown:u}){let{t:g}=F(),p=s?K8:c?Z8:W8,f={position:"absolute",top:kt(t-5),insetInlineEnd:0,width:ha,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 jsx("div",{className:`docx-ruler-marker docx-ruler-marker-${e}`,style:f,onMouseEnter:d,onMouseLeave:m,onMouseDown:u,role:"slider","aria-label":g(e==="topMargin"?"ruler.topMargin":"ruler.bottomMargin"),"aria-orientation":"vertical","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":n,"aria-valuetext":`${r.toFixed(2)} ${i==="cm"?"cm":"in"}`,"aria-disabled":!l,onKeyDown:a,tabIndex:l?0:-1,children:jsx("div",{style:h})})}function U8(e,t,o){let n=[];if(o==="inch"){let r=Ec/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=$e(l)*t;if(a%8===0){let c=a/8;n.push({position:s,width:10,label:c>0?String(c):void 0});}else a%4===0?n.push({position:s,width:6}):a%2===0?n.push({position:s,width:4}):n.push({position:s,width:2});}}else {let r=Sc/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=$e(l)*t;if(a%10===0){let c=a/10;n.push({position:s,width:10,label:c>0?String(c):void 0});}else a%5===0?n.push({position:s,width:6}):n.push({position:s,width:3});}}return n}var V8=e=>e.formatting?.indent??null,G8=e=>e.editable;function Qm(){let e=L(),t=K(V8),o=K(G8),n=useMemo(()=>o&&e!==null&&e.can({type:"setIndent",left:0}).ok,[e,o]),r=useCallback(i=>e?e.exec({...i.left!==void 0?{left:i.left}:{},...i.right!==void 0?{right:i.right}:{},...i.firstLine!==void 0?{firstLine:i.firstLine}:{},type:"setIndent"}).ok:false,[e]);return useMemo(()=>({indent:t,isEnabled:n,apply:r}),[t,n,r])}var cv=e=>e.zoom,Y8=e=>e.isOpening===true;function dv(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function uv(){let{apply:e}=qn(),[t,o]=useState({}),n=useRef({}),r=useCallback(a=>l=>{n.current={...n.current,[a]:Math.round(l)},o(n.current);},[]),i=useCallback(()=>{let a=n.current;n.current={},o({}),Object.keys(a).length!==0&&e({...a.top!==void 0?{marginTopTwips:a.top}:{},...a.right!==void 0?{marginRightTwips:a.right}:{},...a.bottom!==void 0?{marginBottomTwips:a.bottom}:{},...a.left!==void 0?{marginLeftTwips:a.left}:{},scope:"section"});},[e]);return {pending:t,preview:r,commit:i}}function sv(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function X8(){let e=L(),{indent:t,isEnabled:o,apply:n}=Qm(),[r,i]=useState(null),a=useRef(null),l=useRef(null),s=useCallback(m=>{l.current===null&&(l.current=sv(e)),a.current=m,i(m);},[e]),c=useCallback(()=>{let m=a.current,u=l.current;a.current=null,l.current=null,i(null),m&&(u!==null&&u!==sv(e)||n({left:m.left,right:m.right,firstLine:m.firstLine}));},[e,n]),d=useMemo(()=>r??(t?{left:t.left,right:t.right,firstLine:t.firstLine,...t.rtl?{rtl:true}:{}}:null),[r,t]);return useMemo(()=>({indent:d,isEnabled:o,preview:s,commit:c}),[d,o,s,c])}function J8(){let e=Se(),[t,o]=useState(0);return useEffect(()=>{if(!e){o(0);return}let n=()=>o(e.scrollLeft);return n(),e.addEventListener("scroll",n,{passive:true}),()=>e.removeEventListener("scroll",n)},[e]),t}function kc(e){let t=K(eo),o=K(Y8),{pageSetup:n,isEnabled:r}=qn(),i=K(cv),{pending:a,preview:l,commit:s}=uv(),c=X8(),d=Fn(),m=Fs(),u=m==="left",g=D0(fn(),m),p=J8();return t?null: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:jsx(nr,{pageSetup:dv(n,a),zoom:i,editable:r,onLeftMarginChange:l("left"),onRightMarginChange:l("right"),onMarginDragEnd:s,showIndentHandles:c.indent!==null,indent:c.indent,indentEditable:c.isEnabled,onIndentChange:c.preview,onIndentDragEnd:c.commit,unit:e.unit??"inch",className:e.className??"",style:{...e.style,transform:`${e.style?.transform?`${e.style.transform} `:""}translateX(${-p}px)`,clipPath:d>0&&p>0?`inset(0 0 0 ${p}px)`:e.style?.clipPath}})})}function wc(e){let t=K(eo),{pageSetup:o,isEnabled:n}=qn(),r=K(cv),{pending:i,preview:a,commit:l}=uv(),s=Fn(),c=fn(),d=M0();return t||d!==null&&d>0&&o&&$e(o.pageWidthTwips)*r>d-s-c.inlineStart-c.inlineEnd?null:jsx(ji,{pageSetup:dv(o,i),zoom:r,editable:n,onTopMarginChange:a("top"),onBottomMarginChange:a("bottom"),onMarginDragEnd:l,unit:e.unit??"inch",className:e.className??"",style:e.style})}function q({size:e=20,className:t="",style:o,children:n}){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 -960 960 960",fill:"currentColor",className:t,style:{display:"inline-flex",flexShrink:0,...o},"aria-hidden":"true",children:n})}function pv(e){return jsx(q,{...e,children: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 mv(e){return jsx(q,{...e,children: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 jsx(q,{...e,children:jsx("path",{d:"M80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"})})}function gv(e){return jsxs(q,{...e,children:[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"}),jsx("path",{fill:"var(--doc-success)",d:"m421-380 227-227-45-45-182 182-92-91-45 45 137 136Z"})]})}function bv(e){return jsx(q,{...e,children:jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function hv(e){return jsx(q,{...e,children: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 yv(e){return jsx(q,{...e,children: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 xv(e){return jsx(q,{...e,children: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 vv(e){return jsx(q,{...e,children: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 Cv(e){return jsx(q,{...e,children: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 Tv(e){return jsx(q,{...e,children: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 Ev(e){return jsx(q,{...e,children: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 tN(e){return jsx(q,{...e,children: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 jsx(q,{...e,children: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 nN(e){return jsx(q,{...e,children: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 rN(e){return jsx(q,{...e,children: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 aN(e){return jsx(q,{...e,children: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 iN(e){return jsx(q,{...e,children: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 lN(e){return jsx(q,{...e,children:jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function sN(e){return jsx(q,{...e,children: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 cN(e){return jsx(q,{...e,children: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 dN(e){return jsx(q,{...e,children: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 uN(e){return jsx(q,{...e,children: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 pN(e){return jsx(q,{...e,children: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 mN(e){return jsx(q,{...e,children:jsx("path",{d:"M360-160v-240q-83 0-141.5-58.5T160-600q0-83 58.5-141.5T360-800h360v80h-80v560h-80v-560H440v560h-80Z"})})}function fN(e){return jsx(q,{...e,children: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 gN(e){return jsx(q,{...e,children:jsx("path",{d:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z"})})}function bN(e){return jsx(q,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function hN(e){return jsx(q,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function yN(e){return jsx(q,{...e,children:jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function xN(e){return jsx(q,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function nf(e){return jsx(q,{...e,children: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 vN(e){return jsx(q,{...e,children: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 CN(e){return jsx(q,{...e,children: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 TN(e){return jsx(q,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function EN(e){return jsx(q,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function SN(e){return jsx(q,{...e,children:jsx("path",{d:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z"})})}function PN(e){return jsx(q,{...e,children: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 kN(e){return jsx(q,{...e,children: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 wN(e){return jsx(q,{...e,children:jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function DN(e){return jsx(q,{...e,children: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 RN(e){return jsx(q,{...e,children: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 MN(e){return jsx(q,{...e,children: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 _N(e){return jsx(q,{...e,children: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 IN(e){return jsx(q,{...e,children: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 Sv(e){return jsx(q,{...e,children:jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function NN(e){return jsx(q,{...e,children: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 FN(e){return jsx(q,{...e,children: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 LN(e){return jsx(q,{...e,children: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 HN(e){return jsx(q,{...e,children:jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function AN(e){return jsx(q,{...e,children:jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function ON(e){return jsx(q,{...e,children: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 BN(e){return jsx(q,{...e,children: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 WN(e){return jsx(q,{...e,children: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 ZN(e){return jsx(q,{...e,children:jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function KN(e){return jsx(q,{...e,children: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 qN(e){return jsx(q,{...e,children: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 UN(e){return jsx(q,{...e,children:jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function zN(e){return jsx(q,{...e,children:jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function $N(e){return jsx(q,{...e,children:jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function VN(e){return jsx(q,{...e,children: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 GN(e){return jsx(q,{...e,children: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 jN(e){return jsx(q,{...e,children: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 YN(e){return jsx(q,{...e,children:jsx("path",{d:"M440-120v-240h80v80h320v80H520v80h-80Zm-320-80v-80h240v80H120Zm160-160v-80H120v-80h160v-80h80v240h-80Zm160-80v-80h400v80H440Zm160-160v-240h80v80h160v80H680v80h-80Zm-480-80v-80h400v80H120Z"})})}function XN(e){return jsx(q,{...e,children: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 JN(e){return jsx(q,{...e,children: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 QN(e){return jsx(q,{...e,children: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 e5(e){return jsx(q,{...e,children: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 t5(e){return jsx(q,{...e,children: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 jsx(q,{...e,children: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 n5(e){return jsx(q,{...e,children:jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function r5(e){return jsx(q,{...e,children:jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function a5(e){return jsx(q,{...e,children: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 i5(e){return jsx(q,{...e,children: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 l5(e){return jsx(q,{...e,children: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 s5(e){return jsx(q,{...e,children: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 c5(e){return jsx(q,{...e,children: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 d5(e){return jsx(q,{...e,children: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 u5(e){return jsx(q,{...e,children: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 p5(e){return jsx(q,{...e,children: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 m5(e){return jsx(q,{...e,children: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 f5(e){return jsx(q,{...e,children: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 g5(e){return jsx(q,{...e,children:jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function b5(e){return jsx(q,{...e,children: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 h5(e){return jsx(q,{...e,children: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 y5(e){return jsx(q,{...e,children: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 x5(e){return jsx(q,{...e,children:jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function v5(e){return jsx(q,{...e,children: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 C5(e){return jsx(q,{...e,children:jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function T5(e){return jsx(q,{...e,children:jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function E5(e){return jsx(q,{...e,children:jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function S5(e){return jsx(q,{...e,children:jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function P5(e){return jsx(q,{...e,children:jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function k5(e){return jsx(q,{...e,children:jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function w5(e){return jsx(q,{...e,children: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 D5(e){return jsx(q,{...e,children: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 R5(e){return jsx(q,{...e,children: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 M5(e){return jsx(q,{...e,children:jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function _5(e){return jsx(q,{...e,children: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 I5(e){return jsx(q,{...e,children:jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function N5(e){return jsx(q,{...e,children: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 F5(e){return jsx(q,{...e,children: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 L5(e){return jsx(q,{...e,children: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 H5(e){return jsx(q,{...e,children: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 A5(e){return jsx(q,{...e,children: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 O5={undo:tN,redo:oN,print:nN,file_download:rN,file_upload:aN,format_bold:iN,format_italic:lN,format_underlined:sN,strikethrough_s:cN,superscript:dN,subscript:uN,link:pN,format_clear:gN,format_paragraph:mN,format_shapes:fN,lock:Ev,format_align_left:bN,format_align_center:hN,format_align_right:yN,format_align_justify:xN,format_line_spacing:nf,format_list_bulleted:vN,format_list_numbered:CN,format_indent_increase:TN,format_indent_decrease:EN,format_color_text:SN,ink_highlighter:PN,format_color_reset:kN,arrow_drop_down:wN,table:DN,table_chart:RN,grid_on:MN,table_rows:_N,view_column:IN,border_all:Sv,select_all:Sv,border_outer:NN,border_inner:FN,border_clear:LN,add:HN,remove:AN,delete:ON,delete_sweep:BN,call_merge:WN,call_split:ZN,drag_indicator:KN,image:qN,format_image_left:UN,format_image_right:zN,horizontal_rule:$N,flip_to_back:VN,flip_to_front:GN,open_with:jN,tune:YN,rotate_right:XN,rotate_left:JN,swap_horiz:QN,swap_vert:e5,shapes:t5,format_paint:o5,expand_more:n5,expand_less:r5,border_top:a5,border_bottom:i5,border_left:l5,border_right:s5,border_horizontal:c5,border_vertical:d5,padding:u5,text_rotation_none:p5,wrap_text:m5,height:f5,fit_width:g5,settings:b5,border_color:h5,format_color_fill:y5,vertical_align_top:x5,vertical_align_center:v5,vertical_align_bottom:C5,line_weight:T5,keyboard_arrow_up:E5,keyboard_arrow_down:S5,keyboard_arrow_left:P5,keyboard_arrow_right:k5,more_vert:w5,page_break:D5,branding_watermark:R5,arrow_back:M5,search:_5,toc:I5,bookmark:N5,bookmarks:F5,done_all:pv,check_circle:mv,chat_bubble_outline:fv,chat_bubble_check:gv,check:bv,close:hv,add_comment:yv,comment:xv,edit_note:vv,rate_review:Cv,visibility:Tv,format_textdirection_l_to_r:L5,format_textdirection_r_to_l:H5,"agent-sparkle":A5};function G({name:e,size:t=20,className:o="",style:n}){let r=O5[e];return r?jsx(r,{size:t,className:o,style:n}):(console.warn(`Icon not found: ${e}`),jsx("span",{className:o,style:{fontSize:t,width:t,height:t,...n},children:e}))}var Yi=12,rf=240,kv=16,U5=24,z5=Yi+rf+kv,ya=12,$5=36,V5=ya+$5+kv,Xi=Bt__default.memo(function({headings:t,onHeadingClick:o,onClose:n,topOffset:r=0,scrollLeft:i=0,leftOffset:a=Yi}){let{t:l}=F(),[s,c]=useState(false),d=useRef(null),m=t.length?Math.min(...t.map(u=>u.level)):0;return useEffect(()=>{hostWindowOf(d.current).requestAnimationFrame(()=>c(true));},[]),jsxs("nav",{ref:d,className:"docx-outline-nav",role:"navigation","aria-label":l("documentOutline.ariaLabel"),style:{position:"absolute",top:r,left:a-i,bottom:0,width:rf,paddingTop:U5,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:s?"translateX(0)":`translateX(-${a+rf}px)`,transition:"transform 0.15s ease-out"},onMouseDown:u=>u.stopPropagation(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px 0"},children:[jsx("button",{onClick:n,"aria-label":l("documentOutline.closeAriaLabel"),style:{background:"none",border:"none",cursor:"pointer",padding:4,borderRadius:"50%",display:"flex",alignItems:"center",color:"var(--doc-text-muted)"},title:l("documentOutline.closeTitle"),children:jsx(G,{name:"arrow_back",size:20})}),jsx("span",{style:{fontWeight:400,fontSize:14,color:"var(--doc-text)",letterSpacing:"0.01em"},children:l("documentOutline.title")})]}),jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:4},children:t.length===0?jsx("div",{style:{padding:"8px 16px",color:"var(--doc-text-subtle)",fontSize:13,lineHeight:"20px"},children:l("documentOutline.noHeadings")}):t.map((u,g)=>jsx("div",{style:{marginLeft:(u.level-m)*16},children: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 Y5=e=>e,X5=Object.freeze([]),J5=()=>{};function af(e){let t=L(),o=K(Y5),n=useMemo(()=>t&&!o.isLoading?t.getOutline():X5,[t,o]),r=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 eo(o)?null:jsx(Xi,{headings:n,onHeadingClick:r,onClose:e.onClose??J5,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var lf=createContext(null);function Po(e){let t=useContext(lf);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var r6={ok:false,code:"unsupported",reason:"editor is not ready"},Dv=Object.freeze([]);function Dc(e={}){let t=e.enabled??true,o=L(),n=useCallback(k=>t?o?.query({type:"bookmarks"})??Dv:Dv,[o,t]),r=K(n,Ku),[i,a]=useState(""),[l,s]=useState("name"),[c,d]=useState(false),[m,u]=useState(null),[g,p]=useState(null),[f,h]=useState(""),v=useMemo(()=>goToBookmarkRows(r,{query:i,sortBy:l,showHidden:c}),[r,i,l,c]),b=useMemo(()=>m===null?-1:v.findIndex(k=>k.name===m),[v,m]),y=useCallback(k=>{a(k),u(null),p(null);},[]),C=useCallback(k=>{s(k),u(null),p(null);},[]),T=useCallback(k=>{d(k),u(null),p(null);},[]),x=useCallback(k=>{if(v.length===0)return;let w=b<0?k>0?-1:0:b;u(v[(w+k+v.length)%v.length].name);},[v,b]),E=useCallback(k=>u(v[k]?.name??null),[v]),P=useCallback(k=>{if(!o)return r6;let w=k??v[b]?.name??goToBookmarkTarget(r,i,v)?.name;if(w===void 0||w.trim().length===0){let M=i.trim();return p(M.length===0?"empty":"notFound"),h(M),{ok:false,code:"notFound",reason:"no bookmark is named that"}}let D=o.exec({type:"goToBookmark",name:w});return p(D.ok?null:D.code==="notFound"?"notFound":"failed"),h(D.ok?"":w),D},[o,v,b,r,i]);return {query:i,setQuery:y,sortBy:l,setSortBy:C,showHidden:c,setShowHidden:T,rows:v,bookmarks:r,activeIndex:b,move:x,setActiveIndex:E,go:P,problem:g,problemName:f}}var Rv=(...e)=>e.filter(Boolean).join(" "),d6={header:"navigation.goTo.places.header",footer:"navigation.goTo.places.footer",footnote:"navigation.goTo.places.footnote",endnote:"navigation.goTo.places.endnote"},u6={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 p6(){return jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:jsx("path",{d:"M5.5 2.5h5M5.5 13.5h5M8 2.5v11",fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})})}function m6({name:e,query:t}){let o=goToBookmarkMatch(e,t);return o?jsxs(Fragment,{children:[e.slice(0,o.start),jsx("span",{className:"docx-nav__goto-match",children:e.slice(o.start,o.end)}),e.slice(o.end)]}):e}function Ji({className:e,style:t}){let{pane:o,intents:n,t:r}=Po("GoTo"),i=L(),a=o.tab!=="goto",l=Dc({enabled:o.open&&!a}),s=se("insert.bookmark"),c=K(eo),d=useId(),m=`${d}-list`,u=`${d}-label`,g=`${d}-hint`,p=E=>`${d}-option-${E}`,f=useRef(null);useEffect(()=>{if(l.activeIndex<0)return;let E=`${d}-option-${l.activeIndex}`;f.current?.querySelector(`[id="${E}"]`)?.scrollIntoView?.({block:"nearest"});},[l.activeIndex,d]);let h=E=>{l.go(E).ok&&(n.picked(),i?.focus());},v=E=>{E.nativeEvent.isComposing||(E.key==="ArrowDown"||E.key==="ArrowUp"?(E.preventDefault(),l.move(E.key==="ArrowDown"?1:-1)):(E.key==="Home"||E.key==="End")&&l.activeIndex>=0?(E.preventDefault(),l.setActiveIndex(E.key==="Home"?0:l.rows.length-1)):E.key==="Enter"?(E.preventDefault(),h()):E.key==="Escape"&&l.query.length>0&&(E.preventDefault(),l.setQuery("")));},b=l.problem==="notFound"?r("navigation.goTo.notFound",{name:l.problemName}):l.problem==="failed"?r("navigation.goTo.failed"):l.problem==="empty"?r("navigation.goTo.typeName"):l.bookmarks.length>0&&l.rows.length===0?r("navigation.goTo.noMatches"):"",y=l.activeIndex>=0?p(l.activeIndex):void 0,C=l.sortBy==="location",T=l.bookmarks.length===0,x=(E,P)=>{let k=P===l.activeIndex;return jsxs("li",{id:p(P),role:"option","aria-selected":k,className:Rv("docx-nav__goto-row",k&&"docx-nav__goto-row--active"),"data-point":E.empty||void 0,onMouseDown:w=>w.preventDefault(),onClick:()=>h(E.name),children:[jsx("span",{className:"docx-nav__goto-icon","aria-hidden":"true",children:E.empty?jsx(p6,{}):jsx(G,{name:"bookmark",size:16})}),jsx("span",{className:"docx-nav__result-text",children:jsx("bdi",{children:jsx(m6,{name:E.name,query:l.query})})}),E.atSelection&&jsx("span",{className:"docx-nav__goto-here",title:r("navigation.goTo.atCaret"),children:jsx("span",{className:"docx-editor-sr-only",children:r("navigation.goTo.atCaret")})}),!C&&E.place!=="body"&&jsx("span",{className:"docx-nav__goto-place",children:r(d6[E.place])})]},E.name)};return jsxs("div",{className:Rv("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:[jsxs("div",{className:"docx-nav__searchbox",children:[jsx(G,{name:"bookmark",size:18,className:"docx-nav__search-icon"}),jsx("input",{type:"text",role:"combobox",className:"docx-nav__search-input",value:l.query,placeholder:r("navigation.goTo.placeholder"),"aria-label":r("navigation.goTo.label"),"aria-describedby":y?g:void 0,"aria-expanded":l.rows.length>0,"aria-controls":l.rows.length>0?m:void 0,"aria-autocomplete":"list","aria-activedescendant":y,autoComplete:"off",spellCheck:false,onChange:E=>l.setQuery(E.target.value),onKeyDown:v}),y&&jsx("kbd",{className:"docx-nav__goto-enter","aria-hidden":"true",children:"\u21B5"}),jsx("span",{id:g,className:"docx-editor-sr-only",children:r("navigation.goTo.enterHint")})]}),jsxs("div",{className:"docx-nav__goto-controls",children:[jsx("div",{className:"docx-nav__segmented",role:"radiogroup","aria-label":r("dialogs.bookmark.sortBy"),children:["name","location"].map(E=>jsxs("label",{className:"docx-nav__segment","data-checked":l.sortBy===E||void 0,children:[jsx("input",{type:"radio",className:"docx-nav__segment-input",name:`${d}-sort`,checked:l.sortBy===E,onChange:()=>l.setSortBy(E)}),r(E==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},E))}),jsxs("label",{className:"docx-nav__option",children:[jsx("input",{type:"checkbox",checked:l.showHidden,onChange:E=>l.setShowHidden(E.target.checked)}),r("dialogs.bookmark.showHidden")]})]}),T&&!c&&jsxs("div",{className:"docx-nav__goto-empty",children:[jsx(G,{name:"bookmark",size:24,className:"docx-nav__goto-empty-icon"}),jsx("p",{className:"docx-nav__goto-empty-title",children:r("navigation.goTo.empty")}),jsx("p",{className:"docx-nav__goto-empty-hint",children:r("navigation.goTo.emptyHint")}),jsx("button",{type:"button",className:"docx-nav__goto-add",disabled:!s.isEnabled,title:s.disabledReason??void 0,onClick:()=>s.execute(),children:r("navigation.goTo.add")})]}),!T&&jsxs("div",{className:"docx-nav__goto-heading",children:[jsx("span",{id:u,children:r("navigation.goTo.listAriaLabel")}),jsx("span",{className:"docx-nav__goto-count",children:l.query.trim().length>0?r("navigation.goTo.countFiltered",{shown:l.rows.length,total:l.bookmarks.filter(E=>l.showHidden||!E.hidden).length}):l.rows.length})]}),jsx("p",{className:"docx-nav__goto-message",role:"status",children:b}),l.rows.length>0&&jsx("ul",{ref:f,id:m,className:"docx-nav__list docx-nav__goto-list",role:"listbox","aria-labelledby":u,children:C?goToBookmarkGroups(l.rows).map(E=>jsxs("li",{role:"group","aria-labelledby":`${d}-group-${E.place}`,className:"docx-nav__goto-group",children:[jsx("div",{id:`${d}-group-${E.place}`,className:"docx-nav__goto-group-label",children:r(u6[E.place])}),jsx("ul",{role:"none",className:"docx-nav__goto-sublist",children:E.rows.map(({row:P,index:k})=>x(P,k))})]},E.place)):l.rows.map((E,P)=>x(E,P))})]})}var va=280,Rc=32,Mv=16;function Ca(e=280){return 32+e+16}function Mc({viewportWidth:e,pageWidthPx:t,reservation:o,inlineEndReservation:n=0,inlineStartReservation:r=0,docked:i=false}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(n)||n<0||!Number.isFinite(r)||r<0)return 0;let a=(e-n-t)/2,l=a>=o?0:!i&&o<=2*a?2*(o-a):o;return Math.ceil(Math.max(0,l-r))}var sf=320;function _c(e,t){return !Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?false:e-t<sf}var h6=Object.freeze([]),y6=e=>e;function Ic(){let e=L(),t=K(y6),[o,n]=useState(null),r=useMemo(()=>e&&!t.isLoading?e.getOutline():h6,[e,t]),i=useMemo(()=>{if(r.length===0)return [];let l=r[0].level;for(let s of r)s.level<l&&(l=s.level);return r.map(s=>({heading:s,depth:s.level-l}))},[r]),a=useCallback(l=>{if(!e||typeof l!="string"||l.length===0)return;e.focus();let s={paragraphId:l,offset:0};e.exec({type:"setSelection",range:{anchor:s,head:s}}),e.scrollToBlock(l),n(l);},[e]);return {headings:r,items:i,selectedBlockId:o,goTo:a,isEmpty:r.length===0}}var Av=Object.freeze({query:"",matchCase:false,wholeWord:false,matches:Object.freeze([]),truncated:false,activeIndex:-1,activeMatch:null,isPending:false}),T6=()=>()=>{},Iv=()=>Av;function Nc(e={}){let t=e.highlight??"all",o=L(),n=useMemo(()=>o?createDocumentSearch(o):null,[o]),r=useSyncExternalStore(n?n.subscribe:T6,n?n.getState:Iv,n?n.getState:Iv);useEffect(()=>{if(!(!n||t==="none"))return n.showHighlights(t)},[n,t]);let i=useMemo(()=>({setQuery:a=>n?.setQuery(a),find:(a,l)=>n?.find(a,l)??Av.matches,setMatchCase:a=>n?.setMatchCase(a),setWholeWord:a=>n?.setWholeWord(a),goTo:a=>n?.goTo(a)??false,next:()=>n?.next()??false,previous:()=>n?.previous()??false,clear:()=>n?.clear()}),[n]);return useMemo(()=>({...r,...i}),[r,i])}function Kv(e,t=isApplePlatform()){return e.altKey||e.shiftKey||e.isComposing||(t?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey)?false:chordLetter(e)==="f"}var qv=isGoToChord;function Uv(e=isApplePlatform()){return e?"Ctrl+Alt+G":"Ctrl+G"}function zv(e=isApplePlatform()){return e?"Meta+Alt+G":"Control+G"}function $v(e){return e.startsWith("Ctrl")?"Control+F":"Meta+F"}function Vv(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 Gv(e,t,o){if(!isDomNode(e))return false;if(t?.contains(e))return true;if(!o)return false;if(o.contains(e))return true;let n=isElementNode(e)?e:e.parentElement;if(!n)return false;let r=editorInstanceScope(o);if(r&&r!==o&&r.contains(n))return true;if(!n.closest(".docx-editor")||editorInstanceScope(n)!==null)return false;let i=o.ownerDocument.querySelectorAll(".docx-editor__scroll-container");return i.length===1&&i[0]===o}function uf(e,t){let o=e?.querySelector(`#docx-nav-panel-${t}`);if(!o)return null;if(t==="headings"){let n=o.querySelector(".docx-nav__heading--current")??o.querySelector(".docx-nav__heading");if(n)return n}return o.querySelector(".docx-nav__search-input")}function pf(e){e.focus(),e.localName==="input"&&e.select();}function w6(e){let o=e.querySelector('[role="tab"][aria-selected="true"]')?.id??"",r=uf(e,o==="docx-nav-tab-find"?"find":o==="docx-nav-tab-goto"?"goto":"headings");if(r){pf(r);return}isHTMLElementNode(e)&&(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus());}function D6(e,t){let o=[];if(t.contains(e)){let i=e;for(;i!==t&&i.parentElement;){for(let a of i.parentElement.children)a!==i&&o.push(a);i=i.parentElement;}}else o.push(...t.children);let n=e.ownerDocument.activeElement;n&&o.some(i=>i.contains(n))&&w6(e);let r=[];for(let i of o)i.hasAttribute("inert")||(i.setAttribute("inert",""),r.push(i));return ()=>{for(let i of r)i.removeAttribute("inert");r.length=0;}}function jv(e,t,o){let n=D6(e,t),r=i=>{isDomNode(i.target)&&e.contains(i.target)||o();};return t.addEventListener("pointerdown",r),()=>{t.removeEventListener("pointerdown",r),n();}}function Wv(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Yv(e,t){let o=()=>{let i=hostWindowOf(t).getComputedStyle(t),a=t.clientHeight-Wv(i.paddingTop)-Wv(i.paddingBottom);e.style.setProperty("--docx-nav-block-size",`${Math.max(0,Math.round(a))}px`),e.style.setProperty("--docx-nav-inline-size",`${Math.round(t.clientWidth)}px`);};o();let n=hostWindowOf(t).ResizeObserver;if(typeof n>"u")return ()=>{};let r=new n(o);return r.observe(t),()=>r.disconnect()}function Jv(e,t=true,o=true){let n=L(),r=Se(),i=useRef(null),a=useRef(null),l=useRef(false),s=useRef(false),c=useRef(false),d=useRef(0),m=useCallback(()=>{let x=++d.current;hostWindowOf(i.current).setTimeout(()=>{d.current===x&&(l.current=false,s.current=false,c.current=false);},0);},[]),u=useRef(e);u.current=e;let g=useCallback(()=>{l.current=false;let x=uf(i.current,u.current.tab);x&&pf(x);},[]),p=useCallback(()=>{s.current=false;let x=a.current;a.current=null;let E=i.current?.querySelector(".docx-nav__toggle")??null;Vv(x,E,n?()=>n.focus():null);},[n]),f=useRef(p);f.current=p,useEffect(()=>()=>{s.current&&f.current();},[]);let h=useCallback(()=>{l.current=false,s.current=true,u.current.setOpen(false),m();},[m]),v=useCallback((x,E)=>{E&&!i.current?.contains(E)&&(a.current=E),s.current=false;let P=u.current;if(P.open&&P.tab===x){g();return}l.current=true,P.tab!==x&&P.setTab(x),P.open||P.setOpen(true),m();},[g,m]),b=useMemo(()=>({openTab:x=>{let E=i.current?.ownerDocument.activeElement;v(x,isHTMLElementNode(E)?E: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 x=u.current;if(!x.overlay)return;let E=i.current?.ownerDocument.activeElement;c.current=!!E&&!!i.current?.contains(E),x.setOpen(false),m();}}),[h,m,v]),y=useRef(b);y.current=b,useEffect(()=>{let x=i.current?.ownerDocument;if(!x||!t&&!o)return;let E=P=>{if(P.defaultPrevented)return;let k=t&&Kv(P)?"find":o&&qv(P)?"goto":null;if(!k||!Gv(P.target,i.current,r))return;if(k==="goto"&&n?.can({type:"openGoTo"}).ok){n.exec({type:"openGoTo",fromShortcut:true}).ok&&P.preventDefault();return}P.preventDefault();let w=x.activeElement;v(k,isHTMLElementNode(w)?w:null);};return x.addEventListener("keydown",E),()=>x.removeEventListener("keydown",E)},[r,t,o,v,n]),useEffect(()=>{l.current&&(u.current.open?g():l.current=false),s.current&&(u.current.open?s.current=false:p()),c.current&&(c.current=false,u.current.open||n?.focus());});let C=e.open&&e.overlay;useEffect(()=>{let x=i.current;if(!(!C||!x||!r))return jv(x,r,()=>y.current.close())},[C,r]),useEffect(()=>{let x=i.current;if(!(!x||!r||!r.contains(x)))return Yv(x,r)},[r]);let T=useCallback(x=>{x.key!=="Escape"||x.defaultPrevented||x.nativeEvent.isComposing||u.current.open&&(x.preventDefault(),h());},[h]);return {rootRef:i,intents:b,onKeyDown:T}}var I6=150;function N6(e){return e.source!==void 0?true:(e.created?.length??0)>0||(e.deleted?.length??0)>0}function F6(e){let t=0;for(let o of e)t=Math.max(t,o.box.width);return t>0?t:null}function Qv(e,t,o=()=>null){let n=hostTimers(o),r=null,i=false,a=()=>{r=null,i||t(F6(e.getPageGeometry()));},l=()=>{i||(n.clearTimeout(r),r=n.setTimeout(a,I6));},s=e.on("change",c=>{N6(c)&&l();});return a(),{nudge:l,dispose(){i=true,n.clearTimeout(r),r=null,s();}}}var B6=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??ZOOM_MAX)&&e.zoom>(t.minZoom??ZOOM_MIN)}},W6=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips,Z6=e=>e.page.total;function Fc(e={}){let{defaultOpen:t=false,defaultTab:o="headings",paneWidth:n=280}=e,[r,i]=useState(t),[a,l]=useState(o),s=e.open??r,c=e.tab??a,{onOpenChange:d,onTabChange:m}=e,u=e.open!==void 0,g=e.tab!==void 0,p=useCallback(O=>{u||i(O),d?.(O);},[u,d]),f=useCallback(()=>p(!s),[s,p]),h=useCallback(O=>{g||l(O),m?.(O);},[g,m]),v=Nn(),b=Se(),y=useContext(Nt),{pageSetup:C,zoom:T,reviewPaneOpen:x,fitting:E}=K(B6,W6),P=L(),k=K(Z6),[w,D]=useState(0),[M,H]=useState(null),[I,A]=useState(0),[S,_]=useState(0),B=fn();useEffect(()=>{if(!b){D(0),A(0),_(0);return}let O=()=>{D(b.clientWidth);let J=hostWindowOf(b).getComputedStyle(b),de=b.getAttribute("data-chrome-dir")==="rtl",he=Number.parseFloat(de?J.paddingLeft:J.paddingInlineEnd);A(Number.isFinite(he)?he:0);let Oe=Number.parseFloat(J.getPropertyValue("--docx-review-gutter-start"));_(Number.isFinite(Oe)?Oe:0);};O();let N=hostWindowOf(b).ResizeObserver;if(typeof N>"u")return;let W=new N(O);return W.observe(b),()=>W.disconnect()},[b,s,x,y?.mounted,y?.gutters,B]);let Z=useRef(null);C&&(Z.current=C.pageWidthTwips);let ee=C?.pageWidthTwips??Z.current,j=useRef(null);useEffect(()=>{if(!s||!P)return;let O=Qv(P,H,()=>b);return j.current=O,()=>{O.dispose(),j.current===O&&(j.current=null);}},[s,P,b]),useEffect(()=>j.current?.nudge(),[k,ee]);let oe=Ca(n),$=w0(B,I),V=s&&_c(w-$,oe),ce=useMemo(()=>!s||V||ee===null?0:Mc({viewportWidth:w,pageWidthPx:Math.max(M??0,$e(ee))*T,reservation:oe,inlineEndReservation:I,inlineStartReservation:S,docked:E}),[s,V,ee,M,T,w,oe,I,S,E]);return useEffect(()=>{if(v)return v.setShift(ce),()=>v.setShift(0)},[v,ce]),useEffect(()=>{if(v)return v.setReservation(s&&!V?oe:0),()=>v.setReservation(0)},[v,s,V,oe]),{open:s,setOpen:p,toggle:f,tab:c,setTab:h,paneWidth:n,shift:ce,overlay:V}}var tl=["headings","find","goto"],Do=(...e)=>e.filter(Boolean).join(" ");function ol({className:e,style:t,children:o}){return jsx("div",{className:Do("docx-nav__header",e),style:t,children:o??jsxs(Fragment,{children:[jsx(nl,{}),jsx(rl,{})]})})}function nl({className:e,style:t,children:o}){let{intents:n,t:r}=Po("Close");return jsx("button",{type:"button",className:Do("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:n.close,children:o??jsx(G,{name:"arrow_back",size:20})})}function rl({className:e,style:t,children:o}){let{t:n}=Po("Title");return jsx("h2",{className:Do("docx-nav__title",e),style:t,children:o??n("navigation.title")})}function al({className:e,style:t,children:o}){let{pane:n,t:r}=Po("Tabs"),i=useCallback(a=>{let l=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(l===0)return;a.preventDefault();let s=tl.indexOf(n.tab);n.setTab(tl[(s+l+tl.length)%tl.length]);},[n]);return jsx("div",{className:Do("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:i,children:o??tl.map(a=>jsx(il,{value:a},a))})}function il({value:e,className:t,style:o,children:n}){let{pane:r,t:i,goToShortcut:a}=Po("Tab"),l=Ho(),s=r.tab===e,c=e==="goto"&&a?i("navigation.goTo.tabTitle",{shortcut:l(Uv())}):void 0;return 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:Do("docx-nav__tab",s&&"docx-nav__tab--selected",t),style:o,...c?{title:c,"aria-keyshortcuts":zv()}:{},onClick:()=>r.setTab(e),children:n??i(`navigation.tabs.${e}`)})}function oC({value:e,onChange:t,onClear:o,placeholder:n,label:r,clearLabel:i,autoFocus:a,onEnter:l}){let s=useRef(null);return useEffect(()=>{a&&s.current?.focus();},[a]),jsxs("div",{className:"docx-nav__searchbox",children:[jsx(G,{name:"search",size:18,className:"docx-nav__search-icon"}),jsx("input",{ref:s,type:"search",className:"docx-nav__search-input",value:e,placeholder:n,"aria-label":r,autoFocus:a,onChange:c=>t(c.target.value),onKeyDown:c=>{!l||c.key!=="Enter"||c.nativeEvent.isComposing||(c.preventDefault(),l(c.shiftKey));}}),e.length>0&&jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":i,onClick:o,children:jsx(G,{name:"close",size:16})})]})}function ll({className:e,style:t}){let{pane:o,outline:n,intents:r,t:i}=Po("Headings"),[a,l]=useState(""),s=K(eo),c=useMemo(()=>{let m=a.trim().toLowerCase();return m.length===0?n.items:n.items.filter(u=>u.heading.text.toLowerCase().includes(m))},[n.items,a]),d=o.tab!=="headings";return jsxs("div",{className:Do("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:d,children:[jsx(oC,{value:a,onChange:l,onClear:()=>l(""),placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel")}),s?null:n.isEmpty?jsx("p",{className:"docx-nav__empty",children:i("navigation.headings.noHeadings")}):c.length===0?jsx("p",{className:"docx-nav__empty",children:i("navigation.find.noResults")}):jsx("ul",{className:"docx-nav__list",children:c.map((m,u)=>jsx("li",{children:jsx("button",{type:"button",className:Do("docx-nav__heading",n.selectedBlockId===m.heading.blockId&&"docx-nav__heading--current"),style:{paddingInlineStart:`${8+m.depth*14}px`},title:m.heading.text,onClick:()=>{n.goTo(m.heading.blockId),r.picked();},children:jsx("bdi",{children:m.heading.text})})},`${m.heading.blockId}-${u}`))})]})}function V6({match:e,active:t,onSelect:o}){return jsx("li",{children:jsx("button",{type:"button",className:Do("docx-nav__result",t&&"docx-nav__result--active"),"aria-current":t?"true":void 0,onClick:o,children:jsx("span",{className:"docx-nav__result-text",children:jsxs("bdi",{children:[e.contextBefore,jsx("mark",{className:"docx-nav__result-hit",children:e.text}),e.contextAfter]})})})})}function sl({className:e,style:t}){let{pane:o,search:n,intents:r,t:i}=Po("Find"),a=o.tab!=="find",l=n.query.trim().length>0,s=o.open&&!a,c=n.matches.length===0?null:n.activeIndex<0?i(n.truncated?"navigation.find.totalTruncated":"navigation.find.total",{total:n.matches.length}):i(n.truncated?"navigation.find.counterTruncated":"navigation.find.counter",{current:n.activeIndex+1,total:n.matches.length});return jsxs("div",{className:Do("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:a,children:[jsx(oC,{value:n.query,onChange:n.setQuery,onClear:n.clear,placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel"),autoFocus:s,onEnter:d=>{n.isPending&&n.find(n.query),d?n.previous():n.next();}}),jsxs("div",{className:"docx-nav__options",role:"group","aria-label":i("navigation.find.optionsAriaLabel"),children:[jsxs("label",{className:"docx-nav__option",children:[jsx("input",{type:"checkbox",checked:n.matchCase,onChange:d=>n.setMatchCase(d.target.checked)}),i("navigation.find.matchCase")]}),jsxs("label",{className:"docx-nav__option",children:[jsx("input",{type:"checkbox",checked:n.wholeWord,onChange:d=>n.setWholeWord(d.target.checked)}),i("navigation.find.wholeWord")]})]}),jsxs("div",{className:"docx-nav__resultbar",children:[jsx("span",{className:"docx-nav__count","aria-live":"polite",children:l?n.isPending?i("navigation.find.searching"):c??i("navigation.find.noResults"):""}),jsxs("span",{className:"docx-nav__steppers",children:[jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.previousAriaLabel"),disabled:n.matches.length===0,onClick:n.previous,children:jsx(G,{name:"keyboard_arrow_up",size:18})}),jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.nextAriaLabel"),disabled:n.matches.length===0,onClick:n.next,children:jsx(G,{name:"keyboard_arrow_down",size:18})})]})]}),n.matches.length>0&&jsx("ul",{className:"docx-nav__list","aria-label":i("navigation.find.resultsAriaLabel"),children:n.matches.map((d,m)=>jsx(V6,{match:d,active:m===n.activeIndex,onSelect:()=>{n.goTo(m),r.picked();}},`${d.blockId}-${d.start}-${m}`))})]})}function cl({className:e,style:t,children:o}){let{pane:n,intents:r,findShortcut:i,t:a}=Po("Toggle"),s=Ho()("Ctrl+F"),c=i?$v(s):void 0,d=i?a("navigation.openShortcutTitle",{shortcut:s}):a("navigation.openTitle");return jsx("button",{type:"button",className:Do("docx-nav__toggle",e),style:t,"aria-label":a("navigation.openAriaLabel"),"aria-expanded":n.open,"aria-keyshortcuts":c,title:d,onMouseDown:m=>m.preventDefault(),onClick:r.toggle,children:o??jsx(G,{name:"toc",size:20})})}function ff(e){let t=Lt(),o=at(),{t:n,toggle:r=true,searchHighlight:i="all",findShortcut:a=true,goToShortcut:l=true,className:s,style:c,children:d,...m}=e,u=Fc(m),g=Ic(),p=u.open&&u.tab==="find"?i:"none",f=Nc({highlight:p}),h=Qe(),v=useMemo(()=>n??((P,k)=>h(P,k)),[n,h]),b=Jv(u,a,l),y=useMemo(()=>({pane:u,outline:g,search:f,t:v,intents:b.intents,findShortcut:a,goToShortcut:l}),[u,g,f,v,b.intents,a,l]),C=L(),T=useRef(b.intents);T.current=b.intents;let x=useRef(l);x.current=l,useEffect(()=>{if(C)return C.setGoToChrome({onRequest:()=>T.current.openTab("goto"),get shortcut(){return x.current}})},[C]);let E=e.paneWidth??280;return jsx(lf.Provider,{value:y,children:jsxs("div",{ref:b.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:b.onKeyDown,style:{"--docx-nav-width":`${E}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${Ca(E)}px`,...c},children:[r!==false&&!u.open&&jsx(cl,{...typeof r=="object"?r:{}}),jsx("aside",{className:"docx-nav__panel-shell","aria-label":y.t("navigation.ariaLabel"),inert:!u.open,children:d??jsxs(Fragment,{children:[jsx(ol,{}),jsx(al,{}),jsx(ll,{}),jsx(sl,{}),jsx(Ji,{})]})})]})})}var Lc=Object.assign(ff,{Header:ol,Close:nl,Title:rl,Tabs:al,Tab:il,Headings:ll,Find:sl,GoTo:Ji,Toggle:cl});var oF=600,nF=e=>e.isOpening===true?0:e.page.total,Hc=createContext(null);function Ac({className:e,style:t}){let o=Lt(),n=L(),r=Se(),{inside:i,host:a,hostScoped:l}=I0(r),s=K(nF),{t:c}=F(),d=useContext(Hc),[m,u]=useState(1),[g,p]=useState(false);if(useEffect(()=>{if(p(false),!n||!r||s<=1)return;u(n.getCurrentPage("viewport"));let b=hostWindowOf(r),y=null,C=()=>{u(n.getCurrentPage("viewport")),p(true),y!==null&&b.clearTimeout(y),y=b.setTimeout(()=>p(false),oF);};return r.addEventListener("scroll",C,{passive:true}),()=>{r.removeEventListener("scroll",C),y!==null&&b.clearTimeout(y);}},[n,s,r]),s<=1)return null;let f=a?l?"":"docx-editor ":o,h=d?d("viewer.pageIndicator").replace(/\{current\}/g,String(m)).replace(/\{total\}/g,String(s)):c("viewer.pageIndicator",{current:m,total:s}),v=jsx("div",{className:`${f}docx-editor-shell__page-indicator-chip docx-editor__page-number${e?` ${e}`:""}`,style:t,"data-visible":g?"true":"false",role:"status","aria-live":"polite",children:h});return i?a?createPortal(v,a):null:v}var iF=[],lF=e=>e.fontSubstitutions??iF;function Oc({className:e,style:t,t:o}){let n=K(lF),{t:r}=F(),i=o??r,[a,l]=useState(null);if(n.length===0)return null;let s=n.join("\0");return a===s?null:jsxs("div",{className:e?`docx-font-notice ${e}`:"docx-font-notice",role:"status",...t?{style:t}:{},children:[jsx("span",{className:"docx-font-notice__text",children:i("editor.fontSubstitutionNotice",{fonts:n.join(", ")}).replace("{fonts}",n.join(", "))}),jsx("button",{type:"button",className:"docx-font-notice__dismiss",onClick:()=>l(s),children:i("common.dismiss")})]})}var hF={damaged:"openFailure.reasons.damaged","not-docx":"openFailure.reasons.notDocx","too-large":"openFailure.reasons.tooLarge",blocked:"openFailure.reasons.blocked",unknown:"openFailure.reasons.unknown"};function yF(e,t){return typeof e=="object"&&e!==null&&"reason"in e&&e!==t}var xF=e=>e.openFailure??null;function cC(e={}){let t=K(xF),{t:o}=F(),n=e.t??o,[r,i]=useState(null),a=t!==null&&t!==r?t:null,l=useCallback(s=>{yF(s,t)||i(t);},[t]);return {failure:a,message:a?n(hF[a.reason]):null,dismiss:l}}var dC=createContext(null);function bf({variant:e="secondary",dismiss:t=false,asChild:o=false,className:n,onClick:r,children:i,type:a,...l}){let s=useContext(dC),c=`docx-dialog__button${e==="primary"?" docx-dialog__button--primary":""}${n?` ${n}`:""}`,d=m=>{r?.(m),t&&!m.defaultPrevented&&s?.dismiss();};return o?jsx(X,{...l,className:c,onClick:d,children:i}):jsx("button",{...l,type:a??"button",className:c,onClick:d,children:i})}var sC=new Set;function uC(e,t){if(!t||!gt())return;let o=e===false?"disabled":typeof e=="object"&&e.actions?"both":null;o===null||sC.has(o)||(sC.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 pC(e){return Children.toArray(e).some(t=>isValidElement(t)&&t.type===Fragment$1?pC(t.props.children):true)}function vF({title:e,message:t,showCode:o=true,actions:n,closeLabel:r,showClose:i=true,onDismiss:a,children:l,className:s,style:c,t:d}){let{t:m}=F(),u=d??m,{failure:g,message:p,dismiss:f}=cC({t:u}),h=useId();if(!g||p===null)return null;let v=()=>{f(g),a?.(g);},b={failure:g,message:p,dismiss:v},y=e??u("openFailure.title"),C=typeof t=="function"?t(g):t??p,T=n?.(b),x=pC(T);return jsx(dC.Provider,{value:b,children:jsx(Be,{kind:"openFailure",role:"alertdialog",label:y,className:s,style:c,onClose:v,dismissOutside:false,...l?{}:{describedBy:h},children:l?l(b):jsxs(Fragment,{children:[jsx("header",{className:"docx-dialog__header",children:jsx("h2",{className:"docx-dialog__title",children:y})}),jsxs("div",{className:"docx-dialog__body",children:[jsx("div",{id:h,className:"docx-dialog__message",children:C}),o?jsx("p",{className:"docx-dialog__code",children:u("openFailure.code",{code:g.code}).replace("{code}",g.code)}):null]}),x||i?jsxs("footer",{className:"docx-dialog__footer",children:[T,i?jsx(bf,{variant:x?"secondary":"primary",dismiss:true,children:r??u("common.close")}):null]}):null]})})})}var Bc=Object.assign(vF,{Action:bf});function hf(e){return Math.round(e/1440*100)/100}function mC(e){return Math.round(e*1440)}function EF(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 yf(){let e=L(),t=useCallback(o=>e?.getHeaderFooterState()??null,[e]);return K(t,EF)}function wF(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 DF=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function dl(e){let t=L();return 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 RF(e){let{state:t,onMouseDown:o}=e,{t:n}=F(),r=L(),[i,a]=useState(false),l=useRef(null),[s,c]=useState(""),[d,m]=useState("");useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(c(String(hf(t.headerDistanceTwips))),m(String(hf(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),useEffect(()=>{if(i)return listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let u=useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),p=useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),f=useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),h=useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),v=dl(u),b=dl(g),y=dl(p),C=dl(f),T=dl(h),x=(E,P)=>{if(!r)return;let k=Number.parseFloat(P);Number.isFinite(k)&&r.exec({type:"setHeaderFooterOptions",[E]:mC(k)});};return jsxs("div",{ref:l,className:"docx-hf-chrome__options",onMouseDown:o,children:[jsx("button",{type:"button",className:"docx-context-bar__options-trigger","aria-expanded":i,"aria-haspopup":"menu",onClick:()=>a(E=>!E),onMouseDown:o,children:n("headerFooter.options")}),i?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:o,children:[DF.map(E=>{let P={type:"insertPageField",field:E.field},k=r?.can(P);return jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!k?.ok,title:k&&!k.ok?k.reason:void 0,onClick:()=>{r?.exec(P),a(false);},onMouseDown:o,children:n(E.labelKey)},E.field)}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsx("input",{type:"checkbox",checked:t.titlePage===true,disabled:!v.enabled,title:v.reason??void 0,onChange:()=>r?.exec(u)}),jsx("span",{children:n("headerFooter.differentFirstPage")})]}),jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!b.enabled,title:b.reason??void 0,onChange:()=>r?.exec(g)}),jsxs("span",{children:[n("headerFooter.differentOddEven"),jsx("span",{className:"docx-hf-chrome__menu-hint",children:n("headerFooter.differentOddEvenHint")})]})]}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),t.inherited?jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!C.enabled,title:C.reason??void 0,onClick:()=>r?.exec(f),onMouseDown:o,children:n("headerFooter.unlinkFromPrevious")}):jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!y.enabled,title:y.reason??void 0,onClick:()=>r?.exec(p),onMouseDown:o,children:n("headerFooter.linkToPrevious")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsx("span",{children:n("headerFooter.headerDistance")}),jsx("input",{type:"number",min:0,step:.01,"aria-label":n("headerFooter.headerDistance"),value:s,onChange:E=>c(E.target.value),onBlur:()=>x("headerDistanceTwips",s)}),jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsx("span",{children:n("headerFooter.footerDistance")}),jsx("input",{type:"number",min:0,step:.01,"aria-label":n("headerFooter.footerDistance"),value:d,onChange:E=>m(E.target.value),onBlur:()=>x("footerDistanceTwips",d)}),jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!T.enabled,title:T.reason??void 0,onClick:()=>r?.exec(h),onMouseDown:o,children:t.editing==="header"?n("headerFooter.removeHeader"):n("headerFooter.removeFooter")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item","data-testid":"docx-hf-close",onClick:()=>{r?.exec({type:"exitHeaderFooter"}),a(false);},onMouseDown:o,children:n("common.close")})]}):null]})}function Wc({className:e}){let{t}=F(),o=yf(),n=useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),r=li(n,"story-label"),i=U;if(!o?.editing)return null;let a=wF(o.editing,o.variant);return jsxs("div",{ref:r.ref,className:`docx-context-bar docx-hf-chrome${e?` ${e}`:""}`,role:"region","aria-label":t("headerFooter.chromeAriaLabel"),"data-testid":"docx-hf-chrome",onMouseDown:i,style:{...r.style,zIndex:xt.hfInlineEditor},children:[jsxs("div",{className:"docx-context-bar__label",children:[jsx("span",{className:"docx-context-bar__title",children:t(a)}),o.inherited?jsx("span",{className:"docx-context-bar__status","data-testid":"docx-hf-inherited",title:t("headerFooter.sameAsPreviousHint"),children:t("headerFooter.sameAsPrevious")}):null]}),jsx(RF,{state:o,onMouseDown:i})]})}var NF={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},FF={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},LF={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},HF={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},AF={position:"absolute",top:40,insetInlineStart:0,zIndex:10,pointerEvents:"none"},OF={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)"},BF={padding:"8px 12px"},WF={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},ZF={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},KF={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function qF({forwardedRef:e}){let t=L(),o=useRef(null);return o.current=t,F0({ref:e,editorRef:o}),null}function UF(...e){let t=e.filter(Boolean).join(" ");return t===""?void 0:t}var zF=forwardRef(function(t,o){let{document:n,fonts:r,fontShaping:i,imageDecodePort:a,className:l,t:s,chrome:c=true,title:d,onTitleChange:m,renderTitleBarLeft:u,renderTitleBarRight:g,renderOpenFailureActions:p,loadingIndicator:f,colorMode:h="light",author:v,locale:b,mode:y="edit",modules:C,zoom:T,zoomMode:x,revisionMarkup:E,onRevisionMarkupChange:P,reviewDisplayMode:k,fieldResults:w,contentLockPolicy:D,lockedControlNavigation:M,onReady:H,onChange:I,onFontError:A,onOpen:S,onSave:_,hyperlinkPopup:B,contextMenu:Z=true,menu:ee=true,navigation:j=true,openFailure:oe=true,rulers:$=true}=t;!c&&f!==void 0&&d0(),uC(oe,p!==void 0);let[V,ce]=useState(jh);useEffect(()=>{if(h==="system")return Xh(ce)},[h]);let O=Yh(h,V),{t:N}=F(),W=at(),J=useCallback((we,Ke)=>s?s(we,Ke):N(we,Ke),[s,N]),de=jsxs(Hs,{className:c?O?"dark":void 0:l,style:c?FF:void 0,children:[c?jsx(Wc,{}):null,c?jsx(fs,{}):null,jsx(Ms,{}),$&&c?jsx("div",{style:AF,dir:W,children:jsx(wc,{})}):null,t.children]}),he=c?jsxs("div",{className:`docx-editor${O?" dark":""}${l?` ${l}`:""}`,style:NF,dir:W,children:[jsxs("div",{style:OF,children:[jsxs("div",{style:WF,children:[u?.(),jsxs("div",{style:ZF,children:[m?jsx("input",{"aria-label":J("titleBar.documentNameAriaLabel"),value:d??"",placeholder:J("titleBar.untitled"),onChange:we=>m(we.target.value),style:KF}):jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:d??J("titleBar.untitled")}),ee!==false?jsx($i,{t:J,...d!==void 0?{fileName:d}:{},...S?{onOpen:S}:{},..._?{onSave:_}:{},...typeof ee=="object"?ee:{}}):null]}),g?.()]}),jsx("div",{style:BF,children:jsx(Ki,{t:J})})]}),$?jsx("div",{style:HF,"data-testid":"docx-editor-ruler-row",children:jsx(kc,{})}):null,jsx(Oc,{t:J}),jsxs("div",{style:LF,children:[j===false?null:jsx(Lc,{t:J,...typeof j=="object"?j:{}}),de,jsx(Hc.Provider,{value:J,children:jsx(Ac,{})}),jsx(Is,{overlay:true,indicator:f})]})]}):de,Oe=useCallback(we=>J(we),[J]);return jsxs(hi,{popups:Dh(t.popups,B,Z,J),...n!==void 0?{document:n}:{},...r?{fonts:r}:{},...i?{fontShaping:i}:{},...a?{imageDecodePort:a}:{},...v!==void 0?{author:v}:{},...b!==void 0?{locale:b}:{},translate:J,mode:y,...C!==void 0?{modules:C}:{},...T!==void 0?{zoom:T}:{},revisionMarkup:E,onRevisionMarkupChange:P,reviewDisplayMode:k,...w!==void 0?{fieldResults:w}:{},...D!==void 0?{contentLockPolicy:D}:{},...M!==void 0?{lockedControlNavigation:M}:{},...x!==void 0?{zoomMode:x}:{},tableInteractionLabel:Oe,...H?{onReady:H}:{},...I?{onChange:I}:{},...A?{onFontError:A}:{},children:[jsx(qF,{forwardedRef:o}),jsx(Gn.Provider,{value:c,children:he}),oe===false?null:jsx(Bc,{t:J,...typeof oe=="object"?oe:{},...p?{actions:p}:{},className:UF(O?"dark":void 0,typeof oe=="object"?oe.className:void 0)})]})}),$F=forwardRef(function(t,o){return jsx(yr,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsx(zF,{...t,ref:o})})}),VF=Object.assign($F,{Root:hi,Viewport:Hs,Content:Ms,Window:Bp,Toolbar:Ki,Menu:$i,Loading:Is,ColorByChangeType:Kp,RevisionMarkup:Hd,RevisionMarkupDialog:Ra,UnsupportedElement:dd,AuthorStyle:qp,HorizontalRuler:kc,VerticalRuler:wc,DocumentOutline:af,Navigation:Lc,ExportDialog:Ma,PrintDialog:_a,PageSetupDialog:Un,WatermarkDialog:zn,BookmarkDialog:ja,SplitCellDialog:Ya,ParagraphDialog:Zo,TextFormFieldDialog:Ja,PageNumber:Ac,FontNotice:Oc,OpenFailure:Bc,HeaderFooterChrome:Wc,NotesChrome:fs,Equation:Ba,HyperLink:La,ContextMenu:Yu,ContentControlWidget:Ip,InvalidTextFormFieldDialog:dp,ImageAltTextPopup:Cs,ImagePropertiesDialog:ci,NotePropertiesDialog:gs,NotePreview:Cr,NotesContextMenu:Tr,ContentControl:Oa});function JF(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}function vf(e){return Array.isArray(e)?e:[e]}function QF(e){if(typeof e!="function"||isFontResolver(e))return e;let t=e;return defineFontResolver(async()=>t())}function yC(e){return e!==void 0&&vf(e).some(t=>isFontResolver(t))}async function eL(e){return typeof e!="function"?await e:await e()}function tL(e,t={}){let[o,n]=useState(void 0),[r,i]=useState(void 0),[a,l]=useState(null),[s,c]=useState(e!=null),d=yC(t.fonts),m=t.fonts===void 0?"absent":d?"on-demand":"eager",[u,g]=useState(t.fonts===void 0),p=useRef(t);p.current=t;let f=useMemo(()=>defineFontResolver(h=>composeFontOrigins(vf(p.current.fonts??[]).map(QF),h)),[]);return useEffect(()=>{let h=p.current.fonts;if(h===void 0){i(void 0),g(true);return}if(yC(h)){g(true);return}g(false);let v=true;return (async()=>{try{let b=await Promise.allSettled(vf(h).map(eL)),y=[];for(let C of b){if(C.status==="rejected"){console.warn("[fonts] font loading failed for one origin; the others still compose",C.reason);continue}C.value!==void 0&&y.push(C.value);}v&&y.length>0&&i(composeFontConfiguration(y[0],...y.slice(1)));}catch(b){console.warn("[fonts] font loading failed; the fixed measurer stays in effect",b);}finally{v&&g(true);}})(),()=>{v=false;}},[m]),useEffect(()=>{if(e==null){n(void 0),l(null),c(false);return}let h=JF(e);if(h){n(h),l(null),c(false);return}let v=true,b=new AbortController;return c(true),l(null),(async()=>{try{let y=await fetch(String(e),{...p.current.fetchOptions,signal:b.signal});if(!y.ok)throw new Error(`could not open the document: ${y.status} ${y.statusText}`);let C=new Uint8Array(await y.arrayBuffer());if(!v)return;n(C),c(!1);}catch(y){if(!v||y instanceof Error&&y.name==="AbortError")return;l(y instanceof Error?y:new Error("could not open the document")),c(false);}})(),()=>{v=false,b.abort();}},[e]),{document:u?o:void 0,fonts:d?f:r,error:a,isLoading:s||!u}}function iL(...e){let t=useRef(e);return t.current=e,useMemo(()=>defineFontResolver(o=>composeFontOrigins(t.current,o)),[])}function cL(e){let o=e?.surface?.state?.().selection?.head;return o&&typeof o.paragraphId=="string"&&Number.isFinite(o.offset)?o:null}function dL(){let e=L(),t=useRef(null),o=useCallback(r=>{if(!e)return ()=>{};let i=e.on("selectionChange",r),a=e.on("change",r);return ()=>{i(),a();}},[e]),n=useCallback(()=>{let r=cL(e),i=t.current;return (r===null?i===null:i!==null&&uL(i,r))?i:(t.current=r,r)},[e]);return useSyncExternalStore(o,n,()=>null)}function uL(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function fL(e){let t=L(),o=useRef(e);o.current=e;let n=typeof e=="function";useEffect(()=>{if(!(!t||!n))return t.setCommentDraftChrome({onRequest:()=>o.current?.()})},[t,n]);}var EC=Object.freeze({applied:0,unavailable:0});function SC(e){if(!e)return "";let{color:t,activeColor:o,activeIndex:n,className:r,priority:i}=e;return JSON.stringify([t,o,n,r,i])}function yL(e,t,o){let n=L(),[r,i]=useState(EC),a=useRef(null),l=useRef(o);l.current=o;let s=useRef(t);s.current=t;let c=SC(o);return useEffect(()=>{if(!n){i(EC);return}let d=watchHighlights(n,e,s.current,{...l.current,onResult:i});return a.current={watch:d,source:s.current,key:SC(l.current)},i(d.result),()=>{d.stop(),a.current=null;}},[n,e]),useEffect(()=>{let d=a.current;!d||d.source===t&&d.key===c||(d.source=t,d.key=c,d.watch.update(t,l.current??{}));},[t,c]),r}function SL(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 PL(e){let t=L(),o=Se(),[n,r]=useState(null);return useEffect(()=>{if(!t){r(null);return}let i=hostDocumentOf(o),a=hostWindowOf(o),l=0,s=null,c=()=>{l=0;let p=s?t.getHighlightsAt(s.x,s.y).find(f=>e===void 0||f.name===e)??null:null;r(f=>SL(f,p)?f:p);},d=()=>{l===0&&(l=a.requestAnimationFrame(c));},m=p=>{let f=p.target;s=isElementNode(f)&&f.closest("[data-page-index]")!==null?{x:p.clientX,y:p.clientY}:null,d();},u=p=>{p.relatedTarget||(s=null,d());};i.addEventListener("pointermove",m,{passive:true}),i.addEventListener("pointerout",u,{passive:true}),i.addEventListener("scroll",d,{passive:true,capture:true});let g=t.on("change",d);return ()=>{i.removeEventListener("pointermove",m),i.removeEventListener("pointerout",u),i.removeEventListener("scroll",d,{capture:true}),g(),l!==0&&a.cancelAnimationFrame(l);}},[t,e,o]),n}function Tf({source:e,scale:t,measurer:o,onStateChange:n,onError:r,className:i,documentFontFamily:a,ref:l}){let s=useRef(null),c=useRef(null),[d,m]=useState(null),u=useRef(n);u.current=n;let g=useRef(r);return g.current=r,useEffect(()=>{let p=s.current;if(!p)return;let f=mountPaginatedSurface(p,e,{...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onChange:v=>{m(v),u.current?.(v);}});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]),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}),[]),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 pl=createContext(null);function PC(){let e=useContext(pl);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function AL(e){return "type"in e&&e.type==="separator"}var DC={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"},OL={...DC,background:"var(--doc-bg-hover)"},RC={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"},BL={...RC,opacity:.4,cursor:"default"},WL={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},ZL={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},KL={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 ml({label:e,items:t,disabled:o,showChevron:n=false}){let[r,i]=useState(false),[a,l]=useState(null),s=useRef(null),c=useRef(null),[d,m]=useState({top:0,left:0}),u=useCallback(()=>{i(false),l(null);},[]);useEffect(()=>{if(!r||!s.current)return;let p=s.current.getBoundingClientRect();m({top:p.bottom+2,left:p.left});},[r]),useEffect(()=>{if(!r)return;function p(y){y.key==="Escape"&&u();}function f(){u();}let h=hostDocumentOf(s.current),v=hostWindowOf(s.current),b=listenForOutsidePress({popup:s.current,contains:y=>!s.current||!c.current||s.current.contains(y)||c.current.contains(y),close:u});return h.addEventListener("keydown",p),v.addEventListener("scroll",f,true),()=>{b(),h.removeEventListener("keydown",p),v.removeEventListener("scroll",f,true);}},[r,u]);let g=p=>{p.disabled||p.submenuContent||p.onClick&&(p.onClick(),u());};return jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:s,type:"button",onClick:()=>!o&&i(!r),onMouseDown:p=>p.preventDefault(),disabled:o,style:r?OL:DC,children:[e,n&&jsx(G,{name:"arrow_drop_down",size:16})]}),r&&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(AL(p))return jsx("div",{style:WL},`sep-${f}`);let h=p;if(h.customContent)return jsx("div",{onMouseDown:y=>y.preventDefault(),children:h.customContent},h.label);let v=!!h.submenuContent,b=a===h.label;return jsxs("div",{style:{position:"relative"},onMouseEnter:()=>v&&l(h.label),onMouseLeave:()=>v&&l(null),children:[jsxs("button",{type:"button",style:h.disabled?BL:RC,onClick:()=>g(h),onMouseDown:y=>y.preventDefault(),onMouseOver:y=>{h.disabled||(y.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:y=>{y.currentTarget.style.backgroundColor="transparent";},disabled:h.disabled,children:[h.icon&&jsx(G,{name:h.icon,size:18}),jsx("span",{children:h.label}),h.shortcut&&jsx("span",{style:ZL,children:h.shortcut}),v&&jsx("span",{style:{marginLeft:"auto"},children:jsx(G,{name:"keyboard_arrow_right",size:16})})]}),v&&b&&jsx("div",{style:KL,onMouseDown:y=>y.preventDefault(),children:h.submenuContent(u)})]},h.label)})})]})}var Pf=18,UL=2,_C={width:Pf,height:Pf,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},zL={..._C,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},$L={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function IC({onInsert:e,gridRows:t=6,gridColumns:o=6}){let[n,r]=useState(0),[i,a]=useState(0),l=useCallback(()=>{n>0&&i>0&&e(n,i);},[n,i,e]),s=[];for(let d=1;d<=t;d++)for(let m=1;m<=o;m++){let u=d<=n&&m<=i;s.push(jsx("div",{style:u?zL:_C,onMouseEnter:()=>{r(d),a(m);},onClick:l,role:"gridcell","aria-selected":u},`${d}-${m}`));}let c=n>0&&i>0?`${i} \xD7 ${n}`:"Select size";return jsxs("div",{children:[jsx("div",{style:{display:"grid",gap:UL,gridTemplateColumns:`repeat(${o}, ${Pf}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:s}),jsx("div",{style:$L,children:c})]})}function XL({items:e,closeMenu:t}){return jsx("div",{style:{display:"flex",flexDirection:"column",minWidth:220},children:e.map(o=>{let n=!o.onClick;return jsxs("button",{type:"button",disabled:n,style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:n?"default":"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap",opacity:n?.4:1},onMouseDown:r=>r.preventDefault(),onClick:()=>{n||(o.onClick?.(),t());},onMouseOver:r=>{n||(r.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:r=>{r.currentTarget.style.backgroundColor="transparent";},children:[jsx(G,{name:o.icon,size:18}),jsx("span",{children:o.label})]},o.label)})})}function JL(){return jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[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"}),jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function qc({children:e}){return jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function QL(e){return e.replace(/\.docx$/i,"")}function wf({value:e,onChange:t,placeholder:o,editable:n=true}){let{t:r}=F(),i=o??r("titleBar.untitled"),a=QL(e)??"";return n?jsx("input",{type:"text",value:a,onChange:l=>{let s=l.target.value;t?.(s.endsWith(".docx")?s:s+".docx");},placeholder:i,className:"text-base font-normal text-foreground bg-transparent border-0 outline-none px-2 py-0 rounded hover:bg-muted focus:bg-doc-bg-input focus:ring-1 focus:ring-ring min-w-[100px] max-w-[300px] truncate leading-tight","aria-label":r("titleBar.documentNameAriaLabel")}):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 Uc({children:e}){return jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function zc(){let{t:e}=F(),t=PC(),{disabled:o=false,onFormat:n,onPrint:r,onOpen:i,onSave:a,onPageSetup:l,onInsertImage:s,onInsertTable:c,showTableInsert:d=true,showHelpMenu:m=true,onInsertPageBreak:u,onInsertSectionBreakNextPage:g,onInsertSectionBreakContinuous:p,onInsertTOC:f,onWatermark:h,onRefocusEditor:v}=t,b=useCallback(x=>{!o&&n&&n(x);},[o,n]),y=useCallback((x,E)=>{!o&&c&&(c(x,E),hostWindowOf(t.editorRef?.current).requestAnimationFrame(()=>v?.()));},[o,c,v,t.editorRef]),C=!!r||!!l,T=C||i||a;return jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[T&&jsx(ml,{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)&&C?[{type:"separator"}]:[],...r?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:r}]:[],...l?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:l}]:[]]}),jsx(ml,{label:e("toolbar.format"),disabled:o,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>b("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>b("setRtl")}]}),jsx(ml,{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:x=>jsx(IC,{onInsert:(E,P)=>{y(E,P),x();}})}]:[],...s||d&&c?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:x=>jsx(XL,{closeMenu:x,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&&jsx(ml,{label:e("toolbar.help"),disabled:o,items:[{label:e("toolbar.reportIssue"),onClick:()=>Ui()}]})]})}function Df({children:e}){let t=null,o=null,n=[],r=[];Children.forEach(e,a=>{isValidElement(a)&&(a.type===qc?t=a:a.type===Uc?o=a:a.type===zc?r.push(a):n.push(a));});let i=useCallback(a=>{let l=a.target;l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.tagName==="SELECT"||l.tagName==="OPTION"||a.preventDefault();},[]);return jsxs("div",{className:"flex items-stretch bg-doc-surface pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsx(JL,{})}),jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[n.length>0&&jsx("div",{className:"flex items-center gap-2 px-1",children:n}),r.length>0&&jsx("div",{className:"flex items-center px-1",children:r})]}),o&&jsx("div",{className:"flex items-center flex-shrink-0 px-3",children:o})]})}var $c={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},n4={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:""},NC={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 r4(e,t){let o=NC[t]??NC[t.toLowerCase()]??t,r=e?.colorScheme?.[o];return typeof r=="string"&&r?r:$c[o]??"000000"}function FC(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 Rf(e,t,o="000000"){if(!e||e.kind==="auto")return `#${o}`;if(e.kind==="hex")return `#${FC(e.value)??o}`;let n=Object.entries(t?.colorScheme??$c).map(([i,a])=>({slot:i,hex:String(a)})),r=resolveThemeColorHex(e,n);return `#${r.ok?r.hex:r4(t,e.slot)}`}function Vo(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?FC(e.value):Rf(e,t).slice(1)}function LC(e){if(!e||e==="none")return "";let t=n4[e];return t?`#${t}`:""}var a4=[{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"}],i4=[{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 HC(e){let t=e??$c;return i4.map(o=>a4.map(n=>{let r=t[n.slot]??$c[n.slot]??"000000",a={hex:o.type==="base"?r.toUpperCase():o.type==="tint"?applyThemeTint(r,o.keep):applyThemeShade(r,o.keep),themeSlot:n.slot,label:`${n.name}${o.labelSuffix}`};return o.type==="tint"?a.tint=o.keep:o.type==="shade"&&(a.shade=o.keep),a}))}function ue(...e){return clsx(e)}var c4=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"}}),nt=Bt.forwardRef(({className:e,variant:t,size:o,...n},r)=>jsx("button",{className:ue(c4({variant:t,size:o,className:e})),ref:r,...n}));nt.displayName="Button";function Ut({content:e,children:t,side:o="bottom",delayMs:n=400}){let[r,i]=Bt.useState(false),[a,l]=Bt.useState({x:0,y:0}),s=Bt.useRef(null),c=Bt.useRef(null),d=Bt.useCallback(()=>{let p=hostWindowOf(s.current),f=p.setTimeout(()=>{if(s.current){let h=s.current.getBoundingClientRect(),v=h.left+h.width/2,b=o==="top"?h.top-8:h.bottom+8;l({x:v,y:b});}i(true);},n);c.current={win:p,handle:f};},[n,o]),m=Bt.useCallback(()=>{c.current&&(c.current.win.clearTimeout(c.current.handle),c.current=null),i(false);},[]);Bt.useEffect(()=>()=>{c.current&&c.current.win.clearTimeout(c.current.handle);},[]);let u=t.props,g=Bt.cloneElement(t,{ref:s,onMouseEnter:p=>{d(),u.onMouseEnter?.(p);},onMouseLeave:p=>{m(),u.onMouseLeave?.(p);}});return jsxs(Fragment,{children:[g,r&&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 Mf=Bt.createContext(null);function Cn(e){let[t,o]=Bt.useState(null),n=Bt.useMemo(()=>({trigger:t,setTrigger:o}),[t]);return jsx(Mf.Provider,{value:n,children:jsx(Fe.Root,{...e})})}var Tn=Fe.Group,Vc=Fe.Value;function En({className:e,children:t,onMouseDown:o,...n}){let r=Bt.useContext(Mf)?.setTrigger;return jsxs(Fe.Trigger,{ref:r,className:ue("flex h-8 items-center justify-between gap-1 rounded px-2 py-1","text-sm text-foreground bg-transparent","hover:bg-muted/80 focus:outline-none focus:bg-muted/80","disabled:cursor-not-allowed disabled:opacity-50","transition-colors duration-150","[&>span]:truncate",e),onMouseDown:i=>{i.preventDefault(),o?.(i);},...n,children:[t,jsx(Fe.Icon,{asChild:true,children:jsx(y4,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function Sn({className:e,children:t,position:o="popper",onCloseAutoFocus:n,onKeyDown:r,...i}){let a=Bt.useContext(Mf)?.trigger??null,l=typeof globalThis.document>"u"&&!a?null:hostDocumentOf(a),s=!!l?.querySelector(".docx-editor.dark");return jsx(Fe.Portal,{...l?.body?{container:l.body}:{},children:jsx("div",{className:ue("docx-editor",s&&"dark"),children:jsx(Fe.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:c=>{c.preventDefault(),n?.(c);},onKeyDown:c=>{r?.(c),c.defaultPrevented||h4(c);},...i,children:jsx(Fe.Viewport,{className:ue("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:c=>c.preventDefault(),children:t})})})})}var b4=new Set(["ArrowDown","ArrowUp","Home","End"]);function h4(e){let t=e.currentTarget;if(t.ownerDocument===globalThis.document||!b4.has(e.key))return;e.preventDefault();let o=Array.from(t.querySelectorAll('[role="option"]:not([data-disabled])'));if(o.length===0)return;let n=o.indexOf(t.ownerDocument.activeElement),r=n>=0?n:o.findIndex(a=>a.dataset.state==="checked"),i=e.key==="Home"?0:e.key==="End"?o.length-1:e.key==="ArrowDown"?Math.min(o.length-1,r+1):Math.max(0,r<0?0:r-1);o[i].focus({preventScroll:false});}function lr({className:e,...t}){return jsx(Fe.Label,{className:ue("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function zt({className:e,children:t,onMouseDown:o,...n}){return jsxs(Fe.Item,{className:ue("relative flex w-full cursor-pointer select-none items-center","rounded px-2 py-1.5 text-sm text-foreground outline-none","hover:bg-muted focus:bg-muted","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onMouseDown:r=>{r.preventDefault(),o?.(r);},...n,children:[jsx(Fe.ItemText,{children:t}),jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(Fe.ItemIndicator,{children:jsx(x4,{className:"h-4 w-4"})})})]})}function sr({className:e,...t}){return jsx(Fe.Separator,{className:ue("-mx-1 my-1 h-px bg-muted",e),...t})}function y4({className:e}){return jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children: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 x4({className:e}){return jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children: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 _f(e){let t=e.trim();if(!t)return "";let o=null,n="";for(let r of t){if((r==='"'||r==="'")&&o===null){o=r,n+=r;continue}if(r===o){o=null,n+=r;continue}if(r===","&&o===null)break;n+=r;}return n.trim().replace(/^['"]|['"]$/g,"")}var v4=[{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 BC({value:e,onChange:t,fonts:o=v4,documentFonts:n,disabled:r=false,className:i,placeholder:a="Arial",width:l=120,showPreview:s=true}){let{t:c}=F(),d=Bt.useMemo(()=>{if(!n)return [];let f=new Set(o.map(h=>h.name.toLowerCase()));return n.filter(h=>!f.has(h.name.toLowerCase()))},[n,o]),m=Bt.useMemo(()=>[...d,...o],[d,o]),u=Bt.useMemo(()=>e?m.find(h=>h.fontFamily===e||h.name.toLowerCase()===e.toLowerCase()||_f(h.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,m,a]),g=Bt.useCallback(f=>{let h=m.find(v=>v.name===f);h&&t?.(_f(h.fontFamily)||h.name);},[t,m]),p=Bt.useMemo(()=>{let f={"sans-serif":[],serif:[],monospace:[],other:[]};return o.forEach(h=>{let v=h.category||"other";f[v].push(h);}),f},[o]);return jsxs(Cn,{value:u,onValueChange:g,disabled:r,children:[jsx(En,{className:ue("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":c("font.selectAriaLabel"),children:jsx(Vc,{placeholder:a,children:u})}),jsxs(Sn,{className:"max-h-[300px]",children:[d.length>0&&jsxs(Fragment,{children:[jsxs(Tn,{children:[jsx(lr,{children:c("font.documentFonts")}),d.map(f=>jsx(zt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},`doc-${f.name}`))]}),jsx(sr,{})]}),p["sans-serif"].length>0&&jsxs(Tn,{children:[jsx(lr,{children:c("font.sansSerif")}),p["sans-serif"].map(f=>jsx(zt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]}),p.serif.length>0&&jsxs(Fragment,{children:[jsx(sr,{}),jsxs(Tn,{children:[jsx(lr,{children:c("font.serif")}),p.serif.map(f=>jsx(zt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.monospace.length>0&&jsxs(Fragment,{children:[jsx(sr,{}),jsxs(Tn,{children:[jsx(lr,{children:c("font.monospace")}),p.monospace.map(f=>jsx(zt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.other.length>0&&jsxs(Fragment,{children:[jsx(sr,{}),jsx(Tn,{children:p.other.map(f=>jsx(zt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))})]})]})]})}function If(e){if(e===void 0)return;let t=e.map(o=>typeof o=="string"?{name:o,fontFamily:o,category:"other"}:o);if(gt()){let o=new Set,n=new Set;for(let r of t)n.has(r.name)&&!o.has(r.name)&&(console.warn(`[DocxEditor] Duplicate font name in fontFamilies: "${r.name}"`),o.add(r.name)),n.add(r.name);}return t}function k4(e,t,o,n,r){let a=Math.max(8,e.innerWidth-n-8),l=Math.max(8,e.innerHeight-r-8);return {top:Math.min(Math.max(8,t),l),left:Math.min(Math.max(8,o),a)}}function Rt({isOpen:e,onClose:t,align:o="left"}){let n=useRef(null),r=useRef(null),[i,a]=useState({top:0,left:0});useEffect(()=>{if(!e||!n.current)return;let c=n.current.getBoundingClientRect();if(o==="right"){let d=hostWindowOf(n.current);d.requestAnimationFrame(()=>{if(r.current){let m=r.current.getBoundingClientRect(),u=k4(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]),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&&r.current&&r.current.contains(h)||isElementNode(h)&&h!==h.ownerDocument.documentElement&&h!==h.ownerDocument.body&&n.current&&h.contains(n.current)||t();},u=hostDocumentOf(n.current),g=hostWindowOf(n.current),p=listenForOutsidePress({popup:n.current,contains:f=>!n.current||!r.current||n.current.contains(f)||r.current.contains(f),close:()=>t()});return u.addEventListener("keydown",d),g.addEventListener("scroll",m,true),()=>{p(),u.removeEventListener("keydown",d),g.removeEventListener("scroll",m,true);}},[e,t]);let l=useCallback(c=>{c.preventDefault(),c.stopPropagation();},[]),s={position:"fixed",top:i.top,left:i.left,zIndex:1e4};return {containerRef:n,dropdownRef:r,dropdownStyle:s,handleMouseDown:l}}var M4=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],_4=1,I4=400;function qC(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function UC(e,t,o){for(let n=t.length-1;n>=0;n--)if(t[n]<e)return t[n];return Math.max(e-1,o)}function zC({value:e,onChange:t,sizes:o=M4,disabled:n=false,className:r,placeholder:i="11",minSize:a=_4,maxSize:l=I4}){let{t:s}=F(),[c,d]=useState(false),[m,u]=useState(""),[g,p]=useState(false),f=useRef(null),h=useCallback(()=>{p(false),d(false);},[]),{containerRef:v,dropdownRef:b,dropdownStyle:y}=Rt({isOpen:g,onClose:h}),C=e??(parseInt(i,10)||11),T=e!==void 0?e.toString():i,x=useCallback(I=>{if(I.preventDefault(),n)return;let A=UC(C,o,a);t?.(A);},[C,o,a,n,t]),E=useCallback(I=>{if(I.preventDefault(),n)return;let A=qC(C,o,l);t?.(A);},[C,o,l,n,t]),P=useCallback(I=>{I.preventDefault(),!n&&(d(true),u(T),p(true),hostWindowOf(f.current).requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();}));},[n,T]),k=useCallback(I=>{u(I.target.value);},[]),w=useCallback(()=>{d(false);let I=parseFloat(m);if(!isNaN(I)&&I>=a&&I<=l){let A=Math.round(I*2)/2;t?.(A);}},[m,a,l,t]),D=useCallback(I=>{if(I.key==="Enter")I.preventDefault(),w(),p(false);else if(I.key==="Escape")d(false),p(false);else if(I.key==="ArrowUp"){I.preventDefault();let A=qC(C,o,l);u(A.toString()),t?.(A);}else if(I.key==="ArrowDown"){I.preventDefault();let A=UC(C,o,a);u(A.toString()),t?.(A);}},[w,C,o,l,a,t]),M=useCallback(I=>{t?.(I),p(false),d(false);},[t]),H=useCallback(I=>{I.target.tagName!=="INPUT"&&I.preventDefault();},[]);return jsxs("div",{ref:v,className:ue("flex items-center",r),onMouseDown:H,children:[jsx(nt,{variant:"ghost",size:"icon-sm",className:ue("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:x,disabled:n||C<=a,"aria-label":s("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsx(G,{name:"remove",size:18})}),jsx("div",{className:"relative",children:c?jsx("input",{ref:f,type:"text",value:m,onChange:k,onBlur:w,onKeyDown:D,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"}):jsx("button",{type:"button",onClick:P,className:ue("h-7 w-10 text-center text-sm border border-border bg-doc-bg-input text-doc-text","hover:border-input hover:bg-doc-bg-hover","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none",n&&"opacity-50 cursor-not-allowed"),disabled:n,"aria-label":s("fontSize.label"),"aria-haspopup":"listbox","aria-expanded":g,"data-testid":"font-size-display",children:T})}),g&&jsx("div",{ref:b,style:{...y,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(I=>jsx("button",{type:"button",onClick:()=>M(I),className:ue("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",I===C&&"bg-muted font-medium"),role:"option","aria-selected":I===C,children:I},I))}),jsx(nt,{variant:"ghost",size:"icon-sm",className:ue("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:E,disabled:n||C>=l,"aria-label":s("fontSize.increase"),"data-testid":"font-size-increase",children:jsx(G,{name:"add",size:18})})]})}var L4=[{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"}],jc=18,H4=2,A4={position:"relative",display:"inline-block"},O4={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)"},B4={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},Lf={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},Hf={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},GC={display:"grid",gap:`${H4}px`},Yc={width:`${jc}px`,height:`${jc}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},jC={...Yc,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},YC={...Yc,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},W4={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)"},Z4={display:"flex",alignItems:"center",gap:"6px"},K4={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},q4={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},$C={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},U4={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},z4={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)"},$4={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 Af(e,t,o){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let n=LC(e);return n||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return Rf(e,o)}function VC(e){let t=e.replace(/^#/,"");if(t.length!==6)return false;let o=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return (o*299+n*587+r*114)/1e3>230}function XC(e,t,o){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():Vo(e,o))===t.toUpperCase():false}function V4({matrix:e,selectedColor:t,theme:o,onSelect:n}){let[r,i]=useState(null);return jsx("div",{style:{...GC,gridTemplateColumns:`repeat(10, ${jc}px)`},children:e.flatMap((a,l)=>a.map((s,c)=>{let d=`${l}-${c}`,m=r===d,u=XC(t,s.hex,o);return jsx("button",{type:"button",style:{...u?YC:m?jC:Yc,backgroundColor:`#${s.hex}`},title:s.label,"aria-label":s.label,"aria-selected":u,onClick:()=>n(s),onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>i(d),onMouseLeave:()=>i(null)},d)}))})}function G4({selectedColor:e,theme:t,onSelect:o}){let[n,r]=useState(null),{t:i}=F();return jsx("div",{style:{...GC,gridTemplateColumns:`repeat(10, ${jc}px)`},children:L4.map((a,l)=>{let s=n===l,c=XC(e,a.hex,t),d=i(a.nameKey);return jsx("button",{type:"button",style:{...c?YC:s?jC:Yc,backgroundColor:`#${a.hex}`},title:d,"aria-label":d,"aria-selected":c,onClick:()=>o(a.hex),onMouseDown:m=>m.preventDefault(),onMouseEnter:()=>r(l),onMouseLeave:()=>r(null)},a.hex)})})}function ur({mode:e,value:t,onChange:o,theme:n,disabled:r=false,className:i,style:a,title:l,icon:s,autoLabel:c,splitButton:d=true,defaultColor:m}){let[u,g]=useState(false),[p,f]=useState(false),[h,v]=useState(false),[b,y]=useState(false),[C,T]=useState(""),[x,E]=useState(()=>m??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:P}=F();useEffect(()=>{let O=Af(t,e,n).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(O)&&T(O.toUpperCase());},[t,e,n]);let k=useCallback(()=>g(false),[]),{containerRef:w,dropdownRef:D,dropdownStyle:M}=Rt({isOpen:u,onClose:k}),H=n?.colorScheme??null,I=useMemo(()=>HC(H),[H]),A=useMemo(()=>Af(t,e,n),[t,e,n]),S=useMemo(()=>Af(x,e,n),[x,e,n]),_=useCallback(()=>{r||g(O=>!O);},[r]),B=useCallback(O=>{let N;e==="highlight"?N=O.hex:N={kind:"theme",slot:O.themeSlot,...O.tint!==void 0?{tint:O.tint}:{},...O.shade!==void 0?{shade:O.shade}:{}},E(N),o?.(N),g(false);},[e,o]),Z=useCallback(O=>{let N=e==="highlight"?O:{kind:"hex",value:O};E(N),o?.(N),g(false);},[e,o]),ee=useCallback(()=>{o?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,o]),j=useCallback(()=>{let O=C.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(O)){let N=e==="highlight"?O:{kind:"hex",value:O};E(N),o?.(N),g(false),T("");}},[e,C,o]),oe=useCallback(()=>{r||o?.(x);},[r,x,o]),$={...O4,...r?{cursor:"default",opacity:.38}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:p?{backgroundColor:"var(--doc-bg-hover)"}:{}},V=P(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),ce=s??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxs("div",{ref:w,className:`docx-color-picker ${i||""}`,style:{...A4,...a},children:[d?jsxs("div",{className:"docx-color-picker-split",style:{...U4,...r?{opacity:.38,cursor:"default"}:null},children:[jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...z4,...r?{cursor:"default"}:h?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:oe,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>v(true),onMouseLeave:()=>v(false),disabled:r,title:l||V,"aria-label":l||V,children:[jsx(G,{name:ce,size:18}),jsx("div",{style:{...$C,backgroundColor:S==="transparent"?"#fff":S,outline:S==="transparent"||VC(S)?"1px solid #bbb":"none"}})]}),jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...$4,...r?{cursor:"default"}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:b?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:_,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>y(true),onMouseLeave:()=>y(false),disabled:r,title:l||V,"aria-label":l||V,"aria-haspopup":"true","aria-expanded":u,children:jsx(G,{name:"arrow_drop_down",size:18})})]}):jsxs("button",{type:"button",className:"docx-color-picker-button",style:$,onClick:_,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>f(true),onMouseLeave:()=>f(false),disabled:r,title:l||V,"aria-label":l||V,"aria-haspopup":"true","aria-expanded":u,children:[jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsx(G,{name:ce,size:18}),jsx("div",{style:{...$C,backgroundColor:A==="transparent"?"#fff":A,outline:A==="transparent"||VC(A)?"1px solid #bbb":"none"}})]}),jsx(G,{name:"arrow_drop_down",size:14})]}),u&&jsx("div",{ref:D,className:"docx-color-picker-dropdown",style:{...M,...B4},role:"dialog","aria-label":`${V} picker`,onMouseDown:O=>{O.target.tagName!=="INPUT"&&O.preventDefault();},children:jsxs(Fragment,{children:[jsxs("button",{type:"button",style:W4,onClick:ee,onMouseDown:O=>O.preventDefault(),children:[e==="highlight"?jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",border:"1px solid #ccc",borderRadius:"2px",position:"relative",backgroundColor:"#fff"},children:jsx("span",{style:{position:"absolute",top:"50%",left:"-1px",right:"-1px",height:"2px",backgroundColor:"#ff0000",transform:"rotate(-45deg)"}})}):jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",backgroundColor:"#000",borderRadius:"2px"}}),c??P(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsx("div",{style:Hf}),jsx("div",{style:Lf,children:P("colorPicker.themeColors")}),jsx(V4,{matrix:I,selectedColor:t,theme:n,onSelect:B}),jsx("div",{style:Hf}),jsx("div",{style:Lf,children:P("colorPicker.standardColors")}),jsx(G4,{selectedColor:t,theme:n,onSelect:Z}),jsx("div",{style:Hf}),jsx("div",{style:Lf,children:P("colorPicker.customColor")}),jsxs("div",{style:Z4,children:[jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsx("input",{type:"text",style:K4,value:C,onChange:O=>T(O.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:O=>{O.key==="Enter"&&j();},onMouseDown:O=>{O.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsx("button",{type:"button",style:{...q4,opacity:/^[0-9A-Fa-f]{6}$/.test(C)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(C)?"pointer":"default"},onClick:j,onMouseDown:O=>O.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(C),children:P("common.apply")})]})]})})]})}var gl=20,Of=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsx(G,{name:"format_align_left",size:gl}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsx(G,{name:"format_align_center",size:gl}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsx(G,{name:"format_align_right",size:gl}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsx(G,{name:"format_align_justify",size:gl}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function eT({value:e="left",onChange:t,disabled:o=false}){let{t:n}=F(),[r,i]=useState(false),a=useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:s,dropdownStyle:c,handleMouseDown:d}=Rt({isOpen:r,onClose:a}),m=useCallback(v=>{o||t?.(v),i(false);},[o,t]),u=Of.find(v=>v.value===e)||Of[0],g=n(u.labelKey),p=u.shortcutKey?n(u.shortcutKey):void 0,f=`${g}${p?` (${p})`:""}`,h=jsxs(nt,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",o&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!o&&i(v=>!v),disabled:o,"aria-label":f,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsx(G,{name:u.iconName,size:gl}),jsx(G,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[r?h:jsx(Ut,{content:f,children:h}),r&&!o&&jsx("div",{ref:s,style:{...c,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:8,boxShadow:"0 4px 16px var(--doc-shadow)",padding:6},onMouseDown:v=>v.stopPropagation(),children:jsx("div",{style:{display:"flex",gap:2},children:Of.map(v=>{let b=e===v.value,y=n(v.labelKey),C=v.shortcutKey?n(v.shortcutKey):void 0;return jsx("button",{type:"button",title:`${y}${C?` (${C})`:""}`,"data-testid":`alignment-${v.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,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)"},onMouseDown:T=>T.preventDefault(),onMouseEnter:T=>{b||(T.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:T=>{T.currentTarget.style.backgroundColor=b?"var(--doc-primary-light)":"transparent";},onClick:()=>m(v.value),children:jsx(G,{name:v.iconName,size:18})},v.value)})})})]})}function Xc(){return {type:"none",level:0,isInList:false}}var Q4={display:"inline-flex",alignItems:"center",gap:"4px"},tT={display:"inline-flex",alignItems:"center",gap:"4px"},td={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)"},e3={...td,backgroundColor:"var(--doc-bg-hover)"},t3={...td,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},o3={...td,cursor:"default",opacity:.38},n3={width:"28px",height:"28px",padding:"2px"},r3={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Jc=20;function Qc({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,style:a}){let[l,s]=useState(false),c={...t?o3:e?t3:l?e3:td,...a},d=m=>{m.preventDefault();};return jsx("button",{type:"button",className:`docx-list-button ${e?"docx-list-button-active":""} ${t?"docx-list-button-disabled":""} ${i||""}`,style:c,onMouseDown:d,onClick:t?void 0:n,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-disabled":t||void 0,tabIndex:t?-1:void 0,title:o,"aria-label":o,"aria-pressed":e,role:"button",children:r})}function oT({listState:e,onBulletList:t,onNumberedList:o,onIndent:n,onOutdent:r,disabled:i=false,className:a,style:l,showIndentButtons:s=true,compact:c=false,hasIndent:d=false}){let{t:m}=F(),u=useCallback(()=>c?{...n3}:{},[c]),g=e?.type==="bullet",p=e?.type==="numbered",h=(e?.isInList||g||p)&&(e?.level??0)>0||d;return jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...Q4,...l},role:"group","aria-label":m("lists.ariaLabel"),children:[jsxs("div",{style:tT,role:"group","aria-label":m("lists.typeAriaLabel"),children:[jsx(Qc,{active:g,disabled:i,title:m("lists.bulletList"),onClick:t,style:u(),children:jsx(G,{name:"format_list_bulleted",size:Jc})}),jsx(Qc,{active:p,disabled:i,title:m("lists.numberedList"),onClick:o,style:u(),children:jsx(G,{name:"format_list_numbered",size:Jc})})]}),s&&jsxs(Fragment,{children:[jsx("div",{style:r3,role:"separator"}),jsxs("div",{style:tT,role:"group","aria-label":m("lists.indentationAriaLabel"),children:[jsx(Qc,{active:false,disabled:i||!h,title:m("lists.decreaseIndent"),onClick:r,style:u(),children:jsx(G,{name:"format_indent_decrease",size:Jc})}),jsx(Qc,{active:false,disabled:i,title:m("lists.increaseIndent"),onClick:n,style:u(),children:jsx(G,{name:"format_indent_increase",size:Jc})})]})]})]})}var i3=[{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 rT({value:e,onChange:t,options:o=i3,disabled:n=false,className:r}){let{t:i}=F(),a=Bt.useMemo(()=>e===void 0?o[0]:o.find(c=>c.twipsValue===e)||o[0],[e,o]),l=Bt.useCallback(c=>{let d=parseInt(c,10);isNaN(d)||t?.(d);},[t]),s=c=>c.labelKey?i(c.labelKey):c.label;return jsxs(Cn,{value:a.twipsValue.toString(),onValueChange:l,disabled:n,children:[jsx(En,{className:ue("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},"aria-label":i("lineSpacing.label"),title:i("lineSpacing.lineSpacingTitle",{label:s(a)}),children:jsx(nf,{className:"h-5 w-5 shrink-0"})}),jsxs(Sn,{children:[o.map(c=>jsx(zt,{value:c.twipsValue.toString(),children:s(c)},c.twipsValue)),jsx(sr,{}),jsx(Tn,{children:jsx(lr,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var aT=[{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 iT({value:e,onChange:t,styles:o,disabled:n=false,className:r,width:i=120}){let{t:a}=F(),l=Bt.useMemo(()=>{let g=Gy(o);return g.length===0?aT:g.map(p=>({...p,type:"paragraph",nameKey:aT.find(f=>f.styleId===p.styleId)?.nameKey}))},[o]),s=Bt.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 jsxs(Cn,{value:d,onValueChange:s,disabled:n,children:[jsx(En,{className:ue("h-8 text-sm",r),style:{width:typeof i=="number"?`${i}px`:i},"aria-label":a("styles.selectAriaLabel"),children:jsx("span",{className:"truncate",children:u})}),jsx(Sn,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsx(zt,{value:g.styleId,className:"py-2.5 px-3",children:jsx("span",{style:Vy(g),children:c(g)})},g.styleId))})]})}var s3=[{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 sT({value:e=1,onChange:t,levels:o=s3,disabled:n=false,className:r,compact:i=false}){let{t:a}=F(),l=Bt.useMemo(()=>{let g=o.find(p=>Math.abs(p.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[o,e]),s=Bt.useCallback(g=>{let p=parseFloat(g);isNaN(p)||t?.(p);},[t]),c=Bt.useMemo(()=>[...o].sort((g,p)=>g.value-p.value),[o]),d=Bt.useMemo(()=>[...c].reverse().find(g=>g.value<e-.001),[c,e]),m=Bt.useMemo(()=>c.find(g=>g.value>e+.001),[c,e]),u=i?"h-7 w-7":"h-8 w-8";return jsxs("div",{className:"flex items-center",children:[jsx(nt,{variant:"ghost",size:"icon-sm",className:ue(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",(n||!d)&&"opacity-30 cursor-not-allowed"),onClick:()=>d&&t?.(d.value),disabled:n||!d,"aria-label":a("zoom.zoomOut"),children:jsx(G,{name:"remove",size:18})}),jsxs(Cn,{value:e.toString(),onValueChange:s,disabled:n,children:[jsx(En,{className:ue(i?"h-7 min-w-[55px] text-xs":"h-8 min-w-[64px] text-sm","rounded-none",r),"aria-label":a("zoom.ariaLabel",{label:l}),children:jsx(Vc,{placeholder:"100%",children:l})}),jsx(Sn,{children:o.map(g=>jsx(zt,{value:g.value.toString(),children:g.label},g.value))})]}),jsx(nt,{variant:"ghost",size:"icon-sm",className:ue(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(n||!m)&&"opacity-30 cursor-not-allowed"),onClick:()=>m&&t?.(m.value),disabled:n||!m,"aria-label":a("zoom.zoomIn"),children:jsx(G,{name:"add",size:18})})]})}var d3=[{action:"borderAll",icon:"border_all",labelKey:"table.borders.all"},{action:"borderOutside",icon:"border_outer",labelKey:"table.borders.outside"},{action:"borderInside",icon:"border_inner",labelKey:"table.borders.inside"},{action:"borderTop",icon:"border_top",labelKey:"table.borders.top"},{action:"borderBottom",icon:"border_bottom",labelKey:"table.borders.bottom"},{action:"borderLeft",icon:"border_left",labelKey:"table.borders.left"},{action:"borderRight",icon:"border_right",labelKey:"table.borders.right"},{action:"borderNone",icon:"border_clear",labelKey:"table.borders.none"}];function uT({onAction:e,disabled:t=false}){let{t:o}=F(),[n,r]=useState(false),i=useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=Rt({isOpen:n,onClose:i}),d=useCallback(u=>{e(u),r(false);},[e]),m=jsxs(nt,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&r(u=>!u),disabled:t,"aria-label":o("table.borders.styleAriaLabel"),"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[jsx(G,{name:"border_all",size:20}),jsx(G,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[n?m:jsx(Ut,{content:o("table.borders.tooltip"),children:m}),n&&!t&&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:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:d3.map(({action:u,icon:g,labelKey:p})=>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:jsx(G,{name:g,size:18})},typeof u=="string"?u:u.type))})})]})}function pT({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=F(),i=useCallback(a=>{if(typeof a=="string"){e({type:"borderColor",color:a.replace(/^#/,"")});return}let l=a.kind==="auto"?"000000":Vo(a,o);l&&e({type:"borderColor",color:l});},[e,o]);return jsx(ur,{mode:"border",value:n,onChange:i,theme:o,disabled:t,title:r("table.borderColor")})}var f3=[{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 fT({onAction:e,disabled:t=false}){let[o,n]=useState(false),{t:r}=F(),i=useCallback(()=>n(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=Rt({isOpen:o,onClose:i}),d=useCallback(u=>{e({type:"borderWidth",size:u}),n(false);},[e]),m=jsxs(nt,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",o&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&n(u=>!u),disabled:t,"aria-label":r("table.borderWidth"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[jsx(G,{name:"line_weight",size:20}),jsx(G,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[o?m:jsx(Ut,{content:r("table.borderWidth"),children:m}),o&&!t&&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:f3.map(({size:u,label:g,thickness:p})=>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:[jsx("div",{style:{width:50,height:Math.max(p,1),backgroundColor:"#000",borderRadius:p>2?1:0}}),jsx("span",{children:g})]},u))})]})}function bT({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=F(),i=useCallback(a=>{typeof a=="string"&&e(a==="none"?{type:"cellFillColor",color:null}:{type:"cellFillColor",color:a.replace(/^#/,"")});},[e]);return jsx("div",{"data-testid":"toolbar-table-cell-fill",style:{display:"inline-block"},children:jsx(ur,{mode:"highlight",value:n,onChange:i,theme:o,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var b3={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"},fr={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},xT={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function vT({onAction:e,disabled:t=false,tableContext:o}){let{t:n}=F(),[r,i]=useState(false),[a,l]=useState(null),s=useCallback(()=>i(false),[]),{containerRef:c,dropdownRef:d,dropdownStyle:m,handleMouseDown:u}=Rt({isOpen:r,onClose:s,align:"right"}),g=o?.table?.attrs?.justification??"left",p=useCallback(v=>{e(v),i(false);},[e]),f=(v,b,y,C,T)=>{let x=t||T?.itemDisabled;return jsxs("button",{type:"button",role:"menuitem",style:{...b3,backgroundColor:a===v&&!x?"var(--doc-bg-hover)":"transparent",color:x?"var(--doc-text-muted)":T?.danger?"var(--doc-error)":"var(--doc-text)",cursor:x?"not-allowed":"pointer"},onClick:()=>!x&&p(C),onMouseEnter:()=>l(v),onMouseLeave:()=>l(null),disabled:x,children:[jsx(G,{name:b,size:16,className:T?.danger&&!x?"text-destructive":""}),jsx("span",{style:{flex:1},children:y})]},v)},h=jsx(nt,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!t&&i(v=>!v),disabled:t,"aria-label":n("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsx(G,{name:"more_vert",size:20})});return jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[r?h:jsx(Ut,{content:n("table.moreOptions"),children:h}),r&&!t&&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:v=>v.stopPropagation(),children:[f("addRowAbove","add",n("table.insertRowAbove"),"addRowAbove"),f("addRowBelow","add",n("table.insertRowBelow"),"addRowBelow"),f("addColumnLeft","add",n("table.insertColumnLeft"),"addColumnLeft"),f("addColumnRight","add",n("table.insertColumnRight"),"addColumnRight"),jsx("div",{style:fr,role:"separator"}),f("mergeCells","call_merge",n("table.mergeCells"),"mergeCells",{itemDisabled:!o?.hasMultiCellSelection}),f("splitCell","call_split",n("table.splitCell"),"splitCell",{itemDisabled:!o?.canSplitCell}),jsx("div",{style:fr,role:"separator"}),f("selectTable","select_all",n("table.selectTable"),"selectTable"),jsx("div",{style:fr,role:"separator"}),f("deleteRow","delete",n("table.deleteRow"),"deleteRow",{danger:true,itemDisabled:(o?.rowCount??0)<=1}),f("deleteColumn","delete",n("table.deleteColumn"),"deleteColumn",{danger:true,itemDisabled:(o?.columnCount??0)<=1}),f("deleteTable","delete",n("table.deleteTable"),"deleteTable",{danger:true}),jsx("div",{style:fr,role:"separator"}),jsx("div",{style:xT,children:n("tableAdvanced.verticalAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(v=>{let b={top:"vertical_align_top",center:"vertical_align_center",bottom:"vertical_align_bottom"};return jsx("button",{type:"button",title:n({top:"tableAdvanced.top",center:"tableAdvanced.middle",bottom:"tableAdvanced.bottom"}[v]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:C=>C.preventDefault(),onMouseEnter:C=>{C.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent";},onClick:()=>p({type:"cellVerticalAlign",align:v}),children:jsx(G,{name:b[v],size:16})},v)})}),jsx("div",{style:fr,role:"separator"}),jsx("div",{style:xT,children:n("tableAdvanced.tableAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(v=>{let b={left:"format_align_left",center:"format_align_center",right:"format_align_right"},y=g===v;return jsx("button",{type:"button",title:n({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[v]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:y?"var(--doc-primary-light)":"transparent",borderColor:y?"var(--doc-primary)":"var(--doc-border)",color:y?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:C=>C.preventDefault(),onClick:()=>p({type:"tableProperties",props:{justification:v}}),children:jsx(G,{name:b[v],size:16})},v)})}),jsx("div",{style:fr,role:"separator"}),f("headerRow","table_rows",n("tableAdvanced.toggleHeaderRow"),{type:"toggleHeaderRow"}),f("distribute","view_column",n("tableAdvanced.distributeColumns"),{type:"distributeColumns"}),f("autoFit","fit_width",n("tableAdvanced.autoFit"),{type:"autoFitContents"}),f("noWrap","wrap_text",n("tableAdvanced.toggleNoWrap"),{type:"toggleNoWrap"}),jsx("div",{style:fr,role:"separator"}),f("properties","settings",n("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var y3=20;function rd({options:e,activeValue:t,triggerIcon:o,tooltipContent:n,onSelect:r,disabled:i=false,ariaLabel:a,testId:l,showLabels:s=false}){let[c,d]=useState(false),m=useCallback(()=>d(false),[]),{containerRef:u,dropdownRef:g,dropdownStyle:p,handleMouseDown:f}=Rt({isOpen:c,onClose:m}),h=useCallback(b=>{i||r(b),d(false);},[i,r]),v=jsxs(nt,{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(b=>!b),disabled:i,"aria-label":a??n,"aria-expanded":c,"aria-haspopup":"true","data-testid":l,children:[jsx(G,{name:o,size:y3}),jsx(G,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:u,style:{position:"relative",display:"inline-block"},children:[c?v:jsx(Ut,{content:n,children:v}),c&&!i&&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:b=>b.stopPropagation(),children:jsx("div",{style:{display:"flex",flexDirection:s?"column":"row",gap:s?1:2,minWidth:s?200:void 0},children:e.map(b=>{let y=t===b.value;return jsxs("button",{type:"button",title:b.label,"data-testid":l?`${l}-${b.value}`:void 0,style:{display:"flex",alignItems:"center",height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:y?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:y?"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:C=>C.preventDefault(),onMouseEnter:C=>{y||(C.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:C=>{C.currentTarget.style.backgroundColor=y?"var(--doc-primary-light)":"transparent";},onClick:()=>h(b.value),children:[jsx(G,{name:b.iconName,size:18}),s&&jsx("span",{style:{flex:1},children:b.label})]},b.value)})})})]})}var x3=[{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 v3(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function TT({imageContext:e,onChange:t,disabled:o=false}){let{t:n}=F(),r=x3.map(l=>({...l,label:n(l.labelKey)})),i=v3(e),a=r.find(l=>l.value===i)||r[0];return jsx(rd,{options:r,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:o,testId:"toolbar-image-wrap",showLabels:true})}var T3=[{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 ET({onTransform:e,disabled:t=false}){let{t:o}=F(),n=T3.map(r=>({...r,label:o(r.labelKey)}));return jsx(rd,{options:n,triggerIcon:"rotate_right",tooltipContent:o("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var io=18;function $t({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,ariaLabel:a}){let l=a?.toLowerCase().replace(/\s+/g,"-")||o?.toLowerCase().replace(/\s+/g,"-").replace(/\([^()]*\)/g,"").trim(),s=d=>{d.preventDefault();},c=jsx(nt,{variant:"ghost",size:"icon-sm",className:ue("docx-editor-toolbar-toggle text-muted-foreground",t&&"opacity-30 cursor-not-allowed",i),"data-active":e?"true":void 0,onMouseDown:s,onClick:t?void 0:n,"aria-disabled":t||void 0,tabIndex:t?-1:void 0,"aria-pressed":!!e,"aria-label":a||o,"data-testid":l?`toolbar-${l}`:void 0,children:r});return o?jsx(Ut,{content:o,children:c}):c}function lo({label:e,children:t,className:o}){return 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 w3(e){let t=Bt__default.useContext(pl);return t?{...t,...D3(e)}:e}function D3(e){let t={};for(let o of Object.keys(e))e[o]!==void 0&&(t[o]=e[o]);return t}function qf(e){let{t}=F(),o=w3(e),{currentFormatting:n={},onFormat:r,onUndo:i,onRedo:a,canUndo:l=false,canRedo:s=false,disabled:c=false,className:d,style:m,enableShortcuts:u=true,editorRef:g,children:p,showFontPicker:f=true,fontFamilies:h,documentFonts:v,showFontSizePicker:b=true,showTextColorPicker:y=true,showHighlightColorPicker:C=true,showAlignmentButtons:T=true,showListButtons:x=true,showLineSpacingPicker:E=true,showStylePicker:P=true,documentStyles:k,theme:w,showZoomControl:D=true,zoom:M,onZoomChange:H,onRefocusEditor:I,imageContext:A,onImageWrapType:S,onImageTransform:_,onOpenImageProperties:B,tableContext:Z,onTableAction:ee,inline:j=false}=o,oe=useRef(null),$=useCallback(ae=>{!c&&r&&r(ae);},[c,r]),V=useCallback(()=>{!c&&l&&i&&i();},[c,l,i]),ce=useCallback(()=>{!c&&s&&a&&a();},[c,s,a]),O=useCallback(ae=>{!c&&r&&r({type:"fontFamily",value:ae});},[c,r]),N=Bt__default.useMemo(()=>If(h),[h]),W=useCallback(ae=>{!c&&r&&r({type:"fontSize",value:ae});},[c,r]),J=useCallback(ae=>{!c&&r&&r({type:"textColor",value:ae});},[c,r]),de=useCallback(ae=>{!c&&r&&r({type:"highlightColor",value:typeof ae=="string"?ae:""});},[c,r]),he=useCallback(ae=>{!c&&r&&r({type:"alignment",value:ae});},[c,r]),Oe=useCallback(()=>{!c&&r&&r("bulletList");},[c,r]),we=useCallback(()=>{!c&&r&&r("numberedList");},[c,r]),Ke=useCallback(()=>{!c&&r&&r("indent");},[c,r]),Te=useCallback(()=>{!c&&r&&r("outdent");},[c,r]),Io=useCallback(ae=>{!c&&r&&(r({type:"lineSpacing",value:ae}),hostWindowOf(oe.current).requestAnimationFrame(()=>I?.()));},[c,r,I]),co=useCallback(ae=>{!c&&r&&r({type:"applyStyle",value:ae});},[c,r]),_t=useCallback(ae=>{!c&&ee&&(ee(ae),hostWindowOf(oe.current).requestAnimationFrame(()=>I?.()));},[c,ee,I]);useEffect(()=>{if(!u)return;let ae=Ie=>{if(Ie.defaultPrevented)return;let uo=Ie.target,Jo=g?.current,It=oe.current,No=Jo?.contains(uo),br=It?.contains(uo);if(!No&&!br)return;if((Ie.ctrlKey||Ie.metaKey)&&!Ie.altKey)switch(Ie.key.toLowerCase()){case "b":Ie.preventDefault(),$("bold");break;case "i":Ie.preventDefault(),$("italic");break;case "u":Ie.preventDefault(),$("underline");break;case "=":Ie.shiftKey?(Ie.preventDefault(),$("superscript")):(Ie.preventDefault(),$("subscript"));break;case "l":Ie.preventDefault(),he("left");break;case "e":Ie.preventDefault(),he("center");break;case "r":Ie.preventDefault(),he("right");break;case "j":Ie.preventDefault(),he("both");break;case "k":Ie.preventDefault(),$("insertLink");break}},rt=hostDocumentOf(g?.current??oe.current);return rt.addEventListener("keydown",ae),()=>{rt.removeEventListener("keydown",ae);}},[u,$,he,g]);let Xo=useCallback(ae=>{let rt=ae.target;rt.tagName==="INPUT"||rt.tagName==="TEXTAREA"||rt.tagName==="SELECT"||rt.tagName==="OPTION"||ae.preventDefault();},[]),Mn=useCallback(ae=>{let rt=ae.target,Ie=hostDocumentOf(rt).activeElement;rt.tagName==="SELECT"||rt.tagName==="OPTION"||Ie?.tagName==="SELECT"||hostWindowOf(rt).requestAnimationFrame(()=>{I?.();});},[I]);return jsxs("div",{ref:oe,className:ue(!j&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:j?{display:"contents",...m}:m,role:j?void 0:"toolbar","aria-label":j?void 0:t("toolbar.ariaLabel"),"data-testid":j?void 0:"formatting-bar",onMouseDown:j?void 0:Xo,onMouseUp:j?void 0:Mn,children:[jsxs(lo,{label:t("formattingBar.groups.history"),children:[jsx($t,{onClick:V,disabled:c||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsx(G,{name:"undo",size:io})}),jsx($t,{onClick:ce,disabled:c||!s,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsx(G,{name:"redo",size:io})})]}),D&&jsx(lo,{label:t("formattingBar.groups.zoom"),children:jsx(sT,{value:M,onChange:H,disabled:c,compact:true})}),P&&jsx(lo,{label:t("formattingBar.groups.styles"),children:jsx(iT,{value:n.styleId||"Normal",onChange:co,styles:k,theme:w,disabled:c,width:120})}),(f||b)&&jsxs(lo,{label:t("formattingBar.groups.font"),children:[f&&jsx(BC,{value:n.fontFamily||"Arial",onChange:O,fonts:N,documentFonts:v,disabled:c,width:60,placeholder:"Arial"}),b&&jsx(zC,{value:n.fontSize!==void 0?Wp(n.fontSize):11,onChange:W,disabled:c,width:42,placeholder:"11"})]}),jsxs(lo,{label:t("formattingBar.groups.textFormatting"),children:[jsx($t,{onClick:()=>$("bold"),active:n.bold,disabled:c,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsx(G,{name:"format_bold",size:io})}),jsx($t,{onClick:()=>$("italic"),active:n.italic,disabled:c,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsx(G,{name:"format_italic",size:io})}),jsx($t,{onClick:()=>$("underline"),active:n.underline,disabled:c,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsx(G,{name:"format_underlined",size:io})}),jsx($t,{onClick:()=>$("strikethrough"),active:n.strike,disabled:c,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsx(G,{name:"strikethrough_s",size:io})}),y&&jsx(ur,{mode:"text",value:n.color?.replace(/^#/,""),onChange:J,theme:w,disabled:c,title:t("formattingBar.fontColor")}),C&&jsx(ur,{mode:"highlight",value:n.highlight,onChange:de,theme:w,disabled:c,title:t("formattingBar.highlightColor")}),jsx($t,{onClick:()=>$("insertLink"),disabled:c,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsx(G,{name:"link",size:io})})]}),jsxs(lo,{label:t("formattingBar.groups.script"),children:[jsx($t,{onClick:()=>$("superscript"),active:n.superscript,disabled:c,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsx(G,{name:"superscript",size:io})}),jsx($t,{onClick:()=>$("subscript"),active:n.subscript,disabled:c,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsx(G,{name:"subscript",size:io})})]}),T&&jsx(lo,{label:t("formattingBar.groups.alignment"),children:jsx(eT,{value:n.alignment||"left",onChange:he,disabled:c})}),(x||E)&&jsxs(lo,{label:t("formattingBar.groups.listFormatting"),children:[x&&jsx(oT,{listState:n.listState||Xc(),onBulletList:Oe,onNumberedList:we,onIndent:Ke,onOutdent:Te,disabled:c,showIndentButtons:true,compact:true,hasIndent:(n.indentLeft??0)>0}),E&&jsx(rT,{value:n.lineSpacing,onChange:Io,disabled:c})]}),A&&S&&jsxs(lo,{label:t("formattingBar.groups.image"),children:[jsx(TT,{imageContext:A,onChange:S,disabled:c}),_&&jsx(ET,{onTransform:_,disabled:c}),B&&jsx($t,{onClick:B,disabled:c,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsx(G,{name:"tune",size:io})})]}),Z?.isInTable&&ee&&jsxs(lo,{label:t("formattingBar.groups.table"),children:[jsx(uT,{onAction:_t,disabled:c}),jsx(pT,{onAction:_t,disabled:c,theme:w,value:Vo(Z?.cellBorderColor,w)}),jsx(fT,{onAction:_t,disabled:c}),jsx(bT,{onAction:_t,disabled:c,theme:w,value:Z?.cellBackgroundColor}),jsx(vT,{onAction:_t,disabled:c,tableContext:Z})]}),jsx($t,{onClick:()=>$("clearFormatting"),disabled:c,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsx(G,{name:"format_clear",size:io})}),p]})}function R3({children:e,className:t,style:o,...n}){return jsx(pl.Provider,{value:n,children:jsx("div",{className:ue("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:xt.toolbar,...o},"data-testid":"editor-toolbar",children:e})})}var Mt=R3;Mt.TitleBar=Df;Mt.Logo=qc;Mt.DocumentName=wf;Mt.MenuBar=zc;Mt.TitleBarRight=Uc;Mt.Toolbar=qf;var I3=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"]]),N3=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function F3({source:e,scale:t,measurer:o,documentName:n,onStateChange:r,onError:i,onSave:a,renderTitleBarLeft:l,renderTitleBarRight:s,ref:c,colorMode:d,onZoomChange:m,documentFontFamily:u,className:g}){let p=useRef(null),[f,h]=useState(null),[v,b]=useState({}),[y,C]=useState(null),T=useCallback(k=>{h(k);let w=p.current?.formatting();w&&b({bold:w.bold,italic:w.italic,underline:w.underline,strike:w.strikethrough,superscript:w.superscript,subscript:w.subscript,...w.fontFamily?{fontFamily:w.fontFamily}:{},...w.fontSizeHalfPoints?{fontSize:w.fontSizeHalfPoints}:{},...w.alignment?{alignment:w.alignment}:{},...w.styleId?{styleId:w.styleId}:{},...w.color?{color:`#${w.color}`}:{},...w.highlight?{highlight:w.highlight}:{}}),C(p.current?.sectionProperties()??null),r?.(k);},[r]),x=useCallback(k=>{let w=p.current;if(w){if(typeof k=="string")switch(k){case "bold":return w.toggleRunProperty("b");case "italic":return w.toggleRunProperty("i");case "underline":return w.toggleRunProperty("u",{val:"single"});case "strikethrough":return w.toggleRunProperty("strike");case "superscript":return w.setRunProperty("vertAlign",{val:"superscript"});case "subscript":return w.setRunProperty("vertAlign",{val:"subscript"});case "clearFormatting":w.setRunProperty("b",{val:"0"}),w.setRunProperty("i",{val:"0"}),w.setRunProperty("u",{val:"none"}),w.setRunProperty("strike",{val:"0"}),w.setRunProperty("vertAlign",{val:"baseline"});return;case "setRtl":case "setLtr":return w.setParagraphProperty("bidi",void 0,{paragraphDirection:k==="setRtl"?"rtl":"ltr"});default:return}switch(k.type){case "fontFamily":return w.setRunProperty("rFonts",{ascii:k.value,hAnsi:k.value});case "fontSize":return w.setRunProperty("sz",{val:String(Math.round(k.value*2))});case "textColor":{let D=k.value,M=typeof D=="string"?N3(D):Vo(D,null)??null;return M?w.setRunProperty("color",{val:M}):void 0}case "highlightColor":{let D=k.value.trim().toLowerCase();if(D==="none"||D==="")return w.setRunProperty("highlight",{val:"none"});let M=I3.get(D.startsWith("#")?D:`#${D}`);return M?w.setRunProperty("highlight",{val:M}):void 0}case "alignment":return w.setParagraphProperty("jc",{val:String(k.value)},{physicalAlignment:true});case "lineSpacing":return w.setParagraphProperty("spacing",{line:String(Math.round(k.value)),lineRule:"auto"},{mergeAttributes:true});case "applyStyle":return w.setParagraphProperty("pStyle",{val:k.value});default:return}}},[]);useImperativeHandle(c,()=>p.current,[]);let E=t===void 0?1:t/(96/72),P=y?{pageWidthTwips:y.pageSize.widthTwips,pageHeightTwips:y.pageSize.heightTwips,orientation:y.landscape?"landscape":"portrait",marginsTwips:{top:y.margins.topTwips,right:y.margins.rightTwips,bottom:y.margins.bottomTwips,left:y.margins.leftTwips}}:null;return 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:[jsxs(Mt,{currentFormatting:v,onFormat:x,onUndo:()=>p.current?.undo(),onRedo:()=>p.current?.redo(),canUndo:f?.canUndo??false,canRedo:f?.canRedo??false,zoom:E,onZoomChange:m,onSave:()=>{let k=p.current?.save();k&&a?.(k);},children:[jsxs(Mt.TitleBar,{children:[l&&jsx(Mt.Logo,{children:l()}),jsx(Mt.DocumentName,{value:n??"Document",editable:false}),s&&jsx(Mt.TitleBarRight,{children:s()}),jsx(Mt.MenuBar,{})]}),jsx(Mt.Toolbar,{})]}),jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[P?jsx("div",{style:{padding:"4px 0"},children:jsx(nr,{pageSetup:P,zoom:E})}):null,jsx(Tf,{ref:p,source:e,...u?{documentFontFamily:u}:{},...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onStateChange:T,...i?{onError:i}:{}})]})]})}var id=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 ld=class extends id{notifications=[];idCounter=0;timers=new Set;constructor(){super({notifications:[]});}showError(t,o){return this.addNotification(t,"error",o)}showWarning(t,o){return this.addNotification(t,"warning",o)}showInfo(t,o){return this.addNotification(t,"info",o)}dismiss(t){this.notifications=this.notifications.map(n=>n.id===t?{...n,dismissed:true}:n),this.emitSnapshot();let o=globalThis.setTimeout(()=>{this.timers.delete(o),this.notifications=this.notifications.filter(n=>n.id!==t),this.emitSnapshot();},300);this.timers.add(o);}clearAll(){this.notifications=[];for(let t of this.timers)globalThis.clearTimeout(t);this.timers.clear(),this.emitSnapshot();}destroy(){for(let t of this.timers)globalThis.clearTimeout(t);this.timers.clear(),this.notifications=[];}addNotification(t,o,n){let r=`error-${++this.idCounter}-${Date.now()}`,i={id:r,message:t,severity:o,details:n,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),o!=="error"){let a=globalThis.setTimeout(()=>{this.timers.delete(a),this.dismiss(r);},5e3);this.timers.add(a);}return r}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var W3=createContext(null);function RT({children:e}){let t=useMemo(()=>new ld,[]),o=useSyncExternalStore(t.subscribe,t.getSnapshot),n=useCallback((c,d)=>{t.showError(c,d);},[t]),r=useCallback((c,d)=>{t.showWarning(c,d);},[t]),i=useCallback((c,d)=>{t.showInfo(c,d);},[t]),a=useCallback(c=>{t.dismiss(c);},[t]),l=useCallback(()=>{t.clearAll();},[t]),s=useMemo(()=>({notifications:o.notifications,showError:n,showWarning:r,showInfo:i,dismissNotification:a,clearNotifications:l}),[o.notifications,n,r,i,a,l]);return jsxs(W3.Provider,{value:s,children:[e,jsx(Z3,{notifications:o.notifications,onDismiss:a})]})}function Z3({notifications:e,onDismiss:t}){let o=e.filter(r=>!r.dismissed);return o.length===0?null:jsx("div",{className:"docx-notification-container",style:{position:"fixed",top:"16px",right:"16px",zIndex:10001,display:"flex",flexDirection:"column",gap:"8px",maxWidth:"400px"},children:o.map(r=>jsx(K3,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function K3({notification:e,onDismiss:t}){let{t:o}=F(),[n,r]=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 jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsx("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:l,children:jsxs("div",{style:s,children:[jsx("span",{style:c,children:p(e.severity)}),jsxs("div",{style:d,children:[jsx("div",{style:m,children:e.message}),e.details&&jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>r(!n),style:{...g,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:o(n?"errors.hideDetails":"errors.showDetails")}),n&&jsx("div",{style:u,children:e.details})]})]}),jsx("button",{type:"button",onClick:t,style:g,title:o("common.dismiss"),children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}var sd=class extends Component{constructor(t){super(t),this.state={hasError:false,error:null,errorInfo:null};}static getDerivedStateFromError(t){return {hasError:true,error:t}}componentDidCatch(t,o){this.setState({errorInfo:o}),console.error("ErrorBoundary caught an error:",t,o),this.props.onError&&this.props.onError(t,o);}resetError=()=>{this.setState({hasError:false,error:null,errorInfo:null});};render(){if(this.state.hasError){let{fallback:t,showDetails:o=true}=this.props,{error:n,errorInfo:r}=this.state;return t?typeof t=="function"?t(n,this.resetError):t:jsx(q3,{error:n,errorInfo:r,showDetails:o,onReset:this.resetError})}return this.props.children}};function q3({error:e,errorInfo:t,showDetails:o,onReset:n}){let{t:r}=F(),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 jsxs("div",{className:"docx-error-fallback",style:i,children:[jsx("div",{style:a,children:jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsx("h2",{style:l,children:r("errors.somethingWentWrong")}),jsx("p",{style:s,children:r("errors.errorDescription")}),o&&jsxs("div",{style:c,children:[jsx("strong",{children:r("errors.errorLabel")})," ",e.message,t&&jsxs(Fragment,{children:[`
1
+ import*as Bt from'react';import Bt__default,{createContext,useCallback,useState,useRef,useEffect,forwardRef,useMemo,useLayoutEffect,useId,useContext,useSyncExternalStore,Children,useReducer,Fragment as Fragment$1,isValidElement,cloneElement,createElement,useImperativeHandle,Component}from'react';import {REVISION_MARKUP_COLORS,tableChromeIconPaths,CHROME_MENUS,hostWindowOf,listenForOutsidePress,commandForSlotValue,hostDocumentOf,chromeProbeForSlot,isHTMLElementNode,NO_MIXED_FIELDS,seedFields,mixedFieldsOf,changedFields,withTabStop,inchesToTwips,twipsToInches,formatInches,TAB_ALIGNMENT_LABELS,CHROME_GROUPS,chromeSlotId,editorCommandKey,toolbarCommandState,commandExecOptions,runToolbarCommand,LOADING_SNAPSHOT,placeSubmenu,submenuKeys,calendarDateText,calendarMonthNames,toolbarPopupLeft,isDomNode,FIT_WIDTH_ZOOM_MODE,sameZoomMode,AUTO_ZOOM_MODE,lineSpacingMenuRows,lineSpacingMenuRowLabel,chromeSlotIsToggle,TABLE_BORDER_TARGET_OPTIONS,TABLE_BORDER_STYLE_OPTIONS,TABLE_BORDER_WIDTH_OPTIONS,collapseOrder,TOOLBAR_COLLAPSE_ORDER,toolbarShownCount,toolbarHostPanelShown,editorInstanceScope,goToBookmarkGroups,isElementNode,clipboardPasteLandsContent,clipboardDropLandsText,createDocxEditor,resolveZoomMode,resolveRevisionMarkup,defaultTableLabel,validateDrawingPositionInput,positionInputFromPropertiesCommand,DRAWING_REL_FROM_H,DRAWING_REL_FROM_V,IMAGE_WRAP_TARGETS,isChromePrintShortcut,openEditorWindow,trapTabWithin,alignmentAfterDirectionChange,editorHostDocument,bookmarkDialogInitialName,bookmarkDialogRows,bookmarkDialogNameState,initialSplitCellCounts,readSplitCellCounts,TEXT_FORM_FORMATS,commandForSlot,contentControlPopupOpener,observeContentControlPopup,contentControlPopupKeyDown,listenForPopupEscape,listenForPopupFocusLeave,formattingBarChromeGroups,TOOLBAR_PINNED_GROUPS,arrangeToolbarGroups,toolbarGroupItems,toolbarGroupsKey,readToolbarRow,toolbarItemKey,toolbarOverflowItems,TOOLBAR_OVERFLOW_HYSTERESIS,sameItemOverflow,TOOLBAR_ITEM_ATTRIBUTE,hasOpenNestedPopup,DEFAULT_TABLE_CHROME_DRAFT,runTableChromeCommand,runChromeExport,ChromeExportError,ChromePrintError,runChromePrint,editorHostElement,createDocumentSearch,goToBookmarkRows,goToBookmarkTarget,observeHostDirection,REVIEW_MARKERS_GUTTER_PX,overlayHostOrigin,createImageOverlayScrollPort,captureImageMutationPreconditions,isStaleImageInteractionCommit,selectedDrawingOverlayTargetOf,historyShortcutOf,IMAGE_OVERLAY_NUDGE_SHIFT_PT,IMAGE_OVERLAY_NUDGE_PT,computeImageResizeResult,resizePreservesAspect,computeMovedImagePosition,overlayFrameToSheetCssPixels,textboxFrameReason,dragIndent,handlePosition,rulerMarginTicks,rulerTabPosition,unsupportedElementRuleMatches,observeUnsupportedElements,executeImageCommand,watermarkShapeBox,SPLIT_CELL_FALLBACK_MAX,createContentControlListNavigation,parseIsoDate,calendarMonth,shiftMonth,isoDateOf,calendarDateFromText,CONTENT_CONTROL_PICTURE_ACCEPT,toolbarPanelPlacement,tableChromeToolbarState,ZOOM_MAX,ZOOM_MIN,hostTimers,goToBookmarkMatch,reviewPaneEntitledZoom,hostDirectionOf,storyLabelTop,cssPixelsToLayoutPoints,finalizeImageOverlayInteraction,SNAP_TWIPS_CM,SNAP_TWIPS_INCH,DEFAULT_IMAGE_RESOURCE_LIMITS as DEFAULT_IMAGE_RESOURCE_LIMITS$1,sniffImageMime,validateRasterHeader,chordLetter,isGoToChord,tableChromeLabelKeyForTarget,defineFontResolver,composeFontOrigins,composeFontConfiguration,watchHighlights,mountPaginatedSurface,bindHistoryGroup,calendarDateForKey,isFontResolver,applyThemeTint,applyThemeShade,resolveThemeColorHex}from'@docx-editor.dev/core/editor';export{CHROME_GROUPS,CHROME_MENUS,DEFAULT_FONT,DocumentRefreshError,HIGHLIGHT_REFRESH_MS,LOADING_SNAPSHOT,MAX_RESOLVER_FAMILIES,PX_PER_CM,PX_PER_INCH,SEARCH_DEBOUNCE_MS,SEARCH_HIGHLIGHT_PRIORITY,SEARCH_HIGHLIGHT_SET,SEARCH_MATCH_LIMIT,WORD_DEFAULT_FONT,chromeMenuSlots,commandForSlot,composeFontConfiguration,composeFontOrigins,createDocumentRefresh,createFontSource,deferFonts,defineFontResolver,generateRulerTicks,isFontResolver,loadFonts,rulerPageBox,runToolbarCommand,toolbarCommandState}from'@docx-editor.dev/core/editor';import {createPortal,flushSync}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {en,localizeDisabledReason,createT,chromeDirection,catalogDirection,deepMerge,platformShortcut,isApplePlatform}from'@docx-editor.dev/i18n';import {DEFAULT_IMAGE_RESOURCE_LIMITS}from'@docx-editor.dev/core/store';import {cva}from'class-variance-authority';import {clsx}from'clsx';import*as Fe from'@radix-ui/react-select';export{EditorFontError}from'@docx-editor.dev/core/contracts/editor';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?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])=>unsupportedElementRuleMatches(f,p.unsupported))?.[0]===u)}}}var xn=createContext(null);function ag(e){return Children.toArray(e).some(t=>isValidElement(t)&&t.type===Fragment$1?ag(t.props.children):typeof t!="string"||t.trim().length>0)}function ig({host:e,children:t}){let o=ag(t);return useLayoutEffect(()=>(e.setCustomized(o),()=>{e.setCustomized(false);}),[e,o]),o?createPortal(t,e.slot):null}function Cd({match:e,layout:t,includePartial:o,children:r}){let n=useContext(xn);if(!n)throw new Error("DocxEditor.UnsupportedElement must render inside DocxEditor.Root.");let i=useRef(Symbol("unsupported-element-declaration")).current;return useSyncExternalStore(n.subscribe,n.snapshot,n.snapshot),useLayoutEffect(()=>{n.register(i,{includePartial:o,...e?{match:e}:{},...t?{layout:t}:{}});},[n,i,e,t,o]),useLayoutEffect(()=>()=>n.unregister(i),[n,i]),n.hosts(i).map(a=>jsx(ig,{host:a,children:r({element:a.unsupported})},a.key))}var Td=createContext(en),Ed=createContext("en"),Sd=createContext("ltr"),Pd=createContext(void 0);function vn({i18n:e,dir:t,children:o}){let r=useContext(Td),n=useContext(Ed),i=useContext(Sd),a=useContext(Pd),l=typeof e?._lang=="string"?e._lang:n,s=chromeDirection(t,e,a),c=s??catalogDirection(e)??i,d=useMemo(()=>deepMerge(r,e),[r,e]);return jsx(Ed.Provider,{value:l,children:jsx(Sd.Provider,{value:c,children:jsx(Pd.Provider,{value:s,children:jsx(Td.Provider,{value:d,children:o})})})})}function L(){let e=useContext(Td),t=useContext(Ed),o=useContext(Sd);return {t:useMemo(()=>createT(e,t),[e,t]),catalogue:e,lang:t,dir:o}}function it(){return useContext(Pd)}function cg(e){let{t}=L();return useCallback((o,r)=>e?.get(o)??t(o,r),[e,t])}var kd=createContext(null);function H(){return useContext(kd)}function Pl(e){return (e?.mounted??0)+(e?.gutters??0)>0}var Lt=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=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=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=useCallback(()=>l(r?r.snapshot():LOADING_SNAPSHOT),[r,l]),c=useCallback(()=>l(LOADING_SNAPSHOT),[l]);return 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=Children.only(e);if(!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);}),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=createContext(false),Ir=createContext(false);function RE(){let e=useContext(Ao),t=useContext(Ir);return e?"":t?"docx-editor dark ":"docx-editor "}function Rl(e){let t=e==="system",o=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 useContext(Ir)}function qt(){let e=useContext(Ao),t=useContext(Ir);return e?"":t?"docx-editor dark ":"docx-editor "}function NE(){return 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=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){Children.forEach(y,b=>{isValidElement(b)&&(x(b),r(b.props.children,x));});}function n(){let y=useContext(e);if(!y)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return y.state}function i(y,x){return Children.map(y,b=>{if(!isValidElement(b))return b;let v=Sg(b.props);return v&&x.has(v)?x.get(v):b.props.children===void 0?b:cloneElement(b,{children:i(b.props.children,x)})})}function a(y){function x(b){let v=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 jsx(J,{...R,...S?{className:S}:{},...k?{style:k}:{},children:C})}return 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=>Children.toArray(S).flatMap(k=>isValidElement(k)&&k.type===Fragment$1?C(k.props.children):[k]),E=C(x).filter(S=>!isValidElement(S)||!o(S));return jsx(e.Provider,{value:{defaults:P,overrides:T,state:v},children:b?jsxs(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=useRef(null),p=l??g,f=useRef(i);f.current=i;let[h,y]=useState(false),x=Kt();return 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]),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()):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=useRef(null);return 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=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 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=createContext(null);function Fr(){return useContext(Ad)}var kg=()=>0,Od=()=>()=>{};function Lr(){let e=Fr(),t=useCallback(r=>e?e.subscribeShift(r):Od(),[e]),o=useCallback(()=>e?e.getShift():0,[e]);return useSyncExternalStore(t,o,kg)}function wg(){let e=Fr(),t=useCallback(r=>e?e.subscribeReservation(r):Od(),[e]),o=useCallback(()=>e?e.getReservation():0,[e]);return useSyncExternalStore(t,o,kg)}function ke(){let e=Fr(),t=useCallback(n=>e?e.subscribeViewport(n):Od(),[e]),o=useCallback(()=>e?e.getViewport():null,[e]),r=useCallback(()=>null,[]);return useSyncExternalStore(t,o,r)}function Oo(e,t,o){let r=ke(),n=useRef({close:o,viewport:r});n.current={close:o,viewport:r},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=>{isDomNode(l.relatedTarget)&&!e.contains(l.relatedTarget)&&t();},i=listenForPopupEscape({popup:e,contains:l=>e.contains(l),chromeRoot:()=>e.closest(".docx-editor"),editorElements:()=>[o()],skip:l=>isElementNode(l.target)&&e.contains(l.target)&&l.target.matches('input[role="combobox"]'),close:l=>{l&&e.querySelector("[aria-haspopup]")?.focus(),t();}}),a=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:editorCommandKey(e),n=useRef(e);n.current=e;let i=useCallback(s=>{let c=n.current;if(Bd(c)){let m=toolbarCommandState(t,c);return {active:m.active,enabled:m.enabled,disabledReason: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:localizeDisabledReason(d.reason??null,o),value:null}},[t,r,o]),a=W(i,lS),l=useCallback(s=>{let c=commandExecOptions(s),d=n.current;return Bd(d)?runToolbarCommand(t,d,void 0,c??{}).ok:t?t.exec(d,c).ok:false},[t]);return useMemo(()=>({execute:l,isActive:a.active,isEnabled:a.enabled,disabledReason:a.disabledReason,value:a.value}),[l,a])}var Hr=createContext({t:void 0,onSave:void 0});function cS(){return useContext(Hr)}function _l(e){let{t}=L();return o=>e?.(o)??t(o)}function ne(){let{t:e}=useContext(Hr);return _l(e)}var mS=()=>()=>{},fS=()=>true,gS=()=>false;function Yt(){let e=useSyncExternalStore(mS,fS,gS);return useCallback(t=>e?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 import.meta.env}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 CHROME_GROUPS)for(let o of t.controls)if(chromeSlotId(t,o)===e)return o;return null}function re(e){return e?jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:e.map(t=>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=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?jsx(J,{...y,children:n}):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 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 jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.themeColors")}),jsxs("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--theme",role:"group",children:[r.map((a,l)=>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 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]=useState(""),a=MS.test(n);return jsxs(Fragment,{children:[jsx(NS,{...e}),jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.standardColors")}),jsx("div",{className:"docx-toolbar__swatch-grid",role:"group",children:DS.map(l=>jsx(Tn,{value:l.value,css:l.css,title:o(l.labelKey),selected:r===l.value,apply:t},l.value))})]}),jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:o("colorPicker.customColor")}),jsxs("div",{className:"docx-toolbar__swatch-custom",children:[jsx("span",{className:"docx-toolbar__swatch-hash","aria-hidden":"true",children:"#"}),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());}}),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 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 jsxs("div",{className:"docx-toolbar__swatch-section",children:[jsx("div",{className:"docx-toolbar__swatch-heading",children:t("colorPicker.highlightColors")}),jsx("div",{className:"docx-toolbar__swatch-grid docx-toolbar__swatch-grid--highlight",role:"group",children:LS.map(r=>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]=useState(false),[y,x]=useState(o),b=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;useEffect(()=>{if(f)return listenForOutsidePress({popup:b.current,close:()=>h(false)})},[f]);let C=useCallback(k=>{if(h(false),!m)return;m.focus();let w=commandForSlotValue(t,k);w&&m.can(w).ok&&(m.exec(w),k!==n.value&&x(k));},[m]),E=useMemo(()=>Q(t),[]);if(c)return null;let S=p(E?.labelKey??t);return jsxs("div",{ref:b,className:`docx-toolbar__colorsplit${s?` ${s}`:""}`,"data-slot":t,children:[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),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:r(y)},"aria-hidden":"true"})]}),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?jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":S,onMouseDown:U,children:[jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:U,onClick:()=>C(n.value),children:[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=>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=>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=useId(),[l,s]=useState(false),c=useRef(null),d=useRef(null),m=useRef(null);useLayoutEffect(()=>{if(!l||!m.current||!d.current)return;let g=observeContentControlPopup(m.current,d.current);return (m.current.querySelector("[data-selected]")??m.current.querySelector("button"))?.focus(),g},[l]),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 jsxs("div",{ref:c,className:"docx-revision-color-picker",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||s(false);},children:[jsx("span",{id:`${a}-label`,children:e}),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:[jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:zd(t)}}),jsx("span",{id:`${a}-value`,children:i(`values.${t}`)})]}),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:[jsx("div",{className:"docx-revision-color-special",children:o.filter(g=>["auto","none","byAuthor"].includes(g)).map(g=>jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear","aria-pressed":t===g,"data-selected":t===g?"":void 0,onClick:()=>{n(g),u();},children:[jsx("span",{className:"docx-revision-color-swatch","aria-hidden":"true",style:{backgroundColor:zd(g)}}),i(`values.${g}`)]},g))}),jsx("div",{className:"docx-toolbar__swatch-grid",children:o.filter(g=>!["auto","none","byAuthor"].includes(g)).map(g=>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",...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 jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxs("div",{className:"docx-revision-markup-row",children:[jsx("span",{className:"docx-revision-markup-row-title","aria-hidden":"true",children:t(a)}),jsxs("label",{children:[jsx("span",{className:"docx-revision-markup-field-label",children:t(a)}),jsx("select",{value:r[a].mark,disabled:s,onChange:c=>e.setValue(a,{...r[a],mark:c.target.value}),children:l.map(c=>jsx("option",{value:c,children:t(`values.${c}`)},c))})]}),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"&&jsx("div",{className:"docx-revision-markup-background",children:jsx(Ll,{label:t(`${a}Background`),value:r[a].background,values:["none","byAuthor",...REVISION_MARKUP_COLORS],disabled:s,t,change:c=>e.setValue(a,{...r[a],background:c})})})]})},i=a=>jsxs("div",{"data-docx-part":"field","data-docx-field":a,children:[jsxs("label",{children:[jsx("input",{type:"checkbox",checked:r[a],"aria-describedby":`${o}-${a}`,onChange:l=>e.setValue(a,l.target.checked)}),t(a)]}),jsx("p",{id:`${o}-${a}`,children:t(`${a}Note`)})]});return jsxs(Fragment,{children:[jsxs("fieldset",{children:[jsx("legend",{children:t("markup")}),n("insertions"),n("deletions"),n("changedLines")]}),jsxs("fieldset",{children:[jsx("legend",{children:t("moves")}),i("trackMoves"),n("movedFrom"),n("movedTo")]}),jsxs("fieldset",{"data-docx-part":"field","data-docx-field":"cells",className:"docx-revision-markup-tableCells",children:[jsx("legend",{children:t("tableCells")}),["inserted","deleted","merged","split"].map(a=>jsx(Ll,{label:t(`${a}Cells`),value:r.cells[a],values:["byAuthor","none",...REVISION_MARKUP_COLORS],t,change:l=>e.setValue("cells",{...r.cells,[a]:l})},a))]}),jsxs("fieldset",{children:[jsx("legend",{children:t("formatting")}),i("trackFormatting"),n("formatting")]})]})}var Jt=St();function XS(){return Jt.useState()}function JS({session:e,...t}){return e?jsx(QS,{session:e,...t}):null}function QS({session:e,children:t,preset:o,className:r,style:n}){let i=useId(),{t:a}=L(),l=f=>a(`revisionMarkup.${f}`),s=useCallback(f=>e.subscribe(f),[e]),c=useCallback(()=>e.get(),[e]),d=useSyncExternalStore(s,c,c),[m,u]=useState(e.signal.aborted),g=useRef(null);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: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:jsx(Jt.Composition,{state:p,preset:o,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",children:jsx("h2",{"data-docx-part":"title",children:l("title")})}),jsx("div",{"data-docx-part":"body",className:"docx-revision-markup-body",children:Kg(p,l,i)}),jsxs("div",{"data-docx-part":"footer",className:"docx-revision-markup-actions",children:[jsx("button",{"data-docx-part":"reset",type:"button",onClick:p.reset,children:l("reset")}),jsx("span",{"data-docx-part":"error",role:"alert",children:p.errors.form}),jsx("button",{"data-docx-part":"cancel",type:"button",onClick:p.cancel,children:l("cancel")}),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=useRef(e.onRevisionMarkupChange);o.current=e.onRevisionMarkupChange;let{onRevisionMarkupChange:r,...n}=e,i=JSON.stringify(n);return useEffect(()=>t?.on("revisionMarkupChange",a=>o.current?.(a)),[t]),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 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??jsxs(Fragment,{children:[jsxs("header",{className:"docx-dialog__header",children:[o&&jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsx("span",{className:"docx-export-dialog__spinner"})}),jsx("h2",{className:"docx-dialog__title",children:c})]}),jsx("div",{className:"docx-dialog__body",children:jsx("p",{className:"docx-export-dialog__message",role:r?"alert":"status",children:r||s("toolbar.exportDownloadHint")})}),jsx("footer",{className:"docx-dialog__footer",children: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 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=>{isChromePrintShortcut(m.nativeEvent)&&m.preventDefault();},children:l??jsxs(Fragment,{children:[jsxs("header",{className:"docx-dialog__header",children:[t&&jsx("div",{className:"docx-export-dialog__progress","aria-hidden":"true",children:jsx("span",{className:"docx-export-dialog__spinner"})}),jsx("h2",{className:"docx-dialog__title",children:c})]}),o&&jsx("div",{className:"docx-dialog__body",children:jsx("p",{className:"docx-export-dialog__message",role:"alert",children:o})}),jsxs("footer",{className:"docx-dialog__footer",children:[o&&d&&jsx("a",{className:"docx-dialog__link-button docx-print-dialog__open",href:d,target:"_blank",rel:"noopener noreferrer",children:s("toolbar.printOpenPdf")}),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 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 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:[jsx("button",{type:"button",role:"menuitem","data-testid":"docx-notes-menu-delete",disabled:!s,title:m,onClick:r,children:f("notes.delete")}),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")}),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")}),jsx("button",{type:"button",role:"menuitem",onClick:a,children:f("dialogs.footnoteProperties.title")})]})}function lP(e){return t=>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),createElement(Fragment$1,{key:n},r)}var jd=createContext(void 0),kt=()=>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=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=(isElementNode(a)?a:a.parentElement)?.getBoundingClientRect();if(t(s))return {left:s.left,top:s.bottom}}return null}var Ba=createContext(null),Yd=createContext(null);function Xd(){let e=useContext(Yd);useEffect(()=>e?.(),[e]);}function xP(){let e=useContext(Ba);Xd();let t=Hl(e===null);return e??t}function Hl(e=true){let t=H(),o=ke(),r=useRef(o);r.current=o;let[n,i]=useState(kn),a=useRef(null),l=useRef(""),s=useRef(false),c=useRef(n);c.current=n;let d=W(hP),m=t?t.can({type:"insertText",text:""}).ok:false,u=useCallback(()=>{l.current="",s.current=false;let E=a.current;E&&(E.editor.releaseSelection(E.pin),a.current=null);},[]),g=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=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=useCallback(()=>{u(),i(kn);},[u]);useEffect(()=>u,[u]);let h=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]);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]),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]),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=useCallback(async()=>{let E=c.current.link?.href;if(!E)return false;try{await hostWindowOf(r.current).navigator.clipboard.writeText(E);}catch{return false}return i(S=>({...S,copied:true})),true},[]),x=useCallback(()=>{i(E=>({...E,mode:"editing",copied:false,error:false}));},[]),b=useCallback(E=>{i(S=>({...S,text:E,copied:false,error:false}));},[]),v=useCallback(E=>{i(S=>({...S,url:E,copied:false,error:false}));},[]),P=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=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=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 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 useCallback(()=>{e?.focus();},[e])}var Al=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children: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=useRef(null),{state:l,close:s}=i,c=Wa();useEffect(()=>{if(l.mode==="closed")return;let h=b=>{b.key==="Escape"&&(b.preventDefault(),s(),c());},y=hostDocumentOf(a.current);y.addEventListener("keydown",h);let x=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]=useState(null);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?jsx(IP,{children:r}):r;if(o)return l.mode==="closed"?null:jsx(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?jsx(J,{...f,children:r}):jsx("div",{...f,children:p})}function IP({children:e}){let{state:t}=xo(),o=useMemo(()=>NP(e),[e]),r=(i,a)=>i in o?o[i]:a;if(t.mode==="editing")return jsxs(Fragment,{children:[r("Fields",jsx(ru,{})),r("Error",jsx(au,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[r("Apply",jsx(nu,{})),r("Cancel",jsx(iu,{}))]}),o.__extra]});let n=t.canEdit&&!(t.link&&Oa(t.link));return jsxs(Fragment,{children:[r("Url",jsx(Qd,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[r("Copy",jsx(eu,{})),n?r("Edit",jsx(tu,{})):null,n?r("Unlink",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===Fragment$1){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 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=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?jsx(J,{...u,className:e,children:r}):l?jsxs("span",{...u,children:[r??d,jsx("span",{className:"docx-editor-sr-only",children:m})]}):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?jsx(J,{...c,className:e,children:r}):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?jsx(J,{...s,className:e,children:r}):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?jsx(J,{...c,className:e,children:r}):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=useRef(null),d=useId(),m=useId();useEffect(()=>{o.mode==="editing"&&(c.current?.focus({preventScroll:true}),c.current?.select());},[o.mode]);let u=useCallback(g=>{if(g.key==="Enter"){g.preventDefault(),i()&&l();return}g.key==="Escape"&&(g.preventDefault(),a(),l());},[i,a,l]);return t?null:jsxs("div",{className:`docx-hyperlink-popup__fields${e?` ${e}`:""}`,children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:d,children:s("hyperlinkPopup.displayTextPlaceholder")}),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}),jsx("label",{className:"docx-editor-sr-only",htmlFor:m,children:s("hyperlinkPopup.urlLabel")}),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?jsx(J,{...c,className:e,children:r}):jsx("button",{...c,children:r??s})}function au({className:e,hidden:t}){let{state:o}=xo(),{t:r}=L();return t||!o.error?null: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?jsx(J,{...s,className:e,children:r}):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=useContext(cu),t=Ol();return e??t}function Ol(){let e=H(),[t,o]=useState(false),[r,n]=useState(false),[i,a]=useState(false),l=W(C=>C),s=e?.surface??null,c=s?.contentControls;useEffect(()=>{n(c?.showAll()??s?.state().contentControls.showAll??false),a(c?.formFill()??s?.state().contentControls.formFill??false);},[l,c,s]);let d=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=useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=useCallback(C=>{c?.setShowAll(C),n(C);},[c]),g=useCallback(C=>{c?.setFormFill(C),a(C);},[c]),p=useCallback(()=>u(!r),[u,r]),f=useCallback(()=>g(!i),[g,i]),h=useCallback(()=>o(true),[]),y=useCallback(()=>o(false),[]),x=useCallback(()=>o(C=>!C),[]),b=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=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=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=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 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=createContext(null);function du(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var ob=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children: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 jsxs("div",{style:VP,"data-testid":o,children:[jsx("span",{style:GP,children:e}),jsx("span",{style:jP,children:t})]})}function ek({className:e,asChild:t,hidden:o,children:r,preset:n=true}){let i=vo(),a=useRef(null),l=useId(),{t:s}=L(),{control:c,inspectorOpen:d,closeInspector:m}=i;if(useEffect(()=>{if(!d)return;let f=x=>{x.key==="Escape"&&(x.preventDefault(),m());},h=hostDocumentOf(a.current);h.addEventListener("keydown",f);let y=listenForOutsidePress({popup:h,contains:x=>a.current?.contains(x)===true,close:m});return ()=>{h.removeEventListener("keydown",f),y();}},[d,m]),useEffect(()=>{d&&!c&&m();},[d,c,m]),o||!d||!c)return null;let u=n?jsxs(Fragment,{children:[jsx(nb,{}),jsx(ab,{}),jsx("div",{style:XP,children: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=jsxs(Fragment,{children:[jsx("span",{id:l,className:"docx-editor-sr-only",children:s("contentControl.inspectorPanel.title")}),u]});return t?jsx(J,{...g,children:p}):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=jsxs(Fragment,{children:[jsx("span",{children:r??i("contentControl.inspectorPanel.title")}),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?jsx(J,{...a,children:l}):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??jsxs(Fragment,{children:[jsx(wn,{label:i("contentControl.inspectorPanel.alias"),value:n.alias??a,testId:"content-control-inspector-alias"}),jsx(wn,{label:i("contentControl.inspectorPanel.tag"),value:n.tag??a,testId:"content-control-inspector-tag"}),jsx(wn,{label:i("contentControl.inspectorPanel.type"),value:i(JP(n.controlType)),testId:"content-control-inspector-type"}),jsx(wn,{label:i("contentControl.inspectorPanel.lock"),value:i(QP(n)),testId:"content-control-inspector-lock"}),jsx(wn,{label:i("contentControl.inspectorPanel.placeholder"),value:n.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsx(wn,{label:i("contentControl.inspectorPanel.bound"),value:n.bound?l:s,testId:"content-control-inspector-bound"}),n.bound?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?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?jsx(J,{...d,children:c}):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=jsxs(Fragment,{children:[r??n??ob(zP),jsx("span",{children:d})]});return t?jsx(J,{...m,children:u}):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]=useState(null),[n,i]=useState(null),a=useRef(null),l=useRef(null),s=useRef(null),c=useId(),d=useId(),m=useId(),u=o?.activation??null,g=W(ak),p=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?localizeDisabledReason(P,t):null}},[u,e,g,t]),f=useCallback((b=false)=>{s.current?.(),s.current=null,r(null),b&&e&&queueMicrotask(()=>e.focus());},[e]);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]),useEffect(()=>{if(!o||!e?.surface)return;(e.mountGeneration!==o.mountGeneration||!e.surface.equations.equationById(o.activation.equation.id))&&f();},[e,g,o,f]),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=>{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]),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=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=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 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:[jsx("label",{className:"docx-editor-sr-only",htmlFor:c,children:t("equationPopup.inputLabel")}),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?jsx("div",{id:d,className:"docx-equation-popup__error","data-testid":"equation-popup-error",role:"alert",children:t("equationPopup.refused")}):null,p.reason?jsx("div",{id:m,className:"docx-equation-popup__error","data-testid":"equation-popup-disabled-reason",role:"status",children:p.reason}):null,jsxs("div",{className:"docx-equation-popup__actions",children:[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")}),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(!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(!isValidElement(e)||e.type!==Fragment$1)return null;let r=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 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 jsx(Fragment$1,{children:v??i(f,h,b)},y)}),u=m(e),g=[...s.entries()].filter(([p])=>!d.has(p)).map(([p,f])=>(l?.(p,f),jsx(Fragment$1,{children:f},p)));return jsxs(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=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=createContext({measuring:false,overflow:new Set,inMore:false});function gb(){return useContext(Zl)}function Je(){return useContext($a)}function Pe(){let{t:e}=Je(),{t}=L();return o=>e?.(o)??t(o)}var In=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=TOOLBAR_ITEM_ATTRIBUTE,Fn="data-toolbar-fixed",ql="data-toolbar-more",Dk=34,Kl=new Map;function Cu(e,t,o){let r=useRef(null),n=useRef({itemWidths:new Map,groupBases:new Map,groupGaps:new Map,more:Dk}),[i,a]=useState(Kl),l=useRef(i);l.current=i;let s=useRef({groups:t,order:o});s.current={groups:t,order:o};let c=toolbarGroupsKey(t),d=useRef(c),m=o.join("\0"),u=useCallback(()=>{let p=r.current;if(!p||!e)return;let f=readToolbarRow(p,n.current,toolbarItemKey),h=l.current.size===0&&f.overflowing===false,y=toolbarGroupsKey(s.current.groups),x=d.current===y;d.current=y;let b=h?Kl: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:TOOLBAR_OVERFLOW_HYSTERESIS});sameItemOverflow(b,l.current)||(l.current=b,a(b));},[e]),g=useCallback(p=>{r.current=p;},[]);return useLayoutEffect(()=>{if(!e){l.current.size>0&&(l.current=Kl,a(Kl));return}u();},[e,c,u,m]),useEffect(()=>{let p=r.current,f=p?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=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]=useState(void 0);return 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=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=DEFAULT_IMAGE_RESOURCE_LIMITS$1;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=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=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 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??jsxs(Fragment,{children:[jsx("header",{className:"docx-dialog__header",children:jsx("h2",{className:"docx-dialog__title",children:i("imageInsert.errors.title")})}),jsx("div",{className:"docx-dialog__body","data-docx-part":"message",children:e}),jsx("footer",{className:"docx-dialog__footer",children: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=createContext(null);function Db(){let e=useContext(Su);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function ja(){return useContext(Su)}function $l({children:e}){let t=H(),{t:o}=L(),r=useRef(null),n=useRef(false),i=kt(),[a,l]=useState(null),s=useRef(null),c=useCallback(()=>toolbarCommandState(t,"image.insert"),[t]),d=W(c,(b,v)=>b.enabled===v.enabled&&b.disabledReason===v.disabledReason),m=d.enabled,u=localizeDisabledReason(d.disabledReason,o),g=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 executeImageCommand(t,P);T.ok?t.focus():l(localizeDisabledReason(zk(T.reason)??null,o)??o("imageInsert.errors.refused"));}finally{n.current=false;}},[t,o]),p=useCallback(async b=>{let v=b?.[0];if(!v)return;let P=await v.arrayBuffer();await g(new Uint8Array(P));},[g]),f=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=useCallback(()=>{if(!m)return;let b=r.current,v=t?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=useCallback(async b=>{let v=b.currentTarget;await p(v.files),v.value="";},[p]),x=useMemo(()=>({openFilePicker:h,insertFromFileList:p,insertFromDataTransfer:f,isEnabled:m,disabledReason:u,inputRef:r,onInputChange:y}),[h,p,f,m,u,y]);return jsxs(Su.Provider,{value:x,children:[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)}):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?jsx(J,{...d,children:r}):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]=useState(null),[s,c]=useState({rows:1,cols:1}),d=useRef(null),m=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=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(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(jsx("div",{role:"row",className:"docx-menubar__grid-row",children:f},p));}return 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:[jsx("div",{className:"docx-menubar__grid-cells",children:g}),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=useCallback(()=>o(null),[o]);return jsx(jl,{slot:e,label:r("toolbar.insertTable"),onInserted:n,className:t})}function Jk({className:e,hidden:t}){let{isEnabled:o,disabledReason:r}=oe(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 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=isApplePlatform()?"toolbar.goToBookmarkShortcutApple":"toolbar.goToBookmarkShortcut";return jsx(to,{slotId:"insert.goToBookmark",...e.isEnabled?{shortcutKey:t}:{}})}function ow({className:e,hidden:t}){return 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=toolbarCommandState(n,"text.link"),s=localizeDisabledReason(l.disabledReason,a),c=Q("text.link"),d=n?.surface?.hyperlinks.linkAtCaret()!=null,m=a(e??(d?"hyperlinkPopup.editLink":"formattingBar.insertLink"));return jsx(we,{icon:re(c?.paths),slot:"text.link",...t?{shortcut:a(t)}:{},disabled:!l.enabled,title:s??void 0,onSelect:()=>{i.setOpenMenu(null),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=useId(),p=useContext(In),f=r&&n?g:void 0;return 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:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:t}),jsx("span",{className:"docx-menubar__item-label",children:d}),o?jsx("span",{className:"docx-menubar__item-shortcut",children:u(o)}):null,f?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 jsxs("div",{role:"group",className:`docx-menubar__group${o?` ${o}`:""}`,...a?{"aria-label":a}:{},children:[a?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"?jsx(Jl,{...e}):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=chromeSlotIsToggle(i),h=["setAlignment","setParagraphDirection","setReviewDisplayMode"].includes(commandForSlot(i)?.type??"");return 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 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(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 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(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 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 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]=useState(false),s=useRef(null),c=useRef(null),d=useId();t===void 0&&e===void 0&&Lg();let m=t??i(e??""),[u,g]=useState(null);return useLayoutEffect(()=>{if(!a){g(null);return}let p=s.current,f=c.current,h=p?.ownerDocument.defaultView;!p||!f||!h||g(placeSubmenu(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:h.innerWidth,height:h.innerHeight},h.getComputedStyle(p).direction==="rtl"));},[a]),jsxs("div",{role:"none",className:`docx-menubar__submenu${r?` ${r}`:""}`,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),onKeyDown:p=>{let f=submenuKeys(hostWindowOf(p.currentTarget).getComputedStyle(p.currentTarget).direction==="rtl");p.key===f.open&&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:[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:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:re(o)}),jsx("span",{className:"docx-menubar__item-label",children:m}),jsx("span",{className:"docx-menubar__item-caret","aria-hidden":"true",children:"\u203A"})]}),a?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,hostDocumentOf(f).activeElement,1)):p.key==="ArrowUp"&&(p.preventDefault(),p.stopPropagation(),Qt(h,hostDocumentOf(f).activeElement,-1));},children:jsx(In.Provider,{value:-1,children:n})}):null]})}function Tw({entry:e}){let{isEnabled:t}=oe(e.slot),o=Q(e.slot);return t?jsx(oo,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsx(An,{slot:e.slot})}):jsx(to,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Zr({className:e}){return jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function Qa({entry:e,children:t}){return e.kind==="separator"?jsx(Zr,{}):e.kind==="submenu"?jsx(oo,{labelKey:e.labelKey,paths:e.paths,children:t??e.items.map((o,r)=>jsx(Qa,{entry:o},r))}):e.slot==="file.open"?jsx(wu,{}):e.slot==="file.save"?jsx(Du,{}):e.slot==="file.exportMarkdown"?jsx(Ru,{}):e.slot==="file.exportPdf"?jsx(Mu,{}):e.slot==="file.print"?jsx(_u,{}):e.slot==="file.pageSetup"?jsx(Iu,{}):e.slot==="paragraph.dialog"?jsx(vw,{}):e.slot==="insert.watermark"?jsx(Yl,{}):e.slot==="insert.bookmark"?jsx(Xl,{}):e.slot==="insert.goToBookmark"?jsx(Ib,{}):e.slot==="image.insert"?jsx(Nu,{}):e.picker==="tableGrid"?jsx(Tw,{entry:e}):jsx(to,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Ab(e){if(!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)=>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=useId(),f=useRef(null),h=useRef(null),y=useRef(false),x=useRef(false),b=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 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 jsxs("div",{role:"none",className:`docx-menubar__menu-root${n?` ${n}`:""}`,"data-menu":e,...C.rootAttributes,children:[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?jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:r}):null,S?null:T]}),v?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=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:jsx(In.Provider,{value:-1,children:E})}):null]})}function Fu(e){return Object.assign(o=>jsx(ro,{id:e,...o}),{docxMenu:e})}var Lu=Fu("file"),Hu=Fu("format"),Au=Fu("insert");var ts=createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function Zo(){return useContext(ts)}function Bb(){return 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=useMemo(()=>o&&e!==null&&e.can({type:"setPageSetup",marginTop:0}).ok,[e,o]),n=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 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]=useState(Kb),[g,p]=useState(qb),[f,h]=useState("portrait"),[y,x]=useState(dr),[b,v]=useState(dr),[P,T]=useState(dr),[C,E]=useState(dr),[S,k]=useState(false),[w,I]=useState("document"),O=useRef(null),N=useRef("no");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=useCallback(q=>{let G=Bu[q];G&&(u(f==="landscape"?G.height:G.width),p(f==="landscape"?G.width:G.height));},[f]),F=useCallback(q=>{q!==f&&(h(q),u(g),p(m));},[f,m,g]),D=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)=>jsxs("div",{"data-docx-part":"field","data-docx-field":`margin${q[0].toUpperCase()}${q.slice(1)}`,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",children:a(`dialogs.pageSetup.${q}`)}),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}`)}),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 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"&&isHTMLElementNode(q.target)&&q.target.localName==="input"&&c&&(q.preventDefault(),D());},children:jsx(To.Composition,{state:Y,preset:i,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.pageSetup.title")})}),jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.pageSetup.pageSize")}),jsxs("div",{"data-docx-part":"field","data-docx-field":"pageSize",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.sizeLabel")}),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)=>jsx("option",{value:G,children:a(q.labelKey)},q.labelKey)),R<0&&jsx("option",{value:-1,children:a("dialogs.pageSetup.custom")})]})]}),jsxs("div",{"data-docx-part":"field","data-docx-field":"orientation",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.orientation")}),jsxs("select",{className:"docx-dialog__input",value:f,onChange:q=>F(q.target.value),"aria-label":a("dialogs.pageSetup.orientation"),children:[jsx("option",{value:"portrait",children:a("dialogs.pageSetup.portrait")}),jsx("option",{value:"landscape",children:a("dialogs.pageSetup.landscape")})]})]}),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),jsxs("div",{"data-docx-part":"field","data-docx-field":"scope",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",children:a("dialogs.pageSetup.applyTo")}),jsxs("select",{className:"docx-dialog__input",value:w,onChange:q=>I(q.target.value),"aria-label":a("dialogs.pageSetup.applyTo"),children:[jsx("option",{value:"document",children:a("dialogs.pageSetup.applyToDocument")}),jsx("option",{value:"section",children:a("dialogs.pageSetup.applyToSection")})]})]})]}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("span",{"data-docx-part":"error",role:"alert",className:"docx-dialog__error",children:S?a("dialogs.paragraph.refused"):null}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("common.cancel")}),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=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]=useState("left"),[g,p]=useState("ltr"),[f,h]=useState(0),[y,x]=useState(0),[b,v]=useState("none"),[P,T]=useState(0),[C,E]=useState(0),[S,k]=useState(0),[w,I]=useState("multiple"),[O,N]=useState(1.08),[B,F]=useState(false),[D,R]=useState(false),[z,V]=useState(false),[ee,Y]=useState(true),[q,G]=useState(false),[ce,A]=useState([]),[_,ae]=useState(false),[fe,Z]=useState(0),[de,Re]=useState("left"),[Ae,ft]=useState("none"),[ve,nt]=useState(NO_MIXED_FIELDS),[Zt,Nt]=useState(false),er=$=>a(Zt&&($==="indentLeft"||$==="indentRight"||$==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),Mr=useRef(NO_MIXED_FIELDS),ie=useId(),[at,Ie]=useState(false),go=useRef(null),tr=useRef(false),Ft=useRef(null);useEffect(()=>{if(!e){tr.current=false;return}if(tr.current||s===null)return;let $=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=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=useCallback(()=>{if(!c)return;if(!l()){t();return}let $=Ft.current,Ce=$===null?null: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=useCallback(()=>{let $=Math.round(fe);return $<=0?false:(nt(Ce=>({...Ce,tabStops:false})),A(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)=>jsxs("div",{"data-docx-part":"field","data-docx-field":gt,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-${$}`,children:a(`dialogs.paragraph.${$}`)}),jsx("input",{id:`${ie}-${$}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:ve[gt]?"":twipsToInches(Ce),placeholder:ve[gt]?er(gt):void 0,onChange:Ma=>{le(gt),rr(inchesToTwips(Number(Ma.target.value)||0));},"aria-label":a(`dialogs.paragraph.${$}`)}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),Ke=($,Ce,rr,gt)=>jsxs("div",{"data-docx-part":"field","data-docx-field":$,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-${$}`,children:a(`dialogs.paragraph.${$}`)}),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.${$}`)}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),xe=($,Ce,rr)=>jsxs("label",{"data-docx-part":"field","data-docx-field":$,className:"docx-dialog__checkbox-row",children:[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(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 jsx(Be,{kind:"paragraph",className:o,style:r,panelRef:go,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:$=>{$.key==="Escape"&&t();let Ce=isHTMLElementNode($.target)&&($.target.localName==="button"||$.target.localName==="select");if($.key==="Enter"&&!Ce){let rr=$.target;if(isHTMLElementNode(rr)&&rr.dataset.docxTabEntry!==void 0){yn();return}c&&Lo();}},children:jsx(Eo.Composition,{state:_r,preset:i,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.paragraph.title")})}),jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxs("div",{className:"docx-dialog__columns",children:[jsxs("div",{className:"docx-dialog__column",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.general")}),jsxs("div",{"data-docx-part":"field","data-docx-field":"alignment",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-alignment`,children:a("dialogs.paragraph.alignment")}),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?jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsx("option",{value:"left",children:a("dialogs.paragraph.alignLeft")}),jsx("option",{value:"center",children:a("dialogs.paragraph.alignCenter")}),jsx("option",{value:"right",children:a("dialogs.paragraph.alignRight")}),jsx("option",{value:"justify",children:a("dialogs.paragraph.alignJustify")})]})]}),jsxs("div",{"data-docx-part":"field","data-docx-field":"direction",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-direction`,children:a("dialogs.paragraph.direction")}),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?jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsx("option",{value:"rtl",children:a("dialogs.paragraph.directionRtl")}),jsx("option",{value:"ltr",children:a("dialogs.paragraph.directionLtr")})]})]}),jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.indentation")}),be("beforeText",f,h,"indentLeft"),be("afterText",y,x,"indentRight"),jsxs("div",{"data-docx-part":"field","data-docx-field":"special",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-special`,children:a("dialogs.paragraph.special")}),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?jsx("option",{value:"",children:er("special")}):null,jsx("option",{value:"none",children:a("dialogs.paragraph.specialNone")}),jsx("option",{value:"firstLine",children:a("dialogs.paragraph.specialFirstLine")}),jsx("option",{value:"hanging",children:a("dialogs.paragraph.specialHanging")})]})]}),b!=="none"?jsxs("div",{"data-docx-part":"field","data-docx-field":"specialBy",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-by`,children:a("dialogs.paragraph.by")}),jsx("input",{id:`${ie}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:ve.special?"":twipsToInches(P),placeholder:ve.special?er("special"):void 0,onChange:$=>{le("special"),T(Math.max(0,inchesToTwips(Number($.target.value)||0)));},"aria-label":a("dialogs.paragraph.by")}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}):null,jsxs("div",{"data-docx-part":"field","data-docx-field":"tabStops",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.tabStops")}),ce.length===0?jsx("div",{className:"docx-dialog__note",children:a(ve.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):ce.map($=>jsxs("div",{className:"docx-dialog__row",children:[jsx("span",{className:"docx-dialog__label docx-dialog__tab-position",children:a("dialogs.paragraph.tabPositionLabel",{position:formatInches($.positionTwips)})}),jsx("span",{className:"docx-dialog__tab-description",children:a(TAB_ALIGNMENT_LABELS[$.alignment])}),jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>A(ce.filter(Ce=>Ce!==$)),"aria-label":a("dialogs.paragraph.tabRemoveAt",{position:formatInches($.positionTwips)}),children:a("dialogs.paragraph.tabRemove")})]},$.positionTwips)),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsx("input",{id:`${ie}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:twipsToInches(fe),onChange:$=>Z(Math.max(0,inchesToTwips(Number($.target.value)||0))),"aria-label":a("dialogs.paragraph.tabPosition"),"data-docx-tab-entry":""}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),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:[jsx("option",{value:"left",children:a("dialogs.paragraph.tabAlignLeft")}),jsx("option",{value:"center",children:a("dialogs.paragraph.tabAlignCenter")}),jsx("option",{value:"right",children:a("dialogs.paragraph.tabAlignRight")}),jsx("option",{value:"decimal",children:a("dialogs.paragraph.tabAlignDecimal")})]})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),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:[jsx("option",{value:"none",children:a("dialogs.paragraph.tabNone")}),jsx("option",{value:"dot",children:a("dialogs.paragraph.tabLeaderDot")}),jsx("option",{value:"hyphen",children:a("dialogs.paragraph.tabLeaderHyphen")}),jsx("option",{value:"underscore",children:a("dialogs.paragraph.tabLeaderUnderscore")})]})]}),jsxs("div",{className:"docx-dialog__row docx-dialog__row--actions",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:yn,children:a("dialogs.paragraph.tabAdd")}),jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{nt($=>({...$,tabStops:false})),ae(true),A([]);},children:a("dialogs.paragraph.tabClearAll")})]})]})]}),jsxs("div",{className:"docx-dialog__column",children:[jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.spacing")}),Ke("spaceBefore",C,E,"spaceBefore"),Ke("spaceAfter",S,k,"spaceAfter"),jsxs("div",{"data-docx-part":"field","data-docx-field":"lineRule",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),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?jsx("option",{value:"",children:a("dialogs.paragraph.mixed")}):null,jsx("option",{value:"multiple",children:a("dialogs.paragraph.ruleMultiple")}),jsx("option",{value:"atLeast",children:a("dialogs.paragraph.ruleAtLeast")}),jsx("option",{value:"exact",children:a("dialogs.paragraph.ruleExactly")})]})]}),jsxs("div",{"data-docx-part":"field","data-docx-field":"lineValue",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${ie}-at`,children:a("dialogs.paragraph.at")}),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")}),jsx("span",{className:"docx-dialog__unit",children:w==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),xe("contextualSpacing",B,F),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)]})]})}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("span",{role:"alert","data-docx-part":"error",className:"docx-dialog__error",children:at?a("dialogs.paragraph.refused"):null}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a("dialogs.paragraph.cancel")}),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=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=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=useCallback(l=>e?.getWatermark()??null,[e]),o=W(t,sh),r=W(Xw),n=useMemo(()=>r&&e!==null&&e.can({type:"setWatermark",watermark:{text:"DRAFT"}}).ok,[e,r]),i=useCallback(()=>e?.query({type:"watermark"})??null,[e]),a=useCallback(l=>e?e.exec({type:"setWatermark",watermark:l}):Jw,[e]);return 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]=useState(null);return 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=useMemo(()=>is(a),[a]),s=aD(n.kind==="picture"?n.imageData:null),c=gh(n,l),d=s?yh(n,l):null;return jsx("div",{...r,"data-docx-part":"preview","aria-hidden":"true",className:["docx-dialog__preview",e].filter(Boolean).join(" "),style:t,children:jsxs("svg",{className:"docx-dialog__preview-page",viewBox:`0 0 ${l.width} ${l.height}`,focusable:"false",children:[jsx("rect",{className:"docx-dialog__preview-sheet",x:0,y:0,width:l.width,height:l.height}),c?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?editorHostDocument(i):null)),children:c.text}):null,s&&d?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=>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]=useState({...$u}),[h,y]=useState([]),[x,b]=useState(null),[v,P]=useState(false),[T,C]=useState(0),E=useRef(null),S=useRef(null),k=useRef(null),w=useId(),I=useRef(false);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]),useEffect(()=>{T!==0&&S.current?.querySelector(`input[name="${w}-kind"]:checked`)?.focus({preventScroll:true});},[T,w]);let O=useCallback((_,ae)=>{b(null),f(fe=>({...fe,[_]:ae}));},[]),N=ah(p),B=d&&N!==void 0,F=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=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)=>jsxs("label",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"radio",name:`${w}-kind`,checked:p.kind===ae,onChange:()=>O("kind",ae)}),jsx("span",{id:`${w}-${_}-label`,children:fe})]}),G=(_,ae,fe)=>jsxs("div",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${w}-${_}`,children:ae}),fe]}),ce=(_,ae,fe)=>jsxs("label",{"data-docx-part":"field","data-docx-field":_,className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",disabled:!fe,checked:p[_],onChange:Z=>O(_,Z.target.checked)}),jsx("span",{children:ae})]}),A={values:p,setValue:O,errors:Y?{form:Y}:{},isEnabled:B,apply:F,cancel:t};return jsx(Be,{kind:"watermark",className:r,style:n,panelRef:S,label:l("dialogs.watermark.title"),onClose:t,onKeyDown:_=>{let ae=_.target;_.key==="Enter"&&isHTMLElementNode(ae)&&ae.localName==="input"&&(ae.type==="text"||ae.type==="number")&&B&&(_.preventDefault(),F());},children:jsx(ao.Composition,{state:A,preset:a,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:l("dialogs.watermark.title")})}),jsx("div",{"data-docx-part":"body",className:"docx-dialog__body",children:jsxs("div",{className:"docx-dialog__watermark-layout",children:[jsx(iD,{"data-docx-part":"preview"}),jsxs("fieldset",{className:"docx-dialog__fieldset",children:[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")),jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${w}-pictureWatermark-label`,children:[jsxs("div",{"data-docx-part":"field","data-docx-field":"picture",className:"docx-dialog__row",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{O("kind","picture"),k.current?.click();},children:l("dialogs.watermark.selectPicture")}),jsx("span",{className:"docx-dialog__hint","data-docx-watermark-picture":"",children:v?l("dialogs.watermark.pictureFailed"):ee}),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"),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(_=>jsx("option",{value:_===null?"auto":String(_),children:_===null?l("dialogs.watermark.auto"):vh(_)},String(_))),p.scale!==null&&!Uu.includes(p.scale)?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")),jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${w}-textWatermark-label`,children:[G("preset",l("dialogs.watermark.preset"),jsxs("select",{id:`${w}-preset`,className:"docx-dialog__select",disabled:!z,value:uh(p.text,o),onChange:_=>{_.target.value!==""&&O("text",_.target.value);},children:[jsx("option",{value:"",children:l("dialogs.watermark.custom")}),o.map(_=>jsx("option",{value:_,children:_},_))]})),G("text",l("dialogs.watermark.textLabel"),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"),jsx("select",{id:`${w}-fontFamily`,className:"docx-dialog__select",disabled:!z,value:p.fontFamily,onChange:_=>O("fontFamily",_.target.value),children:V.map(_=>jsx("option",{value:_,children:_},_))})),G("fontSizePt",l("dialogs.watermark.size"),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(_=>jsx("option",{value:_===null?"auto":String(_),children:_===null?l("dialogs.watermark.auto"):String(_)},String(_))),p.fontSizePt!==null&&!zu.includes(p.fontSizePt)?jsx("option",{value:String(p.fontSizePt),children:p.fontSizePt}):null]})),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"),jsxs(Fragment,{children:[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))}),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))}),jsx("span",{className:"docx-dialog__unit",children:"%"})]})),G("color",l("dialogs.watermark.color"),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);}})),jsxs("div",{"data-docx-part":"field","data-docx-field":"layout",className:"docx-dialog__row",role:"radiogroup","aria-label":l("dialogs.watermark.layout"),children:[jsx("span",{className:"docx-dialog__label",children:l("dialogs.watermark.layout")}),["diagonal","horizontal"].map(_=>jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"radio",name:`${w}-layout`,disabled:!z,checked:p.layout===_,onChange:()=>O("layout",_)}),jsx("span",{children:l(`dialogs.watermark.${_}`)})]},_))]})]})]})]})}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("span",{"data-docx-part":"error",role:"alert",className:"docx-dialog__error",...x?{title:x}:{},children:Y}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:l("common.cancel")}),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=useCallback(c=>e?.query({type:"bookmarks"})??cD,[e]),o=W(t,ep),r=useCallback(c=>c.editable&&e!==null&&e.can({type:"insertBookmark",name:"Bookmark"}).ok,[e]),n=W(r),i=useCallback(c=>e?e.exec({type:"insertBookmark",name:c}):ss,[e]),a=useCallback(c=>e?e.exec({type:"deleteBookmark",name:c}):ss,[e]),l=useCallback(c=>e?e.exec({type:"goToBookmark",name:c}):ss,[e]),s=useCallback(c=>e?e.exec({type:"keepFirstBookmark",name:c}):ss,[e]);return 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?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]=useState(()=>bookmarkDialogInitialName(s)),[h,y]=useState("name"),[x,b]=useState(false),[v,P]=useState(false),[T,C]=useState(false),[E,S]=useState(false),k=useRef(null),w=useRef(null),I=useId(),O=useId(),N=useId(),B=bookmarkDialogRows(s,{sortBy:h,showHidden:x}),F=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=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=useCallback(()=>{if(!F.canDelete||!F.existing)return;let A=m(F.existing.name);P(!A.ok),A.ok&&f("");},[F,m]),Y=useCallback(()=>{if(!F.canGoTo||!F.existing)return;let A=u(F.existing.name);P(!A.ok),A.ok&&S(true);},[F,u]),q=useCallback(()=>{let A=F.existing;!A||!c||P(!g(A.name).ok);},[F.existing,c,g]),G=F.existing?.name??"";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 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&&isHTMLElementNode(A.target)&&A.target.localName==="input"&&A.target.getAttribute("type")==="text"&&(A.preventDefault(),V());},children:jsx(Ht.Composition,{state:ce,preset:i,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("dialogs.bookmark.title")})}),jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[jsxs("div",{"data-docx-part":"field","data-docx-field":"name",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:I,children:a("dialogs.bookmark.name")}),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)})]}),jsx("div",{"data-docx-part":"field","data-docx-field":"list",className:"docx-dialog__row",children: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=>jsx("option",{value:A.name,children:A.name},A.name))})}),B.length===0?jsx("div",{className:"docx-dialog__hint",children:a("dialogs.bookmark.empty")}):null,jsxs("div",{"data-docx-part":"field","data-docx-field":"sortBy",className:"docx-dialog__row",role:"radiogroup","aria-label":a("dialogs.bookmark.sortBy"),children:[jsx("span",{className:"docx-dialog__label",children:a("dialogs.bookmark.sortBy")}),["name","location"].map(A=>jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"radio",name:N,checked:h===A,onChange:()=>ce.setValue("sortBy",A)}),a(A==="name"?"dialogs.bookmark.sortName":"dialogs.bookmark.sortLocation")]},A))]}),jsx("div",{"data-docx-part":"field","data-docx-field":"showHidden",className:"docx-dialog__row",children:jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:x,onChange:A=>ce.setValue("showHidden",A.target.checked)}),a("dialogs.bookmark.showHidden")]})}),jsxs("div",{className:"docx-dialog__row docx-bookmark-dialog__status",children:[jsx("span",{id:O,"data-docx-part":"error",role:"status",className:D||v?"docx-dialog__error":"docx-dialog__hint",children:z}),R>0?jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"keepfirst",disabled:!c,onClick:q,children:a("dialogs.bookmark.keepFirst")}):null]})]}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[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")}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"delete",disabled:!F.canDelete,onClick:ee,children:a("dialogs.bookmark.delete")}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"goto",disabled:!F.canGoTo,onClick:Y,children:a("dialogs.bookmark.goTo")}),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=SPLIT_CELL_FALLBACK_MAX;function PD(e){return e.open?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=useMemo(()=>l?.query({type:"splitCellConfig"})??null,[l]),[d]=useState(()=>initialSplitCellCounts(c,F=>l?l.can(F):{ok:false,code:"unsupported",reason:""})),[m,u]=useState(d.columns),[g,p]=useState(d.rows),[f,h]=useState(null),y=useId(),x=useId(),b=useId(),{counts:v,problem:P}=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?localizeDisabledReason(E.reason??null,a):null,k=E?.ok===true,w=f??S,I=P?.kind==="range"?P.field:null,O=useCallback(()=>{if(!k||!l)return;if(!s()){t();return}let F=l.exec({type:"splitCell",rows:C,cols:T});F.ok?t():h(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)=>jsxs("div",{"data-docx-part":"field","data-docx-field":F,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:D,children:a(R)}),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 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&&isHTMLElementNode(F.target)&&F.target.localName==="input"&&(F.preventDefault(),O());},children:jsx(So.Composition,{state:N,preset:i,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:a("table.splitCell")})}),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),jsx("div",{className:"docx-dialog__row",children:jsx("span",{id:b,"data-docx-part":"error",role:"status",className:"docx-dialog__error",children:w})})]}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__apply","data-docx-part":"apply",disabled:!k,onClick:O,children:a("dialogs.splitCell.submit")}),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=createContext(void 0),Dh=wh.Provider;function Qe(){let e=useContext(wh),{t}=L();return 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]=useState(e),[n,i]=useState(0);return o!==e&&(r(e),i(n+1)),e?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]=useState(()=>({defaultText:e.field.defaultText,type:e.field.type,maxLength:e.field.maxLength,format:e.field.format,enabled:e.field.enabled})),[c,d]=useState(e.signal.aborted),[m,u]=useState(false);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=TEXT_FORM_FORMATS[l.type]??[],h={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},y=(x,b)=>jsxs("label",{"data-docx-part":"field","data-docx-field":x,className:"docx-dialog__row",children:[jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${x}`)}),b]});return 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"&&isHTMLElementNode(x.target)&&x.target.localName==="input"&&(x.preventDefault(),g());},children:jsx(Po.Composition,{state:p,preset:o,defaults:jsxs(Fragment,{children:[jsx("div",{"data-docx-part":"header",className:"docx-dialog__header",children:jsx("span",{"data-docx-part":"title",className:"docx-dialog__title",children:i("textFormField.title")})}),jsxs("div",{"data-docx-part":"body",className:"docx-dialog__body",children:[y("defaultText",jsx("input",{className:"docx-dialog__input",value:l.defaultText,onChange:x=>p.setValue("defaultText",x.target.value)})),y("type",jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:x=>p.setValue("type",x.target.value),children:[["regular","number","date"].map(x=>jsx("option",{value:x,children:i(`textFormField.${x}`)},x)),Object.hasOwn(TEXT_FORM_FORMATS,l.type)?null:jsx("option",{value:l.type,disabled:true,children:i("textFormField.preservedType")})]})),y("maxLength",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",jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:x=>p.setValue("format",x.target.value),children:[f.map(x=>jsx("option",{value:x,children:h[x]?i(h[x]):x||i("textFormField.noFormat")},x)),f.includes(l.format)?null:jsx("option",{value:l.format,disabled:true,children:l.format||i("textFormField.noFormat")})]})),jsxs("label",{"data-docx-part":"field","data-docx-field":"enabled",className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:l.enabled,onChange:x=>p.setValue("enabled",x.target.checked)}),i("textFormField.enabled")]})]}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("span",{"data-docx-part":"error",className:"docx-dialog__error",role:"alert",children:p.errors.form}),jsx("button",{"data-docx-part":"cancel",className:"docx-dialog__button",type:"button",onClick:e.cancel,children:i("textFormField.cancel")}),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=createContext(null),ko=()=>useContext(_h);function Ih({popups:e,children:t}){let o=H(),r=Ld(),[n,i]=useState(null),[a,l]=useState(null),[s,c]=useState(null),[d,m]=useState(null),u=useRef(d);u.current=d;let g=useRef(e);g.current=e;let p=useRef(null),f=useRef(s);f.current=s;let h=()=>l(null);useEffect(()=>{if(a!==null)return;let P=p.current;p.current=null,P?.isConnected&&P.focus({preventScroll:true});},[a]),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]),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]),useEffect(()=>{l(null),c(null),m(null);},[o,r]);let y=e?.bookmark===false;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]),useEffect(()=>{e?.revisionMarkup===false&&u.current?.cancel(),e?.textFormField===false&&f.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let x=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):jsx(qr,{...b}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Se(e.paragraph,b):jsx(qo,{...b}):a==="watermark"&&e?.watermark!==false?e?.watermark?Se(e.watermark,b):jsx(Ur,{...b}):a==="bookmark"&&e?.bookmark!==false?e?.bookmark?Se(e.bookmark,b):jsx(ei,{...b}):a==="splitCell"&&e?.splitCell!==false?e?.splitCell?Se(e.splitCell,b):jsx(ti,{...b}):d&&e?.revisionMarkup!==false?e?.revisionMarkup?Se(e.revisionMarkup,{session:d},d):jsx(Ia,{session:d}):s&&e?.textFormField!==false?e?.textFormField?Se(e.textFormField,{session:s},s):jsx(ri,{session:s}):null;return jsxs(_h.Provider,{value:x,children:[t,n?createPortal(v,n):null]})}function KD(e){return e?.closest("[data-menu]")?.querySelector(':scope > [role="menuitem"]')??e}function Nh(){let e=ko();return jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer,dir:it()})}function Fh({children:e}){let t=ko();return t?.container?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: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=useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:u,disabledReason:g}=oe(m);if(n)return null;let p=l!==null;return 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=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=useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:u,disabledReason:g}=oe(m);if(n)return null;let p=l!==null;return 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 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: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:tableChromeIconPaths("select_all")}),Gn=zo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:tableChromeIconPaths("table_rows")}),jn=zo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:tableChromeIconPaths("table_rows")}),Yn=zo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:tableChromeIconPaths("view_column")}),Xn=zo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:tableChromeIconPaths("view_column")}),Jn=zo("table.mergeCells",{type:"mergeCells"},{labelKey:"table.mergeCells",paths: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:jsx(we,{slot:"table.splitCell",icon:e??re(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:tableChromeIconPaths("delete_sweep"),destructive:true}),ta=zo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:tableChromeIconPaths("view_column"),destructive:true}),oa=zo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths: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:jsxs("div",{className:"docx-contextmenu__table-align",children:[jsx("span",{className:"docx-contextmenu__table-align-label",children:o("tableAdvanced.verticalAlignment")}),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 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(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=useMemo(()=>t(d),[d]),{isEnabled:g,disabledReason:p}=oe(u);return l||d===null?null: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(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 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=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 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?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:()=>jsx(QD,{})},{kind:"row",id:"edit.cut",render:()=>jsx(ni,{})},{kind:"row",id:"edit.copy",render:()=>jsx(ai,{})},{kind:"row",id:"edit.paste",render:()=>jsx(zn,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsx($n,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsx(fs,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsx(gs,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsx(ii,{})},{kind:"row",id:"edit.selectAll",render:()=>jsx(li,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsx(Jl,{shortcutKey:"contextMenu.insertLinkShortcut"})},{kind:"row",id:"review.addComment",render:()=>jsx(JD,{})}];function tR(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:Vn.docxRow,render:()=>jsx(Vn,{})},{kind:"row",id:Gn.docxRow,render:()=>jsx(Gn,{})},{kind:"row",id:jn.docxRow,render:()=>jsx(jn,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:Yn.docxRow,render:()=>jsx(Yn,{})},{kind:"row",id:Xn.docxRow,render:()=>jsx(Xn,{})},{kind:"separator",id:"sep.table.cells"},{kind:"row",id:Jn.docxRow,render:()=>jsx(Jn,{})},{kind:"row",id:Qn.docxRow,render:()=>jsx(Qn,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:ea.docxRow,render:()=>jsx(ea,{})},{kind:"row",id:ta.docxRow,render:()=>jsx(ta,{})},{kind:"row",id:oa.docxRow,render:()=>jsx(oa,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:$r.docxRow,render:()=>jsx($r,{})}]}function oR(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:ra.docxRow,render:()=>jsx(ra,{})},{kind:"row",id:na.docxRow,render:()=>jsx(na,{})},{kind:"row",id:aa.docxRow,render:()=>jsx(aa,{})}]}function rR(e,t=false){return [...eR,...e?tR():[],...t?oR():[]]}function jh(e){if(!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(!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=useRef(null),u=useRef(null),[g,p]=useState(null),[f,h]=useState(null),[y,x]=useState(null),b=useMemo(()=>rR(d,f!==null),[d,f]),[v,P]=useState(null),T=useCallback((N=false)=>{p(null),P(null),h(null),x(null),N&&s?.focus();},[s]);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||!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]),useEffect(()=>{r&&T();},[r,T]),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=hostDocumentOf(m.current??u.current),R=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]),useLayoutEffect(()=>{let N=u.current;if(!g||!N)return;let{width:B,height:F}=N.getBoundingClientRect(),D=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]),useLayoutEffect(()=>{v&&u.current?.focus({preventScroll:true});},[v]);let C=useRef(n);C.current=n;let E=useRef(false);useEffect(()=>{let N=g!==null;N!==E.current&&(E.current=N,C.current?.(N));},[g]);let S=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]=useState(null),I=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 jsx("div",{ref:m,style:{display:"contents"},children:g?jsx($a.Provider,{value:S,children:jsx(ts.Provider,{value:I,children: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,hostDocumentOf(B).activeElement,1)):N.key==="ArrowUp"?(N.preventDefault(),Qt(F,hostDocumentOf(B).activeElement,-1)):N.key==="Home"?(N.preventDefault(),eo(F,"first")):N.key==="End"&&(N.preventDefault(),eo(F,"last"));},children:[Children.toArray(i).filter(Vh),Bl({entries:b,children:Children.toArray(i).filter(N=>!Vh(N)),preset:o,keyOfEntry:N=>N.id,keyOfChild:N=>db(jh(N)),renderEntry:N=>N.kind==="separator"?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 jsxs(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=>jsx(Za,{...n})),contentControl:e?.contentControl??(n=>jsx(Ua,{...n})),equation:e?.equation??(()=>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=>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=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=useCallback(o=>e?.getNotePropertiesState()??null,[e]);return W(t,cR)}function pi(e,t){let[o,r]=useState(null),n=useCallback(l=>r(l),[]),[i,a]=useState({visibility:"hidden"});return useLayoutEffect(()=>{let l=o?.closest(".docx-editor__scroll-container"),s=l??o?.parentElement?.querySelector(".docx-editor__scroll-container");if(!o||!s)return;let c=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"?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=hostWindowOf(e);return typeof t.matchMedia!="function"?false:t.matchMedia("(pointer: coarse)").matches}function fp(e){let t=H();return 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]=useState(false),n=useRef(null);return useEffect(()=>{if(o)return listenForOutsidePress({popup:n.current,close:()=>r(false)})},[o]),jsxs("div",{ref:n,className:"docx-hf-chrome__options",children:[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?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:U,children:[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")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),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=useRef(null),{t:r}=L(),n=H(),i=up(),[a,l]=useState(null),[s,c]=useState(null),[d,m]=useState(false),u=useRef(null),g=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=useCallback(()=>{u.current&&u.current.win.clearTimeout(u.current.handle),u.current=null,l(null);},[]);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=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=useCallback(I=>{n&&(n.exec(I),c(null));},[n]),y=s?r0(s.scopeId):null,x=useMemo(()=>y?{type:"deleteNote",noteKind:y.noteKind,noteId:y.noteId}:null,[y]),b=useMemo(()=>y?{type:"convertNote",fromKind:y.noteKind,noteId:y.noteId}:null,[y]),v=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?jsxs("div",{className:e,ref:o,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":i?void 0:true,children:[i&&E?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:[jsx("span",{className:"docx-context-bar__title",children:S}),jsx(hR,{onOpenProperties:()=>m(true),onClose:()=>n.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Se(t.notePreview,a):jsx(En,{...a}):null,k&&t?.notesContextMenu!==false?t?.notesContextMenu?Se(t.notesContextMenu,k):jsx(Sn,{...k}):null,d&&t?.noteProperties!==false?t?.noteProperties?Se(t.noteProperties,w):jsx(Ts,{...w}):null]}):null}function Ts(e){let{t}=L(),o=H(),r=pp(),[n,i]=useState("document"),[a,l]=useState("decimal"),[s,c]=useState("continuous"),[d,m]=useState("pageBottom"),[u,g]=useState("decimal"),[p,f]=useState("continuous"),[h,y]=useState("docEnd");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 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:jsxs("div",{className:"docx-note-properties__panel",onClick:v=>v.stopPropagation(),onMouseDown:v=>v.stopPropagation(),children:[jsx("h2",{className:"docx-note-properties__title",children:t("dialogs.footnoteProperties.title")}),jsxs("div",{className:"docx-note-properties__body",children:[jsxs("label",{className:"docx-note-properties__scope",children:[jsx("span",{children:t("notes.scope")}),jsxs("select",{className:"docx-note-properties__select",value:n,onChange:v=>i(v.target.value),children:[jsx("option",{value:"document",children:t("notes.scopeDocument")}),jsx("option",{value:"section",children:t("notes.scopeSection")})]})]}),jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxs("legend",{className:"docx-note-properties__legend",children:[jsx("span",{children:t("dialogs.footnoteProperties.footnotes")}),x?jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxs("div",{className:"docx-note-properties__fields",children:[jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxs("select",{className:"docx-note-properties__select",value:a,onChange:v=>l(v.target.value),children:[jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxs("select",{className:"docx-note-properties__select",value:s,onChange:v=>c(v.target.value),children:[jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxs("select",{className:"docx-note-properties__select",value:d,onChange:v=>m(v.target.value),children:[jsx("option",{value:"pageBottom",children:t("dialogs.footnoteProperties.footnotePositions.bottomOfPage")}),jsx("option",{value:"beneathText",children:t("dialogs.footnoteProperties.footnotePositions.belowText")})]})]})]})]}),jsxs("fieldset",{className:"docx-note-properties__section",children:[jsxs("legend",{className:"docx-note-properties__legend",children:[jsx("span",{children:t("dialogs.footnoteProperties.endnotes")}),b?jsx("span",{className:"docx-note-properties__badge",children:t("notes.inheritedValue")}):null]}),jsxs("div",{className:"docx-note-properties__fields",children:[jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numberFormat")}),jsxs("select",{className:"docx-note-properties__select",value:u,onChange:v=>g(v.target.value),children:[jsx("option",{value:"decimal",children:t("dialogs.footnoteProperties.formats.decimal")}),jsx("option",{value:"lowerRoman",children:t("dialogs.footnoteProperties.formats.lowerRoman")}),jsx("option",{value:"upperRoman",children:t("dialogs.footnoteProperties.formats.upperRoman")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.numbering")}),jsxs("select",{className:"docx-note-properties__select",value:p,onChange:v=>f(v.target.value),children:[jsx("option",{value:"continuous",children:t("dialogs.footnoteProperties.numberingOptions.continuous")}),jsx("option",{value:"eachSect",children:t("dialogs.footnoteProperties.numberingOptions.restartSection")}),jsx("option",{value:"eachPage",children:t("dialogs.footnoteProperties.numberingOptions.restartPage")})]})]}),jsxs("label",{className:"docx-note-properties__field",children:[jsx("span",{children:t("dialogs.footnoteProperties.position")}),jsxs("select",{className:"docx-note-properties__select",value:h,"data-testid":"docx-notes-endnote-position",onChange:v=>y(v.target.value),children:[jsx("option",{value:"docEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfDocument")}),jsx("option",{value:"sectEnd",children:t("dialogs.footnoteProperties.endnotePositions.endOfSection")})]})]})]})]})]}),jsxs("div",{className:"docx-note-properties__footer",children:[jsx("button",{className:"docx-note-properties__button",type:"button",onClick:e.onClose,children:t("common.cancel")}),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===hostDocumentOf(e).activeElement)}function SR(){let e=Kt(),[t,o]=useState(false);return {ref: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=useId(),s=useId(),c=useId(),d=useRef(null),m=useRef(null),u=useRef(null),g=useRef(null),[p,f]=useState(null),[h,y]=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;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=useCallback(()=>{r?.current?.focus(),n?.focus();},[n,r]),w=useCallback(()=>{t(),k();},[t,k]);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=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=hostDocumentOf(D);return ee.addEventListener("keydown",V),()=>ee.removeEventListener("keydown",V)},[e,w]);let I=useMemo(()=>{let D=b??a;return !D||D.widthEmu<=0?1:D.widthEmu/D.heightEmu},[a,b]),O=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=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=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=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(!validateDrawingPositionInput(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:jsx("div",{ref:x.ref,className:`${x.className}docx-dialog-overlay${o?` ${o}`:""}`,onClick:w,onMouseDown:D=>{D.stopPropagation(),PR(D);},children: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:[jsx("div",{id:l,className:"docx-dialog__header",children:i("dialogs.imageProperties.title")}),jsxs("div",{className:"docx-dialog__body",children:[h?jsx("p",{className:"docx-dialog__error",children:i(h)}):null,jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.dimensions")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-width",children:i("dialogs.imageProperties.widthLabel")}),jsx("input",{id:"image-prop-width",className:"docx-dialog__input",value:p.widthPoints,disabled:P,onChange:D=>O(D.target.value)}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-height",children:i("dialogs.imageProperties.heightLabel")}),jsx("input",{id:"image-prop-height",className:"docx-dialog__input",value:p.heightPoints,disabled:P,onChange:D=>N(D.target.value)}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:p.lockAspect,disabled:T,onChange:D=>f(R=>R&&{...R,lockAspect:D.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:v||!b?.intrinsic,onClick:B,children:i("imageProperties.resetNaturalSize")})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.position")}),E?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionUnavailable")}):null,S?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.positionLocked")}):null,C?jsxs(Fragment,{children:[p.positionMode==="frame"?jsxs(Fragment,{children:[jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-h",children:i("imageProperties.relativeToHorizontal")}),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:DRAWING_REL_FROM_H.map(D=>jsx("option",{value:D,children:i(`dialogs.imagePosition.relativeOptions.${D}`)},D))})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-rel-v",children:i("imageProperties.relativeToVertical")}),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:DRAWING_REL_FROM_V.map(D=>jsx("option",{value:D,children:i(`dialogs.imagePosition.relativeOptions.${D}`)},D))})]})]}):null,jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-h",children:i("imageProperties.horizontalOffset")}),jsx("input",{id:"image-pos-h",className:"docx-dialog__input",value:p.horizontalPoints,onChange:D=>f(R=>R&&{...R,horizontalPoints:D.target.value})}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-pos-v",children:i("imageProperties.verticalOffset")}),jsx("input",{id:"image-pos-v",className:"docx-dialog__input",value:p.verticalPoints,onChange:D=>f(R=>R&&{...R,verticalPoints:D.target.value})}),jsx("span",{className:"docx-dialog__unit",children:i("imageProperties.units.points")})]})]}):null]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.altText")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-title",children:i("imageAltText.title")}),jsx("input",{id:"image-prop-title",className:"docx-dialog__input",value:p.title,onChange:D=>f(R=>R&&{...R,title:D.target.value})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-prop-description",children:i("imageAltText.description")}),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")})]})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.hyperlink")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:c,children:i("hyperlinkPopup.urlLabel")}),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"})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("dialogs.imageProperties.textWrapping")}),jsx("label",{className:"docx-dialog__field-label",htmlFor:s,children:i("formattingBar.imageWrap")}),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:IMAGE_WRAP_TARGETS.map(D=>jsx("option",{value:D,children:i(`imageWrap.targets.${D}`)},D))})]}),jsxs("section",{className:"docx-dialog__section",children:[jsx("div",{className:"docx-dialog__section-label",children:i("imageProperties.crop")}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-left",children:i("imageProperties.cropLeft")}),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})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-top",children:i("imageProperties.cropTop")}),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})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-right",children:i("imageProperties.cropRight")}),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})})]}),jsxs("div",{className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__field-label",htmlFor:"image-crop-bottom",children:i("imageProperties.cropBottom")}),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?jsx("p",{className:"docx-dialog__hint",children:i("imageProperties.nonPictureHint")}):null]})]}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:w,children:i("common.cancel")}),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]=useState(false),d=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 jsxs(Fragment,{children:[o?jsx(J,{...h,children:r}):jsx("button",{...h,children:r??re(f?.paths)}),s&&n?.imageProperties!==false?n?.imageProperties?Se(n.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):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=useCallback(()=>toolbarCommandState(t,e),[t,e]),r=W(o,(n,i)=>n.value===i.value&&n.enabled===i.enabled&&n.disabledReason===i.disabledReason);return useMemo(()=>({execute:(n,i)=>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"?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]=useState(false),[u,g]=useState(""),p=useRef(null),f=useRef(null),h=useId();useEffect(()=>{d&&g(l??"");},[d,l]),useEffect(()=>{if(!d)return;let T=S=>{let k=p.current;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=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=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 jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsx(J,{...v,children:r}):jsx("button",{...v,children:r??b}),d&&n?.imageAltText!==false?n?.imageAltText?Se(n.imageAltText,P):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 jsxs("div",{id:e,role:"dialog","aria-label":l("imageAltText.panelTitle"),className:`docx-toolbar__alt-text-panel${a?` ${a}`:""}`,onMouseDown:s=>s.stopPropagation(),children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${e}-description`,children:l("imageAltText.description")}),jsx("textarea",{id:`${e}-description`,className:"docx-dialog__textarea",value:t,onChange:s=>o(s.target.value),placeholder:l("dialogs.imageProperties.altTextPlaceholder")}),jsxs("div",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:n,children:l("common.cancel")}),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]=useState(e.session),[r,n]=useState(0);return t!==e.session&&(o(e.session),n(r+1)),jsx(BR,{...e},r)}function BR({session:e,className:t,style:o,children:r}){let n=Qe(),[i,a]=useState(e.signal.aborted),l=useRef(null);return 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: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??jsxs(Fragment,{children:[jsx("header",{className:"docx-dialog__header",children:jsx("h2",{className:"docx-dialog__title",children:n("textFormField.invalidTitle")})}),jsx("div",{className:"docx-dialog__body",children:n(e.type==="number"?"textFormField.invalidNumber":"textFormField.invalidDate")}),jsx("footer",{className:"docx-dialog__footer",children:jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:e.acknowledge,children:n("textFormField.apply")})})]})})}var m0=createContext(null),f0=m0.Provider;function st(){let e=useContext(m0);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function XR(e){return e.kind==="date"?parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function g0(e){let t=`docx-cc-list-${useId()}`,[o,r]=useState(()=>XR(e)),[n,i]=useState(()=>calendarDateText(e.value,e.locale)),a=useMemo(()=>createContentControlListNavigation(e.locale),[e]),[l,s]=useState(false),c=useCallback(w=>{i(w),s(false);},[]),d=W(()=>e.canApply()),m=e.kind==="date"?parseIsoDate(e.value):null,[u,g]=useState(()=>{let w=m??new Date;return {year:w.getFullYear(),month:w.getMonth()}}),p=useCallback(w=>{let I=e.apply(w??o);return s(!I),I},[e,o]),f=useCallback(()=>e.cancel(),[e]),h=useCallback(async w=>{if(!e.replaceImage)return s(true),false;try{let I=w instanceof Uint8Array?w.byteLength:w.size;if(!e.canApply()||I>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=useMemo(()=>calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),x=useCallback(()=>{g(w=>shiftMonth(w.year,w.month,-1)),C(null);},[]),b=useCallback(()=>{g(w=>shiftMonth(w.year,w.month,1)),C(null);},[]),v=useCallback(w=>p(w),[p]),P=useCallback(()=>p(isoDateOf(new Date)),[p]),[T,C]=useState(null),E=useCallback(w=>{let I=parseIsoDate(w);I&&(g({year:I.getFullYear(),month:I.getMonth()}),C(isoDateOf(I)));},[]),S=useCallback(()=>{let w=calendarDateFromText(n,e.locale);return w?p(w):(s(true),false)},[n,e.locale,p]),k=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 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: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 jsx(J,{...u,...v,...h,...a?{className:a}:{},style:{...b,...l},children:g},p)}return 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"},jsxs(Fragment,{children:[jsx(Dp,{}),jsx(Op,{}),jsx(Rp,{}),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)=>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=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=useRef(null);return 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)=>jsx("div",{role:"row",className:"docx-content-control-calendar-week",children:t.calendar.days.slice(n*7,n*7+7).map(i=>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"},jsxs(Fragment,{children:[jsx(wp,{}),jsx(_p,{}),jsx(Np,{}),jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsx(Fp,{}),jsx(_s,{})]}),jsx(la,{}),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?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)=>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"?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"},jsxs(Fragment,{children:[jsx(Is,{}),jsx(Ap,{})]}))}function Op(e){return et("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxs(Fragment,{children:[jsx(Bp,{}),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))},calendarMonthNames(t.session.locale).map((r,n)=>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=useRef(null),i=useRef(false);return 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]=useState(e.session),[r,n]=useState(0);return t!==e.session&&(o(e.session),n(r+1)),jsx(lM,{...e},r)}function lM({session:e,className:t,style:o,children:r}){let n=Qe(),i=g0(e),[a,l]=useState(e.signal.aborted),s=useRef(null),[c]=useState(()=>contentControlPopupOpener(e.anchor)),d=e.kind==="checkbox"&&r===void 0;if(useEffect(()=>{let u=()=>l(true);return e.signal.addEventListener("abort",u,{once:true}),e.signal.aborted&&u(),()=>e.signal.removeEventListener("abort",u)},[e]),useEffect(()=>{!d||e.signal.aborted||e.apply(e.value==="true"?"false":"true");},[d,e]),useLayoutEffect(()=>{if(a||d)return;let u=s.current,g=u?.ownerDocument,p=u&&e.anchor?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]),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 jsx(f0,{value:i,children: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=>{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"?jsx(Lp,{}):e.kind==="picture"?jsxs(Fragment,{children:[jsx(Zp,{}),jsx(la,{}),jsx(Is,{})]}):e.kind==="comboBox"?jsxs(Fragment,{children:[jsx(_s,{}),jsx(Ms,{}),jsx(la,{}),jsx(Ns,{})]}):jsxs(Fragment,{children:[jsx(Ms,{}),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=useRef(t);o.current=t;let[r,n]=useState(null),[i,a]=useState(null),l=t?.contentControlWidget!==void 0,s=t?.contentControlCheckbox!==void 0,c=t?.contentControlPicture!==void 0,d=t?.invalidTextFormField!==void 0;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]),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]),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 jsxs(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]=useState(null),[l,s]=useState(null),[c,d]=useState({left:0,top:0}),m=useRef(null);m.current=l;let u=useRef(null),g=useRef(null),p=useRef(null),f=useRef(null),h=useRef(null);useEffect(()=>{let E=e.current;if(!E)return;let S=k=>{let w=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]),useEffect(()=>{if(!r){a(null);return}let E=()=>{a(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=useCallback(()=>{d(E=>{let S=overlayHostOrigin(e.current);return S.left===E.left&&S.top===E.top?E:S});},[e]);useEffect(()=>{y();let E=t.current,S=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]),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=createImageOverlayScrollPort(S,k.paintScale),()=>{h.current=null;}},[e,r,o]);let x=useCallback(()=>{s(null),u.current=null;let E=g.current;if(g.current=null,E)try{E.releasePointerCapture(E._lastPointerId??0);}catch{}},[]),b=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=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=useCallback((E,S,k,w,I)=>{if(!r)return;if(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=useCallback(E=>{if(!r)return;let S=m.current?.bounds??selectedDrawingOverlayTargetOf(r.surface);if(!S)return;if(m.current&&E.key==="Escape"){E.preventDefault(),E.stopPropagation(),x();return}if(m.current)return;let k=historyShortcutOf(E);if(k){E.preventDefault(),E.stopPropagation(),r.exec({type:k});return}let w=E.shiftKey?IMAGE_OVERLAY_NUDGE_SHIFT_PT: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=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: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=computeMovedImagePosition(S.position,I,O);r.exec({type:"setImagePosition",...N});},[x,r]);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=cssPixelsToLayoutPoints(I.clientX-N.x,E.paintScale),F=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=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: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=cssPixelsToLayoutPoints(I.clientX-(u.current?.x??I.clientX),E.paintScale),B=cssPixelsToLayoutPoints(I.clientY-(u.current?.y??I.clientY),E.paintScale),F=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=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]),useEffect(()=>{!i||f.current!==i.id||(f.current=null,p.current?.focus({preventScroll:true}));},[i]);let T=l?.bounds??i,C=useMemo(()=>{if(!r?.surface||!T)return null;let E=r.surface.publishedLayout(),S=r.surface.overlayCoordinates(),k=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=textboxFrameReason(T,r.surface.editingMode()),B=N?n(N):void 0;return jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":T.id,tabIndex:0,onKeyDown:P,children:[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 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: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=useRef(null),n=useContext(xn),i=useCallback(d=>{r.current=d,n?.setContainer(d);},[n]),a=useRef(null);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=useCallback(d=>{if(!o?.isEnabled)return;let m=d.clipboardData;m&&Yp(m)&&(clipboardPasteLandsContent(m)||(d.preventDefault(),o.insertFromDataTransfer(m)));},[o]),s=useCallback(d=>{!o?.isEnabled||!Yp(d.dataTransfer)||d.preventDefault();},[o]),c=useCallback(d=>{if(o?.isEnabled&&Yp(d.dataTransfer)){if(clipboardDropLandsText(d.dataTransfer)){if((isElementNode(d.target)?d.target:null)?.closest("[contenteditable]")?.getAttribute("contenteditable")==="true")return;d.preventDefault();return}d.preventDefault(),o.insertFromDataTransfer(d.dataTransfer);}},[o]);return jsxs("div",{ref:a,className:"docx-content-mount",children:[jsx("div",{ref:i,className:`docx-paginated-surface${e?` ${e}`:""}`,onPaste:l,onDragOver:s,onDrop:c}),jsx(Nh,{}),jsx(Xh,{}),jsx(y0,{}),t?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]=useState(null),{dir:d}=L(),m=Kt(),u=useRef(t);u.current=t;let g=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=useRef(null);return 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: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,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?jsx(Fragment,{children:o}):createPortal(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 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]=useState(null);return 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=useRef({visible:false,editor:null}),[,m]=useReducer(x=>x+1,0),u=d.current.visible&&d.current.editor!==c,g=s===null&&(e||a||u);useLayoutEffect(()=>{d.current={visible:g,editor:c},u&&m();},[g,c,u]);let{t:p}=L(),f=Kt(),h=n??jsxs(Fragment,{children:[jsx(em,{}),jsx("span",{className:"docx-editor-sr-only",children:p("loading.label")})]});if(s)return createPortal(h,s);if(!g)return null;let y=`docx-editor${f?" dark":""} docx-editor__loading${t?" docx-editor__loading--overlay":""}${o?` ${o}`:""}`;return jsx("div",{className:y,style:r,role:"status","aria-live":"polite",children:i??jsx("div",{className:"docx-paginated-surface docx-editor__loading-surface",style:{width:l.width,height:l.height},children:jsx("div",{className:"docx-pages",children:jsx("div",{className:"docx-page docx-editor__loading-page",children: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=createContext(null);function N0(){let e=useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function tm(){let e=useContext(Ci),t=N0();return 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=useContext(Ci),s=N0();return 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=resolveZoomMode(e),r=resolveZoomMode(t);return o!==null&&r!==null&&sameZoomMode(o,r)}function u1(e){let t=useRef(e);t.current=e;let[o,r]=useState(null),{onReady:n,onChange:i,onFontError:a,onRevisionMarkupChange:l,...s}=e,c=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=useCallback((Z,de)=>f(Z,de),[f]),y=useRef(h);y.current=h;let x=useRef(false),[b,v]=useState(0),P=useRef(e);P.current=e;let T=r?.maxFontBytes,[C,E]=useState(null),S=useRef(e.fieldResults),k=useRef(e.contentLockPolicy),w=useRef(e.lockedControlNavigation),I=useRef(e.fonts),O=useRef(null);O.current??=M0();let N=O.current,B=useRef(null);B.current??=ng();let F=B.current;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=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]),useEffect(()=>{!C||I.current===o||(I.current=o,C.setFonts(o).catch(()=>{}));},[C,o]),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=useRef({editor:null,zoom:void 0,mode:void 0});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:resolveZoomMode(c),ve=de&&c!==void 0&&ft!==null&&ft.type==="fit";(Ae||ve)&&(D.current.mode=c,C.setZoomMode(c));},[C,s,c]),useEffect(()=>{if(!C||e.revisionMarkup===void 0)return;let Z=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]),useEffect(()=>{C&&C.setAuthor(n);},[C,n]);let R=useRef({editor:null,value:void 0});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]),useEffect(()=>{C&&C.setTranslate(a??h);},[C,a,h]),useEffect(()=>{C&&C.setLocale(i);},[C,i]),useEffect(()=>{C&&L0(S.current,e.fieldResults);},[C,e.fieldResults]),useEffect(()=>{C&&O0(k.current,e.contentLockPolicy);},[C,e.contentLockPolicy]),useEffect(()=>{C&&Z0(w.current,e.lockedControlNavigation);},[C,e.lockedControlNavigation]),useEffect(()=>{C&&C.setTableInteractionLabel(d??defaultTableLabel);},[C,d]);let[z,V]=useState(0),[ee,Y]=useState(0),q=useRef([]),[G,ce]=useState(0),A=G>0,_=useRef(C);_.current=C,useEffect(()=>{if(!(!C||!A))return C.setCommentDraftChrome({onRequest:()=>q.current.at(-1)?.()})},[C,A]);let ae=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&&runToolbarCommand(Z,"review.addComment").ok}}),[z,ee]),fe=useMemo(Pg,[]);return useEffect(()=>(N.connect(C),()=>N.connect(null)),[N,C]),useEffect(()=>(F.connect(C),()=>F.connect(null)),[F,C]),jsx(Ir.Provider,{value:p,children:jsx(xn.Provider,{value:F,children:jsx(Dh,{value:a??h,children:jsx(Lt.Provider,{value:ae,children:jsx(kd.Provider,{value:C,children:jsx(Ad.Provider,{value:fe,children:jsx(Ci.Provider,{value:N,children:jsx(p1,{children:jsx(m1,{children:jsx(Yh,{value:e.popups,children:jsx($l,{children:jsx(Ih,{popups:e.popups,children:g})})})})})})})})})})})})}function p1({children:e}){let[t,o]=useState(0),r=useCallback(()=>(o(i=>i+1),()=>o(i=>i-1)),[]),n=Hl(t>0);return jsx(Yd.Provider,{value:r,children:jsx(Ba.Provider,{value:n,children:e})})}function m1({children:e}){let t=Ol();return jsx(cu.Provider,{value:t,children:e})}var Ei=316,da=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]=useState("ltr");return useLayoutEffect(()=>{let n=t?.parentElement;if(e||!n)return;let i=()=>r(hostDirectionOf(n));return i(),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: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]=useState(null);return useEffect(()=>{if(!e){o(null);return}let r=()=>o(e.clientWidth);r();let n=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=useContext(Lt),{pageSetup:t,reviewPaneOpen:o,entitledZoom:r,scroll:n}=W(S1,P1),i=ke(),a=wg(),l=useRef(null);t&&(l.current=t.pageWidthTwips);let s=t?.pageWidthTwips??l.current,c=Pl(e),d=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]=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)),useEffect(()=>{let f=i?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=createContext(false);function J0(e){let t=useContext(lm),[o,r]=useState(null);return 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=useContext(Lt),m=Pl(d),u=Fr(),g=Lr(),p=useRef(null),f=useCallback(y=>{p.current=y,u?.setViewport(y);},[u]),h=useCallback(y=>{if(!i||!(y.metaKey||y.ctrlKey)||y.altKey)return;let x=y.target;if(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 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:jsx(Ao.Provider,{value:true,children:jsx(lm.Provider,{value:true,children:o})})})}var H1=LOADING_SNAPSHOT;function ey({ref:e,editorRef:t}){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=useRef({close:o,skip:r,viewport:n});i.current={close:o,skip:r,viewport:n},useEffect(()=>{let a=t.current;if(!e||!a)return;let l=d=>a.contains(d),s=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=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]=useState(false),c=useRef(null),d=useRef(null),m=useRef(null);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=useCallback(b=>{let v=[...m.current?.querySelectorAll(dm)??[]],P=v.indexOf(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);},[]);useEffect(()=>{if(l)return listenForOutsidePress({popup:c.current,close:()=>s(false)})},[l]),ua(l,c,b=>{s(false),b&&d.current?.focus();});let g=useCallback(b=>{s(false),runToolbarCommand(o,"review.editingMode",b),o?.focus();},[o]),p=toolbarCommandState(o,"review.editingMode"),f=localizeDisabledReason(p.disabledReason,a),h=W(()=>X1(o),G1),y=useMemo(()=>Pi.find(b=>b.mode===r)??Pi[0],[r]);if(t)return null;let x=Q("review.editingMode");return jsxs("div",{ref:c,className:`docx-toolbar__mode${e?` ${e}`:""}`,"data-slot":"review.editingMode",children:[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),jsx("span",{className:"docx-toolbar__picker-value",children:i(y.labelKey)}),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?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=localizeDisabledReason(h[v]??null,a);return 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),jsxs("span",{className:"docx-toolbar__mode-text",children:[jsx("span",{className:"docx-toolbar__mode-label",children:i(b.labelKey)}),jsx("span",{className:"docx-toolbar__mode-hint",children:i(b.hintKey)})]}),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 jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})})}var ny=[],t2=()=>{};function ki(){let e=H(),t=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 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]=useState(false),d=useRef(null),m=useRef(null),u=useRef(null),g=ne(),{t:p}=L();useEffect(()=>{if(s)return u.current?.querySelector('[role="menuitemcheckbox"]')?.focus(),listenForOutsidePress({popup:d.current,close:()=>c(false)})},[s]),ua(s,d,v=>{c(false),v&&m.current?.focus();});let f=useCallback(v=>{let P=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],T=P.indexOf(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=toolbarCommandState(r,"review.authors"),x=localizeDisabledReason(y.disabledReason,p),b=g(h?.labelKey??"reviewers.label");return jsxs("div",{ref:d,className:`docx-toolbar__reviewers${e?` ${e}`:""}`,"data-slot":"review.authors",children:[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),jsx("span",{className:"docx-toolbar__picker-value",children:b}),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),s?jsxs("div",{ref:u,className:"docx-toolbar__reviewers-menu",role:"menu","aria-label":b,"data-testid":"reviewers-menu",onKeyDown:f,children:[jsx(ay,{checked:l,label:p("reviewers.all"),testId:"reviewer-all",onChoose:()=>r?.setAllReviewAuthorsVisible(!l)}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),n.map(v=>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 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:[jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:e.checked?"\u2713":""}),e.color?jsx("span",{className:"docx-toolbar__reviewer-swatch",style:{background:e.color}}):null,jsx("span",{className:"docx-toolbar__reviewer-name",children:e.label})]})}var ly=createContext(null);function sy({children:e}){let t=ko(),[o,r]=useState(false),n=useRef(null),i=ke(),a=useRef(i);a.current=i;let l=useMemo(()=>({open:c=>{if(t){t.open("paragraph",c);return}n.current=c??hostDocumentOf(a.current).activeElement,r(true);}}),[t]),s=useCallback(()=>{r(false);let c=n.current;n.current=null,isHTMLElementNode(c)&&c.isConnected&&c.focus({preventScroll:true});},[]);return jsxs(ly.Provider,{value:l,children:[e,jsx(qo,{open:o,onClose:s})]})}function cy(){return 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=createContext({close:()=>{}});function pa(){return 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 jsxs("div",{className:"docx-toolbar__more-control",children:[jsx("span",{className:"docx-toolbar__more-control-label",children:e}),jsx("span",{className:"docx-toolbar__more-control-body",children:t})]})}function fy({slot:e}){let t=ne(),o=Yt(),{close:r}=useContext(fm),{execute:n,isActive:i,isEnabled:a,disabledReason:l,value:s}=oe(e),c=Q(e),d=chromeSlotIsToggle(e),m=o(t(c?.labelKey??e));return 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:[jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:re(c?.paths)}),jsx("span",{className:"docx-toolbar__more-command-label",children:m})]})}function gy({sections:e,className:t}){let o=ne(),[r,n]=useState(false),i=useRef(null),a=useRef(null),l=useRef(null),s=useRef(false),c=useId(),d=ke(),m=useRef(d);m.current=d;let u=o("formattingBar.more"),g=useCallback(x=>{n(false),x&&a.current?.focus();},[]),p=useMemo(()=>({close:g}),[g]);useEffect(()=>{if(!r)return;let x=i.current,b=C=>i.current?.contains(C)===true||l.current?.contains(C)===true,v=x?listenForPopupEscape({popup:x,contains:b,chromeRoot:()=>i.current?.closest(".docx-editor"),editorElements:()=>[m.current],skip:()=>hasOpenNestedPopup(l.current),close:g}):void 0,P=x?listenForPopupFocusLeave({popup:x,contains:b,close:()=>n(false)}):void 0,T=listenForOutsidePress({popup:x,close:()=>n(false)});return ()=>{T(),v?.(),P?.();}},[r,g]);let[f,h]=useState(null);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=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]),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 jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[ql]:"",children:[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?jsx(fm.Provider,{value:p,children: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=>jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":x.label??o(x.labelKey),children:[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(!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 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&&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: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:jsx(Fragment,{children:e.children})}Di.docxToolbarSlot=true;var bm=createContext("bar");function yy(){return useContext(bm)}var Xs="review.addComment";function A2({className:e,hidden:t,icon:o,asChild:r,children:n}){let i=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?jsx(J,{...u,children:n}):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]=useState(false),u=useRef(null),g=useRef(null),p=useRef(null),f=useId(),h=useMemo(()=>xm.find(T=>T.value===l)??xm[0],[l]),y=Q("image.wrap"),x=i(y?.labelKey??"formattingBar.imageWrap");useEffect(()=>{if(!d)return;let T=S=>{let k=u.current;k&&isDomNode(S.target)&&k.contains(S.target)||m(false);},C=S=>{S.key==="Escape"&&(S.preventDefault(),m(false),g.current?.focus());},E=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=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 jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsx(J,{...P,children:r}):jsx("button",{...P,children:r??re(y?.paths)}),d?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=>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]=useState(false),m=useRef(null),u=useRef(null),g=useRef(null),p=useId(),f=pa();useEffect(()=>{if(!(!c||!m.current))return listenForOutsidePress({popup:m.current,close:()=>d(false)})},[c]),useEffect(()=>{c&&m.current?.querySelector('[role="gridcell"][tabindex="0"]')?.focus();},[c]);let h=c&&a;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=toolbarPopupLeft({anchorLeft:E.left,popupWidth:P.offsetWidth,viewportWidth:C.innerWidth});P.style.left=`${S-E.left}px`;},[h]);let y=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 jsxs("span",{ref:m,className:"docx-toolbar__table-insert",children:[r?jsx(J,{...v,children:n}):jsx("button",{...v,children:o??n??re(x?.paths)}),h?jsx("div",{ref:g,id:p,className:"docx-toolbar__menu docx-toolbar__table-insert-menu",onBlur:P=>{let T=P.relatedTarget;isDomNode(T)&&!m.current?.contains(T)&&d(false);},onKeyDown:P=>{P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),d(false),u.current?.focus());},children: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=>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?jsx(J,{...u,children:n}):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}=useContext(Hr),n=ne();if(t)return null;let i=Q("file.save"),a=n(i?.labelKey??"file.save"),l=!o||!r;return 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 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=useCallback(i=>{e?.setZoom(i);},[e]),n=useCallback(i=>{e?.setZoomMode(i);},[e]);return 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(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 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:[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,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]=useState(false),[c,d]=useState(null),m=useRef(null);Oo(m,l,()=>s(false));let u=useRef(null),g=useId(),p=useCallback(T=>{if(!o)return;let C=commandForSlotValue("font.size",T);C&&o.can(C).ok&&o.exec(C);},[o]),f=useCallback(T=>{p(Math.min(Ni,Math.max(Ii,Math.round(T*2))));},[p]),h=useCallback(T=>{s(false),d(null),u.current?.blur(),T&&o?.focus();},[o]);if(useEffect(()=>{if(l)return 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 jsxs("span",{ref:m,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsx(tx,{className:e,groupLabel:a("fontSize.label"),decreaseLabel:a("fontSize.decrease"),increaseLabel:a("fontSize.increase"),middle: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?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 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]=useState(false),h=useRef(null);Oo(h,p,()=>f(false)),useEffect(()=>{if(p)return listenForOutsidePress({popup:h.current,close:()=>f(false)})},[p]);let y=useCallback(T=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),a(T);},[a]),x=useCallback(T=>{h.current?.querySelector("[aria-haspopup]")?.focus(),f(false),l(T==="auto"?"auto":FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let b=`${Math.round(r*100)}%`,v=sameZoomMode(i,AUTO_ZOOM_MODE),P=sameZoomMode(i,FIT_WIDTH_ZOOM_MODE);return jsxs("span",{ref:h,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsx(tx,{className:e,groupLabel:g("zoom.zoomLevel"),decreaseLabel:g("zoom.zoomOut"),increaseLabel:g("zoom.zoomIn"),middle: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,jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),canDecrease:m,canIncrease:d,onDecrease:c,onIncrease:s}),p?jsxs("div",{className:"docx-toolbar__menu docx-toolbar__zoom-menu",role:"listbox",tabIndex:0,"aria-label":g("zoom.zoomLevel"),children:[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")}),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")}),jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(T=>{let C=!n&&Math.abs(T-r)<.001;return 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=useRef(n);i.current=n,useEffect(()=>{e&&r&&t(false);},[e,r,t]),useEffect(()=>{let a=o.current;if(!e||r||!a)return;let l=m=>a.contains(m),s=listenForPopupEscape({popup:a,contains:l,chromeRoot:()=>a.closest(".docx-editor"),editorElements:()=>[i.current],close:m=>{t(false),m&&a.querySelector("[aria-haspopup]")?.focus();}}),c=listenForPopupFocusLeave({popup:a,contains:l,close:()=>t(false)}),d=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]=useState(false),u=useRef(null),g=useRef(null);Qr(d,m,u,t);let p=useCallback(v=>{m(false),!(!o||!v.command)&&o.can(v.command).ok&&o.exec(v.command);},[o]),f=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=lineSpacingMenuRows(r.lineSpacing);return jsxs("span",{ref:u,className:"docx-toolbar__line-spacing","data-slot":"list.lineSpacing",children:[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),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),d&&n?jsxs("div",{className:"docx-toolbar__menu docx-toolbar__line-spacing-menu",role:"menu",children:[b.map(v=>{let P=v.selected;return jsxs("button",{type:"button",role:"menuitemradio","aria-checked":P,...P?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:U,onClick:()=>p(v),children:[lineSpacingMenuRowLabel(v,s,c),P?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]},`${v.spacing.rule}:${v.spacing.value}`)}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),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")}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),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")}),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]=useState(false),c=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 jsxs("div",{ref:c,className:`docx-toolbar__alignment${e?` ${e}`:""}`,"data-slot":"alignment",children:[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),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]}),l?jsx("div",{className:"docx-toolbar__menu docx-toolbar__alignment-popup",children:m.map(f=>{let h=a(f.control?.labelKey??f.slot);return 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 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:[jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:o??c}),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?jsx(J,{...u,children:c}):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=useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():H_,[e,o]),{isEnabled:n}=oe("font.family"),i=useCallback(a=>{if(!e)return;let l=commandForSlotValue("font.family",a);l&&e.can(l).ok&&e.exec(l);},[e]);return useMemo(()=>({value:t,setValue:i,options:r,isEnabled:n}),[t,i,r,n])}var dx=createContext(null);function Nm(){return 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??jsx("span",{children:r.value??"\u2014"});return e?jsx(J,{...a,children:l}):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]=useState("");if(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)=>jsxs("div",{role:"group",children:[m>0?jsx("div",{className:"docx-toolbar__menu-separator","aria-hidden":"true"}):null,d.labelKey?jsx("div",{className:"docx-toolbar__menu-label",children:n(d.labelKey)}):null,d.fonts.map(u=>jsx(px,{value:u},u))]},d.category)),e?jsx(J,{...l,children:s}):o!==void 0?jsx("div",{...l,children:s}):jsxs("div",{className:l.className,children:[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)}),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??jsx("span",{style:{fontFamily:e},children:e});return t?jsx(J,{...l,children:s}):jsxs("button",{type:"button",...l,children:[s,a?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]=useState(false),l=useRef(null);Oo(l,i,()=>a(false)),useEffect(()=>{if(i)return listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=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??jsxs(Fragment,{children:[jsx(Fm,{}),jsx(ux,{})]});return jsx(dx.Provider,{value:s,children:t?jsx(J,{...c,ref:l,children:d}):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=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=useCallback(l=>{if(!e)return;let s=commandForSlotValue("styles.style",l);s&&e.can(s).ok&&e.exec(s);},[e]);return useMemo(()=>({value:t,setValue:a,options:n,isEnabled:i}),[t,a,n,i])}var bx=createContext(null);function Om(){return 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?jsx("span",{children:i?.valueKey?n(i.valueKey):"\u2014"}):jsx("span",{children:s?.name??r.value}));return e?jsx(J,{...l,children:c}):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=>jsx(yx,{value:l.styleId},l.styleId));return e?jsx(J,{...i,children:a}):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??jsx("span",{style:l?oI(l.preview):void 0,children:l?.name??e});return t?jsx(J,{...s,children:c}):jsxs("button",{type:"button",...s,children:[c,a?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]=useState(false),l=useRef(null);Oo(l,i,()=>a(false)),useEffect(()=>{if(i)return listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let s=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??jsxs(Fragment,{children:[jsx(Bm,{}),jsx(hx,{})]});return jsx(bx.Provider,{value:s,children:t?jsx(J,{...c,ref:l,children:d}):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?jsx(J,{...h,children:s}):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?jsx(J,{...g,children:n}):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?jsx(J,{...u,children:n}):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=>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 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=useRef(t);r.current=t,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=createContext(null);function Rx(){let e=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=tableChromeToolbarState(e,r,t);o[r]={enabled:n.enabled,disabledReason:n.disabledReason};}return o}function Um({children:e}){let t=H(),[o,r]=useState(DEFAULT_TABLE_CHROME_DRAFT),[n,i]=useState(wx);useEffect(()=>(()=>{}),[]);let a=W(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=useCallback(()=>{if(!t){i(wx);return}let u=xI(t,t.snapshot());i(g=>CI(g,u)?g:u);},[t]);useEffect(()=>{l();},[l,a]),Zm("selectionChange",useCallback(()=>{l();},[l]));let s=n.tableKey!=="",c=useMemo(()=>t?TI(t,o):{},[t,o,n.tableKey,n.selectionKey,n.cellSelectionKey,n.editable,n.editingMode]),d=useCallback((u,g)=>{if(!t)return;let{result:p,nextDraft:f}=runTableChromeCommand(t,u,g,o);p.ok&&f&&r(f);},[t,o]),m=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 jsx(qm.Provider,{value:m,children:e})}function EI(){let e=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 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){(editorInstanceScope(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function hc({enabled:e,disabledReason:t,ariaLabel:o}){let{t:r}=L(),n=localizeDisabledReason(t,r),i=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?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){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,hostDocumentOf(n).activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),Qt(d,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=hostDocumentOf(c.target).activeElement;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){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=hostDocumentOf(s.target).activeElement,d=a();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(tableChromeIconPaths(e))}function Wx(){return createContext(null)}function $o(e){let t=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]=useState(false),x=useRef(null),b=useRef(null);Qr(h,y,x,l||!m);let v=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??jsxs(Fragment,{children:[jsx(i,{}),jsx(a,{})]});return jsx(r.Provider,{value:v,children:s?jsx(J,{...P,ref:x,children:T}):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??jsxs(Fragment,{children:[re(h?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxs(Fragment,{children:[jsx(J,{...v,children:P}),b]}):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=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?jsx(J,{...x,children:c}):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=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?jsx(J,{...d,children:m}):jsx("button",{...d,children:m})}function Kx(e){let{children:t}=e;return jsx(Hi.Content,{...e,children:t??jsx("div",{className:"docx-table-chrome__target-grid",children:TABLE_BORDER_TARGET_OPTIONS.map(o=>jsx(Zx,{value:o.value},o.value))})})}function LI(e){let{children:t}=e,o=t??jsxs(Fragment,{children:[jsx(Hi.Trigger,{}),jsx(Kx,{})]});return 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=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??jsxs(Fragment,{children:[jsx("span",{className:`docx-table-line ${s.previewClass}`,"aria-hidden":"true"}),jsx("span",{children:l(s.labelKey)})]});return t?jsx(J,{...d,children:m}):jsx("button",{...d,children:m})}function Ux(e){let{children:t}=e;return jsx(Ai.Content,{...e,children:t??TABLE_BORDER_STYLE_OPTIONS.map(o=>jsx(qx,{value:o.value},o.value))})}function HI(e){let t=e.children??jsxs(Fragment,{children:[jsx(Ai.Trigger,{}),jsx(Ux,{})]});return 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=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??jsxs(Fragment,{children:[jsx("span",{className:"docx-table-line docx-table-line--single",style:{height:`${c.previewThickness}px`},"aria-hidden":"true"}),jsx("span",{children:l(c.labelKey)})]});return t?jsx(J,{...m,children:u}):jsx("button",{...m,children:u})}function $x(e){let{children:t}=e;return jsx(Oi.Content,{...e,children:t??TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsx(zx,{value:String(o.size)},o.size))})}function AI(e){let t=e.children??jsxs(Fragment,{children:[jsx(Oi.Trigger,{}),jsx($x,{})]});return 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]=useState(false),[P,T]=useState(r),C=useRef(null),E=useRef(null);Qr(b,v,C,d||!p);let S=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??jsxs(Fragment,{children:[jsx(a,{}),jsx(l,{}),jsx(s,{clearFill:o?.clearFill??false})]});return jsx(n.Provider,{value:S,children:m?jsx(J,{...k,ref:C,children:w}):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??jsxs(Fragment,{children:[re(b?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${C.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxs(Fragment,{children:[jsx(J,{...E,children:S}),T]}):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?jsxs(Fragment,{children:[jsx(J,{...C,children:E}),T]}):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=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??jsxs(Fragment,{children:[g?jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:U,onClick:()=>{f(false),y(null),bc(b.current);},children:[jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),T("table.clearCellFill")]}):null,jsx(Zd,{apply:I=>{f(false),P?.(I),y({kind:"hex",value:I}),bc(b.current);},current:S})]});return d?jsx(J,{...k,children:w}):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?jsx(J,{...C,children:f}):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 jsx(Bi.Content,{...e,clearFill:false})}function BI(e){return jsx(Bi.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function WI(e){return 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 jsx(Wi.Content,{...e,clearFill:true})}function KI(e){return jsx(Wi.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function qI(e){return 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()?jsxs(Fragment,{children:[t?jsx(Jr,{}):null,[Zi,Ui,Ki,qi,zi].map(n=>{let i=e.get(n.docxSlot);return i?jsx(Fragment$1,{children:i},n.docxSlot):jsx(n,{},n.docxSlot)}),[ga,ba].map(n=>{let i=e.get(n.docxSlot);return i?jsx(Fragment$1,{children:i},n.docxSlot):jsx(n,{},n.docxSlot)})]}):null}function jx(){let e=ne(),{draft:t}=fc("table.borderTarget");return e(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=>jsx(Bo,{slotId:e,...o}),Yx.set(e,t)),t}function e8(e,t){return 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=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(!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:isValidElement(e)?Children.toArray(e.props.children).some(Vm):false}function a8(e,t){return t?true: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=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=useMemo(()=>e8(d,p),[d,p]),h=useMemo(()=>new Set(f.flatMap(S=>S.entries.map(k=>k.slot))),[f]),y=useMemo(()=>i?hy(l,Cc,S=>h.has(S),S=>Gm.includes(S)):null,[i,l,h]),x=useMemo(()=>y?l8(f,y):[],[f,y]),b=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=useMemo(()=>{let S=new Map;for(let k of x)k.priority!==void 0&&S.set(k.id,k.priority);return collapseOrder(b.map(k=>k.id),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 jsx(V,{})},O=R=>{let z=k.get(R.slot);if(z)return z;let V=R.Part;return 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: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?[]:[jsx(Fragment$1,{children:_},A.slot)]}),G=toolbarHostPanelShown(R.extras.length>0,Y)?c8(R):null;G!==null&&q.push(jsx(Fragment$1,{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(jsx(Jr,{},`separator-${R.id}`)),F+=1,N.push(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 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?[]:[jsx(Fragment$1,{children:V},z.slot)]});R.length>0&&B.unshift({id:yc.id,labelKey:yc.labelKey,children:R});}E=jsxs(Fragment,{children:[N,u&&!D?jsx(Jr,{},"separator-contextual-table"):null,D?null:jsx("div",{className:"docx-toolbar__contextual",[Nn]:on,children:jsx(Gx,{overrides:k,separator:false})}),w.length>0?jsx("div",{className:"docx-toolbar__group",[Fn]:"",children:w}):null,B.length>0?jsx(gy,{sections:B}):null]});}return jsx(Hr.Provider,{value:s,children:jsx(sy,{children: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)?jsx(Um,{children:E}):E})})})}function Tc(e){if(!e)return false;if(e.type===Fragment$1){let t=Children.toArray(e.props.children).find(o=>Cc(o)!==null);return 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 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=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??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=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(!isValidElement(s)||s.type!==Di)continue;let c=s.props.slotId;Py(c,Q(c)!==null);}return 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:jsx(bm.Provider,{value:"panel",children: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)?jsx(my,{label:d8(o,e,r),children:a?a():n(e)}):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=hostDocumentOf(r).createElement("a");i.href=n,i.download=t,i.click(),hostWindowOf(r).setTimeout(()=>URL.revokeObjectURL(n),0);}function rv(e,t,o){let{t:r}=L(),n=useRef(false),[i,a]=useState(false),[l,s]=useState(""),[c,d]=useState("pdf"),[m,u]=useState(false),[g,p]=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 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 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=useRef({editor:e,exporters:t,feedback:o,t:r});n.current={editor:e,exporters:t,feedback:o,t:r};let i=useRef(null),a=useRef(null),[l,s]=useState(false),[c,d]=useState(""),[m,u]=useState(""),[g,p]=useState(false),[f,h]=useState(false),[y,x]=useState({}),b=useCallback(T=>{let{t:C}=n.current;if(T instanceof ChromeExportError)return C("toolbar.printPdfMissing");if(T instanceof 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=useCallback(()=>{i.current=null,h(false),p(false),s(false);},[]),P=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 runChromePrint(C,E,T??hostDocumentOf(null));if(i.current!==S){k.dispose();return}a.current=k,await k.print({beforePrint:()=>{if(i.current!==S)throw new ChromePrintError("print-ended");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 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=useCallback(r=>e?e.on("hostChange",r):D8,[e]),o=useCallback(()=>e?editorHostDocument(e):typeof globalThis.document>"u"?null:globalThis.document,[e]);return 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
+ `),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 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:jsxs(ro,{id:"help",...t,children:[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=toolbarCommandState(o,"review.authors"),c=localizeDisabledReason(s.disabledReason,a);if(!s.enabled)return 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 jsxs(oo,{labelKey:"reviewers.label",className:e,children:[jsx(cv,{checked:m,label:i("reviewers.all"),slot:"reviewer-all",onChoose:()=>o?.setAllReviewAuthorsVisible(!m)}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),r.map(u=>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 jsx(we,{active:e.checked,slot:e.slot,className:"docx-menubar__reviewer-item",icon:jsx("span",{className:"docx-menubar__reviewer-check",children:e.checked?"\u2713":""}),onSelect:e.onChoose,children:e.label})}function A8({children:e,...t}){return jsxs(ro,{id:"review",...t,children:[jsx(oo,{labelKey:"reviewers.markupOptions",className:"docx-menubar__markup-options",children: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(!isValidElement(e))return null;if(e.type===Fragment$1){let i=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(CHROME_MENUS.map(e=>e.id));function _c(e){if(!isValidElement(e))return null;if(e.type===Fragment$1){let r=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]=useState(null),T=W(z8);useEffect(()=>{T&&P(null);},[T]);let[C,E]=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]=useState(null),[R,z]=useState(false),[V,ee]=useState(false),[Y,q]=useState(false),G=useRef(null),ce=useRef(null);useEffect(()=>{if(v!==null)return listenForOutsidePress({popup:G.current,close:()=>P(null)})},[v]),ua(v!==null,G,()=>P(null),le=>isDomNode(le.target)&&G.current?.contains(le.target)===true);let A=useCallback(le=>{P(le),le!==null&&D(le);},[]),_=useCallback(()=>ce.current?.click(),[]),ae=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=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=useMemo(()=>x&&!O?()=>{vu(G.current),N(editorInstanceScope(G.current)??G.current??void 0);}:void 0,[x,O,N]),ft=x?t?.ownsPageSetup?fe:u??fe:void 0,ve=Jm();useEffect(()=>{let le=xe=>{if(!(xe.metaKey||xe.ctrlKey)||xe.altKey||xe.shiftKey)return;let Et=xe.key.toLowerCase(),Ho=isChromePrintShortcut(xe);if(Et!=="s"&&Et!=="o"&&!Ho)return;let or=xe.target,_r=editorInstanceScope(G.current)??G.current;if(!(!or||!((_r?.contains(or)??false)||bb(or,hostDocumentOf(G.current),x?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=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=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=Children.toArray(y),Nt=[];if(f){let le=new Map(Zt.map(be=>[_c(be),be]));for(let be of 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=useMemo(()=>({measuring:h,overflow:ie,inMore:false}),[h,ie]),Ie=useMemo(()=>({measuring:false,overflow:ie,inMore:true}),[ie]),go=le=>Yi(le,true)!==null,tr=(le,be)=>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=[...CHROME_MENUS.map(xe=>{let Et=le.get(xe.id);if(Et)return jsx(Fragment$1,{children:Et},xe.id);let Ho=q8[xe.id];return jsx(Ho,{},xe.id)}),...be.filter(go)];let Ke=be.filter(xe=>!go(xe));Lo=jsxs(Fragment,{children:[Ft,Ke.length>0?tr(Ke,"host"):null]});}let yn=a?.("formattingBar.more")??b("formattingBar.more");return jsxs($a.Provider,{value:nt,children:[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(hostDocumentOf(be).activeElement);if(xe===-1)return;le.preventDefault();let Et=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:jsxs(Zl.Provider,{value:at,children:[jsx(In.Provider,{value:0,children:Lo}),ie.size>0?jsx(ro,{id:_n,label:yn,icon:re(mm),preset:false,children:jsx(Zl.Provider,{value:Ie,children:Ft})}):null]})}),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):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):jsx(Fa,{open:true,pending:I.pending,error:I.error,url:I.url,onClose:I.close}):null]}),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);}));}}),jsx(qr,{open:R,onClose:()=>z(false)}),jsx(qo,{open:V,onClose:()=>ee(false)}),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"?SNAP_TWIPS_CM: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]=useState(null),[b,v]=useState(null),[P,T]=useState(null),[C,E]=useState(null),S=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=useCallback(_=>{let ae=S.current?.getBoundingClientRect();return ae?Bs((_-ae.left)/t):null},[t]),V=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=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=useCallback(_=>{_==="leftMargin"||_==="rightMargin"?i?.():d?.(),x(null),T(null),E(null);},[i,d]),Y=useCallback((_,ae,fe)=>{let Z=handlePosition(_,B,N),de=dragIndent(_,Z+ae*sN(m,fe),B,N,{unit:m,precise:true});c?.(de),d?.();},[B,N,m,c,d]),q=rulerMarginTicks(N,B,m).map(_=>({..._,position:ze(_.position)*t})),G=a&&s&&c!==void 0,ce=_=>ze(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 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:[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"));}}),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"));}}),jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:rn,pointerEvents:"none"},children:q.map((_,ae)=>jsx(cN,{tick:_},ae))}),p?.map(_=>jsx(mN,{tabMark:_,positionPx:ze(rulerTabPosition(_.position,N,B))*t,onDoubleClick:()=>f?.(_.position)},_.position)),a&&jsxs(Fragment,{children:[jsx(af,{direction:"down",anchor:"top",...A("firstLine","ruler.firstLineIndent",B.firstLine)}),jsx(af,{direction:"up",anchor:"strip",...A("hanging","ruler.hangingIndent",B.left)}),jsx(dN,{...A("left","ruler.leftIndent",B.left)}),jsx(af,{direction:"up",anchor:"strip",...A("right","ruler.rightIndent",B.right)})]}),y&&P!==null&&C!==null&&jsx(uN,{value:yv(P,m),positionPx:C})]})}function cN({tick:e}){return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:Dt(e.position),bottom:0,width:1,height:e.height,backgroundColor:rN}}),e.label&&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 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: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 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: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 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 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]=useState(null),[g,p]=useState(null),f=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=useCallback((I,O)=>{o&&(I.preventDefault(),u(O));},[o]),E=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=useCallback(()=>{m!==null&&i?.(),u(null);},[m,i]);useEffect(()=>{if(m){let I=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 jsxs("div",{ref:f,className:`docx-vertical-ruler ${l}`,style:w,dir:d,role:"group","aria-label":c("ruler.vertical"),children:[jsx("div",{style:{position:"absolute",top:0,insetInlineStart:0,insetInlineEnd:0,bottom:0,pointerEvents:"none"},children:k.map((I,O)=>jsx(EN,{tick:I},O))}),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")}),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 jsxs(Fragment,{children:[jsx("div",{style:t}),e.label&&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 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: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=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 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]=useState({}),r=useRef({}),n=useCallback(a=>l=>{r.current={...r.current,[a]:Math.round(l)},o(r.current);},[]),i=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]=useState(null),a=useRef(null),l=useRef(null),s=useCallback(m=>{l.current===null&&(l.current=Dv(e)),a.current=m,i(m);},[e]),c=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=useMemo(()=>n??(t?{left:t.left,right:t.right,firstLine:t.firstLine,...t.rtl?{rtl:true}:{}}:null),[n,t]);return useMemo(()=>({indent:d,isEnabled:o,preview:s,commit:c}),[d,o,s,c])}function FN(){let e=ke(),[t,o]=useState(0);return 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: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: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: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 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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsxs(K,{...e,children:[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"}),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 jsx(K,{...e,children:jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function Av(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function UN(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function QN(e){return jsx(K,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function e5(e){return jsx(K,{...e,children:jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function t5(e){return jsx(K,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function gf(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function a5(e){return jsx(K,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function i5(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function d5(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function g5(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function x5(e){return jsx(K,{...e,children:jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function v5(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function S5(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function w5(e){return jsx(K,{...e,children:jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function D5(e){return jsx(K,{...e,children:jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function R5(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function W5(e){return jsx(K,{...e,children:jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function Z5(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function J5(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function o6(e){return jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function n6(e){return jsx(K,{...e,children:jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function a6(e){return jsx(K,{...e,children:jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function i6(e){return jsx(K,{...e,children:jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function l6(e){return jsx(K,{...e,children:jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function s6(e){return jsx(K,{...e,children:jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function c6(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function m6(e){return jsx(K,{...e,children: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 jsx(K,{...e,children:jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function g6(e){return jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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 jsx(K,{...e,children: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?jsx(n,{size:t,className:o,style:r}):(console.warn(`Icon not found: ${e}`),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__default.memo(function({headings:t,onHeadingClick:o,onClose:r,topOffset:n=0,scrollLeft:i=0,leftOffset:a=tl}){let{t:l}=L(),[s,c]=useState(false),d=useRef(null),m=t.length?Math.min(...t.map(u=>u.level)):0;return useEffect(()=>{hostWindowOf(d.current).requestAnimationFrame(()=>c(true));},[]),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:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"16px 16px 12px 0"},children:[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:jsx(j,{name:"arrow_back",size:20})}),jsx("span",{style:{fontWeight:400,fontSize:14,color:"var(--doc-text)",letterSpacing:"0.01em"},children:l("documentOutline.title")})]}),jsx("div",{style:{overflowY:"auto",flex:1,paddingLeft:4},children:t.length===0?jsx("div",{style:{padding:"8px 16px",color:"var(--doc-text-subtle)",fontSize:13,lineHeight:"20px"},children:l("documentOutline.noHeadings")}):t.map((u,g)=>jsx("div",{style:{marginLeft:(u.level-m)*16},children: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=useMemo(()=>t&&!o.isLoading?t.getOutline():N6,[t,o]),n=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:jsx(ol,{headings:r,onHeadingClick:n,onClose:e.onClose??F6,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var yf=createContext(null);function Do(e){let t=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=useCallback(S=>t?o?.query({type:"bookmarks"})??Gv:Gv,[o,t]),n=W(r,ep),[i,a]=useState(""),[l,s]=useState("name"),[c,d]=useState(false),[m,u]=useState(null),[g,p]=useState(null),[f,h]=useState(""),y=useMemo(()=>goToBookmarkRows(n,{query:i,sortBy:l,showHidden:c}),[n,i,l,c]),x=useMemo(()=>m===null?-1:y.findIndex(S=>S.name===m),[y,m]),b=useCallback(S=>{a(S),u(null),p(null);},[]),v=useCallback(S=>{s(S),u(null),p(null);},[]),P=useCallback(S=>{d(S),u(null),p(null);},[]),T=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=useCallback(S=>u(y[S]?.name??null),[y]),E=useCallback(S=>{if(!o)return W6;let k=S??y[x]?.name??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 jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children: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=goToBookmarkMatch(e,t);return o?jsxs(Fragment,{children:[e.slice(0,o.start),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=useId(),m=`${d}-list`,u=`${d}-label`,g=`${d}-hint`,p=C=>`${d}-option-${C}`,f=useRef(null);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 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:[jsx("span",{className:"docx-nav__goto-icon","aria-hidden":"true",children:C.empty?jsx(G6,{}):jsx(j,{name:"bookmark",size:16})}),jsx("span",{className:"docx-nav__result-text",children:jsx("bdi",{children:jsx(j6,{name:C.name,query:l.query})})}),C.atSelection&&jsx("span",{className:"docx-nav__goto-here",title:n("navigation.goTo.atCaret"),children:jsx("span",{className:"docx-editor-sr-only",children:n("navigation.goTo.atCaret")})}),!v&&C.place!=="body"&&jsx("span",{className:"docx-nav__goto-place",children:n($6[C.place])})]},C.name)};return 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:[jsxs("div",{className:"docx-nav__searchbox",children:[jsx(j,{name:"bookmark",size:18,className:"docx-nav__search-icon"}),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&&jsx("kbd",{className:"docx-nav__goto-enter","aria-hidden":"true",children:"\u21B5"}),jsx("span",{id:g,className:"docx-editor-sr-only",children:n("navigation.goTo.enterHint")})]}),jsxs("div",{className:"docx-nav__goto-controls",children:[jsx("div",{className:"docx-nav__segmented",role:"radiogroup","aria-label":n("dialogs.bookmark.sortBy"),children:["name","location"].map(C=>jsxs("label",{className:"docx-nav__segment","data-checked":l.sortBy===C||void 0,children:[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))}),jsxs("label",{className:"docx-nav__option",children:[jsx("input",{type:"checkbox",checked:l.showHidden,onChange:C=>l.setShowHidden(C.target.checked)}),n("dialogs.bookmark.showHidden")]})]}),P&&!c&&jsxs("div",{className:"docx-nav__goto-empty",children:[jsx(j,{name:"bookmark",size:24,className:"docx-nav__goto-empty-icon"}),jsx("p",{className:"docx-nav__goto-empty-title",children:n("navigation.goTo.empty")}),jsx("p",{className:"docx-nav__goto-empty-hint",children:n("navigation.goTo.emptyHint")}),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&&jsxs("div",{className:"docx-nav__goto-heading",children:[jsx("span",{id:u,children:n("navigation.goTo.listAriaLabel")}),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})]}),jsx("p",{className:"docx-nav__goto-message",role:"status",children:x}),l.rows.length>0&&jsx("ul",{ref:f,id:m,className:"docx-nav__list docx-nav__goto-list",role:"listbox","aria-labelledby":u,children:v?goToBookmarkGroups(l.rows).map(C=>jsxs("li",{role:"group","aria-labelledby":`${d}-group-${C.place}`,className:"docx-nav__goto-group",children:[jsx("div",{id:`${d}-group-${C.place}`,className:"docx-nav__goto-group-label",children:n(V6[C.place])}),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]=useState(null),n=useMemo(()=>e&&!t.isLoading?e.getOutline():Q6,[e,t]),i=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=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=useMemo(()=>o?createDocumentSearch(o):null,[o]),n=useSyncExternalStore(r?r.subscribe:nF,r?r.getState:Jv,r?r.getState:Jv);useEffect(()=>{if(!(!r||t==="none"))return r.showHighlights(t)},[r,t]);let i=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 useMemo(()=>({...n,...i}),[n,i])}function sC(e,t=isApplePlatform()){return e.altKey||e.shiftKey||e.isComposing||(t?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey)?false:chordLetter(e)==="f"}var cC=isGoToChord;function dC(e=isApplePlatform()){return e?"Ctrl+Alt+G":"Ctrl+G"}function uC(e=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(!isDomNode(e))return false;if(t?.contains(e))return true;if(!o)return false;if(o.contains(e))return true;let r=isElementNode(e)?e:e.parentElement;if(!r)return false;let n=editorInstanceScope(o);if(n&&n!==o&&n.contains(r))return true;if(!r.closest(".docx-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}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=>{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=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=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=useRef(null),a=useRef(null),l=useRef(false),s=useRef(false),c=useRef(false),d=useRef(0),m=useCallback(()=>{let T=++d.current;hostWindowOf(i.current).setTimeout(()=>{d.current===T&&(l.current=false,s.current=false,c.current=false);},0);},[]),u=useRef(e);u.current=e;let g=useCallback(()=>{l.current=false;let T=Tf(i.current,u.current.tab);T&&Ef(T);},[]),p=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=useRef(p);f.current=p,useEffect(()=>()=>{s.current&&f.current();},[]);let h=useCallback(()=>{l.current=false,s.current=true,u.current.setOpen(false),m();},[m]),y=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=useMemo(()=>({openTab:T=>{let C=i.current?.ownerDocument.activeElement;y(T,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=useRef(x);b.current=x,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,isHTMLElementNode(k)?k:null);};return T.addEventListener("keydown",C),()=>T.removeEventListener("keydown",C)},[n,t,o,y,r]),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;useEffect(()=>{let T=i.current;if(!(!v||!T||!n))return gC(T,n,()=>b.current.close())},[v,n]),useEffect(()=>{let T=i.current;if(!(!T||!n||!n.contains(T)))return bC(T,n)},[n]);let P=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=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??ZOOM_MAX)&&e.zoom>(t.minZoom??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]=useState(t),[a,l]=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=useCallback(A=>{u||i(A),d?.(A);},[u,d]),f=useCallback(()=>p(!s),[s,p]),h=useCallback(A=>{g||l(A),m?.(A);},[g,m]),y=Fr(),x=ke(),b=useContext(Lt),{pageSetup:v,zoom:P,reviewPaneOpen:T,fitting:C}=W(CF,TF),E=H(),S=W(EF),[k,w]=useState(0),[I,O]=useState(null),[N,B]=useState(0),[F,D]=useState(0),R=fr();useEffect(()=>{if(!x){w(0),B(0),D(0);return}let A=()=>{w(x.clientWidth);let fe=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 _=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=useRef(null);v&&(z.current=v.pageWidthTwips);let V=v?.pageWidthTwips??z.current,ee=useRef(null);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]),useEffect(()=>ee.current?.nudge(),[S,V]);let Y=Sa(r),q=V0(R,N),G=s&&Kc(k-q,Y),ce=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 useEffect(()=>{if(y)return y.setShift(ce),()=>y.setShift(0)},[y,ce]),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 jsx("div",{className:_o("docx-nav__header",e),style:t,children:o??jsxs(Fragment,{children:[jsx(sl,{}),jsx(cl,{})]})})}function sl({className:e,style:t,children:o}){let{intents:r,t:n}=Do("Close");return 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??jsx(j,{name:"arrow_back",size:20})})}function cl({className:e,style:t,children:o}){let{t:r}=Do("Title");return 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=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 jsx("div",{className:_o("docx-nav__tabs",e),style:t,role:"tablist","aria-label":n("navigation.title"),onKeyDown:i,children:o??il.map(a=>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 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=useRef(null);return useEffect(()=>{a&&s.current?.focus();},[a]),jsxs("div",{className:"docx-nav__searchbox",children:[jsx(j,{name:"search",size:18,className:"docx-nav__search-icon"}),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&&jsx("button",{type:"button",className:"docx-nav__search-clear","aria-label":i,onClick:o,children: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]=useState(""),s=W(no),c=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 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:[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?jsx("p",{className:"docx-nav__empty",children:i("navigation.headings.noHeadings")}):c.length===0?jsx("p",{className:"docx-nav__empty",children:i("navigation.find.noResults")}):jsx("ul",{className:"docx-nav__list",children:c.map((m,u)=>jsx("li",{children: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:jsx("bdi",{children:m.heading.text})})},`${m.heading.blockId}-${u}`))})]})}function RF({match:e,active:t,onSelect:o}){return jsx("li",{children:jsx("button",{type:"button",className:_o("docx-nav__result",t&&"docx-nav__result--active"),"aria-current":t?"true":void 0,onClick:o,children:jsx("span",{className:"docx-nav__result-text",children:jsxs("bdi",{children:[e.contextBefore,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 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:[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();}}),jsxs("div",{className:"docx-nav__options",role:"group","aria-label":i("navigation.find.optionsAriaLabel"),children:[jsxs("label",{className:"docx-nav__option",children:[jsx("input",{type:"checkbox",checked:r.matchCase,onChange:d=>r.setMatchCase(d.target.checked)}),i("navigation.find.matchCase")]}),jsxs("label",{className:"docx-nav__option",children:[jsx("input",{type:"checkbox",checked:r.wholeWord,onChange:d=>r.setWholeWord(d.target.checked)}),i("navigation.find.wholeWord")]})]}),jsxs("div",{className:"docx-nav__resultbar",children:[jsx("span",{className:"docx-nav__count","aria-live":"polite",children:l?r.isPending?i("navigation.find.searching"):c??i("navigation.find.noResults"):""}),jsxs("span",{className:"docx-nav__steppers",children:[jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.previousAriaLabel"),disabled:r.matches.length===0,onClick:r.previous,children:jsx(j,{name:"keyboard_arrow_up",size:18})}),jsx("button",{type:"button",className:"docx-nav__stepper","aria-label":i("navigation.find.nextAriaLabel"),disabled:r.matches.length===0,onClick:r.next,children:jsx(j,{name:"keyboard_arrow_down",size:18})})]})]}),r.matches.length>0&&jsx("ul",{className:"docx-nav__list","aria-label":i("navigation.find.resultsAriaLabel"),children:r.matches.map((d,m)=>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 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??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=useMemo(()=>r??((E,S)=>h(E,S)),[r,h]),x=yC(u,a,l),b=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=useRef(x.intents);P.current=x.intents;let T=useRef(l);T.current=l,useEffect(()=>{if(v)return v.setGoToChrome({onRequest:()=>P.current.openTab("goto"),get shortcut(){return T.current}})},[v]);let C=e.paneWidth??280;return jsx(yf.Provider,{value:b,children: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&&jsx(fl,{...typeof n=="object"?n:{}}),jsx("aside",{className:"docx-nav__panel-shell","aria-label":b.t("navigation.ariaLabel"),inert:!u.open,children:d??jsxs(Fragment,{children:[jsx(ll,{}),jsx(dl,{}),jsx(pl,{}),jsx(ml,{}),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=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=useContext(Vc),[u,g]=useState(1),[p,f]=useState(false);if(useEffect(()=>{if(f(false),!n||!i||c<=1)return;g(n.getCurrentPage("viewport"));let b=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=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?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]=useState(null);if(r.length===0)return null;let s=r.join("\0");return a===s?null:jsxs("div",{className:e?`docx-font-notice ${e}`:"docx-font-notice",role:"status",...t?{style:t}:{},children:[jsx("span",{className:"docx-font-notice__text",children:i("editor.fontSubstitutionNotice",{fonts:r.join(", ")}).replace("{fonts}",r.join(", "))}),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]=useState(null),a=t!==null&&t!==n?t:null,l=useCallback(s=>{eL(s,t)||i(t);},[t]);return {failure:a,message:a?r(QF[a.reason]):null,dismiss:l}}var MC=createContext(null);function wf({variant:e="secondary",dismiss:t=false,asChild:o=false,className:r,onClick:n,children:i,type:a,...l}){let s=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?jsx(J,{...l,className:c,onClick:d,children:i}):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 Children.toArray(e).some(t=>isValidElement(t)&&t.type===Fragment$1?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=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 jsx(MC.Provider,{value:x,children:jsx(Be,{kind:"openFailure",role:"alertdialog",label:b,className:s,style:c,onClose:y,dismissOutside:false,...l?{}:{describedBy:h},children:l?l(x):jsxs(Fragment,{children:[jsx("header",{className:"docx-dialog__header",children:jsx("h2",{className:"docx-dialog__title",children:b})}),jsxs("div",{className:"docx-dialog__body",children:[jsx("div",{id:h,className:"docx-dialog__message",children:v}),o?jsx("p",{className:"docx-dialog__code",children:u("openFailure.code",{code:g.code}).replace("{code}",g.code)}):null]}),T||i?jsxs("footer",{className:"docx-dialog__footer",children:[P,i?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=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 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]=useState(false),l=useRef(null),[s,c]=useState(""),[d,m]=useState("");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]),useEffect(()=>{if(i)return listenForOutsidePress({popup:l.current,close:()=>a(false)})},[i]);let u=useMemo(()=>({type:"setHeaderFooterOptions",titlePage:!t.titlePage}),[t.titlePage]),g=useMemo(()=>({type:"setHeaderFooterOptions",evenAndOddHeaders:!t.evenAndOddHeaders}),[t.evenAndOddHeaders]),p=useMemo(()=>({type:"linkHeaderFooterToPrevious"}),[]),f=useMemo(()=>({type:"unlinkHeaderFooterFromPrevious"}),[]),h=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 jsxs("div",{ref:l,className:"docx-hf-chrome__options",onMouseDown:o,children:[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?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 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)}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsx("input",{type:"checkbox",checked:t.titlePage===true,disabled:!y.enabled,title:y.reason??void 0,onChange:()=>n?.exec(u)}),jsx("span",{children:r("headerFooter.differentFirstPage")})]}),jsxs("label",{className:"docx-hf-chrome__menu-row",children:[jsx("input",{type:"checkbox",checked:t.evenAndOddHeaders===true,disabled:!x.enabled,title:x.reason??void 0,onChange:()=>n?.exec(g)}),jsxs("span",{children:[r("headerFooter.differentOddEven"),jsx("span",{className:"docx-hf-chrome__menu-hint",children:r("headerFooter.differentOddEvenHint")})]})]}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),t.inherited?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")}):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")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsx("span",{children:r("headerFooter.headerDistance")}),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)}),jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsxs("label",{className:"docx-hf-chrome__menu-row docx-hf-chrome__menu-row--distance",children:[jsx("span",{children:r("headerFooter.footerDistance")}),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)}),jsx("span",{className:"docx-hf-chrome__unit",children:"in"})]}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),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")}),jsx("div",{className:"docx-hf-chrome__menu-separator",role:"separator"}),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=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 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:[jsxs("div",{className:"docx-context-bar__label",children:[jsx("span",{className:"docx-context-bar__title",children:t(a)}),o.inherited?jsx("span",{className:"docx-context-bar__status","data-testid":"docx-hf-inherited",title:t("headerFooter.sameAsPreviousHint"),children:t("headerFooter.sameAsPrevious")}):null]}),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=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=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(),_=useCallback((de,Re)=>s?s(de,Re):ce(de,Re),[s,ce]),ae=jsxs(Us,{className:c?G?"dark":void 0:l,style:c?fL:void 0,children:[c?jsx(Xc,{}):null,c?jsx(Cs,{}):null,jsx(Os,{}),q&&c?jsx("div",{style:hL,dir:A,children:jsx(Oc,{})}):null,t.children]}),fe=c?jsxs("div",{className:`docx-editor${G?" dark":""}${l?` ${l}`:""}`,style:mL,dir:A,children:[jsxs("div",{style:yL,children:[jsxs("div",{style:vL,children:[u?.(),jsxs("div",{style:CL,children:[m?jsx("input",{"aria-label":_("titleBar.documentNameAriaLabel"),value:d??"",placeholder:_("titleBar.untitled"),onChange:de=>m(de.target.value),style:TL}):jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:d??_("titleBar.untitled")}),V!==false?jsx(Xi,{t:_,...d!==void 0?{fileName:d}:{},...F?{onOpen:F}:{},...D?{onSave:D}:{},...typeof V=="object"?V:{}}):null]}),g?.()]}),jsx("div",{style:xL,children:jsx(Vi,{t:_})})]}),q?jsx("div",{style:bL,"data-testid":"docx-editor-ruler-row",children:jsx(Ac,{})}):null,jsx(jc,{t:_}),jsxs("div",{style:gL,children:[ee===false?null:jsx($c,{t:_,...typeof ee=="object"?ee:{}}),ae,jsx(Vc.Provider,{value:_,children:jsx(Gc,{})}),jsx(Ws,{overlay:true,indicator:f})]})]}):ae,Z=useCallback(de=>_(de),[_]);return 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:[jsx(EL,{forwardedRef:o}),jsx(Ao.Provider,{value:c,children:fe}),Y===false?null:jsx(Yc,{t:_,...typeof Y=="object"?Y:{},...p?{actions:p}:{},className:SL(G?"dark":void 0,typeof Y=="object"?Y.className:void 0)})]})}),kL=forwardRef(function(t,o){return jsx(vn,{...t.i18n!==void 0?{i18n:t.i18n}:{},children: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"||isFontResolver(e))return e;let t=e;return defineFontResolver(async()=>t())}function OC(e){return e!==void 0&&_f(e).some(t=>isFontResolver(t))}async function FL(e){return typeof e!="function"?await e:await e()}function LL(e,t={}){let[o,r]=useState(void 0),[n,i]=useState(void 0),[a,l]=useState(null),[s,c]=useState(e!=null),d=OC(t.fonts),m=t.fonts===void 0?"absent":d?"on-demand":"eager",[u,g]=useState(t.fonts===void 0),p=useRef(t);p.current=t;let f=useMemo(()=>defineFontResolver(h=>composeFontOrigins(_f(p.current.fonts??[]).map(NL),h)),[]);return 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(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]),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=useRef(e);return t.current=e,useMemo(()=>defineFontResolver(o=>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=useRef(null),o=useCallback(n=>{if(!e)return ()=>{};let i=e.on("selectionChange",n),a=e.on("change",n);return ()=>{i(),a();}},[e]),r=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 useSyncExternalStore(o,r,()=>null)}function zL(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function GL(e){let t=H(),o=useRef(e);o.current=e;let r=typeof e=="function";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]=useState(qC),a=useRef(null),l=useRef(o);l.current=o;let s=useRef(t);s.current=t;let c=UC(o);return useEffect(()=>{if(!r){i(qC);return}let d=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]),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]=useState(null);return useEffect(()=>{if(!t){n(null);return}let i=hostDocumentOf(o),a=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=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=useRef(null),c=useRef(null),[d,m]=useState(null),u=useRef(r);u.current=r;let g=useRef(n);return g.current=n,useEffect(()=>{let p=s.current;if(!p)return;let f=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]),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}),[]),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=createContext(null);function zC(){let e=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]=useState(false),[a,l]=useState(null),s=useRef(null),c=useRef(null),[d,m]=useState({top:0,left:0}),u=useCallback(()=>{i(false),l(null);},[]);useEffect(()=>{if(!n||!s.current)return;let p=s.current.getBoundingClientRect();m({top:p.bottom+2,left:p.left});},[n]),useEffect(()=>{if(!n)return;function p(b){b.key==="Escape"&&u();}function f(){u();}let h=hostDocumentOf(s.current),y=hostWindowOf(s.current),x=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 jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:s,type:"button",onClick:()=>!o&&i(!n),onMouseDown:p=>p.preventDefault(),disabled:o,style:n?y4:GC,children:[e,r&&jsx(j,{name:"arrow_drop_down",size:16})]}),n&&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 jsx("div",{style:v4},`sep-${f}`);let h=p;if(h.customContent)return jsx("div",{onMouseDown:b=>b.preventDefault(),children:h.customContent},h.label);let y=!!h.submenuContent,x=a===h.label;return jsxs("div",{style:{position:"relative"},onMouseEnter:()=>y&&l(h.label),onMouseLeave:()=>y&&l(null),children:[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&&jsx(j,{name:h.icon,size:18}),jsx("span",{children:h.label}),h.shortcut&&jsx("span",{style:C4,children:h.shortcut}),y&&jsx("span",{style:{marginLeft:"auto"},children:jsx(j,{name:"keyboard_arrow_right",size:16})})]}),y&&x&&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]=useState(0),[i,a]=useState(0),l=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(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 jsxs("div",{children:[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}),jsx("div",{style:k4,children:c})]})}function _4({items:e,closeMenu:t}){return jsx("div",{style:{display:"flex",flexDirection:"column",minWidth:220},children:e.map(o=>{let r=!o.onClick;return 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:[jsx(j,{name:o.icon,size:18}),jsx("span",{children:o.label})]},o.label)})})}function I4(){return jsxs("svg",{width:"32",height:"40",viewBox:"0 0 32 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[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"}),jsx("path",{d:"M22 0L32 10H24C22.9 10 22 9.1 22 8V0Z",fill:"#94a3b8"}),jsx("rect",{x:"7",y:"18",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"23",width:"18",height:"2",rx:"1",fill:"#fff"}),jsx("rect",{x:"7",y:"28",width:"12",height:"2",rx:"1",fill:"#fff"})]})}function ed({children:e}){return 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?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")}):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 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=useCallback(T=>{!o&&r&&r(T);},[o,r]),b=useCallback((T,C)=>{!o&&c&&(c(T,C),hostWindowOf(t.editorRef?.current).requestAnimationFrame(()=>y?.()));},[o,c,y,t.editorRef]),v=!!n||!!l,P=v||i||a;return jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[P&&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}]:[]]}),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")}]}),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=>jsx(JC,{onInsert:(C,E)=>{b(C,E),T();}})}]:[],...s||d&&c?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:T=>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&&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=[];Children.forEach(e,a=>{isValidElement(a)&&(a.type===ed?t=a:a.type===td?o=a:a.type===od?n.push(a):r.push(a));});let i=useCallback(a=>{let l=a.target;l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.tagName==="SELECT"||l.tagName==="OPTION"||a.preventDefault();},[]);return jsxs("div",{className:"flex items-stretch bg-doc-surface pt-2 pb-1",onMouseDown:i,"data-testid":"title-bar",children:[jsx("div",{className:"flex items-center flex-shrink-0 pl-3 pr-1",children:t||jsx(I4,{})}),jsxs("div",{className:"flex flex-col justify-center flex-1 min-w-0 py-1",children:[r.length>0&&jsx("div",{className:"flex items-center gap-2 px-1",children:r}),n.length>0&&jsx("div",{className:"flex items-center px-1",children:n})]}),o&&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=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"?applyThemeTint(n,o.keep):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(e)}var q4=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.forwardRef(({className:e,variant:t,size:o,...r},n)=>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.useState(false),[a,l]=Bt.useState({x:0,y:0}),s=Bt.useRef(null),c=Bt.useRef(null),d=Bt.useCallback(()=>{let p=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.useCallback(()=>{c.current&&(c.current.win.clearTimeout(c.current.handle),c.current=null),i(false);},[]);Bt.useEffect(()=>()=>{c.current&&c.current.win.clearTimeout(c.current.handle);},[]);let u=t.props,g=Bt.cloneElement(t,{ref:s,onMouseEnter:p=>{d(),u.onMouseEnter?.(p);},onMouseLeave:p=>{m(),u.onMouseLeave?.(p);}});return jsxs(Fragment,{children:[g,n&&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.createContext(null);function Cr(e){let[t,o]=Bt.useState(null),r=Bt.useMemo(()=>({trigger:t,setTrigger:o}),[t]);return jsx(Zf.Provider,{value:r,children:jsx(Fe.Root,{...e})})}var Tr=Fe.Group,nd=Fe.Value;function Er({className:e,children:t,onMouseDown:o,...r}){let n=Bt.useContext(Zf)?.setTrigger;return jsxs(Fe.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,jsx(Fe.Icon,{asChild:true,children: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.useContext(Zf)?.trigger??null,l=typeof globalThis.document>"u"&&!a?null:hostDocumentOf(a),c=Kt()||!!a?.closest(".docx-editor.dark");return jsx(Fe.Portal,{...l?.body?{container:l.body}:{},children:jsx("div",{className:ue("docx-editor",c&&"dark"),children:jsx(Fe.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:jsx(Fe.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 jsx(Fe.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 jsxs(Fe.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:[jsx(Fe.ItemText,{children:t}),jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(Fe.ItemIndicator,{children:jsx(Q4,{className:"h-4 w-4"})})})]})}function dn({className:e,...t}){return jsx(Fe.Separator,{className:ue("-mx-1 my-1 h-px bg-muted",e),...t})}function J4({className:e}){return jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children: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 jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children: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.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.useMemo(()=>[...d,...o],[d,o]),u=Bt.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.useCallback(f=>{let h=m.find(y=>y.name===f);h&&t?.(Kf(h.fontFamily)||h.name);},[t,m]),p=Bt.useMemo(()=>{let f={"sans-serif":[],serif:[],monospace:[],other:[]};return o.forEach(h=>{let y=h.category||"other";f[y].push(h);}),f},[o]);return jsxs(Cr,{value:u,onValueChange:g,disabled:n,children:[jsx(Er,{className:ue("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":c("font.selectAriaLabel"),children:jsx(nd,{placeholder:a,children:u})}),jsxs(Sr,{className:"max-h-[300px]",children:[d.length>0&&jsxs(Fragment,{children:[jsxs(Tr,{children:[jsx(cn,{children:c("font.documentFonts")}),d.map(f=>jsx(Gt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},`doc-${f.name}`))]}),jsx(dn,{})]}),p["sans-serif"].length>0&&jsxs(Tr,{children:[jsx(cn,{children:c("font.sansSerif")}),p["sans-serif"].map(f=>jsx(Gt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]}),p.serif.length>0&&jsxs(Fragment,{children:[jsx(dn,{}),jsxs(Tr,{children:[jsx(cn,{children:c("font.serif")}),p.serif.map(f=>jsx(Gt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.monospace.length>0&&jsxs(Fragment,{children:[jsx(dn,{}),jsxs(Tr,{children:[jsx(cn,{children:c("font.monospace")}),p.monospace.map(f=>jsx(Gt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.other.length>0&&jsxs(Fragment,{children:[jsx(dn,{}),jsx(Tr,{children:p.other.map(f=>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=useRef(null),n=useRef(null),[i,a]=useState({top:0,left:0});useEffect(()=>{if(!e||!r.current)return;let c=r.current.getBoundingClientRect();if(o==="right"){let d=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]),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)||isElementNode(h)&&h!==h.ownerDocument.documentElement&&h!==h.ownerDocument.body&&r.current&&h.contains(r.current)||t();},u=hostDocumentOf(r.current),g=hostWindowOf(r.current),p=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=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]=useState(false),[m,u]=useState(""),[g,p]=useState(false),f=useRef(null),h=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=useCallback(N=>{if(N.preventDefault(),r)return;let B=dT(v,o,a);t?.(B);},[v,o,a,r,t]),C=useCallback(N=>{if(N.preventDefault(),r)return;let B=cT(v,o,l);t?.(B);},[v,o,l,r,t]),E=useCallback(N=>{N.preventDefault(),!r&&(d(true),u(P),p(true),hostWindowOf(f.current).requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();}));},[r,P]),S=useCallback(N=>{u(N.target.value);},[]),k=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=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=useCallback(N=>{t?.(N),p(false),d(false);},[t]),O=useCallback(N=>{N.target.tagName!=="INPUT"&&N.preventDefault();},[]);return jsxs("div",{ref:y,className:ue("flex items-center",n),onMouseDown:O,children:[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:jsx(j,{name:"remove",size:18})}),jsx("div",{className:"relative",children:c?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"}):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&&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=>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))}),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: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]=useState(null);return 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 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]=useState(null),{t:i}=L();return 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 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]=useState(false),[p,f]=useState(false),[h,y]=useState(false),[x,b]=useState(false),[v,P]=useState(""),[T,C]=useState(()=>m??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:E}=L();useEffect(()=>{let A=Gf(t,e,r).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(A)&&P(A.toUpperCase());},[t,e,r]);let S=useCallback(()=>g(false),[]),{containerRef:k,dropdownRef:w,dropdownStyle:I}=_t({isOpen:u,onClose:S}),O=r?.colorScheme??null,N=useMemo(()=>oT(O),[O]),B=useMemo(()=>Gf(t,e,r),[t,e,r]),F=useMemo(()=>Gf(T,e,r),[T,e,r]),D=useCallback(()=>{n||g(A=>!A);},[n]),R=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=useCallback(A=>{let _=e==="highlight"?A:{kind:"hex",value:A};C(_),o?.(_),g(false);},[e,o]),V=useCallback(()=>{o?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,o]),ee=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=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 jsxs("div",{ref:k,className:`docx-color-picker ${i||""}`,style:{...h3,...a},children:[d?jsxs("div",{className:"docx-color-picker-split",style:{...S3,...n?{opacity:.38,cursor:"default"}:null},children:[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:[jsx(j,{name:ce,size:18}),jsx("div",{style:{...pT,backgroundColor:F==="transparent"?"#fff":F,outline:F==="transparent"||mT(F)?"1px solid #bbb":"none"}})]}),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:jsx(j,{name:"arrow_drop_down",size:18})})]}):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:[jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsx(j,{name:ce,size:18}),jsx("div",{style:{...pT,backgroundColor:B==="transparent"?"#fff":B,outline:B==="transparent"||mT(B)?"1px solid #bbb":"none"}})]}),jsx(j,{name:"arrow_drop_down",size:14})]}),u&&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:jsxs(Fragment,{children:[jsxs("button",{type:"button",style:v3,onClick:V,onMouseDown:A=>A.preventDefault(),children:[e==="highlight"?jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",border:"1px solid #ccc",borderRadius:"2px",position:"relative",backgroundColor:"#fff"},children:jsx("span",{style:{position:"absolute",top:"50%",left:"-1px",right:"-1px",height:"2px",backgroundColor:"#ff0000",transform:"rotate(-45deg)"}})}):jsx("span",{style:{display:"inline-block",width:"16px",height:"16px",backgroundColor:"#000",borderRadius:"2px"}}),c??E(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsx("div",{style:Vf}),jsx("div",{style:$f,children:E("colorPicker.themeColors")}),jsx(w3,{matrix:N,selectedColor:t,theme:r,onSelect:R}),jsx("div",{style:Vf}),jsx("div",{style:$f,children:E("colorPicker.standardColors")}),jsx(D3,{selectedColor:t,theme:r,onSelect:z}),jsx("div",{style:Vf}),jsx("div",{style:$f,children:E("colorPicker.customColor")}),jsxs("div",{style:C3,children:[jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),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"}),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: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: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: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: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]=useState(false),a=useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:s,dropdownStyle:c,handleMouseDown:d}=_t({isOpen:n,onClose:a}),m=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=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:[jsx(j,{name:u.iconName,size:vl}),jsx(j,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[n?h:jsx(Vt,{content:f,children:h}),n&&!o&&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: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 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: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]=useState(false),c={...t?H3:e?L3:l?F3:pd,...a},d=m=>{m.preventDefault();};return 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=useCallback(()=>c?{...A3}:{},[c]),g=e?.type==="bullet",p=e?.type==="numbered",h=(e?.isInList||g||p)&&(e?.level??0)>0||d;return jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...N3,...l},role:"group","aria-label":m("lists.ariaLabel"),children:[jsxs("div",{style:CT,role:"group","aria-label":m("lists.typeAriaLabel"),children:[jsx(dd,{active:g,disabled:i,title:m("lists.bulletList"),onClick:t,style:u(),children:jsx(j,{name:"format_list_bulleted",size:cd})}),jsx(dd,{active:p,disabled:i,title:m("lists.numberedList"),onClick:o,style:u(),children:jsx(j,{name:"format_list_numbered",size:cd})})]}),s&&jsxs(Fragment,{children:[jsx("div",{style:O3,role:"separator"}),jsxs("div",{style:CT,role:"group","aria-label":m("lists.indentationAriaLabel"),children:[jsx(dd,{active:false,disabled:i||!h,title:m("lists.decreaseIndent"),onClick:n,style:u(),children:jsx(j,{name:"format_indent_decrease",size:cd})}),jsx(dd,{active:false,disabled:i,title:m("lists.increaseIndent"),onClick:r,style:u(),children: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.useMemo(()=>e===void 0?o[0]:o.find(c=>c.twipsValue===e)||o[0],[e,o]),l=Bt.useCallback(c=>{let d=parseInt(c,10);isNaN(d)||t?.(d);},[t]),s=c=>c.labelKey?i(c.labelKey):c.label;return jsxs(Cr,{value:a.twipsValue.toString(),onValueChange:l,disabled:r,children:[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:jsx(gf,{className:"h-5 w-5 shrink-0"})}),jsxs(Sr,{children:[o.map(c=>jsx(Gt,{value:c.twipsValue.toString(),children:s(c)},c.twipsValue)),jsx(dn,{}),jsx(Tr,{children: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.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.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 jsxs(Cr,{value:d,onValueChange:s,disabled:r,children:[jsx(Er,{className:ue("h-8 text-sm",n),style:{width:typeof i=="number"?`${i}px`:i},"aria-label":a("styles.selectAriaLabel"),children:jsx("span",{className:"truncate",children:u})}),jsx(Sr,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsx(Gt,{value:g.styleId,className:"py-2.5 px-3",children: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.useMemo(()=>{let g=o.find(p=>Math.abs(p.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[o,e]),s=Bt.useCallback(g=>{let p=parseFloat(g);isNaN(p)||t?.(p);},[t]),c=Bt.useMemo(()=>[...o].sort((g,p)=>g.value-p.value),[o]),d=Bt.useMemo(()=>[...c].reverse().find(g=>g.value<e-.001),[c,e]),m=Bt.useMemo(()=>c.find(g=>g.value>e+.001),[c,e]),u=i?"h-7 w-7":"h-8 w-8";return jsxs("div",{className:"flex items-center",children:[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:jsx(j,{name:"remove",size:18})}),jsxs(Cr,{value:e.toString(),onValueChange:s,disabled:r,children:[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:jsx(nd,{placeholder:"100%",children:l})}),jsx(Sr,{children:o.map(g=>jsx(Gt,{value:g.value.toString(),children:g.label},g.value))})]}),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: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]=useState(false),i=useCallback(()=>n(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=_t({isOpen:r,onClose:i}),d=useCallback(u=>{e(u),n(false);},[e]),m=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:[jsx(j,{name:"border_all",size:20}),jsx(j,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[r?m:jsx(Vt,{content:o("table.borders.tooltip"),children:m}),r&&!t&&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:jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:2},children:z3.map(({action:u,icon:g,labelKey:p})=>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: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=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 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]=useState(false),{t:n}=L(),i=useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=_t({isOpen:o,onClose:i}),d=useCallback(u=>{e({type:"borderWidth",size:u}),r(false);},[e]),m=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:[jsx(j,{name:"line_weight",size:20}),jsx(j,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:a,style:{position:"relative",display:"inline-block"},children:[o?m:jsx(Vt,{content:n("table.borderWidth"),children:m}),o&&!t&&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})=>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:[jsx("div",{style:{width:50,height:Math.max(p,1),backgroundColor:"#000",borderRadius:p>2?1:0}}),jsx("span",{children:g})]},u))})]})}function LT({onAction:e,disabled:t=false,theme:o,value:r}){let{t:n}=L(),i=useCallback(a=>{typeof a=="string"&&e(a==="none"?{type:"cellFillColor",color:null}:{type:"cellFillColor",color:a.replace(/^#/,"")});},[e]);return jsx("div",{"data-testid":"toolbar-table-cell-fill",style:{display:"inline-block"},children: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]=useState(false),[a,l]=useState(null),s=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=useCallback(y=>{e(y),i(false);},[e]),f=(y,x,b,v,P)=>{let T=t||P?.itemDisabled;return 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:[jsx(j,{name:x,size:16,className:P?.danger&&!T?"text-destructive":""}),jsx("span",{style:{flex:1},children:b})]},y)},h=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:jsx(j,{name:"more_vert",size:20})});return jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[n?h:jsx(Vt,{content:r("table.moreOptions"),children:h}),n&&!t&&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"),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}),jsx("div",{style:bn,role:"separator"}),f("selectTable","select_all",r("table.selectTable"),"selectTable"),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}),jsx("div",{style:bn,role:"separator"}),jsx("div",{style:OT,children:r("tableAdvanced.verticalAlignment")}),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 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:jsx(j,{name:x[y],size:16})},y)})}),jsx("div",{style:bn,role:"separator"}),jsx("div",{style:OT,children:r("tableAdvanced.tableAlignment")}),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 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:jsx(j,{name:x[y],size:16})},y)})}),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"}),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]=useState(false),m=useCallback(()=>d(false),[]),{containerRef:u,dropdownRef:g,dropdownStyle:p,handleMouseDown:f}=_t({isOpen:c,onClose:m}),h=useCallback(x=>{i||n(x),d(false);},[i,n]),y=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:[jsx(j,{name:o,size:Q3}),jsx(j,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:u,style:{position:"relative",display:"inline-block"},children:[c?y:jsx(Vt,{content:r,children:y}),c&&!i&&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: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 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:[jsx(j,{name:x.iconName,size:18}),s&&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 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 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=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?jsx(Vt,{content:o,children:c}):c}function mo({label:e,children:t,className:o}){return 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__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=useRef(null),q=useCallback(ie=>{!c&&n&&n(ie);},[c,n]),G=useCallback(()=>{!c&&l&&i&&i();},[c,l,i]),ce=useCallback(()=>{!c&&s&&a&&a();},[c,s,a]),A=useCallback(ie=>{!c&&n&&n({type:"fontFamily",value:ie});},[c,n]),_=Bt__default.useMemo(()=>qf(h),[h]),ae=useCallback(ie=>{!c&&n&&n({type:"fontSize",value:ie});},[c,n]),fe=useCallback(ie=>{!c&&n&&n({type:"textColor",value:ie});},[c,n]),Z=useCallback(ie=>{!c&&n&&n({type:"highlightColor",value:typeof ie=="string"?ie:""});},[c,n]),de=useCallback(ie=>{!c&&n&&n({type:"alignment",value:ie});},[c,n]),Re=useCallback(()=>{!c&&n&&n("bulletList");},[c,n]),Ae=useCallback(()=>{!c&&n&&n("numberedList");},[c,n]),ft=useCallback(()=>{!c&&n&&n("indent");},[c,n]),ve=useCallback(()=>{!c&&n&&n("outdent");},[c,n]),nt=useCallback(ie=>{!c&&n&&(n({type:"lineSpacing",value:ie}),hostWindowOf(Y.current).requestAnimationFrame(()=>N?.()));},[c,n,N]),Zt=useCallback(ie=>{!c&&n&&n({type:"applyStyle",value:ie});},[c,n]),Nt=useCallback(ie=>{!c&&V&&(V(ie),hostWindowOf(Y.current).requestAnimationFrame(()=>N?.()));},[c,V,N]);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=hostDocumentOf(g?.current??Y.current);return at.addEventListener("keydown",ie),()=>{at.removeEventListener("keydown",ie);}},[u,q,de,g]);let er=useCallback(ie=>{let at=ie.target;at.tagName==="INPUT"||at.tagName==="TEXTAREA"||at.tagName==="SELECT"||at.tagName==="OPTION"||ie.preventDefault();},[]),Mr=useCallback(ie=>{let at=ie.target,Ie=hostDocumentOf(at).activeElement;at.tagName==="SELECT"||at.tagName==="OPTION"||Ie?.tagName==="SELECT"||hostWindowOf(at).requestAnimationFrame(()=>{N?.();});},[N]);return 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:[jsxs(mo,{label:t("formattingBar.groups.history"),children:[jsx(jt,{onClick:G,disabled:c||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsx(j,{name:"undo",size:po})}),jsx(jt,{onClick:ce,disabled:c||!s,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsx(j,{name:"redo",size:po})})]}),w&&jsx(mo,{label:t("formattingBar.groups.zoom"),children:jsx(wT,{value:I,onChange:O,disabled:c,compact:true})}),E&&jsx(mo,{label:t("formattingBar.groups.styles"),children:jsx(PT,{value:r.styleId||"Normal",onChange:Zt,styles:S,theme:k,disabled:c,width:120})}),(f||x)&&jsxs(mo,{label:t("formattingBar.groups.font"),children:[f&&jsx(aT,{value:r.fontFamily||"Arial",onChange:A,fonts:_,documentFonts:y,disabled:c,width:60,placeholder:"Arial"}),x&&jsx(uT,{value:r.fontSize!==void 0?Qp(r.fontSize):11,onChange:ae,disabled:c,width:42,placeholder:"11"})]}),jsxs(mo,{label:t("formattingBar.groups.textFormatting"),children:[jsx(jt,{onClick:()=>q("bold"),active:r.bold,disabled:c,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsx(j,{name:"format_bold",size:po})}),jsx(jt,{onClick:()=>q("italic"),active:r.italic,disabled:c,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsx(j,{name:"format_italic",size:po})}),jsx(jt,{onClick:()=>q("underline"),active:r.underline,disabled:c,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsx(j,{name:"format_underlined",size:po})}),jsx(jt,{onClick:()=>q("strikethrough"),active:r.strike,disabled:c,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsx(j,{name:"strikethrough_s",size:po})}),b&&jsx(mn,{mode:"text",value:r.color?.replace(/^#/,""),onChange:fe,theme:k,disabled:c,title:t("formattingBar.fontColor")}),v&&jsx(mn,{mode:"highlight",value:r.highlight,onChange:Z,theme:k,disabled:c,title:t("formattingBar.highlightColor")}),jsx(jt,{onClick:()=>q("insertLink"),disabled:c,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsx(j,{name:"link",size:po})})]}),jsxs(mo,{label:t("formattingBar.groups.script"),children:[jsx(jt,{onClick:()=>q("superscript"),active:r.superscript,disabled:c,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsx(j,{name:"superscript",size:po})}),jsx(jt,{onClick:()=>q("subscript"),active:r.subscript,disabled:c,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsx(j,{name:"subscript",size:po})})]}),P&&jsx(mo,{label:t("formattingBar.groups.alignment"),children:jsx(vT,{value:r.alignment||"left",onChange:de,disabled:c})}),(T||C)&&jsxs(mo,{label:t("formattingBar.groups.listFormatting"),children:[T&&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&&jsx(ST,{value:r.lineSpacing,onChange:nt,disabled:c})]}),B&&F&&jsxs(mo,{label:t("formattingBar.groups.image"),children:[jsx(ZT,{imageContext:B,onChange:F,disabled:c}),D&&jsx(KT,{onTransform:D,disabled:c}),R&&jsx(jt,{onClick:R,disabled:c,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsx(j,{name:"tune",size:po})})]}),z?.isInTable&&V&&jsxs(mo,{label:t("formattingBar.groups.table"),children:[jsx(MT,{onAction:Nt,disabled:c}),jsx(_T,{onAction:Nt,disabled:c,theme:k,value:Yo(z?.cellBorderColor,k)}),jsx(NT,{onAction:Nt,disabled:c}),jsx(LT,{onAction:Nt,disabled:c,theme:k,value:z?.cellBackgroundColor}),jsx(BT,{onAction:Nt,disabled:c,tableContext:z})]}),jsx(jt,{onClick:()=>q("clearFormatting"),disabled:c,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsx(j,{name:"format_clear",size:po})}),p]})}function dH({children:e,className:t,style:o,...r}){return jsx(hl.Provider,{value:r,children: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=useRef(null),[f,h]=useState(null),[y,x]=useState({}),[b,v]=useState(null),P=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=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}}},[]);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 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:[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:[jsxs(It.TitleBar,{children:[l&&jsx(It.Logo,{children:l()}),jsx(It.DocumentName,{value:r??"Document",editable:false}),s&&jsx(It.TitleBarRight,{children:s()}),jsx(It.MenuBar,{})]}),jsx(It.Toolbar,{})]}),jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[E?jsx("div",{style:{padding:"4px 0"},children:jsx(nn,{pageSetup:E,zoom:C})}):null,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=createContext(null);function GT({children:e}){let t=useMemo(()=>new yd,[]),o=useSyncExternalStore(t.subscribe,t.getSnapshot),r=useCallback((c,d)=>{t.showError(c,d);},[t]),n=useCallback((c,d)=>{t.showWarning(c,d);},[t]),i=useCallback((c,d)=>{t.showInfo(c,d);},[t]),a=useCallback(c=>{t.dismiss(c);},[t]),l=useCallback(()=>{t.clearAll();},[t]),s=useMemo(()=>({notifications:o.notifications,showError:r,showWarning:n,showInfo:i,dismissNotification:a,clearNotifications:l}),[o.notifications,r,n,i,a,l]);return jsxs(CH.Provider,{value:s,children:[e,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: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=>jsx(EH,{notification:n,onDismiss:()=>t(n.id)},n.id))})}function EH({notification:e,onDismiss:t}){let{t:o}=L(),[r,n]=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 jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 6v5M10 13v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "warning":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("path",{d:"M10 3L18 17H2L10 3z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),jsx("path",{d:"M10 8v4M10 14v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});case "info":return jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[jsx("circle",{cx:"10",cy:"10",r:"8",stroke:"currentColor",strokeWidth:"1.5"}),jsx("path",{d:"M10 9v5M10 6v1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}};return jsx("div",{className:`docx-notification-toast docx-notification-${e.severity}`,style:l,children:jsxs("div",{style:s,children:[jsx("span",{style:c,children:p(e.severity)}),jsxs("div",{style:d,children:[jsx("div",{style:m,children:e.message}),e.details&&jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>n(!r),style:{...g,marginTop:"4px",fontSize:"12px",padding:"2px 8px"},children:o(r?"errors.hideDetails":"errors.showDetails")}),r&&jsx("div",{style:u,children:e.details})]})]}),jsx("button",{type:"button",onClick:t,style:g,title:o("common.dismiss"),children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})})}var xd=class extends 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: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 jsxs("div",{className:"docx-error-fallback",style:i,children:[jsx("div",{style:a,children:jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",children:[jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M24 14v12M24 30v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),jsx("h2",{style:l,children:n("errors.somethingWentWrong")}),jsx("p",{style:s,children:n("errors.errorDescription")}),o&&jsxs("div",{style:c,children:[jsx("strong",{children:n("errors.errorLabel")})," ",e.message,t&&jsxs(Fragment,{children:[`
3
3
 
4
- `,jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsx("button",{type:"button",onClick:n,style:d,children:r("errors.tryAgain")})]})}function IT({onClick:e,topPx:t,scrollLeft:o=0,leftOffset:n=ya}){let{t:r}=F();return jsx("button",{className:"docx-outline-toggle",onClick:e,onMouseDown:i=>i.stopPropagation(),title:r("editor.showDocumentOutline"),"aria-label":r("editor.showDocumentOutline"),style:{position:"absolute",left:n-o,top:t,zIndex:xt.outline},children:jsx(G,{name:"format_list_bulleted",size:20})})}function zf({currentPage:e,totalPages:t,visible:o}){let{t:n}=F();return jsx("div",{style:{position:"absolute",right:24,top:"50%",transform:"translateY(-50%)",backgroundColor:"var(--doc-overlay)",color:"#fff",padding:"6px 12px",borderRadius:"4px",fontSize:"12px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontWeight:500,whiteSpace:"nowrap",pointerEvents:"none",zIndex:1e3,opacity:o?1:0,transition:"opacity 0.3s ease",userSelect:"none"},"aria-live":"polite",role:"status",children:n("viewer.pageIndicator",{current:e,total:t})})}function z3({i18n:e,isDark:t,onEditorError:o,containerRef:n,scrollContainerRef:r,editorContentRef:i,className:a,containerStyle:l,mainContentStyle:s,editorContainerStyle:c,showRuler:d,readOnlyProp:m,showOutline:u,showOutlineButton:g,sidebarOpen:p,minLayoutWidth:f,toolbarHeight:h,editorScrollLeft:v,onScrollContainerMouseDown:b,onEditorBgMouseDown:y,onEditorContextMenu:C,horizontalRulerProps:T,verticalRulerProps:x,outlineProps:E,onToggleOutline:P,scrollPageInfo:k,toolbar:w,pagedArea:D,overlays:M,dialogs:H,fileInputs:I}){let A=d&&!m;return jsx(Gn.Provider,{value:true,children:jsx(yr,{i18n:e,children:jsx(RT,{children:jsx(sd,{onError:o,children:jsxs("div",{ref:n,className:ue("docx-editor",t&&"dark",a),style:l,"data-testid":"docx-editor",children:[jsx("div",{style:s,children:jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[w,jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:c,onMouseDown:b,children:[d&&jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:xt.ruler,paddingLeft:20,paddingRight:20+(p?352:0),minWidth:f,transition:"padding 0.2s ease"},children:jsx(nr,{...T})}),jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:f},children:jsxs("div",{ref:i,style:{position:"relative",flex:1,minWidth:0},onMouseDown:y,onContextMenu:C,children:[A&&jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:xt.ruler,paddingTop:48},children:jsx(ji,{...x})}),D]})})]}),k.totalPages>1&&jsx(zf,{currentPage:k.currentPage,totalPages:k.totalPages,visible:k.visible}),u&&jsx(Xi,{...E,leftOffset:Yi+(A?ha:0)}),g&&!u&&jsx(IT,{onClick:P,topPx:h+(d?Xm+8:0)+48,scrollLeft:v,leftOffset:ya+(A?ha:0)})]})}),M,H,I]})})})})})}function J3(e){let[t,o]=useState(0);return useEffect(()=>{if(!e)return;let n=()=>o(a=>a+1),r=e.on("change",n),i=e.on("selectionChange",n);return n(),()=>{r(),i();}},[e]),t}function rH({kind:e}){let t=L(),[o,n]=useState(null),r=useRef(null);useLayoutEffect(()=>{if(!t||!o)return;let a=bindHistoryGroup(t,o,{kind:e});return r.current=a,()=>{a.dispose(),r.current=null;}},[t,o,e]);let i=useCallback(()=>{if(!r.current)throw new Error("history group control is not mounted");return r.current.options()},[]);return {ref:n,options:i}}export{Pt as CONTENT_CONTROL_SLOTS,Vn as ContextMenuCellVerticalAlignment,ei as ContextMenuCopy,ls as ContextMenuCopyFormatting,Qa as ContextMenuCut,ti as ContextMenuDelete,Yr as ContextMenuDeleteTable,jr as ContextMenuDeleteTableColumn,Gr as ContextMenuDeleteTableRow,Ur as ContextMenuInsertColumnLeft,zr as ContextMenuInsertColumnRight,Kr as ContextMenuInsertRowAbove,qr as ContextMenuInsertRowBelow,cs as ContextMenuItem,$r as ContextMenuMergeCells,Wr as ContextMenuPaste,ss as ContextMenuPasteFormatting,Zr as ContextMenuPasteWithoutFormatting,Xr as ContextMenuRefreshToc,Jr as ContextMenuRefreshTocPageNumbers,oi as ContextMenuSelectAll,Vr as ContextMenuSplitCell,_u as DEFAULT_WATERMARK_PRESETS,wf as DocumentName,Xi as DocumentOutline,VF as DocxEditor,qp as DocxEditorAuthorStyle,ja as DocxEditorBookmarkDialog,Kp as DocxEditorColorByChangeType,Ms as DocxEditorContent,Oa as DocxEditorContentControl,Ip as DocxEditorContentControlWidget,ii as DocxEditorContextMenu,af as DocxEditorDocumentOutline,Ba as DocxEditorEquation,Ma as DocxEditorExportDialog,Oc as DocxEditorFontNotice,Wc as DocxEditorHeaderFooterChrome,kc as DocxEditorHorizontalRuler,La as DocxEditorHyperLink,Cs as DocxEditorImageAltTextPopup,du as DocxEditorImageInsertErrorDialog,ci as DocxEditorImagePropertiesDialog,dp as DocxEditorInvalidTextFormFieldDialog,Is as DocxEditorLoading,Zp as DocxEditorLoadingSpinner,$i as DocxEditorMenu,ff as DocxEditorNavigation,Cr as DocxEditorNotePreview,gs as DocxEditorNotePropertiesDialog,fs as DocxEditorNotesChrome,Tr as DocxEditorNotesContextMenu,Bc as DocxEditorOpenFailure,bf as DocxEditorOpenFailureAction,Ac as DocxEditorPageNumber,Un as DocxEditorPageSetupDialog,Zo as DocxEditorParagraphDialog,_a as DocxEditorPrintDialog,Hd as DocxEditorRevisionMarkup,Ra as DocxEditorRevisionMarkupDialog,hi as DocxEditorRoot,z3 as DocxEditorShell,Ya as DocxEditorSplitCellDialog,Ja as DocxEditorTextFormFieldDialog,Ki as DocxEditorToolbar,dd as DocxEditorUnsupportedElement,wc as DocxEditorVerticalRuler,Hs as DocxEditorViewport,zn as DocxEditorWatermarkDialog,Bp as DocxEditorWindow,nr as HorizontalRuler,vs as ImageAltText,Wl as ImageInsertProvider,Zl as ImageInsertTrigger,xs as ImagePropertiesTrigger,$s as ImageWrap,yr as LocaleProvider,qc as Logo,zc as MenuBar,Mv as NAVIGATION_PANE_GAP,Rc as NAVIGATION_PANE_INSET,sf as NAVIGATION_PANE_MIN_PAGE_ROOM,va as NAVIGATION_PANE_WIDTH,nl as NavigationClose,sl as NavigationFind,Ji as NavigationGoTo,ol as NavigationHeader,ll as NavigationHeadings,il as NavigationTab,al as NavigationTabs,rl as NavigationTitle,cl as NavigationToggle,ya as OUTLINE_BUTTON_LEFT_OFFSET,V5 as OUTLINE_BUTTON_RESERVED_SPACE,Yi as OUTLINE_LEFT_OFFSET,z5 as OUTLINE_RESERVED_SPACE,zf as PageIndicator,Hc as PageNumberTranslationContext,Tf as PaginatedDocxEditor,F3 as PaginatedDocxEditorShell,aa as REVIEW_MARKERS_GUTTER,yi as REVIEW_PANE_GUTTER,ha as RULER_WIDTH,Nt as ReviewRailContext,X as Slot,Df as TitleBar,Uc as TitleBarRight,qf as Toolbar,$t as ToolbarButton,Ln as ToolbarContext,lo as ToolbarGroup,ea as ToolbarImageProperties,LT as VERSION,ji as VerticalRuler,LS as definePopup,rE as editorStateActiveSubscriptionCount,Na as isFieldLink,_c as navigationPaneOverlays,Ca as navigationPaneReservation,Mc as navigationShift,Ol as normalizeImageBytes,tg as notificationYieldsToTask,IM as provideDocxEditor,R0 as reviewGutter,Hw as useBookmarkDialog,qu as useBookmarks,at as useChromeDir,Jf as useChromeTranslate,fL as useCommentDraftRequest,bo as useContentControl,Il as useContentControlInstance,st as useContentControlWidget,gb as useContextMenuTarget,Ic as useDocumentOutline,Nc as useDocumentSearch,L as useDocxEditor,tL as useDocxSource,dL as useEditorCaret,se as useEditorCommand,Rm as useEditorEvent,Zm as useEditorHostDocument,J3 as useEditorSnapshot,K as useEditorState,di as useEditorValueCommand,Js as useFontFamily,iL as useFonts,Dc as useGoToBookmark,yf as useHeaderFooterState,PL as useHighlightAt,yL as useHighlights,rH as useHistoryGroup,Wd as useHyperlinkPopup,Ml as useHyperlinkPopupInstance,Fc as useNavigationPane,Fn as useNavigationShift,Ju as useNotePropertiesState,Xu as useNoteScopeState,cC as useOpenFailure,qn as usePageSetup,Qk as usePageSetupDialog,pw as useParagraphDialog,Du as useParagraphFormat,Qm as useParagraphIndent,Qs as useParagraphStyle,Ci as useReviewAuthors,fn as useReviewGutter,PS as useRevisionMarkupDialog,Lt as useScopeClassName,li as useScopedChromeAnchor,Vw as useSplitCellDialog,Dx as useTableBorderTargetLabel,eD as useTextFormFieldDialog,AE as useToolbarContext,ne as useToolbarLabel,Sl as useToolbarLabelFor,F as useTranslation,Bu as useWatermark,Jb as useWatermarkDialog,pm as useZoom};
4
+ `,jsx("strong",{children:n("errors.componentStack")}),t.componentStack]})]}),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 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:jsx(j,{name:"format_list_bulleted",size:20})})}function og({currentPage:e,totalPages:t,visible:o}){let{t:r}=L();return 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 jsx(Ao.Provider,{value:true,children:jsx(vn,{i18n:e,children:jsx(GT,{children:jsx(xd,{onError:o,children:jsxs("div",{ref:r,className:ue("docx-editor",t&&"dark",a),style:l,"data-testid":"docx-editor",children:[jsx("div",{style:s,children:jsxs("div",{style:{position:"relative",flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column"},children:[k,jsxs("div",{ref:n,className:"docx-editor__scroll-container",style:c,onMouseDown:x,children:[d&&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:jsx(nn,{...P})}),jsx("div",{style:{display:"flex",flex:1,minHeight:0,position:"relative",minWidth:f},children:jsxs("div",{ref:i,style:{position:"relative",flex:1,minWidth:0},onMouseDown:b,onContextMenu:v,children:[B&&jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:vt.ruler,paddingTop:48},children:jsx(el,{...T})}),w]})})]}),S.totalPages>1&&jsx(og,{currentPage:S.currentPage,totalPages:S.totalPages,visible:S.visible}),u&&jsx(ol,{...C,leftOffset:tl+(B?va:0)}),g&&!u&&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]=useState(0);return 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]=useState(null),n=useRef(null);useLayoutEffect(()=>{if(!t||!o)return;let a=bindHistoryGroup(t,o,{kind:e});return n.current=a,()=>{a.dispose(),n.current=null;}},[t,o,e]);let i=useCallback(()=>{if(!n.current)throw new Error("history group control is not mounted");return n.current.options()},[]);return {ref:r,options:i}}export{wt as CONTENT_CONTROL_SLOTS,$r as ContextMenuCellVerticalAlignment,ai as ContextMenuCopy,fs as ContextMenuCopyFormatting,ni as ContextMenuCut,ii as ContextMenuDelete,oa as ContextMenuDeleteTable,ta as ContextMenuDeleteTableColumn,ea as ContextMenuDeleteTableRow,Yn as ContextMenuInsertColumnLeft,Xn as ContextMenuInsertColumnRight,Gn as ContextMenuInsertRowAbove,jn as ContextMenuInsertRowBelow,bs as ContextMenuItem,Jn as ContextMenuMergeCells,zn as ContextMenuPaste,gs as ContextMenuPasteFormatting,$n as ContextMenuPasteWithoutFormatting,ra as ContextMenuRefreshToc,na as ContextMenuRefreshTocPageNumbers,aa as ContextMenuRemoveToc,li as ContextMenuSelectAll,Vn as ContextMenuSelectTable,Qn as ContextMenuSplitCell,qu as DEFAULT_WATERMARK_PRESETS,Of as DocumentName,ol as DocumentOutline,wL as DocxEditor,om as DocxEditorAuthorStyle,ei as DocxEditorBookmarkDialog,tm as DocxEditorColorByChangeType,Os as DocxEditorContent,Ua as DocxEditorContentControl,zp as DocxEditorContentControlWidget,ui as DocxEditorContextMenu,hf as DocxEditorDocumentOutline,za as DocxEditorEquation,Na as DocxEditorExportDialog,jc as DocxEditorFontNotice,Xc as DocxEditorHeaderFooterChrome,Ac as DocxEditorHorizontalRuler,Za as DocxEditorHyperLink,Rs as DocxEditorImageAltTextPopup,Tu as DocxEditorImageInsertErrorDialog,fi as DocxEditorImagePropertiesDialog,Ep as DocxEditorInvalidTextFormFieldDialog,Ws as DocxEditorLoading,em as DocxEditorLoadingSpinner,Xi as DocxEditorMenu,Pf as DocxEditorNavigation,En as DocxEditorNotePreview,Ts as DocxEditorNotePropertiesDialog,Cs as DocxEditorNotesChrome,Sn as DocxEditorNotesContextMenu,Yc as DocxEditorOpenFailure,wf as DocxEditorOpenFailureAction,Gc as DocxEditorPageNumber,qr as DocxEditorPageSetupDialog,qo as DocxEditorParagraphDialog,Fa as DocxEditorPrintDialog,Vd as DocxEditorRevisionMarkup,Ia as DocxEditorRevisionMarkupDialog,Ti as DocxEditorRoot,kH as DocxEditorShell,ti as DocxEditorSplitCellDialog,ri as DocxEditorTextFormFieldDialog,Vi as DocxEditorToolbar,Cd as DocxEditorUnsupportedElement,Oc as DocxEditorVerticalRuler,Us as DocxEditorViewport,Ur as DocxEditorWatermarkDialog,Jp as DocxEditorWindow,nn as HorizontalRuler,Ds as ImageAltText,$l as ImageInsertProvider,Vl as ImageInsertTrigger,ws as ImagePropertiesTrigger,ec as ImageWrap,vn as LocaleProvider,ed as Logo,od as MenuBar,Yv as NAVIGATION_PANE_GAP,Wc as NAVIGATION_PANE_INSET,xf as NAVIGATION_PANE_MIN_PAGE_ROOM,Ea as NAVIGATION_PANE_WIDTH,sl as NavigationClose,ml as NavigationFind,rl as NavigationGoTo,ll as NavigationHeader,pl as NavigationHeadings,ul as NavigationTab,dl as NavigationTabs,cl as NavigationTitle,fl as NavigationToggle,Ca as OUTLINE_BUTTON_LEFT_OFFSET,R6 as OUTLINE_BUTTON_RESERVED_SPACE,tl as OUTLINE_LEFT_OFFSET,w6 as OUTLINE_RESERVED_SPACE,og as PageIndicator,Vc as PageNumberTranslationContext,Nf as PaginatedDocxEditor,gH as PaginatedDocxEditorShell,da as REVIEW_MARKERS_GUTTER,Ei as REVIEW_PANE_GUTTER,va as RULER_WIDTH,Lt as ReviewRailContext,J as Slot,Bf as TitleBar,td as TitleBarRight,eg as Toolbar,jt as ToolbarButton,Hr as ToolbarContext,mo as ToolbarGroup,ia as ToolbarImageProperties,eE as VERSION,el as VerticalRuler,lP as definePopup,EE as editorStateActiveSubscriptionCount,Oa as isFieldLink,Kc as navigationPaneOverlays,Sa as navigationPaneReservation,Zc as navigationShift,Ul as normalizeImageBytes,pg as notificationYieldsToTask,u1 as provideDocxEditor,j0 as reviewGutter,hD as useBookmarkDialog,tp as useBookmarks,it as useChromeDir,cg as useChromeTranslate,GL as useCommentDraftRequest,vo as useContentControl,Ol as useContentControlInstance,st as useContentControlWidget,Bb as useContextMenuTarget,qc as useDocumentOutline,Uc as useDocumentSearch,H as useDocxEditor,LL as useDocxSource,UL as useEditorCaret,NE as useEditorColorMode,oe as useEditorCommand,Zm as useEditorEvent,Jm as useEditorHostDocument,NH as useEditorSnapshot,W as useEditorState,gi as useEditorValueCommand,ic as useFontFamily,WL as useFonts,Bc as useGoToBookmark,Rf as useHeaderFooterState,a4 as useHighlightAt,JL as useHighlights,BH as useHistoryGroup,xP as useHyperlinkPopup,Hl as useHyperlinkPopupInstance,zc as useNavigationPane,Lr as useNavigationShift,pp as useNotePropertiesState,up as useNoteScopeState,RC as useOpenFailure,Kr as usePageSetup,Fw as usePageSetupDialog,Vw as useParagraphDialog,Wu as useParagraphFormat,uf as useParagraphIndent,sc as useParagraphStyle,ki as useReviewAuthors,fr as useReviewGutter,XS as useRevisionMarkupDialog,RE as useScopeClassName,pi as useScopedChromeAnchor,DD as useSplitCellDialog,jx as useTableBorderTargetLabel,LD as useTextFormFieldDialog,cS as useToolbarContext,ne as useToolbarLabel,_l as useToolbarLabelFor,L as useTranslation,Xu as useWatermark,Th as useWatermarkDialog,Sm as useZoom};