import e, { Fragment as g } from "react";
import { Field as v } from "./Field.js";
import { useForm as y } from "react-hook-form";
import "react-router-dom";
import "../components/Icons/EuiIcon.js";
import { Buttons as S } from "../components/Button.js";
import "@elastic/eui";
import "../node_modules/.pnpm/twin.macro@2.8.2/node_modules/twin.macro/macro.js";
import "../node_modules/.pnpm/@elastic_eui@61.0.0_zavqrpf4tc2kjxw3tjmx3rmpbq/node_modules/@elastic/eui/dist/eui_theme_light.js";
import "../tailwind.js";
const H = ({ data: m = [], onSubmit: a, buttons: n, values: u = {}, formId: c, onCloseModal: p }) => {
  const {
    register: s,
    handleSubmit: f,
    formState: { errors: b }
  } = y({
    defaultValues: u
  });
  return /* @__PURE__ */ e.createElement(g, null, /* @__PURE__ */ e.createElement("form", {
    onSubmit: f(a),
    id: c
  }, m == null ? void 0 : m.map((i, h) => {
    var o;
    const { name: r, type: E, required: d, capitalize: k, initialValue: x, label: F, options: t, ...V } = i;
    return /* @__PURE__ */ e.createElement(v, {
      key: r,
      ...i,
      ...s(r, d),
      error: (o = b[r]) == null ? void 0 : o.message,
      label: F || r
    }, t && (t == null ? void 0 : t.map((l, _) => {
      if (E === "select")
        return /* @__PURE__ */ e.createElement("option", {
          value: l.value,
          key: l.value
        }, l.label);
    })));
  }), /* @__PURE__ */ e.createElement(S, {
    data: n,
    onCloseModal: p
  })));
};
export {
  H as Form
};
//# sourceMappingURL=Form.js.map
