import{b as P,n as _,h as b,m,o as n,q as p,a as o,F as V,e as v,t as y,f as l,w as u,c as h,N as E}from"./index-CTxlYqj4.js";import{r as c}from"./VForm-CXf-xKYz.js";import{V as w}from"./VTextField-CWm47OUI.js";import{a as g,V as q}from"./VRow-B-csPNw7.js";import{V as N}from"./VSwitch-HiyBjUWI.js";import{V as R}from"./VAlert-BiAap6Bx.js";import{V as S}from"./VAvatar-x_79C0tA.js";const A={class:"m-label"},F={class:"text-white mr-4"},$={__name:"AccountPasswordSubForm",props:{modelValue:{type:Object,default:null},withPasswordCheck:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},editing:{type:Boolean,default:!1},formErrors:{type:Object,required:!1,default:()=>{}}},setup(s){const{$gettext:t}=P(),k=_(),r=s,e=b(()=>r.modelValue),f=b(()=>!r.disabled&&(!r.editing||e.value.password)),x=i=>i===e.value.new_password||t("Password mismatch");function C(){navigator.clipboard.writeText(e.value.new_password).then(()=>{k.displayNotification({msg:t("Password copied to clipboard")})})}function B(i){i?E.getRandomPassword().then(a=>{e.value.new_password=a.data.password}):(e.value.new_password=null,e.value.password_confirmation=null)}return(i,a)=>(n(),m("div",null,[s.withPasswordCheck?(n(),m(V,{key:0},[v("label",A,y(l(t)("Current password")),1),o(w,{modelValue:e.value.password,"onUpdate:modelValue":a[0]||(a[0]=d=>e.value.password=d),autocomplete:"new-password",variant:"outlined",type:"password",density:"compact","validate-on":"submit",rules:s.disabled?[]:[l(c).required],disabled:s.disabled,"error-messages":r.formErrors?r.formErrors.password:[]},null,8,["modelValue","rules","disabled","error-messages"])],64)):p("",!0),o(q,{justify:"center"},{default:u(()=>[o(g,{cols:"auto"},{default:u(()=>[o(N,{modelValue:e.value.random_password,"onUpdate:modelValue":[a[1]||(a[1]=d=>e.value.random_password=d),B],label:l(t)("Random password"),density:"compact",color:"primary",class:"text-center",disabled:s.disabled},null,8,["modelValue","label","disabled"])]),_:1}),o(g,null,{default:u(()=>[e.value.random_password?(n(),h(R,{key:0,style:{"background-color":"#515d78"},class:"ml-6",density:"compact"},{default:u(()=>[v("span",F,y(e.value.new_password),1),o(S,{size:"small",color:"white",variant:"text",density:"compact",disabled:s.disabled,icon:"mdi-clipboard-multiple-outline",title:l(t)("Copy to clipboard"),onClick:C},null,8,["disabled","title"])]),_:1})):p("",!0)]),_:1})]),_:1}),e.value.random_password?p("",!0):(n(),m(V,{key:1},[o(w,{modelValue:e.value.new_password,"onUpdate:modelValue":a[2]||(a[2]=d=>e.value.new_password=d),variant:"outlined",label:l(t)("Password"),type:"password",autocomplete:"new-password",density:"compact",disabled:s.disabled,rules:f.value?[l(c).required]:[]},null,8,["modelValue","label","disabled","rules"]),o(w,{modelValue:e.value.password_confirmation,"onUpdate:modelValue":a[3]||(a[3]=d=>e.value.password_confirmation=d),variant:"outlined",type:"password",label:l(t)("Confirmation"),density:"compact",disabled:s.disabled,rules:f.value?[l(c).required,x]:[],"error-messages":r.formErrors?r.formErrors.new_password:[]},null,8,["modelValue","label","disabled","rules","error-messages"])],64))]))}};export{$ as _};
