Spaces:
Running
Running
| import{r,j as e}from"./react-CIdJ77ke.js";import{m as A,n as L,o as $,p as G,q as R,c as W,r as Y,k as U,t as q,B as z,w as H,x as J,L as F,y as K,M as f}from"./index-CX7Qxd1D.js";import"./@braintree-DzxiOROe.js";import"./react-dom-R9L8nDNe.js";import"./scheduler-CoSDG3-6.js";import"./@google-CcUHq7Ay.js";import"./idb-Dob3nYDb.js";import"./marked-BrGMJkBT.js";import"./mermaid-KwKZWwy0.js";import"./dayjs-CeEF-NGT.js";import"./d3-transition-CiCB8KJE.js";import"./d3-timer-DdKHrDhs.js";import"./d3-dispatch-kxCwF96_.js";import"./d3-interpolate-CtIaNujU.js";import"./d3-color-amxIadob.js";import"./d3-selection-C52G7wmG.js";import"./d3-ease-DRPgKoYJ.js";import"./d3-zoom-BYoC3mS3.js";import"./dompurify-J5RlrwSC.js";import"./dagre-d3-es-CTpFWynZ.js";import"./lodash-es-Dt6r0yiR.js";import"./d3-shape-CX8xTzfR.js";import"./d3-path-CimkQT29.js";import"./d3-fetch-BOsq7VnW.js";import"./khroma-DUX6PT6k.js";import"./uuid-DhYbOkY1.js";import"./d3-scale-DRZz3QW5.js";import"./internmap-BkD7Hj8s.js";import"./d3-array-DGRYoJHh.js";import"./d3-format-CzD4bSOQ.js";import"./d3-time-format-CUNN4Ell.js";import"./d3-time-6cSPyVSY.js";import"./d3-axis-DSWTncID.js";import"./elkjs-oKFFZvz7.js";import"./cytoscape-DtBltrT8.js";import"./cytoscape-cose-bilkent-Cgr1thlj.js";import"./cose-base-CwCxnKwh.js";import"./layout-base-CMXQqlmj.js";import"./d3-sankey-DgqkLiUE.js";import"./d3-scale-chromatic-B-NsZVaP.js";import"./ts-dedent-DrFu-skq.js";import"./stylis-D5iaQeiq.js";import"./mdast-util-from-markdown-CLAsVoWb.js";import"./micromark-CTBPIv-_.js";import"./micromark-util-combine-extensions-Bka6Sc1c.js";import"./micromark-util-chunked-DrRIdSP-.js";import"./micromark-factory-space-x2vfxbz5.js";import"./micromark-util-character-Bcm1tP9o.js";import"./micromark-core-commonmark-AH8VCgT7.js";import"./micromark-util-classify-character-Cq7Fg3xE.js";import"./micromark-util-resolve-all-PQCKh0dx.js";import"./decode-named-character-reference-C3-224fz.js";import"./micromark-util-subtokenize-QwsxNXk2.js";import"./micromark-factory-destination-CypD_wgM.js";import"./micromark-factory-label-CRHH4ZHP.js";import"./micromark-factory-title-B7kCBvC9.js";import"./micromark-factory-whitespace-B322EA6O.js";import"./micromark-util-normalize-identifier-C9ANKk3v.js";import"./micromark-util-html-tag-name-DbKNfynz.js";import"./micromark-util-decode-numeric-character-reference-DRnCnno4.js";import"./micromark-util-decode-string-DJl8Y_PO.js";import"./unist-util-stringify-position-Ch_qCilz.js";import"./mdast-util-to-string-C_aolqmU.js";import"./jszip-CFFhfFtd.js";import"./octokit-B6bKu3NB.js";import"./@octokit-MBEWYTsi.js";import"./bottleneck-D_vuF9V7.js";import"./universal-user-agent-CLgqIJsR.js";import"./before-after-hook-y8XtM9xW.js";import"./fast-content-type-parse-3SwieiST.js";const pt=()=>{const[n,T]=r.useState('A simple "Hello World" React component with a button that shows an alert.'),[l]=r.useState("React"),[m]=r.useState("Tailwind CSS"),[c,E]=r.useState(!1),[u,p]=r.useState([]),[h,g]=r.useState(""),[b,j]=r.useState(""),[k,y]=r.useState(""),[a,i]=r.useState("CODE"),[x,w]=r.useState(!1),[S,d]=r.useState("");r.useEffect(()=>{(async()=>{const o=await K();p(o),o.length>0&&i(o[0])})()},[]);const M=r.useCallback(async()=>{if(!n.trim()){d("Please enter a feature description.");return}w(!0),d(""),await A(),p([]),g(""),j(""),y(""),i("CODE");try{const t=c?await L(n,l,m):await $(n,l,m);for(const o of t)await G(o);if(p(t),t.length>0){const o=t.find(s=>s.filePath.endsWith(".tsx")||s.filePath.endsWith(".jsx"));i(o||t[0]);const P=R(o?.content||t[0].content),D=t.map(s=>`File: ${s.filePath} | |
| ${s.content}`).join(` | |
| --- | |
| `),B=W(D);let N="";for await(const s of P)N+=s,g(N);let C="";for await(const s of B)C+=s,j(C);if(!c){const s=Y(l);let v="";for await(const O of s)v+=O,y(v)}}}catch(t){d(t instanceof Error?t.message:"Failed to generate feature.")}finally{w(!1)}},[n,l,m,c]),I=()=>{if(typeof a=="string")switch(a){case"TESTS":return e.jsx(f,{content:h});case"COMMIT":return e.jsx("pre",{className:"w-full h-full p-4 whitespace-pre-wrap font-sans text-sm",children:b});case"DEPLOYMENT":return e.jsx(f,{content:k});default:return e.jsx("div",{className:"p-4",children:"Select a file"})}return e.jsx(f,{content:"```tsx\n"+a.content+"\n```"})};return e.jsxs("div",{className:"h-full flex flex-col text-text-primary bg-surface",children:[e.jsx("header",{className:"p-4 border-b border-border flex-shrink-0",children:e.jsxs("h1",{className:"text-xl font-bold flex items-center",children:[e.jsx(U,{}),e.jsx("span",{className:"ml-3",children:"AI Feature Builder"})]})}),e.jsx("div",{className:"flex-grow flex min-h-0",children:e.jsxs("main",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"flex-grow flex flex-col bg-background",children:[e.jsxs("div",{className:"border-b border-border flex items-center bg-surface overflow-x-auto",children:[u.map(t=>e.jsxs("button",{onClick:()=>i(t),className:`flex-shrink-0 flex items-center gap-2 px-4 py-2 text-sm ${a===t?"bg-background border-b-2 border-primary text-text-primary":"text-text-secondary hover:bg-gray-50"}`,children:[e.jsx(q,{})," ",t.filePath]},t.filePath)),h&&e.jsxs("button",{onClick:()=>i("TESTS"),className:`flex-shrink-0 flex items-center gap-2 px-4 py-2 text-sm ${a==="TESTS"?"bg-background border-b-2 border-primary text-text-primary":"text-text-secondary hover:bg-gray-50"}`,children:[e.jsx(z,{})," Tests"]}),b&&e.jsxs("button",{onClick:()=>i("COMMIT"),className:`flex-shrink-0 flex items-center gap-2 px-4 py-2 text-sm ${a==="COMMIT"?"bg-background border-b-2 border-primary text-text-primary":"text-text-secondary hover:bg-gray-50"}`,children:[e.jsx(H,{})," Commit"]}),k&&!c&&e.jsxs("button",{onClick:()=>i("DEPLOYMENT"),className:`flex-shrink-0 flex items-center gap-2 px-4 py-2 text-sm ${a==="DEPLOYMENT"?"bg-background border-b-2 border-primary text-text-primary":"text-text-secondary hover:bg-gray-50"}`,children:[e.jsx(J,{})," Dockerfile"]})]}),e.jsx("div",{className:"flex-grow p-2 overflow-auto",children:x&&!u.length?e.jsx("div",{className:"flex justify-center items-center h-full",children:e.jsx(F,{})}):I()})]}),e.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-border bg-surface",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:t=>E(t.target.checked)})," Include Backend (Cloud Function + Firestore)"]})}),e.jsx("textarea",{value:n,onChange:t=>T(t.target.value),placeholder:"e.g., A user profile card with an avatar, name, and bio.",className:"w-full p-2 bg-background border border-border rounded-md resize-none text-sm h-20"}),e.jsx("div",{className:"flex gap-2 mt-2",children:e.jsx("button",{onClick:M,disabled:x,className:"btn-primary flex-grow flex items-center justify-center gap-2 px-4 py-2",children:x?e.jsxs(e.Fragment,{children:[e.jsx(F,{})," Generating..."]}):"Generate Feature"})}),S&&e.jsx("p",{className:"text-red-600 text-xs mt-2 text-center",children:S})]})]})})]})};export{pt as AiFeatureBuilder}; | |
| //# sourceMappingURL=AiFeatureBuilder-j5l2owNE.js.map | |