wulf.js 1.9.0 → 1.9.2
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 +220 -19
- package/changelog.md +42 -0
- package/dist/focus-trap.esm.js +407 -0
- package/dist/focus-trap.esm.js.map +7 -0
- package/dist/focus-trap.global.js +433 -0
- package/dist/focus-trap.global.js.map +7 -0
- package/dist/focus-trap.global.min.js +6 -0
- package/dist/focus-trap.global.min.js.map +7 -0
- package/dist/index.esm.js +1179 -8
- package/dist/index.esm.js.map +4 -4
- package/dist/index.global.js +1180 -9
- package/dist/index.global.js.map +4 -4
- package/dist/index.global.min.js +5 -2
- package/dist/index.global.min.js.map +4 -4
- package/dist/mask.esm.js +106 -2
- package/dist/mask.esm.js.map +3 -3
- package/dist/mask.global.js +107 -3
- package/dist/mask.global.js.map +3 -3
- package/dist/mask.global.min.js +5 -2
- package/dist/mask.global.min.js.map +4 -4
- package/dist/masonry.esm.js +78 -3
- package/dist/masonry.esm.js.map +3 -3
- package/dist/masonry.global.js +79 -4
- package/dist/masonry.global.js.map +3 -3
- package/dist/masonry.global.min.js +5 -2
- package/dist/masonry.global.min.js.map +4 -4
- package/dist/scroll.esm.js +78 -3
- package/dist/scroll.esm.js.map +3 -3
- package/dist/scroll.global.js +79 -4
- package/dist/scroll.global.js.map +3 -3
- package/dist/scroll.global.min.js +5 -2
- package/dist/scroll.global.min.js.map +4 -4
- package/dist/shortcut.esm.js +584 -0
- package/dist/shortcut.esm.js.map +7 -0
- package/dist/shortcut.global.js +610 -0
- package/dist/shortcut.global.js.map +7 -0
- package/dist/shortcut.global.min.js +3 -0
- package/dist/shortcut.global.min.js.map +7 -0
- package/dist/toast.esm.js +91 -2
- package/dist/toast.esm.js.map +3 -3
- package/dist/toast.global.js +92 -3
- package/dist/toast.global.js.map +3 -3
- package/dist/toast.global.min.js +5 -2
- package/dist/toast.global.min.js.map +4 -4
- package/dist/types/common/AuditableComponent.d.ts +45 -0
- package/dist/types/common/LocalizedComponent.d.ts +3 -2
- package/dist/types/focus-trap/FocusTrap.d.ts +64 -0
- package/dist/types/focus-trap/index.d.ts +3 -0
- package/dist/types/focus-trap/types.d.ts +45 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/mask/BaseInputMask.d.ts +14 -1
- package/dist/types/mask/InputMask.d.ts +1 -0
- package/dist/types/mask/types.d.ts +5 -2
- package/dist/types/masonry/Masonry.d.ts +7 -0
- package/dist/types/masonry/types.d.ts +7 -2
- package/dist/types/scroll/ScrollBlock.d.ts +7 -0
- package/dist/types/scroll/types.d.ts +3 -2
- package/dist/types/shortcut/ShortcutFormatter.d.ts +31 -0
- package/dist/types/shortcut/ShortcutManager.d.ts +91 -0
- package/dist/types/shortcut/index.d.ts +4 -0
- package/dist/types/shortcut/types.d.ts +101 -0
- package/dist/types/toast/Toast.d.ts +3 -0
- package/dist/types/toast/ToastInstance.d.ts +9 -1
- package/dist/types/toast/types.d.ts +3 -2
- package/package.json +23 -10
- package/dist/index.cjs.js +0 -4783
- package/dist/index.cjs.js.map +0 -7
- package/dist/mask.cjs.js +0 -2982
- package/dist/mask.cjs.js.map +0 -7
- package/dist/masonry.cjs.js +0 -783
- package/dist/masonry.cjs.js.map +0 -7
- package/dist/scroll.cjs.js +0 -748
- package/dist/scroll.cjs.js.map +0 -7
- package/dist/toast.cjs.js +0 -626
- package/dist/toast.cjs.js.map +0 -7
package/dist/index.global.min.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
"use strict";var Wulf=(()=>{var st=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var wt=Object.prototype.hasOwnProperty;var J=(m,i)=>{for(var t in i)st(m,t,{get:i[t],enumerable:!0})},Tt=(m,i,t,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of yt(i))!wt.call(m,o)&&o!==t&&st(m,o,{get:()=>i[o],enumerable:!(e=bt(i,o))||e.enumerable});return m};var kt=m=>Tt(st({},"__esModule",{value:!0}),m);var Ct={};J(Ct,{AmountEngine:()=>R,BaseInputMask:()=>x,EmailEngine:()=>V,InputAmountMask:()=>$,InputEmailMask:()=>X,InputMask:()=>z,LocalizedComponent:()=>S,Mask:()=>ot,MaskEngine:()=>H,MaskHistory:()=>C,MaskKeyboard:()=>N,Masonry:()=>ct,Scroll:()=>lt,Toast:()=>mt,createI18nManager:()=>A,default:()=>nt,resolveMaskConstructorArgs:()=>O});var ot={};J(ot,{AmountEngine:()=>R,BaseInputMask:()=>x,EmailEngine:()=>V,InputAmountMask:()=>$,InputEmailMask:()=>X,InputMask:()=>z,Mask:()=>ft,MaskEngine:()=>H,MaskHistory:()=>C,MaskKeyboard:()=>N,default:()=>nt,resolveMaskConstructorArgs:()=>O});function O(m,i,t){return i&&typeof i=="object"&&"tagName"in i&&i.tagName==="INPUT"?{wrapper:m||null,input:i,options:t||{}}:{wrapper:null,input:m,options:i&&typeof i=="object"&&!("tagName"in i)?i:{}}}var x=class{constructor(i,t,e){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=i=>{if(!this.options.copyRaw||this.options.disabled||this.input.type==="password")return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,o="";t!==e?o=this.extractRawSnippet(this.input.value.slice(t,e)):o=this.getRawValue(),o&&i.clipboardData&&(i.preventDefault(),i.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:n}=O(i,t,e);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",r=!!(n.createWrapper??a),h=o;if(!h&&r){let y=document.createElement("span");y.className="wulf-mask-wrapper",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.parentNode&&this.input.parentNode.insertBefore(y,this.input),y.appendChild(this.input),this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",h=y,this.isWrapperCreated=!0}if(!h)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=h,this.normalizeInputType();let u=this.getAttr("data-mask-focus-only")==="true",c=this.hasAttr("data-disabled"),l=this.getAttr("data-mask-select-on-focus")==="true",p=this.getAttr("data-mask-copy-raw")==="true",d=this.getAttr("data-mask-align")||this.getAttr("data-align"),{disabled:f,align:g,...v}=n,b=f!==void 0?f:!!c,T=this.input.type==="password";this.options={...v,createWrapper:r,showMaskOnFocus:n.showMaskOnFocus??u??!1,selectAllOnFocus:n.selectAllOnFocus??l??!1,copyRaw:T?!1:n.copyRaw??p??!1,disabled:b,align:g??(d||void 0),emitNativeInput:n.emitNativeInput??!0},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(i){return this.input.getAttribute(i)||this.wrapper.getAttribute(i)}hasAttr(i){return this.wrapper.hasAttribute(i)||this.input.hasAttribute(i)}hasNativePlaceholder(){return!!(this.input.placeholder&&this.input.placeholder.trim().length>0)}shouldHideGhostForPlaceholder(i){return!this.isFocused&&i&&this.hasNativePlaceholder()}bindBaseEvents(){this.input.addEventListener("copy",this.onBaseCopy),this.input.addEventListener("focus",this.onBaseFocus),this.input.addEventListener("blur",this.onBaseBlur)}extractRawSnippet(i){return i}initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(t=>{for(let e of t)e.type==="attributes"&&e.attributeName&&this.handleAttributeMutation(e.attributeName)});let i={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,i),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,i)}setAlign(i){let t=i||void 0,e=this.wrapper.getAttribute("data-align");this.options.align===t&&e===(i||null)||(this.options.align=t,this.wrapper.classList.remove("align-left","align-right","align-center"),i?(this.wrapper.classList.add(`align-${i}`),this.wrapper.getAttribute("data-align")!==i&&this.wrapper.setAttribute("data-align",i)):this.wrapper.hasAttribute("data-align")&&this.wrapper.removeAttribute("data-align"),this.syncGhostStyles())}handleAttributeMutation(i){if(i==="data-disabled"){let t=this.hasAttr("data-disabled");t!==!!this.options.disabled&&this.setDisabled(t)}else if(i==="data-mask-focus-only"){let t=this.getAttr("data-mask-focus-only")==="true";t!==!!this.options.showMaskOnFocus&&this.setShowMaskOnFocus(t)}else if(i==="data-mask-select-on-focus")this.options.selectAllOnFocus=this.getAttr("data-mask-select-on-focus")==="true";else if(i==="data-mask-copy-raw")this.options.copyRaw=this.getAttr("data-mask-copy-raw")==="true";else if(i==="data-mask-align"||i==="data-align"){let t=this.getAttr("data-mask-align")||this.getAttr("data-align");t!==(this.options.align??null)&&this.setAlign(t)}}normalizeInputType(){let i=["number","email","date","datetime-local","month","week","time","color","file","range"];if(this.input.type&&i.includes(this.input.type.toLowerCase())){let t=this.input.type.toLowerCase();this.input.type="text",t==="number"&&(this.input.inputMode="numeric")}}createGhost(){let i=this.wrapper.querySelector(".mask-ghost");i&&i.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 i=window.getComputedStyle(this.input);if(!i)return;this.ghost.style.fontFamily=i.fontFamily,this.ghost.style.fontSize=i.fontSize,this.ghost.style.fontWeight=i.fontWeight,this.ghost.style.fontStyle=i.fontStyle,this.ghost.style.letterSpacing=i.letterSpacing,this.ghost.style.lineHeight=i.lineHeight,this.ghost.style.paddingTop=i.paddingTop,this.ghost.style.paddingBottom=i.paddingBottom,this.ghost.style.paddingLeft=i.paddingLeft,this.ghost.style.paddingRight=i.paddingRight,this.ghost.style.borderTopWidth=i.borderTopWidth,this.ghost.style.borderBottomWidth=i.borderBottomWidth,this.ghost.style.borderLeftWidth=i.borderLeftWidth,this.ghost.style.borderRightWidth=i.borderRightWidth,this.ghost.style.borderTopStyle=i.borderTopStyle==="none"?"none":"solid",this.ghost.style.borderBottomStyle=i.borderBottomStyle==="none"?"none":"solid",this.ghost.style.borderLeftStyle=i.borderLeftStyle==="none"?"none":"solid",this.ghost.style.borderRightStyle=i.borderRightStyle==="none"?"none":"solid",this.ghost.style.borderColor="transparent",this.ghost.style.boxSizing=i.boxSizing,this.ghost.style.textAlign=i.textAlign,this.ghost.style.direction=i.direction;let t=i.direction==="rtl"||this.input.getAttribute("dir")==="rtl"||this.wrapper.getAttribute("dir")==="rtl";i.textAlign==="right"||i.textAlign==="end"||t&&i.textAlign!=="left"&&i.textAlign!=="center"?this.ghost.style.justifyContent="flex-end":i.textAlign==="center"?this.ghost.style.justifyContent="center":this.ghost.style.justifyContent="flex-start"}setNativeValue(i){this.nativeValueDescriptor&&this.nativeValueDescriptor.set?this.nativeValueDescriptor.set.call(this.input,i):this.input.value=i}dispatchNativeInput(){if(!(this.isDestroyed||typeof window>"u")&&this.options.emitNativeInput!==!1){this.isDispatchingNativeInput=!0;try{let i=this.input._valueTracker;i&&typeof i.setValue=="function"&&i.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 i=HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(i,"value");if(!t||!t.set||!t.get)return;this.nativeValueDescriptor=t;let e=this;Object.defineProperty(this.input,"value",{get(){return t.get.call(this)},set(o){let s=String(o??"");t.set.call(this,s),!e.isDestroyed&&e.onNativeValueSet(s)},configurable:!0})}catch{}}unhookValueProperty(){try{delete this.input.value}catch{}}setShowMaskOnFocus(i){this.options.showMaskOnFocus=i,this.wrapper.classList.toggle("mask-focus-only",i)}disabled(i){if(i===void 0)return!!this.options.disabled;this.setDisabled(i)}setDisabled(i){this.options.disabled=!!i,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}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 Et={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:m=>m.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:m=>m.toUpperCase()}},H=class m{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={...Et,...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 m(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(o=>new m(o,{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 o=0;o<this.pattern.length;o++){let s=this.pattern[o],n=!1;s==="\\"&&o+1<this.pattern.length&&(n=!0,o++,s=this.pattern[o]);let a=n?void 0:this.tokens[s];a?(e=!1,this.slots.push({char:s,isStatic:!1,isPrefix:!1,token:a,placeholder:this.placeholderChar}),t+=this.placeholderChar):(this.slots.push({char:s,isStatic:!0,isPrefix:e,placeholder:s}),t+=s)}this.fullMaskTemplate=t,this.prefixSlotsCount=0,this.prefixString="";for(let o of this.slots)if(o.isPrefix)this.prefixSlotsCount++,this.prefixString+=o.char;else break;return this.slots}selectEngine(i){if(this.subEngines.length<=1)return this;let t=String(i??""),e=this.subEngines.filter(r=>{let h=r.getPrefix();return h.length>0&&t.toLowerCase().startsWith(h.trim().toLowerCase())}),o=e.length>0?e:this.subEngines,s=[...o].sort((r,h)=>h.getEditableCount()-r.getEditableCount())[0],a=(s?s.extractRaw(t):t).length;for(let r of o)if(r.getEditableCount()>=a)return this.activeEngine=r,r;return this.activeEngine=o[o.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 n=this.selectEngine(i);if(n!==this)return n.extractRaw(i)}let t=String(i??"");if(!t)return"";let e="",o=0,s=0;if(this.prefixSlotsCount>0){for(;o<t.length&&(t[o]===" "||t[o]===" ");)o++;let n=0;for(;o<t.length&&n<this.prefixSlotsCount;){let a=this.slots[n].char,r=t[o];if(r.toUpperCase()===a.toUpperCase())o++,n++;else if(a===" "&&r!==" ")n++;else break}s=this.prefixSlotsCount}for(;o<t.length&&s<this.slots.length;){let n=this.slots[s],a=t[o];if(n.isStatic)a.toUpperCase()===n.char.toUpperCase()&&o++,s++;else if(n.token&&n.token.pattern.test(a)){let r=n.token.transform?n.token.transform(a):a;this.autoLowercase&&!n.token.transform&&(r=r.toLowerCase()),e+=r,o++,s++}else this.strict?o++:(e+=this.autoLowercase?a.toLowerCase():a,o++,s++)}if(!this.strict&&o<t.length){let n=t.slice(o);e+=this.autoLowercase?n.toLowerCase():n}return e}format(i){if(this.subEngines.length>0){let n=this.selectEngine(i);if(n!==this)return n.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 o="",s=0;for(let n=0;n<this.slots.length;n++){let a=this.slots[n];if(a.isStatic){let r=s<e.length,h=s===0&&!!a.isPrefix,u=s>0&&s===e.length;if(r||h||u)o+=a.char;else break}else if(s<e.length){let r=e[s],h=a.token?.transform?a.token.transform(r):r;this.autoLowercase&&!a.token?.transform&&(h=h.toLowerCase()),o+=h,s++}else break}if(!this.strict&&s<e.length){let n=e.substring(s);o+=this.autoLowercase?n.toLowerCase():n}return o}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 o=this.prefixSlotsCount,s=String(i??""),n=String(e??"");if(t<=0||!n)return o;let r=this.extractRaw(s.slice(0,t)).length;if(r===0)return Math.max(o,Math.min(this.getNextEditablePosition(0),n.length));let h=0,u=n.length;for(let c=0;c<n.length&&c<this.slots.length;c++)if(!this.slots[c].isStatic&&(h++,h===r)){u=c+1;break}for(;u<n.length&&this.slots[u]&&this.slots[u].isStatic;)u++;return Math.max(o,Math.min(u,n.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 N=class{constructor(i){this.delegate=i}handleKeyDown(i){let t=this.delegate.getInput(),e=this.delegate.getEngine(),o=this.delegate.getHistory(),s=e.getPrefixLength(),n=t.selectionStart??0,a=t.selectionEnd??n;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}o.updateCurrentCursor(n);let r=i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey,h=a>n;if(r&&!h){let l=e.getSlots(),p=n<l.length&&l[n].isStatic&&l[n].char===i.key,d=n>0&&n-1<l.length&&l[n-1].isStatic&&l[n-1].char===i.key;if(p||d){i.preventDefault();let g=p?n:n-1,v=e.getNextEditablePosition(g+1);this.delegate.applyMask(t.value,v,!0);return}let f=-1;for(let g=n;g<l.length;g++)if(l[g].isStatic){l[g].char===i.key&&(f=g);break}if(f!==-1){i.preventDefault();let g=f-1;for(;g>=s&&!l[g].isStatic;)g--;g++;let v=f-g,b=t.value.slice(g,n);if(l.slice(g,f).every(w=>!w.token||w.token.pattern.test("0"))&&v>b.length&&b.length>0){let w=v-b.length,k="0".repeat(w)+b,I=t.value.slice(f),Z=t.value.slice(0,g)+k+I,E=e.getNextEditablePosition(f+1);this.delegate.applyMask(Z,E,!0);return}let y=e.getNextEditablePosition(f+1);this.delegate.applyMask(t.value,y,!0);return}}if(r&&e.isStrict()){let l=e.getEditableCount();if(l>0){let p=e.extractRaw(t.value),d=l-p.length;if(a>n){let f=e.extractRaw(t.value.slice(n,a));d=l-(p.length-f.length)}if(d<=0){i.preventDefault();return}}}if(a>n){if(i.key==="Backspace"||i.key==="Delete"){i.preventDefault();let l=t.value,p=l.slice(0,n)+l.slice(a);this.delegate.applyMask(p,Math.max(s,n));return}return}if(i.key==="ArrowLeft"&&!i.shiftKey&&n<=s){i.preventDefault(),t.setSelectionRange(s,s);return}if(i.key==="Home"&&!i.shiftKey){i.preventDefault(),t.setSelectionRange(s,s);return}if(i.key==="Backspace"&&n<=s){i.preventDefault(),t.setSelectionRange(s,s);return}if(i.key==="Delete"&&n<s){i.preventDefault(),t.setSelectionRange(s,s);return}if(i.key==="Backspace"&&(i.ctrlKey||i.altKey||i.metaKey)){if(i.preventDefault(),n<=s){t.setSelectionRange(s,s);return}let l=n-1;for(;l>=s&&e.isSeparatorAt(l);)l--;for(;l>=s&&!e.isSeparatorAt(l);)l--;let p=Math.max(s,l+1),d=t.value,f=d.slice(0,p)+d.slice(n);this.delegate.applyMask(f,p);return}if(i.key==="Delete"&&(i.ctrlKey||i.altKey||i.metaKey)){i.preventDefault();let l=t.value;if(n>=l.length)return;let p=n;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 d=p,f=l.slice(0,n)+l.slice(d);this.delegate.applyMask(f,n);return}if(i.key==="Backspace"&&n>s){if(e.isSeparatorAt(n-1)){i.preventDefault();let l=n-1;for(;l>s&&e.isSeparatorAt(l-1);)l--;if(l>s){let p=t.value,d=p.slice(0,l-1)+p.slice(n);this.delegate.applyMask(d,l-1)}else this.delegate.applyMask("",s)}return}if(i.key==="Delete"&&n<t.value.length){if(e.isSeparatorAt(n)){i.preventDefault();let l=n;for(;l<t.value.length&&e.isSeparatorAt(l);)l++;if(l<t.value.length){let p=t.value,d=p.slice(0,l)+p.slice(l+1);this.delegate.applyMask(d,n)}}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 z=class extends x{constructor(t,e,o){let s=O(t,e,o),n=s.wrapper,a=s.input,r=s.options,h=n?.getAttribute("data-mask")||a?.getAttribute("data-mask"),u=r.mask||h||"";typeof u=="string"&&u.includes("|")&&(u=u.split("|").map(w=>w.trim()));let c=r.placeholderChar||n?.getAttribute("data-mask-placeholder")||a?.getAttribute("data-mask-placeholder")||"_",l=n?.hasAttribute("data-disabled")||a?.hasAttribute("data-disabled"),p=n?.getAttribute("data-mask-strict")||a?.getAttribute("data-mask-strict"),d=n?.getAttribute("data-mask-auto-lowercase")==="true"||a?.getAttribute("data-mask-auto-lowercase")==="true",f=n?.getAttribute("data-mask-infer-inputmode")??a?.getAttribute("data-mask-infer-inputmode"),g=r.inferInputMode??(f!==null?f!=="false":!0),{disabled:v,...b}=r,T=v!==void 0?v:l?!0:!u||Array.isArray(u)&&u.length===0,y={...b,mask:u,placeholderChar:c,strict:r.strict??(p!==null?p!=="false":!0),autoLowercase:r.autoLowercase??d??!1,disabled:T,resetHistoryOnMaskChange:r.resetHistoryOnMaskChange??!1,inferInputMode:g,onInput:r.onInput||r.oninput,onChange:r.onChange||r.onchange,onComplete:r.onComplete||r.oncomplete};super(n,a,y);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 H(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new N({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(w,k,I)=>this.applyMask(w,k,I),undo:()=>this.undo(),redo:()=>this.redo(),enforceMinCursor:()=>this.enforceMinCursor()}),this.bindEvents(),this.lastValue=this.input.value,this.syncInitialValue()}extractRawSnippet(t){return this.engine.extractRaw(t)}static format(t,e,o={}){return H.format(t,e,o)}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 o=typeof e=="boolean"?e:e&&typeof e=="object"&&e.strict!==void 0?e.strict:this.options.strict,s=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=o,this.engine.setStrict(o??!0),this.engine.compile(""),s&&this.history.clear(),this.setDisabled(!0),this.syncInferredInputMode();return}this.options.mask=t,this.options.strict=o,this.engine.setStrict(o??!0),this.engine.compile(t),s&&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 o=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(e===o)return;if(e){let s=e.includes("|")?e.split("|").map(n=>n.trim()):e;this.setMask(s)}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,o=t!==e;this.wrapper.classList.toggle("has-selection",o)}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 o=this.getRawValue(),s=this.input.selectionStart??0,n=this.input.selectionEnd??s,a=Math.max(0,e-o.length);if(n>s){let r=this.engine.extractRaw(this.input.value.slice(s,n));a=Math.max(0,e-(o.length-r.length))}a<=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 o=this.history.getCurrent(),s=this.engine.getEditableCount();if(s>0&&this.engine.isStrict()&&o&&o.raw.length>=s&&this.engine.extractRaw(this.input.value).length>s){this.applyMask(o.raw,o.cursor);return}let n=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,n),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 o=(t.clipboardData?.getData("text")||"").trim();if(!o)return;let s=this.engine.getPrefixLength(),n=this.input.selectionStart??0,a=this.input.selectionEnd??n,r=this.input.value,h=this.engine.getEditableCount(),u=this.getRawValue(),l=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),p=o.replace(/[\s.-]+/g,"").toUpperCase(),d=l.length>0&&p.startsWith(l),f=r.slice(0,Math.max(s,n)).replace(/[\s.-]+/g,"").toUpperCase(),g=f.length>=2&&p.startsWith(f),v=Math.max(s,n),b=Math.max(s,a);(d||g)&&(v=0,b=r.length);let T=Math.max(0,h-u.length);if(v!==b){let k=this.engine.extractRaw(r.slice(v,b));T=Math.max(0,h-(u.length-k.length))}if(this.engine.isStrict()&&T<=0)return;let y,w;v===0&&b===r.length?(y=o,w=o.length):(y=r.slice(0,v)+o+r.slice(b),w=v+o.length),this.applyMask(y,w),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,o=this.input.selectionEnd??e;e===o&&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 o=this.engine.getFullMaskTemplate(),s=o.length>t.length?o.substring(t.length):"";this.ghost.textContent="";let n=document.createElement("span");n.className="mask-ghost-typed",n.textContent=t;let a=document.createElement("span");a.className="mask-ghost-remaining",a.textContent=s,this.ghost.appendChild(n),this.ghost.appendChild(a),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,o=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let s="",n=!1;try{s=this.engine.format(t);let a=this.engine.getRemainingMask(s);this.input.value=s,this.lastInternalRemainingMask=a,this.wrapper.setAttribute("data-mask",a),this.updateGhost(s);let r=this.engine.getPrefixLength(),h;if(o||this.isUndoingRedoing)h=Math.max(r,Math.min(e,s.length));else{let u=this.engine.mapCursorPosition(t,e,s);h=Math.max(r,u)}this.input.setSelectionRange(h,h),n=this.isComplete(),this.wrapper.classList.toggle("is-complete",n),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(this.getRawValue(),h)}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 o=this.engine.getFullMaskTemplate();this.lastInternalRemainingMask=o,this.wrapper.setAttribute("data-mask",o),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 o=this.input.value;this.lastValue=o;let s=this.options.disabled?o:this.getRawValue(),n=this.options.disabled?0:this.engine.getEditableCount(),a=this.isComplete(),r={value:o,rawValue:s,isComplete:a,totalSlots:n,filledSlots:this.options.disabled?o.length:s.length},h=this.options.onInput||this.options.oninput;h&&h(o,r),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:r})),this.dispatchNativeInput();let u=this.options.onChange||this.options.onchange;u&&u(r),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:r}));let c=this.options.onComplete||this.options.oncomplete;a&&(c&&c(r),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:r})))}}finally{this.isNotifying=!1}}}};var R=class m{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 o=this.options.decimalSeparator,s=t.indexOf(o);s===-1&&(s=t.search(/[,.]/));let n="",a=null,r=!1;return s!==-1?(n=t.substring(0,s).replace(/\D/g,""),this.options.decimals>0&&(r=!0,a=t.substring(s+1).replace(/\D/g,"").slice(0,this.options.decimals))):n=t.replace(/\D/g,""),n.length>1&&(n=n.replace(/^0+/,"")||"0"),{isNegative:e,integerPart:n,decimalPart:a,hasDecimal:r}}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 o=i.substring(0,t),s=o.replace(/\D/g,"").length,n=this.options.decimals>0&&/[,.]/.test(o),{isNegative:a,integerPart:r,decimalPart:h,hasDecimal:u}=this.parse(i),c=h,l=u;if(e&&this.options.decimals>0&&(r||h!==null)&&(l=!0,c===null?c="0".repeat(this.options.decimals):c.length<this.options.decimals&&(c=c+"0".repeat(this.options.decimals-c.length))),a&&!r&&!c&&!l&&this.options.allowNegative){let E="-",D=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(E=`${this.options.currency} -`,D=E.length):(E=`- ${this.options.currency}`,D=1)),{formatted:E,rawNumber:null,rawValue:"-",cursor:D,isValid:!0}}if(!r&&!c&&!l)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let d=(r||"0").replace(/\B(?=(\d{3})+(?!\d))/g,this.options.thousandSeparator);l&&this.options.decimals>0&&(d+=this.options.decimalSeparator+(c??"")),a&&d!=="0"&&(d="-"+d);let f=d;this.options.currency&&(this.options.currencyPosition==="prefix"?f=`${this.options.currency} ${d}`:f=`${d} ${this.options.currency}`);let g=(a?"-":"")+(r||"0")+(h?"."+h:""),v=parseFloat(g);isNaN(v)&&(v=0);let b=v>=this.options.min&&v<=this.options.max,T=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(T=this.options.currency.length+1);let y=0,w=!1,k=T;for(let E=T;E<f.length;E++){let D=f[E];if(D===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(D)?(y++,k=E+1):D===this.options.decimalSeparator&&(w=!0,k=E+1),n){if(w&&y>=s){T=E+1;break}}else if(y>=s){T=E+1;break}}s>0&&y<s&&k>T&&(T=k);let I=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,Z=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,f.length-this.options.currency.length-1):f.length;return T=Math.max(I,Math.min(T,Math.max(I,Z))),{formatted:f,rawNumber:v,rawValue:g,cursor:T,isValid:b}}static format(i,t={}){let e=new m(t),o=typeof i=="number"?i.toString():i;return e.format(o).formatted}escapeRegExp(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var $=class extends x{constructor(t,e,o){let s=O(t,e,o),n=s.wrapper,a=s.input,r=s.options,h=n?.getAttribute("data-mask-pad-decimals")==="true"||a?.getAttribute("data-mask-pad-decimals")==="true",u=a?.getAttribute("data-mask-align")||a?.getAttribute("data-align")||n?.getAttribute("data-mask-align")||n?.getAttribute("data-align"),c={align:r.align??u??"right",padDecimalsOnBlur:r.padDecimalsOnBlur??h??!1,...r};super(n,a,c);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 R(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})}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 R.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 o=this.engine.format(t,e);this.setNativeValue(o.formatted),this.input.setSelectionRange(o.cursor,o.cursor),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(o.rawValue,o.cursor),this.updateGhost(o),this.lastValue!==o.formatted&&(this.lastValue=o.formatted,this.notifyChange(o))}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 o=document.createElement("span");o.className="mask-ghost-remaining",o.textContent=e,this.ghost.appendChild(o);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,o=this.input.selectionEnd??0;if(e===o&&e>0){let s=this.input.value,n=s[e-1];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let a=Math.max(0,e-2),r=s.slice(0,a)+s.slice(e);this.applyAmount(r,a);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,o=this.input.selectionEnd??0;if(e===o&&e<this.input.value.length){let s=this.input.value,n=s[e];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let a=s.slice(0,e)+s.slice(e+2);this.applyAmount(a,e);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let a=s.length-this.options.currency.length-1;if(e>=a){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 o=this.input.value,s=this.options.currency;if(s){if(this.options.currencyPosition==="prefix"){let n=s.length+1;t<n&&this.input.setSelectionRange(n,n)}else if(this.options.currencyPosition==="suffix"){let n=Math.max(0,o.length-s.length-1);t>n&&this.input.setSelectionRange(n,n)}}}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 K=class K{constructor(i={}){this.defaultDomain=null;this.defaultTld="__";this.domains=i.domains&&i.domains.length>0?i.domains:K.DEFAULT_DOMAINS,this.tlds=i.tlds&&i.tlds.length>0?i.tlds.map(t=>t.trim().replace(/^\./,"")).filter(Boolean):[...K.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):[...K.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 o=t.substring(e+1);if(o.length===0)return this.suggestOnAt?[...this.domains]:[];let s=o.toLowerCase();return this.domains.filter(n=>n.toLowerCase().startsWith(s)&&n.toLowerCase()!==s)}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 o=e.indexOf("@"),s=e.substring(0,o),n=e.substring(o+1);if(e.indexOf("@",o+1)!==-1)return{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let a=this.getMatchingDomains(i);if(a.length>0){let d=(t%a.length+a.length)%a.length,f=a[d],g=n.toLowerCase(),v=f.substring(g.length);return{full:`${s}@${f}`,remaining:v,matchedDomain:f,isHintOnly:!1}}if(n.length===0||n.startsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let r=n.toLowerCase();if(this.domains.some(d=>d.toLowerCase()===r))return{full:i,remaining:"",matchedDomain:n,isHintOnly:!1};let h=n.lastIndexOf(".");if(h===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let d=this.defaultTld.includes("_"),f=`.${this.defaultTld}`,g=`${n}.${this.defaultTld}`;return{full:d?i:`${s}@${g}`,remaining:f,matchedDomain:d?null:g,isHintOnly:d}}let u=n.substring(0,h),c=n.substring(h+1);if(!u||u.endsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};if(c.length===0){if(this.defaultTld&&!this.defaultTld.includes("_")){let d=`${u}.${this.defaultTld}`;return{full:`${s}@${d}`,remaining:this.defaultTld,matchedDomain:d,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=c.toLowerCase(),p=this.getMatchingTlds(c);if(p.length>0){let d=(t%p.length+p.length)%p.length,f=p[d],g=f.substring(l.length),v=`${u}.${f}`;return{full:`${s}@${v}`,remaining:g,matchedDomain:v,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&c.length<this.defaultTld.length){let d=this.defaultTld.substring(c.length);if(d.includes("_"))return{full:i,remaining:d,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};K.DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"],K.DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];var V=K;var X=class extends x{constructor(t,e,o){let s=O(t,e,o),n=s.wrapper,a=s.input,r=s.options,h=n?.getAttribute("data-mask-cycle-suggestions")==="true"||a?.getAttribute("data-mask-cycle-suggestions")==="true",u=n?.getAttribute("data-mask-auto-lowercase")==="true"||a?.getAttribute("data-mask-auto-lowercase")==="true",c=n?.getAttribute("data-mask-aria-autocomplete")??a?.getAttribute("data-mask-aria-autocomplete"),l=r.setAriaAutocomplete??(c!==null?c!=="false":!0),p=n?.getAttribute("data-mask-tlds")??a?.getAttribute("data-mask-tlds"),d=r.tlds??(p?p.split(",").map(b=>b.trim()).filter(Boolean):void 0),f=n?.getAttribute("data-mask-default-tld")??a?.getAttribute("data-mask-default-tld"),g=r.defaultTld!==void 0?r.defaultTld:f!==null?f==="false"||f==="none"?null:f==="true"?!0:f:void 0,v={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:r.cycleSuggestions??h??!1,autoLowercase:r.autoLowercase??u??!1,setAriaAutocomplete:l,...r,...d!==void 0?{tlds:d}:{},...g!==void 0?{defaultTld:g}:{}};super(n,a,v);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 V(this.options),this.bindEvents(),this.options.disabled||this.updateSuggestion()}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 o=document.createElement("span");o.className="mask-ghost-typed",o.textContent=t;let s=document.createElement("span");s.className="mask-ghost-remaining",s.textContent=this.currentSuggestion.remaining,this.ghost.appendChild(o),this.ghost.appendChild(s)}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,o=this.input.value.toLowerCase();o!==this.input.value&&(this.setNativeValue(o),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,s=(this.input.selectionStart??0)===this.input.value.length,n=this.input.value.length>0;if(this.options.cycleSuggestions&&e&&n&&s){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&&n&&this.options.completeOnTab){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="Enter"&&e&&n&&this.options.completeOnEnter){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="ArrowRight"&&e&&n&&s&&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(o=>o.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 ft={BaseInputMask:x,InputMask:z,MaskEngine:H,MaskHistory:C,MaskKeyboard:N,AmountEngine:R,InputAmountMask:$,EmailEngine:V,InputEmailMask:X};if(typeof window<"u"){let m=window,i=m.Wulf||{};m.Wulf=i,i.Mask=ft}var nt=z;var lt={};J(lt,{LocalizedComponent:()=>S,Scroll:()=>vt,ScrollBlock:()=>F,createI18nManager:()=>A,default:()=>Lt,scrollEn:()=>at,scrollFr:()=>rt,scrollI18n:()=>G});var S=class{static setLocale(i){this._i18n&&this._i18n.setLocale(i)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(i,t){this._i18n&&this._i18n.registerLocale(i,t)}static setI18n(i){this._i18n&&this._i18n.setI18n(i)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(i,t){return this._i18n?this._i18n.t(i,t):String(i)}constructor(i){this.i18nOverrides=i}t(i){let t=this.constructor;return t._i18n?t._i18n.t(i,this.i18nOverrides):String(i)}};function it(m){return m.trim().toLowerCase().replace(/_/g,"-")}function Mt(m){let i=m.indexOf("-");return i>0?m.slice(0,i):null}function _(m,i){if(!i)return m;for(let t of Object.keys(i))i[t]!==void 0&&(m[t]=i[t]);return m}function A(m,i){let t=it(m),e={};for(let[r,h]of Object.entries(i))e[it(r)]={...h};let o=t,s={...e},n={};function a(){let r=[],h=s[o];h&&r.push(h);let u=Mt(o);return u&&s[u]&&r.push(s[u]),r}return{setLocale(r){r&&r.trim()&&(o=it(r))},getLocale(){return o},registerLocale(r,h){if(!r||!r.trim()||!h)return;let u=it(r);s[u]=_({...s[u]||{}},h)},setI18n(r){r&&(n=_({...n},r))},t(r,h){if(h&&h[r]!==void 0)return String(h[r]);if(n[r]!==void 0)return String(n[r]);for(let c of a())if(c[r]!==void 0)return String(c[r]);let u=s[t]||e[t];return u&&u[r]!==void 0?String(u[r]):String(r)},getAll(r){let h={},u=s[t]||e[t];_(h,u);let c=a().reverse();for(let l of c)_(h,l);return _(h,n),_(h,r),h},reset(){o=t,n={},s={};for(let[r,h]of Object.entries(e))s[r]={...h}}}}var rt={viewport:"Zone de contenu d\xE9filable",verticalThumb:"D\xE9filement vertical",horizontalThumb:"D\xE9filement horizontal"};var at={viewport:"Scrollable content area",verticalThumb:"Vertical scroll",horizontalThumb:"Horizontal scroll"};var G=A("fr",{fr:rt,en:at});var gt=0,F=class extends S{constructor(t,e){super(e?.i18n);this.createdViewport=!1;this.wasIdGenerated=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.hasExplicitAriaLabel=!1;this.lastInferredAriaLabel="";this.isDragging=!1;this.dragStartPos=0;this.dragStartScroll=0;this.atBottom=!1;this.atTop=!0;this.atRight=!1;this.atLeft=!0;let o=typeof t=="string"?document.querySelector(t):t;if(!o)throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${t}".`);this.root=o,this.hasExplicitAriaLabel=!!e?.ariaLabel,this.options={axis:e?.axis||"y",autoHide:e?.autoHide??!0,autoHideDelay:e?.autoHideDelay??1e3,alwaysVisible:e?.alwaysVisible??!1,ariaLabel:e?.ariaLabel||this.t("viewport"),i18n:e?.i18n||{},minThumbSize:e?.minThumbSize??24,edgeThreshold:e?.edgeThreshold??10,onScroll:e?.onScroll||(()=>{}),onTotalScroll:e?.onTotalScroll||(()=>{}),onTotalScrollBack:e?.onTotalScrollBack||(()=>{})},this.boundOnScroll=this.handleScroll.bind(this),this.boundOnMouseEnter=this.handleMouseEnter.bind(this),this.boundOnMouseLeave=this.handleMouseLeave.bind(this),this.boundOnFocusIn=this.handleFocusIn.bind(this),this.boundOnFocusOut=this.handleFocusOut.bind(this),this.boundPointerMove=this.handlePointerMove.bind(this),this.boundPointerUp=this.handlePointerUp.bind(this),this.viewport=this.setupViewport(),this.setupAccessibility(),this.setupScrollbars(),this.setupEventListeners(),this.setupObserver(),this.update()}setupViewport(){this.root.classList.add("wulf-scrollblock"),this.options.alwaysVisible&&this.root.classList.add("is-always-visible"),this.options.axis==="both"&&this.root.classList.add("has-both-axes");let t=this.root.querySelector(":scope > .wulf-scrollblock-viewport");if(t)return t;let e=document.createElement("div");for(e.className="wulf-scrollblock-viewport";this.root.firstChild;)e.appendChild(this.root.firstChild);return this.root.appendChild(e),this.createdViewport=!0,e}setupAccessibility(){if(this.viewport.id||(gt+=1,this.viewport.id=`wulf-scrollblock-vp-${gt}`,this.wasIdGenerated=!0),this.viewport.hasAttribute("role")||(this.viewport.setAttribute("role","region"),this.wasRoleInferred=!0),!this.viewport.hasAttribute("aria-label")){let t=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("viewport");this.viewport.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.wasAriaLabelInferred=!0}}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel){let e=this.t("viewport");this.viewport.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.options.ariaLabel=e}this.thumbY&&this.thumbY.setAttribute("aria-label",this.t("verticalThumb")),this.thumbX&&this.thumbX.setAttribute("aria-label",this.t("horizontalThumb"))}setupScrollbars(){(this.options.axis==="y"||this.options.axis==="both")&&(this.trackY=document.createElement("div"),this.trackY.className="wulf-scrollblock-track wulf-scrollblock-vertical",this.trackY.setAttribute("aria-hidden","true"),this.thumbY=document.createElement("div"),this.thumbY.className="wulf-scrollblock-thumb",this.thumbY.setAttribute("role","scrollbar"),this.thumbY.setAttribute("aria-orientation","vertical"),this.thumbY.setAttribute("aria-controls",this.viewport.id),this.thumbY.setAttribute("aria-valuenow","0"),this.thumbY.setAttribute("aria-valuemin","0"),this.thumbY.setAttribute("aria-valuemax","100"),this.thumbY.setAttribute("aria-label",this.t("verticalThumb")),this.trackY.appendChild(this.thumbY),this.root.appendChild(this.trackY),this.attachTrackListeners(this.trackY,this.thumbY,"y")),(this.options.axis==="x"||this.options.axis==="both")&&(this.trackX=document.createElement("div"),this.trackX.className="wulf-scrollblock-track wulf-scrollblock-horizontal",this.trackX.setAttribute("aria-hidden","true"),this.thumbX=document.createElement("div"),this.thumbX.className="wulf-scrollblock-thumb",this.thumbX.setAttribute("role","scrollbar"),this.thumbX.setAttribute("aria-orientation","horizontal"),this.thumbX.setAttribute("aria-controls",this.viewport.id),this.thumbX.setAttribute("aria-valuenow","0"),this.thumbX.setAttribute("aria-valuemin","0"),this.thumbX.setAttribute("aria-valuemax","100"),this.thumbX.setAttribute("aria-label",this.t("horizontalThumb")),this.trackX.appendChild(this.thumbX),this.root.appendChild(this.trackX),this.attachTrackListeners(this.trackX,this.thumbX,"x"))}attachTrackListeners(t,e,o){e.addEventListener("pointerdown",s=>{s.preventDefault(),s.stopPropagation(),this.isDragging=!0,this.dragAxis=o,this.dragPointerId=s.pointerId,this.dragStartPos=o==="y"?s.clientY:s.clientX,this.dragStartScroll=o==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,e.setPointerCapture(s.pointerId),e.classList.add("is-active"),this.root.classList.add("is-dragging"),window.addEventListener("pointermove",this.boundPointerMove),window.addEventListener("pointerup",this.boundPointerUp),window.addEventListener("pointercancel",this.boundPointerUp)}),t.addEventListener("pointerdown",s=>{if(s.target===e)return;s.preventDefault();let n=t.getBoundingClientRect(),a=o==="y"?s.clientY-n.top:s.clientX-n.left,r=o==="y"?n.height:n.width,h=o==="y"?this.viewport.clientHeight:this.viewport.clientWidth,u=o==="y"?this.viewport.scrollHeight:this.viewport.scrollWidth,l=a/r*(u-h);this.scrollTo(o==="y"?{top:l}:{left:l},{smooth:!0})})}setupEventListeners(){this.viewport.addEventListener("scroll",this.boundOnScroll,{passive:!0}),this.options.autoHide&&!this.options.alwaysVisible&&(this.root.addEventListener("mouseenter",this.boundOnMouseEnter),this.root.addEventListener("mouseleave",this.boundOnMouseLeave),this.root.addEventListener("focusin",this.boundOnFocusIn),this.root.addEventListener("focusout",this.boundOnFocusOut))}setupObserver(){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{window.requestAnimationFrame(()=>this.update())}),this.resizeObserver.observe(this.root),this.resizeObserver.observe(this.viewport),this.viewport.firstElementChild&&this.resizeObserver.observe(this.viewport.firstElementChild))}handlePointerMove(t){if(!this.isDragging||!this.dragAxis)return;let e=this.dragAxis==="y",o=(e?t.clientY:t.clientX)-this.dragStartPos,s=e?this.trackY:this.trackX,n=e?this.thumbY:this.thumbX;if(!s||!n)return;let a=e?s.clientHeight:s.clientWidth,r=e?n.clientHeight:n.clientWidth,h=e?this.viewport.clientHeight:this.viewport.clientWidth,c=(e?this.viewport.scrollHeight:this.viewport.scrollWidth)-h,l=a-r;if(l<=0||c<=0)return;let p=c/l,d=this.dragStartScroll+o*p;e?this.viewport.scrollTop=Math.max(0,Math.min(c,d)):this.viewport.scrollLeft=Math.max(0,Math.min(c,d))}handlePointerUp(t){if(this.isDragging){if(this.dragPointerId!==void 0){let e=this.dragAxis==="y"?this.thumbY:this.thumbX;e&&e.hasPointerCapture(this.dragPointerId)&&e.releasePointerCapture(this.dragPointerId)}window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.isDragging=!1,this.dragAxis=void 0,this.dragPointerId=void 0,this.thumbY?.classList.remove("is-active"),this.thumbX?.classList.remove("is-active"),this.root.classList.remove("is-dragging"),this.scheduleAutoHide()}}handleScroll(){this.syncThumbs();let{scrollTop:t,scrollLeft:e,scrollHeight:o,scrollWidth:s,clientHeight:n,clientWidth:a}=this.viewport,r=Math.max(0,o-n),h=Math.max(0,s-a),u=r>0?t/r:0,c=h>0?e/h:0;this.options.onScroll({top:t,left:e,maxTop:r,maxLeft:h,progressY:Math.round(u*100),progressX:Math.round(c*100)});let l=this.options.edgeThreshold;if(r>0){let p=t>=r-l,d=t<=l;p&&!this.atBottom&&this.options.onTotalScroll("bottom"),d&&!this.atTop&&this.options.onTotalScrollBack("top"),this.atBottom=p,this.atTop=d}if(h>0){let p=e>=h-l,d=e<=l;p&&!this.atRight&&this.options.onTotalScroll("right"),d&&!this.atLeft&&this.options.onTotalScrollBack("left"),this.atRight=p,this.atLeft=d}this.options.autoHide&&!this.options.alwaysVisible&&(this.root.classList.add("is-scrolling"),this.scheduleAutoHide())}syncThumbs(){let{scrollTop:t,scrollLeft:e,scrollHeight:o,scrollWidth:s,clientHeight:n,clientWidth:a}=this.viewport;if(this.thumbY&&this.trackY){let r=o-n,h=this.trackY.clientHeight,u=this.thumbY.clientHeight,c=h-u;if(r>0&&c>0){let l=t/r,p=Math.max(0,Math.min(c,l*c));this.thumbY.style.transform=`translate3d(0, ${p}px, 0)`,this.thumbY.setAttribute("aria-valuenow",String(Math.round(l*100)))}}if(this.thumbX&&this.trackX){let r=s-a,h=this.trackX.clientWidth,u=this.thumbX.clientWidth,c=h-u;if(r>0&&c>0){let l=e/r,p=Math.max(0,Math.min(c,l*c));this.thumbX.style.transform=`translate3d(${p}px, 0, 0)`,this.thumbX.setAttribute("aria-valuenow",String(Math.round(l*100)))}}}handleMouseEnter(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleMouseLeave(){this.scheduleAutoHide()}handleFocusIn(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleFocusOut(){this.scheduleAutoHide()}clearAutoHideTimer(){this.hideTimer&&(window.clearTimeout(this.hideTimer),this.hideTimer=void 0)}scheduleAutoHide(){this.options.alwaysVisible||!this.options.autoHide||this.isDragging||(this.clearAutoHideTimer(),this.hideTimer=window.setTimeout(()=>{this.root.classList.remove("is-scrolling"),this.root.classList.remove("is-visible")},this.options.autoHideDelay))}update(){this.syncAccessibilityLabels();let{scrollHeight:t,clientHeight:e,scrollWidth:o,clientWidth:s}=this.viewport,n=t>e,a=o>s;if(this.root.classList.toggle("has-scroll-y",n),this.root.classList.toggle("has-scroll-x",a),n||a?this.viewport.setAttribute("tabindex","0"):this.viewport.removeAttribute("tabindex"),this.trackY&&this.thumbY&&n){let r=this.trackY.clientHeight,h=Math.max(this.options.minThumbSize,r*(e/t));this.thumbY.style.height=`${h}px`}if(this.trackX&&this.thumbX&&a){let r=this.trackX.clientWidth,h=Math.max(this.options.minThumbSize,r*(s/o));this.thumbX.style.width=`${h}px`}this.syncThumbs()}scrollTo(t,e){let o=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,s=typeof t=="object"&&t!==null&&!(t instanceof HTMLElement)?t.smooth:void 0,a=(e?.smooth??s??!0)&&!o?"smooth":"auto",r=Math.max(0,this.viewport.scrollHeight-this.viewport.clientHeight),h=Math.max(0,this.viewport.scrollWidth-this.viewport.clientWidth),u,c;if(typeof t=="number")u=t;else if(typeof t=="string")switch(t){case"top":u=0;break;case"bottom":u=r;break;case"left":c=0;break;case"right":c=h;break;default:{if(/^-?\d+(\.\d+)?%$/.test(t.trim())){let p=Math.max(0,Math.min(100,parseFloat(t.trim())))/100;this.options.axis==="x"?c=h*p:this.options.axis==="both"?(u=r*p,c=h*p):u=r*p;break}let l=null;try{l=this.viewport.querySelector(t)}catch{l=null}l&&(u=l.offsetTop,c=l.offsetLeft);break}}else t instanceof HTMLElement?(u=t.offsetTop,c=t.offsetLeft):typeof t=="object"&&(u=t.top,c=t.left);this.viewport.scrollTo({top:u!==void 0?Math.max(0,Math.min(r,u)):void 0,left:c!==void 0?Math.max(0,Math.min(h,c)):void 0,behavior:a})}destroy(){if(this.clearAutoHideTimer(),this.resizeObserver&&this.resizeObserver.disconnect(),this.viewport.removeEventListener("scroll",this.boundOnScroll),this.root.removeEventListener("mouseenter",this.boundOnMouseEnter),this.root.removeEventListener("mouseleave",this.boundOnMouseLeave),this.root.removeEventListener("focusin",this.boundOnFocusIn),this.root.removeEventListener("focusout",this.boundOnFocusOut),window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.trackY?.remove(),this.trackX?.remove(),this.root.classList.remove("wulf-scrollblock","has-scroll-y","has-scroll-x","has-both-axes","is-visible","is-scrolling","is-dragging","is-always-visible"),this.createdViewport&&this.viewport.parentElement===this.root){for(;this.viewport.firstChild;)this.root.insertBefore(this.viewport.firstChild,this.viewport);this.viewport.remove()}else this.viewport.removeAttribute("tabindex"),this.wasIdGenerated&&this.viewport.removeAttribute("id"),this.wasRoleInferred&&this.viewport.getAttribute("role")==="region"&&this.viewport.removeAttribute("role"),this.wasAriaLabelInferred&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.viewport.removeAttribute("aria-label")}};F._i18n=G,F.i18n=G;var vt={ScrollBlock:F,i18n:G};var Lt=F;if(typeof window<"u"){let m=window,i=m.Wulf||{};m.Wulf=i,i.Scroll=vt}var ct={};J(ct,{LayoutEngine:()=>U,LocalizedComponent:()=>S,Masonry:()=>P,createI18nManager:()=>A,default:()=>St,masonryEn:()=>ut,masonryFr:()=>ht,masonryI18n:()=>j});var U=class{static parseGutter(i){return typeof i=="number"?{x:Math.max(0,i),y:Math.max(0,i)}:i&&typeof i=="object"?{x:Math.max(0,Number(i.x)||0),y:Math.max(0,Number(i.y)||0)}:{x:0,y:0}}static resolveColumnWidth(i,t,e){if(typeof e=="number"&&e>0)return e;if(typeof e=="string"){let s=i.querySelector(e);if(s){let a=s.getBoundingClientRect().width;if(a>0)return a}let n=parseFloat(e);if(!isNaN(n)&&n>0)return e.endsWith("%")?i.getBoundingClientRect().width*n/100:n}if(e instanceof HTMLElement){let s=e.getBoundingClientRect().width;if(s>0)return s}if(t){let s=t.getBoundingClientRect().width;if(s>0)return s}let o=i.getBoundingClientRect().width;return o>0?o:200}static getItemSpan(i,t,e,o){let s=i.getAttribute("data-masonry-span")||i.dataset.masonrySpan;if(s){let a=parseInt(s,10);if(!isNaN(a)&&a>0)return Math.min(o,a)}let n=i.className.match(/(?:^|\s)(?:span|col-span)-(\d+)(?:\s|$)/);if(n&&n[1]){let a=parseInt(n[1],10);if(!isNaN(a)&&a>0)return Math.min(o,a)}return 1}static calculate(i,t,e){let s=i.getBoundingClientRect().width,{x:n,y:a}=this.parseGutter(e.gutter);if(s<=0||t.length===0)return{cols:1,colWidth:s,gutterX:n,gutterY:a,containerHeight:0,containerWidth:s,positions:[]};let r=t[0]||null,h=this.resolveColumnWidth(i,r,e.columnWidth),u=Math.floor((s+n)/(h+n));u=Math.max(1,u),!e.columnWidth&&u>1&&(h=(s-(u-1)*n)/u);let c=e.fitWidth?u*h+(u-1)*n:void 0,l=new Array(u).fill(0),p=[],d=t.map(b=>{let T=b.getBoundingClientRect().height;return T>0?T:50}),f=0;for(let b=0;b<t.length;b++){let T=t[b],y=d[b],w=this.getItemSpan(T,h,n,u),k=0,I=0;if(e.horizontalOrder){f+w>u&&(f=0),k=f;let L=0;for(let M=0;M<w;M++)l[k+M]>L&&(L=l[k+M]);I=L,f=(k+w)%u}else if(w===1){let L=l[0];k=0;for(let M=1;M<u;M++)l[M]<L&&(L=l[M],k=M);I=L}else{let L=1/0;k=0;for(let M=0;M<=u-w;M++){let tt=0;for(let et=0;et<w;et++)l[M+et]>tt&&(tt=l[M+et]);tt<L&&(L=tt,k=M)}I=L}let Z=w*h+(w-1)*n,E=k*(h+n);p.push({element:T,x:E,y:I,width:Z,height:y,column:k,span:w});let D=I+y+a;for(let L=0;L<w;L++)l[k+L]=D}let g=0;for(let b=0;b<u;b++)l[b]>g&&(g=l[b]);let v=Math.max(0,g>0?g-a:0);return{cols:u,colWidth:h,gutterX:n,gutterY:a,containerHeight:v,containerWidth:s,fittedWidth:c,positions:p}}};var ht={gallery:"Galerie en grille asym\xE9trique"};var ut={gallery:"Masonry grid gallery"};var j=A("fr",{fr:ht,en:ut});var P=class extends S{constructor(t,e={}){super(e.i18n);this.isNativeCSSGrid=!1;this._items=[];this.resizeObserver=null;this.itemResizeObserver=null;this.layoutRafId=null;this.isDestroyed=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.hasExplicitAriaLabel=!1;this.lastInferredAriaLabel="";this.removeTimers=new Set;this.pendingImageListeners=[];if(typeof t=="string"){let s=document.querySelector(t);if(!s)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${t}"`);this.root=s}else if(t instanceof HTMLElement)this.root=t;else throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");this.originalContainerStyles={height:this.root.style.height,width:this.root.style.width},this.hasExplicitAriaLabel=!!e.ariaLabel,this.options={itemSelector:e.itemSelector||"> *",columnWidth:e.columnWidth??0,gutter:e.gutter??0,percentPosition:!!e.percentPosition,fitWidth:!!e.fitWidth,horizontalOrder:!!e.horizontalOrder,transitionDuration:e.transitionDuration!==void 0?e.transitionDuration:300,stagger:e.stagger||0,resize:e.resize!==!1,autoImages:e.autoImages!==!1,useNativeCSSGrid:e.useNativeCSSGrid!==!1,ariaRole:e.ariaRole||"region",ariaLabel:e.ariaLabel||this.t("gallery"),i18n:e.i18n||{},onLayout:e.onLayout||(()=>{}),onItemPlaced:e.onItemPlaced||(()=>{})};let o=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("grid-template-rows","masonry");this.options.useNativeCSSGrid&&o?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native")):this.root.classList.add("wulf-masonry"),this.initAccessibility(),this.applyTransitionDuration(),this.reloadItems(),this.initObservers(),this.initImages(),this.layout()}get items(){return[...this._items]}initAccessibility(){this.options.ariaRole&&!this.root.hasAttribute("role")&&(this.root.setAttribute("role",this.options.ariaRole),this.wasRoleInferred=!0);let t=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("gallery");t&&!this.root.hasAttribute("aria-label")&&(this.root.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.wasAriaLabelInferred=!0)}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel){let e=this.t("gallery");this.root.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.options.ariaLabel=e}}applyTransitionDuration(){let t=this.options.transitionDuration,e=typeof t=="number"?`${t}ms`:t;this.root.style.setProperty("--wulf-masonry-duration",e)}reloadItems(){if(this.isDestroyed)return;let t=[];if(this.options.itemSelector==="> *")t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"));else try{t=Array.from(this.root.querySelectorAll(this.options.itemSelector)).filter(e=>e.parentElement===this.root&&!e.hasAttribute("data-masonry-ignore"))}catch{t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"))}this._items=t;for(let e of this._items)e.classList.add("wulf-masonry-item"),this.itemResizeObserver&&this.itemResizeObserver.observe(e)}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let t=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(e=>{for(let o of e){let s=o.contentRect.width;Math.abs(s-t)>=1&&(t=s,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(()=>{this.scheduleLayout()});for(let e of this._items)this.itemResizeObserver.observe(e)}initImages(){if(!this.options.autoImages)return;let t=Array.from(this.root.querySelectorAll("img"));for(let e of t)if(!e.complete){let o=()=>{let s=()=>{this.pendingImageListeners=this.pendingImageListeners.filter(n=>n.handler!==s),this.isDestroyed||this.scheduleLayout()};this.pendingImageListeners.push({img:e,handler:s}),e.addEventListener("load",s,{once:!0})};typeof e.decode=="function"?e.decode().then(()=>{this.isDestroyed||this.scheduleLayout()}).catch(()=>{o()}):o()}}scheduleLayout(){this.isDestroyed||(this.layoutRafId!==null&&cancelAnimationFrame(this.layoutRafId),this.layoutRafId=requestAnimationFrame(()=>{this.layoutRafId=null,this.layout()}))}layout(){if(this.isDestroyed)return;if(this.syncAccessibilityLabels(),this.isNativeCSSGrid){this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true");let t=U.calculate(this.root,this._items,this.options);this.root.style.height=`${t.containerHeight}px`,this.options.fitWidth&&t.fittedWidth!==void 0?(this.root.style.width=`${t.fittedWidth}px`,this.root.classList.add("wulf-masonry--fit-width")):this.root.classList.remove("wulf-masonry--fit-width");let e=this.options.stagger,o=this.options.percentPosition&&t.containerWidth>0;for(let s=0;s<t.positions.length;s++){let n=t.positions[s],a=n.element;if(o){let r=Number((n.width/t.containerWidth*100).toFixed(4));a.style.setProperty("--wulf-masonry-w",`${r}%`)}else a.style.setProperty("--wulf-masonry-w",`${n.width}px`);a.style.setProperty("--wulf-masonry-x",`${n.x}px`),a.style.setProperty("--wulf-masonry-y",`${n.y}px`),e>0?a.style.transitionDelay=`${s*e}ms`:a.style.removeProperty("transition-delay"),a.classList.remove("wulf-masonry-item--hidden"),this.options.onItemPlaced(a,n)}this.root.setAttribute("aria-busy","false"),this.options.onLayout(t.positions)}append(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let o=document.createDocumentFragment();for(let s of e)s.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),o.appendChild(s);this.root.appendChild(o),this.reloadItems(),this.initImages(),this.layout()}prepend(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let o=this.root.firstChild,s=document.createDocumentFragment();for(let n of e)n.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),s.appendChild(n);this.root.insertBefore(s,o),this.reloadItems(),this.initImages(),this.layout()}remove(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;for(let n of e)n.classList.add("wulf-masonry-item--hidden");let o=typeof this.options.transitionDuration=="number"?this.options.transitionDuration:300;if(o<=0){for(let n of e)n.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(n),this.root.removeChild(n));this.reloadItems(),this.layout();return}let s=window.setTimeout(()=>{if(this.removeTimers.delete(s),!this.isDestroyed){for(let n of e)n.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(n),this.root.removeChild(n));this.reloadItems(),this.layout()}},o);this.removeTimers.add(s)}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(let t of this.removeTimers)clearTimeout(t);this.removeTimers.clear();for(let{img:t,handler:e}of this.pendingImageListeners)t.removeEventListener("load",e);this.pendingImageListeners=[],this.layoutRafId!==null&&(cancelAnimationFrame(this.layoutRafId),this.layoutRafId=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.itemResizeObserver&&(this.itemResizeObserver.disconnect(),this.itemResizeObserver=null),this.root.classList.remove("wulf-masonry","wulf-masonry--native","wulf-masonry--fit-width"),this.root.removeAttribute("aria-busy"),this.wasRoleInferred&&this.root.getAttribute("role")===this.options.ariaRole&&this.root.removeAttribute("role"),this.wasAriaLabelInferred&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.root.removeAttribute("aria-label"),this.root.style.removeProperty("--wulf-masonry-duration"),this.originalContainerStyles.height?this.root.style.height=this.originalContainerStyles.height:this.root.style.removeProperty("height"),this.originalContainerStyles.width?this.root.style.width=this.originalContainerStyles.width:this.root.style.removeProperty("width");for(let t of this._items)t.classList.remove("wulf-masonry-item","wulf-masonry-item--hidden"),t.style.removeProperty("--wulf-masonry-w"),t.style.removeProperty("--wulf-masonry-x"),t.style.removeProperty("--wulf-masonry-y"),t.style.removeProperty("transition-delay");this._items=[]}}};P._i18n=j,P.i18n=j;var St=P;if(typeof window<"u"){let m=window,i=m.Wulf||{};m.Wulf=i,i.Masonry=Object.assign(P,{Masonry:P,LayoutEngine:U,i18n:j})}var mt={};J(mt,{LocalizedComponent:()=>S,Toast:()=>B,ToastInstance:()=>Q,ToastManager:()=>q,createI18nManager:()=>A,default:()=>xt,toastEn:()=>dt,toastFr:()=>pt,toastI18n:()=>W});var pt={closeButton:"Fermer la notification"};var dt={closeButton:"Close notification"};var W=A("fr",{fr:pt,en:dt});var It=1,Q=class{constructor(i,t){this._isClosed=!1;this.timerId=null;this.remainingTime=0;this.timerStartTime=0;this.isPaused=!1;this.id=`wulf-toast-${It++}`,this.options=Object.freeze({...i}),this.onDismissCallback=t;let e=i.duration===void 0?4e3:i.duration;typeof e=="number"&&e>0?this.remainingTime=e:this.remainingTime=0,this.element=this.createDOM(),this.bindEvents()}get isClosed(){return this._isClosed}createDOM(){let i=document.createElement("div");i.id=this.id,i.className="wulf-toast";let t=this.options.role==="alert"?"alert":"status";if(i.setAttribute("role",t),i.setAttribute("aria-live",t==="alert"?"assertive":"polite"),i.setAttribute("aria-atomic","true"),this.options.backgroundColor&&i.style.setProperty("--wulf-toast-bg",this.options.backgroundColor),this.options.titleColor&&i.style.setProperty("--wulf-toast-title-color",this.options.titleColor),this.options.textColor&&i.style.setProperty("--wulf-toast-text-color",this.options.textColor),this.options.iconColor&&i.style.setProperty("--wulf-toast-icon-color",this.options.iconColor),this.options.closeButtonColor&&i.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor),this.options.icon&&this.options.icon.trim()!==""){let s=document.createElement("span");s.className=`wulf-toast-icon ${this.options.icon.trim()}`,s.setAttribute("aria-hidden","true"),i.appendChild(s)}let e=document.createElement("div");if(e.className="wulf-toast-content",this.options.title&&this.options.title.trim()!==""){let s=document.createElement("div");s.className="wulf-toast-title",this.appendTextWithLineBreaks(s,this.options.title),e.appendChild(s)}if(this.options.message&&this.options.message.trim()!==""){let s=document.createElement("div");s.className="wulf-toast-message",this.appendTextWithLineBreaks(s,this.options.message),e.appendChild(s)}if(i.appendChild(e),this.options.closable??!0){let s=document.createElement("button");s.type="button",s.className="wulf-toast-close",s.setAttribute("aria-label",W.t("closeButton",this.options.i18n)),s.setAttribute("tabindex","0");let n=document.createElement("span");n.className="wulf-toast-close-icon",n.setAttribute("aria-hidden","true"),n.textContent="\xD7",s.appendChild(n),s.addEventListener("click",a=>{a.stopPropagation(),this.close("close-button")}),i.appendChild(s)}return i}appendTextWithLineBreaks(i,t){t.split(/\r\n|\r|\n/).forEach((o,s)=>{s>0&&i.appendChild(document.createElement("br")),i.appendChild(document.createTextNode(o))})}bindEvents(){this.element.addEventListener("click",i=>{this.options.onClick&&this.options.onClick(this,i),this.options.closeOnClick&&this.close("toast-click")}),this.element.addEventListener("mouseenter",()=>this.pauseTimer()),this.element.addEventListener("mouseleave",()=>this.resumeTimer()),this.element.addEventListener("focusin",()=>this.pauseTimer()),this.element.addEventListener("focusout",()=>this.resumeTimer())}startTimer(){this._isClosed||this.remainingTime<=0||(this.timerStartTime=Date.now(),this.timerId=window.setTimeout(()=>{this.close("timeout")},this.remainingTime))}pauseTimer(){if(this._isClosed||this.remainingTime<=0||this.isPaused)return;this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null);let i=Date.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-i),this.isPaused=!0}resumeTimer(){this._isClosed||this.remainingTime<=0||!this.isPaused||(this.isPaused=!1,this.startTimer())}destroyImmediate(i="replace"){this._isClosed||(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,i),this.options.onClose&&this.options.onClose(this,i))}close(i="programmatic",t=!1){return this._isClosed?Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),new Promise(e=>{this.element.classList.add(t?"wulf-toast-hiding-fast":"wulf-toast-hiding");let o=()=>{this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,i),this.options.onClose&&this.options.onClose(this,i),e()};if(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)o();else if(t)window.setTimeout(o,90);else{let n=!1,a=null,r=()=>{n||(n=!0,a!==null&&(window.clearTimeout(a),a=null),this.element.removeEventListener("animationend",r),this.element.removeEventListener("transitionend",r),o())};this.element.addEventListener("animationend",r,{once:!0}),this.element.addEventListener("transitionend",r,{once:!0}),a=window.setTimeout(r,300)}}))}};var Y=class Y{constructor(){this.containers=new Map;this.activeToasts=new Map;this.replaceTokens=new Map;this.pendingReplacements=new Set}static getInstance(){return Y.instance||(Y.instance=new Y),Y.instance}add(i){let t=i.options.position||"top-right",e=this.activeToasts.get(t);if(e||(e=[],this.activeToasts.set(t,e)),i.options.replace&&e.length>0){let s=[...e],n=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,n),this.pendingReplacements.add(t);let a=s.map(r=>r.close("replace",!0));Promise.all(a).then(()=>{this.pendingReplacements.delete(t),this.replaceTokens.get(t)===n&&this.mountToast(i,t)});return}let o=typeof i.options.maxToasts=="number"&&i.options.maxToasts>0?i.options.maxToasts:5;if(e.length>=o){let s=e.length-o+1,n=e.splice(0,s);for(let a of n)a.close("max-limit",!0)}this.mountToast(i,t)}mountToast(i,t){let e=this.getOrCreateContainer(t),o=this.activeToasts.get(t);if(o||(o=[],this.activeToasts.set(t,o)),e.appendChild(i.element),o.push(i),i.options.onOpen)try{i.options.onOpen(i)}catch(s){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",s)}i.startTimer()}remove(i,t){let e=i.options.position||"top-right",o=this.activeToasts.get(e);if(o){let s=o.indexOf(i);if(s!==-1&&o.splice(s,1),o.length===0&&!this.pendingReplacements.has(e)){let n=this.containers.get(e);n&&(!n.firstChild||n.children.length===0)&&(n.parentNode&&n.parentNode.removeChild(n),this.containers.delete(e),this.activeToasts.delete(e))}}}clearAll(i){let t=[];if(i){let e=this.activeToasts.get(i);if(e&&e.length>0){let o=[...e];for(let s of o)t.push(s.close("programmatic"))}else{let o=this.containers.get(i);o&&(!o.firstChild||o.children.length===0)&&(o.parentNode&&o.parentNode.removeChild(o),this.containers.delete(i),this.activeToasts.delete(i))}}else{let e=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let o of e)t.push(this.clearAll(o))}return Promise.all(t).then(()=>{if(!i)for(let[e,o]of Array.from(this.containers.entries()))(!o.firstChild||o.children.length===0)&&(o.parentNode&&o.parentNode.removeChild(o),this.containers.delete(e),this.activeToasts.delete(e))})}getOrCreateContainer(i){let t=this.containers.get(i);return(!t||!document.body.contains(t))&&(t=document.createElement("div"),t.className=`wulf-toast-container wulf-toast-${i}`,t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions removals"),document.body.appendChild(t),this.containers.set(i,t)),t}};Y.instance=null;var q=Y;var B=class extends S{static show(i={}){let t=q.getInstance(),e=new Q(i,(o,s)=>{t.remove(o,s)});return t.add(e),e}static clearAll(i){return q.getInstance().clearAll(i)}};B._i18n=W,B.i18n=W;var xt=B;if(typeof window<"u"){let m=window,i=m.Wulf||{};m.Wulf=i,i.Toast=Object.assign(B,{Toast:B,i18n:W})}return kt(Ct);})();
|
|
2
|
-
|
|
1
|
+
"use strict";var Wulf=(()=>{var lt=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var At=Object.prototype.hasOwnProperty;var $=(d,i)=>{for(var t in i)lt(d,t,{get:i[t],enumerable:!0})},xt=(d,i,t,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of Mt(i))!At.call(d,s)&&s!==t&<(d,s,{get:()=>i[s],enumerable:!(e=Lt(i,s))||e.enumerable});return d};var Ct=d=>xt(lt({},"__esModule",{value:!0}),d);var Ft={};$(Ft,{AmountEngine:()=>B,AuditableComponent:()=>C,BaseInputMask:()=>x,EmailEngine:()=>z,FocusTrap:()=>wt,InputAmountMask:()=>Z,InputEmailMask:()=>J,InputMask:()=>U,LocalizedComponent:()=>A,Mask:()=>ht,MaskEngine:()=>P,MaskHistory:()=>D,MaskKeyboard:()=>V,Masonry:()=>gt,Scroll:()=>pt,Shortcut:()=>Tt,Toast:()=>yt,WulfFocusTrap:()=>W,WulfShortcut:()=>j,createI18nManager:()=>O,default:()=>ut,resolveMaskConstructorArgs:()=>R});var ht={};$(ht,{AmountEngine:()=>B,BaseInputMask:()=>x,EmailEngine:()=>z,InputAmountMask:()=>Z,InputEmailMask:()=>J,InputMask:()=>U,Mask:()=>kt,MaskEngine:()=>P,MaskHistory:()=>D,MaskKeyboard:()=>V,default:()=>ut,resolveMaskConstructorArgs:()=>R});var C=class{getAuditDisableHint(){return"Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement"}runAuditWarning(i=!0){if(!i)return[];let t=this.audit();return t.length>0&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${t.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
|
|
2
|
+
`+t.map(e=>` - ${e}`).join(`
|
|
3
|
+
`)+`
|
|
4
|
+
(${this.getAuditDisableHint()})`),t}checkAriaIdReferences(i,t,e){let s=i.getAttribute(t)?.trim();if(!s)return!1;let n=i.ownerDocument||document,r=s.split(/\s+/).filter(Boolean),o=r.length>0&&r.every(a=>!!n.getElementById(a));return o||e.push(`Attribut ${t}="${s}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),o}};function R(d,i,t){return i&&typeof i=="object"&&"tagName"in i&&i.tagName==="INPUT"?{wrapper:d||null,input:i,options:t||{}}:{wrapper:null,input:d,options:i&&typeof i=="object"&&!("tagName"in i)?i:{}}}var x=class extends C{constructor(t,e,s){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,s=this.input.selectionEnd??e,n="";e!==s?n=this.extractRawSnippet(this.input.value.slice(e,s)):n=this.getRawValue(),n&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",n))};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:n,input:r,options:o}=R(t,e,s);if(!r||typeof r!="object"||r.nodeType!==1||r.tagName!=="INPUT")throw new Error(`[${new.target.name||"InputMask"}] input (HTMLInputElement) est requis.`);this.input=r;let a=this.input.getAttribute("data-mask-create-wrapper")==="true",l=!!(o.createWrapper??a),h=n;if(!h&&l){let k=document.createElement("span");k.className="wulf-mask-wrapper",k.style.display="inline-grid",k.style.gridTemplateColumns="1fr",k.style.gridTemplateRows="1fr",k.style.verticalAlign="middle",k.style.boxSizing="border-box",k.style.position="relative",this.input.parentNode&&this.input.parentNode.insertBefore(k,this.input),k.appendChild(this.input),this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",h=k,this.isWrapperCreated=!0}if(!h)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=h,this.normalizeInputType();let c=this.getAttr("data-mask-focus-only")==="true",u=this.hasAttr("data-disabled"),p=this.getAttr("data-mask-select-on-focus")==="true",f=this.getAttr("data-mask-copy-raw")==="true",m=this.getAttr("data-mask-align")||this.getAttr("data-align"),g=this.getAttr("data-mask-audit"),{disabled:b,align:v,...w}=o,E=b!==void 0?b:!!u,y=o.audit??(g!==null?g!=="false":!0),T=this.input.type==="password";this.options={...w,createWrapper:l,showMaskOnFocus:o.showMaskOnFocus??c??!1,selectAllOnFocus:o.selectAllOnFocus??p??!1,copyRaw:T?!1:o.copyRaw??f??!1,disabled:E,align:v??(m||void 0),emitNativeInput:o.emitNativeInput??!0,audit:y},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 s of e)s.type==="attributes"&&s.attributeName&&this.handleAttributeMutation(s.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,s=this.wrapper.getAttribute("data-align");this.options.align===e&&s===(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 s=this;Object.defineProperty(this.input,"value",{get(){return e.get.call(this)},set(n){let r=String(n??"");e.set.call(this,r),!s.isDestroyed&&s.onNativeValueSet(r)},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,s=this.input.getAttribute("aria-label")?.trim(),n=this.checkAriaIdReferences(this.input,"aria-labelledby",t),r=!!this.input.closest("label"),o=!!(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}"]`)),!s&&!n&&!r&&!o&&!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 l=this.getSpecificAuditWarnings();return t.push(...l),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 It={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:d=>d.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:d=>d.toUpperCase()}},P=class d{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={...It,...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 d(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(s=>new d(s,{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 s=0;s<this.pattern.length;s++){let n=this.pattern[s],r=!1;n==="\\"&&s+1<this.pattern.length&&(r=!0,s++,n=this.pattern[s]);let o=r?void 0:this.tokens[n];o?(e=!1,this.slots.push({char:n,isStatic:!1,isPrefix:!1,token:o,placeholder:this.placeholderChar}),t+=this.placeholderChar):(this.slots.push({char:n,isStatic:!0,isPrefix:e,placeholder:n}),t+=n)}this.fullMaskTemplate=t,this.prefixSlotsCount=0,this.prefixString="";for(let s of this.slots)if(s.isPrefix)this.prefixSlotsCount++,this.prefixString+=s.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 l=a.getPrefix();return l.length>0&&t.toLowerCase().startsWith(l.trim().toLowerCase())}),s=e.length>0?e:this.subEngines,n=[...s].sort((a,l)=>l.getEditableCount()-a.getEditableCount())[0],o=(n?n.extractRaw(t):t).length;for(let a of s)if(a.getEditableCount()>=o)return this.activeEngine=a,a;return this.activeEngine=s[s.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 r=this.selectEngine(i);if(r!==this)return r.extractRaw(i)}let t=String(i??"");if(!t)return"";let e="",s=0,n=0;if(this.prefixSlotsCount>0){for(;s<t.length&&(t[s]===" "||t[s]===" ");)s++;let r=0;for(;s<t.length&&r<this.prefixSlotsCount;){let o=this.slots[r].char,a=t[s];if(a.toUpperCase()===o.toUpperCase())s++,r++;else if(o===" "&&a!==" ")r++;else break}n=this.prefixSlotsCount}for(;s<t.length&&n<this.slots.length;){let r=this.slots[n],o=t[s];if(r.isStatic)o.toUpperCase()===r.char.toUpperCase()&&s++,n++;else if(r.token&&r.token.pattern.test(o)){let a=r.token.transform?r.token.transform(o):o;this.autoLowercase&&!r.token.transform&&(a=a.toLowerCase()),e+=a,s++,n++}else this.strict?s++:(e+=this.autoLowercase?o.toLowerCase():o,s++,n++)}if(!this.strict&&s<t.length){let r=t.slice(s);e+=this.autoLowercase?r.toLowerCase():r}return e}format(i){if(this.subEngines.length>0){let r=this.selectEngine(i);if(r!==this)return r.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 s="",n=0;for(let r=0;r<this.slots.length;r++){let o=this.slots[r];if(o.isStatic){let a=n<e.length,l=n===0&&!!o.isPrefix,h=n>0&&n===e.length;if(a||l||h)s+=o.char;else break}else if(n<e.length){let a=e[n],l=o.token?.transform?o.token.transform(a):a;this.autoLowercase&&!o.token?.transform&&(l=l.toLowerCase()),s+=l,n++}else break}if(!this.strict&&n<e.length){let r=e.substring(n);s+=this.autoLowercase?r.toLowerCase():r}return s}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 s=this.prefixSlotsCount,n=String(i??""),r=String(e??"");if(t<=0||!r)return s;let a=this.extractRaw(n.slice(0,t)).length;if(a===0)return Math.max(s,Math.min(this.getNextEditablePosition(0),r.length));let l=0,h=r.length;for(let c=0;c<r.length&&c<this.slots.length;c++)if(!this.slots[c].isStatic&&(l++,l===a)){h=c+1;break}for(;h<r.length&&this.slots[h]&&this.slots[h].isStatic;)h++;return Math.max(s,Math.min(h,r.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 D=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 V=class{constructor(i){this.delegate=i}handleKeyDown(i){let t=this.delegate.getInput(),e=this.delegate.getEngine(),s=this.delegate.getHistory(),n=e.getPrefixLength(),r=t.selectionStart??0,o=t.selectionEnd??r;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}s.updateCurrentCursor(r);let a=i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey,l=o>r;if(a&&!l){let u=e.getSlots(),p=r<u.length&&u[r].isStatic&&u[r].char===i.key,f=r>0&&r-1<u.length&&u[r-1].isStatic&&u[r-1].char===i.key;if(p||f){i.preventDefault();let g=p?r:r-1,b=e.getNextEditablePosition(g+1);this.delegate.applyMask(t.value,b,!0);return}let m=-1;for(let g=r;g<u.length;g++)if(u[g].isStatic){u[g].char===i.key&&(m=g);break}if(m!==-1){i.preventDefault();let g=m-1;for(;g>=n&&!u[g].isStatic;)g--;g++;let b=m-g,v=t.value.slice(g,r);if(u.slice(g,m).every(y=>!y.token||y.token.pattern.test("0"))&&b>v.length&&v.length>0){let y=b-v.length,T="0".repeat(y)+v,k=t.value.slice(m),st=t.value.slice(0,g)+T+k,S=e.getNextEditablePosition(m+1);this.delegate.applyMask(st,S,!0);return}let E=e.getNextEditablePosition(m+1);this.delegate.applyMask(t.value,E,!0);return}}if(a&&e.isStrict()){let u=e.getEditableCount();if(u>0){let p=e.extractRaw(t.value),f=u-p.length;if(o>r){let m=e.extractRaw(t.value.slice(r,o));f=u-(p.length-m.length)}if(f<=0){i.preventDefault();return}}}if(o>r){if(i.key==="Backspace"||i.key==="Delete"){i.preventDefault();let u=t.value,p=u.slice(0,r)+u.slice(o);this.delegate.applyMask(p,Math.max(n,r));return}return}if(i.key==="ArrowLeft"&&!i.shiftKey&&r<=n){i.preventDefault(),t.setSelectionRange(n,n);return}if(i.key==="Home"&&!i.shiftKey){i.preventDefault(),t.setSelectionRange(n,n);return}if(i.key==="Backspace"&&r<=n){i.preventDefault(),t.setSelectionRange(n,n);return}if(i.key==="Delete"&&r<n){i.preventDefault(),t.setSelectionRange(n,n);return}if(i.key==="Backspace"&&(i.ctrlKey||i.altKey||i.metaKey)){if(i.preventDefault(),r<=n){t.setSelectionRange(n,n);return}let u=r-1;for(;u>=n&&e.isSeparatorAt(u);)u--;for(;u>=n&&!e.isSeparatorAt(u);)u--;let p=Math.max(n,u+1),f=t.value,m=f.slice(0,p)+f.slice(r);this.delegate.applyMask(m,p);return}if(i.key==="Delete"&&(i.ctrlKey||i.altKey||i.metaKey)){i.preventDefault();let u=t.value;if(r>=u.length)return;let p=r;for(;p<u.length&&e.isSeparatorAt(p);)p++;for(;p<u.length&&!e.isSeparatorAt(p);)p++;for(;p<u.length&&e.isSeparatorAt(p);)p++;let f=p,m=u.slice(0,r)+u.slice(f);this.delegate.applyMask(m,r);return}if(i.key==="Backspace"&&r>n){if(e.isSeparatorAt(r-1)){i.preventDefault();let u=r-1;for(;u>n&&e.isSeparatorAt(u-1);)u--;if(u>n){let p=t.value,f=p.slice(0,u-1)+p.slice(r);this.delegate.applyMask(f,u-1)}else this.delegate.applyMask("",n)}return}if(i.key==="Delete"&&r<t.value.length){if(e.isSeparatorAt(r)){i.preventDefault();let u=r;for(;u<t.value.length&&e.isSeparatorAt(u);)u++;if(u<t.value.length){let p=t.value,f=p.slice(0,u)+p.slice(u+1);this.delegate.applyMask(f,r)}}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 U=class extends x{constructor(t,e,s){let n=R(t,e,s),r=n.wrapper,o=n.input,a=n.options,l=r?.getAttribute("data-mask")||o?.getAttribute("data-mask"),h=a.mask||l||"";typeof h=="string"&&h.includes("|")&&(h=h.split("|").map(y=>y.trim()));let c=a.placeholderChar||r?.getAttribute("data-mask-placeholder")||o?.getAttribute("data-mask-placeholder")||"_",u=r?.hasAttribute("data-disabled")||o?.hasAttribute("data-disabled"),p=r?.getAttribute("data-mask-strict")||o?.getAttribute("data-mask-strict"),f=r?.getAttribute("data-mask-auto-lowercase")==="true"||o?.getAttribute("data-mask-auto-lowercase")==="true",m=r?.getAttribute("data-mask-infer-inputmode")??o?.getAttribute("data-mask-infer-inputmode"),g=a.inferInputMode??(m!==null?m!=="false":!0),{disabled:b,...v}=a,w=b!==void 0?b:u?!0:!h||Array.isArray(h)&&h.length===0,E={...v,mask:h,placeholderChar:c,strict:a.strict??(p!==null?p!=="false":!0),autoLowercase:a.autoLowercase??f??!1,disabled:w,resetHistoryOnMaskChange:a.resetHistoryOnMaskChange??!1,inferInputMode:g,onInput:a.onInput||a.oninput,onChange:a.onChange||a.onchange,onComplete:a.onComplete||a.oncomplete};super(r,o,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 D,this.engine=new P(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new V({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(y,T,k)=>this.applyMask(y,T,k),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(),s=!!this.input.getAttribute("placeholder")?.trim(),n=!!this.input.getAttribute("aria-placeholder")?.trim();return!e&&!s&&!n&&!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,s={}){return P.format(t,e,s)}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 s=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=s,this.engine.setStrict(s??!0),this.engine.compile(""),n&&this.history.clear(),this.setDisabled(!0),this.syncInferredInputMode();return}this.options.mask=t,this.options.strict=s,this.engine.setStrict(s??!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 s=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(e===s)return;if(e){let n=e.includes("|")?e.split("|").map(r=>r.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.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,s=t!==e;this.wrapper.classList.toggle("has-selection",s)}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 s=this.getRawValue(),n=this.input.selectionStart??0,r=this.input.selectionEnd??n,o=Math.max(0,e-s.length);if(r>n){let a=this.engine.extractRaw(this.input.value.slice(n,r));o=Math.max(0,e-(s.length-a.length))}o<=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 s=this.history.getCurrent(),n=this.engine.getEditableCount();if(n>0&&this.engine.isStrict()&&s&&s.raw.length>=n&&this.engine.extractRaw(this.input.value).length>n){this.applyMask(s.raw,s.cursor);return}let r=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,r),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 s=(t.clipboardData?.getData("text")||"").trim();if(!s)return;let n=this.engine.getPrefixLength(),r=this.input.selectionStart??0,o=this.input.selectionEnd??r,a=this.input.value,l=this.engine.getEditableCount(),h=this.getRawValue(),u=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),p=s.replace(/[\s.-]+/g,"").toUpperCase(),f=u.length>0&&p.startsWith(u),m=a.slice(0,Math.max(n,r)).replace(/[\s.-]+/g,"").toUpperCase(),g=m.length>=2&&p.startsWith(m),b=Math.max(n,r),v=Math.max(n,o);(f||g)&&(b=0,v=a.length);let w=Math.max(0,l-h.length);if(b!==v){let T=this.engine.extractRaw(a.slice(b,v));w=Math.max(0,l-(h.length-T.length))}if(this.engine.isStrict()&&w<=0)return;let E,y;b===0&&v===a.length?(E=s,y=s.length):(E=a.slice(0,b)+s+a.slice(v),y=b+s.length),this.applyMask(E,y),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,s=this.input.selectionEnd??e;e===s&&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 s=this.engine.getFullMaskTemplate(),n=s.length>t.length?s.substring(t.length):"";this.ghost.textContent="";let r=document.createElement("span");r.className="mask-ghost-typed",r.textContent=t;let o=document.createElement("span");o.className="mask-ghost-remaining",o.textContent=n,this.ghost.appendChild(r),this.ghost.appendChild(o),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,s=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let n="",r=!1;try{n=this.engine.format(t);let o=this.engine.getRemainingMask(n);this.input.value=n,this.lastInternalRemainingMask=o,this.wrapper.setAttribute("data-mask",o),this.updateGhost(n);let a=this.engine.getPrefixLength(),l;if(s||this.isUndoingRedoing)l=Math.max(a,Math.min(e,n.length));else{let h=this.engine.mapCursorPosition(t,e,n);l=Math.max(a,h)}this.input.setSelectionRange(l,l),r=this.isComplete(),this.wrapper.classList.toggle("is-complete",r),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(this.getRawValue(),l)}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 s=this.engine.getFullMaskTemplate();this.lastInternalRemainingMask=s,this.wrapper.setAttribute("data-mask",s),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 s=this.input.value;this.lastValue=s;let n=this.options.disabled?s:this.getRawValue(),r=this.options.disabled?0:this.engine.getEditableCount(),o=this.isComplete(),a={value:s,rawValue:n,isComplete:o,totalSlots:r,filledSlots:this.options.disabled?s.length:n.length},l=this.options.onInput||this.options.oninput;l&&l(s,a),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:a})),this.dispatchNativeInput();let h=this.options.onChange||this.options.onchange;h&&h(a),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:a}));let c=this.options.onComplete||this.options.oncomplete;o&&(c&&c(a),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:a})))}}finally{this.isNotifying=!1}}}};var B=class d{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 s=this.options.decimalSeparator,n=t.indexOf(s);n===-1&&(n=t.search(/[,.]/));let r="",o=null,a=!1;return n!==-1?(r=t.substring(0,n).replace(/\D/g,""),this.options.decimals>0&&(a=!0,o=t.substring(n+1).replace(/\D/g,"").slice(0,this.options.decimals))):r=t.replace(/\D/g,""),r.length>1&&(r=r.replace(/^0+/,"")||"0"),{isNegative:e,integerPart:r,decimalPart:o,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 s=i.substring(0,t),n=s.replace(/\D/g,"").length,r=this.options.decimals>0&&/[,.]/.test(s),{isNegative:o,integerPart:a,decimalPart:l,hasDecimal:h}=this.parse(i),c=l,u=h;if(e&&this.options.decimals>0&&(a||l!==null)&&(u=!0,c===null?c="0".repeat(this.options.decimals):c.length<this.options.decimals&&(c=c+"0".repeat(this.options.decimals-c.length))),o&&!a&&!c&&!u&&this.options.allowNegative){let S="-",H=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(S=`${this.options.currency} -`,H=S.length):(S=`- ${this.options.currency}`,H=1)),{formatted:S,rawNumber:null,rawValue:"-",cursor:H,isValid:!0}}if(!a&&!c&&!u)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let f=(a||"0").replace(/\B(?=(\d{3})+(?!\d))/g,this.options.thousandSeparator);u&&this.options.decimals>0&&(f+=this.options.decimalSeparator+(c??"")),o&&f!=="0"&&(f="-"+f);let m=f;this.options.currency&&(this.options.currencyPosition==="prefix"?m=`${this.options.currency} ${f}`:m=`${f} ${this.options.currency}`);let g=(o?"-":"")+(a||"0")+(l?"."+l:""),b=parseFloat(g);isNaN(b)&&(b=0);let v=b>=this.options.min&&b<=this.options.max,w=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(w=this.options.currency.length+1);let E=0,y=!1,T=w;for(let S=w;S<m.length;S++){let H=m[S];if(H===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(H)?(E++,T=S+1):H===this.options.decimalSeparator&&(y=!0,T=S+1),r){if(y&&E>=n){w=S+1;break}}else if(E>=n){w=S+1;break}}n>0&&E<n&&T>w&&(w=T);let k=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,st=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,m.length-this.options.currency.length-1):m.length;return w=Math.max(k,Math.min(w,Math.max(k,st))),{formatted:m,rawNumber:b,rawValue:g,cursor:w,isValid:v}}static format(i,t={}){let e=new d(t),s=typeof i=="number"?i.toString():i;return e.format(s).formatted}escapeRegExp(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var Z=class extends x{constructor(t,e,s){let n=R(t,e,s),r=n.wrapper,o=n.input,a=n.options,l=r?.getAttribute("data-mask-pad-decimals")==="true"||o?.getAttribute("data-mask-pad-decimals")==="true",h=o?.getAttribute("data-mask-align")||o?.getAttribute("data-align")||r?.getAttribute("data-mask-align")||r?.getAttribute("data-align"),c={align:a.align??h??"right",padDecimalsOnBlur:a.padDecimalsOnBlur??l??!1,...a};super(r,o,c);this.isUndoingRedoing=!1;this.isApplying=!1;this.isComposing=!1;this.lastValue="";this.cutTimerId=null;this.resetTimerId=null;this.input.inputMode="decimal",this.history=new D,this.engine=new B(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 B.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 s=this.engine.format(t,e);this.setNativeValue(s.formatted),this.input.setSelectionRange(s.cursor,s.cursor),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(s.rawValue,s.cursor),this.updateGhost(s),this.lastValue!==s.formatted&&(this.lastValue=s.formatted,this.notifyChange(s))}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 s=document.createElement("span");s.className="mask-ghost-remaining",s.textContent=e,this.ghost.appendChild(s);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,s=this.input.selectionEnd??0;if(e===s&&e>0){let n=this.input.value,r=n[e-1];if(r===this.engine.options.thousandSeparator||r===" "){t.preventDefault();let o=Math.max(0,e-2),a=n.slice(0,o)+n.slice(e);this.applyAmount(a,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,s=this.input.selectionEnd??0;if(e===s&&e<this.input.value.length){let n=this.input.value,r=n[e];if(r===this.engine.options.thousandSeparator||r===" "){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}}}}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 s=this.input.value,n=this.options.currency;if(n){if(this.options.currencyPosition==="prefix"){let r=n.length+1;t<r&&this.input.setSelectionRange(r,r)}else if(this.options.currencyPosition==="suffix"){let r=Math.max(0,s.length-n.length-1);t>r&&this.input.setSelectionRange(r,r)}}}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 Y=class Y{constructor(i={}){this.defaultDomain=null;this.defaultTld="__";this.domains=i.domains&&i.domains.length>0?i.domains:Y.DEFAULT_DOMAINS,this.tlds=i.tlds&&i.tlds.length>0?i.tlds.map(t=>t.trim().replace(/^\./,"")).filter(Boolean):[...Y.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):[...Y.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 s=t.substring(e+1);if(s.length===0)return this.suggestOnAt?[...this.domains]:[];let n=s.toLowerCase();return this.domains.filter(r=>r.toLowerCase().startsWith(n)&&r.toLowerCase()!==n)}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 s=e.indexOf("@"),n=e.substring(0,s),r=e.substring(s+1);if(e.indexOf("@",s+1)!==-1)return{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let o=this.getMatchingDomains(i);if(o.length>0){let f=(t%o.length+o.length)%o.length,m=o[f],g=r.toLowerCase(),b=m.substring(g.length);return{full:`${n}@${m}`,remaining:b,matchedDomain:m,isHintOnly:!1}}if(r.length===0||r.startsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let a=r.toLowerCase();if(this.domains.some(f=>f.toLowerCase()===a))return{full:i,remaining:"",matchedDomain:r,isHintOnly:!1};let l=r.lastIndexOf(".");if(l===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let f=this.defaultTld.includes("_"),m=`.${this.defaultTld}`,g=`${r}.${this.defaultTld}`;return{full:f?i:`${n}@${g}`,remaining:m,matchedDomain:f?null:g,isHintOnly:f}}let h=r.substring(0,l),c=r.substring(l+1);if(!h||h.endsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};if(c.length===0){if(this.defaultTld&&!this.defaultTld.includes("_")){let f=`${h}.${this.defaultTld}`;return{full:`${n}@${f}`,remaining:this.defaultTld,matchedDomain:f,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 u=c.toLowerCase(),p=this.getMatchingTlds(c);if(p.length>0){let f=(t%p.length+p.length)%p.length,m=p[f],g=m.substring(u.length),b=`${h}.${m}`;return{full:`${n}@${b}`,remaining:g,matchedDomain:b,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&c.length<this.defaultTld.length){let f=this.defaultTld.substring(c.length);if(f.includes("_"))return{full:i,remaining:f,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};Y.DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"],Y.DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];var z=Y;var J=class extends x{constructor(t,e,s){let n=R(t,e,s),r=n.wrapper,o=n.input,a=n.options,l=r?.getAttribute("data-mask-cycle-suggestions")==="true"||o?.getAttribute("data-mask-cycle-suggestions")==="true",h=r?.getAttribute("data-mask-auto-lowercase")==="true"||o?.getAttribute("data-mask-auto-lowercase")==="true",c=r?.getAttribute("data-mask-aria-autocomplete")??o?.getAttribute("data-mask-aria-autocomplete"),u=a.setAriaAutocomplete??(c!==null?c!=="false":!0),p=r?.getAttribute("data-mask-tlds")??o?.getAttribute("data-mask-tlds"),f=a.tlds??(p?p.split(",").map(v=>v.trim()).filter(Boolean):void 0),m=r?.getAttribute("data-mask-default-tld")??o?.getAttribute("data-mask-default-tld"),g=a.defaultTld!==void 0?a.defaultTld:m!==null?m==="false"||m==="none"?null:m==="true"?!0:m:void 0,b={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:a.cycleSuggestions??l??!1,autoLowercase:a.autoLowercase??h??!1,setAriaAutocomplete:u,...a,...f!==void 0?{tlds:f}:{},...g!==void 0?{defaultTld:g}:{}};super(r,o,b);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 z(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 s=document.createElement("span");s.className="mask-ghost-typed",s.textContent=t;let n=document.createElement("span");n.className="mask-ghost-remaining",n.textContent=this.currentSuggestion.remaining,this.ghost.appendChild(s),this.ghost.appendChild(n)}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,s=this.input.value.toLowerCase();s!==this.input.value&&(this.setNativeValue(s),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,n=(this.input.selectionStart??0)===this.input.value.length,r=this.input.value.length>0;if(this.options.cycleSuggestions&&e&&r&&n){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&&r&&this.options.completeOnTab){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="Enter"&&e&&r&&this.options.completeOnEnter){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="ArrowRight"&&e&&r&&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(){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(s=>s.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 kt={BaseInputMask:x,InputMask:U,MaskEngine:P,MaskHistory:D,MaskKeyboard:V,AmountEngine:B,InputAmountMask:Z,EmailEngine:z,InputEmailMask:J};if(typeof window<"u"){let d=window,i=d.Wulf||{};d.Wulf=i,i.Mask=kt}var ut=U;var pt={};$(pt,{LocalizedComponent:()=>A,Scroll:()=>St,ScrollBlock:()=>K,createI18nManager:()=>O,default:()=>Ot,scrollEn:()=>dt,scrollFr:()=>ct,scrollI18n:()=>tt});var A=class extends C{static setLocale(i){this._i18n&&this._i18n.setLocale(i)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(i,t){this._i18n&&this._i18n.registerLocale(i,t)}static setI18n(i){this._i18n&&this._i18n.setI18n(i)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(i,t){return this._i18n?this._i18n.t(i,t):String(i)}constructor(i){super(),this.i18nOverrides=i}t(i){let t=this.constructor;return t._i18n?t._i18n.t(i,this.i18nOverrides):String(i)}};function at(d){return d.trim().toLowerCase().replace(/_/g,"-")}function Dt(d){let i=d.indexOf("-");return i>0?d.slice(0,i):null}function Q(d,i){if(!i)return d;for(let t of Object.keys(i))i[t]!==void 0&&(d[t]=i[t]);return d}function O(d,i){let t=at(d),e={};for(let[a,l]of Object.entries(i))e[at(a)]={...l};let s=t,n={...e},r={};function o(){let a=[],l=n[s];l&&a.push(l);let h=Dt(s);return h&&n[h]&&a.push(n[h]),a}return{setLocale(a){a&&a.trim()&&(s=at(a))},getLocale(){return s},registerLocale(a,l){if(!a||!a.trim()||!l)return;let h=at(a);n[h]=Q({...n[h]||{}},l)},setI18n(a){a&&(r=Q({...r},a))},t(a,l){if(l&&l[a]!==void 0)return String(l[a]);if(r[a]!==void 0)return String(r[a]);for(let c of o())if(c[a]!==void 0)return String(c[a]);let h=n[t]||e[t];return h&&h[a]!==void 0?String(h[a]):String(a)},getAll(a){let l={},h=n[t]||e[t];Q(l,h);let c=o().reverse();for(let u of c)Q(l,u);return Q(l,r),Q(l,a),l},reset(){s=t,r={},n={};for(let[a,l]of Object.entries(e))n[a]={...l}}}}var ct={viewport:"Zone de contenu d\xE9filable",verticalThumb:"D\xE9filement vertical",horizontalThumb:"D\xE9filement horizontal"};var dt={viewport:"Scrollable content area",verticalThumb:"Vertical scroll",horizontalThumb:"Horizontal scroll"};var tt=O("fr",{fr:ct,en:dt});var Et=0,K=class extends A{constructor(t,e){super(e?.i18n);this.createdViewport=!1;this.wasIdGenerated=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.hasExplicitAriaLabel=!1;this.lastInferredAriaLabel="";this.isDragging=!1;this.dragStartPos=0;this.dragStartScroll=0;this.atBottom=!1;this.atTop=!0;this.atRight=!1;this.atLeft=!0;let s=typeof t=="string"?document.querySelector(t):t;if(!s)throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${t}".`);this.root=s,this.hasExplicitAriaLabel=!!(e?.ariaLabel||e?.i18n?.viewport),this.options={axis:e?.axis||"y",autoHide:e?.autoHide??!0,autoHideDelay:e?.autoHideDelay??1e3,alwaysVisible:e?.alwaysVisible??!1,ariaLabel:e?.ariaLabel||this.t("viewport"),i18n:e?.i18n||{},minThumbSize:e?.minThumbSize??24,edgeThreshold:e?.edgeThreshold??10,onScroll:e?.onScroll||(()=>{}),onTotalScroll:e?.onTotalScroll||(()=>{}),onTotalScrollBack:e?.onTotalScrollBack||(()=>{}),audit:e?.audit??!0},this.boundOnScroll=this.handleScroll.bind(this),this.boundOnMouseEnter=this.handleMouseEnter.bind(this),this.boundOnMouseLeave=this.handleMouseLeave.bind(this),this.boundOnFocusIn=this.handleFocusIn.bind(this),this.boundOnFocusOut=this.handleFocusOut.bind(this),this.boundPointerMove=this.handlePointerMove.bind(this),this.boundPointerUp=this.handlePointerUp.bind(this),this.viewport=this.setupViewport(),this.setupAccessibility(),this.setupScrollbars(),this.setupEventListeners(),this.setupObserver(),this.update(),this.runAuditWarning(this.options.audit)}setupViewport(){this.root.classList.add("wulf-scrollblock"),this.options.alwaysVisible&&this.root.classList.add("is-always-visible"),this.options.axis==="both"&&this.root.classList.add("has-both-axes");let t=this.root.querySelector(":scope > .wulf-scrollblock-viewport");if(t)return t;let e=document.createElement("div");for(e.className="wulf-scrollblock-viewport";this.root.firstChild;)e.appendChild(this.root.firstChild);return this.root.appendChild(e),this.createdViewport=!0,e}setupAccessibility(){if(this.viewport.id||(Et+=1,this.viewport.id=`wulf-scrollblock-vp-${Et}`,this.wasIdGenerated=!0),this.viewport.hasAttribute("role")||(this.viewport.setAttribute("role","region"),this.wasRoleInferred=!0),!this.viewport.hasAttribute("aria-label")){let t=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("viewport");this.viewport.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.wasAriaLabelInferred=!0}}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel){let e=this.t("viewport");this.viewport.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.options.ariaLabel=e}this.thumbY&&this.thumbY.setAttribute("aria-label",this.t("verticalThumb")),this.thumbX&&this.thumbX.setAttribute("aria-label",this.t("horizontalThumb"))}setupScrollbars(){(this.options.axis==="y"||this.options.axis==="both")&&(this.trackY=document.createElement("div"),this.trackY.className="wulf-scrollblock-track wulf-scrollblock-vertical",this.trackY.setAttribute("aria-hidden","true"),this.thumbY=document.createElement("div"),this.thumbY.className="wulf-scrollblock-thumb",this.thumbY.setAttribute("role","scrollbar"),this.thumbY.setAttribute("aria-orientation","vertical"),this.thumbY.setAttribute("aria-controls",this.viewport.id),this.thumbY.setAttribute("aria-valuenow","0"),this.thumbY.setAttribute("aria-valuemin","0"),this.thumbY.setAttribute("aria-valuemax","100"),this.thumbY.setAttribute("aria-label",this.t("verticalThumb")),this.trackY.appendChild(this.thumbY),this.root.appendChild(this.trackY),this.attachTrackListeners(this.trackY,this.thumbY,"y")),(this.options.axis==="x"||this.options.axis==="both")&&(this.trackX=document.createElement("div"),this.trackX.className="wulf-scrollblock-track wulf-scrollblock-horizontal",this.trackX.setAttribute("aria-hidden","true"),this.thumbX=document.createElement("div"),this.thumbX.className="wulf-scrollblock-thumb",this.thumbX.setAttribute("role","scrollbar"),this.thumbX.setAttribute("aria-orientation","horizontal"),this.thumbX.setAttribute("aria-controls",this.viewport.id),this.thumbX.setAttribute("aria-valuenow","0"),this.thumbX.setAttribute("aria-valuemin","0"),this.thumbX.setAttribute("aria-valuemax","100"),this.thumbX.setAttribute("aria-label",this.t("horizontalThumb")),this.trackX.appendChild(this.thumbX),this.root.appendChild(this.trackX),this.attachTrackListeners(this.trackX,this.thumbX,"x"))}attachTrackListeners(t,e,s){e.addEventListener("pointerdown",n=>{n.preventDefault(),n.stopPropagation(),this.isDragging=!0,this.dragAxis=s,this.dragPointerId=n.pointerId,this.dragStartPos=s==="y"?n.clientY:n.clientX,this.dragStartScroll=s==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,e.setPointerCapture(n.pointerId),e.classList.add("is-active"),this.root.classList.add("is-dragging"),window.addEventListener("pointermove",this.boundPointerMove),window.addEventListener("pointerup",this.boundPointerUp),window.addEventListener("pointercancel",this.boundPointerUp)}),t.addEventListener("pointerdown",n=>{if(n.target===e)return;n.preventDefault();let r=t.getBoundingClientRect(),o=s==="y"?n.clientY-r.top:n.clientX-r.left,a=s==="y"?r.height:r.width,l=s==="y"?this.viewport.clientHeight:this.viewport.clientWidth,h=s==="y"?this.viewport.scrollHeight:this.viewport.scrollWidth,u=o/a*(h-l);this.scrollTo(s==="y"?{top:u}:{left:u},{smooth:!0})})}setupEventListeners(){this.viewport.addEventListener("scroll",this.boundOnScroll,{passive:!0}),this.options.autoHide&&!this.options.alwaysVisible&&(this.root.addEventListener("mouseenter",this.boundOnMouseEnter),this.root.addEventListener("mouseleave",this.boundOnMouseLeave),this.root.addEventListener("focusin",this.boundOnFocusIn),this.root.addEventListener("focusout",this.boundOnFocusOut))}setupObserver(){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{window.requestAnimationFrame(()=>this.update())}),this.resizeObserver.observe(this.root),this.resizeObserver.observe(this.viewport),this.viewport.firstElementChild&&this.resizeObserver.observe(this.viewport.firstElementChild))}handlePointerMove(t){if(!this.isDragging||!this.dragAxis)return;let e=this.dragAxis==="y",s=(e?t.clientY:t.clientX)-this.dragStartPos,n=e?this.trackY:this.trackX,r=e?this.thumbY:this.thumbX;if(!n||!r)return;let o=e?n.clientHeight:n.clientWidth,a=e?r.clientHeight:r.clientWidth,l=e?this.viewport.clientHeight:this.viewport.clientWidth,c=(e?this.viewport.scrollHeight:this.viewport.scrollWidth)-l,u=o-a;if(u<=0||c<=0)return;let p=c/u,f=this.dragStartScroll+s*p;e?this.viewport.scrollTop=Math.max(0,Math.min(c,f)):this.viewport.scrollLeft=Math.max(0,Math.min(c,f))}handlePointerUp(t){if(this.isDragging){if(this.dragPointerId!==void 0){let e=this.dragAxis==="y"?this.thumbY:this.thumbX;e&&e.hasPointerCapture(this.dragPointerId)&&e.releasePointerCapture(this.dragPointerId)}window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.isDragging=!1,this.dragAxis=void 0,this.dragPointerId=void 0,this.thumbY?.classList.remove("is-active"),this.thumbX?.classList.remove("is-active"),this.root.classList.remove("is-dragging"),this.scheduleAutoHide()}}handleScroll(){this.syncThumbs();let{scrollTop:t,scrollLeft:e,scrollHeight:s,scrollWidth:n,clientHeight:r,clientWidth:o}=this.viewport,a=Math.max(0,s-r),l=Math.max(0,n-o),h=a>0?t/a:0,c=l>0?e/l:0;this.options.onScroll({top:t,left:e,maxTop:a,maxLeft:l,progressY:Math.round(h*100),progressX:Math.round(c*100)});let u=this.options.edgeThreshold;if(a>0){let p=t>=a-u,f=t<=u;p&&!this.atBottom&&this.options.onTotalScroll("bottom"),f&&!this.atTop&&this.options.onTotalScrollBack("top"),this.atBottom=p,this.atTop=f}if(l>0){let p=e>=l-u,f=e<=u;p&&!this.atRight&&this.options.onTotalScroll("right"),f&&!this.atLeft&&this.options.onTotalScrollBack("left"),this.atRight=p,this.atLeft=f}this.options.autoHide&&!this.options.alwaysVisible&&(this.root.classList.add("is-scrolling"),this.scheduleAutoHide())}syncThumbs(){let{scrollTop:t,scrollLeft:e,scrollHeight:s,scrollWidth:n,clientHeight:r,clientWidth:o}=this.viewport;if(this.thumbY&&this.trackY){let a=s-r,l=this.trackY.clientHeight,h=this.thumbY.clientHeight,c=l-h;if(a>0&&c>0){let u=t/a,p=Math.max(0,Math.min(c,u*c));this.thumbY.style.transform=`translate3d(0, ${p}px, 0)`,this.thumbY.setAttribute("aria-valuenow",String(Math.round(u*100)))}}if(this.thumbX&&this.trackX){let a=n-o,l=this.trackX.clientWidth,h=this.thumbX.clientWidth,c=l-h;if(a>0&&c>0){let u=e/a,p=Math.max(0,Math.min(c,u*c));this.thumbX.style.transform=`translate3d(${p}px, 0, 0)`,this.thumbX.setAttribute("aria-valuenow",String(Math.round(u*100)))}}}handleMouseEnter(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleMouseLeave(){this.scheduleAutoHide()}handleFocusIn(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleFocusOut(){this.scheduleAutoHide()}clearAutoHideTimer(){this.hideTimer&&(window.clearTimeout(this.hideTimer),this.hideTimer=void 0)}scheduleAutoHide(){this.options.alwaysVisible||!this.options.autoHide||this.isDragging||(this.clearAutoHideTimer(),this.hideTimer=window.setTimeout(()=>{this.root.classList.remove("is-scrolling"),this.root.classList.remove("is-visible")},this.options.autoHideDelay))}update(){this.syncAccessibilityLabels();let{scrollHeight:t,clientHeight:e,scrollWidth:s,clientWidth:n}=this.viewport,r=t>e,o=s>n;if(this.root.classList.toggle("has-scroll-y",r),this.root.classList.toggle("has-scroll-x",o),r||o?this.viewport.setAttribute("tabindex","0"):this.viewport.removeAttribute("tabindex"),this.trackY&&this.thumbY&&r){let a=this.trackY.clientHeight,l=Math.max(this.options.minThumbSize,a*(e/t));this.thumbY.style.height=`${l}px`}if(this.trackX&&this.thumbX&&o){let a=this.trackX.clientWidth,l=Math.max(this.options.minThumbSize,a*(n/s));this.thumbX.style.width=`${l}px`}this.syncThumbs()}scrollTo(t,e){let s=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,n=typeof t=="object"&&t!==null&&!(t instanceof HTMLElement)?t.smooth:void 0,o=(e?.smooth??n??!0)&&!s?"smooth":"auto",a=Math.max(0,this.viewport.scrollHeight-this.viewport.clientHeight),l=Math.max(0,this.viewport.scrollWidth-this.viewport.clientWidth),h,c;if(typeof t=="number")h=t;else if(typeof t=="string")switch(t){case"top":h=0;break;case"bottom":h=a;break;case"left":c=0;break;case"right":c=l;break;default:{if(/^-?\d+(\.\d+)?%$/.test(t.trim())){let p=Math.max(0,Math.min(100,parseFloat(t.trim())))/100;this.options.axis==="x"?c=l*p:this.options.axis==="both"?(h=a*p,c=l*p):h=a*p;break}let u=null;try{u=this.viewport.querySelector(t)}catch{u=null}u&&(h=u.offsetTop,c=u.offsetLeft);break}}else t instanceof HTMLElement?(h=t.offsetTop,c=t.offsetLeft):typeof t=="object"&&(h=t.top,c=t.left);this.viewport.scrollTo({top:h!==void 0?Math.max(0,Math.min(a,h)):void 0,left:c!==void 0?Math.max(0,Math.min(l,c)):void 0,behavior:o})}audit(){let t=[],e=this.checkAriaIdReferences(this.viewport,"aria-labelledby",t),s=this.checkAriaIdReferences(this.root,"aria-labelledby",t),n=e||s,r=this.root.getAttribute("aria-label")?.trim(),o=!this.wasAriaLabelInferred&&!!this.viewport.getAttribute("aria-label")?.trim();return!this.hasExplicitAriaLabel&&!o&&!r&&!n&&t.push("Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour d\xE9crire la zone d\xE9filable (WCAG 4.1.2)."),this.options.minThumbSize<24&&t.push(`Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`),t}getAuditPrefix(){return"Wulf.Scroll"}getAuditTargetLabel(){return this.root.id?`#${this.root.id}`:`<${this.root.tagName.toLowerCase()}.wulf-scrollblock>`}destroy(){if(this.clearAutoHideTimer(),this.resizeObserver&&this.resizeObserver.disconnect(),this.viewport.removeEventListener("scroll",this.boundOnScroll),this.root.removeEventListener("mouseenter",this.boundOnMouseEnter),this.root.removeEventListener("mouseleave",this.boundOnMouseLeave),this.root.removeEventListener("focusin",this.boundOnFocusIn),this.root.removeEventListener("focusout",this.boundOnFocusOut),window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.trackY?.remove(),this.trackX?.remove(),this.root.classList.remove("wulf-scrollblock","has-scroll-y","has-scroll-x","has-both-axes","is-visible","is-scrolling","is-dragging","is-always-visible"),this.createdViewport&&this.viewport.parentElement===this.root){for(;this.viewport.firstChild;)this.root.insertBefore(this.viewport.firstChild,this.viewport);this.viewport.remove()}else this.viewport.removeAttribute("tabindex"),this.wasIdGenerated&&this.viewport.removeAttribute("id"),this.wasRoleInferred&&this.viewport.getAttribute("role")==="region"&&this.viewport.removeAttribute("role"),this.wasAriaLabelInferred&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.viewport.removeAttribute("aria-label")}};K._i18n=tt,K.i18n=tt;var St={ScrollBlock:K,i18n:tt};var Ot=K;if(typeof window<"u"){let d=window,i=d.Wulf||{};d.Wulf=i,i.Scroll=St}var gt={};$(gt,{LayoutEngine:()=>G,LocalizedComponent:()=>A,Masonry:()=>F,createI18nManager:()=>O,default:()=>Ht,masonryEn:()=>ft,masonryFr:()=>mt,masonryI18n:()=>et});var G=class{static parseGutter(i){return typeof i=="number"?{x:Math.max(0,i),y:Math.max(0,i)}:i&&typeof i=="object"?{x:Math.max(0,Number(i.x)||0),y:Math.max(0,Number(i.y)||0)}:{x:0,y:0}}static resolveColumnWidth(i,t,e){if(typeof e=="number"&&e>0)return e;if(typeof e=="string"){let n=i.querySelector(e);if(n){let o=n.getBoundingClientRect().width;if(o>0)return o}let r=parseFloat(e);if(!isNaN(r)&&r>0)return e.endsWith("%")?i.getBoundingClientRect().width*r/100:r}if(e instanceof HTMLElement){let n=e.getBoundingClientRect().width;if(n>0)return n}if(t){let n=t.getBoundingClientRect().width;if(n>0)return n}let s=i.getBoundingClientRect().width;return s>0?s:200}static getItemSpan(i,t,e,s){let n=i.getAttribute("data-masonry-span")||i.dataset.masonrySpan;if(n){let o=parseInt(n,10);if(!isNaN(o)&&o>0)return Math.min(s,o)}let r=i.className.match(/(?:^|\s)(?:span|col-span)-(\d+)(?:\s|$)/);if(r&&r[1]){let o=parseInt(r[1],10);if(!isNaN(o)&&o>0)return Math.min(s,o)}return 1}static calculate(i,t,e){let n=i.getBoundingClientRect().width,{x:r,y:o}=this.parseGutter(e.gutter);if(n<=0||t.length===0)return{cols:1,colWidth:n,gutterX:r,gutterY:o,containerHeight:0,containerWidth:n,positions:[]};let a=t[0]||null,l=this.resolveColumnWidth(i,a,e.columnWidth),h=Math.floor((n+r)/(l+r));h=Math.max(1,h),!e.columnWidth&&h>1&&(l=(n-(h-1)*r)/h);let c=e.fitWidth?h*l+(h-1)*r:void 0,u=new Array(h).fill(0),p=[],f=t.map(v=>{let w=v.getBoundingClientRect().height;return w>0?w:50}),m=0;for(let v=0;v<t.length;v++){let w=t[v],E=f[v],y=this.getItemSpan(w,l,r,h),T=0,k=0;if(e.horizontalOrder){m+y>h&&(m=0),T=m;let M=0;for(let L=0;L<y;L++)u[T+L]>M&&(M=u[T+L]);k=M,m=(T+y)%h}else if(y===1){let M=u[0];T=0;for(let L=1;L<h;L++)u[L]<M&&(M=u[L],T=L);k=M}else{let M=1/0;T=0;for(let L=0;L<=h-y;L++){let rt=0;for(let ot=0;ot<y;ot++)u[L+ot]>rt&&(rt=u[L+ot]);rt<M&&(M=rt,T=L)}k=M}let st=y*l+(y-1)*r,S=T*(l+r);p.push({element:w,x:S,y:k,width:st,height:E,column:T,span:y});let H=k+E+o;for(let M=0;M<y;M++)u[T+M]=H}let g=0;for(let v=0;v<h;v++)u[v]>g&&(g=u[v]);let b=Math.max(0,g>0?g-o:0);return{cols:h,colWidth:l,gutterX:r,gutterY:o,containerHeight:b,containerWidth:n,fittedWidth:c,positions:p}}};var mt={gallery:"Galerie en grille asym\xE9trique"};var ft={gallery:"Masonry grid gallery"};var et=O("fr",{fr:mt,en:ft});var F=class extends A{constructor(t,e={}){super(e.i18n);this.isNativeCSSGrid=!1;this._items=[];this.resizeObserver=null;this.itemResizeObserver=null;this.layoutRafId=null;this.isDestroyed=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.hasExplicitAriaLabel=!1;this.lastInferredAriaLabel="";this.removeTimers=new Set;this.pendingImageListeners=[];if(typeof t=="string"){let n=document.querySelector(t);if(!n)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${t}"`);this.root=n}else if(t instanceof HTMLElement)this.root=t;else throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");this.originalContainerStyles={height:this.root.style.height,width:this.root.style.width},this.hasExplicitAriaLabel=!!(e.ariaLabel||e.i18n?.gallery),this.options={itemSelector:e.itemSelector||"> *",columnWidth:e.columnWidth??0,gutter:e.gutter??0,percentPosition:!!e.percentPosition,fitWidth:!!e.fitWidth,horizontalOrder:!!e.horizontalOrder,transitionDuration:e.transitionDuration!==void 0?e.transitionDuration:300,stagger:e.stagger||0,resize:e.resize!==!1,autoImages:e.autoImages!==!1,useNativeCSSGrid:e.useNativeCSSGrid!==!1,ariaRole:e.ariaRole||"region",ariaLabel:e.ariaLabel||this.t("gallery"),i18n:e.i18n||{},onLayout:e.onLayout||(()=>{}),onItemPlaced:e.onItemPlaced||(()=>{}),audit:e.audit??!0};let s=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("grid-template-rows","masonry");this.options.useNativeCSSGrid&&s?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native")):this.root.classList.add("wulf-masonry"),this.initAccessibility(),this.applyTransitionDuration(),this.reloadItems(),this.initObservers(),this.initImages(),this.layout(),this.runAuditWarning(this.options.audit)}get items(){return[...this._items]}initAccessibility(){this.options.ariaRole&&!this.root.hasAttribute("role")&&(this.root.setAttribute("role",this.options.ariaRole),this.wasRoleInferred=!0);let t=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("gallery");t&&!this.root.hasAttribute("aria-label")&&(this.root.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.wasAriaLabelInferred=!0)}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel){let e=this.t("gallery");this.root.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.options.ariaLabel=e}}applyTransitionDuration(){let t=this.options.transitionDuration,e=typeof t=="number"?`${t}ms`:t;this.root.style.setProperty("--wulf-masonry-duration",e)}reloadItems(){if(this.isDestroyed)return;let t=[];if(this.options.itemSelector==="> *")t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"));else try{t=Array.from(this.root.querySelectorAll(this.options.itemSelector)).filter(e=>e.parentElement===this.root&&!e.hasAttribute("data-masonry-ignore"))}catch{t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"))}this._items=t;for(let e of this._items)e.classList.add("wulf-masonry-item"),this.itemResizeObserver&&this.itemResizeObserver.observe(e)}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let t=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(e=>{for(let s of e){let n=s.contentRect.width;Math.abs(n-t)>=1&&(t=n,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(()=>{this.scheduleLayout()});for(let e of this._items)this.itemResizeObserver.observe(e)}initImages(){if(!this.options.autoImages)return;let t=Array.from(this.root.querySelectorAll("img"));for(let e of t)if(!e.complete){let s=()=>{let n=()=>{this.pendingImageListeners=this.pendingImageListeners.filter(r=>r.handler!==n),this.isDestroyed||this.scheduleLayout()};this.pendingImageListeners.push({img:e,handler:n}),e.addEventListener("load",n,{once:!0})};typeof e.decode=="function"?e.decode().then(()=>{this.isDestroyed||this.scheduleLayout()}).catch(()=>{s()}):s()}}scheduleLayout(){this.isDestroyed||(this.layoutRafId!==null&&cancelAnimationFrame(this.layoutRafId),this.layoutRafId=requestAnimationFrame(()=>{this.layoutRafId=null,this.layout()}))}layout(){if(this.isDestroyed)return;if(this.syncAccessibilityLabels(),this.isNativeCSSGrid){this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true");let t=G.calculate(this.root,this._items,this.options);this.root.style.height=`${t.containerHeight}px`,this.options.fitWidth&&t.fittedWidth!==void 0?(this.root.style.width=`${t.fittedWidth}px`,this.root.classList.add("wulf-masonry--fit-width")):this.root.classList.remove("wulf-masonry--fit-width");let e=this.options.stagger,s=this.options.percentPosition&&t.containerWidth>0;for(let n=0;n<t.positions.length;n++){let r=t.positions[n],o=r.element;if(s){let a=Number((r.width/t.containerWidth*100).toFixed(4));o.style.setProperty("--wulf-masonry-w",`${a}%`)}else o.style.setProperty("--wulf-masonry-w",`${r.width}px`);o.style.setProperty("--wulf-masonry-x",`${r.x}px`),o.style.setProperty("--wulf-masonry-y",`${r.y}px`),e>0?o.style.transitionDelay=`${n*e}ms`:o.style.removeProperty("transition-delay"),o.classList.remove("wulf-masonry-item--hidden"),this.options.onItemPlaced(o,r)}this.root.setAttribute("aria-busy","false"),this.options.onLayout(t.positions)}append(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let s=document.createDocumentFragment();for(let n of e)n.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),s.appendChild(n);this.root.appendChild(s),this.reloadItems(),this.initImages(),this.layout()}prepend(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let s=this.root.firstChild,n=document.createDocumentFragment();for(let r of e)r.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),n.appendChild(r);this.root.insertBefore(n,s),this.reloadItems(),this.initImages(),this.layout()}remove(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;for(let r of e)r.classList.add("wulf-masonry-item--hidden");let s=typeof this.options.transitionDuration=="number"?this.options.transitionDuration:300;if(s<=0){for(let r of e)r.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(r),this.root.removeChild(r));this.reloadItems(),this.layout();return}let n=window.setTimeout(()=>{if(this.removeTimers.delete(n),!this.isDestroyed){for(let r of e)r.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(r),this.root.removeChild(r));this.reloadItems(),this.layout()}},s);this.removeTimers.add(n)}audit(){let t=[],e=this.checkAriaIdReferences(this.root,"aria-labelledby",t),s=!this.wasAriaLabelInferred&&!!this.root.getAttribute("aria-label")?.trim();!this.hasExplicitAriaLabel&&!s&&!e&&t.push("Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour qualifier la grille (WCAG 4.1.2).");let n=Array.from(this.root.querySelectorAll("img")).filter(r=>!r.hasAttribute("alt")&&r.getAttribute("aria-hidden")!=="true");return n.length>0&&t.push(`${n.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`),t}getAuditPrefix(){return"Wulf.Masonry"}getAuditTargetLabel(){return this.root.id?`#${this.root.id}`:`<${this.root.tagName.toLowerCase()}.wulf-masonry>`}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(let t of this.removeTimers)clearTimeout(t);this.removeTimers.clear();for(let{img:t,handler:e}of this.pendingImageListeners)t.removeEventListener("load",e);this.pendingImageListeners=[],this.layoutRafId!==null&&(cancelAnimationFrame(this.layoutRafId),this.layoutRafId=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.itemResizeObserver&&(this.itemResizeObserver.disconnect(),this.itemResizeObserver=null),this.root.classList.remove("wulf-masonry","wulf-masonry--native","wulf-masonry--fit-width"),this.root.removeAttribute("aria-busy"),this.wasRoleInferred&&this.root.getAttribute("role")===this.options.ariaRole&&this.root.removeAttribute("role"),this.wasAriaLabelInferred&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.root.removeAttribute("aria-label"),this.root.style.removeProperty("--wulf-masonry-duration"),this.originalContainerStyles.height?this.root.style.height=this.originalContainerStyles.height:this.root.style.removeProperty("height"),this.originalContainerStyles.width?this.root.style.width=this.originalContainerStyles.width:this.root.style.removeProperty("width");for(let t of this._items)t.classList.remove("wulf-masonry-item","wulf-masonry-item--hidden"),t.style.removeProperty("--wulf-masonry-w"),t.style.removeProperty("--wulf-masonry-x"),t.style.removeProperty("--wulf-masonry-y"),t.style.removeProperty("transition-delay");this._items=[]}}};F._i18n=et,F.i18n=et;var Ht=F;if(typeof window<"u"){let d=window,i=d.Wulf||{};d.Wulf=i,i.Masonry=Object.assign(F,{Masonry:F,LayoutEngine:G,i18n:et})}var yt={};$(yt,{LocalizedComponent:()=>A,Toast:()=>N,ToastInstance:()=>nt,ToastManager:()=>it,createI18nManager:()=>O,default:()=>Pt,toastEn:()=>vt,toastFr:()=>bt,toastI18n:()=>q});var bt={closeButton:"Fermer la notification"};var vt={closeButton:"Close notification"};var q=O("fr",{fr:bt,en:vt});var Rt=1,nt=class extends C{constructor(t,e){super();this._isClosed=!1;this.timerId=null;this.remainingTime=0;this.timerStartTime=0;this.isPaused=!1;this.id=`wulf-toast-${Rt++}`,this.options=Object.freeze({...t}),this.onDismissCallback=e;let s=t.duration===void 0?4e3:t.duration;typeof s=="number"&&s>0?this.remainingTime=s:this.remainingTime=0,this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(t.audit!==!1)}get isClosed(){return this._isClosed}audit(){let t=[],e=!!(this.options.title&&this.options.title.trim().length>0),s=!!(this.options.message&&this.options.message.trim().length>0);!e&&!s&&t.push("Contenu textuel vide : d\xE9finissez au moins un title ou un message pour que le lecteur d'\xE9cran puisse annoncer la notification (WCAG 4.1.3).");let n=this.options.duration===void 0?4e3:this.options.duration;typeof n=="number"&&n>0&&n<5e3&&t.push(`Dur\xE9e d'affichage trop courte (duration: ${n}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`);let r=this.options.closable??!0;return(n===!1||typeof n=="number"&&n<=0)&&!r&&!this.options.closeOnClick&&t.push("Notification persistante impossible \xE0 fermer : activez closable: true ou closeOnClick: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."),t}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return`#${this.id}`}createDOM(){let t=document.createElement("div");t.id=this.id,t.className="wulf-toast";let e=this.options.role==="alert"?"alert":"status";if(t.setAttribute("role",e),t.setAttribute("aria-live",e==="alert"?"assertive":"polite"),t.setAttribute("aria-atomic","true"),this.options.backgroundColor&&t.style.setProperty("--wulf-toast-bg",this.options.backgroundColor),this.options.titleColor&&t.style.setProperty("--wulf-toast-title-color",this.options.titleColor),this.options.textColor&&t.style.setProperty("--wulf-toast-text-color",this.options.textColor),this.options.iconColor&&t.style.setProperty("--wulf-toast-icon-color",this.options.iconColor),this.options.closeButtonColor&&t.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor),this.options.icon&&this.options.icon.trim()!==""){let r=document.createElement("span");r.className=`wulf-toast-icon ${this.options.icon.trim()}`,r.setAttribute("aria-hidden","true"),t.appendChild(r)}let s=document.createElement("div");if(s.className="wulf-toast-content",this.options.title&&this.options.title.trim()!==""){let r=document.createElement("div");r.className="wulf-toast-title",this.appendTextWithLineBreaks(r,this.options.title),s.appendChild(r)}if(this.options.message&&this.options.message.trim()!==""){let r=document.createElement("div");r.className="wulf-toast-message",this.appendTextWithLineBreaks(r,this.options.message),s.appendChild(r)}if(t.appendChild(s),this.options.closable??!0){let r=document.createElement("button");r.type="button",r.className="wulf-toast-close",r.setAttribute("aria-label",q.t("closeButton",this.options.i18n)),r.setAttribute("tabindex","0");let o=document.createElement("span");o.className="wulf-toast-close-icon",o.setAttribute("aria-hidden","true"),o.textContent="\xD7",r.appendChild(o),r.addEventListener("click",a=>{a.stopPropagation(),this.close("close-button")}),t.appendChild(r)}return t}appendTextWithLineBreaks(t,e){e.split(/\r\n|\r|\n/).forEach((n,r)=>{r>0&&t.appendChild(document.createElement("br")),t.appendChild(document.createTextNode(n))})}bindEvents(){this.element.addEventListener("click",t=>{this.options.onClick&&this.options.onClick(this,t),this.options.closeOnClick&&this.close("toast-click")}),this.element.addEventListener("mouseenter",()=>this.pauseTimer()),this.element.addEventListener("mouseleave",()=>this.resumeTimer()),this.element.addEventListener("focusin",()=>this.pauseTimer()),this.element.addEventListener("focusout",()=>this.resumeTimer())}startTimer(){this._isClosed||this.remainingTime<=0||(this.timerStartTime=Date.now(),this.timerId=window.setTimeout(()=>{this.close("timeout")},this.remainingTime))}pauseTimer(){if(this._isClosed||this.remainingTime<=0||this.isPaused)return;this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null);let t=Date.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-t),this.isPaused=!0}resumeTimer(){this._isClosed||this.remainingTime<=0||!this.isPaused||(this.isPaused=!1,this.startTimer())}destroyImmediate(t="replace"){this._isClosed||(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,t),this.options.onClose&&this.options.onClose(this,t))}close(t="programmatic",e=!1){return this._isClosed?Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),new Promise(s=>{this.element.classList.add(e?"wulf-toast-hiding-fast":"wulf-toast-hiding");let n=()=>{this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,t),this.options.onClose&&this.options.onClose(this,t),s()};if(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)n();else if(e)window.setTimeout(n,90);else{let o=!1,a=null,l=()=>{o||(o=!0,a!==null&&(window.clearTimeout(a),a=null),this.element.removeEventListener("animationend",l),this.element.removeEventListener("transitionend",l),n())};this.element.addEventListener("animationend",l,{once:!0}),this.element.addEventListener("transitionend",l,{once:!0}),a=window.setTimeout(l,300)}}))}};var X=class X{constructor(){this.containers=new Map;this.activeToasts=new Map;this.replaceTokens=new Map;this.pendingReplacements=new Set}static getInstance(){return X.instance||(X.instance=new X),X.instance}add(i){let t=i.options.position||"top-right",e=this.activeToasts.get(t);if(e||(e=[],this.activeToasts.set(t,e)),i.options.replace&&e.length>0){let n=[...e],r=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,r),this.pendingReplacements.add(t);let o=n.map(a=>a.close("replace",!0));Promise.all(o).then(()=>{this.pendingReplacements.delete(t),this.replaceTokens.get(t)===r&&this.mountToast(i,t)});return}let s=typeof i.options.maxToasts=="number"&&i.options.maxToasts>0?i.options.maxToasts:5;if(e.length>=s){let n=e.length-s+1,r=e.splice(0,n);for(let o of r)o.close("max-limit",!0)}this.mountToast(i,t)}mountToast(i,t){let e=this.getOrCreateContainer(t),s=this.activeToasts.get(t);if(s||(s=[],this.activeToasts.set(t,s)),e.appendChild(i.element),s.push(i),i.options.onOpen)try{i.options.onOpen(i)}catch(n){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",n)}i.startTimer()}remove(i,t){let e=i.options.position||"top-right",s=this.activeToasts.get(e);if(s){let n=s.indexOf(i);if(n!==-1&&s.splice(n,1),s.length===0&&!this.pendingReplacements.has(e)){let r=this.containers.get(e);r&&(!r.firstChild||r.children.length===0)&&(r.parentNode&&r.parentNode.removeChild(r),this.containers.delete(e),this.activeToasts.delete(e))}}}clearAll(i){let t=[];if(i){let e=this.activeToasts.get(i);if(e&&e.length>0){let s=[...e];for(let n of s)t.push(n.close("programmatic"))}else{let s=this.containers.get(i);s&&(!s.firstChild||s.children.length===0)&&(s.parentNode&&s.parentNode.removeChild(s),this.containers.delete(i),this.activeToasts.delete(i))}}else{let e=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let s of e)t.push(this.clearAll(s))}return Promise.all(t).then(()=>{if(!i)for(let[e,s]of Array.from(this.containers.entries()))(!s.firstChild||s.children.length===0)&&(s.parentNode&&s.parentNode.removeChild(s),this.containers.delete(e),this.activeToasts.delete(e))})}getOrCreateContainer(i){let t=this.containers.get(i);return(!t||!document.body.contains(t))&&(t=document.createElement("div"),t.className=`wulf-toast-container wulf-toast-${i}`,t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions removals"),document.body.appendChild(t),this.containers.set(i,t)),t}};X.instance=null;var it=X;var N=class extends A{audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(i={}){let t=it.getInstance(),e=new nt(i,(s,n)=>{t.remove(s,n)});return t.add(e),e}static clearAll(i){return it.getInstance().clearAll(i)}};N._i18n=q,N.i18n=q;var Pt=N;if(typeof window<"u"){let d=window,i=d.Wulf||{};d.Wulf=i,i.Toast=Object.assign(N,{Toast:N,i18n:q})}var wt={};$(wt,{FocusTrap:()=>W,default:()=>W});var Bt=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),_=[],W=class extends C{constructor(t,e={}){super();this.active=!1;this.paused=!1;this.previousActiveElement=null;this.inertSiblings=[];this.startSentinel=null;this.endSentinel=null;let s=typeof t=="string"?document.querySelector(t):t;if(!s||!(s instanceof HTMLElement))throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${t}"`);this.element=s,this.options={initialFocus:e.initialFocus!==void 0?e.initialFocus:"[data-autofocus], [autofocus]",returnFocus:e.returnFocus??!0,fallbackReturnFocus:e.fallbackReturnFocus??"",escapeDeactivates:e.escapeDeactivates??!0,allowOutsideClick:e.allowOutsideClick??!1,setInert:e.setInert??!1,onActivate:e.onActivate??(()=>{}),onDeactivate:e.onDeactivate??(()=>{}),audit:e.audit??!0},this.handleKeyDownBound=this.handleKeyDown.bind(this),this.handleClickOutsideBound=this.handleClickOutside.bind(this),this.handleFocusInBound=this.handleFocusIn.bind(this),this.runAuditWarning(this.options.audit)}isFocusable(t){if(!t||!t.isConnected||t.disabled||t.closest("fieldset[disabled]")&&!t.closest("legend")||t.hasAttribute("inert")||t.closest("[inert]")||t.hidden||t.closest("[hidden]")||t.style.display==="none"||t.style.visibility==="hidden")return!1;let e=window.getComputedStyle(t);if(e.display==="none"||e.visibility==="hidden"||t.offsetWidth===0&&t.offsetHeight===0&&e.position!=="fixed")return!1;if(t instanceof HTMLInputElement&&t.type==="radio"&&t.name){let s=Array.from(this.element.querySelectorAll(`input[type="radio"][name="${CSS.escape(t.name)}"]`)),n=s.find(r=>r.checked);return n?t===n:t===s[0]}return!0}getFocusableElements(){return Array.from(this.element.querySelectorAll(Bt)).filter(e=>this.isFocusable(e))}activate(){if(this.active)return this;let t=_[_.length-1];return t&&t.pause(),this.active=!0,this.paused=!1,_.push(this),this.previousActiveElement=document.activeElement,this.setupSentinels(),this.options.setInert&&this.applyInert(),document.addEventListener("keydown",this.handleKeyDownBound,!0),document.addEventListener("focusin",this.handleFocusInBound,!0),this.options.allowOutsideClick||(document.addEventListener("mousedown",this.handleClickOutsideBound,!0),document.addEventListener("touchstart",this.handleClickOutsideBound,!0)),this.applyInitialFocus(),this.runAuditWarning(this.options.audit),this.options.onActivate(),this}deactivate(){if(!this.active)return this;this.active=!1,this.paused=!1;let t=_.indexOf(this);t!==-1&&_.splice(t,1);let e=_[_.length-1];return e&&e.unpause(),document.removeEventListener("keydown",this.handleKeyDownBound,!0),document.removeEventListener("focusin",this.handleFocusInBound,!0),document.removeEventListener("mousedown",this.handleClickOutsideBound,!0),document.removeEventListener("touchstart",this.handleClickOutsideBound,!0),this.removeSentinels(),this.removeInert(),this.options.returnFocus&&this.restoreFocus(),this.options.onDeactivate(),this}pause(){this.paused=!0}unpause(){this.paused=!1}isActive(){return this.active&&!this.paused}audit(){let t=[],e=this.element.getAttribute("role"),s=this.element.tagName.toLowerCase()==="dialog";!s&&(!e||!["dialog","alertdialog","menu","listbox","tree","grid"].includes(e))&&t.push('R\xF4le s\xE9mantique manquant ou inadapt\xE9 : d\xE9finissez role="dialog" (ou "alertdialog", "menu", "listbox") sur le conteneur.'),(s||e==="dialog"||e==="alertdialog")&&this.element.getAttribute("aria-modal")!=="true"&&t.push('Isolation modale manquante : d\xE9finissez aria-modal="true" sur le conteneur de dialogue (WCAG 4.1.2).');let r=this.element.getAttribute("aria-label")?.trim(),o=this.checkAriaIdReferences(this.element,"aria-labelledby",t);return!r&&!o&&t.push('Nom accessible manquant : d\xE9finissez aria-labelledby="id-titre" ou aria-label="..." sur le conteneur (WCAG 4.1.2).'),t}getAuditPrefix(){return"Wulf.FocusTrap"}getAuditTargetLabel(){return this.element.id?`#${this.element.id}`:`<${this.element.tagName.toLowerCase()}>`}destroy(){this.deactivate()}handleKeyDown(t){if(!this.isActive())return;if(t.key==="Escape"&&this.options.escapeDeactivates){t.preventDefault(),t.stopPropagation(),this.deactivate();return}if(t.key!=="Tab")return;let e=this.getFocusableElements();if(e.length===0){t.preventDefault(),this.element.getAttribute("tabindex")===null&&this.element.setAttribute("tabindex","-1"),this.element.focus();return}let s=e[0],n=e[e.length-1],r=document.activeElement;!t.shiftKey&&(r===n||!this.element.contains(r))?(t.preventDefault(),s.focus()):t.shiftKey&&(r===s||!this.element.contains(r))&&(t.preventDefault(),n.focus())}handleFocusIn(t){if(!this.isActive())return;let e=t.target;if(e){if(e===this.startSentinel){let s=this.getFocusableElements();s.length>0?s[s.length-1].focus():this.element.focus();return}if(e===this.endSentinel){let s=this.getFocusableElements();s.length>0?s[0].focus():this.element.focus();return}if(!this.element.contains(e)){let s=this.getFocusableElements();s.length>0?s[0].focus():(this.element.getAttribute("tabindex")===null&&this.element.setAttribute("tabindex","-1"),this.element.focus())}}}handleClickOutside(t){if(!this.isActive())return;let e=t.target;e&&!this.element.contains(e)&&(t.preventDefault(),t.stopPropagation())}setupSentinels(){this.startSentinel||(this.startSentinel=document.createElement("span"),this.startSentinel.setAttribute("tabindex","0"),this.startSentinel.setAttribute("aria-hidden","true"),this.startSentinel.className="wulf-sentinel-start",this.startSentinel.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;"),this.endSentinel||(this.endSentinel=document.createElement("span"),this.endSentinel.setAttribute("tabindex","0"),this.endSentinel.setAttribute("aria-hidden","true"),this.endSentinel.className="wulf-sentinel-end",this.endSentinel.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;"),this.element.parentNode&&(this.element.parentNode.insertBefore(this.startSentinel,this.element),this.element.parentNode.insertBefore(this.endSentinel,this.element.nextSibling))}removeSentinels(){this.startSentinel?.remove(),this.endSentinel?.remove(),this.startSentinel=null,this.endSentinel=null}applyInert(){this.inertSiblings=[];let t=this.element.parentElement,e=this.element;for(;t&&t!==document.body;)e=t,t=t.parentElement;t===document.body&&Array.from(document.body.children).forEach(s=>{s instanceof HTMLElement&&s!==e&&s!==this.startSentinel&&s!==this.endSentinel&&!s.hasAttribute("inert")&&(s.setAttribute("inert",""),this.inertSiblings.push(s))})}removeInert(){this.inertSiblings.forEach(t=>t.removeAttribute("inert")),this.inertSiblings=[]}applyInitialFocus(){if(this.options.initialFocus===!1)return;let t=null;if(typeof this.options.initialFocus=="string"?t=this.element.querySelector(this.options.initialFocus):this.options.initialFocus instanceof HTMLElement&&(t=this.options.initialFocus),t&&this.isFocusable(t)){t.focus();return}let e=this.getFocusableElements();e.length>0?e[0].focus():(this.element.getAttribute("tabindex")===null&&this.element.setAttribute("tabindex","-1"),this.element.focus())}restoreFocus(){if(this.previousActiveElement&&this.previousActiveElement.isConnected){this.previousActiveElement.focus();return}if(this.options.fallbackReturnFocus){let t=typeof this.options.fallbackReturnFocus=="string"?document.querySelector(this.options.fallbackReturnFocus):this.options.fallbackReturnFocus;t&&t.isConnected&&t.focus()}}};if(typeof window<"u"){let d=window,i=d.Wulf||{};d.Wulf=i,i.FocusTrap=Object.assign(W,{FocusTrap:W})}var Tt={};$(Tt,{ShortcutFormatter:()=>I,ShortcutManager:()=>j,default:()=>j});var I=class d{static isApple(){if(typeof navigator>"u")return!1;let i=navigator.userAgentData;if(i&&typeof i.platform=="string"){let s=i.platform.toLowerCase();if(s.includes("mac")||s.includes("ios"))return!0}let t=(navigator.platform||"").toLowerCase();if(t.includes("mac")||t.includes("iphone")||t.includes("ipad")||t.includes("ipod"))return!0;let e=(navigator.userAgent||"").toLowerCase();return e.includes("macintosh")||e.includes("mac os x")||e.includes("ipad")||e.includes("iphone")}static normalizeKeyName(i){let t=i.trim().toLowerCase();switch(t){case"esc":return"escape";case"return":return"enter";case"space":case"spacebar":return" ";case"del":return"delete";case"ins":return"insert";case"up":return"arrowup";case"down":return"arrowdown";case"left":return"arrowleft";case"right":return"arrowright";default:return t}}static parseCombo(i,t=d.isApple()){let e=i.trim();if(!e)return[];let s=e.split(/\s+/),n=[];for(let r of s){let o=[],a="";for(let f=0;f<r.length;f++){let m=r[f];m==="+"?a===""&&o.length>0?o.push("+"):a!==""&&(o.push(a),a=""):a+=m}a!==""&&o.push(a);let l=!1,h=!1,c=!1,u=!1,p="";for(let f of o){let m=f.trim().toLowerCase();m==="ctrl"||m==="control"?l=!0:m==="alt"||m==="option"||m==="opt"?h=!0:m==="shift"||m==="maj"?c=!0:m==="cmd"||m==="command"||m==="meta"||m==="win"||m==="super"?u=!0:m==="mod"||m==="$mod"?t?u=!0:l=!0:p=d.normalizeKeyName(f)}n.push({ctrl:l,alt:h,shift:c,meta:u,key:p})}return n}static format(i,t=d.isApple()){let e=d.parseCombo(i,t);return e.length===0?i:e.map(n=>{let r=[];if(t){n.ctrl&&r.push("\u2303"),n.alt&&r.push("\u2325"),n.shift&&r.push("\u21E7"),n.meta&&r.push("\u2318");let o=d.formatKeyDisplay(n.key,!0);return r.push(o),r.join("")}else{n.ctrl&&r.push("Ctrl"),n.alt&&r.push("Alt"),n.shift&&r.push("Shift"),n.meta&&r.push("Win");let o=d.formatKeyDisplay(n.key,!1);return r.push(o),r.join("+")}}).join(" ")}static toAriaKeyShortcuts(i,t=d.isApple()){return d.parseCombo(i,t).map(s=>{let n=[];return s.ctrl&&n.push("Control"),s.alt&&n.push("Alt"),s.shift&&n.push("Shift"),s.meta&&n.push("Meta"),n.push(d.formatKeyDisplay(s.key,!1)),n.join("+")}).join(" ")}static formatKeyDisplay(i,t){if(!i)return"";switch(i.toLowerCase()){case"escape":return t?"\u238B":"Esc";case"enter":return t?"\u21A9":"Enter";case" ":return t?"\u2423":"Space";case"tab":return t?"\u21E5":"Tab";case"backspace":return t?"\u232B":"Backspace";case"delete":return t?"\u2326":"Suppr";case"arrowup":return"\u2191";case"arrowdown":return"\u2193";case"arrowleft":return"\u2190";case"arrowright":return"\u2192";default:return i.length===1?i.toUpperCase():i.charAt(0).toUpperCase()+i.slice(1)}}};var j=class d{constructor(i){this.shortcuts=new Map;this.scopeStack=[];this.sequenceBuffer=[];this.sequenceTimer=null;this.isListening=!0;this.boundListener=null;this.idCounter=0;this.options={defaultScope:i?.defaultScope||"global",sequenceTimeout:i?.sequenceTimeout??800,target:i?.target||(typeof window<"u"?window:{}),onError:i?.onError},this.scopeStack=[this.options.defaultScope],this.initListener()}static isEditable(i){if(!i||typeof i.tagName!="string")return!1;let t=i,e=t.tagName.toUpperCase();if(e==="INPUT"){let n=t.type?.toLowerCase()||"text";return!["button","checkbox","radio","submit","reset","range","color","file","image"].includes(n)}if(e==="TEXTAREA"||e==="SELECT"||t.isContentEditable||t.getAttribute("contenteditable")==="true"||t.getAttribute("contenteditable")==="plaintext-only")return!0;let s=t.getAttribute("role");return s==="textbox"||s==="searchbox"}bind(i){let t=Array.isArray(i)?i:[i],e=[];for(let s of t){if(!s.combo||typeof s.handler!="function")continue;let n=`wulf_shortcut_${++this.idCounter}`,r=I.parseCombo(s.combo),o=r.length>1,a=I.format(s.combo),l={...s,id:n,scope:s.scope||"global",category:s.category||"G\xE9n\xE9ral",allowInEditable:s.allowInEditable??!1,preventDefault:s.preventDefault??!0,stopPropagation:s.stopPropagation??!0,priority:s.priority??0,formattedCombo:a,normalizedSteps:r,isSequence:o};this.shortcuts.set(n,l),e.push(n)}return()=>{for(let s of e)this.shortcuts.delete(s)}}unbind(i,t){let e=I.format(i);for(let[s,n]of this.shortcuts.entries())(n.formattedCombo===e||n.combo.trim().toLowerCase()===i.trim().toLowerCase())&&(!t||n.scope===t)&&this.shortcuts.delete(s)}pushScope(i){i&&typeof i=="string"&&(this.scopeStack.push(i),this.clearSequenceBuffer())}popScope(i){if(this.scopeStack.length<=1)return this.scopeStack[0];if(i){if(this.getScope()===i){let e=this.scopeStack.pop();return this.clearSequenceBuffer(),e}return}let t=this.scopeStack.pop();return this.clearSequenceBuffer(),t}setScope(i){this.scopeStack=[i||this.options.defaultScope],this.clearSequenceBuffer()}getScope(){return this.scopeStack[this.scopeStack.length-1]||this.options.defaultScope}getScopeStack(){return[...this.scopeStack]}pause(){this.isListening=!1,this.clearSequenceBuffer()}resume(){this.isListening=!0}isActive(){return this.isListening}getRegistry(i){let t=[];for(let e of this.shortcuts.values())(!i||e.scope===i||e.scope==="*")&&t.push({...e});return t}attachAria(i,t){if(i&&typeof i.setAttribute=="function"){let e=I.toAriaKeyShortcuts(t);i.setAttribute("aria-keyshortcuts",e)}}static format(i,t){return I.format(i,t)}destroy(){this.pause(),this.removeListener(),this.shortcuts.clear(),this.scopeStack=[],this.clearSequenceBuffer()}initListener(){if(typeof window>"u"||!this.options.target)return;this.boundListener=t=>this.handleKeyDown(t);let i=this.options.target;typeof i.addEventListener=="function"&&i.addEventListener("keydown",this.boundListener,!1)}removeListener(){if(this.boundListener&&this.options.target){let i=this.options.target;typeof i.removeEventListener=="function"&&i.removeEventListener("keydown",this.boundListener,!1),this.boundListener=null}}handleKeyDown(i){if(!this.isListening)return;let t=(i.key||"").toLowerCase();if(["control","alt","shift","meta"].includes(t))return;let e=this.getScope(),s=d.isEditable(i.target),n={ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey,meta:i.metaKey,key:I.normalizeKeyName(i.key||"")},r=Date.now();if(this.sequenceBuffer.length>0){let c=this.sequenceBuffer[this.sequenceBuffer.length-1];r-c.timestamp>this.options.sequenceTimeout&&this.clearSequenceBuffer()}let o=this.getActiveShortcuts(e,s),a=[...this.sequenceBuffer.map(c=>c.step),n],l=this.findMatchingSequence(o,a);if(l){this.clearSequenceBuffer(),this.executeShortcut(l,i,e,!0);return}if(this.isPrefixOfAnySequence(o,a)){this.sequenceBuffer.push({step:n,timestamp:r}),this.resetSequenceTimer(),i.key.length===1&&!i.ctrlKey&&!i.altKey&&!i.metaKey&&!s&&i.preventDefault();return}this.clearSequenceBuffer();let h=this.findMatchingChord(o,n,i);h&&this.executeShortcut(h,i,e,!1)}getActiveShortcuts(i,t){let e=[];for(let s of this.shortcuts.values())s.scope!==i&&s.scope!=="*"||t&&!s.allowInEditable||e.push(s);return e.sort((s,n)=>(n.priority??0)-(s.priority??0))}stepMatches(i,t,e){return i.ctrl!==t.ctrl||i.alt!==t.alt||i.meta!==t.meta||!(i.key===t.key||e&&i.key===e.key.toLowerCase())?!1:!!(i.shift===t.shift||!i.shift&&t.shift&&e&&e.key===i.key)}findMatchingChord(i,t,e){for(let s of i){if(s.isSequence||s.normalizedSteps.length!==1)continue;let n=s.normalizedSteps[0];if(this.stepMatches(n,t,e))return s}return null}findMatchingSequence(i,t){for(let e of i){if(!e.isSequence||e.normalizedSteps.length!==t.length)continue;let s=!0;for(let n=0;n<t.length;n++)if(!this.stepMatches(e.normalizedSteps[n],t[n])){s=!1;break}if(s)return e}return null}isPrefixOfAnySequence(i,t){for(let e of i){if(!e.isSequence||e.normalizedSteps.length<=t.length)continue;let s=!0;for(let n=0;n<t.length;n++)if(!this.stepMatches(e.normalizedSteps[n],t[n])){s=!1;break}if(s)return!0}return!1}executeShortcut(i,t,e,s){i.preventDefault&&t.preventDefault(),i.stopPropagation&&t.stopPropagation();let n={combo:i.combo,formattedCombo:i.formattedCombo,scope:e,target:t.target,isSequence:s};try{i.handler(t,n)}catch(r){this.options.onError?this.options.onError(r instanceof Error?r:new Error(String(r)),i.combo):console.error(`[Wulf.Shortcut] Erreur lors de l'ex\xE9cution du raccourci "${i.combo}":`,r)}}resetSequenceTimer(){this.sequenceTimer&&clearTimeout(this.sequenceTimer),this.sequenceTimer=setTimeout(()=>{this.clearSequenceBuffer()},this.options.sequenceTimeout)}clearSequenceBuffer(){this.sequenceBuffer=[],this.sequenceTimer&&(clearTimeout(this.sequenceTimer),this.sequenceTimer=null)}};return Ct(Ft);})();
|
|
5
|
+
if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast", "FocusTrap", "Shortcut"]; for (var i = 0; i < targets.length; i++) { var t = targets[i]; if (Wulf[t] && window.Wulf[t] !== Wulf[t]) { try { Object.defineProperty(window.Wulf, t, { value: Wulf[t], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[t] = Wulf[t]; } catch (__) {} } } } for (var k in Wulf) { if (window.Wulf[k] === undefined) { try { Object.defineProperty(window.Wulf, k, { value: Wulf[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { window.Wulf[k] = Wulf[k]; } catch (__) {} } } } } }
|
|
3
6
|
//# sourceMappingURL=index.global.min.js.map
|