import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import{X as t,et as n,lt as r,rt as i}from"./vendor-primevue-DxVRNMbC.js";import{A as a,D as o,Dt as s,F as c,I as l,It as u,O as d,R as f,Vt as p,Z as m,et as h,gt as g,k as _,o as v,y}from"./vendor-vue-core-X6q-rGJs.js";import"./vendor-other-CyG3qq8S.js";import"./api-DQLKc1Xa.js";import"./vendor-markdown-Cola12Wc.js";import"./colorUtil-Cth7eqhK.js";import"./i18n-DjV_9lZM.js";import"./vendor-reka-ui-CHPbCe4i.js";import{t as b}from"./Button-C7dWyQyS.js";import{t as x}from"./userStore-CGYKho9e.js";import{t as S}from"./BaseViewTemplate-Cdt_Rbxk.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=f({__name:`UserSelectView`,setup(e){let f=x(),A=v(),j=s(null),M=s(``),N=s(``),P=o(()=>M.value.trim()!==``),F=o(()=>f.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 f.createUser(M.value):j.value;if(!e)throw Error(`No user selected`);await f.login(e),await A.push(`/`)}catch(e){N.value=e instanceof Error?e.message:JSON.stringify(e)}};return m(async()=>{f.initialized||await f.initialize()}),(e,o)=>(h(),_(S,{dark:``},{default:g(()=>[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,p(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,p(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(f).users,"option-label":`username`,placeholder:e.$t(`userSelect.selectUser`),disabled:P.value},null,8,[`modelValue`,`options`,`placeholder`,`disabled`]),I.value?(h(),_(u(r),{key:0,severity:`error`},{default:g(()=>[c(p(I.value),1)]),_:1})):a(``,!0)]),d(`footer`,k,[l(b,{onClick:login},{default:g(()=>[c(p(e.$t(`userSelect.next`)),1)]),_:1})])])])]),_:1}))}});export{A as default};
//# sourceMappingURL=UserSelectView-CSHYACjx.js.map