import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-92f6d7ee.js';

const bsToastCss = ".bs-toast{background-color:var(--bs-bg-base-elevated);border-top:4px solid var(--bs-blue-base);bottom:1.5rem;box-shadow:var(--bs-shadow-contentMedium);left:0;margin-left:1.5rem;margin-right:1.5rem;opacity:0;position:fixed;right:0;transform:translate(0, calc(100% + 1.5rem));transition-duration:200ms;transition-property:transform, opacity;transition-timing-function:ease;width:clamp(17rem, 100vw - 3rem, 25rem);z-index:999}.bs-toast:where([data-stacked]){bottom:auto;left:auto;position:static;right:auto;z-index:auto}.bs-toast:where([data-shown]){opacity:1;transform:translate(0, 0)}.bs-toast-header{align-items:center;color:var(--bs-ink-base);display:flex;gap:0.5rem;padding:1rem}.bs-toast-header :where(.bs-toast-header-icon){color:var(--bs-blue-base)}.bs-toast-header :where(h5){font-weight:400}.bs-toast-body{border-bottom:1px solid var(--bs-border);color:var(--bs-ink-light);padding-bottom:1rem;padding-left:1rem;padding-right:1rem}.bs-toast-actions{display:flex;flex-direction:row;gap:1rem;justify-content:flex-end;padding-bottom:0.5rem;padding-left:1rem;padding-right:1rem;padding-top:0.5rem}.bs-toast-actions:where([data-stacked]){flex-direction:column-reverse}.bs-toast:where([data-variant^=\"warning\"]){border-top:4px solid var(--bs-orange-warning)}.bs-toast:where([data-variant^=\"warning\"]) :where(.bs-toast-header .bs-toast-header-icon){color:var(--bs-orange-warning)}.bs-toast:where([data-variant^=\"positive\"]){border-top:4px solid var(--bs-purple-400)}.bs-toast:where([data-variant^=\"positive\"]) :where(.bs-toast-header .bs-toast-header-icon){color:var(--bs-purple-400)}:where(.dark) .bs-toast:where([data-variant^=\"positive\"]){border-top:4px solid var(--bs-purple-200)}:where(.dark) .bs-toast:where([data-variant^=\"positive\"]) :where(.bs-toast-header .bs-toast-header-icon){color:var(--bs-purple-200)}.bs-toast:where([data-variant^=\"negative\"]){border-top:4px solid var(--bs-red-400)}.bs-toast:where([data-variant^=\"negative\"]) :where(.bs-toast-header .bs-toast-header-icon){color:var(--bs-red-400)}@media (min-width: 440px){.bs-toast{left:auto;margin-left:0;margin-right:0;opacity:0;right:1.5rem;transform:translate(calc(100% + 1.5rem), 0)}.bs-toast:where([data-shown]){opacity:1;transform:translate(0, 0)}.bs-toast-actions:where([data-stacked]){flex-direction:row}}bs-toast{display:block}";

const BsToast = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.dismiss = createEvent(this, "dismiss", 7);
    this.enterend = createEvent(this, "enterend", 3);
    this.leaveend = createEvent(this, "leaveend", 3);
    this.toastId = undefined;
    this.variant = undefined;
    this.stacked = false;
    this.duration = 10000;
    this.enterControlled = false;
    this.enterTrigger = false;
    this.leaveTrigger = false;
  }
  /** Initially pass down variant to children. */
  componentDidLoad() {
    this.onVariantChange(this.variant);
  }
  /** Updates variant of children if prop changes */
  onVariantChange(newVal) {
    // Pass down variant to header
    const headerChild = this.hostEl.querySelector('bs-toast-header');
    headerChild === null || headerChild === void 0 ? void 0 : headerChild.setAttribute('variant', newVal);
  }
  handleDismiss() {
    // Clear the dismiss timer to prevent unnecessary side-effects
    if (this.autoDismissTimer) {
      clearTimeout(this.autoDismissTimer);
      this.autoDismissTimer = undefined;
    }
    this.dismiss.emit(this.toastId);
  }
  /** Set auto-dismissal after the toast has fully entered. */
  handleEnterEnd() {
    if (this.duration > 0) {
      this.autoDismissTimer = setTimeout(() => this.handleDismiss(), this.duration);
    }
    this.enterend.emit();
  }
  render() {
    return (h(Host, null, h("bs-transition", { enterAttribute: 'data-shown', enterDuration: 200, enterControlled: this.enterControlled, enterTrigger: this.enterTrigger, leaveTrigger: this.leaveTrigger, onEnterend: () => this.handleEnterEnd(), onLeaveend: () => this.leaveend.emit() }, h("div", { class: "bs-toast", "data-variant": this.variant, "data-stacked": this.stacked, "aria-role": "alert" }, h("slot", null)))));
  }
  get hostEl() { return getElement(this); }
  static get watchers() { return {
    "variant": ["onVariantChange"]
  }; }
};
BsToast.style = bsToastCss;

export { BsToast as bs_toast };

//# sourceMappingURL=bs-toast.entry.js.map