wulf.js 1.9.0 → 1.9.1

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 (67) hide show
  1. package/README.md +75 -7
  2. package/changelog.md +21 -0
  3. package/dist/focus-trap.cjs.js +430 -0
  4. package/dist/focus-trap.cjs.js.map +7 -0
  5. package/dist/focus-trap.esm.js +407 -0
  6. package/dist/focus-trap.esm.js.map +7 -0
  7. package/dist/focus-trap.global.js +433 -0
  8. package/dist/focus-trap.global.js.map +7 -0
  9. package/dist/focus-trap.global.min.js +6 -0
  10. package/dist/focus-trap.global.min.js.map +7 -0
  11. package/dist/index.cjs.js +590 -8
  12. package/dist/index.cjs.js.map +3 -3
  13. package/dist/index.esm.js +590 -8
  14. package/dist/index.esm.js.map +3 -3
  15. package/dist/index.global.js +590 -8
  16. package/dist/index.global.js.map +3 -3
  17. package/dist/index.global.min.js +4 -1
  18. package/dist/index.global.min.js.map +4 -4
  19. package/dist/mask.cjs.js +106 -2
  20. package/dist/mask.cjs.js.map +3 -3
  21. package/dist/mask.esm.js +106 -2
  22. package/dist/mask.esm.js.map +3 -3
  23. package/dist/mask.global.js +106 -2
  24. package/dist/mask.global.js.map +3 -3
  25. package/dist/mask.global.min.js +4 -1
  26. package/dist/mask.global.min.js.map +4 -4
  27. package/dist/masonry.cjs.js +78 -3
  28. package/dist/masonry.cjs.js.map +3 -3
  29. package/dist/masonry.esm.js +78 -3
  30. package/dist/masonry.esm.js.map +3 -3
  31. package/dist/masonry.global.js +78 -3
  32. package/dist/masonry.global.js.map +3 -3
  33. package/dist/masonry.global.min.js +4 -1
  34. package/dist/masonry.global.min.js.map +4 -4
  35. package/dist/scroll.cjs.js +78 -3
  36. package/dist/scroll.cjs.js.map +3 -3
  37. package/dist/scroll.esm.js +78 -3
  38. package/dist/scroll.esm.js.map +3 -3
  39. package/dist/scroll.global.js +78 -3
  40. package/dist/scroll.global.js.map +3 -3
  41. package/dist/scroll.global.min.js +4 -1
  42. package/dist/scroll.global.min.js.map +4 -4
  43. package/dist/toast.cjs.js +91 -2
  44. package/dist/toast.cjs.js.map +3 -3
  45. package/dist/toast.esm.js +91 -2
  46. package/dist/toast.esm.js.map +3 -3
  47. package/dist/toast.global.js +91 -2
  48. package/dist/toast.global.js.map +3 -3
  49. package/dist/toast.global.min.js +4 -1
  50. package/dist/toast.global.min.js.map +4 -4
  51. package/dist/types/common/AuditableComponent.d.ts +45 -0
  52. package/dist/types/common/LocalizedComponent.d.ts +3 -2
  53. package/dist/types/focus-trap/FocusTrap.d.ts +64 -0
  54. package/dist/types/focus-trap/index.d.ts +3 -0
  55. package/dist/types/focus-trap/types.d.ts +45 -0
  56. package/dist/types/index.d.ts +3 -0
  57. package/dist/types/mask/BaseInputMask.d.ts +14 -1
  58. package/dist/types/mask/InputMask.d.ts +1 -0
  59. package/dist/types/mask/types.d.ts +5 -2
  60. package/dist/types/masonry/Masonry.d.ts +7 -0
  61. package/dist/types/masonry/types.d.ts +7 -2
  62. package/dist/types/scroll/ScrollBlock.d.ts +7 -0
  63. package/dist/types/scroll/types.d.ts +3 -2
  64. package/dist/types/toast/Toast.d.ts +3 -0
  65. package/dist/types/toast/ToastInstance.d.ts +9 -1
  66. package/dist/types/toast/types.d.ts +3 -2
  67. package/package.json +9 -3
