UNPKG

@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.

243 lines 230 kB
(function(ye,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],e):(ye=typeof globalThis<"u"?globalThis:ye||self,e(ye.VueRuleBuilder={},ye.Vue,ye.Pinia))})(this,function(ye,e,ir){"use strict";function ur(r){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(s,t,i.get?i:{enumerable:!0,get:()=>r[t]})}}return s.default=r,Object.freeze(s)}const Bt=ur(e),Ue="vue-condition-builder-autosave",mt=50;class De{static save(s,t,i){const c=new Date,a={id:`autosave-${Date.now()}`,instanceId:t,timestamp:c.getTime(),dateString:c.toLocaleDateString(),timeString:c.toLocaleTimeString(),rootGroup:JSON.parse(JSON.stringify(s)),preview:i},l=this.getHistory();return l.unshift(a),l.length>mt&&l.splice(mt),this.saveHistory(l),a}static getHistory(){try{const s=localStorage.getItem(Ue);if(!s)return[];const t=JSON.parse(s);return Array.isArray(t)?t:[]}catch(s){return console.warn("Failed to load autosave history:",s),[]}}static getHistoryForInstance(s){return this.getHistory().filter(i=>i.instanceId===s)}static getLatest(s){const t=s?this.getHistoryForInstance(s):this.getHistory();return t.length>0?t[0]:null}static load(s){return this.getHistory().find(i=>i.id===s)||null}static delete(s){const t=this.getHistory(),i=t.findIndex(c=>c.id===s);return i===-1?!1:(t.splice(i,1),this.saveHistory(t),!0)}static clear(){localStorage.removeItem(Ue)}static getHistoryGroupedByDate(s){const t=s?this.getHistoryForInstance(s):this.getHistory(),i=new Map;return t.forEach(c=>{const a=c.dateString;i.has(a)||i.set(a,[]),i.get(a).push(c)}),Array.from(i.entries()).map(([c,a])=>({date:c,entries:a})).sort((c,a)=>{var g,y;const l=((g=c.entries[0])==null?void 0:g.timestamp)||0;return(((y=a.entries[0])==null?void 0:y.timestamp)||0)-l})}static hasAutosaves(s){return(s?this.getHistoryForInstance(s):this.getHistory()).length>0}static clearInstance(s){const i=this.getHistory().filter(c=>c.instanceId!==s);this.saveHistory(i)}static getStorageSize(){try{const s=localStorage.getItem(Ue);return s?new Blob([s]).size/1024:0}catch{return 0}}static saveHistory(s){try{localStorage.setItem(Ue,JSON.stringify(s))}catch(t){if(console.error("Failed to save autosave history:",t),t instanceof Error&&t.name==="QuotaExceededError"){const i=s.slice(0,Math.floor(mt/2));try{localStorage.setItem(Ue,JSON.stringify(i))}catch{console.error("Still failed to save even after reducing history")}}}}}var Z=(r=>(r[r.Group=0]="Group",r[r.Rule=1]="Rule",r[r.Expression=2]="Expression",r[r.RuleSet=3]="RuleSet",r))(Z||{}),Pe=(r=>(r[r.And=0]="And",r[r.Or=1]="Or",r))(Pe||{}),R=(r=>(r[r.LITERAL=0]="LITERAL",r[r.MODEL=1]="MODEL",r[r.CONTEXT=2]="CONTEXT",r[r.FUNCTION=3]="FUNCTION",r[r.PARAM=4]="PARAM",r[r.EXPRESSION=5]="EXPRESSION",r[r.PROPERTY=6]="PROPERTY",r))(R||{}),pe=(r=>(r[r.Unary=1]="Unary",r[r.Binary=2]="Binary",r[r.Ternary=3]="Ternary",r[r.Variadic=99]="Variadic",r))(pe||{});const cr={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 dr(r){if(r==null)return"null";if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}}function pr(r){return r===Pe.Or?"OR":"AND"}function mr(r){const s=r.function?r.function.name||"function":r.field||"field",t=r.operator?cr[r.operator]||r.operator:"is",i=(r.values||[]).map(a=>dr(a.value));if(r.operator==="between"&&i.length>=2)return`${s} ${t} ${i[0]} and ${i[1]}`;const c=i[0]!==void 0?` ${i[0]}`:"";return`${s} ${t}${c}`}function vr(r){try{const s=i=>{if(i.kind===Z.Group){const c=(i.children||[]).map(l=>s(l)).filter(Boolean),a=c.join(` ${pr(i.combinator)} `);return i.not?`NOT (${a})`:c.length>1?`(${a})`:a}else{if(i.kind===Z.Rule)return mr(i);if(i.kind===Z.Expression)return i.expression?`expression(${i.expression.slice(0,30)}...)`:"expression";if(i.kind===Z.RuleSet){const c=i;return c.ruleSetName?`ruleset(${c.ruleSetName})`:"ruleset"}}return""};return s(r).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 fr=r=>r.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 yr=({size:r,strokeWidth:s=2,absoluteStrokeWidth:t,color:i,iconNode:c,name:a,class:l,...f},{slots:g})=>e.h("svg",{...rt,width:r||rt.width,height:r||rt.height,stroke:i||rt.stroke,"stroke-width":t?Number(s)*24/Number(r):s,class:["lucide",`lucide-${fr(a??"icon")}`],...f},[...c.map(y=>e.h(...y)),...g.default?[g.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 $=(r,s)=>(t,{slots:i})=>e.h(yr,{...t,iconNode:s,name:r},i);/** * @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 gr=$("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 br=$("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 hr=$("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 ot=$("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 Ae=$("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 Be=$("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 Tt=$("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 xr=$("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 St=$("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 Nr=$("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 vt=$("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 Ce=$("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 ft=$("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 kr=$("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 Rt=$("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 Er=$("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 qe=$("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 at=$("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 Ot=$("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 Vr=$("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 wr=$("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 yt=$("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 gt=$("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 Cr=$("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 _r=$("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 Br=$("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 It=$("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 Tr=$("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 Dt=$("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 lt=$("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 Lt=$("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 nt=$("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 Sr=$("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 Re=$("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 Pt=$("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 Rr=$("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 At=$("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 Or=$("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 Ir=$("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 Fe=$("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 st=$("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 Ve=$("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 Dr=$("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 Te=$("XIcon",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Lr={class:"rb-toast-content"},Pr={class:"rb-toast-body"},Ar={class:"rb-toast-icon"},Fr={class:"rb-toast-text"},jr={key:0,class:"rb-toast-title"},Mr=e.defineComponent({__name:"Toast",props:{message:{},title:{},type:{default:"info"},duration:{default:3e3},persistent:{type:Boolean,default:!1}},emits:["close"],setup(r,{expose:s,emit:t}){const i=r,c=t,a=e.ref(!1);let l=null;const f=()=>{a.value=!0,!i.persistent&&i.duration>0&&(l=window.setTimeout(()=>{g()},i.duration))},g=()=>{a.value=!1,l&&(clearTimeout(l),l=null),setTimeout(()=>{c("close")},300)};return e.onMounted(()=>{setTimeout(()=>{f()},50)}),e.onUnmounted(()=>{l&&clearTimeout(l)}),s({show:f,close:g}),(y,N)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[a.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["rb-toast",{"rb-toast-visible":a.value,"rb-toast-hidden":!a.value}])},[e.createElementVNode("div",Lr,[e.createElementVNode("div",Pr,[e.createElementVNode("div",Ar,[y.type==="success"?(e.openBlock(),e.createBlock(e.unref(St),{key:0,class:"rb-toast-icon-svg rb-toast-icon-success"})):y.type==="error"?(e.openBlock(),e.createBlock(e.unref(xr),{key:1,class:"rb-toast-icon-svg rb-toast-icon-error"})):y.type==="info"?(e.openBlock(),e.createBlock(e.unref(wr),{key:2,class:"rb-toast-icon-svg rb-toast-icon-info"})):(e.openBlock(),e.createBlock(e.unref(st),{key:3,class:"rb-toast-icon-svg rb-toast-icon-warning"}))]),e.createElementVNode("div",Fr,[y.title?(e.openBlock(),e.createElementBlock("p",jr,e.toDisplayString(y.title),1)):e.createCommentVNode("",!0),e.createElementVNode("p",{class:e.normalizeClass(["rb-toast-message",{"rb-toast-message-with-title":y.title}])},e.toDisplayString(y.message),3)]),e.createElementVNode("button",{type:"button",onClick:g,class:"rb-toast-close"},[e.createVNode(e.unref(Te),{class:"rb-toast-close-icon"})])])])],2)):e.createCommentVNode("",!0)]))}}),be=(r,s)=>{const t=r.__vccOpts||r;for(const[i,c]of s)t[i]=c;return t},zr=be(Mr,[["__scopeId","data-v-fad29cad"]]),it=e.ref([]);function je(){const r=l=>{const f=Date.now().toString(),g=document.createElement("div"),y=e.createApp(zr,{...l,onClose:()=>{s(f)}});return y.mount(g),it.value.push({id:f,app:y,container:g}),f},s=l=>{const f=it.value.findIndex(g=>g.id===l);f>-1&&(it.value[f].app.unmount(),it.value.splice(f,1))};return{showToast:r,success:(l,f,g)=>r({message:l,title:f,type:"success",...g}),error:(l,f,g)=>r({message:l,title:f,type:"error",duration:5e3,...g}),info:(l,f,g)=>r({message:l,title:f,type:"info",...g}),warning:(l,f,g)=>r({message:l,title:f,type:"warning",...g}),removeToast:s}}const he=Symbol("RULE_BUILDER_INSTANCE_KEY"),Ft=[{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"}],bt=ir.defineStore("ruleBuilder",()=>{const r=[{value:"equals",label:"Equals",supportedTypes:["string","number","boolean","date","enum","list","dictionary","object"],arity:pe.Binary},{value:"notEquals",label:"Not Equals",supportedTypes:["string","number","boolean","date","enum","list","dictionary","object"],arity:pe.Binary},{value:"contains",label:"Contains",supportedTypes:["string"],arity:pe.Binary},{value:"notContains",label:"Does Not Contain",supportedTypes:["string"],arity:pe.Binary},{value:"startsWith",label:"Starts With",supportedTypes:["string"],arity:pe.Binary},{value:"endsWith",label:"Ends With",supportedTypes:["string"],arity:pe.Binary},{value:"greaterThan",label:"Greater Than",supportedTypes:["number","date"],arity:pe.Binary},{value:"lessThan",label:"Less Than",supportedTypes:["number","date"],arity:pe.Binary},{value:"greaterThanOrEqual",label:"Greater Than or Equal",supportedTypes:["number","date"],arity:pe.Binary},{value:"lessThanOrEqual",label:"Less Than or Equal",supportedTypes:["number","date"],arity:pe.Binary},{value:"isEmpty",label:"Is Empty",supportedTypes:["string","object"],arity:pe.Unary},{value:"isNotEmpty",label:"Is Not Empty",supportedTypes:["string","object"],arity:pe.Unary},{value:"isNull",label:"Is Null",supportedTypes:["object"],arity:pe.Unary},{value:"isNotNull",label:"Is Not Null",supportedTypes:["object"],arity:pe.Unary},{value:"between",label:"Between",supportedTypes:["number","date"],arity:pe.Ternary}],s=[{value:"AND",label:"AND"},{value:"OR",label:"OR"}],t=e.ref(r),i=e.ref(s);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"}}),f=d=>(a[d]||(a[d]={dataProviders:{...c},rootRule:e.ref({id:"root",kind:Z.Group,not:!1,children:[]}),entityName:void 0,viewName:void 0,parentEntityName:void 0,availableTabs:void 0,features:e.ref({enableRules:!0,enableExpressions:!0,enableRuleSets:!0,enableNotOperator:!0,enableDeveloperTools:!0}),featureFlags:e.ref({naturalLanguagePreview:!0,testPanel:!0,autoSave:!1,validation:!0,lambdaPreview:!0,animations:!0}),testResult:e.ref(null),selectedField:e.ref(null),expandedNodes:e.ref(new Set),testData:e.ref(l()),isLoadingTree:e.ref(!1),isLoadingChildren:e.ref(!1),loadingChildren:e.ref({}),isLoadingFunctions:e.ref(!1),isTestingRule:e.ref(!1),functions:e.ref([]),functionsInitialized:e.ref(!1),isLoadingOperators:e.ref(!1),operatorsInitialized:e.ref(!1),treeNodes:e.ref([]),childNodes:e.ref({}),treeInitialized:e.ref(!1),lastAutosaveTime:e.ref(0),autosaveInProgress:e.ref(!1),highlightedNodeId:e.ref(null),availableRuleSets:e.ref([])}),a[d]),g=(d,n)=>{const o=f(d);o.highlightedNodeId.value=n,window.setTimeout(()=>{o.highlightedNodeId.value===n&&(o.highlightedNodeId.value=null)},2e3)},y=(d,n)=>{f(d).testData.value=n},N=d=>{f(d).testResult.value=null},b=(d,n)=>{const o=f(d);o.treeNodes.value=n,o.treeInitialized.value=!0},C=async d=>{const n=f(d);if(n.treeInitialized.value&&!(n.dataProviders.fetchTreeNodes||n.dataProviders.fetchTree))return n.treeNodes.value;n.isLoadingTree.value=!0;try{n.dataProviders.fetchTree?n.treeNodes.value=await n.dataProviders.fetchTree({entityName:n.entityName||"Entity",viewName:n.viewName,parentEntityName:n.parentEntityName,path:void 0}):n.dataProviders.fetchTreeNodes?n.treeNodes.value=await n.dataProviders.fetchTreeNodes():n.treeNodes.value=Ft,n.treeInitialized.value=!0}catch(o){console.error("Failed to load tree nodes:",o),n.treeNodes.value=Ft,n.treeInitialized.value=!0}finally{n.isLoadingTree.value=!1}return n.treeNodes.value},P=async(d,n)=>{if(!n)return[];const o=f(d);if(o.childNodes.value[n])return o.childNodes.value[n];o.isLoadingChildren.value=!0,o.loadingChildren.value={...o.loadingChildren.value,[n]:!0};try{if(o.dataProviders.fetchTree)o.childNodes.value[n]=await o.dataProviders.fetchTree({entityName:o.entityName||"Entity",viewName:o.viewName,parentEntityName:o.parentEntityName,path:n});else if(o.dataProviders.fetchChildNodes)o.childNodes.value[n]=await o.dataProviders.fetchChildNodes(n);else{const u=(I,S)=>{for(const W of I){if(W.id===S&&W.children)return W.children;if(W.children){const te=u(W.children,S);if(te.length>0)return te}}return[]};o.childNodes.value[n]=u(o.treeNodes.value,n)}}catch(u){console.error(`Failed to load child nodes for ${n}:`,u),o.childNodes.value[n]=[]}finally{o.isLoadingChildren.value=!1,o.loadingChildren.value={...o.loadingChildren.value,[n]:!1}}return o.childNodes.value[n]},j=async d=>{const n=f(d);if(n.functionsInitialized.value&&!(n.dataProviders.fetchFunctions||n.dataProviders.fetchBaseConfig))return n.functions.value;n.isLoadingFunctions.value=!0;try{if(n.dataProviders.fetchBaseConfig){const o=await n.dataProviders.fetchBaseConfig({entityName:n.entityName||"Entity",viewName:n.viewName,parentEntityName:n.parentEntityName}),u=(o==null?void 0:o.functions)??(o==null?void 0:o.Functions);Array.isArray(u)&&(n.functions.value=u);const I=(o==null?void 0:o.availableTabs)??(o==null?void 0:o.AvailableTabs);I&&(n.availableTabs=I);const S=(o==null?void 0:o.availableProperties)??(o==null?void 0:o.AvailableProperties);Array.isArray(S)&&(n.treeNodes.value=S);const W=(o==null?void 0:o.operators)??(o==null?void 0:o.Operators);if(W){const ce=W.comparison??W.Comparison,ve=W.group??W.Group;ce&&(t.value=ce),ve&&(i.value=ve)}const te=(o==null?void 0:o.ruleSets)??(o==null?void 0:o.RuleSets);Array.isArray(te)&&(n.availableRuleSets.value=te)}else n.dataProviders.fetchFunctions?n.functions.value=await n.dataProviders.fetchFunctions():n.functions.value=[];n.functionsInitialized.value=!0}catch(o){console.error("Failed to load functions:",o),n.functions.value=[],n.functionsInitialized.value=!0}finally{n.isLoadingFunctions.value=!1}return n.functions.value},U=async d=>{const n=f(d);if(n.operatorsInitialized.value&&!(n.dataProviders.fetchOperators||n.dataProviders.fetchBaseConfig))return{comparison:t.value,group:i.value};n.isLoadingOperators.value=!0;try{if(n.dataProviders.fetchBaseConfig){const o=await n.dataProviders.fetchBaseConfig({entityName:n.entityName||"Entity",viewName:n.viewName,parentEntityName:n.parentEntityName}),u=(o==null?void 0:o.operators)??(o==null?void 0:o.Operators);(u!=null&&u.comparison||u!=null&&u.Comparison)&&(t.value=u.comparison??u.Comparison),(u!=null&&u.group||u!=null&&u.Group)&&(i.value=u.group??u.Group);const I=(o==null?void 0:o.functions)??(o==null?void 0:o.functions);Array.isArray(I)&&!n.functionsInitialized.value&&(n.functions.value=I,n.functionsInitialized.value=!0);const S=(o==null?void 0:o.availableTabs)??(o==null?void 0:o.AvailableTabs);S&&(n.availableTabs=S);const W=(o==null?void 0:o.availableProperties)??(o==null?void 0:o.AvailableProperties);Array.isArray(W)&&(!n.treeNodes.value||n.treeNodes.value.length===0)&&(n.treeNodes.value=W);const te=(o==null?void 0:o.ruleSets)??(o==null?void 0:o.RuleSets);Array.isArray(te)&&(n.availableRuleSets.value=te)}else if(n.dataProviders.fetchOperators){const o=await n.dataProviders.fetchOperators();o!=null&&o.comparison&&Array.isArray(o.comparison)&&(t.value=o.comparison),o!=null&&o.group&&Array.isArray(o.group)&&(i.value=o.group)}n.operatorsInitialized.value=!0}catch(o){console.error("Failed to load operators:",o),n.operatorsInitialized.value=!0}finally{n.isLoadingOperators.value=!1}return{comparison:t.value,group:i.value}},D=d=>{const n=[],o=u=>{for(const I of u)n.push(I),I.children&&I.children.length>0&&o(I.children)};return o(d),n},V={},v=async(d,n)=>{const o=f(n||x());if(D(o.treeNodes.value).find(te=>te.path===d))return!1;const I=d.lastIndexOf("."),S=I>0?d.substring(0,I):"";if(!o.dataProviders.fetchTree)return!1;const W=S||"__root__";if(V[W]!==void 0){try{await V[W]}catch{}return D(o.treeNodes.value).some(ce=>ce.path===d)}try{const te=o.dataProviders.fetchTree({entityName:o.entityName||"Entity",viewName:o.viewName,parentEntityName:o.parentEntityName,path:S||void 0});V[W]=te;const ce=await te;if(Array.isArray(ce)&&ce.length>0){if(S){const fe=D(o.treeNodes.value).find(de=>de.path===S);if(fe){const de=fe.children||[],tt=new Map(de.map(Se=>[Se.path,Se]));for(const Se of ce)tt.set(Se.path,Se);fe.children=Array.from(tt.values())}else o.treeNodes.value=[...o.treeNodes.value||[],...ce]}else{const ve=new Map((o.treeNodes.value||[]).map(fe=>[fe.path,fe]));for(const fe of ce)ve.set(fe.path,fe);o.treeNodes.value=Array.from(ve.values())}return!0}}catch(te){console.warn("ensurePathLoaded failed for",d,te)}finally{V[W]=void 0}return!1},p=d=>{const n=new Set,o=u=>{if(u.field&&typeof u.field=="string"&&n.add(u.field),u.values&&Array.isArray(u.values))for(const I of u.values)(I.source===R.PROPERTY||I.source===R.MODEL)&&typeof I.value=="string"&&I.value.length>0&&n.add(I.value);if(u.children&&Array.isArray(u.children))for(const I of u.children)o(I)};return o(d),n},m=async(d,n)=>{const o=p(d),I=Array.from(o).map(S=>v(S,n));await Promise.all(I)},x=()=>{const d=Object.keys(a);return d.length>0?d[0]:"default"},_=(d,n)=>{const o=f(d);return D(o.treeNodes.value).find(I=>I.id===n)||null},h=()=>Math.random().toString(36).substr(2,9),M=t,q=i,re=(d,n)=>(d&n)===n,B=d=>{const n=(d||"object").toLowerCase();return n==="datetime"?"date":n==="guid"?"string":n==="collection"||n==="list"||n==="array"?"array":["string","number","boolean","date","enum","object","array"].includes(n)?n:"object"},w=(d,n,o)=>typeof n=="number"&&d.capabilityClauses&&d.capabilityClauses.length>0?d.capabilityClauses.some(u=>re(n,u)):!!(o&&d.supportedTypes&&d.supportedTypes.includes(o)),L=d=>{const n=B(d.type),o=typeof d.capabilities=="number"?d.capabilities:void 0,u=typeof d.elementCapabilities=="number"?d.elementCapabilities:void 0;return t.value.filter(I=>{const S=w(I,o,n),W=typeof u=="number"?w(I,u,void 0):!1;return S||W})},E=d=>t.value.filter(n=>n.supportedTypes.includes(d)),O=(d,n)=>{if(typeof d=="object"&&d)return typeof d.type=="string"?d.type:"object";if(typeof d=="string"&&d.length>0){const o=f(n||Object.keys(a)[0]||"default"),I=D(o.treeNodes.value).find(S=>S.path===d||S.id===d);return(I==null?void 0:I.type)??"object"}return"object"},Q=d=>d==null?"string":Array.isArray(d)?"array":typeof d=="number"?"number":typeof d=="boolean"?"boolean":typeof d=="object"?"object":"string",ee=d=>typeof d=="string"?515:typeof d=="number"?773:typeof d=="boolean"?521:d instanceof Date?273:Array.isArray(d)?65:1,ae=(d,n)=>{if(!d)return"string";const o=d.source,u=d.value;switch(o){case R.LITERAL:return Q(u);case R.PROPERTY:return typeof u=="object"&&(u!=null&&u.type)?u.type:typeof u=="string"?O(u,n):"object";case R.FUNCTION:return typeof u=="object"&&(u!=null&&u.returnType)?u.returnType:"object";default:return"string"}},oe=(d,n,o)=>{const u=t.value.find(S=>S.value===d);return!u||!w(u,n.caps,n.type&&B(n.type))?!1:["isEmpty","isNotEmpty","isNull","isNotNull","isTrue","isFalse"].includes(d)||u.capabilityClauses&&u.capabilityClauses.length>0||!o||["equals","notEquals","in","notIn"].includes(d)?!0:n.type&&o.type?B(n.type)===B(o.type):!0},F=d=>{const n=[],o=(u,I="root")=>{if(u.kind===Z.Group)I!=="root"&&(!u.children||u.children.length===0)&&n.push({message:"Empty rule group detected",path:I,nodeId:u.id}),(u.children||[]).forEach((S,W)=>{o(S,`${I}.child[${W}]`)});else if(u.kind===Z.Rule||u.kind===Z.Expression||u.kind===Z.RuleSet){if(u.expression!==void 0)return;!u.field&&!u.function&&n.push({message:"Missing property or function selection",path:I,nodeId:u.id}),u.operator||n.push({message:"Missing operator selection",path:I,nodeId:u.id});const S=t.value.find(ve=>ve.value===u.operator),W=S==null?void 0:S.arity,te=Array.isArray(u.values)&&u.values.length>0&&u.values.some(ve=>ve.value!==""&&ve.value!==null&&ve.value!==void 0),ce=Array.isArray(u.values)?u.values.length:0;if(W===pe.Unary?te&&n.push({message:`Operator '${u.operator}' does not require any values`,path:I,nodeId:u.id}):W===pe.Binary?te?ce>1&&n.push({message:`Operator '${u.operator}' requires exactly one value, but ${ce} values were provided`,path:I,nodeId:u.id}):n.push({message:"Missing comparison value",path:I,nodeId:u.id}):W===pe.Ternary?(ce!==2||!te)&&n.push({message:`Operator '${u.operator}' requires exactly two values (From, To)`,path:I,nodeId:u.id}):W===pe.Variadic?te||n.push({message:`Operator '${u.operator}' requires at least one value`,path:I,nodeId:u.id}):te||n.push({message:"Missing comparison value",path:I,nodeId:u.id}),(u.field||u.function)&&u.operator&&te&&W!==pe.Unary)try{const ve=u.function?void 0:(()=>{const de=f(x()),Se=D(de.treeNodes.value).find(Ct=>Ct.path===u.field||Ct.id===u.field);return Se==null?void 0:Se.capabilities})(),fe=u.function?u.function.returnType||"object":O(u.field||"",x());for(const de of u.values||[]){const tt=de.source===R.LITERAL?ee(de.value):de.source===R.PROPERTY||de.source===R.MODEL?(()=>{const Sc=f(x()),_t=D(Sc.treeNodes.value).find(sr=>sr.path===de.value||sr.id===de.value);return(_t==null?void 0:_t.capabilities)??0})():0,Se=de.source===R.LITERAL?Q(de.value):de.source===R.MODEL||de.source===R.PROPERTY?O(de.value||"",x()):"string";oe(u.operator,{caps:ve,type:B(fe)},{caps:tt,type:B(Se)})||n.push({message:`Operator '${u.operator}' is not applicable to left=${B(fe)} / right=${B(Se)}`,path:I,nodeId:u.id})}}catch{}}};return o(d),{isValid:n.length===0,errors:n}},K=2e3,G=(d,n=!1)=>{const o=f(d);if(o.autosaveInProgress.value)return;const u=S=>S.kind===Z.Rule?!!(S.field||S.function||S.expression):S.kind===Z.Expression?!!S.expression:S.kind===Z.RuleSet?!!S.ruleSetId:(S.children||[]).some(u);if(!u(o.rootRule.value)){console.log("Skipping autosave - no meaningful content");return}if(!(!F(o.rootRule.value).isValid&&!n)){if(!n&&ne&&(clearTimeout(ne),ne=null),n){ke(d);return}ne=window.setTimeout(()=>{ke(d),ne=null},K)}},ke=async d=>{const n=f(d);if(!n.autosaveInProgress.value)try{n.autosaveInProgress.value=!0;const o=je(),u=F(n.rootRule.value),I=vr(n.rootRule.value),S=u.isValid?`✅ ${I}`:`⚠️ ${I} (${u.errors.length} issue${u.errors.length>1?"s":""})`,W=De.save(n.rootRule.value,d,S);n.lastAutosaveTime.value=W.timestamp,u.isValid?o.success("Auto-saved",`Valid rule saved at ${W.timeString}`,{duration:2e3}):o.info("Auto-saved",`Draft saved at ${W.timeString} (${u.errors.length} validation issues)`,{duration:3e3})}catch(o){console.error("Autosave failed:",o),je().error("Autosave failed","Your changes were not saved automatically")}finally{n.autosaveInProgress.value=!1}},H=async(d,n)=>{try{const o=De.load(n);if(!o)return je().error("Restore failed","Could not find the selected autosave"),!1;const u=o.rootGroup;return f(d).rootRule.value=u,await m(u,d),je().success("Restored",`Restored from ${o.dateString} at ${o.timeString}`),G(d),!0}catch(o){return console.error("Restore from autosave failed:",o),je().error("Restore failed","An error occurred while restoring"),!1}},A=(d,n,o=Z.Rule)=>{const u=f(d),I={id:h(),kind:o,not:!1,children:[],operator:o===Z.Rule?"equals":void 0,expression:o===Z.Expression?"":void 0,...o===Z.RuleSet?{ruleSetId:"",ruleSetName:""}:{}},S=W=>W.id===n&&W.kind===Z.Group?{...W,children:[...W.children||[],I]}:{...W,children:(W.children||[]).map(S)};u.rootRule.value=S(u.rootRule.value),G(d)},le=(d,n,o)=>{const u=f(d),I=S=>S.id===n&&S.kind===Z.Group?{...S,children:(S.children||[]).filter(W=>W.id!==o)}:{...S,children:(S.children||[]).map(I)};u.rootRule.value=I(u.rootRule.value),G(d)},me=(d,n,o,u)=>{const I=f(d),S=W=>W.id===n&&W.kind===Z.Group?{...W,children:(W.children||[]).map(te=>te.id===o?{...te,...u.field!==void 0?{field:u.field}:{},...u.operator!==void 0?{operator:u.operator}:{},...u.not!==void 0?{not:u.not}:{},...u.expression!==void 0?{expression:u.expression,field:void 0,operator:void 0,values:void 0}:{},...u.ruleSetId!==void 0?{ruleSetId:u.ruleSetId}:{},...u.ruleSetName!==void 0?{ruleSetName:u.ruleSetName}:{},...u.function!==void 0?{function:u.function,field:void 0}:{},...u.field!==void 0?{function:u.field?void 0:te.function}:{},...u.value!==void 0?{values:[{source:u.value.source||R.LITERAL,value:u.value.value}]}:{},...u.values!==void 0?{values:u.values.map(ce=>({source:ce.source||R.LITERAL,value:ce.value}))}:{}}:te)}:{...W,children:(W.children||[]).map(S)};I.rootRule.value=S(I.rootRule.value),G(d)},Ie=(d,n)=>{const o=f(d),u={id:h(),kind:Z.Group,combinator:Pe.Or,not:!1,children:[]},I=S=>S.id===n&&S.kind===Z.Group?{...S,children:[...S.children||[],u]}:{...S,children:(S.children||[]).map(I)};o.rootRule.value=I(o.rootRule.value),G(d)},xe=(d,n,o)=>{const u=f(d),I=S=>S.id===o&&S.kind===Z.Group?{...S,children:(S.children||[]).filter(W=>W.id!==n)}:{...S,children:(S.children||[]).map(I)};u.rootRule.value=I(u.rootRule.value),G(d)},Le=(d,n,o)=>{const u=f(d),I=S=>S.id===n&&S.kind===Z.Group?{...S,combinator:o.toLowerCase()==="and"?Pe.And:Pe.Or}:{...S,children:(S.children||[]).map(I)};u.rootRule.value=I(u.rootRule.value),G(d)},$e=(d,n,o)=>{const u=f(d),I=S=>S.id===n&&S.kind===Z.Group?{...S,not:o}:{...S,children:(S.children||[]).map(I)};u.rootRule.value=I(u.rootRule.value),G(d)},pt=(d,n)=>{const o=f(d);o.featureFlags.value[n]=!o.featureFlags.value[n]},k=(d,n)=>{const o=f(d),u=new Set(o.expandedNodes.value);u.has(n)?u.delete(n):(u.add(n),P(d,n)),o.expandedNodes.value=u},T=async d=>{const n=f(d);try{const o=JSON.parse(JSON.stringify(n.testData.value));n.isTestingRule.value=!0;let u;return n.dataProviders.testRule?u=await n.dataProviders.testRule(n.rootRule.value,o):u={success:!0,result:!0,message:"Test completed (mock)",data:o,executionTime:0},n.testResult.value=u,u}catch(o){throw n.testResult.value={success:!1,result:!1,error:o instanceof Error?o.message:"Test failed",executionTime:0},o}finally{n.isTestingRule.value=!1}},z=async(d,n)=>{const o=f(d);try{return o.dataProviders.fetchContextualData?await o.dataProviders.fetchContextualData(n):[]}catch(u){return console.error("Failed to fetch contextual data:",u),[]}},Y=d=>{var I;let n="";if(d.kind===Z.Rule){if(d.expression)n=`Expression: ${d.expression}`;else{const S=d.field||((I=d.function)==null?void 0:I.name)||"Field",W=d.operator||"equals",te=d.values||[];if(te.length>1){const ce=te.map(ve=>JSON.stringify(ve.value)).join(", ");n=`${S} ${W} [${ce}]`}else{const ce=te[0],ve=ce?JSON.stringify(ce.value):"";n=`${S} ${W} ${ve}`}}return d.not?`NOT (${n})`:n}else{if(d.kind===Z.Expression)return n=`Expression: ${d.expression||"(empty)"}`,d.not?`NOT (${n})`:n;if(d.kind===Z.RuleSet)return n=`RuleSet: ${d.ruleSetName||d.ruleSetId||"(empty)"}`,d.not?`NOT (${n})`:n}const o=(d.children||[]).map(S=>S.kind===Z.Group?`(${Y(S)})`:Y(S));if(o.length===0)return"";if(o.length===1)return o[0];const u=d.combinator===Pe.And?" AND ":" OR ";return n=o.join(u),d.not?`NOT (${n})`:n},J=d=>{var I;let n="";if(d.kind===Z.Rule){if(d.expression)n=d.expression;else{const S=d.field?`x.${d.field}`:(I=d.function)!=null&&I.name?`x.${d.function.name}()`:"x.field",W=d.operator||"equals",te=d.values||[],ce=fe=>typeof fe=="string"?`"${fe}"`:fe,ve=fe=>{const de=ce(fe.value);switch(W){case"equals":return`${S} == ${de}`;case"notEquals":return`${S} != ${de}`;case"contains":return`${S}.Contains(${de})`;case"greaterThan":return`${S} > ${de}`;case"lessThan":return`${S} < ${de}`;case"greaterThanOrEqual":return`${S} >= ${de}`;case"lessThanOrEqual":return`${S} <= ${de}`;default:return`${S} == ${de}`}};if(W==="between"&&te.length===2){const fe=ce(te[0].value),de=ce(te[1].value);n=`${S} >= ${fe} && ${S} <= ${de}`}else{const fe=te.map(ve);n=fe.length>1?`(${fe.join(" || ")})`:fe[0]||""}}return d.not?`!(${n})`:n}else{if(d.kind===Z.Expression)return n=d.expression||"",d.not?`!(${n})`:n;if(d.kind===Z.RuleSet)return n=`/* RuleSet: ${d.ruleSetName||d.ruleSetId||"(empty)"} */`,d.not?`!(${n})`:n}const o=(d.children||[]).map(S=>S.kind===Z.Group?`(${J(S)})`:J(S));if(o.length===0)return"";if(o.length===1)return o[0];const u=d.combinator===Pe.And?` && `:` || `;return n=o.join(u),d.not?`!(${n})`:n},X=(d,n)=>{const o=f(d);o.dataProviders={...o.dataProviders,...n},!o.treeInitialized.value&&n.fetchTreeNodes&&C(d),n.fetchBaseConfig?(async()=>{try{const u=await n.fetchBaseConfig({entityName:o.entityName||"Entity",viewName:o.viewName,parentEntityName:o.parentEntityName}),I=(u==null?void 0:u.operators)??(u==null?void 0:u.Operators);(I!=null&&I.comparison||I!=null&&I.Comparison)&&(t.value=I.comparison??I.Comparison),(I!=null&&I.group||I!=null&&I.Group)&&(i.value=I.group??I.Group);const S=(u==null?void 0:u.functions)??(u==null?void 0:u.functions);Array.isArray(S)&&(o.functions.value=S,o.functionsInitialized.value=!0);const W=(u==null?void 0:u.availableTabs)??(u==null?void 0:u.AvailableTabs);W&&(o.availableTabs=W);const te=(u==null?void 0:u.features)??(u==null?void 0:u.Features);te&&typeof te=="object"&&(o.features.value={...o.features.value,...te});const ce=(u==null?void 0:u.ruleSets)??(u==null?void 0:u.RuleSets);Array.isArray(ce)&&(o.availableRuleSets.value=ce);const ve=(u==null?void 0:u.availableProperties)??(u==null?void 0:u.AvailableProperties);Array.isArray(ve)&&(o.treeNodes.value=ve),o.operatorsInitialized.value=!0}catch(u){console.error("Failed to load base config:",u),o.functions.value=o.functions.value||[],o.functionsInitialized.value=!0,o.operatorsInitialized.value=!0}})():(!o.functionsInitialized.value&&n.fetchFunctions&&j(d),!o.operatorsInitialized.value&&n.fetchOperators&&U(d))},ie=d=>{c={...c,...d};for(const n of Object.keys(a))X(n,d)};let ne=null;const ue=d=>{const n=f(d);return{entityName:n.entityName,viewName:n.viewName,parentEntityName:n.parentEntityName}},_e=async(d,n)=>{const o=f(d);ne&&(clearTimeout(ne),ne=null),n&&(n.entityName!==void 0&&(o.entityName=n.entityName),n.viewName!==void 0&&(o.viewName=n.viewName),n.parentEntityName!==void 0&&(o.parentEntityName=n.parentEntityName)),o.rootRule.value={id:"root",kind:Z.Group,not:!1,children:[]},o.selectedField.value=null,o.expandedNodes.value=new Set,o.highlightedNodeId.value=null,o.testResult.value=null,o.treeNodes.value=[],o.childNodes.value={},o.treeInitialized.value=!1,o.isLoadingTree.value=!1,o.isLoadingChildren.value=!1,o.loadingChildren.value={},o.functions.value=[],o.functionsInitialized.value=!1,o.isLoadingFunctions.value=!1,o.isLoadingOperators.value=!1,o.operatorsInitialized.value=!1,o.lastAutosaveTime.value=0,o.autosaveInProgress.value=!1;try{De.clearInstance(d)}catch{}try{await U(d)}catch{}if(o.treeNodes.value.length===0&&!o.treeInitialized.value)try{await C(d)}catch{}else o.treeNodes.value.length>0&&(o.treeInitialized.value=!0)};return{OPERATORS:M,GROUP_OPERATORS:q,validateRules:F,getOperatorsForType:E,getOperatorsForNode:L,ensurePathLoaded:v,getFieldType:O,getValueType:ae,inferLiteralType:Q,capabilitiesForLiteral:ee,isOperatorCompatible:oe,generateNaturalLanguage:Y,generateLambdaExpression:J,registerDataProviders:ie,getFacade:d=>{const n=f(d);return{rootRule:n.rootRule,rootGroup:n.rootRule,featureFlags:n.featureFlags,selectedField:n.selectedField,testData:n.testData,testResult:n.testResult,expandedNodes:n.expandedNodes,lastAutosaveTime:n.lastAutosaveTime,autosaveInProgress:n.autosaveInProgress,treeNodes:n.treeNodes,childNodes:n.childNodes,functions:n.functions,isLoadingTree:n.isLoadingTree,isLoadingChildren:n.isLoadingChildren,loadingChildren:n.loadingChildren,isLoadingFunctions:n.isLoadingFunctions,isTestingRule:n.isTestingRule,isLoadingOperators:n.isLoadingOperators,treeInitialized:n.treeInitialized,functionsInitialized:n.functionsInitialized,operatorsInitialized:n.operatorsInitialized,availableTabs:()=>n.availableTabs,addRule:(o,u=Z.Rule)=>{A(d,o,u)},removeRule:(o,u)=>le(d,o,u),updateRule:(o,u,I)=>me(d,o,u,I),addGroup:o=>Ie(d,o),removeGroup:(o,u)=>xe(d,o,u),updateGroupOperator:(o,u)=>Le(d,o,u),updateGroupNot:(o,u)=>$e(d,o,u),toggleFeature:o=>pt(d,o),toggleTreeNode:o=>k