@7pmlabs/design-system 0.5.8 → 0.5.10

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