import{a as S}from"./aliases-CTtmxHck.js";import{E as w}from"./EmailField-CK1ZbR3C.js";import{r as A,V as E}from"./VForm-CXf-xKYz.js";import{d as T}from"./domains-HueJ9pRR.js";import{V as U}from"./VSwitch-HiyBjUWI.js";import{V as q}from"./VSelect-tV4GZAtn.js";import{V as h}from"./VAvatar-x_79C0tA.js";import{V as C}from"./VTextField-CWm47OUI.js";import{V as G}from"./VTextarea-Bry3a299.js";import{h as _,g as m,c as f,o as r,w as u,q as N,m as x,a as o,e as V,F,t as i,f as d,b as j,G as L,l as O}from"./index-CTxlYqj4.js";import{V as P}from"./VChip-Def9BYoN.js";const z={class:"m-label"},H={class:"m-label"},I={class:"m-label"},J={class:"m-label"},se={__name:"AliasGeneralForm",props:{modelValue:{type:Object,default:null}},setup(b,{expose:y}){const g=b,e=_(()=>g.modelValue),p=m([]),c=m();function n(){e.value.address!=null&&navigator.clipboard.writeText(e.value.address)}async function s(){e.value.domain!=null&&S.getRandomAddress().then(t=>{e.value.address=`${t.data.address}@${e.value.domain.name}`})}return T.getDomains().then(t=>{p.value=t.data}),y({vFormRef:c}),(t,a)=>(r(),f(E,{ref_key:"vFormRef",ref:c},{default:u(()=>[e.value.pk?N("",!0):(r(),f(U,{key:0,modelValue:e.value.random,"onUpdate:modelValue":a[0]||(a[0]=l=>e.value.random=l),label:t.$gettext("Random address"),color:"primary"},null,8,["modelValue","label"])),e.value.random?(r(),x(F,{key:2},[V("label",H,i(t.$gettext("Domain")),1),o(q,{modelValue:e.value.domain,"onUpdate:modelValue":[a[2]||(a[2]=l=>e.value.domain=l),s],items:p.value,"item-title":"name","return-object":"",variant:"outlined",density:"compact",rules:[d(A).required]},{append:u(()=>[o(h,{variant:"flat",icon:"mdi-reload",onClick:s})]),_:1},8,["modelValue","items","rules"]),o(C,{modelValue:e.value.address,"onUpdate:modelValue":a[3]||(a[3]=l=>e.value.address=l),label:t.$gettext("Generated address"),variant:"outlined",readonly:""},{"append-inner":u(()=>[o(h,{variant:"flat",icon:"mdi-clipboard-outline",onClick:n})]),_:1},8,["modelValue","label"])],64)):(r(),x(F,{key:1},[V("label",z,i(t.$gettext("Email address")),1),o(d(w),{ref:"address",modelValue:e.value.address,"onUpdate:modelValue":a[1]||(a[1]=l=>e.value.address=l),type:"email",variant:"outlined",density:"compact",rules:[d(A).required]},null,8,["modelValue","rules"])],64)),o(U,{modelValue:e.value.enabled,"onUpdate:modelValue":a[4]||(a[4]=l=>e.value.enabled=l),label:t.$gettext("Enabled"),color:"primary"},null,8,["modelValue","label"]),V("label",I,i(t.$gettext("Expire at")),1),o(C,{modelValue:e.value.expire,"onUpdate:modelValue":a[5]||(a[5]=l=>e.value.expire=l),variant:"outlined",density:"compact"},null,8,["modelValue"]),V("label",J,i(t.$gettext("Description")),1),o(G,{modelValue:e.value.description,"onUpdate:modelValue":a[6]||(a[6]=l=>e.value.description=l),rows:"2",variant:"outlined",density:"compact"},null,8,["modelValue"])]),_:1},512))}},re={__name:"AliasRecipientForm",props:{modelValue:{type:Array,default:()=>[]}},emits:["update:model-value"],setup(b,{expose:y,emit:g}){const{$gettext:e}=j(),p=g,c=b,n=_({get:()=>c.modelValue,set:v=>p("update:model-value",v)}),s=m(""),t=m(),a=m();async function l(){n.value.push(s.value),s.value="",a.value.resetValidation()}function B(v){n.value.splice(v,1)}const D=[()=>n.value.length>0||e("Please add at least one recipient.")];return y({vFormRef:a}),(v,$)=>(r(),f(E,{ref_key:"vFormRef",ref:a},{default:u(()=>[o(d(w),{ref_key:"recipientField",ref:t,modelValue:s.value,"onUpdate:modelValue":$[0]||($[0]=k=>s.value=k),placeholder:d(e)("Start typing a name here..."),hint:d(e)("Alias(es) of this mailbox. To create a catchall alias, just enter the domain name (@domain.tld)."),"persistent-hint":"","allow-add":"",rules:D,onDomainSelected:l},null,8,["modelValue","placeholder","hint"]),(r(!0),x(F,null,L(n.value,(k,R)=>(r(),f(P,{key:R,class:"mr-2 mt-2",closable:"","onClick:close":K=>B(R)},{default:u(()=>[O(i(k),1)]),_:2},1032,["onClick:close"]))),128))]),_:1},512))}};export{re as _,se as a};
