"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
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;
};
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);

// src/molecules/form/index.ts
var form_exports = {};
__export(form_exports, {
  Form: () => Form,
  FormItem: () => FormItem
});
module.exports = __toCommonJS(form_exports);

// src/molecules/form/form.tsx
var RadixForm = __toESM(require("@radix-ui/react-form"), 1);
var import_react3 = require("react");

// src/atoms/heading.tsx
var import_themes = require("@radix-ui/themes");
var import_react = require("react");

// src/utils/map-with-responsive.ts
var mapWithResponsive = (args) => {
  const { value, mapFn } = args;
  if (typeof value === "string") {
    return mapFn(value);
  }
  ;
  if (typeof value === "object") {
    const newObj = {};
    let key;
    for (key in value) {
      newObj[key] = mapFn(value[key]);
    }
    return newObj;
  }
  return value;
};

// src/atoms/heading.tsx
var import_themes2 = require("@radix-ui/themes");
var import_jsx_runtime = require("react/jsx-runtime");
var mapVariant = (variant) => {
  switch (variant) {
    case "heading1":
      return "7";
    case "heading2":
      return "6";
    case "heading3":
      return "5";
    case "heading4":
      return "4";
    case "heading5":
      return "3";
    default:
      return void 0;
  }
};
function Heading2(props) {
  const _a = props, { size, children, variant } = _a, rest = __objRest(_a, ["size", "children", "variant"]);
  const radixSize = (0, import_react.useMemo)(() => {
    return variant ? mapWithResponsive({
      value: variant,
      mapFn: mapVariant
    }) : size;
  }, [size, variant]);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_themes.Heading, __spreadProps(__spreadValues({}, rest), { size: radixSize, children }));
}

// src/atoms/typo.tsx
var import_themes3 = require("@radix-ui/themes");
var import_react2 = require("react");
var import_jsx_runtime2 = require("react/jsx-runtime");
var Typo = (0, import_react2.forwardRef)(
  (props, ref) => {
    const _a = props, { size, variant, children } = _a, rest = __objRest(_a, ["size", "variant", "children"]);
    const radixSize = (0, import_react2.useMemo)(() => {
      if (size !== void 0) return size;
      switch (variant) {
        case "caption":
          return "1";
        case "subtitle":
          return "3";
        case "body":
        default:
          return "2";
      }
    }, [size, variant]);
    return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_themes3.Text, __spreadProps(__spreadValues({}, rest), { ref, size: radixSize, children }));
  }
);
Typo.displayName = "Typo";

// src/molecules/form/form.tsx
var import_jsx_runtime3 = require("react/jsx-runtime");
var Root2 = (0, import_react3.forwardRef)(
  (_a, ref) => {
    var _b = _a, { children, className } = _b, rest = __objRest(_b, ["children", "className"]);
    return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
      RadixForm.Root,
      __spreadProps(__spreadValues({}, rest), {
        className: `FormRoot ${className || ""}`,
        ref,
        children
      })
    );
  }
);
Root2.displayName = "FORM_ROOT";
var FieldContext = (0, import_react3.createContext)({
  name: ""
});
var Field2 = (0, import_react3.forwardRef)(
  (_a, ref) => {
    var _b = _a, { children, className } = _b, rest = __objRest(_b, ["children", "className"]);
    return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
      RadixForm.Field,
      __spreadProps(__spreadValues({}, rest), {
        className: `FormField ${className || ""}`,
        ref,
        children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FieldContext.Provider, { value: rest, children })
      })
    );
  }
);
Field2.displayName = "FORM_FIELD";
function HeadingLabel(props) {
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading2, __spreadProps(__spreadValues({ variant: "heading5" }, props), { children: props.children }));
}
function CaptionLabel(props) {
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Typo, __spreadProps(__spreadValues({ color: "gray", variant: "caption" }, props), { children: props.children }));
}
var Label2 = (0, import_react3.forwardRef)(
  (_a, ref) => {
    var _b = _a, { children, className, variant } = _b, rest = __objRest(_b, ["children", "className", "variant"]);
    const Comp = (0, import_react3.useMemo)(() => {
      switch (variant) {
        case "title":
          return HeadingLabel;
        case "caption":
          return CaptionLabel;
        case "body":
        default:
          return Typo;
      }
    }, [variant]);
    const fieldProps = (0, import_react3.useContext)(FieldContext);
    return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
      RadixForm.Label,
      __spreadProps(__spreadValues({}, rest), {
        asChild: true,
        className: `FormLabel ${className || ""}`,
        ref,
        children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Comp, { children: [
          children,
          fieldProps.required ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Typo, { as: "span", color: "tomato", children: ` *` }) : null
        ] })
      })
    );
  }
);
Label2.displayName = "FORM_Label";
var Message2 = (0, import_react3.forwardRef)(
  (_a, ref) => {
    var _b = _a, { children, className } = _b, rest = __objRest(_b, ["children", "className"]);
    return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
      RadixForm.Message,
      __spreadProps(__spreadValues({}, rest), {
        asChild: true,
        className: `FormMessage ${className || ""}`,
        ref,
        children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Typo, { color: "red", children })
      })
    );
  }
);
Message2.displayName = "FORM_Message";
var Control2 = (0, import_react3.forwardRef)(
  (_a, ref) => {
    var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
    const fieldProps = (0, import_react3.useContext)(FieldContext);
    return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
      RadixForm.Control,
      __spreadProps(__spreadValues({}, rest), {
        className: `FormControl ${className || ""}`,
        ref,
        required: fieldProps.required
      })
    );
  }
);
Control2.displayName = "FORM_Control";
function FormItem(_a) {
  var _b = _a, {
    label,
    labelVariant,
    children,
    errorMessage
  } = _b, fieldProps = __objRest(_b, [
    "label",
    "labelVariant",
    "children",
    "errorMessage"
  ]);
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Form.Field, __spreadProps(__spreadValues({}, fieldProps), { children: [
    /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Form.Label, { variant: labelVariant, children: label }),
    children,
    /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Form.Message, { forceMatch: Boolean(errorMessage), children: errorMessage })
  ] }));
}
var Form = {
  Root: Root2,
  Field: Field2,
  Label: Label2,
  Message: Message2,
  Control: RadixForm.Control,
  Submit: RadixForm.Submit,
  FormItem
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Form,
  FormItem
});
//# sourceMappingURL=index.cjs.map