import{r as e}from"./rolldown-runtime-DIIn1E2Q.js";import{K as t,Q as n,ct as r,it as i}from"./vendor-primevue-DyvCA8Nd.js";import{A as a,D as o,F as s,Ht as c,I as l,Lt as u,O as d,Ot as f,R as p,Z as m,_t as h,et as g,k as _,o as v,y}from"./vendor-vue-core-IZuWV8u3.js";import"./vendor-other-Q0G0D0d6.js";import"./api-C840HmAF.js";import"./vendor-markdown-8POvMhty.js";import"./colorUtil-Q3kaA72Z.js";import"./i18n-B8CRKNXU.js";import"./vendor-reka-ui-Dfvl2gA8.js";import{t as b}from"./Button-uSZXZovG.js";import{t as x}from"./userStore-o2bxxBJt.js";import{t as S}from"./BaseViewTemplate-jYb705NA.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=p({__name:`UserSelectView`,setup(e){let p=x(),A=v(),j=f(null),M=f(``),N=f(``),P=o(()=>M.value.trim()!==``),F=o(()=>p.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 p.createUser(M.value):j.value;if(!e)throw Error(`No user selected`);await p.login(e),await A.push(`/`)}catch(e){N.value=e instanceof Error?e.message:JSON.stringify(e)}};return m(async()=>{p.initialized||await p.initialize()}),(e,o)=>(g(),_(S,{dark:``},{default:h(()=>[d(`main`,C,[o[2]||=d(`h1`,{class:`my-2.5 mb-7 font-normal`},`ComfyUI`,-1),d(`div`,w,[d(`div`,T,[d(`label`,E,c(e.$t(`userSelect.newUser`))+`:`,1),l(u(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`])]),l(u(t)),d(`div`,D,[d(`label`,O,c(e.$t(`userSelect.existingUser`))+`:`,1),l(u(n),{modelValue:j.value,"onUpdate:modelValue":o[1]||=e=>j.value=e,class:`w-full`,"input-id":`existing-user-select`,options:u(p).users,"option-label":`username`,placeholder:e.$t(`userSelect.selectUser`),disabled:P.value},null,8,[`modelValue`,`options`,`placeholder`,`disabled`]),I.value?(g(),_(u(r),{key:0,severity:`error`},{default:h(()=>[s(c(I.value),1)]),_:1})):a(``,!0)]),d(`footer`,k,[l(b,{onClick:login},{default:h(()=>[s(c(e.$t(`userSelect.next`)),1)]),_:1})])])])]),_:1}))}});export{A as default};
//# sourceMappingURL=UserSelectView-duYddEsv.js.map