import { jsx as c, jsxs as j } from "react/jsx-runtime";
import { g as p, s as l, c as x, d as y, F as g } from "../index.esm-BQxOvVZs.js";
import { Modal as F } from "../composables/Modal.js";
import { FormModal as M } from "../feature/govco/FormModal.js";
import "react";
import "../hooks/useAnimatePresence.js";
import "../SVGVisualElement-aqO4D4Z5.js";
import "../use-unmount-effect-Wy5iLAex.js";
import "./AlertDialog/index.js";
import "react-dom";
import "./Icons.js";
import "../utils/functions.js";
import "../clsx-7d8NmkQq.js";
import "../utils/components/RenderIf.js";
import "./AlertDialog/variants.js";
import "../index-xVF7D3FM.js";
import "../context/generalContext/index.js";
import "../context/index.js";
import "../index-T7wQHOux.js";
import "../LayoutGroupContext-3euHzeKi.js";
import "../feature/RenderFeatureComponents.js";
import "../useQuery-n4ls1rLk.js";
var h = function(r, e, t) {
  if (r && "reportValidity" in r) {
    var i = p(t, e);
    r.setCustomValidity(i && i.message || ""), r.reportValidity();
  }
}, V = function(r, e) {
  var t = function(a) {
    var o = e.fields[a];
    o && o.ref && "reportValidity" in o.ref ? h(o.ref, a, r) : o.refs && o.refs.forEach(function(n) {
      return h(n, a, r);
    });
  };
  for (var i in e.fields)
    t(i);
}, P = function(r, e) {
  e.shouldUseNativeValidation && V(r, e);
  var t = {};
  for (var i in r) {
    var a = p(e.fields, i), o = Object.assign(r[i] || {}, { ref: a && a.ref });
    if (N(e.names || Object.keys(r), i)) {
      var n = Object.assign({}, E(p(t, i)));
      l(n, "root", o), l(t, i, n);
    } else
      l(t, i, o);
  }
  return t;
}, E = function(r) {
  return Array.isArray(r) ? r.filter(Boolean) : [];
}, N = function(r, e) {
  return r.some(function(t) {
    return t.startsWith(e + ".");
  });
};
function b(r, e, t) {
  return e === void 0 && (e = {}), t === void 0 && (t = {}), function(i, a, o) {
    try {
      return Promise.resolve(function(n, d) {
        try {
          var u = (e.context && process.env.NODE_ENV === "development" && console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"), Promise.resolve(r[t.mode === "sync" ? "validateSync" : "validate"](i, Object.assign({ abortEarly: !1 }, e, { context: a }))).then(function(m) {
            return o.shouldUseNativeValidation && V({}, o), { values: t.raw ? i : m, errors: {} };
          }));
        } catch (m) {
          return d(m);
        }
        return u && u.then ? u.then(void 0, d) : u;
      }(0, function(n) {
        if (!n.inner)
          throw n;
        return { values: {}, errors: P((d = n, u = !o.shouldUseNativeValidation && o.criteriaMode === "all", (d.inner || []).reduce(function(m, s) {
          if (m[s.path] || (m[s.path] = { message: s.message, type: s.type }), u) {
            var f = m[s.path].types, v = f && f[s.type];
            m[s.path] = x(s.path, u, m, s.type, v ? [].concat(v, s.message) : s.message);
          }
          return m;
        }, {})), o) };
        var d, u;
      }));
    } catch (n) {
      return Promise.reject(n);
    }
  };
}
function R({ children: r, submit: e, defaultValue: t, values: i, schema: a, className: o }) {
  const n = y({
    defaultValues: t ?? {},
    values: i,
    mode: "onTouched",
    reValidateMode: "onChange",
    resolver: a ? b(a) : void 0
  });
  return /* @__PURE__ */ c("form", { onSubmit: e ? n.handleSubmit((d) => e(d)) : void 0, className: o, children: /* @__PURE__ */ j(g, { ...n, children: [
    r,
    /* @__PURE__ */ c(F, { children: /* @__PURE__ */ c(M, {}) })
  ] }) });
}
function X({ children: r, submit: e, onError: t, defaultValue: i, values: a, schema: o, className: n }) {
  const d = y({
    defaultValues: i ?? {},
    values: a,
    mode: "onTouched",
    reValidateMode: "onChange",
    resolver: o ? b(o) : void 0
  });
  return /* @__PURE__ */ c("form", { onSubmit: e ? d.handleSubmit((u) => e(u), t) : void 0, className: n, children: /* @__PURE__ */ c(g, { ...d, children: r }) });
}
export {
  R as AppFormProvider,
  X as BasicFormProvider
};
