import{Wo as e,fs as t}from"./app-server-manager-signals-Yn0WSnoY.js";import{t as n}from"./jsx-runtime-CiQ1k8xo.js";import{lt as r}from"./vscode-api-DjORcpSo.js";import{c as i,o as a}from"./lib-MoKmYgcO.js";import{t as o}from"./button-Bi7lGVi1.js";async function s({hostId:n=e,signal:r,useStreamlinedLogin:i}){let a=l(r);return n===`local`?t(`login-with-chatgpt`,{abortController:a,useStreamlinedLogin:i}):t(`login-with-chatgpt-for-host`,{abortController:a,hostId:n,useStreamlinedLogin:i})}function c({signal:e}={}){return t(`login-with-chatgpt-device-code`,{abortController:l(e)})}function l(e){let t=new AbortController;return e==null?t:e.aborted?(t.abort(),t):(e.addEventListener(`abort`,()=>t.abort(),{once:!0}),t)}var u=r(),d=n();function f(e){let t=(0,u.c)(37),{apiKeyValue:n,isApiKeyEntryVisible:r,isApiKeySignInPending:s,isChatGptSignInPending:c,onApiKeySecondaryAction:l,onApiKeySubmit:f,onApiKeyValueChange:p,onChatGptSignIn:m,onShowApiKeyEntry:h,apiKeySecondaryActionLabel:g}=e,_=i();if(r){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,d.jsx)(a,{id:`electron.onboarding.login.apikey.label`,defaultMessage:`OpenAI API key`,description:`Label for API key input on desktop onboarding`}),t[0]=e):e=t[0];let r;t[1]===_?r=t[2]:(r=_.formatMessage({id:`electron.onboarding.login.apikey.placeholder`,defaultMessage:`sk-…`,description:`Placeholder for API key input on desktop onboarding`}),t[1]=_,t[2]=r);let i;t[3]===p?i=t[4]:(i=e=>p(e.target.value),t[3]=p,t[4]=i);let c;t[5]!==n||t[6]!==r||t[7]!==i?(c=(0,d.jsxs)(`label`,{className:`text-base font-medium text-token-foreground`,children:[e,(0,d.jsx)(`input`,{autoFocus:!0,className:`mt-2 w-full rounded-xl border border-token-border bg-token-input-background px-4 py-2.5 focus:ring-2 focus:ring-black/15 focus:outline-none`,placeholder:r,value:n,onChange:i})]}),t[5]=n,t[6]=r,t[7]=i,t[8]=c):c=t[8];let u;t[9]!==g||t[10]!==l?(u=(0,d.jsx)(o,{color:`secondary`,className:`flex flex-1 justify-center py-2`,onClick:l,children:g}),t[9]=g,t[10]=l,t[11]=u):u=t[11];let m;t[12]!==n||t[13]!==s?(m=n.trim().length===0||s,t[12]=n,t[13]=s,t[14]=m):m=t[14];let h;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,d.jsx)(a,{id:`electron.onboarding.login.apikey.continue`,defaultMessage:`Continue`,description:`Continue button label for API key sign-in on desktop onboarding`}),t[15]=h):h=t[15];let v;t[16]!==s||t[17]!==f||t[18]!==m?(v=(0,d.jsx)(o,{className:`flex flex-1 justify-center py-2`,onClick:f,disabled:m,loading:s,children:h}),t[16]=s,t[17]=f,t[18]=m,t[19]=v):v=t[19];let y;t[20]!==u||t[21]!==v?(y=(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u,v]}),t[20]=u,t[21]=v,t[22]=y):y=t[22];let b;return t[23]!==c||t[24]!==y?(b=(0,d.jsxs)(`div`,{className:`flex w-full flex-col gap-3`,children:[c,y]}),t[23]=c,t[24]=y,t[25]=b):b=t[25],b}let v;t[26]===c?v=t[27]:(v=c?(0,d.jsx)(a,{id:`electron.onboarding.login.chatgpt.cancel`,defaultMessage:`Cancel sign-in`,description:`Cancel button label while ChatGPT sign-in is in progress on desktop onboarding`}):(0,d.jsx)(a,{id:`electron.onboarding.login.chatgpt.continue`,defaultMessage:`Continue with ChatGPT`,description:`Button label to sign in with ChatGPT on desktop onboarding`}),t[26]=c,t[27]=v);let y;t[28]!==m||t[29]!==v?(y=(0,d.jsx)(o,{color:`primary`,className:`w-full justify-center py-2.5`,onClick:m,children:v}),t[28]=m,t[29]=v,t[30]=y):y=t[30];let b;t[31]!==c||t[32]!==h?(b=c?null:(0,d.jsx)(o,{color:`outline`,className:`w-full justify-center py-2.5`,onClick:h,children:(0,d.jsx)(a,{id:`electron.onboarding.login.apikey.open`,defaultMessage:`Enter API key`,description:`Button label to open API key entry on desktop onboarding`})}),t[31]=c,t[32]=h,t[33]=b):b=t[33];let x;return t[34]!==y||t[35]!==b?(x=(0,d.jsxs)(`div`,{className:`flex w-full max-w-[200px] flex-col gap-3`,children:[y,b]}),t[34]=y,t[35]=b,t[36]=x):x=t[36],x}export{c as n,s as r,f as t};
//# sourceMappingURL=onboarding-login-content-DG1GwlaY.js.map