import { r as n, c as o, h as s, H as r } from "./index.61732cef.js";
import { c } from "./index-orsBiyT_.fc4357c3.js";
import { D as d } from "./media-query.service-CCYT6DU8.f0931fdc.js";
import "react";
import "react-dom";
import "./utils-CCck-DTo.e4e43b6a.js";
const h = () => ":host{display:flex}:host *{box-sizing:border-box}.toast{display:flex;width:100%;max-width:28rem;padding:var(--s-space-16);border-radius:var(--s-border-radius-sm);color:var(--s-text-on-status);background-color:var(--s-surface-neutral-default);box-shadow:var(--s-shadow-level-2)}.toast--intent-critical{background-color:var(--s-surface-critical-default)}.toast--intent-success{background-color:var(--s-surface-success-default)}.toast__icon{display:inline-flex;width:1.5rem;height:1.5rem;margin-right:0.625rem;flex-shrink:0}.toast__icon ::part(icon){color:var(--s-icon-on-status)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.toast__icon{width:1.25rem;height:1.25rem}}.toast__content{flex-grow:1;line-height:var(--s-line-height-base);text-align:left;align-self:flex-start}.toast__content ::part(link){color:var(--text-default)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.toast__content{font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}.toast__action-button{--swirl-plain-button-text-color-default:var(--s-text-on-status);--swirl-plain-button-text-color-hovered:var(--s-text-on-status);--swirl-plain-button-text-color-pressed:var(--s-text-on-status);margin-left:var(--s-space-16)}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.toast__action-button{margin-top:-1px}}.toast__dismiss-button{display:inline-flex;min-width:1.5rem;height:1.5rem;margin-left:var(--s-space-16);padding:0;flex-shrink:0;justify-content:center;align-items:center;border:none;color:var(--s-text-on-status);background-color:transparent;font:inherit;font-weight:var(--s-font-weight-semibold);cursor:pointer}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.toast__dismiss-button{margin-top:calc(-1 * var(--s-space-2))}}.toast__dismiss-button ::part(icon){color:var(--s-icon-on-status)}", l = class {
  constructor(t) {
    n(this, t), this.action = o(this, "action", 7), this.dismiss = o(this, "dismiss", 7), this.accessibleDismissLabel = "Dismiss", this.intent = "default", this.mediaQueryUnsubscribe = () => {
    }, this.onAction = () => {
      this.action.emit(this.toastId);
    }, this.onDismiss = () => {
      this.dismiss.emit(this.toastId);
    };
  }
  watchDuration() {
    this.startTimer();
  }
  componentDidLoad() {
    this.startTimer(), this.mediaQueryUnsubscribe = d.subscribe((t) => {
      this.forceIconProps(t);
    });
  }
  disconnectedCallback() {
    this.mediaQueryUnsubscribe();
  }
  forceIconProps(t) {
    var a;
    const i = (a = this.iconEl) == null ? void 0 : a.children[0], e = this.dismissIconEl;
    i == null || i.setAttribute("size", t ? "20" : "24"), e == null || e.setAttribute("size", t ? "20" : "24");
  }
  startTimer() {
    this.clearTimer(), !(this.duration === void 0 || this.duration === 1 / 0) && (this.timeout = setTimeout(() => {
      this.dismiss.emit(this.toastId);
    }, this.duration));
  }
  clearTimer() {
    !Boolean(this.timeout) || (clearTimeout(this.timeout), this.timeout = void 0);
  }
  render() {
    const t = c("toast", `toast--intent-${this.intent}`);
    return s(r, { key: "9a60bec945df3c15a823ee9350f7cf5eb7ec6c76" }, s("div", { key: "5fbf54732841cc7f56b480076e01c2c8130f62db", class: t }, this.icon && s("span", { key: "32b7f3d945eca48dd6e06e1c09e6a8f251d95a1a", class: "toast__icon", innerHTML: this.icon, part: "toast__icon", ref: (i) => this.iconEl = i }), s("span", { key: "302223f8a851f542bff53fa2c77e14e8a8e6a6a9", class: "toast__content", innerHTML: this.content, part: "toast__content" }, s("slot", { key: "621340dbff7ac7b350776f323062ff6a6e0edb29" })), this.actionLabel && s("swirl-button", { key: "e3925dbdf646a44cc99cf4957e2d09a3c8c94644", class: "toast__action-button", label: this.actionLabel, onClick: this.onAction, variant: "plain" }), s("button", { key: "b53ad57748fbe8665c3aa729949d5a49992008b8", "aria-label": this.dismissLabel || this.accessibleDismissLabel, class: "toast__dismiss-button", onClick: this.onDismiss, type: "button" }, this.dismissLabel, !Boolean(this.dismissLabel) && s("swirl-icon-close", { key: "60429b81feafb9668ad4ce1e10426018bab30169", ref: (i) => this.dismissIconEl = i }))));
  }
  static get watchers() {
    return {
      duration: [{
        watchDuration: 0
      }]
    };
  }
};
l.style = h();
export {
  l as swirl_toast
};
