import { jsx as ee } from "react/jsx-runtime";
import { lazy as ue, useMemo as ne, useCallback as te } from "react";
import { execute as oe } from "@/common/services/QueryBuilder";
import { showToast as pe } from "@/common/toaster/toaster";
import { useWatch as me } from "react-hook-form";
import './index.css';const se = ue(
  () => import("@/views/feature-components/VerifyRoute.jsx")
), ae = ue(
  () => import("./MedplatFormWrapper-CfKQpZOJ.js").then((e) => e.M)
), ke = [
  {
    path: "medplat/form/:formCode",
    element: /* @__PURE__ */ ee(
      se,
      {
        pageTitle: "General",
        url: "medplat/form",
        component: /* @__PURE__ */ ee(ae, {})
      }
    )
  },
  {
    path: "medplat/form/:formCode/:menuConfigId",
    element: /* @__PURE__ */ ee(se, { url: "medplat/form", component: /* @__PURE__ */ ee(ae, {}) })
  }
];
function ge(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function Re(e) {
  if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
  var r = e.default;
  if (typeof r == "function") {
    var a = function u() {
      return this instanceof u ? Reflect.construct(r, arguments, this.constructor) : r.apply(this, arguments);
    };
    a.prototype = r.prototype;
  } else a = {};
  return Object.defineProperty(a, "__esModule", { value: !0 }), Object.keys(e).forEach(function(u) {
    var l = Object.getOwnPropertyDescriptor(e, u);
    Object.defineProperty(a, u, l.get ? l : {
      enumerable: !0,
      get: function() {
        return e[u];
      }
    });
  }), a;
}
var re = { exports: {} }, ye = re.exports, ie;
function _e() {
  return ie || (ie = 1, (function(e, r) {
    (function(a, u) {
      e.exports = u();
    })(ye, (function() {
      var a = 1e3, u = 6e4, l = 36e5, p = "millisecond", g = "second", f = "minute", O = "hour", m = "day", L = "week", P = "month", U = "quarter", w = "year", E = "date", H = "Invalid Date", o = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, b = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, C = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(c) {
        var n = ["th", "st", "nd", "rd"], t = c % 100;
        return "[" + c + (n[(t - 20) % 10] || n[t] || n[0]) + "]";
      } }, y = function(c, n, t) {
        var i = String(c);
        return !i || i.length >= n ? c : "" + Array(n + 1 - i.length).join(t) + c;
      }, $ = { s: y, z: function(c) {
        var n = -c.utcOffset(), t = Math.abs(n), i = Math.floor(t / 60), s = t % 60;
        return (n <= 0 ? "+" : "-") + y(i, 2, "0") + ":" + y(s, 2, "0");
      }, m: function c(n, t) {
        if (n.date() < t.date()) return -c(t, n);
        var i = 12 * (t.year() - n.year()) + (t.month() - n.month()), s = n.clone().add(i, P), d = t - s < 0, h = n.clone().add(i + (d ? -1 : 1), P);
        return +(-(i + (t - s) / (d ? s - h : h - s)) || 0);
      }, a: function(c) {
        return c < 0 ? Math.ceil(c) || 0 : Math.floor(c);
      }, p: function(c) {
        return { M: P, y: w, w: L, d: m, D: E, h: O, m: f, s: g, ms: p, Q: U }[c] || String(c || "").toLowerCase().replace(/s$/, "");
      }, u: function(c) {
        return c === void 0;
      } }, T = "en", M = {};
      M[T] = C;
      var j = "$isDayjsObject", W = function(c) {
        return c instanceof N || !(!c || !c[j]);
      }, k = function c(n, t, i) {
        var s;
        if (!n) return T;
        if (typeof n == "string") {
          var d = n.toLowerCase();
          M[d] && (s = d), t && (M[d] = t, s = d);
          var h = n.split("-");
          if (!s && h.length > 1) return c(h[0]);
        } else {
          var A = n.name;
          M[A] = n, s = A;
        }
        return !i && s && (T = s), s || !i && T;
      }, S = function(c, n) {
        if (W(c)) return c.clone();
        var t = typeof n == "object" ? n : {};
        return t.date = c, t.args = arguments, new N(t);
      }, _ = $;
      _.l = k, _.i = W, _.w = function(c, n) {
        return S(c, { locale: n.$L, utc: n.$u, x: n.$x, $offset: n.$offset });
      };
      var N = (function() {
        function c(t) {
          this.$L = k(t.locale, null, !0), this.parse(t), this.$x = this.$x || t.x || {}, this[j] = !0;
        }
        var n = c.prototype;
        return n.parse = function(t) {
          this.$d = (function(i) {
            var s = i.date, d = i.utc;
            if (s === null) return /* @__PURE__ */ new Date(NaN);
            if (_.u(s)) return /* @__PURE__ */ new Date();
            if (s instanceof Date) return new Date(s);
            if (typeof s == "string" && !/Z$/i.test(s)) {
              var h = s.match(o);
              if (h) {
                var A = h[2] - 1 || 0, D = (h[7] || "0").substring(0, 3);
                return d ? new Date(Date.UTC(h[1], A, h[3] || 1, h[4] || 0, h[5] || 0, h[6] || 0, D)) : new Date(h[1], A, h[3] || 1, h[4] || 0, h[5] || 0, h[6] || 0, D);
              }
            }
            return new Date(s);
          })(t), this.init();
        }, n.init = function() {
          var t = this.$d;
          this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds();
        }, n.$utils = function() {
          return _;
        }, n.isValid = function() {
          return this.$d.toString() !== H;
        }, n.isSame = function(t, i) {
          var s = S(t);
          return this.startOf(i) <= s && s <= this.endOf(i);
        }, n.isAfter = function(t, i) {
          return S(t) < this.startOf(i);
        }, n.isBefore = function(t, i) {
          return this.endOf(i) < S(t);
        }, n.$g = function(t, i, s) {
          return _.u(t) ? this[i] : this.set(s, t);
        }, n.unix = function() {
          return Math.floor(this.valueOf() / 1e3);
        }, n.valueOf = function() {
          return this.$d.getTime();
        }, n.startOf = function(t, i) {
          var s = this, d = !!_.u(i) || i, h = _.p(t), A = function(J, F) {
            var R = _.w(s.$u ? Date.UTC(s.$y, F, J) : new Date(s.$y, F, J), s);
            return d ? R : R.endOf(m);
          }, D = function(J, F) {
            return _.w(s.toDate()[J].apply(s.toDate("s"), (d ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(F)), s);
          }, I = this.$W, V = this.$M, Y = this.$D, z = "set" + (this.$u ? "UTC" : "");
          switch (h) {
            case w:
              return d ? A(1, 0) : A(31, 11);
            case P:
              return d ? A(1, V) : A(0, V + 1);
            case L:
              var v = this.$locale().weekStart || 0, G = (I < v ? I + 7 : I) - v;
              return A(d ? Y - G : Y + (6 - G), V);
            case m:
            case E:
              return D(z + "Hours", 0);
            case O:
              return D(z + "Minutes", 1);
            case f:
              return D(z + "Seconds", 2);
            case g:
              return D(z + "Milliseconds", 3);
            default:
              return this.clone();
          }
        }, n.endOf = function(t) {
          return this.startOf(t, !1);
        }, n.$set = function(t, i) {
          var s, d = _.p(t), h = "set" + (this.$u ? "UTC" : ""), A = (s = {}, s[m] = h + "Date", s[E] = h + "Date", s[P] = h + "Month", s[w] = h + "FullYear", s[O] = h + "Hours", s[f] = h + "Minutes", s[g] = h + "Seconds", s[p] = h + "Milliseconds", s)[d], D = d === m ? this.$D + (i - this.$W) : i;
          if (d === P || d === w) {
            var I = this.clone().set(E, 1);
            I.$d[A](D), I.init(), this.$d = I.set(E, Math.min(this.$D, I.daysInMonth())).$d;
          } else A && this.$d[A](D);
          return this.init(), this;
        }, n.set = function(t, i) {
          return this.clone().$set(t, i);
        }, n.get = function(t) {
          return this[_.p(t)]();
        }, n.add = function(t, i) {
          var s, d = this;
          t = Number(t);
          var h = _.p(i), A = function(V) {
            var Y = S(d);
            return _.w(Y.date(Y.date() + Math.round(V * t)), d);
          };
          if (h === P) return this.set(P, this.$M + t);
          if (h === w) return this.set(w, this.$y + t);
          if (h === m) return A(1);
          if (h === L) return A(7);
          var D = (s = {}, s[f] = u, s[O] = l, s[g] = a, s)[h] || 1, I = this.$d.getTime() + t * D;
          return _.w(I, this);
        }, n.subtract = function(t, i) {
          return this.add(-1 * t, i);
        }, n.format = function(t) {
          var i = this, s = this.$locale();
          if (!this.isValid()) return s.invalidDate || H;
          var d = t || "YYYY-MM-DDTHH:mm:ssZ", h = _.z(this), A = this.$H, D = this.$m, I = this.$M, V = s.weekdays, Y = s.months, z = s.meridiem, v = function(F, R, X, x) {
            return F && (F[R] || F(i, d)) || X[R].slice(0, x);
          }, G = function(F) {
            return _.s(A % 12 || 12, F, "0");
          }, J = z || function(F, R, X) {
            var x = F < 12 ? "AM" : "PM";
            return X ? x.toLowerCase() : x;
          };
          return d.replace(b, (function(F, R) {
            return R || (function(X) {
              switch (X) {
                case "YY":
                  return String(i.$y).slice(-2);
                case "YYYY":
                  return _.s(i.$y, 4, "0");
                case "M":
                  return I + 1;
                case "MM":
                  return _.s(I + 1, 2, "0");
                case "MMM":
                  return v(s.monthsShort, I, Y, 3);
                case "MMMM":
                  return v(Y, I);
                case "D":
                  return i.$D;
                case "DD":
                  return _.s(i.$D, 2, "0");
                case "d":
                  return String(i.$W);
                case "dd":
                  return v(s.weekdaysMin, i.$W, V, 2);
                case "ddd":
                  return v(s.weekdaysShort, i.$W, V, 3);
                case "dddd":
                  return V[i.$W];
                case "H":
                  return String(A);
                case "HH":
                  return _.s(A, 2, "0");
                case "h":
                  return G(1);
                case "hh":
                  return G(2);
                case "a":
                  return J(A, D, !0);
                case "A":
                  return J(A, D, !1);
                case "m":
                  return String(D);
                case "mm":
                  return _.s(D, 2, "0");
                case "s":
                  return String(i.$s);
                case "ss":
                  return _.s(i.$s, 2, "0");
                case "SSS":
                  return _.s(i.$ms, 3, "0");
                case "Z":
                  return h;
              }
              return null;
            })(F) || h.replace(":", "");
          }));
        }, n.utcOffset = function() {
          return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
        }, n.diff = function(t, i, s) {
          var d, h = this, A = _.p(i), D = S(t), I = (D.utcOffset() - this.utcOffset()) * u, V = this - D, Y = function() {
            return _.m(h, D);
          };
          switch (A) {
            case w:
              d = Y() / 12;
              break;
            case P:
              d = Y();
              break;
            case U:
              d = Y() / 3;
              break;
            case L:
              d = (V - I) / 6048e5;
              break;
            case m:
              d = (V - I) / 864e5;
              break;
            case O:
              d = V / l;
              break;
            case f:
              d = V / u;
              break;
            case g:
              d = V / a;
              break;
            default:
              d = V;
          }
          return s ? d : _.a(d);
        }, n.daysInMonth = function() {
          return this.endOf(P).$D;
        }, n.$locale = function() {
          return M[this.$L];
        }, n.locale = function(t, i) {
          if (!t) return this.$L;
          var s = this.clone(), d = k(t, i, !0);
          return d && (s.$L = d), s;
        }, n.clone = function() {
          return _.w(this.$d, this);
        }, n.toDate = function() {
          return new Date(this.valueOf());
        }, n.toJSON = function() {
          return this.isValid() ? this.toISOString() : null;
        }, n.toISOString = function() {
          return this.$d.toISOString();
        }, n.toString = function() {
          return this.$d.toUTCString();
        }, c;
      })(), K = N.prototype;
      return S.prototype = K, [["$ms", p], ["$s", g], ["$m", f], ["$H", O], ["$W", m], ["$M", P], ["$y", w], ["$D", E]].forEach((function(c) {
        K[c[1]] = function(n) {
          return this.$g(n, c[0], c[1]);
        };
      })), S.extend = function(c, n) {
        return c.$i || (c(n, N, S), c.$i = !0), S;
      }, S.locale = k, S.isDayjs = W, S.unix = function(c) {
        return S(1e3 * c);
      }, S.en = M[T], S.Ls = M, S.p = {}, S;
    }));
  })(re)), re.exports;
}
var $e = _e();
const Z = /* @__PURE__ */ ge($e), Se = (e) => e.replace(/\[(\d+)\](?=\.)/g, ".$1").replace(/\[(\d+)\]$/g, ".$1"), ce = (e) => Object.entries(e || {}).reduce((a, [u, l]) => (l != null && (a[u] = l), a), {}), Oe = (e) => new URLSearchParams(ce(e)).toString(), Ae = (e) => Object.fromEntries(e == null ? void 0 : e.entries()), Te = (e) => Array.isArray(e) ? e.length > 0 && e[0] !== null && typeof e[0] == "object" && !Array.isArray(e[0]) ? JSON.stringify(e) : e.map((r) => String(r ?? "")).join(",") : e, Ce = (e) => {
  var r;
  return (r = e == null ? void 0 : e.match(/{{(.*?)}}/g)) == null ? void 0 : r.map((a) => a.slice(2, -2));
}, Me = ({
  setterMethodCode: e,
  params: r = []
}) => {
  if (!e) return e;
  let a = e;
  return r.forEach(({ key: u, value: l }) => {
    l && (a = a.replaceAll(`#${u}#`, l));
  }), a;
}, De = ({
  value: e,
  iteratorIndicesMap: r = {},
  formIndexes: a = {}
}) => {
  const u = 'getValues("__loggedInUserId__")', l = 'getValues("__formData__")', p = 'getValues("__infoData__")', g = 'getValues("__utilityData__")', f = 'getValues("__routeData__")', O = 'getValues("__accessRights__")';
  let m = fe({
    value: e,
    iteratorIndicesMap: r,
    formIndexes: a,
    withDotNotation: !1
  });
  return m = m.replaceAll("__loggedInUserId__", u).replaceAll("__formData__", l).replaceAll("__infoData__", p).replaceAll("__utilityData__", g).replaceAll("__routeData__", f).replaceAll("__accessRights__", O), m;
}, fe = ({
  value: e = null,
  iteratorIndicesMap: r = {},
  formIndexes: a = {},
  withDotNotation: u = !0
}) => {
  if (!e) return e;
  let l = e;
  return Object.keys(a).forEach((p) => {
    if (l.includes(`[${p}]`)) {
      let g;
      const f = a[p];
      r.hasOwnProperty(f) ? g = r[f] : g = -1, l = l.replaceAll(p, g);
    }
  }), u && (l = Se(l)), l;
}, Le = (e, r, a, u, { dayjs: l }) => {
  const p = De({
    value: e,
    iteratorIndicesMap: r,
    formIndexes: a
  });
  try {
    return new Function("getValues", "dayjs", `return ${p};`)(
      u,
      l
    );
  } catch (g) {
    return pe({ message: `Error evaluating ${e}`, type: "error" }), console.error(`Error evaluating ${e} :`, g), null;
  }
}, Ee = (e) => {
  let r = JSON.parse(
    sessionStorage.getItem("medplatFormRoutes") || "{}"
  );
  r[e] = !0, sessionStorage.setItem(
    "medplatFormRoutes",
    JSON.stringify(r)
  );
}, Ie = (e) => JSON.parse(
  sessionStorage.getItem("medplatFormRoutes") || "{}"
)[e] || !1, le = (e, r = "") => {
  var u, l;
  let a = [];
  for (const p in e) {
    const g = r ? `${r}.${p}` : p;
    (u = e[p]) != null && u.types || (l = e[p]) != null && l.message ? a.push(g) : typeof e[p] == "object" && (a = a.concat(le(e[p], g)));
  }
  return a;
}, Pe = (e, r) => Array.isArray(e) && e.length > 0 ? e.some(
  (u) => r == null ? void 0 : r.includes(u)
) : !1, Ne = (e, r, a, u = !0) => {
  if ((r == null || r === "") && u)
    return "N.A";
  switch (e) {
    case "text":
    case "location":
    case "listValueFieldValue":
    case "html":
      return r;
    case "mediaPreview":
      return r;
    case "boolean":
      return r ? "Yes" : "No";
    case "date":
      return Z(r).format("DD/MM/YYYY");
    case "dateAndTime":
      return Z(r).format("DD/MM/YYYY HH:mm:ss");
    case "gender":
      switch (r) {
        case "M":
          return "Male";
        case "F":
        case "FM":
          return "Female";
        case "T":
          return "Transgender";
      }
      break;
    case "familyPlanning":
      switch (r) {
        case "FMLSTR":
          return "FEMALE STERILIZATION";
        case "MLSTR":
          return "MALE STERILIZATION";
        case "IUCD5":
          return "IUCD- 5 YEARS";
        case "IUCD10":
          return "IUCD- 10 YEARS";
        case "CONDOM":
          return "CONDOM";
        case "ORALPILLS":
          return "ORAL PILLS";
        case "CHHAYA":
          return "CHHAYA";
        case "ANTARA":
          return "ANTARA";
        case "CONTRA":
          return "EMERGENCY CONTRACEPTIVE PILLS";
        case "PPIUCD":
          return "PPIUCD";
        case "PAIUCD":
          return "PAIUCD";
        case "PPTL":
          return "Post Parterm TL";
        case "PATL":
          return "Post Abortion TL";
        case "LAPAROSCOPIC_TL":
          return "Laparoscopic TL";
        case "ABDOMINAL_TL":
          return "Abdominal TL";
        case "VASECTOMY_FOR_HUSBAND":
          return "Vasectomy (for Husband)";
      }
      break;
    case "sdScore":
      switch (r) {
        case "SD4":
          return "Less than -4";
        case "SD3":
          return "-4 to -3";
        case "SD2":
          return "-3 to -2";
        case "SD1":
          return "-2 to -1";
        case "MEDIAN":
          return "MEDIAN";
        default:
          return "NONE";
      }
    case "array": {
      if (!Array.isArray(r))
        return r;
      switch (a) {
        case "BULLETED":
          return r.map((l) => `• ${l}`);
        case "NUMBERED":
          return r.map((l, p) => `${p + 1}. ${l}`);
        case "COMMA":
          return r.join(", ");
        default:
          return r.join(" ");
      }
    }
    default:
      return r;
  }
}, be = async (e) => {
  if (!e || e.length === 0)
    return [];
  const r = (await oe({
    code: "medplat_form_listvalue_field_value_details",
    parameters: {
      ids: e
    }
  })).data;
  return r == null ? void 0 : r.result;
}, Ve = async (e, r) => {
  if (!e || e.length === 0)
    return [];
  const a = {
    locationIds: e.join(",")
  };
  r && (a.lang = r);
  const u = (await oe({
    code: "medplat_form_get_location_hierarchies",
    parameters: a
  })).data;
  return u == null ? void 0 : u.result;
}, Ue = ({
  preValidationQueries: e,
  formContext: r,
  formIndexes: a,
  iteratorIndicesMap: u,
  rowData: l
}) => Array.isArray(e) ? e.map((p) => {
  const g = {};
  return (p.params || []).forEach((f) => {
    if (f.type === "TABLE" && l)
      g[f.key] = l[f.valueKey];
    else {
      const O = q.replaceFormIndexes({
        value: f.valueKey,
        iteratorIndicesMap: u,
        formIndexes: a
      });
      g[f.key] = r.getValues(O);
    }
  }), {
    queryCode: p.queryCode,
    parameters: g
  };
}) : [], q = {
  convertToSearchParams: Oe,
  extractSearchParams: Ae,
  serialiseMultiRowParam: Te,
  extractDynamicContent: Ce,
  replaceFormIndexes: fe,
  evaluate: Le,
  transformWithDisplayType: Ne,
  addRoutePathInSessionStorage: Ee,
  isRoutePresentInSessionStorage: Ie,
  flattenErrors: le,
  checkFormErrors: Pe,
  getFilteredObject: ce,
  fetchListValueDetailByIds: be,
  fetchLocationHierarchyByIds: Ve,
  buildPreValidationQueries: Ue,
  replacePlaceholdersWithConfigParams: Me
}, Q = (e) => (e || "").toString().toLowerCase(), we = (e) => e === "true" || e === "'true'" ? !0 : e === "false" || e === "'false'" ? !1 : e === "null" || e === "'null'" ? null : typeof e == "string" && e.startsWith("'") && e.endsWith("'") ? e.substring(1, e.length - 1) : e, B = {
  EQ: (e, r) => e == r,
  NQ: (e, r) => e != r,
  EQWithType: (e, r) => e === r,
  NQWithType: (e, r) => e !== r,
  GT: (e, r) => e > r,
  LT: (e, r) => e < r,
  GTE: (e, r) => e >= r,
  LTE: (e, r) => e <= r,
  BT: (e, r, a) => e > r && e < a,
  INCLUDES: (e, r) => Array.isArray(e) && e.some((a) => String(a).toLowerCase() === String(r).toLowerCase()),
  NOT_INCLUDES: (e, r) => Array.isArray(e) && !e.some((a) => String(a).toLowerCase() === String(r).toLowerCase()),
  FILLED: (e) => e != null,
  NOT_FILLED: (e) => e == null,
  CONTAINS: (e, r) => Q(e).includes(Q(r)),
  STARTS_WITH: (e, r) => Q(e).startsWith(Q(r)),
  ENDS_WITH: (e, r) => Q(e).endsWith(Q(r)),
  HAS_KEY: (e, r) => e && typeof e == "object" && !Array.isArray(e) && r in e
}, de = (e) => typeof e != "string" ? null : e.startsWith("dateAndTime(") ? "dateAndTime" : e.startsWith("date(") ? "date" : null, Be = ({
  condition: e,
  evaluator: r,
  contextCellValue: a,
  contextRowData: u,
  type: l,
  isStyleMode: p
}) => {
  const { operator: g, config: f, operand: O } = e, m = de(l);
  let L = a;
  if (p && m && (L = r(a, m)), O && (L = r(O, p ? m : null, u, !1)), g === "BT") {
    const E = f.operand1 === "CUSTOM" ? f.operand1CustomValue : f.operand1, H = f.operand2 === "CUSTOM" ? f.operand2CustomValue : f.operand2;
    return B.BT(
      L,
      r(E, m, u, f.operand1 === "CUSTOM"),
      r(H, m, u, f.operand2 === "CUSTOM")
    );
  }
  if (g === "FILLED" || g === "NOT_FILLED") {
    const E = p ? L : O ? r(O, null, u) : L;
    return B[g](E);
  }
  if (g === "HAS_KEY")
    return B.HAS_KEY(L, f.key);
  if (g === "HAS_KEY_VALUE") {
    if (!L || typeof L != "object" || Array.isArray(L) || !f.key) return !1;
    const E = L[f.key], H = f.operator, o = f.config || {};
    if (!H) return !1;
    if (H === "BT") {
      const C = o.operand1 === "CUSTOM", y = o.operand2 === "CUSTOM";
      return E > r(C ? o.operand1CustomValue : o.operand1, m, u, C) && E < r(y ? o.operand2CustomValue : o.operand2, m, u, y);
    }
    const b = o.operand === "CUSTOM";
    return B[H](E, r(b ? o.operandCustomValue : o.operand, m, u, b));
  }
  const P = f.operand === "CUSTOM", U = P ? f.operandCustomValue : f.operand, w = r(U, m, u, P);
  return B[g](L, w);
}, he = ({
  expression: e,
  contextCellValue: r,
  contextRowData: a,
  conditionKey: u,
  evaluateConditionFunc: l
}) => {
  const p = (e == null ? void 0 : e.conditions) || e;
  if (!(p != null && p.options)) return u === "visibility";
  const { rule: g, options: f } = p, O = (m) => m.conditions ? he({ expression: m, contextCellValue: r, contextRowData: a, conditionKey: u, evaluateConditionFunc: l }) : l(m, r, a);
  return g === "AND" ? f.every(O) : f.some(O);
}, ve = ({
  items: e = [],
  formContext: r,
  iteratorIndicesMap: a = {},
  formIndexes: u = {},
  dependencies: l = {},
  rowData: p = {},
  cellValue: g = null,
  type: f = null,
  conditionKey: O = "visibility",
  isStyleMode: m = !1
}) => {
  const L = ne(() => {
    const o = /* @__PURE__ */ new Set(), b = (y) => {
      const $ = /* @__PURE__ */ new Set(), T = (j) => {
        j !== "CUSTOM" && j !== "CUSTOM_VALUE" && j !== "CUSTOM_PATH" && typeof j == "string" && $.add(q.replaceFormIndexes({ value: j }));
      }, M = (j, W) => {
        j === "CUSTOM_PATH" && W && typeof W == "string" && $.add(q.replaceFormIndexes({ value: W }));
      };
      return y.operator === "BT" ? (T(y.config.operand1), M(y.config.operand1, y.config.operand1CustomPath), T(y.config.operand2), M(y.config.operand2, y.config.operand2CustomPath)) : (T(y.config.operand), M(y.config.operand, y.config.operandCustomPath)), T(y.operand), M(y.operand, y.operandCustomPath), [...$];
    }, C = (y) => {
      var $;
      ($ = y == null ? void 0 : y.options) == null || $.forEach((T) => {
        T.conditions ? C(T.conditions) : b(T).forEach((M) => o.add(M));
      });
    };
    return e == null || e.forEach((y) => {
      var T;
      const $ = ((T = y[O]) == null ? void 0 : T.conditions) || y[O];
      $ && C($);
    }), Array.from(o);
  }, [JSON.stringify(e), O, a, u]), P = me({
    control: r == null ? void 0 : r.control,
    name: L.length > 0 ? L : void 0,
    exact: !0
  }), U = te(
    (o, b = null, C = {}, y) => {
      if (typeof o == "string" && o.startsWith("__"))
        try {
          return q.evaluate(o, m ? {} : a, u, r == null ? void 0 : r.getValues, { dayjs: Z, ...l });
        } catch (T) {
          return console.error("Evaluation error:", T), null;
        }
      if (typeof o == "string" && !o.startsWith("__") && !y) {
        if (o in C) return C[o];
        if (C != null && C._raw && o in C._raw) return C._raw[o];
      }
      const $ = b || f;
      return $ === "listValueFieldValue" || $ === "location" ? typeof o == "string" ? Number(o) : o : $ === "boolean" ? o === "true" || o === !0 : $ === "date" && Z(o).isValid() ? Z(o).startOf("day").valueOf() : $ === "dateAndTime" && Z(o).isValid() ? Z(o).startOf("minute").valueOf() : $ ? o : we(o);
    },
    [r == null ? void 0 : r.getValues, a, u, f, m, l]
  ), w = te(
    (o, b = g, C = p) => {
      const { operator: y, config: $, operand: T } = o, M = de(f), j = (N) => N === "CUSTOM" || N === "CUSTOM_VALUE", W = (N) => N === "CUSTOM_PATH", k = (N, K, c, n) => {
        if (j(N))
          return U(K, n, C, !0);
        if (W(N)) {
          const t = q.replaceFormIndexes({
            value: c,
            iteratorIndicesMap: m ? {} : a,
            formIndexes: {}
          });
          return U(t, n, C, !1);
        }
        return U(N, n, C, !1);
      };
      let S = b;
      if (m && M && (S = U(b, M)), T)
        if (j(T))
          S = U(o.operandCustomValue, m ? M : null, C, !0);
        else if (W(T)) {
          const N = q.replaceFormIndexes({
            value: o.operandCustomPath,
            iteratorIndicesMap: m ? {} : a,
            formIndexes: {}
          });
          S = U(N, m ? M : null, C, !1);
        } else
          S = U(T, m ? M : null, C, !1);
      if (y === "BT")
        return B.BT(
          S,
          k($.operand1, $.operand1CustomValue, $.operand1CustomPath, M),
          k($.operand2, $.operand2CustomValue, $.operand2CustomPath, M)
        );
      if (y === "FILLED" || y === "NOT_FILLED") {
        const N = S;
        return B[y](N);
      }
      const _ = k(
        $.operand,
        $.operandCustomValue,
        $.operandCustomPath,
        M || null
      );
      return B[y](S, _);
    },
    [U, g, p, f, m, a]
  ), E = te(
    (o, b = g, C = p) => he({ expression: o, contextCellValue: b, contextRowData: C, conditionKey: O, evaluateConditionFunc: w }),
    [w, g, p, O]
  ), H = ne(() => Array.isArray(e) ? e.filter((o) => {
    const b = o[O];
    return b ? E(b) : (o == null ? void 0 : o.styles) || O === "visibility";
  }) : [], [e, E, O, P]);
  return { evaluate: U, evaluateCondition: w, evaluateExpression: E, filteredItems: H, watchedValues: P };
};
export {
  Z as C,
  q as F,
  Re as a,
  he as b,
  ke as c,
  Be as e,
  ge as g,
  we as n,
  ve as u
};
//# sourceMappingURL=index-Dta_LKti.js.map
