import{o as e}from"./chunk-DR8-3Aex.js";import{f as t,s as n}from"./envUtils-BWeoiL4Y.js";import{J as r,Q as i,Rn as a,T as o,b as s,nt as c,t as l,x as u}from"./src-Di342QoJ.js";import{t as d}from"./jsx-runtime-D-D469L8.js";import{Xi as f,Zi as p,cn as m,on as h,uc as g,yc as _}from"./paths-Ci1iwL5Y.js";import{n as v,r as y}from"./analytics-DqMQntaB.js";import{a as b,n as x}from"./env-C2A9gV_G.js";import{Jy as S,Uy as C,Wy as w,aS as T,oS as E}from"./loadAgentsDir-C_wFhytF.js";import{t as D}from"./useKeybinding-DPOUuymz.js";import{c as O,i as k,s as A}from"./terminalSetup-C1X-sXwp.js";import{n as j,t as M}from"./useExitOnCtrlCDWithKeybindings-BHi41Ku_.js";import{t as N}from"./WelcomeV2-BijS6i2Z.js";import{n as P,t as F}from"./ThemePicker-DKmIL5Ku.js";import{n as I,t as L}from"./PressEnterToContinue-BJ58eCFC.js";import{t as R}from"./ApproveApiKey-CSz0291w.js";n();var z=e(a(),1),B=d();v(),b(),_(),f(),h(),D(),k(),M(),l(),l(),S(),E(),w(),P(),I(),l();var V=(0,z.createContext)({marker:``});function H({children:e}){let{marker:t}=(0,z.useContext)(V);return(0,B.jsxs)(u,{gap:1,children:[(0,B.jsx)(s,{dimColor:!0,children:t}),(0,B.jsx)(u,{flexDirection:`column`,children:e})]})}l();var U=(0,z.createContext)({marker:``});function W({children:e}){let{marker:t}=(0,z.useContext)(U),n=0;for(let t of z.Children.toArray(e))!(0,z.isValidElement)(t)||t.type!==H||n++;let r=String(n).length;return(0,B.jsx)(u,{flexDirection:`column`,children:z.Children.map(e,(e,n)=>{if(!(0,z.isValidElement)(e)||e.type!==H)return e;let i=`${t}${`${String(n+1).padStart(r)}.`}`;return(0,B.jsx)(U.Provider,{value:{marker:i},children:(0,B.jsx)(V.Provider,{value:{marker:i},children:e})})})})}W.Item=H;var G=W;l();function K({onDone:e}){let[n,a]=(0,z.useState)(0),[l,d]=(0,z.useState)(!1),[f]=(0,z.useState)(()=>m()),[h,_]=o();(0,z.useEffect)(()=>{y(`tengu_began_setup`,{oauthEnabled:f})},[f]);function v(){if(n<M.length-1){let e=n+1;a(e),y(`tengu_onboarding_step`,{oauthEnabled:f,stepId:M[e]?.id})}else e()}function b(e){_(e),v()}let S=j(),w=(0,B.jsx)(u,{marginX:1,children:(0,B.jsx)(F,{onThemeSelect:b,showIntroText:!0,helpText:`To change this later, run /theme`,hideEscToCancel:!0,skipExitHandling:!0})}),E=(0,B.jsxs)(u,{flexDirection:`column`,gap:1,paddingLeft:1,children:[(0,B.jsx)(s,{bold:!0,children:`Before you start, keep in mind:`}),(0,B.jsx)(u,{flexDirection:`column`,width:70,children:(0,B.jsxs)(G,{children:[(0,B.jsxs)(G.Item,{children:[(0,B.jsx)(s,{children:`Always review changes before accepting`}),(0,B.jsxs)(s,{dimColor:!0,wrap:`wrap`,children:[`Claude can make mistakes — especially when running commands`,(0,B.jsx)(r,{}),`or editing files. You stay in control of every action.`,(0,B.jsx)(r,{})]})]}),(0,B.jsxs)(G.Item,{children:[(0,B.jsx)(s,{children:`Only use Claude Code on projects you trust`}),(0,B.jsxs)(s,{dimColor:!0,wrap:`wrap`,children:[`Untrusted code could contain prompt injection attacks.`,(0,B.jsx)(r,{}),(0,B.jsx)(i,{url:`https://code.claude.com/docs/en/security`})]})]})]})}),(0,B.jsx)(L,{})]}),D=(0,z.useMemo)(()=>{if(!process.env.ANTHROPIC_API_KEY||t())return``;let e=p(process.env.ANTHROPIC_API_KEY);if(g(e)===`new`)return e},[]);function k(e){e&&d(!0),v()}let M=[];M.push({id:`theme`,component:w}),D&&M.push({id:`api-key`,component:(0,B.jsx)(R,{customApiKeyTruncated:D,onDone:k})}),f&&M.push({id:`oauth`,component:(0,B.jsx)(q,{skip:l,onSkip:v,children:(0,B.jsx)(C,{onDone:v})})}),M.push({id:`security`,component:E}),O()&&M.push({id:`terminal-setup`,component:(0,B.jsxs)(u,{flexDirection:`column`,gap:1,paddingLeft:1,children:[(0,B.jsx)(s,{bold:!0,children:`Use Claude Code's terminal setup?`}),(0,B.jsxs)(u,{flexDirection:`column`,width:70,gap:1,children:[(0,B.jsxs)(s,{children:[`For the optimal coding experience, enable the recommended settings`,(0,B.jsx)(r,{}),`for your terminal:`,` `,x.terminal===`Apple_Terminal`?`Option+Enter for newlines and visual bell`:`Shift+Enter for newlines`]}),(0,B.jsx)(T,{options:[{label:`Yes, use recommended settings`,value:`install`},{label:`No, maybe later with /terminal-setup`,value:`no`}],onChange:e=>{e===`install`?A(h).catch(()=>{}).finally(v):v()},onCancel:()=>v()}),(0,B.jsx)(s,{dimColor:!0,children:S.pending?(0,B.jsxs)(B.Fragment,{children:[`Press `,S.keyName,` again to exit`]}):(0,B.jsx)(B.Fragment,{children:`Enter to confirm · Esc to skip`})})]})]})});let P=M[n],I=(0,z.useCallback)(()=>{n===M.length-1?e():v()},[n,M.length,f,e]),V=(0,z.useCallback)(()=>{v()},[n,M.length,f,e]);return c({"confirm:yes":I},{context:`Confirmation`,isActive:P?.id===`security`}),c({"confirm:no":V},{context:`Confirmation`,isActive:P?.id===`terminal-setup`}),(0,B.jsxs)(u,{flexDirection:`column`,children:[(0,B.jsx)(N,{}),(0,B.jsxs)(u,{flexDirection:`column`,marginTop:1,children:[P?.component,S.pending&&(0,B.jsx)(u,{padding:1,children:(0,B.jsxs)(s,{dimColor:!0,children:[`Press `,S.keyName,` again to exit`]})})]})]})}function q({skip:e,onSkip:t,children:n}){return(0,z.useEffect)(()=>{e&&t()},[e,t]),e?null:n}export{K as Onboarding};