import {
  RadioCards
} from "./chunk-6IVCARWS.js";
import {
  Radio
} from "./chunk-FPD73OHW.js";
import {
  Flex
} from "./chunk-25HMMI7R.js";
import {
  __objRest,
  __spreadProps,
  __spreadValues
} from "./chunk-2NMEKWO5.js";

// src/molecules/radio-button-card.tsx
import {
  createContext,
  useCallback,
  useContext,
  useState,
  Fragment
} from "react";
import { jsx, jsxs } from "react/jsx-runtime";
var RadioCardContext = createContext({});
function Root(props) {
  const [value, setValue] = useState(props.value || props.defaultValue);
  const onValueChange = useCallback(
    (v) => {
      var _a;
      setValue(v);
      (_a = props.onValueChange) == null ? void 0 : _a.call(props, v);
    },
    [props]
  );
  return /* @__PURE__ */ jsx(RadioCardContext.Provider, { value: __spreadProps(__spreadValues({}, props), { value }), children: /* @__PURE__ */ jsx(RadioCards.Root, __spreadProps(__spreadValues({}, props), { onValueChange })) });
}
function Item(_a) {
  var _b = _a, {
    children
  } = _b, itemRest = __objRest(_b, [
    "children"
  ]);
  const _a2 = useContext(RadioCardContext), {
    value,
    justify,
    RadioWrapper = Fragment
  } = _a2, rootRest = __objRest(_a2, [
    "value",
    "justify",
    "RadioWrapper"
  ]);
  return /* @__PURE__ */ jsx(RadioCards.Item, __spreadProps(__spreadValues({}, itemRest), { children: /* @__PURE__ */ jsxs(Flex, { align: "center", justify: justify || "between", width: "100%", children: [
    children,
    /* @__PURE__ */ jsx(RadioWrapper, { children: /* @__PURE__ */ jsx(
      Radio,
      {
        checked: itemRest.value === value,
        disabled: rootRest.disabled,
        value: itemRest.value
      }
    ) })
  ] }) }));
}
var RadioButtonCard = {
  Root,
  Item
};

export {
  RadioButtonCard
};
//# sourceMappingURL=chunk-SLXXCM56.js.map