wulf.js 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +240 -4
  2. package/changelog.md +30 -0
  3. package/dist/focus-trap.esm.js +22 -7
  4. package/dist/focus-trap.esm.js.map +2 -2
  5. package/dist/focus-trap.global.js +22 -7
  6. package/dist/focus-trap.global.js.map +2 -2
  7. package/dist/focus-trap.global.min.js +2 -2
  8. package/dist/focus-trap.global.min.js.map +3 -3
  9. package/dist/index.esm.js +2950 -296
  10. package/dist/index.esm.js.map +4 -4
  11. package/dist/index.global.js +2950 -296
  12. package/dist/index.global.js.map +4 -4
  13. package/dist/index.global.min.js +2 -2
  14. package/dist/index.global.min.js.map +4 -4
  15. package/dist/mask.css +1 -1
  16. package/dist/mask.css.map +2 -2
  17. package/dist/mask.esm.js +2826 -171
  18. package/dist/mask.esm.js.map +4 -4
  19. package/dist/mask.global.js +2816 -161
  20. package/dist/mask.global.js.map +4 -4
  21. package/dist/mask.global.min.js +2 -2
  22. package/dist/mask.global.min.js.map +4 -4
  23. package/dist/mask.layered.css +1 -1
  24. package/dist/mask.layered.css.map +2 -2
  25. package/dist/masonry.esm.js +22 -7
  26. package/dist/masonry.esm.js.map +2 -2
  27. package/dist/masonry.global.js +22 -7
  28. package/dist/masonry.global.js.map +2 -2
  29. package/dist/masonry.global.min.js +2 -2
  30. package/dist/masonry.global.min.js.map +3 -3
  31. package/dist/scroll.esm.js +26 -11
  32. package/dist/scroll.esm.js.map +2 -2
  33. package/dist/scroll.global.js +26 -11
  34. package/dist/scroll.global.js.map +2 -2
  35. package/dist/scroll.global.min.js +2 -2
  36. package/dist/scroll.global.min.js.map +3 -3
  37. package/dist/toast.css +1 -1
  38. package/dist/toast.css.map +2 -2
  39. package/dist/toast.esm.js +25 -7
  40. package/dist/toast.esm.js.map +2 -2
  41. package/dist/toast.global.js +25 -7
  42. package/dist/toast.global.js.map +2 -2
  43. package/dist/toast.global.min.js +2 -2
  44. package/dist/toast.global.min.js.map +3 -3
  45. package/dist/toast.layered.css +1 -1
  46. package/dist/toast.layered.css.map +2 -2
  47. package/dist/types/common/AuditableComponent.d.ts +3 -3
  48. package/dist/types/mask/AmountEngine.d.ts +8 -0
  49. package/dist/types/mask/BaseInputMask.d.ts +18 -0
  50. package/dist/types/mask/DateUTCEngine.d.ts +187 -0
  51. package/dist/types/mask/InputAmountMask.d.ts +5 -0
  52. package/dist/types/mask/InputDateUTCMask.d.ts +110 -0
  53. package/dist/types/mask/InputEmailMask.d.ts +7 -0
  54. package/dist/types/mask/InputMask.d.ts +7 -5
  55. package/dist/types/mask/MaskEngine.d.ts +39 -7
  56. package/dist/types/mask/index.d.ts +12 -6
  57. package/dist/types/mask/paste.d.ts +18 -0
  58. package/dist/types/mask/types.d.ts +27 -2
  59. package/package.json +1 -1
package/dist/mask.esm.js CHANGED
@@ -16,6 +16,14 @@ function safeCssEscape(value) {
16
16
  }
17
17
  return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
18
18
  }
