"use client";
import { radioVariants } from '@heroui/styles';
import React__default, { createContext, useContext } from 'react';
import { Radio } from 'react-aria-components';
import { composeTwRenderProps, composeSlotClassName } from '../../utils/compose.js';
import { jsx } from 'react/jsx-runtime';

const RadioContext = /*#__PURE__*/createContext({});

/* -------------------------------------------------------------------------------------------------
 * Radio Root
 * -----------------------------------------------------------------------------------------------*/

const RadioRoot = ({
  children,
  className,
  ...props
}) => {
  const slots = React__default.useMemo(() => radioVariants(), []);
  return /*#__PURE__*/jsx(Radio, {
    "data-slot": "radio",
    ...props,
    className: composeTwRenderProps(className, slots.base()),
    children: values => /*#__PURE__*/jsx(RadioContext, {
      value: {
        slots,
        state: values
      },
      children: typeof children === "function" ? children(values) : children
    })
  });
};

/* -------------------------------------------------------------------------------------------------
 * Radio Control
 * -----------------------------------------------------------------------------------------------*/

const RadioControl = ({
  children,
  className,
  ...props
}) => {
  const {
    slots
  } = useContext(RadioContext);
  return /*#__PURE__*/jsx("span", {
    className: composeSlotClassName(slots?.control, className),
    "data-slot": "radio-control",
    ...props,
    children: children
  });
};

/* -------------------------------------------------------------------------------------------------
 * Radio Indicator
 * -----------------------------------------------------------------------------------------------*/

const RadioIndicator = ({
  children,
  className,
  ...props
}) => {
  const {
    slots,
    state
  } = useContext(RadioContext);
  const content = typeof children === "function" ? children(state ?? {}) : children;
  return /*#__PURE__*/jsx("span", {
    "aria-hidden": "true",
    className: composeSlotClassName(slots?.indicator, className),
    "data-slot": "radio-indicator",
    ...props,
    children: content
  });
};

/* -------------------------------------------------------------------------------------------------
 * Radio Content
 * -----------------------------------------------------------------------------------------------*/

const RadioContent = ({
  children,
  className,
  ...props
}) => {
  const {
    slots
  } = useContext(RadioContext);
  return /*#__PURE__*/jsx("div", {
    className: composeSlotClassName(slots?.content, className),
    "data-slot": "radio-content",
    ...props,
    children: children
  });
};

export { RadioContent, RadioControl, RadioIndicator, RadioRoot };
