import O from"./Icon.fe8c0e68.js";import P from"./Avatar.b92bd51d.js";import V from"./Button.b41c8ed4.js";import{r as D,j as $,E,G as S,g as F,N as h,s as I,B as q,A as G,o as s,k as v,w as H,a as p,K as g,y as d,l as m,H as T,d as U,t as N,c as y,F as j,x as z,O as A,V as J,T as K}from"./entry.9e31e8a4.js";import{t as L}from"./tw-merge.27ca352e.js";import{G as R,u as Q}from"./ui.config.7ae255de.js";import{e as W}from"./index.dff89205.js";import{_ as X}from"./_plugin-vue_export-helper.c27b6911.js";import"./Link.cc0949f5.js";import"./nuxt-link.f786ecc0.js";import"./index.87a09f8b.js";function Y(e,a,n){let r=null;const{pause:k,resume:t,timestamp:c}=W({...n||{},controls:!0}),i=D(null),l=$(()=>i.value?a-(c.value-i.value):0);function o(...C){r=setTimeout(()=>{r=null,i.value=null,e(...C)},l.value)}function u(){r&&(clearTimeout(r),r=null)}function f(){i.value=Date.now(),o()}function B(){u(),k()}function b(){u(),k()}function M(){o(),t(),i.value=(i.value||0)+(Date.now()-c.value)}return f(),{start:f,stop:B,pause:b,resume:M,remaining:l}}const w=E(S.ui.strategy,S.ui.notification,R),Z=F({components:{UIcon:O,UAvatar:P,UButton:V},inheritAttrs:!1,props:{id:{type:[String,Number],required:!0},title:{type:String,required:!0},description:{type:String,default:null},icon:{type:String,default:()=>w.default.icon},avatar:{type:Object,default:null},closeButton:{type:Object,default:()=>w.default.closeButton},timeout:{type:Number,default:5e3},actions:{type:Array,default:()=>[]},callback:{type:Function,default:null},color:{type:String,default:()=>w.default.color,validator(e){return["gray",...S.ui.colors].includes(e)}},ui:{type:Object,default:void 0}},emits:["close"],setup(e,{emit:a}){const{ui:n,attrs:r,attrsClass:k}=Q("notification",e.ui,w);let t=null;const c=D(e.timeout),i=$(()=>L(h(n.value.wrapper,n.value.background,n.value.rounded,n.value.shadow),k)),l=$(()=>h(n.value.progress.base,n.value.progress.background?.replaceAll("{color}",e.color))),o=$(()=>({width:`${c.value/e.timeout*100||0}%`})),u=$(()=>h(n.value.icon.base,n.value.icon.color?.replaceAll("{color}",e.color)));function f(){t&&t.pause()}function B(){t&&t.resume()}function b(){t&&t.stop(),e.callback&&e.callback(),a("close")}function M(C){t&&t.stop(),C.click&&C.click(),a("close")}return I(()=>{e.timeout&&(t=Y(()=>{b()},e.timeout),q(()=>{c.value=t.remaining.value}))}),G(()=>{t&&t.stop()}),{ui:n,attrs:r,wrapperClass:i,progressClass:l,progressStyle:o,iconClass:u,onMouseover:f,onMouseleave:B,onClose:b,onAction:M}}}),_={class:"w-0 flex-1"},x={key:1,class:"mt-3 flex items-center gap-2"},ee={class:"flex-shrink-0 flex items-center gap-3"},te={key:0,class:"flex items-center gap-2"};function oe(e,a,n,r,k,t){const c=O,i=P,l=V;return s(),v(K,g({appear:""},e.ui.transition),{default:H(()=>[p("div",g({class:e.wrapperClass},e.attrs,{onMouseover:a[0]||(a[0]=(...o)=>e.onMouseover&&e.onMouseover(...o)),onMouseleave:a[1]||(a[1]=(...o)=>e.onMouseleave&&e.onMouseleave(...o))}),[p("div",{class:d([e.ui.container,e.ui.rounded,e.ui.ring])},[p("div",{class:d(e.ui.padding)},[p("div",{class:d(["flex gap-3",{"items-start":e.description||e.$slots.description,"items-center":!e.description&&!e.$slots.description}])},[e.icon?(s(),v(c,{key:0,name:e.icon,class:d(e.iconClass)},null,8,["name","class"])):m("",!0),e.avatar?(s(),v(i,g({key:1},{size:e.ui.avatar.size,...e.avatar},{class:e.ui.avatar.base}),null,16,["class"])):m("",!0),p("div",_,[p("p",{class:d(e.ui.title)},[T(e.$slots,"title",{title:e.title},()=>[U(N(e.title),1)])],2),e.description||e.$slots.description?(s(),y("p",{key:0,class:d(e.ui.description)},[T(e.$slots,"description",{description:e.description},()=>[U(N(e.description),1)])],2)):m("",!0),(e.description||e.$slots.description)&&e.actions.length?(s(),y("div",x,[(s(!0),y(j,null,z(e.actions,(o,u)=>(s(),v(l,g({key:u},{...e.ui.default.actionButton,...o},{onClick:A(f=>e.onAction(o),["stop"])}),null,16,["onClick"]))),128))])):m("",!0)]),p("div",ee,[!e.description&&!e.$slots.description&&e.actions.length?(s(),y("div",te,[(s(!0),y(j,null,z(e.actions,(o,u)=>(s(),v(l,g({key:u},{...e.ui.default.actionButton,...o},{onClick:A(f=>e.onAction(o),["stop"])}),null,16,["onClick"]))),128))])):m("",!0),e.closeButton?(s(),v(l,g({key:1,"aria-label":"Close"},{...e.ui.default.closeButton,...e.closeButton},{onClick:A(e.onClose,["stop"])}),null,16,["onClick"])):m("",!0)])],2)],2),e.timeout?(s(),y("div",{key:0,class:d(e.progressClass),style:J(e.progressStyle)},null,6)):m("",!0)],2)],16)]),_:3},16)}const fe=X(Z,[["render",oe]]);export{fe as default};
