import{l as W,aa as x,ab as j,k as J,E as A,P as R,V as w,Q as S,O as U,a2 as B,ac as z,u as V,G as q,U as D}from"./DEIzhR9A.js";/*! maska v2.1.11 | (c) Alexander Shabunevich | Released under the MIT license */var $=Object.defineProperty,I=(a,t,e)=>t in a?$(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,g=(a,t,e)=>(I(a,typeof t!="symbol"?t+"":t,e),e);const O={"#":{pattern:/[0-9]/},"@":{pattern:/[a-zA-Z]/},"*":{pattern:/[a-zA-Z0-9]/}};class T{constructor(t={}){g(this,"opts",{}),g(this,"memo",new Map);const e={...t};if(e.tokens!=null){e.tokens=e.tokensReplace?{...e.tokens}:{...O,...e.tokens};for(const s of Object.values(e.tokens))typeof s.pattern=="string"&&(s.pattern=new RegExp(s.pattern))}else e.tokens=O;Array.isArray(e.mask)&&(e.mask.length>1?e.mask=[...e.mask].sort((s,n)=>s.length-n.length):e.mask=e.mask[0]??""),e.mask===""&&(e.mask=null),this.opts=e}masked(t){return this.process(t,this.findMask(t))}unmasked(t){return this.process(t,this.findMask(t),!1)}isEager(){return this.opts.eager===!0}isReversed(){return this.opts.reversed===!0}completed(t){const e=this.findMask(t);if(this.opts.mask==null||e==null)return!1;const s=this.process(t,e).length;return typeof this.opts.mask=="string"?s>=this.opts.mask.length:typeof this.opts.mask=="function"?s>=e.length:this.opts.mask.filter(n=>s>=n.length).length===this.opts.mask.length}findMask(t){const e=this.opts.mask;if(e==null)return null;if(typeof e=="string")return e;if(typeof e=="function")return e(t);const s=this.process(t,e.slice(-1).pop()??"",!1);return e.find(n=>this.process(t,n,!1).length>=s.length)??""}escapeMask(t){const e=[],s=[];return t.split("").forEach((n,i)=>{n==="!"&&t[i-1]!=="!"?s.push(i-s.length):e.push(n)}),{mask:e.join(""),escaped:s}}process(t,e,s=!0){if(e==null)return t;const n=`value=${t},mask=${e},masked=${s?1:0}`;if(this.memo.has(n))return this.memo.get(n);const{mask:i,escaped:u}=this.escapeMask(e),o=[],d=this.opts.tokens!=null?this.opts.tokens:{},l=this.isReversed()?-1:1,k=this.isReversed()?"unshift":"push",c=this.isReversed()?0:i.length-1,L=this.isReversed()?()=>r>-1&&p>-1:()=>r<i.length&&p<t.length,N=m=>!this.isReversed()&&m<=c||this.isReversed()&&m>=c;let y,f=-1,r=this.isReversed()?i.length-1:0,p=this.isReversed()?t.length-1:0,E=!1;for(;L();){const m=i.charAt(r),h=d[m],v=(h==null?void 0:h.transform)!=null?h.transform(t.charAt(p)):t.charAt(p);if(!u.includes(r)&&h!=null?(v.match(h.pattern)!=null?(o[k](v),h.repeated?(f===-1?f=r:r===c&&r!==f&&(r=f-l),c===f&&(r-=l)):h.multiple&&(E=!0,r-=l),r+=l):h.multiple?E&&(r+=l,p-=l,E=!1):v===y?y=void 0:h.optional&&(r+=l,p-=l),p+=l):(s&&!this.isEager()&&o[k](m),v===m&&!this.isEager()?p+=l:y=m,this.isEager()||(r+=l)),this.isEager())for(;N(r)&&(d[i.charAt(r)]==null||u.includes(r));)s?o[k](i.charAt(r)):i.charAt(r)===t.charAt(p)&&(p+=l),r+=l}return this.memo.set(n,o.join("")),this.memo.get(n)}}const C=a=>JSON.parse(a.replaceAll("'",'"')),P=(a,t={})=>{const e={...t};return a.dataset.maska!=null&&a.dataset.maska!==""&&(e.mask=Z(a.dataset.maska)),a.dataset.maskaEager!=null&&(e.eager=M(a.dataset.maskaEager)),a.dataset.maskaReversed!=null&&(e.reversed=M(a.dataset.maskaReversed)),a.dataset.maskaTokensReplace!=null&&(e.tokensReplace=M(a.dataset.maskaTokensReplace)),a.dataset.maskaTokens!=null&&(e.tokens=G(a.dataset.maskaTokens)),e},M=a=>a!==""?!!JSON.parse(a):!0,Z=a=>a.startsWith("[")&&a.endsWith("]")?C(a):a,G=a=>{if(a.startsWith("{")&&a.endsWith("}"))return C(a);const t={};return a.split("|").forEach(e=>{const s=e.split(":");t[s[0]]={pattern:new RegExp(s[1]),optional:s[2]==="optional",multiple:s[2]==="multiple",repeated:s[2]==="repeated"}}),t};class H{constructor(t,e={}){g(this,"items",new Map),g(this,"beforeinputEvent",s=>{const n=s.target,i=this.items.get(n);i.isEager()&&"inputType"in s&&s.inputType.startsWith("delete")&&i.unmasked(n.value).length<=1&&this.setMaskedValue(n,"")}),g(this,"inputEvent",s=>{if(s instanceof CustomEvent&&s.type==="input"&&s.detail!=null&&typeof s.detail=="object"&&"masked"in s.detail)return;const n=s.target,i=this.items.get(n),u=n.value,o=n.selectionStart,d=n.selectionEnd;let l=u;if(i.isEager()){const k=i.masked(u),c=i.unmasked(u);c===""&&"data"in s&&s.data!=null?l=s.data:c!==i.unmasked(k)&&(l=c)}if(this.setMaskedValue(n,l),"inputType"in s&&(s.inputType.startsWith("delete")||o!=null&&o<u.length))try{n.setSelectionRange(o,d)}catch{}}),this.options=e,typeof t=="string"?this.init(Array.from(document.querySelectorAll(t)),this.getMaskOpts(e)):this.init("length"in t?Array.from(t):[t],this.getMaskOpts(e))}destroy(){for(const t of this.items.keys())t.removeEventListener("input",this.inputEvent),t.removeEventListener("beforeinput",this.beforeinputEvent);this.items.clear()}needUpdateOptions(t,e){const s=this.items.get(t),n=new T(P(t,this.getMaskOpts(e)));return JSON.stringify(s.opts)!==JSON.stringify(n.opts)}needUpdateValue(t){const e=t.dataset.maskaValue;return e==null&&t.value!==""||e!=null&&e!==t.value}getMaskOpts(t){const{onMaska:e,preProcess:s,postProcess:n,...i}=t;return i}init(t,e){for(const s of t){const n=new T(P(s,e));this.items.set(s,n),s.value!==""&&this.setMaskedValue(s,s.value),s.addEventListener("input",this.inputEvent),s.addEventListener("beforeinput",this.beforeinputEvent)}}setMaskedValue(t,e){const s=this.items.get(t);this.options.preProcess!=null&&(e=this.options.preProcess(e));const n=s.masked(e),i=s.unmasked(s.isEager()?n:e),u=s.completed(e),o={masked:n,unmasked:i,completed:u};e=n,this.options.postProcess!=null&&(e=this.options.postProcess(e)),t.value=e,t.dataset.maskaValue=e,this.options.onMaska!=null&&(Array.isArray(this.options.onMaska)?this.options.onMaska.forEach(d=>d(o)):this.options.onMaska(o)),t.dispatchEvent(new CustomEvent("maska",{detail:o})),t.dispatchEvent(new CustomEvent("input",{detail:o}))}}const b=new WeakMap,Q=a=>{setTimeout(()=>{var t;((t=b.get(a))==null?void 0:t.needUpdateValue(a))===!0&&a.dispatchEvent(new CustomEvent("input"))})},F=(a,t)=>{const e=a instanceof HTMLInputElement?a:a.querySelector("input"),s={...t.arg};if(e==null||(e==null?void 0:e.type)==="file")return;Q(e);const n=b.get(e);if(n!=null){if(!n.needUpdateOptions(e,s))return;n.destroy()}if(t.value!=null){const i=t.value,u=o=>{i.masked=o.masked,i.unmasked=o.unmasked,i.completed=o.completed};s.onMaska=s.onMaska==null?u:Array.isArray(s.onMaska)?[...s.onMaska,u]:[s.onMaska,u]}b.set(e,new H(e,s))},K={class:"relative cursor-text"},X=["id","data-maska","placeholder","maxlength"],Y={key:0,class:"mt-1 text-xs"},ee=W({__name:"TextInput",props:x({type:{type:String,default:"text"},label:{type:String,required:!0},placeholder:{type:String,default:void 0},mask:{type:[String,Array],default:""},readonly:{type:Boolean,default:void 0},maxLength:{type:Number,default:void 0},hint:{type:String,default:""},hasErrors:{type:Boolean,default:!1},autocomplete:{type:String,default:"off"}},{modelValue:{},modelModifiers:{}}),emits:x(["change"],["update:modelValue"]),setup(a,{emit:t}){const e=a,s=t,n=j(a,"modelValue"),i=J(()=>Array.isArray(e.mask)?JSON.stringify(e.mask):e.mask);return(u,o)=>(A(),R("div",K,[w("label",{class:U(["absolute -top-2 left-2 z-10 bg-white px-2 text-left text-xs font-bold",{"text-red-600":a.hasErrors}])},S(a.label),3),B(w("input",q({id:a.label,ref:"input","onUpdate:modelValue":o[0]||(o[0]=d=>n.value=d)},{readonly:a.readonly,type:a.type,autocomplete:a.autocomplete},{"data-maska":V(i),class:["w-full border-b border-secondary-700 px-4 py-3 text-xl outline-0 ring-0 transition-colors duration-200 ease-linear placeholder:text-black hover:border-black focus:border-secondary-700 focus:outline-none focus:ring-0",{"bg-gradient-to-t from-gray-200 to-white":a.readonly,"!border-red-600 text-red-600 placeholder:text-red-600":a.hasErrors}],placeholder:a.placeholder||a.label,maxlength:a.maxLength,onChange:o[1]||(o[1]=d=>s("change",d))}),null,16,X),[[z,n.value],[V(F)]]),a.hint?(A(),R("p",Y,S(a.hint),1)):D("",!0)]))}});export{ee as _};