@docx-editor.dev/react 2.35.0-canary.20261104032723.sha-43c2012 → 2.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -12
- package/dist/index.d.mts +96 -5
- package/dist/index.d.ts +96 -5
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/docs/accept-reject-without-scrolling.md +22 -38
- package/docs/comment-on-found-text.md +38 -19
- package/docs/custom-review-cards.md +39 -25
- package/docs/highlight-ranges.md +25 -4
- package/docs/index.md +21 -21
- package/docs/propose-rewrite.md +87 -138
- package/docs/tracked-replacement.md +36 -18
- package/package.json +3 -3
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,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.35.0-canary.20261104032723.sha-43c2012"};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:[`
|
|
1
|
+
import*as Zt from'react';import Zt__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,focusCompareDocumentsControl,COMPARE_DOCUMENTS_ACCEPT,COMPARE_DOCUMENTS_PHASE_ATTRIBUTE,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,initialChromePrintSettings,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,CHROME_PRINT_DISPLAY_MODES,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,compareDocumentsErrorKey,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 Ae from'@radix-ui/react-select';export{EditorFontError}from'@docx-editor.dev/core/contracts/editor';var mg={version:"2.35.0"};var fE=mg.version;function fg(){let e=new Map,t=new Map,o=new Set,n=0,r=0,i=null,a=[],l,s=false,c=()=>[...e].sort((u,g)=>t.get(u[0])-t.get(g[0])),d=()=>{r++;for(let u of o)u();},m=()=>{d(),!s&&(s=true,queueMicrotask(()=>{s=false,i?.setUnsupportedElementRules(c().map(([,u])=>u));}));};return {register(u,g){t.has(u)||t.set(u,n++),e.set(u,g),m();},unregister(u){e.delete(u)&&m();},connect(u){i=u,u&&m();},current:()=>c().map(([,u])=>u),setContainer(u){l?.();for(let g of a)g.setCustomized(false);a=[],l=u?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 Rr=createContext(null);function gg(e){return Children.toArray(e).some(t=>isValidElement(t)&&t.type===Fragment$1?gg(t.props.children):typeof t!="string"||t.trim().length>0)}function bg({host:e,children:t}){let o=gg(t);return useLayoutEffect(()=>(e.setCustomized(o),()=>{e.setCustomized(false);}),[e,o]),o?createPortal(t,e.slot):null}function Fd({match:e,layout:t,includePartial:o,children:n}){let r=useContext(Rr);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(bg,{host:a,children:n({element:a.unsupported})},a.key))}var Ld=createContext(en),Hd=createContext("en"),Ad=createContext("ltr"),Od=createContext(void 0);function Mr({i18n:e,dir:t,children:o}){let n=useContext(Ld),r=useContext(Hd),i=useContext(Ad),a=useContext(Od),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(Hd.Provider,{value:l,children:jsx(Ad.Provider,{value:c,children:jsx(Od.Provider,{value:s,children:jsx(Ld.Provider,{value:d,children:o})})})})}function H(){let e=useContext(Ld),t=useContext(Hd),o=useContext(Ad);return {t:useMemo(()=>createT(e,t),[e,t]),catalogue:e,lang:t,dir:o}}function lt(){return useContext(Od)}function xg(e){let{t}=H();return useCallback((o,n)=>e?.get(o)??t(o,n),[e,t])}var Bd=createContext(null);function A(){return useContext(Bd)}function Wl(e){return (e?.mounted??0)+(e?.gutters??0)>0}var At=createContext(null);var Wd=0,Zd=false,Kd=false,Zl=[],Kl=null;function Cg(e){if(typeof MessageChannel!="function"){globalThis.setTimeout(e,0);return}Kl||(Kl=new MessageChannel,Kl.port1.onmessage=()=>{let t=Zl;Zl=[];for(let o of t)try{o();}catch(n){queueMicrotask(()=>{throw n});}}),Zl.push(e),Zl.length===1&&Kl.port2.postMessage(null);}function Tg(){let e=globalThis.navigator?.scheduling;return typeof e?.isInputPending!="function"?false:e.isInputPending({includeContinuous:true})?true:(Zd||(Zd=true,Wd+=1,queueMicrotask(()=>{Zd=false;}),Kd||(Kd=true,Cg(()=>{Kd=false,Wd=0;}))),Wd>16)}function Eg(e){let t=false;return ()=>{if(t)return;t=true;let o=()=>{t=false,e();};Tg()?Cg(o):queueMicrotask(o);}}var HE=()=>{},Ud=0;function AE(){return Ud}function Za(e){return Eg(e)}function W(e,t=Object.is,o){let n=A(),r=o?.onSubscribe,i=o?.onUnsubscribe,a=useCallback(d=>{if(!n)return HE;let m=false;Ud++,r?.();let u=Za(()=>{m||d();}),g=[n.on("change",u),n.on("selectionChange",u),n.on("error",u)];return ()=>{m=true,Ud--,i?.();for(let p of g)p();}},[n,r,i]),l=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 ZE(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function KE(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=ZE(t[n],e[n]):n==="className"?o[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(o[n]={...e[n],...t[n]});return o}function Q({children:e,...t}){let o=Children.only(e);if(!isValidElement(o))return null;let n=o.props,r=KE(t,n),i=o.ref,a=t.ref;return (i||a)&&(r.ref=l=>{for(let s of [i,a])typeof s=="function"?s(l):s&&typeof s=="object"&&(s.current=l);}),cloneElement(o,r)}var Sg="(prefers-color-scheme: dark)";function Pg(){return typeof globalThis.window<"u"&&typeof globalThis.window.matchMedia=="function"}function kg(){return Pg()?globalThis.window.matchMedia(Sg).matches:false}function wg(e,t){return e==="dark"||e==="system"&&t}function Dg(e){if(!Pg())return ()=>{};let t=globalThis.window.matchMedia(Sg);e(t.matches);let o=n=>e(n.matches);return t.addEventListener("change",o),()=>t.removeEventListener("change",o)}var Wo=createContext(false),qn=createContext(false);function qE(){let e=useContext(Wo),t=useContext(qn);return e?"":t?"docx-editor dark ":"docx-editor "}function Ul(e){let t=e==="system",o=useSyncExternalStore(t?$E:zE,t?kg:_g,_g);return wg(e??"light",o)}function $E(e){return Dg(()=>e())}function zE(){return ()=>{}}function _g(){return false}function Ut(){return useContext(qn)}function $t(){let e=useContext(Wo),t=useContext(qn);return e?"":t?"docx-editor dark ":"docx-editor "}function VE(){return useContext(qn)?jE:GE}var GE=Object.freeze({colorMode:"light"}),jE=Object.freeze({colorMode:"dark"});var Fg=e=>{let t=e["data-docx-part"];return typeof t=="string"?t==="field"?`field:${e["data-docx-field"]}`:t:null};function yt(){let e=createContext(null),t=new Map,o=y=>{let v=t.get(y.type);return v==="field"?`field:${y.props.name}`:v};function n(y,v){Children.forEach(y,x=>{isValidElement(x)&&(v(x),n(x.props.children,v));});}function r(){let y=useContext(e);if(!y)throw new globalThis.Error("Dialog controls must be rendered inside their dialog.");return y.state}function i(y,v){return Children.map(y,x=>{if(!isValidElement(x))return x;let h=Fg(x.props);return h&&v.has(h)?v.get(h):x.props.children===void 0?x:cloneElement(x,{children:i(x.props.children,v)})})}function a(y){function v(x){let h=useContext(e);if(!h||x.hidden)return null;let k=y==="field"?`field:${x.name}`:y,E=h.defaults.get(k);if(!E)return x.children??null;let{children:C,asChild:T,className:S,style:P,hidden:w,name:_,...L}=x,N={...L,...E.props,className:[E.props.className,S].filter(Boolean).join(" "),style:{...E.props.style,...P}};if(T){let{children:B,className:F,style:D,...R}=N;return jsx(Q,{...R,...S?{className:S}:{},...P?{style:P}:{},children:C})}return cloneElement(E,N,C===void 0?i(E.props.children,h.overrides):C)}return t.set(v,y),v}let l=a("header"),s=a("title"),c=a("body"),d=a("footer"),m=a("apply"),u=a("cancel"),g=a("reset"),p=a("error"),f=a("field");function b({defaults:y,children:v,preset:x=true,state:h}){let k=new Map;n(y,S=>{let P=Fg(S.props);P&&k.set(P,S);});let E=new Map;n(v,S=>{let P=o(S);P&&E.set(P,S);});let C=S=>Children.toArray(S).flatMap(P=>isValidElement(P)&&P.type===Fragment$1?C(P.props.children):[P]),T=C(v).filter(S=>!isValidElement(S)||!o(S));return jsx(e.Provider,{value:{defaults:k,overrides:E,state:h},children:x?jsxs(Fragment,{children:[i(y,E),T]}):v})}return {Header:l,Title:s,Body:c,Footer:d,Apply:m,Cancel:u,Reset:g,Error:p,Field:f,Composition:b,useState:r,part:y=>a(y)}}function Fe({kind:e,role:t="dialog",className:o,style:n,label:r,onClose:i,onKeyDown:a,panelRef:l,children:s,dismissOutside:c=true,sessionSignal:d,restoreFocus:m=true,describedBy:u,busy:g}){let p=useRef(null),f=l??p,b=useRef(i);b.current=i;let[y,v]=useState(false),x=Ut();return useLayoutEffect(()=>{let h=f.current;if(!h)return;v(!h.parentElement?.closest(".docx-editor"));let k=h.ownerDocument.activeElement,E=k===h.ownerDocument.body?null:k,C=()=>{h.open&&h.close?.();};return d?.addEventListener("abort",C),typeof h.showModal=="function"?h.showModal():h.setAttribute("open",""),(h.querySelector('input:not([disabled]),select:not([disabled]),button:not([disabled]),[tabindex="0"]')??h.querySelector("a[href]"))?.focus({preventScroll:true}),()=>{d?.removeEventListener("abort",C),typeof h.close=="function"&&h.open&&h.close(),m&&E?.isConnected&&E.focus({preventScroll:true});}},[f,d,m]),jsx("dialog",{ref:f,role:t,"aria-modal":"true","aria-label":r,"aria-describedby":u,"data-docx-busy":g?"":void 0,className:`docx-dialog${y?` docx-editor${x?" dark":""}`:""}${o?` ${o}`:""}`,style:n,"data-docx-dialog":e,onCancel:h=>{h.preventDefault(),b.current();},onMouseDown:h=>h.stopPropagation(),onClick:h=>{if(c&&h.target===h.currentTarget){let k=h.currentTarget.getBoundingClientRect();(h.clientX<k.left||h.clientX>k.right||h.clientY<k.top||h.clientY>k.bottom)&&b.current();}h.stopPropagation();},onKeyDown:h=>{h.key==="Escape"&&!h.nativeEvent.isComposing?(h.preventDefault(),b.current()):trapTabWithin(h.currentTarget,h.nativeEvent)?h.preventDefault():!h.nativeEvent.isComposing&&!h.defaultPrevented&&a?.(h),h.stopPropagation();},children:s})}function Co(e,t){let o=A(),n=Gd(),r=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 Gd(){let e=A(),t=useCallback(o=>{if(!e)return ()=>{};let n=true,r=Za(()=>{n&&o();}),i=[e.on("change",r),e.on("selectionChange",r),e.on("error",r)];return ()=>{n=false,i.forEach(a=>a());}},[e]);return useSyncExternalStore(t,()=>e?.mountGeneration??0,()=>0)}function Lg(){let e=0,t=0,o=null,n=new Set,r=new Set,i=new Set,a=l=>{for(let s of [...l])s();};return {getShift:()=>e,setShift(l){let s=Math.max(0,Math.round(l));s!==e&&(e=s,a(n));},subscribeShift(l){return n.add(l),()=>n.delete(l)},getReservation:()=>t,setReservation(l){let s=Math.max(0,Math.round(l));s!==t&&(t=s,a(r));},subscribeReservation(l){return r.add(l),()=>r.delete(l)},getViewport:()=>o,setViewport(l){l!==o&&(o=l,a(i));},subscribeViewport(l){return i.add(l),()=>i.delete(l)}}}var Yd=createContext(null);function $n(){return useContext(Yd)}var Hg=()=>0,Xd=()=>()=>{};function zn(){let e=$n(),t=useCallback(n=>e?e.subscribeShift(n):Xd(),[e]),o=useCallback(()=>e?e.getShift():0,[e]);return useSyncExternalStore(t,o,Hg)}function Ag(){let e=$n(),t=useCallback(n=>e?e.subscribeReservation(n):Xd(),[e]),o=useCallback(()=>e?e.getReservation():0,[e]);return useSyncExternalStore(t,o,Hg)}function we(){let e=$n(),t=useCallback(r=>e?e.subscribeViewport(r):Xd(),[e]),o=useCallback(()=>e?e.getViewport():null,[e]),n=useCallback(()=>null,[]);return useSyncExternalStore(t,o,n)}function Zo(e,t,o){let n=we(),r=useRef({close:o,viewport:n});r.current={close:o,viewport:n},useEffect(()=>{let i=e.current;if(!(!t||!i))return fS(i,()=>r.current.close(),()=>r.current.viewport)},[e,t]);}function fS(e,t,o){let n=l=>{if(l.defaultPrevented||l.altKey||l.ctrlKey||l.metaKey)return;let s=l.target;if(s.matches('input[role="combobox"]')||s.matches("input, textarea, select")&&l.key!=="ArrowDown"&&l.key!=="ArrowUp")return;let d=Array.from(e.querySelectorAll('[role="option"]')).filter(g=>!g.matches(':disabled, [aria-disabled="true"]'));if(d.length===0)return;let m=d.indexOf(s),u;if(l.key==="Home")u=0;else if(l.key==="End")u=d.length-1;else if(l.key==="ArrowDown")u=(m+1)%d.length;else if(l.key==="ArrowUp")u=m<0?d.length-1:(m-1+d.length)%d.length;else return;l.preventDefault(),l.stopPropagation(),d[u]?.focus();},r=l=>{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 CS(e,t){return e.active===t.active&&e.enabled===t.enabled&&e.disabledReason===t.disabledReason&&e.value===t.value}function Jd(e){return typeof e=="string"}function re(e){let t=A(),{t:o}=H(),n=Jd(e)?e:editorCommandKey(e),r=useRef(e);r.current=e;let i=useCallback(s=>{let c=r.current;if(Jd(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=W(i,CS),l=useCallback(s=>{let c=commandExecOptions(s),d=r.current;return Jd(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 Vn=createContext({t:void 0,onSave:void 0});function ES(){return useContext(Vn)}function zl(e){let{t}=H();return o=>e?.(o)??t(o)}function ae(){let{t:e}=useContext(Vn);return zl(e)}var wS=()=>()=>{},DS=()=>true,RS=()=>false;function eo(){let e=useSyncExternalStore(wS,DS,RS);return useCallback(t=>e?platformShortcut(t):t,[e])}function MS(e){let t=e.viteEnv?.DEV;return typeof t=="boolean"?t:e.hasProcess&&e.nodeEnv!=="production"}function _S(){try{return import.meta.env}catch{return}}function xt(){let e=typeof process<"u";return MS({viteEnv:_S(),nodeEnv:e?"production":void 0,hasProcess:e})}var Zg=new Set;function un(e){!xt()||Zg.has(e)||(Zg.add(e),console.warn(`[docx-editor] ${e}`));}function Kg(e){un(`Menu.Item and ContextMenu.Slot take the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function qg(e){un(`A hidden context-menu override names "${e}", but no packaged row has that id, so nothing is removed.`);}function Ug(){un("A Menu.Item or ContextMenu.Slot has no slotId, so it renders nothing.");}function $g(){un("A Menu.Submenu has neither label nor labelKey, so its row has no name.");}function zg(e){un(`Toolbar.Button takes the slot id as slotId. slot="${e}" still works in this release; write slotId="${e}".`);}function Vg(){un("A Toolbar.Button has no slotId, so it renders nothing.");}function te(e){for(let t of CHROME_GROUPS)for(let o of t.controls)if(chromeSlotId(t,o)===e)return o;return null}function oe(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 $(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function LS(e){if(e.slotId)return e.slotId;if(e.slot)return zg(e.slot),e.slot;Vg();}function Ko(e){let{icon:t,asChild:o,className:n,children:r,hidden:i}=e,a=LS(e)??"",{execute:l,isActive:s,isEnabled:c,disabledReason:d,value:m}=re(a),u=ae(),g=eo();if(i||!a)return null;let p=te(a),f=g(u(p?.labelKey??a)),b=chromeSlotIsToggle(a),y={onClick:()=>l(),onMouseDown:$,disabled:!c,"data-slot":a,className:`docx-toolbar__button${n?` ${n}`:""}`,...s?{"data-active":""}:{},...c?{}:{"data-disabled":""},...b?{"aria-pressed":s}:{},...m!==null?{"data-value":m}:{},"aria-label":f,title:d??f};return o?jsx(Q,{...y,children:r}):jsx("button",{type:"button",...y,children:t??r??oe(p?.paths)})}Ko.docxToolbarPart=true;var KS=[{value:"C00000",labelKey:"colorPicker.colors.darkRed",css:"#c00000"},{value:"FF0000",labelKey:"colorPicker.colors.red",css:"#ff0000"},{value:"FFC000",labelKey:"colorPicker.colors.orange",css:"#ffc000"},{value:"FFFF00",labelKey:"colorPicker.colors.yellow",css:"#ffff00"},{value:"92D050",labelKey:"colorPicker.colors.lightGreen",css:"#92d050"},{value:"00B050",labelKey:"colorPicker.colors.green",css:"#00b050"},{value:"00B0F0",labelKey:"colorPicker.colors.lightBlue",css:"#00b0f0"},{value:"0070C0",labelKey:"colorPicker.colors.blue",css:"#0070c0"},{value:"002060",labelKey:"colorPicker.colors.darkBlue",css:"#002060"},{value:"7030A0",labelKey:"colorPicker.colors.purple",css:"#7030a0"}],Gg=[{value:"yellow",labelKey:"colorPicker.colors.yellow",css:"#ffff00"},{value:"green",labelKey:"colorPicker.colors.brightGreen",css:"#00ff00"},{value:"cyan",labelKey:"colorPicker.colors.cyan",css:"#00ffff"},{value:"magenta",labelKey:"colorPicker.colors.magenta",css:"#ff00ff"},{value:"blue",labelKey:"colorPicker.colors.blue",css:"#0000ff"},{value:"red",labelKey:"colorPicker.colors.red",css:"#ff0000"},{value:"darkBlue",labelKey:"colorPicker.colors.darkBlue",css:"#000080"},{value:"darkCyan",labelKey:"colorPicker.colors.darkCyan",css:"#008080"},{value:"darkGreen",labelKey:"colorPicker.colors.darkGreen",css:"#008000"},{value:"darkMagenta",labelKey:"colorPicker.colors.darkMagenta",css:"#800080"},{value:"darkRed",labelKey:"colorPicker.colors.darkRed",css:"#800000"},{value:"darkYellow",labelKey:"colorPicker.colors.darkYellow",css:"#808000"},{value:"darkGray",labelKey:"colorPicker.colors.darkGray",css:"#808080"},{value:"lightGray",labelKey:"colorPicker.colors.lightGray",css:"#c0c0c0"},{value:"black",labelKey:"colorPicker.colors.black",css:"#000000"},{value:"white",labelKey:"colorPicker.colors.white",css:"#ffffff"}],jg=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],Gl=["colorPicker.theme.background1","colorPicker.theme.text1","colorPicker.theme.background2","colorPicker.theme.text2","colorPicker.theme.accent1","colorPicker.theme.accent2","colorPicker.theme.accent3","colorPicker.theme.accent4","colorPicker.theme.accent5","colorPicker.theme.accent6"],pn=e=>({labelKey:`colorPicker.theme.lighter${e}`,apply:t=>t+(255-t)*(e/100)}),zt=e=>({labelKey:`colorPicker.theme.darker${e}`,apply:t=>t*(1-e/100)});function qS(e){let t=[0,2,4].map(n=>parseInt(e.slice(n,n+2),16)),o=(Math.max(...t)+Math.min(...t))/2/255;return o===1?[zt(5),zt(15),zt(25),zt(35),zt(50)]:o===0?[pn(50),pn(35),pn(25),pn(15),pn(5)]:o>=.8?[zt(10),zt(25),zt(50),zt(75),zt(90)]:[pn(80),pn(60),pn(40),zt(25),zt(50)]}var US=/^[0-9A-Fa-f]{6}$/;function $S(e,t){let o="";for(let n=0;n<6;n+=2){let r=Math.round(t(parseInt(e.slice(n,n+2),16)));o+=Math.max(0,Math.min(255,r)).toString(16).padStart(2,"0");}return o.toUpperCase()}function zS(e){let t=parseInt(e.slice(0,2),16),o=parseInt(e.slice(2,4),16),n=parseInt(e.slice(4,6),16);return .299*t+.587*o+.114*n>230}function Ir({value:e,css:t,title:o,selected:n,apply:r}){return jsx("button",{type:"button",className:"docx-toolbar__swatch",style:{backgroundColor:t},"aria-label":o,"aria-pressed":n,title:o,"data-value":e,...n?{"data-selected":""}:{},...t.startsWith("var(")||zS(t.replace("#",""))?{"data-light":""}:{},onMouseDown:$,onClick:()=>r(e)})}function VS({apply:e,label:t,current:o,themeHexes:n}){let r=n.map(qS),i=[0,1,2,3,4];return 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(Ir,{value:a,css:`#${a.toLowerCase()}`,title:t(Gl[l]),selected:o===a,apply:e},`base-${l}`)),i.map(a=>n.map((l,s)=>{let c=r[s][a],d=$S(l,c.apply);return jsx(Ir,{value:d,css:`#${d.toLowerCase()}`,title:`${t(Gl[s])}, ${t(c.labelKey)}`,selected:o===d,apply:e},`${a}-${s}`)}))]})]})}function GS(e){let{apply:t,label:o,current:n}=e,[r,i]=useState(""),a=US.test(r);return jsxs(Fragment,{children:[jsx(VS,{...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:KS.map(l=>jsx(Ir,{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:$,onClick:()=>t(r.toUpperCase()),children:o("colorPicker.apply")})]})]})]})}function eu({apply:e,current:t}){let o=A(),n=ae(),r=o?.getDocumentThemeColors()??[],i=r.length===Gl.length?r.map(l=>l.hex):jg,a=t?.toUpperCase()??null;return jsx(GS,{apply:e,label:n,current:a,themeHexes:i})}var jS=Gg.filter(e=>e.value!=="white");function YS({apply:e,label:t,current:o}){return 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:jS.map(n=>jsx(Ir,{value:n.value,css:n.css,title:t(n.labelKey),selected:o===n.value,apply:e},n.value))})]})}function Yg(e){let{slot:t,defaultValue:o,cssOf:n,clear:r,body:i}=e,a=t==="text.color";return Object.assign(({className:s,hidden:c,icon:d})=>{let m=A(),{isEnabled:u,disabledReason:g}=re(t),p=ae(),[f,b]=useState(false),[y,v]=useState(o),x=useRef(null);Zo(x,f,()=>b(false));let h=W(P=>{if(a){let w=P.formatting?.color;return w&&w.kind==="hex"?w.value.toUpperCase():null}return P.formatting?.highlight??null}),k=m?.getDocumentThemeColors()??[],E=k.length===Gl.length?k.map(P=>P.hex):jg;useEffect(()=>{if(f)return listenForOutsidePress({popup:x.current,close:()=>b(false)})},[f]);let C=useCallback(P=>{if(b(false),!m)return;m.focus();let w=commandForSlotValue(t,P);w&&m.can(w).ok&&(m.exec(w),P!==r.value&&v(P));},[m]),T=useMemo(()=>te(t),[]);if(c)return null;let S=p(T?.labelKey??t);return jsxs("div",{ref:x,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:$,onClick:()=>C(y),children:[d??oe(T?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:n(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:$,onClick:()=>b(P=>!P),children:"\u25BE"}),f?jsxs("div",{className:"docx-toolbar__swatch-popup",role:"dialog","aria-label":S,onMouseDown:$,children:[jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:$,onClick:()=>C(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:C,label:p,current:h,themeHexes:E})]}):null]})},{docxSlot:t})}var XS=new Map(Gg.map(e=>[e.value,e.css])),tu=Yg({slot:"text.color",defaultValue:"FF0000",cssOf:e=>e==="auto"?"#000000":`#${e}`,clear:{value:"auto",labelKey:"colorPicker.automatic"},body:e=>jsx(eu,{apply:e.apply,current:e.current})}),ou=Yg({slot:"text.highlight",defaultValue:"yellow",cssOf:e=>XS.get(e)??"#ffff00",clear:{value:"none",labelKey:"colorPicker.noColor"},body:e=>jsx(YS,{...e})});var ru=e=>e==="auto"?"currentColor":e==="byAuthor"?"var(--doc-review-author-0)":e==="none"?"transparent":`var(--doc-revision-color-${e})`;function Yl({label:e,value:t,values:o,disabled:n,change:r,t:i}){let a=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:ru(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),b=g.key==="Home"?0:g.key==="End"?p.length-1:["ArrowRight","ArrowDown"].includes(g.key)?(f+1)%p.length:["ArrowLeft","ArrowUp"].includes(g.key)?(f-1+p.length)%p.length:null;b!==null&&(g.preventDefault(),g.stopPropagation(),p[b]?.focus());},children:[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:ru(g)}}),i(`values.${g}`)]},g))}),jsx("div",{className:"docx-toolbar__swatch-grid",children:o.filter(g=>!["auto","none","byAuthor"].includes(g)).map(g=>jsx(Ir,{value:g,css:ru(g),title:i(`values.${g}`),selected:t===g,apply:p=>{r(p),u();}},g))})]})]})}var Xg=["none","colorOnly","bold","italic","underline","doubleUnderline","strikethrough","doubleStrikethrough"],rP=["byAuthor","auto",...REVISION_MARKUP_COLORS];function Jg(e,t,o){let{values:n}=e,r=a=>{let l=a==="changedLines"?["none","leftBorder","rightBorder","outsideBorder"]:a==="deletions"||a==="movedFrom"?[...Xg,"hidden","caret","pound"]:Xg,s=(a==="movedFrom"||a==="movedTo")&&!n.trackMoves;return 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(Yl,{label:t(`${a}Color`),value:n[a].color,values:rP,disabled:s,t,change:c=>e.setValue(a,{...n[a],color:c})})]}),a!=="changedLines"&&jsx("div",{className:"docx-revision-markup-background",children:jsx(Yl,{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(Yl,{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 oo=yt();function uP(){return oo.useState()}function pP({session:e,...t}){return e?jsx(mP,{session:e,...t}):null}function mP({session:e,children:t,preset:o,className:n,style:r}){let i=useId(),{t:a}=H(),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,b){e.set({[f]:b});},errors:{},isEnabled:!m&&e.canApply(),apply(){e.apply();},cancel(){e.cancel();},reset(){e.reset();}};return m?null:jsx(Fe,{kind:"revisionMarkup",label:l("title"),className:["docx-revision-markup-dialog",n].filter(Boolean).join(" "),style:r,onClose:p.cancel,dismissOutside:false,sessionSignal:e.signal,children:jsx(oo.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:Jg(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 Ka=Object.assign(pP,{Header:oo.Header,Title:oo.Title,Body:oo.Body,Footer:oo.Footer,Apply:oo.Apply,Cancel:oo.Cancel,Error:oo.Error,Field:oo.Field,Reset:oo.Reset});var Vt=yt();function EP(){return Vt.useState()}var tb=new WeakMap,SP=0,PP=e=>{let t=tb.get(e);return t===void 0&&tb.set(e,t=SP++),t};function kP({session:e,...t}){return e?jsx(wP,{session:e,...t},PP(e)):null}function wP({session:e,children:t,preset:o,className:n,style:r}){let i=useId(),{t:a}=H(),l=L=>a(`compareDocuments.${L}`),[s,c]=useState(()=>({revised:null,authorName:e.defaultAuthor,detectFormatChanges:true,removeDateAndTime:false})),[d,m]=useState(),[u,g]=useState(),[p,f]=useState(false),[b,y]=useState(null),[v,x]=useState(e.signal.aborted),h=useRef(null),[k,E]=useState(null);useLayoutEffect(()=>{k&&focusCompareDocumentsControl(h.current,k.moment);},[k]);let C=W(useCallback(()=>e.canApply(),[e]),Object.is),T=useRef(false),S=useRef(null);useEffect(()=>{S.current=e;let L=()=>x(true);return x(e.signal.aborted),e.signal.addEventListener("abort",L),()=>{e.signal.removeEventListener("abort",L),S.current=null,queueMicrotask(()=>{S.current!==e&&e.cancel();});}},[e]);let P=async()=>{let L=s.revised;if(!L){m(l("fileRequired"));return}if(!T.current){T.current=true,f(true),E({moment:"busy"}),m(void 0),g(void 0);try{let N;try{N=new Uint8Array(await L.arrayBuffer());}catch{e.signal.aborted||(m(l("readFailed")),f(!1),E({moment:"refused"}));return}if(e.signal.aborted)return;let B=await e.apply({revised:N,authorName:s.authorName,detectFormatChanges:s.detectFormatChanges,...s.removeDateAndTime?{removeDateAndTime:!0}:{}},{onProgress:y});if(e.signal.aborted)return;y(null),B.ok?g(a("compareDocuments.noDifferences")):m(a(compareDocumentsErrorKey(B))),f(!1),E({moment:B.ok?"unchanged":"refused"});}finally{T.current=false;}}},w=b?a(`compareDocuments.phases.${b.phase}`):l("comparing"),_={values:s,setValue(L,N){m(void 0),g(void 0),c(B=>({...B,[L]:N}));},errors:d===void 0?{}:{form:d},isEnabled:!v&&!p&&s.revised!==null&&C,busy:p,progress:b,cancelable:e.cancelable,notice:u,originalHasTrackedChanges:e.originalHasTrackedChanges,apply(){P();},cancel(){(!p||e.cancelable)&&e.cancel();}};return v?null:jsx(Fe,{kind:"compareDocuments",label:l("title"),className:["docx-compare-documents-dialog",n].filter(Boolean).join(" "),style:r,onClose:_.cancel,panelRef:h,dismissOutside:false,sessionSignal:e.signal,describedBy:o===false?void 0:`${i}-description${e.originalHasTrackedChanges?` ${i}-tracked`:""}`,busy:p,children:jsx(Vt.Composition,{state:_,preset:o,defaults:jsxs(Fragment,{children:[jsxs("div",{"data-docx-part":"header",children:[jsx("h2",{"data-docx-part":"title",children:l("title")}),jsx("p",{id:`${i}-description`,children:l("description")}),e.originalHasTrackedChanges?jsx("p",{id:`${i}-tracked`,"data-docx-part":"trackedChanges",className:"docx-compare-documents-tracked",children:l("trackedChangesAccepted")}):null]}),jsxs("div",{"data-docx-part":"body",className:"docx-compare-documents-body",children:[jsxs("label",{"data-docx-part":"field","data-docx-field":"revised",children:[jsx("span",{children:l("revisedFile")}),jsx("input",{type:"file",accept:COMPARE_DOCUMENTS_ACCEPT,disabled:p,onChange:L=>_.setValue("revised",L.currentTarget.files?.[0]??null)})]}),jsxs("label",{"data-docx-part":"field","data-docx-field":"authorName",children:[jsx("span",{children:l("author")}),jsx("input",{type:"text",autoComplete:"off",value:s.authorName,disabled:p,onChange:L=>_.setValue("authorName",L.currentTarget.value)})]}),jsxs("label",{"data-docx-part":"field","data-docx-field":"detectFormatChanges",className:"docx-compare-documents-check",children:[jsx("input",{type:"checkbox",checked:s.detectFormatChanges,disabled:p,onChange:L=>_.setValue("detectFormatChanges",L.currentTarget.checked)}),l("detectFormatting")]})]}),p?jsxs("div",{"data-docx-part":"progress","aria-busy":"true",children:[jsx("progress",{className:"docx-compare-documents-progress",max:1,value:b?.fraction,"aria-label":l("comparing"),"aria-valuetext":w}),jsx("span",{className:"docx-compare-documents-phase",tabIndex:-1,[COMPARE_DOCUMENTS_PHASE_ATTRIBUTE]:"",children:w})]}):null,jsx("p",{"data-docx-part":"error",role:"alert",className:"docx-compare-documents-error",children:_.errors.form}),jsx("p",{"data-docx-part":"notice",role:"status",className:"docx-compare-documents-notice",children:u}),jsxs("div",{"data-docx-part":"footer",className:"docx-compare-documents-actions",children:[jsx("button",{"data-docx-part":"cancel",type:"button",disabled:p&&!e.cancelable,onClick:_.cancel,children:u?a("common.close"):l("cancel")}),jsx("button",{"data-docx-part":"apply",type:"button",disabled:!_.isEnabled,onClick:_.apply,children:l(p?"comparing":"compare")})]})]}),children:t})})}var qa=Object.assign(kP,{Header:Vt.Header,Title:Vt.Title,Body:Vt.Body,Footer:Vt.Footer,Apply:Vt.Apply,Cancel:Vt.Cancel,Error:Vt.Error,Field:Vt.Field,Progress:Vt.part("progress"),Notice:Vt.part("notice")});function lu(e){let t=A(),o=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 Ua({open:e,format:t,pending:o,error:n,onClose:r,className:i,style:a,children:l}){let{t:s}=H();if(!e)return null;let c=s(n?t==="pdf"?"toolbar.exportPdfFailed":"toolbar.exportMarkdownFailed":t==="pdf"?"toolbar.exportingPdf":"toolbar.exportingMarkdown");return jsx(Fe,{kind:"export",label:c,role:n?"alertdialog":"dialog",className:`docx-export-dialog${o?" docx-export-dialog--pending":""}${i?` ${i}`:""}`,style:a,dismissOutside:false,onClose:r,children:l??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,choosing:i=false,settings:a,onSettingsChange:l,onPrint:s,className:c,style:d,children:m}){let{t:u}=H();if(!e)return null;let g=i&&a&&l&&s,p=u(o?"toolbar.printFailed":g?"toolbar.print":"toolbar.printPreparing"),f=n.startsWith("blob:")?n:"";return jsx(Fe,{kind:"print",label:p,role:o?"alertdialog":"dialog",className:`docx-export-dialog docx-print-dialog${t?" docx-export-dialog--pending":""}${c?` ${c}`:""}`,style:d,dismissOutside:false,onClose:r,onKeyDown:b=>{isChromePrintShortcut(b.nativeEvent)&&(b.preventDefault(),g&&!b.repeat&&s());},children:m??(g?jsx(HP,{title:p,settings:a,onSettingsChange:l,onPrint:s,onClose:r}):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:p})]}),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&&f&&jsx("a",{className:"docx-dialog__link-button docx-print-dialog__open",href:f,target:"_blank",rel:"noopener noreferrer",children:u("toolbar.printOpenPdf")}),jsx("button",{type:"button",className:"docx-dialog__button",ref:LP,onClick:r,children:u(o?"common.close":"common.cancel")})]})]}))})}function LP(e){if(!isHTMLElementNode(e))return;let t=e.ownerDocument.activeElement;(!t||!e.closest("dialog")?.contains(t))&&e.focus({preventScroll:true});}function HP({title:e,settings:t,onSettingsChange:o,onPrint:n,onClose:r}){let{t:i}=H(),a=useId(),l=t.displayMode==="all-markup";return jsxs(Fragment,{children:[jsx("header",{className:"docx-dialog__header","data-docx-part":"print-settings",children:jsx("h2",{className:"docx-dialog__title",children:e})}),jsxs("div",{className:"docx-dialog__body",children:[jsxs("fieldset",{className:"docx-dialog__fieldset",children:[jsx("legend",{className:"docx-dialog__section-label",children:i("toolbar.printMarkup")}),CHROME_PRINT_DISPLAY_MODES.map(({mode:s,labelKey:c})=>jsxs("label",{"data-docx-part":"field","data-docx-field":s,className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"radio",name:`${a}-mode`,checked:t.displayMode===s,onChange:()=>o({displayMode:s})}),i(c)]},s))]}),jsxs("label",{"data-docx-part":"field","data-docx-field":"comments",className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:t.comments,"aria-describedby":l?void 0:`${a}-comments-note`,onChange:s=>o({comments:s.target.checked})}),i("toolbar.printComments")]}),!l&&jsx("p",{id:`${a}-comments-note`,className:"docx-dialog__note",children:i("toolbar.printCommentsNote",{mode:i("review.allMarkup")})})]}),jsxs("footer",{className:"docx-dialog__footer",children:[jsx("button",{type:"button",className:"docx-dialog__button",onClick:r,children:i("common.cancel")}),jsx("button",{type:"button",className:"docx-dialog__button docx-dialog__button--primary",onClick:n,children:i("toolbar.print")})]})]})}var St={hfInlineEditor:10,chrome:50,ruler:30,outline:40,popover:100,toolbar:100,modal:1e4};function Nr({text:e,x:t,y:o,className:n}){return jsx("div",{role:"tooltip",className:n,"data-testid":"docx-notes-preview",style:{position:"fixed",left:t,top:o,zIndex:St.popover,maxWidth:280,maxHeight:"40vh",overflowY:"auto",padding:"8px 10px",background:"var(--doc-popover-bg)",color:"var(--doc-popover-fg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",fontSize:12,lineHeight:1.4,pointerEvents:"none"},onMouseDown:r=>{r.preventDefault(),r.stopPropagation();},children:e})}function Fr({noteKind:e,x:t,y:o,onDelete:n,onConvert:r,onConvertAll:i,onOpenProperties:a,onClose:l,deleteEnabled:s,convertEnabled:c,convertAllEnabled:d,deleteDisabledReason:m,convertDisabledReason:u,convertAllDisabledReason:g,className:p}){let{t:f}=H();return jsxs("div",{role:"menu",className:p,onKeyDown:b=>{b.key==="Escape"&&l();},"data-testid":"docx-notes-menu",style:{position:"fixed",left:t,top:o,zIndex:St.popover,minWidth:160,background:"var(--doc-popover-bg)",border:"1px solid var(--doc-border)",boxShadow:"0 4px 16px var(--doc-shadow)",padding:4},onMouseDown:$,children:[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 BP(e){return t=>createElement(e,t)}var ab=new WeakMap,WP=0;function Te(e,t,o){if(e===false)return null;let n=e(t);if(!o)return n;let r=ab.get(o);return r===void 0&&ab.set(o,r=++WP),createElement(Fragment$1,{key:r},n)}var su=createContext(void 0),Rt=()=>useContext(su);function Lr(e,t,o){let n=e.getBoundingClientRect();return {left:t-n.left-e.clientLeft+e.scrollLeft,top:o-n.top-e.clientTop+e.scrollTop}}function ja(e){return e.paragraphId===""}var GP=4096,Hr=Object.freeze({mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:true}),jP=e=>e;function YP(e){let t=r=>!!r&&(r.width>0||r.height>0),o=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 Ya=createContext(null),cu=createContext(null);function du(){let e=useContext(cu);useEffect(()=>e?.(),[e]);}function XP(){let e=useContext(Ya);du();let t=Xl(e===null);return e??t}function Xl(e=true){let t=A(),o=we(),n=useRef(o);n.current=o;let[r,i]=useState(Hr),a=useRef(null),l=useRef(""),s=useRef(false),c=useRef(r);c.current=r;let d=W(jP),m=t?t.can({type:"insertText",text:""}).ok:false,u=useCallback(()=>{l.current="",s.current=false;let T=a.current;T&&(T.editor.releaseSelection(T.pin),a.current=null);},[]),g=useCallback((T=false)=>{let S=l.current;return S===""||!t?false:!s.current&&t.surface?.hyperlinks.selectionIsPendingDeletion()===true?true:T&&S.length>GP?false:t.query({type:"selectedText"})!==S},[t]),p=useCallback((T,S)=>{u(),i({mode:T?"reading":"editing",link:T??null,anchor:S??null,text:T?.text??"",url:T?T.kind==="internal"?`#${T.anchor??""}`:T.authored:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,u]),f=useCallback(()=>{u(),i(Hr);},[u]);useEffect(()=>u,[u]);let b=useCallback(()=>{let T=YP(n.current);u();let S=t?.surface?.hyperlinks.linkAtCaret()??t?.surface?.hyperlinks.fieldLinkAtCaret()??null;if(S&&ja(S)){p(S,T);return}if(S){i({mode:"editing",link:S,anchor:T,text:S.text,url:S.kind==="internal"?`#${S.anchor??""}`:S.authored,copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});return}let P=t?.surface?.hyperlinks.wordAtCaret()??null;P&&t?.surface?.setSelection({anchor:P.from,head:P.to});let w=t?.query({type:"selectedText"})??"",_=t?.retainSelection()??null;t&&_&&(a.current={editor:t,pin:_}),l.current=w,s.current=t?.surface?.hyperlinks.selectionIsPendingDeletion()===true,i({mode:"editing",link:null,anchor:T,text:w,url:"",copied:false,error:false,canEdit:t?t.can({type:"insertText",text:""}).ok:false});},[t,p,u]);useEffect(()=>{if(!(!t||!e))return t.setHyperlinkChrome({onPopover:T=>p(T.link,{left:T.rect.left,top:T.rect.bottom}),onRequest:b})},[t,e,p,b]),useEffect(()=>{let T=c.current;if(T.mode!=="reading"||!T.link)return;let S=ja(T.link)?t?.surface?.hyperlinks.fieldLinkAtCaret()??null:t?.surface?.hyperlinks.linkAtCaret()??null;S&&S.id===T.link.id||i(Hr);},[d,t]),useEffect(()=>{let T=c.current;if(T.mode!=="editing"||T.link)return;let S=t?.surface;S&&(S.retainedSelection()&&!g(true)||f());},[d,t,g,f]);let y=useCallback(async()=>{let T=c.current.link?.href;if(!T)return false;try{await hostWindowOf(n.current).navigator.clipboard.writeText(T);}catch{return false}return i(S=>({...S,copied:true})),true},[]),v=useCallback(()=>{i(T=>({...T,mode:"editing",copied:false,error:false}));},[]),x=useCallback(T=>{i(S=>({...S,text:T,copied:false,error:false}));},[]),h=useCallback(T=>{i(S=>({...S,url:T,copied:false,error:false}));},[]),k=useCallback(()=>{let T=c.current,S=t?.surface?.hyperlinks;if(!S)return false;if(!T.link&&g())return f(),false;let P=T.url.trim();if(P.length===0)return i(L=>({...L,error:true})),false;let w=P.startsWith("#");return S.applyHyperlink({...w?{anchor:P.slice(1)}:{url:P},...T.text.trim().length>0?{text:T.text}:{}})?(f(),true):(i(L=>({...L,error:true})),false)},[t,f,g]),E=useCallback(()=>{let T=t?.surface?.hyperlinks,S=c.current.link;if(!T)return false;let P=T.removeHyperlink(S?.id);return P&&f(),P},[t,f]),C=useCallback(()=>{let T=t?.surface?.navigation,S=c.current.link;if(!T||!S)return false;if(S.kind==="internal"){let w=S.anchor?T.goToBookmark(S.anchor):false;return w&&i(Hr),w}let P=T.openExternal(S.href);return P&&i(Hr),P},[t]);return useMemo(()=>({state:r.mode==="closed"?Hr:{...r,canEdit:m},open:p,openAtCaret:b,close:f,copy:y,beginEdit:v,setText:x,setUrl:h,commitEdit:k,unlink:E,openTarget:C}),[r,m,p,b,f,y,v,x,h,k,E,C])}function Xn(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Xa(){let e=A();return useCallback(()=>{e?.focus();},[e])}var Jl=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),ak="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z",ik="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z",lk="M770-302 656-416l57-57 114 114-57 57ZM603-469 469-603l57-57 134 134-57 57ZM280-280h133v80H280q-83 0-141.5-58.5T80-400q0-83 58.5-141.5T280-600h133v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35Zm40-80v-80h101l80 80H320Zm493-15-57-57q23-11 33.5-32t10.5-36q0-50-35-85t-85-35H547v-80h133q83 0 141.5 58.5T880-400q0 32-11 61.5T813-375ZM792-56 56-792l56-56 736 736-56 56Z",sk="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z";function ck({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=So();du();let a=useRef(null),{state:l,close:s}=i,c=Xa();useEffect(()=>{if(l.mode==="closed")return;let b=x=>{x.key==="Escape"&&(x.preventDefault(),s(),c());},y=hostDocumentOf(a.current);y.addEventListener("keydown",b);let v=listenForOutsidePress({popup:y,contains:x=>a.current?.contains(x)===true,close:s});return ()=>{y.removeEventListener("keydown",b),v();}},[l.mode,s,c]);let[d,m]=useState(null);useLayoutEffect(()=>{let b=l.anchor,y=a.current;if(!b||!y){m(null);return}let v=y.offsetParent;if(!v){m(null);return}let{left:x,top:h}=Lr(v,b.left,b.top),k=Math.max(0,v.scrollWidth-y.offsetWidth);m({left:Math.max(0,Math.min(x,k)),top:h});},[l.anchor]);let{t:u}=H(),g=l.mode==="editing"?u(l.link?"hyperlinkPopup.editTitle":"hyperlinkPopup.insertTitle"):u("hyperlinkPopup.editLink"),p=r?jsx(dk,{children:n}):n;if(o)return l.mode==="closed"?null:jsx(Fragment,{children:n});let f={ref:a,className:`docx-hyperlink-popup${e?` ${e}`:""}`,"data-testid":"hyperlink-popup","data-mode":l.mode,role:"dialog","aria-modal":false,onMouseDown:Xn,style:d??void 0,"aria-label":g};return l.mode==="closed"?null:t?jsx(Q,{...f,children:n}):jsx("div",{...f,children:p})}function dk({children:e}){let{state:t}=So(),o=useMemo(()=>uk(e),[e]),n=(i,a)=>i in o?o[i]:a;if(t.mode==="editing")return jsxs(Fragment,{children:[n("Fields",jsx(bu,{})),n("Error",jsx(yu,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Apply",jsx(hu,{})),n("Cancel",jsx(xu,{}))]}),o.__extra]});let r=t.canEdit&&!(t.link&&ja(t.link));return jsxs(Fragment,{children:[n("Url",jsx(pu,{})),jsxs("div",{className:"docx-hyperlink-popup__actions",children:[n("Copy",jsx(mu,{})),r?n("Edit",jsx(fu,{})):null,r?n("Unlink",jsx(gu,{})):null]}),o.__extra]})}function uk(e){let t={},o=[],n=r=>{if(Array.isArray(r)){r.forEach(n);return}if(!r||typeof r!="object"||!("type"in r)){r&&o.push(r);return}if(r.type===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 So(){return useContext(Ya)??pk}var pk={state:{mode:"closed",link:null,anchor:null,text:"",url:"",copied:false,error:false,canEdit:false},open:()=>{},openAtCaret:()=>{},close:()=>{},copy:async()=>false,beginEdit:()=>{},setText:()=>{},setUrl:()=>{},commitEdit:()=>false,unlink:()=>false,openTarget:()=>false};function pu({className:e,asChild:t,hidden:o,children:n}){let{state:r,openTarget:i}=So(),{t:a}=H();if(o||!r.link)return null;let l=!r.link.href,s=r.link.kind==="internal",c=s?`#${r.link.anchor??""}`:r.link.authored,d=jsx("bdi",{dir:s?void 0:"ltr",children:c}),m=a(l?"hyperlinkPopup.inertTarget":s?"hyperlinkPopup.bookmarkTarget":"hyperlinkPopup.openLink"),u={className:`docx-hyperlink-popup__url${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-url",...l?{"data-inert":""}:{},title:m,onMouseDown:Xn,...l?{}:{onClick:()=>i(),type:"button"}};return t?jsx(Q,{...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,Jl(sk)]})}pu.docxHyperLinkPart="Url";function mu({className:e,asChild:t,hidden:o,children:n,icon:r}){let{state:i,copy:a}=So(),{t:l}=H();if(o||!i.link?.href)return null;let s=i.copied?l("editor.linkCopied"):l("hyperlinkPopup.copyLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-copy",...i.copied?{"data-copied":""}:{},"aria-label":s,title:s,onMouseDown:Xn,onClick:()=>{a();}};return t?jsx(Q,{...c,className:e,children:n}):jsx("button",{...c,children:r??n??Jl(ak)})}mu.docxHyperLinkPart="Copy";function fu({className:e,asChild:t,hidden:o,children:n,icon:r}){let{beginEdit:i}=So(),{t:a}=H();if(o)return null;let l=a("hyperlinkPopup.editLink"),s={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-edit","aria-label":l,title:l,onMouseDown:Xn,onClick:()=>i()};return t?jsx(Q,{...s,className:e,children:n}):jsx("button",{...s,children:r??n??Jl(ik)})}fu.docxHyperLinkPart="Edit";function gu({className:e,asChild:t,hidden:o,children:n,icon:r}){let{unlink:i}=So(),a=Xa(),{t:l}=H();if(o)return null;let s=l("hyperlinkPopup.removeLink"),c={type:"button",className:`docx-hyperlink-popup__action${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-unlink","aria-label":s,title:s,onMouseDown:Xn,onClick:()=>{i()&&a();}};return t?jsx(Q,{...c,className:e,children:n}):jsx("button",{...c,children:r??n??Jl(lk)})}gu.docxHyperLinkPart="Unlink";function bu({className:e,hidden:t}){let{state:o,setText:n,setUrl:r,commitEdit:i,close:a}=So(),l=Xa(),{t:s}=H(),c=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=>n(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=>r(g.target.value),onKeyDown:u})]})}bu.docxHyperLinkPart="Fields";function hu({className:e,asChild:t,hidden:o,children:n}){let{state:r,commitEdit:i}=So(),a=Xa(),{t:l}=H();if(o)return null;let s=l("hyperlinkPopup.apply"),c={type:"button",className:`docx-hyperlink-popup__apply${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-apply",disabled:r.url.trim().length===0,onMouseDown:Xn,onClick:()=>{i()&&a();}};return t?jsx(Q,{...c,className:e,children:n}):jsx("button",{...c,children:n??s})}function yu({className:e,hidden:t}){let{state:o}=So(),{t:n}=H();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")})}yu.docxHyperLinkPart="Error";hu.docxHyperLinkPart="Apply";function xu({className:e,asChild:t,hidden:o,children:n}){let{close:r}=So(),i=Xa(),{t:a}=H();if(o)return null;let l=a("hyperlinkPopup.cancel"),s={type:"button",className:`docx-hyperlink-popup__cancel${e?` ${e}`:""}`,"data-testid":"hyperlink-popup-cancel",onMouseDown:Xn,onClick:()=>{r(),i();}};return t?jsx(Q,{...s,className:e,children:n}):jsx("button",{...s,children:n??l})}xu.docxHyperLinkPart="Cancel";var Ja=Object.assign(ck,{Url:pu,Copy:mu,Edit:fu,Unlink:gu,Fields:bu,Error:yu,Apply:hu,Cancel:xu});var Mt={showAll:"contentControl.showAll",formFill:"contentControl.formFill",inspector:"contentControl.inspector",remove:"contentControl.remove"};function bk(e){return e==="sdtLocked"||e==="sdtContentLocked"}function hk(e){return e==="contentLocked"||e==="sdtContentLocked"}function Cu(e,t){return !e.ok&&e.code===t}function Po(){let e=useContext(Tu),t=Ql();return e??t}function Ql(){let e=A(),[t,o]=useState(false),[n,r]=useState(false),[i,a]=useState(false),l=W(C=>C),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 C=c?.atCaret()??null;if(C){let F=c?.disabledReason(C.id,"edit")??null,D=c?.disabledReason(C.id,"remove")??null;return {id:C.id,tag:C.tag??null,alias:C.alias??null,controlType:C.controlType,locked:hk(C.effectiveLock)||F==="locked",removalLocked:bk(C.effectiveLock)||D==="locked",placeholder:C.placeholder,bound:C.bound||F==="bound",effectiveLock:C.effectiveLock}}let T=e.query({type:"contentControlAt"});if(!T)return null;let S=c?.disabledReason(T.id,"edit")??null,P=c?.disabledReason(T.id,"remove")??null,w=e.can({type:"setContentControlValue",value:""}),_=e.can({type:"removeContentControl"}),L=T.locked===true||S==="locked"||Cu(w,"locked"),N=S==="bound"||Cu(w,"bound"),B=P==="locked"||Cu(_,"locked");return {id:T.id,tag:T.tag??null,alias:T.alias??null,controlType:T.controlType,locked:L,removalLocked:B,placeholder:false,bound:N,effectiveLock:null}},[e,l,c]),m=useMemo(()=>e?e.query({type:"contentControls"}):[],[e,l]),u=useCallback(C=>{c?.setShowAll(C),r(C);},[c]),g=useCallback(C=>{c?.setFormFill(C),a(C);},[c]),p=useCallback(()=>u(!n),[u,n]),f=useCallback(()=>g(!i),[g,i]),b=useCallback(()=>o(true),[]),y=useCallback(()=>o(false),[]),v=useCallback(()=>o(C=>!C),[]),x=useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let T=c.disabledReason(d.id,"edit");return T==="locked"?"the content control is locked":T==="bound"?"the content control is bound to external data":T==="notFound"?"the content control was not found":T}if(d.locked)return "the content control is locked";if(d.bound)return "the content control is bound to external data";if(!e)return "no document is loaded";let C=e.can({type:"setContentControlValue",value:""});return C.ok?null:C.reason},[d,c,e]),h=useMemo(()=>{if(!d)return "no content control at the current selection";if(c){let T=c.disabledReason(d.id,"remove");return T==="locked"?"the content control is locked":T==="notFound"?"the content control was not found":T}if(d.removalLocked)return "the content control is locked";if(!e)return "no document is loaded";let C=e.can({type:"removeContentControl"});return C.ok?null:C.reason},[d,c,e]),k=useCallback(C=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c&&d){let T=c.disabledReason(d.id,"edit");if(T)return {ok:false,code:T==="bound"?"bound":T==="locked"?"locked":"notFound",reason:T==="bound"?"the content control is bound to external data":T==="locked"?"the content control is locked":"the content control was not found"}}return e.exec({type:"setContentControlValue",value:C})},[e,c,d]),E=useCallback(()=>{if(!e)return {ok:false,code:"notFound",reason:"no document is loaded"};if(c){let C=d?.id;if(!C)return {ok:false,code:"notFound",reason:"no content control at the current selection"};let T=c.disabledReason(C,"remove");return T?{ok:false,code:T==="locked"?"locked":"notFound",reason:T==="locked"?"the content control is locked":"the content control was not found"}:c.remove(C)?{ok:true,changed:true}:{ok:false,code:"unsupported",reason:"the edit was refused"}}return e.exec({type:"removeContentControl"})},[e,c,d]);return useMemo(()=>({control:d,controls:m,showAll:n,formFill:i,inspectorOpen:t,canSetValue:x===null&&d!==null,canRemove:h===null&&d!==null,setValueDisabledReason:x,removeDisabledReason:h,setShowAll:u,toggleShowAll:p,setFormFill:g,toggleFormFill:f,openInspector:b,closeInspector:y,toggleInspector:v,remove:E,setValue:k}),[d,m,n,i,t,x,h,u,p,g,f,b,y,v,E,k])}var Tu=createContext(null);function Eu(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}var fb=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),Tk="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z",Ek="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",Sk={position:"absolute",zIndex:20,minWidth:240,maxWidth:320,top:12,right:12,padding:12,borderRadius:8,border:"1px solid var(--doc-border)",backgroundColor:"var(--doc-surface)",boxShadow:"0 4px 16px var(--doc-shadow)",color:"var(--doc-text)",fontSize:13,display:"flex",flexDirection:"column",gap:10},Pk={display:"flex",justifyContent:"space-between",gap:12,alignItems:"baseline"},kk={color:"var(--doc-text-muted)",flexShrink:0},wk={textAlign:"right",wordBreak:"break-word"},Dk={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,fontWeight:600},Rk={display:"flex",gap:8,marginTop:4},gb={display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:4,border:"1px solid var(--doc-border)",backgroundColor:"var(--doc-bg)",color:"var(--doc-text)",font:"inherit",cursor:"pointer"};function Mk(e){switch(e){case "plainText":return "contentControl.types.plainText";case "checkbox":return "contentControl.types.checkbox";case "dropdown":return "contentControl.types.dropdown";case "comboBox":return "contentControl.types.comboBox";case "date":return "contentControl.types.date";case "picture":return "contentControl.types.picture";case "buildingBlockGallery":return "contentControl.types.buildingBlockGallery";case "repeatingSection":return "contentControl.types.repeatingSection";default:return "contentControl.types.richText"}}function _k(e){return e.effectiveLock==="sdtContentLocked"?"contentControl.lock.sdtContentLocked":e.effectiveLock==="contentLocked"||e.locked?"contentControl.lock.contentLocked":e.effectiveLock==="sdtLocked"||e.removalLocked?"contentControl.lock.sdtLocked":"contentControl.lock.unlocked"}function Ar({label:e,value:t,testId:o}){return jsxs("div",{style:Pk,"data-testid":o,children:[jsx("span",{style:kk,children:e}),jsx("span",{style:wk,children:t})]})}function Ik({className:e,asChild:t,hidden:o,children:n,preset:r=true}){let i=Po(),a=useRef(null),l=useId(),{t:s}=H(),{control:c,inspectorOpen:d,closeInspector:m}=i;if(useEffect(()=>{if(!d)return;let f=v=>{v.key==="Escape"&&(v.preventDefault(),m());},b=hostDocumentOf(a.current);b.addEventListener("keydown",f);let y=listenForOutsidePress({popup:b,contains:v=>a.current?.contains(v)===true,close:m});return ()=>{b.removeEventListener("keydown",f),y();}},[d,m]),useEffect(()=>{d&&!c&&m();},[d,c,m]),o||!d||!c)return null;let u=r?jsxs(Fragment,{children:[jsx(bb,{}),jsx(hb,{}),jsx("div",{style:Rk,children:jsx(yb,{})}),n]}):n,g={ref:a,role:"dialog","aria-modal":false,"aria-labelledby":l,"data-testid":"content-control-inspector","data-control-id":c.id,"data-control-type":c.controlType,...c.locked?{"data-locked":""}:{},...c.bound?{"data-bound":""}:{},...c.placeholder?{"data-placeholder":""}:{},className:`docx-content-control-inspector${e?` ${e}`:""}`,style:Sk,onMouseDown:f=>{Eu(f),f.stopPropagation();}},p=jsxs(Fragment,{children:[jsx("span",{id:l,className:"docx-editor-sr-only",children:s("contentControl.inspectorPanel.title")}),u]});return t?jsx(Q,{...g,children:p}):jsx("div",{...g,children:p})}function bb({className:e,asChild:t,hidden:o,children:n}){let{closeInspector:r}=Po(),{t:i}=H();if(o)return null;let a={style:Dk,className:e??void 0,"data-testid":"content-control-inspector-header"},l=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:{...gb,padding:4,border:"none",background:"transparent"},onMouseDown:Eu,onClick:()=>r(),children:fb(Tk)})]});return t?jsx(Q,{...a,children:l}):jsx("div",{...a,children:l})}function hb({className:e,asChild:t,hidden:o,children:n}){let{control:r}=Po(),{t:i}=H();if(o||!r)return null;let a=i("contentControl.inspectorPanel.empty"),l=i("contentControl.inspectorPanel.yes"),s=i("contentControl.inspectorPanel.no"),c=n??jsxs(Fragment,{children:[jsx(Ar,{label:i("contentControl.inspectorPanel.alias"),value:r.alias??a,testId:"content-control-inspector-alias"}),jsx(Ar,{label:i("contentControl.inspectorPanel.tag"),value:r.tag??a,testId:"content-control-inspector-tag"}),jsx(Ar,{label:i("contentControl.inspectorPanel.type"),value:i(Mk(r.controlType)),testId:"content-control-inspector-type"}),jsx(Ar,{label:i("contentControl.inspectorPanel.lock"),value:i(_k(r)),testId:"content-control-inspector-lock"}),jsx(Ar,{label:i("contentControl.inspectorPanel.placeholder"),value:r.placeholder?l:s,testId:"content-control-inspector-placeholder"}),jsx(Ar,{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(Q,{...d,children:c}):jsx("div",{...d,children:c})}function yb({className:e,asChild:t,hidden:o,icon:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l,closeInspector:s}=Po(),{t:c}=H();if(o)return null;let d=c("contentControl.remove"),m={type:"button",className:`docx-content-control-inspector__remove${e?` ${e}`:""}`,"data-testid":"content-control-inspector-remove","data-slot":"contentControl.remove",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":d,title:a??d,style:gb,onMouseDown:Eu,onClick:()=>{l().ok&&s();}},u=jsxs(Fragment,{children:[n??r??fb(Ek),jsx("span",{children:d})]});return t?jsx(Q,{...m,children:u}):jsx("button",{...m,children:u})}var ti=Object.assign(Ik,{Header:bb,Fields:hb,Remove:yb});var Ak=e=>e;function Du(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function oi(){let e=A(),{t}=H(),[o,n]=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=W(Ak),p=useMemo(()=>{if(!e?.surface||!u)return {replaceEnabled:false,removeEnabled:false,reason:null};let x=e.surface.equations.can(u.equation.id,"replace"),h=e.surface.equations.can(u.equation.id,"remove"),k=x.ok?h.ok?null:h.reason:x.reason;return {replaceEnabled:x.ok,removeEnabled:h.ok,reason:k?localizeDisabledReason(k,t):null}},[u,e,g,t]),f=useCallback((x=false)=>{s.current?.(),s.current=null,n(null),x&&e&&queueMicrotask(()=>e.focus());},[e]);useEffect(()=>{if(!e)return;let x=e.setEquationChrome({onPopover:h=>{s.current?.();let k=e.surface;if(k&&typeof k.retainSelection=="function"){let E=k.retainSelection();s.current=()=>k.releaseSelection(E);}else s.current=null;n({activation:h,mountGeneration:e.mountGeneration,draft:h.equation.linear,error:false});}});return ()=>{x(),s.current?.(),s.current=null,n(null);}},[e,f]),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 x=a.current,h=x?.ownerDocument,k=h?.defaultView;if(!x||!h||!k)return;let E=T=>{T.key==="Escape"&&(T.preventDefault(),f(true));},C=T=>{isDomNode(T.target)&&x.contains(T.target)||f();};return h.addEventListener("keydown",E),h.addEventListener("pointerdown",C,true),()=>{h.removeEventListener("keydown",E),h.removeEventListener("pointerdown",C,true);}},[o,f]),useLayoutEffect(()=>{if(!u){i(null);return}let x=a.current;if(!x)return;let h=x.offsetParent;if(!h){i(null);return}let k=u.rect,E=Lr(h,k.left,k.bottom),C=Math.max(0,h.scrollWidth-x.offsetWidth);i({left:Math.max(0,Math.min(E.left,C)),top:E.top}),l.current?.focus({preventScroll:true}),l.current?.select();},[u]);let b=useCallback(()=>{if(!o||!e?.surface||!p.replaceEnabled)return false;let x=e.surface.equations.applyEquation(o.activation.equation.id,o.draft);return x?f(true):n(h=>h&&{...h,error:true}),x},[e,o,f,p.replaceEnabled]),y=useCallback(()=>{if(!o||!e?.surface||!p.removeEnabled)return false;let x=e.surface.equations.removeEquation(o.activation.equation.id);return x?f(true):n(h=>h&&{...h,error:true}),x},[e,o,f,p.removeEnabled]);if(!o)return null;let v=[o.error?d:null,p.reason?m:null].filter(Boolean).join(" ");return jsxs("div",{ref:a,className:"docx-equation-popup","data-testid":"equation-popup",role:"dialog","aria-modal":false,"aria-label":t("equationPopup.title"),style:r??void 0,onMouseDown:Du,children:[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":v||void 0,onChange:x=>n(h=>h&&{...h,draft:x.target.value,error:false}),onKeyDown:x=>{x.key!=="Enter"||x.nativeEvent.isComposing||(x.preventDefault(),b());}}),o.error?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:Du,onClick:b,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:Du,onClick:y,children:t("equationPopup.delete")})]})]})}var Cb="review.comments",Ru="review.addComment";function Tb(e){return e!==Cb?e:(un(`The context-menu row "${Cb}" is now "${Ru}". The old id still works in this release; write "${Ru}".`),Ru)}var Bk="input, textarea, select",Wk="[data-docx-form-dropdown]",Zk=".docx-paginated-surface:not(.docx-editor__loading-surface)",Kk=".docx-image-selection-overlay";function Eb(e,t){if(!isElementNode(t))return false;let o=t.closest(Bk);if(o&&!o.matches(Wk))return false;let n=e.querySelector(Zk);return n?n.contains(t)||t.contains(n)||!!t.closest(Kk):true}function Wr(e,t){if(!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 es({entries:e,children:t,preset:o,keyOfEntry:n,keyOfChild:r,renderEntry:i,childrenOfEntry:a,onUnmatched:l}){if(!o)return t;let s=new Map,c=[];for(let p of Children.toArray(t)){let f=r(p);f?s.set(f,p):c.push(p);}let d=new Set,m=p=>p.map((f,b)=>{let y=n(f,b);d.add(y);let v=a?.(f),x=v?m(v):void 0,h=s.get(y);return jsx(Fragment$1,{children:h??i(f,b,x)},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 zk="review.addComment",Vk=e=>e.editingMode==="viewing";function ts(e){let{isEnabled:t,disabledReason:o}=re(zk),n=W(Vk);return t?{isEnabled:t,reason:null}:{isEnabled:t,reason:n?e("editingMode.viewingHint"):o}}var ni=createContext({t:void 0,openMenu:null,setOpenMenu:()=>{},activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onWatermarkDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),Zr="docx-menubar-more",os=createContext({measuring:false,overflow:new Set,inMore:false});function wb(){return useContext(os)}function et(){return useContext(ni)}function Pe(){let{t:e}=et(),{t}=H();return o=>e?.(o)??t(o)}var Kr=createContext(-1);var Gk='[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';function Jn(e){return [...e.querySelectorAll(Gk)].filter(t=>t.closest('[role="menu"]')===e)}function Iu(e){return [...e.querySelectorAll(".docx-menubar__trigger")]}function no(e,t,o){if(e.length===0)return false;let n=t?e.indexOf(t):-1,r=n===-1?o>0?0:e.length-1:(n+o+e.length)%e.length;return e[r]?.focus(),true}function ro(e,t){let o=t==="first"?e[0]:e[e.length-1];return o?(o.focus(),true):false}function Nu(e){let t=e?.ownerDocument.activeElement;((t&&e?.contains(t)?t.closest("[data-menu]"):null)?.querySelector(':scope > [role="menuitem"]')??e?.querySelector('.docx-menubar__trigger[aria-expanded="true"]'))?.focus({preventScroll:true});}function Db(e,t,o){return !o||o.ownerDocument===t?false:o.contains(e)}var qr="data-toolbar-group",_b=TOOLBAR_ITEM_ATTRIBUTE,Ur="data-toolbar-fixed",rs="data-toolbar-more",iw=34,ns=new Map;function Fu(e,t,o){let n=useRef(null),r=useRef({itemWidths:new Map,groupBases:new Map,groupGaps:new Map,more:iw}),[i,a]=useState(ns),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=n.current;if(!p||!e)return;let f=readToolbarRow(p,r.current,toolbarItemKey),b=l.current.size===0&&f.overflowing===false,y=toolbarGroupsKey(s.current.groups),v=d.current===y;d.current=y;let x=b?ns:toolbarOverflowItems({...f,groups:s.current.groups,order:s.current.order,itemWidths:r.current.itemWidths,groupBases:r.current.groupBases,groupGaps:r.current.groupGaps,...v?{previous:l.current}:{},hysteresis:TOOLBAR_OVERFLOW_HYSTERESIS});sameItemOverflow(x,l.current)||(l.current=x,a(x));},[e]),g=useCallback(p=>{n.current=p;},[]);return useLayoutEffect(()=>{if(!e){l.current.size>0&&(l.current=ns,a(ns));return}u();},[e,c,u,m]),useEffect(()=>{let p=n.current,f=p?hostWindowOf(p):null;if(!e||!p||!f||typeof f.ResizeObserver>"u")return;let b=0,y=new f.ResizeObserver(()=>{b===0&&(b=f.requestAnimationFrame(()=>{b=0,u();}));});y.observe(p),p.parentElement&&y.observe(p.parentElement);for(let v of p.querySelectorAll(`[${qr}], [${Ur}]`))y.observe(v);return ()=>{b!==0&&f.cancelAnimationFrame(b),y.disconnect();}},[e,c,u,m,i]),{attach:g,overflow:i}}function Ib(e,t,o){let n=t.map(l=>({id:l,items:[l]})),{attach:r,overflow:i}=Fu(e,n,o),a=useMemo(()=>new Set(i.keys()),[i]);return {attach:r,overflow:a}}function Nb(e,t,o){let n=e.overflow.has(t),r=t===Zr;return {skip:e.inMore?!n:n,asSubmenu:e.inMore&&n,iconOnly:r,rootAttributes:{...e.measuring&&!r?{[qr]:t}:{},...r?{[rs]:""}:{}},tabStop:o===t||r&&o!==null&&e.overflow.has(o)}}function Fb(e,t,o){let[n,r]=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 Hb=12700,Lb=96;function mw(e){return e==="image/png"||e==="image/jpeg"||e==="image/gif"}function fw(e,t,o,n){let r=e*72/o,i=t*72/n;return {widthPoints:Math.max(1,Math.round(r*100)/100),heightPoints:Math.max(1,Math.round(i*100)/100)}}function as(e){let t=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(!mw(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}=fw(n.pixelWidth,n.pixelHeight,n.dpiX??Lb,n.dpiY??Lb);return Object.freeze({ok:true,bytes:e,mime:o,widthPoints:i,heightPoints:a})}function gn(e){return Math.round(e/Hb*100)/100}function ai(e){return Math.round(e*Hb)}function is(e,t){return e.label!==void 0?e.label:e.labelKey!==void 0?t(e.labelKey):e.id}function Lu(e){let t=ae();return e.hidden?null:jsx("div",{role:"group","aria-label":is(e,t),className:`docx-toolbar__group${e.className?` ${e.className}`:""}`,"data-toolbar-host-group":e.id,children:e.children})}Lu.docxToolbarGroup=true;function ii(e){return e.hidden?null:jsx(Fragment,{children:e.children})}ii.docxToolbarSlot=true;var ls=createContext("bar");function ss(){return useContext(ls)}function bn(e,t){return ss()==="panel"&&!e&&t===void 0}function hn(e){return e?"docx-toolbar__more-command":"docx-toolbar__button"}function yn({icon:e,label:t}){return jsxs(Fragment,{children:[jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:e}),jsx("span",{className:"docx-toolbar__more-command-label",children:t})]})}function Hu({message:e,onClose:t,className:o,style:n,children:r}){let{t:i}=H();return jsx(Fe,{kind:"imageInsertError",role:"alertdialog",label:i("imageInsert.errors.title"),className:o,style:n,onClose:t,onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing&&(a.preventDefault(),t());},children:r??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 Wb="image/png,image/jpeg,image/gif",Ou=createContext(null);function Kb(){let e=useContext(Ou);if(!e)throw new Error("useImageInsert must be used within ImageInsertProvider");return e}function si(){return useContext(Ou)}function cs({children:e}){let t=A(),{t:o}=H(),n=useRef(null),r=useRef(false),i=Rt(),[a,l]=useState(null),s=useRef(null),c=useCallback(()=>toolbarCommandState(t,"image.insert"),[t]),d=W(c,(x,h)=>x.enabled===h.enabled&&x.disabledReason===h.disabledReason),m=d.enabled,u=localizeDisabledReason(d.disabledReason,o),g=useCallback(async x=>{if(!t||r.current)return;let h=as(x);if(!h.ok){l(o(h.reasonKey));return}let k={type:"insertImage",data:h.bytes,mime:h.mime,widthPoints:h.widthPoints,heightPoints:h.heightPoints};r.current=true;try{let E=await executeImageCommand(t,k);E.ok?t.focus():l(localizeDisabledReason(Dw(E.reason)??null,o)??o("imageInsert.errors.refused"));}finally{r.current=false;}},[t,o]),p=useCallback(async x=>{let h=x?.[0];if(!h)return;let k=await h.arrayBuffer();await g(new Uint8Array(k));},[g]),f=useCallback(async x=>{if(!x)return;let h=[...x.files].find(k=>k.type.startsWith("image/"));if(h){await p([h]);return}for(let k of x.items){if(k.kind!=="file"||!k.type.startsWith("image/"))continue;let E=k.getAsFile();if(!E)continue;let C=await E.arrayBuffer();await g(new Uint8Array(C));return}},[g,p]),b=useCallback(()=>{if(!m)return;let x=n.current,h=t?editorHostDocument(t):null;if(!h||!x||x.ownerDocument===h){x?.click();return}s.current?.remove();let k=h.createElement("input");k.type="file",k.accept=Wb,k.hidden=true,k.tabIndex=-1,k.setAttribute("aria-hidden","true");let E=()=>{k.remove(),s.current===k&&(s.current=null);};k.addEventListener("change",()=>{p(k.files).finally(E);},{once:true}),k.addEventListener("cancel",E,{once:true}),h.body.append(k),s.current=k,k.click();},[t,m,p]),y=useCallback(async x=>{let h=x.currentTarget;await p(h.files),h.value="";},[p]),v=useMemo(()=>({openFilePicker:b,insertFromFileList:p,insertFromDataTransfer:f,isEnabled:m,disabledReason:u,inputRef:n,onInputChange:y}),[b,p,f,m,u,y]);return jsxs(Ou.Provider,{value:v,children:[jsx("input",{ref:n,type:"file",accept:Wb,className:"docx-image-insert__input",tabIndex:-1,"aria-hidden":"true",onChange:y,onMouseDown:x=>x.stopPropagation()}),e,a!==null&&(i?.imageInsertError!==void 0?Te(i.imageInsertError,{message:a,onClose:()=>l(null)}):jsx(Hu,{message:a,onClose:()=>l(null)}))]})}function ds({className:e,hidden:t,asChild:o,children:n}){let{openFilePicker:r,isEnabled:i,disabledReason:a}=Kb(),l=ae(),s=bn(o,n);if(t)return null;let c=te("image.insert"),d=l(c?.labelKey??"toolbar.image"),m={type:"button",className:`${hn(s)}${e?` ${e}`:""}`,"data-slot":"image.insert",disabled:!i,...i?{}:{"data-disabled":""},"aria-label":d,title:a??d,onMouseDown:$,onClick:r};if(o)return jsx(Q,{...m,children:n});let u=oe(c?.paths);return jsx("button",{...m,children:s?jsx(yn,{icon:u,label:d}):n??u})}ds.docxSlot="image.insert";var ci=Object.assign(ds,{docxSlot:"image.insert"});function Dw(e){return e&&/\s/.test(e)?e:void 0}var Bu=6,$b=6;function ps({slot:e,label:t,onInserted:o,className:n}){let r=A(),{isEnabled:i}=re(e),[a,l]=useState(null),[s,c]=useState({rows:1,cols:1}),d=useRef(null),m=useCallback((p,f)=>{if(!r||!i)return;let b={type:"insertTable",rows:p,cols:f};r.can(b).ok&&(r.exec(b),o(),r.focus());},[r,i,o]),u=useCallback(p=>{c(f=>{let b={rows:Math.min($b,Math.max(1,f.rows+(p.rows??0))),cols:Math.min(Bu,Math.max(1,p.toCol??f.cols+(p.cols??0)))};return l(b),queueMicrotask(()=>d.current?.querySelector(`[data-cell="${b.rows}x${b.cols}"]`)?.focus()),b});},[]),g=[];for(let p=1;p<=$b;p+=1){let f=[];for(let b=1;b<=Bu;b+=1){let y=!!a&&p<=a.rows&&b<=a.cols;f.push(jsx("button",{type:"button",role:"gridcell","data-cell":`${p}x${b}`,className:"docx-menubar__grid-cell",tabIndex:s.rows===p&&s.cols===b?0:-1,...y?{"data-filled":""}:{},"aria-label":`${b} \xD7 ${p}`,onMouseDown:$,onMouseEnter:()=>l({rows:p,cols:b}),onFocus:()=>l({rows:p,cols:b}),onClick:()=>m(p,b)},b));}g.push(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:Bu});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 Vr({slot:e="table.insert",className:t}){let{setOpenMenu:o}=et(),n=Pe(),r=useCallback(()=>o(null),[o]);return jsx(ps,{slot:e,label:n("toolbar.insertTable"),onInserted:r,className:t})}function Lw({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=re(chromeProbeForSlot("insert.watermark")),r=et(),i=Pe();if(t)return null;let a=te("insert.watermark"),l=i(a?.labelKey??"toolbar.watermark"),s=o&&!!r.onWatermarkDialog;return jsx(De,{slot:"insert.watermark",icon:oe(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onWatermarkDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var ms=Object.assign(Lw,{docxSlot:"insert.watermark"});var Ow={type:"openGoTo",fromShortcut:true};function zb(){let e=re(Ow),t=isApplePlatform()?"toolbar.goToBookmarkShortcutApple":"toolbar.goToBookmarkShortcut";return jsx(ao,{slotId:"insert.goToBookmark",...e.isEnabled?{shortcutKey:t}:{}})}function Bw({className:e,hidden:t}){return jsx(ao,{slotId:"insert.bookmark",shortcutKey:"toolbar.bookmarkShortcut",...e?{className:e}:{},...t?{hidden:t}:{}})}var fs=Object.assign(Bw,{docxSlot:"insert.bookmark"});var qw=e=>e;function gs({labelKey:e,shortcutKey:t,className:o,hidden:n}){let r=A(),i=et(),a=Pe();if(W(qw),n)return null;let l=toolbarCommandState(r,"text.link"),s=localizeDisabledReason(l.disabledReason,a),c=te("text.link"),d=r?.surface?.hyperlinks.linkAtCaret()!=null,m=a(e??(d?"hyperlinkPopup.editLink":"formattingBar.insertLink"));return jsx(De,{icon:oe(c?.paths),slot:"text.link",...t?{shortcut:a(t)}:{},disabled:!l.enabled,title:s??void 0,onSelect:()=>{i.setOpenMenu(null),runToolbarCommand(r,"text.link");},...o?{className:o}:{},children:m})}function De(e){let{icon:t,shortcut:o,disabled:n,title:r,active:i,selected:a,slot:l,onSelect:s,className:c,children:d}=e,m=e["data-value"],u=eo(),g=useId(),p=useContext(Kr),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:$,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 di({label:e,labelKey:t,className:o,hidden:n,children:r}){let i=Pe();if(n)return null;let a=e??(t===void 0?void 0:i(t));return 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 hs(e){if(e.slotId)return e.slotId;if(e.slot)return Kg(e.slot),e.slot;Ug();}function ao(e){return (e.slotId??e.slot)==="text.link"?jsx(gs,{...e}):jsx(eD,{...e})}function eD(e){let{labelKey:t,shortcutKey:o,className:n,hidden:r}=e,i=hs(e)??"",{execute:a,isActive:l,isEnabled:s,disabledReason:c,value:d}=re(i),{setOpenMenu:m}=et(),u=Pe();if(r||!i)return null;let g=te(i),p=u(t??g?.labelKey??i),f=chromeSlotIsToggle(i),b=["setAlignment","setParagraphDirection","setReviewDisplayMode"].includes(commandForSlot(i)?.type??"");return jsx(De,{slot:i,icon:oe(g?.paths),...o?{shortcut:u(o)}:{},disabled:!s,...c?{title:c}:{},...f?{active:l}:{},...b?{selected:true}:{},...d!==null?{"data-value":d}:{},onSelect:()=>{a(),m(null);},...n?{className:n}:{},children:p})}ao.docxMenuRow=true;function ui(e,t,o,n,r=()=>true){return Object.assign(({className:a,hidden:l})=>{let s=et(),c=Pe(),d=n(s),m=o&&r(s)?o:void 0;if(l)return null;let u=te(e),g=c(t??u?.labelKey??e);return jsx(De,{slot:e,icon:oe(u?.paths),...m?{shortcut:c(m)}:{},disabled:!d,onSelect:()=>{d?.(),s.setOpenMenu(null);},...a?{className:a}:{},children:g})},{docxSlot:e})}var Zu=ui("file.open","toolbar.open","toolbar.openShortcut",e=>e.onOpen),Ku=ui("file.save","toolbar.save","toolbar.saveShortcut",e=>e.onSave),qu=ui("file.exportMarkdown",void 0,void 0,e=>e.onExport?()=>e.onExport?.("markdown"):void 0),Uu=ui("file.exportPdf",void 0,void 0,e=>e.onExport?()=>e.onExport?.("pdf"):void 0),$u=ui("file.print",void 0,"toolbar.printShortcut",e=>e.onPrint,e=>e.printShortcut===true);function tD({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=re(chromeProbeForSlot("file.pageSetup")),r=et(),i=Pe();if(t)return null;let a=te("file.pageSetup"),l=i(a?.labelKey??"file.pageSetup"),s=o&&!!r.onPageSetup;return jsx(De,{slot:"file.pageSetup",icon:oe(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onPageSetup?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}function oD({className:e,hidden:t}){let{isEnabled:o,disabledReason:n}=re(chromeProbeForSlot("paragraph.dialog")),r=et(),i=Pe();if(t)return null;let a=te("paragraph.dialog"),l=i(a?.labelKey??"lineSpacing.options"),s=o&&!!r.onParagraphDialog;return jsx(De,{slot:"paragraph.dialog",icon:oe(a?.paths),disabled:!s,...n?{title:n}:{},onSelect:()=>{r.onParagraphDialog?.(),r.setOpenMenu(null);},...e?{className:e}:{},children:l})}var nD=Object.assign(oD,{docxSlot:"paragraph.dialog"}),zu=Object.assign(tD,{docxSlot:"file.pageSetup"});function rD({className:e,hidden:t}){let o=si(),n=et(),r=Pe();if(t)return null;let i=te("image.insert"),a=r(i?.labelKey??"toolbar.image"),l=o?.isEnabled??false,s=o?.disabledReason??null;return jsx(De,{slot:"image.insert",icon:oe(i?.paths),disabled:!l,...s?{title:s}:{},onSelect:()=>{o?.openFilePicker(),n.setOpenMenu(null);},...e?{className:e}:{},children:a})}var Vu=Object.assign(rD,{docxSlot:"image.insert"});function io({labelKey:e,label:t,paths:o,className:n,children:r}){let i=Pe(),[a,l]=useState(false),s=useRef(null),c=useRef(null),d=useId();t===void 0&&e===void 0&&$g();let m=t??i(e??""),[u,g]=useState(null);return useLayoutEffect(()=>{if(!a){g(null);return}let p=s.current,f=c.current,b=p?.ownerDocument.defaultView;!p||!f||!b||g(placeSubmenu(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:b.innerWidth,height:b.innerHeight},b.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&&ro(Jn(c.current),"first");})):(p.key===f.close||p.key==="Escape")&&a&&(p.preventDefault(),p.stopPropagation(),l(false),s.current?.focus());},onBlur:p=>{p.currentTarget.contains(p.relatedTarget)||l(false);},children:[jsxs("button",{ref:s,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?d:void 0,className:"docx-toolbar__menu-item docx-menubar__item",tabIndex:-1,...a?{"data-open":""}:{},onMouseDown:$,onFocus:()=>l(true),onClick:()=>l(true),children:[jsx("span",{className:"docx-menubar__item-icon","aria-hidden":"true",children:oe(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 b=Jn(f);p.key==="ArrowDown"?(p.preventDefault(),p.stopPropagation(),no(b,hostDocumentOf(f).activeElement,1)):p.key==="ArrowUp"&&(p.preventDefault(),p.stopPropagation(),no(b,hostDocumentOf(f).activeElement,-1));},children:jsx(Kr.Provider,{value:-1,children:r})}):null]})}function aD({entry:e}){let{isEnabled:t}=re(e.slot),o=te(e.slot);return t?jsx(io,{labelKey:e.labelKey??o?.labelKey??e.slot,paths:o?.paths,children:jsx(Vr,{slot:e.slot})}):jsx(ao,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{}})}function Qn({className:e}){return jsx("div",{role:"separator",className:`docx-toolbar__menu-separator${e?` ${e}`:""}`})}function pi({entry:e,children:t}){return e.kind==="separator"?jsx(Qn,{}):e.kind==="submenu"?jsx(io,{labelKey:e.labelKey,paths:e.paths,children:t??e.items.map((o,n)=>jsx(pi,{entry:o},n))}):e.slot==="file.open"?jsx(Zu,{}):e.slot==="file.save"?jsx(Ku,{}):e.slot==="file.exportMarkdown"?jsx(qu,{}):e.slot==="file.exportPdf"?jsx(Uu,{}):e.slot==="file.print"?jsx($u,{}):e.slot==="file.pageSetup"?jsx(zu,{}):e.slot==="paragraph.dialog"?jsx(nD,{}):e.slot==="insert.watermark"?jsx(ms,{}):e.slot==="insert.bookmark"?jsx(fs,{}):e.slot==="insert.goToBookmark"?jsx(zb,{}):e.slot==="image.insert"?jsx(Vu,{}):e.picker==="tableGrid"?jsx(aD,{entry:e}):jsx(ao,{slotId:e.slot,...e.labelKey?{labelKey:e.labelKey}:{},...e.shortcutKey?{shortcutKey:e.shortcutKey}:{}})}function Xb(e){if(!isValidElement(e))return null;let t=Wr(e,Xb);if(t!==null)return t;let o=e.type;return typeof o!="function"&&typeof o!="object"?null:typeof o.docxSlot=="string"?o.docxSlot:o.docxMenuRow===true?hs(e.props)??null:null}function iD(e,t){return e.kind==="item"?e.slot:e.kind==="submenu"?`submenu:${e.labelKey}`:`separator:${t}`}function jb(e,t,o){return es({entries:e??[],children:t,preset:o,keyOfEntry:iD,keyOfChild:Xb,childrenOfEntry:n=>n.kind==="submenu"?n.items:void 0,renderEntry:(n,r,i)=>jsx(pi,{entry:n,children:i})})}function lo({id:e,labelKey:t,label:o,icon:n,className:r,hidden:i,preset:a=true,children:l}){let{openMenu:s,setOpenMenu:c,activeMenu:d,opening:m}=et(),u=wb(),g=Pe(),p=useId(),f=useRef(null),b=useRef(null),y=useRef(false),v=useRef(false),x=CHROME_MENUS.find(w=>w.id===e),h=s===e,k=Fb(h&&e===Zr,f,b);if(i)return null;let E=o??g(t??x?.labelKey??e),C=Nb(u,e,d);if(C.skip)return null;if(C.asSubmenu)return jsx(io,{labelKey:t??x?.labelKey??e,label:E,children:jb(x?.entries,l,a)});let T=jb(x?.entries,l,a),S=C.iconOnly,P=()=>{c(null),f.current?.focus();};return jsxs("div",{role:"none",className:`docx-menubar__menu-root${r?` ${r}`:""}`,"data-menu":e,...C.rootAttributes,children:[jsxs("button",{ref:f,type:"button",role:"menuitem","aria-haspopup":"menu","aria-expanded":h,"aria-controls":h?p:void 0,className:"docx-menubar__trigger",disabled:m===true,tabIndex:C.tabStop?0:-1,...h?{"data-open":""}:{},...S?{"aria-label":E,title:E}:{},onMouseDown:$,onKeyDown:w=>{w.key==="ArrowDown"||w.key==="Enter"||w.key===" "||w.key==="ArrowUp"?(w.preventDefault(),y.current=true,c(e)):w.key==="Escape"&&h&&(w.preventDefault(),P());},onClick:()=>{if(v.current){v.current=false;return}c(h?null:e);},onMouseEnter:()=>{s!==null&&s!==e&&(v.current=true,c(e));},onMouseLeave:()=>{v.current=false;},children:[n?jsx("span",{className:"docx-menubar__trigger-icon","aria-hidden":"true",children:n}):null,S?null:E]}),h?jsx("div",{ref:w=>{b.current=w,w&&y.current&&(y.current=false,ro(Jn(w),"first"));},id:p,role:"menu","aria-label":E,style:k,className:"docx-toolbar__menu docx-menubar__menu",onKeyDown:w=>{let _=b.current;if(!_)return;let L=Jn(_),N=hostDocumentOf(_).activeElement;w.key==="ArrowDown"?(w.preventDefault(),no(L,N,1)):w.key==="ArrowUp"?(w.preventDefault(),no(L,N,-1)):w.key==="Home"?(w.preventDefault(),ro(L,"first")):w.key==="End"?(w.preventDefault(),ro(L,"last")):w.key==="Escape"?(w.preventDefault(),w.stopPropagation(),P()):w.key==="Tab"&&c(null);},children:jsx(Kr.Provider,{value:-1,children:T})}):null]})}function Gu(e){return Object.assign(o=>jsx(lo,{id:e,...o}),{docxMenu:e})}var ju=Gu("file"),Yu=Gu("format"),Xu=Gu("insert");var ys=createContext({close:()=>{},anchor:null,tocId:null,target:null,clipboardRefusal:null,reportClipboardRefusal:()=>{}});function $o(){return useContext(ys)}function Qb(){return useContext(ys).target}var cD=e=>e.pageSetup??null,dD=e=>e.editable;function er(){let e=A(),t=W(cD),o=W(dD),n=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 Qu=[{labelKey:"dialogs.pageSetup.pageSizes.letter",width:12240,height:15840},{labelKey:"dialogs.pageSetup.pageSizes.a4",width:11906,height:16838},{labelKey:"dialogs.pageSetup.pageSizes.legal",width:12240,height:20160},{labelKey:"dialogs.pageSetup.pageSizes.a3",width:16838,height:23811},{labelKey:"dialogs.pageSetup.pageSizes.a5",width:8391,height:11906},{labelKey:"dialogs.pageSetup.pageSizes.b5",width:9979,height:14175},{labelKey:"dialogs.pageSetup.pageSizes.executive",width:10440,height:15120}],rh=1440,mD=e=>Math.round(e/rh*100)/100,fD=e=>Math.round(e*rh);function gD(e,t){let o=Math.min(e,t),n=Math.max(e,t);return Qu.findIndex(r=>Math.abs(r.width-o)<20&&Math.abs(r.height-n)<20)}var oh=12240,nh=15840,xn=1440;function bD({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=Co(e,t),{pageSetup:s,isEnabled:c,apply:d}=er(),[m,u]=useState(oh),[g,p]=useState(nh),[f,b]=useState("portrait"),[y,v]=useState(xn),[x,h]=useState(xn),[k,E]=useState(xn),[C,T]=useState(xn),[S,P]=useState(false),[w,_]=useState("document"),L=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||(P(false),u(s?.pageWidthTwips??oh),p(s?.pageHeightTwips??nh),b(s?.orientation??"portrait"),v(s?.marginsTwips.top??xn),h(s?.marginsTwips.bottom??xn),E(s?.marginsTwips.left??xn),T(s?.marginsTwips.right??xn),_("document"),N.current=s===null?"loading":"yes");},[e,s]);let B=useCallback(q=>{let X=Qu[q];X&&(u(f==="landscape"?X.height:X.width),p(f==="landscape"?X.width:X.height));},[f]),F=useCallback(q=>{q!==f&&(b(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:x,marginLeftTwips:k,scope:w});P(!q),q&&t();},[c,l,d,m,g,f,y,C,x,k,w,t]);if(!e)return null;let R=gD(m,g),U=(q,X,ee)=>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:mD(X),onChange:O=>ee(Math.max(0,fD(Number(O.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:x,marginLeft:k,marginRight:C,scope:w},Y={pageWidth:u,pageHeight:p,orientation:F,marginTop:v,marginBottom:h,marginLeft:E,marginRight:T,scope:_},j={values:V,setValue(q,X){Y[q](X);},errors:S?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:D,cancel:t};return jsx(Fe,{kind:"pageSetup",className:o,style:n,panelRef:L,label:a("dialogs.pageSetup.title"),onClose:t,onKeyDown:q=>{q.key==="Escape"&&t(),q.key==="Enter"&&isHTMLElementNode(q.target)&&q.target.localName==="input"&&c&&(q.preventDefault(),D());},children:jsx(wo.Composition,{state:j,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:[Qu.map((q,X)=>jsx("option",{value:X,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")}),U("top",y,v),U("bottom",x,h),U("left",k,E),U("right",C,T),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=>_(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:r})})}var wo=yt();function hD(){return wo.useState()}var tr=Object.assign(bD,{Header:wo.Header,Title:wo.Title,Body:wo.Body,Footer:wo.Footer,Apply:wo.Apply,Cancel:wo.Cancel,Error:wo.Error,Field:wo.Field});var vD={contextualSpacing:null,keepNext:null,keepLines:null,widowControl:null,pageBreakBefore:null},CD=e=>{let t=e.formatting??null;if(!t)return null;let o=t.indent,n=t.paragraphFlags??vD;return {alignment:t.alignment==="both"?"justify":t.alignment??null,direction:t.direction??null,spaceBeforePt:t.spaceBeforePt??null,spaceAfterPt:t.spaceAfterPt??null,lineSpacing:t.lineSpacing??null,indentLeftTwips:o&&!o.mixed.left?o.left:null,indentRightTwips:o&&!o.mixed.right?o.right:null,indentFirstLineTwips:o&&!o.mixed.firstLine?o.firstLine:null,contextualSpacing:n.contextualSpacing,keepNext:n.keepNext,keepLines:n.keepLines,widowControl:n.widowControl,pageBreakBefore:n.pageBreakBefore,tabStops:t.tabStops??null,indentUnknown:!o,disagrees:{alignment:t.disagrees?.alignment??false,direction:t.disagrees?.direction??false,spaceBeforePt:t.disagrees?.spaceBeforePt??false,spaceAfterPt:t.disagrees?.spaceAfterPt??false,lineSpacing:t.disagrees?.lineSpacing??false,tabStops:t.disagrees?.tabStops??false,indentLeft:o?.mixed.left??false,indentRight:o?.mixed.right??false,indentFirstLine:o?.mixed.firstLine??false}}},TD=["alignment","direction","spaceBeforePt","spaceAfterPt","lineSpacing","tabStops","indentLeft","indentRight","indentFirstLine"],ED=(e,t)=>TD.every(o=>e.disagrees[o]===t.disagrees[o]),SD=(e,t)=>e===null||t===null?e===t:e.alignment===t.alignment&&e.direction===t.direction&&e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value&&e.indentLeftTwips===t.indentLeftTwips&&e.indentRightTwips===t.indentRightTwips&&e.indentFirstLineTwips===t.indentFirstLineTwips&&e.contextualSpacing===t.contextualSpacing&&e.keepNext===t.keepNext&&e.keepLines===t.keepLines&&e.widowControl===t.widowControl&&e.pageBreakBefore===t.pageBreakBefore&&ED(e,t)&&e.indentUnknown===t.indentUnknown&&e.tabStops?.length===t.tabStops?.length&&(e.tabStops??[]).every((o,n)=>o.positionTwips===t.tabStops?.[n]?.positionTwips&&o.alignment===t.tabStops?.[n]?.alignment&&(o.leader??"none")===(t.tabStops?.[n]?.leader??"none")),PD=e=>e.editable,kD={type:"setParagraphFormat",alignment:"left"};function ep(){let e=A(),t=W(CD,SD),o=W(PD),{isEnabled:n}=re(kD),r=o&&n,i=useCallback(a=>{if(!e)return false;let l={type:"setParagraphFormat",...a};return e.can(l).ok?e.exec(l).ok:false},[e]);return {format:t,isEnabled:r,apply:i}}function RD({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=Co(e,t),{format:s,isEnabled:c,apply:d}=ep(),[m,u]=useState("left"),[g,p]=useState("ltr"),[f,b]=useState(0),[y,v]=useState(0),[x,h]=useState("none"),[k,E]=useState(0),[C,T]=useState(0),[S,P]=useState(0),[w,_]=useState("multiple"),[L,N]=useState(1.08),[B,F]=useState(false),[D,R]=useState(false),[U,V]=useState(false),[Y,j]=useState(true),[q,X]=useState(false),[ee,O]=useState([]),[I,ie]=useState(false),[ge,K]=useState(0),[de,ke]=useState("left"),[Ze,at]=useState("none"),[Ce,Ye]=useState(NO_MIXED_FIELDS),[Wn,wt]=useState(false),qt=z=>a(Wn&&(z==="indentLeft"||z==="indentRight"||z==="special")?"dialogs.paragraph.notShown":"dialogs.paragraph.mixed"),Zn=useRef(NO_MIXED_FIELDS),se=useId(),[Ge,Ie]=useState(false),Kn=useRef(null),xo=useRef(false),Qt=useRef(null);useEffect(()=>{if(!e){xo.current=false;return}if(xo.current||s===null)return;let z=seedFields(s);u(z.alignment),p(z.direction),b(z.indentLeft),v(z.indentRight),h(z.special),E(z.specialBy),T(z.spaceBefore),P(z.spaceAfter),_(z.lineRule),N(z.lineValue),F(z.contextualSpacing),R(z.keepNext),V(z.keepLines),j(z.widowControl),X(z.pageBreakBefore),O(z.tabStops),ie(false);let xe=mixedFieldsOf(s);Ye(xe),wt(s.indentUnknown),K(0),ke("left"),at("none"),Zn.current=xe,Ie(false),Qt.current=z,xo.current=true;},[e,s]);let vo=useCallback(()=>{if(!c)return;if(!l()){t();return}let z=Qt.current,xe=z===null?null:changedFields(z,{alignment:m,direction:g,indentLeft:f,indentRight:y,special:x,specialBy:k,spaceBefore:C,spaceAfter:S,lineRule:w,lineValue:L,contextualSpacing:B,keepNext:D,keepLines:U,widowControl:Y,pageBreakBefore:q,tabStops:ee,clearedAllTabStops:I},Zn.current,Ce);if(xe===null){t();return}if(d(xe)){Ie(false),t();return}Ie(true);},[c,l,d,t,Ce,I,m,g,f,y,x,k,C,S,w,L,B,D,U,Y,q,ee]),an=useCallback(()=>{let z=Math.round(ge);return z<=0?false:(Ye(xe=>({...xe,tabStops:false})),O(withTabStop(ee,{positionTwips:z,alignment:de,...Ze!=="none"?{leader:Ze}:{}})),K(0),ke("left"),at("none"),true)},[ee,ge,de,Ze]);if(!e)return null;let Ht=z=>Ye(xe=>({...xe,[z]:false})),ce=(z,xe,cn,ht)=>jsxs("div",{"data-docx-part":"field","data-docx-field":ht,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsx("input",{id:`${se}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Ce[ht]?"":twipsToInches(xe),placeholder:Ce[ht]?qt(ht):void 0,onChange:Wa=>{Ht(ht),cn(inchesToTwips(Number(Wa.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitInches")})]}),be=(z,xe,cn,ht)=>jsxs("div",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-${z}`,children:a(`dialogs.paragraph.${z}`)}),jsx("input",{id:`${se}-${z}`,type:"number",className:"docx-dialog__input",min:0,step:1,value:Ce[ht]?"":xe,placeholder:Ce[ht]?qt(ht):void 0,onChange:Wa=>{Ht(ht),cn(Math.max(0,Number(Wa.target.value)||0));},"aria-label":a(`dialogs.paragraph.${z}`)}),jsx("span",{className:"docx-dialog__unit",children:a("dialogs.paragraph.unitPoints")})]}),Ne=(z,xe,cn)=>jsxs("label",{"data-docx-part":"field","data-docx-field":z,className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",checked:xe,ref:ht=>{ht&&(ht.indeterminate=Ce[z]);},onChange:ht=>{Ye(Wa=>({...Wa,[z]:false})),cn(ht.target.checked);}}),a(`dialogs.paragraph.${z}`)]}),Se={alignment:m,direction:g,indentLeft:f,indentRight:y,special:x,specialBy:k,spaceBefore:C,spaceAfter:S,lineRule:w,lineValue:L,contextualSpacing:B,keepNext:D,keepLines:U,widowControl:Y,pageBreakBefore:q,tabStops:ee,clearedAllTabStops:I},Et=z=>{let xe=Zn.current;z!==g&&!xe.direction&&!xe.alignment&&u(alignmentAfterDirectionChange),p(z);},ln={alignment:u,direction:Et,indentLeft:b,indentRight:v,special:h,specialBy:E,spaceBefore:T,spaceAfter:P,lineRule:_,lineValue:N,contextualSpacing:F,keepNext:R,keepLines:V,widowControl:j,pageBreakBefore:X,tabStops:O,clearedAllTabStops:ie},sn={values:Se,mixed:Ce,setValue(z,xe){ln[z](xe),z==="lineRule"?(Ht("lineSpacing"),N(xe===Qt.current?.lineRule?Qt.current.lineValue:xe==="multiple"?1.08:12)):z==="specialBy"?Ht("special"):z in Ce&&Ht(z);},errors:Ge?{form:a("dialogs.paragraph.refused")}:{},isEnabled:c,apply:vo,cancel:t};return jsx(Fe,{kind:"paragraph",className:o,style:n,panelRef:Kn,label:a("dialogs.paragraph.title"),onClose:t,onKeyDown:z=>{z.key==="Escape"&&t();let xe=isHTMLElementNode(z.target)&&(z.target.localName==="button"||z.target.localName==="select");if(z.key==="Enter"&&!xe){let cn=z.target;if(isHTMLElementNode(cn)&&cn.dataset.docxTabEntry!==void 0){an();return}c&&vo();}},children:jsx(Do.Composition,{state:sn,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:`${se}-alignment`,children:a("dialogs.paragraph.alignment")}),jsxs("select",{id:`${se}-alignment`,className:"docx-dialog__input",value:Ce.alignment?"":m,onChange:z=>{Ht("alignment"),u(z.target.value);},"aria-label":a("dialogs.paragraph.alignment"),children:[Ce.alignment?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:`${se}-direction`,children:a("dialogs.paragraph.direction")}),jsxs("select",{id:`${se}-direction`,className:"docx-dialog__input",value:Ce.direction?"":g,onChange:z=>{Ht("direction"),Et(z.target.value);},"aria-label":a("dialogs.paragraph.direction"),children:[Ce.direction?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")}),ce("beforeText",f,b,"indentLeft"),ce("afterText",y,v,"indentRight"),jsxs("div",{"data-docx-part":"field","data-docx-field":"special",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-special`,children:a("dialogs.paragraph.special")}),jsxs("select",{id:`${se}-special`,className:"docx-dialog__input",value:Ce.special?"":x,onChange:z=>{Ht("special"),h(z.target.value);},"aria-label":a("dialogs.paragraph.special"),children:[Ce.special?jsx("option",{value:"",children:qt("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")})]})]}),x!=="none"?jsxs("div",{"data-docx-part":"field","data-docx-field":"specialBy",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-by`,children:a("dialogs.paragraph.by")}),jsx("input",{id:`${se}-by`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:Ce.special?"":twipsToInches(k),placeholder:Ce.special?qt("special"):void 0,onChange:z=>{Ht("special"),E(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")}),ee.length===0?jsx("div",{className:"docx-dialog__note",children:a(Ce.tabStops?"dialogs.paragraph.tabMixed":"dialogs.paragraph.tabEmpty")}):ee.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(ee.filter(xe=>xe!==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:`${se}-tabPosition`,children:a("dialogs.paragraph.tabPosition")}),jsx("input",{id:`${se}-tabPosition`,type:"number",className:"docx-dialog__input",min:0,step:.1,value:twipsToInches(ge),onChange:z=>K(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:`${se}-tabAlignment`,children:a("dialogs.paragraph.tabAlignment")}),jsxs("select",{id:`${se}-tabAlignment`,className:"docx-dialog__input",value:de,onChange:z=>ke(z.target.value),"aria-label":a("dialogs.paragraph.tabAlignment"),"data-docx-tab-entry":"",children:[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:`${se}-tabLeader`,children:a("dialogs.paragraph.tabLeader")}),jsxs("select",{id:`${se}-tabLeader`,className:"docx-dialog__input",value:Ze,onChange:z=>at(z.target.value),"aria-label":a("dialogs.paragraph.tabLeader"),"data-docx-tab-entry":"",children:[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:an,children:a("dialogs.paragraph.tabAdd")}),jsx("button",{type:"button",className:"docx-dialog__button",onClick:()=>{Ye(z=>({...z,tabStops:false})),ie(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")}),be("spaceBefore",C,T,"spaceBefore"),be("spaceAfter",S,P,"spaceAfter"),jsxs("div",{"data-docx-part":"field","data-docx-field":"lineRule",className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${se}-lineSpacing`,children:a("dialogs.paragraph.lineSpacing")}),jsxs("select",{id:`${se}-lineSpacing`,className:"docx-dialog__input",value:Ce.lineSpacing?"":w,onChange:z=>{let xe=z.target.value;Ht("lineSpacing"),_(xe),N(xe===Qt.current?.lineRule?Qt.current.lineValue:xe==="multiple"?1.08:12);},"aria-label":a("dialogs.paragraph.lineSpacing"),children:[Ce.lineSpacing?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:`${se}-at`,children:a("dialogs.paragraph.at")}),jsx("input",{id:`${se}-at`,type:"number",className:"docx-dialog__input",min:.01,step:w==="multiple"?.01:1,value:Ce.lineSpacing?"":L,disabled:Ce.lineSpacing,onChange:z=>{let xe=z.target.value.trim();N(xe===""?w==="multiple"?1.08:12:Number(xe)||0);},"aria-label":a("dialogs.paragraph.at")}),jsx("span",{className:"docx-dialog__unit",children:w==="multiple"?"":a("dialogs.paragraph.unitPoints")})]}),Ne("contextualSpacing",B,F),jsx("div",{className:"docx-dialog__section-label",children:a("dialogs.paragraph.pagination")}),Ne("keepNext",D,R),Ne("widowControl",Y,j),Ne("keepLines",U,V),Ne("pageBreakBefore",q,X)]})]})}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("span",{role:"alert","data-docx-part":"error",className:"docx-dialog__error",children:Ge?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:vo,children:a("dialogs.paragraph.ok")})]})]}),children:r})})}var Do=yt();function MD(){return Do.useState()}var Vo=Object.assign(RD,{Header:Do.Header,Title:Do.Title,Body:Do.Body,Footer:Do.Footer,Apply:Do.Apply,Cancel:Do.Cancel,Error:Do.Error,Field:Do.Field});var so=e=>e.isLoading||e.parseError!==null||e.pageSetup==null;var np=["ASAP","CONFIDENTIAL","COPY","DO NOT COPY","DRAFT","ORIGINAL","PERSONAL","SAMPLE","TOP SECRET","URGENT"],rp=[null,.5,1,1.5,2,5],ap=[null,36,40,44,48,54,60,66,72,80,90,96,105,120,144],hh="image/png,image/jpeg,image/gif,image/bmp,image/webp",ip={kind:"none",imageData:null,imageName:null,scale:null,washout:true,text:"DRAFT",fontFamily:"Calibri",fontSizePt:null,bold:false,italic:false,transparency:.5,color:"C0C0C0",layout:"diagonal"},Ts=/^[0-9A-Fa-f]{6}$/;function yh(e,t){let o={...ip};return e?e.kind==="image"?{...o,kind:t?.imageData?"picture":"none",imageData:t?.imageData??null,scale:t?.scale??null,washout:e.washout??t?.washout??true}:{...o,kind:"text",text:e.text??o.text,fontFamily:e.fontFamily??o.fontFamily,fontSizePt:e.fontSizePt??null,bold:e.bold??false,italic:e.italic??false,transparency:e.transparency??o.transparency,color:e.color&&Ts.test(e.color)?e.color.toUpperCase():o.color,layout:e.layout??o.layout}:o}function xh(e){if(e.kind==="none")return null;if(e.kind==="picture")return e.imageData?{imageData:e.imageData,scale:e.scale,washout:e.washout}:void 0;if(e.text.trim()!=="")return {text:e.text,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,color:e.color,transparency:e.transparency,layout:e.layout}}var vh=e=>`#${Ts.test(e)?e.toLowerCase():"c0c0c0"}`;function Ch(e){let t=e.startsWith("#")?e.slice(1):e;return Ts.test(t)?t.toUpperCase():null}var lp=e=>Math.round(Math.min(1,Math.max(0,e))*100);function sp(e,t){let o=Number(e);return e.trim()===""||!Number.isFinite(o)?t:Math.min(100,Math.max(0,Math.round(o)))/100}function Th(e,t){return e===t?true:!e||!t?false:e.kind===t.kind&&e.text===t.text&&e.fontFamily===t.fontFamily&&e.fontSizePt===t.fontSizePt&&e.bold===t.bold&&e.italic===t.italic&&e.color===t.color&&e.transparency===t.transparency&&e.layout===t.layout&&e.washout===t.washout}function Eh(e,t){return e!==null&&t.kind==="none"?null:t}function Sh(e,t){return e.kind!==t.kind?false:e.kind==="none"?true:e.kind==="picture"?e.imageData===t.imageData&&e.scale===t.scale&&e.washout===t.washout:e.text===t.text&&e.fontFamily===t.fontFamily&&e.fontSizePt===t.fontSizePt&&e.bold===t.bold&&e.italic===t.italic&&e.color.toUpperCase()===t.color.toUpperCase()&&e.transparency===t.transparency&&e.layout===t.layout}var Ph=(e,t)=>t.includes(e)?e:"",ID={pageWidthTwips:12240,pageHeightTwips:15840,marginsTwips:{top:1440,right:1440,bottom:1440,left:1440}};function Es(e){let t=e&&e.pageWidthTwips>0&&e.pageHeightTwips>0?e:null,{pageWidthTwips:o,pageHeightTwips:n,marginsTwips:r}=t??ID,i=o/20,a=n/20,l=Math.max(72,(o-r.left-r.right)/20),s=Math.max(72,(n-r.top-r.bottom)/20);return {width:i,height:a,area:{x:r.left/20,y:r.top/20,width:l,height:s}}}var mh=12,fh=[.55,1,1,.9,0,1,1,.6,0,1,.95,1,.45];function kh(e){let{area:t}=e,o=36,n=[];for(let r=0,i=t.y;i+mh<=t.y+t.height;r++){let a=fh[r%fh.length];a>0&&n.push({x:t.x,y:i,width:t.width*a,height:mh}),i+=o;}return n}var wh="contrast(0.157068) brightness(1.91)",cp=100,Go=e=>Math.round(e*100)/100,Dh=e=>({cx:e.area.x+e.area.width/2,cy:e.area.y+e.area.height/2});function Rh(e,t=Es(null)){if(e.kind!=="text")return null;let o=e.text.trim();if(o==="")return null;let n=watermarkShapeBox({text:o,fontFamily:e.fontFamily,fontSizePt:e.fontSizePt,bold:e.bold,italic:e.italic,layout:e.layout},t.area);if(!n)return null;let{cx:r,cy:i}=Dh(t);return {text:o,fontFamily:`"${e.fontFamily.replace(/["\\]/g,"")}", sans-serif`,fontWeight:e.bold?"bold":"normal",fontStyle:e.italic?"italic":"normal",fill:`#${Ts.test(e.color)?e.color.toUpperCase():"C0C0C0"}`,opacity:Go(1-Math.min(1,Math.max(0,e.transparency))),box:{x:Go(r-n.width/2),y:Go(i-n.height/2),width:Go(n.width),height:Go(n.height)},rotation:e.layout==="diagonal"?-45:0}}var gh=new WeakMap;function ND(e){if(!e)return null;let t=gh.get(e);if(t===void 0){try{t=e.createElement("canvas").getContext("2d");}catch{t=null;}gh.set(e,t);}return t}function Mh(e,t){let o=cp,n=ND(t);if(n){n.font=`${e.fontStyle} ${e.fontWeight} ${o}px ${e.fontFamily}`;let r=n.measureText(e.text),i=-(r.actualBoundingBoxLeft??0),a=r.actualBoundingBoxRight??r.width,l=-(r.actualBoundingBoxAscent??0),s=r.actualBoundingBoxDescent??0;if(a>i&&s>l)return {left:i,right:a,top:l,bottom:s}}return {left:0,right:.55*o*Array.from(e.text).length,top:-0.7*o,bottom:0}}function _h(e,t){let{x:o,y:n,width:r,height:i}=e.box,a=r>4*7.2?7.2:0,l=i>4*3.6?3.6:0,s=(r-2*a)/(t.right-t.left),c=(i-2*l)/(t.bottom-t.top),d=o+a-t.left*s,m=n+l-t.top*c,u=p=>String(Math.round(p*1e4)/1e4),g=`matrix(${u(s)} 0 0 ${u(c)} ${u(d)} ${u(m)})`;return e.rotation?`rotate(${e.rotation} ${u(o+r/2)} ${u(n+i/2)}) ${g}`:g}function Ih(e,t=Es(null)){if(e.kind!=="picture"||!e.imageData)return null;let o=watermarkShapeBox({imageData:e.imageData,scale:e.scale},t.area);if(!o)return null;let{cx:n,cy:r}=Dh(t);return {x:Go(n-o.width/2),y:Go(r-o.height/2),width:Go(o.width),height:Go(o.height)}}var FD=e=>e.editable,LD={ok:false,code:"unsupported",reason:"editor is not ready"};function up(){let e=A(),t=useCallback(l=>e?.getWatermark()??null,[e]),o=W(t,Th),n=W(FD),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}):LD,[e]);return useMemo(()=>({watermark:o,isEnabled:r,read:i,apply:a}),[o,r,i,a])}var WD=e=>e.pageSetup??null,co=yt(),ZD=co.part("preview");function Hh(){return co.useState()}var Fh=e=>`${Math.round(e*100)}%`;function KD(e){let[t,o]=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 qD({className:e,style:t,"data-docx-part":o,...n}){let{values:r}=Hh(),i=A(),a=W(WD),l=useMemo(()=>Es(a),[a]),s=KD(r.kind==="picture"?r.imageData:null),c=Rh(r,l),d=s?Ih(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:cp,fontWeight:c.fontWeight,fontStyle:c.fontStyle,fill:c.fill,fillOpacity:c.opacity,transform:_h(c,Mh(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:wh}:void 0}):null,kh(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 UD({open:e,onClose:t,presets:o=np,className:n,style:r,children:i,preset:a=true}){let{t:l}=H(),s=A(),c=Co(e,t),{isEnabled:d,read:m,apply:u}=up(),g=W(so),[p,f]=useState({...ip}),[b,y]=useState([]),[v,x]=useState(null),[h,k]=useState(false),[E,C]=useState(0),T=useRef(null),S=useRef(null),P=useRef(null),w=useId(),_=useRef(false);useEffect(()=>{if(!e||g||!s){_.current=false;return}if(_.current)return;_.current=true;let I=s.getWatermark(),ie=yh(I,m());T.current=Eh(I,ie),f(ie),y(s.getAvailableFonts()),x(null),k(false),C(ge=>ge+1);},[e,g,s,m]),useEffect(()=>{E!==0&&S.current?.querySelector(`input[name="${w}-kind"]:checked`)?.focus({preventScroll:true});},[E,w]);let L=useCallback((I,ie)=>{x(null),f(ge=>({...ge,[I]:ie}));},[]),N=xh(p),B=d&&N!==void 0,F=useCallback(()=>{if(!B||N===void 0)return;if(!c()){t();return}if(T.current&&Sh(T.current,p)){t();return}let I=u(N);I.ok?t():x(I.reason);},[B,N,p,c,u,t]),D=useCallback(I=>{I&&(k(false),I.arrayBuffer().then(ie=>{f(ge=>({...ge,kind:"picture",imageData:new Uint8Array(ie),imageName:I.name})),x(null);}).catch(()=>k(true)));},[]);if(!e)return null;let R=p.kind==="picture",U=p.kind==="text",V=b.includes(p.fontFamily)?b:[p.fontFamily,...b],Y=p.imageData?p.imageName??l("dialogs.watermark.currentPicture"):l("dialogs.watermark.noPictureSelected"),j=v!==null?l("dialogs.watermark.refused"):null,q=(I,ie,ge)=>jsxs("label",{"data-docx-part":"field","data-docx-field":I,className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"radio",name:`${w}-kind`,checked:p.kind===ie,onChange:()=>L("kind",ie)}),jsx("span",{id:`${w}-${I}-label`,children:ge})]}),X=(I,ie,ge)=>jsxs("div",{"data-docx-part":"field","data-docx-field":I,className:"docx-dialog__row",children:[jsx("label",{className:"docx-dialog__label",htmlFor:`${w}-${I}`,children:ie}),ge]}),ee=(I,ie,ge)=>jsxs("label",{"data-docx-part":"field","data-docx-field":I,className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"checkbox",disabled:!ge,checked:p[I],onChange:K=>L(I,K.target.checked)}),jsx("span",{children:ie})]}),O={values:p,setValue:L,errors:j?{form:j}:{},isEnabled:B,apply:F,cancel:t};return jsx(Fe,{kind:"watermark",className:n,style:r,panelRef:S,label:l("dialogs.watermark.title"),onClose:t,onKeyDown:I=>{let ie=I.target;I.key==="Enter"&&isHTMLElementNode(ie)&&ie.localName==="input"&&(ie.type==="text"||ie.type==="number")&&B&&(I.preventDefault(),F());},children:jsx(co.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(qD,{"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:()=>{L("kind","picture"),P.current?.click();},children:l("dialogs.watermark.selectPicture")}),jsx("span",{className:"docx-dialog__hint","data-docx-watermark-picture":"",children:h?l("dialogs.watermark.pictureFailed"):Y}),jsx("input",{ref:P,type:"file",accept:hh,hidden:true,"aria-label":l("dialogs.watermark.selectPicture"),onChange:I=>{let ie=I.target.files?.[0];I.target.value="",D(ie);}})]}),X("scale",l("dialogs.watermark.scale"),jsxs("select",{id:`${w}-scale`,className:"docx-dialog__select",disabled:!R,value:p.scale===null?"auto":String(p.scale),onChange:I=>L("scale",I.target.value==="auto"?null:Number(I.target.value)),children:[rp.map(I=>jsx("option",{value:I===null?"auto":String(I),children:I===null?l("dialogs.watermark.auto"):Fh(I)},String(I))),p.scale!==null&&!rp.includes(p.scale)?jsx("option",{value:String(p.scale),children:Fh(p.scale)}):null]})),ee("washout",l("dialogs.watermark.washout"),R)]}),q("textWatermark","text",l("dialogs.watermark.text")),jsxs("div",{className:"docx-dialog__section docx-dialog__section--indented",role:"group","aria-labelledby":`${w}-textWatermark-label`,children:[X("preset",l("dialogs.watermark.preset"),jsxs("select",{id:`${w}-preset`,className:"docx-dialog__select",disabled:!U,value:Ph(p.text,o),onChange:I=>{I.target.value!==""&&L("text",I.target.value);},children:[jsx("option",{value:"",children:l("dialogs.watermark.custom")}),o.map(I=>jsx("option",{value:I,children:I},I))]})),X("text",l("dialogs.watermark.textLabel"),jsx("input",{id:`${w}-text`,type:"text",className:"docx-dialog__input",disabled:!U,maxLength:256,value:p.text,onChange:I=>L("text",I.target.value)})),X("fontFamily",l("dialogs.watermark.font"),jsx("select",{id:`${w}-fontFamily`,className:"docx-dialog__select",disabled:!U,value:p.fontFamily,onChange:I=>L("fontFamily",I.target.value),children:V.map(I=>jsx("option",{value:I,children:I},I))})),X("fontSizePt",l("dialogs.watermark.size"),jsxs("select",{id:`${w}-fontSizePt`,className:"docx-dialog__select",disabled:!U,value:p.fontSizePt===null?"auto":String(p.fontSizePt),onChange:I=>L("fontSizePt",I.target.value==="auto"?null:Number(I.target.value)),children:[ap.map(I=>jsx("option",{value:I===null?"auto":String(I),children:I===null?l("dialogs.watermark.auto"):String(I)},String(I))),p.fontSizePt!==null&&!ap.includes(p.fontSizePt)?jsx("option",{value:String(p.fontSizePt),children:p.fontSizePt}):null]})),jsxs("div",{className:"docx-dialog__row",children:[ee("bold",l("dialogs.watermark.bold"),U),ee("italic",l("dialogs.watermark.italic"),U)]}),X("transparency",l("dialogs.watermark.transparency"),jsxs(Fragment,{children:[jsx("input",{type:"range",className:"docx-dialog__range",min:0,max:100,step:1,disabled:!U,"aria-label":l("dialogs.watermark.transparency"),value:lp(p.transparency),onChange:I=>L("transparency",sp(I.target.value,p.transparency))}),jsx("input",{id:`${w}-transparency`,type:"number",className:"docx-dialog__input docx-dialog__input--narrow",min:0,max:100,step:1,disabled:!U,value:lp(p.transparency),onChange:I=>L("transparency",sp(I.target.value,p.transparency))}),jsx("span",{className:"docx-dialog__unit",children:"%"})]})),X("color",l("dialogs.watermark.color"),jsx("input",{id:`${w}-color`,type:"color",className:"docx-dialog__color",disabled:!U,value:vh(p.color),onChange:I=>{let ie=Ch(I.target.value);ie&&L("color",ie);}})),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(I=>jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"radio",name:`${w}-layout`,disabled:!U,checked:p.layout===I,onChange:()=>L("layout",I)}),jsx("span",{children:l(`dialogs.watermark.${I}`)})]},I))]})]})]})]})}),jsxs("div",{"data-docx-part":"footer",className:"docx-dialog__footer",children:[jsx("span",{"data-docx-part":"error",role:"alert",className:"docx-dialog__error",...v?{title:v}:{},children:j}),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 or=Object.assign(UD,{Header:co.Header,Title:co.Title,Body:co.Body,Preview:ZD,Footer:co.Footer,Apply:co.Apply,Cancel:co.Cancel,Error:co.Error,Field:co.Field});var Ps={ok:false,code:"unsupported",reason:"editor is not ready"},zD=Object.freeze([]);function fp(e,t){return e.length===t.length&&e.every((o,n)=>o.name===t[n].name&&o.order===t[n].order&&o.story===t[n].story&&o.empty===t[n].empty&&o.atSelection===t[n].atSelection&&o.duplicates===t[n].duplicates&&o.hidden===t[n].hidden&&o.place===t[n].place)}function gp(){let e=A(),t=useCallback(c=>e?.query({type:"bookmarks"})??zD,[e]),o=W(t,fp),n=useCallback(c=>c.editable&&e!==null&&e.can({type:"insertBookmark",name:"Bookmark"}).ok,[e]),r=W(n),i=useCallback(c=>e?e.exec({type:"insertBookmark",name:c}):Ps,[e]),a=useCallback(c=>e?e.exec({type:"deleteBookmark",name:c}):Ps,[e]),l=useCallback(c=>e?e.exec({type:"goToBookmark",name:c}):Ps,[e]),s=useCallback(c=>e?e.exec({type:"keepFirstBookmark",name:c}):Ps,[e]);return useMemo(()=>({bookmarks:o,isWritable:r,insert:i,remove:a,goTo:l,keepFirst:s}),[o,r,i,a,l,s])}var Oh={empty:"dialogs.bookmark.nameEmpty",tooLong:"dialogs.bookmark.nameTooLong",invalidStart:"dialogs.bookmark.nameInvalidStart",invalidCharacter:"dialogs.bookmark.nameInvalidCharacter"};function JD(e){return e.open?jsx(QD,{...e}):null}function QD({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=Co(e,t),{bookmarks:s,isWritable:c,insert:d,remove:m,goTo:u,keepFirst:g}=gp(),[p,f]=useState(()=>bookmarkDialogInitialName(s)),[b,y]=useState("name"),[v,x]=useState(false),[h,k]=useState(false),[E,C]=useState(false),[T,S]=useState(false),P=useRef(null),w=useRef(null),_=useId(),L=useId(),N=useId(),B=bookmarkDialogRows(s,{sortBy:b,showHidden:v}),F=bookmarkDialogNameState(s,p,c),D=F.problem&&!F.existing&&(E||p.length>0)?F.problem:null,R=F.existing?.duplicates??0,U=h?a("dialogs.bookmark.refused"):D?a(Oh[D]):R>0?a("dialogs.bookmark.duplicates",{count:R}):F.existing&&F.canAdd?a("dialogs.bookmark.nameExists"):null,V=useCallback(()=>{if(C(true),!F.canAdd)return;if(!l()){t();return}let O=d(p);k(!O.ok),O.ok&&t();},[F.canAdd,l,d,p,t]),Y=useCallback(()=>{if(!F.canDelete||!F.existing)return;let O=m(F.existing.name);k(!O.ok),O.ok&&f("");},[F,m]),j=useCallback(()=>{if(!F.canGoTo||!F.existing)return;let O=u(F.existing.name);k(!O.ok),O.ok&&S(true);},[F,u]),q=useCallback(()=>{let O=F.existing;!O||!c||k(!g(O.name).ok);},[F.existing,c,g]),X=F.existing?.name??"";useLayoutEffect(()=>{!X&&w.current&&(w.current.selectedIndex=-1);});let ee={values:{name:p,sortBy:b,showHidden:v},setValue(O,I){O==="name"?f(I):O==="sortBy"?y(I):x(I),k(false);},errors:D?{name:a(Oh[D])}:h?{form:a("dialogs.bookmark.refused")}:{},isEnabled:F.canAdd,apply:V,cancel:t,rows:B,canDelete:F.canDelete,canGoTo:F.canGoTo,duplicates:R,remove:Y,goTo:j,keepFirst:q};return jsx(Fe,{kind:"bookmark",className:o,style:n,panelRef:P,label:a("dialogs.bookmark.title"),onClose:t,onKeyDown:O=>{O.key==="Enter"&&!O.nativeEvent.isComposing&&O.keyCode!==229&&isHTMLElementNode(O.target)&&O.target.localName==="input"&&O.target.getAttribute("type")==="text"&&(O.preventDefault(),V());},children:jsx(Ot.Composition,{state:ee,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:_,children:a("dialogs.bookmark.name")}),jsx("input",{id:_,type:"text",className:"docx-dialog__input",value:p,maxLength:40,autoComplete:"off",spellCheck:false,"aria-invalid":D?true:void 0,"aria-describedby":L,onChange:O=>ee.setValue("name",O.target.value)})]}),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:X,"aria-label":a("dialogs.bookmark.list"),onChange:O=>ee.setValue("name",O.target.value),onDoubleClick:j,children:B.map(O=>jsx("option",{value:O.name,children:O.name},O.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(O=>jsxs("label",{className:"docx-dialog__checkbox-row",children:[jsx("input",{type:"radio",name:N,checked:b===O,onChange:()=>ee.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:v,onChange:O=>ee.setValue("showHidden",O.target.checked)}),a("dialogs.bookmark.showHidden")]})}),jsxs("div",{className:"docx-dialog__row docx-bookmark-dialog__status",children:[jsx("span",{id:L,"data-docx-part":"error",role:"status",className:D||h?"docx-dialog__error":"docx-dialog__hint",children:U}),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:Y,children:a("dialogs.bookmark.delete")}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"goto",disabled:!F.canGoTo,onClick:j,children:a("dialogs.bookmark.goTo")}),jsx("button",{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t,children:a(T?"common.close":"common.cancel")})]})]}),children:r})})}var Ot=yt();function eR(){return Ot.useState()}var mi=Object.assign(JD,{Header:Ot.Header,Title:Ot.Title,Body:Ot.Body,Footer:Ot.Footer,Apply:Ot.Apply,Cancel:Ot.Cancel,Error:Ot.Error,Field:Ot.Field,Delete:Ot.part("delete"),GoTo:Ot.part("goto"),KeepFirst:Ot.part("keepfirst")});var Wh=SPLIT_CELL_FALLBACK_MAX;function sR(e){return e.open?jsx(dR,{...e}):null}var cR=e=>e;function dR({open:e,onClose:t,className:o,style:n,children:r,preset:i=true}){let{t:a}=H(),l=A(),s=Co(e,t),c=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,b]=useState(null),y=useId(),v=useId(),x=useId(),{counts:h,problem:k}=readSplitCellCounts(m,g,c),E=h?.cols??null,C=h?.rows??null;W(cR);let T=l&&h?l.can({type:"splitCell",...h}):null,S=k?.kind==="range"?a("dialogs.splitCell.range",{max:k.max}):k?.kind==="oneCell"?a("dialogs.splitCell.oneCell"):T&&!T.ok?localizeDisabledReason(T.reason??null,a):null,P=T?.ok===true,w=f??S,_=k?.kind==="range"?k.field:null,L=useCallback(()=>{if(!P||!l)return;if(!s()){t();return}let F=l.exec({type:"splitCell",rows:C,cols:E});F.ok?t():b(localizeDisabledReason(F.reason??null,a));},[P,l,s,t,C,E,a]),N={values:{columns:m,rows:g},setValue(F,D){F==="columns"?u(D):p(D),b(null);},errors:w?{form:w}:{},isEnabled:P,apply:L,cancel:t,limits:c},B=(F,D,R,U,V)=>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:U,"aria-invalid":_===F?true:void 0,"aria-describedby":x,onChange:Y=>N.setValue(F,Y.target.value)})]});return jsx(Fe,{kind:"splitCell",className:o,style:n,label:a("table.splitCell"),onClose:t,onKeyDown:F=>{F.key==="Enter"&&!F.nativeEvent.isComposing&&F.keyCode!==229&&isHTMLElementNode(F.target)&&F.target.localName==="input"&&(F.preventDefault(),L());},children:jsx(Ro.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??Wh),B("rows",v,"dialogs.splitCell.rows",g,c?.maxRows??Wh),jsx("div",{className:"docx-dialog__row",children:jsx("span",{id:x,"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:!P,onClick:L,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 Ro=yt();function uR(){return Ro.useState()}var fi=Object.assign(sR,{Header:Ro.Header,Title:Ro.Title,Body:Ro.Body,Footer:Ro.Footer,Apply:Ro.Apply,Cancel:Ro.Cancel,Error:Ro.Error,Field:Ro.Field});var Zh=createContext(void 0),Kh=Zh.Provider;function tt(){let e=useContext(Zh),{t}=H();return useCallback((o,n)=>{let r=e?.(o,n);return r===void 0||r===o?t(o,n):r},[e,t])}var Mo=yt();function yR(){return Mo.useState()}function xR({session:e,...t}){let[o,n]=useState(e),[r,i]=useState(0);return o!==e&&(n(e),i(r+1)),e?jsx(vR,{session:e,...t},r):null}function vR({session:e,children:t,preset:o,className:n,style:r}){let i=tt(),a=W(()=>e.canApply()),[l,s]=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 v=()=>d(true);return e.signal.addEventListener("abort",v),e.signal.aborted&&v(),()=>e.signal.removeEventListener("abort",v)},[e]);let g=()=>{if(e.signal.aborted)return;let v=Number.isInteger(l.maxLength)&&l.maxLength>=0&&l.maxLength<=32767&&e.apply(l.defaultText,{type:l.type,maxLength:l.maxLength,format:l.format,enabled:l.enabled});u(!v);},p={values:l,setValue(v,x){s(h=>({...h,[v]:x,...v==="type"?{format:""}:{}})),u(false);},errors:m?{form:i("textFormField.invalidOptions")}:{},isEnabled:!c&&a,apply:g,cancel:e.cancel};if(c)return null;let f=TEXT_FORM_FORMATS[l.type]??[],b={Uppercase:"textFormField.uppercase",Lowercase:"textFormField.lowercase","First capital":"textFormField.firstCapital","Title case":"textFormField.titleCase"},y=(v,x)=>jsxs("label",{"data-docx-part":"field","data-docx-field":v,className:"docx-dialog__row",children:[jsx("span",{className:"docx-dialog__label",children:i(`textFormField.${v}`)}),x]});return jsx(Fe,{kind:"textFormField",className:n,style:r,label:i("textFormField.title"),onClose:e.cancel,dismissOutside:false,sessionSignal:e.signal,restoreFocus:false,onKeyDown:v=>{v.key==="Escape"&&(v.preventDefault(),e.cancel()),v.key==="Enter"&&isHTMLElementNode(v.target)&&v.target.localName==="input"&&(v.preventDefault(),g());},children:jsx(Mo.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:v=>p.setValue("defaultText",v.target.value)})),y("type",jsxs("select",{className:"docx-dialog__input",value:l.type,onChange:v=>p.setValue("type",v.target.value),children:[["regular","number","date"].map(v=>jsx("option",{value:v,children:i(`textFormField.${v}`)},v)),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:v=>p.setValue("maxLength",v.target.valueAsNumber)})),y("format",jsxs("select",{className:"docx-dialog__input",value:l.format,onChange:v=>p.setValue("format",v.target.value),children:[f.map(v=>jsx("option",{value:v,children:b[v]?i(b[v]):v||i("textFormField.noFormat")},v)),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:v=>p.setValue("enabled",v.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 bi=Object.assign(xR,{Header:Mo.Header,Title:Mo.Title,Body:Mo.Body,Footer:Mo.Footer,Apply:Mo.Apply,Cancel:Mo.Cancel,Error:Mo.Error,Field:Mo.Field});var $h=createContext(null),_o=()=>useContext($h);function zh({popups:e,children:t}){let o=A(),n=Gd(),[r,i]=useState(null),[a,l]=useState(null),[s,c]=useState(null),[d,m]=useState(null),u=useRef(d);u.current=d;let[g,p]=useState(null),f=useRef(g);f.current=g;let b=useRef(e);b.current=e;let y=useRef(null),v=useRef(s);v.current=s;let x=()=>l(null);useEffect(()=>{if(a!==null)return;let T=y.current;y.current=null,T?.isConnected&&T.focus({preventScroll:true});},[a]),useEffect(()=>{if(o)return o.setTextFormFieldChrome({onRequest(T){if(b.current?.textFormField===false){T.cancel();return}u.current?.cancel(),f.current?.cancel(),l(null),c(T),T.signal.addEventListener("abort",()=>c(S=>S===T?null:S),{once:true});}},{fallback:true})},[o]),useEffect(()=>{if(!o||!r&&e?.revisionMarkup!==false)return;let T=o.setRevisionMarkupChrome({onRequest(S){if(b.current?.revisionMarkup===false){S.cancel();return}v.current?.cancel(),f.current?.cancel(),l(null),m(S),S.signal.addEventListener("abort",()=>m(P=>P===S?null:P),{once:true});}},{fallback:true});return ()=>{u.current?.cancel(),T();}},[o,r,e?.revisionMarkup===false]),useEffect(()=>{if(!o||!r&&e?.compareDocuments!==false)return;let T=o.setCompareDocumentsChrome({onRequest(S){if(b.current?.compareDocuments===false){S.cancel();return}v.current?.cancel(),u.current?.cancel(),l(null),p(S),S.signal.addEventListener("abort",()=>p(P=>P===S?null:P),{once:true});}},{fallback:true});return ()=>{f.current?.cancel(),T();}},[o,r,e?.compareDocuments===false]),useEffect(()=>{l(null),c(null),m(null),p(null);},[o,n]);let h=e?.bookmark===false;useEffect(()=>{if(!(!o||!r||h))return o.setBookmarkChrome({onRequest(){v.current?.cancel(),u.current?.cancel(),f.current?.cancel(),y.current=PR(r.ownerDocument.activeElement),l("bookmark");}})},[o,r,h]),useEffect(()=>{e?.revisionMarkup===false&&u.current?.cancel(),e?.compareDocuments===false&&f.current?.cancel(),e?.textFormField===false&&v.current?.cancel(),a&&e?.[a]===false&&l(null);},[e,a]);let k=useMemo(()=>({container:r,setContainer:i,ownsPageSetup:e?.pageSetup!==void 0,open(T,S){v.current?.cancel(),u.current?.cancel(),f.current?.cancel(),b.current?.[T]!==false&&(y.current=S??r?.ownerDocument.activeElement,l(T));}}),[r,e?.pageSetup]),E={open:true,onClose:x},C=a==="pageSetup"&&e?.pageSetup!==false?e?.pageSetup?Te(e.pageSetup,E):jsx(tr,{...E}):a==="paragraph"&&e?.paragraph!==false?e?.paragraph?Te(e.paragraph,E):jsx(Vo,{...E}):a==="watermark"&&e?.watermark!==false?e?.watermark?Te(e.watermark,E):jsx(or,{...E}):a==="bookmark"&&e?.bookmark!==false?e?.bookmark?Te(e.bookmark,E):jsx(mi,{...E}):a==="splitCell"&&e?.splitCell!==false?e?.splitCell?Te(e.splitCell,E):jsx(fi,{...E}):d&&e?.revisionMarkup!==false?e?.revisionMarkup?Te(e.revisionMarkup,{session:d},d):jsx(Ka,{session:d}):g&&e?.compareDocuments!==false?e?.compareDocuments?Te(e.compareDocuments,{session:g},g):jsx(qa,{session:g}):s&&e?.textFormField!==false?e?.textFormField?Te(e.textFormField,{session:s},s):jsx(bi,{session:s}):null;return jsxs($h.Provider,{value:k,children:[t,r?createPortal(C,r):null]})}function PR(e){return e?.closest("[data-menu]")?.querySelector(':scope > [role="menuitem"]')??e}function Vh(){let e=_o();return jsx("div",{className:"docx-dialog-mount",ref:e?.setContainer,dir:lt()})}function Gh({children:e}){let t=_o();return t?.container?createPortal(e,t.container):e}var jh=["M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-560l-80-80 240-240h120v40L600-560ZM240-640q33 0 56.5-23.5T320-720q0-33-23.5-56.5T240-800q-33 0-56.5 23.5T160-720q0 33 23.5 56.5T240-640Zm240 180q8 0 14-6t6-14q0-8-6-14t-14-6q-8 0-14 6t-6 14q0 8 6 14t14 6Zm-240 300q33 0 56.5-23.5T320-240q0-33-23.5-56.5T240-320q-33 0-56.5 23.5T160-240q0 33 23.5 56.5T240-160Z"],Yh=["M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"],yp=["M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h168q13-36 43.5-58t68.5-22q38 0 68.5 22t43.5 58h168q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z"],xp=["M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z"],Xh=["M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"],Jh=["M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z"],Qh=["M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-120q-33 0-56.5-23.5T120-200h80v80Zm-80-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160q0-33 23.5-56.5T200-840v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z"];function Qr(e,t,o){return Object.assign(({icon:r,labelKey:i,shortcutKey:a,className:l,hidden:s})=>{let c=A(),{close:d}=$o(),m=Pe(),{isEnabled:u,disabledReason:g}=re(t);return s?null:jsx(De,{slot:e,icon:r??oe(o.paths),shortcut:m(a??o.shortcutKey),disabled:!u,...g?{title:g}:{},onSelect:()=>{c?.exec(t),d(true);},...l?{className:l}:{},children:m(i??o.labelKey)})},{docxRow:e})}var xi=Qr("edit.cut",{type:"cut"},{labelKey:"contextMenu.cut",shortcutKey:"contextMenu.cutShortcut",paths:jh}),vi=Qr("edit.copy",{type:"copy"},{labelKey:"contextMenu.copy",shortcutKey:"contextMenu.copyShortcut",paths:Yh}),Ci=Qr("edit.delete",{type:"deleteText"},{labelKey:"contextMenu.delete",shortcutKey:"contextMenu.deleteShortcut",paths:xp}),Ti=Qr("edit.selectAll",{type:"selectAll"},{labelKey:"contextMenu.selectAll",shortcutKey:"contextMenu.selectAllShortcut",paths:Qh});function ea({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=A(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=$o(),c=we(),d=Pe(),m=useMemo(()=>({type:"paste",text:" "}),[]),{isEnabled:u,disabledReason:g}=re(m);if(r)return null;let p=l!==null;return jsx(De,{slot:"edit.paste",icon:e??oe(yp),shortcut:d(o??"contextMenu.pasteShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let{text:f,html:b}=await DR(c);(f||b)&&i?.exec({type:"paste",text:f,...b?{html:b}:{}});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...n?{className:n}:{},children:d(t??"contextMenu.paste")})}ea.docxRow="edit.paste";async function DR(e){let t=hostWindowOf(e),o=t.navigator.clipboard;if(typeof o.read=="function"&&typeof t.ClipboardItem<"u")try{let n=await o.read(),r="",i=null;for(let a of n)a.types.includes("text/plain")&&(r=await(await a.getType("text/plain")).text()),a.types.includes("text/html")&&(i=await(await a.getType("text/html")).text());if(r||i)return {text:r,html:i}}catch{}return {text:await o.readText(),html:null}}function ta({icon:e,labelKey:t,shortcutKey:o,className:n,hidden:r}){let i=A(),{close:a,clipboardRefusal:l,reportClipboardRefusal:s}=$o(),c=we(),d=Pe(),m=useMemo(()=>({type:"pasteWithoutFormatting",text:" "}),[]),{isEnabled:u,disabledReason:g}=re(m);if(r)return null;let p=l!==null;return jsx(De,{slot:"edit.pasteWithoutFormatting",icon:e??oe(yp),shortcut:d(o??"contextMenu.pasteWithoutFormattingShortcut"),disabled:!u||p,...l??g?{title:l??g??""}:{},onSelect:()=>{a(true),(async()=>{try{let f=await hostWindowOf(c).navigator.clipboard.readText();f&&i?.exec({type:"pasteWithoutFormatting",text:f});}catch(f){s(f instanceof Error?f.message:"the clipboard is not readable");}})();},...n?{className:n}:{},children:d(t??"contextMenu.pasteWithoutFormatting")})}ta.docxRow="edit.pasteWithoutFormatting";var t0=te("format.painter")?.paths??[],Rs=Qr("format.copyFormatting",{type:"copyFormatting"},{labelKey:"contextMenu.copyFormatting",shortcutKey:"contextMenu.copyFormattingShortcut",paths:t0}),Ms=Qr("format.pasteFormatting",{type:"pasteFormatting"},{labelKey:"contextMenu.pasteFormatting",shortcutKey:"contextMenu.pasteFormattingShortcut",paths:t0});function Yo(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l,destructive:s})=>{let{close:c}=$o(),d=Pe(),m=Ei(),{isEnabled:u,disabledReason:g,execute:p}=re(t);return l||!m?null:jsx(De,{slot:e,icon:r??oe(o.paths),disabled:!u,...g?{title:g}:{},className:`${s??o.destructive?"docx-table-chrome__destructive-row":""}${a?` ${a}`:""}`,onSelect:()=>{p()&&c(true);},children:d(i??o.labelKey)})},{docxRow:e})}var oa=Yo("table.selectTable",{type:"selectTableRegion",region:"table"},{labelKey:"table.selectTable",paths:tableChromeIconPaths("select_all")}),na=Yo("table.insertRowAbove",{type:"insertRow",where:"above"},{labelKey:"table.insertRowAbove",paths:tableChromeIconPaths("table_rows")}),ra=Yo("table.insertRowBelow",{type:"insertRow",where:"below"},{labelKey:"table.insertRowBelow",paths:tableChromeIconPaths("table_rows")}),aa=Yo("table.insertColumnLeft",{type:"insertColumn",where:"left"},{labelKey:"table.insertColumnLeft",paths:tableChromeIconPaths("view_column")}),ia=Yo("table.insertColumnRight",{type:"insertColumn",where:"right"},{labelKey:"table.insertColumnRight",paths:tableChromeIconPaths("view_column")}),la=Yo("table.mergeCells",{type:"mergeCells"},{labelKey:"table.mergeCells",paths:tableChromeIconPaths("call_merge")}),sa=Object.assign(({icon:e,labelKey:t,className:o,hidden:n})=>{let{close:r}=$o(),i=Pe(),a=Ei(),l=_o(),{isEnabled:s,disabledReason:c}=re("table.splitCell");return n||!a||!l?null:jsx(De,{slot:"table.splitCell",icon:e??oe(tableChromeIconPaths("call_split")),disabled:!s,...c?{title:c}:{},...o?{className:o}:{},onSelect:()=>{r(true),l.open("splitCell");},children:i(t??"table.splitCell")})},{docxRow:"table.splitCell"}),ca=Yo("table.deleteRow",{type:"deleteRow"},{labelKey:"table.deleteRow",paths:tableChromeIconPaths("delete_sweep"),destructive:true}),da=Yo("table.deleteColumn",{type:"deleteColumn"},{labelKey:"table.deleteColumn",paths:tableChromeIconPaths("view_column"),destructive:true}),ua=Yo("table.deleteTable",{type:"deleteTable"},{labelKey:"table.deleteTable",paths:tableChromeIconPaths("delete"),destructive:true}),RR=[{alignment:"top",labelKey:"tableAdvanced.top",icon:"vertical_align_top"},{alignment:"center",labelKey:"tableAdvanced.middle",icon:"vertical_align_center"},{alignment:"bottom",labelKey:"tableAdvanced.bottom",icon:"vertical_align_bottom"}];function ar({hidden:e}){let{close:t}=$o(),o=Pe(),n=Ei(),r=re({type:"setTableCellVerticalAlignment",alignment:"top"}),i=re({type:"setTableCellVerticalAlignment",alignment:"center"}),a=re({type:"setTableCellVerticalAlignment",alignment:"bottom"}),l=[r,i,a];return e||!n?null: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:RR.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:oe(tableChromeIconPaths(s.icon))},s.alignment)})})]})}ar.docxRow="table.cellVerticalAlignment";var o0=e=>e?{tocId:e}:{},n0=e=>t=>({type:"refreshToc",mode:e,...o0(t)}),MR=e=>({type:"removeToc",...o0(e)});function Cp(e,t,o){return Object.assign(({icon:r,labelKey:i,className:a,hidden:l})=>{let s=A(),{close:c,tocId:d}=$o(),m=Pe(),u=useMemo(()=>t(d),[d]),{isEnabled:g,disabledReason:p}=re(u);return l||d===null?null:jsx(De,{slot:e,icon:r??oe(o.paths),disabled:!g,...p?{title:p}:{},onSelect:()=>{s?.exec(u),c(true);},...a?{className:a}:{},children:m(i??o.labelKey)})},{docxRow:e})}var pa=Cp("toc.refresh",n0("entire"),{labelKey:"toc.refresh",paths:Xh}),ma=Cp("toc.refreshPageNumbers",n0("pageNumbers"),{labelKey:"toc.refreshPageNumbers",paths:Jh}),fa=Cp("toc.remove",MR,{labelKey:"toc.remove",paths:xp});function Ei(){return W(useCallback(e=>e.table!=null,[]),(e,t)=>e===t)}function _s({label:e,icon:t,shortcut:o,disabled:n,disabledReason:r,active:i,onSelect:a,className:l}){let{close:s}=$o();return jsx(De,{...t?{icon:t}:{},...o?{shortcut:o}:{},...n?{disabled:n}:{},...n&&r?{title:r}:{},...i!==void 0?{active:i}:{},onSelect:()=>{a?.(),s(true);},...l?{className:l}:{},children:e})}var Pi=8;function LR(){let e=useContext(At),t=et(),o=Pe(),{isEnabled:n,reason:r}=ts(o);if((e?.mounted??0)===0)return null;let i=te("review.addComment");return jsx(De,{icon:oe(i?.paths),slot:"review.addComment",disabled:!n,title:r??void 0,onSelect:()=>{e?.requestCommentDraft()&&t.setOpenMenu(null);},children:o("comments.addComment")})}function HR(){let e=A(),t=et(),o=Pe();return e?.can({type:"editTextFormField"}).ok?jsx(De,{slot:"field.edit",onSelect:()=>{t.setOpenMenu(null),e.exec({type:"editTextFormField"});},children:o("textFormField.edit")}):null}var AR=[{kind:"row",id:"field.edit",render:()=>jsx(HR,{})},{kind:"row",id:"edit.cut",render:()=>jsx(xi,{})},{kind:"row",id:"edit.copy",render:()=>jsx(vi,{})},{kind:"row",id:"edit.paste",render:()=>jsx(ea,{})},{kind:"row",id:"edit.pasteWithoutFormatting",render:()=>jsx(ta,{})},{kind:"row",id:"format.copyFormatting",render:()=>jsx(Rs,{})},{kind:"row",id:"format.pasteFormatting",render:()=>jsx(Ms,{})},{kind:"separator",id:"sep.clipboard"},{kind:"row",id:"edit.delete",render:()=>jsx(Ci,{})},{kind:"row",id:"edit.selectAll",render:()=>jsx(Ti,{})},{kind:"separator",id:"sep.selection"},{kind:"row",id:"text.link",render:()=>jsx(gs,{shortcutKey:"contextMenu.insertLinkShortcut"})},{kind:"row",id:"review.addComment",render:()=>jsx(LR,{})}];function OR(){return [{kind:"separator",id:"sep.table"},{kind:"row",id:oa.docxRow,render:()=>jsx(oa,{})},{kind:"row",id:na.docxRow,render:()=>jsx(na,{})},{kind:"row",id:ra.docxRow,render:()=>jsx(ra,{})},{kind:"separator",id:"sep.table.columns"},{kind:"row",id:aa.docxRow,render:()=>jsx(aa,{})},{kind:"row",id:ia.docxRow,render:()=>jsx(ia,{})},{kind:"separator",id:"sep.table.cells"},{kind:"row",id:la.docxRow,render:()=>jsx(la,{})},{kind:"row",id:sa.docxRow,render:()=>jsx(sa,{})},{kind:"separator",id:"sep.table.destructive"},{kind:"row",id:ca.docxRow,render:()=>jsx(ca,{})},{kind:"row",id:da.docxRow,render:()=>jsx(da,{})},{kind:"row",id:ua.docxRow,render:()=>jsx(ua,{})},{kind:"separator",id:"sep.table.alignment"},{kind:"row",id:ar.docxRow,render:()=>jsx(ar,{})}]}function BR(){return [{kind:"separator",id:"sep.toc"},{kind:"row",id:pa.docxRow,render:()=>jsx(pa,{})},{kind:"row",id:ma.docxRow,render:()=>jsx(ma,{})},{kind:"row",id:fa.docxRow,render:()=>jsx(fa,{})}]}function WR(e,t=false){return [...AR,...e?OR():[],...t?BR():[]]}function c0(e){if(!isValidElement(e))return null;let t=Wr(e,c0);if(t!==null)return t;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxRow=="string")return o.docxRow;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxMenuRow===true){let n=hs(e.props);if(n)return n}return null}function l0(e){if(!isValidElement(e))return false;let t=e.type;return typeof t!="function"&&typeof t!="object"?false:t.docxRowPlacement==="start"}function ZR(e){return e?.closest(".docx-editor__scroll-container")??null}function ki({className:e,t,preset:o=true,disabled:n,onOpenChange:r,children:i}){let a=$t(),l=lt(),s=A(),{t:c}=H(),d=Ei(),m=useRef(null),u=useRef(null),[g,p]=useState(null),[f,b]=useState(null),[y,v]=useState(null),x=useMemo(()=>WR(d,f!==null),[d,f]),[h,k]=useState(null),E=useCallback((N=false)=>{p(null),k(null),b(null),v(null),N&&s?.focus();},[s]);useEffect(()=>{if(n)return;let N=ZR(m.current);if(!N)return;let B=F=>{if(u.current?.contains(F.target)){F.preventDefault();return}if(!Eb(N,F.target))return;F.preventDefault();let D=F.button===-1||F.clientX===0&&F.clientY===0,R=N.getBoundingClientRect();b(s?.snapshot().tocContext?.id??null),v(D||!isHTMLElementNode(F.target)?null:F.target),p(D?{x:R.left+16,y:R.top+16}:{x:F.clientX,y:F.clientY});};return N.addEventListener("contextmenu",B),()=>N.removeEventListener("contextmenu",B)},[n,s]),useEffect(()=>{n&&E();},[n,E]),useEffect(()=>{if(!g)return;let N=U=>{u.current?.contains(U.target)||E();},B=U=>{U.key==="Escape"?(U.preventDefault(),E(true)):U.key==="Tab"&&E();},F=()=>E(),D=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,E]),useLayoutEffect(()=>{let N=u.current;if(!g||!N)return;let{width:B,height:F}=N.getBoundingClientRect(),D=hostWindowOf(N),R=D.innerWidth-B-Pi,U=D.innerHeight-F-Pi,Y=D.getComputedStyle(N).direction==="rtl"?g.x-B>=Pi:g.x>R,j=Math.max(Pi,Math.min(Y?g.x-B:g.x,R)),q=Math.max(Pi,g.y>U?g.y-F:g.y);k({x:j,y:q});},[g]),useLayoutEffect(()=>{h&&u.current?.focus({preventScroll:true});},[h]);let C=useRef(r);C.current=r;let T=useRef(false);useEffect(()=>{let N=g!==null;N!==T.current&&(T.current=N,C.current?.(N));},[g]);let S=useMemo(()=>({t,openMenu:null,setOpenMenu:()=>E(true),activeMenu:null,onOpen:void 0,onSave:void 0,onPageSetup:void 0,onParagraphDialog:void 0,onReportIssue:void 0,reportIssue:void 0}),[t,E]),[P,w]=useState(null),_=useMemo(()=>({close:E,anchor:g,tocId:f,target:y,clipboardRefusal:P,reportClipboardRefusal:w}),[E,g,f,y,P]),L={position:"fixed",left:(h??g)?.x??0,top:(h??g)?.y??0,visibility:h?"visible":"hidden"};return jsx("div",{ref:m,style:{display:"contents"},children:g?jsx(ni.Provider,{value:S,children:jsx(ys.Provider,{value:_,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:L,onKeyDown:N=>{let B=u.current;if(!B)return;let F=Jn(B);N.key==="ArrowDown"?(N.preventDefault(),no(F,hostDocumentOf(B).activeElement,1)):N.key==="ArrowUp"?(N.preventDefault(),no(F,hostDocumentOf(B).activeElement,-1)):N.key==="Home"?(N.preventDefault(),ro(F,"first")):N.key==="End"&&(N.preventDefault(),ro(F,"last"));},children:[Children.toArray(i).filter(l0),es({entries:x,children:Children.toArray(i).filter(N=>!l0(N)),preset:o,keyOfEntry:N=>N.id,keyOfChild:N=>Tb(c0(N)),renderEntry:N=>N.kind==="separator"?jsx(Qn,{}):N.render(),onUnmatched:(N,B)=>{B.props.hidden&&qg(N);}})]})})}):null})}var Sp=Object.assign(ki,{Cut:xi,Copy:vi,Paste:ea,PasteWithoutFormatting:ta,Delete:Ci,SelectAll:Ti,SelectTable:oa,InsertRowAbove:na,InsertRowBelow:ra,InsertColumnLeft:aa,InsertColumnRight:ia,MergeCells:la,SplitCell:sa,DeleteTableRow:ca,DeleteTableColumn:da,DeleteTable:ua,CellVerticalAlignment:ar,RefreshToc:pa,RefreshTocPageNumbers:ma,RemoveToc:fa,Item:_s,Slot:ao,Row:De,Group:di,Separator:Qn,Submenu:io});var d0=su.Provider;function u0(){let e=Rt(),{t}=H();return jsxs(Fragment,{children:[e?.hyperlink&&Te(e.hyperlink,{}),e?.contentControl&&Te(e.contentControl,{}),e?.equation&&Te(e.equation,{}),e?.contextMenu&&Te(e.contextMenu,{t:o=>t(o)})]})}function p0(e,t,o,n){return {...e,hyperlink:e?.hyperlink??(t===false?false:r=>jsx(Ja,{...r})),contentControl:e?.contentControl??(r=>jsx(ti,{...r})),equation:e?.equation??(()=>jsx(oi,{})),contextMenu:e?.contextMenu!==void 0?e.contextMenu===false?false:r=>e.contextMenu&&Te(e.contextMenu,{...r,t:n??r.t}):o===false?false:r=>jsx(ki,{...r,t:n??r.t,...typeof o=="object"?o:{}})}}function $R(e,t){return e===t?true:!e||!t||e.kind!==t.kind?false:e.kind==="note"&&t.kind==="note"?e.id===t.id:e.kind==="headerFooter"&&t.kind==="headerFooter"?e.rId===t.rId:true}function Pp(){let e=A(),t=useCallback(n=>{let r=e?.getActiveScope();return r?.kind==="note"?r:null},[e]),o=W(t,$R);return o?.kind==="note"?o:null}function m0(e,t){return e===t?true:!e||!t?false:e.pos===t.pos&&e.numFmt===t.numFmt&&e.numStart===t.numStart&&e.numRestart===t.numRestart}function f0(e,t){return e.resolved.pos===t.resolved.pos&&e.resolved.numFmt===t.resolved.numFmt&&e.resolved.numStart===t.resolved.numStart&&e.resolved.numRestart===t.resolved.numRestart&&m0(e.documentAuthored,t.documentAuthored)&&m0(e.sectionAuthored,t.sectionAuthored)}function zR(e,t){return e===t?true:!e||!t?false:e.sectionIndex===t.sectionIndex&&f0(e.footnote,t.footnote)&&f0(e.endnote,t.endnote)}function kp(){let e=A(),t=useCallback(o=>e?.getNotePropertiesState()??null,[e]);return W(t,zR)}function wi(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 b=e(s);if(b!==m&&(u.disconnect(),u.observe(s),u.observe(o),b&&u.observe(b),m=b),!b||!b.isConnected){a({visibility:"hidden"});return}let y=b.getBoundingClientRect(),v=t==="story-label"?Math.max(o.offsetHeight,28):o.offsetHeight,x=t==="story-label"?6:4,h=l===s,k=t==="after"?y.bottom+6:t==="story-label"?storyLabelTop(y,b.closest(".docx-page")?.getBoundingClientRect().top,v,x):y.top-v-x,E=h?Lr(s,y.left,k):{left:y.left,top:k},C=E.left,T=E.top,S=h?s.scrollLeft+8:8;a({position:h?"absolute":"fixed",left:t==="story-label"?C:Math.max(S,C+8),top:t==="story-label"?T:Math.max(h?s.scrollTop+8:8,T),...t==="story-label"?{width:Math.max(240,Math.min(y.width,s.clientWidth-16))}:{maxWidth:Math.max(240,Math.min(y.width-16,s.clientWidth-16))},visibility:"visible"});},p=()=>{d||(d=c.requestAnimationFrame(g));};u.observe(s),u.observe(o);let f=new c.MutationObserver(p);return f.observe(s,{subtree:true,childList:true,attributes:true,attributeFilter:["data-docx-hf-active","data-docx-note-scope"]}),s.addEventListener("scroll",p,{passive:true}),c.addEventListener("resize",p),g(),()=>{d&&c.cancelAnimationFrame(d),u.disconnect(),f.disconnect(),s.removeEventListener("scroll",p),c.removeEventListener("resize",p);}},[o,e,t]),{ref:r,style:i}}var JR=/^(footnote|endnote):(-?\d{1,10})$/;function h0(e){let t=JR.exec(e);if(!t)return null;let o=Number(t[2]);return Number.isInteger(o)?{noteKind:t[1],noteId:o}:null}function QR(e){let t=hostWindowOf(e);return typeof t.matchMedia!="function"?false:t.matchMedia("(pointer: coarse)").matches}function Dp(e){let t=A();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 eM(e){let{t}=H(),[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:$,onClick:()=>n(i=>!i),children:t("headerFooter.options")}),o?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:$,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 Hs({className:e}){let t=Rt(),o=useRef(null),{t:n}=H(),r=A(),i=Pp(),[a,l]=useState(null),[s,c]=useState(null),[d,m]=useState(false),u=useRef(null),g=useCallback(_=>{if(!i)return null;let N=[..._.querySelectorAll("[data-docx-note-scope]")].find(B=>B.matches("[data-docx-note]")&&B.dataset.docxNoteScope===i.id)??null;return N?.closest("[data-docx-notes]")??N},[i]),p=wi(g,"story-label"),f=useCallback(()=>{u.current&&u.current.win.clearTimeout(u.current.handle),u.current=null,l(null);},[]);useEffect(()=>{if(!r)return;let _=o.current?.closest(".docx-editor__scroll-container")??o.current?.closest(".docx-editor");if(!_)return;let L=F=>{let D=F.target;if(!D)return;let R=D.closest("[data-docx-note-ref]");if(R?.dataset.docxNoteScope){F.preventDefault(),f(),c(null),r.setActiveScope({kind:"note",id:R.dataset.docxNoteScope});return}D.closest("[data-docx-note-mark-back]")&&(F.preventDefault(),f(),c(null),r.setActiveScope({kind:"body"}));},N=F=>{let D=F,U=D.target?.closest("[data-docx-note-scope]");U?.dataset.docxNoteScope&&(D.preventDefault(),c({scopeId:U.dataset.docxNoteScope,x:D.clientX,y:D.clientY}));},B=F=>{let D=F.target;if(QR(D))return;let R=D?.closest("[data-docx-note-ref]");if(!R?.dataset.docxNoteScope){f();return}let U=R.dataset.docxNoteScope,Y=r.getNotePreviewText(U)??R.getAttribute("aria-description")??n("notes.previewFallback"),j=R.getBoundingClientRect();u.current&&u.current.win.clearTimeout(u.current.handle);let q=hostWindowOf(R),X=q.setTimeout(()=>{l({scopeId:U,text:Y,x:j.left,y:j.bottom+4});},400);u.current={win:q,handle:X};};return _.addEventListener("click",L),_.addEventListener("contextmenu",N),_.addEventListener("pointerover",B),_.addEventListener("scroll",f,true),()=>{_.removeEventListener("click",L),_.removeEventListener("contextmenu",N),_.removeEventListener("pointerover",B),_.removeEventListener("scroll",f,true),f();}},[r,f,n]);let b=useCallback(_=>{r&&(r.exec(_),c(null));},[r]),y=s?h0(s.scopeId):null,v=useMemo(()=>y?{type:"deleteNote",noteKind:y.noteKind,noteId:y.noteId}:null,[y]),x=useMemo(()=>y?{type:"convertNote",fromKind:y.noteKind,noteId:y.noteId}:null,[y]),h=useMemo(()=>y?{type:"convertAllNotes",fromKind:y.noteKind}:null,[y]),k=Dp(v??{type:"deleteNote",noteKind:"footnote",noteId:0}),E=Dp(x??{type:"convertNote",fromKind:"footnote",noteId:0}),C=Dp(h??{type:"convertAllNotes",fromKind:"footnote"}),T=i?h0(i.id):null,S=T?n("notes.editingRegion",{kind:T.noteKind==="footnote"?n("notes.footnoteKind"):n("notes.endnoteKind"),number:T.noteId}):null,P=s&&y?{...s,...y,onDelete:()=>{v&&b(v);},onConvert:()=>{x&&b(x);},onConvertAll:()=>{h&&b(h);},onOpenProperties:()=>m(true),onClose:()=>c(null),deleteEnabled:k.enabled,convertEnabled:E.enabled,convertAllEnabled:C.enabled,deleteDisabledReason:k.reason??void 0,convertDisabledReason:E.reason??void 0,convertAllDisabledReason:C.reason??void 0}:null,w={onClose:()=>m(false),onApply:_=>{b(_),m(false);}};return r?jsxs("div",{className:e,ref:o,"data-docx-notes-chrome":"","data-testid":"docx-notes-chrome","aria-hidden":i?void 0:true,children:[i&&T?jsxs("div",{ref:p.ref,className:"docx-context-bar docx-notes-chrome__banner",role:"region","aria-label":n("notes.chromeAriaLabel"),"data-testid":"docx-notes-banner","data-note-scope":i.id,style:{...p.style,zIndex:St.chrome},children:[jsx("span",{className:"docx-context-bar__title",children:S}),jsx(eM,{onOpenProperties:()=>m(true),onClose:()=>r.setActiveScope({kind:"body"})})]}):null,a&&t?.notePreview!==false?t?.notePreview?Te(t.notePreview,a):jsx(Nr,{...a}):null,P&&t?.notesContextMenu!==false?t?.notesContextMenu?Te(t.notesContextMenu,P):jsx(Fr,{...P}):null,d&&t?.noteProperties!==false?t?.noteProperties?Te(t.noteProperties,w):jsx(As,{...w}):null]}):null}function As(e){let{t}=H(),o=A(),n=kp(),[r,i]=useState("document"),[a,l]=useState("decimal"),[s,c]=useState("continuous"),[d,m]=useState("pageBottom"),[u,g]=useState("decimal"),[p,f]=useState("continuous"),[b,y]=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),y(n.endnote.resolved.pos));},[n]);let v=!n?.footnote.sectionAuthored,x=!n?.endnote.sectionAuthored&&n?.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:St.modal},onClick:e.onClose,onKeyDown:h=>{h.key==="Escape"&&e.onClose();},children:jsxs("div",{className:"docx-note-properties__panel",onClick:h=>h.stopPropagation(),onMouseDown:h=>h.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:h=>i(h.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")}),v?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:h=>l(h.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:h=>c(h.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:h=>m(h.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")}),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:u,onChange:h=>g(h.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:h=>f(h.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:b,"data-testid":"docx-notes-endnote-position",onChange:h=>y(h.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 h={type:"setNoteProperties",scope:r,sectionIndex:r==="section"?n?.sectionIndex:void 0,footnote:{numFmt:a,numRestart:s,position:d},endnote:{numFmt:u,numRestart:p,position:b}};o.can(h).ok&&e.onApply(h);},children:t("common.apply")})]})]})})}var C0=e=>e.image;function v0(e){return Array.from(e.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(t=>t.offsetParent!==null||t===hostDocumentOf(e).activeElement)}function lM(){let e=Ut(),[t,o]=useState(false);return {ref:useCallback(r=>{r&&o(!r.parentElement?.closest(e?".docx-editor.dark":".docx-editor"));},[e]),className:t?`docx-editor ${e?"dark ":""}`:""}}function sM(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Fp(e){let t=e.position;return !t||e.kind!=="anchored"?{positionMode:"frame",horizontalPoints:"",verticalPoints:"",relativeToH:"page",relativeToV:"line"}:t.mode==="simple"?{positionMode:"simple",horizontalPoints:t.horizontalEmu!==void 0?String(gn(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(gn(t.verticalEmu)):"",relativeToH:"page",relativeToV:"line"}:{positionMode:"frame",horizontalPoints:t.horizontalEmu!==void 0?String(gn(t.horizontalEmu)):"",verticalPoints:t.verticalEmu!==void 0?String(gn(t.verticalEmu)):"",relativeToH:t.relativeToH??"page",relativeToV:t.relativeToV??"line"}}function cM(e,t){let o=Fp(t);return e.horizontalPoints!==o.horizontalPoints||e.verticalPoints!==o.verticalPoints||e.relativeToH!==o.relativeToH||e.relativeToV!==o.relativeToV}function Os(e){if(e.trim()==="")return null;let t=Number(e);if(!Number.isFinite(t))return null;let o=ai(t);return Number.isInteger(o)?o:null}function dM(e,t){let o=Fp(t);if(e.positionMode==="simple"||t.position?.mode==="simple"){let c=e.horizontalPoints!==o.horizontalPoints,d=e.verticalPoints!==o.verticalPoints,m=c?Os(e.horizontalPoints):t.position?.horizontalEmu,u=d?Os(e.verticalPoints):t.position?.verticalEmu;return c&&m===null?{ok:false}:d&&u===null?{ok:false}:m===void 0||u===void 0?{ok:false}:{ok:true,value:{horizontalEmu:m,verticalEmu:u}}}let n=e.horizontalPoints!==o.horizontalPoints,r=e.verticalPoints!==o.verticalPoints,i=e.relativeToH!==o.relativeToH,a=e.relativeToV!==o.relativeToV,l=n?Os(e.horizontalPoints):t.position?.horizontalEmu,s=r?Os(e.verticalPoints):t.position?.verticalEmu;return n&&l===null?{ok:false}:r&&s===null?{ok:false}:{ok:true,value:{...typeof l=="number"?{horizontalEmu:l}:{},...typeof s=="number"?{verticalEmu:s}:{},...i||n||r?{relativeToH:e.relativeToH}:{},...a||n||r?{relativeToV:e.relativeToV}:{}}}}function Bs(e){let t=Number(e);return !Number.isFinite(t)||t<0||t>100?null:t}function Ws(e){let t=Number(e);return !Number.isFinite(t)||t<=0?null:t}function Ri({open:e,onClose:t,className:o,triggerRef:n}){let r=A(),{t:i}=H(),a=W(C0),l=useId(),s=useId(),c=useId(),d=useRef(null),m=useRef(null),u=useRef(null),g=useRef(null),[p,f]=useState(null),[b,y]=useState(null),v=lM(),x=m.current,h=x?.canCrop===false,k=x?.canResize===false,E=x?.locks.changeAspect===true,C=x?.kind==="anchored"&&x.canMove===true,T=x?.kind==="inline",S=x?.kind==="anchored"&&x.canMove===false;useEffect(()=>{if(!e){m.current=null,u.current=null,g.current=null;return}if(!a)return;if(m.current=a,r?.surface){let{anchor:U}=r.surface.state().selection;u.current={paragraphId:U.paragraphId,offset:U.offset},g.current=r.surface.session.packageRevision();}y(null);let D=Fp(a),R=a.crop;f({widthPoints:String(gn(a.widthEmu)),heightPoints:String(gn(a.heightEmu)),cropLeft:String(R.left),cropTop:String(R.top),cropRight:String(R.right),cropBottom:String(R.bottom),title:a.title,description:a.description,hyperlink:a.hyperlink??"",wrap:a.wrap,lockAspect:a.locks.changeAspect,...D});},[e,a?.id,a?.widthEmu,a?.heightEmu,r]);let P=useCallback(()=>{n?.current?.focus(),r?.focus();},[r,n]),w=useCallback(()=>{t(),P();},[t,P]);useEffect(()=>{if(!e)return;let D=d.current;if(!D)return;let R=v0(D);(R.find(j=>j.id==="image-prop-width"&&!j.hasAttribute("disabled"))??R.find(j=>!j.hasAttribute("disabled"))??D).focus();let V=j=>{if(j.key==="Escape"){j.preventDefault(),w();return}if(j.key!=="Tab")return;let q=v0(D);if(q.length===0)return;let X=hostDocumentOf(D).activeElement,ee=q.findIndex(I=>I===X);if(ee===-1)return;j.preventDefault();let O=j.shiftKey?(ee-1+q.length)%q.length:(ee+1)%q.length;q[O]?.focus();},Y=hostDocumentOf(D);return Y.addEventListener("keydown",V),()=>Y.removeEventListener("keydown",V)},[e,w]);let _=useMemo(()=>{let D=x??a;return !D||D.widthEmu<=0?1:D.widthEmu/D.heightEmu},[a,x]),L=useCallback(D=>{f(R=>{if(!R)return R;if(!R.lockAspect)return {...R,widthPoints:D};let U=Ws(D);if(U===null)return {...R,widthPoints:D};let V=Math.round(U/_*100)/100;return {...R,widthPoints:D,heightPoints:String(V)}});},[_]),N=useCallback(D=>{f(R=>{if(!R)return R;if(!R.lockAspect)return {...R,heightPoints:D};let U=Ws(D);if(U===null)return {...R,heightPoints:D};let V=Math.round(U*_*100)/100;return {...R,widthPoints:String(V),heightPoints:D}});},[_]),B=useCallback(()=>{let D=m.current;if(!D?.intrinsic)return;let R=D.intrinsic.pixelWidth*72/D.intrinsic.dpiX,U=D.intrinsic.pixelHeight*72/D.intrinsic.dpiY;f(V=>V&&{...V,widthPoints:String(Math.round(R*100)/100),heightPoints:String(Math.round(U*100)/100)});},[a]),F=useCallback(()=>{let D=m.current,R=u.current,U=g.current;if(!r||!D||!p||!R||U===null)return;let V={type:"setImageProperties",drawingNodeId:D.id,expectedPackageRevision:U,selectionParagraphId:R.paragraphId,selectionOffset:R.offset};if(!k){let O=Ws(p.widthPoints),I=Ws(p.heightPoints);if(O===null||I===null){y("imageProperties.errors.invalidDimensions");return}let ie=ai(O),ge=ai(I);ie!==D.widthEmu&&(V.widthEmu=ie),ge!==D.heightEmu&&(V.heightEmu=ge);}if(D.canCrop&&!h){let O=Bs(p.cropLeft),I=Bs(p.cropTop),ie=Bs(p.cropRight),ge=Bs(p.cropBottom);if(O===null||I===null||ie===null||ge===null){y("imageProperties.errors.invalidCrop");return}let K=D.crop;(O!==K.left||I!==K.top||ie!==K.right||ge!==K.bottom)&&(V.crop={left:O,top:I,right:ie,bottom:ge});}p.title!==D.title&&(V.title=p.title),p.description!==D.description&&(V.description=p.description);let Y=p.hyperlink.trim();if(Y!==(D.hyperlink??"")&&(V.hyperlink=Y===""?null:Y),D.canChangeWrap&&p.wrap!==D.wrap&&(V.wrap=p.wrap),D.kind==="anchored"&&D.canMove&&cM(p,D)){let O=dM(p,D);if(!O.ok){y("imageProperties.errors.invalidPosition");return}if(!validateDrawingPositionInput(positionInputFromPropertiesCommand(O.value,D))){y("imageProperties.errors.invalidPosition");return}Object.assign(V,O.value);}if(!(V.widthEmu!==void 0||V.heightEmu!==void 0||V.title!==void 0||V.description!==void 0||V.hyperlink!==void 0||V.crop!==void 0||V.wrap!==void 0||V.horizontalEmu!==void 0||V.verticalEmu!==void 0||V.relativeToH!==void 0||V.relativeToV!==void 0)){w();return}if(!r.can(V).ok){y("imageProperties.errors.refused");return}if(!r.exec(V).ok){y("imageProperties.errors.refused");return}w();},[r,p,h,k,w]);return !e||!p?null:jsx("div",{ref:v.ref,className:`${v.className}docx-dialog-overlay${o?` ${o}`:""}`,onClick:w,onMouseDown:D=>{D.stopPropagation(),sM(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:[b?jsx("p",{className:"docx-dialog__error",children:i(b)}):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:k,onChange:D=>L(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:k,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:E,onChange:D=>f(R=>R&&{...R,lockAspect:D.target.checked})}),i("dialogs.imageProperties.lockAspectRatio")]}),jsx("button",{type:"button",className:"docx-dialog__link-button",disabled:h||!x?.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")}),T?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:x?.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:h,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:h,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:h,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:h,value:p.cropBottom,onChange:D=>f(R=>R&&{...R,cropBottom:D.target.value})})]}),h?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 Ks({className:e,hidden:t,asChild:o,children:n}){let r=Rt(),i=A(),{t:a}=H(),l=W(C0),[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,f=bn(o,n);if(t)return null;let b=te("image.properties"),y=a("formattingBar.imagePropertiesShortcut"),v={type:"button",ref:d,className:`${hn(f)}${e?` ${e}`:""}`,"data-slot":"image.properties",disabled:!g,...g?{}:{"data-disabled":""},"aria-label":y,title:p??y,onMouseDown:$,onClick:()=>c(true)};return jsxs(Fragment,{children:[o?jsx(Q,{...v,children:n}):jsx("button",{...v,children:f?jsx(yn,{icon:oe(b?.paths),label:y}):n??oe(b?.paths)}),s&&r?.imageProperties!==false?r?.imageProperties?Te(r.imageProperties,{open:s,onClose:()=>c(false),triggerRef:d}):jsx(Ri,{open:s,onClose:()=>c(false),triggerRef:d}):null]})}Ks.docxSlot="image.properties";var ga=Object.assign(Ks,{docxSlot:"image.properties"});function Mi(e){let t=A(),o=useCallback(()=>toolbarCommandState(t,e),[t,e]),n=W(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 qs({className:e,hidden:t,asChild:o,children:n}){let r=Rt(),i=ae(),{execute:a,value:l,isEnabled:s,disabledReason:c}=Mi("image.altText"),[d,m]=useState(false),[u,g]=useState(""),p=useRef(null),f=useRef(null),b=useId(),y=bn(o,n);useEffect(()=>{d&&g(l??"");},[d,l]),useEffect(()=>{if(!d)return;let C=P=>{let w=p.current;isDomNode(P.target)&&(w?.contains(P.target)||w?.ownerDocument.getElementById(b)?.contains(P.target))||m(false);},T=P=>{P.key==="Escape"&&(P.preventDefault(),m(false),f.current?.focus());},S=hostDocumentOf(p.current);return S.addEventListener("mousedown",C,true),S.addEventListener("keydown",T),()=>{S.removeEventListener("mousedown",C,true),S.removeEventListener("keydown",T);}},[d,b]);let v=useCallback(()=>{a(u),m(false);},[u,a]);if(t)return null;let x=te("image.altText"),h=i(x?.labelKey??"formattingBar.altText"),k={type:"button",ref:f,className:`${hn(y)} docx-toolbar__alt-text-trigger${e?` ${e}`:""}`,"data-slot":"image.altText",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"dialog","aria-expanded":d,"aria-controls":d?b:void 0,"aria-label":h,title:c??h,onMouseDown:$,onClick:()=>m(C=>!C)},E={id:b,value:u,onValueChange:g,onApply:v,onClose:()=>m(false),isEnabled:s,anchorRef:f};return jsxs("div",{ref:p,className:"docx-toolbar__alt-text",children:[o?jsx(Q,{...k,children:n}):jsx("button",{...k,children:y?jsx(yn,{icon:null,label:h}):n??h}),d&&r?.imageAltText!==false?r?.imageAltText?Te(r.imageAltText,E):jsx(Us,{...E}):null]})}qs.docxSlot="image.altText";var _i=Object.assign(qs,{docxSlot:"image.altText"});function Us({id:e,value:t,onValueChange:o,onApply:n,onClose:r,isEnabled:i,className:a}){let{t:l}=H();return 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 Ap(e){let[t,o]=useState(e.session),[n,r]=useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsx(TM,{...e},n)}function TM({session:e,className:t,style:o,children:n}){let r=tt(),[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(Fe,{kind:"invalidTextFormField",role:"alertdialog",label:r("textFormField.invalidTitle"),className:t,style:o,panelRef:l,dismissOutside:false,onClose:e.acknowledge,sessionSignal:e.signal,restoreFocus:false,onKeyDown:s=>{s.key==="Enter"&&!s.nativeEvent.isComposing&&(s.preventDefault(),e.acknowledge());},children:n??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 w0=createContext(null),D0=w0.Provider;function ct(){let e=useContext(w0);if(!e)throw new globalThis.Error("useContentControlWidget must be rendered inside DocxEditorContentControlWidget.");return e}function FM(e){return e.kind==="date"?parseIsoDate(e.value)?e.value.slice(0,10):"":e.value}function R0(e){let t=`docx-cc-list-${useId()}`,[o,n]=useState(()=>FM(e)),[r,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 _=e.apply(w??o);return s(!_),_},[e,o]),f=useCallback(()=>e.cancel(),[e]),b=useCallback(async w=>{if(!e.replaceImage)return s(true),false;try{let _=w instanceof Uint8Array?w.byteLength:w.size;if(!e.canApply()||_>DEFAULT_IMAGE_RESOURCE_LIMITS.maxEncodedBytes)return s(!0),!1;let L=w instanceof Uint8Array?w:new Uint8Array(await w.arrayBuffer()),N=await e.replaceImage(L);return s(!N),N}catch{return s(true),false}},[e]),y=useMemo(()=>calendarMonth(u.year,u.month,{locale:e.locale,selected:e.kind==="date"?e.value:null}),[u,e]),v=useCallback(()=>{g(w=>shiftMonth(w.year,w.month,-1)),C(null);},[]),x=useCallback(()=>{g(w=>shiftMonth(w.year,w.month,1)),C(null);},[]),h=useCallback(w=>p(w),[p]),k=useCallback(()=>p(isoDateOf(new Date)),[p]),[E,C]=useState(null),T=useCallback(w=>{let _=parseIsoDate(w);_&&(g({year:_.getFullYear(),month:_.getMonth()}),C(isoDateOf(_)));},[]),S=useCallback(()=>{let w=calendarDateFromText(r,e.locale);return w?p(w):(s(true),false)},[r,e.locale,p]),P=useCallback((w,_)=>{!Number.isInteger(w)||w<100||w>9999||!Number.isInteger(_)||_<0||_>11||(g({year:w,month:_}),C(null));},[]);return useMemo(()=>({session:e,kind:e.kind,items:e.items,value:o,setValue:n,isEnabled:d,refused:l,apply:p,cancel:f,calendar:y,previousMonth:v,nextMonth:x,selectDay:h,selectToday:k,focusIso:E,focusDay:T,dateText:r,setDateText:c,applyDateText:S,showMonth:P,listNavigation:a,listId:t,accept:CONTENT_CONTROL_PICTURE_ACCEPT,replaceImage:b}),[e,b,o,d,l,p,f,y,v,x,h,k,E,T,r,c,S,P,a,t])}function ot(e,t,o,n){if(t.hidden)return null;let{children:r,asChild:i,className:a,style:l,hidden:s,id:c,title:d,"aria-label":m,...u}=t,g=r===void 0?n:r,{key:p,...f}=o,b={...c!==void 0?{id:c}:{},...d!==void 0?{title:d}:{},...m!==void 0?{"aria-label":m}:{}};if(i){let{className:v,style:x,...h}=f;return jsx(Q,{...u,...h,...b,...a?{className:a}:{},style:{...x,...l},children:g},p)}return jsx(e,{...u,...f,...b,className:[o.className,a].filter(Boolean).join(" "),style:{...o.style,...l},children:g},p)}var sr=e=>e.stopPropagation();function Zp(e){return ot("div",e,{className:"docx-content-control-calendar-header","data-docx-part":"header"},jsxs(Fragment,{children:[jsx(Kp,{}),jsx(Jp,{}),jsx(qp,{}),jsx(Up,{className:"docx-content-control-calendar-announcement"})]}))}function Kp(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"previousMonth","aria-label":o("contentControl.calendar.previousMonth"),onMouseDown:sr,onClick:t.previousMonth},"\u2039")}function qp(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-content-control-calendar-nav","data-docx-part":"nextMonth","aria-label":o("contentControl.calendar.nextMonth"),onMouseDown:sr,onClick:t.nextMonth},"\u203A")}function Up(e){let t=ct();return ot("div",e,{className:"docx-content-control-calendar-title","data-docx-part":"title","aria-live":"polite"},t.calendar.title)}function $p(e){let t=ct();return ot("div",e,{className:"docx-content-control-calendar-weekdays","data-docx-part":"weekdays"},t.calendar.weekdays.map((o,n)=>jsx("span",{children:o},n)))}function zp({day:e,...t}){let o=ct(),n=o.calendar.days.find(i=>i.iso===o.focusIso)??o.calendar.days.find(i=>i.selected)??o.calendar.days.find(i=>i.today&&!i.otherMonth)??o.calendar.days.find(i=>!i.otherMonth),r=i=>{if(i.nativeEvent.isComposing||i.altKey||i.ctrlKey||i.metaKey)return;let a=calendarDateForKey(e.iso,i.key,o.session.locale,i.shiftKey);a&&(i.preventDefault(),o.focusDay(a));};return ot("button",t,{type:"button",className:"docx-content-control-calendar-day","data-docx-part":"day","data-iso":e.iso,role:"gridcell",tabIndex:e.iso===n?.iso?0:-1,"aria-label":e.label,...e.selected?{"data-selected":"","aria-selected":true}:{},"aria-current":e.today?"date":void 0,"aria-selected":e.selected,...e.today?{"data-today":""}:{},...e.otherMonth?{"data-other-month":""}:{},disabled:!o.isEnabled,onMouseDown:sr,onClick:()=>o.selectDay(e.iso),onKeyDown:r},String(e.day))}function Vp(e){let t=ct(),o=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]),ot("div",e,{ref:o,className:"docx-content-control-calendar-grid","data-docx-part":"grid",role:"grid","aria-label":t.calendar.title},Array.from({length:6},(n,r)=>jsx("div",{role:"row",className:"docx-content-control-calendar-week",children:t.calendar.days.slice(r*7,r*7+7).map(i=>jsx(zp,{day:i},i.iso))},r)))}function Gp(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-content-control-calendar-today","data-docx-part":"today",disabled:!t.isEnabled,onMouseDown:sr,onClick:t.selectToday},o("contentControl.calendar.today"))}function jp(e){return ot("div",e,{className:"docx-content-control-calendar","data-docx-part":"calendar"},jsxs(Fragment,{children:[jsx(Zp,{}),jsx($p,{}),jsx(Vp,{}),jsxs("div",{className:"docx-content-control-calendar-entry","data-docx-part":"dateEntry",children:[jsx(Gp,{}),jsx(zs,{})]}),jsx(ba,{}),jsx(Gs,{})]}))}function Yp({item:e,...t}){let o=ct();return ot("button",t,{type:"button",className:"docx-content-control-menu-item","data-docx-part":"item","data-value":e.value,role:"option",tabIndex:o.items.findIndex(n=>n.value===o.value)<0?o.items[0]===e?0:-1:o.value===e.value?0:-1,"aria-selected":o.value===e.value,disabled:!o.isEnabled,onMouseDown:sr,onClick:()=>o.apply(e.value)},e.displayText)}function $s(e){let t=ct(),o=tt();return ot("div",e,{className:"docx-content-control-menu-list","data-docx-part":"list",role:"listbox",id:t.listId,"aria-label":o(`contentControl.types.${t.kind}`)},t.kind==="buildingBlockGallery"&&t.items.length===0?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(Yp,{item:n},r)))}function zs(e){let t=ct(),o=tt();return ot("input",e,{type:"text",className:"docx-content-control-menu-input","data-docx-part":"input","aria-label":o(`contentControl.types.${t.kind}`),value:t.kind==="date"?t.dateText:t.value,placeholder:t.kind==="date"?calendarDateText("2006-11-22",t.session.locale):void 0,"aria-invalid":t.refused||void 0,role:t.kind==="comboBox"?"combobox":void 0,"aria-expanded":t.kind==="comboBox"?true:void 0,"aria-controls":t.kind==="comboBox"?t.listId:void 0,"aria-autocomplete":t.kind==="comboBox"?"list":void 0,onKeyDown:n=>{n.key!=="Enter"||n.nativeEvent.isComposing||(n.preventDefault(),n.stopPropagation(),t.kind==="date"?t.applyDateText():t.apply());},onMouseDown:sr,onChange:n=>(t.kind==="date"?t.setDateText:t.setValue)(n.target.value)},void 0)}function ba(e){let t=ct(),o=tt();return t.refused?ot("div",e,{className:"docx-content-control-widget-error","data-docx-part":"error",role:"alert"},o("disabledReason.invalidValue")):null}function Xp(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-dialog__button docx-dialog__button--primary","data-docx-part":"apply",disabled:!t.isEnabled,onClick:()=>t.kind==="date"?t.applyDateText():t.apply()},o("common.apply"))}function Vs(e){let t=ct(),o=tt();return ot("button",e,{type:"button",className:"docx-dialog__button","data-docx-part":"cancel",onClick:t.cancel},o("common.cancel"))}function Gs(e){return ot("div",e,{className:"docx-dialog__footer","data-docx-part":"footer"},jsxs(Fragment,{children:[jsx(Vs,{}),jsx(Xp,{})]}))}function Jp(e){return ot("div",e,{className:"docx-content-control-calendar-navigation","data-docx-part":"navigation"},jsxs(Fragment,{children:[jsx(Qp,{}),jsx(em,{})]}))}function Qp(e){let t=ct(),o=tt();return ot("select",e,{className:"docx-content-control-calendar-month","data-docx-part":"month","aria-label":o("contentControl.calendar.month"),value:t.calendar.month,onChange:n=>t.showMonth(t.calendar.year,Number(n.target.value))},calendarMonthNames(t.session.locale).map((n,r)=>jsx("option",{value:r,children:n},r)))}function em(e){let t=ct(),o=tt();return ot("input",e,{type:"number",min:100,max:9999,className:"docx-content-control-calendar-year","data-docx-part":"year","aria-label":o("contentControl.calendar.year"),key:t.calendar.year,defaultValue:t.calendar.year,onBlur:n=>{let r=Number(n.target.value);if(!Number.isInteger(r)||r<100||r>9999){n.target.value=String(t.calendar.year);return}t.showMonth(r,t.calendar.month);},onKeyDown:n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&(n.preventDefault(),n.currentTarget.blur());}},void 0)}function tm({autoOpen:e,...t}){let o=ct(),n=tt(),r=useRef(null),i=useRef(false);return useLayoutEffect(()=>{e!==false&&!i.current&&(i.current=true,r.current?.click());},[e]),ot("input",t,{ref:r,type:"file",accept:o.accept,className:"docx-content-control-picture-input","data-docx-part":"picture","aria-label":n("contentControl.types.picture"),"aria-invalid":o.refused||void 0,onMouseDown:sr,onCancel:o.cancel,onChange:a=>{let l=a.target.files?.[0];a.target.value="",l&&o.replaceImage(l);}},void 0)}function qM(e){let[t,o]=useState(e.session),[n,r]=useState(0);return t!==e.session&&(o(e.session),r(n+1)),jsx(UM,{...e},n)}function UM({session:e,className:t,style:o,children:n}){let r=tt(),i=R0(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(D0,{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??$M(i)})})}function $M(e){return e.kind==="date"?jsx(jp,{}):e.kind==="picture"?jsxs(Fragment,{children:[jsx(tm,{}),jsx(ba,{}),jsx(Vs,{})]}):e.kind==="comboBox"?jsxs(Fragment,{children:[jsx(zs,{}),jsx($s,{}),jsx(ba,{}),jsx(Gs,{})]}):jsxs(Fragment,{children:[jsx($s,{}),jsx(ba,{})]})}var am=Object.assign(qM,{Navigation:Jp,Month:Qp,Year:em,Calendar:jp,Header:Zp,PreviousMonth:Kp,Title:Up,NextMonth:qp,Weekdays:$p,Grid:Vp,Day:zp,Today:Gp,List:$s,Item:Yp,Input:zs,Picture:tm,Error:ba,Footer:Gs,Apply:Xp,Cancel:Vs});function lm(e){return e==="checkbox"?"contentControlCheckbox":e==="picture"?"contentControlPicture":"contentControlWidget"}function I0(){let e=A(),t=Rt(),o=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?.[lm(f.kind)]===false)return f.cancel();r(f),f.signal.addEventListener("abort",()=>{u&&r(b=>b===f?null:b);},{once:true});}},{fallback:true});return ()=>{u=false,p(),r(null);}},[e,l,s,c]),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?.[lm(n.kind)]===false&&n.cancel(),t?.invalidTextFormField===false&&i?.cancel();},[t,n,i]);let m=n?t?.[lm(n.kind)]:void 0;return jsxs(Fragment,{children:[n&&m&&Te(m,{session:n},n),i&&t?.invalidTextFormField&&Te(t.invalidTextFormField,{session:i},i)]})}var c1=["nw","n","ne","e","se","s","sw","w"],A0=40,O0=12;function d1(e){return `imageOverlay.handle.${e}`}function u1(e){switch(e){case "nw":case "se":return "nwse-resize";case "ne":case "sw":return "nesw-resize";case "n":case "s":return "ns-resize";default:return "ew-resize"}}function p1(e){return {nw:{x:"0%",y:"0%"},n:{x:"50%",y:"0%"},ne:{x:"100%",y:"0%"},e:{x:"100%",y:"50%"},se:{x:"100%",y:"100%"},s:{x:"50%",y:"100%"},sw:{x:"0%",y:"100%"},w:{x:"0%",y:"50%"}}[e]}function m1(e,t){return e>0&&t>0?"se":e>0&&t<0?"ne":e<0&&t>0?"sw":e<0&&t<0?"nw":e>0?"e":e<0?"w":t>0?"s":"n"}function cm({containerRef:e,portalRef:t,scrollPort:o}){let n=A(),{t:r}=H(),[i,a]=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),b=useRef(null);useEffect(()=>{let T=e.current;if(!T)return;let S=P=>{let w=isElementNode(P.target)?P.target:null;if(w?.closest(".docx-drawing-textbox-content")){f.current=null;return}let _=w?.closest("[data-drawing-node-id]")?.getAttribute("data-drawing-node-id");f.current=_??null,_&&_===i?.id&&queueMicrotask(()=>p.current?.focus({preventScroll:true}));};return T.addEventListener("pointerdown",S,{capture:true}),()=>T.removeEventListener("pointerdown",S,{capture:true})},[e,i?.id]),useEffect(()=>{if(!n){a(null);return}let T=()=>{a(selectedDrawingOverlayTargetOf(n.surface));},S=()=>{queueMicrotask(T);};T();let P=[n.on("change",S),n.on("selectionChange",T)];return ()=>{for(let w of P)w();}},[n]);let y=useCallback(()=>{d(T=>{let S=overlayHostOrigin(e.current);return S.left===T.left&&S.top===T.top?T:S});},[e]);useEffect(()=>{y();let T=t.current,S=hostWindowOf(T).ResizeObserver;if(!T||typeof S!="function")return;let P=new S(y);P.observe(T);let w=e.current;return w&&P.observe(w),()=>P.disconnect()},[e,t,y,i]),useEffect(()=>{if(o){b.current=o;return}let T=e.current;if(!T||!n?.surface)return;let S=T.closest(".docx-editor__scroll-container");if(!S)return;let P=n.surface.overlayCoordinates();return b.current=createImageOverlayScrollPort(S,P.paintScale),()=>{b.current=null;}},[e,n,o]);let v=useCallback(()=>{s(null),u.current=null;let T=g.current;if(g.current=null,T)try{T.releasePointerCapture(T._lastPointerId??0);}catch{}},[]),x=useCallback((T,S,P,w,_,L,N)=>{if(!n?.surface)return;let B=n.surface.activeScope();if(B.kind==="frame"&&!n.surface.selectDrawing(P.id,B.hostParagraphId))return;let F=n.surface.layout(),D=captureImageMutationPreconditions(n);if(D){u.current=Object.freeze({x:w,y:_}),g.current=L,L._lastPointerId=N;try{L.setPointerCapture(N);}catch{}s({session:Object.freeze({drawingNodeId:P.id,startBounds:Object.freeze({x:P.x,y:P.y,width:P.width,height:P.height}),startWidthEmu:P.widthEmu,startHeightEmu:P.heightEmu,startPosition:P.position,anchorFrameOrigin:P.anchorFrameOrigin,transform:P.transform,mode:T,handle:S,preconditions:D,layoutRevision:F.revision,packageRevision:n.surface.session.packageRevision(),kind:P.kind}),bounds:P,accumulatedScrollPt:0}),p.current?.focus({preventScroll:true});}},[n]),h=useCallback((T,S,P,w,_)=>{if(!n)return;if(isStaleImageInteractionCommit(n,T)){v();return}T.mode==="resize"?n.exec({type:"setImageProperties",widthEmu:S,heightEmu:P,..._?.mode==="simple"?{horizontalEmu:_.horizontalEmu,verticalEmu:_.verticalEmu}:{},..._?.mode==="frame"?{..._.horizontalEmu!==void 0?{horizontalEmu:_.horizontalEmu}:{},..._.verticalEmu!==void 0?{verticalEmu:_.verticalEmu}:{}}:{}}):T.mode==="move"&&_&&n.exec({type:"setImagePosition",..._}),v();},[v,n]),k=useCallback(T=>{if(!n)return;let S=m.current?.bounds??selectedDrawingOverlayTargetOf(n.surface);if(!S)return;if(m.current&&T.key==="Escape"){T.preventDefault(),T.stopPropagation(),v();return}if(m.current)return;let P=historyShortcutOf(T);if(P){T.preventDefault(),T.stopPropagation(),n.exec({type:P});return}let w=T.shiftKey?IMAGE_OVERLAY_NUDGE_SHIFT_PT:IMAGE_OVERLAY_NUDGE_PT;if(T.key==="Delete"||T.key==="Backspace"){T.preventDefault(),T.stopPropagation(),n.exec({type:"deleteImage"});return}if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(T.key))return;T.preventDefault(),T.stopPropagation();let _=T.key==="ArrowLeft"?-w:T.key==="ArrowRight"?w:0,L=T.key==="ArrowUp"?-w:T.key==="ArrowDown"?w:0;if(T.altKey){if(!S.canResize)return;let B=m1(_,L),F=computeImageResizeResult({handle:B,startWidthEmu:S.widthEmu,startHeightEmu:S.heightEmu,startBounds:{x:S.x,y:S.y,width:S.width,height:S.height},startPosition:S.position,anchorFrameOrigin:S.anchorFrameOrigin,deltaXPt:_,deltaYPt:L,transform:S.transform,preserveAspect:resizePreservesAspect(B,S.aspectLocked,T.shiftKey,S.textbox),kind:S.kind});n.exec({type:"setImageProperties",widthEmu:F.widthEmu,heightEmu:F.heightEmu,...F.position?.mode==="simple"?{horizontalEmu:F.position.horizontalEmu,verticalEmu:F.position.verticalEmu}:{},...F.position?.mode==="frame"?{...F.position.horizontalEmu!==void 0?{horizontalEmu:F.position.horizontalEmu}:{},...F.position.verticalEmu!==void 0?{verticalEmu:F.position.verticalEmu}:{}}:{}});return}if(S.kind!=="anchored"||!S.canMove||!S.position)return;let N=computeMovedImagePosition(S.position,_,L);n.exec({type:"setImagePosition",...N});},[v,n]);useEffect(()=>{if(!l||!n?.surface)return;let T=n.surface.overlayCoordinates(),S=_=>{let L=m.current,N=u.current;if(!L||!N)return;let B=cssPixelsToLayoutPoints(_.clientX-N.x,T.paintScale),F=cssPixelsToLayoutPoints(_.clientY-N.y,T.paintScale);if(L.session.mode==="move"){let R=0,U=b.current,V=e.current?.closest(".docx-editor__scroll-container");if(U&&V){let j=V.getBoundingClientRect();_.clientY>j.bottom-A0?R=O0:_.clientY<j.top+A0&&(R=-O0),R!==0&&(R=U.scrollBy(R));}let Y=L.accumulatedScrollPt+R;s({...L,accumulatedScrollPt:Y,bounds:Object.freeze({...L.bounds,x:L.session.startBounds.x+B,y:L.session.startBounds.y+F+Y})});return}if(!L.session.handle)return;let D=computeImageResizeResult({handle:L.session.handle,startWidthEmu:L.session.startWidthEmu,startHeightEmu:L.session.startHeightEmu,startBounds:L.session.startBounds,startPosition:L.session.startPosition,anchorFrameOrigin:L.session.anchorFrameOrigin,deltaXPt:B,deltaYPt:F,transform:L.session.transform,preserveAspect:resizePreservesAspect(L.session.handle,L.bounds.aspectLocked,_.shiftKey,L.bounds.textbox),kind:L.session.kind});s({...L,bounds:Object.freeze({...L.bounds,x:D.previewBounds.x,y:D.previewBounds.y,width:D.previewBounds.width,height:D.previewBounds.height,widthEmu:D.widthEmu,heightEmu:D.heightEmu})});},P=_=>{let L=m.current;if(L)if(_.type==="pointerup"){let N=cssPixelsToLayoutPoints(_.clientX-(u.current?.x??_.clientX),T.paintScale),B=cssPixelsToLayoutPoints(_.clientY-(u.current?.y??_.clientY),T.paintScale),F=finalizeImageOverlayInteraction({session:L.session,deltaXPt:N,deltaYPt:B,accumulatedScrollPt:L.accumulatedScrollPt,aspectLocked:L.bounds.aspectLocked,textbox:L.bounds.textbox,shiftKey:_.shiftKey,anchorFrameOrigin:L.session.anchorFrameOrigin});h(L.session,F.widthEmu,F.heightEmu,F.previewBounds,F.position);}else v();},w=hostWindowOf(e.current);return w.addEventListener("pointermove",S),w.addEventListener("pointerup",P),w.addEventListener("pointercancel",P),()=>{w.removeEventListener("pointermove",S),w.removeEventListener("pointerup",P),w.removeEventListener("pointercancel",P);}},[v,h,e,n,l]),useEffect(()=>{!i||f.current!==i.id||(f.current=null,p.current?.focus({preventScroll:true}));},[i]);let E=l?.bounds??i,C=useMemo(()=>{if(!n?.surface||!E)return null;let T=n.surface.publishedLayout(),S=n.surface.overlayCoordinates(),P=overlayFrameToSheetCssPixels(T,{pageIndex:E.pageIndex,x:E.x,y:E.y,width:E.width,height:E.height},S),w={left:P.left+c.left,top:P.top+c.top,width:P.width,height:P.height},_=E.canResize,L=E.kind==="anchored"&&E.canMove,N=textboxFrameReason(E,n.surface.editingMode()),B=N?r(N):void 0;return jsxs("div",{ref:p,className:"docx-image-selection-overlay","data-drawing-node-id":E.id,tabIndex:0,onKeyDown:k,children:[jsx("div",{className:`docx-image-selection-overlay__frame${L?" docx-editor-one-surface__overlay-control":""}`,"data-textbox":E.textbox?"true":void 0,title:B,"aria-description":B,role:"group","aria-label":r("imageOverlay.selection"),style:{left:`${w.left}px`,top:`${w.top}px`,width:`${w.width}px`,height:`${w.height}px`,cursor:L?"move":"default"},onPointerDown:F=>{$(F),!(!L||!E.position)&&F.button===0&&(F.preventDefault(),F.stopPropagation(),x("move",null,E,F.clientX,F.clientY,F.currentTarget,F.pointerId));}}),_?c1.map(F=>{let D=p1(F);return jsx("button",{type:"button",className:"docx-image-selection-overlay__handle","aria-label":r(d1(F)),tabIndex:0,style:{left:`calc(${w.left}px + ${w.width}px * ${parseFloat(D.x)/100} - 5px)`,top:`calc(${w.top}px + ${w.height}px * ${parseFloat(D.y)/100} - 5px)`,cursor:u1(F)},onPointerDown:R=>{$(R),R.button===0&&(R.preventDefault(),R.stopPropagation(),x("resize",F,E,R.clientX,R.clientY,R.currentTarget,R.pointerId));}},F)}):null]})},[E,x,n,k,c.left,c.top,r]);return !C||!t.current?null:createPortal(C,t.current)}function dm(e){return [...e.items].some(t=>t.kind==="file"&&t.type.startsWith("image/"))}function Qs({className:e}){let t=A(),o=si(),n=useRef(null),r=useContext(Rr),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&&dm(m)&&(clipboardPasteLandsContent(m)||(d.preventDefault(),o.insertFromDataTransfer(m)));},[o]),s=useCallback(d=>{!o?.isEnabled||!dm(d.dataTransfer)||d.preventDefault();},[o]),c=useCallback(d=>{if(o?.isEnabled&&dm(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(Vh,{}),jsx(u0,{}),jsx(I0,{}),t?jsx(cm,{containerRef:n,portalRef:a}):null]})}function pm({open:e,onClose:t,children:o,url:n,name:r,features:i,title:a,styles:l}){let[s,c]=useState(null),{dir:d}=H(),m=Ut(),u=useRef(t);u.current=t;let g=useRef({url:n,name:r,features:i,title:a,styles:l});g.current={url:n,name:r,features:i,title:a,styles:l};let p=useRef(null);return useEffect(()=>{if(!e)return;let f=p.current;if(f)f.claimed=true;else {let{url:x,name:h,features:k,title:E,styles:C}=g.current;f={claimed:true,promise:openEditorWindow({...x!==void 0?{url:x}:{},...h!==void 0?{name:h}:{},...k!==void 0?{features:k}:{},...E!==void 0?{title:E}:{},...C!==void 0?{styles:C}:{}})},p.current=f;}let b=f,y=true,v;return b.promise.then(x=>{if(y){if(!x){p.current=null,u.current?.();return}v=x.onClose(()=>{y&&(p.current=null,flushSync(()=>c(null)),u.current?.());}),c(x);}}),()=>{y=false,v?.(),b.claimed=false,c(null),queueMicrotask(()=>{b.claimed||(p.current===b&&(p.current=null),b.promise.then(x=>x?.close()));});}},[e]),!s||!e?jsx(Fragment,{children:o}):createPortal(jsx("div",{className:`docx-editor${m?" dark":""}`,style:{height:"100%"},dir:d,children:o}),s.element)}function $e(e){return e/1440*96}function ec(e){return e/96*1440}function _t(e){return `${Math.round(e*100)/100}px`}function mm(e){return e/2}var N1=e=>e.isLoading||e.isOpening===true,F1=e=>({width:$e(e.pageSetup?.pageWidthTwips??12240)*e.zoom,height:$e(e.pageSetup?.pageHeightTwips??15840)*e.zoom}),L1=(e,t)=>e.width===t.width&&e.height===t.height;function fm({className:e}){return jsx("span",{className:`docx-editor__loading-spinner${e?` ${e}`:""}`,"aria-hidden":"true"})}var K0=false;function q0(){K0||!xt()||(K0=true,console.warn("[docx-editor] loadingIndicator is ignored with chrome={false}, which renders no loading screen. Compose <DocxEditor.Loading overlay indicator={...} /> in a positioned box instead."));}function H1(e){let t=A(),[o,n]=useState(null);return useEffect(()=>{if(!(!t||!e))return t.setOpeningIndicatorHost({publish:n}),()=>{t.setOpeningIndicatorHost(null),n(null);}},[t,e]),o}function A1({when:e=false,overlay:t=false,className:o,style:n,indicator:r,children:i}){let a=W(N1),l=W(F1,L1),s=H1(t),c=A(),d=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}=H(),f=Ut(),b=r??jsxs(Fragment,{children:[jsx(fm,{}),jsx("span",{className:"docx-editor-sr-only",children:p("loading.label")})]});if(s)return createPortal(b,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: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:b})})})})})}var tc=Object.assign(A1,{Spinner:fm});function U0(){let e=new Set,t=new Map,o=new Map,n=0,r=null,i=false;function a(){if(e.size===0&&t.size===0)return;if(t.size===0)return "kind";let u=Object.create(null),g=[...t].sort((p,f)=>(o.get(p[0])??0)-(o.get(f[0])??0));for(let[,{author:p,style:f}]of g)u[p]=f;return {authors:u,others:e.size>0?"kind":"author"}}let l=null,s=false;function c(u){if(u===void 0)return "none";if(typeof u=="string")return u;let g=Object.entries(u.authors).map(([p,f])=>`${p}\0${JSON.stringify(f)}`).sort();return `${u.others??"kind"}${g.join("")}`}function d(){if(!r)return;let u=a(),g=c(u);if(g!==l){if(u===void 0){i&&(r.setRevisionStyles("author"),i=false,l=g);return}r.setRevisionStyles(u),i=true,l=g;}}function m(){!r||s||(s=true,queueMicrotask(()=>{s=false,d();}));}return {registerScheme(u){e.add(u),m();},register(u,g,p){o.has(u)||o.set(u,n++),t.set(u,{author:g,style:p}),m();},unregister(u){(e.delete(u)||t.delete(u))&&m();},connect(u){r=u;let g=a();i=u!==null&&g!==void 0,l=u===null?null:c(g),m();},current:a}}var Hi=createContext(null);function V0(){let e=useRef(null);return e.current===null&&(e.current=Symbol("revision-style-declaration")),e.current}function gm(){let e=useContext(Hi),t=V0();return useEffect(()=>{if(e)return e.registerScheme(t),()=>e.unregister(t)},[e,t]),null}function bm(e){let{author:t,color:o,background:n,activeBackground:r,spanClassName:i,avatarUrl:a}=e,l=useContext(Hi),s=V0();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 j0(e,t){e===t||G0||!xt()||(G0=true,console.warn("[docx-editor] fieldResults changed after the editor was created, so the change is ignored. The editor reads fieldResults once; create a new editor to change it."));}var Y0=false,X0=e=>e?.allowFormattingInLockedContent===true;function J0(e,t){X0(e)===X0(t)||Y0||!xt()||(Y0=true,console.warn("[docx-editor] contentLockPolicy changed after the editor was created, so the change is ignored. The editor reads contentLockPolicy once; create a new editor to change it."));}var Q0=false;function ey(e){return e===void 0?"characters":e}function ty(e,t){ey(e)===ey(t)||Q0||!xt()||(Q0=true,console.warn("[docx-editor] lockedControlNavigation changed after the editor was created, so the change is ignored. The editor reads lockedControlNavigation once; create a new editor to change it."));}function V1(e,t){if(e===t)return true;let o=resolveZoomMode(e),n=resolveZoomMode(t);return o!==null&&n!==null&&sameZoomMode(o,n)}function G1(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:Ai,rootProps:s,rootListeners:c,editorRef:o}}function Ai(e){let{document:t,fonts:o,fontShaping:n,author:r,locale:i,translate:a,mode:l,zoom:s,zoomMode:c,tableInteractionLabel:d,imageDecodePort:m,colorMode:u,children:g}=e,p=Ul(u),{t:f}=H(),b=useCallback((K,de)=>f(K,de),[f]),y=useRef(b);y.current=b;let v=useRef(false),[x,h]=useState(0),k=useRef(e);k.current=e;let E=n?.maxFontBytes,[C,T]=useState(null),S=useRef(e.fieldResults),P=useRef(e.contentLockPolicy),w=useRef(e.lockedControlNavigation),_=useRef(e.fonts),L=useRef(null);L.current??=U0();let N=L.current,B=useRef(null);B.current??=fg();let F=B.current;useEffect(()=>{let K=k.current,de=K.translate??y.current,ke=N.current();S.current=K.fieldResults,P.current=K.contentLockPolicy,w.current=K.lockedControlNavigation;let Ze=createDocxEditor({unsupportedElementRules:F.current(),...K.document!==void 0?{document:K.document}:{},...K.fonts?{fonts:K.fonts}:{},...K.fontShaping?{fontShaping:K.fontShaping}:{},...K.author!==void 0?{author:K.author}:{},...K.locale!==void 0?{locale:K.locale}:{},translate:de,...K.revisionMarkup!==void 0?{revisionMarkup:K.revisionMarkup}:{},...K.reviewDisplayMode!==void 0?{reviewDisplayMode:K.reviewDisplayMode}:{},...K.fieldResults!==void 0?{fieldResults:K.fieldResults}:{},...K.contentLockPolicy!==void 0?{contentLockPolicy:K.contentLockPolicy}:{},...K.lockedControlNavigation!==void 0?{lockedControlNavigation:K.lockedControlNavigation}:{},...K.mode!==void 0?{mode:K.mode}:{},...ke!==void 0?{revisionStyles:ke}:{},...K.modules!==void 0?{modules:K.modules}:{},...K.zoom!==void 0?{zoom:K.zoom}:{},...K.zoomMode!==void 0?{zoomMode:K.zoomMode}:{},...K.tableInteractionLabel?{tableInteractionLabel:K.tableInteractionLabel}:{},...K.imageDecodePort?{imageDecodePort:K.imageDecodePort}:{},onFontError:Ye=>k.current.onFontError?.(Ye)});_.current=K.fonts;let at=Ze.on("revisionMarkupChange",Ye=>{v.current||(k.current.onRevisionMarkupChange?.(Ye),h(Wn=>Wn+1));}),Ce=Ze.on("change",Ye=>k.current.onChange?.(Ye));return T(Ze),()=>{at(),Ce(),Ze.destroy(),T(Ye=>Ye===Ze?null:Ye);}},[t,E,m,N,F]),useEffect(()=>{!C||_.current===o||(_.current=o,C.setFonts(o).catch(()=>{}));},[C,o]),useEffect(()=>{if(!C)return;if(!C.snapshot().isOpening){k.current.onReady?.(C);return}let K=C.on("change",()=>{K(),k.current.onReady?.(C);});return K},[C]);let D=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 ke=D.current.mode,Ze=c!==void 0&&(ke===void 0||!V1(ke,c)),at=c===void 0?null:resolveZoomMode(c),Ce=de&&c!==void 0&&at!==null&&at.type==="fit";(Ze||Ce)&&(D.current.mode=c,C.setZoomMode(c));},[C,s,c]),useEffect(()=>{if(!C||e.revisionMarkup===void 0)return;let K=resolveRevisionMarkup(e.revisionMarkup);if(JSON.stringify(K)!==JSON.stringify(C.snapshot().revisionMarkup)){v.current=true;try{C.setRevisionMarkup(K);}finally{v.current=false;}}},[C,e.revisionMarkup,x]),useEffect(()=>{C&&C.setAuthor(r);},[C,r]);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??b);},[C,a,b]),useEffect(()=>{C&&C.setLocale(i);},[C,i]),useEffect(()=>{C&&j0(S.current,e.fieldResults);},[C,e.fieldResults]),useEffect(()=>{C&&J0(P.current,e.contentLockPolicy);},[C,e.contentLockPolicy]),useEffect(()=>{C&&ty(w.current,e.lockedControlNavigation);},[C,e.lockedControlNavigation]),useEffect(()=>{C&&C.setTableInteractionLabel(d??defaultTableLabel);},[C,d]);let[U,V]=useState(0),[Y,j]=useState(0),q=useRef([]),[X,ee]=useState(0),O=X>0,I=useRef(C);I.current=C,useEffect(()=>{if(!(!C||!O))return C.setCommentDraftChrome({onRequest:()=>q.current.at(-1)?.()})},[C,O]);let ie=useMemo(()=>({mounted:U,register:()=>(V(K=>K+1),()=>V(K=>Math.max(0,K-1))),gutters:Y,reserveGutter:()=>(j(K=>K+1),()=>j(K=>Math.max(0,K-1))),registerCommentDraft:K=>(q.current.push(K),ee(de=>de+1),()=>{let de=q.current.indexOf(K);de!==-1&&(q.current.splice(de,1),ee(ke=>Math.max(0,ke-1)));}),requestCommentDraft:()=>{let K=I.current;return K!==null&&runToolbarCommand(K,"review.addComment").ok}}),[U,Y]),ge=useMemo(Lg,[]);return useEffect(()=>(N.connect(C),()=>N.connect(null)),[N,C]),useEffect(()=>(F.connect(C),()=>F.connect(null)),[F,C]),jsx(qn.Provider,{value:p,children:jsx(Rr.Provider,{value:F,children:jsx(Kh,{value:a??b,children:jsx(At.Provider,{value:ie,children:jsx(Bd.Provider,{value:C,children:jsx(Yd.Provider,{value:ge,children:jsx(Hi.Provider,{value:N,children:jsx(j1,{children:jsx(Y1,{children:jsx(d0,{value:e.popups,children:jsx(cs,{children:jsx(zh,{popups:e.popups,children:g})})})})})})})})})})})})}function j1({children:e}){let[t,o]=useState(0),n=useCallback(()=>(o(i=>i+1),()=>o(i=>i-1)),[]),r=Xl(t>0);return jsx(cu.Provider,{value:n,children:jsx(Ya.Provider,{value:r,children:e})})}function Y1({children:e}){let t=Ql();return jsx(Tu.Provider,{value:t,children:e})}var Oi=316,xa=REVIEW_MARKERS_GUTTER_PX,iy=24,oc={inlineStart:0,inlineEnd:Oi},ny={inlineStart:xa,inlineEnd:xa},a2={inlineStart:0,inlineEnd:0},xm={inlineStart:iy,inlineEnd:Oi};function i2(e){return e.inlineStart===xm.inlineStart&&e.inlineEnd===xm.inlineEnd}function ly(e,t){return i2(e)?Math.max(0,t-(Oi-xa)):t}function nc(){let e=lt(),t=we(),[o,n]=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 sy(e,t){return t==="left"?{left:e.inlineEnd,right:e.inlineStart}:{left:e.inlineStart,right:e.inlineEnd}}function cy({open:e,viewportWidth:t,pageWidthPx:o,inlineStartReservation:n=0,docked:r=false,scroll:i=false}){if(!e)return ny;if(r||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0)return oc;let a=Number.isFinite(n)&&n>0?n:0;return t-a-o-2*iy>=Oi?oc:i?xm:ny}var l2=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,reviewPaneOpen:e.reviewPaneOpen??true,entitledZoom:reviewPaneEntitledZoom(t,e.zoom,e.reviewPane.overflow),scroll:e.reviewPane.overflow==="scroll"}},s2=(e,t)=>e.reviewPaneOpen===t.reviewPaneOpen&&e.scroll===t.scroll&&e.entitledZoom===t.entitledZoom&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips;function dy(){let e=we(),[t,o]=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 En(){let e=useContext(At),{pageSetup:t,reviewPaneOpen:o,entitledZoom:n,scroll:r}=W(l2,s2),i=we(),a=Ag(),l=useRef(null);t&&(l.current=t.pageWidthTwips);let s=t?.pageWidthTwips??l.current,c=Wl(e),d=useCallback(f=>c?cy({open:o,viewportWidth:f??0,pageWidthPx:s===null||n===null?0:$e(s)*n,inlineStartReservation:a,docked:n===null,scroll:r}):a2,[c,o,s,n,a,r]),m=()=>d(i?i.clientWidth:null),[u,g]=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 b=()=>g(v=>{let x=d(i.clientWidth);return x===v.gutter?v:{compute:d,viewport:i,gutter:x}}),y=new f(b);return y.observe(i),()=>y.disconnect()},[i,d]),p.gutter}var rc=[.25,.5,.75,1,1.25,1.5,2];function Bi(e,t){return t==="in"?rc.find(n=>n>e+.001)??null:[...rc].reverse().find(n=>n<e-.001)??null}function uy(e,t){return e==="0"?1:e==="+"||e==="="?Bi(t,"in")??t:e==="-"?Bi(t,"out")??t:null}var Cm=createContext(false);function py(e){let t=useContext(Cm),[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 b2=e=>e.reviewPaneOpen??true,h2=e=>e.zoomMode?.type==="fit";function ac({className:e,style:t,children:o}){let{t:n}=H(),r=$t(),i=A(),a=W(b2),l=En(),s=nc(),c=W(h2),d=useContext(At),m=Wl(d),u=$n(),g=zn(),p=useRef(null),f=useCallback(y=>{p.current=y,u?.setViewport(y);},[u]),b=useCallback(y=>{if(!i||!(y.metaKey||y.ctrlKey)||y.altKey)return;let v=y.target;if(isElementNode(v)&&v.closest('input, textarea, select, [role="dialog"]'))return;let x=uy(y.key,i.getZoom());x!==null&&(y.preventDefault(),i.setZoom(x));},[i]);return jsx("div",{ref:f,"data-testid":"docx-editor-scroll",tabIndex:0,role:"region","aria-label":n("editor.documentViewport"),onKeyDownCapture:b,...m?{"data-review-pane":a?"open":"closed"}:{},...s==="left"?{"data-chrome-dir":"rtl"}:{},...m&&s==="left"?{"data-review-side":"left"}:{},...c?{"data-zoom-fit":""}:{},className:`${r}docx-editor-one-surface docx-editor-one-surface__viewport docx-editor__scroll-container${e?` ${e}`:""}`,style:{...t,"--docx-nav-shift":`${g}px`,...m?{"--docx-review-gutter":`${l.inlineEnd}px`,"--docx-review-gutter-start":`${l.inlineStart}px`,"--docx-review-strip":`${2*xa}px`}:{}},children:jsx(Wo.Provider,{value:true,children:jsx(Cm.Provider,{value:true,children:o})})})}var x2=LOADING_SNAPSHOT;function fy({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)??x2}),[t]);}function va(e,t,o,n){let r=we(),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 M2=e=>e.editingMode??"editing",Sm='[role="menuitemradio"]:not([disabled])',_2=(e,t)=>e.length===t.length&&e.every((o,n)=>o===t[n]),I2=e=>e.isLoading||e.isOpening===true,Wi=[{mode:"editing",labelKey:"editingMode.editing",hintKey:"editingMode.editingHint",path:"M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z"},{mode:"suggesting",labelKey:"editingMode.suggesting",hintKey:"editingMode.suggestingHint",path:"M240-400h122l40-40H240v40Zm0-100h222l40-40H240v40Zm0-100h322l40-40H240v40ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v320h-80v-320H160v525l46-45h274v80H240L80-80Zm520-80v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q8 9 12.5 20t4.5 22q0 11-4 22.5T943-380L723-160H600Zm300-263-37-37 37 37ZM660-220h38l121-122-19-18-18-19-122 121v38Zm140-141-18-19 37 37-19-18Z"},{mode:"viewing",labelKey:"editingMode.viewing",hintKey:"editingMode.viewingHint",path:"M480-320q75 0 127.5-52.5T660-500q0-75-52.5-127.5T480-680q-75 0-127.5 52.5T300-500q0 75 52.5 127.5T480-320Zm0-72q-45 0-76.5-31.5T372-500q0-45 31.5-76.5T480-608q45 0 76.5 31.5T588-500q0 45-31.5 76.5T480-392Zm0 192q-146 0-266-81.5T40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200Z"}],N2=Object.freeze(Wi.map(()=>null));function F2(e){return e?Wi.map(t=>{let o=e.can({type:"setEditingMode",mode:t.mode});return o.ok?null:o.reason}):N2}var L2="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z";function lc({className:e,hidden:t}){let o=A(),n=W(M2),r=W(I2),i=ae(),{t:a}=H(),[l,s]=useState(false),c=useRef(null),d=useRef(null),m=useRef(null);useEffect(()=>{if(!l)return;let x=m.current?.querySelectorAll(Sm);(m.current?.querySelector(`${Sm}[aria-checked="true"]`)??x?.[0]??void 0)?.focus();},[l]);let u=useCallback(x=>{let h=[...m.current?.querySelectorAll(Sm)??[]],k=h.indexOf(hostDocumentOf(m.current).activeElement),E=C=>{x.preventDefault(),h[(C+h.length)%h.length]?.focus();};x.key==="ArrowDown"?E(k+1):x.key==="ArrowUp"?E(k-1):x.key==="Home"?E(0):x.key==="End"&&E(h.length-1);},[]);useEffect(()=>{if(l)return listenForOutsidePress({popup:c.current,close:()=>s(false)})},[l]),va(l,c,x=>{s(false),x&&d.current?.focus();});let g=useCallback(x=>{s(false),runToolbarCommand(o,"review.editingMode",x),o?.focus();},[o]),p=toolbarCommandState(o,"review.editingMode"),f=localizeDisabledReason(p.disabledReason,a),b=W(()=>F2(o),_2),y=useMemo(()=>Wi.find(x=>x.mode===n)??Wi[0],[n]);if(t)return null;let v=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(v?.labelKey??"editingMode.label"),disabled:r||!p.enabled,...f?{title:f}:{},onMouseDown:$,onClick:()=>s(x=>!x),children:[Pm(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(v?.labelKey??"editingMode.label"),"data-testid":"editing-mode-menu",onKeyDown:u,children:Wi.map((x,h)=>{let k=localizeDisabledReason(b[h]??null,a);return jsxs("button",{type:"button",role:"menuitemradio","aria-checked":x.mode===n,className:"docx-toolbar__mode-item","data-testid":`editing-mode-${x.mode}`,disabled:k!==null,...k?{title:k}:{},onMouseDown:$,onClick:()=>g(x.mode),children:[Pm(x.path),jsxs("span",{className:"docx-toolbar__mode-text",children:[jsx("span",{className:"docx-toolbar__mode-label",children:i(x.labelKey)}),jsx("span",{className:"docx-toolbar__mode-hint",children:i(x.hintKey)})]}),jsx("span",{className:"docx-toolbar__mode-check","aria-hidden":"true",children:x.mode===n?Pm(L2):null})]},x.mode)})}):null]})}lc.docxSlot="review.editingMode";function Pm(e){return jsx("svg",{viewBox:"0 -960 960 960",width:18,height:18,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})})}var yy=[],O2=()=>{};function Zi(){let e=A(),t=useCallback(o=>{if(!e)return O2;let n=Za(o),r=e.on("change",n),i=e.on("selectionChange",n);return ()=>{r(),i();}},[e]);return useSyncExternalStore(t,()=>e?.getReviewAuthors()??yy,()=>yy)}var z2=e=>e.hiddenReviewAuthors??[];function cc({className:e,hidden:t,icon:o}){let n=A(),r=Zi(),i=W(z2),a=new Set(i),l=r.every(h=>!a.has(h.author)),[s,c]=useState(false),d=useRef(null),m=useRef(null),u=useRef(null),g=ae(),{t:p}=H();useEffect(()=>{if(s)return u.current?.querySelector('[role="menuitemcheckbox"]')?.focus(),listenForOutsidePress({popup:d.current,close:()=>c(false)})},[s]),va(s,d,h=>{c(false),h&&m.current?.focus();});let f=useCallback(h=>{let k=[...u.current?.querySelectorAll('[role="menuitemcheckbox"]')??[]],E=k.indexOf(hostDocumentOf(u.current).activeElement),C=T=>{h.preventDefault(),k[(T+k.length)%k.length]?.focus();};h.key==="ArrowDown"?C(E+1):h.key==="ArrowUp"?C(E-1):h.key==="Home"?C(0):h.key==="End"?C(k.length-1):h.key==="Tab"&&c(false);},[]);if(t)return null;let b=te("review.authors"),y=toolbarCommandState(n,"review.authors"),v=localizeDisabledReason(y.disabledReason,p),x=g(b?.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":x,disabled:!y.enabled,title:v??x,onMouseDown:$,onClick:()=>c(h=>!h),children:[o??oe(b?.paths),jsx("span",{className:"docx-toolbar__picker-value",children:x}),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":x,"data-testid":"reviewers-menu",onKeyDown:f,children:[jsx(xy,{checked:l,label:p("reviewers.all"),testId:"reviewer-all",onChoose:()=>n?.setAllReviewAuthorsVisible(!l)}),jsx("div",{className:"docx-toolbar__menu-separator",role:"separator"}),r.map(h=>jsx(xy,{checked:!a.has(h.author),label:h.author||"\u2014",testId:`reviewer-${h.slot}`,color:h.color,onChoose:()=>n?.setReviewAuthorVisible(h.author,a.has(h.author))},h.author))]}):null]})}cc.docxSlot="review.authors";function xy(e){return jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":e.checked,className:"docx-toolbar__reviewer-item","data-testid":e.testId,onMouseDown:$,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 Cy=createContext(null);function Ty({children:e}){let t=_o(),[o,n]=useState(false),r=useRef(null),i=we(),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(Cy.Provider,{value:l,children:[e,jsx(Vo,{open:o,onClose:s})]})}function Ey(){return useContext(Cy)}var wm=["M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z"],Dm=createContext({close:()=>{}});function Ca(){return useContext(Dm).close}function m_(e){e.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')?.focus();}function wy({label:e,children:t}){return 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 Dy({slot:e}){let t=ae(),o=eo(),{close:n}=useContext(Dm),{execute:r,isActive:i,isEnabled:a,disabledReason:l,value:s}=re(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:$,onClick:u=>{r(),n(u.detail===0);},children:[jsx("span",{className:"docx-toolbar__more-command-icon","aria-hidden":"true",children:oe(c?.paths)}),jsx("span",{className:"docx-toolbar__more-command-label",children:m})]})}function Ry({sections:e,className:t}){let o=ae(),[n,r]=useState(false),i=useRef(null),a=useRef(null),l=useRef(null),s=useRef(false),c=useId(),d=we(),m=useRef(d);m.current=d;let u=o("formattingBar.more"),g=useCallback(v=>{r(false),v&&a.current?.focus();},[]),p=useMemo(()=>({close:g}),[g]);useEffect(()=>{if(!n)return;let v=i.current,x=C=>i.current?.contains(C)===true||l.current?.contains(C)===true,h=v?listenForPopupEscape({popup:v,contains:x,chromeRoot:()=>i.current?.closest(".docx-editor"),editorElements:()=>[m.current],skip:()=>hasOpenNestedPopup(l.current),close:g}):void 0,k=v?listenForPopupFocusLeave({popup:v,contains:x,close:()=>r(false)}):void 0,E=listenForOutsidePress({popup:v,close:()=>r(false)});return ()=>{E(),h?.(),k?.();}},[n,g]);let[f,b]=useState(null);useLayoutEffect(()=>{if(!n){b(null);return}let v=()=>{let h=i.current,k=l.current,E=a.current,C=h?.ownerDocument.defaultView;if(!h||!k||!E||!C)return;let T=E.getBoundingClientRect(),S=toolbarPanelPlacement({triggerLeft:T.left,triggerRight:T.right,panelWidth:k.offsetWidth,viewportWidth:C.innerWidth}),P=S.left-h.getBoundingClientRect().left;b(w=>w&&w.left===P&&w.maxWidth===S.maxWidth&&w.anchor===S.anchor?w:{...S,left:P});};v();let x=i.current?.ownerDocument.defaultView;return x?.addEventListener("resize",v),()=>x?.removeEventListener("resize",v)},[n]),useEffect(()=>{if(!n||!s.current)return;s.current=false;let v=l.current;v&&m_(v);},[n]);let y=v=>{v.key!=="Escape"||v.defaultPrevented||(v.preventDefault(),g(true));};return jsxs("div",{ref:i,className:`docx-toolbar__more${t?` ${t}`:""}`,[rs]:"",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:$,onClick:()=>r(v=>!v),onKeyDown:v=>{v.key==="ArrowDown"&&(v.preventDefault(),s.current=true,r(true));},children:oe(wm)}),n?jsx(Dm.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(v=>jsxs("div",{className:"docx-toolbar__more-section",role:"group","aria-label":v.label??o(v.labelKey),children:[jsx("span",{className:"docx-toolbar__more-heading","aria-hidden":"true",children:v.label??o(v.labelKey)}),v.children]},v.id))})}):null]})}function g_(e){if(!isValidElement(e))return false;let t=e.type;return (typeof t=="function"||typeof t=="object")&&t.docxToolbarGroup===true}function _y(e,t,o,n){let r=new Map,i=new Map,a=new Map,l=[];for(let s of Children.toArray(e)){if(g_(s)){a.delete(s.props.id),a.set(s.props.id,s.props);continue}let c=t(s);if(c&&o(c))r.set(c,s);else if(c&&n(c))i.set(c,s);else {if(c&&isValidElement(s)&&s.props.hidden===true)continue;l.push(s);}}return {overrides:r,tableOverrides:i,groups:[...a.values()],appended:l}}var uc="review.addComment";function h_({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=useContext(At),a=ae(),{isEnabled:l,reason:s}=ts(a),c=Ca();if(t||(i?.mounted??0)===0)return null;let d=te(uc),m=a(d?.labelKey??uc),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":uc,disabled:!l,...l?{}:{"data-disabled":""},"aria-label":m,title:s??m,onMouseDown:$,onClick:()=>{i?.requestCommentDraft()&&c(false);}};return n?jsx(Q,{...u,children:r}):jsx("button",{...u,children:o??r??oe(d?.paths)})}var Rm=Object.assign(h_,{docxSlot:uc});var Ny=new Set;function pc(e){!xt()||Ny.has(e)||(Ny.add(e),console.warn(`[docx-editor] ${e}`));}function Fy(e,t,o){pc(`Toolbar.Group "${e}" has after="${t}", but no group has that id. The group is placed after every other group. Known ids: ${o.join(", ")}.`);}function Ly(e,t){pc(`Toolbar.Group "${e}" is a built-in group, so its ${t} is ignored. A built-in group keeps its own label and place in the bar.`);}function Hy(e){pc(`Toolbar.Group "${e}" uses the id of the contextual table group, so it is ignored. Give the group another id.`);}function Ay(e,t){pc(t?`Toolbar slot "${e}" is not part of the preset arrangement, so its content is appended after the groups. Put it in a Toolbar.Group to give it a place.`:`"${e}" is not a toolbar slot id. Its content is appended after the groups. Use a ChromeSlotId such as "text.bold".`);}var _m=[{value:"inline",labelKey:"imageWrap.menu.inLineWithText",iconName:"wrap_text"},{value:"square",labelKey:"imageWrap.square",iconName:"crop_square"},{value:"squareLeft",labelKey:"imageWrap.menu.squareLeft",iconName:"format_image_left"},{value:"squareRight",labelKey:"imageWrap.menu.squareRight",iconName:"format_image_right"},{value:"tight",labelKey:"imageWrap.tight",iconName:"wrap_text"},{value:"through",labelKey:"imageWrap.through",iconName:"wrap_text"},{value:"topAndBottom",labelKey:"imageWrap.topAndBottom",iconName:"vertical_align_center"},{value:"behind",labelKey:"imageWrap.behindText",iconName:"flip_to_back"},{value:"inFront",labelKey:"imageWrap.inFrontOfText",iconName:"flip_to_front"}];function mc({className:e,hidden:t,asChild:o,children:n}){let{t:r}=H(),i=ae(),{execute:a,value:l,isEnabled:s,disabledReason:c}=Mi("image.wrap"),[d,m]=useState(false),u=useRef(null),g=useRef(null),p=useRef(null),f=useId(),b=bn(o,n),y=useMemo(()=>_m.find(C=>C.value===l)??_m[0],[l]),v=te("image.wrap"),x=i(v?.labelKey??"formattingBar.imageWrap");useEffect(()=>{if(!d)return;let C=P=>{let w=u.current;w&&isDomNode(P.target)&&w.contains(P.target)||m(false);},T=P=>{P.key==="Escape"&&(P.preventDefault(),m(false),g.current?.focus());},S=hostDocumentOf(u.current);return S.addEventListener("mousedown",C,true),S.addEventListener("keydown",T),()=>{S.removeEventListener("mousedown",C,true),S.removeEventListener("keydown",T);}},[d]);let h=useCallback(C=>{m(false),a(C);},[a]);if(t)return null;let k=r("imageWrap.tooltipPrefix",{label:r(y.labelKey)}),E={type:"button",ref:g,className:`${hn(b)} docx-toolbar__image-wrap-trigger${e?` ${e}`:""}`,"data-slot":"image.wrap",disabled:!s,...s?{}:{"data-disabled":""},"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?f:void 0,"aria-label":x,title:c??k,onMouseDown:$,onClick:()=>m(C=>!C)};return jsxs("div",{ref:u,className:"docx-toolbar__image-wrap",children:[o?jsx(Q,{...E,children:n}):jsx("button",{...E,children:b?jsx(yn,{icon:oe(v?.paths),label:x}):n??oe(v?.paths)}),d?jsx("div",{ref:p,id:f,role:"menu",className:"docx-toolbar__image-wrap-menu","aria-label":r("imageWrap.menu.ariaLabel"),onMouseDown:C=>C.stopPropagation(),children:_m.map(C=>jsx("button",{type:"button",role:"menuitemradio",className:"docx-toolbar__image-wrap-item","aria-checked":l===C.value,...l===C.value?{"data-active":""}:{},onMouseDown:$,onClick:()=>h(C.value),children:r(C.labelKey)},C.value))}):null]})}mc.docxSlot="image.wrap";var Ui=Object.assign(mc,{docxSlot:"image.wrap"});var Ta="table.insert";function N_({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=A(),{isEnabled:a,disabledReason:l}=re(Ta),s=ae(),[c,d]=useState(false),m=useRef(null),u=useRef(null),g=useRef(null),p=useId(),f=Ca();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 b=c&&a;useLayoutEffect(()=>{let k=g.current,E=m.current,C=E?.ownerDocument.defaultView;if(!b||!k||!E||!C||E.closest(".docx-toolbar__more-panel"))return;let T=E.getBoundingClientRect(),S=toolbarPopupLeft({anchorLeft:T.left,popupWidth:k.offsetWidth,viewportWidth:C.innerWidth});k.style.left=`${S-T.left}px`;},[b]);let y=useCallback(()=>{d(false),f(false);},[f]);if(t)return null;let v=te(Ta),x=s(v?.labelKey??Ta),h={ref:u,type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Ta,disabled:!a,...a?{}:{"data-disabled":""},...b?{"data-active":""}:{},"aria-haspopup":"grid","aria-expanded":b,"aria-controls":b?p:void 0,"aria-label":x,title:l??x,onMouseDown:$,onClick:()=>{if(!c){d(true);return}d(false),i?.focus();},onKeyDown:k=>{k.key==="ArrowDown"&&(k.preventDefault(),d(true));}};return jsxs("span",{ref:m,className:"docx-toolbar__table-insert",children:[n?jsx(Q,{...h,children:r}):jsx("button",{...h,children:o??r??oe(v?.paths)}),b?jsx("div",{ref:g,id:p,className:"docx-toolbar__menu docx-toolbar__table-insert-menu",onBlur:k=>{let E=k.relatedTarget;isDomNode(E)&&!m.current?.contains(E)&&d(false);},onKeyDown:k=>{k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),d(false),u.current?.focus());},children:jsx(ps,{slot:Ta,label:s("toolbar.insertTable"),onInserted:y})}):null]})}var Nm=Object.assign(N_,{docxSlot:Ta});function nt(e){return Object.assign(o=>jsx(Ko,{slotId:e,...o}),{docxSlot:e})}var By=nt("history.undo"),Wy=nt("history.redo"),Zy=nt("text.bold"),Ky=nt("text.italic"),qy=nt("text.underline"),Uy=nt("text.strike"),$y=nt("format.clear"),zy=nt("script.super"),Vy=nt("script.sub"),Gy=nt("alignment.left"),jy=nt("alignment.center"),Yy=nt("alignment.right"),Xy=nt("alignment.justify"),Jy=nt("direction.ltr"),Qy=nt("direction.rtl"),ex=nt("list.bullet"),tx=nt("list.numbered"),ox=nt("list.outdent"),nx=nt("list.indent");var rx=nt("review.comments");function H_({className:e,hidden:t,icon:o,asChild:n,children:r}){let{execute:i,isEnabled:a,disabledReason:l}=re("text.link"),s=ae(),c=eo();if(t)return null;let d=te("text.link"),m=c(s(d?.labelKey??"text.link")),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":"text.link",disabled:!a,...a?{}:{"data-disabled":""},"aria-label":m,title:l??m,onMouseDown:$,onClick:()=>i()};return n?jsx(Q,{...u,children:r}):jsx("button",{...u,children:o??r??oe(d?.paths)})}var Fm=Object.assign(H_,{docxSlot:"text.link"});function A_({className:e,hidden:t}){let o=A(),{onSave:n}=useContext(Vn),r=ae();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:$,onClick:()=>n?.(),children:oe(i?.paths)})}var Lm=Object.assign(A_,{docxSlot:"file.save"});function dr({className:e}){return jsx("div",{role:"separator","aria-orientation":"vertical",className:`docx-toolbar__separator${e?` ${e}`:""}`})}var W_=e=>({zoom:e.zoom,mode:e.zoomMode}),Z_=(e,t)=>e.zoom===t.zoom&&e.mode===t.mode,ix={type:"fixed"};function Hm(){let e=A(),{zoom:t,mode:o}=W(W_,Z_),n=useCallback(i=>{e?.setZoom(i);},[e]),r=useCallback(i=>{e?.setZoomMode(i);},[e]);return useMemo(()=>{let i=o??ix,a=Bi(t,"out"),l=Bi(t,"in");return {zoom:t,mode:i,isFit:i.type==="fit",setZoom:n,setMode:r,fitToWidth:()=>r(FIT_WIDTH_ZOOM_MODE),auto:()=>r("auto"),reset:()=>{r(ix),n(1);},zoomIn:()=>l!==null&&n(l),zoomOut:()=>a!==null&&n(a),canZoomIn:!!e&&l!==null,canZoomOut:!!e&&a!==null,levels:rc}},[e,t,o,n,r])}var Vi=2,Gi=3276,zi=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],$_=e=>e.formatting?.fontSizePt??null;function cx(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function dx(e,t,o){for(let n=t.length-1;n>=0;n-=1)if(t[n]<e)return t[n];return Math.max(e-1,o)}function mx(e){return 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:$,onClick:e.onDecrease,children:"\u2212"}),e.middle,jsx("button",{type:"button",className:"docx-toolbar__stepper-button",disabled:!e.canIncrease,"aria-label":e.increaseLabel,onMouseDown:$,onClick:e.onIncrease,children:"+"})]})}function z_(e){let t=e.trim().replace(/pt$/i,"").trim();if(t==="")return null;let o=Number(t);if(!Number.isFinite(o))return null;let n=Math.round(o*2);return n<Vi||n>Gi?null:n}function V_({className:e,hidden:t}){let o=A(),n=W($_),{isEnabled:r,disabledReason:i}=re("font.size"),a=ae(),[l,s]=useState(false),[c,d]=useState(null),m=useRef(null);Zo(m,l,()=>s(false));let u=useRef(null),g=useId(),p=useCallback(E=>{if(!o)return;let C=commandForSlotValue("font.size",E);C&&o.can(C).ok&&o.exec(C);},[o]),f=useCallback(E=>{p(Math.min(Gi,Math.max(Vi,Math.round(E*2))));},[p]),b=useCallback(E=>{s(false),d(null),u.current?.blur(),E&&o?.focus();},[o]);if(useEffect(()=>{if(l)return listenForOutsidePress({popup:m.current,close:()=>{s(false),d(null);}})},[l]),t)return null;let y=r&&n!==null,v=n===null?"\u2014":String(Math.round(n*2)/2),x=c??v,h=n===null?null:Math.round(n*2)/2,k=()=>{if(c===null)return;let E=z_(c);E!==null&&p(E);};return jsxs("span",{ref:m,className:"docx-toolbar__font-size","data-slot":"font.size",title:i??void 0,children:[jsx(mx,{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:x,disabled:!r,role:"combobox","aria-expanded":l,"aria-haspopup":"listbox","aria-label":a("fontSize.label"),"aria-controls":l?g:void 0,autoComplete:"off",onChange:E=>{d(E.target.value),s(true);},onFocus:E=>{E.target.select(),s(true);},onClick:()=>s(true),onKeyDown:E=>{E.key==="Enter"?(E.preventDefault(),k(),b(true)):E.key==="Escape"?(E.preventDefault(),b(true)):(E.key==="ArrowDown"||E.key==="ArrowUp")&&(E.preventDefault(),s(true),n!==null&&f(E.key==="ArrowDown"?dx(n,zi,Vi/2):cx(n,zi,Gi/2)));},onBlur:()=>{k(),d(null);}}),canDecrease:y&&Math.round(n*2)>Vi,canIncrease:y&&Math.round(n*2)<Gi,onDecrease:()=>f(dx(n??0,zi,Vi/2)),onIncrease:()=>f(cx(n??0,zi,Gi/2))}),l&&r?jsx("div",{className:"docx-toolbar__menu docx-toolbar__font-size-menu",role:"listbox",tabIndex:0,"aria-label":a("fontSize.listLabel"),id:g,children:zi.map(E=>{let C=h===E;return jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>{f(E),b(true);},children:E},E)})}):null]})}var Bm=Object.assign(V_,{docxSlot:"font.size"});function G_({className:e,hidden:t}){let o=A(),{zoom:n,isFit:r,mode:i,setZoom:a,setMode:l,zoomIn:s,zoomOut:c,canZoomIn:d,canZoomOut:m,levels:u}=Hm(),g=ae(),[p,f]=useState(false),b=useRef(null);Zo(b,p,()=>f(false)),useEffect(()=>{if(p)return listenForOutsidePress({popup:b.current,close:()=>f(false)})},[p]);let y=useCallback(E=>{b.current?.querySelector("[aria-haspopup]")?.focus(),f(false),a(E);},[a]),v=useCallback(E=>{b.current?.querySelector("[aria-haspopup]")?.focus(),f(false),l(E==="auto"?"auto":FIT_WIDTH_ZOOM_MODE);},[l]);if(t)return null;let x=`${Math.round(n*100)}%`,h=sameZoomMode(i,AUTO_ZOOM_MODE),k=sameZoomMode(i,FIT_WIDTH_ZOOM_MODE);return jsxs("span",{ref:b,className:"docx-toolbar__zoom","data-slot":"zoom.level",children:[jsx(mx,{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")}: ${x}`,onMouseDown:$,onClick:()=>f(E=>!E),children:[x,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":h,...h?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>v("auto"),children:g("zoom.automatic")}),jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":k,...k?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>v("fit-width"),children:g("zoom.fitWidth")}),jsx("hr",{className:"docx-toolbar__menu-separator",role:"presentation"}),u.map(E=>{let C=!r&&Math.abs(E-n)<.001;return jsx("button",{type:"button",role:"option",tabIndex:-1,"aria-selected":C,...C?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>y(E),children:`${Math.round(E*100)}%`},E)})]}):null]})}var Wm=Object.assign(G_,{docxSlot:"zoom.level"});function ur(e,t,o,n=false){let r=we(),i=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 hx=10,yx=0,oI=e=>({lineSpacing:e.formatting?.lineSpacing??null,spaceBeforePt:e.formatting?.spaceBeforePt??null,spaceAfterPt:e.formatting?.spaceAfterPt??null}),nI=(e,t)=>e.spaceBeforePt===t.spaceBeforePt&&e.spaceAfterPt===t.spaceAfterPt&&e.lineSpacing?.rule===t.lineSpacing?.rule&&e.lineSpacing?.value===t.lineSpacing?.value;function rI({className:e,hidden:t}){let o=A(),n=W(oI,nI),{isEnabled:r,disabledReason:i}=re("list.lineSpacing"),a=re("paragraph.dialog"),l=Ey(),s=ae(),{lang:c}=H(),[d,m]=useState(false),u=useRef(null),g=useRef(null);ur(d,m,u,t);let p=useCallback(h=>{m(false),!(!o||!h.command)&&o.can(h.command).ok&&o.exec(h.command);},[o]),f=useCallback((h,k)=>{if(m(false),!o)return;let E={type:"setParagraphSpacing",[h]:k};o.can(E).ok&&o.exec(E);},[o]);if(t)return null;let b=te("list.lineSpacing"),y=(n.spaceBeforePt??0)>0,v=(n.spaceAfterPt??0)>0,x=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:$,onClick:()=>m(h=>!h),children:[oe(b?.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:[x.map(h=>{let k=h.selected;return jsxs("button",{type:"button",role:"menuitemradio","aria-checked":k,...k?{"data-selected":""}:{},className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>p(h),children:[lineSpacingMenuRowLabel(h,s,c),k?jsx("span",{className:"docx-toolbar__menu-check","aria-hidden":"true",children:"\u2713"}):null]},`${h.spacing.rule}:${h.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:$,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:$,onClick:()=>f("beforePt",y?yx:hx),children:s(y?"lineSpacing.removeSpaceBefore":"lineSpacing.addSpaceBefore")}),jsx("button",{type:"button",role:"menuitem",className:"docx-toolbar__menu-item",onMouseDown:$,onClick:()=>f("afterPt",v?yx:hx),children:s(v?"lineSpacing.removeSpaceAfter":"lineSpacing.addSpaceAfter")})]}):null]})}var Zm=Object.assign(rI,{docxSlot:"list.lineSpacing"});var lI=["alignment.left","alignment.center","alignment.right","alignment.justify"];function sI({className:e,hidden:t}){let o=re("alignment.left"),n=re("alignment.center"),r=re("alignment.right"),i=re("alignment.justify"),a=ae(),[l,s]=useState(false),c=useRef(null);if(ur(l,s,c,t),t)return null;let d=[o,n,r,i],m=lI.map((f,b)=>({slot:f,control:te(f),state:d[b]})),u=m.find(f=>f.state.isActive)??m[0],g=m.some(f=>f.state.isEnabled),p=a(u.control?.labelKey??u.slot);return 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:$,onClick:()=>s(f=>!f),children:[oe(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 b=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":b,title:f.state.disabledReason??b,onMouseDown:$,onClick:()=>{f.state.execute(),s(false);},children:oe(f.control?.paths)},f.slot)})}):null]})}var bc=Object.assign(sI,{docxSlot:"alignment"});function qm(e){let{label:t,icon:o,active:n,disabled:r,disabledReason:i,onSelect:a,asChild:l,className:s,children:c}=e,d=ss(),m=Ca();if(d==="panel"&&!l)return jsxs("button",{type:"button",className:`docx-toolbar__more-command${s?` ${s}`:""}`,disabled:r,...n?{"data-active":""}:{},...n!==void 0?{"aria-pressed":n}:{},...r&&i?{title:i}:{},onMouseDown:g=>$(g),onClick:g=>{a?.(),m(g.detail===0);},children:[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=>$(g),onClick:r?void 0:a};return l?jsx(Q,{...u,children:c}):jsx("button",{...u,children:o??c})}var bI=Object.freeze([]),hI=e=>e.formatting?.fontFamily??null,yI=e=>e;function xc(){let e=A(),t=W(hI),o=W(yI),n=useMemo(()=>e&&!o.isLoading?e.getAvailableFonts():bI,[e,o]),{isEnabled:r}=re("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 Tx=createContext(null);function $m(){return useContext(Tx)}function zm({asChild:e,className:t,children:o}){let n=$m(),r=ae();if(!n)return null;let i=r(te("font.family")?.labelKey??"font.family"),a={onClick:()=>n.setOpen(!n.open),onMouseDown:$,disabled:!n.isEnabled,className:`docx-toolbar__font-family-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,"aria-label":o!==void 0?void 0:`${i}: ${n.value??"\u2014"}`,title:i},l=o??jsx("span",{children:n.value??"\u2014"});return e?jsx(Q,{...a,children:l}):jsx("button",{type:"button",...a,children:l})}zm.docxToolbarPart=true;var xI=new Map([["arial","sansSerif"],["calibri","sansSerif"],["helvetica","sansSerif"],["verdana","sansSerif"],["open sans","sansSerif"],["roboto","sansSerif"],["times new roman","serif"],["georgia","serif"],["cambria","serif"],["garamond","serif"],["courier new","monospace"],["consolas","monospace"]]),vI=[{category:"sansSerif",labelKey:"font.sansSerif"},{category:"serif",labelKey:"font.serif"},{category:"monospace",labelKey:"font.monospace"},{category:"other",labelKey:null}];function Ex({asChild:e,className:t,children:o}){let n=$m(),r=ae(),[i,a]=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=vI.map(d=>({...d,fonts:n.options.filter(m=>m.toLowerCase().includes(i.toLowerCase())&&(xI.get(m.toLowerCase())??"other")===d.category)})).filter(d=>d.fonts.length>0).map((d,m)=>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(Sx,{value:u},u))]},d.category)),e?jsx(Q,{...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 Sx({value:e,asChild:t,className:o,children:n}){let r=A(),i=$m();if(!i)return null;let a=i.value===e,l={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:$,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__font-family-item${o?` ${o}`:""}`},s=n??jsx("span",{style:{fontFamily:e},children:e});return t?jsx(Q,{...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 CI({hidden:e,asChild:t,className:o,children:n}){let r=xc(),[i,a]=useState(false),l=useRef(null);Zo(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(zm,{}),jsx(Ex,{})]});return jsx(Tx.Provider,{value:s,children:t?jsx(Q,{...c,ref:l,children:d}):jsx("div",{ref:l,...c,children:d})})}var Vm=Object.assign(CI,{docxSlot:"font.family",Trigger:zm,Content:Ex,Item:Sx});var EI={Title:26,Subtitle:18,Heading1:24,Heading2:18,Heading3:16,Heading4:14,Heading5:13,Heading6:13,Normal:14},SI=new Set(["Title","Heading1","Heading2","Heading3"]),PI={Subtitle:"666666"},kI="#4a6c8c";function Px(e){let t=EI[e.styleId],n={fontSize:t?`${t}px`:`${Math.min(Math.max(e.fontSize?e.fontSize/2:11,11),20)}px`,lineHeight:"1.3"};(e.bold??SI.has(e.styleId))&&(n.fontWeight="bold"),e.italic&&(n.fontStyle="italic");let r=e.color??PI[e.styleId];return r?n.color=`#${r}`:e.styleId.startsWith("Heading")&&(n.color=kI),n}var kx=/^heading ([1-9])$/;function Gm(e,t){let o=e||t,n=kx.exec(o);return n?`Heading ${n[1]}`:o}var wI=new Map([["normal","styles.normal"],["title","styles.title"],["subtitle","styles.subtitle"],["no spacing","styles.noSpacing"],["quote","styles.quote"],["intense quote","styles.intenseQuote"],["list paragraph","styles.listParagraph"]]);function vc(e){let t=e.toLowerCase(),o=wI.get(t);if(o)return {key:o};let n=kx.exec(t);return n?{key:"styles.headingLevel",vars:{level:Number(n[1])}}:null}function wx(e){return !e||e.length===0?[]:e.filter(t=>t.type==="paragraph").map(t=>({styleId:t.styleId,name:Gm(t.name,t.styleId),priority:99}))}function HI(e){let t=e.fontSizePt;return {...e.fontFamily?{fontFamily:e.fontFamily}:{},...t?{fontSize:`${Math.min(Math.max(t,9),20)}px`}:{},...e.bold?{fontWeight:700}:{},...e.italic?{fontStyle:"italic"}:{},...e.color?{color:`#${e.color}`}:{}}}var AI=Object.freeze([]),OI=e=>e.formatting?.styleId??null,BI=e=>e;function Cc(){let e=A(),t=W(OI),o=W(BI),{t:n}=H(),r=useMemo(()=>e&&!o.isLoading?e.getDocumentStyles().filter(l=>l.type==="paragraph").map(l=>{let s=vc(l.name);return {styleId:l.styleId,name:s?n(s.key,s.vars):Gm(l.name,l.styleId),preview:l.preview}}):AI,[e,o,n]),{isEnabled:i}=re("styles.style"),a=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:r,isEnabled:i}),[t,a,r,i])}var Dx=createContext(null);function Ym(){return useContext(Dx)}function Xm({asChild:e,className:t,children:o}){let n=Ym(),r=ae();if(!n)return null;let i=te("styles.style"),a=r(i?.labelKey??"styles.style"),l={onClick:()=>n.setOpen(!n.open),onMouseDown:$,disabled:!n.isEnabled,className:`docx-toolbar__style-trigger${t?` ${t}`:""}`,...n.isEnabled?{}:{"data-disabled":""},"aria-haspopup":"listbox","aria-expanded":n.open,title:a},s=n.options.find(d=>d.styleId===n.value),c=o??(n.value===null?jsx("span",{children:i?.valueKey?r(i.valueKey):"\u2014"}):jsx("span",{children:s?.name??n.value}));return e?jsx(Q,{...l,children:c}):jsx("button",{type:"button",...l,children:c})}Xm.docxToolbarPart=true;function Rx({asChild:e,className:t,children:o}){let n=ae(),r=Ym();if(!r||!r.open)return null;let i={role:"listbox",tabIndex:0,"aria-label":n("styles.selectAriaLabel"),className:`docx-toolbar__menu docx-toolbar__style-content${t?` ${t}`:""}`},a=o??r.options.map(l=>jsx(Mx,{value:l.styleId},l.styleId));return e?jsx(Q,{...i,children:a}):jsx("div",{...i,children:a})}function Mx({value:e,asChild:t,className:o,children:n}){let r=A(),i=Ym();if(!i)return null;let a=i.value===e,l=i.options.find(d=>d.styleId===e),s={role:"option",tabIndex:-1,"aria-selected":a,...a?{"data-selected":""}:{},onMouseDown:$,onClick:()=>{i.setValue(e),i.setOpen(false),r?.focus();},className:`docx-toolbar__style-item${o?` ${o}`:""}`},c=n??jsx("span",{style:l?HI(l.preview):void 0,children:l?.name??e});return t?jsx(Q,{...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 WI({hidden:e,asChild:t,className:o,children:n}){let r=Cc(),[i,a]=useState(false),l=useRef(null);Zo(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(Xm,{}),jsx(Rx,{})]});return jsx(Dx.Provider,{value:s,children:t?jsx(Q,{...c,ref:l,children:d}):jsx("div",{ref:l,...c,children:d})})}var Jm=Object.assign(WI,{docxSlot:"styles.style",Trigger:Xm,Content:Rx,Item:Mx});function Ix(e,t){let o=e;return Object.assign(({className:r,hidden:i,icon:a,asChild:l,children:s})=>{let{isEnabled:c,disabledReason:d}=re(o),m=Po(),u=t==="showAll"?m.showAll:m.formFill,g=ae();if(i)return null;let p=te(o),f=g(p?.labelKey??e),b={type:"button",className:`docx-toolbar__button${r?` ${r}`:""}`,"data-slot":e,disabled:!c,...c?{}:{"data-disabled":""},...u?{"data-active":""}:{},"aria-pressed":u,"aria-label":f,title:d??f,onMouseDown:$,onClick:()=>{t==="showAll"?m.toggleShowAll():m.toggleFormFill();}};return l?jsx(Q,{...b,children:s}):jsx("button",{...b,children:a??s??oe(p?.paths)})},{docxSlot:o})}function KI({className:e,hidden:t,icon:o,asChild:n,children:r}){let i=Mt.inspector,{isEnabled:a,disabledReason:l}=re(i),{inspectorOpen:s,openInspector:c}=Po(),d=ae();if(t)return null;let m=te(i),u=d(m?.labelKey??"contentControl.inspector"),g={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Mt.inspector,disabled:!a,...a?{}:{"data-disabled":""},...s?{"data-active":""}:{},"aria-pressed":s,"aria-label":u,title:l??u,onMouseDown:$,onClick:()=>c()};return n?jsx(Q,{...g,children:r}):jsx("button",{...g,children:o??r??oe(m?.paths)})}function qI({className:e,hidden:t,icon:o,asChild:n,children:r}){let{canRemove:i,removeDisabledReason:a,remove:l}=Po(),s=ae();if(t)return null;let c=Mt.remove,d=te(c),m=s(d?.labelKey??"contentControl.remove"),u={type:"button",className:`docx-toolbar__button${e?` ${e}`:""}`,"data-slot":Mt.remove,disabled:!i,...i?{}:{"data-disabled":""},"aria-label":m,title:a??m,onMouseDown:$,onClick:()=>{l();}};return n?jsx(Q,{...u,children:r}):jsx("button",{...u,children:o??r??oe(d?.paths)})}var Tc=Ix(Mt.showAll,"showAll"),Ec=Ix(Mt.formFill,"formFill"),Sc=Object.assign(qI,{docxSlot:Mt.remove}),Pc=Object.assign(KI,{docxSlot:Mt.inspector}),Nx={[Mt.showAll]:Tc,[Mt.formFill]:Ec,[Mt.inspector]:Pc,[Mt.remove]:Sc};var Sa=Object.assign(e=>jsx(Ko,{slotId:"table.mergeCells",...e}),{docxSlot:"table.mergeCells"});function UI({icon:e,className:t,children:o,hidden:n}){let{isEnabled:r,disabledReason:i}=re("table.splitCell"),a=_o(),l=ae();if(n||!a)return null;let s=l(te("table.splitCell")?.labelKey??"table.splitCell");return jsx("button",{type:"button","data-slot":"table.splitCell",className:`docx-toolbar__button${t?` ${t}`:""}`,disabled:!r,...r?{}:{"data-disabled":""},"aria-label":s,"aria-haspopup":"dialog",title:i??s,onMouseDown:$,onClick:c=>a.open("splitCell",c.currentTarget),children:e??o??oe(te("table.splitCell")?.paths)})}var Pa=Object.assign(UI,{docxSlot:"table.splitCell"});function Qm(e,t){let o=A(),n=useRef(t);n.current=t,useEffect(()=>{if(!o)return;let r=((...i)=>{n.current(...i);});return o.on(e,r)},[o,e]);}var XI=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill"],tf=createContext(null);function Zx(){let e=useContext(tf);if(!e)throw new Error("table chrome group must render inside TableChromeProvider");return e.visible}function QI(e,t){let o=t.table,r=(e?.getSelectedTable()??null)?.blockId??"",i=o?`${r}|${o.rows}|${o.columns}|${o.rowIndex}|${o.columnIndex}`:"",a=t.selection,l=a?`${a.from&&"paraId"in a.from?a.from.paraId:""}|${a.to&&"paraId"in a.to?a.to.paraId:""}|${t.selectionCollapsed}`:"",s=e?.getTableCellSelection()??null,c=s?`${s.tableId}|${s.rows.from}-${s.rows.to}|${s.columns.from}-${s.columns.to}|${s.cellIds.join(",")}`:"";return {tableKey:i,selectionKey:l,cellSelectionKey:c,editable:t.editable,editingMode:t.editingMode??"editing"}}function e8(e,t){return e.table===t.table&&e.editable===t.editable&&e.editingMode===t.editingMode&&e.headParagraphId===t.headParagraphId}function t8(e,t){return e.tableKey===t.tableKey&&e.selectionKey===t.selectionKey&&e.cellSelectionKey===t.cellSelectionKey&&e.editable===t.editable&&e.editingMode===t.editingMode}var Bx={tableKey:"",selectionKey:"",cellSelectionKey:"",editable:false,editingMode:"editing"};function o8(e,t){let o={};for(let n of XI){let r=tableChromeToolbarState(e,n,t);o[n]={enabled:r.enabled,disabledReason:r.disabledReason};}return o}function of({children:e}){let t=A(),[o,n]=useState(DEFAULT_TABLE_CHROME_DRAFT),[r,i]=useState(Bx);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:""}),[]),e8,{onSubscribe:()=>{},onUnsubscribe:()=>{}}),l=useCallback(()=>{if(!t){i(Bx);return}let u=QI(t,t.snapshot());i(g=>t8(g,u)?g:u);},[t]);useEffect(()=>{l();},[l,a]),Qm("selectionChange",useCallback(()=>{l();},[l]));let s=r.tableKey!=="",c=useMemo(()=>t?o8(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(tf.Provider,{value:m,children:e})}function n8(){let e=useContext(tf);if(!e)throw new Error("table chrome parts must render inside TableChromeProvider");return e}function wc(e){let t=n8(),o=t.slotState(e);return useMemo(()=>({visible:t.visible,enabled:o.enabled,disabledReason:o.disabledReason,draft:t.draft,apply:n=>t.apply(e,n)}),[t,e,o])}function Rc(e){(editorInstanceScope(e)??e?.ownerDocument?.body)?.querySelector(".docx-pages")?.focus();}function Mc({enabled:e,disabledReason:t,ariaLabel:o}){let{t:n}=H(),r=localizeDisabledReason(t,n),i=useId(),a=!e&&r?i:void 0;return {reasonId:i,shared:{type:"button",onMouseDown:$,"aria-label":o,...a?{"aria-describedby":a}:{},...r?{title:r}:{},...e?{}:{"data-disabled":"","aria-disabled":true}},reasonNode:a&&r?jsx("span",{id:i,className:"docx-editor-sr-only",children:r}):null}}var s8='[role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]';function Ux(e,t,o,n){useEffect(()=>{if(!e)return;let r=o.current,i=n.current;if(!r)return;let a=()=>[...r.querySelectorAll(s8)].filter(c=>c.closest('[role="menu"]')===r);queueMicrotask(()=>{let c=a();(c.find(m=>m.hasAttribute("data-selected")||m.hasAttribute("data-active"))??c[0])?.focus();});let s=c=>{if(c.defaultPrevented||c.isComposing||c.keyCode===229)return;let d=a();if(c.key==="Escape"){c.preventDefault(),t(false),i?.focus();return}if(c.key==="ArrowDown"){c.preventDefault(),no(d,hostDocumentOf(r).activeElement,1);return}if(c.key==="ArrowUp"){c.preventDefault(),no(d,hostDocumentOf(r).activeElement,-1);return}if(c.key==="Home"){c.preventDefault(),ro(d,"first");return}if(c.key==="End"){c.preventDefault(),ro(d,"last");return}if(c.key==="Enter"||c.key===" "){let m=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 $x(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 Xx(e,t,o){if(e)return n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),o(!t));}}function f8(e){return oe(tableChromeIconPaths(e))}function Jx(){return createContext(null)}function Xo(e){let t=useContext(e);if(!t)throw new Error("table chrome compound part used outside its root");return t}function rf(e,t,o){let n=Jx();function r({hidden:l,asChild:s,className:c,children:d}){let{visible:m,enabled:u,disabledReason:g,draft:p,apply:f}=wc(e),[b,y]=useState(false),v=useRef(null),x=useRef(null);ur(b,y,v,l||!m);let h=useMemo(()=>({open:b,setOpen:y,enabled:u,disabledReason:g,apply:f,draft:p,triggerRef:x}),[b,u,g,f,p]);if(l||!m)return null;let k={className:`${t}${c?` ${c}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},E=d??jsxs(Fragment,{children:[jsx(i,{}),jsx(a,{})]});return jsx(n.Provider,{value:h,children:s?jsx(Q,{...k,ref:v,children:E}):jsx("div",{ref:v,...k,children:E})})}function i({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,disabledReason:g,triggerRef:p}=Xo(n),f=ae(),b=te(e),y=f(b?.labelKey??o),{shared:v,reasonNode:x}=Mc({enabled:u,disabledReason:g,ariaLabel:y}),h={...v,ref:p,className:`docx-toolbar__button docx-table-chrome__trigger${s?` ${s}`:""}`,"aria-haspopup":"menu","aria-expanded":d,onClick:u?()=>m(!d):void 0,...l?{tabIndex:u?0:-1,role:"button",onKeyDown:Xx(u,d,m)}:{}},k=c??jsxs(Fragment,{children:[oe(b?.paths),jsx("span",{className:"docx-toolbar__picker-caret","aria-hidden":"true",children:"\u25BE"})]});return l?jsxs(Fragment,{children:[jsx(Q,{...h,children:k}),x]}):jsxs("button",{...h,children:[k,x]})}i.docxToolbarPart=true;function a({asChild:l,className:s,children:c}){let{open:d,setOpen:m,enabled:u,triggerRef:g}=Xo(n),p=ae(),f=useRef(null);if(Ux(d&&u,m,f,g),!d||!u)return null;let b=te(e),y=p(b?.labelKey??o),v={ref:f,role:"menu","aria-label":y,className:`docx-table-chrome__panel${s?` ${s}`:""}`,onMouseDown:$};return l?jsx(Q,{...v,children:c}):jsx("div",{...v,children:c})}return {Root:r,Trigger:i,Content:a,Ctx:n}}var Xi=rf("table.borderTarget","docx-table-chrome docx-table-chrome--target","table.borders.tooltip");function Qx({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xo(Xi.Ctx),l=ae(),s=TABLE_BORDER_TARGET_OPTIONS.find(u=>u.value===e);if(!s)return null;let c=s.value==="none"?false:s.value===a.activeTarget,d={type:"button",role:"menuitemradio","aria-checked":c,"data-value":s.value,className:`docx-table-chrome__target-btn${o?` ${o}`:""}`,...c?{"data-active":""}:{},"aria-label":l(s.labelKey),title:l(s.labelKey),onMouseDown:$,onClick:()=>{i(false),r(s.value);}},m=n??f8(s.icon);return t?jsx(Q,{...d,children:m}):jsx("button",{...d,children:m})}function ev(e){let{children:t}=e;return jsx(Xi.Content,{...e,children:t??jsx("div",{className:"docx-table-chrome__target-grid",children:TABLE_BORDER_TARGET_OPTIONS.map(o=>jsx(Qx,{value:o.value},o.value))})})}function g8(e){let{children:t}=e,o=t??jsxs(Fragment,{children:[jsx(Xi.Trigger,{}),jsx(ev,{})]});return jsx(Xi.Root,{...e,children:o})}var ol=Object.assign(g8,{docxSlot:"table.borderTarget",Trigger:Xi.Trigger,Content:ev,Item:Qx}),Ji=rf("table.borderStyle","docx-table-chrome docx-table-chrome--style","table.borders.styleAriaLabel");function tv({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xo(Ji.Ctx),l=ae(),s=TABLE_BORDER_STYLE_OPTIONS.find(u=>u.value===e);if(!s)return null;let c=s.value===a.spec.style,d={type:"button",role:"menuitemradio","aria-checked":c,...c?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:$,onClick:()=>{i(false),r(s.value);}},m=n??jsxs(Fragment,{children:[jsx("span",{className:`docx-table-line ${s.previewClass}`,"aria-hidden":"true"}),jsx("span",{children:l(s.labelKey)})]});return t?jsx(Q,{...d,children:m}):jsx("button",{...d,children:m})}function ov(e){let{children:t}=e;return jsx(Ji.Content,{...e,children:t??TABLE_BORDER_STYLE_OPTIONS.map(o=>jsx(tv,{value:o.value},o.value))})}function b8(e){let t=e.children??jsxs(Fragment,{children:[jsx(Ji.Trigger,{}),jsx(ov,{})]});return jsx(Ji.Root,{...e,children:t})}var nl=Object.assign(b8,{docxSlot:"table.borderStyle",Trigger:Ji.Trigger,Content:ov,Item:tv}),Qi=rf("table.borderWidth","docx-table-chrome docx-table-chrome--width","table.borderWidth");function nv({value:e,asChild:t,className:o,children:n}){let{apply:r,setOpen:i,draft:a}=Xo(Qi.Ctx),l=ae(),s=Number(e),c=TABLE_BORDER_WIDTH_OPTIONS.find(g=>g.size===s);if(!c)return null;let d=c.size===a.spec.size,m={type:"button",role:"menuitemradio","aria-checked":d,...d?{"data-selected":""}:{},className:`docx-table-chrome__width-row${o?` ${o}`:""}`,onMouseDown:$,onClick:()=>{i(false),r(c.size);}},u=n??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(Q,{...m,children:u}):jsx("button",{...m,children:u})}function rv(e){let{children:t}=e;return jsx(Qi.Content,{...e,children:t??TABLE_BORDER_WIDTH_OPTIONS.map(o=>jsx(nv,{value:String(o.size)},o.size))})}function h8(e){let t=e.children??jsxs(Fragment,{children:[jsx(Qi.Trigger,{}),jsx(rv,{})]});return jsx(Qi.Root,{...e,children:t})}var rl=Object.assign(h8,{docxSlot:"table.borderWidth",Trigger:Qi.Trigger,Content:rv,Item:nv});function av(e,t,o){let n=o?.defaultHex??"FF0000",r=Jx();function i({hidden:d,asChild:m,className:u,children:g}){let{visible:p,enabled:f,disabledReason:b,draft:y,apply:v}=wc(e),[x,h]=useState(false),[k,E]=useState(n),C=useRef(null),T=useRef(null);ur(x,h,C,d||!p);let S=useMemo(()=>({open:x,setOpen:h,enabled:f,disabledReason:b,apply:v,draft:y,triggerRef:T,lastHex:k,setLastHex:E}),[x,f,b,v,y,k]);if(d||!p)return null;let P={className:`docx-toolbar__colorsplit docx-table-chrome${u?` ${u}`:""}`,"data-slot":e,style:{position:"relative",display:"inline-flex",alignItems:"center",verticalAlign:"middle"}},w=g??jsxs(Fragment,{children:[jsx(a,{}),jsx(l,{}),jsx(s,{clearFill:o?.clearFill??false})]});return jsx(r.Provider,{value:S,children:m?jsx(Q,{...P,ref:C,children:w}):jsx("div",{ref:C,...P,children:w})})}function a({asChild:d,className:m,children:u}){let{enabled:g,disabledReason:p,apply:f,draft:b,lastHex:y}=Xo(r),v=ae(),x=te(e),h=v(x?.labelKey??t),{shared:k,reasonNode:E}=Mc({enabled:g,disabledReason:p,ariaLabel:h}),C=e==="table.borderColor"&&b.spec.color.kind==="hex"?b.spec.color.value:y??n,T={...k,className:`docx-toolbar__button docx-toolbar__colorsplit-main${m?` ${m}`:""}`,onClick:g?()=>f({kind:"hex",value:C}):void 0},S=u??jsxs(Fragment,{children:[oe(x?.paths),jsx("span",{className:"docx-toolbar__colorsplit-bar",style:{backgroundColor:`#${C.toLowerCase()}`},"aria-hidden":"true"})]});return d?jsxs(Fragment,{children:[jsx(Q,{...T,children:S}),E]}):jsxs("button",{...T,children:[S,E]})}a.docxToolbarPart=true;function l({asChild:d,className:m,children:u}){let{open:g,setOpen:p,enabled:f,disabledReason:b,triggerRef:y}=Xo(r),v=ae(),x=te(e),h=v(x?.labelKey??t),{shared:k,reasonNode:E}=Mc({enabled:f,disabledReason:b,ariaLabel:h}),C={...k,ref:y,className:`docx-toolbar__colorsplit-caret${m?` ${m}`:""}`,"aria-haspopup":"dialog","aria-expanded":g,onClick:f?()=>p(!g):void 0,...d?{tabIndex:f?0:-1,role:"button",onKeyDown:Xx(f,g,p)}:{}},T=u??"\u25BE";return d?jsxs(Fragment,{children:[jsx(Q,{...C,children:T}),E]}):jsxs("button",{...C,children:[T,E]})}l.docxToolbarPart=true;function s({asChild:d,className:m,children:u,clearFill:g}){let{open:p,setOpen:f,enabled:b,apply:y,draft:v,triggerRef:x,lastHex:h,setLastHex:k}=Xo(r),E=ae(),C=useRef(null);if($x(p&&b,f,C,x),!p||!b)return null;let T=E(t),S=e==="table.borderColor"&&v.spec.color.kind==="hex"?v.spec.color.value:h??n,P={ref:C,role:"dialog","aria-label":T,className:`docx-toolbar__swatch-popup docx-table-chrome__panel${m?` ${m}`:""}`,onMouseDown:$},w=u??jsxs(Fragment,{children:[g?jsxs("button",{type:"button",className:"docx-toolbar__swatch-clear",onMouseDown:$,onClick:()=>{f(false),y(null),Rc(x.current);},children:[jsx("span",{className:"docx-toolbar__swatch-clear-chip docx-toolbar__swatch-clear-chip--none","aria-hidden":"true"}),E("table.clearCellFill")]}):null,jsx(eu,{apply:_=>{f(false),k?.(_),y({kind:"hex",value:_}),Rc(x.current);},current:S})]});return d?jsx(Q,{...P,children:w}):jsx("div",{...P,children:w})}function c({value:d,css:m,labelKey:u,asChild:g,className:p,children:f}){let{apply:b,setOpen:y,setLastHex:v,triggerRef:x}=Xo(r),h=ae(),k=m??`#${d.toLowerCase()}`,E=u?h(u):d,C={type:"button",className:`docx-toolbar__swatch docx-table-chrome__swatch${p?` ${p}`:""}`,style:{backgroundColor:k},"data-value":d,"aria-label":E,title:E,onMouseDown:$,onClick:()=>{y(false),v?.(d),b({kind:"hex",value:d}),Rc(x.current);}};return g?jsx(Q,{...C,children:f}):jsx("button",{...C,children:f})}return {Root:i,Main:a,Trigger:l,Content:s,Item:c,Ctx:r}}var el=av("table.borderColor","table.borderColor",{defaultHex:"000000"});function y8(e){return jsx(el.Content,{...e,clearFill:false})}function x8(e){return jsx(el.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function v8(e){return jsx(el.Root,{...e})}var al=Object.assign(v8,{docxSlot:"table.borderColor",Trigger:el.Trigger,Content:y8,Item:x8,Main:el.Main}),tl=av("table.cellFill","table.cellFillColor",{clearFill:true,defaultHex:"FFFF00"});function C8(e){return jsx(tl.Content,{...e,clearFill:true})}function T8(e){return jsx(tl.Item,{...e,css:`#${e.value.toLowerCase()}`,labelKey:"colorPicker.customColor"})}function E8(e){return jsx(tl.Root,{...e})}var il=Object.assign(E8,{docxSlot:"table.cellFill",Trigger:tl.Trigger,Content:C8,Item:T8,Main:tl.Main});function iv({overrides:e=new Map,separator:t=true}){return Zx()?jsxs(Fragment,{children:[t?jsx(dr,{}):null,[ol,al,nl,rl,il].map(r=>{let i=e.get(r.docxSlot);return i?jsx(Fragment$1,{children:i},r.docxSlot):jsx(r,{},r.docxSlot)}),[Sa,Pa].map(r=>{let i=e.get(r.docxSlot);return i?jsx(Fragment$1,{children:i},r.docxSlot):jsx(r,{},r.docxSlot)})]}):null}function lv(){let e=ae(),{draft:t}=wc("table.borderTarget");return e(tableChromeLabelKeyForTarget(t.activeTarget))}var lf=["table.borderTarget","table.borderColor","table.borderStyle","table.borderWidth","table.cellFill","table.mergeCells","table.splitCell"],fr="contextual-table",sf={"zoom.level":Wm,"styles.style":Jm,"font.family":Vm,"font.size":Bm,"text.color":tu,"text.highlight":ou,"text.link":Fm,"list.lineSpacing":Zm,"review.editingMode":lc,"review.authors":cc,"file.save":Lm,...Nx,"table.borderTarget":ol,"table.borderColor":al,"table.borderStyle":nl,"table.borderWidth":rl,"table.cellFill":il,"table.splitCell":Pa,"image.insert":ci,"image.properties":ga,"image.wrap":Ui,"image.altText":_i},N8=new Set(["image.insert","image.properties","image.wrap","image.altText"]),_c={id:fr,labelKey:"formattingBar.groups.table",entries:lf.map(e=>({slot:e,Part:e==="table.mergeCells"?Sa:sf[e]}))},sv=new Map;function F8(e){let t=sv.get(e);return t||(t=o=>jsx(Ko,{slotId:e,...o}),sv.set(e,t)),t}function L8(e,t){return formattingBarChromeGroups(e,{direction:t}).map(o=>o.id==="alignment"?{id:o.id,labelKey:o.labelKey,entries:[{slot:"alignment",Part:bc}]}:{id:o.id,labelKey:o.labelKey,entries:o.controls.map(n=>{let r=chromeSlotId(o,n);return {slot:r,Part:sf[r]??F8(r)}})})}var H8=e=>e.image,A8=e=>e.isLoading||e.isOpening===true,O8=e=>e.table!==null;function B8(e){return e==="alignment"||e in sf}function Fc(e){let t=Wr(e,Fc);if(t!==null)return t;if(!isValidElement(e))return null;let o=e.type;if(typeof o!="function"&&typeof o!="object")return null;if(typeof o.docxSlot=="string")return o.docxSlot;if(o.docxToolbarSlot===true){let n=e.props.slotId;return typeof n=="string"?n:null}if(o.docxToolbarPart===true){let n=e.props,r=n.slotId??n.slot;if(typeof r=="string")return r}return null}function af(e){if(e==null||typeof e=="boolean")return false;if(Array.isArray(e))return e.some(af);let t=Fc(e);return t!=null&&lf.includes(t)?true:isValidElement(e)?Children.toArray(e.props.children).some(af):false}function W8(e,t){return t?true:Children.toArray(e).some(af)}function Z8(e){let t=$t(),{className:o,t:n,onSave:r,preset:i=true,overflow:a=true,children:l}=e,s=useMemo(()=>({t:n,onSave:r}),[n,r]),c=zl(n),d=W(H8),m=W(A8),u=W(O8),g=lt(),p=g==="rtl",f=useMemo(()=>L8(d,p),[d,p]),b=useMemo(()=>new Set(f.flatMap(S=>S.entries.map(P=>P.slot))),[f]),y=useMemo(()=>i?_y(l,Fc,S=>b.has(S),S=>lf.includes(S)):null,[i,l,b]),v=useMemo(()=>y?K8(f,y):[],[f,y]),x=useMemo(()=>[...v.filter(S=>!S.pinned).map(S=>({id:S.id,items:cv(S,y?.overrides)})),...u?[{id:fr,items:[fr]}]:[]],[v,y,u]),h=useMemo(()=>{let S=new Map;for(let P of v)P.priority!==void 0&&S.set(P.id,P.priority);return collapseOrder(x.map(P=>P.id),TOOLBAR_COLLAPSE_ORDER,S)},[v,x]),k=i&&a,{attach:E,overflow:C}=Fu(k,x,h),T;if(!y)T=l;else {let{overrides:S,tableOverrides:P,appended:w}=y,_=R=>{let U=S.get(R.slot);if(U)return U;let V=R.Part;return jsx(V,{})},L=R=>{let U=P.get(R.slot);if(U)return U;let V=R.Part;return jsx(V,{})},N=[],B=[],F=0;for(let R of v){let U=cv(R,S),V=new Map(R.entries.map(q=>[q.slot,q])),Y=R.pinned?U.length:toolbarShownCount(C,R.id,U.length),j=U.slice(Y);if(j.length>0){let q=j.flatMap(ee=>{let O=V.get(ee);if(!O)return [];let I=dv(O,S,c,R.labelKey,_);return I===null?[]:[jsx(Fragment$1,{children:I},O.slot)]}),X=toolbarHostPanelShown(R.extras.length>0,j)?U8(R):null;X!==null&&q.push(jsx(Fragment$1,{children:X},"host")),q.length>0&&B.push({id:R.id,labelKey:R.labelKey,...R.heading?{label:is(R.heading,c)}:{},children:q});}Y!==0&&(F>0&&N.push(jsx(dr,{},`separator-${R.id}`)),F+=1,N.push(jsx("div",{className:`docx-toolbar__group${R.className?` ${R.className}`:""}`,...R.heading?{role:"group","aria-label":is(R.heading,c)}:{},...R.pinned?{[Ur]:""}:{[qr]:R.id},children:U.slice(0,Y).map(q=>{let X=V.get(q);return jsx("div",{className:"docx-toolbar__item",[_b]:q,children:X?_(X):R.extras},q)})},R.id)));}let D=C.has(fr);if(u&&D){let R=_c.entries.flatMap(U=>{let V=dv(U,P,c,_c.labelKey,L);return V===null?[]:[jsx(Fragment$1,{children:V},U.slot)]});R.length>0&&B.unshift({id:_c.id,labelKey:_c.labelKey,children:R});}T=jsxs(Fragment,{children:[N,u&&!D?jsx(dr,{},"separator-contextual-table"):null,D?null:jsx("div",{className:"docx-toolbar__contextual",[qr]:fr,children:jsx(iv,{overrides:P,separator:false})}),w.length>0?jsx("div",{className:"docx-toolbar__group",[Ur]:"",children:w}):null,B.length>0?jsx(Ry,{sections:B}):null]});}return jsx(Vn.Provider,{value:s,children:jsx(Ty,{children:jsx("fieldset",{ref:E,disabled:m,"aria-label":c("formattingBar.label"),"data-testid":"docx-toolbar",className:`${t}docx-toolbar${o?` ${o}`:""}`,dir:g,...k?{"data-overflow":""}:{},onMouseDown:$,children:W8(l,i)?jsx(of,{children:T}):T})})})}function Lc(e){if(!e)return false;if(e.type===Fragment$1){let t=Children.toArray(e.props.children).find(o=>Fc(o)!==null);return isValidElement(t)?Lc(t):false}return !!e.props.hidden}function cv(e,t){let o=e.entries.filter(n=>!Lc(t?.get(n.slot))).map(n=>n.slot);return toolbarGroupItems(o,e.extras.length>0)}function K8(e,t){let o=new Map(t.groups.map(s=>[s.id,s])),n=new Set(e.map(s=>s.id)),r=new Map;for(let s of e){let c=o.get(s.id);if(c&&q8(c),c?.hidden)continue;let d=Children.toArray(c?.children);!s.entries.some(u=>!Lc(t.overrides.get(u.slot)))&&d.length===0||r.set(s.id,{id:s.id,labelKey:s.labelKey,heading:void 0,entries:s.entries,extras:d,pinned:c?.pinned??TOOLBAR_PINNED_GROUPS.has(s.id),priority:c?.priority,overflowContent:c?.overflowContent,className:c?.className,host:false});}for(let s of t.groups)s.id===fr&&Hy(s.id);let i=t.groups.filter(s=>!n.has(s.id)&&s.id!==fr);for(let s of i){let c=Children.toArray(s.children);s.hidden||c.length===0||r.set(s.id,{id:s.id,labelKey:s.labelKey??s.id,heading:{id:s.id,label:s.label,labelKey:s.labelKey},entries:[],extras:c,pinned:s.pinned===true,priority:s.priority,overflowContent:s.overflowContent,className:s.className,host:true});}let a=[...n,...i.map(s=>s.id)];for(let s of i)s.after!==void 0&&!a.includes(s.after)&&Fy(s.id,s.after,a);for(let s of t.appended){if(!isValidElement(s)||s.type!==ii)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 q8(e){for(let t of ["label","labelKey","after"])e[t]!==void 0&&Ly(e.id,t);}function U8(e){return e.overflowContent?e.overflowContent():e.extras.length===0?null:jsx(ls.Provider,{value:"panel",children:jsx("div",{className:"docx-toolbar__more-host",children:e.extras})})}function dv(e,t,o,n,r){let i=t.get(e.slot);if(Lc(i))return null;let a=i?.type===ii?i.props.overflowContent:void 0;return !i&&N8.has(e.slot)?jsx(ls.Provider,{value:"panel",children:r(e)}):i||B8(e.slot)?jsx(wy,{label:$8(o,e,n),children:a?a():r(e)}):jsx(Dy,{slot:e.slot})}function $8(e,t,o){let n=t.slot==="alignment"?null:te(t.slot);return e(n?.labelKey??o)}var sl=Object.assign(Z8,{Button:Ko,Action:qm,Separator:dr,Group:Lu,Slot:ii,AddComment:Rm,Undo:By,Redo:Wy,Bold:Zy,Italic:Ky,Underline:qy,Strike:Uy,Link:Fm,ClearFormatting:$y,Superscript:zy,Subscript:Vy,Alignment:bc,AlignLeft:Gy,AlignCenter:jy,AlignRight:Yy,AlignJustify:Xy,LeftToRight:Jy,RightToLeft:Qy,LineSpacing:Zm,BulletList:ex,NumberedList:tx,Outdent:ox,Indent:nx,ImageInsert:ci,ImageProperties:ga,ImageWrap:Ui,ImageAltText:_i,TableInsert:Nm,TableBorderTarget:ol,TableBorderColor:al,TableBorderStyle:nl,TableBorderWidth:rl,TableCellFill:il,TableMergeCells:Sa,TableSplitCell:Pa,Comments:rx,FontFamily:Vm,FontSize:Bm,FontColor:tu,Highlight:ou,Zoom:Wm,StylePicker:Jm,EditingMode:lc,Reviewers:cc,Save:Lm,ContentControlShowAll:Tc,ContentControlFormFill:Ec,ContentControlInspector:Pc,ContentControlRemove:Sc});var uv=/^(con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])$/i,Y8=/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff<>:"/\\|?*]/g,X8=200,pv=new TextEncoder;function J8(e,t){if(pv.encode(e).length<=t)return e;let o=0,n="";for(let r of e){let i=pv.encode(r).length;if(o+i>t)break;o+=i,n+=r;}return n}function mv(e){let t=e.length;for(;t>0;){let o=e.charCodeAt(t-1);if(o!==46&&o!==32)break;t-=1;}return e.slice(0,t)}function fv(e){return mv(mv(e).replace(/\.docx$/i,""))}function Hc(e){let t=(e??"").replace(Y8," ").replace(/\s+/g," ").trim(),o=fv(t).replace(/^[. ]+/,""),n=J8(o,X8),r=n===o?o:fv(n);return !r||uv.test(r)?"document.docx":uv.test(r.split(".",1)[0].trim())?`_${r}.docx`:`${r}.docx`}function Ac(e,t,o="application/vnd.openxmlformats-officedocument.wordprocessingml.document",n){let r=URL.createObjectURL(new Blob([e],{type:o})),i=hostDocumentOf(n).createElement("a");i.href=r,i.download=t,i.click(),hostWindowOf(n).setTimeout(()=>URL.revokeObjectURL(r),0);}function gv(e,t,o){let{t:n}=H(),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 b=>{if(!(!e||r.current)){r.current=true,p({}),d(b),u(true),a(true),s("");try{let y=await runChromeExport(e,b,t);Ac(y.bytes.slice().buffer,Hc(o).replace(/\.docx$/,`.${y.extension}`),y.mimeType),u(!1);}catch(y){u(true),s(y instanceof ChromeExportError?n(y.format==="markdown"?"toolbar.exportMarkdownMissing":"toolbar.exportPdfMissing"):n("toolbar.exportFailed",{message:y instanceof Error?y.message:String(y)}));}finally{r.current=false,a(false);}}}}}function yv(e,t,o,n=false){let{t:r}=H(),i=useRef({editor:e,exporters:t,feedback:o,t:r,settingsStep:n});i.current={editor:e,exporters:t,feedback:o,t:r,settingsStep:n};let a=useRef(null),l=useRef(null),[s,c]=useState(false),[d,m]=useState(""),[u,g]=useState(""),[p,f]=useState(false),[b,y]=useState(false),[v,x]=useState({}),[h,k]=useState(false),[E,C]=useState(()=>initialChromePrintSettings(null)),T=useRef(E),S=useRef(void 0),P=useRef(null),w=useCallback(D=>{let{t:R}=i.current;if(D instanceof ChromeExportError)return R("toolbar.printPdfMissing");if(D instanceof ChromePrintError){if(D.code==="pdf-viewer-unavailable")return R("toolbar.printNoViewer");if(D.code==="pdf-load-failed")return R("toolbar.printLoadFailed");if(D.code==="print-refused")return R("toolbar.printRefused")}return R("toolbar.printFailedMessage",{message:D instanceof Error?D.message:String(D)})},[]),_=useCallback(()=>{a.current=null,y(false),f(false),c(false),k(false);},[]),L=useCallback(async(D,R)=>{let{editor:U,exporters:V}=i.current;if(!(!U||a.current!==D||P.current===D)){P.current=D,k(false),c(true);try{let Y=await runChromePrint(U,V,S.current??hostDocumentOf(null),R);if(a.current!==D){Y.dispose();return}l.current=Y,await Y.print({beforePrint:()=>{if(a.current!==D)throw new ChromePrintError("print-ended");flushSync(()=>f(!1));}}),a.current===D&&_();}catch(Y){if(a.current!==D)return;if(!i.current.feedback){console.error("[docx-editor] print failed",Y),_();return}c(false),g(l.current?.url??""),m(w(Y)),f(true);}}},[_,w]),N=useCallback(async D=>{let{editor:R,exporters:U,feedback:V,settingsStep:Y}=i.current;if(!R||a.current)return;let j={};if(a.current=j,S.current=D,l.current?.dispose(),l.current=null,x(j),y(true),f(true),m(""),g(""),!Y||!V||!U?.pdf){await L(j,{});return}let q=initialChromePrintSettings(R.snapshot());T.current=q,C(q),c(false),k(true);},[L]),B=useCallback(D=>{let R={...T.current,...D};T.current=R,C(R);},[]),F=useCallback(()=>{let D=a.current;D&&L(D,T.current);},[L]);return useEffect(()=>()=>{a.current=null,l.current?.dispose(),l.current=null;},[]),{pending:s,error:d,url:u,visible:p,active:b,session:v,choosing:h,settings:E,execute:N,changeSettings:B,confirm:F,close:_}}var cN=()=>{};function cf(){let e=A(),t=useCallback(n=>e?e.on("hostChange",n):cN,[e]),o=useCallback(()=>e?editorHostDocument(e):typeof globalThis.document>"u"?null:globalThis.document,[e]);return useSyncExternalStore(t,o,()=>null)}var dN="https://github.com/eigenpal/docx-editor/issues/new";function uN(){if(typeof globalThis.window>"u")return "";try{let e=new URL(globalThis.window.location.href);return `${e.origin}${e.pathname}`}catch{return ""}}function vv(e={}){let t=e.userAgent??(typeof globalThis.navigator<"u"?globalThis.navigator.userAgent:"unknown"),o=e.viewport??(typeof globalThis.window<"u"?{width:globalThis.window.innerWidth,height:globalThis.window.innerHeight}:{width:0,height:0}),r=["### What happened","","### Steps to reproduce","1. ","2. ","3. ","","### Expected","","### Actual","","### Attach the DOCX","Please drag the `.docx` file that reproduces this onto the issue (below this text box). Bugs are much faster to fix with a real file.","","### Environment",`- URL: ${e.pageUrl??uN()}`,`- Viewport: ${o.width} x ${o.height}`,`- User agent: ${t}`,""].join(`
|
|
2
|
+
`),i=new URLSearchParams({title:"[Bug] ",body:r});return `${dN}?${i.toString()}`}function dl(e){typeof globalThis.window>"u"||globalThis.window.open(vv(e),"_blank","noopener,noreferrer");}function pN({className:e,hidden:t,onSelect:o}){let{setOpenMenu:n,onReportIssue:r,reportIssue:i}=et(),a=Pe();if(t||i===false)return null;let l=o??r??dl;return jsx(De,{slot:"help.reportIssue",onSelect:()=>{l(),n(null);},...e?{className:e}:{},children:a("toolbar.reportIssue")})}var Oc=Object.assign(pN,{docxSlot:"help.reportIssue"});function mN({children:e,...t}){let{reportIssue:o}=et();return e===void 0&&o===false?null:jsxs(lo,{id:"help",...t,children:[jsx(Oc,{}),e]})}var df=Object.assign(mN,{docxMenu:"help"});var hN=e=>e.hiddenReviewAuthors??[];function Bc({className:e,hidden:t}){let o=A(),n=Zi(),r=W(hN),i=Pe(),{t:a}=H();if(t)return null;let l=i("reviewers.label"),s=toolbarCommandState(o,"review.authors"),c=localizeDisabledReason(s.disabledReason,a);if(!s.enabled)return jsx(De,{disabled:true,title:c??void 0,slot:"review.authors",children:l});let d=new Set(r),m=n.every(u=>!d.has(u.author));return jsxs(io,{labelKey:"reviewers.label",className:e,children:[jsx(Tv,{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(Tv,{checked:!d.has(u.author),label:u.author||"\u2014",slot:`reviewer-${u.slot}`,onChoose:()=>o?.setReviewAuthorVisible(u.author,d.has(u.author))},u.author))]})}function Tv(e){return jsx(De,{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 yN({children:e,...t}){return jsxs(lo,{id:"review",...t,children:[jsx(io,{labelKey:"reviewers.markupOptions",className:"docx-menubar__markup-options",children:jsx(Bc,{className:"docx-menubar__reviewers-submenu"})}),e]})}var Wc=Object.assign(yN,{docxMenu:"review"});var SN={file:ju,format:Yu,insert:Xu,review:Wc,help:df};function ul(e,t=false){if(!isValidElement(e))return null;if(e.type===Fragment$1){let i=Children.toArray(e.props.children).map(a=>ul(a,t)).filter(a=>a!==null);return i.length===1?i[0]:null}let o=e.props;if(o.hidden===true&&!t)return null;let n=e.type;return (typeof n=="function"||typeof n=="object")&&typeof n.docxMenu=="string"?n.docxMenu:e.type===lo&&typeof o.id=="string"?o.id:null}var PN=new Set(CHROME_MENUS.map(e=>e.id));function Uc(e){if(!isValidElement(e))return null;if(e.type===Fragment$1){let n=Children.toArray(e.props.children).map(Uc).filter(r=>r!==null);return n.length===1?n[0]:null}let t=e.type;if((typeof t=="function"||typeof t=="object")&&typeof t.docxMenu=="string")return t.docxMenu;if(e.type===lo){let o=e.props.id;if(typeof o=="string"&&PN.has(o))return o}return null}var kN=e=>e.isOpening===true;function wN(e){let t=_o(),o=Rt(),n=$t(),r=lt(),{className:i,t:a,fileName:l,exporters:s,printSettings:c,onOpen:d,onOpenFile:m,onSave:u,onPageSetup:g,onReportIssue:p,reportIssue:f,preset:b=true,overflow:y=true,children:v}=e,x=A(),{t:h}=H(),[k,E]=useState(null),C=W(kN);useEffect(()=>{C&&E(null);},[C]);let[T,S]=useState(null),P=gv(x,s,l??T??void 0),{pending:w,execute:_}=P,L=yv(x,s,o?.print!==false,c??o?.print===void 0),{active:N,execute:B}=L,F=L.visible&&o?.print!==false,[D,R]=useState(null),[U,V]=useState(false),[Y,j]=useState(false),[q,X]=useState(false),ee=useRef(null),O=useRef(null);useEffect(()=>{if(k!==null)return listenForOutsidePress({popup:ee.current,close:()=>E(null)})},[k]),va(k!==null,ee,()=>E(null),ce=>isDomNode(ce.target)&&ee.current?.contains(ce.target)===true);let I=useCallback(ce=>{E(ce),ce!==null&&R(ce);},[]),ie=useCallback(()=>O.current?.click(),[]),ge=useCallback(()=>{x&&x.save().then(ce=>Ac(ce,Hc(l??T??void 0),void 0,ee.current)).catch(ce=>{console.error("[docx-editor] save failed",ce);});},[x,l,T]),K=useCallback(()=>t?t.open("pageSetup",ee.current?.querySelector('[data-menu="file"] > [role="menuitem"]')):V(true),[t]),de=x?d??ie:void 0,ke=x?u??ge:void 0,Ze=!!s?.pdf,at=useMemo(()=>x&&!N?()=>{Nu(ee.current),B(editorInstanceScope(ee.current)??ee.current??void 0);}:void 0,[x,N,B]),Ce=x?t?.ownsPageSetup?K:g??K:void 0,Ye=cf();useEffect(()=>{let ce=Se=>{if(!(Se.metaKey||Se.ctrlKey)||Se.altKey||Se.shiftKey)return;let Et=Se.key.toLowerCase(),ln=isChromePrintShortcut(Se);if(Et!=="s"&&Et!=="o"&&!ln)return;let sn=Se.target,z=editorInstanceScope(ee.current)??ee.current;if(!(!sn||!((z?.contains(sn)??false)||Db(sn,hostDocumentOf(ee.current),x?editorHostElement(x):null))))if(ln){if(!Ze||!x||!at&&!F)return;Se.preventDefault(),at?.();}else Et==="s"&&ke?(Se.preventDefault(),ke()):Et==="o"&&de&&(Se.preventDefault(),de());},be=hostDocumentOf(ee.current),Ne=Ye&&Ye!==be?[be,Ye]:[be];for(let Se of Ne)Se.addEventListener("keydown",ce);return ()=>{for(let Se of Ne)Se.removeEventListener("keydown",ce);}},[de,ke,at,F,Ze,x,Ye]);let Wn=useMemo(()=>({t:a,openMenu:k,setOpenMenu:I,activeMenu:D,onOpen:de,onSave:ke,onExport:x&&!w?ce=>(Nu(ee.current),_(ce)):void 0,onPrint:at,printShortcut:Ze,onPageSetup:Ce,onParagraphDialog:()=>t?t.open("paragraph",ee.current?.querySelector('[data-menu="format"] > [role="menuitem"]')):j(true),onWatermarkDialog:x?()=>t?t.open("watermark",ee.current?.querySelector('[data-menu="insert"] > [role="menuitem"]')):X(true):void 0,onReportIssue:p,reportIssue:f,opening:C}),[C,x,w,_,at,Ze,a,k,I,D,de,ke,Ce,t,p,f]),wt=Children.toArray(v),qt=[];if(b){let ce=new Map(wt.map(be=>[Uc(be),be]));for(let be of CHROME_MENUS){let Ne=ce.get(be.id);(Ne===void 0||ul(Ne)!==null)&&qt.push(be.id);}for(let be of wt){if(Uc(be)!==null)continue;let Ne=ul(be);Ne!==null&&qt.push(Ne);}}else for(let ce of wt){let be=ul(ce);be!==null&&qt.push(be);}let Zn=[...qt].reverse(),{attach:se,overflow:Ge}=Ib(y,qt,Zn),Ie=useMemo(()=>({measuring:y,overflow:Ge,inMore:false}),[y,Ge]),Kn=useMemo(()=>({measuring:false,overflow:Ge,inMore:true}),[Ge]),xo=ce=>ul(ce,true)!==null,Qt=(ce,be)=>jsx("div",{role:"none",className:"docx-menubar__host",[Ur]:"",children:ce},be),vo,an;if(!b)vo=wt.filter(xo),an=y?wt.map((ce,be)=>xo(ce)?ce:Qt([ce],`host-${be}`)):v;else {let ce=new Map,be=[];for(let Se of wt){let Et=Uc(Se);Et?ce.set(Et,Se):be.push(Se);}vo=[...CHROME_MENUS.map(Se=>{let Et=ce.get(Se.id);if(Et)return jsx(Fragment$1,{children:Et},Se.id);let ln=SN[Se.id];return jsx(ln,{},Se.id)}),...be.filter(xo)];let Ne=be.filter(Se=>!xo(Se));an=jsxs(Fragment,{children:[vo,Ne.length>0?Qt(Ne,"host"):null]});}let Ht=a?.("formattingBar.more")??h("formattingBar.more");return jsxs(ni.Provider,{value:Wn,children:[jsx("div",{ref:ce=>{if(ee.current=ce,se(ce),ce&&D===null){let be=Iu(ce)[0]?.closest("[data-menu]")?.getAttribute("data-menu");be&&R(be);}},role:"menubar","aria-label":a?.("titleBar.menuBarAriaLabel")??h("titleBar.menuBarAriaLabel"),"data-testid":"docx-menubar",...y?{"data-overflow":""}:{},className:`${n}docx-menubar${i?` ${i}`:""}`,dir:r,onMouseDown:$,onKeyDown:ce=>{if(ce.key!=="ArrowLeft"&&ce.key!=="ArrowRight")return;let be=ee.current;if(!be)return;let Ne=Iu(be),Se=Ne.indexOf(hostDocumentOf(be).activeElement);if(Se===-1)return;ce.preventDefault();let Et=hostWindowOf(be).getComputedStyle(be).direction==="rtl",ln=(ce.key==="ArrowRight"?1:-1)*(Et?-1:1),sn=Ne[(Se+ln+Ne.length)%Ne.length],z=sn?.closest("[data-menu]")?.getAttribute("data-menu");z&&(R(z),sn?.focus(),k!==null&&E(z));},children:jsxs(os.Provider,{value:Ie,children:[jsx(Kr.Provider,{value:0,children:an}),Ge.size>0?jsx(lo,{id:Zr,label:Ht,icon:oe(wm),preset:false,children:jsx(os.Provider,{value:Kn,children:vo})}):null]})}),jsxs(Gh,{children:[P.visible&&o?.export!==false?o?.export?Te(o.export,{open:true,format:P.format,pending:P.pending,error:P.error,onClose:P.dismiss},P.session):jsx(Ua,{open:true,format:P.format,pending:P.pending,error:P.error,onClose:P.dismiss}):null,L.visible&&o?.print!==false?o?.print?Te(o.print,{open:true,pending:L.pending,error:L.error,url:L.url,onClose:L.close,choosing:L.choosing,settings:L.settings,onSettingsChange:L.changeSettings,onPrint:L.confirm},L.session):jsx($a,{open:true,pending:L.pending,error:L.error,url:L.url,onClose:L.close,choosing:L.choosing,settings:L.settings,onSettingsChange:L.changeSettings,onPrint:L.confirm}):null]}),jsx("input",{ref:O,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:ce=>{let be=ce.target.files?.[0];ce.target.value="",!(!be||!x)&&(S(be.name),m?.(be),be.arrayBuffer().then(Ne=>x.load(new Uint8Array(Ne))).catch(Ne=>{console.error("[docx-editor] could not open the file",Ne);}));}}),jsx(tr,{open:U,onClose:()=>V(false)}),jsx(Vo,{open:Y,onClose:()=>j(false)}),jsx(or,{open:q,onClose:()=>X(false)})]})}var pl=Object.assign(wN,{Menu:lo,File:ju,Format:Yu,Insert:Xu,Review:Wc,Help:df,Item:ao,Row:De,Group:di,Separator:Qn,Submenu:io,TableGrid:Vr,Entry:pi,Open:Zu,Save:Ku,ExportMarkdown:qu,ExportPdf:Uu,Print:$u,PageSetup:zu,ImageInsert:Vu,Watermark:ms,Bookmark:fs,Reviewers:Bc,ReportIssue:Oc});var FN=12240,Rv=1440,LN=1440,HN=567,gr=20,hf=6,xf=gr+hf+2,AN="var(--doc-text-muted)",ON="var(--doc-text-subtle)",Mv="var(--doc-shadow-subtle)",BN="var(--doc-primary)",WN="var(--doc-primary-hover)",ZN="var(--doc-text-subtle)",fl=5,ml=7,KN={left:0,right:0,firstLine:0};function _v(e,t){return t==="inch"?(e/LN).toFixed(2)+'"':(e/HN).toFixed(1)+" cm"}function qN(e,t){return t?1:Math.round(e==="cm"?SNAP_TWIPS_CM:SNAP_TWIPS_INCH)}function br({pageSetup:e,zoom:t=1,editable:o=false,onLeftMarginChange:n,onRightMarginChange:r,onMarginDragEnd:i,showIndentHandles:a=false,indent:l,indentEditable:s=false,onIndentChange:c,onIndentDragEnd:d,unit:m="inch",className:u="",style:g,tabMarks:p,onTabMarkRemove:f}){let{t:b}=H(),[y,v]=useState(null),[x,h]=useState(null),[k,E]=useState(null),[C,T]=useState(null),S=useRef(null),P=e?.pageWidthTwips??FN,w=e?.marginsTwips.left??Rv,_=e?.marginsTwips.right??Rv,L=e?.gutterTwips??0,N={pageWidth:P,leftMargin:w,rightMargin:_},B=l??KN,F=$e(P)*t,D=$e(w)*t,R=$e(_)*t,U=useCallback(I=>{let ie=S.current?.getBoundingClientRect();return ie?ec((I-ie.left)/t):null},[t]),V=useCallback((I,ie,ge)=>{let K=U(ie);if(K===null)return;if(T($e(K)*t),I==="leftMargin"||I==="rightMargin"){if(I==="leftMargin"){let ke=P-_-L-720,Ze=Math.round(Math.max(0,Math.min(K,ke)));E(Ze),n?.(Ze);}else {let ke=P-K,Ze=P-w-L-720,at=Math.round(Math.max(0,Math.min(ke,Ze)));E(at),r?.(at);}return}let de=dragIndent(I,K,B,N,{unit:m,precise:ge});E(I==="right"?de.right:I==="firstLine"?de.firstLine:de.left),c?.(de);},[U,t,P,w,_,L,n,r,c,B,N,m]),Y=useCallback(I=>{I==="leftMargin"||I==="rightMargin"?i?.():d?.(),v(null),E(null),T(null);},[i,d]),j=useCallback((I,ie,ge)=>{let K=handlePosition(I,B,N),de=dragIndent(I,K+ie*qN(m,ge),B,N,{unit:m,precise:true});c?.(de),d?.();},[B,N,m,c,d]),q=rulerMarginTicks(N,B,m).map(I=>({...I,position:$e(I.position)*t})),X=a&&s&&c!==void 0,ee=I=>$e(handlePosition(I,B,N))*t,O=(I,ie,ge)=>({positionPx:ee(I),editable:X,isDragging:y===I,isHovered:x===I,onPointerEnter:()=>h(I),onPointerLeave:()=>h(null),onPointerDown:K=>{X&&(K.preventDefault(),K.stopPropagation(),K.currentTarget.setPointerCapture(K.pointerId),v(I));},onPointerMove:K=>{y===I&&V(I,K.clientX,K.altKey);},onPointerUp:K=>{y===I&&(K.currentTarget.releasePointerCapture(K.pointerId),Y(I));},onKeyDown:K=>{X&&(K.key!=="ArrowLeft"&&K.key!=="ArrowRight"||(K.preventDefault(),j(I,K.key==="ArrowLeft"?-1:1,K.shiftKey)));},label:b(ie),valueNow:ge,valueText:_v(ge,m),pageWidthTwips:P});return jsxs("div",{ref:S,className:`docx-horizontal-ruler ${u}`,style:{position:"relative",width:_t(F),height:xf,backgroundColor:"transparent",overflow:"visible",userSelect:"none",touchAction:"none",cursor:y?"ew-resize":"default",flexShrink:0,marginInline:"auto",...g},role:"group","aria-label":b("ruler.horizontal"),children:[jsx("div",{style:{position:"absolute",top:0,left:0,width:_t(D),height:gr,backgroundColor:Mv,borderRight:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&n?I=>{I.preventDefault(),I.currentTarget.setPointerCapture(I.pointerId),v("leftMargin");}:void 0,onPointerMove:I=>y==="leftMargin"&&V("leftMargin",I.clientX,I.altKey),onPointerUp:I=>{y==="leftMargin"&&(I.currentTarget.releasePointerCapture(I.pointerId),Y("leftMargin"));}}),jsx("div",{style:{position:"absolute",top:0,right:0,width:_t(R),height:gr,backgroundColor:Mv,borderLeft:"1px solid var(--doc-shadow-subtle)",cursor:o?"ew-resize":"default",zIndex:1},onPointerDown:o&&r?I=>{I.preventDefault(),I.currentTarget.setPointerCapture(I.pointerId),v("rightMargin");}:void 0,onPointerMove:I=>y==="rightMargin"&&V("rightMargin",I.clientX,I.altKey),onPointerUp:I=>{y==="rightMargin"&&(I.currentTarget.releasePointerCapture(I.pointerId),Y("rightMargin"));}}),jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:gr,pointerEvents:"none"},children:q.map((I,ie)=>jsx(UN,{tick:I},ie))}),p?.map(I=>jsx(GN,{tabMark:I,positionPx:$e(rulerTabPosition(I.position,N,B))*t,onDoubleClick:()=>f?.(I.position)},I.position)),a&&jsxs(Fragment,{children:[jsx(bf,{direction:"down",anchor:"top",...O("firstLine","ruler.firstLineIndent",B.firstLine)}),jsx(bf,{direction:"up",anchor:"strip",...O("hanging","ruler.hangingIndent",B.left)}),jsx($N,{...O("left","ruler.leftIndent",B.left)}),jsx(bf,{direction:"up",anchor:"strip",...O("right","ruler.rightIndent",B.right)})]}),y&&k!==null&&C!==null&&jsx(zN,{value:_v(k,m),positionPx:C})]})}function UN({tick:e}){return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:_t(e.position),bottom:0,width:1,height:e.height,backgroundColor:ON}}),e.label&&jsx("div",{style:{position:"absolute",left:_t(e.position),top:2,transform:"translateX(-50%)",fontSize:"9px",color:AN,fontFamily:"sans-serif",whiteSpace:"nowrap"},children:e.label})]})}function Iv(e){return e.editable?e.isDragging||e.isHovered?WN:BN:ZN}function Nv(e,t,o){return {position:"absolute",left:_t(e.positionPx-t/2),width:t,cursor:e.editable?"ew-resize":"default",zIndex:e.isDragging?10:4,touchAction:"none",...o}}function Fv(e){return {role:"slider","aria-label":e.label,"aria-orientation":"horizontal","aria-valuenow":e.valueNow,"aria-valuemin":-e.pageWidthTwips,"aria-valuemax":e.pageWidthTwips,"aria-valuetext":e.valueText,"aria-disabled":e.editable?void 0:true,tabIndex:e.editable?0:-1}}function bf({direction:e,anchor:t,...o}){let n=Iv(o),r=t==="top"?{top:0,height:ml+1}:{top:gr-ml,height:ml};return jsx("div",{className:"docx-ruler-indent",style:Nv(o,fl*2,r),onPointerEnter:o.onPointerEnter,onPointerLeave:o.onPointerLeave,onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onKeyDown:o.onKeyDown,...Fv(o),children:jsx("div",{style:{position:"absolute",left:0,width:0,height:0,borderLeft:`${fl}px solid transparent`,borderRight:`${fl}px solid transparent`,...e==="down"?{top:0,borderTop:`${ml}px solid ${n}`}:{bottom:0,borderBottom:`${ml}px solid ${n}`},transition:"border-color 0.1s"}})})}function $N(e){return jsx("div",{className:"docx-ruler-indent docx-ruler-indent--box",style:Nv(e,fl*2,{top:gr+1,height:hf}),onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,onPointerDown:e.onPointerDown,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onKeyDown:e.onKeyDown,...Fv(e),children:jsx("div",{style:{position:"absolute",left:1,top:0,width:fl*2-2,height:hf,backgroundColor:Iv(e),borderRadius:1,transition:"background-color 0.1s"}})})}function zN({value:e,positionPx:t}){return jsx("div",{style:{position:"absolute",left:_t(t),top:-22,transform:"translateX(-50%)",backgroundColor:"var(--doc-text)",color:"var(--doc-on-primary)",fontSize:"10px",fontFamily:"sans-serif",padding:"2px 6px",borderRadius:3,whiteSpace:"nowrap",pointerEvents:"none",zIndex:20},children:e})}var VN={left:"L",center:"C",right:"R",decimal:"D",bar:"|"};function GN({tabMark:e,positionPx:t,onDoubleClick:o}){return jsx("div",{style:{position:"absolute",left:_t(t-5),top:gr-12,width:10,height:12,display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,color:"var(--doc-text-muted)",cursor:"pointer",userSelect:"none"},onDoubleClick:n=>{n.stopPropagation(),o();},title:`${e.alignment} tab at ${(e.position/1440).toFixed(2)}"`,children:VN[e.alignment]||"L"})}var JN=15840,Av=1440,Vc=1440,Gc=567,Ma=20,QN="var(--doc-text-muted)",e5="var(--doc-text-subtle)",t5="var(--doc-primary)",o5="var(--doc-primary)",n5="var(--doc-primary-hover)";function gl({pageSetup:e,zoom:t=1,editable:o=false,onTopMarginChange:n,onBottomMarginChange:r,onMarginDragEnd:i,unit:a="inch",className:l="",style:s}){let{t:c}=H(),d=lt(),[m,u]=useState(null),[g,p]=useState(null),f=useRef(null),b=e?.pageHeightTwips??JN,y=e?.marginsTwips.top??Av,v=e?.marginsTwips.bottom??Av,x=(_,L)=>{if(!o||_.altKey||_.ctrlKey||_.metaKey||!["ArrowUp","ArrowDown","Home","End"].includes(_.key))return;_.preventDefault();let N=L==="topMargin"?y:v,F=Math.max(0,b-(L==="topMargin"?v:y)-720),D=_.shiftKey?1:Math.round(a==="cm"?Gc/10:Vc/8),R=_.key==="Home"?0:_.key==="End"?F:Math.max(0,Math.min(F,N+(_.key==="ArrowUp"?D:-D)));R!==N&&((L==="topMargin"?n:r)?.(R),i?.());},h=$e(b)*t,k=$e(y)*t,E=$e(v)*t,C=useCallback((_,L)=>{o&&(_.preventDefault(),u(L));},[o]),T=useCallback(_=>{if(!m||!f.current)return;let L=f.current.getBoundingClientRect(),N=_.clientY-L.top,B=ec(N/t);if(m==="topMargin"){let F=b-v-720,D=Math.max(0,Math.min(B,F));n?.(Math.round(D));}else if(m==="bottomMargin"){let F=b-B,D=b-y-720,R=Math.max(0,Math.min(F,D));r?.(Math.round(R));}},[m,t,b,y,v,n,r]),S=useCallback(()=>{m!==null&&i?.(),u(null);},[m,i]);useEffect(()=>{if(m){let _=hostDocumentOf(f.current);return _.addEventListener("mousemove",T),_.addEventListener("mouseup",S),()=>{_.removeEventListener("mousemove",T),_.removeEventListener("mouseup",S);}}},[m,T,S]);let P=a5(b,t,a),w={position:"relative",width:Ma,height:_t(h),backgroundColor:"transparent",overflow:"visible",userSelect:"none",cursor:m?"ns-resize":"default",...s};return 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:P.map((_,L)=>jsx(r5,{tick:_},L))}),jsx(Ov,{type:"topMargin",value:y,maximum:Math.max(0,b-v-720),valueText:y/(a==="cm"?Gc:Vc),unit:a,onKeyDown:_=>x(_,"topMargin"),position:k,editable:o,isDragging:m==="topMargin",isHovered:g==="topMargin",onMouseEnter:()=>p("topMargin"),onMouseLeave:()=>p(null),onMouseDown:_=>C(_,"topMargin")}),jsx(Ov,{type:"bottomMargin",value:v,maximum:Math.max(0,b-y-720),valueText:v/(a==="cm"?Gc:Vc),unit:a,onKeyDown:_=>x(_,"bottomMargin"),position:h-E,editable:o,isDragging:m==="bottomMargin",isHovered:g==="bottomMargin",onMouseEnter:()=>p("bottomMargin"),onMouseLeave:()=>p(null),onMouseDown:_=>C(_,"bottomMargin")})]})}function r5({tick:e}){let t={position:"absolute",top:_t(e.position),insetInlineEnd:0,height:1,width:e.width,backgroundColor:e5},o={position:"absolute",top:_t(e.position),insetInlineStart:2,transform:"translateY(-50%)",fontSize:"9px",color:QN,fontFamily:"sans-serif",whiteSpace:"nowrap"};return jsxs(Fragment,{children:[jsx("div",{style:t}),e.label&&jsx("div",{style:o,children:e.label})]})}function Ov({type:e,position:t,value:o,maximum:n,valueText:r,unit:i,onKeyDown:a,editable:l,isDragging:s,isHovered:c,onMouseEnter:d,onMouseLeave:m,onMouseDown:u}){let{t:g}=H(),p=s?n5:c?o5:t5,f={position:"absolute",top:_t(t-5),insetInlineEnd:0,width:Ma,height:10,cursor:l?"ns-resize":"default",zIndex:s?10:1},b={position:"absolute",top:0,insetInlineEnd:2,width:0,height:0,borderTop:"5px solid transparent",borderBottom:"5px solid transparent",borderInlineEnd:`8px solid ${p}`,transition:"border-inline-end-color 0.1s"};return 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:b})})}function a5(e,t,o){let n=[];if(o==="inch"){let r=Vc/8,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=$e(l)*t;if(a%8===0){let c=a/8;n.push({position:s,width:10,label:c>0?String(c):void 0});}else a%4===0?n.push({position:s,width:6}):a%2===0?n.push({position:s,width:4}):n.push({position:s,width:2});}}else {let r=Gc/10,i=Math.ceil(e/r);for(let a=0;a<=i;a++){let l=a*r;if(l>e)break;let s=$e(l)*t;if(a%10===0){let c=a/10;n.push({position:s,width:10,label:c>0?String(c):void 0});}else a%5===0?n.push({position:s,width:6}):n.push({position:s,width:3});}}return n}var c5=e=>e.formatting?.indent??null,d5=e=>e.editable,u5={type:"setIndent",left:0};function Cf(){let e=A(),t=W(c5),o=W(d5),{isEnabled:n}=re(u5),r=o&&n,i=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:r,apply:i}),[t,r,i])}var Kv=e=>e.zoom,m5=e=>e.isOpening===true;function qv(e,t){return !e||Object.keys(t).length===0?e:{...e,marginsTwips:{...e.marginsTwips,...t}}}function Uv(){let{apply:e}=er(),[t,o]=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 Zv(e){let t=e?.snapshot().selection??null;return t?JSON.stringify(t):""}function f5(){let e=A(),{indent:t,isEnabled:o,apply:n}=Cf(),[r,i]=useState(null),a=useRef(null),l=useRef(null),s=useCallback(m=>{l.current===null&&(l.current=Zv(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!==Zv(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 g5(){let e=we(),[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 Yc(e){let t=W(so),o=W(m5),{pageSetup:n,isEnabled:r}=er(),i=W(Kv),{pending:a,preview:l,commit:s}=Uv(),c=f5(),d=zn(),m=nc(),u=m==="left",g=sy(En(),m),p=g5();return t?null: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(br,{pageSetup:qv(n,a),zoom:i,editable:r,onLeftMarginChange:l("left"),onRightMarginChange:l("right"),onMarginDragEnd:s,showIndentHandles:c.indent!==null,indent:c.indent,indentEditable:c.isEnabled,onIndentChange:c.preview,onIndentDragEnd:c.commit,unit:e.unit??"inch",className:e.className??"",style:{...e.style,transform:`${e.style?.transform?`${e.style.transform} `:""}translateX(${-p}px)`,clipPath:d>0&&p!==0?p>0?`inset(0 0 0 ${p}px)`:`inset(0 ${-p}px 0 0)`:e.style?.clipPath}})})}function Xc(e){let t=W(so),{pageSetup:o,isEnabled:n}=er(),r=W(Kv),{pending:i,preview:a,commit:l}=Uv(),s=zn(),c=En(),d=dy();return t||d!==null&&d>0&&o&&$e(o.pageWidthTwips)*r>d-s-c.inlineStart-c.inlineEnd?null:jsx(gl,{pageSetup:qv(o,i),zoom:r,editable:n,onTopMarginChange:a("top"),onBottomMarginChange:a("bottom"),onMarginDragEnd:l,unit:e.unit??"inch",className:e.className??"",style:e.style})}function Z({size:e=20,className:t="",style:o,children:n}){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 -960 960 960",fill:"currentColor",className:t,style:{display:"inline-flex",flexShrink:0,...o},"aria-hidden":"true",children:n})}function $v(e){return jsx(Z,{...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 zv(e){return jsx(Z,{...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 Vv(e){return jsx(Z,{...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(Z,{...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 jv(e){return jsx(Z,{...e,children:jsx("path",{d:"M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"})})}function Yv(e){return jsx(Z,{...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 Xv(e){return jsx(Z,{...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 Jv(e){return jsx(Z,{...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 Qv(e){return jsx(Z,{...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 eC(e){return jsx(Z,{...e,children:jsx("path",{d:"M500-520h80v-80h80v-80h-80v-80h-80v80h-80v80h80v80Zm-80 160h240v-80H420v80ZM320-200q-33 0-56.5-23.5T240-280v-560q0-33 23.5-56.5T320-920h280l240 240v400q0 33-23.5 56.5T760-200H320Zm0-80h440v-360L560-840H320v560ZM160-40q-33 0-56.5-23.5T80-120v-560h80v560h440v80H160Zm160-240v-560 560Z"})})}function tC(e){return jsx(Z,{...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 oC(e){return jsx(Z,{...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 nC(e){return jsx(Z,{...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 y5(e){return jsx(Z,{...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 x5(e){return jsx(Z,{...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 v5(e){return jsx(Z,{...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 C5(e){return jsx(Z,{...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 T5(e){return jsx(Z,{...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 E5(e){return jsx(Z,{...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 S5(e){return jsx(Z,{...e,children:jsx("path",{d:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z"})})}function P5(e){return jsx(Z,{...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 k5(e){return jsx(Z,{...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 w5(e){return jsx(Z,{...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 D5(e){return jsx(Z,{...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 R5(e){return jsx(Z,{...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 M5(e){return jsx(Z,{...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 _5(e){return jsx(Z,{...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 I5(e){return jsx(Z,{...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 N5(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"})})}function F5(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"})})}function L5(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"})})}function H5(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z"})})}function Pf(e){return jsx(Z,{...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 A5(e){return jsx(Z,{...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 O5(e){return jsx(Z,{...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 B5(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z"})})}function W5(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z"})})}function Z5(e){return jsx(Z,{...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 K5(e){return jsx(Z,{...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 q5(e){return jsx(Z,{...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 U5(e){return jsx(Z,{...e,children:jsx("path",{d:"M480-360 280-560h400L480-360Z"})})}function $5(e){return jsx(Z,{...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 z5(e){return jsx(Z,{...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 V5(e){return jsx(Z,{...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 G5(e){return jsx(Z,{...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 j5(e){return jsx(Z,{...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 rC(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-120v-720h720v720H120Zm640-80v-240H520v240h240Zm0-560H520v240h240v-240Zm-560 0v240h240v-240H200Zm0 560h240v-240H200v240Z"})})}function Y5(e){return jsx(Z,{...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 X5(e){return jsx(Z,{...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 J5(e){return jsx(Z,{...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 Q5(e){return jsx(Z,{...e,children:jsx("path",{d:"M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"})})}function e6(e){return jsx(Z,{...e,children:jsx("path",{d:"M200-440v-80h560v80H200Z"})})}function t6(e){return jsx(Z,{...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 o6(e){return jsx(Z,{...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 n6(e){return jsx(Z,{...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 r6(e){return jsx(Z,{...e,children:jsx("path",{d:"M440-160v-304L240-664v104h-80v-240h240v80H296l224 224v336h-80Zm154-376-58-58 128-126H560v-80h240v240h-80v-104L594-536Z"})})}function a6(e){return jsx(Z,{...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 i6(e){return jsx(Z,{...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 l6(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-280v-400h400v400H120Zm80-80h240v-240H200v240Zm-80-400v-80h720v80H120Zm480 160v-80h240v80H600Zm0 160v-80h240v80H600Zm0 160v-80h240v80H600ZM120-120v-80h720v80H120Z"})})}function s6(e){return jsx(Z,{...e,children:jsx("path",{d:"M440-280v-400h400v400H440Zm80-80h240v-240H520v240ZM120-120v-80h720v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h240v80H120Zm0-160v-80h720v80H120Z"})})}function c6(e){return jsx(Z,{...e,children:jsx("path",{d:"M160-440v-80h640v80H160Z"})})}function d6(e){return jsx(Z,{...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 u6(e){return jsx(Z,{...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 p6(e){return jsx(Z,{...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 m6(e){return jsx(Z,{...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 f6(e){return jsx(Z,{...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 g6(e){return jsx(Z,{...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 b6(e){return jsx(Z,{...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 h6(e){return jsx(Z,{...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 y6(e){return jsx(Z,{...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 x6(e){return jsx(Z,{...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 v6(e){return jsx(Z,{...e,children:jsx("path",{d:"M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z"})})}function C6(e){return jsx(Z,{...e,children:jsx("path",{d:"m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z"})})}function T6(e){return jsx(Z,{...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 E6(e){return jsx(Z,{...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 S6(e){return jsx(Z,{...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 P6(e){return jsx(Z,{...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 k6(e){return jsx(Z,{...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 w6(e){return jsx(Z,{...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 D6(e){return jsx(Z,{...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 R6(e){return jsx(Z,{...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 M6(e){return jsx(Z,{...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 _6(e){return jsx(Z,{...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 I6(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-120v-720h80v720h-80Zm640 0v-720h80v720h-80ZM280-440v-80h80v80h-80Zm160 0v-80h80v80h-80Zm160 0v-80h80v80h-80Z"})})}function N6(e){return jsx(Z,{...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 F6(e){return jsx(Z,{...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 L6(e){return jsx(Z,{...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 H6(e){return jsx(Z,{...e,children:jsx("path",{d:"M160-760v-80h640v80H160Zm280 640v-408L336-424l-56-56 200-200 200 200-56 56-104-104v408h-80Z"})})}function A6(e){return jsx(Z,{...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 O6(e){return jsx(Z,{...e,children:jsx("path",{d:"M160-120v-80h640v80H160Zm320-160L280-480l56-56 104 104v-408h80v408l104-104 56 56-200 200Z"})})}function B6(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-160v-40h720v40H120Zm0-120v-80h720v80H120Zm0-160v-120h720v120H120Zm0-200v-160h720v160H120Z"})})}function W6(e){return jsx(Z,{...e,children:jsx("path",{d:"M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"})})}function Z6(e){return jsx(Z,{...e,children:jsx("path",{d:"M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"})})}function K6(e){return jsx(Z,{...e,children:jsx("path",{d:"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z"})})}function q6(e){return jsx(Z,{...e,children:jsx("path",{d:"M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"})})}function U6(e){return jsx(Z,{...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 $6(e){return jsx(Z,{...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 z6(e){return jsx(Z,{...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 V6(e){return jsx(Z,{...e,children:jsx("path",{d:"M313-440l224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"})})}function G6(e){return jsx(Z,{...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 j6(e){return jsx(Z,{...e,children:jsx("path",{d:"M120-240v-80h240v80H120Zm0-200v-80h480v80H120Zm0-200v-80h720v80H120Z"})})}function Y6(e){return jsx(Z,{...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 X6(e){return jsx(Z,{...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 J6(e){return jsx(Z,{...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 Q6(e){return jsx(Z,{...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 eF(e){return jsx(Z,{...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 tF={undo:y5,redo:x5,print:v5,file_download:C5,file_upload:T5,format_bold:E5,format_italic:S5,format_underlined:P5,strikethrough_s:k5,superscript:w5,subscript:D5,link:R5,format_clear:I5,format_paragraph:M5,format_shapes:_5,lock:nC,format_align_left:N5,format_align_center:F5,format_align_right:L5,format_align_justify:H5,format_line_spacing:Pf,format_list_bulleted:A5,format_list_numbered:O5,format_indent_increase:B5,format_indent_decrease:W5,format_color_text:Z5,ink_highlighter:K5,format_color_reset:q5,arrow_drop_down:U5,table:$5,table_chart:z5,grid_on:V5,table_rows:G5,view_column:j5,border_all:rC,select_all:rC,border_outer:Y5,border_inner:X5,border_clear:J5,add:Q5,remove:e6,delete:t6,delete_sweep:o6,call_merge:n6,call_split:r6,drag_indicator:a6,image:i6,format_image_left:l6,format_image_right:s6,horizontal_rule:c6,flip_to_back:d6,flip_to_front:u6,open_with:p6,tune:m6,rotate_right:f6,rotate_left:g6,swap_horiz:b6,swap_vert:h6,shapes:y6,format_paint:x6,expand_more:v6,expand_less:C6,border_top:T6,border_bottom:E6,border_left:S6,border_right:P6,border_horizontal:k6,border_vertical:w6,padding:D6,text_rotation_none:R6,wrap_text:M6,height:_6,fit_width:I6,settings:N6,border_color:F6,format_color_fill:L6,vertical_align_top:H6,vertical_align_center:A6,vertical_align_bottom:O6,line_weight:B6,keyboard_arrow_up:W6,keyboard_arrow_down:Z6,keyboard_arrow_left:K6,keyboard_arrow_right:q6,more_vert:U6,page_break:$6,branding_watermark:z6,arrow_back:V6,search:G6,toc:j6,bookmark:Y6,bookmarks:X6,done_all:$v,check_circle:zv,chat_bubble_outline:Vv,chat_bubble_check:Gv,check:jv,close:Yv,add_comment:Xv,comment:Jv,edit_note:Qv,difference:eC,rate_review:tC,visibility:oC,format_textdirection_l_to_r:J6,format_textdirection_r_to_l:Q6,"agent-sparkle":eF};function G({name:e,size:t=20,className:o="",style:n}){let r=tF[e];return r?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 bl=12,kf=240,iC=16,lF=24,sF=bl+kf+iC,_a=12,cF=36,dF=_a+cF+iC,hl=Zt__default.memo(function({headings:t,onHeadingClick:o,onClose:n,topOffset:r=0,scrollLeft:i=0,leftOffset:a=bl}){let{t:l}=H(),[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:kf,paddingTop:lF,display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"'Google Sans', Roboto, Arial, sans-serif",zIndex:40,transform:s?"translateX(0)":`translateX(-${a+kf}px)`,transition:"transform 0.15s ease-out"},onMouseDown:u=>u.stopPropagation(),children:[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 mF=e=>e,fF=Object.freeze([]),gF=()=>{};function wf(e){let t=A(),o=W(mF),n=useMemo(()=>t&&!o.isLoading?t.getOutline():fF,[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 so(o)?null:jsx(hl,{headings:n,onHeadingClick:r,onClose:e.onClose??gF,topOffset:e.topOffset??0,...e.leftOffset!==void 0?{leftOffset:e.leftOffset}:{}})}var Df=createContext(null);function No(e){let t=useContext(Df);if(!t)throw new Error(`<DocxEditor.Navigation.${e}> must be rendered inside <DocxEditor.Navigation>`);return t}var CF={ok:false,code:"unsupported",reason:"editor is not ready"},sC=Object.freeze([]);function Jc(e={}){let t=e.enabled??true,o=A(),n=useCallback(S=>t?o?.query({type:"bookmarks"})??sC:sC,[o,t]),r=W(n,fp),[i,a]=useState(""),[l,s]=useState("name"),[c,d]=useState(false),[m,u]=useState(null),[g,p]=useState(null),[f,b]=useState(""),y=useMemo(()=>goToBookmarkRows(r,{query:i,sortBy:l,showHidden:c}),[r,i,l,c]),v=useMemo(()=>m===null?-1:y.findIndex(S=>S.name===m),[y,m]),x=useCallback(S=>{a(S),u(null),p(null);},[]),h=useCallback(S=>{s(S),u(null),p(null);},[]),k=useCallback(S=>{d(S),u(null),p(null);},[]),E=useCallback(S=>{if(y.length===0)return;let P=v<0?S>0?-1:0:v;u(y[(P+S+y.length)%y.length].name);},[y,v]),C=useCallback(S=>u(y[S]?.name??null),[y]),T=useCallback(S=>{if(!o)return CF;let P=S??y[v]?.name??goToBookmarkTarget(r,i,y)?.name;if(P===void 0||P.trim().length===0){let _=i.trim();return p(_.length===0?"empty":"notFound"),b(_),{ok:false,code:"notFound",reason:"no bookmark is named that"}}let w=o.exec({type:"goToBookmark",name:P});return p(w.ok?null:w.code==="notFound"?"notFound":"failed"),b(w.ok?"":P),w},[o,y,v,r,i]);return {query:i,setQuery:x,sortBy:l,setSortBy:h,showHidden:c,setShowHidden:k,rows:y,bookmarks:r,activeIndex:v,move:E,setActiveIndex:C,go:T,problem:g,problemName:f}}var cC=(...e)=>e.filter(Boolean).join(" "),wF={header:"navigation.goTo.places.header",footer:"navigation.goTo.places.footer",footnote:"navigation.goTo.places.footnote",endnote:"navigation.goTo.places.endnote"},DF={body:"navigation.goTo.groups.body",header:"navigation.goTo.groups.header",footer:"navigation.goTo.groups.footer",footnote:"navigation.goTo.groups.footnote",endnote:"navigation.goTo.groups.endnote"};function RF(){return 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 MF({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 yl({className:e,style:t}){let{pane:o,intents:n,t:r}=No("GoTo"),i=A(),a=o.tab!=="goto",l=Jc({enabled:o.open&&!a}),s=re("insert.bookmark"),c=W(so),d=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 b=C=>{l.go(C).ok&&(n.picked(),i?.focus());},y=C=>{C.nativeEvent.isComposing||(C.key==="ArrowDown"||C.key==="ArrowUp"?(C.preventDefault(),l.move(C.key==="ArrowDown"?1:-1)):(C.key==="Home"||C.key==="End")&&l.activeIndex>=0?(C.preventDefault(),l.setActiveIndex(C.key==="Home"?0:l.rows.length-1)):C.key==="Enter"?(C.preventDefault(),b()):C.key==="Escape"&&l.query.length>0&&(C.preventDefault(),l.setQuery("")));},v=l.problem==="notFound"?r("navigation.goTo.notFound",{name:l.problemName}):l.problem==="failed"?r("navigation.goTo.failed"):l.problem==="empty"?r("navigation.goTo.typeName"):l.bookmarks.length>0&&l.rows.length===0?r("navigation.goTo.noMatches"):"",x=l.activeIndex>=0?p(l.activeIndex):void 0,h=l.sortBy==="location",k=l.bookmarks.length===0,E=(C,T)=>{let S=T===l.activeIndex;return jsxs("li",{id:p(T),role:"option","aria-selected":S,className:cC("docx-nav__goto-row",S&&"docx-nav__goto-row--active"),"data-point":C.empty||void 0,onMouseDown:P=>P.preventDefault(),onClick:()=>b(C.name),children:[jsx("span",{className:"docx-nav__goto-icon","aria-hidden":"true",children:C.empty?jsx(RF,{}):jsx(G,{name:"bookmark",size:16})}),jsx("span",{className:"docx-nav__result-text",children:jsx("bdi",{children:jsx(MF,{name:C.name,query:l.query})})}),C.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")})}),!h&&C.place!=="body"&&jsx("span",{className:"docx-nav__goto-place",children:r(wF[C.place])})]},C.name)};return jsxs("div",{className:cC("docx-nav__panel docx-nav__panel--goto",e),style:t,role:"tabpanel",id:"docx-nav-panel-goto","aria-labelledby":"docx-nav-tab-goto",hidden:a,children:[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":x?g:void 0,"aria-expanded":l.rows.length>0,"aria-controls":l.rows.length>0?m:void 0,"aria-autocomplete":"list","aria-activedescendant":x,autoComplete:"off",spellCheck:false,onChange:C=>l.setQuery(C.target.value),onKeyDown:y}),x&&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(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)}),r(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)}),r("dialogs.bookmark.showHidden")]})]}),k&&!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")})]}),!k&&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(C=>l.showHidden||!C.hidden).length}):l.rows.length})]}),jsx("p",{className:"docx-nav__goto-message",role:"status",children:v}),l.rows.length>0&&jsx("ul",{ref:f,id:m,className:"docx-nav__list docx-nav__goto-list",role:"listbox","aria-labelledby":u,children:h?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:r(DF[C.place])}),jsx("ul",{role:"none",className:"docx-nav__goto-sublist",children:C.rows.map(({row:T,index:S})=>E(T,S))})]},C.place)):l.rows.map((C,T)=>E(C,T))})]})}var Na=280,Qc=32,dC=16;function Fa(e=280){return 32+e+16}function ed({viewportWidth:e,pageWidthPx:t,reservation:o,inlineEndReservation:n=0,inlineStartReservation:r=0,docked:i=false}){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0||!Number.isFinite(o)||o<=0||!Number.isFinite(n)||n<0||!Number.isFinite(r)||r<0)return 0;let a=(e-n-t)/2,l=a>=o?0:!i&&o<=2*a?2*(o-a):o;return Math.ceil(Math.max(0,l-r))}var Rf=320;function td(e,t){return !Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?false:e-t<Rf}var FF=Object.freeze([]),LF=e=>e;function od(){let e=A(),t=W(LF),[o,n]=useState(null),r=useMemo(()=>e&&!t.isLoading?e.getOutline():FF,[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 hC=Object.freeze({query:"",matchCase:false,wholeWord:false,matches:Object.freeze([]),truncated:false,activeIndex:-1,activeMatch:null,isPending:false}),BF=()=>()=>{},pC=()=>hC;function nd(e={}){let t=e.highlight??"all",o=A(),n=useMemo(()=>o?createDocumentSearch(o):null,[o]),r=useSyncExternalStore(n?n.subscribe:BF,n?n.getState:pC,n?n.getState:pC);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)??hC.matches,setMatchCase:a=>n?.setMatchCase(a),setWholeWord:a=>n?.setWholeWord(a),goTo:a=>n?.goTo(a)??false,next:()=>n?.next()??false,previous:()=>n?.previous()??false,clear:()=>n?.clear()}),[n]);return useMemo(()=>({...r,...i}),[r,i])}function TC(e,t=isApplePlatform()){return e.altKey||e.shiftKey||e.isComposing||(t?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey)?false:chordLetter(e)==="f"}var EC=isGoToChord;function SC(e=isApplePlatform()){return e?"Ctrl+Alt+G":"Ctrl+G"}function PC(e=isApplePlatform()){return e?"Meta+Alt+G":"Control+G"}function kC(e){return e.startsWith("Ctrl")?"Control+F":"Meta+F"}function wC(e,t,o){if(e?.isConnected){o&&e.closest(".docx-pages")?o():e.focus({preventScroll:true});return}if(e&&o){o();return}t?t.focus({preventScroll:true}):o?.();}function DC(e,t,o){if(!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 If(e,t){let o=e?.querySelector(`#docx-nav-panel-${t}`);if(!o)return null;if(t==="headings"){let n=o.querySelector(".docx-nav__heading--current")??o.querySelector(".docx-nav__heading");if(n)return n}return o.querySelector(".docx-nav__search-input")}function Nf(e){e.focus(),e.localName==="input"&&e.select();}function UF(e){let o=e.querySelector('[role="tab"][aria-selected="true"]')?.id??"",r=If(e,o==="docx-nav-tab-find"?"find":o==="docx-nav-tab-goto"?"goto":"headings");if(r){Nf(r);return}isHTMLElementNode(e)&&(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus());}function $F(e,t){let o=[];if(t.contains(e)){let i=e;for(;i!==t&&i.parentElement;){for(let a of i.parentElement.children)a!==i&&o.push(a);i=i.parentElement;}}else o.push(...t.children);let n=e.ownerDocument.activeElement;n&&o.some(i=>i.contains(n))&&UF(e);let r=[];for(let i of o)i.hasAttribute("inert")||(i.setAttribute("inert",""),r.push(i));return ()=>{for(let i of r)i.removeAttribute("inert");r.length=0;}}function RC(e,t,o){let n=$F(e,t),r=i=>{isDomNode(i.target)&&e.contains(i.target)||o();};return t.addEventListener("pointerdown",r),()=>{t.removeEventListener("pointerdown",r),n();}}function vC(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function MC(e,t){let o=()=>{let i=hostWindowOf(t).getComputedStyle(t),a=t.clientHeight-vC(i.paddingTop)-vC(i.paddingBottom);e.style.setProperty("--docx-nav-block-size",`${Math.max(0,Math.round(a))}px`),e.style.setProperty("--docx-nav-inline-size",`${Math.round(t.clientWidth)}px`);};o();let n=hostWindowOf(t).ResizeObserver;if(typeof n>"u")return ()=>{};let r=new n(o);return r.observe(t),()=>r.disconnect()}function IC(e,t=true,o=true){let n=A(),r=we(),i=useRef(null),a=useRef(null),l=useRef(false),s=useRef(false),c=useRef(false),d=useRef(0),m=useCallback(()=>{let E=++d.current;hostWindowOf(i.current).setTimeout(()=>{d.current===E&&(l.current=false,s.current=false,c.current=false);},0);},[]),u=useRef(e);u.current=e;let g=useCallback(()=>{l.current=false;let E=If(i.current,u.current.tab);E&&Nf(E);},[]),p=useCallback(()=>{s.current=false;let E=a.current;a.current=null;let C=i.current?.querySelector(".docx-nav__toggle")??null;wC(E,C,n?()=>n.focus():null);},[n]),f=useRef(p);f.current=p,useEffect(()=>()=>{s.current&&f.current();},[]);let b=useCallback(()=>{l.current=false,s.current=true,u.current.setOpen(false),m();},[m]),y=useCallback((E,C)=>{C&&!i.current?.contains(C)&&(a.current=C),s.current=false;let T=u.current;if(T.open&&T.tab===E){g();return}l.current=true,T.tab!==E&&T.setTab(E),T.open||T.setOpen(true),m();},[g,m]),v=useMemo(()=>({openTab:E=>{let C=i.current?.ownerDocument.activeElement;y(E,isHTMLElementNode(C)?C:null);},toggle:()=>{if(u.current.open){b();return}a.current=null,s.current=false,l.current=true,u.current.setOpen(true),m();},close:b,picked:()=>{let E=u.current;if(!E.overlay)return;let C=i.current?.ownerDocument.activeElement;c.current=!!C&&!!i.current?.contains(C),E.setOpen(false),m();}}),[b,m,y]),x=useRef(v);x.current=v,useEffect(()=>{let E=i.current?.ownerDocument;if(!E||!t&&!o)return;let C=T=>{if(T.defaultPrevented)return;let S=t&&TC(T)?"find":o&&EC(T)?"goto":null;if(!S||!DC(T.target,i.current,r))return;if(S==="goto"&&n?.can({type:"openGoTo"}).ok){n.exec({type:"openGoTo",fromShortcut:true}).ok&&T.preventDefault();return}T.preventDefault();let P=E.activeElement;y(S,isHTMLElementNode(P)?P:null);};return E.addEventListener("keydown",C),()=>E.removeEventListener("keydown",C)},[r,t,o,y,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 h=e.open&&e.overlay;useEffect(()=>{let E=i.current;if(!(!h||!E||!r))return RC(E,r,()=>x.current.close())},[h,r]),useEffect(()=>{let E=i.current;if(!(!E||!r||!r.contains(E)))return MC(E,r)},[r]);let k=useCallback(E=>{E.key!=="Escape"||E.defaultPrevented||E.nativeEvent.isComposing||u.current.open&&(E.preventDefault(),b());},[b]);return {rootRef:i,intents:v,onKeyDown:k}}var jF=150;function YF(e){return e.source!==void 0?true:(e.created?.length??0)>0||(e.deleted?.length??0)>0}function XF(e){let t=0;for(let o of e)t=Math.max(t,o.box.width);return t>0?t:null}function NC(e,t,o=()=>null){let n=hostTimers(o),r=null,i=false,a=()=>{r=null,i||t(XF(e.getPageGeometry()));},l=()=>{i||(n.clearTimeout(r),r=n.setTimeout(a,jF));},s=e.on("change",c=>{YF(c)&&l();});return a(),{nudge:l,dispose(){i=true,n.clearTimeout(r),r=null,s();}}}var oL=e=>{let t=e.zoomMode;return {pageSetup:e.pageSetup??null,zoom:e.zoom,reviewPaneOpen:e.reviewPaneOpen??true,fitting:t?.type==="fit"&&e.zoom<(t.maxZoom??ZOOM_MAX)&&e.zoom>(t.minZoom??ZOOM_MIN)}},nL=(e,t)=>e.zoom===t.zoom&&e.reviewPaneOpen===t.reviewPaneOpen&&e.fitting===t.fitting&&e.pageSetup?.pageWidthTwips===t.pageSetup?.pageWidthTwips,rL=e=>e.page.total;function rd(e={}){let{defaultOpen:t=false,defaultTab:o="headings",paneWidth:n=280}=e,[r,i]=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]),b=useCallback(O=>{g||l(O),m?.(O);},[g,m]),y=$n(),v=we(),x=useContext(At),{pageSetup:h,zoom:k,reviewPaneOpen:E,fitting:C}=W(oL,nL),T=A(),S=W(rL),[P,w]=useState(0),[_,L]=useState(null),[N,B]=useState(0),[F,D]=useState(0),R=En();useEffect(()=>{if(!v){w(0),B(0),D(0);return}let O=()=>{w(v.clientWidth);let ge=hostWindowOf(v).getComputedStyle(v),K=v.getAttribute("data-chrome-dir")==="rtl",de=Number.parseFloat(K?ge.paddingLeft:ge.paddingInlineEnd);B(Number.isFinite(de)?de:0);let ke=Number.parseFloat(ge.getPropertyValue("--docx-review-gutter-start"));D(Number.isFinite(ke)?ke:0);};O();let I=hostWindowOf(v).ResizeObserver;if(typeof I>"u")return;let ie=new I(O);return ie.observe(v),()=>ie.disconnect()},[v,s,E,x?.mounted,x?.gutters,R]);let U=useRef(null);h&&(U.current=h.pageWidthTwips);let V=h?.pageWidthTwips??U.current,Y=useRef(null);useEffect(()=>{if(!s||!T)return;let O=NC(T,L,()=>v);return Y.current=O,()=>{O.dispose(),Y.current===O&&(Y.current=null);}},[s,T,v]),useEffect(()=>Y.current?.nudge(),[S,V]);let j=Fa(n),q=ly(R,N),X=s&&td(P-q,j),ee=useMemo(()=>!s||X||V===null?0:ed({viewportWidth:P,pageWidthPx:Math.max(_??0,$e(V))*k,reservation:j,inlineEndReservation:N,inlineStartReservation:F,docked:C}),[s,X,V,_,k,P,j,N,F,C]);return useEffect(()=>{if(y)return y.setShift(ee),()=>y.setShift(0)},[y,ee]),useEffect(()=>{if(y)return y.setReservation(s&&!X?j:0),()=>y.setReservation(0)},[y,s,X,j]),{open:s,setOpen:p,toggle:f,tab:c,setTab:b,paneWidth:n,shift:ee,overlay:X}}var Cl=["headings","find","goto"],Ho=(...e)=>e.filter(Boolean).join(" ");function Tl({className:e,style:t,children:o}){return jsx("div",{className:Ho("docx-nav__header",e),style:t,children:o??jsxs(Fragment,{children:[jsx(El,{}),jsx(Sl,{})]})})}function El({className:e,style:t,children:o}){let{intents:n,t:r}=No("Close");return jsx("button",{type:"button",className:Ho("docx-nav__close",e),style:t,"aria-label":r("navigation.closeAriaLabel"),title:r("navigation.closeTitle"),onClick:n.close,children:o??jsx(G,{name:"arrow_back",size:20})})}function Sl({className:e,style:t,children:o}){let{t:n}=No("Title");return jsx("h2",{className:Ho("docx-nav__title",e),style:t,children:o??n("navigation.title")})}function Pl({className:e,style:t,children:o}){let{pane:n,t:r}=No("Tabs"),i=useCallback(a=>{let l=a.key==="ArrowRight"?1:a.key==="ArrowLeft"?-1:0;if(l===0)return;a.preventDefault();let s=Cl.indexOf(n.tab);n.setTab(Cl[(s+l+Cl.length)%Cl.length]);},[n]);return jsx("div",{className:Ho("docx-nav__tabs",e),style:t,role:"tablist","aria-label":r("navigation.title"),onKeyDown:i,children:o??Cl.map(a=>jsx(kl,{value:a},a))})}function kl({value:e,className:t,style:o,children:n}){let{pane:r,t:i,goToShortcut:a}=No("Tab"),l=eo(),s=r.tab===e,c=e==="goto"&&a?i("navigation.goTo.tabTitle",{shortcut:l(SC())}):void 0;return jsx("button",{type:"button",role:"tab",id:`docx-nav-tab-${e}`,"aria-selected":s,"aria-controls":`docx-nav-panel-${e}`,tabIndex:s?0:-1,className:Ho("docx-nav__tab",s&&"docx-nav__tab--selected",t),style:o,...c?{title:c,"aria-keyshortcuts":PC()}:{},onClick:()=>r.setTab(e),children:n??i(`navigation.tabs.${e}`)})}function HC({value:e,onChange:t,onClear:o,placeholder:n,label:r,clearLabel:i,autoFocus:a,onEnter:l}){let s=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 wl({className:e,style:t}){let{pane:o,outline:n,intents:r,t:i}=No("Headings"),[a,l]=useState(""),s=W(so),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:Ho("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-headings","aria-labelledby":"docx-nav-tab-headings",hidden:d,children:[jsx(HC,{value:a,onChange:l,onClear:()=>l(""),placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel")}),s?null:n.isEmpty?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:Ho("docx-nav__heading",n.selectedBlockId===m.heading.blockId&&"docx-nav__heading--current"),style:{paddingInlineStart:`${8+m.depth*14}px`},title:m.heading.text,onClick:()=>{n.goTo(m.heading.blockId),r.picked();},children:jsx("bdi",{children:m.heading.text})})},`${m.heading.blockId}-${u}`))})]})}function dL({match:e,active:t,onSelect:o}){return jsx("li",{children:jsx("button",{type:"button",className:Ho("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 Dl({className:e,style:t}){let{pane:o,search:n,intents:r,t:i}=No("Find"),a=o.tab!=="find",l=n.query.trim().length>0,s=o.open&&!a,c=n.matches.length===0?null:n.activeIndex<0?i(n.truncated?"navigation.find.totalTruncated":"navigation.find.total",{total:n.matches.length}):i(n.truncated?"navigation.find.counterTruncated":"navigation.find.counter",{current:n.activeIndex+1,total:n.matches.length});return jsxs("div",{className:Ho("docx-nav__panel",e),style:t,role:"tabpanel",id:"docx-nav-panel-find","aria-labelledby":"docx-nav-tab-find",hidden:a,children:[jsx(HC,{value:n.query,onChange:n.setQuery,onClear:n.clear,placeholder:i("navigation.find.placeholder"),label:i("navigation.find.inputAriaLabel"),clearLabel:i("navigation.find.clearAriaLabel"),autoFocus:s,onEnter:d=>{n.isPending&&n.find(n.query),d?n.previous():n.next();}}),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(dL,{match:d,active:m===n.activeIndex,onSelect:()=>{n.goTo(m),r.picked();}},`${d.blockId}-${d.start}-${m}`))})]})}function Rl({className:e,style:t,children:o}){let{pane:n,intents:r,findShortcut:i,t:a}=No("Toggle"),s=eo()("Ctrl+F"),c=i?kC(s):void 0,d=i?a("navigation.openShortcutTitle",{shortcut:s}):a("navigation.openTitle");return jsx("button",{type:"button",className:Ho("docx-nav__toggle",e),style:t,"aria-label":a("navigation.openAriaLabel"),"aria-expanded":n.open,"aria-keyshortcuts":c,title:d,onMouseDown:m=>m.preventDefault(),onClick:r.toggle,children:o??jsx(G,{name:"toc",size:20})})}function Lf(e){let t=$t(),o=lt(),{t:n,toggle:r=true,searchHighlight:i="all",findShortcut:a=true,goToShortcut:l=true,className:s,style:c,children:d,...m}=e,u=rd(m),g=od(),p=u.open&&u.tab==="find"?i:"none",f=nd({highlight:p}),b=tt(),y=useMemo(()=>n??((T,S)=>b(T,S)),[n,b]),v=IC(u,a,l),x=useMemo(()=>({pane:u,outline:g,search:f,t:y,intents:v.intents,findShortcut:a,goToShortcut:l}),[u,g,f,y,v.intents,a,l]),h=A(),k=useRef(v.intents);k.current=v.intents;let E=useRef(l);E.current=l,useEffect(()=>{if(h)return h.setGoToChrome({onRequest:()=>k.current.openTab("goto"),get shortcut(){return E.current}})},[h]);let C=e.paneWidth??280;return jsx(Df.Provider,{value:x,children:jsxs("div",{ref:v.rootRef,className:`${t}docx-nav${u.open?" docx-nav--open":""}${u.overlay?" docx-nav--overlay":""}${s?` ${s}`:""}`,"data-open":u.open?"true":"false",dir:o,onKeyDown:v.onKeyDown,style:{"--docx-nav-width":`${C}px`,"--docx-nav-inset":`${32}px`,"--docx-nav-reservation":`${Fa(C)}px`,...c},children:[r!==false&&!u.open&&jsx(Rl,{...typeof r=="object"?r:{}}),jsx("aside",{className:"docx-nav__panel-shell","aria-label":x.t("navigation.ariaLabel"),inert:!u.open,children:d??jsxs(Fragment,{children:[jsx(Tl,{}),jsx(Pl,{}),jsx(wl,{}),jsx(Dl,{}),jsx(yl,{})]})})]})})}var ad=Object.assign(Lf,{Header:Tl,Close:El,Title:Sl,Tabs:Pl,Tab:kl,Headings:wl,Find:Dl,GoTo:yl,Toggle:Rl});var xL=600,vL=e=>e.isOpening===true?0:e.page.total,id=createContext(null);function ld({className:e,style:t}){let o=$t(),n=Ut(),r=A(),i=we(),{inside:a,host:l,hostScoped:s}=py(i),c=W(vL),{t:d}=H(),m=useContext(id),[u,g]=useState(1),[p,f]=useState(false);if(useEffect(()=>{if(f(false),!r||!i||c<=1)return;g(r.getCurrentPage("viewport"));let x=hostWindowOf(i),h=null,k=()=>{g(r.getCurrentPage("viewport")),f(true),h!==null&&x.clearTimeout(h),h=x.setTimeout(()=>f(false),xL);};return i.addEventListener("scroll",k,{passive:true}),()=>{i.removeEventListener("scroll",k),h!==null&&x.clearTimeout(h);}},[r,c,i]),c<=1)return null;let b=l?s?"":`docx-editor ${n?"dark ":""}`:o,y=m?m("viewer.pageIndicator").replace(/\{current\}/g,String(u)).replace(/\{total\}/g,String(c)):d("viewer.pageIndicator",{current:u,total:c}),v=jsx("div",{className:`${b}docx-editor-shell__page-indicator-chip docx-editor__page-number${e?` ${e}`:""}`,style:t,"data-visible":p?"true":"false",role:"status","aria-live":"polite",children:y});return a?l?createPortal(v,l):null:v}var EL=[],SL=e=>e.fontSubstitutions??EL;function sd({className:e,style:t,t:o}){let n=W(SL),{t:r}=H(),i=o??r,[a,l]=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 FL={damaged:"openFailure.reasons.damaged","not-docx":"openFailure.reasons.notDocx","too-large":"openFailure.reasons.tooLarge",blocked:"openFailure.reasons.blocked",unknown:"openFailure.reasons.unknown"};function LL(e,t){return typeof e=="object"&&e!==null&&"reason"in e&&e!==t}var HL=e=>e.openFailure??null;function qC(e={}){let t=W(HL),{t:o}=H(),n=e.t??o,[r,i]=useState(null),a=t!==null&&t!==r?t:null,l=useCallback(s=>{LL(s,t)||i(t);},[t]);return {failure:a,message:a?n(FL[a.reason]):null,dismiss:l}}var UC=createContext(null);function Af({variant:e="secondary",dismiss:t=false,asChild:o=false,className:n,onClick:r,children:i,type:a,...l}){let s=useContext(UC),c=`docx-dialog__button${e==="primary"?" docx-dialog__button--primary":""}${n?` ${n}`:""}`,d=m=>{r?.(m),t&&!m.defaultPrevented&&s?.dismiss();};return o?jsx(Q,{...l,className:c,onClick:d,children:i}):jsx("button",{...l,type:a??"button",className:c,onClick:d,children:i})}var KC=new Set;function $C(e,t){if(!t||!xt())return;let o=e===false?"disabled":typeof e=="object"&&e.actions?"both":null;o===null||KC.has(o)||(KC.add(o),console.warn(o==="both"?"[docx-editor] renderOpenFailureActions replaces openFailure.actions. Pass only one.":"[docx-editor] renderOpenFailureActions is ignored with openFailure={false}, which renders no dialog."));}function zC(e){return Children.toArray(e).some(t=>isValidElement(t)&&t.type===Fragment$1?zC(t.props.children):true)}function AL({title:e,message:t,showCode:o=true,actions:n,closeLabel:r,showClose:i=true,onDismiss:a,children:l,className:s,style:c,t:d}){let{t:m}=H(),u=d??m,{failure:g,message:p,dismiss:f}=qC({t:u}),b=useId();if(!g||p===null)return null;let y=()=>{f(g),a?.(g);},v={failure:g,message:p,dismiss:y},x=e??u("openFailure.title"),h=typeof t=="function"?t(g):t??p,k=n?.(v),E=zC(k);return jsx(UC.Provider,{value:v,children:jsx(Fe,{kind:"openFailure",role:"alertdialog",label:x,className:s,style:c,onClose:y,dismissOutside:false,...l?{}:{describedBy:b},children:l?l(v):jsxs(Fragment,{children:[jsx("header",{className:"docx-dialog__header",children:jsx("h2",{className:"docx-dialog__title",children:x})}),jsxs("div",{className:"docx-dialog__body",children:[jsx("div",{id:b,className:"docx-dialog__message",children:h}),o?jsx("p",{className:"docx-dialog__code",children:u("openFailure.code",{code:g.code}).replace("{code}",g.code)}):null]}),E||i?jsxs("footer",{className:"docx-dialog__footer",children:[k,i?jsx(Af,{variant:E?"secondary":"primary",dismiss:true,children:r??u("common.close")}):null]}):null]})})})}var cd=Object.assign(AL,{Action:Af});function Of(e){return Math.round(e/1440*100)/100}function VC(e){return Math.round(e*1440)}function WL(e,t){return e===t?true:!e||!t?false:e.editing===t.editing&&e.sectionIndex===t.sectionIndex&&e.variant===t.variant&&e.rId===t.rId&&e.partName===t.partName&&e.inherited===t.inherited&&e.titlePage===t.titlePage&&e.evenAndOddHeaders===t.evenAndOddHeaders&&e.headerDistanceTwips===t.headerDistanceTwips&&e.footerDistanceTwips===t.footerDistanceTwips}function Bf(){let e=A(),t=useCallback(o=>e?.getHeaderFooterState()??null,[e]);return W(t,WL)}function UL(e,t){return t==="first"?e==="header"?"headerFooter.firstPageHeader":"headerFooter.firstPageFooter":t==="even"?e==="header"?"headerFooter.evenPageHeader":"headerFooter.evenPageFooter":e==="header"?"headerFooter.header":"headerFooter.footer"}var $L=[{field:"PAGE",labelKey:"headerFooter.insertPageNumber"},{field:"NUMPAGES",labelKey:"headerFooter.insertTotalPages"},{field:"SECTIONPAGES",labelKey:"headerFooter.insertSectionPages"},{field:"PAGE_X_OF_Y",labelKey:"headerFooter.insertPageXofY"}];function Ml(e){let t=A();return useMemo(()=>{if(!t)return {enabled:false,reason:"editor is not ready"};let o=t.can(e);return o.ok?{enabled:true,reason:null}:{enabled:false,reason:o.reason}},[t,e])}function zL(e){let{state:t,onMouseDown:o}=e,{t:n}=H(),r=A(),[i,a]=useState(false),l=useRef(null),[s,c]=useState(""),[d,m]=useState("");useEffect(()=>{i&&(t.headerDistanceTwips===void 0||t.footerDistanceTwips===void 0||(c(String(Of(t.headerDistanceTwips))),m(String(Of(t.footerDistanceTwips)))));},[i,t.headerDistanceTwips,t.footerDistanceTwips]),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"}),[]),b=useMemo(()=>({type:"removeHeaderFooter",position:t.editing}),[t.editing]),y=Ml(u),v=Ml(g),x=Ml(p),h=Ml(f),k=Ml(b),E=(C,T)=>{if(!r)return;let S=Number.parseFloat(T);Number.isFinite(S)&&r.exec({type:"setHeaderFooterOptions",[C]:VC(S)});};return 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:n("headerFooter.options")}),i?jsxs("div",{className:"docx-hf-chrome__options-menu",role:"menu",onMouseDown:o,children:[$L.map(C=>{let T={type:"insertPageField",field:C.field},S=r?.can(T);return jsx("button",{type:"button",role:"menuitem",className:"docx-hf-chrome__menu-item",disabled:!S?.ok,title:S&&!S.ok?S.reason:void 0,onClick:()=>{r?.exec(T),a(false);},onMouseDown:o,children:n(C.labelKey)},C.field)}),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:()=>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:!v.enabled,title:v.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:!h.enabled,title:h.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:!x.enabled,title:x.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:C=>c(C.target.value),onBlur:()=>E("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:C=>m(C.target.value),onBlur:()=>E("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:!k.enabled,title:k.reason??void 0,onClick:()=>r?.exec(b),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 dd({className:e}){let{t}=H(),o=Bf(),n=useCallback(l=>l.querySelector("[data-docx-hf-active]"),[]),r=wi(n,"story-label"),i=$;if(!o?.editing)return null;let a=UL(o.editing,o.variant);return jsxs("div",{ref:r.ref,className:`docx-context-bar docx-hf-chrome${e?` ${e}`:""}`,role:"region","aria-label":t("headerFooter.chromeAriaLabel"),"data-testid":"docx-hf-chrome",onMouseDown:i,style:{...r.style,zIndex:St.hfInlineEditor},children:[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(zL,{state:o,onMouseDown:i})]})}var GL={display:"flex",flexDirection:"column",height:"100%",width:"100%",backgroundColor:"var(--doc-bg)"},jL={flex:1,minHeight:0,minWidth:0,overflowAnchor:"none"},YL={position:"relative",display:"flex",flex:1,minHeight:0,minWidth:0},XL={flex:"none",minHeight:34,padding:"6px 0 2px",overflow:"hidden",scrollbarGutter:"stable both-edges",backgroundColor:"var(--doc-bg)"},JL={position:"absolute",top:40,insetInlineStart:0,zIndex:10,pointerEvents:"none"},QL={flex:"none",display:"flex",flexDirection:"column",position:"relative",zIndex:"var(--doc-z-overlay)",backgroundColor:"var(--doc-surface)",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--doc-border)",boxShadow:"0 1px 3px var(--doc-shadow-subtle)"},e4={padding:"8px 12px"},t4={display:"flex",alignItems:"center",gap:8,padding:"8px 12px 0",color:"var(--doc-text)"},o4={display:"flex",flexDirection:"column",flex:1,minWidth:0,gap:2},n4={flex:1,minWidth:0,font:"inherit",color:"inherit",backgroundColor:"transparent",border:"1px solid transparent",borderRadius:4,padding:"2px 6px"};function r4({forwardedRef:e}){let t=A(),o=useRef(null);return o.current=t,fy({ref:e,editorRef:o}),null}function a4(...e){let t=e.filter(Boolean).join(" ");return t===""?void 0:t}var i4=forwardRef(function(t,o){let{document:n,fonts:r,fontShaping:i,imageDecodePort:a,className:l,t:s,chrome:c=true,title:d,onTitleChange:m,renderTitleBarLeft:u,renderTitleBarRight:g,renderOpenFailureActions:p,loadingIndicator:f,colorMode:b="light",author:y,locale:v,mode:x="edit",modules:h,zoom:k,zoomMode:E,revisionMarkup:C,onRevisionMarkupChange:T,reviewDisplayMode:S,fieldResults:P,contentLockPolicy:w,lockedControlNavigation:_,onReady:L,onChange:N,onFontError:B,onOpen:F,onSave:D,hyperlinkPopup:R,contextMenu:U=true,menu:V=true,navigation:Y=true,openFailure:j=true,rulers:q=true}=t;!c&&f!==void 0&&q0(),$C(j,p!==void 0);let X=Ul(b),{t:ee}=H(),O=lt(),I=useCallback((de,ke)=>s?s(de,ke):ee(de,ke),[s,ee]),ie=jsxs(ac,{className:c?X?"dark":void 0:l,style:c?jL:void 0,children:[c?jsx(dd,{}):null,c?jsx(Hs,{}):null,jsx(Qs,{}),q&&c?jsx("div",{style:JL,dir:O,children:jsx(Xc,{})}):null,t.children]}),ge=c?jsxs("div",{className:`docx-editor${X?" dark":""}${l?` ${l}`:""}`,style:GL,dir:O,children:[jsxs("div",{style:QL,children:[jsxs("div",{style:t4,children:[u?.(),jsxs("div",{style:o4,children:[m?jsx("input",{"aria-label":I("titleBar.documentNameAriaLabel"),value:d??"",placeholder:I("titleBar.untitled"),onChange:de=>m(de.target.value),style:n4}):jsx("span",{style:{minWidth:0,padding:"2px 6px"},children:d??I("titleBar.untitled")}),V!==false?jsx(pl,{t:I,...d!==void 0?{fileName:d}:{},...F?{onOpen:F}:{},...D?{onSave:D}:{},...typeof V=="object"?V:{}}):null]}),g?.()]}),jsx("div",{style:e4,children:jsx(sl,{t:I})})]}),q?jsx("div",{style:XL,"data-testid":"docx-editor-ruler-row",children:jsx(Yc,{})}):null,jsx(sd,{t:I}),jsxs("div",{style:YL,children:[Y===false?null:jsx(ad,{t:I,...typeof Y=="object"?Y:{}}),ie,jsx(id.Provider,{value:I,children:jsx(ld,{})}),jsx(tc,{overlay:true,indicator:f})]})]}):ie,K=useCallback(de=>I(de),[I]);return jsxs(Ai,{popups:p0(t.popups,R,U,I),...n!==void 0?{document:n}:{},...r?{fonts:r}:{},...i?{fontShaping:i}:{},...a?{imageDecodePort:a}:{},...y!==void 0?{author:y}:{},...v!==void 0?{locale:v}:{},translate:I,...c?{colorMode:X?"dark":"light"}:{},mode:x,...h!==void 0?{modules:h}:{},...k!==void 0?{zoom:k}:{},revisionMarkup:C,onRevisionMarkupChange:T,reviewDisplayMode:S,...P!==void 0?{fieldResults:P}:{},...w!==void 0?{contentLockPolicy:w}:{},..._!==void 0?{lockedControlNavigation:_}:{},...E!==void 0?{zoomMode:E}:{},tableInteractionLabel:K,...L?{onReady:L}:{},...N?{onChange:N}:{},...B?{onFontError:B}:{},children:[jsx(r4,{forwardedRef:o}),jsx(Wo.Provider,{value:c,children:ge}),j===false?null:jsx(cd,{t:I,...typeof j=="object"?j:{},...p?{actions:p}:{},className:a4(X?"dark":void 0,typeof j=="object"?j.className:void 0)})]})}),l4=forwardRef(function(t,o){return jsx(Mr,{...t.i18n!==void 0?{i18n:t.i18n}:{},children:jsx(i4,{...t,ref:o})})}),s4=Object.assign(l4,{Root:Ai,Viewport:ac,Content:Qs,Window:pm,Toolbar:sl,Menu:pl,Loading:tc,ColorByChangeType:gm,RevisionMarkup:lu,RevisionMarkupDialog:Ka,CompareDocumentsDialog:qa,UnsupportedElement:Fd,AuthorStyle:bm,HorizontalRuler:Yc,VerticalRuler:Xc,DocumentOutline:wf,Navigation:ad,ExportDialog:Ua,PrintDialog:$a,PageSetupDialog:tr,WatermarkDialog:or,BookmarkDialog:mi,SplitCellDialog:fi,ParagraphDialog:Vo,TextFormFieldDialog:bi,PageNumber:ld,FontNotice:sd,OpenFailure:cd,HeaderFooterChrome:dd,NotesChrome:Hs,Equation:oi,HyperLink:Ja,ContextMenu:Sp,ContentControlWidget:am,InvalidTextFormFieldDialog:Ap,ImageAltTextPopup:Us,ImagePropertiesDialog:Ri,NotePropertiesDialog:As,NotePreview:Nr,NotesContextMenu:Fr,ContentControl:ti});function m4(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null}function Zf(e){return Array.isArray(e)?e:[e]}function f4(e){if(typeof e!="function"||isFontResolver(e))return e;let t=e;return defineFontResolver(async()=>t())}function JC(e){return e!==void 0&&Zf(e).some(t=>isFontResolver(t))}async function g4(e){return typeof e!="function"?await e:await e()}function b4(e,t={}){let[o,n]=useState(void 0),[r,i]=useState(void 0),[a,l]=useState(null),[s,c]=useState(e!=null),d=JC(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(b=>composeFontOrigins(Zf(p.current.fonts??[]).map(f4),b)),[]);return useEffect(()=>{let b=p.current.fonts;if(b===void 0){i(void 0),g(true);return}if(JC(b)){g(true);return}g(false);let y=true;return (async()=>{try{let v=await Promise.allSettled(Zf(b).map(g4)),x=[];for(let h of v){if(h.status==="rejected"){console.warn("[fonts] font loading failed for one origin; the others still compose",h.reason);continue}h.value!==void 0&&x.push(h.value);}y&&x.length>0&&i(composeFontConfiguration(x[0],...x.slice(1)));}catch(v){console.warn("[fonts] font loading failed; the fixed measurer stays in effect",v);}finally{y&&g(true);}})(),()=>{y=false;}},[m]),useEffect(()=>{if(e==null){n(void 0),l(null),c(false);return}let b=m4(e);if(b){n(b),l(null),c(false);return}let y=true,v=new AbortController;return c(true),l(null),(async()=>{try{let x=await fetch(String(e),{...p.current.fetchOptions,signal:v.signal});if(!x.ok)throw new Error(`could not open the document: ${x.status} ${x.statusText}`);let h=new Uint8Array(await x.arrayBuffer());if(!y)return;n(h),c(!1);}catch(x){if(!y||x instanceof Error&&x.name==="AbortError")return;l(x instanceof Error?x:new Error("could not open the document")),c(false);}})(),()=>{y=false,v.abort();}},[e]),{document:u?o:void 0,fonts:d?f:r,error:a,isLoading:s||!u}}function C4(...e){let t=useRef(e);return t.current=e,useMemo(()=>defineFontResolver(o=>composeFontOrigins(t.current,o)),[])}function S4(e){let o=e?.surface?.state?.().selection?.head;return o&&typeof o.paragraphId=="string"&&Number.isFinite(o.offset)?o:null}function P4(){let e=A(),t=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=S4(e),i=t.current;return (r===null?i===null:i!==null&&k4(i,r))?i:(t.current=r,r)},[e]);return useSyncExternalStore(o,n,()=>null)}function k4(e,t){return e.paragraphId===t.paragraphId&&e.offset===t.offset}function R4(e){let t=A(),o=useRef(e);o.current=e;let n=typeof e=="function";useEffect(()=>{if(!(!t||!n))return t.setCommentDraftChrome({onRequest:()=>o.current?.()})},[t,n]);}var nT=Object.freeze({applied:0,unavailable:0});function rT(e){if(!e)return "";let{color:t,activeColor:o,activeIndex:n,className:r,priority:i}=e;return JSON.stringify([t,o,n,r,i])}function N4(e,t,o){let n=A(),[r,i]=useState(nT),a=useRef(null),l=useRef(o);l.current=o;let s=useRef(t);s.current=t;let c=rT(o);return useEffect(()=>{if(!n){i(nT);return}let d=watchHighlights(n,e,s.current,{...l.current,onResult:i});return a.current={watch:d,source:s.current,key:rT(l.current)},i(d.result),()=>{d.stop(),a.current=null;}},[n,e]),useEffect(()=>{let d=a.current;!d||d.source===t&&d.key===c||(d.source=t,d.key=c,d.watch.update(t,l.current??{}));},[t,c]),r}function B4(e,t){return e===t?true:!e||!t?false:e.name===t.name&&e.index===t.index&&e.range===t.range&&e.active===t.active&&e.rect.left===t.rect.left&&e.rect.top===t.rect.top&&e.rect.width===t.rect.width&&e.rect.height===t.rect.height}function W4(e){let t=A(),o=we(),[n,r]=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=>B4(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 qf({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:y=>{m(y),u.current?.(y);}});if(!f.ok){g.current?.(f.reason,f.detail);return}c.current=f.surface;let b=f.surface.state();return m(b),u.current?.(b),()=>{f.surface.destroy(),c.current=null;}},[e,o]),useImperativeHandle(l,()=>({focus:()=>c.current?.focus(),type:p=>c.current?.type(p),undo:()=>c.current?.undo(),redo:()=>c.current?.redo(),selectAll:()=>c.current?.selectAll(),navigate:(p,f)=>c.current?.navigate(p,f),toggleRunProperty:(p,f)=>c.current?.toggleRunProperty(p,f),setRunProperty:(p,f)=>c.current?.setRunProperty(p,f),setParagraphProperty:(p,f,b)=>c.current?.setParagraphProperty(p,f,b),formatting:()=>c.current?.formatting()??null,sectionProperties:()=>c.current?.sectionProperties()??null,save:()=>c.current?.save()??null}),[]),jsx("div",{ref:s,style:{margin:"24px auto",...a?{fontFamily:a}:{}},className:i?`docx-paginated-surface ${i}`:"docx-paginated-surface","data-revision":d?.revision??0,"data-page-count":d?.pageCount??0})}var Il=createContext(null);function aT(){let e=useContext(Il);if(!e)throw new Error("useEditorToolbar must be used within an <EditorToolbar> component");return e}function J4(e){return "type"in e&&e.type==="separator"}var sT={display:"flex",alignItems:"center",gap:2,padding:"2px 8px",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",fontSize:13,fontWeight:400,color:"var(--doc-text)",whiteSpace:"nowrap",height:28,lineHeight:"28px"},Q4={...sT,background:"var(--doc-bg-hover)"},cT={display:"flex",alignItems:"center",gap:8,padding:"6px 12px",border:"none",background:"transparent",cursor:"pointer",fontSize:13,color:"var(--doc-text)",width:"100%",textAlign:"left",whiteSpace:"nowrap"},e3={...cT,opacity:.4,cursor:"default"},t3={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},o3={marginLeft:"auto",fontSize:12,color:"var(--doc-text-muted)"},n3={position:"absolute",left:"100%",top:-4,marginLeft:2,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",padding:8,zIndex:1001};function Nl({label:e,items:t,disabled:o,showChevron:n=false}){let[r,i]=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(x){x.key==="Escape"&&u();}function f(){u();}let b=hostDocumentOf(s.current),y=hostWindowOf(s.current),v=listenForOutsidePress({popup:s.current,contains:x=>!s.current||!c.current||s.current.contains(x)||c.current.contains(x),close:u});return b.addEventListener("keydown",p),y.addEventListener("scroll",f,true),()=>{v(),b.removeEventListener("keydown",p),y.removeEventListener("scroll",f,true);}},[r,u]);let g=p=>{p.disabled||p.submenuContent||p.onClick&&(p.onClick(),u());};return jsxs("div",{style:{position:"relative"},children:[jsxs("button",{ref:s,type:"button",onClick:()=>!o&&i(!r),onMouseDown:p=>p.preventDefault(),disabled:o,style:r?Q4:sT,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(J4(p))return jsx("div",{style:t3},`sep-${f}`);let b=p;if(b.customContent)return jsx("div",{onMouseDown:x=>x.preventDefault(),children:b.customContent},b.label);let y=!!b.submenuContent,v=a===b.label;return jsxs("div",{style:{position:"relative"},onMouseEnter:()=>y&&l(b.label),onMouseLeave:()=>y&&l(null),children:[jsxs("button",{type:"button",style:b.disabled?e3:cT,onClick:()=>g(b),onMouseDown:x=>x.preventDefault(),onMouseOver:x=>{b.disabled||(x.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseOut:x=>{x.currentTarget.style.backgroundColor="transparent";},disabled:b.disabled,children:[b.icon&&jsx(G,{name:b.icon,size:18}),jsx("span",{children:b.label}),b.shortcut&&jsx("span",{style:o3,children:b.shortcut}),y&&jsx("span",{style:{marginLeft:"auto"},children:jsx(G,{name:"keyboard_arrow_right",size:16})})]}),y&&v&&jsx("div",{style:n3,onMouseDown:x=>x.preventDefault(),children:b.submenuContent(u)})]},b.label)})})]})}var zf=18,a3=2,uT={width:zf,height:zf,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:2,transition:"background-color 0.1s, border-color 0.1s",cursor:"pointer"},i3={...uT,backgroundColor:"var(--doc-primary)",border:"1px solid var(--doc-primary)"},l3={marginTop:6,fontSize:11,fontWeight:500,color:"var(--doc-text)",textAlign:"center"};function pT({onInsert:e,gridRows:t=6,gridColumns:o=6}){let[n,r]=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?i3:uT,onMouseEnter:()=>{r(d),a(m);},onClick:l,role:"gridcell","aria-selected":u},`${d}-${m}`));}let c=n>0&&i>0?`${i} \xD7 ${n}`:"Select size";return jsxs("div",{children:[jsx("div",{style:{display:"grid",gap:a3,gridTemplateColumns:`repeat(${o}, ${zf}px)`},onMouseLeave:()=>{r(0),a(0);},role:"grid","aria-label":"Table size selector",children:s}),jsx("div",{style:l3,children:c})]})}function p3({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 m3(){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 md({children:e}){return jsx("div",{className:"flex items-center flex-shrink-0",children:e})}function f3(e){return e.replace(/\.docx$/i,"")}function Gf({value:e,onChange:t,placeholder:o,editable:n=true}){let{t:r}=H(),i=o??r("titleBar.untitled"),a=f3(e)??"";return n?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 fd({children:e}){return jsx("div",{className:"flex items-center gap-2 ml-auto flex-shrink-0",children:e})}function gd(){let{t:e}=H(),t=aT(),{disabled:o=false,onFormat:n,onPrint:r,onOpen:i,onSave:a,onPageSetup:l,onInsertImage:s,onInsertTable:c,showTableInsert:d=true,showHelpMenu:m=true,onInsertPageBreak:u,onInsertSectionBreakNextPage:g,onInsertSectionBreakContinuous:p,onInsertTOC:f,onWatermark:b,onRefocusEditor:y}=t,v=useCallback(E=>{!o&&n&&n(E);},[o,n]),x=useCallback((E,C)=>{!o&&c&&(c(E,C),hostWindowOf(t.editorRef?.current).requestAnimationFrame(()=>y?.()));},[o,c,y,t.editorRef]),h=!!r||!!l,k=h||i||a;return jsxs("div",{className:"flex items-center",role:"menubar","aria-label":e("titleBar.menuBarAriaLabel"),children:[k&&jsx(Nl,{label:e("toolbar.file"),disabled:o,items:[...i?[{icon:"file_upload",label:e("toolbar.open"),shortcut:e("toolbar.openShortcut"),onClick:i}]:[],...a?[{icon:"file_download",label:e("toolbar.save"),shortcut:e("toolbar.saveShortcut"),onClick:a}]:[],...(i||a)&&h?[{type:"separator"}]:[],...r?[{icon:"print",label:e("toolbar.print"),shortcut:e("toolbar.printShortcut"),onClick:r}]:[],...l?[{icon:"settings",label:e("toolbar.pageSetup"),onClick:l}]:[]]}),jsx(Nl,{label:e("toolbar.format"),disabled:o,items:[{icon:"format_textdirection_l_to_r",label:e("toolbar.leftToRight"),onClick:()=>v("setLtr")},{icon:"format_textdirection_r_to_l",label:e("toolbar.rightToLeft"),onClick:()=>v("setRtl")}]}),jsx(Nl,{label:e("toolbar.insert"),disabled:o,items:[...s?[{icon:"image",label:e("toolbar.image"),onClick:s}]:[],...d&&c?[{icon:"grid_on",label:e("toolbar.table"),submenuContent:E=>jsx(pT,{onInsert:(C,T)=>{x(C,T),E();}})}]:[],...s||d&&c?[{type:"separator"}]:[],{icon:"page_break",label:e("toolbar.break"),submenuContent:E=>jsx(p3,{closeMenu:E,items:[{icon:"page_break",label:e("toolbar.pageBreak"),onClick:u},{icon:"horizontal_rule",label:e("toolbar.sectionBreakNextPage"),onClick:g},{icon:"border_horizontal",label:e("toolbar.sectionBreakContinuous"),onClick:p}]})},{icon:"format_list_numbered",label:e("toolbar.tableOfContents"),onClick:f,disabled:!f},...b?[{icon:"branding_watermark",label:e("toolbar.watermark"),onClick:b}]:[]]}),m&&jsx(Nl,{label:e("toolbar.help"),disabled:o,items:[{label:e("toolbar.reportIssue"),onClick:()=>dl()}]})]})}function jf({children:e}){let t=null,o=null,n=[],r=[];Children.forEach(e,a=>{isValidElement(a)&&(a.type===md?t=a:a.type===fd?o=a:a.type===gd?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(m3,{})}),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 bd={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},y3={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""},mT={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function x3(e,t){let o=mT[t]??mT[t.toLowerCase()]??t,r=e?.colorScheme?.[o];return typeof r=="string"&&r?r:bd[o]??"000000"}function fT(e){let t=e.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/.test(t))return t;if(/^[0-9A-F]{3}$/.test(t))return t.split("").map(o=>o+o).join("")}function Yf(e,t,o="000000"){if(!e||e.kind==="auto")return `#${o}`;if(e.kind==="hex")return `#${fT(e.value)??o}`;let n=Object.entries(t?.colorScheme??bd).map(([i,a])=>({slot:i,hex:String(a)})),r=resolveThemeColorHex(e,n);return `#${r.ok?r.hex:x3(t,e.slot)}`}function tn(e,t){if(!(!e||e.kind==="auto"))return e.kind==="hex"?fT(e.value):Yf(e,t).slice(1)}function gT(e){if(!e||e==="none")return "";let t=y3[e];return t?`#${t}`:""}var v3=[{slot:"lt1",name:"Background 1"},{slot:"dk1",name:"Text 1"},{slot:"lt2",name:"Background 2"},{slot:"dk2",name:"Text 2"},{slot:"accent1",name:"Accent 1"},{slot:"accent2",name:"Accent 2"},{slot:"accent3",name:"Accent 3"},{slot:"accent4",name:"Accent 4"},{slot:"accent5",name:"Accent 5"},{slot:"accent6",name:"Accent 6"}],C3=[{type:"base",keep:1,labelSuffix:""},{type:"tint",keep:.2,labelSuffix:", Lighter 80%"},{type:"tint",keep:.4,labelSuffix:", Lighter 60%"},{type:"tint",keep:.6,labelSuffix:", Lighter 40%"},{type:"shade",keep:.75,labelSuffix:", Darker 25%"},{type:"shade",keep:.5,labelSuffix:", Darker 50%"}];function bT(e){let t=e??bd;return C3.map(o=>v3.map(n=>{let r=t[n.slot]??bd[n.slot]??"000000",a={hex:o.type==="base"?r.toUpperCase():o.type==="tint"?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 S3=cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-9 w-9","icon-sm":"h-7 w-7"}},defaultVariants:{variant:"default",size:"default"}}),it=Zt.forwardRef(({className:e,variant:t,size:o,...n},r)=>jsx("button",{className:ue(S3({variant:t,size:o,className:e})),ref:r,...n}));it.displayName="Button";function Yt({content:e,children:t,side:o="bottom",delayMs:n=400}){let[r,i]=Zt.useState(false),[a,l]=Zt.useState({x:0,y:0}),s=Zt.useRef(null),c=Zt.useRef(null),d=Zt.useCallback(()=>{let p=hostWindowOf(s.current),f=p.setTimeout(()=>{if(s.current){let b=s.current.getBoundingClientRect(),y=b.left+b.width/2,v=o==="top"?b.top-8:b.bottom+8;l({x:y,y:v});}i(true);},n);c.current={win:p,handle:f};},[n,o]),m=Zt.useCallback(()=>{c.current&&(c.current.win.clearTimeout(c.current.handle),c.current=null),i(false);},[]);Zt.useEffect(()=>()=>{c.current&&c.current.win.clearTimeout(c.current.handle);},[]);let u=t.props,g=Zt.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 Xf=Zt.createContext(null);function _n(e){let[t,o]=Zt.useState(null),n=Zt.useMemo(()=>({trigger:t,setTrigger:o}),[t]);return jsx(Xf.Provider,{value:n,children:jsx(Ae.Root,{...e})})}var In=Ae.Group,hd=Ae.Value;function Nn({className:e,children:t,onMouseDown:o,...n}){let r=Zt.useContext(Xf)?.setTrigger;return jsxs(Ae.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(Ae.Icon,{asChild:true,children:jsx(N3,{className:"h-4 w-4 text-muted-foreground shrink-0"})})]})}function Fn({className:e,children:t,position:o="popper",onCloseAutoFocus:n,onKeyDown:r,...i}){let a=Zt.useContext(Xf)?.trigger??null,l=typeof globalThis.document>"u"&&!a?null:hostDocumentOf(a),c=Ut()||!!a?.closest(".docx-editor.dark");return jsx(Ae.Portal,{...l?.body?{container:l.body}:{},children:jsx("div",{className:ue("docx-editor",c&&"dark"),children:jsx(Ae.Content,{className:ue("relative z-50 max-h-72 min-w-[8rem] overflow-hidden","rounded-lg border border-border bg-popover text-popover-foreground shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",e),position:o,onCloseAutoFocus:d=>{d.preventDefault(),n?.(d);},onKeyDown:d=>{r?.(d),d.defaultPrevented||I3(d);},...i,children:jsx(Ae.Viewport,{className:ue("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),onMouseDown:d=>d.preventDefault(),children:t})})})})}var _3=new Set(["ArrowDown","ArrowUp","Home","End"]);function I3(e){let t=e.currentTarget;if(t.ownerDocument===globalThis.document||!_3.has(e.key))return;e.preventDefault();let o=Array.from(t.querySelectorAll('[role="option"]:not([data-disabled])'));if(o.length===0)return;let n=o.indexOf(t.ownerDocument.activeElement),r=n>=0?n:o.findIndex(a=>a.dataset.state==="checked"),i=e.key==="Home"?0:e.key==="End"?o.length-1:e.key==="ArrowDown"?Math.min(o.length-1,r+1):Math.max(0,r<0?0:r-1);o[i].focus({preventScroll:false});}function vr({className:e,...t}){return jsx(Ae.Label,{className:ue("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t})}function Xt({className:e,children:t,onMouseDown:o,...n}){return jsxs(Ae.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(Ae.ItemText,{children:t}),jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:jsx(Ae.ItemIndicator,{children:jsx(F3,{className:"h-4 w-4"})})})]})}function Cr({className:e,...t}){return jsx(Ae.Separator,{className:ue("-mx-1 my-1 h-px bg-muted",e),...t})}function N3({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 F3({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 Jf(e){let t=e.trim();if(!t)return "";let o=null,n="";for(let r of t){if((r==='"'||r==="'")&&o===null){o=r,n+=r;continue}if(r===o){o=null,n+=r;continue}if(r===","&&o===null)break;n+=r;}return n.trim().replace(/^['"]|['"]$/g,"")}var L3=[{name:"Arial",fontFamily:"Arial, Helvetica, sans-serif",category:"sans-serif"},{name:"Calibri",fontFamily:'"Calibri", Arial, sans-serif',category:"sans-serif"},{name:"Helvetica",fontFamily:"Helvetica, Arial, sans-serif",category:"sans-serif"},{name:"Verdana",fontFamily:"Verdana, Geneva, sans-serif",category:"sans-serif"},{name:"Open Sans",fontFamily:'"Open Sans", sans-serif',category:"sans-serif"},{name:"Roboto",fontFamily:"Roboto, sans-serif",category:"sans-serif"},{name:"Times New Roman",fontFamily:'"Times New Roman", Times, serif',category:"serif"},{name:"Georgia",fontFamily:"Georgia, serif",category:"serif"},{name:"Cambria",fontFamily:"Cambria, Georgia, serif",category:"serif"},{name:"Garamond",fontFamily:"Garamond, serif",category:"serif"},{name:"Courier New",fontFamily:'"Courier New", Courier, monospace',category:"monospace"},{name:"Consolas",fontFamily:"Consolas, monospace",category:"monospace"}];function xT({value:e,onChange:t,fonts:o=L3,documentFonts:n,disabled:r=false,className:i,placeholder:a="Arial",width:l=120,showPreview:s=true}){let{t:c}=H(),d=Zt.useMemo(()=>{if(!n)return [];let f=new Set(o.map(b=>b.name.toLowerCase()));return n.filter(b=>!f.has(b.name.toLowerCase()))},[n,o]),m=Zt.useMemo(()=>[...d,...o],[d,o]),u=Zt.useMemo(()=>e?m.find(b=>b.fontFamily===e||b.name.toLowerCase()===e.toLowerCase()||Jf(b.fontFamily).toLowerCase()===e.toLowerCase())?.name||e:a,[e,m,a]),g=Zt.useCallback(f=>{let b=m.find(y=>y.name===f);b&&t?.(Jf(b.fontFamily)||b.name);},[t,m]),p=Zt.useMemo(()=>{let f={"sans-serif":[],serif:[],monospace:[],other:[]};return o.forEach(b=>{let y=b.category||"other";f[y].push(b);}),f},[o]);return jsxs(_n,{value:u,onValueChange:g,disabled:r,children:[jsx(Nn,{className:ue("h-8 text-sm",i),style:{minWidth:typeof l=="number"?`${l}px`:l},"aria-label":c("font.selectAriaLabel"),children:jsx(hd,{placeholder:a,children:u})}),jsxs(Fn,{className:"max-h-[300px]",children:[d.length>0&&jsxs(Fragment,{children:[jsxs(In,{children:[jsx(vr,{children:c("font.documentFonts")}),d.map(f=>jsx(Xt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},`doc-${f.name}`))]}),jsx(Cr,{})]}),p["sans-serif"].length>0&&jsxs(In,{children:[jsx(vr,{children:c("font.sansSerif")}),p["sans-serif"].map(f=>jsx(Xt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]}),p.serif.length>0&&jsxs(Fragment,{children:[jsx(Cr,{}),jsxs(In,{children:[jsx(vr,{children:c("font.serif")}),p.serif.map(f=>jsx(Xt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.monospace.length>0&&jsxs(Fragment,{children:[jsx(Cr,{}),jsxs(In,{children:[jsx(vr,{children:c("font.monospace")}),p.monospace.map(f=>jsx(Xt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))]})]}),p.other.length>0&&jsxs(Fragment,{children:[jsx(Cr,{}),jsx(In,{children:p.other.map(f=>jsx(Xt,{value:f.name,style:s?{fontFamily:f.fontFamily}:void 0,children:f.name},f.name))})]})]})]})}function Qf(e){if(e===void 0)return;let t=e.map(o=>typeof o=="string"?{name:o,fontFamily:o,category:"other"}:o);if(xt()){let o=new Set,n=new Set;for(let r of t)n.has(r.name)&&!o.has(r.name)&&(console.warn(`[DocxEditor] Duplicate font name in fontFamilies: "${r.name}"`),o.add(r.name)),n.add(r.name);}return t}function Z3(e,t,o,n,r){let a=Math.max(8,e.innerWidth-n-8),l=Math.max(8,e.innerHeight-r-8);return {top:Math.min(Math.max(8,t),l),left:Math.min(Math.max(8,o),a)}}function Ft({isOpen:e,onClose:t,align:o="left"}){let n=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=Z3(d,c.bottom+4,c.right-m.width,m.width,m.height);a(u);}else a({top:c.bottom+4,left:c.left});});}else a({top:c.bottom+4,left:c.left});},[e,o]),useEffect(()=>{if(!e)return;let c=performance.now()+150,d=f=>{f.key==="Escape"&&t();},m=f=>{if(performance.now()<c)return;let b=f.target;b&&r.current&&r.current.contains(b)||isElementNode(b)&&b!==b.ownerDocument.documentElement&&b!==b.ownerDocument.body&&n.current&&b.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 $3=[8,9,10,11,12,14,16,18,20,24,28,36,48,72],z3=1,V3=400;function ET(e,t,o){for(let n of t)if(n>e)return n;return Math.min(e+1,o)}function ST(e,t,o){for(let n=t.length-1;n>=0;n--)if(t[n]<e)return t[n];return Math.max(e-1,o)}function PT({value:e,onChange:t,sizes:o=$3,disabled:n=false,className:r,placeholder:i="11",minSize:a=z3,maxSize:l=V3}){let{t:s}=H(),[c,d]=useState(false),[m,u]=useState(""),[g,p]=useState(false),f=useRef(null),b=useCallback(()=>{p(false),d(false);},[]),{containerRef:y,dropdownRef:v,dropdownStyle:x}=Ft({isOpen:g,onClose:b}),h=e??(parseInt(i,10)||11),k=e!==void 0?e.toString():i,E=useCallback(N=>{if(N.preventDefault(),n)return;let B=ST(h,o,a);t?.(B);},[h,o,a,n,t]),C=useCallback(N=>{if(N.preventDefault(),n)return;let B=ET(h,o,l);t?.(B);},[h,o,l,n,t]),T=useCallback(N=>{N.preventDefault(),!n&&(d(true),u(k),p(true),hostWindowOf(f.current).requestAnimationFrame(()=>{f.current?.focus(),f.current?.select();}));},[n,k]),S=useCallback(N=>{u(N.target.value);},[]),P=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(),P(),p(false);else if(N.key==="Escape")d(false),p(false);else if(N.key==="ArrowUp"){N.preventDefault();let B=ET(h,o,l);u(B.toString()),t?.(B);}else if(N.key==="ArrowDown"){N.preventDefault();let B=ST(h,o,a);u(B.toString()),t?.(B);}},[P,h,o,l,a,t]),_=useCallback(N=>{t?.(N),p(false),d(false);},[t]),L=useCallback(N=>{N.target.tagName!=="INPUT"&&N.preventDefault();},[]);return jsxs("div",{ref:y,className:ue("flex items-center",r),onMouseDown:L,children:[jsx(it,{variant:"ghost",size:"icon-sm",className:ue("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:E,disabled:n||h<=a,"aria-label":s("fontSize.decrease"),"data-testid":"font-size-decrease",children:jsx(G,{name:"remove",size:18})}),jsx("div",{className:"relative",children:c?jsx("input",{ref:f,type:"text",value:m,onChange:S,onBlur:P,onKeyDown:w,className:ue("h-7 w-10 text-center text-sm border border-input bg-doc-bg-input text-doc-text","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none"),"aria-label":s("fontSize.label"),"data-testid":"font-size-input"}):jsx("button",{type:"button",onClick:T,className:ue("h-7 w-10 text-center text-sm border border-border bg-doc-bg-input text-doc-text","hover:border-input hover:bg-doc-bg-hover","focus:outline-none focus:ring-1 focus:ring-ring","rounded-none",n&&"opacity-50 cursor-not-allowed"),disabled:n,"aria-label":s("fontSize.label"),"aria-haspopup":"listbox","aria-expanded":g,"data-testid":"font-size-display",children:k})}),g&&jsx("div",{ref:v,style:{...x,backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border)",borderRadius:6,boxShadow:"0 4px 12px var(--doc-shadow)",maxHeight:240,overflowY:"auto",minWidth:60},role:"listbox","aria-label":s("fontSize.listLabel"),children:o.map(N=>jsx("button",{type:"button",onClick:()=>_(N),className:ue("w-full px-3 py-1.5 text-sm text-left","hover:bg-muted",N===h&&"bg-muted font-medium"),role:"option","aria-selected":N===h,children:N},N))}),jsx(it,{variant:"ghost",size:"icon-sm",className:ue("h-7 w-7 text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",n&&"opacity-30 cursor-not-allowed"),onMouseDown:C,disabled:n||h>=l,"aria-label":s("fontSize.increase"),"data-testid":"font-size-increase",children:jsx(G,{name:"add",size:18})})]})}var Y3=[{name:"Dark Red",nameKey:"colorPicker.colors.darkRed",hex:"C00000"},{name:"Red",nameKey:"colorPicker.colors.red",hex:"FF0000"},{name:"Orange",nameKey:"colorPicker.colors.orange",hex:"FFC000"},{name:"Yellow",nameKey:"colorPicker.colors.yellow",hex:"FFFF00"},{name:"Light Green",nameKey:"colorPicker.colors.lightGreen",hex:"92D050"},{name:"Green",nameKey:"colorPicker.colors.green",hex:"00B050"},{name:"Light Blue",nameKey:"colorPicker.colors.lightBlue",hex:"00B0F0"},{name:"Blue",nameKey:"colorPicker.colors.blue",hex:"0070C0"},{name:"Dark Blue",nameKey:"colorPicker.colors.darkBlue",hex:"002060"},{name:"Purple",nameKey:"colorPicker.colors.purple",hex:"7030A0"}],xd=18,X3=2,J3={position:"relative",display:"inline-block"},Q3={display:"flex",alignItems:"center",justifyContent:"center",width:"40px",height:"32px",padding:"2px 6px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},eH={padding:"10px",backgroundColor:"var(--doc-surface)",border:"1px solid var(--doc-border-dark)",borderRadius:"6px",boxShadow:"0 4px 16px var(--doc-shadow)",width:"auto"},og={fontSize:"11px",color:"var(--doc-text-muted)",marginBottom:"4px",fontWeight:500},ng={height:"1px",backgroundColor:"var(--doc-border)",margin:"8px 0"},DT={display:"grid",gap:`${X3}px`},vd={width:`${xd}px`,height:`${xd}px`,border:"1px solid var(--doc-border-input)",borderRadius:"2px",cursor:"pointer",padding:0,transition:"transform 0.1s, border-color 0.1s"},RT={...vd,transform:"scale(1.15)",borderColor:"var(--doc-text)",zIndex:1},MT={...vd,borderWidth:"2px",borderColor:"var(--doc-primary)",boxShadow:"0 0 0 1px var(--doc-primary)"},tH={display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"5px 8px",border:"1px solid var(--doc-border-dark)",borderRadius:"4px",backgroundColor:"var(--doc-surface)",cursor:"pointer",fontSize:"12px",color:"var(--doc-text)"},oH={display:"flex",alignItems:"center",gap:"6px"},nH={width:"70px",height:"24px",padding:"2px 6px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",fontSize:"12px"},rH={height:"24px",padding:"0 10px",border:"1px solid var(--doc-border-input)",borderRadius:"3px",backgroundColor:"var(--doc-bg-subtle)",fontSize:"12px",cursor:"pointer"},kT={width:"16px",height:"4px",borderRadius:"1px",marginTop:"-2px"},aH={display:"inline-flex",alignItems:"stretch",height:"32px",gap:"2px"},iH={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:0,width:"28px",padding:"2px 4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},lH={display:"flex",alignItems:"center",justifyContent:"center",width:"18px",padding:0,border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"};function rg(e,t,o){if(!e)return t==="text"||t==="border"?"#000000":"transparent";if(typeof e=="string"){if(t==="highlight"){let n=gT(e);return n||(e==="none"?"transparent":e.startsWith("#")?e:`#${e}`)}return e.startsWith("#")?e:`#${e}`}return Yf(e,o)}function wT(e){let t=e.replace(/^#/,"");if(t.length!==6)return false;let o=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return (o*299+n*587+r*114)/1e3>230}function _T(e,t,o){return e?(typeof e=="string"?e.replace(/^#/,"").toUpperCase():tn(e,o))===t.toUpperCase():false}function sH({matrix:e,selectedColor:t,theme:o,onSelect:n}){let[r,i]=useState(null);return jsx("div",{style:{...DT,gridTemplateColumns:`repeat(10, ${xd}px)`},children:e.flatMap((a,l)=>a.map((s,c)=>{let d=`${l}-${c}`,m=r===d,u=_T(t,s.hex,o);return jsx("button",{type:"button",style:{...u?MT:m?RT:vd,backgroundColor:`#${s.hex}`},title:s.label,"aria-label":s.label,"aria-selected":u,onClick:()=>n(s),onMouseDown:g=>g.preventDefault(),onMouseEnter:()=>i(d),onMouseLeave:()=>i(null)},d)}))})}function cH({selectedColor:e,theme:t,onSelect:o}){let[n,r]=useState(null),{t:i}=H();return jsx("div",{style:{...DT,gridTemplateColumns:`repeat(10, ${xd}px)`},children:Y3.map((a,l)=>{let s=n===l,c=_T(e,a.hex,t),d=i(a.nameKey);return jsx("button",{type:"button",style:{...c?MT:s?RT:vd,backgroundColor:`#${a.hex}`},title:d,"aria-label":d,"aria-selected":c,onClick:()=>o(a.hex),onMouseDown:m=>m.preventDefault(),onMouseEnter:()=>r(l),onMouseLeave:()=>r(null)},a.hex)})})}function Sr({mode:e,value:t,onChange:o,theme:n,disabled:r=false,className:i,style:a,title:l,icon:s,autoLabel:c,splitButton:d=true,defaultColor:m}){let[u,g]=useState(false),[p,f]=useState(false),[b,y]=useState(false),[v,x]=useState(false),[h,k]=useState(""),[E,C]=useState(()=>m??(e==="highlight"?"FFFF00":e==="border"?{kind:"hex",value:"000000"}:{kind:"hex",value:"FF0000"})),{t:T}=H();useEffect(()=>{let O=rg(t,e,n).replace(/^#/,"");/^[0-9A-Fa-f]{6}$/.test(O)&&k(O.toUpperCase());},[t,e,n]);let S=useCallback(()=>g(false),[]),{containerRef:P,dropdownRef:w,dropdownStyle:_}=Ft({isOpen:u,onClose:S}),L=n?.colorScheme??null,N=useMemo(()=>bT(L),[L]),B=useMemo(()=>rg(t,e,n),[t,e,n]),F=useMemo(()=>rg(E,e,n),[E,e,n]),D=useCallback(()=>{r||g(O=>!O);},[r]),R=useCallback(O=>{let I;e==="highlight"?I=O.hex:I={kind:"theme",slot:O.themeSlot,...O.tint!==void 0?{tint:O.tint}:{},...O.shade!==void 0?{shade:O.shade}:{}},C(I),o?.(I),g(false);},[e,o]),U=useCallback(O=>{let I=e==="highlight"?O:{kind:"hex",value:O};C(I),o?.(I),g(false);},[e,o]),V=useCallback(()=>{o?.(e==="highlight"?"none":{kind:"auto"}),g(false);},[e,o]),Y=useCallback(()=>{let O=h.replace(/^#/,"").toUpperCase();if(/^[0-9A-F]{6}$/i.test(O)){let I=e==="highlight"?O:{kind:"hex",value:O};C(I),o?.(I),g(false),k("");}},[e,h,o]),j=useCallback(()=>{r||o?.(E);},[r,E,o]),q={...Q3,...r?{cursor:"default",opacity:.38}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:p?{backgroundColor:"var(--doc-bg-hover)"}:{}},X=T(e==="text"?"formattingBar.fontColor":e==="highlight"?"formattingBar.highlightColor":"table.borderColor"),ee=s??(e==="text"?"format_color_text":e==="highlight"?"ink_highlighter":"border_color");return jsxs("div",{ref:P,className:`docx-color-picker ${i||""}`,style:{...J3,...a},children:[d?jsxs("div",{className:"docx-color-picker-split",style:{...aH,...r?{opacity:.38,cursor:"default"}:null},children:[jsxs("button",{type:"button",className:"docx-color-picker-apply",style:{...iH,...r?{cursor:"default"}:b?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:j,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>y(true),onMouseLeave:()=>y(false),disabled:r,title:l||X,"aria-label":l||X,children:[jsx(G,{name:ee,size:18}),jsx("div",{style:{...kT,backgroundColor:F==="transparent"?"#fff":F,outline:F==="transparent"||wT(F)?"1px solid #bbb":"none"}})]}),jsx("button",{type:"button",className:"docx-color-picker-arrow",style:{...lH,...r?{cursor:"default"}:u?{backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"}:v?{backgroundColor:"var(--doc-bg-hover)"}:null},onClick:D,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>x(true),onMouseLeave:()=>x(false),disabled:r,title:l||X,"aria-label":l||X,"aria-haspopup":"true","aria-expanded":u,children:jsx(G,{name:"arrow_drop_down",size:18})})]}):jsxs("button",{type:"button",className:"docx-color-picker-button",style:q,onClick:D,onMouseDown:O=>O.preventDefault(),onMouseEnter:()=>f(true),onMouseLeave:()=>f(false),disabled:r,title:l||X,"aria-label":l||X,"aria-haspopup":"true","aria-expanded":u,children:[jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0},children:[jsx(G,{name:ee,size:18}),jsx("div",{style:{...kT,backgroundColor:B==="transparent"?"#fff":B,outline:B==="transparent"||wT(B)?"1px solid #bbb":"none"}})]}),jsx(G,{name:"arrow_drop_down",size:14})]}),u&&jsx("div",{ref:w,className:"docx-color-picker-dropdown",style:{..._,...eH},role:"dialog","aria-label":`${X} picker`,onMouseDown:O=>{O.target.tagName!=="INPUT"&&O.preventDefault();},children:jsxs(Fragment,{children:[jsxs("button",{type:"button",style:tH,onClick:V,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??T(e==="highlight"?"colorPicker.noColor":"colorPicker.automatic")]}),jsx("div",{style:ng}),jsx("div",{style:og,children:T("colorPicker.themeColors")}),jsx(sH,{matrix:N,selectedColor:t,theme:n,onSelect:R}),jsx("div",{style:ng}),jsx("div",{style:og,children:T("colorPicker.standardColors")}),jsx(cH,{selectedColor:t,theme:n,onSelect:U}),jsx("div",{style:ng}),jsx("div",{style:og,children:T("colorPicker.customColor")}),jsxs("div",{style:oH,children:[jsx("span",{style:{fontSize:"12px",color:"var(--doc-text-muted)"},children:"#"}),jsx("input",{type:"text",style:nH,value:h,onChange:O=>k(O.target.value.replace(/[^0-9A-Fa-f]/g,"").slice(0,6)),onKeyDown:O=>{O.key==="Enter"&&Y();},onMouseDown:O=>{O.stopPropagation();},placeholder:"FF0000",maxLength:6,"aria-label":"Custom hex color"}),jsx("button",{type:"button",style:{...rH,opacity:/^[0-9A-Fa-f]{6}$/.test(h)?1:.4,cursor:/^[0-9A-Fa-f]{6}$/.test(h)?"pointer":"default"},onClick:Y,onMouseDown:O=>O.preventDefault(),disabled:!/^[0-9A-Fa-f]{6}$/.test(h),children:T("common.apply")})]})]})})]})}var Ll=20,ag=[{value:"left",label:"Align Left",labelKey:"alignment.alignLeft",shortcutKey:"alignment.alignLeftShortcut",icon:jsx(G,{name:"format_align_left",size:Ll}),iconName:"format_align_left",shortcut:"Ctrl+L"},{value:"center",label:"Center",labelKey:"alignment.center",shortcutKey:"alignment.centerShortcut",icon:jsx(G,{name:"format_align_center",size:Ll}),iconName:"format_align_center",shortcut:"Ctrl+E"},{value:"right",label:"Align Right",labelKey:"alignment.alignRight",shortcutKey:"alignment.alignRightShortcut",icon:jsx(G,{name:"format_align_right",size:Ll}),iconName:"format_align_right",shortcut:"Ctrl+R"},{value:"both",label:"Justify",labelKey:"alignment.justify",shortcutKey:"alignment.justifyShortcut",icon:jsx(G,{name:"format_align_justify",size:Ll}),iconName:"format_align_justify",shortcut:"Ctrl+J"}];function FT({value:e="left",onChange:t,disabled:o=false}){let{t:n}=H(),[r,i]=useState(false),a=useCallback(()=>i(false),[]),{containerRef:l,dropdownRef:s,dropdownStyle:c,handleMouseDown:d}=Ft({isOpen:r,onClose:a}),m=useCallback(y=>{o||t?.(y),i(false);},[o,t]),u=ag.find(y=>y.value===e)||ag[0],g=n(u.labelKey),p=u.shortcutKey?n(u.shortcutKey):void 0,f=`${g}${p?` (${p})`:""}`,b=jsxs(it,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",o&&"opacity-30 cursor-not-allowed"),onMouseDown:d,onClick:()=>!o&&i(y=>!y),disabled:o,"aria-label":f,"aria-expanded":r,"aria-haspopup":"true","data-testid":"toolbar-alignment",children:[jsx(G,{name:u.iconName,size:Ll}),jsx(G,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[r?b:jsx(Yt,{content:f,children:b}),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:y=>y.stopPropagation(),children:jsx("div",{style:{display:"flex",gap:2},children:ag.map(y=>{let v=e===y.value,x=n(y.labelKey),h=y.shortcutKey?n(y.shortcutKey):void 0;return jsx("button",{type:"button",title:`${x}${h?` (${h})`:""}`,"data-testid":`alignment-${y.value}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:v?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:v?"var(--doc-primary)":"var(--doc-text)"},onMouseDown:k=>k.preventDefault(),onMouseEnter:k=>{v||(k.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:k=>{k.currentTarget.style.backgroundColor=v?"var(--doc-primary-light)":"transparent";},onClick:()=>m(y.value),children:jsx(G,{name:y.iconName,size:18})},y.value)})})})]})}function Cd(){return {type:"none",level:0,isInList:false}}var fH={display:"inline-flex",alignItems:"center",gap:"4px"},LT={display:"inline-flex",alignItems:"center",gap:"4px"},Pd={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",padding:"4px",border:"none",borderRadius:"4px",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 0.1s",color:"var(--doc-text-muted)"},gH={...Pd,backgroundColor:"var(--doc-bg-hover)"},bH={...Pd,backgroundColor:"var(--doc-primary-light)",color:"var(--doc-primary)"},hH={...Pd,cursor:"default",opacity:.38},yH={width:"28px",height:"28px",padding:"2px"},xH={width:"1px",height:"20px",backgroundColor:"var(--doc-border)",margin:"0 6px"},Td=20;function Ed({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,style:a}){let[l,s]=useState(false),c={...t?hH:e?bH:l?gH: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:n,onMouseEnter:()=>s(true),onMouseLeave:()=>s(false),"aria-disabled":t||void 0,tabIndex:t?-1:void 0,title:o,"aria-label":o,"aria-pressed":e,role:"button",children:r})}function HT({listState:e,onBulletList:t,onNumberedList:o,onIndent:n,onOutdent:r,disabled:i=false,className:a,style:l,showIndentButtons:s=true,compact:c=false,hasIndent:d=false}){let{t:m}=H(),u=useCallback(()=>c?{...yH}:{},[c]),g=e?.type==="bullet",p=e?.type==="numbered",b=(e?.isInList||g||p)&&(e?.level??0)>0||d;return jsxs("div",{className:`docx-list-buttons ${a||""}`,style:{...fH,...l},role:"group","aria-label":m("lists.ariaLabel"),children:[jsxs("div",{style:LT,role:"group","aria-label":m("lists.typeAriaLabel"),children:[jsx(Ed,{active:g,disabled:i,title:m("lists.bulletList"),onClick:t,style:u(),children:jsx(G,{name:"format_list_bulleted",size:Td})}),jsx(Ed,{active:p,disabled:i,title:m("lists.numberedList"),onClick:o,style:u(),children:jsx(G,{name:"format_list_numbered",size:Td})})]}),s&&jsxs(Fragment,{children:[jsx("div",{style:xH,role:"separator"}),jsxs("div",{style:LT,role:"group","aria-label":m("lists.indentationAriaLabel"),children:[jsx(Ed,{active:false,disabled:i||!b,title:m("lists.decreaseIndent"),onClick:r,style:u(),children:jsx(G,{name:"format_indent_decrease",size:Td})}),jsx(Ed,{active:false,disabled:i,title:m("lists.increaseIndent"),onClick:n,style:u(),children:jsx(G,{name:"format_indent_increase",size:Td})})]})]})]})}var CH=[{label:"Single",labelKey:"lineSpacing.single",value:1,twipsValue:240},{label:"1.15",value:1.15,twipsValue:276},{label:"1.5",value:1.5,twipsValue:360},{label:"Double",labelKey:"lineSpacing.double",value:2,twipsValue:480}];function OT({value:e,onChange:t,options:o=CH,disabled:n=false,className:r}){let{t:i}=H(),a=Zt.useMemo(()=>e===void 0?o[0]:o.find(c=>c.twipsValue===e)||o[0],[e,o]),l=Zt.useCallback(c=>{let d=parseInt(c,10);isNaN(d)||t?.(d);},[t]),s=c=>c.labelKey?i(c.labelKey):c.label;return jsxs(_n,{value:a.twipsValue.toString(),onValueChange:l,disabled:n,children:[jsx(Nn,{className:ue("h-8 text-sm gap-0.5 px-2",r),style:{width:"auto"},"aria-label":i("lineSpacing.label"),title:i("lineSpacing.lineSpacingTitle",{label:s(a)}),children:jsx(Pf,{className:"h-5 w-5 shrink-0"})}),jsxs(Fn,{children:[o.map(c=>jsx(Xt,{value:c.twipsValue.toString(),children:s(c)},c.twipsValue)),jsx(Cr,{}),jsx(In,{children:jsx(vr,{children:i("lineSpacing.blockSpacingRules")})})]})]})}var TH=[{styleId:"Normal",name:"Normal text",nameKey:"styles.normalText",type:"paragraph",isDefault:true,priority:0,qFormat:true,fontSize:22},{styleId:"Title",name:"Title",nameKey:"styles.title",type:"paragraph",priority:1,qFormat:true,fontSize:52,bold:true},{styleId:"Subtitle",name:"Subtitle",nameKey:"styles.subtitle",type:"paragraph",priority:2,qFormat:true,fontSize:30,color:"666666"},{styleId:"Heading1",name:"Heading 1",nameKey:"styles.heading1",type:"paragraph",priority:3,qFormat:true,fontSize:40,bold:true},{styleId:"Heading2",name:"Heading 2",nameKey:"styles.heading2",type:"paragraph",priority:4,qFormat:true,fontSize:32,bold:true},{styleId:"Heading3",name:"Heading 3",nameKey:"styles.heading3",type:"paragraph",priority:5,qFormat:true,fontSize:28,bold:true}];function BT({value:e,onChange:t,styles:o,disabled:n=false,className:r,width:i=120}){let{t:a}=H(),l=Zt.useMemo(()=>{let g=wx(o);return g.length===0?TH:g.map(p=>{let f=vc(p.name);if(!f)return {...p,type:"paragraph"};let b=f.key==="styles.normal"?a("styles.normalText"):a(f.key,f.vars);return {...p,type:"paragraph",name:b}})},[o,a]),s=Zt.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(_n,{value:d,onValueChange:s,disabled:n,children:[jsx(Nn,{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(Fn,{className:"min-w-[260px] max-h-[400px]",children:l.map(g=>jsx(Xt,{value:g.styleId,className:"py-2.5 px-3",children:jsx("span",{style:Px(g),children:c(g)})},g.styleId))})]})}var SH=[{value:.5,label:"50%"},{value:.75,label:"75%"},{value:1,label:"100%"},{value:1.25,label:"125%"},{value:1.5,label:"150%"},{value:2,label:"200%"}];function ZT({value:e=1,onChange:t,levels:o=SH,disabled:n=false,className:r,compact:i=false}){let{t:a}=H(),l=Zt.useMemo(()=>{let g=o.find(p=>Math.abs(p.value-e)<.001);return g?g.label:`${Math.round(e*100)}%`},[o,e]),s=Zt.useCallback(g=>{let p=parseFloat(g);isNaN(p)||t?.(p);},[t]),c=Zt.useMemo(()=>[...o].sort((g,p)=>g.value-p.value),[o]),d=Zt.useMemo(()=>[...c].reverse().find(g=>g.value<e-.001),[c,e]),m=Zt.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(it,{variant:"ghost",size:"icon-sm",className:ue(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-r-none",(n||!d)&&"opacity-30 cursor-not-allowed"),onClick:()=>d&&t?.(d.value),disabled:n||!d,"aria-label":a("zoom.zoomOut"),children:jsx(G,{name:"remove",size:18})}),jsxs(_n,{value:e.toString(),onValueChange:s,disabled:n,children:[jsx(Nn,{className:ue(i?"h-7 min-w-[55px] text-xs":"h-8 min-w-[64px] text-sm","rounded-none",r),"aria-label":a("zoom.ariaLabel",{label:l}),children:jsx(hd,{placeholder:"100%",children:l})}),jsx(Fn,{children:o.map(g=>jsx(Xt,{value:g.value.toString(),children:g.label},g.value))})]}),jsx(it,{variant:"ghost",size:"icon-sm",className:ue(u,"text-muted-foreground hover:text-foreground hover:bg-muted/80 rounded-l-none",(n||!m)&&"opacity-30 cursor-not-allowed"),onClick:()=>m&&t?.(m.value),disabled:n||!m,"aria-label":a("zoom.zoomIn"),children:jsx(G,{name:"add",size:18})})]})}var kH=[{action:"borderAll",icon:"border_all",labelKey:"table.borders.all"},{action:"borderOutside",icon:"border_outer",labelKey:"table.borders.outside"},{action:"borderInside",icon:"border_inner",labelKey:"table.borders.inside"},{action:"borderTop",icon:"border_top",labelKey:"table.borders.top"},{action:"borderBottom",icon:"border_bottom",labelKey:"table.borders.bottom"},{action:"borderLeft",icon:"border_left",labelKey:"table.borders.left"},{action:"borderRight",icon:"border_right",labelKey:"table.borders.right"},{action:"borderNone",icon:"border_clear",labelKey:"table.borders.none"}];function UT({onAction:e,disabled:t=false}){let{t:o}=H(),[n,r]=useState(false),i=useCallback(()=>r(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=Ft({isOpen:n,onClose:i}),d=useCallback(u=>{e(u),r(false);},[e]),m=jsxs(it,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",n&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&r(u=>!u),disabled:t,"aria-label":o("table.borders.styleAriaLabel"),"aria-expanded":n,"aria-haspopup":"true","data-testid":"toolbar-table-borders",children:[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(Yt,{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:kH.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 $T({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=H(),i=useCallback(a=>{if(typeof a=="string"){e({type:"borderColor",color:a.replace(/^#/,"")});return}let l=a.kind==="auto"?"000000":tn(a,o);l&&e({type:"borderColor",color:l});},[e,o]);return jsx(Sr,{mode:"border",value:n,onChange:i,theme:o,disabled:t,title:r("table.borderColor")})}var MH=[{size:4,label:"0.5 pt",thickness:.5},{size:8,label:"1 pt",thickness:1},{size:12,label:"1.5 pt",thickness:1.5},{size:16,label:"2 pt",thickness:2},{size:24,label:"3 pt",thickness:3}];function VT({onAction:e,disabled:t=false}){let[o,n]=useState(false),{t:r}=H(),i=useCallback(()=>n(false),[]),{containerRef:a,dropdownRef:l,dropdownStyle:s,handleMouseDown:c}=Ft({isOpen:o,onClose:i}),d=useCallback(u=>{e({type:"borderWidth",size:u}),n(false);},[e]),m=jsxs(it,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",o&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:c,onClick:()=>!t&&n(u=>!u),disabled:t,"aria-label":r("table.borderWidth"),"aria-expanded":o,"aria-haspopup":"true","data-testid":"toolbar-table-border-width",children:[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(Yt,{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:MH.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 jT({onAction:e,disabled:t=false,theme:o,value:n}){let{t:r}=H(),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(Sr,{mode:"highlight",value:n,onChange:i,theme:o,disabled:t,title:r("table.cellFillColor"),icon:"format_color_fill",autoLabel:r("colorPicker.noColor")})})}var IH={display:"flex",alignItems:"center",gap:10,padding:"7px 14px",fontSize:13,color:"var(--doc-text)",cursor:"pointer",border:"none",backgroundColor:"transparent",width:"100%",textAlign:"left"},wr={height:1,backgroundColor:"var(--doc-border)",margin:"4px 0"},JT={padding:"6px 14px 2px",fontSize:11,color:"var(--doc-text-muted)",fontWeight:500};function QT({onAction:e,disabled:t=false,tableContext:o}){let{t:n}=H(),[r,i]=useState(false),[a,l]=useState(null),s=useCallback(()=>i(false),[]),{containerRef:c,dropdownRef:d,dropdownStyle:m,handleMouseDown:u}=Ft({isOpen:r,onClose:s,align:"right"}),g=o?.table?.attrs?.justification??"left",p=useCallback(y=>{e(y),i(false);},[e]),f=(y,v,x,h,k)=>{let E=t||k?.itemDisabled;return jsxs("button",{type:"button",role:"menuitem",style:{...IH,backgroundColor:a===y&&!E?"var(--doc-bg-hover)":"transparent",color:E?"var(--doc-text-muted)":k?.danger?"var(--doc-error)":"var(--doc-text)",cursor:E?"not-allowed":"pointer"},onClick:()=>!E&&p(h),onMouseEnter:()=>l(y),onMouseLeave:()=>l(null),disabled:E,children:[jsx(G,{name:v,size:16,className:k?.danger&&!E?"text-destructive":""}),jsx("span",{style:{flex:1},children:x})]},y)},b=jsx(it,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",r&&"bg-muted",t&&"opacity-30 cursor-not-allowed"),onMouseDown:u,onClick:()=>!t&&i(y=>!y),disabled:t,"aria-label":n("table.moreOptions"),"aria-expanded":r,"aria-haspopup":"menu","data-testid":"toolbar-table-more",children:jsx(G,{name:"more_vert",size:20})});return jsxs("div",{ref:c,style:{position:"relative",display:"inline-block"},children:[r?b:jsx(Yt,{content:n("table.moreOptions"),children:b}),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:y=>y.stopPropagation(),children:[f("addRowAbove","add",n("table.insertRowAbove"),"addRowAbove"),f("addRowBelow","add",n("table.insertRowBelow"),"addRowBelow"),f("addColumnLeft","add",n("table.insertColumnLeft"),"addColumnLeft"),f("addColumnRight","add",n("table.insertColumnRight"),"addColumnRight"),jsx("div",{style:wr,role:"separator"}),f("mergeCells","call_merge",n("table.mergeCells"),"mergeCells",{itemDisabled:!o?.hasMultiCellSelection}),f("splitCell","call_split",n("table.splitCell"),"splitCell",{itemDisabled:!o?.canSplitCell}),jsx("div",{style:wr,role:"separator"}),f("selectTable","select_all",n("table.selectTable"),"selectTable"),jsx("div",{style:wr,role:"separator"}),f("deleteRow","delete",n("table.deleteRow"),"deleteRow",{danger:true,itemDisabled:(o?.rowCount??0)<=1}),f("deleteColumn","delete",n("table.deleteColumn"),"deleteColumn",{danger:true,itemDisabled:(o?.columnCount??0)<=1}),f("deleteTable","delete",n("table.deleteTable"),"deleteTable",{danger:true}),jsx("div",{style:wr,role:"separator"}),jsx("div",{style:JT,children:n("tableAdvanced.verticalAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["top","center","bottom"].map(y=>{let v={top:"vertical_align_top",center:"vertical_align_center",bottom:"vertical_align_bottom"};return jsx("button",{type:"button",title:n({top:"tableAdvanced.top",center:"tableAdvanced.middle",bottom:"tableAdvanced.bottom"}[y]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:"transparent",cursor:"pointer"},onMouseDown:h=>h.preventDefault(),onMouseEnter:h=>{h.currentTarget.style.backgroundColor="var(--doc-bg-hover)";},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent";},onClick:()=>p({type:"cellVerticalAlign",align:y}),children:jsx(G,{name:v[y],size:16})},y)})}),jsx("div",{style:wr,role:"separator"}),jsx("div",{style:JT,children:n("tableAdvanced.tableAlignment")}),jsx("div",{style:{display:"flex",gap:4,padding:"4px 14px"},children:["left","center","right"].map(y=>{let v={left:"format_align_left",center:"format_align_center",right:"format_align_right"},x=g===y;return jsx("button",{type:"button",title:n({left:"tableAdvanced.alignTableLeft",center:"tableAdvanced.alignTableCenter",right:"tableAdvanced.alignTableRight"}[y]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:28,border:"1px solid var(--doc-border)",borderRadius:4,backgroundColor:x?"var(--doc-primary-light)":"transparent",borderColor:x?"var(--doc-primary)":"var(--doc-border)",color:x?"var(--doc-primary)":"var(--doc-text)",cursor:"pointer"},onMouseDown:h=>h.preventDefault(),onClick:()=>p({type:"tableProperties",props:{justification:y}}),children:jsx(G,{name:v[y],size:16})},y)})}),jsx("div",{style:wr,role:"separator"}),f("headerRow","table_rows",n("tableAdvanced.toggleHeaderRow"),{type:"toggleHeaderRow"}),f("distribute","view_column",n("tableAdvanced.distributeColumns"),{type:"distributeColumns"}),f("autoFit","fit_width",n("tableAdvanced.autoFit"),{type:"autoFitContents"}),f("noWrap","wrap_text",n("tableAdvanced.toggleNoWrap"),{type:"toggleNoWrap"}),jsx("div",{style:wr,role:"separator"}),f("properties","settings",n("tableAdvanced.tableProperties"),{type:"openTableProperties"})]})]})}var FH=20;function Dd({options:e,activeValue:t,triggerIcon:o,tooltipContent:n,onSelect:r,disabled:i=false,ariaLabel:a,testId:l,showLabels:s=false}){let[c,d]=useState(false),m=useCallback(()=>d(false),[]),{containerRef:u,dropdownRef:g,dropdownStyle:p,handleMouseDown:f}=Ft({isOpen:c,onClose:m}),b=useCallback(v=>{i||r(v),d(false);},[i,r]),y=jsxs(it,{variant:"ghost",size:"icon-sm",className:ue("text-muted-foreground hover:text-foreground hover:bg-muted/80",c&&"bg-muted",i&&"opacity-30 cursor-not-allowed"),onMouseDown:f,onClick:()=>!i&&d(v=>!v),disabled:i,"aria-label":a??n,"aria-expanded":c,"aria-haspopup":"true","data-testid":l,children:[jsx(G,{name:o,size:FH}),jsx(G,{name:"arrow_drop_down",size:14,className:"-ml-1"})]});return jsxs("div",{ref:u,style:{position:"relative",display:"inline-block"},children:[c?y:jsx(Yt,{content:n,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:v=>v.stopPropagation(),children:jsx("div",{style:{display:"flex",flexDirection:s?"column":"row",gap:s?1:2,minWidth:s?200:void 0},children:e.map(v=>{let x=t===v.value;return jsxs("button",{type:"button",title:v.label,"data-testid":l?`${l}-${v.value}`:void 0,style:{display:"flex",alignItems:"center",height:32,border:"1px solid transparent",borderRadius:4,backgroundColor:x?"var(--doc-primary-light)":"transparent",cursor:"pointer",color:x?"var(--doc-primary)":"var(--doc-text)",...s?{width:"100%",gap:10,padding:"0 10px",justifyContent:"flex-start",fontSize:13,textAlign:"left"}:{width:32,justifyContent:"center"}},onMouseDown:h=>h.preventDefault(),onMouseEnter:h=>{x||(h.currentTarget.style.backgroundColor="var(--doc-bg-hover)");},onMouseLeave:h=>{h.currentTarget.style.backgroundColor=x?"var(--doc-primary-light)":"transparent";},onClick:()=>b(v.value),children:[jsx(G,{name:v.iconName,size:18}),s&&jsx("span",{style:{flex:1},children:v.label})]},v.value)})})})]})}var LH=[{value:"inline",labelKey:"imageWrap.inline",iconName:"wrap_text"},{value:"wrapRight",labelKey:"imageWrap.floatLeft",iconName:"format_image_left"},{value:"wrapLeft",labelKey:"imageWrap.floatRight",iconName:"format_image_right"},{value:"behind",labelKey:"imageWrap.behindText",iconName:"flip_to_back"},{value:"inFront",labelKey:"imageWrap.inFrontOfText",iconName:"flip_to_front"}];function HH(e){return e.displayMode==="float"&&e.cssFloat==="left"?"wrapRight":e.displayMode==="float"&&e.cssFloat==="right"?"wrapLeft":e.wrapType}function tE({imageContext:e,onChange:t,disabled:o=false}){let{t:n}=H(),r=LH.map(l=>({...l,label:n(l.labelKey)})),i=HH(e),a=r.find(l=>l.value===i)||r[0];return jsx(Dd,{options:r,activeValue:i,triggerIcon:a.iconName,tooltipContent:`Wrap: ${a.label}`,onSelect:t,disabled:o,testId:"toolbar-image-wrap",showLabels:true})}var OH=[{value:"rotateCW",labelKey:"imageTransform.rotateClockwise",iconName:"rotate_right"},{value:"rotateCCW",labelKey:"imageTransform.rotateCounterClockwise",iconName:"rotate_left"},{value:"flipH",labelKey:"imageTransform.flipHorizontal",iconName:"swap_horiz"},{value:"flipV",labelKey:"imageTransform.flipVertical",iconName:"swap_vert"}];function oE({onTransform:e,disabled:t=false}){let{t:o}=H(),n=OH.map(r=>({...r,label:o(r.labelKey)}));return jsx(Dd,{options:n,triggerIcon:"rotate_right",tooltipContent:o("imageTransform.tooltip"),onSelect:e,disabled:t,testId:"toolbar-image-transform"})}var bo=18;function Jt({active:e=false,disabled:t=false,title:o,onClick:n,children:r,className:i,ariaLabel:a}){let l=a?.toLowerCase().replace(/\s+/g,"-")||o?.toLowerCase().replace(/\s+/g,"-").replace(/\([^()]*\)/g,"").trim(),s=d=>{d.preventDefault();},c=jsx(it,{variant:"ghost",size:"icon-sm",className:ue("docx-editor-toolbar-toggle text-muted-foreground",t&&"opacity-30 cursor-not-allowed",i),"data-active":e?"true":void 0,onMouseDown:s,onClick:t?void 0:n,"aria-disabled":t||void 0,tabIndex:t?-1:void 0,"aria-pressed":!!e,"aria-label":a||o,"data-testid":l?`toolbar-${l}`:void 0,children:r});return o?jsx(Yt,{content:o,children:c}):c}function ho({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 qH(e){let t=Zt__default.useContext(Il);return t?{...t,...UH(e)}:e}function UH(e){let t={};for(let o of Object.keys(e))e[o]!==void 0&&(t[o]=e[o]);return t}function dg(e){let{t}=H(),o=qH(e),{currentFormatting:n={},onFormat:r,onUndo:i,onRedo:a,canUndo:l=false,canRedo:s=false,disabled:c=false,className:d,style:m,enableShortcuts:u=true,editorRef:g,children:p,showFontPicker:f=true,fontFamilies:b,documentFonts:y,showFontSizePicker:v=true,showTextColorPicker:x=true,showHighlightColorPicker:h=true,showAlignmentButtons:k=true,showListButtons:E=true,showLineSpacingPicker:C=true,showStylePicker:T=true,documentStyles:S,theme:P,showZoomControl:w=true,zoom:_,onZoomChange:L,onRefocusEditor:N,imageContext:B,onImageWrapType:F,onImageTransform:D,onOpenImageProperties:R,tableContext:U,onTableAction:V,inline:Y=false}=o,j=useRef(null),q=useCallback(se=>{!c&&r&&r(se);},[c,r]),X=useCallback(()=>{!c&&l&&i&&i();},[c,l,i]),ee=useCallback(()=>{!c&&s&&a&&a();},[c,s,a]),O=useCallback(se=>{!c&&r&&r({type:"fontFamily",value:se});},[c,r]),I=Zt__default.useMemo(()=>Qf(b),[b]),ie=useCallback(se=>{!c&&r&&r({type:"fontSize",value:se});},[c,r]),ge=useCallback(se=>{!c&&r&&r({type:"textColor",value:se});},[c,r]),K=useCallback(se=>{!c&&r&&r({type:"highlightColor",value:typeof se=="string"?se:""});},[c,r]),de=useCallback(se=>{!c&&r&&r({type:"alignment",value:se});},[c,r]),ke=useCallback(()=>{!c&&r&&r("bulletList");},[c,r]),Ze=useCallback(()=>{!c&&r&&r("numberedList");},[c,r]),at=useCallback(()=>{!c&&r&&r("indent");},[c,r]),Ce=useCallback(()=>{!c&&r&&r("outdent");},[c,r]),Ye=useCallback(se=>{!c&&r&&(r({type:"lineSpacing",value:se}),hostWindowOf(j.current).requestAnimationFrame(()=>N?.()));},[c,r,N]),Wn=useCallback(se=>{!c&&r&&r({type:"applyStyle",value:se});},[c,r]),wt=useCallback(se=>{!c&&V&&(V(se),hostWindowOf(j.current).requestAnimationFrame(()=>N?.()));},[c,V,N]);useEffect(()=>{if(!u)return;let se=Ie=>{if(Ie.defaultPrevented)return;let Kn=Ie.target,xo=g?.current,Qt=j.current,vo=xo?.contains(Kn),an=Qt?.contains(Kn);if(!vo&&!an)return;if((Ie.ctrlKey||Ie.metaKey)&&!Ie.altKey)switch(Ie.key.toLowerCase()){case "b":Ie.preventDefault(),q("bold");break;case "i":Ie.preventDefault(),q("italic");break;case "u":Ie.preventDefault(),q("underline");break;case "=":Ie.shiftKey?(Ie.preventDefault(),q("superscript")):(Ie.preventDefault(),q("subscript"));break;case "l":Ie.preventDefault(),de("left");break;case "e":Ie.preventDefault(),de("center");break;case "r":Ie.preventDefault(),de("right");break;case "j":Ie.preventDefault(),de("both");break;case "k":Ie.preventDefault(),q("insertLink");break}},Ge=hostDocumentOf(g?.current??j.current);return Ge.addEventListener("keydown",se),()=>{Ge.removeEventListener("keydown",se);}},[u,q,de,g]);let qt=useCallback(se=>{let Ge=se.target;Ge.tagName==="INPUT"||Ge.tagName==="TEXTAREA"||Ge.tagName==="SELECT"||Ge.tagName==="OPTION"||se.preventDefault();},[]),Zn=useCallback(se=>{let Ge=se.target,Ie=hostDocumentOf(Ge).activeElement;Ge.tagName==="SELECT"||Ge.tagName==="OPTION"||Ie?.tagName==="SELECT"||hostWindowOf(Ge).requestAnimationFrame(()=>{N?.();});},[N]);return jsxs("div",{ref:j,className:ue(!Y&&"flex items-center px-2 py-1 bg-muted rounded-full min-h-[36px] overflow-x-auto mx-2 mb-1",d),style:Y?{display:"contents",...m}:m,role:Y?void 0:"toolbar","aria-label":Y?void 0:t("toolbar.ariaLabel"),"data-testid":Y?void 0:"formatting-bar",onMouseDown:Y?void 0:qt,onMouseUp:Y?void 0:Zn,children:[jsxs(ho,{label:t("formattingBar.groups.history"),children:[jsx(Jt,{onClick:X,disabled:c||!l,title:t("formattingBar.undoShortcut"),ariaLabel:t("formattingBar.undo"),children:jsx(G,{name:"undo",size:bo})}),jsx(Jt,{onClick:ee,disabled:c||!s,title:t("formattingBar.redoShortcut"),ariaLabel:t("formattingBar.redo"),children:jsx(G,{name:"redo",size:bo})})]}),w&&jsx(ho,{label:t("formattingBar.groups.zoom"),children:jsx(ZT,{value:_,onChange:L,disabled:c,compact:true})}),T&&jsx(ho,{label:t("formattingBar.groups.styles"),children:jsx(BT,{value:n.styleId||"Normal",onChange:Wn,styles:S,theme:P,disabled:c,width:120})}),(f||v)&&jsxs(ho,{label:t("formattingBar.groups.font"),children:[f&&jsx(xT,{value:n.fontFamily||"Arial",onChange:O,fonts:I,documentFonts:y,disabled:c,width:60,placeholder:"Arial"}),v&&jsx(PT,{value:n.fontSize!==void 0?mm(n.fontSize):11,onChange:ie,disabled:c,width:42,placeholder:"11"})]}),jsxs(ho,{label:t("formattingBar.groups.textFormatting"),children:[jsx(Jt,{onClick:()=>q("bold"),active:n.bold,disabled:c,title:t("formattingBar.boldShortcut"),ariaLabel:t("formattingBar.bold"),children:jsx(G,{name:"format_bold",size:bo})}),jsx(Jt,{onClick:()=>q("italic"),active:n.italic,disabled:c,title:t("formattingBar.italicShortcut"),ariaLabel:t("formattingBar.italic"),children:jsx(G,{name:"format_italic",size:bo})}),jsx(Jt,{onClick:()=>q("underline"),active:n.underline,disabled:c,title:t("formattingBar.underlineShortcut"),ariaLabel:t("formattingBar.underline"),children:jsx(G,{name:"format_underlined",size:bo})}),jsx(Jt,{onClick:()=>q("strikethrough"),active:n.strike,disabled:c,title:t("formattingBar.strikethrough"),ariaLabel:t("formattingBar.strikethrough"),children:jsx(G,{name:"strikethrough_s",size:bo})}),x&&jsx(Sr,{mode:"text",value:n.color?.replace(/^#/,""),onChange:ge,theme:P,disabled:c,title:t("formattingBar.fontColor")}),h&&jsx(Sr,{mode:"highlight",value:n.highlight,onChange:K,theme:P,disabled:c,title:t("formattingBar.highlightColor")}),jsx(Jt,{onClick:()=>q("insertLink"),disabled:c,title:t("formattingBar.insertLinkShortcut"),ariaLabel:t("formattingBar.insertLink"),children:jsx(G,{name:"link",size:bo})})]}),jsxs(ho,{label:t("formattingBar.groups.script"),children:[jsx(Jt,{onClick:()=>q("superscript"),active:n.superscript,disabled:c,title:t("formattingBar.superscriptShortcut"),ariaLabel:t("formattingBar.superscript"),children:jsx(G,{name:"superscript",size:bo})}),jsx(Jt,{onClick:()=>q("subscript"),active:n.subscript,disabled:c,title:t("formattingBar.subscriptShortcut"),ariaLabel:t("formattingBar.subscript"),children:jsx(G,{name:"subscript",size:bo})})]}),k&&jsx(ho,{label:t("formattingBar.groups.alignment"),children:jsx(FT,{value:n.alignment||"left",onChange:de,disabled:c})}),(E||C)&&jsxs(ho,{label:t("formattingBar.groups.listFormatting"),children:[E&&jsx(HT,{listState:n.listState||Cd(),onBulletList:ke,onNumberedList:Ze,onIndent:at,onOutdent:Ce,disabled:c,showIndentButtons:true,compact:true,hasIndent:(n.indentLeft??0)>0}),C&&jsx(OT,{value:n.lineSpacing,onChange:Ye,disabled:c})]}),B&&F&&jsxs(ho,{label:t("formattingBar.groups.image"),children:[jsx(tE,{imageContext:B,onChange:F,disabled:c}),D&&jsx(oE,{onTransform:D,disabled:c}),R&&jsx(Jt,{onClick:R,disabled:c,title:t("formattingBar.imagePropertiesShortcut"),ariaLabel:t("formattingBar.imageProperties"),children:jsx(G,{name:"tune",size:bo})})]}),U?.isInTable&&V&&jsxs(ho,{label:t("formattingBar.groups.table"),children:[jsx(UT,{onAction:wt,disabled:c}),jsx($T,{onAction:wt,disabled:c,theme:P,value:tn(U?.cellBorderColor,P)}),jsx(VT,{onAction:wt,disabled:c}),jsx(jT,{onAction:wt,disabled:c,theme:P,value:U?.cellBackgroundColor}),jsx(QT,{onAction:wt,disabled:c,tableContext:U})]}),jsx(Jt,{onClick:()=>q("clearFormatting"),disabled:c,title:t("formattingBar.clearFormatting"),ariaLabel:t("formattingBar.clearFormatting"),children:jsx(G,{name:"format_clear",size:bo})}),p]})}function $H({children:e,className:t,style:o,...n}){return jsx(Il.Provider,{value:n,children:jsx("div",{className:ue("flex flex-col bg-doc-surface shadow-sm flex-shrink-0",t),style:{position:"relative",zIndex:St.toolbar,...o},"data-testid":"editor-toolbar",children:e})})}var Lt=$H;Lt.TitleBar=jf;Lt.Logo=md;Lt.DocumentName=Gf;Lt.MenuBar=gd;Lt.TitleBarRight=fd;Lt.Toolbar=dg;var GH=new Map([["#ffff00","yellow"],["#00ff00","green"],["#00ffff","cyan"],["#ff00ff","magenta"],["#0000ff","blue"],["#ff0000","red"],["#000080","darkBlue"],["#008080","darkCyan"],["#008000","darkGreen"],["#800080","darkMagenta"],["#800000","darkRed"],["#808000","darkYellow"],["#808080","darkGray"],["#c0c0c0","lightGray"],["#ffffff","white"]]),jH=e=>{let t=/^#?([0-9a-fA-F]{6})$/.exec(e.trim());return t?t[1].toUpperCase():null};function YH({source:e,scale:t,measurer:o,documentName:n,onStateChange:r,onError:i,onSave:a,renderTitleBarLeft:l,renderTitleBarRight:s,ref:c,colorMode:d,onZoomChange:m,documentFontFamily:u,className:g}){let p=useRef(null),[f,b]=useState(null),[y,v]=useState({}),[x,h]=useState(null),k=useCallback(S=>{b(S);let P=p.current?.formatting();P&&v({bold:P.bold,italic:P.italic,underline:P.underline,strike:P.strikethrough,superscript:P.superscript,subscript:P.subscript,...P.fontFamily?{fontFamily:P.fontFamily}:{},...P.fontSizeHalfPoints?{fontSize:P.fontSizeHalfPoints}:{},...P.alignment?{alignment:P.alignment}:{},...P.styleId?{styleId:P.styleId}:{},...P.color?{color:`#${P.color}`}:{},...P.highlight?{highlight:P.highlight}:{}}),h(p.current?.sectionProperties()??null),r?.(S);},[r]),E=useCallback(S=>{let P=p.current;if(P){if(typeof S=="string")switch(S){case "bold":return P.toggleRunProperty("b");case "italic":return P.toggleRunProperty("i");case "underline":return P.toggleRunProperty("u",{val:"single"});case "strikethrough":return P.toggleRunProperty("strike");case "superscript":return P.setRunProperty("vertAlign",{val:"superscript"});case "subscript":return P.setRunProperty("vertAlign",{val:"subscript"});case "clearFormatting":P.setRunProperty("b",{val:"0"}),P.setRunProperty("i",{val:"0"}),P.setRunProperty("u",{val:"none"}),P.setRunProperty("strike",{val:"0"}),P.setRunProperty("vertAlign",{val:"baseline"});return;case "setRtl":case "setLtr":return P.setParagraphProperty("bidi",void 0,{paragraphDirection:S==="setRtl"?"rtl":"ltr"});default:return}switch(S.type){case "fontFamily":return P.setRunProperty("rFonts",{ascii:S.value,hAnsi:S.value});case "fontSize":return P.setRunProperty("sz",{val:String(Math.round(S.value*2))});case "textColor":{let w=S.value,_=typeof w=="string"?jH(w):tn(w,null)??null;return _?P.setRunProperty("color",{val:_}):void 0}case "highlightColor":{let w=S.value.trim().toLowerCase();if(w==="none"||w==="")return P.setRunProperty("highlight",{val:"none"});let _=GH.get(w.startsWith("#")?w:`#${w}`);return _?P.setRunProperty("highlight",{val:_}):void 0}case "alignment":return P.setParagraphProperty("jc",{val:String(S.value)},{physicalAlignment:true});case "lineSpacing":return P.setParagraphProperty("spacing",{line:String(Math.round(S.value)),lineRule:"auto"},{mergeAttributes:true});case "applyStyle":return P.setParagraphProperty("pStyle",{val:S.value});default:return}}},[]);useImperativeHandle(c,()=>p.current,[]);let C=t===void 0?1:t/(96/72),T=x?{pageWidthTwips:x.pageSize.widthTwips,pageHeightTwips:x.pageSize.heightTwips,orientation:x.landscape?"landscape":"portrait",marginsTwips:{top:x.margins.topTwips,right:x.margins.rightTwips,bottom:x.margins.bottomTwips,left:x.margins.leftTwips}}:null;return 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(Lt,{currentFormatting:y,onFormat:E,onUndo:()=>p.current?.undo(),onRedo:()=>p.current?.redo(),canUndo:f?.canUndo??false,canRedo:f?.canRedo??false,zoom:C,onZoomChange:m,onSave:()=>{let S=p.current?.save();S&&a?.(S);},children:[jsxs(Lt.TitleBar,{children:[l&&jsx(Lt.Logo,{children:l()}),jsx(Lt.DocumentName,{value:n??"Document",editable:false}),s&&jsx(Lt.TitleBarRight,{children:s()}),jsx(Lt.MenuBar,{})]}),jsx(Lt.Toolbar,{})]}),jsxs("div",{className:"docx-editor__scroll-container",style:{flex:1,minHeight:0,overflow:"auto",background:"var(--doc-bg)"},children:[T?jsx("div",{style:{padding:"4px 0"},children:jsx(br,{pageSetup:T,zoom:C})}):null,jsx(qf,{ref:p,source:e,...u?{documentFontFamily:u}:{},...t===void 0?{}:{scale:t},...o?{measurer:o}:{},onStateChange:k,...i?{onError:i}:{}})]})]})}var Md=class{listeners=new Set;snapshot;constructor(t){this.snapshot=t;}subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t);});getSnapshot=()=>this.snapshot;setSnapshot(t){this.snapshot=t,this.notify();}notify(){for(let t of this.listeners)t();}};var _d=class extends Md{notifications=[];idCounter=0;timers=new Set;constructor(){super({notifications:[]});}showError(t,o){return this.addNotification(t,"error",o)}showWarning(t,o){return this.addNotification(t,"warning",o)}showInfo(t,o){return this.addNotification(t,"info",o)}dismiss(t){this.notifications=this.notifications.map(n=>n.id===t?{...n,dismissed:true}:n),this.emitSnapshot();let o=globalThis.setTimeout(()=>{this.timers.delete(o),this.notifications=this.notifications.filter(n=>n.id!==t),this.emitSnapshot();},300);this.timers.add(o);}clearAll(){this.notifications=[];for(let t of this.timers)globalThis.clearTimeout(t);this.timers.clear(),this.emitSnapshot();}destroy(){for(let t of this.timers)globalThis.clearTimeout(t);this.timers.clear(),this.notifications=[];}addNotification(t,o,n){let r=`error-${++this.idCounter}-${Date.now()}`,i={id:r,message:t,severity:o,details:n,timestamp:Date.now()};if(this.notifications=[...this.notifications,i],this.emitSnapshot(),o!=="error"){let a=globalThis.setTimeout(()=>{this.timers.delete(a),this.dismiss(r);},5e3);this.timers.add(a);}return r}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var oA=createContext(null);function sE({children:e}){let t=useMemo(()=>new _d,[]),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(oA.Provider,{value:s,children:[e,jsx(nA,{notifications:o.notifications,onDismiss:a})]})}function nA({notifications:e,onDismiss:t}){let o=e.filter(r=>!r.dismissed);return o.length===0?null: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(rA,{notification:r,onDismiss:()=>t(r.id)},r.id))})}function rA({notification:e,onDismiss:t}){let{t:o}=H(),[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 Id=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(aA,{error:n,errorInfo:r,showDetails:o,onReset:this.resetError})}return this.props.children}};function aA({error:e,errorInfo:t,showDetails:o,onReset:n}){let{t:r}=H(),i={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"40px",textAlign:"center",minHeight:"200px",background:"var(--doc-surface)",borderRadius:"8px",border:"1px solid var(--doc-border)",margin:"20px"},a={color:"var(--doc-error)",marginBottom:"16px"},l={fontSize:"18px",fontWeight:600,color:"var(--doc-text)",marginBottom:"8px"},s={fontSize:"14px",color:"var(--doc-text-muted)",marginBottom:"16px",maxWidth:"400px"},c={width:"100%",maxWidth:"600px",marginBottom:"16px",padding:"12px",background:"var(--doc-error-bg)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"200px",overflow:"auto"},d={padding:"10px 20px",background:"var(--doc-primary)",color:"var(--doc-on-primary)",border:"none",borderRadius:"4px",fontSize:"14px",cursor:"pointer"};return 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:[`
|
|
3
3
|
|
|
4
|
-
`,jsx("strong",{children:
|
|
4
|
+
`,jsx("strong",{children:r("errors.componentStack")}),t.componentStack]})]}),jsx("button",{type:"button",onClick:n,style:d,children:r("errors.tryAgain")})]})}function uE({onClick:e,topPx:t,scrollLeft:o=0,leftOffset:n=_a}){let{t:r}=H();return jsx("button",{className:"docx-outline-toggle",onClick:e,onMouseDown:i=>i.stopPropagation(),title:r("editor.showDocumentOutline"),"aria-label":r("editor.showDocumentOutline"),style:{position:"absolute",left:n-o,top:t,zIndex:St.outline},children:jsx(G,{name:"format_list_bulleted",size:20})})}function pg({currentPage:e,totalPages:t,visible:o}){let{t:n}=H();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 lA({i18n:e,isDark:t,onEditorError:o,containerRef:n,scrollContainerRef:r,editorContentRef:i,className:a,containerStyle:l,mainContentStyle:s,editorContainerStyle:c,showRuler:d,readOnlyProp:m,showOutline:u,showOutlineButton:g,sidebarOpen:p,minLayoutWidth:f,toolbarHeight:b,editorScrollLeft:y,onScrollContainerMouseDown:v,onEditorBgMouseDown:x,onEditorContextMenu:h,horizontalRulerProps:k,verticalRulerProps:E,outlineProps:C,onToggleOutline:T,scrollPageInfo:S,toolbar:P,pagedArea:w,overlays:_,dialogs:L,fileInputs:N}){let B=d&&!m;return jsx(Wo.Provider,{value:true,children:jsx(Mr,{i18n:e,children:jsx(sE,{children:jsx(Id,{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:[P,jsxs("div",{ref:r,className:"docx-editor__scroll-container",style:c,onMouseDown:v,children:[d&&jsx("div",{className:"flex py-1 flex-shrink-0 bg-doc-bg",style:{position:"sticky",top:0,zIndex:St.ruler,paddingLeft:20,paddingRight:20+(p?352:0),minWidth:f,transition:"padding 0.2s ease"},children:jsx(br,{...k})}),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:x,onContextMenu:h,children:[B&&jsx("div",{style:{position:"absolute",left:0,top:0,zIndex:St.ruler,paddingTop:48},children:jsx(gl,{...E})}),w]})})]}),S.totalPages>1&&jsx(pg,{currentPage:S.currentPage,totalPages:S.totalPages,visible:S.visible}),u&&jsx(hl,{...C,leftOffset:bl+(B?Ma:0)}),g&&!u&&jsx(uE,{onClick:T,topPx:b+(d?xf+8:0)+48,scrollLeft:y,leftOffset:_a+(B?Ma:0)})]})}),_,L,N]})})})})})}function fA(e){let[t,o]=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 vA({kind:e}){let t=A(),[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{Mt as CONTENT_CONTROL_SLOTS,ar as ContextMenuCellVerticalAlignment,vi as ContextMenuCopy,Rs as ContextMenuCopyFormatting,xi as ContextMenuCut,Ci as ContextMenuDelete,ua as ContextMenuDeleteTable,da as ContextMenuDeleteTableColumn,ca as ContextMenuDeleteTableRow,aa as ContextMenuInsertColumnLeft,ia as ContextMenuInsertColumnRight,na as ContextMenuInsertRowAbove,ra as ContextMenuInsertRowBelow,_s as ContextMenuItem,la as ContextMenuMergeCells,ea as ContextMenuPaste,Ms as ContextMenuPasteFormatting,ta as ContextMenuPasteWithoutFormatting,pa as ContextMenuRefreshToc,ma as ContextMenuRefreshTocPageNumbers,fa as ContextMenuRemoveToc,Ti as ContextMenuSelectAll,oa as ContextMenuSelectTable,sa as ContextMenuSplitCell,np as DEFAULT_WATERMARK_PRESETS,Gf as DocumentName,hl as DocumentOutline,s4 as DocxEditor,bm as DocxEditorAuthorStyle,mi as DocxEditorBookmarkDialog,gm as DocxEditorColorByChangeType,qa as DocxEditorCompareDocumentsDialog,Qs as DocxEditorContent,ti as DocxEditorContentControl,am as DocxEditorContentControlWidget,ki as DocxEditorContextMenu,wf as DocxEditorDocumentOutline,oi as DocxEditorEquation,Ua as DocxEditorExportDialog,sd as DocxEditorFontNotice,dd as DocxEditorHeaderFooterChrome,Yc as DocxEditorHorizontalRuler,Ja as DocxEditorHyperLink,Us as DocxEditorImageAltTextPopup,Hu as DocxEditorImageInsertErrorDialog,Ri as DocxEditorImagePropertiesDialog,Ap as DocxEditorInvalidTextFormFieldDialog,tc as DocxEditorLoading,fm as DocxEditorLoadingSpinner,pl as DocxEditorMenu,Lf as DocxEditorNavigation,Nr as DocxEditorNotePreview,As as DocxEditorNotePropertiesDialog,Hs as DocxEditorNotesChrome,Fr as DocxEditorNotesContextMenu,cd as DocxEditorOpenFailure,Af as DocxEditorOpenFailureAction,ld as DocxEditorPageNumber,tr as DocxEditorPageSetupDialog,Vo as DocxEditorParagraphDialog,$a as DocxEditorPrintDialog,lu as DocxEditorRevisionMarkup,Ka as DocxEditorRevisionMarkupDialog,Ai as DocxEditorRoot,lA as DocxEditorShell,fi as DocxEditorSplitCellDialog,bi as DocxEditorTextFormFieldDialog,sl as DocxEditorToolbar,Fd as DocxEditorUnsupportedElement,Xc as DocxEditorVerticalRuler,ac as DocxEditorViewport,or as DocxEditorWatermarkDialog,pm as DocxEditorWindow,br as HorizontalRuler,qs as ImageAltText,cs as ImageInsertProvider,ds as ImageInsertTrigger,Ks as ImagePropertiesTrigger,mc as ImageWrap,Mr as LocaleProvider,md as Logo,gd as MenuBar,dC as NAVIGATION_PANE_GAP,Qc as NAVIGATION_PANE_INSET,Rf as NAVIGATION_PANE_MIN_PAGE_ROOM,Na as NAVIGATION_PANE_WIDTH,El as NavigationClose,Dl as NavigationFind,yl as NavigationGoTo,Tl as NavigationHeader,wl as NavigationHeadings,kl as NavigationTab,Pl as NavigationTabs,Sl as NavigationTitle,Rl as NavigationToggle,_a as OUTLINE_BUTTON_LEFT_OFFSET,dF as OUTLINE_BUTTON_RESERVED_SPACE,bl as OUTLINE_LEFT_OFFSET,sF as OUTLINE_RESERVED_SPACE,pg as PageIndicator,id as PageNumberTranslationContext,qf as PaginatedDocxEditor,YH as PaginatedDocxEditorShell,xa as REVIEW_MARKERS_GUTTER,Oi as REVIEW_PANE_GUTTER,Ma as RULER_WIDTH,At as ReviewRailContext,Q as Slot,jf as TitleBar,fd as TitleBarRight,dg as Toolbar,Jt as ToolbarButton,Vn as ToolbarContext,ho as ToolbarGroup,ga as ToolbarImageProperties,fE as VERSION,gl as VerticalRuler,BP as definePopup,AE as editorStateActiveSubscriptionCount,ja as isFieldLink,td as navigationPaneOverlays,Fa as navigationPaneReservation,ed as navigationShift,as as normalizeImageBytes,Tg as notificationYieldsToTask,G1 as provideDocxEditor,cy as reviewGutter,eR as useBookmarkDialog,gp as useBookmarks,lt as useChromeDir,xg as useChromeTranslate,R4 as useCommentDraftRequest,EP as useCompareDocumentsDialog,Po as useContentControl,Ql as useContentControlInstance,ct as useContentControlWidget,Qb as useContextMenuTarget,od as useDocumentOutline,nd as useDocumentSearch,A as useDocxEditor,b4 as useDocxSource,P4 as useEditorCaret,VE as useEditorColorMode,re as useEditorCommand,Qm as useEditorEvent,cf as useEditorHostDocument,fA as useEditorSnapshot,W as useEditorState,Mi as useEditorValueCommand,xc as useFontFamily,C4 as useFonts,Jc as useGoToBookmark,Bf as useHeaderFooterState,W4 as useHighlightAt,N4 as useHighlights,vA as useHistoryGroup,XP as useHyperlinkPopup,Xl as useHyperlinkPopupInstance,rd as useNavigationPane,zn as useNavigationShift,kp as useNotePropertiesState,Pp as useNoteScopeState,qC as useOpenFailure,er as usePageSetup,hD as usePageSetupDialog,MD as useParagraphDialog,ep as useParagraphFormat,Cf as useParagraphIndent,Cc as useParagraphStyle,Zi as useReviewAuthors,En as useReviewGutter,uP as useRevisionMarkupDialog,qE as useScopeClassName,wi as useScopedChromeAnchor,uR as useSplitCellDialog,lv as useTableBorderTargetLabel,yR as useTextFormFieldDialog,ES as useToolbarContext,ae as useToolbarLabel,zl as useToolbarLabelFor,H as useTranslation,up as useWatermark,Hh as useWatermarkDialog,Hm as useZoom};
|