"use client";
'use strict';

var React = require('react');
var radio = require('@base-ui/react/radio');
var radioGroup = require('@base-ui/react/radio-group');
var clsx = require('clsx');
var tailwindMerge = require('tailwind-merge');
var jsxRuntime = require('react/jsx-runtime');

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var React__namespace = /*#__PURE__*/_interopNamespace(React);

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
function cn(...inputs) {
  return tailwindMerge.twMerge(clsx.clsx(inputs));
}
function RadioGroup(_a) {
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
  return /* @__PURE__ */ jsxRuntime.jsx(
    radioGroup.RadioGroup,
    __spreadValues({
      "data-slot": "radio-group",
      className: cn("grid w-full gap-2", className)
    }, props)
  );
}

// src/primitives/portfolio-form-controls-visuals.tsx
var PORTFOLIO_FORM_CONTROL_BORDER_HEX = "#ebeced";
var PORTFOLIO_FORM_CONTROL_PRIMARY_ACCENT_HEX = "#319e83";
var PORTFOLIO_CHECKBOX_ACCENT_HEX = PORTFOLIO_FORM_CONTROL_PRIMARY_ACCENT_HEX;
var PORTFOLIO_RADIO_ACCENT_HEX = PORTFOLIO_FORM_CONTROL_PRIMARY_ACCENT_HEX;
var PORTFOLIO_RADIO_SELECTED_INNER_FILL_HEX = PORTFOLIO_CHECKBOX_ACCENT_HEX;
var PORTFOLIO_FORM_CONTROL_DISABLED_FILL_HEX = "#a3a3a3";
var PORTFOLIO_FORM_CONTROL_GRADIENT_START_HEX = "#ECECED";
var PORTFOLIO_FORM_CONTROL_GRADIENT_MID_HEX = "#7A7B7F";
var PORTFOLIO_FORM_CONTROL_GRADIENT_END_HEX = "#ECECED";
var PORTFOLIO_FORM_CONTROL_SURFACE_HEX = "#fafafa";
var PORTFOLIO_RADIO_DEFAULT_VISUALS = {
  accentColor: PORTFOLIO_RADIO_ACCENT_HEX,
  gradientStartColor: PORTFOLIO_FORM_CONTROL_GRADIENT_START_HEX,
  gradientMidColor: PORTFOLIO_FORM_CONTROL_GRADIENT_MID_HEX,
  gradientEndColor: PORTFOLIO_FORM_CONTROL_GRADIENT_END_HEX,
  surfaceColor: PORTFOLIO_FORM_CONTROL_SURFACE_HEX,
  disabledFillColor: PORTFOLIO_FORM_CONTROL_DISABLED_FILL_HEX,
  glowSizePx: 12,
  glowBlurPx: 2,
  glowOpacity: 1,
  dotSizePx: 10
};
function hexToRgbaString(hexColor, alpha) {
  const normalizedHex = hexColor.replace("#", "");
  const safeAlpha = Math.min(1, Math.max(0, alpha));
  if (normalizedHex.length !== 6) {
    return hexColor;
  }
  const red = Number.parseInt(normalizedHex.slice(0, 2), 16);
  const green = Number.parseInt(normalizedHex.slice(2, 4), 16);
  const blue = Number.parseInt(normalizedHex.slice(4, 6), 16);
  return `rgba(${red}, ${green}, ${blue}, ${safeAlpha})`;
}
function PortfolioRadioInnerDot({ className }) {
  return /* @__PURE__ */ jsxRuntime.jsx(
    "span",
    {
      "data-slot": "portfolio-radio-inner-dot",
      className: cn(
        "pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[color:var(--portfolio-radio-accent)] opacity-0 transition-opacity group-data-checked/portfolio-radio:opacity-100 group-data-[visual-disabled=true]/portfolio-radio:bg-[color:var(--portfolio-radio-disabled)]",
        className
      ),
      style: {
        width: "var(--portfolio-radio-dot-size)",
        height: "var(--portfolio-radio-dot-size)"
      },
      "aria-hidden": true
    }
  );
}
function PortfolioRadioBlurLayer() {
  return /* @__PURE__ */ jsxRuntime.jsx(
    "span",
    {
      className: "pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full opacity-0 transition-opacity group-data-checked/portfolio-radio:opacity-100 group-disabled/portfolio-radio:opacity-0 group-data-[visual-disabled=true]/portfolio-radio:opacity-0",
      style: {
        width: "var(--portfolio-radio-glow-size)",
        height: "var(--portfolio-radio-glow-size)",
        backgroundColor: "var(--portfolio-radio-glow-color)",
        filter: "blur(var(--portfolio-radio-glow-blur))"
      },
      "aria-hidden": true
    }
  );
}
function PortfolioRadioButton(_a) {
  var _b = _a, {
    className,
    disabled,
    showFocusRing,
    visualDisabled,
    visualSpec = PORTFOLIO_RADIO_DEFAULT_VISUALS,
    style
  } = _b, props = __objRest(_b, [
    "className",
    "disabled",
    "showFocusRing",
    "visualDisabled",
    "visualSpec",
    "style"
  ]);
  const isVisuallyDisabled = Boolean(disabled || visualDisabled);
  const fadeWhenDisabled = isVisuallyDisabled && !showFocusRing;
  return /* @__PURE__ */ jsxRuntime.jsx(
    radio.Radio.Root,
    __spreadProps(__spreadValues({
      "data-slot": "portfolio-radio",
      "data-visual-disabled": visualDisabled ? "true" : void 0,
      disabled,
      className: cn(
        "group/portfolio-radio peer relative inline-flex h-[24px] w-[24px] min-h-[24px] min-w-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full outline-none transition-colors touch-manipulation",
        "focus-visible:outline-none",
        "disabled:cursor-not-allowed",
        !showFocusRing && "disabled:opacity-65",
        "data-disabled:[&_[data-slot=portfolio-radio-inner-dot]]:bg-[color:var(--portfolio-radio-disabled)]",
        fadeWhenDisabled && "opacity-65",
        className
      ),
      style: __spreadValues({
        "--portfolio-radio-border": PORTFOLIO_FORM_CONTROL_BORDER_HEX,
        "--portfolio-radio-accent": visualSpec.accentColor,
        "--portfolio-radio-disabled": visualSpec.disabledFillColor,
        "--portfolio-radio-surface": visualSpec.surfaceColor,
        "--portfolio-radio-dot-size": `${visualSpec.dotSizePx}px`,
        "--portfolio-radio-glow-size": `${visualSpec.glowSizePx}px`,
        "--portfolio-radio-glow-blur": `${visualSpec.glowBlurPx}px`,
        "--portfolio-radio-glow-color": hexToRgbaString(
          visualSpec.accentColor,
          visualSpec.glowOpacity
        ),
        "--portfolio-form-control-focus-ring": hexToRgbaString(
          visualSpec.accentColor,
          0.32
        ),
        "--portfolio-radio-selected-inner-fill": PORTFOLIO_RADIO_SELECTED_INNER_FILL_HEX
      }, style)
    }, props), {
      children: /* @__PURE__ */ jsxRuntime.jsxs(
        "span",
        {
          className: cn(
            "relative size-4 shrink-0 overflow-hidden rounded-full transition-colors",
            "group-focus-visible/portfolio-radio:ring-2 group-focus-visible/portfolio-radio:ring-[color:var(--portfolio-form-control-focus-ring)] group-focus-visible/portfolio-radio:ring-offset-1 group-focus-visible/portfolio-radio:ring-offset-background",
            showFocusRing && "ring-2 ring-[color:var(--portfolio-form-control-focus-ring)] ring-offset-1 ring-offset-background"
          ),
          children: [
            /* @__PURE__ */ jsxRuntime.jsx(
              "span",
              {
                "aria-hidden": true,
                className: "pointer-events-none absolute inset-0 z-0 rounded-full",
                style: {
                  background: `linear-gradient(to bottom right, ${visualSpec.gradientStartColor} 0%, ${visualSpec.gradientMidColor} 50%, ${visualSpec.gradientEndColor} 100%)`
                }
              }
            ),
            /* @__PURE__ */ jsxRuntime.jsx(
              "span",
              {
                "aria-hidden": true,
                className: "pointer-events-none absolute inset-px z-0 rounded-full bg-[color:var(--portfolio-radio-surface)] transition-colors group-data-checked/portfolio-radio:bg-[color:var(--portfolio-radio-selected-inner-fill)] group-disabled/portfolio-radio:bg-[#e3e5e8] group-disabled/portfolio-radio:group-data-checked/portfolio-radio:bg-[color:var(--portfolio-radio-disabled)] group-data-[visual-disabled=true]/portfolio-radio:bg-[#e3e5e8] group-data-[visual-disabled=true]/portfolio-radio:group-data-checked/portfolio-radio:bg-[color:var(--portfolio-radio-disabled)]"
              }
            ),
            /* @__PURE__ */ jsxRuntime.jsx(PortfolioRadioBlurLayer, {}),
            /* @__PURE__ */ jsxRuntime.jsx(
              radio.Radio.Indicator,
              {
                "data-slot": "portfolio-radio-indicator",
                className: "flex size-4 items-center justify-center",
                children: /* @__PURE__ */ jsxRuntime.jsx(PortfolioRadioInnerDot, {})
              }
            )
          ]
        }
      )
    })
  );
}
function RadioCardGroup(_a) {
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
  return /* @__PURE__ */ jsxRuntime.jsx(
    RadioGroup,
    __spreadValues({
      "data-slot": "radio-card-group",
      className: cn("grid gap-2 sm:grid-cols-2", className)
    }, props)
  );
}
function RadioCardOption(_a) {
  var _b = _a, {
    className,
    title,
    description,
    subDetail,
    media,
    trailing,
    hideControl = false,
    leading,
    leadingContainerClassName,
    titleClassName,
    id: idProp
  } = _b, props = __objRest(_b, [
    "className",
    "title",
    "description",
    "subDetail",
    "media",
    "trailing",
    "hideControl",
    "leading",
    "leadingContainerClassName",
    "titleClassName",
    "id"
  ]);
  const generatedId = React__namespace.useId();
  const id = idProp != null ? idProp : `radio-card-${String(props.value).replace(/\s/g, "-")}-${generatedId.replace(/:/g, "")}`;
  const descriptionId = description ? `${id}-desc` : void 0;
  return /* @__PURE__ */ jsxRuntime.jsxs(
    "label",
    {
      htmlFor: id,
      className: cn(
        "group/card-option relative flex cursor-pointer flex-col overflow-hidden rounded-md border border-border bg-card text-left transition-colors",
        media != null && "bg-white dark:bg-zinc-950",
        media == null && "hover:bg-accent/30 hover:border-border",
        media != null && "hover:border-primary/40 hover:shadow-sm",
        "has-data-[checked]:border-primary has-data-[checked]:bg-primary/5",
        media != null && "has-data-[checked]:bg-white dark:has-data-[checked]:bg-zinc-950",
        media != null && "hover:bg-white dark:hover:bg-zinc-950",
        "has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",
        "[&_[data-slot=radio-card-trailing]]:text-muted-foreground has-data-[checked]:[&_[data-slot=radio-card-trailing]]:text-primary",
        "[&_[data-slot=radio-card-trailing]_[data-slot=badge]]:font-headline [&_[data-slot=radio-card-trailing]_[data-slot=badge]]:tracking-normal",
        className
      ),
      children: [
        hideControl ? /* @__PURE__ */ jsxRuntime.jsx(
          PortfolioRadioButton,
          __spreadProps(__spreadValues({
            id,
            "aria-describedby": descriptionId
          }, props), {
            className: cn(
              "sr-only !absolute !size-px !min-h-0 !min-w-0 overflow-hidden p-0 opacity-0"
            )
          })
        ) : null,
        media != null ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full shrink-0 border-b border-border/60", children: media }) : null,
        /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex items-center gap-3 p-4", children: [
          !hideControl ? /* @__PURE__ */ jsxRuntime.jsx(
            PortfolioRadioButton,
            __spreadProps(__spreadValues({
              id,
              "aria-describedby": descriptionId
            }, props), {
              className: cn("shrink-0")
            })
          ) : null,
          hideControl && leading != null ? /* @__PURE__ */ jsxRuntime.jsx(
            "span",
            {
              className: cn(
                "flex size-10 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-primary",
                leadingContainerClassName
              ),
              children: leading
            }
          ) : null,
          /* @__PURE__ */ jsxRuntime.jsxs(
            "div",
            {
              className: cn(
                "min-w-0 flex-1 flex flex-col gap-0.5",
                trailing != null && "pr-20"
              ),
              children: [
                /* @__PURE__ */ jsxRuntime.jsx(
                  "span",
                  {
                    className: cn(
                      "text-sm font-medium leading-snug text-foreground",
                      titleClassName
                    ),
                    children: title
                  }
                ),
                description ? /* @__PURE__ */ jsxRuntime.jsx(
                  "span",
                  {
                    id: descriptionId,
                    className: "text-sm text-muted-foreground leading-snug",
                    children: description
                  }
                ) : null,
                subDetail ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: subDetail }) : null
              ]
            }
          ),
          trailing != null ? /* @__PURE__ */ jsxRuntime.jsx(
            "span",
            {
              "data-slot": "radio-card-trailing",
              className: "absolute top-2 right-2 shrink-0 transition-colors",
              children: trailing
            }
          ) : null
        ] })
      ]
    }
  );
}

exports.RadioCardGroup = RadioCardGroup;
exports.RadioCardOption = RadioCardOption;
//# sourceMappingURL=radio-card.cjs.map
//# sourceMappingURL=radio-card.cjs.map