@commercelayer/app-elements 6.2.0 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
1
  "use client";
2
- import { t as Z, B as re, D as le, E as ie, I as oe, N as ce, O as ue, P as de, Z as R, b as me, d as pe, e as fe, f as he, g as ge, h as ye, i as be, j as xe, k as ve, l as D, n as je, o as _e, p as Te, q as Ne, r as we, s as Ee, u as Ce, v as $e, w as Se, x as Re, y as ke, z as Ve, A as Ae, C as Ie, F as Ze, G as De, H as Me, J as Oe, K as qe, L as Pe, M as Le, Q as Fe, R as Ue, S as ze, T as Je, U as We, V as Be, W as Ye, X as Ge, Y as Xe, _ as He, $ as Qe, a0 as Ke, a1 as et, a2 as tt, a3 as at, a4 as st, a5 as nt, a6 as rt, a7 as lt, a8 as it, a9 as M, aa as ot, ab as ct, ac as ut, ad as dt, ae as mt, af as pt, ag as ft, ah as ht, ai as gt, aj as yt, ak as bt, al as xt, am as vt, an as jt, ao as _t, ap as Tt, aq as Nt, ar as wt, as as Et, at as Ct, au as $t, av as St, aw as Rt, ax as kt, ay as Vt, az as At, aA as It, aB as Zt, aC as Dt, aD as Mt, aE as Ot, aF as qt, aG as Pt, aH as Lt, aI as Ft, aJ as Ut, aK as zt, aL as Jt, aM as Wt, aN as Bt, aO as Yt, aP as Gt, aQ as Xt, aR as Ht, aS as Qt, aT as Kt, aU as t, aV as k, aW as ea, aX as ta, aY as aa, aZ as j, a_ as E, a$ as sa, b0 as W, b1 as b, b2 as A, b3 as w, b4 as v, b5 as N, b6 as na, b7 as $, b8 as B, b9 as Y, ba as G, bb as ra, bc as la, bd as X, be as V, bf as ia, bg as oa, bh as ca } from "./main-3wm3lckW.js";
3
- import O, { useReducer as ua, useCallback as C, useMemo as da, createContext as ma, useContext as pa, useRef as H, useState as f, useEffect as _ } from "react";
2
+ import { t as O, B as fe, D as pe, E as he, I as ge, N as xe, O as ye, P as be, Z as $, b as ve, d as je, e as _e, f as Te, g as Ne, h as Me, i as we, j as Se, k as Ce, l as q, n as Ee, o as $e, p as ke, q as Re, r as Ve, s as Ae, u as Ie, v as Ze, w as De, x as Oe, y as qe, z as Pe, A as Le, C as Fe, F as ze, G as Ue, H as Je, J as We, K as Be, L as Ye, M as Ge, Q as Xe, R as He, S as Qe, T as Ke, U as et, V as tt, W as at, X as st, Y as nt, _ as rt, $ as lt, a0 as it, a1 as ot, a2 as ct, a3 as ut, a4 as dt, a5 as mt, a6 as ft, a7 as pt, a8 as ht, a9 as P, aa as gt, ab as xt, ac as yt, ad as bt, ae as vt, af as jt, ag as _t, ah as Tt, ai as Nt, aj as Mt, ak as wt, al as St, am as Ct, an as Et, ao as $t, ap as kt, aq as Rt, ar as Vt, as as At, at as It, au as Zt, av as Dt, aw as Ot, ax as qt, ay as Pt, az as Lt, aA as Ft, aB as zt, aC as Ut, aD as Jt, aE as Wt, aF as Bt, aG as Yt, aH as Gt, aI as Xt, aJ as Ht, aK as Qt, aL as Kt, aM as ea, aN as ta, aO as aa, aP as sa, aQ as na, aR as ra, aS as la, aT as ia, aU as t, aV as R, aW as oa, aX as ca, aY as Q, aZ as j, a_ as N, a$ as ua, b0 as K, b1 as b, b2 as A, b3 as w, b4 as v, b5 as M, b6 as C, b7 as da, b8 as ee, b9 as ma, ba as L, bb as I, bc as te, bd as fa, be as pa, bf as ae, bg as V, bh as ha, bi as ga, bj as xa } from "./main-L857O21K.js";
3
+ import F, { useReducer as ya, useCallback as S, useMemo as ba, createContext as va, useContext as ja, useRef as se, useState as g, useEffect as _ } from "react";
4
4
  import "react-hook-form";
5
5
  import "wouter";
6
- import { p as q } from "./parseISO-DFFsG4qz.js";
7
- function P(e, s) {
6
+ import { p as z } from "./parseISO-CbJPLsTx.js";
7
+ function U(e, s) {
8
8
  const a = e.match(
9
9
  /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/
10
10
  );
11
- return a ? Z(
11
+ return a ? O(
12
12
  Date.UTC(
13
13
  +a[1],
14
14
  +a[2] - 1,
@@ -19,149 +19,149 @@ function P(e, s) {
19
19
  +((a[7] || "0") + "00").substring(0, 3)
20
20
  ),
21
21
  s?.in
22
- ) : Z(NaN, s?.in);
22
+ ) : O(NaN, s?.in);
23
23
  }
24
24
  const y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
25
25
  __proto__: null,
26
- BRAND: re,
27
- DIRTY: le,
28
- EMPTY_PATH: ie,
29
- INVALID: oe,
30
- NEVER: ce,
31
- OK: ue,
32
- ParseStatus: de,
33
- Schema: R,
34
- ZodAny: me,
35
- ZodArray: pe,
36
- ZodBigInt: fe,
37
- ZodBoolean: he,
38
- ZodBranded: ge,
39
- ZodCatch: ye,
40
- ZodDate: be,
41
- ZodDefault: xe,
42
- ZodDiscriminatedUnion: ve,
43
- ZodEffects: D,
44
- ZodEnum: je,
45
- ZodError: _e,
26
+ BRAND: fe,
27
+ DIRTY: pe,
28
+ EMPTY_PATH: he,
29
+ INVALID: ge,
30
+ NEVER: xe,
31
+ OK: ye,
32
+ ParseStatus: be,
33
+ Schema: $,
34
+ ZodAny: ve,
35
+ ZodArray: je,
36
+ ZodBigInt: _e,
37
+ ZodBoolean: Te,
38
+ ZodBranded: Ne,
39
+ ZodCatch: Me,
40
+ ZodDate: we,
41
+ ZodDefault: Se,
42
+ ZodDiscriminatedUnion: Ce,
43
+ ZodEffects: q,
44
+ ZodEnum: Ee,
45
+ ZodError: $e,
46
46
  get ZodFirstPartyTypeKind() {
47
- return Te;
47
+ return ke;
48
48
  },
49
- ZodFunction: Ne,
50
- ZodIntersection: we,
51
- ZodIssueCode: Ee,
52
- ZodLazy: Ce,
53
- ZodLiteral: $e,
54
- ZodMap: Se,
55
- ZodNaN: Re,
56
- ZodNativeEnum: ke,
57
- ZodNever: Ve,
58
- ZodNull: Ae,
59
- ZodNullable: Ie,
60
- ZodNumber: Ze,
61
- ZodObject: De,
62
- ZodOptional: Me,
63
- ZodParsedType: Oe,
64
- ZodPipeline: qe,
65
- ZodPromise: Pe,
66
- ZodReadonly: Le,
67
- ZodRecord: Fe,
68
- ZodSchema: R,
69
- ZodSet: Ue,
70
- ZodString: ze,
71
- ZodSymbol: Je,
72
- ZodTransformer: D,
73
- ZodTuple: We,
74
- ZodType: R,
75
- ZodUndefined: Be,
76
- ZodUnion: Ye,
77
- ZodUnknown: Ge,
78
- ZodVoid: Xe,
79
- addIssueToContext: He,
80
- any: Qe,
81
- array: Ke,
82
- bigint: et,
83
- boolean: tt,
84
- coerce: at,
85
- custom: st,
86
- date: nt,
87
- datetimeRegex: rt,
88
- defaultErrorMap: lt,
89
- discriminatedUnion: it,
90
- effect: M,
91
- enum: ot,
92
- function: ct,
93
- getErrorMap: ut,
94
- getParsedType: dt,
95
- instanceof: mt,
96
- intersection: pt,
97
- isAborted: ft,
98
- isAsync: ht,
99
- isDirty: gt,
100
- isValid: yt,
101
- late: bt,
102
- lazy: xt,
103
- literal: vt,
104
- makeIssue: jt,
105
- map: _t,
106
- nan: Tt,
107
- nativeEnum: Nt,
108
- never: wt,
109
- null: Et,
110
- nullable: Ct,
111
- number: $t,
112
- object: St,
49
+ ZodFunction: Re,
50
+ ZodIntersection: Ve,
51
+ ZodIssueCode: Ae,
52
+ ZodLazy: Ie,
53
+ ZodLiteral: Ze,
54
+ ZodMap: De,
55
+ ZodNaN: Oe,
56
+ ZodNativeEnum: qe,
57
+ ZodNever: Pe,
58
+ ZodNull: Le,
59
+ ZodNullable: Fe,
60
+ ZodNumber: ze,
61
+ ZodObject: Ue,
62
+ ZodOptional: Je,
63
+ ZodParsedType: We,
64
+ ZodPipeline: Be,
65
+ ZodPromise: Ye,
66
+ ZodReadonly: Ge,
67
+ ZodRecord: Xe,
68
+ ZodSchema: $,
69
+ ZodSet: He,
70
+ ZodString: Qe,
71
+ ZodSymbol: Ke,
72
+ ZodTransformer: q,
73
+ ZodTuple: et,
74
+ ZodType: $,
75
+ ZodUndefined: tt,
76
+ ZodUnion: at,
77
+ ZodUnknown: st,
78
+ ZodVoid: nt,
79
+ addIssueToContext: rt,
80
+ any: lt,
81
+ array: it,
82
+ bigint: ot,
83
+ boolean: ct,
84
+ coerce: ut,
85
+ custom: dt,
86
+ date: mt,
87
+ datetimeRegex: ft,
88
+ defaultErrorMap: pt,
89
+ discriminatedUnion: ht,
90
+ effect: P,
91
+ enum: gt,
92
+ function: xt,
93
+ getErrorMap: yt,
94
+ getParsedType: bt,
95
+ instanceof: vt,
96
+ intersection: jt,
97
+ isAborted: _t,
98
+ isAsync: Tt,
99
+ isDirty: Nt,
100
+ isValid: Mt,
101
+ late: wt,
102
+ lazy: St,
103
+ literal: Ct,
104
+ makeIssue: Et,
105
+ map: $t,
106
+ nan: kt,
107
+ nativeEnum: Rt,
108
+ never: Vt,
109
+ null: At,
110
+ nullable: It,
111
+ number: Zt,
112
+ object: Dt,
113
113
  get objectUtil() {
114
- return Rt;
114
+ return Ot;
115
115
  },
116
- oboolean: kt,
117
- onumber: Vt,
118
- optional: At,
119
- ostring: It,
120
- pipeline: Zt,
121
- preprocess: Dt,
122
- promise: Mt,
123
- quotelessJson: Ot,
124
- record: qt,
125
- set: Pt,
126
- setErrorMap: Lt,
127
- strictObject: Ft,
128
- string: Ut,
129
- symbol: zt,
130
- transformer: M,
131
- tuple: Jt,
132
- undefined: Wt,
133
- union: Bt,
134
- unknown: Yt,
116
+ oboolean: qt,
117
+ onumber: Pt,
118
+ optional: Lt,
119
+ ostring: Ft,
120
+ pipeline: zt,
121
+ preprocess: Ut,
122
+ promise: Jt,
123
+ quotelessJson: Wt,
124
+ record: Bt,
125
+ set: Yt,
126
+ setErrorMap: Gt,
127
+ strictObject: Xt,
128
+ string: Ht,
129
+ symbol: Qt,
130
+ transformer: P,
131
+ tuple: Kt,
132
+ undefined: ea,
133
+ union: ta,
134
+ unknown: aa,
135
135
  get util() {
136
- return Gt;
136
+ return sa;
137
137
  },
138
- void: Xt
138
+ void: na
139
139
  }, Symbol.toStringTag, { value: "Module" }));
