@isettingkit/business-rules 0.1.32 → 0.1.34

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.
package/dist/index.es.js CHANGED
@@ -1,45 +1,45 @@
1
- import { jsxs as u, Fragment as E, jsx as r } from "react/jsx-runtime";
2
- import { ValueDataType as k, ValueHowToSetUp as b, DecisionConditionRender as $ } from "@isettingkit/input";
1
+ import { jsxs as c, Fragment as N, jsx as i } from "react/jsx-runtime";
2
+ import { ValueDataType as D, ValueHowToSetUp as T, DecisionConditionRender as $ } from "@isettingkit/input";
3
3
  import { Stack as d } from "@inubekit/stack";
4
4
  import { Divider as w } from "@inubekit/divider";
5
5
  import { Button as z } from "@inubekit/button";
6
- import { useState as N, useEffect as te } from "react";
7
- import { Text as x } from "@inubekit/text";
6
+ import { useState as F, useEffect as te } from "react";
7
+ import { Text as f } from "@inubekit/text";
8
8
  import { Date as q } from "@inubekit/date";
9
- import { Checkbox as re } from "@inubekit/checkbox";
10
- import { Toggle as B } from "@inubekit/toggle";
11
- import { inube as v } from "@inubekit/foundations";
12
- import g, { keyframes as ae } from "styled-components";
13
- import { useFormik as ne } from "formik";
14
- import { mixed as P, object as L, number as R, string as I, date as M, lazy as H } from "yup";
15
- import { DecisionViewConditionRenderer as _ } from "@isettingkit/view";
16
- import { SkeletonLine as T } from "@inubekit/skeleton";
17
- import { MdOutlineDelete as oe, MdClear as ie, MdAdd as de } from "react-icons/md";
9
+ import { Checkbox as ie } from "@inubekit/checkbox";
10
+ import { Toggle as G } from "@inubekit/toggle";
11
+ import { inube as x } from "@inubekit/foundations";
12
+ import b, { keyframes as ne } from "styled-components";
13
+ import { useFormik as ae } from "formik";
14
+ import { mixed as B, object as L, number as I, string as U, date as O, lazy as j } from "yup";
15
+ import { DecisionViewConditionRenderer as A } from "@isettingkit/view";
16
+ import { SkeletonLine as C } from "@inubekit/skeleton";
17
+ import { MdOutlineDelete as re, MdClear as oe, MdAdd as le } from "react-icons/md";
18
18
  import { Icon as Q } from "@inubekit/icon";
19
- import { createPortal as le } from "react-dom";
19
+ import { createPortal as de } from "react-dom";
20
20
  import { Blanket as se } from "@inubekit/blanket";
21
21
  import { Grid as ce } from "@inubekit/grid";
