@socotra/ec-react-utils 2.2.1 → 2.2.2-beta.64

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