@prolibu-suite/cobalt-form-vue 0.1.3 → 2.0.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.
Files changed (70) hide show
  1. package/dist/FieldObject-Cxd3I0Jv.js +4 -0
  2. package/dist/components/CoFieldRenderer.test.d.ts +2 -0
  3. package/dist/components/CoFieldRenderer.test.d.ts.map +1 -0
  4. package/dist/components/CoFieldRenderer.vue.d.ts +40 -3
  5. package/dist/components/CoFieldRenderer.vue.d.ts.map +1 -1
  6. package/dist/components/CoFieldShell.vue.d.ts +23 -0
  7. package/dist/components/CoFieldShell.vue.d.ts.map +1 -0
  8. package/dist/components/CoFormRenderer.file.test.d.ts +2 -0
  9. package/dist/components/CoFormRenderer.file.test.d.ts.map +1 -0
  10. package/dist/components/CoFormRenderer.nested.test.d.ts +2 -0
  11. package/dist/components/CoFormRenderer.nested.test.d.ts.map +1 -0
  12. package/dist/components/CoFormRenderer.vue.d.ts +35 -6
  13. package/dist/components/CoFormRenderer.vue.d.ts.map +1 -1
  14. package/dist/components/fields/FieldBoolean.vue.d.ts.map +1 -1
  15. package/dist/components/fields/FieldColor.vue.d.ts +17 -0
  16. package/dist/components/fields/FieldColor.vue.d.ts.map +1 -0
  17. package/dist/components/fields/FieldDate.vue.d.ts.map +1 -1
  18. package/dist/components/fields/FieldDatePicker.vue.d.ts +18 -0
  19. package/dist/components/fields/FieldDatePicker.vue.d.ts.map +1 -0
  20. package/dist/components/fields/FieldFile.test.d.ts +2 -0
  21. package/dist/components/fields/FieldFile.test.d.ts.map +1 -0
  22. package/dist/components/fields/FieldFile.vue.d.ts +61 -0
  23. package/dist/components/fields/FieldFile.vue.d.ts.map +1 -0
  24. package/dist/components/fields/FieldMasked.test.d.ts +2 -0
  25. package/dist/components/fields/FieldMasked.test.d.ts.map +1 -0
  26. package/dist/components/fields/FieldMasked.vue.d.ts +23 -0
  27. package/dist/components/fields/FieldMasked.vue.d.ts.map +1 -0
  28. package/dist/components/fields/FieldMixed.vue.d.ts +17 -0
  29. package/dist/components/fields/FieldMixed.vue.d.ts.map +1 -0
  30. package/dist/components/fields/FieldMultiple.vue.d.ts +17 -0
  31. package/dist/components/fields/FieldMultiple.vue.d.ts.map +1 -0
  32. package/dist/components/fields/FieldNumber.vue.d.ts.map +1 -1
  33. package/dist/components/fields/FieldObject.vue.d.ts +18 -0
  34. package/dist/components/fields/FieldObject.vue.d.ts.map +1 -0
  35. package/dist/components/fields/FieldPhone.vue.d.ts +16 -0
  36. package/dist/components/fields/FieldPhone.vue.d.ts.map +1 -0
  37. package/dist/components/fields/FieldRef.vue.d.ts +2 -2
  38. package/dist/components/fields/FieldRichText.vue.d.ts +16 -0
  39. package/dist/components/fields/FieldRichText.vue.d.ts.map +1 -0
  40. package/dist/components/fields/FieldSelect.vue.d.ts.map +1 -1
  41. package/dist/components/fields/FieldText.vue.d.ts.map +1 -1
  42. package/dist/components/fields/FieldTextArea.vue.d.ts.map +1 -1
  43. package/dist/composables/useFileFieldStates.d.ts +41 -0
  44. package/dist/composables/useFileFieldStates.d.ts.map +1 -0
  45. package/dist/composables/useForm.d.ts.map +1 -1
  46. package/dist/composables/useForm.test.d.ts +2 -0
  47. package/dist/composables/useForm.test.d.ts.map +1 -0
  48. package/dist/composables/useRefFieldStates.d.ts +25 -0
  49. package/dist/composables/useRefFieldStates.d.ts.map +1 -0
  50. package/dist/index.css +1 -1
  51. package/dist/index.d.ts +25 -8
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +3921 -386
  54. package/dist/utils/fieldPath.d.ts +29 -0
  55. package/dist/utils/fieldPath.d.ts.map +1 -0
  56. package/dist/utils/formContext.d.ts +84 -0
  57. package/dist/utils/formContext.d.ts.map +1 -0
  58. package/dist/utils/gridCell.d.ts +28 -0
  59. package/dist/utils/gridCell.d.ts.map +1 -0
  60. package/dist/utils/gridCell.test.d.ts +2 -0
  61. package/dist/utils/gridCell.test.d.ts.map +1 -0
  62. package/dist/utils/normalizeMaskConfig.d.ts +23 -0
  63. package/dist/utils/normalizeMaskConfig.d.ts.map +1 -0
  64. package/dist/utils/normalizeMaskConfig.test.d.ts +2 -0
  65. package/dist/utils/normalizeMaskConfig.test.d.ts.map +1 -0
  66. package/dist/utils/sectionPreview.d.ts +26 -0
  67. package/dist/utils/sectionPreview.d.ts.map +1 -0
  68. package/dist/utils/sectionPreview.test.d.ts +2 -0
  69. package/dist/utils/sectionPreview.test.d.ts.map +1 -0
  70. package/package.json +13 -6
