/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const index=require("./index-f0fde70b.js"),i18n=require("./i18n-9f4d1694.js"),dev_utils=require("./dev.utils-487b14ca.js"),componentNames=require("./component-names-4cf3e7f5.js");require("./index-cb2ce614.js"),require("./i18n-c3fa5bd7.js");const InternalToast=({toastState:t,onClose:s,key:e})=>index.h("div",{class:`toast ${t.status}`,key:e},index.h(componentNames.KolAlertTag,{class:"alert",_alert:!0,_label:t.toast.label,_level:0,_hasCloser:!0,_type:t.toast.type,_variant:t.toast.alertVariant||"card",_on:{onClose:s}},index.h("div",{ref:e=>{"function"==typeof t.toast.render&&e&&t.toast.render(e,{close:()=>s()})}},"string"==typeof t.toast.description?t.toast.description:null))),defaultStyleCss="@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}",KolToastContainerDefaultStyle0=defaultStyleCss,TRANSITION_TIMEOUT=300,KolToastContainer=class{constructor(t){index.registerInstance(this,t),this.state={_toastStates:[]}}async enqueue(t){const s={toast:t,status:"adding",id:`toast-${dev_utils.nonce()}`};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))})}),300),()=>{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))})}),300)}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:[]})}),300)}render(){return index.h(index.Host,{key:"f07fd5109ed0d409e24587c68ff6b6ac22029c77",class:"kol-toast-container"},this.state._toastStates.length>1&&index.h(componentNames.KolButtonTag,{_label:i18n.translate("kol-toast-close-all"),class:"close-all",_on:{onClick:()=>{this.closeAll()}}}),this.state._toastStates.map((t=>index.h(InternalToast,{toastState:t,onClose:()=>this.handleClose(t),key:t.id}))))}};KolToastContainer.style={default:KolToastContainerDefaultStyle0},exports.kol_toast_container=KolToastContainer;