import{a as R,r as l,j as t}from"./components-xz3w7t4N.js";import{C as j}from"./client-only-01RtDe9O.js";import{u as v,l as I,d as x,n as $,o as G,q as w,r as T,v as D,w as F,x as y,y as M,z as O,H}from"./Header-B9pRTiZx.js";const N=["node_modules/**",".git/**",".github/**",".vscode/**","**/*.jpg","**/*.jpeg","**/*.png","dist/**","build/**",".next/**","coverage/**",".cache/**",".vscode/**",".idea/**","**/*.log","**/.DS_Store","**/npm-debug.log*","**/yarn-debug.log*","**/yarn-error.log*","**/*lock.yaml"];function _(){const[d]=R(),{ready:s,importChat:m}=v(),{ready:a,gitClone:b}=I(),[u,C]=l.useState(!1),[k,f]=l.useState(!0),S=async o=>{if(!(!a&&!s)&&o){const r=T().add(N);try{const{workdir:n,data:g}=await b(o);if(m){const A=Object.keys(g).filter(e=>!r.ignores(e)),B=new TextDecoder("utf-8"),p=A.map(e=>{const{data:c,encoding:P}=g[e];return{path:e,content:P==="utf8"?c:c instanceof Uint8Array?B.decode(c):""}}).filter(e=>e.content),E=await D(p),h=F(E),i=[{role:"assistant",content:`Cloning the repo ${o} into ${n}
<boltArtifact id="imported-files" title="Git Cloned Files"  type="bundled">
${p.map(e=>`<boltAction type="file" filePath="${e.path}">
${M(e.content)}
</boltAction>`).join(`
`)}
</boltArtifact>`,id:y(),createdAt:new Date}];h&&(i.push({role:"user",id:y(),content:"Setup the codebase and Start the application"}),i.push(h)),await m(`Git Project:${o.split("/").slice(-1)[0]}`,i,{gitUrl:o})}}catch(n){console.error("Error during import:",n),x.error("Failed to import repository"),f(!1),window.location.href="/";return}}};return l.useEffect(()=>{if(!s||!a||u)return;const o=d.get("url");if(!o){window.location.href="/";return}S(o).catch(r=>{console.error("Error importing repo:",r),x.error("Failed to import repository"),f(!1),window.location.href="/"}),C(!0)},[d,s,a,u]),t.jsx(j,{fallback:t.jsx(w,{}),children:()=>t.jsxs(t.Fragment,{children:[t.jsx($,{}),k&&t.jsx(G,{message:"Please wait while we clone the repository..."})]})})}const K=()=>[{title:"Bolt"},{name:"description",content:"Talk with Bolt, an AI assistant from StackBlitz"}];function Q(){return t.jsxs("div",{className:"flex flex-col h-full w-full bg-bolt-elements-background-depth-1",children:[t.jsx(O,{}),t.jsx(H,{}),t.jsx(j,{fallback:t.jsx(w,{}),children:()=>t.jsx(_,{})})]})}export{Q as default,K as meta};