package/dist/index.js CHANGED
@@ -1,128 +1,3028 @@
1
- import { createForm as W, normalizeForValidation as H } from "@prolibu-suite/cobalt-form-core";
2
- import { createForm as xe } from "@prolibu-suite/cobalt-form-core";
3
- import { shallowRef as M, watch as U, toValue as G, onBeforeUnmount as K, computed as f, defineComponent as C, openBlock as g, createBlock as A, unref as $, resolveDynamicComponent as Z, reactive as Q, onMounted as X, createElementBlock as T, withModifiers as Y, renderSlot as V, createElementVNode as O, normalizeClass as N, Fragment as _, renderList as ee, createVNode as I } from "vue";
4
- import { CoInput as k, CoNumberField as te, CoSwitch as le, CoSelect as re, CoRefField as ae, CoButton as oe } from "@prolibu-suite/cobalt-vue";
5
- function he(e) {
6
- const c = M(null), t = M({
1
+ import { createForm as ht, normalizeForValidation as ct } from "@prolibu-suite/cobalt-form-core";
2
+ import { createForm as zs } from "@prolibu-suite/cobalt-form-core";
3
+ import { shallowRef as ge, watch as J, toValue as xe, onBeforeUnmount as Le, computed as p, defineComponent as R, openBlock as I, createBlock as T, unref as B, withCtx as _e, createElementBlock as P, renderSlot as se, createCommentVNode as te, normalizeClass as pt, createTextVNode as ft, toDisplayString as Fe, createElementVNode as ie, ref as j, onMounted as Se, withModifiers as Ne, createVNode as ae, defineAsyncComponent as mt, resolveDynamicComponent as vt, reactive as qe, provide as K, normalizeStyle as be, Fragment as Ue, renderList as $e, mergeProps as ze, nextTick as gt, inject as W } from "vue";
4
+ import { CoSwitch as kt, CoColorPicker as yt, CoDatePicker as Ct, CoFileField as Ft, CoIcon as bt, CoJsonField as At, CoTagsField as Et, CoNumberField as xt, CoPhoneField as _t, CoRefField as St, CoRichTextEditor as Bt, CoSelect as Mt, CoInput as Pe, CoTextarea as wt, CoButton as It, CoAccordion as Vt } from "@prolibu-suite/cobalt-vue";
5
+ function Os(i) {
6
+ const e = ge(null), t = ge({
7
7
  values: {},
8
8
  errors: {},
9
9
  touched: {},
10
10
  isValid: !0,
11
11
  isDirty: !1,
12
12
  isSubmitting: !1
13
- });
13
+ }), s = ge([]);
14
14
  let r = null;
15
- function v(n) {
15
+ function n(a) {
16
16
  r == null || r();
17
- const s = W(n);
18
- c.value = s, t.value = s.state, r = s.subscribe((a) => {
19
- t.value = a;
17
+ const l = ht(a);
18
+ e.value = l, t.value = l.state, s.value = l.fields, r = l.subscribe((u) => {
19
+ t.value = u, s.value = l.fields;
20
20
  });
21
21
  }
22
- return U(
23
- () => G(e),
24
- (n) => v(n),
22
+ return J(
23
+ () => xe(i),
24
+ (a) => n(a),
25
25
  { immediate: !0, deep: !1 }
26
- ), K(() => {
26
+ ), Le(() => {
27
27
  r == null || r(), r = null;
28
28
  }), {
29
- controller: c,
30
- values: f(() => t.value.values),
31
- errors: f(() => t.value.errors),
32
- touched: f(() => t.value.touched),
33
- isValid: f(() => t.value.isValid),
34
- isDirty: f(() => t.value.isDirty),
35
- isSubmitting: f(() => t.value.isSubmitting),
36
- fields: f(() => {
37
- var n;
38
- return ((n = c.value) == null ? void 0 : n.fields) ?? [];
39
- }),
40
- setValue: (n, s) => {
41
- var a;
42
- return (a = c.value) == null ? void 0 : a.setValue(n, s);
29
+ controller: e,
30
+ values: p(() => t.value.values),
31
+ errors: p(() => t.value.errors),
32
+ touched: p(() => t.value.touched),
33
+ isValid: p(() => t.value.isValid),
34
+ isDirty: p(() => t.value.isDirty),
35
+ isSubmitting: p(() => t.value.isSubmitting),
36
+ fields: p(() => s.value),
37
+ setValue: (a, l) => {
38
+ var u;
39
+ return (u = e.value) == null ? void 0 : u.setValue(a, l);
43
40
  },
44
- setValues: (n) => {
45
- var s;
46
- return (s = c.value) == null ? void 0 : s.setValues(n);
41
+ setValues: (a) => {
42
+ var l;
43
+ return (l = e.value) == null ? void 0 : l.setValues(a);
47
44
  },
48
- touch: (n) => {
49
- var s;
50
- return (s = c.value) == null ? void 0 : s.touch(n);
45
+ touch: (a) => {
46
+ var l;
47
+ return (l = e.value) == null ? void 0 : l.touch(a);
51
48
  },
52
49
  touchAll: () => {
53
- var n;
54
- return (n = c.value) == null ? void 0 : n.touchAll();
50
+ var a;
51
+ return (a = e.value) == null ? void 0 : a.touchAll();
55
52
  },
56
- setSchema: (n) => {
57
- var s;
58
- return (s = c.value) == null ? void 0 : s.setSchema(n);
53
+ setSchema: (a) => {
54
+ var l;
55
+ return (l = e.value) == null ? void 0 : l.setSchema(a);
59
56
  },
60
57
  validate: () => {
61
- var n;
62
- return ((n = c.value) == null ? void 0 : n.validate()) ?? !0;
58
+ var a;
59
+ return ((a = e.value) == null ? void 0 : a.validate()) ?? !0;
60
+ },
61
+ submit: () => {
62
+ var a;
63
+ return ((a = e.value) == null ? void 0 : a.submit()) ?? Promise.resolve({ values: {}, isValid: !0, errors: {} });
64
+ },
65
+ reset: (a) => {
66
+ var l;
67
+ return (l = e.value) == null ? void 0 : l.reset(a);
68
+ }
69
+ };
70
+ }
71
+ const Dt = /* @__PURE__ */ R({
72
+ __name: "FieldBoolean",
73
+ props: {
74
+ field: {},
75
+ value: {},
76
+ errors: {},
77
+ disabled: { type: Boolean }
78
+ },
79
+ emits: ["update:value"],
80
+ setup(i, { emit: e }) {
81
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText);
82
+ return (a, l) => (I(), T(B(kt), {
83
+ label: i.field.label,
84
+ required: i.field.required,
85
+ disabled: i.disabled,
86
+ status: r.value,
87
+ "helper-text": n.value,
88
+ checked: !!i.value,
89
+ onCoChange: l[0] || (l[0] = (u) => s("update:value", u.detail))
90
+ }, null, 8, ["label", "required", "disabled", "status", "helper-text", "checked"]));
91
+ }
92
+ }), Rt = /* @__PURE__ */ R({
93
+ __name: "FieldColor",
94
+ props: {
95
+ field: {},
96
+ value: {},
97
+ errors: {},
98
+ disabled: { type: Boolean },
99
+ locale: {}
100
+ },
101
+ emits: ["update:value", "blur"],
102
+ setup(i, { emit: e }) {
103
+ const t = i, s = e, r = {
104
+ en: {
105
+ green: "Green",
106
+ yellow: "Yellow",
107
+ blue: "Blue",
108
+ pink: "Pink",
109
+ red: "Red",
110
+ orange: "Orange",
111
+ teal: "Teal",
112
+ lightBlue: "Light blue",
113
+ electricBlue: "Electric blue",
114
+ violet: "Violet",
115
+ burgundy: "Burgundy",
116
+ olive: "Olive"
117
+ },
118
+ es: {
119
+ green: "Verde",
120
+ yellow: "Amarillo",
121
+ blue: "Azul",
122
+ pink: "Rosado",
123
+ red: "Rojo",
124
+ orange: "Naranja",
125
+ teal: "Turquesa",
126
+ lightBlue: "Azul claro",
127
+ electricBlue: "Azul eléctrico",
128
+ violet: "Violeta",
129
+ burgundy: "Guinda",
130
+ olive: "Oliva"
131
+ },
132
+ pt: {
133
+ green: "Verde",
134
+ yellow: "Amarelo",
135
+ blue: "Azul",
136
+ pink: "Rosa",
137
+ red: "Vermelho",
138
+ orange: "Laranja",
139
+ teal: "Turquesa",
140
+ lightBlue: "Azul claro",
141
+ electricBlue: "Azul elétrico",
142
+ violet: "Violeta",
143
+ burgundy: "Bordô",
144
+ olive: "Oliva"
145
+ }
146
+ }, n = [
147
+ { key: "green", value: "#02A270" },
148
+ { key: "yellow", value: "#FDBF00" },
149
+ { key: "blue", value: "#2563EB" },
150
+ { key: "pink", value: "#F32A73" },
151
+ { key: "red", value: "#EB1E1E" },
152
+ { key: "orange", value: "#F0821E" },
153
+ { key: "teal", value: "#00AFAF" },
154
+ { key: "lightBlue", value: "#00BEE6" },
155
+ { key: "electricBlue", value: "#000AFF" },
156
+ { key: "violet", value: "#5F4BD7" },
157
+ { key: "burgundy", value: "#811137" },
158
+ { key: "olive", value: "#AAB43C" }
159
+ ], a = p(() => t.errors.length > 0 ? "error" : "default"), l = p(() => t.errors[0] || t.field.helperText), u = p(() => {
160
+ var x;
161
+ const o = (x = t.field.originalAttrs) == null ? void 0 : x.presets;
162
+ if (Array.isArray(o) && o.length) return JSON.stringify(o);
163
+ const v = (t.locale || "en").split("-")[0].toLowerCase(), f = r[v] || r.en, m = n.map((g) => ({
164
+ name: f[g.key] || g.key,
165
+ value: g.value
166
+ }));
167
+ return JSON.stringify(m);
168
+ });
169
+ return (o, v) => (I(), T(B(yt), {
170
+ label: i.field.label,
171
+ placeholder: i.field.placeholder,
172
+ required: i.field.required,
173
+ disabled: i.disabled,
174
+ status: a.value,
175
+ "helper-text": l.value,
176
+ presets: u.value,
177
+ value: String(i.value ?? ""),
178
+ onCoChange: v[0] || (v[0] = (f) => s("update:value", f.detail))
179
+ }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "presets", "value"]));
180
+ }
181
+ }), Tt = /* @__PURE__ */ R({
182
+ __name: "FieldDatePicker",
183
+ props: {
184
+ field: {},
185
+ value: {},
186
+ errors: {},
187
+ disabled: { type: Boolean },
188
+ locale: {}
189
+ },
190
+ emits: ["update:value", "blur"],
191
+ setup(i, { emit: e }) {
192
+ const t = i, s = e, r = p(() => {
193
+ const f = t.value;
194
+ return typeof f != "string" || f === "" ? null : f.length >= 10 ? f.slice(0, 10) : f;
195
+ }), n = p(() => t.field.originalAttrs.min), a = p(() => t.field.originalAttrs.max), l = p(() => t.field.originalAttrs.disabledDates), u = p(() => t.field.originalAttrs.disabledDaysOfWeek), o = p(
196
+ () => t.locale || t.field.originalAttrs.locale || "es-CO"
197
+ ), v = p(
198
+ () => t.field.originalAttrs.displayFormat || "d MMM yyyy"
199
+ );
200
+ return (f, m) => (I(), T(B(Ct), {
201
+ label: i.field.label,
202
+ placeholder: i.field.placeholder,
203
+ required: i.field.required,
204
+ disabled: i.disabled,
205
+ clearable: !i.field.required,
206
+ invalid: i.errors.length > 0,
207
+ "error-message": i.errors[0],
208
+ "helper-text": i.field.helperText,
209
+ value: r.value,
210
+ min: n.value,
211
+ max: a.value,
212
+ "disabled-dates": l.value,
213
+ "disabled-days-of-week": u.value,
214
+ locale: o.value,
215
+ "display-format": v.value,
216
+ onCoChange: m[0] || (m[0] = (x) => s("update:value", x.detail)),
217
+ onCoBlur: m[1] || (m[1] = (x) => s("blur"))
218
+ }, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "invalid", "error-message", "helper-text", "value", "min", "max", "disabled-dates", "disabled-days-of-week", "locale", "display-format"]));
219
+ }
220
+ }), Ot = {
221
+ key: 0,
222
+ slot: "actions",
223
+ style: { display: "contents" }
224
+ }, Lt = /* @__PURE__ */ R({
225
+ __name: "FieldFile",
226
+ props: {
227
+ field: {},
228
+ value: {},
229
+ errors: {},
230
+ disabled: { type: Boolean },
231
+ fileState: {},
232
+ locale: {}
233
+ },
234
+ emits: ["update:value", "upload", "remove-file", "reorder", "copy-url"],
235
+ setup(i, { emit: e }) {
236
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText), a = p(() => {
237
+ var x;
238
+ const m = t.field.originalAttrs;
239
+ return !!m.multiple || Array.isArray(m.type) || ((x = m.type) == null ? void 0 : x[0]) === "array";
240
+ }), l = p(() => {
241
+ const m = t.field.originalAttrs.ext;
242
+ if (Array.isArray(m)) return m.join(",");
243
+ if (typeof m == "string") return m;
244
+ }), u = p(() => {
245
+ const m = t.field.originalAttrs.maxElements;
246
+ return typeof m == "number" ? m : 100;
247
+ }), o = p(() => {
248
+ const m = t.field.originalAttrs.maxBytes;
249
+ return typeof m == "number" ? m : void 0;
250
+ });
251
+ function v(m) {
252
+ const x = (h) => {
253
+ if (!h) return null;
254
+ if (typeof h == "string") return { id: h, name: h, status: "done" };
255
+ if (typeof h == "object") {
256
+ const k = h._id || h.id;
257
+ return k ? {
258
+ id: k,
259
+ name: h.fileName || h.name || h.originalName || k,
260
+ size: h.size,
261
+ url: h.url,
262
+ thumbnail: h.thumbnail,
263
+ fileCode: h.fileCode,
264
+ status: "done"
265
+ } : null;
266
+ }
267
+ return null;
268
+ };
269
+ if (m == null || m === "") return [];
270
+ if (Array.isArray(m)) return m.map(x).filter((h) => !!h);
271
+ const g = x(m);
272
+ return g ? [g] : [];
273
+ }
274
+ const f = p(
275
+ () => JSON.stringify(t.fileState ?? v(t.value))
276
+ );
277
+ return (m, x) => (I(), T(B(Ft), {
278
+ label: i.field.label,
279
+ required: i.field.required,
280
+ disabled: i.disabled,
281
+ multiple: a.value,
282
+ accept: l.value,
283
+ "max-files": u.value,
284
+ "max-bytes": o.value,
285
+ status: r.value,
286
+ "helper-text": n.value,
287
+ locale: i.locale,
288
+ files: f.value,
289
+ onCoFilesSelected: x[0] || (x[0] = (g) => s("upload", g.detail)),
290
+ onCoRemove: x[1] || (x[1] = (g) => s("remove-file", g.detail)),
291
+ onCoClear: x[2] || (x[2] = (g) => s("update:value", a.value ? [] : null)),
292
+ onCoReorder: x[3] || (x[3] = (g) => s("reorder", g.detail)),
293
+ onCoCopy: x[4] || (x[4] = (g) => s("copy-url", g.detail))
294
+ }, {
295
+ default: _e(() => [
296
+ m.$slots.actions ? (I(), P("div", Ot, [
297
+ se(m.$slots, "actions")
298
+ ])) : te("", !0)
299
+ ]),
300
+ _: 3
301
+ }, 8, ["label", "required", "disabled", "multiple", "accept", "max-files", "max-bytes", "status", "helper-text", "locale", "files"]));
302
+ }
303
+ });
304
+ function X(i) {
305
+ return typeof i == "string" || i instanceof String;
306
+ }
307
+ function Ve(i) {
308
+ var e;
309
+ return typeof i == "object" && i != null && (i == null || (e = i.constructor) == null ? void 0 : e.name) === "Object";
310
+ }
311
+ function je(i, e) {
312
+ return Array.isArray(e) ? je(i, (t, s) => e.includes(s)) : Object.entries(i).reduce((t, s) => {
313
+ let [r, n] = s;
314
+ return e(n, r) && (t[r] = n), t;
315
+ }, {});
316
+ }
317
+ const b = {
318
+ NONE: "NONE",
319
+ LEFT: "LEFT",
320
+ FORCE_LEFT: "FORCE_LEFT",
321
+ RIGHT: "RIGHT",
322
+ FORCE_RIGHT: "FORCE_RIGHT"
323
+ };
324
+ function Nt(i) {
325
+ switch (i) {
326
+ case b.LEFT:
327
+ return b.FORCE_LEFT;
328
+ case b.RIGHT:
329
+ return b.FORCE_RIGHT;
330
+ default:
331
+ return i;
332
+ }
333
+ }
334
+ function ke(i) {
335
+ return i.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1");
336
+ }
337
+ function le(i, e) {
338
+ if (e === i) return !0;
339
+ const t = Array.isArray(e), s = Array.isArray(i);
340
+ let r;
341
+ if (t && s) {
342
+ if (e.length != i.length) return !1;
343
+ for (r = 0; r < e.length; r++) if (!le(e[r], i[r])) return !1;
344
+ return !0;
345
+ }
346
+ if (t != s) return !1;
347
+ if (e && i && typeof e == "object" && typeof i == "object") {
348
+ const n = e instanceof Date, a = i instanceof Date;
349
+ if (n && a) return e.getTime() == i.getTime();
350
+ if (n != a) return !1;
351
+ const l = e instanceof RegExp, u = i instanceof RegExp;
352
+ if (l && u) return e.toString() == i.toString();
353
+ if (l != u) return !1;
354
+ const o = Object.keys(e);
355
+ for (r = 0; r < o.length; r++) if (!Object.prototype.hasOwnProperty.call(i, o[r])) return !1;
356
+ for (r = 0; r < o.length; r++) if (!le(i[o[r]], e[o[r]])) return !1;
357
+ return !0;
358
+ } else if (e && i && typeof e == "function" && typeof i == "function")
359
+ return e.toString() === i.toString();
360
+ return !1;
361
+ }
362
+ class qt {
363
+ /** Current input value */
364
+ /** Current cursor position */
365
+ /** Old input value */
366
+ /** Old selection */
367
+ constructor(e) {
368
+ for (Object.assign(this, e); this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos); )
369
+ --this.oldSelection.start;
370
+ if (this.insertedCount)
371
+ for (; this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end); )
372
+ this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end ? ++this.oldSelection.end : ++this.cursorPos;
373
+ }
374
+ /** Start changing position */
375
+ get startChangePos() {
376
+ return Math.min(this.cursorPos, this.oldSelection.start);
377
+ }
378
+ /** Inserted symbols count */
379
+ get insertedCount() {
380
+ return this.cursorPos - this.startChangePos;
381
+ }
382
+ /** Inserted symbols */
383
+ get inserted() {
384
+ return this.value.substr(this.startChangePos, this.insertedCount);
385
+ }
386
+ /** Removed symbols count */
387
+ get removedCount() {
388
+ return Math.max(this.oldSelection.end - this.startChangePos || // for Delete
389
+ this.oldValue.length - this.value.length, 0);
390
+ }
391
+ /** Removed symbols */
392
+ get removed() {
393
+ return this.oldValue.substr(this.startChangePos, this.removedCount);
394
+ }
395
+ /** Unchanged head symbols */
396
+ get head() {
397
+ return this.value.substring(0, this.startChangePos);
398
+ }
399
+ /** Unchanged tail symbols */
400
+ get tail() {
401
+ return this.value.substring(this.startChangePos + this.insertedCount);
402
+ }
403
+ /** Remove direction */
404
+ get removeDirection() {
405
+ return !this.removedCount || this.insertedCount ? b.NONE : (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) && // if not range removed (event with backspace)
406
+ this.oldSelection.end === this.oldSelection.start ? b.RIGHT : b.LEFT;
407
+ }
408
+ }
409
+ function _(i, e) {
410
+ return new _.InputMask(i, e);
411
+ }
412
+ function He(i) {
413
+ if (i == null) throw new Error("mask property should be defined");
414
+ return i instanceof RegExp ? _.MaskedRegExp : X(i) ? _.MaskedPattern : i === Date ? _.MaskedDate : i === Number ? _.MaskedNumber : Array.isArray(i) || i === Array ? _.MaskedDynamic : _.Masked && i.prototype instanceof _.Masked ? i : _.Masked && i instanceof _.Masked ? i.constructor : i instanceof Function ? _.MaskedFunction : (console.warn("Mask not found for mask", i), _.Masked);
415
+ }
416
+ function re(i) {
417
+ if (!i) throw new Error("Options in not defined");
418
+ if (_.Masked) {
419
+ if (i.prototype instanceof _.Masked) return {
420
+ mask: i
421
+ };
422
+ const {
423
+ mask: e = void 0,
424
+ ...t
425
+ } = i instanceof _.Masked ? {
426
+ mask: i
427
+ } : Ve(i) && i.mask instanceof _.Masked ? i : {};
428
+ if (e) {
429
+ const s = e.mask;
430
+ return {
431
+ ...je(e, (r, n) => !n.startsWith("_")),
432
+ mask: e.constructor,
433
+ _mask: s,
434
+ ...t
435
+ };
436
+ }
437
+ }
438
+ return Ve(i) ? {
439
+ ...i
440
+ } : {
441
+ mask: i
442
+ };
443
+ }
444
+ function Y(i) {
445
+ if (_.Masked && i instanceof _.Masked) return i;
446
+ const e = re(i), t = He(e.mask);
447
+ if (!t) throw new Error("Masked class is not found for provided mask " + e.mask + ", appropriate module needs to be imported manually before creating mask.");
448
+ return e.mask === t && delete e.mask, e._mask && (e.mask = e._mask, delete e._mask), new t(e);
449
+ }
450
+ _.createMask = Y;
451
+ class Be {
452
+ /** */
453
+ /** */
454
+ /** */
455
+ /** Safely returns selection start */
456
+ get selectionStart() {
457
+ let e;
458
+ try {
459
+ e = this._unsafeSelectionStart;
460
+ } catch {
461
+ }
462
+ return e ?? this.value.length;
463
+ }
464
+ /** Safely returns selection end */
465
+ get selectionEnd() {
466
+ let e;
467
+ try {
468
+ e = this._unsafeSelectionEnd;
469
+ } catch {
470
+ }
471
+ return e ?? this.value.length;
472
+ }
473
+ /** Safely sets element selection */
474
+ select(e, t) {
475
+ if (!(e == null || t == null || e === this.selectionStart && t === this.selectionEnd))
476
+ try {
477
+ this._unsafeSelect(e, t);
478
+ } catch {
479
+ }
480
+ }
481
+ /** */
482
+ get isActive() {
483
+ return !1;
484
+ }
485
+ /** */
486
+ /** */
487
+ /** */
488
+ }
489
+ _.MaskElement = Be;
490
+ const De = 90, Ut = 89;
491
+ class oe extends Be {
492
+ /** HTMLElement to use mask on */
493
+ constructor(e) {
494
+ super(), this.input = e, this._onKeydown = this._onKeydown.bind(this), this._onInput = this._onInput.bind(this), this._onBeforeinput = this._onBeforeinput.bind(this), this._onCompositionEnd = this._onCompositionEnd.bind(this);
495
+ }
496
+ get rootElement() {
497
+ var e, t, s;
498
+ return (e = (t = (s = this.input).getRootNode) == null ? void 0 : t.call(s)) != null ? e : document;
499
+ }
500
+ /** Is element in focus */
501
+ get isActive() {
502
+ return this.input === this.rootElement.activeElement;
503
+ }
504
+ /** Binds HTMLElement events to mask internal events */
505
+ bindEvents(e) {
506
+ this.input.addEventListener("keydown", this._onKeydown), this.input.addEventListener("input", this._onInput), this.input.addEventListener("beforeinput", this._onBeforeinput), this.input.addEventListener("compositionend", this._onCompositionEnd), this.input.addEventListener("drop", e.drop), this.input.addEventListener("click", e.click), this.input.addEventListener("focus", e.focus), this.input.addEventListener("blur", e.commit), this._handlers = e;
507
+ }
508
+ _onKeydown(e) {
509
+ if (this._handlers.redo && (e.keyCode === De && e.shiftKey && (e.metaKey || e.ctrlKey) || e.keyCode === Ut && e.ctrlKey))
510
+ return e.preventDefault(), this._handlers.redo(e);
511
+ if (this._handlers.undo && e.keyCode === De && (e.metaKey || e.ctrlKey))
512
+ return e.preventDefault(), this._handlers.undo(e);
513
+ e.isComposing || this._handlers.selectionChange(e);
514
+ }
515
+ _onBeforeinput(e) {
516
+ if (e.inputType === "historyUndo" && this._handlers.undo)
517
+ return e.preventDefault(), this._handlers.undo(e);
518
+ if (e.inputType === "historyRedo" && this._handlers.redo)
519
+ return e.preventDefault(), this._handlers.redo(e);
520
+ }
521
+ _onCompositionEnd(e) {
522
+ this._handlers.input(e);
523
+ }
524
+ _onInput(e) {
525
+ e.isComposing || this._handlers.input(e);
526
+ }
527
+ /** Unbinds HTMLElement events to mask internal events */
528
+ unbindEvents() {
529
+ this.input.removeEventListener("keydown", this._onKeydown), this.input.removeEventListener("input", this._onInput), this.input.removeEventListener("beforeinput", this._onBeforeinput), this.input.removeEventListener("compositionend", this._onCompositionEnd), this.input.removeEventListener("drop", this._handlers.drop), this.input.removeEventListener("click", this._handlers.click), this.input.removeEventListener("focus", this._handlers.focus), this.input.removeEventListener("blur", this._handlers.commit), this._handlers = {};
530
+ }
531
+ }
532
+ _.HTMLMaskElement = oe;
533
+ class $t extends oe {
534
+ /** InputElement to use mask on */
535
+ constructor(e) {
536
+ super(e), this.input = e;
537
+ }
538
+ /** Returns InputElement selection start */
539
+ get _unsafeSelectionStart() {
540
+ return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
541
+ }
542
+ /** Returns InputElement selection end */
543
+ get _unsafeSelectionEnd() {
544
+ return this.input.selectionEnd;
545
+ }
546
+ /** Sets InputElement selection */
547
+ _unsafeSelect(e, t) {
548
+ this.input.setSelectionRange(e, t);
549
+ }
550
+ get value() {
551
+ return this.input.value;
552
+ }
553
+ set value(e) {
554
+ this.input.value = e;
555
+ }
556
+ }
557
+ _.HTMLMaskElement = oe;
558
+ class Ke extends oe {
559
+ /** Returns HTMLElement selection start */
560
+ get _unsafeSelectionStart() {
561
+ const e = this.rootElement, t = e.getSelection && e.getSelection(), s = t && t.anchorOffset, r = t && t.focusOffset;
562
+ return r == null || s == null || s < r ? s : r;
563
+ }
564
+ /** Returns HTMLElement selection end */
565
+ get _unsafeSelectionEnd() {
566
+ const e = this.rootElement, t = e.getSelection && e.getSelection(), s = t && t.anchorOffset, r = t && t.focusOffset;
567
+ return r == null || s == null || s > r ? s : r;
568
+ }
569
+ /** Sets HTMLElement selection */
570
+ _unsafeSelect(e, t) {
571
+ if (!this.rootElement.createRange) return;
572
+ const s = this.rootElement.createRange();
573
+ s.setStart(this.input.firstChild || this.input, e), s.setEnd(this.input.lastChild || this.input, t);
574
+ const r = this.rootElement, n = r.getSelection && r.getSelection();
575
+ n && (n.removeAllRanges(), n.addRange(s));
576
+ }
577
+ /** HTMLElement value */
578
+ get value() {
579
+ return this.input.textContent || "";
580
+ }
581
+ set value(e) {
582
+ this.input.textContent = e;
583
+ }
584
+ }
585
+ _.HTMLContenteditableMaskElement = Ke;
586
+ class de {
587
+ constructor() {
588
+ this.states = [], this.currentIndex = 0;
589
+ }
590
+ get currentState() {
591
+ return this.states[this.currentIndex];
592
+ }
593
+ get isEmpty() {
594
+ return this.states.length === 0;
595
+ }
596
+ push(e) {
597
+ this.currentIndex < this.states.length - 1 && (this.states.length = this.currentIndex + 1), this.states.push(e), this.states.length > de.MAX_LENGTH && this.states.shift(), this.currentIndex = this.states.length - 1;
598
+ }
599
+ go(e) {
600
+ return this.currentIndex = Math.min(Math.max(this.currentIndex + e, 0), this.states.length - 1), this.currentState;
601
+ }
602
+ undo() {
603
+ return this.go(-1);
604
+ }
605
+ redo() {
606
+ return this.go(1);
607
+ }
608
+ clear() {
609
+ this.states.length = 0, this.currentIndex = 0;
610
+ }
611
+ }
612
+ de.MAX_LENGTH = 100;
613
+ class zt {
614
+ /**
615
+ View element
616
+ */
617
+ /** Internal {@link Masked} model */
618
+ constructor(e, t) {
619
+ this.el = e instanceof Be ? e : e.isContentEditable && e.tagName !== "INPUT" && e.tagName !== "TEXTAREA" ? new Ke(e) : new $t(e), this.masked = Y(t), this._listeners = {}, this._value = "", this._unmaskedValue = "", this._rawInputValue = "", this.history = new de(), this._saveSelection = this._saveSelection.bind(this), this._onInput = this._onInput.bind(this), this._onChange = this._onChange.bind(this), this._onDrop = this._onDrop.bind(this), this._onFocus = this._onFocus.bind(this), this._onClick = this._onClick.bind(this), this._onUndo = this._onUndo.bind(this), this._onRedo = this._onRedo.bind(this), this.alignCursor = this.alignCursor.bind(this), this.alignCursorFriendly = this.alignCursorFriendly.bind(this), this._bindEvents(), this.updateValue(), this._onChange();
620
+ }
621
+ maskEquals(e) {
622
+ var t;
623
+ return e == null || ((t = this.masked) == null ? void 0 : t.maskEquals(e));
624
+ }
625
+ /** Masked */
626
+ get mask() {
627
+ return this.masked.mask;
628
+ }
629
+ set mask(e) {
630
+ if (this.maskEquals(e)) return;
631
+ if (!(e instanceof _.Masked) && this.masked.constructor === He(e)) {
632
+ this.masked.updateOptions({
633
+ mask: e
634
+ });
635
+ return;
636
+ }
637
+ const t = e instanceof _.Masked ? e : Y({
638
+ mask: e
639
+ });
640
+ t.unmaskedValue = this.masked.unmaskedValue, this.masked = t;
641
+ }
642
+ /** Raw value */
643
+ get value() {
644
+ return this._value;
645
+ }
646
+ set value(e) {
647
+ this.value !== e && (this.masked.value = e, this.updateControl("auto"));
648
+ }
649
+ /** Unmasked value */
650
+ get unmaskedValue() {
651
+ return this._unmaskedValue;
652
+ }
653
+ set unmaskedValue(e) {
654
+ this.unmaskedValue !== e && (this.masked.unmaskedValue = e, this.updateControl("auto"));
655
+ }
656
+ /** Raw input value */
657
+ get rawInputValue() {
658
+ return this._rawInputValue;
659
+ }
660
+ set rawInputValue(e) {
661
+ this.rawInputValue !== e && (this.masked.rawInputValue = e, this.updateControl(), this.alignCursor());
662
+ }
663
+ /** Typed unmasked value */
664
+ get typedValue() {
665
+ return this.masked.typedValue;
666
+ }
667
+ set typedValue(e) {
668
+ this.masked.typedValueEquals(e) || (this.masked.typedValue = e, this.updateControl("auto"));
669
+ }
670
+ /** Display value */
671
+ get displayValue() {
672
+ return this.masked.displayValue;
673
+ }
674
+ /** Starts listening to element events */
675
+ _bindEvents() {
676
+ this.el.bindEvents({
677
+ selectionChange: this._saveSelection,
678
+ input: this._onInput,
679
+ drop: this._onDrop,
680
+ click: this._onClick,
681
+ focus: this._onFocus,
682
+ commit: this._onChange,
683
+ undo: this._onUndo,
684
+ redo: this._onRedo
685
+ });
686
+ }
687
+ /** Stops listening to element events */
688
+ _unbindEvents() {
689
+ this.el && this.el.unbindEvents();
690
+ }
691
+ /** Fires custom event */
692
+ _fireEvent(e, t) {
693
+ const s = this._listeners[e];
694
+ s && s.forEach((r) => r(t));
695
+ }
696
+ /** Current selection start */
697
+ get selectionStart() {
698
+ return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
699
+ }
700
+ /** Current cursor position */
701
+ get cursorPos() {
702
+ return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
703
+ }
704
+ set cursorPos(e) {
705
+ !this.el || !this.el.isActive || (this.el.select(e, e), this._saveSelection());
706
+ }
707
+ /** Stores current selection */
708
+ _saveSelection() {
709
+ this.displayValue !== this.el.value && console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."), this._selection = {
710
+ start: this.selectionStart,
711
+ end: this.cursorPos
712
+ };
713
+ }
714
+ /** Syncronizes model value from view */
715
+ updateValue() {
716
+ this.masked.value = this.el.value, this._value = this.masked.value, this._unmaskedValue = this.masked.unmaskedValue, this._rawInputValue = this.masked.rawInputValue;
717
+ }
718
+ /** Syncronizes view from model value, fires change events */
719
+ updateControl(e) {
720
+ const t = this.masked.unmaskedValue, s = this.masked.value, r = this.masked.rawInputValue, n = this.displayValue, a = this.unmaskedValue !== t || this.value !== s || this._rawInputValue !== r;
721
+ this._unmaskedValue = t, this._value = s, this._rawInputValue = r, this.el.value !== n && (this.el.value = n), e === "auto" ? this.alignCursor() : e != null && (this.cursorPos = e), a && this._fireChangeEvents(), !this._historyChanging && (a || this.history.isEmpty) && this.history.push({
722
+ unmaskedValue: t,
723
+ selection: {
724
+ start: this.selectionStart,
725
+ end: this.cursorPos
726
+ }
727
+ });
728
+ }
729
+ /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
730
+ updateOptions(e) {
731
+ const {
732
+ mask: t,
733
+ ...s
734
+ } = e, r = !this.maskEquals(t), n = this.masked.optionsIsChanged(s);
735
+ r && (this.mask = t), n && this.masked.updateOptions(s), (r || n) && this.updateControl();
736
+ }
737
+ /** Updates cursor */
738
+ updateCursor(e) {
739
+ e != null && (this.cursorPos = e, this._delayUpdateCursor(e));
740
+ }
741
+ /** Delays cursor update to support mobile browsers */
742
+ _delayUpdateCursor(e) {
743
+ this._abortUpdateCursor(), this._changingCursorPos = e, this._cursorChanging = setTimeout(() => {
744
+ this.el && (this.cursorPos = this._changingCursorPos, this._abortUpdateCursor());
745
+ }, 10);
746
+ }
747
+ /** Fires custom events */
748
+ _fireChangeEvents() {
749
+ this._fireEvent("accept", this._inputEvent), this.masked.isComplete && this._fireEvent("complete", this._inputEvent);
750
+ }
751
+ /** Aborts delayed cursor update */
752
+ _abortUpdateCursor() {
753
+ this._cursorChanging && (clearTimeout(this._cursorChanging), delete this._cursorChanging);
754
+ }
755
+ /** Aligns cursor to nearest available position */
756
+ alignCursor() {
757
+ this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, b.LEFT));
758
+ }
759
+ /** Aligns cursor only if selection is empty */
760
+ alignCursorFriendly() {
761
+ this.selectionStart === this.cursorPos && this.alignCursor();
762
+ }
763
+ /** Adds listener on custom event */
764
+ on(e, t) {
765
+ return this._listeners[e] || (this._listeners[e] = []), this._listeners[e].push(t), this;
766
+ }
767
+ /** Removes custom event listener */
768
+ off(e, t) {
769
+ if (!this._listeners[e]) return this;
770
+ if (!t)
771
+ return delete this._listeners[e], this;
772
+ const s = this._listeners[e].indexOf(t);
773
+ return s >= 0 && this._listeners[e].splice(s, 1), this;
774
+ }
775
+ /** Handles view input event */
776
+ _onInput(e) {
777
+ this._inputEvent = e, this._abortUpdateCursor();
778
+ const t = new qt({
779
+ // new state
780
+ value: this.el.value,
781
+ cursorPos: this.cursorPos,
782
+ // old state
783
+ oldValue: this.displayValue,
784
+ oldSelection: this._selection
785
+ }), s = this.masked.rawInputValue, r = this.masked.splice(t.startChangePos, t.removed.length, t.inserted, t.removeDirection, {
786
+ input: !0,
787
+ raw: !0
788
+ }).offset, n = s === this.masked.rawInputValue ? t.removeDirection : b.NONE;
789
+ let a = this.masked.nearestInputPos(t.startChangePos + r, n);
790
+ n !== b.NONE && (a = this.masked.nearestInputPos(a, b.NONE)), this.updateControl(a), delete this._inputEvent;
791
+ }
792
+ /** Handles view change event and commits model value */
793
+ _onChange() {
794
+ this.displayValue !== this.el.value && this.updateValue(), this.masked.doCommit(), this.updateControl(), this._saveSelection();
795
+ }
796
+ /** Handles view drop event, prevents by default */
797
+ _onDrop(e) {
798
+ e.preventDefault(), e.stopPropagation();
799
+ }
800
+ /** Restore last selection on focus */
801
+ _onFocus(e) {
802
+ this.alignCursorFriendly();
803
+ }
804
+ /** Restore last selection on focus */
805
+ _onClick(e) {
806
+ this.alignCursorFriendly();
807
+ }
808
+ _onUndo() {
809
+ this._applyHistoryState(this.history.undo());
810
+ }
811
+ _onRedo() {
812
+ this._applyHistoryState(this.history.redo());
813
+ }
814
+ _applyHistoryState(e) {
815
+ e && (this._historyChanging = !0, this.unmaskedValue = e.unmaskedValue, this.el.select(e.selection.start, e.selection.end), this._saveSelection(), this._historyChanging = !1);
816
+ }
817
+ /** Unbind view events and removes element reference */
818
+ destroy() {
819
+ this._unbindEvents(), this._listeners.length = 0, delete this.el;
820
+ }
821
+ }
822
+ _.InputMask = zt;
823
+ class S {
824
+ /** Inserted symbols */
825
+ /** Additional offset if any changes occurred before tail */
826
+ /** Raw inserted is used by dynamic mask */
827
+ /** Can skip chars */
828
+ static normalize(e) {
829
+ return Array.isArray(e) ? e : [e, new S()];
830
+ }
831
+ constructor(e) {
832
+ Object.assign(this, {
833
+ inserted: "",
834
+ rawInserted: "",
835
+ tailShift: 0,
836
+ skip: !1
837
+ }, e);
838
+ }
839
+ /** Aggregate changes */
840
+ aggregate(e) {
841
+ return this.inserted += e.inserted, this.rawInserted += e.rawInserted, this.tailShift += e.tailShift, this.skip = this.skip || e.skip, this;
842
+ }
843
+ /** Total offset considering all changes */
844
+ get offset() {
845
+ return this.tailShift + this.inserted.length;
846
+ }
847
+ get consumed() {
848
+ return !!this.rawInserted || this.skip;
849
+ }
850
+ equals(e) {
851
+ return this.inserted === e.inserted && this.tailShift === e.tailShift && this.rawInserted === e.rawInserted && this.skip === e.skip;
852
+ }
853
+ }
854
+ _.ChangeDetails = S;
855
+ class H {
856
+ /** Tail value as string */
857
+ /** Tail start position */
858
+ /** Start position */
859
+ constructor(e, t, s) {
860
+ e === void 0 && (e = ""), t === void 0 && (t = 0), this.value = e, this.from = t, this.stop = s;
861
+ }
862
+ toString() {
863
+ return this.value;
864
+ }
865
+ extend(e) {
866
+ this.value += String(e);
867
+ }
868
+ appendTo(e) {
869
+ return e.append(this.toString(), {
870
+ tail: !0
871
+ }).aggregate(e._appendPlaceholder());
872
+ }
873
+ get state() {
874
+ return {
875
+ value: this.value,
876
+ from: this.from,
877
+ stop: this.stop
878
+ };
879
+ }
880
+ set state(e) {
881
+ Object.assign(this, e);
882
+ }
883
+ unshift(e) {
884
+ if (!this.value.length || e != null && this.from >= e) return "";
885
+ const t = this.value[0];
886
+ return this.value = this.value.slice(1), t;
887
+ }
888
+ shift() {
889
+ if (!this.value.length) return "";
890
+ const e = this.value[this.value.length - 1];
891
+ return this.value = this.value.slice(0, -1), e;
892
+ }
893
+ }
894
+ class L {
895
+ /** */
896
+ /** */
897
+ /** Transforms value before mask processing */
898
+ /** Transforms each char before mask processing */
899
+ /** Validates if value is acceptable */
900
+ /** Does additional processing at the end of editing */
901
+ /** Format typed value to string */
902
+ /** Parse string to get typed value */
903
+ /** Enable characters overwriting */
904
+ /** */
905
+ /** */
906
+ /** */
907
+ /** */
908
+ constructor(e) {
909
+ this._value = "", this._update({
910
+ ...L.DEFAULTS,
911
+ ...e
912
+ }), this._initialized = !0;
913
+ }
914
+ /** Sets and applies new options */
915
+ updateOptions(e) {
916
+ this.optionsIsChanged(e) && this.withValueRefresh(this._update.bind(this, e));
917
+ }
918
+ /** Sets new options */
919
+ _update(e) {
920
+ Object.assign(this, e);
921
+ }
922
+ /** Mask state */
923
+ get state() {
924
+ return {
925
+ _value: this.value,
926
+ _rawInputValue: this.rawInputValue
927
+ };
928
+ }
929
+ set state(e) {
930
+ this._value = e._value;
931
+ }
932
+ /** Resets value */
933
+ reset() {
934
+ this._value = "";
935
+ }
936
+ get value() {
937
+ return this._value;
938
+ }
939
+ set value(e) {
940
+ this.resolve(e, {
941
+ input: !0
942
+ });
943
+ }
944
+ /** Resolve new value */
945
+ resolve(e, t) {
946
+ t === void 0 && (t = {
947
+ input: !0
948
+ }), this.reset(), this.append(e, t, ""), this.doCommit();
949
+ }
950
+ get unmaskedValue() {
951
+ return this.value;
952
+ }
953
+ set unmaskedValue(e) {
954
+ this.resolve(e, {});
955
+ }
956
+ get typedValue() {
957
+ return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
958
+ }
959
+ set typedValue(e) {
960
+ this.format ? this.value = this.format(e, this) : this.unmaskedValue = String(e);
961
+ }
962
+ /** Value that includes raw user input */
963
+ get rawInputValue() {
964
+ return this.extractInput(0, this.displayValue.length, {
965
+ raw: !0
966
+ });
967
+ }
968
+ set rawInputValue(e) {
969
+ this.resolve(e, {
970
+ raw: !0
971
+ });
972
+ }
973
+ get displayValue() {
974
+ return this.value;
975
+ }
976
+ get isComplete() {
977
+ return !0;
978
+ }
979
+ get isFilled() {
980
+ return this.isComplete;
981
+ }
982
+ /** Finds nearest input position in direction */
983
+ nearestInputPos(e, t) {
984
+ return e;
985
+ }
986
+ totalInputPositions(e, t) {
987
+ return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), Math.min(this.displayValue.length, t - e);
988
+ }
989
+ /** Extracts value in range considering flags */
990
+ extractInput(e, t, s) {
991
+ return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), this.displayValue.slice(e, t);
992
+ }
993
+ /** Extracts tail in range */
994
+ extractTail(e, t) {
995
+ return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), new H(this.extractInput(e, t), e);
996
+ }
997
+ /** Appends tail */
998
+ appendTail(e) {
999
+ return X(e) && (e = new H(String(e))), e.appendTo(this);
1000
+ }
1001
+ /** Appends char */
1002
+ _appendCharRaw(e, t) {
1003
+ return e ? (this._value += e, new S({
1004
+ inserted: e,
1005
+ rawInserted: e
1006
+ })) : new S();
1007
+ }
1008
+ /** Appends char */
1009
+ _appendChar(e, t, s) {
1010
+ t === void 0 && (t = {});
1011
+ const r = this.state;
1012
+ let n;
1013
+ if ([e, n] = this.doPrepareChar(e, t), e && (n = n.aggregate(this._appendCharRaw(e, t)), !n.rawInserted && this.autofix === "pad")) {
1014
+ const a = this.state;
1015
+ this.state = r;
1016
+ let l = this.pad(t);
1017
+ const u = this._appendCharRaw(e, t);
1018
+ l = l.aggregate(u), u.rawInserted || l.equals(n) ? n = l : this.state = a;
1019
+ }
1020
+ if (n.inserted) {
1021
+ let a, l = this.doValidate(t) !== !1;
1022
+ if (l && s != null) {
1023
+ const u = this.state;
1024
+ if (this.overwrite === !0) {
1025
+ a = s.state;
1026
+ for (let v = 0; v < n.rawInserted.length; ++v)
1027
+ s.unshift(this.displayValue.length - n.tailShift);
1028
+ }
1029
+ let o = this.appendTail(s);
1030
+ if (l = o.rawInserted.length === s.toString().length, !(l && o.inserted) && this.overwrite === "shift") {
1031
+ this.state = u, a = s.state;
1032
+ for (let v = 0; v < n.rawInserted.length; ++v)
1033
+ s.shift();
1034
+ o = this.appendTail(s), l = o.rawInserted.length === s.toString().length;
1035
+ }
1036
+ l && o.inserted && (this.state = u);
1037
+ }
1038
+ l || (n = new S(), this.state = r, s && a && (s.state = a));
1039
+ }
1040
+ return n;
1041
+ }
1042
+ /** Appends optional placeholder at the end */
1043
+ _appendPlaceholder() {
1044
+ return new S();
1045
+ }
1046
+ /** Appends optional eager placeholder at the end */
1047
+ _appendEager() {
1048
+ return new S();
1049
+ }
1050
+ /** Appends symbols considering flags */
1051
+ append(e, t, s) {
1052
+ if (!X(e)) throw new Error("value should be string");
1053
+ const r = X(s) ? new H(String(s)) : s;
1054
+ t != null && t.tail && (t._beforeTailState = this.state);
1055
+ let n;
1056
+ [e, n] = this.doPrepare(e, t);
1057
+ for (let a = 0; a < e.length; ++a) {
1058
+ const l = this._appendChar(e[a], t, r);
1059
+ if (!l.rawInserted && !this.doSkipInvalid(e[a], t, r)) break;
1060
+ n.aggregate(l);
1061
+ }
1062
+ return (this.eager === !0 || this.eager === "append") && t != null && t.input && e && n.aggregate(this._appendEager()), r != null && (n.tailShift += this.appendTail(r).tailShift), n;
1063
+ }
1064
+ remove(e, t) {
1065
+ return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), this._value = this.displayValue.slice(0, e) + this.displayValue.slice(t), new S();
1066
+ }
1067
+ /** Calls function and reapplies current value */
1068
+ withValueRefresh(e) {
1069
+ if (this._refreshing || !this._initialized) return e();
1070
+ this._refreshing = !0;
1071
+ const t = this.rawInputValue, s = this.value, r = e();
1072
+ return this.rawInputValue = t, this.value && this.value !== s && s.indexOf(this.value) === 0 && (this.append(s.slice(this.displayValue.length), {}, ""), this.doCommit()), delete this._refreshing, r;
1073
+ }
1074
+ runIsolated(e) {
1075
+ if (this._isolated || !this._initialized) return e(this);
1076
+ this._isolated = !0;
1077
+ const t = this.state, s = e(this);
1078
+ return this.state = t, delete this._isolated, s;
1079
+ }
1080
+ doSkipInvalid(e, t, s) {
1081
+ return !!this.skipInvalid;
1082
+ }
1083
+ /** Prepares string before mask processing */
1084
+ doPrepare(e, t) {
1085
+ return t === void 0 && (t = {}), S.normalize(this.prepare ? this.prepare(e, this, t) : e);
1086
+ }
1087
+ /** Prepares each char before mask processing */
1088
+ doPrepareChar(e, t) {
1089
+ return t === void 0 && (t = {}), S.normalize(this.prepareChar ? this.prepareChar(e, this, t) : e);
1090
+ }
1091
+ /** Validates if value is acceptable */
1092
+ doValidate(e) {
1093
+ return (!this.validate || this.validate(this.value, this, e)) && (!this.parent || this.parent.doValidate(e));
1094
+ }
1095
+ /** Does additional processing at the end of editing */
1096
+ doCommit() {
1097
+ this.commit && this.commit(this.value, this);
1098
+ }
1099
+ splice(e, t, s, r, n) {
1100
+ s === void 0 && (s = ""), r === void 0 && (r = b.NONE), n === void 0 && (n = {
1101
+ input: !0
1102
+ });
1103
+ const a = e + t, l = this.extractTail(a), u = this.eager === !0 || this.eager === "remove";
1104
+ let o;
1105
+ u && (r = Nt(r), o = this.extractInput(0, a, {
1106
+ raw: !0
1107
+ }));
1108
+ let v = e;
1109
+ const f = new S();
1110
+ if (r !== b.NONE && (v = this.nearestInputPos(e, t > 1 && e !== 0 && !u ? b.NONE : r), f.tailShift = v - e), f.aggregate(this.remove(v)), u && r !== b.NONE && o === this.rawInputValue)
1111
+ if (r === b.FORCE_LEFT) {
1112
+ let m;
1113
+ for (; o === this.rawInputValue && (m = this.displayValue.length); )
1114
+ f.aggregate(new S({
1115
+ tailShift: -1
1116
+ })).aggregate(this.remove(m - 1));
1117
+ } else r === b.FORCE_RIGHT && l.unshift();
1118
+ return f.aggregate(this.append(s, n, l));
1119
+ }
1120
+ maskEquals(e) {
1121
+ return this.mask === e;
1122
+ }
1123
+ optionsIsChanged(e) {
1124
+ return !le(this, e);
1125
+ }
1126
+ typedValueEquals(e) {
1127
+ const t = this.typedValue;
1128
+ return e === t || L.EMPTY_VALUES.includes(e) && L.EMPTY_VALUES.includes(t) || (this.format ? this.format(e, this) === this.format(this.typedValue, this) : !1);
1129
+ }
1130
+ pad(e) {
1131
+ return new S();
1132
+ }
1133
+ }
1134
+ L.DEFAULTS = {
1135
+ skipInvalid: !0
1136
+ };
1137
+ L.EMPTY_VALUES = [void 0, null, ""];
1138
+ _.Masked = L;
1139
+ class Q {
1140
+ /** */
1141
+ constructor(e, t) {
1142
+ e === void 0 && (e = []), t === void 0 && (t = 0), this.chunks = e, this.from = t;
1143
+ }
1144
+ toString() {
1145
+ return this.chunks.map(String).join("");
1146
+ }
1147
+ extend(e) {
1148
+ if (!String(e)) return;
1149
+ e = X(e) ? new H(String(e)) : e;
1150
+ const t = this.chunks[this.chunks.length - 1], s = t && // if stops are same or tail has no stop
1151
+ (t.stop === e.stop || e.stop == null) && // if tail chunk goes just after last chunk
1152
+ e.from === t.from + t.toString().length;
1153
+ if (e instanceof H)
1154
+ s ? t.extend(e.toString()) : this.chunks.push(e);
1155
+ else if (e instanceof Q) {
1156
+ if (e.stop == null) {
1157
+ let r;
1158
+ for (; e.chunks.length && e.chunks[0].stop == null; )
1159
+ r = e.chunks.shift(), r.from += e.from, this.extend(r);
1160
+ }
1161
+ e.toString() && (e.stop = e.blockIndex, this.chunks.push(e));
1162
+ }
1163
+ }
1164
+ appendTo(e) {
1165
+ if (!(e instanceof _.MaskedPattern))
1166
+ return new H(this.toString()).appendTo(e);
1167
+ const t = new S();
1168
+ for (let s = 0; s < this.chunks.length; ++s) {
1169
+ const r = this.chunks[s], n = e._mapPosToBlock(e.displayValue.length), a = r.stop;
1170
+ let l;
1171
+ if (a != null && // if block not found or stop is behind lastBlock
1172
+ (!n || n.index <= a) && ((r instanceof Q || // for continuous block also check if stop is exist
1173
+ e._stops.indexOf(a) >= 0) && t.aggregate(e._appendPlaceholder(a)), l = r instanceof Q && e._blocks[a]), l) {
1174
+ const u = l.appendTail(r);
1175
+ t.aggregate(u);
1176
+ const o = r.toString().slice(u.rawInserted.length);
1177
+ o && t.aggregate(e.append(o, {
1178
+ tail: !0
1179
+ }));
1180
+ } else
1181
+ t.aggregate(e.append(r.toString(), {
1182
+ tail: !0
1183
+ }));
1184
+ }
1185
+ return t;
1186
+ }
1187
+ get state() {
1188
+ return {
1189
+ chunks: this.chunks.map((e) => e.state),
1190
+ from: this.from,
1191
+ stop: this.stop,
1192
+ blockIndex: this.blockIndex
1193
+ };
1194
+ }
1195
+ set state(e) {
1196
+ const {
1197
+ chunks: t,
1198
+ ...s
1199
+ } = e;
1200
+ Object.assign(this, s), this.chunks = t.map((r) => {
1201
+ const n = "chunks" in r ? new Q() : new H();
1202
+ return n.state = r, n;
1203
+ });
1204
+ }
1205
+ unshift(e) {
1206
+ if (!this.chunks.length || e != null && this.from >= e) return "";
1207
+ const t = e != null ? e - this.from : e;
1208
+ let s = 0;
1209
+ for (; s < this.chunks.length; ) {
1210
+ const r = this.chunks[s], n = r.unshift(t);
1211
+ if (r.toString()) {
1212
+ if (!n) break;
1213
+ ++s;
1214
+ } else
1215
+ this.chunks.splice(s, 1);
1216
+ if (n) return n;
1217
+ }
1218
+ return "";
1219
+ }
1220
+ shift() {
1221
+ if (!this.chunks.length) return "";
1222
+ let e = this.chunks.length - 1;
1223
+ for (; 0 <= e; ) {
1224
+ const t = this.chunks[e], s = t.shift();
1225
+ if (t.toString()) {
1226
+ if (!s) break;
1227
+ --e;
1228
+ } else
1229
+ this.chunks.splice(e, 1);
1230
+ if (s) return s;
1231
+ }
1232
+ return "";
1233
+ }
1234
+ }
1235
+ class Pt {
1236
+ constructor(e, t) {
1237
+ this.masked = e, this._log = [];
1238
+ const {
1239
+ offset: s,
1240
+ index: r
1241
+ } = e._mapPosToBlock(t) || (t < 0 ? (
1242
+ // first
1243
+ {
1244
+ index: 0,
1245
+ offset: 0
1246
+ }
1247
+ ) : (
1248
+ // last
1249
+ {
1250
+ index: this.masked._blocks.length,
1251
+ offset: 0
1252
+ }
1253
+ ));
1254
+ this.offset = s, this.index = r, this.ok = !1;
1255
+ }
1256
+ get block() {
1257
+ return this.masked._blocks[this.index];
1258
+ }
1259
+ get pos() {
1260
+ return this.masked._blockStartPos(this.index) + this.offset;
1261
+ }
1262
+ get state() {
1263
+ return {
1264
+ index: this.index,
1265
+ offset: this.offset,
1266
+ ok: this.ok
1267
+ };
1268
+ }
1269
+ set state(e) {
1270
+ Object.assign(this, e);
1271
+ }
1272
+ pushState() {
1273
+ this._log.push(this.state);
1274
+ }
1275
+ popState() {
1276
+ const e = this._log.pop();
1277
+ return e && (this.state = e), e;
1278
+ }
1279
+ bindBlock() {
1280
+ this.block || (this.index < 0 && (this.index = 0, this.offset = 0), this.index >= this.masked._blocks.length && (this.index = this.masked._blocks.length - 1, this.offset = this.block.displayValue.length));
1281
+ }
1282
+ _pushLeft(e) {
1283
+ for (this.pushState(), this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((t = this.block) == null ? void 0 : t.displayValue.length) || 0) {
1284
+ var t;
1285
+ if (e()) return this.ok = !0;
1286
+ }
1287
+ return this.ok = !1;
1288
+ }
1289
+ _pushRight(e) {
1290
+ for (this.pushState(), this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0)
1291
+ if (e()) return this.ok = !0;
1292
+ return this.ok = !1;
1293
+ }
1294
+ pushLeftBeforeFilled() {
1295
+ return this._pushLeft(() => {
1296
+ if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, b.FORCE_LEFT), this.offset !== 0))
1297
+ return !0;
1298
+ });
1299
+ }
1300
+ pushLeftBeforeInput() {
1301
+ return this._pushLeft(() => {
1302
+ if (!this.block.isFixed)
1303
+ return this.offset = this.block.nearestInputPos(this.offset, b.LEFT), !0;
1304
+ });
1305
+ }
1306
+ pushLeftBeforeRequired() {
1307
+ return this._pushLeft(() => {
1308
+ if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
1309
+ return this.offset = this.block.nearestInputPos(this.offset, b.LEFT), !0;
1310
+ });
1311
+ }
1312
+ pushRightBeforeFilled() {
1313
+ return this._pushRight(() => {
1314
+ if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, b.FORCE_RIGHT), this.offset !== this.block.value.length))
1315
+ return !0;
1316
+ });
1317
+ }
1318
+ pushRightBeforeInput() {
1319
+ return this._pushRight(() => {
1320
+ if (!this.block.isFixed)
1321
+ return this.offset = this.block.nearestInputPos(this.offset, b.NONE), !0;
1322
+ });
1323
+ }
1324
+ pushRightBeforeRequired() {
1325
+ return this._pushRight(() => {
1326
+ if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
1327
+ return this.offset = this.block.nearestInputPos(this.offset, b.NONE), !0;
1328
+ });
1329
+ }
1330
+ }
1331
+ class Ge {
1332
+ /** */
1333
+ /** */
1334
+ /** */
1335
+ /** */
1336
+ /** */
1337
+ /** */
1338
+ constructor(e) {
1339
+ Object.assign(this, e), this._value = "", this.isFixed = !0;
1340
+ }
1341
+ get value() {
1342
+ return this._value;
1343
+ }
1344
+ get unmaskedValue() {
1345
+ return this.isUnmasking ? this.value : "";
1346
+ }
1347
+ get rawInputValue() {
1348
+ return this._isRawInput ? this.value : "";
1349
+ }
1350
+ get displayValue() {
1351
+ return this.value;
1352
+ }
1353
+ reset() {
1354
+ this._isRawInput = !1, this._value = "";
1355
+ }
1356
+ remove(e, t) {
1357
+ return e === void 0 && (e = 0), t === void 0 && (t = this._value.length), this._value = this._value.slice(0, e) + this._value.slice(t), this._value || (this._isRawInput = !1), new S();
1358
+ }
1359
+ nearestInputPos(e, t) {
1360
+ t === void 0 && (t = b.NONE);
1361
+ const s = 0, r = this._value.length;
1362
+ switch (t) {
1363
+ case b.LEFT:
1364
+ case b.FORCE_LEFT:
1365
+ return s;
1366
+ case b.NONE:
1367
+ case b.RIGHT:
1368
+ case b.FORCE_RIGHT:
1369
+ default:
1370
+ return r;
1371
+ }
1372
+ }
1373
+ totalInputPositions(e, t) {
1374
+ return e === void 0 && (e = 0), t === void 0 && (t = this._value.length), this._isRawInput ? t - e : 0;
1375
+ }
1376
+ extractInput(e, t, s) {
1377
+ return e === void 0 && (e = 0), t === void 0 && (t = this._value.length), s === void 0 && (s = {}), s.raw && this._isRawInput && this._value.slice(e, t) || "";
1378
+ }
1379
+ get isComplete() {
1380
+ return !0;
1381
+ }
1382
+ get isFilled() {
1383
+ return !!this._value;
1384
+ }
1385
+ _appendChar(e, t) {
1386
+ if (t === void 0 && (t = {}), this.isFilled) return new S();
1387
+ const s = this.eager === !0 || this.eager === "append", n = this.char === e && (this.isUnmasking || t.input || t.raw) && (!t.raw || !s) && !t.tail, a = new S({
1388
+ inserted: this.char,
1389
+ rawInserted: n ? this.char : ""
1390
+ });
1391
+ return this._value = this.char, this._isRawInput = n && (t.raw || t.input), a;
1392
+ }
1393
+ _appendEager() {
1394
+ return this._appendChar(this.char, {
1395
+ tail: !0
1396
+ });
1397
+ }
1398
+ _appendPlaceholder() {
1399
+ const e = new S();
1400
+ return this.isFilled || (this._value = e.inserted = this.char), e;
1401
+ }
1402
+ extractTail() {
1403
+ return new H("");
1404
+ }
1405
+ appendTail(e) {
1406
+ return X(e) && (e = new H(String(e))), e.appendTo(this);
1407
+ }
1408
+ append(e, t, s) {
1409
+ const r = this._appendChar(e[0], t);
1410
+ return s != null && (r.tailShift += this.appendTail(s).tailShift), r;
1411
+ }
1412
+ doCommit() {
1413
+ }
1414
+ get state() {
1415
+ return {
1416
+ _value: this._value,
1417
+ _rawInputValue: this.rawInputValue
1418
+ };
1419
+ }
1420
+ set state(e) {
1421
+ this._value = e._value, this._isRawInput = !!e._rawInputValue;
1422
+ }
1423
+ pad(e) {
1424
+ return this._appendPlaceholder();
1425
+ }
1426
+ }
1427
+ class ue {
1428
+ /** */
1429
+ /** */
1430
+ /** */
1431
+ /** */
1432
+ /** */
1433
+ /** */
1434
+ /** */
1435
+ /** */
1436
+ constructor(e) {
1437
+ const {
1438
+ parent: t,
1439
+ isOptional: s,
1440
+ placeholderChar: r,
1441
+ displayChar: n,
1442
+ lazy: a,
1443
+ eager: l,
1444
+ ...u
1445
+ } = e;
1446
+ this.masked = Y(u), Object.assign(this, {
1447
+ parent: t,
1448
+ isOptional: s,
1449
+ placeholderChar: r,
1450
+ displayChar: n,
1451
+ lazy: a,
1452
+ eager: l
1453
+ });
1454
+ }
1455
+ reset() {
1456
+ this.isFilled = !1, this.masked.reset();
1457
+ }
1458
+ remove(e, t) {
1459
+ return e === void 0 && (e = 0), t === void 0 && (t = this.value.length), e === 0 && t >= 1 ? (this.isFilled = !1, this.masked.remove(e, t)) : new S();
1460
+ }
1461
+ get value() {
1462
+ return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : "");
1463
+ }
1464
+ get unmaskedValue() {
1465
+ return this.masked.unmaskedValue;
1466
+ }
1467
+ get rawInputValue() {
1468
+ return this.masked.rawInputValue;
1469
+ }
1470
+ get displayValue() {
1471
+ return this.masked.value && this.displayChar || this.value;
1472
+ }
1473
+ get isComplete() {
1474
+ return !!this.masked.value || this.isOptional;
1475
+ }
1476
+ _appendChar(e, t) {
1477
+ if (t === void 0 && (t = {}), this.isFilled) return new S();
1478
+ const s = this.masked.state;
1479
+ let r = this.masked._appendChar(e, this.currentMaskFlags(t));
1480
+ return r.inserted && this.doValidate(t) === !1 && (r = new S(), this.masked.state = s), !r.inserted && !this.isOptional && !this.lazy && !t.input && (r.inserted = this.placeholderChar), r.skip = !r.inserted && !this.isOptional, this.isFilled = !!r.inserted, r;
1481
+ }
1482
+ append(e, t, s) {
1483
+ return this.masked.append(e, this.currentMaskFlags(t), s);
1484
+ }
1485
+ _appendPlaceholder() {
1486
+ return this.isFilled || this.isOptional ? new S() : (this.isFilled = !0, new S({
1487
+ inserted: this.placeholderChar
1488
+ }));
1489
+ }
1490
+ _appendEager() {
1491
+ return new S();
1492
+ }
1493
+ extractTail(e, t) {
1494
+ return this.masked.extractTail(e, t);
1495
+ }
1496
+ appendTail(e) {
1497
+ return this.masked.appendTail(e);
1498
+ }
1499
+ extractInput(e, t, s) {
1500
+ return e === void 0 && (e = 0), t === void 0 && (t = this.value.length), this.masked.extractInput(e, t, s);
1501
+ }
1502
+ nearestInputPos(e, t) {
1503
+ t === void 0 && (t = b.NONE);
1504
+ const s = 0, r = this.value.length, n = Math.min(Math.max(e, s), r);
1505
+ switch (t) {
1506
+ case b.LEFT:
1507
+ case b.FORCE_LEFT:
1508
+ return this.isComplete ? n : s;
1509
+ case b.RIGHT:
1510
+ case b.FORCE_RIGHT:
1511
+ return this.isComplete ? n : r;
1512
+ case b.NONE:
1513
+ default:
1514
+ return n;
1515
+ }
1516
+ }
1517
+ totalInputPositions(e, t) {
1518
+ return e === void 0 && (e = 0), t === void 0 && (t = this.value.length), this.value.slice(e, t).length;
1519
+ }
1520
+ doValidate(e) {
1521
+ return this.masked.doValidate(this.currentMaskFlags(e)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(e)));
1522
+ }
1523
+ doCommit() {
1524
+ this.masked.doCommit();
1525
+ }
1526
+ get state() {
1527
+ return {
1528
+ _value: this.value,
1529
+ _rawInputValue: this.rawInputValue,
1530
+ masked: this.masked.state,
1531
+ isFilled: this.isFilled
1532
+ };
1533
+ }
1534
+ set state(e) {
1535
+ this.masked.state = e.masked, this.isFilled = e.isFilled;
1536
+ }
1537
+ currentMaskFlags(e) {
1538
+ var t;
1539
+ return {
1540
+ ...e,
1541
+ _beforeTailState: (e == null || (t = e._beforeTailState) == null ? void 0 : t.masked) || (e == null ? void 0 : e._beforeTailState)
1542
+ };
1543
+ }
1544
+ pad(e) {
1545
+ return new S();
1546
+ }
1547
+ }
1548
+ ue.DEFAULT_DEFINITIONS = {
1549
+ 0: /\d/,
1550
+ a: /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
1551
+ // http://stackoverflow.com/a/22075070
1552
+ "*": /./
1553
+ };
1554
+ class jt extends L {
1555
+ /** */
1556
+ /** Enable characters overwriting */
1557
+ /** */
1558
+ /** */
1559
+ /** */
1560
+ updateOptions(e) {
1561
+ super.updateOptions(e);
1562
+ }
1563
+ _update(e) {
1564
+ const t = e.mask;
1565
+ t && (e.validate = (s) => s.search(t) >= 0), super._update(e);
1566
+ }
1567
+ }
1568
+ _.MaskedRegExp = jt;
1569
+ class N extends L {
1570
+ /** */
1571
+ /** */
1572
+ /** Single char for empty input */
1573
+ /** Single char for filled input */
1574
+ /** Show placeholder only when needed */
1575
+ /** Enable characters overwriting */
1576
+ /** */
1577
+ /** */
1578
+ /** */
1579
+ constructor(e) {
1580
+ super({
1581
+ ...N.DEFAULTS,
1582
+ ...e,
1583
+ definitions: Object.assign({}, ue.DEFAULT_DEFINITIONS, e == null ? void 0 : e.definitions)
1584
+ });
1585
+ }
1586
+ updateOptions(e) {
1587
+ super.updateOptions(e);
1588
+ }
1589
+ _update(e) {
1590
+ e.definitions = Object.assign({}, this.definitions, e.definitions), super._update(e), this._rebuildMask();
1591
+ }
1592
+ _rebuildMask() {
1593
+ const e = this.definitions;
1594
+ this._blocks = [], this.exposeBlock = void 0, this._stops = [], this._maskedBlocks = {};
1595
+ const t = this.mask;
1596
+ if (!t || !e) return;
1597
+ let s = !1, r = !1;
1598
+ for (let n = 0; n < t.length; ++n) {
1599
+ if (this.blocks) {
1600
+ const o = t.slice(n), v = Object.keys(this.blocks).filter((m) => o.indexOf(m) === 0);
1601
+ v.sort((m, x) => x.length - m.length);
1602
+ const f = v[0];
1603
+ if (f) {
1604
+ const {
1605
+ expose: m,
1606
+ repeat: x,
1607
+ ...g
1608
+ } = re(this.blocks[f]), h = {
1609
+ lazy: this.lazy,
1610
+ eager: this.eager,
1611
+ placeholderChar: this.placeholderChar,
1612
+ displayChar: this.displayChar,
1613
+ overwrite: this.overwrite,
1614
+ autofix: this.autofix,
1615
+ ...g,
1616
+ repeat: x,
1617
+ parent: this
1618
+ }, k = x != null ? new _.RepeatBlock(
1619
+ h
1620
+ /* TODO */
1621
+ ) : Y(h);
1622
+ k && (this._blocks.push(k), m && (this.exposeBlock = k), this._maskedBlocks[f] || (this._maskedBlocks[f] = []), this._maskedBlocks[f].push(this._blocks.length - 1)), n += f.length - 1;
1623
+ continue;
1624
+ }
1625
+ }
1626
+ let a = t[n], l = a in e;
1627
+ if (a === N.STOP_CHAR) {
1628
+ this._stops.push(this._blocks.length);
1629
+ continue;
1630
+ }
1631
+ if (a === "{" || a === "}") {
1632
+ s = !s;
1633
+ continue;
1634
+ }
1635
+ if (a === "[" || a === "]") {
1636
+ r = !r;
1637
+ continue;
1638
+ }
1639
+ if (a === N.ESCAPE_CHAR) {
1640
+ if (++n, a = t[n], !a) break;
1641
+ l = !1;
1642
+ }
1643
+ const u = l ? new ue({
1644
+ isOptional: r,
1645
+ lazy: this.lazy,
1646
+ eager: this.eager,
1647
+ placeholderChar: this.placeholderChar,
1648
+ displayChar: this.displayChar,
1649
+ ...re(e[a]),
1650
+ parent: this
1651
+ }) : new Ge({
1652
+ char: a,
1653
+ eager: this.eager,
1654
+ isUnmasking: s
1655
+ });
1656
+ this._blocks.push(u);
1657
+ }
1658
+ }
1659
+ get state() {
1660
+ return {
1661
+ ...super.state,
1662
+ _blocks: this._blocks.map((e) => e.state)
1663
+ };
1664
+ }
1665
+ set state(e) {
1666
+ if (!e) {
1667
+ this.reset();
1668
+ return;
1669
+ }
1670
+ const {
1671
+ _blocks: t,
1672
+ ...s
1673
+ } = e;
1674
+ this._blocks.forEach((r, n) => r.state = t[n]), super.state = s;
1675
+ }
1676
+ reset() {
1677
+ super.reset(), this._blocks.forEach((e) => e.reset());
1678
+ }
1679
+ get isComplete() {
1680
+ return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every((e) => e.isComplete);
1681
+ }
1682
+ get isFilled() {
1683
+ return this._blocks.every((e) => e.isFilled);
1684
+ }
1685
+ get isFixed() {
1686
+ return this._blocks.every((e) => e.isFixed);
1687
+ }
1688
+ get isOptional() {
1689
+ return this._blocks.every((e) => e.isOptional);
1690
+ }
1691
+ doCommit() {
1692
+ this._blocks.forEach((e) => e.doCommit()), super.doCommit();
1693
+ }
1694
+ get unmaskedValue() {
1695
+ return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((e, t) => e += t.unmaskedValue, "");
1696
+ }
1697
+ set unmaskedValue(e) {
1698
+ if (this.exposeBlock) {
1699
+ const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1700
+ this.exposeBlock.unmaskedValue = e, this.appendTail(t), this.doCommit();
1701
+ } else super.unmaskedValue = e;
1702
+ }
1703
+ get value() {
1704
+ return this.exposeBlock ? this.exposeBlock.value : (
1705
+ // TODO return _value when not in change?
1706
+ this._blocks.reduce((e, t) => e += t.value, "")
1707
+ );
1708
+ }
1709
+ set value(e) {
1710
+ if (this.exposeBlock) {
1711
+ const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1712
+ this.exposeBlock.value = e, this.appendTail(t), this.doCommit();
1713
+ } else super.value = e;
1714
+ }
1715
+ get typedValue() {
1716
+ return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
1717
+ }
1718
+ set typedValue(e) {
1719
+ if (this.exposeBlock) {
1720
+ const t = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1721
+ this.exposeBlock.typedValue = e, this.appendTail(t), this.doCommit();
1722
+ } else super.typedValue = e;
1723
+ }
1724
+ get displayValue() {
1725
+ return this._blocks.reduce((e, t) => e += t.displayValue, "");
1726
+ }
1727
+ appendTail(e) {
1728
+ return super.appendTail(e).aggregate(this._appendPlaceholder());
1729
+ }
1730
+ _appendEager() {
1731
+ var e;
1732
+ const t = new S();
1733
+ let s = (e = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : e.index;
1734
+ if (s == null) return t;
1735
+ this._blocks[s].isFilled && ++s;
1736
+ for (let r = s; r < this._blocks.length; ++r) {
1737
+ const n = this._blocks[r]._appendEager();
1738
+ if (!n.inserted) break;
1739
+ t.aggregate(n);
1740
+ }
1741
+ return t;
1742
+ }
1743
+ _appendCharRaw(e, t) {
1744
+ t === void 0 && (t = {});
1745
+ const s = this._mapPosToBlock(this.displayValue.length), r = new S();
1746
+ if (!s) return r;
1747
+ for (let a = s.index, l; l = this._blocks[a]; ++a) {
1748
+ var n;
1749
+ const u = l._appendChar(e, {
1750
+ ...t,
1751
+ _beforeTailState: (n = t._beforeTailState) == null || (n = n._blocks) == null ? void 0 : n[a]
1752
+ });
1753
+ if (r.aggregate(u), u.consumed) break;
1754
+ }
1755
+ return r;
1756
+ }
1757
+ extractTail(e, t) {
1758
+ e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
1759
+ const s = new Q();
1760
+ return e === t || this._forEachBlocksInRange(e, t, (r, n, a, l) => {
1761
+ const u = r.extractTail(a, l);
1762
+ u.stop = this._findStopBefore(n), u.from = this._blockStartPos(n), u instanceof Q && (u.blockIndex = n), s.extend(u);
1763
+ }), s;
1764
+ }
1765
+ extractInput(e, t, s) {
1766
+ if (e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), s === void 0 && (s = {}), e === t) return "";
1767
+ let r = "";
1768
+ return this._forEachBlocksInRange(e, t, (n, a, l, u) => {
1769
+ r += n.extractInput(l, u, s);
1770
+ }), r;
1771
+ }
1772
+ _findStopBefore(e) {
1773
+ let t;
1774
+ for (let s = 0; s < this._stops.length; ++s) {
1775
+ const r = this._stops[s];
1776
+ if (r <= e) t = r;
1777
+ else break;
1778
+ }
1779
+ return t;
1780
+ }
1781
+ /** Appends placeholder depending on laziness */
1782
+ _appendPlaceholder(e) {
1783
+ const t = new S();
1784
+ if (this.lazy && e == null) return t;
1785
+ const s = this._mapPosToBlock(this.displayValue.length);
1786
+ if (!s) return t;
1787
+ const r = s.index, n = e ?? this._blocks.length;
1788
+ return this._blocks.slice(r, n).forEach((a) => {
1789
+ if (!a.lazy || e != null) {
1790
+ var l;
1791
+ t.aggregate(a._appendPlaceholder((l = a._blocks) == null ? void 0 : l.length));
1792
+ }
1793
+ }), t;
1794
+ }
1795
+ /** Finds block in pos */
1796
+ _mapPosToBlock(e) {
1797
+ let t = "";
1798
+ for (let s = 0; s < this._blocks.length; ++s) {
1799
+ const r = this._blocks[s], n = t.length;
1800
+ if (t += r.displayValue, e <= t.length)
1801
+ return {
1802
+ index: s,
1803
+ offset: e - n
1804
+ };
1805
+ }
1806
+ }
1807
+ _blockStartPos(e) {
1808
+ return this._blocks.slice(0, e).reduce((t, s) => t += s.displayValue.length, 0);
1809
+ }
1810
+ _forEachBlocksInRange(e, t, s) {
1811
+ t === void 0 && (t = this.displayValue.length);
1812
+ const r = this._mapPosToBlock(e);
1813
+ if (r) {
1814
+ const n = this._mapPosToBlock(t), a = n && r.index === n.index, l = r.offset, u = n && a ? n.offset : this._blocks[r.index].displayValue.length;
1815
+ if (s(this._blocks[r.index], r.index, l, u), n && !a) {
1816
+ for (let o = r.index + 1; o < n.index; ++o)
1817
+ s(this._blocks[o], o, 0, this._blocks[o].displayValue.length);
1818
+ s(this._blocks[n.index], n.index, 0, n.offset);
1819
+ }
1820
+ }
1821
+ }
1822
+ remove(e, t) {
1823
+ e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
1824
+ const s = super.remove(e, t);
1825
+ return this._forEachBlocksInRange(e, t, (r, n, a, l) => {
1826
+ s.aggregate(r.remove(a, l));
1827
+ }), s;
1828
+ }
1829
+ nearestInputPos(e, t) {
1830
+ if (t === void 0 && (t = b.NONE), !this._blocks.length) return 0;
1831
+ const s = new Pt(this, e);
1832
+ if (t === b.NONE)
1833
+ return s.pushRightBeforeInput() || (s.popState(), s.pushLeftBeforeInput()) ? s.pos : this.displayValue.length;
1834
+ if (t === b.LEFT || t === b.FORCE_LEFT) {
1835
+ if (t === b.LEFT) {
1836
+ if (s.pushRightBeforeFilled(), s.ok && s.pos === e) return e;
1837
+ s.popState();
1838
+ }
1839
+ if (s.pushLeftBeforeInput(), s.pushLeftBeforeRequired(), s.pushLeftBeforeFilled(), t === b.LEFT) {
1840
+ if (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.ok && s.pos <= e || (s.popState(), s.ok && s.pos <= e)) return s.pos;
1841
+ s.popState();
1842
+ }
1843
+ return s.ok ? s.pos : t === b.FORCE_LEFT ? 0 : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : 0);
1844
+ }
1845
+ return t === b.RIGHT || t === b.FORCE_RIGHT ? (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.pushRightBeforeFilled() ? s.pos : t === b.FORCE_RIGHT ? this.displayValue.length : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : this.nearestInputPos(e, b.LEFT))) : e;
1846
+ }
1847
+ totalInputPositions(e, t) {
1848
+ e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
1849
+ let s = 0;
1850
+ return this._forEachBlocksInRange(e, t, (r, n, a, l) => {
1851
+ s += r.totalInputPositions(a, l);
1852
+ }), s;
1853
+ }
1854
+ /** Get block by name */
1855
+ maskedBlock(e) {
1856
+ return this.maskedBlocks(e)[0];
1857
+ }
1858
+ /** Get all blocks by name */
1859
+ maskedBlocks(e) {
1860
+ const t = this._maskedBlocks[e];
1861
+ return t ? t.map((s) => this._blocks[s]) : [];
1862
+ }
1863
+ pad(e) {
1864
+ const t = new S();
1865
+ return this._forEachBlocksInRange(0, this.displayValue.length, (s) => t.aggregate(s.pad(e))), t;
1866
+ }
1867
+ }
1868
+ N.DEFAULTS = {
1869
+ ...L.DEFAULTS,
1870
+ lazy: !0,
1871
+ placeholderChar: "_"
1872
+ };
1873
+ N.STOP_CHAR = "`";
1874
+ N.ESCAPE_CHAR = "\\";
1875
+ N.InputDefinition = ue;
1876
+ N.FixedDefinition = Ge;
1877
+ _.MaskedPattern = N;
1878
+ class ne extends N {
1879
+ /**
1880
+ Optionally sets max length of pattern.
1881
+ Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
1882
+ */
1883
+ /** Min bound */
1884
+ /** Max bound */
1885
+ get _matchFrom() {
1886
+ return this.maxLength - String(this.from).length;
1887
+ }
1888
+ constructor(e) {
1889
+ super(e);
1890
+ }
1891
+ updateOptions(e) {
1892
+ super.updateOptions(e);
1893
+ }
1894
+ _update(e) {
1895
+ const {
1896
+ to: t = this.to || 0,
1897
+ from: s = this.from || 0,
1898
+ maxLength: r = this.maxLength || 0,
1899
+ autofix: n = this.autofix,
1900
+ ...a
1901
+ } = e;
1902
+ this.to = t, this.from = s, this.maxLength = Math.max(String(t).length, r), this.autofix = n;
1903
+ const l = String(this.from).padStart(this.maxLength, "0"), u = String(this.to).padStart(this.maxLength, "0");
1904
+ let o = 0;
1905
+ for (; o < u.length && u[o] === l[o]; ) ++o;
1906
+ a.mask = u.slice(0, o).replace(/0/g, "\\0") + "0".repeat(this.maxLength - o), super._update(a);
1907
+ }
1908
+ get isComplete() {
1909
+ return super.isComplete && !!this.value;
1910
+ }
1911
+ boundaries(e) {
1912
+ let t = "", s = "";
1913
+ const [, r, n] = e.match(/^(\D*)(\d*)(\D*)/) || [];
1914
+ return n && (t = "0".repeat(r.length) + n, s = "9".repeat(r.length) + n), t = t.padEnd(this.maxLength, "0"), s = s.padEnd(this.maxLength, "9"), [t, s];
1915
+ }
1916
+ doPrepareChar(e, t) {
1917
+ t === void 0 && (t = {});
1918
+ let s;
1919
+ return [e, s] = super.doPrepareChar(e.replace(/\D/g, ""), t), e || (s.skip = !this.isComplete), [e, s];
1920
+ }
1921
+ _appendCharRaw(e, t) {
1922
+ if (t === void 0 && (t = {}), !this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(e, t);
1923
+ const s = String(this.from).padStart(this.maxLength, "0"), r = String(this.to).padStart(this.maxLength, "0"), [n, a] = this.boundaries(this.value + e);
1924
+ return Number(a) < this.from ? super._appendCharRaw(s[this.value.length], t) : Number(n) > this.to ? !t.tail && this.autofix === "pad" && this.value.length + 1 < this.maxLength ? super._appendCharRaw(s[this.value.length], t).aggregate(this._appendCharRaw(e, t)) : super._appendCharRaw(r[this.value.length], t) : super._appendCharRaw(e, t);
1925
+ }
1926
+ doValidate(e) {
1927
+ const t = this.value;
1928
+ if (t.search(/[^0]/) === -1 && t.length <= this._matchFrom) return !0;
1929
+ const [r, n] = this.boundaries(t);
1930
+ return this.from <= Number(n) && Number(r) <= this.to && super.doValidate(e);
1931
+ }
1932
+ pad(e) {
1933
+ const t = new S();
1934
+ if (this.value.length === this.maxLength) return t;
1935
+ const s = this.value, r = this.maxLength - this.value.length;
1936
+ if (r) {
1937
+ this.reset();
1938
+ for (let n = 0; n < r; ++n)
1939
+ t.aggregate(super._appendCharRaw("0", e));
1940
+ s.split("").forEach((n) => this._appendCharRaw(n));
1941
+ }
1942
+ return t;
1943
+ }
1944
+ }
1945
+ _.MaskedRange = ne;
1946
+ const Ht = "d{.}`m{.}`Y";
1947
+ class G extends N {
1948
+ static extractPatternOptions(e) {
1949
+ const {
1950
+ mask: t,
1951
+ pattern: s,
1952
+ ...r
1953
+ } = e;
1954
+ return {
1955
+ ...r,
1956
+ mask: X(t) ? t : s
1957
+ };
1958
+ }
1959
+ /** Pattern mask for date according to {@link MaskedDate#format} */
1960
+ /** Start date */
1961
+ /** End date */
1962
+ /** Format typed value to string */
1963
+ /** Parse string to get typed value */
1964
+ constructor(e) {
1965
+ super(G.extractPatternOptions({
1966
+ ...G.DEFAULTS,
1967
+ ...e
1968
+ }));
1969
+ }
1970
+ updateOptions(e) {
1971
+ super.updateOptions(e);
1972
+ }
1973
+ _update(e) {
1974
+ const {
1975
+ mask: t,
1976
+ pattern: s,
1977
+ blocks: r,
1978
+ ...n
1979
+ } = {
1980
+ ...G.DEFAULTS,
1981
+ ...e
1982
+ }, a = Object.assign({}, G.GET_DEFAULT_BLOCKS());
1983
+ e.min && (a.Y.from = e.min.getFullYear()), e.max && (a.Y.to = e.max.getFullYear()), e.min && e.max && a.Y.from === a.Y.to && (a.m.from = e.min.getMonth() + 1, a.m.to = e.max.getMonth() + 1, a.m.from === a.m.to && (a.d.from = e.min.getDate(), a.d.to = e.max.getDate())), Object.assign(a, this.blocks, r), super._update({
1984
+ ...n,
1985
+ mask: X(t) ? t : s,
1986
+ blocks: a
1987
+ });
1988
+ }
1989
+ doValidate(e) {
1990
+ const t = this.date;
1991
+ return super.doValidate(e) && (!this.isComplete || this.isDateExist(this.value) && t != null && (this.min == null || this.min <= t) && (this.max == null || t <= this.max));
1992
+ }
1993
+ /** Checks if date is exists */
1994
+ isDateExist(e) {
1995
+ return this.format(this.parse(e, this), this).indexOf(e) >= 0;
1996
+ }
1997
+ /** Parsed Date */
1998
+ get date() {
1999
+ return this.typedValue;
2000
+ }
2001
+ set date(e) {
2002
+ this.typedValue = e;
2003
+ }
2004
+ get typedValue() {
2005
+ return this.isComplete ? super.typedValue : null;
2006
+ }
2007
+ set typedValue(e) {
2008
+ super.typedValue = e;
2009
+ }
2010
+ maskEquals(e) {
2011
+ return e === Date || super.maskEquals(e);
2012
+ }
2013
+ optionsIsChanged(e) {
2014
+ return super.optionsIsChanged(G.extractPatternOptions(e));
2015
+ }
2016
+ }
2017
+ G.GET_DEFAULT_BLOCKS = () => ({
2018
+ d: {
2019
+ mask: ne,
2020
+ from: 1,
2021
+ to: 31,
2022
+ maxLength: 2
2023
+ },
2024
+ m: {
2025
+ mask: ne,
2026
+ from: 1,
2027
+ to: 12,
2028
+ maxLength: 2
2029
+ },
2030
+ Y: {
2031
+ mask: ne,
2032
+ from: 1900,
2033
+ to: 9999
2034
+ }
2035
+ });
2036
+ G.DEFAULTS = {
2037
+ ...N.DEFAULTS,
2038
+ mask: Date,
2039
+ pattern: Ht,
2040
+ format: (i, e) => {
2041
+ if (!i) return "";
2042
+ const t = String(i.getDate()).padStart(2, "0"), s = String(i.getMonth() + 1).padStart(2, "0"), r = i.getFullYear();
2043
+ return [t, s, r].join(".");
2044
+ },
2045
+ parse: (i, e) => {
2046
+ const [t, s, r] = i.split(".").map(Number);
2047
+ return new Date(r, s - 1, t);
2048
+ }
2049
+ };
2050
+ _.MaskedDate = G;
2051
+ class he extends L {
2052
+ constructor(e) {
2053
+ super({
2054
+ ...he.DEFAULTS,
2055
+ ...e
2056
+ }), this.currentMask = void 0;
2057
+ }
2058
+ updateOptions(e) {
2059
+ super.updateOptions(e);
2060
+ }
2061
+ _update(e) {
2062
+ super._update(e), "mask" in e && (this.exposeMask = void 0, this.compiledMasks = Array.isArray(e.mask) ? e.mask.map((t) => {
2063
+ const {
2064
+ expose: s,
2065
+ ...r
2066
+ } = re(t), n = Y({
2067
+ overwrite: this._overwrite,
2068
+ eager: this._eager,
2069
+ skipInvalid: this._skipInvalid,
2070
+ ...r
2071
+ });
2072
+ return s && (this.exposeMask = n), n;
2073
+ }) : []);
2074
+ }
2075
+ _appendCharRaw(e, t) {
2076
+ t === void 0 && (t = {});
2077
+ const s = this._applyDispatch(e, t);
2078
+ return this.currentMask && s.aggregate(this.currentMask._appendChar(e, this.currentMaskFlags(t))), s;
2079
+ }
2080
+ _applyDispatch(e, t, s) {
2081
+ e === void 0 && (e = ""), t === void 0 && (t = {}), s === void 0 && (s = "");
2082
+ const r = t.tail && t._beforeTailState != null ? t._beforeTailState._value : this.value, n = this.rawInputValue, a = t.tail && t._beforeTailState != null ? t._beforeTailState._rawInputValue : n, l = n.slice(a.length), u = this.currentMask, o = new S(), v = u == null ? void 0 : u.state;
2083
+ return this.currentMask = this.doDispatch(e, {
2084
+ ...t
2085
+ }, s), this.currentMask && (this.currentMask !== u ? (this.currentMask.reset(), a && (this.currentMask.append(a, {
2086
+ raw: !0
2087
+ }), o.tailShift = this.currentMask.value.length - r.length), l && (o.tailShift += this.currentMask.append(l, {
2088
+ raw: !0,
2089
+ tail: !0
2090
+ }).tailShift)) : v && (this.currentMask.state = v)), o;
2091
+ }
2092
+ _appendPlaceholder() {
2093
+ const e = this._applyDispatch();
2094
+ return this.currentMask && e.aggregate(this.currentMask._appendPlaceholder()), e;
2095
+ }
2096
+ _appendEager() {
2097
+ const e = this._applyDispatch();
2098
+ return this.currentMask && e.aggregate(this.currentMask._appendEager()), e;
2099
+ }
2100
+ appendTail(e) {
2101
+ const t = new S();
2102
+ return e && t.aggregate(this._applyDispatch("", {}, e)), t.aggregate(this.currentMask ? this.currentMask.appendTail(e) : super.appendTail(e));
2103
+ }
2104
+ currentMaskFlags(e) {
2105
+ var t, s;
2106
+ return {
2107
+ ...e,
2108
+ _beforeTailState: ((t = e._beforeTailState) == null ? void 0 : t.currentMaskRef) === this.currentMask && ((s = e._beforeTailState) == null ? void 0 : s.currentMask) || e._beforeTailState
2109
+ };
2110
+ }
2111
+ doDispatch(e, t, s) {
2112
+ return t === void 0 && (t = {}), s === void 0 && (s = ""), this.dispatch(e, this, t, s);
2113
+ }
2114
+ doValidate(e) {
2115
+ return super.doValidate(e) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(e)));
2116
+ }
2117
+ doPrepare(e, t) {
2118
+ t === void 0 && (t = {});
2119
+ let [s, r] = super.doPrepare(e, t);
2120
+ if (this.currentMask) {
2121
+ let n;
2122
+ [s, n] = super.doPrepare(s, this.currentMaskFlags(t)), r = r.aggregate(n);
2123
+ }
2124
+ return [s, r];
2125
+ }
2126
+ doPrepareChar(e, t) {
2127
+ t === void 0 && (t = {});
2128
+ let [s, r] = super.doPrepareChar(e, t);
2129
+ if (this.currentMask) {
2130
+ let n;
2131
+ [s, n] = super.doPrepareChar(s, this.currentMaskFlags(t)), r = r.aggregate(n);
2132
+ }
2133
+ return [s, r];
2134
+ }
2135
+ reset() {
2136
+ var e;
2137
+ (e = this.currentMask) == null || e.reset(), this.compiledMasks.forEach((t) => t.reset());
2138
+ }
2139
+ get value() {
2140
+ return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : "";
2141
+ }
2142
+ set value(e) {
2143
+ this.exposeMask ? (this.exposeMask.value = e, this.currentMask = this.exposeMask, this._applyDispatch()) : super.value = e;
2144
+ }
2145
+ get unmaskedValue() {
2146
+ return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : "";
2147
+ }
2148
+ set unmaskedValue(e) {
2149
+ this.exposeMask ? (this.exposeMask.unmaskedValue = e, this.currentMask = this.exposeMask, this._applyDispatch()) : super.unmaskedValue = e;
2150
+ }
2151
+ get typedValue() {
2152
+ return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : "";
2153
+ }
2154
+ set typedValue(e) {
2155
+ if (this.exposeMask) {
2156
+ this.exposeMask.typedValue = e, this.currentMask = this.exposeMask, this._applyDispatch();
2157
+ return;
2158
+ }
2159
+ let t = String(e);
2160
+ this.currentMask && (this.currentMask.typedValue = e, t = this.currentMask.unmaskedValue), this.unmaskedValue = t;
2161
+ }
2162
+ get displayValue() {
2163
+ return this.currentMask ? this.currentMask.displayValue : "";
2164
+ }
2165
+ get isComplete() {
2166
+ var e;
2167
+ return !!((e = this.currentMask) != null && e.isComplete);
2168
+ }
2169
+ get isFilled() {
2170
+ var e;
2171
+ return !!((e = this.currentMask) != null && e.isFilled);
2172
+ }
2173
+ remove(e, t) {
2174
+ const s = new S();
2175
+ return this.currentMask && s.aggregate(this.currentMask.remove(e, t)).aggregate(this._applyDispatch()), s;
2176
+ }
2177
+ get state() {
2178
+ var e;
2179
+ return {
2180
+ ...super.state,
2181
+ _rawInputValue: this.rawInputValue,
2182
+ compiledMasks: this.compiledMasks.map((t) => t.state),
2183
+ currentMaskRef: this.currentMask,
2184
+ currentMask: (e = this.currentMask) == null ? void 0 : e.state
2185
+ };
2186
+ }
2187
+ set state(e) {
2188
+ const {
2189
+ compiledMasks: t,
2190
+ currentMaskRef: s,
2191
+ currentMask: r,
2192
+ ...n
2193
+ } = e;
2194
+ t && this.compiledMasks.forEach((a, l) => a.state = t[l]), s != null && (this.currentMask = s, this.currentMask.state = r), super.state = n;
2195
+ }
2196
+ extractInput(e, t, s) {
2197
+ return this.currentMask ? this.currentMask.extractInput(e, t, s) : "";
2198
+ }
2199
+ extractTail(e, t) {
2200
+ return this.currentMask ? this.currentMask.extractTail(e, t) : super.extractTail(e, t);
2201
+ }
2202
+ doCommit() {
2203
+ this.currentMask && this.currentMask.doCommit(), super.doCommit();
2204
+ }
2205
+ nearestInputPos(e, t) {
2206
+ return this.currentMask ? this.currentMask.nearestInputPos(e, t) : super.nearestInputPos(e, t);
2207
+ }
2208
+ get overwrite() {
2209
+ return this.currentMask ? this.currentMask.overwrite : this._overwrite;
2210
+ }
2211
+ set overwrite(e) {
2212
+ this._overwrite = e;
2213
+ }
2214
+ get eager() {
2215
+ return this.currentMask ? this.currentMask.eager : this._eager;
2216
+ }
2217
+ set eager(e) {
2218
+ this._eager = e;
2219
+ }
2220
+ get skipInvalid() {
2221
+ return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
2222
+ }
2223
+ set skipInvalid(e) {
2224
+ this._skipInvalid = e;
2225
+ }
2226
+ get autofix() {
2227
+ return this.currentMask ? this.currentMask.autofix : this._autofix;
2228
+ }
2229
+ set autofix(e) {
2230
+ this._autofix = e;
2231
+ }
2232
+ maskEquals(e) {
2233
+ return Array.isArray(e) ? this.compiledMasks.every((t, s) => {
2234
+ if (!e[s]) return;
2235
+ const {
2236
+ mask: r,
2237
+ ...n
2238
+ } = e[s];
2239
+ return le(t, n) && t.maskEquals(r);
2240
+ }) : super.maskEquals(e);
2241
+ }
2242
+ typedValueEquals(e) {
2243
+ var t;
2244
+ return !!((t = this.currentMask) != null && t.typedValueEquals(e));
2245
+ }
2246
+ }
2247
+ he.DEFAULTS = {
2248
+ ...L.DEFAULTS,
2249
+ dispatch: (i, e, t, s) => {
2250
+ if (!e.compiledMasks.length) return;
2251
+ const r = e.rawInputValue, n = e.compiledMasks.map((a, l) => {
2252
+ const u = e.currentMask === a, o = u ? a.displayValue.length : a.nearestInputPos(a.displayValue.length, b.FORCE_LEFT);
2253
+ return a.rawInputValue !== r ? (a.reset(), a.append(r, {
2254
+ raw: !0
2255
+ })) : u || a.remove(o), a.append(i, e.currentMaskFlags(t)), a.appendTail(s), {
2256
+ index: l,
2257
+ weight: a.rawInputValue.length,
2258
+ totalInputPositions: a.totalInputPositions(0, Math.max(o, a.nearestInputPos(a.displayValue.length, b.FORCE_LEFT)))
2259
+ };
2260
+ });
2261
+ return n.sort((a, l) => l.weight - a.weight || l.totalInputPositions - a.totalInputPositions), e.compiledMasks[n[0].index];
2262
+ }
2263
+ };
2264
+ _.MaskedDynamic = he;
2265
+ class ce extends N {
2266
+ constructor(e) {
2267
+ super({
2268
+ ...ce.DEFAULTS,
2269
+ ...e
2270
+ });
2271
+ }
2272
+ updateOptions(e) {
2273
+ super.updateOptions(e);
2274
+ }
2275
+ _update(e) {
2276
+ const {
2277
+ enum: t,
2278
+ ...s
2279
+ } = e;
2280
+ if (t) {
2281
+ const r = t.map((l) => l.length), n = Math.min(...r), a = Math.max(...r) - n;
2282
+ s.mask = "*".repeat(n), a && (s.mask += "[" + "*".repeat(a) + "]"), this.enum = t;
2283
+ }
2284
+ super._update(s);
2285
+ }
2286
+ _appendCharRaw(e, t) {
2287
+ t === void 0 && (t = {});
2288
+ const s = Math.min(this.nearestInputPos(0, b.FORCE_RIGHT), this.value.length), r = this.enum.filter((n) => this.matchValue(n, this.unmaskedValue + e, s));
2289
+ if (r.length) {
2290
+ r.length === 1 && this._forEachBlocksInRange(0, this.value.length, (a, l) => {
2291
+ const u = r[0][l];
2292
+ l >= this.value.length || u === a.value || (a.reset(), a._appendChar(u, t));
2293
+ });
2294
+ const n = super._appendCharRaw(r[0][this.value.length], t);
2295
+ return r.length === 1 && r[0].slice(this.unmaskedValue.length).split("").forEach((a) => n.aggregate(super._appendCharRaw(a))), n;
2296
+ }
2297
+ return new S({
2298
+ skip: !this.isComplete
2299
+ });
2300
+ }
2301
+ extractTail(e, t) {
2302
+ return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), new H("", e);
2303
+ }
2304
+ remove(e, t) {
2305
+ if (e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), e === t) return new S();
2306
+ const s = Math.min(super.nearestInputPos(0, b.FORCE_RIGHT), this.value.length);
2307
+ let r;
2308
+ for (r = e; r >= 0 && !(this.enum.filter((l) => this.matchValue(l, this.value.slice(s, r), s)).length > 1); --r)
2309
+ ;
2310
+ const n = super.remove(r, t);
2311
+ return n.tailShift += r - e, n;
2312
+ }
2313
+ get isComplete() {
2314
+ return this.enum.indexOf(this.value) >= 0;
2315
+ }
2316
+ }
2317
+ ce.DEFAULTS = {
2318
+ ...N.DEFAULTS,
2319
+ matchValue: (i, e, t) => i.indexOf(e, t) === t
2320
+ };
2321
+ _.MaskedEnum = ce;
2322
+ class Kt extends L {
2323
+ /** */
2324
+ /** Enable characters overwriting */
2325
+ /** */
2326
+ /** */
2327
+ /** */
2328
+ updateOptions(e) {
2329
+ super.updateOptions(e);
2330
+ }
2331
+ _update(e) {
2332
+ super._update({
2333
+ ...e,
2334
+ validate: e.mask
2335
+ });
2336
+ }
2337
+ }
2338
+ _.MaskedFunction = Kt;
2339
+ var Je;
2340
+ class $ extends L {
2341
+ /** Single char */
2342
+ /** Single char */
2343
+ /** Array of single chars */
2344
+ /** */
2345
+ /** */
2346
+ /** Digits after point */
2347
+ /** Flag to remove leading and trailing zeros in the end of editing */
2348
+ /** Flag to pad trailing zeros after point in the end of editing */
2349
+ /** Enable characters overwriting */
2350
+ /** */
2351
+ /** */
2352
+ /** */
2353
+ /** Format typed value to string */
2354
+ /** Parse string to get typed value */
2355
+ constructor(e) {
2356
+ super({
2357
+ ...$.DEFAULTS,
2358
+ ...e
2359
+ });
2360
+ }
2361
+ updateOptions(e) {
2362
+ super.updateOptions(e);
2363
+ }
2364
+ _update(e) {
2365
+ super._update(e), this._updateRegExps();
2366
+ }
2367
+ _updateRegExps() {
2368
+ const e = "^" + (this.allowNegative ? "[+|\\-]?" : ""), t = "\\d*", s = (this.scale ? "(" + ke(this.radix) + "\\d{0," + this.scale + "})?" : "") + "$";
2369
+ this._numberRegExp = new RegExp(e + t + s), this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(ke).join("") + "]", "g"), this._thousandsSeparatorRegExp = new RegExp(ke(this.thousandsSeparator), "g");
2370
+ }
2371
+ _removeThousandsSeparators(e) {
2372
+ return e.replace(this._thousandsSeparatorRegExp, "");
2373
+ }
2374
+ _insertThousandsSeparators(e) {
2375
+ const t = e.split(this.radix);
2376
+ return t[0] = t[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator), t.join(this.radix);
2377
+ }
2378
+ doPrepareChar(e, t) {
2379
+ t === void 0 && (t = {});
2380
+ const [s, r] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && /*
2381
+ radix should be mapped when
2382
+ 1) input is done from keyboard = flags.input && flags.raw
2383
+ 2) unmasked value is set = !flags.input && !flags.raw
2384
+ and should not be mapped when
2385
+ 1) value is set = flags.input && !flags.raw
2386
+ 2) raw value is set = !flags.input && flags.raw
2387
+ */
2388
+ (t.input && t.raw || !t.input && !t.raw) ? e.replace(this._mapToRadixRegExp, this.radix) : e), t);
2389
+ return e && !s && (r.skip = !0), s && !this.allowPositive && !this.value && s !== "-" && r.aggregate(this._appendChar("-")), [s, r];
2390
+ }
2391
+ _separatorsCount(e, t) {
2392
+ t === void 0 && (t = !1);
2393
+ let s = 0;
2394
+ for (let r = 0; r < e; ++r)
2395
+ this._value.indexOf(this.thousandsSeparator, r) === r && (++s, t && (e += this.thousandsSeparator.length));
2396
+ return s;
2397
+ }
2398
+ _separatorsCountFromSlice(e) {
2399
+ return e === void 0 && (e = this._value), this._separatorsCount(this._removeThousandsSeparators(e).length, !0);
2400
+ }
2401
+ extractInput(e, t, s) {
2402
+ return e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), [e, t] = this._adjustRangeWithSeparators(e, t), this._removeThousandsSeparators(super.extractInput(e, t, s));
2403
+ }
2404
+ _appendCharRaw(e, t) {
2405
+ t === void 0 && (t = {});
2406
+ const s = t.tail && t._beforeTailState ? t._beforeTailState._value : this._value, r = this._separatorsCountFromSlice(s);
2407
+ this._value = this._removeThousandsSeparators(this.value);
2408
+ const n = this._value;
2409
+ this._value += e;
2410
+ const a = this.number;
2411
+ let l = !isNaN(a), u = !1;
2412
+ if (l) {
2413
+ let m;
2414
+ this.min != null && this.min < 0 && this.number < this.min && (m = this.min), this.max != null && this.max > 0 && this.number > this.max && (m = this.max), m != null && (this.autofix ? (this._value = this.format(m, this).replace($.UNMASKED_RADIX, this.radix), u || (u = n === this._value && !t.tail)) : l = !1), l && (l = !!this._value.match(this._numberRegExp));
2415
+ }
2416
+ let o;
2417
+ l ? o = new S({
2418
+ inserted: this._value.slice(n.length),
2419
+ rawInserted: u ? "" : e,
2420
+ skip: u
2421
+ }) : (this._value = n, o = new S()), this._value = this._insertThousandsSeparators(this._value);
2422
+ const v = t.tail && t._beforeTailState ? t._beforeTailState._value : this._value, f = this._separatorsCountFromSlice(v);
2423
+ return o.tailShift += (f - r) * this.thousandsSeparator.length, o;
2424
+ }
2425
+ _findSeparatorAround(e) {
2426
+ if (this.thousandsSeparator) {
2427
+ const t = e - this.thousandsSeparator.length + 1, s = this.value.indexOf(this.thousandsSeparator, t);
2428
+ if (s <= e) return s;
2429
+ }
2430
+ return -1;
2431
+ }
2432
+ _adjustRangeWithSeparators(e, t) {
2433
+ const s = this._findSeparatorAround(e);
2434
+ s >= 0 && (e = s);
2435
+ const r = this._findSeparatorAround(t);
2436
+ return r >= 0 && (t = r + this.thousandsSeparator.length), [e, t];
2437
+ }
2438
+ remove(e, t) {
2439
+ e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length), [e, t] = this._adjustRangeWithSeparators(e, t);
2440
+ const s = this.value.slice(0, e), r = this.value.slice(t), n = this._separatorsCount(s.length);
2441
+ this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(s + r));
2442
+ const a = this._separatorsCountFromSlice(s);
2443
+ return new S({
2444
+ tailShift: (a - n) * this.thousandsSeparator.length
2445
+ });
2446
+ }
2447
+ nearestInputPos(e, t) {
2448
+ if (!this.thousandsSeparator) return e;
2449
+ switch (t) {
2450
+ case b.NONE:
2451
+ case b.LEFT:
2452
+ case b.FORCE_LEFT: {
2453
+ const s = this._findSeparatorAround(e - 1);
2454
+ if (s >= 0) {
2455
+ const r = s + this.thousandsSeparator.length;
2456
+ if (e < r || this.value.length <= r || t === b.FORCE_LEFT)
2457
+ return s;
2458
+ }
2459
+ break;
2460
+ }
2461
+ case b.RIGHT:
2462
+ case b.FORCE_RIGHT: {
2463
+ const s = this._findSeparatorAround(e);
2464
+ if (s >= 0)
2465
+ return s + this.thousandsSeparator.length;
2466
+ }
2467
+ }
2468
+ return e;
2469
+ }
2470
+ doCommit() {
2471
+ if (this.value) {
2472
+ const e = this.number;
2473
+ let t = e;
2474
+ this.min != null && (t = Math.max(t, this.min)), this.max != null && (t = Math.min(t, this.max)), t !== e && (this.unmaskedValue = this.format(t, this));
2475
+ let s = this.value;
2476
+ this.normalizeZeros && (s = this._normalizeZeros(s)), this.padFractionalZeros && this.scale > 0 && (s = this._padFractionalZeros(s)), this._value = s;
2477
+ }
2478
+ super.doCommit();
2479
+ }
2480
+ _normalizeZeros(e) {
2481
+ const t = this._removeThousandsSeparators(e).split(this.radix);
2482
+ return t[0] = t[0].replace(/^(\D*)(0*)(\d*)/, (s, r, n, a) => r + a), e.length && !/\d$/.test(t[0]) && (t[0] = t[0] + "0"), t.length > 1 && (t[1] = t[1].replace(/0*$/, ""), t[1].length || (t.length = 1)), this._insertThousandsSeparators(t.join(this.radix));
2483
+ }
2484
+ _padFractionalZeros(e) {
2485
+ if (!e) return e;
2486
+ const t = e.split(this.radix);
2487
+ return t.length < 2 && t.push(""), t[1] = t[1].padEnd(this.scale, "0"), t.join(this.radix);
2488
+ }
2489
+ doSkipInvalid(e, t, s) {
2490
+ t === void 0 && (t = {});
2491
+ const r = this.scale === 0 && e !== this.thousandsSeparator && (e === this.radix || e === $.UNMASKED_RADIX || this.mapToRadix.includes(e));
2492
+ return super.doSkipInvalid(e, t, s) && !r;
2493
+ }
2494
+ get unmaskedValue() {
2495
+ return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, $.UNMASKED_RADIX);
2496
+ }
2497
+ set unmaskedValue(e) {
2498
+ super.unmaskedValue = e;
2499
+ }
2500
+ get typedValue() {
2501
+ return this.parse(this.unmaskedValue, this);
2502
+ }
2503
+ set typedValue(e) {
2504
+ this.rawInputValue = this.format(e, this).replace($.UNMASKED_RADIX, this.radix);
2505
+ }
2506
+ /** Parsed Number */
2507
+ get number() {
2508
+ return this.typedValue;
2509
+ }
2510
+ set number(e) {
2511
+ this.typedValue = e;
2512
+ }
2513
+ get allowNegative() {
2514
+ return this.min != null && this.min < 0 || this.max != null && this.max < 0;
2515
+ }
2516
+ get allowPositive() {
2517
+ return this.min != null && this.min > 0 || this.max != null && this.max > 0;
2518
+ }
2519
+ typedValueEquals(e) {
2520
+ return (super.typedValueEquals(e) || $.EMPTY_VALUES.includes(e) && $.EMPTY_VALUES.includes(this.typedValue)) && !(e === 0 && this.value === "");
2521
+ }
2522
+ }
2523
+ Je = $;
2524
+ $.UNMASKED_RADIX = ".";
2525
+ $.EMPTY_VALUES = [...L.EMPTY_VALUES, 0];
2526
+ $.DEFAULTS = {
2527
+ ...L.DEFAULTS,
2528
+ mask: Number,
2529
+ radix: ",",
2530
+ thousandsSeparator: "",
2531
+ mapToRadix: [Je.UNMASKED_RADIX],
2532
+ min: Number.MIN_SAFE_INTEGER,
2533
+ max: Number.MAX_SAFE_INTEGER,
2534
+ scale: 2,
2535
+ normalizeZeros: !0,
2536
+ padFractionalZeros: !1,
2537
+ parse: Number,
2538
+ format: (i) => i.toLocaleString("en-US", {
2539
+ useGrouping: !1,
2540
+ maximumFractionDigits: 20
2541
+ })
2542
+ };
2543
+ _.MaskedNumber = $;
2544
+ const Ae = {
2545
+ MASKED: "value",
2546
+ UNMASKED: "unmaskedValue",
2547
+ TYPED: "typedValue"
2548
+ };
2549
+ function Ye(i, e, t) {
2550
+ e === void 0 && (e = Ae.MASKED), t === void 0 && (t = Ae.MASKED);
2551
+ const s = Y(i);
2552
+ return (r) => s.runIsolated((n) => (n[e] = r, n[t]));
2553
+ }
2554
+ function Gt(i, e, t, s) {
2555
+ return Ye(e, t, s)(i);
2556
+ }
2557
+ _.PIPE_TYPE = Ae;
2558
+ _.createPipe = Ye;
2559
+ _.pipe = Gt;
2560
+ class Jt extends N {
2561
+ get repeatFrom() {
2562
+ var e;
2563
+ return (e = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === 1 / 0 ? 0 : this.repeat) != null ? e : 0;
2564
+ }
2565
+ get repeatTo() {
2566
+ var e;
2567
+ return (e = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? e : 1 / 0;
2568
+ }
2569
+ constructor(e) {
2570
+ super(e);
2571
+ }
2572
+ updateOptions(e) {
2573
+ super.updateOptions(e);
2574
+ }
2575
+ _update(e) {
2576
+ var t, s, r;
2577
+ const {
2578
+ repeat: n,
2579
+ ...a
2580
+ } = re(e);
2581
+ this._blockOpts = Object.assign({}, this._blockOpts, a);
2582
+ const l = Y(this._blockOpts);
2583
+ this.repeat = (t = (s = n ?? l.repeat) != null ? s : this.repeat) != null ? t : 1 / 0, super._update({
2584
+ mask: "m".repeat(Math.max(this.repeatTo === 1 / 0 && ((r = this._blocks) == null ? void 0 : r.length) || 0, this.repeatFrom)),
2585
+ blocks: {
2586
+ m: l
2587
+ },
2588
+ eager: l.eager,
2589
+ overwrite: l.overwrite,
2590
+ skipInvalid: l.skipInvalid,
2591
+ lazy: l.lazy,
2592
+ placeholderChar: l.placeholderChar,
2593
+ displayChar: l.displayChar
2594
+ });
2595
+ }
2596
+ _allocateBlock(e) {
2597
+ if (e < this._blocks.length) return this._blocks[e];
2598
+ if (this.repeatTo === 1 / 0 || this._blocks.length < this.repeatTo)
2599
+ return this._blocks.push(Y(this._blockOpts)), this.mask += "m", this._blocks[this._blocks.length - 1];
2600
+ }
2601
+ _appendCharRaw(e, t) {
2602
+ t === void 0 && (t = {});
2603
+ const s = new S();
2604
+ for (
2605
+ let u = (r = (n = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : n.index) != null ? r : Math.max(this._blocks.length - 1, 0), o, v;
2606
+ // try to get a block or
2607
+ // try to allocate a new block if not allocated already
2608
+ o = (a = this._blocks[u]) != null ? a : v = !v && this._allocateBlock(u);
2609
+ ++u
2610
+ ) {
2611
+ var r, n, a, l;
2612
+ const f = o._appendChar(e, {
2613
+ ...t,
2614
+ _beforeTailState: (l = t._beforeTailState) == null || (l = l._blocks) == null ? void 0 : l[u]
2615
+ });
2616
+ if (f.skip && v) {
2617
+ this._blocks.pop(), this.mask = this.mask.slice(1);
2618
+ break;
2619
+ }
2620
+ if (s.aggregate(f), f.consumed) break;
2621
+ }
2622
+ return s;
2623
+ }
2624
+ _trimEmptyTail(e, t) {
2625
+ var s, r;
2626
+ e === void 0 && (e = 0);
2627
+ const n = Math.max(((s = this._mapPosToBlock(e)) == null ? void 0 : s.index) || 0, this.repeatFrom, 0);
2628
+ let a;
2629
+ t != null && (a = (r = this._mapPosToBlock(t)) == null ? void 0 : r.index), a == null && (a = this._blocks.length - 1);
2630
+ let l = 0;
2631
+ for (let u = a; n <= u && !this._blocks[u].unmaskedValue; --u, ++l)
2632
+ ;
2633
+ l && (this._blocks.splice(a - l + 1, l), this.mask = this.mask.slice(l));
2634
+ }
2635
+ reset() {
2636
+ super.reset(), this._trimEmptyTail();
2637
+ }
2638
+ remove(e, t) {
2639
+ e === void 0 && (e = 0), t === void 0 && (t = this.displayValue.length);
2640
+ const s = super.remove(e, t);
2641
+ return this._trimEmptyTail(e, t), s;
2642
+ }
2643
+ totalInputPositions(e, t) {
2644
+ return e === void 0 && (e = 0), t == null && this.repeatTo === 1 / 0 ? 1 / 0 : super.totalInputPositions(e, t);
2645
+ }
2646
+ get state() {
2647
+ return super.state;
2648
+ }
2649
+ set state(e) {
2650
+ this._blocks.length = e._blocks.length, this.mask = this.mask.slice(0, this._blocks.length), super.state = e;
2651
+ }
2652
+ }
2653
+ _.RepeatBlock = Jt;
2654
+ try {
2655
+ globalThis.IMask = _;
2656
+ } catch {
2657
+ }
2658
+ const Z = {
2659
+ lazy: !0,
2660
+ placeholderChar: "_",
2661
+ rawMode: "unmasked",
2662
+ normalize: "none"
2663
+ };
2664
+ function Yt(i) {
2665
+ return i === "unmasked" || i === "masked" || i === "typed";
2666
+ }
2667
+ function Wt(i) {
2668
+ return i === "digits" || i === "e164" || i === "none";
2669
+ }
2670
+ function We(i) {
2671
+ const e = i.match(/\+\{(\d+)\}/);
2672
+ return (e == null ? void 0 : e[1]) ?? null;
2673
+ }
2674
+ function Zt(i) {
2675
+ const e = i.trim();
2676
+ if (!e) return null;
2677
+ const t = Z.lazy, s = Z.placeholderChar, r = Z.rawMode, n = Z.normalize;
2678
+ return {
2679
+ pattern: e,
2680
+ lazy: t,
2681
+ placeholderChar: s,
2682
+ rawMode: r,
2683
+ normalize: n,
2684
+ countryCode: We(e),
2685
+ imaskOptions: {
2686
+ mask: e,
2687
+ lazy: t,
2688
+ placeholderChar: s
63
2689
  },
64
- submit: () => {
65
- var n;
66
- return ((n = c.value) == null ? void 0 : n.submit()) ?? Promise.resolve({ values: {}, isValid: !0, errors: {} });
2690
+ cacheKey: JSON.stringify({ pattern: e, lazy: t, placeholderChar: s, rawMode: r, normalize: n })
2691
+ };
2692
+ }
2693
+ function Xt(i) {
2694
+ const e = typeof i.pattern == "string" ? i.pattern.trim() : "";
2695
+ if (!e) return null;
2696
+ const t = typeof i.lazy == "boolean" ? i.lazy : Z.lazy, s = typeof i.placeholderChar == "string" && i.placeholderChar.length > 0 ? i.placeholderChar : Z.placeholderChar, r = Yt(i.rawMode) ? i.rawMode : Z.rawMode, n = Wt(i.normalize) ? i.normalize : Z.normalize;
2697
+ return {
2698
+ pattern: e,
2699
+ lazy: t,
2700
+ placeholderChar: s,
2701
+ rawMode: r,
2702
+ normalize: n,
2703
+ countryCode: We(e),
2704
+ imaskOptions: {
2705
+ mask: e,
2706
+ lazy: t,
2707
+ placeholderChar: s
67
2708
  },
68
- reset: (n) => {
69
- var s;
70
- return (s = c.value) == null ? void 0 : s.reset(n);
71
- }
2709
+ cacheKey: JSON.stringify({ pattern: e, lazy: t, placeholderChar: s, rawMode: r, normalize: n })
72
2710
  };
73
2711
  }
74
- const D = /* @__PURE__ */ C({
75
- __name: "FieldText",
2712
+ function Qt(i) {
2713
+ return typeof i == "string" ? Zt(i) : i && typeof i == "object" ? Xt(i) : null;
2714
+ }
2715
+ const es = ["for"], ts = {
2716
+ key: 0,
2717
+ class: "co-field-shell__required",
2718
+ "aria-hidden": "true"
2719
+ }, ss = { class: "co-field-shell__control" }, is = {
2720
+ key: 1,
2721
+ class: "co-field-shell__message"
2722
+ }, rs = /* @__PURE__ */ R({
2723
+ __name: "CoFieldShell",
2724
+ props: {
2725
+ label: {},
2726
+ inputId: {},
2727
+ required: { type: Boolean },
2728
+ disabled: { type: Boolean },
2729
+ focused: { type: Boolean },
2730
+ helperText: {},
2731
+ errors: {},
2732
+ size: {}
2733
+ },
2734
+ setup(i) {
2735
+ const e = i, t = p(() => {
2736
+ var n;
2737
+ return (((n = e.errors) == null ? void 0 : n.length) ?? 0) > 0;
2738
+ }), s = p(() => {
2739
+ var n;
2740
+ return ((n = e.errors) == null ? void 0 : n[0]) || e.helperText || "";
2741
+ }), r = p(() => e.size ?? "md");
2742
+ return (n, a) => (I(), P("div", {
2743
+ class: pt([
2744
+ "co-field-shell",
2745
+ `co-field-shell--${r.value}`,
2746
+ {
2747
+ "co-field-shell--error": t.value,
2748
+ "co-field-shell--disabled": i.disabled,
2749
+ "co-field-shell--focused": i.focused
2750
+ }
2751
+ ])
2752
+ }, [
2753
+ i.label ? (I(), P("label", {
2754
+ key: 0,
2755
+ for: i.inputId,
2756
+ class: "co-field-shell__label"
2757
+ }, [
2758
+ ft(Fe(i.label) + " ", 1),
2759
+ i.required ? (I(), P("span", ts, "*")) : te("", !0)
2760
+ ], 8, es)) : te("", !0),
2761
+ ie("div", ss, [
2762
+ se(n.$slots, "default", {}, void 0, !0)
2763
+ ]),
2764
+ s.value ? (I(), P("p", is, Fe(s.value), 1)) : te("", !0)
2765
+ ], 2));
2766
+ }
2767
+ }), Me = (i, e) => {
2768
+ const t = i.__vccOpts || i;
2769
+ for (const [s, r] of e)
2770
+ t[s] = r;
2771
+ return t;
2772
+ }, ns = /* @__PURE__ */ Me(rs, [["__scopeId", "data-v-9aa9efaf"]]), as = ["id", "type", "placeholder", "disabled"], ls = /* @__PURE__ */ R({
2773
+ __name: "FieldMasked",
76
2774
  props: {
77
2775
  field: {},
78
2776
  value: {},
79
2777
  errors: {},
80
2778
  disabled: { type: Boolean }
81
2779
  },
82
- emits: ["update:value", "blur"],
83
- setup(e, { emit: c }) {
84
- const t = e, r = c, v = f(() => t.errors.length > 0 ? "error" : "default"), n = f(() => t.errors[0] || t.field.helperText), s = f(() => {
85
- const a = t.field.originalAttrs, o = a.format || a.uiCom;
86
- return o === "email" || t.field.name === "email" ? "email" : o === "password" || o === "Password" ? "password" : o === "tel" || o === "phone" ? "tel" : o === "url" ? "url" : "text";
87
- });
88
- return (a, o) => (g(), A($(k), {
89
- label: e.field.label,
90
- placeholder: e.field.placeholder,
91
- required: e.field.required,
92
- disabled: e.disabled,
93
- status: v.value,
94
- "helper-text": n.value,
95
- type: s.value,
96
- value: String(e.value ?? ""),
97
- onCoInput: o[0] || (o[0] = (y) => r("update:value", y.detail)),
98
- onBlur: o[1] || (o[1] = (y) => r("blur"))
99
- }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "type", "value"]));
2780
+ emits: ["update:value", "blur", "mask:accept"],
2781
+ setup(i, { emit: e }) {
2782
+ const t = i, s = e, r = j(null), n = j(!1), a = p(() => `co-masked-${t.field.name}`), l = p(() => !!t.disabled || !!t.field.disabled), u = p(() => t.value !== null && t.value !== void 0 && `${t.value}`.length > 0), o = p(() => !t.field.required && u.value && !l.value), v = p(() => {
2783
+ var E;
2784
+ const F = (E = t.field.originalAttrs) == null ? void 0 : E.size;
2785
+ return F === "sm" || F === "lg" ? F : "md";
2786
+ }), f = p(() => {
2787
+ const F = t.field.originalAttrs ?? {}, E = F.format || F.uiCom;
2788
+ return E === "email" || t.field.name === "email" ? "email" : E === "tel" || E === "phone" ? "tel" : E === "url" ? "url" : "text";
2789
+ }), m = p(() => {
2790
+ var F;
2791
+ return Qt((F = t.field.originalAttrs) == null ? void 0 : F.mask);
2792
+ }), x = p(() => {
2793
+ var F;
2794
+ return ((F = m.value) == null ? void 0 : F.cacheKey) ?? "no-mask-config";
2795
+ });
2796
+ let g = null, h = !1;
2797
+ function k(F) {
2798
+ return F.replace(/\D/g, "");
2799
+ }
2800
+ function y(F, E, U) {
2801
+ const q = F.length > 0, V = E.trim().length > 0, w = U != null && `${U}`.length > 0;
2802
+ return q || V || w;
2803
+ }
2804
+ function c(F, E, U) {
2805
+ const q = m.value;
2806
+ if (!q) return F || null;
2807
+ if (!y(F, E, U)) return null;
2808
+ let w;
2809
+ if (q.rawMode === "masked" ? w = E : q.rawMode === "typed" ? w = U : w = F, w === "" || w === null || w === void 0) return null;
2810
+ if (q.normalize === "none") return w;
2811
+ const dt = q.rawMode === "masked" ? E : F || `${w}`, ee = k(dt);
2812
+ if (!ee) return null;
2813
+ if (q.normalize === "digits") return ee;
2814
+ const ve = q.countryCode;
2815
+ return ve ? ee.startsWith(ve) ? `+${ee}` : `+${ve}${ee}` : `+${ee}`;
2816
+ }
2817
+ function C(F) {
2818
+ if (g) {
2819
+ h = !0;
2820
+ try {
2821
+ if (F == null) {
2822
+ g.value = "";
2823
+ return;
2824
+ }
2825
+ const E = m.value;
2826
+ if (!E) {
2827
+ g.value = String(F);
2828
+ return;
2829
+ }
2830
+ if (E.rawMode === "masked") {
2831
+ g.value = String(F);
2832
+ return;
2833
+ }
2834
+ if (E.rawMode === "typed") {
2835
+ try {
2836
+ g.typedValue = F;
2837
+ } catch {
2838
+ g.value = String(F);
2839
+ }
2840
+ return;
2841
+ }
2842
+ const U = E.normalize === "none" ? String(F) : k(String(F));
2843
+ g.unmaskedValue = U;
2844
+ } finally {
2845
+ h = !1;
2846
+ }
2847
+ }
2848
+ }
2849
+ function d() {
2850
+ var V;
2851
+ if (!g || h) return;
2852
+ const F = `${g.unmaskedValue ?? ""}`, E = `${g.value ?? ""}`, U = g.typedValue, q = !!((V = g.masked) != null && V.isComplete);
2853
+ s("mask:accept", { rawValue: F, maskedValue: E, isComplete: q }), s("update:value", c(F, E, U));
2854
+ }
2855
+ function A() {
2856
+ !r.value || !m.value || (g = _(r.value, m.value.imaskOptions), g.on("accept", d), C(t.value));
2857
+ }
2858
+ function D() {
2859
+ g && (g.off("accept", d), g.destroy(), g = null);
2860
+ }
2861
+ function z() {
2862
+ D(), A();
2863
+ }
2864
+ function pe(F) {
2865
+ if (g) return;
2866
+ const E = F.target.value;
2867
+ s("update:value", E.trim() ? E : null);
2868
+ }
2869
+ function fe() {
2870
+ var F;
2871
+ if (g) {
2872
+ h = !0;
2873
+ try {
2874
+ g.value = "";
2875
+ } finally {
2876
+ h = !1;
2877
+ }
2878
+ } else r.value && (r.value.value = "");
2879
+ s("update:value", null), (F = r.value) == null || F.focus();
2880
+ }
2881
+ function me() {
2882
+ n.value = !0;
2883
+ }
2884
+ function M() {
2885
+ n.value = !1, s("blur");
2886
+ }
2887
+ return J(
2888
+ () => t.value,
2889
+ (F) => {
2890
+ C(F);
2891
+ }
2892
+ ), J(x, () => {
2893
+ z();
2894
+ }), Se(() => {
2895
+ A(), !g && r.value && (r.value.value = t.value == null ? "" : String(t.value));
2896
+ }), Le(() => {
2897
+ D();
2898
+ }), (F, E) => (I(), T(ns, {
2899
+ label: i.field.label,
2900
+ "input-id": a.value,
2901
+ required: i.field.required,
2902
+ disabled: l.value,
2903
+ focused: n.value,
2904
+ "helper-text": i.field.helperText,
2905
+ errors: i.errors,
2906
+ size: v.value
2907
+ }, {
2908
+ default: _e(() => [
2909
+ ie("input", {
2910
+ id: a.value,
2911
+ ref_key: "inputRef",
2912
+ ref: r,
2913
+ class: "co-field-shell__input",
2914
+ type: f.value,
2915
+ placeholder: i.field.placeholder,
2916
+ disabled: l.value,
2917
+ onInput: pe,
2918
+ onFocus: me,
2919
+ onBlur: M
2920
+ }, null, 40, as),
2921
+ o.value ? (I(), P("button", {
2922
+ key: 0,
2923
+ class: "co-masked__clear",
2924
+ type: "button",
2925
+ tabindex: "-1",
2926
+ "aria-label": "Clear",
2927
+ onMousedown: E[0] || (E[0] = Ne(() => {
2928
+ }, ["prevent"])),
2929
+ onClick: fe
2930
+ }, [
2931
+ ae(B(bt), {
2932
+ name: "x-circle",
2933
+ size: 16,
2934
+ weight: "fill"
2935
+ })
2936
+ ], 32)) : te("", !0)
2937
+ ]),
2938
+ _: 1
2939
+ }, 8, ["label", "input-id", "required", "disabled", "focused", "helper-text", "errors", "size"]));
100
2940
  }
101
- }), J = /* @__PURE__ */ C({
102
- __name: "FieldTextArea",
2941
+ }), us = /* @__PURE__ */ Me(ls, [["__scopeId", "data-v-6a147f90"]]), os = /* @__PURE__ */ R({
2942
+ __name: "FieldMixed",
103
2943
  props: {
104
2944
  field: {},
105
2945
  value: {},
106
2946
  errors: {},
107
- disabled: { type: Boolean }
2947
+ disabled: { type: Boolean },
2948
+ locale: {}
108
2949
  },
109
2950
  emits: ["update:value", "blur"],
110
- setup(e, { emit: c }) {
111
- const t = e, r = c, v = f(() => t.errors.length > 0 ? "error" : "default"), n = f(() => t.errors[0] || t.field.helperText);
112
- return (s, a) => (g(), A($(k), {
113
- label: e.field.label,
114
- placeholder: e.field.placeholder,
115
- required: e.field.required,
116
- disabled: e.disabled,
117
- status: v.value,
2951
+ setup(i, { emit: e }) {
2952
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText);
2953
+ function a(o) {
2954
+ if (o == null) return "";
2955
+ if (typeof o == "string") {
2956
+ const v = o.trim();
2957
+ if (!v) return "";
2958
+ try {
2959
+ return JSON.stringify(JSON.parse(v), null, 2);
2960
+ } catch {
2961
+ return o;
2962
+ }
2963
+ }
2964
+ try {
2965
+ return JSON.stringify(o, null, 2);
2966
+ } catch {
2967
+ return String(o);
2968
+ }
2969
+ }
2970
+ function l(o) {
2971
+ const v = (o ?? "").trim();
2972
+ if (!v) return null;
2973
+ try {
2974
+ return JSON.parse(v);
2975
+ } catch {
2976
+ return o;
2977
+ }
2978
+ }
2979
+ const u = p(() => a(t.value));
2980
+ return (o, v) => (I(), T(B(At), {
2981
+ label: i.field.label,
2982
+ placeholder: i.field.placeholder || "{ }",
2983
+ required: i.field.required,
2984
+ disabled: i.disabled,
2985
+ status: r.value,
118
2986
  "helper-text": n.value,
119
- multiline: "",
120
- value: String(e.value ?? ""),
121
- onCoInput: a[0] || (a[0] = (o) => r("update:value", o.detail)),
122
- onBlur: a[1] || (a[1] = (o) => r("blur"))
2987
+ value: u.value,
2988
+ onCoChange: v[0] || (v[0] = (f) => s("update:value", l(f.detail))),
2989
+ onCoBlur: v[1] || (v[1] = (f) => s("blur"))
123
2990
  }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "value"]));
124
2991
  }
125
- }), w = /* @__PURE__ */ C({
2992
+ }), ds = /* @__PURE__ */ R({
2993
+ __name: "FieldMultiple",
2994
+ props: {
2995
+ field: {},
2996
+ value: {},
2997
+ errors: {},
2998
+ disabled: { type: Boolean },
2999
+ locale: {}
3000
+ },
3001
+ emits: ["update:value", "blur"],
3002
+ setup(i, { emit: e }) {
3003
+ const t = i, s = e, r = p(() => {
3004
+ const a = t.value;
3005
+ return Array.isArray(a) ? JSON.stringify(a.map((l) => String(l))) : a == null || a === "" ? "[]" : JSON.stringify([String(a)]);
3006
+ }), n = p(() => {
3007
+ const a = t.field.originalAttrs.maxElements;
3008
+ return typeof a == "number" ? a : void 0;
3009
+ });
3010
+ return (a, l) => (I(), T(B(Et), {
3011
+ label: i.field.label,
3012
+ placeholder: i.field.placeholder,
3013
+ required: i.field.required,
3014
+ disabled: i.disabled,
3015
+ clearable: !i.field.required,
3016
+ invalid: i.errors.length > 0,
3017
+ "error-message": i.errors[0],
3018
+ "helper-text": i.field.helperText,
3019
+ "max-tags": n.value,
3020
+ value: r.value,
3021
+ onCoChange: l[0] || (l[0] = (u) => s("update:value", u.detail)),
3022
+ onCoBlur: l[1] || (l[1] = (u) => s("blur"))
3023
+ }, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "invalid", "error-message", "helper-text", "max-tags", "value"]));
3024
+ }
3025
+ }), ye = /* @__PURE__ */ R({
126
3026
  __name: "FieldNumber",
127
3027
  props: {
128
3028
  field: {},
@@ -131,24 +3031,29 @@ const D = /* @__PURE__ */ C({
131
3031
  disabled: { type: Boolean }
132
3032
  },
133
3033
  emits: ["update:value", "blur"],
134
- setup(e, { emit: c }) {
135
- const t = e, r = c, v = f(() => t.errors.length > 0 ? "error" : "default"), n = f(() => t.errors[0] || t.field.helperText), s = f(() => t.field.originalAttrs.min), a = f(() => t.field.originalAttrs.max), o = f(() => typeof t.value == "number" ? t.value : void 0);
136
- return (y, x) => (g(), A($(te), {
137
- label: e.field.label,
138
- placeholder: e.field.placeholder,
139
- required: e.field.required,
140
- disabled: e.disabled,
141
- status: v.value,
3034
+ setup(i, { emit: e }) {
3035
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText), a = p(() => t.field.originalAttrs.min), l = p(() => t.field.originalAttrs.max), u = p(() => {
3036
+ const v = String(t.field.originalAttrs.format || "").toLowerCase();
3037
+ return v === "rate" || v === "percent" ? v : void 0;
3038
+ }), o = p(() => typeof t.value == "number" ? t.value : null);
3039
+ return (v, f) => (I(), T(B(xt), {
3040
+ label: i.field.label,
3041
+ placeholder: i.field.placeholder,
3042
+ required: i.field.required,
3043
+ disabled: i.disabled,
3044
+ clearable: !i.field.required,
3045
+ status: r.value,
142
3046
  "helper-text": n.value,
143
- min: s.value,
144
- max: a.value,
3047
+ min: a.value,
3048
+ max: l.value,
3049
+ format: u.value,
145
3050
  value: o.value,
146
- onCoChange: x[0] || (x[0] = (i) => r("update:value", i.detail)),
147
- onBlur: x[1] || (x[1] = (i) => r("blur"))
148
- }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "min", "max", "value"]));
3051
+ onCoChange: f[0] || (f[0] = (m) => s("update:value", m.detail)),
3052
+ onBlur: f[1] || (f[1] = (m) => s("blur"))
3053
+ }, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "status", "helper-text", "min", "max", "format", "value"]));
149
3054
  }
150
- }), ne = /* @__PURE__ */ C({
151
- __name: "FieldDate",
3055
+ }), hs = /* @__PURE__ */ R({
3056
+ __name: "FieldPhone",
152
3057
  props: {
153
3058
  field: {},
154
3059
  value: {},
@@ -156,42 +3061,117 @@ const D = /* @__PURE__ */ C({
156
3061
  disabled: { type: Boolean }
157
3062
  },
158
3063
  emits: ["update:value", "blur"],
159
- setup(e, { emit: c }) {
160
- const t = e, r = c, v = f(() => t.errors.length > 0 ? "error" : "default"), n = f(() => t.errors[0] || t.field.helperText);
161
- return (s, a) => (g(), A($(k), {
162
- label: e.field.label,
163
- placeholder: e.field.placeholder,
164
- required: e.field.required,
165
- disabled: e.disabled,
166
- status: v.value,
3064
+ setup(i, { emit: e }) {
3065
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText), a = p(() => t.field.originalAttrs.defaultCountry || "CO");
3066
+ return (l, u) => (I(), T(B(_t), {
3067
+ label: i.field.label,
3068
+ placeholder: i.field.placeholder,
3069
+ required: i.field.required,
3070
+ disabled: i.disabled,
3071
+ status: r.value,
167
3072
  "helper-text": n.value,
168
- type: "date",
169
- value: String(e.value ?? ""),
170
- onCoInput: a[0] || (a[0] = (o) => r("update:value", o.detail)),
171
- onBlur: a[1] || (a[1] = (o) => r("blur"))
172
- }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "value"]));
3073
+ "default-country": a.value,
3074
+ value: String(i.value ?? ""),
3075
+ onCoChange: u[0] || (u[0] = (o) => s("update:value", o.detail))
3076
+ }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "default-country", "value"]));
173
3077
  }
174
- }), ie = /* @__PURE__ */ C({
175
- __name: "FieldBoolean",
3078
+ }), cs = /* @__PURE__ */ R({
3079
+ __name: "FieldRef",
3080
+ props: {
3081
+ field: {},
3082
+ value: {},
3083
+ errors: {},
3084
+ disabled: { type: Boolean },
3085
+ refState: {}
3086
+ },
3087
+ emits: ["update:value", "search", "load-more", "open"],
3088
+ setup(i, { emit: e }) {
3089
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText), a = p(
3090
+ () => !!t.field.originalAttrs.multiple || t.field.originalAttrs.type === "array"
3091
+ ), l = p(() => {
3092
+ const f = t.value;
3093
+ if (f == null) return "";
3094
+ if (Array.isArray(f)) {
3095
+ const m = f.map((x) => typeof x == "string" ? x : (x == null ? void 0 : x._id) || "");
3096
+ return JSON.stringify(m);
3097
+ }
3098
+ return typeof f == "string" ? a.value ? JSON.stringify([f]) : f : typeof f == "object" && f._id ? a.value ? JSON.stringify([f._id]) : String(f._id) : "";
3099
+ }), u = p(() => {
3100
+ var f;
3101
+ return JSON.stringify(((f = t.refState) == null ? void 0 : f.options) || []);
3102
+ }), o = p(() => {
3103
+ var f;
3104
+ return JSON.stringify(((f = t.refState) == null ? void 0 : f.selectedDisplay) || []);
3105
+ });
3106
+ function v(f) {
3107
+ const m = f.detail ?? {};
3108
+ s("update:value", m.value);
3109
+ }
3110
+ return (f, m) => {
3111
+ var x, g;
3112
+ return I(), T(B(St), {
3113
+ label: i.field.label,
3114
+ placeholder: i.field.placeholder,
3115
+ required: i.field.required,
3116
+ disabled: i.disabled,
3117
+ clearable: !i.field.required,
3118
+ multiple: a.value,
3119
+ status: r.value,
3120
+ "helper-text": n.value,
3121
+ model: i.field.originalAttrs.ref,
3122
+ value: l.value,
3123
+ options: u.value,
3124
+ "selected-display": o.value,
3125
+ loading: ((x = i.refState) == null ? void 0 : x.loading) || !1,
3126
+ total: ((g = i.refState) == null ? void 0 : g.total) || 0,
3127
+ onCoOpen: m[0] || (m[0] = (h) => s("open")),
3128
+ onCoSearch: m[1] || (m[1] = (h) => s("search", h.detail)),
3129
+ onCoLoadMore: m[2] || (m[2] = (h) => s("load-more")),
3130
+ onCoChange: v,
3131
+ onCoClear: m[3] || (m[3] = (h) => s("update:value", a.value ? [] : null))
3132
+ }, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "multiple", "status", "helper-text", "model", "value", "options", "selected-display", "loading", "total"]);
3133
+ };
3134
+ }
3135
+ }), ps = /* @__PURE__ */ R({
3136
+ __name: "FieldRichText",
176
3137
  props: {
177
3138
  field: {},
178
3139
  value: {},
179
3140
  errors: {},
180
3141
  disabled: { type: Boolean }
181
3142
  },
182
- emits: ["update:value"],
183
- setup(e, { emit: c }) {
184
- const t = e, r = c, v = f(() => t.errors.length > 0 ? "error" : "default"), n = f(() => t.errors[0] || t.field.helperText);
185
- return (s, a) => (g(), A($(le), {
186
- label: e.field.label,
187
- disabled: e.disabled,
188
- status: v.value,
3143
+ emits: ["update:value", "blur"],
3144
+ setup(i, { emit: e }) {
3145
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText), a = p(() => {
3146
+ var v;
3147
+ return ((v = t.field.originalAttrs) == null ? void 0 : v.preset) || "task";
3148
+ }), l = j(null), u = j(t.value == null ? "" : String(t.value));
3149
+ J(
3150
+ () => t.value,
3151
+ (v) => {
3152
+ const f = v == null ? "" : String(v);
3153
+ f !== l.value && (u.value = f);
3154
+ }
3155
+ );
3156
+ function o(v) {
3157
+ var m;
3158
+ const f = ((m = v.detail) == null ? void 0 : m.html) ?? "";
3159
+ l.value = f, s("update:value", f);
3160
+ }
3161
+ return (v, f) => (I(), T(B(Bt), {
3162
+ label: i.field.label,
3163
+ placeholder: i.field.placeholder,
3164
+ required: i.field.required,
3165
+ disabled: i.disabled,
3166
+ status: r.value,
189
3167
  "helper-text": n.value,
190
- checked: !!e.value,
191
- onCoChange: a[0] || (a[0] = (o) => r("update:value", o.detail))
192
- }, null, 8, ["label", "disabled", "status", "helper-text", "checked"]));
3168
+ preset: a.value,
3169
+ value: u.value,
3170
+ onCoInput: o,
3171
+ onCoBlur: f[0] || (f[0] = (m) => s("blur"))
3172
+ }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "preset", "value"]));
193
3173
  }
194
- }), se = /* @__PURE__ */ C({
3174
+ }), Ce = /* @__PURE__ */ R({
195
3175
  __name: "FieldSelect",
196
3176
  props: {
197
3177
  field: {},
@@ -200,82 +3180,88 @@ const D = /* @__PURE__ */ C({
200
3180
  disabled: { type: Boolean }
201
3181
  },
202
3182
  emits: ["update:value", "blur"],
203
- setup(e, { emit: c }) {
204
- const t = e, r = c, v = f(() => t.errors.length > 0 ? "error" : "default"), n = f(() => t.errors[0] || t.field.helperText), s = f(() => {
205
- const a = t.field.originalAttrs.enum;
206
- return Array.isArray(a) ? JSON.stringify(a.map((o) => ({ label: String(o), value: String(o) }))) : "[]";
207
- });
208
- return (a, o) => (g(), A($(re), {
209
- label: e.field.label,
210
- placeholder: e.field.placeholder,
211
- required: e.field.required,
212
- disabled: e.disabled,
213
- status: v.value,
3183
+ setup(i, { emit: e }) {
3184
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText), a = p(() => {
3185
+ const l = t.field.originalAttrs.enum;
3186
+ return Array.isArray(l) ? JSON.stringify(l.map((u) => ({ label: String(u), value: String(u) }))) : "[]";
3187
+ });
3188
+ return (l, u) => (I(), T(B(Mt), {
3189
+ label: i.field.label,
3190
+ placeholder: i.field.placeholder,
3191
+ required: i.field.required,
3192
+ disabled: i.disabled,
3193
+ clearable: !i.field.required,
3194
+ status: r.value,
214
3195
  "helper-text": n.value,
215
- options: s.value,
216
- value: String(e.value ?? ""),
217
- onCoChange: o[0] || (o[0] = (y) => r("update:value", y.detail)),
218
- onBlur: o[1] || (o[1] = (y) => r("blur"))
219
- }, null, 8, ["label", "placeholder", "required", "disabled", "status", "helper-text", "options", "value"]));
3196
+ options: a.value,
3197
+ value: String(i.value ?? ""),
3198
+ onCoChange: u[0] || (u[0] = (o) => s("update:value", o.detail)),
3199
+ onBlur: u[1] || (u[1] = (o) => s("blur"))
3200
+ }, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "status", "helper-text", "options", "value"]));
220
3201
  }
221
- }), ue = /* @__PURE__ */ C({
222
- __name: "FieldRef",
3202
+ }), fs = /* @__PURE__ */ R({
3203
+ __name: "FieldText",
223
3204
  props: {
224
3205
  field: {},
225
3206
  value: {},
226
3207
  errors: {},
227
- disabled: { type: Boolean },
228
- refState: {}
3208
+ disabled: { type: Boolean }
229
3209
  },
230
- emits: ["update:value", "search", "load-more", "open"],
231
- setup(e, { emit: c }) {
232
- const t = e, r = c, v = f(() => t.errors.length > 0 ? "error" : "default"), n = f(() => t.errors[0] || t.field.helperText), s = f(
233
- () => !!t.field.originalAttrs.multiple || t.field.originalAttrs.type === "array"
234
- ), a = f(() => {
235
- const i = t.value;
236
- if (i == null) return "";
237
- if (Array.isArray(i)) {
238
- const p = i.map((S) => typeof S == "string" ? S : (S == null ? void 0 : S._id) || "");
239
- return JSON.stringify(p);
3210
+ emits: ["update:value", "blur"],
3211
+ setup(i, { emit: e }) {
3212
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText), a = p(() => {
3213
+ const l = t.field.originalAttrs, u = l.format || l.uiCom;
3214
+ return u === "email" || t.field.name === "email" ? "email" : u === "password" || u === "Password" ? "password" : u === "tel" || u === "phone" ? "tel" : u === "url" ? "url" : "text";
3215
+ });
3216
+ return (l, u) => (I(), T(B(Pe), {
3217
+ label: i.field.label,
3218
+ placeholder: i.field.placeholder,
3219
+ required: i.field.required,
3220
+ disabled: i.disabled,
3221
+ clearable: !i.field.required,
3222
+ status: r.value,
3223
+ "helper-text": n.value,
3224
+ type: a.value,
3225
+ value: String(i.value ?? ""),
3226
+ onCoInput: u[0] || (u[0] = (o) => s("update:value", o.detail)),
3227
+ onBlur: u[1] || (u[1] = (o) => s("blur"))
3228
+ }, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "status", "helper-text", "type", "value"]));
3229
+ }
3230
+ }), ms = /* @__PURE__ */ R({
3231
+ __name: "FieldTextArea",
3232
+ props: {
3233
+ field: {},
3234
+ value: {},
3235
+ errors: {},
3236
+ disabled: { type: Boolean }
3237
+ },
3238
+ emits: ["update:value", "blur"],
3239
+ setup(i, { emit: e }) {
3240
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText), a = p(() => {
3241
+ var u;
3242
+ return ((u = t.field.originalAttrs) == null ? void 0 : u.rows) ?? 4;
3243
+ }), l = p(
3244
+ () => {
3245
+ var u, o;
3246
+ return ((u = t.field.originalAttrs) == null ? void 0 : u.maxLength) ?? ((o = t.field.ajvProperty) == null ? void 0 : o.maxLength) ?? void 0;
240
3247
  }
241
- return typeof i == "string" ? s.value ? JSON.stringify([i]) : i : typeof i == "object" && i._id ? s.value ? JSON.stringify([i._id]) : String(i._id) : "";
242
- }), o = f(() => {
243
- var i;
244
- return JSON.stringify(((i = t.refState) == null ? void 0 : i.options) || []);
245
- }), y = f(() => {
246
- var i;
247
- return JSON.stringify(((i = t.refState) == null ? void 0 : i.selectedDisplay) || []);
248
- });
249
- function x(i) {
250
- const p = i.detail ?? {};
251
- r("update:value", p.value);
252
- }
253
- return (i, p) => {
254
- var S, q;
255
- return g(), A($(ae), {
256
- label: e.field.label,
257
- placeholder: e.field.placeholder,
258
- required: e.field.required,
259
- disabled: e.disabled,
260
- clearable: !e.field.required,
261
- multiple: s.value,
262
- status: v.value,
263
- "helper-text": n.value,
264
- model: e.field.originalAttrs.ref,
265
- value: a.value,
266
- options: o.value,
267
- "selected-display": y.value,
268
- loading: ((S = e.refState) == null ? void 0 : S.loading) || !1,
269
- total: ((q = e.refState) == null ? void 0 : q.total) || 0,
270
- onCoOpen: p[0] || (p[0] = (B) => r("open")),
271
- onCoSearch: p[1] || (p[1] = (B) => r("search", B.detail)),
272
- onCoLoadMore: p[2] || (p[2] = (B) => r("load-more")),
273
- onCoChange: x,
274
- onCoClear: p[3] || (p[3] = (B) => r("update:value", s.value ? [] : null))
275
- }, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "multiple", "status", "helper-text", "model", "value", "options", "selected-display", "loading", "total"]);
276
- };
3248
+ );
3249
+ return (u, o) => (I(), T(B(wt), {
3250
+ label: i.field.label,
3251
+ placeholder: i.field.placeholder,
3252
+ required: i.field.required,
3253
+ disabled: i.disabled,
3254
+ clearable: !i.field.required,
3255
+ status: r.value,
3256
+ "helper-text": n.value,
3257
+ rows: a.value,
3258
+ "max-length": l.value,
3259
+ value: String(i.value ?? ""),
3260
+ onCoInput: o[0] || (o[0] = (v) => s("update:value", v.detail)),
3261
+ onCoBlur: o[1] || (o[1] = (v) => s("blur"))
3262
+ }, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "status", "helper-text", "rows", "max-length", "value"]));
277
3263
  }
278
- }), de = /* @__PURE__ */ C({
3264
+ }), Ze = /* @__PURE__ */ R({
279
3265
  __name: "CoFieldRenderer",
280
3266
  props: {
281
3267
  field: {},
@@ -283,232 +3269,781 @@ const D = /* @__PURE__ */ C({
283
3269
  errors: {},
284
3270
  disabled: { type: Boolean },
285
3271
  refState: {},
3272
+ fileState: {},
3273
+ locale: {},
286
3274
  fieldComponents: {}
287
3275
  },
288
- emits: ["update:value", "blur", "search", "load-more", "open"],
289
- setup(e, { emit: c }) {
290
- const t = {
291
- text: D,
292
- textarea: J,
293
- html: J,
294
- number: w,
295
- date: ne,
296
- boolean: ie,
297
- select: se,
298
- ref: ue,
299
- rating: w,
300
- slider: w,
301
- color: D,
3276
+ emits: ["update:value", "blur", "mask:accept", "search", "load-more", "open", "upload", "remove-file", "reorder", "add-files", "copy-url"],
3277
+ setup(i, { emit: e }) {
3278
+ const t = mt(() => import("./FieldObject-Cxd3I0Jv.js")), s = {
3279
+ text: fs,
3280
+ masked: us,
3281
+ phone: hs,
3282
+ textarea: ms,
3283
+ html: ps,
3284
+ number: ye,
3285
+ // Default date renderer is the Cobalt date picker (manual input + calendar).
3286
+ // The native `<input type="date">` wrapper (FieldDate) stays exported for
3287
+ // apps that opt back in via the `fieldComponents` prop.
3288
+ date: Tt,
3289
+ boolean: Dt,
3290
+ select: Ce,
3291
+ radio: Ce,
3292
+ checkbox: Ce,
3293
+ ref: cs,
3294
+ rating: ye,
3295
+ slider: ye,
3296
+ color: Rt,
302
3297
  section: null,
303
- file: D,
3298
+ file: Lt,
304
3299
  array: null,
3300
+ object: t,
3301
+ tags: ds,
3302
+ mixed: os,
3303
+ "fill-blank": null,
3304
+ ordering: null,
3305
+ matching: null,
3306
+ "image-choice": null,
305
3307
  custom: null
306
- }, r = e, v = c, n = f(() => {
307
- var a, o;
308
- const s = r.field.originalAttrs.uiCom;
309
- return s && ((a = r.fieldComponents) != null && a[s]) ? r.fieldComponents[s] : (o = r.fieldComponents) != null && o[r.field.kind] ? r.fieldComponents[r.field.kind] : t[r.field.kind] ?? null;
310
- });
311
- return (s, a) => (g(), A(Z(n.value), {
312
- field: e.field,
313
- value: e.value,
314
- errors: e.errors,
315
- disabled: e.disabled,
316
- "ref-state": e.refState,
317
- "onUpdate:value": a[0] || (a[0] = (o) => v("update:value", o)),
318
- onBlur: a[1] || (a[1] = (o) => v("blur")),
319
- onSearch: a[2] || (a[2] = (o) => v("search", o)),
320
- onLoadMore: a[3] || (a[3] = (o) => v("load-more")),
321
- onOpen: a[4] || (a[4] = (o) => v("open"))
322
- }, null, 40, ["field", "value", "errors", "disabled", "ref-state"]));
323
- }
324
- }), fe = { class: "co-form-footer" }, L = 20, me = /* @__PURE__ */ C({
3308
+ }, r = i, n = e, a = p(() => {
3309
+ var u, o;
3310
+ const l = r.field.originalAttrs.uiCom;
3311
+ return l && ((u = r.fieldComponents) != null && u[l]) ? r.fieldComponents[l] : (o = r.fieldComponents) != null && o[r.field.kind] ? r.fieldComponents[r.field.kind] : s[r.field.kind] ?? null;
3312
+ });
3313
+ return (l, u) => (I(), T(vt(a.value), {
3314
+ field: i.field,
3315
+ value: i.value,
3316
+ errors: i.errors,
3317
+ disabled: i.disabled,
3318
+ "ref-state": i.refState,
3319
+ "file-state": i.fileState,
3320
+ locale: i.locale,
3321
+ "field-components": i.fieldComponents,
3322
+ "onUpdate:value": u[0] || (u[0] = (o) => n("update:value", o)),
3323
+ onBlur: u[1] || (u[1] = (o) => n("blur")),
3324
+ onSearch: u[2] || (u[2] = (o) => n("search", o)),
3325
+ onLoadMore: u[3] || (u[3] = (o) => n("load-more")),
3326
+ onOpen: u[4] || (u[4] = (o) => n("open")),
3327
+ onUpload: u[5] || (u[5] = (o) => n("upload", o)),
3328
+ onRemoveFile: u[6] || (u[6] = (o) => n("remove-file", o)),
3329
+ onReorder: u[7] || (u[7] = (o) => n("reorder", o)),
3330
+ onAddFiles: u[8] || (u[8] = (o) => n("add-files", o)),
3331
+ onCopyUrl: u[9] || (u[9] = (o) => n("copy-url", o)),
3332
+ "onMask:accept": u[10] || (u[10] = (o) => n("mask:accept", o))
3333
+ }, null, 40, ["field", "value", "errors", "disabled", "ref-state", "file-state", "locale", "field-components"]));
3334
+ }
3335
+ });
3336
+ function O(i) {
3337
+ return i.path ?? i.name;
3338
+ }
3339
+ function we(i, e) {
3340
+ var t;
3341
+ for (const s of i)
3342
+ e(s), (t = s.children) != null && t.length && we(s.children, e);
3343
+ }
3344
+ function Xe(i, e) {
3345
+ return e.split(".").reduce((t, s) => t == null ? void 0 : t[s], i);
3346
+ }
3347
+ function vs(i, e, t) {
3348
+ const s = e.split(".");
3349
+ if (s.length === 1)
3350
+ return i.setValue(e, t), { name: e, value: t };
3351
+ const r = s[0], n = Qe(i.values.value[r], s.slice(1), t);
3352
+ return i.setValue(r, n), { name: r, value: n };
3353
+ }
3354
+ function Qe(i, e, t) {
3355
+ const s = i && typeof i == "object" && !Array.isArray(i) ? i : {}, [r, ...n] = e;
3356
+ return { ...s, [r]: n.length ? Qe(s[r], n, t) : t };
3357
+ }
3358
+ const Re = 20;
3359
+ function gs(i) {
3360
+ const e = () => xe(i.form), t = qe({}), s = /* @__PURE__ */ new Map();
3361
+ function r() {
3362
+ return {
3363
+ options: [],
3364
+ selectedDisplay: [],
3365
+ loading: !1,
3366
+ total: 0,
3367
+ hasMore: !1,
3368
+ page: 1,
3369
+ query: ""
3370
+ };
3371
+ }
3372
+ function n(g, h) {
3373
+ const k = g.originalAttrs.displayName || "name", y = [], c = [], C = (d) => {
3374
+ d && (typeof d == "string" ? y.push(d) : typeof d == "object" && d._id && (y.push(d._id), c.push({
3375
+ value: d._id,
3376
+ label: String(d[k] ?? d.name ?? d._id),
3377
+ meta: d
3378
+ })));
3379
+ };
3380
+ return Array.isArray(h) ? h.forEach(C) : C(h), { ids: y, display: c };
3381
+ }
3382
+ async function a(g, h) {
3383
+ const k = i.refResolver();
3384
+ if (!k) return;
3385
+ const y = O(g), c = t[y] || r();
3386
+ c.loading = !0, t[y] = { ...c };
3387
+ try {
3388
+ const C = await k({
3389
+ model: g.originalAttrs.ref,
3390
+ pageSize: Re,
3391
+ ...h
3392
+ }), d = t[y], A = (h.page ?? 1) > 1;
3393
+ t[y] = {
3394
+ ...d,
3395
+ options: A ? [...d.options, ...C.options] : C.options,
3396
+ total: C.total ?? C.options.length,
3397
+ hasMore: C.hasMore ?? (h.page ?? 1) * Re < (C.total ?? C.options.length),
3398
+ page: h.page ?? 1,
3399
+ query: h.query ?? d.query,
3400
+ loading: !1
3401
+ };
3402
+ } catch (C) {
3403
+ console.error("[CoFormRenderer] refResolver failed:", C), t[y] = { ...t[y], loading: !1 };
3404
+ }
3405
+ }
3406
+ async function l(g, h) {
3407
+ const k = i.refResolver();
3408
+ if (!k) return;
3409
+ const y = O(g), c = t[y] || r();
3410
+ c.loading = !0, t[y] = { ...c };
3411
+ try {
3412
+ const C = await k({ model: g.originalAttrs.ref, ids: h }), d = t[y], A = new Set(d.selectedDisplay.map((z) => z.value)), D = [...d.selectedDisplay];
3413
+ for (const z of C.options)
3414
+ A.has(z.value) || D.push(z);
3415
+ t[y] = { ...d, selectedDisplay: D, loading: !1 };
3416
+ } catch (C) {
3417
+ console.error("[CoFormRenderer] hydrateRef failed:", C), t[y] = { ...t[y], loading: !1 };
3418
+ }
3419
+ }
3420
+ function u() {
3421
+ s.clear(), we(e().fields.value, (g) => {
3422
+ if (g.kind !== "ref") return;
3423
+ const h = O(g);
3424
+ s.set(h, g);
3425
+ const { ids: k, display: y } = n(g, Xe(e().values.value, h));
3426
+ t[h] = { ...r(), selectedDisplay: y };
3427
+ const c = k.filter((C) => !y.some((d) => d.value === C));
3428
+ c.length > 0 && l(g, c);
3429
+ });
3430
+ }
3431
+ Se(u), J(() => e().fields.value, u, { flush: "post" });
3432
+ function o(g) {
3433
+ const h = t[O(g)];
3434
+ h && h.options.length === 0 && !h.loading && a(g, { query: "", page: 1 });
3435
+ }
3436
+ function v(g, h) {
3437
+ a(g, { query: h, page: 1 });
3438
+ }
3439
+ function f(g) {
3440
+ const h = t[O(g)];
3441
+ !h || h.loading || !h.hasMore || a(g, { query: h.query, page: h.page + 1 });
3442
+ }
3443
+ function m(g) {
3444
+ return t[g];
3445
+ }
3446
+ function x(g) {
3447
+ const h = s.get(g);
3448
+ return {
3449
+ search: (k) => h && v(h, k),
3450
+ loadMore: () => h && f(h),
3451
+ open: () => h && o(h)
3452
+ };
3453
+ }
3454
+ return { refStates: t, stateFor: m, handlersFor: x, onRefOpen: o, onRefSearch: v, onRefLoadMore: f };
3455
+ }
3456
+ function ks(i) {
3457
+ const e = () => xe(i.form), t = qe({}), s = /* @__PURE__ */ new Map();
3458
+ function r(h) {
3459
+ var y;
3460
+ const k = h.originalAttrs;
3461
+ return !!k.multiple || Array.isArray(k.type) || ((y = k.type) == null ? void 0 : y[0]) === "array";
3462
+ }
3463
+ function n(h) {
3464
+ const k = (c) => {
3465
+ if (!c) return null;
3466
+ if (typeof c == "string") return { id: c, name: c, status: "done" };
3467
+ if (typeof c == "object") {
3468
+ const C = c._id || c.id;
3469
+ return C ? {
3470
+ id: C,
3471
+ name: c.fileName || c.name || c.originalName || C,
3472
+ size: c.size,
3473
+ url: c.url,
3474
+ thumbnail: c.thumbnail,
3475
+ fileCode: c.fileCode,
3476
+ status: "done"
3477
+ } : null;
3478
+ }
3479
+ return null;
3480
+ };
3481
+ if (h == null || h === "") return [];
3482
+ if (Array.isArray(h)) return h.map(k).filter((c) => !!c);
3483
+ const y = k(h);
3484
+ return y ? [y] : [];
3485
+ }
3486
+ function a() {
3487
+ s.clear(), we(e().fields.value, (h) => {
3488
+ if (h.kind !== "file") return;
3489
+ const k = O(h);
3490
+ s.set(k, h), t[k] = n(Xe(e().values.value, k));
3491
+ });
3492
+ }
3493
+ Se(a), J(() => e().fields.value, a, { flush: "post" });
3494
+ function l(h) {
3495
+ var C;
3496
+ const k = O(h), y = (t[k] || []).filter((d) => d.status === "done" && d.id), c = r(h) ? y.map((d) => d.id) : ((C = y[0]) == null ? void 0 : C.id) ?? null;
3497
+ i.onChange(vs(e(), k, c));
3498
+ }
3499
+ function u(h, k) {
3500
+ if (!i.uploadResolver()) {
3501
+ console.warn("[CoFormRenderer] file upload requires an `uploadResolver` prop.");
3502
+ return;
3503
+ }
3504
+ const y = O(h);
3505
+ t[y] || (t[y] = []), r(h) || (t[y] = []), k.files.forEach((c, C) => {
3506
+ const d = k.tempIds[C];
3507
+ t[y] = [
3508
+ ...t[y],
3509
+ { tempId: d, name: c.name, size: c.size, status: "uploading", progress: 0 }
3510
+ ], o(h, c, d);
3511
+ });
3512
+ }
3513
+ async function o(h, k, y) {
3514
+ const c = O(h), C = (d) => {
3515
+ t[c] = (t[c] || []).map((A) => A.tempId === y ? d(A) : A);
3516
+ };
3517
+ try {
3518
+ const d = await i.uploadResolver()({
3519
+ field: c,
3520
+ file: k,
3521
+ multiple: r(h),
3522
+ originalAttrs: h.originalAttrs,
3523
+ onProgress: (A) => C((D) => ({ ...D, progress: A }))
3524
+ });
3525
+ C((A) => ({
3526
+ ...A,
3527
+ id: d.id,
3528
+ name: d.name ?? A.name,
3529
+ url: d.url,
3530
+ thumbnail: d.thumbnail,
3531
+ fileCode: d.fileCode,
3532
+ progress: 100,
3533
+ status: "done"
3534
+ })), l(h);
3535
+ } catch (d) {
3536
+ console.error("[CoFormRenderer] uploadResolver failed:", d), C((A) => ({ ...A, status: "error", error: (d == null ? void 0 : d.message) || "Upload failed" }));
3537
+ }
3538
+ }
3539
+ function v(h, k) {
3540
+ const y = O(h), c = (t[y] || []).find(
3541
+ (d) => d.id === k || d.tempId === k
3542
+ );
3543
+ t[y] = (t[y] || []).filter(
3544
+ (d) => d.id !== k && d.tempId !== k
3545
+ ), l(h);
3546
+ const C = i.removeResolver();
3547
+ C && (c == null ? void 0 : c.status) === "done" && c.id && C({
3548
+ field: y,
3549
+ id: c.id,
3550
+ fileCode: c.fileCode,
3551
+ originalAttrs: h.originalAttrs
3552
+ }).catch((d) => console.error("[CoFormRenderer] removeResolver failed:", d));
3553
+ }
3554
+ function f(h, k) {
3555
+ const y = t[O(h)] || [], c = (d) => d.id || d.tempId || `${d.name}:${d.size ?? ""}`, C = new Map(k.map((d, A) => [d, A]));
3556
+ t[O(h)] = [...y].sort((d, A) => {
3557
+ const D = C.has(c(d)) ? C.get(c(d)) : k.length + y.indexOf(d), z = C.has(c(A)) ? C.get(c(A)) : k.length + y.indexOf(A);
3558
+ return D - z;
3559
+ }), l(h);
3560
+ }
3561
+ function m(h, k) {
3562
+ if (!(k != null && k.length)) return;
3563
+ const y = O(h), c = k.filter((d) => d && d.id).map((d) => ({
3564
+ id: d.id,
3565
+ name: d.name || d.id,
3566
+ size: d.size,
3567
+ url: d.url,
3568
+ thumbnail: d.thumbnail,
3569
+ fileCode: d.fileCode,
3570
+ status: "done"
3571
+ }));
3572
+ if (!c.length) return;
3573
+ const C = t[y] || [];
3574
+ if (!r(h))
3575
+ t[y] = [c[0]];
3576
+ else {
3577
+ const d = new Set(C.map((A) => A.id).filter(Boolean));
3578
+ t[y] = [...C, ...c.filter((A) => !d.has(A.id))];
3579
+ }
3580
+ l(h);
3581
+ }
3582
+ function x(h) {
3583
+ return t[h];
3584
+ }
3585
+ function g(h) {
3586
+ const k = s.get(h);
3587
+ return {
3588
+ upload: (y) => k && u(k, y),
3589
+ removeFile: (y) => k && v(k, y),
3590
+ reorder: (y) => k && f(k, y),
3591
+ addFiles: (y) => k && m(k, y),
3592
+ copyUrl: (y) => i.onCopyUrl({ field: h, ...y })
3593
+ };
3594
+ }
3595
+ return { fileStates: t, stateFor: x, handlersFor: g, onFileUpload: u, onFileRemove: v, onFileReorder: f, onFileAddRefs: m };
3596
+ }
3597
+ const Te = {
3598
+ sm: "var(--co-spacing-sm, 8px)",
3599
+ md: "var(--co-spacing-md, 12px)",
3600
+ lg: "var(--co-spacing-lg, 16px)"
3601
+ }, ys = "15rem", Cs = /* @__PURE__ */ new Set([
3602
+ "TextArea",
3603
+ "HtmlEditor",
3604
+ "CodeEditor",
3605
+ "TemplateEditor",
3606
+ "FilterEditor",
3607
+ "objectEditor",
3608
+ "langEditor"
3609
+ ]);
3610
+ function et(i) {
3611
+ var t;
3612
+ if (i.fullWidth) return !0;
3613
+ const e = (t = i.originalAttrs) == null ? void 0 : t.uiCom;
3614
+ return typeof e == "string" && Cs.has(e);
3615
+ }
3616
+ function tt(i, e) {
3617
+ const t = Math.max(1, Math.floor(i));
3618
+ return {
3619
+ display: "grid",
3620
+ gap: Te[e] ?? Te.lg,
3621
+ "grid-template-columns": t <= 1 ? "1fr" : `repeat(auto-fit, minmax(min(100%, ${ys}), 1fr))`
3622
+ };
3623
+ }
3624
+ function Fs(i, e) {
3625
+ return !i.colSpan || i.colSpan < 1 ? 1 : Math.min(Math.floor(i.colSpan), Math.max(1, e));
3626
+ }
3627
+ function st(i, e, t) {
3628
+ if (t) return { style: { "grid-column": "1 / -1" } };
3629
+ const s = Fs(i, e);
3630
+ return s <= 1 ? {} : { style: { "grid-column": `span ${s}` } };
3631
+ }
3632
+ const Oe = Symbol("co-form-depth"), it = Symbol("co-form-expand-all"), Ee = Symbol("co-form-columns"), rt = Symbol("co-form-errors"), nt = Symbol("co-form-touched"), at = Symbol("co-form-touch"), lt = Symbol("co-form-ref-fields"), ut = Symbol("co-form-file-fields"), bs = ["data-has-error"], As = { class: "co-form-footer" }, Es = /* @__PURE__ */ R({
325
3633
  __name: "CoFormRenderer",
326
3634
  props: {
327
3635
  form: {},
328
3636
  layout: {},
329
3637
  disabled: { type: Boolean },
330
3638
  excludeFields: {},
3639
+ locale: {},
331
3640
  fieldComponents: {},
332
- refResolver: { type: Function }
3641
+ refResolver: { type: Function },
3642
+ uploadResolver: { type: Function },
3643
+ removeResolver: { type: Function },
3644
+ columns: {},
3645
+ gap: {},
3646
+ expandAll: { type: Boolean }
333
3647
  },
334
- emits: ["submit", "invalid", "change"],
335
- setup(e, { emit: c }) {
336
- const t = e, r = c, v = f(() => t.layout ?? "grid"), n = f(() => {
337
- const l = new Set(t.excludeFields ?? []);
338
- return t.form.fields.value.filter((u) => !u.hidden && !l.has(u.name));
339
- }), s = /* @__PURE__ */ new Set([
340
- "TextArea",
341
- "HtmlEditor",
342
- "CodeEditor",
343
- "TemplateEditor",
344
- "FilterEditor",
345
- "objectEditor",
346
- "langEditor"
347
- ]);
348
- function a(l) {
349
- var d;
350
- if (l.fullWidth) return !0;
351
- const u = (d = l.originalAttrs) == null ? void 0 : d.uiCom;
352
- return typeof u == "string" && s.has(u);
353
- }
354
- function o(l) {
355
- return t.form.touched.value[l.name] ? t.form.errors.value[l.name] || [] : [];
356
- }
357
- function y(l, u) {
358
- t.form.setValue(l, u), r("change", { name: l, value: u });
359
- }
360
- async function x() {
361
- const l = await t.form.submit();
362
- if (!l.isValid) {
363
- t.form.touchAll(), r("invalid", l.errors);
364
- return;
365
- }
366
- const u = t.form.fields.value.reduce((d, m) => (d[m.name] = m.ajvProperty, d), {});
367
- r("submit", { values: H(l.values, u) });
368
- }
369
- const i = Q({});
370
- function p() {
371
- return {
372
- options: [],
373
- selectedDisplay: [],
374
- loading: !1,
375
- total: 0,
376
- hasMore: !1,
377
- page: 1,
378
- query: ""
379
- };
3648
+ emits: ["submit", "invalid", "change", "copy-url"],
3649
+ setup(i, { expose: e, emit: t }) {
3650
+ const s = i, r = t, n = p(() => s.layout ?? "grid");
3651
+ K(it, p(() => !!s.expandAll));
3652
+ const a = p(() => {
3653
+ const c = new Set(s.excludeFields ?? []);
3654
+ return s.form.fields.value.filter((C) => !C.hidden && !c.has(C.name));
3655
+ }), l = p(() => n.value === "stack" ? 1 : s.columns ?? 2), u = p(() => s.gap ?? "lg");
3656
+ K(Ee, l), K(rt, p(() => s.form.errors.value)), K(nt, p(() => s.form.touched.value)), K(at, (c) => s.form.touch(c));
3657
+ const o = p(() => tt(l.value, u.value)), v = gs({
3658
+ form: () => s.form,
3659
+ refResolver: () => s.refResolver
3660
+ }), f = ks({
3661
+ form: () => s.form,
3662
+ uploadResolver: () => s.uploadResolver,
3663
+ removeResolver: () => s.removeResolver,
3664
+ onChange: (c) => r("change", c),
3665
+ onCopyUrl: (c) => r("copy-url", c)
3666
+ });
3667
+ K(lt, { stateFor: v.stateFor, handlersFor: v.handlersFor }), K(ut, { stateFor: f.stateFor, handlersFor: f.handlersFor });
3668
+ function m(c) {
3669
+ return st(c, l.value, et(c));
380
3670
  }
381
- function S(l, u) {
382
- const d = l.originalAttrs.displayName || "name", m = [], h = [], F = (b) => {
383
- b && (typeof b == "string" ? m.push(b) : typeof b == "object" && b._id && (m.push(b._id), h.push({
384
- value: b._id,
385
- label: String(b[d] ?? b.name ?? b._id),
386
- meta: b
387
- })));
388
- };
389
- return Array.isArray(u) ? u.forEach(F) : F(u), { ids: m, display: h };
3671
+ function x(c) {
3672
+ const C = O(c);
3673
+ return s.form.touched.value[C] ? s.form.errors.value[C] || [] : [];
390
3674
  }
391
- async function q(l, u) {
392
- if (!t.refResolver) return;
393
- const d = i[l.name] || p();
394
- d.loading = !0, i[l.name] = { ...d };
395
- try {
396
- const m = await t.refResolver({
397
- model: l.originalAttrs.ref,
398
- pageSize: L,
399
- ...u
400
- }), h = i[l.name], F = (u.page ?? 1) > 1;
401
- i[l.name] = {
402
- ...h,
403
- options: F ? [...h.options, ...m.options] : m.options,
404
- total: m.total ?? m.options.length,
405
- hasMore: m.hasMore ?? (u.page ?? 1) * L < (m.total ?? m.options.length),
406
- page: u.page ?? 1,
407
- query: u.query ?? h.query,
408
- loading: !1
409
- };
410
- } catch (m) {
411
- console.error("[CoFormRenderer] refResolver failed:", m), i[l.name] = { ...i[l.name], loading: !1 };
412
- }
3675
+ const g = j(null);
3676
+ function h() {
3677
+ var A, D;
3678
+ const c = (A = g.value) == null ? void 0 : A.querySelector("[data-has-error]");
3679
+ if (!c) return;
3680
+ c.scrollIntoView({ behavior: "smooth", block: "center" });
3681
+ const d = Array.from(c.querySelectorAll("*")).find(
3682
+ (z) => z.tagName.startsWith("CO-")
3683
+ ) ?? c.querySelector("input, textarea, select, button, [tabindex]");
3684
+ (D = d == null ? void 0 : d.focus) == null || D.call(d, { preventScroll: !0 });
413
3685
  }
414
- async function B(l, u) {
415
- if (!t.refResolver) return;
416
- const d = i[l.name] || p();
417
- d.loading = !0, i[l.name] = { ...d };
418
- try {
419
- const m = await t.refResolver({ model: l.originalAttrs.ref, ids: u }), h = i[l.name], F = new Set(h.selectedDisplay.map((R) => R.value)), b = [...h.selectedDisplay];
420
- for (const R of m.options)
421
- F.has(R.value) || b.push(R);
422
- i[l.name] = { ...h, selectedDisplay: b, loading: !1 };
423
- } catch (m) {
424
- console.error("[CoFormRenderer] hydrateRef failed:", m), i[l.name] = { ...i[l.name], loading: !1 };
425
- }
3686
+ e({ scrollToFirstError: h });
3687
+ function k(c, C) {
3688
+ s.form.setValue(c, C), r("change", { name: c, value: C });
426
3689
  }
427
- function E() {
428
- for (const l of t.form.fields.value) {
429
- if (l.kind !== "ref") continue;
430
- const { ids: u, display: d } = S(l, t.form.values.value[l.name]);
431
- i[l.name] = { ...p(), selectedDisplay: d };
432
- const m = u.filter((h) => !d.some((F) => F.value === h));
433
- m.length > 0 && B(l, m);
3690
+ async function y() {
3691
+ const c = await s.form.submit();
3692
+ if (!c.isValid) {
3693
+ s.form.touchAll(), r("invalid", c.errors), gt(h);
3694
+ return;
434
3695
  }
3696
+ const C = s.form.fields.value.reduce((d, A) => (d[A.name] = A.ajvProperty, d), {});
3697
+ r("submit", { values: ct(c.values, C) });
435
3698
  }
436
- X(E), U(() => t.form.fields.value, E, { flush: "post" });
437
- function j(l) {
438
- const u = i[l.name];
439
- u && u.options.length === 0 && !u.loading && q(l, { query: "", page: 1 });
440
- }
441
- function z(l, u) {
442
- q(l, { query: u, page: 1 });
443
- }
444
- function P(l) {
445
- const u = i[l.name];
446
- !u || u.loading || !u.hasMore || q(l, { query: u.query, page: u.page + 1 });
447
- }
448
- return (l, u) => (g(), T("form", {
449
- onSubmit: Y(x, ["prevent"])
3699
+ return (c, C) => (I(), P("form", {
3700
+ ref_key: "formEl",
3701
+ ref: g,
3702
+ onSubmit: Ne(y, ["prevent"])
450
3703
  }, [
451
- V(l.$slots, "header", { form: e.form }, void 0, !0),
452
- O("div", {
453
- class: N(["co-form-layout", `co-form-layout--${v.value}`])
3704
+ se(c.$slots, "header", { form: i.form }, void 0, !0),
3705
+ ie("div", {
3706
+ class: "co-form-grid",
3707
+ style: be(o.value)
454
3708
  }, [
455
- (g(!0), T(_, null, ee(n.value, (d) => (g(), T("div", {
3709
+ (I(!0), P(Ue, null, $e(a.value, (d) => (I(), P("div", ze({
456
3710
  key: d.name,
457
- class: N(["co-form-field", { "co-form-field--full": a(d) }])
458
- }, [
459
- V(l.$slots, `field:${d.name}`, {
3711
+ class: "co-form-field",
3712
+ "data-has-error": x(d).length > 0 || void 0
3713
+ }, { ref_for: !0 }, m(d)), [
3714
+ se(c.$slots, `field:${d.name}`, {
460
3715
  field: d,
461
- value: e.form.values.value[d.name],
462
- errors: o(d),
463
- setValue: (m) => e.form.setValue(d.name, m),
464
- touch: () => e.form.touch(d.name)
3716
+ value: i.form.values.value[d.name],
3717
+ errors: x(d),
3718
+ setValue: (A) => i.form.setValue(d.name, A),
3719
+ touch: () => i.form.touch(d.name)
465
3720
  }, () => [
466
- I(de, {
3721
+ ae(Ze, {
467
3722
  field: d,
468
- value: e.form.values.value[d.name],
469
- errors: o(d),
470
- disabled: e.disabled || d.disabled,
471
- "ref-state": i[d.name],
472
- "field-components": e.fieldComponents,
473
- "onUpdate:value": (m) => y(d.name, m),
474
- onBlur: (m) => e.form.touch(d.name),
475
- onSearch: (m) => z(d, m),
476
- onLoadMore: (m) => P(d),
477
- onOpen: (m) => j(d)
478
- }, null, 8, ["field", "value", "errors", "disabled", "ref-state", "field-components", "onUpdate:value", "onBlur", "onSearch", "onLoadMore", "onOpen"])
3723
+ value: i.form.values.value[d.name],
3724
+ errors: x(d),
3725
+ disabled: i.disabled || d.disabled,
3726
+ "ref-state": B(v).refStates[B(O)(d)],
3727
+ "file-state": B(f).fileStates[B(O)(d)],
3728
+ locale: i.locale,
3729
+ "field-components": i.fieldComponents,
3730
+ "onUpdate:value": (A) => k(d.name, A),
3731
+ onBlur: (A) => i.form.touch(d.name),
3732
+ onSearch: (A) => B(v).onRefSearch(d, A),
3733
+ onLoadMore: (A) => B(v).onRefLoadMore(d),
3734
+ onOpen: (A) => B(v).onRefOpen(d),
3735
+ onUpload: (A) => B(f).onFileUpload(d, A),
3736
+ onRemoveFile: (A) => B(f).onFileRemove(d, A),
3737
+ onReorder: (A) => B(f).onFileReorder(d, A),
3738
+ onAddFiles: (A) => B(f).onFileAddRefs(d, A),
3739
+ onCopyUrl: (A) => r("copy-url", { field: d.name, ...A })
3740
+ }, null, 8, ["field", "value", "errors", "disabled", "ref-state", "file-state", "locale", "field-components", "onUpdate:value", "onBlur", "onSearch", "onLoadMore", "onOpen", "onUpload", "onRemoveFile", "onReorder", "onAddFiles", "onCopyUrl"])
479
3741
  ], !0)
480
- ], 2))), 128))
481
- ], 2),
482
- O("div", fe, [
483
- V(l.$slots, "footer", {
484
- form: e.form,
485
- submit: x
3742
+ ], 16, bs))), 128))
3743
+ ], 4),
3744
+ ie("div", As, [
3745
+ se(c.$slots, "footer", {
3746
+ form: i.form,
3747
+ submit: y
486
3748
  }, () => [
487
- I($(oe), {
3749
+ ae(B(It), {
488
3750
  type: "submit",
489
3751
  label: "Enviar",
490
3752
  variant: "primary"
491
3753
  })
492
3754
  ], !0)
493
3755
  ])
494
- ], 32));
3756
+ ], 544));
495
3757
  }
496
- }), ce = (e, c) => {
497
- const t = e.__vccOpts || e;
498
- for (const [r, v] of c)
499
- t[r] = v;
500
- return t;
501
- }, ge = /* @__PURE__ */ ce(me, [["__scopeId", "data-v-5700cb3a"]]);
3758
+ }), Ls = /* @__PURE__ */ Me(Es, [["__scopeId", "data-v-c59f7d9a"]]), Ns = /* @__PURE__ */ R({
3759
+ __name: "FieldDate",
3760
+ props: {
3761
+ field: {},
3762
+ value: {},
3763
+ errors: {},
3764
+ disabled: { type: Boolean }
3765
+ },
3766
+ emits: ["update:value", "blur"],
3767
+ setup(i, { emit: e }) {
3768
+ const t = i, s = e, r = p(() => t.errors.length > 0 ? "error" : "default"), n = p(() => t.errors[0] || t.field.helperText);
3769
+ return (a, l) => (I(), T(B(Pe), {
3770
+ label: i.field.label,
3771
+ placeholder: i.field.placeholder,
3772
+ required: i.field.required,
3773
+ disabled: i.disabled,
3774
+ clearable: !i.field.required,
3775
+ status: r.value,
3776
+ "helper-text": n.value,
3777
+ type: "date",
3778
+ value: String(i.value ?? ""),
3779
+ onCoInput: l[0] || (l[0] = (u) => s("update:value", u.detail)),
3780
+ onBlur: l[1] || (l[1] = (u) => s("blur"))
3781
+ }, null, 8, ["label", "placeholder", "required", "disabled", "clearable", "status", "helper-text", "value"]));
3782
+ }
3783
+ }), xs = 3;
3784
+ function Ie(i) {
3785
+ return i == null || i === "" ? !0 : Array.isArray(i) ? i.length === 0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
3786
+ }
3787
+ function ot(i, e) {
3788
+ return i == null ? void 0 : i[e.name];
3789
+ }
3790
+ function _s(i, e) {
3791
+ return i.some((t) => !Ie(ot(e, t)));
3792
+ }
3793
+ function Ss(i, e) {
3794
+ return i.some((t) => t.required && Ie(ot(e, t)));
3795
+ }
3796
+ function Bs({
3797
+ children: i,
3798
+ objectValue: e,
3799
+ errors: t,
3800
+ originalAttrs: s
3801
+ }) {
3802
+ return t && t.length > 0 || (s == null ? void 0 : s.expanded) === !0 ? !0 : (s == null ? void 0 : s.collapsed) === !0 ? !1 : !!(Ss(i, e) || !_s(i, e));
3803
+ }
3804
+ function Ms(i, e) {
3805
+ var t, s, r;
3806
+ if (Ie(e)) return null;
3807
+ switch (i.kind) {
3808
+ case "select":
3809
+ case "radio":
3810
+ case "checkbox": {
3811
+ const n = ((t = i.originalAttrs) == null ? void 0 : t.enumLabels) ?? ((s = i.originalAttrs) == null ? void 0 : s.labels) ?? null;
3812
+ return n && typeof n == "object" && !Array.isArray(n) ? String(n[e] ?? e) : String(e);
3813
+ }
3814
+ case "boolean":
3815
+ return e ? "Sí" : "No";
3816
+ case "ref": {
3817
+ if (e && typeof e == "object") {
3818
+ const n = ((r = i.originalAttrs) == null ? void 0 : r.displayName) || "name", a = e[n] ?? e.name ?? e.label ?? e.displayName;
3819
+ return a ? String(a) : null;
3820
+ }
3821
+ return null;
3822
+ }
3823
+ case "tags":
3824
+ case "array":
3825
+ return Array.isArray(e) ? e.map(String).join(", ") : null;
3826
+ case "object":
3827
+ case "file":
3828
+ return null;
3829
+ // don't summarize nested objects or files inline
3830
+ default:
3831
+ return typeof e == "object" ? null : String(e);
3832
+ }
3833
+ }
3834
+ function ws(i, e, t) {
3835
+ const s = [];
3836
+ for (const a of i) {
3837
+ const l = Ms(a, e == null ? void 0 : e[a.name]);
3838
+ l != null && l !== "" && s.push(l);
3839
+ }
3840
+ if (s.length === 0) return "";
3841
+ const r = s.slice(0, xs), n = s.length - r.length;
3842
+ return n > 0 ? `${r.join(" · ")} +${n}` : r.join(" · ");
3843
+ }
3844
+ const Is = ["data-has-error"], Vs = {
3845
+ key: 0,
3846
+ style: {
3847
+ marginTop: "var(--co-spacing-sm, 8px)",
3848
+ color: "var(--co-semantic-status-error, #aa2e1b)",
3849
+ fontSize: "var(--co-font-size-14, 14px)",
3850
+ fontFamily: "var(--co-font-family-primary)"
3851
+ }
3852
+ }, qs = /* @__PURE__ */ R({
3853
+ __name: "FieldObject",
3854
+ props: {
3855
+ field: {},
3856
+ value: {},
3857
+ errors: {},
3858
+ disabled: { type: Boolean },
3859
+ locale: {},
3860
+ fieldComponents: {}
3861
+ },
3862
+ emits: ["update:value"],
3863
+ setup(i, { emit: e }) {
3864
+ const t = i, s = e, r = p(() => t.field.children ?? []), n = W(lt, null), a = W(ut, null), l = W(Oe, 0);
3865
+ K(Oe, l + 1);
3866
+ const u = p(
3867
+ () => l > 0 ? {
3868
+ paddingLeft: "var(--co-spacing-lg, 16px)",
3869
+ borderLeft: "1px solid var(--co-semantic-border-subtle, rgba(31, 28, 27, 0.08))"
3870
+ } : {}
3871
+ ), o = p(
3872
+ () => t.value && typeof t.value == "object" && !Array.isArray(t.value) ? t.value : {}
3873
+ ), v = W(Ee, j(2)), f = p(() => {
3874
+ var F;
3875
+ const M = Number((F = t.field.originalAttrs) == null ? void 0 : F.columns);
3876
+ return Number.isFinite(M) && M >= 1 ? Math.floor(M) : v.value;
3877
+ });
3878
+ K(Ee, f);
3879
+ const m = p(() => {
3880
+ var F;
3881
+ const M = (F = t.field.originalAttrs) == null ? void 0 : F.gap;
3882
+ return M === "sm" || M === "md" || M === "lg" ? M : "lg";
3883
+ }), x = p(() => tt(f.value, m.value));
3884
+ function g(M) {
3885
+ return st(M, f.value, et(M));
3886
+ }
3887
+ const h = W(rt, j({})), k = W(nt, j({})), y = W(at, () => {
3888
+ });
3889
+ function c(M) {
3890
+ return M.path ?? M.name;
3891
+ }
3892
+ function C(M) {
3893
+ const F = c(M);
3894
+ return k.value[F] ? h.value[F] || [] : [];
3895
+ }
3896
+ function d(M) {
3897
+ y(c(M));
3898
+ }
3899
+ const A = W(it, j(!1)), D = j(
3900
+ A.value || Bs({
3901
+ children: r.value,
3902
+ objectValue: o.value,
3903
+ errors: t.errors,
3904
+ originalAttrs: t.field.originalAttrs
3905
+ })
3906
+ );
3907
+ J(
3908
+ () => t.errors,
3909
+ (M) => {
3910
+ M && M.length > 0 && (D.value = !0);
3911
+ }
3912
+ );
3913
+ const z = p(() => `${t.field.path ?? t.field.name}.`), pe = p(
3914
+ () => Object.keys(h.value).some(
3915
+ (M) => {
3916
+ var F;
3917
+ return M.startsWith(z.value) && k.value[M] && (((F = h.value[M]) == null ? void 0 : F.length) ?? 0) > 0;
3918
+ }
3919
+ )
3920
+ );
3921
+ J(pe, (M) => {
3922
+ M && (D.value = !0);
3923
+ }), J(A, (M) => {
3924
+ M && (D.value = !0);
3925
+ });
3926
+ const fe = p(
3927
+ () => ws(r.value, o.value, t.locale)
3928
+ );
3929
+ function me(M, F) {
3930
+ s("update:value", { ...o.value, [M]: F });
3931
+ }
3932
+ return (M, F) => (I(), T(B(Vt), {
3933
+ class: "co-fieldset",
3934
+ heading: i.field.label,
3935
+ subheading: D.value ? "" : fe.value,
3936
+ open: D.value,
3937
+ style: be(u.value),
3938
+ onCoToggle: F[0] || (F[0] = (E) => D.value = E.detail)
3939
+ }, {
3940
+ default: _e(() => [
3941
+ ie("div", {
3942
+ class: "co-form-grid",
3943
+ style: be(x.value)
3944
+ }, [
3945
+ (I(!0), P(Ue, null, $e(r.value, (E) => {
3946
+ var U, q;
3947
+ return I(), P("div", ze({
3948
+ key: E.name,
3949
+ class: "co-form-field",
3950
+ "data-has-error": C(E).length > 0 || void 0
3951
+ }, { ref_for: !0 }, g(E)), [
3952
+ ae(Ze, {
3953
+ field: E,
3954
+ value: o.value[E.name],
3955
+ errors: C(E),
3956
+ disabled: i.disabled || E.disabled,
3957
+ "ref-state": (U = B(n)) == null ? void 0 : U.stateFor(c(E)),
3958
+ "file-state": (q = B(a)) == null ? void 0 : q.stateFor(c(E)),
3959
+ locale: i.locale,
3960
+ "field-components": i.fieldComponents,
3961
+ "onUpdate:value": (V) => me(E.name, V),
3962
+ onBlur: (V) => d(E),
3963
+ onSearch: (V) => {
3964
+ var w;
3965
+ return (w = B(n)) == null ? void 0 : w.handlersFor(c(E)).search(V);
3966
+ },
3967
+ onLoadMore: (V) => {
3968
+ var w;
3969
+ return (w = B(n)) == null ? void 0 : w.handlersFor(c(E)).loadMore();
3970
+ },
3971
+ onOpen: (V) => {
3972
+ var w;
3973
+ return (w = B(n)) == null ? void 0 : w.handlersFor(c(E)).open();
3974
+ },
3975
+ onUpload: (V) => {
3976
+ var w;
3977
+ return (w = B(a)) == null ? void 0 : w.handlersFor(c(E)).upload(V);
3978
+ },
3979
+ onRemoveFile: (V) => {
3980
+ var w;
3981
+ return (w = B(a)) == null ? void 0 : w.handlersFor(c(E)).removeFile(V);
3982
+ },
3983
+ onReorder: (V) => {
3984
+ var w;
3985
+ return (w = B(a)) == null ? void 0 : w.handlersFor(c(E)).reorder(V);
3986
+ },
3987
+ onAddFiles: (V) => {
3988
+ var w;
3989
+ return (w = B(a)) == null ? void 0 : w.handlersFor(c(E)).addFiles(V);
3990
+ },
3991
+ onCopyUrl: (V) => {
3992
+ var w;
3993
+ return (w = B(a)) == null ? void 0 : w.handlersFor(c(E)).copyUrl(V);
3994
+ }
3995
+ }, null, 8, ["field", "value", "errors", "disabled", "ref-state", "file-state", "locale", "field-components", "onUpdate:value", "onBlur", "onSearch", "onLoadMore", "onOpen", "onUpload", "onRemoveFile", "onReorder", "onAddFiles", "onCopyUrl"])
3996
+ ], 16, Is);
3997
+ }), 128))
3998
+ ], 4),
3999
+ i.errors.length ? (I(), P("div", Vs, Fe(i.errors[0]), 1)) : te("", !0)
4000
+ ]),
4001
+ _: 1
4002
+ }, 8, ["heading", "subheading", "open", "style"]));
4003
+ }
4004
+ });
502
4005
  export {
503
- de as CoFieldRenderer,
504
- ge as CoFormRenderer,
505
- ie as FieldBoolean,
506
- ne as FieldDate,
507
- w as FieldNumber,
508
- ue as FieldRef,
509
- se as FieldSelect,
510
- D as FieldText,
511
- J as FieldTextArea,
512
- xe as createForm,
513
- he as useForm
4006
+ Ze as CoFieldRenderer,
4007
+ Ls as CoFormRenderer,
4008
+ Z as DEFAULT_MASK_CONFIG,
4009
+ Ee as FORM_COLUMNS,
4010
+ Oe as FORM_DEPTH,
4011
+ rt as FORM_ERRORS,
4012
+ it as FORM_EXPAND_ALL,
4013
+ ut as FORM_FILE_FIELDS,
4014
+ lt as FORM_REF_FIELDS,
4015
+ at as FORM_TOUCH,
4016
+ nt as FORM_TOUCHED,
4017
+ Cs as FULL_WIDTH_UICOMS,
4018
+ Dt as FieldBoolean,
4019
+ Rt as FieldColor,
4020
+ Ns as FieldDate,
4021
+ Tt as FieldDatePicker,
4022
+ Lt as FieldFile,
4023
+ us as FieldMasked,
4024
+ os as FieldMixed,
4025
+ ds as FieldMultiple,
4026
+ ye as FieldNumber,
4027
+ qs as FieldObject,
4028
+ hs as FieldPhone,
4029
+ cs as FieldRef,
4030
+ Ce as FieldSelect,
4031
+ fs as FieldText,
4032
+ ms as FieldTextArea,
4033
+ st as cellBindings,
4034
+ Fs as cellSpan,
4035
+ Bs as computeInitialOpen,
4036
+ zs as createForm,
4037
+ O as fieldKey,
4038
+ ws as formatSectionPreview,
4039
+ Xe as getValueAtPath,
4040
+ tt as gridRootStyle,
4041
+ _s as hasAnyValue,
4042
+ Ss as hasEmptyRequiredChild,
4043
+ Ie as isEmptyValue,
4044
+ et as isFullWidthField,
4045
+ Qt as normalizeMaskConfig,
4046
+ vs as setValueAtPath,
4047
+ Os as useForm,
4048
+ we as walkFields
514
4049
  };