import{DD as R0,ED as _f,FD as qf,HD as jf,Vl as d0,Wl as w0,Xl as B0,Yl as vf,Zl as U0,_l as Of,aE as Hf,bE as Sf,bm as c0,cm as lf,iF as H0,jF as nf,vD as t,wD as G0}from"./cli-0.5.3-jbzr8k4s.mjs";import"./cli-0.5.3-me9jkw92.mjs";import"./cli-0.5.3-bqmztzjc.mjs";import"./cli-0.5.3-ytqxzjff.mjs";import"./cli-0.5.3-h6n812td.mjs";import"./cli-0.5.3-hg8c6qbh.mjs";import"./cli-0.5.3-39jr2yrx.mjs";import"./cli-0.5.3-42e2paz8.mjs";import"./cli-0.5.3-mn45xfck.mjs";import"./cli-0.5.3-m884a3pk.mjs";import"./cli-0.5.3-4f9xxrem.mjs";import"./cli-0.5.3-gr8nsa2k.mjs";import"./cli-0.5.3-yj9nbd9d.mjs";import"./cli-0.5.3-55kd38ff.mjs";import"./cli-0.5.3-e6bjcfwg.mjs";import"./cli-0.5.3-4dbxtwh3.mjs";import"./cli-0.5.3-m0kfmb79.mjs";import{xT as Ef,yT as fq}from"./cli-0.5.3-8zq9vdtg.mjs";import"./cli-0.5.3-vmx7agj7.mjs";import"./cli-0.5.3-h8xs2818.mjs";import"./cli-0.5.3-wcx7cnw5.mjs";import"./cli-0.5.3-9zbakvbf.mjs";import{LU as z0,MU as s,NU as J0,xU as e,yU as D0}from"./cli-0.5.3-hx550gz2.mjs";import{GW as f0,IW as Q,KW as X,OW as L0,jV as zf,nX as j,oV as of,pV as r,yV as I0}from"./cli-0.5.3-842pf3t4.mjs";import"./cli-0.5.3-wxead1ct.mjs";import"./cli-0.5.3-s1hz35ye.mjs";import"./cli-0.5.3-g0svn6bx.mjs";import"./cli-0.5.3-sfdh3pkx.mjs";import"./cli-0.5.3-d8tjnxcj.mjs";import"./cli-0.5.3-6zfw1732.mjs";import"./cli-0.5.3-ptjdgcsy.mjs";import"./cli-0.5.3-tp3jye12.mjs";import{MY as T,NY as d,OY as I,PY as g}from"./cli-0.5.3-vqmxwet2.mjs";import{QY as Y0}from"./cli-0.5.3-rch86nhn.mjs";import"./cli-0.5.3-zg2apr51.mjs";import"./cli-0.5.3-ngnshpb7.mjs";import"./cli-0.5.3-e58xste9.mjs";import{lZ as V0,mZ as Uf}from"./cli-0.5.3-6163zevg.mjs";import"./cli-0.5.3-jmkkd5ph.mjs";import{A2 as Nf,_2 as Gf,y2 as y0,z3 as Mf}from"./cli-0.5.3-1vt6twff.mjs";import"./cli-0.5.3-7017ez65.mjs";import"./cli-0.5.3-ea94acj4.mjs";import"./cli-0.5.3-3k22nqvy.mjs";import"./cli-0.5.3-63q4g3zt.mjs";import"./cli-0.5.3-dyhbm5kp.mjs";import"./cli-0.5.3-vpcrbd8n.mjs";import"./cli-0.5.3-jdw3ajfv.mjs";import"./cli-0.5.3-qg4a557t.mjs";import{Caa as Bf,G7 as gf,H6 as Df,I6 as M0,J6 as Jf,K7 as ef,M6 as m0,N6 as sf,P6 as o,R6 as wf,X_ as kf,Yaa as af,d$ as tf,z6 as Q0}from"./cli-0.5.3-t65dek0m.mjs";import"./cli-0.5.3-kavpx97n.mjs";import"./cli-0.5.3-9bdwhdys.mjs";import"./cli-0.5.3-ttc72eq3.mjs";import"./cli-0.5.3-g75gdzrp.mjs";import"./cli-0.5.3-1rg2r7n7.mjs";import"./cli-0.5.3-6j2jk6dt.mjs";import"./cli-0.5.3-66650sba.mjs";import{Lea as R,Nea as F0}from"./cli-0.5.3-9vh3vpap.mjs";import"./cli-0.5.3-n3cxyxpg.mjs";import"./cli-0.5.3-kbvzmaax.mjs";import"./cli-0.5.3-7wdgps7z.mjs";import"./cli-0.5.3-c8bcrqa4.mjs";import"./cli-0.5.3-qrvd6cmy.mjs";import"./cli-0.5.3-2dk1sk8w.mjs";import{Tma as _,Xma as h}from"./cli-0.5.3-0df3r78b.mjs";function hf(W){if(W.pending)return I(X,{children:["Press ",W.keyName," again to exit"]});return I(U0,{children:[d(d0,{shortcut:"↑↓",action:"navigate"}),d(d0,{shortcut:"Space",action:"toggle"}),d(d0,{shortcut:"Enter",action:"confirm"}),d(B0,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancel"})]})}function A0(W){let f=C0.c(14),{onSubmit:q,defaultSelections:Y}=W,[D,z]=K0.useState(!1),M;if(f[0]!==q)M=(N)=>{if(N.length===0){z(!0);return}z(!1),q(N)},f[0]=q,f[1]=M;else M=f[1];let L=M,H;if(f[2]===Symbol.for("react.memo_cache_sentinel"))H=()=>{z(!1)},f[2]=H;else H=f[2];let V=H,Z;if(f[3]===Symbol.for("react.memo_cache_sentinel"))Z=()=>{z(!0)},f[3]=Z;else Z=f[3];let F=Z,y;if(f[4]===Symbol.for("react.memo_cache_sentinel"))y=d(Q,{children:I(X,{dimColor:!0,children:["More workflow examples (issue triage, CI fixes, etc.) at:"," ",d(L0,{url:"https://github.com/anthropics/claude-code-action/blob/main/examples/",children:"https://github.com/anthropics/claude-code-action/blob/main/examples/"})]})}),f[4]=y;else y=f[4];let m;if(f[5]===Symbol.for("react.memo_cache_sentinel"))m=Tf.map(pf),f[5]=m;else m=f[5];let b;if(f[6]!==Y||f[7]!==L)b=d(R0,{options:m,defaultValue:Y,onSubmit:L,onChange:V,onCancel:F,hideIndexes:!0}),f[6]=Y,f[7]=L,f[8]=b;else b=f[8];let P;if(f[9]!==D)P=D&&d(Q,{children:d(X,{color:"error",children:"You must select at least one workflow to continue"})}),f[9]=D,f[10]=P;else P=f[10];let C;if(f[11]!==b||f[12]!==P)C=I(c0,{title:"Select GitHub workflows to install",subtitle:"We'll create a workflow file in your repository for each one you select.",onCancel:F,inputGuide:hf,children:[y,b,P]}),f[11]=b,f[12]=P,f[13]=C;else C=f[13];return C}function pf(W){return{label:W.label,value:W.value}}var C0,K0,Tf;var g0=h(()=>{j();vf();_f();Of();lf();w0();g();C0=_(r(),1),K0=_(Y0(),1),Tf=[{value:"claude",label:"@Claude Code - Tag @claude in issues and PR comments"},{value:"claude-review",label:"Claude Code Review - Automated code review on new PRs"}]});var k0="Add Claude Code GitHub Workflow",x="https://github.com/anthropics/claude-code-action/blob/main/docs/setup.md",N0=`name: Claude Code

on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]
  issues:
    types: [opened, assigned]
  pull_request_review:
    types: [submitted]

jobs:
  claude:
    if: |
      (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
      (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
      (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
      (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: read
      issues: read
      id-token: write
      actions: read # Required for Claude to read CI results on PRs
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Run Claude Code
        id: claude
        uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: \${{ secrets.ANTHROPIC_API_KEY }}

          # This is an optional setting that allows Claude to read CI results on PRs
          additional_permissions: |
            actions: read

          # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
          # prompt: 'Update the pull request description to include a summary of changes.'

          # Optional: Add claude_args to customize behavior and configuration
          # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
          # or https://code.claude.com/docs/en/cli-reference for available options
          # claude_args: '--allowed-tools Bash(gh pr:*)'

`,E0=`## \uD83E\uDD16 Installing Claude Code GitHub App

This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.

### What is Claude Code?

[Claude Code](https://claude.com/claude-code) is an AI coding agent that can help with:
- Bug fixes and improvements  
- Documentation updates
- Implementing new features
- Code reviews and suggestions
- Writing tests
- And more!

### How it works

Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.
Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action.

### Important Notes

- **This workflow won't take effect until this PR is merged**
- **@claude mentions won't work until after the merge is complete**
- The workflow runs automatically whenever Claude is mentioned in PR or issue comments
- Claude gets access to the entire PR or issue context including files, diffs, and previous comments

### Security

- Our Anthropic API key is securely stored as a GitHub Actions secret
- Only users with write access to the repository can trigger the workflow
- All Claude runs are stored in the GitHub Actions run history
- Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits.
- We can add more allowed tools by adding them to the workflow file like:

\`\`\`
allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test)
\`\`\`

There's more information in the [Claude Code action repo](https://github.com/anthropics/claude-code-action).

After merging this PR, let's try mentioning @claude in a comment on any PR to get started!`,v0=`name: Claude Code Review

on:
  pull_request:
    types: [opened, synchronize, ready_for_review, reopened]
    # Optional: Only run on specific file changes
    # paths:
    #   - "src/**/*.ts"
    #   - "src/**/*.tsx"
    #   - "src/**/*.js"
    #   - "src/**/*.jsx"

jobs:
  claude-review:
    # Optional: Filter by PR author
    # if: |
    #   github.event.pull_request.user.login == 'external-contributor' ||
    #   github.event.pull_request.user.login == 'new-developer' ||
    #   github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'

    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: read
      issues: read
      id-token: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Run Claude Code Review
        id: claude-review
        uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: \${{ secrets.ANTHROPIC_API_KEY }}
          plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
          plugins: 'code-review@claude-code-plugins'
          prompt: '/code-review:code-review \${{ github.repository }}/pull/\${{ github.event.pull_request.number }}'
          # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
          # or https://code.claude.com/docs/en/cli-reference for available options

`;var X0=()=>{};function _0(W){let f=O0.c(55),{existingApiKey:q,apiKeyOrOAuthToken:Y,onApiKeyChange:D,onSubmit:z,onToggleUseExistingKey:M,onCreateOAuthToken:L,selectedOption:H,onSelectOption:V}=W,Z=H===void 0?q?"existing":L?"oauth":"new":H,[F,y]=l0.useState(0),m=e(),[b]=I0(),P;if(f[0]!==q||f[1]!==L||f[2]!==V||f[3]!==M||f[4]!==Z)P=()=>{if(Z==="new"&&L)V?.("oauth");else if(Z==="oauth"&&q)V?.("existing"),M(!0)},f[0]=q,f[1]=L,f[2]=V,f[3]=M,f[4]=Z,f[5]=P;else P=f[5];let C=P,N;if(f[6]!==L||f[7]!==V||f[8]!==M||f[9]!==Z)N=()=>{if(Z==="existing")V?.(L?"oauth":"new"),M(!1);else if(Z==="oauth")V?.("new")},f[6]=L,f[7]=V,f[8]=M,f[9]=Z,f[10]=N;else N=f[10];let E=N,v;if(f[11]!==L||f[12]!==z||f[13]!==Z)v=()=>{if(Z==="oauth"&&L)L();else z()},f[11]=L,f[12]=z,f[13]=Z,f[14]=v;else v=f[14];let O=v,B=Z==="new",K;if(f[15]!==O||f[16]!==E||f[17]!==C)K={"confirm:previous":C,"confirm:next":E,"confirm:yes":O},f[15]=O,f[16]=E,f[17]=C,f[18]=K;else K=f[18];let J=!B,G;if(f[19]!==J)G={context:"Confirmation",isActive:J},f[19]=J,f[20]=G;else G=f[20];s(K,G);let w;if(f[21]!==E||f[22]!==C)w={"confirm:previous":C,"confirm:next":E},f[21]=E,f[22]=C,f[23]=w;else w=f[23];let U;if(f[24]!==B)U={context:"Confirmation",isActive:B},f[24]=B,f[25]=U;else U=f[25];s(w,U);let c;if(f[26]===Symbol.for("react.memo_cache_sentinel"))c=I(Q,{flexDirection:"column",marginBottom:1,children:[d(X,{bold:!0,children:"Install GitHub App"}),d(X,{dimColor:!0,children:"Choose API key"})]}),f[26]=c;else c=f[26];let k;if(f[27]!==q||f[28]!==Z||f[29]!==b)k=q&&d(Q,{marginBottom:1,children:I(X,{children:[Z==="existing"?f0("success",b)("> "):"  ","Use your existing Claude Code API key"]})}),f[27]=q,f[28]=Z,f[29]=b,f[30]=k;else k=f[30];let A;if(f[31]!==L||f[32]!==Z||f[33]!==b)A=L&&d(Q,{marginBottom:1,children:I(X,{children:[Z==="oauth"?f0("success",b)("> "):"  ","Create a long-lived token with your Claude subscription"]})}),f[31]=L,f[32]=Z,f[33]=b,f[34]=A;else A=f[34];let l;if(f[35]!==Z||f[36]!==b)l=Z==="new"?f0("success",b)("> "):"  ",f[35]=Z,f[36]=b,f[37]=l;else l=f[37];let $;if(f[38]!==l)$=d(Q,{marginBottom:1,children:I(X,{children:[l,"Enter a new API key"]})}),f[38]=l,f[39]=$;else $=f[39];let p;if(f[40]!==Y||f[41]!==F||f[42]!==D||f[43]!==z||f[44]!==Z||f[45]!==m)p=Z==="new"&&d(t,{value:Y,onChange:D,onSubmit:z,onPaste:D,focus:!0,placeholder:"sk-ant… (Create a new key at https://platform.claude.com/settings/keys)",mask:"*",columns:m.columns,cursorOffset:F,onChangeCursorOffset:y,showCursor:!0}),f[40]=Y,f[41]=F,f[42]=D,f[43]=z,f[44]=Z,f[45]=m,f[46]=p;else p=f[46];let u;if(f[47]!==k||f[48]!==A||f[49]!==$||f[50]!==p)u=I(Q,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[c,k,A,$,p]}),f[47]=k,f[48]=A,f[49]=$,f[50]=p,f[51]=u;else u=f[51];let n;if(f[52]===Symbol.for("react.memo_cache_sentinel"))n=d(Q,{marginLeft:3,children:d(X,{dimColor:!0,children:"↑/↓ to select · Enter to continue"})}),f[52]=n;else n=f[52];let a;if(f[53]!==u)a=I(T,{children:[u,n]}),f[53]=u,f[54]=a;else a=f[54];return a}var O0,l0;var T0=h(()=>{G0();D0();j();J0();g();O0=_(r(),1),l0=_(Y0(),1)});function p0(W){let f=i0.c(42),{useExistingSecret:q,secretName:Y,onToggleUseExistingSecret:D,onSecretNameChange:z,onSubmit:M}=W,[L,H]=h0.useState(0),V=e(),[Z]=I0(),F;if(f[0]!==D)F=()=>D(!0),f[0]=D,f[1]=F;else F=f[1];let y=F,m;if(f[2]!==D)m=()=>D(!1),f[2]=D,f[3]=m;else m=f[3];let b=m,P;if(f[4]!==b||f[5]!==y||f[6]!==M)P={"confirm:previous":y,"confirm:next":b,"confirm:yes":M},f[4]=b,f[5]=y,f[6]=M,f[7]=P;else P=f[7];let C;if(f[8]!==q)C={context:"Confirmation",isActive:q},f[8]=q,f[9]=C;else C=f[9];s(P,C);let N;if(f[10]!==b||f[11]!==y)N={"confirm:previous":y,"confirm:next":b},f[10]=b,f[11]=y,f[12]=N;else N=f[12];let E=!q,v;if(f[13]!==E)v={context:"Confirmation",isActive:E},f[13]=E,f[14]=v;else v=f[14];s(N,v);let O;if(f[15]===Symbol.for("react.memo_cache_sentinel"))O=I(Q,{flexDirection:"column",marginBottom:1,children:[d(X,{bold:!0,children:"Install GitHub App"}),d(X,{dimColor:!0,children:"Setup API key secret"})]}),f[15]=O;else O=f[15];let B;if(f[16]===Symbol.for("react.memo_cache_sentinel"))B=d(Q,{marginBottom:1,children:d(X,{color:"warning",children:"ANTHROPIC_API_KEY already exists in repository secrets!"})}),f[16]=B;else B=f[16];let K;if(f[17]===Symbol.for("react.memo_cache_sentinel"))K=d(Q,{marginBottom:1,children:d(X,{children:"Would you like to:"})}),f[17]=K;else K=f[17];let J;if(f[18]!==Z||f[19]!==q)J=q?f0("success",Z)("> "):"  ",f[18]=Z,f[19]=q,f[20]=J;else J=f[20];let G;if(f[21]!==J)G=d(Q,{marginBottom:1,children:I(X,{children:[J,"Use the existing API key"]})}),f[21]=J,f[22]=G;else G=f[22];let w;if(f[23]!==Z||f[24]!==q)w=!q?f0("success",Z)("> "):"  ",f[23]=Z,f[24]=q,f[25]=w;else w=f[25];let U;if(f[26]!==w)U=d(Q,{marginBottom:1,children:I(X,{children:[w,"Create a new secret with a different name"]})}),f[26]=w,f[27]=U;else U=f[27];let c;if(f[28]!==L||f[29]!==z||f[30]!==M||f[31]!==Y||f[32]!==V||f[33]!==q)c=!q&&I(T,{children:[d(Q,{marginBottom:1,children:d(X,{children:"Enter new secret name (alphanumeric with underscores):"})}),d(t,{value:Y,onChange:z,onSubmit:M,focus:!0,placeholder:"e.g., CLAUDE_API_KEY",columns:V.columns,cursorOffset:L,onChangeCursorOffset:H,showCursor:!0})]}),f[28]=L,f[29]=z,f[30]=M,f[31]=Y,f[32]=V,f[33]=q,f[34]=c;else c=f[34];let k;if(f[35]!==G||f[36]!==U||f[37]!==c)k=I(Q,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[O,B,K,G,U,c]}),f[35]=G,f[36]=U,f[37]=c,f[38]=k;else k=f[38];let A;if(f[39]===Symbol.for("react.memo_cache_sentinel"))A=d(Q,{marginLeft:3,children:d(X,{dimColor:!0,children:"↑/↓ to select · Enter to continue"})}),f[39]=A;else A=f[39];let l;if(f[40]!==k)l=I(T,{children:[k,A]}),f[40]=k,f[41]=l;else l=f[41];return l}var i0,h0;var u0=h(()=>{G0();D0();j();J0();g();i0=_(r(),1),h0=_(Y0(),1)});function o0(){let W=j0.c(1),f;if(W[0]===Symbol.for("react.memo_cache_sentinel"))f=d(X,{children:"Checking GitHub CLI installation…"}),W[0]=f;else f=W[0];return f}var j0;var S0=h(()=>{j();g();j0=_(r(),1)});function a0(W){let f=n0.c(49),{currentRepo:q,useCurrentRepo:Y,repoUrl:D,onRepoUrlChange:z,onSubmit:M,onToggleUseCurrentRepo:L}=W,[H,V]=W0.useState(0),[Z,F]=W0.useState(!1),m=e().columns,b;if(f[0]!==q||f[1]!==M||f[2]!==D||f[3]!==Y)b=()=>{if(!(Y?q:D)?.trim()){F(!0);return}M()},f[0]=q,f[1]=M,f[2]=D,f[3]=Y,f[4]=b;else b=f[4];let P=b,C=!Y||!q,N;if(f[5]!==L)N=()=>{L(!0),F(!1)},f[5]=L,f[6]=N;else N=f[6];let E=N,v;if(f[7]!==L)v=()=>{L(!1),F(!1)},f[7]=L,f[8]=v;else v=f[8];let O=v,B;if(f[9]!==O||f[10]!==E||f[11]!==P)B={"confirm:previous":E,"confirm:next":O,"confirm:yes":P},f[9]=O,f[10]=E,f[11]=P,f[12]=B;else B=f[12];let K=!C,J;if(f[13]!==K)J={context:"Confirmation",isActive:K},f[13]=K,f[14]=J;else J=f[14];s(B,J);let G;if(f[15]!==O||f[16]!==E)G={"confirm:previous":E,"confirm:next":O},f[15]=O,f[16]=E,f[17]=G;else G=f[17];let w;if(f[18]!==C)w={context:"Confirmation",isActive:C},f[18]=C,f[19]=w;else w=f[19];s(G,w);let U;if(f[20]===Symbol.for("react.memo_cache_sentinel"))U=I(Q,{flexDirection:"column",marginBottom:1,children:[d(X,{bold:!0,children:"Install GitHub App"}),d(X,{dimColor:!0,children:"Select GitHub repository"})]}),f[20]=U;else U=f[20];let c;if(f[21]!==q||f[22]!==Y)c=q&&d(Q,{marginBottom:1,children:I(X,{bold:Y,color:Y?"permission":void 0,children:[Y?"> ":"  ","Use current repository: ",q]})}),f[21]=q,f[22]=Y,f[23]=c;else c=f[23];let k=!Y||!q,A=!Y||!q?"permission":void 0,l=!Y||!q?"> ":"  ",$=q?"Enter a different repository":"Enter repository",p;if(f[24]!==k||f[25]!==A||f[26]!==l||f[27]!==$)p=d(Q,{marginBottom:1,children:I(X,{bold:k,color:A,children:[l,$]})}),f[24]=k,f[25]=A,f[26]=l,f[27]=$,f[28]=p;else p=f[28];let u;if(f[29]!==q||f[30]!==H||f[31]!==P||f[32]!==z||f[33]!==D||f[34]!==m||f[35]!==Y)u=(!Y||!q)&&d(Q,{marginLeft:2,marginBottom:1,children:d(t,{value:D,onChange:(P0)=>{z(P0),F(!1)},onSubmit:P,focus:!0,placeholder:"Enter a repo as owner/repo or https://github.com/owner/repo…",columns:m,cursorOffset:H,onChangeCursorOffset:V,showCursor:!0})}),f[29]=q,f[30]=H,f[31]=P,f[32]=z,f[33]=D,f[34]=m,f[35]=Y,f[36]=u;else u=f[36];let n;if(f[37]!==c||f[38]!==p||f[39]!==u)n=I(Q,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[U,c,p,u]}),f[37]=c,f[38]=p,f[39]=u,f[40]=n;else n=f[40];let a;if(f[41]!==Z)a=Z&&d(Q,{marginLeft:3,marginBottom:1,children:d(X,{color:"error",children:"Please enter a repository name to continue"})}),f[41]=Z,f[42]=a;else a=f[42];let b0=q?"↑/↓ to select · ":"",q0;if(f[43]!==b0)q0=d(Q,{marginLeft:3,children:I(X,{dimColor:!0,children:[b0,"Enter to continue"]})}),f[43]=b0,f[44]=q0;else q0=f[44];let Z0;if(f[45]!==n||f[46]!==a||f[47]!==q0)Z0=I(T,{children:[n,a,q0]}),f[45]=n,f[46]=a,f[47]=q0,f[48]=Z0;else Z0=f[48];return Z0}var n0,W0;var r0=h(()=>{G0();D0();j();J0();g();n0=_(r(),1),W0=_(Y0(),1)});function x0(W){let f=$0.c(10),{currentWorkflowInstallStep:q,secretExists:Y,useExistingSecret:D,secretName:z,skipWorkflow:M,selectedWorkflows:L}=W,H=M===void 0?!1:M,V;if(f[0]!==Y||f[1]!==z||f[2]!==L||f[3]!==H||f[4]!==D)V=H?["Getting repository information",Y&&D?"Using existing API key secret":`Setting up ${z} secret`]:["Getting repository information","Creating branch",L.length>1?"Creating workflow files":"Creating workflow file",Y&&D?"Using existing API key secret":`Setting up ${z} secret`,"Opening pull request page"],f[0]=Y,f[1]=z,f[2]=L,f[3]=H,f[4]=D,f[5]=V;else V=f[5];let Z=V,F;if(f[6]===Symbol.for("react.memo_cache_sentinel"))F=I(Q,{flexDirection:"column",marginBottom:1,children:[d(X,{bold:!0,children:"Install GitHub App"}),d(X,{dimColor:!0,children:"Create GitHub Actions workflow"})]}),f[6]=F;else F=f[6];let y;if(f[7]!==q||f[8]!==Z)y=d(T,{children:I(Q,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[F,Z.map((m,b)=>{let P="pending";if(b<q)P="completed";else if(b===q)P="in-progress";return d(Q,{children:I(X,{color:P==="completed"?"success":P==="in-progress"?"warning":void 0,children:[P==="completed"?"✓ ":"",m,P==="in-progress"?"…":""]})},b)})]})}),f[7]=q,f[8]=Z,f[9]=y;else y=f[9];return y}var $0;var s0=h(()=>{j();g();$0=_(r(),1)});function t0(W){let f=e0.c(15),{error:q,errorReason:Y,errorInstructions:D}=W,z;if(f[0]===Symbol.for("react.memo_cache_sentinel"))z=d(Q,{flexDirection:"column",marginBottom:1,children:d(X,{bold:!0,children:"Install GitHub App"})}),f[0]=z;else z=f[0];let M;if(f[1]!==q)M=I(X,{color:"error",children:["Error: ",q]}),f[1]=q,f[2]=M;else M=f[2];let L;if(f[3]!==Y)L=Y&&d(Q,{marginTop:1,children:I(X,{dimColor:!0,children:["Reason: ",Y]})}),f[3]=Y,f[4]=L;else L=f[4];let H;if(f[5]!==D)H=D&&D.length>0&&I(Q,{flexDirection:"column",marginTop:1,children:[d(X,{dimColor:!0,children:"How to fix:"}),D.map(uf)]}),f[5]=D,f[6]=H;else H=f[6];let V;if(f[7]===Symbol.for("react.memo_cache_sentinel"))V=d(Q,{marginTop:1,children:I(X,{dimColor:!0,children:["For manual setup instructions, see:"," ",d(X,{color:"claude",children:x})]})}),f[7]=V;else V=f[7];let Z;if(f[8]!==M||f[9]!==L||f[10]!==H)Z=I(Q,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[z,M,L,H,V]}),f[8]=M,f[9]=L,f[10]=H,f[11]=Z;else Z=f[11];let F;if(f[12]===Symbol.for("react.memo_cache_sentinel"))F=d(Q,{marginLeft:3,children:d(X,{dimColor:!0,children:"Press any key to exit"})}),f[12]=F;else F=f[12];let y;if(f[13]!==Z)y=I(T,{children:[Z,F]}),f[13]=Z,f[14]=y;else y=f[14];return y}function uf(W,f){return I(Q,{marginLeft:2,children:[d(X,{dimColor:!0,children:"• "}),d(X,{children:W})]},f)}var e0;var ff=h(()=>{X0();j();g();e0=_(r(),1)});function Yf(W){let f=df.c(16),{repoName:q,onSelectAction:Y}=W,D;if(f[0]===Symbol.for("react.memo_cache_sentinel"))D=[{label:"Update workflow file with latest version",value:"update"},{label:"Skip workflow update (configure secrets only)",value:"skip"},{label:"Exit without making changes",value:"exit"}],f[0]=D;else D=f[0];let z=D,M;if(f[1]!==Y)M=(C)=>{Y(C)},f[1]=Y,f[2]=M;else M=f[2];let L=M,H;if(f[3]!==Y)H=()=>{Y("exit")},f[3]=Y,f[4]=H;else H=f[4];let V=H,Z;if(f[5]===Symbol.for("react.memo_cache_sentinel"))Z=d(X,{bold:!0,children:"Existing Workflow Found"}),f[5]=Z;else Z=f[5];let F;if(f[6]!==q)F=I(Q,{flexDirection:"column",marginBottom:1,children:[Z,I(X,{dimColor:!0,children:["Repository: ",q]})]}),f[6]=q,f[7]=F;else F=f[7];let y;if(f[8]===Symbol.for("react.memo_cache_sentinel"))y=I(Q,{flexDirection:"column",marginBottom:1,children:[I(X,{children:["A Claude workflow file already exists at"," ",d(X,{color:"claude",children:".github/workflows/claude.yml"})]}),d(X,{dimColor:!0,children:"What would you like to do?"})]}),f[8]=y;else y=f[8];let m;if(f[9]!==V||f[10]!==L)m=d(Q,{flexDirection:"column",children:d(qf,{options:z,onChange:L,onCancel:V})}),f[9]=V,f[10]=L,f[11]=m;else m=f[11];let b;if(f[12]===Symbol.for("react.memo_cache_sentinel"))b=d(Q,{marginTop:1,children:I(X,{dimColor:!0,children:["View the latest workflow template at:"," ",d(X,{color:"claude",children:"https://github.com/anthropics/claude-code-action/blob/main/examples/claude.yml"})]})}),f[12]=b;else b=f[12];let P;if(f[13]!==F||f[14]!==m)P=I(Q,{flexDirection:"column",borderStyle:"round",borderDimColor:!0,paddingX:1,children:[F,y,m,b]}),f[13]=F,f[14]=m,f[15]=P;else P=f[15];return P}var df;var Xf=h(()=>{jf();j();g();df=_(r(),1)});function Zf(W){let f=Qf.c(12),{repoUrl:q,onSubmit:Y}=W,D;if(f[0]===Symbol.for("react.memo_cache_sentinel"))D={context:"Confirmation"},f[0]=D;else D=f[0];z0("confirm:yes",Y,D);let z;if(f[1]===Symbol.for("react.memo_cache_sentinel"))z=d(Q,{flexDirection:"column",marginBottom:1,children:d(X,{bold:!0,children:"Install the Claude GitHub App"})}),f[1]=z;else z=f[1];let M;if(f[2]===Symbol.for("react.memo_cache_sentinel"))M=d(Q,{marginBottom:1,children:d(X,{children:"Opening browser to install the Claude GitHub App…"})}),f[2]=M;else M=f[2];let L;if(f[3]===Symbol.for("react.memo_cache_sentinel"))L=d(Q,{marginBottom:1,children:d(X,{children:"If your browser doesn't open automatically, visit:"})}),f[3]=L;else L=f[3];let H;if(f[4]===Symbol.for("react.memo_cache_sentinel"))H=d(Q,{marginBottom:1,children:d(X,{underline:!0,children:"https://github.com/apps/claude"})}),f[4]=H;else H=f[4];let V;if(f[5]!==q)V=d(Q,{marginBottom:1,children:I(X,{children:["Please install the app for repository: ",d(X,{bold:!0,children:q})]})}),f[5]=q,f[6]=V;else V=f[6];let Z;if(f[7]===Symbol.for("react.memo_cache_sentinel"))Z=d(Q,{marginBottom:1,children:d(X,{dimColor:!0,children:"Important: Make sure to grant access to this specific repository"})}),f[7]=Z;else Z=f[7];let F;if(f[8]===Symbol.for("react.memo_cache_sentinel"))F=d(Q,{children:I(X,{bold:!0,color:"permission",children:["Press Enter once you've installed the app",M0.ellipsis]})}),f[8]=F;else F=f[8];let y;if(f[9]===Symbol.for("react.memo_cache_sentinel"))y=d(Q,{marginTop:1,children:I(X,{dimColor:!0,children:["Having trouble? See manual setup instructions at:"," ",d(X,{color:"claude",children:x})]})}),f[9]=y;else y=f[9];let m;if(f[10]!==V)m=I(Q,{flexDirection:"column",borderStyle:"round",borderDimColor:!0,paddingX:1,children:[z,M,L,H,V,Z,F,y]}),f[10]=V,f[11]=m;else m=f[11];return m}var Qf;var Lf=h(()=>{Jf();X0();j();J0();g();Qf=_(r(),1)});function Vf({onSuccess:W,onCancel:f}){let[q,Y]=i.useState({state:"starting"}),[D]=i.useState(()=>new Hf),[z,M]=i.useState(""),[L,H]=i.useState(0),[V,Z]=i.useState(!1),[F,y]=i.useState(!1),m=i.useRef(new Set),b=i.useRef(void 0),P=e(),C=Math.max(50,P.columns-If.length-4);function N(B){if(q.state!=="error")return;if(B.preventDefault(),B.key==="return"&&q.toRetry)M(""),H(0),Y({state:"about_to_retry",nextState:q.toRetry});else f()}async function E(B,K){try{let[J,G]=B.split("#");if(!J||!G){Y({state:"error",message:"Invalid code. Please make sure the full code was copied",toRetry:{state:"waiting_for_login",url:K}});return}R("tengu_oauth_manual_entry",{}),D.handleManualAuthCodeInput({authorizationCode:J,state:G})}catch(J){Q0(J),Y({state:"error",message:J.message,toRetry:{state:"waiting_for_login",url:K}})}}let v=i.useCallback(async()=>{m.current.forEach((B)=>clearTimeout(B)),m.current.clear();try{let B=await D.startOAuthFlow(async(J)=>{Y({state:"waiting_for_login",url:J});let G=setTimeout(Z,3000,!0);m.current.add(G)},{loginWithClaudeAi:!0,inferenceOnly:!0,expiresIn:31536000});Y({state:"processing"}),Gf(B);let K=setTimeout((J,G,w,U)=>{J({state:"success",token:G});let c=setTimeout(w,1000,G);U.current.add(c)},100,Y,B.accessToken,W,m);m.current.add(K)}catch(B){let K=B.message;Y({state:"error",message:K,toRetry:{state:"starting"}}),Q0(B),R("tengu_oauth_error",{error:K})}},[D,W]);i.useEffect(()=>{if(q.state==="starting")v()},[q.state,v]),i.useEffect(()=>{if(q.state==="about_to_retry"){let B=setTimeout((K,J,G)=>{J(K.state==="waiting_for_login"),G(K)},500,q.nextState,Z,Y);m.current.add(B)}},[q]),i.useEffect(()=>{if(z==="c"&&q.state==="waiting_for_login"&&V&&!F)zf(q.url).then((B)=>{if(B)process.stdout.write(B);y(!0),clearTimeout(b.current),b.current=setTimeout(y,2000,!1)}),M("")},[z,q,V,F]),i.useEffect(()=>{let B=m.current;return()=>{D.cleanup(),B.forEach((K)=>clearTimeout(K)),B.clear(),clearTimeout(b.current)}},[D]);function O(){switch(q.state){case"starting":return I(Q,{children:[d(H0,{}),d(X,{children:"Starting authentication…"})]});case"waiting_for_login":return I(Q,{flexDirection:"column",gap:1,children:[!V&&I(Q,{children:[d(H0,{}),d(X,{children:"Opening browser to sign in with your Claude account…"})]}),V&&I(Q,{children:[d(X,{children:If}),d(t,{value:z,onChange:M,onSubmit:(B)=>E(B,q.url),cursorOffset:L,onChangeCursorOffset:H,columns:C})]})]});case"processing":return I(Q,{children:[d(H0,{}),d(X,{children:"Processing authentication…"})]});case"success":return I(Q,{flexDirection:"column",gap:1,children:[d(X,{color:"success",children:"✓ Authentication token created successfully!"}),d(X,{dimColor:!0,children:"Using token for GitHub Actions setup…"})]});case"error":return I(Q,{flexDirection:"column",gap:1,children:[I(X,{color:"error",children:["OAuth error: ",q.message]}),q.toRetry?d(X,{dimColor:!0,children:"Press Enter to try again, or any other key to cancel"}):d(X,{dimColor:!0,children:"Press any key to return to API key selection"})]});case"about_to_retry":return d(Q,{flexDirection:"column",gap:1,children:d(X,{color:"permission",children:"Retrying…"})});default:return null}}return I(Q,{flexDirection:"column",gap:1,tabIndex:0,autoFocus:!0,onKeyDown:N,children:[q.state==="starting"&&I(Q,{flexDirection:"column",gap:1,paddingBottom:1,children:[d(X,{bold:!0,children:"Create Authentication Token"}),d(X,{dimColor:!0,children:"Creating a long-lived token for GitHub Actions"})]}),q.state!=="success"&&q.state!=="starting"&&q.state!=="processing"&&I(Q,{flexDirection:"column",gap:1,paddingBottom:1,children:[d(X,{bold:!0,children:"Create Authentication Token"}),d(X,{dimColor:!0,children:"Creating a long-lived token for GitHub Actions"})]},"header"),q.state==="waiting_for_login"&&V&&I(Q,{flexDirection:"column",gap:1,paddingBottom:1,children:[I(Q,{paddingX:1,children:[I(X,{dimColor:!0,children:["Browser didn't open? Use the url below to sign in"," "]}),F?d(X,{color:"success",children:"(Copied!)"}):d(X,{dimColor:!0,children:d(d0,{shortcut:"c",action:"copy",parens:!0})})]}),d(L0,{url:q.url,children:d(X,{dimColor:!0,children:q.url})})]},"urlToCopy"),d(Q,{paddingLeft:1,flexDirection:"column",gap:1,children:O()})]})}var i,If="Paste code here if prompted > ";var bf=h(()=>{F0();w0();nf();G0();D0();of();j();Sf();Mf();Df();g();i=_(Y0(),1)});function Wf(W){let f=W.trim(),q=f.match(/^(?<owner>[^/:\s]+)\/(?<repo>[^/\s]+?)(?:\.git)?\/?$/i);if(q?.groups?.owner&&q.groups.repo)return`${q.groups.owner}/${q.groups.repo}`.replace(/\.git$/i,"");let Y=f.match(/^(?:https?:\/\/)?(?:www\.)?github\.com\/(?<owner>[^/:\s]+)\/(?<repo>[^/\s]+?)(?:\.git)?\/?$/i);if(Y?.groups?.owner&&Y.groups.repo)return`${Y.groups.owner}/${Y.groups.repo}`.replace(/\.git$/i,"");let D=f.match(/^(?:git@|ssh:\/\/git@)(?:www\.)?github\.com[:/](?<owner>[^/:\s]+)\/(?<repo>[^/\s]+?)(?:\.git)?\/?$/i);if(D?.groups?.owner&&D.groups.repo)return`${D.groups.owner}/${D.groups.repo}`;if(/^[a-z][a-z0-9+.-]*:\/\//i.test(f))return null;try{let z=new URL(f),M=z.hostname.toLowerCase();if(M!=="github.com"&&M!=="www.github.com")return null;let L=z.pathname.replace(/^\/+|\/+$/g,"").split("/").filter(Boolean);if(L.length<2)return null;return`${L[0]}/${L[1]}`.replace(/\.git$/i,"")}catch{return null}}var Ff=()=>{};function yf(W){let f=mf.c(21),{secretExists:q,useExistingSecret:Y,secretName:D,skipWorkflow:z}=W,M=z===void 0?!1:z,L;if(f[0]===Symbol.for("react.memo_cache_sentinel"))L=I(Q,{flexDirection:"column",marginBottom:1,children:[d(X,{bold:!0,children:"Install GitHub App"}),d(X,{dimColor:!0,children:"Success"})]}),f[0]=L;else L=f[0];let H;if(f[1]!==M)H=!M&&d(X,{color:"success",children:"✓ GitHub Actions workflow created!"}),f[1]=M,f[2]=H;else H=f[2];let V;if(f[3]!==q||f[4]!==Y)V=q&&Y&&d(Q,{marginTop:1,children:d(X,{color:"success",children:"✓ Using existing ANTHROPIC_API_KEY secret"})}),f[3]=q,f[4]=Y,f[5]=V;else V=f[5];let Z;if(f[6]!==q||f[7]!==D||f[8]!==Y)Z=(!q||!Y)&&d(Q,{marginTop:1,children:I(X,{color:"success",children:["✓ API key saved as ",D," secret"]})}),f[6]=q,f[7]=D,f[8]=Y,f[9]=Z;else Z=f[9];let F;if(f[10]===Symbol.for("react.memo_cache_sentinel"))F=d(Q,{marginTop:1,children:d(X,{children:"Next steps:"})}),f[10]=F;else F=f[10];let y;if(f[11]!==M)y=M?I(T,{children:[d(X,{children:"1. Install the Claude GitHub App if you haven't already"}),d(X,{children:"2. Your workflow file was kept unchanged"}),d(X,{children:"3. API key is configured and ready to use"})]}):I(T,{children:[d(X,{children:"1. A pre-filled PR page has been created"}),d(X,{children:"2. Install the Claude GitHub App if you haven't already"}),d(X,{children:"3. Merge the PR to enable Claude PR assistance"})]}),f[11]=M,f[12]=y;else y=f[12];let m;if(f[13]!==H||f[14]!==V||f[15]!==Z||f[16]!==y)m=I(Q,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[L,H,V,Z,F,y]}),f[13]=H,f[14]=V,f[15]=Z,f[16]=y,f[17]=m;else m=f[17];let b;if(f[18]===Symbol.for("react.memo_cache_sentinel"))b=d(Q,{marginLeft:3,children:d(X,{dimColor:!0,children:"Press any key to exit"})}),f[18]=b;else b=f[18];let P;if(f[19]!==m)P=I(T,{children:[m,b]}),f[19]=m,f[20]=P;else P=f[20];return P}var mf;var Pf=h(()=>{j();g();mf=_(r(),1)});async function rf(W,f,q,Y,D,z,M){let L=await o("gh",["api",`repos/${W}/contents/${q}`,"--jq",".sha"]),H=null;if(L.code===0)H=L.stdout.trim();let V=Y;if(D==="CLAUDE_CODE_OAUTH_TOKEN")V=Y.replace(/anthropic_api_key: \$\{\{ secrets\.ANTHROPIC_API_KEY \}\}/g,"claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}");else if(D!=="ANTHROPIC_API_KEY")V=Y.replace(/anthropic_api_key: \$\{\{ secrets\.ANTHROPIC_API_KEY \}\}/g,`anthropic_api_key: \${{ secrets.${D} }}`);let Z=Buffer.from(V).toString("base64"),F=["api","--method","PUT",`repos/${W}/contents/${q}`,"-f",`message=${H?`"Update ${z}"`:`"${z}"`}`,"-f",`content=${Z}`,"-f",`branch=${f}`];if(H)F.push("-f",`sha=${H}`);let y=await o("gh",F);if(y.code!==0){if(y.stderr.includes("422")&&y.stderr.includes("sha"))throw R("tengu_setup_github_actions_failed",{reason:"failed_to_create_workflow_file",exit_code:y.code,...M}),Error(`Failed to create workflow file ${q}: A Claude workflow file already exists in this repository. Please remove it first or update it manually.`);R("tengu_setup_github_actions_failed",{reason:"failed_to_create_workflow_file",exit_code:y.code,...M});let m=`

Need help? Common issues:
`+`· Permission denied → Run: gh auth refresh -h github.com -s repo,workflow
`+`· Not authorized → Ensure you have admin access to the repository
`+"· For manual setup → Visit: https://github.com/anthropics/claude-code-action";throw Error(`Failed to create workflow file ${q}: ${y.stderr}${m}`)}}async function cf(W,f,q,Y,D=!1,z,M,L){try{R("tengu_setup_github_actions_started",{skip_workflow:D,has_api_key:!!f,using_default_secret_name:q==="ANTHROPIC_API_KEY",selected_claude_workflow:z.includes("claude"),selected_claude_review_workflow:z.includes("claude-review"),...L});let H=await o("gh",["api",`repos/${W}`,"--jq",".id"]);if(H.code!==0)throw R("tengu_setup_github_actions_failed",{reason:"repo_not_found",exit_code:H.code,...L}),Error(`Failed to access repository ${W}: ${H.stderr}`);let V=await o("gh",["api",`repos/${W}`,"--jq",".default_branch"]);if(V.code!==0)throw R("tengu_setup_github_actions_failed",{reason:"failed_to_get_default_branch",exit_code:V.code,...L}),Error(`Failed to get default branch: ${V.stderr}`);let Z=V.stdout.trim(),F=await o("gh",["api",`repos/${W}/git/ref/heads/${Z}`,"--jq",".object.sha"]);if(F.code!==0)throw R("tengu_setup_github_actions_failed",{reason:"failed_to_get_branch_sha",exit_code:F.code,...L}),Error(`Failed to get branch SHA: ${F.stderr}`);let y=F.stdout.trim(),m=null;if(!D){Y(),m=`add-claude-github-actions-${Date.now()}`;let b=await o("gh",["api","--method","POST",`repos/${W}/git/refs`,"-f",`ref=refs/heads/${m}`,"-f",`sha=${y}`]);if(b.code!==0)throw R("tengu_setup_github_actions_failed",{reason:"failed_to_create_branch",exit_code:b.code,...L}),Error(`Failed to create branch: ${b.stderr}`);Y();let P=[];if(z.includes("claude"))P.push({path:".github/workflows/claude.yml",content:N0,message:"Claude PR Assistant workflow"});if(z.includes("claude-review"))P.push({path:".github/workflows/claude-code-review.yml",content:v0,message:"Claude Code Review workflow"});for(let C of P)await rf(W,m,C.path,C.content,q,C.message,L)}if(Y(),f){let b=await o("gh",["secret","set",q,"--body",f,"--repo",W]);if(b.code!==0){R("tengu_setup_github_actions_failed",{reason:"failed_to_set_api_key_secret",exit_code:b.code,...L});let P=`

Need help? Common issues:
`+`· Permission denied → Run: gh auth refresh -h github.com -s repo
`+`· Not authorized → Ensure you have admin access to the repository
`+"· For manual setup → Visit: https://github.com/anthropics/claude-code-action";throw Error(`Failed to set API key secret: ${b.stderr||"Unknown error"}${P}`)}}if(!D&&m){Y();let b=`https://github.com/${W}/compare/${Z}...${m}?quick_pull=1&title=${encodeURIComponent(k0)}&body=${encodeURIComponent(E0)}`;await V0(b)}R("tengu_setup_github_actions_completed",{skip_workflow:D,has_api_key:!!f,auth_type:M,using_default_secret_name:q==="ANTHROPIC_API_KEY",selected_claude_workflow:z.includes("claude"),selected_claude_review_workflow:z.includes("claude-review"),...L}),Bf((b)=>({...b,githubActionSetupCount:(b.githubActionSetupCount??0)+1}))}catch(H){if(!H||!(H instanceof Error)||!H.message.includes("Failed to"))R("tengu_setup_github_actions_failed",{reason:"unexpected_error",...L});if(H instanceof Error)Q0(H);throw H}}var Rf=h(()=>{F0();af();X0();Uf();wf();Df()});function Kf(W){let f=Cf.c(8),{warnings:q,onContinue:Y}=W,D;if(f[0]===Symbol.for("react.memo_cache_sentinel"))D={context:"Confirmation"},f[0]=D;else D=f[0];z0("confirm:yes",Y,D);let z;if(f[1]===Symbol.for("react.memo_cache_sentinel"))z=I(Q,{flexDirection:"column",marginBottom:1,children:[I(X,{bold:!0,children:[M0.warning," Setup Warnings"]}),d(X,{dimColor:!0,children:"We found some potential issues, but you can continue anyway"})]}),f[1]=z;else z=f[1];let M;if(f[2]!==q)M=q.map($f),f[2]=q,f[3]=M;else M=f[3];let L;if(f[4]===Symbol.for("react.memo_cache_sentinel"))L=d(Q,{marginTop:1,children:d(X,{bold:!0,color:"permission",children:"Press Enter to continue anyway, or Ctrl+C to exit and fix issues"})}),f[4]=L;else L=f[4];let H;if(f[5]===Symbol.for("react.memo_cache_sentinel"))H=d(Q,{marginTop:1,children:I(X,{dimColor:!0,children:["You can also try the manual setup steps if needed:"," ",d(X,{color:"claude",children:x})]})}),f[5]=H;else H=f[5];let V;if(f[6]!==M)V=d(T,{children:I(Q,{flexDirection:"column",borderStyle:"round",paddingX:1,children:[z,M,L,H]})}),f[6]=M,f[7]=V;else V=f[7];return V}function $f(W,f){return I(Q,{flexDirection:"column",marginBottom:1,children:[d(X,{color:"warning",bold:!0,children:W.title}),d(X,{children:W.message}),W.instructions.length>0&&d(Q,{flexDirection:"column",marginLeft:2,marginTop:1,children:W.instructions.map(xf)})]},f)}function xf(W,f){return I(X,{dimColor:!0,children:["• ",W]},f)}var Cf;var Af=h(()=>{Jf();X0();j();J0();g();Cf=_(r(),1)});function dq(W){let[f]=S.useState(()=>Nf()),[q,Y]=S.useState({...qq,useExistingKey:!!f,selectedApiKeyOption:f?"existing":y0()?"oauth":"new"});Ef(),S.default.useEffect(()=>{R("tengu_install_github_app_started",{})},[]);let D=S.useCallback(async()=>{let J=[];if((await m0("gh --version",{shell:!0,reject:!1})).exitCode!==0)J.push({title:"GitHub CLI not found",message:"GitHub CLI (gh) does not appear to be installed or accessible.",instructions:["Install GitHub CLI from https://cli.github.com/","macOS: brew install gh","Windows: winget install --id GitHub.cli","Linux: See installation instructions at https://github.com/cli/cli#installation"]});let w=await m0("gh auth status -a",{shell:!0,reject:!1});if(w.exitCode!==0)J.push({title:"GitHub CLI not authenticated",message:"GitHub CLI does not appear to be authenticated.",instructions:["Run: gh auth login","Follow the prompts to authenticate with GitHub","Or set up authentication using environment variables or other methods"]});else{let c=w.stdout.match(/Token scopes:.*$/m);if(c){let k=c[0],A=[];if(!k.includes("repo"))A.push("repo");if(!k.includes("workflow"))A.push("workflow");if(A.length>0){Y((l)=>({...l,step:"error",error:`GitHub CLI is missing required permissions: ${A.join(", ")}.`,errorReason:"Missing required scopes",errorInstructions:[`Your GitHub CLI authentication is missing the "${A.join('" and "')}" ${kf(A.length,"scope")} needed to manage GitHub Actions and secrets.`,"","To fix this, run:","  gh auth refresh -h github.com -s repo,workflow","","This will add the necessary permissions to manage workflows and secrets."]}));return}}}let U=await gf()??"";R("tengu_install_github_app_step_completed",{step:"check-gh"}),Y((c)=>({...c,warnings:J,currentRepo:U,selectedRepoName:U,useCurrentRepo:!!U,step:J.length>0?"warnings":"choose-repo"}))},[]);S.default.useEffect(()=>{if(q.step==="check-gh")D()},[q.step,D]);let z=S.useCallback(async(J,G)=>{Y((w)=>({...w,step:"creating",currentWorkflowInstallStep:0}));try{await cf(q.selectedRepoName,J,G,()=>{Y((w)=>({...w,currentWorkflowInstallStep:w.currentWorkflowInstallStep+1}))},q.workflowAction==="skip",q.selectedWorkflows,q.authType,{useCurrentRepo:q.useCurrentRepo,workflowExists:q.workflowExists,secretExists:q.secretExists}),R("tengu_install_github_app_step_completed",{step:"creating"}),Y((w)=>({...w,step:"success"}))}catch(w){let U=w instanceof Error?w.message:"Failed to set up GitHub Actions";if(U.includes("workflow file already exists"))R("tengu_install_github_app_error",{reason:"workflow_file_exists"}),Y((c)=>({...c,step:"error",error:"A Claude workflow file already exists in this repository.",errorReason:"Workflow file conflict",errorInstructions:["The file .github/workflows/claude.yml already exists","You can either:","  1. Delete the existing file and run this command again","  2. Update the existing file manually using the template from:",`     ${x}`]}));else R("tengu_install_github_app_error",{reason:"setup_github_actions_failed"}),Y((c)=>({...c,step:"error",error:U,errorReason:"GitHub Actions setup failed",errorInstructions:[]}))}},[q.selectedRepoName,q.workflowAction,q.selectedWorkflows,q.useCurrentRepo,q.workflowExists,q.secretExists,q.authType]);async function M(){await V0("https://github.com/apps/claude")}async function L(J){try{let G=await o("gh",["api",`repos/${J}`,"--jq",".permissions.admin"]);if(G.code===0)return{hasAccess:G.stdout.trim()==="true"};if(G.stderr.includes("404")||G.stderr.includes("Not Found"))return{hasAccess:!1,error:"repository_not_found"};return{hasAccess:!1}}catch{return{hasAccess:!1}}}async function H(J){return(await o("gh",["api",`repos/${J}/contents/.github/workflows/claude.yml`,"--jq",".sha"])).code===0}async function V(){let J=await o("gh",["secret","list","--app","actions","--repo",q.selectedRepoName]);if(J.code===0)if(J.stdout.split(`
`).some((U)=>{return/^ANTHROPIC_API_KEY\s+/.test(U)}))Y((U)=>({...U,secretExists:!0,step:"check-existing-secret"}));else if(f)Y((U)=>({...U,apiKeyOrOAuthToken:f,useExistingKey:!0})),await z(f,q.secretName);else Y((U)=>({...U,step:"api-key"}));else if(f)Y((G)=>({...G,apiKeyOrOAuthToken:f,useExistingKey:!0})),await z(f,q.secretName);else Y((G)=>({...G,step:"api-key"}))}let Z=async()=>{if(q.step==="warnings")R("tengu_install_github_app_step_completed",{step:"warnings"}),Y((J)=>({...J,step:"install-app"})),setTimeout(M,0);else if(q.step==="choose-repo"){let J=q.useCurrentRepo?q.currentRepo:q.selectedRepoName;if(!J.trim())return;let G=[],w=Wf(J),U=/^[a-z][a-z0-9+.-]*:\/\//i.test(J)||J.startsWith("www.");if(w)J=w;else if(U)G.push({title:"Invalid GitHub URL format",message:"The repository URL format appears to be invalid.",instructions:["Use format: owner/repo or https://github.com/owner/repo","Example: anthropics/claude-cli"]});if(!J.includes("/"))G.push({title:"Repository format warning",message:'Repository should be in format "owner/repo"',instructions:["Use format: owner/repo","Example: anthropics/claude-cli"]});let c=await L(J);if(c.error==="repository_not_found")G.push({title:"Repository not found",message:`Repository ${J} was not found or you don't have access.`,instructions:[`Check that the repository name is correct: ${J}`,"Ensure you have access to this repository",'For private repositories, make sure your GitHub token has the "repo" scope',"You can add the repo scope with: gh auth refresh -h github.com -s repo,workflow"]});else if(!c.hasAccess)G.push({title:"Admin permissions required",message:`You might need admin permissions on ${J} to set up GitHub Actions.`,instructions:["Repository admins can install GitHub Apps and set secrets","Ask a repository admin to run this command if setup fails","Alternatively, you can use the manual setup instructions"]});let k=await H(J);if(G.length>0){let A=[...q.warnings,...G];Y((l)=>({...l,selectedRepoName:J,workflowExists:k,warnings:A,step:"warnings"}))}else R("tengu_install_github_app_step_completed",{step:"choose-repo"}),Y((A)=>({...A,selectedRepoName:J,workflowExists:k,step:"install-app"})),setTimeout(M,0)}else if(q.step==="install-app")if(R("tengu_install_github_app_step_completed",{step:"install-app"}),q.workflowExists)Y((J)=>({...J,step:"check-existing-workflow"}));else Y((J)=>({...J,step:"select-workflows"}));else if(q.step==="check-existing-workflow")return;else if(q.step==="select-workflows")return;else if(q.step==="check-existing-secret")if(R("tengu_install_github_app_step_completed",{step:"check-existing-secret"}),q.useExistingSecret)await z(null,q.secretName);else await z(q.apiKeyOrOAuthToken,q.secretName);else if(q.step==="api-key"){if(q.selectedApiKeyOption==="oauth")return;let J=q.selectedApiKeyOption==="existing"?f:q.apiKeyOrOAuthToken;if(!J){R("tengu_install_github_app_error",{reason:"api_key_missing"}),Y((w)=>({...w,step:"error",error:"API key is required"}));return}Y((w)=>({...w,apiKeyOrOAuthToken:J,useExistingKey:q.selectedApiKeyOption==="existing"}));let G=await o("gh",["secret","list","--app","actions","--repo",q.selectedRepoName]);if(G.code===0)if(G.stdout.split(`
`).some((c)=>{return/^ANTHROPIC_API_KEY\s+/.test(c)}))R("tengu_install_github_app_step_completed",{step:"api-key"}),Y((c)=>({...c,secretExists:!0,step:"check-existing-secret"}));else R("tengu_install_github_app_step_completed",{step:"api-key"}),await z(J,q.secretName);else R("tengu_install_github_app_step_completed",{step:"api-key"}),await z(J,q.secretName)}},F=(J)=>{Y((G)=>({...G,selectedRepoName:J}))},y=(J)=>{Y((G)=>({...G,apiKeyOrOAuthToken:J}))},m=(J)=>{Y((G)=>({...G,selectedApiKeyOption:J}))},b=S.useCallback(()=>{R("tengu_install_github_app_step_completed",{step:"api-key"}),Y((J)=>({...J,step:"oauth-flow"}))},[]),P=S.useCallback((J)=>{R("tengu_install_github_app_step_completed",{step:"oauth-flow"}),Y((G)=>({...G,apiKeyOrOAuthToken:J,useExistingKey:!1,secretName:"CLAUDE_CODE_OAUTH_TOKEN",authType:"oauth_token"})),z(J,"CLAUDE_CODE_OAUTH_TOKEN")},[z]),C=S.useCallback(()=>{Y((J)=>({...J,step:"api-key"}))},[]),N=(J)=>{if(J&&!/^[a-zA-Z0-9_]+$/.test(J))return;Y((G)=>({...G,secretName:J}))},E=(J)=>{Y((G)=>({...G,useCurrentRepo:J,selectedRepoName:J?G.currentRepo:""}))},v=(J)=>{Y((G)=>({...G,useExistingKey:J}))},O=(J)=>{Y((G)=>({...G,useExistingSecret:J,secretName:J?"ANTHROPIC_API_KEY":""}))},B=async(J)=>{if(J==="exit"){W.onDone("Installation cancelled by user");return}if(R("tengu_install_github_app_step_completed",{step:"check-existing-workflow"}),Y((G)=>({...G,workflowAction:J})),J==="skip"||J==="update")if(f)await V();else Y((G)=>({...G,step:"api-key"}))};function K(J){if(J.preventDefault(),q.step==="success")R("tengu_install_github_app_completed",{});W.onDone(q.step==="success"?"GitHub Actions setup complete!":q.error?`Couldn't install GitHub App: ${q.error}
For manual setup instructions, see: ${x}`:`GitHub App installation failed
For manual setup instructions, see: ${x}`)}switch(q.step){case"check-gh":return d(o0,{});case"warnings":return d(Kf,{warnings:q.warnings,onContinue:Z});case"choose-repo":return d(a0,{currentRepo:q.currentRepo,useCurrentRepo:q.useCurrentRepo,repoUrl:q.selectedRepoName,onRepoUrlChange:F,onToggleUseCurrentRepo:E,onSubmit:Z});case"install-app":return d(Zf,{repoUrl:q.selectedRepoName,onSubmit:Z});case"check-existing-workflow":return d(Yf,{repoName:q.selectedRepoName,onSelectAction:B});case"check-existing-secret":return d(p0,{useExistingSecret:q.useExistingSecret,secretName:q.secretName,onToggleUseExistingSecret:O,onSecretNameChange:N,onSubmit:Z});case"api-key":return d(_0,{existingApiKey:f,useExistingKey:q.useExistingKey,apiKeyOrOAuthToken:q.apiKeyOrOAuthToken,onApiKeyChange:y,onToggleUseExistingKey:v,onSubmit:Z,onCreateOAuthToken:y0()?b:void 0,selectedOption:q.selectedApiKeyOption,onSelectOption:m});case"creating":return d(x0,{currentWorkflowInstallStep:q.currentWorkflowInstallStep,secretExists:q.secretExists,useExistingSecret:q.useExistingSecret,secretName:q.secretName,skipWorkflow:q.workflowAction==="skip",selectedWorkflows:q.selectedWorkflows});case"success":return d(Q,{tabIndex:0,autoFocus:!0,onKeyDown:K,children:d(yf,{secretExists:q.secretExists,useExistingSecret:q.useExistingSecret,secretName:q.secretName,skipWorkflow:q.workflowAction==="skip"})});case"error":return d(Q,{tabIndex:0,autoFocus:!0,onKeyDown:K,children:d(t0,{error:q.error,errorReason:q.errorReason,errorInstructions:q.errorInstructions})});case"select-workflows":return d(A0,{defaultSelections:q.selectedWorkflows,onSubmit:(J)=>{if(R("tengu_install_github_app_step_completed",{step:"select-workflows"}),Y((G)=>({...G,selectedWorkflows:J})),f)V();else Y((G)=>({...G,step:"api-key"}))}});case"oauth-flow":return d(Vf,{onSuccess:P,onCancel:C})}}async function JY(W){return d(dq,{onDone:W})}var S,qq;var Yq=h(()=>{sf();F0();g0();X0();fq();j();Mf();Uf();wf();ef();tf();T0();u0();S0();r0();s0();ff();Xf();Lf();bf();Ff();Pf();Rf();Af();g();S=_(Y0(),1),qq={step:"check-gh",selectedRepoName:"",currentRepo:"",useCurrentRepo:!1,apiKeyOrOAuthToken:"",useExistingKey:!0,currentWorkflowInstallStep:0,warnings:[],secretExists:!1,secretName:"ANTHROPIC_API_KEY",useExistingSecret:!0,workflowExists:!1,selectedWorkflows:["claude","claude-review"],selectedApiKeyOption:"new",authType:"api_key"}});Yq();export{JY as call};
