wulf.js 2.0.1 → 2.1.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 (75) hide show
  1. package/README.md +240 -4
  2. package/changelog.md +37 -0
  3. package/dist/focus-trap.esm.js +110 -37
  4. package/dist/focus-trap.esm.js.map +2 -2
  5. package/dist/focus-trap.global.js +110 -37
  6. package/dist/focus-trap.global.js.map +2 -2
  7. package/dist/focus-trap.global.min.js +2 -2
  8. package/dist/focus-trap.global.min.js.map +3 -3
  9. package/dist/index.esm.js +3370 -337
  10. package/dist/index.esm.js.map +4 -4
  11. package/dist/index.global.js +3370 -337
  12. package/dist/index.global.js.map +4 -4
  13. package/dist/index.global.min.js +2 -2
  14. package/dist/index.global.min.js.map +4 -4
  15. package/dist/mask.css +1 -1
  16. package/dist/mask.css.map +2 -2
  17. package/dist/mask.esm.js +2826 -171
  18. package/dist/mask.esm.js.map +4 -4
  19. package/dist/mask.global.js +2816 -161
  20. package/dist/mask.global.js.map +4 -4
  21. package/dist/mask.global.min.js +2 -2
  22. package/dist/mask.global.min.js.map +4 -4
  23. package/dist/mask.layered.css +1 -1
  24. package/dist/mask.layered.css.map +2 -2
  25. package/dist/masonry.esm.js +175 -69
  26. package/dist/masonry.esm.js.map +2 -2
  27. package/dist/masonry.global.js +175 -69
  28. package/dist/masonry.global.js.map +2 -2
  29. package/dist/masonry.global.min.js +3 -3
  30. package/dist/masonry.global.min.js.map +3 -3
  31. package/dist/scroll.css +1 -1
  32. package/dist/scroll.css.map +2 -2
  33. package/dist/scroll.esm.js +132 -40
  34. package/dist/scroll.esm.js.map +2 -2
  35. package/dist/scroll.global.js +132 -40
  36. package/dist/scroll.global.js.map +2 -2
  37. package/dist/scroll.global.min.js +2 -2
  38. package/dist/scroll.global.min.js.map +3 -3
  39. package/dist/scroll.layered.css +1 -1
  40. package/dist/scroll.layered.css.map +2 -2
  41. package/dist/shortcut.esm.js +182 -22
  42. package/dist/shortcut.esm.js.map +3 -3
  43. package/dist/shortcut.global.js +182 -22
  44. package/dist/shortcut.global.js.map +3 -3
  45. package/dist/shortcut.global.min.js +4 -1
  46. package/dist/shortcut.global.min.js.map +4 -4
  47. package/dist/toast.css +1 -1
  48. package/dist/toast.css.map +2 -2
  49. package/dist/toast.esm.js +116 -19
  50. package/dist/toast.esm.js.map +2 -2
  51. package/dist/toast.global.js +116 -19
  52. package/dist/toast.global.js.map +2 -2
  53. package/dist/toast.global.min.js +3 -3
  54. package/dist/toast.global.min.js.map +3 -3
  55. package/dist/toast.layered.css +1 -1
  56. package/dist/toast.layered.css.map +2 -2
  57. package/dist/types/common/AuditableComponent.d.ts +3 -3
  58. package/dist/types/common/dom.d.ts +5 -0
  59. package/dist/types/focus-trap/FocusTrap.d.ts +5 -2
  60. package/dist/types/mask/AmountEngine.d.ts +8 -0
  61. package/dist/types/mask/BaseInputMask.d.ts +18 -0
  62. package/dist/types/mask/DateUTCEngine.d.ts +187 -0
  63. package/dist/types/mask/InputAmountMask.d.ts +5 -0
  64. package/dist/types/mask/InputDateUTCMask.d.ts +110 -0
  65. package/dist/types/mask/InputEmailMask.d.ts +7 -0
  66. package/dist/types/mask/InputMask.d.ts +7 -5
  67. package/dist/types/mask/MaskEngine.d.ts +39 -7
  68. package/dist/types/mask/index.d.ts +12 -6
  69. package/dist/types/mask/paste.d.ts +15 -0
  70. package/dist/types/mask/types.d.ts +27 -2
  71. package/dist/types/masonry/Masonry.d.ts +2 -0
  72. package/dist/types/scroll/ScrollBlock.d.ts +2 -0
  73. package/dist/types/shortcut/ShortcutManager.d.ts +14 -3
  74. package/dist/types/toast/ToastManager.d.ts +2 -0
  75. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- "use strict";var __WulfIIFE=(()=>{var wt=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Yt=Object.prototype.hasOwnProperty;var et=(u,t)=>{for(var e in t)wt(u,e,{get:t[e],enumerable:!0})},Xt=(u,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of jt(t))!Yt.call(u,s)&&s!==e&&wt(u,s,{get:()=>t[s],enumerable:!(i=_t(t,s))||i.enumerable});return u};var Zt=u=>Xt(wt({},"__esModule",{value:!0}),u);var ue={};et(ue,{AmountEngine:()=>q,AuditableComponent:()=>N,BaseInputMask:()=>O,EmailEngine:()=>J,FocusTrap:()=>Ot,InputAmountMask:()=>rt,InputEmailMask:()=>at,InputMask:()=>st,LayoutEngine:()=>W,LocalizedComponent:()=>x,Mask:()=>At,MaskEngine:()=>G,MaskHistory:()=>V,MaskKeyboard:()=>Z,Masonry:()=>Lt,Scroll:()=>It,ScrollBlock:()=>Q,Shortcut:()=>Ht,ShortcutFormatter:()=>D,ShortcutManager:()=>B,Toast:()=>Pt,ToastInstance:()=>nt,ToastManager:()=>_,WulfFocusTrap:()=>X,WulfMasonry:()=>U,WulfShortcut:()=>B,WulfToast:()=>j,createI18nManager:()=>z,default:()=>St,getDeepActiveElement:()=>bt,getSafeWulfNamespace:()=>R,isImeComposing:()=>H,parseCssDurationMs:()=>Tt,prefersReducedMotion:()=>ot,resolveMaskConstructorArgs:()=>$,safeCssEscape:()=>ct,safeMove:()=>it,waitForAnimations:()=>ht});var At={};et(At,{AmountEngine:()=>q,BaseInputMask:()=>O,EmailEngine:()=>J,InputAmountMask:()=>rt,InputEmailMask:()=>at,InputMask:()=>st,Mask:()=>Ft,MaskEngine:()=>G,MaskHistory:()=>V,MaskKeyboard:()=>Z,default:()=>St,resolveMaskConstructorArgs:()=>$});function R(){if(typeof window>"u")return null;let u=window,t=u.Wulf;if(!t||typeof t!="object"||typeof Node<"u"&&t instanceof Node||typeof HTMLCollection<"u"&&t instanceof HTMLCollection){let e={};return u.Wulf=e,e}return t}function ct(u){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(u):String(u).replace(/["\\\u0000-\u001F\u007F]/g,"\\$&")}function bt(u){if(typeof document>"u")return null;let t=(u??document).activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t&&typeof t.focus=="function"?t:null}function it(u,t,e=null){let i=u.moveBefore;if(typeof i=="function"&&t.isConnected&&u.isConnected&&typeof u.getRootNode=="function"&&typeof t.getRootNode=="function"&&u.getRootNode()===t.getRootNode())try{i.call(u,t,e);return}catch{}u.insertBefore(t,e)}function H(u){return!!(u.isComposing||u.key==="Process"||u.key==="Enter"&&u.keyCode===229)}function Tt(u,t=300,e=6e4){let i=Number.isFinite(t)&&t>=0?Math.min(t,e):300;if(typeof u=="number")return Number.isFinite(u)&&u>=0?Math.min(u,e):i;if(typeof u=="string"){let s=u.split(","),n=-1;for(let o of s){let r=/^\+?(\d+(?:\.\d+)?|\.\d+)(ms|s)?$/i.exec(o.trim());if(r){let a=parseFloat(r[1]);if(Number.isFinite(a)&&a>=0){let l=r[2]?.toLowerCase()==="s"?a*1e3:a;l>n&&(n=l)}}}if(n>=0)return Math.min(n,e)}return i}function ot(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ht(u,t,e){let i=Number.isFinite(t)?Math.min(t,6e4):300;if(e?.aborted||i<=0||ot())return Promise.resolve();let s=typeof u.getAnimations=="function"?u.getAnimations().filter(n=>{if(n.playState!=="running")return!1;let o=n.effect?.getComputedTiming?.();return o?Number.isFinite(o.endTime):!0}):[];return s.length===0?Promise.resolve():new Promise(n=>{let o=!1,r=null,a=()=>{o||(o=!0,r!==null&&(clearTimeout(r),r=null),e?.removeEventListener("abort",a),n())};e?.addEventListener("abort",a,{once:!0}),r=setTimeout(a,i),Promise.allSettled(s.map(l=>l.finished)).then(a)})}var N=class{getAuditDisableHint(){return"Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement"}runAuditWarning(t=!0){if(!t)return[];let e=this.audit();return e.length>0&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${e.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
1
+ "use strict";var __WulfIIFE=(()=>{var Lt=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var at=(f,t)=>{for(var e in t)Lt(f,e,{get:t[e],enumerable:!0})},le=(f,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of oe(t))!ae.call(f,n)&&n!==e&&Lt(f,n,{get:()=>t[n],enumerable:!(i=re(t,n))||i.enumerable});return f};var ue=f=>le(Lt({},"__esModule",{value:!0}),f);var De={};at(De,{AmountEngine:()=>J,AuditableComponent:()=>B,BaseInputMask:()=>N,DATE_UTC_PRESETS:()=>gt,DateUTCEngine:()=>Q,EmailEngine:()=>rt,FocusTrap:()=>Yt,InputAmountMask:()=>pt,InputDateUTCMask:()=>bt,InputEmailMask:()=>ft,InputMask:()=>ht,LayoutEngine:()=>Y,LocalizedComponent:()=>H,Mask:()=>Rt,MaskEngine:()=>Z,MaskHistory:()=>U,MaskKeyboard:()=>nt,Masonry:()=>Bt,Scroll:()=>Ft,ScrollBlock:()=>ot,Shortcut:()=>Gt,ShortcutFormatter:()=>F,ShortcutManager:()=>_,Toast:()=>Wt,ToastInstance:()=>ct,ToastManager:()=>et,WulfFocusTrap:()=>st,WulfMasonry:()=>tt,WulfShortcut:()=>_,WulfToast:()=>it,createI18nManager:()=>j,default:()=>Pt,getDeepActiveElement:()=>D,getSafeWulfNamespace:()=>V,isImeComposing:()=>R,parseCssDurationMs:()=>Mt,prefersReducedMotion:()=>dt,safeCssEscape:()=>lt,safeMove:()=>ut,sanitizePastedText:()=>W,stripBidiAndInvisibles:()=>z,waitForAnimations:()=>St});var Rt={};at(Rt,{AmountEngine:()=>J,BaseInputMask:()=>N,DATE_UTC_PRESETS:()=>gt,DateUTCEngine:()=>Q,EmailEngine:()=>rt,InputAmountMask:()=>pt,InputDateUTCMask:()=>bt,InputEmailMask:()=>ft,InputMask:()=>ht,Mask:()=>jt,MaskEngine:()=>Z,MaskHistory:()=>U,MaskKeyboard:()=>nt,default:()=>Pt,sanitizePastedText:()=>W,stripBidiAndInvisibles:()=>z});function V(){if(typeof window>"u")return null;let f=window,t=f.Wulf;if(!t||typeof t!="object"||typeof Node<"u"&&t instanceof Node||typeof HTMLCollection<"u"&&t instanceof HTMLCollection){let e={};return f.Wulf=e,e}return t}function lt(f){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(f):String(f).replace(/["\\\u0000-\u001F\u007F]/g,"\\$&")}function z(f,t=4096){let e=Math.max(0,t);return String(f??"").slice(0,e).replace(/[\u061C\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g,"")}function D(f){if(typeof document>"u")return null;let t=(f??document).activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t&&typeof t.focus=="function"?t:null}function ut(f,t,e=null){let i=f.moveBefore;if(typeof i=="function"&&t.isConnected&&f.isConnected&&typeof f.getRootNode=="function"&&typeof t.getRootNode=="function"&&f.getRootNode()===t.getRootNode())try{i.call(f,t,e);return}catch{}f.insertBefore(t,e)}function R(f){return!!(f.isComposing||f.key==="Process"||f.key==="Enter"&&f.keyCode===229)}function Mt(f,t=300,e=6e4){let i=Number.isFinite(t)&&t>=0?Math.min(t,e):300;if(typeof f=="number")return Number.isFinite(f)&&f>=0?Math.min(f,e):i;if(typeof f=="string"){let n=f.split(","),s=-1;for(let r of n){let o=/^\+?(\d+(?:\.\d+)?|\.\d+)(ms|s)?$/i.exec(r.trim());if(o){let a=parseFloat(o[1]);if(Number.isFinite(a)&&a>=0){let l=o[2]?.toLowerCase()==="s"?a*1e3:a;l>s&&(s=l)}}}if(s>=0)return Math.min(s,e)}return i}function dt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function St(f,t,e){let i=Number.isFinite(t)?Math.min(t,6e4):300;if(e?.aborted||i<=0||dt())return Promise.resolve();let n=typeof f.getAnimations=="function"?f.getAnimations().filter(s=>{if(s.playState!=="running")return!1;let r=s.effect?.getComputedTiming?.();return r?Number.isFinite(r.endTime):!0}):[];return n.length===0?Promise.resolve():new Promise(s=>{let r=!1,o=null,a=()=>{r||(r=!0,o!==null&&(clearTimeout(o),o=null),e?.removeEventListener("abort",a),s())};e?.addEventListener("abort",a,{once:!0}),o=setTimeout(a,i),Promise.allSettled(n.map(l=>l.finished)).then(a)})}var B=class{getAuditDisableHint(){return"Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement"}runAuditWarning(t=!0){if(!t)return[];let e=this.audit();return e.length>0&&typeof console<"u"&&typeof console.warn=="function"&&console.warn(`[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${e.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
2
2
  `+e.map(i=>` - ${i}`).join(`
3
3
  `)+`
4
- (${this.getAuditDisableHint()})`),e}checkAriaIdReferences(t,e,i){let s=t.getAttribute(e)?.trim();if(!s)return!1;let n=t.ownerDocument||document,o=typeof t.getRootNode=="function"?t.getRootNode():n,r=s.split(/\s+/).filter(Boolean),a=r.length>0&&r.every(l=>!!(typeof ShadowRoot<"u"&&o instanceof ShadowRoot?o.getElementById(l):n.getElementById(l)));return a||i.push(`Attribut ${e}="${s}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),a}};var vt=new Set(["left","right","center"]);function $(u,t,e){return t&&typeof t=="object"&&"tagName"in t&&t.tagName==="INPUT"?{wrapper:u||null,input:t,options:e||{}}:{wrapper:null,input:u,options:t&&typeof t=="object"&&!("tagName"in t)?t:{}}}var O=class extends N{wrapper;input;options;ghost=null;isWrapperCreated=!1;wasWrapperFallbackStyled=!1;wasAlignSet=!1;hadInitialDataAlign=!1;isDestroyed=!1;isFocused=!1;isDispatchingNativeInput=!1;lastTrackedValue="";nativeValueDescriptor=null;onCutHandler=()=>{};onFormResetHandler;mutationObserver=null;focusSelectTimerId=null;abortController=new AbortController;constructor(t,e,i){super();let{wrapper:s,input:n,options:o}=$(t,e,i);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",a=!!(o.createWrapper??r),l=s;if(!l&&a){let M=this.input.ownerDocument||document,v=M.createElement("span");v.className="wulf-mask-wrapper",this.input.parentNode&&this.input.parentNode.insertBefore(v,this.input),it(v,this.input,null);let k=M.defaultView||(typeof window<"u"?window:null);(!v.isConnected||!k||k.getComputedStyle(v).display!=="inline-grid")&&(v.style.display="inline-grid",v.style.gridTemplateColumns="1fr",v.style.gridTemplateRows="1fr",v.style.verticalAlign="middle",v.style.boxSizing="border-box",v.style.position="relative",this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",this.wasWrapperFallbackStyled=!0),l=v,this.isWrapperCreated=!0}if(!l)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=l,this.normalizeInputType();let d=this.getAttr("data-mask-focus-only")==="true",c=this.hasAttr("data-disabled"),h=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"),m=f&&vt.has(f)?f:null;this.hadInitialDataAlign=this.wrapper.hasAttribute("data-align");let g=this.getAttr("data-mask-audit"),{disabled:b,align:I,...y}=o,E=I&&vt.has(I)?I:void 0,T=b!==void 0?b:!!c,A=o.audit??(g!==null?g!=="false":!0),w=this.isPasswordInput();this.options={...y,createWrapper:a,showMaskOnFocus:o.showMaskOnFocus??d??!1,selectAllOnFocus:o.selectAllOnFocus??h??!1,copyRaw:w?!1:o.copyRaw??p??!1,disabled:T,align:E??(m||void 0),emitNativeInput:o.emitNativeInput??!0,audit:A},this.options.showMaskOnFocus&&this.wrapper.classList.add("mask-focus-only"),this.options.disabled&&this.wrapper.setAttribute("data-disabled","true"),this.options.align&&this.setAlign(this.options.align),this.createGhost(),this.hookValueProperty(),this.bindBaseEvents(),this.initMutationObserver()}getAttr(t){return this.input.getAttribute(t)||this.wrapper.getAttribute(t)}hasAttr(t){return this.wrapper.hasAttribute(t)||this.input.hasAttribute(t)}hasNativePlaceholder(){return!!(this.input.placeholder&&this.input.placeholder.trim().length>0)}shouldHideGhostForPlaceholder(t){return!this.isFocused&&t&&this.hasNativePlaceholder()}bindBaseEvents(){let{signal:t}=this.abortController;this.input.addEventListener("copy",this.onBaseCopy,{signal:t}),this.input.addEventListener("focus",this.onBaseFocus,{signal:t}),this.input.addEventListener("blur",this.onBaseBlur,{signal:t})}onBaseCopy=t=>{if(!this.options.copyRaw||this.options.disabled||this.input.type==="password")return;let e=this.input.selectionStart??0,i=this.input.selectionEnd??e,s="";e!==i?s=this.extractRawSnippet(this.input.value.slice(e,i)):s=this.getRawValue(),s&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",s))};extractRawSnippet(t){return t}onBaseFocus=()=>{this.isFocused=!0,this.options.selectAllOnFocus&&this.input.value.length>0&&(this.focusSelectTimerId!==null&&clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=window.setTimeout(()=>{this.focusSelectTimerId=null,!this.isDestroyed&&document.activeElement===this.input&&this.input.select()},0))};onBaseBlur=()=>{this.isFocused=!1,this.isPasswordInput()&&(this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask"))};initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(e=>{for(let i of e)i.type==="attributes"&&i.attributeName&&this.handleAttributeMutation(i.attributeName)});let t={attributes:!0,attributeFilter:["data-mask","data-mask-placeholder","data-mask-focus-only","data-mask-strict","data-mask-select-on-focus","data-mask-copy-raw","data-mask-pad-decimals","data-mask-auto-lowercase","data-mask-cycle-suggestions","data-mask-default-tld","data-mask-tlds","data-disabled","data-mask-align","data-align","placeholder","type"]};this.mutationObserver.observe(this.wrapper,t),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,t)}isPasswordInput(){return(this.input.type||"").toLowerCase()==="password"}computePasswordDigest(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=Math.imul(e,16777619);return`__pwd:${(e>>>0).toString(36)}:${t.length}`}setAlign(t){let e=t&&vt.has(t)?t:null,i=e||void 0,s=this.wrapper.getAttribute("data-align"),n=e?this.wrapper.classList.contains(`align-${e}`):!this.wrapper.classList.contains("align-left")&&!this.wrapper.classList.contains("align-right")&&!this.wrapper.classList.contains("align-center");this.options.align===i&&s===e&&n||(this.options.align=i,this.wrapper.classList.remove("align-left","align-right","align-center"),e?(this.wrapper.classList.add(`align-${e}`),this.wasAlignSet=!0,this.wrapper.getAttribute("data-align")!==e&&this.wrapper.setAttribute("data-align",e)):this.wrapper.hasAttribute("data-align")&&this.wrapper.removeAttribute("data-align"),this.syncGhostStyles())}handleAttributeMutation(t){if(t==="data-disabled"){let e=this.hasAttr("data-disabled");e!==!!this.options.disabled&&this.setDisabled(e)}else if(t==="data-mask-focus-only"){let e=this.getAttr("data-mask-focus-only")==="true";e!==!!this.options.showMaskOnFocus&&this.setShowMaskOnFocus(e)}else if(t==="data-mask-select-on-focus")this.options.selectAllOnFocus=this.getAttr("data-mask-select-on-focus")==="true";else if(t==="data-mask-copy-raw")this.options.copyRaw=this.isPasswordInput()?!1:this.getAttr("data-mask-copy-raw")==="true";else if(t==="type")this.isPasswordInput()&&(this.options.copyRaw=!1,this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask"),this.onPasswordModeDetected());else if(t==="data-mask-align"||t==="data-align"){let e=this.getAttr("data-mask-align")||this.getAttr("data-align"),i=e&&vt.has(e)?e:null;i!==(this.options.align??null)&&this.setAlign(i)}}normalizeInputType(){let t=["number","email","date","datetime-local","month","week","time","color","file","range"];if(this.input.type&&t.includes(this.input.type.toLowerCase())){let e=this.input.type.toLowerCase();this.input.type="text",e==="number"&&(this.input.inputMode="numeric")}}createGhost(){let t=this.wrapper.querySelector(".mask-ghost");t&&t.remove();let e=this.input.ownerDocument||document;this.ghost=e.createElement("div"),this.ghost.className="mask-ghost",this.ghost.setAttribute("aria-hidden","true"),this.ghost.style.display="flex",this.ghost.style.alignItems="center",this.wrapper.appendChild(this.ghost),this.wrapper.classList.add("has-ghost");let i=e.defaultView||(typeof window<"u"?window:null);(!this.wrapper.isConnected||!i||i.getComputedStyle(this.ghost).pointerEvents!=="none")&&(this.ghost.style.gridArea="1 / 1 / 2 / 2",this.ghost.style.pointerEvents="none"),this.syncGhostStyles()}setGhostContent(...t){if(this.ghost){if(typeof this.ghost.replaceChildren=="function")this.ghost.replaceChildren(...t);else{this.ghost.textContent="";for(let e of t)this.ghost.appendChild(typeof e=="string"?document.createTextNode(e):e)}this.wrapper.classList.toggle("has-visible-ghost",t.length>0)}}clearGhost(){this.setGhostContent()}syncGhostStyles(){if(!this.ghost||typeof window>"u")return;let t=window.getComputedStyle(this.input);if(!t)return;this.ghost.style.fontFamily=t.fontFamily,this.ghost.style.fontSize=t.fontSize,this.ghost.style.fontWeight=t.fontWeight,this.ghost.style.fontStyle=t.fontStyle,this.ghost.style.letterSpacing=t.letterSpacing,this.ghost.style.lineHeight=t.lineHeight,this.ghost.style.paddingTop=t.paddingTop,this.ghost.style.paddingBottom=t.paddingBottom,this.ghost.style.paddingLeft=t.paddingLeft,this.ghost.style.paddingRight=t.paddingRight,this.ghost.style.borderTopWidth=t.borderTopWidth,this.ghost.style.borderBottomWidth=t.borderBottomWidth,this.ghost.style.borderLeftWidth=t.borderLeftWidth,this.ghost.style.borderRightWidth=t.borderRightWidth,this.ghost.style.borderTopStyle=t.borderTopStyle==="none"?"none":"solid",this.ghost.style.borderBottomStyle=t.borderBottomStyle==="none"?"none":"solid",this.ghost.style.borderLeftStyle=t.borderLeftStyle==="none"?"none":"solid",this.ghost.style.borderRightStyle=t.borderRightStyle==="none"?"none":"solid",this.ghost.style.borderColor="transparent",this.ghost.style.boxSizing=t.boxSizing,this.ghost.style.textAlign=t.textAlign,this.ghost.style.direction=t.direction;let e=t.direction==="rtl"||this.input.getAttribute("dir")==="rtl"||this.wrapper.getAttribute("dir")==="rtl",i=t.textAlign;i==="right"?this.ghost.style.justifyContent="right":i==="left"?this.ghost.style.justifyContent="left":i==="center"?this.ghost.style.justifyContent="center":i==="end"?this.ghost.style.justifyContent=e?"left":"right":this.ghost.style.justifyContent=e?"right":"left"}setNativeValue(t){this.nativeValueDescriptor&&this.nativeValueDescriptor.set?this.nativeValueDescriptor.set.call(this.input,t):this.input.value=t}dispatchNativeInput(){if(!(this.isDestroyed||typeof window>"u")&&this.options.emitNativeInput!==!1){this.isDispatchingNativeInput=!0;try{let t=this.input._valueTracker;!this.isPasswordInput()&&t&&typeof t.setValue=="function"&&t.setValue(this.lastTrackedValue),this.lastTrackedValue=this.isPasswordInput()?"":this.input.value,this.input.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))}finally{this.isDispatchingNativeInput=!1}}}onScroll=()=>{this.ghost&&(this.ghost.scrollLeft=this.input.scrollLeft)};hookValueProperty(){try{let t=HTMLInputElement.prototype,e=Object.getOwnPropertyDescriptor(t,"value");if(!e||!e.set||!e.get)return;this.nativeValueDescriptor=e;let i=this;Object.defineProperty(this.input,"value",{get(){return e.get.call(this)},set(s){let n=String(s??"");e.set.call(this,n),!i.isDestroyed&&i.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,i=typeof this.input.getRootNode=="function"?this.input.getRootNode():e,s=typeof ShadowRoot<"u"&&i instanceof ShadowRoot?i:e,n=this.input.getAttribute("aria-label")?.trim(),o=this.checkAriaIdReferences(this.input,"aria-labelledby",t),r=!!this.input.closest("label"),a=!!(this.input.labels&&this.input.labels.length>0),l=!1;if(this.input.id)try{l=!!s.querySelector(`label[for="${ct(this.input.id)}"]`)}catch{l=!1}!n&&!o&&!r&&!a&&!l&&t.push(`\xC9tiquetage accessible manquant : associez un <label for="id"> (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`),this.checkAriaIdReferences(this.input,"aria-describedby",t);let d=this.getSpecificAuditWarnings();return t.push(...d),t}getAuditPrefix(){return`Wulf.Mask.${this.constructor.name||"InputMask"}`}getAuditTargetLabel(){return this.input.id?`#${this.input.id}`:this.input.name?`input[name="${this.input.name}"]`:"<input>"}getAuditDisableHint(){return'Passez { audit: false } ou data-mask-audit="false" pour d\xE9sactiver cet avertissement'}getSpecificAuditWarnings(){return[]}onPasswordModeDetected(){}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.focusSelectTimerId!==null&&(clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.abortController.abort(),this.lastTrackedValue="",this.unhookValueProperty(),this.ghost&&(this.ghost.remove(),this.ghost=null),this.isWrapperCreated&&this.wrapper?(this.wasWrapperFallbackStyled&&(this.input.style.gridArea="",this.input.style.boxSizing=""),this.wrapper.parentElement?it(this.wrapper.parentElement,this.input,this.wrapper):this.wrapper.parentNode&&this.wrapper.parentNode.insertBefore(this.input,this.wrapper),this.wrapper.remove()):this.wrapper&&(this.wrapper.removeAttribute("data-mask"),this.wrapper.removeAttribute("data-disabled"),this.wasAlignSet&&!this.hadInitialDataAlign&&this.wrapper.removeAttribute("data-align"),this.wasAlignSet&&this.wrapper.classList.remove("align-left","align-right","align-center"),this.wrapper.classList.remove("is-complete","is-focused","mask-focus-only","has-selection","has-ghost","has-visible-ghost")))}};var Jt={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:u=>u.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:u=>u.toUpperCase()}},G=class u{pattern;patterns=[];subEngines=[];activeEngine=null;placeholderChar;tokens;slots=[];fullMaskTemplate="";prefixSlotsCount=0;prefixString="";strict=!0;autoLowercase=!1;constructor(t,e={}){let i=e||{},s=String(i.placeholderChar||"_");this.placeholderChar=Array.from(s)[0]||"_";let n=Object.create(null);for(let[o,r]of Object.entries(Jt))n[o]=r;if(i.tokens&&typeof i.tokens=="object")for(let[o,r]of Object.entries(i.tokens))o!=="__proto__"&&o!=="constructor"&&o!=="prototype"&&r&&(n[o]=r);this.tokens=n,this.strict=i.strict!==!1,this.autoLowercase=i.autoLowercase??!1,this.pattern="",this.compile(t)}static format(t,e,i={}){return!e||Array.isArray(e)&&e.length===0?t??"":new u(e,i||{}).format(t??"")}compile(t){if(t!==void 0&&(Array.isArray(t)?(this.patterns=t.slice(0,32).map(s=>String(s??"").slice(0,512)),this.pattern=this.patterns[0]||""):(this.patterns=[],this.pattern=String(t??"").slice(0,512))),this.patterns.length>0)return this.subEngines=this.patterns.map(s=>new u(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 e="",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&&Object.hasOwn(this.tokens,n)?this.tokens[n]:void 0;r?(i=!1,this.slots.push({char:n,isStatic:!1,isPrefix:!1,token:r,placeholder:this.placeholderChar}),e+=this.placeholderChar):(this.slots.push({char:n,isStatic:!0,isPrefix:i,placeholder:n}),e+=n)}this.fullMaskTemplate=e,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(t){if(this.subEngines.length<=1)return this;let e=String(t??""),i=this.subEngines.filter(a=>{let l=a.getPrefix();return l.length>0&&e.toLowerCase().startsWith(l.trim().toLowerCase())}),s=i.length>0?i:this.subEngines,n=s.toSorted((a,l)=>l.getEditableCount()-a.getEditableCount())[0],r=(n?n.extractRaw(e):e).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(t=>t.getEditableCount())):this.activeEngine?this.activeEngine.getEditableCount():this.slots.filter(t=>!t.isStatic).length}isNumericOnly(){if(this.subEngines.length>0)return this.subEngines.every(i=>i.isNumericOnly());let e=(this.activeEngine?this.activeEngine.slots:this.slots).filter(i=>!i.isStatic);return e.length===0?!1:e.every(i=>i.char==="9"||i.token&&i.token.pattern.test("0")&&!i.token.pattern.test("a")&&!i.token.pattern.test("Z"))}setStrict(t){this.strict=t;for(let e of this.subEngines)e.setStrict(t)}setAutoLowercase(t){this.autoLowercase=t;for(let e of this.subEngines)e.setAutoLowercase(t)}isStrict(){return this.strict}extractRaw(t){if(this.subEngines.length>0){let r=this.selectEngine(t);if(r!==this)return r.extractRaw(t)}let e=Math.max(4096,this.slots.length*4),i=String(t??"").slice(0,e);if(!i)return"";let s="",n=0,o=0;if(this.prefixSlotsCount>0){for(;n<i.length&&(i[n]===" "||i[n]===" ");)n++;let r=0;for(;n<i.length&&r<this.prefixSlotsCount;){let a=this.slots[r].char,l=i[n];if(l.toUpperCase()===a.toUpperCase())n++,r++;else if(a===" "&&l!==" ")r++;else break}o=this.prefixSlotsCount}for(;n<i.length&&o<this.slots.length;){let r=this.slots[o],a=i[n];if(r.isStatic)a.toUpperCase()===r.char.toUpperCase()&&n++,o++;else if(r.token&&r.token.pattern.test(a)){let l=r.token.transform?r.token.transform(a):a;this.autoLowercase&&!r.token.transform&&(l=l.toLowerCase()),s+=l,n++,o++}else this.strict?n++:(s+=this.autoLowercase?a.toLowerCase():a,n++,o++)}if(!this.strict&&n<i.length){let r=i.slice(n);s+=this.autoLowercase?r.toLowerCase():r}return s}format(t){if(this.subEngines.length>0){let r=this.selectEngine(t);if(r!==this)return r.format(t)}let e=Math.max(4096,this.slots.length*4),i=String(t??"").slice(0,e);if(!this.slots.length)return i;let s=this.extractRaw(i);if(s.length===0)return this.prefixString;let n="",o=0;for(let r=0;r<this.slots.length;r++){let a=this.slots[r];if(a.isStatic){let l=o<s.length,d=o===0&&!!a.isPrefix,c=o>0&&o===s.length;if(l||d||c)n+=a.char;else break}else if(o<s.length){let l=s[o],d=a.token?.transform?a.token.transform(l):l;this.autoLowercase&&!a.token?.transform&&(d=d.toLowerCase()),n+=d,o++}else break}if(!this.strict&&o<s.length){let r=s.substring(o);n+=this.autoLowercase?r.toLowerCase():r}return n}getRemainingMask(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getRemainingMask(t):this.fullMaskTemplate?t.length>=this.fullMaskTemplate.length?t:t+this.fullMaskTemplate.substring(t.length):""}mapCursorPosition(t,e,i){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.mapCursorPosition(t,e,i);let s=this.prefixSlotsCount,n=String(t??""),o=String(i??"");if(e<=0||!o)return s;let a=this.extractRaw(n.slice(0,e)).length;if(a===0)return Math.max(s,Math.min(this.getNextEditablePosition(0),o.length));let l=0,d=o.length;for(let c=0;c<o.length&&c<this.slots.length;c++)if(!this.slots[c].isStatic&&(l++,l===a)){d=c+1;break}for(;d<o.length&&this.slots[d]&&this.slots[d].isStatic;)d++;return Math.max(s,Math.min(d,o.length))}isSeparatorAt(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.isSeparatorAt(t):t>=0&&t<this.slots.length?this.slots[t].isStatic:!1}getNextEditablePosition(t){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.getNextEditablePosition(t);let e=Math.max(0,t);for(let i=e;i<this.slots.length;i++)if(!this.slots[i].isStatic)return i;return this.slots.length}getSlotAt(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlotAt(t):this.slots[t]}getSlots(){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlots():this.slots}};var V=class{stack=[];index=-1;maxDepth;constructor(t=50){this.maxDepth=t}push(t,e){let i=this.getCurrent();if(i&&i.raw===t){i.cursor=e;return}this.stack=this.stack.slice(0,this.index+1),this.stack.push({raw:t,cursor:e}),this.stack.length>this.maxDepth&&this.stack.shift(),this.index=this.stack.length-1}updateCurrentCursor(t){let e=this.getCurrent();e&&(e.cursor=t)}undo(){return this.canUndo()?(this.index--,this.stack[this.index]):null}redo(){return this.canRedo()?(this.index++,this.stack[this.index]):null}canUndo(){return this.index>0}canRedo(){return this.index>=0&&this.index<this.stack.length-1}getCurrent(){return this.index>=0&&this.index<this.stack.length?this.stack[this.index]:null}clear(){this.stack=[],this.index=-1}};var Z=class{delegate;constructor(t){this.delegate=t}handleKeyDown(t){if(H(t))return;let e=this.delegate.getInput(),i=this.delegate.getEngine(),s=this.delegate.getHistory(),n=i.getPrefixLength(),o=e.selectionStart??0,r=e.selectionEnd??o;if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")&&!t.shiftKey){t.preventDefault(),this.delegate.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")||(t.ctrlKey||t.metaKey)&&t.shiftKey&&(t.key==="z"||t.key==="Z")){t.preventDefault(),this.delegate.redo();return}s.updateCurrentCursor(o);let a=t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey,l=r>o;if(a&&!l){let h=i.getSlots(),p=o<h.length&&h[o].isStatic&&h[o].char===t.key,f=o>0&&o-1<h.length&&h[o-1].isStatic&&h[o-1].char===t.key;if(p||f){t.preventDefault();let g=p?o:o-1,b=i.getNextEditablePosition(g+1);this.delegate.applyMask(e.value,b,!0);return}let m=-1;for(let g=o;g<h.length;g++)if(h[g].isStatic){h[g].char===t.key&&(m=g);break}if(m!==-1){t.preventDefault();let g=m-1;for(;g>=n&&!h[g].isStatic;)g--;g++;let b=m-g,I=e.value.slice(g,o);if(h.slice(g,m).every(T=>!T.token||T.token.pattern.test("0"))&&b>I.length&&I.length>0){let T=b-I.length,A="0".repeat(T)+I,w=e.value.slice(m),M=e.value.slice(0,g)+A+w,v=i.getNextEditablePosition(m+1);this.delegate.applyMask(M,v,!0);return}let E=i.getNextEditablePosition(m+1);this.delegate.applyMask(e.value,E,!0);return}}if(a&&i.isStrict()){let h=i.getEditableCount();if(h>0){let p=i.extractRaw(e.value),f=h-p.length;if(r>o){let m=i.extractRaw(e.value.slice(o,r));f=h-(p.length-m.length)}if(f<=0){t.preventDefault();return}}}if(r>o){if(t.key==="Backspace"||t.key==="Delete"){t.preventDefault();let h=e.value,p=h.slice(0,o)+h.slice(r);this.delegate.applyMask(p,Math.max(n,o));return}return}if(t.key==="ArrowLeft"&&!t.shiftKey&&o<=n){t.preventDefault(),e.setSelectionRange(n,n);return}if(t.key==="Home"&&n>0&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey){t.preventDefault(),e.setSelectionRange(n,n);return}if(t.key==="Backspace"&&o<=n){t.preventDefault(),e.setSelectionRange(n,n);return}if(t.key==="Delete"&&o<n){t.preventDefault(),e.setSelectionRange(n,n);return}if(t.key==="Backspace"&&(t.ctrlKey||t.altKey||t.metaKey)){if(t.preventDefault(),o<=n){e.setSelectionRange(n,n);return}let h=o-1;for(;h>=n&&i.isSeparatorAt(h);)h--;for(;h>=n&&!i.isSeparatorAt(h);)h--;let p=Math.max(n,h+1),f=e.value,m=f.slice(0,p)+f.slice(o);this.delegate.applyMask(m,p);return}if(t.key==="Delete"&&(t.ctrlKey||t.altKey||t.metaKey)){t.preventDefault();let h=e.value;if(o>=h.length)return;let p=o;for(;p<h.length&&i.isSeparatorAt(p);)p++;for(;p<h.length&&!i.isSeparatorAt(p);)p++;for(;p<h.length&&i.isSeparatorAt(p);)p++;let f=p,m=h.slice(0,o)+h.slice(f);this.delegate.applyMask(m,o);return}if(t.key==="Backspace"&&o>n){if(i.isSeparatorAt(o-1)){t.preventDefault();let h=o-1;for(;h>n&&i.isSeparatorAt(h-1);)h--;if(h>n){let p=e.value,f=p.slice(0,h-1)+p.slice(o);this.delegate.applyMask(f,h-1)}else this.delegate.applyMask("",n)}return}if(t.key==="Delete"&&o<e.value.length){if(i.isSeparatorAt(o)){t.preventDefault();let h=o;for(;h<e.value.length&&i.isSeparatorAt(h);)h++;if(h<e.value.length){let p=e.value,f=p.slice(0,h)+p.slice(h+1);this.delegate.applyMask(f,o)}}return}}handleKeyUp(t){let e=this.delegate.getInput(),i=this.delegate.getHistory();(t.key==="ArrowLeft"||t.key==="ArrowRight"||t.key==="Home")&&!t.shiftKey&&this.delegate.enforceMinCursor(),i.updateCurrentCursor(e.selectionStart??0)}};var st=class extends O{engine;history;keyboard;isComposing=!1;isUndoingRedoing=!1;isMouseDown=!1;isApplyingMask=!1;lastValue="";lastInternalRemainingMask="";isNotifying=!1;hasPendingNotification=!1;onChangeNativeHandler=()=>{};wasInputModeInferred=!1;cutTimerId=null;pasteTimerId=null;resetTimerId=null;constructor(t,e,i){let s=$(t,e,i),n=s.wrapper,o=s.input,r=s.options,a=n?.getAttribute("data-mask")||o?.getAttribute("data-mask"),l=r.mask||a||"";typeof l=="string"&&l.includes("|")&&(l=l.split("|").map(E=>E.trim()));let d=r.placeholderChar||n?.getAttribute("data-mask-placeholder")||o?.getAttribute("data-mask-placeholder")||"_",c=n?.hasAttribute("data-disabled")||o?.hasAttribute("data-disabled"),h=n?.getAttribute("data-mask-strict")||o?.getAttribute("data-mask-strict"),p=n?.getAttribute("data-mask-auto-lowercase")==="true"||o?.getAttribute("data-mask-auto-lowercase")==="true",f=n?.getAttribute("data-mask-infer-inputmode")??o?.getAttribute("data-mask-infer-inputmode"),m=r.inferInputMode??(f!==null?f!=="false":!0),{disabled:g,...b}=r,I=g!==void 0?g:c?!0:!l||Array.isArray(l)&&l.length===0,y={...b,mask:l,placeholderChar:d,strict:r.strict??(h!==null?h!=="false":!0),autoLowercase:r.autoLowercase??p??!1,disabled:I,resetHistoryOnMaskChange:r.resetHistoryOnMaskChange??!1,inferInputMode:m,onInput:r.onInput||r.oninput,onChange:r.onChange||r.onchange,onComplete:r.onComplete||r.oncomplete};super(n,o,y),this.history=new V,this.engine=new G(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new Z({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(E,T,A)=>this.applyMask(E,T,A),undo:()=>this.undo(),redo:()=>this.redo(),enforceMinCursor:()=>this.enforceMinCursor()}),this.bindEvents(),this.lastValue=this.isPasswordInput()?this.computePasswordDigest(this.input.value):this.input.value,this.syncInitialValue(),this.runAuditWarning(this.options.audit)}getSpecificAuditWarnings(){let t=[],e=[],i=this.checkAriaIdReferences(this.input,"aria-describedby",e),s=!!this.input.getAttribute("placeholder")?.trim(),n=!!this.input.getAttribute("aria-placeholder")?.trim();return!i&&!s&&!n&&!this.options.disabled&&t.push("Indication du format attendu manquante : d\xE9finissez aria-describedby, placeholder ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2)."),t}extractRawSnippet(t){return this.engine.extractRaw(t)}onPasswordModeDetected(){this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask")}static format(t,e,i={}){return G.format(t,e,i)}onNativeValueSet(t){this.options.disabled?this.checkValueChange():this.applyMask(t,t.length)}onDisabledChange(t){t?(this.wrapper.removeAttribute("data-mask"),this.wrapper.classList.remove("is-complete","has-selection"),this.clearGhost(),this.checkValueChange()):this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length),this.syncInferredInputMode()}bindEvents(){this.handleInput=this.handleInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onClick=this.onClick.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onSelect=this.onSelect.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onScroll=this.onScroll.bind(this),this.onBeforeInput=this.onBeforeInput.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,!this.isDestroyed)if(this.options.disabled)this.checkValueChange();else{let e=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,e)}},0)},this.onChangeNativeHandler=()=>{this.isDestroyed||this.checkValueChange()};let{signal:t}=this.abortController;this.input.addEventListener("beforeinput",this.onBeforeInput,{signal:t}),this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.onKeyDown,{signal:t}),this.input.addEventListener("paste",this.onPaste,{signal:t}),this.input.addEventListener("focus",this.onFocus,{signal:t}),this.input.addEventListener("blur",this.onBlur,{signal:t}),this.input.addEventListener("click",this.onClick,{signal:t}),this.input.addEventListener("keyup",this.onKeyUp,{signal:t}),this.input.addEventListener("select",this.onSelect,{signal:t}),this.input.addEventListener("mousedown",this.onMouseDown,{signal:t}),window.addEventListener("mouseup",this.onMouseUp,{signal:t}),this.input.addEventListener("compositionstart",this.onCompositionStart,{signal:t}),this.input.addEventListener("compositionend",this.onCompositionEnd,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("change",this.onChangeNativeHandler,{signal:t}),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled?this.checkValueChange():this.syncInitialValue())},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:t}))}syncInferredInputMode(){if(!this.options.inferInputMode)return;!this.options.disabled&&this.engine.isNumericOnly()?this.input.hasAttribute("inputmode")||(this.input.inputMode="numeric",this.wasInputModeInferred=!0):this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&(this.input.removeAttribute("inputmode"),this.wasInputModeInferred=!1)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.pasteTimerId!==null&&(clearTimeout(this.pasteTimerId),this.pasteTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&this.input.removeAttribute("inputmode"),this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",super.destroy())}setStrict(t){this.options.strict=t,this.engine.setStrict(t),this.options.disabled||this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}isStrict(){return this.engine.isStrict()}setMask(t,e){let i=typeof e=="boolean"?e:e&&typeof e=="object"&&e.strict!==void 0?e.strict:this.options.strict,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=i,this.engine.setStrict(i??!0),this.engine.compile(""),s&&this.history.clear(),this.setDisabled(!0),this.syncInferredInputMode();return}this.options.mask=t,this.options.strict=i,this.engine.setStrict(i??!0),this.engine.compile(t),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 i=Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(e===i)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.setAutoLowercase(this.options.autoLowercase),this.engine.compile(this.options.mask||""),this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)):t==="placeholder"&&this.updateGhost(this.input.value)}setValue(t){let e=t!=null?String(t):"";if(this.options.disabled){this.input.value=e,this.checkValueChange();return}this.applyMask(e,e.length)}getRawValue(){return this.engine.extractRaw(this.input.value)}isComplete(){return this.options.disabled?!0:this.getRawValue().length>=this.engine.getEditableCount()}get onInput(){return this.options.onInput}set onInput(t){this.options.onInput=t}undo(){if(this.options.disabled)return;let t=this.history.undo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}redo(){if(this.options.disabled)return;let t=this.history.redo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}checkSelection(){if(this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,i=t!==e;this.wrapper.classList.toggle("has-selection",i)}onBeforeInput(t){if(!this.options.disabled&&!this.isComposing&&this.engine.isStrict()&&!(t.inputType==="insertFromPaste"||t.inputType==="insertReplacementText")&&t.inputType&&t.inputType.startsWith("insert")){let e=this.engine.getEditableCount();if(e>0){let i=this.getRawValue(),s=this.input.selectionStart??0,n=this.input.selectionEnd??s,o=Math.max(0,e-i.length);if(n>s){let r=this.engine.extractRaw(this.input.value.slice(s,n));o=Math.max(0,e-(i.length-r.length))}o<=0&&t.preventDefault()}}}handleInput(t){if(this.isDispatchingNativeInput||this.isComposing)return;let e=!!(this.options.onInput||this.options.oninput),i=this.isPasswordInput()?this.computePasswordDigest(this.input.value):this.input.value;if(e&&i!==this.lastValue&&this.checkValueChange(),this.options.disabled){this.checkValueChange();return}let 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){this.pasteTimerId!==null&&clearTimeout(this.pasteTimerId),this.pasteTimerId=window.setTimeout(()=>{this.pasteTimerId=null,this.isDestroyed||this.checkValueChange()},0);return}t.preventDefault(),this.history.updateCurrentCursor(this.input.selectionStart??0);let i=(t.clipboardData?.getData("text")||"").slice(0,4096).trim();if(!i)return;let s=this.engine.getPrefixLength(),n=this.input.selectionStart??0,o=this.input.selectionEnd??n,r=this.input.value,a=this.engine.getEditableCount(),l=this.getRawValue(),c=this.engine.getPrefix().replace(/[\s.-]+/g,"").toUpperCase(),h=i.replace(/[\s.-]+/g,"").toUpperCase(),p=c.length>0&&h.startsWith(c),f=r.slice(0,Math.max(s,n)).replace(/[\s.-]+/g,"").toUpperCase(),m=f.length>=2&&h.startsWith(f),g=Math.max(s,n),b=Math.max(s,o);(p||m)&&(g=0,b=r.length);let I=Math.max(0,a-l.length);if(g!==b){let T=this.engine.extractRaw(r.slice(g,b));I=Math.max(0,a-(l.length-T.length))}if(this.engine.isStrict()&&I<=0)return;let y,E;g===0&&b===r.length?(y=i,E=i.length):(y=r.slice(0,g)+i+r.slice(b),E=g+i.length),this.applyMask(y,E),this.checkSelection()}onFocus(){this.syncGhostStyles(),this.wrapper.classList.add("is-focused"),!this.options.disabled&&!this.isMouseDown&&this.enforceMinCursor(),this.updateGhost(this.input.value),this.checkSelection()}onBlur(){if(this.wrapper.classList.remove("is-focused","has-selection"),this.isPasswordInput()){this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask");return}this.updateGhost(this.input.value)}onClick(){this.options.disabled||this.enforceMinCursor(),this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onKeyUp(t){this.options.disabled||this.keyboard.handleKeyUp(t),this.checkSelection()}onSelect(){this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t),this.checkSelection()}enforceMinCursor(){let t=this.engine.getPrefixLength();if(t<=0)return;let e=this.input.selectionStart??0,i=this.input.selectionEnd??e;e===i&&e<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled||this.isPasswordInput()){this.clearGhost();return}let e=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(e)){this.clearGhost();return}let i=this.engine.getFullMaskTemplate(),s=i.length>t.length?i.substring(t.length):"",n=this.input.ownerDocument||document,o=n.createElement("span");o.className="mask-ghost-typed",o.textContent=t;let r=n.createElement("span");r.className="mask-ghost-remaining",r.textContent=s,this.setGhostContent(o,r),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,i=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let s="",n=!1;try{s=this.engine.format(t);let o=this.engine.getRemainingMask(s),r=this.isPasswordInput();this.input.value=s,r?(this.lastInternalRemainingMask="",this.wrapper.removeAttribute("data-mask"),this.clearGhost()):(this.lastInternalRemainingMask=o,this.wrapper.setAttribute("data-mask",o),this.updateGhost(s));let a=this.engine.getPrefixLength(),l;if(i||this.isUndoingRedoing)l=Math.max(a,Math.min(e,s.length));else{let d=this.engine.mapCursorPosition(t,e,s);l=Math.max(a,d)}this.input.setSelectionRange(l,l),n=this.isComplete(),this.wrapper.classList.toggle("is-complete",n),r?(this.options.copyRaw=!1,this.history.clear()):this.isUndoingRedoing||this.history.push(this.getRawValue(),l)}finally{this.isApplyingMask=!1}this.checkValueChange()}syncInitialValue(){let t=this.isPasswordInput();if(this.options.disabled){this.wrapper.removeAttribute("data-mask"),this.clearGhost(),this.lastValue=t?this.computePasswordDigest(this.input.value):this.input.value,this.checkValueChange();return}this.syncGhostStyles();let e=this.input.value||"";if(e)this.applyMask(e,e.length);else{let i=this.engine.getPrefixLength();if(i>0)this.applyMask("",i);else{if(t)this.lastInternalRemainingMask="",this.wrapper.removeAttribute("data-mask"),this.clearGhost();else{this.history.push("",0);let s=this.engine.getFullMaskTemplate();this.lastInternalRemainingMask=s,this.wrapper.setAttribute("data-mask",s),this.updateGhost("")}this.checkValueChange()}}}checkValueChange(t=!1){let e=this.isPasswordInput(),i=this.input.value;if(!((e?this.computePasswordDigest(i):i)===this.lastValue&&!t&&!this.hasPendingNotification)){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{let n=0,o=10;for(;((e?this.computePasswordDigest(this.input.value):this.input.value)!==this.lastValue||this.hasPendingNotification||t)&&n<o;){n++,this.hasPendingNotification=!1,t=!1;let r=this.input.value;this.lastValue=e?this.computePasswordDigest(r):r;let a=this.options.disabled?r:this.getRawValue(),l=this.options.disabled?0:this.engine.getEditableCount(),d=this.isComplete(),c={value:r,rawValue:a,isComplete:d,totalSlots:l,filledSlots:this.options.disabled?r.length:a.length},h=this.options.onInput||this.options.oninput;h&&h(r,c),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:c})),this.dispatchNativeInput();let p=this.options.onChange||this.options.onchange;p&&p(c),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:c}));let f=this.options.onComplete||this.options.oncomplete;d&&(f&&f(c),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:!0,detail:c})))}}finally{this.isNotifying=!1}}}};var q=class u{options;constructor(t={}){let e=t.currency??"";!e&&t.unit&&(e=t.unit);let i=e==="$"||e==="\xA3"||e==="\xA5"?"prefix":"suffix",s=t.decimals!==void 0?Number(t.decimals):2,n=Number.isFinite(s)?Math.min(20,Math.max(0,Math.floor(s))):2;this.options={currency:String(e).slice(0,32),unit:String(t.unit??e).slice(0,32),currencyPosition:t.currencyPosition??i,decimals:n,decimalSeparator:String(t.decimalSeparator??",").slice(0,4)||",",thousandSeparator:String(t.thousandSeparator??"\xA0").slice(0,4),allowNegative:t.allowNegative??!1,min:t.min??-1/0,max:t.max??1/0}}parse(t){let e=String(t??"").slice(0,512).trim(),i=!1;this.options.allowNegative&&e.includes("-")&&(i=!0),this.options.currency&&(e=e.replace(new RegExp(this.escapeRegExp(this.options.currency),"g"),"")),this.options.thousandSeparator&&(e=e.replace(new RegExp(this.escapeRegExp(this.options.thousandSeparator),"g"),"")),e=e.replace(/[\s\u00A0]/g,"");let s=this.options.decimalSeparator,n=e.indexOf(s);n===-1&&(n=e.search(/[,.]/));let o="",r=null,a=!1;return n!==-1?(o=e.substring(0,n).replace(/\D/g,""),this.options.decimals>0&&(a=!0,r=e.substring(n+1).replace(/\D/g,"").slice(0,this.options.decimals))):o=e.replace(/\D/g,""),o.length>1&&(o=o.replace(/^0+/,"")||"0"),{isNegative:i,integerPart:o,decimalPart:r,hasDecimal:a}}format(t,e=t.length,i=!1){let s=String(t??"").slice(0,512),n=Math.max(0,Math.min(e,s.length));if(!s||s.trim()===""||s===this.options.currency.trim())return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let o=s.substring(0,n),r=o.replace(/\D/g,"").length,a=this.options.decimals>0&&/[,.]/.test(o),{isNegative:l,integerPart:d,decimalPart:c,hasDecimal:h}=this.parse(s),p=c,f=h;if(i&&this.options.decimals>0&&(d||c!==null)&&(f=!0,p===null?p="0".repeat(this.options.decimals):p.length<this.options.decimals&&(p=p+"0".repeat(this.options.decimals-p.length))),l&&!d&&!p&&!f&&this.options.allowNegative){let S="-",P=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(S=`${this.options.currency} -`,P=S.length):(S=`- ${this.options.currency}`,P=1)),{formatted:S,rawNumber:null,rawValue:"-",cursor:P,isValid:!0}}if(!d&&!p&&!f)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let g=this.formatThousands(d||"0");f&&this.options.decimals>0&&(g+=this.options.decimalSeparator+(p??"")),l&&g!=="0"&&(g="-"+g);let b=g;this.options.currency&&(this.options.currencyPosition==="prefix"?b=`${this.options.currency} ${g}`:b=`${g} ${this.options.currency}`);let I=(l?"-":"")+(d||"0")+(c?"."+c:""),y=parseFloat(I);isNaN(y)&&(y=0);let E=y>=this.options.min&&y<=this.options.max,T=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(T=this.options.currency.length+1);let A=0,w=!1,M=T;for(let S=T;S<b.length;S++){let P=b[S];if(P===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(P)?(A++,M=S+1):P===this.options.decimalSeparator&&(w=!0,M=S+1),a){if(w&&A>=r){T=S+1;break}}else if(A>=r){T=S+1;break}}r>0&&A<r&&M>T&&(T=M);let v=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,k=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,b.length-this.options.currency.length-1):b.length;return T=Math.max(v,Math.min(T,Math.max(v,k))),{formatted:b,rawNumber:y,rawValue:I,cursor:T,isValid:E}}static format(t,e={}){let i=new u(e),s=typeof t=="number"?t.toString():t;return i.format(s).formatted}formatThousands(t){let e=this.options.thousandSeparator;if(!e||t.length<=3)return t;let i=[],s=t.length;for(;s>0;){let n=Math.max(0,s-3);i.push(t.slice(n,s)),s=n}return i.reverse().join(e)}escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var rt=class extends O{engine;history;isUndoingRedoing=!1;isApplying=!1;isComposing=!1;lastValue="";wasInputModeInferred=!1;cutTimerId=null;resetTimerId=null;cursorTimerId=null;constructor(t,e,i){let s=$(t,e,i),n=s.wrapper,o=s.input,r=s.options,a=n?.getAttribute("data-mask-pad-decimals")==="true"||o?.getAttribute("data-mask-pad-decimals")==="true",l=o?.getAttribute("data-mask-align")||o?.getAttribute("data-align")||n?.getAttribute("data-mask-align")||n?.getAttribute("data-align"),d={align:r.align??l??"right",padDecimalsOnBlur:r.padDecimalsOnBlur??a??!1,...r};super(n,o,d),this.input.hasAttribute("inputmode")||(this.input.inputMode="decimal",this.wasInputModeInferred=!0),this.history=new V,this.engine=new q(this.options),this.bindEvents(),this.input.value?this.options.disabled||this.applyAmount(this.input.value,this.input.value.length):this.updateGhost({formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0}),this.runAuditWarning(this.options.audit)}extractRawSnippet(t){let e=this.engine.parse(t);return!e.integerPart&&!e.decimalPart?"":(e.isNegative?"-":"")+(e.integerPart||"0")+(e.decimalPart?"."+e.decimalPart:"")}onPasswordModeDetected(){this.history.clear(),this.lastValue="",this.lastTrackedValue="",this.clearGhost()}static format(t,e={}){return q.format(t,e)}onNativeValueSet(t){if(this.options.disabled||this.isComposing){this.lastValue=t;return}this.applyAmount(t,t.length)}onDisabledChange(t){t?this.clearGhost():this.applyAmount(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleClick=this.handleClick.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,this.isDestroyed||this.options.disabled)return;let e=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,e)},0)};let{signal:t}=this.abortController;this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.handleKeyDown,{signal:t}),this.input.addEventListener("blur",this.handleBlur,{signal:t}),this.input.addEventListener("focus",this.handleFocus,{signal:t}),this.input.addEventListener("click",this.handleClick,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("compositionstart",this.onCompositionStart,{signal:t}),this.input.addEventListener("compositionend",this.onCompositionEnd,{signal:t}),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled||this.applyAmount(this.input.value,this.input.value.length))},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:t}))}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)}applyAmount(t,e){if(!(this.isApplying||this.options.disabled)){this.isApplying=!0;try{let i=this.engine.format(t,e);this.setNativeValue(i.formatted),this.input.setSelectionRange(i.cursor,i.cursor);let s=this.isPasswordInput();s?(this.options.copyRaw=!1,this.history.clear(),this.clearGhost()):(this.isUndoingRedoing||this.history.push(i.rawValue,i.cursor),this.updateGhost(i));let n=s?this.computePasswordDigest(i.formatted):i.formatted;this.lastValue!==n&&(this.lastValue=n,this.notifyChange(i))}finally{this.isApplying=!1}}}updateGhost(t){if(this.ghost){if(!t.formatted){if(this.shouldHideGhostForPlaceholder(!0)){this.clearGhost();return}let e=this.options.currency?this.options.currencyPosition==="prefix"?`${this.options.currency} 0`:`0 ${this.options.currency}`:"0,00",s=(this.input.ownerDocument||document).createElement("span");s.className="mask-ghost-remaining",s.textContent=e,this.setGhostContent(s);return}this.clearGhost(),this.ghost.scrollLeft=this.input.scrollLeft}}handleInput(){if(this.isDispatchingNativeInput||this.options.disabled||this.isComposing)return;let t=this.input.value,e=this.input.selectionStart??t.length;this.applyAmount(t,e)}handleKeyDown(t){if(!(this.options.disabled||H(t))){if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")){t.preventDefault(),t.shiftKey?this.redo():this.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")){t.preventDefault(),this.redo();return}if(t.key==="Backspace"){let e=this.input.selectionStart??0,i=this.input.selectionEnd??0;if(e===i&&e>0){let s=this.input.value,n=s[e-1];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let o=Math.max(0,e-2),r=s.slice(0,o)+s.slice(e);this.applyAmount(r,o);return}if(this.options.currency&&this.options.currencyPosition==="prefix"&&e<=this.options.currency.length+1){t.preventDefault();return}}}if(t.key==="Delete"){let e=this.input.selectionStart??0,i=this.input.selectionEnd??0;if(e===i&&e<this.input.value.length){let s=this.input.value,n=s[e];if(n===this.engine.options.thousandSeparator||n===" "){t.preventDefault();let o=s.slice(0,e)+s.slice(e+2);this.applyAmount(o,e);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let o=s.length-this.options.currency.length-1;if(e>=o){t.preventDefault();return}}}}(t.key==="ArrowLeft"||t.key==="ArrowRight"||t.key==="Home"||t.key==="End")&&(this.cursorTimerId!==null&&clearTimeout(this.cursorTimerId),this.cursorTimerId=window.setTimeout(()=>{this.cursorTimerId=null,this.enforceCursorBounds()},0))}}enforceCursorBounds(){if(this.isDestroyed||!this.isFocused||document.activeElement!==this.input||!this.input.value||this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??0;if(t!==e)return;let i=this.input.value,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,i.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.isPasswordInput()){this.history.clear(),this.lastValue="",this.lastTrackedValue="",this.clearGhost();return}if(this.options.padDecimalsOnBlur&&!this.options.disabled&&this.input.value.trim().length>0){let e=this.engine.format(this.input.value,this.input.value.length,!0);e.formatted!==this.input.value&&(this.setNativeValue(e.formatted),this.lastValue=e.formatted)}this.updateGhost(this.engine.format(this.input.value));let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){super.handleAttributeMutation(t),t==="data-mask-pad-decimals"?this.options.padDecimalsOnBlur=this.getAttr("data-mask-pad-decimals")==="true":t==="placeholder"&&this.updateGhost(this.engine.format(this.input.value))}notifyChange(t){let e={value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid};this.options.onInput&&this.options.onInput(e),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:e})),this.dispatchNativeInput()}undo(){let t=this.history.undo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}redo(){let t=this.history.redo();if(t){this.isUndoingRedoing=!0;try{this.applyAmount(t.raw,t.cursor)}finally{this.isUndoingRedoing=!1}}}getDetail(){let t=this.engine.format(this.input.value);return{value:t.formatted,number:t.rawNumber,rawValue:t.rawValue,isValid:t.isValid}}getNumber(){return this.getDetail().number}getRawValue(){return this.getDetail().rawValue}isValid(){return this.getDetail().isValid}setValue(t){let e=t!=null?String(t):"";this.options.disabled?(this.setNativeValue(e),this.lastValue=e):this.applyAmount(e,e.length)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.cursorTimerId!==null&&(clearTimeout(this.cursorTimerId),this.cursorTimerId=null),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="decimal"&&this.input.removeAttribute("inputmode"),this.lastValue="",this.history.clear(),super.destroy())}};var J=class u{domains;tlds;suggestOnAt;defaultDomain=null;defaultTld="__";static DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"];static DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];constructor(t={}){this.domains=t.domains&&t.domains.length>0?t.domains:u.DEFAULT_DOMAINS,this.tlds=t.tlds&&t.tlds.length>0?t.tlds.slice(0,200).map(e=>String(e).trim().replace(/^\./,"").slice(0,32)).filter(Boolean):[...u.DEFAULT_TLDS],this.suggestOnAt=t.suggestOnAt??!0,this.setDefaultDomain(t.defaultDomain??null),this.setDefaultTld(t.defaultTld!==void 0?t.defaultTld:"__")}setDefaultDomain(t){t===!0?this.defaultDomain=this.domains.length>0?this.domains[0]:null:typeof t=="string"&&t.trim().length>0?this.defaultDomain=t.trim().replace(/^@/,""):this.defaultDomain=null}setDefaultTld(t){t===!0?this.defaultTld=this.tlds.length>0?this.tlds[0]:null:typeof t=="string"&&t.trim().length>0?this.defaultTld=t.trim().replace(/^\./,""):this.defaultTld=null}setTlds(t){this.tlds=t&&t.length>0?t.slice(0,200).map(e=>String(e).trim().replace(/^\./,"").slice(0,32)).filter(Boolean):[...u.DEFAULT_TLDS]}getMatchingTlds(t){let e=(t??"").toLowerCase();return e.length===0?[...this.tlds]:this.tlds.filter(i=>i.toLowerCase().startsWith(e)&&i.toLowerCase()!==e)}getMatchingDomains(t){let e=String(t??"").slice(0,512);if(!e.includes("@"))return this.defaultDomain?[this.defaultDomain]:[];let i=e.indexOf("@");if(e.indexOf("@",i+1)!==-1)return[];let s=e.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(t,e=0){let i=String(t??"").slice(0,512);if(!i.includes("@"))return this.defaultDomain?{full:i?`${i}@${this.defaultDomain}`:`@${this.defaultDomain}`,remaining:`@${this.defaultDomain}`,matchedDomain:this.defaultDomain,isHintOnly:!1}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let 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,isHintOnly:!1};let r=this.getMatchingDomains(t);if(r.length>0){let f=(e%r.length+r.length)%r.length,m=r[f],g=o.toLowerCase(),b=m.substring(g.length);return{full:`${n}@${m}`,remaining:b,matchedDomain:m,isHintOnly:!1}}if(o.length===0||o.startsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let a=o.toLowerCase();if(this.domains.some(f=>f.toLowerCase()===a))return{full:i,remaining:"",matchedDomain:o,isHintOnly:!1};let l=o.lastIndexOf(".");if(l===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let f=this.defaultTld.includes("_"),m=`.${this.defaultTld}`,g=`${o}.${this.defaultTld}`;return{full:f?i:`${n}@${g}`,remaining:m,matchedDomain:f?null:g,isHintOnly:f}}let d=o.substring(0,l),c=o.substring(l+1);if(!d||d.endsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};if(c.length===0){if(this.defaultTld&&!this.defaultTld.includes("_")){let f=`${d}.${this.defaultTld}`;return{full:`${n}@${f}`,remaining:this.defaultTld,matchedDomain:f,isHintOnly:!1}}return this.defaultTld&&this.defaultTld.includes("_")?{full:i,remaining:this.defaultTld,matchedDomain:null,isHintOnly:!0}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}let h=c.toLowerCase();if(this.tlds.some(f=>f.toLowerCase()===h))return{full:i,remaining:"",matchedDomain:o,isHintOnly:!1};let p=this.getMatchingTlds(c);if(p.length>0){let f=(e%p.length+p.length)%p.length,m=p[f],g=m.substring(h.length),b=`${d}.${m}`;return{full:`${n}@${b}`,remaining:g,matchedDomain:b,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&c.length<this.defaultTld.length){let f=this.defaultTld.substring(c.length);if(f.includes("_"))return{full:i,remaining:f,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};var at=class extends O{engine;currentSuggestion={full:"",remaining:"",matchedDomain:null};currentSuggestionIndex=0;wasAriaAutocompleteSet=!1;wasAutocorrectSet=!1;wasAutocapitalizeSet=!1;wasSpellcheckSet=!1;wasInputModeInferred=!1;isComposing=!1;lastNotifiedValue="";srStatusEl=null;srAnnounceTimerId=null;lastAnnouncedSuggestion="";cutTimerId=null;resetTimerId=null;constructor(t,e,i){let s=$(t,e,i),n=s.wrapper,o=s.input,r=s.options,a=n?.getAttribute("data-mask-cycle-suggestions")==="true"||o?.getAttribute("data-mask-cycle-suggestions")==="true",l=n?.getAttribute("data-mask-auto-lowercase")==="true"||o?.getAttribute("data-mask-auto-lowercase")==="true",d=n?.getAttribute("data-mask-aria-autocomplete")??o?.getAttribute("data-mask-aria-autocomplete"),c=r.setAriaAutocomplete??(d!==null?d!=="false":!0),h=n?.getAttribute("data-mask-tlds")??o?.getAttribute("data-mask-tlds"),p=r.tlds??(h?h.split(",").map(b=>b.trim()).filter(Boolean):void 0),f=n?.getAttribute("data-mask-default-tld")??o?.getAttribute("data-mask-default-tld"),m=r.defaultTld!==void 0?r.defaultTld:f!==null?f==="false"||f==="none"?null:f==="true"?!0:f:void 0,g={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:r.cycleSuggestions??a??!1,autoLowercase:r.autoLowercase??l??!1,setAriaAutocomplete:c,...r,...p!==void 0?{tlds:p}:{},...m!==void 0?{defaultTld:m}:{}};super(n,o,g),this.input.hasAttribute("inputmode")||(this.input.inputMode="email",this.wasInputModeInferred=!0),this.input.hasAttribute("autocorrect")||(this.input.setAttribute("autocorrect","off"),this.wasAutocorrectSet=!0),this.input.hasAttribute("autocapitalize")||(this.input.setAttribute("autocapitalize","none"),this.wasAutocapitalizeSet=!0),this.input.hasAttribute("spellcheck")||(this.input.setAttribute("spellcheck","false"),this.wasSpellcheckSet=!0),this.options.setAriaAutocomplete&&!this.input.hasAttribute("aria-autocomplete")&&(this.input.setAttribute("aria-autocomplete","inline"),this.wasAriaAutocompleteSet=!0),this.engine=new J(this.options),this.lastNotifiedValue=this.isPasswordInput()?"":this.input.value,this.bindEvents(),!this.options.disabled&&!this.isPasswordInput()&&this.updateSuggestion(),this.runAuditWarning(this.options.audit)}onPasswordModeDetected(){this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.lastNotifiedValue="",this.lastTrackedValue="",this.lastAnnouncedSuggestion="",this.currentSuggestion={full:"",remaining:"",matchedDomain:null},this.srStatusEl&&(this.srStatusEl.textContent=""),this.clearGhost()}onNativeValueSet(t){this.options.disabled||this.isComposing||this.isPasswordInput()||this.updateSuggestion()}onDisabledChange(t){t||this.isPasswordInput()?this.clearGhost():this.updateSuggestion()}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{this.cutTimerId=null,!(this.isDestroyed||this.options.disabled||this.isPasswordInput())&&this.updateSuggestion()},0)};let{signal:t}=this.abortController;this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.handleKeyDown,{signal:t}),this.input.addEventListener("blur",this.handleBlur,{signal:t}),this.input.addEventListener("focus",this.handleFocus,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("compositionstart",()=>{this.isComposing=!0},{signal:t}),this.input.addEventListener("compositionend",()=>{this.isComposing=!1,!this.isDestroyed&&!this.options.disabled&&!this.isPasswordInput()&&this.handleInput()},{signal:t}),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!(this.isDestroyed||this.options.disabled||this.isPasswordInput())&&this.updateSuggestion()},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:t}))}ensureSrStatusEl(){if(this.srStatusEl&&this.wrapper.contains(this.srStatusEl))return this.srStatusEl;let t=this.input.ownerDocument||(typeof document<"u"?document:null);if(!t)return null;let e=t.createElement("span");return e.className="wulf-mask-sr-status",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.wrapper.appendChild(e),this.srStatusEl=e,e}scheduleSuggestionAnnouncement(t=!1){if(this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),!this.options.setAriaAutocomplete||!this.isFocused||this.isDestroyed||this.isPasswordInput())return;let e=this.currentSuggestion;if(!e.remaining||e.isHintOnly){this.lastAnnouncedSuggestion="",this.srStatusEl&&(this.srStatusEl.textContent="");return}let i=e.full;if(i===this.lastAnnouncedSuggestion&&!t)return;let s=()=>{if(this.srAnnounceTimerId=null,this.isDestroyed||!this.isFocused||this.isPasswordInput())return;this.lastAnnouncedSuggestion=i;let o=this.input.ownerDocument||(typeof document<"u"?document:null);if(o&&typeof o.ariaNotify=="function")try{o.ariaNotify(i,{priority:"normal"});return}catch{}let r=this.ensureSrStatusEl();r&&(r.textContent=r.textContent===i?`${i}\xA0`:i)};t?s():this.srAnnounceTimerId=window.setTimeout(s,250)}updateSuggestion(t){if(this.options.disabled||this.isPasswordInput()){this.currentSuggestion={full:"",remaining:"",matchedDomain:null},this.clearGhost();return}let e=this.input.value;if(this.currentSuggestion=this.engine.getSuggestion(e,this.currentSuggestionIndex),!this.ghost)return;if(this.shouldHideGhostForPlaceholder(e.length===0))this.clearGhost();else if(this.currentSuggestion.remaining){let s=this.input.ownerDocument||document,n=s.createElement("span");n.className="mask-ghost-typed",n.textContent=e;let o=s.createElement("span");o.className="mask-ghost-remaining",o.textContent=this.currentSuggestion.remaining,this.setGhostContent(n,o)}else this.clearGhost();this.ghost.scrollLeft=this.input.scrollLeft,t?.announce&&this.scheduleSuggestionAnnouncement(!!t.immediate);let i=this.getDetail();this.options.onInput&&this.options.onInput(i),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:!0,detail:i})),e!==this.lastNotifiedValue&&(this.lastNotifiedValue=e,this.dispatchNativeInput())}handleInput(t){if(!this.isDispatchingNativeInput&&!(this.options.disabled||this.isPasswordInput())&&!(this.isComposing||t&&"isComposing"in t&&t.isComposing)){if(this.options.autoLowercase){let e=this.input.selectionStart??0,i=this.input.selectionEnd??e,s=this.input.value.toLowerCase();s!==this.input.value&&(this.setNativeValue(s),this.input.setSelectionRange(e,i))}this.currentSuggestionIndex=0,this.updateSuggestion({announce:!0,immediate:!1})}}handleKeyDown(t){if(this.options.disabled||this.isPasswordInput()||H(t)||t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)return;let e=!!this.currentSuggestion.remaining&&!this.currentSuggestion.isHintOnly,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({announce:!0,immediate:!0});return}if(t.key==="ArrowUp"){t.preventDefault(),this.currentSuggestionIndex--,this.updateSuggestion({announce:!0,immediate:!0});return}}if(t.key==="Tab"&&e&&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(){if(this.wrapper.classList.remove("is-focused"),this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.lastAnnouncedSuggestion="",this.srStatusEl&&(this.srStatusEl.textContent=""),this.isPasswordInput()){this.lastNotifiedValue="",this.lastTrackedValue="",this.clearGhost();return}this.updateSuggestion();let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!0,detail:t}))}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask-cycle-suggestions")this.options.cycleSuggestions=this.getAttr("data-mask-cycle-suggestions")==="true";else if(t==="data-mask-auto-lowercase")this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true";else if(t==="data-mask-default-tld"){let e=this.getAttr("data-mask-default-tld");this.setDefaultTld(e===null||e==="false"||e==="none"?null:e==="true"?!0:e)}else if(t==="data-mask-tlds"){let e=this.getAttr("data-mask-tlds");this.setTlds(e?e.split(",").map(i=>i.trim()).filter(Boolean):null)}else t==="placeholder"&&this.updateSuggestion()}getDetail(){return{value:this.input.value,suggestedValue:this.currentSuggestion.isHintOnly?"":this.currentSuggestion.full,domain:this.currentSuggestion.matchedDomain}}setValue(t){let e=t!=null?String(t):"";this.setNativeValue(e),this.updateSuggestion()}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.srStatusEl&&(this.srStatusEl.remove(),this.srStatusEl=null),this.lastNotifiedValue="",this.lastAnnouncedSuggestion="",this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="email"&&this.input.removeAttribute("inputmode"),this.wasAriaAutocompleteSet&&this.input.getAttribute("aria-autocomplete")==="inline"&&this.input.removeAttribute("aria-autocomplete"),this.wasAutocorrectSet&&this.input.getAttribute("autocorrect")==="off"&&this.input.removeAttribute("autocorrect"),this.wasAutocapitalizeSet&&this.input.getAttribute("autocapitalize")==="none"&&this.input.removeAttribute("autocapitalize"),this.wasSpellcheckSet&&this.input.getAttribute("spellcheck")==="false"&&this.input.removeAttribute("spellcheck"),super.destroy())}};var Ft={BaseInputMask:O,InputMask:st,MaskEngine:G,MaskHistory:V,MaskKeyboard:Z,AmountEngine:q,InputAmountMask:rt,EmailEngine:J,InputEmailMask:at},Nt=R();Nt&&(Nt.Mask=Ft);var St=st;var It={};et(It,{LocalizedComponent:()=>x,Scroll:()=>zt,ScrollBlock:()=>Q,createI18nManager:()=>z,default:()=>ee,scrollEn:()=>kt,scrollFr:()=>Et,scrollI18n:()=>lt});var x=class extends N{static _i18n;static setLocale(t){this._i18n&&this._i18n.setLocale(t)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(t,e){this._i18n&&this._i18n.registerLocale(t,e)}static setI18n(t){this._i18n&&this._i18n.setI18n(t)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(t,e){return this._i18n?this._i18n.t(t,e):String(t)}i18nOverrides;constructor(t){super(),this.i18nOverrides=t}t(t){let e=this.constructor;return e._i18n?e._i18n.t(t,this.i18nOverrides):String(t)}};var Qt=new Set(["__proto__","constructor","prototype"]);function dt(u){return!!u&&!Qt.has(u)}function yt(u){let t=String(u??"").trim().toLowerCase().replace(/_/g,"-");return dt(t)?t:""}function te(u){let t=u.indexOf("-"),e=t>0?u.slice(0,t):null;return e&&dt(e)?e:null}function F(u,t){if(!t||typeof t!="object")return u;for(let e of Object.keys(t))dt(String(e))&&Object.hasOwn(t,e)&&t[e]!==void 0&&(u[e]=t[e]);return u}function z(u,t){let e=yt(u)||"fr",i=Object.create(null);for(let[a,l]of Object.entries(t)){let d=yt(a);d&&(i[d]=F(Object.create(null),l))}let s=e,n=Object.create(null);for(let[a,l]of Object.entries(i))n[a]=F(Object.create(null),l);let o=Object.create(null);function r(){let a=[];if(dt(s)){let d=n[s];d&&a.push(d)}let l=te(s);return l&&n[l]&&a.push(n[l]),a}return{setLocale(a){if(a&&typeof a=="string"&&a.trim()){let l=yt(a);l&&(s=l)}},getLocale(){return s},registerLocale(a,l){if(!a||typeof a!="string"||!a.trim()||!l)return;let d=yt(a);if(!d)return;let c=F(Object.create(null),n[d]);n[d]=F(c,l)},setI18n(a){if(!a||typeof a!="object")return;let l=F(Object.create(null),o);o=F(l,a)},t(a,l){if(!dt(String(a)))return"";if(l&&typeof l=="object"&&Object.hasOwn(l,a)&&l[a]!==void 0)return String(l[a]);if(o[a]!==void 0)return String(o[a]);for(let c of r())if(c[a]!==void 0)return String(c[a]);let d=n[e]||i[e];return d&&d[a]!==void 0?String(d[a]):String(a)},getAll(a){let l={},d=n[e]||i[e];F(l,d);let c=r().reverse();for(let h of c)F(l,h);return F(l,o),F(l,a),l},reset(){s=e,o=Object.create(null),n=Object.create(null);for(let[a,l]of Object.entries(i))n[a]=F(Object.create(null),l)}}}var Et={viewport:"Zone de contenu d\xE9filable",verticalThumb:"D\xE9filement vertical",horizontalThumb:"D\xE9filement horizontal"};var kt={viewport:"Scrollable content area",verticalThumb:"Vertical scroll",horizontalThumb:"Horizontal scroll"};var lt=z("fr",{fr:Et,en:kt});var Bt=0,Q=class extends x{static _i18n=lt;static i18n=lt;root;viewport;options;createdViewport=!1;isDestroyed=!1;wasIdGenerated=!1;wasRoleInferred=!1;wasAriaLabelInferred=!1;hasExplicitAriaLabel=!1;hasRootAriaLabel=!1;propagatedRootLabel=null;lastInferredAriaLabel="";trackY;thumbY;trackX;thumbX;resizeObserver;hideTimer;scrollEndFallbackTimer;rafId=null;resizeRafId=null;abortController=new AbortController;dragAbortController;activeScrollToController;supportsScrollEnd=typeof window<"u"&&"onscrollend"in window;cachedMaxTop=0;cachedMaxLeft=0;cachedTrackHeight=0;cachedThumbHeight=0;cachedTrackWidth=0;cachedThumbWidth=0;isDragging=!1;dragAxis;dragPointerId;dragStartPos=0;dragStartScroll=0;atBottom=!1;atTop=!0;atRight=!1;atLeft=!0;boundOnScroll;boundOnScrollEnd;boundOnMouseEnter;boundOnMouseLeave;boundOnFocusIn;boundOnFocusOut;boundPointerMove;boundPointerUp;constructor(t,e){super(e?.i18n);let i=null;if(typeof t=="string")try{i=document.querySelector(t)}catch{i=null}else i=t;if(!i||!(i instanceof HTMLElement))throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${t}".`);this.root=i,this.hasExplicitAriaLabel=!!(e?.ariaLabel||e?.i18n?.viewport);let s=e?.autoHideDelay,n=typeof s=="number"&&Number.isFinite(s)&&s>=0?s:1e3,o=e?.minThumbSize,r=typeof o=="number"&&Number.isFinite(o)&&o>0?o:24,a=e?.edgeThreshold,l=typeof a=="number"&&Number.isFinite(a)&&a>=0?a:10;this.options={axis:e?.axis||"y",mode:e?.mode||"custom",autoHide:e?.autoHide??!0,autoHideDelay:n,alwaysVisible:e?.alwaysVisible??!1,ariaLabel:e?.ariaLabel||this.t("viewport"),i18n:e?.i18n||{},minThumbSize:r,edgeThreshold:l,onScroll:e?.onScroll||(()=>{}),onScrollEnd:e?.onScrollEnd||(()=>{}),onTotalScroll:e?.onTotalScroll||(()=>{}),onTotalScrollBack:e?.onTotalScrollBack||(()=>{}),audit:e?.audit??!0},this.boundOnScroll=this.handleScroll.bind(this),this.boundOnScrollEnd=this.handleScrollEnd.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.mode==="native"&&this.root.classList.add("wulf-scrollblock--native"),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=Array.from(this.root.childNodes),i=document.createElement("div");i.className="wulf-scrollblock-viewport",this.root.appendChild(i);for(let s of e)it(i,s,null);return this.createdViewport=!0,i}setupAccessibility(){this.viewport.id||(Bt+=1,this.viewport.id=`wulf-scrollblock-vp-${Bt}`,this.wasIdGenerated=!0),this.viewport.hasAttribute("role")||(this.viewport.setAttribute("role","region"),this.wasRoleInferred=!0);let t=this.root.getAttribute("aria-labelledby")?.trim(),e=this.root.getAttribute("aria-label")?.trim();if(t?(this.hasRootAriaLabel=!0,!this.hasExplicitAriaLabel&&!this.viewport.hasAttribute("aria-labelledby")&&!this.viewport.hasAttribute("aria-label")&&(this.viewport.setAttribute("aria-labelledby",t),this.propagatedRootLabel="aria-labelledby")):e&&(this.hasRootAriaLabel=!0,!this.hasExplicitAriaLabel&&!this.viewport.hasAttribute("aria-label")&&!this.viewport.hasAttribute("aria-labelledby")&&(this.viewport.setAttribute("aria-label",e),this.propagatedRootLabel="aria-label")),this.hasExplicitAriaLabel&&!this.viewport.hasAttribute("aria-label"))this.viewport.setAttribute("aria-label",this.options.ariaLabel),this.lastInferredAriaLabel=this.options.ariaLabel,this.wasAriaLabelInferred=!0;else if(!this.viewport.hasAttribute("aria-label")&&!this.viewport.hasAttribute("aria-labelledby")){let i=this.t("viewport");this.viewport.setAttribute("aria-label",i),this.lastInferredAriaLabel=i,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.mode!=="native"&&((this.options.axis==="y"||this.options.axis==="both")&&(this.trackY=document.createElement("div"),this.trackY.className="wulf-scrollblock-track wulf-scrollblock-vertical",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.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")))}isRtl(){return typeof window<"u"&&window.getComputedStyle(this.viewport).direction==="rtl"}attachTrackListeners(t,e,i){let{signal:s}=this.abortController;e.addEventListener("pointerdown",n=>{if(n.button!==0)return;n.preventDefault(),n.stopPropagation(),this.dragAbortController?.abort(),this.dragAbortController=new AbortController;let o=this.dragAbortController.signal;this.isDragging=!0,this.dragAxis=i,this.dragPointerId=n.pointerId,this.dragStartPos=i==="y"?n.clientY:n.clientX,this.dragStartScroll=i==="y"?this.viewport.scrollTop:this.viewport.scrollLeft;try{e.setPointerCapture(n.pointerId)}catch{}e.classList.add("is-active"),this.root.classList.add("is-dragging"),window.addEventListener("pointermove",this.boundPointerMove,{signal:o}),window.addEventListener("pointerup",this.boundPointerUp,{signal:o}),window.addEventListener("pointercancel",this.boundPointerUp,{signal:o}),e.addEventListener("lostpointercapture",this.boundPointerUp,{signal:o})},{signal:s}),e.addEventListener("keydown",n=>{if(n.ctrlKey||n.altKey||n.metaKey)return;let o=40,r=i==="y"?Math.max(o,Math.round(this.viewport.clientHeight*.9)):Math.max(o,Math.round(this.viewport.clientWidth*.9)),a=i==="y"?this.cachedMaxTop:this.cachedMaxLeft;if(a<=0)return;let l=i==="x"&&this.isRtl(),d=i==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,c=null;if(i==="y")switch(n.key){case"ArrowDown":c=d+o;break;case"ArrowUp":c=d-o;break;case"PageDown":c=d+r;break;case"PageUp":c=d-r;break;case" ":c=d+(n.shiftKey?-r:r);break;case"Home":c=0;break;case"End":c=a;break}else switch(n.key){case"ArrowRight":c=d+o;break;case"ArrowLeft":c=d-o;break;case"PageDown":c=d+(l?-r:r);break;case"PageUp":c=d+(l?r:-r);break;case" ":c=d+(n.shiftKey?l?r:-r:l?-r:r);break;case"Home":c=0;break;case"End":c=l?-a:a;break}c!==null&&(n.preventDefault(),n.stopPropagation(),this.scrollTo(i==="y"?{top:c}:{left:c},{smooth:!1}),this.syncThumbs())},{signal:s}),t.addEventListener("pointerdown",n=>{if(n.button!==0||n.target===e)return;n.preventDefault();let o=i==="x"&&this.isRtl(),r=t.getBoundingClientRect(),a=i==="y"?n.clientY-r.top:o?r.right-n.clientX:n.clientX-r.left,l=i==="y"?r.height:r.width;if(l<=0)return;let d=i==="y"?this.cachedMaxTop:this.cachedMaxLeft,c=Math.max(0,Math.min(1,a/l)),h=o?-(c*d):c*d;this.scrollTo(i==="y"?{top:h}:{left:h},{smooth:!0})},{signal:s})}setupEventListeners(){let{signal:t}=this.abortController;this.viewport.addEventListener("scroll",this.boundOnScroll,{passive:!0,signal:t}),this.supportsScrollEnd&&this.viewport.addEventListener("scrollend",this.boundOnScrollEnd,{passive:!0,signal:t}),this.options.mode!=="native"&&this.options.autoHide&&!this.options.alwaysVisible&&(this.root.addEventListener("mouseenter",this.boundOnMouseEnter,{signal:t}),this.root.addEventListener("mouseleave",this.boundOnMouseLeave,{signal:t}),this.root.addEventListener("focusin",this.boundOnFocusIn,{signal:t}),this.root.addEventListener("focusout",this.boundOnFocusOut,{signal:t}))}setupObserver(){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{this.isDestroyed||this.resizeRafId!==null||(this.resizeRafId=window.requestAnimationFrame(()=>{this.resizeRafId=null,this.isDestroyed||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||this.dragPointerId!==void 0&&t.pointerId!==this.dragPointerId)return;let e=this.dragAxis==="y",i=(e?t.clientY:t.clientX)-this.dragStartPos,s=e?this.cachedTrackHeight:this.cachedTrackWidth,n=e?this.cachedThumbHeight:this.cachedThumbWidth,o=e?this.cachedMaxTop:this.cachedMaxLeft,r=s-n;if(r<=0||o<=0)return;let a=o/r,l=this.dragStartScroll+i*a;e?this.viewport.scrollTop=Math.max(0,Math.min(o,l)):this.isRtl()?this.viewport.scrollLeft=Math.max(-o,Math.min(0,l)):this.viewport.scrollLeft=Math.max(0,Math.min(o,l))}handlePointerUp(t){if(this.isDragging&&!(t&&t.type!=="lostpointercapture"&&this.dragPointerId!==void 0&&t.pointerId!==this.dragPointerId)){if(this.dragPointerId!==void 0){let e=this.dragAxis==="y"?this.thumbY:this.thumbX;try{e&&e.hasPointerCapture(this.dragPointerId)&&e.releasePointerCapture(this.dragPointerId)}catch{}}this.dragAbortController?.abort(),this.dragAbortController=void 0,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()}}getScrollInfo(){let{scrollTop:t,scrollLeft:e}=this.viewport,i=this.cachedMaxTop,s=this.cachedMaxLeft,o=this.isRtl()?Math.max(0,-e):Math.max(0,e),r=i>0?Math.max(0,Math.min(1,t/i)):0,a=s>0?Math.max(0,Math.min(1,o/s)):0;return{top:t,left:e,maxTop:i,maxLeft:s,progressY:Math.round(r*100),progressX:Math.round(a*100)}}handleScroll(){this.scheduleSyncThumbs();let t=this.getScrollInfo(),{top:e,left:i,maxTop:s,maxLeft:n}=t;this.options.onScroll(t);let o=this.options.edgeThreshold;if(s>0){let r=e>=s-o,a=e<=o;r&&!this.atBottom&&this.options.onTotalScroll("bottom"),a&&!this.atTop&&this.options.onTotalScrollBack("top"),this.atBottom=r,this.atTop=a}if(n>0){let r=this.isRtl(),a=r?i>=-o:i>=n-o,l=r?i<=-n+o:i<=o;a&&!this.atRight&&this.options.onTotalScroll("right"),l&&!this.atLeft&&this.options.onTotalScrollBack("left"),this.atRight=a,this.atLeft=l}this.options.mode!=="native"&&this.options.autoHide&&!this.options.alwaysVisible&&(this.clearAutoHideTimer(),this.root.classList.add("is-scrolling"),this.supportsScrollEnd||this.scheduleAutoHide()),this.supportsScrollEnd||(this.scrollEndFallbackTimer!==void 0&&window.clearTimeout(this.scrollEndFallbackTimer),this.scrollEndFallbackTimer=window.setTimeout(()=>{this.scrollEndFallbackTimer=void 0,this.handleScrollEnd()},150))}handleScrollEnd(){this.options.onScrollEnd(this.getScrollInfo()),this.options.mode!=="native"&&this.options.autoHide&&!this.options.alwaysVisible&&this.scheduleAutoHide()}scheduleSyncThumbs(){this.options.mode==="native"||this.isDestroyed||this.rafId===null&&(this.rafId=window.requestAnimationFrame(()=>{this.rafId=null,this.isDestroyed||this.syncThumbs()}))}syncThumbs(){if(this.options.mode==="native"||this.isDestroyed)return;let{scrollTop:t,scrollLeft:e}=this.viewport;if(this.thumbY&&this.trackY){let i=this.cachedMaxTop,s=this.cachedTrackHeight-this.cachedThumbHeight;if(i>0&&s>0){let n=Math.max(0,Math.min(1,t/i)),o=Math.max(0,Math.min(s,n*s));this.thumbY.style.setProperty("--scrollblock-thumb-y",`${o}px`),this.thumbY.setAttribute("aria-valuenow",String(Math.round(n*100)))}}if(this.thumbX&&this.trackX){let i=this.cachedMaxLeft,s=this.cachedTrackWidth-this.cachedThumbWidth;if(i>0&&s>0){let n=this.isRtl(),o=n?Math.max(0,-e):Math.max(0,e),r=Math.max(0,Math.min(1,o/i)),a=Math.max(0,Math.min(s,r*s)),l=n?-a:a;this.thumbX.style.setProperty("--scrollblock-thumb-x",`${l}px`),this.thumbX.setAttribute("aria-valuenow",String(Math.round(r*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(){if(this.isDestroyed)return;this.syncAccessibilityLabels();let{scrollHeight:t,clientHeight:e,scrollWidth:i,clientWidth:s}=this.viewport,n=this.trackY?this.trackY.clientHeight:0,o=this.trackX?this.trackX.clientWidth:0,r=this.thumbY&&typeof window<"u"&&parseFloat(window.getComputedStyle(this.thumbY).minBlockSize)||0,a=this.thumbX&&typeof window<"u"&&parseFloat(window.getComputedStyle(this.thumbX).minInlineSize)||0;this.cachedMaxTop=Math.max(0,t-e),this.cachedMaxLeft=Math.max(0,i-s),this.cachedTrackHeight=n,this.cachedTrackWidth=o;let l=t>e,d=i>s,c=this.cachedThumbHeight;if(this.trackY&&this.thumbY&&l&&t>0){let p=Math.max(this.options.minThumbSize,r);c=Math.max(p,n*(e/t)),this.cachedThumbHeight=c}let h=this.cachedThumbWidth;if(this.trackX&&this.thumbX&&d&&i>0){let p=Math.max(this.options.minThumbSize,a);h=Math.max(p,o*(s/i)),this.cachedThumbWidth=h}this.root.classList.toggle("has-scroll-y",l),this.root.classList.toggle("has-scroll-x",d),l||d?this.viewport.setAttribute("tabindex","0"):this.viewport.removeAttribute("tabindex"),this.trackY&&this.thumbY&&(this.trackY.hidden=!l,l?(this.thumbY.setAttribute("tabindex","0"),this.thumbY.style.height=`${c}px`):this.thumbY.removeAttribute("tabindex")),this.trackX&&this.thumbX&&(this.trackX.hidden=!d,d?(this.thumbX.setAttribute("tabindex","0"),this.thumbX.style.width=`${h}px`):this.thumbX.removeAttribute("tabindex")),this.syncThumbs()}scrollTo(t,e){if(this.isDestroyed)return Promise.resolve();let i=typeof t=="object"&&t!==null&&!(t instanceof HTMLElement)?t.smooth:void 0,n=(e?.smooth??i??!0)&&!ot()?"smooth":"auto",o=this.isRtl(),{scrollHeight:r,clientHeight:a,scrollWidth:l,clientWidth:d,scrollTop:c,scrollLeft:h}=this.viewport,p=Math.max(0,r-a),f=Math.max(0,l-d);this.cachedMaxTop=p,this.cachedMaxLeft=f;let m,g;if(typeof t=="number")m=t;else if(typeof t=="string")switch(t){case"top":m=0;break;case"bottom":m=p;break;case"left":g=o?-f:0;break;case"right":g=o?0:f;break;default:{if(/^-?\d+(\.\d+)?%$/.test(t.trim())){let k=Math.max(0,Math.min(100,parseFloat(t.trim())))/100;this.options.axis==="x"?g=o?-f*k:f*k:this.options.axis==="both"?(m=p*k,g=o?-f*k:f*k):m=p*k;break}let v=null;try{v=this.viewport.querySelector(t)}catch{v=null}if(v){let k=this.viewport.getBoundingClientRect(),S=v.getBoundingClientRect();m=S.top-k.top+c,g=S.left-k.left+h}break}}else if(t instanceof HTMLElement){let v=this.viewport.getBoundingClientRect(),k=t.getBoundingClientRect();m=k.top-v.top+c,g=k.left-v.left+h}else typeof t=="object"&&t!==null&&(m=t.top,g=t.left);let b=m!==void 0&&Number.isFinite(m)?Math.max(0,Math.min(p,m)):void 0,I=o?-f:0,y=o?0:f,E=g!==void 0&&Number.isFinite(g)?Math.max(I,Math.min(y,g)):void 0,T=b??c,A=E??h;if(Math.abs(T-c)<=1&&Math.abs(A-h)<=1)return Promise.resolve();this.activeScrollToController?.abort();let w=new AbortController;this.activeScrollToController=w;let M=this.viewport.scrollTo({top:b,left:E,behavior:n});return M instanceof Promise?M.then(()=>{this.activeScrollToController===w&&(this.activeScrollToController=void 0)}):n!=="smooth"?(this.activeScrollToController===w&&(this.activeScrollToController=void 0),Promise.resolve()):new Promise(v=>{let k=!1,S,P,tt=()=>{k||(k=!0,S!==void 0&&window.clearTimeout(S),P!==void 0&&window.clearTimeout(P),this.activeScrollToController===w&&(this.activeScrollToController=void 0),w.abort(),v())};if(w.signal.addEventListener("abort",tt,{once:!0}),this.abortController.signal.addEventListener("abort",tt,{once:!0,signal:w.signal}),this.supportsScrollEnd)this.viewport.addEventListener("scrollend",tt,{once:!0,signal:w.signal});else{let ft=()=>{S!==void 0&&window.clearTimeout(S),S=window.setTimeout(tt,150)};this.viewport.addEventListener("scroll",ft,{passive:!0,signal:w.signal}),ft()}P=window.setTimeout(tt,2500)})}audit(){let t=[],e=this.checkAriaIdReferences(this.viewport,"aria-labelledby",t),i=this.checkAriaIdReferences(this.root,"aria-labelledby",t),s=e||i,n=this.root.getAttribute("aria-label")?.trim(),o=!this.wasAriaLabelInferred&&!!this.viewport.getAttribute("aria-label")?.trim();return!this.hasExplicitAriaLabel&&!this.hasRootAriaLabel&&!o&&!n&&!s&&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.mode!=="native"&&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.isDestroyed)if(this.isDestroyed=!0,this.clearAutoHideTimer(),this.scrollEndFallbackTimer!==void 0&&(window.clearTimeout(this.scrollEndFallbackTimer),this.scrollEndFallbackTimer=void 0),this.rafId!==null&&(window.cancelAnimationFrame(this.rafId),this.rafId=null),this.resizeRafId!==null&&(window.cancelAnimationFrame(this.resizeRafId),this.resizeRafId=null),this.activeScrollToController?.abort(),this.activeScrollToController=void 0,this.dragAbortController?.abort(),this.dragAbortController=void 0,this.abortController.abort(),this.resizeObserver&&this.resizeObserver.disconnect(),this.trackY?.remove(),this.trackX?.remove(),this.root.classList.remove("wulf-scrollblock","wulf-scrollblock--native","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;)it(this.root,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.propagatedRootLabel&&this.viewport.removeAttribute(this.propagatedRootLabel),this.wasAriaLabelInferred&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.viewport.removeAttribute("aria-label")}};var zt={ScrollBlock:Q,i18n:lt};var ee=Q,Vt=R();Vt&&(Vt.Scroll=zt);var Lt={};et(Lt,{LayoutEngine:()=>W,LocalizedComponent:()=>x,Masonry:()=>U,createI18nManager:()=>z,default:()=>ie,masonryEn:()=>Ct,masonryFr:()=>Mt,masonryI18n:()=>ut});var W=class{static parseGutter(t){if(typeof t=="number"){let e=Number.isFinite(t)?Math.max(0,t):0;return{x:e,y:e}}if(t&&typeof t=="object"){let e=Number(t.x),i=Number(t.y);return{x:Number.isFinite(e)?Math.max(0,e):0,y:Number.isFinite(i)?Math.max(0,i):0}}return{x:0,y:0}}static resolveColumnWidth(t,e,i){if(typeof i=="number"&&Number.isFinite(i)&&i>0)return i;if(typeof i=="string"){let n=i.trim();if(/^\d+(\.\d+)?(px|%)?$/i.test(n)){let o=parseFloat(n);if(Number.isFinite(o)&&o>0)if(n.endsWith("%")){let a=t.getBoundingClientRect().width*o/100;if(a>0)return a}else return o}else if(n){let o=null;try{o=t.querySelector(n)}catch{o=null}if(o){let a=o.getBoundingClientRect().width;if(Number.isFinite(a)&&a>0)return a}let r=parseFloat(n);if(Number.isFinite(r)&&r>0)return r}}if(i instanceof HTMLElement){let n=i.getBoundingClientRect().width;if(n>0)return n}if(e){let n=e.getBoundingClientRect().width;if(n>0)return n}let s=t.getBoundingClientRect().width;return s>0?s:200}static getItemSpan(t,e,i,s){let n=t.getAttribute("data-masonry-span")||t.dataset.masonrySpan;if(n){let o=parseInt(n,10);if(!isNaN(o)&&o>0)return Math.min(s,o)}for(let o of t.classList){let r=/^(?:span|col-span)-(\d+)$/.exec(o);if(r&&r[1]){let a=parseInt(r[1],10);if(!isNaN(a)&&a>0)return Math.min(s,a)}}return 1}static calculate(t,e,i){let n=t.getBoundingClientRect().width,{x:o,y:r}=this.parseGutter(i.gutter);if(n<=0||e.length===0)return{cols:1,colWidth:n,gutterX:o,gutterY:r,containerHeight:0,containerWidth:n,positions:[]};let a=e[0]||null,l=this.resolveColumnWidth(t,a,i.columnWidth),d=l+o,c=d>0?Math.floor((n+o)/d):1;!Number.isFinite(c)||c<1?c=1:c>1e3&&(c=1e3),!i.columnWidth&&c>1&&(l=(n-(c-1)*o)/c);let h=i.fitWidth?c*l+(c-1)*o:void 0,p=new Array(c).fill(0),f=[],m=e.map(y=>{let E=y.getBoundingClientRect().height;return E>0?E:50}),g=0;for(let y=0;y<e.length;y++){let E=e[y],T=m[y],A=this.getItemSpan(E,l,o,c),w=0,M=0;if(i.horizontalOrder){g+A>c&&(g=0),w=g;let L=0;for(let C=0;C<A;C++)p[w+C]>L&&(L=p[w+C]);M=L,g=(w+A)%c}else if(A===1){let L=p[0];w=0;for(let C=1;C<c;C++)p[C]<L&&(L=p[C],w=C);M=L}else{let L=1/0;w=0;for(let C=0;C<=c-A;C++){let mt=0;for(let gt=0;gt<A;gt++)p[C+gt]>mt&&(mt=p[C+gt]);mt<L&&(L=mt,w=C)}M=L}let v=A*l+(A-1)*o,k=typeof window<"u"&&typeof window.getComputedStyle=="function"&&window.getComputedStyle(t).direction==="rtl",S=h!==void 0?h:n,P=w*(l+o),tt=k?Math.max(0,S-P-v):P;f.push({element:E,x:tt,y:M,width:v,height:T,column:w,span:A});let ft=M+T+r;for(let L=0;L<A;L++)p[w+L]=ft}let b=0;for(let y=0;y<c;y++)p[y]>b&&(b=p[y]);let I=Math.max(0,b>0?b-r:0);return{cols:c,colWidth:l,gutterX:o,gutterY:r,containerHeight:I,containerWidth:n,fittedWidth:h,positions:f}}};var Mt={gallery:"Galerie en grille asym\xE9trique"};var Ct={gallery:"Masonry grid gallery"};var ut=z("fr",{fr:Mt,en:Ct});var U=class extends x{static _i18n=ut;static i18n=ut;root;isNativeCSSGrid=!1;_items=[];options;resizeObserver=null;itemResizeObserver=null;observedItems=new Set;observedItemHeights=new WeakMap;removingItems=new WeakSet;layoutRafId=null;isDestroyed=!1;wasRoleInferred=!1;wasAriaLabelInferred=!1;hasExplicitAriaLabel=!1;lastInferredAriaLabel="";abortController=new AbortController;watchedImages=new WeakSet;originalContainerStyles;constructor(t,e={}){if(super(e.i18n),typeof t=="string"){let s=null;try{s=document.querySelector(t)}catch{s=null}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||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 i=typeof CSS<"u"&&typeof CSS.supports=="function"&&(CSS.supports("display","grid-lanes")||CSS.supports("grid-template-rows","masonry"));this.options.useNativeCSSGrid&&i?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native"),this.syncNativeGridVariables()):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.hasAttribute("aria-labelledby")&&(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="300ms";typeof t=="number"&&Number.isFinite(t)&&t>=0?e=`${t}ms`:typeof t=="string"&&/^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(t)&&(e=t.trim()),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")&&!this.removingItems.has(e));else try{let e=this.options.itemSelector.trim(),i=e.startsWith(">")?`:scope ${e}`:e;t=Array.from(this.root.querySelectorAll(i)).filter(s=>s.parentElement===this.root&&!s.hasAttribute("data-masonry-ignore")&&!this.removingItems.has(s))}catch{t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore")&&!this.removingItems.has(e))}if(this.itemResizeObserver){let e=new Set(t);for(let i of this.observedItems)e.has(i)||(this.itemResizeObserver.unobserve(i),this.observedItems.delete(i),this.observedItemHeights.delete(i))}this._items=t;for(let e of this._items)e.classList.add("wulf-masonry-item"),this.itemResizeObserver&&!this.observedItems.has(e)&&(this.itemResizeObserver.observe(e),this.observedItems.add(e))}initObservers(){if(!this.options.resize||typeof ResizeObserver>"u")return;let t=this.root.getBoundingClientRect().width;this.resizeObserver=new ResizeObserver(e=>{for(let i of e){let s=i.contentRect.width;Math.abs(s-t)>=1&&(t=s,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(e=>{let i=!1;for(let s of e){let n=s.borderBoxSize?.[0]?.blockSize??s.contentRect.height,o=this.observedItemHeights.get(s.target);(o===void 0||Math.abs(n-o)>=1)&&(this.observedItemHeights.set(s.target,n),o!==void 0&&(i=!0))}i&&this.scheduleLayout()});for(let e of this._items)this.itemResizeObserver.observe(e),this.observedItems.add(e)}syncNativeGridVariables(){let{x:t,y:e}=W.parseGutter(this.options.gutter);if(this.root.style.setProperty("--wulf-masonry-gutter-x",`${t}px`),this.root.style.setProperty("--wulf-masonry-gutter-y",`${e}px`),typeof this.options.columnWidth=="number"&&Number.isFinite(this.options.columnWidth)&&this.options.columnWidth>0)this.root.style.setProperty("--wulf-masonry-col-min",`${this.options.columnWidth}px`);else if(this.options.columnWidth instanceof HTMLElement){let i=this.options.columnWidth.getBoundingClientRect().width;i>0&&this.root.style.setProperty("--wulf-masonry-col-min",`${i}px`)}else if(typeof this.options.columnWidth=="string"&&this.options.columnWidth.trim())try{let i=this.root.querySelector(this.options.columnWidth);if(i){let s=i.getBoundingClientRect().width;s>0&&this.root.style.setProperty("--wulf-masonry-col-min",`${s}px`)}}catch{}}initImages(){if(!this.options.autoImages)return;let t=Array.from(this.root.querySelectorAll("img"));for(let e of t)if(!e.complete&&!this.watchedImages.has(e)){this.watchedImages.add(e);let i=()=>{e.addEventListener("load",()=>{this.isDestroyed||this.scheduleLayout()},{once:!0,signal:this.abortController.signal})};typeof e.decode=="function"?e.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.syncAccessibilityLabels(),this.isNativeCSSGrid){this.syncNativeGridVariables();for(let r of this._items)r.classList.remove("wulf-masonry-item--hidden");this.options.onLayout([]);return}this.root.setAttribute("aria-busy","true"),this.options.fitWidth&&this.root.classList.contains("wulf-masonry--fit-width")&&(this.root.style.width="");let t=W.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,i=typeof e=="number"&&Number.isFinite(e)&&e>0;i?this.root.style.setProperty("--wulf-masonry-stagger",`${e}ms`):this.root.style.removeProperty("--wulf-masonry-stagger");let n=!(this._items.length!==this.root.children.length)&&typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("transition-delay","calc(sibling-index() * 1ms)"),o=this.options.percentPosition&&t.containerWidth>0;for(let r=0;r<t.positions.length;r++){let a=t.positions[r],l=a.element;if(o){let d=Number((a.width/t.containerWidth*100).toFixed(4));l.style.setProperty("--wulf-masonry-w",`${d}%`)}else l.style.setProperty("--wulf-masonry-w",`${a.width}px`);l.style.setProperty("--wulf-masonry-x",`${a.x}px`),l.style.setProperty("--wulf-masonry-y",`${a.y}px`),i&&!n?l.style.setProperty("--wulf-masonry-index",String(r)):l.style.removeProperty("--wulf-masonry-index"),l.classList.remove("wulf-masonry-item--hidden"),this.observedItemHeights.set(l,a.height),this.options.onItemPlaced(l,a)}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 i=document.createDocumentFragment();for(let s of e)this.isNativeCSSGrid?s.classList.add("wulf-masonry-item"):s.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),i.appendChild(s);this.root.appendChild(i),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 i=this.root.firstChild,s=document.createDocumentFragment();for(let n of e)this.isNativeCSSGrid?n.classList.add("wulf-masonry-item"):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(t){if(this.isDestroyed)return;let e=Array.isArray(t)?t:[t];if(e.length===0)return;let i=()=>{if(!this.isDestroyed){for(let n of e)this.removingItems.delete(n),n.parentElement===this.root&&(this.itemResizeObserver&&(this.itemResizeObserver.unobserve(n),this.observedItems.delete(n),this.observedItemHeights.delete(n)),this.root.removeChild(n));this.reloadItems(),this.layout()}};for(let n of e)this.removingItems.add(n),typeof document<"u"&&document.activeElement&&n.contains(document.activeElement)&&document.activeElement.blur?.(),n.setAttribute("inert",""),n.style.transitionDelay="0ms",n.classList.add("wulf-masonry-item--hidden");let s=Tt(this.options.transitionDuration,300);if(s<=0||this.isNativeCSSGrid){i();return}this.reloadItems(),this.layout(),Promise.all(e.map(n=>ht(n,s,this.abortController.signal))).then(()=>{this.abortController.signal.aborted||i()})}audit(){let t=[],e=this.checkAriaIdReferences(this.root,"aria-labelledby",t),i=!this.wasAriaLabelInferred&&!!this.root.getAttribute("aria-label")?.trim();!this.hasExplicitAriaLabel&&!i&&!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 s=Array.from(this.root.querySelectorAll("img")).filter(n=>!n.hasAttribute("alt")&&n.getAttribute("aria-hidden")!=="true");return s.length>0&&t.push(`${s.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,this.abortController.abort(),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.root.style.removeProperty("--wulf-masonry-stagger"),this.root.style.removeProperty("--wulf-masonry-col-min"),this.root.style.removeProperty("--wulf-masonry-gutter-x"),this.root.style.removeProperty("--wulf-masonry-gutter-y"),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("--wulf-masonry-index");this._items=[]}}};var ie=U,Wt=R();Wt&&(Wt.Masonry=Object.assign(U,{Masonry:U,LayoutEngine:W,i18n:ut}));var Pt={};et(Pt,{LocalizedComponent:()=>x,Toast:()=>j,ToastInstance:()=>nt,ToastManager:()=>_,createI18nManager:()=>z,default:()=>ae,toastEn:()=>Dt,toastFr:()=>xt,toastI18n:()=>K});var xt={closeButton:"Fermer la notification",notificationsRegion:"Notifications"};var Dt={closeButton:"Close notification",notificationsRegion:"Notifications"};var K=z("fr",{fr:xt,en:Dt});var se=1,Kt=5e3;function pt(u){if(!u||typeof u!="string"||u.length>128)return!1;let t=u.trim();return!t||/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env)\s*\(/i.test(t)?!1:typeof CSS<"u"&&typeof CSS.supports=="function"?CSS.supports("color",t)||CSS.supports("background-color",t):!0}function ne(u){return u.slice(0,128).trim().split(/\s+/).filter(t=>/^[a-zA-Z0-9_-]+$/.test(t)&&!t.startsWith("wulf-toast")).slice(0,8).join(" ")}var nt=class extends N{id;options;element;_isClosed=!1;_isFinalized=!1;closePromise=null;timerId=null;remainingTime=0;hasDuration=!1;timerStartTime=0;isPausedByHover=!1;isPausedByFocus=!1;isPausedByVisibility=!1;isPendingFocusDismiss=!1;previousActiveElement=null;eventsAbortController=new AbortController;disposeAbortController=new AbortController;onDismissCallback;constructor(t,e){super(),this.id=`wulf-toast-${se++}`,this.options=Object.freeze({...t}),this.onDismissCallback=e,this.previousActiveElement=typeof document<"u"&&document.activeElement instanceof HTMLElement?document.activeElement:null;let i=t.duration===void 0?Kt:t.duration;typeof i=="number"&&Number.isFinite(i)&&i>0?(this.remainingTime=Math.min(i,2147483647),this.hasDuration=!0):(this.remainingTime=0,this.hasDuration=!1),this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(t.audit!==!1)}get isClosed(){return this._isClosed}getPreviousActiveElement(){return this.previousActiveElement}audit(){let t=[],e=!!(this.options.title&&this.options.title.trim().length>0),i=!!(this.options.message&&this.options.message.trim().length>0);!e&&!i&&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 s=this.options.duration===void 0?Kt:this.options.duration;typeof s=="number"&&s>0&&s<5e3&&t.push(`Dur\xE9e d'affichage trop courte (duration: ${s}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(s===!1||typeof s=="number"&&s<=0)&&!n&&t.push("Notification persistante impossible \xE0 fermer au clavier : activez closable: 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");if(t.id=this.id,t.className="wulf-toast",t.setAttribute("data-toast-role",this.options.role==="alert"?"alert":"status"),this.options.backgroundColor&&pt(this.options.backgroundColor)&&t.style.setProperty("--wulf-toast-bg",this.options.backgroundColor.trim()),this.options.titleColor&&pt(this.options.titleColor)&&t.style.setProperty("--wulf-toast-title-color",this.options.titleColor.trim()),this.options.textColor&&pt(this.options.textColor)&&t.style.setProperty("--wulf-toast-text-color",this.options.textColor.trim()),this.options.iconColor&&pt(this.options.iconColor)&&t.style.setProperty("--wulf-toast-icon-color",this.options.iconColor.trim()),this.options.closeButtonColor&&pt(this.options.closeButtonColor)&&t.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor.trim()),this.options.icon&&typeof this.options.icon=="string"&&this.options.icon.trim()!==""){let s=ne(this.options.icon);if(s){let n=document.createElement("span");n.className=`wulf-toast-icon ${s}`,n.setAttribute("aria-hidden","true"),t.appendChild(n)}}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(t.appendChild(e),this.options.closable??!0){let s=document.createElement("button");s.type="button",s.className="wulf-toast-close",s.setAttribute("aria-label",K.t("closeButton",this.options.i18n));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",o=>{o.stopPropagation(),this.close("close-button")},{signal:this.eventsAbortController.signal}),t.appendChild(s)}if(this.options.progressBar&&this.remainingTime>0){t.style.setProperty("--wulf-toast-duration",`${this.remainingTime}ms`);let s=document.createElement("div");s.className="wulf-toast-progress",s.setAttribute("aria-hidden","true"),t.appendChild(s)}return t}appendTextWithLineBreaks(t,e){String(e??"").slice(0,4096).split(/\r\n|\r|\n/).slice(0,100).forEach((n,o)=>{o>0&&t.appendChild(document.createElement("br")),t.appendChild(document.createTextNode(n))})}bindEvents(){let{signal:t}=this.eventsAbortController;this.element.addEventListener("click",e=>{this.options.onClick&&this.options.onClick(this,e),this.options.closeOnClick&&this.close("toast-click")},{signal:t}),this.element.addEventListener("mouseenter",()=>this.pauseTimer("hover"),{signal:t}),this.element.addEventListener("mouseleave",()=>this.resumeTimer("hover"),{signal:t}),this.element.addEventListener("focusin",()=>this.pauseTimer("focus"),{signal:t}),this.element.addEventListener("focusout",e=>{let i=e.relatedTarget;if(!(i&&this.element.contains(i))){if(this.isPendingFocusDismiss&&!this._isClosed){this.isPendingFocusDismiss=!1,this.close("timeout");return}this.resumeTimer("focus")}},{signal:t}),this.element.addEventListener("keydown",e=>{e.key==="Escape"&&(this.options.closable??!0)&&(e.stopPropagation(),this.close("close-button"))},{signal:t}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pauseTimer("visibility"):this.resumeTimer("visibility")},{signal:t})}get isPaused(){return this.isPausedByHover||this.isPausedByFocus||this.isPausedByVisibility}startTimer(){if(!(this._isClosed||this.remainingTime<=0||this.isPaused)){if(typeof document<"u"&&document.visibilityState==="hidden"){this.isPausedByVisibility=!0,this.element.classList.add("is-paused");return}this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.timerStartTime=performance.now(),this.timerId=window.setTimeout(()=>{if(this.timerId=null,typeof document<"u"&&this.element.contains(document.activeElement)){this.isPendingFocusDismiss=!0;return}this.close("timeout")},this.remainingTime)}}pauseTimer(t="interaction"){if(this._isClosed||!this.hasDuration||this.remainingTime<=0)return;let e=this.isPaused;if(t==="visibility"?this.isPausedByVisibility=!0:t==="focus"?this.isPausedByFocus=!0:this.isPausedByHover=!0,!e){if(this.timerId!==null){window.clearTimeout(this.timerId),this.timerId=null;let i=performance.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-i)}this.element.classList.add("is-paused")}}resumeTimer(t="interaction"){if(!(this._isClosed||!this.hasDuration)&&(t==="visibility"?this.isPausedByVisibility=!1:t==="focus"?this.isPausedByFocus=!1:t==="hover"?this.isPausedByHover=!1:(this.isPausedByHover=!1,this.isPausedByFocus=!1),!this.isPaused)){if(this.element.classList.remove("is-paused"),this.remainingTime<=0){this.close("timeout");return}this.startTimer()}}finalizeDismiss(t){this._isFinalized||(this._isFinalized=!0,this.eventsAbortController.abort(),this.onDismissCallback&&this.onDismissCallback(this,t),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.options.onClose&&this.options.onClose(this,t))}destroyImmediate(t="replace"){this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.disposeAbortController.abort(),this.finalizeDismiss(t)}close(t="programmatic",e=!1){return this._isClosed?this.closePromise??Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.eventsAbortController.abort(),this.element.classList.add(e?"wulf-toast-hiding-fast":"wulf-toast-hiding"),ot()?(this.finalizeDismiss(t),this.closePromise=Promise.resolve(),this.closePromise):(this.closePromise=ht(this.element,e?90:300,this.disposeAbortController.signal).then(()=>{this.disposeAbortController.signal.aborted||this.finalizeDismiss(t)}),this.closePromise))}};var oe=new Set(["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"]);function $t(u){return u&&oe.has(u)?u:"top-right"}var re='button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])',_=class u{static instance=null;containers=new Map;activeToasts=new Map;announcerEl=null;politeRegion=null;assertiveRegion=null;announceTimers=[];politeAnnounceTimerId=null;assertiveAnnounceTimerId=null;politeClearTimerId=null;assertiveClearTimerId=null;lastPoliteText="";lastAssertiveText="";announcerToggle=!1;isPopoverOpen(t){try{if(t.matches(":popover-open"))return!0}catch{}return t.classList.contains(":popover-open")}replaceTokens=new Map;pendingReplacements=new Set;constructor(){}static getInstance(){return u.instance||(u.instance=new u),u.instance}add(t){let e=$t(t.options.position),i=this.activeToasts.get(e);i||(i=[],this.activeToasts.set(e,i));let s=t.options.maxToasts,n=typeof s=="number"&&Number.isFinite(s)&&s>0?Math.min(50,Math.max(1,Math.floor(s))):5;if(t.options.replace&&i.length>0){let o=[...i],r=(this.replaceTokens.get(e)||0)+1;this.replaceTokens.set(e,r),this.pendingReplacements.add(e);let a=o.map(l=>l.close("replace",!0));Promise.all(a).then(()=>{if(this.pendingReplacements.delete(e),this.replaceTokens.get(e)!==r){t.destroyImmediate("replace");return}this.mountToast(t,e,n)});return}if(this.pendingReplacements.has(e)&&(this.replaceTokens.set(e,(this.replaceTokens.get(e)||0)+1),this.pendingReplacements.delete(e)),i.length>=n){let o=i.length-n+1,r=i.splice(0,o);for(let a of r)a.close("max-limit",!0)}this.mountToast(t,e,n)}mountToast(t,e,i=5){if(t.isClosed)return;let s=t.options.useTopLayer??!0,n=this.getOrCreateContainer(e,t,s),o=this.activeToasts.get(e);o||(o=[],this.activeToasts.set(e,o));let r=i+10;if(n.children.length>=r){let a=Array.from(n.children);for(let l of a){if(n.children.length<r)break;(l.classList.contains("wulf-toast-hiding")||l.classList.contains("wulf-toast-hiding-fast"))&&l.remove()}}if(s&&typeof n.showPopover=="function"&&n.getAttribute("popover")==="manual")try{let a=n;this.isPopoverOpen(n)||a.showPopover()}catch{n.removeAttribute("popover")}if(n.appendChild(t.element),o.push(t),this.announce(t),t.options.onOpen)try{t.options.onOpen(t)}catch(a){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",a)}t.startTimer()}announce(t){let e=[t.options.title,t.options.message].filter(p=>typeof p=="string"&&p.trim().length>0).map(p=>p.trim());if(e.length===0)return;let i=e.join(". "),s=i.length>512?`${i.slice(0,509)}...`:i,n=t.options.role==="alert",o=document;if(typeof o.ariaNotify=="function")try{o.ariaNotify(s,{priority:n?"high":"normal"});return}catch{}let r=!this.announcerEl||!this.announcerEl.isConnected;this.ensureAnnouncer();let a=n?this.assertiveRegion:this.politeRegion;if(!a)return;n?(this.assertiveAnnounceTimerId!==null&&(window.clearTimeout(this.assertiveAnnounceTimerId),this.assertiveAnnounceTimerId=null),this.assertiveClearTimerId!==null&&(window.clearTimeout(this.assertiveClearTimerId),this.assertiveClearTimerId=null)):(this.politeAnnounceTimerId!==null&&(window.clearTimeout(this.politeAnnounceTimerId),this.politeAnnounceTimerId=null),this.politeClearTimerId!==null&&(window.clearTimeout(this.politeClearTimerId),this.politeClearTimerId=null)),a.textContent="";let l=n?this.lastAssertiveText:this.lastPoliteText,d=s;s===l?(this.announcerToggle=!this.announcerToggle,d=this.announcerToggle?`${s}\xA0`:s):this.announcerToggle=!1,n?this.lastAssertiveText=s:this.lastPoliteText=s;let c=r?120:50,h=window.setTimeout(()=>{let p=this.announceTimers.indexOf(h);if(p!==-1&&this.announceTimers.splice(p,1),n?this.assertiveAnnounceTimerId=null:this.politeAnnounceTimerId=null,a.isConnected){a.textContent=d;let f=window.setTimeout(()=>{let m=this.announceTimers.indexOf(f);m!==-1&&this.announceTimers.splice(m,1),a.isConnected&&a.textContent===d&&(a.textContent="")},4e3);this.announceTimers.push(f),n?this.assertiveClearTimerId=f:this.politeClearTimerId=f}},c);this.announceTimers.push(h),n?this.assertiveAnnounceTimerId=h:this.politeAnnounceTimerId=h}ensureAnnouncer(){if(this.announcerEl&&document.body.contains(this.announcerEl))return;let t=document.createElement("div");t.className="wulf-toast-announcer",t.setAttribute("data-wulf-toast-announcer","true");let e=document.createElement("div");e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true");let i=document.createElement("div");i.setAttribute("role","alert"),i.setAttribute("aria-live","assertive"),i.setAttribute("aria-atomic","true"),t.appendChild(e),t.appendChild(i),document.body.appendChild(t),this.announcerEl=t,this.politeRegion=e,this.assertiveRegion=i}handleFocusHandoff(t,e){if(!t.element.contains(document.activeElement))return;for(let s=e.length-1;s>=0;s--){let n=e[s];if(n===t||n.isClosed||!n.element.isConnected)continue;let o=n.element.querySelector(re);if(o){o.focus({preventScroll:!0});return}}let i=t.getPreviousActiveElement();if(i&&i.isConnected&&typeof i.focus=="function"&&!i.disabled&&!i.closest("[inert]")&&i.getAttribute("aria-hidden")!=="true")try{i.focus()}catch{}}remove(t,e){let i=$t(t.options.position),s=this.activeToasts.get(i);if(s){let n=s.indexOf(t);if(n!==-1&&s.splice(n,1),this.handleFocusHandoff(t,s),t.element.parentNode&&t.element.parentNode.removeChild(t.element),s.length===0&&!this.pendingReplacements.has(i)){let o=this.containers.get(i);o&&(!o.firstChild||o.children.length===0)&&(this.disposeContainer(o),this.containers.delete(i),this.activeToasts.delete(i))}}else t.element.parentNode&&t.element.parentNode.removeChild(t.element)}disposeContainer(t){try{let e=t;typeof e.hidePopover=="function"&&this.isPopoverOpen(t)&&e.hidePopover()}catch{}t.parentNode&&t.parentNode.removeChild(t)}clearAll(t){let e=[];if(t){this.replaceTokens.set(t,(this.replaceTokens.get(t)||0)+1),this.pendingReplacements.delete(t);let i=this.activeToasts.get(t);if(i&&i.length>0){let s=[...i];for(let n of s)e.push(n.close("programmatic"))}else{let s=this.containers.get(t);s&&(!s.firstChild||s.children.length===0)&&(this.disposeContainer(s),this.containers.delete(t),this.activeToasts.delete(t))}}else{for(let s of this.replaceTokens.keys())this.replaceTokens.set(s,(this.replaceTokens.get(s)||0)+1);this.pendingReplacements.clear();for(let s of this.announceTimers)window.clearTimeout(s);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;let i=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let s of i)e.push(this.clearAll(s))}return Promise.all(e).then(()=>{if(!t)for(let[i,s]of Array.from(this.containers.entries()))(!s.firstChild||s.children.length===0)&&(this.disposeContainer(s),this.containers.delete(i),this.activeToasts.delete(i))})}destroy(){for(let t of this.announceTimers)window.clearTimeout(t);this.announceTimers=[];for(let t of Array.from(this.activeToasts.values()))for(let e of[...t])e.destroyImmediate("programmatic");for(let t of Array.from(this.containers.values()))this.disposeContainer(t);this.containers.clear(),this.activeToasts.clear(),this.replaceTokens.clear(),this.pendingReplacements.clear(),this.announcerEl&&(this.announcerEl.remove(),this.announcerEl=null,this.politeRegion=null,this.assertiveRegion=null),u.instance=null}getOrCreateContainer(t,e,i){let s=this.containers.get(t);return(!s||!document.body.contains(s))&&(s=document.createElement("div"),s.className=`wulf-toast-container wulf-toast-${t}`,s.setAttribute("role","region"),s.setAttribute("aria-label",K.t("notificationsRegion",e.options.i18n)),i&&typeof s.showPopover=="function"&&s.setAttribute("popover","manual"),document.body.appendChild(s),this.containers.set(t,s)),s}};var j=class extends x{static _i18n=K;static i18n=K;audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(t={}){let e=_.getInstance(),i=new nt(t,(s,n)=>{e.remove(s,n)});return e.add(i),i}static clearAll(t){return _.getInstance().clearAll(t)}static destroy(){_.getInstance().destroy()}};var ae=j,Gt=R();Gt&&(Gt.Toast=Object.assign(j,{Toast:j,i18n:K}));var Ot={};et(Ot,{FocusTrap:()=>X,default:()=>X});var le=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","button:not([disabled])","audio[controls]","video[controls]","details > summary:first-of-type","iframe","object","embed",'[contenteditable]:not([contenteditable="false"])','[tabindex]:not([tabindex="-1"])'].join(",");function Rt(u,t){if(!t||typeof t!="string")return null;try{return u.querySelector(t)}catch{return null}}var Y=[],X=class extends N{element;options;active=!1;paused=!1;previousActiveElement=null;inertSiblings=[];addedContainerTabIndex=!1;lastOutsidePointerDownTime=0;abortController;handleKeyDownBound;handleClickOutsideBound;handleFocusInBound;constructor(t,e={}){super();let i=typeof t=="string"?Rt(document,t):t;if(!i||!(i instanceof HTMLElement))throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${t}"`);this.element=i;let s=e.allowOutsideClick??!1;this.options={initialFocus:e.initialFocus!==void 0?e.initialFocus:"[data-autofocus], [autofocus]",returnFocus:e.returnFocus??!0,fallbackReturnFocus:e.fallbackReturnFocus??"",escapeDeactivates:e.escapeDeactivates??!0,allowOutsideClick:s,setInert:e.setInert??!s,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)}isNativeDialogElement(){return this.element.tagName.toLowerCase()==="dialog"}isNativeModalDialog(){if(!this.isNativeDialogElement())return!1;try{return this.element.matches(":modal")}catch{return!1}}isElementFocusableBase(t){if(!t||!t.isConnected||t.tabIndex<0||t.disabled)return!1;try{if(t.matches(":disabled"))return!1}catch{if(t.closest("fieldset[disabled]"))return!1}if(t.hasAttribute("inert")||t.closest("[inert]")||t.hidden||t.closest("[hidden]"))return!1;let e=t;if(typeof e.checkVisibility=="function"){if(!e.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0,visibilityProperty:!0}))return!1}else{if(t.style.display==="none"||t.style.visibility==="hidden")return!1;let i=window.getComputedStyle(t);if(i.display==="none"||i.visibility==="hidden"||t.offsetWidth===0&&t.offsetHeight===0&&i.position!=="fixed")return!1}return!0}isFocusable(t){if(!this.isElementFocusableBase(t))return!1;if(t instanceof HTMLInputElement&&t.type==="radio"&&t.name){let e=Array.from(this.element.querySelectorAll(`input[type="radio"][name="${ct(t.name)}"]`)).filter(s=>s.form===t.form&&this.isElementFocusableBase(s));if(e.length===0)return!1;let i=e.find(s=>s.checked);return i?t===i:t===e[0]}return!0}getFocusableElements(){return Array.from(this.element.querySelectorAll(le)).filter(e=>this.isFocusable(e))}activate(){if(this.active)return this;let t=Y[Y.length-1];t&&t.pause(),this.active=!0,this.paused=!1,Y.push(this);let e=bt(document);this.previousActiveElement=e instanceof HTMLElement?e:document.activeElement,this.options.setInert&&!this.isNativeModalDialog()&&this.applyInert(),this.abortController?.abort(),this.abortController=new AbortController;let{signal:i}=this.abortController;return document.addEventListener("keydown",this.handleKeyDownBound,{capture:!0,signal:i}),document.addEventListener("focusin",this.handleFocusInBound,{capture:!0,signal:i}),document.addEventListener("pointerdown",this.handleClickOutsideBound,{capture:!0,signal:i}),this.options.allowOutsideClick||(document.addEventListener("mousedown",this.handleClickOutsideBound,{capture:!0,signal:i}),document.addEventListener("touchstart",this.handleClickOutsideBound,{capture:!0,signal:i}),document.addEventListener("click",this.handleClickOutsideBound,{capture:!0,signal:i})),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=Y.indexOf(this);t!==-1&&Y.splice(t,1),this.abortController?.abort(),this.abortController=void 0,this.removeInert(),this.addedContainerTabIndex&&(this.element.removeAttribute("tabindex"),this.addedContainerTabIndex=!1);let e=Y[Y.length-1];return e&&e.unpause(),this.options.returnFocus&&this.restoreFocus(),this.previousActiveElement=null,this.options.onDeactivate(),this}pause(){this.paused=!0,this.removeInert()}unpause(){this.active&&Y[Y.length-1]===this&&(this.paused=!1,this.options.setInert&&!this.isNativeModalDialog()&&this.applyInert())}isActive(){return this.active&&!this.paused}audit(){let t=[],e=this.element.getAttribute("role");this.isNativeDialogElement()?(e==="dialog"&&t.push('Attribut redondant : role="dialog" est d\xE9j\xE0 implicite sur une balise native <dialog>.'),this.element.hasAttribute("aria-modal")&&t.push('Attribut redondant : <dialog> ouvert via showModal() g\xE8re nativement la modalit\xE9 sans n\xE9cessiter aria-modal="true".'),this.element.hasAttribute("open")&&!this.isNativeModalDialog()&&t.push("Dialogue non modal d\xE9tect\xE9 : pr\xE9f\xE9rez dialog.showModal() plut\xF4t que l'attribut open pour obtenir la Top Layer et l'inertie natives.")):((!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.'),(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(),o=this.checkAriaIdReferences(this.element,"aria-labelledby",t);return!n&&!o&&t.push('Nom accessible manquant : d\xE9finissez aria-labelledby="id-titre" ou aria-label="..." sur le conteneur (WCAG 4.1.2).'),t}getAuditPrefix(){return"Wulf.FocusTrap"}getAuditTargetLabel(){return this.element.id?`#${this.element.id}`:`<${this.element.tagName.toLowerCase()}>`}destroy(){this.deactivate()}isEventInside(t,e){return!!(e&&this.element.contains(e)||typeof t.composedPath=="function"&&t.composedPath().includes(this.element))}isInsideToastContainer(t){return!t||!(t instanceof Element)?!1:!!t.closest(".wulf-toast-container")}ensureContainerTabIndex(){this.element.getAttribute("tabindex")===null&&(this.element.setAttribute("tabindex","-1"),this.addedContainerTabIndex=!0)}handleKeyDown(t){if(!this.isActive())return;if(this.element.isConnected===!1){this.deactivate();return}if(t.key==="Escape"&&this.options.escapeDeactivates){if(H(t))return;this.isNativeModalDialog()||(t.preventDefault(),t.stopPropagation()),this.deactivate();return}if(t.key!=="Tab")return;let e=this.getFocusableElements();if(e.length===0){t.preventDefault(),this.ensureContainerTabIndex(),this.element.focus();return}let i=e[0],s=e[e.length-1],n=bt(document),o=n instanceof HTMLElement?n:document.activeElement,r=o?this.element.contains(o)||this.isEventInside(t,o):!1;!t.shiftKey&&(o===s||!r)?(t.preventDefault(),i.focus()):t.shiftKey&&(o===i||o===this.element||!r)&&(t.preventDefault(),s.focus())}handleFocusIn(t){if(!this.isActive())return;if(this.element.isConnected===!1){this.deactivate();return}let e=t.target;if(e&&!this.isInsideToastContainer(e)&&!(this.options.allowOutsideClick&&performance.now()-this.lastOutsidePointerDownTime<150)&&!this.isEventInside(t,e)){let i=this.getFocusableElements();i.length>0?i[0].focus():(this.ensureContainerTabIndex(),this.element.focus())}}handleClickOutside(t){if(!this.isActive())return;if(this.element.isConnected===!1){this.deactivate();return}let e=t.target;if(e&&!this.isEventInside(t,e)){if(this.isInsideToastContainer(e))return;if(this.options.allowOutsideClick){this.lastOutsidePointerDownTime=performance.now();return}t.preventDefault(),t.stopPropagation()}}applyInert(){this.removeInert();let t=this.element,e=new Set(["SCRIPT","STYLE","TEMPLATE","LINK","META","NOSCRIPT"]);for(;t&&t!==document.body&&t.parentElement;){let i=t.parentElement;for(let s of Array.from(i.children))s instanceof HTMLElement&&s!==t&&!e.has(s.tagName)&&!s.hasAttribute("inert")&&!s.matches(".wulf-toast-container, .wulf-toast-announcer")&&(s.setAttribute("inert",""),this.inertSiblings.push(s));t=i}}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=Rt(this.element,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.ensureContainerTabIndex(),this.element.focus())}restoreFocus(){if(this.previousActiveElement&&this.previousActiveElement.isConnected&&this.isElementFocusableBase(this.previousActiveElement)){this.previousActiveElement.focus();return}if(this.options.fallbackReturnFocus){let t=typeof this.options.fallbackReturnFocus=="string"?Rt(document,this.options.fallbackReturnFocus):this.options.fallbackReturnFocus;t&&t.isConnected&&this.isElementFocusableBase(t)&&t.focus()}}};var qt=R();qt&&(qt.FocusTrap=Object.assign(X,{FocusTrap:X}));var Ht={};et(Ht,{ShortcutFormatter:()=>D,ShortcutManager:()=>B,default:()=>B});var D=class u{static isApple(){if(typeof navigator>"u")return!1;let t=navigator.userAgentData;if(t&&typeof t.platform=="string"){let s=t.platform.toLowerCase();if(s.includes("mac")||s.includes("ios"))return!0}let e=(navigator.platform||"").toLowerCase();if(e.includes("mac")||e.includes("iphone")||e.includes("ipad")||e.includes("ipod"))return!0;let i=(navigator.userAgent||"").toLowerCase();return i.includes("macintosh")||i.includes("mac os x")||i.includes("ipad")||i.includes("iphone")}static normalizeKeyName(t){if(t===" ")return" ";let e=t.trim().toLowerCase();switch(e){case"esc":return"escape";case"return":return"enter";case"space":case"spacebar":return" ";case"plus":return"+";case"del":return"delete";case"ins":return"insert";case"up":return"arrowup";case"down":return"arrowdown";case"left":return"arrowleft";case"right":return"arrowright";default:return e}}static parseCombo(t,e=u.isApple()){if(typeof t!="string")return[];if(t===" ")return[{ctrl:!1,alt:!1,shift:!1,meta:!1,key:" "}];let i=t.slice(0,512).trim();if(!i)return[];let n=i.replace(/\b(ctrl|control|alt|option|opt|shift|maj|cmd|command|meta|win|super|mod|\$mod)\s*\+\s*/gi,"$1+").split(/\s+/).slice(0,10),o=[];for(let r of n){let a=[];if(r==="+")a.push("+");else{let f="";for(let m=0;m<r.length;m++){let g=r[m];g==="+"?f===""&&a.length>0?a.push("+"):f!==""&&(a.push(f),f=""):f+=g}f!==""&&a.push(f)}let l=!1,d=!1,c=!1,h=!1,p="";for(let f of a){let m=f.trim().toLowerCase();m==="ctrl"||m==="control"?l=!0:m==="alt"||m==="option"||m==="opt"?d=!0:m==="shift"||m==="maj"?c=!0:m==="cmd"||m==="command"||m==="meta"||m==="win"||m==="super"?h=!0:m==="mod"||m==="$mod"?e?h=!0:l=!0:p=u.normalizeKeyName(f)}o.push({ctrl:l,alt:d,shift:c,meta:h,key:p})}return o}static format(t,e=u.isApple()){let i=u.parseCombo(t,e);return i.length===0?t:i.map(n=>{let o=[];if(e){n.ctrl&&o.push("\u2303"),n.alt&&o.push("\u2325"),n.shift&&o.push("\u21E7"),n.meta&&o.push("\u2318");let r=u.formatKeyDisplay(n.key,!0);return o.push(r),o.join("")}else{n.ctrl&&o.push("Ctrl"),n.alt&&o.push("Alt"),n.shift&&o.push("Shift"),n.meta&&o.push("Win");let r=u.formatKeyDisplay(n.key,!1);return o.push(r),o.join("+")}}).join(" ")}static toAriaKeyShortcuts(t,e=u.isApple()){let i=u.parseCombo(t,e);if(i.length!==1)return"";let s=i[0],n=u.formatAriaKey(s.key);if(!n)return"";let o=[];return s.ctrl&&o.push("Control"),s.alt&&o.push("Alt"),s.shift&&o.push("Shift"),s.meta&&o.push("Meta"),o.push(n),o.join("+")}static formatAriaKey(t){if(!t)return"";switch(t.toLowerCase()){case"escape":return"Escape";case"enter":return"Enter";case" ":return"Space";case"tab":return"Tab";case"backspace":return"Backspace";case"delete":return"Delete";case"insert":return"Insert";case"home":return"Home";case"end":return"End";case"pageup":return"PageUp";case"pagedown":return"PageDown";case"arrowup":return"ArrowUp";case"arrowdown":return"ArrowDown";case"arrowleft":return"ArrowLeft";case"arrowright":return"ArrowRight";case"printscreen":return"PrintScreen";case"scrolllock":return"ScrollLock";case"numlock":return"NumLock";case"capslock":return"CapsLock";case"contextmenu":return"ContextMenu";case"+":return"Plus";default:return t.length===1?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)}}static formatKeyDisplay(t,e){if(!t)return"";switch(t.toLowerCase()){case"escape":return e?"\u238B":"Esc";case"enter":return e?"\u21A9":"Enter";case" ":return e?"\u2423":"Space";case"tab":return e?"\u21E5":"Tab";case"backspace":return e?"\u232B":"Backspace";case"delete":return e?"\u2326":"Suppr";case"arrowup":return"\u2191";case"arrowdown":return"\u2193";case"arrowleft":return"\u2190";case"arrowright":return"\u2192";default:return t.length===1?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)}}};var B=class u{options;shortcuts=new Map;scopeStack=[];sequenceBuffer=[];sequenceTimer=null;isListening=!0;boundListener=null;abortController=null;idCounter=0;constructor(t){let e=t?.sequenceTimeout,i=typeof e=="number"&&Number.isFinite(e)&&e>0?Math.min(e,1e4):800;this.options={defaultScope:t?.defaultScope||"global",sequenceTimeout:i,target:t?.target||(typeof window<"u"?window:{}),onError:t?.onError},this.scopeStack=[this.options.defaultScope],this.initListener()}static isEditable(t){if(!t||typeof t.tagName!="string")return!1;let e=t,i=e.tagName.toUpperCase();if(i==="INPUT"){let n=e.type?.toLowerCase()||"text";return!["button","checkbox","radio","submit","reset","range","color","file","image"].includes(n)}if(i==="TEXTAREA"||i==="SELECT"||e.isContentEditable||e.getAttribute("contenteditable")==="true"||e.getAttribute("contenteditable")==="plaintext-only"||e.getAttribute("contenteditable")==="")return!0;let s=e.getAttribute("role");return!!(s==="textbox"||s==="searchbox"||s==="combobox"||s==="spinbutton"||typeof e.closest=="function"&&e.closest('[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"], [role="combobox"], [role="spinbutton"]'))}static isPasswordField(t){if(!t||typeof t.tagName!="string")return!1;let e=t;return e.tagName.toUpperCase()==="INPUT"&&(e.type||"").toLowerCase()==="password"}bind(t){let e=Array.isArray(t)?t:[t],i=[];for(let s of e){if(!s.combo||typeof s.handler!="function")continue;let n=`wulf_shortcut_${++this.idCounter}`,o=D.parseCombo(s.combo),r=o.length>1,a=D.format(s.combo),l={...s,id:n,scope:s.scope||"global",category:s.category||"G\xE9n\xE9ral",allowInEditable:s.allowInEditable??!1,preventDefault:s.preventDefault??!0,stopPropagation:s.stopPropagation??!0,priority:s.priority??0,formattedCombo:a,normalizedSteps:o,isSequence:r};this.shortcuts.set(n,l),i.push(n)}return()=>{for(let s of i)this.shortcuts.delete(s)}}unbind(t,e){if(typeof t!="string"||!t.trim())return;let i=D.format(t);for(let[s,n]of this.shortcuts.entries())(n.formattedCombo===i||n.combo.trim().toLowerCase()===t.trim().toLowerCase())&&(!e||n.scope===e)&&this.shortcuts.delete(s)}pushScope(t){if(t&&typeof t=="string"){if(this.scopeStack.length>=64)return;this.scopeStack.push(t),this.clearSequenceBuffer()}}popScope(t){if(this.scopeStack.length<=1)return this.scopeStack[0];if(t){if(this.getScope()===t){let i=this.scopeStack.pop();return this.clearSequenceBuffer(),i}return}let e=this.scopeStack.pop();return this.clearSequenceBuffer(),e}setScope(t){this.scopeStack=[t||this.options.defaultScope],this.clearSequenceBuffer()}getScope(){return this.scopeStack[this.scopeStack.length-1]||this.options.defaultScope}getScopeStack(){return[...this.scopeStack]}pause(){this.isListening=!1,this.clearSequenceBuffer()}resume(){this.isListening=!0}isActive(){return this.isListening}getRegistry(t){let e=[];for(let i of this.shortcuts.values())(!t||i.scope===t||i.scope==="*")&&e.push({...i});return e}attachAria(t,e){if(t&&typeof t.setAttribute=="function"){let i=D.toAriaKeyShortcuts(e);i?t.setAttribute("aria-keyshortcuts",i):typeof t.removeAttribute=="function"&&t.removeAttribute("aria-keyshortcuts")}}static format(t,e){return D.format(t,e)}destroy(){this.pause(),this.removeListener(),this.shortcuts.clear(),this.scopeStack=[],this.clearSequenceBuffer()}initListener(){if(typeof window>"u"||!this.options.target)return;this.abortController=new AbortController,this.boundListener=e=>this.handleKeyDown(e);let t=this.options.target;typeof t.addEventListener=="function"&&t.addEventListener("keydown",this.boundListener,{capture:!1,signal:this.abortController.signal})}removeListener(){if(this.abortController)this.abortController.abort(),this.abortController=null;else if(this.boundListener&&this.options.target){let t=this.options.target;typeof t.removeEventListener=="function"&&t.removeEventListener("keydown",this.boundListener,!1)}this.boundListener=null}handleKeyDown(t){if(!this.isListening||H(t))return;let e=(t.key||"").toLowerCase();if(["control","alt","shift","meta"].includes(e))return;let i=this.getScope(),s=typeof t.composedPath=="function"?t.composedPath():[],n=s.length>0?s[0]:t.target,o=u.isEditable(n)||u.isEditable(t.target),r=u.isPasswordField(n)||u.isPasswordField(t.target),a={ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey,meta:t.metaKey,key:D.normalizeKeyName(t.key||"")},l=t.timeStamp>0?t.timeStamp:typeof performance<"u"?performance.now():Date.now();if(this.sequenceBuffer.length>0){let f=this.sequenceBuffer[this.sequenceBuffer.length-1];l-f.timestamp>this.options.sequenceTimeout&&this.clearSequenceBuffer()}let d=this.getActiveShortcuts(i,o,r),c=[...this.sequenceBuffer.map(f=>f.step),a],h=this.findMatchingSequence(d,c);if(h){this.clearSequenceBuffer(),this.executeShortcut(h,t,i,!0);return}if(this.isPrefixOfAnySequence(d,c)){this.sequenceBuffer.push({step:a,timestamp:l}),this.resetSequenceTimer(),t.key.length===1&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!o&&t.preventDefault();return}this.clearSequenceBuffer();let p=this.findMatchingChord(d,a,t);p&&this.executeShortcut(p,t,i,!1)}getActiveShortcuts(t,e,i=!1){let s=[];for(let n of this.shortcuts.values())if(!(n.scope!==t&&n.scope!=="*")&&!(e&&!n.allowInEditable)){if(i){if(n.isSequence)continue;let o=n.normalizedSteps[0];if(o&&o.key.length===1){let r=!o.ctrl&&!o.alt&&!o.meta,a=o.ctrl&&o.alt&&!o.meta||o.alt&&!o.ctrl&&!o.meta;if(r||a)continue}}s.push(n)}return s.sort((n,o)=>(o.priority??0)-(n.priority??0))}stepMatches(t,e,i){if(t.ctrl!==e.ctrl||t.alt!==e.alt||t.meta!==e.meta)return!1;let s=typeof i?.key=="string"?i.key:"";if(!(t.key===e.key||s!==""&&t.key===s.toLowerCase()))return!1;if(t.shift===e.shift)return!0;if(!t.shift&&e.shift){let o=t.key.length===1&&!/^[a-z]$/i.test(t.key);if(s!==""&&s===t.key||o&&e.key===t.key)return!0}return!1}findMatchingChord(t,e,i){for(let s of t){if(s.isSequence||s.normalizedSteps.length!==1)continue;let n=s.normalizedSteps[0];if(this.stepMatches(n,e,i))return s}return null}findMatchingSequence(t,e){for(let i of t){if(!i.isSequence||i.normalizedSteps.length!==e.length)continue;let s=!0;for(let n=0;n<e.length;n++)if(!this.stepMatches(i.normalizedSteps[n],e[n])){s=!1;break}if(s)return i}return null}isPrefixOfAnySequence(t,e){for(let i of t){if(!i.isSequence||i.normalizedSteps.length<=e.length)continue;let s=!0;for(let n=0;n<e.length;n++)if(!this.stepMatches(i.normalizedSteps[n],e[n])){s=!1;break}if(s)return!0}return!1}executeShortcut(t,e,i,s){t.preventDefault&&e.preventDefault(),t.stopPropagation&&e.stopPropagation();let n={combo:t.combo,formattedCombo:t.formattedCombo,scope:i,target:e.target,isSequence:s};try{t.handler(e,n)}catch(o){this.options.onError?this.options.onError(o instanceof Error?o:new Error(String(o)),t.combo):console.error(`[Wulf.Shortcut] Erreur lors de l'ex\xE9cution du raccourci "${t.combo}":`,o)}}resetSequenceTimer(){this.sequenceTimer&&clearTimeout(this.sequenceTimer),this.sequenceTimer=setTimeout(()=>{this.clearSequenceBuffer()},this.options.sequenceTimeout)}clearSequenceBuffer(){this.sequenceBuffer=[],this.sequenceTimer&&(clearTimeout(this.sequenceTimer),this.sequenceTimer=null)}};var Ut=R();Ut&&(Ut.Shortcut=Object.assign(B,{ShortcutManager:B,ShortcutFormatter:D}));return Zt(ue);})();
4
+ (${this.getAuditDisableHint()})`),e}checkAriaIdReferences(t,e,i,n=!1){let s=t.getAttribute(e)?.trim();if(!s)return!1;let r=t.ownerDocument||document,o=typeof t.getRootNode=="function"?t.getRootNode():r,a=s.split(/\s+/).filter(Boolean),l=a.map(h=>typeof ShadowRoot<"u"&&o instanceof ShadowRoot?o.getElementById(h):r.getElementById(h));return a.length>0&&l.every(h=>!!h)?n&&!l.some(c=>c?(c.textContent?.trim()||c.getAttribute("aria-label")?.trim()||"").length>0:!1)?(i.push(`Attribut ${e}="${s}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`),!1):!0:(i.push(`Attribut ${e}="${s}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`),!1)}};var Dt=4096;function W(f,t=Dt){return z(f,t).replace(/[\u00A0\u202F\u2007]/g," ").replace(/[\u2013\u2014\u2212]/g,"-").trim()}var Et=new Set(["left","right","center"]);function X(f,t,e){return t&&typeof t=="object"&&"tagName"in t&&t.tagName==="INPUT"?{wrapper:f||null,input:t,options:e||{}}:{wrapper:null,input:f,options:t&&typeof t=="object"&&!("tagName"in t)?t:{}}}var N=class extends B{wrapper;input;options;ghost=null;isWrapperCreated=!1;wasWrapperFallbackStyled=!1;wasAlignSet=!1;hadInitialDataAlign=!1;isDestroyed=!1;isFocused=!1;isDispatchingNativeInput=!1;lastTrackedValue="";nativeValueDescriptor=null;onCutHandler=()=>{};onFormResetHandler;mutationObserver=null;resizeObserver=null;focusSelectTimerId=null;abortController=new AbortController;constructor(t,e,i){super();let{wrapper:n,input:s,options:r}=X(t,e,i);if(!s||typeof s!="object"||s.nodeType!==1||s.tagName!=="INPUT")throw new Error(`[${new.target.name||"InputMask"}] input (HTMLInputElement) est requis.`);this.input=s;let o=this.input.getAttribute("data-mask-create-wrapper")==="true",a=!!(r.createWrapper??o),l=n;if(!l&&a){let k=this.input.ownerDocument||document,I=k.createElement("span");I.className="wulf-mask-wrapper wulf-mask-wrapper--auto",this.input.parentNode&&this.input.parentNode.insertBefore(I,this.input),ut(I,this.input,null);let q=k.defaultView||(typeof window<"u"?window:null);(!I.isConnected||!q||q.getComputedStyle(I).display!=="inline-grid")&&(I.style.display="inline-grid",I.style.gridTemplateColumns="1fr",I.style.gridTemplateRows="1fr",I.style.verticalAlign="middle",I.style.boxSizing="border-box",I.style.position="relative",this.input.style.gridArea="1 / 1 / 2 / 2",this.input.style.boxSizing="border-box",this.wasWrapperFallbackStyled=!0),l=I,this.isWrapperCreated=!0}if(!l)throw new Error(`[${new.target.name||"InputMask"}] wrapper (HTMLElement) et input (HTMLInputElement) sont requis, ou activez l'option createWrapper: true.`);this.wrapper=l,this.normalizeInputType();let u=this.getAttr("data-mask-focus-only")==="true",h=this.hasAttr("data-disabled"),c=this.getAttr("data-mask-select-on-focus")==="true",d=this.getAttr("data-mask-copy-raw")==="true",p=this.getAttr("data-mask-sensitive")==="true",m=this.getAttr("data-mask-align")||this.getAttr("data-align"),g=m&&Et.has(m)?m:null;this.hadInitialDataAlign=this.wrapper.hasAttribute("data-align");let b=this.getAttr("data-mask-audit"),{disabled:v,align:y,sensitive:T,...A}=r,S=y&&Et.has(y)?y:void 0,w=v!==void 0?v:!!h,C=r.audit??(b!==null?b!=="false":!0),E=!!(T??p),M=this.isPasswordInput()||E;this.options={...A,createWrapper:a,showMaskOnFocus:r.showMaskOnFocus??u??!1,selectAllOnFocus:r.selectAllOnFocus??c??!1,copyRaw:M?!1:r.copyRaw??d??!1,sensitive:E,disabled:w,align:S??(g||void 0),emitNativeInput:r.emitNativeInput??!0,audit:C},this.options.showMaskOnFocus&&this.wrapper.classList.add("mask-focus-only"),this.options.disabled&&this.wrapper.setAttribute("data-disabled","true"),this.options.align&&this.setAlign(this.options.align),this.createGhost(),this.hookValueProperty(),this.bindBaseEvents(),this.initMutationObserver()}getAttr(t){return this.input.getAttribute(t)||this.wrapper.getAttribute(t)}hasAttr(t){return this.wrapper.hasAttribute(t)||this.input.hasAttribute(t)}hasNativePlaceholder(){return!!(this.input.placeholder&&this.input.placeholder.trim().length>0)}shouldHideGhostForPlaceholder(t){return!this.isFocused&&t&&this.hasNativePlaceholder()}bindBaseEvents(){let{signal:t}=this.abortController;this.input.addEventListener("copy",this.onBaseCopy,{signal:t}),this.input.addEventListener("focus",this.onBaseFocus,{signal:t}),this.input.addEventListener("blur",this.onBaseBlur,{signal:t})}onBaseCopy=t=>{if(!this.options.copyRaw||this.options.disabled||this.isSensitiveField())return;let e=this.input.selectionStart??0,i=this.input.selectionEnd??e,n="";e!==i?n=this.extractRawSnippet(this.input.value.slice(e,i)):n=this.getRawValue(),n&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",n))};extractRawSnippet(t){return t}getClipboardPlainText(t){return t.clipboardData&&(t.clipboardData.getData("text")||t.clipboardData.getData("text/plain"))||""}preparePastedText(t,e=Dt){let i=W(t,e);if(typeof this.options.transformPaste!="function")return i;try{let n=this.options.transformPaste(i);if(typeof n=="string")return W(n,e)}catch{}return i}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&&D(this.input.ownerDocument)===this.input&&this.input.select()},0))};onBaseBlur=()=>{this.isFocused=!1,this.isSensitiveField()&&(this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask"))};initMutationObserver(){if(typeof MutationObserver>"u")return;this.mutationObserver=new MutationObserver(e=>{for(let i of e)i.type==="attributes"&&i.attributeName&&this.handleAttributeMutation(i.attributeName)});let t={attributes:!0,attributeFilter:["data-mask","data-mask-placeholder","data-mask-focus-only","data-mask-strict","data-mask-select-on-focus","data-mask-copy-raw","data-mask-sensitive","data-mask-pad-decimals","data-mask-auto-lowercase","data-mask-cycle-suggestions","data-mask-default-tld","data-mask-tlds","data-mask-format","data-mask-utc-indicator","data-disabled","data-mask-align","data-align","placeholder","type"]};this.mutationObserver.observe(this.wrapper,t),this.input!==this.wrapper&&this.mutationObserver.observe(this.input,t)}isPasswordInput(){return(this.input.type||"").toLowerCase()==="password"}isSensitiveField(){return this.isPasswordInput()||!!this.options.sensitive}computePasswordDigest(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=Math.imul(e,16777619);return`__pwd:${(e>>>0).toString(36)}:${t.length}`}setAlign(t){let e=t&&Et.has(t)?t:null,i=e||void 0,n=this.wrapper.getAttribute("data-align"),s=e?this.wrapper.classList.contains(`align-${e}`):!this.wrapper.classList.contains("align-left")&&!this.wrapper.classList.contains("align-right")&&!this.wrapper.classList.contains("align-center");this.options.align===i&&n===e&&s||(this.options.align=i,this.wrapper.classList.remove("align-left","align-right","align-center"),e?(this.wrapper.classList.add(`align-${e}`),this.wasAlignSet=!0,this.wrapper.getAttribute("data-align")!==e&&this.wrapper.setAttribute("data-align",e)):this.wrapper.hasAttribute("data-align")&&this.wrapper.removeAttribute("data-align"),this.syncGhostStyles())}handleAttributeMutation(t){if(t==="data-disabled"){let e=this.hasAttr("data-disabled");e!==!!this.options.disabled&&this.setDisabled(e)}else if(t==="data-mask-focus-only"){let e=this.getAttr("data-mask-focus-only")==="true";e!==!!this.options.showMaskOnFocus&&this.setShowMaskOnFocus(e)}else if(t==="data-mask-select-on-focus")this.options.selectAllOnFocus=this.getAttr("data-mask-select-on-focus")==="true";else if(t==="data-mask-copy-raw")this.options.copyRaw=this.isSensitiveField()?!1:this.getAttr("data-mask-copy-raw")==="true";else if(t==="data-mask-sensitive"){let e=this.getAttr("data-mask-sensitive")==="true";this.options.sensitive=e,this.isSensitiveField()&&(this.options.copyRaw=!1,this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask"),this.onPasswordModeDetected())}else if(t==="type")this.isSensitiveField()&&(this.options.copyRaw=!1,this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask"),this.onPasswordModeDetected());else if(t==="data-mask-align"||t==="data-align"){let e=this.getAttr("data-mask-align")||this.getAttr("data-align"),i=e&&Et.has(e)?e:null;i!==(this.options.align??null)&&this.setAlign(i)}}normalizeInputType(){let t=["number","email","date","datetime-local","month","week","time","color","file","range"];if(this.input.type&&t.includes(this.input.type.toLowerCase())){let e=this.input.type.toLowerCase();this.input.type="text",e==="number"&&(this.input.inputMode="numeric")}}createGhost(){let t=this.wrapper.querySelector(".mask-ghost");t&&t.remove();let e=this.input.ownerDocument||document;this.ghost=e.createElement("div"),this.ghost.className="mask-ghost",this.ghost.setAttribute("aria-hidden","true"),this.ghost.style.display="flex",this.ghost.style.alignItems="center",this.wrapper.appendChild(this.ghost),this.wrapper.classList.add("has-ghost");let i=e.defaultView||(typeof window<"u"?window:null);(!this.wrapper.isConnected||!i||i.getComputedStyle(this.ghost).pointerEvents!=="none")&&(this.ghost.style.gridArea="1 / 1 / 2 / 2",this.ghost.style.pointerEvents="none"),this.syncGhostStyles(),typeof ResizeObserver<"u"&&(this.resizeObserver?.disconnect(),this.resizeObserver=new ResizeObserver(()=>{this.isDestroyed||this.syncGhostStyles()}),this.resizeObserver.observe(this.input));let n=e;n.fonts?.ready&&typeof n.fonts.ready.then=="function"&&n.fonts.ready.then(()=>{this.isDestroyed||this.syncGhostStyles()}).catch(()=>{})}setGhostContent(...t){if(this.ghost){if(typeof this.ghost.replaceChildren=="function")this.ghost.replaceChildren(...t);else{this.ghost.textContent="";for(let e of t)this.ghost.appendChild(typeof e=="string"?document.createTextNode(e):e)}this.wrapper.classList.toggle("has-visible-ghost",t.length>0)}}clearGhost(){this.setGhostContent()}syncGhostStyles(){if(!this.ghost||typeof window>"u")return;let t=window.getComputedStyle(this.input);if(!t)return;this.ghost.style.fontFamily=t.fontFamily,this.ghost.style.fontSize=t.fontSize,this.ghost.style.fontWeight=t.fontWeight,this.ghost.style.fontStyle=t.fontStyle,this.ghost.style.letterSpacing=t.letterSpacing,this.ghost.style.wordSpacing=t.wordSpacing,this.ghost.style.textIndent=t.textIndent,this.ghost.style.fontKerning=t.fontKerning,this.ghost.style.fontVariantNumeric=t.fontVariantNumeric,this.ghost.style.lineHeight=t.lineHeight,this.ghost.style.paddingTop=t.paddingTop,this.ghost.style.paddingBottom=t.paddingBottom,this.ghost.style.paddingLeft=t.paddingLeft,this.ghost.style.paddingRight=t.paddingRight,this.ghost.style.borderTopWidth=t.borderTopWidth,this.ghost.style.borderBottomWidth=t.borderBottomWidth,this.ghost.style.borderLeftWidth=t.borderLeftWidth,this.ghost.style.borderRightWidth=t.borderRightWidth,this.ghost.style.borderTopStyle=t.borderTopStyle==="none"?"none":"solid",this.ghost.style.borderBottomStyle=t.borderBottomStyle==="none"?"none":"solid",this.ghost.style.borderLeftStyle=t.borderLeftStyle==="none"?"none":"solid",this.ghost.style.borderRightStyle=t.borderRightStyle==="none"?"none":"solid",this.ghost.style.borderColor="transparent",this.ghost.style.boxSizing=t.boxSizing,this.ghost.style.textAlign=t.textAlign,this.ghost.style.direction=t.direction;let e=t.direction==="rtl"||this.input.getAttribute("dir")==="rtl"||this.wrapper.getAttribute("dir")==="rtl",i=t.textAlign;i==="right"?this.ghost.style.justifyContent="right":i==="left"?this.ghost.style.justifyContent="left":i==="center"?this.ghost.style.justifyContent="center":i==="end"?this.ghost.style.justifyContent=e?"left":"right":this.ghost.style.justifyContent=e?"right":"left"}setNativeValue(t){this.nativeValueDescriptor&&this.nativeValueDescriptor.set?this.nativeValueDescriptor.set.call(this.input,t):this.input.value=t}dispatchNativeInput(){if(!(this.isDestroyed||typeof window>"u")&&this.options.emitNativeInput!==!1){this.isDispatchingNativeInput=!0;try{let t=this.isSensitiveField(),e=this.input._valueTracker;!t&&e&&typeof e.setValue=="function"&&e.setValue(this.lastTrackedValue),this.lastTrackedValue=t?"":this.input.value,this.input.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))}finally{this.isDispatchingNativeInput=!1}}}onScroll=()=>{this.ghost&&(this.ghost.scrollLeft=this.input.scrollLeft)};hookValueProperty(){try{let t=HTMLInputElement.prototype,e=Object.getOwnPropertyDescriptor(t,"value");if(!e||!e.set||!e.get)return;this.nativeValueDescriptor=e;let i=this;Object.defineProperty(this.input,"value",{get(){return e.get.call(this)},set(n){let s=String(n??"");e.set.call(this,s),!i.isDestroyed&&i.onNativeValueSet(s)},configurable:!0})}catch{}}unhookValueProperty(){try{delete this.input.value}catch{}}setShowMaskOnFocus(t){this.options.showMaskOnFocus=t,this.wrapper.classList.toggle("mask-focus-only",t)}disabled(t){if(t===void 0)return!!this.options.disabled;this.setDisabled(t)}setDisabled(t){this.options.disabled=!!t,this.options.disabled?this.wrapper.setAttribute("data-disabled","true"):this.wrapper.removeAttribute("data-disabled"),this.onDisabledChange(this.options.disabled)}getWrapper(){return this.wrapper}getInput(){return this.input}getGhost(){return this.ghost}getElements(){return{wrapper:this.wrapper,input:this.input,ghost:this.ghost}}getValue(){return this.input.value}getRawValue(){return this.input.value}hasAccessibleLabelText(t){if(!t)return!1;if(t.getAttribute("aria-label")?.trim())return!0;let i=n=>{if(n.nodeType===3)return n.textContent||"";if(n.nodeType===1){let s=n,r=s.tagName;if(r==="INPUT"||r==="SELECT"||r==="TEXTAREA"||r==="BUTTON"||s.getAttribute("aria-hidden")==="true")return"";let o="";for(let a=0;a<s.childNodes.length;a++)o+=i(s.childNodes[a]);return o}return""};return i(t).trim().length>0}audit(){let t=[],e=this.input.ownerDocument||document,i=typeof this.input.getRootNode=="function"?this.input.getRootNode():e,n=typeof ShadowRoot<"u"&&i instanceof ShadowRoot?i:e,s=this.input.getAttribute("aria-label")?.trim(),r=this.checkAriaIdReferences(this.input,"aria-labelledby",t,!0),o=this.input.closest("label"),a=this.hasAccessibleLabelText(o),l=!!(this.input.labels&&Array.from(this.input.labels).some(d=>this.hasAccessibleLabelText(d))),u=!1;if(this.input.id)try{let d=n.querySelector(`label[for="${lt(this.input.id)}"]`);u=this.hasAccessibleLabelText(d)}catch{u=!1}!s&&!r&&!a&&!l&&!u&&t.push(`\xC9tiquetage accessible manquant : associez un <label for="id"> non vide (ou d\xE9finissez aria-label / aria-labelledby) sur l'input (WCAG 4.1.2).`),this.checkAriaIdReferences(this.input,"aria-describedby",t,!0),this.input.hasAttribute("aria-errormessage")&&this.checkAriaIdReferences(this.input,"aria-errormessage",t,!0);let h=this.input.getAttribute("tabindex");if(h!==null){let d=Number.parseInt(h,10);Number.isFinite(d)&&d>0&&t.push(`Attribut tabindex="${h}" positif d\xE9tect\xE9 : \xE9vitez les tabindex > 0 qui perturbent l'ordre de tabulation naturel (WCAG 2.4.3).`)}let c=this.getSpecificAuditWarnings();return t.push(...c),t}getAuditPrefix(){return`Wulf.Mask.${this.constructor.name||"InputMask"}`}getAuditTargetLabel(){return this.input.id?`#${this.input.id}`:this.input.name?`input[name="${this.input.name}"]`:"<input>"}getAuditDisableHint(){return'Passez { audit: false } ou data-mask-audit="false" pour d\xE9sactiver cet avertissement'}getSpecificAuditWarnings(){return[]}onPasswordModeDetected(){}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.focusSelectTimerId!==null&&(clearTimeout(this.focusSelectTimerId),this.focusSelectTimerId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.abortController.abort(),this.lastTrackedValue="",this.unhookValueProperty(),this.ghost&&(this.ghost.remove(),this.ghost=null),this.isWrapperCreated&&this.wrapper?(this.wasWrapperFallbackStyled&&(this.input.style.gridArea="",this.input.style.boxSizing=""),this.wrapper.parentElement?ut(this.wrapper.parentElement,this.input,this.wrapper):this.wrapper.parentNode&&this.wrapper.parentNode.insertBefore(this.input,this.wrapper),this.wrapper.remove()):this.wrapper&&(this.wrapper.removeAttribute("data-mask"),this.wrapper.removeAttribute("data-disabled"),this.wasAlignSet&&!this.hadInitialDataAlign&&this.wrapper.removeAttribute("data-align"),this.wasAlignSet&&this.wrapper.classList.remove("align-left","align-right","align-center"),this.wrapper.classList.remove("is-complete","is-focused","mask-focus-only","has-selection","has-ghost","has-visible-ghost")))}};var $t=new Set(["/","-",".",":"]),he={9:{pattern:/[0-9]/},a:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:f=>f.toUpperCase()},"*":{pattern:/[a-zA-Z0-9]/},"#":{pattern:/[a-zA-Z0-9]/,transform:f=>f.toUpperCase()}},Z=class f{pattern;patterns=[];patternResolver=null;lastResolvedKey="";subEngines=[];activeEngine=null;placeholderChar;tokens;slots=[];fullMaskTemplate="";prefixSlotsCount=0;prefixString="";strict=!0;autoLowercase=!1;constructor(t,e={}){let i=e||{},n=String(i.placeholderChar||"_");this.placeholderChar=Array.from(n)[0]||"_";let s=Object.create(null);for(let[r,o]of Object.entries(he))s[r]=o;if(i.tokens&&typeof i.tokens=="object")for(let[r,o]of Object.entries(i.tokens))r!=="__proto__"&&r!=="constructor"&&r!=="prototype"&&o&&(s[r]=o);this.tokens=s,this.strict=i.strict!==!1,this.autoLowercase=i.autoLowercase??!1,this.pattern="",this.compile(t)}static format(t,e,i={}){return!e||Array.isArray(e)&&e.length===0?t??"":new f(e,i||{}).format(t??"")}isDynamicPattern(){return this.patternResolver!==null}resolveForValue(t){if(!this.patternResolver)return!1;let e;try{e=this.patternResolver(String(t??"").slice(0,4096))}catch{return!1}let i,n;if(Array.isArray(e))i=e.slice(0,32).map(s=>String(s??"").slice(0,512)),n="A:"+i.join("\0");else if(typeof e=="string")i=e.slice(0,512),n="S:"+i;else return!1;return n===this.lastResolvedKey?!1:(this.lastResolvedKey=n,this.compileStatic(i),!0)}compile(t){return typeof t=="function"?(this.patternResolver=t,this.lastResolvedKey="",this.resolveForValue(""),this.slots):t!==void 0?(this.patternResolver=null,this.lastResolvedKey="",this.compileStatic(t)):this.patternResolver?(this.lastResolvedKey="",this.resolveForValue(""),this.slots):this.compileStatic(this.patterns.length>0?this.patterns:this.pattern)}compileStatic(t){if(Array.isArray(t)?(this.patterns=t.slice(0,32).map(n=>String(n??"").slice(0,512)),this.pattern=this.patterns[0]||""):(this.patterns=[],this.pattern=String(t??"").slice(0,512)),this.patterns.length>0)return this.subEngines=this.patterns.map(n=>new f(n,{placeholderChar:this.placeholderChar,tokens:this.tokens,strict:this.strict,autoLowercase:this.autoLowercase})),this.activeEngine=this.subEngines[0],this.slots=this.activeEngine.slots,this.fullMaskTemplate=this.activeEngine.fullMaskTemplate,this.prefixSlotsCount=this.activeEngine.prefixSlotsCount,this.prefixString=this.activeEngine.prefixString,this.slots;this.subEngines=[],this.activeEngine=null,this.slots=[];let e="",i=!0;for(let n=0;n<this.pattern.length;n++){let s=this.pattern[n],r=!1;s==="\\"&&n+1<this.pattern.length&&(r=!0,n++,s=this.pattern[n]);let o=!r&&Object.hasOwn(this.tokens,s)?this.tokens[s]:void 0;if(o){i=!1;let a=o.placeholder?Array.from(String(o.placeholder))[0]||this.placeholderChar:this.placeholderChar;this.slots.push({char:s,isStatic:!1,isPrefix:!1,token:o,placeholder:a}),e+=a}else this.slots.push({char:s,isStatic:!0,isPrefix:i,placeholder:s}),e+=s}this.fullMaskTemplate=e,this.prefixSlotsCount=0,this.prefixString="";for(let n of this.slots)if(n.isPrefix)this.prefixSlotsCount++,this.prefixString+=n.char;else break;return this.slots}selectEngine(t){if(this.subEngines.length<=1)return this;let e=String(t??""),i=this.subEngines.filter(a=>{let l=a.getPrefix();return l.length>0&&e.toLowerCase().startsWith(l.trim().toLowerCase())}),n=i.length>0?i:this.subEngines,s=n.toSorted((a,l)=>l.getEditableCount()-a.getEditableCount())[0],o=(s?s.extractRaw(e):e).length;for(let a of n)if(a.getEditableCount()>=o)return this.activeEngine=a,a;return this.activeEngine=n[n.length-1],this.activeEngine}getPrefix(){return this.activeEngine?this.activeEngine.getPrefix():this.prefixString}getPrefixLength(){return this.activeEngine?this.activeEngine.getPrefixLength():this.prefixSlotsCount}getFullMaskTemplate(){return this.activeEngine?this.activeEngine.getFullMaskTemplate():this.fullMaskTemplate}getActiveEditableCount(){return this.subEngines.length>0?(this.activeEngine??this.subEngines[0]).getActiveEditableCount():this.activeEngine?this.activeEngine.getActiveEditableCount():this.slots.filter(t=>!t.isStatic).length}getMaxEditableCount(){return this.subEngines.length>0?Math.max(...this.subEngines.map(t=>t.getMaxEditableCount())):this.getActiveEditableCount()}getEditableCount(){return this.getMaxEditableCount()}isNumericOnly(){if(this.subEngines.length>0)return this.subEngines.every(i=>i.isNumericOnly());let e=(this.activeEngine?this.activeEngine.slots:this.slots).filter(i=>!i.isStatic);return e.length===0?!1:e.every(i=>i.char==="9"||i.token&&i.token.pattern.test("0")&&!i.token.pattern.test("a")&&!i.token.pattern.test("Z"))}setStrict(t){this.strict=t;for(let e of this.subEngines)e.setStrict(t)}setAutoLowercase(t){this.autoLowercase=t;for(let e of this.subEngines)e.setAutoLowercase(t)}isStrict(){return this.strict}normalizePastedValue(t){let e=String(t??"");if(!e)return e;if(this.resolveForValue(e),this.subEngines.length>0){let i=e.toLowerCase(),n=this.subEngines.filter(o=>{let a=o.getPrefix();return a.length>0&&i.startsWith(a.trim().toLowerCase())}),s=n.length>0?n:this.subEngines,r=null;for(let o of s){let a=o.tryNormalizeSegments(e);if(a.matched){if(a.exactSegmentCount)return a.normalized;r===null&&(r=a.normalized)}}return r!==null?r:e}return this.tryNormalizeSegments(e).normalized}tryNormalizeSegments(t){let e={matched:!1,normalized:t,exactSegmentCount:!1};if(!this.strict||this.slots.length===0||!t)return e;let i=t;if(this.prefixSlotsCount>0){let v=0;for(;v<t.length&&(t[v]===" "||t[v]===" ");)v++;let y=0;for(;v<t.length&&y<this.prefixSlotsCount;){let T=this.slots[y].char,A=t[v];if(A.toUpperCase()===T.toUpperCase())v++,y++;else if(T===" "&&A!==" ")y++;else break}y===this.prefixSlotsCount&&(i=t.slice(v))}if(!i)return e;let n=[],s=[],r=[],o="",a=!1;for(let v=this.prefixSlotsCount;v<this.slots.length;v++){let y=this.slots[v];y.isStatic?r.length>0?(n.push(r),r=[],o=y.char):o+=y.char:(o.length>0&&(s.push(o),o=""),r.push(y))}if(r.length>0?n.push(r):o.length>0&&(a=!0),a||n.length<2||s.length!==n.length-1)return e;let l=[];for(let v of s){let y=v.trim();if(y.length!==1||!$t.has(y))return e;l.push(y)}let u=[],h=[],c=0;for(let v=0;v<i.length;v++){let y=i[v];$t.has(y)&&(u.push(i.slice(c,v).trim()),h.push(y),c=v+1)}if(u.push(i.slice(c).trim()),h.length===0||h.length>l.length||u.length!==h.length+1||u.length>n.length||u.some(v=>v.length===0))return e;let d=h.every((v,y)=>v===l[y]),p=h.every(v=>v===h[0]);if(!d&&!p)return e;let m=u.length===n.length,g=[];for(let v=0;v<u.length;v++){let y=u[v],T=n[v];if(y.length>T.length)return e;if(T.every(S=>!!(S.token&&S.token.pattern.test("0")&&!S.token.pattern.test("a")&&!S.token.pattern.test("Z")))){let S=v<u.length-1,w=v===u.length-1&&m&&n.length<=3&&T.length===2,C=y.length<T.length&&(S||w),E=C?T.length-y.length:0;for(let M=0;M<y.length;M++){let k=y[M];if(k<"0"||k>"9"||!T[E+M].token.pattern.test(k))return e}g.push(C?"0".repeat(T.length-y.length)+y:y)}else{if(y.length!==T.length)return e;for(let S=0;S<y.length;S++)if(!T[S].token||!T[S].token.pattern.test(y[S]))return e;g.push(y)}}let b=this.prefixSlotsCount>0?this.prefixString:"";for(let v=0;v<g.length;v++)v>0&&(b+=s[v-1]),b+=g[v];return{matched:!0,normalized:b,exactSegmentCount:m}}extractRawForCurrentPattern(t){return this.extractRawInternal(t)}extractRaw(t){return this.resolveForValue(t),this.extractRawInternal(t)}extractRawInternal(t){if(this.subEngines.length>0){let o=this.selectEngine(t);if(o!==this)return o.extractRawInternal(t)}let e=Math.max(4096,this.slots.length*4),i=String(t??"").slice(0,e);if(!i)return"";let n="",s=0,r=0;if(this.prefixSlotsCount>0){for(;s<i.length&&(i[s]===" "||i[s]===" ");)s++;let o=0;for(;s<i.length&&o<this.prefixSlotsCount;){let a=this.slots[o].char,l=i[s];if(l.toUpperCase()===a.toUpperCase())s++,o++;else if(a===" "&&l!==" ")o++;else break}r=this.prefixSlotsCount}for(;s<i.length&&r<this.slots.length;){let o=this.slots[r],a=i[s];if(o.isStatic)a.toUpperCase()===o.char.toUpperCase()&&s++,r++;else if(o.token&&o.token.pattern.test(a)){let l=o.token.transform?o.token.transform(a):a;this.autoLowercase&&!o.token.transform&&(l=l.toLowerCase()),n+=l,s++,r++}else this.strict?s++:(n+=this.autoLowercase?a.toLowerCase():a,s++,r++)}if(!this.strict&&s<i.length){let o=i.slice(s);n+=this.autoLowercase?o.toLowerCase():o}return n}format(t){if(this.resolveForValue(t),this.subEngines.length>0){let o=this.selectEngine(t);if(o!==this)return o.format(t)}let e=Math.max(4096,this.slots.length*4),i=String(t??"").slice(0,e);if(!this.slots.length)return i;let n=this.extractRawInternal(i);if(n.length===0)return this.prefixString;let s="",r=0;for(let o=0;o<this.slots.length;o++){let a=this.slots[o];if(a.isStatic){let l=r<n.length,u=r===0&&!!a.isPrefix,h=r>0&&r===n.length;if(l||u||h)s+=a.char;else break}else if(r<n.length){let l=n[r],u=a.token?.transform?a.token.transform(l):l;this.autoLowercase&&!a.token?.transform&&(u=u.toLowerCase()),s+=u,r++}else break}if(!this.strict&&r<n.length){let o=n.substring(r);s+=this.autoLowercase?o.toLowerCase():o}return s}getRemainingMask(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getRemainingMask(t):this.fullMaskTemplate?t.length>=this.fullMaskTemplate.length?t:t+this.fullMaskTemplate.substring(t.length):""}mapCursorPosition(t,e,i){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.mapCursorPosition(t,e,i);let n=this.prefixSlotsCount,s=String(t??""),r=String(i??"");if(e<=0||!r)return n;let a=this.extractRawInternal(s.slice(0,e)).length;if(a===0)return Math.max(n,Math.min(this.getNextEditablePosition(0),r.length));let l=0,u=r.length;for(let h=0;h<r.length&&h<this.slots.length;h++)if(!this.slots[h].isStatic&&(l++,l===a)){u=h+1;break}for(;u<r.length&&this.slots[u]&&this.slots[u].isStatic;)u++;return Math.max(n,Math.min(u,r.length))}isSeparatorAt(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.isSeparatorAt(t):t>=0&&t<this.slots.length?this.slots[t].isStatic:!1}getNextEditablePosition(t){if(this.activeEngine&&this.activeEngine!==this)return this.activeEngine.getNextEditablePosition(t);let e=Math.max(0,t);for(let i=e;i<this.slots.length;i++)if(!this.slots[i].isStatic)return i;return this.slots.length}getSlotAt(t){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlotAt(t):this.slots[t]}getSlots(){return this.activeEngine&&this.activeEngine!==this?this.activeEngine.getSlots():this.slots}};var U=class{stack=[];index=-1;maxDepth;constructor(t=50){this.maxDepth=t}push(t,e){let i=this.getCurrent();if(i&&i.raw===t){i.cursor=e;return}this.stack=this.stack.slice(0,this.index+1),this.stack.push({raw:t,cursor:e}),this.stack.length>this.maxDepth&&this.stack.shift(),this.index=this.stack.length-1}updateCurrentCursor(t){let e=this.getCurrent();e&&(e.cursor=t)}undo(){return this.canUndo()?(this.index--,this.stack[this.index]):null}redo(){return this.canRedo()?(this.index++,this.stack[this.index]):null}canUndo(){return this.index>0}canRedo(){return this.index>=0&&this.index<this.stack.length-1}getCurrent(){return this.index>=0&&this.index<this.stack.length?this.stack[this.index]:null}clear(){this.stack=[],this.index=-1}};var nt=class{delegate;constructor(t){this.delegate=t}handleKeyDown(t){if(R(t))return;let e=this.delegate.getInput(),i=this.delegate.getEngine(),n=this.delegate.getHistory(),s=i.getPrefixLength(),r=e.selectionStart??0,o=e.selectionEnd??r;if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")&&!t.shiftKey){t.preventDefault(),this.delegate.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")||(t.ctrlKey||t.metaKey)&&t.shiftKey&&(t.key==="z"||t.key==="Z")){t.preventDefault(),this.delegate.redo();return}n.updateCurrentCursor(r);let a=t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey,l=o>r;if(a&&!l){let c=i.getSlots(),d=r<c.length&&c[r].isStatic&&c[r].char===t.key,p=-1;if(r>0&&r-1<c.length)if(c[r-1].isStatic&&c[r-1].char===t.key)p=r-1;else{let b=r-1;for(;b>=s&&c[b].isStatic;){if(c[b].char===t.key){p=b;break}b--}}if(d||p!==-1){t.preventDefault();let b=d?r:p,v=i.getNextEditablePosition(b+1);this.delegate.applyMask(e.value,v,!0);return}let g=-1;for(let b=r;b<c.length;b++)if(c[b].isStatic){c[b].char===t.key&&(g=b);break}if(g!==-1){t.preventDefault();let b=g-1;for(;b>=s&&!c[b].isStatic;)b--;b++;let v=g-b,y=e.value.slice(b,r);if(c.slice(b,g).every(S=>!!(S.token&&S.token.pattern.test("0")&&!S.token.pattern.test("a")&&!S.token.pattern.test("Z")))&&v>y.length&&y.length>0){let S=v-y.length,w="0".repeat(S)+y,C=e.value.slice(g),E=e.value.slice(0,b)+w+C,M=i.getNextEditablePosition(g+1);this.delegate.applyMask(E,M,!0);return}let A=i.getNextEditablePosition(g+1);this.delegate.applyMask(e.value,A,!0);return}}if(a&&i.isStrict()){let c=i.isDynamicPattern(),d=i.extractRaw(e.value),p=o>r?i.extractRawForCurrentPattern(e.value.slice(r,o)):"";if(c){let g=e.value.slice(0,r)+t.key+e.value.slice(o);i.resolveForValue(g)}let m=i.getMaxEditableCount();if(m>0&&m-(d.length-p.length)<=0){c&&i.resolveForValue(e.value),t.preventDefault();return}c&&i.resolveForValue(e.value)}if(o>r){if(t.key==="Backspace"||t.key==="Delete"){t.preventDefault();let c=e.value,d=c.slice(0,r)+c.slice(o);this.delegate.applyMask(d,Math.max(s,r));return}return}if(t.key==="ArrowLeft"&&!t.shiftKey&&r<=s){t.preventDefault(),e.setSelectionRange(s,s);return}if(t.key==="Home"&&s>0&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey){t.preventDefault(),e.setSelectionRange(s,s);return}if(t.key==="Backspace"&&r<=s){t.preventDefault(),e.setSelectionRange(s,s);return}if(t.key==="Delete"&&r<s){t.preventDefault(),e.setSelectionRange(s,s);return}if(t.key==="Backspace"&&(t.ctrlKey||t.altKey||t.metaKey)){if(t.preventDefault(),r<=s){e.setSelectionRange(s,s);return}let c=r-1;for(;c>=s&&i.isSeparatorAt(c);)c--;for(;c>=s&&!i.isSeparatorAt(c);)c--;let d=Math.max(s,c+1),p=e.value,m=p.slice(0,d)+p.slice(r);this.delegate.applyMask(m,d);return}if(t.key==="Delete"&&(t.ctrlKey||t.altKey||t.metaKey)){t.preventDefault();let c=e.value;if(r>=c.length)return;let d=r;for(;d<c.length&&i.isSeparatorAt(d);)d++;for(;d<c.length&&!i.isSeparatorAt(d);)d++;for(;d<c.length&&i.isSeparatorAt(d);)d++;let p=d,m=c.slice(0,r)+c.slice(p);this.delegate.applyMask(m,r);return}if(t.key==="Backspace"&&r>s){if(i.isSeparatorAt(r-1)){t.preventDefault();let c=r-1;for(;c>s&&i.isSeparatorAt(c-1);)c--;if(c>s){let d=e.value,p=d.slice(0,c-1)+d.slice(r);this.delegate.applyMask(p,c-1)}else this.delegate.applyMask("",s)}return}if(t.key==="Delete"&&r<e.value.length){if(i.isSeparatorAt(r)){t.preventDefault();let c=r;for(;c<e.value.length&&i.isSeparatorAt(c);)c++;if(c<e.value.length){let d=e.value,p=d.slice(0,c)+d.slice(c+1);this.delegate.applyMask(p,r)}}return}}handleKeyUp(t){let e=this.delegate.getInput(),i=this.delegate.getHistory();(t.key==="ArrowLeft"||t.key==="ArrowRight"||t.key==="Home")&&!t.shiftKey&&this.delegate.enforceMinCursor(),i.updateCurrentCursor(e.selectionStart??0)}};var ht=class extends N{engine;history;keyboard;isComposing=!1;isUndoingRedoing=!1;isMouseDown=!1;isApplyingMask=!1;lastValue="";lastInternalRemainingMask="";isNotifying=!1;hasPendingNotification=!1;onChangeNativeHandler=()=>{};wasInputModeInferred=!1;cutTimerId=null;pasteTimerId=null;resetTimerId=null;lastInputType="";constructor(t,e,i){let n=X(t,e,i),s=n.wrapper,r=n.input,o=n.options,a=s?.getAttribute("data-mask")||r?.getAttribute("data-mask"),l=o.mask||a||"";typeof l=="string"&&l.includes("|")&&(l=l.split("|").map(T=>T.trim()));let u=o.placeholderChar||s?.getAttribute("data-mask-placeholder")||r?.getAttribute("data-mask-placeholder")||"_",h=s?.hasAttribute("data-disabled")||r?.hasAttribute("data-disabled"),c=s?.getAttribute("data-mask-strict")||r?.getAttribute("data-mask-strict"),d=s?.getAttribute("data-mask-auto-lowercase")==="true"||r?.getAttribute("data-mask-auto-lowercase")==="true",p=s?.getAttribute("data-mask-infer-inputmode")??r?.getAttribute("data-mask-infer-inputmode"),m=o.inferInputMode??(p!==null?p!=="false":!0),{disabled:g,...b}=o,v=g!==void 0?g:h?!0:!l||Array.isArray(l)&&l.length===0,y={...b,mask:l,placeholderChar:u,strict:o.strict??(c!==null?c!=="false":!0),autoLowercase:o.autoLowercase??d??!1,disabled:v,resetHistoryOnMaskChange:o.resetHistoryOnMaskChange??!1,inferInputMode:m,onInput:o.onInput||o.oninput,onChange:o.onChange||o.onchange,onComplete:o.onComplete||o.oncomplete};super(s,r,y),this.history=new U,this.engine=new Z(this.options.mask||"",{placeholderChar:this.options.placeholderChar,tokens:this.options.tokens,strict:this.options.strict,autoLowercase:this.options.autoLowercase}),this.syncInferredInputMode(),this.keyboard=new nt({getInput:()=>this.input,getEngine:()=>this.engine,getHistory:()=>this.history,applyMask:(T,A,S)=>this.applyMask(T,A,S),undo:()=>this.undo(),redo:()=>this.redo(),enforceMinCursor:()=>this.enforceMinCursor()}),this.bindEvents(),this.lastValue=this.isSensitiveField()?this.computePasswordDigest(this.input.value):this.input.value,this.syncInitialValue(),this.runAuditWarning(this.options.audit)}getSpecificAuditWarnings(){let t=[],e=[],i=this.checkAriaIdReferences(this.input,"aria-describedby",e,!0),n=!!this.input.getAttribute("placeholder")?.trim(),s=!!this.input.getAttribute("aria-placeholder")?.trim();return!i&&!s&&!this.options.disabled&&(n?t.push("Indication du format attendu fragile : l'attribut placeholder seul dispara\xEEt \xE0 la saisie et est masqu\xE9 par le gabarit fant\xF4me ; utilisez aria-describedby ou aria-placeholder (WCAG 3.3.2)."):t.push("Indication du format attendu manquante : d\xE9finissez aria-describedby ou aria-placeholder pour informer les technologies d'assistance (WCAG 3.3.2).")),t}extractRawSnippet(t){return this.engine.extractRaw(t)}onPasswordModeDetected(){this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask")}static format(t,e,i={}){return Z.format(t,e,i)}onNativeValueSet(t){if(this.options.disabled)this.checkValueChange();else{let e=this.applyTransformInput(t,"programmatic","");this.applyMask(e,e.length)}}onDisabledChange(t){t?(this.wrapper.removeAttribute("data-mask"),this.wrapper.classList.remove("is-complete","has-selection"),this.clearGhost(),this.checkValueChange()):this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length),this.syncInferredInputMode()}bindEvents(){this.handleInput=this.handleInput.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onClick=this.onClick.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onSelect=this.onSelect.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onScroll=this.onScroll.bind(this),this.onBeforeInput=this.onBeforeInput.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,!this.isDestroyed)if(this.options.disabled)this.checkValueChange();else{let e=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,e)}},0)},this.onChangeNativeHandler=()=>{this.isDestroyed||this.checkValueChange()};let{signal:t}=this.abortController;this.input.addEventListener("beforeinput",this.onBeforeInput,{signal:t}),this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.onKeyDown,{signal:t}),this.input.addEventListener("paste",this.onPaste,{signal:t}),this.input.addEventListener("focus",this.onFocus,{signal:t}),this.input.addEventListener("blur",this.onBlur,{signal:t}),this.input.addEventListener("click",this.onClick,{signal:t}),this.input.addEventListener("keyup",this.onKeyUp,{signal:t}),this.input.addEventListener("select",this.onSelect,{signal:t}),this.input.addEventListener("mousedown",this.onMouseDown,{signal:t}),window.addEventListener("mouseup",this.onMouseUp,{signal:t}),this.input.addEventListener("compositionstart",this.onCompositionStart,{signal:t}),this.input.addEventListener("compositionend",this.onCompositionEnd,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("change",this.onChangeNativeHandler,{signal:t}),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled?this.checkValueChange():this.syncInitialValue())},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:t}))}syncInferredInputMode(){if(!this.options.inferInputMode)return;!this.options.disabled&&this.engine.isNumericOnly()?this.input.hasAttribute("inputmode")||(this.input.inputMode="numeric",this.wasInputModeInferred=!0):this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&(this.input.removeAttribute("inputmode"),this.wasInputModeInferred=!1)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.pasteTimerId!==null&&(clearTimeout(this.pasteTimerId),this.pasteTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="numeric"&&this.input.removeAttribute("inputmode"),this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",super.destroy())}setStrict(t){this.options.strict=t,this.engine.setStrict(t),this.options.disabled||this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)}isStrict(){return this.engine.isStrict()}setMask(t,e){let i=typeof e=="boolean"?e:e&&typeof e=="object"&&e.strict!==void 0?e.strict:this.options.strict,n=e&&typeof e=="object"&&e.resetHistory!==void 0?e.resetHistory:!!this.options.resetHistoryOnMaskChange;if(!((!t||Array.isArray(t)&&t.length===0)&&this.options.disabled&&(!this.options.mask||this.options.mask===""))){if(!t||Array.isArray(t)&&t.length===0){this.options.mask="",this.options.strict=i,this.engine.setStrict(i??!0),this.engine.compile(""),n&&this.history.clear(),this.setDisabled(!0),this.syncInferredInputMode();return}this.options.mask=t,this.options.strict=i,this.engine.setStrict(i??!0),this.engine.compile(t),n&&this.history.clear(),this.setDisabled(!1),this.syncInferredInputMode()}}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask"){let e=this.getAttr("data-mask");if(e===null&&(this.isSensitiveField()||typeof this.options.mask=="function")||e===this.lastInternalRemainingMask)return;let i=typeof this.options.mask=="function"?"":Array.isArray(this.options.mask)?this.options.mask.join("|"):this.options.mask||"";if(e===i)return;if(e){let n=e.includes("|")?e.split("|").map(s=>s.trim()):e;this.setMask(n)}else this.setMask(null)}else if(t==="data-mask-strict"){let e=this.getAttr("data-mask-strict");this.setStrict(e!=="false")}else t==="data-mask-auto-lowercase"?(this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true",this.engine.setAutoLowercase(this.options.autoLowercase),this.engine.compile(this.options.mask||""),this.applyMask(this.input.value,this.input.selectionStart??this.input.value.length)):t==="placeholder"&&this.updateGhost(this.input.value)}applyTransformInput(t,e,i){if(typeof this.options.transformInput!="function")return t;try{let n=this.options.transformInput(t,{source:e,inputType:i});if(typeof n=="string")return e==="paste"?W(n,4096):z(n,4096)}catch{}return t}setValue(t){let e=t!=null?String(t):"";if(this.options.disabled){this.input.value=e,this.checkValueChange();return}let i=this.applyTransformInput(e,"programmatic","");this.applyMask(i,i.length)}getRawValue(){return this.engine.extractRaw(this.input.value)}isComplete(){if(this.options.disabled)return!0;let t=this.getRawValue(),e=this.engine.getActiveEditableCount();return e===0?!0:t.length>=e}get onInput(){return this.options.onInput}set onInput(t){this.options.onInput=t}undo(){if(this.options.disabled)return;let t=this.history.undo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}redo(){if(this.options.disabled)return;let t=this.history.redo();t&&(this.isUndoingRedoing=!0,this.applyMask(t.raw,t.cursor),this.isUndoingRedoing=!1)}checkSelection(){if(this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??t,i=t!==e;this.wrapper.classList.toggle("has-selection",i)}onBeforeInput(t){if(this.lastInputType=t.inputType||"",!this.options.disabled&&!this.isComposing&&this.engine.isStrict()&&!(t.inputType==="insertFromPaste"||t.inputType==="insertReplacementText")&&t.inputType&&t.inputType.startsWith("insert")){let e=this.input.value,i=this.engine.isDynamicPattern(),n=this.engine.extractRaw(e),s=this.input.selectionStart??0,r=this.input.selectionEnd??s,o=r>s?this.engine.extractRawForCurrentPattern(e.slice(s,r)):"";if(i){let l=e.slice(0,s)+(t.data??"")+e.slice(r);this.engine.resolveForValue(l)}let a=this.engine.getMaxEditableCount();if(a>0&&Math.max(0,a-(n.length-o.length))<=0){i&&this.engine.resolveForValue(e),t.preventDefault();return}i&&this.engine.resolveForValue(e)}}handleInput(t){if(this.isDispatchingNativeInput||this.isComposing)return;let e=t?.inputType||this.lastInputType||"";this.lastInputType="";let i=!!(this.options.onInput||this.options.oninput),n=this.isSensitiveField()?this.computePasswordDigest(this.input.value):this.input.value;if(i&&n!==this.lastValue&&this.checkValueChange(),this.options.disabled){this.checkValueChange();return}let s=this.input.value,r=this.input.selectionStart??s.length,o=this.applyTransformInput(s,"input",e),a=o!==s?r>=s.length?o.length:Math.min(r,o.length):r,l=this.history.getCurrent(),u=this.engine.extractRaw(o),h=this.engine.getMaxEditableCount();if(h>0&&this.engine.isStrict()&&l&&l.raw.length>=h&&u.length>h){this.applyMask(l.raw,l.cursor);return}this.applyMask(o,a),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 e=this.preparePastedText(this.getClipboardPlainText(t),4096),i=this.applyTransformInput(e,"paste","insertFromPaste");if(!i)return;let n=this.engine.getPrefixLength(),s=this.input.selectionStart??0,r=this.input.selectionEnd??s,o=this.input.value,a=this.getRawValue(),l=this.engine.getMaxEditableCount(),u=this.engine.getPrefix(),h=u.replace(/[\s.-]+/g,"").toUpperCase(),c=i.replace(/[\s.-]+/g,"").toUpperCase(),d=h.length>0&&c.startsWith(h),p=o.slice(0,Math.max(n,s)).replace(/[\s.-]+/g,"").toUpperCase(),m=p.length>=2&&c.startsWith(p),g=Math.max(n,s),b=Math.max(n,r);(d||m)&&(g=0,b=o.length);let v=Math.max(0,l-a.length);if(g!==b){let C=this.engine.extractRawForCurrentPattern(o.slice(g,b));v=Math.max(0,l-(a.length-C.length))}let y=this.engine.normalizePastedValue(i),T=this.engine.getActiveEditableCount(),A=T>0&&a.length>=T;if(this.engine.isStrict()&&(v<=0||s===r&&A)){let C=this.engine.extractRaw(y).length,E=this.engine.getMaxEditableCount();if(s===r&&E>0&&C===E&&(v<=0||C>v))g=0,b=o.length;else if(v<=0){this.engine.resolveForValue(o);return}else this.engine.resolveForValue(o)}let S,w;g===0&&b===o.length?(S=y,w=y.length):a.length===0&&g===n&&b===o.length?n>0&&y.toUpperCase().startsWith(u.toUpperCase())?(S=y,w=y.length):(S=o.slice(0,g)+y,w=S.length):(S=o.slice(0,g)+i+o.slice(b),w=g+i.length),this.applyMask(S,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(){if(this.wrapper.classList.remove("is-focused","has-selection"),this.isSensitiveField()){this.history.clear(),this.lastValue="",this.lastInternalRemainingMask="",this.lastTrackedValue="",this.clearGhost(),this.wrapper.removeAttribute("data-mask");return}this.updateGhost(this.input.value)}onClick(){this.options.disabled||this.enforceMinCursor(),this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onKeyUp(t){this.options.disabled||this.keyboard.handleKeyUp(t),this.checkSelection()}onSelect(){this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyMask(this.input.value,t),this.checkSelection()}enforceMinCursor(){let t=this.engine.getPrefixLength();if(t<=0)return;let e=this.input.selectionStart??0,i=this.input.selectionEnd??e;e===i&&e<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled||this.isSensitiveField()){this.clearGhost();return}let e=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(e)){this.clearGhost();return}let i=this.engine.getFullMaskTemplate(),n=i.length>t.length?i.substring(t.length):"",s=this.input.ownerDocument||document,r=s.createElement("span");r.className="mask-ghost-typed",r.textContent=t;let o=s.createElement("span");o.className="mask-ghost-remaining",o.textContent=n,this.setGhostContent(r,o),this.ghost.scrollLeft=this.input.scrollLeft}applyMask(t,e,i=!1){if(this.options.disabled||this.isApplyingMask)return;this.isApplyingMask=!0;let n="",s=!1;try{n=this.engine.format(t),this.engine.isDynamicPattern()&&this.syncInferredInputMode();let r=this.engine.getRemainingMask(n),o=this.isSensitiveField();this.setNativeValue(n),o?(this.lastInternalRemainingMask="",this.wrapper.removeAttribute("data-mask"),this.clearGhost()):(this.lastInternalRemainingMask=r,this.wrapper.setAttribute("data-mask",r),this.updateGhost(n));let a=this.engine.getPrefixLength(),l;if(i||this.isUndoingRedoing)l=Math.max(a,Math.min(e,n.length));else{let u=this.engine.mapCursorPosition(t,e,n);l=Math.max(a,u)}this.input.setSelectionRange(l,l),s=this.isComplete(),this.wrapper.classList.toggle("is-complete",s),o?(this.options.copyRaw=!1,this.history.clear()):this.isUndoingRedoing||this.history.push(this.getRawValue(),l)}finally{this.isApplyingMask=!1}this.checkValueChange()}syncInitialValue(){let t=this.isSensitiveField();if(this.options.disabled){this.wrapper.removeAttribute("data-mask"),this.clearGhost(),this.lastValue=t?this.computePasswordDigest(this.input.value):this.input.value,this.checkValueChange();return}this.syncGhostStyles();let e=this.input.value||"";if(e){let i=this.applyTransformInput(e,"programmatic","");this.applyMask(i,i.length)}else{let i=this.engine.getPrefixLength();if(i>0)this.applyMask("",i);else{if(t)this.lastInternalRemainingMask="",this.wrapper.removeAttribute("data-mask"),this.clearGhost();else{this.history.push("",0);let n=this.engine.getFullMaskTemplate();this.lastInternalRemainingMask=n,this.wrapper.setAttribute("data-mask",n),this.updateGhost("")}this.checkValueChange()}}}checkValueChange(t=!1){let e=this.isSensitiveField(),i=this.input.value;if(!((e?this.computePasswordDigest(i):i)===this.lastValue&&!t&&!this.hasPendingNotification)){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{let s=0,r=10;for(;((this.isSensitiveField()?this.computePasswordDigest(this.input.value):this.input.value)!==this.lastValue||this.hasPendingNotification||t)&&s<r;){s++,this.hasPendingNotification=!1,t=!1;let o=this.isSensitiveField(),a=this.input.value;this.lastValue=o?this.computePasswordDigest(a):a;let l=this.options.disabled?a:this.getRawValue(),u=this.options.disabled?0:this.engine.getActiveEditableCount(),h=this.isComplete(),c={value:a,rawValue:l,isComplete:h,totalSlots:u,filledSlots:this.options.disabled?a.length:l.length},d=!o,p=this.options.onInput||this.options.oninput;p&&p(a,c),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:d,detail:c})),this.dispatchNativeInput();let m=this.options.onChange||this.options.onchange;m&&m(c),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:d,detail:c}));let g=this.options.onComplete||this.options.oncomplete;h&&(g&&g(c),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:d,detail:c})))}}finally{this.isNotifying=!1}}}};var J=class f{options;constructor(t={}){let e=t.currency??"";!e&&t.unit&&(e=t.unit);let i=e==="$"||e==="\xA3"||e==="\xA5"?"prefix":"suffix",n=t.decimals!==void 0?Number(t.decimals):2,s=Number.isFinite(n)?Math.min(20,Math.max(0,Math.floor(n))):2;this.options={currency:String(e).slice(0,32),unit:String(t.unit??e).slice(0,32),currencyPosition:t.currencyPosition??i,decimals:s,decimalSeparator:String(t.decimalSeparator??",").slice(0,4)||",",thousandSeparator:String(t.thousandSeparator??"\xA0").slice(0,4),allowNegative:t.allowNegative??!1,min:t.min??-1/0,max:t.max??1/0}}normalizePastedValue(t){let e=W(t,512);if(!e)return"";let i=0,n=0,s=-1,r=-1;for(let o=0;o<e.length;o++){let a=e[o];a===","?(i++,s=o):a==="."&&(n++,r=o)}if(i>0&&n>0){let o=s>r?",":".";if((o===","?i:n)!==1)return e;let l=o===","?".":",";return e.split(l).join("").replace(o,this.options.decimalSeparator)}return i>=2&&n===0?e.split(",").join(""):n>=2&&i===0?e.split(".").join(""):e}parse(t){let e=String(t??"").slice(0,512).trim(),i=!1;this.options.allowNegative&&e.includes("-")&&(i=!0),this.options.currency&&(e=e.replace(new RegExp(this.escapeRegExp(this.options.currency),"g"),"")),this.options.thousandSeparator&&(e=e.replace(new RegExp(this.escapeRegExp(this.options.thousandSeparator),"g"),"")),e=e.replace(/[\s\u00A0]/g,"");let n=this.options.decimalSeparator,s=e.indexOf(n);s===-1&&(s=e.search(/[,.]/));let r="",o=null,a=!1;return s!==-1?(r=e.substring(0,s).replace(/\D/g,""),this.options.decimals>0&&(a=!0,o=e.substring(s+1).replace(/\D/g,"").slice(0,this.options.decimals))):r=e.replace(/\D/g,""),r.length>1&&(r=r.replace(/^0+/,"")||"0"),{isNegative:i,integerPart:r,decimalPart:o,hasDecimal:a}}format(t,e=t.length,i=!1){let n=String(t??"").slice(0,512),s=Math.max(0,Math.min(e,n.length));if(!n||n.trim()===""||n===this.options.currency.trim())return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let r=n.substring(0,s),o=r.replace(/\D/g,"").length,a=this.options.decimals>0&&/[,.]/.test(r),{isNegative:l,integerPart:u,decimalPart:h,hasDecimal:c}=this.parse(n),d=h,p=c;if(i&&this.options.decimals>0&&(u||h!==null)&&(p=!0,d===null?d="0".repeat(this.options.decimals):d.length<this.options.decimals&&(d=d+"0".repeat(this.options.decimals-d.length))),l&&!u&&!d&&!p&&this.options.allowNegative){let k="-",I=1;return this.options.currency&&(this.options.currencyPosition==="prefix"?(k=`${this.options.currency} -`,I=k.length):(k=`- ${this.options.currency}`,I=1)),{formatted:k,rawNumber:null,rawValue:"-",cursor:I,isValid:!0}}if(!u&&!d&&!p)return{formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0};let g=this.formatThousands(u||"0");p&&this.options.decimals>0&&(g+=this.options.decimalSeparator+(d??"")),l&&g!=="0"&&(g="-"+g);let b=g;this.options.currency&&(this.options.currencyPosition==="prefix"?b=`${this.options.currency} ${g}`:b=`${g} ${this.options.currency}`);let v=(l?"-":"")+(u||"0")+(h?"."+h:""),y=parseFloat(v);isNaN(y)&&(y=0);let T=y>=this.options.min&&y<=this.options.max,A=0;this.options.currency&&this.options.currencyPosition==="prefix"&&(A=this.options.currency.length+1);let S=0,w=!1,C=A;for(let k=A;k<b.length;k++){let I=b[k];if(I===this.options.currency.trim()[0]&&this.options.currencyPosition==="suffix")break;if(/\d/.test(I)?(S++,C=k+1):I===this.options.decimalSeparator&&(w=!0,C=k+1),a){if(w&&S>=o){A=k+1;break}}else if(S>=o){A=k+1;break}}o>0&&S<o&&C>A&&(A=C);let E=this.options.currency&&this.options.currencyPosition==="prefix"?this.options.currency.length+1:0,M=this.options.currency&&this.options.currencyPosition==="suffix"?Math.max(0,b.length-this.options.currency.length-1):b.length;return A=Math.max(E,Math.min(A,Math.max(E,M))),{formatted:b,rawNumber:y,rawValue:v,cursor:A,isValid:T}}static format(t,e={}){let i=new f(e),n=typeof t=="number"?t.toString():t;return i.format(n).formatted}formatThousands(t){let e=this.options.thousandSeparator;if(!e||t.length<=3)return t;let i=[],n=t.length;for(;n>0;){let s=Math.max(0,n-3);i.push(t.slice(s,n)),n=s}return i.reverse().join(e)}escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};var ce=10,pt=class extends N{engine;history;isUndoingRedoing=!1;isApplying=!1;isComposing=!1;isNotifying=!1;hasPendingNotification=!1;lastValue="";wasInputModeInferred=!1;cutTimerId=null;resetTimerId=null;cursorTimerId=null;constructor(t,e,i){let n=X(t,e,i),s=n.wrapper,r=n.input,o=n.options,a=s?.getAttribute("data-mask-pad-decimals")==="true"||r?.getAttribute("data-mask-pad-decimals")==="true",l=r?.getAttribute("data-mask-align")||r?.getAttribute("data-align")||s?.getAttribute("data-mask-align")||s?.getAttribute("data-align"),u={align:o.align??l??"right",padDecimalsOnBlur:o.padDecimalsOnBlur??a??!1,...o};super(s,r,u),this.input.hasAttribute("inputmode")||(this.input.inputMode="decimal",this.wasInputModeInferred=!0),this.history=new U,this.engine=new J(this.options),this.bindEvents(),this.input.value?this.options.disabled||this.applyAmount(this.input.value,this.input.value.length):this.updateGhost({formatted:"",rawNumber:null,rawValue:"",cursor:0,isValid:!0}),this.runAuditWarning(this.options.audit)}extractRawSnippet(t){let e=this.engine.parse(t);return!e.integerPart&&!e.decimalPart?"":(e.isNegative?"-":"")+(e.integerPart||"0")+(e.decimalPart?"."+e.decimalPart:"")}onPasswordModeDetected(){this.history.clear(),this.lastValue="",this.lastTrackedValue="",this.clearGhost()}static format(t,e={}){return J.format(t,e)}onNativeValueSet(t){if(this.options.disabled||this.isComposing){this.lastValue=this.isSensitiveField()?this.computePasswordDigest(t):t;return}this.applyAmount(t,t.length)}onDisabledChange(t){t?this.clearGhost():this.applyAmount(this.input.value,this.input.selectionStart??this.input.value.length)}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handlePaste=this.handlePaste.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleClick=this.handleClick.bind(this),this.onCompositionStart=this.onCompositionStart.bind(this),this.onCompositionEnd=this.onCompositionEnd.bind(this),this.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,this.isDestroyed||this.options.disabled)return;let e=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,e)},0)};let{signal:t}=this.abortController;this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.handleKeyDown,{signal:t}),this.input.addEventListener("paste",this.handlePaste,{signal:t}),this.input.addEventListener("blur",this.handleBlur,{signal:t}),this.input.addEventListener("focus",this.handleFocus,{signal:t}),this.input.addEventListener("click",this.handleClick,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("compositionstart",this.onCompositionStart,{signal:t}),this.input.addEventListener("compositionend",this.onCompositionEnd,{signal:t}),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!this.isDestroyed&&(this.options.disabled||this.applyAmount(this.input.value,this.input.value.length))},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:t}))}onCompositionStart(){this.isComposing=!0}onCompositionEnd(){if(this.isComposing=!1,this.options.disabled)return;let t=this.input.selectionStart??this.input.value.length;this.applyAmount(this.input.value,t)}applyAmount(t,e){if(this.isApplying||this.options.disabled)return;this.isApplying=!0;let i=null;try{i=this.engine.format(t,e),this.setNativeValue(i.formatted),this.input.setSelectionRange(i.cursor,i.cursor),this.isSensitiveField()?(this.options.copyRaw=!1,this.history.clear(),this.clearGhost()):(this.isUndoingRedoing||this.history.push(i.rawValue,i.cursor),this.updateGhost(i))}finally{this.isApplying=!1}i&&this.checkValueChange(i)}updateGhost(t){if(this.ghost){if(this.options.disabled||this.isSensitiveField()){this.clearGhost();return}if(!t.formatted){if(this.shouldHideGhostForPlaceholder(!0)){this.clearGhost();return}let e=this.options.currency?this.options.currencyPosition==="prefix"?`${this.options.currency} 0`:`0 ${this.options.currency}`:"0,00",n=(this.input.ownerDocument||document).createElement("span");n.className="mask-ghost-remaining",n.textContent=e,this.setGhostContent(n);return}this.clearGhost(),this.ghost.scrollLeft=this.input.scrollLeft}}handleInput(){if(this.isDispatchingNativeInput||this.options.disabled||this.isComposing)return;let t=this.input.value,e=this.input.selectionStart??t.length;this.applyAmount(t,e)}handlePaste(t){if(this.options.disabled)return;t.preventDefault(),this.history.updateCurrentCursor(this.input.selectionStart??0);let e=this.preparePastedText(this.getClipboardPlainText(t),512);if(!e)return;let i=this.engine.normalizePastedValue(e),n=this.input.selectionStart??this.input.value.length,s=this.input.selectionEnd??n,r=this.input.value.slice(0,n)+i+this.input.value.slice(s);this.applyAmount(r,n+i.length)}handleKeyDown(t){if(!(this.options.disabled||R(t))){if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")){t.preventDefault(),t.shiftKey?this.redo():this.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")){t.preventDefault(),this.redo();return}if(t.key==="Backspace"){let e=this.input.selectionStart??0,i=this.input.selectionEnd??0;if(e===i&&e>0){let n=this.input.value,s=n[e-1];if(s===this.engine.options.thousandSeparator||s===" "){t.preventDefault();let r=Math.max(0,e-2),o=n.slice(0,r)+n.slice(e);this.applyAmount(o,r);return}if(this.options.currency&&this.options.currencyPosition==="prefix"&&e<=this.options.currency.length+1){t.preventDefault();return}}}if(t.key==="Delete"){let e=this.input.selectionStart??0,i=this.input.selectionEnd??0;if(e===i&&e<this.input.value.length){let n=this.input.value,s=n[e];if(s===this.engine.options.thousandSeparator||s===" "){t.preventDefault();let r=n.slice(0,e)+n.slice(e+2);this.applyAmount(r,e);return}if(this.options.currency&&this.options.currencyPosition==="suffix"){let r=n.length-this.options.currency.length-1;if(e>=r){t.preventDefault();return}}}}(t.key==="ArrowLeft"||t.key==="ArrowRight"||t.key==="Home"||t.key==="End")&&(this.cursorTimerId!==null&&clearTimeout(this.cursorTimerId),this.cursorTimerId=window.setTimeout(()=>{this.cursorTimerId=null,this.enforceCursorBounds()},0))}}enforceCursorBounds(){if(this.isDestroyed||!this.isFocused||D(this.input.ownerDocument)!==this.input||!this.input.value||this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??0;if(t!==e)return;let i=this.input.value,n=this.options.currency;if(n){if(this.options.currencyPosition==="prefix"){let s=n.length+1;t<s&&this.input.setSelectionRange(s,s)}else if(this.options.currencyPosition==="suffix"){let s=Math.max(0,i.length-n.length-1);t>s&&this.input.setSelectionRange(s,s)}}}handleClick(){this.enforceCursorBounds()}handleFocus(){this.wrapper.classList.add("is-focused"),this.syncGhostStyles(),this.enforceCursorBounds(),this.updateGhost(this.engine.format(this.input.value))}handleBlur(){if(this.wrapper.classList.remove("is-focused"),this.isSensitiveField()){this.history.clear(),this.lastValue="",this.lastTrackedValue="",this.clearGhost();return}if(this.options.padDecimalsOnBlur&&!this.options.disabled&&this.input.value.trim().length>0){let e=this.engine.format(this.input.value,this.input.value.length,!0);e.formatted!==this.input.value&&(this.setNativeValue(e.formatted),this.lastValue=e.formatted)}this.updateGhost(this.engine.format(this.input.value));let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!this.isSensitiveField(),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))}checkValueChange(t){if(!((this.isSensitiveField()?this.computePasswordDigest(this.input.value):this.input.value)===this.lastValue&&!this.hasPendingNotification)){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{let n=0,s=t;for(;((this.isSensitiveField()?this.computePasswordDigest(this.input.value):this.input.value)!==this.lastValue||this.hasPendingNotification)&&n<ce;){n++,this.hasPendingNotification=!1;let r=this.isSensitiveField(),o=this.input.value;this.lastValue=r?this.computePasswordDigest(o):o;let a=s??this.engine.format(o);s=void 0,this.notifyChange(a)}}finally{this.isNotifying=!1}}}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:!this.isSensitiveField(),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}getSpecificAuditWarnings(){let t=[],e=(this.options.currency||this.options.unit||"").trim();if(!e||this.options.disabled)return t;let i=[],n=this.checkAriaIdReferences(this.input,"aria-describedby",i,!0),s=!!this.input.getAttribute("aria-placeholder")?.trim();if(n||s)return t;let r=this.input.ownerDocument||document,o=typeof this.input.getRootNode=="function"?this.input.getRootNode():r,a=typeof ShadowRoot<"u"&&o instanceof ShadowRoot?o:r,l=this.input.getAttribute("aria-label")||"",u=this.input.getAttribute("aria-labelledby")?.trim();if(u)for(let m of u.split(/\s+/).filter(Boolean)){let g=typeof ShadowRoot<"u"&&o instanceof ShadowRoot?o.getElementById(m):r.getElementById(m);g?.textContent&&(l+=" "+g.textContent)}let h=this.input.closest("label");if(h?.textContent&&(l+=" "+h.textContent),this.input.id)try{let m=a.querySelector(`label[for="${lt(this.input.id)}"]`);m?.textContent&&(l+=" "+m.textContent)}catch{}let c=l.toLowerCase(),d=e.toLowerCase();return c.includes(d)||d==="\u20AC"&&(c.includes("euro")||c.includes("eur"))||d==="$"&&(c.includes("dollar")||c.includes("usd"))||d==="\xA3"&&(c.includes("livre")||c.includes("pound")||c.includes("gbp"))||t.push(`Devise/unit\xE9 "${e}" non expos\xE9e aux technologies d'assistance quand le champ est vide (le fant\xF4me est aria-hidden="true") : mentionnez-la dans le <label>, aria-label ou aria-describedby (WCAG 3.3.2).`),t}setValue(t){let e=t!=null?String(t):"";this.options.disabled?(this.setNativeValue(e),this.lastValue=this.isSensitiveField()?this.computePasswordDigest(e):e):this.applyAmount(e,e.length)}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.cursorTimerId!==null&&(clearTimeout(this.cursorTimerId),this.cursorTimerId=null),this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="decimal"&&this.input.removeAttribute("inputmode"),this.lastValue="",this.history.clear(),super.destroy())}};var rt=class f{domains;tlds;suggestOnAt;defaultDomain=null;defaultTld="__";static DEFAULT_DOMAINS=["gmail.com","outlook.com","orange.fr","free.fr","sfr.fr","yahoo.com","hotmail.com","icloud.com","laposte.net","proton.me"];static DEFAULT_TLDS=["com","fr","net","org","eu","io","co","info","biz","me","tv","fi","be","ch","ca","uk","de","es","it"];constructor(t={}){let e=Array.isArray(t.domains)?t.domains.slice(0,500).map(i=>String(i??"").trim().slice(0,253)).filter(Boolean):[];this.domains=e.length>0?e:f.DEFAULT_DOMAINS,this.tlds=t.tlds&&t.tlds.length>0?t.tlds.slice(0,200).map(i=>String(i).trim().replace(/^\./,"").slice(0,32)).filter(Boolean):[...f.DEFAULT_TLDS],this.suggestOnAt=t.suggestOnAt??!0,this.setDefaultDomain(t.defaultDomain??null),this.setDefaultTld(t.defaultTld!==void 0?t.defaultTld:"__")}setDefaultDomain(t){t===!0?this.defaultDomain=this.domains.length>0?this.domains[0]:null:typeof t=="string"&&t.trim().length>0?this.defaultDomain=t.trim().replace(/^@/,"").slice(0,253)||null:this.defaultDomain=null}setDefaultTld(t){t===!0?this.defaultTld=this.tlds.length>0?this.tlds[0]:null:typeof t=="string"&&t.trim().length>0?this.defaultTld=t.trim().replace(/^\./,"").slice(0,32)||null:this.defaultTld=null}setTlds(t){this.tlds=t&&t.length>0?t.slice(0,200).map(e=>String(e).trim().replace(/^\./,"").slice(0,32)).filter(Boolean):[...f.DEFAULT_TLDS]}getMatchingTlds(t){let e=(t??"").toLowerCase();return e.length===0?[...this.tlds]:this.tlds.filter(i=>i.toLowerCase().startsWith(e)&&i.toLowerCase()!==e)}getMatchingDomains(t){let e=String(t??"").slice(0,512);if(!e.includes("@"))return this.defaultDomain?[this.defaultDomain]:[];let i=e.indexOf("@");if(e.indexOf("@",i+1)!==-1)return[];let n=e.substring(i+1);if(n.length===0)return this.suggestOnAt?[...this.domains]:[];let s=n.toLowerCase();return this.domains.filter(r=>r.toLowerCase().startsWith(s)&&r.toLowerCase()!==s)}getSuggestion(t,e=0){let i=String(t??"").slice(0,512);if(!i.includes("@"))return this.defaultDomain?{full:i?`${i}@${this.defaultDomain}`:`@${this.defaultDomain}`,remaining:`@${this.defaultDomain}`,matchedDomain:this.defaultDomain,isHintOnly:!1}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let n=i.indexOf("@"),s=i.substring(0,n),r=i.substring(n+1);if(i.indexOf("@",n+1)!==-1)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let o=this.getMatchingDomains(t);if(o.length>0){let p=(e%o.length+o.length)%o.length,m=o[p],g=r.toLowerCase(),b=m.substring(g.length);return{full:`${s}@${m}`,remaining:b,matchedDomain:m,isHintOnly:!1}}if(r.length===0||r.startsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let a=r.toLowerCase();if(this.domains.some(p=>p.toLowerCase()===a))return{full:i,remaining:"",matchedDomain:r,isHintOnly:!1};let l=r.lastIndexOf(".");if(l===-1){if(!this.defaultTld)return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};let p=this.defaultTld.includes("_"),m=`.${this.defaultTld}`,g=`${r}.${this.defaultTld}`;return{full:p?i:`${s}@${g}`,remaining:m,matchedDomain:p?null:g,isHintOnly:p}}let u=r.substring(0,l),h=r.substring(l+1);if(!u||u.endsWith("."))return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1};if(h.length===0){if(this.defaultTld&&!this.defaultTld.includes("_")){let p=`${u}.${this.defaultTld}`;return{full:`${s}@${p}`,remaining:this.defaultTld,matchedDomain:p,isHintOnly:!1}}return this.defaultTld&&this.defaultTld.includes("_")?{full:i,remaining:this.defaultTld,matchedDomain:null,isHintOnly:!0}:{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}let c=h.toLowerCase();if(this.tlds.some(p=>p.toLowerCase()===c))return{full:i,remaining:"",matchedDomain:r,isHintOnly:!1};let d=this.getMatchingTlds(h);if(d.length>0){let p=(e%d.length+d.length)%d.length,m=d[p],g=m.substring(c.length),b=`${u}.${m}`;return{full:`${s}@${b}`,remaining:g,matchedDomain:b,isHintOnly:!1}}if(this.defaultTld&&this.defaultTld.includes("_")&&h.length<this.defaultTld.length){let p=this.defaultTld.substring(h.length);if(p.includes("_"))return{full:i,remaining:p,matchedDomain:null,isHintOnly:!0}}return{full:i,remaining:"",matchedDomain:null,isHintOnly:!1}}};var de=10,ft=class extends N{engine;currentSuggestion={full:"",remaining:"",matchedDomain:null};currentSuggestionIndex=0;hadInitialAriaAutocomplete=!1;wasAriaAutocompleteSet=!1;isSuggestionDismissed=!1;isNotifying=!1;hasPendingNotification=!1;wasAutocorrectSet=!1;wasAutocapitalizeSet=!1;wasSpellcheckSet=!1;wasInputModeInferred=!1;isComposing=!1;lastNotifiedValue="";srStatusEl=null;srAnnounceTimerId=null;lastAnnouncedSuggestion="";cutTimerId=null;resetTimerId=null;constructor(t,e,i){let n=X(t,e,i),s=n.wrapper,r=n.input,o=n.options,a=s?.getAttribute("data-mask-cycle-suggestions")==="true"||r?.getAttribute("data-mask-cycle-suggestions")==="true",l=s?.getAttribute("data-mask-auto-lowercase")==="true"||r?.getAttribute("data-mask-auto-lowercase")==="true",u=s?.getAttribute("data-mask-aria-autocomplete")??r?.getAttribute("data-mask-aria-autocomplete"),h=o.setAriaAutocomplete??(u!==null?u!=="false":!0),c=s?.getAttribute("data-mask-tlds")??r?.getAttribute("data-mask-tlds"),d=o.tlds??(c?c.split(",").map(b=>b.trim()).filter(Boolean):void 0),p=s?.getAttribute("data-mask-default-tld")??r?.getAttribute("data-mask-default-tld"),m=o.defaultTld!==void 0?o.defaultTld:p!==null?p==="false"||p==="none"?null:p==="true"?!0:p:void 0,g={completeOnTab:!0,completeOnArrowRight:!0,completeOnEnter:!0,cycleSuggestions:o.cycleSuggestions??a??!1,autoLowercase:o.autoLowercase??l??!1,setAriaAutocomplete:h,...o,...d!==void 0?{tlds:d}:{},...m!==void 0?{defaultTld:m}:{}};super(s,r,g),this.input.hasAttribute("inputmode")||(this.input.inputMode="email",this.wasInputModeInferred=!0),this.input.hasAttribute("autocorrect")||(this.input.setAttribute("autocorrect","off"),this.wasAutocorrectSet=!0),this.input.hasAttribute("autocapitalize")||(this.input.setAttribute("autocapitalize","none"),this.wasAutocapitalizeSet=!0),this.input.hasAttribute("spellcheck")||(this.input.setAttribute("spellcheck","false"),this.wasSpellcheckSet=!0),this.hadInitialAriaAutocomplete=this.input.hasAttribute("aria-autocomplete"),this.syncAriaAutocomplete(),this.engine=new rt(this.options),this.lastNotifiedValue=this.isSensitiveField()?"":this.input.value,this.bindEvents(),!this.options.disabled&&!this.isSensitiveField()&&this.updateSuggestion(),this.runAuditWarning(this.options.audit)}syncAriaAutocomplete(){let t=!!(this.options.setAriaAutocomplete&&!this.options.disabled&&!this.isSensitiveField()&&!this.isDestroyed);this.hadInitialAriaAutocomplete||(t?this.input.hasAttribute("aria-autocomplete")||(this.input.setAttribute("aria-autocomplete","inline"),this.wasAriaAutocompleteSet=!0):this.wasAriaAutocompleteSet&&(this.input.getAttribute("aria-autocomplete")==="inline"&&this.input.removeAttribute("aria-autocomplete"),this.wasAriaAutocompleteSet=!1));let e=this.input.ownerDocument||(typeof document<"u"?document:null),i=!!(e&&typeof e.ariaNotify=="function");t&&!i?this.ensureSrStatusEl():!t&&this.srStatusEl&&(this.srStatusEl.remove(),this.srStatusEl=null)}onPasswordModeDetected(){this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.lastNotifiedValue="",this.lastTrackedValue="",this.lastAnnouncedSuggestion="",this.currentSuggestion={full:"",remaining:"",matchedDomain:null},this.syncAriaAutocomplete(),this.clearGhost()}onNativeValueSet(t){this.options.disabled||this.isComposing||this.isSensitiveField()||(this.isSuggestionDismissed=!1,this.updateSuggestion())}onDisabledChange(t){this.syncAriaAutocomplete(),t||this.isSensitiveField()?(this.currentSuggestion={full:"",remaining:"",matchedDomain:null},this.clearGhost()):(this.isSuggestionDismissed=!1,this.updateSuggestion())}bindEvents(){this.handleInput=this.handleInput.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handlePaste=this.handlePaste.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.isSensitiveField())&&this.updateSuggestion()},0)};let{signal:t}=this.abortController;this.input.addEventListener("input",this.handleInput,{signal:t}),this.input.addEventListener("keydown",this.handleKeyDown,{signal:t}),this.input.addEventListener("paste",this.handlePaste,{signal:t}),this.input.addEventListener("blur",this.handleBlur,{signal:t}),this.input.addEventListener("focus",this.handleFocus,{signal:t}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:t}),this.input.addEventListener("cut",this.onCutHandler,{signal:t}),this.input.addEventListener("compositionstart",()=>{this.isComposing=!0},{signal:t}),this.input.addEventListener("compositionend",()=>{this.isComposing=!1,!this.isDestroyed&&!this.options.disabled&&!this.isSensitiveField()&&this.handleInput()},{signal:t}),this.input.form&&(this.onFormResetHandler=()=>{this.resetTimerId!==null&&clearTimeout(this.resetTimerId),this.resetTimerId=window.setTimeout(()=>{this.resetTimerId=null,!(this.isDestroyed||this.options.disabled||this.isSensitiveField())&&this.updateSuggestion()},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:t}))}ensureSrStatusEl(){if(this.srStatusEl&&this.wrapper.contains(this.srStatusEl))return this.srStatusEl;let t=this.input.ownerDocument||(typeof document<"u"?document:null);if(!t)return null;let e=t.createElement("span");return e.className="wulf-mask-sr-status",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),this.wrapper.appendChild(e),this.srStatusEl=e,e}scheduleSuggestionAnnouncement(t=!1){if(this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),!this.options.setAriaAutocomplete||!this.isFocused||this.isDestroyed||this.isSensitiveField())return;let e=this.currentSuggestion;if(!e.remaining||e.isHintOnly){this.lastAnnouncedSuggestion="",this.srStatusEl&&(this.srStatusEl.textContent="");return}let i=e.full;if(i===this.lastAnnouncedSuggestion&&!t)return;let n=()=>{if(this.srAnnounceTimerId=null,this.isDestroyed||!this.isFocused||this.isSensitiveField())return;this.lastAnnouncedSuggestion=i;let r=this.input.ownerDocument||(typeof document<"u"?document:null);if(r&&typeof r.ariaNotify=="function")try{r.ariaNotify(i,{priority:"normal"});return}catch{}let o=this.ensureSrStatusEl();o&&(o.textContent=o.textContent===i?`${i}\xA0`:i)};t?n():this.srAnnounceTimerId=window.setTimeout(n,250)}updateSuggestion(t){if(this.options.disabled||this.isSensitiveField()){this.currentSuggestion={full:"",remaining:"",matchedDomain:null},this.clearGhost();return}let e=this.input.value;if(this.currentSuggestion=this.isSuggestionDismissed?{full:e,remaining:"",matchedDomain:null}:this.engine.getSuggestion(e,this.currentSuggestionIndex),!!this.ghost){if(this.shouldHideGhostForPlaceholder(e.length===0))this.clearGhost();else if(this.currentSuggestion.remaining){let i=this.input.ownerDocument||document,n=i.createElement("span");n.className="mask-ghost-typed",n.textContent=e;let s=i.createElement("span");s.className="mask-ghost-remaining",s.textContent=this.currentSuggestion.remaining,this.setGhostContent(n,s)}else this.clearGhost();this.ghost.scrollLeft=this.input.scrollLeft,t?.announce&&this.scheduleSuggestionAnnouncement(!!t.immediate),this.notifyValueChange()}}notifyValueChange(){if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{let t=0;do{t++,this.hasPendingNotification=!1;let e=this.isSensitiveField(),i=!e,n=this.input.value,s=this.getDetail();this.options.onInput&&this.options.onInput(s),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:i,detail:s})),n!==this.lastNotifiedValue&&(this.lastNotifiedValue=e?"":n,this.dispatchNativeInput())}while(this.hasPendingNotification&&t<de)}finally{this.isNotifying=!1}}handleInput(t){if(!this.isDispatchingNativeInput&&!(this.options.disabled||this.isSensitiveField())&&!(this.isComposing||t&&"isComposing"in t&&t.isComposing)){if(this.options.autoLowercase){let e=this.input.selectionStart??0,i=this.input.selectionEnd??e,n=this.input.value.toLowerCase();n!==this.input.value&&(this.setNativeValue(n),this.input.setSelectionRange(e,i))}this.isSuggestionDismissed=!1,this.currentSuggestionIndex=0,this.updateSuggestion({announce:!0,immediate:!1})}}handlePaste(t){if(this.options.disabled||this.isSensitiveField())return;let e=this.getClipboardPlainText(t),i=this.preparePastedText(e,512);if(i===e)return;t.preventDefault();let n=this.input.selectionStart??this.input.value.length,s=this.input.selectionEnd??n,r=this.input.value.slice(0,n),o=this.input.value.slice(s),a=r+i+o,l=this.options.autoLowercase?a.toLowerCase():a;if(typeof document<"u"&&D(this.input.ownerDocument)===this.input&&typeof document.execCommand=="function")try{if(document.execCommand("insertText",!1,i)&&this.input.value===l)return}catch{}this.setNativeValue(a);let u=n+i.length;this.input.setSelectionRange(u,u),this.handleInput()}handleKeyDown(t){if(this.options.disabled||this.isSensitiveField()||R(t)||t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)return;let e=!!this.currentSuggestion.remaining&&!this.currentSuggestion.isHintOnly,n=(this.input.selectionStart??0)===this.input.value.length,s=this.input.value.length>0;if(t.key==="Escape"&&e){t.preventDefault(),this.isSuggestionDismissed=!0,this.currentSuggestion={full:this.input.value,remaining:"",matchedDomain:null},this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.lastAnnouncedSuggestion="",this.srStatusEl&&(this.srStatusEl.textContent=""),this.clearGhost();return}if(this.options.cycleSuggestions&&e&&s&&n){if(t.key==="ArrowDown"){t.preventDefault(),this.currentSuggestionIndex++,this.updateSuggestion({announce:!0,immediate:!0});return}if(t.key==="ArrowUp"){t.preventDefault(),this.currentSuggestionIndex--,this.updateSuggestion({announce:!0,immediate:!0});return}}if(t.key==="Tab"&&e&&s&&this.options.completeOnTab){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="Enter"&&e&&s&&this.options.completeOnEnter){t.preventDefault(),this.acceptSuggestion();return}if(t.key==="ArrowRight"&&e&&s&&n&&this.options.completeOnArrowRight){t.preventDefault(),this.acceptSuggestion();return}}acceptSuggestion(){if(!this.currentSuggestion.remaining||this.currentSuggestion.isHintOnly||this.options.disabled||this.isSensitiveField()||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();this.options.onChange&&this.options.onChange(e);let i=!this.isSensitiveField();return this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:i,detail:e})),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:i,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.isSuggestionDismissed=!1,this.syncGhostStyles(),this.updateSuggestion()}handleBlur(){if(this.wrapper.classList.remove("is-focused"),this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.lastAnnouncedSuggestion="",this.srStatusEl&&(this.srStatusEl.textContent=""),this.isSensitiveField()){this.lastNotifiedValue="",this.lastTrackedValue="",this.clearGhost();return}this.updateSuggestion();let t=this.getDetail();this.options.onChange&&this.options.onChange(t),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:!this.isSensitiveField(),detail:t}))}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask-cycle-suggestions")this.options.cycleSuggestions=this.getAttr("data-mask-cycle-suggestions")==="true";else if(t==="data-mask-auto-lowercase")this.options.autoLowercase=this.getAttr("data-mask-auto-lowercase")==="true";else if(t==="data-mask-default-tld"){let e=this.getAttr("data-mask-default-tld");this.setDefaultTld(e===null||e==="false"||e==="none"?null:e==="true"?!0:e)}else if(t==="data-mask-tlds"){let e=this.getAttr("data-mask-tlds");this.setTlds(e?e.split(",").map(i=>i.trim()).filter(Boolean):null)}else t==="placeholder"&&this.updateSuggestion()}getDetail(){return{value:this.input.value,suggestedValue:this.currentSuggestion.isHintOnly?"":this.currentSuggestion.full,domain:this.currentSuggestion.matchedDomain}}setValue(t){let e=t!=null?String(t):"";this.isSuggestionDismissed=!1,this.setNativeValue(e),this.updateSuggestion()}destroy(){this.isDestroyed||(this.cutTimerId!==null&&(clearTimeout(this.cutTimerId),this.cutTimerId=null),this.resetTimerId!==null&&(clearTimeout(this.resetTimerId),this.resetTimerId=null),this.srAnnounceTimerId!==null&&(clearTimeout(this.srAnnounceTimerId),this.srAnnounceTimerId=null),this.srStatusEl&&(this.srStatusEl.remove(),this.srStatusEl=null),this.lastNotifiedValue="",this.lastAnnouncedSuggestion="",this.wasInputModeInferred&&this.input.getAttribute("inputmode")==="email"&&this.input.removeAttribute("inputmode"),this.wasAriaAutocompleteSet&&this.input.getAttribute("aria-autocomplete")==="inline"&&this.input.removeAttribute("aria-autocomplete"),this.wasAutocorrectSet&&this.input.getAttribute("autocorrect")==="off"&&this.input.removeAttribute("autocorrect"),this.wasAutocapitalizeSet&&this.input.getAttribute("autocapitalize")==="none"&&this.input.removeAttribute("autocapitalize"),this.wasSpellcheckSet&&this.input.getAttribute("spellcheck")==="false"&&this.input.removeAttribute("spellcheck"),super.destroy())}};var gt={iso:{format:"YYYY-MM-DD HH:mm:ss"},"iso-t":{format:"YYYY-MM-DD\\THH:mm:ss"},fr:{format:"DD/MM/YYYY HH:mm",placeholderTokens:{DD:"jj",MM:"mm",YYYY:"aaaa",HH:"hh",mm:"mm"}},"fr-sec":{format:"DD/MM/YYYY HH:mm:ss",placeholderTokens:{DD:"jj",MM:"mm",YYYY:"aaaa",HH:"hh",mm:"mm",ss:"ss"}},us:{format:"MM/DD/YYYY HH:mm"},"us-12h":{format:"MM/DD/YYYY hh:mm A"},uk:{format:"DD/MM/YYYY HH:mm"},no:{format:"DD/MM-YYYY HH:mm"},cz:{format:"DD. MM. YYYY HH:mm"},de:{format:"DD.MM.YYYY HH:mm"},jp:{format:"YYYY/MM/DD HH:mm"}},It={YYYY:"YYYY",MM:"MM",DD:"DD",HH:"HH",hh:"hh",mm:"mm",ss:"ss",A:"AM"},pe=[{token:"YYYY",length:4},{token:"MM",length:2},{token:"DD",length:2},{token:"HH",length:2},{token:"hh",length:2},{token:"mm",length:2},{token:"ss",length:2},{token:"A",length:2}],fe=128,mt=512,me=new Set(["/","-",".",":"," ","T","t"]),_t=new Set(["HH","hh","mm","ss","A"]);function x(f){return f>="0"&&f<="9"}function L(f){let t=0;for(let e=0;e<f.length;e++){let i=f.charCodeAt(e);if(i<48||i>57)return NaN;t=t*10+(i-48)}return f.length>0?t:NaN}function ge(f,t,e){let i=Array.from(f||e),n=Array.from(e);for(;i.length<t;)i.push(n[i.length]||n[n.length-1]||"_");return i.slice(0,t).join("")}var Q=class f{formatSpec="YYYY-MM-DD HH:mm";customPlaceholders={};slots=[];segments=[];fullTemplate="";prefixSlotsCount=0;prefixString="";editableCount=0;hasMeridiemFlag=!1;utcIndicator=" UTC";includeMilliseconds=!1;convertPastedOffset=!0;defaultTimeOnDateOnly=!1;minTs=null;maxTs=null;constructor(t={}){this.updateOptions(t)}static format(t,e={}){return new f(e).formatFromValue(t)}updateOptions(t={}){t.utcIndicator!==void 0&&(this.utcIndicator=t.utcIndicator===!1?!1:String(t.utcIndicator).slice(0,32)),t.includeMilliseconds!==void 0&&(this.includeMilliseconds=!!t.includeMilliseconds),t.convertPastedOffset!==void 0&&(this.convertPastedOffset=t.convertPastedOffset!==!1),t.defaultTimeOnDateOnly!==void 0&&(this.defaultTimeOnDateOnly=t.defaultTimeOnDateOnly),t.min!==void 0&&(this.minTs=this.normalizeBoundary(t.min)),t.max!==void 0&&(this.maxTs=this.normalizeBoundary(t.max)),t.placeholderTokens!==void 0&&(this.customPlaceholders=t.placeholderTokens||{}),(t.format!==void 0||this.slots.length===0)&&this.compile(t.format??this.formatSpec,t.placeholderTokens)}setFormat(t,e){e!==void 0&&(this.customPlaceholders=e),this.compile(t,this.customPlaceholders)}setUtcIndicator(t){this.utcIndicator=t===!1?!1:String(t).slice(0,32)}getUtcIndicator(){return this.utcIndicator}getFormat(){return this.formatSpec}getFullTemplate(){return this.fullTemplate}getGhostRemaining(t){let e=this.utcIndicator?this.utcIndicator:"";return t.length>=this.fullTemplate.length?e:this.fullTemplate.slice(t.length)+e}getPrefix(){return this.prefixString}getPrefixLength(){return this.prefixSlotsCount}getEditableCount(){return this.editableCount}hasMeridiem(){return this.hasMeridiemFlag}isNumericOnly(){return!this.hasMeridiemFlag}getSegments(){return this.segments}getSlots(){return this.slots}isSeparatorAt(t){return t>=0&&t<this.slots.length&&this.slots[t].isStatic}getNextEditablePosition(t){let e=Math.max(0,t);for(let i=e;i<this.slots.length;i++)if(!this.slots[i].isStatic)return i;return this.slots.length}compile(t,e){let i=String(t||"YYYY-MM-DD HH:mm").trim().slice(0,fe)||"YYYY-MM-DD HH:mm";this.formatSpec=i;let n=Object.hasOwn(gt,i)?gt[i]:null,s=n?n.format:i,r=Object.create(null);if(n?.placeholderTokens)for(let[h,c]of Object.entries(n.placeholderTokens))Object.hasOwn(It,h)&&typeof c=="string"&&(r[h]=c);let o=e!==void 0?e:this.customPlaceholders;if(o&&typeof o=="object")for(let[h,c]of Object.entries(o))Object.hasOwn(It,h)&&typeof c=="string"&&(r[h]=c);this.slots=[],this.segments=[],this.hasMeridiemFlag=!1;let a="",l=!0,u=0;for(;u<s.length;){let h=s[u];if(h==="\\"&&u+1<s.length){let d=s[u+1];this.slots.push({char:d,isStatic:!0,isPrefix:l,segmentIndex:-1,charIndexInSegment:-1,placeholder:d}),a+=d,u+=2;continue}let c=null;for(let d of pe)if(s.startsWith(d.token,u)){c=d;break}if(c){l=!1;let{token:d,length:p}=c;d==="A"&&(this.hasMeridiemFlag=!0);let m=r[d]??It[d],g=ge(m,p,It[d]),b=Array.from(g),v=this.segments.length,y=this.slots.length;for(let T=0;T<p;T++)this.slots.push({char:d==="A"?"A":"9",isStatic:!1,isPrefix:!1,segmentIndex:v,charIndexInSegment:T,tokenKind:d,placeholder:b[T]||"_"});this.segments.push({kind:d,start:y,end:y+p,length:p,placeholder:g,followingSeparator:""}),a+=g,u+=d.length}else this.slots.push({char:h,isStatic:!0,isPrefix:l,segmentIndex:-1,charIndexInSegment:-1,placeholder:h}),a+=h,u++}this.fullTemplate=a,this.editableCount=this.slots.filter(h=>!h.isStatic).length,this.prefixSlotsCount=0,this.prefixString="";for(let h of this.slots)if(h.isPrefix)this.prefixSlotsCount++,this.prefixString+=h.char;else break;for(let h=0;h<this.segments.length;h++){let c=this.segments[h],d="";for(let p=c.end;p<this.slots.length&&this.slots[p].isStatic;p++)d+=this.slots[p].char;c.followingSeparator=d}}extractRaw(t,e=!1){let i=String(t??"").slice(0,mt);if(!i||this.slots.length===0)return"";let n="",s=0,r=0;if(this.prefixSlotsCount>0){for(;s<i.length&&(i[s]===" "||i[s]===" ");)s++;let o=0;for(;s<i.length&&o<this.prefixSlotsCount;){let a=this.slots[o].char,l=i[s];if(l.toUpperCase()===a.toUpperCase())s++,o++;else if(a===" "&&l!==" ")o++;else break}r=this.prefixSlotsCount}for(;s<i.length&&r<this.slots.length;){let o=this.slots[r],a=i[s];if(o.isStatic){a.toUpperCase()===o.char.toUpperCase()&&s++,r++;continue}if(o.tokenKind==="A"){let l=a.toUpperCase();o.charIndexInSegment===0?l==="A"||l==="P"?(n+=l,s++,r++,(s<i.length?i[s].toUpperCase():"")==="M"?(n+="M",s++,r++):e&&(n+="M",r++)):s++:l==="M"?(n+="M",s++,r++):e?(n+="M",r++):s++;continue}x(a)?(n+=a,s++,r++):s++}return n}format(t,e=!1){if(this.slots.length===0)return String(t??"").slice(0,mt);let i=this.extractRaw(t,e);if(i.length===0)return this.prefixString;let n="",s=0;for(let r=0;r<this.slots.length;r++){let o=this.slots[r];if(o.isStatic){let a=s<i.length,l=s===0&&o.isPrefix,u=s>0&&s===i.length;if(a||l||u)n+=o.char;else break}else if(s<i.length)n+=i[s],s++;else break}return n}analyze(t,e=!1){let i=this.extractRaw(t,e),n=this.formatFromCleanRaw(i),s=this.editableCount,r=i.length,o=s>0&&r>=s,a=this.extractSegmentValues(i),l=a.parts,u=null,h=null,c=null,d=!1;if(o&&a.allSegmentsPresent){let p=this.resolveHour24(a);if(p!==null){let m={year:l.year,month:l.month,day:l.day,hour:p,minute:l.minute??0,second:l.second??0},g=this.buildStrictUTCDate(m);if(g){let b=g.getTime(),v=this.minTs===null||b>=this.minTs,y=this.maxTs===null||b<=this.maxTs;v&&y&&(u=g,c=b,h=this.formatDateToISO(g),d=!0)}}}return{formatted:n,rawValue:h||"",isoString:h,date:u,timestamp:c,parts:l,isComplete:o,isValid:d,totalSlots:s,filledSlots:r}}mapCursorPosition(t,e,i){let n=this.prefixSlotsCount,s=String(t??""),r=String(i??"");if(e<=0||!r)return n;let a=this.extractRaw(s.slice(0,e),!1).length;if(a===0)return Math.max(n,Math.min(this.getNextEditablePosition(0),r.length));let l=0,u=r.length;for(let h=0;h<r.length&&h<this.slots.length;h++)if(!this.slots[h].isStatic&&(l++,l===a)){u=h+1;break}for(;u<r.length&&this.slots[u]&&this.slots[u].isStatic;)u++;return Math.max(n,Math.min(u,r.length))}tryHandleSeparatorKey(t,e,i){let n={handled:!1,formatted:t,cursor:e};if(!i||i.length!==1)return n;if(e<this.slots.length&&this.slots[e].isStatic&&this.separatorMatchesKey(this.slots[e].char,i)){let a=this.getNextEditablePosition(e+1),l=this.format(t);return{handled:!0,formatted:l,cursor:Math.min(a,l.length)}}if(e>this.prefixSlotsCount&&e-1<this.slots.length&&this.slots[e-1].isStatic){let a=e-1;for(;a>=this.prefixSlotsCount&&this.slots[a].isStatic;){if(this.separatorMatchesKey(this.slots[a].char,i)){let l=this.getNextEditablePosition(a+1),u=this.format(t);return{handled:!0,formatted:u,cursor:Math.min(l,u.length)}}a--}}let s=-1;for(let a=0;a<this.segments.length;a++){let l=this.segments[a];if(e>=l.start&&e<=l.end){s=a;break}}if(s===-1)return n;let r=this.segments[s];if(!r.followingSeparator||!this.followingSeparatorMatchesKey(r.followingSeparator,i))return n;let o=t.slice(r.start,Math.min(e,r.end)).replace(/\D/g,"");if(r.kind!=="YYYY"&&r.kind!=="A"&&o.length>0&&o.length<r.length){let a="0".repeat(r.length-o.length)+o,l=t.slice(Math.min(t.length,r.end)),u=t.slice(0,r.start)+a+r.followingSeparator+l,h=this.format(u),c=this.getNextEditablePosition(r.end);return{handled:!0,formatted:h,cursor:Math.min(c,h.length)}}if(e===r.end){let a=this.format(t),l=this.getNextEditablePosition(r.end);return{handled:!0,formatted:a,cursor:Math.min(l,a.length)}}return n}formatFromValue(t){if(t==null)return this.prefixString;if(t instanceof Date)return Number.isNaN(t.getTime())?this.prefixString:this.formatPartsToTemplate(this.dateToUTCParts(t));if(typeof t=="number"){if(!Number.isFinite(t))return this.prefixString;let n=new Date(t);return Number.isNaN(n.getTime())?this.prefixString:this.formatPartsToTemplate(this.dateToUTCParts(n))}let e=String(t).slice(0,mt).trim();if(!e)return this.prefixString;let i=this.parsePasted(e);return i.matched?i.formatted:i.rejected?this.prefixString:this.format(e,!0)}formatFromNativeValue(t){let e=String(t??"").slice(0,mt);if(!e)return this.prefixString;let i=e.trim();if(i.length>=16){let n=this.parseISO8601Linear(i);if(n&&!n.dateOnly){let s=this.parsePasted(i);if(s.matched)return s.formatted}}return this.format(e,!1)}parsePasted(t){let e={matched:!1,formatted:"",cursor:0},i={matched:!1,rejected:!0,formatted:"",cursor:0},n=String(t??"").slice(0,mt).trim();if(!n||this.segments.length===0)return e;let s=n.length>=10&&x(n[0])&&x(n[1])&&x(n[2])&&x(n[3])&&n[4]==="-"&&x(n[5])&&x(n[6])&&n[7]==="-"&&x(n[8])&&x(n[9]),r=this.parseISO8601Linear(n);if(r){if(r.dateOnly)return this.formatDateOnlyMatch({year:r.year,month:r.month,day:r.day},i);if(r.offsetMinutes!==null&&r.offsetMinutes!==0&&!this.convertPastedOffset)return i;let o=this.buildStrictUTCDate({year:r.year,month:r.month,day:r.day,hour:r.hour,minute:r.minute,second:r.second});if(!o)return i;let a=o,l;if(r.offsetMinutes!==null&&r.offsetMinutes!==0){let h=o.getTime()-r.offsetMinutes*6e4;if(a=new Date(h),Number.isNaN(a.getTime()))return i;l={original:n,offsetMinutes:r.offsetMinutes,utcIso:this.formatDateToISO(a)}}let u=this.formatPartsToTemplate(this.dateToUTCParts(a));return{matched:!0,formatted:u,cursor:u.length,offsetConverted:l}}return s&&n.length>10&&(n[10]==="T"||n[10]==="t"||this.segments[0]?.kind!=="YYYY")?i:this.parseConfiguredFormatLinear(n)}formatLocal(t,e,i){if(!t||Number.isNaN(t.getTime()))return null;try{let n=i||{dateStyle:"short",timeStyle:"medium"};return new Intl.DateTimeFormat(e,n).format(t)}catch{return null}}normalizeBoundary(t){if(t==null)return null;if(t instanceof Date){let s=t.getTime();return Number.isNaN(s)?null:s}if(typeof t=="number")return Number.isFinite(t)?t:null;let e=String(t).slice(0,mt).trim();if(!e)return null;let i=this.parseISO8601Linear(e);if(i){let s=this.buildStrictUTCDate({year:i.year,month:i.month,day:i.day,hour:i.hour,minute:i.minute,second:i.second});if(!s)return null;let r=i.offsetMinutes?i.offsetMinutes*6e4:0;return s.getTime()-r}return this.analyze(e,!0).timestamp}separatorMatchesKey(t,e){return t===e||(t==="T"||t==="t")&&(e==="T"||e==="t"||e===" ")}followingSeparatorMatchesKey(t,e){let i=!1;for(let n=0;n<t.length;n++)if(t[n]!==" "){i=!0;break}for(let n=0;n<t.length;n++){let s=t[n];if(!(i&&s===" ")&&this.separatorMatchesKey(s,e))return!0}return!1}formatFromCleanRaw(t){if(this.slots.length===0)return"";if(t.length===0)return this.prefixString;let e="",i=0;for(let n=0;n<this.slots.length;n++){let s=this.slots[n];if(s.isStatic){let r=i<t.length,o=i===0&&s.isPrefix,a=i>0&&i===t.length;if(r||o||a)e+=s.char;else break}else if(i<t.length)e+=t[i],i++;else break}return e}extractSegmentValues(t){let e={},i,n,s=0,r=!0;for(let o of this.segments){if(s+o.length>t.length){r=!1;break}let a=t.slice(s,s+o.length);switch(s+=o.length,o.kind){case"YYYY":e.year=L(a);break;case"MM":e.month=L(a);break;case"DD":e.day=L(a);break;case"HH":e.hour=L(a);break;case"hh":i=L(a);break;case"mm":e.minute=L(a);break;case"ss":e.second=L(a);break;case"A":a==="AM"||a==="PM"?n=a:r=!1;break}}if((e.year===void 0||e.month===void 0||e.day===void 0)&&(r=!1),e.hour===void 0&&i===void 0&&(r=!1),r&&i!==void 0){let o=this.resolveHour24({parts:e,hour12:i,meridiem:n});o!==null&&(e.hour=o)}return{parts:e,hour12:i,meridiem:n,allSegmentsPresent:r}}resolveHour24(t){if(t.hour12!==void 0){let e=t.hour12;return e<1||e>12||!t.meridiem?null:t.meridiem==="AM"?e===12?0:e:e===12?12:e+12}return t.parts.hour!==void 0&&t.parts.hour>=0&&t.parts.hour<=23?t.parts.hour:null}buildStrictUTCDate(t){let{year:e,month:i,day:n,hour:s,minute:r,second:o}=t;if(!Number.isInteger(e)||e<1||e>9999||!Number.isInteger(i)||i<1||i>12||!Number.isInteger(n)||n<1||n>31||!Number.isInteger(s)||s<0||s>23||!Number.isInteger(r)||r<0||r>59||!Number.isInteger(o)||o<0||o>59)return null;let a=new Date(0);return a.setUTCFullYear(e,i-1,n),a.setUTCHours(s,r,o,0),a.getUTCFullYear()!==e||a.getUTCMonth()!==i-1||a.getUTCDate()!==n||a.getUTCHours()!==s||a.getUTCMinutes()!==r||a.getUTCSeconds()!==o?null:a}dateToUTCParts(t){return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}formatDateToISO(t){let e=String(t.getUTCFullYear()).padStart(4,"0"),i=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0"),s=String(t.getUTCHours()).padStart(2,"0"),r=String(t.getUTCMinutes()).padStart(2,"0"),o=String(t.getUTCSeconds()).padStart(2,"0");if(this.includeMilliseconds){let a=String(t.getUTCMilliseconds()).padStart(3,"0");return`${e}-${i}-${n}T${s}:${r}:${o}.${a}Z`}return`${e}-${i}-${n}T${s}:${r}:${o}Z`}formatPartsToTemplate(t){let e="";for(let i of this.segments)switch(i.kind){case"YYYY":e+=String(t.year).padStart(4,"0").slice(-4);break;case"MM":e+=String(t.month).padStart(2,"0");break;case"DD":e+=String(t.day).padStart(2,"0");break;case"HH":e+=String(t.hour).padStart(2,"0");break;case"hh":{let n=t.hour%12===0?12:t.hour%12;e+=String(n).padStart(2,"0");break}case"mm":e+=String(t.minute).padStart(2,"0");break;case"ss":e+=String(t.second).padStart(2,"0");break;case"A":e+=t.hour>=12?"PM":"AM";break}return this.formatFromCleanRaw(e)}formatDateOnlyMatch(t,e){if(!this.buildStrictUTCDate({year:t.year,month:t.month,day:t.day,hour:0,minute:0,second:0}))return e;if(typeof this.defaultTimeOnDateOnly=="string"&&this.defaultTimeOnDateOnly.trim()){let r=this.parseDefaultTime(this.defaultTimeOnDateOnly.trim());if(r){let o=this.formatPartsToTemplate({...t,hour:r.hour,minute:r.minute,second:r.second});return{matched:!0,formatted:o,cursor:o.length}}}let n="";for(let r of this.segments){if(_t.has(r.kind))break;r.kind==="YYYY"?n+=String(t.year).padStart(4,"0"):r.kind==="MM"?n+=String(t.month).padStart(2,"0"):r.kind==="DD"&&(n+=String(t.day).padStart(2,"0"))}if(!n)return e;let s=this.formatFromCleanRaw(n);return{matched:!0,formatted:s,cursor:s.length}}parseDefaultTime(t){let e=t.split(":");if(e.length<2||e.length>3)return null;let i=L(e[0]),n=L(e[1]),s=e.length===3?L(e[2]):0;return Number.isNaN(i)||i<0||i>23||Number.isNaN(n)||n<0||n>59||Number.isNaN(s)||s<0||s>59?null:{hour:i,minute:n,second:s}}parseISO8601Linear(t){if(t.length<10)return null;for(let u of[0,1,2,3,5,6,8,9])if(!x(t[u]))return null;if(t[4]!=="-"||t[7]!=="-")return null;let e=L(t.slice(0,4)),i=L(t.slice(5,7)),n=L(t.slice(8,10));if(t.length===10)return{year:e,month:i,day:n,hour:0,minute:0,second:0,dateOnly:!0,offsetMinutes:null};let s=10;if(t[s]!=="T"&&t[s]!=="t"&&t[s]!==" "||(s++,s+5>t.length)||!x(t[s])||!x(t[s+1])||t[s+2]!==":"||!x(t[s+3])||!x(t[s+4]))return null;let r=L(t.slice(s,s+2)),o=L(t.slice(s+3,s+5));s+=5;let a=0;if(s<t.length&&t[s]===":"){if(s++,s+2>t.length||!x(t[s])||!x(t[s+1]))return null;a=L(t.slice(s,s+2)),s+=2}if(s<t.length&&t[s]==="."){s++;let u=s;for(;s<t.length&&x(t[s]);)s++;if(s===u)return null}let l=null;if(s<t.length){for(;s<t.length&&t[s]===" ";)s++;if(s<t.length){let u=t[s];if(u==="Z"||u==="z")l=0,s++;else if(u==="+"||u==="-"){let h=u==="-"?-1:1;if(s++,s+2>t.length||!x(t[s])||!x(t[s+1]))return null;let c=L(t.slice(s,s+2));s+=2;let d=0;if(s<t.length){if(t[s]===":"&&s++,s+2>t.length||!x(t[s])||!x(t[s+1]))return null;d=L(t.slice(s,s+2)),s+=2}if(c>14||d>59||c===14&&d!==0)return null;l=h*(c*60+d)}else if(t.slice(s).toUpperCase()==="UTC")l=0,s=t.length;else return null}}return s!==t.length?null:{year:e,month:i,day:n,hour:r,minute:o,second:a,dateOnly:!1,offsetMinutes:l}}parseConfiguredFormatLinear(t){let e={matched:!1,formatted:"",cursor:0},i=t;i.toUpperCase().endsWith(" UTC")?i=i.slice(0,-4).trim():i.length>2&&(i.endsWith("Z")||i.endsWith("z"))&&x(i[i.length-2])&&(i=i.slice(0,-1).trim()),this.prefixString&&i.toLowerCase().startsWith(this.prefixString.trim().toLowerCase())&&(i=i.slice(this.prefixString.trim().length).trim());let n=[],s=-1;for(let d=0;d<i.length;d++){let p=i[d];me.has(p)?s!==-1&&(n.push(i.slice(s,d)),s=-1):s===-1&&(s=d)}if(s!==-1&&n.push(i.slice(s)),n.length===0||n.length>this.segments.length)return e;let r=0;for(let d of this.segments){if(_t.has(d.kind))break;r++}let o=[],a,l,u;for(let d=0;d<n.length;d++){let p=n[d],m=this.segments[d];if(m.kind==="A"){let g=p.toUpperCase();if(g==="AM"||g==="A")o.push("AM");else if(g==="PM"||g==="P")o.push("PM");else return e;continue}for(let g=0;g<p.length;g++)if(!x(p[g]))return e;if(m.kind==="YYYY"){if(p.length!==4)return e;a=L(p),o.push(p)}else{if(p.length<1||p.length>2)return e;let g=p.length===1?"0"+p:p,b=L(g);m.kind==="MM"&&(l=b),m.kind==="DD"&&(u=b),o.push(g)}}if(n.length===r&&a!==void 0&&l!==void 0&&u!==void 0)return this.formatDateOnlyMatch({year:a,month:l,day:u},e);let h=this.segments.length;if(n.length<h&&!(r>0&&n.length>=r+2&&this.segments[r+1]?.kind==="mm"))return e;let c=this.formatFromCleanRaw(o.join(""));return{matched:!0,formatted:c,cursor:c.length}}};var be=10,bt=class extends N{engine;history;isComposing=!1;isUndoingRedoing=!1;isMouseDown=!1;isApplying=!1;isNotifying=!1;hasPendingNotification=!1;lastValue="";lastValueLength=0;lastInputType="";inferredInputModeValue=null;wasAutocorrectSet=!1;wasAutocapitalizeSet=!1;wasSpellcheckSet=!1;cutTimerId=null;pasteTimerId=null;resetTimerId=null;constructor(t,e,i){let n=X(t,e,i),s=n.wrapper,r=n.input,o=n.options,a=s?.getAttribute("data-mask-format")||r?.getAttribute("data-mask-format")||void 0,l=s?.getAttribute("data-mask-utc-indicator")??r?.getAttribute("data-mask-utc-indicator"),u=s?.getAttribute("data-mask-infer-inputmode")??r?.getAttribute("data-mask-infer-inputmode"),h=o.utcIndicator!==void 0?o.utcIndicator:l!==null?l==="false"||l==="none"?!1:l:" UTC",c={...o,format:o.format??a??"YYYY-MM-DD HH:mm",utcIndicator:h,includeMilliseconds:o.includeMilliseconds??!1,convertPastedOffset:o.convertPastedOffset??!0,defaultTimeOnDateOnly:o.defaultTimeOnDateOnly??!1,inferInputMode:o.inferInputMode??(u!==null?u!=="false":!0),onInput:o.onInput||o.oninput,onChange:o.onChange||o.onchange,onComplete:o.onComplete||o.oncomplete};super(s,r,c),this.history=new U,this.engine=new Q(this.options),this.input.hasAttribute("autocorrect")||(this.input.setAttribute("autocorrect","off"),this.wasAutocorrectSet=!0),this.input.hasAttribute("autocapitalize")||(this.input.setAttribute("autocapitalize","none"),this.wasAutocapitalizeSet=!0),this.input.hasAttribute("spellcheck")||(this.input.setAttribute("spellcheck","false"),this.wasSpellcheckSet=!0),this.syncInferredInputMode(),this.bindEvents(),this.lastValue=this.isSensitiveField()?this.computePasswordDigest(this.input.value):this.input.value,this.syncInitialValue(),this.runAuditWarning(this.options.audit)}static format(t,e={}){return Q.format(t,e)}getSpecificAuditWarnings(){let t=[],e=[],i=this.checkAriaIdReferences(this.input,"aria-describedby",e,!0),n=!!this.input.getAttribute("placeholder")?.trim(),s=!!this.input.getAttribute("aria-placeholder")?.trim();return!i&&!s&&!this.options.disabled&&(n?t.push(`Indication du format UTC fragile : placeholder seul dispara\xEEt \xE0 la saisie et l'indicateur UTC fant\xF4me est aria-hidden="true" ; d\xE9finissez aria-describedby ou aria-placeholder (WCAG 3.3.2).`):t.push("Indication du format UTC attendu manquante : d\xE9finissez aria-describedby ou aria-placeholder pour informer les technologies d'assistance du format et du r\xE9f\xE9rentiel UTC (WCAG 3.3.2).")),t}extractRawSnippet(t){return t?t===this.input.value&&this.isValid()?this.getRawValue():this.engine.extractRaw(t,!1):""}onPasswordModeDetected(){this.history.clear(),this.lastValue="",this.lastValueLength=0,this.lastTrackedValue="",this.clearGhost()}onNativeValueSet(t){if(this.options.disabled)this.checkValueChange(!1);else{let e=this.engine.formatFromNativeValue(t);this.applyFormatted(e,e.length,!1)}}onDisabledChange(t){if(t)this.wrapper.classList.remove("is-complete","has-selection"),this.clearGhost(),this.checkValueChange(!1);else{let e=this.engine.formatFromValue(this.input.value);this.applyFormatted(e,this.input.selectionStart??e.length,!1)}this.syncInferredInputMode()}handleAttributeMutation(t){if(super.handleAttributeMutation(t),t==="data-mask-format"){let e=this.getAttr("data-mask-format");e&&e!==this.engine.getFormat()&&this.setFormat(e)}else if(t==="data-mask-utc-indicator"){let e=this.getAttr("data-mask-utc-indicator"),i=e===null||e==="false"||e==="none"?!1:e;this.setUtcIndicator(i)}else t==="placeholder"&&this.updateGhost(this.input.value)}bindEvents(){this.onBeforeInput=this.onBeforeInput.bind(this),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.onCutHandler=()=>{this.cutTimerId!==null&&clearTimeout(this.cutTimerId),this.cutTimerId=window.setTimeout(()=>{if(this.cutTimerId=null,!this.isDestroyed)if(this.options.disabled)this.checkValueChange(!1);else{let i=this.input.selectionStart??this.input.value.length;this.applyFormatted(this.input.value,i,!1)}},0)};let t=()=>{this.isDestroyed||this.checkValueChange(!0,!0)},{signal:e}=this.abortController;this.input.addEventListener("beforeinput",this.onBeforeInput,{signal:e}),this.input.addEventListener("input",this.handleInput,{signal:e}),this.input.addEventListener("keydown",this.onKeyDown,{signal:e}),this.input.addEventListener("paste",this.onPaste,{signal:e}),this.input.addEventListener("focus",this.onFocus,{signal:e}),this.input.addEventListener("blur",this.onBlur,{signal:e}),this.input.addEventListener("click",this.onClick,{signal:e}),this.input.addEventListener("keyup",this.onKeyUp,{signal:e}),this.input.addEventListener("select",this.onSelect,{signal:e}),this.input.addEventListener("mousedown",this.onMouseDown,{signal:e}),window.addEventListener("mouseup",this.onMouseUp,{signal:e}),this.input.addEventListener("compositionstart",this.onCompositionStart,{signal:e}),this.input.addEventListener("compositionend",this.onCompositionEnd,{signal:e}),this.input.addEventListener("scroll",this.onScroll,{passive:!0,signal:e}),this.input.addEventListener("cut",this.onCutHandler,{signal:e}),this.input.addEventListener("change",t,{signal:e}),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(!1):this.syncInitialValue())},0)},this.input.form.addEventListener("reset",this.onFormResetHandler,{signal:e}))}syncInferredInputMode(){if(this.options.inferInputMode===!1)return;if(this.options.disabled){this.inferredInputModeValue&&this.input.getAttribute("inputmode")===this.inferredInputModeValue&&this.input.removeAttribute("inputmode"),this.inferredInputModeValue=null;return}let t=this.engine.isNumericOnly()?"numeric":"text",e=this.input.getAttribute("inputmode");(!e||this.inferredInputModeValue===e)&&(this.input.inputMode=t,this.inferredInputModeValue=t)}getDetail(){let t=this.engine.analyze(this.input.value,!1);return{...t,value:this.options.disabled?this.input.value:t.formatted}}getRawValue(){return this.options.disabled?this.input.value:this.getDetail().rawValue}getISOString(){return this.getDetail().isoString}getDate(){return this.getDetail().date}getTimestamp(){return this.getDetail().timestamp}getParts(){return this.getDetail().parts}getTemporalInstant(){let t=this.getTimestamp();if(t===null)return null;let e=globalThis.Temporal;if(e?.Instant&&typeof e.Instant.fromEpochMilliseconds=="function")try{return e.Instant.fromEpochMilliseconds(t)}catch{return null}return null}isComplete(){return this.options.disabled?!0:this.getDetail().isComplete}isValid(){return this.options.disabled?!0:this.getDetail().isValid}setValue(t){if(this.options.disabled){let i=t instanceof Date?Number.isNaN(t.getTime())?"":this.engine.formatDateToISO(t):t!=null?String(t):"";this.setNativeValue(i),this.checkValueChange(!1);return}let e=this.engine.formatFromValue(t);this.applyFormatted(e,e.length,!0)}setNow(){this.setValue(new Date)}formatLocal(t,e){return this.engine.formatLocal(this.getDate(),t,e)}setFormat(t,e){let i=this.getDate();if(this.options.format=t,e!==void 0&&(this.options.placeholderTokens=e),this.engine.setFormat(t,e),this.syncInferredInputMode(),this.options.disabled){this.clearGhost();return}if(i){let n=this.engine.formatFromValue(i);this.applyFormatted(n,n.length,!0)}else{let n=this.engine.format(this.input.value,!1);this.applyFormatted(n,Math.min(this.input.selectionStart??n.length,n.length),!1)}}setUtcIndicator(t){this.options.utcIndicator=t,this.engine.setUtcIndicator(t),this.updateGhost(this.input.value)}undo(){if(this.options.disabled)return;let t=this.history.undo();if(t){this.isUndoingRedoing=!0;try{this.applyFormatted(this.engine.format(t.raw,!1),t.cursor,!0)}finally{this.isUndoingRedoing=!1}}}redo(){if(this.options.disabled)return;let t=this.history.redo();if(t){this.isUndoingRedoing=!0;try{this.applyFormatted(this.engine.format(t.raw,!1),t.cursor,!0)}finally{this.isUndoingRedoing=!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.inferredInputModeValue&&this.input.getAttribute("inputmode")===this.inferredInputModeValue&&this.input.removeAttribute("inputmode"),this.wasAutocorrectSet&&this.input.removeAttribute("autocorrect"),this.wasAutocapitalizeSet&&this.input.removeAttribute("autocapitalize"),this.wasSpellcheckSet&&this.input.removeAttribute("spellcheck"),this.history.clear(),this.lastValue="",this.lastValueLength=0,super.destroy())}checkSelection(){if(this.options.disabled)return;let t=this.input.selectionStart??0,e=this.input.selectionEnd??t;this.wrapper.classList.toggle("has-selection",t!==e)}onBeforeInput(t){if(this.lastInputType=t.inputType||"",!(this.options.disabled||this.isComposing)&&!(t.inputType==="insertFromPaste"||t.inputType==="insertReplacementText")&&t.inputType&&t.inputType.startsWith("insert")){let e=this.engine.getEditableCount();if(e>0){let i=this.engine.extractRaw(this.input.value,!1),n=this.input.selectionStart??0,s=this.input.selectionEnd??n,r=Math.max(0,e-i.length);if(s>n){let o=this.engine.extractRaw(this.input.value.slice(n,s),!1);r=Math.max(0,e-(i.length-o.length))}r<=0&&t.preventDefault()}}}handleInput(t){if(this.isDispatchingNativeInput||this.isComposing)return;if(this.options.disabled){this.checkValueChange(!1);return}let e=t?.inputType||this.lastInputType||"";this.lastInputType="";let i=this.input.value,n=this.input.selectionStart??i.length,s=this.history.getCurrent(),r=this.engine.getEditableCount(),o=e.startsWith("delete")||!this.isSensitiveField()&&i.length<this.lastValueLength,a=this.engine.extractRaw(i,!1);if(r>0&&s&&s.raw.length>=r&&a.length>r){let h=this.engine.format(s.raw,!1);this.applyFormatted(h,s.cursor,!0);return}let l=i,u=!o;if(o&&this.engine.hasMeridiem()){for(let h of this.engine.getSegments())if(h.kind==="A"&&i.length>=h.start+1&&i.length<h.end){l=i.slice(0,h.start)+i.slice(h.start+1),u=!1;break}}this.applyFormatted(l,n,!1,u),this.checkSelection()}onKeyDown(t){if(this.options.disabled||R(t))return;let e=this.input.selectionStart??0,i=this.input.selectionEnd??e,n=this.engine.getPrefixLength();if((t.ctrlKey||t.metaKey)&&(t.key==="z"||t.key==="Z")&&!t.shiftKey){t.preventDefault(),this.undo();return}if((t.ctrlKey||t.metaKey)&&(t.key==="y"||t.key==="Y")||(t.ctrlKey||t.metaKey)&&t.shiftKey&&(t.key==="z"||t.key==="Z")){t.preventDefault(),this.redo();return}this.history.updateCurrentCursor(e);let s=t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey,r=i>e;if(s&&!r){let o=this.engine.tryHandleSeparatorKey(this.input.value,e,t.key);if(o.handled){t.preventDefault(),this.applyFormatted(o.formatted,o.cursor,!0);return}if(this.engine.hasMeridiem()){for(let l of this.engine.getSegments())if(l.kind==="A"&&e>=l.start&&e<=l.end){let u=t.key.toUpperCase();if(u==="A"||u==="P"){t.preventDefault();let h=u==="A"?"AM":"PM",c=this.input.value,d=c.slice(0,l.start)+h+c.slice(Math.min(c.length,l.end));this.applyFormatted(d,l.end,!0);return}}}let a=this.engine.getEditableCount();if(a>0&&this.engine.extractRaw(this.input.value,!1).length>=a){t.preventDefault();return}}if(r){if(t.key==="Backspace"||t.key==="Delete"){t.preventDefault();let o=this.input.value,a=o.slice(0,e)+o.slice(i);this.applyFormatted(a,Math.max(n,e),!1);return}return}if(t.key==="ArrowLeft"&&!t.shiftKey&&e<=n){t.preventDefault(),this.input.setSelectionRange(n,n);return}if(t.key==="Home"&&n>0&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey){t.preventDefault(),this.input.setSelectionRange(n,n);return}if(t.key==="Backspace"&&e<=n){t.preventDefault(),this.input.setSelectionRange(n,n);return}if(t.key==="Delete"&&e<n){t.preventDefault(),this.input.setSelectionRange(n,n);return}if(t.key==="Backspace"&&this.engine.hasMeridiem()){for(let o of this.engine.getSegments())if(o.kind==="A"&&e>o.start&&e<=o.end){t.preventDefault();let a=this.input.value,l=a.slice(0,o.start)+a.slice(Math.min(a.length,o.end));this.applyFormatted(l,o.start,!0);return}}if(t.key==="Backspace"&&(t.ctrlKey||t.altKey||t.metaKey)){if(t.preventDefault(),e<=n){this.input.setSelectionRange(n,n);return}let o=e-1;for(;o>=n&&this.engine.isSeparatorAt(o);)o--;for(;o>=n&&!this.engine.isSeparatorAt(o);)o--;let a=Math.max(n,o+1),l=this.input.value;this.applyFormatted(l.slice(0,a)+l.slice(e),a,!0);return}if(t.key==="Delete"&&(t.ctrlKey||t.altKey||t.metaKey)){t.preventDefault();let o=this.input.value;if(e>=o.length)return;let a=e;for(;a<o.length&&this.engine.isSeparatorAt(a);)a++;for(;a<o.length&&!this.engine.isSeparatorAt(a);)a++;for(;a<o.length&&this.engine.isSeparatorAt(a);)a++;this.applyFormatted(o.slice(0,e)+o.slice(a),e,!0);return}if(t.key==="Backspace"&&e>n&&this.engine.isSeparatorAt(e-1)){t.preventDefault();let o=e-1;for(;o>n&&this.engine.isSeparatorAt(o-1);)o--;if(o>n){let a=this.input.value;this.applyFormatted(a.slice(0,o-1)+a.slice(e),o-1,!1)}else this.applyFormatted("",n,!0);return}if(t.key==="Delete"&&e<this.input.value.length&&this.engine.isSeparatorAt(e)){t.preventDefault();let o=e;for(;o<this.input.value.length&&this.engine.isSeparatorAt(o);)o++;if(o<this.input.value.length){let a=this.input.value;this.applyFormatted(a.slice(0,o)+a.slice(o+1),e,!0)}}}onPaste(t){if(this.options.disabled){this.pasteTimerId!==null&&clearTimeout(this.pasteTimerId),this.pasteTimerId=window.setTimeout(()=>{this.pasteTimerId=null,this.isDestroyed||this.checkValueChange(!1)},0);return}t.preventDefault(),this.history.updateCurrentCursor(this.input.selectionStart??0);let e=this.preparePastedText(this.getClipboardPlainText(t),512);if(!e)return;let i=this.engine.getPrefixLength(),n=this.input.selectionStart??0,s=this.input.selectionEnd??n,r=this.input.value,o=this.engine.getEditableCount(),a=this.engine.extractRaw(r,!1);if(a.length===0||n<=i&&s>=r.length||n===s){let p=this.engine.parsePasted(e);if(p.matched){if(this.applyFormatted(p.formatted,p.cursor,!0),p.offsetConverted&&this.options.onOffsetConverted)try{this.options.onOffsetConverted(p.offsetConverted)}catch{}this.checkSelection();return}if(p.rejected)return}let u=Math.max(0,o-a.length);if(s>n){let p=this.engine.extractRaw(r.slice(n,s),!1);u=Math.max(0,o-(a.length-p.length))}if(u<=0)return;let h=Math.max(i,n),c=Math.max(i,s),d=r.slice(0,h)+e+r.slice(c);this.applyFormatted(d,h+e.length,!1,!0),this.checkSelection()}onFocus(){this.syncGhostStyles(),this.wrapper.classList.add("is-focused"),!this.options.disabled&&!this.isMouseDown&&this.enforceMinCursor(),this.updateGhost(this.input.value),this.checkSelection()}onBlur(){if(this.wrapper.classList.remove("is-focused","has-selection"),this.isSensitiveField()){this.onPasswordModeDetected();return}this.updateGhost(this.input.value),this.checkValueChange(!1,!0)}onClick(){this.options.disabled||this.enforceMinCursor(),this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onKeyUp(t){this.options.disabled||((t.key==="ArrowLeft"||t.key==="ArrowRight"||t.key==="Home")&&!t.shiftKey&&this.enforceMinCursor(),this.history.updateCurrentCursor(this.input.selectionStart??0)),this.checkSelection()}onSelect(){this.history.updateCurrentCursor(this.input.selectionStart??0),this.checkSelection()}onMouseDown(){this.isMouseDown=!0}onMouseUp(){this.isMouseDown=!1,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.applyFormatted(this.input.value,t,!1,!0),this.checkSelection()}enforceMinCursor(){let t=this.engine.getPrefixLength();if(t<=0)return;let e=this.input.selectionStart??0,i=this.input.selectionEnd??e;e===i&&e<t&&this.input.setSelectionRange(t,t)}updateGhost(t){if(!this.ghost)return;if(this.options.disabled||this.isSensitiveField()){this.clearGhost();return}let e=!t||t===this.engine.getPrefix();if(this.shouldHideGhostForPlaceholder(e)){this.clearGhost();return}let i=this.engine.getGhostRemaining(t),n=this.input.ownerDocument||document,s=n.createElement("span");s.className="mask-ghost-typed",s.textContent=t;let r=n.createElement("span");r.className="mask-ghost-remaining",r.textContent=i,this.setGhostContent(s,r),this.ghost.scrollLeft=this.input.scrollLeft}applyFormatted(t,e,i=!1,n=!1){if(!(this.options.disabled||this.isApplying)){this.isApplying=!0;try{let s=this.engine.format(t,n),r=this.isSensitiveField();this.setNativeValue(s),r?this.clearGhost():this.updateGhost(s);let o=this.engine.getPrefixLength(),a;i||this.isUndoingRedoing?a=Math.max(o,Math.min(e,s.length)):a=Math.max(o,this.engine.mapCursorPosition(t,e,s)),this.input.setSelectionRange(a,a);let l=this.engine.analyze(s,!1);this.wrapper.classList.toggle("is-complete",l.isComplete),r?(this.options.copyRaw=!1,this.lastValueLength=0,this.history.clear()):(this.lastValueLength=s.length,this.isUndoingRedoing||this.history.push(this.engine.extractRaw(s,!1),a))}finally{this.isApplying=!1}this.checkValueChange(!1)}}syncInitialValue(){let t=this.isSensitiveField();if(this.options.disabled){this.clearGhost(),this.lastValue=t?this.computePasswordDigest(this.input.value):this.input.value,this.lastValueLength=t?0:this.input.value.length,this.checkValueChange(!1);return}this.syncGhostStyles();let e=this.input.value||"";if(e){let i=this.engine.formatFromValue(e);this.applyFormatted(i,i.length,!0)}else{let i=this.engine.getPrefixLength();i>0?this.applyFormatted("",i,!0):(t?this.clearGhost():(this.history.push("",0),this.updateGhost("")),this.checkValueChange(!1))}}checkValueChange(t=!1,e=!1){let i=this.isSensitiveField(),n=this.input.value;if((i?this.computePasswordDigest(n):n)===this.lastValue&&!t&&!this.hasPendingNotification){if(e){let r=!i,o=this.getDetail(),a=this.options.onChange||this.options.onchange;a&&a(o),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:r,detail:o}))}return}if(this.isNotifying){this.hasPendingNotification=!0;return}this.isNotifying=!0;try{let r=0;for(;((this.isSensitiveField()?this.computePasswordDigest(this.input.value):this.input.value)!==this.lastValue||this.hasPendingNotification||t)&&r<be;){r++,this.hasPendingNotification=!1,t=!1;let o=this.isSensitiveField(),a=!o,l=this.input.value;this.lastValue=o?this.computePasswordDigest(l):l,this.lastValueLength=o?0:l.length;let u=this.getDetail(),h=this.options.onInput||this.options.oninput;if(h&&h(u),this.input.dispatchEvent(new CustomEvent("mask:input",{bubbles:a,detail:u})),this.dispatchNativeInput(),e){let c=this.options.onChange||this.options.onchange;c&&c(u),this.input.dispatchEvent(new CustomEvent("mask:change",{bubbles:a,detail:u}))}if(u.isComplete){let c=this.options.onComplete||this.options.oncomplete;c&&c(u),this.input.dispatchEvent(new CustomEvent("mask:complete",{bubbles:a,detail:u}))}}}finally{this.isNotifying=!1}}};var jt={BaseInputMask:N,InputMask:ht,MaskEngine:Z,MaskHistory:U,MaskKeyboard:nt,AmountEngine:J,InputAmountMask:pt,EmailEngine:rt,InputEmailMask:ft,DateUTCEngine:Q,DATE_UTC_PRESETS:gt,InputDateUTCMask:bt,sanitizePastedText:W,stripBidiAndInvisibles:z},qt=V();qt&&(qt.Mask=jt);var Pt=ht;var Ft={};at(Ft,{LocalizedComponent:()=>H,Scroll:()=>Jt,ScrollBlock:()=>ot,createI18nManager:()=>j,default:()=>Te,scrollEn:()=>Ht,scrollFr:()=>Ot,scrollI18n:()=>vt});var H=class extends B{static _i18n;static setLocale(t){this._i18n&&this._i18n.setLocale(t)}static getLocale(){return this._i18n?this._i18n.getLocale():""}static registerLocale(t,e){this._i18n&&this._i18n.registerLocale(t,e)}static setI18n(t){this._i18n&&this._i18n.setI18n(t)}static getI18n(){return this._i18n?this._i18n.getAll():{}}static resetI18n(){this._i18n&&this._i18n.reset()}static t(t,e){return this._i18n?this._i18n.t(t,e):String(t)}i18nOverrides;constructor(t){super(),this.i18nOverrides=t}t(t){let e=this.constructor;return e._i18n?e._i18n.t(t,this.i18nOverrides):String(t)}};var ve=new Set(["__proto__","constructor","prototype"]);function wt(f){return!!f&&!ve.has(f)}function xt(f){let t=String(f??"").trim().toLowerCase().replace(/_/g,"-");return wt(t)?t:""}function ye(f){let t=f.indexOf("-"),e=t>0?f.slice(0,t):null;return e&&wt(e)?e:null}function K(f,t){if(!t||typeof t!="object")return f;for(let e of Object.keys(t))wt(String(e))&&Object.hasOwn(t,e)&&t[e]!==void 0&&(f[e]=t[e]);return f}function j(f,t){let e=xt(f)||"fr",i=Object.create(null);for(let[a,l]of Object.entries(t)){let u=xt(a);u&&(i[u]=K(Object.create(null),l))}let n=e,s=Object.create(null);for(let[a,l]of Object.entries(i))s[a]=K(Object.create(null),l);let r=Object.create(null);function o(){let a=[];if(wt(n)){let u=s[n];u&&a.push(u)}let l=ye(n);return l&&s[l]&&a.push(s[l]),a}return{setLocale(a){if(a&&typeof a=="string"&&a.trim()){let l=xt(a);l&&(n=l)}},getLocale(){return n},registerLocale(a,l){if(!a||typeof a!="string"||!a.trim()||!l)return;let u=xt(a);if(!u)return;let h=K(Object.create(null),s[u]);s[u]=K(h,l)},setI18n(a){if(!a||typeof a!="object")return;let l=K(Object.create(null),r);r=K(l,a)},t(a,l){if(!wt(String(a)))return"";if(l&&typeof l=="object"&&Object.hasOwn(l,a)&&l[a]!==void 0)return String(l[a]);if(r[a]!==void 0)return String(r[a]);for(let h of o())if(h[a]!==void 0)return String(h[a]);let u=s[e]||i[e];return u&&u[a]!==void 0?String(u[a]):String(a)},getAll(a){let l={},u=s[e]||i[e];K(l,u);let h=o().reverse();for(let c of h)K(l,c);return K(l,r),K(l,a),l},reset(){n=e,r=Object.create(null),s=Object.create(null);for(let[a,l]of Object.entries(i))s[a]=K(Object.create(null),l)}}}var Ot={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 vt=j("fr",{fr:Ot,en:Ht});var Xt=0,ot=class extends H{static _i18n=vt;static i18n=vt;root;viewport;options;createdViewport=!1;isDestroyed=!1;wasIdGenerated=!1;wasRoleInferred=!1;wasAriaLabelInferred=!1;hasExplicitAriaLabel=!1;hasRootAriaLabel=!1;propagatedRootLabel=null;lastInferredAriaLabel="";trackY;thumbY;trackX;thumbX;resizeObserver;mutationObserver;observedChildren=new Set;hideTimer;scrollEndFallbackTimer;rafId=null;resizeRafId=null;abortController=new AbortController;dragAbortController;activeScrollToController;supportsScrollEnd=typeof window<"u"&&"onscrollend"in window;cachedMaxTop=0;cachedMaxLeft=0;cachedTrackHeight=0;cachedThumbHeight=0;cachedTrackWidth=0;cachedThumbWidth=0;isDragging=!1;dragAxis;dragPointerId;dragStartPos=0;dragStartScroll=0;atBottom=!1;atTop=!0;atRight=!1;atLeft=!0;boundOnScroll;boundOnScrollEnd;boundOnMouseEnter;boundOnMouseLeave;boundOnFocusIn;boundOnFocusOut;boundPointerMove;boundPointerUp;constructor(t,e){super(e?.i18n);let i=null;if(typeof t=="string")try{i=document.querySelector(t)}catch{i=null}else i=t;if(!i||!(i instanceof HTMLElement))throw new Error(`[ScrollBlock] \xC9l\xE9ment introuvable : "${t}".`);this.root=i,this.hasExplicitAriaLabel=!!(e?.ariaLabel||e?.i18n?.viewport);let n=e?.autoHideDelay,s=typeof n=="number"&&Number.isFinite(n)&&n>=0?Math.min(n,2147483647):1e3,r=e?.minThumbSize,o=typeof r=="number"&&Number.isFinite(r)&&r>0?r:24,a=e?.edgeThreshold,l=typeof a=="number"&&Number.isFinite(a)&&a>=0?a:10;this.options={axis:e?.axis||"y",mode:e?.mode||"custom",autoHide:e?.autoHide??!0,autoHideDelay:s,alwaysVisible:e?.alwaysVisible??!1,ariaLabel:e?.ariaLabel||this.t("viewport"),i18n:e?.i18n||{},minThumbSize:o,edgeThreshold:l,onScroll:e?.onScroll||(()=>{}),onScrollEnd:e?.onScrollEnd||(()=>{}),onTotalScroll:e?.onTotalScroll||(()=>{}),onTotalScrollBack:e?.onTotalScrollBack||(()=>{}),audit:e?.audit??!0},this.boundOnScroll=this.handleScroll.bind(this),this.boundOnScrollEnd=this.handleScrollEnd.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.mode==="native"&&this.root.classList.add("wulf-scrollblock--native"),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=Array.from(this.root.childNodes),i=document.createElement("div");i.className="wulf-scrollblock-viewport",this.root.appendChild(i);for(let n of e)ut(i,n,null);return this.createdViewport=!0,i}setupAccessibility(){this.viewport.id||(Xt+=1,this.viewport.id=`wulf-scrollblock-vp-${Xt}`,this.wasIdGenerated=!0),this.viewport.hasAttribute("role")||(this.viewport.setAttribute("role","region"),this.wasRoleInferred=!0);let t=this.root.getAttribute("aria-labelledby")?.trim(),e=this.root.getAttribute("aria-label")?.trim();if(t?(this.hasRootAriaLabel=!0,!this.hasExplicitAriaLabel&&!this.viewport.hasAttribute("aria-labelledby")&&!this.viewport.hasAttribute("aria-label")&&(this.viewport.setAttribute("aria-labelledby",t),this.propagatedRootLabel="aria-labelledby")):e&&(this.hasRootAriaLabel=!0,!this.hasExplicitAriaLabel&&!this.viewport.hasAttribute("aria-label")&&!this.viewport.hasAttribute("aria-labelledby")&&(this.viewport.setAttribute("aria-label",e),this.propagatedRootLabel="aria-label")),this.hasExplicitAriaLabel&&!this.viewport.hasAttribute("aria-label"))this.viewport.setAttribute("aria-label",this.options.ariaLabel),this.lastInferredAriaLabel=this.options.ariaLabel,this.wasAriaLabelInferred=!0;else if(!this.viewport.hasAttribute("aria-label")&&!this.viewport.hasAttribute("aria-labelledby")){let i=this.t("viewport");this.viewport.setAttribute("aria-label",i),this.lastInferredAriaLabel=i,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.mode!=="native"&&((this.options.axis==="y"||this.options.axis==="both")&&(this.trackY=document.createElement("div"),this.trackY.className="wulf-scrollblock-track wulf-scrollblock-vertical",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.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")))}isRtl(){return typeof window<"u"&&window.getComputedStyle(this.viewport).direction==="rtl"}attachTrackListeners(t,e,i){let{signal:n}=this.abortController;e.addEventListener("pointerdown",s=>{if(s.button!==0)return;s.preventDefault(),s.stopPropagation(),this.dragAbortController?.abort(),this.dragAbortController=new AbortController;let r=this.dragAbortController.signal;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;try{e.setPointerCapture(s.pointerId)}catch{}e.classList.add("is-active"),this.root.classList.add("is-dragging"),window.addEventListener("pointermove",this.boundPointerMove,{signal:r}),window.addEventListener("pointerup",this.boundPointerUp,{signal:r}),window.addEventListener("pointercancel",this.boundPointerUp,{signal:r}),e.addEventListener("lostpointercapture",this.boundPointerUp,{signal:r})},{signal:n}),e.addEventListener("keydown",s=>{if(s.ctrlKey||s.altKey||s.metaKey)return;let r=40,o=i==="y"?Math.max(r,Math.round(this.viewport.clientHeight*.9)):Math.max(r,Math.round(this.viewport.clientWidth*.9)),a=i==="y"?this.cachedMaxTop:this.cachedMaxLeft;if(a<=0)return;let l=i==="x"&&this.isRtl(),u=i==="y"?this.viewport.scrollTop:this.viewport.scrollLeft,h=null;if(i==="y")switch(s.key){case"ArrowDown":h=u+r;break;case"ArrowUp":h=u-r;break;case"PageDown":h=u+o;break;case"PageUp":h=u-o;break;case" ":h=u+(s.shiftKey?-o:o);break;case"Home":h=0;break;case"End":h=a;break}else switch(s.key){case"ArrowRight":h=u+r;break;case"ArrowLeft":h=u-r;break;case"PageDown":h=u+(l?-o:o);break;case"PageUp":h=u+(l?o:-o);break;case" ":h=u+(s.shiftKey?l?o:-o:l?-o:o);break;case"Home":h=0;break;case"End":h=l?-a:a;break}h!==null&&(s.preventDefault(),s.stopPropagation(),this.scrollTo(i==="y"?{top:h}:{left:h},{smooth:!1}),this.syncThumbs())},{signal:n}),t.addEventListener("pointerdown",s=>{if(s.button!==0||s.target===e)return;s.preventDefault();let r=i==="x"&&this.isRtl(),o=t.getBoundingClientRect(),a=i==="y"?s.clientY-o.top:r?o.right-s.clientX:s.clientX-o.left,l=i==="y"?o.height:o.width;if(l<=0)return;let u=i==="y"?this.cachedMaxTop:this.cachedMaxLeft,h=Math.max(0,Math.min(1,a/l)),c=r?-(h*u):h*u;this.scrollTo(i==="y"?{top:c}:{left:c},{smooth:!0})},{signal:n})}setupEventListeners(){let{signal:t}=this.abortController;this.viewport.addEventListener("scroll",this.boundOnScroll,{passive:!0,signal:t}),this.supportsScrollEnd&&this.viewport.addEventListener("scrollend",this.boundOnScrollEnd,{passive:!0,signal:t}),this.options.mode!=="native"&&this.options.autoHide&&!this.options.alwaysVisible&&(this.root.addEventListener("mouseenter",this.boundOnMouseEnter,{signal:t}),this.root.addEventListener("mouseleave",this.boundOnMouseLeave,{signal:t}),this.root.addEventListener("focusin",this.boundOnFocusIn,{signal:t}),this.root.addEventListener("focusout",this.boundOnFocusOut,{signal:t}))}setupObserver(){let t=()=>{this.isDestroyed||this.resizeRafId!==null||(this.resizeRafId=window.requestAnimationFrame(()=>{this.resizeRafId=null,this.isDestroyed||this.update()}))};if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(t),this.resizeObserver.observe(this.root),this.resizeObserver.observe(this.viewport);for(let e of Array.from(this.viewport.children))this.resizeObserver.observe(e),this.observedChildren.add(e)}typeof MutationObserver<"u"&&(this.mutationObserver=new MutationObserver(t),this.mutationObserver.observe(this.viewport,{childList:!0}))}handlePointerMove(t){if(!this.isDragging||!this.dragAxis||this.dragPointerId!==void 0&&t.pointerId!==this.dragPointerId)return;let e=this.dragAxis==="y",i=(e?t.clientY:t.clientX)-this.dragStartPos,n=e?this.cachedTrackHeight:this.cachedTrackWidth,s=e?this.cachedThumbHeight:this.cachedThumbWidth,r=e?this.cachedMaxTop:this.cachedMaxLeft,o=n-s;if(o<=0||r<=0)return;let a=r/o,l=this.dragStartScroll+i*a;e?this.viewport.scrollTop=Math.max(0,Math.min(r,l)):this.isRtl()?this.viewport.scrollLeft=Math.max(-r,Math.min(0,l)):this.viewport.scrollLeft=Math.max(0,Math.min(r,l))}handlePointerUp(t){if(this.isDragging&&!(t&&t.type!=="lostpointercapture"&&this.dragPointerId!==void 0&&t.pointerId!==this.dragPointerId)){if(this.dragPointerId!==void 0){let e=this.dragAxis==="y"?this.thumbY:this.thumbX;try{e&&e.hasPointerCapture(this.dragPointerId)&&e.releasePointerCapture(this.dragPointerId)}catch{}}this.dragAbortController?.abort(),this.dragAbortController=void 0,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()}}getScrollInfo(){let{scrollTop:t,scrollLeft:e}=this.viewport,i=this.cachedMaxTop,n=this.cachedMaxLeft,r=this.isRtl()?Math.max(0,-e):Math.max(0,e),o=i>0?Math.max(0,Math.min(1,t/i)):0,a=n>0?Math.max(0,Math.min(1,r/n)):0;return{top:t,left:e,maxTop:i,maxLeft:n,progressY:Math.round(o*100),progressX:Math.round(a*100)}}handleScroll(){this.scheduleSyncThumbs();let t=this.getScrollInfo(),{top:e,left:i,maxTop:n,maxLeft:s}=t;try{this.options.onScroll(t)}catch(o){console.error("[Wulf.Scroll] Erreur dans onScroll:",o)}let r=this.options.edgeThreshold;if(n>0){let o=e>=n-r,a=e<=r;if(o&&!this.atBottom)try{this.options.onTotalScroll("bottom")}catch(l){console.error("[Wulf.Scroll] Erreur dans onTotalScroll:",l)}if(a&&!this.atTop)try{this.options.onTotalScrollBack("top")}catch(l){console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:",l)}this.atBottom=o,this.atTop=a}if(s>0){let o=this.isRtl(),a=o?i>=-r:i>=s-r,l=o?i<=-s+r:i<=r;if(a&&!this.atRight)try{this.options.onTotalScroll("right")}catch(u){console.error("[Wulf.Scroll] Erreur dans onTotalScroll:",u)}if(l&&!this.atLeft)try{this.options.onTotalScrollBack("left")}catch(u){console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:",u)}this.atRight=a,this.atLeft=l}this.options.mode!=="native"&&this.options.autoHide&&!this.options.alwaysVisible&&(this.clearAutoHideTimer(),this.root.classList.add("is-scrolling"),this.supportsScrollEnd||this.scheduleAutoHide()),this.supportsScrollEnd||(this.scrollEndFallbackTimer!==void 0&&window.clearTimeout(this.scrollEndFallbackTimer),this.scrollEndFallbackTimer=window.setTimeout(()=>{this.scrollEndFallbackTimer=void 0,this.handleScrollEnd()},150))}handleScrollEnd(){try{this.options.onScrollEnd(this.getScrollInfo())}catch(t){console.error("[Wulf.Scroll] Erreur dans onScrollEnd:",t)}this.options.mode!=="native"&&this.options.autoHide&&!this.options.alwaysVisible&&this.scheduleAutoHide()}scheduleSyncThumbs(){this.options.mode==="native"||this.isDestroyed||this.rafId===null&&(this.rafId=window.requestAnimationFrame(()=>{this.rafId=null,this.isDestroyed||this.syncThumbs()}))}syncThumbs(){if(this.options.mode==="native"||this.isDestroyed)return;let{scrollTop:t,scrollLeft:e}=this.viewport;if(this.thumbY&&this.trackY){let i=this.cachedMaxTop,n=this.cachedTrackHeight-this.cachedThumbHeight;if(i>0){let s=Math.max(0,Math.min(1,t/i));if(this.thumbY.setAttribute("aria-valuenow",String(Math.round(s*100))),n>0){let r=Math.max(0,Math.min(n,s*n));this.thumbY.style.setProperty("--scrollblock-thumb-y",`${r}px`)}}else this.thumbY.setAttribute("aria-valuenow","0"),this.thumbY.style.setProperty("--scrollblock-thumb-y","0px")}if(this.thumbX&&this.trackX){let i=this.cachedMaxLeft,n=this.cachedTrackWidth-this.cachedThumbWidth;if(i>0){let s=this.isRtl(),r=s?Math.max(0,-e):Math.max(0,e),o=Math.max(0,Math.min(1,r/i));if(this.thumbX.setAttribute("aria-valuenow",String(Math.round(o*100))),n>0){let a=Math.max(0,Math.min(n,o*n)),l=s?-a:a;this.thumbX.style.setProperty("--scrollblock-thumb-x",`${l}px`)}}else this.thumbX.setAttribute("aria-valuenow","0"),this.thumbX.style.setProperty("--scrollblock-thumb-x","0px")}}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(){if(this.isDestroyed)return;if(this.syncAccessibilityLabels(),this.resizeObserver){let d=new Set(Array.from(this.viewport.children));for(let p of this.observedChildren)d.has(p)||(this.resizeObserver.unobserve(p),this.observedChildren.delete(p));for(let p of d)this.observedChildren.has(p)||(this.resizeObserver.observe(p),this.observedChildren.add(p))}let{scrollHeight:t,clientHeight:e,scrollWidth:i,clientWidth:n}=this.viewport,s=this.trackY?this.trackY.clientHeight:0,r=this.trackX?this.trackX.clientWidth:0,o=this.thumbY&&typeof window<"u"&&parseFloat(window.getComputedStyle(this.thumbY).minBlockSize)||0,a=this.thumbX&&typeof window<"u"&&parseFloat(window.getComputedStyle(this.thumbX).minInlineSize)||0;this.cachedMaxTop=Math.max(0,t-e),this.cachedMaxLeft=Math.max(0,i-n),this.cachedTrackHeight=s,this.cachedTrackWidth=r;let l=t>e,u=i>n,h=this.cachedThumbHeight;if(this.trackY&&this.thumbY&&l&&t>0){let d=Math.max(this.options.minThumbSize,o);h=Math.max(d,s*(e/t)),this.cachedThumbHeight=h}let c=this.cachedThumbWidth;if(this.trackX&&this.thumbX&&u&&i>0){let d=Math.max(this.options.minThumbSize,a);c=Math.max(d,r*(n/i)),this.cachedThumbWidth=c}this.root.classList.toggle("has-scroll-y",l),this.root.classList.toggle("has-scroll-x",u),l||u?this.viewport.setAttribute("tabindex","0"):this.viewport.removeAttribute("tabindex"),this.trackY&&this.thumbY&&(this.trackY.hidden=!l,l?(this.thumbY.setAttribute("tabindex","0"),this.thumbY.style.height=`${h}px`):this.thumbY.removeAttribute("tabindex")),this.trackX&&this.thumbX&&(this.trackX.hidden=!u,u?(this.thumbX.setAttribute("tabindex","0"),this.thumbX.style.width=`${c}px`):this.thumbX.removeAttribute("tabindex")),this.syncThumbs()}scrollTo(t,e){if(this.isDestroyed)return Promise.resolve();let i=typeof t=="object"&&t!==null&&!(t instanceof HTMLElement)?t.smooth:void 0,s=(e?.smooth??i??!0)&&!dt()?"smooth":"auto",r=this.isRtl(),{scrollHeight:o,clientHeight:a,scrollWidth:l,clientWidth:u,scrollTop:h,scrollLeft:c}=this.viewport,d=Math.max(0,o-a),p=Math.max(0,l-u);this.cachedMaxTop=d,this.cachedMaxLeft=p;let m,g;if(typeof t=="number")m=t;else if(typeof t=="string")switch(t){case"top":m=0;break;case"bottom":m=d;break;case"left":g=r?-p:0;break;case"right":g=r?0:p;break;default:{if(/^-?\d+(\.\d+)?%$/.test(t.trim())){let M=Math.max(0,Math.min(100,parseFloat(t.trim())))/100;this.options.axis==="x"?g=r?-p*M:p*M:this.options.axis==="both"?(m=d*M,g=r?-p*M:p*M):m=d*M;break}let E=null;try{E=this.viewport.querySelector(t)}catch{E=null}if(E){let M=this.viewport.getBoundingClientRect(),k=E.getBoundingClientRect();m=k.top-M.top-this.viewport.clientTop+h,g=k.left-M.left-this.viewport.clientLeft+c}break}}else if(t instanceof HTMLElement){if(t.isConnected&&this.viewport.contains(t)){let E=this.viewport.getBoundingClientRect(),M=t.getBoundingClientRect();m=M.top-E.top-this.viewport.clientTop+h,g=M.left-E.left-this.viewport.clientLeft+c}}else typeof t=="object"&&t!==null&&(m=t.top,g=t.left);let b=m!==void 0&&Number.isFinite(m)?Math.max(0,Math.min(d,m)):void 0,v=r?-p:0,y=r?0:p,T=g!==void 0&&Number.isFinite(g)?Math.max(v,Math.min(y,g)):void 0,A=b??h,S=T??c;if(Math.abs(A-h)<=1&&Math.abs(S-c)<=1)return Promise.resolve();this.activeScrollToController?.abort();let w=new AbortController;this.activeScrollToController=w;let C=this.viewport.scrollTo({top:b,left:T,behavior:s});return C instanceof Promise?C.then(()=>{this.activeScrollToController===w&&(this.activeScrollToController=void 0)}):s!=="smooth"?(this.activeScrollToController===w&&(this.activeScrollToController=void 0),Promise.resolve()):new Promise(E=>{let M=!1,k,I,q=()=>{M||(M=!0,k!==void 0&&window.clearTimeout(k),I!==void 0&&window.clearTimeout(I),this.activeScrollToController===w&&(this.activeScrollToController=void 0),w.abort(),E())};if(w.signal.addEventListener("abort",q,{once:!0}),this.abortController.signal.addEventListener("abort",q,{once:!0,signal:w.signal}),this.supportsScrollEnd)this.viewport.addEventListener("scrollend",q,{once:!0,signal:w.signal});else{let Tt=()=>{k!==void 0&&window.clearTimeout(k),k=window.setTimeout(q,150)};this.viewport.addEventListener("scroll",Tt,{passive:!0,signal:w.signal}),Tt()}I=window.setTimeout(q,2500)})}audit(){let t=[],e=this.checkAriaIdReferences(this.viewport,"aria-labelledby",t,!0),i=this.checkAriaIdReferences(this.root,"aria-labelledby",t,!0),n=e||i,s=this.root.getAttribute("aria-label")?.trim(),r=!this.wasAriaLabelInferred&&!!this.viewport.getAttribute("aria-label")?.trim();return!this.hasExplicitAriaLabel&&!this.hasRootAriaLabel&&!r&&!s&&!n&&t.push("Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour d\xE9crire la zone d\xE9filable (WCAG 4.1.2)."),this.options.mode!=="native"&&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.`),(this.root.tabIndex>0||this.viewport.tabIndex>0)&&t.push('Attribut tabindex > 0 d\xE9tect\xE9 sur la zone d\xE9filable : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).'),this.root.getAttribute("role")==="region"&&this.viewport.getAttribute("role")==="region"&&t.push('Landmark role="region" redondant : \xE9vitez de d\xE9clarer role="region" \xE0 la fois sur le conteneur racine et sur le viewport interne.'),t}getAuditPrefix(){return"Wulf.Scroll"}getAuditTargetLabel(){return this.root.id?`#${this.root.id}`:`<${this.root.tagName.toLowerCase()}.wulf-scrollblock>`}destroy(){if(!this.isDestroyed)if(this.isDragging&&this.handlePointerUp(),this.isDestroyed=!0,this.clearAutoHideTimer(),this.scrollEndFallbackTimer!==void 0&&(window.clearTimeout(this.scrollEndFallbackTimer),this.scrollEndFallbackTimer=void 0),this.rafId!==null&&(window.cancelAnimationFrame(this.rafId),this.rafId=null),this.resizeRafId!==null&&(window.cancelAnimationFrame(this.resizeRafId),this.resizeRafId=null),this.activeScrollToController?.abort(),this.activeScrollToController=void 0,this.dragAbortController?.abort(),this.dragAbortController=void 0,this.abortController.abort(),this.resizeObserver&&this.resizeObserver.disconnect(),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=void 0),this.observedChildren.clear(),this.trackY?.remove(),this.trackX?.remove(),this.root.classList.remove("wulf-scrollblock","wulf-scrollblock--native","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;)ut(this.root,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.propagatedRootLabel&&this.viewport.removeAttribute(this.propagatedRootLabel),this.wasAriaLabelInferred&&this.viewport.getAttribute("aria-label")===this.lastInferredAriaLabel&&this.viewport.removeAttribute("aria-label")}};var Jt={ScrollBlock:ot,i18n:vt};var Te=ot,Zt=V();Zt&&(Zt.Scroll=Jt);var Bt={};at(Bt,{LayoutEngine:()=>Y,LocalizedComponent:()=>H,Masonry:()=>tt,createI18nManager:()=>j,default:()=>we,masonryEn:()=>Vt,masonryFr:()=>Nt,masonryI18n:()=>yt});var Y=class{static parseGutter(t){if(typeof t=="number"){let e=Number.isFinite(t)?Math.max(0,t):0;return{x:e,y:e}}if(t&&typeof t=="object"){let e=Number(t.x),i=Number(t.y);return{x:Number.isFinite(e)?Math.max(0,e):0,y:Number.isFinite(i)?Math.max(0,i):0}}return{x:0,y:0}}static resolveColumnWidth(t,e,i){if(typeof i=="number"&&Number.isFinite(i)&&i>0)return i;if(typeof i=="string"){let s=i.trim();if(/^\d+(\.\d+)?(px|%)?$/i.test(s)){let r=parseFloat(s);if(Number.isFinite(r)&&r>0)if(s.endsWith("%")){let a=t.getBoundingClientRect().width*r/100;if(a>0)return a}else return r}else if(s){let r=null;try{r=t.querySelector(s)}catch{r=null}if(r){let a=r.getBoundingClientRect().width;if(Number.isFinite(a)&&a>0)return a}let o=parseFloat(s);if(Number.isFinite(o)&&o>0)return o}}if(i instanceof HTMLElement){let s=i.getBoundingClientRect().width;if(s>0)return s}if(e){let s=e.getBoundingClientRect().width;if(s>0)return s}let n=t.getBoundingClientRect().width;return n>0?n:200}static getItemSpan(t,e,i,n){let s=t.getAttribute("data-masonry-span")||t.dataset.masonrySpan;if(s){let r=parseInt(s,10);if(!isNaN(r)&&r>0)return Math.min(n,r)}for(let r of t.classList){let o=/^(?:span|col-span)-(\d+)$/.exec(r);if(o&&o[1]){let a=parseInt(o[1],10);if(!isNaN(a)&&a>0)return Math.min(n,a)}}return 1}static calculate(t,e,i){let s=t.getBoundingClientRect().width,{x:r,y:o}=this.parseGutter(i.gutter);if(s<=0||e.length===0)return{cols:1,colWidth:s,gutterX:r,gutterY:o,containerHeight:0,containerWidth:s,positions:[]};let a=e[0]||null,l=this.resolveColumnWidth(t,a,i.columnWidth),u=l+r,h=u>0?Math.floor((s+r)/u):1;!Number.isFinite(h)||h<1?h=1:h>1e3&&(h=1e3),!i.columnWidth&&h>1&&(l=(s-(h-1)*r)/h);let c=i.fitWidth?h*l+(h-1)*r:void 0,d=new Array(h).fill(0),p=[],m=e.map(T=>{let A=T.classList.contains("wulf-masonry-item--hidden")&&T.offsetHeight>0?T.offsetHeight:T.getBoundingClientRect().height;return A>0?A:50}),g=typeof window<"u"&&typeof window.getComputedStyle=="function"&&window.getComputedStyle(t).direction==="rtl",b=0;for(let T=0;T<e.length;T++){let A=e[T],S=m[T],w=this.getItemSpan(A,l,r,h),C=0,E=0;if(i.horizontalOrder){b+w>h&&(b=0),C=b;let O=0;for(let P=0;P<w;P++)d[C+P]>O&&(O=d[C+P]);E=O,b=(C+w)%h}else if(w===1){let O=d[0];C=0;for(let P=1;P<h;P++)d[P]<O&&(O=d[P],C=P);E=O}else{let O=1/0;C=0;for(let P=0;P<=h-w;P++){let At=0;for(let kt=0;kt<w;kt++)d[P+kt]>At&&(At=d[P+kt]);At<O&&(O=At,C=P)}E=O}let M=w*l+(w-1)*r,k=c!==void 0?c:s,I=C*(l+r),q=g?Math.max(0,k-I-M):I;p.push({element:A,x:q,y:E,width:M,height:S,column:C,span:w});let Tt=E+S+o;for(let O=0;O<w;O++)d[C+O]=Tt}let v=0;for(let T=0;T<h;T++)d[T]>v&&(v=d[T]);let y=Math.max(0,v>0?v-o:0);return{cols:h,colWidth:l,gutterX:r,gutterY:o,containerHeight:y,containerWidth:s,fittedWidth:c,positions:p}}};var Nt={gallery:"Galerie en grille asym\xE9trique"};var Vt={gallery:"Masonry grid gallery"};var yt=j("fr",{fr:Nt,en:Vt});var Se=new Set(["UL","OL","MAIN","NAV","ASIDE","ARTICLE","SECTION"]),tt=class extends H{static _i18n=yt;static i18n=yt;root;isNativeCSSGrid=!1;_items=[];options;resizeObserver=null;itemResizeObserver=null;observedItems=new Set;observedItemHeights=new WeakMap;removingItems=new Set;layoutRafId=null;lastObservedWidth=0;isDestroyed=!1;hasExplicitAriaRole=!1;wasRoleInferred=!1;wasAriaLabelInferred=!1;hasExplicitAriaLabel=!1;lastInferredAriaLabel="";abortController=new AbortController;watchedImages=new WeakSet;originalContainerStyles;constructor(t,e={}){if(super(e.i18n),typeof t=="string"){let n=null;try{n=document.querySelector(t)}catch{n=null}if(!n)throw new Error(`[Wulf.Masonry] Conteneur introuvable pour le s\xE9lecteur : "${t}"`);this.root=n}else if(t instanceof HTMLElement)this.root=t;else throw new Error("[Wulf.Masonry] Cible invalide : fournissez un \xE9l\xE9ment HTMLElement ou un s\xE9lecteur valide.");this.originalContainerStyles={height:this.root.style.height,width:this.root.style.width},this.hasExplicitAriaRole=!!e.ariaRole,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 i=typeof CSS<"u"&&typeof CSS.supports=="function"&&(CSS.supports("display","grid-lanes")||CSS.supports("grid-template-rows","masonry"));this.options.useNativeCSSGrid&&i?(this.isNativeCSSGrid=!0,this.root.classList.add("wulf-masonry","wulf-masonry--native"),this.syncNativeGridVariables()):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.hasExplicitAriaRole||!Se.has(this.root.tagName))&&(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.hasAttribute("aria-labelledby")&&(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="300ms";typeof t=="number"&&Number.isFinite(t)&&t>=0?e=`${Math.min(t,6e4)}ms`:typeof t=="string"&&/^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(t)&&(e=Mt(t,300,6e4)>=6e4?"60000ms":t.trim()),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")&&!this.removingItems.has(e));else try{let e=this.options.itemSelector.trim(),i=e.startsWith(">")?`:scope ${e}`:e;t=Array.from(this.root.querySelectorAll(i)).filter(n=>n.parentElement===this.root&&!n.hasAttribute("data-masonry-ignore")&&!this.removingItems.has(n))}catch{t=Array.from(this.root.children).filter(e=>e instanceof HTMLElement&&!e.hasAttribute("data-masonry-ignore")&&!this.removingItems.has(e))}if(this.itemResizeObserver){let e=new Set(t);for(let i of this.observedItems)e.has(i)||(this.itemResizeObserver.unobserve(i),this.observedItems.delete(i),this.observedItemHeights.delete(i))}this._items=t;for(let e of this._items)e.classList.add("wulf-masonry-item"),this.itemResizeObserver&&!this.observedItems.has(e)&&(this.itemResizeObserver.observe(e),this.observedItems.add(e))}initObservers(){if(!(!this.options.resize||typeof ResizeObserver>"u")){this.lastObservedWidth=this.root.getBoundingClientRect().width,this.resizeObserver=new ResizeObserver(t=>{for(let e of t){let i=e.contentRect.width;Math.abs(i-this.lastObservedWidth)>=1&&(this.lastObservedWidth=i,this.scheduleLayout())}}),this.resizeObserver.observe(this.root),this.itemResizeObserver=new ResizeObserver(t=>{let e=!1;for(let i of t){let n=i.borderBoxSize?.[0]?.blockSize??i.contentRect.height,s=this.observedItemHeights.get(i.target);(s===void 0||Math.abs(n-s)>=1)&&(this.observedItemHeights.set(i.target,n),s!==void 0&&(e=!0))}e&&this.scheduleLayout()});for(let t of this._items)this.itemResizeObserver.observe(t),this.observedItems.add(t)}}syncNativeGridVariables(){let{x:t,y:e}=Y.parseGutter(this.options.gutter);if(this.root.style.setProperty("--wulf-masonry-gutter-x",`${t}px`),this.root.style.setProperty("--wulf-masonry-gutter-y",`${e}px`),typeof this.options.columnWidth=="number"&&Number.isFinite(this.options.columnWidth)&&this.options.columnWidth>0)this.root.style.setProperty("--wulf-masonry-col-min",`${this.options.columnWidth}px`);else if(this.options.columnWidth instanceof HTMLElement){let i=this.options.columnWidth.getBoundingClientRect().width;i>0&&this.root.style.setProperty("--wulf-masonry-col-min",`${i}px`)}else if(typeof this.options.columnWidth=="string"&&this.options.columnWidth.trim()){let i=this.options.columnWidth.trim();if(/^\d+(\.\d+)?(px|%)?$/i.test(i)){let n=Y.resolveColumnWidth(this.root,null,i);n>0&&this.root.style.setProperty("--wulf-masonry-col-min",`${n}px`)}else try{let n=this.root.querySelector(i);if(n){let s=n.getBoundingClientRect().width;s>0&&this.root.style.setProperty("--wulf-masonry-col-min",`${s}px`)}}catch{}}}initImages(){if(!this.options.autoImages)return;let t=Array.from(this.root.querySelectorAll("img"));for(let e of t)if(!e.complete&&!this.watchedImages.has(e)){this.watchedImages.add(e);let i=()=>{e.addEventListener("load",()=>{this.isDestroyed||this.scheduleLayout()},{once:!0,signal:this.abortController.signal})};typeof e.decode=="function"?e.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.syncAccessibilityLabels(),this.isNativeCSSGrid){this.syncNativeGridVariables();for(let e of this._items)e.classList.remove("wulf-masonry-item--hidden");try{this.options.onLayout([])}catch(e){console.error("[Wulf.Masonry] Erreur dans onLayout:",e)}return}this.root.setAttribute("aria-busy","true");let t=[];try{this.options.fitWidth&&this.root.classList.contains("wulf-masonry--fit-width")&&(this.root.style.width="");let e=Y.calculate(this.root,this._items,this.options);t=e.positions,this.root.style.height=`${e.containerHeight}px`,this.options.fitWidth&&e.fittedWidth!==void 0?(this.root.style.width=`${e.fittedWidth}px`,this.lastObservedWidth=e.fittedWidth,this.root.classList.add("wulf-masonry--fit-width")):this.root.classList.remove("wulf-masonry--fit-width");let i=this.options.stagger,n=typeof i=="number"&&Number.isFinite(i)&&i>0;n?this.root.style.setProperty("--wulf-masonry-stagger",`${i}ms`):this.root.style.removeProperty("--wulf-masonry-stagger");let r=!(this._items.length!==this.root.children.length)&&typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("transition-delay","calc(sibling-index() * 1ms)"),o=this.options.percentPosition&&e.containerWidth>0;for(let a=0;a<e.positions.length;a++){let l=e.positions[a],u=l.element;if(o){let h=Number((l.width/e.containerWidth*100).toFixed(4));u.style.setProperty("--wulf-masonry-w",`${h}%`)}else u.style.setProperty("--wulf-masonry-w",`${l.width}px`);u.style.setProperty("--wulf-masonry-x",`${l.x}px`),u.style.setProperty("--wulf-masonry-y",`${l.y}px`),n&&!r?u.style.setProperty("--wulf-masonry-index",String(a)):u.style.removeProperty("--wulf-masonry-index"),u.classList.remove("wulf-masonry-item--hidden"),this.observedItemHeights.set(u,l.height);try{this.options.onItemPlaced(u,l)}catch(h){console.error("[Wulf.Masonry] Erreur dans onItemPlaced:",h)}}}finally{this.root.setAttribute("aria-busy","false")}try{this.options.onLayout(t)}catch(e){console.error("[Wulf.Masonry] Erreur dans onLayout:",e)}}append(t){if(this.isDestroyed)return;let e=(Array.isArray(t)?t:[t]).filter(n=>n instanceof HTMLElement&&!n.contains(this.root));if(e.length===0)return;let i=document.createDocumentFragment();for(let n of e)this.isNativeCSSGrid?n.classList.add("wulf-masonry-item"):n.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),i.appendChild(n);this.root.appendChild(i),this.reloadItems(),this.initImages(),this.layout()}prepend(t){if(this.isDestroyed)return;let e=(Array.isArray(t)?t:[t]).filter(s=>s instanceof HTMLElement&&!s.contains(this.root));if(e.length===0)return;let i=this.root.firstChild,n=document.createDocumentFragment();for(let s of e)this.isNativeCSSGrid?s.classList.add("wulf-masonry-item"):s.classList.add("wulf-masonry-item","wulf-masonry-item--hidden"),n.appendChild(s);this.root.insertBefore(n,i),this.reloadItems(),this.initImages(),this.layout()}remove(t){if(this.isDestroyed)return;let e=(Array.isArray(t)?t:[t]).filter(r=>r instanceof HTMLElement);if(e.length===0)return;let i=()=>{if(!this.isDestroyed){for(let r of e)this.removingItems.delete(r),r.parentElement===this.root&&(this.itemResizeObserver&&(this.itemResizeObserver.unobserve(r),this.observedItems.delete(r),this.observedItemHeights.delete(r)),this.root.removeChild(r));this.reloadItems(),this.layout()}},n=D();if(n&&e.some(r=>r.contains(n))){let r=new Set(e),o=this._items.findIndex(c=>r.has(c)),a=o>=0?this._items.slice(o+1).filter(c=>!r.has(c)):[],l=o>0?this._items.slice(0,o).filter(c=>!r.has(c)).reverse():[],u=a[0]||l[0]||null,h=!1;if(u){let d=u.querySelector('a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||(u.tabIndex>=0?u:null);if(d)try{d.focus({preventScroll:!0}),h=!0}catch{h=!1}}h||n.blur?.()}for(let r of e)this.removingItems.add(r),r.setAttribute("inert",""),r.style.transitionDelay="0ms",r.classList.add("wulf-masonry-item--hidden");let s=Mt(this.options.transitionDuration,300);if(s<=0||this.isNativeCSSGrid){i();return}this.reloadItems(),this.layout(),Promise.all(e.map(r=>St(r,s,this.abortController.signal))).then(()=>{this.abortController.signal.aborted||i()})}audit(){let t=[],e=this.checkAriaIdReferences(this.root,"aria-labelledby",t,!0),i=!this.wasAriaLabelInferred&&!!this.root.getAttribute("aria-label")?.trim();!this.hasExplicitAriaLabel&&!i&&!e&&t.push("Libell\xE9 contextuel manquant : d\xE9finissez l'option ariaLabel (ou un attribut aria-label / aria-labelledby sur le conteneur) pour qualifier la grille (WCAG 4.1.2).");let n=Array.from(this.root.querySelectorAll("img")).filter(r=>!r.hasAttribute("alt")&&r.getAttribute("aria-hidden")!=="true");n.length>0&&t.push(`${n.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`);let s=Array.from(this.root.querySelectorAll("[tabindex]")).filter(r=>r.tabIndex>0);return s.length>0&&t.push(`${s.length} \xE9l\xE9ment(s) avec tabindex > 0 d\xE9tect\xE9(s) : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).`),!this.options.horizontalOrder&&this.root.querySelector('a[href], button, input, select, textarea, [tabindex="0"]')!==null&&t.push("Grille interactive avec horizontalOrder: false : l'ordre visuel peut diverger de l'ordre de tabulation ; envisagez horizontalOrder: true (WCAG 1.3.2 / 2.4.3)."),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,this.abortController.abort(),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.root.style.removeProperty("--wulf-masonry-stagger"),this.root.style.removeProperty("--wulf-masonry-col-min"),this.root.style.removeProperty("--wulf-masonry-gutter-x"),this.root.style.removeProperty("--wulf-masonry-gutter-y"),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.removingItems)t.removeAttribute("inert"),t.style.removeProperty("transition-delay"),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("--wulf-masonry-index");this.removingItems.clear();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("--wulf-masonry-index");this._items=[]}}};var we=tt,Qt=V();Qt&&(Qt.Masonry=Object.assign(tt,{Masonry:tt,LayoutEngine:Y,i18n:yt}));var Wt={};at(Wt,{LocalizedComponent:()=>H,Toast:()=>it,ToastInstance:()=>ct,ToastManager:()=>et,createI18nManager:()=>j,default:()=>Ie,toastEn:()=>Ut,toastFr:()=>zt,toastI18n:()=>G});var zt={closeButton:"Fermer la notification",notificationsRegion:"Notifications"};var Ut={closeButton:"Close notification",notificationsRegion:"Notifications"};var G=j("fr",{fr:zt,en:Ut});var Ce=1,te=5e3,Ae=/^(?:#[0-9a-f]{3,8}|(?:rgb|rgba|hsl|hsla|oklch|oklab|lch|lab)\([^;{}<>\\]+\)|[a-z]{3,20})$/i;function Ct(f){if(!f||typeof f!="string"||f.length>128)return!1;let t=f.trim();return!t||/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env|var)\s*\(/i.test(t)?!1:typeof CSS<"u"&&typeof CSS.supports=="function"?CSS.supports("color",t)||CSS.supports("background-color",t):Ae.test(t)}function ke(f){return f.slice(0,128).trim().split(/\s+/).filter(t=>/^[a-zA-Z0-9_-]+$/.test(t)&&!t.startsWith("wulf-toast")).slice(0,8).join(" ")}var ct=class extends B{id;options;element;_isClosed=!1;_isFinalized=!1;closePromise=null;timerId=null;remainingTime=0;hasDuration=!1;timerStartTime=0;isPausedByHover=!1;isPausedByFocus=!1;isPausedByVisibility=!1;isPendingFocusDismiss=!1;previousActiveElement=null;eventsAbortController=new AbortController;disposeAbortController=new AbortController;onDismissCallback;constructor(t,e){super(),this.id=`wulf-toast-${Ce++}`,this.options=Object.freeze({...t}),this.onDismissCallback=e,this.previousActiveElement=D();let i=t.duration===void 0?te:t.duration;typeof i=="number"&&Number.isFinite(i)&&i>0?(this.remainingTime=Math.min(i,2147483647),this.hasDuration=!0):(this.remainingTime=0,this.hasDuration=!1),this.element=this.createDOM(),this.bindEvents(),this.runAuditWarning(t.audit!==!1)}get isClosed(){return this._isClosed}getPreviousActiveElement(){return this.previousActiveElement}audit(){let t=[],e=!!(this.options.title&&this.options.title.trim().length>0),i=!!(this.options.message&&this.options.message.trim().length>0);!e&&!i&&t.push("Contenu textuel vide : d\xE9finissez au moins un title ou un message pour que le lecteur d'\xE9cran puisse annoncer la notification (WCAG 4.1.3).");let n=this.options.duration===void 0?te:this.options.duration;typeof n=="number"&&n>0&&n<5e3&&t.push(`Dur\xE9e d'affichage trop courte (duration: ${n}ms) : pr\xE9voyez au moins 5000ms ou duration: false pour laisser le temps de lecture aux utilisateurs (WCAG 2.2.1).`);let s=this.options.closable??!0;return(n===!1||typeof n=="number"&&n<=0)&&!s&&t.push("Notification persistante impossible \xE0 fermer au clavier : activez closable: 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");if(t.id=this.id,t.className="wulf-toast",t.setAttribute("data-toast-role",this.options.role==="alert"?"alert":"status"),this.options.backgroundColor&&Ct(this.options.backgroundColor)&&t.style.setProperty("--wulf-toast-bg",this.options.backgroundColor.trim()),this.options.titleColor&&Ct(this.options.titleColor)&&t.style.setProperty("--wulf-toast-title-color",this.options.titleColor.trim()),this.options.textColor&&Ct(this.options.textColor)&&t.style.setProperty("--wulf-toast-text-color",this.options.textColor.trim()),this.options.iconColor&&Ct(this.options.iconColor)&&t.style.setProperty("--wulf-toast-icon-color",this.options.iconColor.trim()),this.options.closeButtonColor&&Ct(this.options.closeButtonColor)&&t.style.setProperty("--wulf-toast-close-color",this.options.closeButtonColor.trim()),this.options.icon&&typeof this.options.icon=="string"&&this.options.icon.trim()!==""){let s=ke(this.options.icon);if(s){let r=document.createElement("span");r.className=`wulf-toast-icon ${s}`,r.setAttribute("aria-hidden","true"),t.appendChild(r)}}let e=document.createElement("div"),i=!!(this.options.onClick||this.options.closeOnClick);if(e.className=i?"wulf-toast-content wulf-toast-content--interactive":"wulf-toast-content",i&&(e.setAttribute("role","button"),e.setAttribute("tabindex","0"),e.addEventListener("keydown",s=>{R(s)||(s.key==="Enter"?(s.preventDefault(),s.stopPropagation(),e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0}))):s.key===" "&&(s.preventDefault(),s.stopPropagation()))},{signal:this.eventsAbortController.signal}),e.addEventListener("keyup",s=>{s.key===" "&&(s.preventDefault(),s.stopPropagation(),e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})))},{signal:this.eventsAbortController.signal})),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(t.appendChild(e),this.options.closable??!0){let s=document.createElement("button");s.type="button",s.className="wulf-toast-close",s.setAttribute("aria-label",G.t("closeButton",this.options.i18n));let r=document.createElement("span");r.className="wulf-toast-close-icon",r.setAttribute("aria-hidden","true"),r.textContent="\xD7",s.appendChild(r),s.addEventListener("click",o=>{o.stopPropagation(),this.close("close-button")},{signal:this.eventsAbortController.signal}),t.appendChild(s)}if(this.options.progressBar&&this.remainingTime>0){t.style.setProperty("--wulf-toast-duration",`${this.remainingTime}ms`);let s=document.createElement("div");s.className="wulf-toast-progress",s.setAttribute("aria-hidden","true"),t.appendChild(s)}return t}appendTextWithLineBreaks(t,e){z(String(e??""),4096).split(/\r\n|\r|\n/).slice(0,100).forEach((s,r)=>{r>0&&t.appendChild(document.createElement("br")),t.appendChild(document.createTextNode(s))})}bindEvents(){let{signal:t}=this.eventsAbortController;this.element.addEventListener("click",e=>{if(this.options.onClick)try{this.options.onClick(this,e)}catch(i){console.error("[Wulf.Toast] Erreur dans le callback onClick:",i)}this.options.closeOnClick&&this.close("toast-click")},{signal:t}),this.element.addEventListener("mouseenter",()=>this.pauseTimer("hover"),{signal:t}),this.element.addEventListener("mouseleave",()=>this.resumeTimer("hover"),{signal:t}),this.element.addEventListener("focusin",()=>this.pauseTimer("focus"),{signal:t}),this.element.addEventListener("focusout",e=>{let i=e.relatedTarget;if(!(i&&this.element.contains(i))){if(this.isPendingFocusDismiss&&!this._isClosed){this.isPendingFocusDismiss=!1,this.close("timeout");return}this.resumeTimer("focus")}},{signal:t}),this.element.addEventListener("keydown",e=>{if(e.key==="Escape"&&(this.options.closable??!0)){if(R(e))return;e.stopPropagation(),this.close("close-button")}},{signal:t}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pauseTimer("visibility"):this.resumeTimer("visibility")},{signal:t})}get isPaused(){return this.isPausedByHover||this.isPausedByFocus||this.isPausedByVisibility}startTimer(){if(!(this._isClosed||this.remainingTime<=0||this.isPaused)){if(typeof document<"u"&&document.visibilityState==="hidden"){this.isPausedByVisibility=!0,this.element.classList.add("is-paused");return}this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.timerStartTime=performance.now(),this.timerId=window.setTimeout(()=>{this.timerId=null;let t=D();if(t&&this.element.contains(t)){this.isPendingFocusDismiss=!0;return}this.close("timeout")},this.remainingTime)}}pauseTimer(t="interaction"){if(this._isClosed||!this.hasDuration||this.remainingTime<=0)return;let e=this.isPaused;if(t==="visibility"?this.isPausedByVisibility=!0:t==="focus"?this.isPausedByFocus=!0:this.isPausedByHover=!0,!e){if(this.timerId!==null){window.clearTimeout(this.timerId),this.timerId=null;let i=performance.now()-this.timerStartTime;this.remainingTime=Math.max(0,this.remainingTime-i)}this.element.classList.add("is-paused")}}resumeTimer(t="interaction"){if(!(this._isClosed||!this.hasDuration)){if(t==="visibility")this.isPausedByVisibility=!1;else if(t==="focus")this.isPausedByFocus=!1;else if(t==="hover"){this.isPausedByHover=!1;let e=D();e&&this.element.contains(e)&&(this.isPausedByFocus=!0)}else this.isPausedByHover=!1,this.isPausedByFocus=!1;if(!this.isPaused){if(this.element.classList.remove("is-paused"),this.remainingTime<=0){this.close("timeout");return}this.startTimer()}}}finalizeDismiss(t){if(!this._isFinalized&&(this._isFinalized=!0,this.eventsAbortController.abort(),this.onDismissCallback&&this.onDismissCallback(this,t),this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.options.onClose))try{this.options.onClose(this,t)}catch(e){console.error("[Wulf.Toast] Erreur dans le callback onClose:",e)}}destroyImmediate(t="replace"){this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.disposeAbortController.abort(),this.finalizeDismiss(t)}close(t="programmatic",e=!1){return this._isClosed?this.closePromise??Promise.resolve():(this._isClosed=!0,this.timerId!==null&&(window.clearTimeout(this.timerId),this.timerId=null),this.eventsAbortController.abort(),this.element.classList.add(e?"wulf-toast-hiding-fast":"wulf-toast-hiding"),dt()?(this.finalizeDismiss(t),this.closePromise=Promise.resolve(),this.closePromise):(this.closePromise=St(this.element,e?90:300,this.disposeAbortController.signal).then(()=>{this.disposeAbortController.signal.aborted||this.finalizeDismiss(t)}),this.closePromise))}};var Me=new Set(["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"]);function ee(f){return f&&Me.has(f)?f:"top-right"}var Ee='button:not([disabled]), [href], [tabindex]:not([tabindex="-1"])',et=class f{static instance=null;containers=new Map;containerBaseLabels=new WeakMap;activeToasts=new Map;announcerEl=null;politeRegion=null;assertiveRegion=null;announceTimers=[];politeAnnounceTimerId=null;assertiveAnnounceTimerId=null;politeClearTimerId=null;assertiveClearTimerId=null;lastPoliteText="";lastAssertiveText="";announcerToggle=!1;isPopoverOpen(t){try{if(t.matches(":popover-open"))return!0}catch{}return t.classList.contains(":popover-open")}replaceTokens=new Map;pendingReplacements=new Set;constructor(){}static getInstance(){return f.instance||(f.instance=new f),f.instance}add(t){let e=ee(t.options.position),i=this.activeToasts.get(e);i||(i=[],this.activeToasts.set(e,i));let n=t.options.maxToasts,s=typeof n=="number"&&Number.isFinite(n)&&n>0?Math.min(50,Math.max(1,Math.floor(n))):5;if(t.options.replace&&i.length>0){let r=[...i],o=(this.replaceTokens.get(e)||0)+1;this.replaceTokens.set(e,o),this.pendingReplacements.add(e);let a=r.map(l=>l.close("replace",!0));Promise.all(a).then(()=>{if(this.pendingReplacements.delete(e),this.replaceTokens.get(e)!==o){t.destroyImmediate("replace");return}this.mountToast(t,e,s)});return}if(this.pendingReplacements.has(e)&&(this.replaceTokens.set(e,(this.replaceTokens.get(e)||0)+1),this.pendingReplacements.delete(e)),i.length>=s){let r=i.length-s+1,o=i.splice(0,r);for(let a of o)a.close("max-limit",!0)}this.mountToast(t,e,s)}mountToast(t,e,i=5){if(t.isClosed)return;let n=t.options.useTopLayer??!0,s=this.getOrCreateContainer(e,t,n),r=this.activeToasts.get(e);r||(r=[],this.activeToasts.set(e,r));let o=i+10;if(s.children.length>=o){let a=Array.from(s.children);for(let l of a){if(s.children.length<o)break;(l.classList.contains("wulf-toast-hiding")||l.classList.contains("wulf-toast-hiding-fast"))&&l.remove()}}if(n&&typeof s.showPopover=="function"&&s.getAttribute("popover")==="manual")try{let a=s;this.isPopoverOpen(s)||a.showPopover()}catch{s.removeAttribute("popover")}if(s.appendChild(t.element),r.push(t),this.announce(t),t.options.onOpen)try{t.options.onOpen(t)}catch(a){console.error("[Wulf.Toast] Erreur dans le callback onOpen:",a)}t.startTimer()}announce(t){let e=[t.options.title,t.options.message].filter(d=>typeof d=="string"&&d.trim().length>0).map(d=>z(d,512).trim()).filter(Boolean);if(e.length===0)return;let i=e.join(". "),n=i.length>512?`${i.slice(0,509)}...`:i,s=t.options.role==="alert",r=document;if(typeof r.ariaNotify=="function")try{r.ariaNotify(n,{priority:s?"high":"normal"});return}catch{}let o=!this.announcerEl||!this.announcerEl.isConnected;this.ensureAnnouncer();let a=s?this.assertiveRegion:this.politeRegion;if(!a)return;s?(this.assertiveAnnounceTimerId!==null&&(window.clearTimeout(this.assertiveAnnounceTimerId),this.assertiveAnnounceTimerId=null),this.assertiveClearTimerId!==null&&(window.clearTimeout(this.assertiveClearTimerId),this.assertiveClearTimerId=null)):(this.politeAnnounceTimerId!==null&&(window.clearTimeout(this.politeAnnounceTimerId),this.politeAnnounceTimerId=null),this.politeClearTimerId!==null&&(window.clearTimeout(this.politeClearTimerId),this.politeClearTimerId=null)),a.textContent="";let l=s?this.lastAssertiveText:this.lastPoliteText,u=n;n===l?(this.announcerToggle=!this.announcerToggle,u=this.announcerToggle?`${n}\xA0`:n):this.announcerToggle=!1,s?this.lastAssertiveText=n:this.lastPoliteText=n;let h=o?120:50,c=window.setTimeout(()=>{let d=this.announceTimers.indexOf(c);if(d!==-1&&this.announceTimers.splice(d,1),s?this.assertiveAnnounceTimerId=null:this.politeAnnounceTimerId=null,a.isConnected){a.textContent=u;let p=window.setTimeout(()=>{let m=this.announceTimers.indexOf(p);m!==-1&&this.announceTimers.splice(m,1),a.isConnected&&a.textContent===u&&(a.textContent="")},4e3);this.announceTimers.push(p),s?this.assertiveClearTimerId=p:this.politeClearTimerId=p}},h);this.announceTimers.push(c),s?this.assertiveAnnounceTimerId=c:this.politeAnnounceTimerId=c}ensureAnnouncer(){if(this.announcerEl&&document.body.contains(this.announcerEl))return;let t=document.createElement("div");t.className="wulf-toast-announcer",t.setAttribute("data-wulf-toast-announcer","true");let e=document.createElement("div");e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true");let i=document.createElement("div");i.setAttribute("role","alert"),i.setAttribute("aria-live","assertive"),i.setAttribute("aria-atomic","true"),t.appendChild(e),t.appendChild(i),document.body.appendChild(t),this.announcerEl=t,this.politeRegion=e,this.assertiveRegion=i}handleFocusHandoff(t,e){let i=D();if(!i||!t.element.contains(i))return;for(let s=e.length-1;s>=0;s--){let r=e[s];if(r===t||r.isClosed||!r.element.isConnected)continue;let o=r.element.querySelector(Ee);if(o){o.focus({preventScroll:!0});return}}let n=t.getPreviousActiveElement();if(n&&n.isConnected&&typeof n.focus=="function"&&!n.disabled&&!n.hidden&&!n.closest("[hidden]")&&!n.closest("[inert]")&&n.getAttribute("aria-hidden")!=="true"&&(n.tabIndex>=0||n.getAttribute("tabindex")!==null)){let s=n;if(typeof s.checkVisibility=="function"&&!s.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0,visibilityProperty:!0}))return;try{n.focus()}catch{}}}remove(t,e){let i=ee(t.options.position),n=this.activeToasts.get(i);if(n){let s=n.indexOf(t);if(s!==-1&&n.splice(s,1),this.handleFocusHandoff(t,n),t.element.parentNode&&t.element.parentNode.removeChild(t.element),n.length===0&&!this.pendingReplacements.has(i)){let r=this.containers.get(i);r&&(!r.firstChild||r.children.length===0)&&(this.disposeContainer(r),this.containers.delete(i),this.activeToasts.delete(i),this.syncContainerRegionLabels())}}else t.element.parentNode&&t.element.parentNode.removeChild(t.element)}disposeContainer(t){try{let e=t;typeof e.hidePopover=="function"&&this.isPopoverOpen(t)&&e.hidePopover()}catch{}t.parentNode&&t.parentNode.removeChild(t)}clearAll(t){let e=[];if(t){this.replaceTokens.set(t,(this.replaceTokens.get(t)||0)+1),this.pendingReplacements.delete(t);let i=this.activeToasts.get(t);if(i&&i.length>0){let n=[...i];for(let s of n)e.push(s.close("programmatic"))}else{let n=this.containers.get(t);n&&(!n.firstChild||n.children.length===0)&&(this.disposeContainer(n),this.containers.delete(t),this.activeToasts.delete(t),this.syncContainerRegionLabels())}}else{for(let n of this.replaceTokens.keys())this.replaceTokens.set(n,(this.replaceTokens.get(n)||0)+1);this.pendingReplacements.clear();for(let n of this.announceTimers)window.clearTimeout(n);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;let i=new Set([...Array.from(this.containers.keys()),...Array.from(this.activeToasts.keys())]);for(let n of i)e.push(this.clearAll(n))}return Promise.all(e).then(()=>{if(!t){for(let[i,n]of Array.from(this.containers.entries()))(!n.firstChild||n.children.length===0)&&(this.disposeContainer(n),this.containers.delete(i),this.activeToasts.delete(i));this.syncContainerRegionLabels()}})}destroy(){for(let t of this.announceTimers)window.clearTimeout(t);this.announceTimers=[],this.politeAnnounceTimerId=null,this.assertiveAnnounceTimerId=null,this.politeClearTimerId=null,this.assertiveClearTimerId=null;for(let t of Array.from(this.activeToasts.values()))for(let e of[...t])e.destroyImmediate("programmatic");for(let t of Array.from(this.containers.values()))this.disposeContainer(t);this.containers.clear(),this.activeToasts.clear(),this.replaceTokens.clear(),this.pendingReplacements.clear(),this.announcerEl&&(this.announcerEl.remove(),this.announcerEl=null,this.politeRegion=null,this.assertiveRegion=null),f.instance=null}syncContainerRegionLabels(){let t=this.containers.size>1;for(let[e,i]of this.containers.entries()){let n=this.containerBaseLabels.get(i)||G.t("notificationsRegion");i.setAttribute("aria-label",t?`${n} (${e})`:n)}}getOrCreateContainer(t,e,i){let n=this.containers.get(t);if(!n||!document.body.contains(n)){n=document.createElement("div"),n.className=`wulf-toast-container wulf-toast-${t}`,n.setAttribute("role","region");let s=G.t("notificationsRegion",e.options.i18n);this.containerBaseLabels.set(n,s),n.setAttribute("aria-label",s),i&&typeof n.showPopover=="function"&&n.setAttribute("popover","manual"),document.body.appendChild(n),this.containers.set(t,n),this.syncContainerRegionLabels()}return n}};var it=class extends H{static _i18n=G;static i18n=G;audit(){return[]}getAuditPrefix(){return"Wulf.Toast"}getAuditTargetLabel(){return"Toast"}static show(t={}){let e=et.getInstance(),i=new ct(t,(n,s)=>{e.remove(n,s)});return e.add(i),i}static clearAll(t){return et.getInstance().clearAll(t)}static destroy(){et.getInstance().destroy()}};var Ie=it,ie=V();ie&&(ie.Toast=Object.assign(it,{Toast:it,i18n:G}));var Yt={};at(Yt,{FocusTrap:()=>st,default:()=>st});var xe=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","button:not([disabled])","audio[controls]","video[controls]","details > summary:first-of-type","iframe","object","embed",'[contenteditable]:not([contenteditable="false"])','[tabindex]:not([tabindex="-1"])'].join(",");function Kt(f,t){if(!t||typeof t!="string")return null;try{return f.querySelector(t)}catch{return null}}var $=[],st=class extends B{element;options;active=!1;paused=!1;previousActiveElement=null;inertSiblings=[];addedContainerTabIndex=!1;lastOutsidePointerDownTime=0;abortController;handleKeyDownBound;handleClickOutsideBound;handleFocusInBound;constructor(t,e={}){super();let i=typeof t=="string"?Kt(document,t):t;if(!i||!(i instanceof HTMLElement))throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${t}"`);this.element=i;let n=e.allowOutsideClick??!1;this.options={initialFocus:e.initialFocus!==void 0?e.initialFocus:"[data-autofocus], [autofocus]",returnFocus:e.returnFocus??!0,fallbackReturnFocus:e.fallbackReturnFocus??"",escapeDeactivates:e.escapeDeactivates??!0,allowOutsideClick:n,setInert:e.setInert??!n,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)}isNativeDialogElement(){return this.element.tagName.toLowerCase()==="dialog"}isNativeModalDialog(){if(!this.isNativeDialogElement())return!1;try{return this.element.matches(":modal")}catch{return!1}}isElementVisibleAndEnabled(t){if(!t||!t.isConnected||t.disabled)return!1;try{if(t.matches(":disabled"))return!1}catch{if(t.closest("fieldset[disabled]"))return!1}if(t.hasAttribute("inert")||t.closest("[inert]")||t.hidden||t.closest("[hidden]"))return!1;let e=t;if(typeof e.checkVisibility=="function"){if(!e.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0,visibilityProperty:!0}))return!1}else{if(t.style.display==="none"||t.style.visibility==="hidden")return!1;let i=window.getComputedStyle(t);if(i.display==="none"||i.visibility==="hidden"||t.offsetWidth===0&&t.offsetHeight===0&&i.position!=="fixed")return!1}return!0}isElementFocusableBase(t){return!t||t.tabIndex<0?!1:this.isElementVisibleAndEnabled(t)}isProgrammaticallyFocusable(t){return!t||!this.isElementVisibleAndEnabled(t)?!1:t.tabIndex>=0||t.getAttribute("tabindex")!==null}isFocusable(t){if(!this.isElementFocusableBase(t))return!1;if(t instanceof HTMLInputElement&&t.type==="radio"&&t.name){let e=Array.from(this.element.querySelectorAll(`input[type="radio"][name="${lt(t.name)}"]`)).filter(n=>n.form===t.form&&this.isElementFocusableBase(n));if(e.length===0)return!1;let i=e.find(n=>n.checked);return i?t===i:t===e[0]}return!0}getFocusableElements(){return Array.from(this.element.querySelectorAll(xe)).filter(e=>this.isFocusable(e))}activate(){if(this.active)return this;let t=$[$.length-1];t&&t.pause(),this.active=!0,this.paused=!1,$.push(this);let e=D(document);this.previousActiveElement=e instanceof HTMLElement?e:document.activeElement,this.options.setInert&&!this.isNativeModalDialog()&&this.applyInert(),this.abortController?.abort(),this.abortController=new AbortController;let{signal:i}=this.abortController;document.addEventListener("keydown",this.handleKeyDownBound,{capture:!0,signal:i}),document.addEventListener("focusin",this.handleFocusInBound,{capture:!0,signal:i}),document.addEventListener("pointerdown",this.handleClickOutsideBound,{capture:!0,signal:i}),this.options.allowOutsideClick||(document.addEventListener("mousedown",this.handleClickOutsideBound,{capture:!0,signal:i}),document.addEventListener("touchstart",this.handleClickOutsideBound,{capture:!0,signal:i}),document.addEventListener("click",this.handleClickOutsideBound,{capture:!0,signal:i})),this.isNativeDialogElement()&&this.element.addEventListener("close",()=>this.deactivate(),{signal:i}),this.applyInitialFocus(),this.runAuditWarning(this.options.audit);try{this.options.onActivate()}catch(n){console.error("[Wulf.FocusTrap] Erreur dans onActivate:",n)}return this}deactivate(){if(!this.active)return this;let t=$[$.length-1]===this;this.active=!1,this.paused=!1;let e=$.indexOf(this);if(e!==-1&&$.splice(e,1),this.abortController?.abort(),this.abortController=void 0,this.removeInert(),this.addedContainerTabIndex&&(this.element.removeAttribute("tabindex"),this.addedContainerTabIndex=!1),t){let i=$[$.length-1];i&&i.unpause(),this.options.returnFocus&&this.restoreFocus()}this.previousActiveElement=null;try{this.options.onDeactivate()}catch(i){console.error("[Wulf.FocusTrap] Erreur dans onDeactivate:",i)}return this}pause(){this.paused=!0,this.removeInert()}unpause(){this.active&&$[$.length-1]===this&&(this.paused=!1,this.options.setInert&&!this.isNativeModalDialog()&&this.applyInert())}isActive(){return this.active&&!this.paused}audit(){let t=[],e=this.element.getAttribute("role");this.isNativeDialogElement()?(e==="dialog"&&t.push('Attribut redondant : role="dialog" est d\xE9j\xE0 implicite sur une balise native <dialog>.'),this.element.hasAttribute("aria-modal")&&t.push('Attribut redondant : <dialog> ouvert via showModal() g\xE8re nativement la modalit\xE9 sans n\xE9cessiter aria-modal="true".'),this.element.hasAttribute("open")&&!this.isNativeModalDialog()&&t.push("Dialogue non modal d\xE9tect\xE9 : pr\xE9f\xE9rez dialog.showModal() plut\xF4t que l'attribut open pour obtenir la Top Layer et l'inertie natives.")):((!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.'),(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 s=this.element.getAttribute("aria-label")?.trim(),r=this.checkAriaIdReferences(this.element,"aria-labelledby",t,!0);!s&&!r&&t.push('Nom accessible manquant : d\xE9finissez aria-labelledby="id-titre" ou aria-label="..." sur le conteneur (WCAG 4.1.2).'),this.element.hasAttribute("aria-describedby")&&this.checkAriaIdReferences(this.element,"aria-describedby",t,!0);let o=Array.from(this.element.querySelectorAll("[tabindex]")).filter(a=>a.tabIndex>0);return o.length>0&&t.push(`${o.length} \xE9l\xE9ment(s) avec tabindex > 0 d\xE9tect\xE9(s) : utilisez uniquement tabindex="0" ou "-1" pour pr\xE9server l'ordre s\xE9quentiel de tabulation (WCAG 2.4.3).`),t}getAuditPrefix(){return"Wulf.FocusTrap"}getAuditTargetLabel(){return this.element.id?`#${this.element.id}`:`<${this.element.tagName.toLowerCase()}>`}destroy(){this.deactivate()}isEventInside(t,e){return!!(e&&this.element.contains(e)||typeof t.composedPath=="function"&&t.composedPath().includes(this.element))}isInsideToastContainer(t){if(!t||!(t instanceof Element))return!1;let e=t.closest(".wulf-toast-container");return!!(e&&e.parentElement===document.body&&!this.element.contains(e))}ensureContainerTabIndex(){this.element.getAttribute("tabindex")===null&&(this.element.setAttribute("tabindex","-1"),this.addedContainerTabIndex=!0)}handleKeyDown(t){if(!this.isActive())return;if(this.element.isConnected===!1){this.deactivate();return}if(t.key==="Escape"&&this.options.escapeDeactivates){if(t.defaultPrevented||t.ctrlKey||t.altKey||t.metaKey||t.shiftKey||R(t))return;let a=D(document);if(this.isInsideToastContainer(a)||this.isInsideToastContainer(t.target)||this.isNativeModalDialog())return;t.preventDefault(),t.stopPropagation(),this.deactivate();return}if(t.key!=="Tab")return;let e=this.getFocusableElements();if(e.length===0){t.preventDefault(),this.ensureContainerTabIndex(),this.element.focus();return}let i=e[0],n=e[e.length-1],s=D(document),r=s instanceof HTMLElement?s:document.activeElement,o=r?this.element.contains(r)||this.isEventInside(t,r):!1;!t.shiftKey&&(r===n||!o)?(t.preventDefault(),i.focus()):t.shiftKey&&(r===i||r===this.element||!o)&&(t.preventDefault(),n.focus())}handleFocusIn(t){if(!this.isActive())return;if(this.element.isConnected===!1){this.deactivate();return}let e=t.target;if(e&&!this.isInsideToastContainer(e)&&!(this.options.allowOutsideClick&&performance.now()-this.lastOutsidePointerDownTime<150)&&!this.isEventInside(t,e)){let i=this.getFocusableElements();i.length>0?i[0].focus():(this.ensureContainerTabIndex(),this.element.focus())}}handleClickOutside(t){if(!this.isActive())return;if(this.element.isConnected===!1){this.deactivate();return}let e=t.target;if(e&&!this.isEventInside(t,e)){if(this.isInsideToastContainer(e))return;if(this.options.allowOutsideClick){this.lastOutsidePointerDownTime=performance.now();return}t.preventDefault(),t.stopPropagation()}}applyInert(){this.removeInert();let t=this.element,e=new Set(["SCRIPT","STYLE","TEMPLATE","LINK","META","NOSCRIPT"]);for(;t&&t!==document.body;){let i=t.parentElement;if(i){for(let n of Array.from(i.children))n instanceof HTMLElement&&n!==t&&!e.has(n.tagName)&&!n.hasAttribute("inert")&&!(i===document.body&&n.matches(".wulf-toast-container, .wulf-toast-announcer"))&&(n.setAttribute("inert",""),this.inertSiblings.push(n));t=i}else{let n=typeof t.getRootNode=="function"?t.getRootNode():null;if(typeof ShadowRoot<"u"&&n instanceof ShadowRoot){for(let s of Array.from(n.children))s instanceof HTMLElement&&s!==t&&!e.has(s.tagName)&&!s.hasAttribute("inert")&&(s.setAttribute("inert",""),this.inertSiblings.push(s));t=n.host instanceof HTMLElement?n.host:null}else break}}}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=Kt(this.element,this.options.initialFocus):this.options.initialFocus instanceof HTMLElement&&(t=this.element.contains(this.options.initialFocus)?this.options.initialFocus:null),t&&(t instanceof HTMLInputElement&&t.type==="radio"&&!!t.name&&t.tabIndex>=0?this.isFocusable(t):this.isProgrammaticallyFocusable(t))){t.focus();return}let e=this.getFocusableElements();e.length>0?e[0].focus():(this.ensureContainerTabIndex(),this.element.focus())}restoreFocus(){if(this.previousActiveElement&&this.previousActiveElement.isConnected&&this.isProgrammaticallyFocusable(this.previousActiveElement)){this.previousActiveElement.focus();return}if(this.options.fallbackReturnFocus){let t=typeof this.options.fallbackReturnFocus=="string"?Kt(document,this.options.fallbackReturnFocus):this.options.fallbackReturnFocus;t&&t.isConnected&&this.isProgrammaticallyFocusable(t)&&t.focus()}}};var se=V();se&&(se.FocusTrap=Object.assign(st,{FocusTrap:st}));var Gt={};at(Gt,{ShortcutFormatter:()=>F,ShortcutManager:()=>_,default:()=>_});var F=class f{static isApple(){if(typeof navigator>"u")return!1;let t=navigator.userAgentData;if(t&&typeof t.platform=="string"){let n=t.platform.toLowerCase();if(n.includes("mac")||n.includes("ios"))return!0}let e=(navigator.platform||"").toLowerCase();if(e.includes("mac")||e.includes("iphone")||e.includes("ipad")||e.includes("ipod"))return!0;let i=(navigator.userAgent||"").toLowerCase();return i.includes("macintosh")||i.includes("mac os x")||i.includes("ipad")||i.includes("iphone")}static normalizeKeyName(t){if(t===" ")return" ";let e=t.trim().toLowerCase();switch(e){case"esc":return"escape";case"return":return"enter";case"space":case"spacebar":return" ";case"plus":return"+";case"del":return"delete";case"ins":return"insert";case"up":return"arrowup";case"down":return"arrowdown";case"left":return"arrowleft";case"right":return"arrowright";default:return e}}static parseCombo(t,e=f.isApple()){if(typeof t!="string")return[];if(t===" ")return[{ctrl:!1,alt:!1,shift:!1,meta:!1,key:" "}];let i=t.slice(0,512).trim();if(!i)return[];let s=i.replace(/\b(ctrl|control|alt|option|opt|shift|maj|cmd|command|meta|win|super|mod|\$mod)\s*\+\s*/gi,"$1+").split(/\s+/).slice(0,10),r=[];for(let o of s){let a=[];if(o==="+")a.push("+");else{let p="";for(let m=0;m<o.length;m++){let g=o[m];g==="+"?p===""&&a.length>0?a.push("+"):p!==""&&(a.push(p),p=""):p+=g}p!==""&&a.push(p)}let l=!1,u=!1,h=!1,c=!1,d="";for(let p of a){let m=p.trim().toLowerCase();m==="ctrl"||m==="control"?l=!0:m==="alt"||m==="option"||m==="opt"?u=!0:m==="shift"||m==="maj"?h=!0:m==="cmd"||m==="command"||m==="meta"||m==="win"||m==="super"?c=!0:m==="mod"||m==="$mod"?e?c=!0:l=!0:d=f.normalizeKeyName(p)}r.push({ctrl:l,alt:u,shift:h,meta:c,key:d})}return r}static format(t,e=f.isApple()){let i=f.parseCombo(t,e);return i.length===0?t:i.map(s=>{let r=[];if(e){s.ctrl&&r.push("\u2303"),s.alt&&r.push("\u2325"),s.shift&&r.push("\u21E7"),s.meta&&r.push("\u2318");let o=f.formatKeyDisplay(s.key,!0);return r.push(o),r.join("")}else{s.ctrl&&r.push("Ctrl"),s.alt&&r.push("Alt"),s.shift&&r.push("Shift"),s.meta&&r.push("Win");let o=f.formatKeyDisplay(s.key,!1);return r.push(o),r.join("+")}}).join(" ")}static toAriaKeyShortcuts(t,e=f.isApple()){let i=f.parseCombo(t,e);if(i.length!==1)return"";let n=i[0],s=f.formatAriaKey(n.key);if(!s)return"";let r=[];return n.ctrl&&r.push("Control"),n.alt&&r.push("Alt"),n.shift&&r.push("Shift"),n.meta&&r.push("Meta"),r.push(s),r.join("+")}static formatAriaKey(t){if(!t)return"";switch(t.toLowerCase()){case"escape":return"Escape";case"enter":return"Enter";case" ":return"Space";case"tab":return"Tab";case"backspace":return"Backspace";case"delete":return"Delete";case"insert":return"Insert";case"home":return"Home";case"end":return"End";case"pageup":return"PageUp";case"pagedown":return"PageDown";case"arrowup":return"ArrowUp";case"arrowdown":return"ArrowDown";case"arrowleft":return"ArrowLeft";case"arrowright":return"ArrowRight";case"printscreen":return"PrintScreen";case"scrolllock":return"ScrollLock";case"numlock":return"NumLock";case"capslock":return"CapsLock";case"contextmenu":return"ContextMenu";case"+":return"Plus";default:return t.length===1?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)}}static formatKeyDisplay(t,e){if(!t)return"";switch(t.toLowerCase()){case"escape":return e?"\u238B":"Esc";case"enter":return e?"\u21A9":"Enter";case" ":return e?"\u2423":"Space";case"tab":return e?"\u21E5":"Tab";case"backspace":return e?"\u232B":"Backspace";case"delete":return e?"\u2326":"Delete";case"arrowup":return"\u2191";case"arrowdown":return"\u2193";case"arrowleft":return"\u2190";case"arrowright":return"\u2192";default:return t.length===1?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1)}}};var Le=new Set(["current-password","new-password","one-time-code","cc-number","cc-csc"]),_=class f extends B{options;shortcuts=new Map;scopeStack=[];sequenceBuffer=[];sequenceTimer=null;isListening=!0;boundListener=null;abortController=null;idCounter=0;constructor(t){super();let e=t?.sequenceTimeout,i=typeof e=="number"&&Number.isFinite(e)&&e>0?Math.min(e,1e4):800;this.options={defaultScope:t?.defaultScope||"global",sequenceTimeout:i,target:t?.target||(typeof window<"u"?window:{}),onError:t?.onError},this.scopeStack=[this.options.defaultScope],this.initListener()}static isEditable(t){if(!t||typeof t.tagName!="string")return!1;let e=t,i=e.tagName.toUpperCase();if(i==="INPUT"){let r=e.type?.toLowerCase()||"text";return!["button","checkbox","radio","submit","reset","range","color","file","image"].includes(r)}if(i==="TEXTAREA"||i==="SELECT")return!0;let n=e.getAttribute?.("contenteditable")?.toLowerCase();if(e.isContentEditable||n==="true"||n==="plaintext-only"||n==="")return!0;let s=e.getAttribute?.("role");return!!(s==="textbox"||s==="searchbox"||s==="combobox"||s==="spinbutton"||typeof e.closest=="function"&&e.closest('[contenteditable="true"], [contenteditable="plaintext-only"], [contenteditable=""], [role="textbox"], [role="searchbox"], [role="combobox"], [role="spinbutton"]'))}static isTypeaheadWidget(t){if(!t||typeof t.tagName!="string")return!1;let e=t,i=e.getAttribute?.("role");return i==="listbox"||i==="menu"||i==="menubar"||i==="tree"||i==="grid"?!0:typeof e.closest=="function"?!!e.closest('[role="listbox"], [role="menu"], [role="menubar"], [role="tree"], [role="grid"]'):!1}static isSensitiveField(t){if(!t||typeof t.tagName!="string")return!1;let e=t;if(e.tagName.toUpperCase()==="INPUT"&&(e.type||"").toLowerCase()==="password")return!0;let i=e.getAttribute?.("data-mask-sensitive");if(i!=null&&i!=="false")return!0;let n=e.getAttribute?.("autocomplete");return!!(n&&n.trim().toLowerCase().split(/\s+/).some(r=>Le.has(r)))}bind(t){let e=Array.isArray(t)?t:[t],i=[];for(let n of e){if(!n.combo||typeof n.handler!="function")continue;let s=F.parseCombo(n.combo);if(s.length===0||s.some(u=>!u.key))continue;let r=`wulf_shortcut_${++this.idCounter}`,o=s.length>1,a=F.format(n.combo),l={...n,id:r,scope:n.scope||"global",category:n.category||"G\xE9n\xE9ral",allowInEditable:n.allowInEditable??!1,preventDefault:n.preventDefault??!0,stopPropagation:n.stopPropagation??!0,priority:n.priority??0,formattedCombo:a,normalizedSteps:s,isSequence:o};this.shortcuts.set(r,l),i.push(r)}return()=>{for(let n of i)this.shortcuts.delete(n)}}unbind(t,e){if(typeof t!="string"||!t.trim())return;let i=F.format(t);for(let[n,s]of this.shortcuts.entries())(s.formattedCombo===i||s.combo.trim().toLowerCase()===t.trim().toLowerCase())&&(!e||s.scope===e)&&this.shortcuts.delete(n)}pushScope(t){if(t&&typeof t=="string"){if(this.scopeStack.length>=64)return;this.scopeStack.push(t),this.clearSequenceBuffer()}}popScope(t){if(this.scopeStack.length<=1)return this.scopeStack[0];if(t){if(this.getScope()===t){let i=this.scopeStack.pop();return this.clearSequenceBuffer(),i}return}let e=this.scopeStack.pop();return this.clearSequenceBuffer(),e}setScope(t){this.scopeStack=[t||this.options.defaultScope],this.clearSequenceBuffer()}getScope(){return this.scopeStack[this.scopeStack.length-1]||this.options.defaultScope}getScopeStack(){return[...this.scopeStack]}pause(){this.isListening=!1,this.clearSequenceBuffer()}resume(){this.isListening=!0}isActive(){return this.isListening}getRegistry(t){let e=[];for(let i of this.shortcuts.values())(!t||i.scope===t||i.scope==="*")&&e.push({...i,normalizedSteps:i.normalizedSteps.map(n=>({...n}))});return e}audit(){let t=[],e=new Set(["c","v","x","a","z"]);for(let i of this.shortcuts.values())if(i.normalizedSteps.length>0&&i.normalizedSteps.every(s=>!s.ctrl&&!s.alt&&!s.meta&&s.key.length===1)&&t.push(`Raccourci mono-caract\xE8re sans modificateur "${i.combo}" : pr\xE9voyez une option pour le d\xE9sactiver ou le reconfigurer (WCAG 2.1.4).`),i.allowInEditable&&!i.isSequence&&i.normalizedSteps.length===1){let s=i.normalizedSteps[0];!s.alt&&!s.shift&&(s.ctrl&&!s.meta||s.meta&&!s.ctrl)&&e.has(s.key)&&t.push(`Raccourci "${i.combo}" avec allowInEditable: true risque d'\xE9craser une commande d'\xE9dition native (Ctrl/Cmd+${s.key.toUpperCase()}).`)}return t}getAuditPrefix(){return"Wulf.Shortcut"}getAuditTargetLabel(){return`${this.shortcuts.size} raccourci(s)`}attachAria(t,e){if(t&&typeof t.setAttribute=="function"){let i=F.toAriaKeyShortcuts(e);i?t.setAttribute("aria-keyshortcuts",i):typeof t.removeAttribute=="function"&&t.removeAttribute("aria-keyshortcuts")}}static format(t,e){return F.format(t,e)}destroy(){this.pause(),this.removeListener(),this.shortcuts.clear(),this.scopeStack=[],this.clearSequenceBuffer()}initListener(){if(typeof window>"u"||!this.options.target)return;this.abortController=new AbortController,this.boundListener=e=>this.handleKeyDown(e);let t=this.options.target;typeof t.addEventListener=="function"&&t.addEventListener("keydown",this.boundListener,{capture:!1,signal:this.abortController.signal})}removeListener(){if(this.abortController)this.abortController.abort(),this.abortController=null;else if(this.boundListener&&this.options.target){let t=this.options.target;typeof t.removeEventListener=="function"&&t.removeEventListener("keydown",this.boundListener,!1)}this.boundListener=null}handleKeyDown(t){if(!this.isListening||R(t))return;let e=(t.key||"").toLowerCase();if(["control","alt","shift","meta"].includes(e))return;let i=this.getScope(),n=typeof t.composedPath=="function"?t.composedPath():[],s=n.length>0?n:t.target?[t.target]:[],r=f.isEditable(t.target),o=f.isSensitiveField(t.target),a=f.isTypeaheadWidget(t.target);for(let m of s)!r&&f.isEditable(m)&&(r=!0),!o&&f.isSensitiveField(m)&&(o=!0),!a&&f.isTypeaheadWidget(m)&&(a=!0);let l={ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey,meta:t.metaKey,key:F.normalizeKeyName(t.key||"")},u=typeof performance<"u"?performance.now():Date.now();if(this.sequenceBuffer.length>0){let m=this.sequenceBuffer[this.sequenceBuffer.length-1];u-m.timestamp>this.options.sequenceTimeout&&this.clearSequenceBuffer()}let h=this.getActiveShortcuts(i,r,o,a),c=[...this.sequenceBuffer.map(m=>m.step),l],d=this.findMatchingSequence(h,c);if(d){this.clearSequenceBuffer(),this.executeShortcut(d,t,i,!0);return}if(this.isPrefixOfAnySequence(h,c)){this.sequenceBuffer.push({step:l,timestamp:u}),this.resetSequenceTimer(),t.key.length===1&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!r&&!a&&t.preventDefault();return}this.clearSequenceBuffer();let p=this.findMatchingChord(h,l,t);p&&this.executeShortcut(p,t,i,!1)}getActiveShortcuts(t,e,i=!1,n=!1){let s=[];for(let r of this.shortcuts.values())if(!(r.scope!==t&&r.scope!=="*")&&!(e&&!r.allowInEditable)){if(n){let o=r.normalizedSteps[0];if(o&&!o.ctrl&&!o.alt&&!o.meta&&o.key.length===1)continue}if(i){if(r.isSequence)continue;let o=r.normalizedSteps[0];if(o){if(o.key.length===1){let a=!o.ctrl&&!o.alt&&!o.meta,l=o.ctrl&&o.alt&&!o.meta||o.alt&&!o.ctrl&&!o.meta;if(a||l)continue}else if(!o.ctrl&&!o.alt&&!o.meta&&(o.key==="backspace"||o.key==="delete"||o.key==="dead"))continue}}s.push(r)}return s.sort((r,o)=>(o.priority??0)-(r.priority??0))}stepMatches(t,e,i){if(t.ctrl!==e.ctrl||t.alt!==e.alt||t.meta!==e.meta)return!1;let n=typeof i?.key=="string"?i.key:"";if(!(t.key===e.key||n!==""&&t.key===n.toLowerCase()))return!1;if(t.shift===e.shift)return!0;if(!t.shift&&e.shift){let r=t.key.length===1&&!/^[a-z]$/i.test(t.key);if(n!==""&&n===t.key||r&&e.key===t.key)return!0}return!1}findMatchingChord(t,e,i){for(let n of t){if(n.isSequence||n.normalizedSteps.length!==1)continue;let s=n.normalizedSteps[0];if(this.stepMatches(s,e,i))return n}return null}findMatchingSequence(t,e){for(let i of t){if(!i.isSequence||i.normalizedSteps.length!==e.length)continue;let n=!0;for(let s=0;s<e.length;s++)if(!this.stepMatches(i.normalizedSteps[s],e[s])){n=!1;break}if(n)return i}return null}isPrefixOfAnySequence(t,e){for(let i of t){if(!i.isSequence||i.normalizedSteps.length<=e.length)continue;let n=!0;for(let s=0;s<e.length;s++)if(!this.stepMatches(i.normalizedSteps[s],e[s])){n=!1;break}if(n)return!0}return!1}executeShortcut(t,e,i,n){t.preventDefault&&e.preventDefault(),t.stopPropagation&&e.stopPropagation();let s={combo:t.combo,formattedCombo:t.formattedCombo,scope:i,target:e.target,isSequence:n};try{t.handler(e,s)}catch(r){if(this.options.onError)try{this.options.onError(r instanceof Error?r:new Error(String(r)),t.combo)}catch(o){console.error("[Wulf.Shortcut] Erreur dans le callback onError:",o)}else console.error(`[Wulf.Shortcut] Erreur lors de l'ex\xE9cution du raccourci "${t.combo}":`,r)}}resetSequenceTimer(){this.sequenceTimer&&clearTimeout(this.sequenceTimer),this.sequenceTimer=setTimeout(()=>{this.clearSequenceBuffer()},this.options.sequenceTimeout)}clearSequenceBuffer(){this.sequenceBuffer=[],this.sequenceTimer&&(clearTimeout(this.sequenceTimer),this.sequenceTimer=null)}};var ne=V();ne&&(ne.Shortcut=Object.assign(_,{ShortcutManager:_,ShortcutFormatter:F}));return ue(De);})();
5
5
  if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; } if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { for (var k in __WulfIIFE) { if (Object.hasOwn(__WulfIIFE, k) && k !== "__proto__" && k !== "constructor" && k !== "prototype" && __w[k] === undefined) { try { Object.defineProperty(__w, k, { value: __WulfIIFE[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { __w[k] = __WulfIIFE[k]; } catch (__) {} } } } } }
6
6
  //# sourceMappingURL=index.global.min.js.map