import { ref as W, reactive as je, computed as A, unref as F, nextTick as B, warn as xt, onMounted as Bt, isRef as Ge, watch as Pe, provide as rt, toValue as T, readonly as Dt, watchEffect as Mt, getCurrentInstance as it, onUnmounted as Lt, shallowRef as Ut, defineComponent as zt, openBlock as $t, createBlock as Wt, normalizeProps as qe, guardReactiveProps as He, withCtx as Gt, renderSlot as qt } from "vue";
import { ElForm as Ht } from "element-plus";
function Qt() {
  return ot().__VUE_DEVTOOLS_GLOBAL_HOOK__;
}
function ot() {
  return typeof navigator < "u" && typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
}
const Kt = typeof Proxy == "function", Jt = "devtools-plugin:setup", Yt = "plugin:settings:set";
let J, Ce;
function Xt() {
  var e;
  return J !== void 0 || (typeof window < "u" && window.performance ? (J = !0, Ce = window.performance) : typeof globalThis < "u" && (!((e = globalThis.perf_hooks) === null || e === void 0) && e.performance) ? (J = !0, Ce = globalThis.perf_hooks.performance) : J = !1), J;
}
function Zt() {
  return Xt() ? Ce.now() : Date.now();
}
class en {
  constructor(t, n) {
    this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = t, this.hook = n;
    const o = {};
    if (t.settings)
      for (const s in t.settings) {
        const f = t.settings[s];
        o[s] = f.defaultValue;
      }
    const l = `__vue-devtools-plugin-settings__${t.id}`;
    let a = Object.assign({}, o);
    try {
      const s = localStorage.getItem(l), f = JSON.parse(s);
      Object.assign(a, f);
    } catch {
    }
    this.fallbacks = {
      getSettings() {
        return a;
      },
      setSettings(s) {
        try {
          localStorage.setItem(l, JSON.stringify(s));
        } catch {
        }
        a = s;
      },
      now() {
        return Zt();
      }
    }, n && n.on(Yt, (s, f) => {
      s === this.plugin.id && this.fallbacks.setSettings(f);
    }), this.proxiedOn = new Proxy({}, {
      get: (s, f) => this.target ? this.target.on[f] : (...v) => {
        this.onQueue.push({
          method: f,
          args: v
        });
      }
    }), this.proxiedTarget = new Proxy({}, {
      get: (s, f) => this.target ? this.target[f] : f === "on" ? this.proxiedOn : Object.keys(this.fallbacks).includes(f) ? (...v) => (this.targetQueue.push({
        method: f,
        args: v,
        resolve: () => {
        }
      }), this.fallbacks[f](...v)) : (...v) => new Promise((d) => {
        this.targetQueue.push({
          method: f,
          args: v,
          resolve: d
        });
      })
    });
  }
  async setRealTarget(t) {
    this.target = t;
    for (const n of this.onQueue)
      this.target.on[n.method](...n.args);
    for (const n of this.targetQueue)
      n.resolve(await this.target[n.method](...n.args));
  }
}
function tn(e, t) {
  const n = e, o = ot(), l = Qt(), a = Kt && n.enableEarlyProxy;
  if (l && (o.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !a))
    l.emit(Jt, e, t);
  else {
    const s = a ? new en(n, l) : null;
    (o.__VUE_DEVTOOLS_PLUGINS__ = o.__VUE_DEVTOOLS_PLUGINS__ || []).push({
      pluginDescriptor: n,
      setupFn: t,
      proxy: s
    }), s && t(s.proxiedTarget);
  }
}
/**
  * vee-validate v4.12.6
  * (c) 2024 Abdelrahman Awad
  * @license MIT
  */
