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