import{tuple as e,withInstall as t}from"../_util/type.mjs";import n from"../_util/classNames.mjs";import{isValidElement as r}from"../_util/props-util/index.mjs";import i from"../config-provider/hooks/useConfigInject.mjs";import a from"../_util/vue-types/index.mjs";import{getTransitionProps as o}from"../_util/transition.mjs";import{cloneElement as s}from"../_util/vnode.mjs";import c from"./style/index.mjs";import{Transition as l,computed as u,createVNode as d,defineComponent as f,shallowRef as p,vShow as m,withDirectives as h}from"vue";import{CheckCircleFilled as g,CheckCircleOutlined as _,CloseCircleFilled as v,CloseCircleOutlined as y,CloseOutlined as b,ExclamationCircleFilled as x,ExclamationCircleOutlined as S,InfoCircleFilled as C,InfoCircleOutlined as w}from"@antsoo-lib/icons";var T={success:g,info:C,error:v,warning:x},E={success:_,info:w,error:y,warning:S},D=e(`success`,`info`,`warning`,`error`),O=()=>({type:a.oneOf(D),closable:{type:Boolean,default:void 0},closeText:a.any,message:a.any,description:a.any,afterClose:Function,showIcon:{type:Boolean,default:void 0},prefixCls:String,banner:{type:Boolean,default:void 0},icon:a.any,closeIcon:a.any,onClose:Function}),k=t(f({compatConfig:{MODE:3},name:`AAlert`,inheritAttrs:!1,props:O(),setup(e,{slots:t,emit:a,attrs:f,expose:g}){let{prefixCls:_,direction:v}=i(`alert`,e),[y,x]=c(_),S=p(!1),C=p(!1),w=p(),D=e=>{e.preventDefault();let t=w.value;t.style.height=`${t.offsetHeight}px`,t.style.height=`${t.offsetHeight}px`,S.value=!0,a(`close`,e)},O=()=>{S.value=!1,C.value=!0,e.afterClose?.()},k=u(()=>{let{type:t}=e;return t===void 0?e.banner?`warning`:`info`:t});g({animationEnd:O});let A=p({});return()=>{let{banner:i,closeIcon:a=t.closeIcon?.()}=e,{closable:c,showIcon:u}=e,p=e.closeText??t.closeText?.(),g=e.description??t.description?.(),j=e.message??t.message?.(),M=e.icon??t.icon?.(),N=t.action?.();u=i&&u===void 0?!0:u;let P=(g?E:T)[k.value]||null;p&&(c=!0);let F=_.value,I=n(F,{[`${F}-${k.value}`]:!0,[`${F}-closing`]:S.value,[`${F}-with-description`]:!!g,[`${F}-no-icon`]:!u,[`${F}-banner`]:!!i,[`${F}-closable`]:c,[`${F}-rtl`]:v.value===`rtl`,[x.value]:!0}),L=c?d(`button`,{type:`button`,onClick:D,class:`${F}-close-icon`,tabindex:0},[p?d(`span`,{class:`${F}-close-text`},[p]):a===void 0?d(b,null,null):a]):null,R=M&&(r(M)?s(M,{class:`${F}-icon`}):d(`span`,{class:`${F}-icon`},[M]))||d(P,{class:`${F}-icon`},null),z=o(`${F}-motion`,{appear:!1,css:!0,onAfterLeave:O,onBeforeLeave:e=>{e.style.maxHeight=`${e.offsetHeight}px`},onLeave:e=>{e.style.maxHeight=`0px`}});return y(C.value?null:d(l,z,{default:()=>[h(d(`div`,{role:`alert`,...f,style:[f.style,A.value],class:[f.class,I],"data-show":!S.value,ref:w},[u?R:null,d(`div`,{class:`${F}-content`},[j?d(`div`,{class:`${F}-message`},[j]):null,g?d(`div`,{class:`${F}-description`},[g]):null]),N?d(`div`,{class:`${F}-action`},[N]):null,L]),[[m,!S.value]])]}))}}}));export{O as alertProps,k as default};