/*!
 * KoliBri - The accessible HTML-Standard
 */
import{h as t,r as s,H as e}from"./index-9ca46203.js";import{t as o}from"./i18n-3bac791b.js";import{n as a}from"./dev.utils-e81fbe6f.js";import{k as n,n as i}from"./component-names-61247f2f.js";import"./index-0489af72.js";import"./i18n-fddf0324.js";const c=({toastState:s,onClose:a,key:e})=>t("div",{class:`toast ${s.status}`,key:e},t(n,{class:"alert",_alert:!0,_label:s.toast.label,_level:0,_hasCloser:!0,_type:s.toast.type,_variant:s.toast.alertVariant||"card",_on:{onClose:a}},t("div",{ref:t=>{"function"==typeof s.toast.render&&t&&s.toast.render(t,{close:()=>a()})}},"string"==typeof s.toast.description?s.toast.description:null))),l="@layer kol-component {\n  :host {\n    display: flex;\n    flex-direction: column;\n    position: fixed;\n    z-index: 200;\n  }\n  .close-all {\n    align-self: flex-end;\n  }\n}",r=l,f=300,h=class{constructor(t){s(this,t),this.state={_toastStates:[]}}async enqueue(t){const s={toast:t,status:"adding",id:`toast-${a()}`};return this.state=Object.assign(Object.assign({},this.state),{_toastStates:[s,...this.state._toastStates]}),setTimeout((()=>{this.state=Object.assign(Object.assign({},this.state),{_toastStates:this.state._toastStates.map((t=>t.id===s.id?Object.assign(Object.assign({},t),{status:"settled"}):t))})}),f),()=>{this.handleClose(s)}}handleClose(t){this.state=Object.assign(Object.assign({},this.state),{_toastStates:this.state._toastStates.map((s=>(s.id===t.id&&(s.status="removing"),s)))}),setTimeout((()=>{this.state=Object.assign(Object.assign({},this.state),{_toastStates:this.state._toastStates.filter((s=>s.id!==t.id))})}),f)}async closeAll(){this.state=Object.assign(Object.assign({},this.state),{_toastStates:this.state._toastStates.map((t=>Object.assign(Object.assign({},t),{status:"removing"})))}),setTimeout((()=>{this.state=Object.assign(Object.assign({},this.state),{_toastStates:[]})}),f)}render(){return t(e,{key:"f07fd5109ed0d409e24587c68ff6b6ac22029c77",class:"kol-toast-container"},this.state._toastStates.length>1&&t(i,{_label:o("kol-toast-close-all"),class:"close-all",_on:{onClick:()=>{this.closeAll()}}}),this.state._toastStates.map((s=>t(c,{toastState:s,onClose:()=>this.handleClose(s),key:s.id}))))}};h.style={default:r};export{h as kol_toast_container};