"use client";
import { jsx as e, jsxs as p } from "react/jsx-runtime";
import { forwardRef as C, createContext as _, useContext as G } from "react";
import { r as x } from "./resolve-variant-gw6eh7fa4st8ej7m.js";
import { R as L, U as O, Q as w, bx as v, by as R } from "./vendor-base-ui-elpbzr8xeffrz4h2.js";
import { c as r } from "./vendor-styling-ofvnbcuht98q88oo.js";
const N = {
  variant: {
    default: {
      classes: "ring-kumo-hairline",
      description: "Default radio appearance"
    },
    error: {
      classes: "ring-kumo-danger",
      description: "Error state for validation failures"
    }
  },
  appearance: {
    default: {
      classes: "",
      description: "Standard inline radio item"
    },
    card: {
      classes: "rounded-lg border border-kumo-hairline bg-kumo-base p-3 transition-colors hover:bg-kumo-tint has-[[data-checked]]:border-kumo-interact has-[[data-checked]]:bg-kumo-tint",
      description: "Choice card appearance with border, padding, and highlighted selection state"
    }
  }
}, f = {
  variant: "default",
  appearance: "default"
};
function F({
  variant: t = f.variant,
  appearance: a = f.appearance
} = {}) {
  return r(
    x(
      N.variant,
      t,
      f.variant
    ).classes,
    x(
      N.appearance,
      a,
      f.appearance
    ).classes
  );
}
const y = _({
  controlPosition: void 0,
  appearance: "default"
});
function S({
  className: t,
  disabled: a,
  variant: o = "default",
  appearance: s,
  label: n,
  description: i,
  value: c
}, l) {
  const { controlPosition: g, appearance: u } = G(y), d = (s ?? u) === "card", m = g ?? (d ? "end" : "start");
  return d ? /* @__PURE__ */ p(
    "label",
    {
      "data-kumo-component": "Radio",
      "data-kumo-part": "item-label",
      className: r(
        "m-0 group relative flex items-start gap-3 rounded-lg border border-kumo-hairline bg-kumo-base p-3 transition-colors has-[[data-checked]]:border-kumo-interact has-[[data-checked]]:bg-kumo-tint",
        m === "start" && "flex-row-reverse",
        o === "error" && "border-kumo-danger has-[[data-checked]]:border-kumo-danger has-[[data-checked]]:bg-kumo-base",
        a ? "cursor-not-allowed opacity-50" : r(
          "has-[[data-disabled]]:cursor-not-allowed has-[[data-disabled]]:opacity-50 cursor-pointer",
          o !== "error" && "hover:not-has-[[data-disabled]]:bg-kumo-tint"
        ),
        t
      ),
      children: [
        /* @__PURE__ */ p("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
          /* @__PURE__ */ e("span", { className: "text-base font-medium text-kumo-default", children: n }),
          i && /* @__PURE__ */ e("span", { className: "text-sm text-kumo-subtle", children: i })
        ] }),
        /* @__PURE__ */ e(
          v,
          {
            ref: l,
            "data-kumo-component": "Radio",
            "data-kumo-part": "item",
            value: c,
            disabled: a,
            className: r(
              "relative mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border-0 bg-kumo-base ring ring-2 focus:outline-none focus:ring-kumo-focus focus-visible:ring-2 focus-visible:ring-kumo-brand",
              o === "error" ? "ring-kumo-danger" : "ring-kumo-line",
              !a && o !== "error" && "group-hover:ring-kumo-hairline focus-visible:outline-offset-3",
              !a && o === "error" && "focus-visible:outline-offset-3",
              "data-[checked]:bg-kumo-contrast"
            ),
            children: /* @__PURE__ */ e(
              R,
              {
                keepMounted: !0,
                className: "flex items-center justify-center",
                children: /* @__PURE__ */ e("span", { className: "h-2 w-2 rounded-full bg-kumo-base" })
              }
            )
          }
        )
      ]
    }
  ) : /* @__PURE__ */ p(
    "label",
    {
      "data-kumo-component": "Radio",
      "data-kumo-part": "item-label",
      className: r(
        "m-0 group relative inline-flex items-start gap-2",
        // "start" (default): radio before label
        // "end": label before radio using flex-row-reverse
        m === "end" && "flex-row-reverse justify-end",
        a ? "cursor-not-allowed opacity-50" : "cursor-pointer",
        t
      ),
      children: [
        /* @__PURE__ */ e(
          v,
          {
            ref: l,
            "data-kumo-component": "Radio",
            "data-kumo-part": "item",
            value: c,
            disabled: a,
            className: r(
              "relative mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border-0 bg-kumo-base ring focus:outline-none after:absolute after:-inset-x-3 after:-inset-y-2",
              o === "error" ? "ring-kumo-danger" : "ring-kumo-line",
              !a && o !== "error" && "group-hover:ring-kumo-hairline focus:ring-kumo-focus focus:ring-2 focus-visible:ring-2 focus-visible:ring-kumo-brand focus-visible:outline-offset-3",
              !a && o === "error" && "focus:ring-kumo-focus focus:ring-2 focus-visible:ring-2 focus-visible:ring-kumo-brand focus-visible:outline-offset-3",
              "data-[checked]:bg-kumo-contrast"
            ),
            children: /* @__PURE__ */ e(
              R,
              {
                keepMounted: !0,
                className: "flex items-center justify-center",
                children: /* @__PURE__ */ e("span", { className: "h-2 w-2 rounded-full bg-kumo-base" })
              }
            )
          }
        ),
        /* @__PURE__ */ e("span", { className: "text-base text-kumo-default", children: n })
      ]
    }
  );
}
const A = C(S);
A.displayName = "Radio.Item";
function I({ children: t, className: a }) {
  return /* @__PURE__ */ e(
    w,
    {
      className: r("text-base font-medium text-kumo-default", a),
      children: t
    }
  );
}
I.displayName = "Radio.Legend";
function k({
  legend: t,
  children: a,
  orientation: o = "vertical",
  appearance: s = "default",
  error: n,
  description: i,
  defaultValue: c,
  value: l,
  onValueChange: g,
  disabled: u,
  controlPosition: h,
  name: d,
  className: m
}) {
  return /* @__PURE__ */ e(y.Provider, { value: { controlPosition: h, appearance: s }, children: /* @__PURE__ */ e(
    L,
    {
      defaultValue: c,
      value: l,
      onValueChange: (b, j) => g?.(b, j),
      disabled: u,
      name: d,
      children: /* @__PURE__ */ p(
        O,
        {
          disabled: u,
          className: r("flex flex-col gap-4", m),
          children: [
            t && /* @__PURE__ */ e(w, { className: "text-base font-medium text-kumo-default", children: t }),
            /* @__PURE__ */ e(
              "div",
              {
                className: r(
                  o === "vertical" ? r("flex flex-col", s === "card" ? "gap-3" : "gap-2") : s === "card" ? "grid grid-cols-2 gap-3" : "flex flex-row flex-wrap gap-2"
                ),
                children: a
              }
            ),
            n && /* @__PURE__ */ e("p", { className: "text-sm text-kumo-danger", children: n }),
            i && /* @__PURE__ */ e("p", { className: "text-sm text-kumo-subtle", children: i })
          ]
        }
      )
    }
  ) });
}
k.displayName = "Radio.Group";
const K = Object.assign(k, {
  Item: A,
  Group: k,
  Legend: I
});
export {
  N as K,
  K as R,
  k as a,
  f as b,
  F as r
};
//# sourceMappingURL=radio-ejey7i6r4tq314av.js.map