19
+ function getDeepActiveElement(root) {
20
+ if (typeof document === "undefined") return null;
21
+ let active = (root ?? document).activeElement;
22
+ while (active && active.shadowRoot && active.shadowRoot.activeElement) {
23
+ active = active.shadowRoot.activeElement;
24
+ }
25
+ return active && typeof active.focus === "function" ? active : null;
26
+ }
19
27
  function safeMove(parent, node, referenceNode = null) {
20
28
  const moveBefore = parent.moveBefore;
21
29
  if (typeof moveBefore === "function" && node.isConnected && parent.isConnected && typeof parent.getRootNode === "function" && typeof node.getRootNode === "function" && parent.getRootNode() === node.getRootNode()) {
@@ -58,27 +66,52 @@ var AuditableComponent = class {
58
66
  return warnings;
59
67
  }
60
68
  /**
61
- * Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby)
62
- * pointe vers des éléments réellement présents dans le document.
69
+ * Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby, aria-errormessage)
70
+ * pointe vers des éléments réellement présents dans le document (et optionnellement non vides).
63
71
  */
64
- checkAriaIdReferences(element, attrName, warnings) {
72
+ checkAriaIdReferences(element, attrName, warnings, requireNonEmptyText = false) {
65
73
  const rawValue = element.getAttribute(attrName)?.trim();
66
74
  if (!rawValue) return false;
67
75
  const doc = element.ownerDocument || document;
68
76
  const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
69
77
  const ids = rawValue.split(/\s+/).filter(Boolean);
70
- const isValid = ids.length > 0 && ids.every(
71
- (id) => Boolean(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id))
78
+ const targets = ids.map(
79
+ (id) => typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id)
72
80
  );
73
- if (!isValid) {
81
+ const allFound = ids.length > 0 && targets.every((el) => Boolean(el));
82
+ if (!allFound) {
74
83
  warnings.push(
75
84
  `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
76
85
  );
86
+ return false;
87
+ }
88
+ if (requireNonEmptyText) {
89
+ const hasNonEmptyText = targets.some((el) => {
90
+ if (!el) return false;
91
+ const text = el.textContent?.trim() || el.getAttribute("aria-label")?.trim() || "";
92
+ return text.length > 0;
93
+ });
94
+ if (!hasNonEmptyText) {
95
+ warnings.push(
96
+ `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`
97
+ );
98
+ return false;
99
+ }
77
100
  }
78
- return isValid;
101
+ return true;
79
102
  }
80
103
  };
81
104
 
105
+ // src/mask/paste.ts
106
+ var MAX_PASTE_LENGTH = 4096;
107
+ function stripBidiAndInvisibles(raw, maxLength = MAX_PASTE_LENGTH) {
108
+ const safeLimit = Math.max(0, maxLength);
109
+ return String(raw ?? "").slice(0, safeLimit).replace(/[\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g, "");
110
+ }
111
+ function sanitizePastedText(raw, maxLength = MAX_PASTE_LENGTH) {
112
+ return stripBidiAndInvisibles(raw, maxLength).replace(/[\u00A0\u202F\u2007]/g, " ").replace(/[\u2013\u2014\u2212]/g, "-").trim();
113
+ }
114
+
82
115
  // src/mask/BaseInputMask.ts
83
116
  var VALID_ALIGNS = /* @__PURE__ */ new Set(["left", "right", "center"]);
84
117
  function resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, maybeOptions) {
@@ -116,6 +149,7 @@ var BaseInputMask = class extends AuditableComponent {
116
149
  };
117
150
  onFormResetHandler;
118
151
  mutationObserver = null;
152
+ resizeObserver = null;
119
153
  focusSelectTimerId = null;
120
154
  abortController = new AbortController();
121
155
  constructor(targetOrWrapper, inputOrOptions, maybeOptions) {
@@ -131,7 +165,7 @@ var BaseInputMask = class extends AuditableComponent {
131
165
  if (!effectiveWrapper && shouldCreateWrapper) {
132
166
  const doc = this.input.ownerDocument || document;
133
167
  const span = doc.createElement("span");
134
- span.className = "wulf-mask-wrapper";
168
+ span.className = "wulf-mask-wrapper wulf-mask-wrapper--auto";
135
169
  if (this.input.parentNode) {
136
170
  this.input.parentNode.insertBefore(span, this.input);
137
171
  }
@@ -161,21 +195,24 @@ var BaseInputMask = class extends AuditableComponent {
161
195
  const dataDisabled = this.hasAttr("data-disabled");
162
196
  const dataSelectAll = this.getAttr("data-mask-select-on-focus") === "true";
163
197
  const dataCopyRaw = this.getAttr("data-mask-copy-raw") === "true";
198
+ const dataSensitive = this.getAttr("data-mask-sensitive") === "true";
164
199
  const rawDataAlign = this.getAttr("data-mask-align") || this.getAttr("data-align");
165
200
  const dataAlign = rawDataAlign && VALID_ALIGNS.has(rawDataAlign) ? rawDataAlign : null;
166
201
  this.hadInitialDataAlign = this.wrapper.hasAttribute("data-align");
167
202
  const dataAudit = this.getAttr("data-mask-audit");
168
- const { disabled: optDisabled, align: optAlign, ...otherOptions } = options;
203
+ const { disabled: optDisabled, align: optAlign, sensitive: optSensitive, ...otherOptions } = options;
169
204
  const validOptAlign = optAlign && VALID_ALIGNS.has(optAlign) ? optAlign : void 0;
170
205
  const resolvedDisabled = optDisabled !== void 0 ? optDisabled : dataDisabled ? true : false;
171
206
  const resolvedAudit = options.audit ?? (dataAudit !== null ? dataAudit !== "false" : true);
172
- const isPassword = this.isPasswordInput();
207
+ const resolvedSensitive = Boolean(optSensitive ?? dataSensitive);
208
+ const isSensitive = this.isPasswordInput() || resolvedSensitive;
173
209
  this.options = {
174
210
  ...otherOptions,
175
211
  createWrapper: shouldCreateWrapper,
176
212
  showMaskOnFocus: options.showMaskOnFocus ?? dataFocusOnly ?? false,
177
213
  selectAllOnFocus: options.selectAllOnFocus ?? dataSelectAll ?? false,
178
- copyRaw: isPassword ? false : options.copyRaw ?? dataCopyRaw ?? false,
214
+ copyRaw: isSensitive ? false : options.copyRaw ?? dataCopyRaw ?? false,
215
+ sensitive: resolvedSensitive,
179
216
  disabled: resolvedDisabled,
180
217
  align: validOptAlign ?? (dataAlign || void 0),
181
218
  emitNativeInput: options.emitNativeInput ?? true,
@@ -230,7 +267,7 @@ var BaseInputMask = class extends AuditableComponent {
230
267
  this.input.addEventListener("blur", this.onBaseBlur, { signal });
231
268
  }
232
269
  onBaseCopy = (e) => {
233
- if (!this.options.copyRaw || this.options.disabled || this.input.type === "password") return;
270
+ if (!this.options.copyRaw || this.options.disabled || this.isSensitiveField()) return;
234
271
  const start = this.input.selectionStart ?? 0;
235
272
  const end = this.input.selectionEnd ?? start;
236
273
  let textToCopy = "";
@@ -250,6 +287,30 @@ var BaseInputMask = class extends AuditableComponent {
250
287
  extractRawSnippet(snippet) {
251
288
  return snippet;
252
289
  }
290
+ /**
291
+ * Extrait de manière compatible le texte brut du presse-papier lors d'un événement paste.
292
+ */
293
+ getClipboardPlainText(e) {
294
+ if (!e.clipboardData) return "";
295
+ return e.clipboardData.getData("text") || e.clipboardData.getData("text/plain") || "";
296
+ }
297
+ /**
298
+ * Applique l'hygiène Unicode O(N) puis le hook optionnel transformPaste de façon sécurisée et bornée.
299
+ */
300
+ preparePastedText(rawClipboard, maxLength = MAX_PASTE_LENGTH) {
301
+ const sanitized = sanitizePastedText(rawClipboard, maxLength);
302
+ if (typeof this.options.transformPaste !== "function") {
303
+ return sanitized;
304
+ }
305
+ try {
306
+ const transformed = this.options.transformPaste(sanitized);
307
+ if (typeof transformed === "string") {
308
+ return sanitizePastedText(transformed, maxLength);
309
+ }
310
+ } catch {
311
+ }
312
+ return sanitized;
313
+ }
253
314
  onBaseFocus = () => {
254
315
  this.isFocused = true;
255
316
  if (this.options.selectAllOnFocus && this.input.value.length > 0) {
@@ -258,7 +319,7 @@ var BaseInputMask = class extends AuditableComponent {
258
319
  }
259
320
  this.focusSelectTimerId = window.setTimeout(() => {
260
321
  this.focusSelectTimerId = null;
261
- if (!this.isDestroyed && document.activeElement === this.input) {
322
+ if (!this.isDestroyed && getDeepActiveElement(this.input.ownerDocument) === this.input) {
262
323
  this.input.select();
263
324
  }
264
325
  }, 0);
@@ -266,7 +327,7 @@ var BaseInputMask = class extends AuditableComponent {
266
327
  };
267
328
  onBaseBlur = () => {
268
329
  this.isFocused = false;
269
- if (this.isPasswordInput()) {
330
+ if (this.isSensitiveField()) {
270
331
  this.lastTrackedValue = "";
271
332
  this.clearGhost();
272
333
  this.wrapper.removeAttribute("data-mask");
@@ -293,11 +354,14 @@ var BaseInputMask = class extends AuditableComponent {
293
354
  "data-mask-strict",
294
355
  "data-mask-select-on-focus",
295
356
  "data-mask-copy-raw",
357
+ "data-mask-sensitive",
296
358
  "data-mask-pad-decimals",
297
359
  "data-mask-auto-lowercase",
298
360
  "data-mask-cycle-suggestions",
299
361
  "data-mask-default-tld",
300
362
  "data-mask-tlds",
363
+ "data-mask-format",
364
+ "data-mask-utc-indicator",
301
365
  "data-disabled",
302
366
  "data-mask-align",
303
367
  "data-align",
@@ -316,6 +380,12 @@ var BaseInputMask = class extends AuditableComponent {
316
380
  isPasswordInput() {
317
381
  return (this.input.type || "").toLowerCase() === "password";
318
382
  }
383
+ /**
384
+ * Indique si le champ relève du sanctuaire confidentiel (type="password" ou option sensitive: true).
385
+ */
386
+ isSensitiveField() {
387
+ return this.isPasswordInput() || Boolean(this.options.sensitive);
388
+ }
319
389
  /**
320
390
  * Calcule une empreinte non réversible pour détecter les changements sans conserver de secret en RAM.
321
391
  */
@@ -370,9 +440,19 @@ var BaseInputMask = class extends AuditableComponent {
370
440
  } else if (attrName === "data-mask-select-on-focus") {
371
441
  this.options.selectAllOnFocus = this.getAttr("data-mask-select-on-focus") === "true";
372
442
  } else if (attrName === "data-mask-copy-raw") {
373
- this.options.copyRaw = this.isPasswordInput() ? false : this.getAttr("data-mask-copy-raw") === "true";
443
+ this.options.copyRaw = this.isSensitiveField() ? false : this.getAttr("data-mask-copy-raw") === "true";
444
+ } else if (attrName === "data-mask-sensitive") {
445
+ const nextSensitive = this.getAttr("data-mask-sensitive") === "true";
446
+ this.options.sensitive = nextSensitive;
447
+ if (this.isSensitiveField()) {
448
+ this.options.copyRaw = false;
449
+ this.lastTrackedValue = "";
450
+ this.clearGhost();
451
+ this.wrapper.removeAttribute("data-mask");
452
+ this.onPasswordModeDetected();
453
+ }
374
454
  } else if (attrName === "type") {
375
- if (this.isPasswordInput()) {
455
+ if (this.isSensitiveField()) {
376
456
  this.options.copyRaw = false;
377
457
  this.lastTrackedValue = "";
378
458
  this.clearGhost();
@@ -423,6 +503,24 @@ var BaseInputMask = class extends AuditableComponent {
423
503
  this.ghost.style.pointerEvents = "none";
424
504
  }
425
505
  this.syncGhostStyles();
506
+ if (typeof ResizeObserver !== "undefined") {
507
+ this.resizeObserver?.disconnect();
508
+ this.resizeObserver = new ResizeObserver(() => {
509
+ if (!this.isDestroyed) {
510
+ this.syncGhostStyles();
511
+ }
512
+ });
513
+ this.resizeObserver.observe(this.input);
514
+ }
515
+ const docWithFonts = doc;
516
+ if (docWithFonts.fonts?.ready && typeof docWithFonts.fonts.ready.then === "function") {
517
+ docWithFonts.fonts.ready.then(() => {
518
+ if (!this.isDestroyed) {
519
+ this.syncGhostStyles();
520
+ }
521
+ }).catch(() => {
522
+ });
523
+ }
426
524
  }
427
525
  /**
428
526
  * Met à jour atomiquement le contenu du conteneur fantôme et synchronise .has-visible-ghost.
@@ -459,6 +557,10 @@ var BaseInputMask = class extends AuditableComponent {
459
557
  this.ghost.style.fontWeight = style.fontWeight;
460
558
  this.ghost.style.fontStyle = style.fontStyle;
461
559
  this.ghost.style.letterSpacing = style.letterSpacing;
560
+ this.ghost.style.wordSpacing = style.wordSpacing;
561
+ this.ghost.style.textIndent = style.textIndent;
562
+ this.ghost.style.fontKerning = style.fontKerning;
563
+ this.ghost.style.fontVariantNumeric = style.fontVariantNumeric;
462
564
  this.ghost.style.lineHeight = style.lineHeight;
463
565
  this.ghost.style.paddingTop = style.paddingTop;
464
566
  this.ghost.style.paddingBottom = style.paddingBottom;
@@ -510,11 +612,12 @@ var BaseInputMask = class extends AuditableComponent {
510
612
  if (this.options.emitNativeInput === false) return;
511
613
  this.isDispatchingNativeInput = true;
512
614
  try {
615
+ const isSensitive = this.isSensitiveField();
513
616
  const tracker = this.input._valueTracker;
514
- if (!this.isPasswordInput() && tracker && typeof tracker.setValue === "function") {
617
+ if (!isSensitive && tracker && typeof tracker.setValue === "function") {
515
618
  tracker.setValue(this.lastTrackedValue);
516
619
  }
517
- this.lastTrackedValue = this.isPasswordInput() ? "" : this.input.value;
620
+ this.lastTrackedValue = isSensitive ? "" : this.input.value;
518
621
  this.input.dispatchEvent(new Event("input", { bubbles: true, cancelable: false }));
519
622
  } finally {
520
623
  this.isDispatchingNativeInput = false;
@@ -632,6 +735,37 @@ var BaseInputMask = class extends AuditableComponent {
632
735
  getRawValue() {
633
736
  return this.input.value;
634
737
  }
738
+ /**
739
+ * Vérifie qu'un élément <label> possède un nom accessible non vide,
740
+ * en ignorant le texte éventuel des contrôles enfants (<input>, <select>, <textarea>, <button>).
741
+ */
742
+ hasAccessibleLabelText(labelEl) {
743
+ if (!labelEl) return false;
744
+ const ariaLabel = labelEl.getAttribute("aria-label")?.trim();
745
+ if (ariaLabel) return true;
746
+ const collectText = (node) => {
747
+ if (node.nodeType === 3) {
748
+ return node.textContent || "";
749
+ }
750
+ if (node.nodeType === 1) {
751
+ const el = node;
752
+ const tag = el.tagName;
753
+ if (tag === "INPUT" || tag === "SELECT" || tag === "TEXTAREA" || tag === "BUTTON") {
754
+ return "";
755
+ }
756
+ if (el.getAttribute("aria-hidden") === "true") {
757
+ return "";
758
+ }
759
+ let acc = "";
760
+ for (let i = 0; i < el.childNodes.length; i++) {
761
+ acc += collectText(el.childNodes[i]);
762
+ }
763
+ return acc;
764
+ }
765
+ return "";
766
+ };
767
+ return collectText(labelEl).trim().length > 0;
768
+ }
635
769
  /**
636
770
  * Vérifie la conformité d'accessibilité WAI-ARIA du champ de saisie (étiquetage, format attendu)
637
771
  * et retourne la liste des contraintes manquantes.
@@ -642,23 +776,39 @@ var BaseInputMask = class extends AuditableComponent {
642
776
  const root = typeof this.input.getRootNode === "function" ? this.input.getRootNode() : doc;
643
777
  const labelRoot = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : doc;
644
778
  const ariaLabel = this.input.getAttribute("aria-label")?.trim();
645
- const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings);
646
- const hasWrappingLabel = Boolean(this.input.closest("label"));
647
- const hasNativeLabels = Boolean(this.input.labels && this.input.labels.length > 0);
779
+ const hasValidLabelledby = this.checkAriaIdReferences(this.input, "aria-labelledby", warnings, true);
780
+ const wrappingLabel = this.input.closest("label");
781
+ const hasWrappingLabel = this.hasAccessibleLabelText(wrappingLabel);
782
+ const hasNativeLabels = Boolean(
783
+ this.input.labels && Array.from(this.input.labels).some((lbl) => this.hasAccessibleLabelText(lbl))
784
+ );
648
785
  let hasExplicitLabelFor = false;
649
786
  if (this.input.id) {
650
787
  try {
651
- hasExplicitLabelFor = Boolean(labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`));
788
+ const explicitLabel = labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`);
789
+ hasExplicitLabelFor = this.hasAccessibleLabelText(explicitLabel);
652
790
  } catch {
653
791
  hasExplicitLabelFor = false;
654
792
  }
655
793
  }
656
794
  if (!ariaLabel && !hasValidLabelledby && !hasWrappingLabel && !hasNativeLabels && !hasExplicitLabelFor) {
657
795
  warnings.push(
658
- `\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`
796
+ `\xC9tiquetage accessible manquant : associez un <label for="id"> non vide (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`
659
797
  );
660
798
  }
661
- this.checkAriaIdReferences(this.input, "aria-describedby", warnings);
799
+ this.checkAriaIdReferences(this.input, "aria-describedby", warnings, true);
800
+ if (this.input.hasAttribute("aria-errormessage")) {
801
+ this.checkAriaIdReferences(this.input, "aria-errormessage", warnings, true);
802
+ }
803
+ const rawTabIndex = this.input.getAttribute("tabindex");
804
+ if (rawTabIndex !== null) {
805
+ const parsedTabIndex = Number.parseInt(rawTabIndex, 10);
806
+ if (Number.isFinite(parsedTabIndex) && parsedTabIndex > 0) {
807
+ warnings.push(
808
+ `Attribut tabindex="${rawTabIndex}" positif d\xE9tect\xE9 : \xE9vitez les tabindex > 0 qui perturbent l'ordre de tabulation naturel (WCAG 2.4.3).`
809
+ );
810
+ }
811
+ }
662
812
  const extraWarnings = this.getSpecificAuditWarnings();
663
813
  warnings.push(...extraWarnings);
664
814
  return warnings;
@@ -697,6 +847,10 @@ var BaseInputMask = class extends AuditableComponent {
697
847
  this.mutationObserver.disconnect();
698
848
  this.mutationObserver = null;
699
849
  }
850
+ if (this.resizeObserver) {
851
+ this.resizeObserver.disconnect();
852
+ this.resizeObserver = null;
853
+ }
700
854
  this.abortController.abort();
701
855
  this.lastTrackedValue = "";
702
856
  this.unhookValueProperty();
@@ -737,6 +891,7 @@ var BaseInputMask = class extends AuditableComponent {
737
891
  };
738
892
 
739
893
  // src/mask/MaskEngine.ts
894
+ var SEGMENT_SEPARATORS = /* @__PURE__ */ new Set(["/", "-", ".", ":"]);
740
895
  var DEFAULT_TOKENS = {
741
896
  "9": { pattern: /[0-9]/ },
742
897
  "a": { pattern: /[a-zA-Z]/ },
@@ -747,6 +902,8 @@ var DEFAULT_TOKENS = {
747
902
  var MaskEngine = class _MaskEngine {
748
903
  pattern;
749
904
  patterns = [];
905
+ patternResolver = null;
906
+ lastResolvedKey = "";
750
907
  subEngines = [];
751
908
  activeEngine = null;
752
909
  placeholderChar;
@@ -783,7 +940,7 @@ var MaskEngine = class _MaskEngine {
783
940
  * Fonction statique utilitaire permettant un formatage direct sans instanciation manuelle.
784
941
  *
785
942
  * @param value Valeur à formater (brute ou partiellement formatée)
786
- * @param pattern Masque à appliquer (ex: "99 99 99 99 99" ou tableau de masques)
943
+ * @param pattern Masque à appliquer (ex: "99 99 99 99 99", tableau de masques ou résolveur dynamique)
787
944
  * @param options Options facultatives (placeholderChar, tokens, strict, autoLowercase)
788
945
  * @returns La valeur formatée selon le masque
789
946
  */
@@ -793,17 +950,69 @@ var MaskEngine = class _MaskEngine {
793
950
  return engine.format(value ?? "");
794
951
  }
795
952
  /**
796
- * Analyse le ou les gabarits statiques et compile la liste des slots.
953
+ * Indique si le gabarit repose sur une fonction résolveuse dynamique.
954
+ */
955
+ isDynamicPattern() {
956
+ return this.patternResolver !== null;
957
+ }
958
+ /**
959
+ * Résout et compile si besoin le gabarit dynamique pour la valeur fournie (avec mémoïsation).
960
+ */
961
+ resolveForValue(input) {
962
+ if (!this.patternResolver) return false;
963
+ let resolved;
964
+ try {
965
+ resolved = this.patternResolver(String(input ?? "").slice(0, 4096));
966
+ } catch {
967
+ return false;
968
+ }
969
+ let normalized;
970
+ let key;
971
+ if (Array.isArray(resolved)) {
972
+ normalized = resolved.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
973
+ key = "A:" + normalized.join("\0");
974
+ } else if (typeof resolved === "string") {
975
+ normalized = resolved.slice(0, 512);
976
+ key = "S:" + normalized;
977
+ } else {
978
+ return false;
979
+ }
980
+ if (key === this.lastResolvedKey) {
981
+ return false;
982
+ }
983
+ this.lastResolvedKey = key;
984
+ this.compileStatic(normalized);
985
+ return true;
986
+ }
987
+ /**
988
+ * Analyse le ou les gabarits (statiques ou résolus dynamiquement) et compile la liste des slots.
797
989
  */
798
990
  compile(newPattern) {
991
+ if (typeof newPattern === "function") {
992
+ this.patternResolver = newPattern;
993
+ this.lastResolvedKey = "";
994
+ this.resolveForValue("");
995
+ return this.slots;
996
+ }
799
997
  if (newPattern !== void 0) {
800
- if (Array.isArray(newPattern)) {
801
- this.patterns = newPattern.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
802
- this.pattern = this.patterns[0] || "";
803
- } else {
804
- this.patterns = [];
805
- this.pattern = String(newPattern ?? "").slice(0, 512);
806
- }
998
+ this.patternResolver = null;
999
+ this.lastResolvedKey = "";
1000
+ return this.compileStatic(newPattern);
1001
+ }
1002
+ if (this.patternResolver) {
1003
+ this.lastResolvedKey = "";
1004
+ this.resolveForValue("");
1005
+ return this.slots;
1006
+ }
1007
+ return this.compileStatic(this.patterns.length > 0 ? this.patterns : this.pattern);
1008
+ }
1009
+ compileStatic(newPattern) {
1010
+ if (Array.isArray(newPattern)) {
1011
+ this.patterns = newPattern.slice(0, 32).map((p) => String(p ?? "").slice(0, 512));
1012
+ this.pattern = this.patterns[0] || "";
1013
+ } else {
1014
+ this.patterns = [];
1015
+ this.pattern = String(newPattern ?? "").slice(0, 512);
807
1016
  }
808
1017
  if (this.patterns.length > 0) {
809
1018
  this.subEngines = this.patterns.map((p) => new _MaskEngine(p, {
@@ -835,14 +1044,15 @@ var MaskEngine = class _MaskEngine {
835
1044
  const token = !isEscaped && Object.hasOwn(this.tokens, char) ? this.tokens[char] : void 0;
836
1045
  if (token) {
837
1046
  isPrefixMode = false;
1047
+ const slotPlaceholder = token.placeholder ? Array.from(String(token.placeholder))[0] || this.placeholderChar : this.placeholderChar;
838
1048
  this.slots.push({
839
1049
  char,
840
1050
  isStatic: false,
841
1051
  isPrefix: false,
842
1052
  token,
843
- placeholder: this.placeholderChar
1053
+ placeholder: slotPlaceholder
844
1054
  });
845
- templateBuilder += this.placeholderChar;
1055
+ templateBuilder += slotPlaceholder;
846
1056
  } else {
847
1057
  this.slots.push({
848
1058
  char,
@@ -910,13 +1120,29 @@ var MaskEngine = class _MaskEngine {
910
1120
  return this.activeEngine ? this.activeEngine.getFullMaskTemplate() : this.fullMaskTemplate;
911
1121
  }
912
1122
  /**
913
- * Nombre total de positions éditables dans le masque.
1123
+ * Nombre total de positions éditables du sous-moteur actif (pour isComplete et detail.totalSlots).
914
1124
  */
915
- getEditableCount() {
1125
+ getActiveEditableCount() {
1126
+ if (this.subEngines.length > 0) {
1127
+ const target = this.activeEngine ?? this.subEngines[0];
1128
+ return target.getActiveEditableCount();
1129
+ }
1130
+ return this.activeEngine ? this.activeEngine.getActiveEditableCount() : this.slots.filter((s) => !s.isStatic).length;
1131
+ }
1132
+ /**
1133
+ * Capacité maximale de positions éditables parmi les gabarits configurés (pour le blocage de frappe / collage).
1134
+ */
1135
+ getMaxEditableCount() {
916
1136
  if (this.subEngines.length > 0) {
917
- return Math.max(...this.subEngines.map((e) => e.getEditableCount()));
1137
+ return Math.max(...this.subEngines.map((e) => e.getMaxEditableCount()));
918
1138
  }
919
- return this.activeEngine ? this.activeEngine.getEditableCount() : this.slots.filter((s) => !s.isStatic).length;
1139
+ return this.getActiveEditableCount();
1140
+ }
1141
+ /**
1142
+ * Capacité maximale totale de positions éditables dans le masque (alias rétrocompatible de getMaxEditableCount).
1143
+ */
1144
+ getEditableCount() {
1145
+ return this.getMaxEditableCount();
920
1146
  }
921
1147
  /**
922
1148
  * Indique si tous les emplacements éditables du masque acceptent exclusivement des chiffres numériques.
@@ -954,15 +1180,199 @@ var MaskEngine = class _MaskEngine {
954
1180
  isStrict() {
955
1181
  return this.strict;
956
1182
  }
1183
+ /**
1184
+ * Normalise une chaîne issue du presse-papier en alignant et complétant à gauche par '0'
1185
+ * les segments numériques courts lorsque la structure correspond sans ambiguïté au gabarit.
1186
+ * N'altère jamais extractRaw() ni la saisie clavier.
1187
+ */
1188
+ normalizePastedValue(pasted) {
1189
+ const rawPasted = String(pasted ?? "");
1190
+ if (!rawPasted) return rawPasted;
1191
+ this.resolveForValue(rawPasted);
1192
+ if (this.subEngines.length > 0) {
1193
+ const lowerPasted = rawPasted.toLowerCase();
1194
+ const withMatchingPrefix = this.subEngines.filter((e) => {
1195
+ const p = e.getPrefix();
1196
+ return p.length > 0 && lowerPasted.startsWith(p.trim().toLowerCase());
1197
+ });
1198
+ const candidates = withMatchingPrefix.length > 0 ? withMatchingPrefix : this.subEngines;
1199
+ let firstMatch = null;
1200
+ for (const eng of candidates) {
1201
+ const res = eng.tryNormalizeSegments(rawPasted);
1202
+ if (res.matched) {
1203
+ if (res.exactSegmentCount) {
1204
+ return res.normalized;
1205
+ }
1206
+ if (firstMatch === null) {
1207
+ firstMatch = res.normalized;
1208
+ }
1209
+ }
1210
+ }
1211
+ return firstMatch !== null ? firstMatch : rawPasted;
1212
+ }
1213
+ return this.tryNormalizeSegments(rawPasted).normalized;
1214
+ }
1215
+ tryNormalizeSegments(pasted) {
1216
+ const fail = { matched: false, normalized: pasted, exactSegmentCount: false };
1217
+ if (!this.strict || this.slots.length === 0 || !pasted) {
1218
+ return fail;
1219
+ }
1220
+ let rest = pasted;
1221
+ if (this.prefixSlotsCount > 0) {
1222
+ let inputIdx = 0;
1223
+ while (inputIdx < pasted.length && (pasted[inputIdx] === " " || pasted[inputIdx] === " ")) {
1224
+ inputIdx++;
1225
+ }
1226
+ let pIdx = 0;
1227
+ while (inputIdx < pasted.length && pIdx < this.prefixSlotsCount) {
1228
+ const pChar = this.slots[pIdx].char;
1229
+ const inChar = pasted[inputIdx];
1230
+ if (inChar.toUpperCase() === pChar.toUpperCase()) {
1231
+ inputIdx++;
1232
+ pIdx++;
1233
+ } else if (pChar === " " && inChar !== " ") {
1234
+ pIdx++;
1235
+ } else {
1236
+ break;
1237
+ }
1238
+ }
1239
+ if (pIdx === this.prefixSlotsCount) {
1240
+ rest = pasted.slice(inputIdx);
1241
+ }
1242
+ }
1243
+ if (!rest) {
1244
+ return fail;
1245
+ }
1246
+ const segments = [];
1247
+ const separators = [];
1248
+ let currentSeg = [];
1249
+ let currentSep = "";
1250
+ let hasTrailingStatic = false;
1251
+ for (let i = this.prefixSlotsCount; i < this.slots.length; i++) {
1252
+ const slot = this.slots[i];
1253
+ if (slot.isStatic) {
1254
+ if (currentSeg.length > 0) {
1255
+ segments.push(currentSeg);
1256
+ currentSeg = [];
1257
+ currentSep = slot.char;
1258
+ } else {
1259
+ currentSep += slot.char;
1260
+ }
1261
+ } else {
1262
+ if (currentSep.length > 0) {
1263
+ separators.push(currentSep);
1264
+ currentSep = "";
1265
+ }
1266
+ currentSeg.push(slot);
1267
+ }
1268
+ }
1269
+ if (currentSeg.length > 0) {
1270
+ segments.push(currentSeg);
1271
+ } else if (currentSep.length > 0) {
1272
+ hasTrailingStatic = true;
1273
+ }
1274
+ if (hasTrailingStatic || segments.length < 2 || separators.length !== segments.length - 1) {
1275
+ return fail;
1276
+ }
1277
+ const coreSeps = [];
1278
+ for (const sep of separators) {
1279
+ const core = sep.trim();
1280
+ if (core.length !== 1 || !SEGMENT_SEPARATORS.has(core)) {
1281
+ return fail;
1282
+ }
1283
+ coreSeps.push(core);
1284
+ }
1285
+ const parts = [];
1286
+ const foundSeps = [];
1287
+ let blockStart = 0;
1288
+ for (let i = 0; i < rest.length; i++) {
1289
+ const ch = rest[i];
1290
+ if (SEGMENT_SEPARATORS.has(ch)) {
1291
+ parts.push(rest.slice(blockStart, i).trim());
1292
+ foundSeps.push(ch);
1293
+ blockStart = i + 1;
1294
+ }
1295
+ }
1296
+ parts.push(rest.slice(blockStart).trim());
1297
+ if (foundSeps.length === 0 || foundSeps.length > coreSeps.length) {
1298
+ return fail;
1299
+ }
1300
+ if (parts.length !== foundSeps.length + 1 || parts.length > segments.length || parts.some((p) => p.length === 0)) {
1301
+ return fail;
1302
+ }
1303
+ const matchesMaskOrder = foundSeps.every((sep, idx) => sep === coreSeps[idx]);
1304
+ const isHomogeneous = foundSeps.every((sep) => sep === foundSeps[0]);
1305
+ if (!matchesMaskOrder && !isHomogeneous) {
1306
+ return fail;
1307
+ }
1308
+ const exactSegmentCount = parts.length === segments.length;
1309
+ const paddedParts = [];
1310
+ for (let i = 0; i < parts.length; i++) {
1311
+ const part = parts[i];
1312
+ const segSlots = segments[i];
1313
+ if (part.length > segSlots.length) {
1314
+ return fail;
1315
+ }
1316
+ const isNumericSeg = segSlots.every(
1317
+ (s) => Boolean(s.token && s.token.pattern.test("0") && !s.token.pattern.test("a") && !s.token.pattern.test("Z"))
1318
+ );
1319
+ if (isNumericSeg) {
1320
+ const isClosedBySep = i < parts.length - 1;
1321
+ const isTerminalTwoDigitEligible = i === parts.length - 1 && exactSegmentCount && segments.length <= 3 && segSlots.length === 2;
1322
+ const shouldPad = part.length < segSlots.length && (isClosedBySep || isTerminalTwoDigitEligible);
1323
+ const offset = shouldPad ? segSlots.length - part.length : 0;
1324
+ for (let k = 0; k < part.length; k++) {
1325
+ const ch = part[k];
1326
+ if (ch < "0" || ch > "9" || !segSlots[offset + k].token.pattern.test(ch)) {
1327
+ return fail;
1328
+ }
1329
+ }
1330
+ paddedParts.push(shouldPad ? "0".repeat(segSlots.length - part.length) + part : part);
1331
+ } else {
1332
+ if (part.length !== segSlots.length) {
1333
+ return fail;
1334
+ }
1335
+ for (let k = 0; k < part.length; k++) {
1336
+ if (!segSlots[k].token || !segSlots[k].token.pattern.test(part[k])) {
1337
+ return fail;
1338
+ }
1339
+ }
1340
+ paddedParts.push(part);
1341
+ }
1342
+ }
1343
+ let normalized = this.prefixSlotsCount > 0 ? this.prefixString : "";
1344
+ for (let i = 0; i < paddedParts.length; i++) {
1345
+ if (i > 0) {
1346
+ normalized += separators[i - 1];
1347
+ }
1348
+ normalized += paddedParts[i];
1349
+ }
1350
+ return {
1351
+ matched: true,
1352
+ normalized,
1353
+ exactSegmentCount
1354
+ };
1355
+ }
1356
+ /**
1357
+ * Filtre et extrait les caractères éditables sans déclencher de ré-évaluation dynamique du gabarit.
1358
+ * Utile pour mesurer une sélection partielle ou mapper le curseur sans effet de bord.
1359
+ */
1360
+ extractRawForCurrentPattern(input) {
1361
+ return this.extractRawInternal(input);
1362
+ }
957
1363
  /**
958
1364
  * Filtre et extrait uniquement les caractères éditables valides d'une chaîne.
959
1365
  * Gère intelligemment la présence ou l'absence des séparateurs statiques et du préfixe.
960
1366
  */
961
1367
  extractRaw(input) {
1368
+ this.resolveForValue(input);
1369
+ return this.extractRawInternal(input);
1370
+ }
1371
+ extractRawInternal(input) {
962
1372
  if (this.subEngines.length > 0) {
963
1373
  const engine = this.selectEngine(input);
964
1374
  if (engine !== this) {
965
- return engine.extractRaw(input);
1375
+ return engine.extractRawInternal(input);
966
1376
  }
967
1377
  }
968
1378
  const maxInputLen = Math.max(4096, this.slots.length * 4);
@@ -1029,6 +1439,7 @@ var MaskEngine = class _MaskEngine {
1029
1439
  * Si aucune donnée éditable n'est présente, retourne le préfixe statique fixe s'il existe.
1030
1440
  */
1031
1441
  format(rawValue) {
1442
+ this.resolveForValue(rawValue);
1032
1443
  if (this.subEngines.length > 0) {
1033
1444
  const engine = this.selectEngine(rawValue);
1034
1445
  if (engine !== this) {
@@ -1038,7 +1449,7 @@ var MaskEngine = class _MaskEngine {
1038
1449
  const maxInputLen = Math.max(4096, this.slots.length * 4);
1039
1450
  const rawStr = String(rawValue ?? "").slice(0, maxInputLen);
1040
1451
  if (!this.slots.length) return rawStr;
1041
- const cleanRaw = this.extractRaw(rawStr);
1452
+ const cleanRaw = this.extractRawInternal(rawStr);
1042
1453
  if (cleanRaw.length === 0) {
1043
1454
  return this.prefixString;
1044
1455
  }
@@ -1100,7 +1511,7 @@ var MaskEngine = class _MaskEngine {
1100
1511
  const safeInput = String(inputValue ?? "");
1101
1512
  const safeFormatted = String(formatted ?? "");
1102
1513
  if (inputCursor <= 0 || !safeFormatted) return minPos;
1103
- const rawBeforeCursor = this.extractRaw(safeInput.slice(0, inputCursor));
1514
+ const rawBeforeCursor = this.extractRawInternal(safeInput.slice(0, inputCursor));
1104
1515
  const targetRawCount = rawBeforeCursor.length;
1105
1516
  if (targetRawCount === 0) {
1106
1517
  return Math.max(minPos, Math.min(this.getNextEditablePosition(0), safeFormatted.length));
@@ -1283,10 +1694,25 @@ var MaskKeyboard = class {
1283
1694
  if (isPrintableChar && !hasSelection) {
1284
1695
  const slots = engine.getSlots();
1285
1696
  const isAlreadyOnSep = cursor < slots.length && slots[cursor].isStatic && slots[cursor].char === e.key;
1286
- const isJustAfterSep = cursor > 0 && cursor - 1 < slots.length && slots[cursor - 1].isStatic && slots[cursor - 1].char === e.key;
1697
+ let justAfterSepIdx = -1;
1698
+ if (cursor > 0 && cursor - 1 < slots.length) {
1699
+ if (slots[cursor - 1].isStatic && slots[cursor - 1].char === e.key) {
1700
+ justAfterSepIdx = cursor - 1;
1701
+ } else {
1702
+ let k = cursor - 1;
1703
+ while (k >= minPos && slots[k].isStatic) {
1704
+ if (slots[k].char === e.key) {
1705
+ justAfterSepIdx = k;
1706
+ break;
1707
+ }
1708
+ k--;
1709
+ }
1710
+ }
1711
+ }
1712
+ const isJustAfterSep = justAfterSepIdx !== -1;
1287
1713
  if (isAlreadyOnSep || isJustAfterSep) {
1288
1714
  e.preventDefault();
1289
- const baseIdx = isAlreadyOnSep ? cursor : cursor - 1;
1715
+ const baseIdx = isAlreadyOnSep ? cursor : justAfterSepIdx;
1290
1716
  const nextEditable = engine.getNextEditablePosition(baseIdx + 1);
1291
1717
  this.delegate.applyMask(input.value, nextEditable, true);
1292
1718
  return;
@@ -1309,7 +1735,7 @@ var MaskKeyboard = class {
1309
1735
  segStart++;
1310
1736
  const segLength = nextSepIdx - segStart;
1311
1737
  const currentSegVal = input.value.slice(segStart, cursor);
1312
- const isNumericSegment = slots.slice(segStart, nextSepIdx).every((s) => !s.token || s.token.pattern.test("0"));
1738
+ const isNumericSegment = slots.slice(segStart, nextSepIdx).every((s) => Boolean(s.token && s.token.pattern.test("0") && !s.token.pattern.test("a") && !s.token.pattern.test("Z")));
1313
1739
  if (isNumericSegment && segLength > currentSegVal.length && currentSegVal.length > 0) {
1314
1740
  const missingCount = segLength - currentSegVal.length;
1315
1741
  const paddedSeg = "0".repeat(missingCount) + currentSegVal;
@@ -1325,19 +1751,27 @@ var MaskKeyboard = class {
1325
1751
  }
1326
1752
  }
1327
1753
  if (isPrintableChar && engine.isStrict()) {
1328
- const totalSlots = engine.getEditableCount();
1754
+ const isDynamic = engine.isDynamicPattern();
1755
+ const currentRaw = engine.extractRaw(input.value);
1756
+ const selectedRaw = selectionEnd > cursor ? engine.extractRawForCurrentPattern(input.value.slice(cursor, selectionEnd)) : "";
1757
+ if (isDynamic) {
1758
+ const candidate = input.value.slice(0, cursor) + e.key + input.value.slice(selectionEnd);
1759
+ engine.resolveForValue(candidate);
1760
+ }
1761
+ const totalSlots = engine.getMaxEditableCount();
1329
1762
  if (totalSlots > 0) {
1330
- const currentRaw = engine.extractRaw(input.value);
1331
- let availableCapacity = totalSlots - currentRaw.length;
1332
- if (selectionEnd > cursor) {
1333
- const selectedRaw = engine.extractRaw(input.value.slice(cursor, selectionEnd));
1334
- availableCapacity = totalSlots - (currentRaw.length - selectedRaw.length);
1335
- }
1763
+ const availableCapacity = totalSlots - (currentRaw.length - selectedRaw.length);
1336
1764
  if (availableCapacity <= 0) {
1765
+ if (isDynamic) {
1766
+ engine.resolveForValue(input.value);
1767
+ }
1337
1768
  e.preventDefault();
1338
1769
  return;
1339
1770
  }
1340
1771
  }
1772
+ if (isDynamic) {
1773
+ engine.resolveForValue(input.value);
1774
+ }
1341
1775
  }
1342
1776
  if (selectionEnd > cursor) {
1343
1777
  if (e.key === "Backspace" || e.key === "Delete") {
@@ -1476,6 +1910,7 @@ var InputMask = class extends BaseInputMask {
1476
1910
  cutTimerId = null;
1477
1911
  pasteTimerId = null;
1478
1912
  resetTimerId = null;
1913
+ lastInputType = "";
1479
1914
  constructor(targetOrWrapper, inputOrOptions, options) {
1480
1915
  const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
1481
1916
  const wrap = args.wrapper;
@@ -1526,20 +1961,26 @@ var InputMask = class extends BaseInputMask {
1526
1961
  enforceMinCursor: () => this.enforceMinCursor()
1527
1962
  });
1528
1963
  this.bindEvents();
1529
- this.lastValue = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
1964
+ this.lastValue = this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value;
1530
1965
  this.syncInitialValue();
1531
1966
  this.runAuditWarning(this.options.audit);
1532
1967
  }
1533
1968
  getSpecificAuditWarnings() {
1534
1969
  const warnings = [];
1535
1970
  const describedbyWarnings = [];
1536
- const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings);
1971
+ const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings, true);
1537
1972
  const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
1538
1973
  const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
1539
- if (!hasValidDescribedby && !hasPlaceholder && !hasAriaPlaceholder && !this.options.disabled) {
1540
- warnings.push(
1541
- "Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
1542
- );
1974
+ if (!hasValidDescribedby && !hasAriaPlaceholder && !this.options.disabled) {
1975
+ if (hasPlaceholder) {
1976
+ warnings.push(
1977
+ "Indication du format attendu fragile : l'attribut placeholder seul dispara\xEEt \xE0 la saisie et est masqu\xE9 par le gabarit fant\xF4me ; utilisez aria-describedby ou aria-placeholder (WCAG 3.3.2)."
1978
+ );
1979
+ } else {
1980
+ warnings.push(
1981
+ "Indication du format attendu manquante : d\xE9finissez aria-describedby ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."
1982
+ );
1983
+ }
1543
1984
  }
1544
1985
  return warnings;
1545
1986
  }
@@ -1558,7 +1999,7 @@ var InputMask = class extends BaseInputMask {
1558
1999
  * Formate statiquement une valeur selon un masque donné sans nécessiter d'élément DOM.
1559
2000
  *
1560
2001
  * @param value Valeur à formater (ex: "0123456789")
1561
- * @param mask Gabarit de masque (ex: "99 99 99 99 99")
2002
+ * @param mask Gabarit de masque (ex: "99 99 99 99 99", tableau ou résolveur dynamique)
1562
2003
  * @param options Options facultatives du masque (tokens, placeholderChar, strict, etc.)
1563
2004
  * @returns Valeur formatée (ex: "01 23 45 67 89")
1564
2005
  */
@@ -1569,7 +2010,8 @@ var InputMask = class extends BaseInputMask {
1569
2010
  if (this.options.disabled) {
1570
2011
  this.checkValueChange();
1571
2012
  } else {
1572
- this.applyMask(strVal, strVal.length);
2013
+ const transformed = this.applyTransformInput(strVal, "programmatic", "");
2014
+ this.applyMask(transformed, transformed.length);
1573
2015
  }
1574
2016
  }
1575
2017
  onDisabledChange(disabled) {
@@ -1746,10 +2188,13 @@ var InputMask = class extends BaseInputMask {
1746
2188
  super.handleAttributeMutation(attrName);
1747
2189
  if (attrName === "data-mask") {
1748
2190
  const rawAttr = this.getAttr("data-mask");
2191
+ if (rawAttr === null && (this.isSensitiveField() || typeof this.options.mask === "function")) {
2192
+ return;
2193
+ }
1749
2194
  if (rawAttr === this.lastInternalRemainingMask) {
1750
2195
  return;
1751
2196
  }
1752
- const currentMaskStr = Array.isArray(this.options.mask) ? this.options.mask.join("|") : this.options.mask || "";
2197
+ const currentMaskStr = typeof this.options.mask === "function" ? "" : Array.isArray(this.options.mask) ? this.options.mask.join("|") : this.options.mask || "";
1753
2198
  if (rawAttr === currentMaskStr) {
1754
2199
  return;
1755
2200
  }
@@ -1771,6 +2216,19 @@ var InputMask = class extends BaseInputMask {
1771
2216
  this.updateGhost(this.input.value);
1772
2217
  }
1773
2218
  }
2219
+ applyTransformInput(value, source, inputType) {
2220
+ if (typeof this.options.transformInput !== "function") {
2221
+ return value;
2222
+ }
2223
+ try {
2224
+ const res = this.options.transformInput(value, { source, inputType });
2225
+ if (typeof res === "string") {
2226
+ return source === "paste" ? sanitizePastedText(res, 4096) : stripBidiAndInvisibles(res, 4096);
2227
+ }
2228
+ } catch {
2229
+ }
2230
+ return value;
2231
+ }
1774
2232
  /**
1775
2233
  * Affecte une nouvelle valeur manuellement (formatée ou brute).
1776
2234
  */
@@ -1781,7 +2239,8 @@ var InputMask = class extends BaseInputMask {
1781
2239
  this.checkValueChange();
1782
2240
  return;
1783
2241
  }
1784
- this.applyMask(safeVal, safeVal.length);
2242
+ const transformed = this.applyTransformInput(safeVal, "programmatic", "");
2243
+ this.applyMask(transformed, transformed.length);
1785
2244
  }
1786
2245
  /**
1787
2246
  * Retourne la valeur brute sans séparateurs.
@@ -1790,12 +2249,14 @@ var InputMask = class extends BaseInputMask {
1790
2249
  return this.engine.extractRaw(this.input.value);
1791
2250
  }
1792
2251
  /**
1793
- * Indique si tous les emplacements éditables sont renseignés.
2252
+ * Indique si tous les emplacements éditables du gabarit actif sont renseignés.
1794
2253
  */
1795
2254
  isComplete() {
1796
2255
  if (this.options.disabled) return true;
1797
2256
  const raw = this.getRawValue();
1798
- return raw.length >= this.engine.getEditableCount();
2257
+ const activeSlots = this.engine.getActiveEditableCount();
2258
+ if (activeSlots === 0) return true;
2259
+ return raw.length >= activeSlots;
1799
2260
  }
1800
2261
  /**
1801
2262
  * Callback d'écoute directe ou getter/setter pour onInput.
@@ -1841,32 +2302,45 @@ var InputMask = class extends BaseInputMask {
1841
2302
  this.wrapper.classList.toggle("has-selection", hasSelection);
1842
2303
  }
1843
2304
  onBeforeInput(e) {
2305
+ this.lastInputType = e.inputType || "";
1844
2306
  if (this.options.disabled) return;
1845
2307
  if (this.isComposing) return;
1846
2308
  if (!this.engine.isStrict()) return;
1847
2309
  if (e.inputType === "insertFromPaste" || e.inputType === "insertReplacementText") return;
1848
2310
  if (e.inputType && e.inputType.startsWith("insert")) {
1849
- const totalSlots = this.engine.getEditableCount();
2311
+ const currentVal = this.input.value;
2312
+ const isDynamic = this.engine.isDynamicPattern();
2313
+ const currentRaw = this.engine.extractRaw(currentVal);
2314
+ const start = this.input.selectionStart ?? 0;
2315
+ const end = this.input.selectionEnd ?? start;
2316
+ const selectedRaw = end > start ? this.engine.extractRawForCurrentPattern(currentVal.slice(start, end)) : "";
2317
+ if (isDynamic) {
2318
+ const candidate = currentVal.slice(0, start) + (e.data ?? "") + currentVal.slice(end);
2319
+ this.engine.resolveForValue(candidate);
2320
+ }
2321
+ const totalSlots = this.engine.getMaxEditableCount();
1850
2322
  if (totalSlots > 0) {
1851
- const currentRaw = this.getRawValue();
1852
- const start = this.input.selectionStart ?? 0;
1853
- const end = this.input.selectionEnd ?? start;
1854
- let availableCapacity = Math.max(0, totalSlots - currentRaw.length);
1855
- if (end > start) {
1856
- const selectedRaw = this.engine.extractRaw(this.input.value.slice(start, end));
1857
- availableCapacity = Math.max(0, totalSlots - (currentRaw.length - selectedRaw.length));
1858
- }
2323
+ const availableCapacity = Math.max(0, totalSlots - (currentRaw.length - selectedRaw.length));
1859
2324
  if (availableCapacity <= 0) {
2325
+ if (isDynamic) {
2326
+ this.engine.resolveForValue(currentVal);
2327
+ }
1860
2328
  e.preventDefault();
2329
+ return;
1861
2330
  }
1862
2331
  }
2332
+ if (isDynamic) {
2333
+ this.engine.resolveForValue(currentVal);
2334
+ }
1863
2335
  }
1864
2336
  }
1865
2337
  handleInput(e) {
1866
2338
  if (this.isDispatchingNativeInput) return;
1867
2339
  if (this.isComposing) return;
2340
+ const inputType = e?.inputType || this.lastInputType || "";
2341
+ this.lastInputType = "";
1868
2342
  const hasOnInput = Boolean(this.options.onInput || this.options.oninput);
1869
- const currentComparison = this.isPasswordInput() ? this.computePasswordDigest(this.input.value) : this.input.value;
2343
+ const currentComparison = this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value;
1870
2344
  if (hasOnInput && currentComparison !== this.lastValue) {
1871
2345
  this.checkValueChange();
1872
2346
  }
@@ -1874,17 +2348,20 @@ var InputMask = class extends BaseInputMask {
1874
2348
  this.checkValueChange();
1875
2349
  return;
1876
2350
  }
2351
+ const rawInputVal = this.input.value;
2352
+ const oldCursor = this.input.selectionStart ?? rawInputVal.length;
2353
+ const transformedVal = this.applyTransformInput(rawInputVal, "input", inputType);
2354
+ const effectiveCursor = transformedVal !== rawInputVal ? oldCursor >= rawInputVal.length ? transformedVal.length : Math.min(oldCursor, transformedVal.length) : oldCursor;
1877
2355
  const prevState = this.history.getCurrent();
1878
- const totalSlots = this.engine.getEditableCount();
2356
+ const newRaw = this.engine.extractRaw(transformedVal);
2357
+ const totalSlots = this.engine.getMaxEditableCount();
1879
2358
  if (totalSlots > 0 && this.engine.isStrict() && prevState && prevState.raw.length >= totalSlots) {
1880
- const newRaw = this.engine.extractRaw(this.input.value);
1881
2359
  if (newRaw.length > totalSlots) {
1882
2360
  this.applyMask(prevState.raw, prevState.cursor);
1883
2361
  return;
1884
2362
  }
1885
2363
  }
1886
- const oldCursor = this.input.selectionStart ?? this.input.value.length;
1887
- this.applyMask(this.input.value, oldCursor);
2364
+ this.applyMask(transformedVal, effectiveCursor);
1888
2365
  this.checkSelection();
1889
2366
  }
1890
2367
  onKeyDown(e) {
@@ -1909,15 +2386,15 @@ var InputMask = class extends BaseInputMask {
1909
2386
  }
1910
2387
  e.preventDefault();
1911
2388
  this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
1912
- const rawPasted = (e.clipboardData?.getData("text") || "").slice(0, 4096);
1913
- const pastedText = rawPasted.trim();
2389
+ const preparedText = this.preparePastedText(this.getClipboardPlainText(e), 4096);
2390
+ const pastedText = this.applyTransformInput(preparedText, "paste", "insertFromPaste");
1914
2391
  if (!pastedText) return;
1915
2392
  const minPos = this.engine.getPrefixLength();
1916
2393
  const selStart = this.input.selectionStart ?? 0;
1917
2394
  const selEnd = this.input.selectionEnd ?? selStart;
1918
2395
  const currentVal = this.input.value;
1919
- const totalSlots = this.engine.getEditableCount();
1920
2396
  const currentRaw = this.getRawValue();
2397
+ const totalSlots = this.engine.getMaxEditableCount();
1921
2398
  const prefix = this.engine.getPrefix();
1922
2399
  const cleanPrefix = prefix.replace(/[\s.-]+/g, "").toUpperCase();
1923
2400
  const cleanPasted = pastedText.replace(/[\s.-]+/g, "").toUpperCase();
@@ -1932,17 +2409,38 @@ var InputMask = class extends BaseInputMask {
1932
2409
  }
1933
2410
  let availableCapacity = Math.max(0, totalSlots - currentRaw.length);
1934
2411
  if (effectiveStart !== effectiveEnd) {
1935
- const selectedRaw = this.engine.extractRaw(currentVal.slice(effectiveStart, effectiveEnd));
2412
+ const selectedRaw = this.engine.extractRawForCurrentPattern(currentVal.slice(effectiveStart, effectiveEnd));
1936
2413
  availableCapacity = Math.max(0, totalSlots - (currentRaw.length - selectedRaw.length));
1937
2414
  }
1938
- if (this.engine.isStrict() && availableCapacity <= 0) {
1939
- return;
2415
+ const normalizedPasted = this.engine.normalizePastedValue(pastedText);
2416
+ const activeSlots = this.engine.getActiveEditableCount();
2417
+ const isCurrentComplete = activeSlots > 0 && currentRaw.length >= activeSlots;
2418
+ if (this.engine.isStrict() && (availableCapacity <= 0 || selStart === selEnd && isCurrentComplete)) {
2419
+ const pastedRawLen = this.engine.extractRaw(normalizedPasted).length;
2420
+ const targetMaxSlots = this.engine.getMaxEditableCount();
2421
+ if (selStart === selEnd && targetMaxSlots > 0 && pastedRawLen === targetMaxSlots && (availableCapacity <= 0 || pastedRawLen > availableCapacity)) {
2422
+ effectiveStart = 0;
2423
+ effectiveEnd = currentVal.length;
2424
+ } else if (availableCapacity <= 0) {
2425
+ this.engine.resolveForValue(currentVal);
2426
+ return;
2427
+ } else {
2428
+ this.engine.resolveForValue(currentVal);
2429
+ }
1940
2430
  }
1941
2431
  let combined;
1942
2432
  let newCursorPos;
1943
2433
  if (effectiveStart === 0 && effectiveEnd === currentVal.length) {
1944
- combined = pastedText;
1945
- newCursorPos = pastedText.length;
2434
+ combined = normalizedPasted;
2435
+ newCursorPos = normalizedPasted.length;
2436
+ } else if (currentRaw.length === 0 && effectiveStart === minPos && effectiveEnd === currentVal.length) {
2437
+ if (minPos > 0 && normalizedPasted.toUpperCase().startsWith(prefix.toUpperCase())) {
2438
+ combined = normalizedPasted;
2439
+ newCursorPos = normalizedPasted.length;
2440
+ } else {
2441
+ combined = currentVal.slice(0, effectiveStart) + normalizedPasted;
2442
+ newCursorPos = combined.length;
2443
+ }
1946
2444
  } else {
1947
2445
  combined = currentVal.slice(0, effectiveStart) + pastedText + currentVal.slice(effectiveEnd);
1948
2446
  newCursorPos = effectiveStart + pastedText.length;
@@ -1961,7 +2459,7 @@ var InputMask = class extends BaseInputMask {
1961
2459
  }
1962
2460
  onBlur() {
1963
2461
  this.wrapper.classList.remove("is-focused", "has-selection");
1964
- if (this.isPasswordInput()) {
2462
+ if (this.isSensitiveField()) {
1965
2463
  this.history.clear();
1966
2464
  this.lastValue = "";
1967
2465
  this.lastInternalRemainingMask = "";
@@ -2022,7 +2520,7 @@ var InputMask = class extends BaseInputMask {
2022
2520
  // ==========================================================================
2023
2521
  updateGhost(formatted) {
2024
2522
  if (!this.ghost) return;
2025
- if (this.options.disabled || this.isPasswordInput()) {
2523
+ if (this.options.disabled || this.isSensitiveField()) {
2026
2524
  this.clearGhost();
2027
2525
  return;
2028
2526
  }
@@ -2050,10 +2548,13 @@ var InputMask = class extends BaseInputMask {
2050
2548
  let isCompleted = false;
2051
2549
  try {
2052
2550
  formatted = this.engine.format(rawOrPartial);
2551
+ if (this.engine.isDynamicPattern()) {
2552
+ this.syncInferredInputMode();
2553
+ }
2053
2554
  const remainingMask = this.engine.getRemainingMask(formatted);
2054
- const isPwd = this.isPasswordInput();
2055
- this.input.value = formatted;
2056
- if (isPwd) {
2555
+ const isSensitive = this.isSensitiveField();
2556
+ this.setNativeValue(formatted);
2557
+ if (isSensitive) {
2057
2558
  this.lastInternalRemainingMask = "";
2058
2559
  this.wrapper.removeAttribute("data-mask");
2059
2560
  this.clearGhost();
@@ -2073,7 +2574,7 @@ var InputMask = class extends BaseInputMask {
2073
2574
  this.input.setSelectionRange(safeCursor, safeCursor);
2074
2575
  isCompleted = this.isComplete();
2075
2576
  this.wrapper.classList.toggle("is-complete", isCompleted);
2076
- if (isPwd) {
2577
+ if (isSensitive) {
2077
2578
  this.options.copyRaw = false;
2078
2579
  this.history.clear();
2079
2580
  } else if (!this.isUndoingRedoing) {
@@ -2085,24 +2586,25 @@ var InputMask = class extends BaseInputMask {
2085
2586
  this.checkValueChange();
2086
2587
  }
2087
2588
  syncInitialValue() {
2088
- const isPwd = this.isPasswordInput();
2589
+ const isSensitive = this.isSensitiveField();
2089
2590
  if (this.options.disabled) {
2090
2591
  this.wrapper.removeAttribute("data-mask");
2091
2592
  this.clearGhost();
2092
- this.lastValue = isPwd ? this.computePasswordDigest(this.input.value) : this.input.value;
2593
+ this.lastValue = isSensitive ? this.computePasswordDigest(this.input.value) : this.input.value;
2093
2594
  this.checkValueChange();
2094
2595
  return;
2095
2596
  }
2096
2597
  this.syncGhostStyles();
2097
2598
  const initialVal = this.input.value || "";
2098
2599
  if (initialVal) {
2099
- this.applyMask(initialVal, initialVal.length);
2600
+ const transformed = this.applyTransformInput(initialVal, "programmatic", "");
2601
+ this.applyMask(transformed, transformed.length);
2100
2602
  } else {
2101
2603
  const minPos = this.engine.getPrefixLength();
2102
2604
  if (minPos > 0) {
2103
2605
  this.applyMask("", minPos);
2104
2606
  } else {
2105
- if (!isPwd) {
2607
+ if (!isSensitive) {
2106
2608
  this.history.push("", 0);
2107
2609
  const fullTemplate = this.engine.getFullMaskTemplate();
2108
2610
  this.lastInternalRemainingMask = fullTemplate;
@@ -2122,9 +2624,9 @@ var InputMask = class extends BaseInputMask {
2122
2624
  * Gère de manière sûre la réentrance pour permettre d'appeler setMask() directement dans le callback.
2123
2625
  */
2124
2626
  checkValueChange(forceNotify = false) {
2125
- const isPwd = this.isPasswordInput();
2627
+ const initialSensitive = this.isSensitiveField();
2126
2628
  const currentVal = this.input.value;
2127
- const currentComparison = isPwd ? this.computePasswordDigest(currentVal) : currentVal;
2629
+ const currentComparison = initialSensitive ? this.computePasswordDigest(currentVal) : currentVal;
2128
2630
  if (currentComparison === this.lastValue && !forceNotify && !this.hasPendingNotification) {
2129
2631
  return;
2130
2632
  }
@@ -2135,15 +2637,16 @@ var InputMask = class extends BaseInputMask {
2135
2637
  this.isNotifying = true;
2136
2638
  try {
2137
2639
  let iterations = 0;
2138
- const MAX_NOTIFICATION_ITERATIONS = 10;
2139
- while (((isPwd ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS) {
2640
+ const MAX_NOTIFICATION_ITERATIONS4 = 10;
2641
+ while (((this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS4) {
2140
2642
  iterations++;
2141
2643
  this.hasPendingNotification = false;
2142
2644
  forceNotify = false;
2645
+ const sensitiveNow = this.isSensitiveField();
2143
2646
  const valToNotify = this.input.value;
2144
- this.lastValue = isPwd ? this.computePasswordDigest(valToNotify) : valToNotify;
2647
+ this.lastValue = sensitiveNow ? this.computePasswordDigest(valToNotify) : valToNotify;
2145
2648
  const raw = this.options.disabled ? valToNotify : this.getRawValue();
2146
- const totalSlots = this.options.disabled ? 0 : this.engine.getEditableCount();
2649
+ const totalSlots = this.options.disabled ? 0 : this.engine.getActiveEditableCount();
2147
2650
  const isComplete = this.isComplete();
2148
2651
  const detail = {
2149
2652
  value: valToNotify,
@@ -2152,23 +2655,24 @@ var InputMask = class extends BaseInputMask {
2152
2655
  totalSlots,
2153
2656
  filledSlots: this.options.disabled ? valToNotify.length : raw.length
2154
2657
  };
2658
+ const allowBubble = !sensitiveNow;
2155
2659
  const onInputCb = this.options.onInput || this.options.oninput;
2156
2660
  if (onInputCb) {
2157
2661
  onInputCb(valToNotify, detail);
2158
2662
  }
2159
- this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
2663
+ this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: allowBubble, detail }));
2160
2664
  this.dispatchNativeInput();
2161
2665
  const onChangeCb = this.options.onChange || this.options.onchange;
2162
2666
  if (onChangeCb) {
2163
2667
  onChangeCb(detail);
2164
2668
  }
2165
- this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: true, detail }));
2669
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: allowBubble, detail }));
2166
2670
  const onCompleteCb = this.options.onComplete || this.options.oncomplete;
2167
2671
  if (isComplete) {
2168
2672
  if (onCompleteCb) {
2169
2673
  onCompleteCb(detail);
2170
2674
  }
2171
- this.input.dispatchEvent(new CustomEvent("mask:complete", { bubbles: true, detail }));
2675
+ this.input.dispatchEvent(new CustomEvent("mask:complete", { bubbles: allowBubble, detail }));
2172
2676
  }
2173
2677
  }
2174
2678
  } finally {
@@ -2201,6 +2705,47 @@ var AmountEngine = class _AmountEngine {
2201
2705
  max: options.max ?? Infinity
2202
2706
  };
2203
2707
  }
2708
+ /**
2709
+ * Normalise un texte collé uniquement lorsque le séparateur décimal vs milliers
2710
+ * est mathématiquement non ambigu :
2711
+ * - coexistence de ',' et '.' (le séparateur le plus à droite, s'il est unique, est la décimale),
2712
+ * - répétition (>= 2) d'un unique séparateur (il s'agit alors de séparateurs de milliers).
2713
+ * Un séparateur unique isolé (ex: "1,234") reste inchangé pour respecter la locale configurée.
2714
+ */
2715
+ normalizePastedValue(pasted) {
2716
+ const str = sanitizePastedText(pasted, 512);
2717
+ if (!str) return "";
2718
+ let commaCount = 0;
2719
+ let dotCount = 0;
2720
+ let lastCommaIdx = -1;
2721
+ let lastDotIdx = -1;
2722
+ for (let i = 0; i < str.length; i++) {
2723
+ const ch = str[i];
2724
+ if (ch === ",") {
2725
+ commaCount++;
2726
+ lastCommaIdx = i;
2727
+ } else if (ch === ".") {
2728
+ dotCount++;
2729
+ lastDotIdx = i;
2730
+ }
2731
+ }
2732
+ if (commaCount > 0 && dotCount > 0) {
2733
+ const decChar = lastCommaIdx > lastDotIdx ? "," : ".";
2734
+ const decCount = decChar === "," ? commaCount : dotCount;
2735
+ if (decCount !== 1) {
2736
+ return str;
2737
+ }
2738
+ const thousandChar = decChar === "," ? "." : ",";
2739
+ return str.split(thousandChar).join("").replace(decChar, this.options.decimalSeparator);
2740
+ }
2741
+ if (commaCount >= 2 && dotCount === 0) {
2742
+ return str.split(",").join("");
2743
+ }
2744
+ if (dotCount >= 2 && commaCount === 0) {
2745
+ return str.split(".").join("");
2746
+ }
2747
+ return str;
2748
+ }
2204
2749
  /**
2205
2750
  * Analyse et nettoie une saisie utilisateur pour extraire ses composantes numériques.
2206
2751
  */
@@ -2391,12 +2936,15 @@ var AmountEngine = class _AmountEngine {
2391
2936
  };
2392
2937
 
2393
2938
  // src/mask/InputAmountMask.ts
2939
+ var MAX_NOTIFICATION_ITERATIONS = 10;
2394
2940
  var InputAmountMask = class extends BaseInputMask {
2395
2941
  engine;
2396
2942
  history;
2397
2943
  isUndoingRedoing = false;
2398
2944
  isApplying = false;
2399
2945
  isComposing = false;
2946
+ isNotifying = false;
2947
+ hasPendingNotification = false;
2400
2948
  lastValue = "";
2401
2949
  wasInputModeInferred = false;
2402
2950
  cutTimerId = null;
@@ -2456,7 +3004,7 @@ var InputAmountMask = class extends BaseInputMask {
2456
3004
  }
2457
3005
  onNativeValueSet(strVal) {
2458
3006
  if (this.options.disabled || this.isComposing) {
2459
- this.lastValue = strVal;
3007
+ this.lastValue = this.isSensitiveField() ? this.computePasswordDigest(strVal) : strVal;
2460
3008
  return;
2461
3009
  }
2462
3010
  this.applyAmount(strVal, strVal.length);
@@ -2471,6 +3019,7 @@ var InputAmountMask = class extends BaseInputMask {
2471
3019
  bindEvents() {
2472
3020
  this.handleInput = this.handleInput.bind(this);
2473
3021
  this.handleKeyDown = this.handleKeyDown.bind(this);
3022
+ this.handlePaste = this.handlePaste.bind(this);
2474
3023
  this.handleBlur = this.handleBlur.bind(this);
2475
3024
  this.handleFocus = this.handleFocus.bind(this);
2476
3025
  this.handleClick = this.handleClick.bind(this);
@@ -2490,6 +3039,7 @@ var InputAmountMask = class extends BaseInputMask {
2490
3039
  const { signal } = this.abortController;
2491
3040
  this.input.addEventListener("input", this.handleInput, { signal });
2492
3041
  this.input.addEventListener("keydown", this.handleKeyDown, { signal });
3042
+ this.input.addEventListener("paste", this.handlePaste, { signal });
2493
3043
  this.input.addEventListener("blur", this.handleBlur, { signal });
2494
3044
  this.input.addEventListener("focus", this.handleFocus, { signal });
2495
3045
  this.input.addEventListener("click", this.handleClick, { signal });
@@ -2524,12 +3074,13 @@ var InputAmountMask = class extends BaseInputMask {
2524
3074
  applyAmount(val, cursor) {
2525
3075
  if (this.isApplying || this.options.disabled) return;
2526
3076
  this.isApplying = true;
3077
+ let result = null;
2527
3078
  try {
2528
- const result = this.engine.format(val, cursor);
3079
+ result = this.engine.format(val, cursor);
2529
3080
  this.setNativeValue(result.formatted);
2530
3081
  this.input.setSelectionRange(result.cursor, result.cursor);
2531
- const isPwd = this.isPasswordInput();
2532
- if (isPwd) {
3082
+ const isSensitive = this.isSensitiveField();
3083
+ if (isSensitive) {
2533
3084
  this.options.copyRaw = false;
2534
3085
  this.history.clear();
2535
3086
  this.clearGhost();
@@ -2539,17 +3090,19 @@ var InputAmountMask = class extends BaseInputMask {
2539
3090
  }
2540
3091
  this.updateGhost(result);
2541
3092
  }
2542
- const nextComparison = isPwd ? this.computePasswordDigest(result.formatted) : result.formatted;
2543
- if (this.lastValue !== nextComparison) {
2544
- this.lastValue = nextComparison;
2545
- this.notifyChange(result);
2546
- }
2547
3093
  } finally {
2548
3094
  this.isApplying = false;
2549
3095
  }
3096
+ if (result) {
3097
+ this.checkValueChange(result);
3098
+ }
2550
3099
  }
2551
3100
  updateGhost(result) {
2552
3101
  if (!this.ghost) return;
3102
+ if (this.options.disabled || this.isSensitiveField()) {
3103
+ this.clearGhost();
3104
+ return;
3105
+ }
2553
3106
  if (!result.formatted) {
2554
3107
  if (this.shouldHideGhostForPlaceholder(true)) {
2555
3108
  this.clearGhost();
@@ -2573,6 +3126,18 @@ var InputAmountMask = class extends BaseInputMask {
2573
3126
  const cur = this.input.selectionStart ?? rawVal.length;
2574
3127
  this.applyAmount(rawVal, cur);
2575
3128
  }
3129
+ handlePaste(e) {
3130
+ if (this.options.disabled) return;
3131
+ e.preventDefault();
3132
+ this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
3133
+ const prepared = this.preparePastedText(this.getClipboardPlainText(e), 512);
3134
+ if (!prepared) return;
3135
+ const normalized = this.engine.normalizePastedValue(prepared);
3136
+ const start = this.input.selectionStart ?? this.input.value.length;
3137
+ const end = this.input.selectionEnd ?? start;
3138
+ const combined = this.input.value.slice(0, start) + normalized + this.input.value.slice(end);
3139
+ this.applyAmount(combined, start + normalized.length);
3140
+ }
2576
3141
  handleKeyDown(e) {
2577
3142
  if (this.options.disabled || isImeComposing(e)) return;
2578
3143
  if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z")) {
@@ -2637,7 +3202,9 @@ var InputAmountMask = class extends BaseInputMask {
2637
3202
  }
2638
3203
  }
2639
3204
  enforceCursorBounds() {
2640
- if (this.isDestroyed || !this.isFocused || document.activeElement !== this.input || !this.input.value || this.options.disabled) return;
3205
+ if (this.isDestroyed || !this.isFocused || getDeepActiveElement(this.input.ownerDocument) !== this.input || !this.input.value || this.options.disabled) {
3206
+ return;
3207
+ }
2641
3208
  const start = this.input.selectionStart ?? 0;
2642
3209
  const end = this.input.selectionEnd ?? 0;
2643
3210
  if (start !== end) return;
@@ -2668,7 +3235,7 @@ var InputAmountMask = class extends BaseInputMask {
2668
3235
  }
2669
3236
  handleBlur() {
2670
3237
  this.wrapper.classList.remove("is-focused");
2671
- if (this.isPasswordInput()) {
3238
+ if (this.isSensitiveField()) {
2672
3239
  this.history.clear();
2673
3240
  this.lastValue = "";
2674
3241
  this.lastTrackedValue = "";
@@ -2687,7 +3254,7 @@ var InputAmountMask = class extends BaseInputMask {
2687
3254
  if (this.options.onChange) {
2688
3255
  this.options.onChange(detail);
2689
3256
  }
2690
- this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: true, detail }));
3257
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: !this.isSensitiveField(), detail }));
2691
3258
  }
2692
3259
  handleAttributeMutation(attrName) {
2693
3260
  super.handleAttributeMutation(attrName);
@@ -2697,6 +3264,34 @@ var InputAmountMask = class extends BaseInputMask {
2697
3264
  this.updateGhost(this.engine.format(this.input.value));
2698
3265
  }
2699
3266
  }
3267
+ checkValueChange(initialResult) {
3268
+ const initialSensitive = this.isSensitiveField();
3269
+ const initialComparison = initialSensitive ? this.computePasswordDigest(this.input.value) : this.input.value;
3270
+ if (initialComparison === this.lastValue && !this.hasPendingNotification) {
3271
+ return;
3272
+ }
3273
+ if (this.isNotifying) {
3274
+ this.hasPendingNotification = true;
3275
+ return;
3276
+ }
3277
+ this.isNotifying = true;
3278
+ try {
3279
+ let iterations = 0;
3280
+ let nextResult = initialResult;
3281
+ while (((this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification) && iterations < MAX_NOTIFICATION_ITERATIONS) {
3282
+ iterations++;
3283
+ this.hasPendingNotification = false;
3284
+ const sensitiveNow = this.isSensitiveField();
3285
+ const currentVal = this.input.value;
3286
+ this.lastValue = sensitiveNow ? this.computePasswordDigest(currentVal) : currentVal;
3287
+ const res = nextResult ?? this.engine.format(currentVal);
3288
+ nextResult = void 0;
3289
+ this.notifyChange(res);
3290
+ }
3291
+ } finally {
3292
+ this.isNotifying = false;
3293
+ }
3294
+ }
2700
3295
  notifyChange(result) {
2701
3296
  const detail = {
2702
3297
  value: result.formatted,
@@ -2707,7 +3302,7 @@ var InputAmountMask = class extends BaseInputMask {
2707
3302
  if (this.options.onInput) {
2708
3303
  this.options.onInput(detail);
2709
3304
  }
2710
- this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
3305
+ this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: !this.isSensitiveField(), detail }));
2711
3306
  this.dispatchNativeInput();
2712
3307
  }
2713
3308
  undo() {
@@ -2750,11 +3345,53 @@ var InputAmountMask = class extends BaseInputMask {
2750
3345
  isValid() {
2751
3346
  return this.getDetail().isValid;
2752
3347
  }
3348
+ getSpecificAuditWarnings() {
3349
+ const warnings = [];
3350
+ const currencyOrUnit = (this.options.currency || this.options.unit || "").trim();
3351
+ if (!currencyOrUnit || this.options.disabled) {
3352
+ return warnings;
3353
+ }
3354
+ const describedbyWarnings = [];
3355
+ const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings, true);
3356
+ const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
3357
+ if (hasValidDescribedby || hasAriaPlaceholder) {
3358
+ return warnings;
3359
+ }
3360
+ const doc = this.input.ownerDocument || document;
3361
+ const root = typeof this.input.getRootNode === "function" ? this.input.getRootNode() : doc;
3362
+ const labelRoot = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : doc;
3363
+ let labelTexts = this.input.getAttribute("aria-label") || "";
3364
+ const labelledBy = this.input.getAttribute("aria-labelledby")?.trim();
3365
+ if (labelledBy) {
3366
+ for (const id of labelledBy.split(/\s+/).filter(Boolean)) {
3367
+ const target = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id);
3368
+ if (target?.textContent) labelTexts += " " + target.textContent;
3369
+ }
3370
+ }
3371
+ const wrapping = this.input.closest("label");
3372
+ if (wrapping?.textContent) labelTexts += " " + wrapping.textContent;
3373
+ if (this.input.id) {
3374
+ try {
3375
+ const explicit = labelRoot.querySelector(`label[for="${safeCssEscape(this.input.id)}"]`);
3376
+ if (explicit?.textContent) labelTexts += " " + explicit.textContent;
3377
+ } catch {
3378
+ }
3379
+ }
3380
+ const norm = labelTexts.toLowerCase();
3381
+ const token = currencyOrUnit.toLowerCase();
3382
+ const hasCurrencyAlias = norm.includes(token) || token === "\u20AC" && (norm.includes("euro") || norm.includes("eur")) || token === "$" && (norm.includes("dollar") || norm.includes("usd")) || token === "\xA3" && (norm.includes("livre") || norm.includes("pound") || norm.includes("gbp"));
3383
+ if (!hasCurrencyAlias) {
3384
+ warnings.push(
3385
+ `Devise/unit\xE9 "${currencyOrUnit}" non expos\xE9e aux technologies d'assistance quand le champ est vide (le fant\xF4me est aria-hidden="true") : mentionnez-la dans le <label>, aria-label ou aria-describedby (WCAG 3.3.2).`
3386
+ );
3387
+ }
3388
+ return warnings;
3389
+ }
2753
3390
  setValue(val) {
2754
3391
  const str = val !== null && val !== void 0 ? String(val) : "";
2755
3392
  if (this.options.disabled) {
2756
3393
  this.setNativeValue(str);
2757
- this.lastValue = str;
3394
+ this.lastValue = this.isSensitiveField() ? this.computePasswordDigest(str) : str;
2758
3395
  } else {
2759
3396
  this.applyAmount(str, str.length);
2760
3397
  }
@@ -2823,7 +3460,8 @@ var EmailEngine = class _EmailEngine {
2823
3460
  "it"
2824
3461
  ];
2825
3462
  constructor(options = {}) {
2826
- this.domains = options.domains && options.domains.length > 0 ? options.domains : _EmailEngine.DEFAULT_DOMAINS;
3463
+ const customDomains = Array.isArray(options.domains) ? options.domains.slice(0, 500).map((d) => String(d ?? "").trim().slice(0, 253)).filter(Boolean) : [];
3464
+ this.domains = customDomains.length > 0 ? customDomains : _EmailEngine.DEFAULT_DOMAINS;
2827
3465
  this.tlds = options.tlds && options.tlds.length > 0 ? options.tlds.slice(0, 200).map((t) => String(t).trim().replace(/^\./, "").slice(0, 32)).filter(Boolean) : [..._EmailEngine.DEFAULT_TLDS];
2828
3466
  this.suggestOnAt = options.suggestOnAt ?? true;
2829
3467
  this.setDefaultDomain(options.defaultDomain ?? null);
@@ -2836,7 +3474,7 @@ var EmailEngine = class _EmailEngine {
2836
3474
  if (domain === true) {
2837
3475
  this.defaultDomain = this.domains.length > 0 ? this.domains[0] : null;
2838
3476
  } else if (typeof domain === "string" && domain.trim().length > 0) {
2839
- this.defaultDomain = domain.trim().replace(/^@/, "");
3477
+ this.defaultDomain = domain.trim().replace(/^@/, "").slice(0, 253) || null;
2840
3478
  } else {
2841
3479
  this.defaultDomain = null;
2842
3480
  }
@@ -2848,7 +3486,7 @@ var EmailEngine = class _EmailEngine {
2848
3486
  if (tld === true) {
2849
3487
  this.defaultTld = this.tlds.length > 0 ? this.tlds[0] : null;
2850
3488
  } else if (typeof tld === "string" && tld.trim().length > 0) {
2851
- this.defaultTld = tld.trim().replace(/^\./, "");
3489
+ this.defaultTld = tld.trim().replace(/^\./, "").slice(0, 32) || null;
2852
3490
  } else {
2853
3491
  this.defaultTld = null;
2854
3492
  }
@@ -3007,11 +3645,16 @@ var EmailEngine = class _EmailEngine {
3007
3645
  };
3008
3646
 
3009
3647
  // src/mask/InputEmailMask.ts
3648
+ var MAX_NOTIFICATION_ITERATIONS2 = 10;
3010
3649
  var InputEmailMask = class extends BaseInputMask {
3011
3650
  engine;
3012
3651
  currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3013
3652
  currentSuggestionIndex = 0;
3653
+ hadInitialAriaAutocomplete = false;
3014
3654
  wasAriaAutocompleteSet = false;
3655
+ isSuggestionDismissed = false;
3656
+ isNotifying = false;
3657
+ hasPendingNotification = false;
3015
3658
  wasAutocorrectSet = false;
3016
3659
  wasAutocapitalizeSet = false;
3017
3660
  wasSpellcheckSet = false;
@@ -3064,46 +3707,73 @@ var InputEmailMask = class extends BaseInputMask {
3064
3707
  this.input.setAttribute("spellcheck", "false");
3065
3708
  this.wasSpellcheckSet = true;
3066
3709
  }
3067
- if (this.options.setAriaAutocomplete && !this.input.hasAttribute("aria-autocomplete")) {
3068
- this.input.setAttribute("aria-autocomplete", "inline");
3069
- this.wasAriaAutocompleteSet = true;
3070
- }
3710
+ this.hadInitialAriaAutocomplete = this.input.hasAttribute("aria-autocomplete");
3711
+ this.syncAriaAutocomplete();
3071
3712
  this.engine = new EmailEngine(this.options);
3072
- this.lastNotifiedValue = this.isPasswordInput() ? "" : this.input.value;
3713
+ this.lastNotifiedValue = this.isSensitiveField() ? "" : this.input.value;
3073
3714
  this.bindEvents();
3074
- if (!this.options.disabled && !this.isPasswordInput()) {
3715
+ if (!this.options.disabled && !this.isSensitiveField()) {
3075
3716
  this.updateSuggestion();
3076
3717
  }
3077
3718
  this.runAuditWarning(this.options.audit);
3078
3719
  }
3079
- onPasswordModeDetected() {
3080
- if (this.srAnnounceTimerId !== null) {
3081
- clearTimeout(this.srAnnounceTimerId);
3082
- this.srAnnounceTimerId = null;
3720
+ syncAriaAutocomplete() {
3721
+ const canSuggest = Boolean(
3722
+ this.options.setAriaAutocomplete && !this.options.disabled && !this.isSensitiveField() && !this.isDestroyed
3723
+ );
3724
+ if (!this.hadInitialAriaAutocomplete) {
3725
+ if (canSuggest) {
3726
+ if (!this.input.hasAttribute("aria-autocomplete")) {
3727
+ this.input.setAttribute("aria-autocomplete", "inline");
3728
+ this.wasAriaAutocompleteSet = true;
3729
+ }
3730
+ } else if (this.wasAriaAutocompleteSet) {
3731
+ if (this.input.getAttribute("aria-autocomplete") === "inline") {
3732
+ this.input.removeAttribute("aria-autocomplete");
3733
+ }
3734
+ this.wasAriaAutocompleteSet = false;
3735
+ }
3083
3736
  }
3084
- this.lastNotifiedValue = "";
3737
+ const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
3738
+ const hasAriaNotify = Boolean(doc && typeof doc.ariaNotify === "function");
3739
+ if (canSuggest && !hasAriaNotify) {
3740
+ this.ensureSrStatusEl();
3741
+ } else if (!canSuggest && this.srStatusEl) {
3742
+ this.srStatusEl.remove();
3743
+ this.srStatusEl = null;
3744
+ }
3745
+ }
3746
+ onPasswordModeDetected() {
3747
+ if (this.srAnnounceTimerId !== null) {
3748
+ clearTimeout(this.srAnnounceTimerId);
3749
+ this.srAnnounceTimerId = null;
3750
+ }
3751
+ this.lastNotifiedValue = "";
3085
3752
  this.lastTrackedValue = "";
3086
3753
  this.lastAnnouncedSuggestion = "";
3087
3754
  this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3088
- if (this.srStatusEl) {
3089
- this.srStatusEl.textContent = "";
3090
- }
3755
+ this.syncAriaAutocomplete();
3091
3756
  this.clearGhost();
3092
3757
  }
3093
3758
  onNativeValueSet(_strVal) {
3094
- if (this.options.disabled || this.isComposing || this.isPasswordInput()) return;
3759
+ if (this.options.disabled || this.isComposing || this.isSensitiveField()) return;
3760
+ this.isSuggestionDismissed = false;
3095
3761
  this.updateSuggestion();
3096
3762
  }
3097
3763
  onDisabledChange(disabled) {
3098
- if (disabled || this.isPasswordInput()) {
3764
+ this.syncAriaAutocomplete();
3765
+ if (disabled || this.isSensitiveField()) {
3766
+ this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3099
3767
  this.clearGhost();
3100
3768
  } else {
3769
+ this.isSuggestionDismissed = false;
3101
3770
  this.updateSuggestion();
3102
3771
  }
3103
3772
  }
3104
3773
  bindEvents() {
3105
3774
  this.handleInput = this.handleInput.bind(this);
3106
3775
  this.handleKeyDown = this.handleKeyDown.bind(this);
3776
+ this.handlePaste = this.handlePaste.bind(this);
3107
3777
  this.handleBlur = this.handleBlur.bind(this);
3108
3778
  this.handleFocus = this.handleFocus.bind(this);
3109
3779
  this.onCutHandler = () => {
@@ -3112,13 +3782,14 @@ var InputEmailMask = class extends BaseInputMask {
3112
3782
  }
3113
3783
  this.cutTimerId = window.setTimeout(() => {
3114
3784
  this.cutTimerId = null;
3115
- if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
3785
+ if (this.isDestroyed || this.options.disabled || this.isSensitiveField()) return;
3116
3786
  this.updateSuggestion();
3117
3787
  }, 0);
3118
3788
  };
3119
3789
  const { signal } = this.abortController;
3120
3790
  this.input.addEventListener("input", this.handleInput, { signal });
3121
3791
  this.input.addEventListener("keydown", this.handleKeyDown, { signal });
3792
+ this.input.addEventListener("paste", this.handlePaste, { signal });
3122
3793
  this.input.addEventListener("blur", this.handleBlur, { signal });
3123
3794
  this.input.addEventListener("focus", this.handleFocus, { signal });
3124
3795
  this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
@@ -3128,7 +3799,7 @@ var InputEmailMask = class extends BaseInputMask {
3128
3799
  }, { signal });
3129
3800
  this.input.addEventListener("compositionend", () => {
3130
3801
  this.isComposing = false;
3131
- if (!this.isDestroyed && !this.options.disabled && !this.isPasswordInput()) {
3802
+ if (!this.isDestroyed && !this.options.disabled && !this.isSensitiveField()) {
3132
3803
  this.handleInput();
3133
3804
  }
3134
3805
  }, { signal });
@@ -3139,7 +3810,7 @@ var InputEmailMask = class extends BaseInputMask {
3139
3810
  }
3140
3811
  this.resetTimerId = window.setTimeout(() => {
3141
3812
  this.resetTimerId = null;
3142
- if (this.isDestroyed || this.options.disabled || this.isPasswordInput()) return;
3813
+ if (this.isDestroyed || this.options.disabled || this.isSensitiveField()) return;
3143
3814
  this.updateSuggestion();
3144
3815
  }, 0);
3145
3816
  };
@@ -3165,7 +3836,7 @@ var InputEmailMask = class extends BaseInputMask {
3165
3836
  clearTimeout(this.srAnnounceTimerId);
3166
3837
  this.srAnnounceTimerId = null;
3167
3838
  }
3168
- if (!this.options.setAriaAutocomplete || !this.isFocused || this.isDestroyed || this.isPasswordInput()) {
3839
+ if (!this.options.setAriaAutocomplete || !this.isFocused || this.isDestroyed || this.isSensitiveField()) {
3169
3840
  return;
3170
3841
  }
3171
3842
  const suggestion = this.currentSuggestion;
@@ -3182,7 +3853,7 @@ var InputEmailMask = class extends BaseInputMask {
3182
3853
  }
3183
3854
  const run = () => {
3184
3855
  this.srAnnounceTimerId = null;
3185
- if (this.isDestroyed || !this.isFocused || this.isPasswordInput()) return;
3856
+ if (this.isDestroyed || !this.isFocused || this.isSensitiveField()) return;
3186
3857
  this.lastAnnouncedSuggestion = textToAnnounce;
3187
3858
  const doc = this.input.ownerDocument || (typeof document !== "undefined" ? document : null);
3188
3859
  const docWithAriaNotify = doc;
@@ -3205,13 +3876,13 @@ var InputEmailMask = class extends BaseInputMask {
3205
3876
  }
3206
3877
  }
3207
3878
  updateSuggestion(announceOptions) {
3208
- if (this.options.disabled || this.isPasswordInput()) {
3879
+ if (this.options.disabled || this.isSensitiveField()) {
3209
3880
  this.currentSuggestion = { full: "", remaining: "", matchedDomain: null };
3210
3881
  this.clearGhost();
3211
3882
  return;
3212
3883
  }
3213
3884
  const val = this.input.value;
3214
- this.currentSuggestion = this.engine.getSuggestion(val, this.currentSuggestionIndex);
3885
+ this.currentSuggestion = this.isSuggestionDismissed ? { full: val, remaining: "", matchedDomain: null } : this.engine.getSuggestion(val, this.currentSuggestionIndex);
3215
3886
  if (!this.ghost) return;
3216
3887
  if (this.shouldHideGhostForPlaceholder(val.length === 0)) {
3217
3888
  this.clearGhost();
@@ -3231,19 +3902,39 @@ var InputEmailMask = class extends BaseInputMask {
3231
3902
  if (announceOptions?.announce) {
3232
3903
  this.scheduleSuggestionAnnouncement(Boolean(announceOptions.immediate));
3233
3904
  }
3234
- const detail = this.getDetail();
3235
- if (this.options.onInput) {
3236
- this.options.onInput(detail);
3905
+ this.notifyValueChange();
3906
+ }
3907
+ notifyValueChange() {
3908
+ if (this.isNotifying) {
3909
+ this.hasPendingNotification = true;
3910
+ return;
3237
3911
  }
3238
- this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: true, detail }));
3239
- if (val !== this.lastNotifiedValue) {
3240
- this.lastNotifiedValue = val;
3241
- this.dispatchNativeInput();
3912
+ this.isNotifying = true;
3913
+ try {
3914
+ let iterations = 0;
3915
+ do {
3916
+ iterations++;
3917
+ this.hasPendingNotification = false;
3918
+ const sensitiveNow = this.isSensitiveField();
3919
+ const allowBubble = !sensitiveNow;
3920
+ const valNow = this.input.value;
3921
+ const detail = this.getDetail();
3922
+ if (this.options.onInput) {
3923
+ this.options.onInput(detail);
3924
+ }
3925
+ this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: allowBubble, detail }));
3926
+ if (valNow !== this.lastNotifiedValue) {
3927
+ this.lastNotifiedValue = sensitiveNow ? "" : valNow;
3928
+ this.dispatchNativeInput();
3929
+ }
3930
+ } while (this.hasPendingNotification && iterations < MAX_NOTIFICATION_ITERATIONS2);
3931
+ } finally {
3932
+ this.isNotifying = false;
3242
3933
  }
3243
3934
  }
3244
3935
  handleInput(e) {
3245
3936
  if (this.isDispatchingNativeInput) return;
3246
- if (this.options.disabled || this.isPasswordInput()) return;
3937
+ if (this.options.disabled || this.isSensitiveField()) return;
3247
3938
  if (this.isComposing || e && "isComposing" in e && e.isComposing) return;
3248
3939
  if (this.options.autoLowercase) {
3249
3940
  const start = this.input.selectionStart ?? 0;
@@ -3254,16 +3945,60 @@ var InputEmailMask = class extends BaseInputMask {
3254
3945
  this.input.setSelectionRange(start, end);
3255
3946
  }
3256
3947
  }
3948
+ this.isSuggestionDismissed = false;
3257
3949
  this.currentSuggestionIndex = 0;
3258
3950
  this.updateSuggestion({ announce: true, immediate: false });
3259
3951
  }
3952
+ handlePaste(e) {
3953
+ if (this.options.disabled || this.isSensitiveField()) return;
3954
+ const raw = this.getClipboardPlainText(e);
3955
+ const prepared = this.preparePastedText(raw, 512);
3956
+ if (prepared === raw) {
3957
+ return;
3958
+ }
3959
+ e.preventDefault();
3960
+ const start = this.input.selectionStart ?? this.input.value.length;
3961
+ const end = this.input.selectionEnd ?? start;
3962
+ const before = this.input.value.slice(0, start);
3963
+ const after = this.input.value.slice(end);
3964
+ const expected = before + prepared + after;
3965
+ const finalExpected = this.options.autoLowercase ? expected.toLowerCase() : expected;
3966
+ if (typeof document !== "undefined" && getDeepActiveElement(this.input.ownerDocument) === this.input && typeof document.execCommand === "function") {
3967
+ try {
3968
+ const execOk = document.execCommand("insertText", false, prepared);
3969
+ if (execOk && this.input.value === finalExpected) {
3970
+ return;
3971
+ }
3972
+ } catch {
3973
+ }
3974
+ }
3975
+ this.setNativeValue(expected);
3976
+ const nextCursor = start + prepared.length;
3977
+ this.input.setSelectionRange(nextCursor, nextCursor);
3978
+ this.handleInput();
3979
+ }
3260
3980
  handleKeyDown(e) {
3261
- if (this.options.disabled || this.isPasswordInput() || isImeComposing(e)) return;
3981
+ if (this.options.disabled || this.isSensitiveField() || isImeComposing(e)) return;
3262
3982
  if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
3263
3983
  const hasSuggestion = Boolean(this.currentSuggestion.remaining) && !this.currentSuggestion.isHintOnly;
3264
3984
  const cursor = this.input.selectionStart ?? 0;
3265
3985
  const isAtEnd = cursor === this.input.value.length;
3266
3986
  const isNotEmpty = this.input.value.length > 0;
3987
+ if (e.key === "Escape" && hasSuggestion) {
3988
+ e.preventDefault();
3989
+ this.isSuggestionDismissed = true;
3990
+ this.currentSuggestion = { full: this.input.value, remaining: "", matchedDomain: null };
3991
+ if (this.srAnnounceTimerId !== null) {
3992
+ clearTimeout(this.srAnnounceTimerId);
3993
+ this.srAnnounceTimerId = null;
3994
+ }
3995
+ this.lastAnnouncedSuggestion = "";
3996
+ if (this.srStatusEl) {
3997
+ this.srStatusEl.textContent = "";
3998
+ }
3999
+ this.clearGhost();
4000
+ return;
4001
+ }
3267
4002
  if (this.options.cycleSuggestions && hasSuggestion && isNotEmpty && isAtEnd) {
3268
4003
  if (e.key === "ArrowDown") {
3269
4004
  e.preventDefault();
@@ -3298,7 +4033,9 @@ var InputEmailMask = class extends BaseInputMask {
3298
4033
  * Valide et applique la suggestion courante dans le champ natif.
3299
4034
  */
3300
4035
  acceptSuggestion() {
3301
- if (!this.currentSuggestion.remaining || this.currentSuggestion.isHintOnly || this.options.disabled || this.input.value.length === 0) return false;
4036
+ if (!this.currentSuggestion.remaining || this.currentSuggestion.isHintOnly || this.options.disabled || this.isSensitiveField() || this.input.value.length === 0) {
4037
+ return false;
4038
+ }
3302
4039
  const completed = this.currentSuggestion.full;
3303
4040
  this.setNativeValue(completed);
3304
4041
  this.input.setSelectionRange(completed.length, completed.length);
@@ -3308,8 +4045,9 @@ var InputEmailMask = class extends BaseInputMask {
3308
4045
  if (this.options.onChange) {
3309
4046
  this.options.onChange(detail);
3310
4047
  }
3311
- this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: true, detail }));
3312
- this.input.dispatchEvent(new CustomEvent("mask:complete", { bubbles: true, detail }));
4048
+ const allowBubble = !this.isSensitiveField();
4049
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: allowBubble, detail }));
4050
+ this.input.dispatchEvent(new CustomEvent("mask:complete", { bubbles: allowBubble, detail }));
3313
4051
  return true;
3314
4052
  }
3315
4053
  /**
@@ -3336,6 +4074,7 @@ var InputEmailMask = class extends BaseInputMask {
3336
4074
  }
3337
4075
  handleFocus() {
3338
4076
  this.wrapper.classList.add("is-focused");
4077
+ this.isSuggestionDismissed = false;
3339
4078
  this.syncGhostStyles();
3340
4079
  this.updateSuggestion();
3341
4080
  }
@@ -3349,7 +4088,7 @@ var InputEmailMask = class extends BaseInputMask {
3349
4088
  if (this.srStatusEl) {
3350
4089
  this.srStatusEl.textContent = "";
3351
4090
  }
3352
- if (this.isPasswordInput()) {
4091
+ if (this.isSensitiveField()) {
3353
4092
  this.lastNotifiedValue = "";
3354
4093
  this.lastTrackedValue = "";
3355
4094
  this.clearGhost();
@@ -3360,7 +4099,7 @@ var InputEmailMask = class extends BaseInputMask {
3360
4099
  if (this.options.onChange) {
3361
4100
  this.options.onChange(detail);
3362
4101
  }
3363
- this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: true, detail }));
4102
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: !this.isSensitiveField(), detail }));
3364
4103
  }
3365
4104
  handleAttributeMutation(attrName) {
3366
4105
  super.handleAttributeMutation(attrName);
@@ -3387,6 +4126,7 @@ var InputEmailMask = class extends BaseInputMask {
3387
4126
  }
3388
4127
  setValue(val) {
3389
4128
  const str = val !== null && val !== void 0 ? String(val) : "";
4129
+ this.isSuggestionDismissed = false;
3390
4130
  this.setNativeValue(str);
3391
4131
  this.updateSuggestion();
3392
4132
  }
@@ -3429,17 +4169,1928 @@ var InputEmailMask = class extends BaseInputMask {
3429
4169
  }
3430
4170
  };
3431
4171
 
3432
- // src/mask/index.ts
3433
- var Mask = {
3434
- BaseInputMask,
3435
- InputMask,
3436
- MaskEngine,
3437
- MaskHistory,
3438
- MaskKeyboard,
3439
- AmountEngine,
3440
- InputAmountMask,
3441
- EmailEngine,
3442
- InputEmailMask
4172
+ // src/mask/DateUTCEngine.ts
4173
+ var DATE_UTC_PRESETS = {
4174
+ iso: { format: "YYYY-MM-DD HH:mm:ss" },
4175
+ "iso-t": { format: "YYYY-MM-DD\\THH:mm:ss" },
4176
+ fr: {
4177
+ format: "DD/MM/YYYY HH:mm",
4178
+ placeholderTokens: { DD: "jj", MM: "mm", YYYY: "aaaa", HH: "hh", mm: "mm" }
4179
+ },
4180
+ "fr-sec": {
4181
+ format: "DD/MM/YYYY HH:mm:ss",
4182
+ placeholderTokens: { DD: "jj", MM: "mm", YYYY: "aaaa", HH: "hh", mm: "mm", ss: "ss" }
4183
+ },
4184
+ us: { format: "MM/DD/YYYY HH:mm" },
4185
+ "us-12h": { format: "MM/DD/YYYY hh:mm A" },
4186
+ uk: { format: "DD/MM/YYYY HH:mm" },
4187
+ no: { format: "DD/MM-YYYY HH:mm" },
4188
+ cz: { format: "DD. MM. YYYY HH:mm" },
4189
+ de: { format: "DD.MM.YYYY HH:mm" },
4190
+ jp: { format: "YYYY/MM/DD HH:mm" }
4191
+ };
4192
+ var DEFAULT_PLACEHOLDERS = {
4193
+ YYYY: "YYYY",
4194
+ MM: "MM",
4195
+ DD: "DD",
4196
+ HH: "HH",
4197
+ hh: "hh",
4198
+ mm: "mm",
4199
+ ss: "ss",
4200
+ A: "AM"
4201
+ };
4202
+ var TOKEN_DEFS = [
4203
+ { token: "YYYY", length: 4 },
4204
+ { token: "MM", length: 2 },
4205
+ { token: "DD", length: 2 },
4206
+ { token: "HH", length: 2 },
4207
+ { token: "hh", length: 2 },
4208
+ { token: "mm", length: 2 },
4209
+ { token: "ss", length: 2 },
4210
+ { token: "A", length: 2 }
4211
+ ];
4212
+ var MAX_FORMAT_LENGTH = 128;
4213
+ var MAX_INPUT_LENGTH = 512;
4214
+ var DATE_SEPARATORS = /* @__PURE__ */ new Set(["/", "-", ".", ":", " ", "T", "t"]);
4215
+ var TIME_TOKEN_KINDS = /* @__PURE__ */ new Set(["HH", "hh", "mm", "ss", "A"]);
4216
+ function isAsciiDigit(ch) {
4217
+ return ch >= "0" && ch <= "9";
4218
+ }
4219
+ function parseAsciiInt(str) {
4220
+ let val = 0;
4221
+ for (let i = 0; i < str.length; i++) {
4222
+ const code = str.charCodeAt(i);
4223
+ if (code < 48 || code > 57) return NaN;
4224
+ val = val * 10 + (code - 48);
4225
+ }
4226
+ return str.length > 0 ? val : NaN;
4227
+ }
4228
+ function normalizeSegmentPlaceholder(raw, length, fallback) {
4229
+ const graphemes = Array.from(raw || fallback);
4230
+ const fb = Array.from(fallback);
4231
+ while (graphemes.length < length) {
4232
+ graphemes.push(fb[graphemes.length] || fb[fb.length - 1] || "_");
4233
+ }
4234
+ return graphemes.slice(0, length).join("");
4235
+ }
4236
+ var DateUTCEngine = class _DateUTCEngine {
4237
+ formatSpec = "YYYY-MM-DD HH:mm";
4238
+ customPlaceholders = {};
4239
+ slots = [];
4240
+ segments = [];
4241
+ fullTemplate = "";
4242
+ prefixSlotsCount = 0;
4243
+ prefixString = "";
4244
+ editableCount = 0;
4245
+ hasMeridiemFlag = false;
4246
+ utcIndicator = " UTC";
4247
+ includeMilliseconds = false;
4248
+ convertPastedOffset = true;
4249
+ defaultTimeOnDateOnly = false;
4250
+ minTs = null;
4251
+ maxTs = null;
4252
+ constructor(options = {}) {
4253
+ this.updateOptions(options);
4254
+ }
4255
+ /**
4256
+ * Formate statiquement une date (Date, timestamp ms, ISO ou chaîne) selon les options données.
4257
+ */
4258
+ static format(value, options = {}) {
4259
+ const engine = new _DateUTCEngine(options);
4260
+ return engine.formatFromValue(value);
4261
+ }
4262
+ updateOptions(options = {}) {
4263
+ if (options.utcIndicator !== void 0) {
4264
+ this.utcIndicator = options.utcIndicator === false ? false : String(options.utcIndicator).slice(0, 32);
4265
+ }
4266
+ if (options.includeMilliseconds !== void 0) {
4267
+ this.includeMilliseconds = Boolean(options.includeMilliseconds);
4268
+ }
4269
+ if (options.convertPastedOffset !== void 0) {
4270
+ this.convertPastedOffset = options.convertPastedOffset !== false;
4271
+ }
4272
+ if (options.defaultTimeOnDateOnly !== void 0) {
4273
+ this.defaultTimeOnDateOnly = options.defaultTimeOnDateOnly;
4274
+ }
4275
+ if (options.min !== void 0) {
4276
+ this.minTs = this.normalizeBoundary(options.min);
4277
+ }
4278
+ if (options.max !== void 0) {
4279
+ this.maxTs = this.normalizeBoundary(options.max);
4280
+ }
4281
+ if (options.placeholderTokens !== void 0) {
4282
+ this.customPlaceholders = options.placeholderTokens || {};
4283
+ }
4284
+ if (options.format !== void 0 || this.slots.length === 0) {
4285
+ this.compile(options.format ?? this.formatSpec, options.placeholderTokens);
4286
+ }
4287
+ }
4288
+ setFormat(format, placeholderTokens) {
4289
+ if (placeholderTokens !== void 0) {
4290
+ this.customPlaceholders = placeholderTokens;
4291
+ }
4292
+ this.compile(format, this.customPlaceholders);
4293
+ }
4294
+ setUtcIndicator(indicator) {
4295
+ this.utcIndicator = indicator === false ? false : String(indicator).slice(0, 32);
4296
+ }
4297
+ getUtcIndicator() {
4298
+ return this.utcIndicator;
4299
+ }
4300
+ getFormat() {
4301
+ return this.formatSpec;
4302
+ }
4303
+ getFullTemplate() {
4304
+ return this.fullTemplate;
4305
+ }
4306
+ getGhostRemaining(formatted) {
4307
+ const suffix = this.utcIndicator ? this.utcIndicator : "";
4308
+ if (formatted.length >= this.fullTemplate.length) {
4309
+ return suffix;
4310
+ }
4311
+ return this.fullTemplate.slice(formatted.length) + suffix;
4312
+ }
4313
+ getPrefix() {
4314
+ return this.prefixString;
4315
+ }
4316
+ getPrefixLength() {
4317
+ return this.prefixSlotsCount;
4318
+ }
4319
+ getEditableCount() {
4320
+ return this.editableCount;
4321
+ }
4322
+ hasMeridiem() {
4323
+ return this.hasMeridiemFlag;
4324
+ }
4325
+ isNumericOnly() {
4326
+ return !this.hasMeridiemFlag;
4327
+ }
4328
+ getSegments() {
4329
+ return this.segments;
4330
+ }
4331
+ getSlots() {
4332
+ return this.slots;
4333
+ }
4334
+ isSeparatorAt(idx) {
4335
+ return idx >= 0 && idx < this.slots.length && this.slots[idx].isStatic;
4336
+ }
4337
+ getNextEditablePosition(fromIdx) {
4338
+ const start = Math.max(0, fromIdx);
4339
+ for (let i = start; i < this.slots.length; i++) {
4340
+ if (!this.slots[i].isStatic) return i;
4341
+ }
4342
+ return this.slots.length;
4343
+ }
4344
+ compile(format, overridePlaceholders) {
4345
+ const rawSpec = String(format || "YYYY-MM-DD HH:mm").trim().slice(0, MAX_FORMAT_LENGTH) || "YYYY-MM-DD HH:mm";
4346
+ this.formatSpec = rawSpec;
4347
+ const preset = Object.hasOwn(DATE_UTC_PRESETS, rawSpec) ? DATE_UTC_PRESETS[rawSpec] : null;
4348
+ const pattern = preset ? preset.format : rawSpec;
4349
+ const mergedPlaceholders = /* @__PURE__ */ Object.create(null);
4350
+ if (preset?.placeholderTokens) {
4351
+ for (const [k, v] of Object.entries(preset.placeholderTokens)) {
4352
+ if (Object.hasOwn(DEFAULT_PLACEHOLDERS, k) && typeof v === "string") {
4353
+ mergedPlaceholders[k] = v;
4354
+ }
4355
+ }
4356
+ }
4357
+ const sourceOverrides = overridePlaceholders !== void 0 ? overridePlaceholders : this.customPlaceholders;
4358
+ if (sourceOverrides && typeof sourceOverrides === "object") {
4359
+ for (const [k, v] of Object.entries(sourceOverrides)) {
4360
+ if (Object.hasOwn(DEFAULT_PLACEHOLDERS, k) && typeof v === "string") {
4361
+ mergedPlaceholders[k] = v;
4362
+ }
4363
+ }
4364
+ }
4365
+ this.slots = [];
4366
+ this.segments = [];
4367
+ this.hasMeridiemFlag = false;
4368
+ let template = "";
4369
+ let isPrefixMode = true;
4370
+ let i = 0;
4371
+ while (i < pattern.length) {
4372
+ const ch = pattern[i];
4373
+ if (ch === "\\" && i + 1 < pattern.length) {
4374
+ const lit = pattern[i + 1];
4375
+ this.slots.push({
4376
+ char: lit,
4377
+ isStatic: true,
4378
+ isPrefix: isPrefixMode,
4379
+ segmentIndex: -1,
4380
+ charIndexInSegment: -1,
4381
+ placeholder: lit
4382
+ });
4383
+ template += lit;
4384
+ i += 2;
4385
+ continue;
4386
+ }
4387
+ let matchedToken = null;
4388
+ for (const def of TOKEN_DEFS) {
4389
+ if (pattern.startsWith(def.token, i)) {
4390
+ matchedToken = def;
4391
+ break;
4392
+ }
4393
+ }
4394
+ if (matchedToken) {
4395
+ isPrefixMode = false;
4396
+ const { token, length } = matchedToken;
4397
+ if (token === "A") {
4398
+ this.hasMeridiemFlag = true;
4399
+ }
4400
+ const phRaw = mergedPlaceholders[token] ?? DEFAULT_PLACEHOLDERS[token];
4401
+ const ph = normalizeSegmentPlaceholder(phRaw, length, DEFAULT_PLACEHOLDERS[token]);
4402
+ const phChars = Array.from(ph);
4403
+ const segIdx = this.segments.length;
4404
+ const start = this.slots.length;
4405
+ for (let k = 0; k < length; k++) {
4406
+ this.slots.push({
4407
+ char: token === "A" ? "A" : "9",
4408
+ isStatic: false,
4409
+ isPrefix: false,
4410
+ segmentIndex: segIdx,
4411
+ charIndexInSegment: k,
4412
+ tokenKind: token,
4413
+ placeholder: phChars[k] || "_"
4414
+ });
4415
+ }
4416
+ this.segments.push({
4417
+ kind: token,
4418
+ start,
4419
+ end: start + length,
4420
+ length,
4421
+ placeholder: ph,
4422
+ followingSeparator: ""
4423
+ });
4424
+ template += ph;
4425
+ i += token.length;
4426
+ } else {
4427
+ this.slots.push({
4428
+ char: ch,
4429
+ isStatic: true,
4430
+ isPrefix: isPrefixMode,
4431
+ segmentIndex: -1,
4432
+ charIndexInSegment: -1,
4433
+ placeholder: ch
4434
+ });
4435
+ template += ch;
4436
+ i++;
4437
+ }
4438
+ }
4439
+ this.fullTemplate = template;
4440
+ this.editableCount = this.slots.filter((s) => !s.isStatic).length;
4441
+ this.prefixSlotsCount = 0;
4442
+ this.prefixString = "";
4443
+ for (const slot of this.slots) {
4444
+ if (slot.isPrefix) {
4445
+ this.prefixSlotsCount++;
4446
+ this.prefixString += slot.char;
4447
+ } else {
4448
+ break;
4449
+ }
4450
+ }
4451
+ for (let s = 0; s < this.segments.length; s++) {
4452
+ const seg = this.segments[s];
4453
+ let sep = "";
4454
+ for (let pos = seg.end; pos < this.slots.length && this.slots[pos].isStatic; pos++) {
4455
+ sep += this.slots[pos].char;
4456
+ }
4457
+ seg.followingSeparator = sep;
4458
+ }
4459
+ }
4460
+ /**
4461
+ * Extrait linéairement les caractères bruts valides alignés sur les slots.
4462
+ */
4463
+ extractRaw(input, expandSingleMeridiem = false) {
4464
+ const str = String(input ?? "").slice(0, MAX_INPUT_LENGTH);
4465
+ if (!str || this.slots.length === 0) return "";
4466
+ let raw = "";
4467
+ let inputIdx = 0;
4468
+ let slotIdx = 0;
4469
+ if (this.prefixSlotsCount > 0) {
4470
+ while (inputIdx < str.length && (str[inputIdx] === " " || str[inputIdx] === " ")) {
4471
+ inputIdx++;
4472
+ }
4473
+ let pIdx = 0;
4474
+ while (inputIdx < str.length && pIdx < this.prefixSlotsCount) {
4475
+ const pChar = this.slots[pIdx].char;
4476
+ const inChar = str[inputIdx];
4477
+ if (inChar.toUpperCase() === pChar.toUpperCase()) {
4478
+ inputIdx++;
4479
+ pIdx++;
4480
+ } else if (pChar === " " && inChar !== " ") {
4481
+ pIdx++;
4482
+ } else {
4483
+ break;
4484
+ }
4485
+ }
4486
+ slotIdx = this.prefixSlotsCount;
4487
+ }
4488
+ while (inputIdx < str.length && slotIdx < this.slots.length) {
4489
+ const slot = this.slots[slotIdx];
4490
+ const ch = str[inputIdx];
4491
+ if (slot.isStatic) {
4492
+ if (ch.toUpperCase() === slot.char.toUpperCase()) {
4493
+ inputIdx++;
4494
+ slotIdx++;
4495
+ } else {
4496
+ slotIdx++;
4497
+ }
4498
+ continue;
4499
+ }
4500
+ if (slot.tokenKind === "A") {
4501
+ const upper = ch.toUpperCase();
4502
+ if (slot.charIndexInSegment === 0) {
4503
+ if (upper === "A" || upper === "P") {
4504
+ raw += upper;
4505
+ inputIdx++;
4506
+ slotIdx++;
4507
+ const nextCh = inputIdx < str.length ? str[inputIdx].toUpperCase() : "";
4508
+ if (nextCh === "M") {
4509
+ raw += "M";
4510
+ inputIdx++;
4511
+ slotIdx++;
4512
+ } else if (expandSingleMeridiem) {
4513
+ raw += "M";
4514
+ slotIdx++;
4515
+ }
4516
+ } else {
4517
+ inputIdx++;
4518
+ }
4519
+ } else {
4520
+ if (upper === "M") {
4521
+ raw += "M";
4522
+ inputIdx++;
4523
+ slotIdx++;
4524
+ } else if (expandSingleMeridiem) {
4525
+ raw += "M";
4526
+ slotIdx++;
4527
+ } else {
4528
+ inputIdx++;
4529
+ }
4530
+ }
4531
+ continue;
4532
+ }
4533
+ if (isAsciiDigit(ch)) {
4534
+ raw += ch;
4535
+ inputIdx++;
4536
+ slotIdx++;
4537
+ } else {
4538
+ inputIdx++;
4539
+ }
4540
+ }
4541
+ return raw;
4542
+ }
4543
+ /**
4544
+ * Formate une saisie (brute ou partiellement formatée) selon le gabarit configuré.
4545
+ */
4546
+ format(input, expandSingleMeridiem = false) {
4547
+ if (this.slots.length === 0) return String(input ?? "").slice(0, MAX_INPUT_LENGTH);
4548
+ const cleanRaw = this.extractRaw(input, expandSingleMeridiem);
4549
+ if (cleanRaw.length === 0) {
4550
+ return this.prefixString;
4551
+ }
4552
+ let formatted = "";
4553
+ let rawIdx = 0;
4554
+ for (let i = 0; i < this.slots.length; i++) {
4555
+ const slot = this.slots[i];
4556
+ if (slot.isStatic) {
4557
+ const hasRemainingRaw = rawIdx < cleanRaw.length;
4558
+ const isPrefix = rawIdx === 0 && slot.isPrefix;
4559
+ const isCompletedSegmentTrailingSep = rawIdx > 0 && rawIdx === cleanRaw.length;
4560
+ if (hasRemainingRaw || isPrefix || isCompletedSegmentTrailingSep) {
4561
+ formatted += slot.char;
4562
+ } else {
4563
+ break;
4564
+ }
4565
+ } else if (rawIdx < cleanRaw.length) {
4566
+ formatted += cleanRaw[rawIdx];
4567
+ rawIdx++;
4568
+ } else {
4569
+ break;
4570
+ }
4571
+ }
4572
+ return formatted;
4573
+ }
4574
+ /**
4575
+ * Analyse complète de la saisie courante : formatage, complétude, validité calendaire UTC, Date & ISO.
4576
+ */
4577
+ analyze(input, expandSingleMeridiem = false) {
4578
+ const cleanRaw = this.extractRaw(input, expandSingleMeridiem);
4579
+ const formatted = this.formatFromCleanRaw(cleanRaw);
4580
+ const totalSlots = this.editableCount;
4581
+ const filledSlots = cleanRaw.length;
4582
+ const isComplete = totalSlots > 0 && filledSlots >= totalSlots;
4583
+ const extracted = this.extractSegmentValues(cleanRaw);
4584
+ const parts = extracted.parts;
4585
+ let date = null;
4586
+ let isoString = null;
4587
+ let timestamp = null;
4588
+ let isValid = false;
4589
+ if (isComplete && extracted.allSegmentsPresent) {
4590
+ const resolvedHour = this.resolveHour24(extracted);
4591
+ if (resolvedHour !== null) {
4592
+ const candidate = {
4593
+ year: parts.year,
4594
+ month: parts.month,
4595
+ day: parts.day,
4596
+ hour: resolvedHour,
4597
+ minute: parts.minute ?? 0,
4598
+ second: parts.second ?? 0
4599
+ };
4600
+ const strictDate = this.buildStrictUTCDate(candidate);
4601
+ if (strictDate) {
4602
+ const ts = strictDate.getTime();
4603
+ const inMin = this.minTs === null || ts >= this.minTs;
4604
+ const inMax = this.maxTs === null || ts <= this.maxTs;
4605
+ if (inMin && inMax) {
4606
+ date = strictDate;
4607
+ timestamp = ts;
4608
+ isoString = this.formatDateToISO(strictDate);
4609
+ isValid = true;
4610
+ }
4611
+ }
4612
+ }
4613
+ }
4614
+ return {
4615
+ formatted,
4616
+ rawValue: isoString || "",
4617
+ isoString,
4618
+ date,
4619
+ timestamp,
4620
+ parts,
4621
+ isComplete,
4622
+ isValid,
4623
+ totalSlots,
4624
+ filledSlots
4625
+ };
4626
+ }
4627
+ /**
4628
+ * Calcule la nouvelle position du curseur en préservant le nombre de caractères bruts avant lui.
4629
+ */
4630
+ mapCursorPosition(inputValue, inputCursor, formatted) {
4631
+ const minPos = this.prefixSlotsCount;
4632
+ const safeInput = String(inputValue ?? "");
4633
+ const safeFormatted = String(formatted ?? "");
4634
+ if (inputCursor <= 0 || !safeFormatted) return minPos;
4635
+ const rawBeforeCursor = this.extractRaw(safeInput.slice(0, inputCursor), false);
4636
+ const targetRawCount = rawBeforeCursor.length;
4637
+ if (targetRawCount === 0) {
4638
+ return Math.max(minPos, Math.min(this.getNextEditablePosition(0), safeFormatted.length));
4639
+ }
4640
+ let currentRawCount = 0;
4641
+ let targetPos = safeFormatted.length;
4642
+ for (let i = 0; i < safeFormatted.length && i < this.slots.length; i++) {
4643
+ if (!this.slots[i].isStatic) {
4644
+ currentRawCount++;
4645
+ if (currentRawCount === targetRawCount) {
4646
+ targetPos = i + 1;
4647
+ break;
4648
+ }
4649
+ }
4650
+ }
4651
+ while (targetPos < safeFormatted.length && this.slots[targetPos] && this.slots[targetPos].isStatic) {
4652
+ targetPos++;
4653
+ }
4654
+ return Math.max(minPos, Math.min(targetPos, safeFormatted.length));
4655
+ }
4656
+ /**
4657
+ * Gère la frappe d'un séparateur au clavier segment par segment (ex: '5' + '/' -> '05/', '5' + '.' -> '05. ').
4658
+ * Résout atomiquement les séparateurs composites ('DD. MM. YYYY HH:mm') sans jamais dédoubler l'espace.
4659
+ */
4660
+ tryHandleSeparatorKey(currentValue, cursor, key) {
4661
+ const none = { handled: false, formatted: currentValue, cursor };
4662
+ if (!key || key.length !== 1) return none;
4663
+ if (cursor < this.slots.length && this.slots[cursor].isStatic && this.separatorMatchesKey(this.slots[cursor].char, key)) {
4664
+ const nextEditable = this.getNextEditablePosition(cursor + 1);
4665
+ const formatted = this.format(currentValue);
4666
+ return { handled: true, formatted, cursor: Math.min(nextEditable, formatted.length) };
4667
+ }
4668
+ if (cursor > this.prefixSlotsCount && cursor - 1 < this.slots.length && this.slots[cursor - 1].isStatic) {
4669
+ let k = cursor - 1;
4670
+ while (k >= this.prefixSlotsCount && this.slots[k].isStatic) {
4671
+ if (this.separatorMatchesKey(this.slots[k].char, key)) {
4672
+ const nextEditable = this.getNextEditablePosition(k + 1);
4673
+ const formatted = this.format(currentValue);
4674
+ return { handled: true, formatted, cursor: Math.min(nextEditable, formatted.length) };
4675
+ }
4676
+ k--;
4677
+ }
4678
+ }
4679
+ let segIdx = -1;
4680
+ for (let i = 0; i < this.segments.length; i++) {
4681
+ const seg2 = this.segments[i];
4682
+ if (cursor >= seg2.start && cursor <= seg2.end) {
4683
+ segIdx = i;
4684
+ break;
4685
+ }
4686
+ }
4687
+ if (segIdx === -1) return none;
4688
+ const seg = this.segments[segIdx];
4689
+ if (!seg.followingSeparator) return none;
4690
+ if (!this.followingSeparatorMatchesKey(seg.followingSeparator, key)) {
4691
+ return none;
4692
+ }
4693
+ const rawInSeg = currentValue.slice(seg.start, Math.min(cursor, seg.end)).replace(/\D/g, "");
4694
+ if (seg.kind !== "YYYY" && seg.kind !== "A" && rawInSeg.length > 0 && rawInSeg.length < seg.length) {
4695
+ const paddedSeg = "0".repeat(seg.length - rawInSeg.length) + rawInSeg;
4696
+ const tail = currentValue.slice(Math.min(currentValue.length, seg.end));
4697
+ const candidate = currentValue.slice(0, seg.start) + paddedSeg + seg.followingSeparator + tail;
4698
+ const formatted = this.format(candidate);
4699
+ const nextEditable = this.getNextEditablePosition(seg.end);
4700
+ return { handled: true, formatted, cursor: Math.min(nextEditable, formatted.length) };
4701
+ }
4702
+ if (cursor === seg.end) {
4703
+ const formatted = this.format(currentValue);
4704
+ const nextEditable = this.getNextEditablePosition(seg.end);
4705
+ return { handled: true, formatted, cursor: Math.min(nextEditable, formatted.length) };
4706
+ }
4707
+ return none;
4708
+ }
4709
+ /**
4710
+ * Formate un Date, timestamp numérique, ISO string ou valeur partielle vers le gabarit configuré.
4711
+ * Immunisé contre Invalid Date et NaN.
4712
+ */
4713
+ formatFromValue(value) {
4714
+ if (value === null || value === void 0) return this.prefixString;
4715
+ if (value instanceof Date) {
4716
+ if (Number.isNaN(value.getTime())) return this.prefixString;
4717
+ return this.formatPartsToTemplate(this.dateToUTCParts(value));
4718
+ }
4719
+ if (typeof value === "number") {
4720
+ if (!Number.isFinite(value)) return this.prefixString;
4721
+ const d = new Date(value);
4722
+ if (Number.isNaN(d.getTime())) return this.prefixString;
4723
+ return this.formatPartsToTemplate(this.dateToUTCParts(d));
4724
+ }
4725
+ const str = String(value).slice(0, MAX_INPUT_LENGTH).trim();
4726
+ if (!str) return this.prefixString;
4727
+ const pasted = this.parsePasted(str);
4728
+ if (pasted.matched) {
4729
+ return pasted.formatted;
4730
+ }
4731
+ if (pasted.rejected) {
4732
+ return this.prefixString;
4733
+ }
4734
+ return this.format(str, true);
4735
+ }
4736
+ /**
4737
+ * Formate une chaîne issue d'une affectation native (input.value = '...') sans altérer la frappe
4738
+ * en cours par le parseur segmenté (seul un ISO 8601 complet avec horaire est reconnu).
4739
+ */
4740
+ formatFromNativeValue(strVal) {
4741
+ const str = String(strVal ?? "").slice(0, MAX_INPUT_LENGTH);
4742
+ if (!str) return this.prefixString;
4743
+ const trimmed = str.trim();
4744
+ if (trimmed.length >= 16) {
4745
+ const iso = this.parseISO8601Linear(trimmed);
4746
+ if (iso && !iso.dateOnly) {
4747
+ const res = this.parsePasted(trimmed);
4748
+ if (res.matched) return res.formatted;
4749
+ }
4750
+ }
4751
+ return this.format(str, false);
4752
+ }
4753
+ /**
4754
+ * Parse universellement une chaîne collée en O(N) :
4755
+ * 1) ISO 8601 (YYYY-MM-DD[T| ]HH:mm[:ss][.sss][Z|±HH:MM], date seule)
4756
+ * 2) Format configuré de l'instance avec tolérance des segments courts (ex: 2/3/2026 9:5)
4757
+ */
4758
+ parsePasted(rawText) {
4759
+ const fail = { matched: false, formatted: "", cursor: 0 };
4760
+ const rejected = { matched: false, rejected: true, formatted: "", cursor: 0 };
4761
+ const text = String(rawText ?? "").slice(0, MAX_INPUT_LENGTH).trim();
4762
+ if (!text || this.segments.length === 0) return fail;
4763
+ const looksLikeIso = text.length >= 10 && isAsciiDigit(text[0]) && isAsciiDigit(text[1]) && isAsciiDigit(text[2]) && isAsciiDigit(text[3]) && text[4] === "-" && isAsciiDigit(text[5]) && isAsciiDigit(text[6]) && text[7] === "-" && isAsciiDigit(text[8]) && isAsciiDigit(text[9]);
4764
+ const iso = this.parseISO8601Linear(text);
4765
+ if (iso) {
4766
+ if (iso.dateOnly) {
4767
+ return this.formatDateOnlyMatch(
4768
+ { year: iso.year, month: iso.month, day: iso.day },
4769
+ rejected
4770
+ );
4771
+ }
4772
+ if (iso.offsetMinutes !== null && iso.offsetMinutes !== 0 && !this.convertPastedOffset) {
4773
+ return rejected;
4774
+ }
4775
+ const baseDate = this.buildStrictUTCDate({
4776
+ year: iso.year,
4777
+ month: iso.month,
4778
+ day: iso.day,
4779
+ hour: iso.hour,
4780
+ minute: iso.minute,
4781
+ second: iso.second
4782
+ });
4783
+ if (!baseDate) return rejected;
4784
+ let targetDate = baseDate;
4785
+ let offsetConverted;
4786
+ if (iso.offsetMinutes !== null && iso.offsetMinutes !== 0) {
4787
+ const utcMs = baseDate.getTime() - iso.offsetMinutes * 6e4;
4788
+ targetDate = new Date(utcMs);
4789
+ if (Number.isNaN(targetDate.getTime())) return rejected;
4790
+ offsetConverted = {
4791
+ original: text,
4792
+ offsetMinutes: iso.offsetMinutes,
4793
+ utcIso: this.formatDateToISO(targetDate)
4794
+ };
4795
+ }
4796
+ const formatted = this.formatPartsToTemplate(this.dateToUTCParts(targetDate));
4797
+ return {
4798
+ matched: true,
4799
+ formatted,
4800
+ cursor: formatted.length,
4801
+ offsetConverted
4802
+ };
4803
+ }
4804
+ if (looksLikeIso && text.length > 10 && (text[10] === "T" || text[10] === "t" || this.segments[0]?.kind !== "YYYY")) {
4805
+ return rejected;
4806
+ }
4807
+ return this.parseConfiguredFormatLinear(text);
4808
+ }
4809
+ /**
4810
+ * Formate une date UTC valide dans la locale demandée via Intl.DateTimeFormat (aperçu miroir).
4811
+ */
4812
+ formatLocal(date, locale, intlOptions) {
4813
+ if (!date || Number.isNaN(date.getTime())) return null;
4814
+ try {
4815
+ const opts = intlOptions || {
4816
+ dateStyle: "short",
4817
+ timeStyle: "medium"
4818
+ };
4819
+ return new Intl.DateTimeFormat(locale, opts).format(date);
4820
+ } catch {
4821
+ return null;
4822
+ }
4823
+ }
4824
+ // ==========================================================================
4825
+ // Helpers internes purs
4826
+ // ==========================================================================
4827
+ normalizeBoundary(val) {
4828
+ if (val === null || val === void 0) return null;
4829
+ if (val instanceof Date) {
4830
+ const t = val.getTime();
4831
+ return Number.isNaN(t) ? null : t;
4832
+ }
4833
+ if (typeof val === "number") {
4834
+ return Number.isFinite(val) ? val : null;
4835
+ }
4836
+ const str = String(val).slice(0, MAX_INPUT_LENGTH).trim();
4837
+ if (!str) return null;
4838
+ const iso = this.parseISO8601Linear(str);
4839
+ if (iso) {
4840
+ const d = this.buildStrictUTCDate({
4841
+ year: iso.year,
4842
+ month: iso.month,
4843
+ day: iso.day,
4844
+ hour: iso.hour,
4845
+ minute: iso.minute,
4846
+ second: iso.second
4847
+ });
4848
+ if (!d) return null;
4849
+ const offsetMs = iso.offsetMinutes ? iso.offsetMinutes * 6e4 : 0;
4850
+ return d.getTime() - offsetMs;
4851
+ }
4852
+ const res = this.analyze(str, true);
4853
+ return res.timestamp;
4854
+ }
4855
+ separatorMatchesKey(sepChar, key) {
4856
+ if (sepChar === key) return true;
4857
+ if ((sepChar === "T" || sepChar === "t") && (key === "T" || key === "t" || key === " ")) {
4858
+ return true;
4859
+ }
4860
+ return false;
4861
+ }
4862
+ followingSeparatorMatchesKey(followingSep, key) {
4863
+ let hasNonSpace = false;
4864
+ for (let i = 0; i < followingSep.length; i++) {
4865
+ if (followingSep[i] !== " ") {
4866
+ hasNonSpace = true;
4867
+ break;
4868
+ }
4869
+ }
4870
+ for (let i = 0; i < followingSep.length; i++) {
4871
+ const ch = followingSep[i];
4872
+ if (hasNonSpace && ch === " ") {
4873
+ continue;
4874
+ }
4875
+ if (this.separatorMatchesKey(ch, key)) return true;
4876
+ }
4877
+ return false;
4878
+ }
4879
+ formatFromCleanRaw(cleanRaw) {
4880
+ if (this.slots.length === 0) return "";
4881
+ if (cleanRaw.length === 0) return this.prefixString;
4882
+ let formatted = "";
4883
+ let rawIdx = 0;
4884
+ for (let i = 0; i < this.slots.length; i++) {
4885
+ const slot = this.slots[i];
4886
+ if (slot.isStatic) {
4887
+ const hasRemainingRaw = rawIdx < cleanRaw.length;
4888
+ const isPrefix = rawIdx === 0 && slot.isPrefix;
4889
+ const isCompletedSegmentTrailingSep = rawIdx > 0 && rawIdx === cleanRaw.length;
4890
+ if (hasRemainingRaw || isPrefix || isCompletedSegmentTrailingSep) {
4891
+ formatted += slot.char;
4892
+ } else {
4893
+ break;
4894
+ }
4895
+ } else if (rawIdx < cleanRaw.length) {
4896
+ formatted += cleanRaw[rawIdx];
4897
+ rawIdx++;
4898
+ } else {
4899
+ break;
4900
+ }
4901
+ }
4902
+ return formatted;
4903
+ }
4904
+ extractSegmentValues(cleanRaw) {
4905
+ const parts = {};
4906
+ let hour12;
4907
+ let meridiem;
4908
+ let rawOffset = 0;
4909
+ let allPresent = true;
4910
+ for (const seg of this.segments) {
4911
+ if (rawOffset + seg.length > cleanRaw.length) {
4912
+ allPresent = false;
4913
+ break;
4914
+ }
4915
+ const chunk = cleanRaw.slice(rawOffset, rawOffset + seg.length);
4916
+ rawOffset += seg.length;
4917
+ switch (seg.kind) {
4918
+ case "YYYY":
4919
+ parts.year = parseAsciiInt(chunk);
4920
+ break;
4921
+ case "MM":
4922
+ parts.month = parseAsciiInt(chunk);
4923
+ break;
4924
+ case "DD":
4925
+ parts.day = parseAsciiInt(chunk);
4926
+ break;
4927
+ case "HH":
4928
+ parts.hour = parseAsciiInt(chunk);
4929
+ break;
4930
+ case "hh":
4931
+ hour12 = parseAsciiInt(chunk);
4932
+ break;
4933
+ case "mm":
4934
+ parts.minute = parseAsciiInt(chunk);
4935
+ break;
4936
+ case "ss":
4937
+ parts.second = parseAsciiInt(chunk);
4938
+ break;
4939
+ case "A":
4940
+ if (chunk === "AM" || chunk === "PM") {
4941
+ meridiem = chunk;
4942
+ } else {
4943
+ allPresent = false;
4944
+ }
4945
+ break;
4946
+ }
4947
+ }
4948
+ if (parts.year === void 0 || parts.month === void 0 || parts.day === void 0) {
4949
+ allPresent = false;
4950
+ }
4951
+ if (parts.hour === void 0 && hour12 === void 0) {
4952
+ allPresent = false;
4953
+ }
4954
+ if (allPresent && hour12 !== void 0) {
4955
+ const resolved = this.resolveHour24({ parts, hour12, meridiem });
4956
+ if (resolved !== null) {
4957
+ parts.hour = resolved;
4958
+ }
4959
+ }
4960
+ return { parts, hour12, meridiem, allSegmentsPresent: allPresent };
4961
+ }
4962
+ resolveHour24(extracted) {
4963
+ if (extracted.hour12 !== void 0) {
4964
+ const h12 = extracted.hour12;
4965
+ if (h12 < 1 || h12 > 12 || !extracted.meridiem) return null;
4966
+ if (extracted.meridiem === "AM") {
4967
+ return h12 === 12 ? 0 : h12;
4968
+ }
4969
+ return h12 === 12 ? 12 : h12 + 12;
4970
+ }
4971
+ if (extracted.parts.hour !== void 0) {
4972
+ return extracted.parts.hour >= 0 && extracted.parts.hour <= 23 ? extracted.parts.hour : null;
4973
+ }
4974
+ return null;
4975
+ }
4976
+ /**
4977
+ * Validation calendaire stricte sans rollover ni piège Date.UTC(0..99).
4978
+ */
4979
+ buildStrictUTCDate(parts) {
4980
+ const { year, month, day, hour, minute, second } = parts;
4981
+ if (!Number.isInteger(year) || year < 1 || year > 9999 || !Number.isInteger(month) || month < 1 || month > 12 || !Number.isInteger(day) || day < 1 || day > 31 || !Number.isInteger(hour) || hour < 0 || hour > 23 || !Number.isInteger(minute) || minute < 0 || minute > 59 || !Number.isInteger(second) || second < 0 || second > 59) {
4982
+ return null;
4983
+ }
4984
+ const d = /* @__PURE__ */ new Date(0);
4985
+ d.setUTCFullYear(year, month - 1, day);
4986
+ d.setUTCHours(hour, minute, second, 0);
4987
+ if (d.getUTCFullYear() !== year || d.getUTCMonth() !== month - 1 || d.getUTCDate() !== day || d.getUTCHours() !== hour || d.getUTCMinutes() !== minute || d.getUTCSeconds() !== second) {
4988
+ return null;
4989
+ }
4990
+ return d;
4991
+ }
4992
+ dateToUTCParts(d) {
4993
+ return {
4994
+ year: d.getUTCFullYear(),
4995
+ month: d.getUTCMonth() + 1,
4996
+ day: d.getUTCDate(),
4997
+ hour: d.getUTCHours(),
4998
+ minute: d.getUTCMinutes(),
4999
+ second: d.getUTCSeconds()
5000
+ };
5001
+ }
5002
+ formatDateToISO(d) {
5003
+ const y = String(d.getUTCFullYear()).padStart(4, "0");
5004
+ const m = String(d.getUTCMonth() + 1).padStart(2, "0");
5005
+ const day = String(d.getUTCDate()).padStart(2, "0");
5006
+ const h = String(d.getUTCHours()).padStart(2, "0");
5007
+ const min = String(d.getUTCMinutes()).padStart(2, "0");
5008
+ const s = String(d.getUTCSeconds()).padStart(2, "0");
5009
+ if (this.includeMilliseconds) {
5010
+ const ms = String(d.getUTCMilliseconds()).padStart(3, "0");
5011
+ return `${y}-${m}-${day}T${h}:${min}:${s}.${ms}Z`;
5012
+ }
5013
+ return `${y}-${m}-${day}T${h}:${min}:${s}Z`;
5014
+ }
5015
+ formatPartsToTemplate(parts) {
5016
+ let raw = "";
5017
+ for (const seg of this.segments) {
5018
+ switch (seg.kind) {
5019
+ case "YYYY":
5020
+ raw += String(parts.year).padStart(4, "0").slice(-4);
5021
+ break;
5022
+ case "MM":
5023
+ raw += String(parts.month).padStart(2, "0");
5024
+ break;
5025
+ case "DD":
5026
+ raw += String(parts.day).padStart(2, "0");
5027
+ break;
5028
+ case "HH":
5029
+ raw += String(parts.hour).padStart(2, "0");
5030
+ break;
5031
+ case "hh": {
5032
+ const h12 = parts.hour % 12 === 0 ? 12 : parts.hour % 12;
5033
+ raw += String(h12).padStart(2, "0");
5034
+ break;
5035
+ }
5036
+ case "mm":
5037
+ raw += String(parts.minute).padStart(2, "0");
5038
+ break;
5039
+ case "ss":
5040
+ raw += String(parts.second).padStart(2, "0");
5041
+ break;
5042
+ case "A":
5043
+ raw += parts.hour >= 12 ? "PM" : "AM";
5044
+ break;
5045
+ }
5046
+ }
5047
+ return this.formatFromCleanRaw(raw);
5048
+ }
5049
+ formatDateOnlyMatch(dateParts, fail) {
5050
+ const check = this.buildStrictUTCDate({
5051
+ year: dateParts.year,
5052
+ month: dateParts.month,
5053
+ day: dateParts.day,
5054
+ hour: 0,
5055
+ minute: 0,
5056
+ second: 0
5057
+ });
5058
+ if (!check) return fail;
5059
+ if (typeof this.defaultTimeOnDateOnly === "string" && this.defaultTimeOnDateOnly.trim()) {
5060
+ const parsedTime = this.parseDefaultTime(this.defaultTimeOnDateOnly.trim());
5061
+ if (parsedTime) {
5062
+ const formatted2 = this.formatPartsToTemplate({
5063
+ ...dateParts,
5064
+ hour: parsedTime.hour,
5065
+ minute: parsedTime.minute,
5066
+ second: parsedTime.second
5067
+ });
5068
+ return { matched: true, formatted: formatted2, cursor: formatted2.length };
5069
+ }
5070
+ }
5071
+ let rawDate = "";
5072
+ for (const seg of this.segments) {
5073
+ if (TIME_TOKEN_KINDS.has(seg.kind)) break;
5074
+ if (seg.kind === "YYYY") rawDate += String(dateParts.year).padStart(4, "0");
5075
+ else if (seg.kind === "MM") rawDate += String(dateParts.month).padStart(2, "0");
5076
+ else if (seg.kind === "DD") rawDate += String(dateParts.day).padStart(2, "0");
5077
+ }
5078
+ if (!rawDate) return fail;
5079
+ const formatted = this.formatFromCleanRaw(rawDate);
5080
+ return { matched: true, formatted, cursor: formatted.length };
5081
+ }
5082
+ parseDefaultTime(timeStr) {
5083
+ const parts = timeStr.split(":");
5084
+ if (parts.length < 2 || parts.length > 3) return null;
5085
+ const hour = parseAsciiInt(parts[0]);
5086
+ const minute = parseAsciiInt(parts[1]);
5087
+ const second = parts.length === 3 ? parseAsciiInt(parts[2]) : 0;
5088
+ if (Number.isNaN(hour) || hour < 0 || hour > 23 || Number.isNaN(minute) || minute < 0 || minute > 59 || Number.isNaN(second) || second < 0 || second > 59) {
5089
+ return null;
5090
+ }
5091
+ return { hour, minute, second };
5092
+ }
5093
+ /**
5094
+ * Parseur ISO 8601 strict en complexité linéaire O(N) sans regex à backtracking.
5095
+ */
5096
+ parseISO8601Linear(str) {
5097
+ if (str.length < 10) return null;
5098
+ for (const idx of [0, 1, 2, 3, 5, 6, 8, 9]) {
5099
+ if (!isAsciiDigit(str[idx])) return null;
5100
+ }
5101
+ if (str[4] !== "-" || str[7] !== "-") return null;
5102
+ const year = parseAsciiInt(str.slice(0, 4));
5103
+ const month = parseAsciiInt(str.slice(5, 7));
5104
+ const day = parseAsciiInt(str.slice(8, 10));
5105
+ if (str.length === 10) {
5106
+ return { year, month, day, hour: 0, minute: 0, second: 0, dateOnly: true, offsetMinutes: null };
5107
+ }
5108
+ let pos = 10;
5109
+ if (str[pos] !== "T" && str[pos] !== "t" && str[pos] !== " ") return null;
5110
+ pos++;
5111
+ if (pos + 5 > str.length) return null;
5112
+ if (!isAsciiDigit(str[pos]) || !isAsciiDigit(str[pos + 1]) || str[pos + 2] !== ":" || !isAsciiDigit(str[pos + 3]) || !isAsciiDigit(str[pos + 4])) {
5113
+ return null;
5114
+ }
5115
+ const hour = parseAsciiInt(str.slice(pos, pos + 2));
5116
+ const minute = parseAsciiInt(str.slice(pos + 3, pos + 5));
5117
+ pos += 5;
5118
+ let second = 0;
5119
+ if (pos < str.length && str[pos] === ":") {
5120
+ pos++;
5121
+ if (pos + 2 > str.length || !isAsciiDigit(str[pos]) || !isAsciiDigit(str[pos + 1])) return null;
5122
+ second = parseAsciiInt(str.slice(pos, pos + 2));
5123
+ pos += 2;
5124
+ }
5125
+ if (pos < str.length && str[pos] === ".") {
5126
+ pos++;
5127
+ const fracStart = pos;
5128
+ while (pos < str.length && isAsciiDigit(str[pos])) {
5129
+ pos++;
5130
+ }
5131
+ if (pos === fracStart) return null;
5132
+ }
5133
+ let offsetMinutes = null;
5134
+ if (pos < str.length) {
5135
+ while (pos < str.length && str[pos] === " ") pos++;
5136
+ if (pos < str.length) {
5137
+ const tzChar = str[pos];
5138
+ if (tzChar === "Z" || tzChar === "z") {
5139
+ offsetMinutes = 0;
5140
+ pos++;
5141
+ } else if (tzChar === "+" || tzChar === "-") {
5142
+ const sign = tzChar === "-" ? -1 : 1;
5143
+ pos++;
5144
+ if (pos + 2 > str.length || !isAsciiDigit(str[pos]) || !isAsciiDigit(str[pos + 1])) return null;
5145
+ const offH = parseAsciiInt(str.slice(pos, pos + 2));
5146
+ pos += 2;
5147
+ let offM = 0;
5148
+ if (pos < str.length) {
5149
+ if (str[pos] === ":") pos++;
5150
+ if (pos + 2 > str.length || !isAsciiDigit(str[pos]) || !isAsciiDigit(str[pos + 1])) return null;
5151
+ offM = parseAsciiInt(str.slice(pos, pos + 2));
5152
+ pos += 2;
5153
+ }
5154
+ if (offH > 14 || offM > 59 || offH === 14 && offM !== 0) {
5155
+ return null;
5156
+ }
5157
+ offsetMinutes = sign * (offH * 60 + offM);
5158
+ } else if (str.slice(pos).toUpperCase() === "UTC") {
5159
+ offsetMinutes = 0;
5160
+ pos = str.length;
5161
+ } else {
5162
+ return null;
5163
+ }
5164
+ }
5165
+ }
5166
+ if (pos !== str.length) return null;
5167
+ return { year, month, day, hour, minute, second, dateOnly: false, offsetMinutes };
5168
+ }
5169
+ /**
5170
+ * Parseur segmenté O(N) aligné sur le gabarit configuré de l'instance.
5171
+ * Tolère les segments courts (ex: 2/3/2026 9:5 ou 2. 3. 2026 9:5 ou 2/3-2026 9:5 pm)
5172
+ * sans deviner sur les dates ambiguës (03/04/2026 suit strictement l'ordre configuré).
5173
+ */
5174
+ parseConfiguredFormatLinear(text) {
5175
+ const fail = { matched: false, formatted: "", cursor: 0 };
5176
+ let cleaned = text;
5177
+ if (cleaned.toUpperCase().endsWith(" UTC")) {
5178
+ cleaned = cleaned.slice(0, -4).trim();
5179
+ } else if (cleaned.length > 2 && (cleaned.endsWith("Z") || cleaned.endsWith("z")) && isAsciiDigit(cleaned[cleaned.length - 2])) {
5180
+ cleaned = cleaned.slice(0, -1).trim();
5181
+ }
5182
+ if (this.prefixString && cleaned.toLowerCase().startsWith(this.prefixString.trim().toLowerCase())) {
5183
+ cleaned = cleaned.slice(this.prefixString.trim().length).trim();
5184
+ }
5185
+ const tokens = [];
5186
+ let start = -1;
5187
+ for (let i = 0; i < cleaned.length; i++) {
5188
+ const ch = cleaned[i];
5189
+ if (DATE_SEPARATORS.has(ch)) {
5190
+ if (start !== -1) {
5191
+ tokens.push(cleaned.slice(start, i));
5192
+ start = -1;
5193
+ }
5194
+ } else {
5195
+ if (start === -1) start = i;
5196
+ }
5197
+ }
5198
+ if (start !== -1) {
5199
+ tokens.push(cleaned.slice(start));
5200
+ }
5201
+ if (tokens.length === 0 || tokens.length > this.segments.length) return fail;
5202
+ let dateSegCount = 0;
5203
+ for (const seg of this.segments) {
5204
+ if (TIME_TOKEN_KINDS.has(seg.kind)) break;
5205
+ dateSegCount++;
5206
+ }
5207
+ const rawParts = [];
5208
+ let yearVal;
5209
+ let monthVal;
5210
+ let dayVal;
5211
+ for (let i = 0; i < tokens.length; i++) {
5212
+ const tok = tokens[i];
5213
+ const seg = this.segments[i];
5214
+ if (seg.kind === "A") {
5215
+ const up = tok.toUpperCase();
5216
+ if (up === "AM" || up === "A") rawParts.push("AM");
5217
+ else if (up === "PM" || up === "P") rawParts.push("PM");
5218
+ else return fail;
5219
+ continue;
5220
+ }
5221
+ for (let k = 0; k < tok.length; k++) {
5222
+ if (!isAsciiDigit(tok[k])) return fail;
5223
+ }
5224
+ if (seg.kind === "YYYY") {
5225
+ if (tok.length !== 4) return fail;
5226
+ yearVal = parseAsciiInt(tok);
5227
+ rawParts.push(tok);
5228
+ } else {
5229
+ if (tok.length < 1 || tok.length > 2) return fail;
5230
+ const padded = tok.length === 1 ? "0" + tok : tok;
5231
+ const val = parseAsciiInt(padded);
5232
+ if (seg.kind === "MM") monthVal = val;
5233
+ if (seg.kind === "DD") dayVal = val;
5234
+ rawParts.push(padded);
5235
+ }
5236
+ }
5237
+ if (tokens.length === dateSegCount && yearVal !== void 0 && monthVal !== void 0 && dayVal !== void 0) {
5238
+ return this.formatDateOnlyMatch({ year: yearVal, month: monthVal, day: dayVal }, fail);
5239
+ }
5240
+ const minRequired = this.segments.length;
5241
+ if (tokens.length < minRequired) {
5242
+ const hasMinDateAndHourMin = dateSegCount > 0 && tokens.length >= dateSegCount + 2 && this.segments[dateSegCount + 1]?.kind === "mm";
5243
+ if (!hasMinDateAndHourMin) return fail;
5244
+ }
5245
+ const formatted = this.formatFromCleanRaw(rawParts.join(""));
5246
+ return {
5247
+ matched: true,
5248
+ formatted,
5249
+ cursor: formatted.length
5250
+ };
5251
+ }
5252
+ };
5253
+
5254
+ // src/mask/InputDateUTCMask.ts
5255
+ var MAX_NOTIFICATION_ITERATIONS3 = 10;
5256
+ var InputDateUTCMask = class extends BaseInputMask {
5257
+ engine;
5258
+ history;
5259
+ isComposing = false;
5260
+ isUndoingRedoing = false;
5261
+ isMouseDown = false;
5262
+ isApplying = false;
5263
+ isNotifying = false;
5264
+ hasPendingNotification = false;
5265
+ lastValue = "";
5266
+ lastValueLength = 0;
5267
+ lastInputType = "";
5268
+ inferredInputModeValue = null;
5269
+ wasAutocorrectSet = false;
5270
+ wasAutocapitalizeSet = false;
5271
+ wasSpellcheckSet = false;
5272
+ cutTimerId = null;
5273
+ pasteTimerId = null;
5274
+ resetTimerId = null;
5275
+ constructor(targetOrWrapper, inputOrOptions, options) {
5276
+ const args = resolveMaskConstructorArgs(targetOrWrapper, inputOrOptions, options);
5277
+ const wrap = args.wrapper;
5278
+ const inp = args.input;
5279
+ const opts = args.options;
5280
+ const attrFormat = wrap?.getAttribute("data-mask-format") || inp?.getAttribute("data-mask-format") || void 0;
5281
+ const attrUtcIndicator = wrap?.getAttribute("data-mask-utc-indicator") ?? inp?.getAttribute("data-mask-utc-indicator");
5282
+ const attrInfer = wrap?.getAttribute("data-mask-infer-inputmode") ?? inp?.getAttribute("data-mask-infer-inputmode");
5283
+ const resolvedUtcIndicator = opts.utcIndicator !== void 0 ? opts.utcIndicator : attrUtcIndicator !== null ? attrUtcIndicator === "false" || attrUtcIndicator === "none" ? false : attrUtcIndicator : " UTC";
5284
+ const resolvedOptions = {
5285
+ ...opts,
5286
+ format: opts.format ?? attrFormat ?? "YYYY-MM-DD HH:mm",
5287
+ utcIndicator: resolvedUtcIndicator,
5288
+ includeMilliseconds: opts.includeMilliseconds ?? false,
5289
+ convertPastedOffset: opts.convertPastedOffset ?? true,
5290
+ defaultTimeOnDateOnly: opts.defaultTimeOnDateOnly ?? false,
5291
+ inferInputMode: opts.inferInputMode ?? (attrInfer !== null ? attrInfer !== "false" : true),
5292
+ onInput: opts.onInput || opts.oninput,
5293
+ onChange: opts.onChange || opts.onchange,
5294
+ onComplete: opts.onComplete || opts.oncomplete
5295
+ };
5296
+ super(wrap, inp, resolvedOptions);
5297
+ this.history = new MaskHistory();
5298
+ this.engine = new DateUTCEngine(this.options);
5299
+ if (!this.input.hasAttribute("autocorrect")) {
5300
+ this.input.setAttribute("autocorrect", "off");
5301
+ this.wasAutocorrectSet = true;
5302
+ }
5303
+ if (!this.input.hasAttribute("autocapitalize")) {
5304
+ this.input.setAttribute("autocapitalize", "none");
5305
+ this.wasAutocapitalizeSet = true;
5306
+ }
5307
+ if (!this.input.hasAttribute("spellcheck")) {
5308
+ this.input.setAttribute("spellcheck", "false");
5309
+ this.wasSpellcheckSet = true;
5310
+ }
5311
+ this.syncInferredInputMode();
5312
+ this.bindEvents();
5313
+ this.lastValue = this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value;
5314
+ this.syncInitialValue();
5315
+ this.runAuditWarning(this.options.audit);
5316
+ }
5317
+ /**
5318
+ * Formate statiquement une date (Date, timestamp ms, ISO ou chaîne) sans DOM.
5319
+ */
5320
+ static format(value, options = {}) {
5321
+ return DateUTCEngine.format(value, options);
5322
+ }
5323
+ getSpecificAuditWarnings() {
5324
+ const warnings = [];
5325
+ const describedbyWarnings = [];
5326
+ const hasValidDescribedby = this.checkAriaIdReferences(this.input, "aria-describedby", describedbyWarnings, true);
5327
+ const hasPlaceholder = Boolean(this.input.getAttribute("placeholder")?.trim());
5328
+ const hasAriaPlaceholder = Boolean(this.input.getAttribute("aria-placeholder")?.trim());
5329
+ if (!hasValidDescribedby && !hasAriaPlaceholder && !this.options.disabled) {
5330
+ if (hasPlaceholder) {
5331
+ warnings.push(
5332
+ `Indication du format UTC fragile : placeholder seul dispara\xEEt \xE0 la saisie et l'indicateur UTC fant\xF4me est aria-hidden="true" ; d\xE9finissez aria-describedby ou aria-placeholder (WCAG 3.3.2).`
5333
+ );
5334
+ } else {
5335
+ warnings.push(
5336
+ "Indication du format UTC attendu manquante : d\xE9finissez aria-describedby ou aria-placeholder pour informer les technologies d'assistance du format et du r\xE9f\xE9rentiel UTC (WCAG 3.3.2)."
5337
+ );
5338
+ }
5339
+ }
5340
+ return warnings;
5341
+ }
5342
+ extractRawSnippet(snippet) {
5343
+ if (!snippet) return "";
5344
+ if (snippet === this.input.value && this.isValid()) {
5345
+ return this.getRawValue();
5346
+ }
5347
+ return this.engine.extractRaw(snippet, false);
5348
+ }
5349
+ onPasswordModeDetected() {
5350
+ this.history.clear();
5351
+ this.lastValue = "";
5352
+ this.lastValueLength = 0;
5353
+ this.lastTrackedValue = "";
5354
+ this.clearGhost();
5355
+ }
5356
+ onNativeValueSet(strVal) {
5357
+ if (this.options.disabled) {
5358
+ this.checkValueChange(false);
5359
+ } else {
5360
+ const formatted = this.engine.formatFromNativeValue(strVal);
5361
+ this.applyFormatted(formatted, formatted.length, false);
5362
+ }
5363
+ }
5364
+ onDisabledChange(disabled) {
5365
+ if (disabled) {
5366
+ this.wrapper.classList.remove("is-complete", "has-selection");
5367
+ this.clearGhost();
5368
+ this.checkValueChange(false);
5369
+ } else {
5370
+ const formatted = this.engine.formatFromValue(this.input.value);
5371
+ this.applyFormatted(formatted, this.input.selectionStart ?? formatted.length, false);
5372
+ }
5373
+ this.syncInferredInputMode();
5374
+ }
5375
+ handleAttributeMutation(attrName) {
5376
+ super.handleAttributeMutation(attrName);
5377
+ if (attrName === "data-mask-format") {
5378
+ const newFormat = this.getAttr("data-mask-format");
5379
+ if (newFormat && newFormat !== this.engine.getFormat()) {
5380
+ this.setFormat(newFormat);
5381
+ }
5382
+ } else if (attrName === "data-mask-utc-indicator") {
5383
+ const attrInd = this.getAttr("data-mask-utc-indicator");
5384
+ const indicator = attrInd === null || attrInd === "false" || attrInd === "none" ? false : attrInd;
5385
+ this.setUtcIndicator(indicator);
5386
+ } else if (attrName === "placeholder") {
5387
+ this.updateGhost(this.input.value);
5388
+ }
5389
+ }
5390
+ bindEvents() {
5391
+ this.onBeforeInput = this.onBeforeInput.bind(this);
5392
+ this.handleInput = this.handleInput.bind(this);
5393
+ this.onKeyDown = this.onKeyDown.bind(this);
5394
+ this.onPaste = this.onPaste.bind(this);
5395
+ this.onFocus = this.onFocus.bind(this);
5396
+ this.onBlur = this.onBlur.bind(this);
5397
+ this.onClick = this.onClick.bind(this);
5398
+ this.onKeyUp = this.onKeyUp.bind(this);
5399
+ this.onSelect = this.onSelect.bind(this);
5400
+ this.onMouseDown = this.onMouseDown.bind(this);
5401
+ this.onMouseUp = this.onMouseUp.bind(this);
5402
+ this.onCompositionStart = this.onCompositionStart.bind(this);
5403
+ this.onCompositionEnd = this.onCompositionEnd.bind(this);
5404
+ this.onCutHandler = () => {
5405
+ if (this.cutTimerId !== null) clearTimeout(this.cutTimerId);
5406
+ this.cutTimerId = window.setTimeout(() => {
5407
+ this.cutTimerId = null;
5408
+ if (this.isDestroyed) return;
5409
+ if (this.options.disabled) {
5410
+ this.checkValueChange(false);
5411
+ } else {
5412
+ const cur = this.input.selectionStart ?? this.input.value.length;
5413
+ this.applyFormatted(this.input.value, cur, false);
5414
+ }
5415
+ }, 0);
5416
+ };
5417
+ const onChangeNative = () => {
5418
+ if (this.isDestroyed) return;
5419
+ this.checkValueChange(true, true);
5420
+ };
5421
+ const { signal } = this.abortController;
5422
+ this.input.addEventListener("beforeinput", this.onBeforeInput, { signal });
5423
+ this.input.addEventListener("input", this.handleInput, { signal });
5424
+ this.input.addEventListener("keydown", this.onKeyDown, { signal });
5425
+ this.input.addEventListener("paste", this.onPaste, { signal });
5426
+ this.input.addEventListener("focus", this.onFocus, { signal });
5427
+ this.input.addEventListener("blur", this.onBlur, { signal });
5428
+ this.input.addEventListener("click", this.onClick, { signal });
5429
+ this.input.addEventListener("keyup", this.onKeyUp, { signal });
5430
+ this.input.addEventListener("select", this.onSelect, { signal });
5431
+ this.input.addEventListener("mousedown", this.onMouseDown, { signal });
5432
+ window.addEventListener("mouseup", this.onMouseUp, { signal });
5433
+ this.input.addEventListener("compositionstart", this.onCompositionStart, { signal });
5434
+ this.input.addEventListener("compositionend", this.onCompositionEnd, { signal });
5435
+ this.input.addEventListener("scroll", this.onScroll, { passive: true, signal });
5436
+ this.input.addEventListener("cut", this.onCutHandler, { signal });
5437
+ this.input.addEventListener("change", onChangeNative, { signal });
5438
+ if (this.input.form) {
5439
+ this.onFormResetHandler = () => {
5440
+ if (this.resetTimerId !== null) clearTimeout(this.resetTimerId);
5441
+ this.resetTimerId = window.setTimeout(() => {
5442
+ this.resetTimerId = null;
5443
+ if (this.isDestroyed) return;
5444
+ if (this.options.disabled) {
5445
+ this.checkValueChange(false);
5446
+ } else {
5447
+ this.syncInitialValue();
5448
+ }
5449
+ }, 0);
5450
+ };
5451
+ this.input.form.addEventListener("reset", this.onFormResetHandler, { signal });
5452
+ }
5453
+ }
5454
+ syncInferredInputMode() {
5455
+ if (this.options.inferInputMode === false) return;
5456
+ if (this.options.disabled) {
5457
+ if (this.inferredInputModeValue && this.input.getAttribute("inputmode") === this.inferredInputModeValue) {
5458
+ this.input.removeAttribute("inputmode");
5459
+ }
5460
+ this.inferredInputModeValue = null;
5461
+ return;
5462
+ }
5463
+ const desired = this.engine.isNumericOnly() ? "numeric" : "text";
5464
+ const currentAttr = this.input.getAttribute("inputmode");
5465
+ if (!currentAttr || this.inferredInputModeValue === currentAttr) {
5466
+ this.input.inputMode = desired;
5467
+ this.inferredInputModeValue = desired;
5468
+ }
5469
+ }
5470
+ // ==========================================================================
5471
+ // API Publique
5472
+ // ==========================================================================
5473
+ getDetail() {
5474
+ const result = this.engine.analyze(this.input.value, false);
5475
+ return {
5476
+ ...result,
5477
+ value: this.options.disabled ? this.input.value : result.formatted
5478
+ };
5479
+ }
5480
+ getRawValue() {
5481
+ if (this.options.disabled) return this.input.value;
5482
+ return this.getDetail().rawValue;
5483
+ }
5484
+ getISOString() {
5485
+ return this.getDetail().isoString;
5486
+ }
5487
+ getDate() {
5488
+ return this.getDetail().date;
5489
+ }
5490
+ getTimestamp() {
5491
+ return this.getDetail().timestamp;
5492
+ }
5493
+ getParts() {
5494
+ return this.getDetail().parts;
5495
+ }
5496
+ /**
5497
+ * Progressive Enhancement Baseline : retourne un Temporal.Instant natif si supporté par le navigateur,
5498
+ * sinon null (zéro polyfill externe).
5499
+ */
5500
+ getTemporalInstant() {
5501
+ const ts = this.getTimestamp();
5502
+ if (ts === null) return null;
5503
+ const globalTemporal = globalThis.Temporal;
5504
+ if (globalTemporal?.Instant && typeof globalTemporal.Instant.fromEpochMilliseconds === "function") {
5505
+ try {
5506
+ return globalTemporal.Instant.fromEpochMilliseconds(ts);
5507
+ } catch {
5508
+ return null;
5509
+ }
5510
+ }
5511
+ return null;
5512
+ }
5513
+ isComplete() {
5514
+ if (this.options.disabled) return true;
5515
+ return this.getDetail().isComplete;
5516
+ }
5517
+ isValid() {
5518
+ if (this.options.disabled) return true;
5519
+ return this.getDetail().isValid;
5520
+ }
5521
+ setValue(val) {
5522
+ if (this.options.disabled) {
5523
+ const str = val instanceof Date ? Number.isNaN(val.getTime()) ? "" : this.engine.formatDateToISO(val) : val !== null && val !== void 0 ? String(val) : "";
5524
+ this.setNativeValue(str);
5525
+ this.checkValueChange(false);
5526
+ return;
5527
+ }
5528
+ const formatted = this.engine.formatFromValue(val);
5529
+ this.applyFormatted(formatted, formatted.length, true);
5530
+ }
5531
+ /**
5532
+ * Remplit l'instant UTC courant.
5533
+ */
5534
+ setNow() {
5535
+ this.setValue(/* @__PURE__ */ new Date());
5536
+ }
5537
+ /**
5538
+ * Convertit la date UTC saisie vers la locale demandée via Intl.DateTimeFormat (aperçu sans widget).
5539
+ */
5540
+ formatLocal(locale, intlOptions) {
5541
+ return this.engine.formatLocal(this.getDate(), locale, intlOptions);
5542
+ }
5543
+ /**
5544
+ * Change dynamiquement le format (preset ou chaîne de tokens) et reconvertit la date courante si elle est valide.
5545
+ */
5546
+ setFormat(format, placeholderTokens) {
5547
+ const currentDate = this.getDate();
5548
+ this.options.format = format;
5549
+ if (placeholderTokens !== void 0) {
5550
+ this.options.placeholderTokens = placeholderTokens;
5551
+ }
5552
+ this.engine.setFormat(format, placeholderTokens);
5553
+ this.syncInferredInputMode();
5554
+ if (this.options.disabled) {
5555
+ this.clearGhost();
5556
+ return;
5557
+ }
5558
+ if (currentDate) {
5559
+ const formatted = this.engine.formatFromValue(currentDate);
5560
+ this.applyFormatted(formatted, formatted.length, true);
5561
+ } else {
5562
+ const formatted = this.engine.format(this.input.value, false);
5563
+ this.applyFormatted(formatted, Math.min(this.input.selectionStart ?? formatted.length, formatted.length), false);
5564
+ }
5565
+ }
5566
+ setUtcIndicator(indicator) {
5567
+ this.options.utcIndicator = indicator;
5568
+ this.engine.setUtcIndicator(indicator);
5569
+ this.updateGhost(this.input.value);
5570
+ }
5571
+ undo() {
5572
+ if (this.options.disabled) return;
5573
+ const state = this.history.undo();
5574
+ if (state) {
5575
+ this.isUndoingRedoing = true;
5576
+ try {
5577
+ this.applyFormatted(this.engine.format(state.raw, false), state.cursor, true);
5578
+ } finally {
5579
+ this.isUndoingRedoing = false;
5580
+ }
5581
+ }
5582
+ }
5583
+ redo() {
5584
+ if (this.options.disabled) return;
5585
+ const state = this.history.redo();
5586
+ if (state) {
5587
+ this.isUndoingRedoing = true;
5588
+ try {
5589
+ this.applyFormatted(this.engine.format(state.raw, false), state.cursor, true);
5590
+ } finally {
5591
+ this.isUndoingRedoing = false;
5592
+ }
5593
+ }
5594
+ }
5595
+ destroy() {
5596
+ if (this.isDestroyed) return;
5597
+ if (this.cutTimerId !== null) {
5598
+ clearTimeout(this.cutTimerId);
5599
+ this.cutTimerId = null;
5600
+ }
5601
+ if (this.pasteTimerId !== null) {
5602
+ clearTimeout(this.pasteTimerId);
5603
+ this.pasteTimerId = null;
5604
+ }
5605
+ if (this.resetTimerId !== null) {
5606
+ clearTimeout(this.resetTimerId);
5607
+ this.resetTimerId = null;
5608
+ }
5609
+ if (this.inferredInputModeValue && this.input.getAttribute("inputmode") === this.inferredInputModeValue) {
5610
+ this.input.removeAttribute("inputmode");
5611
+ }
5612
+ if (this.wasAutocorrectSet) this.input.removeAttribute("autocorrect");
5613
+ if (this.wasAutocapitalizeSet) this.input.removeAttribute("autocapitalize");
5614
+ if (this.wasSpellcheckSet) this.input.removeAttribute("spellcheck");
5615
+ this.history.clear();
5616
+ this.lastValue = "";
5617
+ this.lastValueLength = 0;
5618
+ super.destroy();
5619
+ }
5620
+ // ==========================================================================
5621
+ // Événements DOM & Clavier
5622
+ // ==========================================================================
5623
+ checkSelection() {
5624
+ if (this.options.disabled) return;
5625
+ const start = this.input.selectionStart ?? 0;
5626
+ const end = this.input.selectionEnd ?? start;
5627
+ this.wrapper.classList.toggle("has-selection", start !== end);
5628
+ }
5629
+ onBeforeInput(e) {
5630
+ this.lastInputType = e.inputType || "";
5631
+ if (this.options.disabled || this.isComposing) return;
5632
+ if (e.inputType === "insertFromPaste" || e.inputType === "insertReplacementText") return;
5633
+ if (e.inputType && e.inputType.startsWith("insert")) {
5634
+ const totalSlots = this.engine.getEditableCount();
5635
+ if (totalSlots > 0) {
5636
+ const currentRaw = this.engine.extractRaw(this.input.value, false);
5637
+ const start = this.input.selectionStart ?? 0;
5638
+ const end = this.input.selectionEnd ?? start;
5639
+ let available = Math.max(0, totalSlots - currentRaw.length);
5640
+ if (end > start) {
5641
+ const selectedRaw = this.engine.extractRaw(this.input.value.slice(start, end), false);
5642
+ available = Math.max(0, totalSlots - (currentRaw.length - selectedRaw.length));
5643
+ }
5644
+ if (available <= 0) {
5645
+ e.preventDefault();
5646
+ }
5647
+ }
5648
+ }
5649
+ }
5650
+ handleInput(e) {
5651
+ if (this.isDispatchingNativeInput || this.isComposing) return;
5652
+ if (this.options.disabled) {
5653
+ this.checkValueChange(false);
5654
+ return;
5655
+ }
5656
+ const inputType = e?.inputType || this.lastInputType || "";
5657
+ this.lastInputType = "";
5658
+ const val = this.input.value;
5659
+ const cursor = this.input.selectionStart ?? val.length;
5660
+ const prevState = this.history.getCurrent();
5661
+ const totalSlots = this.engine.getEditableCount();
5662
+ const isShorter = inputType.startsWith("delete") || !this.isSensitiveField() && val.length < this.lastValueLength;
5663
+ const newRawNoExpand = this.engine.extractRaw(val, false);
5664
+ if (totalSlots > 0 && prevState && prevState.raw.length >= totalSlots && newRawNoExpand.length > totalSlots) {
5665
+ const prevFormatted = this.engine.format(prevState.raw, false);
5666
+ this.applyFormatted(prevFormatted, prevState.cursor, true);
5667
+ return;
5668
+ }
5669
+ let candidate = val;
5670
+ let expandMeridiem = !isShorter;
5671
+ if (isShorter && this.engine.hasMeridiem()) {
5672
+ for (const seg of this.engine.getSegments()) {
5673
+ if (seg.kind === "A" && val.length >= seg.start + 1 && val.length < seg.end) {
5674
+ candidate = val.slice(0, seg.start) + val.slice(seg.start + 1);
5675
+ expandMeridiem = false;
5676
+ break;
5677
+ }
5678
+ }
5679
+ }
5680
+ this.applyFormatted(candidate, cursor, false, expandMeridiem);
5681
+ this.checkSelection();
5682
+ }
5683
+ onKeyDown(e) {
5684
+ if (this.options.disabled || isImeComposing(e)) return;
5685
+ const cursor = this.input.selectionStart ?? 0;
5686
+ const selectionEnd = this.input.selectionEnd ?? cursor;
5687
+ const minPos = this.engine.getPrefixLength();
5688
+ if ((e.ctrlKey || e.metaKey) && (e.key === "z" || e.key === "Z") && !e.shiftKey) {
5689
+ e.preventDefault();
5690
+ this.undo();
5691
+ return;
5692
+ }
5693
+ if ((e.ctrlKey || e.metaKey) && (e.key === "y" || e.key === "Y") || (e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === "z" || e.key === "Z")) {
5694
+ e.preventDefault();
5695
+ this.redo();
5696
+ return;
5697
+ }
5698
+ this.history.updateCurrentCursor(cursor);
5699
+ const isPrintable = e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey;
5700
+ const hasSelection = selectionEnd > cursor;
5701
+ if (isPrintable && !hasSelection) {
5702
+ const sepResult = this.engine.tryHandleSeparatorKey(this.input.value, cursor, e.key);
5703
+ if (sepResult.handled) {
5704
+ e.preventDefault();
5705
+ this.applyFormatted(sepResult.formatted, sepResult.cursor, true);
5706
+ return;
5707
+ }
5708
+ if (this.engine.hasMeridiem()) {
5709
+ for (const seg of this.engine.getSegments()) {
5710
+ if (seg.kind === "A" && cursor >= seg.start && cursor <= seg.end) {
5711
+ const up = e.key.toUpperCase();
5712
+ if (up === "A" || up === "P") {
5713
+ e.preventDefault();
5714
+ const meridiem = up === "A" ? "AM" : "PM";
5715
+ const val = this.input.value;
5716
+ const updated = val.slice(0, seg.start) + meridiem + val.slice(Math.min(val.length, seg.end));
5717
+ this.applyFormatted(updated, seg.end, true);
5718
+ return;
5719
+ }
5720
+ }
5721
+ }
5722
+ }
5723
+ const totalSlots = this.engine.getEditableCount();
5724
+ if (totalSlots > 0 && this.engine.extractRaw(this.input.value, false).length >= totalSlots) {
5725
+ e.preventDefault();
5726
+ return;
5727
+ }
5728
+ }
5729
+ if (hasSelection) {
5730
+ if (e.key === "Backspace" || e.key === "Delete") {
5731
+ e.preventDefault();
5732
+ const val = this.input.value;
5733
+ const updated = val.slice(0, cursor) + val.slice(selectionEnd);
5734
+ this.applyFormatted(updated, Math.max(minPos, cursor), false);
5735
+ return;
5736
+ }
5737
+ return;
5738
+ }
5739
+ if (e.key === "ArrowLeft" && !e.shiftKey && cursor <= minPos) {
5740
+ e.preventDefault();
5741
+ this.input.setSelectionRange(minPos, minPos);
5742
+ return;
5743
+ }
5744
+ if (e.key === "Home" && minPos > 0 && !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey) {
5745
+ e.preventDefault();
5746
+ this.input.setSelectionRange(minPos, minPos);
5747
+ return;
5748
+ }
5749
+ if (e.key === "Backspace" && cursor <= minPos) {
5750
+ e.preventDefault();
5751
+ this.input.setSelectionRange(minPos, minPos);
5752
+ return;
5753
+ }
5754
+ if (e.key === "Delete" && cursor < minPos) {
5755
+ e.preventDefault();
5756
+ this.input.setSelectionRange(minPos, minPos);
5757
+ return;
5758
+ }
5759
+ if (e.key === "Backspace" && this.engine.hasMeridiem()) {
5760
+ for (const seg of this.engine.getSegments()) {
5761
+ if (seg.kind === "A" && cursor > seg.start && cursor <= seg.end) {
5762
+ e.preventDefault();
5763
+ const val = this.input.value;
5764
+ const updated = val.slice(0, seg.start) + val.slice(Math.min(val.length, seg.end));
5765
+ this.applyFormatted(updated, seg.start, true);
5766
+ return;
5767
+ }
5768
+ }
5769
+ }
5770
+ if (e.key === "Backspace" && (e.ctrlKey || e.altKey || e.metaKey)) {
5771
+ e.preventDefault();
5772
+ if (cursor <= minPos) {
5773
+ this.input.setSelectionRange(minPos, minPos);
5774
+ return;
5775
+ }
5776
+ let i = cursor - 1;
5777
+ while (i >= minPos && this.engine.isSeparatorAt(i)) i--;
5778
+ while (i >= minPos && !this.engine.isSeparatorAt(i)) i--;
5779
+ const startPos = Math.max(minPos, i + 1);
5780
+ const val = this.input.value;
5781
+ this.applyFormatted(val.slice(0, startPos) + val.slice(cursor), startPos, true);
5782
+ return;
5783
+ }
5784
+ if (e.key === "Delete" && (e.ctrlKey || e.altKey || e.metaKey)) {
5785
+ e.preventDefault();
5786
+ const val = this.input.value;
5787
+ if (cursor >= val.length) return;
5788
+ let i = cursor;
5789
+ while (i < val.length && this.engine.isSeparatorAt(i)) i++;
5790
+ while (i < val.length && !this.engine.isSeparatorAt(i)) i++;
5791
+ while (i < val.length && this.engine.isSeparatorAt(i)) i++;
5792
+ this.applyFormatted(val.slice(0, cursor) + val.slice(i), cursor, true);
5793
+ return;
5794
+ }
5795
+ if (e.key === "Backspace" && cursor > minPos && this.engine.isSeparatorAt(cursor - 1)) {
5796
+ e.preventDefault();
5797
+ let targetPos = cursor - 1;
5798
+ while (targetPos > minPos && this.engine.isSeparatorAt(targetPos - 1)) {
5799
+ targetPos--;
5800
+ }
5801
+ if (targetPos > minPos) {
5802
+ const val = this.input.value;
5803
+ this.applyFormatted(val.slice(0, targetPos - 1) + val.slice(cursor), targetPos - 1, false);
5804
+ } else {
5805
+ this.applyFormatted("", minPos, true);
5806
+ }
5807
+ return;
5808
+ }
5809
+ if (e.key === "Delete" && cursor < this.input.value.length && this.engine.isSeparatorAt(cursor)) {
5810
+ e.preventDefault();
5811
+ let targetPos = cursor;
5812
+ while (targetPos < this.input.value.length && this.engine.isSeparatorAt(targetPos)) {
5813
+ targetPos++;
5814
+ }
5815
+ if (targetPos < this.input.value.length) {
5816
+ const val = this.input.value;
5817
+ this.applyFormatted(val.slice(0, targetPos) + val.slice(targetPos + 1), cursor, true);
5818
+ }
5819
+ }
5820
+ }
5821
+ onPaste(e) {
5822
+ if (this.options.disabled) {
5823
+ if (this.pasteTimerId !== null) clearTimeout(this.pasteTimerId);
5824
+ this.pasteTimerId = window.setTimeout(() => {
5825
+ this.pasteTimerId = null;
5826
+ if (!this.isDestroyed) this.checkValueChange(false);
5827
+ }, 0);
5828
+ return;
5829
+ }
5830
+ e.preventDefault();
5831
+ this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
5832
+ const pastedText = this.preparePastedText(this.getClipboardPlainText(e), 512);
5833
+ if (!pastedText) return;
5834
+ const minPos = this.engine.getPrefixLength();
5835
+ const selStart = this.input.selectionStart ?? 0;
5836
+ const selEnd = this.input.selectionEnd ?? selStart;
5837
+ const currentVal = this.input.value;
5838
+ const totalSlots = this.engine.getEditableCount();
5839
+ const currentRaw = this.engine.extractRaw(currentVal, false);
5840
+ const isGlobalOrEmpty = currentRaw.length === 0 || selStart <= minPos && selEnd >= currentVal.length || selStart === selEnd;
5841
+ if (isGlobalOrEmpty) {
5842
+ const parsed = this.engine.parsePasted(pastedText);
5843
+ if (parsed.matched) {
5844
+ this.applyFormatted(parsed.formatted, parsed.cursor, true);
5845
+ if (parsed.offsetConverted && this.options.onOffsetConverted) {
5846
+ try {
5847
+ this.options.onOffsetConverted(parsed.offsetConverted);
5848
+ } catch {
5849
+ }
5850
+ }
5851
+ this.checkSelection();
5852
+ return;
5853
+ }
5854
+ if (parsed.rejected) {
5855
+ return;
5856
+ }
5857
+ }
5858
+ let available = Math.max(0, totalSlots - currentRaw.length);
5859
+ if (selEnd > selStart) {
5860
+ const selectedRaw = this.engine.extractRaw(currentVal.slice(selStart, selEnd), false);
5861
+ available = Math.max(0, totalSlots - (currentRaw.length - selectedRaw.length));
5862
+ }
5863
+ if (available <= 0) return;
5864
+ const effectiveStart = Math.max(minPos, selStart);
5865
+ const effectiveEnd = Math.max(minPos, selEnd);
5866
+ const combined = currentVal.slice(0, effectiveStart) + pastedText + currentVal.slice(effectiveEnd);
5867
+ this.applyFormatted(combined, effectiveStart + pastedText.length, false, true);
5868
+ this.checkSelection();
5869
+ }
5870
+ onFocus() {
5871
+ this.syncGhostStyles();
5872
+ this.wrapper.classList.add("is-focused");
5873
+ if (!this.options.disabled && !this.isMouseDown) {
5874
+ this.enforceMinCursor();
5875
+ }
5876
+ this.updateGhost(this.input.value);
5877
+ this.checkSelection();
5878
+ }
5879
+ onBlur() {
5880
+ this.wrapper.classList.remove("is-focused", "has-selection");
5881
+ if (this.isSensitiveField()) {
5882
+ this.onPasswordModeDetected();
5883
+ return;
5884
+ }
5885
+ this.updateGhost(this.input.value);
5886
+ this.checkValueChange(false, true);
5887
+ }
5888
+ onClick() {
5889
+ if (!this.options.disabled) {
5890
+ this.enforceMinCursor();
5891
+ }
5892
+ this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
5893
+ this.checkSelection();
5894
+ }
5895
+ onKeyUp(e) {
5896
+ if (!this.options.disabled) {
5897
+ if ((e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Home") && !e.shiftKey) {
5898
+ this.enforceMinCursor();
5899
+ }
5900
+ this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
5901
+ }
5902
+ this.checkSelection();
5903
+ }
5904
+ onSelect() {
5905
+ this.history.updateCurrentCursor(this.input.selectionStart ?? 0);
5906
+ this.checkSelection();
5907
+ }
5908
+ onMouseDown() {
5909
+ this.isMouseDown = true;
5910
+ }
5911
+ onMouseUp() {
5912
+ this.isMouseDown = false;
5913
+ this.checkSelection();
5914
+ }
5915
+ onCompositionStart() {
5916
+ this.isComposing = true;
5917
+ }
5918
+ onCompositionEnd() {
5919
+ this.isComposing = false;
5920
+ if (this.options.disabled) return;
5921
+ const cur = this.input.selectionStart ?? this.input.value.length;
5922
+ this.applyFormatted(this.input.value, cur, false, true);
5923
+ this.checkSelection();
5924
+ }
5925
+ enforceMinCursor() {
5926
+ const minPos = this.engine.getPrefixLength();
5927
+ if (minPos <= 0) return;
5928
+ const start = this.input.selectionStart ?? 0;
5929
+ const end = this.input.selectionEnd ?? start;
5930
+ if (start !== end) return;
5931
+ if (start < minPos) {
5932
+ this.input.setSelectionRange(minPos, minPos);
5933
+ }
5934
+ }
5935
+ // ==========================================================================
5936
+ // Synchronisation & Notifications
5937
+ // ==========================================================================
5938
+ updateGhost(formatted) {
5939
+ if (!this.ghost) return;
5940
+ if (this.options.disabled || this.isSensitiveField()) {
5941
+ this.clearGhost();
5942
+ return;
5943
+ }
5944
+ const isCleanEmpty = !formatted || formatted === this.engine.getPrefix();
5945
+ if (this.shouldHideGhostForPlaceholder(isCleanEmpty)) {
5946
+ this.clearGhost();
5947
+ return;
5948
+ }
5949
+ const remaining = this.engine.getGhostRemaining(formatted);
5950
+ const doc = this.input.ownerDocument || document;
5951
+ const spanTyped = doc.createElement("span");
5952
+ spanTyped.className = "mask-ghost-typed";
5953
+ spanTyped.textContent = formatted;
5954
+ const spanRemaining = doc.createElement("span");
5955
+ spanRemaining.className = "mask-ghost-remaining";
5956
+ spanRemaining.textContent = remaining;
5957
+ this.setGhostContent(spanTyped, spanRemaining);
5958
+ this.ghost.scrollLeft = this.input.scrollLeft;
5959
+ }
5960
+ applyFormatted(rawOrPartial, cursorPosition, forceExactCursor = false, expandSingleMeridiem = false) {
5961
+ if (this.options.disabled || this.isApplying) return;
5962
+ this.isApplying = true;
5963
+ try {
5964
+ const formatted = this.engine.format(rawOrPartial, expandSingleMeridiem);
5965
+ const isSensitive = this.isSensitiveField();
5966
+ this.setNativeValue(formatted);
5967
+ if (isSensitive) {
5968
+ this.clearGhost();
5969
+ } else {
5970
+ this.updateGhost(formatted);
5971
+ }
5972
+ const minPos = this.engine.getPrefixLength();
5973
+ let safeCursor;
5974
+ if (forceExactCursor || this.isUndoingRedoing) {
5975
+ safeCursor = Math.max(minPos, Math.min(cursorPosition, formatted.length));
5976
+ } else {
5977
+ safeCursor = Math.max(minPos, this.engine.mapCursorPosition(rawOrPartial, cursorPosition, formatted));
5978
+ }
5979
+ this.input.setSelectionRange(safeCursor, safeCursor);
5980
+ const analysis = this.engine.analyze(formatted, false);
5981
+ this.wrapper.classList.toggle("is-complete", analysis.isComplete);
5982
+ if (isSensitive) {
5983
+ this.options.copyRaw = false;
5984
+ this.lastValueLength = 0;
5985
+ this.history.clear();
5986
+ } else {
5987
+ this.lastValueLength = formatted.length;
5988
+ if (!this.isUndoingRedoing) {
5989
+ this.history.push(this.engine.extractRaw(formatted, false), safeCursor);
5990
+ }
5991
+ }
5992
+ } finally {
5993
+ this.isApplying = false;
5994
+ }
5995
+ this.checkValueChange(false);
5996
+ }
5997
+ syncInitialValue() {
5998
+ const isSensitive = this.isSensitiveField();
5999
+ if (this.options.disabled) {
6000
+ this.clearGhost();
6001
+ this.lastValue = isSensitive ? this.computePasswordDigest(this.input.value) : this.input.value;
6002
+ this.lastValueLength = isSensitive ? 0 : this.input.value.length;
6003
+ this.checkValueChange(false);
6004
+ return;
6005
+ }
6006
+ this.syncGhostStyles();
6007
+ const initialVal = this.input.value || "";
6008
+ if (initialVal) {
6009
+ const formatted = this.engine.formatFromValue(initialVal);
6010
+ this.applyFormatted(formatted, formatted.length, true);
6011
+ } else {
6012
+ const minPos = this.engine.getPrefixLength();
6013
+ if (minPos > 0) {
6014
+ this.applyFormatted("", minPos, true);
6015
+ } else {
6016
+ if (!isSensitive) {
6017
+ this.history.push("", 0);
6018
+ this.updateGhost("");
6019
+ } else {
6020
+ this.clearGhost();
6021
+ }
6022
+ this.checkValueChange(false);
6023
+ }
6024
+ }
6025
+ }
6026
+ checkValueChange(forceNotify = false, emitChangeEvent = false) {
6027
+ const initialSensitive = this.isSensitiveField();
6028
+ const currentVal = this.input.value;
6029
+ const currentComparison = initialSensitive ? this.computePasswordDigest(currentVal) : currentVal;
6030
+ if (currentComparison === this.lastValue && !forceNotify && !this.hasPendingNotification) {
6031
+ if (emitChangeEvent) {
6032
+ const allowBubble = !initialSensitive;
6033
+ const detail = this.getDetail();
6034
+ const onChangeCb = this.options.onChange || this.options.onchange;
6035
+ if (onChangeCb) onChangeCb(detail);
6036
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: allowBubble, detail }));
6037
+ }
6038
+ return;
6039
+ }
6040
+ if (this.isNotifying) {
6041
+ this.hasPendingNotification = true;
6042
+ return;
6043
+ }
6044
+ this.isNotifying = true;
6045
+ try {
6046
+ let iterations = 0;
6047
+ while (((this.isSensitiveField() ? this.computePasswordDigest(this.input.value) : this.input.value) !== this.lastValue || this.hasPendingNotification || forceNotify) && iterations < MAX_NOTIFICATION_ITERATIONS3) {
6048
+ iterations++;
6049
+ this.hasPendingNotification = false;
6050
+ forceNotify = false;
6051
+ const sensitiveNow = this.isSensitiveField();
6052
+ const allowBubble = !sensitiveNow;
6053
+ const valToNotify = this.input.value;
6054
+ this.lastValue = sensitiveNow ? this.computePasswordDigest(valToNotify) : valToNotify;
6055
+ this.lastValueLength = sensitiveNow ? 0 : valToNotify.length;
6056
+ const detail = this.getDetail();
6057
+ const onInputCb = this.options.onInput || this.options.oninput;
6058
+ if (onInputCb) onInputCb(detail);
6059
+ this.input.dispatchEvent(new CustomEvent("mask:input", { bubbles: allowBubble, detail }));
6060
+ this.dispatchNativeInput();
6061
+ if (emitChangeEvent) {
6062
+ const onChangeCb = this.options.onChange || this.options.onchange;
6063
+ if (onChangeCb) onChangeCb(detail);
6064
+ this.input.dispatchEvent(new CustomEvent("mask:change", { bubbles: allowBubble, detail }));
6065
+ }
6066
+ if (detail.isComplete) {
6067
+ const onCompleteCb = this.options.onComplete || this.options.oncomplete;
6068
+ if (onCompleteCb) onCompleteCb(detail);
6069
+ this.input.dispatchEvent(new CustomEvent("mask:complete", { bubbles: allowBubble, detail }));
6070
+ }
6071
+ }
6072
+ } finally {
6073
+ this.isNotifying = false;
6074
+ }
6075
+ }
6076
+ };
6077
+
6078
+ // src/mask/index.ts
6079
+ var Mask = {
6080
+ BaseInputMask,
6081
+ InputMask,
6082
+ MaskEngine,
6083
+ MaskHistory,
6084
+ MaskKeyboard,
6085
+ AmountEngine,
6086
+ InputAmountMask,
6087
+ EmailEngine,
6088
+ InputEmailMask,
6089
+ DateUTCEngine,
6090
+ DATE_UTC_PRESETS,
6091
+ InputDateUTCMask,
6092
+ sanitizePastedText,
6093
+ stripBidiAndInvisibles
3443
6094
  };
3444
6095
  var wulfNamespace = getSafeWulfNamespace();
3445
6096
  if (wulfNamespace) {
@@ -3449,8 +6100,11 @@ var index_default = InputMask;
3449
6100
  export {
3450
6101
  AmountEngine,
3451
6102
  BaseInputMask,
6103
+ DATE_UTC_PRESETS,
6104
+ DateUTCEngine,
3452
6105
  EmailEngine,
3453
6106
  InputAmountMask,
6107
+ InputDateUTCMask,
3454
6108
  InputEmailMask,
3455
6109
  InputMask,
3456
6110
  Mask,
@@ -3458,6 +6112,7 @@ export {
3458
6112
  MaskHistory,
3459
6113
  MaskKeyboard,
3460
6114
  index_default as default,
3461
- resolveMaskConstructorArgs
6115
+ sanitizePastedText,
6116
+ stripBidiAndInvisibles
3462
6117
  };
3463
6118
  //# sourceMappingURL=mask.esm.js.map