1import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{n as t}from"./jsx-runtime-BhgoufuK.js";import{al as n,l as r}from"./UnifyTheme-EYT_jcHV.js";import{_ as i}from"./css-DnAA4g0J.js";import{m as a}from"./utils-DBa0ndjA.js";import{t as o}from"./react-B9fJwgic.js";var s=e(n(),1),c=s.default.div` 2 position: fixed; 3 background-color: ${({theme:{color:e,theme:t}})=>t===r.LIGHT?e.background.primaryAlt:e.opacity.white100}; 4 cursor: default; 5 top: 0; 6 bottom: 0; 7 left: 0; 8 right: 0; 9 10 #app-viewport & { 11 position: absolute; 12 } 13 14 opacity: 0; 15 will-change: opacity; 16 transition: opacity 0.2s; 17 18 ${({$isOpen:e,$isTopOverlay:t})=>e&&t?s.css` 19 opacity: 0.3; 20 `:s.css` 21 opacity: 0; 22 `} 23`,l=e(t(),1),u=o()(e=>({modalsState:{openModalIds:[]},modalsActions:{openModal:t=>e(e=>({...e,modalsState:{...e.modalsState,openModalIds:[...e.modalsState.openModalIds,t]}})),closeModal:t=>e(e=>({...e,modalsState:{...e.modalsState,openModalIds:e.modalsState.openModalIds.filter(e=>e!==t)}})),closeAllModals:()=>e(e=>({...e,modalsState:{...e.modalsState,openModalIds:[]}})),closeTopModal:()=>e(e=>({...e,modalsState:{...e.modalsState,openModalIds:e.modalsState.openModalIds.slice(0,e.modalsState.openModalIds.length-1)}}))}})),d=e=>u(t=>e?t.modalsState.openModalIds.includes(e):t.modalsState.openModalIds.length>0),f=e=>u(t=>t.modalsState.openModalIds.length>0&&t.modalsState.openModalIds[t.modalsState.openModalIds.length-1]===e),p=()=>u(e=>e.modalsActions.openModal),m=()=>u(e=>e.modalsActions.closeModal);function h(){let e=document.activeElement;return!i(e)||!(e instanceof HTMLElement)?!1:(e.blur(),!0)}function g({onClose:e,isOpenDeferred:t=!1,isCloseDisabled:n=!1,confirmCloseProps:r,closeTransitionDurationMs:i=150}){let o=(0,l.useId)(),s=(0,l.useRef)(!1),c=(0,l.useRef)(null),g=a(`modal`);c.current||=document.getElementById(`app-modal-root`)??document.getElementById(`modal-root`)??document.body;let _=g??c.current,v=p(),y=m(),b=d(o),x=f(o),S=(0,l.useCallback)(()=>v(o),[v,o]),C=(0,l.useCallback)(()=>y(o),[y,o]);(0,l.useEffect)(()=>{if(t){s.current=!0;return}s.current||(s.current=!0,document.body.style.overflow=`hidden`,(0,l.startTransition)(()=>S()))},[S,t]);let w=(0,l.useCallback)(()=>{document.body.style.overflow=`hidden`,S()},[S]),T=r?.canClose??!0,E=r?.beforeClose,D=(0,l.useCallback)(t=>{if(!n){if(!T){E?.();return}u.getState().modalsState.openModalIds.length<=1&&document.body.style.removeProperty(`overflow`),(0,l.startTransition)(()=>C()),setTimeout(()=>{(0,l.startTransition)(()=>{e?.(),t&&typeof t==`function`&&t()})},i)}},[e,C,n,T,E,i]),O=(0,l.useCallback)(e=>{if(e.key!==`Escape`||e.defaultPrevented||e.isComposing)return;let t=u.getState().modalsState.openModalIds,n=e.target;if(!(n instanceof Node&&!_.contains(n)&&_.closest(`[inert]`)!==null)&&t[t.length-1]===o){if(h()){e.preventDefault(),e.stopPropagation();return}D()}},[D,o,_]);(0,l.useEffect)(()=>(document.body.addEventListener(`keydown`,O,!1),()=>document.body.removeEventListener(`keydown`,O,!1)),[O]);let k=(0,l.useRef)({isModalOpen:b,closeThisModal:C});return(0,l.useEffect)(()=>{k.current={isModalOpen:b,closeThisModal:C}},[b,C]),(0,l.useEffect)(()=>()=>{let{isModalOpen:e,closeThisModal:t}=k.current;e&&(u.getState().modalsState.openModalIds.length<=1&&document.body.style.removeProperty(`overflow`),t())},[]),(0,l.useMemo)(()=>({modalId:o,openModal:w,closeModal:D,isOpen:b,isTopModal:x,modalRoot:_}),[o,w,D,b,x,_])}export{f as a,c,d as i,h as n,u as o,m as r,p as s,g as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.