@opengis/form 0.0.11 → 0.0.13

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.
@@ -0,0 +1,2383 @@
1
+ function A(u) {
2
+ return typeof u == "string" || u instanceof String;
3
+ }
4
+ function N(u) {
5
+ var t;
6
+ return typeof u == "object" && u != null && (u == null || (t = u.constructor) == null ? void 0 : t.name) === "Object";
7
+ }
8
+ function P(u, t) {
9
+ return Array.isArray(t) ? P(u, (e, s) => t.includes(s)) : Object.entries(u).reduce((e, s) => {
10
+ let [i, n] = s;
11
+ return t(n, i) && (e[i] = n), e;
12
+ }, {});
13
+ }
14
+ const l = {
15
+ NONE: "NONE",
16
+ LEFT: "LEFT",
17
+ FORCE_LEFT: "FORCE_LEFT",
18
+ RIGHT: "RIGHT",
19
+ FORCE_RIGHT: "FORCE_RIGHT"
20
+ };
21
+ function Y(u) {
22
+ switch (u) {
23
+ case l.LEFT:
24
+ return l.FORCE_LEFT;
25
+ case l.RIGHT:
26
+ return l.FORCE_RIGHT;
27
+ default:
28
+ return u;
29
+ }
30
+ }
31
+ function T(u) {
32
+ return u.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1");
33
+ }
34
+ function I(u, t) {
35
+ if (t === u) return !0;
36
+ const e = Array.isArray(t), s = Array.isArray(u);
37
+ let i;
38
+ if (e && s) {
39
+ if (t.length != u.length) return !1;
40
+ for (i = 0; i < t.length; i++) if (!I(t[i], u[i])) return !1;
41
+ return !0;
42
+ }
43
+ if (e != s) return !1;
44
+ if (t && u && typeof t == "object" && typeof u == "object") {
45
+ const n = t instanceof Date, a = u instanceof Date;
46
+ if (n && a) return t.getTime() == u.getTime();
47
+ if (n != a) return !1;
48
+ const r = t instanceof RegExp, h = u instanceof RegExp;
49
+ if (r && h) return t.toString() == u.toString();
50
+ if (r != h) return !1;
51
+ const o = Object.keys(t);
52
+ for (i = 0; i < o.length; i++) if (!Object.prototype.hasOwnProperty.call(u, o[i])) return !1;
53
+ for (i = 0; i < o.length; i++) if (!I(u[o[i]], t[o[i]])) return !1;
54
+ return !0;
55
+ } else if (t && u && typeof t == "function" && typeof u == "function")
56
+ return t.toString() === u.toString();
57
+ return !1;
58
+ }
59
+ class Z {
60
+ /** Current input value */
61
+ /** Current cursor position */
62
+ /** Old input value */
63
+ /** Old selection */
64
+ constructor(t) {
65
+ for (Object.assign(this, t); this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos); )
66
+ --this.oldSelection.start;
67
+ if (this.insertedCount)
68
+ for (; this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end); )
69
+ this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end ? ++this.oldSelection.end : ++this.cursorPos;
70
+ }
71
+ /** Start changing position */
72
+ get startChangePos() {
73
+ return Math.min(this.cursorPos, this.oldSelection.start);
74
+ }
75
+ /** Inserted symbols count */
76
+ get insertedCount() {
77
+ return this.cursorPos - this.startChangePos;
78
+ }
79
+ /** Inserted symbols */
80
+ get inserted() {
81
+ return this.value.substr(this.startChangePos, this.insertedCount);
82
+ }
83
+ /** Removed symbols count */
84
+ get removedCount() {
85
+ return Math.max(this.oldSelection.end - this.startChangePos || // for Delete
86
+ this.oldValue.length - this.value.length, 0);
87
+ }
88
+ /** Removed symbols */
89
+ get removed() {
90
+ return this.oldValue.substr(this.startChangePos, this.removedCount);
91
+ }
92
+ /** Unchanged head symbols */
93
+ get head() {
94
+ return this.value.substring(0, this.startChangePos);
95
+ }
96
+ /** Unchanged tail symbols */
97
+ get tail() {
98
+ return this.value.substring(this.startChangePos + this.insertedCount);
99
+ }
100
+ /** Remove direction */
101
+ get removeDirection() {
102
+ return !this.removedCount || this.insertedCount ? l.NONE : (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) && // if not range removed (event with backspace)
103
+ this.oldSelection.end === this.oldSelection.start ? l.RIGHT : l.LEFT;
104
+ }
105
+ }
106
+ function p(u, t) {
107
+ return new p.InputMask(u, t);
108
+ }
109
+ function H(u) {
110
+ if (u == null) throw new Error("mask property should be defined");
111
+ return u instanceof RegExp ? p.MaskedRegExp : A(u) ? p.MaskedPattern : u === Date ? p.MaskedDate : u === Number ? p.MaskedNumber : Array.isArray(u) || u === Array ? p.MaskedDynamic : p.Masked && u.prototype instanceof p.Masked ? u : p.Masked && u instanceof p.Masked ? u.constructor : u instanceof Function ? p.MaskedFunction : (console.warn("Mask not found for mask", u), p.Masked);
112
+ }
113
+ function x(u) {
114
+ if (!u) throw new Error("Options in not defined");
115
+ if (p.Masked) {
116
+ if (u.prototype instanceof p.Masked) return {
117
+ mask: u
118
+ };
119
+ const {
120
+ mask: t = void 0,
121
+ ...e
122
+ } = u instanceof p.Masked ? {
123
+ mask: u
124
+ } : N(u) && u.mask instanceof p.Masked ? u : {};
125
+ if (t) {
126
+ const s = t.mask;
127
+ return {
128
+ ...P(t, (i, n) => !n.startsWith("_")),
129
+ mask: t.constructor,
130
+ _mask: s,
131
+ ...e
132
+ };
133
+ }
134
+ }
135
+ return N(u) ? {
136
+ ...u
137
+ } : {
138
+ mask: u
139
+ };
140
+ }
141
+ function C(u) {
142
+ if (p.Masked && u instanceof p.Masked) return u;
143
+ const t = x(u), e = H(t.mask);
144
+ if (!e) throw new Error("Masked class is not found for provided mask " + t.mask + ", appropriate module needs to be imported manually before creating mask.");
145
+ return t.mask === e && delete t.mask, t._mask && (t.mask = t._mask, delete t._mask), new e(t);
146
+ }
147
+ p.createMask = C;
148
+ class O {
149
+ /** */
150
+ /** */
151
+ /** */
152
+ /** Safely returns selection start */
153
+ get selectionStart() {
154
+ let t;
155
+ try {
156
+ t = this._unsafeSelectionStart;
157
+ } catch {
158
+ }
159
+ return t ?? this.value.length;
160
+ }
161
+ /** Safely returns selection end */
162
+ get selectionEnd() {
163
+ let t;
164
+ try {
165
+ t = this._unsafeSelectionEnd;
166
+ } catch {
167
+ }
168
+ return t ?? this.value.length;
169
+ }
170
+ /** Safely sets element selection */
171
+ select(t, e) {
172
+ if (!(t == null || e == null || t === this.selectionStart && e === this.selectionEnd))
173
+ try {
174
+ this._unsafeSelect(t, e);
175
+ } catch {
176
+ }
177
+ }
178
+ /** */
179
+ get isActive() {
180
+ return !1;
181
+ }
182
+ /** */
183
+ /** */
184
+ /** */
185
+ }
186
+ p.MaskElement = O;
187
+ const U = 90, $ = 89;
188
+ class V extends O {
189
+ /** HTMLElement to use mask on */
190
+ constructor(t) {
191
+ super(), this.input = t, this._onKeydown = this._onKeydown.bind(this), this._onInput = this._onInput.bind(this), this._onBeforeinput = this._onBeforeinput.bind(this), this._onCompositionEnd = this._onCompositionEnd.bind(this);
192
+ }
193
+ get rootElement() {
194
+ var t, e, s;
195
+ return (t = (e = (s = this.input).getRootNode) == null ? void 0 : e.call(s)) != null ? t : document;
196
+ }
197
+ /** Is element in focus */
198
+ get isActive() {
199
+ return this.input === this.rootElement.activeElement;
200
+ }
201
+ /** Binds HTMLElement events to mask internal events */
202
+ bindEvents(t) {
203
+ 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", t.drop), this.input.addEventListener("click", t.click), this.input.addEventListener("focus", t.focus), this.input.addEventListener("blur", t.commit), this._handlers = t;
204
+ }
205
+ _onKeydown(t) {
206
+ if (this._handlers.redo && (t.keyCode === U && t.shiftKey && (t.metaKey || t.ctrlKey) || t.keyCode === $ && t.ctrlKey))
207
+ return t.preventDefault(), this._handlers.redo(t);
208
+ if (this._handlers.undo && t.keyCode === U && (t.metaKey || t.ctrlKey))
209
+ return t.preventDefault(), this._handlers.undo(t);
210
+ t.isComposing || this._handlers.selectionChange(t);
211
+ }
212
+ _onBeforeinput(t) {
213
+ if (t.inputType === "historyUndo" && this._handlers.undo)
214
+ return t.preventDefault(), this._handlers.undo(t);
215
+ if (t.inputType === "historyRedo" && this._handlers.redo)
216
+ return t.preventDefault(), this._handlers.redo(t);
217
+ }
218
+ _onCompositionEnd(t) {
219
+ this._handlers.input(t);
220
+ }
221
+ _onInput(t) {
222
+ t.isComposing || this._handlers.input(t);
223
+ }
224
+ /** Unbinds HTMLElement events to mask internal events */
225
+ unbindEvents() {
226
+ 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 = {};
227
+ }
228
+ }
229
+ p.HTMLMaskElement = V;
230
+ class X extends V {
231
+ /** InputElement to use mask on */
232
+ constructor(t) {
233
+ super(t), this.input = t;
234
+ }
235
+ /** Returns InputElement selection start */
236
+ get _unsafeSelectionStart() {
237
+ return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
238
+ }
239
+ /** Returns InputElement selection end */
240
+ get _unsafeSelectionEnd() {
241
+ return this.input.selectionEnd;
242
+ }
243
+ /** Sets InputElement selection */
244
+ _unsafeSelect(t, e) {
245
+ this.input.setSelectionRange(t, e);
246
+ }
247
+ get value() {
248
+ return this.input.value;
249
+ }
250
+ set value(t) {
251
+ this.input.value = t;
252
+ }
253
+ }
254
+ p.HTMLMaskElement = V;
255
+ class j extends V {
256
+ /** Returns HTMLElement selection start */
257
+ get _unsafeSelectionStart() {
258
+ const t = this.rootElement, e = t.getSelection && t.getSelection(), s = e && e.anchorOffset, i = e && e.focusOffset;
259
+ return i == null || s == null || s < i ? s : i;
260
+ }
261
+ /** Returns HTMLElement selection end */
262
+ get _unsafeSelectionEnd() {
263
+ const t = this.rootElement, e = t.getSelection && t.getSelection(), s = e && e.anchorOffset, i = e && e.focusOffset;
264
+ return i == null || s == null || s > i ? s : i;
265
+ }
266
+ /** Sets HTMLElement selection */
267
+ _unsafeSelect(t, e) {
268
+ if (!this.rootElement.createRange) return;
269
+ const s = this.rootElement.createRange();
270
+ s.setStart(this.input.firstChild || this.input, t), s.setEnd(this.input.lastChild || this.input, e);
271
+ const i = this.rootElement, n = i.getSelection && i.getSelection();
272
+ n && (n.removeAllRanges(), n.addRange(s));
273
+ }
274
+ /** HTMLElement value */
275
+ get value() {
276
+ return this.input.textContent || "";
277
+ }
278
+ set value(t) {
279
+ this.input.textContent = t;
280
+ }
281
+ }
282
+ p.HTMLContenteditableMaskElement = j;
283
+ class y {
284
+ constructor() {
285
+ this.states = [], this.currentIndex = 0;
286
+ }
287
+ get currentState() {
288
+ return this.states[this.currentIndex];
289
+ }
290
+ get isEmpty() {
291
+ return this.states.length === 0;
292
+ }
293
+ push(t) {
294
+ this.currentIndex < this.states.length - 1 && (this.states.length = this.currentIndex + 1), this.states.push(t), this.states.length > y.MAX_LENGTH && this.states.shift(), this.currentIndex = this.states.length - 1;
295
+ }
296
+ go(t) {
297
+ return this.currentIndex = Math.min(Math.max(this.currentIndex + t, 0), this.states.length - 1), this.currentState;
298
+ }
299
+ undo() {
300
+ return this.go(-1);
301
+ }
302
+ redo() {
303
+ return this.go(1);
304
+ }
305
+ clear() {
306
+ this.states.length = 0, this.currentIndex = 0;
307
+ }
308
+ }
309
+ y.MAX_LENGTH = 100;
310
+ class W {
311
+ /**
312
+ View element
313
+ */
314
+ /** Internal {@link Masked} model */
315
+ constructor(t, e) {
316
+ this.el = t instanceof O ? t : t.isContentEditable && t.tagName !== "INPUT" && t.tagName !== "TEXTAREA" ? new j(t) : new X(t), this.masked = C(e), this._listeners = {}, this._value = "", this._unmaskedValue = "", this._rawInputValue = "", this.history = new y(), 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();
317
+ }
318
+ maskEquals(t) {
319
+ var e;
320
+ return t == null || ((e = this.masked) == null ? void 0 : e.maskEquals(t));
321
+ }
322
+ /** Masked */
323
+ get mask() {
324
+ return this.masked.mask;
325
+ }
326
+ set mask(t) {
327
+ if (this.maskEquals(t)) return;
328
+ if (!(t instanceof p.Masked) && this.masked.constructor === H(t)) {
329
+ this.masked.updateOptions({
330
+ mask: t
331
+ });
332
+ return;
333
+ }
334
+ const e = t instanceof p.Masked ? t : C({
335
+ mask: t
336
+ });
337
+ e.unmaskedValue = this.masked.unmaskedValue, this.masked = e;
338
+ }
339
+ /** Raw value */
340
+ get value() {
341
+ return this._value;
342
+ }
343
+ set value(t) {
344
+ this.value !== t && (this.masked.value = t, this.updateControl("auto"));
345
+ }
346
+ /** Unmasked value */
347
+ get unmaskedValue() {
348
+ return this._unmaskedValue;
349
+ }
350
+ set unmaskedValue(t) {
351
+ this.unmaskedValue !== t && (this.masked.unmaskedValue = t, this.updateControl("auto"));
352
+ }
353
+ /** Raw input value */
354
+ get rawInputValue() {
355
+ return this._rawInputValue;
356
+ }
357
+ set rawInputValue(t) {
358
+ this.rawInputValue !== t && (this.masked.rawInputValue = t, this.updateControl(), this.alignCursor());
359
+ }
360
+ /** Typed unmasked value */
361
+ get typedValue() {
362
+ return this.masked.typedValue;
363
+ }
364
+ set typedValue(t) {
365
+ this.masked.typedValueEquals(t) || (this.masked.typedValue = t, this.updateControl("auto"));
366
+ }
367
+ /** Display value */
368
+ get displayValue() {
369
+ return this.masked.displayValue;
370
+ }
371
+ /** Starts listening to element events */
372
+ _bindEvents() {
373
+ this.el.bindEvents({
374
+ selectionChange: this._saveSelection,
375
+ input: this._onInput,
376
+ drop: this._onDrop,
377
+ click: this._onClick,
378
+ focus: this._onFocus,
379
+ commit: this._onChange,
380
+ undo: this._onUndo,
381
+ redo: this._onRedo
382
+ });
383
+ }
384
+ /** Stops listening to element events */
385
+ _unbindEvents() {
386
+ this.el && this.el.unbindEvents();
387
+ }
388
+ /** Fires custom event */
389
+ _fireEvent(t, e) {
390
+ const s = this._listeners[t];
391
+ s && s.forEach((i) => i(e));
392
+ }
393
+ /** Current selection start */
394
+ get selectionStart() {
395
+ return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
396
+ }
397
+ /** Current cursor position */
398
+ get cursorPos() {
399
+ return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
400
+ }
401
+ set cursorPos(t) {
402
+ !this.el || !this.el.isActive || (this.el.select(t, t), this._saveSelection());
403
+ }
404
+ /** Stores current selection */
405
+ _saveSelection() {
406
+ this.displayValue !== this.el.value && console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."), this._selection = {
407
+ start: this.selectionStart,
408
+ end: this.cursorPos
409
+ };
410
+ }
411
+ /** Syncronizes model value from view */
412
+ updateValue() {
413
+ this.masked.value = this.el.value, this._value = this.masked.value, this._unmaskedValue = this.masked.unmaskedValue, this._rawInputValue = this.masked.rawInputValue;
414
+ }
415
+ /** Syncronizes view from model value, fires change events */
416
+ updateControl(t) {
417
+ const e = this.masked.unmaskedValue, s = this.masked.value, i = this.masked.rawInputValue, n = this.displayValue, a = this.unmaskedValue !== e || this.value !== s || this._rawInputValue !== i;
418
+ this._unmaskedValue = e, this._value = s, this._rawInputValue = i, this.el.value !== n && (this.el.value = n), t === "auto" ? this.alignCursor() : t != null && (this.cursorPos = t), a && this._fireChangeEvents(), !this._historyChanging && (a || this.history.isEmpty) && this.history.push({
419
+ unmaskedValue: e,
420
+ selection: {
421
+ start: this.selectionStart,
422
+ end: this.cursorPos
423
+ }
424
+ });
425
+ }
426
+ /** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
427
+ updateOptions(t) {
428
+ const {
429
+ mask: e,
430
+ ...s
431
+ } = t, i = !this.maskEquals(e), n = this.masked.optionsIsChanged(s);
432
+ i && (this.mask = e), n && this.masked.updateOptions(s), (i || n) && this.updateControl();
433
+ }
434
+ /** Updates cursor */
435
+ updateCursor(t) {
436
+ t != null && (this.cursorPos = t, this._delayUpdateCursor(t));
437
+ }
438
+ /** Delays cursor update to support mobile browsers */
439
+ _delayUpdateCursor(t) {
440
+ this._abortUpdateCursor(), this._changingCursorPos = t, this._cursorChanging = setTimeout(() => {
441
+ this.el && (this.cursorPos = this._changingCursorPos, this._abortUpdateCursor());
442
+ }, 10);
443
+ }
444
+ /** Fires custom events */
445
+ _fireChangeEvents() {
446
+ this._fireEvent("accept", this._inputEvent), this.masked.isComplete && this._fireEvent("complete", this._inputEvent);
447
+ }
448
+ /** Aborts delayed cursor update */
449
+ _abortUpdateCursor() {
450
+ this._cursorChanging && (clearTimeout(this._cursorChanging), delete this._cursorChanging);
451
+ }
452
+ /** Aligns cursor to nearest available position */
453
+ alignCursor() {
454
+ this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, l.LEFT));
455
+ }
456
+ /** Aligns cursor only if selection is empty */
457
+ alignCursorFriendly() {
458
+ this.selectionStart === this.cursorPos && this.alignCursor();
459
+ }
460
+ /** Adds listener on custom event */
461
+ on(t, e) {
462
+ return this._listeners[t] || (this._listeners[t] = []), this._listeners[t].push(e), this;
463
+ }
464
+ /** Removes custom event listener */
465
+ off(t, e) {
466
+ if (!this._listeners[t]) return this;
467
+ if (!e)
468
+ return delete this._listeners[t], this;
469
+ const s = this._listeners[t].indexOf(e);
470
+ return s >= 0 && this._listeners[t].splice(s, 1), this;
471
+ }
472
+ /** Handles view input event */
473
+ _onInput(t) {
474
+ this._inputEvent = t, this._abortUpdateCursor();
475
+ const e = new Z({
476
+ // new state
477
+ value: this.el.value,
478
+ cursorPos: this.cursorPos,
479
+ // old state
480
+ oldValue: this.displayValue,
481
+ oldSelection: this._selection
482
+ }), s = this.masked.rawInputValue, i = this.masked.splice(e.startChangePos, e.removed.length, e.inserted, e.removeDirection, {
483
+ input: !0,
484
+ raw: !0
485
+ }).offset, n = s === this.masked.rawInputValue ? e.removeDirection : l.NONE;
486
+ let a = this.masked.nearestInputPos(e.startChangePos + i, n);
487
+ n !== l.NONE && (a = this.masked.nearestInputPos(a, l.NONE)), this.updateControl(a), delete this._inputEvent;
488
+ }
489
+ /** Handles view change event and commits model value */
490
+ _onChange() {
491
+ this.displayValue !== this.el.value && this.updateValue(), this.masked.doCommit(), this.updateControl(), this._saveSelection();
492
+ }
493
+ /** Handles view drop event, prevents by default */
494
+ _onDrop(t) {
495
+ t.preventDefault(), t.stopPropagation();
496
+ }
497
+ /** Restore last selection on focus */
498
+ _onFocus(t) {
499
+ this.alignCursorFriendly();
500
+ }
501
+ /** Restore last selection on focus */
502
+ _onClick(t) {
503
+ this.alignCursorFriendly();
504
+ }
505
+ _onUndo() {
506
+ this._applyHistoryState(this.history.undo());
507
+ }
508
+ _onRedo() {
509
+ this._applyHistoryState(this.history.redo());
510
+ }
511
+ _applyHistoryState(t) {
512
+ t && (this._historyChanging = !0, this.unmaskedValue = t.unmaskedValue, this.el.select(t.selection.start, t.selection.end), this._saveSelection(), this._historyChanging = !1);
513
+ }
514
+ /** Unbind view events and removes element reference */
515
+ destroy() {
516
+ this._unbindEvents(), this._listeners.length = 0, delete this.el;
517
+ }
518
+ }
519
+ p.InputMask = W;
520
+ class d {
521
+ /** Inserted symbols */
522
+ /** Additional offset if any changes occurred before tail */
523
+ /** Raw inserted is used by dynamic mask */
524
+ /** Can skip chars */
525
+ static normalize(t) {
526
+ return Array.isArray(t) ? t : [t, new d()];
527
+ }
528
+ constructor(t) {
529
+ Object.assign(this, {
530
+ inserted: "",
531
+ rawInserted: "",
532
+ tailShift: 0,
533
+ skip: !1
534
+ }, t);
535
+ }
536
+ /** Aggregate changes */
537
+ aggregate(t) {
538
+ return this.inserted += t.inserted, this.rawInserted += t.rawInserted, this.tailShift += t.tailShift, this.skip = this.skip || t.skip, this;
539
+ }
540
+ /** Total offset considering all changes */
541
+ get offset() {
542
+ return this.tailShift + this.inserted.length;
543
+ }
544
+ get consumed() {
545
+ return !!this.rawInserted || this.skip;
546
+ }
547
+ equals(t) {
548
+ return this.inserted === t.inserted && this.tailShift === t.tailShift && this.rawInserted === t.rawInserted && this.skip === t.skip;
549
+ }
550
+ }
551
+ p.ChangeDetails = d;
552
+ class v {
553
+ /** Tail value as string */
554
+ /** Tail start position */
555
+ /** Start position */
556
+ constructor(t, e, s) {
557
+ t === void 0 && (t = ""), e === void 0 && (e = 0), this.value = t, this.from = e, this.stop = s;
558
+ }
559
+ toString() {
560
+ return this.value;
561
+ }
562
+ extend(t) {
563
+ this.value += String(t);
564
+ }
565
+ appendTo(t) {
566
+ return t.append(this.toString(), {
567
+ tail: !0
568
+ }).aggregate(t._appendPlaceholder());
569
+ }
570
+ get state() {
571
+ return {
572
+ value: this.value,
573
+ from: this.from,
574
+ stop: this.stop
575
+ };
576
+ }
577
+ set state(t) {
578
+ Object.assign(this, t);
579
+ }
580
+ unshift(t) {
581
+ if (!this.value.length || t != null && this.from >= t) return "";
582
+ const e = this.value[0];
583
+ return this.value = this.value.slice(1), e;
584
+ }
585
+ shift() {
586
+ if (!this.value.length) return "";
587
+ const t = this.value[this.value.length - 1];
588
+ return this.value = this.value.slice(0, -1), t;
589
+ }
590
+ }
591
+ class k {
592
+ /** */
593
+ /** */
594
+ /** Transforms value before mask processing */
595
+ /** Transforms each char before mask processing */
596
+ /** Validates if value is acceptable */
597
+ /** Does additional processing at the end of editing */
598
+ /** Format typed value to string */
599
+ /** Parse string to get typed value */
600
+ /** Enable characters overwriting */
601
+ /** */
602
+ /** */
603
+ /** */
604
+ /** */
605
+ constructor(t) {
606
+ this._value = "", this._update({
607
+ ...k.DEFAULTS,
608
+ ...t
609
+ }), this._initialized = !0;
610
+ }
611
+ /** Sets and applies new options */
612
+ updateOptions(t) {
613
+ this.optionsIsChanged(t) && this.withValueRefresh(this._update.bind(this, t));
614
+ }
615
+ /** Sets new options */
616
+ _update(t) {
617
+ Object.assign(this, t);
618
+ }
619
+ /** Mask state */
620
+ get state() {
621
+ return {
622
+ _value: this.value,
623
+ _rawInputValue: this.rawInputValue
624
+ };
625
+ }
626
+ set state(t) {
627
+ this._value = t._value;
628
+ }
629
+ /** Resets value */
630
+ reset() {
631
+ this._value = "";
632
+ }
633
+ get value() {
634
+ return this._value;
635
+ }
636
+ set value(t) {
637
+ this.resolve(t, {
638
+ input: !0
639
+ });
640
+ }
641
+ /** Resolve new value */
642
+ resolve(t, e) {
643
+ e === void 0 && (e = {
644
+ input: !0
645
+ }), this.reset(), this.append(t, e, ""), this.doCommit();
646
+ }
647
+ get unmaskedValue() {
648
+ return this.value;
649
+ }
650
+ set unmaskedValue(t) {
651
+ this.resolve(t, {});
652
+ }
653
+ get typedValue() {
654
+ return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
655
+ }
656
+ set typedValue(t) {
657
+ this.format ? this.value = this.format(t, this) : this.unmaskedValue = String(t);
658
+ }
659
+ /** Value that includes raw user input */
660
+ get rawInputValue() {
661
+ return this.extractInput(0, this.displayValue.length, {
662
+ raw: !0
663
+ });
664
+ }
665
+ set rawInputValue(t) {
666
+ this.resolve(t, {
667
+ raw: !0
668
+ });
669
+ }
670
+ get displayValue() {
671
+ return this.value;
672
+ }
673
+ get isComplete() {
674
+ return !0;
675
+ }
676
+ get isFilled() {
677
+ return this.isComplete;
678
+ }
679
+ /** Finds nearest input position in direction */
680
+ nearestInputPos(t, e) {
681
+ return t;
682
+ }
683
+ totalInputPositions(t, e) {
684
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), Math.min(this.displayValue.length, e - t);
685
+ }
686
+ /** Extracts value in range considering flags */
687
+ extractInput(t, e, s) {
688
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), this.displayValue.slice(t, e);
689
+ }
690
+ /** Extracts tail in range */
691
+ extractTail(t, e) {
692
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), new v(this.extractInput(t, e), t);
693
+ }
694
+ /** Appends tail */
695
+ appendTail(t) {
696
+ return A(t) && (t = new v(String(t))), t.appendTo(this);
697
+ }
698
+ /** Appends char */
699
+ _appendCharRaw(t, e) {
700
+ return t ? (this._value += t, new d({
701
+ inserted: t,
702
+ rawInserted: t
703
+ })) : new d();
704
+ }
705
+ /** Appends char */
706
+ _appendChar(t, e, s) {
707
+ e === void 0 && (e = {});
708
+ const i = this.state;
709
+ let n;
710
+ if ([t, n] = this.doPrepareChar(t, e), t && (n = n.aggregate(this._appendCharRaw(t, e)), !n.rawInserted && this.autofix === "pad")) {
711
+ const a = this.state;
712
+ this.state = i;
713
+ let r = this.pad(e);
714
+ const h = this._appendCharRaw(t, e);
715
+ r = r.aggregate(h), h.rawInserted || r.equals(n) ? n = r : this.state = a;
716
+ }
717
+ if (n.inserted) {
718
+ let a, r = this.doValidate(e) !== !1;
719
+ if (r && s != null) {
720
+ const h = this.state;
721
+ if (this.overwrite === !0) {
722
+ a = s.state;
723
+ for (let c = 0; c < n.rawInserted.length; ++c)
724
+ s.unshift(this.displayValue.length - n.tailShift);
725
+ }
726
+ let o = this.appendTail(s);
727
+ if (r = o.rawInserted.length === s.toString().length, !(r && o.inserted) && this.overwrite === "shift") {
728
+ this.state = h, a = s.state;
729
+ for (let c = 0; c < n.rawInserted.length; ++c)
730
+ s.shift();
731
+ o = this.appendTail(s), r = o.rawInserted.length === s.toString().length;
732
+ }
733
+ r && o.inserted && (this.state = h);
734
+ }
735
+ r || (n = new d(), this.state = i, s && a && (s.state = a));
736
+ }
737
+ return n;
738
+ }
739
+ /** Appends optional placeholder at the end */
740
+ _appendPlaceholder() {
741
+ return new d();
742
+ }
743
+ /** Appends optional eager placeholder at the end */
744
+ _appendEager() {
745
+ return new d();
746
+ }
747
+ /** Appends symbols considering flags */
748
+ append(t, e, s) {
749
+ if (!A(t)) throw new Error("value should be string");
750
+ const i = A(s) ? new v(String(s)) : s;
751
+ e != null && e.tail && (e._beforeTailState = this.state);
752
+ let n;
753
+ [t, n] = this.doPrepare(t, e);
754
+ for (let a = 0; a < t.length; ++a) {
755
+ const r = this._appendChar(t[a], e, i);
756
+ if (!r.rawInserted && !this.doSkipInvalid(t[a], e, i)) break;
757
+ n.aggregate(r);
758
+ }
759
+ return (this.eager === !0 || this.eager === "append") && e != null && e.input && t && n.aggregate(this._appendEager()), i != null && (n.tailShift += this.appendTail(i).tailShift), n;
760
+ }
761
+ remove(t, e) {
762
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), this._value = this.displayValue.slice(0, t) + this.displayValue.slice(e), new d();
763
+ }
764
+ /** Calls function and reapplies current value */
765
+ withValueRefresh(t) {
766
+ if (this._refreshing || !this._initialized) return t();
767
+ this._refreshing = !0;
768
+ const e = this.rawInputValue, s = this.value, i = t();
769
+ return this.rawInputValue = e, this.value && this.value !== s && s.indexOf(this.value) === 0 && (this.append(s.slice(this.displayValue.length), {}, ""), this.doCommit()), delete this._refreshing, i;
770
+ }
771
+ runIsolated(t) {
772
+ if (this._isolated || !this._initialized) return t(this);
773
+ this._isolated = !0;
774
+ const e = this.state, s = t(this);
775
+ return this.state = e, delete this._isolated, s;
776
+ }
777
+ doSkipInvalid(t, e, s) {
778
+ return !!this.skipInvalid;
779
+ }
780
+ /** Prepares string before mask processing */
781
+ doPrepare(t, e) {
782
+ return e === void 0 && (e = {}), d.normalize(this.prepare ? this.prepare(t, this, e) : t);
783
+ }
784
+ /** Prepares each char before mask processing */
785
+ doPrepareChar(t, e) {
786
+ return e === void 0 && (e = {}), d.normalize(this.prepareChar ? this.prepareChar(t, this, e) : t);
787
+ }
788
+ /** Validates if value is acceptable */
789
+ doValidate(t) {
790
+ return (!this.validate || this.validate(this.value, this, t)) && (!this.parent || this.parent.doValidate(t));
791
+ }
792
+ /** Does additional processing at the end of editing */
793
+ doCommit() {
794
+ this.commit && this.commit(this.value, this);
795
+ }
796
+ splice(t, e, s, i, n) {
797
+ s === void 0 && (s = ""), i === void 0 && (i = l.NONE), n === void 0 && (n = {
798
+ input: !0
799
+ });
800
+ const a = t + e, r = this.extractTail(a), h = this.eager === !0 || this.eager === "remove";
801
+ let o;
802
+ h && (i = Y(i), o = this.extractInput(0, a, {
803
+ raw: !0
804
+ }));
805
+ let c = t;
806
+ const f = new d();
807
+ if (i !== l.NONE && (c = this.nearestInputPos(t, e > 1 && t !== 0 && !h ? l.NONE : i), f.tailShift = c - t), f.aggregate(this.remove(c)), h && i !== l.NONE && o === this.rawInputValue)
808
+ if (i === l.FORCE_LEFT) {
809
+ let _;
810
+ for (; o === this.rawInputValue && (_ = this.displayValue.length); )
811
+ f.aggregate(new d({
812
+ tailShift: -1
813
+ })).aggregate(this.remove(_ - 1));
814
+ } else i === l.FORCE_RIGHT && r.unshift();
815
+ return f.aggregate(this.append(s, n, r));
816
+ }
817
+ maskEquals(t) {
818
+ return this.mask === t;
819
+ }
820
+ optionsIsChanged(t) {
821
+ return !I(this, t);
822
+ }
823
+ typedValueEquals(t) {
824
+ const e = this.typedValue;
825
+ return t === e || k.EMPTY_VALUES.includes(t) && k.EMPTY_VALUES.includes(e) || (this.format ? this.format(t, this) === this.format(this.typedValue, this) : !1);
826
+ }
827
+ pad(t) {
828
+ return new d();
829
+ }
830
+ }
831
+ k.DEFAULTS = {
832
+ skipInvalid: !0
833
+ };
834
+ k.EMPTY_VALUES = [void 0, null, ""];
835
+ p.Masked = k;
836
+ class F {
837
+ /** */
838
+ constructor(t, e) {
839
+ t === void 0 && (t = []), e === void 0 && (e = 0), this.chunks = t, this.from = e;
840
+ }
841
+ toString() {
842
+ return this.chunks.map(String).join("");
843
+ }
844
+ extend(t) {
845
+ if (!String(t)) return;
846
+ t = A(t) ? new v(String(t)) : t;
847
+ const e = this.chunks[this.chunks.length - 1], s = e && // if stops are same or tail has no stop
848
+ (e.stop === t.stop || t.stop == null) && // if tail chunk goes just after last chunk
849
+ t.from === e.from + e.toString().length;
850
+ if (t instanceof v)
851
+ s ? e.extend(t.toString()) : this.chunks.push(t);
852
+ else if (t instanceof F) {
853
+ if (t.stop == null) {
854
+ let i;
855
+ for (; t.chunks.length && t.chunks[0].stop == null; )
856
+ i = t.chunks.shift(), i.from += t.from, this.extend(i);
857
+ }
858
+ t.toString() && (t.stop = t.blockIndex, this.chunks.push(t));
859
+ }
860
+ }
861
+ appendTo(t) {
862
+ if (!(t instanceof p.MaskedPattern))
863
+ return new v(this.toString()).appendTo(t);
864
+ const e = new d();
865
+ for (let s = 0; s < this.chunks.length; ++s) {
866
+ const i = this.chunks[s], n = t._mapPosToBlock(t.displayValue.length), a = i.stop;
867
+ let r;
868
+ if (a != null && // if block not found or stop is behind lastBlock
869
+ (!n || n.index <= a) && ((i instanceof F || // for continuous block also check if stop is exist
870
+ t._stops.indexOf(a) >= 0) && e.aggregate(t._appendPlaceholder(a)), r = i instanceof F && t._blocks[a]), r) {
871
+ const h = r.appendTail(i);
872
+ e.aggregate(h);
873
+ const o = i.toString().slice(h.rawInserted.length);
874
+ o && e.aggregate(t.append(o, {
875
+ tail: !0
876
+ }));
877
+ } else
878
+ e.aggregate(t.append(i.toString(), {
879
+ tail: !0
880
+ }));
881
+ }
882
+ return e;
883
+ }
884
+ get state() {
885
+ return {
886
+ chunks: this.chunks.map((t) => t.state),
887
+ from: this.from,
888
+ stop: this.stop,
889
+ blockIndex: this.blockIndex
890
+ };
891
+ }
892
+ set state(t) {
893
+ const {
894
+ chunks: e,
895
+ ...s
896
+ } = t;
897
+ Object.assign(this, s), this.chunks = e.map((i) => {
898
+ const n = "chunks" in i ? new F() : new v();
899
+ return n.state = i, n;
900
+ });
901
+ }
902
+ unshift(t) {
903
+ if (!this.chunks.length || t != null && this.from >= t) return "";
904
+ const e = t != null ? t - this.from : t;
905
+ let s = 0;
906
+ for (; s < this.chunks.length; ) {
907
+ const i = this.chunks[s], n = i.unshift(e);
908
+ if (i.toString()) {
909
+ if (!n) break;
910
+ ++s;
911
+ } else
912
+ this.chunks.splice(s, 1);
913
+ if (n) return n;
914
+ }
915
+ return "";
916
+ }
917
+ shift() {
918
+ if (!this.chunks.length) return "";
919
+ let t = this.chunks.length - 1;
920
+ for (; 0 <= t; ) {
921
+ const e = this.chunks[t], s = e.shift();
922
+ if (e.toString()) {
923
+ if (!s) break;
924
+ --t;
925
+ } else
926
+ this.chunks.splice(t, 1);
927
+ if (s) return s;
928
+ }
929
+ return "";
930
+ }
931
+ }
932
+ class J {
933
+ constructor(t, e) {
934
+ this.masked = t, this._log = [];
935
+ const {
936
+ offset: s,
937
+ index: i
938
+ } = t._mapPosToBlock(e) || (e < 0 ? (
939
+ // first
940
+ {
941
+ index: 0,
942
+ offset: 0
943
+ }
944
+ ) : (
945
+ // last
946
+ {
947
+ index: this.masked._blocks.length,
948
+ offset: 0
949
+ }
950
+ ));
951
+ this.offset = s, this.index = i, this.ok = !1;
952
+ }
953
+ get block() {
954
+ return this.masked._blocks[this.index];
955
+ }
956
+ get pos() {
957
+ return this.masked._blockStartPos(this.index) + this.offset;
958
+ }
959
+ get state() {
960
+ return {
961
+ index: this.index,
962
+ offset: this.offset,
963
+ ok: this.ok
964
+ };
965
+ }
966
+ set state(t) {
967
+ Object.assign(this, t);
968
+ }
969
+ pushState() {
970
+ this._log.push(this.state);
971
+ }
972
+ popState() {
973
+ const t = this._log.pop();
974
+ return t && (this.state = t), t;
975
+ }
976
+ bindBlock() {
977
+ 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));
978
+ }
979
+ _pushLeft(t) {
980
+ for (this.pushState(), this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((e = this.block) == null ? void 0 : e.displayValue.length) || 0) {
981
+ var e;
982
+ if (t()) return this.ok = !0;
983
+ }
984
+ return this.ok = !1;
985
+ }
986
+ _pushRight(t) {
987
+ for (this.pushState(), this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0)
988
+ if (t()) return this.ok = !0;
989
+ return this.ok = !1;
990
+ }
991
+ pushLeftBeforeFilled() {
992
+ return this._pushLeft(() => {
993
+ if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, l.FORCE_LEFT), this.offset !== 0))
994
+ return !0;
995
+ });
996
+ }
997
+ pushLeftBeforeInput() {
998
+ return this._pushLeft(() => {
999
+ if (!this.block.isFixed)
1000
+ return this.offset = this.block.nearestInputPos(this.offset, l.LEFT), !0;
1001
+ });
1002
+ }
1003
+ pushLeftBeforeRequired() {
1004
+ return this._pushLeft(() => {
1005
+ if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
1006
+ return this.offset = this.block.nearestInputPos(this.offset, l.LEFT), !0;
1007
+ });
1008
+ }
1009
+ pushRightBeforeFilled() {
1010
+ return this._pushRight(() => {
1011
+ if (!(this.block.isFixed || !this.block.value) && (this.offset = this.block.nearestInputPos(this.offset, l.FORCE_RIGHT), this.offset !== this.block.value.length))
1012
+ return !0;
1013
+ });
1014
+ }
1015
+ pushRightBeforeInput() {
1016
+ return this._pushRight(() => {
1017
+ if (!this.block.isFixed)
1018
+ return this.offset = this.block.nearestInputPos(this.offset, l.NONE), !0;
1019
+ });
1020
+ }
1021
+ pushRightBeforeRequired() {
1022
+ return this._pushRight(() => {
1023
+ if (!(this.block.isFixed || this.block.isOptional && !this.block.value))
1024
+ return this.offset = this.block.nearestInputPos(this.offset, l.NONE), !0;
1025
+ });
1026
+ }
1027
+ }
1028
+ class G {
1029
+ /** */
1030
+ /** */
1031
+ /** */
1032
+ /** */
1033
+ /** */
1034
+ /** */
1035
+ constructor(t) {
1036
+ Object.assign(this, t), this._value = "", this.isFixed = !0;
1037
+ }
1038
+ get value() {
1039
+ return this._value;
1040
+ }
1041
+ get unmaskedValue() {
1042
+ return this.isUnmasking ? this.value : "";
1043
+ }
1044
+ get rawInputValue() {
1045
+ return this._isRawInput ? this.value : "";
1046
+ }
1047
+ get displayValue() {
1048
+ return this.value;
1049
+ }
1050
+ reset() {
1051
+ this._isRawInput = !1, this._value = "";
1052
+ }
1053
+ remove(t, e) {
1054
+ return t === void 0 && (t = 0), e === void 0 && (e = this._value.length), this._value = this._value.slice(0, t) + this._value.slice(e), this._value || (this._isRawInput = !1), new d();
1055
+ }
1056
+ nearestInputPos(t, e) {
1057
+ e === void 0 && (e = l.NONE);
1058
+ const s = 0, i = this._value.length;
1059
+ switch (e) {
1060
+ case l.LEFT:
1061
+ case l.FORCE_LEFT:
1062
+ return s;
1063
+ case l.NONE:
1064
+ case l.RIGHT:
1065
+ case l.FORCE_RIGHT:
1066
+ default:
1067
+ return i;
1068
+ }
1069
+ }
1070
+ totalInputPositions(t, e) {
1071
+ return t === void 0 && (t = 0), e === void 0 && (e = this._value.length), this._isRawInput ? e - t : 0;
1072
+ }
1073
+ extractInput(t, e, s) {
1074
+ return t === void 0 && (t = 0), e === void 0 && (e = this._value.length), s === void 0 && (s = {}), s.raw && this._isRawInput && this._value.slice(t, e) || "";
1075
+ }
1076
+ get isComplete() {
1077
+ return !0;
1078
+ }
1079
+ get isFilled() {
1080
+ return !!this._value;
1081
+ }
1082
+ _appendChar(t, e) {
1083
+ if (e === void 0 && (e = {}), this.isFilled) return new d();
1084
+ const s = this.eager === !0 || this.eager === "append", n = this.char === t && (this.isUnmasking || e.input || e.raw) && (!e.raw || !s) && !e.tail, a = new d({
1085
+ inserted: this.char,
1086
+ rawInserted: n ? this.char : ""
1087
+ });
1088
+ return this._value = this.char, this._isRawInput = n && (e.raw || e.input), a;
1089
+ }
1090
+ _appendEager() {
1091
+ return this._appendChar(this.char, {
1092
+ tail: !0
1093
+ });
1094
+ }
1095
+ _appendPlaceholder() {
1096
+ const t = new d();
1097
+ return this.isFilled || (this._value = t.inserted = this.char), t;
1098
+ }
1099
+ extractTail() {
1100
+ return new v("");
1101
+ }
1102
+ appendTail(t) {
1103
+ return A(t) && (t = new v(String(t))), t.appendTo(this);
1104
+ }
1105
+ append(t, e, s) {
1106
+ const i = this._appendChar(t[0], e);
1107
+ return s != null && (i.tailShift += this.appendTail(s).tailShift), i;
1108
+ }
1109
+ doCommit() {
1110
+ }
1111
+ get state() {
1112
+ return {
1113
+ _value: this._value,
1114
+ _rawInputValue: this.rawInputValue
1115
+ };
1116
+ }
1117
+ set state(t) {
1118
+ this._value = t._value, this._isRawInput = !!t._rawInputValue;
1119
+ }
1120
+ pad(t) {
1121
+ return this._appendPlaceholder();
1122
+ }
1123
+ }
1124
+ class D {
1125
+ /** */
1126
+ /** */
1127
+ /** */
1128
+ /** */
1129
+ /** */
1130
+ /** */
1131
+ /** */
1132
+ /** */
1133
+ constructor(t) {
1134
+ const {
1135
+ parent: e,
1136
+ isOptional: s,
1137
+ placeholderChar: i,
1138
+ displayChar: n,
1139
+ lazy: a,
1140
+ eager: r,
1141
+ ...h
1142
+ } = t;
1143
+ this.masked = C(h), Object.assign(this, {
1144
+ parent: e,
1145
+ isOptional: s,
1146
+ placeholderChar: i,
1147
+ displayChar: n,
1148
+ lazy: a,
1149
+ eager: r
1150
+ });
1151
+ }
1152
+ reset() {
1153
+ this.isFilled = !1, this.masked.reset();
1154
+ }
1155
+ remove(t, e) {
1156
+ return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), t === 0 && e >= 1 ? (this.isFilled = !1, this.masked.remove(t, e)) : new d();
1157
+ }
1158
+ get value() {
1159
+ return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : "");
1160
+ }
1161
+ get unmaskedValue() {
1162
+ return this.masked.unmaskedValue;
1163
+ }
1164
+ get rawInputValue() {
1165
+ return this.masked.rawInputValue;
1166
+ }
1167
+ get displayValue() {
1168
+ return this.masked.value && this.displayChar || this.value;
1169
+ }
1170
+ get isComplete() {
1171
+ return !!this.masked.value || this.isOptional;
1172
+ }
1173
+ _appendChar(t, e) {
1174
+ if (e === void 0 && (e = {}), this.isFilled) return new d();
1175
+ const s = this.masked.state;
1176
+ let i = this.masked._appendChar(t, this.currentMaskFlags(e));
1177
+ return i.inserted && this.doValidate(e) === !1 && (i = new d(), this.masked.state = s), !i.inserted && !this.isOptional && !this.lazy && !e.input && (i.inserted = this.placeholderChar), i.skip = !i.inserted && !this.isOptional, this.isFilled = !!i.inserted, i;
1178
+ }
1179
+ append(t, e, s) {
1180
+ return this.masked.append(t, this.currentMaskFlags(e), s);
1181
+ }
1182
+ _appendPlaceholder() {
1183
+ return this.isFilled || this.isOptional ? new d() : (this.isFilled = !0, new d({
1184
+ inserted: this.placeholderChar
1185
+ }));
1186
+ }
1187
+ _appendEager() {
1188
+ return new d();
1189
+ }
1190
+ extractTail(t, e) {
1191
+ return this.masked.extractTail(t, e);
1192
+ }
1193
+ appendTail(t) {
1194
+ return this.masked.appendTail(t);
1195
+ }
1196
+ extractInput(t, e, s) {
1197
+ return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), this.masked.extractInput(t, e, s);
1198
+ }
1199
+ nearestInputPos(t, e) {
1200
+ e === void 0 && (e = l.NONE);
1201
+ const s = 0, i = this.value.length, n = Math.min(Math.max(t, s), i);
1202
+ switch (e) {
1203
+ case l.LEFT:
1204
+ case l.FORCE_LEFT:
1205
+ return this.isComplete ? n : s;
1206
+ case l.RIGHT:
1207
+ case l.FORCE_RIGHT:
1208
+ return this.isComplete ? n : i;
1209
+ case l.NONE:
1210
+ default:
1211
+ return n;
1212
+ }
1213
+ }
1214
+ totalInputPositions(t, e) {
1215
+ return t === void 0 && (t = 0), e === void 0 && (e = this.value.length), this.value.slice(t, e).length;
1216
+ }
1217
+ doValidate(t) {
1218
+ return this.masked.doValidate(this.currentMaskFlags(t)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(t)));
1219
+ }
1220
+ doCommit() {
1221
+ this.masked.doCommit();
1222
+ }
1223
+ get state() {
1224
+ return {
1225
+ _value: this.value,
1226
+ _rawInputValue: this.rawInputValue,
1227
+ masked: this.masked.state,
1228
+ isFilled: this.isFilled
1229
+ };
1230
+ }
1231
+ set state(t) {
1232
+ this.masked.state = t.masked, this.isFilled = t.isFilled;
1233
+ }
1234
+ currentMaskFlags(t) {
1235
+ var e;
1236
+ return {
1237
+ ...t,
1238
+ _beforeTailState: (t == null || (e = t._beforeTailState) == null ? void 0 : e.masked) || t?._beforeTailState
1239
+ };
1240
+ }
1241
+ pad(t) {
1242
+ return new d();
1243
+ }
1244
+ }
1245
+ D.DEFAULT_DEFINITIONS = {
1246
+ 0: /\d/,
1247
+ 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]/,
1248
+ // http://stackoverflow.com/a/22075070
1249
+ "*": /./
1250
+ };
1251
+ class Q extends k {
1252
+ /** */
1253
+ /** Enable characters overwriting */
1254
+ /** */
1255
+ /** */
1256
+ /** */
1257
+ updateOptions(t) {
1258
+ super.updateOptions(t);
1259
+ }
1260
+ _update(t) {
1261
+ const e = t.mask;
1262
+ e && (t.validate = (s) => s.search(e) >= 0), super._update(t);
1263
+ }
1264
+ }
1265
+ p.MaskedRegExp = Q;
1266
+ class g extends k {
1267
+ /** */
1268
+ /** */
1269
+ /** Single char for empty input */
1270
+ /** Single char for filled input */
1271
+ /** Show placeholder only when needed */
1272
+ /** Enable characters overwriting */
1273
+ /** */
1274
+ /** */
1275
+ /** */
1276
+ constructor(t) {
1277
+ super({
1278
+ ...g.DEFAULTS,
1279
+ ...t,
1280
+ definitions: Object.assign({}, D.DEFAULT_DEFINITIONS, t?.definitions)
1281
+ });
1282
+ }
1283
+ updateOptions(t) {
1284
+ super.updateOptions(t);
1285
+ }
1286
+ _update(t) {
1287
+ t.definitions = Object.assign({}, this.definitions, t.definitions), super._update(t), this._rebuildMask();
1288
+ }
1289
+ _rebuildMask() {
1290
+ const t = this.definitions;
1291
+ this._blocks = [], this.exposeBlock = void 0, this._stops = [], this._maskedBlocks = {};
1292
+ const e = this.mask;
1293
+ if (!e || !t) return;
1294
+ let s = !1, i = !1;
1295
+ for (let n = 0; n < e.length; ++n) {
1296
+ if (this.blocks) {
1297
+ const o = e.slice(n), c = Object.keys(this.blocks).filter((_) => o.indexOf(_) === 0);
1298
+ c.sort((_, B) => B.length - _.length);
1299
+ const f = c[0];
1300
+ if (f) {
1301
+ const {
1302
+ expose: _,
1303
+ repeat: B,
1304
+ ...q
1305
+ } = x(this.blocks[f]), L = {
1306
+ lazy: this.lazy,
1307
+ eager: this.eager,
1308
+ placeholderChar: this.placeholderChar,
1309
+ displayChar: this.displayChar,
1310
+ overwrite: this.overwrite,
1311
+ autofix: this.autofix,
1312
+ ...q,
1313
+ repeat: B,
1314
+ parent: this
1315
+ }, M = B != null ? new p.RepeatBlock(
1316
+ L
1317
+ /* TODO */
1318
+ ) : C(L);
1319
+ M && (this._blocks.push(M), _ && (this.exposeBlock = M), this._maskedBlocks[f] || (this._maskedBlocks[f] = []), this._maskedBlocks[f].push(this._blocks.length - 1)), n += f.length - 1;
1320
+ continue;
1321
+ }
1322
+ }
1323
+ let a = e[n], r = a in t;
1324
+ if (a === g.STOP_CHAR) {
1325
+ this._stops.push(this._blocks.length);
1326
+ continue;
1327
+ }
1328
+ if (a === "{" || a === "}") {
1329
+ s = !s;
1330
+ continue;
1331
+ }
1332
+ if (a === "[" || a === "]") {
1333
+ i = !i;
1334
+ continue;
1335
+ }
1336
+ if (a === g.ESCAPE_CHAR) {
1337
+ if (++n, a = e[n], !a) break;
1338
+ r = !1;
1339
+ }
1340
+ const h = r ? new D({
1341
+ isOptional: i,
1342
+ lazy: this.lazy,
1343
+ eager: this.eager,
1344
+ placeholderChar: this.placeholderChar,
1345
+ displayChar: this.displayChar,
1346
+ ...x(t[a]),
1347
+ parent: this
1348
+ }) : new G({
1349
+ char: a,
1350
+ eager: this.eager,
1351
+ isUnmasking: s
1352
+ });
1353
+ this._blocks.push(h);
1354
+ }
1355
+ }
1356
+ get state() {
1357
+ return {
1358
+ ...super.state,
1359
+ _blocks: this._blocks.map((t) => t.state)
1360
+ };
1361
+ }
1362
+ set state(t) {
1363
+ if (!t) {
1364
+ this.reset();
1365
+ return;
1366
+ }
1367
+ const {
1368
+ _blocks: e,
1369
+ ...s
1370
+ } = t;
1371
+ this._blocks.forEach((i, n) => i.state = e[n]), super.state = s;
1372
+ }
1373
+ reset() {
1374
+ super.reset(), this._blocks.forEach((t) => t.reset());
1375
+ }
1376
+ get isComplete() {
1377
+ return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every((t) => t.isComplete);
1378
+ }
1379
+ get isFilled() {
1380
+ return this._blocks.every((t) => t.isFilled);
1381
+ }
1382
+ get isFixed() {
1383
+ return this._blocks.every((t) => t.isFixed);
1384
+ }
1385
+ get isOptional() {
1386
+ return this._blocks.every((t) => t.isOptional);
1387
+ }
1388
+ doCommit() {
1389
+ this._blocks.forEach((t) => t.doCommit()), super.doCommit();
1390
+ }
1391
+ get unmaskedValue() {
1392
+ return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((t, e) => t += e.unmaskedValue, "");
1393
+ }
1394
+ set unmaskedValue(t) {
1395
+ if (this.exposeBlock) {
1396
+ const e = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1397
+ this.exposeBlock.unmaskedValue = t, this.appendTail(e), this.doCommit();
1398
+ } else super.unmaskedValue = t;
1399
+ }
1400
+ get value() {
1401
+ return this.exposeBlock ? this.exposeBlock.value : (
1402
+ // TODO return _value when not in change?
1403
+ this._blocks.reduce((t, e) => t += e.value, "")
1404
+ );
1405
+ }
1406
+ set value(t) {
1407
+ if (this.exposeBlock) {
1408
+ const e = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1409
+ this.exposeBlock.value = t, this.appendTail(e), this.doCommit();
1410
+ } else super.value = t;
1411
+ }
1412
+ get typedValue() {
1413
+ return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
1414
+ }
1415
+ set typedValue(t) {
1416
+ if (this.exposeBlock) {
1417
+ const e = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
1418
+ this.exposeBlock.typedValue = t, this.appendTail(e), this.doCommit();
1419
+ } else super.typedValue = t;
1420
+ }
1421
+ get displayValue() {
1422
+ return this._blocks.reduce((t, e) => t += e.displayValue, "");
1423
+ }
1424
+ appendTail(t) {
1425
+ return super.appendTail(t).aggregate(this._appendPlaceholder());
1426
+ }
1427
+ _appendEager() {
1428
+ var t;
1429
+ const e = new d();
1430
+ let s = (t = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : t.index;
1431
+ if (s == null) return e;
1432
+ this._blocks[s].isFilled && ++s;
1433
+ for (let i = s; i < this._blocks.length; ++i) {
1434
+ const n = this._blocks[i]._appendEager();
1435
+ if (!n.inserted) break;
1436
+ e.aggregate(n);
1437
+ }
1438
+ return e;
1439
+ }
1440
+ _appendCharRaw(t, e) {
1441
+ e === void 0 && (e = {});
1442
+ const s = this._mapPosToBlock(this.displayValue.length), i = new d();
1443
+ if (!s) return i;
1444
+ for (let a = s.index, r; r = this._blocks[a]; ++a) {
1445
+ var n;
1446
+ const h = r._appendChar(t, {
1447
+ ...e,
1448
+ _beforeTailState: (n = e._beforeTailState) == null || (n = n._blocks) == null ? void 0 : n[a]
1449
+ });
1450
+ if (i.aggregate(h), h.consumed) break;
1451
+ }
1452
+ return i;
1453
+ }
1454
+ extractTail(t, e) {
1455
+ t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
1456
+ const s = new F();
1457
+ return t === e || this._forEachBlocksInRange(t, e, (i, n, a, r) => {
1458
+ const h = i.extractTail(a, r);
1459
+ h.stop = this._findStopBefore(n), h.from = this._blockStartPos(n), h instanceof F && (h.blockIndex = n), s.extend(h);
1460
+ }), s;
1461
+ }
1462
+ extractInput(t, e, s) {
1463
+ if (t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), s === void 0 && (s = {}), t === e) return "";
1464
+ let i = "";
1465
+ return this._forEachBlocksInRange(t, e, (n, a, r, h) => {
1466
+ i += n.extractInput(r, h, s);
1467
+ }), i;
1468
+ }
1469
+ _findStopBefore(t) {
1470
+ let e;
1471
+ for (let s = 0; s < this._stops.length; ++s) {
1472
+ const i = this._stops[s];
1473
+ if (i <= t) e = i;
1474
+ else break;
1475
+ }
1476
+ return e;
1477
+ }
1478
+ /** Appends placeholder depending on laziness */
1479
+ _appendPlaceholder(t) {
1480
+ const e = new d();
1481
+ if (this.lazy && t == null) return e;
1482
+ const s = this._mapPosToBlock(this.displayValue.length);
1483
+ if (!s) return e;
1484
+ const i = s.index, n = t ?? this._blocks.length;
1485
+ return this._blocks.slice(i, n).forEach((a) => {
1486
+ if (!a.lazy || t != null) {
1487
+ var r;
1488
+ e.aggregate(a._appendPlaceholder((r = a._blocks) == null ? void 0 : r.length));
1489
+ }
1490
+ }), e;
1491
+ }
1492
+ /** Finds block in pos */
1493
+ _mapPosToBlock(t) {
1494
+ let e = "";
1495
+ for (let s = 0; s < this._blocks.length; ++s) {
1496
+ const i = this._blocks[s], n = e.length;
1497
+ if (e += i.displayValue, t <= e.length)
1498
+ return {
1499
+ index: s,
1500
+ offset: t - n
1501
+ };
1502
+ }
1503
+ }
1504
+ _blockStartPos(t) {
1505
+ return this._blocks.slice(0, t).reduce((e, s) => e += s.displayValue.length, 0);
1506
+ }
1507
+ _forEachBlocksInRange(t, e, s) {
1508
+ e === void 0 && (e = this.displayValue.length);
1509
+ const i = this._mapPosToBlock(t);
1510
+ if (i) {
1511
+ const n = this._mapPosToBlock(e), a = n && i.index === n.index, r = i.offset, h = n && a ? n.offset : this._blocks[i.index].displayValue.length;
1512
+ if (s(this._blocks[i.index], i.index, r, h), n && !a) {
1513
+ for (let o = i.index + 1; o < n.index; ++o)
1514
+ s(this._blocks[o], o, 0, this._blocks[o].displayValue.length);
1515
+ s(this._blocks[n.index], n.index, 0, n.offset);
1516
+ }
1517
+ }
1518
+ }
1519
+ remove(t, e) {
1520
+ t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
1521
+ const s = super.remove(t, e);
1522
+ return this._forEachBlocksInRange(t, e, (i, n, a, r) => {
1523
+ s.aggregate(i.remove(a, r));
1524
+ }), s;
1525
+ }
1526
+ nearestInputPos(t, e) {
1527
+ if (e === void 0 && (e = l.NONE), !this._blocks.length) return 0;
1528
+ const s = new J(this, t);
1529
+ if (e === l.NONE)
1530
+ return s.pushRightBeforeInput() || (s.popState(), s.pushLeftBeforeInput()) ? s.pos : this.displayValue.length;
1531
+ if (e === l.LEFT || e === l.FORCE_LEFT) {
1532
+ if (e === l.LEFT) {
1533
+ if (s.pushRightBeforeFilled(), s.ok && s.pos === t) return t;
1534
+ s.popState();
1535
+ }
1536
+ if (s.pushLeftBeforeInput(), s.pushLeftBeforeRequired(), s.pushLeftBeforeFilled(), e === l.LEFT) {
1537
+ if (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.ok && s.pos <= t || (s.popState(), s.ok && s.pos <= t)) return s.pos;
1538
+ s.popState();
1539
+ }
1540
+ return s.ok ? s.pos : e === l.FORCE_LEFT ? 0 : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : 0);
1541
+ }
1542
+ return e === l.RIGHT || e === l.FORCE_RIGHT ? (s.pushRightBeforeInput(), s.pushRightBeforeRequired(), s.pushRightBeforeFilled() ? s.pos : e === l.FORCE_RIGHT ? this.displayValue.length : (s.popState(), s.ok || (s.popState(), s.ok) ? s.pos : this.nearestInputPos(t, l.LEFT))) : t;
1543
+ }
1544
+ totalInputPositions(t, e) {
1545
+ t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
1546
+ let s = 0;
1547
+ return this._forEachBlocksInRange(t, e, (i, n, a, r) => {
1548
+ s += i.totalInputPositions(a, r);
1549
+ }), s;
1550
+ }
1551
+ /** Get block by name */
1552
+ maskedBlock(t) {
1553
+ return this.maskedBlocks(t)[0];
1554
+ }
1555
+ /** Get all blocks by name */
1556
+ maskedBlocks(t) {
1557
+ const e = this._maskedBlocks[t];
1558
+ return e ? e.map((s) => this._blocks[s]) : [];
1559
+ }
1560
+ pad(t) {
1561
+ const e = new d();
1562
+ return this._forEachBlocksInRange(0, this.displayValue.length, (s) => e.aggregate(s.pad(t))), e;
1563
+ }
1564
+ }
1565
+ g.DEFAULTS = {
1566
+ ...k.DEFAULTS,
1567
+ lazy: !0,
1568
+ placeholderChar: "_"
1569
+ };
1570
+ g.STOP_CHAR = "`";
1571
+ g.ESCAPE_CHAR = "\\";
1572
+ g.InputDefinition = D;
1573
+ g.FixedDefinition = G;
1574
+ p.MaskedPattern = g;
1575
+ class S extends g {
1576
+ /**
1577
+ Optionally sets max length of pattern.
1578
+ Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
1579
+ */
1580
+ /** Min bound */
1581
+ /** Max bound */
1582
+ get _matchFrom() {
1583
+ return this.maxLength - String(this.from).length;
1584
+ }
1585
+ constructor(t) {
1586
+ super(t);
1587
+ }
1588
+ updateOptions(t) {
1589
+ super.updateOptions(t);
1590
+ }
1591
+ _update(t) {
1592
+ const {
1593
+ to: e = this.to || 0,
1594
+ from: s = this.from || 0,
1595
+ maxLength: i = this.maxLength || 0,
1596
+ autofix: n = this.autofix,
1597
+ ...a
1598
+ } = t;
1599
+ this.to = e, this.from = s, this.maxLength = Math.max(String(e).length, i), this.autofix = n;
1600
+ const r = String(this.from).padStart(this.maxLength, "0"), h = String(this.to).padStart(this.maxLength, "0");
1601
+ let o = 0;
1602
+ for (; o < h.length && h[o] === r[o]; ) ++o;
1603
+ a.mask = h.slice(0, o).replace(/0/g, "\\0") + "0".repeat(this.maxLength - o), super._update(a);
1604
+ }
1605
+ get isComplete() {
1606
+ return super.isComplete && !!this.value;
1607
+ }
1608
+ boundaries(t) {
1609
+ let e = "", s = "";
1610
+ const [, i, n] = t.match(/^(\D*)(\d*)(\D*)/) || [];
1611
+ return n && (e = "0".repeat(i.length) + n, s = "9".repeat(i.length) + n), e = e.padEnd(this.maxLength, "0"), s = s.padEnd(this.maxLength, "9"), [e, s];
1612
+ }
1613
+ doPrepareChar(t, e) {
1614
+ e === void 0 && (e = {});
1615
+ let s;
1616
+ return [t, s] = super.doPrepareChar(t.replace(/\D/g, ""), e), t || (s.skip = !this.isComplete), [t, s];
1617
+ }
1618
+ _appendCharRaw(t, e) {
1619
+ if (e === void 0 && (e = {}), !this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(t, e);
1620
+ const s = String(this.from).padStart(this.maxLength, "0"), i = String(this.to).padStart(this.maxLength, "0"), [n, a] = this.boundaries(this.value + t);
1621
+ return Number(a) < this.from ? super._appendCharRaw(s[this.value.length], e) : Number(n) > this.to ? !e.tail && this.autofix === "pad" && this.value.length + 1 < this.maxLength ? super._appendCharRaw(s[this.value.length], e).aggregate(this._appendCharRaw(t, e)) : super._appendCharRaw(i[this.value.length], e) : super._appendCharRaw(t, e);
1622
+ }
1623
+ doValidate(t) {
1624
+ const e = this.value;
1625
+ if (e.search(/[^0]/) === -1 && e.length <= this._matchFrom) return !0;
1626
+ const [i, n] = this.boundaries(e);
1627
+ return this.from <= Number(n) && Number(i) <= this.to && super.doValidate(t);
1628
+ }
1629
+ pad(t) {
1630
+ const e = new d();
1631
+ if (this.value.length === this.maxLength) return e;
1632
+ const s = this.value, i = this.maxLength - this.value.length;
1633
+ if (i) {
1634
+ this.reset();
1635
+ for (let n = 0; n < i; ++n)
1636
+ e.aggregate(super._appendCharRaw("0", t));
1637
+ s.split("").forEach((n) => this._appendCharRaw(n));
1638
+ }
1639
+ return e;
1640
+ }
1641
+ }
1642
+ p.MaskedRange = S;
1643
+ const tt = "d{.}`m{.}`Y";
1644
+ class E extends g {
1645
+ static extractPatternOptions(t) {
1646
+ const {
1647
+ mask: e,
1648
+ pattern: s,
1649
+ ...i
1650
+ } = t;
1651
+ return {
1652
+ ...i,
1653
+ mask: A(e) ? e : s
1654
+ };
1655
+ }
1656
+ /** Pattern mask for date according to {@link MaskedDate#format} */
1657
+ /** Start date */
1658
+ /** End date */
1659
+ /** Format typed value to string */
1660
+ /** Parse string to get typed value */
1661
+ constructor(t) {
1662
+ super(E.extractPatternOptions({
1663
+ ...E.DEFAULTS,
1664
+ ...t
1665
+ }));
1666
+ }
1667
+ updateOptions(t) {
1668
+ super.updateOptions(t);
1669
+ }
1670
+ _update(t) {
1671
+ const {
1672
+ mask: e,
1673
+ pattern: s,
1674
+ blocks: i,
1675
+ ...n
1676
+ } = {
1677
+ ...E.DEFAULTS,
1678
+ ...t
1679
+ }, a = Object.assign({}, E.GET_DEFAULT_BLOCKS());
1680
+ t.min && (a.Y.from = t.min.getFullYear()), t.max && (a.Y.to = t.max.getFullYear()), t.min && t.max && a.Y.from === a.Y.to && (a.m.from = t.min.getMonth() + 1, a.m.to = t.max.getMonth() + 1, a.m.from === a.m.to && (a.d.from = t.min.getDate(), a.d.to = t.max.getDate())), Object.assign(a, this.blocks, i), super._update({
1681
+ ...n,
1682
+ mask: A(e) ? e : s,
1683
+ blocks: a
1684
+ });
1685
+ }
1686
+ doValidate(t) {
1687
+ const e = this.date;
1688
+ return super.doValidate(t) && (!this.isComplete || this.isDateExist(this.value) && e != null && (this.min == null || this.min <= e) && (this.max == null || e <= this.max));
1689
+ }
1690
+ /** Checks if date is exists */
1691
+ isDateExist(t) {
1692
+ return this.format(this.parse(t, this), this).indexOf(t) >= 0;
1693
+ }
1694
+ /** Parsed Date */
1695
+ get date() {
1696
+ return this.typedValue;
1697
+ }
1698
+ set date(t) {
1699
+ this.typedValue = t;
1700
+ }
1701
+ get typedValue() {
1702
+ return this.isComplete ? super.typedValue : null;
1703
+ }
1704
+ set typedValue(t) {
1705
+ super.typedValue = t;
1706
+ }
1707
+ maskEquals(t) {
1708
+ return t === Date || super.maskEquals(t);
1709
+ }
1710
+ optionsIsChanged(t) {
1711
+ return super.optionsIsChanged(E.extractPatternOptions(t));
1712
+ }
1713
+ }
1714
+ E.GET_DEFAULT_BLOCKS = () => ({
1715
+ d: {
1716
+ mask: S,
1717
+ from: 1,
1718
+ to: 31,
1719
+ maxLength: 2
1720
+ },
1721
+ m: {
1722
+ mask: S,
1723
+ from: 1,
1724
+ to: 12,
1725
+ maxLength: 2
1726
+ },
1727
+ Y: {
1728
+ mask: S,
1729
+ from: 1900,
1730
+ to: 9999
1731
+ }
1732
+ });
1733
+ E.DEFAULTS = {
1734
+ ...g.DEFAULTS,
1735
+ mask: Date,
1736
+ pattern: tt,
1737
+ format: (u, t) => {
1738
+ if (!u) return "";
1739
+ const e = String(u.getDate()).padStart(2, "0"), s = String(u.getMonth() + 1).padStart(2, "0"), i = u.getFullYear();
1740
+ return [e, s, i].join(".");
1741
+ },
1742
+ parse: (u, t) => {
1743
+ const [e, s, i] = u.split(".").map(Number);
1744
+ return new Date(i, s - 1, e);
1745
+ }
1746
+ };
1747
+ p.MaskedDate = E;
1748
+ class b extends k {
1749
+ constructor(t) {
1750
+ super({
1751
+ ...b.DEFAULTS,
1752
+ ...t
1753
+ }), this.currentMask = void 0;
1754
+ }
1755
+ updateOptions(t) {
1756
+ super.updateOptions(t);
1757
+ }
1758
+ _update(t) {
1759
+ super._update(t), "mask" in t && (this.exposeMask = void 0, this.compiledMasks = Array.isArray(t.mask) ? t.mask.map((e) => {
1760
+ const {
1761
+ expose: s,
1762
+ ...i
1763
+ } = x(e), n = C({
1764
+ overwrite: this._overwrite,
1765
+ eager: this._eager,
1766
+ skipInvalid: this._skipInvalid,
1767
+ ...i
1768
+ });
1769
+ return s && (this.exposeMask = n), n;
1770
+ }) : []);
1771
+ }
1772
+ _appendCharRaw(t, e) {
1773
+ e === void 0 && (e = {});
1774
+ const s = this._applyDispatch(t, e);
1775
+ return this.currentMask && s.aggregate(this.currentMask._appendChar(t, this.currentMaskFlags(e))), s;
1776
+ }
1777
+ _applyDispatch(t, e, s) {
1778
+ t === void 0 && (t = ""), e === void 0 && (e = {}), s === void 0 && (s = "");
1779
+ const i = e.tail && e._beforeTailState != null ? e._beforeTailState._value : this.value, n = this.rawInputValue, a = e.tail && e._beforeTailState != null ? e._beforeTailState._rawInputValue : n, r = n.slice(a.length), h = this.currentMask, o = new d(), c = h?.state;
1780
+ return this.currentMask = this.doDispatch(t, {
1781
+ ...e
1782
+ }, s), this.currentMask && (this.currentMask !== h ? (this.currentMask.reset(), a && (this.currentMask.append(a, {
1783
+ raw: !0
1784
+ }), o.tailShift = this.currentMask.value.length - i.length), r && (o.tailShift += this.currentMask.append(r, {
1785
+ raw: !0,
1786
+ tail: !0
1787
+ }).tailShift)) : c && (this.currentMask.state = c)), o;
1788
+ }
1789
+ _appendPlaceholder() {
1790
+ const t = this._applyDispatch();
1791
+ return this.currentMask && t.aggregate(this.currentMask._appendPlaceholder()), t;
1792
+ }
1793
+ _appendEager() {
1794
+ const t = this._applyDispatch();
1795
+ return this.currentMask && t.aggregate(this.currentMask._appendEager()), t;
1796
+ }
1797
+ appendTail(t) {
1798
+ const e = new d();
1799
+ return t && e.aggregate(this._applyDispatch("", {}, t)), e.aggregate(this.currentMask ? this.currentMask.appendTail(t) : super.appendTail(t));
1800
+ }
1801
+ currentMaskFlags(t) {
1802
+ var e, s;
1803
+ return {
1804
+ ...t,
1805
+ _beforeTailState: ((e = t._beforeTailState) == null ? void 0 : e.currentMaskRef) === this.currentMask && ((s = t._beforeTailState) == null ? void 0 : s.currentMask) || t._beforeTailState
1806
+ };
1807
+ }
1808
+ doDispatch(t, e, s) {
1809
+ return e === void 0 && (e = {}), s === void 0 && (s = ""), this.dispatch(t, this, e, s);
1810
+ }
1811
+ doValidate(t) {
1812
+ return super.doValidate(t) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(t)));
1813
+ }
1814
+ doPrepare(t, e) {
1815
+ e === void 0 && (e = {});
1816
+ let [s, i] = super.doPrepare(t, e);
1817
+ if (this.currentMask) {
1818
+ let n;
1819
+ [s, n] = super.doPrepare(s, this.currentMaskFlags(e)), i = i.aggregate(n);
1820
+ }
1821
+ return [s, i];
1822
+ }
1823
+ doPrepareChar(t, e) {
1824
+ e === void 0 && (e = {});
1825
+ let [s, i] = super.doPrepareChar(t, e);
1826
+ if (this.currentMask) {
1827
+ let n;
1828
+ [s, n] = super.doPrepareChar(s, this.currentMaskFlags(e)), i = i.aggregate(n);
1829
+ }
1830
+ return [s, i];
1831
+ }
1832
+ reset() {
1833
+ var t;
1834
+ (t = this.currentMask) == null || t.reset(), this.compiledMasks.forEach((e) => e.reset());
1835
+ }
1836
+ get value() {
1837
+ return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : "";
1838
+ }
1839
+ set value(t) {
1840
+ this.exposeMask ? (this.exposeMask.value = t, this.currentMask = this.exposeMask, this._applyDispatch()) : super.value = t;
1841
+ }
1842
+ get unmaskedValue() {
1843
+ return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : "";
1844
+ }
1845
+ set unmaskedValue(t) {
1846
+ this.exposeMask ? (this.exposeMask.unmaskedValue = t, this.currentMask = this.exposeMask, this._applyDispatch()) : super.unmaskedValue = t;
1847
+ }
1848
+ get typedValue() {
1849
+ return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : "";
1850
+ }
1851
+ set typedValue(t) {
1852
+ if (this.exposeMask) {
1853
+ this.exposeMask.typedValue = t, this.currentMask = this.exposeMask, this._applyDispatch();
1854
+ return;
1855
+ }
1856
+ let e = String(t);
1857
+ this.currentMask && (this.currentMask.typedValue = t, e = this.currentMask.unmaskedValue), this.unmaskedValue = e;
1858
+ }
1859
+ get displayValue() {
1860
+ return this.currentMask ? this.currentMask.displayValue : "";
1861
+ }
1862
+ get isComplete() {
1863
+ var t;
1864
+ return !!((t = this.currentMask) != null && t.isComplete);
1865
+ }
1866
+ get isFilled() {
1867
+ var t;
1868
+ return !!((t = this.currentMask) != null && t.isFilled);
1869
+ }
1870
+ remove(t, e) {
1871
+ const s = new d();
1872
+ return this.currentMask && s.aggregate(this.currentMask.remove(t, e)).aggregate(this._applyDispatch()), s;
1873
+ }
1874
+ get state() {
1875
+ var t;
1876
+ return {
1877
+ ...super.state,
1878
+ _rawInputValue: this.rawInputValue,
1879
+ compiledMasks: this.compiledMasks.map((e) => e.state),
1880
+ currentMaskRef: this.currentMask,
1881
+ currentMask: (t = this.currentMask) == null ? void 0 : t.state
1882
+ };
1883
+ }
1884
+ set state(t) {
1885
+ const {
1886
+ compiledMasks: e,
1887
+ currentMaskRef: s,
1888
+ currentMask: i,
1889
+ ...n
1890
+ } = t;
1891
+ e && this.compiledMasks.forEach((a, r) => a.state = e[r]), s != null && (this.currentMask = s, this.currentMask.state = i), super.state = n;
1892
+ }
1893
+ extractInput(t, e, s) {
1894
+ return this.currentMask ? this.currentMask.extractInput(t, e, s) : "";
1895
+ }
1896
+ extractTail(t, e) {
1897
+ return this.currentMask ? this.currentMask.extractTail(t, e) : super.extractTail(t, e);
1898
+ }
1899
+ doCommit() {
1900
+ this.currentMask && this.currentMask.doCommit(), super.doCommit();
1901
+ }
1902
+ nearestInputPos(t, e) {
1903
+ return this.currentMask ? this.currentMask.nearestInputPos(t, e) : super.nearestInputPos(t, e);
1904
+ }
1905
+ get overwrite() {
1906
+ return this.currentMask ? this.currentMask.overwrite : this._overwrite;
1907
+ }
1908
+ set overwrite(t) {
1909
+ this._overwrite = t;
1910
+ }
1911
+ get eager() {
1912
+ return this.currentMask ? this.currentMask.eager : this._eager;
1913
+ }
1914
+ set eager(t) {
1915
+ this._eager = t;
1916
+ }
1917
+ get skipInvalid() {
1918
+ return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
1919
+ }
1920
+ set skipInvalid(t) {
1921
+ this._skipInvalid = t;
1922
+ }
1923
+ get autofix() {
1924
+ return this.currentMask ? this.currentMask.autofix : this._autofix;
1925
+ }
1926
+ set autofix(t) {
1927
+ this._autofix = t;
1928
+ }
1929
+ maskEquals(t) {
1930
+ return Array.isArray(t) ? this.compiledMasks.every((e, s) => {
1931
+ if (!t[s]) return;
1932
+ const {
1933
+ mask: i,
1934
+ ...n
1935
+ } = t[s];
1936
+ return I(e, n) && e.maskEquals(i);
1937
+ }) : super.maskEquals(t);
1938
+ }
1939
+ typedValueEquals(t) {
1940
+ var e;
1941
+ return !!((e = this.currentMask) != null && e.typedValueEquals(t));
1942
+ }
1943
+ }
1944
+ b.DEFAULTS = {
1945
+ ...k.DEFAULTS,
1946
+ dispatch: (u, t, e, s) => {
1947
+ if (!t.compiledMasks.length) return;
1948
+ const i = t.rawInputValue, n = t.compiledMasks.map((a, r) => {
1949
+ const h = t.currentMask === a, o = h ? a.displayValue.length : a.nearestInputPos(a.displayValue.length, l.FORCE_LEFT);
1950
+ return a.rawInputValue !== i ? (a.reset(), a.append(i, {
1951
+ raw: !0
1952
+ })) : h || a.remove(o), a.append(u, t.currentMaskFlags(e)), a.appendTail(s), {
1953
+ index: r,
1954
+ weight: a.rawInputValue.length,
1955
+ totalInputPositions: a.totalInputPositions(0, Math.max(o, a.nearestInputPos(a.displayValue.length, l.FORCE_LEFT)))
1956
+ };
1957
+ });
1958
+ return n.sort((a, r) => r.weight - a.weight || r.totalInputPositions - a.totalInputPositions), t.compiledMasks[n[0].index];
1959
+ }
1960
+ };
1961
+ p.MaskedDynamic = b;
1962
+ class w extends g {
1963
+ constructor(t) {
1964
+ super({
1965
+ ...w.DEFAULTS,
1966
+ ...t
1967
+ });
1968
+ }
1969
+ updateOptions(t) {
1970
+ super.updateOptions(t);
1971
+ }
1972
+ _update(t) {
1973
+ const {
1974
+ enum: e,
1975
+ ...s
1976
+ } = t;
1977
+ if (e) {
1978
+ const i = e.map((r) => r.length), n = Math.min(...i), a = Math.max(...i) - n;
1979
+ s.mask = "*".repeat(n), a && (s.mask += "[" + "*".repeat(a) + "]"), this.enum = e;
1980
+ }
1981
+ super._update(s);
1982
+ }
1983
+ _appendCharRaw(t, e) {
1984
+ e === void 0 && (e = {});
1985
+ const s = Math.min(this.nearestInputPos(0, l.FORCE_RIGHT), this.value.length), i = this.enum.filter((n) => this.matchValue(n, this.unmaskedValue + t, s));
1986
+ if (i.length) {
1987
+ i.length === 1 && this._forEachBlocksInRange(0, this.value.length, (a, r) => {
1988
+ const h = i[0][r];
1989
+ r >= this.value.length || h === a.value || (a.reset(), a._appendChar(h, e));
1990
+ });
1991
+ const n = super._appendCharRaw(i[0][this.value.length], e);
1992
+ return i.length === 1 && i[0].slice(this.unmaskedValue.length).split("").forEach((a) => n.aggregate(super._appendCharRaw(a))), n;
1993
+ }
1994
+ return new d({
1995
+ skip: !this.isComplete
1996
+ });
1997
+ }
1998
+ extractTail(t, e) {
1999
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), new v("", t);
2000
+ }
2001
+ remove(t, e) {
2002
+ if (t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), t === e) return new d();
2003
+ const s = Math.min(super.nearestInputPos(0, l.FORCE_RIGHT), this.value.length);
2004
+ let i;
2005
+ for (i = t; i >= 0 && !(this.enum.filter((r) => this.matchValue(r, this.value.slice(s, i), s)).length > 1); --i)
2006
+ ;
2007
+ const n = super.remove(i, e);
2008
+ return n.tailShift += i - t, n;
2009
+ }
2010
+ get isComplete() {
2011
+ return this.enum.indexOf(this.value) >= 0;
2012
+ }
2013
+ }
2014
+ w.DEFAULTS = {
2015
+ ...g.DEFAULTS,
2016
+ matchValue: (u, t, e) => u.indexOf(t, e) === e
2017
+ };
2018
+ p.MaskedEnum = w;
2019
+ class et extends k {
2020
+ /** */
2021
+ /** Enable characters overwriting */
2022
+ /** */
2023
+ /** */
2024
+ /** */
2025
+ updateOptions(t) {
2026
+ super.updateOptions(t);
2027
+ }
2028
+ _update(t) {
2029
+ super._update({
2030
+ ...t,
2031
+ validate: t.mask
2032
+ });
2033
+ }
2034
+ }
2035
+ p.MaskedFunction = et;
2036
+ var z;
2037
+ class m extends k {
2038
+ /** Single char */
2039
+ /** Single char */
2040
+ /** Array of single chars */
2041
+ /** */
2042
+ /** */
2043
+ /** Digits after point */
2044
+ /** Flag to remove leading and trailing zeros in the end of editing */
2045
+ /** Flag to pad trailing zeros after point in the end of editing */
2046
+ /** Enable characters overwriting */
2047
+ /** */
2048
+ /** */
2049
+ /** */
2050
+ /** Format typed value to string */
2051
+ /** Parse string to get typed value */
2052
+ constructor(t) {
2053
+ super({
2054
+ ...m.DEFAULTS,
2055
+ ...t
2056
+ });
2057
+ }
2058
+ updateOptions(t) {
2059
+ super.updateOptions(t);
2060
+ }
2061
+ _update(t) {
2062
+ super._update(t), this._updateRegExps();
2063
+ }
2064
+ _updateRegExps() {
2065
+ const t = "^" + (this.allowNegative ? "[+|\\-]?" : ""), e = "\\d*", s = (this.scale ? "(" + T(this.radix) + "\\d{0," + this.scale + "})?" : "") + "$";
2066
+ this._numberRegExp = new RegExp(t + e + s), this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(T).join("") + "]", "g"), this._thousandsSeparatorRegExp = new RegExp(T(this.thousandsSeparator), "g");
2067
+ }
2068
+ _removeThousandsSeparators(t) {
2069
+ return t.replace(this._thousandsSeparatorRegExp, "");
2070
+ }
2071
+ _insertThousandsSeparators(t) {
2072
+ const e = t.split(this.radix);
2073
+ return e[0] = e[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator), e.join(this.radix);
2074
+ }
2075
+ doPrepareChar(t, e) {
2076
+ e === void 0 && (e = {});
2077
+ const [s, i] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && /*
2078
+ radix should be mapped when
2079
+ 1) input is done from keyboard = flags.input && flags.raw
2080
+ 2) unmasked value is set = !flags.input && !flags.raw
2081
+ and should not be mapped when
2082
+ 1) value is set = flags.input && !flags.raw
2083
+ 2) raw value is set = !flags.input && flags.raw
2084
+ */
2085
+ (e.input && e.raw || !e.input && !e.raw) ? t.replace(this._mapToRadixRegExp, this.radix) : t), e);
2086
+ return t && !s && (i.skip = !0), s && !this.allowPositive && !this.value && s !== "-" && i.aggregate(this._appendChar("-")), [s, i];
2087
+ }
2088
+ _separatorsCount(t, e) {
2089
+ e === void 0 && (e = !1);
2090
+ let s = 0;
2091
+ for (let i = 0; i < t; ++i)
2092
+ this._value.indexOf(this.thousandsSeparator, i) === i && (++s, e && (t += this.thousandsSeparator.length));
2093
+ return s;
2094
+ }
2095
+ _separatorsCountFromSlice(t) {
2096
+ return t === void 0 && (t = this._value), this._separatorsCount(this._removeThousandsSeparators(t).length, !0);
2097
+ }
2098
+ extractInput(t, e, s) {
2099
+ return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), [t, e] = this._adjustRangeWithSeparators(t, e), this._removeThousandsSeparators(super.extractInput(t, e, s));
2100
+ }
2101
+ _appendCharRaw(t, e) {
2102
+ e === void 0 && (e = {});
2103
+ const s = e.tail && e._beforeTailState ? e._beforeTailState._value : this._value, i = this._separatorsCountFromSlice(s);
2104
+ this._value = this._removeThousandsSeparators(this.value);
2105
+ const n = this._value;
2106
+ this._value += t;
2107
+ const a = this.number;
2108
+ let r = !isNaN(a), h = !1;
2109
+ if (r) {
2110
+ let _;
2111
+ this.min != null && this.min < 0 && this.number < this.min && (_ = this.min), this.max != null && this.max > 0 && this.number > this.max && (_ = this.max), _ != null && (this.autofix ? (this._value = this.format(_, this).replace(m.UNMASKED_RADIX, this.radix), h || (h = n === this._value && !e.tail)) : r = !1), r && (r = !!this._value.match(this._numberRegExp));
2112
+ }
2113
+ let o;
2114
+ r ? o = new d({
2115
+ inserted: this._value.slice(n.length),
2116
+ rawInserted: h ? "" : t,
2117
+ skip: h
2118
+ }) : (this._value = n, o = new d()), this._value = this._insertThousandsSeparators(this._value);
2119
+ const c = e.tail && e._beforeTailState ? e._beforeTailState._value : this._value, f = this._separatorsCountFromSlice(c);
2120
+ return o.tailShift += (f - i) * this.thousandsSeparator.length, o;
2121
+ }
2122
+ _findSeparatorAround(t) {
2123
+ if (this.thousandsSeparator) {
2124
+ const e = t - this.thousandsSeparator.length + 1, s = this.value.indexOf(this.thousandsSeparator, e);
2125
+ if (s <= t) return s;
2126
+ }
2127
+ return -1;
2128
+ }
2129
+ _adjustRangeWithSeparators(t, e) {
2130
+ const s = this._findSeparatorAround(t);
2131
+ s >= 0 && (t = s);
2132
+ const i = this._findSeparatorAround(e);
2133
+ return i >= 0 && (e = i + this.thousandsSeparator.length), [t, e];
2134
+ }
2135
+ remove(t, e) {
2136
+ t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), [t, e] = this._adjustRangeWithSeparators(t, e);
2137
+ const s = this.value.slice(0, t), i = this.value.slice(e), n = this._separatorsCount(s.length);
2138
+ this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(s + i));
2139
+ const a = this._separatorsCountFromSlice(s);
2140
+ return new d({
2141
+ tailShift: (a - n) * this.thousandsSeparator.length
2142
+ });
2143
+ }
2144
+ nearestInputPos(t, e) {
2145
+ if (!this.thousandsSeparator) return t;
2146
+ switch (e) {
2147
+ case l.NONE:
2148
+ case l.LEFT:
2149
+ case l.FORCE_LEFT: {
2150
+ const s = this._findSeparatorAround(t - 1);
2151
+ if (s >= 0) {
2152
+ const i = s + this.thousandsSeparator.length;
2153
+ if (t < i || this.value.length <= i || e === l.FORCE_LEFT)
2154
+ return s;
2155
+ }
2156
+ break;
2157
+ }
2158
+ case l.RIGHT:
2159
+ case l.FORCE_RIGHT: {
2160
+ const s = this._findSeparatorAround(t);
2161
+ if (s >= 0)
2162
+ return s + this.thousandsSeparator.length;
2163
+ }
2164
+ }
2165
+ return t;
2166
+ }
2167
+ doCommit() {
2168
+ if (this.value) {
2169
+ const t = this.number;
2170
+ let e = t;
2171
+ this.min != null && (e = Math.max(e, this.min)), this.max != null && (e = Math.min(e, this.max)), e !== t && (this.unmaskedValue = this.format(e, this));
2172
+ let s = this.value;
2173
+ this.normalizeZeros && (s = this._normalizeZeros(s)), this.padFractionalZeros && this.scale > 0 && (s = this._padFractionalZeros(s)), this._value = s;
2174
+ }
2175
+ super.doCommit();
2176
+ }
2177
+ _normalizeZeros(t) {
2178
+ const e = this._removeThousandsSeparators(t).split(this.radix);
2179
+ return e[0] = e[0].replace(/^(\D*)(0*)(\d*)/, (s, i, n, a) => i + a), t.length && !/\d$/.test(e[0]) && (e[0] = e[0] + "0"), e.length > 1 && (e[1] = e[1].replace(/0*$/, ""), e[1].length || (e.length = 1)), this._insertThousandsSeparators(e.join(this.radix));
2180
+ }
2181
+ _padFractionalZeros(t) {
2182
+ if (!t) return t;
2183
+ const e = t.split(this.radix);
2184
+ return e.length < 2 && e.push(""), e[1] = e[1].padEnd(this.scale, "0"), e.join(this.radix);
2185
+ }
2186
+ doSkipInvalid(t, e, s) {
2187
+ e === void 0 && (e = {});
2188
+ const i = this.scale === 0 && t !== this.thousandsSeparator && (t === this.radix || t === m.UNMASKED_RADIX || this.mapToRadix.includes(t));
2189
+ return super.doSkipInvalid(t, e, s) && !i;
2190
+ }
2191
+ get unmaskedValue() {
2192
+ return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, m.UNMASKED_RADIX);
2193
+ }
2194
+ set unmaskedValue(t) {
2195
+ super.unmaskedValue = t;
2196
+ }
2197
+ get typedValue() {
2198
+ return this.parse(this.unmaskedValue, this);
2199
+ }
2200
+ set typedValue(t) {
2201
+ this.rawInputValue = this.format(t, this).replace(m.UNMASKED_RADIX, this.radix);
2202
+ }
2203
+ /** Parsed Number */
2204
+ get number() {
2205
+ return this.typedValue;
2206
+ }
2207
+ set number(t) {
2208
+ this.typedValue = t;
2209
+ }
2210
+ get allowNegative() {
2211
+ return this.min != null && this.min < 0 || this.max != null && this.max < 0;
2212
+ }
2213
+ get allowPositive() {
2214
+ return this.min != null && this.min > 0 || this.max != null && this.max > 0;
2215
+ }
2216
+ typedValueEquals(t) {
2217
+ return (super.typedValueEquals(t) || m.EMPTY_VALUES.includes(t) && m.EMPTY_VALUES.includes(this.typedValue)) && !(t === 0 && this.value === "");
2218
+ }
2219
+ }
2220
+ z = m;
2221
+ m.UNMASKED_RADIX = ".";
2222
+ m.EMPTY_VALUES = [...k.EMPTY_VALUES, 0];
2223
+ m.DEFAULTS = {
2224
+ ...k.DEFAULTS,
2225
+ mask: Number,
2226
+ radix: ",",
2227
+ thousandsSeparator: "",
2228
+ mapToRadix: [z.UNMASKED_RADIX],
2229
+ min: Number.MIN_SAFE_INTEGER,
2230
+ max: Number.MAX_SAFE_INTEGER,
2231
+ scale: 2,
2232
+ normalizeZeros: !0,
2233
+ padFractionalZeros: !1,
2234
+ parse: Number,
2235
+ format: (u) => u.toLocaleString("en-US", {
2236
+ useGrouping: !1,
2237
+ maximumFractionDigits: 20
2238
+ })
2239
+ };
2240
+ p.MaskedNumber = m;
2241
+ const R = {
2242
+ MASKED: "value",
2243
+ UNMASKED: "unmaskedValue",
2244
+ TYPED: "typedValue"
2245
+ };
2246
+ function K(u, t, e) {
2247
+ t === void 0 && (t = R.MASKED), e === void 0 && (e = R.MASKED);
2248
+ const s = C(u);
2249
+ return (i) => s.runIsolated((n) => (n[t] = i, n[e]));
2250
+ }
2251
+ function st(u, t, e, s) {
2252
+ return K(t, e, s)(u);
2253
+ }
2254
+ p.PIPE_TYPE = R;
2255
+ p.createPipe = K;
2256
+ p.pipe = st;
2257
+ class it extends g {
2258
+ get repeatFrom() {
2259
+ var t;
2260
+ return (t = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === 1 / 0 ? 0 : this.repeat) != null ? t : 0;
2261
+ }
2262
+ get repeatTo() {
2263
+ var t;
2264
+ return (t = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? t : 1 / 0;
2265
+ }
2266
+ constructor(t) {
2267
+ super(t);
2268
+ }
2269
+ updateOptions(t) {
2270
+ super.updateOptions(t);
2271
+ }
2272
+ _update(t) {
2273
+ var e, s, i;
2274
+ const {
2275
+ repeat: n,
2276
+ ...a
2277
+ } = x(t);
2278
+ this._blockOpts = Object.assign({}, this._blockOpts, a);
2279
+ const r = C(this._blockOpts);
2280
+ this.repeat = (e = (s = n ?? r.repeat) != null ? s : this.repeat) != null ? e : 1 / 0, super._update({
2281
+ mask: "m".repeat(Math.max(this.repeatTo === 1 / 0 && ((i = this._blocks) == null ? void 0 : i.length) || 0, this.repeatFrom)),
2282
+ blocks: {
2283
+ m: r
2284
+ },
2285
+ eager: r.eager,
2286
+ overwrite: r.overwrite,
2287
+ skipInvalid: r.skipInvalid,
2288
+ lazy: r.lazy,
2289
+ placeholderChar: r.placeholderChar,
2290
+ displayChar: r.displayChar
2291
+ });
2292
+ }
2293
+ _allocateBlock(t) {
2294
+ if (t < this._blocks.length) return this._blocks[t];
2295
+ if (this.repeatTo === 1 / 0 || this._blocks.length < this.repeatTo)
2296
+ return this._blocks.push(C(this._blockOpts)), this.mask += "m", this._blocks[this._blocks.length - 1];
2297
+ }
2298
+ _appendCharRaw(t, e) {
2299
+ e === void 0 && (e = {});
2300
+ const s = new d();
2301
+ for (
2302
+ let h = (i = (n = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : n.index) != null ? i : Math.max(this._blocks.length - 1, 0), o, c;
2303
+ // try to get a block or
2304
+ // try to allocate a new block if not allocated already
2305
+ o = (a = this._blocks[h]) != null ? a : c = !c && this._allocateBlock(h);
2306
+ ++h
2307
+ ) {
2308
+ var i, n, a, r;
2309
+ const f = o._appendChar(t, {
2310
+ ...e,
2311
+ _beforeTailState: (r = e._beforeTailState) == null || (r = r._blocks) == null ? void 0 : r[h]
2312
+ });
2313
+ if (f.skip && c) {
2314
+ this._blocks.pop(), this.mask = this.mask.slice(1);
2315
+ break;
2316
+ }
2317
+ if (s.aggregate(f), f.consumed) break;
2318
+ }
2319
+ return s;
2320
+ }
2321
+ _trimEmptyTail(t, e) {
2322
+ var s, i;
2323
+ t === void 0 && (t = 0);
2324
+ const n = Math.max(((s = this._mapPosToBlock(t)) == null ? void 0 : s.index) || 0, this.repeatFrom, 0);
2325
+ let a;
2326
+ e != null && (a = (i = this._mapPosToBlock(e)) == null ? void 0 : i.index), a == null && (a = this._blocks.length - 1);
2327
+ let r = 0;
2328
+ for (let h = a; n <= h && !this._blocks[h].unmaskedValue; --h, ++r)
2329
+ ;
2330
+ r && (this._blocks.splice(a - r + 1, r), this.mask = this.mask.slice(r));
2331
+ }
2332
+ reset() {
2333
+ super.reset(), this._trimEmptyTail();
2334
+ }
2335
+ remove(t, e) {
2336
+ t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
2337
+ const s = super.remove(t, e);
2338
+ return this._trimEmptyTail(t, e), s;
2339
+ }
2340
+ totalInputPositions(t, e) {
2341
+ return t === void 0 && (t = 0), e == null && this.repeatTo === 1 / 0 ? 1 / 0 : super.totalInputPositions(t, e);
2342
+ }
2343
+ get state() {
2344
+ return super.state;
2345
+ }
2346
+ set state(t) {
2347
+ this._blocks.length = t._blocks.length, this.mask = this.mask.slice(0, this._blocks.length), super.state = t;
2348
+ }
2349
+ }
2350
+ p.RepeatBlock = it;
2351
+ try {
2352
+ globalThis.IMask = p;
2353
+ } catch {
2354
+ }
2355
+ export {
2356
+ d as ChangeDetails,
2357
+ F as ChunksTailDetails,
2358
+ l as DIRECTION,
2359
+ j as HTMLContenteditableMaskElement,
2360
+ X as HTMLInputMaskElement,
2361
+ V as HTMLMaskElement,
2362
+ W as InputMask,
2363
+ O as MaskElement,
2364
+ k as Masked,
2365
+ E as MaskedDate,
2366
+ b as MaskedDynamic,
2367
+ w as MaskedEnum,
2368
+ et as MaskedFunction,
2369
+ m as MaskedNumber,
2370
+ g as MaskedPattern,
2371
+ S as MaskedRange,
2372
+ Q as MaskedRegExp,
2373
+ R as PIPE_TYPE,
2374
+ G as PatternFixedDefinition,
2375
+ D as PatternInputDefinition,
2376
+ it as RepeatBlock,
2377
+ C as createMask,
2378
+ K as createPipe,
2379
+ p as default,
2380
+ Y as forceDirection,
2381
+ x as normalizeOpts,
2382
+ st as pipe
2383
+ };