@socotra/ec-react-utils 2.2.5 → 2.3.0-next.0

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,25 +1,25 @@
1
1
  const q = (t) => {
2
- const { data: e, scope: a, dataTypes: f, rootDisplayName: b, account: d, quote: g, element: p } = t, M = [];
3
- let P = {};
4
- const C = Object.fromEntries(
2
+ const { data: e, scope: i, dataTypes: o, rootDisplayName: v, account: d, quote: D, element: p } = t, x = [];
3
+ let E = {};
4
+ const B = Object.fromEntries(
5
5
  Object.entries(e ?? {}).filter(([, h]) => {
6
6
  var O;
7
- const r = (O = h.scope) == null ? void 0 : O.split(",").map((Y) => Y.trim());
8
- return !!(!r || a === "P" && (r != null && r.includes("P")) || r != null && r.includes("Q") || a === "Q" && (r != null && r.includes("Q")));
7
+ const r = (O = h.scope) == null ? void 0 : O.split(",").map((j) => j.trim());
8
+ return !!(!r || i === "P" && (r != null && r.includes("P")) || r != null && r.includes("Q") || i === "Q" && (r != null && r.includes("Q")));
9
9
  }).map(([h, r]) => {
10
- var H, z, u, i, n, c, s, o, l, y, D, x, T, S, N, I, A;
11
- let O = !1, Y = !1, W = !1;
12
- const R = r.displayName ?? h, Z = (H = r.type) == null ? void 0 : H.slice(-1), V = r.maxLength, B = r.minLength, _ = r.max, j = r.min, F = r.regex;
13
- let m = r.type ?? "", L;
14
- switch (Z) {
10
+ var V, z, c, a, n, u, s, l, f, $, b, w, M, S, N, I, A;
11
+ let O = !1, j = !1, W = !1;
12
+ const Z = r.displayName ?? h, U = (V = r.type) == null ? void 0 : V.slice(-1), C = r.maxLength, H = r.minLength, _ = r.max, L = r.min, F = r.regex;
13
+ let m = r.type ?? "", Y;
14
+ switch (U) {
15
15
  case "*":
16
- Y = !0, O = !0, m = m == null ? void 0 : m.split("*")[0];
16
+ j = !0, O = !0, m = m == null ? void 0 : m.split("*")[0];
17
17
  break;
18
18
  case "?":
19
19
  m = m == null ? void 0 : m.split("?")[0], O = !0;
20
20
  break;
21
21
  case "+":
22
- Y = !0, m = m == null ? void 0 : m.split("+")[0];
22
+ j = !0, m = m == null ? void 0 : m.split("+")[0];
23
23
  break;
24
24
  case "!":
25
25
  m = m == null ? void 0 : m.split("!")[0];
@@ -38,10 +38,10 @@ const q = (t) => {
38
38
  break;
39
39
  case "dateTime":
40
40
  case "datetime":
41
- m = "string", L = "date-time";
41
+ m = "string", Y = "date-time";
42
42
  break;
43
43
  case "date":
44
- m = "string", L = "date";
44
+ m = "string", Y = "date";
45
45
  break;
46
46
  case "boolean":
47
47
  case "bool":
@@ -51,25 +51,25 @@ const q = (t) => {
51
51
  W = !0;
52
52
  break;
53
53
  }
54
- if (!O && !W && !Y && M.push(h), W) {
55
- const k = f == null ? void 0 : f[m];
54
+ if (!O && !W && !j && x.push(h), W) {
55
+ const k = o == null ? void 0 : o[m];
56
56
  if (k) {
57
- let w = Y ? [] : {};
57
+ let T = j ? [] : {};
58
58
  const Q = q({
59
59
  data: k.data ?? {},
60
- scope: a,
61
- dataTypes: f,
60
+ scope: i,
61
+ dataTypes: o,
62
62
  rootDisplayName: k.displayName ?? h
63
63
  });
64
- return g && (u = (z = g.element) == null ? void 0 : z.data) != null && u[h] && (w = (n = (i = g.element) == null ? void 0 : i.data) == null ? void 0 : n[h]), p && (c = p == null ? void 0 : p.data) != null && c[h] && (w = (s = p == null ? void 0 : p.data) == null ? void 0 : s[h]), d && (o = d == null ? void 0 : d.data) != null && o[h] && (w = (l = d == null ? void 0 : d.data) == null ? void 0 : l[h]), P = {
65
- ...P,
64
+ return D && (c = (z = D.element) == null ? void 0 : z.data) != null && c[h] && (T = (n = (a = D.element) == null ? void 0 : a.data) == null ? void 0 : n[h]), p && (u = p == null ? void 0 : p.data) != null && u[h] && (T = (s = p == null ? void 0 : p.data) == null ? void 0 : s[h]), d && (l = d == null ? void 0 : d.data) != null && l[h] && (T = (f = d == null ? void 0 : d.data) == null ? void 0 : f[h]), E = {
65
+ ...E,
66
66
  [`${m}`]: Q
67
- }, Y ? [
67
+ }, j ? [
68
68
  h,
69
69
  {
70
70
  title: k.displayName ?? h,
71
71
  type: "array",
72
- default: w,
72
+ default: T,
73
73
  items: {
74
74
  $ref: `#/definitions/${m}`
75
75
  },
@@ -79,30 +79,30 @@ const q = (t) => {
79
79
  h,
80
80
  {
81
81
  title: k.displayName ?? h,
82
- default: w,
82
+ default: T,
83
83
  $ref: `#/definitions/${m}`
84
84
  }
85
85
  ];
86
86
  }
87
87
  }
88
- let v = "";
88
+ let y = "";
89
89
  if (d) {
90
90
  const k = (d == null ? void 0 : d.state) === "validated" ? h.charAt(0).toLowerCase() + h.slice(1) : h;
91
- v = (y = d == null ? void 0 : d.data) != null && y[k] ? (D = d == null ? void 0 : d.data) == null ? void 0 : D[k] : m === "boolean" ? !!r.defaultValue : r.defaultValue;
91
+ y = ($ = d == null ? void 0 : d.data) != null && $[k] ? (b = d == null ? void 0 : d.data) == null ? void 0 : b[k] : m === "boolean" ? !!r.defaultValue : r.defaultValue;
92
92
  }
93
- return g && (v = (T = (x = g.element) == null ? void 0 : x.data) != null && T[h] ? (N = (S = g.element) == null ? void 0 : S.data) == null ? void 0 : N[h] : m === "boolean" ? !!r.defaultValue : r.defaultValue), p && (v = (I = p == null ? void 0 : p.data) != null && I[h] ? (A = p == null ? void 0 : p.data) == null ? void 0 : A[h] : m === "boolean" ? !!r.defaultValue : r.defaultValue), Y ? [
93
+ return D && (y = (M = (w = D.element) == null ? void 0 : w.data) != null && M[h] ? (N = (S = D.element) == null ? void 0 : S.data) == null ? void 0 : N[h] : m === "boolean" ? !!r.defaultValue : r.defaultValue), p && (y = (I = p == null ? void 0 : p.data) != null && I[h] ? (A = p == null ? void 0 : p.data) == null ? void 0 : A[h] : m === "boolean" ? !!r.defaultValue : r.defaultValue), j ? [
94
94
  h,
95
95
  {
96
- title: R,
96
+ title: Z,
97
97
  type: "array",
98
- default: v,
98
+ default: y,
99
99
  items: {
100
100
  type: m,
101
- ...V && { maxLength: V },
102
- ...B && { minLength: B },
103
- ...j && { min: j },
101
+ ...C && { maxLength: C },
102
+ ...H && { minLength: H },
103
+ ...L && { min: L },
104
104
  ..._ && { max: _ },
105
- ...L && { format: L },
105
+ ...Y && { format: Y },
106
106
  ...F && { pattern: r.regex }
107
107
  },
108
108
  ...!O && { minItems: 1 }
@@ -110,14 +110,14 @@ const q = (t) => {
110
110
  ] : [
111
111
  h,
112
112
  {
113
- title: R,
113
+ title: Z,
114
114
  type: m,
115
- ...v && { default: v },
116
- ...B && { minLength: B },
117
- ...V && { maxLength: V },
118
- ...j && { minimum: parseInt(j) },
115
+ ...y && { default: y },
116
+ ...H && { minLength: H },
117
+ ...C && { maxLength: C },
118
+ ...L && { minimum: parseInt(L) },
119
119
  ..._ && { maximum: parseInt(_) },
120
- ...L && { format: L },
120
+ ...Y && { format: Y },
121
121
  ...r.options && { enum: r.options },
122
122
  ...F && { pattern: r.regex }
123
123
  }
@@ -125,13 +125,13 @@ const q = (t) => {
125
125
  })
126
126
  );
127
127
  return {
128
- title: b,
128
+ title: v,
129
129
  type: "object",
130
- definitions: P,
131
- required: M,
132
- properties: C
130
+ definitions: E,
131
+ required: x,
132
+ properties: B
133
133
  };
134
- }, oe = ({
134
+ }, le = ({
135
135
  formData: t,
136
136
  locator: e
137
137
  }) => ({
@@ -146,321 +146,321 @@ function te(t) {
146
146
  }
147
147
  var K = { exports: {} };
148
148
  (function(t, e) {
149
- (function(a, f) {
150
- t.exports = f();
149
+ (function(i, o) {
150
+ t.exports = o();
151
151
  })(ee, function() {
152
- var a = 1e3, f = 6e4, b = 36e5, d = "millisecond", g = "second", p = "minute", M = "hour", P = "day", C = "week", E = "month", h = "quarter", r = "year", O = "date", Y = "Invalid Date", W = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, R = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, Z = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(u) {
153
- var i = ["th", "st", "nd", "rd"], n = u % 100;
154
- return "[" + u + (i[(n - 20) % 10] || i[n] || i[0]) + "]";
155
- } }, V = function(u, i, n) {
156
- var c = String(u);
157
- return !c || c.length >= i ? u : "" + Array(i + 1 - c.length).join(n) + u;
158
- }, B = { s: V, z: function(u) {
159
- var i = -u.utcOffset(), n = Math.abs(i), c = Math.floor(n / 60), s = n % 60;
160
- return (i <= 0 ? "+" : "-") + V(c, 2, "0") + ":" + V(s, 2, "0");
161
- }, m: function u(i, n) {
162
- if (i.date() < n.date()) return -u(n, i);
163
- var c = 12 * (n.year() - i.year()) + (n.month() - i.month()), s = i.clone().add(c, E), o = n - s < 0, l = i.clone().add(c + (o ? -1 : 1), E);
164
- return +(-(c + (n - s) / (o ? s - l : l - s)) || 0);
165
- }, a: function(u) {
166
- return u < 0 ? Math.ceil(u) || 0 : Math.floor(u);
167
- }, p: function(u) {
168
- return { M: E, y: r, w: C, d: P, D: O, h: M, m: p, s: g, ms: d, Q: h }[u] || String(u || "").toLowerCase().replace(/s$/, "");
169
- }, u: function(u) {
170
- return u === void 0;
171
- } }, _ = "en", j = {};
172
- j[_] = Z;
173
- var F = "$isDayjsObject", m = function(u) {
174
- return u instanceof H || !(!u || !u[F]);
175
- }, L = function u(i, n, c) {
152
+ var i = 1e3, o = 6e4, v = 36e5, d = "millisecond", D = "second", p = "minute", x = "hour", E = "day", B = "week", P = "month", h = "quarter", r = "year", O = "date", j = "Invalid Date", W = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, Z = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, U = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(c) {
153
+ var a = ["th", "st", "nd", "rd"], n = c % 100;
154
+ return "[" + c + (a[(n - 20) % 10] || a[n] || a[0]) + "]";
155
+ } }, C = function(c, a, n) {
156
+ var u = String(c);
157
+ return !u || u.length >= a ? c : "" + Array(a + 1 - u.length).join(n) + c;
158
+ }, H = { s: C, z: function(c) {
159
+ var a = -c.utcOffset(), n = Math.abs(a), u = Math.floor(n / 60), s = n % 60;
160
+ return (a <= 0 ? "+" : "-") + C(u, 2, "0") + ":" + C(s, 2, "0");
161
+ }, m: function c(a, n) {
162
+ if (a.date() < n.date()) return -c(n, a);
163
+ var u = 12 * (n.year() - a.year()) + (n.month() - a.month()), s = a.clone().add(u, P), l = n - s < 0, f = a.clone().add(u + (l ? -1 : 1), P);
164
+ return +(-(u + (n - s) / (l ? s - f : f - s)) || 0);
165
+ }, a: function(c) {
166
+ return c < 0 ? Math.ceil(c) || 0 : Math.floor(c);
167
+ }, p: function(c) {
168
+ return { M: P, y: r, w: B, d: E, D: O, h: x, m: p, s: D, ms: d, Q: h }[c] || String(c || "").toLowerCase().replace(/s$/, "");
169
+ }, u: function(c) {
170
+ return c === void 0;
171
+ } }, _ = "en", L = {};
172
+ L[_] = U;
173
+ var F = "$isDayjsObject", m = function(c) {
174
+ return c instanceof V || !(!c || !c[F]);
175
+ }, Y = function c(a, n, u) {
176
176
  var s;
177
- if (!i) return _;
178
- if (typeof i == "string") {
179
- var o = i.toLowerCase();
180
- j[o] && (s = o), n && (j[o] = n, s = o);
181
- var l = i.split("-");
182
- if (!s && l.length > 1) return u(l[0]);
177
+ if (!a) return _;
178
+ if (typeof a == "string") {
179
+ var l = a.toLowerCase();
180
+ L[l] && (s = l), n && (L[l] = n, s = l);
181
+ var f = a.split("-");
182
+ if (!s && f.length > 1) return c(f[0]);
183
183
  } else {
184
- var y = i.name;
185
- j[y] = i, s = y;
184
+ var $ = a.name;
185
+ L[$] = a, s = $;
186
186
  }
187
- return !c && s && (_ = s), s || !c && _;
188
- }, v = function(u, i) {
189
- if (m(u)) return u.clone();
190
- var n = typeof i == "object" ? i : {};
191
- return n.date = u, n.args = arguments, new H(n);
192
- }, $ = B;
193
- $.l = L, $.i = m, $.w = function(u, i) {
194
- return v(u, { locale: i.$L, utc: i.$u, x: i.$x, $offset: i.$offset });
187
+ return !u && s && (_ = s), s || !u && _;
188
+ }, y = function(c, a) {
189
+ if (m(c)) return c.clone();
190
+ var n = typeof a == "object" ? a : {};
191
+ return n.date = c, n.args = arguments, new V(n);
192
+ }, g = H;
193
+ g.l = Y, g.i = m, g.w = function(c, a) {
194
+ return y(c, { locale: a.$L, utc: a.$u, x: a.$x, $offset: a.$offset });
195
195
  };
196
- var H = function() {
197
- function u(n) {
198
- this.$L = L(n.locale, null, !0), this.parse(n), this.$x = this.$x || n.x || {}, this[F] = !0;
196
+ var V = function() {
197
+ function c(n) {
198
+ this.$L = Y(n.locale, null, !0), this.parse(n), this.$x = this.$x || n.x || {}, this[F] = !0;
199
199
  }
200
- var i = u.prototype;
201
- return i.parse = function(n) {
202
- this.$d = function(c) {
203
- var s = c.date, o = c.utc;
200
+ var a = c.prototype;
201
+ return a.parse = function(n) {
202
+ this.$d = function(u) {
203
+ var s = u.date, l = u.utc;
204
204
  if (s === null) return /* @__PURE__ */ new Date(NaN);
205
- if ($.u(s)) return /* @__PURE__ */ new Date();
205
+ if (g.u(s)) return /* @__PURE__ */ new Date();
206
206
  if (s instanceof Date) return new Date(s);
207
207
  if (typeof s == "string" && !/Z$/i.test(s)) {
208
- var l = s.match(W);
209
- if (l) {
210
- var y = l[2] - 1 || 0, D = (l[7] || "0").substring(0, 3);
211
- return o ? new Date(Date.UTC(l[1], y, l[3] || 1, l[4] || 0, l[5] || 0, l[6] || 0, D)) : new Date(l[1], y, l[3] || 1, l[4] || 0, l[5] || 0, l[6] || 0, D);
208
+ var f = s.match(W);
209
+ if (f) {
210
+ var $ = f[2] - 1 || 0, b = (f[7] || "0").substring(0, 3);
211
+ return l ? new Date(Date.UTC(f[1], $, f[3] || 1, f[4] || 0, f[5] || 0, f[6] || 0, b)) : new Date(f[1], $, f[3] || 1, f[4] || 0, f[5] || 0, f[6] || 0, b);
212
212
  }
213
213
  }
214
214
  return new Date(s);
215
215
  }(n), this.init();
216
- }, i.init = function() {
216
+ }, a.init = function() {
217
217
  var n = this.$d;
218
218
  this.$y = n.getFullYear(), this.$M = n.getMonth(), this.$D = n.getDate(), this.$W = n.getDay(), this.$H = n.getHours(), this.$m = n.getMinutes(), this.$s = n.getSeconds(), this.$ms = n.getMilliseconds();
219
- }, i.$utils = function() {
220
- return $;
221
- }, i.isValid = function() {
222
- return this.$d.toString() !== Y;
223
- }, i.isSame = function(n, c) {
224
- var s = v(n);
225
- return this.startOf(c) <= s && s <= this.endOf(c);
226
- }, i.isAfter = function(n, c) {
227
- return v(n) < this.startOf(c);
228
- }, i.isBefore = function(n, c) {
229
- return this.endOf(c) < v(n);
230
- }, i.$g = function(n, c, s) {
231
- return $.u(n) ? this[c] : this.set(s, n);
232
- }, i.unix = function() {
219
+ }, a.$utils = function() {
220
+ return g;
221
+ }, a.isValid = function() {
222
+ return this.$d.toString() !== j;
223
+ }, a.isSame = function(n, u) {
224
+ var s = y(n);
225
+ return this.startOf(u) <= s && s <= this.endOf(u);
226
+ }, a.isAfter = function(n, u) {
227
+ return y(n) < this.startOf(u);
228
+ }, a.isBefore = function(n, u) {
229
+ return this.endOf(u) < y(n);
230
+ }, a.$g = function(n, u, s) {
231
+ return g.u(n) ? this[u] : this.set(s, n);
232
+ }, a.unix = function() {
233
233
  return Math.floor(this.valueOf() / 1e3);
234
- }, i.valueOf = function() {
234
+ }, a.valueOf = function() {
235
235
  return this.$d.getTime();
236
- }, i.startOf = function(n, c) {
237
- var s = this, o = !!$.u(c) || c, l = $.p(n), y = function(k, w) {
238
- var Q = $.w(s.$u ? Date.UTC(s.$y, w, k) : new Date(s.$y, w, k), s);
239
- return o ? Q : Q.endOf(P);
240
- }, D = function(k, w) {
241
- return $.w(s.toDate()[k].apply(s.toDate("s"), (o ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(w)), s);
242
- }, x = this.$W, T = this.$M, S = this.$D, N = "set" + (this.$u ? "UTC" : "");
243
- switch (l) {
236
+ }, a.startOf = function(n, u) {
237
+ var s = this, l = !!g.u(u) || u, f = g.p(n), $ = function(k, T) {
238
+ var Q = g.w(s.$u ? Date.UTC(s.$y, T, k) : new Date(s.$y, T, k), s);
239
+ return l ? Q : Q.endOf(E);
240
+ }, b = function(k, T) {
241
+ return g.w(s.toDate()[k].apply(s.toDate("s"), (l ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(T)), s);
242
+ }, w = this.$W, M = this.$M, S = this.$D, N = "set" + (this.$u ? "UTC" : "");
243
+ switch (f) {
244
244
  case r:
245
- return o ? y(1, 0) : y(31, 11);
246
- case E:
247
- return o ? y(1, T) : y(0, T + 1);
248
- case C:
249
- var I = this.$locale().weekStart || 0, A = (x < I ? x + 7 : x) - I;
250
- return y(o ? S - A : S + (6 - A), T);
245
+ return l ? $(1, 0) : $(31, 11);
251
246
  case P:
247
+ return l ? $(1, M) : $(0, M + 1);
248
+ case B:
249
+ var I = this.$locale().weekStart || 0, A = (w < I ? w + 7 : w) - I;
250
+ return $(l ? S - A : S + (6 - A), M);
251
+ case E:
252
252
  case O:
253
- return D(N + "Hours", 0);
254
- case M:
255
- return D(N + "Minutes", 1);
253
+ return b(N + "Hours", 0);
254
+ case x:
255
+ return b(N + "Minutes", 1);
256
256
  case p:
257
- return D(N + "Seconds", 2);
258
- case g:
259
- return D(N + "Milliseconds", 3);
257
+ return b(N + "Seconds", 2);
258
+ case D:
259
+ return b(N + "Milliseconds", 3);
260
260
  default:
261
261
  return this.clone();
262
262
  }
263
- }, i.endOf = function(n) {
263
+ }, a.endOf = function(n) {
264
264
  return this.startOf(n, !1);
265
- }, i.$set = function(n, c) {
266
- var s, o = $.p(n), l = "set" + (this.$u ? "UTC" : ""), y = (s = {}, s[P] = l + "Date", s[O] = l + "Date", s[E] = l + "Month", s[r] = l + "FullYear", s[M] = l + "Hours", s[p] = l + "Minutes", s[g] = l + "Seconds", s[d] = l + "Milliseconds", s)[o], D = o === P ? this.$D + (c - this.$W) : c;
267
- if (o === E || o === r) {
268
- var x = this.clone().set(O, 1);
269
- x.$d[y](D), x.init(), this.$d = x.set(O, Math.min(this.$D, x.daysInMonth())).$d;
270
- } else y && this.$d[y](D);
265
+ }, a.$set = function(n, u) {
266
+ var s, l = g.p(n), f = "set" + (this.$u ? "UTC" : ""), $ = (s = {}, s[E] = f + "Date", s[O] = f + "Date", s[P] = f + "Month", s[r] = f + "FullYear", s[x] = f + "Hours", s[p] = f + "Minutes", s[D] = f + "Seconds", s[d] = f + "Milliseconds", s)[l], b = l === E ? this.$D + (u - this.$W) : u;
267
+ if (l === P || l === r) {
268
+ var w = this.clone().set(O, 1);
269
+ w.$d[$](b), w.init(), this.$d = w.set(O, Math.min(this.$D, w.daysInMonth())).$d;
270
+ } else $ && this.$d[$](b);
271
271
  return this.init(), this;
272
- }, i.set = function(n, c) {
273
- return this.clone().$set(n, c);
274
- }, i.get = function(n) {
275
- return this[$.p(n)]();
276
- }, i.add = function(n, c) {
277
- var s, o = this;
272
+ }, a.set = function(n, u) {
273
+ return this.clone().$set(n, u);
274
+ }, a.get = function(n) {
275
+ return this[g.p(n)]();
276
+ }, a.add = function(n, u) {
277
+ var s, l = this;
278
278
  n = Number(n);
279
- var l = $.p(c), y = function(T) {
280
- var S = v(o);
281
- return $.w(S.date(S.date() + Math.round(T * n)), o);
279
+ var f = g.p(u), $ = function(M) {
280
+ var S = y(l);
281
+ return g.w(S.date(S.date() + Math.round(M * n)), l);
282
282
  };
283
- if (l === E) return this.set(E, this.$M + n);
284
- if (l === r) return this.set(r, this.$y + n);
285
- if (l === P) return y(1);
286
- if (l === C) return y(7);
287
- var D = (s = {}, s[p] = f, s[M] = b, s[g] = a, s)[l] || 1, x = this.$d.getTime() + n * D;
288
- return $.w(x, this);
289
- }, i.subtract = function(n, c) {
290
- return this.add(-1 * n, c);
291
- }, i.format = function(n) {
292
- var c = this, s = this.$locale();
293
- if (!this.isValid()) return s.invalidDate || Y;
294
- var o = n || "YYYY-MM-DDTHH:mm:ssZ", l = $.z(this), y = this.$H, D = this.$m, x = this.$M, T = s.weekdays, S = s.months, N = s.meridiem, I = function(w, Q, J, U) {
295
- return w && (w[Q] || w(c, o)) || J[Q].slice(0, U);
296
- }, A = function(w) {
297
- return $.s(y % 12 || 12, w, "0");
298
- }, k = N || function(w, Q, J) {
299
- var U = w < 12 ? "AM" : "PM";
300
- return J ? U.toLowerCase() : U;
283
+ if (f === P) return this.set(P, this.$M + n);
284
+ if (f === r) return this.set(r, this.$y + n);
285
+ if (f === E) return $(1);
286
+ if (f === B) return $(7);
287
+ var b = (s = {}, s[p] = o, s[x] = v, s[D] = i, s)[f] || 1, w = this.$d.getTime() + n * b;
288
+ return g.w(w, this);
289
+ }, a.subtract = function(n, u) {
290
+ return this.add(-1 * n, u);
291
+ }, a.format = function(n) {
292
+ var u = this, s = this.$locale();
293
+ if (!this.isValid()) return s.invalidDate || j;
294
+ var l = n || "YYYY-MM-DDTHH:mm:ssZ", f = g.z(this), $ = this.$H, b = this.$m, w = this.$M, M = s.weekdays, S = s.months, N = s.meridiem, I = function(T, Q, R, J) {
295
+ return T && (T[Q] || T(u, l)) || R[Q].slice(0, J);
296
+ }, A = function(T) {
297
+ return g.s($ % 12 || 12, T, "0");
298
+ }, k = N || function(T, Q, R) {
299
+ var J = T < 12 ? "AM" : "PM";
300
+ return R ? J.toLowerCase() : J;
301
301
  };
302
- return o.replace(R, function(w, Q) {
303
- return Q || function(J) {
304
- switch (J) {
302
+ return l.replace(Z, function(T, Q) {
303
+ return Q || function(R) {
304
+ switch (R) {
305
305
  case "YY":
306
- return String(c.$y).slice(-2);
306
+ return String(u.$y).slice(-2);
307
307
  case "YYYY":
308
- return $.s(c.$y, 4, "0");
308
+ return g.s(u.$y, 4, "0");
309
309
  case "M":
310
- return x + 1;
310
+ return w + 1;
311
311
  case "MM":
312
- return $.s(x + 1, 2, "0");
312
+ return g.s(w + 1, 2, "0");
313
313
  case "MMM":
314
- return I(s.monthsShort, x, S, 3);
314
+ return I(s.monthsShort, w, S, 3);
315
315
  case "MMMM":
316
- return I(S, x);
316
+ return I(S, w);
317
317
  case "D":
318
- return c.$D;
318
+ return u.$D;
319
319
  case "DD":
320
- return $.s(c.$D, 2, "0");
320
+ return g.s(u.$D, 2, "0");
321
321
  case "d":
322
- return String(c.$W);
322
+ return String(u.$W);
323
323
  case "dd":
324
- return I(s.weekdaysMin, c.$W, T, 2);
324
+ return I(s.weekdaysMin, u.$W, M, 2);
325
325
  case "ddd":
326
- return I(s.weekdaysShort, c.$W, T, 3);
326
+ return I(s.weekdaysShort, u.$W, M, 3);
327
327
  case "dddd":
328
- return T[c.$W];
328
+ return M[u.$W];
329
329
  case "H":
330
- return String(y);
330
+ return String($);
331
331
  case "HH":
332
- return $.s(y, 2, "0");
332
+ return g.s($, 2, "0");
333
333
  case "h":
334
334
  return A(1);
335
335
  case "hh":
336
336
  return A(2);
337
337
  case "a":
338
- return k(y, D, !0);
338
+ return k($, b, !0);
339
339
  case "A":
340
- return k(y, D, !1);
340
+ return k($, b, !1);
341
341
  case "m":
342
- return String(D);
342
+ return String(b);
343
343
  case "mm":
344
- return $.s(D, 2, "0");
344
+ return g.s(b, 2, "0");
345
345
  case "s":
346
- return String(c.$s);
346
+ return String(u.$s);
347
347
  case "ss":
348
- return $.s(c.$s, 2, "0");
348
+ return g.s(u.$s, 2, "0");
349
349
  case "SSS":
350
- return $.s(c.$ms, 3, "0");
350
+ return g.s(u.$ms, 3, "0");
351
351
  case "Z":
352
- return l;
352
+ return f;
353
353
  }
354
354
  return null;
355
- }(w) || l.replace(":", "");
355
+ }(T) || f.replace(":", "");
356
356
  });
357
- }, i.utcOffset = function() {
357
+ }, a.utcOffset = function() {
358
358
  return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
359
- }, i.diff = function(n, c, s) {
360
- var o, l = this, y = $.p(c), D = v(n), x = (D.utcOffset() - this.utcOffset()) * f, T = this - D, S = function() {
361
- return $.m(l, D);
359
+ }, a.diff = function(n, u, s) {
360
+ var l, f = this, $ = g.p(u), b = y(n), w = (b.utcOffset() - this.utcOffset()) * o, M = this - b, S = function() {
361
+ return g.m(f, b);
362
362
  };
363
- switch (y) {
363
+ switch ($) {
364
364
  case r:
365
- o = S() / 12;
365
+ l = S() / 12;
366
366
  break;
367
- case E:
368
- o = S();
367
+ case P:
368
+ l = S();
369
369
  break;
370
370
  case h:
371
- o = S() / 3;
371
+ l = S() / 3;
372
372
  break;
373
- case C:
374
- o = (T - x) / 6048e5;
373
+ case B:
374
+ l = (M - w) / 6048e5;
375
375
  break;
376
- case P:
377
- o = (T - x) / 864e5;
376
+ case E:
377
+ l = (M - w) / 864e5;
378
378
  break;
379
- case M:
380
- o = T / b;
379
+ case x:
380
+ l = M / v;
381
381
  break;
382
382
  case p:
383
- o = T / f;
383
+ l = M / o;
384
384
  break;
385
- case g:
386
- o = T / a;
385
+ case D:
386
+ l = M / i;
387
387
  break;
388
388
  default:
389
- o = T;
389
+ l = M;
390
390
  }
391
- return s ? o : $.a(o);
392
- }, i.daysInMonth = function() {
393
- return this.endOf(E).$D;
394
- }, i.$locale = function() {
395
- return j[this.$L];
396
- }, i.locale = function(n, c) {
391
+ return s ? l : g.a(l);
392
+ }, a.daysInMonth = function() {
393
+ return this.endOf(P).$D;
394
+ }, a.$locale = function() {
395
+ return L[this.$L];
396
+ }, a.locale = function(n, u) {
397
397
  if (!n) return this.$L;
398
- var s = this.clone(), o = L(n, c, !0);
399
- return o && (s.$L = o), s;
400
- }, i.clone = function() {
401
- return $.w(this.$d, this);
402
- }, i.toDate = function() {
398
+ var s = this.clone(), l = Y(n, u, !0);
399
+ return l && (s.$L = l), s;
400
+ }, a.clone = function() {
401
+ return g.w(this.$d, this);
402
+ }, a.toDate = function() {
403
403
  return new Date(this.valueOf());
404
- }, i.toJSON = function() {
404
+ }, a.toJSON = function() {
405
405
  return this.isValid() ? this.toISOString() : null;
406
- }, i.toISOString = function() {
406
+ }, a.toISOString = function() {
407
407
  return this.$d.toISOString();
408
- }, i.toString = function() {
408
+ }, a.toString = function() {
409
409
  return this.$d.toUTCString();
410
- }, u;
411
- }(), z = H.prototype;
412
- return v.prototype = z, [["$ms", d], ["$s", g], ["$m", p], ["$H", M], ["$W", P], ["$M", E], ["$y", r], ["$D", O]].forEach(function(u) {
413
- z[u[1]] = function(i) {
414
- return this.$g(i, u[0], u[1]);
410
+ }, c;
411
+ }(), z = V.prototype;
412
+ return y.prototype = z, [["$ms", d], ["$s", D], ["$m", p], ["$H", x], ["$W", E], ["$M", P], ["$y", r], ["$D", O]].forEach(function(c) {
413
+ z[c[1]] = function(a) {
414
+ return this.$g(a, c[0], c[1]);
415
415
  };
416
- }), v.extend = function(u, i) {
417
- return u.$i || (u(i, H, v), u.$i = !0), v;
418
- }, v.locale = L, v.isDayjs = m, v.unix = function(u) {
419
- return v(1e3 * u);
420
- }, v.en = j[_], v.Ls = j, v.p = {}, v;
416
+ }), y.extend = function(c, a) {
417
+ return c.$i || (c(a, V, y), c.$i = !0), y;
418
+ }, y.locale = Y, y.isDayjs = m, y.unix = function(c) {
419
+ return y(1e3 * c);
420
+ }, y.en = L[_], y.Ls = L, y.p = {}, y;
421
421
  });
422
422
  })(K);
423
423
  var ne = K.exports;
424
- const G = /* @__PURE__ */ te(ne), le = ({ data: t }) => {
425
- const e = {}, a = { ...t };
426
- return a.default && (a.default.startTime && (e.startTime = G(a.default.startTime).format()), a.default.endTime && (e.endTime = G(a.default.endTime).format()), a.default.expirationTime && (e.expirationTime = G(a.default.expirationTime).format())), a.advanced && (a.advanced.currency && (e.currency = a.advanced.currency), a.advanced.timezone && (e.timezone = a.advanced.timezone), a.advanced.billingPlan && (e.billingPlan = a.advanced.billingPlan), a.advanced.defaultTermDuration && (e.defaultTermDuration = a.advanced.defaultTermDuration), a.advanced.installmentPlan && (e.installmentPlan = a.advanced.installmentPlan), a.advanced.durationBasis && (e.durationBasis = a.advanced.durationBasis), a.advanced.delinquencyPlanName && (e.delinquencyPlanName = a.advanced.delinquencyPlanName)), delete a.default, delete a.advanced, e.setData = a, e;
424
+ const G = /* @__PURE__ */ te(ne), fe = ({ data: t }) => {
425
+ const e = {}, i = { ...t };
426
+ return i.default && (i.default.startTime && (e.startTime = G(i.default.startTime).format()), i.default.endTime && (e.endTime = G(i.default.endTime).format()), i.default.expirationTime && (e.expirationTime = G(i.default.expirationTime).format())), i.advanced && (i.advanced.currency && (e.currency = i.advanced.currency), i.advanced.timezone && (e.timezone = i.advanced.timezone), i.advanced.billingPlan && (e.billingPlan = i.advanced.billingPlan), i.advanced.defaultTermDuration && (e.defaultTermDuration = i.advanced.defaultTermDuration), i.advanced.installmentPlan && (e.installmentPlan = i.advanced.installmentPlan), i.advanced.durationBasis && (e.durationBasis = i.advanced.durationBasis), i.advanced.delinquencyPlanName && (e.delinquencyPlanName = i.advanced.delinquencyPlanName)), delete i.default, delete i.advanced, e.setData = i, e;
427
427
  }, se = (t) => {
428
- const e = /^(.*?)(Quote|QuickQuote|Policy)$/, a = t.match(e);
429
- return a && (a[2] === "Quote" || a[2] === "QuickQuote" || a[2] === "Policy") ? [a[1], a[2]] : [t, null];
428
+ const e = /^(.*?)(Quote|QuickQuote|Policy)$/, i = t.match(e);
429
+ return i && (i[2] === "Quote" || i[2] === "QuickQuote" || i[2] === "Policy") ? [i[1], i[2]] : [t, null];
430
430
  };
431
431
  function ie(t, e) {
432
432
  if (t.locator === e)
433
433
  return t;
434
434
  if (t.elements)
435
- for (const a of t.elements) {
436
- const f = ie(a, e);
437
- if (f)
438
- return f;
435
+ for (const i of t.elements) {
436
+ const o = ie(i, e);
437
+ if (o)
438
+ return o;
439
439
  }
440
440
  }
441
- function fe(t, e) {
442
- const [a] = se(
441
+ function oe(t, e) {
442
+ const [i] = se(
443
443
  t.type ?? ""
444
444
  );
445
- let f = {};
446
- return e.exposures && Object.keys(e.exposures).forEach((b) => {
447
- b === a && e.exposures && (f = e.exposures[b]);
448
- }), e.coverages && Object.keys(e.coverages).forEach((b) => {
449
- b === a && e.coverages && (f = e.coverages[b]);
450
- }), e.policyLines && Object.keys(e.policyLines).forEach((b) => {
451
- b === a && e.policyLines && (f = e.policyLines[b]);
452
- }), e.exposureGroups && Object.keys(e.exposureGroups).forEach((b) => {
453
- b === a && e.exposureGroups && (f = e.exposureGroups[b]);
454
- }), f;
445
+ let o = {};
446
+ return e.exposures && Object.keys(e.exposures).forEach((v) => {
447
+ v === i && e.exposures && (o = e.exposures[v]);
448
+ }), e.coverages && Object.keys(e.coverages).forEach((v) => {
449
+ v === i && e.coverages && (o = e.coverages[v]);
450
+ }), e.policyLines && Object.keys(e.policyLines).forEach((v) => {
451
+ v === i && e.policyLines && (o = e.policyLines[v]);
452
+ }), e.exposureGroups && Object.keys(e.exposureGroups).forEach((v) => {
453
+ v === i && e.exposureGroups && (o = e.exposureGroups[v]);
454
+ }), o;
455
455
  }
456
- function de(t) {
456
+ function me(t) {
457
457
  return t == null ? void 0 : t.map((e) => (e.keyword === "pattern" && (e.message = `Invalid format, must match pattern ${e.params.pattern}`), e.keyword === "format" && (e.message = "Invalid format"), e.keyword === "required" && (e.message = "Required"), e.keyword === "minItems" && (e.message = `Must have at least ${e.params.limit} item${e.params.limit !== 1 ? "s" : ""}`), e.keyword === "maxItems" && (e.message = `Must have at most ${e.params.limit} item${e.params.limit !== 1 ? "s" : ""}`), e.keyword === "type" && (e.message = "Invalid format"), e.keyword === "maxLength" && (e.message = `Must be at most ${e.params.limit} character${e.params.limit !== 1 ? "s" : ""}`), e.keyword === "minLength" && (e.message = `Must be at least ${e.params.limit} character${e.params.limit !== 1 ? "s" : ""}`), e.keyword === "minimum" && (e.message = `Must be greater than or equal to ${e.params.limit}`), e.keyword === "maximum" && (e.message = `Must be less than or equal to ${e.params.limit}`), e.keyword === "enum" && (e.message = "Invalid value"), e));
458
458
  }
459
- const me = (t) => {
460
- var e, a, f, b, d, g;
459
+ const de = (t, e, i) => {
460
+ var o, v;
461
461
  return {
462
- ...((e = t == null ? void 0 : t.element) == null ? void 0 : e.data) && {
463
- ...(a = t == null ? void 0 : t.element) == null ? void 0 : a.data
462
+ ...((o = t == null ? void 0 : t.element) == null ? void 0 : o.data) && {
463
+ ...(v = t == null ? void 0 : t.element) == null ? void 0 : v.data
464
464
  },
465
465
  default: {
466
466
  // set date to yyyy-MM-dd format if it exists
@@ -475,60 +475,61 @@ const me = (t) => {
475
475
  }
476
476
  },
477
477
  advanced: {
478
- currency: (t == null ? void 0 : t.currency) ?? void 0,
479
- timezone: (t == null ? void 0 : t.timezone) ?? void 0,
480
- billingPlan: ((b = (f = t == null ? void 0 : t.preferences) == null ? void 0 : f.billingPreferences) == null ? void 0 : b.billingPlanName) ?? void 0,
481
- installmentPlan: ((g = (d = t == null ? void 0 : t.preferences) == null ? void 0 : d.installmentPreferences) == null ? void 0 : g.installmentPlanName) ?? void 0,
482
- durationBasis: (t == null ? void 0 : t.durationBasis) ?? void 0,
483
- delinquencyPlanName: (t == null ? void 0 : t.delinquencyPlanName) ?? void 0
478
+ currency: (t == null ? void 0 : t.currency) ?? e.defaultCurrency ?? i.defaultCurrency ?? void 0,
479
+ timezone: (t == null ? void 0 : t.timezone) ?? e.defaultTimeZone ?? i.defaultTimeZone ?? void 0,
480
+ billingLevel: (t == null ? void 0 : t.billingLevel) ?? e.defaultBillingLevel ?? i.defaultBillingLevel ?? void 0,
481
+ billingTrigger: (t == null ? void 0 : t.billingTrigger) ?? e.defaultBillingTrigger,
482
+ durationBasis: (t == null ? void 0 : t.durationBasis) ?? e.defaultDurationBasis ?? void 0,
483
+ delinquencyPlanName: (t == null ? void 0 : t.delinquencyPlanName) ?? (e == null ? void 0 : e.defaultDelinquencyPlan) ?? void 0,
484
+ autoRenewalPlanName: (t == null ? void 0 : t.autoRenewalPlanName) ?? (e == null ? void 0 : e.defaultAutoRenewalPlan) ?? void 0
484
485
  }
485
486
  };
486
487
  }, he = (t) => ({
487
488
  ...t.data,
488
489
  coverageTerms: t.coverageTerms ?? {}
489
490
  }), X = (t, e) => {
490
- for (const a of t) {
491
- if (a.locator === e)
492
- return a;
493
- const f = X(
494
- a.elements ?? [],
491
+ for (const i of t) {
492
+ if (i.locator === e)
493
+ return i;
494
+ const o = X(
495
+ i.elements ?? [],
495
496
  e
496
497
  );
497
- if (f)
498
- return f;
498
+ if (o)
499
+ return o;
499
500
  }
500
501
  return !1;
501
502
  }, ae = (t, e) => {
502
- var a, f;
503
- return ((a = t.element) == null ? void 0 : a.locator) === e ? t.element : X(
504
- ((f = t.element) == null ? void 0 : f.elements) ?? [],
503
+ var i, o;
504
+ return ((i = t.element) == null ? void 0 : i.locator) === e ? t.element : X(
505
+ ((o = t.element) == null ? void 0 : o.elements) ?? [],
505
506
  e
506
507
  );
507
508
  }, re = ({
508
509
  dataModel: t,
509
510
  element: { productName: e }
510
- }) => t.products[e] ?? {}, ce = (t) => {
511
- var f;
511
+ }) => t.products[e] ?? {}, ue = (t) => {
512
+ var o;
512
513
  t = t ?? "";
513
- const e = t.replace(/\?|\*|!|\+/g, ""), a = (f = t.match(/\?|\*|!|\+/g)) == null ? void 0 : f.pop();
514
+ const e = t.replace(/\?|\*|!|\+/g, ""), i = (o = t.match(/\?|\*|!|\+/g)) == null ? void 0 : o.pop();
514
515
  return {
515
516
  name: e,
516
- quantifier: a ?? ""
517
+ quantifier: i ?? ""
517
518
  };
518
- }, ue = ({
519
+ }, ce = ({
519
520
  dataModel: t,
520
521
  productDataModel: e
521
522
  }) => {
522
- const a = t.exposures ?? {}, f = t.coverages ?? {}, b = t.policyLines ?? {}, d = t.exposureGroups ?? {}, p = (e.contents ?? []).map((r) => {
523
- const { name: O } = ce(r);
523
+ const i = t.exposures ?? {}, o = t.coverages ?? {}, v = t.policyLines ?? {}, d = t.exposureGroups ?? {}, p = (e.contents ?? []).map((r) => {
524
+ const { name: O } = ue(r);
524
525
  return O;
525
- }), M = Object.keys(a).filter(
526
+ }), x = Object.keys(i).filter(
526
527
  (r) => p.includes(r)
527
- ), P = Object.keys(f).filter(
528
+ ), E = Object.keys(o).filter(
528
529
  (r) => p.includes(r)
529
- ), C = Object.keys(b).filter(
530
+ ), B = Object.keys(v).filter(
530
531
  (r) => p.includes(r)
531
- ), E = Object.keys(
532
+ ), P = Object.keys(
532
533
  d
533
534
  ).filter((r) => p.includes(r)), h = {
534
535
  coverages: {},
@@ -536,56 +537,56 @@ const me = (t) => {
536
537
  policyLines: {},
537
538
  exposureGroups: {}
538
539
  };
539
- for (const r of M)
540
- h.exposures[r] = a[r];
541
- for (const r of P)
542
- h.coverages[r] = f[r];
543
- for (const r of C)
544
- h.policyLines[r] = b[r];
540
+ for (const r of x)
541
+ h.exposures[r] = i[r];
545
542
  for (const r of E)
543
+ h.coverages[r] = o[r];
544
+ for (const r of B)
545
+ h.policyLines[r] = v[r];
546
+ for (const r of P)
546
547
  h.exposureGroups[r] = d[r];
547
548
  return h;
548
549
  }, pe = ({
549
550
  dataModel: t,
550
551
  quote: e,
551
- elementLocator: a
552
+ elementLocator: i
552
553
  }) => {
553
- const f = ae(e, a);
554
- if (!f)
554
+ const o = ae(e, i);
555
+ if (!o)
555
556
  return {};
556
- const b = re({
557
+ const v = re({
557
558
  element: e,
558
559
  dataModel: t
559
- }), d = ue({
560
+ }), d = ce({
560
561
  dataModel: t,
561
- productDataModel: b
562
+ productDataModel: v
562
563
  });
563
- let g = !1;
564
- const p = f.type.split("Quote")[0];
565
- return Object.keys(d.exposures).forEach((M) => {
566
- M === p && (g = d.exposures[M]);
567
- }), g || Object.keys(d.coverages).forEach((M) => {
568
- M === p && (g = d.coverages[M]);
569
- }), g || Object.keys(d.policyLines).forEach((M) => {
570
- M === p && (g = d.policyLines[M]);
571
- }), g || Object.keys(d.exposureGroups).forEach((M) => {
572
- M === p && (g = d.exposureGroups[M]);
573
- }), g;
564
+ let D = !1;
565
+ const p = o.type.split("Quote")[0];
566
+ return Object.keys(d.exposures).forEach((x) => {
567
+ x === p && (D = d.exposures[x]);
568
+ }), D || Object.keys(d.coverages).forEach((x) => {
569
+ x === p && (D = d.coverages[x]);
570
+ }), D || Object.keys(d.policyLines).forEach((x) => {
571
+ x === p && (D = d.policyLines[x]);
572
+ }), D || Object.keys(d.exposureGroups).forEach((x) => {
573
+ x === p && (D = d.exposureGroups[x]);
574
+ }), D;
574
575
  };
575
576
  export {
576
577
  q as dataModelToJSONSchema,
577
578
  pe as extractElementDataModel,
578
579
  ae as extractElementFromQuote,
579
580
  re as extractProductDataModel,
580
- ue as extractProductElements,
581
+ ce as extractProductElements,
581
582
  he as getDefaultElementValues,
582
- me as getDefaultQuoteValues,
583
- oe as getQuoteElementRequest,
584
- le as getQuoteRequest,
583
+ de as getDefaultQuoteValues,
584
+ le as getQuoteElementRequest,
585
+ fe as getQuoteRequest,
585
586
  se as parseElementTypeAndScopeByElementType,
586
- fe as retrieveDataModelFromElement,
587
+ oe as retrieveDataModelFromElement,
587
588
  ie as retrieveElementFromQuoteByLocator,
588
- ce as splitInputAndQuantifier,
589
- de as transformErrors
589
+ ue as splitInputAndQuantifier,
590
+ me as transformErrors
590
591
  };
591
592
  //# sourceMappingURL=index.es.js.map