"use strict";
var import_Form = require("../Form.css");
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const jsxRuntime = require("react/jsx-runtime");
const antd = require("antd");
const kit_Theme_UI = require("./Theme/UI.cjs");
require("./Theme/themeUtils.cjs");
require("./Theme/themes.cjs");
const formItem = "Form_formItem_00ce1";
const css = {
  formItem
};
const FormItem = ({
  children,
  label,
  labelCol = { span: 24 },
  max,
  maxMessage,
  required,
  requiredMessage,
  rules = [],
  validateMessage,
  ...props
}) => {
  const {
    themeSettings: { className: themeClass }
  } = kit_Theme_UI.useTheme();
  const classes = [css.formItem, themeClass];
  if (required)
    rules.push({ message: requiredMessage || `${label} required`, required: true });
  if (max)
    rules.push({ max, message: maxMessage || `${label} cannot exceed ${max} characters` });
  return /* @__PURE__ */ jsxRuntime.jsx(
    antd.Form.Item,
    {
      className: classes.join(" "),
      help: validateMessage,
      label,
      labelCol,
      required,
      rules,
      ...props,
      children
    }
  );
};
const Form = ({ noValidate = true, ...props }) => {
  const {
    themeSettings: { className: themeClass }
  } = kit_Theme_UI.useTheme();
  const classes = (props == null ? void 0 : props.className) ? themeClass.concat(" ", props.className) : themeClass;
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Form, { noValidate, ...props, className: classes });
};
const ErrorList = ({ ...props }) => {
  const {
    themeSettings: { className }
  } = kit_Theme_UI.useTheme();
  const classes = (props == null ? void 0 : props.className) ? className.concat(" ", props.className) : className;
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.ErrorList, { ...props, className: classes });
};
Form.Item = FormItem;
Form.List = antd.Form.List;
Form.ErrorList = ErrorList;
Form.useForm = antd.Form.useForm;
Form.useWatch = antd.Form.useWatch;
const hasErrors = (form) => {
  return form.getFieldsError().some(({ errors }) => errors.length);
};
exports.default = Form;
exports.hasErrors = hasErrors;
