"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var RadioListElement_exports = {};
__export(RadioListElement_exports, {
  Label: () => Label,
  default: () => RadioListElement_default
});
module.exports = __toCommonJS(RadioListElement_exports);
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import_Text = __toESM(require("../../asorted/Text"));
var import_Flex = __toESM(require("../../layout/Flex"));
var import_helpers = require("../../../styles/helpers");
var import_index = require("./index");
const Label = (0, import_styled_components.default)(import_Text.default)`
  color: ${(p) => p.disabled ? p.theme.colors.neutral.c50 : p.checked ? p.theme.colors.primary.c90 : p.theme.colors.neutral.c100};
`;
const Container = (0, import_styled_components.default)(import_Flex.default)`
  cursor: ${(p) => p.disabled ? "" : "pointer"};
  justify-content: center;
  align-items: center;
  background-color: ${(p) => p.checked ? p.theme.colors.primary.c20 : ""};
  border: 1px solid ${(p) => p.checked ? p.theme.colors.primary.c50 : p.theme.colors.neutral.c40};
  border-radius: ${(p) => `${p.theme.radii[2]}px`};
  padding: ${(p) => p.theme.space[6]}px;

  &:hover {
    border-color: ${(p) => p.disabled || p.checked ? "" : p.theme.colors.primary.c80};
  }
`;
const Input = import_styled_components.default.input`
  position: relative;
  appearance: none;
  &:focus ~ ${Container} {
    box-shadow: 0px 0px 0px 4px ${(p) => (0, import_helpers.rgba)(p.theme.colors.primary.c60, 0.48)};
  }
`;
const RadioListElement = import_styled_components.default.label.attrs({ tabIndex: -1 })`
  display: inline-flex;
  align-items: center;
`;
const ListElement = ({
  label,
  value,
  disabled,
  containerProps,
  ...props
}) => {
  const context = (0, import_react.useContext)(import_index.RadioContext);
  if (context === void 0)
    throw new Error("RadioElement must be used within a RadioProvider");
  const isChecked = context.currentValue === value;
  const handleChange = (event) => {
    context.onChange(event.target.value);
  };
  return /* @__PURE__ */ import_react.default.createElement(RadioListElement, null, /* @__PURE__ */ import_react.default.createElement(
    Input,
    {
      type: "radio",
      checked: isChecked,
      disabled,
      onChange: handleChange,
      value,
      name: context.name,
      ...props
    }
  ), /* @__PURE__ */ import_react.default.createElement(Container, { checked: isChecked, disabled, ...containerProps }, typeof label === "string" ? /* @__PURE__ */ import_react.default.createElement(Label, { checked: isChecked, disabled, variant: "paragraph" }, label) : import_react.default.createElement(label, { checked: isChecked, disabled })));
};
ListElement.displayName = "Radio.ListElement";
ListElement.Label = Label;
var RadioListElement_default = ListElement;
//# sourceMappingURL=RadioListElement.js.map
