import{a as L,_ as M}from"./AliasRecipientForm-rO7zW0eC.js";import{L as U}from"./LoadingData-BT9tD67O.js";import{b as R,M as I,s as S,g as p,d as z,c as f,m as v,o as s,a,e as E,w as e,l as r,t as i,f as u,F as B,G as O,j as q}from"./index-CTxlYqj4.js";import{a as w}from"./aliases-CTtmxHck.js";import{g as b,d as A,V as T}from"./VAvatar-x_79C0tA.js";import{V as $,c as h,a as C,b as H}from"./VExpansionPanels-DpJzLCB-.js";import{V as k,a as c}from"./VRow-B-csPNw7.js";import{V as J}from"./VChip-Def9BYoN.js";import{V as K,a as Q}from"./VToolbar-Cd2iSn8H.js";import"./EmailField-CK1ZbR3C.js";import"./VTextField-CWm47OUI.js";import"./tag-Dx3OexMp.js";import"./VProgressCircular-ubzZW5PC.js";import"./forwardRefs-BSESyuUp.js";import"./ssrBoot-DGgZQEVC.js";import"./domains.store-BAoaJY6i.js";import"./domains-HueJ9pRR.js";import"./VForm-CXf-xKYz.js";import"./VSwitch-HiyBjUWI.js";import"./VSelectionControl-Bdgm37Tl.js";import"./VSelect-tV4GZAtn.js";import"./VMenu-DTm7W1Hp.js";import"./VCheckboxBtn-xrhfoOlo.js";import"./VTextarea-Bry3a299.js";import"./VContainer-CC8lqRXa.js";/* empty css              */const W={key:1},X={key:0},Y={class:"mr-2"},Z={key:0},ee={class:"mt-4 d-flex justify-end"},ae={__name:"AliasEditForm",setup(N){const{$gettext:n}=R(),d=I(),y=S(),o=p({pk:d.params.id}),V=p(0),m=p(!0),g=p(!1),x=p(),F=p(),P={generalForm:x,recipientForm:F};async function j(){g.value=!1,V.value=[];for(const[_,t]of Object.entries(P))if(t.value!=null){const{valid:l}=await t.value.vFormRef.validate();l||(g.value=!0,V.value.push(_))}if(!g.value){m.value=!0;try{await w.patch(d.params.id,o.value),y.push({name:"AliasDetail",params:{id:d.params.id}})}finally{m.value=!1}}}return z(()=>{w.get(d.params.id).then(_=>{o.value=_.data,m.value=!1})}),(_,t)=>m.value?(s(),f(U,{key:0})):(s(),v("div",W,[a(H,{modelValue:V.value,"onUpdate:modelValue":t[2]||(t[2]=l=>V.value=l),multiple:g.value},{default:e(()=>[a($,{eager:"",value:"generalForm"},{default:e(()=>[a(h,null,{default:e(({expanded:l})=>[a(k,{"no-gutters":""},{default:e(()=>[a(c,{cols:"4"},{default:e(()=>[r(i(u(n)("General")),1)]),_:1}),a(c,{cols:"8",class:"text-medium-emphasis"},{default:e(()=>[a(b,{"leave-absolute":""},{default:e(()=>[l?(s(),v("span",X)):(s(),f(k,{key:1,"no-gutters":"",style:{width:"100%"}},{default:e(()=>[a(c,{cols:"6"},{default:e(()=>[r(i(u(n)("Address"))+": "+i(o.value.address),1)]),_:1}),a(c,{cols:"6"},{default:e(()=>[E("div",Y,i(u(n)("Enabled")),1),o.value.enabled?(s(),f(A,{key:0,color:"success"},{default:e(()=>t[4]||(t[4]=[r("mdi-check-circle-outline")])),_:1,__:[4]})):(s(),f(A,{key:1},{default:e(()=>t[5]||(t[5]=[r("mdi-close-circle-outline")])),_:1,__:[5]}))]),_:1})]),_:1}))]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:1}),a(C,null,{default:e(()=>[a(L,{ref_key:"generalForm",ref:x,modelValue:o.value,"onUpdate:modelValue":t[0]||(t[0]=l=>o.value=l)},null,8,["modelValue"])]),_:1})]),_:1}),a($,{eager:"",value:"recipientForm"},{default:e(()=>[a(h,null,{default:e(({expanded:l})=>[a(k,{"no-gutters":""},{default:e(()=>[a(c,{cols:"4"},{default:e(()=>[r(i(u(n)("Recipients")),1)]),_:1}),a(c,{cols:"8",class:"text-medium-emphasis"},{default:e(()=>[a(b,{"leave-absolute":""},{default:e(()=>[l?(s(),v("span",Z)):(s(),f(k,{key:1,"no-gutters":"",style:{width:"100%"}},{default:e(()=>[(s(!0),v(B,null,O(o.value.recipients,(D,G)=>(s(),f(J,{key:G,size:"small"},{default:e(()=>[r(i(D),1)]),_:2},1024))),128))]),_:1}))]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:1}),a(C,null,{default:e(()=>[a(u(M),{ref_key:"recipientForm",ref:F,modelValue:o.value.recipients,"onUpdate:modelValue":t[1]||(t[1]=l=>o.value.recipients=l)},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["modelValue","multiple"]),E("div",ee,[a(T,{loading:m.value,onClick:t[3]||(t[3]=l=>_.$router.go(-1))},{default:e(()=>[r(i(u(n)("Cancel")),1)]),_:1},8,["loading"]),a(T,{class:"ml-4",color:"primary darken-1",loading:m.value,onClick:j},{default:e(()=>[r(i(u(n)("Save")),1)]),_:1},8,["loading"])])]))}},te={__name:"AliasEditView",setup(N){const{$gettext:n}=R();return(d,y)=>(s(),v(B,null,[a(K,{flat:""},{default:e(()=>[a(Q,null,{default:e(()=>[r(i(u(n)("Edit alias")),1)]),_:1})]),_:1}),a(ae,{alias:d.alias},null,8,["alias"])],64))}},he=q(te,[["__scopeId","data-v-21c8ea90"]]);export{he as default};
