static / assets /AiCodeExplainer-B2pZiqoI.js
admin08077's picture
Upload 131 files
777dff7 verified
import{r as o,j as e}from"./react-_fH1j4AW.js";import{e as u}from"./geminiService-7wPGMJPL.js";import{a as f}from"./index-Nqm_ElTk.js";import{m as h}from"./marked-CesSW9Du.js";import"./@braintree-9Zuj5s7N.js";import"./@google-4tyssLU_.js";import"./react-dom-B47xkeQg.js";import"./scheduler-DYLXRpC5.js";import"./mermaid-CwNlsT42.js";import"./dayjs-LlU9W_sF.js";import"./d3-transition-593SbTzI.js";import"./d3-timer-DdKHrDhs.js";import"./d3-dispatch-kxCwF96_.js";import"./d3-interpolate-CfLzPKWk.js";import"./d3-color-amxIadob.js";import"./d3-selection-C52G7wmG.js";import"./d3-ease-DRPgKoYJ.js";import"./d3-zoom-Dc8HCWOS.js";import"./dompurify-J5RlrwSC.js";import"./dagre-d3-es-CXvdFQqV.js";import"./lodash-es-CKQobiyk.js";import"./d3-shape-C6amFesj.js";import"./d3-path-CimkQT29.js";import"./d3-fetch-BOsq7VnW.js";import"./khroma-DUX6PT6k.js";import"./uuid-DhYbOkY1.js";import"./d3-scale-BchcX-lF.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-BS_sNva5.js";import"./cytoscape-Copgxxlq.js";import"./cytoscape-cose-bilkent-DNVwk4oY.js";import"./cose-base-HlRMd3jM.js";import"./layout-base-BVPXtQQC.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";const p=()=>e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-cyan-400 animate-pulse",style:{animationDelay:"0s"}}),e.jsx("div",{className:"w-2 h-2 rounded-full bg-cyan-400 animate-pulse",style:{animationDelay:"0.2s"}}),e.jsx("div",{className:"w-2 h-2 rounded-full bg-cyan-400 animate-pulse",style:{animationDelay:"0.4s"}}),e.jsx("span",{className:"text-slate-400 ml-2",children:"AI is thinking..."})]}),j=`const bubbleSort = (arr) => {
for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < arr.length - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
[arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
}
}
}
return arr;
};`,Ie=()=>{const[s,c]=o.useState(j),[a,n]=o.useState(""),[r,m]=o.useState(!1),[i,l]=o.useState(""),d=o.useCallback(async()=>{if(!s.trim()){l("Please enter some code to explain.");return}m(!0),l(""),n("");try{const t=await u(s);n(t)}catch(t){const x=t instanceof Error?t.message:"An unknown error occurred.";l(`Failed to get explanation: ${x}`)}finally{m(!1)}},[s]);return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-slate-300",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold text-slate-100 flex items-center",children:[e.jsx(f,{}),e.jsx("span",{className:"ml-3",children:"AI Code Explainer"})]}),e.jsx("p",{className:"text-slate-400 mt-1",children:"Paste a code snippet below and let Gemini explain it to you."})]}),e.jsxs("div",{className:"flex-grow grid grid-cols-1 lg:grid-cols-2 gap-6 h-full overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("label",{htmlFor:"code-input",className:"text-sm font-medium text-slate-400 mb-2",children:"Your Code"}),e.jsx("textarea",{id:"code-input",value:s,onChange:t=>c(t.target.value),placeholder:"Paste your code here...",className:"flex-grow p-4 bg-slate-900 border border-slate-700 rounded-md resize-none font-mono text-sm text-cyan-300 focus:ring-2 focus:ring-cyan-500 focus:outline-none"}),e.jsx("button",{onClick:d,disabled:r,className:"mt-4 w-full flex items-center justify-center px-6 py-3 bg-cyan-500 text-slate-900 font-bold rounded-md hover:bg-cyan-400 transition-colors disabled:bg-slate-600 disabled:cursor-not-allowed",children:r?e.jsx(p,{}):"Generate Explanation"})]}),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("label",{className:"text-sm font-medium text-slate-400 mb-2",children:"AI Explanation"}),e.jsxs("div",{className:"flex-grow p-4 bg-slate-800/50 border border-slate-700/50 rounded-md overflow-y-auto",children:[r&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(p,{})}),i&&e.jsx("p",{className:"text-red-400",children:i}),a&&!r&&e.jsx("div",{className:"prose prose-sm prose-invert max-w-none prose-headings:text-slate-200 prose-p:text-slate-300 prose-strong:text-slate-100 prose-code:text-cyan-300 prose-code:before:content-none prose-code:after:content-none prose-pre:bg-slate-900/50 prose-pre:border prose-pre:border-slate-700",dangerouslySetInnerHTML:{__html:h(a)}}),!r&&!a&&!i&&e.jsx("div",{className:"text-slate-500 h-full flex items-center justify-center",children:"The explanation will appear here."})]})]})]})]})};export{Ie as AiCodeExplainer};
//# sourceMappingURL=AiCodeExplainer-B2pZiqoI.js.map