import { o as V } from "./rolldown-runtime.js";
import { i as B, n as I, t as S } from "./vendor/react.js";
import { t as y } from "./Button.js";
import { t as s } from "./utils.js";
import { a as M, c as H, d as L, f as q, i as F, m as Z, n as $, o as J, p as W, s as X, t as G, u as K } from "./DialogTrigger.js";
import { t as Q } from "./DialogViewport.js";
var i = /* @__PURE__ */ V(B()), o = S();
function U(e) {
  const { children: t, open: a, defaultOpen: r = !1, onOpenChange: n, onOpenChangeComplete: d, actionsRef: c, handle: k, triggerId: u, defaultTriggerId: v = null } = e, h = Z(!0), x = !!h, l = M.useStore(k?.store, {
    open: r,
    openProp: a,
    activeTriggerId: v,
    triggerIdProp: u,
    modal: !0,
    disablePointerDismissal: !0,
    nested: x,
    role: "alertdialog"
  });
  l.useControlledProp("openProp", a), l.useControlledProp("triggerIdProp", u), l.useSyncedValue("nested", x), l.useContextCallback("onOpenChange", n), l.useContextCallback("onOpenChangeComplete", d);
  const O = l.useState("payload");
  J({
    store: l,
    actionsRef: c,
    parentContext: h?.store.context,
    isDrawer: !1,
    onOpenChange: n,
    triggerIdProp: u
  });
  const E = i.useMemo(() => ({ store: l }), [l]);
  return /* @__PURE__ */ (0, o.jsx)(F.Provider, {
    value: !1,
    children: /* @__PURE__ */ (0, o.jsx)(W.Provider, {
      value: E,
      children: typeof t == "function" ? t({ payload: O }) : t
    })
  });
}
var g = i.forwardRef(function({ ...t }, a) {
  return /* @__PURE__ */ (0, o.jsx)(U, {
    "data-slot": "alert-dialog",
    ...t
  });
});
g.displayName = "AlertDialog.Root";
var b = i.forwardRef(function({ ...t }, a) {
  return /* @__PURE__ */ (0, o.jsx)(G, {
    ref: a,
    "data-slot": "alert-dialog-trigger",
    ...t
  });
});
b.displayName = "AlertDialog.Trigger";
function f({ ...e }) {
  return /* @__PURE__ */ (0, o.jsx)(X, {
    "data-slot": "alert-dialog-portal",
    ...e
  });
}
f.displayName = "AlertDialog.Portal";
var m = i.forwardRef(function({ className: t, disableAnimation: a, disableBackdropBlur: r, ...n }, d) {
  return /* @__PURE__ */ (0, o.jsx)(q, {
    ref: d,
    "data-slot": "alert-dialog-backdrop",
    className: s("bg-background/80/10 fixed inset-0 isolate z-50", !a && "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 duration-100 motion-reduce:animate-none", !r && "supports-backdrop-filter:backdrop-blur-xs", t),
    ...n
  });
});
m.displayName = "AlertDialog.Backdrop";
var C = i.forwardRef(function({ className: t, children: a, ...r }, n) {
  return /* @__PURE__ */ (0, o.jsx)(Q, {
    ref: n,
    "data-slot": "alert-dialog-viewport",
    className: s("fixed inset-0 z-50 flex items-center justify-center p-4", t),
    ...r,
    children: a
  });
});
C.displayName = "AlertDialog.Viewport";
var D = i.forwardRef(function({ className: t, size: a = "default", disableAnimation: r, disableBackdropBlur: n, ...d }, c) {
  return /* @__PURE__ */ (0, o.jsxs)(f, { children: [/* @__PURE__ */ (0, o.jsx)(m, {
    disableAnimation: r,
    disableBackdropBlur: n
  }), /* @__PURE__ */ (0, o.jsx)(H, {
    ref: c,
    "data-slot": "alert-dialog-popup",
    "data-size": a,
    className: s("bg-background ring-foreground/10 gap-6 rounded-xl p-6 ring-1 shadow-lg data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none", !r && "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 duration-150 motion-reduce:animate-none", t),
    ...d
  })] });
});
D.displayName = "AlertDialog.Popup";
var w = i.forwardRef(function({ className: t, ...a }, r) {
  return /* @__PURE__ */ (0, o.jsx)("div", {
    ref: r,
    "data-slot": "alert-dialog-header",
    className: s("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]", t),
    ...a
  });
});
w.displayName = "AlertDialog.Header";
var N = i.forwardRef(function({ className: t, ...a }, r) {
  return /* @__PURE__ */ (0, o.jsx)("div", {
    ref: r,
    "data-slot": "alert-dialog-footer",
    className: s("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end", t),
    ...a
  });
});
N.displayName = "AlertDialog.Footer";
var j = i.forwardRef(function({ className: t, ...a }, r) {
  return /* @__PURE__ */ (0, o.jsx)("div", {
    ref: r,
    "data-slot": "alert-dialog-media",
    className: s("bg-muted mb-2 inline-flex size-16 items-center justify-center rounded-md sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-8 delight-bounce-in motion-reduce:!animate-none", t),
    ...a
  });
});
j.displayName = "AlertDialog.Media";
var A = i.forwardRef(function({ className: t, ...a }, r) {
  return /* @__PURE__ */ (0, o.jsx)($, {
    ref: r,
    "data-slot": "alert-dialog-title",
    className: s("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2 delight-stagger motion-reduce:!animate-none", t),
    ...a,
    style: { "--delight-delay": "50ms" }
  });
});
A.displayName = "AlertDialog.Title";
var z = i.forwardRef(function({ className: t, ...a }, r) {
  return /* @__PURE__ */ (0, o.jsx)(K, {
    ref: r,
    "data-slot": "alert-dialog-description",
    className: s("text-muted-foreground *:[a]:hover:text-foreground text-sm text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3 delight-stagger motion-reduce:!animate-none", t),
    ...a,
    style: { "--delight-delay": "100ms" }
  });
});
z.displayName = "AlertDialog.Description";
var P = i.forwardRef(function({ className: t, ...a }, r) {
  return /* @__PURE__ */ (0, o.jsx)(y, {
    ref: r,
    "data-slot": "alert-dialog-action",
    className: s(t),
    ...a
  });
});
P.displayName = "AlertDialog.Action";
var R = i.forwardRef(function({ className: t, appearance: a = "outline", variant: r = "secondary", size: n = "default", ...d }, c) {
  return /* @__PURE__ */ (0, o.jsx)(L, {
    ref: c,
    "data-slot": "alert-dialog-cancel",
    className: s(t),
    render: /* @__PURE__ */ (0, o.jsx)(y, {
      appearance: a,
      variant: r,
      size: n
    }),
    ...d
  });
});
R.displayName = "AlertDialog.Cancel";
var Y = Object.assign(g, {
  Root: g,
  Trigger: b,
  Portal: f,
  Backdrop: m,
  Viewport: C,
  Popup: D,
  Header: w,
  Footer: N,
  Title: A,
  Description: z,
  Action: P,
  Cancel: R,
  Media: j
}), ee = I(), p = {
  disableAnimation: "boolean",
  disableBackdropBlur: "boolean"
};
function _(e, t) {
  if (e !== null)
    switch (t) {
      case "number":
        return Number(e);
      case "boolean":
        return e !== "false" && e !== "0";
      case "json":
        try {
          return JSON.parse(e);
        } catch {
          return e;
        }
      default:
        return e;
    }
}
var T = class extends HTMLElement {
  _root = null;
  _childrenContainer = null;
  _props = {};
  _initialized = !1;
  connectedCallback() {
    setTimeout(() => this._initialize(), 0);
  }
  _initialize() {
    if (this._initialized) return;
    this._initialized = !0;
    const e = [];
    for (const a of Array.from(this.childNodes))
      a.nodeType === Node.TEXT_NODE && !a.textContent?.trim() || e.push(a);
    const t = document.createElement("div");
    for (t.style.display = "contents", this._childrenContainer = document.createElement("div"), this._childrenContainer.style.display = "contents", e.forEach((a) => this._childrenContainer.appendChild(a)); this.firstChild; ) this.removeChild(this.firstChild);
    this.appendChild(t), this._root = (0, ee.createRoot)(t), this._render();
  }
  disconnectedCallback() {
    this._root?.unmount(), this._root = null;
  }
  attributeChangedCallback(e, t, a) {
    this._render();
  }
  static get observedAttributes() {
    return Object.keys(p).map((e) => e.replace(/([A-Z])/g, "-$1").toLowerCase());
  }
  _setProp(e, t) {
    const a = p[e] || "string";
    this._props[e] = this._parseValue(t, a), this._render();
  }
  _parseValue(e, t) {
    if (t === "boolean" && typeof e == "boolean" || t === "number" && typeof e == "number" || t === "string" && typeof e == "string") return e;
    if (typeof e == "string") switch (t) {
      case "boolean":
        return e !== "false" && e !== "0" && e !== "";
      case "number":
        return Number(e);
      case "json":
        try {
          return JSON.parse(e);
        } catch {
          return e;
        }
      default:
        return e;
    }
    return e;
  }
  _getProp(e) {
    if (e in this._props) return this._props[e];
    const t = e.replace(/([A-Z])/g, "-$1").toLowerCase(), a = p[e] || "string";
    return _(this.getAttribute(t), a);
  }
  _render() {
    if (!this._root) return;
    const e = {};
    for (const [a, r] of Object.entries(p)) if (a in this._props) e[a] = this._props[a];
    else {
      const n = a.replace(/([A-Z])/g, "-$1").toLowerCase();
      e[a] = _(this.getAttribute(n), r);
    }
    const t = i.createElement(Y, {
      ...e,
      _hostElement: this
    });
    this._root.render(t);
  }
};
for (const e of Object.keys(p)) Object.defineProperty(T.prototype, e, {
  get() {
    return this._getProp(e);
  },
  set(t) {
    this._setProp(e, t);
  },
  enumerable: !0,
  configurable: !0
});
typeof customElements < "u" && !customElements.get("hf-alert-dialog") && customElements.define("hf-alert-dialog", T);
export {
  T as AlertDialogWC,
  T as default
};

//# sourceMappingURL=hf-alert-dialog.js.map