140
- var fa = 1, ha = 4;
141
- function ga(e) {
142
- return Ht(e, fa | ha);
140
+ var _a = 1, Ta = 4;
141
+ function Na(e) {
142
+ return ra(e, _a | Ta);
143
143
  }
144
- function L(e, s, a) {
145
- return e == null ? e : Qt(e, s, a);
144
+ function J(e, s, a) {
145
+ return e == null ? e : la(e, s, a);
146
146
  }
147
- function F(e, s) {
148
- return e == null ? !0 : Kt(e, s);
147
+ function W(e, s) {
148
+ return e == null ? !0 : ia(e, s);
149
149
  }
150
- const Q = ma(
150
+ const ne = va(
151
151
  void 0
152
152
  );
153
- function ya(e, s) {
153
+ function Ma(e, s) {
154
154
  switch (s.type) {
155
155
  case "SET_PATH": {
156
- const a = ga(e.value);
156
+ const a = Na(e.value);
157
157
  if (s.value === null)
158
158
  if (/\.\d+$/.test(s.path)) {
159
- const n = s.path.replace(/\.\d+$/, ""), c = parseInt(s.path.match(/\d+$/)?.[0] ?? "0", 10), o = ea(a, n);
160
- Array.isArray(o) && (o.splice(c, 1), L(a, n, o), o.length === 0 && n.endsWith(".nested.conditions") && F(a, n.replace(/\.conditions$/, "")));
159
+ const n = s.path.replace(/\.\d+$/, ""), c = parseInt(s.path.match(/\d+$/)?.[0] ?? "0", 10), i = oa(a, n);
160
+ Array.isArray(i) && (i.splice(c, 1), J(a, n, i), i.length === 0 && n.endsWith(".nested.conditions") && W(a, n.replace(/\.conditions$/, "")));
161
161
  } else
162
- F(a, s.path);
162
+ W(a, s.path);
163
163
  else
164
- L(a, s.path, s.value);
164
+ J(a, s.path, s.value);
165
165
  return {
166
166
  ...e,
167
167
  value: a
@@ -173,7 +173,7 @@ function ya(e, s) {
173
173
  selectedRuleIndex: s.index
174
174
  };
175
175
  case "SET_VALUE":
176
- return k(e.value, s.value) ? e : (s.value.rules?.length ?? 0) === 0 ? {
176
+ return R(e.value, s.value) ? e : (s.value.rules?.length ?? 0) === 0 ? {
177
177
  selectedRuleIndex: 0,
178
178
  value: {
179
179
  rules: [
@@ -194,58 +194,58 @@ function ya(e, s) {
194
194
  return e;
195
195
  }
196
196
  }
197
- function ba({
197
+ function wa({
198
198
  children: e,
199
199
  initialValue: s
200
200
  }) {
201
- const [a, n] = ua(ya, {
201
+ const [a, n] = ya(Ma, {
202
202
  value: s.value,
203
203
  selectedRuleIndex: 0
204
- }), c = C((u, l) => {
205
- n({ type: "SET_PATH", path: u, value: l });
206
- }, []), o = C((u) => {
207
- n({ type: "SET_SELECTED_RULE_INDEX", index: u }), u < 0 && setTimeout(() => {
204
+ }), c = S((o, l) => {
205
+ n({ type: "SET_PATH", path: o, value: l });
206
+ }, []), i = S((o) => {
207
+ n({ type: "SET_SELECTED_RULE_INDEX", index: o }), o < 0 && setTimeout(() => {
208
208
  n({ type: "SET_SELECTED_RULE_INDEX", index: 0 });
209
209
  }, 50);
210
- }, []), i = C((u) => {
211
- n({ type: "SET_VALUE", value: u });
212
- }, []), r = da(
210
+ }, []), u = S((o) => {
211
+ n({ type: "SET_VALUE", value: o });
212
+ }, []), r = ba(
213
213
  () => ({
214
214
  state: a,
215
215
  setPath: c,
216
- setSelectedRuleIndex: o,
217
- setValue: i,
216
+ setSelectedRuleIndex: i,
217
+ setValue: u,
218
218
  availableActionTypes: s.availableActionTypes,
219
219
  schemaType: s.schemaType
220
220
  }),
221
221
  [
222
222
  a,
223
223
  c,
224
- o,
225
224
  i,
225
+ u,
226
226
  s.availableActionTypes,
227
227
  s.schemaType
228
228
  ]
229
229
  );
230
- return /* @__PURE__ */ t.jsx(Q.Provider, { value: r, children: e });
230
+ return /* @__PURE__ */ t.jsx(ne.Provider, { value: r, children: e });
231
231
  }
232
- function g() {
233
- const e = pa(Q);
232
+ function x() {
233
+ const e = ja(ne);
234
234
  if (e === void 0)
235
235
  throw new Error("useRuleEngine must be used within a RuleEngineProvider");
236
236
  return e;
237
237
  }
238
- function K({
238
+ function re({
239
239
  value: e,
240
240
  name: s,
241
241
  preset: a
242
242
  }) {
243
- const { setPath: n, schemaType: c } = g(), { t: o } = ta(), i = H(null), r = c === "order-rules" ? "order" : c === "price-rules" ? "price" : void 0, u = aa(
244
- (a === "condition" ? xa : a === "action" ? va : []).filter(
243
+ const { setPath: n, schemaType: c } = x(), { t: i } = ca(), u = se(null), r = c === "order-rules" ? "order" : c === "price-rules" ? "price" : void 0, o = Q(
244
+ (a === "condition" ? Sa : a === "action" ? Ca : []).filter(
245
245
  (l) => r != null && l.startsWith(r)
246
246
  ).map((l) => ({
247
247
  value: l,
248
- label: o(`resource_paths.${l}`).replace(
248
+ label: i(`resource_paths.${l}`).replace(
249
249
  "resource_paths.",
250
250
  ""
251
251
  )
@@ -255,36 +255,39 @@ function K({
255
255
  return /* @__PURE__ */ t.jsx(
256
256
  j,
257
257
  {
258
- ref: i,
258
+ ref: u,
259
259
  name: s,
260
- initialValues: u,
261
- defaultValue: e != null ? u.find((l) => l.value === e) ?? {
260
+ initialValues: o,
261
+ defaultValue: e != null ? o.find((l) => l.value === e) ?? {
262
262
  value: e,
263
263
  label: e
264
264
  } : void 0,
265
- asTextSearch: !0,
265
+ asTextSearch: a === "condition",
266
266
  isCreatable: !0,
267
267
  loadAsyncValues: async (l) => {
268
268
  if (r == null)
269
269
  return [];
270
- const d = u.filter(
271
- (m) => m.label.includes(l)
272
- ), p = (await sa([r], l)).filter((m) => m.value.startsWith(l)).map((m) => {
273
- const T = m.type === "relationship" || m.value.endsWith(".metadata") ? `${m.value}.` : m.value;
270
+ const d = o.filter(
271
+ (f) => f.label.includes(l)
272
+ ), h = a === "condition" ? (await ua(
273
+ [r],
274
+ l
275
+ )).filter((f) => f.value.startsWith(l)).map((f) => {
276
+ const T = f.type === "relationship" || f.value.endsWith(".metadata") ? `${f.value}.` : f.value;
274
277
  return {
275
278
  value: T,
276
279
  label: T
277
280
  };
278
- }), x = l.includes(".metadata") ? [{ label: l, value: l }] : [], h = [...d, ...p, ...x];
279
- return console.log("results", h), h;
281
+ }) : [], p = l.includes(".metadata") ? [{ label: l, value: l }] : [];
282
+ return [...d, ...h, ...p];
280
283
  },
281
284
  onSelect: async (l) => {
282
- E(l) && (n(s, l.value), l.value.toString().endsWith(".") && i.current?.openMenu("first"));
285
+ N(l) && (n(s, l.value), l.value.toString().endsWith(".") && u.current?.openMenu("first"));
283
286
  }
284
287
  }
285
288
  );
286
289
  }
287
- const xa = [
290
+ const Sa = [
288
291
  "order.billing_address.country_code",
289
292
  "order.country_code",
290
293
  "order.currency_code",
@@ -327,23 +330,23 @@ const xa = [
327
330
  "price.sku.tags.name",
328
331
  "price.processed_at",
329
332
  "price.amount_cents"
330
- ], va = [
333
+ ], Ca = [
334
+ "order",
335
+ "order.line_items",
331
336
  "order.line_items.line_item_options",
332
- "order.line_items.shipment",
333
- "order.line_items.sku_code",
334
- "order.line_items.sku.code",
335
337
  "order.line_items.sku",
336
- "order.line_items",
337
- "order.subtotal_amount_cents",
338
- "order.total_amount_cents",
339
- "order",
338
+ "order.line_items.bundle",
339
+ "order.line_items.shipment",
340
+ "order.line_items.payment_method",
341
+ "order.line_items.adjustment",
342
+ "order.line_items.gift_card",
340
343
  "price"
341
344
  ];
342
- function ja({
345
+ function Ea({
343
346
  item: e,
344
347
  pathPrefix: s
345
348
  }) {
346
- const { setPath: a } = g();
349
+ const { setPath: a } = x();
347
350
  if (e == null)
348
351
  return null;
349
352
  switch (e.type) {
@@ -452,10 +455,10 @@ function ja({
452
455
  ) });
453
456
  }
454
457
  default:
455
- return W();
458
+ return K();
456
459
  }
457
460
  }
458
- function _a({
461
+ function $a({
459
462
  item: e,
460
463
  index: s,
461
464
  onDelete: a
@@ -463,8 +466,8 @@ function _a({
463
466
  const {
464
467
  setPath: n,
465
468
  state: { selectedRuleIndex: c },
466
- availableActionTypes: o
467
- } = g(), i = {
469
+ availableActionTypes: i
470
+ } = x(), u = {
468
471
  percentage: "Percentage discount",
469
472
  fixed_amount: "Fixed amount",
470
473
  fixed_price: "Fixed price",
@@ -478,22 +481,22 @@ function _a({
478
481
  {
479
482
  name: `${r}.type`,
480
483
  defaultValue: e != null ? {
481
- label: i[e.type],
484
+ label: u[e.type],
482
485
  value: e.type
483
486
  } : void 0,
484
- initialValues: o.map((u) => ({
485
- value: u,
486
- label: i[u]
487
+ initialValues: i.map((o) => ({
488
+ value: o,
489
+ label: u[o]
487
490
  })),
488
- onSelect: (u) => {
489
- E(u) && n(`${r}.type`, u.value);
491
+ onSelect: (o) => {
492
+ N(o) && n(`${r}.type`, o.value);
490
493
  }
491
494
  }
492
495
  ) }),
493
- /* @__PURE__ */ t.jsx(ja, { item: e, pathPrefix: r }),
496
+ /* @__PURE__ */ t.jsx(Ea, { item: e, pathPrefix: r }),
494
497
  /* @__PURE__ */ t.jsx("div", { className: "text-black font-bold text-sm", children: "ON" }),
495
498
  /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
496
- K,
499
+ re,
497
500
  {
498
501
  preset: "action",
499
502
  value: e?.selector,
@@ -526,27 +529,27 @@ function _a({
526
529
  )
527
530
  ] }) });
528
531
  }
529
- function Ta({
532
+ function ka({
530
533
  actions: e
531
534
  }) {
532
- const [s, a] = f(0), {
535
+ const [s, a] = g(0), {
533
536
  setPath: n,
534
537
  state: { selectedRuleIndex: c }
535
- } = g();
538
+ } = x();
536
539
  return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
537
- /* @__PURE__ */ t.jsx("div", { children: e?.map((o, i, r) => /* @__PURE__ */ t.jsx(
538
- _a,
540
+ /* @__PURE__ */ t.jsx("div", { children: e?.map((i, u, r) => /* @__PURE__ */ t.jsx(
541
+ $a,
539
542
  {
540
- item: o,
541
- index: i,
543
+ item: i,
544
+ index: u,
542
545
  onDelete: r.length > 1 ? () => {
543
- a((u) => u + 1);
546
+ a((o) => o + 1);
544
547
  } : void 0
545
548
  },
546
- `${c}-${i}-${s}`
549
+ `${c}-${u}-${s}`
547
550
  )) }),
548
551
  /* @__PURE__ */ t.jsx("div", { className: "mt-6", children: /* @__PURE__ */ t.jsxs(
549
- N,
552
+ M,
550
553
  {
551
554
  size: "small",
552
555
  variant: "secondary",
@@ -565,61 +568,7 @@ function Ta({
565
568
  ) })
566
569
  ] });
567
570
  }
568
- function ee(e) {
569
- const [s, a] = f(void 0);
570
- return _(() => {
571
- e?.field != null && na(e.field).then((n) => {
572
- a(n);
573
- }).catch((n) => {
574
- console.error("Error fetching field info:", n);
575
- });
576
- }, [e?.field]), { infos: s };
577
- }
578
- function te(e) {
579
- if (typeof e == "string")
580
- return $(P(e)) ? "datetime" : "string";
581
- if (typeof e == "number")
582
- return "integer";
583
- if (typeof e == "boolean")
584
- return "boolean";
585
- if (Array.isArray(e)) {
586
- if (typeof e[0] == "string")
587
- return $(P(e[0])) ? "datetime" : "string";
588
- if (typeof e[0] == "number")
589
- return "integer";
590
- }
591
- return "string";
592
- }
593
- function Na({
594
- item: e,
595
- pathPrefix: s
596
- }) {
597
- const { setPath: a } = g(), { infos: n } = ee(e);
598
- let c = n?.field?.type;
599
- c == null && (c = te(e?.value));
600
- const o = n?.resource?.id, i = ["tag"], r = [
601
- "matches",
602
- "does_not_match",
603
- "array_match"
604
- ], u = wa.filter(({ fieldTypes: l, visible: d }) => d !== !1 && l.includes(c)).filter(({ matcher: l }) => o == null || o != null && !i.includes(o) || r.includes(l)).map(({ matcher: l, label: d }) => ({ value: l, label: d }));
605
- return /* @__PURE__ */ t.jsx(
606
- j,
607
- {
608
- name: `${s}.matcher`,
609
- value: e != null ? u.find((l) => l.value === e.matcher) ?? {
610
- label: e.matcher != null ? `⚠️   ${e.matcher}` : "",
611
- value: e.matcher
612
- } : void 0,
613
- initialValues: u,
614
- onSelect: (l) => {
615
- E(l) && (a(`${s}.matcher`, l.value), B.includes(
616
- l.value
617
- ) && a(`${s}.value`, null));
618
- }
619
- }
620
- );
621
- }
622
- const wa = [
571
+ const le = [
623
572
  {
624
573
  /** Matches if field value equals provided value
625
574
  * @field Integer, String, Datetime, Boolean
@@ -627,7 +576,9 @@ const wa = [
627
576
  */
628
577
  matcher: "eq",
629
578
  label: "equals",
630
- fieldTypes: ["integer", "string", "datetime", "boolean"]
579
+ fieldTypes: ["integer", "string", "datetime", "boolean"],
580
+ isMulti: !1,
581
+ exactMatch: !0
631
582
  },
632
583
  {
633
584
  /** Matches if field value is not equal to provided value
@@ -636,7 +587,9 @@ const wa = [
636
587
  */
637
588
  matcher: "not_eq",
638
589
  label: "not equals",
639
- fieldTypes: ["integer", "string", "datetime", "boolean"]
590
+ fieldTypes: ["integer", "string", "datetime", "boolean"],
591
+ isMulti: !1,
592
+ exactMatch: !0
640
593
  },
641
594
  {
642
595
  /** Matches if field value is less than provided value
@@ -645,7 +598,9 @@ const wa = [
645
598
  */
646
599
  matcher: "lt",
647
600
  label: "<",
648
- fieldTypes: ["integer", "datetime"]
601
+ fieldTypes: ["integer", "datetime"],
602
+ isMulti: !1,
603
+ exactMatch: !0
649
604
  },
650
605
  {
651
606
  /** Matches if field value is less than or equal to provided value
@@ -654,7 +609,9 @@ const wa = [
654
609
  */
655
610
  matcher: "lteq",
656
611
  label: "≤",
657
- fieldTypes: ["integer", "datetime"]
612
+ fieldTypes: ["integer", "datetime"],
613
+ isMulti: !1,
614
+ exactMatch: !0
658
615
  },
659
616
  {
660
617
  /** Matches if field value is greater than provided value
@@ -663,7 +620,9 @@ const wa = [
663
620
  */
664
621
  matcher: "gt",
665
622
  label: ">",
666
- fieldTypes: ["integer", "datetime"]
623
+ fieldTypes: ["integer", "datetime"],
624
+ isMulti: !1,
625
+ exactMatch: !0
667
626
  },
668
627
  {
669
628
  /** Matches if field value is greater than or equal to provided value
@@ -672,7 +631,9 @@ const wa = [
672
631
  */
673
632
  matcher: "gteq",
674
633
  label: "≥",
675
- fieldTypes: ["integer", "datetime"]
634
+ fieldTypes: ["integer", "datetime"],
635
+ isMulti: !1,
636
+ exactMatch: !0
676
637
  },
677
638
  {
678
639
  /** Matches if field value is a multiple of provided value
@@ -681,7 +642,9 @@ const wa = [
681
642
  */
682
643
  matcher: "multiple",
683
644
  label: "is a multiple of",
684
- fieldTypes: ["integer"]
645
+ fieldTypes: ["integer"],
646
+ isMulti: !1,
647
+ exactMatch: !0
685
648
  },
686
649
  {
687
650
  /** Matches if field value matches regex pattern
@@ -690,7 +653,9 @@ const wa = [
690
653
  */
691
654
  matcher: "matches",
692
655
  label: "matches regex",
693
- fieldTypes: ["string"]
656
+ fieldTypes: ["string"],
657
+ isMulti: !1,
658
+ exactMatch: !1
694
659
  },
695
660
  {
696
661
  /** Matches if field value does not match regex pattern
@@ -699,7 +664,9 @@ const wa = [
699
664
  */
700
665
  matcher: "does_not_match",
701
666
  label: "doesn't match regex",
702
- fieldTypes: ["string"]
667
+ fieldTypes: ["string"],
668
+ isMulti: !1,
669
+ exactMatch: !1
703
670
  },
704
671
  {
705
672
  /** Matches if field value starts with provided string
@@ -708,7 +675,9 @@ const wa = [
708
675
  */
709
676
  matcher: "start_with",
710
677
  label: "starts with",
711
- fieldTypes: ["string"]
678
+ fieldTypes: ["string"],
679
+ isMulti: !1,
680
+ exactMatch: !1
712
681
  },
713
682
  {
714
683
  /** Matches if field value does not start with provided string
@@ -717,7 +686,9 @@ const wa = [
717
686
  */
718
687
  matcher: "not_start_with",
719
688
  label: "doesn't start with",
720
- fieldTypes: ["string"]
689
+ fieldTypes: ["string"],
690
+ isMulti: !1,
691
+ exactMatch: !1
721
692
  },
722
693
  {
723
694
  /** Matches if field value ends with provided string
@@ -726,7 +697,9 @@ const wa = [
726
697
  */
727
698
  matcher: "end_with",
728
699
  label: "ends with",
729
- fieldTypes: ["string"]
700
+ fieldTypes: ["string"],
701
+ isMulti: !1,
702
+ exactMatch: !1
730
703
  },
731
704
  {
732
705
  /** Matches if field value does not end with provided string
@@ -735,7 +708,9 @@ const wa = [
735
708
  */
736
709
  matcher: "not_end_with",
737
710
  label: "doesn't end with",
738
- fieldTypes: ["string"]
711
+ fieldTypes: ["string"],
712
+ isMulti: !1,
713
+ exactMatch: !1
739
714
  },
740
715
  {
741
716
  /** Matches if field value is between two values (exclusive)
@@ -744,7 +719,9 @@ const wa = [
744
719
  */
745
720
  matcher: "gt_lt",
746
721
  label: "> and <",
747
- fieldTypes: ["integer"]
722
+ fieldTypes: ["integer"],
723
+ isMulti: !1,
724
+ exactMatch: !0
748
725
  },
749
726
  {
750
727
  /** Matches if field value is between two values (inclusive start, exclusive end)
@@ -753,7 +730,9 @@ const wa = [
753
730
  */
754
731
  matcher: "gteq_lt",
755
732
  label: "≥ and <",
756
- fieldTypes: ["integer"]
733
+ fieldTypes: ["integer"],
734
+ isMulti: !1,
735
+ exactMatch: !0
757
736
  },
758
737
  {
759
738
  /** Matches if field value is greater than first and less than or equal to second
@@ -762,7 +741,9 @@ const wa = [
762
741
  */
763
742
  matcher: "gt_lteq",
764
743
  label: "> and ≤",
765
- fieldTypes: ["integer"]
744
+ fieldTypes: ["integer"],
745
+ isMulti: !1,
746
+ exactMatch: !0
766
747
  },
767
748
  {
768
749
  /** Matches if field value is between two values (inclusive)
@@ -771,7 +752,9 @@ const wa = [
771
752
  */
772
753
  matcher: "gteq_lteq",
773
754
  label: "≥ and ≤",
774
- fieldTypes: ["integer"]
755
+ fieldTypes: ["integer"],
756
+ isMulti: !1,
757
+ exactMatch: !0
775
758
  },
776
759
  {
777
760
  /** Matches if field value is between two values (exclusive)
@@ -781,7 +764,9 @@ const wa = [
781
764
  matcher: "gt_lt",
782
765
  label: "date range",
783
766
  visible: !1,
784
- fieldTypes: ["datetime"]
767
+ fieldTypes: ["datetime"],
768
+ isMulti: !1,
769
+ exactMatch: !0
785
770
  },
786
771
  {
787
772
  /** Matches if field value is between two values (inclusive start, exclusive end)
@@ -791,7 +776,9 @@ const wa = [
791
776
  matcher: "gteq_lt",
792
777
  label: "date range",
793
778
  visible: !1,
794
- fieldTypes: ["datetime"]
779
+ fieldTypes: ["datetime"],
780
+ isMulti: !1,
781
+ exactMatch: !0
795
782
  },
796
783
  {
797
784
  /** Matches if field value is greater than first and less than or equal to second
@@ -801,7 +788,9 @@ const wa = [
801
788
  matcher: "gt_lteq",
802
789
  label: "date range",
803
790
  visible: !1,
804
- fieldTypes: ["datetime"]
791
+ fieldTypes: ["datetime"],
792
+ isMulti: !1,
793
+ exactMatch: !0
805
794
  },
806
795
  {
807
796
  /** Matches if field value is between two values (inclusive)
@@ -811,7 +800,9 @@ const wa = [
811
800
  matcher: "gteq_lteq",
812
801
  label: "date range",
813
802
  visible: !0,
814
- fieldTypes: ["datetime"]
803
+ fieldTypes: ["datetime"],
804
+ isMulti: !1,
805
+ exactMatch: !0
815
806
  },
816
807
  {
817
808
  /** Matches if field value is in provided array
@@ -820,7 +811,9 @@ const wa = [
820
811
  */
821
812
  matcher: "is_in",
822
813
  label: "is one of",
823
- fieldTypes: ["integer", "string", "datetime"]
814
+ fieldTypes: ["integer", "string", "datetime"],
815
+ isMulti: !0,
816
+ exactMatch: !0
824
817
  },
825
818
  {
826
819
  /** Matches if field value is not in provided array
@@ -829,7 +822,9 @@ const wa = [
829
822
  */
830
823
  matcher: "is_not_in",
831
824
  label: "is not one of",
832
- fieldTypes: ["integer", "string", "datetime"]
825
+ fieldTypes: ["integer", "string", "datetime"],
826
+ isMulti: !0,
827
+ exactMatch: !0
833
828
  },
834
829
  {
835
830
  /** Matches objects within arrays that meet specified requirements
@@ -838,33 +833,179 @@ const wa = [
838
833
  */
839
834
  matcher: "array_match",
840
835
  label: "is",
841
- fieldTypes: ["integer", "string", "datetime"]
836
+ fieldTypes: ["integer", "string", "datetime"],
837
+ isMulti: !0,
838
+ exactMatch: !0
842
839
  },
843
840
  {
844
841
  /** Matches if field value is null or empty string */
845
842
  matcher: "blank",
846
843
  label: "is blank",
847
- fieldTypes: ["integer", "string", "datetime", "boolean"]
844
+ fieldTypes: ["integer", "string", "datetime", "boolean"],
845
+ isMulti: !1,
846
+ exactMatch: !0
848
847
  },
849
848
  {
850
849
  /** Matches if field value is null */
851
850
  matcher: "null",
852
851
  label: "is null",
853
- fieldTypes: ["integer", "string", "datetime", "boolean"]
852
+ fieldTypes: ["integer", "string", "datetime", "boolean"],
853
+ isMulti: !1,
854
+ exactMatch: !0
854
855
  },
855
856
  {
856
857
  /** Matches if field value is not null */
857
858
  matcher: "not_null",
858
859
  label: "is not null",
859
- fieldTypes: ["integer", "string", "datetime", "boolean"]
860
+ fieldTypes: ["integer", "string", "datetime", "boolean"],
861
+ isMulti: !1,
862
+ exactMatch: !0
860
863
  },
861
864
  {
862
865
  /** Matches if field value is not null */
863
866
  matcher: "present",
864
867
  label: "is present",
865
- fieldTypes: ["integer", "string", "datetime", "boolean"]
868
+ fieldTypes: ["integer", "string", "datetime", "boolean"],
869
+ isMulti: !1,
870
+ exactMatch: !0
871
+ }
872
+ ];
873
+ function ie(e) {
874
+ if (typeof e == "string")
875
+ return C(U(e)) ? "datetime" : "string";
876
+ if (typeof e == "number")
877
+ return "integer";
878
+ if (typeof e == "boolean")
879
+ return "boolean";
880
+ if (Array.isArray(e)) {
881
+ if (typeof e[0] == "string")
882
+ return C(U(e[0])) ? "datetime" : "string";
883
+ if (typeof e[0] == "number")
884
+ return "integer";
866
885
  }
867
- ], U = {
886
+ return "string";
887
+ }
888
+ const oe = {
889
+ market: "markets",
890
+ tag: "tags",
891
+ sku: "skus",
892
+ sku_list: "sku_lists"
893
+ };
894
+ function Ra(e) {
895
+ return oe[e];
896
+ }
897
+ function Z(e) {
898
+ const [s, a] = g(void 0);
899
+ return _(() => {
900
+ e?.field != null && da(e.field).then((n) => {
901
+ const c = le.find(
902
+ (i) => i.matcher === e.matcher
903
+ );
904
+ a({
905
+ ...n,
906
+ matcherInfos: c,
907
+ resourceSelectorAvailable: n?.resource?.id != null && Object.keys(oe).includes(n.resource.id) && n.path.endsWith(".id") && c?.exactMatch === !0
908
+ });
909
+ }).catch((n) => {
910
+ console.error("Error fetching field info:", n);
911
+ });
912
+ }, [e?.field, e?.matcher]), { infos: s };
913
+ }
914
+ function Va({
915
+ item: e,
916
+ pathPrefix: s
917
+ }) {
918
+ const { setPath: a } = x(), { infos: n } = Z(e);
919
+ let c = n?.field?.type;
920
+ c == null && (c = ie(e?.value));
921
+ const i = n?.resource?.id, u = ["tag"], r = [
922
+ "matches",
923
+ "does_not_match",
924
+ "array_match"
925
+ ], o = le.filter(({ fieldTypes: l, visible: d }) => d !== !1 && l.includes(c)).filter(({ matcher: l }) => i == null || i != null && !u.includes(i) || r.includes(l)).map(({ matcher: l, label: d }) => ({ value: l, label: d }));
926
+ return /* @__PURE__ */ t.jsx(
927
+ j,
928
+ {
929
+ name: `${s}.matcher`,
930
+ value: e != null ? o.find((l) => l.value === e.matcher) ?? {
931
+ label: e.matcher != null ? `⚠️   ${e.matcher}` : "",
932
+ value: e.matcher
933
+ } : void 0,
934
+ initialValues: o,
935
+ onSelect: (l) => {
936
+ N(l) && (a(`${s}.matcher`, l.value), ee.includes(
937
+ l.value
938
+ ) && a(`${s}.value`, null));
939
+ }
940
+ }
941
+ );
942
+ }
943
+ const ce = ({ value: e, pathKey: s, infos: a }) => {
944
+ const { sdkClient: n } = ma(), { setPath: c } = x(), i = a?.field?.name ?? "id", u = Ra(a?.resource?.id), { data: r, isLoading: o } = L(
945
+ u,
946
+ "list",
947
+ a?.resource?.id == null ? null : [k({ value: "" })]
948
+ ), { data: l, isLoading: d } = L(
949
+ u,
950
+ "list",
951
+ a?.resource?.id == null ? null : [
952
+ {
953
+ ...k({ value: "" }),
954
+ filters: {
955
+ id_in: Array.isArray(e) ? e : [e]
956
+ }
957
+ }
958
+ ]
959
+ ), h = Q([...l ?? [], ...r ?? []], "id");
960
+ u === "sku_lists" && (console.log("data", r), console.log("selectedData", l), console.log("initialValues", h));
961
+ function p(m) {
962
+ return {
963
+ label: h?.find((f) => f.id === m.toString())?.name ?? m.toString(),
964
+ value: m.toString()
965
+ };
966
+ }
967
+ return /* @__PURE__ */ t.jsx(
968
+ j,
969
+ {
970
+ placeholder: "Search...",
971
+ isClearable: !1,
972
+ isMulti: a?.matcherInfos?.isMulti,
973
+ defaultValue: Array.isArray(e) ? e.map(p) : e != null ? p(e) : void 0,
974
+ menuFooterText: r != null && r.meta.recordCount > 25 ? "Type to search for more options." : void 0,
975
+ initialValues: B(h ?? [], i),
976
+ loadAsyncValues: async (m) => {
977
+ const f = await n[u].list(k({ value: m }));
978
+ return B(f, i);
979
+ },
980
+ onSelect: (m) => {
981
+ I(m) ? c(
982
+ s,
983
+ m.map((f) => f.value).filter((f) => f != null)
984
+ ) : N(m) && c(s, m.value);
985
+ }
986
+ },
987
+ `${a?.matcherInfos?.isMulti?.toString()}-${o}-${d}`
988
+ );
989
+ };
990
+ function k({ value: e }) {
991
+ return {
992
+ pageSize: 25,
993
+ sort: {
994
+ name: "asc"
995
+ },
996
+ filters: {
997
+ name_cont: e
998
+ }
999
+ };
1000
+ }
1001
+ function B(e, s) {
1002
+ return e.map((a) => ({
1003
+ label: a.name,
1004
+ // @ts-expect-error TODO: fix this
1005
+ value: a[s]
1006
+ }));
1007
+ }
1008
+ const Y = {
868
1009
  in_and: {
869
1010
  label: "all of"
870
1011
  },
@@ -878,63 +1019,76 @@ const wa = [
878
1019
  label: "not at least one of"
879
1020
  }
880
1021
  };
881
- function Ea({
1022
+ function G({
882
1023
  value: e,
883
- pathPrefix: s
1024
+ pathPrefix: s,
1025
+ hasResourceSelector: a = !1,
1026
+ infos: n
884
1027
  }) {
885
1028
  return (typeof e != "object" || Array.isArray(e) || e === null) && (e = {
886
1029
  in_and: []
887
- }), /* @__PURE__ */ t.jsx("div", { children: Object.entries(e).map(([a, n], c) => /* @__PURE__ */ t.jsx(
888
- Ca,
1030
+ }), /* @__PURE__ */ t.jsx("div", { children: Object.entries(e).map(([c, i], u) => /* @__PURE__ */ t.jsx(
1031
+ Aa,
889
1032
  {
1033
+ infos: n,
1034
+ hasResourceSelector: a,
890
1035
  pathPrefix: s,
891
- defaultValue: n,
892
- initialMatcher: a
1036
+ defaultValue: i,
1037
+ initialMatcher: c
893
1038
  },
894
1039
  `${s}.${// biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
895
- c}`
1040
+ u}`
896
1041
  )) });
897
1042
  }
898
- function Ca({
1043
+ function Aa({
899
1044
  initialMatcher: e,
900
1045
  defaultValue: s,
901
- pathPrefix: a
1046
+ pathPrefix: a,
1047
+ hasResourceSelector: n,
1048
+ infos: c
902
1049
  }) {
903
- const [n, c] = f(e), [o, i] = f(e), [r, u] = f(s), { setPath: l } = g();
1050
+ const [i, u] = g(e), [r, o] = g(e), [l, d] = g(s), { setPath: h } = x();
904
1051
  return _(() => {
905
- n !== o && (l(`${a}.${n}`, null), c(o)), l(`${a}.${o}`, r);
906
- }, [o, r, l]), /* @__PURE__ */ t.jsxs("div", { className: "flex gap-2 last-of-type:mt-2", children: [
1052
+ i !== r && (h(`${a}.${i}`, null), u(r)), h(`${a}.${r}`, l);
1053
+ }, [r, l, h]), /* @__PURE__ */ t.jsxs("div", { className: "flex gap-2 mt-2 first-of-type:mt-0", children: [
907
1054
  /* @__PURE__ */ t.jsx("div", { className: "shrink-0", children: /* @__PURE__ */ t.jsx(
908
1055
  j,
909
1056
  {
910
1057
  defaultValue: [
911
- { value: o, label: U[o].label }
1058
+ { value: r, label: Y[r].label }
912
1059
  ],
913
- initialValues: Object.entries(U).map(
914
- ([d, { label: p }]) => ({
915
- value: d,
916
- label: p
1060
+ initialValues: Object.entries(Y).map(
1061
+ ([p, { label: m }]) => ({
1062
+ value: p,
1063
+ label: m
917
1064
  })
918
1065
  ),
919
- onSelect: (d) => {
920
- E(d) && i(d.value);
1066
+ onSelect: (p) => {
1067
+ N(p) && o(p.value);
921
1068
  }
922
1069
  }
923
1070
  ) }),
924
- /* @__PURE__ */ t.jsx("div", { className: "grow", children: /* @__PURE__ */ t.jsx(
1071
+ /* @__PURE__ */ t.jsx("div", { className: "grow", children: n ? /* @__PURE__ */ t.jsx(
1072
+ ce,
1073
+ {
1074
+ infos: c,
1075
+ value: l,
1076
+ pathKey: `${a}.${r}`
1077
+ }
1078
+ ) : /* @__PURE__ */ t.jsx(
925
1079
  j,
926
1080
  {
927
1081
  isMulti: !0,
928
1082
  isCreatable: !0,
929
- defaultValue: (Array.isArray(r) ? r : []).map((d) => ({
930
- value: d,
931
- label: d.toString()
1083
+ defaultValue: (Array.isArray(l) ? l : []).map((p) => ({
1084
+ value: p,
1085
+ label: p.toString()
932
1086
  })),
933
1087
  initialValues: [],
934
- onSelect: (d) => {
935
- Y(d) && u(
936
- d.map(
937
- (p) => typeof p.value == "boolean" ? p.value.toString() : p.value
1088
+ onSelect: (p) => {
1089
+ I(p) && d(
1090
+ p.map(
1091
+ (m) => typeof m.value == "boolean" ? m.value.toString() : m.value
938
1092
  )
939
1093
  );
940
1094
  }
@@ -942,13 +1096,13 @@ function Ca({
942
1096
  ) })
943
1097
  ] });
944
1098
  }
945
- function $a({
1099
+ function Ia({
946
1100
  value: e,
947
1101
  onChange: s
948
1102
  }) {
949
- const [a, n] = f(
1103
+ const [a, n] = g(
950
1104
  Array.isArray(e) && typeof e[0] == "number" ? e[0] : null
951
- ), [c, o] = f(
1105
+ ), [c, i] = g(
952
1106
  Array.isArray(e) && typeof e[1] == "number" ? e[1] : null
953
1107
  );
954
1108
  return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
@@ -958,8 +1112,8 @@ function $a({
958
1112
  type: "number",
959
1113
  placeholder: "Min",
960
1114
  value: a ?? "",
961
- onChange: (i) => {
962
- const r = parseInt(i.currentTarget.value, 10);
1115
+ onChange: (u) => {
1116
+ const r = parseInt(u.currentTarget.value, 10);
963
1117
  n(Number.isNaN(r) ? null : r), s([Number.isNaN(r) ? null : r, c]);
964
1118
  }
965
1119
  }
@@ -971,21 +1125,21 @@ function $a({
971
1125
  type: "number",
972
1126
  placeholder: "Max",
973
1127
  value: c ?? "",
974
- onChange: (i) => {
975
- const r = parseInt(i.currentTarget.value, 10);
976
- o(Number.isNaN(r) ? null : r), s([a, Number.isNaN(r) ? null : r]);
1128
+ onChange: (u) => {
1129
+ const r = parseInt(u.currentTarget.value, 10);
1130
+ i(Number.isNaN(r) ? null : r), s([a, Number.isNaN(r) ? null : r]);
977
1131
  }
978
1132
  }
979
1133
  ) })
980
1134
  ] });
981
1135
  }
982
- function Sa({
1136
+ function Za({
983
1137
  value: e,
984
1138
  onChange: s
985
1139
  }) {
986
- const [a, n] = f(
1140
+ const [a, n] = g(
987
1141
  Array.isArray(e) && typeof e[0] == "string" ? e[0] : null
988
- ), [c, o] = f(
1142
+ ), [c, i] = g(
989
1143
  Array.isArray(e) && typeof e[1] == "string" ? e[1] : null
990
1144
  );
991
1145
  return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
@@ -995,8 +1149,8 @@ function Sa({
995
1149
  type: "text",
996
1150
  placeholder: "Min",
997
1151
  value: a ?? "",
998
- onChange: (i) => {
999
- const r = i.currentTarget.value;
1152
+ onChange: (u) => {
1153
+ const r = u.currentTarget.value;
1000
1154
  n(r), s([r, c]);
1001
1155
  }
1002
1156
  }
@@ -1008,76 +1162,76 @@ function Sa({
1008
1162
  type: "text",
1009
1163
  placeholder: "Max",
1010
1164
  value: c ?? "",
1011
- onChange: (i) => {
1012
- const r = i.currentTarget.value;
1013
- o(r), s([a, r]);
1165
+ onChange: (u) => {
1166
+ const r = u.currentTarget.value;
1167
+ i(r), s([a, r]);
1014
1168
  }
1015
1169
  }
1016
1170
  ) })
1017
1171
  ] });
1018
1172
  }
1019
- function Ra({
1173
+ function Da({
1020
1174
  item: e,
1021
1175
  pathPrefix: s
1022
1176
  }) {
1023
- const { setPath: a } = g(), { infos: n } = ee(e), c = `${s}.value`, [o, i] = f(0), [r, u] = f(e?.matcher), l = e == null || B.includes(
1177
+ const { setPath: a } = x(), { infos: n } = Z(e), c = `${s}.value`, [i, u] = g(0), [r, o] = g(e?.matcher), l = e == null || ee.includes(
1024
1178
  e.matcher
1025
1179
  );
1026
1180
  let d = n?.field?.type;
1027
- ae(e) && (d == null && (d = te(e.value)), (typeof e.value == "string" && /^{{.*}}$/.test(e.value) || Array.isArray(e.value) && e.value.some((x) => typeof x == "string" && /^{{.*}}$/.test(x))) && (d = "string"));
1028
- const p = Va(d, e?.matcher);
1181
+ ue(e) && (d == null && (d = ie(e.value)), (typeof e.value == "string" && /^{{.*}}$/.test(e.value) || Array.isArray(e.value) && e.value.some((p) => typeof p == "string" && /^{{.*}}$/.test(p))) && (d = "string"));
1182
+ const h = qa(d, e?.matcher, n);
1029
1183
  return _(
1030
1184
  function() {
1031
- r !== e?.matcher && (u(e?.matcher), a(c, null), i((h) => h + 1));
1185
+ r !== e?.matcher && (o(e?.matcher), a(c, null), u((m) => m + 1));
1032
1186
  },
1033
- [p]
1187
+ [h]
1034
1188
  ), l ? null : /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsx(
1035
- ka,
1189
+ Oa,
1036
1190
  {
1037
1191
  item: e,
1038
1192
  fieldType: d,
1039
- componentType: p,
1193
+ componentType: h,
1040
1194
  pathKey: c
1041
1195
  }
1042
- ) }, o);
1196
+ ) }, i);
1043
1197
  }
1044
- function ka({
1198
+ function Oa({
1045
1199
  item: e,
1046
1200
  fieldType: s,
1047
1201
  componentType: a,
1048
1202
  pathKey: n
1049
1203
  }) {
1050
- const { setPath: c } = g(), { user: o } = G(), i = ae(e) ? e.value : void 0;
1204
+ const { setPath: c } = x(), { user: i } = te(), { infos: u } = Z(e), r = ue(e) ? e.value : void 0;
1051
1205
  switch (a) {
1052
1206
  case "date": {
1053
- const r = q(typeof i == "string" ? i : "");
1207
+ const o = z(typeof r == "string" ? r : "");
1054
1208
  return /* @__PURE__ */ t.jsx(
1055
- la,
1209
+ pa,
1056
1210
  {
1057
- value: $(r) ? r : void 0,
1211
+ value: C(o) ? o : void 0,
1058
1212
  showTimeSelect: !0,
1059
1213
  placeholder: "Enter value",
1060
- onChange: (u) => {
1061
- c(n, u?.toJSON());
1214
+ onChange: (l) => {
1215
+ c(n, l?.toJSON());
1062
1216
  },
1063
- timezone: o?.timezone
1217
+ timezone: i?.timezone
1064
1218
  }
1065
1219
  );
1066
1220
  }
1067
1221
  case "dateRange": {
1068
- const r = Array.isArray(i) ? i.map((u) => {
1069
- const l = q(typeof u == "string" ? u : "");
1070
- return $(l) ? l : null;
1222
+ const o = Array.isArray(r) ? r.map((l) => {
1223
+ const d = z(typeof l == "string" ? l : "");
1224
+ return C(d) ? d : null;
1071
1225
  }) : [null, null];
1072
1226
  return /* @__PURE__ */ t.jsx(
1073
- ra,
1227
+ fa,
1074
1228
  {
1075
- value: r,
1229
+ value: o,
1076
1230
  showTimeSelect: !0,
1077
- onChange: (u) => {
1231
+ onChange: (l) => {
1078
1232
  c(
1079
1233
  n,
1080
- u.map((l) => l?.toJSON() ?? null)
1234
+ l.map((d) => d?.toJSON() ?? null)
1081
1235
  );
1082
1236
  }
1083
1237
  }
@@ -1085,26 +1239,26 @@ function ka({
1085
1239
  }
1086
1240
  case "numberRange":
1087
1241
  return /* @__PURE__ */ t.jsx(
1088
- $a,
1242
+ Ia,
1089
1243
  {
1090
- value: i,
1091
- onChange: (r) => {
1092
- c(n, r);
1244
+ value: r,
1245
+ onChange: (o) => {
1246
+ c(n, o);
1093
1247
  }
1094
1248
  }
1095
1249
  );
1096
1250
  case "textRange":
1097
1251
  return /* @__PURE__ */ t.jsx(
1098
- Sa,
1252
+ Za,
1099
1253
  {
1100
- value: i,
1101
- onChange: (r) => {
1102
- c(n, r);
1254
+ value: r,
1255
+ onChange: (o) => {
1256
+ c(n, o);
1103
1257
  }
1104
1258
  }
1105
1259
  );
1106
1260
  case "arrayMatch":
1107
- return /* @__PURE__ */ t.jsx(Ea, { value: i, pathPrefix: n });
1261
+ return /* @__PURE__ */ t.jsx(G, { infos: u, value: r, pathPrefix: n });
1108
1262
  case "tag":
1109
1263
  return /* @__PURE__ */ t.jsx(
1110
1264
  j,
@@ -1112,35 +1266,45 @@ function ka({
1112
1266
  isMulti: !0,
1113
1267
  isClearable: !1,
1114
1268
  isCreatable: !0,
1115
- defaultValue: Array.isArray(i) ? i.map((r) => ({
1116
- label: r.toString(),
1117
- value: r
1269
+ defaultValue: Array.isArray(r) ? r.map((o) => ({
1270
+ label: o.toString(),
1271
+ value: o
1118
1272
  })) : [],
1119
1273
  initialValues: [],
1120
- onSelect: (r) => {
1121
- Y(r) && c(
1274
+ onSelect: (o) => {
1275
+ I(o) && c(
1122
1276
  n,
1123
- r.map((u) => {
1277
+ o.map((l) => {
1124
1278
  if (s === "integer") {
1125
- const l = parseInt(u.value.toString(), 10);
1126
- return Number.isNaN(l) ? null : l;
1279
+ const d = parseInt(l.value.toString(), 10);
1280
+ return Number.isNaN(d) ? null : d;
1127
1281
  }
1128
- return u.value;
1129
- }).filter((u) => u != null)
1282
+ return l.value;
1283
+ }).filter((l) => l != null)
1130
1284
  );
1131
1285
  }
1132
1286
  }
1133
1287
  );
1288
+ case "resourceSelector":
1289
+ return e?.matcher === "array_match" ? /* @__PURE__ */ t.jsx(
1290
+ G,
1291
+ {
1292
+ infos: u,
1293
+ value: r,
1294
+ pathPrefix: n,
1295
+ hasResourceSelector: !0
1296
+ }
1297
+ ) : /* @__PURE__ */ t.jsx(ce, { infos: u, value: r, pathKey: n });
1134
1298
  case "number":
1135
1299
  return /* @__PURE__ */ t.jsx(
1136
1300
  b,
1137
1301
  {
1138
1302
  name: n,
1139
1303
  type: "number",
1140
- defaultValue: typeof i == "number" ? i : "",
1304
+ defaultValue: typeof r == "number" ? r : "",
1141
1305
  placeholder: "Enter value",
1142
- onChange: (r) => {
1143
- c(n, parseInt(r.currentTarget.value, 10));
1306
+ onChange: (o) => {
1307
+ c(n, parseInt(o.currentTarget.value, 10));
1144
1308
  }
1145
1309
  }
1146
1310
  );
@@ -1149,16 +1313,16 @@ function ka({
1149
1313
  j,
1150
1314
  {
1151
1315
  name: n,
1152
- defaultValue: typeof i == "boolean" ? {
1153
- label: i ? "Yes" : "No",
1154
- value: i
1316
+ defaultValue: typeof r == "boolean" ? {
1317
+ label: r ? "Yes" : "No",
1318
+ value: r
1155
1319
  } : void 0,
1156
1320
  initialValues: [
1157
1321
  { label: "Yes", value: !0 },
1158
1322
  { label: "No", value: !1 }
1159
1323
  ],
1160
- onSelect: (r) => {
1161
- E(r) && c(n, r.value);
1324
+ onSelect: (o) => {
1325
+ N(o) && c(n, o.value);
1162
1326
  }
1163
1327
  }
1164
1328
  );
@@ -1169,38 +1333,38 @@ function ka({
1169
1333
  {
1170
1334
  name: n,
1171
1335
  type: "text",
1172
- defaultValue: typeof i == "string" ? i : JSON.stringify(i),
1336
+ defaultValue: typeof r == "string" ? r : JSON.stringify(r),
1173
1337
  placeholder: "Enter value",
1174
- onChange: (r) => {
1175
- c(n, r.currentTarget.value);
1338
+ onChange: (o) => {
1339
+ c(n, o.currentTarget.value);
1176
1340
  }
1177
1341
  }
1178
1342
  );
1179
1343
  default:
1180
- return W();
1344
+ return K();
1181
1345
  }
1182
1346
  }
1183
- function ae(e) {
1347
+ function ue(e) {
1184
1348
  return e != null && "value" in e;
1185
1349
  }
1186
- function Va(e, s) {
1187
- let a = null;
1350
+ function qa(e, s, a) {
1351
+ let n = null;
1188
1352
  switch (e) {
1189
1353
  case "datetime": {
1190
- a = "date";
1354
+ n = "date";
1191
1355
  break;
1192
1356
  }
1193
1357
  case "boolean": {
1194
- a = "boolean";
1358
+ n = "boolean";
1195
1359
  break;
1196
1360
  }
1197
1361
  case "string": {
1198
- a = "text";
1362
+ n = "text";
1199
1363
  break;
1200
1364
  }
1201
1365
  case "integer":
1202
1366
  case "float": {
1203
- a = "number";
1367
+ n = "number";
1204
1368
  break;
1205
1369
  }
1206
1370
  case "array":
@@ -1208,7 +1372,7 @@ function Va(e, s) {
1208
1372
  case "object":
1209
1373
  break;
1210
1374
  default: {
1211
- a = "text";
1375
+ n = "text";
1212
1376
  break;
1213
1377
  }
1214
1378
  }
@@ -1232,29 +1396,29 @@ function Va(e, s) {
1232
1396
  case "gteq_lt":
1233
1397
  case "gt_lteq":
1234
1398
  case "gteq_lteq": {
1235
- a === "number" && (a = "numberRange"), a === "text" && (a = "textRange"), a === "date" && (a = "dateRange");
1399
+ n === "number" && (n = "numberRange"), n === "text" && (n = "textRange"), n === "date" && (n = "dateRange");
1236
1400
  break;
1237
1401
  }
1238
1402
  case "is_in":
1239
1403
  case "is_not_in": {
1240
- a = "tag";
1404
+ n = "tag";
1241
1405
  break;
1242
1406
  }
1243
1407
  case "array_match": {
1244
- a = "arrayMatch";
1408
+ n = "arrayMatch";
1245
1409
  break;
1246
1410
  }
1247
1411
  }
1248
- return a;
1412
+ return a?.resourceSelectorAvailable && (n = "resourceSelector"), n;
1249
1413
  }
1250
- function Aa({
1414
+ function Pa({
1251
1415
  item: e,
1252
1416
  nestingLevel: s,
1253
1417
  pathPrefix: a,
1254
1418
  onDelete: n
1255
1419
  }) {
1256
- const { setPath: c } = g(), o = [];
1257
- return s < 2 && (o[0] ??= [], o[0].push(
1420
+ const { setPath: c } = x(), i = [];
1421
+ return s < 2 && (i[0] ??= [], i[0].push(
1258
1422
  /* @__PURE__ */ t.jsx(
1259
1423
  w,
1260
1424
  {
@@ -1267,7 +1431,7 @@ function Aa({
1267
1431
  }
1268
1432
  }
1269
1433
  )
1270
- )), n != null && (o[1] ??= [], o[1].push(
1434
+ )), n != null && (i[1] ??= [], i[1].push(
1271
1435
  /* @__PURE__ */ t.jsx(
1272
1436
  w,
1273
1437
  {
@@ -1281,18 +1445,18 @@ function Aa({
1281
1445
  /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-between gap-2 grow p-2", children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-2 grow", children: [
1282
1446
  /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1283
1447
  /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
1284
- K,
1448
+ re,
1285
1449
  {
1286
1450
  preset: "condition",
1287
1451
  value: e?.field,
1288
1452
  name: `${a}.field`
1289
1453
  }
1290
1454
  ) }),
1291
- /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsx(Na, { item: e, pathPrefix: a }) })
1455
+ /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsx(Va, { item: e, pathPrefix: a }) })
1292
1456
  ] }),
1293
- /* @__PURE__ */ t.jsx(Ra, { item: e, pathPrefix: a })
1457
+ /* @__PURE__ */ t.jsx(Da, { item: e, pathPrefix: a })
1294
1458
  ] }) }),
1295
- o.length > 0 && /* @__PURE__ */ t.jsx(
1459
+ i.length > 0 && /* @__PURE__ */ t.jsx(
1296
1460
  A,
1297
1461
  {
1298
1462
  className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
@@ -1304,21 +1468,21 @@ function Aa({
1304
1468
  children: /* @__PURE__ */ t.jsx(v, { name: "dotsThreeVertical", size: 16, weight: "bold" })
1305
1469
  }
1306
1470
  ),
1307
- dropdownItems: o.map((i, r, u) => (
1471
+ dropdownItems: i.map((u, r, o) => (
1308
1472
  // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
1309
- /* @__PURE__ */ t.jsxs(O.Fragment, { children: [
1310
- i.map((l, d) => (
1473
+ /* @__PURE__ */ t.jsxs(F.Fragment, { children: [
1474
+ u.map((l, d) => (
1311
1475
  // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
1312
- /* @__PURE__ */ t.jsx(O.Fragment, { children: l }, d)
1476
+ /* @__PURE__ */ t.jsx(F.Fragment, { children: l }, d)
1313
1477
  )),
1314
- r < u.length - 1 && /* @__PURE__ */ t.jsx(X, {})
1478
+ r < o.length - 1 && /* @__PURE__ */ t.jsx(ae, {})
1315
1479
  ] }, r)
1316
1480
  ))
1317
1481
  }
1318
1482
  )
1319
1483
  ] });
1320
1484
  }
1321
- function se({
1485
+ function de({
1322
1486
  item: e,
1323
1487
  children: s,
1324
1488
  nestingLevel: a = 0,
@@ -1326,7 +1490,7 @@ function se({
1326
1490
  }) {
1327
1491
  const {
1328
1492
  state: { selectedRuleIndex: c }
1329
- } = g(), o = e?.conditions_logic?.toLowerCase() ?? "and", { setPath: i } = g(), [r, u] = f(0), l = a > 0;
1493
+ } = x(), i = e?.conditions_logic?.toLowerCase() ?? "and", { setPath: u } = x(), [r, o] = g(0), l = a > 0;
1330
1494
  return /* @__PURE__ */ t.jsxs(
1331
1495
  "div",
1332
1496
  {
@@ -1340,12 +1504,12 @@ function se({
1340
1504
  "select",
1341
1505
  {
1342
1506
  onChange: (d) => {
1343
- i(
1507
+ u(
1344
1508
  `${n}.conditions_logic`,
1345
1509
  d.currentTarget.value
1346
1510
  );
1347
1511
  },
1348
- defaultValue: o,
1512
+ defaultValue: i,
1349
1513
  className: "pl-4 pr-8 py-2 font-bold focus:ring-0 focus:outline-hidden appearance-none bg-gray-50 border border-gray-200 rounded-md text-sm leading-4",
1350
1514
  children: [
1351
1515
  /* @__PURE__ */ t.jsxs("option", { value: "and", children: [
@@ -1359,20 +1523,20 @@ function se({
1359
1523
  ]
1360
1524
  }
1361
1525
  ),
1362
- /* @__PURE__ */ t.jsx("div", { className: "border-l border-gray-200 ml-3 pt-3", children: e?.conditions?.map((d, p, x) => {
1363
- const h = p === x.length - 1;
1526
+ /* @__PURE__ */ t.jsx("div", { className: "border-l border-gray-200 ml-3 pt-3", children: e?.conditions?.map((d, h, p) => {
1527
+ const m = h === p.length - 1;
1364
1528
  return /* @__PURE__ */ t.jsxs(
1365
1529
  "div",
1366
1530
  {
1367
1531
  className: "flex items-center mb-4 last:mb-0 relative",
1368
1532
  children: [
1369
- /* @__PURE__ */ t.jsx(Ia, { rounded: h }),
1533
+ /* @__PURE__ */ t.jsx(La, { rounded: m }),
1370
1534
  /* @__PURE__ */ t.jsx("div", { className: "ml-4 w-full", children: /* @__PURE__ */ t.jsx(
1371
- se,
1535
+ de,
1372
1536
  {
1373
1537
  item: d?.nested ?? void 0,
1374
1538
  nestingLevel: d?.nested != null ? a + 1 : 0,
1375
- pathPrefix: `${n}.conditions.${p}.nested`,
1539
+ pathPrefix: `${n}.conditions.${h}.nested`,
1376
1540
  children: /* @__PURE__ */ t.jsx(
1377
1541
  "div",
1378
1542
  {
@@ -1380,13 +1544,13 @@ function se({
1380
1544
  "mb-4": d?.nested != null
1381
1545
  }),
1382
1546
  children: /* @__PURE__ */ t.jsx(
1383
- Aa,
1547
+ Pa,
1384
1548
  {
1385
1549
  item: d,
1386
1550
  nestingLevel: a,
1387
- pathPrefix: `${n}.conditions.${p}`,
1388
- onDelete: x.length > 1 || a > 0 ? () => {
1389
- u((m) => m + 1);
1551
+ pathPrefix: `${n}.conditions.${h}`,
1552
+ onDelete: p.length > 1 || a > 0 ? () => {
1553
+ o((f) => f + 1);
1390
1554
  } : void 0
1391
1555
  }
1392
1556
  )
@@ -1396,7 +1560,7 @@ function se({
1396
1560
  ) })
1397
1561
  ]
1398
1562
  },
1399
- `${c}-${p}-${r}`
1563
+ `${c}-${h}-${r}`
1400
1564
  );
1401
1565
  }) })
1402
1566
  ] })
@@ -1404,7 +1568,7 @@ function se({
1404
1568
  }
1405
1569
  );
1406
1570
  }
1407
- function Ia({
1571
+ function La({
1408
1572
  rounded: e = !1
1409
1573
  }) {
1410
1574
  return e ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
@@ -1412,11 +1576,11 @@ function Ia({
1412
1576
  /* @__PURE__ */ t.jsx("div", { className: "absolute -left-px top-1/2 -translate-y-1/2 w-3.5 h-3.5 border-l border-b rounded-es-sm bg-white border-gray-200" })
1413
1577
  ] }) : /* @__PURE__ */ t.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-3.5 h-px bg-gray-200" });
1414
1578
  }
1415
- function Za() {
1579
+ function Fa() {
1416
1580
  const {
1417
1581
  setPath: e,
1418
1582
  state: { value: s, selectedRuleIndex: a }
1419
- } = g(), [n, c] = f(
1583
+ } = x(), [n, c] = g(
1420
1584
  s.rules?.[a]?.name ?? ""
1421
1585
  );
1422
1586
  return _(() => {
@@ -1436,51 +1600,51 @@ function Za() {
1436
1600
  {
1437
1601
  contentEditable: "plaintext-only",
1438
1602
  suppressContentEditableWarning: !0,
1439
- onInput: (o) => {
1440
- const r = o.currentTarget.innerText.replace(/[\n\s]+/g, " ").trim();
1603
+ onInput: (i) => {
1604
+ const r = i.currentTarget.innerText.replace(/[\n\s]+/g, " ").trim();
1441
1605
  e(`rules.${a}.name`, r);
1442
1606
  },
1443
- onKeyDown: (o) => {
1444
- o.key === "Enter" && (o.preventDefault(), o.currentTarget.blur());
1607
+ onKeyDown: (i) => {
1608
+ i.key === "Enter" && (i.preventDefault(), i.currentTarget.blur());
1445
1609
  },
1446
- onBlur: (o) => {
1447
- const i = o.currentTarget;
1448
- i.innerText = i.innerText.replace(/[\n\s]+/g, " ").trim();
1610
+ onBlur: (i) => {
1611
+ const u = i.currentTarget;
1612
+ u.innerText = u.innerText.replace(/[\n\s]+/g, " ").trim();
1449
1613
  },
1450
1614
  children: n
1451
1615
  },
1452
1616
  a
1453
1617
  );
1454
1618
  }
1455
- const z = {
1619
+ const X = {
1456
1620
  rules: []
1457
- }, S = (e) => {
1621
+ }, E = (e) => {
1458
1622
  try {
1459
- return JSON.parse(e ?? JSON.stringify(z));
1623
+ return JSON.parse(e ?? JSON.stringify(X));
1460
1624
  } catch {
1461
- return z;
1625
+ return X;
1462
1626
  }
1463
- }, Da = (e) => {
1627
+ }, za = (e) => {
1464
1628
  try {
1465
1629
  return JSON.parse(e ?? "{}"), !0;
1466
1630
  } catch {
1467
1631
  return !1;
1468
1632
  }
1469
1633
  };
1470
- function Ja(e) {
1634
+ function Qa(e) {
1471
1635
  const {
1472
1636
  settings: { domain: s }
1473
- } = G(), [a, n] = f([]), [c, o] = f(
1474
- S(e.value ?? e.defaultValue)
1637
+ } = te(), [a, n] = g([]), [c, i] = g(
1638
+ E(e.value ?? e.defaultValue)
1475
1639
  );
1476
1640
  return _(
1477
1641
  function() {
1478
- c.rules?.length === 0 && o(S(e.value));
1642
+ c.rules?.length === 0 && i(E(e.value));
1479
1643
  },
1480
1644
  [e.value]
1481
1645
  ), _(
1482
1646
  function() {
1483
- ia(e.schemaType, s).then((r) => {
1647
+ ha(e.schemaType, s).then((r) => {
1484
1648
  const l = y.object({
1485
1649
  properties: y.object({
1486
1650
  rules: y.object({
@@ -1511,41 +1675,41 @@ function Ja(e) {
1511
1675
  },
1512
1676
  [s]
1513
1677
  ), /* @__PURE__ */ t.jsx(
1514
- ba,
1678
+ wa,
1515
1679
  {
1516
1680
  initialValue: {
1517
1681
  value: { rules: c.rules },
1518
1682
  availableActionTypes: a,
1519
1683
  schemaType: e.schemaType
1520
1684
  },
1521
- children: /* @__PURE__ */ t.jsx(Ma, { ...e })
1685
+ children: /* @__PURE__ */ t.jsx(Ua, { ...e })
1522
1686
  }
1523
1687
  );
1524
1688
  }
1525
- function Ma(e) {
1689
+ function Ua(e) {
1526
1690
  const {
1527
1691
  state: { value: s, selectedRuleIndex: a },
1528
1692
  setSelectedRuleIndex: n,
1529
1693
  setValue: c,
1530
- setPath: o
1531
- } = g(), [i, r] = f(
1694
+ setPath: i
1695
+ } = x(), [u, r] = g(
1532
1696
  e.defaultCodeEditorVisible ?? !1
1533
- ), u = s.rules?.[a], l = H(null), [d, p] = f(0);
1697
+ ), o = s.rules?.[a], l = se(null), [d, h] = g(0);
1534
1698
  _(
1535
1699
  function() {
1536
- k(S(l.current?.getValue()), s) || l.current?.setValue(JSON.stringify(s, null, 2)), e.onChange?.(s);
1700
+ R(E(l.current?.getValue()), s) || l.current?.setValue(JSON.stringify(s, null, 2)), e.onChange?.(s);
1537
1701
  },
1538
1702
  [s]
1539
1703
  );
1540
- const x = C(
1541
- (h) => {
1542
- const m = S(h);
1543
- l.current?.hasTextFocus() && Da(h) && !k(m, s) && (c(m), p((T) => T + 1));
1704
+ const p = S(
1705
+ (m) => {
1706
+ const f = E(m);
1707
+ l.current?.hasTextFocus() && za(m) && !R(f, s) && (c(f), h((T) => T + 1));
1544
1708
  },
1545
1709
  [s]
1546
1710
  );
1547
1711
  return /* @__PURE__ */ t.jsx(
1548
- oa,
1712
+ ga,
1549
1713
  {
1550
1714
  hint: e.hint,
1551
1715
  feedback: e.feedback,
@@ -1554,12 +1718,12 @@ function Ma(e) {
1554
1718
  /* @__PURE__ */ t.jsxs(
1555
1719
  "div",
1556
1720
  {
1557
- className: `shrink-0 basis-3/5 overflow-x-auto relative flex flex-col ${i ? "" : "grow"}`,
1721
+ className: `shrink-0 basis-3/5 overflow-x-auto relative flex flex-col ${u ? "" : "grow"}`,
1558
1722
  children: [
1559
1723
  /* @__PURE__ */ t.jsxs("header", { className: "w-full bg-white border-b border-gray-200 px-4 flex text-[13px] gap-4 text-gray-400 font-semibold items-center", children: [
1560
1724
  /* @__PURE__ */ t.jsxs("div", { className: "flex items-center flex-wrap basis-full", children: [
1561
- s.rules?.map((h, m, T) => {
1562
- const ne = `#${(m + 1).toString().padStart(2, "0")}`;
1725
+ s.rules?.map((m, f, T) => {
1726
+ const me = `#${(f + 1).toString().padStart(2, "0")}`;
1563
1727
  return /* @__PURE__ */ t.jsxs(
1564
1728
  "div",
1565
1729
  {
@@ -1570,41 +1734,41 @@ function Ma(e) {
1570
1734
  {
1571
1735
  type: "button",
1572
1736
  className: V("font-bold mr-2", {
1573
- "text-black": a === m
1737
+ "text-black": a === f
1574
1738
  }),
1575
1739
  onClick: () => {
1576
- n(m);
1740
+ n(f);
1577
1741
  },
1578
- children: ne
1742
+ children: me
1579
1743
  }
1580
1744
  ),
1581
1745
  /* @__PURE__ */ t.jsx(
1582
1746
  A,
1583
1747
  {
1584
- menuPosition: m === 0 ? "bottom-left" : "bottom-right",
1585
- dropdownLabel: /* @__PURE__ */ t.jsx(N, { variant: "circle", children: /* @__PURE__ */ t.jsx(v, { name: "dotsThreeVertical", size: 16 }) }),
1748
+ menuPosition: f === 0 ? "bottom-left" : "bottom-right",
1749
+ dropdownLabel: /* @__PURE__ */ t.jsx(M, { variant: "circle", children: /* @__PURE__ */ t.jsx(v, { name: "dotsThreeVertical", size: 16 }) }),
1586
1750
  dropdownItems: /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
1587
1751
  /* @__PURE__ */ t.jsx(
1588
1752
  w,
1589
1753
  {
1590
1754
  onClick: () => {
1591
- const I = s.rules?.length ?? 0;
1592
- o(`rules.${I}`, {
1593
- ...h,
1755
+ const D = s.rules?.length ?? 0;
1756
+ i(`rules.${D}`, {
1757
+ ...m,
1594
1758
  id: void 0,
1595
- name: `${h.name} (copy)`
1596
- }), n(I);
1759
+ name: `${m.name} (copy)`
1760
+ }), n(D);
1597
1761
  },
1598
1762
  label: "Duplicate"
1599
1763
  }
1600
1764
  ),
1601
- /* @__PURE__ */ t.jsx(X, {}),
1765
+ /* @__PURE__ */ t.jsx(ae, {}),
1602
1766
  /* @__PURE__ */ t.jsx(
1603
1767
  w,
1604
1768
  {
1605
1769
  disabled: T.length === 1,
1606
1770
  onClick: () => {
1607
- o(`rules.${m}`, null), a >= m && n(a - 1);
1771
+ i(`rules.${f}`, null), a >= f && n(a - 1);
1608
1772
  },
1609
1773
  label: "Delete"
1610
1774
  }
@@ -1614,16 +1778,16 @@ function Ma(e) {
1614
1778
  )
1615
1779
  ]
1616
1780
  },
1617
- `${m}-${h.id}`
1781
+ `${f}-${m.id}`
1618
1782
  );
1619
1783
  }),
1620
1784
  /* @__PURE__ */ t.jsx("div", { className: "min-h-[49px] flex items-center", children: /* @__PURE__ */ t.jsx(
1621
- N,
1785
+ M,
1622
1786
  {
1623
1787
  variant: "circle",
1624
1788
  className: "mx-4",
1625
1789
  onClick: () => {
1626
- o(`rules.${s.rules?.length ?? 0}`, {
1790
+ i(`rules.${s.rules?.length ?? 0}`, {
1627
1791
  name: "Rule name",
1628
1792
  actions: [null],
1629
1793
  conditions: [null]
@@ -1634,40 +1798,40 @@ function Ma(e) {
1634
1798
  ) })
1635
1799
  ] }),
1636
1800
  /* @__PURE__ */ t.jsx("div", { className: "grow flex justify-end", children: /* @__PURE__ */ t.jsx(
1637
- N,
1801
+ M,
1638
1802
  {
1639
1803
  variant: "circle",
1640
1804
  onClick: () => {
1641
- r(!i);
1805
+ r(!u);
1642
1806
  },
1643
1807
  children: /* @__PURE__ */ t.jsx(v, { name: "sidebarSimple", size: 16 })
1644
1808
  }
1645
1809
  ) })
1646
1810
  ] }),
1647
- /* @__PURE__ */ t.jsx(qa, { children: u && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
1811
+ /* @__PURE__ */ t.jsx(Wa, { children: o && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
1648
1812
  /* @__PURE__ */ t.jsxs("div", { className: "mb-8 flex items-center gap-2", children: [
1649
- /* @__PURE__ */ t.jsx(Za, {}),
1813
+ /* @__PURE__ */ t.jsx(Fa, {}),
1650
1814
  /* @__PURE__ */ t.jsx(v, { name: "pencilSimple", size: 16, className: "shrink-0" })
1651
1815
  ] }),
1652
- /* @__PURE__ */ t.jsx(J, { title: "Actions", icon: "lightning", children: /* @__PURE__ */ t.jsx(Ta, { actions: u?.actions }) }),
1653
- /* @__PURE__ */ t.jsx(Oa, { children: "when" }),
1654
- /* @__PURE__ */ t.jsxs(J, { title: "Conditions", icon: "treeView", children: [
1816
+ /* @__PURE__ */ t.jsx(H, { title: "Actions", icon: "lightning", children: /* @__PURE__ */ t.jsx(ka, { actions: o?.actions }) }),
1817
+ /* @__PURE__ */ t.jsx(Ja, { children: "when" }),
1818
+ /* @__PURE__ */ t.jsxs(H, { title: "Conditions", icon: "treeView", children: [
1655
1819
  /* @__PURE__ */ t.jsx(
1656
- se,
1820
+ de,
1657
1821
  {
1658
- item: u,
1822
+ item: o,
1659
1823
  pathPrefix: `rules.${a}`
1660
1824
  }
1661
1825
  ),
1662
1826
  /* @__PURE__ */ t.jsx("div", { className: "mt-6", children: /* @__PURE__ */ t.jsxs(
1663
- N,
1827
+ M,
1664
1828
  {
1665
1829
  size: "small",
1666
1830
  variant: "secondary",
1667
1831
  alignItems: "center",
1668
1832
  onClick: () => {
1669
- o(
1670
- `rules.${a}.conditions.${u?.conditions?.length ?? 0}`,
1833
+ i(
1834
+ `rules.${a}.conditions.${o?.conditions?.length ?? 0}`,
1671
1835
  void 0
1672
1836
  );
1673
1837
  },
@@ -1683,8 +1847,8 @@ function Ma(e) {
1683
1847
  },
1684
1848
  d
1685
1849
  ),
1686
- i && /* @__PURE__ */ t.jsx("div", { className: "shrink-0 basis-2/5", children: /* @__PURE__ */ t.jsx(
1687
- ca,
1850
+ u && /* @__PURE__ */ t.jsx("div", { className: "shrink-0 basis-2/5", children: /* @__PURE__ */ t.jsx(
1851
+ xa,
1688
1852
  {
1689
1853
  ref: l,
1690
1854
  name: e.id ?? e.name,
@@ -1693,21 +1857,21 @@ function Ma(e) {
1693
1857
  jsonSchema: e.schemaType,
1694
1858
  defaultValue: JSON.stringify(s, null, 2),
1695
1859
  noRounding: !0,
1696
- onChange: x
1860
+ onChange: p
1697
1861
  }
1698
1862
  ) })
1699
1863
  ] })
1700
1864
  }
1701
1865
  );
1702
1866
  }
1703
- function Oa({ children: e }) {
1867
+ function Ja({ children: e }) {
1704
1868
  return /* @__PURE__ */ t.jsxs("div", { className: "text-gray-500 flex items-center justify-center flex-col", children: [
1705
1869
  /* @__PURE__ */ t.jsx("div", { className: "h-6 w-[2px] bg-gray-200" }),
1706
1870
  /* @__PURE__ */ t.jsx("span", { className: "font-bold my-1 bg-gray-200 px-3 relative uppercase rounded h-[25px] items-center flex text-sm", children: e }),
1707
1871
  /* @__PURE__ */ t.jsx("div", { className: "h-6 w-[2px] bg-gray-200" })
1708
1872
  ] });
1709
1873
  }
1710
- function J({
1874
+ function H({
1711
1875
  children: e,
1712
1876
  title: s,
1713
1877
  icon: a
@@ -1720,11 +1884,11 @@ function J({
1720
1884
  /* @__PURE__ */ t.jsx("div", { className: "p-6", children: e })
1721
1885
  ] });
1722
1886
  }
1723
- function qa({
1887
+ function Wa({
1724
1888
  children: e
1725
1889
  }) {
1726
1890
  return /* @__PURE__ */ t.jsx("div", { className: "h-full w-full bg-gray-50 p-8 bg-[radial-gradient(#d6d6d6_1px,transparent_1px)] bg-size-[16px_16px] overflow-auto", children: /* @__PURE__ */ t.jsx("div", { className: "max-w-[900px] mx-auto", children: e }) });
1727
1891
  }
1728
1892
  export {
1729
- Ja as RuleEngine
1893
+ Qa as RuleEngine
1730
1894
  };