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