import{u5 as L,v5 as H}from"./chunks/cli-0.5.3-nhm4rp4m.mjs";import{Vba as _,Zba as $,_ba as j,cca as B,fca as q,ica as G,lca as C}from"./chunks/cli-0.5.3-t65dek0m.mjs";import"./chunks/cli-0.5.3-kavpx97n.mjs";import"./chunks/cli-0.5.3-9bdwhdys.mjs";import"./chunks/cli-0.5.3-ttc72eq3.mjs";import"./chunks/cli-0.5.3-g75gdzrp.mjs";import"./chunks/cli-0.5.3-1rg2r7n7.mjs";import"./chunks/cli-0.5.3-6j2jk6dt.mjs";import"./chunks/cli-0.5.3-66650sba.mjs";import"./chunks/cli-0.5.3-9vh3vpap.mjs";import"./chunks/cli-0.5.3-n3cxyxpg.mjs";import"./chunks/cli-0.5.3-kbvzmaax.mjs";import{cga as Z,kga as F}from"./chunks/cli-0.5.3-7wdgps7z.mjs";import"./chunks/cli-0.5.3-c8bcrqa4.mjs";import"./chunks/cli-0.5.3-qrvd6cmy.mjs";import"./chunks/cli-0.5.3-2dk1sk8w.mjs";import{Yma as J}from"./chunks/cli-0.5.3-0df3r78b.mjs";C();q();F();H();var V=["ghp_","gho_","ghs_","ghr_","github_pat_"];function W(A,K="copilot"){if(V.some((w)=>A.startsWith(w))){if(K==="copilot")return"expired";return"valid"}let D=A.match(/exp=(\d+)/);if(D){let w=Number(D[1]);if(!Number.isNaN(w))return Date.now()>=w*1000?"expired":"valid"}let O=A.split(".");if(O.length===3&&O.every((w)=>/^[A-Za-z0-9_-]+$/.test(w)))try{let w=O[1].replace(/-/g,"+").replace(/_/g,"/"),N=w+"=".repeat((4-w.length%4)%4),U=Buffer.from(N,"base64").toString("utf8"),R=JSON.parse(U);if(R&&typeof R==="object"&&R.exp)return Date.now()>=R.exp*1000?"expired":"valid"}catch{return"invalid_format"}return"valid"}async function b(A,K){let D=G();if(!D)return null;if(D.transport==="gemini"){if((await(K?.resolveGeminiCredential??L)(process.env)).kind==="none")return"Configure Gemini auth via /provider — pick API key, access token, or rely on Google ADC.";return null}if(D.transport==="github_copilot"){let Q=D.extras?.githubToken?.trim()||D.apiKey?.trim()||"";if(!Q)return`GitHub Copilot authentication required.
Run /provider and choose GitHub Copilot.`;let w=$(D.baseUrl),N=W(Q,w);if(N==="expired")return`GitHub Copilot token has expired.
Run /provider and choose GitHub Copilot.`;if(N==="invalid_format")return`GitHub Copilot token is invalid or corrupted.
Run /provider and choose GitHub Copilot.`;return null}if(D.transport!=="openai_compat"&&D.transport!=="codex_responses")return null;let O=j({model:D.model,baseUrl:D.baseUrl});if(D.apiKey==="SUA_CHAVE")return"Invalid API key: placeholder value SUA_CHAVE detected. Set a real key in /provider, or leave blank for local providers.";if(O.transport==="codex_responses"){let Q=B();if(!Q.apiKey){let w=Z()?"":", choose Codex OAuth in /provider",N=Q.authPath?`${w} or put auth.json at ${Q.authPath}`:w;return`Codex auth is required for ${O.requestedModel}. Configure it via /provider${N}.`}if(!Q.accountId)return"Codex auth is missing chatgpt_account_id. Re-login with Codex OAuth via /provider, or import an auth.json with chatgpt_account_id.";return null}if(!D.apiKey&&!_(O.baseUrl))return"API key required for the active /provider profile. Run /provider to set it.";return null}function I(A={}){let K=A.args??process.argv.slice(2);if(!(A.stdoutIsTTY??process.stdout.isTTY))return!0;return K.includes("-p")||K.includes("--print")||K.includes("--init-only")||K.some((O)=>O.startsWith("--sdk-url"))}async function z(A=process.env,K){let D=await b(A);if(!D)return;if(I(K))console.error(D),process.exit(1);console.error(`Warning: provider configuration is incomplete.
${D}
Claudio will continue starting so you can run /provider and repair the saved provider settings.`)}if(typeof globalThis.File>"u")try{let{File:A}=J("node:buffer");globalThis.File=A}catch{globalThis.File=class extends Blob{name;lastModified;constructor(K,D,O){super(K,O);this.name=D,this.lastModified=O?.lastModified??Date.now()}}}if(typeof Promise.withResolvers!=="function")Promise.withResolvers=function(){let K=()=>{},D=()=>{};return{promise:new Promise((Q,w)=>{K=Q,D=w}),resolve:K,reject:D}};{let A=J("node:util");if(typeof A.markAsUncloneable!=="function")A.markAsUncloneable=()=>{}}process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS??="true";process.env.CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING??="1";process.env.COREPACK_ENABLE_AUTO_PIN="0";if(process.env.CLAUDE_CODE_REMOTE==="true"){let A=process.env.NODE_OPTIONS||"";process.env.NODE_OPTIONS=A?`${A} --max-old-space-size=8192`:"--max-old-space-size=8192"}async function P(){let A=process.argv.slice(2);if(A.length===1&&(A[0]==="--version"||A[0]==="-v"||A[0]==="-V")){console.log("0.5.3 (Claudio)");return}if(A.includes("--provider"))console.error('The --provider CLI flag was removed. Run "claudio" and use /provider to choose a profile.'),process.exit(1);{let{enableConfigs:w}=await import("./chunks/config-0.5.3-36ecyxr9.mjs");w()}{let{applySafeConfigEnvironmentVariables:w}=await import("./chunks/managedEnv-0.5.3-tg1tbd8m.mjs");w()}(async()=>{let{runStartupUpdateCheck:w}=await import("./chunks/startupUpdateCheck-0.5.3-k9wd7skc.mjs");await w(A)})();{let{hydrateGithubModelsTokenFromSecureStorage:w,refreshGithubModelsTokenIfNeeded:N}=await import("./chunks/githubModelsCredentials-0.5.3-h9xysfsw.mjs");await N(),w()}await z();let{tryGetActiveProvider:K}=await import("./chunks/activeProvider-0.5.3-7tn5hxnj.mjs");if(K()&&process.stdout.isTTY&&process.env.CLAUDIO_CLEAR_ON_START==="1"){let{clearTerminal:w}=await import("./chunks/clearTerminal-0.5.3-maxkpg47.mjs");process.stdout.write(w)}let{profileCheckpoint:D}=await import("./chunks/startupProfiler-0.5.3-dhxqyect.mjs");if(D("cli_entry"),A[0]==="--dump-system-prompt"){D("cli_dump_system_prompt_path");let{enableConfigs:w}=await import("./chunks/config-0.5.3-36ecyxr9.mjs");w();let{getMainLoopModel:N}=await import("./chunks/model-0.5.3-y8mjx4bv.mjs"),U=A.indexOf("--model"),R=U!==-1&&A[U+1]||N(),{getSystemPrompt:X}=await import("./chunks/prompts-0.5.3-8zpq5d7c.mjs"),Y=await X([],R);console.log(Y.join(`
`));return}if(!1)switch(A[0]){case"ps":case"logs":case"attach":case"kill":default:}if((A.includes("--tmux")||A.includes("--tmux=classic"))&&(A.includes("-w")||A.includes("--worktree")||A.some((w)=>w.startsWith("--worktree=")))){D("cli_tmux_worktree_fast_path");let{enableConfigs:w}=await import("./chunks/config-0.5.3-36ecyxr9.mjs");w();let{isWorktreeModeEnabled:N}=await import("./chunks/worktreeModeEnabled-0.5.3-bgybaqfq.mjs");if(N()){let{execIntoTmuxWorktree:U}=await import("./chunks/worktree-0.5.3-ggj1vt6g.mjs"),R=await U(A);if(R.handled)return;if(R.error){let{exitWithError:X}=await import("./chunks/process-0.5.3-j65nb7pq.mjs");X(R.error)}}}if(A.length===1&&(A[0]==="--update"||A[0]==="--upgrade"))process.argv=[process.argv[0],process.argv[1],"update"];if(A.includes("--bare"))process.env.CLAUDE_CODE_SIMPLE="1";if(process.env.CLAUDIO_DISABLE_EARLY_INPUT!=="1"){let{startCapturingEarlyInput:w}=await import("./chunks/earlyInput-0.5.3-28qnjskq.mjs");w()}D("cli_before_main_import");let{main:Q}=await import("./chunks/main-0.5.3-qzfycb0w.mjs");D("cli_after_main_import"),await Q(),D("cli_after_main_complete")}P();
