import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{$P as t}from"./lucide-C4oWPzu4.js";import{p as n}from"./utils-Bs-0X7qI.js";import{r}from"./bundle-mjs-C4g7ASB5.js";import{a as i,c as a,i as o,l as s,n as c,o as l,r as u,s as d,t as f}from"./alert-dialog-DyL4auo-.js";var p=n(),m=e(t(),1),h=r(),g=m.createContext(null);function _(e){let t=(0,p.c)(36),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:!1},t[0]=r):r=t[0];let[_,x]=m.useState(r),S=m.useRef(!1),C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C={},t[1]=C):C=t[1];let w=m.useRef(C),T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>{let t=e===void 0?{}:e;return S.current=!1,new Promise(e=>{w.current={resolve:e,onConfirm:t.onConfirm,onCancel:t.onCancel},x({...t,open:!0,resolve:e})})},t[2]=T):T=t[2];let E=T,D;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{!e&&!S.current&&(S.current=!0,w.current.onCancel?.(),w.current.resolve?.(!1),x(b))},t[3]=D):D=t[3];let O=D,k;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(k=async()=>{S.current||(S.current=!0,await w.current.onConfirm?.(),w.current.resolve?.(!0),x(y))},t[4]=k):k=t[4];let A=k,j;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(j=async()=>{S.current||(S.current=!0,await w.current.onCancel?.(),w.current.resolve?.(!1),x(v))},t[5]=j):j=t[5];let M=j,N;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(N={confirm:E},t[6]=N):N=t[6];let P=N,F;t[7]===_.media?F=t[8]:(F=_.media&&(0,h.jsx)(a,{children:_.media}),t[7]=_.media,t[8]=F);let I;t[9]===_.title?I=t[10]:(I=_.title&&(0,h.jsx)(s,{children:_.title}),t[9]=_.title,t[10]=I);let L;t[11]===_.description?L=t[12]:(L=_.description&&(0,h.jsx)(i,{children:_.description}),t[11]=_.description,t[12]=L);let R;t[13]!==L||t[14]!==F||t[15]!==I?(R=(0,h.jsxs)(d,{children:[F,I,L]}),t[13]=L,t[14]=F,t[15]=I,t[16]=R):R=t[16];let z=_.cancelText??`取消`,B;t[17]!==_.cancelVariant||t[18]!==z?(B=(0,h.jsx)(u,{variant:_.cancelVariant,onClick:M,children:z}),t[17]=_.cancelVariant,t[18]=z,t[19]=B):B=t[19];let V=_.confirmText??`确定`,H;t[20]!==_.confirmVariant||t[21]!==V?(H=(0,h.jsx)(c,{variant:_.confirmVariant,onClick:A,children:V}),t[20]=_.confirmVariant,t[21]=V,t[22]=H):H=t[22];let U;t[23]!==B||t[24]!==H?(U=(0,h.jsxs)(l,{children:[B,H]}),t[23]=B,t[24]=H,t[25]=U):U=t[25];let W;t[26]!==_.size||t[27]!==R||t[28]!==U?(W=(0,h.jsxs)(o,{size:_.size,className:`max-w-sm data-[size=default]:max-w-sm data-[size=default]:sm:max-w-sm`,children:[R,U]}),t[26]=_.size,t[27]=R,t[28]=U,t[29]=W):W=t[29];let G;t[30]!==_.open||t[31]!==W?(G=(0,h.jsx)(f,{open:_.open,onOpenChange:O,children:W}),t[30]=_.open,t[31]=W,t[32]=G):G=t[32];let K;return t[33]!==n||t[34]!==G?(K=(0,h.jsxs)(g.Provider,{value:P,children:[n,G]}),t[33]=n,t[34]=G,t[35]=K):K=t[35],K}function v(e){return{...e,open:!1}}function y(e){return{...e,open:!1}}function b(e){return{...e,open:!1}}function x(){let e=(0,p.c)(4),t=m.useContext(g);if(!t)throw Error(`useAlertDialog must be used within an AlertDialogProvider`);let n;e[0]===t?n=e[1]:(n=async e=>{if(!await t.confirm(e))throw Error(`AlertDialog cancelled`)},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={confirm:r},e[2]=r,e[3]=i),i}export{x as n,_ as t};