1import{X as e,dt as t,ft as n,lt as r,q as i,st as a}from"./DX0lVUTv.js";function o(...e){return e.filter(Boolean).join(` `)}var s=typeof document<`u`,c=0;function l(e){return typeof e?.id==`number`||typeof e?.id==`string`&&e.id.length>0?e.id:c++}var u=class{#e=t(a([]));get toasts(){return i(this.#e)}set toasts(e){r(this.#e,e,!0)}#t=t(a([]));get heights(){return i(this.#t)}set heights(e){r(this.#t,e,!0)}#n=new Map;#r=e=>{let t=this.toasts.findIndex(t=>t.id===e);return t===-1?null:t};#i=e=>this.heights.findIndex(t=>t.toastId===e);addToast=e=>{s&&this.toasts.unshift(e)};updateToast=({id:e,data:t,type:n,message:r})=>{let i=this.toasts.findIndex(t=>t.id===e),a=this.toasts[i];this.toasts[i]={...a,...t,id:e,title:r,type:n,dismiss:!1,delete:!1,updated:!0}};markDismissed=e=>{let t=this.#r(e);if(t===null)return;let n=this.toasts[t];n&&(!n.dismiss||!n.delete)&&(this.toasts[t]={...n,dismiss:!0,delete:!0})};scheduleRemoval=(e,t)=>{this.cancelRemoval(e),this.#n.set(e,setTimeout(()=>{this.#n.delete(e),this.remove(e)},t))};cancelRemoval=e=>{let t=this.#n.get(e);t!==void 0&&(clearTimeout(t),this.#n.delete(e))};create=t=>{let{message:n,...r}=t,i=l(t),a=t.dismissible===void 0?t.dismissable===void 0||t.dismissable:t.dismissible,o=t.type===void 0?`default`:t.type;return e(()=>{this.cancelRemoval(i);let e=this.toasts.find(e=>e.id===i);e?.dismiss||e?.delete?(this.remove(i),this.addToast({...r,id:i,title:n,dismissible:a,type:o,updated:!0})):e?this.updateToast({id:i,data:t,type:o,message:n,dismissible:a}):this.addToast({...r,id:i,title:n,dismissible:a,type:o})}),i};dismiss=t=>(e(()=>{if(t===void 0){this.toasts=this.toasts.map(e=>e.dismiss?e:{...e,dismiss:!0});return}let e=this.toasts.findIndex(e=>e.id===t);this.toasts[e]&&(this.toasts[e]={...this.toasts[e],dismiss:!0})}),t);remove=e=>{if(e===void 0){this.toasts=[];return}let t=this.#r(e);if(t!==null)return this.toasts.splice(t,1),e};message=(e,t)=>this.create({...t,type:`default`,message:e});error=(e,t)=>this.create({...t,type:`error`,message:e});success=(e,t)=>this.create({...t,type:`success`,message:e});info=(e,t)=>this.create({...t,type:`info`,message:e});warning=(e,t)=>this.create({...t,type:`warning`,message:e});loading=(e,t)=>
1this.create({...t,type:`loading`,message:e});promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:typeof t.loading==`string`?t.loading:t.loading()}));let r=e instanceof Promise?e:e(),i=n!==void 0;return r.then(e=>{if(typeof e==`object`&&e&&`ok`in e&&typeof e.ok==`boolean`&&!e.ok){i=!1;let t=d(e);this.create({id:n,type:`error`,message:t})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?t.success(e):t.success;this.create({id:n,type:`success`,message:r})}}).catch(e=>{if(t.error!==void 0){i=!1;let r=typeof t.error==`function`?t.error(e):t.error;this.create({id:n,type:`error`,message:r})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally?.()}),n};custom=(e,t)=>{let n=l(t);return this.create({component:e,...t,id:n}),n};removeHeight=e=>{this.heights=this.heights.filter(t=>t.toastId!==e)};setHeight=t=>{e(()=>{let e=this.#i(t.toastId);if(e!==-1){this.heights[e]=t;return}let n=new Map(this.toasts.map((e,t)=>[e.id,t])),r=n.get(t.toastId)??-1,i=this.heights.findIndex(e=>(n.get(e.toastId)??1/0)>r);i===-1?this.heights.push(t):this.heights.splice(i,0,t)})};reset=()=>{this.toasts=[],this.heights=[],this.#n.forEach(e=>clearTimeout(e)),this.#n.clear()}};function d(e){return e&&typeof e==`object`&&`status`in e?`HTTP error! Status: ${e.status}`:`Error! ${e}`}var f=new u;function p(e,t){return f.message(e,t)}var m=class{#e=n(()=>f.toasts.filter(e=>!e.dismiss));get toasts(){return i(this.#e)}},h=Object.assign(p,{success:f.success,info:f.info,warning:f.warning,error:f.error,custom:f.custom,message:f.message,promise:f.promise,dismiss:f.dismiss,loading:f.loading,getActiveToasts:()=>f.toasts.filter(e=>!e.dismiss)});export{o as i,h as n,f as r,m as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.