import { r as n, c as o, h as s, H as r } from "./index.e6beb8d9.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: "755346b31178e4af07834e1d95bf0241faedfc89" }, s("div", { key: "baf1e4f5691fcfc21b11c35f6584e951a9039c43", class: t }, this.icon && s("span", { key: "af1d9cd2a9ccb33d4d473e2e8139018a55074adc", class: "toast__icon", innerHTML: this.icon, part: "toast__icon", ref: (i) => this.iconEl = i }), s("span", { key: "9bf836f9e64a343c76527c09868afb93b89dc1b6", class: "toast__content", innerHTML: this.content, part: "toast__content" }, s("slot", { key: "be669cb508dd92b6d8dbc7cc416a147ba40a0bbe" })), this.actionLabel && s("swirl-button", { key: "754a0a06417dfde70903c6099e3150913d1927c9", class: "toast__action-button", label: this.actionLabel, onClick: this.onAction, variant: "plain" }), s("button", { key: "822e778a495dbfb52d872d461c7275f76bcf0ead", "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: "ed76a1a28b11be0da4973afb0669a2935d768bcf", ref: (i) => this.dismissIconEl = i }))));
  }
  static get watchers() {
    return {
      duration: [{
        watchDuration: 0
      }]
    };
  }
};
l.style = h();
export {
  l as swirl_toast
};
