admin08077/Githubgemini
0
1import{r as i,j as e}from"./react-DKy9e2uO.js";import{G as g,A as j,M as y}from"./index-Ykf-MVva.js";import{d as b}from"./geminiService-D2PWX7SA.js";import{L as f}from"./LoadingSpinner-B20BJ_HS.js";import{d as v}from"./fileUtils-Bw7t6Hrv.js";import"./bottleneck-Cpj98o6Y.js";import"./react-dom-CpxHE_eW.js";import"./scheduler-DYLXRpC5.js";import"./idb-Dob3nYDb.js";import"./@google-D80DdW2m.js";import"./marked-CesSW9Du.js";import"./jszip-s56H2EZ-.js";const N=`* commit 3a4b5c6d7e8f9g0h1i2j3k4l5m6n7o8p9q0r (HEAD -> main, origin/main)2|\\ Merge: 1a2b3c4 2d3e4f53| | Author: Dev One <dev.one@example.com>4| | Date: Mon Jul 15 11:30:00 2024 -04005| |6| | feat: Implement collapsible sidebar navigation7| |8* | commit 2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u (feature/new-sidebar)9| | Author: Dev Two <dev.two@example.com>10| | Date: Mon Jul 15 10:00:00 2024 -040011| |12| | feat: Add icons to sidebar items13| |14* | commit 1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r15|/ Author: Dev One <dev.one@example.com>16| Date: Fri Jul 12 16:45:00 2024 -040017|18| fix: Correct user authentication bug`,w=({logInput:l})=>{const n=i.useMemo(()=>{const s=l.split(`19`),a=[];let r=null;return s.forEach(t=>{const o=t.match(/^.?[\\|/ ]*\* commit (\w+)(.*)/);o?(r&&a.push(r),r={hash:o[1],shortHash:o[1].substring(0,7),refs:o[2].trim(),message:"",author:""}):r&&(t.includes("Author:")?r.author=t.split("Author:")[1].trim():t.trim().length>0&&!t.match(/^[\\|/ ]*[\\|/ ]/)&&(r.message+=t.trim()+" "))}),r&&a.push(r),a.map((t,o)=>({...t,x:50,y:50+o*60}))},[l]);return e.jsx("svg",{width:"100%",height:50+n.length*60,className:"min-h-[200px]",children:n.map((s,a)=>{const r=n[a+1];return e.jsxs("g",{children:[r&&e.jsx("line",{x1:s.x,y1:s.y,x2:r.x,y2:r.y,stroke:"var(--color-border)",strokeWidth:"2"}),e.jsxs("g",{className:"group cursor-pointer",children:[e.jsx("circle",{cx:s.x,cy:s.y,r:"8",fill:"var(--color-primary)",stroke:"var(--color-surface)",strokeWidth:"3"}),e.jsx("foreignObject",{x:s.x+20,y:s.y-25,width:"350",height:"50",children:e.jsxs("div",{className:"text-sm p-1",children:[e.jsx("p",{className:"font-bold truncate text-text-primary",children:s.message}),e.jsxs("p",{className:"text-xs text-text-secondary font-mono",children:[s.shortHash," ",e.jsx("span",{className:"text-amber-600",children:s.refs})]})]})}),e.jsx("title",{children:`Commit: ${s.hash}20Author: ${s.author}21 22${s.message}`})]})]},s.hash)})})},O=({logInput:l})=>{const[n,s]=i.useState(l||N),[a,r]=i.useState(""),[t,o]=i.useState(!1),[x,h]=i.useState(""),u=i.useCallback(async c=>{if(!c.trim()){h("Please paste git log output.");return}o(!0),h(""),r("");try{const m=b(c);let d="";for await(const p of m)d+=p,r(d)}catch(m){const d=m instanceof Error?m.message:"An unknown error occurred.";h(`Failed to analyze log: ${d}`)}finally{o(!1)}},[]);return i.useEffect(()=>{l&&(s(l),u(l))},[l,u]),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(g,{}),e.jsx("span",{className:"ml-3",children:"Visual Git Tree"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Paste your `git log --graph` output to visualize the history and get an AI summary."})]}),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:"log-input",className:"text-sm font-medium text-text-secondary mb-2",children:"Git Log Output"}),e.jsx("textarea",{id:"log-input",value:n,onChange:c=>s(c.target.value),placeholder:"Paste your git log output here...",className:"flex-grow p-4 bg-surface border border-border rounded-md resize-none font-mono text-sm"}),e.jsx("button",{onClick:()=>u(n),disabled:t,className:"btn-primary mt-4 w-full flex items-center justify-center px-6 py-3",children:t?e.jsx(f,{}):"Analyze & Summarize"})]}),e.jsxs("div",{className:"flex flex-col h-full gap-4",children:[e.jsxs("div",{className:"flex flex-col h-1/2",children:[e.jsx("label",{className:"text-sm font-medium text-text-secondary mb-2",children:"Commit Graph"}),e.jsx("div",{className:"flex-grow p-2 bg-surface border border-border rounded-md overflow-auto",children:e.jsx(w,{logInput:n})})]}),e.jsxs("div",{className:"flex flex-col h-1/2",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-text-secondary",children:"AI Summary"}),a&&!t&&e.jsxs("button",{onClick:()=>v(a,"summary.md","text/markdown"),className:"flex items-center gap-1 px-3 py-1 bg-gray-100 text-xs rounded-md hover:bg-gray-200",children:[e.jsx(j,{className:"w-4 h-4"})," Download Summary"]})]}),e.jsxs("div",{className:"flex-grow p-4 bg-background border border-border rounded-md overflow-y-auto",children:[t&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(f,{})}),x&&e.jsx("p",{className:"text-red-500",children:x}),a&&!t&&e.jsx(y,{content:a}),!t&&!a&&!x&&e.jsx("div",{className:"text-text-secondary h-full flex items-center justify-center",children:"AI summary will appear here."})]})]})]})]})]})};export{O as VisualGitTree};23//# sourceMappingURL=VisualGitTree-QMEtdddq.js.map24 