numora 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,31 +1,29 @@
1
- var Q = Object.defineProperty;
2
- var X = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var w = (e, t, n) => X(e, typeof t != "symbol" ? t + "" : t, n);
4
- var v = /* @__PURE__ */ ((e) => (e.Blur = "blur", e.Change = "change", e))(v || {}), b = /* @__PURE__ */ ((e) => (e.None = "none", e.Thousand = "thousand", e.Lakh = "lakh", e.Wan = "wan", e))(b || {});
5
- const I = 2, R = 0, O = v.Blur, _ = ",", P = b.None, E = ".", B = !1, W = !1, k = !1, Z = !1;
1
+ var K = Object.defineProperty;
2
+ var Q = (e, t, n) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var L = (e, t, n) => Q(e, typeof t != "symbol" ? t + "" : t, n);
4
+ var v = /* @__PURE__ */ ((e) => (e.Blur = "blur", e.Change = "change", e))(v || {}), S = /* @__PURE__ */ ((e) => (e.None = "none", e.Thousand = "thousand", e.Lakh = "lakh", e.Wan = "wan", e))(S || {});
5
+ const I = 2, R = 0, O = v.Blur, _ = ",", B = S.None, E = ".", X = !1, P = !1, W = !1, k = !1;
6
6
  function D(e) {
7
7
  return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
8
8
  }