function D(e) {
  return typeof e == "function";
}
function lt(e) {
  return e == null;
}
const Q = (e) => e !== null && !!e && typeof e == "object" && !Array.isArray(e);
function Ne(e) {
  return Number(e) >= 0;
}
function nn(e) {
  return typeof e == "object" && e !== null;
}
function rn(e) {
  return e == null ? e === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(e);
}
function Qe(e) {
  if (!nn(e) || rn(e) !== "[object Object]")
    return !1;
  if (Object.getPrototypeOf(e) === null)
    return !0;
  let t = e;
  for (; Object.getPrototypeOf(t) !== null; )
    t = Object.getPrototypeOf(t);
  return Object.getPrototypeOf(e) === t;
}
function le(e, t) {
  return Object.keys(t).forEach((n) => {
    if (Qe(t[n]) && Qe(e[n])) {
      e[n] || (e[n] = {}), le(e[n], t[n]);
      return;
    }
    e[n] = t[n];
  }), e;
}
function de(e) {
  const t = e.split(".");
  if (!t.length)
    return "";
  let n = String(t[0]);
  for (let o = 1; o < t.length; o++) {
    if (Ne(t[o])) {
      n += `[${t[o]}]`;
      continue;
    }
    n += `.${t[o]}`;
  }
  return n;
}
const on = {};
function ln(e) {
  return on[e];
}
function Ke(e, t, n) {
  typeof n.value == "object" && (n.value = b(n.value)), !n.enumerable || n.get || n.set || !n.configurable || !n.writable || t === "__proto__" ? Object.defineProperty(e, t, n) : e[t] = n.value;
}
function b(e) {
  if (typeof e != "object")
    return e;
  var t = 0, n, o, l, a = Object.prototype.toString.call(e);
  if (a === "[object Object]" ? l = Object.create(e.__proto__ || null) : a === "[object Array]" ? l = Array(e.length) : a === "[object Set]" ? (l = /* @__PURE__ */ new Set(), e.forEach(function(s) {
    l.add(b(s));
  })) : a === "[object Map]" ? (l = /* @__PURE__ */ new Map(), e.forEach(function(s, f) {
    l.set(b(f), b(s));
  })) : a === "[object Date]" ? l = /* @__PURE__ */ new Date(+e) : a === "[object RegExp]" ? l = new RegExp(e.source, e.flags) : a === "[object DataView]" ? l = new e.constructor(b(e.buffer)) : a === "[object ArrayBuffer]" ? l = e.slice(0) : a.slice(-6) === "Array]" && (l = new e.constructor(e)), l) {
    for (o = Object.getOwnPropertySymbols(e); t < o.length; t++)
      Ke(l, o[t], Object.getOwnPropertyDescriptor(e, o[t]));
    for (t = 0, o = Object.getOwnPropertyNames(e); t < o.length; t++)
      Object.hasOwnProperty.call(l, n = o[t]) && l[n] === e[n] || Ke(l, n, Object.getOwnPropertyDescriptor(e, n));
  }
  return l || e;
}
const an = Symbol("vee-validate-form"), un = typeof window < "u";
function sn(e) {
  return D(e) && !!e.__locatorRef;
}
function q(e) {
  return !!e && D(e.parse) && e.__type === "VVTypedSchema";
}
function at(e) {
  return !!e && D(e.validate);
}
function cn(e) {
  return e === "checkbox" || e === "radio";
}
function dn(e) {
  return Q(e) || Array.isArray(e);
}
function fn(e) {
  return Array.isArray(e) ? e.length === 0 : Q(e) && Object.keys(e).length === 0;
}
function he(e) {
  return /^\[.+\]$/i.test(e);
}
function vn(e) {
  return ut(e) && e.multiple;
}
function ut(e) {
  return e.tagName === "SELECT";
}
function hn(e) {
  return st(e) && e.target && "submit" in e.target;
}
function st(e) {
  return e ? !!(typeof Event < "u" && D(Event) && e instanceof Event || e && e.srcElement) : !1;
}
function ie(e, t) {
  if (e === t)
    return !0;
  if (e && t && typeof e == "object" && typeof t == "object") {
    if (e.constructor !== t.constructor)
      return !1;
    var n, o, l;
    if (Array.isArray(e)) {
      if (n = e.length, n != t.length)
        return !1;
      for (o = n; o-- !== 0; )
        if (!ie(e[o], t[o]))
          return !1;
      return !0;
    }
    if (e instanceof Map && t instanceof Map) {
      if (e.size !== t.size)
        return !1;
      for (o of e.entries())
        if (!t.has(o[0]))
          return !1;
      for (o of e.entries())
        if (!ie(o[1], t.get(o[0])))
          return !1;
      return !0;
    }
    if (Je(e) && Je(t))
      return !(e.size !== t.size || e.name !== t.name || e.lastModified !== t.lastModified || e.type !== t.type);
    if (e instanceof Set && t instanceof Set) {
      if (e.size !== t.size)
        return !1;
      for (o of e.entries())
        if (!t.has(o[0]))
          return !1;
      return !0;
    }
    if (ArrayBuffer.isView(e) && ArrayBuffer.isView(t)) {
      if (n = e.length, n != t.length)
        return !1;
      for (o = n; o-- !== 0; )
        if (e[o] !== t[o])
          return !1;
      return !0;
    }
    if (e.constructor === RegExp)
      return e.source === t.source && e.flags === t.flags;
    if (e.valueOf !== Object.prototype.valueOf)
      return e.valueOf() === t.valueOf();
    if (e.toString !== Object.prototype.toString)
      return e.toString() === t.toString();
    for (l = Object.keys(e), n = l.length, o = n; o-- !== 0; ) {
      var a = l[o];
      if (!ie(e[a], t[a]))
        return !1;
    }
    return !0;
  }
  return e !== e && t !== t;
}
function Je(e) {
  return un ? e instanceof File : !1;
}
function Fe(e) {
  return he(e) ? e.replace(/\[|\]/gi, "") : e;
}
function z(e, t, n) {
  return e ? he(t) ? e[Fe(t)] : (t || "").split(/\.|\[(\d+)\]/).filter(Boolean).reduce((l, a) => dn(l) && a in l ? l[a] : n, e) : n;
}
function U(e, t, n) {
  if (he(t)) {
    e[Fe(t)] = n;
    return;
  }
  const o = t.split(/\.|\[(\d+)\]/).filter(Boolean);
  let l = e;
  for (let a = 0; a < o.length; a++) {
    if (a === o.length - 1) {
      l[o[a]] = n;
      return;
    }
    (!(o[a] in l) || lt(l[o[a]])) && (l[o[a]] = Ne(o[a + 1]) ? [] : {}), l = l[o[a]];
  }
}
function Ae(e, t) {
  if (Array.isArray(e) && Ne(t)) {
    e.splice(Number(t), 1);
    return;
  }
  Q(e) && delete e[t];
}
function Ye(e, t) {
  if (he(t)) {
    delete e[Fe(t)];
    return;
  }
  const n = t.split(/\.|\[(\d+)\]/).filter(Boolean);
  let o = e;
  for (let a = 0; a < n.length; a++) {
    if (a === n.length - 1) {
      Ae(o, n[a]);
      break;
    }
    if (!(n[a] in o) || lt(o[n[a]]))
      break;
    o = o[n[a]];
  }
  const l = n.map((a, s) => z(e, n.slice(0, s).join(".")));
  for (let a = l.length - 1; a >= 0; a--)
    if (fn(l[a])) {
      if (a === 0) {
        Ae(e, n[0]);
        continue;
      }
      Ae(l[a - 1], n[a - 1]);
    }
}
function N(e) {
  return Object.keys(e);
}
function pn(e, t) {
  let n, o;
  return function(...l) {
    const a = this;
    return n || (n = !0, setTimeout(() => n = !1, t), o = e.apply(a, l)), o;
  };
}
function Xe(e, t = 0) {
  let n = null, o = [];
  return function(...l) {
    return n && clearTimeout(n), n = setTimeout(() => {
      const a = e(...l);
      o.forEach((s) => s(a)), o = [];
    }, t), new Promise((a) => o.push(a));
  };
}
function mn(e, t) {
  let n;
  return async function(...l) {
    const a = e(...l);
    n = a;
    const s = await a;
    return a !== n ? s : (n = void 0, t(s, l));
  };
}
function Ze(e) {
  return Array.isArray(e) ? e : e ? [e] : [];
}
function fe(e, t) {
  const n = {};
  for (const o in e)
    t.includes(o) || (n[o] = e[o]);
  return n;
}
function gn(e) {
  let t = null, n = [];
  return function(...o) {
    const l = B(() => {
      if (t !== l)
        return;
      const a = e(...o);
      n.forEach((s) => s(a)), n = [], t = null;
    });
    return t = l, new Promise((a) => n.push(a));
  };
}
function Ie(e) {
  if (ct(e))
    return e._value;
}
function ct(e) {
  return "_value" in e;
}
function yn(e) {
  return e.type === "number" || e.type === "range" ? Number.isNaN(e.valueAsNumber) ? e.value : e.valueAsNumber : e.value;
}
function et(e) {
  if (!st(e))
    return e;
  const t = e.target;
  if (cn(t.type) && ct(t))
    return Ie(t);
  if (t.type === "file" && t.files) {
    const n = Array.from(t.files);
    return t.multiple ? n : n[0];
  }
  if (vn(t))
    return Array.from(t.options).filter((n) => n.selected && !n.disabled).map(Ie);
  if (ut(t)) {
    const n = Array.from(t.options).find((o) => o.selected);
    return n ? Ie(n) : t.value;
  }
  return yn(t);
}
function bn(e) {
  const t = {};
  return Object.defineProperty(t, "_$$isNormalized", {
    value: !0,
    writable: !1,
    enumerable: !1,
    configurable: !1
  }), e ? Q(e) && e._$$isNormalized ? e : Q(e) ? Object.keys(e).reduce((n, o) => {
    const l = On(e[o]);
    return e[o] !== !1 && (n[o] = tt(l)), n;
  }, t) : typeof e != "string" ? t : e.split("|").reduce((n, o) => {
    const l = _n(o);
    return l.name && (n[l.name] = tt(l.params)), n;
  }, t) : t;
}
function On(e) {
  return e === !0 ? [] : Array.isArray(e) || Q(e) ? e : [e];
}
function tt(e) {
  const t = (n) => typeof n == "string" && n[0] === "@" ? Sn(n.slice(1)) : n;
  return Array.isArray(e) ? e.map(t) : e instanceof RegExp ? [e] : Object.keys(e).reduce((n, o) => (n[o] = t(e[o]), n), {});
}
const _n = (e) => {
  let t = [];
  const n = e.split(":")[0];
  return e.includes(":") && (t = e.split(":").slice(1).join(":").split(",")), { name: n, params: t };
};
function Sn(e) {
  const t = (n) => z(n, e) || n[e];
  return t.__locatorRef = e, t;
}
const Vn = {
  generateMessage: ({ field: e }) => `${e} is not valid.`,
  bails: !0,
  validateOnBlur: !0,
  validateOnChange: !0,
  validateOnInput: !1,
  validateOnModelUpdate: !0
};
let En = Object.assign({}, Vn);
const re = () => En;
async function wn(e, t, n = {}) {
  const o = n == null ? void 0 : n.bails, l = {
    name: (n == null ? void 0 : n.name) || "{field}",
    rules: t,
    label: n == null ? void 0 : n.label,
    bails: o ?? !0,
    formData: (n == null ? void 0 : n.values) || {}
  }, s = (await Pn(l, e)).errors;
  return {
    errors: s,
    valid: !s.length
  };
}
async function Pn(e, t) {
  if (q(e.rules) || at(e.rules))
    return In(t, e.rules);
  if (D(e.rules) || Array.isArray(e.rules)) {
    const s = {
      field: e.label || e.name,
      name: e.name,
      label: e.label,
      form: e.formData,
      value: t
    }, f = Array.isArray(e.rules) ? e.rules : [e.rules], v = f.length, d = [];
    for (let g = 0; g < v; g++) {
      const V = f[g], E = await V(t, s);
      if (!(typeof E != "string" && !Array.isArray(E) && E)) {
        if (Array.isArray(E))
          d.push(...E);
        else {
          const L = typeof E == "string" ? E : ft(s);
          d.push(L);
        }
        if (e.bails)
          return {
            errors: d
          };
      }
    }
    return {
      errors: d
    };
  }
  const n = Object.assign(Object.assign({}, e), { rules: bn(e.rules) }), o = [], l = Object.keys(n.rules), a = l.length;
  for (let s = 0; s < a; s++) {
    const f = l[s], v = await Tn(n, t, {
      name: f,
      params: n.rules[f]
    });
    if (v.error && (o.push(v.error), e.bails))
      return {
        errors: o
      };
  }
  return {
    errors: o
  };
}
function An(e) {
  return !!e && e.name === "ValidationError";
}
function dt(e) {
  return {
    __type: "VVTypedSchema",
    async parse(n) {
      var o;
      try {
        return {
          output: await e.validate(n, { abortEarly: !1 }),
          errors: []
        };
      } catch (l) {
        if (!An(l))
          throw l;
        if (!(!((o = l.inner) === null || o === void 0) && o.length) && l.errors.length)
          return { errors: [{ path: l.path, errors: l.errors }] };
        const a = l.inner.reduce((s, f) => {
          const v = f.path || "";
          return s[v] || (s[v] = { errors: [], path: v }), s[v].errors.push(...f.errors), s;
        }, {});
        return { errors: Object.values(a) };
      }
    }
  };
}
async function In(e, t) {
  const o = await (q(t) ? t : dt(t)).parse(e), l = [];
  for (const a of o.errors)
    a.errors.length && l.push(...a.errors);
  return {
    errors: l
  };
}
async function Tn(e, t, n) {
  const o = ln(n.name);
  if (!o)
    throw new Error(`No such validator '${n.name}' exists.`);
  const l = jn(n.params, e.formData), a = {
    field: e.label || e.name,
    name: e.name,
    label: e.label,
    value: t,
    form: e.formData,
    rule: Object.assign(Object.assign({}, n), { params: l })
  }, s = await o(t, l, a);
  return typeof s == "string" ? {
    error: s
  } : {
    error: s ? void 0 : ft(a)
  };
}
function ft(e) {
  const t = re().generateMessage;
  return t ? t(e) : "Field is invalid";
}
function jn(e, t) {
  const n = (o) => sn(o) ? o(t) : o;
  return Array.isArray(e) ? e.map(n) : Object.keys(e).reduce((o, l) => (o[l] = n(e[l]), o), {});
}
async function Cn(e, t) {
  const o = await (q(e) ? e : dt(e)).parse(b(t)), l = {}, a = {};
  for (const s of o.errors) {
    const f = s.errors, v = (s.path || "").replace(/\["(\d+)"\]/g, (d, g) => `[${g}]`);
    l[v] = { valid: !f.length, errors: f }, f.length && (a[v] = f[0]);
  }
  return {
    valid: !o.errors.length,
    results: l,
    errors: a,
    values: o.value
  };
}
async function kn(e, t, n) {
  const l = N(e).map(async (d) => {
    var g, V, E;
    const w = (g = n == null ? void 0 : n.names) === null || g === void 0 ? void 0 : g[d], L = await wn(z(t, d), e[d], {
      name: (w == null ? void 0 : w.name) || d,
      label: w == null ? void 0 : w.label,
      values: t,
      bails: (E = (V = n == null ? void 0 : n.bailsMap) === null || V === void 0 ? void 0 : V[d]) !== null && E !== void 0 ? E : !0
    });
    return Object.assign(Object.assign({}, L), { path: d });
  });
  let a = !0;
  const s = await Promise.all(l), f = {}, v = {};
  for (const d of s)
    f[d.path] = {
      valid: d.valid,
      errors: d.errors
    }, d.valid || (a = !1, v[d.path] = d.errors[0]);
  return {
    valid: a,
    results: f,
    errors: v
  };
}
function Nn(e) {
  process.env.NODE_ENV !== "production" && tn({
    id: "vee-validate-devtools-plugin",
    label: "VeeValidate Plugin",
    packageName: "vee-validate",
    homepage: "https://vee-validate.logaretm.com/v4",
    app: e,
    logo: "https://vee-validate.logaretm.com/v4/logo.png"
  }, Rn);
}
const oe = {}, vt = {};
let G;
const ke = pn(() => {
  setTimeout(async () => {
    await B(), G == null || G.sendInspectorState(Y), G == null || G.sendInspectorTree(Y);
  }, 100);
}, 100);
function Fn(e) {
  const t = it();
  if (!G) {
    const n = t == null ? void 0 : t.appContext.app;
    if (!n)
      return;
    Nn(n);
  }
  oe[e.formId] = Object.assign({}, e), oe[e.formId]._vm = t, Lt(() => {
    delete oe[e.formId], ke();
  }), ke();
}
const Y = "vee-validate-inspector", k = {
  error: 12405579,
  success: 448379,
  unknown: 5522283,
  white: 16777215,
  black: 0,
  blue: 218007,
  purple: 12157168,
  orange: 16099682,
  gray: 12304330
};
let S = null;
function Rn(e) {
  G = e, e.addInspector({
    id: Y,
    icon: "rule",
    label: "vee-validate",
    noSelectionText: "Select a vee-validate node to inspect",
    actions: [
      {
        icon: "done_outline",
        tooltip: "Validate selected item",
        action: async () => {
          if (!S) {
            console.error("There is not a valid selected vee-validate node or component");
            return;
          }
          if (S.type === "field") {
            await S.field.validate();
            return;
          }
          if (S.type === "form") {
            await S.form.validate();
            return;
          }
          S.type === "pathState" && await S.form.validateField(S.state.path);
        }
      },
      {
        icon: "delete_sweep",
        tooltip: "Clear validation state of the selected item",
        action: () => {
          if (!S) {
            console.error("There is not a valid selected vee-validate node or component");
            return;
          }
          if (S.type === "field") {
            S.field.resetField();
            return;
          }
          S.type === "form" && S.form.resetForm(), S.type === "pathState" && S.form.resetField(S.state.path);
        }
      }
    ]
  }), e.on.getInspectorTree((t) => {
    if (t.inspectorId !== Y)
      return;
    const n = Object.values(oe), o = Object.values(vt);
    t.rootNodes = [
      ...n.map(xn),
      ...o.map((l) => Dn(l))
    ];
  }), e.on.getInspectorState((t, n) => {
    if (t.inspectorId !== Y || n.currentTab !== `custom-inspector:${Y}`)
      return;
    const { form: o, field: l, state: a, type: s } = Mn(t.nodeId);
    if (o && s === "form") {
      t.state = Ln(o), S = { type: "form", form: o };
      return;
    }
    if (a && s === "pathState" && o) {
      t.state = nt(a), S = { type: "pathState", state: a, form: o };
      return;
    }
    if (l && s === "field") {
      t.state = nt({
        errors: l.errors.value,
        dirty: l.meta.dirty,
        valid: l.meta.valid,
        touched: l.meta.touched,
        value: l.value.value,
        initialValue: l.meta.initialValue
      }), S = { field: l, type: "field" };
      return;
    }
    S = null;
  });
}
function xn(e) {
  const { textColor: t, bgColor: n } = pt(e.meta.value.valid), o = {};
  Object.values(e.getAllPathStates()).forEach((s) => {
    U(o, F(s.path), Bn(s, e));
  });
  function l(s, f = []) {
    const v = [...f].pop();
    return "id" in s ? Object.assign(Object.assign({}, s), { label: v || s.label }) : Q(s) ? {
      id: `${f.join(".")}`,
      label: v || "",
      children: Object.keys(s).map((d) => l(s[d], [...f, d]))
    } : Array.isArray(s) ? {
      id: `${f.join(".")}`,
      label: `${v}[]`,
      children: s.map((d, g) => l(d, [...f, String(g)]))
    } : { id: "", label: "", children: [] };
  }
  const { children: a } = l(o);
  return {
    id: Re(e),
    label: "Form",
    children: a,
    tags: [
      {
        label: "Form",
        textColor: t,
        backgroundColor: n
      },
      {
        label: `${e.getAllPathStates().length} fields`,
        textColor: k.white,
        backgroundColor: k.unknown
      }
    ]
  };
}
function Bn(e, t) {
  return {
    id: Re(t, e),
    label: F(e.path),
    tags: ht(e.multiple, e.fieldsCount, e.type, e.valid, t)
  };
}
function Dn(e, t) {
  return {
    id: Re(t, e),
    label: F(e.name),
    tags: ht(!1, 1, e.type, e.meta.valid, t)
  };
}
function ht(e, t, n, o, l) {
  const { textColor: a, bgColor: s } = pt(o);
  return [
    e ? void 0 : {
      label: "Field",
      textColor: a,
      backgroundColor: s
    },
    l ? void 0 : {
      label: "Standalone",
      textColor: k.black,
      backgroundColor: k.gray
    },
    n === "checkbox" ? {
      label: "Checkbox",
      textColor: k.white,
      backgroundColor: k.blue
    } : void 0,
    n === "radio" ? {
      label: "Radio",
      textColor: k.white,
      backgroundColor: k.purple
    } : void 0,
    e ? {
      label: "Multiple",
      textColor: k.black,
      backgroundColor: k.orange
    } : void 0
  ].filter(Boolean);
}
function Re(e, t) {
  const n = t ? "path" in t ? "pathState" : "field" : "form", o = t ? "path" in t ? t == null ? void 0 : t.path : F(t == null ? void 0 : t.name) : "", l = { f: e == null ? void 0 : e.formId, ff: o, type: n };
  return btoa(encodeURIComponent(JSON.stringify(l)));
}
function Mn(e) {
  try {
    const t = JSON.parse(decodeURIComponent(atob(e))), n = oe[t.f];
    if (!n && t.ff) {
      const l = vt[t.ff];
      return l ? {
        type: t.type,
        field: l
      } : {};
    }
    if (!n)
      return {};
    const o = n.getPathState(t.ff);
    return {
      type: t.type,
      form: n,
      state: o
    };
  } catch {
  }
  return {};
}
function nt(e) {
  return {
    "Field state": [
      { key: "errors", value: e.errors },
      {
        key: "initialValue",
        value: e.initialValue
      },
      {
        key: "currentValue",
        value: e.value
      },
      {
        key: "touched",
        value: e.touched
      },
      {
        key: "dirty",
        value: e.dirty
      },
      {
        key: "valid",
        value: e.valid
      }
    ]
  };
}
function Ln(e) {
  const { errorBag: t, meta: n, values: o, isSubmitting: l, isValidating: a, submitCount: s } = e;
  return {
    "Form state": [
      {
        key: "submitCount",
        value: s.value
      },
      {
        key: "isSubmitting",
        value: l.value
      },
      {
        key: "isValidating",
        value: a.value
      },
      {
        key: "touched",
        value: n.value.touched
      },
      {
        key: "dirty",
        value: n.value.dirty
      },
      {
        key: "valid",
        value: n.value.valid
      },
      {
        key: "initialValues",
        value: n.value.initialValues
      },
      {
        key: "currentValues",
        value: o
      },
      {
        key: "errors",
        value: N(t.value).reduce((f, v) => {
          var d;
          const g = (d = t.value[v]) === null || d === void 0 ? void 0 : d[0];
          return g && (f[v] = g), f;
        }, {})
      }
    ]
  };
}
function pt(e) {
  return {
    bgColor: e ? k.success : k.error,
    textColor: e ? k.black : k.white
  };
}
let Un = 0;
const ve = ["bails", "fieldsCount", "id", "multiple", "type", "validate"];
function mt(e) {
  const t = Object.assign({}, T((e == null ? void 0 : e.initialValues) || {})), n = F(e == null ? void 0 : e.validationSchema);
  return n && q(n) && D(n.cast) ? b(n.cast(t) || {}) : b(t);
}
function zn(e) {
  var t;
  const n = Un++;
  let o = 0;
  const l = W(!1), a = W(!1), s = W(0), f = [], v = je(mt(e)), d = W([]), g = W({}), V = W({}), E = gn(() => {
    V.value = d.value.reduce((i, r) => (i[de(T(r.path))] = r, i), {});
  });
  function w(i, r) {
    const u = j(i);
    if (!u) {
      typeof i == "string" && (g.value[de(i)] = Ze(r));
      return;
    }
    if (typeof i == "string") {
      const c = de(i);
      g.value[c] && delete g.value[c];
    }
    u.errors = Ze(r), u.valid = !u.errors.length;
  }
  function L(i) {
    N(i).forEach((r) => {
      w(r, i[r]);
    });
  }
  e != null && e.initialErrors && L(e.initialErrors);
  const ae = A(() => {
    const i = d.value.reduce((r, u) => (u.errors.length && (r[u.path] = u.errors), r), {});
    return Object.assign(Object.assign({}, g.value), i);
  }), pe = A(() => N(ae.value).reduce((i, r) => {
    const u = ae.value[r];
    return u != null && u.length && (i[r] = u[0]), i;
  }, {})), gt = A(() => d.value.reduce((i, r) => (i[r.path] = { name: r.path || "", label: r.label || "" }, i), {})), yt = A(() => d.value.reduce((i, r) => {
    var u;
    return i[r.path] = (u = r.bails) !== null && u !== void 0 ? u : !0, i;
  }, {})), xe = Object.assign({}, (e == null ? void 0 : e.initialErrors) || {}), bt = (t = e == null ? void 0 : e.keepValuesOnUnmount) !== null && t !== void 0 ? t : !1, { initialValues: X, originalInitialValues: Z, setInitialValues: Ot } = Wn(d, v, e), Be = $n(d, v, Z, pe), De = A(() => d.value.reduce((i, r) => {
    const u = z(v, r.path);
    return U(i, r.path, u), i;
  }, {})), R = e == null ? void 0 : e.validationSchema;
  function ue(i, r) {
    var u, c;
    const p = A(() => z(X.value, T(i))), h = V.value[T(i)], m = (r == null ? void 0 : r.type) === "checkbox" || (r == null ? void 0 : r.type) === "radio";
    if (h && m) {
      h.multiple = !0;
      const x = o++;
      return Array.isArray(h.id) ? h.id.push(x) : h.id = [h.id, x], h.fieldsCount++, h.__flags.pendingUnmount[x] = !1, h;
    }
    const O = A(() => z(v, T(i))), _ = T(i), I = te.findIndex((x) => x === _);
    I !== -1 && te.splice(I, 1);
    const y = A(() => {
      var x, ne, Ve, We, Ee, we;
      return q(R) ? (Ve = (ne = (x = R).describe) === null || ne === void 0 ? void 0 : ne.call(x, T(i)).required) !== null && Ve !== void 0 ? Ve : !1 : q(r == null ? void 0 : r.schema) && (we = (Ee = (We = r == null ? void 0 : r.schema).describe) === null || Ee === void 0 ? void 0 : Ee.call(We).required) !== null && we !== void 0 ? we : !1;
    }), P = o++, C = je({
      id: P,
      path: i,
      touched: !1,
      pending: !1,
      valid: !0,
      validated: !!(!((u = xe[_]) === null || u === void 0) && u.length),
      required: y,
      initialValue: p,
      errors: Ut([]),
      bails: (c = r == null ? void 0 : r.bails) !== null && c !== void 0 ? c : !1,
      label: r == null ? void 0 : r.label,
      type: (r == null ? void 0 : r.type) || "default",
      value: O,
      multiple: !1,
      __flags: {
        pendingUnmount: { [P]: !1 },
        pendingReset: !1
      },
      fieldsCount: 1,
      validate: r == null ? void 0 : r.validate,
      dirty: A(() => !ie(F(O), F(p)))
    });
    return d.value.push(C), V.value[_] = C, E(), pe.value[_] && !xe[_] && B(() => {
      H(_, { mode: "silent" });
    }), Ge(i) && Pe(i, (x) => {
      E();
      const ne = b(O.value);
      V.value[x] = C, B(() => {
        U(v, x, ne);
      });
    }), C;
  }
  const _t = Xe($e, 5), St = Xe($e, 5), Me = mn(async (i) => await (i === "silent" ? _t() : St()), (i, [r]) => {
    const u = N(M.errorBag.value), p = [
      .../* @__PURE__ */ new Set([...N(i.results), ...d.value.map((h) => h.path), ...u])
    ].sort().reduce((h, m) => {
      var O;
      const _ = m, I = j(_) || Vt(_), y = ((O = i.results[_]) === null || O === void 0 ? void 0 : O.errors) || [], P = T(I == null ? void 0 : I.path) || _, C = Gn({ errors: y, valid: !y.length }, h.results[P]);
      return h.results[P] = C, C.valid || (h.errors[P] = C.errors[0]), I && g.value[P] && delete g.value[P], I ? (I.valid = C.valid, r === "silent" || r === "validated-only" && !I.validated || w(I, C.errors), h) : (w(P, y), h);
    }, { valid: i.valid, results: {}, errors: {} });
    return i.values && (p.values = i.values), N(p.results).forEach((h) => {
      var m;
      const O = j(h);
      O && r !== "silent" && (r === "validated-only" && !O.validated || w(O, (m = p.results[h]) === null || m === void 0 ? void 0 : m.errors));
    }), p;
  });
  function ee(i) {
    d.value.forEach(i);
  }
  function j(i) {
    const r = typeof i == "string" ? de(i) : i;
    return typeof r == "string" ? V.value[r] : r;
  }
  function Vt(i) {
    return d.value.filter((u) => i.startsWith(u.path)).reduce((u, c) => u ? c.path.length > u.path.length ? c : u : c, void 0);
  }
  let te = [], se;
  function Et(i) {
    return te.push(i), se || (se = B(() => {
      [...te].sort().reverse().forEach((u) => {
        Ye(v, u);
      }), te = [], se = null;
    })), se;
  }
  function Le(i) {
    return function(u, c) {
      return function(h) {
        return h instanceof Event && (h.preventDefault(), h.stopPropagation()), ee((m) => m.touched = !0), l.value = !0, s.value++, K().then((m) => {
          const O = b(v);
          if (m.valid && typeof u == "function") {
            const _ = b(De.value);
            let I = i ? _ : O;
            return m.values && (I = m.values), u(I, {
              evt: h,
              controlledValues: _,
              setErrors: L,
              setFieldError: w,
              setTouched: be,
              setFieldTouched: ce,
              setValues: ge,
              setFieldValue: $,
              resetForm: Oe,
              resetField: Ue
            });
          }
          !m.valid && typeof c == "function" && c({
            values: O,
            evt: h,
            errors: m.errors,
            results: m.results
          });
        }).then((m) => (l.value = !1, m), (m) => {
          throw l.value = !1, m;
        });
      };
    };
  }
  const me = Le(!1);
  me.withControlled = Le(!0);
  function wt(i, r) {
    const u = d.value.findIndex((p) => p.path === i && (Array.isArray(p.id) ? p.id.includes(r) : p.id === r)), c = d.value[u];
    if (!(u === -1 || !c)) {
      if (B(() => {
        H(i, { mode: "silent", warn: !1 });
      }), c.multiple && c.fieldsCount && c.fieldsCount--, Array.isArray(c.id)) {
        const p = c.id.indexOf(r);
        p >= 0 && c.id.splice(p, 1), delete c.__flags.pendingUnmount[r];
      }
      (!c.multiple || c.fieldsCount <= 0) && (d.value.splice(u, 1), ze(i), E(), delete V.value[i]);
    }
  }
  function Pt(i) {
    N(V.value).forEach((r) => {
      r.startsWith(i) && delete V.value[r];
    }), d.value = d.value.filter((r) => !r.path.startsWith(i)), B(() => {
      E();
    });
  }
  const M = {
    formId: n,
    values: v,
    controlledValues: De,
    errorBag: ae,
    errors: pe,
    schema: R,
    submitCount: s,
    meta: Be,
    isSubmitting: l,
    isValidating: a,
    fieldArrays: f,
    keepValuesOnUnmount: bt,
    validateSchema: F(R) ? Me : void 0,
    validate: K,
    setFieldError: w,
    validateField: H,
    setFieldValue: $,
    setValues: ge,
    setErrors: L,
    setFieldTouched: ce,
    setTouched: be,
    resetForm: Oe,
    resetField: Ue,
    handleSubmit: me,
    useFieldModel: Nt,
    defineInputBinds: Ft,
    defineComponentBinds: Rt,
    defineField: Se,
    stageInitialValue: Ct,
    unsetInitialValue: ze,
    setFieldInitialValue: _e,
    createPathState: ue,
    getPathState: j,
    unsetPathValue: Et,
    removePathState: wt,
    initialValues: X,
    getAllPathStates: () => d.value,
    destroyPath: Pt,
    isFieldTouched: It,
    isFieldDirty: Tt,
    isFieldValid: jt
  };
  function $(i, r, u = !0) {
    const c = b(r), p = typeof i == "string" ? i : i.path;
    j(p) || ue(p), U(v, p, c), u && H(p);
  }
  function At(i, r = !0) {
    N(v).forEach((u) => {
      delete v[u];
    }), N(i).forEach((u) => {
      $(u, i[u], !1);
    }), r && K();
  }
  function ge(i, r = !0) {
    le(v, i), f.forEach((u) => u && u.reset()), r && K();
  }
  function ye(i, r) {
    const u = j(T(i)) || ue(i);
    return A({
      get() {
        return u.value;
      },
      set(c) {
        var p;
        const h = T(i);
        $(h, c, (p = T(r)) !== null && p !== void 0 ? p : !1);
      }
    });
  }
  function ce(i, r) {
    const u = j(i);
    u && (u.touched = r);
  }
  function It(i) {
    const r = j(i);
    return r ? r.touched : d.value.filter((u) => u.path.startsWith(i)).some((u) => u.touched);
  }
  function Tt(i) {
    const r = j(i);
    return r ? r.dirty : d.value.filter((u) => u.path.startsWith(i)).some((u) => u.dirty);
  }
  function jt(i) {
    const r = j(i);
    return r ? r.valid : d.value.filter((u) => u.path.startsWith(i)).every((u) => u.valid);
  }
  function be(i) {
    if (typeof i == "boolean") {
      ee((r) => {
        r.touched = i;
      });
      return;
    }
    N(i).forEach((r) => {
      ce(r, !!i[r]);
    });
  }
  function Ue(i, r) {
    var u;
    const c = r && "value" in r ? r.value : z(X.value, i), p = j(i);
    p && (p.__flags.pendingReset = !0), _e(i, b(c), !0), $(i, c, !1), ce(i, (u = r == null ? void 0 : r.touched) !== null && u !== void 0 ? u : !1), w(i, (r == null ? void 0 : r.errors) || []), B(() => {
      p && (p.__flags.pendingReset = !1);
    });
  }
  function Oe(i, r) {
    let u = b(i != null && i.values ? i.values : Z.value);
    u = r != null && r.force ? u : le(Z.value, u), u = q(R) && D(R.cast) ? R.cast(u) : u, Ot(u), ee((c) => {
      var p;
      c.__flags.pendingReset = !0, c.validated = !1, c.touched = ((p = i == null ? void 0 : i.touched) === null || p === void 0 ? void 0 : p[c.path]) || !1, $(c.path, z(u, c.path), !1), w(c.path, void 0);
    }), r != null && r.force ? At(u, !1) : ge(u, !1), L((i == null ? void 0 : i.errors) || {}), s.value = (i == null ? void 0 : i.submitCount) || 0, B(() => {
      K({ mode: "silent" }), ee((c) => {
        c.__flags.pendingReset = !1;
      });
    });
  }
  async function K(i) {
    const r = (i == null ? void 0 : i.mode) || "force";
    if (r === "force" && ee((h) => h.validated = !0), M.validateSchema)
      return M.validateSchema(r);
    a.value = !0;
    const u = await Promise.all(d.value.map((h) => h.validate ? h.validate(i).then((m) => ({
      key: h.path,
      valid: m.valid,
      errors: m.errors
    })) : Promise.resolve({
      key: h.path,
      valid: !0,
      errors: []
    })));
    a.value = !1;
    const c = {}, p = {};
    for (const h of u)
      c[h.key] = {
        valid: h.valid,
        errors: h.errors
      }, h.errors.length && (p[h.key] = h.errors[0]);
    return {
      valid: u.every((h) => h.valid),
      results: c,
      errors: p
    };
  }
  async function H(i, r) {
    var u;
    const c = j(i);
    if (c && (r == null ? void 0 : r.mode) !== "silent" && (c.validated = !0), R) {
      const { results: h } = await Me((r == null ? void 0 : r.mode) || "validated-only");
      return h[i] || { errors: [], valid: !0 };
    }
    return c != null && c.validate ? c.validate(r) : (!c && ((u = r == null ? void 0 : r.warn) !== null && u !== void 0 ? u : !0) && process.env.NODE_ENV !== "production" && xt(`field with path ${i} was not found`), Promise.resolve({ errors: [], valid: !0 }));
  }
  function ze(i) {
    Ye(X.value, i);
  }
  function Ct(i, r, u = !1) {
    _e(i, r), U(v, i, r), u && !(e != null && e.initialValues) && U(Z.value, i, b(r));
  }
  function _e(i, r, u = !1) {
    U(X.value, i, b(r)), u && U(Z.value, i, b(r));
  }
  async function $e() {
    const i = F(R);
    if (!i)
      return { valid: !0, results: {}, errors: {} };
    a.value = !0;
    const r = at(i) || q(i) ? await Cn(i, v) : await kn(i, v, {
      names: gt.value,
      bailsMap: yt.value
    });
    return a.value = !1, r;
  }
  const kt = me((i, { evt: r }) => {
    hn(r) && r.target.submit();
  });
  Bt(() => {
    if (e != null && e.initialErrors && L(e.initialErrors), e != null && e.initialTouched && be(e.initialTouched), e != null && e.validateOnMount) {
      K();
      return;
    }
    M.validateSchema && M.validateSchema("silent");
  }), Ge(R) && Pe(R, () => {
    var i;
    (i = M.validateSchema) === null || i === void 0 || i.call(M, "validated-only");
  }), rt(an, M), process.env.NODE_ENV !== "production" && (Fn(M), Pe(() => Object.assign(Object.assign({ errors: ae.value }, Be.value), { values: v, isSubmitting: l.value, isValidating: a.value, submitCount: s.value }), ke, {
    deep: !0
  }));
  function Se(i, r) {
    const u = D(r) || r == null ? void 0 : r.label, c = j(T(i)) || ue(i, { label: u }), p = () => D(r) ? r(fe(c, ve)) : r || {};
    function h() {
      var y;
      c.touched = !0, ((y = p().validateOnBlur) !== null && y !== void 0 ? y : re().validateOnBlur) && H(c.path);
    }
    function m() {
      var y;
      ((y = p().validateOnInput) !== null && y !== void 0 ? y : re().validateOnInput) && B(() => {
        H(c.path);
      });
    }
    function O() {
      var y;
      ((y = p().validateOnChange) !== null && y !== void 0 ? y : re().validateOnChange) && B(() => {
        H(c.path);
      });
    }
    const _ = A(() => {
      const y = {
        onChange: O,
        onInput: m,
        onBlur: h
      };
      return D(r) ? Object.assign(Object.assign({}, y), r(fe(c, ve)).props || {}) : r != null && r.props ? Object.assign(Object.assign({}, y), r.props(fe(c, ve))) : y;
    });
    return [ye(i, () => {
      var y, P, C;
      return (C = (y = p().validateOnModelUpdate) !== null && y !== void 0 ? y : (P = re()) === null || P === void 0 ? void 0 : P.validateOnModelUpdate) !== null && C !== void 0 ? C : !0;
    }), _];
  }
  function Nt(i) {
    return Array.isArray(i) ? i.map((r) => ye(r, !0)) : ye(i);
  }
  function Ft(i, r) {
    const [u, c] = Se(i, r);
    function p() {
      c.value.onBlur();
    }
    function h(O) {
      const _ = et(O);
      $(T(i), _, !1), c.value.onInput();
    }
    function m(O) {
      const _ = et(O);
      $(T(i), _, !1), c.value.onChange();
    }
    return A(() => Object.assign(Object.assign({}, c.value), {
      onBlur: p,
      onInput: h,
      onChange: m,
      value: u.value
    }));
  }
  function Rt(i, r) {
    const [u, c] = Se(i, r), p = j(T(i));
    function h(m) {
      u.value = m;
    }
    return A(() => {
      const m = D(r) ? r(fe(p, ve)) : r || {};
      return Object.assign({ [m.model || "modelValue"]: u.value, [`onUpdate:${m.model || "modelValue"}`]: h }, c.value);
    });
  }
  return Object.assign(Object.assign({}, M), { values: Dt(v), handleReset: () => Oe(), submitForm: kt });
}
function $n(e, t, n, o) {
  const l = {
    touched: "some",
    pending: "some",
    valid: "every"
  }, a = A(() => !ie(t, F(n)));
  function s() {
    const v = e.value;
    return N(l).reduce((d, g) => {
      const V = l[g];
      return d[g] = v[V]((E) => E[g]), d;
    }, {});
  }
  const f = je(s());
  return Mt(() => {
    const v = s();
    f.touched = v.touched, f.valid = v.valid, f.pending = v.pending;
  }), A(() => Object.assign(Object.assign({ initialValues: F(n) }, f), { valid: f.valid && !N(o.value).length, dirty: a.value }));
}
function Wn(e, t, n) {
  const o = mt(n), l = W(o), a = W(b(o));
  function s(f, v = !1) {
    l.value = le(b(l.value) || {}, b(f)), a.value = le(b(a.value) || {}, b(f)), v && e.value.forEach((d) => {
      if (d.touched)
        return;
      const V = z(l.value, d.path);
      U(t, d.path, b(V));
    });
  }
  return {
    initialValues: l,
    originalInitialValues: a,
    setInitialValues: s
  };
}
function Gn(e, t) {
  return t ? {
    valid: e.valid && t.valid,
    errors: [...e.errors, ...t.errors]
  } : e;
}
const Te = /* @__PURE__ */ new WeakMap(), qn = (e, t) => {
  var n;
  const o = (n = it()) == null ? void 0 : n.proxy;
  if (o == null)
    throw new Error("provideLocal must be called in setup");
  Te.has(o) || Te.set(o, /* @__PURE__ */ Object.create(null));
  const l = Te.get(o);
  l[e] = t, rt(e, t);
};
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
const Hn = Symbol("FORM_PROVIDER_CONTEXT"), Qn = (e) => qn(Hn, e), Xn = /* @__PURE__ */ zt({
  name: "FsForm",
  __name: "FsForm",
  props: {
    validationSchema: {},
    initialValues: {},
    initialErrors: {},
    initialTouched: {},
    validateOnMount: { type: Boolean },
    keepValuesOnUnmount: {},
    model: {},
    rules: {},
    labelPosition: {},
    requireAsteriskPosition: {},
    labelWidth: {},
    labelSuffix: {},
    inline: { type: Boolean },
    inlineMessage: { type: Boolean },
    statusIcon: { type: Boolean },
    showMessage: { type: Boolean },
    validateOnRuleChange: { type: Boolean },
    hideRequiredAsterisk: { type: Boolean },
    scrollToError: { type: Boolean },
    scrollIntoViewOptions: {},
    size: {},
    disabled: { type: Boolean }
  },
  setup(e, { expose: t }) {
    const n = e, o = zn(n);
    Qn(o), t({ ...o });
    const l = A(() => ({
      inline: n.inline,
      labelPosition: n.labelPosition || "right",
      labelWidth: n.labelWidth,
      labelSuffix: n.labelSuffix,
      hideRequiredAsterisk: n.hideRequiredAsterisk,
      requireAsteriskPosition: n.requireAsteriskPosition || "left",
      disabled: n.disabled,
      size: n.size,
      showMessage: n.showMessage || !0,
      inlineMessage: n.inlineMessage,
      statusIcon: n.statusIcon,
      validateOnRuleChange: n.validateOnRuleChange || !0,
      scrollToError: n.scrollToError,
      scrollIntoViewOptions: n.scrollIntoViewOptions
    }));
    return (a, s) => ($t(), Wt(F(Ht), qe(He(l.value)), {
      default: Gt(() => [
        qt(a.$slots, "default", qe(He(F(o))))
      ]),
      _: 3
    }, 16));
  }
});
export {
  Xn as default
};
//# sourceMappingURL=FsForm.mjs.map
