wulf.js 1.9.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -78
- package/changelog.md +105 -0
- package/dist/focus-trap.esm.js +245 -126
- package/dist/focus-trap.esm.js.map +3 -3
- package/dist/focus-trap.global.js +247 -128
- package/dist/focus-trap.global.js.map +3 -3
- package/dist/focus-trap.global.min.js +4 -4
- package/dist/focus-trap.global.min.js.map +4 -4
- package/dist/index.esm.js +2434 -905
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +2436 -907
- package/dist/index.global.js.map +4 -4
- package/dist/index.global.min.js +4 -4
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.css +1 -1
- package/dist/mask.css.map +2 -2
- package/dist/mask.esm.js +746 -346
- package/dist/mask.esm.js.map +3 -3
- package/dist/mask.global.js +748 -348
- package/dist/mask.global.js.map +3 -3
- package/dist/mask.global.min.js +4 -4
- package/dist/mask.global.min.js.map +4 -4
- package/dist/mask.layered.css +1 -0
- package/dist/mask.layered.css.map +7 -0
- package/dist/masonry.css +1 -1
- package/dist/masonry.css.map +2 -2
- package/dist/masonry.esm.js +341 -114
- package/dist/masonry.esm.js.map +3 -3
- package/dist/masonry.global.js +343 -116
- package/dist/masonry.global.js.map +3 -3
- package/dist/masonry.global.min.js +4 -4
- package/dist/masonry.global.min.js.map +4 -4
- package/dist/masonry.layered.css +1 -0
- package/dist/masonry.layered.css.map +7 -0
- package/dist/scroll.css +1 -1
- package/dist/scroll.css.map +2 -2
- package/dist/scroll.esm.js +524 -153
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +526 -155
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +4 -4
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/scroll.layered.css +1 -0
- package/dist/scroll.layered.css.map +7 -0
- package/dist/shortcut.esm.js +209 -46
- package/dist/shortcut.esm.js.map +3 -3
- package/dist/shortcut.global.js +211 -48
- package/dist/shortcut.global.js.map +3 -3
- package/dist/shortcut.global.min.js +2 -2
- package/dist/shortcut.global.min.js.map +4 -4
- package/dist/toast.css +1 -1
- package/dist/toast.css.map +2 -2
- package/dist/toast.esm.js +590 -160
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +592 -162
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +4 -4
- package/dist/toast.global.min.js.map +4 -4
- package/dist/toast.layered.css +1 -0
- package/dist/toast.layered.css.map +7 -0
- package/dist/types/common/dom.d.ts +38 -0
- package/dist/types/focus-trap/FocusTrap.d.ts +15 -5
- package/dist/types/focus-trap/types.d.ts +2 -2
- package/dist/types/index.d.ts +10 -0
- package/dist/types/mask/AmountEngine.d.ts +1 -0
- package/dist/types/mask/BaseInputMask.d.ts +24 -0
- package/dist/types/mask/InputAmountMask.d.ts +3 -0
- package/dist/types/mask/InputEmailMask.d.ts +16 -1
- package/dist/types/mask/InputMask.d.ts +1 -0
- package/dist/types/mask/MaskEngine.d.ts +4 -0
- package/dist/types/masonry/Masonry.d.ts +10 -3
- package/dist/types/scroll/ScrollBlock.d.ts +31 -3
- package/dist/types/scroll/types.d.ts +13 -1
- package/dist/types/shortcut/ShortcutFormatter.d.ts +6 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +5 -0
- package/dist/types/toast/Toast.d.ts +4 -0
- package/dist/types/toast/ToastInstance.d.ts +22 -10
- package/dist/types/toast/ToastManager.d.ts +37 -4
- package/dist/types/toast/i18n/types.d.ts +2 -0
- package/dist/types/toast/types.d.ts +14 -2
- package/package.json +20 -5
package/dist/mask.global.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`+
|
|
1
|
+
"use strict";var __WulfIIFE=(()=>{var G=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var J=(c,t)=>{for(var e in t)G(c,e,{get:t[e],enumerable:!0})},X=(c,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Z(t))!Y.call(c,n)&&n!==e&&G(c,n,{get:()=>t[n],enumerable:!(i=q(t,n))||i.enumerable});return c};var Q=c=>X(G({},"__esModule",{value:!0}),c);var it={};J(it,{AmountEngine:()=>x,BaseInputMask:()=>E,EmailEngine:()=>R,InputAmountMask:()=>N,InputEmailMask:()=>B,InputMask:()=>V,Mask:()=>j,MaskEngine:()=>D,MaskHistory:()=>I,MaskKeyboard:()=>O,default:()=>et,resolveMaskConstructorArgs:()=>C});function U(){if(typeof window>"u")return null;let c=window,t=c.Wulf;if(!t||typeof t!="object"||typeof Node<"u"&&t instanceof Node||typeof HTMLCollection<"u"&&t instanceof HTMLCollection){let e={};return c.Wulf=e,e}return t}function z(c){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(c):String(c).replace(/["\\\u0000-\u001F\u007F]/g,"\\$&")}function $(c,t,e=null){let i=c.moveBefore;if(typeof i=="function"&&t.isConnected&&c.isConnected&&typeof c.getRootNode=="function"&&typeof t.getRootNode=="function"&&c.getRootNode()===t.getRootNode())try{i.call(c,t,e);return}catch{}c.insertBefore(t,e)}function H(c){return!!(c.isComposing||c.key==="Process"||c.key==="Enter"&&c.keyCode===229)}var K=class{getAuditDisableHint(){return"Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement"}runAuditWarning(t=!0){if(!t)return[];let e=this.audit();return e.length>0&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${e.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
|
|
2
|
+
`+e.map(i=>` - ${i}`).join(`
|
|
3
3
|
`)+`
|
|
4
|
-
(${this.getAuditDisableHint()})`),t}checkAriaIdReferences(i,t,e){let n=i.getAttribute(t)?.trim();if(!n)return!1;let o=i.ownerDocument||document,s=n.split(/\s+/).filter(Boolean),r=s.length>0&&s.every(a=>!!o.getElementById(a));return r||e.push(`Attribut ${t}="${n}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),r}};function T(b,i,t){return i&&typeof i=="object"&&"tagName"in i&&i.tagName==="INPUT"?{wrapper:b||null,input:i,options:t||{}}:{wrapper:null,input:b,options:i&&typeof i=="object"&&!("tagName"in i)?i:{}}}var A=class extends B{constructor(t,e,n){super();this.ghost=null;this.isWrapperCreated=!1;this.isDestroyed=!1;this.isFocused=!1;this.isDispatchingNativeInput=!1;this.lastTrackedValue="";this.nativeValueDescriptor=null;this.onCutHandler=()=>{};this.mutationObserver=null;this.focusSelectTimerId=null;this.onBaseCopy=t=>{if(!this.options.copyRaw||this.options.disabled||this.input.type==="password")return;let e=this.input.selectionStart??0,n=this.input.selectionEnd??e,o="";e!==n?o=this.extractRawSnippet(this.input.value.slice(e,n)):o=this.getRawValue(),o&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",o))};this.onBaseFocus=()=>{this.isFocused=!0,this.options.selectAllOnFocus&&this.input.value.length>0&&(this.focusSelectTimerId!==null&&clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=window.setTimeout(()=>{this.focusSelectTimerId=null,!this.isDestroyed&&document.activeElement===this.input&&this.input.select()},0))};this.onBaseBlur=()=>{this.isFocused=!1};this.onScroll=()=>{this.ghost&&(this.ghost.scrollLeft=this.input.scrollLeft)};let{wrapper:o,input:s,options:r}=T(t,e,n);if(!s||typeof s!="object"||s.nodeType!==1||s.tagName!=="INPUT")throw new Error(`[${new.target.name||"InputMask"}] input (HTMLInputElement) est requis.`);this.input=s;let a=this.input.getAttribute("data-mask-create-wrapper")==="true",u=!!(r.createWrapper??a),d=o;if(!d&&u){let w=document.createElement("span");w.className="wulf-mask-wrapper",w.style.display="inline-grid",w.style.gridTemplateColumns="1fr",w.style.gridTemplateRows="1fr",w.style.verticalAlign="middle",w.style.boxSizing="border-box",w.style.position="relative",this.input.parentNode&&this.input.parentNode.insertBefore(w,this.input),w.appendChild(this.input),this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",d=w,this.isWrapperCreated=!0}if(!d)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=d,this.normalizeInputType();let m=this.getAttr("data-mask-focus-only")==="true",l=this.hasAttr("data-disabled"),p=this.getAttr("data-mask-select-on-focus")==="true",h=this.getAttr("data-mask-copy-raw")==="true",c=this.getAttr("data-mask-align")||this.getAttr("data-align"),g=this.getAttr("data-mask-audit"),{disabled:f,align:v,...y}=r,E=f!==void 0?f:!!l,k=r.audit??(g!==null?g!=="false":!0),M=this.input.type==="password";this.options={...y,createWrapper:u,showMaskOnFocus:r.showMaskOnFocus??m??!1,selectAllOnFocus:r.selectAllOnFocus??p??!1,copyRaw:M?!1:r.copyRaw??h??!1,disabled:E,align:v??(c||void 0),emitNativeInput:r.emitNativeInput??!0,audit:k},this.options.showMaskOnFocus&&this.wrapper.classList.add("mask-focus-only"),this.options.disabled&&this.wrapper.setAttribute("data-disabled","true"),this.options.align&&this.setAlign(this.options.align),this.createGhost(),this.hookValueProperty(),this.bindBaseEvents(),this.initMutationObserver()}getAttr(t){return this.input.getAttribute(t)||this.wrapper.getAttribute(t)}hasAttr(t){return this.wrapper.hasAttribute(t)||this.input.hasAttribute(t)}hasNativePlaceholder(){return!!(this.input.placeholder&&this.input.placeholder.trim().length>0)}shouldHideGhostForPlaceholder(t){return!this.isFocused&&t&&this.hasNativePlaceholder()}bindBaseEvents(){this.input.addEventListener("copy",this.onBaseCopy),this.input.addEventListener("focus",this.onBaseFocus),this.input.addEventListener("blur",this.onBaseBlur)}extractRawSnippet(t){return t}initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(e=>{for(let n of e)n.type==="attributes"&&n.attributeName&&this.handleAttributeMutation(n.attributeName)});let t={attributes:!0,attributeFilter:["data-mask","data-mask-placeholder","data-mask-focus-only","data-mask-strict","data-mask-select-on-focus","data-mask-copy-raw","data-mask-pad-decimals","data-mask-auto-lowercase","data-mask-cycle-suggestions","data-mask-default-tld","data-mask-tlds","data-disabled","data-mask-align","data-align","placeholder"]};this.mutationObserver.observe(this.wrapper,t),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,t)}setAlign(t){let e=t||void 0,n=this.wrapper.getAttribute("data-align");this.options.align===e&&n===(t||null)||(this.options.align=e,this.wrapper.classList.remove("align-left","align-right","align-center"),t?(this.wrapper.classList.add(`align-${t}`),this.wrapper.getAttribute("data-align")!==t&&this.wrapper.setAttribute("data-align",t)):this.wrapper.hasAttribute("data-align")&&this.wrapper.removeAttribute("data-align"),this.syncGhostStyles())}handleAttributeMutation(t){if(t==="data-disabled"){let e=this.hasAttr("data-disabled");e!==!!this.options.disabled&&this.setDisabled(e)}else if(t==="data-mask-focus-only"){let e=this.getAttr("data-mask-focus-only")==="true";e!==!!this.options.showMaskOnFocus&&this.setShowMaskOnFocus(e)}else if(t==="data-mask-select-on-focus")this.options.selectAllOnFocus=this.getAttr("data-mask-select-on-focus")==="true";else if(t==="data-mask-copy-raw")this.options.copyRaw=this.getAttr("data-mask-copy-raw")==="true";else if(t==="data-mask-align"||t==="data-align"){let e=this.getAttr("data-mask-align")||this.getAttr("data-align");e!==(this.options.align??null)&&this.setAlign(e)}}normalizeInputType(){let t=["number","email","date","datetime-local","month","week","time","color","file","range"];if(this.input.type&&t.includes(this.input.type.toLowerCase())){let e=this.input.type.toLowerCase();this.input.type="text",e==="number"&&(this.input.inputMode="numeric")}}createGhost(){let t=this.wrapper.querySelector(".mask-ghost");t&&t.remove(),this.ghost=document.createElement("div"),this.ghost.className="mask-ghost",this.ghost.setAttribute("aria-hidden","true"),this.ghost.style.display="flex",this.ghost.style.alignItems="center",this.wrapper.appendChild(this.ghost),this.wrapper.classList.add("has-ghost"),this.syncGhostStyles()}syncGhostStyles(){if(!this.ghost||typeof window>"u")return;let t=window.getComputedStyle(this.input);if(!t)return;this.ghost.style.fontFamily=t.fontFamily,this.ghost.style.fontSize=t.fontSize,this.ghost.style.fontWeight=t.fontWeight,this.ghost.style.fontStyle=t.fontStyle,this.ghost.style.letterSpacing=t.letterSpacing,this.ghost.style.lineHeight=t.lineHeight,this.ghost.style.paddingTop=t.paddingTop,this.ghost.style.paddingBottom=t.paddingBottom,this.ghost.style.paddingLeft=t.paddingLeft,this.ghost.style.paddingRight=t.paddingRight,this.ghost.style.borderTopWidth=t.borderTopWidth,this.ghost.style.borderBottomWidth=t.borderBottomWidth,this.ghost.style.borderLeftWidth=t.borderLeftWidth,this.ghost.style.borderRightWidth=t.borderRightWidth,this.ghost.style.borderTopStyle=t.borderTopStyle==="none"?"none":"solid",this.ghost.style.borderBottomStyle=t.borderBottomStyle==="none"?"none":"solid",this.ghost.style.borderLeftStyle=t.borderLeftStyle==="none"?"none":"solid",this.ghost.style.borderRightStyle=t.borderRightStyle==="none"?"none":"solid",this.ghost.style.borderColor="transparent",this.ghost.style.boxSizing=t.boxSizing,this.ghost.style.textAlign=t.textAlign,this.ghost.style.direction=t.direction;let e=t.direction==="rtl"||this.input.getAttribute("dir")==="rtl"||this.wrapper.getAttribute("dir")==="rtl";t.textAlign==="right"||t.textAlign==="end"||e&&t.textAlign!=="left"&&t.textAlign!=="center"?this.ghost.style.justifyContent="flex-end":t.textAlign==="center"?this.ghost.style.justifyContent="center":this.ghost.style.justifyContent="flex-start"}setNativeValue(t){this.nativeValueDescriptor&&this.nativeValueDescriptor.set?this.nativeValueDescriptor.set.call(this.input,t):this.input.value=t}dispatchNativeInput(){if(!(this.isDestroyed||typeof window>"u")&&this.options.emitNativeInput!==!1){this.isDispatchingNativeInput=!0;try{let t=this.input._valueTracker;t&&typeof t.setValue=="function"&&t.setValue(this.lastTrackedValue),this.lastTrackedValue=this.input.value,this.input.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))}finally{this.isDispatchingNativeInput=!1}}}hookValueProperty(){try{let t=HTMLInputElement.prototype,e=Object.getOwnPropertyDescriptor(t,"value");if(!e||!e.set||!e.get)return;this.nativeValueDescriptor=e;let n=this;Object.defineProperty(this.input,"value",{get(){return e.get.call(this)},set(o){let s=String(o??"");e.set.call(this,s),!n.isDestroyed&&n.onNativeValueSet(s)},configurable:!0})}catch{}}unhookValueProperty(){try{delete this.input.value}catch{}}setShowMaskOnFocus(t){this.options.showMaskOnFocus=t,this.wrapper.classList.toggle("mask-focus-only",t)}disabled(t){if(t===void 0)return!!this.options.disabled;this.setDisabled(t)}setDisabled(t){this.options.disabled=!!t,this.options.disabled?this.wrapper.setAttribute("data-disabled","true"):this.wrapper.removeAttribute("data-disabled"),this.onDisabledChange(this.options.disabled)}getWrapper(){return this.wrapper}getInput(){return this.input}getGhost(){return this.ghost}getElements(){return{wrapper:this.wrapper,input:this.input,ghost:this.ghost}}getValue(){return this.input.value}getRawValue(){return this.input.value}audit(){let t=[],e=this.input.ownerDocument||document,n=this.input.getAttribute("aria-label")?.trim(),o=this.checkAriaIdReferences(this.input,"aria-labelledby",t),s=!!this.input.closest("label"),r=!!(this.input.labels&&this.input.labels.length>0),a=!1;this.input.id&&typeof CSS<"u"&&typeof CSS.escape=="function"?a=!!e.querySelector(`label[for="${CSS.escape(this.input.id)}"]`):this.input.id&&(a=!!e.querySelector(`label[for="${this.input.id}"]`)),!n&&!o&&!s&&!r&&!a&&t.push(`\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`),this.checkAriaIdReferences(this.input,"aria-describedby",t);let u=this.getSpecificAuditWarnings();return t.push(...u),t}getAuditPrefix(){return`Wulf.Mask.${this.constructor.name||"InputMask"}`}getAuditTargetLabel(){return this.input.id?`#${this.input.id}`:this.input.name?`input[name="${this.input.name}"]`:"<input>"}getAuditDisableHint(){return'Passez { audit: false } ou data-mask-audit="false" pour d\xE9sactiver cet avertissement'}getSpecificAuditWarnings(){return[]}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.focusSelectTimerId!==null&&(clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.input.removeEventListener("copy",this.onBaseCopy),this.input.removeEventListener("focus",this.onBaseFocus),this.input.removeEventListener("blur",this.onBaseBlur),this.unhookValueProperty(),this.ghost&&(this.ghost.remove(),this.ghost=null),this.isWrapperCreated&&this.wrapper?(this.input.style.gridArea="",this.input.style.boxSizing="",this.wrapper.parentNode&&this.wrapper.parentNode.insertBefore(this.input,this.wrapper),this.wrapper.remove()):this.wrapper&&(this.wrapper.removeAttribute("data-mask"),this.wrapper.removeAttribute("data-disabled"),this.wrapper.classList.remove("is-complete","is-focused","mask-focus-only","has-selection","has-ghost")))}};var j={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:b=>b.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:b=>b.toUpperCase()}},x=class b{constructor(i,t={}){this.patterns=[];this.subEngines=[];this.activeEngine=null;this.slots=[];this.fullMaskTemplate="";this.prefixSlotsCount=0;this.prefixString="";this.strict=!0;this.autoLowercase=!1;let e=t||{};this.placeholderChar=e.placeholderChar||"_",this.tokens={...j,...e.tokens||{}},this.strict=e.strict!==!1,this.autoLowercase=e.autoLowercase??!1,this.pattern="",this.compile(i)}static format(i,t,e={}){return!t||Array.isArray(t)&&t.length===0?i??"":new b(t,e||{}).format(i??"")}compile(i){if(i!==void 0&&(Array.isArray(i)?(this.patterns=[...i],this.pattern=this.patterns[0]||""):(this.patterns=[],this.pattern=i)),this.patterns.length>0)return this.subEngines=this.patterns.map(n=>new b(n,{placeholderChar:this.placeholderChar,tokens:this.tokens,strict:this.strict,autoLowercase:this.autoLowercase})),this.activeEngine=this.subEngines[0],this.slots=this.activeEngine.slots,this.fullMaskTemplate=this.activeEngine.fullMaskTemplate,this.prefixSlotsCount=this.activeEngine.prefixSlotsCount,this.prefixString=this.activeEngine.prefixString,this.slots;this.subEngines=[],this.activeEngine=null,this.slots=[];let t="",e=!0;for(let n=0;n<this.pattern.length;n++){let o=this.pattern[n],s=!1;o==="\\"&&n+1<this.pattern.length&&(s=!0,n++,o=this.pattern[n]);let r=s?void 0:this.tokens[o];r?(e=!1,this.slots.push({char:o,isStatic:!1,isPrefix:!1,token:r,placeholder:this.placeholderChar}),t+=this.placeholderChar):(this.slots.push({char:o,isStatic:!0,isPrefix:e,placeholder:o}),t+=o)}this.fullMaskTemplate=t,this.prefixSlotsCount=0,this.prefixString="";for(let n of this.slots)if(n.isPrefix)this.prefixSlotsCount++,this.prefixString+=n.char;else break;return this.slots}selectEngine(i){if(this.subEngines.length<=1)return this;let t=String(i??""),e=this.subEngines.filter(a=>{let u=a.getPrefix();return u.length>0&&t.toLowerCase().startsWith(u.trim().toLowerCase())}),n=e.length>0?e:this.subEngines,o=[...n].sort((a,u)=>u.getEditableCount()-a.getEditableCount())[0],r=(o?o.extractRaw(t):t).length;for(let a of n)if(a.getEditableCount()>=r)return this.activeEngine=a,a;return this.activeEngine=n[n.length-1],this.activeEngine}getPrefix(){return this.activeEngine?this.activeEngine.getPrefix():this.prefixString}getPrefixLength(){return this.activeEngine?this.activeEngine.getPrefixLength():this.prefixSlotsCount}getFullMaskTemplate(){return this.activeEngine?this.activeEngine.getFullMaskTemplate():this.fullMaskTemplate}getEditableCount(){return this.subEngines.length>0?Math.max(...this.subEngines.map(i=>i.getEditableCount())):this.activeEngine?this.activeEngine.getEditableCount():this.slots.filter(i=>!i.isStatic).length}isNumericOnly(){if(this.subEngines.length>0)return this.subEngines.every(e=>e.isNumericOnly());let t=(this.activeEngine?this.activeEngine.slots:this.slots).filter(e=>!e.isStatic);return t.length===0?!1:t.every(e=>e.char==="9"||e.token&&e.token.pattern.test("0")&&!e.token.pattern.test("a")&&!e.token.pattern.test("Z"))}setStrict(i){this.strict=i}isStrict(){return this.strict}extractRaw(i){if(this.subEngines.length>0){let s=this.selectEngine(i);if(s!==this)return s.extractRaw(i)}let t=String(i??"");if(!t)return"";let e="",n=0,o=0;if(this.prefixSlotsCount>0){for(;n<t.length&&(t[n]===" "||t[n]===" ");)n++;let s=0;for(;n<t.length&&s<this.prefixSlotsCount;){let r=this.slots[s].char,a=t[n];if(a.toUpperCase()===r.toUpperCase())n++,s++;else if(r===" "&&a!==" ")s++;else break}o=this.prefixSlotsCount}for(;n<t.length&&o<this.slots.length;){let s=this.slots[o],r=t[n];if(s.isStatic)r.toUpperCase()===s.char.toUpperCase()&&n++,o++;else if(s.token&&s.token.pattern.test(r)){let a=s.token.transform?s.token.transform(r):r;this.autoLowercase&&!s.token.transform&&(a=a.toLowerCase()),e+=a,n++,o++}else this.strict?n++:(e+=this.autoLowercase?r.toLowerCase():r,n++,o++)}if(!this.strict&&n<t.length){let s=t.slice(n);e+=this.autoLowercase?s.toLowerCase():s}return e}format(i){if(this.subEngines.length>0){let s=this.selectEngine(i);if(s!==this)return s.format(i)}let t=String(i??"");if(!this.slots.length)return t;let e=this.extractRaw(t);if(e.length===0)return this.prefixString;let n="",o=0;for(let s=0;s<this.slots.length;s++){let r=this.slots[s];if(r.isStatic){let a=o<e.length,u=o===0&&!!r.isPrefix,d=o>0&&o===e.length;if(a||u||d)n+=r.char;else break}else if(o<e.length){let a=e[o],u=r.token?.transform?r.token.transform(a):a;this.autoLowercase&&!r.token?.transform&&(u=u.toLowerCase()),n+=u,o++}else break}if(!this.strict&&o<e.length){let s=e.substring(o);n+=this.autoLowercase?s.toLowerCase():s}return n}getRemainingMask(i){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getRemainingMask(i):this.fullMaskTemplate?i.length>=this.fullMaskTemplate.length?i:i+this.fullMaskTemplate.substring(i.length):""}mapCursorPosition(i,t,e){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.mapCursorPosition(i,t,e);let n=this.prefixSlotsCount,o=String(i??""),s=String(e??"");if(t<=0||!s)return n;let a=this.extractRaw(o.slice(0,t)).length;if(a===0)return Math.max(n,Math.min(this.getNextEditablePosition(0),s.length));let u=0,d=s.length;for(let m=0;m<s.length&&m<this.slots.length;m++)if(!this.slots[m].isStatic&&(u++,u===a)){d=m+1;break}for(;d<s.length&&this.slots[d]&&this.slots[d].isStatic;)d++;return Math.max(n,Math.min(d,s.length))}isSeparatorAt(i){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.isSeparatorAt(i):i>=0&&i<this.slots.length?this.slots[i].isStatic:!1}getNextEditablePosition(i){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.getNextEditablePosition(i);let t=Math.max(0,i);for(let e=t;e<this.slots.length;e++)if(!this.slots[e].isStatic)return e;return this.slots.length}getSlotAt(i){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlotAt(i):this.slots[i]}getSlots(){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlots():this.slots}};var C=class{constructor(i=50){this.stack=[];this.index=-1;this.maxDepth=i}push(i,t){let e=this.getCurrent();if(e&&e.raw===i){e.cursor=t;return}this.stack=this.stack.slice(0,this.index+1),this.stack.push({raw:i,cursor:t}),this.stack.length>this.maxDepth&&this.stack.shift(),this.index=this.stack.length-1}updateCurrentCursor(i){let t=this.getCurrent();t&&(t.cursor=i)}undo(){return this.canUndo()?(this.index--,this.stack[this.index]):null}redo(){return this.canRedo()?(this.index++,this.stack[this.index]):null}canUndo(){return this.index>0}canRedo(){return this.index>=0&&this.index<this.stack.length-1}getCurrent(){return this.index>=0&&this.index<this.stack.length?this.stack[this.index]:null}clear(){this.stack=[],this.index=-1}};var L=class{constructor(i){this.delegate=i}handleKeyDown(i){let t=this.delegate.getInput(),e=this.delegate.getEngine(),n=this.delegate.getHistory(),o=e.getPrefixLength(),s=t.selectionStart??0,r=t.selectionEnd??s;if((i.ctrlKey||i.metaKey)&&(i.key==="z"||i.key==="Z")&&!i.shiftKey){i.preventDefault(),this.delegate.undo();return}if((i.ctrlKey||i.metaKey)&&(i.key==="y"||i.key==="Y")||(i.ctrlKey||i.metaKey)&&i.shiftKey&&(i.key==="z"||i.key==="Z")){i.preventDefault(),this.delegate.redo();return}n.updateCurrentCursor(s);let a=i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey,u=r>s;if(a&&!u){let l=e.getSlots(),p=s<l.length&&l[s].isStatic&&l[s].char===i.key,h=s>0&&s-1<l.length&&l[s-1].isStatic&&l[s-1].char===i.key;if(p||h){i.preventDefault();let g=p?s:s-1,f=e.getNextEditablePosition(g+1);this.delegate.applyMask(t.value,f,!0);return}let c=-1;for(let g=s;g<l.length;g++)if(l[g].isStatic){l[g].char===i.key&&(c=g);break}if(c!==-1){i.preventDefault();let g=c-1;for(;g>=o&&!l[g].isStatic;)g--;g++;let f=c-g,v=t.value.slice(g,s);if(l.slice(g,c).every(k=>!k.token||k.token.pattern.test("0"))&&f>v.length&&v.length>0){let k=f-v.length,M="0".repeat(k)+v,w=t.value.slice(c),N=t.value.slice(0,g)+M+w,S=e.getNextEditablePosition(c+1);this.delegate.applyMask(N,S,!0);return}let E=e.getNextEditablePosition(c+1);this.delegate.applyMask(t.value,E,!0);return}}if(a&&e.isStrict()){let l=e.getEditableCount();if(l>0){let p=e.extractRaw(t.value),h=l-p.length;if(r>s){let c=e.extractRaw(t.value.slice(s,r));h=l-(p.length-c.length)}if(h<=0){i.preventDefault();return}}}if(r>s){if(i.key==="Backspace"||i.key==="Delete"){i.preventDefault();let l=t.value,p=l.slice(0,s)+l.slice(r);this.delegate.applyMask(p,Math.max(o,s));return}return}if(i.key==="ArrowLeft"&&!i.shiftKey&&s<=o){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Home"&&!i.shiftKey){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Backspace"&&s<=o){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Delete"&&s<o){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Backspace"&&(i.ctrlKey||i.altKey||i.metaKey)){if(i.preventDefault(),s<=o){t.setSelectionRange(o,o);return}let l=s-1;for(;l>=o&&e.isSeparatorAt(l);)l--;for(;l>=o&&!e.isSeparatorAt(l);)l--;let p=Math.max(o,l+1),h=t.value,c=h.slice(0,p)+h.slice(s);this.delegate.applyMask(c,p);return}if(i.key==="Delete"&&(i.ctrlKey||i.altKey||i.metaKey)){i.preventDefault();let l=t.value;if(s>=l.length)return;let p=s;for(;p<l.length&&e.isSeparatorAt(p);)p++;for(;p<l.length&&!e.isSeparatorAt(p);)p++;for(;p<l.length&&e.isSeparatorAt(p);)p++;let h=p,c=l.slice(0,s)+l.slice(h);this.delegate.applyMask(c,s);return}if(i.key==="Backspace"&&s>o){if(e.isSeparatorAt(s-1)){i.preventDefault();let l=s-1;for(;l>o&&e.isSeparatorAt(l-1);)l--;if(l>o){let p=t.value,h=p.slice(0,l-1)+p.slice(s);this.delegate.applyMask(h,l-1)}else this.delegate.applyMask("",o)}return}if(i.key==="Delete"&&s<t.value.length){if(e.isSeparatorAt(s)){i.preventDefault();let l=s;for(;l<t.value.length&&e.isSeparatorAt(l);)l++;if(l<t.value.length){let p=t.value,h=p.slice(0,l)+p.slice(l+1);this.delegate.applyMask(h,s)}}return}}handleKeyUp(i){let t=this.delegate.getInput(),e=this.delegate.getHistory();(i.key==="ArrowLeft"||i.key==="ArrowRight"||i.key==="Home")&&!i.shiftKey&&this.delegate.enforceMinCursor(),e.updateCurrentCursor(t.selectionStart??0)}};var R=class extends A{constructor(t,e,n){let o=T(t,e,n),s=o.wrapper,r=o.input,a=o.options,u=s?.getAttribute("data-mask")||r?.getAttribute("data-mask"),d=a.mask||u||"";typeof d=="string"&&d.includes("|")&&(d=d.split("|").map(k=>k.trim()));let m=a.placeholderChar||s?.getAttribute("data-mask-placeholder")||r?.getAttribute("data-mask-placeholder")||"_",l=s?.hasAttribute("data-disabled")||r?.hasAttribute("data-disabled"),p=s?.getAttribute("data-mask-strict")||r?.getAttribute("data-mask-strict"),h=s?.getAttribute("data-mask-auto-lowercase")==="true"||r?.getAttribute("data-mask-auto-lowercase")==="true",c=s?.getAttribute("data-mask-infer-inputmode")??r?.getAttribute("data-mask-infer-inputmode"),g=a.inferInputMode??(c!==null?c!=="false":!0),{disabled:f,...v}=a,y=f!==void 0?f:l?!0:!d||Array.isArray(d)&&d.length===0,E={...v,mask:d,placeholderChar:m,strict:a.strict??(p!==null?p!=="false":!0),autoLowercase:a.autoLowercase??h??!1,disabled:y,resetHistoryOnMaskChange:a.resetHistoryOnMaskChange??!1,inferInputMode:g,onInput:a.onInput||a.oninput,onChange:a.onChange||a.onchange,onComplete:a.onComplete||a.oncomplete};super(s,r,E);this.isComposing=!1;this.isUndoingRedoing=!1;this.isMouseDown=!1;this.isApplyingMask=!1;this.lastValue="";this.lastInternalRemainingMask="";this.isNotifying=!1;this.hasPendingNotification=!1;this.onChangeNativeHandler=()=>{};this.wasInputModeInferred=!1;this.cutTimerId=null;this.pasteTimerId=null;this.resetTimerId=null;this.history=new C,this.engine=new x(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new L({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(k,M,w)=>this.applyMask(k,M,w),undo:()=>this.undo(),redo:()=>this.redo(),enforceMinCursor:()=>this.enforceMinCursor()}),this.bindEvents(),this.lastValue=this.input.value,this.syncInitialValue(),this.runAuditWarning(this.options.audit)}getSpecificAuditWarnings(){let t=[],e=!!this.input.getAttribute("aria-describedby")?.trim(),n=!!this.input.getAttribute("placeholder")?.trim(),o=!!this.input.getAttribute("aria-placeholder")?.trim();return!e&&!n&&!o&&!this.options.disabled&&t.push("Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."),t}extractRawSnippet(t){return this.engine.extractRaw(t)}static format(t,e,n={}){return x.format(t,e,n)}onNativeValueSet(t){this.options.disabled?this.checkValueChange():this.applyMask(t,t.length)}onDisabledChange(t){t?(this.wrapper.removeAttribute("data-mask"),this.wrapper.classList.remove("is-complete","has-selection"),this.ghost&&(this.ghost.textContent=""),this.checkValueChange()):this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onClick=this.onClick.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onSelect=this.onSelect.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onScroll=this.onScroll.bind(this),this.onBeforeInput=this.onBeforeInput.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,!this.isDestroyed)if(this.options.disabled)this.checkValueChange();else{let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t)}},0)},this.onChangeNativeHandler=()=>{this.isDestroyed||this.checkValueChange()},this.input.addEventListener("beforeinput",this.onBeforeInput),this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.onKeyDown),this.input.addEventListener("paste",this.onPaste),this.input.addEventListener("focus",this.onFocus),this.input.addEventListener("blur",this.onBlur),this.input.addEventListener("click",this.onClick),this.input.addEventListener("keyup",this.onKeyUp),this.input.addEventListener("select",this.onSelect),this.input.addEventListener("mousedown",this.onMouseDown),window.addEventListener("mouseup",this.onMouseUp),this.input.addEventListener("compositionstart",this.onCompositionStart),this.input.addEventListener("compositionend",this.onCompositionEnd),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.addEventListener("change",this.onChangeNativeHandler),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled?this.checkValueChange():this.syncInitialValue())},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}syncInferredInputMode(){if(!this.options.inferInputMode)return;!this.options.disabled&&this.engine.isNumericOnly()?this.input.hasAttribute("inputmode")||(this.input.inputMode="numeric",this.wasInputModeInferred=!0):this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&(this.input.removeAttribute("inputmode"),this.wasInputModeInferred=!1)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.pasteTimerId!==null&&(clearTimeout(this.pasteTimerId),this.pasteTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("beforeinput",this.onBeforeInput),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.onKeyDown),this.input.removeEventListener("paste",this.onPaste),this.input.removeEventListener("focus",this.onFocus),this.input.removeEventListener("blur",this.onBlur),this.input.removeEventListener("click",this.onClick),this.input.removeEventListener("keyup",this.onKeyUp),this.input.removeEventListener("select",this.onSelect),this.input.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),this.input.removeEventListener("compositionstart",this.onCompositionStart),this.input.removeEventListener("compositionend",this.onCompositionEnd),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.removeEventListener("change",this.onChangeNativeHandler),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&this.input.removeAttribute("inputmode"),this.history.clear(),super.destroy())}setStrict(t){this.options.strict=t,this.engine.setStrict(t),this.options.disabled||this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}isStrict(){return this.engine.isStrict()}setMask(t,e){let n=typeof e=="boolean"?e:e&&typeof e=="object"&&e.strict!==void 0?e.strict:this.options.strict,o=e&&typeof e=="object"&&e.resetHistory!==void 0?e.resetHistory:!!this.options.resetHistoryOnMaskChange;if(!((!t||Array.isArray(t)&&t.length===0)&&this.options.disabled&&(!this.options.mask||this.options.mask===""))){if(!t||Array.isArray(t)&&t.length===0){this.options.mask="",this.options.strict=n,this.engine.setStrict(n??!0),this.engine.compile(""),o&&this.history.clear(),this.setDisabled(!0),this.syncInferredInputMode();return}this.options.mask=t,this.options.strict=n,this.engine.setStrict(n??!0),this.engine.compile(t),o&&this.history.clear(),this.setDisabled(!1),this.syncInferredInputMode()}}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask"){let e=this.getAttr("data-mask");if(e===this.lastInternalRemainingMask)return;let n=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(e===n)return;if(e){let o=e.includes("|")?e.split("|").map(s=>s.trim()):e;this.setMask(o)}else this.setMask(null)}else if(t==="data-mask-strict"){let e=this.getAttr("data-mask-strict");this.setStrict(e!=="false")}else t==="data-mask-auto-lowercase"?(this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true",this.engine.compile(this.options.mask||""),this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)):t==="placeholder"&&this.updateGhost(this.input.value)}setValue(t){let e=t!=null?String(t):"";if(this.options.disabled){this.input.value=e,this.checkValueChange();return}this.applyMask(e,e.length)}getRawValue(){return this.engine.extractRaw(this.input.value)}isComplete(){return this.options.disabled?!0:this.getRawValue().length>=this.engine.getEditableCount()}get onInput(){return this.options.onInput}set onInput(t){this.options.onInput=t}undo(){if(this.options.disabled)return;let t=this.history.undo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}redo(){if(this.options.disabled)return;let t=this.history.redo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}checkSelection(){if(this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,n=t!==e;this.wrapper.classList.toggle("has-selection",n)}onBeforeInput(t){if(!this.options.disabled&&!this.isComposing&&this.engine.isStrict()&&t.inputType!=="insertFromPaste"&&t.inputType&&t.inputType.startsWith("insert")){let e=this.engine.getEditableCount();if(e>0){let n=this.getRawValue(),o=this.input.selectionStart??0,s=this.input.selectionEnd??o,r=Math.max(0,e-n.length);if(s>o){let a=this.engine.extractRaw(this.input.value.slice(o,s));r=Math.max(0,e-(n.length-a.length))}r<=0&&t.preventDefault()}}}handleInput(t){if(this.isDispatchingNativeInput||this.isComposing)return;if(!!(this.options.onInput||this.options.oninput)&&this.input.value!==this.lastValue&&this.checkValueChange(),this.options.disabled){this.checkValueChange();return}let n=this.history.getCurrent(),o=this.engine.getEditableCount();if(o>0&&this.engine.isStrict()&&n&&n.raw.length>=o&&this.engine.extractRaw(this.input.value).length>o){this.applyMask(n.raw,n.cursor);return}let s=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,s),this.checkSelection()}onKeyDown(t){this.options.disabled||this.keyboard.handleKeyDown(t)}onMouseDown(){this.isMouseDown=!0}onMouseUp(){this.isMouseDown=!1,this.checkSelection()}onPaste(t){if(this.options.disabled){this.pasteTimerId!==null&&clearTimeout(this.pasteTimerId),this.pasteTimerId=window.setTimeout(()=>{this.pasteTimerId=null,this.isDestroyed||this.checkValueChange()},0);return}t.preventDefault(),this.history.updateCurrentCursor(this.input.selectionStart??0);let n=(t.clipboardData?.getData("text")||"").trim();if(!n)return;let o=this.engine.getPrefixLength(),s=this.input.selectionStart??0,r=this.input.selectionEnd??s,a=this.input.value,u=this.engine.getEditableCount(),d=this.getRawValue(),l=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),p=n.replace(/[\s.-]+/g,"").toUpperCase(),h=l.length>0&&p.startsWith(l),c=a.slice(0,Math.max(o,s)).replace(/[\s.-]+/g,"").toUpperCase(),g=c.length>=2&&p.startsWith(c),f=Math.max(o,s),v=Math.max(o,r);(h||g)&&(f=0,v=a.length);let y=Math.max(0,u-d.length);if(f!==v){let M=this.engine.extractRaw(a.slice(f,v));y=Math.max(0,u-(d.length-M.length))}if(this.engine.isStrict()&&y<=0)return;let E,k;f===0&&v===a.length?(E=n,k=n.length):(E=a.slice(0,f)+n+a.slice(v),k=f+n.length),this.applyMask(E,k),this.checkSelection()}onFocus(){this.syncGhostStyles(),this.wrapper.classList.add("is-focused"),!this.options.disabled&&!this.isMouseDown&&this.enforceMinCursor(),this.updateGhost(this.input.value),this.checkSelection()}onBlur(){this.wrapper.classList.remove("is-focused","has-selection"),this.input.type==="password"&&this.history.clear(),this.updateGhost(this.input.value)}onClick(){this.options.disabled||this.enforceMinCursor(),this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onKeyUp(t){this.options.disabled||this.keyboard.handleKeyUp(t),this.checkSelection()}onSelect(){this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t),this.checkSelection()}enforceMinCursor(){let t=this.engine.getPrefixLength();if(t<=0)return;let e=this.input.selectionStart??0,n=this.input.selectionEnd??e;e===n&&e<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled){this.ghost.textContent="";return}let e=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(e)){this.ghost.textContent="";return}let n=this.engine.getFullMaskTemplate(),o=n.length>t.length?n.substring(t.length):"";this.ghost.textContent="";let s=document.createElement("span");s.className="mask-ghost-typed",s.textContent=t;let r=document.createElement("span");r.className="mask-ghost-remaining",r.textContent=o,this.ghost.appendChild(s),this.ghost.appendChild(r),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,n=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let o="",s=!1;try{o=this.engine.format(t);let r=this.engine.getRemainingMask(o);this.input.value=o,this.lastInternalRemainingMask=r,this.wrapper.setAttribute("data-mask",r),this.updateGhost(o);let a=this.engine.getPrefixLength(),u;if(n||this.isUndoingRedoing)u=Math.max(a,Math.min(e,o.length));else{let d=this.engine.mapCursorPosition(t,e,o);u=Math.max(a,d)}this.input.setSelectionRange(u,u),s=this.isComplete(),this.wrapper.classList.toggle("is-complete",s),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(this.getRawValue(),u)}finally{this.isApplyingMask=!1}this.checkValueChange()}syncInitialValue(){if(this.options.disabled){this.wrapper.removeAttribute("data-mask"),this.ghost&&(this.ghost.textContent=""),this.lastValue=this.input.value,this.checkValueChange();return}this.syncGhostStyles();let t=this.input.value||"";if(t)this.applyMask(t,t.length);else{let e=this.engine.getPrefixLength();if(e>0)this.applyMask("",e);else{this.input.type!=="password"&&this.history.push("",0);let n=this.engine.getFullMaskTemplate();this.lastInternalRemainingMask=n,this.wrapper.setAttribute("data-mask",n),this.updateGhost(""),this.checkValueChange()}}}checkValueChange(t=!1){if(!(this.input.value===this.lastValue&&!t&&!this.hasPendingNotification)){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{for(;this.input.value!==this.lastValue||this.hasPendingNotification||t;){this.hasPendingNotification=!1,t=!1;let n=this.input.value;this.lastValue=n;let o=this.options.disabled?n:this.getRawValue(),s=this.options.disabled?0:this.engine.getEditableCount(),r=this.isComplete(),a={value:n,rawValue:o,isComplete:r,totalSlots:s,filledSlots:this.options.disabled?n.length:o.length},u=this.options.onInput||this.options.oninput;u&&u(n,a),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:a})),this.dispatchNativeInput();let d=this.options.onChange||this.options.onchange;d&&d(a),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:a}));let m=this.options.onComplete||this.options.oncomplete;r&&(m&&m(a),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:a})))}}finally{this.isNotifying=!1}}}};var I=class b{constructor(i={}){let t=i.currency??"";!t&&i.unit&&(t=i.unit);let e=t==="$"||t==="\xA3"||t==="\xA5"?"prefix":"suffix";this.options={currency:t,unit:i.unit??t,currencyPosition:i.currencyPosition??e,decimals:i.decimals!==void 0?Math.max(0,i.decimals):2,decimalSeparator:i.decimalSeparator??",",thousandSeparator:i.thousandSeparator??"\xA0",allowNegative:i.allowNegative??!1,min:i.min??-1/0,max:i.max??1/0}}parse(i){let t=i.trim(),e=!1;this.options.allowNegative&&t.includes("-")&&(e=!0),this.options.currency&&(t=t.replace(new RegExp(this.escapeRegExp(this.options.currency),"g"),"")),this.options.thousandSeparator&&(t=t.replace(new RegExp(this.escapeRegExp(this.options.thousandSeparator),"g"),"")),t=t.replace(/[\s\u00A0]/g,"");let n=this.options.decimalSeparator,o=t.indexOf(n);o===-1&&(o=t.search(/[,.]/));let s="",r=null,a=!1;return o!==-1?(s=t.substring(0,o).replace(/\D/g,""),this.options.decimals>0&&(a=!0,r=t.substring(o+1).replace(/\D/g,"").slice(0,this.options.decimals))):s=t.replace(/\D/g,""),s.length>1&&(s=s.replace(/^0+/,"")||"0"),{isNegative:e,integerPart:s,decimalPart:r,hasDecimal:a}}format(i,t=i.length,e=!1){if(!i||i.trim()===""||i===this.options.currency.trim())return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let n=i.substring(0,t),o=n.replace(/\D/g,"").length,s=this.options.decimals>0&&/[,.]/.test(n),{isNegative:r,integerPart:a,decimalPart:u,hasDecimal:d}=this.parse(i),m=u,l=d;if(e&&this.options.decimals>0&&(a||u!==null)&&(l=!0,m===null?m="0".repeat(this.options.decimals):m.length<this.options.decimals&&(m=m+"0".repeat(this.options.decimals-m.length))),r&&!a&&!m&&!l&&this.options.allowNegative){let S="-",D=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(S=`${this.options.currency} -`,D=S.length):(S=`- ${this.options.currency}`,D=1)),{formatted:S,rawNumber:null,rawValue:"-",cursor:D,isValid:!0}}if(!a&&!m&&!l)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let h=(a||"0").replace(/\B(?=(\d{3})+(?!\d))/g,this.options.thousandSeparator);l&&this.options.decimals>0&&(h+=this.options.decimalSeparator+(m??"")),r&&h!=="0"&&(h="-"+h);let c=h;this.options.currency&&(this.options.currencyPosition==="prefix"?c=`${this.options.currency} ${h}`:c=`${h} ${this.options.currency}`);let g=(r?"-":"")+(a||"0")+(u?"."+u:""),f=parseFloat(g);isNaN(f)&&(f=0);let v=f>=this.options.min&&f<=this.options.max,y=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(y=this.options.currency.length+1);let E=0,k=!1,M=y;for(let S=y;S<c.length;S++){let D=c[S];if(D===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(D)?(E++,M=S+1):D===this.options.decimalSeparator&&(k=!0,M=S+1),s){if(k&&E>=o){y=S+1;break}}else if(E>=o){y=S+1;break}}o>0&&E<o&&M>y&&(y=M);let w=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,N=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,c.length-this.options.currency.length-1):c.length;return y=Math.max(w,Math.min(y,Math.max(w,N))),{formatted:c,rawNumber:f,rawValue:g,cursor:y,isValid:v}}static format(i,t={}){let e=new b(t),n=typeof i=="number"?i.toString():i;return e.format(n).formatted}escapeRegExp(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var P=class extends A{constructor(t,e,n){let o=T(t,e,n),s=o.wrapper,r=o.input,a=o.options,u=s?.getAttribute("data-mask-pad-decimals")==="true"||r?.getAttribute("data-mask-pad-decimals")==="true",d=r?.getAttribute("data-mask-align")||r?.getAttribute("data-align")||s?.getAttribute("data-mask-align")||s?.getAttribute("data-align"),m={align:a.align??d??"right",padDecimalsOnBlur:a.padDecimalsOnBlur??u??!1,...a};super(s,r,m);this.isUndoingRedoing=!1;this.isApplying=!1;this.isComposing=!1;this.lastValue="";this.cutTimerId=null;this.resetTimerId=null;this.input.inputMode="decimal",this.history=new C,this.engine=new I(this.options),this.bindEvents(),this.input.value?this.options.disabled||this.applyAmount(this.input.value,this.input.value.length):this.updateGhost({formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0}),this.runAuditWarning(this.options.audit)}extractRawSnippet(t){let e=this.engine.parse(t);return!e.integerPart&&!e.decimalPart?"":(e.isNegative?"-":"")+(e.integerPart||"0")+(e.decimalPart?"."+e.decimalPart:"")}static format(t,e={}){return I.format(t,e)}onNativeValueSet(t){if(this.options.disabled||this.isComposing){this.lastValue=t;return}this.applyAmount(t,t.length)}onDisabledChange(t){t||this.applyAmount(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleClick=this.handleClick.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,this.isDestroyed||this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)},0)},this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("click",this.handleClick),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.addEventListener("compositionstart",this.onCompositionStart),this.input.addEventListener("compositionend",this.onCompositionEnd),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled||this.applyAmount(this.input.value,this.input.value.length))},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)}applyAmount(t,e){if(!(this.isApplying||this.options.disabled)){this.isApplying=!0;try{let n=this.engine.format(t,e);this.setNativeValue(n.formatted),this.input.setSelectionRange(n.cursor,n.cursor),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(n.rawValue,n.cursor),this.updateGhost(n),this.lastValue!==n.formatted&&(this.lastValue=n.formatted,this.notifyChange(n))}finally{this.isApplying=!1}}}updateGhost(t){if(this.ghost){if(!t.formatted){if(this.shouldHideGhostForPlaceholder(!0)){this.ghost.textContent="";return}let e=this.options.currency?this.options.currencyPosition==="prefix"?`${this.options.currency} 0`:`0 ${this.options.currency}`:"0,00";this.ghost.textContent="";let n=document.createElement("span");n.className="mask-ghost-remaining",n.textContent=e,this.ghost.appendChild(n);return}this.ghost.textContent="",this.ghost.scrollLeft=this.input.scrollLeft}}handleInput(){if(this.isDispatchingNativeInput||this.options.disabled||this.isComposing)return;let t=this.input.value,e=this.input.selectionStart??t.length;this.applyAmount(t,e)}handleKeyDown(t){if(!this.options.disabled){if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")){t.preventDefault(),t.shiftKey?this.redo():this.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")){t.preventDefault(),this.redo();return}if(t.key==="Backspace"){let e=this.input.selectionStart??0,n=this.input.selectionEnd??0;if(e===n&&e>0){let o=this.input.value,s=o[e-1];if(s===this.engine.options.thousandSeparator||s===" "){t.preventDefault();let r=Math.max(0,e-2),a=o.slice(0,r)+o.slice(e);this.applyAmount(a,r);return}if(this.options.currency&&this.options.currencyPosition==="prefix"&&e<=this.options.currency.length+1){t.preventDefault();return}}}if(t.key==="Delete"){let e=this.input.selectionStart??0,n=this.input.selectionEnd??0;if(e===n&&e<this.input.value.length){let o=this.input.value,s=o[e];if(s===this.engine.options.thousandSeparator||s===" "){t.preventDefault();let r=o.slice(0,e)+o.slice(e+2);this.applyAmount(r,e);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let r=o.length-this.options.currency.length-1;if(e>=r){t.preventDefault();return}}}}setTimeout(()=>this.enforceCursorBounds(),0)}}enforceCursorBounds(){if(!this.input.value||this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??0;if(t!==e)return;let n=this.input.value,o=this.options.currency;if(o){if(this.options.currencyPosition==="prefix"){let s=o.length+1;t<s&&this.input.setSelectionRange(s,s)}else if(this.options.currencyPosition==="suffix"){let s=Math.max(0,n.length-o.length-1);t>s&&this.input.setSelectionRange(s,s)}}}handleClick(){this.enforceCursorBounds()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.enforceCursorBounds(),this.updateGhost(this.engine.format(this.input.value))}handleBlur(){if(this.wrapper.classList.remove("is-focused"),this.input.type==="password"&&this.history.clear(),this.options.padDecimalsOnBlur&&!this.options.disabled&&this.input.value.trim().length>0){let e=this.engine.format(this.input.value,this.input.value.length,!0);e.formatted!==this.input.value&&(this.setNativeValue(e.formatted),this.lastValue=e.formatted)}this.updateGhost(this.engine.format(this.input.value));let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){super.handleAttributeMutation(t),t==="data-mask-pad-decimals"?this.options.padDecimalsOnBlur=this.getAttr("data-mask-pad-decimals")==="true":t==="placeholder"&&this.updateGhost(this.engine.format(this.input.value))}notifyChange(t){let e={value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid};this.options.onInput&&this.options.onInput(e),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:e})),this.dispatchNativeInput()}undo(){let t=this.history.undo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}redo(){let t=this.history.redo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}getDetail(){let t=this.engine.format(this.input.value);return{value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid}}getNumber(){return this.getDetail().number}getRawValue(){return this.getDetail().rawValue}isValid(){return this.getDetail().isValid}setValue(t){let e=t!=null?String(t):"";this.options.disabled?(this.setNativeValue(e),this.lastValue=e):this.applyAmount(e,e.length)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("blur",this.handleBlur),this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("click",this.handleClick),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.removeEventListener("compositionstart",this.onCompositionStart),this.input.removeEventListener("compositionend",this.onCompositionEnd),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.history.clear(),super.destroy())}};var O=class O{constructor(i={}){this.defaultDomain=null;this.defaultTld="__";this.domains=i.domains&&i.domains.length>0?i.domains:O.DEFAULT_DOMAINS,this.tlds=i.tlds&&i.tlds.length>0?i.tlds.map(t=>t.trim().replace(/^\./,"")).filter(Boolean):[...O.DEFAULT_TLDS],this.suggestOnAt=i.suggestOnAt??!0,this.setDefaultDomain(i.defaultDomain??null),this.setDefaultTld(i.defaultTld!==void 0?i.defaultTld:"__")}setDefaultDomain(i){i===!0?this.defaultDomain=this.domains.length>0?this.domains[0]:null:typeof i=="string"&&i.trim().length>0?this.defaultDomain=i.trim().replace(/^@/,""):this.defaultDomain=null}setDefaultTld(i){i===!0?this.defaultTld=this.tlds.length>0?this.tlds[0]:null:typeof i=="string"&&i.trim().length>0?this.defaultTld=i.trim().replace(/^\./,""):this.defaultTld=null}setTlds(i){this.tlds=i&&i.length>0?i.map(t=>t.trim().replace(/^\./,"")).filter(Boolean):[...O.DEFAULT_TLDS]}getMatchingTlds(i){let t=(i??"").toLowerCase();return t.length===0?[...this.tlds]:this.tlds.filter(e=>e.toLowerCase().startsWith(t)&&e.toLowerCase()!==t)}getMatchingDomains(i){let t=i??"";if(!t.includes("@"))return this.defaultDomain?[this.defaultDomain]:[];let e=t.indexOf("@");if(t.indexOf("@",e+1)!==-1)return[];let n=t.substring(e+1);if(n.length===0)return this.suggestOnAt?[...this.domains]:[];let o=n.toLowerCase();return this.domains.filter(s=>s.toLowerCase().startsWith(o)&&s.toLowerCase()!==o)}getSuggestion(i,t=0){let e=i??"";if(!e.includes("@"))return this.defaultDomain?{full:e?`${e}@${this.defaultDomain}`:`@${this.defaultDomain}`,remaining:`@${this.defaultDomain}`,matchedDomain:this.defaultDomain,isHintOnly:!1}:{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let n=e.indexOf("@"),o=e.substring(0,n),s=e.substring(n+1);if(e.indexOf("@",n+1)!==-1)return{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let r=this.getMatchingDomains(i);if(r.length>0){let h=(t%r.length+r.length)%r.length,c=r[h],g=s.toLowerCase(),f=c.substring(g.length);return{full:`${o}@${c}`,remaining:f,matchedDomain:c,isHintOnly:!1}}if(s.length===0||s.startsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let a=s.toLowerCase();if(this.domains.some(h=>h.toLowerCase()===a))return{full:i,remaining:"",matchedDomain:s,isHintOnly:!1};let u=s.lastIndexOf(".");if(u===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let h=this.defaultTld.includes("_"),c=`.${this.defaultTld}`,g=`${s}.${this.defaultTld}`;return{full:h?i:`${o}@${g}`,remaining:c,matchedDomain:h?null:g,isHintOnly:h}}let d=s.substring(0,u),m=s.substring(u+1);if(!d||d.endsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};if(m.length===0){if(this.defaultTld&&!this.defaultTld.includes("_")){let h=`${d}.${this.defaultTld}`;return{full:`${o}@${h}`,remaining:this.defaultTld,matchedDomain:h,isHintOnly:!1}}return this.defaultTld&&this.defaultTld.includes("_")?{full:i,remaining:this.defaultTld,matchedDomain:null,isHintOnly:!0}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}let l=m.toLowerCase(),p=this.getMatchingTlds(m);if(p.length>0){let h=(t%p.length+p.length)%p.length,c=p[h],g=c.substring(l.length),f=`${d}.${c}`;return{full:`${o}@${f}`,remaining:g,matchedDomain:f,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&m.length<this.defaultTld.length){let h=this.defaultTld.substring(m.length);if(h.includes("_"))return{full:i,remaining:h,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};O.DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"],O.DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];var H=O;var V=class extends A{constructor(t,e,n){let o=T(t,e,n),s=o.wrapper,r=o.input,a=o.options,u=s?.getAttribute("data-mask-cycle-suggestions")==="true"||r?.getAttribute("data-mask-cycle-suggestions")==="true",d=s?.getAttribute("data-mask-auto-lowercase")==="true"||r?.getAttribute("data-mask-auto-lowercase")==="true",m=s?.getAttribute("data-mask-aria-autocomplete")??r?.getAttribute("data-mask-aria-autocomplete"),l=a.setAriaAutocomplete??(m!==null?m!=="false":!0),p=s?.getAttribute("data-mask-tlds")??r?.getAttribute("data-mask-tlds"),h=a.tlds??(p?p.split(",").map(v=>v.trim()).filter(Boolean):void 0),c=s?.getAttribute("data-mask-default-tld")??r?.getAttribute("data-mask-default-tld"),g=a.defaultTld!==void 0?a.defaultTld:c!==null?c==="false"||c==="none"?null:c==="true"?!0:c:void 0,f={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:a.cycleSuggestions??u??!1,autoLowercase:a.autoLowercase??d??!1,setAriaAutocomplete:l,...a,...h!==void 0?{tlds:h}:{},...g!==void 0?{defaultTld:g}:{}};super(s,r,f);this.currentSuggestion={full:"",remaining:"",matchedDomain:null};this.currentSuggestionIndex=0;this.wasAriaAutocompleteSet=!1;this.cutTimerId=null;this.resetTimerId=null;this.input.inputMode="email",this.options.setAriaAutocomplete&&!this.input.hasAttribute("aria-autocomplete")&&(this.input.setAttribute("aria-autocomplete","inline"),this.wasAriaAutocompleteSet=!0),this.engine=new H(this.options),this.bindEvents(),this.options.disabled||this.updateSuggestion(),this.runAuditWarning(this.options.audit)}onNativeValueSet(t){this.options.disabled||this.updateSuggestion()}onDisabledChange(t){t?this.ghost&&(this.ghost.textContent=""):this.updateSuggestion()}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{this.cutTimerId=null,!(this.isDestroyed||this.options.disabled)&&this.updateSuggestion()},0)},this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!(this.isDestroyed||this.options.disabled)&&this.updateSuggestion()},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}updateSuggestion(){if(this.options.disabled){this.ghost&&(this.ghost.textContent="");return}let t=this.input.value;if(this.currentSuggestion=this.engine.getSuggestion(t,this.currentSuggestionIndex),!this.ghost)return;if(this.shouldHideGhostForPlaceholder(t.length===0))this.ghost.textContent="";else if(this.currentSuggestion.remaining){this.ghost.textContent="";let n=document.createElement("span");n.className="mask-ghost-typed",n.textContent=t;let o=document.createElement("span");o.className="mask-ghost-remaining",o.textContent=this.currentSuggestion.remaining,this.ghost.appendChild(n),this.ghost.appendChild(o)}else this.ghost.textContent="";this.ghost.scrollLeft=this.input.scrollLeft;let e=this.getDetail();this.options.onInput&&this.options.onInput(e),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:e})),this.dispatchNativeInput()}handleInput(){if(!this.isDispatchingNativeInput&&!this.options.disabled){if(this.options.autoLowercase){let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,n=this.input.value.toLowerCase();n!==this.input.value&&(this.setNativeValue(n),this.input.setSelectionRange(t,e))}this.currentSuggestionIndex=0,this.updateSuggestion()}}handleKeyDown(t){if(this.options.disabled)return;let e=!!this.currentSuggestion.remaining&&!this.currentSuggestion.isHintOnly,o=(this.input.selectionStart??0)===this.input.value.length,s=this.input.value.length>0;if(this.options.cycleSuggestions&&e&&s&&o){if(t.key==="ArrowDown"){t.preventDefault(),this.currentSuggestionIndex++,this.updateSuggestion();return}if(t.key==="ArrowUp"){t.preventDefault(),this.currentSuggestionIndex--,this.updateSuggestion();return}}if(t.key==="Tab"&&e&&s&&this.options.completeOnTab){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="Enter"&&e&&s&&this.options.completeOnEnter){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="ArrowRight"&&e&&s&&o&&this.options.completeOnArrowRight){t.preventDefault(),this.acceptSuggestion();return}}acceptSuggestion(){if(!this.currentSuggestion.remaining||this.currentSuggestion.isHintOnly||this.options.disabled||this.input.value.length===0)return!1;let t=this.currentSuggestion.full;this.setNativeValue(t),this.input.setSelectionRange(t.length,t.length),this.currentSuggestionIndex=0,this.updateSuggestion();let e=this.getDetail();return this.options.onChange&&this.options.onChange(e),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:e})),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:e})),!0}setDefaultDomain(t){this.engine.setDefaultDomain(t),this.updateSuggestion()}setDefaultTld(t){this.engine.setDefaultTld(t),this.updateSuggestion()}setTlds(t){this.engine.setTlds(t),this.currentSuggestionIndex=0,this.updateSuggestion()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.updateSuggestion()}handleBlur(){this.wrapper.classList.remove("is-focused"),this.updateSuggestion();let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask-cycle-suggestions")this.options.cycleSuggestions=this.getAttr("data-mask-cycle-suggestions")==="true";else if(t==="data-mask-auto-lowercase")this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true";else if(t==="data-mask-default-tld"){let e=this.getAttr("data-mask-default-tld");this.setDefaultTld(e===null||e==="false"||e==="none"?null:e==="true"?!0:e)}else if(t==="data-mask-tlds"){let e=this.getAttr("data-mask-tlds");this.setTlds(e?e.split(",").map(n=>n.trim()).filter(Boolean):null)}else t==="placeholder"&&this.updateSuggestion()}getDetail(){return{value:this.input.value,suggestedValue:this.currentSuggestion.isHintOnly?"":this.currentSuggestion.full,domain:this.currentSuggestion.matchedDomain}}setValue(t){let e=t!=null?String(t):"";this.setNativeValue(e),this.updateSuggestion()}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("blur",this.handleBlur),this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.wasAriaAutocompleteSet&&this.input.getAttribute("aria-autocomplete")==="inline"&&this.input.removeAttribute("aria-autocomplete"),super.destroy())}};var K={BaseInputMask:A,InputMask:R,MaskEngine:x,MaskHistory:C,MaskKeyboard:L,AmountEngine:I,InputAmountMask:P,EmailEngine:H,InputEmailMask:V};if(typeof window<"u"){let b=window,i=b.Wulf||{};b.Wulf=i,i.Mask=K}var _=R;return q(Z);})();
|
|
5
|
-
if (typeof window !== "undefined") {
|
|
4
|
+
(${this.getAuditDisableHint()})`),e}checkAriaIdReferences(t,e,i){let n=t.getAttribute(e)?.trim();if(!n)return!1;let s=t.ownerDocument||document,o=typeof t.getRootNode=="function"?t.getRootNode():s,r=n.split(/\s+/).filter(Boolean),u=r.length>0&&r.every(l=>!!(typeof ShadowRoot<"u"&&o instanceof ShadowRoot?o.getElementById(l):s.getElementById(l)));return u||i.push(`Attribut ${e}="${n}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),u}};var W=new Set(["left","right","center"]);function C(c,t,e){return t&&typeof t=="object"&&"tagName"in t&&t.tagName==="INPUT"?{wrapper:c||null,input:t,options:e||{}}:{wrapper:null,input:c,options:t&&typeof t=="object"&&!("tagName"in t)?t:{}}}var E=class extends K{wrapper;input;options;ghost=null;isWrapperCreated=!1;wasWrapperFallbackStyled=!1;wasAlignSet=!1;hadInitialDataAlign=!1;isDestroyed=!1;isFocused=!1;isDispatchingNativeInput=!1;lastTrackedValue="";nativeValueDescriptor=null;onCutHandler=()=>{};onFormResetHandler;mutationObserver=null;focusSelectTimerId=null;abortController=new AbortController;constructor(t,e,i){super();let{wrapper:n,input:s,options:o}=C(t,e,i);if(!s||typeof s!="object"||s.nodeType!==1||s.tagName!=="INPUT")throw new Error(`[${new.target.name||"InputMask"}] input (HTMLInputElement) est requis.`);this.input=s;let r=this.input.getAttribute("data-mask-create-wrapper")==="true",u=!!(o.createWrapper??r),l=n;if(!l&&u){let T=this.input.ownerDocument||document,y=T.createElement("span");y.className="wulf-mask-wrapper",this.input.parentNode&&this.input.parentNode.insertBefore(y,this.input),$(y,this.input,null);let F=T.defaultView||(typeof window<"u"?window:null);(!y.isConnected||!F||F.getComputedStyle(y).display!=="inline-grid")&&(y.style.display="inline-grid",y.style.gridTemplateColumns="1fr",y.style.gridTemplateRows="1fr",y.style.verticalAlign="middle",y.style.boxSizing="border-box",y.style.position="relative",this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",this.wasWrapperFallbackStyled=!0),l=y,this.isWrapperCreated=!0}if(!l)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=l,this.normalizeInputType();let g=this.getAttr("data-mask-focus-only")==="true",f=this.hasAttr("data-disabled"),a=this.getAttr("data-mask-select-on-focus")==="true",h=this.getAttr("data-mask-copy-raw")==="true",p=this.getAttr("data-mask-align")||this.getAttr("data-align"),m=p&&W.has(p)?p:null;this.hadInitialDataAlign=this.wrapper.hasAttribute("data-align");let d=this.getAttr("data-mask-audit"),{disabled:b,align:w,...k}=o,S=w&&W.has(w)?w:void 0,v=b!==void 0?b:!!f,M=o.audit??(d!==null?d!=="false":!0),P=this.isPasswordInput();this.options={...k,createWrapper:u,showMaskOnFocus:o.showMaskOnFocus??g??!1,selectAllOnFocus:o.selectAllOnFocus??a??!1,copyRaw:P?!1:o.copyRaw??h??!1,disabled:v,align:S??(m||void 0),emitNativeInput:o.emitNativeInput??!0,audit:M},this.options.showMaskOnFocus&&this.wrapper.classList.add("mask-focus-only"),this.options.disabled&&this.wrapper.setAttribute("data-disabled","true"),this.options.align&&this.setAlign(this.options.align),this.createGhost(),this.hookValueProperty(),this.bindBaseEvents(),this.initMutationObserver()}getAttr(t){return this.input.getAttribute(t)||this.wrapper.getAttribute(t)}hasAttr(t){return this.wrapper.hasAttribute(t)||this.input.hasAttribute(t)}hasNativePlaceholder(){return!!(this.input.placeholder&&this.input.placeholder.trim().length>0)}shouldHideGhostForPlaceholder(t){return!this.isFocused&&t&&this.hasNativePlaceholder()}bindBaseEvents(){let{signal:t}=this.abortController;this.input.addEventListener("copy",this.onBaseCopy,{signal:t}),this.input.addEventListener("focus",this.onBaseFocus,{signal:t}),this.input.addEventListener("blur",this.onBaseBlur,{signal:t})}onBaseCopy=t=>{if(!this.options.copyRaw||this.options.disabled||this.input.type==="password")return;let e=this.input.selectionStart??0,i=this.input.selectionEnd??e,n="";e!==i?n=this.extractRawSnippet(this.input.value.slice(e,i)):n=this.getRawValue(),n&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",n))};extractRawSnippet(t){return t}onBaseFocus=()=>{this.isFocused=!0,this.options.selectAllOnFocus&&this.input.value.length>0&&(this.focusSelectTimerId!==null&&clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=window.setTimeout(()=>{this.focusSelectTimerId=null,!this.isDestroyed&&document.activeElement===this.input&&this.input.select()},0))};onBaseBlur=()=>{this.isFocused=!1,this.isPasswordInput()&&(this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask"))};initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(e=>{for(let i of e)i.type==="attributes"&&i.attributeName&&this.handleAttributeMutation(i.attributeName)});let t={attributes:!0,attributeFilter:["data-mask","data-mask-placeholder","data-mask-focus-only","data-mask-strict","data-mask-select-on-focus","data-mask-copy-raw","data-mask-pad-decimals","data-mask-auto-lowercase","data-mask-cycle-suggestions","data-mask-default-tld","data-mask-tlds","data-disabled","data-mask-align","data-align","placeholder","type"]};this.mutationObserver.observe(this.wrapper,t),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,t)}isPasswordInput(){return(this.input.type||"").toLowerCase()==="password"}computePasswordDigest(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=Math.imul(e,16777619);return`__pwd:${(e>>>0).toString(36)}:${t.length}`}setAlign(t){let e=t&&W.has(t)?t:null,i=e||void 0,n=this.wrapper.getAttribute("data-align"),s=e?this.wrapper.classList.contains(`align-${e}`):!this.wrapper.classList.contains("align-left")&&!this.wrapper.classList.contains("align-right")&&!this.wrapper.classList.contains("align-center");this.options.align===i&&n===e&&s||(this.options.align=i,this.wrapper.classList.remove("align-left","align-right","align-center"),e?(this.wrapper.classList.add(`align-${e}`),this.wasAlignSet=!0,this.wrapper.getAttribute("data-align")!==e&&this.wrapper.setAttribute("data-align",e)):this.wrapper.hasAttribute("data-align")&&this.wrapper.removeAttribute("data-align"),this.syncGhostStyles())}handleAttributeMutation(t){if(t==="data-disabled"){let e=this.hasAttr("data-disabled");e!==!!this.options.disabled&&this.setDisabled(e)}else if(t==="data-mask-focus-only"){let e=this.getAttr("data-mask-focus-only")==="true";e!==!!this.options.showMaskOnFocus&&this.setShowMaskOnFocus(e)}else if(t==="data-mask-select-on-focus")this.options.selectAllOnFocus=this.getAttr("data-mask-select-on-focus")==="true";else if(t==="data-mask-copy-raw")this.options.copyRaw=this.isPasswordInput()?!1:this.getAttr("data-mask-copy-raw")==="true";else if(t==="type")this.isPasswordInput()&&(this.options.copyRaw=!1,this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask"),this.onPasswordModeDetected());else if(t==="data-mask-align"||t==="data-align"){let e=this.getAttr("data-mask-align")||this.getAttr("data-align"),i=e&&W.has(e)?e:null;i!==(this.options.align??null)&&this.setAlign(i)}}normalizeInputType(){let t=["number","email","date","datetime-local","month","week","time","color","file","range"];if(this.input.type&&t.includes(this.input.type.toLowerCase())){let e=this.input.type.toLowerCase();this.input.type="text",e==="number"&&(this.input.inputMode="numeric")}}createGhost(){let t=this.wrapper.querySelector(".mask-ghost");t&&t.remove();let e=this.input.ownerDocument||document;this.ghost=e.createElement("div"),this.ghost.className="mask-ghost",this.ghost.setAttribute("aria-hidden","true"),this.ghost.style.display="flex",this.ghost.style.alignItems="center",this.wrapper.appendChild(this.ghost),this.wrapper.classList.add("has-ghost");let i=e.defaultView||(typeof window<"u"?window:null);(!this.wrapper.isConnected||!i||i.getComputedStyle(this.ghost).pointerEvents!=="none")&&(this.ghost.style.gridArea="1 / 1 / 2 / 2",this.ghost.style.pointerEvents="none"),this.syncGhostStyles()}setGhostContent(...t){if(this.ghost){if(typeof this.ghost.replaceChildren=="function")this.ghost.replaceChildren(...t);else{this.ghost.textContent="";for(let e of t)this.ghost.appendChild(typeof e=="string"?document.createTextNode(e):e)}this.wrapper.classList.toggle("has-visible-ghost",t.length>0)}}clearGhost(){this.setGhostContent()}syncGhostStyles(){if(!this.ghost||typeof window>"u")return;let t=window.getComputedStyle(this.input);if(!t)return;this.ghost.style.fontFamily=t.fontFamily,this.ghost.style.fontSize=t.fontSize,this.ghost.style.fontWeight=t.fontWeight,this.ghost.style.fontStyle=t.fontStyle,this.ghost.style.letterSpacing=t.letterSpacing,this.ghost.style.lineHeight=t.lineHeight,this.ghost.style.paddingTop=t.paddingTop,this.ghost.style.paddingBottom=t.paddingBottom,this.ghost.style.paddingLeft=t.paddingLeft,this.ghost.style.paddingRight=t.paddingRight,this.ghost.style.borderTopWidth=t.borderTopWidth,this.ghost.style.borderBottomWidth=t.borderBottomWidth,this.ghost.style.borderLeftWidth=t.borderLeftWidth,this.ghost.style.borderRightWidth=t.borderRightWidth,this.ghost.style.borderTopStyle=t.borderTopStyle==="none"?"none":"solid",this.ghost.style.borderBottomStyle=t.borderBottomStyle==="none"?"none":"solid",this.ghost.style.borderLeftStyle=t.borderLeftStyle==="none"?"none":"solid",this.ghost.style.borderRightStyle=t.borderRightStyle==="none"?"none":"solid",this.ghost.style.borderColor="transparent",this.ghost.style.boxSizing=t.boxSizing,this.ghost.style.textAlign=t.textAlign,this.ghost.style.direction=t.direction;let e=t.direction==="rtl"||this.input.getAttribute("dir")==="rtl"||this.wrapper.getAttribute("dir")==="rtl",i=t.textAlign;i==="right"?this.ghost.style.justifyContent="right":i==="left"?this.ghost.style.justifyContent="left":i==="center"?this.ghost.style.justifyContent="center":i==="end"?this.ghost.style.justifyContent=e?"left":"right":this.ghost.style.justifyContent=e?"right":"left"}setNativeValue(t){this.nativeValueDescriptor&&this.nativeValueDescriptor.set?this.nativeValueDescriptor.set.call(this.input,t):this.input.value=t}dispatchNativeInput(){if(!(this.isDestroyed||typeof window>"u")&&this.options.emitNativeInput!==!1){this.isDispatchingNativeInput=!0;try{let t=this.input._valueTracker;!this.isPasswordInput()&&t&&typeof t.setValue=="function"&&t.setValue(this.lastTrackedValue),this.lastTrackedValue=this.isPasswordInput()?"":this.input.value,this.input.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))}finally{this.isDispatchingNativeInput=!1}}}onScroll=()=>{this.ghost&&(this.ghost.scrollLeft=this.input.scrollLeft)};hookValueProperty(){try{let t=HTMLInputElement.prototype,e=Object.getOwnPropertyDescriptor(t,"value");if(!e||!e.set||!e.get)return;this.nativeValueDescriptor=e;let i=this;Object.defineProperty(this.input,"value",{get(){return e.get.call(this)},set(n){let s=String(n??"");e.set.call(this,s),!i.isDestroyed&&i.onNativeValueSet(s)},configurable:!0})}catch{}}unhookValueProperty(){try{delete this.input.value}catch{}}setShowMaskOnFocus(t){this.options.showMaskOnFocus=t,this.wrapper.classList.toggle("mask-focus-only",t)}disabled(t){if(t===void 0)return!!this.options.disabled;this.setDisabled(t)}setDisabled(t){this.options.disabled=!!t,this.options.disabled?this.wrapper.setAttribute("data-disabled","true"):this.wrapper.removeAttribute("data-disabled"),this.onDisabledChange(this.options.disabled)}getWrapper(){return this.wrapper}getInput(){return this.input}getGhost(){return this.ghost}getElements(){return{wrapper:this.wrapper,input:this.input,ghost:this.ghost}}getValue(){return this.input.value}getRawValue(){return this.input.value}audit(){let t=[],e=this.input.ownerDocument||document,i=typeof this.input.getRootNode=="function"?this.input.getRootNode():e,n=typeof ShadowRoot<"u"&&i instanceof ShadowRoot?i:e,s=this.input.getAttribute("aria-label")?.trim(),o=this.checkAriaIdReferences(this.input,"aria-labelledby",t),r=!!this.input.closest("label"),u=!!(this.input.labels&&this.input.labels.length>0),l=!1;if(this.input.id)try{l=!!n.querySelector(`label[for="${z(this.input.id)}"]`)}catch{l=!1}!s&&!o&&!r&&!u&&!l&&t.push(`\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`),this.checkAriaIdReferences(this.input,"aria-describedby",t);let g=this.getSpecificAuditWarnings();return t.push(...g),t}getAuditPrefix(){return`Wulf.Mask.${this.constructor.name||"InputMask"}`}getAuditTargetLabel(){return this.input.id?`#${this.input.id}`:this.input.name?`input[name="${this.input.name}"]`:"<input>"}getAuditDisableHint(){return'Passez { audit: false } ou data-mask-audit="false" pour d\xE9sactiver cet avertissement'}getSpecificAuditWarnings(){return[]}onPasswordModeDetected(){}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.focusSelectTimerId!==null&&(clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.abortController.abort(),this.lastTrackedValue="",this.unhookValueProperty(),this.ghost&&(this.ghost.remove(),this.ghost=null),this.isWrapperCreated&&this.wrapper?(this.wasWrapperFallbackStyled&&(this.input.style.gridArea="",this.input.style.boxSizing=""),this.wrapper.parentElement?$(this.wrapper.parentElement,this.input,this.wrapper):this.wrapper.parentNode&&this.wrapper.parentNode.insertBefore(this.input,this.wrapper),this.wrapper.remove()):this.wrapper&&(this.wrapper.removeAttribute("data-mask"),this.wrapper.removeAttribute("data-disabled"),this.wasAlignSet&&!this.hadInitialDataAlign&&this.wrapper.removeAttribute("data-align"),this.wasAlignSet&&this.wrapper.classList.remove("align-left","align-right","align-center"),this.wrapper.classList.remove("is-complete","is-focused","mask-focus-only","has-selection","has-ghost","has-visible-ghost")))}};var tt={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:c=>c.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:c=>c.toUpperCase()}},D=class c{pattern;patterns=[];subEngines=[];activeEngine=null;placeholderChar;tokens;slots=[];fullMaskTemplate="";prefixSlotsCount=0;prefixString="";strict=!0;autoLowercase=!1;constructor(t,e={}){let i=e||{},n=String(i.placeholderChar||"_");this.placeholderChar=Array.from(n)[0]||"_";let s=Object.create(null);for(let[o,r]of Object.entries(tt))s[o]=r;if(i.tokens&&typeof i.tokens=="object")for(let[o,r]of Object.entries(i.tokens))o!=="__proto__"&&o!=="constructor"&&o!=="prototype"&&r&&(s[o]=r);this.tokens=s,this.strict=i.strict!==!1,this.autoLowercase=i.autoLowercase??!1,this.pattern="",this.compile(t)}static format(t,e,i={}){return!e||Array.isArray(e)&&e.length===0?t??"":new c(e,i||{}).format(t??"")}compile(t){if(t!==void 0&&(Array.isArray(t)?(this.patterns=t.slice(0,32).map(n=>String(n??"").slice(0,512)),this.pattern=this.patterns[0]||""):(this.patterns=[],this.pattern=String(t??"").slice(0,512))),this.patterns.length>0)return this.subEngines=this.patterns.map(n=>new c(n,{placeholderChar:this.placeholderChar,tokens:this.tokens,strict:this.strict,autoLowercase:this.autoLowercase})),this.activeEngine=this.subEngines[0],this.slots=this.activeEngine.slots,this.fullMaskTemplate=this.activeEngine.fullMaskTemplate,this.prefixSlotsCount=this.activeEngine.prefixSlotsCount,this.prefixString=this.activeEngine.prefixString,this.slots;this.subEngines=[],this.activeEngine=null,this.slots=[];let e="",i=!0;for(let n=0;n<this.pattern.length;n++){let s=this.pattern[n],o=!1;s==="\\"&&n+1<this.pattern.length&&(o=!0,n++,s=this.pattern[n]);let r=!o&&Object.hasOwn(this.tokens,s)?this.tokens[s]:void 0;r?(i=!1,this.slots.push({char:s,isStatic:!1,isPrefix:!1,token:r,placeholder:this.placeholderChar}),e+=this.placeholderChar):(this.slots.push({char:s,isStatic:!0,isPrefix:i,placeholder:s}),e+=s)}this.fullMaskTemplate=e,this.prefixSlotsCount=0,this.prefixString="";for(let n of this.slots)if(n.isPrefix)this.prefixSlotsCount++,this.prefixString+=n.char;else break;return this.slots}selectEngine(t){if(this.subEngines.length<=1)return this;let e=String(t??""),i=this.subEngines.filter(u=>{let l=u.getPrefix();return l.length>0&&e.toLowerCase().startsWith(l.trim().toLowerCase())}),n=i.length>0?i:this.subEngines,s=n.toSorted((u,l)=>l.getEditableCount()-u.getEditableCount())[0],r=(s?s.extractRaw(e):e).length;for(let u of n)if(u.getEditableCount()>=r)return this.activeEngine=u,u;return this.activeEngine=n[n.length-1],this.activeEngine}getPrefix(){return this.activeEngine?this.activeEngine.getPrefix():this.prefixString}getPrefixLength(){return this.activeEngine?this.activeEngine.getPrefixLength():this.prefixSlotsCount}getFullMaskTemplate(){return this.activeEngine?this.activeEngine.getFullMaskTemplate():this.fullMaskTemplate}getEditableCount(){return this.subEngines.length>0?Math.max(...this.subEngines.map(t=>t.getEditableCount())):this.activeEngine?this.activeEngine.getEditableCount():this.slots.filter(t=>!t.isStatic).length}isNumericOnly(){if(this.subEngines.length>0)return this.subEngines.every(i=>i.isNumericOnly());let e=(this.activeEngine?this.activeEngine.slots:this.slots).filter(i=>!i.isStatic);return e.length===0?!1:e.every(i=>i.char==="9"||i.token&&i.token.pattern.test("0")&&!i.token.pattern.test("a")&&!i.token.pattern.test("Z"))}setStrict(t){this.strict=t;for(let e of this.subEngines)e.setStrict(t)}setAutoLowercase(t){this.autoLowercase=t;for(let e of this.subEngines)e.setAutoLowercase(t)}isStrict(){return this.strict}extractRaw(t){if(this.subEngines.length>0){let r=this.selectEngine(t);if(r!==this)return r.extractRaw(t)}let e=Math.max(4096,this.slots.length*4),i=String(t??"").slice(0,e);if(!i)return"";let n="",s=0,o=0;if(this.prefixSlotsCount>0){for(;s<i.length&&(i[s]===" "||i[s]===" ");)s++;let r=0;for(;s<i.length&&r<this.prefixSlotsCount;){let u=this.slots[r].char,l=i[s];if(l.toUpperCase()===u.toUpperCase())s++,r++;else if(u===" "&&l!==" ")r++;else break}o=this.prefixSlotsCount}for(;s<i.length&&o<this.slots.length;){let r=this.slots[o],u=i[s];if(r.isStatic)u.toUpperCase()===r.char.toUpperCase()&&s++,o++;else if(r.token&&r.token.pattern.test(u)){let l=r.token.transform?r.token.transform(u):u;this.autoLowercase&&!r.token.transform&&(l=l.toLowerCase()),n+=l,s++,o++}else this.strict?s++:(n+=this.autoLowercase?u.toLowerCase():u,s++,o++)}if(!this.strict&&s<i.length){let r=i.slice(s);n+=this.autoLowercase?r.toLowerCase():r}return n}format(t){if(this.subEngines.length>0){let r=this.selectEngine(t);if(r!==this)return r.format(t)}let e=Math.max(4096,this.slots.length*4),i=String(t??"").slice(0,e);if(!this.slots.length)return i;let n=this.extractRaw(i);if(n.length===0)return this.prefixString;let s="",o=0;for(let r=0;r<this.slots.length;r++){let u=this.slots[r];if(u.isStatic){let l=o<n.length,g=o===0&&!!u.isPrefix,f=o>0&&o===n.length;if(l||g||f)s+=u.char;else break}else if(o<n.length){let l=n[o],g=u.token?.transform?u.token.transform(l):l;this.autoLowercase&&!u.token?.transform&&(g=g.toLowerCase()),s+=g,o++}else break}if(!this.strict&&o<n.length){let r=n.substring(o);s+=this.autoLowercase?r.toLowerCase():r}return s}getRemainingMask(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getRemainingMask(t):this.fullMaskTemplate?t.length>=this.fullMaskTemplate.length?t:t+this.fullMaskTemplate.substring(t.length):""}mapCursorPosition(t,e,i){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.mapCursorPosition(t,e,i);let n=this.prefixSlotsCount,s=String(t??""),o=String(i??"");if(e<=0||!o)return n;let u=this.extractRaw(s.slice(0,e)).length;if(u===0)return Math.max(n,Math.min(this.getNextEditablePosition(0),o.length));let l=0,g=o.length;for(let f=0;f<o.length&&f<this.slots.length;f++)if(!this.slots[f].isStatic&&(l++,l===u)){g=f+1;break}for(;g<o.length&&this.slots[g]&&this.slots[g].isStatic;)g++;return Math.max(n,Math.min(g,o.length))}isSeparatorAt(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.isSeparatorAt(t):t>=0&&t<this.slots.length?this.slots[t].isStatic:!1}getNextEditablePosition(t){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.getNextEditablePosition(t);let e=Math.max(0,t);for(let i=e;i<this.slots.length;i++)if(!this.slots[i].isStatic)return i;return this.slots.length}getSlotAt(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlotAt(t):this.slots[t]}getSlots(){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlots():this.slots}};var I=class{stack=[];index=-1;maxDepth;constructor(t=50){this.maxDepth=t}push(t,e){let i=this.getCurrent();if(i&&i.raw===t){i.cursor=e;return}this.stack=this.stack.slice(0,this.index+1),this.stack.push({raw:t,cursor:e}),this.stack.length>this.maxDepth&&this.stack.shift(),this.index=this.stack.length-1}updateCurrentCursor(t){let e=this.getCurrent();e&&(e.cursor=t)}undo(){return this.canUndo()?(this.index--,this.stack[this.index]):null}redo(){return this.canRedo()?(this.index++,this.stack[this.index]):null}canUndo(){return this.index>0}canRedo(){return this.index>=0&&this.index<this.stack.length-1}getCurrent(){return this.index>=0&&this.index<this.stack.length?this.stack[this.index]:null}clear(){this.stack=[],this.index=-1}};var O=class{delegate;constructor(t){this.delegate=t}handleKeyDown(t){if(H(t))return;let e=this.delegate.getInput(),i=this.delegate.getEngine(),n=this.delegate.getHistory(),s=i.getPrefixLength(),o=e.selectionStart??0,r=e.selectionEnd??o;if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")&&!t.shiftKey){t.preventDefault(),this.delegate.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")||(t.ctrlKey||t.metaKey)&&t.shiftKey&&(t.key==="z"||t.key==="Z")){t.preventDefault(),this.delegate.redo();return}n.updateCurrentCursor(o);let u=t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey,l=r>o;if(u&&!l){let a=i.getSlots(),h=o<a.length&&a[o].isStatic&&a[o].char===t.key,p=o>0&&o-1<a.length&&a[o-1].isStatic&&a[o-1].char===t.key;if(h||p){t.preventDefault();let d=h?o:o-1,b=i.getNextEditablePosition(d+1);this.delegate.applyMask(e.value,b,!0);return}let m=-1;for(let d=o;d<a.length;d++)if(a[d].isStatic){a[d].char===t.key&&(m=d);break}if(m!==-1){t.preventDefault();let d=m-1;for(;d>=s&&!a[d].isStatic;)d--;d++;let b=m-d,w=e.value.slice(d,o);if(a.slice(d,m).every(v=>!v.token||v.token.pattern.test("0"))&&b>w.length&&w.length>0){let v=b-w.length,M="0".repeat(v)+w,P=e.value.slice(m),T=e.value.slice(0,d)+M+P,y=i.getNextEditablePosition(m+1);this.delegate.applyMask(T,y,!0);return}let S=i.getNextEditablePosition(m+1);this.delegate.applyMask(e.value,S,!0);return}}if(u&&i.isStrict()){let a=i.getEditableCount();if(a>0){let h=i.extractRaw(e.value),p=a-h.length;if(r>o){let m=i.extractRaw(e.value.slice(o,r));p=a-(h.length-m.length)}if(p<=0){t.preventDefault();return}}}if(r>o){if(t.key==="Backspace"||t.key==="Delete"){t.preventDefault();let a=e.value,h=a.slice(0,o)+a.slice(r);this.delegate.applyMask(h,Math.max(s,o));return}return}if(t.key==="ArrowLeft"&&!t.shiftKey&&o<=s){t.preventDefault(),e.setSelectionRange(s,s);return}if(t.key==="Home"&&s>0&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey){t.preventDefault(),e.setSelectionRange(s,s);return}if(t.key==="Backspace"&&o<=s){t.preventDefault(),e.setSelectionRange(s,s);return}if(t.key==="Delete"&&o<s){t.preventDefault(),e.setSelectionRange(s,s);return}if(t.key==="Backspace"&&(t.ctrlKey||t.altKey||t.metaKey)){if(t.preventDefault(),o<=s){e.setSelectionRange(s,s);return}let a=o-1;for(;a>=s&&i.isSeparatorAt(a);)a--;for(;a>=s&&!i.isSeparatorAt(a);)a--;let h=Math.max(s,a+1),p=e.value,m=p.slice(0,h)+p.slice(o);this.delegate.applyMask(m,h);return}if(t.key==="Delete"&&(t.ctrlKey||t.altKey||t.metaKey)){t.preventDefault();let a=e.value;if(o>=a.length)return;let h=o;for(;h<a.length&&i.isSeparatorAt(h);)h++;for(;h<a.length&&!i.isSeparatorAt(h);)h++;for(;h<a.length&&i.isSeparatorAt(h);)h++;let p=h,m=a.slice(0,o)+a.slice(p);this.delegate.applyMask(m,o);return}if(t.key==="Backspace"&&o>s){if(i.isSeparatorAt(o-1)){t.preventDefault();let a=o-1;for(;a>s&&i.isSeparatorAt(a-1);)a--;if(a>s){let h=e.value,p=h.slice(0,a-1)+h.slice(o);this.delegate.applyMask(p,a-1)}else this.delegate.applyMask("",s)}return}if(t.key==="Delete"&&o<e.value.length){if(i.isSeparatorAt(o)){t.preventDefault();let a=o;for(;a<e.value.length&&i.isSeparatorAt(a);)a++;if(a<e.value.length){let h=e.value,p=h.slice(0,a)+h.slice(a+1);this.delegate.applyMask(p,o)}}return}}handleKeyUp(t){let e=this.delegate.getInput(),i=this.delegate.getHistory();(t.key==="ArrowLeft"||t.key==="ArrowRight"||t.key==="Home")&&!t.shiftKey&&this.delegate.enforceMinCursor(),i.updateCurrentCursor(e.selectionStart??0)}};var V=class extends E{engine;history;keyboard;isComposing=!1;isUndoingRedoing=!1;isMouseDown=!1;isApplyingMask=!1;lastValue="";lastInternalRemainingMask="";isNotifying=!1;hasPendingNotification=!1;onChangeNativeHandler=()=>{};wasInputModeInferred=!1;cutTimerId=null;pasteTimerId=null;resetTimerId=null;constructor(t,e,i){let n=C(t,e,i),s=n.wrapper,o=n.input,r=n.options,u=s?.getAttribute("data-mask")||o?.getAttribute("data-mask"),l=r.mask||u||"";typeof l=="string"&&l.includes("|")&&(l=l.split("|").map(S=>S.trim()));let g=r.placeholderChar||s?.getAttribute("data-mask-placeholder")||o?.getAttribute("data-mask-placeholder")||"_",f=s?.hasAttribute("data-disabled")||o?.hasAttribute("data-disabled"),a=s?.getAttribute("data-mask-strict")||o?.getAttribute("data-mask-strict"),h=s?.getAttribute("data-mask-auto-lowercase")==="true"||o?.getAttribute("data-mask-auto-lowercase")==="true",p=s?.getAttribute("data-mask-infer-inputmode")??o?.getAttribute("data-mask-infer-inputmode"),m=r.inferInputMode??(p!==null?p!=="false":!0),{disabled:d,...b}=r,w=d!==void 0?d:f?!0:!l||Array.isArray(l)&&l.length===0,k={...b,mask:l,placeholderChar:g,strict:r.strict??(a!==null?a!=="false":!0),autoLowercase:r.autoLowercase??h??!1,disabled:w,resetHistoryOnMaskChange:r.resetHistoryOnMaskChange??!1,inferInputMode:m,onInput:r.onInput||r.oninput,onChange:r.onChange||r.onchange,onComplete:r.onComplete||r.oncomplete};super(s,o,k),this.history=new I,this.engine=new D(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new O({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(S,v,M)=>this.applyMask(S,v,M),undo:()=>this.undo(),redo:()=>this.redo(),enforceMinCursor:()=>this.enforceMinCursor()}),this.bindEvents(),this.lastValue=this.isPasswordInput()?this.computePasswordDigest(this.input.value):this.input.value,this.syncInitialValue(),this.runAuditWarning(this.options.audit)}getSpecificAuditWarnings(){let t=[],e=[],i=this.checkAriaIdReferences(this.input,"aria-describedby",e),n=!!this.input.getAttribute("placeholder")?.trim(),s=!!this.input.getAttribute("aria-placeholder")?.trim();return!i&&!n&&!s&&!this.options.disabled&&t.push("Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."),t}extractRawSnippet(t){return this.engine.extractRaw(t)}onPasswordModeDetected(){this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask")}static format(t,e,i={}){return D.format(t,e,i)}onNativeValueSet(t){this.options.disabled?this.checkValueChange():this.applyMask(t,t.length)}onDisabledChange(t){t?(this.wrapper.removeAttribute("data-mask"),this.wrapper.classList.remove("is-complete","has-selection"),this.clearGhost(),this.checkValueChange()):this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length),this.syncInferredInputMode()}bindEvents(){this.handleInput=this.handleInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onClick=this.onClick.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onSelect=this.onSelect.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onScroll=this.onScroll.bind(this),this.onBeforeInput=this.onBeforeInput.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,!this.isDestroyed)if(this.options.disabled)this.checkValueChange();else{let e=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,e)}},0)},this.onChangeNativeHandler=()=>{this.isDestroyed||this.checkValueChange()};let{signal:t}=this.abortController;this.input.addEventListener("beforeinput",this.onBeforeInput,{signal:t}),this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.onKeyDown,{signal:t}),this.input.addEventListener("paste",this.onPaste,{signal:t}),this.input.addEventListener("focus",this.onFocus,{signal:t}),this.input.addEventListener("blur",this.onBlur,{signal:t}),this.input.addEventListener("click",this.onClick,{signal:t}),this.input.addEventListener("keyup",this.onKeyUp,{signal:t}),this.input.addEventListener("select",this.onSelect,{signal:t}),this.input.addEventListener("mousedown",this.onMouseDown,{signal:t}),window.addEventListener("mouseup",this.onMouseUp,{signal:t}),this.input.addEventListener("compositionstart",this.onCompositionStart,{signal:t}),this.input.addEventListener("compositionend",this.onCompositionEnd,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("change",this.onChangeNativeHandler,{signal:t}),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled?this.checkValueChange():this.syncInitialValue())},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:t}))}syncInferredInputMode(){if(!this.options.inferInputMode)return;!this.options.disabled&&this.engine.isNumericOnly()?this.input.hasAttribute("inputmode")||(this.input.inputMode="numeric",this.wasInputModeInferred=!0):this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&(this.input.removeAttribute("inputmode"),this.wasInputModeInferred=!1)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.pasteTimerId!==null&&(clearTimeout(this.pasteTimerId),this.pasteTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&this.input.removeAttribute("inputmode"),this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",super.destroy())}setStrict(t){this.options.strict=t,this.engine.setStrict(t),this.options.disabled||this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}isStrict(){return this.engine.isStrict()}setMask(t,e){let i=typeof e=="boolean"?e:e&&typeof e=="object"&&e.strict!==void 0?e.strict:this.options.strict,n=e&&typeof e=="object"&&e.resetHistory!==void 0?e.resetHistory:!!this.options.resetHistoryOnMaskChange;if(!((!t||Array.isArray(t)&&t.length===0)&&this.options.disabled&&(!this.options.mask||this.options.mask===""))){if(!t||Array.isArray(t)&&t.length===0){this.options.mask="",this.options.strict=i,this.engine.setStrict(i??!0),this.engine.compile(""),n&&this.history.clear(),this.setDisabled(!0),this.syncInferredInputMode();return}this.options.mask=t,this.options.strict=i,this.engine.setStrict(i??!0),this.engine.compile(t),n&&this.history.clear(),this.setDisabled(!1),this.syncInferredInputMode()}}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask"){let e=this.getAttr("data-mask");if(e===this.lastInternalRemainingMask)return;let i=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(e===i)return;if(e){let n=e.includes("|")?e.split("|").map(s=>s.trim()):e;this.setMask(n)}else this.setMask(null)}else if(t==="data-mask-strict"){let e=this.getAttr("data-mask-strict");this.setStrict(e!=="false")}else t==="data-mask-auto-lowercase"?(this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true",this.engine.setAutoLowercase(this.options.autoLowercase),this.engine.compile(this.options.mask||""),this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)):t==="placeholder"&&this.updateGhost(this.input.value)}setValue(t){let e=t!=null?String(t):"";if(this.options.disabled){this.input.value=e,this.checkValueChange();return}this.applyMask(e,e.length)}getRawValue(){return this.engine.extractRaw(this.input.value)}isComplete(){return this.options.disabled?!0:this.getRawValue().length>=this.engine.getEditableCount()}get onInput(){return this.options.onInput}set onInput(t){this.options.onInput=t}undo(){if(this.options.disabled)return;let t=this.history.undo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}redo(){if(this.options.disabled)return;let t=this.history.redo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}checkSelection(){if(this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,i=t!==e;this.wrapper.classList.toggle("has-selection",i)}onBeforeInput(t){if(!this.options.disabled&&!this.isComposing&&this.engine.isStrict()&&!(t.inputType==="insertFromPaste"||t.inputType==="insertReplacementText")&&t.inputType&&t.inputType.startsWith("insert")){let e=this.engine.getEditableCount();if(e>0){let i=this.getRawValue(),n=this.input.selectionStart??0,s=this.input.selectionEnd??n,o=Math.max(0,e-i.length);if(s>n){let r=this.engine.extractRaw(this.input.value.slice(n,s));o=Math.max(0,e-(i.length-r.length))}o<=0&&t.preventDefault()}}}handleInput(t){if(this.isDispatchingNativeInput||this.isComposing)return;let e=!!(this.options.onInput||this.options.oninput),i=this.isPasswordInput()?this.computePasswordDigest(this.input.value):this.input.value;if(e&&i!==this.lastValue&&this.checkValueChange(),this.options.disabled){this.checkValueChange();return}let n=this.history.getCurrent(),s=this.engine.getEditableCount();if(s>0&&this.engine.isStrict()&&n&&n.raw.length>=s&&this.engine.extractRaw(this.input.value).length>s){this.applyMask(n.raw,n.cursor);return}let o=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,o),this.checkSelection()}onKeyDown(t){this.options.disabled||this.keyboard.handleKeyDown(t)}onMouseDown(){this.isMouseDown=!0}onMouseUp(){this.isMouseDown=!1,this.checkSelection()}onPaste(t){if(this.options.disabled){this.pasteTimerId!==null&&clearTimeout(this.pasteTimerId),this.pasteTimerId=window.setTimeout(()=>{this.pasteTimerId=null,this.isDestroyed||this.checkValueChange()},0);return}t.preventDefault(),this.history.updateCurrentCursor(this.input.selectionStart??0);let i=(t.clipboardData?.getData("text")||"").slice(0,4096).trim();if(!i)return;let n=this.engine.getPrefixLength(),s=this.input.selectionStart??0,o=this.input.selectionEnd??s,r=this.input.value,u=this.engine.getEditableCount(),l=this.getRawValue(),f=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),a=i.replace(/[\s.-]+/g,"").toUpperCase(),h=f.length>0&&a.startsWith(f),p=r.slice(0,Math.max(n,s)).replace(/[\s.-]+/g,"").toUpperCase(),m=p.length>=2&&a.startsWith(p),d=Math.max(n,s),b=Math.max(n,o);(h||m)&&(d=0,b=r.length);let w=Math.max(0,u-l.length);if(d!==b){let v=this.engine.extractRaw(r.slice(d,b));w=Math.max(0,u-(l.length-v.length))}if(this.engine.isStrict()&&w<=0)return;let k,S;d===0&&b===r.length?(k=i,S=i.length):(k=r.slice(0,d)+i+r.slice(b),S=d+i.length),this.applyMask(k,S),this.checkSelection()}onFocus(){this.syncGhostStyles(),this.wrapper.classList.add("is-focused"),!this.options.disabled&&!this.isMouseDown&&this.enforceMinCursor(),this.updateGhost(this.input.value),this.checkSelection()}onBlur(){if(this.wrapper.classList.remove("is-focused","has-selection"),this.isPasswordInput()){this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask");return}this.updateGhost(this.input.value)}onClick(){this.options.disabled||this.enforceMinCursor(),this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onKeyUp(t){this.options.disabled||this.keyboard.handleKeyUp(t),this.checkSelection()}onSelect(){this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t),this.checkSelection()}enforceMinCursor(){let t=this.engine.getPrefixLength();if(t<=0)return;let e=this.input.selectionStart??0,i=this.input.selectionEnd??e;e===i&&e<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled||this.isPasswordInput()){this.clearGhost();return}let e=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(e)){this.clearGhost();return}let i=this.engine.getFullMaskTemplate(),n=i.length>t.length?i.substring(t.length):"",s=this.input.ownerDocument||document,o=s.createElement("span");o.className="mask-ghost-typed",o.textContent=t;let r=s.createElement("span");r.className="mask-ghost-remaining",r.textContent=n,this.setGhostContent(o,r),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,i=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let n="",s=!1;try{n=this.engine.format(t);let o=this.engine.getRemainingMask(n),r=this.isPasswordInput();this.input.value=n,r?(this.lastInternalRemainingMask="",this.wrapper.removeAttribute("data-mask"),this.clearGhost()):(this.lastInternalRemainingMask=o,this.wrapper.setAttribute("data-mask",o),this.updateGhost(n));let u=this.engine.getPrefixLength(),l;if(i||this.isUndoingRedoing)l=Math.max(u,Math.min(e,n.length));else{let g=this.engine.mapCursorPosition(t,e,n);l=Math.max(u,g)}this.input.setSelectionRange(l,l),s=this.isComplete(),this.wrapper.classList.toggle("is-complete",s),r?(this.options.copyRaw=!1,this.history.clear()):this.isUndoingRedoing||this.history.push(this.getRawValue(),l)}finally{this.isApplyingMask=!1}this.checkValueChange()}syncInitialValue(){let t=this.isPasswordInput();if(this.options.disabled){this.wrapper.removeAttribute("data-mask"),this.clearGhost(),this.lastValue=t?this.computePasswordDigest(this.input.value):this.input.value,this.checkValueChange();return}this.syncGhostStyles();let e=this.input.value||"";if(e)this.applyMask(e,e.length);else{let i=this.engine.getPrefixLength();if(i>0)this.applyMask("",i);else{if(t)this.lastInternalRemainingMask="",this.wrapper.removeAttribute("data-mask"),this.clearGhost();else{this.history.push("",0);let n=this.engine.getFullMaskTemplate();this.lastInternalRemainingMask=n,this.wrapper.setAttribute("data-mask",n),this.updateGhost("")}this.checkValueChange()}}}checkValueChange(t=!1){let e=this.isPasswordInput(),i=this.input.value;if(!((e?this.computePasswordDigest(i):i)===this.lastValue&&!t&&!this.hasPendingNotification)){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{let s=0,o=10;for(;((e?this.computePasswordDigest(this.input.value):this.input.value)!==this.lastValue||this.hasPendingNotification||t)&&s<o;){s++,this.hasPendingNotification=!1,t=!1;let r=this.input.value;this.lastValue=e?this.computePasswordDigest(r):r;let u=this.options.disabled?r:this.getRawValue(),l=this.options.disabled?0:this.engine.getEditableCount(),g=this.isComplete(),f={value:r,rawValue:u,isComplete:g,totalSlots:l,filledSlots:this.options.disabled?r.length:u.length},a=this.options.onInput||this.options.oninput;a&&a(r,f),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:f})),this.dispatchNativeInput();let h=this.options.onChange||this.options.onchange;h&&h(f),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:f}));let p=this.options.onComplete||this.options.oncomplete;g&&(p&&p(f),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:f})))}}finally{this.isNotifying=!1}}}};var x=class c{options;constructor(t={}){let e=t.currency??"";!e&&t.unit&&(e=t.unit);let i=e==="$"||e==="\xA3"||e==="\xA5"?"prefix":"suffix",n=t.decimals!==void 0?Number(t.decimals):2,s=Number.isFinite(n)?Math.min(20,Math.max(0,Math.floor(n))):2;this.options={currency:String(e).slice(0,32),unit:String(t.unit??e).slice(0,32),currencyPosition:t.currencyPosition??i,decimals:s,decimalSeparator:String(t.decimalSeparator??",").slice(0,4)||",",thousandSeparator:String(t.thousandSeparator??"\xA0").slice(0,4),allowNegative:t.allowNegative??!1,min:t.min??-1/0,max:t.max??1/0}}parse(t){let e=String(t??"").slice(0,512).trim(),i=!1;this.options.allowNegative&&e.includes("-")&&(i=!0),this.options.currency&&(e=e.replace(new RegExp(this.escapeRegExp(this.options.currency),"g"),"")),this.options.thousandSeparator&&(e=e.replace(new RegExp(this.escapeRegExp(this.options.thousandSeparator),"g"),"")),e=e.replace(/[\s\u00A0]/g,"");let n=this.options.decimalSeparator,s=e.indexOf(n);s===-1&&(s=e.search(/[,.]/));let o="",r=null,u=!1;return s!==-1?(o=e.substring(0,s).replace(/\D/g,""),this.options.decimals>0&&(u=!0,r=e.substring(s+1).replace(/\D/g,"").slice(0,this.options.decimals))):o=e.replace(/\D/g,""),o.length>1&&(o=o.replace(/^0+/,"")||"0"),{isNegative:i,integerPart:o,decimalPart:r,hasDecimal:u}}format(t,e=t.length,i=!1){let n=String(t??"").slice(0,512),s=Math.max(0,Math.min(e,n.length));if(!n||n.trim()===""||n===this.options.currency.trim())return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let o=n.substring(0,s),r=o.replace(/\D/g,"").length,u=this.options.decimals>0&&/[,.]/.test(o),{isNegative:l,integerPart:g,decimalPart:f,hasDecimal:a}=this.parse(n),h=f,p=a;if(i&&this.options.decimals>0&&(g||f!==null)&&(p=!0,h===null?h="0".repeat(this.options.decimals):h.length<this.options.decimals&&(h=h+"0".repeat(this.options.decimals-h.length))),l&&!g&&!h&&!p&&this.options.allowNegative){let A="-",L=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(A=`${this.options.currency} -`,L=A.length):(A=`- ${this.options.currency}`,L=1)),{formatted:A,rawNumber:null,rawValue:"-",cursor:L,isValid:!0}}if(!g&&!h&&!p)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let d=this.formatThousands(g||"0");p&&this.options.decimals>0&&(d+=this.options.decimalSeparator+(h??"")),l&&d!=="0"&&(d="-"+d);let b=d;this.options.currency&&(this.options.currencyPosition==="prefix"?b=`${this.options.currency} ${d}`:b=`${d} ${this.options.currency}`);let w=(l?"-":"")+(g||"0")+(f?"."+f:""),k=parseFloat(w);isNaN(k)&&(k=0);let S=k>=this.options.min&&k<=this.options.max,v=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(v=this.options.currency.length+1);let M=0,P=!1,T=v;for(let A=v;A<b.length;A++){let L=b[A];if(L===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(L)?(M++,T=A+1):L===this.options.decimalSeparator&&(P=!0,T=A+1),u){if(P&&M>=r){v=A+1;break}}else if(M>=r){v=A+1;break}}r>0&&M<r&&T>v&&(v=T);let y=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,F=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,b.length-this.options.currency.length-1):b.length;return v=Math.max(y,Math.min(v,Math.max(y,F))),{formatted:b,rawNumber:k,rawValue:w,cursor:v,isValid:S}}static format(t,e={}){let i=new c(e),n=typeof t=="number"?t.toString():t;return i.format(n).formatted}formatThousands(t){let e=this.options.thousandSeparator;if(!e||t.length<=3)return t;let i=[],n=t.length;for(;n>0;){let s=Math.max(0,n-3);i.push(t.slice(s,n)),n=s}return i.reverse().join(e)}escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var N=class extends E{engine;history;isUndoingRedoing=!1;isApplying=!1;isComposing=!1;lastValue="";wasInputModeInferred=!1;cutTimerId=null;resetTimerId=null;cursorTimerId=null;constructor(t,e,i){let n=C(t,e,i),s=n.wrapper,o=n.input,r=n.options,u=s?.getAttribute("data-mask-pad-decimals")==="true"||o?.getAttribute("data-mask-pad-decimals")==="true",l=o?.getAttribute("data-mask-align")||o?.getAttribute("data-align")||s?.getAttribute("data-mask-align")||s?.getAttribute("data-align"),g={align:r.align??l??"right",padDecimalsOnBlur:r.padDecimalsOnBlur??u??!1,...r};super(s,o,g),this.input.hasAttribute("inputmode")||(this.input.inputMode="decimal",this.wasInputModeInferred=!0),this.history=new I,this.engine=new x(this.options),this.bindEvents(),this.input.value?this.options.disabled||this.applyAmount(this.input.value,this.input.value.length):this.updateGhost({formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0}),this.runAuditWarning(this.options.audit)}extractRawSnippet(t){let e=this.engine.parse(t);return!e.integerPart&&!e.decimalPart?"":(e.isNegative?"-":"")+(e.integerPart||"0")+(e.decimalPart?"."+e.decimalPart:"")}onPasswordModeDetected(){this.history.clear(),this.lastValue="",this.lastTrackedValue="",this.clearGhost()}static format(t,e={}){return x.format(t,e)}onNativeValueSet(t){if(this.options.disabled||this.isComposing){this.lastValue=t;return}this.applyAmount(t,t.length)}onDisabledChange(t){t?this.clearGhost():this.applyAmount(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleClick=this.handleClick.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,this.isDestroyed||this.options.disabled)return;let e=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,e)},0)};let{signal:t}=this.abortController;this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.handleKeyDown,{signal:t}),this.input.addEventListener("blur",this.handleBlur,{signal:t}),this.input.addEventListener("focus",this.handleFocus,{signal:t}),this.input.addEventListener("click",this.handleClick,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("compositionstart",this.onCompositionStart,{signal:t}),this.input.addEventListener("compositionend",this.onCompositionEnd,{signal:t}),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled||this.applyAmount(this.input.value,this.input.value.length))},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:t}))}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)}applyAmount(t,e){if(!(this.isApplying||this.options.disabled)){this.isApplying=!0;try{let i=this.engine.format(t,e);this.setNativeValue(i.formatted),this.input.setSelectionRange(i.cursor,i.cursor);let n=this.isPasswordInput();n?(this.options.copyRaw=!1,this.history.clear(),this.clearGhost()):(this.isUndoingRedoing||this.history.push(i.rawValue,i.cursor),this.updateGhost(i));let s=n?this.computePasswordDigest(i.formatted):i.formatted;this.lastValue!==s&&(this.lastValue=s,this.notifyChange(i))}finally{this.isApplying=!1}}}updateGhost(t){if(this.ghost){if(!t.formatted){if(this.shouldHideGhostForPlaceholder(!0)){this.clearGhost();return}let e=this.options.currency?this.options.currencyPosition==="prefix"?`${this.options.currency} 0`:`0 ${this.options.currency}`:"0,00",n=(this.input.ownerDocument||document).createElement("span");n.className="mask-ghost-remaining",n.textContent=e,this.setGhostContent(n);return}this.clearGhost(),this.ghost.scrollLeft=this.input.scrollLeft}}handleInput(){if(this.isDispatchingNativeInput||this.options.disabled||this.isComposing)return;let t=this.input.value,e=this.input.selectionStart??t.length;this.applyAmount(t,e)}handleKeyDown(t){if(!(this.options.disabled||H(t))){if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")){t.preventDefault(),t.shiftKey?this.redo():this.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")){t.preventDefault(),this.redo();return}if(t.key==="Backspace"){let e=this.input.selectionStart??0,i=this.input.selectionEnd??0;if(e===i&&e>0){let n=this.input.value,s=n[e-1];if(s===this.engine.options.thousandSeparator||s===" "){t.preventDefault();let o=Math.max(0,e-2),r=n.slice(0,o)+n.slice(e);this.applyAmount(r,o);return}if(this.options.currency&&this.options.currencyPosition==="prefix"&&e<=this.options.currency.length+1){t.preventDefault();return}}}if(t.key==="Delete"){let e=this.input.selectionStart??0,i=this.input.selectionEnd??0;if(e===i&&e<this.input.value.length){let n=this.input.value,s=n[e];if(s===this.engine.options.thousandSeparator||s===" "){t.preventDefault();let o=n.slice(0,e)+n.slice(e+2);this.applyAmount(o,e);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let o=n.length-this.options.currency.length-1;if(e>=o){t.preventDefault();return}}}}(t.key==="ArrowLeft"||t.key==="ArrowRight"||t.key==="Home"||t.key==="End")&&(this.cursorTimerId!==null&&clearTimeout(this.cursorTimerId),this.cursorTimerId=window.setTimeout(()=>{this.cursorTimerId=null,this.enforceCursorBounds()},0))}}enforceCursorBounds(){if(this.isDestroyed||!this.isFocused||document.activeElement!==this.input||!this.input.value||this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??0;if(t!==e)return;let i=this.input.value,n=this.options.currency;if(n){if(this.options.currencyPosition==="prefix"){let s=n.length+1;t<s&&this.input.setSelectionRange(s,s)}else if(this.options.currencyPosition==="suffix"){let s=Math.max(0,i.length-n.length-1);t>s&&this.input.setSelectionRange(s,s)}}}handleClick(){this.enforceCursorBounds()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.enforceCursorBounds(),this.updateGhost(this.engine.format(this.input.value))}handleBlur(){if(this.wrapper.classList.remove("is-focused"),this.isPasswordInput()){this.history.clear(),this.lastValue="",this.lastTrackedValue="",this.clearGhost();return}if(this.options.padDecimalsOnBlur&&!this.options.disabled&&this.input.value.trim().length>0){let e=this.engine.format(this.input.value,this.input.value.length,!0);e.formatted!==this.input.value&&(this.setNativeValue(e.formatted),this.lastValue=e.formatted)}this.updateGhost(this.engine.format(this.input.value));let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){super.handleAttributeMutation(t),t==="data-mask-pad-decimals"?this.options.padDecimalsOnBlur=this.getAttr("data-mask-pad-decimals")==="true":t==="placeholder"&&this.updateGhost(this.engine.format(this.input.value))}notifyChange(t){let e={value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid};this.options.onInput&&this.options.onInput(e),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:e})),this.dispatchNativeInput()}undo(){let t=this.history.undo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}redo(){let t=this.history.redo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}getDetail(){let t=this.engine.format(this.input.value);return{value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid}}getNumber(){return this.getDetail().number}getRawValue(){return this.getDetail().rawValue}isValid(){return this.getDetail().isValid}setValue(t){let e=t!=null?String(t):"";this.options.disabled?(this.setNativeValue(e),this.lastValue=e):this.applyAmount(e,e.length)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.cursorTimerId!==null&&(clearTimeout(this.cursorTimerId),this.cursorTimerId=null),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="decimal"&&this.input.removeAttribute("inputmode"),this.lastValue="",this.history.clear(),super.destroy())}};var R=class c{domains;tlds;suggestOnAt;defaultDomain=null;defaultTld="__";static DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"];static DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];constructor(t={}){this.domains=t.domains&&t.domains.length>0?t.domains:c.DEFAULT_DOMAINS,this.tlds=t.tlds&&t.tlds.length>0?t.tlds.slice(0,200).map(e=>String(e).trim().replace(/^\./,"").slice(0,32)).filter(Boolean):[...c.DEFAULT_TLDS],this.suggestOnAt=t.suggestOnAt??!0,this.setDefaultDomain(t.defaultDomain??null),this.setDefaultTld(t.defaultTld!==void 0?t.defaultTld:"__")}setDefaultDomain(t){t===!0?this.defaultDomain=this.domains.length>0?this.domains[0]:null:typeof t=="string"&&t.trim().length>0?this.defaultDomain=t.trim().replace(/^@/,""):this.defaultDomain=null}setDefaultTld(t){t===!0?this.defaultTld=this.tlds.length>0?this.tlds[0]:null:typeof t=="string"&&t.trim().length>0?this.defaultTld=t.trim().replace(/^\./,""):this.defaultTld=null}setTlds(t){this.tlds=t&&t.length>0?t.slice(0,200).map(e=>String(e).trim().replace(/^\./,"").slice(0,32)).filter(Boolean):[...c.DEFAULT_TLDS]}getMatchingTlds(t){let e=(t??"").toLowerCase();return e.length===0?[...this.tlds]:this.tlds.filter(i=>i.toLowerCase().startsWith(e)&&i.toLowerCase()!==e)}getMatchingDomains(t){let e=String(t??"").slice(0,512);if(!e.includes("@"))return this.defaultDomain?[this.defaultDomain]:[];let i=e.indexOf("@");if(e.indexOf("@",i+1)!==-1)return[];let n=e.substring(i+1);if(n.length===0)return this.suggestOnAt?[...this.domains]:[];let s=n.toLowerCase();return this.domains.filter(o=>o.toLowerCase().startsWith(s)&&o.toLowerCase()!==s)}getSuggestion(t,e=0){let i=String(t??"").slice(0,512);if(!i.includes("@"))return this.defaultDomain?{full:i?`${i}@${this.defaultDomain}`:`@${this.defaultDomain}`,remaining:`@${this.defaultDomain}`,matchedDomain:this.defaultDomain,isHintOnly:!1}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let n=i.indexOf("@"),s=i.substring(0,n),o=i.substring(n+1);if(i.indexOf("@",n+1)!==-1)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let r=this.getMatchingDomains(t);if(r.length>0){let p=(e%r.length+r.length)%r.length,m=r[p],d=o.toLowerCase(),b=m.substring(d.length);return{full:`${s}@${m}`,remaining:b,matchedDomain:m,isHintOnly:!1}}if(o.length===0||o.startsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let u=o.toLowerCase();if(this.domains.some(p=>p.toLowerCase()===u))return{full:i,remaining:"",matchedDomain:o,isHintOnly:!1};let l=o.lastIndexOf(".");if(l===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let p=this.defaultTld.includes("_"),m=`.${this.defaultTld}`,d=`${o}.${this.defaultTld}`;return{full:p?i:`${s}@${d}`,remaining:m,matchedDomain:p?null:d,isHintOnly:p}}let g=o.substring(0,l),f=o.substring(l+1);if(!g||g.endsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};if(f.length===0){if(this.defaultTld&&!this.defaultTld.includes("_")){let p=`${g}.${this.defaultTld}`;return{full:`${s}@${p}`,remaining:this.defaultTld,matchedDomain:p,isHintOnly:!1}}return this.defaultTld&&this.defaultTld.includes("_")?{full:i,remaining:this.defaultTld,matchedDomain:null,isHintOnly:!0}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}let a=f.toLowerCase();if(this.tlds.some(p=>p.toLowerCase()===a))return{full:i,remaining:"",matchedDomain:o,isHintOnly:!1};let h=this.getMatchingTlds(f);if(h.length>0){let p=(e%h.length+h.length)%h.length,m=h[p],d=m.substring(a.length),b=`${g}.${m}`;return{full:`${s}@${b}`,remaining:d,matchedDomain:b,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&f.length<this.defaultTld.length){let p=this.defaultTld.substring(f.length);if(p.includes("_"))return{full:i,remaining:p,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};var B=class extends E{engine;currentSuggestion={full:"",remaining:"",matchedDomain:null};currentSuggestionIndex=0;wasAriaAutocompleteSet=!1;wasAutocorrectSet=!1;wasAutocapitalizeSet=!1;wasSpellcheckSet=!1;wasInputModeInferred=!1;isComposing=!1;lastNotifiedValue="";srStatusEl=null;srAnnounceTimerId=null;lastAnnouncedSuggestion="";cutTimerId=null;resetTimerId=null;constructor(t,e,i){let n=C(t,e,i),s=n.wrapper,o=n.input,r=n.options,u=s?.getAttribute("data-mask-cycle-suggestions")==="true"||o?.getAttribute("data-mask-cycle-suggestions")==="true",l=s?.getAttribute("data-mask-auto-lowercase")==="true"||o?.getAttribute("data-mask-auto-lowercase")==="true",g=s?.getAttribute("data-mask-aria-autocomplete")??o?.getAttribute("data-mask-aria-autocomplete"),f=r.setAriaAutocomplete??(g!==null?g!=="false":!0),a=s?.getAttribute("data-mask-tlds")??o?.getAttribute("data-mask-tlds"),h=r.tlds??(a?a.split(",").map(b=>b.trim()).filter(Boolean):void 0),p=s?.getAttribute("data-mask-default-tld")??o?.getAttribute("data-mask-default-tld"),m=r.defaultTld!==void 0?r.defaultTld:p!==null?p==="false"||p==="none"?null:p==="true"?!0:p:void 0,d={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:r.cycleSuggestions??u??!1,autoLowercase:r.autoLowercase??l??!1,setAriaAutocomplete:f,...r,...h!==void 0?{tlds:h}:{},...m!==void 0?{defaultTld:m}:{}};super(s,o,d),this.input.hasAttribute("inputmode")||(this.input.inputMode="email",this.wasInputModeInferred=!0),this.input.hasAttribute("autocorrect")||(this.input.setAttribute("autocorrect","off"),this.wasAutocorrectSet=!0),this.input.hasAttribute("autocapitalize")||(this.input.setAttribute("autocapitalize","none"),this.wasAutocapitalizeSet=!0),this.input.hasAttribute("spellcheck")||(this.input.setAttribute("spellcheck","false"),this.wasSpellcheckSet=!0),this.options.setAriaAutocomplete&&!this.input.hasAttribute("aria-autocomplete")&&(this.input.setAttribute("aria-autocomplete","inline"),this.wasAriaAutocompleteSet=!0),this.engine=new R(this.options),this.lastNotifiedValue=this.isPasswordInput()?"":this.input.value,this.bindEvents(),!this.options.disabled&&!this.isPasswordInput()&&this.updateSuggestion(),this.runAuditWarning(this.options.audit)}onPasswordModeDetected(){this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.lastNotifiedValue="",this.lastTrackedValue="",this.lastAnnouncedSuggestion="",this.currentSuggestion={full:"",remaining:"",matchedDomain:null},this.srStatusEl&&(this.srStatusEl.textContent=""),this.clearGhost()}onNativeValueSet(t){this.options.disabled||this.isComposing||this.isPasswordInput()||this.updateSuggestion()}onDisabledChange(t){t||this.isPasswordInput()?this.clearGhost():this.updateSuggestion()}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{this.cutTimerId=null,!(this.isDestroyed||this.options.disabled||this.isPasswordInput())&&this.updateSuggestion()},0)};let{signal:t}=this.abortController;this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.handleKeyDown,{signal:t}),this.input.addEventListener("blur",this.handleBlur,{signal:t}),this.input.addEventListener("focus",this.handleFocus,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("compositionstart",()=>{this.isComposing=!0},{signal:t}),this.input.addEventListener("compositionend",()=>{this.isComposing=!1,!this.isDestroyed&&!this.options.disabled&&!this.isPasswordInput()&&this.handleInput()},{signal:t}),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!(this.isDestroyed||this.options.disabled||this.isPasswordInput())&&this.updateSuggestion()},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:t}))}ensureSrStatusEl(){if(this.srStatusEl&&this.wrapper.contains(this.srStatusEl))return this.srStatusEl;let t=this.input.ownerDocument||(typeof document<"u"?document:null);if(!t)return null;let e=t.createElement("span");return e.className="wulf-mask-sr-status",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.wrapper.appendChild(e),this.srStatusEl=e,e}scheduleSuggestionAnnouncement(t=!1){if(this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),!this.options.setAriaAutocomplete||!this.isFocused||this.isDestroyed||this.isPasswordInput())return;let e=this.currentSuggestion;if(!e.remaining||e.isHintOnly){this.lastAnnouncedSuggestion="",this.srStatusEl&&(this.srStatusEl.textContent="");return}let i=e.full;if(i===this.lastAnnouncedSuggestion&&!t)return;let n=()=>{if(this.srAnnounceTimerId=null,this.isDestroyed||!this.isFocused||this.isPasswordInput())return;this.lastAnnouncedSuggestion=i;let o=this.input.ownerDocument||(typeof document<"u"?document:null);if(o&&typeof o.ariaNotify=="function")try{o.ariaNotify(i,{priority:"normal"});return}catch{}let r=this.ensureSrStatusEl();r&&(r.textContent=r.textContent===i?`${i}\xA0`:i)};t?n():this.srAnnounceTimerId=window.setTimeout(n,250)}updateSuggestion(t){if(this.options.disabled||this.isPasswordInput()){this.currentSuggestion={full:"",remaining:"",matchedDomain:null},this.clearGhost();return}let e=this.input.value;if(this.currentSuggestion=this.engine.getSuggestion(e,this.currentSuggestionIndex),!this.ghost)return;if(this.shouldHideGhostForPlaceholder(e.length===0))this.clearGhost();else if(this.currentSuggestion.remaining){let n=this.input.ownerDocument||document,s=n.createElement("span");s.className="mask-ghost-typed",s.textContent=e;let o=n.createElement("span");o.className="mask-ghost-remaining",o.textContent=this.currentSuggestion.remaining,this.setGhostContent(s,o)}else this.clearGhost();this.ghost.scrollLeft=this.input.scrollLeft,t?.announce&&this.scheduleSuggestionAnnouncement(!!t.immediate);let i=this.getDetail();this.options.onInput&&this.options.onInput(i),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:i})),e!==this.lastNotifiedValue&&(this.lastNotifiedValue=e,this.dispatchNativeInput())}handleInput(t){if(!this.isDispatchingNativeInput&&!(this.options.disabled||this.isPasswordInput())&&!(this.isComposing||t&&"isComposing"in t&&t.isComposing)){if(this.options.autoLowercase){let e=this.input.selectionStart??0,i=this.input.selectionEnd??e,n=this.input.value.toLowerCase();n!==this.input.value&&(this.setNativeValue(n),this.input.setSelectionRange(e,i))}this.currentSuggestionIndex=0,this.updateSuggestion({announce:!0,immediate:!1})}}handleKeyDown(t){if(this.options.disabled||this.isPasswordInput()||H(t)||t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)return;let e=!!this.currentSuggestion.remaining&&!this.currentSuggestion.isHintOnly,n=(this.input.selectionStart??0)===this.input.value.length,s=this.input.value.length>0;if(this.options.cycleSuggestions&&e&&s&&n){if(t.key==="ArrowDown"){t.preventDefault(),this.currentSuggestionIndex++,this.updateSuggestion({announce:!0,immediate:!0});return}if(t.key==="ArrowUp"){t.preventDefault(),this.currentSuggestionIndex--,this.updateSuggestion({announce:!0,immediate:!0});return}}if(t.key==="Tab"&&e&&s&&this.options.completeOnTab){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="Enter"&&e&&s&&this.options.completeOnEnter){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="ArrowRight"&&e&&s&&n&&this.options.completeOnArrowRight){t.preventDefault(),this.acceptSuggestion();return}}acceptSuggestion(){if(!this.currentSuggestion.remaining||this.currentSuggestion.isHintOnly||this.options.disabled||this.input.value.length===0)return!1;let t=this.currentSuggestion.full;this.setNativeValue(t),this.input.setSelectionRange(t.length,t.length),this.currentSuggestionIndex=0,this.updateSuggestion();let e=this.getDetail();return this.options.onChange&&this.options.onChange(e),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:e})),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:e})),!0}setDefaultDomain(t){this.engine.setDefaultDomain(t),this.updateSuggestion()}setDefaultTld(t){this.engine.setDefaultTld(t),this.updateSuggestion()}setTlds(t){this.engine.setTlds(t),this.currentSuggestionIndex=0,this.updateSuggestion()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.updateSuggestion()}handleBlur(){if(this.wrapper.classList.remove("is-focused"),this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.lastAnnouncedSuggestion="",this.srStatusEl&&(this.srStatusEl.textContent=""),this.isPasswordInput()){this.lastNotifiedValue="",this.lastTrackedValue="",this.clearGhost();return}this.updateSuggestion();let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask-cycle-suggestions")this.options.cycleSuggestions=this.getAttr("data-mask-cycle-suggestions")==="true";else if(t==="data-mask-auto-lowercase")this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true";else if(t==="data-mask-default-tld"){let e=this.getAttr("data-mask-default-tld");this.setDefaultTld(e===null||e==="false"||e==="none"?null:e==="true"?!0:e)}else if(t==="data-mask-tlds"){let e=this.getAttr("data-mask-tlds");this.setTlds(e?e.split(",").map(i=>i.trim()).filter(Boolean):null)}else t==="placeholder"&&this.updateSuggestion()}getDetail(){return{value:this.input.value,suggestedValue:this.currentSuggestion.isHintOnly?"":this.currentSuggestion.full,domain:this.currentSuggestion.matchedDomain}}setValue(t){let e=t!=null?String(t):"";this.setNativeValue(e),this.updateSuggestion()}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.srStatusEl&&(this.srStatusEl.remove(),this.srStatusEl=null),this.lastNotifiedValue="",this.lastAnnouncedSuggestion="",this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="email"&&this.input.removeAttribute("inputmode"),this.wasAriaAutocompleteSet&&this.input.getAttribute("aria-autocomplete")==="inline"&&this.input.removeAttribute("aria-autocomplete"),this.wasAutocorrectSet&&this.input.getAttribute("autocorrect")==="off"&&this.input.removeAttribute("autocorrect"),this.wasAutocapitalizeSet&&this.input.getAttribute("autocapitalize")==="none"&&this.input.removeAttribute("autocapitalize"),this.wasSpellcheckSet&&this.input.getAttribute("spellcheck")==="false"&&this.input.removeAttribute("spellcheck"),super.destroy())}};var j={BaseInputMask:E,InputMask:V,MaskEngine:D,MaskHistory:I,MaskKeyboard:O,AmountEngine:x,InputAmountMask:N,EmailEngine:R,InputEmailMask:B},_=U();_&&(_.Mask=j);var et=V;return Q(it);})();
|
|
5
|
+
if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; } if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { for (var k in __WulfIIFE) { if (Object.hasOwn(__WulfIIFE, k) && k !== "__proto__" && k !== "constructor" && k !== "prototype" && __w[k] === undefined) { try { Object.defineProperty(__w, k, { value: __WulfIIFE[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { __w[k] = __WulfIIFE[k]; } catch (__) {} } } } } }
|
|
6
6
|
//# sourceMappingURL=mask.global.min.js.map
|