function m(n){n.directive("mask",(e,{value:t,expression:o},{effect:s,evaluateLater:f,cleanup:l})=>{let r=()=>o,i="";queueMicrotask(()=>{if(["function","dynamic"].includes(t)){let u=f(o);s(()=>{r=g=>{let d;return n.dontAutoEvaluateFunctions(()=>{u(c=>{d=typeof c=="function"?c(g):c},{scope:{$input:g,$money:k.bind({el:e})}})}),d},a(e,!1)})}else a(e,!1);if(e._x_model){if(e._x_model.get()===e.value||e._x_model.get()===null&&e.value==="")return;e._x_model.set(e.value)}});const h=new AbortController;l(()=>{h.abort()}),e.addEventListener("input",()=>a(e),{signal:h.signal,capture:!0}),e.addEventListener("blur",()=>a(e,!1),{signal:h.signal});function a(u,g=!0){let d=u.value,c=r(d);if(!c||c==="false")return!1;if(i.length-u.value.length===1)return i=u.value;let v=()=>{i=u.value=p(d,c)};g?I(u,c,()=>{v()}):v()}function p(u,g){if(u==="")return"";let d=b(g,u);return _(g,d)}}).before("model")}function I(n,e,t){let o=n.selectionStart,s=n.value;t();let f=s.slice(0,o),l=_(e,b(e,f)).length;n.setSelectionRange(l,l)}function b(n,e){let t=e,o="",s={9:/[0-9]/,a:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},f="";for(let l=0;l<n.length;l++){if(["9","a","*"].includes(n[l])){f+=n[l];continue}for(let r=0;r<t.length;r++)if(t[r]===n[l]){t=t.slice(0,r)+t.slice(r+1);break}}for(let l=0;l<f.length;l++){let r=!1;for(let i=0;i<t.length;i++)if(s[f[l]].test(t[i])){o+=t[i],t=t.slice(0,i)+t.slice(i+1),r=!0;break}if(!r)break}return o}function _(n,e){let t=Array.from(e),o="";for(let s=0;s<n.length;s++){if(!["9","a","*"].includes(n[s])){o+=n[s];continue}if(t.length===0)break;o+=t.shift()}return o}function k(n,e=".",t,o=2){if(n==="-")return"-";if(/^\D+$/.test(n))return"9";t==null&&(t=e===","?".":",");let s=(i,h)=>{let a="",p=0;for(let u=i.length-1;u>=0;u--)i[u]!==h&&(p===3?(a=i[u]+h+a,p=0):a=i[u]+a,p++);return a},f=n.startsWith("-")?"-":"",l=n.replaceAll(new RegExp(`[^0-9\\${e}]`,"g"),""),r=Array.from({length:l.split(e)[0].length}).fill("9").join("");return r=`${f}${s(r,t)}`,o>0&&n.includes(e)&&(r+=`${e}`+"9".repeat(o)),queueMicrotask(()=>{this.el.value.endsWith(e)||this.el.value[this.el.selectionStart-1]===e&&this.el.setSelectionRange(this.el.selectionStart-1,this.el.selectionStart-1)}),r}var S=m;export{S as m,m as s};