@@ -1,3 +1,6 @@
1
- "use strict";var Wulf=(()=>{var st=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var wt=Object.prototype.hasOwnProperty;var J=(m,i)=>{for(var t in i)st(m,t,{get:i[t],enumerable:!0})},Tt=(m,i,t,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of yt(i))!wt.call(m,o)&&o!==t&&st(m,o,{get:()=>i[o],enumerable:!(e=bt(i,o))||e.enumerable});return m};var kt=m=>Tt(st({},"__esModule",{value:!0}),m);var Ct={};J(Ct,{AmountEngine:()=>R,BaseInputMask:()=>x,EmailEngine:()=>V,InputAmountMask:()=>$,InputEmailMask:()=>X,InputMask:()=>z,LocalizedComponent:()=>S,Mask:()=>ot,MaskEngine:()=>H,MaskHistory:()=>C,MaskKeyboard:()=>N,Masonry:()=>ct,Scroll:()=>lt,Toast:()=>mt,createI18nManager:()=>A,default:()=>nt,resolveMaskConstructorArgs:()=>O});var ot={};J(ot,{AmountEngine:()=>R,BaseInputMask:()=>x,EmailEngine:()=>V,InputAmountMask:()=>$,InputEmailMask:()=>X,InputMask:()=>z,Mask:()=>ft,MaskEngine:()=>H,MaskHistory:()=>C,MaskKeyboard:()=>N,default:()=>nt,resolveMaskConstructorArgs:()=>O});function O(m,i,t){return i&&typeof i=="object"&&"tagName"in i&&i.tagName==="INPUT"?{wrapper:m||null,input:i,options:t||{}}:{wrapper:null,input:m,options:i&&typeof i=="object"&&!("tagName"in i)?i:{}}}var x=class{constructor(i,t,e){this.ghost=null;this.isWrapperCreated=!1;this.isDestroyed=!1;this.isFocused=!1;this.isDispatchingNativeInput=!1;this.lastTrackedValue="";this.nativeValueDescriptor=null;this.onCutHandler=()=>{};this.mutationObserver=null;this.focusSelectTimerId=null;this.onBaseCopy=i=>{if(!this.options.copyRaw||this.options.disabled||this.input.type==="password")return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,o="";t!==e?o=this.extractRawSnippet(this.input.value.slice(t,e)):o=this.getRawValue(),o&&i.clipboardData&&(i.preventDefault(),i.clipboardData.setData("text/plain",o))};this.onBaseFocus=()=>{this.isFocused=!0,this.options.selectAllOnFocus&&this.input.value.length>0&&(this.focusSelectTimerId!==null&&clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=window.setTimeout(()=>{this.focusSelectTimerId=null,!this.isDestroyed&&document.activeElement===this.input&&this.input.select()},0))};this.onBaseBlur=()=>{this.isFocused=!1};this.onScroll=()=>{this.ghost&&(this.ghost.scrollLeft=this.input.scrollLeft)};let{wrapper:o,input:s,options:n}=O(i,t,e);if(!s||typeof s!="object"||s.nodeType!==1||s.tagName!=="INPUT")throw new Error(`[${new.target.name||"InputMask"}] input (HTMLInputElement) est requis.`);this.input=s;let a=this.input.getAttribute("data-mask-create-wrapper")==="true",r=!!(n.createWrapper??a),h=o;if(!h&&r){let y=document.createElement("span");y.className="wulf-mask-wrapper",y.style.display="inline-grid",y.style.gridTemplateColumns="1fr",y.style.gridTemplateRows="1fr",y.style.verticalAlign="middle",y.style.boxSizing="border-box",y.style.position="relative",this.input.parentNode&&this.input.parentNode.insertBefore(y,this.input),y.appendChild(this.input),this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",h=y,this.isWrapperCreated=!0}if(!h)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=h,this.normalizeInputType();let u=this.getAttr("data-mask-focus-only")==="true",c=this.hasAttr("data-disabled"),l=this.getAttr("data-mask-select-on-focus")==="true",p=this.getAttr("data-mask-copy-raw")==="true",d=this.getAttr("data-mask-align")||this.getAttr("data-align"),{disabled:f,align:g,...v}=n,b=f!==void 0?f:!!c,T=this.input.type==="password";this.options={...v,createWrapper:r,showMaskOnFocus:n.showMaskOnFocus??u??!1,selectAllOnFocus:n.selectAllOnFocus??l??!1,copyRaw:T?!1:n.copyRaw??p??!1,disabled:b,align:g??(d||void 0),emitNativeInput:n.emitNativeInput??!0},this.options.showMaskOnFocus&&this.wrapper.classList.add("mask-focus-only"),this.options.disabled&&this.wrapper.setAttribute("data-disabled","true"),this.options.align&&this.setAlign(this.options.align),this.createGhost(),this.hookValueProperty(),this.bindBaseEvents(),this.initMutationObserver()}getAttr(i){return this.input.getAttribute(i)||this.wrapper.getAttribute(i)}hasAttr(i){return this.wrapper.hasAttribute(i)||this.input.hasAttribute(i)}hasNativePlaceholder(){return!!(this.input.placeholder&&this.input.placeholder.trim().length>0)}shouldHideGhostForPlaceholder(i){return!this.isFocused&&i&&this.hasNativePlaceholder()}bindBaseEvents(){this.input.addEventListener("copy",this.onBaseCopy),this.input.addEventListener("focus",this.onBaseFocus),this.input.addEventListener("blur",this.onBaseBlur)}extractRawSnippet(i){return i}initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(t=>{for(let e of t)e.type==="attributes"&&e.attributeName&&this.handleAttributeMutation(e.attributeName)});let i={attributes:!0,attributeFilter:["data-mask","data-mask-placeholder","data-mask-focus-only","data-mask-strict","data-mask-select-on-focus","data-mask-copy-raw","data-mask-pad-decimals","data-mask-auto-lowercase","data-mask-cycle-suggestions","data-mask-default-tld","data-mask-tlds","data-disabled","data-mask-align","data-align","placeholder"]};this.mutationObserver.observe(this.wrapper,i),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,i)}setAlign(i){let t=i||void 0,e=this.wrapper.getAttribute("data-align");this.options.align===t&&e===(i||null)||(this.options.align=t,this.wrapper.classList.remove("align-left","align-right","align-center"),i?(this.wrapper.classList.add(`align-${i}`),this.wrapper.getAttribute("data-align")!==i&&this.wrapper.setAttribute("data-align",i)):this.wrapper.hasAttribute("data-align")&&this.wrapper.removeAttribute("data-align"),this.syncGhostStyles())}handleAttributeMutation(i){if(i==="data-disabled"){let t=this.hasAttr("data-disabled");t!==!!this.options.disabled&&this.setDisabled(t)}else if(i==="data-mask-focus-only"){let t=this.getAttr("data-mask-focus-only")==="true";t!==!!this.options.showMaskOnFocus&&this.setShowMaskOnFocus(t)}else if(i==="data-mask-select-on-focus")this.options.selectAllOnFocus=this.getAttr("data-mask-select-on-focus")==="true";else if(i==="data-mask-copy-raw")this.options.copyRaw=this.getAttr("data-mask-copy-raw")==="true";else if(i==="data-mask-align"||i==="data-align"){let t=this.getAttr("data-mask-align")||this.getAttr("data-align");t!==(this.options.align??null)&&this.setAlign(t)}}normalizeInputType(){let i=["number","email","date","datetime-local","month","week","time","color","file","range"];if(this.input.type&&i.includes(this.input.type.toLowerCase())){let t=this.input.type.toLowerCase();this.input.type="text",t==="number"&&(this.input.inputMode="numeric")}}createGhost(){let i=this.wrapper.querySelector(".mask-ghost");i&&i.remove(),this.ghost=document.createElement("div"),this.ghost.className="mask-ghost",this.ghost.setAttribute("aria-hidden","true"),this.ghost.style.display="flex",this.ghost.style.alignItems="center",this.wrapper.appendChild(this.ghost),this.wrapper.classList.add("has-ghost"),this.syncGhostStyles()}syncGhostStyles(){if(!this.ghost||typeof window>"u")return;let i=window.getComputedStyle(this.input);if(!i)return;this.ghost.style.fontFamily=i.fontFamily,this.ghost.style.fontSize=i.fontSize,this.ghost.style.fontWeight=i.fontWeight,this.ghost.style.fontStyle=i.fontStyle,this.ghost.style.letterSpacing=i.letterSpacing,this.ghost.style.lineHeight=i.lineHeight,this.ghost.style.paddingTop=i.paddingTop,this.ghost.style.paddingBottom=i.paddingBottom,this.ghost.style.paddingLeft=i.paddingLeft,this.ghost.style.paddingRight=i.paddingRight,this.ghost.style.borderTopWidth=i.borderTopWidth,this.ghost.style.borderBottomWidth=i.borderBottomWidth,this.ghost.style.borderLeftWidth=i.borderLeftWidth,this.ghost.style.borderRightWidth=i.borderRightWidth,this.ghost.style.borderTopStyle=i.borderTopStyle==="none"?"none":"solid",this.ghost.style.borderBottomStyle=i.borderBottomStyle==="none"?"none":"solid",this.ghost.style.borderLeftStyle=i.borderLeftStyle==="none"?"none":"solid",this.ghost.style.borderRightStyle=i.borderRightStyle==="none"?"none":"solid",this.ghost.style.borderColor="transparent",this.ghost.style.boxSizing=i.boxSizing,this.ghost.style.textAlign=i.textAlign,this.ghost.style.direction=i.direction;let t=i.direction==="rtl"||this.input.getAttribute("dir")==="rtl"||this.wrapper.getAttribute("dir")==="rtl";i.textAlign==="right"||i.textAlign==="end"||t&&i.textAlign!=="left"&&i.textAlign!=="center"?this.ghost.style.justifyContent="flex-end":i.textAlign==="center"?this.ghost.style.justifyContent="center":this.ghost.style.justifyContent="flex-start"}setNativeValue(i){this.nativeValueDescriptor&&this.nativeValueDescriptor.set?this.nativeValueDescriptor.set.call(this.input,i):this.input.value=i}dispatchNativeInput(){if(!(this.isDestroyed||typeof window>"u")&&this.options.emitNativeInput!==!1){this.isDispatchingNativeInput=!0;try{let i=this.input._valueTracker;i&&typeof i.setValue=="function"&&i.setValue(this.lastTrackedValue),this.lastTrackedValue=this.input.value,this.input.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))}finally{this.isDispatchingNativeInput=!1}}}hookValueProperty(){try{let i=HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(i,"value");if(!t||!t.set||!t.get)return;this.nativeValueDescriptor=t;let e=this;Object.defineProperty(this.input,"value",{get(){return t.get.call(this)},set(o){let s=String(o??"");t.set.call(this,s),!e.isDestroyed&&e.onNativeValueSet(s)},configurable:!0})}catch{}}unhookValueProperty(){try{delete this.input.value}catch{}}setShowMaskOnFocus(i){this.options.showMaskOnFocus=i,this.wrapper.classList.toggle("mask-focus-only",i)}disabled(i){if(i===void 0)return!!this.options.disabled;this.setDisabled(i)}setDisabled(i){this.options.disabled=!!i,this.options.disabled?this.wrapper.setAttribute("data-disabled","true"):this.wrapper.removeAttribute("data-disabled"),this.onDisabledChange(this.options.disabled)}getWrapper(){return this.wrapper}getInput(){return this.input}getGhost(){return this.ghost}getElements(){return{wrapper:this.wrapper,input:this.input,ghost:this.ghost}}getValue(){return this.input.value}getRawValue(){return this.input.value}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.focusSelectTimerId!==null&&(clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.input.removeEventListener("copy",this.onBaseCopy),this.input.removeEventListener("focus",this.onBaseFocus),this.input.removeEventListener("blur",this.onBaseBlur),this.unhookValueProperty(),this.ghost&&(this.ghost.remove(),this.ghost=null),this.isWrapperCreated&&this.wrapper?(this.input.style.gridArea="",this.input.style.boxSizing="",this.wrapper.parentNode&&this.wrapper.parentNode.insertBefore(this.input,this.wrapper),this.wrapper.remove()):this.wrapper&&(this.wrapper.removeAttribute("data-mask"),this.wrapper.removeAttribute("data-disabled"),this.wrapper.classList.remove("is-complete","is-focused","mask-focus-only","has-selection","has-ghost")))}};var Et={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:m=>m.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:m=>m.toUpperCase()}},H=class m{constructor(i,t={}){this.patterns=[];this.subEngines=[];this.activeEngine=null;this.slots=[];this.fullMaskTemplate="";this.prefixSlotsCount=0;this.prefixString="";this.strict=!0;this.autoLowercase=!1;let e=t||{};this.placeholderChar=e.placeholderChar||"_",this.tokens={...Et,...e.tokens||{}},this.strict=e.strict!==!1,this.autoLowercase=e.autoLowercase??!1,this.pattern="",this.compile(i)}static format(i,t,e={}){return!t||Array.isArray(t)&&t.length===0?i??"":new m(t,e||{}).format(i??"")}compile(i){if(i!==void 0&&(Array.isArray(i)?(this.patterns=[...i],this.pattern=this.patterns[0]||""):(this.patterns=[],this.pattern=i)),this.patterns.length>0)return this.subEngines=this.patterns.map(o=>new m(o,{placeholderChar:this.placeholderChar,tokens:this.tokens,strict:this.strict,autoLowercase:this.autoLowercase})),this.activeEngine=this.subEngines[0],this.slots=this.activeEngine.slots,this.fullMaskTemplate=this.activeEngine.fullMaskTemplate,this.prefixSlotsCount=this.activeEngine.prefixSlotsCount,this.prefixString=this.activeEngine.prefixString,this.slots;this.subEngines=[],this.activeEngine=null,this.slots=[];let t="",e=!0;for(let o=0;o<this.pattern.length;o++){let s=this.pattern[o],n=!1;s==="\\"&&o+1<this.pattern.length&&(n=!0,o++,s=this.pattern[o]);let a=n?void 0:this.tokens[s];a?(e=!1,this.slots.push({char:s,isStatic:!1,isPrefix:!1,token:a,placeholder:this.placeholderChar}),t+=this.placeholderChar):(this.slots.push({char:s,isStatic:!0,isPrefix:e,placeholder:s}),t+=s)}this.fullMaskTemplate=t,this.prefixSlotsCount=0,this.prefixString="";for(let o of this.slots)if(o.isPrefix)this.prefixSlotsCount++,this.prefixString+=o.char;else break;return this.slots}selectEngine(i){if(this.subEngines.length<=1)return this;let t=String(i??""),e=this.subEngines.filter(r=>{let h=r.getPrefix();return h.length>0&&t.toLowerCase().startsWith(h.trim().toLowerCase())}),o=e.length>0?e:this.subEngines,s=[...o].sort((r,h)=>h.getEditableCount()-r.getEditableCount())[0],a=(s?s.extractRaw(t):t).length;for(let r of o)if(r.getEditableCount()>=a)return this.activeEngine=r,r;return this.activeEngine=o[o.length-1],this.activeEngine}getPrefix(){return this.activeEngine?this.activeEngine.getPrefix():this.prefixString}getPrefixLength(){return this.activeEngine?this.activeEngine.getPrefixLength():this.prefixSlotsCount}getFullMaskTemplate(){return this.activeEngine?this.activeEngine.getFullMaskTemplate():this.fullMaskTemplate}getEditableCount(){return this.subEngines.length>0?Math.max(...this.subEngines.map(i=>i.getEditableCount())):this.activeEngine?this.activeEngine.getEditableCount():this.slots.filter(i=>!i.isStatic).length}isNumericOnly(){if(this.subEngines.length>0)return this.subEngines.every(e=>e.isNumericOnly());let t=(this.activeEngine?this.activeEngine.slots:this.slots).filter(e=>!e.isStatic);return t.length===0?!1:t.every(e=>e.char==="9"||e.token&&e.token.pattern.test("0")&&!e.token.pattern.test("a")&&!e.token.pattern.test("Z"))}setStrict(i){this.strict=i}isStrict(){return this.strict}extractRaw(i){if(this.subEngines.length>0){let n=this.selectEngine(i);if(n!==this)return n.extractRaw(i)}let t=String(i??"");if(!t)return"";let e="",o=0,s=0;if(this.prefixSlotsCount>0){for(;o<t.length&&(t[o]===" "||t[o]===" ");)o++;let n=0;for(;o<t.length&&n<this.prefixSlotsCount;){let a=this.slots[n].char,r=t[o];if(r.toUpperCase()===a.toUpperCase())o++,n++;else if(a===" "&&r!==" ")n++;else break}s=this.prefixSlotsCount}for(;o<t.length&&s<this.slots.length;){let n=this.slots[s],a=t[o];if(n.isStatic)a.toUpperCase()===n.char.toUpperCase()&&o++,s++;else if(n.token&&n.token.pattern.test(a)){let r=n.token.transform?n.token.transform(a):a;this.autoLowercase&&!n.token.transform&&(r=r.toLowerCase()),e+=r,o++,s++}else this.strict?o++:(e+=this.autoLowercase?a.toLowerCase():a,o++,s++)}if(!this.strict&&o<t.length){let n=t.slice(o);e+=this.autoLowercase?n.toLowerCase():n}return e}format(i){if(this.subEngines.length>0){let n=this.selectEngine(i);if(n!==this)return n.format(i)}let t=String(i??"");if(!this.slots.length)return t;let e=this.extractRaw(t);if(e.length===0)return this.prefixString;let o="",s=0;for(let n=0;n<this.slots.length;n++){let a=this.slots[n];if(a.isStatic){let r=s<e.length,h=s===0&&!!a.isPrefix,u=s>0&&s===e.length;if(r||h||u)o+=a.char;else break}else if(s<e.length){let r=e[s],h=a.token?.transform?a.token.transform(r):r;this.autoLowercase&&!a.token?.transform&&(h=h.toLowerCase()),o+=h,s++}else break}if(!this.strict&&s<e.length){let n=e.substring(s);o+=this.autoLowercase?n.toLowerCase():n}return o}getRemainingMask(i){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getRemainingMask(i):this.fullMaskTemplate?i.length>=this.fullMaskTemplate.length?i:i+this.fullMaskTemplate.substring(i.length):""}mapCursorPosition(i,t,e){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.mapCursorPosition(i,t,e);let o=this.prefixSlotsCount,s=String(i??""),n=String(e??"");if(t<=0||!n)return o;let r=this.extractRaw(s.slice(0,t)).length;if(r===0)return Math.max(o,Math.min(this.getNextEditablePosition(0),n.length));let h=0,u=n.length;for(let c=0;c<n.length&&c<this.slots.length;c++)if(!this.slots[c].isStatic&&(h++,h===r)){u=c+1;break}for(;u<n.length&&this.slots[u]&&this.slots[u].isStatic;)u++;return Math.max(o,Math.min(u,n.length))}isSeparatorAt(i){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.isSeparatorAt(i):i>=0&&i<this.slots.length?this.slots[i].isStatic:!1}getNextEditablePosition(i){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.getNextEditablePosition(i);let t=Math.max(0,i);for(let e=t;e<this.slots.length;e++)if(!this.slots[e].isStatic)return e;return this.slots.length}getSlotAt(i){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlotAt(i):this.slots[i]}getSlots(){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlots():this.slots}};var C=class{constructor(i=50){this.stack=[];this.index=-1;this.maxDepth=i}push(i,t){let e=this.getCurrent();if(e&&e.raw===i){e.cursor=t;return}this.stack=this.stack.slice(0,this.index+1),this.stack.push({raw:i,cursor:t}),this.stack.length>this.maxDepth&&this.stack.shift(),this.index=this.stack.length-1}updateCurrentCursor(i){let t=this.getCurrent();t&&(t.cursor=i)}undo(){return this.canUndo()?(this.index--,this.stack[this.index]):null}redo(){return this.canRedo()?(this.index++,this.stack[this.index]):null}canUndo(){return this.index>0}canRedo(){return this.index>=0&&this.index<this.stack.length-1}getCurrent(){return this.index>=0&&this.index<this.stack.length?this.stack[this.index]:null}clear(){this.stack=[],this.index=-1}};var N=class{constructor(i){this.delegate=i}handleKeyDown(i){let t=this.delegate.getInput(),e=this.delegate.getEngine(),o=this.delegate.getHistory(),s=e.getPrefixLength(),n=t.selectionStart??0,a=t.selectionEnd??n;if((i.ctrlKey||i.metaKey)&&(i.key==="z"||i.key==="Z")&&!i.shiftKey){i.preventDefault(),this.delegate.undo();return}if((i.ctrlKey||i.metaKey)&&(i.key==="y"||i.key==="Y")||(i.ctrlKey||i.metaKey)&&i.shiftKey&&(i.key==="z"||i.key==="Z")){i.preventDefault(),this.delegate.redo();return}o.updateCurrentCursor(n);let r=i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey,h=a>n;if(r&&!h){let l=e.getSlots(),p=n<l.length&&l[n].isStatic&&l[n].char===i.key,d=n>0&&n-1<l.length&&l[n-1].isStatic&&l[n-1].char===i.key;if(p||d){i.preventDefault();let g=p?n:n-1,v=e.getNextEditablePosition(g+1);this.delegate.applyMask(t.value,v,!0);return}let f=-1;for(let g=n;g<l.length;g++)if(l[g].isStatic){l[g].char===i.key&&(f=g);break}if(f!==-1){i.preventDefault();let g=f-1;for(;g>=s&&!l[g].isStatic;)g--;g++;let v=f-g,b=t.value.slice(g,n);if(l.slice(g,f).every(w=>!w.token||w.token.pattern.test("0"))&&v>b.length&&b.length>0){let w=v-b.length,k="0".repeat(w)+b,I=t.value.slice(f),Z=t.value.slice(0,g)+k+I,E=e.getNextEditablePosition(f+1);this.delegate.applyMask(Z,E,!0);return}let y=e.getNextEditablePosition(f+1);this.delegate.applyMask(t.value,y,!0);return}}if(r&&e.isStrict()){let l=e.getEditableCount();if(l>0){let p=e.extractRaw(t.value),d=l-p.length;if(a>n){let f=e.extractRaw(t.value.slice(n,a));d=l-(p.length-f.length)}if(d<=0){i.preventDefault();return}}}if(a>n){if(i.key==="Backspace"||i.key==="Delete"){i.preventDefault();let l=t.value,p=l.slice(0,n)+l.slice(a);this.delegate.applyMask(p,Math.max(s,n));return}return}if(i.key==="ArrowLeft"&&!i.shiftKey&&n<=s){i.preventDefault(),t.setSelectionRange(s,s);return}if(i.key==="Home"&&!i.shiftKey){i.preventDefault(),t.setSelectionRange(s,s);return}if(i.key==="Backspace"&&n<=s){i.preventDefault(),t.setSelectionRange(s,s);return}if(i.key==="Delete"&&n<s){i.preventDefault(),t.setSelectionRange(s,s);return}if(i.key==="Backspace"&&(i.ctrlKey||i.altKey||i.metaKey)){if(i.preventDefault(),n<=s){t.setSelectionRange(s,s);return}let l=n-1;for(;l>=s&&e.isSeparatorAt(l);)l--;for(;l>=s&&!e.isSeparatorAt(l);)l--;let p=Math.max(s,l+1),d=t.value,f=d.slice(0,p)+d.slice(n);this.delegate.applyMask(f,p);return}if(i.key==="Delete"&&(i.ctrlKey||i.altKey||i.metaKey)){i.preventDefault();let l=t.value;if(n>=l.length)return;let p=n;for(;p<l.length&&e.isSeparatorAt(p);)p++;for(;p<l.length&&!e.isSeparatorAt(p);)p++;for(;p<l.length&&e.isSeparatorAt(p);)p++;let d=p,f=l.slice(0,n)+l.slice(d);this.delegate.applyMask(f,n);return}if(i.key==="Backspace"&&n>s){if(e.isSeparatorAt(n-1)){i.preventDefault();let l=n-1;for(;l>s&&e.isSeparatorAt(l-1);)l--;if(l>s){let p=t.value,d=p.slice(0,l-1)+p.slice(n);this.delegate.applyMask(d,l-1)}else this.delegate.applyMask("",s)}return}if(i.key==="Delete"&&n<t.value.length){if(e.isSeparatorAt(n)){i.preventDefault();let l=n;for(;l<t.value.length&&e.isSeparatorAt(l);)l++;if(l<t.value.length){let p=t.value,d=p.slice(0,l)+p.slice(l+1);this.delegate.applyMask(d,n)}}return}}handleKeyUp(i){let t=this.delegate.getInput(),e=this.delegate.getHistory();(i.key==="ArrowLeft"||i.key==="ArrowRight"||i.key==="Home")&&!i.shiftKey&&this.delegate.enforceMinCursor(),e.updateCurrentCursor(t.selectionStart??0)}};var z=class extends x{constructor(t,e,o){let s=O(t,e,o),n=s.wrapper,a=s.input,r=s.options,h=n?.getAttribute("data-mask")||a?.getAttribute("data-mask"),u=r.mask||h||"";typeof u=="string"&&u.includes("|")&&(u=u.split("|").map(w=>w.trim()));let c=r.placeholderChar||n?.getAttribute("data-mask-placeholder")||a?.getAttribute("data-mask-placeholder")||"_",l=n?.hasAttribute("data-disabled")||a?.hasAttribute("data-disabled"),p=n?.getAttribute("data-mask-strict")||a?.getAttribute("data-mask-strict"),d=n?.getAttribute("data-mask-auto-lowercase")==="true"||a?.getAttribute("data-mask-auto-lowercase")==="true",f=n?.getAttribute("data-mask-infer-inputmode")??a?.getAttribute("data-mask-infer-inputmode"),g=r.inferInputMode??(f!==null?f!=="false":!0),{disabled:v,...b}=r,T=v!==void 0?v:l?!0:!u||Array.isArray(u)&&u.length===0,y={...b,mask:u,placeholderChar:c,strict:r.strict??(p!==null?p!=="false":!0),autoLowercase:r.autoLowercase??d??!1,disabled:T,resetHistoryOnMaskChange:r.resetHistoryOnMaskChange??!1,inferInputMode:g,onInput:r.onInput||r.oninput,onChange:r.onChange||r.onchange,onComplete:r.onComplete||r.oncomplete};super(n,a,y);this.isComposing=!1;this.isUndoingRedoing=!1;this.isMouseDown=!1;this.isApplyingMask=!1;this.lastValue="";this.lastInternalRemainingMask="";this.isNotifying=!1;this.hasPendingNotification=!1;this.onChangeNativeHandler=()=>{};this.wasInputModeInferred=!1;this.cutTimerId=null;this.pasteTimerId=null;this.resetTimerId=null;this.history=new C,this.engine=new H(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new N({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(w,k,I)=>this.applyMask(w,k,I),undo:()=>this.undo(),redo:()=>this.redo(),enforceMinCursor:()=>this.enforceMinCursor()}),this.bindEvents(),this.lastValue=this.input.value,this.syncInitialValue()}extractRawSnippet(t){return this.engine.extractRaw(t)}static format(t,e,o={}){return H.format(t,e,o)}onNativeValueSet(t){this.options.disabled?this.checkValueChange():this.applyMask(t,t.length)}onDisabledChange(t){t?(this.wrapper.removeAttribute("data-mask"),this.wrapper.classList.remove("is-complete","has-selection"),this.ghost&&(this.ghost.textContent=""),this.checkValueChange()):this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onClick=this.onClick.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onSelect=this.onSelect.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onScroll=this.onScroll.bind(this),this.onBeforeInput=this.onBeforeInput.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,!this.isDestroyed)if(this.options.disabled)this.checkValueChange();else{let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t)}},0)},this.onChangeNativeHandler=()=>{this.isDestroyed||this.checkValueChange()},this.input.addEventListener("beforeinput",this.onBeforeInput),this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.onKeyDown),this.input.addEventListener("paste",this.onPaste),this.input.addEventListener("focus",this.onFocus),this.input.addEventListener("blur",this.onBlur),this.input.addEventListener("click",this.onClick),this.input.addEventListener("keyup",this.onKeyUp),this.input.addEventListener("select",this.onSelect),this.input.addEventListener("mousedown",this.onMouseDown),window.addEventListener("mouseup",this.onMouseUp),this.input.addEventListener("compositionstart",this.onCompositionStart),this.input.addEventListener("compositionend",this.onCompositionEnd),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.addEventListener("change",this.onChangeNativeHandler),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled?this.checkValueChange():this.syncInitialValue())},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}syncInferredInputMode(){if(!this.options.inferInputMode)return;!this.options.disabled&&this.engine.isNumericOnly()?this.input.hasAttribute("inputmode")||(this.input.inputMode="numeric",this.wasInputModeInferred=!0):this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&(this.input.removeAttribute("inputmode"),this.wasInputModeInferred=!1)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.pasteTimerId!==null&&(clearTimeout(this.pasteTimerId),this.pasteTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("beforeinput",this.onBeforeInput),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.onKeyDown),this.input.removeEventListener("paste",this.onPaste),this.input.removeEventListener("focus",this.onFocus),this.input.removeEventListener("blur",this.onBlur),this.input.removeEventListener("click",this.onClick),this.input.removeEventListener("keyup",this.onKeyUp),this.input.removeEventListener("select",this.onSelect),this.input.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),this.input.removeEventListener("compositionstart",this.onCompositionStart),this.input.removeEventListener("compositionend",this.onCompositionEnd),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.removeEventListener("change",this.onChangeNativeHandler),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&this.input.removeAttribute("inputmode"),this.history.clear(),super.destroy())}setStrict(t){this.options.strict=t,this.engine.setStrict(t),this.options.disabled||this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}isStrict(){return this.engine.isStrict()}setMask(t,e){let o=typeof e=="boolean"?e:e&&typeof e=="object"&&e.strict!==void 0?e.strict:this.options.strict,s=e&&typeof e=="object"&&e.resetHistory!==void 0?e.resetHistory:!!this.options.resetHistoryOnMaskChange;if(!((!t||Array.isArray(t)&&t.length===0)&&this.options.disabled&&(!this.options.mask||this.options.mask===""))){if(!t||Array.isArray(t)&&t.length===0){this.options.mask="",this.options.strict=o,this.engine.setStrict(o??!0),this.engine.compile(""),s&&this.history.clear(),this.setDisabled(!0),this.syncInferredInputMode();return}this.options.mask=t,this.options.strict=o,this.engine.setStrict(o??!0),this.engine.compile(t),s&&this.history.clear(),this.setDisabled(!1),this.syncInferredInputMode()}}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask"){let e=this.getAttr("data-mask");if(e===this.lastInternalRemainingMask)return;let o=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(e===o)return;if(e){let s=e.includes("|")?e.split("|").map(n=>n.trim()):e;this.setMask(s)}else this.setMask(null)}else if(t==="data-mask-strict"){let e=this.getAttr("data-mask-strict");this.setStrict(e!=="false")}else t==="data-mask-auto-lowercase"?(this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true",this.engine.compile(this.options.mask||""),this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)):t==="placeholder"&&this.updateGhost(this.input.value)}setValue(t){let e=t!=null?String(t):"";if(this.options.disabled){this.input.value=e,this.checkValueChange();return}this.applyMask(e,e.length)}getRawValue(){return this.engine.extractRaw(this.input.value)}isComplete(){return this.options.disabled?!0:this.getRawValue().length>=this.engine.getEditableCount()}get onInput(){return this.options.onInput}set onInput(t){this.options.onInput=t}undo(){if(this.options.disabled)return;let t=this.history.undo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}redo(){if(this.options.disabled)return;let t=this.history.redo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}checkSelection(){if(this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,o=t!==e;this.wrapper.classList.toggle("has-selection",o)}onBeforeInput(t){if(!this.options.disabled&&!this.isComposing&&this.engine.isStrict()&&t.inputType!=="insertFromPaste"&&t.inputType&&t.inputType.startsWith("insert")){let e=this.engine.getEditableCount();if(e>0){let o=this.getRawValue(),s=this.input.selectionStart??0,n=this.input.selectionEnd??s,a=Math.max(0,e-o.length);if(n>s){let r=this.engine.extractRaw(this.input.value.slice(s,n));a=Math.max(0,e-(o.length-r.length))}a<=0&&t.preventDefault()}}}handleInput(t){if(this.isDispatchingNativeInput||this.isComposing)return;if(!!(this.options.onInput||this.options.oninput)&&this.input.value!==this.lastValue&&this.checkValueChange(),this.options.disabled){this.checkValueChange();return}let o=this.history.getCurrent(),s=this.engine.getEditableCount();if(s>0&&this.engine.isStrict()&&o&&o.raw.length>=s&&this.engine.extractRaw(this.input.value).length>s){this.applyMask(o.raw,o.cursor);return}let n=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,n),this.checkSelection()}onKeyDown(t){this.options.disabled||this.keyboard.handleKeyDown(t)}onMouseDown(){this.isMouseDown=!0}onMouseUp(){this.isMouseDown=!1,this.checkSelection()}onPaste(t){if(this.options.disabled){this.pasteTimerId!==null&&clearTimeout(this.pasteTimerId),this.pasteTimerId=window.setTimeout(()=>{this.pasteTimerId=null,this.isDestroyed||this.checkValueChange()},0);return}t.preventDefault(),this.history.updateCurrentCursor(this.input.selectionStart??0);let o=(t.clipboardData?.getData("text")||"").trim();if(!o)return;let s=this.engine.getPrefixLength(),n=this.input.selectionStart??0,a=this.input.selectionEnd??n,r=this.input.value,h=this.engine.getEditableCount(),u=this.getRawValue(),l=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),p=o.replace(/[\s.-]+/g,"").toUpperCase(),d=l.length>0&&p.startsWith(l),f=r.slice(0,Math.max(s,n)).replace(/[\s.-]+/g,"").toUpperCase(),g=f.length>=2&&p.startsWith(f),v=Math.max(s,n),b=Math.max(s,a);(d||g)&&(v=0,b=r.length);let T=Math.max(0,h-u.length);if(v!==b){let k=this.engine.extractRaw(r.slice(v,b));T=Math.max(0,h-(u.length-k.length))}if(this.engine.isStrict()&&T<=0)return;let y,w;v===0&&b===r.length?(y=o,w=o.length):(y=r.slice(0,v)+o+r.slice(b),w=v+o.length),this.applyMask(y,w),this.checkSelection()}onFocus(){this.syncGhostStyles(),this.wrapper.classList.add("is-focused"),!this.options.disabled&&!this.isMouseDown&&this.enforceMinCursor(),this.updateGhost(this.input.value),this.checkSelection()}onBlur(){this.wrapper.classList.remove("is-focused","has-selection"),this.input.type==="password"&&this.history.clear(),this.updateGhost(this.input.value)}onClick(){this.options.disabled||this.enforceMinCursor(),this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onKeyUp(t){this.options.disabled||this.keyboard.handleKeyUp(t),this.checkSelection()}onSelect(){this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t),this.checkSelection()}enforceMinCursor(){let t=this.engine.getPrefixLength();if(t<=0)return;let e=this.input.selectionStart??0,o=this.input.selectionEnd??e;e===o&&e<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled){this.ghost.textContent="";return}let e=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(e)){this.ghost.textContent="";return}let o=this.engine.getFullMaskTemplate(),s=o.length>t.length?o.substring(t.length):"";this.ghost.textContent="";let n=document.createElement("span");n.className="mask-ghost-typed",n.textContent=t;let a=document.createElement("span");a.className="mask-ghost-remaining",a.textContent=s,this.ghost.appendChild(n),this.ghost.appendChild(a),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,o=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let s="",n=!1;try{s=this.engine.format(t);let a=this.engine.getRemainingMask(s);this.input.value=s,this.lastInternalRemainingMask=a,this.wrapper.setAttribute("data-mask",a),this.updateGhost(s);let r=this.engine.getPrefixLength(),h;if(o||this.isUndoingRedoing)h=Math.max(r,Math.min(e,s.length));else{let u=this.engine.mapCursorPosition(t,e,s);h=Math.max(r,u)}this.input.setSelectionRange(h,h),n=this.isComplete(),this.wrapper.classList.toggle("is-complete",n),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(this.getRawValue(),h)}finally{this.isApplyingMask=!1}this.checkValueChange()}syncInitialValue(){if(this.options.disabled){this.wrapper.removeAttribute("data-mask"),this.ghost&&(this.ghost.textContent=""),this.lastValue=this.input.value,this.checkValueChange();return}this.syncGhostStyles();let t=this.input.value||"";if(t)this.applyMask(t,t.length);else{let e=this.engine.getPrefixLength();if(e>0)this.applyMask("",e);else{this.input.type!=="password"&&this.history.push("",0);let o=this.engine.getFullMaskTemplate();this.lastInternalRemainingMask=o,this.wrapper.setAttribute("data-mask",o),this.updateGhost(""),this.checkValueChange()}}}checkValueChange(t=!1){if(!(this.input.value===this.lastValue&&!t&&!this.hasPendingNotification)){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{for(;this.input.value!==this.lastValue||this.hasPendingNotification||t;){this.hasPendingNotification=!1,t=!1;let o=this.input.value;this.lastValue=o;let s=this.options.disabled?o:this.getRawValue(),n=this.options.disabled?0:this.engine.getEditableCount(),a=this.isComplete(),r={value:o,rawValue:s,isComplete:a,totalSlots:n,filledSlots:this.options.disabled?o.length:s.length},h=this.options.onInput||this.options.oninput;h&&h(o,r),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:r})),this.dispatchNativeInput();let u=this.options.onChange||this.options.onchange;u&&u(r),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:r}));let c=this.options.onComplete||this.options.oncomplete;a&&(c&&c(r),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:r})))}}finally{this.isNotifying=!1}}}};var R=class m{constructor(i={}){let t=i.currency??"";!t&&i.unit&&(t=i.unit);let e=t==="$"||t==="\xA3"||t==="\xA5"?"prefix":"suffix";this.options={currency:t,unit:i.unit??t,currencyPosition:i.currencyPosition??e,decimals:i.decimals!==void 0?Math.max(0,i.decimals):2,decimalSeparator:i.decimalSeparator??",",thousandSeparator:i.thousandSeparator??"\xA0",allowNegative:i.allowNegative??!1,min:i.min??-1/0,max:i.max??1/0}}parse(i){let t=i.trim(),e=!1;this.options.allowNegative&&t.includes("-")&&(e=!0),this.options.currency&&(t=t.replace(new RegExp(this.escapeRegExp(this.options.currency),"g"),"")),this.options.thousandSeparator&&(t=t.replace(new RegExp(this.escapeRegExp(this.options.thousandSeparator),"g"),"")),t=t.replace(/[\s\u00A0]/g,"");let o=this.options.decimalSeparator,s=t.indexOf(o);s===-1&&(s=t.search(/[,.]/));let n="",a=null,r=!1;return s!==-1?(n=t.substring(0,s).replace(/\D/g,""),this.options.decimals>0&&(r=!0,a=t.substring(s+1).replace(/\D/g,"").slice(0,this.options.decimals))):n=t.replace(/\D/g,""),n.length>1&&(n=n.replace(/^0+/,"")||"0"),{isNegative:e,integerPart:n,decimalPart:a,hasDecimal:r}}format(i,t=i.length,e=!1){if(!i||i.trim()===""||i===this.options.currency.trim())return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let o=i.substring(0,t),s=o.replace(/\D/g,"").length,n=this.options.decimals>0&&/[,.]/.test(o),{isNegative:a,integerPart:r,decimalPart:h,hasDecimal:u}=this.parse(i),c=h,l=u;if(e&&this.options.decimals>0&&(r||h!==null)&&(l=!0,c===null?c="0".repeat(this.options.decimals):c.length<this.options.decimals&&(c=c+"0".repeat(this.options.decimals-c.length))),a&&!r&&!c&&!l&&this.options.allowNegative){let E="-",D=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(E=`${this.options.currency} -`,D=E.length):(E=`- ${this.options.currency}`,D=1)),{formatted:E,rawNumber:null,rawValue:"-",cursor:D,isValid:!0}}if(!r&&!c&&!l)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let d=(r||"0").replace(/\B(?=(\d{3})+(?!\d))/g,this.options.thousandSeparator);l&&this.options.decimals>0&&(d+=this.options.decimalSeparator+(c??"")),a&&d!=="0"&&(d="-"+d);let f=d;this.options.currency&&(this.options.currencyPosition==="prefix"?f=`${this.options.currency} ${d}`:f=`${d} ${this.options.currency}`);let g=(a?"-":"")+(r||"0")+(h?"."+h:""),v=parseFloat(g);isNaN(v)&&(v=0);let b=v>=this.options.min&&v<=this.options.max,T=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(T=this.options.currency.length+1);let y=0,w=!1,k=T;for(let E=T;E<f.length;E++){let D=f[E];if(D===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(D)?(y++,k=E+1):D===this.options.decimalSeparator&&(w=!0,k=E+1),n){if(w&&y>=s){T=E+1;break}}else if(y>=s){T=E+1;break}}s>0&&y<s&&k>T&&(T=k);let I=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,Z=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,f.length-this.options.currency.length-1):f.length;return T=Math.max(I,Math.min(T,Math.max(I,Z))),{formatted:f,rawNumber:v,rawValue:g,cursor:T,isValid:b}}static format(i,t={}){let e=new m(t),o=typeof i=="number"?i.toString():i;return e.format(o).formatted}escapeRegExp(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var $=class extends x{constructor(t,e,o){let s=O(t,e,o),n=s.wrapper,a=s.input,r=s.options,h=n?.getAttribute("data-mask-pad-decimals")==="true"||a?.getAttribute("data-mask-pad-decimals")==="true",u=a?.getAttribute("data-mask-align")||a?.getAttribute("data-align")||n?.getAttribute("data-mask-align")||n?.getAttribute("data-align"),c={align:r.align??u??"right",padDecimalsOnBlur:r.padDecimalsOnBlur??h??!1,...r};super(n,a,c);this.isUndoingRedoing=!1;this.isApplying=!1;this.isComposing=!1;this.lastValue="";this.cutTimerId=null;this.resetTimerId=null;this.input.inputMode="decimal",this.history=new C,this.engine=new R(this.options),this.bindEvents(),this.input.value?this.options.disabled||this.applyAmount(this.input.value,this.input.value.length):this.updateGhost({formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0})}extractRawSnippet(t){let e=this.engine.parse(t);return!e.integerPart&&!e.decimalPart?"":(e.isNegative?"-":"")+(e.integerPart||"0")+(e.decimalPart?"."+e.decimalPart:"")}static format(t,e={}){return R.format(t,e)}onNativeValueSet(t){if(this.options.disabled||this.isComposing){this.lastValue=t;return}this.applyAmount(t,t.length)}onDisabledChange(t){t||this.applyAmount(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleClick=this.handleClick.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,this.isDestroyed||this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)},0)},this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("click",this.handleClick),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.addEventListener("compositionstart",this.onCompositionStart),this.input.addEventListener("compositionend",this.onCompositionEnd),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled||this.applyAmount(this.input.value,this.input.value.length))},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)}applyAmount(t,e){if(!(this.isApplying||this.options.disabled)){this.isApplying=!0;try{let o=this.engine.format(t,e);this.setNativeValue(o.formatted),this.input.setSelectionRange(o.cursor,o.cursor),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(o.rawValue,o.cursor),this.updateGhost(o),this.lastValue!==o.formatted&&(this.lastValue=o.formatted,this.notifyChange(o))}finally{this.isApplying=!1}}}updateGhost(t){if(this.ghost){if(!t.formatted){if(this.shouldHideGhostForPlaceholder(!0)){this.ghost.textContent="";return}let e=this.options.currency?this.options.currencyPosition==="prefix"?`${this.options.currency} 0`:`0 ${this.options.currency}`:"0,00";this.ghost.textContent="";let o=document.createElement("span");o.className="mask-ghost-remaining",o.textContent=e,this.ghost.appendChild(o);return}this.ghost.textContent="",this.ghost.scrollLeft=this.input.scrollLeft}}handleInput(){if(this.isDispatchingNativeInput||this.options.disabled||this.isComposing)return;let t=this.input.value,e=this.input.selectionStart??t.length;this.applyAmount(t,e)}handleKeyDown(t){if(!this.options.disabled){if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")){t.preventDefault(),t.shiftKey?this.redo():this.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")){t.preventDefault(),this.redo();return}if(t.key==="Backspace"){let e=this.input.selectionStart??0,o=this.input.selectionEnd??0;if(e===o&&e>0){let s=this.input.value,n=s[e-1];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let a=Math.max(0,e-2),r=s.slice(0,a)+s.slice(e);this.applyAmount(r,a);return}if(this.options.currency&&this.options.currencyPosition==="prefix"&&e<=this.options.currency.length+1){t.preventDefault();return}}}if(t.key==="Delete"){let e=this.input.selectionStart??0,o=this.input.selectionEnd??0;if(e===o&&e<this.input.value.length){let s=this.input.value,n=s[e];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let a=s.slice(0,e)+s.slice(e+2);this.applyAmount(a,e);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let a=s.length-this.options.currency.length-1;if(e>=a){t.preventDefault();return}}}}setTimeout(()=>this.enforceCursorBounds(),0)}}enforceCursorBounds(){if(!this.input.value||this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??0;if(t!==e)return;let o=this.input.value,s=this.options.currency;if(s){if(this.options.currencyPosition==="prefix"){let n=s.length+1;t<n&&this.input.setSelectionRange(n,n)}else if(this.options.currencyPosition==="suffix"){let n=Math.max(0,o.length-s.length-1);t>n&&this.input.setSelectionRange(n,n)}}}handleClick(){this.enforceCursorBounds()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.enforceCursorBounds(),this.updateGhost(this.engine.format(this.input.value))}handleBlur(){if(this.wrapper.classList.remove("is-focused"),this.input.type==="password"&&this.history.clear(),this.options.padDecimalsOnBlur&&!this.options.disabled&&this.input.value.trim().length>0){let e=this.engine.format(this.input.value,this.input.value.length,!0);e.formatted!==this.input.value&&(this.setNativeValue(e.formatted),this.lastValue=e.formatted)}this.updateGhost(this.engine.format(this.input.value));let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){super.handleAttributeMutation(t),t==="data-mask-pad-decimals"?this.options.padDecimalsOnBlur=this.getAttr("data-mask-pad-decimals")==="true":t==="placeholder"&&this.updateGhost(this.engine.format(this.input.value))}notifyChange(t){let e={value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid};this.options.onInput&&this.options.onInput(e),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:e})),this.dispatchNativeInput()}undo(){let t=this.history.undo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}redo(){let t=this.history.redo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}getDetail(){let t=this.engine.format(this.input.value);return{value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid}}getNumber(){return this.getDetail().number}getRawValue(){return this.getDetail().rawValue}isValid(){return this.getDetail().isValid}setValue(t){let e=t!=null?String(t):"";this.options.disabled?(this.setNativeValue(e),this.lastValue=e):this.applyAmount(e,e.length)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("blur",this.handleBlur),this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("click",this.handleClick),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.removeEventListener("compositionstart",this.onCompositionStart),this.input.removeEventListener("compositionend",this.onCompositionEnd),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.history.clear(),super.destroy())}};var K=class K{constructor(i={}){this.defaultDomain=null;this.defaultTld="__";this.domains=i.domains&&i.domains.length>0?i.domains:K.DEFAULT_DOMAINS,this.tlds=i.tlds&&i.tlds.length>0?i.tlds.map(t=>t.trim().replace(/^\./,"")).filter(Boolean):[...K.DEFAULT_TLDS],this.suggestOnAt=i.suggestOnAt??!0,this.setDefaultDomain(i.defaultDomain??null),this.setDefaultTld(i.defaultTld!==void 0?i.defaultTld:"__")}setDefaultDomain(i){i===!0?this.defaultDomain=this.domains.length>0?this.domains[0]:null:typeof i=="string"&&i.trim().length>0?this.defaultDomain=i.trim().replace(/^@/,""):this.defaultDomain=null}setDefaultTld(i){i===!0?this.defaultTld=this.tlds.length>0?this.tlds[0]:null:typeof i=="string"&&i.trim().length>0?this.defaultTld=i.trim().replace(/^\./,""):this.defaultTld=null}setTlds(i){this.tlds=i&&i.length>0?i.map(t=>t.trim().replace(/^\./,"")).filter(Boolean):[...K.DEFAULT_TLDS]}getMatchingTlds(i){let t=(i??"").toLowerCase();return t.length===0?[...this.tlds]:this.tlds.filter(e=>e.toLowerCase().startsWith(t)&&e.toLowerCase()!==t)}getMatchingDomains(i){let t=i??"";if(!t.includes("@"))return this.defaultDomain?[this.defaultDomain]:[];let e=t.indexOf("@");if(t.indexOf("@",e+1)!==-1)return[];let o=t.substring(e+1);if(o.length===0)return this.suggestOnAt?[...this.domains]:[];let s=o.toLowerCase();return this.domains.filter(n=>n.toLowerCase().startsWith(s)&&n.toLowerCase()!==s)}getSuggestion(i,t=0){let e=i??"";if(!e.includes("@"))return this.defaultDomain?{full:e?`${e}@${this.defaultDomain}`:`@${this.defaultDomain}`,remaining:`@${this.defaultDomain}`,matchedDomain:this.defaultDomain,isHintOnly:!1}:{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let o=e.indexOf("@"),s=e.substring(0,o),n=e.substring(o+1);if(e.indexOf("@",o+1)!==-1)return{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let a=this.getMatchingDomains(i);if(a.length>0){let d=(t%a.length+a.length)%a.length,f=a[d],g=n.toLowerCase(),v=f.substring(g.length);return{full:`${s}@${f}`,remaining:v,matchedDomain:f,isHintOnly:!1}}if(n.length===0||n.startsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let r=n.toLowerCase();if(this.domains.some(d=>d.toLowerCase()===r))return{full:i,remaining:"",matchedDomain:n,isHintOnly:!1};let h=n.lastIndexOf(".");if(h===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let d=this.defaultTld.includes("_"),f=`.${this.defaultTld}`,g=`${n}.${this.defaultTld}`;return{full:d?i:`${s}@${g}`,remaining:f,matchedDomain:d?null:g,isHintOnly:d}}let u=n.substring(0,h),c=n.substring(h+1);if(!u||u.endsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};if(c.length===0){if(this.defaultTld&&!this.defaultTld.includes("_")){let d=`${u}.${this.defaultTld}`;return{full:`${s}@${d}`,remaining:this.defaultTld,matchedDomain:d,isHintOnly:!1}}return this.defaultTld&&this.defaultTld.includes("_")?{full:i,remaining:this.defaultTld,matchedDomain:null,isHintOnly:!0}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}let l=c.toLowerCase(),p=this.getMatchingTlds(c);if(p.length>0){let d=(t%p.length+p.length)%p.length,f=p[d],g=f.substring(l.length),v=`${u}.${f}`;return{full:`${s}@${v}`,remaining:g,matchedDomain:v,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&c.length<this.defaultTld.length){let d=this.defaultTld.substring(c.length);if(d.includes("_"))return{full:i,remaining:d,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};K.DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"],K.DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];var V=K;var X=class extends x{constructor(t,e,o){let s=O(t,e,o),n=s.wrapper,a=s.input,r=s.options,h=n?.getAttribute("data-mask-cycle-suggestions")==="true"||a?.getAttribute("data-mask-cycle-suggestions")==="true",u=n?.getAttribute("data-mask-auto-lowercase")==="true"||a?.getAttribute("data-mask-auto-lowercase")==="true",c=n?.getAttribute("data-mask-aria-autocomplete")??a?.getAttribute("data-mask-aria-autocomplete"),l=r.setAriaAutocomplete??(c!==null?c!=="false":!0),p=n?.getAttribute("data-mask-tlds")??a?.getAttribute("data-mask-tlds"),d=r.tlds??(p?p.split(",").map(b=>b.trim()).filter(Boolean):void 0),f=n?.getAttribute("data-mask-default-tld")??a?.getAttribute("data-mask-default-tld"),g=r.defaultTld!==void 0?r.defaultTld:f!==null?f==="false"||f==="none"?null:f==="true"?!0:f:void 0,v={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:r.cycleSuggestions??h??!1,autoLowercase:r.autoLowercase??u??!1,setAriaAutocomplete:l,...r,...d!==void 0?{tlds:d}:{},...g!==void 0?{defaultTld:g}:{}};super(n,a,v);this.currentSuggestion={full:"",remaining:"",matchedDomain:null};this.currentSuggestionIndex=0;this.wasAriaAutocompleteSet=!1;this.cutTimerId=null;this.resetTimerId=null;this.input.inputMode="email",this.options.setAriaAutocomplete&&!this.input.hasAttribute("aria-autocomplete")&&(this.input.setAttribute("aria-autocomplete","inline"),this.wasAriaAutocompleteSet=!0),this.engine=new V(this.options),this.bindEvents(),this.options.disabled||this.updateSuggestion()}onNativeValueSet(t){this.options.disabled||this.updateSuggestion()}onDisabledChange(t){t?this.ghost&&(this.ghost.textContent=""):this.updateSuggestion()}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{this.cutTimerId=null,!(this.isDestroyed||this.options.disabled)&&this.updateSuggestion()},0)},this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!(this.isDestroyed||this.options.disabled)&&this.updateSuggestion()},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}updateSuggestion(){if(this.options.disabled){this.ghost&&(this.ghost.textContent="");return}let t=this.input.value;if(this.currentSuggestion=this.engine.getSuggestion(t,this.currentSuggestionIndex),!this.ghost)return;if(this.shouldHideGhostForPlaceholder(t.length===0))this.ghost.textContent="";else if(this.currentSuggestion.remaining){this.ghost.textContent="";let o=document.createElement("span");o.className="mask-ghost-typed",o.textContent=t;let s=document.createElement("span");s.className="mask-ghost-remaining",s.textContent=this.currentSuggestion.remaining,this.ghost.appendChild(o),this.ghost.appendChild(s)}else this.ghost.textContent="";this.ghost.scrollLeft=this.input.scrollLeft;let e=this.getDetail();this.options.onInput&&this.options.onInput(e),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:e})),this.dispatchNativeInput()}handleInput(){if(!this.isDispatchingNativeInput&&!this.options.disabled){if(this.options.autoLowercase){let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,o=this.input.value.toLowerCase();o!==this.input.value&&(this.setNativeValue(o),this.input.setSelectionRange(t,e))}this.currentSuggestionIndex=0,this.updateSuggestion()}}handleKeyDown(t){if(this.options.disabled)return;let e=!!this.currentSuggestion.remaining&&!this.currentSuggestion.isHintOnly,s=(this.input.selectionStart??0)===this.input.value.length,n=this.input.value.length>0;if(this.options.cycleSuggestions&&e&&n&&s){if(t.key==="ArrowDown"){t.preventDefault(),this.currentSuggestionIndex++,this.updateSuggestion();return}if(t.key==="ArrowUp"){t.preventDefault(),this.currentSuggestionIndex--,this.updateSuggestion();return}}if(t.key==="Tab"&&e&&n&&this.options.completeOnTab){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="Enter"&&e&&n&&this.options.completeOnEnter){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="ArrowRight"&&e&&n&&s&&this.options.completeOnArrowRight){t.preventDefault(),this.acceptSuggestion();return}}acceptSuggestion(){if(!this.currentSuggestion.remaining||this.currentSuggestion.isHintOnly||this.options.disabled||this.input.value.length===0)return!1;let t=this.currentSuggestion.full;this.setNativeValue(t),this.input.setSelectionRange(t.length,t.length),this.currentSuggestionIndex=0,this.updateSuggestion();let e=this.getDetail();return this.options.onChange&&this.options.onChange(e),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:e})),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:e})),!0}setDefaultDomain(t){this.engine.setDefaultDomain(t),this.updateSuggestion()}setDefaultTld(t){this.engine.setDefaultTld(t),this.updateSuggestion()}setTlds(t){this.engine.setTlds(t),this.currentSuggestionIndex=0,this.updateSuggestion()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.updateSuggestion()}handleBlur(){this.wrapper.classList.remove("is-focused"),this.updateSuggestion();let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask-cycle-suggestions")this.options.cycleSuggestions=this.getAttr("data-mask-cycle-suggestions")==="true";else if(t==="data-mask-auto-lowercase")this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true";else if(t==="data-mask-default-tld"){let e=this.getAttr("data-mask-default-tld");this.setDefaultTld(e===null||e==="false"||e==="none"?null:e==="true"?!0:e)}else if(t==="data-mask-tlds"){let e=this.getAttr("data-mask-tlds");this.setTlds(e?e.split(",").map(o=>o.trim()).filter(Boolean):null)}else t==="placeholder"&&this.updateSuggestion()}getDetail(){return{value:this.input.value,suggestedValue:this.currentSuggestion.isHintOnly?"":this.currentSuggestion.full,domain:this.currentSuggestion.matchedDomain}}setValue(t){let e=t!=null?String(t):"";this.setNativeValue(e),this.updateSuggestion()}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("blur",this.handleBlur),this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.wasAriaAutocompleteSet&&this.input.getAttribute("aria-autocomplete")==="inline"&&this.input.removeAttribute("aria-autocomplete"),super.destroy())}};var ft={BaseInputMask:x,InputMask:z,MaskEngine:H,MaskHistory:C,MaskKeyboard:N,AmountEngine:R,InputAmountMask:$,EmailEngine:V,InputEmailMask:X};if(typeof window<"u"){let m=window,i=m.Wulf||{};m.Wulf=i,i.Mask=ft}var nt=z;var lt={};J(lt,{LocalizedComponent:()=>S,Scroll:()=>vt,ScrollBlock:()=>F,createI18nManager:()=>A,default:()=>Lt,scrollEn:()=>at,scrollFr:()=>rt,scrollI18n:()=>G});var S=class{static setLocale(i){this._i18n&&this._i18n.setLocale(i)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(i,t){this._i18n&&this._i18n.registerLocale(i,t)}static setI18n(i){this._i18n&&this._i18n.setI18n(i)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(i,t){return this._i18n?this._i18n.t(i,t):String(i)}constructor(i){this.i18nOverrides=i}t(i){let t=this.constructor;return t._i18n?t._i18n.t(i,this.i18nOverrides):String(i)}};function it(m){return m.trim().toLowerCase().replace(/_/g,"-")}function Mt(m){let i=m.indexOf("-");return i>0?m.slice(0,i):null}function _(m,i){if(!i)return m;for(let t of Object.keys(i))i[t]!==void 0&&(m[t]=i[t]);return m}function A(m,i){let t=it(m),e={};for(let[r,h]of Object.entries(i))e[it(r)]={...h};let o=t,s={...e},n={};function a(){let r=[],h=s[o];h&&r.push(h);let u=Mt(o);return u&&s[u]&&r.push(s[u]),r}return{setLocale(r){r&&r.trim()&&(o=it(r))},getLocale(){return o},registerLocale(r,h){if(!r||!r.trim()||!h)return;let u=it(r);s[u]=_({...s[u]||{}},h)},setI18n(r){r&&(n=_({...n},r))},t(r,h){if(h&&h[r]!==void 0)return String(h[r]);if(n[r]!==void 0)return String(n[r]);for(let c of a())if(c[r]!==void 0)return String(c[r]);let u=s[t]||e[t];return u&&u[r]!==void 0?String(u[r]):String(r)},getAll(r){let h={},u=s[t]||e[t];_(h,u);let c=a().reverse();for(let l of c)_(h,l);return _(h,n),_(h,r),h},reset(){o=t,n={},s={};for(let[r,h]of Object.entries(e))s[r]={...h}}}}var rt={viewport:"Zone de contenu d\xE9filable",verticalThumb:"D\xE9filement vertical",horizontalThumb:"D\xE9filement horizontal"};var at={viewport:"Scrollable content area",verticalThumb:"Vertical scroll",horizontalThumb:"Horizontal scroll"};var G=A("fr",{fr:rt,en:at});var gt=0,F=class extends S{constructor(t,e){super(e?.i18n);this.createdViewport=!1;this.wasIdGenerated=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.hasExplicitAriaLabel=!1;this.lastInferredAriaLabel="";this.isDragging=!1;this.dragStartPos=0;this.dragStartScroll=0;this.atBottom=!1;this.atTop=!0;this.atRight=!1;this.atLeft=!0;let o=typeof t=="string"?document.querySelector(t):t;if(!o)throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${t}".`);this.root=o,this.hasExplicitAriaLabel=!!e?.ariaLabel,this.options={axis:e?.axis||"y",autoHide:e?.autoHide??!0,autoHideDelay:e?.autoHideDelay??1e3,alwaysVisible:e?.alwaysVisible??!1,ariaLabel:e?.ariaLabel||this.t("viewport"),i18n:e?.i18n||{},minThumbSize:e?.minThumbSize??24,edgeThreshold:e?.edgeThreshold??10,onScroll:e?.onScroll||(()=>{}),onTotalScroll:e?.onTotalScroll||(()=>{}),onTotalScrollBack:e?.onTotalScrollBack||(()=>{})},this.boundOnScroll=this.handleScroll.bind(this),this.boundOnMouseEnter=this.handleMouseEnter.bind(this),this.boundOnMouseLeave=this.handleMouseLeave.bind(this),this.boundOnFocusIn=this.handleFocusIn.bind(this),this.boundOnFocusOut=this.handleFocusOut.bind(this),this.boundPointerMove=this.handlePointerMove.bind(this),this.boundPointerUp=this.handlePointerUp.bind(this),this.viewport=this.setupViewport(),this.setupAccessibility(),this.setupScrollbars(),this.setupEventListeners(),this.setupObserver(),this.update()}setupViewport(){this.root.classList.add("wulf-scrollblock"),this.options.alwaysVisible&&this.root.classList.add("is-always-visible"),this.options.axis==="both"&&this.root.classList.add("has-both-axes");let t=this.root.querySelector(":scope > .wulf-scrollblock-viewport");if(t)return t;let e=document.createElement("div");for(e.className="wulf-scrollblock-viewport";this.root.firstChild;)e.appendChild(this.root.firstChild);return this.root.appendChild(e),this.createdViewport=!0,e}setupAccessibility(){if(this.viewport.id||(gt+=1,this.viewport.id=`wulf-scrollblock-vp-${gt}`,this.wasIdGenerated=!0),this.viewport.hasAttribute("role")||(this.viewport.setAttribute("role","region"),this.wasRoleInferred=!0),!this.viewport.hasAttribute("aria-label")){let t=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("viewport");this.viewport.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.wasAriaLabelInferred=!0}}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel){let e=this.t("viewport");this.viewport.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.options.ariaLabel=e}this.thumbY&&this.thumbY.setAttribute("aria-label",this.t("verticalThumb")),this.thumbX&&this.thumbX.setAttribute("aria-label",this.t("horizontalThumb"))}setupScrollbars(){(this.options.axis==="y"||this.options.axis==="both")&&(this.trackY=document.createElement("div"),this.trackY.className="wulf-scrollblock-track wulf-scrollblock-vertical",this.trackY.setAttribute("aria-hidden","true"),this.thumbY=document.createElement("div"),this.thumbY.className="wulf-scrollblock-thumb",this.thumbY.setAttribute("role","scrollbar"),this.thumbY.setAttribute("aria-orientation","vertical"),this.thumbY.setAttribute("aria-controls",this.viewport.id),this.thumbY.setAttribute("aria-valuenow","0"),this.thumbY.setAttribute("aria-valuemin","0"),this.thumbY.setAttribute("aria-valuemax","100"),this.thumbY.setAttribute("aria-label",this.t("verticalThumb")),this.trackY.appendChild(this.thumbY),this.root.appendChild(this.trackY),this.attachTrackListeners(this.trackY,this.thumbY,"y")),(this.options.axis==="x"||this.options.axis==="both")&&(this.trackX=document.createElement("div"),this.trackX.className="wulf-scrollblock-track wulf-scrollblock-horizontal",this.trackX.setAttribute("aria-hidden","true"),this.thumbX=document.createElement("div"),this.thumbX.className="wulf-scrollblock-thumb",this.thumbX.setAttribute("role","scrollbar"),this.thumbX.setAttribute("aria-orientation","horizontal"),this.thumbX.setAttribute("aria-controls",this.viewport.id),this.thumbX.setAttribute("aria-valuenow","0"),this.thumbX.setAttribute("aria-valuemin","0"),this.thumbX.setAttribute("aria-valuemax","100"),this.thumbX.setAttribute("aria-label",this.t("horizontalThumb")),this.trackX.appendChild(this.thumbX),this.root.appendChild(this.trackX),this.attachTrackListeners(this.trackX,this.thumbX,"x"))}attachTrackListeners(t,e,o){e.addEventListener("pointerdown",s=>{s.preventDefault(),s.stopPropagation(),this.isDragging=!0,this.dragAxis=o,this.dragPointerId=s.pointerId,this.dragStartPos=o==="y"?s.clientY:s.clientX,this.dragStartScroll=o==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,e.setPointerCapture(s.pointerId),e.classList.add("is-active"),this.root.classList.add("is-dragging"),window.addEventListener("pointermove",this.boundPointerMove),window.addEventListener("pointerup",this.boundPointerUp),window.addEventListener("pointercancel",this.boundPointerUp)}),t.addEventListener("pointerdown",s=>{if(s.target===e)return;s.preventDefault();let n=t.getBoundingClientRect(),a=o==="y"?s.clientY-n.top:s.clientX-n.left,r=o==="y"?n.height:n.width,h=o==="y"?this.viewport.clientHeight:this.viewport.clientWidth,u=o==="y"?this.viewport.scrollHeight:this.viewport.scrollWidth,l=a/r*(u-h);this.scrollTo(o==="y"?{top:l}:{left:l},{smooth:!0})})}setupEventListeners(){this.viewport.addEventListener("scroll",this.boundOnScroll,{passive:!0}),this.options.autoHide&&!this.options.alwaysVisible&&(this.root.addEventListener("mouseenter",this.boundOnMouseEnter),this.root.addEventListener("mouseleave",this.boundOnMouseLeave),this.root.addEventListener("focusin",this.boundOnFocusIn),this.root.addEventListener("focusout",this.boundOnFocusOut))}setupObserver(){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{window.requestAnimationFrame(()=>this.update())}),this.resizeObserver.observe(this.root),this.resizeObserver.observe(this.viewport),this.viewport.firstElementChild&&this.resizeObserver.observe(this.viewport.firstElementChild))}handlePointerMove(t){if(!this.isDragging||!this.dragAxis)return;let e=this.dragAxis==="y",o=(e?t.clientY:t.clientX)-this.dragStartPos,s=e?this.trackY:this.trackX,n=e?this.thumbY:this.thumbX;if(!s||!n)return;let a=e?s.clientHeight:s.clientWidth,r=e?n.clientHeight:n.clientWidth,h=e?this.viewport.clientHeight:this.viewport.clientWidth,c=(e?this.viewport.scrollHeight:this.viewport.scrollWidth)-h,l=a-r;if(l<=0||c<=0)return;let p=c/l,d=this.dragStartScroll+o*p;e?this.viewport.scrollTop=Math.max(0,Math.min(c,d)):this.viewport.scrollLeft=Math.max(0,Math.min(c,d))}handlePointerUp(t){if(this.isDragging){if(this.dragPointerId!==void 0){let e=this.dragAxis==="y"?this.thumbY:this.thumbX;e&&e.hasPointerCapture(this.dragPointerId)&&e.releasePointerCapture(this.dragPointerId)}window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.isDragging=!1,this.dragAxis=void 0,this.dragPointerId=void 0,this.thumbY?.classList.remove("is-active"),this.thumbX?.classList.remove("is-active"),this.root.classList.remove("is-dragging"),this.scheduleAutoHide()}}handleScroll(){this.syncThumbs();let{scrollTop:t,scrollLeft:e,scrollHeight:o,scrollWidth:s,clientHeight:n,clientWidth:a}=this.viewport,r=Math.max(0,o-n),h=Math.max(0,s-a),u=r>0?t/r:0,c=h>0?e/h:0;this.options.onScroll({top:t,left:e,maxTop:r,maxLeft:h,progressY:Math.round(u*100),progressX:Math.round(c*100)});let l=this.options.edgeThreshold;if(r>0){let p=t>=r-l,d=t<=l;p&&!this.atBottom&&this.options.onTotalScroll("bottom"),d&&!this.atTop&&this.options.onTotalScrollBack("top"),this.atBottom=p,this.atTop=d}if(h>0){let p=e>=h-l,d=e<=l;p&&!this.atRight&&this.options.onTotalScroll("right"),d&&!this.atLeft&&this.options.onTotalScrollBack("left"),this.atRight=p,this.atLeft=d}this.options.autoHide&&!this.options.alwaysVisible&&(this.root.classList.add("is-scrolling"),this.scheduleAutoHide())}syncThumbs(){let{scrollTop:t,scrollLeft:e,scrollHeight:o,scrollWidth:s,clientHeight:n,clientWidth:a}=this.viewport;if(this.thumbY&&this.trackY){let r=o-n,h=this.trackY.clientHeight,u=this.thumbY.clientHeight,c=h-u;if(r>0&&c>0){let l=t/r,p=Math.max(0,Math.min(c,l*c));this.thumbY.style.transform=`translate3d(0, ${p}px, 0)`,this.thumbY.setAttribute("aria-valuenow",String(Math.round(l*100)))}}if(this.thumbX&&this.trackX){let r=s-a,h=this.trackX.clientWidth,u=this.thumbX.clientWidth,c=h-u;if(r>0&&c>0){let l=e/r,p=Math.max(0,Math.min(c,l*c));this.thumbX.style.transform=`translate3d(${p}px, 0, 0)`,this.thumbX.setAttribute("aria-valuenow",String(Math.round(l*100)))}}}handleMouseEnter(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleMouseLeave(){this.scheduleAutoHide()}handleFocusIn(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleFocusOut(){this.scheduleAutoHide()}clearAutoHideTimer(){this.hideTimer&&(window.clearTimeout(this.hideTimer),this.hideTimer=void 0)}scheduleAutoHide(){this.options.alwaysVisible||!this.options.autoHide||this.isDragging||(this.clearAutoHideTimer(),this.hideTimer=window.setTimeout(()=>{this.root.classList.remove("is-scrolling"),this.root.classList.remove("is-visible")},this.options.autoHideDelay))}update(){this.syncAccessibilityLabels();let{scrollHeight:t,clientHeight:e,scrollWidth:o,clientWidth:s}=this.viewport,n=t>e,a=o>s;if(this.root.classList.toggle("has-scroll-y",n),this.root.classList.toggle("has-scroll-x",a),n||a?this.viewport.setAttribute("tabindex","0"):this.viewport.removeAttribute("tabindex"),this.trackY&&this.thumbY&&n){let r=this.trackY.clientHeight,h=Math.max(this.options.minThumbSize,r*(e/t));this.thumbY.style.height=`${h}px`}if(this.trackX&&this.thumbX&&a){let r=this.trackX.clientWidth,h=Math.max(this.options.minThumbSize,r*(s/o));this.thumbX.style.width=`${h}px`}this.syncThumbs()}scrollTo(t,e){let o=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,s=typeof t=="object"&&t!==null&&!(t instanceof HTMLElement)?t.smooth:void 0,a=(e?.smooth??s??!0)&&!o?"smooth":"auto",r=Math.max(0,this.viewport.scrollHeight-this.viewport.clientHeight),h=Math.max(0,this.viewport.scrollWidth-this.viewport.clientWidth),u,c;if(typeof t=="number")u=t;else if(typeof t=="string")switch(t){case"top":u=0;break;case"bottom":u=r;break;case"left":c=0;break;case"right":c=h;break;default:{if(/^-?\d+(\.\d+)?%$/.test(t.trim())){let p=Math.max(0,Math.min(100,parseFloat(t.trim())))/100;this.options.axis==="x"?c=h*p:this.options.axis==="both"?(u=r*p,c=h*p):u=r*p;break}let l=null;try{l=this.viewport.querySelector(t)}catch{l=null}l&&(u=l.offsetTop,c=l.offsetLeft);break}}else t instanceof HTMLElement?(u=t.offsetTop,c=t.offsetLeft):typeof t=="object"&&(u=t.top,c=t.left);this.viewport.scrollTo({top:u!==void 0?Math.max(0,Math.min(r,u)):void 0,left:c!==void 0?Math.max(0,Math.min(h,c)):void 0,behavior:a})}destroy(){if(this.clearAutoHideTimer(),this.resizeObserver&&this.resizeObserver.disconnect(),this.viewport.removeEventListener("scroll",this.boundOnScroll),this.root.removeEventListener("mouseenter",this.boundOnMouseEnter),this.root.removeEventListener("mouseleave",this.boundOnMouseLeave),this.root.removeEventListener("focusin",this.boundOnFocusIn),this.root.removeEventListener("focusout",this.boundOnFocusOut),window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.trackY?.remove(),this.trackX?.remove(),this.root.classList.remove("wulf-scrollblock","has-scroll-y","has-scroll-x","has-both-axes","is-visible","is-scrolling","is-dragging","is-always-visible"),this.createdViewport&&this.viewport.parentElement===this.root){for(;this.viewport.firstChild;)this.root.insertBefore(this.viewport.firstChild,this.viewport);this.viewport.remove()}else this.viewport.removeAttribute("tabindex"),this.wasIdGenerated&&this.viewport.removeAttribute("id"),this.wasRoleInferred&&this.viewport.getAttribute("role")==="region"&&this.viewport.removeAttribute("role"),this.wasAriaLabelInferred&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.viewport.removeAttribute("aria-label")}};F._i18n=G,F.i18n=G;var vt={ScrollBlock:F,i18n:G};var Lt=F;if(typeof window<"u"){let m=window,i=m.Wulf||{};m.Wulf=i,i.Scroll=vt}var ct={};J(ct,{LayoutEngine:()=>U,LocalizedComponent:()=>S,Masonry:()=>P,createI18nManager:()=>A,default:()=>St,masonryEn:()=>ut,masonryFr:()=>ht,masonryI18n:()=>j});var U=class{static parseGutter(i){return typeof i=="number"?{x:Math.max(0,i),y:Math.max(0,i)}:i&&typeof i=="object"?{x:Math.max(0,Number(i.x)||0),y:Math.max(0,Number(i.y)||0)}:{x:0,y:0}}static resolveColumnWidth(i,t,e){if(typeof e=="number"&&e>0)return e;if(typeof e=="string"){let s=i.querySelector(e);if(s){let a=s.getBoundingClientRect().width;if(a>0)return a}let n=parseFloat(e);if(!isNaN(n)&&n>0)return e.endsWith("%")?i.getBoundingClientRect().width*n/100:n}if(e instanceof HTMLElement){let s=e.getBoundingClientRect().width;if(s>0)return s}if(t){let s=t.getBoundingClientRect().width;if(s>0)return s}let o=i.getBoundingClientRect().width;return o>0?o:200}static getItemSpan(i,t,e,o){let s=i.getAttribute("data-masonry-span")||i.dataset.masonrySpan;if(s){let a=parseInt(s,10);if(!isNaN(a)&&a>0)return Math.min(o,a)}let n=i.className.match(/(?:^|\s)(?:span|col-span)-(\d+)(?:\s|$)/);if(n&&n[1]){let a=parseInt(n[1],10);if(!isNaN(a)&&a>0)return Math.min(o,a)}return 1}static calculate(i,t,e){let s=i.getBoundingClientRect().width,{x:n,y:a}=this.parseGutter(e.gutter);if(s<=0||t.length===0)return{cols:1,colWidth:s,gutterX:n,gutterY:a,containerHeight:0,containerWidth:s,positions:[]};let r=t[0]||null,h=this.resolveColumnWidth(i,r,e.columnWidth),u=Math.floor((s+n)/(h+n));u=Math.max(1,u),!e.columnWidth&&u>1&&(h=(s-(u-1)*n)/u);let c=e.fitWidth?u*h+(u-1)*n:void 0,l=new Array(u).fill(0),p=[],d=t.map(b=>{let T=b.getBoundingClientRect().height;return T>0?T:50}),f=0;for(let b=0;b<t.length;b++){let T=t[b],y=d[b],w=this.getItemSpan(T,h,n,u),k=0,I=0;if(e.horizontalOrder){f+w>u&&(f=0),k=f;let L=0;for(let M=0;M<w;M++)l[k+M]>L&&(L=l[k+M]);I=L,f=(k+w)%u}else if(w===1){let L=l[0];k=0;for(let M=1;M<u;M++)l[M]<L&&(L=l[M],k=M);I=L}else{let L=1/0;k=0;for(let M=0;M<=u-w;M++){let tt=0;for(let et=0;et<w;et++)l[M+et]>tt&&(tt=l[M+et]);tt<L&&(L=tt,k=M)}I=L}let Z=w*h+(w-1)*n,E=k*(h+n);p.push({element:T,x:E,y:I,width:Z,height:y,column:k,span:w});let D=I+y+a;for(let L=0;L<w;L++)l[k+L]=D}let g=0;for(let b=0;b<u;b++)l[b]>g&&(g=l[b]);let v=Math.max(0,g>0?g-a:0);return{cols:u,colWidth:h,gutterX:n,gutterY:a,containerHeight:v,containerWidth:s,fittedWidth:c,positions:p}}};var ht={gallery:"Galerie en grille asym\xE9trique"};var ut={gallery:"Masonry grid gallery"};var j=A("fr",{fr:ht,en:ut});var P=class extends S{constructor(t,e={}){super(e.i18n);this.isNativeCSSGrid=!1;this._items=[];this.resizeObserver=null;this.itemResizeObserver=null;this.layoutRafId=null;this.isDestroyed=!1;this.wasRoleInferred=!1;this.wasAriaLabelInferred=!1;this.hasExplicitAriaLabel=!1;this.lastInferredAriaLabel="";this.removeTimers=new Set;this.pendingImageListeners=[];if(typeof t=="string"){let s=document.querySelector(t);if(!s)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${t}"`);this.root=s}else if(t instanceof HTMLElement)this.root=t;else throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");this.originalContainerStyles={height:this.root.style.height,width:this.root.style.width},this.hasExplicitAriaLabel=!!e.ariaLabel,this.options={itemSelector:e.itemSelector||"> *",columnWidth:e.columnWidth??0,gutter:e.gutter??0,percentPosition:!!e.percentPosition,fitWidth:!!e.fitWidth,horizontalOrder:!!e.horizontalOrder,transitionDuration:e.transitionDuration!==void 0?e.transitionDuration:300,stagger:e.stagger||0,resize:e.resize!==!1,autoImages:e.autoImages!==!1,useNativeCSSGrid:e.useNativeCSSGrid!==!1,ariaRole:e.ariaRole||"region",ariaLabel:e.ariaLabel||this.t("gallery"),i18n:e.i18n||{},onLayout:e.onLayout||(()=>{}),onItemPlaced:e.onItemPlaced||(()=>{})};let o=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("grid-template-rows","masonry");this.options.useNativeCSSGrid&&o?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native")):this.root.classList.add("wulf-masonry"),this.initAccessibility(),this.applyTransitionDuration(),this.reloadItems(),this.initObservers(),this.initImages(),this.layout()}get items(){return[...this._items]}initAccessibility(){this.options.ariaRole&&!this.root.hasAttribute("role")&&(this.root.setAttribute("role",this.options.ariaRole),this.wasRoleInferred=!0);let t=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("gallery");t&&!this.root.hasAttribute("aria-label")&&(this.root.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.wasAriaLabelInferred=!0)}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel){let e=this.t("gallery");this.root.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.options.ariaLabel=e}}applyTransitionDuration(){let t=this.options.transitionDuration,e=typeof t=="number"?`${t}ms`:t;this.root.style.setProperty("--wulf-masonry-duration",e)}reloadItems(){if(this.isDestroyed)return;let t=[];if(this.options.itemSelector==="> *")t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"));else try{t=Array.from(this.root.querySelectorAll(this.options.itemSelector)).filter(e=>e.parentElement===this.root&&!e.hasAttribute("data-masonry-ignore"))}catch{t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"))}this._items=t;for(let e of this._items)e.classList.add("wulf-masonry-item"),this.itemResizeObserver&&this.itemResizeObserver.observe(e)}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let t=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(e=>{for(let o of e){let s=o.contentRect.width;Math.abs(s-t)>=1&&(t=s,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(()=>{this.scheduleLayout()});for(let e of this._items)this.itemResizeObserver.observe(e)}initImages(){if(!this.options.autoImages)return;let t=Array.from(this.root.querySelectorAll("img"));for(let e of t)if(!e.complete){let o=()=>{let s=()=>{this.pendingImageListeners=this.pendingImageListeners.filter(n=>n.handler!==s),this.isDestroyed||this.scheduleLayout()};this.pendingImageListeners.push({img:e,handler:s}),e.addEventListener("load",s,{once:!0})};typeof e.decode=="function"?e.decode().then(()=>{this.isDestroyed||this.scheduleLayout()}).catch(()=>{o()}):o()}}scheduleLayout(){this.isDestroyed||(this.layoutRafId!==null&&cancelAnimationFrame(this.layoutRafId),this.layoutRafId=requestAnimationFrame(()=>{this.layoutRafId=null,this.layout()}))}layout(){if(this.isDestroyed)return;if(this.syncAccessibilityLabels(),this.isNativeCSSGrid){this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true");let t=U.calculate(this.root,this._items,this.options);this.root.style.height=`${t.containerHeight}px`,this.options.fitWidth&&t.fittedWidth!==void 0?(this.root.style.width=`${t.fittedWidth}px`,this.root.classList.add("wulf-masonry--fit-width")):this.root.classList.remove("wulf-masonry--fit-width");let e=this.options.stagger,o=this.options.percentPosition&&t.containerWidth>0;for(let s=0;s<t.positions.length;s++){let n=t.positions[s],a=n.element;if(o){let r=Number((n.width/t.containerWidth*100).toFixed(4));a.style.setProperty("--wulf-masonry-w",`${r}%`)}else a.style.setProperty("--wulf-masonry-w",`${n.width}px`);a.style.setProperty("--wulf-masonry-x",`${n.x}px`),a.style.setProperty("--wulf-masonry-y",`${n.y}px`),e>0?a.style.transitionDelay=`${s*e}ms`:a.style.removeProperty("transition-delay"),a.classList.remove("wulf-masonry-item--hidden"),this.options.onItemPlaced(a,n)}this.root.setAttribute("aria-busy","false"),this.options.onLayout(t.positions)}append(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let o=document.createDocumentFragment();for(let s of e)s.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),o.appendChild(s);this.root.appendChild(o),this.reloadItems(),this.initImages(),this.layout()}prepend(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let o=this.root.firstChild,s=document.createDocumentFragment();for(let n of e)n.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),s.appendChild(n);this.root.insertBefore(s,o),this.reloadItems(),this.initImages(),this.layout()}remove(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;for(let n of e)n.classList.add("wulf-masonry-item--hidden");let o=typeof this.options.transitionDuration=="number"?this.options.transitionDuration:300;if(o<=0){for(let n of e)n.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(n),this.root.removeChild(n));this.reloadItems(),this.layout();return}let s=window.setTimeout(()=>{if(this.removeTimers.delete(s),!this.isDestroyed){for(let n of e)n.parentElement===this.root&&(this.itemResizeObserver&&this.itemResizeObserver.unobserve(n),this.root.removeChild(n));this.reloadItems(),this.layout()}},o);this.removeTimers.add(s)}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(let t of this.removeTimers)clearTimeout(t);this.removeTimers.clear();for(let{img:t,handler:e}of this.pendingImageListeners)t.removeEventListener("load",e);this.pendingImageListeners=[],this.layoutRafId!==null&&(cancelAnimationFrame(this.layoutRafId),this.layoutRafId=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.itemResizeObserver&&(this.itemResizeObserver.disconnect(),this.itemResizeObserver=null),this.root.classList.remove("wulf-masonry","wulf-masonry--native","wulf-masonry--fit-width"),this.root.removeAttribute("aria-busy"),this.wasRoleInferred&&this.root.getAttribute("role")===this.options.ariaRole&&this.root.removeAttribute("role"),this.wasAriaLabelInferred&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.root.removeAttribute("aria-label"),this.root.style.removeProperty("--wulf-masonry-duration"),this.originalContainerStyles.height?this.root.style.height=this.originalContainerStyles.height:this.root.style.removeProperty("height"),this.originalContainerStyles.width?this.root.style.width=this.originalContainerStyles.width:this.root.style.removeProperty("width");for(let t of this._items)t.classList.remove("wulf-masonry-item","wulf-masonry-item--hidden"),t.style.removeProperty("--wulf-masonry-w"),t.style.removeProperty("--wulf-masonry-x"),t.style.removeProperty("--wulf-masonry-y"),t.style.removeProperty("transition-delay");this._items=[]}}};P._i18n=j,P.i18n=j;var St=P;if(typeof window<"u"){let m=window,i=m.Wulf||{};m.Wulf=i,i.Masonry=Object.assign(P,{Masonry:P,LayoutEngine:U,i18n:j})}var mt={};J(mt,{LocalizedComponent:()=>S,Toast:()=>B,ToastInstance:()=>Q,ToastManager:()=>q,createI18nManager:()=>A,default:()=>xt,toastEn:()=>dt,toastFr:()=>pt,toastI18n:()=>W});var pt={closeButton:"Fermer la notification"};var dt={closeButton:"Close notification"};var W=A("fr",{fr:pt,en:dt});var It=1,Q=class{constructor(i,t){this._isClosed=!1;this.timerId=null;this.remainingTime=0;this.timerStartTime=0;this.isPaused=!1;this.id=`wulf-toast-${It++}`,this.options=Object.freeze({...i}),this.onDismissCallback=t;let e=i.duration===void 0?4e3:i.duration;typeof e=="number"&&e>0?this.remainingTime=e:this.remainingTime=0,this.element=this.createDOM(),this.bindEvents()}get isClosed(){return this._isClosed}createDOM(){let i=document.createElement("div");i.id=this.id,i.className="wulf-toast";let t=this.options.role==="alert"?"alert":"status";if(i.setAttribute("role",t),i.setAttribute("aria-live",t==="alert"?"assertive":"polite"),i.setAttribute("aria-atomic","true"),this.options.backgroundColor&&i.style.setProperty("--wulf-toast-bg",this.options.backgroundColor),this.options.titleColor&&i.style.setProperty("--wulf-toast-title-color",this.options.titleColor),this.options.textColor&&i.style.setProperty("--wulf-toast-text-color",this.options.textColor),this.options.iconColor&&i.style.setProperty("--wulf-toast-icon-color",this.options.iconColor),this.options.closeButtonColor&&i.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor),this.options.icon&&this.options.icon.trim()!==""){let s=document.createElement("span");s.className=`wulf-toast-icon ${this.options.icon.trim()}`,s.setAttribute("aria-hidden","true"),i.appendChild(s)}let e=document.createElement("div");if(e.className="wulf-toast-content",this.options.title&&this.options.title.trim()!==""){let s=document.createElement("div");s.className="wulf-toast-title",this.appendTextWithLineBreaks(s,this.options.title),e.appendChild(s)}if(this.options.message&&this.options.message.trim()!==""){let s=document.createElement("div");s.className="wulf-toast-message",this.appendTextWithLineBreaks(s,this.options.message),e.appendChild(s)}if(i.appendChild(e),this.options.closable??!0){let s=document.createElement("button");s.type="button",s.className="wulf-toast-close",s.setAttribute("aria-label",W.t("closeButton",this.options.i18n)),s.setAttribute("tabindex","0");let n=document.createElement("span");n.className="wulf-toast-close-icon",n.setAttribute("aria-hidden","true"),n.textContent="\xD7",s.appendChild(n),s.addEventListener("click",a=>{a.stopPropagation(),this.close("close-button")}),i.appendChild(s)}return i}appendTextWithLineBreaks(i,t){t.split(/\r\n|\r|\n/).forEach((o,s)=>{s>0&&i.appendChild(document.createElement("br")),i.appendChild(document.createTextNode(o))})}bindEvents(){this.element.addEventListener("click",i=>{this.options.onClick&&this.options.onClick(this,i),this.options.closeOnClick&&this.close("toast-click")}),this.element.addEventListener("mouseenter",()=>this.pauseTimer()),this.element.addEventListener("mouseleave",()=>this.resumeTimer()),this.element.addEventListener("focusin",()=>this.pauseTimer()),this.element.addEventListener("focusout",()=>this.resumeTimer())}startTimer(){this._isClosed||this.remainingTime<=0||(this.timerStartTime=Date.now(),this.timerId=window.setTimeout(()=>{this.close("timeout")},this.remainingTime))}pauseTimer(){if(this._isClosed||this.remainingTime<=0||this.isPaused)return;this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null);let i=Date.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-i),this.isPaused=!0}resumeTimer(){this._isClosed||this.remainingTime<=0||!this.isPaused||(this.isPaused=!1,this.startTimer())}destroyImmediate(i="replace"){this._isClosed||(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,i),this.options.onClose&&this.options.onClose(this,i))}close(i="programmatic",t=!1){return this._isClosed?Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),new Promise(e=>{this.element.classList.add(t?"wulf-toast-hiding-fast":"wulf-toast-hiding");let o=()=>{this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,i),this.options.onClose&&this.options.onClose(this,i),e()};if(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)o();else if(t)window.setTimeout(o,90);else{let n=!1,a=null,r=()=>{n||(n=!0,a!==null&&(window.clearTimeout(a),a=null),this.element.removeEventListener("animationend",r),this.element.removeEventListener("transitionend",r),o())};this.element.addEventListener("animationend",r,{once:!0}),this.element.addEventListener("transitionend",r,{once:!0}),a=window.setTimeout(r,300)}}))}};var Y=class Y{constructor(){this.containers=new Map;this.activeToasts=new Map;this.replaceTokens=new Map;this.pendingReplacements=new Set}static getInstance(){return Y.instance||(Y.instance=new Y),Y.instance}add(i){let t=i.options.position||"top-right",e=this.activeToasts.get(t);if(e||(e=[],this.activeToasts.set(t,e)),i.options.replace&&e.length>0){let s=[...e],n=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,n),this.pendingReplacements.add(t);let a=s.map(r=>r.close("replace",!0));Promise.all(a).then(()=>{this.pendingReplacements.delete(t),this.replaceTokens.get(t)===n&&this.mountToast(i,t)});return}let o=typeof i.options.maxToasts=="number"&&i.options.maxToasts>0?i.options.maxToasts:5;if(e.length>=o){let s=e.length-o+1,n=e.splice(0,s);for(let a of n)a.close("max-limit",!0)}this.mountToast(i,t)}mountToast(i,t){let e=this.getOrCreateContainer(t),o=this.activeToasts.get(t);if(o||(o=[],this.activeToasts.set(t,o)),e.appendChild(i.element),o.push(i),i.options.onOpen)try{i.options.onOpen(i)}catch(s){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",s)}i.startTimer()}remove(i,t){let e=i.options.position||"top-right",o=this.activeToasts.get(e);if(o){let s=o.indexOf(i);if(s!==-1&&o.splice(s,1),o.length===0&&!this.pendingReplacements.has(e)){let n=this.containers.get(e);n&&(!n.firstChild||n.children.length===0)&&(n.parentNode&&n.parentNode.removeChild(n),this.containers.delete(e),this.activeToasts.delete(e))}}}clearAll(i){let t=[];if(i){let e=this.activeToasts.get(i);if(e&&e.length>0){let o=[...e];for(let s of o)t.push(s.close("programmatic"))}else{let o=this.containers.get(i);o&&(!o.firstChild||o.children.length===0)&&(o.parentNode&&o.parentNode.removeChild(o),this.containers.delete(i),this.activeToasts.delete(i))}}else{let e=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let o of e)t.push(this.clearAll(o))}return Promise.all(t).then(()=>{if(!i)for(let[e,o]of Array.from(this.containers.entries()))(!o.firstChild||o.children.length===0)&&(o.parentNode&&o.parentNode.removeChild(o),this.containers.delete(e),this.activeToasts.delete(e))})}getOrCreateContainer(i){let t=this.containers.get(i);return(!t||!document.body.contains(t))&&(t=document.createElement("div"),t.className=`wulf-toast-container wulf-toast-${i}`,t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions removals"),document.body.appendChild(t),this.containers.set(i,t)),t}};Y.instance=null;var q=Y;var B=class extends S{static show(i={}){let t=q.getInstance(),e=new Q(i,(o,s)=>{t.remove(o,s)});return t.add(e),e}static clearAll(i){return q.getInstance().clearAll(i)}};B._i18n=W,B.i18n=W;var xt=B;if(typeof window<"u"){let m=window,i=m.Wulf||{};m.Wulf=i,i.Toast=Object.assign(B,{Toast:B,i18n:W})}return kt(Ct);})();
1
+ "use strict";var Wulf=(()=>{var rt=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var Lt=Object.prototype.hasOwnProperty;var _=(p,i)=>{for(var t in i)rt(p,t,{get:i[t],enumerable:!0})},Mt=(p,i,t,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of Et(i))!Lt.call(p,s)&&s!==t&&rt(p,s,{get:()=>i[s],enumerable:!(e=kt(i,s))||e.enumerable});return p};var At=p=>Mt(rt({},"__esModule",{value:!0}),p);var Rt={};_(Rt,{AmountEngine:()=>P,AuditableComponent:()=>I,BaseInputMask:()=>x,EmailEngine:()=>V,FocusTrap:()=>vt,InputAmountMask:()=>q,InputEmailMask:()=>j,InputMask:()=>K,LocalizedComponent:()=>S,Mask:()=>lt,MaskEngine:()=>R,MaskHistory:()=>C,MaskKeyboard:()=>W,Masonry:()=>mt,Scroll:()=>ct,Toast:()=>bt,WulfFocusTrap:()=>N,createI18nManager:()=>D,default:()=>at,resolveMaskConstructorArgs:()=>H});var lt={};_(lt,{AmountEngine:()=>P,BaseInputMask:()=>x,EmailEngine:()=>V,InputAmountMask:()=>q,InputEmailMask:()=>j,InputMask:()=>K,Mask:()=>yt,MaskEngine:()=>R,MaskHistory:()=>C,MaskKeyboard:()=>W,default:()=>at,resolveMaskConstructorArgs:()=>H});var I=class{getAuditDisableHint(){return"Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement"}runAuditWarning(i=!0){if(!i)return[];let t=this.audit();return t.length>0&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${t.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
2
+ `+t.map(e=>` - ${e}`).join(`
3
+ `)+`
4
+ (${this.getAuditDisableHint()})`),t}checkAriaIdReferences(i,t,e){let s=i.getAttribute(t)?.trim();if(!s)return!1;let o=i.ownerDocument||document,n=s.split(/\s+/).filter(Boolean),a=n.length>0&&n.every(r=>!!o.getElementById(r));return a||e.push(`Attribut ${t}="${s}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),a}};function H(p,i,t){return i&&typeof i=="object"&&"tagName"in i&&i.tagName==="INPUT"?{wrapper:p||null,input:i,options:t||{}}:{wrapper:null,input:p,options:i&&typeof i=="object"&&!("tagName"in i)?i:{}}}var x=class extends I{constructor(t,e,s){super();this.ghost=null;this.isWrapperCreated=!1;this.isDestroyed=!1;this.isFocused=!1;this.isDispatchingNativeInput=!1;this.lastTrackedValue="";this.nativeValueDescriptor=null;this.onCutHandler=()=>{};this.mutationObserver=null;this.focusSelectTimerId=null;this.onBaseCopy=t=>{if(!this.options.copyRaw||this.options.disabled||this.input.type==="password")return;let e=this.input.selectionStart??0,s=this.input.selectionEnd??e,o="";e!==s?o=this.extractRawSnippet(this.input.value.slice(e,s)):o=this.getRawValue(),o&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",o))};this.onBaseFocus=()=>{this.isFocused=!0,this.options.selectAllOnFocus&&this.input.value.length>0&&(this.focusSelectTimerId!==null&&clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=window.setTimeout(()=>{this.focusSelectTimerId=null,!this.isDestroyed&&document.activeElement===this.input&&this.input.select()},0))};this.onBaseBlur=()=>{this.isFocused=!1};this.onScroll=()=>{this.ghost&&(this.ghost.scrollLeft=this.input.scrollLeft)};let{wrapper:o,input:n,options:a}=H(t,e,s);if(!n||typeof n!="object"||n.nodeType!==1||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",l=!!(a.createWrapper??r),h=o;if(!h&&l){let k=document.createElement("span");k.className="wulf-mask-wrapper",k.style.display="inline-grid",k.style.gridTemplateColumns="1fr",k.style.gridTemplateRows="1fr",k.style.verticalAlign="middle",k.style.boxSizing="border-box",k.style.position="relative",this.input.parentNode&&this.input.parentNode.insertBefore(k,this.input),k.appendChild(this.input),this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",h=k,this.isWrapperCreated=!0}if(!h)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=h,this.normalizeInputType();let c=this.getAttr("data-mask-focus-only")==="true",u=this.hasAttr("data-disabled"),d=this.getAttr("data-mask-select-on-focus")==="true",m=this.getAttr("data-mask-copy-raw")==="true",f=this.getAttr("data-mask-align")||this.getAttr("data-align"),g=this.getAttr("data-mask-audit"),{disabled:b,align:v,...w}=a,E=b!==void 0?b:!!u,y=a.audit??(g!==null?g!=="false":!0),T=this.input.type==="password";this.options={...w,createWrapper:l,showMaskOnFocus:a.showMaskOnFocus??c??!1,selectAllOnFocus:a.selectAllOnFocus??d??!1,copyRaw:T?!1:a.copyRaw??m??!1,disabled:E,align:v??(f||void 0),emitNativeInput:a.emitNativeInput??!0,audit:y},this.options.showMaskOnFocus&&this.wrapper.classList.add("mask-focus-only"),this.options.disabled&&this.wrapper.setAttribute("data-disabled","true"),this.options.align&&this.setAlign(this.options.align),this.createGhost(),this.hookValueProperty(),this.bindBaseEvents(),this.initMutationObserver()}getAttr(t){return this.input.getAttribute(t)||this.wrapper.getAttribute(t)}hasAttr(t){return this.wrapper.hasAttribute(t)||this.input.hasAttribute(t)}hasNativePlaceholder(){return!!(this.input.placeholder&&this.input.placeholder.trim().length>0)}shouldHideGhostForPlaceholder(t){return!this.isFocused&&t&&this.hasNativePlaceholder()}bindBaseEvents(){this.input.addEventListener("copy",this.onBaseCopy),this.input.addEventListener("focus",this.onBaseFocus),this.input.addEventListener("blur",this.onBaseBlur)}extractRawSnippet(t){return t}initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(e=>{for(let s of e)s.type==="attributes"&&s.attributeName&&this.handleAttributeMutation(s.attributeName)});let t={attributes:!0,attributeFilter:["data-mask","data-mask-placeholder","data-mask-focus-only","data-mask-strict","data-mask-select-on-focus","data-mask-copy-raw","data-mask-pad-decimals","data-mask-auto-lowercase","data-mask-cycle-suggestions","data-mask-default-tld","data-mask-tlds","data-disabled","data-mask-align","data-align","placeholder"]};this.mutationObserver.observe(this.wrapper,t),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,t)}setAlign(t){let e=t||void 0,s=this.wrapper.getAttribute("data-align");this.options.align===e&&s===(t||null)||(this.options.align=e,this.wrapper.classList.remove("align-left","align-right","align-center"),t?(this.wrapper.classList.add(`align-${t}`),this.wrapper.getAttribute("data-align")!==t&&this.wrapper.setAttribute("data-align",t)):this.wrapper.hasAttribute("data-align")&&this.wrapper.removeAttribute("data-align"),this.syncGhostStyles())}handleAttributeMutation(t){if(t==="data-disabled"){let e=this.hasAttr("data-disabled");e!==!!this.options.disabled&&this.setDisabled(e)}else if(t==="data-mask-focus-only"){let e=this.getAttr("data-mask-focus-only")==="true";e!==!!this.options.showMaskOnFocus&&this.setShowMaskOnFocus(e)}else if(t==="data-mask-select-on-focus")this.options.selectAllOnFocus=this.getAttr("data-mask-select-on-focus")==="true";else if(t==="data-mask-copy-raw")this.options.copyRaw=this.getAttr("data-mask-copy-raw")==="true";else if(t==="data-mask-align"||t==="data-align"){let e=this.getAttr("data-mask-align")||this.getAttr("data-align");e!==(this.options.align??null)&&this.setAlign(e)}}normalizeInputType(){let t=["number","email","date","datetime-local","month","week","time","color","file","range"];if(this.input.type&&t.includes(this.input.type.toLowerCase())){let e=this.input.type.toLowerCase();this.input.type="text",e==="number"&&(this.input.inputMode="numeric")}}createGhost(){let t=this.wrapper.querySelector(".mask-ghost");t&&t.remove(),this.ghost=document.createElement("div"),this.ghost.className="mask-ghost",this.ghost.setAttribute("aria-hidden","true"),this.ghost.style.display="flex",this.ghost.style.alignItems="center",this.wrapper.appendChild(this.ghost),this.wrapper.classList.add("has-ghost"),this.syncGhostStyles()}syncGhostStyles(){if(!this.ghost||typeof window>"u")return;let t=window.getComputedStyle(this.input);if(!t)return;this.ghost.style.fontFamily=t.fontFamily,this.ghost.style.fontSize=t.fontSize,this.ghost.style.fontWeight=t.fontWeight,this.ghost.style.fontStyle=t.fontStyle,this.ghost.style.letterSpacing=t.letterSpacing,this.ghost.style.lineHeight=t.lineHeight,this.ghost.style.paddingTop=t.paddingTop,this.ghost.style.paddingBottom=t.paddingBottom,this.ghost.style.paddingLeft=t.paddingLeft,this.ghost.style.paddingRight=t.paddingRight,this.ghost.style.borderTopWidth=t.borderTopWidth,this.ghost.style.borderBottomWidth=t.borderBottomWidth,this.ghost.style.borderLeftWidth=t.borderLeftWidth,this.ghost.style.borderRightWidth=t.borderRightWidth,this.ghost.style.borderTopStyle=t.borderTopStyle==="none"?"none":"solid",this.ghost.style.borderBottomStyle=t.borderBottomStyle==="none"?"none":"solid",this.ghost.style.borderLeftStyle=t.borderLeftStyle==="none"?"none":"solid",this.ghost.style.borderRightStyle=t.borderRightStyle==="none"?"none":"solid",this.ghost.style.borderColor="transparent",this.ghost.style.boxSizing=t.boxSizing,this.ghost.style.textAlign=t.textAlign,this.ghost.style.direction=t.direction;let e=t.direction==="rtl"||this.input.getAttribute("dir")==="rtl"||this.wrapper.getAttribute("dir")==="rtl";t.textAlign==="right"||t.textAlign==="end"||e&&t.textAlign!=="left"&&t.textAlign!=="center"?this.ghost.style.justifyContent="flex-end":t.textAlign==="center"?this.ghost.style.justifyContent="center":this.ghost.style.justifyContent="flex-start"}setNativeValue(t){this.nativeValueDescriptor&&this.nativeValueDescriptor.set?this.nativeValueDescriptor.set.call(this.input,t):this.input.value=t}dispatchNativeInput(){if(!(this.isDestroyed||typeof window>"u")&&this.options.emitNativeInput!==!1){this.isDispatchingNativeInput=!0;try{let t=this.input._valueTracker;t&&typeof t.setValue=="function"&&t.setValue(this.lastTrackedValue),this.lastTrackedValue=this.input.value,this.input.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))}finally{this.isDispatchingNativeInput=!1}}}hookValueProperty(){try{let t=HTMLInputElement.prototype,e=Object.getOwnPropertyDescriptor(t,"value");if(!e||!e.set||!e.get)return;this.nativeValueDescriptor=e;let s=this;Object.defineProperty(this.input,"value",{get(){return e.get.call(this)},set(o){let n=String(o??"");e.set.call(this,n),!s.isDestroyed&&s.onNativeValueSet(n)},configurable:!0})}catch{}}unhookValueProperty(){try{delete this.input.value}catch{}}setShowMaskOnFocus(t){this.options.showMaskOnFocus=t,this.wrapper.classList.toggle("mask-focus-only",t)}disabled(t){if(t===void 0)return!!this.options.disabled;this.setDisabled(t)}setDisabled(t){this.options.disabled=!!t,this.options.disabled?this.wrapper.setAttribute("data-disabled","true"):this.wrapper.removeAttribute("data-disabled"),this.onDisabledChange(this.options.disabled)}getWrapper(){return this.wrapper}getInput(){return this.input}getGhost(){return this.ghost}getElements(){return{wrapper:this.wrapper,input:this.input,ghost:this.ghost}}getValue(){return this.input.value}getRawValue(){return this.input.value}audit(){let t=[],e=this.input.ownerDocument||document,s=this.input.getAttribute("aria-label")?.trim(),o=this.checkAriaIdReferences(this.input,"aria-labelledby",t),n=!!this.input.closest("label"),a=!!(this.input.labels&&this.input.labels.length>0),r=!1;this.input.id&&typeof CSS<"u"&&typeof CSS.escape=="function"?r=!!e.querySelector(`label[for="${CSS.escape(this.input.id)}"]`):this.input.id&&(r=!!e.querySelector(`label[for="${this.input.id}"]`)),!s&&!o&&!n&&!a&&!r&&t.push(`\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`),this.checkAriaIdReferences(this.input,"aria-describedby",t);let l=this.getSpecificAuditWarnings();return t.push(...l),t}getAuditPrefix(){return`Wulf.Mask.${this.constructor.name||"InputMask"}`}getAuditTargetLabel(){return this.input.id?`#${this.input.id}`:this.input.name?`input[name="${this.input.name}"]`:"<input>"}getAuditDisableHint(){return'Passez { audit: false } ou data-mask-audit="false" pour d\xE9sactiver cet avertissement'}getSpecificAuditWarnings(){return[]}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.focusSelectTimerId!==null&&(clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.input.removeEventListener("copy",this.onBaseCopy),this.input.removeEventListener("focus",this.onBaseFocus),this.input.removeEventListener("blur",this.onBaseBlur),this.unhookValueProperty(),this.ghost&&(this.ghost.remove(),this.ghost=null),this.isWrapperCreated&&this.wrapper?(this.input.style.gridArea="",this.input.style.boxSizing="",this.wrapper.parentNode&&this.wrapper.parentNode.insertBefore(this.input,this.wrapper),this.wrapper.remove()):this.wrapper&&(this.wrapper.removeAttribute("data-mask"),this.wrapper.removeAttribute("data-disabled"),this.wrapper.classList.remove("is-complete","is-focused","mask-focus-only","has-selection","has-ghost")))}};var St={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:p=>p.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:p=>p.toUpperCase()}},R=class p{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={...St,...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 p(t,e||{}).format(i??"")}compile(i){if(i!==void 0&&(Array.isArray(i)?(this.patterns=[...i],this.pattern=this.patterns[0]||""):(this.patterns=[],this.pattern=i)),this.patterns.length>0)return this.subEngines=this.patterns.map(s=>new p(s,{placeholderChar:this.placeholderChar,tokens:this.tokens,strict:this.strict,autoLowercase:this.autoLowercase})),this.activeEngine=this.subEngines[0],this.slots=this.activeEngine.slots,this.fullMaskTemplate=this.activeEngine.fullMaskTemplate,this.prefixSlotsCount=this.activeEngine.prefixSlotsCount,this.prefixString=this.activeEngine.prefixString,this.slots;this.subEngines=[],this.activeEngine=null,this.slots=[];let t="",e=!0;for(let s=0;s<this.pattern.length;s++){let o=this.pattern[s],n=!1;o==="\\"&&s+1<this.pattern.length&&(n=!0,s++,o=this.pattern[s]);let a=n?void 0:this.tokens[o];a?(e=!1,this.slots.push({char:o,isStatic:!1,isPrefix:!1,token:a,placeholder:this.placeholderChar}),t+=this.placeholderChar):(this.slots.push({char:o,isStatic:!0,isPrefix:e,placeholder:o}),t+=o)}this.fullMaskTemplate=t,this.prefixSlotsCount=0,this.prefixString="";for(let s of this.slots)if(s.isPrefix)this.prefixSlotsCount++,this.prefixString+=s.char;else break;return this.slots}selectEngine(i){if(this.subEngines.length<=1)return this;let t=String(i??""),e=this.subEngines.filter(r=>{let l=r.getPrefix();return l.length>0&&t.toLowerCase().startsWith(l.trim().toLowerCase())}),s=e.length>0?e:this.subEngines,o=[...s].sort((r,l)=>l.getEditableCount()-r.getEditableCount())[0],a=(o?o.extractRaw(t):t).length;for(let r of s)if(r.getEditableCount()>=a)return this.activeEngine=r,r;return this.activeEngine=s[s.length-1],this.activeEngine}getPrefix(){return this.activeEngine?this.activeEngine.getPrefix():this.prefixString}getPrefixLength(){return this.activeEngine?this.activeEngine.getPrefixLength():this.prefixSlotsCount}getFullMaskTemplate(){return this.activeEngine?this.activeEngine.getFullMaskTemplate():this.fullMaskTemplate}getEditableCount(){return this.subEngines.length>0?Math.max(...this.subEngines.map(i=>i.getEditableCount())):this.activeEngine?this.activeEngine.getEditableCount():this.slots.filter(i=>!i.isStatic).length}isNumericOnly(){if(this.subEngines.length>0)return this.subEngines.every(e=>e.isNumericOnly());let t=(this.activeEngine?this.activeEngine.slots:this.slots).filter(e=>!e.isStatic);return t.length===0?!1:t.every(e=>e.char==="9"||e.token&&e.token.pattern.test("0")&&!e.token.pattern.test("a")&&!e.token.pattern.test("Z"))}setStrict(i){this.strict=i}isStrict(){return this.strict}extractRaw(i){if(this.subEngines.length>0){let n=this.selectEngine(i);if(n!==this)return n.extractRaw(i)}let t=String(i??"");if(!t)return"";let e="",s=0,o=0;if(this.prefixSlotsCount>0){for(;s<t.length&&(t[s]===" "||t[s]===" ");)s++;let n=0;for(;s<t.length&&n<this.prefixSlotsCount;){let a=this.slots[n].char,r=t[s];if(r.toUpperCase()===a.toUpperCase())s++,n++;else if(a===" "&&r!==" ")n++;else break}o=this.prefixSlotsCount}for(;s<t.length&&o<this.slots.length;){let n=this.slots[o],a=t[s];if(n.isStatic)a.toUpperCase()===n.char.toUpperCase()&&s++,o++;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,s++,o++}else this.strict?s++:(e+=this.autoLowercase?a.toLowerCase():a,s++,o++)}if(!this.strict&&s<t.length){let n=t.slice(s);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 s="",o=0;for(let n=0;n<this.slots.length;n++){let a=this.slots[n];if(a.isStatic){let r=o<e.length,l=o===0&&!!a.isPrefix,h=o>0&&o===e.length;if(r||l||h)s+=a.char;else break}else if(o<e.length){let r=e[o],l=a.token?.transform?a.token.transform(r):r;this.autoLowercase&&!a.token?.transform&&(l=l.toLowerCase()),s+=l,o++}else break}if(!this.strict&&o<e.length){let n=e.substring(o);s+=this.autoLowercase?n.toLowerCase():n}return s}getRemainingMask(i){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getRemainingMask(i):this.fullMaskTemplate?i.length>=this.fullMaskTemplate.length?i:i+this.fullMaskTemplate.substring(i.length):""}mapCursorPosition(i,t,e){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.mapCursorPosition(i,t,e);let s=this.prefixSlotsCount,o=String(i??""),n=String(e??"");if(t<=0||!n)return s;let r=this.extractRaw(o.slice(0,t)).length;if(r===0)return Math.max(s,Math.min(this.getNextEditablePosition(0),n.length));let l=0,h=n.length;for(let c=0;c<n.length&&c<this.slots.length;c++)if(!this.slots[c].isStatic&&(l++,l===r)){h=c+1;break}for(;h<n.length&&this.slots[h]&&this.slots[h].isStatic;)h++;return Math.max(s,Math.min(h,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 W=class{constructor(i){this.delegate=i}handleKeyDown(i){let t=this.delegate.getInput(),e=this.delegate.getEngine(),s=this.delegate.getHistory(),o=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}s.updateCurrentCursor(n);let r=i.key.length===1&&!i.ctrlKey&&!i.metaKey&&!i.altKey,l=a>n;if(r&&!l){let u=e.getSlots(),d=n<u.length&&u[n].isStatic&&u[n].char===i.key,m=n>0&&n-1<u.length&&u[n-1].isStatic&&u[n-1].char===i.key;if(d||m){i.preventDefault();let g=d?n:n-1,b=e.getNextEditablePosition(g+1);this.delegate.applyMask(t.value,b,!0);return}let f=-1;for(let g=n;g<u.length;g++)if(u[g].isStatic){u[g].char===i.key&&(f=g);break}if(f!==-1){i.preventDefault();let g=f-1;for(;g>=o&&!u[g].isStatic;)g--;g++;let b=f-g,v=t.value.slice(g,n);if(u.slice(g,f).every(y=>!y.token||y.token.pattern.test("0"))&&b>v.length&&v.length>0){let y=b-v.length,T="0".repeat(y)+v,k=t.value.slice(f),et=t.value.slice(0,g)+T+k,L=e.getNextEditablePosition(f+1);this.delegate.applyMask(et,L,!0);return}let E=e.getNextEditablePosition(f+1);this.delegate.applyMask(t.value,E,!0);return}}if(r&&e.isStrict()){let u=e.getEditableCount();if(u>0){let d=e.extractRaw(t.value),m=u-d.length;if(a>n){let f=e.extractRaw(t.value.slice(n,a));m=u-(d.length-f.length)}if(m<=0){i.preventDefault();return}}}if(a>n){if(i.key==="Backspace"||i.key==="Delete"){i.preventDefault();let u=t.value,d=u.slice(0,n)+u.slice(a);this.delegate.applyMask(d,Math.max(o,n));return}return}if(i.key==="ArrowLeft"&&!i.shiftKey&&n<=o){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Home"&&!i.shiftKey){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Backspace"&&n<=o){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Delete"&&n<o){i.preventDefault(),t.setSelectionRange(o,o);return}if(i.key==="Backspace"&&(i.ctrlKey||i.altKey||i.metaKey)){if(i.preventDefault(),n<=o){t.setSelectionRange(o,o);return}let u=n-1;for(;u>=o&&e.isSeparatorAt(u);)u--;for(;u>=o&&!e.isSeparatorAt(u);)u--;let d=Math.max(o,u+1),m=t.value,f=m.slice(0,d)+m.slice(n);this.delegate.applyMask(f,d);return}if(i.key==="Delete"&&(i.ctrlKey||i.altKey||i.metaKey)){i.preventDefault();let u=t.value;if(n>=u.length)return;let d=n;for(;d<u.length&&e.isSeparatorAt(d);)d++;for(;d<u.length&&!e.isSeparatorAt(d);)d++;for(;d<u.length&&e.isSeparatorAt(d);)d++;let m=d,f=u.slice(0,n)+u.slice(m);this.delegate.applyMask(f,n);return}if(i.key==="Backspace"&&n>o){if(e.isSeparatorAt(n-1)){i.preventDefault();let u=n-1;for(;u>o&&e.isSeparatorAt(u-1);)u--;if(u>o){let d=t.value,m=d.slice(0,u-1)+d.slice(n);this.delegate.applyMask(m,u-1)}else this.delegate.applyMask("",o)}return}if(i.key==="Delete"&&n<t.value.length){if(e.isSeparatorAt(n)){i.preventDefault();let u=n;for(;u<t.value.length&&e.isSeparatorAt(u);)u++;if(u<t.value.length){let d=t.value,m=d.slice(0,u)+d.slice(u+1);this.delegate.applyMask(m,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 K=class extends x{constructor(t,e,s){let o=H(t,e,s),n=o.wrapper,a=o.input,r=o.options,l=n?.getAttribute("data-mask")||a?.getAttribute("data-mask"),h=r.mask||l||"";typeof h=="string"&&h.includes("|")&&(h=h.split("|").map(y=>y.trim()));let c=r.placeholderChar||n?.getAttribute("data-mask-placeholder")||a?.getAttribute("data-mask-placeholder")||"_",u=n?.hasAttribute("data-disabled")||a?.hasAttribute("data-disabled"),d=n?.getAttribute("data-mask-strict")||a?.getAttribute("data-mask-strict"),m=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:b,...v}=r,w=b!==void 0?b:u?!0:!h||Array.isArray(h)&&h.length===0,E={...v,mask:h,placeholderChar:c,strict:r.strict??(d!==null?d!=="false":!0),autoLowercase:r.autoLowercase??m??!1,disabled:w,resetHistoryOnMaskChange:r.resetHistoryOnMaskChange??!1,inferInputMode:g,onInput:r.onInput||r.oninput,onChange:r.onChange||r.onchange,onComplete:r.onComplete||r.oncomplete};super(n,a,E);this.isComposing=!1;this.isUndoingRedoing=!1;this.isMouseDown=!1;this.isApplyingMask=!1;this.lastValue="";this.lastInternalRemainingMask="";this.isNotifying=!1;this.hasPendingNotification=!1;this.onChangeNativeHandler=()=>{};this.wasInputModeInferred=!1;this.cutTimerId=null;this.pasteTimerId=null;this.resetTimerId=null;this.history=new C,this.engine=new R(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new W({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(y,T,k)=>this.applyMask(y,T,k),undo:()=>this.undo(),redo:()=>this.redo(),enforceMinCursor:()=>this.enforceMinCursor()}),this.bindEvents(),this.lastValue=this.input.value,this.syncInitialValue(),this.runAuditWarning(this.options.audit)}getSpecificAuditWarnings(){let t=[],e=!!this.input.getAttribute("aria-describedby")?.trim(),s=!!this.input.getAttribute("placeholder")?.trim(),o=!!this.input.getAttribute("aria-placeholder")?.trim();return!e&&!s&&!o&&!this.options.disabled&&t.push("Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."),t}extractRawSnippet(t){return this.engine.extractRaw(t)}static format(t,e,s={}){return R.format(t,e,s)}onNativeValueSet(t){this.options.disabled?this.checkValueChange():this.applyMask(t,t.length)}onDisabledChange(t){t?(this.wrapper.removeAttribute("data-mask"),this.wrapper.classList.remove("is-complete","has-selection"),this.ghost&&(this.ghost.textContent=""),this.checkValueChange()):this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onClick=this.onClick.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onSelect=this.onSelect.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onScroll=this.onScroll.bind(this),this.onBeforeInput=this.onBeforeInput.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,!this.isDestroyed)if(this.options.disabled)this.checkValueChange();else{let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t)}},0)},this.onChangeNativeHandler=()=>{this.isDestroyed||this.checkValueChange()},this.input.addEventListener("beforeinput",this.onBeforeInput),this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.onKeyDown),this.input.addEventListener("paste",this.onPaste),this.input.addEventListener("focus",this.onFocus),this.input.addEventListener("blur",this.onBlur),this.input.addEventListener("click",this.onClick),this.input.addEventListener("keyup",this.onKeyUp),this.input.addEventListener("select",this.onSelect),this.input.addEventListener("mousedown",this.onMouseDown),window.addEventListener("mouseup",this.onMouseUp),this.input.addEventListener("compositionstart",this.onCompositionStart),this.input.addEventListener("compositionend",this.onCompositionEnd),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.addEventListener("change",this.onChangeNativeHandler),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled?this.checkValueChange():this.syncInitialValue())},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}syncInferredInputMode(){if(!this.options.inferInputMode)return;!this.options.disabled&&this.engine.isNumericOnly()?this.input.hasAttribute("inputmode")||(this.input.inputMode="numeric",this.wasInputModeInferred=!0):this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&(this.input.removeAttribute("inputmode"),this.wasInputModeInferred=!1)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.pasteTimerId!==null&&(clearTimeout(this.pasteTimerId),this.pasteTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("beforeinput",this.onBeforeInput),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.onKeyDown),this.input.removeEventListener("paste",this.onPaste),this.input.removeEventListener("focus",this.onFocus),this.input.removeEventListener("blur",this.onBlur),this.input.removeEventListener("click",this.onClick),this.input.removeEventListener("keyup",this.onKeyUp),this.input.removeEventListener("select",this.onSelect),this.input.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),this.input.removeEventListener("compositionstart",this.onCompositionStart),this.input.removeEventListener("compositionend",this.onCompositionEnd),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.removeEventListener("change",this.onChangeNativeHandler),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&this.input.removeAttribute("inputmode"),this.history.clear(),super.destroy())}setStrict(t){this.options.strict=t,this.engine.setStrict(t),this.options.disabled||this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}isStrict(){return this.engine.isStrict()}setMask(t,e){let s=typeof e=="boolean"?e:e&&typeof e=="object"&&e.strict!==void 0?e.strict:this.options.strict,o=e&&typeof e=="object"&&e.resetHistory!==void 0?e.resetHistory:!!this.options.resetHistoryOnMaskChange;if(!((!t||Array.isArray(t)&&t.length===0)&&this.options.disabled&&(!this.options.mask||this.options.mask===""))){if(!t||Array.isArray(t)&&t.length===0){this.options.mask="",this.options.strict=s,this.engine.setStrict(s??!0),this.engine.compile(""),o&&this.history.clear(),this.setDisabled(!0),this.syncInferredInputMode();return}this.options.mask=t,this.options.strict=s,this.engine.setStrict(s??!0),this.engine.compile(t),o&&this.history.clear(),this.setDisabled(!1),this.syncInferredInputMode()}}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask"){let e=this.getAttr("data-mask");if(e===this.lastInternalRemainingMask)return;let s=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(e===s)return;if(e){let o=e.includes("|")?e.split("|").map(n=>n.trim()):e;this.setMask(o)}else this.setMask(null)}else if(t==="data-mask-strict"){let e=this.getAttr("data-mask-strict");this.setStrict(e!=="false")}else t==="data-mask-auto-lowercase"?(this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true",this.engine.compile(this.options.mask||""),this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)):t==="placeholder"&&this.updateGhost(this.input.value)}setValue(t){let e=t!=null?String(t):"";if(this.options.disabled){this.input.value=e,this.checkValueChange();return}this.applyMask(e,e.length)}getRawValue(){return this.engine.extractRaw(this.input.value)}isComplete(){return this.options.disabled?!0:this.getRawValue().length>=this.engine.getEditableCount()}get onInput(){return this.options.onInput}set onInput(t){this.options.onInput=t}undo(){if(this.options.disabled)return;let t=this.history.undo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}redo(){if(this.options.disabled)return;let t=this.history.redo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}checkSelection(){if(this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,s=t!==e;this.wrapper.classList.toggle("has-selection",s)}onBeforeInput(t){if(!this.options.disabled&&!this.isComposing&&this.engine.isStrict()&&t.inputType!=="insertFromPaste"&&t.inputType&&t.inputType.startsWith("insert")){let e=this.engine.getEditableCount();if(e>0){let s=this.getRawValue(),o=this.input.selectionStart??0,n=this.input.selectionEnd??o,a=Math.max(0,e-s.length);if(n>o){let r=this.engine.extractRaw(this.input.value.slice(o,n));a=Math.max(0,e-(s.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 s=this.history.getCurrent(),o=this.engine.getEditableCount();if(o>0&&this.engine.isStrict()&&s&&s.raw.length>=o&&this.engine.extractRaw(this.input.value).length>o){this.applyMask(s.raw,s.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 s=(t.clipboardData?.getData("text")||"").trim();if(!s)return;let o=this.engine.getPrefixLength(),n=this.input.selectionStart??0,a=this.input.selectionEnd??n,r=this.input.value,l=this.engine.getEditableCount(),h=this.getRawValue(),u=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),d=s.replace(/[\s.-]+/g,"").toUpperCase(),m=u.length>0&&d.startsWith(u),f=r.slice(0,Math.max(o,n)).replace(/[\s.-]+/g,"").toUpperCase(),g=f.length>=2&&d.startsWith(f),b=Math.max(o,n),v=Math.max(o,a);(m||g)&&(b=0,v=r.length);let w=Math.max(0,l-h.length);if(b!==v){let T=this.engine.extractRaw(r.slice(b,v));w=Math.max(0,l-(h.length-T.length))}if(this.engine.isStrict()&&w<=0)return;let E,y;b===0&&v===r.length?(E=s,y=s.length):(E=r.slice(0,b)+s+r.slice(v),y=b+s.length),this.applyMask(E,y),this.checkSelection()}onFocus(){this.syncGhostStyles(),this.wrapper.classList.add("is-focused"),!this.options.disabled&&!this.isMouseDown&&this.enforceMinCursor(),this.updateGhost(this.input.value),this.checkSelection()}onBlur(){this.wrapper.classList.remove("is-focused","has-selection"),this.input.type==="password"&&this.history.clear(),this.updateGhost(this.input.value)}onClick(){this.options.disabled||this.enforceMinCursor(),this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onKeyUp(t){this.options.disabled||this.keyboard.handleKeyUp(t),this.checkSelection()}onSelect(){this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t),this.checkSelection()}enforceMinCursor(){let t=this.engine.getPrefixLength();if(t<=0)return;let e=this.input.selectionStart??0,s=this.input.selectionEnd??e;e===s&&e<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled){this.ghost.textContent="";return}let e=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(e)){this.ghost.textContent="";return}let s=this.engine.getFullMaskTemplate(),o=s.length>t.length?s.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=o,this.ghost.appendChild(n),this.ghost.appendChild(a),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,s=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let o="",n=!1;try{o=this.engine.format(t);let a=this.engine.getRemainingMask(o);this.input.value=o,this.lastInternalRemainingMask=a,this.wrapper.setAttribute("data-mask",a),this.updateGhost(o);let r=this.engine.getPrefixLength(),l;if(s||this.isUndoingRedoing)l=Math.max(r,Math.min(e,o.length));else{let h=this.engine.mapCursorPosition(t,e,o);l=Math.max(r,h)}this.input.setSelectionRange(l,l),n=this.isComplete(),this.wrapper.classList.toggle("is-complete",n),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(this.getRawValue(),l)}finally{this.isApplyingMask=!1}this.checkValueChange()}syncInitialValue(){if(this.options.disabled){this.wrapper.removeAttribute("data-mask"),this.ghost&&(this.ghost.textContent=""),this.lastValue=this.input.value,this.checkValueChange();return}this.syncGhostStyles();let t=this.input.value||"";if(t)this.applyMask(t,t.length);else{let e=this.engine.getPrefixLength();if(e>0)this.applyMask("",e);else{this.input.type!=="password"&&this.history.push("",0);let s=this.engine.getFullMaskTemplate();this.lastInternalRemainingMask=s,this.wrapper.setAttribute("data-mask",s),this.updateGhost(""),this.checkValueChange()}}}checkValueChange(t=!1){if(!(this.input.value===this.lastValue&&!t&&!this.hasPendingNotification)){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{for(;this.input.value!==this.lastValue||this.hasPendingNotification||t;){this.hasPendingNotification=!1,t=!1;let s=this.input.value;this.lastValue=s;let o=this.options.disabled?s:this.getRawValue(),n=this.options.disabled?0:this.engine.getEditableCount(),a=this.isComplete(),r={value:s,rawValue:o,isComplete:a,totalSlots:n,filledSlots:this.options.disabled?s.length:o.length},l=this.options.onInput||this.options.oninput;l&&l(s,r),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:r})),this.dispatchNativeInput();let h=this.options.onChange||this.options.onchange;h&&h(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 P=class p{constructor(i={}){let t=i.currency??"";!t&&i.unit&&(t=i.unit);let e=t==="$"||t==="\xA3"||t==="\xA5"?"prefix":"suffix";this.options={currency:t,unit:i.unit??t,currencyPosition:i.currencyPosition??e,decimals:i.decimals!==void 0?Math.max(0,i.decimals):2,decimalSeparator:i.decimalSeparator??",",thousandSeparator:i.thousandSeparator??"\xA0",allowNegative:i.allowNegative??!1,min:i.min??-1/0,max:i.max??1/0}}parse(i){let t=i.trim(),e=!1;this.options.allowNegative&&t.includes("-")&&(e=!0),this.options.currency&&(t=t.replace(new RegExp(this.escapeRegExp(this.options.currency),"g"),"")),this.options.thousandSeparator&&(t=t.replace(new RegExp(this.escapeRegExp(this.options.thousandSeparator),"g"),"")),t=t.replace(/[\s\u00A0]/g,"");let s=this.options.decimalSeparator,o=t.indexOf(s);o===-1&&(o=t.search(/[,.]/));let n="",a=null,r=!1;return o!==-1?(n=t.substring(0,o).replace(/\D/g,""),this.options.decimals>0&&(r=!0,a=t.substring(o+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 s=i.substring(0,t),o=s.replace(/\D/g,"").length,n=this.options.decimals>0&&/[,.]/.test(s),{isNegative:a,integerPart:r,decimalPart:l,hasDecimal:h}=this.parse(i),c=l,u=h;if(e&&this.options.decimals>0&&(r||l!==null)&&(u=!0,c===null?c="0".repeat(this.options.decimals):c.length<this.options.decimals&&(c=c+"0".repeat(this.options.decimals-c.length))),a&&!r&&!c&&!u&&this.options.allowNegative){let L="-",O=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(L=`${this.options.currency} -`,O=L.length):(L=`- ${this.options.currency}`,O=1)),{formatted:L,rawNumber:null,rawValue:"-",cursor:O,isValid:!0}}if(!r&&!c&&!u)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let m=(r||"0").replace(/\B(?=(\d{3})+(?!\d))/g,this.options.thousandSeparator);u&&this.options.decimals>0&&(m+=this.options.decimalSeparator+(c??"")),a&&m!=="0"&&(m="-"+m);let f=m;this.options.currency&&(this.options.currencyPosition==="prefix"?f=`${this.options.currency} ${m}`:f=`${m} ${this.options.currency}`);let g=(a?"-":"")+(r||"0")+(l?"."+l:""),b=parseFloat(g);isNaN(b)&&(b=0);let v=b>=this.options.min&&b<=this.options.max,w=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(w=this.options.currency.length+1);let E=0,y=!1,T=w;for(let L=w;L<f.length;L++){let O=f[L];if(O===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(O)?(E++,T=L+1):O===this.options.decimalSeparator&&(y=!0,T=L+1),n){if(y&&E>=o){w=L+1;break}}else if(E>=o){w=L+1;break}}o>0&&E<o&&T>w&&(w=T);let k=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,et=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,f.length-this.options.currency.length-1):f.length;return w=Math.max(k,Math.min(w,Math.max(k,et))),{formatted:f,rawNumber:b,rawValue:g,cursor:w,isValid:v}}static format(i,t={}){let e=new p(t),s=typeof i=="number"?i.toString():i;return e.format(s).formatted}escapeRegExp(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var q=class extends x{constructor(t,e,s){let o=H(t,e,s),n=o.wrapper,a=o.input,r=o.options,l=n?.getAttribute("data-mask-pad-decimals")==="true"||a?.getAttribute("data-mask-pad-decimals")==="true",h=a?.getAttribute("data-mask-align")||a?.getAttribute("data-align")||n?.getAttribute("data-mask-align")||n?.getAttribute("data-align"),c={align:r.align??h??"right",padDecimalsOnBlur:r.padDecimalsOnBlur??l??!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 P(this.options),this.bindEvents(),this.input.value?this.options.disabled||this.applyAmount(this.input.value,this.input.value.length):this.updateGhost({formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0}),this.runAuditWarning(this.options.audit)}extractRawSnippet(t){let e=this.engine.parse(t);return!e.integerPart&&!e.decimalPart?"":(e.isNegative?"-":"")+(e.integerPart||"0")+(e.decimalPart?"."+e.decimalPart:"")}static format(t,e={}){return P.format(t,e)}onNativeValueSet(t){if(this.options.disabled||this.isComposing){this.lastValue=t;return}this.applyAmount(t,t.length)}onDisabledChange(t){t||this.applyAmount(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleClick=this.handleClick.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,this.isDestroyed||this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)},0)},this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("click",this.handleClick),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.addEventListener("compositionstart",this.onCompositionStart),this.input.addEventListener("compositionend",this.onCompositionEnd),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled||this.applyAmount(this.input.value,this.input.value.length))},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)}applyAmount(t,e){if(!(this.isApplying||this.options.disabled)){this.isApplying=!0;try{let s=this.engine.format(t,e);this.setNativeValue(s.formatted),this.input.setSelectionRange(s.cursor,s.cursor),!this.isUndoingRedoing&&this.input.type!=="password"&&this.history.push(s.rawValue,s.cursor),this.updateGhost(s),this.lastValue!==s.formatted&&(this.lastValue=s.formatted,this.notifyChange(s))}finally{this.isApplying=!1}}}updateGhost(t){if(this.ghost){if(!t.formatted){if(this.shouldHideGhostForPlaceholder(!0)){this.ghost.textContent="";return}let e=this.options.currency?this.options.currencyPosition==="prefix"?`${this.options.currency} 0`:`0 ${this.options.currency}`:"0,00";this.ghost.textContent="";let s=document.createElement("span");s.className="mask-ghost-remaining",s.textContent=e,this.ghost.appendChild(s);return}this.ghost.textContent="",this.ghost.scrollLeft=this.input.scrollLeft}}handleInput(){if(this.isDispatchingNativeInput||this.options.disabled||this.isComposing)return;let t=this.input.value,e=this.input.selectionStart??t.length;this.applyAmount(t,e)}handleKeyDown(t){if(!this.options.disabled){if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")){t.preventDefault(),t.shiftKey?this.redo():this.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")){t.preventDefault(),this.redo();return}if(t.key==="Backspace"){let e=this.input.selectionStart??0,s=this.input.selectionEnd??0;if(e===s&&e>0){let o=this.input.value,n=o[e-1];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let a=Math.max(0,e-2),r=o.slice(0,a)+o.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,s=this.input.selectionEnd??0;if(e===s&&e<this.input.value.length){let o=this.input.value,n=o[e];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let a=o.slice(0,e)+o.slice(e+2);this.applyAmount(a,e);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let a=o.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 s=this.input.value,o=this.options.currency;if(o){if(this.options.currencyPosition==="prefix"){let n=o.length+1;t<n&&this.input.setSelectionRange(n,n)}else if(this.options.currencyPosition==="suffix"){let n=Math.max(0,s.length-o.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 U=class U{constructor(i={}){this.defaultDomain=null;this.defaultTld="__";this.domains=i.domains&&i.domains.length>0?i.domains:U.DEFAULT_DOMAINS,this.tlds=i.tlds&&i.tlds.length>0?i.tlds.map(t=>t.trim().replace(/^\./,"")).filter(Boolean):[...U.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):[...U.DEFAULT_TLDS]}getMatchingTlds(i){let t=(i??"").toLowerCase();return t.length===0?[...this.tlds]:this.tlds.filter(e=>e.toLowerCase().startsWith(t)&&e.toLowerCase()!==t)}getMatchingDomains(i){let t=i??"";if(!t.includes("@"))return this.defaultDomain?[this.defaultDomain]:[];let e=t.indexOf("@");if(t.indexOf("@",e+1)!==-1)return[];let s=t.substring(e+1);if(s.length===0)return this.suggestOnAt?[...this.domains]:[];let o=s.toLowerCase();return this.domains.filter(n=>n.toLowerCase().startsWith(o)&&n.toLowerCase()!==o)}getSuggestion(i,t=0){let e=i??"";if(!e.includes("@"))return this.defaultDomain?{full:e?`${e}@${this.defaultDomain}`:`@${this.defaultDomain}`,remaining:`@${this.defaultDomain}`,matchedDomain:this.defaultDomain,isHintOnly:!1}:{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let s=e.indexOf("@"),o=e.substring(0,s),n=e.substring(s+1);if(e.indexOf("@",s+1)!==-1)return{full:e,remaining:"",matchedDomain:null,isHintOnly:!1};let a=this.getMatchingDomains(i);if(a.length>0){let m=(t%a.length+a.length)%a.length,f=a[m],g=n.toLowerCase(),b=f.substring(g.length);return{full:`${o}@${f}`,remaining:b,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(m=>m.toLowerCase()===r))return{full:i,remaining:"",matchedDomain:n,isHintOnly:!1};let l=n.lastIndexOf(".");if(l===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let m=this.defaultTld.includes("_"),f=`.${this.defaultTld}`,g=`${n}.${this.defaultTld}`;return{full:m?i:`${o}@${g}`,remaining:f,matchedDomain:m?null:g,isHintOnly:m}}let h=n.substring(0,l),c=n.substring(l+1);if(!h||h.endsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};if(c.length===0){if(this.defaultTld&&!this.defaultTld.includes("_")){let m=`${h}.${this.defaultTld}`;return{full:`${o}@${m}`,remaining:this.defaultTld,matchedDomain:m,isHintOnly:!1}}return this.defaultTld&&this.defaultTld.includes("_")?{full:i,remaining:this.defaultTld,matchedDomain:null,isHintOnly:!0}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}let u=c.toLowerCase(),d=this.getMatchingTlds(c);if(d.length>0){let m=(t%d.length+d.length)%d.length,f=d[m],g=f.substring(u.length),b=`${h}.${f}`;return{full:`${o}@${b}`,remaining:g,matchedDomain:b,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&c.length<this.defaultTld.length){let m=this.defaultTld.substring(c.length);if(m.includes("_"))return{full:i,remaining:m,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};U.DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"],U.DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];var V=U;var j=class extends x{constructor(t,e,s){let o=H(t,e,s),n=o.wrapper,a=o.input,r=o.options,l=n?.getAttribute("data-mask-cycle-suggestions")==="true"||a?.getAttribute("data-mask-cycle-suggestions")==="true",h=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"),u=r.setAriaAutocomplete??(c!==null?c!=="false":!0),d=n?.getAttribute("data-mask-tlds")??a?.getAttribute("data-mask-tlds"),m=r.tlds??(d?d.split(",").map(v=>v.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,b={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:r.cycleSuggestions??l??!1,autoLowercase:r.autoLowercase??h??!1,setAriaAutocomplete:u,...r,...m!==void 0?{tlds:m}:{},...g!==void 0?{defaultTld:g}:{}};super(n,a,b);this.currentSuggestion={full:"",remaining:"",matchedDomain:null};this.currentSuggestionIndex=0;this.wasAriaAutocompleteSet=!1;this.cutTimerId=null;this.resetTimerId=null;this.input.inputMode="email",this.options.setAriaAutocomplete&&!this.input.hasAttribute("aria-autocomplete")&&(this.input.setAttribute("aria-autocomplete","inline"),this.wasAriaAutocompleteSet=!0),this.engine=new V(this.options),this.bindEvents(),this.options.disabled||this.updateSuggestion(),this.runAuditWarning(this.options.audit)}onNativeValueSet(t){this.options.disabled||this.updateSuggestion()}onDisabledChange(t){t?this.ghost&&(this.ghost.textContent=""):this.updateSuggestion()}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{this.cutTimerId=null,!(this.isDestroyed||this.options.disabled)&&this.updateSuggestion()},0)},this.input.addEventListener("input",this.handleInput),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("scroll",this.onScroll),this.input.addEventListener("cut",this.onCutHandler),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!(this.isDestroyed||this.options.disabled)&&this.updateSuggestion()},0)},this.input.form.addEventListener("reset",this.onFormResetHandler))}updateSuggestion(){if(this.options.disabled){this.ghost&&(this.ghost.textContent="");return}let t=this.input.value;if(this.currentSuggestion=this.engine.getSuggestion(t,this.currentSuggestionIndex),!this.ghost)return;if(this.shouldHideGhostForPlaceholder(t.length===0))this.ghost.textContent="";else if(this.currentSuggestion.remaining){this.ghost.textContent="";let s=document.createElement("span");s.className="mask-ghost-typed",s.textContent=t;let o=document.createElement("span");o.className="mask-ghost-remaining",o.textContent=this.currentSuggestion.remaining,this.ghost.appendChild(s),this.ghost.appendChild(o)}else this.ghost.textContent="";this.ghost.scrollLeft=this.input.scrollLeft;let e=this.getDetail();this.options.onInput&&this.options.onInput(e),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:e})),this.dispatchNativeInput()}handleInput(){if(!this.isDispatchingNativeInput&&!this.options.disabled){if(this.options.autoLowercase){let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,s=this.input.value.toLowerCase();s!==this.input.value&&(this.setNativeValue(s),this.input.setSelectionRange(t,e))}this.currentSuggestionIndex=0,this.updateSuggestion()}}handleKeyDown(t){if(this.options.disabled)return;let e=!!this.currentSuggestion.remaining&&!this.currentSuggestion.isHintOnly,o=(this.input.selectionStart??0)===this.input.value.length,n=this.input.value.length>0;if(this.options.cycleSuggestions&&e&&n&&o){if(t.key==="ArrowDown"){t.preventDefault(),this.currentSuggestionIndex++,this.updateSuggestion();return}if(t.key==="ArrowUp"){t.preventDefault(),this.currentSuggestionIndex--,this.updateSuggestion();return}}if(t.key==="Tab"&&e&&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&&o&&this.options.completeOnArrowRight){t.preventDefault(),this.acceptSuggestion();return}}acceptSuggestion(){if(!this.currentSuggestion.remaining||this.currentSuggestion.isHintOnly||this.options.disabled||this.input.value.length===0)return!1;let t=this.currentSuggestion.full;this.setNativeValue(t),this.input.setSelectionRange(t.length,t.length),this.currentSuggestionIndex=0,this.updateSuggestion();let e=this.getDetail();return this.options.onChange&&this.options.onChange(e),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:e})),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:e})),!0}setDefaultDomain(t){this.engine.setDefaultDomain(t),this.updateSuggestion()}setDefaultTld(t){this.engine.setDefaultTld(t),this.updateSuggestion()}setTlds(t){this.engine.setTlds(t),this.currentSuggestionIndex=0,this.updateSuggestion()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.updateSuggestion()}handleBlur(){this.wrapper.classList.remove("is-focused"),this.updateSuggestion();let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask-cycle-suggestions")this.options.cycleSuggestions=this.getAttr("data-mask-cycle-suggestions")==="true";else if(t==="data-mask-auto-lowercase")this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true";else if(t==="data-mask-default-tld"){let e=this.getAttr("data-mask-default-tld");this.setDefaultTld(e===null||e==="false"||e==="none"?null:e==="true"?!0:e)}else if(t==="data-mask-tlds"){let e=this.getAttr("data-mask-tlds");this.setTlds(e?e.split(",").map(s=>s.trim()).filter(Boolean):null)}else t==="placeholder"&&this.updateSuggestion()}getDetail(){return{value:this.input.value,suggestedValue:this.currentSuggestion.isHintOnly?"":this.currentSuggestion.full,domain:this.currentSuggestion.matchedDomain}}setValue(t){let e=t!=null?String(t):"";this.setNativeValue(e),this.updateSuggestion()}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("blur",this.handleBlur),this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("scroll",this.onScroll),this.input.removeEventListener("cut",this.onCutHandler),this.input.form&&this.onFormResetHandler&&this.input.form.removeEventListener("reset",this.onFormResetHandler),this.wasAriaAutocompleteSet&&this.input.getAttribute("aria-autocomplete")==="inline"&&this.input.removeAttribute("aria-autocomplete"),super.destroy())}};var yt={BaseInputMask:x,InputMask:K,MaskEngine:R,MaskHistory:C,MaskKeyboard:W,AmountEngine:P,InputAmountMask:q,EmailEngine:V,InputEmailMask:j};if(typeof window<"u"){let p=window,i=p.Wulf||{};p.Wulf=i,i.Mask=yt}var at=K;var ct={};_(ct,{LocalizedComponent:()=>S,Scroll:()=>Tt,ScrollBlock:()=>z,createI18nManager:()=>D,default:()=>It,scrollEn:()=>ht,scrollFr:()=>ut,scrollI18n:()=>J});var S=class extends I{static setLocale(i){this._i18n&&this._i18n.setLocale(i)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(i,t){this._i18n&&this._i18n.registerLocale(i,t)}static setI18n(i){this._i18n&&this._i18n.setI18n(i)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(i,t){return this._i18n?this._i18n.t(i,t):String(i)}constructor(i){super(),this.i18nOverrides=i}t(i){let t=this.constructor;return t._i18n?t._i18n.t(i,this.i18nOverrides):String(i)}};function ot(p){return p.trim().toLowerCase().replace(/_/g,"-")}function xt(p){let i=p.indexOf("-");return i>0?p.slice(0,i):null}function Z(p,i){if(!i)return p;for(let t of Object.keys(i))i[t]!==void 0&&(p[t]=i[t]);return p}function D(p,i){let t=ot(p),e={};for(let[r,l]of Object.entries(i))e[ot(r)]={...l};let s=t,o={...e},n={};function a(){let r=[],l=o[s];l&&r.push(l);let h=xt(s);return h&&o[h]&&r.push(o[h]),r}return{setLocale(r){r&&r.trim()&&(s=ot(r))},getLocale(){return s},registerLocale(r,l){if(!r||!r.trim()||!l)return;let h=ot(r);o[h]=Z({...o[h]||{}},l)},setI18n(r){r&&(n=Z({...n},r))},t(r,l){if(l&&l[r]!==void 0)return String(l[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 h=o[t]||e[t];return h&&h[r]!==void 0?String(h[r]):String(r)},getAll(r){let l={},h=o[t]||e[t];Z(l,h);let c=a().reverse();for(let u of c)Z(l,u);return Z(l,n),Z(l,r),l},reset(){s=t,n={},o={};for(let[r,l]of Object.entries(e))o[r]={...l}}}}var ut={viewport:"Zone de contenu d\xE9filable",verticalThumb:"D\xE9filement vertical",horizontalThumb:"D\xE9filement horizontal"};var ht={viewport:"Scrollable content area",verticalThumb:"Vertical scroll",horizontalThumb:"Horizontal scroll"};var J=D("fr",{fr:ut,en:ht});var wt=0,z=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 s=typeof t=="string"?document.querySelector(t):t;if(!s)throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${t}".`);this.root=s,this.hasExplicitAriaLabel=!!(e?.ariaLabel||e?.i18n?.viewport),this.options={axis:e?.axis||"y",autoHide:e?.autoHide??!0,autoHideDelay:e?.autoHideDelay??1e3,alwaysVisible:e?.alwaysVisible??!1,ariaLabel:e?.ariaLabel||this.t("viewport"),i18n:e?.i18n||{},minThumbSize:e?.minThumbSize??24,edgeThreshold:e?.edgeThreshold??10,onScroll:e?.onScroll||(()=>{}),onTotalScroll:e?.onTotalScroll||(()=>{}),onTotalScrollBack:e?.onTotalScrollBack||(()=>{}),audit:e?.audit??!0},this.boundOnScroll=this.handleScroll.bind(this),this.boundOnMouseEnter=this.handleMouseEnter.bind(this),this.boundOnMouseLeave=this.handleMouseLeave.bind(this),this.boundOnFocusIn=this.handleFocusIn.bind(this),this.boundOnFocusOut=this.handleFocusOut.bind(this),this.boundPointerMove=this.handlePointerMove.bind(this),this.boundPointerUp=this.handlePointerUp.bind(this),this.viewport=this.setupViewport(),this.setupAccessibility(),this.setupScrollbars(),this.setupEventListeners(),this.setupObserver(),this.update(),this.runAuditWarning(this.options.audit)}setupViewport(){this.root.classList.add("wulf-scrollblock"),this.options.alwaysVisible&&this.root.classList.add("is-always-visible"),this.options.axis==="both"&&this.root.classList.add("has-both-axes");let t=this.root.querySelector(":scope > .wulf-scrollblock-viewport");if(t)return t;let e=document.createElement("div");for(e.className="wulf-scrollblock-viewport";this.root.firstChild;)e.appendChild(this.root.firstChild);return this.root.appendChild(e),this.createdViewport=!0,e}setupAccessibility(){if(this.viewport.id||(wt+=1,this.viewport.id=`wulf-scrollblock-vp-${wt}`,this.wasIdGenerated=!0),this.viewport.hasAttribute("role")||(this.viewport.setAttribute("role","region"),this.wasRoleInferred=!0),!this.viewport.hasAttribute("aria-label")){let t=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("viewport");this.viewport.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.wasAriaLabelInferred=!0}}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel){let e=this.t("viewport");this.viewport.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.options.ariaLabel=e}this.thumbY&&this.thumbY.setAttribute("aria-label",this.t("verticalThumb")),this.thumbX&&this.thumbX.setAttribute("aria-label",this.t("horizontalThumb"))}setupScrollbars(){(this.options.axis==="y"||this.options.axis==="both")&&(this.trackY=document.createElement("div"),this.trackY.className="wulf-scrollblock-track wulf-scrollblock-vertical",this.trackY.setAttribute("aria-hidden","true"),this.thumbY=document.createElement("div"),this.thumbY.className="wulf-scrollblock-thumb",this.thumbY.setAttribute("role","scrollbar"),this.thumbY.setAttribute("aria-orientation","vertical"),this.thumbY.setAttribute("aria-controls",this.viewport.id),this.thumbY.setAttribute("aria-valuenow","0"),this.thumbY.setAttribute("aria-valuemin","0"),this.thumbY.setAttribute("aria-valuemax","100"),this.thumbY.setAttribute("aria-label",this.t("verticalThumb")),this.trackY.appendChild(this.thumbY),this.root.appendChild(this.trackY),this.attachTrackListeners(this.trackY,this.thumbY,"y")),(this.options.axis==="x"||this.options.axis==="both")&&(this.trackX=document.createElement("div"),this.trackX.className="wulf-scrollblock-track wulf-scrollblock-horizontal",this.trackX.setAttribute("aria-hidden","true"),this.thumbX=document.createElement("div"),this.thumbX.className="wulf-scrollblock-thumb",this.thumbX.setAttribute("role","scrollbar"),this.thumbX.setAttribute("aria-orientation","horizontal"),this.thumbX.setAttribute("aria-controls",this.viewport.id),this.thumbX.setAttribute("aria-valuenow","0"),this.thumbX.setAttribute("aria-valuemin","0"),this.thumbX.setAttribute("aria-valuemax","100"),this.thumbX.setAttribute("aria-label",this.t("horizontalThumb")),this.trackX.appendChild(this.thumbX),this.root.appendChild(this.trackX),this.attachTrackListeners(this.trackX,this.thumbX,"x"))}attachTrackListeners(t,e,s){e.addEventListener("pointerdown",o=>{o.preventDefault(),o.stopPropagation(),this.isDragging=!0,this.dragAxis=s,this.dragPointerId=o.pointerId,this.dragStartPos=s==="y"?o.clientY:o.clientX,this.dragStartScroll=s==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,e.setPointerCapture(o.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",o=>{if(o.target===e)return;o.preventDefault();let n=t.getBoundingClientRect(),a=s==="y"?o.clientY-n.top:o.clientX-n.left,r=s==="y"?n.height:n.width,l=s==="y"?this.viewport.clientHeight:this.viewport.clientWidth,h=s==="y"?this.viewport.scrollHeight:this.viewport.scrollWidth,u=a/r*(h-l);this.scrollTo(s==="y"?{top:u}:{left:u},{smooth:!0})})}setupEventListeners(){this.viewport.addEventListener("scroll",this.boundOnScroll,{passive:!0}),this.options.autoHide&&!this.options.alwaysVisible&&(this.root.addEventListener("mouseenter",this.boundOnMouseEnter),this.root.addEventListener("mouseleave",this.boundOnMouseLeave),this.root.addEventListener("focusin",this.boundOnFocusIn),this.root.addEventListener("focusout",this.boundOnFocusOut))}setupObserver(){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{window.requestAnimationFrame(()=>this.update())}),this.resizeObserver.observe(this.root),this.resizeObserver.observe(this.viewport),this.viewport.firstElementChild&&this.resizeObserver.observe(this.viewport.firstElementChild))}handlePointerMove(t){if(!this.isDragging||!this.dragAxis)return;let e=this.dragAxis==="y",s=(e?t.clientY:t.clientX)-this.dragStartPos,o=e?this.trackY:this.trackX,n=e?this.thumbY:this.thumbX;if(!o||!n)return;let a=e?o.clientHeight:o.clientWidth,r=e?n.clientHeight:n.clientWidth,l=e?this.viewport.clientHeight:this.viewport.clientWidth,c=(e?this.viewport.scrollHeight:this.viewport.scrollWidth)-l,u=a-r;if(u<=0||c<=0)return;let d=c/u,m=this.dragStartScroll+s*d;e?this.viewport.scrollTop=Math.max(0,Math.min(c,m)):this.viewport.scrollLeft=Math.max(0,Math.min(c,m))}handlePointerUp(t){if(this.isDragging){if(this.dragPointerId!==void 0){let e=this.dragAxis==="y"?this.thumbY:this.thumbX;e&&e.hasPointerCapture(this.dragPointerId)&&e.releasePointerCapture(this.dragPointerId)}window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.isDragging=!1,this.dragAxis=void 0,this.dragPointerId=void 0,this.thumbY?.classList.remove("is-active"),this.thumbX?.classList.remove("is-active"),this.root.classList.remove("is-dragging"),this.scheduleAutoHide()}}handleScroll(){this.syncThumbs();let{scrollTop:t,scrollLeft:e,scrollHeight:s,scrollWidth:o,clientHeight:n,clientWidth:a}=this.viewport,r=Math.max(0,s-n),l=Math.max(0,o-a),h=r>0?t/r:0,c=l>0?e/l:0;this.options.onScroll({top:t,left:e,maxTop:r,maxLeft:l,progressY:Math.round(h*100),progressX:Math.round(c*100)});let u=this.options.edgeThreshold;if(r>0){let d=t>=r-u,m=t<=u;d&&!this.atBottom&&this.options.onTotalScroll("bottom"),m&&!this.atTop&&this.options.onTotalScrollBack("top"),this.atBottom=d,this.atTop=m}if(l>0){let d=e>=l-u,m=e<=u;d&&!this.atRight&&this.options.onTotalScroll("right"),m&&!this.atLeft&&this.options.onTotalScrollBack("left"),this.atRight=d,this.atLeft=m}this.options.autoHide&&!this.options.alwaysVisible&&(this.root.classList.add("is-scrolling"),this.scheduleAutoHide())}syncThumbs(){let{scrollTop:t,scrollLeft:e,scrollHeight:s,scrollWidth:o,clientHeight:n,clientWidth:a}=this.viewport;if(this.thumbY&&this.trackY){let r=s-n,l=this.trackY.clientHeight,h=this.thumbY.clientHeight,c=l-h;if(r>0&&c>0){let u=t/r,d=Math.max(0,Math.min(c,u*c));this.thumbY.style.transform=`translate3d(0, ${d}px, 0)`,this.thumbY.setAttribute("aria-valuenow",String(Math.round(u*100)))}}if(this.thumbX&&this.trackX){let r=o-a,l=this.trackX.clientWidth,h=this.thumbX.clientWidth,c=l-h;if(r>0&&c>0){let u=e/r,d=Math.max(0,Math.min(c,u*c));this.thumbX.style.transform=`translate3d(${d}px, 0, 0)`,this.thumbX.setAttribute("aria-valuenow",String(Math.round(u*100)))}}}handleMouseEnter(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleMouseLeave(){this.scheduleAutoHide()}handleFocusIn(){this.root.classList.add("is-visible"),this.clearAutoHideTimer()}handleFocusOut(){this.scheduleAutoHide()}clearAutoHideTimer(){this.hideTimer&&(window.clearTimeout(this.hideTimer),this.hideTimer=void 0)}scheduleAutoHide(){this.options.alwaysVisible||!this.options.autoHide||this.isDragging||(this.clearAutoHideTimer(),this.hideTimer=window.setTimeout(()=>{this.root.classList.remove("is-scrolling"),this.root.classList.remove("is-visible")},this.options.autoHideDelay))}update(){this.syncAccessibilityLabels();let{scrollHeight:t,clientHeight:e,scrollWidth:s,clientWidth:o}=this.viewport,n=t>e,a=s>o;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,l=Math.max(this.options.minThumbSize,r*(e/t));this.thumbY.style.height=`${l}px`}if(this.trackX&&this.thumbX&&a){let r=this.trackX.clientWidth,l=Math.max(this.options.minThumbSize,r*(o/s));this.thumbX.style.width=`${l}px`}this.syncThumbs()}scrollTo(t,e){let s=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,o=typeof t=="object"&&t!==null&&!(t instanceof HTMLElement)?t.smooth:void 0,a=(e?.smooth??o??!0)&&!s?"smooth":"auto",r=Math.max(0,this.viewport.scrollHeight-this.viewport.clientHeight),l=Math.max(0,this.viewport.scrollWidth-this.viewport.clientWidth),h,c;if(typeof t=="number")h=t;else if(typeof t=="string")switch(t){case"top":h=0;break;case"bottom":h=r;break;case"left":c=0;break;case"right":c=l;break;default:{if(/^-?\d+(\.\d+)?%$/.test(t.trim())){let d=Math.max(0,Math.min(100,parseFloat(t.trim())))/100;this.options.axis==="x"?c=l*d:this.options.axis==="both"?(h=r*d,c=l*d):h=r*d;break}let u=null;try{u=this.viewport.querySelector(t)}catch{u=null}u&&(h=u.offsetTop,c=u.offsetLeft);break}}else t instanceof HTMLElement?(h=t.offsetTop,c=t.offsetLeft):typeof t=="object"&&(h=t.top,c=t.left);this.viewport.scrollTo({top:h!==void 0?Math.max(0,Math.min(r,h)):void 0,left:c!==void 0?Math.max(0,Math.min(l,c)):void 0,behavior:a})}audit(){let t=[],e=this.checkAriaIdReferences(this.viewport,"aria-labelledby",t),s=this.checkAriaIdReferences(this.root,"aria-labelledby",t),o=e||s,n=this.root.getAttribute("aria-label")?.trim(),a=!this.wasAriaLabelInferred&&!!this.viewport.getAttribute("aria-label")?.trim();return!this.hasExplicitAriaLabel&&!a&&!n&&!o&&t.push("Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour d\xE9crire la zone d\xE9filable (WCAG 4.1.2)."),this.options.minThumbSize<24&&t.push(`Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`),t}getAuditPrefix(){return"Wulf.Scroll"}getAuditTargetLabel(){return this.root.id?`#${this.root.id}`:`<${this.root.tagName.toLowerCase()}.wulf-scrollblock>`}destroy(){if(this.clearAutoHideTimer(),this.resizeObserver&&this.resizeObserver.disconnect(),this.viewport.removeEventListener("scroll",this.boundOnScroll),this.root.removeEventListener("mouseenter",this.boundOnMouseEnter),this.root.removeEventListener("mouseleave",this.boundOnMouseLeave),this.root.removeEventListener("focusin",this.boundOnFocusIn),this.root.removeEventListener("focusout",this.boundOnFocusOut),window.removeEventListener("pointermove",this.boundPointerMove),window.removeEventListener("pointerup",this.boundPointerUp),window.removeEventListener("pointercancel",this.boundPointerUp),this.trackY?.remove(),this.trackX?.remove(),this.root.classList.remove("wulf-scrollblock","has-scroll-y","has-scroll-x","has-both-axes","is-visible","is-scrolling","is-dragging","is-always-visible"),this.createdViewport&&this.viewport.parentElement===this.root){for(;this.viewport.firstChild;)this.root.insertBefore(this.viewport.firstChild,this.viewport);this.viewport.remove()}else this.viewport.removeAttribute("tabindex"),this.wasIdGenerated&&this.viewport.removeAttribute("id"),this.wasRoleInferred&&this.viewport.getAttribute("role")==="region"&&this.viewport.removeAttribute("role"),this.wasAriaLabelInferred&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.viewport.removeAttribute("aria-label")}};z._i18n=J,z.i18n=J;var Tt={ScrollBlock:z,i18n:J};var It=z;if(typeof window<"u"){let p=window,i=p.Wulf||{};p.Wulf=i,i.Scroll=Tt}var mt={};_(mt,{LayoutEngine:()=>Y,LocalizedComponent:()=>S,Masonry:()=>B,createI18nManager:()=>D,default:()=>Ct,masonryEn:()=>pt,masonryFr:()=>dt,masonryI18n:()=>Q});var Y=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 o=i.querySelector(e);if(o){let a=o.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 o=e.getBoundingClientRect().width;if(o>0)return o}if(t){let o=t.getBoundingClientRect().width;if(o>0)return o}let s=i.getBoundingClientRect().width;return s>0?s:200}static getItemSpan(i,t,e,s){let o=i.getAttribute("data-masonry-span")||i.dataset.masonrySpan;if(o){let a=parseInt(o,10);if(!isNaN(a)&&a>0)return Math.min(s,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(s,a)}return 1}static calculate(i,t,e){let o=i.getBoundingClientRect().width,{x:n,y:a}=this.parseGutter(e.gutter);if(o<=0||t.length===0)return{cols:1,colWidth:o,gutterX:n,gutterY:a,containerHeight:0,containerWidth:o,positions:[]};let r=t[0]||null,l=this.resolveColumnWidth(i,r,e.columnWidth),h=Math.floor((o+n)/(l+n));h=Math.max(1,h),!e.columnWidth&&h>1&&(l=(o-(h-1)*n)/h);let c=e.fitWidth?h*l+(h-1)*n:void 0,u=new Array(h).fill(0),d=[],m=t.map(v=>{let w=v.getBoundingClientRect().height;return w>0?w:50}),f=0;for(let v=0;v<t.length;v++){let w=t[v],E=m[v],y=this.getItemSpan(w,l,n,h),T=0,k=0;if(e.horizontalOrder){f+y>h&&(f=0),T=f;let A=0;for(let M=0;M<y;M++)u[T+M]>A&&(A=u[T+M]);k=A,f=(T+y)%h}else if(y===1){let A=u[0];T=0;for(let M=1;M<h;M++)u[M]<A&&(A=u[M],T=M);k=A}else{let A=1/0;T=0;for(let M=0;M<=h-y;M++){let st=0;for(let nt=0;nt<y;nt++)u[M+nt]>st&&(st=u[M+nt]);st<A&&(A=st,T=M)}k=A}let et=y*l+(y-1)*n,L=T*(l+n);d.push({element:w,x:L,y:k,width:et,height:E,column:T,span:y});let O=k+E+a;for(let A=0;A<y;A++)u[T+A]=O}let g=0;for(let v=0;v<h;v++)u[v]>g&&(g=u[v]);let b=Math.max(0,g>0?g-a:0);return{cols:h,colWidth:l,gutterX:n,gutterY:a,containerHeight:b,containerWidth:o,fittedWidth:c,positions:d}}};var dt={gallery:"Galerie en grille asym\xE9trique"};var pt={gallery:"Masonry grid gallery"};var Q=D("fr",{fr:dt,en:pt});var B=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 o=document.querySelector(t);if(!o)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${t}"`);this.root=o}else if(t instanceof HTMLElement)this.root=t;else throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");this.originalContainerStyles={height:this.root.style.height,width:this.root.style.width},this.hasExplicitAriaLabel=!!(e.ariaLabel||e.i18n?.gallery),this.options={itemSelector:e.itemSelector||"> *",columnWidth:e.columnWidth??0,gutter:e.gutter??0,percentPosition:!!e.percentPosition,fitWidth:!!e.fitWidth,horizontalOrder:!!e.horizontalOrder,transitionDuration:e.transitionDuration!==void 0?e.transitionDuration:300,stagger:e.stagger||0,resize:e.resize!==!1,autoImages:e.autoImages!==!1,useNativeCSSGrid:e.useNativeCSSGrid!==!1,ariaRole:e.ariaRole||"region",ariaLabel:e.ariaLabel||this.t("gallery"),i18n:e.i18n||{},onLayout:e.onLayout||(()=>{}),onItemPlaced:e.onItemPlaced||(()=>{}),audit:e.audit??!0};let s=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("grid-template-rows","masonry");this.options.useNativeCSSGrid&&s?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native")):this.root.classList.add("wulf-masonry"),this.initAccessibility(),this.applyTransitionDuration(),this.reloadItems(),this.initObservers(),this.initImages(),this.layout(),this.runAuditWarning(this.options.audit)}get items(){return[...this._items]}initAccessibility(){this.options.ariaRole&&!this.root.hasAttribute("role")&&(this.root.setAttribute("role",this.options.ariaRole),this.wasRoleInferred=!0);let t=this.hasExplicitAriaLabel?this.options.ariaLabel:this.t("gallery");t&&!this.root.hasAttribute("aria-label")&&(this.root.setAttribute("aria-label",t),this.lastInferredAriaLabel=t,this.wasAriaLabelInferred=!0)}syncAccessibilityLabels(){if(this.wasAriaLabelInferred&&!this.hasExplicitAriaLabel&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel){let e=this.t("gallery");this.root.setAttribute("aria-label",e),this.lastInferredAriaLabel=e,this.options.ariaLabel=e}}applyTransitionDuration(){let t=this.options.transitionDuration,e=typeof t=="number"?`${t}ms`:t;this.root.style.setProperty("--wulf-masonry-duration",e)}reloadItems(){if(this.isDestroyed)return;let t=[];if(this.options.itemSelector==="> *")t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"));else try{t=Array.from(this.root.querySelectorAll(this.options.itemSelector)).filter(e=>e.parentElement===this.root&&!e.hasAttribute("data-masonry-ignore"))}catch{t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore"))}this._items=t;for(let e of this._items)e.classList.add("wulf-masonry-item"),this.itemResizeObserver&&this.itemResizeObserver.observe(e)}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let t=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(e=>{for(let s of e){let o=s.contentRect.width;Math.abs(o-t)>=1&&(t=o,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(()=>{this.scheduleLayout()});for(let e of this._items)this.itemResizeObserver.observe(e)}initImages(){if(!this.options.autoImages)return;let t=Array.from(this.root.querySelectorAll("img"));for(let e of t)if(!e.complete){let s=()=>{let o=()=>{this.pendingImageListeners=this.pendingImageListeners.filter(n=>n.handler!==o),this.isDestroyed||this.scheduleLayout()};this.pendingImageListeners.push({img:e,handler:o}),e.addEventListener("load",o,{once:!0})};typeof e.decode=="function"?e.decode().then(()=>{this.isDestroyed||this.scheduleLayout()}).catch(()=>{s()}):s()}}scheduleLayout(){this.isDestroyed||(this.layoutRafId!==null&&cancelAnimationFrame(this.layoutRafId),this.layoutRafId=requestAnimationFrame(()=>{this.layoutRafId=null,this.layout()}))}layout(){if(this.isDestroyed)return;if(this.syncAccessibilityLabels(),this.isNativeCSSGrid){this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true");let t=Y.calculate(this.root,this._items,this.options);this.root.style.height=`${t.containerHeight}px`,this.options.fitWidth&&t.fittedWidth!==void 0?(this.root.style.width=`${t.fittedWidth}px`,this.root.classList.add("wulf-masonry--fit-width")):this.root.classList.remove("wulf-masonry--fit-width");let e=this.options.stagger,s=this.options.percentPosition&&t.containerWidth>0;for(let o=0;o<t.positions.length;o++){let n=t.positions[o],a=n.element;if(s){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=`${o*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 s=document.createDocumentFragment();for(let o of e)o.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),s.appendChild(o);this.root.appendChild(s),this.reloadItems(),this.initImages(),this.layout()}prepend(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let s=this.root.firstChild,o=document.createDocumentFragment();for(let n of e)n.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),o.appendChild(n);this.root.insertBefore(o,s),this.reloadItems(),this.initImages(),this.layout()}remove(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;for(let n of e)n.classList.add("wulf-masonry-item--hidden");let s=typeof this.options.transitionDuration=="number"?this.options.transitionDuration:300;if(s<=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 o=window.setTimeout(()=>{if(this.removeTimers.delete(o),!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()}},s);this.removeTimers.add(o)}audit(){let t=[],e=this.checkAriaIdReferences(this.root,"aria-labelledby",t),s=!this.wasAriaLabelInferred&&!!this.root.getAttribute("aria-label")?.trim();!this.hasExplicitAriaLabel&&!s&&!e&&t.push("Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour qualifier la grille (WCAG 4.1.2).");let o=Array.from(this.root.querySelectorAll("img")).filter(n=>!n.hasAttribute("alt")&&n.getAttribute("aria-hidden")!=="true");return o.length>0&&t.push(`${o.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`),t}getAuditPrefix(){return"Wulf.Masonry"}getAuditTargetLabel(){return this.root.id?`#${this.root.id}`:`<${this.root.tagName.toLowerCase()}.wulf-masonry>`}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(let t of this.removeTimers)clearTimeout(t);this.removeTimers.clear();for(let{img:t,handler:e}of this.pendingImageListeners)t.removeEventListener("load",e);this.pendingImageListeners=[],this.layoutRafId!==null&&(cancelAnimationFrame(this.layoutRafId),this.layoutRafId=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.itemResizeObserver&&(this.itemResizeObserver.disconnect(),this.itemResizeObserver=null),this.root.classList.remove("wulf-masonry","wulf-masonry--native","wulf-masonry--fit-width"),this.root.removeAttribute("aria-busy"),this.wasRoleInferred&&this.root.getAttribute("role")===this.options.ariaRole&&this.root.removeAttribute("role"),this.wasAriaLabelInferred&&this.root.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.root.removeAttribute("aria-label"),this.root.style.removeProperty("--wulf-masonry-duration"),this.originalContainerStyles.height?this.root.style.height=this.originalContainerStyles.height:this.root.style.removeProperty("height"),this.originalContainerStyles.width?this.root.style.width=this.originalContainerStyles.width:this.root.style.removeProperty("width");for(let t of this._items)t.classList.remove("wulf-masonry-item","wulf-masonry-item--hidden"),t.style.removeProperty("--wulf-masonry-w"),t.style.removeProperty("--wulf-masonry-x"),t.style.removeProperty("--wulf-masonry-y"),t.style.removeProperty("transition-delay");this._items=[]}}};B._i18n=Q,B.i18n=Q;var Ct=B;if(typeof window<"u"){let p=window,i=p.Wulf||{};p.Wulf=i,i.Masonry=Object.assign(B,{Masonry:B,LayoutEngine:Y,i18n:Q})}var bt={};_(bt,{LocalizedComponent:()=>S,Toast:()=>F,ToastInstance:()=>it,ToastManager:()=>tt,createI18nManager:()=>D,default:()=>Ot,toastEn:()=>gt,toastFr:()=>ft,toastI18n:()=>$});var ft={closeButton:"Fermer la notification"};var gt={closeButton:"Close notification"};var $=D("fr",{fr:ft,en:gt});var Dt=1,it=class extends I{constructor(t,e){super();this._isClosed=!1;this.timerId=null;this.remainingTime=0;this.timerStartTime=0;this.isPaused=!1;this.id=`wulf-toast-${Dt++}`,this.options=Object.freeze({...t}),this.onDismissCallback=e;let s=t.duration===void 0?4e3:t.duration;typeof s=="number"&&s>0?this.remainingTime=s:this.remainingTime=0,this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(t.audit!==!1)}get isClosed(){return this._isClosed}audit(){let t=[],e=!!(this.options.title&&this.options.title.trim().length>0),s=!!(this.options.message&&this.options.message.trim().length>0);!e&&!s&&t.push("Contenu textuel vide : d\xE9finissez au moins un title ou un message pour que le lecteur d'\xE9cran puisse annoncer la notification (WCAG 4.1.3).");let o=this.options.duration===void 0?4e3:this.options.duration;typeof o=="number"&&o>0&&o<5e3&&t.push(`Dur\xE9e d'affichage trop courte (duration: ${o}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`);let n=this.options.closable??!0;return(o===!1||typeof o=="number"&&o<=0)&&!n&&!this.options.closeOnClick&&t.push("Notification persistante impossible \xE0 fermer : activez closable: true ou closeOnClick: true lorsque duration est d\xE9sactiv\xE9 (WCAG 2.1.1)."),t}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return`#${this.id}`}createDOM(){let t=document.createElement("div");t.id=this.id,t.className="wulf-toast";let e=this.options.role==="alert"?"alert":"status";if(t.setAttribute("role",e),t.setAttribute("aria-live",e==="alert"?"assertive":"polite"),t.setAttribute("aria-atomic","true"),this.options.backgroundColor&&t.style.setProperty("--wulf-toast-bg",this.options.backgroundColor),this.options.titleColor&&t.style.setProperty("--wulf-toast-title-color",this.options.titleColor),this.options.textColor&&t.style.setProperty("--wulf-toast-text-color",this.options.textColor),this.options.iconColor&&t.style.setProperty("--wulf-toast-icon-color",this.options.iconColor),this.options.closeButtonColor&&t.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor),this.options.icon&&this.options.icon.trim()!==""){let n=document.createElement("span");n.className=`wulf-toast-icon ${this.options.icon.trim()}`,n.setAttribute("aria-hidden","true"),t.appendChild(n)}let s=document.createElement("div");if(s.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),s.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),s.appendChild(n)}if(t.appendChild(s),this.options.closable??!0){let n=document.createElement("button");n.type="button",n.className="wulf-toast-close",n.setAttribute("aria-label",$.t("closeButton",this.options.i18n)),n.setAttribute("tabindex","0");let a=document.createElement("span");a.className="wulf-toast-close-icon",a.setAttribute("aria-hidden","true"),a.textContent="\xD7",n.appendChild(a),n.addEventListener("click",r=>{r.stopPropagation(),this.close("close-button")}),t.appendChild(n)}return t}appendTextWithLineBreaks(t,e){e.split(/\r\n|\r|\n/).forEach((o,n)=>{n>0&&t.appendChild(document.createElement("br")),t.appendChild(document.createTextNode(o))})}bindEvents(){this.element.addEventListener("click",t=>{this.options.onClick&&this.options.onClick(this,t),this.options.closeOnClick&&this.close("toast-click")}),this.element.addEventListener("mouseenter",()=>this.pauseTimer()),this.element.addEventListener("mouseleave",()=>this.resumeTimer()),this.element.addEventListener("focusin",()=>this.pauseTimer()),this.element.addEventListener("focusout",()=>this.resumeTimer())}startTimer(){this._isClosed||this.remainingTime<=0||(this.timerStartTime=Date.now(),this.timerId=window.setTimeout(()=>{this.close("timeout")},this.remainingTime))}pauseTimer(){if(this._isClosed||this.remainingTime<=0||this.isPaused)return;this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null);let t=Date.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-t),this.isPaused=!0}resumeTimer(){this._isClosed||this.remainingTime<=0||!this.isPaused||(this.isPaused=!1,this.startTimer())}destroyImmediate(t="replace"){this._isClosed||(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,t),this.options.onClose&&this.options.onClose(this,t))}close(t="programmatic",e=!1){return this._isClosed?Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),new Promise(s=>{this.element.classList.add(e?"wulf-toast-hiding-fast":"wulf-toast-hiding");let o=()=>{this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.onDismissCallback&&this.onDismissCallback(this,t),this.options.onClose&&this.options.onClose(this,t),s()};if(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)o();else if(e)window.setTimeout(o,90);else{let a=!1,r=null,l=()=>{a||(a=!0,r!==null&&(window.clearTimeout(r),r=null),this.element.removeEventListener("animationend",l),this.element.removeEventListener("transitionend",l),o())};this.element.addEventListener("animationend",l,{once:!0}),this.element.addEventListener("transitionend",l,{once:!0}),r=window.setTimeout(l,300)}}))}};var G=class G{constructor(){this.containers=new Map;this.activeToasts=new Map;this.replaceTokens=new Map;this.pendingReplacements=new Set}static getInstance(){return G.instance||(G.instance=new G),G.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 o=[...e],n=(this.replaceTokens.get(t)||0)+1;this.replaceTokens.set(t,n),this.pendingReplacements.add(t);let a=o.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 s=typeof i.options.maxToasts=="number"&&i.options.maxToasts>0?i.options.maxToasts:5;if(e.length>=s){let o=e.length-s+1,n=e.splice(0,o);for(let a of n)a.close("max-limit",!0)}this.mountToast(i,t)}mountToast(i,t){let e=this.getOrCreateContainer(t),s=this.activeToasts.get(t);if(s||(s=[],this.activeToasts.set(t,s)),e.appendChild(i.element),s.push(i),i.options.onOpen)try{i.options.onOpen(i)}catch(o){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",o)}i.startTimer()}remove(i,t){let e=i.options.position||"top-right",s=this.activeToasts.get(e);if(s){let o=s.indexOf(i);if(o!==-1&&s.splice(o,1),s.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 s=[...e];for(let o of s)t.push(o.close("programmatic"))}else{let s=this.containers.get(i);s&&(!s.firstChild||s.children.length===0)&&(s.parentNode&&s.parentNode.removeChild(s),this.containers.delete(i),this.activeToasts.delete(i))}}else{let e=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let s of e)t.push(this.clearAll(s))}return Promise.all(t).then(()=>{if(!i)for(let[e,s]of Array.from(this.containers.entries()))(!s.firstChild||s.children.length===0)&&(s.parentNode&&s.parentNode.removeChild(s),this.containers.delete(e),this.activeToasts.delete(e))})}getOrCreateContainer(i){let t=this.containers.get(i);return(!t||!document.body.contains(t))&&(t=document.createElement("div"),t.className=`wulf-toast-container wulf-toast-${i}`,t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions removals"),document.body.appendChild(t),this.containers.set(i,t)),t}};G.instance=null;var tt=G;var F=class extends S{audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(i={}){let t=tt.getInstance(),e=new it(i,(s,o)=>{t.remove(s,o)});return t.add(e),e}static clearAll(i){return tt.getInstance().clearAll(i)}};F._i18n=$,F.i18n=$;var Ot=F;if(typeof window<"u"){let p=window,i=p.Wulf||{};p.Wulf=i,i.Toast=Object.assign(F,{Toast:F,i18n:$})}var vt={};_(vt,{FocusTrap:()=>N,default:()=>N});var Ht=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(","),X=[],N=class extends I{constructor(t,e={}){super();this.active=!1;this.paused=!1;this.previousActiveElement=null;this.inertSiblings=[];this.startSentinel=null;this.endSentinel=null;let s=typeof t=="string"?document.querySelector(t):t;if(!s||!(s instanceof HTMLElement))throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${t}"`);this.element=s,this.options={initialFocus:e.initialFocus!==void 0?e.initialFocus:"[data-autofocus], [autofocus]",returnFocus:e.returnFocus??!0,fallbackReturnFocus:e.fallbackReturnFocus??"",escapeDeactivates:e.escapeDeactivates??!0,allowOutsideClick:e.allowOutsideClick??!1,setInert:e.setInert??!1,onActivate:e.onActivate??(()=>{}),onDeactivate:e.onDeactivate??(()=>{}),audit:e.audit??!0},this.handleKeyDownBound=this.handleKeyDown.bind(this),this.handleClickOutsideBound=this.handleClickOutside.bind(this),this.handleFocusInBound=this.handleFocusIn.bind(this),this.runAuditWarning(this.options.audit)}isFocusable(t){if(!t||!t.isConnected||t.disabled||t.closest("fieldset[disabled]")&&!t.closest("legend")||t.hasAttribute("inert")||t.closest("[inert]")||t.hidden||t.closest("[hidden]")||t.style.display==="none"||t.style.visibility==="hidden")return!1;let e=window.getComputedStyle(t);if(e.display==="none"||e.visibility==="hidden"||t.offsetWidth===0&&t.offsetHeight===0&&e.position!=="fixed")return!1;if(t instanceof HTMLInputElement&&t.type==="radio"&&t.name){let s=Array.from(this.element.querySelectorAll(`input[type="radio"][name="${CSS.escape(t.name)}"]`)),o=s.find(n=>n.checked);return o?t===o:t===s[0]}return!0}getFocusableElements(){return Array.from(this.element.querySelectorAll(Ht)).filter(e=>this.isFocusable(e))}activate(){if(this.active)return this;let t=X[X.length-1];return t&&t.pause(),this.active=!0,this.paused=!1,X.push(this),this.previousActiveElement=document.activeElement,this.setupSentinels(),this.options.setInert&&this.applyInert(),document.addEventListener("keydown",this.handleKeyDownBound,!0),document.addEventListener("focusin",this.handleFocusInBound,!0),this.options.allowOutsideClick||(document.addEventListener("mousedown",this.handleClickOutsideBound,!0),document.addEventListener("touchstart",this.handleClickOutsideBound,!0)),this.applyInitialFocus(),this.runAuditWarning(this.options.audit),this.options.onActivate(),this}deactivate(){if(!this.active)return this;this.active=!1,this.paused=!1;let t=X.indexOf(this);t!==-1&&X.splice(t,1);let e=X[X.length-1];return e&&e.unpause(),document.removeEventListener("keydown",this.handleKeyDownBound,!0),document.removeEventListener("focusin",this.handleFocusInBound,!0),document.removeEventListener("mousedown",this.handleClickOutsideBound,!0),document.removeEventListener("touchstart",this.handleClickOutsideBound,!0),this.removeSentinels(),this.removeInert(),this.options.returnFocus&&this.restoreFocus(),this.options.onDeactivate(),this}pause(){this.paused=!0}unpause(){this.paused=!1}isActive(){return this.active&&!this.paused}audit(){let t=[],e=this.element.getAttribute("role"),s=this.element.tagName.toLowerCase()==="dialog";!s&&(!e||!["dialog","alertdialog","menu","listbox","tree","grid"].includes(e))&&t.push('R\xF4le s\xE9mantique manquant ou inadapt\xE9 : d\xE9finissez role="dialog" (ou "alertdialog", "menu", "listbox") sur le conteneur.'),(s||e==="dialog"||e==="alertdialog")&&this.element.getAttribute("aria-modal")!=="true"&&t.push('Isolation modale manquante : d\xE9finissez aria-modal="true" sur le conteneur de dialogue (WCAG 4.1.2).');let n=this.element.getAttribute("aria-label")?.trim(),a=this.checkAriaIdReferences(this.element,"aria-labelledby",t);return!n&&!a&&t.push('Nom accessible manquant : d\xE9finissez aria-labelledby="id-titre" ou aria-label="..." sur le conteneur (WCAG 4.1.2).'),t}getAuditPrefix(){return"Wulf.FocusTrap"}getAuditTargetLabel(){return this.element.id?`#${this.element.id}`:`<${this.element.tagName.toLowerCase()}>`}destroy(){this.deactivate()}handleKeyDown(t){if(!this.isActive())return;if(t.key==="Escape"&&this.options.escapeDeactivates){t.preventDefault(),t.stopPropagation(),this.deactivate();return}if(t.key!=="Tab")return;let e=this.getFocusableElements();if(e.length===0){t.preventDefault(),this.element.getAttribute("tabindex")===null&&this.element.setAttribute("tabindex","-1"),this.element.focus();return}let s=e[0],o=e[e.length-1],n=document.activeElement;!t.shiftKey&&(n===o||!this.element.contains(n))?(t.preventDefault(),s.focus()):t.shiftKey&&(n===s||!this.element.contains(n))&&(t.preventDefault(),o.focus())}handleFocusIn(t){if(!this.isActive())return;let e=t.target;if(e){if(e===this.startSentinel){let s=this.getFocusableElements();s.length>0?s[s.length-1].focus():this.element.focus();return}if(e===this.endSentinel){let s=this.getFocusableElements();s.length>0?s[0].focus():this.element.focus();return}if(!this.element.contains(e)){let s=this.getFocusableElements();s.length>0?s[0].focus():(this.element.getAttribute("tabindex")===null&&this.element.setAttribute("tabindex","-1"),this.element.focus())}}}handleClickOutside(t){if(!this.isActive())return;let e=t.target;e&&!this.element.contains(e)&&(t.preventDefault(),t.stopPropagation())}setupSentinels(){this.startSentinel||(this.startSentinel=document.createElement("span"),this.startSentinel.setAttribute("tabindex","0"),this.startSentinel.setAttribute("aria-hidden","true"),this.startSentinel.className="wulf-sentinel-start",this.startSentinel.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;"),this.endSentinel||(this.endSentinel=document.createElement("span"),this.endSentinel.setAttribute("tabindex","0"),this.endSentinel.setAttribute("aria-hidden","true"),this.endSentinel.className="wulf-sentinel-end",this.endSentinel.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none;width:0;height:0;"),this.element.parentNode&&(this.element.parentNode.insertBefore(this.startSentinel,this.element),this.element.parentNode.insertBefore(this.endSentinel,this.element.nextSibling))}removeSentinels(){this.startSentinel?.remove(),this.endSentinel?.remove(),this.startSentinel=null,this.endSentinel=null}applyInert(){this.inertSiblings=[];let t=this.element.parentElement,e=this.element;for(;t&&t!==document.body;)e=t,t=t.parentElement;t===document.body&&Array.from(document.body.children).forEach(s=>{s instanceof HTMLElement&&s!==e&&s!==this.startSentinel&&s!==this.endSentinel&&!s.hasAttribute("inert")&&(s.setAttribute("inert",""),this.inertSiblings.push(s))})}removeInert(){this.inertSiblings.forEach(t=>t.removeAttribute("inert")),this.inertSiblings=[]}applyInitialFocus(){if(this.options.initialFocus===!1)return;let t=null;if(typeof this.options.initialFocus=="string"?t=this.element.querySelector(this.options.initialFocus):this.options.initialFocus instanceof HTMLElement&&(t=this.options.initialFocus),t&&this.isFocusable(t)){t.focus();return}let e=this.getFocusableElements();e.length>0?e[0].focus():(this.element.getAttribute("tabindex")===null&&this.element.setAttribute("tabindex","-1"),this.element.focus())}restoreFocus(){if(this.previousActiveElement&&this.previousActiveElement.isConnected){this.previousActiveElement.focus();return}if(this.options.fallbackReturnFocus){let t=typeof this.options.fallbackReturnFocus=="string"?document.querySelector(this.options.fallbackReturnFocus):this.options.fallbackReturnFocus;t&&t.isConnected&&t.focus()}}};if(typeof window<"u"){let p=window,i=p.Wulf||{};p.Wulf=i,i.FocusTrap=Object.assign(N,{FocusTrap:N})}return At(Rt);})();
2
5
  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
6
  //# sourceMappingURL=index.global.min.js.map