"use client";
'use strict';

var classVarianceAuthority = require('class-variance-authority');
var lucideReact = require('lucide-react');
var clsx = require('clsx');
var tailwindMerge = require('tailwind-merge');
var checkbox = require('@base-ui/react/checkbox');
var jsxRuntime = require('react/jsx-runtime');

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 Checkbox(_a) {
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
  return /* @__PURE__ */ jsxRuntime.jsx(
    checkbox.Checkbox.Root,
    __spreadProps(__spreadValues({
      "data-slot": "checkbox",
      className: cn(
        "group/checkbox relative inline-flex size-6 shrink-0 cursor-pointer items-center justify-center outline-none touch-manipulation",
        "focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
        className
      )
    }, props), {
      children: /* @__PURE__ */ jsxRuntime.jsx(
        "span",
        {
          "aria-hidden": true,
          className: cn(
            "relative flex size-4 shrink-0 items-center justify-center overflow-hidden rounded-[4px] border border-input bg-background transition-colors outline-none",
            "dark:bg-input/30",
            "group-focus-visible/checkbox:ring-4 group-focus-visible/checkbox:ring-ring/50 group-focus-visible/checkbox:ring-offset-1 group-focus-visible/checkbox:ring-offset-background",
            "group-focus-visible/checkbox:border-ring",
            "group-disabled/checkbox:cursor-not-allowed group-disabled/checkbox:opacity-50",
            "group-aria-invalid/checkbox:border-destructive group-aria-invalid/checkbox:ring-3 group-aria-invalid/checkbox:ring-destructive/20",
            "group-aria-invalid/checkbox:group-data-checked/checkbox:border-primary",
            "dark:group-aria-invalid/checkbox:border-destructive/50 dark:group-aria-invalid/checkbox:ring-destructive/40",
            "group-data-unchecked/checkbox:group-hover/checkbox:border-input-hover group-data-unchecked/checkbox:group-hover/checkbox:bg-accent/50",
            "dark:group-data-unchecked/checkbox:group-hover/checkbox:border-input-hover dark:group-data-unchecked/checkbox:group-hover/checkbox:bg-accent/30",
            "group-disabled/checkbox:group-hover/checkbox:border-input group-disabled/checkbox:group-hover/checkbox:bg-transparent",
            "group-data-checked/checkbox:border-primary group-data-checked/checkbox:bg-primary group-data-checked/checkbox:text-primary-foreground",
            "group-data-checked/checkbox:group-hover/checkbox:border-[var(--primary-hover)] group-data-checked/checkbox:group-hover/checkbox:bg-[var(--primary-hover)]",
            "dark:group-data-checked/checkbox:bg-primary",
            "group-data-indeterminate/checkbox:border-primary group-data-indeterminate/checkbox:bg-primary group-data-indeterminate/checkbox:text-primary-foreground",
            "group-data-indeterminate/checkbox:group-hover/checkbox:border-[var(--primary-hover)] group-data-indeterminate/checkbox:group-hover/checkbox:bg-[var(--primary-hover)]",
            "dark:group-data-indeterminate/checkbox:bg-primary"
          ),
          children: /* @__PURE__ */ jsxRuntime.jsx(
            checkbox.Checkbox.Indicator,
            {
              "data-slot": "checkbox-indicator",
              keepMounted: true,
              className: "absolute inset-0 flex items-center justify-center leading-none text-current transition-none",
              render: (indicatorProps, state) => /* @__PURE__ */ jsxRuntime.jsx(
                "span",
                __spreadProps(__spreadValues({}, indicatorProps), {
                  className: cn(
                    indicatorProps.className,
                    "flex size-full items-center justify-center"
                  ),
                  children: state.indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(
                    lucideReact.MinusIcon,
                    {
                      className: "block size-2.5",
                      strokeWidth: 2.25,
                      "aria-hidden": true
                    }
                  ) : state.checked ? /* @__PURE__ */ jsxRuntime.jsx(
                    lucideReact.CheckIcon,
                    {
                      className: "block size-2.5",
                      strokeWidth: 2.25,
                      "aria-hidden": true
                    }
                  ) : null
                })
              )
            }
          )
        }
      )
    })
  );
}
var STRENGTH_SEGMENTS = 3;
var strengthBarColor = {
  none: "bg-muted",
  low: "bg-[#e74341]",
  medium: "bg-[#f27313]",
  high: "bg-primary"
};
function filledSegments(strength) {
  switch (strength) {
    case "low":
      return 1;
    case "medium":
      return 2;
    case "high":
      return 3;
    default:
      return 0;
  }
}
var inputCaptionVariants = classVarianceAuthority.cva("flex w-full", {
  variants: {
    variant: {
      default: "items-center gap-0",
      success: "items-center gap-0",
      error: "items-center gap-0",
      checkbox: "items-center gap-2",
      password: "flex-col items-start gap-2.5"
    }
  },
  defaultVariants: {
    variant: "default"
  }
});
function InputCaption(_a) {
  var _b = _a, {
    className,
    variant = "default",
    text = "Caption text",
    successText = "Success message",
    errorText = "Error message",
    strength = "none",
    requirements = [],
    checked,
    onCheckedChange
  } = _b, props = __objRest(_b, [
    "className",
    "variant",
    "text",
    "successText",
    "errorText",
    "strength",
    "requirements",
    "checked",
    "onCheckedChange"
  ]);
  return /* @__PURE__ */ jsxRuntime.jsxs(
    "div",
    __spreadProps(__spreadValues({
      "data-slot": "input-caption",
      className: cn(inputCaptionVariants({ variant }), className)
    }, props), {
      children: [
        variant === "default" && /* @__PURE__ */ jsxRuntime.jsx(InputCaptionText, { children: text }),
        variant === "success" && /* @__PURE__ */ jsxRuntime.jsx(InputCaptionText, { variant: "success", children: successText }),
        variant === "error" && /* @__PURE__ */ jsxRuntime.jsx(InputCaptionText, { variant: "error", children: errorText }),
        variant === "checkbox" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
          /* @__PURE__ */ jsxRuntime.jsx(
            Checkbox,
            {
              checked,
              onCheckedChange
            }
          ),
          /* @__PURE__ */ jsxRuntime.jsx(InputCaptionText, { children: text })
        ] }),
        variant === "password" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
          /* @__PURE__ */ jsxRuntime.jsx(InputCaptionText, { children: "Password requirements:" }),
          /* @__PURE__ */ jsxRuntime.jsx(PasswordStrengthBar, { strength }),
          requirements.map((req) => /* @__PURE__ */ jsxRuntime.jsx(
            PasswordRequirementRow,
            {
              label: req.label,
              met: req.met
            },
            req.label
          ))
        ] })
      ]
    })
  );
}
var captionTextVariants = classVarianceAuthority.cva(
  "text-xs font-normal leading-4",
  {
    variants: {
      variant: {
        default: "text-muted-foreground",
        success: "text-primary",
        error: "text-destructive"
      }
    },
    defaultVariants: {
      variant: "default"
    }
  }
);
function InputCaptionText(_a) {
  var _b = _a, {
    className,
    variant
  } = _b, props = __objRest(_b, [
    "className",
    "variant"
  ]);
  return /* @__PURE__ */ jsxRuntime.jsx(
    "p",
    __spreadValues({
      "data-slot": "input-caption-text",
      className: cn(captionTextVariants({ variant }), className)
    }, props)
  );
}
function PasswordStrengthBar(_a) {
  var _b = _a, {
    className,
    strength = "none"
  } = _b, props = __objRest(_b, [
    "className",
    "strength"
  ]);
  const filled = filledSegments(strength);
  const barColor = strengthBarColor[strength];
  const emptyColor = "bg-muted";
  return /* @__PURE__ */ jsxRuntime.jsx(
    "div",
    __spreadProps(__spreadValues({
      "data-slot": "password-strength-bar",
      className: cn("flex w-full items-center gap-1", className),
      role: "meter",
      "aria-label": "Password strength",
      "aria-valuenow": filled,
      "aria-valuemin": 0,
      "aria-valuemax": STRENGTH_SEGMENTS
    }, props), {
      children: Array.from({ length: STRENGTH_SEGMENTS }, (_, i) => /* @__PURE__ */ jsxRuntime.jsx(
        "div",
        {
          "data-slot": "password-strength-segment",
          "data-filled": i < filled || void 0,
          className: cn(
            "h-1 min-h-px min-w-px flex-1 rounded-full transition-colors duration-200",
            i < filled ? barColor : emptyColor
          )
        },
        i
      ))
    })
  );
}
function PasswordRequirementRow(_a) {
  var _b = _a, {
    className,
    label,
    met
  } = _b, props = __objRest(_b, [
    "className",
    "label",
    "met"
  ]);
  return /* @__PURE__ */ jsxRuntime.jsxs(
    "div",
    __spreadProps(__spreadValues({
      "data-slot": "password-requirement",
      className: cn("flex w-full items-center gap-1", className)
    }, props), {
      children: [
        /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-4 shrink-0 items-center justify-center", children: met ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckIcon, { className: "size-4 text-primary", "aria-hidden": true }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { className: "size-4 text-muted-foreground", "aria-hidden": true }) }),
        /* @__PURE__ */ jsxRuntime.jsx(
          "span",
          {
            className: cn(
              "text-xs font-normal leading-4",
              met ? "text-primary" : "text-muted-foreground"
            ),
            children: label
          }
        )
      ]
    })
  );
}

exports.InputCaption = InputCaption;
exports.InputCaptionText = InputCaptionText;
exports.PasswordRequirementRow = PasswordRequirementRow;
exports.PasswordStrengthBar = PasswordStrengthBar;
exports.captionTextVariants = captionTextVariants;
exports.inputCaptionVariants = inputCaptionVariants;
//# sourceMappingURL=input-caption.cjs.map
//# sourceMappingURL=input-caption.cjs.map