import{x as t,d as o,H as e,aY as n,af as a,E as l,a as s,w as c,a6 as i,ap as r,aZ as u,ar as d,c as m,ad as f,B,a_ as g,z as b,aq as p,C as h,a$ as C,r as v,G as w,az as y,y as x,P as k,b0 as S,b1 as T,b2 as D,b3 as O,b4 as H,am as P,a0 as z,b5 as A,b6 as E}from"./index-d31722d5.js";const[N,F]=t("action-bar"),I=Symbol(N),U=c(o({name:N,props:{placeholder:Boolean,safeAreaInsetBottom:l},setup(t,{slots:o}){const l=e(),c=n(l,F),{linkChildren:i}=a(I);i();const r=()=>{var e;return s("div",{ref:l,"class":[F(),{"van-safe-area-bottom":t.safeAreaInsetBottom}]},[null==(e=o["default"])?void 0:e.call(o)])};return()=>t.placeholder?c(r):r()}})),[j,q]=t("action-bar-button"),G=c(o({name:j,props:i({},r,{type:String,text:String,icon:String,color:String,loading:Boolean,disabled:Boolean}),setup(t,{slots:o}){const e=u(),{parent:n,index:a}=d(I),l=m((()=>{if(n){const t=n.children[a.value-1];return!(t&&"isButton"in t)}})),c=m((()=>{if(n){const t=n.children[a.value+1];return!(t&&"isButton"in t)}}));return f({isButton:!0}),()=>{const{type:n,icon:a,text:i,color:r,loading:u,disabled:d}=t;return s(B,{"class":q([n,{last:c.value,first:l.value}]),size:"large",type:n,icon:a,color:r,loading:u,disabled:d,onClick:e},{"default":()=>[o["default"]?o["default"]():i]})}}})),[K,L,M]=t("dialog"),R=i({},g,{title:String,theme:String,width:b,message:[String,Function],callback:Function,allowHtml:Boolean,className:p,transition:h("van-dialog-bounce"),messageAlign:String,closeOnPopstate:l,showCancelButton:Boolean,cancelButtonText:String,cancelButtonColor:String,cancelButtonDisabled:Boolean,confirmButtonText:String,confirmButtonColor:String,confirmButtonDisabled:Boolean,showConfirmButton:l,closeOnClickOverlay:Boolean}),Y=[...C,"transition","closeOnPopstate"];var Z=o({name:K,props:R,emits:["confirm","cancel","keydown","update:show"],setup(t,{emit:o,slots:n}){const a=e(),l=v({confirm:!1,cancel:!1}),c=t=>o("update:show",t),i=o=>{var e;c(!1),null==(e=t.callback)||e.call(t,o)},r=e=>()=>{t.show&&(o(e),t.beforeClose?(l[e]=!0,P(t.beforeClose,{args:[e],done(){i(e),l[e]=!1},canceled(){l[e]=!1}})):i(e))},u=r("cancel"),d=r("confirm"),m=S((e=>{var n,l;e.target===(null==(l=null==(n=a.value)?void 0:n.popupRef)?void 0:l.value)&&({Enter:t.showConfirmButton?d:T,Escape:t.showCancelButton?u:T}[e.key](),o("keydown",e))}),["enter","esc"]),f=()=>{const o=n.title?n.title():t.title;if(o)return s("div",{"class":L("header",{isolated:!t.message&&!n["default"]})},[o])},g=o=>{const{message:e,allowHtml:n,messageAlign:a}=t,l=L("message",{"has-title":o,[a]:a}),c=D(e)?e():e;return n&&"string"==typeof c?s("div",{"class":l,innerHTML:c},null):s("div",{"class":l},[c])},b=()=>{if(n["default"])return s("div",{"class":L("content")},[n["default"]()]);const{title:o,message:e,allowHtml:a}=t;if(e){const t=!(!o&&!n.title);return s("div",{key:a?1:0,"class":L("content",{isolated:!t})},[g(t)])}};return()=>{const{width:o,title:e,theme:i,message:r,className:g}=t;return s(k,w({ref:a,role:"dialog","class":[L([i]),g],style:{width:x(o)},tabindex:0,"aria-labelledby":e||r,onKeydown:m,"onUpdate:show":c},y(t,Y)),{"default":()=>[f(),b(),n.footer?n.footer():"round-button"===t.theme?s(U,{"class":L("footer")},{"default":()=>[t.showCancelButton&&s(G,{type:"warning",text:t.cancelButtonText||M("cancel"),"class":L("cancel"),color:t.cancelButtonColor,loading:l.cancel,disabled:t.cancelButtonDisabled,onClick:u},null),t.showConfirmButton&&s(G,{type:"danger",text:t.confirmButtonText||M("confirm"),"class":L("confirm"),color:t.confirmButtonColor,loading:l.confirm,disabled:t.confirmButtonDisabled,onClick:d},null)]}):s("div",{"class":[H,L("footer")]},[t.showCancelButton&&s(B,{size:"large",text:t.cancelButtonText||M("cancel"),"class":L("cancel"),style:{color:t.cancelButtonColor},loading:l.cancel,disabled:t.cancelButtonDisabled,onClick:u},null),t.showConfirmButton&&s(B,{size:"large",text:t.confirmButtonText||M("confirm"),"class":[L("confirm"),{[O]:t.showCancelButton}],style:{color:t.confirmButtonColor},loading:l.confirm,disabled:t.confirmButtonDisabled,onClick:d},null)])]})}}});let $,_=i({},{title:"",width:"",theme:null,message:"",overlay:!0,callback:null,teleport:"body",className:"",allowHtml:!1,lockScroll:!0,transition:void 0,beforeClose:null,overlayClass:"",overlayStyle:void 0,messageAlign:"",cancelButtonText:"",cancelButtonColor:null,cancelButtonDisabled:!1,confirmButtonText:"",confirmButtonColor:null,confirmButtonDisabled:!1,showConfirmButton:!0,showCancelButton:!1,closeOnPopstate:!0,closeOnClickOverlay:!1});function J(t){return z?new Promise(((o,e)=>{$||function(){const t={setup(){const{state:t,toggle:o}=E();return()=>s(Z,w(t,{"onUpdate:show":o}),null)}};({instance:$}=A(t))}(),$.open(i({},_,t,{callback:t=>{("confirm"===t?o:e)(t)}}))})):Promise.resolve(void 0)}const Q=t=>J(i({showCancelButton:!0},t));export{Q as a,J as b,Z as s};