@vpwhite/vue-rule-builder
Version:
A powerful, flexible Vue 3 component library for building complex business rules with an intuitive visual interface. Transform your business logic into interactive, maintainable rule definitions.
1,335 lines (1,334 loc) • 305 kB
JavaScript
import * as lr from "vue";
import { h as nt, defineComponent as _e, ref as O, onMounted as Ue, onUnmounted as ut, createBlock as fe, openBlock as i, Teleport as gt, createElementBlock as m, createCommentVNode as F, normalizeClass as se, createElementVNode as r, unref as N, toDisplayString as H, createVNode as h, createApp as Ur, renderSlot as kt, computed as G, mergeProps as zr, watchEffect as Vt, cloneVNode as Br, Fragment as Te, provide as $t, inject as Ve, watch as $e, nextTick as Ye, toRaw as Ze, withCtx as ee, Transition as Mt, renderList as Le, resolveComponent as Kt, normalizeStyle as er, withModifiers as rt, resolveDynamicComponent as Nt, TransitionGroup as Pt, withDirectives as Me, vModelText as qe, createTextVNode as pe, vModelRadio as or, withKeys as nr, mergeModels as ir, useModel as qr } from "vue";
import { defineStore as Hr } from "pinia";
const mt = "vue-condition-builder-autosave", Gt = 50;
class at {
/**
* Save current condition to autosave history
*/
static save(n, e, u) {
const c = /* @__PURE__ */ new Date(), a = {
id: `autosave-${Date.now()}`,
instanceId: e,
timestamp: c.getTime(),
dateString: c.toLocaleDateString(),
timeString: c.toLocaleTimeString(),
rootGroup: JSON.parse(JSON.stringify(n)),
// Deep clone
preview: u
}, l = this.getHistory();
return l.unshift(a), l.length > Gt && l.splice(Gt), this.saveHistory(l), a;
}
/**
* Get full autosave history (all instances)
*/
static getHistory() {
try {
const n = localStorage.getItem(mt);
if (!n) return [];
const e = JSON.parse(n);
return Array.isArray(e) ? e : [];
} catch (n) {
return console.warn("Failed to load autosave history:", n), [];
}
}
/**
* Get autosave history filtered by instance ID
*/
static getHistoryForInstance(n) {
return this.getHistory().filter((u) => u.instanceId === n);
}
/**
* Get most recent autosave entry for a specific instance
*/
static getLatest(n) {
const e = n ? this.getHistoryForInstance(n) : this.getHistory();
return e.length > 0 ? e[0] : null;
}
/**
* Load specific autosave entry by ID
*/
static load(n) {
return this.getHistory().find((u) => u.id === n) || null;
}
/**
* Delete specific autosave entry
*/
static delete(n) {
const e = this.getHistory(), u = e.findIndex((c) => c.id === n);
return u === -1 ? !1 : (e.splice(u, 1), this.saveHistory(e), !0);
}
/**
* Clear all autosave history
*/
static clear() {
localStorage.removeItem(mt);
}
/**
* Get history grouped by date for better UI organization
*/
static getHistoryGroupedByDate(n) {
const e = n ? this.getHistoryForInstance(n) : this.getHistory(), u = /* @__PURE__ */ new Map();
return e.forEach((c) => {
const a = c.dateString;
u.has(a) || u.set(a, []), u.get(a).push(c);
}), Array.from(u.entries()).map(([c, a]) => ({ date: c, entries: a })).sort((c, a) => {
var x, b;
const l = ((x = c.entries[0]) == null ? void 0 : x.timestamp) || 0;
return (((b = a.entries[0]) == null ? void 0 : b.timestamp) || 0) - l;
});
}
/**
* Check if there are any autosaves available
*/
static hasAutosaves(n) {
return (n ? this.getHistoryForInstance(n) : this.getHistory()).length > 0;
}
/**
* Clear autosave history for a specific instance
*/
static clearInstance(n) {
const u = this.getHistory().filter((c) => c.instanceId !== n);
this.saveHistory(u);
}
/**
* Get storage size in KB (for debugging/monitoring)
*/
static getStorageSize() {
try {
const n = localStorage.getItem(mt);
return n ? new Blob([n]).size / 1024 : 0;
} catch {
return 0;
}
}
/**
* Private method to save history to localStorage
*/
static saveHistory(n) {
try {
localStorage.setItem(mt, JSON.stringify(n));
} catch (e) {
if (console.error("Failed to save autosave history:", e), e instanceof Error && e.name === "QuotaExceededError") {
const u = n.slice(0, Math.floor(Gt / 2));
try {
localStorage.setItem(mt, JSON.stringify(u));
} catch {
console.error("Still failed to save even after reducing history");
}
}
}
}
}
var ue = /* @__PURE__ */ ((t) => (t[t.Group = 0] = "Group", t[t.Rule = 1] = "Rule", t[t.Expression = 2] = "Expression", t[t.RuleSet = 3] = "RuleSet", t))(ue || {}), st = /* @__PURE__ */ ((t) => (t[t.And = 0] = "And", t[t.Or = 1] = "Or", t))(st || {}), j = /* @__PURE__ */ ((t) => (t[t.LITERAL = 0] = "LITERAL", t[t.MODEL = 1] = "MODEL", t[t.CONTEXT = 2] = "CONTEXT", t[t.FUNCTION = 3] = "FUNCTION", t[t.PARAM = 4] = "PARAM", t[t.EXPRESSION = 5] = "EXPRESSION", t[t.PROPERTY = 6] = "PROPERTY", t))(j || {}), Se = /* @__PURE__ */ ((t) => (t[t.Unary = 1] = "Unary", t[t.Binary = 2] = "Binary", t[t.Ternary = 3] = "Ternary", t[t.Variadic = 99] = "Variadic", t))(Se || {});
const Gr = {
equals: "equals",
notEquals: "does not equal",
contains: "contains",
notContains: "does not contain",
startsWith: "starts with",
endsWith: "ends with",
greaterThan: "is greater than",
lessThan: "is less than",
greaterThanOrEqual: "is greater than or equal to",
lessThanOrEqual: "is less than or equal to",
between: "is between"
};
function Jr(t) {
if (t == null) return "null";
if (typeof t == "string") return t;
try {
return JSON.stringify(t);
} catch {
return String(t);
}
}
function Wr(t) {
return t === st.Or ? "OR" : "AND";
}
function Yr(t) {
const n = t.function ? t.function.name || "function" : t.field || "field", e = t.operator ? Gr[t.operator] || t.operator : "is", u = (t.values || []).map((a) => Jr(a.value));
if (t.operator === "between" && u.length >= 2)
return `${n} ${e} ${u[0]} and ${u[1]}`;
const c = u[0] !== void 0 ? ` ${u[0]}` : "";
return `${n} ${e}${c}`;
}
function Xr(t) {
try {
const n = (u) => {
if (u.kind === ue.Group) {
const c = (u.children || []).map((l) => n(l)).filter(Boolean), a = c.join(` ${Wr(u.combinator)} `);
return u.not ? `NOT (${a})` : c.length > 1 ? `(${a})` : a;
} else {
if (u.kind === ue.Rule)
return Yr(u);
if (u.kind === ue.Expression)
return u.expression ? `expression(${u.expression.slice(0, 30)}...)` : "expression";
if (u.kind === ue.RuleSet) {
const c = u;
return c.ruleSetName ? `ruleset(${c.ruleSetName})` : "ruleset";
}
}
return "";
};
return n(t).trim() || "Empty condition";
} catch {
return "Condition";
}
}
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Qr = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
var Rt = {
xmlns: "http://www.w3.org/2000/svg",
width: 24,
height: 24,
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": 2,
"stroke-linecap": "round",
"stroke-linejoin": "round"
};
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Zr = ({ size: t, strokeWidth: n = 2, absoluteStrokeWidth: e, color: u, iconNode: c, name: a, class: l, ...g }, { slots: x }) => nt(
"svg",
{
...Rt,
width: t || Rt.width,
height: t || Rt.height,
stroke: u || Rt.stroke,
"stroke-width": e ? Number(n) * 24 / Number(t) : n,
class: ["lucide", `lucide-${Qr(a ?? "icon")}`],
...g
},
[...c.map((b) => nt(...b)), ...x.default ? [x.default()] : []]
);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const de = (t, n) => (e, { slots: u }) => nt(
Zr,
{
...e,
iconNode: n,
name: t
},
u
);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Kr = de("BellIcon", [
["path", { d: "M10.268 21a2 2 0 0 0 3.464 0", key: "vwvbt9" }],
[
"path",
{
d: "M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",
key: "11g9vi"
}
]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const es = de("BugIcon", [
["path", { d: "m8 2 1.88 1.88", key: "fmnt4t" }],
["path", { d: "M14.12 3.88 16 2", key: "qol33r" }],
["path", { d: "M9 7.13v-1a3.003 3.003 0 1 1 6 0v1", key: "d7y7pr" }],
[
"path",
{
d: "M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",
key: "xs1cw7"
}
],
["path", { d: "M12 20v-9", key: "1qisl0" }],
["path", { d: "M6.53 9C4.6 8.8 3 7.1 3 5", key: "32zzws" }],
["path", { d: "M6 13H2", key: "82j7cp" }],
["path", { d: "M3 21c0-2.1 1.7-3.9 3.8-4", key: "4p0ekp" }],
["path", { d: "M20.97 5c0 2.1-1.6 3.8-3.5 4", key: "18gb23" }],
["path", { d: "M22 13h-4", key: "1jl80f" }],
["path", { d: "M17.2 17c2.1.1 3.8 1.9 3.8 4", key: "k3fwyw" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ts = de("BuildingIcon", [
["rect", { width: "16", height: "20", x: "4", y: "2", rx: "2", ry: "2", key: "76otgf" }],
["path", { d: "M9 22v-4h6v4", key: "r93iot" }],
["path", { d: "M8 6h.01", key: "1dz90k" }],
["path", { d: "M16 6h.01", key: "1x0f13" }],
["path", { d: "M12 6h.01", key: "1vi96p" }],
["path", { d: "M12 10h.01", key: "1nrarc" }],
["path", { d: "M12 14h.01", key: "1etili" }],
["path", { d: "M16 10h.01", key: "1m94wz" }],
["path", { d: "M16 14h.01", key: "1gbofw" }],
["path", { d: "M8 10h.01", key: "19clt8" }],
["path", { d: "M8 14h.01", key: "6423bh" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const At = de("CalendarIcon", [
["path", { d: "M8 2v4", key: "1cmpym" }],
["path", { d: "M16 2v4", key: "4m81vk" }],
["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
["path", { d: "M3 10h18", key: "8toen8" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ot = de("CheckIcon", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const We = de("ChevronDownIcon", [
["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const kr = de("ChevronRightIcon", [
["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const rs = de("CircleAlertIcon", [
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const $r = de("CircleCheckBigIcon", [
["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ss = de("CircleXIcon", [
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
["path", { d: "m15 9-6 6", key: "1uzhvr" }],
["path", { d: "m9 9 6 6", key: "z0biqf" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const tr = de("ClockIcon", [
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
["polyline", { points: "12 6 12 12 16 14", key: "68esgv" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Ge = de("CodeIcon", [
["polyline", { points: "16 18 22 12 16 6", key: "z7tu5w" }],
["polyline", { points: "8 6 2 12 8 18", key: "1eg1df" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Xt = de("DatabaseIcon", [
["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
["path", { d: "M3 5V19A9 3 0 0 0 21 19V5", key: "1wlel7" }],
["path", { d: "M3 12A9 3 0 0 0 21 12", key: "mv7ke4" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const as = de("DollarSignIcon", [
["line", { x1: "12", x2: "12", y1: "2", y2: "22", key: "7eqyqh" }],
["path", { d: "M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6", key: "1b0p4s" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ur = de("FileIcon", [
["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ls = de("GlobeIcon", [
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
["path", { d: "M2 12h20", key: "9i4pu4" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const bt = de("GripVerticalIcon", [
["circle", { cx: "9", cy: "12", r: "1", key: "1vctgf" }],
["circle", { cx: "9", cy: "5", r: "1", key: "hp0tcf" }],
["circle", { cx: "9", cy: "19", r: "1", key: "fkjjf6" }],
["circle", { cx: "15", cy: "12", r: "1", key: "1tmaij" }],
["circle", { cx: "15", cy: "5", r: "1", key: "19l28e" }],
["circle", { cx: "15", cy: "19", r: "1", key: "f4zoj3" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Dt = de("HashIcon", [
["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const dr = de("HistoryIcon", [
["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
["path", { d: "M3 3v5h5", key: "1xhq8a" }],
["path", { d: "M12 7v5l4 2", key: "1fdv2h" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const os = de("ImageIcon", [
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ns = de("InfoIcon", [
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
["path", { d: "M12 16v-4", key: "1dtifu" }],
["path", { d: "M12 8h.01", key: "e9boi3" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Jt = de("LayersIcon", [
[
"path",
{
d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
key: "zw3jo"
}
],
[
"path",
{
d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
key: "1wduqc"
}
],
[
"path",
{
d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
key: "kqbvx6"
}
]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Qt = de("LinkIcon", [
["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const is = de("ListIcon", [
["path", { d: "M3 12h.01", key: "nlz23k" }],
["path", { d: "M3 18h.01", key: "1tta3j" }],
["path", { d: "M3 6h.01", key: "1rqtza" }],
["path", { d: "M8 12h13", key: "1za7za" }],
["path", { d: "M8 18h13", key: "1lx6n3" }],
["path", { d: "M8 6h13", key: "ik3vkj" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const us = de("MailIcon", [
["rect", { width: "20", height: "16", x: "2", y: "4", rx: "2", key: "18n3k1" }],
["path", { d: "m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7", key: "1ocrg3" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ds = de("MapPinIcon", [
[
"path",
{
d: "M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",
key: "1r0f0z"
}
],
["circle", { cx: "12", cy: "10", r: "3", key: "ilqhr7" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const cr = de("PackageIcon", [
[
"path",
{
d: "M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",
key: "1a0edw"
}
],
["path", { d: "M12 22V12", key: "d0xqtd" }],
["path", { d: "m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7", key: "yx3hmr" }],
["path", { d: "m7.5 4.27 9 5.15", key: "1c824w" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const cs = de("PaletteIcon", [
["circle", { cx: "13.5", cy: "6.5", r: ".5", fill: "currentColor", key: "1okk4w" }],
["circle", { cx: "17.5", cy: "10.5", r: ".5", fill: "currentColor", key: "f64h9f" }],
["circle", { cx: "8.5", cy: "7.5", r: ".5", fill: "currentColor", key: "fotxhn" }],
["circle", { cx: "6.5", cy: "12.5", r: ".5", fill: "currentColor", key: "qy21gx" }],
[
"path",
{
d: "M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",
key: "12rzf8"
}
]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const pr = de("PlayIcon", [
["polygon", { points: "6 3 20 12 6 21 6 3", key: "1oa8hb" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Ut = de("PlusIcon", [
["path", { d: "M5 12h14", key: "1ays0h" }],
["path", { d: "M12 5v14", key: "s699le" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const vr = de("RotateCcwIcon", [
["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const jt = de("SearchIcon", [
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ps = de("ServerIcon", [
["rect", { width: "20", height: "8", x: "2", y: "2", rx: "2", ry: "2", key: "ngkwjq" }],
["rect", { width: "20", height: "8", x: "2", y: "14", rx: "2", ry: "2", key: "iecqi9" }],
["line", { x1: "6", x2: "6.01", y1: "6", y2: "6", key: "16zg32" }],
["line", { x1: "6", x2: "6.01", y1: "18", y2: "18", key: "nzw8ys" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Ke = de("SettingsIcon", [
[
"path",
{
d: "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",
key: "1qme2f"
}
],
["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Nr = de("ShieldIcon", [
[
"path",
{
d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
key: "oel41y"
}
]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const vs = de("ShoppingCartIcon", [
["circle", { cx: "8", cy: "21", r: "1", key: "jimo8o" }],
["circle", { cx: "19", cy: "21", r: "1", key: "13723u" }],
[
"path",
{
d: "M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",
key: "9zh506"
}
]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const fr = de("SquarePenIcon", [
["path", { d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7", key: "1m0v6g" }],
[
"path",
{
d: "M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",
key: "ohrbg2"
}
]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const fs = de("TagIcon", [
[
"path",
{
d: "M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",
key: "vktsd0"
}
],
["circle", { cx: "7.5", cy: "7.5", r: ".5", fill: "currentColor", key: "kqv944" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ms = de("ToggleLeftIcon", [
["rect", { width: "20", height: "12", x: "2", y: "6", rx: "6", ry: "6", key: "f2vt7d" }],
["circle", { cx: "8", cy: "12", r: "2", key: "1nvbw3" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const it = de("Trash2Icon", [
["path", { d: "M3 6h18", key: "d0wm0j" }],
["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }],
["line", { x1: "10", x2: "10", y1: "11", y2: "17", key: "1uufr5" }],
["line", { x1: "14", x2: "14", y1: "11", y2: "17", key: "xtxkd" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Ft = de("TriangleAlertIcon", [
[
"path",
{
d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
key: "wmoenq"
}
],
["path", { d: "M12 9v4", key: "juzpu7" }],
["path", { d: "M12 17h.01", key: "p32p05" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Be = de("TypeIcon", [
["polyline", { points: "4 7 4 4 20 4 20 7", key: "1nosan" }],
["line", { x1: "9", x2: "15", y1: "20", y2: "20", key: "swin9y" }],
["line", { x1: "12", x2: "12", y1: "4", y2: "20", key: "1tx1rr" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const ys = de("UserIcon", [
["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", key: "975kel" }],
["circle", { cx: "12", cy: "7", r: "4", key: "17ys0d" }]
]);
/**
* @license lucide-vue-next v0.468.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const Xe = de("XIcon", [
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
]), gs = { class: "rb-toast-content" }, bs = { class: "rb-toast-body" }, hs = { class: "rb-toast-icon" }, xs = { class: "rb-toast-text" }, ws = {
key: 0,
class: "rb-toast-title"
}, _s = /* @__PURE__ */ _e({
__name: "Toast",
props: {
message: {},
title: {},
type: { default: "info" },
duration: { default: 3e3 },
persistent: { type: Boolean, default: !1 }
},
emits: ["close"],
setup(t, { expose: n, emit: e }) {
const u = t, c = e, a = O(!1);
let l = null;
const g = () => {
a.value = !0, !u.persistent && u.duration > 0 && (l = window.setTimeout(() => {
x();
}, u.duration));
}, x = () => {
a.value = !1, l && (clearTimeout(l), l = null), setTimeout(() => {
c("close");
}, 300);
};
return Ue(() => {
setTimeout(() => {
g();
}, 50);
}), ut(() => {
l && clearTimeout(l);
}), n({
show: g,
close: x
}), (b, $) => (i(), fe(gt, { to: "body" }, [
a.value ? (i(), m("div", {
key: 0,
class: se(["rb-toast", {
"rb-toast-visible": a.value,
"rb-toast-hidden": !a.value
}])
}, [
r("div", gs, [
r("div", bs, [
r("div", hs, [
b.type === "success" ? (i(), fe(N($r), {
key: 0,
class: "rb-toast-icon-svg rb-toast-icon-success"
})) : b.type === "error" ? (i(), fe(N(rs), {
key: 1,
class: "rb-toast-icon-svg rb-toast-icon-error"
})) : b.type === "info" ? (i(), fe(N(ns), {
key: 2,
class: "rb-toast-icon-svg rb-toast-icon-info"
})) : (i(), fe(N(Ft), {
key: 3,
class: "rb-toast-icon-svg rb-toast-icon-warning"
}))
]),
r("div", xs, [
b.title ? (i(), m("p", ws, H(b.title), 1)) : F("", !0),
r("p", {
class: se(["rb-toast-message", { "rb-toast-message-with-title": b.title }])
}, H(b.message), 3)
]),
r("button", {
type: "button",
onClick: x,
class: "rb-toast-close"
}, [
h(N(Xe), { class: "rb-toast-close-icon" })
])
])
])
], 2)) : F("", !0)
]));
}
}), Pe = (t, n) => {
const e = t.__vccOpts || t;
for (const [u, c] of n)
e[u] = c;
return e;
}, ks = /* @__PURE__ */ Pe(_s, [["__scopeId", "data-v-fad29cad"]]), It = O([]);
function lt() {
const t = (l) => {
const g = Date.now().toString(), x = document.createElement("div"), b = Ur(ks, {
...l,
onClose: () => {
n(g);
}
});
return b.mount(x), It.value.push({ id: g, app: b, container: x }), g;
}, n = (l) => {
const g = It.value.findIndex((x) => x.id === l);
g > -1 && (It.value[g].app.unmount(), It.value.splice(g, 1));
};
return {
showToast: t,
success: (l, g, x) => t({
message: l,
title: g,
type: "success",
...x
}),
error: (l, g, x) => t({
message: l,
title: g,
type: "error",
duration: 5e3,
// Longer for errors
...x
}),
info: (l, g, x) => t({
message: l,
title: g,
type: "info",
...x
}),
warning: (l, g, x) => t({
message: l,
title: g,
type: "warning",
...x
}),
removeToast: n
};
}
const De = Symbol("RULE_BUILDER_INSTANCE_KEY"), mr = [
{
id: "user",
name: "User",
type: "object",
path: "user",
isExpandable: !0,
icon: "User"
},
{
id: "order",
name: "Order",
type: "object",
path: "order",
isExpandable: !0,
icon: "ShoppingCart"
},
{
id: "datetime",
name: "Date & Time",
type: "object",
path: "datetime",
isExpandable: !0,
icon: "Calendar"
}
], Tr = Hr("ruleBuilder", () => {
const t = [
{ value: "equals", label: "Equals", supportedTypes: ["string", "number", "boolean", "date", "enum", "list", "dictionary", "object"], arity: Se.Binary },
{ value: "notEquals", label: "Not Equals", supportedTypes: ["string", "number", "boolean", "date", "enum", "list", "dictionary", "object"], arity: Se.Binary },
{ value: "contains", label: "Contains", supportedTypes: ["string"], arity: Se.Binary },
{ value: "notContains", label: "Does Not Contain", supportedTypes: ["string"], arity: Se.Binary },
{ value: "startsWith", label: "Starts With", supportedTypes: ["string"], arity: Se.Binary },
{ value: "endsWith", label: "Ends With", supportedTypes: ["string"], arity: Se.Binary },
{ value: "greaterThan", label: "Greater Than", supportedTypes: ["number", "date"], arity: Se.Binary },
{ value: "lessThan", label: "Less Than", supportedTypes: ["number", "date"], arity: Se.Binary },
{ value: "greaterThanOrEqual", label: "Greater Than or Equal", supportedTypes: ["number", "date"], arity: Se.Binary },
{ value: "lessThanOrEqual", label: "Less Than or Equal", supportedTypes: ["number", "date"], arity: Se.Binary },
{ value: "isEmpty", label: "Is Empty", supportedTypes: ["string", "object"], arity: Se.Unary },
{ value: "isNotEmpty", label: "Is Not Empty", supportedTypes: ["string", "object"], arity: Se.Unary },
{ value: "isNull", label: "Is Null", supportedTypes: ["object"], arity: Se.Unary },
{ value: "isNotNull", label: "Is Not Null", supportedTypes: ["object"], arity: Se.Unary },
{ value: "between", label: "Between", supportedTypes: ["number", "date"], arity: Se.Ternary }
], n = [
{ value: "AND", label: "AND" },
{ value: "OR", label: "OR" }
], e = O(t), u = O(n);
let c = {};
const a = {}, l = () => ({
user: {
email: "test@example.com",
age: 25,
role: "admin",
department: "IT",
isActive: !0,
profile: { firstName: "John", lastName: "Doe" }
},
order: {
id: "ORD-001",
total: 299.99,
status: "pending",
createdAt: "2024-01-15T10:30:00Z",
customer: { email: "customer@example.com", name: "Jane Smith" },
items: [{ name: "Product A", price: 149.99 }, { name: "Product B", price: 150 }]
},
datetime: { created: "2024-01-15T10:30:00Z", updated: "2024-01-15T11:45:00Z", timezone: "UTC", format: "ISO" }
}), g = (p) => (a[p] || (a[p] = {
dataProviders: { ...c },
rootRule: O({ id: "root", kind: ue.Group, not: !1, children: [] }),
entityName: void 0,
viewName: void 0,
parentEntityName: void 0,
availableTabs: void 0,
// Feature toggles that can be overridden per instance or via base-config
features: O({
enableRules: !0,
enableExpressions: !0,
enableRuleSets: !0,
enableNotOperator: !0,
enableDeveloperTools: !0
}),
featureFlags: O({
naturalLanguagePreview: !0,
testPanel: !0,
autoSave: !1,
validation: !0,
lambdaPreview: !0,
animations: !0
}),
testResult: O(null),
selectedField: O(null),
expandedNodes: O(/* @__PURE__ */ new Set()),
testData: O(l()),
isLoadingTree: O(!1),
isLoadingChildren: O(!1),
loadingChildren: O({}),
isLoadingFunctions: O(!1),
isTestingRule: O(!1),
functions: O([]),
functionsInitialized: O(!1),
isLoadingOperators: O(!1),
operatorsInitialized: O(!1),
treeNodes: O([]),
childNodes: O({}),
treeInitialized: O(!1),
lastAutosaveTime: O(0),
autosaveInProgress: O(!1),
highlightedNodeId: O(null),
availableRuleSets: O([])
}), a[p]), x = (p, o) => {
const s = g(p);
s.highlightedNodeId.value = o, window.setTimeout(() => {
s.highlightedNodeId.value === o && (s.highlightedNodeId.value = null);
}, 2e3);
}, b = (p, o) => {
g(p).testData.value = o;
}, $ = (p) => {
g(p).testResult.value = null;
}, w = (p, o) => {
const s = g(p);
s.treeNodes.value = o, s.treeInitialized.value = !0;
}, R = async (p) => {
const o = g(p);
if (o.treeInitialized.value && !(o.dataProviders.fetchTreeNodes || o.dataProviders.fetchTree))
return o.treeNodes.value;
o.isLoadingTree.value = !0;
try {
o.dataProviders.fetchTree ? o.treeNodes.value = await o.dataProviders.fetchTree({
entityName: o.entityName || "Entity",
viewName: o.viewName,
parentEntityName: o.parentEntityName,
path: void 0
}) : o.dataProviders.fetchTreeNodes ? o.treeNodes.value = await o.dataProviders.fetchTreeNodes() : o.treeNodes.value = mr, o.treeInitialized.value = !0;
} catch (s) {
console.error("Failed to load tree nodes:", s), o.treeNodes.value = mr, o.treeInitialized.value = !0;
} finally {
o.isLoadingTree.value = !1;
}
return o.treeNodes.value;
}, z = async (p, o) => {
if (!o) return [];
const s = g(p);
if (s.childNodes.value[o]) return s.childNodes.value[o];
s.isLoadingChildren.value = !0, s.loadingChildren.value = { ...s.loadingChildren.value, [o]: !0 };
try {
if (s.dataProviders.fetchTree)
s.childNodes.value[o] = await s.dataProviders.fetchTree({
entityName: s.entityName || "Entity",
viewName: s.viewName,
parentEntityName: s.parentEntityName,
path: o
});
else if (s.dataProviders.fetchChildNodes)
s.childNodes.value[o] = await s.dataProviders.fetchChildNodes(o);
else {
const d = (V, A) => {
for (const re of V) {
if (re.id === A && re.children) return re.children;
if (re.children) {
const ce = d(re.children, A);
if (ce.length > 0) return ce;
}
}
return [];
};
s.childNodes.value[o] = d(s.treeNodes.value, o);
}
} catch (d) {
console.error(`Failed to load child nodes for ${o}:`, d), s.childNodes.value[o] = [];
} finally {
s.isLoadingChildren.value = !1, s.loadingChildren.value = { ...s.loadingChildren.value, [o]: !1 };
}
return s.childNodes.value[o];
}, J = async (p) => {
const o = g(p);
if (o.functionsInitialized.value && !(o.dataProviders.fetchFunctions || o.dataProviders.fetchBaseConfig))
return o.functions.value;
o.isLoadingFunctions.value = !0;
try {
if (o.dataProviders.fetchBaseConfig) {
const s = await o.dataProviders.fetchBaseConfig({
entityName: o.entityName || "Entity",
viewName: o.viewName,
parentEntityName: o.parentEntityName
}), d = (s == null ? void 0 : s.functions) ?? (s == null ? void 0 : s.Functions);
Array.isArray(d) && (o.functions.value = d);
const V = (s == null ? void 0 : s.availableTabs) ?? (s == null ? void 0 : s.AvailableTabs);
V && (o.availableTabs = V);
const A = (s == null ? void 0 : s.availableProperties) ?? (s == null ? void 0 : s.AvailableProperties);
Array.isArray(A) && (o.treeNodes.value = A);
const re = (s == null ? void 0 : s.operators) ?? (s == null ? void 0 : s.Operators);
if (re) {
const ke = re.comparison ?? re.Comparison, Ee = re.group ?? re.Group;
ke && (e.value = ke), Ee && (u.value = Ee);
}
const ce = (s == null ? void 0 : s.ruleSets) ?? (s == null ? void 0 : s.RuleSets);
Array.isArray(ce) && (o.availableRuleSets.value = ce);
} else o.dataProviders.fetchFunctions ? o.functions.value = await o.dataProviders.fetchFunctions() : o.functions.value = [];
o.functionsInitialized.value = !0;
} catch (s) {
console.error("Failed to load functions:", s), o.functions.value = [], o.functionsInitialized.value = !0;
} finally {
o.isLoadingFunctions.value = !1;
}
return o.functions.value;
}, X = async (p) => {
const o = g(p);
if (o.operatorsInitialized.value && !(o.dataProviders.fetchOperators || o.dataProviders.fetchBaseConfig))
return { comparison: e.value, group: u.value };
o.isLoadingOperators.value = !0;
try {
if (o.dataProviders.fetchBaseConfig) {
const s = await o.dataProviders.fetchBaseConfig({
entityName: o.entityName || "Entity",
viewName: o.viewName,
parentEntityName: o.parentEntityName
}), d = (s == null ? void 0 : s.operators) ?? (s == null ? void 0 : s.Operators);
(d != null && d.comparison || d != null && d.Comparison) && (e.value = d.comparison ?? d.Comparison), (d != null && d.group || d != null && d.Group) && (u.value = d.group ?? d.Group);
const V = (s == null ? void 0 : s.functions) ?? (s == null ? void 0 : s.functions);
Array.isArray(V) && !o.functionsInitialized.value && (o.functions.value = V, o.functionsInitialized.value = !0);
const A = (s == null ? void 0 : s.availableTabs) ?? (s == null ? void 0 : s.AvailableTabs);
A && (o.availableTabs = A);
const re = (s == null ? void 0 : s.availableProperties) ?? (s == null ? void 0 : s.AvailableProperties);
Array.isArray(re) && (!o.treeNodes.value || o.treeNodes.value.length === 0) && (o.treeNodes.value = re);
const ce = (s == null ? void 0 : s.ruleSets) ?? (s == null ? void 0 : s.RuleSets);
Array.isArray(ce) && (o.availableRuleSets.value = ce);
} else if (o.dataProviders.fetchOperators) {
const s = await o.dataProviders.fetchOperators();
s != null && s.comparison && Array.isArray(s.comparison) && (e.value = s.comparison), s != null && s.group && Array.isArray(s.group) && (u.value = s.group);
}
o.operatorsInitialized.value = !0;
} catch (s) {
console.error("Failed to load operators:", s), o.operatorsInitialized.value = !0;
} finally {
o.isLoadingOperators.value = !1;
}
return { comparison: e.value, group: u.value };
}, M = (p) => {
const o = [], s = (d) => {
for (const V of d)
o.push(V), V.children && V.children.length > 0 && s(V.children);
};
return s(p), o;
}, C = {}, y = async (p, o) => {
const s = g(o || k());
if (M(s.treeNodes.value).find((ce) => ce.path === p)) return !1;
const V = p.lastIndexOf("."), A = V > 0 ? p.substring(0, V) : "";
if (!s.dataProviders.fetchTree) return !1;
const re = A || "__root__";
if (C[re] !== void 0) {
try {
await C[re];
} catch {
}
return M(s.treeNodes.value).some((ke) => ke.path === p);
}
try {
const ce = s.dataProviders.fetchTree({
entityName: s.entityName || "Entity",
viewName: s.viewName,
parentEntityName: s.parentEntityName,
path: A || void 0
});
C[re] = ce;
const ke = await ce;
if (Array.isArray(ke) && ke.length > 0) {
if (A) {
const Oe = M(s.treeNodes.value).find((Ne) => Ne.path === A);
if (Oe) {
const Ne = Oe.children || [], ft = new Map(Ne.map((Je) => [Je.path, Je]));
for (const Je of ke) ft.set(Je.path, Je);
Oe.children = Array.from(ft.values());
} else
s.treeNodes.value = [...s.treeNodes.value || [], ...ke];
} else {
const Ee = new Map((s.treeNodes.value || []).map((Oe) => [Oe.path, Oe]));
for (const Oe of ke) Ee.set(Oe.path, Oe);
s.treeNodes.value = Array.from(Ee.values());
}
return !0;
}
} catch (ce) {
console.warn("ensurePathLoaded failed for", p, ce);
} finally {
C[re] = void 0;
}
return !1;
}, v = (p) => {
const o = /* @__PURE__ */ new Set(), s = (d) => {
if (d.field && typeof d.field == "string" && o.add(d.field), d.values && Array.isArray(d.values))
for (const V of d.values)
(V.source === j.PROPERTY || V.source === j.MODEL) && typeof V.value == "string" && V.value.length > 0 && o.add(V.value);
if (d.children && Array.isArray(d.children))
for (const V of d.children)
s(V);
};
return s(p), o;
}, f = async (p, o) => {
const s = v(p), V = Array.from(s).map((A) => y(A, o));
await Promise.all(V);
}, k = () => {
const p = Object.keys(a);
return p.length > 0 ? p[0] : "default";
}, I = (p, o) => {
const s = g(p);
return M(s.treeNodes.value).find((V) => V.id === o) || null;
}, _ = () => Math.random().toString(36).substr(2, 9), W = e, Q = u, ve = (p, o) => (p & o) === o, L = (p) => {
const o = (p || "object").toLowerCase();
return o === "datetime" ? "date" : o === "guid" ? "string" : o === "collection" || o === "list" || o === "array" ? "array" : ["string", "number", "boolean", "date", "enum", "object", "array"].includes(o) ? o : "object";
}, E = (p, o, s) => typeof o == "number" && p.capabilityClauses && p.capabilityClauses.length > 0 ? p.capabilityClauses.some((d) => ve(o, d)) : !!(s && p.supportedTypes && p.supportedTypes.includes(s)), U = (p) => {
const o = L(p.type), s = typeof p.capabilities == "number" ? p.capabilities : void 0, d = typeof p.elementCapabilities == "number" ? p.elementCapabilities : void 0;
return e.value.filter((V) => {
const A = E(V, s, o), re = typeof d == "number" ? E(V, d, void 0) : !1;
return A || re;
});
}, S = (p) => e.value.filter((o) => o.supportedTypes.includes(p)), D = (p, o) => {
if (typeof p == "object" && p)
return typeof p.type == "string" ? p.type : "object";
if (typeof p == "string" && p.length > 0) {
const s = g(o || Object.keys(a)[0] || "default"), V = M(s.treeNodes.value).find((A) => A.path === p || A.id === p);
return (V == null ? void 0 : V.type) ?? "object";
}
return "object";
}, oe = (p) => p == null ? "string" : Array.isArray(p) ? "array" : typeof p == "number" ? "number" : typeof p == "boolean" ? "boolean" : typeof p == "object" ? "object" : "string", ie = (p) => typeof p == "string" ? 515 : typeof p == "number" ? 773 : typeof p == "boolean" ? 521 : p instanceof Date ? 273 : Array.isArray(p) ? 65 : 1, ye = (p, o) => {
if (!p) return "string";
const s = p.source, d = p.value;
switch (s) {
case j.LITERAL:
return oe(d);
case j.PROPERTY:
return typeof d == "object" && (d != null && d.type) ? d.type : typeof d == "string" ? D(d, o) : "object";
case j.FUNCTION:
return typeof d == "object" && (d != null && d.returnType) ? d.returnType : "object";
default:
return "string";
}
}, me = (p, o, s) => {
const d = e.value.find((A) => A.value === p);
return !d || !E(d, o.caps, o.type && L(o.type)) ? !1 : ["isEmpty", "isNotEmpty", "isNull", "isNotNull", "isTrue", "isFalse"].includes(p) || d.capabilityClauses && d.capabilityClauses.length > 0 || !s || ["equals", "notEquals", "in", "notIn"].includes(p) ? !0 : o.type && s.type ? L(o.type) === L(s.type) : !0;
}, q = (p) => {
const o = [], s = (d, V = "root") => {
if (d.kind === ue.Group)
V !== "root" && (!d.children || d.children.length === 0) && o.push({
message: "Empty rule group detected",
path: V,
nodeId: d.id
}), (d.children || []).forEach((A, re) => {
s(A, `${V}.child[${re}]`);
});
else if (d.kind === ue.Rule || d.kind === ue.Expression || d.kind === ue.RuleSet) {
if (d.expression !== void 0)
return;
!d.field && !d.function && o.push({
message: "Missing property or function selection",
path: V,
nodeId: d.id
}), d.operator || o.push({
message: "Missing operator selection",
path: V,
nodeId: d.id
});
const A = e.value.find((Ee) => Ee.value === d.operator), re = A == null ? void 0 : A.arity, ce = Array.isArray(d.values) && d.values.length > 0 && d.values.some((Ee) => Ee.value !== "" && Ee.value !== null && Ee.value !== void 0), ke = Array.isArray(d.values) ? d.values.length : 0;
if (re === Se.Unary ? ce && o.push({
message: `Operator '${d.operator}' does not require any values`,
path: V,
nodeId: d.id
}) : re === Se.Binary ? ce ? ke > 1 && o.push({
message: `Operator '${d.operator}' requires exactly one value, but ${ke} values were provided`,
path: V,
nodeId: d.id
}) : o.push({
message: "Missing comparison value",
path: V,
nodeId: d.id
}) : re === Se.Ternary ? (ke !== 2 || !ce) && o.push({
message: `Operator '${d.operator}' requires exactly two values (From, To)`,
path: V,
nodeId: d.id
}) : re === Se.Variadic ? ce || o.push({
message: `Operator '${d.operator}' requires at least one value`,
path: V,
nodeId: d.id
}) : ce || o.push({
message: "Missing comparison value",
path: V,
nodeId: d.id
}), (d.field || d.function) && d.operator && ce && re !== Se.Unary)
try {
const Ee = d.function ? void 0 : (() => {
const Ne = g(k()), Je = M(Ne.treeNodes.value).find((qt) => qt.path === d.field || qt.id === d.field);
return Je == null ? void 0 : Je.capabilities;
})(), Oe = d.function ? d.function.returnType || "object" : D(d.field || "", k());
for (const Ne of d.values || []) {
const ft = Ne.source === j.LITERAL ? ie(Ne.value) : Ne.source === j.PROPERTY || Ne.source === j.MODEL ? (() => {
const Mr = g(k()), Ht = M(Mr.treeNodes.value).find((ar) => ar.path === Ne.value || ar.id === Ne.value);
return (Ht == null ? void 0 : Ht.capabilities) ?? 0;
})() : 0, Je = Ne.source === j.LITERAL ? oe(Ne.value) : Ne.source === j.MODEL || Ne.source === j.PROPERTY ? D(Ne.value || "", k()) : "string";
me(
d.operator,
{ caps: Ee, type: L(Oe) },
{ caps: ft, type: L(Je) }
) || o.push({
message: `Operator '${d.operator}' is not applicable to left=${L(Oe)} / right=${L(Je)}`,
path: V,
nodeId: d.id