22
- import { useMediaQuery as ue } from "@inubekit/hooks";
23
- const he = (e) => {
22
+ import { useMediaQuery as he } from "@inubekit/hooks";
23
+ const ue = (t) => {
24
24
  const {
25
- onHandleStartChange: t,
25
+ onHandleStartChange: e,
26
26
  onHandleEndChange: n,
27
- onCheckClosedChange: o,
28
- labelStart: l,
29
- labelEnd: a,
27
+ onCheckClosedChange: a,
28
+ labelStart: r,
29
+ labelEnd: o,
30
30
  checkedClosed: s = !1,
31
- required: c = !1,
32
- valueStart: h = "",
33
- valueEnd: i = "",
34
- messageStart: m = "",
35
- messageEnd: p = "",
36
- statusStart: f = "pending",
37
- statusEnd: S = "pending"
38
- } = e, [A, J] = N(s), [K, X] = N(h), [Z, ee] = N(i);
39
- return /* @__PURE__ */ u(E, { children: [
40
- /* @__PURE__ */ u(d, { direction: "row", justifyContent: "space-between", margin: "10px 0", children: [
41
- /* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(
42
- x,
31
+ required: h = !1,
32
+ valueStart: u = "",
33
+ valueEnd: l = "",
34
+ messageStart: p = "",
35
+ messageEnd: m = "",
36
+ statusStart: g = "pending",
37
+ statusEnd: k = "pending"
38
+ } = t, [S, J] = F(s), [K, X] = F(u), [Z, ee] = F(l);
39
+ return /* @__PURE__ */ c(N, { children: [
40
+ /* @__PURE__ */ c(d, { direction: "row", justifyContent: "space-between", margin: "10px 0", children: [
41
+ /* @__PURE__ */ i(d, { children: /* @__PURE__ */ i(
42
+ f,
43
43
  {
44
44
  appearance: "gray",
45
45
  margin: "10px 0",
@@ -49,66 +49,66 @@ const he = (e) => {
49
49
  children: "Vigencia"
50
50
  }
51
51
  ) }),
52
- /* @__PURE__ */ r(
52
+ /* @__PURE__ */ i(
53
53
  d,
54
54
  {
55
55
  alignContent: "center",
56
56
  justifyContent: "center",
57
57
  wrap: "wrap",
58
58
  gap: "4px",
59
- children: /* @__PURE__ */ r(
60
- re,
59
+ children: /* @__PURE__ */ i(
60
+ ie,
61
61
  {
62
62
  label: "Cerrada",
63
63
  onChange: ({ target: y }) => {
64
- J(y.checked), o && o(y.checked);
64
+ J(y.checked), a && a(y.checked);
65
65
  },
66
- checked: A,
66
+ checked: S,
67
67
  value: ""
68
68
  }
69
69
  )
70
70
  }
71
71
  )
72
72
  ] }),
73
- /* @__PURE__ */ u(d, { justifyContent: "space-between", gap: "24px", children: [
74
- /* @__PURE__ */ r(d, { width: "189px", children: /* @__PURE__ */ r(
73
+ /* @__PURE__ */ c(d, { justifyContent: "space-between", gap: "24px", children: [
74
+ /* @__PURE__ */ i(d, { width: "189px", children: /* @__PURE__ */ i(
75
75
  q,
76
76
  {
77
77
  id: "dateStart",
78
- label: l,
78
+ label: r,
79
79
  onChange: (y) => {
80
- X(y.target.value), t(y);
80
+ X(y.target.value), e(y);
81
81
  },
82
82
  value: K,
83
- required: c,
83
+ required: h,
84
84
  size: "compact",
85
- status: f,
86
- message: m
85
+ status: g,
86
+ message: p
87
87
  }
88
88
  ) }),
89
- A && /* @__PURE__ */ r(d, { width: "189px", children: /* @__PURE__ */ r(
89
+ S && /* @__PURE__ */ i(d, { width: "189px", children: /* @__PURE__ */ i(
90
90
  q,
91
91
  {
92
92
  id: "dateEnd",
93
- label: a,
93
+ label: o,
94
94
  onChange: (y) => {
95
95
  ee(y.target.value), n(y);
96
96
  },
97
97
  value: Z,
98
- required: c,
98
+ required: h,
99
99
  size: "compact",
100
- status: S,
101
- message: p
100
+ status: k,
101
+ message: m
102
102
  }
103
103
  ) })
104
104
  ] })
105
105
  ] });
106
- }, pe = g.div`
106
+ }, pe = b.div`
107
107
  & > div {
108
108
  border-radius: 8px;
109
- border: 1px solid ${v.palette.neutral.N30};
109
+ border: 1px solid ${x.palette.neutral.N30};
110
110
  }
111
- `, ge = g.div`
111
+ `, me = b.div`
112
112
  width: 100%;
113
113
  height: 100%;
114
114
  overflow-y: auto;
@@ -125,184 +125,206 @@ const he = (e) => {
125
125
  background-color: #ebecf0;
126
126
  border-radius: 8px;
127
127
  }
128
- `, me = (e) => {
128
+ `, ge = (t) => {
129
129
  const {
130
- checked: t,
130
+ checked: e,
131
131
  children: n,
132
- handleToggleChange: o,
133
- id: l,
134
- labelToggle: a,
132
+ handleToggleChange: a,
133
+ id: r,
134
+ labelToggle: o,
135
135
  name: s,
136
- valueToggle: c = ""
137
- } = e, [h, i] = N(t), m = (p) => {
138
- i(p.target.checked), o(p);
136
+ valueToggle: h = ""
137
+ } = t, [u, l] = F(e), p = (m) => {
138
+ l(m.target.checked), a(m);
139
139
  };
140
140
  return te(() => {
141
- i(t);
142
- }, [t]), /* @__PURE__ */ u(E, { children: [
143
- /* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(
144
- B,
141
+ l(e);
142
+ }, [e]), /* @__PURE__ */ c(N, { children: [
143
+ /* @__PURE__ */ i(d, { children: /* @__PURE__ */ i(
144
+ G,
145
145
  {
146
- checked: h,
147
- id: l,
146
+ checked: u,
147
+ id: r,
148
148
  name: s,
149
- onChange: m,
149
+ onChange: p,
150
150
  size: "small",
151
- value: c,
152
- children: /* @__PURE__ */ r(x, { size: "medium", type: "label", weight: "bold", children: a })
151
+ value: h,
152
+ children: /* @__PURE__ */ i(f, { size: "medium", type: "label", weight: "bold", children: o })
153
153
  }
154
154
  ) }),
155
- h && /* @__PURE__ */ r(E, { children: n })
155
+ u && /* @__PURE__ */ i(N, { children: n })
156
156
  ] });
157
- }, be = (e) => ({
158
- schema: P().test(
157
+ }, be = (t) => ({
158
+ schema: B().test(
159
159
  "isArrayOrString",
160
160
  "Must be an array of strings/numbers or a single string",
161
- (t) => Array.isArray(t) ? t.every(
161
+ (e) => Array.isArray(e) ? e.every(
162
162
  (n) => typeof n == "string" || typeof n == "number"
163
- ) : typeof t == "string"
163
+ ) : typeof e == "string"
164
164
  ),
165
- value: e
166
- }), fe = (e) => ({
167
- schema: P().test(
165
+ value: t
166
+ }), Te = (t) => ({
167
+ schema: B().test(
168
168
  "isArrayOrString",
169
169
  "Must be an array of strings/numbers or a single string",
170
- (t) => Array.isArray(t) ? t.every(
170
+ (e) => Array.isArray(e) ? e.every(
171
171
  (n) => typeof n == "string" || typeof n == "number"
172
- ) : typeof t == "string"
172
+ ) : typeof e == "string"
173
173
  ),
174
- value: e
175
- }), xe = (e) => {
176
- const t = (e == null ? void 0 : e.from) ?? 0, n = (e == null ? void 0 : e.to) ?? 0;
174
+ value: t
175
+ }), fe = (t) => {
176
+ const e = (t == null ? void 0 : t.from) ?? 0, n = (t == null ? void 0 : t.to) ?? 0;
177
177
  return {
178
178
  schema: L({
179
- from: R().required("Range From is required").max(n, "'Range From' cannot be greater than 'Range To'").min(0, "'Range From' cannot be less than 0"),
180
- to: R().min(0, "To value must be greater than or equal to 0").required("To value is required").test(
179
+ from: I().required("Range From is required").max(n, "'Range From' cannot be greater than 'Range To'").min(0, "'Range From' cannot be less than 0"),
180
+ to: I().min(0, "To value must be greater than or equal to 0").required("To value is required").test(
181
181
  "is-greater",
182
182
  "To value must be greater than From value",
183
- function(o) {
184
- const { from: l } = this.parent;
185
- return o > l;
183
+ function(a) {
184
+ const { from: r } = this.parent;
185
+ return a > r;
186
186
  }
187
187
  )
188
188
  }),
189
- value: { from: t, to: n }
189
+ value: { from: e, to: n }
190
190
  };
191
- }, V = (e, t) => t === k.PERCENTAGE ? {
192
- schema: R().required("Percentage is required").min(0, "Percentage cannot be less than 0").max(100, "Percentage cannot be greater than 100"),
193
- value: e
191
+ }, V = (t, e) => e === D.PERCENTAGE ? {
192
+ schema: I().required("Percentage is required").min(0, "Percentage cannot be less than 0").max(100, "Percentage cannot be greater than 100"),
193
+ value: t
194
194
  } : {
195
- schema: I().required("Required"),
196
- value: e
197
- }, ye = (e) => ({
198
- schema: I().required("Required").test(
195
+ schema: U().required("Required"),
196
+ value: t
197
+ }, ye = (t) => ({
198
+ schema: U().required("Required").test(
199
199
  "non-empty",
200
200
  "Value cannot be empty",
201
- (t) => t != null && t.trim() !== ""
201
+ (e) => e != null && e.trim() !== ""
202
202
  ),
203
- value: e
204
- }), ve = {
205
- [b.LIST_OF_VALUES]: be,
206
- [b.LIST_OF_VALUES_MULTI]: fe,
207
- [b.RANGE]: xe,
208
- [b.GREATER_THAN]: V,
209
- [b.LESS_THAN]: V,
210
- [b.EQUAL]: V
211
- }, O = (e) => ve[e] || ye;
212
- function Ce({ decision: e, onSubmitEvent: t }) {
203
+ value: t
204
+ }), xe = {
205
+ [T.LIST_OF_VALUES]: be,
206
+ [T.LIST_OF_VALUES_MULTI]: Te,
207
+ [T.RANGE]: fe,
208
+ [T.GREATER_THAN]: V,
209
+ [T.LESS_THAN]: V,
210
+ [T.EQUAL]: V
211
+ }, H = (t) => xe[t] || ye;
212
+ function ve({ decision: t, onSubmitEvent: e }) {
213
213
  const n = {
214
- name: e.name || "",
215
- dataType: e.dataType || k.ALPHABETICAL,
216
- valueUse: e.valueUse || "",
217
- value: e.value || "",
218
- startDate: e.startDate || "",
219
- endDate: e.endDate || "",
214
+ ruleName: t.ruleName || "",
215
+ decisionDataType: t.decisionDataType || D.ALPHABETICAL,
216
+ howToSetTheDecision: t.howToSetTheDecision || "",
217
+ value: t.value || "",
218
+ effectiveFrom: t.effectiveFrom || "",
219
+ validUntil: t.validUntil || "",
220
220
  toggleNone: !0,
221
- conditions: {},
221
+ conditionThatEstablishesTheDecision: {},
222
222
  checkClosed: !1
223
- }, o = L({
224
- name: I().required("Name is required"),
225
- startDate: M().required("Start date is required"),
226
- endDate: M().when("checkClosed", (s, c, { parent: h }) => (h == null ? void 0 : h.checkClosed) ? c.required("End date is required").test(
227
- "is-after-startDate",
228
- "End date must be greater than or equal to Start date",
229
- function(m) {
230
- const p = this.parent.startDate;
231
- return !p || !m ? !0 : new Date(m) >= new Date(p);
232
- }
233
- ) : c.notRequired()),
234
- value: H(() => O(l.values.valueUse)(l.values.value, l.values.dataType).schema),
235
- conditions: H((s, { parent: c }) => {
236
- var i, m;
237
- return (c == null ? void 0 : c.toggleNone) && ((i = c == null ? void 0 : c.conditions) == null ? void 0 : i.length) > 0 ? L().shape({}) : L(
238
- (m = e.conditions) == null ? void 0 : m.reduce(
239
- (p, f) => {
240
- if (l.values.conditions[f.name] !== void 0) {
241
- const S = O(f.valueUse);
242
- p[f.name] = S(
243
- f.value,
244
- f.dataType
245
- ).schema;
246
- }
247
- return p;
248
- },
249
- {}
250
- )
223
+ }, a = L({
224
+ ruleName: U().required("Name is required"),
225
+ effectiveFrom: O().required("effective From date is required"),
226
+ validUntil: O().when(
227
+ "checkClosed",
228
+ (s, h, { parent: u }) => (u == null ? void 0 : u.checkClosed) ? h.required("valid Until date is required").test(
229
+ "is-after-startDate",
230
+ "valid Until date must be greater than or equal to Start date",
231
+ function(p) {
232
+ const m = this.parent.effectiveFrom;
233
+ return !m || !p ? !0 : new Date(p) >= new Date(m);
234
+ }
235
+ ) : h.notRequired()
236
+ ),
237
+ value: j(() => H(r.values.howToSetTheDecision)(
238
+ r.values.value,
239
+ r.values.decisionDataType
240
+ ).schema),
241
+ conditionThatEstablishesTheDecision: j((s, { parent: h }) => {
242
+ var p;
243
+ if ((h == null ? void 0 : h.toggleNone) && Object.keys(h.conditionThatEstablishesTheDecision || {}).length > 0) return L().shape({});
244
+ const l = (p = t.conditionThatEstablishesTheDecision) == null ? void 0 : p.reduce(
245
+ (m, g) => {
246
+ if (r.values.conditionThatEstablishesTheDecision[g.conditionName] !== void 0) {
247
+ const S = H(g.howToSetTheCondition);
248
+ m[g.conditionName] = S(
249
+ g.value,
250
+ g.conditionDataType
251
+ ).schema;
252
+ }
253
+ return m;
254
+ },
255
+ {}
256
+ );
257
+ return L(l).test(
258
+ "at-least-one-condition",
259
+ "It must be at least one condition in order for the decision to be validated correctly.",
260
+ (m) => m ? Object.values(m).some(
261
+ (g) => g != null && g !== ""
262
+ ) : !1
251
263
  );
252
264
  })
253
- }), l = ne({
265
+ }), r = ae({
254
266
  initialValues: n,
255
- validationSchema: o,
267
+ validationSchema: a,
256
268
  validateOnBlur: !0,
257
269
  onSubmit: (s) => {
258
- var h;
259
- const c = {
260
- ...e,
261
- name: s.name,
262
- dataType: s.dataType,
263
- valueUse: s.valueUse,
270
+ var u;
271
+ const h = {
272
+ ...t,
273
+ ruleName: s.ruleName,
274
+ decisionDataType: s.decisionDataType,
275
+ howToSetTheDecision: s.howToSetTheDecision,
264
276
  value: s.value,
265
- startDate: s.startDate,
266
- endDate: s.endDate,
267
- conditions: (h = e.conditions) == null ? void 0 : h.map((i) => ({
268
- ...i,
269
- value: s.conditions[i.name]
277
+ effectiveFrom: s.effectiveFrom,
278
+ validUntil: s.validUntil,
279
+ conditionThatEstablishesTheDecision: (u = t.conditionThatEstablishesTheDecision) == null ? void 0 : u.filter((l) => {
280
+ const p = s.conditionThatEstablishesTheDecision[l.conditionName];
281
+ return p != null && p !== "";
282
+ }).map((l) => ({
283
+ ...l,
284
+ value: s.conditionThatEstablishesTheDecision[l.conditionName]
270
285
  }))
271
286
  };
272
- t(c);
287
+ e(h);
273
288
  }
274
289
  });
275
- return { formik: l, handleToggleNoneChange: (s) => {
276
- var c;
277
- l.setFieldValue("toggleNone", s), (c = e.conditions) == null || c.forEach((h) => {
290
+ return { formik: r, handleToggleNoneChange: (s) => {
291
+ var h;
292
+ r.setFieldValue("toggleNone", s), (h = t.conditionThatEstablishesTheDecision) == null || h.forEach((u) => {
278
293
  if (s)
279
- l.setFieldValue(`conditions.${h.name}`, void 0);
294
+ r.setFieldValue(
295
+ `conditionThatEstablishesTheDecision.${u.conditionName}`,
296
+ void 0
297
+ );
280
298
  else {
281
- const i = h.valueUse === b.LIST_OF_VALUES_MULTI ? [] : "";
282
- l.setFieldValue(`conditions.${h.name}`, i);
299
+ const l = u.howToSetTheCondition === T.LIST_OF_VALUES_MULTI ? [] : "";
300
+ r.setFieldValue(
301
+ `conditionThatEstablishesTheDecision.${u.conditionName}`,
302
+ l
303
+ );
283
304
  }
284
305
  });
285
306
  } };
286
307
  }
287
- const we = (e) => {
288
- var h;
289
- const { decision: t, onSubmitEvent: n, textValues: o, onCancel: l } = e, { formik: a, handleToggleNoneChange: s } = Ce({
290
- decision: t,
308
+ const we = (t) => {
309
+ var u;
310
+ const { decision: e, onSubmitEvent: n, textValues: a, onCancel: r } = t, { formik: o, handleToggleNoneChange: s } = ve({
311
+ decision: e,
291
312
  onSubmitEvent: n
292
- }), c = {
293
- name: t.name,
294
- valueUse: t.valueUse,
295
- dataType: t.dataType,
296
- possibleValue: t.possibleValue
313
+ }), h = {
314
+ ruleName: e.ruleName,
315
+ labelName: e.labelName,
316
+ howToSetTheCondition: e.howToSetTheDecision,
317
+ decisionDataType: e.decisionDataType,
318
+ listOfPossibleValues: e.listOfPossibleValues
297
319
  };
298
- return /* @__PURE__ */ r("form", { onSubmit: a.handleSubmit, children: /* @__PURE__ */ u(d, { direction: "column", gap: "24px", children: [
320
+ return /* @__PURE__ */ i("form", { onSubmit: o.handleSubmit, children: /* @__PURE__ */ c(d, { direction: "column", gap: "24px", children: [
299
321
  $({
300
- condition: c,
301
- formik: a,
322
+ condition: h,
323
+ formik: o,
302
324
  isDecision: !0
303
325
  }),
304
- /* @__PURE__ */ r(w, { dashed: !0 }),
305
- /* @__PURE__ */ r(pe, { children: /* @__PURE__ */ r(ge, { children: /* @__PURE__ */ u(
326
+ /* @__PURE__ */ i(w, { dashed: !0 }),
327
+ /* @__PURE__ */ i(pe, { children: /* @__PURE__ */ i(me, { children: /* @__PURE__ */ c(
306
328
  d,
307
329
  {
308
330
  direction: "column",
@@ -310,91 +332,94 @@ const we = (e) => {
310
332
  gap: "16px",
311
333
  height: "272px",
312
334
  children: [
313
- /* @__PURE__ */ u(
335
+ /* @__PURE__ */ c(
314
336
  d,
315
337
  {
316
338
  justifyContent: "space-between",
317
339
  alignItems: "center",
318
340
  gap: "64px",
319
341
  children: [
320
- /* @__PURE__ */ r(x, { type: "title", size: "small", weight: "bold", appearance: "gray", children: o.factsThatConditionIt }),
321
- /* @__PURE__ */ r(
322
- B,
342
+ /* @__PURE__ */ i(f, { type: "title", size: "small", weight: "bold", appearance: "gray", children: a.factsThatConditionIt }),
343
+ /* @__PURE__ */ i(
344
+ G,
323
345
  {
324
346
  id: "toggleNone",
325
- onChange: () => s(!a.values.toggleNone),
326
- checked: a.values.toggleNone,
347
+ onChange: () => s(!o.values.toggleNone),
348
+ checked: o.values.toggleNone,
327
349
  size: "small",
328
- children: /* @__PURE__ */ r(x, { size: "medium", type: "label", weight: "bold", children: o.none })
350
+ children: /* @__PURE__ */ i(f, { size: "medium", type: "label", weight: "bold", children: a.none })
329
351
  }
330
352
  )
331
353
  ]
332
354
  }
333
355
  ),
334
- /* @__PURE__ */ r(d, { direction: "column", gap: "20px", children: (h = t.conditions) == null ? void 0 : h.map((i) => /* @__PURE__ */ r(
335
- me,
336
- {
337
- id: `toggle-${i.name}`,
338
- name: `toggle.${i.name}`,
339
- labelToggle: i.name,
340
- checked: !a.values.toggleNone && a.values.conditions[i.name] !== void 0,
341
- handleToggleChange: (m) => {
342
- if (!m.target.checked)
343
- a.setFieldValue(
344
- `conditions.${i.name}`,
345
- void 0
346
- ), a.setFieldTouched(
347
- `conditions.${i.name}`,
348
- !1,
349
- !1
350
- );
351
- else {
352
- const f = i.valueUse === b.LIST_OF_VALUES_MULTI ? [] : "";
353
- a.setFieldValue(
354
- `conditions.${i.name}`,
355
- f
356
- );
357
- }
356
+ /* @__PURE__ */ i(d, { direction: "column", gap: "20px", children: (u = e.conditionThatEstablishesTheDecision) == null ? void 0 : u.map(
357
+ (l) => l.hidden ? null : /* @__PURE__ */ i(
358
+ ge,
359
+ {
360
+ id: `toggle-${l.conditionName}`,
361
+ name: `toggle.${l.conditionName}`,
362
+ labelToggle: l.labelName,
363
+ checked: !o.values.toggleNone && o.values.conditionThatEstablishesTheDecision[l.conditionName] !== void 0,
364
+ handleToggleChange: (p) => {
365
+ if (!p.target.checked)
366
+ o.setFieldValue(
367
+ `conditionThatEstablishesTheDecision.${l.conditionName}`,
368
+ void 0
369
+ ), o.setFieldTouched(
370
+ `conditionThatEstablishesTheDecision.${l.conditionName}`,
371
+ !1,
372
+ !1
373
+ );
374
+ else {
375
+ const g = l.howToSetTheCondition === T.LIST_OF_VALUES_MULTI ? [] : "";
376
+ o.setFieldValue(
377
+ `conditionThatEstablishesTheDecision.${l.conditionName}`,
378
+ g
379
+ );
380
+ }
381
+ },
382
+ children: $({ condition: l, formik: o })
358
383
  },
359
- children: $({ condition: i, formik: a })
360
- },
361
- i.name
362
- )) })
384
+ l.conditionName
385
+ )
386
+ ) })
363
387
  ]
364
388
  }
365
389
  ) }) }),
366
- /* @__PURE__ */ r(w, { dashed: !0 }),
367
- /* @__PURE__ */ r(
368
- he,
390
+ /* @__PURE__ */ i(w, { dashed: !0 }),
391
+ /* @__PURE__ */ i(
392
+ ue,
369
393
  {
370
- labelStart: o.termStart,
371
- labelEnd: o.termEnd,
372
- valueStart: a.values.startDate,
373
- valueEnd: a.values.endDate,
374
- messageStart: a.errors.startDate,
375
- messageEnd: a.errors.endDate,
376
- statusStart: a.touched.startDate ? a.errors.startDate ? "invalid" : "valid" : void 0,
377
- statusEnd: a.touched.endDate ? a.errors.endDate ? "invalid" : "valid" : void 0,
378
- onHandleStartChange: (i) => a.setFieldValue("startDate", i.target.value),
379
- onHandleEndChange: (i) => a.setFieldValue("endDate", i.target.value),
380
- onCheckClosedChange: (i) => {
381
- a.setFieldValue("checkClosed", i), i && a.setFieldValue("endDate", "");
394
+ labelStart: a.termStart,
395
+ labelEnd: a.termEnd,
396
+ valueStart: o.values.effectiveFrom,
397
+ valueEnd: o.values.validUntil,
398
+ messageStart: o.errors.effectiveFrom,
399
+ messageEnd: o.errors.validUntil,
400
+ statusStart: o.touched.effectiveFrom ? o.errors.effectiveFrom ? "invalid" : "valid" : void 0,
401
+ statusEnd: o.touched.validUntil ? o.errors.validUntil ? "invalid" : "valid" : void 0,
402
+ onHandleStartChange: (l) => o.setFieldValue("effectiveFrom", l.target.value),
403
+ onHandleEndChange: (l) => o.setFieldValue("validUntil", l.target.value),
404
+ onCheckClosedChange: (l) => {
405
+ o.setFieldValue("checkClosed", l), l && o.setFieldValue("validUntil", "");
382
406
  },
383
- checkedClosed: a.values.checkClosed
407
+ checkedClosed: o.values.checkClosed
384
408
  }
385
409
  ),
386
- /* @__PURE__ */ r(w, {}),
387
- /* @__PURE__ */ u(d, { direction: "row", justifyContent: "end", gap: "16px", children: [
388
- /* @__PURE__ */ r(z, { appearance: "gray", onClick: l, children: o.cancel }),
389
- /* @__PURE__ */ r(z, { type: "submit", children: o.confirm })
410
+ /* @__PURE__ */ i(w, {}),
411
+ o.errors.conditionThatEstablishesTheDecision && o.submitCount > 0 && /* @__PURE__ */ i(f, { type: "label", size: "medium", appearance: "danger", children: String(o.errors.conditionThatEstablishesTheDecision) }),
412
+ /* @__PURE__ */ c(d, { direction: "row", justifyContent: "end", gap: "16px", children: [
413
+ /* @__PURE__ */ i(z, { appearance: "gray", onClick: r, children: a.cancel }),
414
+ /* @__PURE__ */ i(z, { type: "submit", children: a.confirm })
390
415
  ] })
391
416
  ] }) });
392
- }, j = g.div`
417
+ }, M = b.div`
393
418
  & > div {
394
419
  border-radius: 8px;
395
- border: 1px solid ${v.palette.neutral.N30};
420
+ border: 1px solid ${x.palette.neutral.N30};
396
421
  }
397
- `, G = g.div`
422
+ `, P = b.div`
398
423
  width: 100%;
399
424
  height: 100%;
400
425
  overflow-y: auto;
@@ -412,41 +437,41 @@ const we = (e) => {
412
437
  background-color: #ebecf0;
413
438
  border-radius: 8px;
414
439
  }
415
- `, ke = (e) => e.value, Se = (e) => e.value, Te = (e) => ({
416
- from: e.from ?? "",
417
- to: e.to ?? ""
418
- }), De = (e) => e.value, Ee = (e) => e.value, Ae = (e) => e.value;
419
- var C = /* @__PURE__ */ ((e) => (e.EQUAL = "equal", e.GREATER_THAN = "greater_than", e.LESS_THAN = "less_than", e.LIST_OF_VALUES = "list_of_values", e.LIST_OF_VALUES_MULTI = "list_of_values_multi", e.RANGE = "range", e))(C || {});
420
- const _e = (e) => e.value, Ne = {
421
- [C.LIST_OF_VALUES]: ke,
422
- [C.LIST_OF_VALUES_MULTI]: Se,
423
- [C.RANGE]: Te,
424
- [C.GREATER_THAN]: De,
425
- [C.LESS_THAN]: Ee,
426
- [C.EQUAL]: Ae
440
+ `, Se = (t) => t.value, De = (t) => t.value, Ce = (t) => ({
441
+ from: t.from ?? "",
442
+ to: t.to ?? ""
443
+ }), Ee = (t) => t.value, Ne = (t) => t.value, ke = (t) => t.value;
444
+ var v = /* @__PURE__ */ ((t) => (t.EQUAL = "EqualTo", t.GREATER_THAN = "GreaterThan", t.LESS_THAN = "LessThan", t.LIST_OF_VALUES = "ListOfValues", t.LIST_OF_VALUES_MULTI = "ListOfValuesMulti", t.RANGE = "Range", t))(v || {});
445
+ const Ae = (t) => t.value, Fe = {
446
+ [v.LIST_OF_VALUES]: Se,
447
+ [v.LIST_OF_VALUES_MULTI]: De,
448
+ [v.RANGE]: Ce,
449
+ [v.GREATER_THAN]: Ee,
450
+ [v.LESS_THAN]: Ne,
451
+ [v.EQUAL]: ke
427
452
  };
428
- function D(e) {
429
- const t = e == null ? void 0 : e.value, n = typeof t == "object" && t !== null && !Array.isArray(t), o = Ne[e == null ? void 0 : e.valueUse] || _e;
430
- return n && o(t) || t || void 0;
453
+ function E(t) {
454
+ const e = t == null ? void 0 : t.value, n = typeof e == "object" && e !== null && !Array.isArray(e), a = Fe[t == null ? void 0 : t.howToSetTheDecision] || Ae;
455
+ return n && a(e) || e || void 0;
431
456
  }
432
- const Y = (e) => {
433
- const { decision: t, loading: n = !1, textValues: o } = e, l = {
434
- name: (t == null ? void 0 : t.name) || "",
435
- dataType: (t == null ? void 0 : t.dataType) || "alphabetical",
436
- value: D(t),
437
- valueUse: (t == null ? void 0 : t.valueUse) || "equal"
457
+ const Y = (t) => {
458
+ const { decision: e, loading: n = !1, textValues: a } = t, r = {
459
+ labelName: (e == null ? void 0 : e.labelName) || "",
460
+ decisionDataType: (e == null ? void 0 : e.decisionDataType) || "alphabetical",
461
+ value: E(e),
462
+ howToSetTheDecision: (e == null ? void 0 : e.howToSetTheDecision) || "EqualTo"
438
463
  };
439
- return !n && t && o ? /* @__PURE__ */ u(d, { direction: "column", gap: "12px", children: [
440
- t && /* @__PURE__ */ r(d, { direction: "column", alignItems: "center", children: /* @__PURE__ */ r(
441
- _,
464
+ return !n && e && a ? /* @__PURE__ */ c(d, { direction: "column", gap: "12px", children: [
465
+ e && /* @__PURE__ */ i(d, { direction: "column", alignItems: "center", children: /* @__PURE__ */ i(
466
+ A,
442
467
  {
443
- element: l,
444
- valueData: D(l),
468
+ element: r,
469
+ valueData: E(r),
445
470
  type: "decision"
446
471
  }
447
- ) }, t.name),
448
- /* @__PURE__ */ r(w, { dashed: !0 }),
449
- /* @__PURE__ */ r(G, { children: /* @__PURE__ */ u(
472
+ ) }, e.ruleName),
473
+ /* @__PURE__ */ i(w, { dashed: !0 }),
474
+ /* @__PURE__ */ i(P, { children: /* @__PURE__ */ c(
450
475
  d,
451
476
  {
452
477
  direction: "column",
@@ -454,91 +479,91 @@ const Y = (e) => {
454
479
  justifyContent: "space-between",
455
480
  height: "203px",
456
481
  children: [
457
- /* @__PURE__ */ r(
458
- x,
482
+ /* @__PURE__ */ i(
483
+ f,
459
484
  {
460
485
  type: "label",
461
486
  size: "large",
462
487
  appearance: "dark",
463
488
  weight: "bold",
464
489
  textAlign: "center",
465
- children: o.factsThatConditionIt
490
+ children: a.factsThatConditionIt
466
491
  }
467
492
  ),
468
- t.conditions && t.conditions.map((a) => a.hidden ? null : (console.log("condition: ", a), /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(d, { direction: "column", padding: "8px", children: /* @__PURE__ */ r(
469
- _,
493
+ e.conditionThatEstablishesTheDecision && e.conditionThatEstablishesTheDecision.map((o) => o.hidden ? null : /* @__PURE__ */ i(M, { children: /* @__PURE__ */ i(d, { direction: "column", padding: "8px", children: /* @__PURE__ */ i(
494
+ A,
470
495
  {
471
496
  element: {
472
- ...a,
473
- value: a.value
497
+ ...o,
498
+ value: o.value
474
499
  },
475
- valueData: D(a)
500
+ valueData: E(o)
476
501
  }
477
- ) }) }, a.name))),
478
- /* @__PURE__ */ r(w, { dashed: !0 }),
479
- /* @__PURE__ */ u(d, { direction: "column", gap: "12px", children: [
480
- (t == null ? void 0 : t.startDate) && (t == null ? void 0 : t.endDate) && /* @__PURE__ */ r(
481
- _,
502
+ ) }) }, o.conditionName)),
503
+ /* @__PURE__ */ i(w, { dashed: !0 }),
504
+ /* @__PURE__ */ c(d, { direction: "column", gap: "12px", children: [
505
+ (e == null ? void 0 : e.effectiveFrom) && (e == null ? void 0 : e.validUntil) && /* @__PURE__ */ i(
506
+ A,
482
507
  {
483
508
  element: {
484
- name: o.terms,
485
- value: String(t.startDate),
486
- valueUse: b.RANGE,
487
- dataType: k.DATE
509
+ labelName: a.terms,
510
+ value: String(e.effectiveFrom),
511
+ howToSetTheDecision: T.RANGE,
512
+ decisionDataType: D.DATE
488
513
  },
489
- valueData: D({
490
- name: o.terms,
514
+ valueData: E({
515
+ labelName: a.terms,
491
516
  value: {
492
- from: String(t.startDate),
493
- to: String(t.endDate)
517
+ from: String(e.effectiveFrom),
518
+ to: String(e.validUntil)
494
519
  },
495
- valueUse: b.RANGE,
496
- dataType: k.DATE
520
+ howToSetTheDecision: T.RANGE,
521
+ decisionDataType: D.DATE
497
522
  }),
498
523
  type: "decision"
499
524
  },
500
- o.terms
525
+ a.terms
501
526
  ),
502
- (t == null ? void 0 : t.startDate) && !(t != null && t.endDate) && /* @__PURE__ */ r(
503
- _,
527
+ (e == null ? void 0 : e.effectiveFrom) && !(e != null && e.validUntil) && /* @__PURE__ */ i(
528
+ A,
504
529
  {
505
530
  element: {
506
- name: o.terms,
507
- value: String(t.startDate),
508
- valueUse: b.EQUAL,
509
- dataType: k.DATE
531
+ labelName: a.terms,
532
+ value: String(e.effectiveFrom),
533
+ howToSetTheDecision: T.EQUAL,
534
+ decisionDataType: D.DATE
510
535
  },
511
- valueData: D({
512
- name: o.terms,
513
- value: String(t.startDate),
514
- valueUse: b.EQUAL,
515
- dataType: k.DATE
536
+ valueData: E({
537
+ labelName: a.terms,
538
+ value: String(e.effectiveFrom),
539
+ howToSetTheDecision: T.EQUAL,
540
+ decisionDataType: D.DATE
516
541
  }),
517
542
  type: "decision"
518
543
  },
519
- o.terms
544
+ a.terms
520
545
  )
521
546
  ] })
522
547
  ]
523
548
  }
524
549
  ) })
525
- ] }) : /* @__PURE__ */ u(d, { direction: "column", gap: "12px", children: [
526
- /* @__PURE__ */ u(d, { direction: "column", alignItems: "center", gap: "4px", children: [
527
- /* @__PURE__ */ r(T, { animated: !0, width: "180px" }),
528
- /* @__PURE__ */ r(T, { animated: !0, width: "85px" })
550
+ ] }) : /* @__PURE__ */ c(d, { direction: "column", gap: "12px", children: [
551
+ /* @__PURE__ */ c(d, { direction: "column", alignItems: "center", gap: "4px", children: [
552
+ /* @__PURE__ */ i(C, { animated: !0, width: "180px" }),
553
+ /* @__PURE__ */ i(C, { animated: !0, width: "85px" })
529
554
  ] }, "loading"),
530
- /* @__PURE__ */ u(d, { direction: "column", gap: "12px", alignItems: "center", children: [
531
- /* @__PURE__ */ r(w, { dashed: !0 }),
532
- /* @__PURE__ */ r(T, { animated: !0, width: "150px" })
555
+ /* @__PURE__ */ c(d, { direction: "column", gap: "12px", alignItems: "center", children: [
556
+ /* @__PURE__ */ i(w, { dashed: !0 }),
557
+ /* @__PURE__ */ i(C, { animated: !0, width: "150px" })
533
558
  ] }),
534
- /* @__PURE__ */ r(G, { children: /* @__PURE__ */ r(
559
+ /* @__PURE__ */ i(P, { children: /* @__PURE__ */ i(
535
560
  d,
536
561
  {
537
562
  direction: "column",
538
563
  gap: "12px",
539
564
  justifyContent: "space-between",
540
565
  height: "203px",
541
- children: Array.from({ length: 5 }).map((a, s) => /* @__PURE__ */ r(j, { children: /* @__PURE__ */ u(
566
+ children: Array.from({ length: 5 }).map((o, s) => /* @__PURE__ */ i(M, { children: /* @__PURE__ */ c(
542
567
  d,
543
568
  {
544
569
  direction: "column",
@@ -546,17 +571,17 @@ const Y = (e) => {
546
571
  alignItems: "start",
547
572
  padding: "8px",
548
573
  children: [
549
- /* @__PURE__ */ r(T, { animated: !0, width: "180px" }),
550
- /* @__PURE__ */ r(T, { animated: !0, width: "85px" })
574
+ /* @__PURE__ */ i(C, { animated: !0, width: "180px" }),
575
+ /* @__PURE__ */ i(C, { animated: !0, width: "85px" })
551
576
  ]
552
577
  }
553
578
  ) }, `condition-${s}`))
554
579
  }
555
580
  ) })
556
581
  ] });
557
- }, Le = g.div`
582
+ }, Le = b.div`
558
583
  border-radius: 8px;
559
- border: 1px solid ${v.palette.neutral.N30};
584
+ border: 1px solid ${x.palette.neutral.N30};
560
585
  box-sizing: border-box;
561
586
  display: flex;
562
587
  flex-direction: column;
@@ -566,7 +591,7 @@ const Y = (e) => {
566
591
  height: 100%;
567
592
  box-shadow: 0px 4px 8px 3px rgba(0, 0, 0, 0.1);
568
593
  `;
569
- g.div`
594
+ b.div`
570
595
  width: 100%;
571
596
  height: 100%;
572
597
  overflow-y: auto;
@@ -585,35 +610,35 @@ g.div`
585
610
  border-radius: 8px;
586
611
  }
587
612
  `;
588
- const F = (e) => {
589
- const { children: t, controls: n = !0, handleDelete: o, id: l } = e;
590
- return /* @__PURE__ */ r(Le, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "16px", padding: "12px 16px", children: [
591
- t,
592
- n && /* @__PURE__ */ u(E, { children: [
593
- /* @__PURE__ */ r(w, {}),
594
- /* @__PURE__ */ r(d, { gap: "16px", justifyContent: "end", children: /* @__PURE__ */ r(
613
+ const _ = (t) => {
614
+ const { children: e, controls: n = !0, handleDelete: a, id: r } = t;
615
+ return /* @__PURE__ */ i(Le, { children: /* @__PURE__ */ c(d, { direction: "column", gap: "16px", padding: "12px 16px", children: [
616
+ e,
617
+ n && /* @__PURE__ */ c(N, { children: [
618
+ /* @__PURE__ */ i(w, {}),
619
+ /* @__PURE__ */ i(d, { gap: "16px", justifyContent: "end", children: /* @__PURE__ */ i(
595
620
  Q,
596
621
  {
597
622
  cursorHover: !0,
598
623
  appearance: "dark",
599
624
  size: "24px",
600
- icon: /* @__PURE__ */ r(oe, {}),
625
+ icon: /* @__PURE__ */ i(re, {}),
601
626
  onClick: () => {
602
- o(l);
627
+ a(r);
603
628
  }
604
629
  }
605
630
  ) })
606
631
  ] })
607
632
  ] }) });
608
- }, Ve = g.div`
633
+ }, Ve = b.div`
609
634
  position: relative;
610
635
  & > div {
611
636
  padding: 24px 16px;
612
637
  }
613
- `, Re = g.div`
614
- background-color: ${({ theme: e }) => {
615
- var t, n;
616
- return ((n = (t = e == null ? void 0 : e.palette) == null ? void 0 : t.neutral) == null ? void 0 : n.N0) || v.palette.neutral.N0;
638
+ `, Ie = b.div`
639
+ background-color: ${({ theme: t }) => {
640
+ var e, n;
641
+ return ((n = (e = t == null ? void 0 : t.palette) == null ? void 0 : e.neutral) == null ? void 0 : n.N0) || x.palette.neutral.N0;
617
642
  }};
618
643
  max-width: 450px;
619
644
  max-height: 90vh;
@@ -641,23 +666,23 @@ const F = (e) => {
641
666
  background-color: #ebecf0;
642
667
  border-radius: 8px;
643
668
  }
644
- `, Ue = (e) => {
645
- const { children: t, portalId: n, onCloseModal: o, title: l } = e, a = document.getElementById(n);
646
- if (!a)
669
+ `, Re = (t) => {
670
+ const { children: e, portalId: n, onCloseModal: a, title: r } = t, o = document.getElementById(n);
671
+ if (!o)
647
672
  throw new Error(
648
673
  "The portal node is not defined. This can occur when the specific node used to render the portal has not been defined correctly."
649
674
  );
650
- return le(
651
- /* @__PURE__ */ r(Ve, { children: /* @__PURE__ */ r(se, { children: /* @__PURE__ */ r(Re, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "24px", children: [
652
- /* @__PURE__ */ r(d, { direction: "column", gap: "24px", children: /* @__PURE__ */ u(d, { alignItems: "center", justifyContent: "space-between", children: [
653
- /* @__PURE__ */ r(x, { type: "title", size: "large", appearance: "dark", weight: "bold", children: l }),
654
- /* @__PURE__ */ r(ie, { size: "24px", cursor: "pointer", onClick: o })
675
+ return de(
676
+ /* @__PURE__ */ i(Ve, { children: /* @__PURE__ */ i(se, { children: /* @__PURE__ */ i(Ie, { children: /* @__PURE__ */ c(d, { direction: "column", gap: "24px", children: [
677
+ /* @__PURE__ */ i(d, { direction: "column", gap: "24px", children: /* @__PURE__ */ c(d, { alignItems: "center", justifyContent: "space-between", children: [
678
+ /* @__PURE__ */ i(f, { type: "title", size: "large", appearance: "dark", weight: "bold", children: r }),
679
+ /* @__PURE__ */ i(oe, { size: "24px", cursor: "pointer", onClick: a })
655
680
  ] }) }),
656
- t
681
+ e
657
682
  ] }) }) }) }),
658
- a
683
+ o
659
684
  );
660
- }, Ie = ae`
685
+ }, Ue = ne`
661
686
  from {
662
687
  opacity: 0;
663
688
  transform: translateY(20px);
@@ -666,16 +691,16 @@ const F = (e) => {
666
691
  opacity: 1;
667
692
  transform: translateY(0);
668
693
  }
669
- `, W = g.div`
694
+ `, W = b.div`
670
695
  width: 100%;
671
696
  height: 100%;
672
697
  & > div {
673
- animation: ${Ie} 600ms ease-out;
698
+ animation: ${Ue} 600ms ease-out;
674
699
  }
675
700
  `;
676
- g.div`
701
+ b.div`
677
702
  border-radius: 8px;
678
- border: 1px solid ${v.palette.neutral.N30};
703
+ border: 1px solid ${x.palette.neutral.N30};
679
704
  box-sizing: border-box;
680
705
  display: flex;
681
706
  flex-direction: column;
@@ -685,7 +710,7 @@ g.div`
685
710
  height: 100%;
686
711
  box-shadow: 0px 4px 8px 3px rgba(0, 0, 0, 0.1);
687
712
  `;
688
- const Fe = g.div`
713
+ const _e = b.div`
689
714
  & > div {
690
715
  width: 100%;
691
716
  height: 100%;
@@ -705,16 +730,16 @@ const Fe = g.div`
705
730
  border-radius: 8px;
706
731
  }
707
732
  }
708
- `, $e = g.div`
733
+ `, $e = b.div`
709
734
  & > div > div {
710
735
  border-radius: 8px;
711
- border: 1px solid ${v.palette.neutral.N30};
736
+ border: 1px solid ${x.palette.neutral.N30};
712
737
  box-sizing: border-box;
713
738
  box-shadow: 0px 4px 8px 3px rgba(0, 0, 0, 0.1);
714
739
  }
715
- `, ze = g.div`
740
+ `, ze = b.div`
716
741
  & > div {
717
- background-color: ${v.palette.neutral.N30};
742
+ background-color: ${x.palette.neutral.N30};
718
743
  justify-content: center;
719
744
  }
720
745
  min-height: 300px;
@@ -722,139 +747,145 @@ const Fe = g.div`
722
747
  height: 100%;
723
748
  padding-bottom: 12px;
724
749
  `;
725
- g.div`
750
+ b.div`
726
751
  & > div {
727
752
  border-radius: 8px;
728
- border: 1px solid ${v.palette.neutral.N30};
753
+ border: 1px solid ${x.palette.neutral.N30};
729
754
  }
730
755
  `;
731
756
  function qe({
732
- index: e,
733
- handleOpenModal: t
757
+ index: t,
758
+ handleOpenModal: e
734
759
  }) {
735
- return /* @__PURE__ */ r(
736
- F,
760
+ return /* @__PURE__ */ i(
761
+ _,
737
762
  {
738
- id: `loading-card-${e}`,
763
+ id: `loading-card-${t}`,
739
764
  handleDelete: () => {
740
765
  },
741
- handleView: () => t(),
766
+ handleView: () => e ? e() : null,
742
767
  controls: !1,
743
- children: /* @__PURE__ */ r(Y, { loading: !0 })
768
+ children: /* @__PURE__ */ i(Y, { loading: !0 })
744
769
  },
745
- `loading-card-${e}`
770
+ `loading-card-${t}`
746
771
  );
747
772
  }
748
- function Me({
749
- decision: e,
750
- controls: t,
773
+ function Oe({
774
+ decision: t,
775
+ controls: e,
751
776
  handleOpenModal: n,
752
- handleDelete: o,
753
- textValues: l
777
+ handleDelete: a,
778
+ textValues: r
754
779
  }) {
755
- return e ? /* @__PURE__ */ r(W, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "4px", width: "100%", padding: "0 0 12px 0", children: [
756
- /* @__PURE__ */ r(x, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: e.id }),
757
- /* @__PURE__ */ r(
758
- F,
780
+ return t ? /* @__PURE__ */ i(W, { children: /* @__PURE__ */ c(d, { direction: "column", gap: "4px", width: "100%", padding: "0 0 12px 0", children: [
781
+ /* @__PURE__ */ i(f, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: t.decisionId }),
782
+ /* @__PURE__ */ i(
783
+ _,
759
784
  {
760
- id: e.id,
761
- handleDelete: () => o(e.id),
762
- handleView: () => n(e),
763
- controls: t,
764
- children: /* @__PURE__ */ r(Y, { decision: e, textValues: l })
785
+ id: t.decisionId,
786
+ handleDelete: () => a ? a(t.decisionId) : null,
787
+ handleView: () => n ? n(t) : null,
788
+ controls: e,
789
+ children: /* @__PURE__ */ i(Y, { decision: t, textValues: r })
765
790
  }
766
791
  )
767
- ] }) }, e.id) : null;
792
+ ] }) }, t.decisionId) : null;
768
793
  }
769
- function He({
770
- index: e,
771
- handleOpenModal: t
794
+ function je({
795
+ index: t,
796
+ handleOpenModal: e
772
797
  }) {
773
- return /* @__PURE__ */ r(W, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "4px", width: "100%", height: "100%", children: [
774
- /* @__PURE__ */ r(x, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: "Nueva decisión" }),
775
- /* @__PURE__ */ r(ze, { onClick: () => t(), children: /* @__PURE__ */ r(
776
- F,
798
+ return /* @__PURE__ */ i(W, { children: /* @__PURE__ */ c(d, { direction: "column", gap: "4px", width: "100%", height: "100%", children: [
799
+ /* @__PURE__ */ i(f, { type: "title", size: "medium", appearance: "gray", weight: "bold", children: "Nueva decisión" }),
800
+ /* @__PURE__ */ i(
801
+ ze,
777
802
  {
778
- id: `add-decision-${e}`,
779
- handleDelete: () => {
780
- },
781
- handleView: () => t(),
782
- controls: !1,
783
- children: /* @__PURE__ */ u(d, { direction: "column", gap: "12px", alignItems: "center", children: [
784
- /* @__PURE__ */ r(Q, { appearance: "gray", icon: /* @__PURE__ */ r(de, {}), size: "35px" }),
785
- /* @__PURE__ */ r(x, { appearance: "gray", type: "body", size: "large", children: "Agregar decisión" })
786
- ] })
803
+ onClick: () => e ? e() : null,
804
+ children: /* @__PURE__ */ i(
805
+ _,
806
+ {
807
+ id: `add-decision-${t}`,
808
+ handleDelete: () => {
809
+ },
810
+ handleView: () => e ? e() : null,
811
+ controls: !1,
812
+ children: /* @__PURE__ */ c(d, { direction: "column", gap: "12px", alignItems: "center", children: [
813
+ /* @__PURE__ */ i(Q, { appearance: "gray", icon: /* @__PURE__ */ i(le, {}), size: "35px" }),
814
+ /* @__PURE__ */ i(f, { appearance: "gray", type: "body", size: "large", children: "Agregar decisión" })
815
+ ] })
816
+ }
817
+ )
787
818
  }
788
- ) })
789
- ] }) }, `add-decision-${e}`);
819
+ )
820
+ ] }) }, `add-decision-${t}`);
790
821
  }
791
- const Oe = {
822
+ const He = {
792
823
  loading: qe,
793
- decision: Me,
794
- add: He
824
+ decision: Oe,
825
+ add: je
795
826
  };
796
- function U(e) {
797
- const { type: t } = e, n = Oe[t];
798
- return n ? n(e) : null;
827
+ function R(t) {
828
+ const { type: e } = t, n = He[e];
829
+ return n ? n(t) : null;
799
830
  }
800
- function je({
801
- controls: e,
802
- decisions: t,
831
+ function Me({
832
+ controls: t,
833
+ decisions: e,
803
834
  loading: n,
804
- handleOpenModal: o,
805
- handleDelete: l,
806
- textValues: a
835
+ handleOpenModal: a,
836
+ handleDelete: r,
837
+ textValues: o
807
838
  }) {
808
839
  const s = n ? Array.from({ length: 3 }).map(
809
- (h, i) => U({
840
+ (u, l) => R({
810
841
  type: "loading",
811
- index: i,
812
- controls: e,
842
+ index: l,
843
+ controls: t,
813
844
  loading: n,
814
- handleOpenModal: o,
815
- handleDelete: l,
816
- textValues: a
845
+ handleOpenModal: a,
846
+ handleDelete: r,
847
+ textValues: o
817
848
  })
818
- ) : t.map(
819
- (h) => U({
849
+ ) : e.map(
850
+ (u) => R({
820
851
  type: "decision",
821
- decision: h,
822
- controls: e,
852
+ decision: u,
853
+ controls: t,
823
854
  loading: n,
824
- handleOpenModal: o,
825
- handleDelete: l,
826
- textValues: a
855
+ handleOpenModal: a,
856
+ handleDelete: r,
857
+ textValues: o
827
858
  })
828
- ), c = (t.length === 0 || t.length < Math.floor(window.innerWidth / 300)) && !n && e;
829
- return { renderedCards: s, shouldRenderAddCard: c };
859
+ ), h = (e.length === 0 || e.length < Math.floor(window.innerWidth / 300)) && !n && t;
860
+ return { renderedCards: s, shouldRenderAddCard: h };
830
861
  }
831
- const mt = (e) => {
862
+ const gt = (t) => {
832
863
  const {
833
- controls: t = !0,
864
+ controls: e = !0,
834
865
  decisions: n,
835
- textValues: o,
836
- decisionTemplate: l,
837
- isModalOpen: a,
866
+ textValues: a,
867
+ decisionTemplate: r,
868
+ isModalOpen: o,
838
869
  selectedDecision: s,
839
- loading: c,
840
- handleOpenModal: h,
841
- handleCloseModal: i,
842
- handleSubmitForm: m,
843
- handleDelete: p
844
- } = e, f = ue("(max-width: 681px)"), { renderedCards: S, shouldRenderAddCard: A } = je({
845
- controls: t,
870
+ loading: h,
871
+ handleOpenModal: u,
872
+ handleCloseModal: l,
873
+ handleSubmitForm: p,
874
+ handleDelete: m
875
+ } = t, g = he("(max-width: 681px)"), { renderedCards: k, shouldRenderAddCard: S } = Me({
876
+ controls: e,
846
877
  decisions: n,
847
- loading: c,
848
- handleOpenModal: h,
849
- handleDelete: p,
850
- textValues: o
878
+ loading: h,
879
+ handleOpenModal: u,
880
+ handleDelete: m,
881
+ textValues: a
851
882
  });
852
- return /* @__PURE__ */ u(E, { children: [
853
- /* @__PURE__ */ r($e, { children: /* @__PURE__ */ r(Fe, { children: /* @__PURE__ */ u(d, { direction: "column", gap: "16px", padding: "6px", children: [
854
- n.length === 0 && !c && /* @__PURE__ */ u(x, { as: "span", type: "label", size: "large", appearance: "gray", children: [
883
+ return /* @__PURE__ */ c(N, { children: [
884
+ /* @__PURE__ */ i($e, { children: /* @__PURE__ */ i(_e, { children: /* @__PURE__ */ c(d, { direction: "column", gap: "16px", padding: "6px", children: [
885
+ n.length === 0 && !h && /* @__PURE__ */ c(f, { as: "span", type: "label", size: "large", appearance: "gray", children: [
855
886
  "Aún no tienes definidas tasas de interés efectivas. Presiona",
856
- /* @__PURE__ */ r(
857
- x,
887
+ /* @__PURE__ */ i(
888
+ f,
858
889
  {
859
890
  as: "span",
860
891
  type: "label",
@@ -866,7 +897,7 @@ const mt = (e) => {
866
897
  ),
867
898
  "para empezar."
868
899
  ] }),
869
- /* @__PURE__ */ u(
900
+ /* @__PURE__ */ c(
870
901
  ce,
871
902
  {
872
903
  templateColumns: "repeat(auto-fill, minmax(300px, 1fr))",
@@ -877,45 +908,114 @@ const mt = (e) => {
877
908
  autoRows: "1fr",
878
909
  justifyItems: "center",
879
910
  padding: "6px",
880
- height: f ? "auto" : "484px",
911
+ height: g ? "auto" : "484px",
881
912
  children: [
882
- S,
883
- A && U({
913
+ k,
914
+ S && R({
884
915
  type: "add",
885
916
  index: n.length,
886
- controls: t,
887
- loading: c,
888
- handleOpenModal: h,
889
- handleDelete: p,
890
- textValues: o
917
+ controls: e,
918
+ loading: h,
919
+ handleOpenModal: u,
920
+ handleDelete: m,
921
+ textValues: a
891
922
  })
892
923
  ]
893
924
  }
894
925
  )
895
926
  ] }) }) }),
896
- a && /* @__PURE__ */ r(
897
- Ue,
927
+ o && /* @__PURE__ */ i(
928
+ Re,
898
929
  {
899
930
  portalId: "modal-portal",
900
- onCloseModal: i,
931
+ onCloseModal: l,
901
932
  title: s ? "Editar Decisión" : "Nueva decisión",
902
- children: /* @__PURE__ */ r(
933
+ children: /* @__PURE__ */ i(
903
934
  we,
904
935
  {
905
- decision: s || l,
906
- onSubmitEvent: m,
907
- textValues: o,
908
- onCancel: () => i()
936
+ decision: s || r,
937
+ onSubmitEvent: p,
938
+ textValues: a,
939
+ onCancel: () => l ? l() : () => {
940
+ }
909
941
  }
910
942
  )
911
943
  }
912
944
  )
913
945
  ] });
914
- };
946
+ }, bt = (t) => {
947
+ var a;
948
+ const e = { ...t }, n = (a = e.conditionThatEstablishesTheDecision) == null ? void 0 : a.find(
949
+ (r) => r.switchPlaces
950
+ );
951
+ return n ? {
952
+ ...e,
953
+ ruleName: n.conditionName,
954
+ labelName: n.labelName,
955
+ decisionDataType: n.conditionDataType,
956
+ value: n.value,
957
+ howToSetTheDecision: n.howToSetTheCondition,
958
+ conditionThatEstablishesTheDecision: e.conditionThatEstablishesTheDecision.map(
959
+ (r) => r.conditionName === n.conditionName ? { ...r, hidden: !0 } : r
960
+ )
961
+ } : e;
962
+ }, Tt = (t) => t.map((e) => {
963
+ var a;
964
+ const n = (a = e.conditionThatEstablishesTheDecision) == null ? void 0 : a.find(
965
+ (r) => r.switchPlaces
966
+ );
967
+ return n ? {
968
+ ...e,
969
+ ruleName: n.conditionName,
970
+ labelName: n.labelName,
971
+ decisionDataType: n.conditionDataType,
972
+ value: n.value,
973
+ howToSetTheDecision: n.howToSetTheCondition,
974
+ conditionThatEstablishesTheDecision: e.conditionThatEstablishesTheDecision.map(
975
+ (r) => r.conditionName === n.conditionName ? { ...r, hidden: !0 } : r
976
+ )
977
+ } : e;
978
+ }), ft = (t, e) => {
979
+ const n = {
980
+ conditionName: t.ruleName || "",
981
+ labelName: t.labelName || "",
982
+ conditionDataType: t.decisionDataType || "alphabetical",
983
+ value: t.value || "",
984
+ howToSetTheCondition: t.howToSetTheDecision || "EqualTo",
985
+ switchPlaces: !0,
986
+ hidden: !1
987
+ };
988
+ return {
989
+ ...e,
990
+ conditionThatEstablishesTheDecision: e.conditionThatEstablishesTheDecision.map(
991
+ (a) => a.hidden ? { ...n } : a
992
+ )
993
+ };
994
+ }, yt = (t) => t.map((e) => {
995
+ var a;
996
+ const n = (a = e.conditionThatEstablishesTheDecision) == null ? void 0 : a.find(
997
+ (r) => r.hidden
998
+ );
999
+ return n ? {
1000
+ ...e,
1001
+ ruleName: e.ruleName,
1002
+ labelName: e.labelName,
1003
+ decisionDataType: e.decisionDataType,
1004
+ value: e.value,
1005
+ howToSetTheDecision: e.howToSetTheDecision,
1006
+ conditionThatEstablishesTheDecision: e.conditionThatEstablishesTheDecision.map(
1007
+ (r) => r.hidden ? { ...n, hidden: !1 } : r
1008
+ )
1009
+ } : e;
1010
+ });
915
1011
  export {
916
- F as BusinessRuleCard,
1012
+ _ as BusinessRuleCard,
917
1013
  Y as BusinessRuleView,
918
- mt as BusinessRules,
919
- Ue as ModalRules,
920
- we as RulesForm
1014
+ gt as BusinessRules,
1015
+ Re as ModalRules,
1016
+ we as RulesForm,
1017
+ ft as revertSortedDataSampleSwitchPlaces,
1018
+ yt as revertSortedDataSwitchPlaces,
1019
+ bt as sortDisplayDataSampleSwitchPlaces,
1020
+ Tt as sortDisplayDataSwitchPlaces
921
1021
  };