Aimobile / assets /AiCodeMigrator-DyYOOclS.js
admin08077's picture
Upload 395 files
634008a verified
import{r,j as e}from"./react-B-lWpQRQ.js";import{aj as L,ak as k,L as w,M as A}from"./index-DyMS-nC-.js";import"./@google-xfXoiafW.js";import"./@braintree-DY5JYOZd.js";import"./react-dom-CU2yWD-Y.js";import"./scheduler-DYLXRpC5.js";import"./idb-Dob3nYDb.js";import"./axe-core-CA05Kxsw.js";import"./marked-CesSW9Du.js";import"./@mermaid-js-Ce0__7Tp.js";import"./langium-B_PGe6V2.js";import"./vscode-jsonrpc-2tvYB2ki.js";import"./chevrotain-D5DQZOif.js";import"./@chevrotain-DMYZVohV.js";import"./lodash-es-CKTcnrxn.js";import"./chevrotain-allstar-eFSt8-qu.js";import"./vscode-languageserver-types-NoPvPymt.js";import"./vscode-languageserver-textdocument-CKBVUiR3.js";import"./vscode-uri-CoxP0whD.js";const M=["SASS","CSS","JavaScript","TypeScript","Python","Go","React","Vue","Angular","Tailwind CSS"],E=`// SASS
$primary-color: #333;
body {
color: $primary-color;
font-family: sans-serif;
}`,Y=({inputCode:a,fromLang:o,toLang:l})=>{const[f,g]=r.useState(a||E),[m,h]=r.useState(""),[j,S]=r.useState(o||"SASS"),[b,y]=r.useState(l||"CSS"),[n,N]=r.useState(!1),[x,i]=r.useState(""),u=r.useCallback(async(t,p,s)=>{if(!t.trim()){i("Please enter some code to migrate.");return}N(!0),i(""),h("");try{const c=L(t,p,s);let d="";for await(const C of c)d+=C,h(d)}catch(c){const d=c instanceof Error?c.message:"An unknown error occurred.";i(`Failed to migrate code: ${d}`)}finally{N(!1)}},[]);r.useEffect(()=>{a&&o&&l&&(g(a),S(o),y(l),u(a,o,l))},[a,o,l,u]);const v=({value:t,onChange:p})=>e.jsx("select",{value:t,onChange:s=>p(s.target.value),className:"w-full px-3 py-2 rounded-md bg-surface border border-border",children:M.map(s=>e.jsx("option",{value:s,children:s},s))});return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[e.jsx(k,{}),e.jsx("span",{className:"ml-3",children:"AI Code Migrator"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Translate code between languages, frameworks, and syntax styles."})]}),e.jsxs("div",{className:"flex-grow flex flex-col min-h-0",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 flex-grow min-h-0",children:[e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-text-secondary",children:"From:"}),e.jsx(v,{value:j,onChange:S})]}),e.jsx("textarea",{value:f,onChange:t=>g(t.target.value),placeholder:"Paste your source code here...",className:"flex-grow p-4 bg-surface border border-border rounded-md resize-none font-mono text-sm"})]}),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-text-secondary",children:"To:"}),e.jsx(v,{value:b,onChange:y})]}),e.jsxs("div",{className:"flex-grow p-1 bg-background border border-border rounded-md overflow-y-auto",children:[n&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(w,{})}),x&&e.jsx("p",{className:"p-4 text-red-500",children:x}),m&&!n&&e.jsx(A,{content:m}),!n&&!m&&!x&&e.jsx("div",{className:"text-text-secondary h-full flex items-center justify-center",children:"Migrated code will appear here."})]})]})]}),e.jsx("button",{onClick:()=>u(f,j,b),disabled:n,className:"btn-primary mt-4 w-full max-w-sm mx-auto flex items-center justify-center px-6 py-3",children:n?e.jsx(w,{}):"Migrate Code"})]})]})};export{Y as AiCodeMigrator};
//# sourceMappingURL=AiCodeMigrator-DyYOOclS.js.map