"use client";
import { jsx as e, jsxs as f } from "react/jsx-runtime";
import { forwardRef as j, createContext as I, useContext as C } from "react";
import { c as o } from "./cn-ct4n7r74mh8y0f48.js";
import { R as G, U as L, Q as R, br as k, bs as x } from "./vendor-base-ui-ie71jahf0czyf58j.js";
const v = {
  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"
    }
  }
}, N = {
  variant: "default",
  appearance: "default"
};
function M({
  variant: t = N.variant,
  appearance: r = N.appearance
} = {}) {
  return o(
    v.variant[t].classes,
    v.appearance[r].classes
  );
}
const w = I({
  controlPosition: void 0,
  appearance: "default"
}), y = j(
  ({
    className: t,
    disabled: r,
    variant: a = "default",
    appearance: s,
    label: n,
    description: i,
    value: c
  }, l) => {
    const { controlPosition: g, appearance: u } = C(w), d = (s ?? u) === "card", m = g ?? (d ? "end" : "start");
    return d ? /* @__PURE__ */ f(
      "label",
      {
        className: o(
          "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",
          a === "error" && "border-kumo-danger has-[[data-checked]]:border-kumo-danger has-[[data-checked]]:bg-kumo-base",
          r ? "cursor-not-allowed opacity-50" : o(
            "has-[[data-disabled]]:cursor-not-allowed has-[[data-disabled]]:opacity-50 cursor-pointer",
            a !== "error" && "hover:not-has-[[data-disabled]]:bg-kumo-tint"
          ),
          t
        ),
        children: [
          /* @__PURE__ */ f("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(
            k,
            {
              ref: l,
              value: c,
              disabled: r,
              className: o(
                "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",
                a === "error" ? "ring-kumo-danger" : "ring-kumo-line",
                !r && a !== "error" && "group-hover:ring-kumo-hairline focus-visible:outline-offset-3",
                !r && a === "error" && "focus-visible:outline-offset-3",
                "data-[checked]:bg-kumo-contrast"
              ),
              children: /* @__PURE__ */ e(
                x,
                {
                  keepMounted: !0,
                  className: "flex items-center justify-center",
                  children: /* @__PURE__ */ e("span", { className: "h-2 w-2 rounded-full bg-kumo-base" })
                }
              )
            }
          )
        ]
      }
    ) : /* @__PURE__ */ f(
      "label",
      {
        className: o(
          "m-0 group relative inline-flex items-center gap-2",
          // "start" (default): radio before label
          // "end": label before radio using flex-row-reverse
          m === "end" && "flex-row-reverse justify-end",
          r ? "cursor-not-allowed opacity-50" : "cursor-pointer",
          t
        ),
        children: [
          /* @__PURE__ */ e(
            k,
            {
              ref: l,
              value: c,
              disabled: r,
              className: o(
                "relative flex h-4 w-4 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",
                a === "error" ? "ring-kumo-danger" : "ring-kumo-line",
                !r && a !== "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",
                !r && a === "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(
                x,
                {
                  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 })
        ]
      }
    );
  }
);
y.displayName = "Radio.Item";
function A({ children: t, className: r }) {
  return /* @__PURE__ */ e(
    R,
    {
      className: o("text-base font-medium text-kumo-default", r),
      children: t
    }
  );
}
A.displayName = "Radio.Legend";
function p({
  legend: t,
  children: r,
  orientation: a = "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(w.Provider, { value: { controlPosition: h, appearance: s }, children: /* @__PURE__ */ e(
    G,
    {
      defaultValue: c,
      value: l,
      onValueChange: (b) => g?.(b),
      disabled: u,
      name: d,
      children: /* @__PURE__ */ f(
        L,
        {
          disabled: u,
          className: o("flex flex-col gap-4", m),
          children: [
            t && /* @__PURE__ */ e(R, { className: "text-base font-medium text-kumo-default", children: t }),
            /* @__PURE__ */ e(
              "div",
              {
                className: o(
                  a === "vertical" ? o("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: r
              }
            ),
            n && /* @__PURE__ */ e("p", { className: "text-sm text-kumo-danger", children: n }),
            i && /* @__PURE__ */ e("p", { className: "text-sm text-kumo-subtle", children: i })
          ]
        }
      )
    }
  ) });
}
p.displayName = "Radio.Group";
const P = Object.assign(p, {
  Item: y,
  Group: p,
  Legend: A
});
export {
  v as K,
  P as R,
  p as a,
  N as b,
  M as r
};
//# sourceMappingURL=radio-datzh3pilz8ojak1.js.map
