import{i as b,j as B,h as p,g as n,d as F,a3 as $,a4 as z,a5 as A,m as g,o as d,a as y,q as T,B as U,a6 as N,w,F as S,G as R,c as W,J as j,l as K,t as O}from"./index-CTxlYqj4.js";import{V as P}from"./VTextField-CWm47OUI.js";import{a as q,b as G,V as J}from"./forwardRefs-BSESyuUp.js";import{u as H}from"./domains.store-BAoaJY6i.js";const Q={__name:"EmailField",props:{modelValue:{type:String,default:""},allowAdd:{type:Boolean,default:!1},role:{type:String,default:b.USER},errorMsg:{type:Array,default:()=>[]}},emits:["domain-selected","update:model-value"],setup(x,{emit:E}){const h=H(),o=x,V=E,r=p({get(){return o.modelValue},set(e){v.value=[],e.indexOf("@")!==-1?(u.value=e.split("@")[1],o.allowAdd?a.value=s.value.length>0:a.value=!0):a.value=!1,V("update:model-value",e)}}),s=p(()=>Object.values(h.domains).filter(e=>e.name.startsWith(u.value))),v=p({get(){return[...D.value,...o.errorMsg]},set(e){D.value=e}}),u=n(""),l=n(0),a=n(!1),k=n(500),_=n(),D=n([]);function C(e){const t=e.keyCode;t===40||t===34?(a.value?M():(u.value="",a.value=!0),e.preventDefault()):t===38||t===33?(a.value?I():(u.value="",a.value=!0),e.preventDefault()):t===13||t===9?(s.value.length>0?c(s.value[l.value]):o.allowAdd&&c(),e.preventDefault()):t===27&&s.value.length>0&&(a.value=!1,e.preventDefault())}function M(){l.value>=s.value.length-1?l.value=0:l.value+=1}function I(){l.value<=0?l.value=s.value.length-1:l.value-=1}function c(e){e!==void 0&&(r.value=r.value.split("@")[0]+"@"+e.name),a.value=!1,V("domain-selected")}function m(){k.value=_.value.$el.clientWidth}return F(()=>{h.getDomains(),window.addEventListener("resize",m)}),$(()=>{window.removeEventListener("resize",m)}),z(()=>{A(()=>{m()})}),(e,t)=>(d(),g(S,null,[y(P,U({ref_key:"inputRef",ref:_,modelValue:r.value,"onUpdate:modelValue":t[0]||(t[0]=i=>r.value=i),variant:"outlined"},e.$attrs,{"error-messages":v.value,error:v.value.length>0,density:"compact",autocomplete:"new-password",onKeydown:C}),null,16,["modelValue","error-messages","error"]),a.value?(d(),g("div",{key:0,class:"menu",style:N(`width: ${k.value}px;`)},[y(J,{class:"list"},{default:w(()=>[(d(!0),g(S,null,R(s.value,(i,f)=>(d(),W(q,{key:f,class:j(l.value===f?"bg-primary-lighten-1":""),onClick:L=>c(i),onMouseenter:L=>l.value=f},{default:w(()=>[y(G,null,{default:w(()=>[K(O(i.name),1)]),_:2},1024)]),_:2},1032,["class","onClick","onMouseenter"]))),128))]),_:1})],4)):T("",!0)],64))}},ae=B(Q,[["__scopeId","data-v-bed4b698"]]);export{ae as E};