9
- function y(e) {
9
+ function A(e) {
10
10
  return {
11
11
  decimalSeparator: (e == null ? void 0 : e.decimalSeparator) ?? E,
12
12
  thousandSeparator: e == null ? void 0 : e.thousandSeparator
13
13
  };
14
14
  }
15
15
  function Y(e, t) {
16
- if (e.key !== t)
17
- return !1;
18
16
  const n = e.target;
19
17
  return n ? n.value.includes(t) : !1;
20
18
  }
21
19
  function V(e, t, n, r) {
22
- const { selectionStart: i, selectionEnd: a, value: s } = t, { key: o } = e, c = n == null ? void 0 : n.ThousandStyle;
23
- if (c !== b.None && c !== void 0 || o !== "," && o !== ".")
20
+ const { selectionStart: i, selectionEnd: o, value: s } = t, { key: a } = e, c = n == null ? void 0 : n.ThousandStyle;
21
+ if (c !== S.None && c !== void 0 || a !== "," && a !== ".")
24
22
  return !1;
25
23
  if (Y(e, r))
26
24
  return !0;
27
- if (o !== r) {
28
- const l = i ?? 0, h = a ?? l, d = s.slice(0, l) + r + s.slice(h);
25
+ if (a !== r) {
26
+ const l = i ?? 0, h = o ?? l, d = s.slice(0, l) + r + s.slice(h);
29
27
  t.value = d;
30
28
  const u = l + 1;
31
29
  return t.setSelectionRange(u, u), !0;
@@ -43,273 +41,105 @@ const F = (e, t, n = E) => {
43
41
  return e;
44
42
  if (!e || e === "0" || e === n || e === "-" || e === `-${n}`)
45
43
  return e === "-" || e === `-${n}` ? `-${n}${"0".repeat(t)}` : e === n ? `${n}${"0".repeat(t)}` : `${e}${n}${"0".repeat(t)}`;
46
- const r = e.includes(n), i = e.startsWith("-"), a = i ? e.slice(1) : e, [s, o = ""] = a.split(n);
44
+ const r = e.includes(n), i = e.startsWith("-"), o = i ? e.slice(1) : e, [s, a = ""] = o.split(n);
47
45
  if (!r) {
48
46
  const c = "0".repeat(t);
49
47
  return i ? `-${s}${n}${c}` : `${s}${n}${c}`;
50
48
  }
51
- if (o.length < t) {
52
- const c = t - o.length, l = o + "0".repeat(c);
49
+ if (a.length < t) {
50
+ const c = t - a.length, l = a + "0".repeat(c);
53
51
  return i ? `-${s}${n}${l}` : `${s}${n}${l}`;
54
52
  }
55
53
  return e;
56
- }, ne = (e, t = !1, n = ".") => {
57
- const r = D(n), i = new RegExp(`[^0-9${r}]`, "g");
58
- if (!t)
59
- return e.replace(i, "");
60
- const a = e.startsWith("-"), s = e.replace(i, "");
61
- if (a) {
62
- if (s.length > 0)
63
- return "-" + s;
64
- if (e === "-")
65
- return "-";
66
- }
67
- return s;
68
- };
69
- function re(e) {
70
- const t = /([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g;
71
- let n = e, r;
72
- const i = [];
73
- for (; (r = t.exec(e)) !== null; ) {
74
- const a = r[0], s = r[1], o = parseInt(r[2], 10);
75
- let c;
76
- if (o === 0)
77
- c = s;
78
- else {
79
- const l = s.startsWith("-"), h = l ? s.slice(1) : s, [d, u = ""] = h.split(".");
80
- o > 0 ? c = se(d, u, o) : c = ie(d, u, Math.abs(o)), l && (c = "-" + c);
81
- }
82
- i.push({ full: a, expanded: c });
83
- }
84
- for (const { full: a, expanded: s } of i)
85
- n = n.replace(a, s);
86
- return n;
87
- }
88
- function se(e, t, n) {
89
- const r = e + t;
90
- if (r === "0" || r.match(/^0+$/))
91
- return "0";
92
- const i = t.length;
93
- if (n <= i) {
94
- const s = r.slice(0, e.length + n), o = r.slice(e.length + n);
95
- return o ? `${s}.${o}` : s;
96
- }
97
- const a = n - i;
98
- return r + "0".repeat(a);
99
- }
100
- function ie(e, t, n) {
101
- const r = e + t;
102
- if (r === "0" || r.match(/^0+$/))
103
- return "0";
104
- const s = e.length - n;
105
- if (s <= 0) {
106
- const o = Math.abs(s), c = `0.${"0".repeat(o)}${r}`;
107
- return A(c);
108
- }
109
- if (s < e.length) {
110
- const o = r.slice(0, s), c = r.slice(s), l = `${o}.${c}`;
111
- return A(l);
112
- }
113
- return A(r);
114
- }
115
- function A(e) {
116
- if (!e.includes("."))
117
- return e;
118
- if (e === "0" || e === "0.")
119
- return "0";
120
- if (e.startsWith("0.")) {
121
- const t = e.replace(/\.?0+$/, "");
122
- return t === "0" ? "0" : t || "0";
123
- }
124
- if (e.startsWith("-0.")) {
125
- const t = e.replace(/\.?0+$/, "");
126
- return t === "-0" || t === "0" ? "0" : t || "0";
127
- }
128
- return e.replace(/\.?0+$/, "") || e;
129
- }
130
- function ae(e) {
131
- const t = /(\d+\.?\d*)\s*(Qa|Qi|Sx|Sp|[kmbMTO]|N)/gi;
132
- return e.replace(t, (n, r, i) => {
133
- const a = {
134
- k: 3,
135
- // Thousand
136
- m: 6,
137
- // Million (lowercase)
138
- M: 6,
139
- // Million (uppercase)
140
- b: 9,
141
- // Billion
142
- T: 12,
143
- // Trillion
144
- Qa: 15,
145
- // Quadrillion
146
- Qi: 18,
147
- // Quintillion
148
- Sx: 21,
149
- // Sextillion
150
- Sp: 24,
151
- // Septillion
152
- O: 27,
153
- // Octillion
154
- N: 30
155
- // Nonillion
156
- };
157
- let s;
158
- if (i.length > 1)
159
- s = a[i] || a[i.charAt(0).toUpperCase() + i.slice(1).toLowerCase()];
160
- else {
161
- const f = i.toLowerCase();
162
- s = a[i] || a[f];
163
- }
164
- if (!s)
165
- return n;
166
- const o = r.startsWith("-"), c = o ? r.slice(1) : r, [l, h = ""] = c.split("."), d = l.replace(/^0+/, "") || "0";
167
- let u;
168
- if (h.length === 0)
169
- u = d + "0".repeat(s);
170
- else if (h.length <= s) {
171
- const f = s - h.length;
172
- u = d + h + "0".repeat(f);
173
- } else {
174
- const f = h.slice(0, s), g = h.slice(s);
175
- u = d + f + "." + g;
176
- }
177
- return u = u.replace(/^(-?)0+([1-9])/, "$1$2"), u.match(/^-?0+$/) && (u = o ? "-0" : "0"), u = u.replace(/\.?0+$/, ""), o && !u.startsWith("-") ? "-" + u : u;
178
- });
179
- }
180
- function oe(e) {
181
- if (!e || e === "0" || e === "-0" || e === "-" || e === ".")
182
- return e;
183
- const t = e.startsWith("-"), n = t ? e.slice(1) : e;
184
- if (!n || n === "0" || n === ".")
185
- return e;
186
- if (n.includes(".")) {
187
- const [i, a] = n.split(".");
188
- if (i && i.length > 0) {
189
- const o = (i.replace(/^0+/, "") || "0") + "." + a;
190
- return t ? "-" + o : o;
191
- }
192
- return e;
193
- }
194
- if (n.startsWith("0") && n.length > 1) {
195
- const i = n.replace(/^0+/, "") || "0";
196
- return t ? "-" + i : i;
197
- }
198
- return e;
199
- }
200
- function ce(e) {
201
- return e.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g, " ").replace(/\s/g, "");
202
- }
203
- function L(e, t) {
204
- const n = D(t);
205
- return e.replace(new RegExp(n, "g"), "");
206
- }
207
- const le = (e, t) => {
208
- let n = ce(e);
209
- return t != null && t.thousandSeparator && (n = L(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n = ae(n)), n = re(n), n = ne(
210
- n,
211
- t == null ? void 0 : t.enableNegative,
212
- t == null ? void 0 : t.decimalSeparator
213
- ), n = ee(n, (t == null ? void 0 : t.decimalSeparator) || E), t != null && t.enableLeadingZeros || (n = oe(n)), n;
214
- };
215
- function he(e, t, n) {
216
- return {
217
- enableCompactNotation: e == null ? void 0 : e.enableCompactNotation,
218
- enableNegative: e == null ? void 0 : e.enableNegative,
219
- enableLeadingZeros: e == null ? void 0 : e.enableLeadingZeros,
220
- decimalSeparator: t.decimalSeparator,
221
- thousandSeparator: n ? t.thousandSeparator : void 0
222
- };
223
- }
224
- const N = {
54
+ }, N = {
225
55
  thousand: { size: 3 },
226
56
  lakh: { firstGroup: 3, restGroup: 2 },
227
57
  wan: { size: 4 }
228
58
  };
229
- function z(e, t, n, r = !1, i = ".") {
59
+ function G(e, t, n, r = !1, i = ".") {
230
60
  if (!e || e === "0" || e === i || e === "-" || e === `-${i}`)
231
61
  return e;
232
- const a = e.includes(i), s = e.startsWith("-"), o = s ? e.slice(1) : e, [c, l] = o.split(i);
62
+ const o = e.includes(i), s = e.startsWith("-"), a = s ? e.slice(1) : e, [c, l] = a.split(i);
233
63
  if (!c) {
234
- const u = l ? `${i}${l}` : o;
64
+ const u = l ? `${i}${l}` : a;
235
65
  return s ? `-${u}` : u;
236
66
  }
237
67
  if (r && c.startsWith("0") && c.length > 1) {
238
68
  const u = c.match(/^(0+)/);
239
69
  if (u) {
240
- const f = u[1], g = c.slice(f.length);
241
- if (g) {
242
- const p = G(g, t, n), $ = f + p, M = s ? "-" : "";
243
- return a ? l ? `${M}${$}${i}${l}` : `${M}${$}${i}` : `${M}${$}`;
70
+ const g = u[1], f = c.slice(g.length);
71
+ if (f) {
72
+ const p = Z(f, t, n), $ = g + p, m = s ? "-" : "";
73
+ return o ? l ? `${m}${$}${i}${l}` : `${m}${$}${i}` : `${m}${$}`;
244
74
  }
245
75
  }
246
76
  }
247
- const h = G(c, t, n), d = s ? "-" : "";
248
- return a ? l ? `${d}${h}${i}${l}` : `${d}${h}${i}` : `${d}${h}`;
77
+ const h = Z(c, t, n), d = s ? "-" : "";
78
+ return o ? l ? `${d}${h}${i}${l}` : `${d}${h}${i}` : `${d}${h}`;
249
79
  }
250
- function G(e, t, n) {
80
+ function Z(e, t, n) {
251
81
  if (e === "0" || e === "")
252
82
  return e;
253
83
  switch (n) {
254
- case b.None:
84
+ case S.None:
255
85
  return e;
256
- case b.Thousand:
257
- return ue(e, t);
258
- case b.Lakh:
259
- return de(e, t);
260
- case b.Wan:
261
- return fe(e, t);
86
+ case S.Thousand:
87
+ return ne(e, t);
88
+ case S.Lakh:
89
+ return re(e, t);
90
+ case S.Wan:
91
+ return se(e, t);
262
92
  default:
263
93
  return e;
264
94
  }
265
95
  }
266
- function ue(e, t) {
267
- return j(e, t, N.thousand.size);
96
+ function ne(e, t) {
97
+ return U(e, t, N.thousand.size);
268
98
  }
269
- function de(e, t) {
99
+ function re(e, t) {
270
100
  if (e.length <= N.lakh.firstGroup)
271
101
  return e;
272
102
  const n = e.split("").reverse(), r = [], i = n.slice(0, N.lakh.firstGroup).reverse().join("");
273
103
  r.push(i);
274
- for (let a = N.lakh.firstGroup; a < n.length; a += N.lakh.restGroup)
275
- r.push(n.slice(a, a + N.lakh.restGroup).reverse().join(""));
104
+ for (let o = N.lakh.firstGroup; o < n.length; o += N.lakh.restGroup)
105
+ r.push(n.slice(o, o + N.lakh.restGroup).reverse().join(""));
276
106
  return r.reverse().join(t);
277
107
  }
278
- function fe(e, t) {
279
- return j(e, t, N.wan.size);
108
+ function se(e, t) {
109
+ return U(e, t, N.wan.size);
280
110
  }
281
- function j(e, t, n) {
111
+ function U(e, t, n) {
282
112
  const r = e.split("").reverse(), i = [];
283
- for (let a = 0; a < r.length; a += n)
284
- i.push(r.slice(a, a + n).reverse().join(""));
113
+ for (let o = 0; o < r.length; o += n)
114
+ i.push(r.slice(o, o + n).reverse().join(""));
285
115
  return i.reverse().join(t);
286
116
  }
287
- function ge(e, t, n) {
288
- return (t == null ? void 0 : t.formatOn) === "change" && t.thousandSeparator ? z(
117
+ function ie(e, t, n) {
118
+ return (t == null ? void 0 : t.formatOn) === "change" && t.thousandSeparator ? G(
289
119
  e,
290
120
  t.thousandSeparator,
291
- t.ThousandStyle ?? b.None,
121
+ t.ThousandStyle ?? S.None,
292
122
  t.enableLeadingZeros,
293
123
  (n == null ? void 0 : n.decimalSeparator) ?? E
294
124
  ) : e;
295
125
  }
296
- function S(e, t, n, r = ".") {
126
+ function b(e, t, n, r = ".") {
297
127
  let i = 0;
298
- for (let a = 0; a < t && a < e.length; a++) {
299
- const s = e[a];
128
+ for (let o = 0; o < t && o < e.length; o++) {
129
+ const s = e[o];
300
130
  s !== n && s !== r && i++;
301
131
  }
302
132
  return i;
303
133
  }
304
- function pe(e, t, n, r = ".") {
134
+ function oe(e, t, n, r = ".") {
305
135
  if (t === 0)
306
136
  return 0;
307
137
  let i = 0;
308
- for (let a = 0; a < e.length; a++) {
309
- const s = e[a];
138
+ for (let o = 0; o < e.length; o++) {
139
+ const s = e[o];
310
140
  if (s !== n && s !== r) {
311
141
  if (i === t - 1)
312
- return a + 1;
142
+ return o + 1;
313
143
  i++;
314
144
  }
315
145
  }
@@ -319,114 +149,117 @@ function C(e, t, n, r = ".") {
319
149
  if (t === 0)
320
150
  return 0;
321
151
  let i = 0;
322
- for (let a = 0; a < e.length; a++) {
323
- const s = e[a];
152
+ for (let o = 0; o < e.length; o++) {
153
+ const s = e[o];
324
154
  if (s !== n && s !== r) {
325
155
  if (i++, i === t)
326
- return a + 1;
156
+ return o + 1;
327
157
  if (i > t)
328
- return a;
158
+ return o;
329
159
  }
330
160
  }
331
161
  return e.length;
332
162
  }
333
- function J(e, t, n) {
163
+ function j(e, t, n) {
334
164
  return t < 0 || t >= e.length ? !1 : e[t] === n;
335
165
  }
336
- function be(e, t = {}) {
166
+ function ae(e, t = {}) {
337
167
  const {
338
168
  thousandSeparator: n,
339
169
  decimalSeparator: r = ".",
340
170
  prefix: i = "",
341
- suffix: a = ""
171
+ suffix: o = ""
342
172
  } = t, s = Array.from({ length: e.length + 1 }).map(() => !0);
343
- if (i && s.fill(!1, 0, i.length), a) {
344
- const o = e.length - a.length;
345
- s.fill(!1, o + 1, e.length + 1);
173
+ if (i && s.fill(!1, 0, i.length), o) {
174
+ const a = e.length - o.length;
175
+ s.fill(!1, a + 1, e.length + 1);
346
176
  }
347
- for (let o = 0; o < e.length; o++) {
348
- const c = e[o];
349
- (n && c === n || c === r) && (s[o] = !1, o + 1 < e.length && !/\d/.test(e[o + 1]) && (s[o + 1] = !1));
177
+ for (let a = 0; a < e.length; a++) {
178
+ const c = e[a];
179
+ (n && c === n || c === r) && (s[a] = !1, a + 1 < e.length && !/\d/.test(e[a + 1]) && (s[a + 1] = !1));
350
180
  }
351
- return s.some((o) => o) || s.fill(!0), s;
181
+ return s.some((a) => a) || s.fill(!0), s;
352
182
  }
353
183
  function T(e, t, n, r) {
354
184
  const i = e.length;
355
185
  if (t = Math.max(0, Math.min(t, i)), !n[t]) {
356
- let a = t;
357
- for (; a <= i && !n[a]; )
358
- a++;
186
+ let o = t;
187
+ for (; o <= i && !n[o]; )
188
+ o++;
359
189
  let s = t;
360
190
  for (; s >= 0 && !n[s]; )
361
191
  s--;
362
- a <= i && s >= 0 ? t = t - s < a - t ? s : a : a <= i ? t = a : s >= 0 && (t = s);
192
+ o <= i && s >= 0 ? t = t - s < o - t ? s : o : o <= i ? t = o : s >= 0 && (t = s);
363
193
  }
364
194
  return (t === -1 || t > i) && (t = i), t;
365
195
  }
366
- const H = (e, t) => e === t;
367
- function Se(e, t, n, r, i, a, s = ".", o = {}) {
196
+ const J = (e, t) => e === t;
197
+ function ce(e, t, n, r, i, o, s = ".", a = {}) {
368
198
  if (n < 0)
369
199
  return 0;
370
200
  if (n > e.length || e === "" || t === "")
371
201
  return t.length;
372
- const c = t.length < e.length, l = J(
202
+ const c = /(\d+\.?\d*)\s*[kmbMTOQaqiSxsxSpOoNn]$/i;
203
+ if (c.test(e) && !c.test(t) && t.length > e.length && n >= e.length - 1)
204
+ return t.length;
205
+ const l = t.length < e.length, h = j(
373
206
  e,
374
207
  n,
375
208
  r
376
- ), h = e.indexOf(s), d = t.indexOf(s);
377
- if (o.isCharacterEquivalent && e !== t) {
378
- const g = ve(
209
+ ), d = e.indexOf(s), u = t.indexOf(s);
210
+ if (a.isCharacterEquivalent && e !== t) {
211
+ const p = le(
379
212
  e,
380
213
  t,
381
214
  n,
382
- o.isCharacterEquivalent || H,
383
- a,
384
- o
215
+ a.isCharacterEquivalent || J,
216
+ o,
217
+ a
385
218
  );
386
- if (g !== void 0)
387
- return g;
219
+ if (p !== void 0)
220
+ return p;
388
221
  }
389
- if (c)
390
- return $e(
222
+ if (l)
223
+ return he(
391
224
  e,
392
225
  t,
393
226
  n,
394
227
  r,
395
- l,
396
228
  h,
397
229
  d,
398
- a,
230
+ u,
231
+ o,
399
232
  s,
400
- o
233
+ a
401
234
  );
402
- const f = Le(
235
+ const f = ge(
403
236
  e,
404
237
  t,
405
238
  n,
406
239
  r,
407
- l,
240
+ h,
408
241
  s
409
242
  );
410
- return o.boundary ? T(t, f, o.boundary) : f;
243
+ return a.boundary ? T(t, f, a.boundary) : f;
411
244
  }
412
- function ve(e, t, n, r, i, a) {
413
- const s = e.length, o = t.length, c = {}, l = new Array(s);
414
- for (let g = 0; g < s; g++) {
415
- l[g] = -1;
416
- for (let p = 0; p < o; p++) {
245
+ function le(e, t, n, r, i, o) {
246
+ const s = e.length, a = t.length, c = {}, l = new Array(s);
247
+ for (let f = 0; f < s; f++) {
248
+ l[f] = -1;
249
+ for (let p = 0; p < a; p++) {
417
250
  if (c[p]) continue;
418
251
  if (r(
419
- e[g],
252
+ e[f],
420
253
  t[p],
421
254
  {
422
255
  oldValue: e,
423
256
  newValue: t,
424
257
  typedRange: i,
425
- oldIndex: g,
258
+ oldIndex: f,
426
259
  newIndex: p
427
260
  }
428
261
  )) {
429
- l[g] = p, c[p] = !0;
262
+ l[f] = p, c[p] = !0;
430
263
  break;
431
264
  }
432
265
  }
@@ -434,16 +267,16 @@ function ve(e, t, n, r, i, a) {
434
267
  let h = n;
435
268
  for (; h < s && (l[h] === -1 || !/\d/.test(e[h])); )
436
269
  h++;
437
- const d = h === s || l[h] === -1 ? o : l[h];
270
+ const d = h === s || l[h] === -1 ? a : l[h];
438
271
  for (h = n - 1; h >= 0 && l[h] === -1; ) h--;
439
272
  const u = h === -1 || l[h] === -1 ? 0 : l[h] + 1;
440
273
  if (u > d) return d;
441
- const f = n - u < d - n ? u : d;
442
- return a.boundary ? T(t, f, a.boundary) : f;
274
+ const g = n - u < d - n ? u : d;
275
+ return o.boundary ? T(t, g, o.boundary) : g;
443
276
  }
444
- function $e(e, t, n, r, i, a, s, o, c, l = {}) {
277
+ function he(e, t, n, r, i, o, s, a, c, l = {}) {
445
278
  if (i)
446
- return Ee(
279
+ return ue(
447
280
  e,
448
281
  t,
449
282
  n,
@@ -451,97 +284,97 @@ function $e(e, t, n, r, i, a, s, o, c, l = {}) {
451
284
  s,
452
285
  c
453
286
  );
454
- const h = S(
287
+ const h = b(
455
288
  e,
456
289
  n,
457
290
  r,
458
291
  c
459
- ), d = S(
292
+ ), d = b(
460
293
  e,
461
294
  e.length,
462
295
  r,
463
296
  c
464
- ), u = S(
297
+ ), u = b(
465
298
  t,
466
299
  t.length,
467
300
  r,
468
301
  c
469
- ), f = d - u, g = Ne(
302
+ ), g = d - u, f = de(
470
303
  e,
471
304
  n,
472
305
  r,
473
306
  h,
474
- f,
475
- a,
307
+ g,
476
308
  o,
309
+ a,
477
310
  c
478
- ), p = a === -1 || n <= a, $ = we(
311
+ ), p = o === -1 || n <= o, $ = fe(
479
312
  t,
480
- g,
481
- r,
482
313
  f,
483
- o,
314
+ r,
315
+ g,
316
+ a,
484
317
  c,
485
318
  p,
486
319
  s
487
320
  );
488
321
  return l.boundary ? T(t, $, l.boundary) : $;
489
322
  }
490
- function Ee(e, t, n, r, i, a) {
323
+ function ue(e, t, n, r, i, o) {
491
324
  const s = n + 1;
492
325
  if (s < e.length) {
493
- const o = S(
326
+ const a = b(
494
327
  e,
495
328
  s,
496
329
  r,
497
- a
498
- ), c = pe(
330
+ o
331
+ ), c = oe(
499
332
  t,
500
- o,
333
+ a,
501
334
  r,
502
- a
335
+ o
503
336
  );
504
337
  return c < t.length && t[c] !== r ? c + 1 : c;
505
338
  }
506
339
  return n;
507
340
  }
508
- function Ne(e, t, n, r, i, a, s, o) {
341
+ function de(e, t, n, r, i, o, s, a) {
509
342
  if (s) {
510
343
  const { start: l, isDelete: h } = s;
511
- return h ? S(
344
+ return h ? b(
512
345
  e,
513
346
  l,
514
347
  n,
515
- o
516
- ) : Math.max(0, S(
348
+ a
349
+ ) : Math.max(0, b(
517
350
  e,
518
351
  l,
519
352
  n,
520
- o
353
+ a
521
354
  ));
522
355
  }
523
356
  return t > 0 && e[t - 1] === n && i > 0 ? r + 1 : r;
524
357
  }
525
- function we(e, t, n, r, i, a, s, o) {
526
- if (s && o !== -1) {
527
- const l = e.substring(0, o), h = S(
358
+ function fe(e, t, n, r, i, o, s, a) {
359
+ if (s && a !== -1) {
360
+ const l = e.substring(0, a), h = b(
528
361
  l,
529
362
  l.length,
530
363
  n,
531
- a
364
+ o
532
365
  );
533
366
  if (t <= h) {
534
367
  const d = C(
535
368
  l,
536
369
  t,
537
370
  n,
538
- a
371
+ o
539
372
  );
540
- if (d > 0 && d < l.length && S(
373
+ if (d > 0 && d < l.length && b(
541
374
  l,
542
375
  d,
543
376
  n,
544
- a
377
+ o
545
378
  ) === t) {
546
379
  if (l[d] === n && i && r > 0 && d < l.length - 1)
547
380
  return d + 1;
@@ -555,13 +388,13 @@ function we(e, t, n, r, i, a, s, o) {
555
388
  e,
556
389
  t,
557
390
  n,
558
- a
391
+ o
559
392
  );
560
- if (c > 0 && c < e.length && S(
393
+ if (c > 0 && c < e.length && b(
561
394
  e,
562
395
  c,
563
396
  n,
564
- a
397
+ o
565
398
  ) === t) {
566
399
  if (e[c] === n && i && r > 0 && c < e.length - 1)
567
400
  return c + 1;
@@ -570,38 +403,38 @@ function we(e, t, n, r, i, a, s, o) {
570
403
  }
571
404
  return c;
572
405
  }
573
- function Le(e, t, n, r, i, a) {
574
- const s = n >= e.length, o = S(
406
+ function ge(e, t, n, r, i, o) {
407
+ const s = n >= e.length, a = b(
575
408
  e,
576
409
  n,
577
410
  r,
578
- a
579
- ), c = S(
411
+ o
412
+ ), c = b(
580
413
  e,
581
414
  e.length,
582
415
  r,
583
- a
584
- ), l = S(
416
+ o
417
+ ), l = b(
585
418
  t,
586
419
  t.length,
587
420
  r,
588
- a
421
+ o
589
422
  );
590
- if (s || o === c)
423
+ if (s || a === c)
591
424
  return t.length;
592
425
  const h = l - c;
593
- let d = o;
594
- h > 0 && !s && o < c && (d = o + 1);
426
+ let d = a;
427
+ h > 0 && !s && a < c && (d = a + 1);
595
428
  const u = C(
596
429
  t,
597
430
  d,
598
431
  r,
599
- a
432
+ o
600
433
  );
601
- return i && !J(t, u, r) ? Math.max(0, u - 1) : u;
434
+ return i && !j(t, u, r) ? Math.max(0, u - 1) : u;
602
435
  }
603
- function De(e, t, n) {
604
- const { selectionStart: r, selectionEnd: i, endOffset: a = 0 } = e;
436
+ function pe(e, t, n) {
437
+ const { selectionStart: r, selectionEnd: i, endOffset: o = 0 } = e;
605
438
  if (r !== i) {
606
439
  const h = i - r;
607
440
  return {
@@ -611,8 +444,8 @@ function De(e, t, n) {
611
444
  isDelete: !1
612
445
  };
613
446
  }
614
- if (a > 0) {
615
- const h = a;
447
+ if (o > 0) {
448
+ const h = o;
616
449
  return {
617
450
  start: r,
618
451
  end: r + h,
@@ -620,7 +453,7 @@ function De(e, t, n) {
620
453
  isDelete: !0
621
454
  };
622
455
  }
623
- const o = t.length, c = n.length, l = o - c;
456
+ const a = t.length, c = n.length, l = a - c;
624
457
  if (!(l <= 0))
625
458
  return {
626
459
  start: r,
@@ -629,7 +462,7 @@ function De(e, t, n) {
629
462
  isDelete: !1
630
463
  };
631
464
  }
632
- function Me(e, t) {
465
+ function Se(e, t) {
633
466
  if (e === t)
634
467
  return;
635
468
  let n = 0;
@@ -638,16 +471,16 @@ function Me(e, t) {
638
471
  let r = e.length - 1, i = t.length - 1;
639
472
  for (; r >= n && i >= n && e[r] === t[i]; )
640
473
  r--, i--;
641
- const a = r - n + 1, s = i - n + 1;
642
- if (!(a === 0 && s === 0))
474
+ const o = r - n + 1, s = i - n + 1;
475
+ if (!(o === 0 && s === 0))
643
476
  return {
644
477
  start: n,
645
478
  end: r + 1,
646
- deletedLength: a,
647
- isDelete: a > s
479
+ deletedLength: o,
480
+ isDelete: o > s
648
481
  };
649
482
  }
650
- function U(e, t) {
483
+ function z(e, t) {
651
484
  if (e.value = e.value, e === null)
652
485
  return !1;
653
486
  if (e.createTextRange) {
@@ -656,65 +489,237 @@ function U(e, t) {
656
489
  }
657
490
  return e.selectionStart !== null || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), !0) : (e.focus(), !1);
658
491
  }
659
- function me(e, t, n) {
660
- return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (U(e, t), setTimeout(() => {
661
- e.value === n && e.selectionStart !== t && U(e, t);
492
+ function be(e, t, n) {
493
+ return e.selectionStart === 0 && e.selectionEnd === e.value.length ? null : (z(e, t), setTimeout(() => {
494
+ e.value === n && e.selectionStart !== t && z(e, t);
662
495
  }, 0));
663
496
  }
664
- function ye(e) {
497
+ function ve(e) {
665
498
  return Math.max(e.selectionStart, e.selectionEnd);
666
499
  }
667
- function Ae(e, t, n) {
500
+ function $e(e, t, n) {
668
501
  if ((n == null ? void 0 : n.formatOn) !== v.Change || !n.thousandSeparator)
669
502
  return;
670
- const { selectionStart: r, selectionEnd: i, value: a } = t;
503
+ const { selectionStart: r, selectionEnd: i, value: o } = t;
671
504
  if (r === null || i === null || r !== i)
672
505
  return;
673
- const { key: s } = e, o = n.thousandSeparator;
674
- s === "Backspace" && r > 0 && a[r - 1] === o && t.setSelectionRange(r - 1, r - 1), s === "Delete" && a[r] === o && t.setSelectionRange(r + 1, r + 1);
506
+ const { key: s } = e, a = n.thousandSeparator;
507
+ s === "Backspace" && r > 0 && o[r - 1] === a && t.setSelectionRange(r - 1, r - 1), s === "Delete" && o[r] === a && t.setSelectionRange(r + 1, r + 1);
675
508
  }
676
- function Ce(e, t, n, r, i, a, s) {
509
+ function Ee(e, t, n, r, i, o, s) {
677
510
  if (!i) return;
678
- const { selectionStart: o = 0, selectionEnd: c = 0, endOffset: l = 0 } = i;
679
- let h = De(
680
- { selectionStart: o, selectionEnd: c, endOffset: l },
511
+ const { selectionStart: a = 0, selectionEnd: c = 0, endOffset: l = 0 } = i;
512
+ let h = pe(
513
+ { selectionStart: a, selectionEnd: c, endOffset: l },
681
514
  t,
682
515
  n
683
516
  );
684
- if (h || (h = Me(t, n)), !h) return;
685
- const d = be(n, {
686
- thousandSeparator: (s == null ? void 0 : s.thousandSeparator) ?? a.thousandSeparator,
687
- decimalSeparator: a.decimalSeparator
517
+ if (h || (h = Se(t, n)), !h) return;
518
+ const d = ae(n, {
519
+ thousandSeparator: (s == null ? void 0 : s.thousandSeparator) ?? o.thousandSeparator,
520
+ decimalSeparator: o.decimalSeparator
688
521
  }), u = {
689
- thousandSeparator: (s == null ? void 0 : s.thousandSeparator) ?? a.thousandSeparator,
690
- isCharacterEquivalent: H,
522
+ thousandSeparator: (s == null ? void 0 : s.thousandSeparator) ?? o.thousandSeparator,
523
+ isCharacterEquivalent: J,
691
524
  boundary: d
692
- }, f = (s == null ? void 0 : s.thousandSeparator) ?? a.thousandSeparator ?? ",", g = (s == null ? void 0 : s.ThousandStyle) ?? b.None, p = Se(
525
+ }, g = (s == null ? void 0 : s.thousandSeparator) ?? o.thousandSeparator ?? ",", f = (s == null ? void 0 : s.ThousandStyle) ?? S.None, p = ce(
693
526
  t,
694
527
  n,
695
528
  r,
696
- f,
697
529
  g,
530
+ f,
698
531
  h,
699
- a.decimalSeparator,
532
+ o.decimalSeparator,
700
533
  u
701
534
  );
702
- me(e, p, n);
535
+ be(e, p, n);
703
536
  }
704
- function x(e, t, n, r, i) {
705
- const a = le(
537
+ const Ne = (e, t = !1, n = ".") => {
538
+ const r = D(n), i = new RegExp(`[^0-9${r}]`, "g");
539
+ if (!t)
540
+ return e.replace(i, "");
541
+ const o = e.startsWith("-"), s = e.replace(i, "");
542
+ if (o) {
543
+ if (s.length > 0)
544
+ return "-" + s;
545
+ if (e === "-")
546
+ return "-";
547
+ }
548
+ return s;
549
+ };
550
+ function Le(e) {
551
+ const t = /([+-]?\d+\.?\d*)[eE]([+-]?\d+)/g;
552
+ let n = e, r;
553
+ const i = [];
554
+ for (; (r = t.exec(e)) !== null; ) {
555
+ const o = r[0], s = r[1], a = parseInt(r[2], 10);
556
+ let c;
557
+ if (a === 0)
558
+ c = s;
559
+ else {
560
+ const l = s.startsWith("-"), h = l ? s.slice(1) : s, [d, u = ""] = h.split(".");
561
+ a > 0 ? c = we(d, u, a) : c = De(d, u, Math.abs(a)), l && (c = "-" + c);
562
+ }
563
+ i.push({ full: o, expanded: c });
564
+ }
565
+ for (const { full: o, expanded: s } of i)
566
+ n = n.replace(o, s);
567
+ return n;
568
+ }
569
+ function we(e, t, n) {
570
+ const r = e + t;
571
+ if (r === "0" || r.match(/^0+$/))
572
+ return "0";
573
+ const i = t.length;
574
+ if (n <= i) {
575
+ const s = r.slice(0, e.length + n), a = r.slice(e.length + n);
576
+ return a ? `${s}.${a}` : s;
577
+ }
578
+ const o = n - i;
579
+ return r + "0".repeat(o);
580
+ }
581
+ function De(e, t, n) {
582
+ const r = e + t;
583
+ if (r === "0" || r.match(/^0+$/))
584
+ return "0";
585
+ const s = e.length - n;
586
+ if (s <= 0) {
587
+ const a = Math.abs(s), c = `0.${"0".repeat(a)}${r}`;
588
+ return y(c);
589
+ }
590
+ if (s < e.length) {
591
+ const a = r.slice(0, s), c = r.slice(s), l = `${a}.${c}`;
592
+ return y(l);
593
+ }
594
+ return y(r);
595
+ }
596
+ function y(e) {
597
+ if (!e.includes("."))
598
+ return e;
599
+ if (e === "0" || e === "0.")
600
+ return "0";
601
+ if (e.startsWith("0.")) {
602
+ const t = e.replace(/\.?0+$/, "");
603
+ return t === "0" ? "0" : t || "0";
604
+ }
605
+ if (e.startsWith("-0.")) {
606
+ const t = e.replace(/\.?0+$/, "");
607
+ return t === "-0" || t === "0" ? "0" : t || "0";
608
+ }
609
+ return e.replace(/\.?0+$/, "") || e;
610
+ }
611
+ function me(e) {
612
+ const t = /(\d+\.?\d*)\s*(Qa|Qi|Sx|Sp|[kmbMTO]|N)/gi;
613
+ return e.replace(t, (n, r, i) => {
614
+ const o = {
615
+ k: 3,
616
+ // Thousand
617
+ K: 3,
618
+ // Thousand
619
+ m: 6,
620
+ // Million (lowercase)
621
+ M: 6,
622
+ // Million (uppercase)
623
+ b: 9,
624
+ // Billion
625
+ B: 9,
626
+ // Billion
627
+ T: 12,
628
+ // Trillion
629
+ t: 12
630
+ // Trillion
631
+ };
632
+ let s;
633
+ if (i.length > 1) {
634
+ const g = i.charAt(0).toUpperCase() + i.slice(1).toLowerCase();
635
+ s = o[i] || o[g];
636
+ } else {
637
+ const g = i.toLowerCase();
638
+ s = o[i] || o[g];
639
+ }
640
+ if (!s)
641
+ return n;
642
+ const a = r.startsWith("-"), c = a ? r.slice(1) : r, [l, h = ""] = c.split("."), d = l.replace(/^0+/, "") || "0";
643
+ let u;
644
+ if (h.length === 0)
645
+ u = d + "0".repeat(s);
646
+ else if (h.length <= s) {
647
+ const g = s - h.length;
648
+ u = d + h + "0".repeat(g);
649
+ } else {
650
+ const g = h.slice(0, s), f = h.slice(s);
651
+ u = d + g + "." + f;
652
+ }
653
+ return u = u.replace(/^(-?)0+([1-9])/, "$1$2"), u.match(/^-?0+$/) && (u = a ? "-0" : "0"), u.includes(".") && (u = u.replace(/\.?0+$/, "")), a && !u.startsWith("-") ? "-" + u : u;
654
+ });
655
+ }
656
+ function Me(e) {
657
+ if (!e || e === "0" || e === "-0" || e === "-" || e === ".")
658
+ return e;
659
+ const t = e.startsWith("-"), n = t ? e.slice(1) : e;
660
+ if (!n || n === "0" || n === ".")
661
+ return e;
662
+ if (n.includes(".")) {
663
+ const [i, o] = n.split(".");
664
+ if (i && i.length > 0) {
665
+ const a = (i.replace(/^0+/, "") || "0") + "." + o;
666
+ return t ? "-" + a : a;
667
+ }
668
+ return e;
669
+ }
670
+ if (n.startsWith("0") && n.length > 1) {
671
+ const i = n.replace(/^0+/, "") || "0";
672
+ return t ? "-" + i : i;
673
+ }
674
+ return e;
675
+ }
676
+ function ye(e) {
677
+ return e.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g, " ").replace(/\s/g, "");
678
+ }
679
+ function w(e, t) {
680
+ const n = D(t);
681
+ return e.replace(new RegExp(n, "g"), "");
682
+ }
683
+ const Ce = (e, t) => {
684
+ let n = ye(e);
685
+ return t != null && t.thousandSeparator && (n = w(n, t.thousandSeparator)), t != null && t.enableCompactNotation && (n = me(n)), n = Le(n), n = Ne(
686
+ n,
687
+ t == null ? void 0 : t.enableNegative,
688
+ t == null ? void 0 : t.decimalSeparator
689
+ ), n = ee(n, (t == null ? void 0 : t.decimalSeparator) || E), t != null && t.enableLeadingZeros || (n = Me(n)), n;
690
+ };
691
+ function Ae(e, t, n) {
692
+ return {
693
+ enableCompactNotation: e == null ? void 0 : e.enableCompactNotation,
694
+ enableNegative: e == null ? void 0 : e.enableNegative,
695
+ enableLeadingZeros: e == null ? void 0 : e.enableLeadingZeros,
696
+ decimalSeparator: t.decimalSeparator,
697
+ thousandSeparator: n ? t.thousandSeparator : void 0
698
+ };
699
+ }
700
+ function x(e, t, n, r) {
701
+ const i = A(n), o = r ?? (n == null ? void 0 : n.formatOn) === v.Change, s = Ce(
706
702
  e,
707
- he(r, i, n)
708
- ), s = F(
709
- a,
703
+ Ae(n, i, o)
704
+ ), a = F(
705
+ s,
710
706
  t,
711
707
  i.decimalSeparator
712
- ), o = (r == null ? void 0 : r.decimalMinLength) ?? 0, c = te(
713
- s,
714
- o,
708
+ ), c = (n == null ? void 0 : n.decimalMinLength) ?? 0, l = te(
709
+ a,
710
+ c,
715
711
  i.decimalSeparator
716
- ), l = c;
717
- return { formatted: ge(c, r, i), raw: l };
712
+ ), h = l;
713
+ return { formatted: ie(l, n, i), raw: h };
714
+ }
715
+ function Ke(e, t, n) {
716
+ const r = !!(n != null && n.thousandSeparator);
717
+ return x(
718
+ e,
719
+ t,
720
+ n,
721
+ r
722
+ );
718
723
  }
719
724
  function Te(e, t, n) {
720
725
  if (e === "Backspace" || e === "Delete")
@@ -725,74 +730,60 @@ function Te(e, t, n) {
725
730
  };
726
731
  }
727
732
  function xe(e, t) {
728
- const { decimalSeparator: n } = y(t), r = e.target;
733
+ const { decimalSeparator: n } = A(t), r = e.target;
729
734
  if (V(e, r, t, n)) {
730
735
  e.preventDefault();
731
736
  return;
732
737
  }
733
- return Ae(e, r, t), Te(e.key, r.selectionStart, r.selectionEnd);
738
+ return $e(e, r, t), Te(e.key, r.selectionStart, r.selectionEnd);
734
739
  }
735
740
  function Ie(e, t, n, r) {
736
- const i = e.target, a = i.value, s = ye(i), o = y(r), c = (r == null ? void 0 : r.formatOn) === v.Change, { formatted: l, raw: h } = x(
737
- a,
741
+ const i = e.target, o = i.value, s = ve(i), a = A(r), c = (r == null ? void 0 : r.formatOn) === v.Change, { formatted: l, raw: h } = x(
742
+ o,
738
743
  t,
739
- c,
740
744
  r,
741
- o
745
+ c
742
746
  );
743
- i.value = l, r != null && r.rawValueMode && i.setAttribute("data-raw-value", h), a !== l && Ce(
747
+ return i.value = l, o !== l && Ee(
744
748
  i,
745
- a,
749
+ o,
746
750
  l,
747
751
  s,
748
752
  n,
749
- o,
753
+ a,
750
754
  r
751
- );
755
+ ), { formatted: l, raw: h };
752
756
  }
753
757
  function Re(e, t, n, r) {
754
758
  const i = r - n;
755
759
  return e + t + i;
756
760
  }
757
761
  function Oe(e, t, n) {
758
- var f;
762
+ var u;
759
763
  e.preventDefault();
760
- const r = e.target, { value: i, selectionStart: a, selectionEnd: s } = r, o = y(n), c = ((f = e.clipboardData) == null ? void 0 : f.getData("text/plain")) || "", l = i.slice(0, a || 0) + c + i.slice(s || 0), { formatted: h, raw: d } = x(
761
- l,
764
+ const r = e.target, { value: i, selectionStart: o, selectionEnd: s } = r, a = ((u = e.clipboardData) == null ? void 0 : u.getData("text/plain")) || "", c = i.slice(0, o || 0) + a + i.slice(s || 0), { formatted: l, raw: h } = x(
765
+ c,
762
766
  t,
763
- !0,
764
767
  n,
765
- o
768
+ !0
766
769
  );
767
- r.value = h, n != null && n.rawValueMode && r.setAttribute("data-raw-value", d);
768
- const u = Re(
769
- a || 0,
770
+ r.value = l;
771
+ const d = Re(
772
+ o || 0,
773
+ a.length,
770
774
  c.length,
771
- l.length,
772
- h.length
775
+ l.length
773
776
  );
774
- return r.setSelectionRange(u, u), r.value;
775
- }
776
- function Ke(e, t, n) {
777
- if (!e)
778
- return e;
779
- const r = y(n), i = !0, { formatted: a } = x(
780
- e,
781
- t,
782
- i,
783
- n,
784
- r
785
- );
786
- return a;
777
+ return r.setSelectionRange(d, d), { formatted: l, raw: h };
787
778
  }
788
779
  function _e(e, t) {
789
780
  const n = D(e);
790
781
  return t ? `^-?[0-9]*[${n}]?[0-9]*$` : `^[0-9]*[${n}]?[0-9]*$`;
791
782
  }
792
- function Pe(e) {
793
- Be(e.decimalMaxLength), We(e.decimalMinLength), ke(e.decimalMinLength, e.decimalMaxLength), Ze(e.formatOn), Ge(e.thousandSeparator), Ue(e.thousandStyle), ze(e.decimalSeparator), je(e.thousandSeparator, e.decimalSeparator), m("enableCompactNotation", e.enableCompactNotation), m("enableNegative", e.enableNegative), m("enableLeadingZeros", e.enableLeadingZeros), m("rawValueMode", e.rawValueMode), Je(e.onChange);
794
- }
795
783
  function Be(e) {
784
+ Pe(e.decimalMaxLength), We(e.decimalMinLength), ke(e.decimalMinLength, e.decimalMaxLength), Ze(e.formatOn), ze(e.thousandSeparator), Ge(e.thousandStyle), Ue(e.decimalSeparator), je(e.thousandSeparator, e.decimalSeparator), M("enableCompactNotation", e.enableCompactNotation), M("enableNegative", e.enableNegative), M("enableLeadingZeros", e.enableLeadingZeros), M("rawValueMode", e.rawValueMode), Je(e.onChange);
785
+ }
786
+ function Pe(e) {
796
787
  if (e !== void 0) {
797
788
  if (typeof e != "number")
798
789
  throw new Error(
@@ -836,7 +827,7 @@ function Ze(e) {
836
827
  `formatOn must be either ${v.Blur} or ${v.Change}. Received: ${JSON.stringify(e)}`
837
828
  );
838
829
  }
839
- function Ge(e) {
830
+ function ze(e) {
840
831
  if (e !== void 0) {
841
832
  if (typeof e != "string")
842
833
  throw new Error(
@@ -852,13 +843,13 @@ function Ge(e) {
852
843
  );
853
844
  }
854
845
  }
855
- function Ue(e) {
856
- if (e !== void 0 && !Object.values(b).includes(e))
846
+ function Ge(e) {
847
+ if (e !== void 0 && !Object.values(S).includes(e))
857
848
  throw new Error(
858
- `ThousandStyle must be one of: ${Object.values(b).map((t) => `'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`
849
+ `ThousandStyle must be one of: ${Object.values(S).map((t) => `'${t}'`).join(", ")}. Received: ${JSON.stringify(e)}`
859
850
  );
860
851
  }
861
- function ze(e) {
852
+ function Ue(e) {
862
853
  if (e !== void 0) {
863
854
  if (typeof e != "string")
864
855
  throw new Error(
@@ -880,7 +871,7 @@ function je(e, t) {
880
871
  `Decimal separator can't be same as thousand separator. thousandSeparator: ${e}, decimalSeparator: ${t}`
881
872
  );
882
873
  }
883
- function m(e, t) {
874
+ function M(e, t) {
884
875
  if (t !== void 0 && typeof t != "boolean")
885
876
  throw new Error(
886
877
  `${e} must be a boolean. Received: ${typeof t} (${JSON.stringify(t)})`
@@ -897,28 +888,28 @@ class Qe {
897
888
  decimalMaxLength: n = I,
898
889
  decimalMinLength: r = R,
899
890
  formatOn: i = O,
900
- thousandSeparator: a = _,
901
- thousandStyle: s = P,
902
- decimalSeparator: o = E,
903
- enableCompactNotation: c = B,
904
- enableNegative: l = W,
905
- enableLeadingZeros: h = k,
906
- rawValueMode: d = Z,
891
+ thousandSeparator: o = _,
892
+ thousandStyle: s = B,
893
+ decimalSeparator: a = E,
894
+ enableCompactNotation: c = !0,
895
+ enableNegative: l = P,
896
+ enableLeadingZeros: h = W,
897
+ rawValueMode: d = k,
907
898
  onChange: u,
908
- ...f
899
+ ...g
909
900
  }) {
910
- w(this, "element");
911
- w(this, "options");
912
- w(this, "resolvedOptions");
913
- w(this, "rawValue", "");
914
- w(this, "caretPositionBeforeChange");
915
- if (Pe({
901
+ L(this, "element");
902
+ L(this, "options");
903
+ L(this, "resolvedOptions");
904
+ L(this, "rawValue", "");
905
+ L(this, "caretPositionBeforeChange");
906
+ if (Be({
916
907
  decimalMaxLength: n,
917
908
  decimalMinLength: r,
918
909
  formatOn: i,
919
- thousandSeparator: a,
910
+ thousandSeparator: o,
920
911
  thousandStyle: s,
921
- decimalSeparator: o,
912
+ decimalSeparator: a,
922
913
  enableCompactNotation: c,
923
914
  enableNegative: l,
924
915
  enableLeadingZeros: h,
@@ -929,52 +920,48 @@ class Qe {
929
920
  decimalMinLength: r,
930
921
  onChange: u,
931
922
  formatOn: i,
932
- thousandSeparator: a,
923
+ thousandSeparator: o,
933
924
  thousandStyle: s,
934
- decimalSeparator: o,
925
+ decimalSeparator: a,
935
926
  enableCompactNotation: c,
936
927
  enableNegative: l,
937
928
  enableLeadingZeros: h,
938
929
  rawValueMode: d,
939
- ...f
930
+ ...g
940
931
  }, this.resolvedOptions = this.getResolvedOptions(), this.createInputElement(t), this.setupEventListeners(), this.resolvedOptions.rawValueMode && this.element.value) {
941
- const g = this.element.value, p = this.resolvedOptions.thousandSeparator ? L(g, this.resolvedOptions.thousandSeparator) : g;
932
+ const f = this.element.value, p = this.resolvedOptions.thousandSeparator ? w(f, this.resolvedOptions.thousandSeparator) : f;
942
933
  this.rawValue = p, this.element.value = this.formatValueForDisplay(p);
943
- } else if (this.element.value && !this.resolvedOptions.rawValueMode) {
944
- const g = this.element.value;
945
- this.element.value = this.formatValueForDisplay(g);
934
+ } else if (this.element.value) {
935
+ const f = this.element.value;
936
+ this.element.value = this.formatValueForDisplay(f);
946
937
  }
947
938
  }
948
939
  createInputElement(t) {
949
940
  if (this.element = document.createElement("input"), this.element.setAttribute("type", "text"), this.element.setAttribute("inputmode", "decimal"), this.element.setAttribute("spellcheck", "false"), this.element.setAttribute("autocomplete", "off"), this.resolvedOptions.decimalSeparator !== void 0 && this.resolvedOptions.enableNegative !== void 0) {
950
- const K = _e(this.resolvedOptions.decimalSeparator, this.resolvedOptions.enableNegative);
951
- this.element.setAttribute("pattern", K);
941
+ const H = _e(this.resolvedOptions.decimalSeparator, this.resolvedOptions.enableNegative);
942
+ this.element.setAttribute("pattern", H);
952
943
  }
953
944
  const {
954
945
  decimalMaxLength: n,
955
946
  decimalMinLength: r,
956
947
  formatOn: i,
957
- thousandSeparator: a,
948
+ thousandSeparator: o,
958
949
  thousandStyle: s,
959
- decimalSeparator: o,
950
+ decimalSeparator: a,
960
951
  enableCompactNotation: c,
961
952
  enableNegative: l,
962
953
  enableLeadingZeros: h,
963
954
  rawValueMode: d,
964
955
  onChange: u,
965
- value: f,
966
- defaultValue: g,
956
+ value: g,
957
+ defaultValue: f,
967
958
  type: p,
968
- // Exclude - forced to 'text' above
969
959
  inputMode: $,
970
- // Exclude - forced to 'decimal' above
971
- spellcheck: M,
972
- // Exclude - forced to 'false' above
973
- autocomplete: He,
974
- // Exclude - forced to 'off' above
960
+ spellcheck: m,
961
+ autocomplete: qe,
975
962
  ...q
976
963
  } = this.options;
977
- Object.assign(this.element, q), f !== void 0 ? this.element.value = f : g !== void 0 && (this.element.defaultValue = g, this.element.value = g), t.appendChild(this.element);
964
+ Object.assign(this.element, q), g !== void 0 ? this.element.value = g : f !== void 0 && (this.element.defaultValue = f, this.element.value = f), t.appendChild(this.element);
978
965
  }
979
966
  setupEventListeners() {
980
967
  this.element.addEventListener("input", this.handleChange.bind(this)), this.element.addEventListener("keydown", this.handleKeyDown.bind(this)), this.element.addEventListener("paste", this.handlePaste.bind(this)), this.resolvedOptions.formatOn === v.Blur && this.resolvedOptions.thousandSeparator && (this.element.addEventListener("focus", this.handleFocus.bind(this)), this.element.addEventListener("blur", this.handleBlur.bind(this)));
@@ -985,12 +972,12 @@ class Qe {
985
972
  decimalMinLength: this.options.decimalMinLength ?? R,
986
973
  formatOn: this.options.formatOn ?? O,
987
974
  thousandSeparator: this.options.thousandSeparator ?? _,
988
- thousandStyle: this.options.thousandStyle ?? P,
975
+ thousandStyle: this.options.thousandStyle ?? B,
989
976
  decimalSeparator: this.options.decimalSeparator ?? E,
990
- enableCompactNotation: this.options.enableCompactNotation ?? B,
991
- enableNegative: this.options.enableNegative ?? W,
992
- enableLeadingZeros: this.options.enableLeadingZeros ?? k,
993
- rawValueMode: this.options.rawValueMode ?? Z,
977
+ enableCompactNotation: this.options.enableCompactNotation ?? X,
978
+ enableNegative: this.options.enableNegative ?? P,
979
+ enableLeadingZeros: this.options.enableLeadingZeros ?? W,
980
+ rawValueMode: this.options.rawValueMode ?? k,
994
981
  onChange: this.options.onChange
995
982
  };
996
983
  }
@@ -1008,39 +995,38 @@ class Qe {
1008
995
  };
1009
996
  }
1010
997
  handleValueChange(t, n) {
1011
- const r = n ?? t;
1012
- if (this.resolvedOptions.rawValueMode && this.updateRawValue(r), this.resolvedOptions.onChange) {
1013
- const i = this.resolvedOptions.rawValueMode ? this.rawValue : t;
1014
- this.resolvedOptions.onChange(i);
998
+ if (this.resolvedOptions.rawValueMode && n !== void 0 && (this.rawValue = n), this.resolvedOptions.onChange) {
999
+ const r = this.resolvedOptions.rawValueMode ? this.rawValue : t;
1000
+ this.resolvedOptions.onChange(r);
1015
1001
  }
1016
1002
  }
1017
1003
  formatValueForDisplay(t) {
1018
1004
  if (!t)
1019
1005
  return t;
1020
- const { thousandSeparator: n, thousandStyle: r, enableLeadingZeros: i, decimalSeparator: a } = this.resolvedOptions;
1021
- return n && r !== b.None ? z(
1006
+ const { thousandSeparator: n, thousandStyle: r, enableLeadingZeros: i, decimalSeparator: o } = this.resolvedOptions;
1007
+ return n && r !== S.None ? G(
1022
1008
  t,
1023
1009
  n,
1024
1010
  r,
1025
1011
  i,
1026
- a
1012
+ o
1027
1013
  ) : t;
1028
1014
  }
1029
1015
  handleChange(t) {
1030
- const n = t.target;
1031
- Ie(
1016
+ const { formatted: n, raw: r } = Ie(
1032
1017
  t,
1033
1018
  this.resolvedOptions.decimalMaxLength,
1034
1019
  this.caretPositionBeforeChange,
1035
1020
  this.buildFormattingOptions()
1036
- ), this.caretPositionBeforeChange = void 0, this.handleValueChange(n.value);
1021
+ );
1022
+ this.caretPositionBeforeChange = void 0, this.handleValueChange(n, r);
1037
1023
  }
1038
1024
  handleKeyDown(t) {
1039
- const n = t.target, { selectionStart: r, selectionEnd: i } = n, a = this.buildFormattingOptions(), s = xe(t, {
1040
- formatOn: a.formatOn,
1041
- thousandSeparator: a.thousandSeparator,
1042
- ThousandStyle: a.ThousandStyle,
1043
- decimalSeparator: a.decimalSeparator
1025
+ const n = t.target, { selectionStart: r, selectionEnd: i } = n, o = this.buildFormattingOptions(), s = xe(t, {
1026
+ formatOn: o.formatOn,
1027
+ thousandSeparator: o.thousandSeparator,
1028
+ ThousandStyle: o.ThousandStyle,
1029
+ decimalSeparator: o.decimalSeparator
1044
1030
  });
1045
1031
  s ? this.caretPositionBeforeChange = {
1046
1032
  selectionStart: r ?? 0,
@@ -1052,51 +1038,37 @@ class Qe {
1052
1038
  };
1053
1039
  }
1054
1040
  handlePaste(t) {
1055
- const n = Oe(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
1056
- this.handleValueChange(n);
1057
- const r = new Event("input", { bubbles: !0, cancelable: !0 });
1058
- this.element.dispatchEvent(r);
1041
+ const { formatted: n, raw: r } = Oe(t, this.resolvedOptions.decimalMaxLength, this.buildFormattingOptions());
1042
+ this.handleValueChange(n, r);
1043
+ const i = new Event("input", { bubbles: !0, cancelable: !0 });
1044
+ this.element.dispatchEvent(i);
1059
1045
  }
1060
1046
  handleFocus(t) {
1061
1047
  if (this.resolvedOptions.formatOn === v.Blur && this.resolvedOptions.thousandSeparator) {
1062
1048
  const n = t.target;
1063
- n.value = L(n.value, this.resolvedOptions.thousandSeparator);
1049
+ n.value = w(n.value, this.resolvedOptions.thousandSeparator);
1064
1050
  }
1065
1051
  }
1066
1052
  handleBlur(t) {
1067
1053
  const n = t.target, { thousandSeparator: r, thousandStyle: i } = this.resolvedOptions;
1068
- if (r && i !== b.None && n.value) {
1069
- const a = n.value, s = this.formatValueForDisplay(n.value);
1070
- if (n.value = s, this.handleValueChange(s), a !== s) {
1071
- const o = new Event("input", { bubbles: !0, cancelable: !0 });
1072
- this.element.dispatchEvent(o);
1073
- const c = new Event("change", { bubbles: !0, cancelable: !0 });
1054
+ if (r && i !== S.None && n.value) {
1055
+ const o = n.value, s = this.formatValueForDisplay(n.value);
1056
+ n.value = s;
1057
+ const a = this.resolvedOptions.rawValueMode ? w(s, r) : void 0;
1058
+ if (this.handleValueChange(s, a), o !== s) {
1059
+ const c = new Event("input", { bubbles: !0, cancelable: !0 });
1074
1060
  this.element.dispatchEvent(c);
1061
+ const l = new Event("change", { bubbles: !0, cancelable: !0 });
1062
+ this.element.dispatchEvent(l);
1075
1063
  }
1076
1064
  }
1077
1065
  }
1078
- /**
1079
- * Extracts and stores the raw numeric value from a formatted value.
1080
- * Gets the raw value from the data attribute set by event handlers, or extracts it from formatted value.
1081
- */
1082
- updateRawValue(t) {
1083
- const n = this.element.getAttribute("data-raw-value");
1084
- if (n !== null) {
1085
- this.rawValue = n, this.element.removeAttribute("data-raw-value");
1086
- return;
1087
- }
1088
- if (!this.resolvedOptions.thousandSeparator) {
1089
- this.rawValue = t;
1090
- return;
1091
- }
1092
- this.rawValue = L(t, this.resolvedOptions.thousandSeparator);
1093
- }
1094
1066
  getValue() {
1095
1067
  return this.resolvedOptions.rawValueMode ? this.rawValue : this.element.value;
1096
1068
  }
1097
1069
  setValue(t) {
1098
1070
  if (this.resolvedOptions.rawValueMode) {
1099
- const n = this.resolvedOptions.thousandSeparator ? L(t, this.resolvedOptions.thousandSeparator) : t;
1071
+ const n = this.resolvedOptions.thousandSeparator ? w(t, this.resolvedOptions.thousandSeparator) : t;
1100
1072
  this.rawValue = n, this.element.value = this.formatValueForDisplay(n);
1101
1073
  } else
1102
1074
  this.element.value = t;
@@ -1144,7 +1116,7 @@ class Qe {
1144
1116
  const t = this.getValue();
1145
1117
  if (!t)
1146
1118
  return NaN;
1147
- const n = this.resolvedOptions.thousandSeparator ? L(t, this.resolvedOptions.thousandSeparator) : t, r = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(D(this.resolvedOptions.decimalSeparator), "g"), ".") : n;
1119
+ const n = this.resolvedOptions.thousandSeparator ? w(t, this.resolvedOptions.thousandSeparator) : t, r = this.resolvedOptions.decimalSeparator && this.resolvedOptions.decimalSeparator !== "." ? n.replace(new RegExp(D(this.resolvedOptions.decimalSeparator), "g"), ".") : n;
1148
1120
  return parseFloat(r);
1149
1121
  }
1150
1122
  /**
@@ -1162,9 +1134,10 @@ class Qe {
1162
1134
  export {
1163
1135
  v as FormatOn,
1164
1136
  Qe as NumoraInput,
1165
- b as ThousandStyle,
1166
- Ke as formatValueForNumora,
1137
+ S as ThousandStyle,
1138
+ Ke as formatValue,
1167
1139
  Ie as handleOnChangeNumoraInput,
1168
1140
  xe as handleOnKeyDownNumoraInput,
1169
- Oe as handleOnPasteNumoraInput
1141
+ Oe as handleOnPasteNumoraInput,
1142
+ x as processAndFormatValue
1170
1143
  };