wulf.js 1.8.4 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +18 -14
  2. package/changelog.md +55 -0
  3. package/dist/index.cjs.js +590 -54
  4. package/dist/index.cjs.js.map +3 -3
  5. package/dist/index.esm.js +590 -54
  6. package/dist/index.esm.js.map +3 -3
  7. package/dist/index.global.js +590 -54
  8. package/dist/index.global.js.map +3 -3
  9. package/dist/index.global.min.js +1 -1
  10. package/dist/index.global.min.js.map +4 -4
  11. package/dist/mask.cjs.js +231 -31
  12. package/dist/mask.cjs.js.map +2 -2
  13. package/dist/mask.css +1 -1
  14. package/dist/mask.css.map +2 -2
  15. package/dist/mask.esm.js +231 -31
  16. package/dist/mask.esm.js.map +2 -2
  17. package/dist/mask.global.js +231 -31
  18. package/dist/mask.global.js.map +2 -2
  19. package/dist/mask.global.min.js +1 -1
  20. package/dist/mask.global.min.js.map +3 -3
  21. package/dist/masonry.cjs.js +220 -9
  22. package/dist/masonry.cjs.js.map +3 -3
  23. package/dist/masonry.esm.js +220 -9
  24. package/dist/masonry.esm.js.map +3 -3
  25. package/dist/masonry.global.js +220 -9
  26. package/dist/masonry.global.js.map +3 -3
  27. package/dist/masonry.global.min.js +1 -1
  28. package/dist/masonry.global.min.js.map +4 -4
  29. package/dist/scroll.cjs.js +256 -8
  30. package/dist/scroll.cjs.js.map +3 -3
  31. package/dist/scroll.esm.js +256 -8
  32. package/dist/scroll.esm.js.map +3 -3
  33. package/dist/scroll.global.js +256 -8
  34. package/dist/scroll.global.js.map +3 -3
  35. package/dist/scroll.global.min.js +1 -1
  36. package/dist/scroll.global.min.js.map +4 -4
  37. package/dist/toast.cjs.js +199 -6
  38. package/dist/toast.cjs.js.map +3 -3
  39. package/dist/toast.css +1 -1
  40. package/dist/toast.css.map +2 -2
  41. package/dist/toast.esm.js +199 -6
  42. package/dist/toast.esm.js.map +3 -3
  43. package/dist/toast.global.js +199 -6
  44. package/dist/toast.global.js.map +3 -3
  45. package/dist/toast.global.min.js +1 -1
  46. package/dist/toast.global.min.js.map +4 -4
  47. package/dist/types/common/LocalizedComponent.d.ts +53 -0
  48. package/dist/types/common/i18n.d.ts +39 -0
  49. package/dist/types/index.d.ts +2 -0
  50. package/dist/types/mask/BaseInputMask.d.ts +1 -0
  51. package/dist/types/mask/EmailEngine.d.ts +24 -2
  52. package/dist/types/mask/InputEmailMask.d.ts +8 -0
  53. package/dist/types/mask/InputMask.d.ts +8 -0
  54. package/dist/types/masonry/Masonry.d.ts +11 -1
  55. package/dist/types/masonry/i18n/en.d.ts +2 -0
  56. package/dist/types/masonry/i18n/fr.d.ts +2 -0
  57. package/dist/types/masonry/i18n/index.d.ts +9 -0
  58. package/dist/types/masonry/i18n/types.d.ts +7 -0
  59. package/dist/types/masonry/index.d.ts +1 -0
  60. package/dist/types/masonry/types.d.ts +8 -3
  61. package/dist/types/scroll/ScrollBlock.d.ts +14 -1
  62. package/dist/types/scroll/i18n/en.d.ts +2 -0
  63. package/dist/types/scroll/i18n/fr.d.ts +2 -0
  64. package/dist/types/scroll/i18n/index.d.ts +9 -0
  65. package/dist/types/scroll/i18n/types.d.ts +11 -0
  66. package/dist/types/scroll/index.d.ts +2 -0
  67. package/dist/types/scroll/types.d.ts +6 -1
  68. package/dist/types/toast/Toast.d.ts +5 -1
  69. package/dist/types/toast/i18n/en.d.ts +2 -0
  70. package/dist/types/toast/i18n/fr.d.ts +2 -0
  71. package/dist/types/toast/i18n/index.d.ts +9 -0
  72. package/dist/types/toast/i18n/types.d.ts +7 -0
  73. package/dist/types/toast/index.d.ts +1 -0
  74. package/dist/types/toast/types.d.ts +9 -1
  75. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
