import{A as e,C as t,I as n,Q as r,R as i,St as a,b as o,ct as s,h as c,l,m as u,v as d,w as f,wt as p,x as m,y as h,yt as g}from"./vue.runtime.esm-bundler-DS0mm12S.js";import{a as _,i as v,n as y,r as b,t as x}from"./SelectValue-CPTo3Tck.js";import{n as S}from"./lib-CiHeuR38.js";import{c as C,d as w,l as T,r as E,s as D,u as O}from"./index-aDrlI3dP.js";import{n as k}from"./button-DQxx5HZh.js";import{a as A,n as j,r as M}from"./modal-BsQDUPf_.js";import{a as N,c as P,i as F,l as I,n as L,r as R,s as z,t as B}from"./vee-validate-zod-DHwQMVp1.js";import{t as V}from"./Input-Bq5OMrfM.js";var H=D([`active`,`inactive`,`invited`,`suspended`]),U=D([`superadmin`,`admin`,`cashier`,`manager`]);C(O({id:w(),firstName:w(),lastName:w(),username:w(),email:w(),phoneNumber:w(),status:H,role:U,createdAt:E(),updatedAt:E()}));var W=O({id:w().optional(),firstName:w().min(1),lastName:w().min(1),username:w().min(1),email:T().min(1),phoneNumber:w().min(1),status:H,role:U}),G={class:`max-h-[500px] overflow-y-auto`},K=m({__name:`user-form`,props:{user:{}},emits:[`close`],setup(u,{emit:m}){let C=m,w=[`superadmin`,`admin`,`cashier`,`manager`],T=[`active`,`inactive`,`invited`,`suspended`],E=s({firstName:u.user?.firstName||``,lastName:u.user?.lastName||``,username:u.user?.username||``,email:u.user?.email||``,phoneNumber:u.user?.phoneNumber||``,status:u.user?.status||`active`,role:u.user?.role||`cashier`}),{handleSubmit:D}=P({validationSchema:B(W),initialValues:E}),O=D(e=>{let t={...e};u.user&&(t.id=u.user.id),S(`You submitted the following values:`,{description:f(`pre`,{class:`mt-2 w-[340px] rounded-md bg-slate-950 p-4`},f(`code`,{class:`text-white`},JSON.stringify(t,null,2)))}),C(`close`)});return(s,u)=>(n(),d(`div`,G,[c(`form`,{class:`space-y-8`,onSubmit:u[0]||=(...e)=>g(O)&&g(O)(...e)},[o(g(z),{name:`firstName`},{default:r(({componentField:t})=>[o(g(F),null,{default:r(()=>[o(g(R),null,{default:r(()=>[...u[1]||=[h(`First Name`,-1)]]),_:1}),o(g(N),null,{default:r(()=>[o(g(V),e({type:`text`},t),null,16)]),_:2},1024),o(g(L))]),_:2},1024)]),_:1}),o(g(z),{name:`lastName`},{default:r(({componentField:t})=>[o(g(F),null,{default:r(()=>[o(g(R),null,{default:r(()=>[...u[2]||=[h(`Last Name`,-1)]]),_:1}),o(g(N),null,{default:r(()=>[o(g(V),e({type:`text`},t),null,16)]),_:2},1024),o(g(L))]),_:2},1024)]),_:1}),o(g(z),{name:`username`},{default:r(({componentField:t})=>[o(g(F),null,{default:r(()=>[o(g(R),null,{default:r(()=>[...u[3]||=[h(`User Name`,-1)]]),_:1}),o(g(N),null,{default:r(()=>[o(g(V),e({type:`text`},t),null,16)]),_:2},1024),o(g(L))]),_:2},1024)]),_:1}),o(g(z),{name:`email`},{default:r(({componentField:t})=>[o(g(F),null,{default:r(()=>[o(g(R),null,{default:r(()=>[...u[4]||=[h(`Email address`,-1)]]),_:1}),o(g(N),null,{default:r(()=>[o(g(V),e({type:`text`},t),null,16)]),_:2},1024),o(g(L))]),_:2},1024)]),_:1}),o(g(z),{name:`phoneNumber`},{default:r(({componentField:t})=>[o(g(F),null,{default:r(()=>[o(g(R),null,{default:r(()=>[...u[5]||=[h(`Phone Number`,-1)]]),_:1}),o(g(N),null,{default:r(()=>[o(g(V),e({type:`text`},t),null,16)]),_:2},1024),o(g(L))]),_:2},1024)]),_:1}),o(g(z),{name:`status`},{default:r(({componentField:e})=>[o(g(F),null,{default:r(()=>[o(g(R),null,{default:r(()=>[...u[6]||=[h(`Status`,-1)]]),_:1}),o(g(N),null,{default:r(()=>[o(g(_),a(t(e)),{default:r(()=>[o(g(N),null,{default:r(()=>[o(g(y),{class:`w-full`},{default:r(()=>[o(g(x),{placeholder:`Select a status`})]),_:1})]),_:1}),o(g(v),null,{default:r(()=>[o(g(I),null,{default:r(()=>[(n(),d(l,null,i(T,e=>o(g(b),{key:e,value:e},{default:r(()=>[h(p(e),1)]),_:2},1032,[`value`])),64))]),_:1})]),_:1})]),_:1},16)]),_:2},1024),o(g(L))]),_:2},1024)]),_:1}),o(g(z),{name:`role`},{default:r(({componentField:e})=>[o(g(F),null,{default:r(()=>[o(g(R),null,{default:r(()=>[...u[7]||=[h(`Role`,-1)]]),_:1}),o(g(N),null,{default:r(()=>[o(g(_),a(t(e)),{default:r(()=>[o(g(N),null,{default:r(()=>[o(g(y),{class:`w-full`},{default:r(()=>[o(g(x),{placeholder:`Select a role`})]),_:1})]),_:1}),o(g(v),null,{default:r(()=>[o(g(I),null,{default:r(()=>[(n(),d(l,null,i(w,e=>o(g(b),{key:e,value:e},{default:r(()=>[h(p(e),1)]),_:2},1032,[`value`])),64))]),_:1})]),_:1})]),_:1},16)]),_:2},1024),o(g(L))]),_:2},1024)]),_:1}),o(g(k),{type:`submit`,class:`w-full`},{default:r(()=>[...u[8]||=[h(` SaveChanges `,-1)]]),_:1})],32)]))}}),q=m({__name:`user-resource`,props:{user:{}},emits:[`close`],setup(e){let t=e,i=u(()=>t.user),a=u(()=>i.value?.id?`Edit User`:`New User`),s=u(()=>i.value?.id?`Edit user ${i.value.username}`:`Create new user`);return(e,t)=>(n(),d(`div`,null,[o(g(M),null,{default:r(()=>[o(g(j),null,{default:r(()=>[h(p(g(a)),1)]),_:1}),o(g(A),null,{default:r(()=>[h(p(g(s)),1)]),_:1})]),_:1}),o(K,{user:g(i),onClose:t[0]||=t=>e.$emit(`close`)},null,8,[`user`])]))}});export{q as t};