import{r as e}from"./rolldown-runtime-DIIn1E2Q.js";import{W as t,ct as n,nt as r,ot as i}from"./vendor-primevue-DGevbYGF.js";import{A as a,D as o,F as s,I as c,O as l,R as u,Rt as d,Ut as f,Z as p,_t as m,et as h,k as g,kt as _,o as v,y}from"./vendor-vue-core-BdhYaYlO.js";import"./vendor-other-D9HJWI2D.js";import"./api-C1WIrB4Z.js";import"./vendor-markdown-th9BvURy.js";import"./colorUtil-DJbZtU1U.js";import"./i18n-DKtnmyh4.js";import"./vendor-reka-ui-CSo89nDv.js";import{t as b}from"./Button-DHxPjNdi.js";import{t as x}from"./userStore-ChcnLOkA.js";import{t as S}from"./BaseViewTemplate-BPNpLti5.js";var C={id:`comfy-user-selection`,class:`relative min-w-84 rounded-lg bg-(--comfy-menu-bg) p-5 px-10 shadow-lg`},w={class:`flex w-full flex-col items-center`},T={class:`flex w-full flex-col gap-2`},E={for:`new-user-input`},D={class:`flex w-full flex-col gap-2`},O={for:`existing-user-select`},k={class:`mt-5`},A=u({__name:`UserSelectView`,setup(e){let u=x(),A=v(),j=_(null),M=_(``),N=_(``),P=o(()=>M.value.trim()!==``),F=o(()=>u.users.find(e=>e.username===M.value)?`User "${M.value}" already exists`:``),I=o(()=>F.value||N.value),login=async()=>{try{let e=P.value?await u.createUser(M.value):j.value;if(!e)throw Error(`No user selected`);await u.login(e),await A.push(`/`)}catch(e){N.value=e instanceof Error?e.message:JSON.stringify(e)}};return p(async()=>{u.initialized||await u.initialize()}),(e,o)=>(h(),g(S,{dark:``},{default:m(()=>[l(`main`,C,[o[2]||=l(`h1`,{class:`my-2.5 mb-7 font-normal`},`ComfyUI`,-1),l(`div`,w,[l(`div`,T,[l(`label`,E,f(e.$t(`userSelect.newUser`))+`:`,1),c(d(i),{id:`new-user-input`,modelValue:M.value,"onUpdate:modelValue":o[0]||=e=>M.value=e,placeholder:e.$t(`userSelect.enterUsername`),onKeyup:y(login,[`enter`])},null,8,[`modelValue`,`placeholder`])]),c(d(t)),l(`div`,D,[l(`label`,O,f(e.$t(`userSelect.existingUser`))+`:`,1),c(d(r),{modelValue:j.value,"onUpdate:modelValue":o[1]||=e=>j.value=e,class:`w-full`,"input-id":`existing-user-select`,options:d(u).users,"option-label":`username`,placeholder:e.$t(`userSelect.selectUser`),disabled:P.value},null,8,[`modelValue`,`options`,`placeholder`,`disabled`]),I.value?(h(),g(d(n),{key:0,severity:`error`},{default:m(()=>[s(f(I.value),1)]),_:1})):a(``,!0)]),l(`footer`,k,[c(b,{onClick:login},{default:m(()=>[s(f(e.$t(`userSelect.next`)),1)]),_:1})])])])]),_:1}))}});export{A as default};
//# sourceMappingURL=UserSelectView-Tt4sYoPG.js.map