- "use strict";var Wulf=(()=>{var _=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var X=(d,e)=>{for(var t in e)_(d,t,{get:e[t],enumerable:!0})},lt=(d,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of rt(e))!at.call(d,s)&&s!==t&&_(d,s,{get:()=>e[s],enumerable:!(i=ot(e,s))||i.enumerable});return d};var ht=d=>lt(_({},"__esModule",{value:!0}),d);var gt={};X(gt,{AmountEngine:()=>O,BaseInputMask:()=>L,EmailEngine:()=>R,InputAmountMask:()=>F,InputEmailMask:()=>W,InputMask:()=>P,Mask:()=>J,MaskEngine:()=>D,MaskHistory:()=>x,MaskKeyboard:()=>H,Masonry:()=>tt,Scroll:()=>Q,Toast:()=>et,default:()=>Z,resolveMaskConstructorArgs:()=>I});var J={};X(J,{AmountEngine:()=>O,BaseInputMask:()=>L,EmailEngine:()=>R,InputAmountMask:()=>F,InputEmailMask:()=>W,InputMask:()=>P,Mask:()=>it,MaskEngine:()=>D,MaskHistory:()=>x,MaskKeyboard:()=>H,default:()=>Z,resolveMaskConstructorArgs:()=>I});function I(d,e,t){return e&&typeof e=="object"&&"tagName"in e&&e.tagName==="INPUT"?{wrapper:d||null,input:e,options:t||{}}:{wrapper:null,input:d,options:e&&typeof e=="object"&&!("tagName"in e)?e:{}}}var L=class{constructor(e,t,i){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.onBaseCopy=e=>{if(!this.options.copyRaw||this.options.disabled||this.input.type==="password")return;let t=this.input.selectionStart??0,i=this.input.selectionEnd??t,s="";t!==i?s=this.extractRawSnippet(this.input.value.slice(t,i)):s=this.getRawValue(),s&&e.clipboardData&&(e.preventDefault(),e.clipboardData.setData("text/plain",s))};this.onBaseFocus=()=>{this.isFocused=!0,this.options.selectAllOnFocus&&this.input.value.length>0&&setTimeout(()=>{!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:s,input:n,options:o}=I(e,t,i);if(!n||!(n instanceof HTMLElement)||n.tagName!=="INPUT")throw new Error(`[${new.target.name||"InputMask"}] input (HTMLInputElement) est requis.`);this.input=n;let r=this.input.getAttribute("data-mask-create-wrapper")==="true",a=!!(o.createWrapper??r),u=s;if(!u&&a){let b=document.createElement("span");b.className="wulf-mask-wrapper",b.style.display="inline-grid",b.style.gridTemplateColumns="1fr",b.style.gridTemplateRows="1fr",b.style.verticalAlign="middle",b.style.boxSizing="border-box",b.style.position="relative",this.input.parentNode&&this.input.parentNode.insertBefore(b,this.input),b.appendChild(this.input),this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",u=b,this.isWrapperCreated=!0}if(!u)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=u,this.normalizeInputType();let h=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",f=this.getAttr("data-mask-align")||this.getAttr("data-align"),{disabled:m,align:g,...w}=o,v=m!==void 0?m:!!c,k=this.input.type==="password";this.options={...w,createWrapper:a,showMaskOnFocus:o.showMaskOnFocus??h??!1,selectAllOnFocus:o.selectAllOnFocus??l??!1,copyRaw:k?!1:o.copyRaw??p??!1,disabled:v,align:g??(f||void 0),emitNativeInput:o.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(e){return this.input.getAttribute(e)||this.wrapper.getAttribute(e)}hasAttr(e){return this.wrapper.hasAttribute(e)||this.input.hasAttribute(e)}hasNativePlaceholder(){return!!(this.input.placeholder&&this.input.placeholder.trim().length>0)}shouldHideGhostForPlaceholder(e){return!this.isFocused&&e&&this.hasNativePlaceholder()}bindBaseEvents(){this.input.addEventListener("copy",this.onBaseCopy),this.input.addEventListener("focus",this.onBaseFocus),this.input.addEventListener("blur",this.onBaseBlur)}extractRawSnippet(e){return e}initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(t=>{for(let i of t)i.type==="attributes"&&i.attributeName&&this.handleAttributeMutation(i.attributeName)});let e={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-disabled","data-mask-align","data-align","placeholder"]};this.mutationObserver.observe(this.wrapper,e),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,e)}setAlign(e){let t=e||void 0,i=this.wrapper.getAttribute("data-align");this.options.align===t&&i===(e||null)||(this.options.align=t,this.wrapper.classList.remove("align-left","align-right","align-center"),e?(this.wrapper.classList.add(`align-${e}`),this.wrapper.getAttribute("data-align")!==e&&this.wrapper.setAttribute("data-align",e)):this.wrapper.hasAttribute("data-align")&&this.wrapper.removeAttribute("data-align"),this.syncGhostStyles())}handleAttributeMutation(e){if(e==="data-disabled"){let t=this.hasAttr("data-disabled");t!==!!this.options.disabled&&this.setDisabled(t)}else if(e==="data-mask-focus-only"){let t=this.getAttr("data-mask-focus-only")==="true";t!==!!this.options.showMaskOnFocus&&this.setShowMaskOnFocus(t)}else if(e==="data-mask-select-on-focus")this.options.selectAllOnFocus=this.getAttr("data-mask-select-on-focus")==="true";else if(e==="data-mask-copy-raw")this.options.copyRaw=this.getAttr("data-mask-copy-raw")==="true";else if(e==="data-mask-align"||e==="data-align"){let t=this.getAttr("data-mask-align")||this.getAttr("data-align");t!==(this.options.align??null)&&this.setAlign(t)}}normalizeInputType(){let e=["number","email","date","datetime-local","month","week","time","color","file","range"];if(this.input.type&&e.includes(this.input.type.toLowerCase())){let t=this.input.type.toLowerCase();this.input.type="text",t==="number"&&(this.input.inputMode="numeric")}}createGhost(){let e=this.wrapper.querySelector(".mask-ghost");e&&e.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 e=window.getComputedStyle(this.input);if(!e)return;this.ghost.style.fontFamily=e.fontFamily,this.ghost.style.fontSize=e.fontSize,this.ghost.style.fontWeight=e.fontWeight,this.ghost.style.fontStyle=e.fontStyle,this.ghost.style.letterSpacing=e.letterSpacing,this.ghost.style.lineHeight=e.lineHeight,this.ghost.style.paddingTop=e.paddingTop,this.ghost.style.paddingBottom=e.paddingBottom,this.ghost.style.paddingLeft=e.paddingLeft,this.ghost.style.paddingRight=e.paddingRight,this.ghost.style.borderTopWidth=e.borderTopWidth,this.ghost.style.borderBottomWidth=e.borderBottomWidth,this.ghost.style.borderLeftWidth=e.borderLeftWidth,this.ghost.style.borderRightWidth=e.borderRightWidth,this.ghost.style.borderTopStyle=e.borderTopStyle==="none"?"none":"solid",this.ghost.style.borderBottomStyle=e.borderBottomStyle==="none"?"none":"solid",this.ghost.style.borderLeftStyle=e.borderLeftStyle==="none"?"none":"solid",this.ghost.style.borderRightStyle=e.borderRightStyle==="none"?"none":"solid",this.ghost.style.borderColor="transparent",this.ghost.style.boxSizing=e.boxSizing,this.ghost.style.textAlign=e.textAlign,this.ghost.style.direction=e.direction;let t=e.direction==="rtl"||this.input.getAttribute("dir")==="rtl"||this.wrapper.getAttribute("dir")==="rtl";e.textAlign==="right"||e.textAlign==="end"||t&&e.textAlign!=="left"&&e.textAlign!=="center"?this.ghost.style.justifyContent="flex-end":e.textAlign==="center"?this.ghost.style.justifyContent="center":this.ghost.style.justifyContent="flex-start"}setNativeValue(e){this.nativeValueDescriptor&&this.nativeValueDescriptor.set?this.nativeValueDescriptor.set.call(this.input,e):this.input.value=e}dispatchNativeInput(){if(!(this.isDestroyed||typeof window>"u")&&this.options.emitNativeInput!==!1){this.isDispatchingNativeInput=!0;try{let e=this.input._valueTracker;e&&typeof e.setValue=="function"&&e.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 e=HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(e,"value");if(!t||!t.set||!t.get)return;this.nativeValueDescriptor=t;let i=this;Object.defineProperty(this.input,"value",{get(){return t.get.call(this)},set(s){let n=String(s??"");t.set.call(this,n),!i.isDestroyed&&i.onNativeValueSet(n)},configurable:!0})}catch{}}unhookValueProperty(){try{delete this.input.value}catch{}}setShowMaskOnFocus(e){this.options.showMaskOnFocus=e,this.wrapper.classList.toggle("mask-focus-only",e)}disabled(e){if(e===void 0)return!!this.options.disabled;this.setDisabled(e)}setDisabled(e){this.options.disabled=!!e,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.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 ut={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()}},D=class d{constructor(e,t={}){this.patterns=[];this.subEngines=[];this.activeEngine=null;this.slots=[];this.fullMaskTemplate="";this.prefixSlotsCount=0;this.prefixString="";this.strict=!0;this.autoLowercase=!1;let i=t||{};this.placeholderChar=i.placeholderChar||"_",this.tokens={...ut,...i.tokens||{}},this.strict=i.strict!==!1,this.autoLowercase=i.autoLowercase??!1,this.pattern="",this.compile(e)}static format(e,t,i={}){return!t||Array.isArray(t)&&t.length===0?e??"":new d(t,i||{}).format(e??"")}compile(e){if(e!==void 0&&(Array.isArray(e)?(this.patterns=[...e],this.pattern=this.patterns[0]||""):(this.patterns=[],this.pattern=e)),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="",i=!0;for(let s=0;s<this.pattern.length;s++){let n=this.pattern[s],o=!1;n==="\\"&&s+1<this.pattern.length&&(o=!0,s++,n=this.pattern[s]);let r=o?void 0:this.tokens[n];r?(i=!1,this.slots.push({char:n,isStatic:!1,isPrefix:!1,token:r,placeholder:this.placeholderChar}),t+=this.placeholderChar):(this.slots.push({char:n,isStatic:!0,isPrefix:i,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(e){if(this.subEngines.length<=1)return this;let t=String(e??""),i=this.subEngines.filter(a=>{let u=a.getPrefix();return u.length>0&&t.toLowerCase().startsWith(u.trim().toLowerCase())}),s=i.length>0?i:this.subEngines,n=[...s].sort((a,u)=>u.getEditableCount()-a.getEditableCount())[0],r=(n?n.extractRaw(t):t).length;for(let a of s)if(a.getEditableCount()>=r)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(e=>e.getEditableCount())):this.activeEngine?this.activeEngine.getEditableCount():this.slots.filter(e=>!e.isStatic).length}isNumericOnly(){if(this.subEngines.length>0)return this.subEngines.every(i=>i.isNumericOnly());let t=(this.activeEngine?this.activeEngine.slots:this.slots).filter(i=>!i.isStatic);return t.length===0?!1:t.every(i=>i.char==="9"||i.token&&i.token.pattern.test("0")&&!i.token.pattern.test("a")&&!i.token.pattern.test("Z"))}setStrict(e){this.strict=e}isStrict(){return this.strict}extractRaw(e){if(this.subEngines.length>0){let o=this.selectEngine(e);if(o!==this)return o.extractRaw(e)}let t=String(e??"");if(!t)return"";let i="",s=0,n=0;if(this.prefixSlotsCount>0){for(;s<t.length&&(t[s]===" "||t[s]===" ");)s++;let o=0;for(;s<t.length&&o<this.prefixSlotsCount;){let r=this.slots[o].char,a=t[s];if(a.toUpperCase()===r.toUpperCase())s++,o++;else if(r===" "&&a!==" ")o++;else break}n=this.prefixSlotsCount}for(;s<t.length&&n<this.slots.length;){let o=this.slots[n],r=t[s];if(o.isStatic)r.toUpperCase()===o.char.toUpperCase()&&s++,n++;else if(o.token&&o.token.pattern.test(r)){let a=o.token.transform?o.token.transform(r):r;this.autoLowercase&&!o.token.transform&&(a=a.toLowerCase()),i+=a,s++,n++}else this.strict?s++:(i+=this.autoLowercase?r.toLowerCase():r,s++,n++)}if(!this.strict&&s<t.length){let o=t.slice(s);i+=this.autoLowercase?o.toLowerCase():o}return i}format(e){if(this.subEngines.length>0){let o=this.selectEngine(e);if(o!==this)return o.format(e)}let t=String(e??"");if(!this.slots.length)return t;let i=this.extractRaw(t);if(i.length===0)return this.prefixString;let s="",n=0;for(let o=0;o<this.slots.length;o++){let r=this.slots[o];if(r.isStatic){let a=n<i.length,u=n===0&&!!r.isPrefix,h=n>0&&n===i.length;if(a||u||h)s+=r.char;else break}else if(n<i.length){let a=i[n],u=r.token?.transform?r.token.transform(a):a;this.autoLowercase&&!r.token?.transform&&(u=u.toLowerCase()),s+=u,n++}else break}if(!this.strict&&n<i.length){let o=i.substring(n);s+=this.autoLowercase?o.toLowerCase():o}return s}getRemainingMask(e){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getRemainingMask(e):this.fullMaskTemplate?e.length>=this.fullMaskTemplate.length?e:e+this.fullMaskTemplate.substring(e.length):""}mapCursorPosition(e,t,i){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.mapCursorPosition(e,t,i);let s=this.prefixSlotsCount,n=String(e??""),o=String(i??"");if(t<=0||!o)return s;let a=this.extractRaw(n.slice(0,t)).length;if(a===0)return Math.max(s,Math.min(this.getNextEditablePosition(0),o.length));let u=0,h=o.length;for(let c=0;c<o.length&&c<this.slots.length;c++)if(!this.slots[c].isStatic&&(u++,u===a)){h=c+1;break}for(;h<o.length&&this.slots[h]&&this.slots[h].isStatic;)h++;return Math.max(s,Math.min(h,o.length))}isSeparatorAt(e){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.isSeparatorAt(e):e>=0&&e<this.slots.length?this.slots[e].isStatic:!1}getNextEditablePosition(e){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.getNextEditablePosition(e);let t=Math.max(0,e);for(let i=t;i<this.slots.length;i++)if(!this.slots[i].isStatic)return i;return this.slots.length}getSlotAt(e){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlotAt(e):this.slots[e]}getSlots(){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlots():this.slots}};var x=class{constructor(e=50){this.stack=[];this.index=-1;this.maxDepth=e}push(e,t){let i=this.getCurrent();if(i&&i.raw===e){i.cursor=t;return}this.stack=this.stack.slice(0,this.index+1),this.stack.push({raw:e,cursor:t}),this.stack.length>this.maxDepth&&this.stack.shift(),this.index=this.stack.length-1}updateCurrentCursor(e){let t=this.getCurrent();t&&(t.cursor=e)}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 H=class{constructor(e){this.delegate=e}handleKeyDown(e){let t=this.delegate.getInput(),i=this.delegate.getEngine(),s=this.delegate.getHistory(),n=i.getPrefixLength(),o=t.selectionStart??0,r=t.selectionEnd??o;if((e.ctrlKey||e.metaKey)&&(e.key==="z"||e.key==="Z")&&!e.shiftKey){e.preventDefault(),this.delegate.undo();return}if((e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="Y")||(e.ctrlKey||e.metaKey)&&e.shiftKey&&(e.key==="z"||e.key==="Z")){e.preventDefault(),this.delegate.redo();return}s.updateCurrentCursor(o);let a=e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey,u=r>o;if(a&&!u){let l=i.getSlots(),p=o<l.length&&l[o].isStatic&&l[o].char===e.key,f=o>0&&o-1<l.length&&l[o-1].isStatic&&l[o-1].char===e.key;if(p||f){e.preventDefault();let g=p?o:o-1,w=i.getNextEditablePosition(g+1);this.delegate.applyMask(t.value,w,!0);return}let m=-1;for(let g=o;g<l.length;g++)if(l[g].isStatic){l[g].char===e.key&&(m=g);break}if(m!==-1){e.preventDefault();let g=m-1;for(;g>=n&&!l[g].isStatic;)g--;g++;let w=m-g,v=t.value.slice(g,o);if(l.slice(g,m).every(y=>!y.token||y.token.pattern.test("0"))&&w>v.length&&v.length>0){let y=w-v.length,E="0".repeat(y)+v,C=t.value.slice(m),Y=t.value.slice(0,g)+E+C,M=i.getNextEditablePosition(m+1);this.delegate.applyMask(Y,M,!0);return}let b=i.getNextEditablePosition(m+1);this.delegate.applyMask(t.value,b,!0);return}}if(a&&i.isStrict()){let l=i.getEditableCount();if(l>0){let p=i.extractRaw(t.value),f=l-p.length;if(r>o){let m=i.extractRaw(t.value.slice(o,r));f=l-(p.length-m.length)}if(f<=0){e.preventDefault();return}}}if(r>o){if(e.key==="Backspace"||e.key==="Delete"){e.preventDefault();let l=t.value,p=l.slice(0,o)+l.slice(r);this.delegate.applyMask(p,Math.max(n,o));return}return}if(e.key==="ArrowLeft"&&!e.shiftKey&&o<=n){e.preventDefault(),t.setSelectionRange(n,n);return}if(e.key==="Home"&&!e.shiftKey){e.preventDefault(),t.setSelectionRange(n,n);return}if(e.key==="Backspace"&&o<=n){e.preventDefault(),t.setSelectionRange(n,n);return}if(e.key==="Delete"&&o<n){e.preventDefault(),t.setSelectionRange(n,n);return}if(e.key==="Backspace"&&(e.ctrlKey||e.altKey||e.metaKey)){if(e.preventDefault(),o<=n){t.setSelectionRange(n,n);return}let l=o-1;for(;l>=n&&i.isSeparatorAt(l);)l--;for(;l>=n&&!i.isSeparatorAt(l);)l--;let p=Math.max(n,l+1),f=t.value,m=f.slice(0,p)+f.slice(o);this.delegate.applyMask(m,p);return}if(e.key==="Delete"&&(e.ctrlKey||e.altKey||e.metaKey)){e.preventDefault();let l=t.value;if(o>=l.length)return;let p=o;for(;p<l.length&&i.isSeparatorAt(p);)p++;for(;p<l.length&&!i.isSeparatorAt(p);)p++;for(;p<l.length&&i.isSeparatorAt(p);)p++;let f=p,m=l.slice(0,o)+l.slice(f);this.delegate.applyMask(m,o);return}if(e.key==="Backspace"&&o>n){if(i.isSeparatorAt(o-1)){e.preventDefault();let l=o-1;for(;l>n&&i.isSeparatorAt(l-1);)l--;if(l>n){let p=t.value,f=p.slice(0,l-1)+p.slice(o);this.delegate.applyMask(f,l-1)}else this.delegate.applyMask("",n)}return}if(e.key==="Delete"&&o<t.value.length){if(i.isSeparatorAt(o)){e.preventDefault();let l=o;for(;l<t.value.length&&i.isSeparatorAt(l);)l++;if(l<t.value.length){let p=t.value,f=p.slice(0,l)+p.slice(l+1);this.delegate.applyMask(f,o)}}return}}handleKeyUp(e){let t=this.delegate.getInput(),i=this.delegate.getHistory();(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="Home")&&!e.shiftKey&&this.delegate.enforceMinCursor(),i.updateCurrentCursor(t.selectionStart??0)}};var P=class extends L{constructor(t,i,s){let n=I(t,i,s),o=n.wrapper,r=n.input,a=n.options,u=o?.getAttribute("data-mask")||r?.getAttribute("data-mask"),h=a.mask||u||"";typeof h=="string"&&h.includes("|")&&(h=h.split("|").map(y=>y.trim()));let c=a.placeholderChar||o?.getAttribute("data-mask-placeholder")||r?.getAttribute("data-mask-placeholder")||"_",l=o?.hasAttribute("data-disabled")||r?.hasAttribute("data-disabled"),p=o?.getAttribute("data-mask-strict")||r?.getAttribute("data-mask-strict"),f=o?.getAttribute("data-mask-auto-lowercase")==="true"||r?.getAttribute("data-mask-auto-lowercase")==="true",m=o?.getAttribute("data-mask-infer-inputmode")??r?.getAttribute("data-mask-infer-inputmode"),g=a.inferInputMode??(m!==null?m!=="false":!0),{disabled:w,...v}=a,k=w!==void 0?w:l?!0:!h||Array.isArray(h)&&h.length===0,b={...v,mask:h,placeholderChar:c,strict:a.strict??(p!==null?p!=="false":!0),autoLowercase:a.autoLowercase??f??!1,disabled:k,resetHistoryOnMaskChange:a.resetHistoryOnMaskChange??!1,inferInputMode:g,onInput:a.onInput||a.oninput,onChange:a.onChange||a.onchange,onComplete:a.onComplete||a.oncomplete};super(o,r,b);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.history=new x,this.engine=new D(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.options.inferInputMode&&!this.input.hasAttribute("inputmode")&&this.engine.isNumericOnly()&&(this.input.inputMode="numeric",this.wasInputModeInferred=!0),this.keyboard=new H({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(y,E,C)=>this.applyMask(y,E,C),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,i,s={}){return D.format(t,i,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=()=>{setTimeout(()=>{if(!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=()=>{setTimeout(()=>{this.isDestroyed||(this.options.disabled?this.checkValueChange():this.syncInitialValue())},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}destroy(){this.isDestroyed||(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,i){let s=typeof i=="boolean"?i:i&&typeof i=="object"&&i.strict!==void 0?i.strict:this.options.strict,n=i&&typeof i=="object"&&i.resetHistory!==void 0?i.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);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)}}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask"){let i=this.getAttr("data-mask");if(i===this.lastInternalRemainingMask)return;let s=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(i===s)return;if(i){let n=i.includes("|")?i.split("|").map(o=>o.trim()):i;this.setMask(n)}else this.setMask(null)}else if(t==="data-mask-strict"){let i=this.getAttr("data-mask-strict");this.setStrict(i!=="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 i=t!=null?String(t):"";if(this.options.disabled){this.input.value=i,this.checkValueChange();return}this.applyMask(i,i.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,i=this.input.selectionEnd??t,s=t!==i;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 i=this.engine.getEditableCount();if(i>0){let s=this.getRawValue(),n=this.input.selectionStart??0,o=this.input.selectionEnd??n,r=Math.max(0,i-s.length);if(o>n){let a=this.engine.extractRaw(this.input.value.slice(n,o));r=Math.max(0,i-(s.length-a.length))}r<=0&&t.preventDefault()}}}handleInput(t){if(this.isDispatchingNativeInput||this.isComposing)return;if(!!(this.options.onInput||this.options.oninput)&&this.input.value!==this.lastValue&&this.checkValueChange(),this.options.disabled){this.checkValueChange();return}let 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 o=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,o),this.checkSelection()}onKeyDown(t){this.options.disabled||this.keyboard.handleKeyDown(t)}onMouseDown(){this.isMouseDown=!0}onMouseUp(){this.isMouseDown=!1,this.checkSelection()}onPaste(t){if(this.options.disabled){setTimeout(()=>{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(),o=this.input.selectionStart??0,r=this.input.selectionEnd??o,a=this.input.value,u=this.engine.getEditableCount(),h=this.getRawValue(),l=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),p=s.replace(/[\s.-]+/g,"").toUpperCase(),f=l.length>0&&p.startsWith(l),m=a.slice(0,Math.max(n,o)).replace(/[\s.-]+/g,"").toUpperCase(),g=m.length>=2&&p.startsWith(m),w=Math.max(n,o),v=Math.max(n,r);(f||g)&&(w=0,v=a.length);let k=Math.max(0,u-h.length);if(w!==v){let E=this.engine.extractRaw(a.slice(w,v));k=Math.max(0,u-(h.length-E.length))}if(this.engine.isStrict()&&k<=0)return;let b,y;w===0&&v===a.length?(b=s,y=s.length):(b=a.slice(0,w)+s+a.slice(v),y=w+s.length),this.applyMask(b,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 i=this.input.selectionStart??0,s=this.input.selectionEnd??i;i===s&&i<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled){this.ghost.textContent="";return}let i=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(i)){this.ghost.textContent="";return}let s=this.engine.getFullMaskTemplate(),n=s.length>t.length?s.substring(t.length):"";this.ghost.textContent="";let o=document.createElement("span");o.className="mask-ghost-typed",o.textContent=t;let r=document.createElement("span");r.className="mask-ghost-remaining",r.textContent=n,this.ghost.appendChild(o),this.ghost.appendChild(r),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,i,s=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let n="",o=!1;try{n=this.engine.format(t);let r=this.engine.getRemainingMask(n);this.input.value=n,this.lastInternalRemainingMask=r,this.wrapper.setAttribute("data-mask",r),this.updateGhost(n);let a=this.engine.getPrefixLength(),u;if(s||this.isUndoingRedoing)u=Math.max(a,Math.min(i,n.length));else{let h=this.engine.mapCursorPosition(t,i,n);u=Math.max(a,h)}this.input.setSelectionRange(u,u),o=this.isComplete(),this.wrapper.classList.toggle("is-complete",o),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(this.getRawValue(),u)}finally{this.isApplyingMask=!1}this.checkValueChange()}syncInitialValue(){if(this.options.disabled){this.wrapper.removeAttribute("data-mask"),this.ghost&&(this.ghost.textContent=""),this.lastValue=this.input.value,this.checkValueChange();return}this.syncGhostStyles();let t=this.input.value||"";if(t)this.applyMask(t,t.length);else{let i=this.engine.getPrefixLength();if(i>0)this.applyMask("",i);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(),o=this.options.disabled?0:this.engine.getEditableCount(),r=this.isComplete(),a={value:s,rawValue:n,isComplete:r,totalSlots:o,filledSlots:this.options.disabled?s.length:n.length},u=this.options.onInput||this.options.oninput;u&&u(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;r&&(c&&c(a),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:a})))}}finally{this.isNotifying=!1}}}};var O=class d{constructor(e={}){let t=e.currency??"";!t&&e.unit&&(t=e.unit);let i=t==="$"||t==="\xA3"||t==="\xA5"?"prefix":"suffix";this.options={currency:t,unit:e.unit??t,currencyPosition:e.currencyPosition??i,decimals:e.decimals!==void 0?Math.max(0,e.decimals):2,decimalSeparator:e.decimalSeparator??",",thousandSeparator:e.thousandSeparator??"\xA0",allowNegative:e.allowNegative??!1,min:e.min??-1/0,max:e.max??1/0}}parse(e){let t=e.trim(),i=!1;this.options.allowNegative&&t.includes("-")&&(i=!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 o="",r=null,a=!1;return n!==-1?(o=t.substring(0,n).replace(/\D/g,""),this.options.decimals>0&&(a=!0,r=t.substring(n+1).replace(/\D/g,"").slice(0,this.options.decimals))):o=t.replace(/\D/g,""),o.length>1&&(o=o.replace(/^0+/,"")||"0"),{isNegative:i,integerPart:o,decimalPart:r,hasDecimal:a}}format(e,t=e.length,i=!1){if(!e||e.trim()===""||e===this.options.currency.trim())return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let s=e.substring(0,t),n=s.replace(/\D/g,"").length,o=this.options.decimals>0&&/[,.]/.test(s),{isNegative:r,integerPart:a,decimalPart:u,hasDecimal:h}=this.parse(e),c=u,l=h;if(i&&this.options.decimals>0&&(a||u!==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))),r&&!a&&!c&&!l&&this.options.allowNegative){let M="-",A=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(M=`${this.options.currency} -`,A=M.length):(M=`- ${this.options.currency}`,A=1)),{formatted:M,rawNumber:null,rawValue:"-",cursor:A,isValid:!0}}if(!a&&!c&&!l)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let f=(a||"0").replace(/\B(?=(\d{3})+(?!\d))/g,this.options.thousandSeparator);l&&this.options.decimals>0&&(f+=this.options.decimalSeparator+(c??"")),r&&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=(r?"-":"")+(a||"0")+(u?"."+u:""),w=parseFloat(g);isNaN(w)&&(w=0);let v=w>=this.options.min&&w<=this.options.max,k=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(k=this.options.currency.length+1);let b=0,y=!1,E=k;for(let M=k;M<m.length;M++){let A=m[M];if(A===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(A)?(b++,E=M+1):A===this.options.decimalSeparator&&(y=!0,E=M+1),o){if(y&&b>=n){k=M+1;break}}else if(b>=n){k=M+1;break}}n>0&&b<n&&E>k&&(k=E);let C=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,Y=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,m.length-this.options.currency.length-1):m.length;return k=Math.max(C,Math.min(k,Math.max(C,Y))),{formatted:m,rawNumber:w,rawValue:g,cursor:k,isValid:v}}static format(e,t={}){let i=new d(t),s=typeof e=="number"?e.toString():e;return i.format(s).formatted}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var F=class extends L{constructor(t,i,s){let n=I(t,i,s),o=n.wrapper,r=n.input,a=n.options,u=o?.getAttribute("data-mask-pad-decimals")==="true"||r?.getAttribute("data-mask-pad-decimals")==="true",h=r?.getAttribute("data-mask-align")||r?.getAttribute("data-align")||o?.getAttribute("data-mask-align")||o?.getAttribute("data-align"),c={align:a.align??h??"right",padDecimalsOnBlur:a.padDecimalsOnBlur??u??!1,...a};super(o,r,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 x,this.engine=new O(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 i=this.engine.parse(t);return!i.integerPart&&!i.decimalPart?"":(i.isNegative?"-":"")+(i.integerPart||"0")+(i.decimalPart?"."+i.decimalPart:"")}static format(t,i={}){return O.format(t,i)}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,i){if(!(this.isApplying||this.options.disabled)){this.isApplying=!0;try{let s=this.engine.format(t,i);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 i=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=i,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,i=this.input.selectionStart??t.length;this.applyAmount(t,i)}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 i=this.input.selectionStart??0,s=this.input.selectionEnd??0;if(i===s&&i>0){let n=this.input.value,o=n[i-1];if(o===this.engine.options.thousandSeparator||o===" "){t.preventDefault();let r=Math.max(0,i-2),a=n.slice(0,r)+n.slice(i);this.applyAmount(a,r);return}if(this.options.currency&&this.options.currencyPosition==="prefix"&&i<=this.options.currency.length+1){t.preventDefault();return}}}if(t.key==="Delete"){let i=this.input.selectionStart??0,s=this.input.selectionEnd??0;if(i===s&&i<this.input.value.length){let n=this.input.value,o=n[i];if(o===this.engine.options.thousandSeparator||o===" "){t.preventDefault();let r=n.slice(0,i)+n.slice(i+2);this.applyAmount(r,i);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let r=n.length-this.options.currency.length-1;if(i>=r){t.preventDefault();return}}}}setTimeout(()=>this.enforceCursorBounds(),0)}}enforceCursorBounds(){if(!this.input.value||this.options.disabled)return;let t=this.input.selectionStart??0,i=this.input.selectionEnd??0;if(t!==i)return;let s=this.input.value,n=this.options.currency;if(n){if(this.options.currencyPosition==="prefix"){let o=n.length+1;t<o&&this.input.setSelectionRange(o,o)}else if(this.options.currencyPosition==="suffix"){let o=Math.max(0,s.length-n.length-1);t>o&&this.input.setSelectionRange(o,o)}}}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 i=this.engine.format(this.input.value,this.input.value.length,!0);i.formatted!==this.input.value&&(this.setNativeValue(i.formatted),this.lastValue=i.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 i={value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid};this.options.onInput&&this.options.onInput(i),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:i})),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 i=t!=null?String(t):"";this.options.disabled?(this.setNativeValue(i),this.lastValue=i):this.applyAmount(i,i.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 j=class j{constructor(e={}){this.defaultDomain=null;this.domains=e.domains&&e.domains.length>0?e.domains:j.DEFAULT_DOMAINS,this.suggestOnAt=e.suggestOnAt??!0,this.setDefaultDomain(e.defaultDomain??null)}setDefaultDomain(e){e===!0?this.defaultDomain=this.domains.length>0?this.domains[0]:null:typeof e=="string"&&e.trim().length>0?this.defaultDomain=e.trim().replace(/^@/,""):this.defaultDomain=null}getMatchingDomains(e){let t=e??"";if(!t.includes("@"))return this.defaultDomain?[this.defaultDomain]:[];let i=t.indexOf("@");if(t.indexOf("@",i+1)!==-1)return[];let s=t.substring(i+1);if(s.length===0)return this.suggestOnAt?[...this.domains]:[];let n=s.toLowerCase();return this.domains.filter(o=>o.toLowerCase().startsWith(n)&&o.toLowerCase()!==n)}getSuggestion(e,t=0){let i=e??"";if(!i.includes("@"))return this.defaultDomain?{full:i?`${i}@${this.defaultDomain}`:`@${this.defaultDomain}`,remaining:`@${this.defaultDomain}`,matchedDomain:this.defaultDomain}:{full:i,remaining:"",matchedDomain:null};let s=i.indexOf("@"),n=i.substring(0,s),o=i.substring(s+1);if(i.indexOf("@",s+1)!==-1)return{full:i,remaining:"",matchedDomain:null};let r=this.getMatchingDomains(e);if(r.length===0)return{full:e,remaining:"",matchedDomain:null};let a=(t%r.length+r.length)%r.length,u=r[a],h=o.toLowerCase(),c=u.substring(h.length);return{full:`${n}@${u}`,remaining:c,matchedDomain:u}}};j.DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"];var R=j;var W=class extends L{constructor(t,i,s){let n=I(t,i,s),o=n.wrapper,r=n.input,a=n.options,u=o?.getAttribute("data-mask-cycle-suggestions")==="true"||r?.getAttribute("data-mask-cycle-suggestions")==="true",h=o?.getAttribute("data-mask-auto-lowercase")==="true"||r?.getAttribute("data-mask-auto-lowercase")==="true",c=o?.getAttribute("data-mask-aria-autocomplete")??r?.getAttribute("data-mask-aria-autocomplete"),l=a.setAriaAutocomplete??(c!==null?c!=="false":!0),p={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:a.cycleSuggestions??u??!1,autoLowercase:a.autoLowercase??h??!1,setAriaAutocomplete:l,...a};super(o,r,p);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 R(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 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 i=this.getDetail();this.options.onInput&&this.options.onInput(i),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:i})),this.dispatchNativeInput()}handleInput(){if(!this.isDispatchingNativeInput&&!this.options.disabled){if(this.options.autoLowercase){let t=this.input.selectionStart??0,i=this.input.selectionEnd??t,s=this.input.value.toLowerCase();s!==this.input.value&&(this.setNativeValue(s),this.input.setSelectionRange(t,i))}this.currentSuggestionIndex=0,this.updateSuggestion()}}handleKeyDown(t){if(this.options.disabled)return;let i=!!this.currentSuggestion.remaining,n=(this.input.selectionStart??0)===this.input.value.length,o=this.input.value.length>0;if(this.options.cycleSuggestions&&i&&o&&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"&&i&&o&&this.options.completeOnTab){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="Enter"&&i&&o&&this.options.completeOnEnter){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="ArrowRight"&&i&&o&&n&&this.options.completeOnArrowRight){t.preventDefault(),this.acceptSuggestion();return}}acceptSuggestion(){if(!this.currentSuggestion.remaining||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 i=this.getDetail();return this.options.onChange&&this.options.onChange(i),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:i})),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:i})),!0}setDefaultDomain(t){this.engine.setDefaultDomain(t),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){super.handleAttributeMutation(t),t==="data-mask-cycle-suggestions"?this.options.cycleSuggestions=this.getAttr("data-mask-cycle-suggestions")==="true":t==="data-mask-auto-lowercase"?this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true":t==="placeholder"&&this.updateSuggestion()}getDetail(){return{value:this.input.value,suggestedValue:this.currentSuggestion.full,domain:this.currentSuggestion.matchedDomain}}setValue(t){let i=t!=null?String(t):"";this.setNativeValue(i),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 it={BaseInputMask:L,InputMask:P,MaskEngine:D,MaskHistory:x,MaskKeyboard:H,AmountEngine:O,InputAmountMask:F,EmailEngine:R,InputEmailMask:W};if(typeof window<"u"){let d=window,e=d.Wulf||{};d.Wulf=e,e.Mask=it}var Z=P;var Q={};X(Q,{Scroll:()=>nt,ScrollBlock:()=>z,default:()=>ct});var st=0,z=class{constructor(e,t){this.createdViewport=!1;this.isDragging=!1;this.dragStartPos=0;this.dragStartScroll=0;this.atBottom=!1;this.atTop=!0;this.atRight=!1;this.atLeft=!0;let i=typeof e=="string"?document.querySelector(e):e;if(!i)throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${e}".`);this.root=i,this.options={axis:t?.axis||"y",autoHide:t?.autoHide??!0,autoHideDelay:t?.autoHideDelay??1e3,alwaysVisible:t?.alwaysVisible??!1,ariaLabel:t?.ariaLabel||"Zone de contenu d\xE9filable",minThumbSize:t?.minThumbSize??24,edgeThreshold:t?.edgeThreshold??10,onScroll:t?.onScroll||(()=>{}),onTotalScroll:t?.onTotalScroll||(()=>{}),onTotalScrollBack:t?.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 e=this.root.querySelector(":scope > .wulf-scrollblock-viewport");if(e)return e;let t=document.createElement("div");for(t.className="wulf-scrollblock-viewport";this.root.firstChild;)t.appendChild(this.root.firstChild);return this.root.appendChild(t),this.createdViewport=!0,t}setupAccessibility(){this.viewport.id||(st+=1,this.viewport.id=`wulf-scrollblock-vp-${st}`),this.viewport.setAttribute("role","region"),this.viewport.setAttribute("aria-label",this.options.ariaLabel)}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","D\xE9filement vertical"),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","D\xE9filement horizontal"),this.trackX.appendChild(this.thumbX),this.root.appendChild(this.trackX),this.attachTrackListeners(this.trackX,this.thumbX,"x"))}attachTrackListeners(e,t,i){t.addEventListener("pointerdown",s=>{s.preventDefault(),s.stopPropagation(),this.isDragging=!0,this.dragAxis=i,this.dragPointerId=s.pointerId,this.dragStartPos=i==="y"?s.clientY:s.clientX,this.dragStartScroll=i==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,t.setPointerCapture(s.pointerId),t.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)}),e.addEventListener("pointerdown",s=>{if(s.target===t)return;s.preventDefault();let n=e.getBoundingClientRect(),o=i==="y"?s.clientY-n.top:s.clientX-n.left,r=i==="y"?n.height:n.width,a=i==="y"?this.viewport.clientHeight:this.viewport.clientWidth,u=i==="y"?this.viewport.scrollHeight:this.viewport.scrollWidth,c=o/r*(u-a);this.scrollTo(i==="y"?{top:c}:{left:c},{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(e){if(!this.isDragging||!this.dragAxis)return;let t=this.dragAxis==="y",i=(t?e.clientY:e.clientX)-this.dragStartPos,s=t?this.trackY:this.trackX,n=t?this.thumbY:this.thumbX;if(!s||!n)return;let o=t?s.clientHeight:s.clientWidth,r=t?n.clientHeight:n.clientWidth,a=t?this.viewport.clientHeight:this.viewport.clientWidth,h=(t?this.viewport.scrollHeight:this.viewport.scrollWidth)-a,c=o-r;if(c<=0||h<=0)return;let l=h/c,p=this.dragStartScroll+i*l;t?this.viewport.scrollTop=Math.max(0,Math.min(h,p)):this.viewport.scrollLeft=Math.max(0,Math.min(h,p))}handlePointerUp(e){if(this.isDragging){if(this.dragPointerId!==void 0){let t=this.dragAxis==="y"?this.thumbY:this.thumbX;t&&t.hasPointerCapture(this.dragPointerId)&&t.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:e,scrollLeft:t,scrollHeight:i,scrollWidth:s,clientHeight:n,clientWidth:o}=this.viewport,r=Math.max(0,i-n),a=Math.max(0,s-o),u=r>0?e/r:0,h=a>0?t/a:0;this.options.onScroll({top:e,left:t,maxTop:r,maxLeft:a,progressY:Math.round(u*100),progressX:Math.round(h*100)});let c=this.options.edgeThreshold;if(r>0){let l=e>=r-c,p=e<=c;l&&!this.atBottom&&this.options.onTotalScroll("bottom"),p&&!this.atTop&&this.options.onTotalScrollBack("top"),this.atBottom=l,this.atTop=p}if(a>0){let l=t>=a-c,p=t<=c;l&&!this.atRight&&this.options.onTotalScroll("right"),p&&!this.atLeft&&this.options.onTotalScrollBack("left"),this.atRight=l,this.atLeft=p}this.options.autoHide&&!this.options.alwaysVisible&&(this.root.classList.add("is-scrolling"),this.scheduleAutoHide())}syncThumbs(){let{scrollTop:e,scrollLeft:t,scrollHeight:i,scrollWidth:s,clientHeight:n,clientWidth:o}=this.viewport;if(this.thumbY&&this.trackY){let r=i-n,a=this.trackY.clientHeight,u=this.thumbY.clientHeight,h=a-u;if(r>0&&h>0){let c=e/r,l=Math.max(0,Math.min(h,c*h));this.thumbY.style.transform=`translate3d(0, ${l}px, 0)`,this.thumbY.setAttribute("aria-valuenow",String(Math.round(c*100)))}}if(this.thumbX&&this.trackX){let r=s-o,a=this.trackX.clientWidth,u=this.thumbX.clientWidth,h=a-u;if(r>0&&h>0){let c=t/r,l=Math.max(0,Math.min(h,c*h));this.thumbX.style.transform=`translate3d(${l}px, 0, 0)`,this.thumbX.setAttribute("aria-valuenow",String(Math.round(c*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(){let{scrollHeight:e,clientHeight:t,scrollWidth:i,clientWidth:s}=this.viewport,n=e>t,o=i>s;if(this.root.classList.toggle("has-scroll-y",n),this.root.classList.toggle("has-scroll-x",o),n||o?this.viewport.setAttribute("tabindex","0"):this.viewport.removeAttribute("tabindex"),this.trackY&&this.thumbY&&n){let r=this.trackY.clientHeight,a=Math.max(this.options.minThumbSize,r*(t/e));this.thumbY.style.height=`${a}px`}if(this.trackX&&this.thumbX&&o){let r=this.trackX.clientWidth,a=Math.max(this.options.minThumbSize,r*(s/i));this.thumbX.style.width=`${a}px`}this.syncThumbs()}scrollTo(e,t){let i=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,s=typeof e=="object"&&e!==null&&!(e instanceof HTMLElement)?e.smooth:void 0,o=(t?.smooth??s??!0)&&!i?"smooth":"auto",r=Math.max(0,this.viewport.scrollHeight-this.viewport.clientHeight),a=Math.max(0,this.viewport.scrollWidth-this.viewport.clientWidth),u,h;if(typeof e=="number")u=e;else if(typeof e=="string")switch(e){case"top":u=0;break;case"bottom":u=r;break;case"left":h=0;break;case"right":h=a;break;default:{let c=null;try{c=this.viewport.querySelector(e)}catch{c=null}c&&(u=c.offsetTop,h=c.offsetLeft);break}}else e instanceof HTMLElement?(u=e.offsetTop,h=e.offsetLeft):typeof e=="object"&&(u=e.top,h=e.left);this.viewport.scrollTo({top:u!==void 0?Math.max(0,Math.min(r,u)):void 0,left:h!==void 0?Math.max(0,Math.min(a,h)):void 0,behavior:o})}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()}}};var nt={ScrollBlock:z};var ct=z;if(typeof window<"u"){let d=window,e=d.Wulf||{};d.Wulf=e,e.Scroll=nt}var tt={};X(tt,{LayoutEngine:()=>N,Masonry:()=>B,default:()=>pt});var N=class{static parseGutter(e){return typeof e=="number"?{x:Math.max(0,e),y:Math.max(0,e)}:e&&typeof e=="object"?{x:Math.max(0,Number(e.x)||0),y:Math.max(0,Number(e.y)||0)}:{x:0,y:0}}static resolveColumnWidth(e,t,i){if(typeof i=="number"&&i>0)return i;if(typeof i=="string"){let n=e.querySelector(i);if(n){let r=n.getBoundingClientRect().width;if(r>0)return r}let o=parseFloat(i);if(!isNaN(o)&&o>0)return i.endsWith("%")?e.getBoundingClientRect().width*o/100:o}if(i instanceof HTMLElement){let n=i.getBoundingClientRect().width;if(n>0)return n}if(t){let n=t.getBoundingClientRect().width;if(n>0)return n}let s=e.getBoundingClientRect().width;return s>0?s:200}static getItemSpan(e,t,i,s){let n=e.getAttribute("data-masonry-span")||e.dataset.masonrySpan;if(n){let r=parseInt(n,10);if(!isNaN(r)&&r>0)return Math.min(s,r)}let o=e.className.match(/(?:^|\s)(?:span|col-span)-(\d+)(?:\s|$)/);if(o&&o[1]){let r=parseInt(o[1],10);if(!isNaN(r)&&r>0)return Math.min(s,r)}return 1}static calculate(e,t,i){let n=e.getBoundingClientRect().width,{x:o,y:r}=this.parseGutter(i.gutter);if(n<=0||t.length===0)return{cols:1,colWidth:n,gutterX:o,gutterY:r,containerHeight:0,containerWidth:n,positions:[]};let a=t[0]||null,u=this.resolveColumnWidth(e,a,i.columnWidth),h=Math.floor((n+o)/(u+o));h=Math.max(1,h),!i.columnWidth&&h>1&&(u=(n-(h-1)*o)/h);let c=i.fitWidth?h*u+(h-1)*o:void 0,l=new Array(h).fill(0),p=[],f=t.map(v=>{let k=v.getBoundingClientRect().height;return k>0?k:50}),m=0;for(let v=0;v<t.length;v++){let k=t[v],b=f[v],y=this.getItemSpan(k,u,o,h),E=0,C=0;if(i.horizontalOrder){m+y>h&&(m=0),E=m;let T=0;for(let S=0;S<y;S++)l[E+S]>T&&(T=l[E+S]);C=T,m=(E+y)%h}else if(y===1){let T=l[0];E=0;for(let S=1;S<h;S++)l[S]<T&&(T=l[S],E=S);C=T}else{let T=1/0;E=0;for(let S=0;S<=h-y;S++){let $=0;for(let q=0;q<y;q++)l[S+q]>$&&($=l[S+q]);$<T&&(T=$,E=S)}C=T}let Y=y*u+(y-1)*o,M=E*(u+o);p.push({element:k,x:M,y:C,width:Y,height:b,column:E,span:y});let A=C+b+r;for(let T=0;T<y;T++)l[E+T]=A}let g=0;for(let v=0;v<h;v++)l[v]>g&&(g=l[v]);let w=Math.max(0,g>0?g-r:0);return{cols:h,colWidth:u,gutterX:o,gutterY:r,containerHeight:w,containerWidth:n,fittedWidth:c,positions:p}}};var B=class{constructor(e,t={}){this.isNativeCSSGrid=!1;this._items=[];this.resizeObserver=null;this.itemResizeObserver=null;this.layoutRafId=null;this.isDestroyed=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.removeTimers=new Set;this.pendingImageListeners=[];if(typeof e=="string"){let s=document.querySelector(e);if(!s)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${e}"`);this.root=s}else if(e instanceof HTMLElement)this.root=e;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.options={itemSelector:t.itemSelector||"> *",columnWidth:t.columnWidth??0,gutter:t.gutter??0,percentPosition:t.percentPosition!==!1,fitWidth:!!t.fitWidth,horizontalOrder:!!t.horizontalOrder,transitionDuration:t.transitionDuration!==void 0?t.transitionDuration:300,stagger:t.stagger||0,resize:t.resize!==!1,autoImages:t.autoImages!==!1,useNativeCSSGrid:t.useNativeCSSGrid!==!1,ariaRole:t.ariaRole||"region",ariaLabel:t.ariaLabel||"Galerie en grille asym\xE9trique",onLayout:t.onLayout||(()=>{}),onItemPlaced:t.onItemPlaced||(()=>{})};let i=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("grid-template-rows","masonry");this.options.useNativeCSSGrid&&i?(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),this.options.ariaLabel&&!this.root.hasAttribute("aria-label")&&(this.root.setAttribute("aria-label",this.options.ariaLabel),this.wasAriaLabelInferred=!0)}applyTransitionDuration(){let e=this.options.transitionDuration,t=typeof e=="number"?`${e}ms`:e;this.root.style.setProperty("--wulf-masonry-duration",t)}reloadItems(){if(this.isDestroyed)return;let e=[];if(this.options.itemSelector==="> *")e=Array.from(this.root.children).filter(t=>t instanceof HTMLElement&&!t.hasAttribute("data-masonry-ignore"));else try{e=Array.from(this.root.querySelectorAll(this.options.itemSelector)).filter(t=>t.parentElement===this.root&&!t.hasAttribute("data-masonry-ignore"))}catch{e=Array.from(this.root.children).filter(t=>t instanceof HTMLElement&&!t.hasAttribute("data-masonry-ignore"))}this._items=e;for(let t of this._items)t.classList.add("wulf-masonry-item"),this.itemResizeObserver&&this.itemResizeObserver.observe(t)}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let e=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(t=>{for(let i of t){let s=i.contentRect.width;Math.abs(s-e)>=1&&(e=s,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(()=>{this.scheduleLayout()});for(let t of this._items)this.itemResizeObserver.observe(t)}initImages(){if(!this.options.autoImages)return;let e=Array.from(this.root.querySelectorAll("img"));for(let t of e)if(!t.complete){let i=()=>{let s=()=>{this.pendingImageListeners=this.pendingImageListeners.filter(n=>n.handler!==s),this.isDestroyed||this.scheduleLayout()};this.pendingImageListeners.push({img:t,handler:s}),t.addEventListener("load",s,{once:!0})};typeof t.decode=="function"?t.decode().then(()=>{this.isDestroyed||this.scheduleLayout()}).catch(()=>{i()}):i()}}scheduleLayout(){this.isDestroyed||(this.layoutRafId!==null&&cancelAnimationFrame(this.layoutRafId),this.layoutRafId=requestAnimationFrame(()=>{this.layoutRafId=null,this.layout()}))}layout(){if(this.isDestroyed)return;if(this.isNativeCSSGrid){this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true");let e=N.calculate(this.root,this._items,this.options);this.root.style.height=`${e.containerHeight}px`,this.options.fitWidth&&e.fittedWidth!==void 0?(this.root.style.width=`${e.fittedWidth}px`,this.root.classList.add("wulf-masonry--fit-width")):this.root.classList.remove("wulf-masonry--fit-width");let t=this.options.stagger;for(let i=0;i<e.positions.length;i++){let s=e.positions[i],n=s.element;n.style.setProperty("--wulf-masonry-w",`${s.width}px`),n.style.setProperty("--wulf-masonry-x",`${s.x}px`),n.style.setProperty("--wulf-masonry-y",`${s.y}px`),t>0?n.style.transitionDelay=`${i*t}ms`:n.style.removeProperty("transition-delay"),n.classList.remove("wulf-masonry-item--hidden"),this.options.onItemPlaced(n,s)}this.root.setAttribute("aria-busy","false"),this.options.onLayout(e.positions)}append(e){if(this.isDestroyed)return;let t=Array.isArray(e)?e:[e];if(t.length===0)return;let i=document.createDocumentFragment();for(let s of t)s.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),i.appendChild(s);this.root.appendChild(i),this.reloadItems(),this.initImages(),this.layout()}prepend(e){if(this.isDestroyed)return;let t=Array.isArray(e)?e:[e];if(t.length===0)return;let i=this.root.firstChild,s=document.createDocumentFragment();for(let n of t)n.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),s.appendChild(n);this.root.insertBefore(s,i),this.reloadItems(),this.initImages(),this.layout()}remove(e){if(this.isDestroyed)return;let t=Array.isArray(e)?e:[e];if(t.length===0)return;for(let n of t)n.classList.add("wulf-masonry-item--hidden");let i=typeof this.options.transitionDuration=="number"?this.options.transitionDuration:300;if(i<=0){for(let n of t)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 t)n.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(n),this.root.removeChild(n));this.reloadItems(),this.layout()}},i);this.removeTimers.add(s)}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(let e of this.removeTimers)clearTimeout(e);this.removeTimers.clear();for(let{img:e,handler:t}of this.pendingImageListeners)e.removeEventListener("load",t);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.options.ariaLabel&&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 e of this._items)e.classList.remove("wulf-masonry-item","wulf-masonry-item--hidden"),e.style.removeProperty("--wulf-masonry-w"),e.style.removeProperty("--wulf-masonry-x"),e.style.removeProperty("--wulf-masonry-y"),e.style.removeProperty("transition-delay");this._items=[]}}};var pt=B;if(typeof window<"u"){let d=window,e=d.Wulf||{};d.Wulf=e,e.Masonry=Object.assign(B,{Masonry:B,LayoutEngine:N})}var et={};X(et,{Toast:()=>U,ToastInstance:()=>G,ToastManager:()=>K,default:()=>mt});var dt=1,G=class{constructor(e,t){this._isClosed=!1;this.timerId=null;this.remainingTime=0;this.timerStartTime=0;this.isPaused=!1;this.id=`wulf-toast-${dt++}`,this.options=Object.freeze({...e}),this.onDismissCallback=t;let i=e.duration===void 0?4e3:e.duration;typeof i=="number"&&i>0?this.remainingTime=i:this.remainingTime=0,this.element=this.createDOM(),this.bindEvents()}get isClosed(){return this._isClosed}createDOM(){let e=document.createElement("div");e.id=this.id,e.className="wulf-toast";let t=this.options.role==="alert"?"alert":"status";if(e.setAttribute("role",t),e.setAttribute("aria-live",t==="alert"?"assertive":"polite"),e.setAttribute("aria-atomic","true"),this.options.backgroundColor&&e.style.setProperty("--wulf-toast-bg",this.options.backgroundColor),this.options.titleColor&&e.style.setProperty("--wulf-toast-title-color",this.options.titleColor),this.options.textColor&&e.style.setProperty("--wulf-toast-text-color",this.options.textColor),this.options.iconColor&&e.style.setProperty("--wulf-toast-icon-color",this.options.iconColor),this.options.closeButtonColor&&e.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor),this.options.icon&&this.options.icon.trim()!==""){let n=document.createElement("span");n.className=`wulf-toast-icon ${this.options.icon.trim()}`,n.setAttribute("aria-hidden","true"),e.appendChild(n)}let i=document.createElement("div");if(i.className="wulf-toast-content",this.options.title&&this.options.title.trim()!==""){let n=document.createElement("div");n.className="wulf-toast-title",this.appendTextWithLineBreaks(n,this.options.title),i.appendChild(n)}if(this.options.message&&this.options.message.trim()!==""){let n=document.createElement("div");n.className="wulf-toast-message",this.appendTextWithLineBreaks(n,this.options.message),i.appendChild(n)}if(e.appendChild(i),this.options.closable!==void 0?this.options.closable:this.remainingTime===0||this.options.closable===!0||!0){let n=document.createElement("button");n.type="button",n.className="wulf-toast-close",n.setAttribute("aria-label","Fermer la notification"),n.setAttribute("tabindex","0");let o=document.createElement("span");o.className="wulf-toast-close-icon",o.setAttribute("aria-hidden","true"),o.textContent="\xD7",n.appendChild(o),n.addEventListener("click",r=>{r.stopPropagation(),this.close("close-button")}),e.appendChild(n)}return e}appendTextWithLineBreaks(e,t){t.split(/\r\n|\r|\n/).forEach((s,n)=>{n>0&&e.appendChild(document.createElement("br")),e.appendChild(document.createTextNode(s))})}bindEvents(){this.element.addEventListener("click",e=>{this.options.onClick&&this.options.onClick(this,e)}),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 e=Date.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-e),this.isPaused=!0}resumeTimer(){this._isClosed||this.remainingTime<=0||!this.isPaused||(this.isPaused=!1,this.startTimer())}destroyImmediate(e="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,e),this.options.onClose&&this.options.onClose(this,e))}close(e="programmatic",t=!1){return this._isClosed?Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),new Promise(i=>{this.element.classList.add(t?"wulf-toast-hiding-fast":"wulf-toast-hiding");let s=()=>{this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,e),this.options.onClose&&this.options.onClose(this,e),i()};if(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)s();else if(t)window.setTimeout(s,90);else{let o=!1,r=()=>{o||(o=!0,this.element.removeEventListener("animationend",r),this.element.removeEventListener("transitionend",r),s())};this.element.addEventListener("animationend",r,{once:!0}),this.element.addEventListener("transitionend",r,{once:!0}),window.setTimeout(r,300)}}))}};var V=class V{constructor(){this.containers=new Map;this.activeToasts=new Map;this.replaceTokens=new Map;this.pendingReplacements=new Set}static getInstance(){return V.instance||(V.instance=new V),V.instance}add(e){let t=e.options.position||"top-right",i=this.activeToasts.get(t);if(i||(i=[],this.activeToasts.set(t,i)),e.options.replace&&i.length>0){let n=[...i],o=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,o),this.pendingReplacements.add(t);let r=n.map(a=>a.close("replace",!0));Promise.all(r).then(()=>{this.pendingReplacements.delete(t),this.replaceTokens.get(t)===o&&this.mountToast(e,t)});return}let s=typeof e.options.maxToasts=="number"&&e.options.maxToasts>0?e.options.maxToasts:5;if(i.length>=s){let n=i.length-s+1,o=i.splice(0,n);for(let r of o)r.close("max-limit",!0)}this.mountToast(e,t)}mountToast(e,t){let i=this.getOrCreateContainer(t),s=this.activeToasts.get(t);if(s||(s=[],this.activeToasts.set(t,s)),i.appendChild(e.element),s.push(e),e.options.onOpen)try{e.options.onOpen(e)}catch(n){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",n)}e.startTimer()}remove(e,t){let i=e.options.position||"top-right",s=this.activeToasts.get(i);if(s){let n=s.indexOf(e);if(n!==-1&&s.splice(n,1),s.length===0&&!this.pendingReplacements.has(i)){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))}}}clearAll(e){let t=[];if(e){let i=this.activeToasts.get(e);if(i&&i.length>0){let s=[...i];for(let n of s)t.push(n.close("programmatic"))}else{let s=this.containers.get(e);s&&(!s.firstChild||s.children.length===0)&&(s.parentNode&&s.parentNode.removeChild(s),this.containers.delete(e),this.activeToasts.delete(e))}}else{let i=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let s of i)t.push(this.clearAll(s))}return Promise.all(t).then(()=>{if(!e)for(let[i,s]of Array.from(this.containers.entries()))(!s.firstChild||s.children.length===0)&&(s.parentNode&&s.parentNode.removeChild(s),this.containers.delete(i),this.activeToasts.delete(i))})}getOrCreateContainer(e){let t=this.containers.get(e);return(!t||!document.body.contains(t))&&(t=document.createElement("div"),t.className=`wulf-toast-container wulf-toast-${e}`,t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions removals"),document.body.appendChild(t),this.containers.set(e,t)),t}};V.instance=null;var K=V;var U=class{static show(e={}){let t=K.getInstance(),i=new G(e,(s,n)=>{t.remove(s,n)});return t.add(i),i}static clearAll(e){return K.getInstance().clearAll(e)}};var mt=U;if(typeof window<"u"){let d=window,e=d.Wulf||{};d.Wulf=e,e.Toast=U}return ht(gt);})();
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
2
  if (typeof window !== "undefined") { window.Wulf = window.Wulf || {}; if (typeof Wulf !== "undefined" && Wulf) { var targets = ["Mask", "Scroll", "Masonry", "Toast"]; 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
3
  //# sourceMappingURL=index.global.min.js.map