import{i as e,n as t}from"./rolldown-runtime-BKYq3fBv.js";import{$n as n,$t as r,Cr as i,Hn as a,Nn as o,Qn as s,Rr as c,Ut as l,Wt as u,Xn as d,Xr as f,Zn as p,_n as m,ai as h,an as g,ar as _,br as v,en as y,ir as b,on as x,sr as S,ui as C,vn as w}from"./vendor-primevue-D50rA9nL.js";import{ln as T,sn as E}from"./vendor-other-BnH5nyVX.js";import{n as D,t as O}from"./Button-DzMg17Os.js";import{n as k,t as A}from"./userStore-D0IyjTYG.js";import{n as j,t as M}from"./BaseViewTemplate-A9dy6oGX.js";var N,P,F,I,L,R,z,B,V=t((()=>{o(),l(),g(),m(),r(),E(),D(),A(),j(),N={id:`comfy-user-selection`,class:`relative min-w-84 rounded-lg bg-(--comfy-menu-bg) p-5 px-10 shadow-lg`},P={class:`flex w-full flex-col items-center`},F={class:`flex w-full flex-col gap-2`},I={for:`new-user-input`},L={class:`flex w-full flex-col gap-2`},R={for:`existing-user-select`},z={class:`mt-5`},B=S({__name:`UserSelectView`,setup(e){let t=k(),r=T(),o=f(null),l=f(``),m=f(``),g=d(()=>l.value.trim()!==``),S=d(()=>t.users.find(e=>e.username===l.value)?`User "${l.value}" already exists`:``),E=d(()=>S.value||m.value),login=async()=>{try{let e=g.value?await t.createUser(l.value):o.value;if(!e)throw Error(`No user selected`);await t.login(e),await r.push(`/`)}catch(e){m.value=e instanceof Error?e.message:JSON.stringify(e)}};return v(async()=>{t.initialized||await t.initialize()}),(e,r)=>(i(),s(M,{dark:``},{default:c(()=>[p(`main`,N,[r[2]||=p(`h1`,{class:`my-2.5 mb-7 font-normal`},`ComfyUI`,-1),p(`div`,P,[p(`div`,F,[p(`label`,I,C(e.$t(`userSelect.newUser`))+`:`,1),_(h(x),{id:`new-user-input`,modelValue:l.value,"onUpdate:modelValue":r[0]||=e=>l.value=e,placeholder:e.$t(`userSelect.enterUsername`),onKeyup:a(login,[`enter`])},null,8,[`modelValue`,`placeholder`])]),_(h(u)),p(`div`,L,[p(`label`,R,C(e.$t(`userSelect.existingUser`))+`:`,1),_(h(y),{modelValue:o.value,"onUpdate:modelValue":r[1]||=e=>o.value=e,class:`w-full`,"input-id":`existing-user-select`,options:h(t).users,"option-label":`username`,placeholder:e.$t(`userSelect.selectUser`),disabled:g.value},null,8,[`modelValue`,`options`,`placeholder`,`disabled`]),E.value?(i(),s(h(w),{key:0,severity:`error`},{default:c(()=>[b(C(E.value),1)]),_:1})):n(``,!0)]),p(`footer`,z,[_(O,{onClick:login},{default:c(()=>[b(C(e.$t(`userSelect.next`)),1)]),_:1})])])])]),_:1}))}})})),H;t((()=>{V(),V(),H=B}))();export{H as default};
//# sourceMappingURL=UserSelectView-C_GqmLwH.js.map