import{p as ae,q as re,ab as se,r as h,k as m,s as ie,t as ue,K as de,N as w,h as y,o as u,v as r,u as t,w as B,b as E,c as A,A as d,Z as ce,x as k,ak as pe,y as fe,D as me}from"./index-DRopsKkO.js";import{u as be}from"./useMutationObserver-DtW-3lQD.js";import{b as R}from"./index-_-ijfL1Q.js";import{_ as ge}from"./ULabel.vue_vue_type_script_setup_true_lang-B9XE8rwf.js";const L={inputLabel:"{ULabel}",wrapper:{base:`
      border rounded-dynamic border-gray-300 relative flex w-full bg-white transition
      hover:border-gray-400 hover:focus-within:border-brand-600 focus-within:border-brand-600
      focus-within:outline focus-within:outline-dynamic-sm focus-within:outline-brand-600
    `,variants:{error:{true:"!border-red-600 focus-within:outline-red-600"},disabled:{true:"!border-gray-300 focus-within:outline-0 bg-gray-100"}}},inputIcon:{base:"{UIcon}",defaults:{size:{sm:"xs",md:"sm",lg:"md"}}},leftIcon:"{UIcon} {>inputIcon}",rightIcon:"{UIcon} {>inputIcon}",passwordIcon:"{UIcon} {>inputIcon}",passwordIconWrapper:"flex items-center justify-end whitespace-nowrap pr-2.5 gap-1 rounded-inherit rounded-l-none",leftSlot:"pl-2.5 flex items-center",rightSlot:"pr-2.5 flex items-center",input:{base:`
      block w-full py-2 px-3 font-normal !leading-none bg-transparent
      border-none rounded-inherit transition focus:ring-0
      placeholder:font-normal placeholder-gray-400
      disabled:text-gray-700 disabled:cursor-not-allowed
    `,variants:{size:{sm:"text-xs placeholder:text-xs placeholder:font-normal",md:"text-sm placeholder:text-sm placeholder:font-normal",lg:"text-base placeholder:text-base placeholder:font-normal"},error:{true:"placeholder:text-red-300"},typePassword:{true:"tracking-widest [-webkit-text-security:disc]"}},compoundVariants:[{labelAlign:"topInside",label:!0,size:"sm",class:"pt-5"},{labelAlign:"topInside",label:!0,size:"md",class:"pt-6"},{labelAlign:"topInside",label:!0,size:"lg",class:"pt-7"}]},defaults:{size:"md",type:"text",inputmode:"text",labelAlign:"topInside",validationRule:"",readonly:!1,disabled:!1,noAutocomplete:!1,passwordVisibleIcon:"visibility-fill",passwordHiddenIcon:"visibility_off-fill"}},he="UInput",ye=["for"],ve=["id","placeholder","type","readonly","disabled","maxlength","inputmode","data-test"],Ie=["for"],Se=ae({inheritAttrs:!1,__name:"UInput",props:re({modelValue:{},label:{},labelAlign:{},placeholder:{},description:{},error:{},size:{},leftIcon:{},rightIcon:{},maxLength:{},validationRule:{},type:{},inputmode:{},readonly:{type:Boolean},disabled:{type:Boolean},noAutocomplete:{type:Boolean},id:{},config:{},dataTest:{}},{...me(L,he),modelValue:"",label:"",placeholder:""}),emits:["update:modelValue","change","click","focus","mousedown","blur","input","copy","paste"],setup(N,{expose:U,emit:D}){const o=N,a=D,S={integer:/\d*/g,number:/\d*\.?\d*/g,string:/[a-zA-Z]+/g,stringAndNumber:/[a-zA-Z0-9]+/g,symbol:/\D/g},$=se(),c=h(!1),s=h(null),b=h(null),g=h(null),v=m(()=>o.type==="password"),I=m({get:()=>o.modelValue,set:e=>a("update:modelValue",e)}),p=o.id||ie(),T=m(()=>c.value||o.noAutocomplete?"text":o.type),x=m(()=>c.value?P.value.defaults.passwordVisibleIcon||"":P.value.defaults.passwordHiddenIcon||"");de(()=>{f(!0),V()});function M(e){const n=e.target;if(!n)return;let l=n.value;if(o.validationRule){const i=document.querySelector(`#${p}`);if(!i)return;l=S[o.validationRule]?C(l,S[o.validationRule]):C(l,o.validationRule),i.value=l}a("input",l)}function O(e){a("change",e)}function W(e){f(!1),a("click",e)}function Z(e){f(!1),a("focus",e)}function j(e){f(!0),a("blur",e)}function q(e){f(!1),a("mousedown",e)}function F(e){a("paste",e)}function H(e){a("copy",e)}function G(){c.value=!c.value}function f(e){o.noAutocomplete&&!o.readonly&&s.value&&(e?s.value.setAttribute("readonly","readonly"):s.value.removeAttribute("readonly"))}function C(e,n){const l=new RegExp(n,"ig"),i=String(e).match(l);return i?i.join(""):""}be(b,e=>e.forEach(V),{childList:!0,characterData:!0,subtree:!0});function V(){var n,l;const e=!w($.left)&&!o.leftIcon;if(!(o.labelAlign==="top"||e)&&b.value&&s.value&&(n=g.value)!=null&&n.labelElement){const i=b.value.getBoundingClientRect().width,ne=parseFloat(getComputedStyle(s.value).paddingLeft);(l=g.value)!=null&&l.labelElement&&(g.value.labelElement.style.left=`${i+ne}px`)}}U({inputRef:s});const K=m(()=>({error:!!o.error&&!o.disabled,label:!!o.label,typePassword:!!(I.value&&!c.value&&v.value)})),{getDataTest:z,config:P,inputAttrs:X,wrapperAttrs:J,inputLabelAttrs:Q,passwordIconAttrs:Y,leftIconAttrs:_,leftSlotAttrs:ee,rightIconAttrs:te,rightSlotAttrs:oe,passwordIconWrapperAttrs:le}=ue(L,K);return(e,n)=>(u(),y(ge,r({ref_key:"labelComponentRef",ref:g,for:t(p),label:e.label,description:e.description,disabled:e.disabled,error:e.error,size:e.size,align:e.labelAlign,centred:"",interactive:""},t(Q)),{label:B(()=>[k(e.$slots,"label",{label:e.label})]),default:B(()=>[E("label",r({for:t(p)},t(J)),[t(w)(e.$slots.left)||e.leftIcon?(u(),A("span",r({key:0},t(ee),{ref_key:"leftSlotWrapperRef",ref:b}),[k(e.$slots,"left",{iconName:e.leftIcon},()=>[e.leftIcon?(u(),y(R,r({key:0,internal:"",color:"gray",name:e.leftIcon},t(_)),null,16,["name"])):d("",!0)])],16)):d("",!0),ce(E("input",r({id:t(p),ref_key:"inputRef",ref:s,"onUpdate:modelValue":n[0]||(n[0]=l=>I.value=l),placeholder:e.placeholder,type:T.value,readonly:e.readonly,disabled:e.disabled,maxlength:e.maxLength,inputmode:e.inputmode},t(X),{"data-test":t(z)(),onFocus:Z,onBlur:j,onInput:M,onChange:O,onMousedown:q,onClick:W,onPaste:F,onCopy:H}),null,16,ve),[[pe,I.value]]),v.value?(u(),A("label",r({key:1},t(le),{for:t(p)}),[v.value?(u(),y(R,r({key:0,name:x.value,color:"gray",interactive:"",internal:""},t(Y),{"data-test":t(z)("password-icon"),onClick:G}),null,16,["name","data-test"])):d("",!0)],16,Ie)):d("",!0),t(w)(e.$slots.right)||e.rightIcon?(u(),A("div",fe(r({key:2},t(oe))),[k(e.$slots,"right",{iconName:e.rightIcon},()=>[e.rightIcon?(u(),y(R,r({key:0,internal:"",color:"gray",name:e.rightIcon},t(te)),null,16,["name"])):d("",!0)])],16)):d("",!0)],16,ye)]),_:3},16,["for","label","description","disabled","error","size","align"]))}});export{Se as _};
