heyiam 0.2.22 → 0.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.js +2 -0
- package/dist/export.js +7 -5
- package/dist/format-utils.js +8 -0
- package/dist/mount.js +8 -1
- package/dist/public/assets/{index-CRlRJPQx.js → index-B_d6DlEI.js} +1 -1
- package/dist/public/assets/index-Dalqz2mC.css +1 -0
- package/dist/public/index.html +2 -2
- package/dist/render/liquid.js +1 -1
- package/dist/render/templates/project.liquid +5 -1
- package/dist/routes/enhance.js +6 -2
- package/dist/routes/publish.js +32 -17
- package/dist/settings.js +1 -0
- package/dist/sync.js +2 -8
- package/package.json +1 -1
- package/dist/public/assets/index-Db79-YaJ.css +0 -1
|
@@ -17,5 +17,5 @@ codebase over time. Green is
|
|
|
17
17
|
additions, red is deletions.`,`Each session is a card you can
|
|
18
18
|
click to see the full AI
|
|
19
19
|
conversation transcript.`];return(0,F.jsxs)(Ar,{chips:[{label:`local-first`,variant:`primary`},{label:`private by default`,variant:`green`}],actions:(0,F.jsx)(`div`,{className:`flex items-center gap-3`,children:M?(0,F.jsx)(`button`,{onClick:ne,className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors`,children:`Skip tour`}):(0,F.jsx)(P,{to:`/settings`,className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors`,children:`Settings`})}),children:[e!==`dashboard`&&(0,F.jsxs)(`div`,{className:`flex min-h-[calc(100vh-3rem)]`,style:{justifyContent:ae?`flex-start`:`center`,alignItems:ae?`flex-start`:`center`},children:[(0,F.jsxs)(`div`,{className:`shrink-0 transition-all duration-700 ease-[cubic-bezier(0.16,1,0.3,1)]`,style:{width:ae?340:`100%`,maxWidth:ae?340:680,padding:ae?`1.5rem 1rem 1.5rem 1.5rem`:`0 1.5rem`,position:ae?`sticky`:`relative`,top:ae?48:`auto`,alignSelf:ae?`flex-start`:`center`},children:[e===`loading`&&(0,F.jsxs)(Zi,{compact:!1,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam`}),(0,F.jsx)(U,{variant:`active`,children:` Connecting...`})]}),e===`syncing`&&i&&(0,F.jsxs)(Zi,{compact:!1,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam`}),(0,F.jsx)(U,{variant:`info`,children:` Indexing your AI coding sessions.`}),(0,F.jsx)(U,{variant:`info`,children:` Everything stays on your machine.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),i.phase===`discovering`&&(0,F.jsx)(U,{variant:`active`,children:` Discovering sessions...`}),(i.phase===`indexing`||i.phase===`done`)&&(0,F.jsxs)(U,{variant:`passed`,children:[` Found `,i.parentCount,` sessions`]}),i.phase===`indexing`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(U,{variant:`active`,children:[` `,`Indexing... (`,i.current,`/`,i.total,`)`,i.currentProject?` — ${i.currentProject}`:``]}),o.size>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`section`,children:` Projects found:`}),[...o].slice(0,8).map(e=>(0,F.jsxs)(U,{variant:`default`,children:[` `,e]},e)),o.size>8&&(0,F.jsxs)(U,{variant:`default`,children:[` ...and `,o.size-8,` more`]})]})]}),i.phase===`done`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(U,{variant:`passed`,children:[` Indexed `,i.total,` sessions`]}),(0,F.jsx)(U,{variant:`passed`,children:` Ready.`})]})]}),e===`reveal`&&re&&(0,F.jsxs)(Zi,{compact:!1,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam`}),(0,F.jsxs)(U,{variant:`passed`,children:[` Indexed `,re.sessionCount,` sessions. Ready.`]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`section`,children:` Your coding in numbers:`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),c>=1&&(0,F.jsxs)(U,{variant:`reveal`,children:[` `,(0,F.jsx)(`span`,{className:`text-[#9dcaff] font-semibold`,children:re.sessionCount}),` sessions indexed`]}),c>=2&&(0,F.jsxs)(U,{variant:`reveal`,children:[` `,(0,F.jsx)(`span`,{className:`text-[#9dcaff] font-semibold`,children:re.projectCount}),` projects discovered`]}),c>=3&&(0,F.jsxs)(U,{variant:`reveal`,children:[` `,(0,F.jsx)(`span`,{className:`text-[#9dcaff] font-semibold`,children:re.sourceCount}),` `,re.sourceCount===1?`tool`:`tools`,` detected`]}),c>=4&&j&&(0,F.jsxs)(U,{variant:`reveal`,children:[` `,`Biggest: `,(0,F.jsx)(`span`,{className:`text-[#9dcaff] font-semibold`,children:j.projectName}),` (`,j.sessionCount,` sessions)`]})]}),e===`prompt_project`&&(0,F.jsxs)(Zi,{compact:!1,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam`}),(0,F.jsxs)(U,{variant:`passed`,children:[` `,re?.sessionCount,` sessions across `,re?.projectCount,` projects.`]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`info`,children:` Here's what a project page looks`}),(0,F.jsx)(U,{variant:`info`,children:` like — with timeline, growth chart,`}),(0,F.jsx)(U,{variant:`info`,children:` and clickable sessions.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(Qi,{question:`See a demo project?`,onYes:()=>t(`preview_project`),onNo:()=>t(`prompt_enhance`)})]}),e===`preview_project`&&(0,F.jsxs)(Zi,{compact:!0,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam project view`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),g?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(U,{variant:`info`,children:` Viewing session detail.`}),(0,F.jsx)(U,{variant:`info`,children:` Click X to go back.`})]}):(0,F.jsxs)(F.Fragment,{children:[oe[u]?.split(`
|
|
20
|
-
`).map((e,t)=>(0,F.jsxs)(U,{variant:`info`,children:[` `,e]},`${u}-${t}`)),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(U,{variant:`default`,children:[` `,(0,F.jsxs)(`span`,{className:`text-white/30`,children:[`section `,u+1,`/4`]})]})]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(Qi,{question:`Enhance this project?`,onYes:()=>{v(null),t(`preview_enhanced`)},onNo:()=>{v(null),t(`preview_enhanced`)},yesLabel:`Enhance`,noLabel:`Skip`})]}),e===`preview_enhanced`&&(0,F.jsxs)(Zi,{compact:!0,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam enhance heyi-am`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`passed`,children:` Reading 16 sessions...`}),(0,F.jsx)(U,{variant:`passed`,children:` Extracting skills...`}),(0,F.jsx)(U,{variant:`passed`,children:` Writing narrative...`}),(0,F.jsx)(U,{variant:`passed`,children:` Building project arc...`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`passed`,children:` Enhanced. Scroll to see the`}),(0,F.jsx)(U,{variant:`passed`,children:` difference.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(Qi,{question:`Continue tour?`,onYes:()=>t(`prompt_enhance`),onNo:()=>ne()})]}),e===`prompt_enhance`&&(0,F.jsxs)(Zi,{compact:!0,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam enhance`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`info`,children:` To enhance your own projects,`}),(0,F.jsx)(U,{variant:`info`,children:` you need an Anthropic API key.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),m?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(U,{variant:`passed`,children:` API key saved. You're all set.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(Qi,{question:`Continue?`,onYes:()=>t(`claim_username`),onNo:()=>t(`claim_username`)})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Qi,{question:`Add your API key now?`,onYes:()=>{},onNo:()=>t(`claim_username`),noLabel:`I'll do this later`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(`div`,{className:`triage-terminal__line opacity-80`,children:` Paste your key:`}),(0,F.jsx)(`div`,{className:`flex items-center gap-2 mt-1 ml-4`,children:(0,F.jsx)(`input`,{type:`password`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f.startsWith(`sk-`)&&ur(f).then(()=>h(!0)).catch(()=>{})},placeholder:`sk-ant-...`,className:`bg-white/10 border border-white/20 rounded px-2 py-1 text-[11px] font-mono text-[#34d399] w-48 outline-none focus:border-[#9dcaff] placeholder:text-white/20`})}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(`div`,{className:`triage-terminal__line opacity-40 text-[10px]`,children:[` `,`You can always add this later in Settings.`]})]})]}),e===`claim_username`&&(0,F.jsxs)(Zi,{compact:!1,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam publish`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`section`,children:` Claim your portfolio page`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`info`,children:` Want to show off your AI dev work?`}),(0,F.jsx)(U,{variant:`info`,children:` Claim a name and create a public`}),(0,F.jsx)(U,{variant:`info`,children:` portfolio on heyi.am — show how`}),(0,F.jsx)(U,{variant:`info`,children:` you build, not just what you ship.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(U,{variant:`info`,children:[` Your page: `,(0,F.jsxs)(`span`,{className:`text-[#9dcaff] font-semibold`,children:[`heyi.am/`,y||`your-name`]})]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(`div`,{className:`triage-terminal__line opacity-40 text-[10px]`,children:[` `,`Optional — the CLI works fully without an account.`]}),(0,F.jsxs)(`div`,{className:`triage-terminal__line opacity-40 text-[10px]`,children:[` `,`You choose what to publish. Nothing is public by default.`]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),x===`claimed`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(U,{variant:`passed`,children:[` Welcome, `,T,`!`]}),(0,F.jsxs)(U,{variant:`passed`,children:[` heyi.am/`,T,` is yours.`]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(Qi,{question:`Ready to explore?`,onYes:ne,onNo:ne,yesLabel:`Let's go`})]}):D?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(U,{variant:`active`,children:` Waiting for signup to complete...`}),(0,F.jsx)(U,{variant:`info`,children:` A browser window should have opened.`}),(0,F.jsx)(U,{variant:`info`,children:` Sign up there, then come back here.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 ml-4`,children:[(0,F.jsx)(`button`,{onClick:()=>{O(!1),S(`idle`),k(``)},className:`text-[10px] font-mono px-2.5 py-1 rounded text-white/40 hover:text-white/70 transition-colors`,children:`Cancel`}),(0,F.jsx)(`button`,{onClick:()=>{O(!1),ne()},className:`text-[10px] font-mono px-2.5 py-1 rounded text-white/40 hover:text-white/70 transition-colors`,children:`Skip this`})]})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`triage-terminal__line opacity-80`,children:` Choose a username:`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 ml-4`,children:[(0,F.jsx)(`span`,{className:`text-white/40 text-[11px] font-mono`,children:`heyi.am/`}),(0,F.jsx)(`input`,{type:`text`,value:y,onChange:e=>{let t=e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,``);b(t),S(`idle`),w(``),A.current&&clearTimeout(A.current),t.length>=3&&t!==te.current&&(A.current=setTimeout(async()=>{te.current=t,S(`checking`);try{let e=await br(t);S(e.available?`available`:`taken`),e.available||w(e.reason||`Taken`)}catch{S(`idle`)}},500))},onKeyDown:async e=>{if(e.key===`Enter`&&y.length>=3){if(e.preventDefault(),x===`submitting`||x===`checking`||D)return;A.current&&clearTimeout(A.current),S(`submitting`),w(``);try{let e=await br(y);if(!e.available){S(`taken`),w(e.reason||`Username is taken`);return}let t=await xr(y);k(t.device_code),O(!0),S(`available`),window.open(t.verification_uri,`_blank`);let n=Date.now(),r=async()=>{try{let e=await yr(t.device_code);if(e.authenticated){O(!1),S(`claimed`),E(e.username||y);return}}catch{}Date.now()-n<3e5?setTimeout(r,5e3):(O(!1),S(`error`),w(`Timed out. Try again.`))};setTimeout(r,5e3)}catch{S(`error`),w(`Could not connect. Try again later.`)}}},placeholder:`your-name`,className:`bg-white/10 border border-white/20 rounded px-2 py-1 text-[11px] font-mono text-[#34d399] w-36 outline-none focus:border-[#9dcaff] placeholder:text-white/20`,autoFocus:!0}),x===`checking`&&(0,F.jsx)(`span`,{className:`text-[10px] text-[#fbbf24] font-mono`,children:`checking...`}),x===`available`&&(0,F.jsx)(`span`,{className:`text-[10px] text-[#34d399] font-mono`,children:`available!`}),x===`submitting`&&(0,F.jsx)(`span`,{className:`text-[10px] text-[#fbbf24] font-mono`,children:`claiming...`}),x===`taken`&&(0,F.jsx)(`span`,{className:`text-[10px] text-[#f87171] font-mono`,children:C}),x===`error`&&(0,F.jsx)(`span`,{className:`text-[10px] text-[#f87171] font-mono`,children:C})]}),y.length>=3&&x===`idle`&&(0,F.jsxs)(`div`,{className:`triage-terminal__line opacity-40 text-[10px] mt-1`,children:[` `,`Press Enter to check & claim`]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 ml-4`,children:[(0,F.jsx)(`button`,{disabled:D||x===`submitting`,onClick:async()=>{if(!(D||x===`submitting`)){S(`submitting`),w(``);try{let e=await xr(``);k(e.device_code),O(!0),S(`idle`),window.open(e.verification_uri,`_blank`);let t=Date.now(),n=async()=>{try{let t=await yr(e.device_code);if(t.authenticated){O(!1),S(`claimed`),E(t.username||``);return}}catch{}Date.now()-t<3e5?setTimeout(n,5e3):(O(!1),S(`error`),w(`Timed out.`))};setTimeout(n,5e3)}catch{S(`error`),w(`Could not connect. Try again later.`)}}},className:`text-[10px] font-mono px-2.5 py-1 rounded bg-white/10 text-white/70 hover:text-white/90 hover:bg-white/15 transition-colors disabled:opacity-40`,children:`Already have an account? Log in`}),(0,F.jsx)(`button`,{onClick:()=>ne(),className:`text-[10px] font-mono px-2.5 py-1 rounded text-white/40 hover:text-white/70 transition-colors`,children:`I'll do this later`})]})]})]})]}),ae&&(0,F.jsx)(`div`,{className:`flex-1 min-w-0 pr-4 pt-6 pb-8 animate-[slideIn_0.6s_cubic-bezier(0.16,1,0.3,1)_forwards]`,children:(e===`preview_project`||e===`preview_enhanced`||e===`prompt_enhance`)&&(0,F.jsx)(qi,{enhanced:e===`preview_enhanced`||e===`prompt_enhance`,onScrollSection:d,selectedSession:g,onSelectSession:v},e===`preview_project`?`draft`:`enhanced`)})]}),e===`dashboard`&&(0,F.jsx)($i,{dashboard:n,stats:re,projects:ie})]})}var Wi=[`bg-primary`,`bg-green`,`bg-violet`];function Gi(){let e=[`Set up project scaffolding with Vite + React + TypeScript`,`Build SQLite sync pipeline for session indexing`,`Implement real-time file watcher with debounce`,`Design project detail page with work timeline`,`Add full-text search across all sessions`,`Fix subagent indexing — children were silently dropped`,`Add multi-agent orchestration visualization`,`Build guided onboarding flow with CLI aesthetics`,`Implement session archiving with hard links`,`Add Cursor workspace discovery and polling`,`Design growth chart with cumulative LOC tracking`,`Build publish flow with streaming SSE upload`,`Add Ed25519 session sealing for interviews`,`Implement project-level AI enhancement pipeline`,`Fix work timeline SVG rendering for long sessions`,`Add context export in compact/summary/full formats`],t=[`TypeScript`,`React`,`SQLite`,`Node.js`,`CSS`,`Vite`,`Shell`,`Vitest`],n=[`claude`,`claude`,`claude`,`cursor`,`claude`,`codex`],r=new Date(`2026-02-15T10:00:00Z`),i=[];for(let a=0;a<e.length;a++){let o=new Date(r.getTime()+a*2.5*864e5+Math.random()*432e5),s=15+Math.floor(Math.random()*120),c=new Date(o.getTime()+s*6e4),l=Math.floor(200+Math.random()*5e3),u=Math.floor(50+Math.random()*l*.3),d=a%4==0?[{sessionId:`child-${a}-1`,role:`frontend-dev`,durationMinutes:Math.floor(s*.6),linesOfCode:Math.floor(l*.3),date:o.toISOString()},{sessionId:`child-${a}-2`,role:`qa-engineer`,durationMinutes:Math.floor(s*.4),linesOfCode:Math.floor(l*.15),date:o.toISOString()}]:a%3==0?[{sessionId:`child-${a}-1`,role:`backend-dev`,durationMinutes:Math.floor(s*.7),linesOfCode:Math.floor(l*.4),date:o.toISOString()}]:void 0;i.push({id:`mock-session-${a}`,title:e[a],date:o.toISOString(),endTime:c.toISOString(),durationMinutes:s,wallClockMinutes:s+Math.floor(Math.random()*30),turns:10+Math.floor(Math.random()*60),linesOfCode:l+u,status:`draft`,projectName:`heyi-am`,rawLog:[],skills:[t[a%t.length],t[(a+3)%t.length]],source:n[a%n.length],filesChanged:[[`src/sync.ts`,`src/db.ts`,`src/parsers/index.ts`,`src/server.ts`,`src/bridge.ts`],[`src/analyzer.ts`,`src/search.ts`,`src/settings.ts`,`src/export.ts`],[`app/src/components/ProjectDetail.tsx`,`app/src/components/WorkTimeline.tsx`,`app/src/api.ts`],[`src/routes/projects.ts`,`src/routes/sessions.ts`,`src/routes/dashboard.ts`,`app/src/types.ts`],[`src/parsers/claude.ts`,`src/parsers/cursor.ts`,`src/parsers/codex.ts`,`src/parsers/gemini.ts`],[`app/src/components/FirstRun.tsx`,`app/src/index.css`,`src/routes/export.ts`],[`src/archive.ts`,`src/context-export.ts`,`app/src/components/Search.tsx`],[`app/src/components/GrowthChart.tsx`,`app/src/components/SessionView.tsx`,`src/transcript.ts`]][a%8].map((e,t)=>({path:e,additions:Math.floor(l/(t+1.5)),deletions:Math.floor(u/(t+2))})),toolBreakdown:[{tool:`Read`,count:15+Math.floor(Math.random()*30)},{tool:`Edit`,count:8+Math.floor(Math.random()*25)},{tool:`Bash`,count:5+Math.floor(Math.random()*20)},{tool:`Write`,count:2+Math.floor(Math.random()*10)},{tool:`Grep`,count:3+Math.floor(Math.random()*8)},{tool:`Glob`,count:1+Math.floor(Math.random()*5)}],children:d,childCount:d?.length??0,isOrchestrated:!!d})}return i}var Ki=Gi();function qi({enhanced:e,onScrollSection:t,selectedSession:n,onSelectSession:r}){let i=(0,_.useRef)([]);(0,_.useEffect)(()=>{let e=[];return i.current.forEach((n,r)=>{if(!n)return;let i=new IntersectionObserver(([e])=>{e.isIntersecting&&t(r)},{threshold:.3});i.observe(n),e.push(i)}),()=>e.forEach(e=>e.disconnect())},[t]);let a=Ki.reduce((e,t)=>e+t.linesOfCode,0);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Xi,{url:`localhost:17845/project/heyi-am`,children:(0,F.jsxs)(`div`,{className:`bg-surface-mid`,children:[(0,F.jsxs)(`div`,{ref:e=>{i.current[0]=e},className:`p-5 pb-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`font-display text-xl font-bold text-on-surface`,children:`heyi-am`}),(0,F.jsx)(`span`,{className:`text-on-surface-variant text-[0.8125rem]`,children:`Feb 15 – Mar 25, 2026`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(I,{variant:e?`green`:`primary`,children:e?`Enhanced`:`Draft`}),(0,F.jsx)(I,{variant:`primary`,children:`16 sessions`})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-1 mb-2`,children:[(0,F.jsxs)(`a`,{href:`https://heyi.am`,target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-xs text-primary hover:underline flex items-center gap-1`,children:[(0,F.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 16 16`,fill:`currentColor`,children:(0,F.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z`})}),`github.com/interactivecats/heyi.am`]}),(0,F.jsxs)(`a`,{href:`https://heyi.am`,target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-xs text-primary hover:underline flex items-center gap-1`,children:[(0,F.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,F.jsx)(`path`,{d:`M6.5 10.5l3-3m-1.5-2a2.5 2.5 0 013.54 3.54l-1.5 1.5m-4.08-1.08a2.5 2.5 0 01-3.54-3.54l1.5-1.5`})}),`heyi.am`]})]}),(0,F.jsxs)(`div`,{className:`rounded-md border border-ghost overflow-hidden shadow-sm mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2 bg-surface-low border-b border-ghost`,children:[(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#ff5f57]`}),(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#febc2e]`}),(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#28c840]`})]}),(0,F.jsx)(`div`,{className:`max-h-96 overflow-y-auto`,children:(0,F.jsx)(`img`,{src:`/heyi-am-screenshot.png`,alt:`heyi.am — proof-of-work for AI-native developers`,className:`w-full h-auto`})})]}),e&&(0,F.jsxs)(L,{className:`my-3`,children:[(0,F.jsx)(z,{title:`Narrative summary`,meta:`AI-generated`}),(0,F.jsx)(`p`,{className:`leading-relaxed text-on-surface border-l-[3px] border-primary pl-3`,style:{fontSize:`clamp(0.8125rem, 1.2vw, 1rem)`},children:`Built a local-first developer portfolio tool that indexes AI coding sessions across Claude Code, Cursor, Codex, and Gemini CLI. Designed a real-time sync pipeline with SQLite indexing, implemented multi-agent session visualization, and shipped a guided onboarding flow.`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-3 mb-4`,children:[(0,F.jsx)(Nr,{label:`Sessions`,value:16}),(0,F.jsx)(Nr,{label:`Human / Agents`,value:`52h / 78h`}),(0,F.jsx)(Nr,{label:`Lines changed`,value:Hi(a)}),(0,F.jsx)(Nr,{label:`Files`,value:847})]})]}),e&&(0,F.jsx)(`div`,{className:`px-5 pb-4`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Project arc`,meta:`AI-generated`}),(0,F.jsxs)(`div`,{className:`relative pl-5`,children:[(0,F.jsx)(`div`,{className:`absolute left-1 top-1.5 bottom-1.5 w-0.5 bg-ghost rounded-full`}),[{title:`Foundation`,desc:`Set up project scaffolding, parser pipeline, and SQLite schema`},{title:`Core features`,desc:`Built sync engine, search, work timeline, and growth chart`},{title:`Polish`,desc:`Onboarding flow, subagent visualization, export pipeline`}].map(e=>(0,F.jsxs)(`div`,{className:`relative pb-3 last:pb-0`,children:[(0,F.jsx)(`div`,{className:`absolute -left-5 top-1.5 w-2 h-2 rounded-full bg-primary shadow-[0_0_0_3px_rgba(8,68,113,0.1)]`}),(0,F.jsx)(`div`,{className:`font-mono text-[0.6875rem] uppercase tracking-wider text-on-surface-variant`,children:e.title}),(0,F.jsx)(R,{children:(0,F.jsx)(`span`,{className:`text-on-surface-variant`,children:e.desc})})]},e.title))]})]})}),e&&(0,F.jsx)(`div`,{className:`px-5 pb-4`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Skills extracted`,meta:`14 skills`}),(0,F.jsx)(`div`,{className:`flex gap-1.5 flex-wrap`,children:[`TypeScript`,`React`,`SQLite`,`Node.js`,`CSS`,`Vite`,`Vitest`,`Shell`,`HTML`,`Express`,`SSE`,`FTS5`,`Ed25519`,`Docker`].map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e))})]})}),(0,F.jsx)(`div`,{ref:e=>{i.current[1]=e},className:`px-5 pb-4`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Work timeline`,meta:`sessions over time`}),(0,F.jsx)(Ei,{sessions:Ki,maxHeight:280})]})}),(0,F.jsx)(`div`,{ref:e=>{i.current[2]=e},className:`px-5 pb-4`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Project growth`,meta:`lines changed`}),(0,F.jsx)(zi,{sessions:Ki,totalLoc:a,totalFiles:847})]})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 px-5 pb-4`,children:[(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Key decisions`,meta:`signal`}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(R,{title:`SQLite over filesystem`,children:`Chose SQLite for session indexing over raw filesystem scans — 10x faster project listing.`}),(0,F.jsx)(R,{title:`Local-first architecture`,children:`All data stays on the user's machine. No cloud dependency for core features.`}),(0,F.jsx)(R,{title:`Multi-parser pipeline`,children:`One bridge layer normalizes data from Claude, Cursor, Codex, and Gemini into a shared schema.`})]}):(0,F.jsx)(R,{children:`Enhance this project to extract key decisions.`})})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Source breakdown`,meta:`provenance`}),(0,F.jsxs)(`table`,{className:`w-full border-collapse text-[0.8125rem]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Source`}),(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Count`})]})}),(0,F.jsx)(`tbody`,{children:[{source:`claude`,count:10},{source:`cursor`,count:3},{source:`codex`,count:2},{source:`gemini`,count:1}].map(e=>(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:e.source}),(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:e.count})]},e.source))})]})]})]}),(0,F.jsx)(`div`,{ref:e=>{i.current[3]=e},className:`px-5 pb-5`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:e?`Featured sessions`:`Sessions`,meta:`${Ki.length} total`}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:Ki.slice(0,6).map((e,t)=>(0,F.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`text-left bg-surface-lowest border border-ghost rounded-sm p-4 cursor-pointer transition-shadow hover:shadow-md`,children:[(0,F.jsx)(`div`,{className:`h-1 rounded-full mb-3 ${Wi[t%Wi.length]}`}),(0,F.jsx)(`h4`,{className:`font-display text-[0.8125rem] font-semibold text-on-surface mb-1 line-clamp-2`,children:e.title}),(0,F.jsxs)(`span`,{className:`text-on-surface-variant text-xs`,children:[Vi(e.durationMinutes),` · `,e.turns,` turns · `,Hi(e.linesOfCode),` lines`]}),e.skills?.[0]&&(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(I,{variant:`violet`,children:e.skills[0]})})]},e.id))})]})})]})}),n&&(0,F.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-black/40`,onClick:e=>{e.target===e.currentTarget&&r(null)},children:(0,F.jsx)(`div`,{className:`w-[600px] max-w-full h-full bg-surface overflow-y-auto shadow-[-8px_0_32px_rgba(25,28,30,0.1)] animate-[slideIn_0.3s_ease_forwards]`,children:(0,F.jsxs)(`div`,{className:`p-8`,children:[(0,F.jsx)(`div`,{className:`flex items-center gap-3 mb-6`,children:(0,F.jsx)(`button`,{type:`button`,onClick:()=>r(null),className:`font-mono text-[0.8125rem] text-on-surface-variant bg-surface-low border border-surface-high rounded-md px-3 py-1 cursor-pointer hover:text-on-surface`,children:`ESC · Close`})}),(0,F.jsx)(`h2`,{className:`font-display text-2xl font-bold text-on-surface mb-2`,children:n.title}),(0,F.jsxs)(`div`,{className:`font-mono text-[0.6875rem] uppercase tracking-wider text-on-surface-variant mb-4`,children:[new Date(n.date).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),n.source&&` · ${n.source}`]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-3 mb-5`,children:[(0,F.jsx)(Ji,{label:`Active Time`,value:Vi(n.durationMinutes),primary:!0}),(0,F.jsx)(Ji,{label:`Turns`,value:n.turns}),(0,F.jsx)(Ji,{label:`Files`,value:n.filesChanged?.length??`—`}),(0,F.jsx)(Ji,{label:`Lines changed`,value:Hi(n.linesOfCode)})]}),e&&(0,F.jsx)(`p`,{className:`text-[0.9375rem] leading-relaxed text-on-surface border-l-[3px] border-primary pl-3 mb-5`,children:`Implemented the core sync pipeline that discovers sessions from the filesystem, checks staleness against SQLite, and indexes new or changed sessions with full text search support.`}),n.skills&&n.skills.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-5`,children:n.skills.map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e))}),n.turns>=50&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsxs)(Yi,{children:[`Session Activity · `,n.turns,` turns over `,Vi(n.durationMinutes)]}),(0,F.jsx)(Ei,{sessions:[n],maxHeight:200})]}),(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(Yi,{children:`Execution Path`}),(e?[{n:1,title:`Read existing parsers and DB schema`,desc:`Analyzed the current session discovery pipeline and SQLite schema to understand the data flow`},{n:2,title:`Build staleness checker`,desc:`Compared file mtime/size against DB records to skip unchanged sessions`},{n:3,title:`Implement indexing loop`,desc:`Parse → bridge → analyze → upsert for each stale session, with progress reporting`}]:(()=>{let e=n.filesChanged??[],t=[],r=Math.max(1,Math.ceil(e.length/3));for(let n=0;n<e.length;n+=r){let i=e.slice(n,n+r);t.push({n:t.length+1,title:`Modified ${i.map(e=>e.path.split(`/`).pop()).join(`, `)}`,desc:``})}return t.length>0?t:[{n:1,title:`Modified multiple files`,desc:``}]})()).map(e=>(0,F.jsxs)(`div`,{className:`flex gap-3 items-start py-2.5 border-b border-ghost last:border-b-0`,children:[(0,F.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-primary text-white font-mono text-[0.625rem] font-bold flex items-center justify-center flex-shrink-0`,children:e.n}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`font-semibold text-sm text-on-surface mb-0.5`,children:e.title}),e.desc&&(0,F.jsx)(`div`,{className:`text-[0.8125rem] text-on-surface-variant leading-relaxed`,children:e.desc})]})]},e.n))]}),n.toolBreakdown&&n.toolBreakdown.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(Yi,{children:`Tool Usage`}),n.toolBreakdown.map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between items-center py-1.5 border-b border-ghost last:border-b-0 font-mono text-xs`,children:[(0,F.jsx)(`span`,{className:`text-on-surface`,children:e.tool}),(0,F.jsx)(`span`,{className:`text-on-surface-variant`,children:e.count})]},e.tool))]}),n.filesChanged&&n.filesChanged.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(Yi,{children:`Top Files`}),n.filesChanged.slice(0,10).map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between items-center py-1.5 border-b border-ghost last:border-b-0 font-mono text-xs`,children:[(0,F.jsx)(`span`,{className:`text-on-surface truncate min-w-0`,children:e.path}),(0,F.jsxs)(`span`,{className:`flex-shrink-0 ml-2 whitespace-nowrap`,children:[(0,F.jsxs)(`span`,{className:`text-green-600 font-semibold`,children:[`+`,e.additions]}),(0,F.jsxs)(`span`,{className:`text-red-600 font-semibold ml-1`,children:[`-`,e.deletions]})]})]},e.path))]})]})})})]})}function Ji({label:e,value:t,primary:n}){return(0,F.jsxs)(`div`,{className:`text-center p-3 border border-ghost rounded-sm bg-surface-lowest`,children:[(0,F.jsx)(`div`,{className:`font-mono text-xl font-bold ${n?`text-primary`:`text-on-surface`}`,children:t}),(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-on-surface-variant mt-1`,children:e})]})}function Yi({children:e}){return(0,F.jsx)(`div`,{className:`font-mono text-[0.625rem] font-semibold uppercase tracking-wider text-on-surface-variant mb-2.5`,children:e})}function Xi({url:e,children:t}){return(0,F.jsxs)(`div`,{className:`rounded-lg border border-[#d1d5db] bg-white shadow-xl overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-[#f1f3f5] border-b border-[#d1d5db]`,children:[(0,F.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-[10px] h-[10px] rounded-full bg-[#ff5f57]`}),(0,F.jsx)(`div`,{className:`w-[10px] h-[10px] rounded-full bg-[#febc2e]`}),(0,F.jsx)(`div`,{className:`w-[10px] h-[10px] rounded-full bg-[#28c840]`})]}),(0,F.jsx)(`div`,{className:`flex-1 mx-2`,children:(0,F.jsx)(`div`,{className:`bg-white rounded-md border border-[#d1d5db] px-3 py-1 text-[10px] text-[#6b7280] font-mono`,children:e})})]}),(0,F.jsx)(`div`,{className:`bg-[#f1f5f9] max-h-[70vh] overflow-y-auto`,children:t})]})}function Zi({children:e,compact:t}){let n=(0,_.useRef)(null);return(0,_.useEffect)(()=>{n.current?.scrollTo({top:n.current.scrollHeight})}),(0,F.jsxs)(`div`,{className:`triage-terminal`,style:{maxWidth:t?340:680,margin:`0 auto`,padding:t?`0.875rem 1rem 0.625rem`:`1.5rem 1.5rem 1rem`,fontSize:t?`0.6875rem`:`0.8125rem`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-3`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-[#ff5f57]`}),(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-[#febc2e]`}),(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-[#28c840]`})]}),(0,F.jsx)(`div`,{ref:n,className:`triage-terminal__feed`,children:e})]})}function U({variant:e,children:t}){return(0,F.jsx)(`div`,{className:`triage-terminal__line ${e===`prompt`?`triage-terminal__prompt`:e===`passed`?`triage-terminal__line--passed`:e===`active`?`triage-terminal__line--active`:e===`section`?`triage-terminal__section`:e===`reveal`?`triage-terminal__line--passed opacity-0 animate-[fadeIn_0.3s_ease_forwards]`:e===`info`?`opacity-80`:``}`,children:t})}function Qi({question:e,onYes:t,onNo:n,defaultNo:r,yesLabel:i,noLabel:a}){let o=(0,_.useRef)(null),[s,c]=(0,_.useState)(r?``:`Y`);return(0,_.useEffect)(()=>{let e=setTimeout(()=>o.current?.focus(),100);return()=>clearTimeout(e)},[]),(0,F.jsxs)(`div`,{className:`mt-1`,children:[(0,F.jsxs)(`div`,{className:`triage-terminal__line flex items-center gap-0 flex-wrap`,children:[(0,F.jsx)(`span`,{className:`text-[#9dcaff] font-semibold`,children:` > `}),(0,F.jsxs)(`span`,{children:[e,` `]}),(0,F.jsxs)(`span`,{className:`text-white/40`,children:[r?`[y/N]`:`[Y/n]`,` `]}),(0,F.jsx)(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let r=s.trim().toLowerCase();r===``||r===`y`||r===`yes`?t():n()}},className:`bg-transparent border-none outline-none text-[#34d399] font-mono w-12 caret-[#34d399]`,style:{fontSize:`inherit`,lineHeight:`inherit`,padding:0}})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 ml-4`,children:[(0,F.jsxs)(`button`,{onClick:t,className:`text-[10px] font-mono px-2.5 py-1 rounded bg-white/10 text-white/90 hover:bg-white/20 transition-colors`,children:[i??`Yes`,` `,(0,F.jsx)(`span`,{className:`text-white/30 ml-0.5`,children:`↵`})]}),(0,F.jsx)(`button`,{onClick:n,className:`text-[10px] font-mono px-2.5 py-1 rounded text-white/40 hover:text-white/70 transition-colors`,children:a??`No`})]})]})}function $i({dashboard:e,stats:t,projects:n}){let r=n.slice(0,4),i=t?.enhancedCount??0;return(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsx)(`h1`,{className:`font-display text-[1.75rem] leading-[1.1] font-bold text-on-surface`,children:`Turn your AI sessions into a dev portfolio.`}),t&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`h-6`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-4`,children:[(0,F.jsx)(ta,{label:`Sessions indexed`,value:t.sessionCount,to:`/archive`,color:`var(--primary)`}),(0,F.jsx)(ta,{label:`Projects`,value:t.projectCount,to:`/projects`}),(0,F.jsx)(ta,{label:`Enhanced`,value:i,to:`/projects`,color:i>0?`#34d399`:void 0}),(0,F.jsx)(ta,{label:`Sources`,value:t.sourceCount,to:`/sources`})]})]}),(0,F.jsx)(`div`,{className:`h-6`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,F.jsx)(P,{to:`/sources`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-4 py-2 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,children:`Sync new sessions`}),(0,F.jsx)(P,{to:`/projects`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-4 py-2 rounded-sm text-primary border border-ghost hover:border-outline transition-colors`,children:`View projects`}),(0,F.jsx)(P,{to:`/search`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-4 py-2 rounded-sm text-primary border border-ghost hover:border-outline transition-colors`,children:`Search sessions`}),e?.sync.status===`syncing`&&(0,F.jsxs)(`span`,{className:`text-xs text-on-surface-variant`,children:[`syncing `,e.sync.current,`/`,e.sync.total,e.sync.currentProject?` — ${e.sync.currentProject}`:``,`...`]})]}),(0,F.jsx)(`div`,{className:`h-10`}),r.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`flex items-baseline justify-between mb-3`,children:[(0,F.jsx)(`h2`,{className:`font-semibold text-sm text-on-surface`,children:`Recent projects`}),(0,F.jsx)(P,{to:`/projects`,className:`text-xs text-primary hover:underline`,children:`View all →`})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:r.map(e=>(0,F.jsx)(ea,{project:e},e.projectDir))}),(0,F.jsx)(`div`,{className:`h-10`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,F.jsx)(na,{to:`/archive`,label:`Archive`,title:`Back up sessions`,desc:`Import from local AI tools before they expire. Everything stays on your machine.`}),(0,F.jsx)(na,{to:`/projects`,label:`Build`,title:`AI case studies`,desc:`AI reads your sessions, extracts skills, and drafts a narrative for each project.`}),(0,F.jsx)(na,{to:`/search`,label:`Search`,title:`Find past work`,desc:`Full-text search across all sessions. Filter by tool, project, or skill.`}),(0,F.jsx)(na,{to:`/projects`,label:`Export`,title:`HTML, markdown, or publish`,desc:`Save locally, export markdown, or publish a public portfolio on heyi.am.`})]}),(0,F.jsx)(`div`,{className:`h-8`}),(0,F.jsxs)(`div`,{className:`border-t border-ghost pt-4 flex items-start gap-6 text-xs text-on-surface-variant`,children:[(0,F.jsx)(`span`,{children:`Everything is local by default.`}),(0,F.jsx)(`span`,{children:`Nothing is published unless you choose to.`}),(0,F.jsx)(`span`,{children:`No account required to archive or export.`})]})]})}function ea({project:e}){return(0,F.jsxs)(P,{to:`/project/${encodeURIComponent(e.projectDir)}`,className:`group block bg-white border border-ghost rounded-sm p-3.5 hover:border-outline transition-colors`,children:[(0,F.jsx)(`div`,{className:`font-semibold text-sm text-on-surface truncate`,children:e.projectName}),(0,F.jsxs)(`div`,{className:`text-xs text-on-surface-variant mt-0.5`,children:[e.sessionCount,` session`,e.sessionCount===1?``:`s`,e.enhancedAt&&(0,F.jsx)(`span`,{className:`ml-2`,style:{color:`#34d399`},children:`enhanced`})]}),e.skills.length>0&&(0,F.jsx)(`div`,{className:`flex gap-1 mt-2 flex-wrap`,children:e.skills.slice(0,3).map(e=>(0,F.jsx)(I,{children:e},e))})]})}function ta({label:e,value:t,to:n,color:r}){return(0,F.jsxs)(P,{to:n,className:`block bg-white border border-ghost rounded-sm px-4 py-3 hover:border-outline transition-colors`,children:[(0,F.jsx)(`div`,{className:`text-2xl font-bold`,style:r?{color:r}:{color:`var(--on-surface)`},children:t}),(0,F.jsx)(`div`,{className:`text-xs text-on-surface-variant mt-0.5`,children:e})]})}function na({to:e,label:t,title:n,desc:r}){return(0,F.jsxs)(P,{to:e,className:`group block bg-white border border-ghost rounded-sm p-4 hover:border-outline transition-colors`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-primary mb-1.5`,children:t}),(0,F.jsx)(`div`,{className:`font-semibold text-sm text-on-surface mb-1`,children:n}),(0,F.jsx)(`div`,{className:`text-xs text-on-surface-variant leading-relaxed`,children:r})]})}function ra(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!0),[i,a]=(0,_.useState)(!1);if((0,_.useEffect)(()=>{Zn().then(e=>{t(e.sources.map(e=>({tool:e.name,path:e.path+(e.dateRange?` · ${e.dateRange}`:``),live:e.liveCount,archived:e.archivedCount,chips:[{label:`${e.liveCount} live`,variant:`primary`},{label:`${e.archivedCount} archived`,variant:`green`},...e.retentionRisk?[{label:e.retentionRisk,variant:`amber`}]:[]],kpis:[{label:`Health`,value:e.health}]})))}).catch(()=>{a(!0)}).finally(()=>r(!1))},[]),n)return(0,F.jsx)(Ar,{back:{label:`Back`,to:`/`},chips:[{label:`Source audit`}],children:(0,F.jsx)(`div`,{className:`p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Scanning sources...`})})});if(i)return(0,F.jsx)(Ar,{back:{label:`Back`,to:`/`},chips:[{label:`Source audit`}],children:(0,F.jsx)(`div`,{className:`p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Scan failed. Could not load source data.`})})});let o=e.reduce((e,t)=>e+t.live,0),s=e.reduce((e,t)=>e+t.archived,0),c=e.some(e=>e.chips.some(e=>e.variant===`amber`));return(0,F.jsx)(Ar,{back:{label:`Back`,to:`/`},chips:[{label:`Source audit`}],actions:(0,F.jsx)(`button`,{className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm text-primary border border-ghost hover:border-outline transition-colors bg-transparent`,children:`Rescan all`}),children:(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between mb-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`font-display text-xl font-semibold text-on-surface`,children:`What we found, what we archived, and what we skipped`}),(0,F.jsx)(`p`,{className:`text-on-surface-variant text-sm mt-1`,children:`The ingestion layer should feel inspectable, not magical.`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,F.jsxs)(I,{variant:`green`,children:[s,` archived`]}),c&&(0,F.jsx)(I,{variant:`amber`,children:`Claude retention risk detected`})]})]}),(0,F.jsx)(`div`,{className:`h-4`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,F.jsx)(Nr,{label:`Sources scanned`,value:e.length}),(0,F.jsx)(Nr,{label:`Live sessions`,value:o}),(0,F.jsx)(Nr,{label:`Archived`,value:s})]}),(0,F.jsx)(`div`,{className:`h-5`}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map(e=>(0,F.jsxs)(L,{children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-display text-[0.9375rem] font-semibold text-on-surface`,children:e.tool}),(0,F.jsx)(`span`,{className:`font-mono text-xs text-outline`,children:e.path})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1`,children:e.chips.map(e=>(0,F.jsx)(I,{variant:e.variant,children:e.label},e.label))})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-4 text-[0.8125rem] text-on-surface-variant mt-2`,children:e.kpis.map(e=>(0,F.jsxs)(`span`,{children:[(0,F.jsxs)(`strong`,{className:`text-on-surface`,children:[e.label,`:`]}),` `,e.value]},e.label))})]},e.tool))}),(0,F.jsx)(`div`,{className:`h-5`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(P,{to:`/archive`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,children:`Review archive`}),(0,F.jsx)(P,{to:`/projects`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm text-primary border border-ghost hover:border-outline transition-colors`,children:`Continue to projects`}),(0,F.jsx)(`button`,{className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors bg-transparent border-none`,children:`Add custom path`})]})]})})}function ia(e){switch(e){case`healthy`:return{status:`healthy`,statusVariant:`green`};case`warning`:return{status:`partial`,statusVariant:`default`};case`error`:return{status:`filtered`,statusVariant:`violet`}}}function aa(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null);function x(){return Promise.all([Qn(),Zn()]).then(([e,n])=>{t({archived:e.total,oldest:e.oldest,sources:e.sourcesCount,lastSync:e.lastSync}),r(n.sources.map(e=>({source:e.name,archived:e.archivedCount,...ia(e.health)})))})}(0,_.useEffect)(()=>{x().catch(()=>s(!0)).finally(()=>a(!1))},[]);async function S(){l(!0),d(null);try{let e=await $n();e.archived===0?d(`Archive is up to date — no new sessions to sync.`):d(`Archived ${e.archived} new session${e.archived===1?``:`s`}.`),await x()}catch{d(`Sync failed. Check the console for details.`)}finally{l(!1)}}async function C(){p(!0),h(null);try{h(await tr())}catch{h({total:0,verified:0,missing:0,errors:[`Verification failed. Check the console for details.`]})}finally{p(!1)}}async function w(){v(!0),b(null);try{await er()}catch(e){b(e.message)}finally{v(!1)}}return i?(0,F.jsx)(Ar,{back:{label:`Sources`,to:`/sources`},chips:[{label:`Archive`}],children:(0,F.jsx)(`div`,{className:`p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading archive...`})})}):o||!e?(0,F.jsx)(Ar,{back:{label:`Sources`,to:`/sources`},chips:[{label:`Archive`}],children:(0,F.jsx)(`div`,{className:`p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Failed to load archive data.`})})}):(0,F.jsx)(Ar,{back:{label:`Sources`,to:`/sources`},chips:[{label:`Archive`}],actions:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`button`,{onClick:S,disabled:c,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm text-primary border border-ghost hover:border-outline transition-colors bg-transparent disabled:opacity-50 disabled:cursor-not-allowed`,children:c?`Syncing…`:`Archive now`}),(0,F.jsx)(`button`,{onClick:w,disabled:g,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm text-primary border border-ghost hover:border-outline transition-colors bg-transparent disabled:opacity-50 disabled:cursor-not-allowed`,children:g?`Exporting…`:`Export archive`})]}),children:(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between mb-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`font-display text-xl font-semibold text-on-surface`,children:`Your preserved AI work history`}),(0,F.jsx)(`p`,{className:`text-on-surface-variant text-sm mt-1`,children:`A durable library across tools, with clear ownership and visible coverage.`})]}),(0,F.jsx)(I,{variant:`green`,children:`under your control`})]}),(0,F.jsx)(`div`,{className:`h-4`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-3`,children:[(0,F.jsx)(Nr,{label:`Archived sessions`,value:e.archived}),(0,F.jsx)(Nr,{label:`Oldest saved`,value:e.oldest}),(0,F.jsx)(Nr,{label:`Sources covered`,value:e.sources}),(0,F.jsx)(Nr,{label:`Last sync`,value:e.lastSync})]}),u&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`h-3`}),(0,F.jsx)(R,{children:u})]}),y&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`h-3`}),(0,F.jsxs)(R,{children:[`Export failed: `,y]})]}),(0,F.jsx)(`div`,{className:`h-5`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,F.jsxs)(L,{className:`bg-white`,children:[(0,F.jsx)(z,{title:`By source`,meta:`coverage`}),(0,F.jsxs)(`table`,{className:`w-full border-collapse text-[0.8125rem]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Source`}),(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Archived`}),(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Status`})]})}),(0,F.jsx)(`tbody`,{children:n.map(e=>(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:e.source}),(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:e.archived}),(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:(0,F.jsx)(I,{variant:e.statusVariant,children:e.status})})]},e.source))})]})]}),(0,F.jsxs)(L,{className:`bg-white`,children:[(0,F.jsx)(z,{title:`Archive posture`,meta:`ops`}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n.some(e=>e.status===`partial`)&&(0,F.jsxs)(R,{children:[n.filter(e=>e.status===`partial`).length,` source`,n.filter(e=>e.status===`partial`).length===1?``:`s`,` with partial coverage — consider a manual sync.`]}),n.every(e=>e.status===`healthy`)&&n.length>0&&(0,F.jsx)(R,{children:`All sources healthy. Archive coverage is complete.`}),(0,F.jsx)(R,{children:(0,F.jsx)(`span`,{className:`font-mono text-xs`,children:`Archive path: ~/.config/heyiam/sessions/`})})]}),(0,F.jsx)(`div`,{className:`h-4`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(P,{to:`/projects`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,children:`Go to projects`}),(0,F.jsx)(`button`,{onClick:C,disabled:f,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm text-primary border border-ghost hover:border-outline transition-colors bg-transparent disabled:opacity-50 disabled:cursor-not-allowed`,children:f?`Verifying…`:`Verify integrity`})]}),m&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`h-3`}),m.missing===0&&m.errors.length===0?(0,F.jsxs)(R,{children:[`All `,m.verified,` archived file`,m.verified===1?``:`s`,` verified.`]}):(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsxs)(R,{children:[`Verified `,m.verified,`/`,m.total,` — `,m.missing,` missing.`]}),m.errors.map((e,t)=>(0,F.jsx)(`span`,{className:`text-xs text-on-surface-variant font-mono break-all`,children:e},t))]})]})]})]})]})})}function oa(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function sa(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ca(e){if(!e)return``;let[t,n]=e.split(`|`),r=e=>{try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,year:`numeric`})}catch{return``}},i=r(t),a=r(n);return i?i===a?i:`${i} — ${a}`:``}function la(e){let t=[];return e.enhancedAt&&t.push({variant:`refined`,label:`Refined`}),e.isUploaded?t.push({variant:`exported`,label:`Exported`}):t.push({variant:`local`,label:`Local only`}),t}function ua(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!0),[i,a]=(0,_.useState)(``);(0,_.useEffect)(()=>{Jn().then(t).catch(()=>{}).finally(()=>r(!1))},[]);let o=i?e.filter(e=>{let t=i.toLowerCase();return e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.skills.some(e=>e.toLowerCase().includes(t))}):e;return(0,F.jsx)(Ar,{chips:[{label:`Projects`}],actions:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(P,{to:`/search`,className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors`,children:`Search`}),(0,F.jsx)(P,{to:`/archive`,className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors`,children:`Archive`}),(0,F.jsx)(P,{to:`/settings`,className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors`,children:`Settings`})]}),children:(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsx)(z,{title:`Your projects`,meta:`Local project memory built from both live and archived history.`,children:(0,F.jsx)(I,{variant:`green`,children:`Local-only is a complete state`})}),e.length>3&&(0,F.jsx)(`div`,{className:`mt-3`,children:(0,F.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Filter projects...`,className:`w-full max-w-sm bg-surface-low border border-ghost rounded-md font-mono text-xs text-on-surface placeholder:text-outline px-3 py-1.5 focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary/20`})}),(0,F.jsx)(`div`,{className:`h-4`}),n?(0,F.jsx)(`div`,{className:`text-sm text-on-surface-variant`,children:`Loading projects...`}):o.length===0?(0,F.jsx)(L,{children:(0,F.jsx)(`p`,{className:`text-sm text-on-surface-variant`,children:i?`No projects match your filter.`:`No projects found. Run a source scan to get started.`})}):(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:o.map(e=>(0,F.jsx)(P,{to:`/project/${encodeURIComponent(e.dirName)}`,className:`no-underline`,children:(0,F.jsxs)(L,{hover:!0,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-between mb-1`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`h3`,{className:`font-display text-[0.9375rem] font-semibold text-on-surface`,children:e.name}),la(e).map(e=>(0,F.jsx)(Mr,{variant:e.variant,children:e.label},e.label))]}),(0,F.jsx)(`p`,{className:`text-on-surface-variant text-sm mt-1`,children:e.description})]})}),(e.dateRange||e.skills.length>0)&&(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mt-2`,children:[e.dateRange&&(0,F.jsx)(`span`,{className:`font-mono text-[0.6875rem] text-outline`,children:ca(e.dateRange)}),e.skills.length>0&&(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[e.skills.slice(0,8).map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e)),e.skills.length>8&&(0,F.jsxs)(`span`,{className:`font-mono text-[10px] text-outline`,children:[`+`,e.skills.length-8]})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-3 mt-3`,children:[(0,F.jsx)(Nr,{label:`Sessions`,value:e.sessionCount,valueSize:`text-lg`}),(0,F.jsx)(Nr,{label:`Time`,value:oa(e.totalDuration),valueSize:`text-lg`}),(0,F.jsx)(Nr,{label:`Lines changed`,value:sa(e.totalLoc),valueSize:`text-lg`}),(0,F.jsx)(Nr,{label:`Files`,value:e.totalFiles,valueSize:`text-lg`})]})]})},e.dirName))})]})})}function da(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function fa(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function pa(e){try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}catch{return e}}function ma({session:e,projectDirName:t,onClose:n}){let[r,i]=(0,_.useState)(e),[a,o]=(0,_.useState)(!0),s=at();(0,_.useEffect)(()=>{Xn(t,e.id).then(e=>i(e)).catch(()=>{}).finally(()=>o(!1))},[t,e.id]);let c=(0,_.useCallback)(e=>{e.key===`Escape`&&n()},[n]);(0,_.useEffect)(()=>(document.addEventListener(`keydown`,c),()=>document.removeEventListener(`keydown`,c)),[c]);let l=r.children&&r.children.length>0;return(0,F.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-black/40`,onClick:e=>{e.target===e.currentTarget&&n()},children:(0,F.jsx)(`div`,{className:`w-[600px] max-w-full h-full bg-surface overflow-y-auto shadow-[-8px_0_32px_rgba(25,28,30,0.1)]`,children:(0,F.jsxs)(`div`,{className:`p-8`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:n,className:`font-mono text-[0.8125rem] text-on-surface-variant bg-surface-low border border-surface-high rounded-md px-3 py-1 cursor-pointer hover:text-on-surface`,children:`ESC · Close`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{n(),s(`/session/${encodeURIComponent(r.id)}`)},className:`font-mono text-[0.8125rem] text-primary bg-primary/5 border border-primary/20 rounded-md px-3 py-1 cursor-pointer hover:bg-primary/10 transition-colors`,children:`View full session →`})]}),(0,F.jsx)(`h2`,{className:`font-display text-2xl font-bold text-on-surface mb-2`,children:r.title}),(0,F.jsxs)(`div`,{className:`font-mono text-[0.6875rem] uppercase tracking-wider text-on-surface-variant mb-4`,children:[pa(r.date),r.source&&` · ${r.source}`,r.context&&` · ${r.context}`]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-3 mb-5`,children:[(0,F.jsx)(ga,{label:`Active Time`,value:da(r.durationMinutes),primary:!0,children:l&&(0,F.jsx)(_a,{you:da(Math.max(0,r.durationMinutes-r.children.reduce((e,t)=>e+t.durationMinutes,0))),agent:da(r.children.reduce((e,t)=>e+t.durationMinutes,0))})}),(0,F.jsx)(ga,{label:`Turns`,value:r.turns,children:l&&(0,F.jsx)(_a,{you:`Human`,agent:`${r.childCount??r.children.length} agents`})}),(0,F.jsx)(ga,{label:`Files`,value:r.filesChanged?.length===1&&r.filesChanged[0]?.path===`(aggregate)`?`—`:r.filesChanged?.length??`—`}),(0,F.jsx)(ga,{label:`Lines changed`,value:fa(r.linesOfCode),children:l&&(0,F.jsx)(_a,{you:fa(Math.max(0,r.linesOfCode-r.children.reduce((e,t)=>e+t.linesOfCode,0))),agent:fa(r.children.reduce((e,t)=>e+t.linesOfCode,0))})})]}),r.developerTake&&(0,F.jsx)(`p`,{className:`text-[0.9375rem] leading-relaxed text-on-surface border-l-[3px] border-primary pl-3 mb-5`,children:r.developerTake}),r.skills&&r.skills.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-5`,children:r.skills.map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e))}),r.turns>=50&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsxs)(ha,{children:[`Session Activity · `,r.turns,` turns over `,da(r.durationMinutes)]}),(0,F.jsx)(Ei,{sessions:[r],maxHeight:200})]}),a&&(0,F.jsx)(`p`,{className:`text-sm text-on-surface-variant mb-4`,children:`Loading full session data...`}),r.executionPath&&r.executionPath.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(ha,{children:`Execution Path`}),r.executionPath.map(e=>(0,F.jsxs)(`div`,{className:`flex gap-3 items-start py-2.5 border-b border-ghost last:border-b-0`,children:[(0,F.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-primary text-white font-mono text-[0.625rem] font-bold flex items-center justify-center flex-shrink-0`,children:e.stepNumber}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`font-semibold text-sm text-on-surface mb-0.5`,children:e.title}),(0,F.jsx)(`div`,{className:`text-[0.8125rem] text-on-surface-variant leading-relaxed`,children:e.description})]})]},e.stepNumber))]}),r.toolBreakdown&&r.toolBreakdown.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(ha,{children:`Tool Usage`}),r.toolBreakdown.map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between items-center py-1.5 border-b border-ghost last:border-b-0 font-mono text-xs`,children:[(0,F.jsx)(`span`,{className:`text-on-surface truncate min-w-0`,children:e.tool}),(0,F.jsx)(`span`,{className:`text-on-surface-variant flex-shrink-0 ml-3`,children:e.count})]},e.tool))]}),r.filesChanged&&r.filesChanged.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(ha,{children:`Top Files`}),r.filesChanged.slice(0,10).map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between items-center py-1.5 border-b border-ghost last:border-b-0 font-mono text-xs`,children:[(0,F.jsx)(`span`,{className:`text-on-surface truncate min-w-0`,children:e.path}),(0,F.jsxs)(`span`,{className:`flex-shrink-0 ml-2 whitespace-nowrap`,children:[(0,F.jsxs)(`span`,{className:`text-green-600 font-semibold`,children:[`+`,e.additions]}),(0,F.jsxs)(`span`,{className:`text-red-600 font-semibold ml-1`,children:[`-`,e.deletions]})]})]},e.path))]}),r.qaPairs&&r.qaPairs.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(ha,{children:`Questions & Answers`}),r.qaPairs.map((e,t)=>(0,F.jsxs)(`div`,{className:`py-3 border-b border-ghost last:border-b-0`,children:[(0,F.jsx)(`div`,{className:`font-semibold text-[0.9375rem] text-on-surface mb-2`,children:e.question}),(0,F.jsx)(`div`,{className:`text-sm text-on-surface-variant leading-relaxed`,children:e.answer})]},t))]})]})})})}function ha({children:e}){return(0,F.jsx)(`div`,{className:`font-mono text-[0.625rem] font-semibold uppercase tracking-wider text-on-surface-variant mb-2.5`,children:e})}function ga({label:e,value:t,primary:n,children:r}){return(0,F.jsxs)(`div`,{className:`text-center p-3 border border-ghost rounded-sm bg-surface-lowest`,children:[(0,F.jsx)(`div`,{className:`font-mono text-xl font-bold ${n?`text-primary`:`text-on-surface`}`,children:t}),(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-on-surface-variant mt-1`,children:e}),r]})}function _a({you:e,agent:t}){return(0,F.jsxs)(`div`,{className:`flex justify-center gap-2 mt-1 font-mono text-[9px] text-on-surface-variant`,children:[(0,F.jsx)(`span`,{className:`text-primary font-semibold`,children:e}),(0,F.jsx)(`span`,{className:`text-green font-semibold`,children:t})]})}function va(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function ya(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ba(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e)}function xa(e){try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}catch{return e}}function Sa(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/36e5);return n<1?`just now`:n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}var Ca=[`bg-primary`,`bg-green`,`bg-violet`];function wa({narrative:e,screenshotSrc:t,projectName:n,humanTime:r,agentTime:i,stats:a}){let o=i?parseFloat(i)/parseFloat(r):void 0,s=o&&o>1?`${o.toFixed(1)}x`:void 0;return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 mb-4`,children:[t&&(0,F.jsxs)(`div`,{className:`rounded-md border border-ghost overflow-hidden shadow-sm`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2 bg-surface-low border-b border-ghost`,children:[(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#ff5f57]`}),(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#febc2e]`}),(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#28c840]`})]}),(0,F.jsx)(`div`,{className:`max-h-96 overflow-y-auto`,children:(0,F.jsx)(`img`,{src:t,alt:`${n} screenshot`,className:`w-full h-auto`})})]}),e&&(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Narrative summary`,meta:`editable`}),(0,F.jsx)(`p`,{className:`leading-relaxed text-on-surface border-l-[3px] border-primary pl-3`,style:{fontSize:`clamp(0.8125rem, 1.2vw, 1rem)`},children:e})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-[1fr_2fr] gap-3`,children:[(0,F.jsxs)(`div`,{className:`bg-surface-lowest border border-ghost rounded-md p-4 flex flex-col justify-between`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-on-surface-variant mb-1`,children:i?`Human / Agents`:`Time`}),(0,F.jsx)(`div`,{className:`font-display font-bold text-on-surface text-2xl`,children:i?`${r} / ${i}`:r})]}),s&&(0,F.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-ghost`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-on-surface-variant mb-0.5`,children:`Efficiency multiplier`}),(0,F.jsx)(`div`,{className:`font-display font-bold text-on-surface text-lg`,children:s})]})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-2 gap-3`,children:a.map(e=>(0,F.jsx)(Nr,{label:e.label,value:e.value},e.label))})]})]})}function Ta(){let{dirName:e}=st(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(!1),v=(0,_.useRef)(null),y=(0,_.useRef)(null);(0,_.useEffect)(()=>{e&&(nr(e).then(e=>{n(e),e.enhanceCache?.repoUrl&&c(e.enhanceCache.repoUrl),e.enhanceCache?.projectUrl&&u(e.enhanceCache.projectUrl),e.enhanceCache?.screenshotBase64&&f(e.enhanceCache.screenshotBase64)}).catch(()=>{}).finally(()=>i(!1)),_r(e).then(({url:e})=>{e&&c(t=>t||(e.startsWith(`http`)?e:`https://${e}`))}).catch(()=>{}))},[e]);let b=(0,_.useCallback)(()=>{if(!e||!t)return;let n=t.enhanceCache;gr(e,n?.selectedSessionIds??[],n?.result??{narrative:``,arc:[],skills:[],timeline:[],questions:[]},{repoUrl:s||void 0,projectUrl:l||void 0,screenshotBase64:d??void 0}).then(()=>g(!1)).catch(()=>{})},[e,t,s,l,d]);if((0,_.useEffect)(()=>{if(h)return v.current&&clearTimeout(v.current),v.current=setTimeout(b,800),()=>{v.current&&clearTimeout(v.current)}},[h,b]),r)return(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading project...`})});if(!t)return(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Project not found.`})});let{project:x,sessions:S,enhanceCache:C}=t,w=C??null,T=w?.result?.narrative??x.description,E=w?.result?.arc??[],D=[...new Set(S.map(e=>e.source??`unknown`))],O=w?.screenshotBase64?`data:image/png;base64,${w.screenshotBase64}`:void 0,ee=[],k=new Set;if(w?.result?.timeline)for(let e of w.result.timeline)for(let t of e.sessions)t.featured&&(k.add(t.sessionId),t.tag?ee.push({sessionId:t.sessionId,label:t.tag}):ee.push({sessionId:t.sessionId,label:t.title.slice(0,18)}));let A=(()=>{let e=S.filter(e=>k.has(e.id));if(e.length>=6)return e.slice(0,6);let t=S.filter(e=>e.status===`enhanced`||e.status===`uploaded`),n=S.filter(e=>e.status===`draft`&&!k.has(e.id)),r=[...e,...t.filter(e=>!k.has(e.id)).sort((e,t)=>t.linesOfCode-e.linesOfCode),...n],i=new Set;return r.filter(e=>i.has(e.id)?!1:(i.add(e.id),!0)).slice(0,6)})();return(0,F.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] min-h-[calc(100vh-48px)]`,children:[(0,F.jsxs)(`aside`,{className:`border-r border-ghost bg-surface-low p-4`,children:[(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-1.5`,children:`Source mix`}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:D.map(e=>(0,F.jsx)(I,{children:e},e))})]}),(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-1.5`,children:`Status`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:[(0,F.jsx)(I,{variant:`primary`,children:x.enhancedAt?`Refined`:`Unrefined`}),(0,F.jsx)(I,{variant:`green`,children:x.isUploaded?`Uploaded`:`Local only`})]})]}),(0,F.jsx)(R,{children:`The local project page is the main object. Public pages are just one projection of it.`}),(0,F.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-ghost`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-3`,children:`Project links`}),(0,F.jsxs)(`label`,{className:`block mb-3`,children:[(0,F.jsx)(`span`,{className:`text-[0.75rem] font-medium text-on-surface-variant block mb-1`,children:`Repo URL`}),(0,F.jsx)(`input`,{type:`url`,value:s,onChange:e=>{c(e.target.value),g(!0)},placeholder:`https://github.com/...`,className:`w-full text-xs font-mono px-2 py-1.5 rounded-sm border border-ghost bg-surface-lowest text-on-surface placeholder:text-outline`})]}),(0,F.jsxs)(`label`,{className:`block mb-3`,children:[(0,F.jsx)(`span`,{className:`text-[0.75rem] font-medium text-on-surface-variant block mb-1`,children:`Project URL`}),(0,F.jsx)(`input`,{type:`url`,value:l,onChange:e=>{u(e.target.value),g(!0)},placeholder:`https://example.com`,className:`w-full text-xs font-mono px-2 py-1.5 rounded-sm border border-ghost bg-surface-lowest text-on-surface placeholder:text-outline`})]}),(0,F.jsxs)(`div`,{className:`mb-2`,children:[(0,F.jsx)(`span`,{className:`text-[0.75rem] font-medium text-on-surface-variant block mb-1`,children:`Screenshot`}),d?(0,F.jsxs)(`div`,{className:`relative rounded-sm overflow-hidden border border-ghost`,children:[(0,F.jsx)(`img`,{src:d.startsWith(`data:`)?d:`data:image/png;base64,${d}`,alt:`Project screenshot`,className:`w-full h-auto max-h-32 object-cover object-top`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{f(null),g(!0)},className:`absolute top-1 right-1 w-5 h-5 rounded-full bg-black/60 text-white text-[10px] flex items-center justify-center hover:bg-black/80`,children:`×`})]}):(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>y.current?.click(),className:`text-xs font-mono text-primary hover:underline text-left`,children:`Upload image...`}),l&&(0,F.jsx)(`button`,{type:`button`,onClick:async()=>{if(!e)return;m(!0);let t=x.name.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``);try{let n=await vr(e,t,l);n.ok&&n.preview&&(f(n.preview),g(!0))}catch{}finally{m(!1)}},disabled:p,className:`text-xs font-mono text-primary hover:underline text-left`,children:p?`Capturing...`:`Auto-capture from URL`})]}),(0,F.jsx)(`input`,{ref:y,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{f(n.result),g(!0)},n.readAsDataURL(t)}})]}),h&&(0,F.jsx)(`div`,{className:`text-[9px] font-mono text-outline mt-2`,children:`Saving...`})]})]}),(0,F.jsxs)(`main`,{className:`p-6 overflow-y-auto max-w-[1200px] mx-auto`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`font-display text-xl font-bold text-on-surface`,children:x.name}),(0,F.jsxs)(`span`,{className:`text-on-surface-variant text-[0.8125rem]`,children:[x.dateRange?typeof x.dateRange==`string`?x.dateRange:`${xa(x.dateRange.start)} – ${xa(x.dateRange.end)}`:``,x.enhancedAt&&` · last refined ${Sa(x.enhancedAt)}`]})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,F.jsxs)(I,{variant:`primary`,children:[x.sessionCount,` sessions`]})})]}),(s||l)&&(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-1 mb-1`,children:[s&&(0,F.jsxs)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-xs text-primary hover:underline flex items-center gap-1`,children:[(0,F.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 16 16`,fill:`currentColor`,children:(0,F.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z`})}),s.replace(/^https?:\/\/(www\.)?/,``).replace(/\.git$/,``)]}),l&&(0,F.jsxs)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-xs text-primary hover:underline flex items-center gap-1`,children:[(0,F.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,F.jsx)(`path`,{d:`M6.5 10.5l3-3m-1.5-2a2.5 2.5 0 013.54 3.54l-1.5 1.5m-4.08-1.08a2.5 2.5 0 01-3.54-3.54l1.5-1.5`})}),l.replace(/^https?:\/\/(www\.)?/,``)]})]}),(0,F.jsx)(`div`,{className:`h-4`}),(0,F.jsx)(wa,{narrative:T,screenshotSrc:d?d.startsWith(`data:`)?d:`data:image/png;base64,${d}`:O,projectName:x.name,humanTime:va(x.totalDuration),agentTime:x.totalAgentDuration?va(x.totalAgentDuration):void 0,stats:[{label:`Sessions`,value:x.sessionCount},{label:`Lines changed`,value:ya(x.totalLoc)},{label:`Files`,value:x.totalFiles},...x.totalInputTokens||x.totalOutputTokens?[{label:`Tokens`,value:ba((x.totalInputTokens??0)+(x.totalOutputTokens??0))}]:[]]}),(0,F.jsxs)(L,{className:`mb-4`,children:[(0,F.jsx)(z,{title:`Work timeline`,meta:`sessions over time`}),(0,F.jsx)(Ei,{sessions:S,maxHeight:300})]}),(0,F.jsxs)(L,{className:`mb-4`,children:[(0,F.jsx)(z,{title:`Project growth`,meta:`lines changed`}),(0,F.jsx)(zi,{sessions:S,totalLoc:x.totalLoc,totalFiles:x.totalFiles,keyMoments:ee})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 mb-4`,children:[(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Key decisions`,meta:`signal`}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:E.length>0?E.slice(0,3).map(e=>(0,F.jsx)(R,{title:e.title,children:e.description},e.phase)):(0,F.jsx)(R,{children:`Enhance this project to extract key decisions.`})})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Source breakdown`,meta:`provenance`}),(0,F.jsx)(Ea,{sessions:S})]})]}),E.length>0&&(0,F.jsxs)(L,{className:`mb-4`,children:[(0,F.jsx)(z,{title:`Project phases`,meta:`timeline`}),(0,F.jsxs)(`div`,{className:`relative pl-5`,children:[(0,F.jsx)(`div`,{className:`absolute left-1 top-1.5 bottom-1.5 w-0.5 bg-ghost rounded-full`}),E.map(e=>(0,F.jsxs)(`div`,{className:`relative pb-4 last:pb-0`,children:[(0,F.jsx)(`div`,{className:`absolute -left-5 top-1.5 w-2 h-2 rounded-full bg-primary shadow-[0_0_0_3px_rgba(8,68,113,0.1)]`}),(0,F.jsx)(`div`,{className:`font-mono text-[0.6875rem] uppercase tracking-wider text-on-surface-variant`,children:e.title}),(0,F.jsx)(R,{children:(0,F.jsx)(`span`,{className:`text-on-surface-variant`,children:e.description})})]},e.phase))]})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Featured sessions`,children:(0,F.jsxs)(P,{to:`/project/${encodeURIComponent(e??``)}/sessions`,className:`font-mono text-[11px] text-primary hover:underline`,children:[`All `,S.length,` sessions →`]})}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:A.map((e,t)=>(0,F.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`text-left bg-surface-lowest border border-ghost rounded-sm p-4 cursor-pointer transition-shadow hover:shadow-md`,children:[(0,F.jsx)(`div`,{className:`h-1 rounded-full mb-3 ${Ca[t%Ca.length]}`}),(0,F.jsx)(`h4`,{className:`font-display text-[0.8125rem] font-semibold text-on-surface mb-1 line-clamp-2`,children:e.title}),(0,F.jsxs)(`span`,{className:`text-on-surface-variant text-xs`,children:[va(e.durationMinutes),` · `,e.turns,` turns · `,ya(e.linesOfCode),` lines`]}),e.skills?.[0]&&(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(I,{variant:`violet`,children:e.skills[0]})})]},e.id))})]})]}),a&&e&&(0,F.jsx)(ma,{session:a,projectDirName:e,onClose:()=>o(null)})]})}function Ea({sessions:e}){let t=e.reduce((e,t)=>(e[t.source??`unknown`]=(e[t.source??`unknown`]??0)+1,e),{});return(0,F.jsxs)(`table`,{className:`w-full border-collapse text-[0.8125rem]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Source`}),(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Count`})]})}),(0,F.jsx)(`tbody`,{children:Object.entries(t).map(([e,t])=>(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:e}),(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:t})]},e))})]})}function Da(){let{dirName:e}=st(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(!1);(0,_.useEffect)(()=>{e&&Promise.all([rr(e).catch(()=>null),Yn(e).catch(()=>[])]).then(([e,t])=>{e&&n(e),i(t)}).finally(()=>o(!1))},[e]);let l=r.filter(e=>t?.selectedSessionIds?.includes(e.id)),u=t?.skippedSessions??[];async function d(){if(!(!e||!t)){c(!0);try{await ir(e,t)}catch{}finally{c(!1)}}}return a?(0,F.jsx)(Ar,{back:{label:e??`Project`,to:`/project/${encodeURIComponent(e??``)}`},chips:[{label:`Project boundaries`}],children:(0,F.jsx)(`div`,{className:`p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading boundaries...`})})}):(0,F.jsx)(Ar,{back:{label:e??`Project`,to:`/project/${encodeURIComponent(e??``)}`},chips:[{label:`Project boundaries`}],actions:(0,F.jsx)(`button`,{onClick:d,disabled:s,className:`bg-primary text-on-primary font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm hover:bg-primary-hover transition-colors disabled:opacity-50`,children:s?`Saving...`:`Save boundaries`}),children:(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsx)(`h2`,{className:`font-display text-xl font-bold text-on-surface`,children:`Shape what this project actually contains`}),(0,F.jsx)(`p`,{className:`text-on-surface-variant text-sm mt-1`,children:`Clustering gets you close. This screen makes it trustworthy.`}),(0,F.jsx)(`div`,{className:`h-4`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Included sessions`,meta:`${l.length} total`}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:l.length===0?(0,F.jsx)(R,{children:`No sessions included yet.`}):l.map(e=>(0,F.jsx)(R,{title:e.title,children:(0,F.jsxs)(`span`,{className:`font-mono text-xs text-on-surface-variant`,children:[e.source??`unknown`,` · `,e.filesChanged?.length??0,` files · `,e.linesOfCode,` lines`]})},e.id))})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Nearby / excluded`,meta:`needs review`}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:u.length===0?(0,F.jsx)(R,{children:`No excluded sessions.`}):u.map(e=>(0,F.jsx)(R,{title:r.find(t=>t.id===e.sessionId)?.title??e.sessionId,children:(0,F.jsxs)(`span`,{className:`font-mono text-xs text-on-surface-variant`,children:[`excluded · `,e.reason]})},e.sessionId))})]})]})]})})}function Oa(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function ka(e){return e<1e3?String(e):`${(e/1e3).toFixed(1)}k`}function Aa(e){return e?new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`}):``}function ja(e){if(!e)return``;let[t,n]=e.split(`|`);if(!t||!n)return``;let r=new Date(t),i=new Date(n),a=e=>e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`}),o=i.getFullYear();return`${a(r)}\u2013${a(i)}, ${o}`}var Ma=[`overview`,`triage`,`enhance`,`questions`,`timeline`];function Na({current:e}){let t=Ma.indexOf(e);return(0,F.jsx)(`div`,{className:`phase-bar`,children:Ma.slice(0,-1).map((e,n)=>(0,F.jsx)(`div`,{className:`phase-bar__segment ${n<=t?`phase-bar__segment--active`:``}`},n))})}function Pa({project:e,sessions:t,onTriage:n,onCancel:r}){let i=[...t].sort((e,t)=>{let n=e.date?new Date(e.date).getTime():0;return(t.date?new Date(t.date).getTime():0)-n});return(0,F.jsxs)(`div`,{className:`upload-flow`,children:[(0,F.jsx)(`div`,{className:`upload-flow__label`,children:`Upload Project`}),(0,F.jsx)(`h2`,{className:`upload-flow__title`,children:e.name}),(0,F.jsx)(`div`,{className:`upload-flow__date`,children:ja(e.dateRange)}),(0,F.jsxs)(`p`,{className:`upload-flow__desc`,children:[`The AI will scan all `,e.sessionCount,` sessions, pick the ones worth showcasing, and build a project narrative. Small or trivial sessions are skipped automatically.`]}),(0,F.jsxs)(`div`,{className:`upload-flow__stat-grid`,children:[(0,F.jsx)(Fa,{label:`Sessions`,value:String(e.sessionCount)}),(0,F.jsx)(Fa,{label:e.totalAgentDuration?`Human / Agents`:`Total Time`,value:e.totalAgentDuration?`${Oa(e.totalDuration)} / ${Oa(e.totalAgentDuration)}`:Oa(e.totalDuration)}),(0,F.jsx)(Fa,{label:`Lines changed`,value:ka(e.totalLoc)}),(0,F.jsx)(Fa,{label:`Files`,value:String(e.totalFiles)})]}),(0,F.jsxs)(`div`,{className:`upload-flow__section-label`,children:[`All Sessions (`,t.length,`)`]}),(0,F.jsxs)(`div`,{className:`session-table`,children:[(0,F.jsxs)(`div`,{className:`session-table__header`,children:[(0,F.jsx)(`span`,{children:`Session`}),(0,F.jsx)(`span`,{style:{textAlign:`right`},children:`Date`}),(0,F.jsx)(`span`,{style:{textAlign:`right`},children:`Time`}),(0,F.jsx)(`span`,{style:{textAlign:`right`},children:`LOC`}),(0,F.jsx)(`span`,{style:{textAlign:`right`},children:`Turns`})]}),(0,F.jsx)(`div`,{className:`session-table__body`,children:i.map(e=>(0,F.jsxs)(`div`,{className:`session-table__row`,children:[(0,F.jsx)(`span`,{className:`session-table__name`,children:e.title}),(0,F.jsx)(`span`,{className:`session-table__cell`,children:Aa(e.date)}),(0,F.jsx)(`span`,{className:`session-table__cell`,children:Oa(e.durationMinutes)}),(0,F.jsx)(`span`,{className:`session-table__cell`,children:ka(e.linesOfCode)}),(0,F.jsx)(`span`,{className:`session-table__cell`,children:e.turns})]},e.id))})]}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:r,children:`Cancel`}),(0,F.jsxs)(`button`,{className:`btn btn--primary btn--large`,onClick:n,children:[e.sessionCount<5?`Enhance all ${e.sessionCount} sessions`:`Let AI pick sessions`,` →`]})]})]})}function Fa({label:e,value:t}){return(0,F.jsxs)(`div`,{className:`stat-card`,children:[(0,F.jsx)(`div`,{className:`stat-card__label`,children:e}),(0,F.jsx)(`div`,{className:`stat-card__value`,children:t})]})}var Ia=[`◐`,`◑`,`◒`,`◓`];function La(){let[e,t]=(0,_.useState)(0);return(0,_.useEffect)(()=>{let e=setInterval(()=>t(e=>(e+1)%Ia.length),120);return()=>clearInterval(e)},[]),Ia[e]}function Ra(e,t){let n=[{id:`prompt`,text:`$ heyiam triage`,variant:`prompt`}],r=0,i=0,a=0,o=!1,s=!1,c=!1;for(let l of e)switch(l.type){case`scanning`:r=l.total,n.push({id:`scanning`,text:` Loading session stats... (${l.total} sessions)`,variant:`active`});break;case`loading_stats`:l.index;break;case`hard_floor`:{if(!o){let e=n.findIndex(e=>e.id===`scanning`);e!==-1&&(n[e]={id:`scanning-done`,text:` \u2713 Loaded ${r} sessions`,variant:`passed`}),n.push({id:`hf-header`,text:``,variant:`default`}),n.push({id:`hf-section`,text:` ── Hard floor filter ──`,variant:`section`}),o=!0}let e=l.sessionId.slice(0,8);l.passed?(i++,n.push({id:`hf-${l.sessionId}`,text:` \u2713 ${l.title||e} \u2192 passed`,variant:`passed`})):(a++,n.push({id:`hf-${l.sessionId}`,text:` \u2717 ${l.title||e} \u2192 skipped${l.reason?` (${l.reason})`:``}`,variant:`skipped`}));break}case`extracting_signals`:{s||=(o&&n.push({id:`hf-summary`,text:` \u2713 ${i} passed, ${a} filtered`,variant:`passed`}),n.push({id:`sig-header`,text:``,variant:`default`}),n.push({id:`sig-section`,text:` ── Signal extraction ──`,variant:`section`}),!0);let e=l.sessionId.slice(0,8);n.push({id:`sig-${l.sessionId}`,text:` ${t} Scanning ${l.title||e}...`,variant:`active`});break}case`signals_done`:{let e=n.findIndex(e=>e.id===`sig-${l.sessionId}`);if(e!==-1){let t=l.sessionId.slice(0,8);n[e]={id:`sig-done-${l.sessionId}`,text:` \u2713 ${t}: signals extracted`,variant:`passed`}}break}case`llm_ranking`:c||=(n.push({id:`rank-header`,text:``,variant:`default`}),n.push({id:`rank-section`,text:` ── AI ranking ──`,variant:`section`}),!0),n.push({id:`llm-ranking`,text:` ${t} Sending ${l.sessionCount} sessions to AI...`,variant:`active`});break;case`scoring_fallback`:c||=(n.push({id:`rank-header`,text:``,variant:`default`}),n.push({id:`rank-section`,text:` ── Scoring ──`,variant:`section`}),!0),n.push({id:`scoring-fallback`,text:` ${t} Scoring ${l.sessionCount} sessions...`,variant:`active`});break;case`done`:let e=n.findIndex(e=>e.id===`llm-ranking`||e.id===`scoring-fallback`);e!==-1&&(n[e]={id:`rank-done`,text:` \u2713 AI selected ${l.selected} sessions`,variant:`passed`});break;case`result`:break}return n}function za({events:e,dirName:t}){let n=La(),r=(0,_.useRef)(null),i=Ra(e,n);return(0,_.useEffect)(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[i.length]),(0,F.jsx)(`div`,{className:`triage-terminal`,role:`log`,"aria-live":`polite`,"aria-label":`Triage progress`,children:(0,F.jsx)(`div`,{className:`triage-terminal__feed`,ref:r,children:i.map(e=>(0,F.jsx)(`div`,{className:`triage-terminal__line${e.variant===`prompt`?` triage-terminal__prompt`:e.variant===`section`?` triage-terminal__section`:e.variant===`passed`?` triage-terminal__line--passed`:e.variant===`skipped`?` triage-terminal__line--skipped`:e.variant===`active`?` triage-terminal__line--active`:``}`,children:e.text},e.id))})})}function Ba({sessionId:e,title:t,stats:n,reason:r,variant:i,checked:a,onToggle:o,dimTitle:s,previouslyUploaded:c}){let[l,u]=(0,_.useState)(!1),d=r.length>(i===`selected`?60:40),f=i===`selected`?r.length>60?r.slice(0,57)+`...`:r:r.length>40?r.slice(0,37)+`...`:r;return(0,F.jsxs)(`div`,{className:`triage-item ${a?`triage-item--selected`:`triage-item--skipped`}`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:a,onChange:o,className:`triage-item__checkbox`}),(0,F.jsxs)(`div`,{className:`triage-item__info`,children:[(0,F.jsxs)(`div`,{className:`triage-item__name`,style:s?{color:`var(--on-surface-variant)`}:void 0,children:[t,c&&(0,F.jsx)(`span`,{className:`triage-item__uploaded-badge`,children:`previously uploaded`})]}),(0,F.jsx)(`div`,{className:`triage-item__stats`,children:n})]}),(0,F.jsx)(`div`,{className:`triage-item__reason triage-item__reason--${i} ${d?`triage-item__reason--expandable`:``}`,onClick:d?()=>u(!l):void 0,role:d?`button`:void 0,tabIndex:d?0:void 0,onKeyDown:d?e=>{e.key===`Enter`&&u(!l)}:void 0,children:l?r:f})]})}function Va({project:e,sessions:t,triageResult:n,selectedIds:r,onToggle:i,onEnhance:a,onBack:o,uploadedSessionIds:s}){let c=new Map(t.map(e=>[e.id,e])),l=r.size,u=t.length-l;return(0,F.jsxs)(`div`,{className:`upload-flow`,children:[(0,F.jsx)(Na,{current:`triage`}),(0,F.jsxs)(`div`,{className:`upload-flow__scan-status`,children:[`✓ Scanned `,t.length,` sessions · `,Oa(e.totalDuration),` · `,ka(e.totalLoc),` lines`]}),(0,F.jsxs)(`h2`,{className:`upload-flow__title`,children:[`AI selected `,l,` sessions to showcase`]}),(0,F.jsxs)(`p`,{className:`upload-flow__desc`,children:[`Skipped `,u,` sessions that were too small, purely mechanical, or redundant. You can override any selection.`]}),n.triageMethod===`scoring`&&(0,F.jsxs)(`div`,{className:`triage-method-banner`,children:[(0,F.jsx)(`span`,{className:`triage-method-banner__icon`,"aria-hidden":`true`,children:`ⓘ`}),(0,F.jsx)(`span`,{children:`Sessions selected by signal analysis (no API key configured). `}),(0,F.jsx)(`a`,{href:`/settings`,className:`triage-method-banner__link`,children:`Go to Settings`})]}),(0,F.jsxs)(`div`,{className:`upload-flow__section-label upload-flow__section-label--selected`,children:[`✓ Selected for showcase (`,l,`)`]}),(0,F.jsx)(`div`,{className:`triage-list`,children:n.selected.map(e=>{let t=c.get(e.sessionId),n=r.has(e.sessionId);return(0,F.jsx)(Ba,{sessionId:e.sessionId,title:t?.title??e.sessionId,stats:t?`${Oa(t.durationMinutes)} \u00b7 ${ka(t.linesOfCode)} lines \u00b7 ${t.turns} turns`:``,reason:e.reason,variant:`selected`,checked:n,onToggle:()=>i(e.sessionId),previouslyUploaded:s?.has(e.sessionId)},e.sessionId)})}),(0,F.jsxs)(`details`,{className:`triage-skipped`,children:[(0,F.jsxs)(`summary`,{className:`triage-skipped__summary`,children:[(0,F.jsx)(`span`,{children:`▶`}),` Skipped (`,n.skipped.length,`) — click to override`]}),(0,F.jsx)(`div`,{className:`triage-list`,style:{marginTop:`var(--spacing-3)`},children:n.skipped.map(e=>{let t=c.get(e.sessionId),n=r.has(e.sessionId);return(0,F.jsx)(Ba,{sessionId:e.sessionId,title:t?.title??e.sessionId,stats:t?`${Oa(t.durationMinutes)} \u00b7 ${ka(t.linesOfCode)} lines \u00b7 ${t.turns} turns`:``,reason:e.reason,variant:`skipped`,checked:n,onToggle:()=>i(e.sessionId),dimTitle:!n,previouslyUploaded:s?.has(e.sessionId)},e.sessionId)})})]}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:o,children:`Back`}),(0,F.jsx)(`button`,{className:`btn btn--primary btn--large`,onClick:a,disabled:l===0,children:`Enhance project →`})]})]})}function Ha({project:e,sessions:t,selectedIds:n,triageResult:r,onComplete:i,onBack:a}){let o=new Map(t.map(e=>[e.id,e])),[s,c]=(0,_.useState)(()=>{let e=r.selected.filter(e=>n.has(e.sessionId)),t=r.skipped.filter(e=>n.has(e.sessionId));return[...e,...t].map(e=>({sessionId:e.sessionId,title:o.get(e.sessionId)?.title??e.sessionId,status:`pending`}))}),[l,u]=(0,_.useState)(`waiting`),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),T=(0,_.useRef)(null),E=(0,_.useCallback)(t=>{if(!e.dirName)return;t&&(x(null),f(null),u(`waiting`),g(``),m([]),y(null),c(e=>e.map(e=>({...e,status:`pending`}))));let i=r.skipped.filter(e=>!n.has(e.sessionId)).map(e=>{let t=o.get(e.sessionId);return{title:t?.title??e.sessionId,duration:t?.durationMinutes??0,loc:t?.linesOfCode??0}}),a=or(e.dirName,Array.from(n),i,e=>{switch(e.type){case`session_progress`:c(t=>t.map(t=>t.sessionId===e.sessionId?{...t,status:e.status,title:e.title||t.title,detail:e.detail}:t)),(e.status===`done`||e.status===`skipped`)&&e.skills&&m(t=>{let n=new Set(t);for(let t of e.skills)n.add(t);return[...n]});break;case`project_enhance`:u(`generating`);break;case`narrative_chunk`:g(t=>t+e.text);break;case`cached`:x(e.enhancedAt),c(e=>e.map(e=>({...e,status:`done`}))),u(`done`);break;case`done`:u(`done`),f(e.result);break;case`error`:y(e.message);break}},t);return w.current=a,a},[e.dirName,n,r,o]);(0,_.useEffect)(()=>{let e=E(S);return()=>e?.abort()},[S]);let D=s.filter(e=>e.status!==`pending`).length;(0,_.useEffect)(()=>{if(!T.current||D===0)return;let e=T.current.querySelectorAll(`.enhance-feed-item:not(.enhance-feed-item--pending)`),t=e[e.length-1];t&&t.scrollIntoView({block:`nearest`,behavior:`smooth`})},[D]);let O=d!==null,ee=d?.skills??p,k=s.filter(e=>e.status===`failed`),A=s.filter(e=>e.status===`done`||e.status===`skipped`),te=s.every(e=>e.status!==`pending`&&e.status!==`enhancing`),ne=k.length>0,re=A.length>0,ie=(0,_.useCallback)(()=>{c(e=>e.map(e=>e.status===`failed`?{...e,status:`pending`,detail:void 0}:e)),y(null),w.current?.abort(),C(e=>!e)},[]),j=(0,_.useCallback)(()=>{i({narrative:``,arc:[],skills:p,timeline:[],questions:[]})},[p,i]);return(0,F.jsxs)(`div`,{className:`enhance-split`,children:[(0,F.jsxs)(`div`,{className:`enhance-split__left`,children:[(0,F.jsx)(`div`,{className:`enhance-split__left-header`,children:`Session Processing`}),(0,F.jsx)(`div`,{className:`enhance-split__feed`,ref:T,children:s.map(e=>(0,F.jsxs)(`div`,{className:`enhance-feed-item ${e.status===`pending`?`enhance-feed-item--pending`:``} ${e.status===`failed`?`enhance-feed-item--failed`:``}`,children:[(0,F.jsxs)(`div`,{className:`enhance-feed-item__row`,children:[e.status===`done`||e.status===`skipped`?(0,F.jsx)(`span`,{className:`enhance-feed-item__check`,children:`✓`}):e.status===`failed`?(0,F.jsx)(`span`,{className:`enhance-feed-item__fail`,children:`✗`}):e.status===`enhancing`?(0,F.jsx)(`span`,{className:`enhance-feed-item__spinner`}):(0,F.jsx)(`span`,{className:`enhance-feed-item__circle`,children:`◯`}),(0,F.jsx)(`span`,{className:`enhance-feed-item__title ${e.status===`enhancing`?`enhance-feed-item__title--active`:``} ${e.status===`failed`?`enhance-feed-item__title--failed`:``}`,children:e.title})]}),e.detail&&e.status!==`pending`&&(0,F.jsx)(`div`,{className:`enhance-feed-item__detail ${e.status===`failed`?`enhance-feed-item__detail--failed`:``}`,children:e.detail})]},e.sessionId))}),(0,F.jsxs)(`div`,{className:`enhance-split__narrative-box`,children:[(0,F.jsx)(`div`,{className:`enhance-split__narrative-label`,children:`PROJECT NARRATIVE`}),(0,F.jsx)(`div`,{className:`enhance-split__narrative-status`,children:b&&l===`done`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`enhance-feed-item__check`,children:`✓`}),(0,F.jsxs)(`span`,{children:[`Loaded from cache (`,new Date(b).toLocaleDateString(),`)`]})]}):l===`done`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`enhance-feed-item__check`,children:`✓`}),(0,F.jsx)(`span`,{children:`Project story complete`})]}):l===`generating`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`enhance-split__blink-dot`}),(0,F.jsxs)(`span`,{children:[`Building project story from `,n.size,` sessions...`]})]}):(0,F.jsx)(`span`,{children:`Waiting for session processing...`})})]})]}),(0,F.jsxs)(`div`,{className:`enhance-split__right`,children:[(0,F.jsx)(Na,{current:`enhance`}),v?(0,F.jsxs)(`div`,{className:`enhance-error`,style:{marginTop:`var(--spacing-4)`},children:[(0,F.jsx)(`div`,{className:`enhance-error__message`,children:v}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:a,children:`Back`}),(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:ie,children:`Retry`}),re&&(0,F.jsx)(`button`,{className:`btn btn--primary btn--large`,onClick:j,children:`Continue without narrative`})]})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`upload-flow__label`,children:`Project Story`}),(0,F.jsx)(`h2`,{className:`upload-flow__title`,children:e.name}),!h&&!d?.narrative&&(0,F.jsxs)(`div`,{className:`enhance-split__narrative-placeholder`,children:[(0,F.jsx)(`span`,{className:`enhance-split__blink-dot`}),(0,F.jsx)(`span`,{children:l===`generating`?`Writing project narrative...`:`Analyzing sessions — narrative will appear here...`})]}),(h||d?.narrative)&&(0,F.jsxs)(`div`,{className:`enhance-split__narrative-text`,children:[d?.narrative??h,l===`generating`&&(0,F.jsx)(`span`,{className:`typewriter-cursor`,"aria-hidden":`true`})]}),ee.length>0&&(0,F.jsx)(`div`,{className:`enhance-split__skills`,children:ee.map(e=>(0,F.jsx)(`span`,{className:`chip`,children:e},e))}),d?.arc&&d.arc.length>0&&(()=>{let e=d.arc;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`upload-flow__section-label`,style:{marginTop:`var(--spacing-6)`},children:`Project Arc`}),(0,F.jsx)(`div`,{className:`enhance-split__arc`,children:e.map((t,n)=>(0,F.jsxs)(`div`,{className:`enhance-split__arc-item ${!O&&n===e.length-1?`enhance-split__arc-item--generating`:``}`,children:[(0,F.jsx)(`div`,{className:`enhance-split__arc-num`,children:String(t.phase).padStart(2,`0`)}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`enhance-split__arc-title`,children:t.title}),(0,F.jsx)(`div`,{className:`enhance-split__arc-desc`,children:t.description})]})]},n))})]})})(),te&&ne&&!O&&(0,F.jsxs)(`div`,{className:`enhance-split__failure-recovery`,children:[(0,F.jsxs)(`p`,{className:`enhance-split__failure-text`,children:[k.length,` session`,k.length===1?``:`s`,` failed to enhance.`]}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:ie,children:`Retry failed`}),re&&(0,F.jsxs)(`button`,{className:`btn btn--primary btn--large`,onClick:j,children:[`Continue with `,A.length,` successful →`]})]})]}),O&&(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[b&&(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:()=>{w.current?.abort(),C(!0)},children:`Re-enhance`}),(0,F.jsxs)(`button`,{className:`btn btn--primary btn--large`,onClick:()=>i(d),children:[d.questions.length>0?`Answer a few questions`:`Continue`,` →`]})]})]})]})]})}var Ua={pattern:`Pattern detected`,architecture:`Architecture`,evolution:`Evolution`};function Wa({enhanceResult:e,onSkip:t,onWeave:n}){let[r,i]=(0,_.useState)(new Map),[a,o]=(0,_.useState)(!1),s=(0,_.useCallback)((e,t)=>{i(n=>{let r=new Map(n);return r.set(e,t),r})},[]),c=Array.from(r.values()).some(e=>e.trim().length>0),l=(0,_.useCallback)(()=>{let t=e.questions.filter(e=>(r.get(e.id)??``).trim().length>0).map(e=>({questionId:e.id,question:e.question,answer:r.get(e.id).trim()}));o(!0),n(t)},[r,e.questions,n]);return(0,F.jsxs)(`div`,{className:`upload-flow`,children:[(0,F.jsx)(Na,{current:`questions`}),(0,F.jsxs)(`div`,{className:`upload-flow__scan-status`,children:[`✓ `,e.timeline.reduce((e,t)=>e+t.sessions.length,0),` sessions enhanced · Project narrative generated`]}),(0,F.jsx)(`h2`,{className:`upload-flow__title`,children:`A few things we noticed`}),(0,F.jsx)(`p`,{className:`upload-flow__desc`,children:`Your answers get woven into the narrative. Skip any you don't want to answer.`}),(0,F.jsx)(`div`,{className:`questions-list`,children:e.questions.map(e=>(0,F.jsxs)(`div`,{className:`question-card`,children:[(0,F.jsx)(`div`,{className:`question-card__tag-row`,children:(0,F.jsx)(`span`,{className:`question-card__tag question-card__tag--${e.category}`,children:Ua[e.category]??e.category})}),(0,F.jsx)(`div`,{className:`question-card__text`,children:e.question}),(0,F.jsx)(`textarea`,{className:`question-card__textarea`,value:r.get(e.id)??``,onChange:t=>s(e.id,t.target.value),placeholder:e.context||``,rows:3})]},e.id))}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:t,disabled:a,children:`Skip questions`}),(0,F.jsx)(`button`,{className:`btn btn--primary btn--large`,onClick:l,disabled:!c||a,children:a?`Weaving...`:`Weave into narrative →`})]})]})}function Ga({project:e,timeline:t,onBack:n,onViewProject:r}){let i=t.reduce((e,t)=>e+t.sessions.length,0);return(0,F.jsxs)(`div`,{className:`upload-flow`,children:[(0,F.jsx)(Na,{current:`timeline`}),(0,F.jsx)(`div`,{className:`upload-flow__label`,children:`Project Timeline`}),(0,F.jsxs)(`h2`,{className:`upload-flow__title`,children:[e.name,` `,(0,F.jsxs)(`span`,{style:{fontWeight:400,fontSize:`1rem`,color:`var(--on-surface-variant)`},children:[i,` sessions`]})]}),(0,F.jsx)(`p`,{className:`upload-flow__desc`,children:e.description}),(0,F.jsxs)(`div`,{className:`timeline`,children:[(0,F.jsx)(`div`,{className:`timeline__line`}),t.map((e,t)=>{let n=e.sessions.filter(e=>e.featured),r=e.sessions.filter(e=>!e.featured);return(0,F.jsxs)(`div`,{className:`timeline__period`,children:[(0,F.jsxs)(`div`,{className:`timeline__period-header`,children:[(0,F.jsx)(`span`,{className:`timeline__period-date`,children:e.period}),(0,F.jsx)(`span`,{className:`timeline__period-sep`,children:`—`}),(0,F.jsx)(`span`,{className:`timeline__period-label`,children:e.label})]}),n.map(e=>(0,F.jsxs)(`div`,{className:`timeline__featured`,children:[(0,F.jsx)(`div`,{className:`timeline__dot--large`}),(0,F.jsxs)(`div`,{className:`timeline__card`,children:[(0,F.jsxs)(`div`,{className:`timeline__card-header`,children:[(0,F.jsx)(`span`,{className:`timeline__card-title`,children:e.title}),e.tag&&(0,F.jsx)(`span`,{className:`timeline__card-tag`,children:e.tag})]}),(0,F.jsxs)(`div`,{className:`timeline__card-meta`,children:[(0,F.jsx)(`span`,{children:Oa(e.duration)}),e.date&&(0,F.jsx)(`span`,{children:Aa(e.date)})]}),e.description&&(0,F.jsx)(`p`,{className:`timeline__card-desc`,children:e.description}),e.skills&&e.skills.length>0&&(0,F.jsx)(`div`,{className:`timeline__card-skills`,children:e.skills.map(e=>(0,F.jsx)(`span`,{className:`chip`,children:e},e))})]})]},e.sessionId)),r.length>0&&(0,F.jsxs)(`div`,{className:`timeline__collapsed`,children:[(0,F.jsx)(`div`,{className:`timeline__dot--small`}),(0,F.jsx)(Ka,{sessions:r})]})]},t)})]}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:n,children:`Back`}),(0,F.jsx)(`button`,{className:`btn btn--primary btn--large`,onClick:r,children:`View updated project →`})]})]})}function Ka({sessions:e}){let t=e.map(e=>e.title.toLowerCase()).join(`, `),n=e.filter(e=>e.date).map(e=>e.date).sort(),r=n.length>=2?`${Aa(n[0])} \u2013 ${Aa(n[n.length-1])}`:n.length===1?Aa(n[0]):``;return(0,F.jsxs)(`span`,{className:`timeline__collapsed-text`,children:[e.length,` smaller session`,e.length===1?``:`s`,` — `,t,r&&(0,F.jsxs)(F.Fragment,{children:[` · `,r]})]})}var qa=[{period:`Mar 3–7`,label:`Foundation`,sessions:[{sessionId:`placeholder-1`,title:`Project scaffolding & architecture`,description:`Set up the monorepo structure, CI pipeline, and core abstractions.`,duration:145,featured:!0,tag:`KEY DECISION`,skills:[`Architecture`,`CI/CD`],date:`2026-03-03`},{sessionId:`placeholder-2`,title:`Dependency setup`,duration:30,featured:!1,date:`2026-03-04`},{sessionId:`placeholder-3`,title:`Initial config`,duration:15,featured:!1,date:`2026-03-05`}]},{period:`Mar 10–14`,label:`Core Implementation`,sessions:[{sessionId:`placeholder-4`,title:`Data model & API design`,description:`Designed the schema and REST endpoints for the core domain.`,duration:210,featured:!0,skills:[`API Design`,`PostgreSQL`],date:`2026-03-10`},{sessionId:`placeholder-5`,title:`Frontend component library`,description:`Built reusable components following the design system.`,duration:180,featured:!0,skills:[`React`,`CSS`],date:`2026-03-12`}]}];function Ja(){let{dirName:e}=st(),[t,n]=Mn(),r=at(),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!0);(0,_.useEffect)(()=>{Jn().then(a).catch(()=>{}).finally(()=>s(!1))},[]);let c=i.find(t=>t.dirName===e),[l,u]=(0,_.useState)(`overview`),d=(0,_.useCallback)(e=>{u(e),window.scrollTo(0,0)},[]),[f,p]=(0,_.useState)([]),[m,h]=(0,_.useState)(!0),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(new Set),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)([]),[T,E]=(0,_.useState)(null),D=(0,_.useRef)(null),[O,ee]=(0,_.useState)(null),[k,A]=(0,_.useState)(null);k?.narrative,k?.skills;let te=k?.timeline??[],ne=(0,_.useCallback)(()=>{f.length>0||!e||Yn(e).then(e=>{p(e),h(!1)}).catch(e=>{ee(e.message),h(!1)})},[e,f.length]);(0,_.useEffect)(()=>{[`overview`,`triage`,`enhance`].includes(l)&&ne()},[l,ne]),(0,_.useEffect)(()=>{let i=t.get(`view`)||t.get(`preview`);!e||i!==`1`||(n({},{replace:!0}),r(`/project/${e}`))},[e]);let re=(0,_.useCallback)(()=>{e&&(S(!0),ee(null),w([]),D.current=ar(e,e=>{if(w(t=>[...t,e]),e.type===`error`){ee(e.message),S(!1);return}if(e.type===`result`){let t={selected:e.selected,skipped:e.skipped,autoSelected:e.autoSelected,triageMethod:e.triageMethod};v(t);let n=new Set(t.selected.map(e=>e.sessionId));if(c?.uploadedSessions)for(let e of c.uploadedSessions)n.add(e);b(n),setTimeout(()=>{S(!1),t.autoSelected?(E(`All ${n.size} sessions selected (small project)`),d(`enhance`)):d(`triage`)},1200)}}))},[e]);(0,_.useEffect)(()=>()=>{D.current?.abort()},[]);let ie=(0,_.useCallback)(e=>{A(e),e.questions.length>0?d(`questions`):d(`timeline`)},[]),j=(0,_.useCallback)(()=>{d(`timeline`)},[]),M=(0,_.useCallback)(async t=>{if(!(!e||!k))try{let n=await sr(e,k.narrative,k.timeline,t);A(e=>e&&{...e,narrative:n.narrative,timeline:n.timeline}),d(`timeline`)}catch(e){ee(e.message)}},[e,k]),ae=(0,_.useCallback)(e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return o?(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},children:(0,F.jsx)(`div`,{className:`dashboard-loading`,children:`Loading project...`})}):c?(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},children:m&&l===`overview`?(0,F.jsx)(`div`,{className:`dashboard-loading`,children:`Loading sessions...`}):O&&l===`overview`?(0,F.jsx)(`div`,{className:`dashboard-error`,children:O}):l===`overview`?x?(0,F.jsx)(za,{events:C,dirName:e??``}):(0,F.jsx)(Pa,{project:c,sessions:f,onTriage:re,onCancel:()=>r(`/`)}):l===`triage`&&g?(0,F.jsx)(Va,{project:c,sessions:f,triageResult:g,selectedIds:y,onToggle:ae,onEnhance:()=>d(`enhance`),onBack:()=>d(`overview`),uploadedSessionIds:c.uploadedSessions?new Set(c.uploadedSessions):void 0}):l===`enhance`&&g?(0,F.jsxs)(F.Fragment,{children:[T&&(0,F.jsxs)(`div`,{className:`upload-flow__auto-select-banner`,children:[`✓ `,T]}),(0,F.jsx)(Ha,{project:c,sessions:f,selectedIds:y,triageResult:g,onComplete:ie,onBack:()=>d(`triage`)})]}):l===`questions`&&k?(0,F.jsx)(Wa,{enhanceResult:k,onSkip:j,onWeave:M}):l===`timeline`?(0,F.jsx)(Ga,{project:c,timeline:te.length>0?te.map(e=>({...e,sessions:e.sessions.map(e=>({sessionId:e.sessionId,title:e.title,featured:e.featured,tag:e.tag,duration:f.find(t=>t.id===e.sessionId)?.durationMinutes??0,date:f.find(t=>t.id===e.sessionId)?.date}))})):qa,onBack:()=>k?.questions.length?d(`questions`):d(`enhance`),onViewProject:()=>{e&&k&&gr(e,Array.from(y),k).catch(()=>{}),r(`/project/${e}`)}}):null}):(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},children:(0,F.jsx)(`div`,{className:`dashboard-error`,children:`Project not found`})})}function Ya(e){let t=e.indexOf(`-Dev-`);if(t!==-1)return e.slice(t+5);let n=e.split(`-`).filter(Boolean);return n.length>0?n[n.length-1]:e}function Xa(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)}function Za(){let{dirName:e=``}=st(),[t,n]=(0,_.useState)({step:`review`}),[r,i]=(0,_.useState)(null);(0,_.useEffect)(()=>{e&&nr(e).then(i).catch(()=>{})},[e]);let a=(0,_.useCallback)(()=>{n({step:`uploading`,messages:[]});let t=r?.enhanceCache,i=r?.project,a=i?.name??Ya(e);cr(e,{title:a,slug:Xa(a),narrative:t?.result?.narrative??``,repoUrl:t?.repoUrl??``,projectUrl:t?.projectUrl??``,timeline:t?.result?.timeline??[],skills:t?.result?.skills??[],totalSessions:i?.sessionCount??0,totalLoc:i?.totalLoc??0,totalDurationMinutes:i?.totalDuration??0,totalAgentDurationMinutes:i?.totalAgentDuration,totalFilesChanged:i?.totalFiles??0,totalInputTokens:i?.totalInputTokens??0,totalOutputTokens:i?.totalOutputTokens??0,skippedSessions:[],selectedSessionIds:t?.selectedSessionIds??[],screenshotBase64:t?.screenshotBase64??void 0},e=>{switch(e.type){case`project`:n(t=>t.step===`uploading`?{...t,messages:[...t.messages,`Project ${e.status}`]}:t);break;case`session`:n(t=>t.step===`uploading`?{...t,messages:[...t.messages,`Session ${e.sessionId}: ${e.status}`]}:t);break;case`done`:n({step:`done`,projectUrl:e.projectUrl,uploaded:e.uploaded,failed:e.failed});break;case`error`:e.message===`AUTH_REQUIRED`?o():n({step:`error`,message:e.message});break}})},[e,r]),o=(0,_.useCallback)(async()=>{n({step:`auth`,status:`opening`});try{let e=await Sr();window.open(e.verification_uri,`_blank`),n({step:`auth`,status:`waiting`});let t=Date.now(),r=async()=>{try{if((await yr(e.device_code)).authenticated){n({step:`auth`,status:`done`}),setTimeout(()=>a(),500);return}}catch{}Date.now()-t<3e5?setTimeout(r,5e3):n({step:`auth`,status:`error`,error:`Timed out. Try again.`})};setTimeout(r,5e3)}catch{n({step:`auth`,status:`error`,error:`Could not connect. Try again later.`})}},[a]),s=(0,F.jsx)(`button`,{className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,onClick:a,disabled:t.step===`uploading`,children:`Upload to heyiam.com`});return(0,F.jsx)(Ar,{back:{label:`Project`,to:`/project/${e}`},chips:[{label:`Upload to heyiam.com`}],actions:t.step===`review`?s:void 0,children:(0,F.jsxs)(`div`,{className:`p-6`,children:[t.step===`uploading`&&(0,F.jsxs)(L,{className:`max-w-2xl mx-auto`,children:[(0,F.jsx)(z,{title:`Uploading...`,meta:`in progress`}),(0,F.jsxs)(`div`,{className:`space-y-1.5 mt-3`,children:[t.messages.map((e,t)=>(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-on-surface-variant`,children:[(0,F.jsx)(`span`,{className:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin shrink-0`}),e]},t)),t.messages.length===0&&(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-on-surface-variant`,children:[(0,F.jsx)(`span`,{className:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin shrink-0`}),`Connecting...`]})]})]}),t.step===`done`&&(0,F.jsxs)(L,{className:`max-w-2xl mx-auto`,children:[(0,F.jsx)(z,{title:`Uploaded`,meta:`on heyi.am`}),(0,F.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green shrink-0`}),(0,F.jsxs)(`span`,{className:`text-sm text-on-surface font-medium`,children:[t.uploaded,` session`,t.uploaded===1?``:`s`,` uploaded`]})]}),(0,F.jsx)(`p`,{className:`text-xs text-on-surface-variant`,children:`Sessions are unlisted by default. Go to the dashboard to publish them.`}),(0,F.jsx)(`a`,{href:t.projectUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors mt-1`,children:`Open dashboard`})]})]}),t.step===`auth`&&(0,F.jsxs)(L,{className:`max-w-2xl mx-auto`,children:[t.status===`opening`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{title:`Opening browser...`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 text-sm text-on-surface-variant`,children:[(0,F.jsx)(`span`,{className:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin shrink-0`}),`Starting login...`]})]}),t.status===`waiting`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{title:`Log in to heyiam.com`}),(0,F.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-on-surface-variant`,children:[(0,F.jsx)(`span`,{className:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin shrink-0`}),`Waiting for you to finish in the browser...`]}),(0,F.jsx)(`p`,{className:`text-xs text-on-surface-variant`,children:`Log in or create an account in the browser window that opened, then come back here.`})]})]}),t.status===`done`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{title:`Logged in`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 text-sm text-on-surface`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green shrink-0`}),`Uploading...`]})]}),t.status===`error`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{title:`Login failed`}),(0,F.jsx)(`p`,{className:`text-error text-sm mt-2`,children:t.error}),(0,F.jsx)(`button`,{className:`mt-3 inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,onClick:o,children:`Try again`})]})]}),t.step===`error`&&(0,F.jsxs)(L,{className:`max-w-2xl mx-auto`,children:[(0,F.jsx)(z,{title:`Upload failed`}),(0,F.jsx)(`p`,{className:`text-error text-sm mt-2`,children:t.message}),(0,F.jsx)(`button`,{className:`mt-3 inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,onClick:a,children:`Retry`})]}),t.step===`review`&&(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`What gets uploaded`,meta:`review`}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(R,{children:`Project title and narrative summary`}),(0,F.jsx)(R,{children:`Selected sessions and stats`}),(0,F.jsx)(R,{children:`Curated decisions, phases, and rendered templates`})]})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`What stays local`,meta:`safety`}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(R,{children:`Excluded sessions and private notes`}),(0,F.jsx)(R,{children:`Source audit details and archive metadata`}),(0,F.jsx)(R,{children:`Sensitive flagged terms and personal data`})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-3 mt-4`,children:(0,F.jsx)(`button`,{className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,onClick:a,children:`Upload to heyiam.com`})})]})]})]})})}function Qa(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!0),[m,h]=(0,_.useState)({localOnly:!0,requireReview:!0,excludeOpenClaw:!1});(0,_.useEffect)(()=>{Promise.all([lr().catch(()=>({hasKey:!1})),dr().catch(()=>({authenticated:!1}))]).then(([e,n])=>{t(e),r(n)}).finally(()=>p(!1))},[]);async function g(){if(i.trim()){l(!0);try{await ur(i.trim()),t({hasKey:!0,keyPrefix:i.trim().slice(0,16)}),a(``)}finally{l(!1)}}}async function v(){l(!0);try{await ur(``),t({hasKey:!1}),a(``),s(!1)}finally{l(!1)}}async function y(){d(!0);try{await Cr(),r({authenticated:!1})}finally{d(!1)}}function b(e){h(t=>({...t,[e]:!t[e]}))}return f||!e||!n?(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},chips:[{label:`Settings`}],children:(0,F.jsx)(`div`,{className:`max-w-3xl mx-auto p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading settings...`})})}):(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},chips:[{label:`Settings`}],children:(0,F.jsxs)(`div`,{className:`max-w-3xl mx-auto p-6`,children:[(0,F.jsx)(`h2`,{className:`font-display text-2xl font-bold text-on-surface`,children:`Settings`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 mt-6`,children:[(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`API configuration`,meta:`local only`}),(0,F.jsx)(`label`,{className:`font-mono text-[11px] uppercase tracking-wider text-on-surface-variant block mb-1.5`,children:`Anthropic API Key`}),e.hasKey&&!i?(0,F.jsx)(`input`,{type:o?`text`:`password`,value:e.keyPrefix?`${e.keyPrefix}...`:`••••••••••••`,readOnly:!0,className:`w-full bg-surface-low border border-ghost rounded-md px-3 py-1.5 text-sm font-mono text-on-surface mb-2`}):(0,F.jsx)(`input`,{type:`password`,value:i,onChange:e=>a(e.target.value),placeholder:`sk-ant-api03-...`,className:`w-full bg-surface-low border border-ghost rounded-md px-3 py-1.5 text-sm font-mono text-on-surface mb-2`,onKeyDown:e=>{e.key===`Enter`&&g()}}),(0,F.jsx)(`p`,{className:`text-on-surface-variant text-xs mb-3`,children:`Used for project refinement. Keys stay on your machine.`}),(0,F.jsx)(`div`,{className:`flex items-center gap-2`,children:e.hasKey&&!i?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{className:`text-xs font-medium px-2.5 py-1 rounded-md border border-outline text-on-surface hover:bg-surface-low transition-colors`,onClick:()=>s(!o),children:o?`Hide`:`Show`}),(0,F.jsx)(`button`,{className:`text-xs font-medium px-2.5 py-1 rounded-md text-on-surface-variant hover:text-on-surface transition-colors`,onClick:v,disabled:c,children:`Remove`})]}):i?(0,F.jsx)(`button`,{className:`text-xs font-medium px-2.5 py-1 rounded-md bg-primary text-on-primary hover:bg-primary-hover transition-colors`,onClick:g,disabled:c,children:c?`Saving...`:`Save key`}):null})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Privacy defaults`,meta:`recommended`}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)($a,{label:`Mark new projects local only by default`,checked:m.localOnly,onChange:()=>b(`localOnly`)}),(0,F.jsx)($a,{label:`Require review before publish`,checked:m.requireReview,onChange:()=>b(`requireReview`)}),(0,F.jsx)($a,{label:`Exclude personal OpenClaw sessions by default`,checked:m.excludeOpenClaw,onChange:()=>b(`excludeOpenClaw`)})]})]})]}),(0,F.jsx)(`div`,{className:`mt-4`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Authentication`,meta:`optional`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${n.authenticated?`bg-green`:`bg-outline`}`}),n.authenticated?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`span`,{className:`text-[13px] text-on-surface`,children:[`Connected as `,(0,F.jsxs)(`strong`,{children:[`@`,n.username]})]}),(0,F.jsx)(`span`,{className:`text-xs text-on-surface-variant`,children:`Authenticated via device auth. Required for publishing.`}),(0,F.jsx)(`button`,{className:`ml-auto text-xs font-medium px-2.5 py-1 rounded-md text-on-surface-variant hover:text-on-surface transition-colors`,onClick:y,disabled:u,children:u?`Disconnecting...`:`Disconnect`})]}):(0,F.jsx)(`span`,{className:`text-[13px] text-on-surface-variant`,children:`Not connected. Authentication is required for publishing.`})]})]})})]})})}function $a({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`span`,{className:`text-sm text-on-surface`,children:e}),(0,F.jsx)(`button`,{role:`switch`,"aria-checked":t,onClick:n,className:`relative w-[40px] h-[22px] rounded-full transition-colors ${t?`bg-green`:`bg-surface-high`}`,children:(0,F.jsx)(`span`,{className:`absolute top-[3px] w-4 h-4 rounded-full bg-surface-lowest shadow-sm transition-transform ${t?`left-[21px]`:`left-[3px]`}`})})]})}var eo=[`Claude`,`Cursor`,`Codex`,`Gemini`];function to(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function no(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ro(e){try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}catch{return e}}function io(){let[e,t]=Mn(),n=at(),r=e.get(`q`)??``,i=e.get(`source`)??``,a=e.get(`project`)??``,o=e.get(`skill`)??``,[s,c]=(0,_.useState)(r),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(!1),v=i,y=a,b=o,[x,S]=(0,_.useState)([]),[C,w]=(0,_.useState)([]),T=(0,_.useCallback)(async(e,t,n,r)=>{if(!e&&!t&&!n&&!r){u([]),f(0),g(!1);return}m(!0),g(!0);try{let i=await fr(e,{source:t||void 0,project:n||void 0,skill:r||void 0});u(i.results),f(i.total);let a=[...new Set(i.results.map(e=>e.projectName))].sort(),o=[...new Set(i.results.flatMap(e=>e.skills))].sort();S(a),w(o)}catch{u([]),f(0)}finally{m(!1)}},[]);(0,_.useEffect)(()=>{let e=setTimeout(()=>{let e=new URLSearchParams;s&&e.set(`q`,s),v&&e.set(`source`,v),y&&e.set(`project`,y),b&&e.set(`skill`,b),t(e,{replace:!0}),T(s,v,y,b)},300);return()=>clearTimeout(e)},[s,v,y,b,t,T]),(0,_.useEffect)(()=>{(r||i||a||o)&&(c(r),T(r,i,a,o))},[]);function E(n,r){let i=new URLSearchParams(e);i.get(n)===r?i.delete(n):i.set(n,r),t(i,{replace:!0})}return(0,F.jsx)(Ar,{chips:[{label:`Search`}],children:(0,F.jsxs)(`div`,{className:`p-6 max-w-3xl mx-auto`,children:[(0,F.jsx)(kr,{value:s,onChange:c,autoFocus:!0,placeholder:`Search sessions...`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-3`,children:[(0,F.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mr-1`,children:`Source`}),eo.map(e=>(0,F.jsx)(`button`,{onClick:()=>E(`source`,e.toLowerCase()),className:[`font-mono text-[11px] leading-tight py-0.5 px-2 rounded-sm border transition-colors cursor-pointer`,v===e.toLowerCase()?`bg-primary/10 text-primary border-primary/30`:`bg-surface-low text-on-surface-variant border-ghost hover:border-outline`].join(` `),children:e},e)),x.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline ml-3 mr-1`,children:`Project`}),x.slice(0,5).map(e=>(0,F.jsx)(`button`,{onClick:()=>E(`project`,e),className:[`font-mono text-[11px] leading-tight py-0.5 px-2 rounded-sm border transition-colors cursor-pointer`,y===e?`bg-primary/10 text-primary border-primary/30`:`bg-surface-low text-on-surface-variant border-ghost hover:border-outline`].join(` `),children:e},e))]}),C.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline ml-3 mr-1`,children:`Skill`}),C.slice(0,5).map(e=>(0,F.jsx)(`button`,{onClick:()=>E(`skill`,e),className:[`font-mono text-[11px] leading-tight py-0.5 px-2 rounded-sm border transition-colors cursor-pointer`,b===e?`bg-violet-bg text-violet border-violet/30`:`bg-surface-low text-on-surface-variant border-ghost hover:border-outline`].join(` `),children:e},e))]})]}),(0,F.jsx)(`div`,{className:`h-4`}),p?(0,F.jsx)(`div`,{className:`text-sm text-on-surface-variant`,children:`Searching...`}):h?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`font-mono text-[11px] text-on-surface-variant mb-3`,children:[d,` result`,d===1?``:`s`,s?` for '${s}'`:``]}),l.length===0?(0,F.jsx)(L,{children:(0,F.jsx)(`p`,{className:`text-sm text-on-surface-variant`,children:`No sessions found. Try a different query or adjust filters.`})}):(0,F.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,F.jsx)(`button`,{onClick:()=>n(`/session/${encodeURIComponent(e.sessionId)}${s?`?q=${encodeURIComponent(s)}`:``}`),className:`text-left w-full cursor-pointer`,children:(0,F.jsxs)(L,{hover:!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`h4`,{className:`font-display text-[0.8125rem] font-semibold text-on-surface truncate`,children:e.title}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,F.jsx)(`span`,{className:`text-xs text-on-surface-variant`,children:e.projectName}),(0,F.jsx)(I,{children:e.source}),(0,F.jsx)(`span`,{className:`text-xs text-outline`,children:ro(e.date)})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 font-mono text-[0.6875rem] text-outline shrink-0`,children:[(0,F.jsx)(`span`,{children:to(e.durationMinutes)}),(0,F.jsxs)(`span`,{children:[e.turns,` turns`]}),(0,F.jsxs)(`span`,{children:[no(e.linesOfCode),` lines`]})]})]}),e.snippet&&(0,F.jsx)(`p`,{className:`text-xs text-on-surface-variant mt-2 line-clamp-2 font-mono`,children:e.snippet}),e.skills.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.skills.map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e))})]})},e.sessionId))})]}):(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,F.jsxs)(`svg`,{className:`w-12 h-12 text-outline mb-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,F.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,F.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,F.jsx)(`p`,{className:`font-display text-sm font-semibold text-on-surface`,children:`Search across all your AI sessions`}),(0,F.jsx)(`p`,{className:`text-xs text-on-surface-variant mt-1`,children:`Full-text search with source, project, and skill filters`})]})]})})}var ao={Read:`📄`,Write:`✏️`,Edit:`✏️`,Bash:`▶`,Grep:`🔍`,Glob:`📂`,Agent:`🤖`,WebSearch:`🌐`,WebFetch:`🌐`};function oo(e){return ao[e]??`⚙`}function so(e){let{toolName:t,input:n}=e;if(!n)return t;switch(t){case`Read`:return n;case`Write`:return n;case`Edit`:return n;case`Bash`:return n.length>80?n.slice(0,77)+`...`:n;case`Grep`:case`Glob`:return n;case`Agent`:return n;default:return n.length>60?n.slice(0,57)+`...`:n}}function co({block:e}){let[t,n]=(0,_.useState)(!1),r=!!e.output,i=e.toolName===`Edit`,a=e.toolName===`Bash`;return(0,F.jsxs)(`div`,{className:`my-1.5 border border-ghost rounded-md bg-surface-lowest overflow-hidden`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-surface-low transition-colors cursor-pointer`,children:[(0,F.jsx)(`span`,{className:`text-xs shrink-0 w-4 text-center`,children:oo(e.toolName)}),(0,F.jsx)(`span`,{className:`font-mono text-[11px] font-semibold text-primary shrink-0`,children:e.toolName}),(0,F.jsx)(`span`,{className:`font-mono text-[11px] text-on-surface-variant truncate flex-1`,children:so(e)}),e.isError&&(0,F.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-error shrink-0`,children:`error`}),(0,F.jsx)(`span`,{className:`text-[10px] text-outline shrink-0 transition-transform`,style:{transform:t?`rotate(90deg)`:`rotate(0deg)`},children:`▸`})]}),t&&(0,F.jsxs)(`div`,{className:`border-t border-ghost`,children:[i&&e.inputData&&(0,F.jsxs)(`div`,{className:`px-3 py-2 border-b border-ghost`,children:[typeof e.inputData.old_string==`string`&&(0,F.jsxs)(`div`,{className:`mb-2`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-1`,children:`old`}),(0,F.jsx)(`pre`,{className:`font-mono text-[11px] text-error/80 bg-error/5 rounded px-2 py-1.5 overflow-x-auto whitespace-pre-wrap break-all max-h-40 overflow-y-auto`,children:e.inputData.old_string})]}),typeof e.inputData.new_string==`string`&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-1`,children:`new`}),(0,F.jsx)(`pre`,{className:`font-mono text-[11px] text-green/80 bg-green/5 rounded px-2 py-1.5 overflow-x-auto whitespace-pre-wrap break-all max-h-40 overflow-y-auto`,children:e.inputData.new_string})]})]}),a&&e.input&&(0,F.jsx)(`div`,{className:`px-3 py-2 border-b border-ghost bg-[var(--inverse-surface)]`,children:(0,F.jsxs)(`pre`,{className:`font-mono text-[11px] text-[var(--inverse-on-surface)] whitespace-pre-wrap break-all`,children:[`$ `,e.input]})}),r&&(0,F.jsxs)(`div`,{className:`px-3 py-2 max-h-64 overflow-y-auto`,children:[(0,F.jsx)(`pre`,{className:`font-mono text-[11px] whitespace-pre-wrap break-all ${e.isError?`text-error`:`text-on-surface-variant`}`,children:e.output}),e.outputTruncated&&(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mt-2`,children:`output truncated`})]}),!r&&!i&&!a&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-[11px] text-outline italic`,children:`no output`})]})]})}function W({text:e}){let[t,n]=(0,_.useState)(!1),r=e.slice(0,80).replace(/\n/g,` `);return(0,F.jsxs)(`div`,{className:`my-1`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex items-center gap-2 text-left cursor-pointer group`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-outline transition-transform shrink-0`,style:{transform:t?`rotate(90deg)`:`rotate(0deg)`},children:`▸`}),(0,F.jsx)(`span`,{className:`font-mono text-[11px] text-outline italic group-hover:text-on-surface-variant transition-colors`,children:t?`thinking`:`thinking: ${r}${e.length>80?`...`:``}`})]}),t&&(0,F.jsx)(`div`,{className:`ml-5 mt-1.5 pl-3 border-l-2 border-ghost`,children:(0,F.jsx)(`pre`,{className:`font-mono text-[11px] text-on-surface-variant/70 whitespace-pre-wrap break-words max-h-96 overflow-y-auto`,children:e})})]})}var G=300;function lo({text:e,highlights:t}){let[n,r]=(0,_.useState)(e.length<=G),i=e.length>G,a=(()=>{if(!i)return e.length;let t=e.slice(0,G+50),n=t.lastIndexOf(`. `,G);if(n>G*.6)return n+1;let r=t.lastIndexOf(` `,G);return r>G*.6?r:G})(),o=n?e:e.slice(0,a);if(t){let e=RegExp(`(${go(t)})`,`gi`);return(0,F.jsxs)(`div`,{className:`text-[0.8125rem] leading-relaxed whitespace-pre-wrap break-words`,children:[o.split(e).map((t,n)=>e.test(t)?(0,F.jsx)(`mark`,{className:`bg-amber/30 text-on-surface rounded-sm px-0.5`,children:t},n):(0,F.jsx)(`span`,{children:t},n)),i&&(0,F.jsx)(uo,{expanded:n,onToggle:()=>r(!n)})]})}return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(fo,{text:o}),i&&(0,F.jsx)(uo,{expanded:n,onToggle:()=>r(!n)})]})}function uo({expanded:e,onToggle:t}){return(0,F.jsx)(`button`,{type:`button`,onClick:t,className:`inline-block mt-1 font-mono text-[11px] text-primary hover:underline cursor-pointer`,children:e?`▴ Show less`:`▾ Show more`})}function fo({text:e}){return(0,F.jsx)(`div`,{className:`text-[0.8125rem] leading-relaxed whitespace-pre-wrap break-words`,children:e.split(/(```[\s\S]*?```)/g).map((e,t)=>{if(e.startsWith("```")&&e.endsWith("```")){let n=e.slice(3,-3),r=n.indexOf(`
|
|
20
|
+
`).map((e,t)=>(0,F.jsxs)(U,{variant:`info`,children:[` `,e]},`${u}-${t}`)),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(U,{variant:`default`,children:[` `,(0,F.jsxs)(`span`,{className:`text-white/30`,children:[`section `,u+1,`/4`]})]})]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(Qi,{question:`Enhance this project?`,onYes:()=>{v(null),t(`preview_enhanced`)},onNo:()=>{v(null),t(`preview_enhanced`)},yesLabel:`Enhance`,noLabel:`Skip`})]}),e===`preview_enhanced`&&(0,F.jsxs)(Zi,{compact:!0,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam enhance heyi-am`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`passed`,children:` Reading 16 sessions...`}),(0,F.jsx)(U,{variant:`passed`,children:` Extracting skills...`}),(0,F.jsx)(U,{variant:`passed`,children:` Writing narrative...`}),(0,F.jsx)(U,{variant:`passed`,children:` Building project arc...`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`passed`,children:` Enhanced. Scroll to see the`}),(0,F.jsx)(U,{variant:`passed`,children:` difference.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(Qi,{question:`Continue tour?`,onYes:()=>t(`prompt_enhance`),onNo:()=>ne()})]}),e===`prompt_enhance`&&(0,F.jsxs)(Zi,{compact:!0,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam enhance`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`info`,children:` To enhance your own projects,`}),(0,F.jsx)(U,{variant:`info`,children:` you need an Anthropic API key.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),m?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(U,{variant:`passed`,children:` API key saved. You're all set.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(Qi,{question:`Continue?`,onYes:()=>t(`claim_username`),onNo:()=>t(`claim_username`)})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Qi,{question:`Add your API key now?`,onYes:()=>{},onNo:()=>t(`claim_username`),noLabel:`I'll do this later`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(`div`,{className:`triage-terminal__line opacity-80`,children:` Paste your key:`}),(0,F.jsx)(`div`,{className:`flex items-center gap-2 mt-1 ml-4`,children:(0,F.jsx)(`input`,{type:`password`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f.startsWith(`sk-`)&&ur(f).then(()=>h(!0)).catch(()=>{})},placeholder:`sk-ant-...`,className:`bg-white/10 border border-white/20 rounded px-2 py-1 text-[11px] font-mono text-[#34d399] w-48 outline-none focus:border-[#9dcaff] placeholder:text-white/20`})}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(`div`,{className:`triage-terminal__line opacity-40 text-[10px]`,children:[` `,`You can always add this later in Settings.`]})]})]}),e===`claim_username`&&(0,F.jsxs)(Zi,{compact:!1,children:[(0,F.jsx)(U,{variant:`prompt`,children:`$ heyiam publish`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`section`,children:` Claim your portfolio page`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(U,{variant:`info`,children:` Want to show off your AI dev work?`}),(0,F.jsx)(U,{variant:`info`,children:` Claim a name and create a public`}),(0,F.jsx)(U,{variant:`info`,children:` portfolio on heyi.am — show how`}),(0,F.jsx)(U,{variant:`info`,children:` you build, not just what you ship.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(U,{variant:`info`,children:[` Your page: `,(0,F.jsxs)(`span`,{className:`text-[#9dcaff] font-semibold`,children:[`heyi.am/`,y||`your-name`]})]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(`div`,{className:`triage-terminal__line opacity-40 text-[10px]`,children:[` `,`Optional — the CLI works fully without an account.`]}),(0,F.jsxs)(`div`,{className:`triage-terminal__line opacity-40 text-[10px]`,children:[` `,`You choose what to publish. Nothing is public by default.`]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),x===`claimed`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(U,{variant:`passed`,children:[` Welcome, `,T,`!`]}),(0,F.jsxs)(U,{variant:`passed`,children:[` heyi.am/`,T,` is yours.`]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsx)(Qi,{question:`Ready to explore?`,onYes:ne,onNo:ne,yesLabel:`Let's go`})]}):D?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(U,{variant:`active`,children:` Waiting for signup to complete...`}),(0,F.jsx)(U,{variant:`info`,children:` A browser window should have opened.`}),(0,F.jsx)(U,{variant:`info`,children:` Sign up there, then come back here.`}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 ml-4`,children:[(0,F.jsx)(`button`,{onClick:()=>{O(!1),S(`idle`),k(``)},className:`text-[10px] font-mono px-2.5 py-1 rounded text-white/40 hover:text-white/70 transition-colors`,children:`Cancel`}),(0,F.jsx)(`button`,{onClick:()=>{O(!1),ne()},className:`text-[10px] font-mono px-2.5 py-1 rounded text-white/40 hover:text-white/70 transition-colors`,children:`Skip this`})]})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`triage-terminal__line opacity-80`,children:` Choose a username:`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 ml-4`,children:[(0,F.jsx)(`span`,{className:`text-white/40 text-[11px] font-mono`,children:`heyi.am/`}),(0,F.jsx)(`input`,{type:`text`,value:y,onChange:e=>{let t=e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,``);b(t),S(`idle`),w(``),A.current&&clearTimeout(A.current),t.length>=3&&t!==te.current&&(A.current=setTimeout(async()=>{te.current=t,S(`checking`);try{let e=await br(t);S(e.available?`available`:`taken`),e.available||w(e.reason||`Taken`)}catch{S(`idle`)}},500))},onKeyDown:async e=>{if(e.key===`Enter`&&y.length>=3){if(e.preventDefault(),x===`submitting`||x===`checking`||D)return;A.current&&clearTimeout(A.current),S(`submitting`),w(``);try{let e=await br(y);if(!e.available){S(`taken`),w(e.reason||`Username is taken`);return}let t=await xr(y);k(t.device_code),O(!0),S(`available`),window.open(t.verification_uri,`_blank`);let n=Date.now(),r=async()=>{try{let e=await yr(t.device_code);if(e.authenticated){O(!1),S(`claimed`),E(e.username||y);return}}catch{}Date.now()-n<3e5?setTimeout(r,5e3):(O(!1),S(`error`),w(`Timed out. Try again.`))};setTimeout(r,5e3)}catch{S(`error`),w(`Could not connect. Try again later.`)}}},placeholder:`your-name`,className:`bg-white/10 border border-white/20 rounded px-2 py-1 text-[11px] font-mono text-[#34d399] w-36 outline-none focus:border-[#9dcaff] placeholder:text-white/20`,autoFocus:!0}),x===`checking`&&(0,F.jsx)(`span`,{className:`text-[10px] text-[#fbbf24] font-mono`,children:`checking...`}),x===`available`&&(0,F.jsx)(`span`,{className:`text-[10px] text-[#34d399] font-mono`,children:`available!`}),x===`submitting`&&(0,F.jsx)(`span`,{className:`text-[10px] text-[#fbbf24] font-mono`,children:`claiming...`}),x===`taken`&&(0,F.jsx)(`span`,{className:`text-[10px] text-[#f87171] font-mono`,children:C}),x===`error`&&(0,F.jsx)(`span`,{className:`text-[10px] text-[#f87171] font-mono`,children:C})]}),y.length>=3&&x===`idle`&&(0,F.jsxs)(`div`,{className:`triage-terminal__line opacity-40 text-[10px] mt-1`,children:[` `,`Press Enter to check & claim`]}),(0,F.jsx)(U,{variant:`default`,children:`\xA0`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 ml-4`,children:[(0,F.jsx)(`button`,{disabled:D||x===`submitting`,onClick:async()=>{if(!(D||x===`submitting`)){S(`submitting`),w(``);try{let e=await xr(``);k(e.device_code),O(!0),S(`idle`),window.open(e.verification_uri,`_blank`);let t=Date.now(),n=async()=>{try{let t=await yr(e.device_code);if(t.authenticated){O(!1),S(`claimed`),E(t.username||``);return}}catch{}Date.now()-t<3e5?setTimeout(n,5e3):(O(!1),S(`error`),w(`Timed out.`))};setTimeout(n,5e3)}catch{S(`error`),w(`Could not connect. Try again later.`)}}},className:`text-[10px] font-mono px-2.5 py-1 rounded bg-white/10 text-white/70 hover:text-white/90 hover:bg-white/15 transition-colors disabled:opacity-40`,children:`Already have an account? Log in`}),(0,F.jsx)(`button`,{onClick:()=>ne(),className:`text-[10px] font-mono px-2.5 py-1 rounded text-white/40 hover:text-white/70 transition-colors`,children:`I'll do this later`})]})]})]})]}),ae&&(0,F.jsx)(`div`,{className:`flex-1 min-w-0 pr-4 pt-6 pb-8 animate-[slideIn_0.6s_cubic-bezier(0.16,1,0.3,1)_forwards]`,children:(e===`preview_project`||e===`preview_enhanced`||e===`prompt_enhance`)&&(0,F.jsx)(qi,{enhanced:e===`preview_enhanced`||e===`prompt_enhance`,onScrollSection:d,selectedSession:g,onSelectSession:v},e===`preview_project`?`draft`:`enhanced`)})]}),e===`dashboard`&&(0,F.jsx)($i,{dashboard:n,stats:re,projects:ie})]})}var Wi=[`bg-primary`,`bg-green`,`bg-violet`];function Gi(){let e=[`Set up project scaffolding with Vite + React + TypeScript`,`Build SQLite sync pipeline for session indexing`,`Implement real-time file watcher with debounce`,`Design project detail page with work timeline`,`Add full-text search across all sessions`,`Fix subagent indexing — children were silently dropped`,`Add multi-agent orchestration visualization`,`Build guided onboarding flow with CLI aesthetics`,`Implement session archiving with hard links`,`Add Cursor workspace discovery and polling`,`Design growth chart with cumulative LOC tracking`,`Build publish flow with streaming SSE upload`,`Add Ed25519 session sealing for interviews`,`Implement project-level AI enhancement pipeline`,`Fix work timeline SVG rendering for long sessions`,`Add context export in compact/summary/full formats`],t=[`TypeScript`,`React`,`SQLite`,`Node.js`,`CSS`,`Vite`,`Shell`,`Vitest`],n=[`claude`,`claude`,`claude`,`cursor`,`claude`,`codex`],r=new Date(`2026-02-15T10:00:00Z`),i=[];for(let a=0;a<e.length;a++){let o=new Date(r.getTime()+a*2.5*864e5+Math.random()*432e5),s=15+Math.floor(Math.random()*120),c=new Date(o.getTime()+s*6e4),l=Math.floor(200+Math.random()*5e3),u=Math.floor(50+Math.random()*l*.3),d=a%4==0?[{sessionId:`child-${a}-1`,role:`frontend-dev`,durationMinutes:Math.floor(s*.6),linesOfCode:Math.floor(l*.3),date:o.toISOString()},{sessionId:`child-${a}-2`,role:`qa-engineer`,durationMinutes:Math.floor(s*.4),linesOfCode:Math.floor(l*.15),date:o.toISOString()}]:a%3==0?[{sessionId:`child-${a}-1`,role:`backend-dev`,durationMinutes:Math.floor(s*.7),linesOfCode:Math.floor(l*.4),date:o.toISOString()}]:void 0;i.push({id:`mock-session-${a}`,title:e[a],date:o.toISOString(),endTime:c.toISOString(),durationMinutes:s,wallClockMinutes:s+Math.floor(Math.random()*30),turns:10+Math.floor(Math.random()*60),linesOfCode:l+u,status:`draft`,projectName:`heyi-am`,rawLog:[],skills:[t[a%t.length],t[(a+3)%t.length]],source:n[a%n.length],filesChanged:[[`src/sync.ts`,`src/db.ts`,`src/parsers/index.ts`,`src/server.ts`,`src/bridge.ts`],[`src/analyzer.ts`,`src/search.ts`,`src/settings.ts`,`src/export.ts`],[`app/src/components/ProjectDetail.tsx`,`app/src/components/WorkTimeline.tsx`,`app/src/api.ts`],[`src/routes/projects.ts`,`src/routes/sessions.ts`,`src/routes/dashboard.ts`,`app/src/types.ts`],[`src/parsers/claude.ts`,`src/parsers/cursor.ts`,`src/parsers/codex.ts`,`src/parsers/gemini.ts`],[`app/src/components/FirstRun.tsx`,`app/src/index.css`,`src/routes/export.ts`],[`src/archive.ts`,`src/context-export.ts`,`app/src/components/Search.tsx`],[`app/src/components/GrowthChart.tsx`,`app/src/components/SessionView.tsx`,`src/transcript.ts`]][a%8].map((e,t)=>({path:e,additions:Math.floor(l/(t+1.5)),deletions:Math.floor(u/(t+2))})),toolBreakdown:[{tool:`Read`,count:15+Math.floor(Math.random()*30)},{tool:`Edit`,count:8+Math.floor(Math.random()*25)},{tool:`Bash`,count:5+Math.floor(Math.random()*20)},{tool:`Write`,count:2+Math.floor(Math.random()*10)},{tool:`Grep`,count:3+Math.floor(Math.random()*8)},{tool:`Glob`,count:1+Math.floor(Math.random()*5)}],children:d,childCount:d?.length??0,isOrchestrated:!!d})}return i}var Ki=Gi();function qi({enhanced:e,onScrollSection:t,selectedSession:n,onSelectSession:r}){let i=(0,_.useRef)([]);(0,_.useEffect)(()=>{let e=[];return i.current.forEach((n,r)=>{if(!n)return;let i=new IntersectionObserver(([e])=>{e.isIntersecting&&t(r)},{threshold:.3});i.observe(n),e.push(i)}),()=>e.forEach(e=>e.disconnect())},[t]);let a=Ki.reduce((e,t)=>e+t.linesOfCode,0);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Xi,{url:`localhost:17845/project/heyi-am`,children:(0,F.jsxs)(`div`,{className:`bg-surface-mid`,children:[(0,F.jsxs)(`div`,{ref:e=>{i.current[0]=e},className:`p-5 pb-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`font-display text-xl font-bold text-on-surface`,children:`heyi-am`}),(0,F.jsx)(`span`,{className:`text-on-surface-variant text-[0.8125rem]`,children:`Feb 15 – Mar 25, 2026`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(I,{variant:e?`green`:`primary`,children:e?`Enhanced`:`Draft`}),(0,F.jsx)(I,{variant:`primary`,children:`16 sessions`})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-1 mb-2`,children:[(0,F.jsxs)(`a`,{href:`https://heyi.am`,target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-xs text-primary hover:underline flex items-center gap-1`,children:[(0,F.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 16 16`,fill:`currentColor`,children:(0,F.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z`})}),`github.com/interactivecats/heyi.am`]}),(0,F.jsxs)(`a`,{href:`https://heyi.am`,target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-xs text-primary hover:underline flex items-center gap-1`,children:[(0,F.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,F.jsx)(`path`,{d:`M6.5 10.5l3-3m-1.5-2a2.5 2.5 0 013.54 3.54l-1.5 1.5m-4.08-1.08a2.5 2.5 0 01-3.54-3.54l1.5-1.5`})}),`heyi.am`]})]}),(0,F.jsxs)(`div`,{className:`rounded-md border border-ghost overflow-hidden shadow-sm mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2 bg-surface-low border-b border-ghost`,children:[(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#ff5f57]`}),(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#febc2e]`}),(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#28c840]`})]}),(0,F.jsx)(`div`,{className:`max-h-96 overflow-y-auto`,children:(0,F.jsx)(`img`,{src:`/heyi-am-screenshot.png`,alt:`heyi.am — proof-of-work for AI-native developers`,className:`w-full h-auto`})})]}),e&&(0,F.jsxs)(L,{className:`my-3`,children:[(0,F.jsx)(z,{title:`Narrative summary`,meta:`AI-generated`}),(0,F.jsx)(`p`,{className:`leading-relaxed text-on-surface border-l-[3px] border-primary pl-3`,style:{fontSize:`clamp(0.8125rem, 1.2vw, 1rem)`},children:`Built a local-first developer portfolio tool that indexes AI coding sessions across Claude Code, Cursor, Codex, and Gemini CLI. Designed a real-time sync pipeline with SQLite indexing, implemented multi-agent session visualization, and shipped a guided onboarding flow.`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-3 mb-4`,children:[(0,F.jsx)(Nr,{label:`Sessions`,value:16}),(0,F.jsx)(Nr,{label:`Human / Agents`,value:`52h / 78h`}),(0,F.jsx)(Nr,{label:`Lines changed`,value:Hi(a)}),(0,F.jsx)(Nr,{label:`Files`,value:847})]})]}),e&&(0,F.jsx)(`div`,{className:`px-5 pb-4`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Project arc`,meta:`AI-generated`}),(0,F.jsxs)(`div`,{className:`relative pl-5`,children:[(0,F.jsx)(`div`,{className:`absolute left-1 top-1.5 bottom-1.5 w-0.5 bg-ghost rounded-full`}),[{title:`Foundation`,desc:`Set up project scaffolding, parser pipeline, and SQLite schema`},{title:`Core features`,desc:`Built sync engine, search, work timeline, and growth chart`},{title:`Polish`,desc:`Onboarding flow, subagent visualization, export pipeline`}].map(e=>(0,F.jsxs)(`div`,{className:`relative pb-3 last:pb-0`,children:[(0,F.jsx)(`div`,{className:`absolute -left-5 top-1.5 w-2 h-2 rounded-full bg-primary shadow-[0_0_0_3px_rgba(8,68,113,0.1)]`}),(0,F.jsx)(`div`,{className:`font-mono text-[0.6875rem] uppercase tracking-wider text-on-surface-variant`,children:e.title}),(0,F.jsx)(R,{children:(0,F.jsx)(`span`,{className:`text-on-surface-variant`,children:e.desc})})]},e.title))]})]})}),e&&(0,F.jsx)(`div`,{className:`px-5 pb-4`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Skills extracted`,meta:`14 skills`}),(0,F.jsx)(`div`,{className:`flex gap-1.5 flex-wrap`,children:[`TypeScript`,`React`,`SQLite`,`Node.js`,`CSS`,`Vite`,`Vitest`,`Shell`,`HTML`,`Express`,`SSE`,`FTS5`,`Ed25519`,`Docker`].map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e))})]})}),(0,F.jsx)(`div`,{ref:e=>{i.current[1]=e},className:`px-5 pb-4`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Work timeline`,meta:`sessions over time`}),(0,F.jsx)(Ei,{sessions:Ki,maxHeight:280})]})}),(0,F.jsx)(`div`,{ref:e=>{i.current[2]=e},className:`px-5 pb-4`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Project growth`,meta:`lines changed`}),(0,F.jsx)(zi,{sessions:Ki,totalLoc:a,totalFiles:847})]})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 px-5 pb-4`,children:[(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Key decisions`,meta:`signal`}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(R,{title:`SQLite over filesystem`,children:`Chose SQLite for session indexing over raw filesystem scans — 10x faster project listing.`}),(0,F.jsx)(R,{title:`Local-first architecture`,children:`All data stays on the user's machine. No cloud dependency for core features.`}),(0,F.jsx)(R,{title:`Multi-parser pipeline`,children:`One bridge layer normalizes data from Claude, Cursor, Codex, and Gemini into a shared schema.`})]}):(0,F.jsx)(R,{children:`Enhance this project to extract key decisions.`})})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Source breakdown`,meta:`provenance`}),(0,F.jsxs)(`table`,{className:`w-full border-collapse text-[0.8125rem]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Source`}),(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Count`})]})}),(0,F.jsx)(`tbody`,{children:[{source:`claude`,count:10},{source:`cursor`,count:3},{source:`codex`,count:2},{source:`gemini`,count:1}].map(e=>(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:e.source}),(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:e.count})]},e.source))})]})]})]}),(0,F.jsx)(`div`,{ref:e=>{i.current[3]=e},className:`px-5 pb-5`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:e?`Featured sessions`:`Sessions`,meta:`${Ki.length} total`}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:Ki.slice(0,6).map((e,t)=>(0,F.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`text-left bg-surface-lowest border border-ghost rounded-sm p-4 cursor-pointer transition-shadow hover:shadow-md`,children:[(0,F.jsx)(`div`,{className:`h-1 rounded-full mb-3 ${Wi[t%Wi.length]}`}),(0,F.jsx)(`h4`,{className:`font-display text-[0.8125rem] font-semibold text-on-surface mb-1 line-clamp-2`,children:e.title}),(0,F.jsxs)(`span`,{className:`text-on-surface-variant text-xs`,children:[Vi(e.durationMinutes),` · `,e.turns,` turns · `,Hi(e.linesOfCode),` lines`]}),e.skills?.[0]&&(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(I,{variant:`violet`,children:e.skills[0]})})]},e.id))})]})})]})}),n&&(0,F.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-black/40`,onClick:e=>{e.target===e.currentTarget&&r(null)},children:(0,F.jsx)(`div`,{className:`w-[600px] max-w-full h-full bg-surface overflow-y-auto shadow-[-8px_0_32px_rgba(25,28,30,0.1)] animate-[slideIn_0.3s_ease_forwards]`,children:(0,F.jsxs)(`div`,{className:`p-8`,children:[(0,F.jsx)(`div`,{className:`flex items-center gap-3 mb-6`,children:(0,F.jsx)(`button`,{type:`button`,onClick:()=>r(null),className:`font-mono text-[0.8125rem] text-on-surface-variant bg-surface-low border border-surface-high rounded-md px-3 py-1 cursor-pointer hover:text-on-surface`,children:`ESC · Close`})}),(0,F.jsx)(`h2`,{className:`font-display text-2xl font-bold text-on-surface mb-2`,children:n.title}),(0,F.jsxs)(`div`,{className:`font-mono text-[0.6875rem] uppercase tracking-wider text-on-surface-variant mb-4`,children:[new Date(n.date).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),n.source&&` · ${n.source}`]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-3 mb-5`,children:[(0,F.jsx)(Ji,{label:`Active Time`,value:Vi(n.durationMinutes),primary:!0}),(0,F.jsx)(Ji,{label:`Turns`,value:n.turns}),(0,F.jsx)(Ji,{label:`Files`,value:n.filesChanged?.length??`—`}),(0,F.jsx)(Ji,{label:`Lines changed`,value:Hi(n.linesOfCode)})]}),e&&(0,F.jsx)(`p`,{className:`text-[0.9375rem] leading-relaxed text-on-surface border-l-[3px] border-primary pl-3 mb-5`,children:`Implemented the core sync pipeline that discovers sessions from the filesystem, checks staleness against SQLite, and indexes new or changed sessions with full text search support.`}),n.skills&&n.skills.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-5`,children:n.skills.map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e))}),n.turns>=50&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsxs)(Yi,{children:[`Session Activity · `,n.turns,` turns over `,Vi(n.durationMinutes)]}),(0,F.jsx)(Ei,{sessions:[n],maxHeight:200})]}),(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(Yi,{children:`Execution Path`}),(e?[{n:1,title:`Read existing parsers and DB schema`,desc:`Analyzed the current session discovery pipeline and SQLite schema to understand the data flow`},{n:2,title:`Build staleness checker`,desc:`Compared file mtime/size against DB records to skip unchanged sessions`},{n:3,title:`Implement indexing loop`,desc:`Parse → bridge → analyze → upsert for each stale session, with progress reporting`}]:(()=>{let e=n.filesChanged??[],t=[],r=Math.max(1,Math.ceil(e.length/3));for(let n=0;n<e.length;n+=r){let i=e.slice(n,n+r);t.push({n:t.length+1,title:`Modified ${i.map(e=>e.path.split(`/`).pop()).join(`, `)}`,desc:``})}return t.length>0?t:[{n:1,title:`Modified multiple files`,desc:``}]})()).map(e=>(0,F.jsxs)(`div`,{className:`flex gap-3 items-start py-2.5 border-b border-ghost last:border-b-0`,children:[(0,F.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-primary text-white font-mono text-[0.625rem] font-bold flex items-center justify-center flex-shrink-0`,children:e.n}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`font-semibold text-sm text-on-surface mb-0.5`,children:e.title}),e.desc&&(0,F.jsx)(`div`,{className:`text-[0.8125rem] text-on-surface-variant leading-relaxed`,children:e.desc})]})]},e.n))]}),n.toolBreakdown&&n.toolBreakdown.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(Yi,{children:`Tool Usage`}),n.toolBreakdown.map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between items-center py-1.5 border-b border-ghost last:border-b-0 font-mono text-xs`,children:[(0,F.jsx)(`span`,{className:`text-on-surface`,children:e.tool}),(0,F.jsx)(`span`,{className:`text-on-surface-variant`,children:e.count})]},e.tool))]}),n.filesChanged&&n.filesChanged.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(Yi,{children:`Top Files`}),n.filesChanged.slice(0,10).map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between items-center py-1.5 border-b border-ghost last:border-b-0 font-mono text-xs`,children:[(0,F.jsx)(`span`,{className:`text-on-surface truncate min-w-0`,children:e.path}),(0,F.jsxs)(`span`,{className:`flex-shrink-0 ml-2 whitespace-nowrap`,children:[(0,F.jsxs)(`span`,{className:`text-green-600 font-semibold`,children:[`+`,e.additions]}),(0,F.jsxs)(`span`,{className:`text-red-600 font-semibold ml-1`,children:[`-`,e.deletions]})]})]},e.path))]})]})})})]})}function Ji({label:e,value:t,primary:n}){return(0,F.jsxs)(`div`,{className:`text-center p-3 border border-ghost rounded-sm bg-surface-lowest`,children:[(0,F.jsx)(`div`,{className:`font-mono text-xl font-bold ${n?`text-primary`:`text-on-surface`}`,children:t}),(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-on-surface-variant mt-1`,children:e})]})}function Yi({children:e}){return(0,F.jsx)(`div`,{className:`font-mono text-[0.625rem] font-semibold uppercase tracking-wider text-on-surface-variant mb-2.5`,children:e})}function Xi({url:e,children:t}){return(0,F.jsxs)(`div`,{className:`rounded-lg border border-[#d1d5db] bg-white shadow-xl overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-[#f1f3f5] border-b border-[#d1d5db]`,children:[(0,F.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-[10px] h-[10px] rounded-full bg-[#ff5f57]`}),(0,F.jsx)(`div`,{className:`w-[10px] h-[10px] rounded-full bg-[#febc2e]`}),(0,F.jsx)(`div`,{className:`w-[10px] h-[10px] rounded-full bg-[#28c840]`})]}),(0,F.jsx)(`div`,{className:`flex-1 mx-2`,children:(0,F.jsx)(`div`,{className:`bg-white rounded-md border border-[#d1d5db] px-3 py-1 text-[10px] text-[#6b7280] font-mono`,children:e})})]}),(0,F.jsx)(`div`,{className:`bg-[#f1f5f9] max-h-[70vh] overflow-y-auto`,children:t})]})}function Zi({children:e,compact:t}){let n=(0,_.useRef)(null);return(0,_.useEffect)(()=>{n.current?.scrollTo({top:n.current.scrollHeight})}),(0,F.jsxs)(`div`,{className:`triage-terminal`,style:{maxWidth:t?340:680,margin:`0 auto`,padding:t?`0.875rem 1rem 0.625rem`:`1.5rem 1.5rem 1rem`,fontSize:t?`0.6875rem`:`0.8125rem`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-3`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-[#ff5f57]`}),(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-[#febc2e]`}),(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-[#28c840]`})]}),(0,F.jsx)(`div`,{ref:n,className:`triage-terminal__feed`,children:e})]})}function U({variant:e,children:t}){return(0,F.jsx)(`div`,{className:`triage-terminal__line ${e===`prompt`?`triage-terminal__prompt`:e===`passed`?`triage-terminal__line--passed`:e===`active`?`triage-terminal__line--active`:e===`section`?`triage-terminal__section`:e===`reveal`?`triage-terminal__line--passed opacity-0 animate-[fadeIn_0.3s_ease_forwards]`:e===`info`?`opacity-80`:``}`,children:t})}function Qi({question:e,onYes:t,onNo:n,defaultNo:r,yesLabel:i,noLabel:a}){let o=(0,_.useRef)(null),[s,c]=(0,_.useState)(r?``:`Y`);return(0,_.useEffect)(()=>{let e=setTimeout(()=>o.current?.focus(),100);return()=>clearTimeout(e)},[]),(0,F.jsxs)(`div`,{className:`mt-1`,children:[(0,F.jsxs)(`div`,{className:`triage-terminal__line flex items-center gap-0 flex-wrap`,children:[(0,F.jsx)(`span`,{className:`text-[#9dcaff] font-semibold`,children:` > `}),(0,F.jsxs)(`span`,{children:[e,` `]}),(0,F.jsxs)(`span`,{className:`text-white/40`,children:[r?`[y/N]`:`[Y/n]`,` `]}),(0,F.jsx)(`input`,{ref:o,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let r=s.trim().toLowerCase();r===``||r===`y`||r===`yes`?t():n()}},className:`bg-transparent border-none outline-none text-[#34d399] font-mono w-12 caret-[#34d399]`,style:{fontSize:`inherit`,lineHeight:`inherit`,padding:0}})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 ml-4`,children:[(0,F.jsxs)(`button`,{onClick:t,className:`text-[10px] font-mono px-2.5 py-1 rounded bg-white/10 text-white/90 hover:bg-white/20 transition-colors`,children:[i??`Yes`,` `,(0,F.jsx)(`span`,{className:`text-white/30 ml-0.5`,children:`↵`})]}),(0,F.jsx)(`button`,{onClick:n,className:`text-[10px] font-mono px-2.5 py-1 rounded text-white/40 hover:text-white/70 transition-colors`,children:a??`No`})]})]})}function $i({dashboard:e,stats:t,projects:n}){let r=n.slice(0,4),i=t?.enhancedCount??0;return(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsx)(`h1`,{className:`font-display text-[1.75rem] leading-[1.1] font-bold text-on-surface`,children:`Turn your AI sessions into a dev portfolio.`}),t&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`h-6`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-4`,children:[(0,F.jsx)(ta,{label:`Sessions indexed`,value:t.sessionCount,to:`/archive`,color:`var(--primary)`}),(0,F.jsx)(ta,{label:`Projects`,value:t.projectCount,to:`/projects`}),(0,F.jsx)(ta,{label:`Enhanced`,value:i,to:`/projects`,color:i>0?`#34d399`:void 0}),(0,F.jsx)(ta,{label:`Sources`,value:t.sourceCount,to:`/sources`})]})]}),(0,F.jsx)(`div`,{className:`h-6`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,F.jsx)(P,{to:`/sources`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-4 py-2 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,children:`Sync new sessions`}),(0,F.jsx)(P,{to:`/projects`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-4 py-2 rounded-sm text-primary border border-ghost hover:border-outline transition-colors`,children:`View projects`}),(0,F.jsx)(P,{to:`/search`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-4 py-2 rounded-sm text-primary border border-ghost hover:border-outline transition-colors`,children:`Search sessions`}),e?.sync.status===`syncing`&&(0,F.jsxs)(`span`,{className:`text-xs text-on-surface-variant`,children:[`syncing `,e.sync.current,`/`,e.sync.total,e.sync.currentProject?` — ${e.sync.currentProject}`:``,`...`]})]}),(0,F.jsx)(`div`,{className:`h-10`}),r.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`flex items-baseline justify-between mb-3`,children:[(0,F.jsx)(`h2`,{className:`font-semibold text-sm text-on-surface`,children:`Recent projects`}),(0,F.jsx)(P,{to:`/projects`,className:`text-xs text-primary hover:underline`,children:`View all →`})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:r.map(e=>(0,F.jsx)(ea,{project:e},e.projectDir))}),(0,F.jsx)(`div`,{className:`h-10`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,F.jsx)(na,{to:`/archive`,label:`Archive`,title:`Back up sessions`,desc:`Import from local AI tools before they expire. Everything stays on your machine.`}),(0,F.jsx)(na,{to:`/projects`,label:`Build`,title:`AI case studies`,desc:`AI reads your sessions, extracts skills, and drafts a narrative for each project.`}),(0,F.jsx)(na,{to:`/search`,label:`Search`,title:`Find past work`,desc:`Full-text search across all sessions. Filter by tool, project, or skill.`}),(0,F.jsx)(na,{to:`/projects`,label:`Export`,title:`HTML, markdown, or publish`,desc:`Save locally, export markdown, or publish a public portfolio on heyi.am.`})]}),(0,F.jsx)(`div`,{className:`h-8`}),(0,F.jsxs)(`div`,{className:`border-t border-ghost pt-4 flex items-start gap-6 text-xs text-on-surface-variant`,children:[(0,F.jsx)(`span`,{children:`Everything is local by default.`}),(0,F.jsx)(`span`,{children:`Nothing is published unless you choose to.`}),(0,F.jsx)(`span`,{children:`No account required to archive or export.`})]})]})}function ea({project:e}){return(0,F.jsxs)(P,{to:`/project/${encodeURIComponent(e.projectDir)}`,className:`group block bg-white border border-ghost rounded-sm p-3.5 hover:border-outline transition-colors`,children:[(0,F.jsx)(`div`,{className:`font-semibold text-sm text-on-surface truncate`,children:e.projectName}),(0,F.jsxs)(`div`,{className:`text-xs text-on-surface-variant mt-0.5`,children:[e.sessionCount,` session`,e.sessionCount===1?``:`s`,e.enhancedAt&&(0,F.jsx)(`span`,{className:`ml-2`,style:{color:`#34d399`},children:`enhanced`})]}),e.skills.length>0&&(0,F.jsx)(`div`,{className:`flex gap-1 mt-2 flex-wrap`,children:e.skills.slice(0,3).map(e=>(0,F.jsx)(I,{children:e},e))})]})}function ta({label:e,value:t,to:n,color:r}){return(0,F.jsxs)(P,{to:n,className:`block bg-white border border-ghost rounded-sm px-4 py-3 hover:border-outline transition-colors`,children:[(0,F.jsx)(`div`,{className:`text-2xl font-bold`,style:r?{color:r}:{color:`var(--on-surface)`},children:t}),(0,F.jsx)(`div`,{className:`text-xs text-on-surface-variant mt-0.5`,children:e})]})}function na({to:e,label:t,title:n,desc:r}){return(0,F.jsxs)(P,{to:e,className:`group block bg-white border border-ghost rounded-sm p-4 hover:border-outline transition-colors`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-primary mb-1.5`,children:t}),(0,F.jsx)(`div`,{className:`font-semibold text-sm text-on-surface mb-1`,children:n}),(0,F.jsx)(`div`,{className:`text-xs text-on-surface-variant leading-relaxed`,children:r})]})}function ra(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!0),[i,a]=(0,_.useState)(!1);if((0,_.useEffect)(()=>{Zn().then(e=>{t(e.sources.map(e=>({tool:e.name,path:e.path+(e.dateRange?` · ${e.dateRange}`:``),live:e.liveCount,archived:e.archivedCount,chips:[{label:`${e.liveCount} live`,variant:`primary`},{label:`${e.archivedCount} archived`,variant:`green`},...e.retentionRisk?[{label:e.retentionRisk,variant:`amber`}]:[]],kpis:[{label:`Health`,value:e.health}]})))}).catch(()=>{a(!0)}).finally(()=>r(!1))},[]),n)return(0,F.jsx)(Ar,{back:{label:`Back`,to:`/`},chips:[{label:`Source audit`}],children:(0,F.jsx)(`div`,{className:`p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Scanning sources...`})})});if(i)return(0,F.jsx)(Ar,{back:{label:`Back`,to:`/`},chips:[{label:`Source audit`}],children:(0,F.jsx)(`div`,{className:`p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Scan failed. Could not load source data.`})})});let o=e.reduce((e,t)=>e+t.live,0),s=e.reduce((e,t)=>e+t.archived,0),c=e.some(e=>e.chips.some(e=>e.variant===`amber`));return(0,F.jsx)(Ar,{back:{label:`Back`,to:`/`},chips:[{label:`Source audit`}],actions:(0,F.jsx)(`button`,{className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm text-primary border border-ghost hover:border-outline transition-colors bg-transparent`,children:`Rescan all`}),children:(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between mb-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`font-display text-xl font-semibold text-on-surface`,children:`What we found, what we archived, and what we skipped`}),(0,F.jsx)(`p`,{className:`text-on-surface-variant text-sm mt-1`,children:`The ingestion layer should feel inspectable, not magical.`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,F.jsxs)(I,{variant:`green`,children:[s,` archived`]}),c&&(0,F.jsx)(I,{variant:`amber`,children:`Claude retention risk detected`})]})]}),(0,F.jsx)(`div`,{className:`h-4`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,F.jsx)(Nr,{label:`Sources scanned`,value:e.length}),(0,F.jsx)(Nr,{label:`Live sessions`,value:o}),(0,F.jsx)(Nr,{label:`Archived`,value:s})]}),(0,F.jsx)(`div`,{className:`h-5`}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map(e=>(0,F.jsxs)(L,{children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-display text-[0.9375rem] font-semibold text-on-surface`,children:e.tool}),(0,F.jsx)(`span`,{className:`font-mono text-xs text-outline`,children:e.path})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1`,children:e.chips.map(e=>(0,F.jsx)(I,{variant:e.variant,children:e.label},e.label))})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-4 text-[0.8125rem] text-on-surface-variant mt-2`,children:e.kpis.map(e=>(0,F.jsxs)(`span`,{children:[(0,F.jsxs)(`strong`,{className:`text-on-surface`,children:[e.label,`:`]}),` `,e.value]},e.label))})]},e.tool))}),(0,F.jsx)(`div`,{className:`h-5`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(P,{to:`/archive`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,children:`Review archive`}),(0,F.jsx)(P,{to:`/projects`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm text-primary border border-ghost hover:border-outline transition-colors`,children:`Continue to projects`}),(0,F.jsx)(`button`,{className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors bg-transparent border-none`,children:`Add custom path`})]})]})})}function ia(e){switch(e){case`healthy`:return{status:`healthy`,statusVariant:`green`};case`warning`:return{status:`partial`,statusVariant:`default`};case`error`:return{status:`filtered`,statusVariant:`violet`}}}function aa(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null);function x(){return Promise.all([Qn(),Zn()]).then(([e,n])=>{t({archived:e.total,oldest:e.oldest,sources:e.sourcesCount,lastSync:e.lastSync}),r(n.sources.map(e=>({source:e.name,archived:e.archivedCount,...ia(e.health)})))})}(0,_.useEffect)(()=>{x().catch(()=>s(!0)).finally(()=>a(!1))},[]);async function S(){l(!0),d(null);try{let e=await $n();e.archived===0?d(`Archive is up to date — no new sessions to sync.`):d(`Archived ${e.archived} new session${e.archived===1?``:`s`}.`),await x()}catch{d(`Sync failed. Check the console for details.`)}finally{l(!1)}}async function C(){p(!0),h(null);try{h(await tr())}catch{h({total:0,verified:0,missing:0,errors:[`Verification failed. Check the console for details.`]})}finally{p(!1)}}async function w(){v(!0),b(null);try{await er()}catch(e){b(e.message)}finally{v(!1)}}return i?(0,F.jsx)(Ar,{back:{label:`Sources`,to:`/sources`},chips:[{label:`Archive`}],children:(0,F.jsx)(`div`,{className:`p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading archive...`})})}):o||!e?(0,F.jsx)(Ar,{back:{label:`Sources`,to:`/sources`},chips:[{label:`Archive`}],children:(0,F.jsx)(`div`,{className:`p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Failed to load archive data.`})})}):(0,F.jsx)(Ar,{back:{label:`Sources`,to:`/sources`},chips:[{label:`Archive`}],actions:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`button`,{onClick:S,disabled:c,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm text-primary border border-ghost hover:border-outline transition-colors bg-transparent disabled:opacity-50 disabled:cursor-not-allowed`,children:c?`Syncing…`:`Archive now`}),(0,F.jsx)(`button`,{onClick:w,disabled:g,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm text-primary border border-ghost hover:border-outline transition-colors bg-transparent disabled:opacity-50 disabled:cursor-not-allowed`,children:g?`Exporting…`:`Export archive`})]}),children:(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between mb-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`font-display text-xl font-semibold text-on-surface`,children:`Your preserved AI work history`}),(0,F.jsx)(`p`,{className:`text-on-surface-variant text-sm mt-1`,children:`A durable library across tools, with clear ownership and visible coverage.`})]}),(0,F.jsx)(I,{variant:`green`,children:`under your control`})]}),(0,F.jsx)(`div`,{className:`h-4`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-3`,children:[(0,F.jsx)(Nr,{label:`Archived sessions`,value:e.archived}),(0,F.jsx)(Nr,{label:`Oldest saved`,value:e.oldest}),(0,F.jsx)(Nr,{label:`Sources covered`,value:e.sources}),(0,F.jsx)(Nr,{label:`Last sync`,value:e.lastSync})]}),u&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`h-3`}),(0,F.jsx)(R,{children:u})]}),y&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`h-3`}),(0,F.jsxs)(R,{children:[`Export failed: `,y]})]}),(0,F.jsx)(`div`,{className:`h-5`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,F.jsxs)(L,{className:`bg-white`,children:[(0,F.jsx)(z,{title:`By source`,meta:`coverage`}),(0,F.jsxs)(`table`,{className:`w-full border-collapse text-[0.8125rem]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Source`}),(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Archived`}),(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Status`})]})}),(0,F.jsx)(`tbody`,{children:n.map(e=>(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:e.source}),(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:e.archived}),(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:(0,F.jsx)(I,{variant:e.statusVariant,children:e.status})})]},e.source))})]})]}),(0,F.jsxs)(L,{className:`bg-white`,children:[(0,F.jsx)(z,{title:`Archive posture`,meta:`ops`}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n.some(e=>e.status===`partial`)&&(0,F.jsxs)(R,{children:[n.filter(e=>e.status===`partial`).length,` source`,n.filter(e=>e.status===`partial`).length===1?``:`s`,` with partial coverage — consider a manual sync.`]}),n.every(e=>e.status===`healthy`)&&n.length>0&&(0,F.jsx)(R,{children:`All sources healthy. Archive coverage is complete.`}),(0,F.jsx)(R,{children:(0,F.jsx)(`span`,{className:`font-mono text-xs`,children:`Archive path: ~/.config/heyiam/sessions/`})})]}),(0,F.jsx)(`div`,{className:`h-4`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(P,{to:`/projects`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,children:`Go to projects`}),(0,F.jsx)(`button`,{onClick:C,disabled:f,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm text-primary border border-ghost hover:border-outline transition-colors bg-transparent disabled:opacity-50 disabled:cursor-not-allowed`,children:f?`Verifying…`:`Verify integrity`})]}),m&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`h-3`}),m.missing===0&&m.errors.length===0?(0,F.jsxs)(R,{children:[`All `,m.verified,` archived file`,m.verified===1?``:`s`,` verified.`]}):(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsxs)(R,{children:[`Verified `,m.verified,`/`,m.total,` — `,m.missing,` missing.`]}),m.errors.map((e,t)=>(0,F.jsx)(`span`,{className:`text-xs text-on-surface-variant font-mono break-all`,children:e},t))]})]})]})]})]})})}function oa(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function sa(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ca(e){if(!e)return``;let[t,n]=e.split(`|`),r=e=>{try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,year:`numeric`})}catch{return``}},i=r(t),a=r(n);return i?i===a?i:`${i} — ${a}`:``}function la(e){let t=[];return e.enhancedAt&&t.push({variant:`refined`,label:`Refined`}),e.isUploaded?t.push({variant:`exported`,label:`Exported`}):t.push({variant:`local`,label:`Local only`}),t}function ua(){let[e,t]=(0,_.useState)([]),[n,r]=(0,_.useState)(!0),[i,a]=(0,_.useState)(``);(0,_.useEffect)(()=>{Jn().then(t).catch(()=>{}).finally(()=>r(!1))},[]);let o=i?e.filter(e=>{let t=i.toLowerCase();return e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.skills.some(e=>e.toLowerCase().includes(t))}):e;return(0,F.jsx)(Ar,{chips:[{label:`Projects`}],actions:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(P,{to:`/search`,className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors`,children:`Search`}),(0,F.jsx)(P,{to:`/archive`,className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors`,children:`Archive`}),(0,F.jsx)(P,{to:`/settings`,className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors`,children:`Settings`})]}),children:(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsx)(z,{title:`Your projects`,meta:`Local project memory built from both live and archived history.`,children:(0,F.jsx)(I,{variant:`green`,children:`Local-only is a complete state`})}),e.length>3&&(0,F.jsx)(`div`,{className:`mt-3`,children:(0,F.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Filter projects...`,className:`w-full max-w-sm bg-surface-low border border-ghost rounded-md font-mono text-xs text-on-surface placeholder:text-outline px-3 py-1.5 focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary/20`})}),(0,F.jsx)(`div`,{className:`h-4`}),n?(0,F.jsx)(`div`,{className:`text-sm text-on-surface-variant`,children:`Loading projects...`}):o.length===0?(0,F.jsx)(L,{children:(0,F.jsx)(`p`,{className:`text-sm text-on-surface-variant`,children:i?`No projects match your filter.`:`No projects found. Run a source scan to get started.`})}):(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:o.map(e=>(0,F.jsx)(P,{to:`/project/${encodeURIComponent(e.dirName)}`,className:`no-underline`,children:(0,F.jsxs)(L,{hover:!0,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-between mb-1`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`h3`,{className:`font-display text-[0.9375rem] font-semibold text-on-surface`,children:e.name}),la(e).map(e=>(0,F.jsx)(Mr,{variant:e.variant,children:e.label},e.label))]}),(0,F.jsx)(`p`,{className:`text-on-surface-variant text-sm mt-1`,children:e.description})]})}),(e.dateRange||e.skills.length>0)&&(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mt-2`,children:[e.dateRange&&(0,F.jsx)(`span`,{className:`font-mono text-[0.6875rem] text-outline`,children:ca(e.dateRange)}),e.skills.length>0&&(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[e.skills.slice(0,8).map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e)),e.skills.length>8&&(0,F.jsxs)(`span`,{className:`font-mono text-[10px] text-outline`,children:[`+`,e.skills.length-8]})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-3 mt-3`,children:[(0,F.jsx)(Nr,{label:`Sessions`,value:e.sessionCount,valueSize:`text-lg`}),(0,F.jsx)(Nr,{label:`Time`,value:oa(e.totalDuration),valueSize:`text-lg`}),(0,F.jsx)(Nr,{label:`Lines changed`,value:sa(e.totalLoc),valueSize:`text-lg`}),(0,F.jsx)(Nr,{label:`Files`,value:e.totalFiles,valueSize:`text-lg`})]})]})},e.dirName))})]})})}function da(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function fa(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function pa(e){try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}catch{return e}}function ma({session:e,projectDirName:t,onClose:n}){let[r,i]=(0,_.useState)(e),[a,o]=(0,_.useState)(!0),s=at();(0,_.useEffect)(()=>{Xn(t,e.id).then(e=>i(e)).catch(()=>{}).finally(()=>o(!1))},[t,e.id]);let c=(0,_.useCallback)(e=>{e.key===`Escape`&&n()},[n]);(0,_.useEffect)(()=>(document.addEventListener(`keydown`,c),()=>document.removeEventListener(`keydown`,c)),[c]);let l=r.children&&r.children.length>0;return(0,F.jsx)(`div`,{className:`fixed inset-0 z-50 flex justify-end bg-black/40`,onClick:e=>{e.target===e.currentTarget&&n()},children:(0,F.jsx)(`div`,{className:`w-[600px] max-w-full h-full bg-surface overflow-y-auto shadow-[-8px_0_32px_rgba(25,28,30,0.1)]`,children:(0,F.jsxs)(`div`,{className:`p-8`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:n,className:`font-mono text-[0.8125rem] text-on-surface-variant bg-surface-low border border-surface-high rounded-md px-3 py-1 cursor-pointer hover:text-on-surface`,children:`ESC · Close`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{n(),s(`/session/${encodeURIComponent(r.id)}`)},className:`font-mono text-[0.8125rem] text-primary bg-primary/5 border border-primary/20 rounded-md px-3 py-1 cursor-pointer hover:bg-primary/10 transition-colors`,children:`View full session →`})]}),(0,F.jsx)(`h2`,{className:`font-display text-2xl font-bold text-on-surface mb-2`,children:r.title}),(0,F.jsxs)(`div`,{className:`font-mono text-[0.6875rem] uppercase tracking-wider text-on-surface-variant mb-4`,children:[pa(r.date),r.source&&` · ${r.source}`,r.context&&` · ${r.context}`]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-4 gap-3 mb-5`,children:[(0,F.jsx)(ga,{label:`Active Time`,value:da(r.durationMinutes),primary:!0,children:l&&(0,F.jsx)(_a,{you:da(Math.max(0,r.durationMinutes-r.children.reduce((e,t)=>e+t.durationMinutes,0))),agent:da(r.children.reduce((e,t)=>e+t.durationMinutes,0))})}),(0,F.jsx)(ga,{label:`Turns`,value:r.turns,children:l&&(0,F.jsx)(_a,{you:`Human`,agent:`${r.childCount??r.children.length} agents`})}),(0,F.jsx)(ga,{label:`Files`,value:r.filesChanged?.length===1&&r.filesChanged[0]?.path===`(aggregate)`?`—`:r.filesChanged?.length??`—`}),(0,F.jsx)(ga,{label:`Lines changed`,value:fa(r.linesOfCode),children:l&&(0,F.jsx)(_a,{you:fa(Math.max(0,r.linesOfCode-r.children.reduce((e,t)=>e+t.linesOfCode,0))),agent:fa(r.children.reduce((e,t)=>e+t.linesOfCode,0))})})]}),r.developerTake&&(0,F.jsx)(`p`,{className:`text-[0.9375rem] leading-relaxed text-on-surface border-l-[3px] border-primary pl-3 mb-5`,children:r.developerTake}),r.skills&&r.skills.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-5`,children:r.skills.map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e))}),r.turns>=50&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsxs)(ha,{children:[`Session Activity · `,r.turns,` turns over `,da(r.durationMinutes)]}),(0,F.jsx)(Ei,{sessions:[r],maxHeight:200})]}),a&&(0,F.jsx)(`p`,{className:`text-sm text-on-surface-variant mb-4`,children:`Loading full session data...`}),r.executionPath&&r.executionPath.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(ha,{children:`Execution Path`}),r.executionPath.map(e=>(0,F.jsxs)(`div`,{className:`flex gap-3 items-start py-2.5 border-b border-ghost last:border-b-0`,children:[(0,F.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-primary text-white font-mono text-[0.625rem] font-bold flex items-center justify-center flex-shrink-0`,children:e.stepNumber}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`font-semibold text-sm text-on-surface mb-0.5`,children:e.title}),(0,F.jsx)(`div`,{className:`text-[0.8125rem] text-on-surface-variant leading-relaxed`,children:e.description})]})]},e.stepNumber))]}),r.toolBreakdown&&r.toolBreakdown.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(ha,{children:`Tool Usage`}),r.toolBreakdown.map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between items-center py-1.5 border-b border-ghost last:border-b-0 font-mono text-xs`,children:[(0,F.jsx)(`span`,{className:`text-on-surface truncate min-w-0`,children:e.tool}),(0,F.jsx)(`span`,{className:`text-on-surface-variant flex-shrink-0 ml-3`,children:e.count})]},e.tool))]}),r.filesChanged&&r.filesChanged.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(ha,{children:`Top Files`}),r.filesChanged.slice(0,10).map(e=>(0,F.jsxs)(`div`,{className:`flex justify-between items-center py-1.5 border-b border-ghost last:border-b-0 font-mono text-xs`,children:[(0,F.jsx)(`span`,{className:`text-on-surface truncate min-w-0`,children:e.path}),(0,F.jsxs)(`span`,{className:`flex-shrink-0 ml-2 whitespace-nowrap`,children:[(0,F.jsxs)(`span`,{className:`text-green-600 font-semibold`,children:[`+`,e.additions]}),(0,F.jsxs)(`span`,{className:`text-red-600 font-semibold ml-1`,children:[`-`,e.deletions]})]})]},e.path))]}),r.qaPairs&&r.qaPairs.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(ha,{children:`Questions & Answers`}),r.qaPairs.map((e,t)=>(0,F.jsxs)(`div`,{className:`py-3 border-b border-ghost last:border-b-0`,children:[(0,F.jsx)(`div`,{className:`font-semibold text-[0.9375rem] text-on-surface mb-2`,children:e.question}),(0,F.jsx)(`div`,{className:`text-sm text-on-surface-variant leading-relaxed`,children:e.answer})]},t))]})]})})})}function ha({children:e}){return(0,F.jsx)(`div`,{className:`font-mono text-[0.625rem] font-semibold uppercase tracking-wider text-on-surface-variant mb-2.5`,children:e})}function ga({label:e,value:t,primary:n,children:r}){return(0,F.jsxs)(`div`,{className:`text-center p-3 border border-ghost rounded-sm bg-surface-lowest`,children:[(0,F.jsx)(`div`,{className:`font-mono text-xl font-bold ${n?`text-primary`:`text-on-surface`}`,children:t}),(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-on-surface-variant mt-1`,children:e}),r]})}function _a({you:e,agent:t}){return(0,F.jsxs)(`div`,{className:`flex justify-center gap-2 mt-1 font-mono text-[9px] text-on-surface-variant`,children:[(0,F.jsx)(`span`,{className:`text-primary font-semibold`,children:e}),(0,F.jsx)(`span`,{className:`text-green font-semibold`,children:t})]})}function va(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function ya(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ba(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e)}function xa(e){try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}catch{return e}}function Sa(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/36e5);return n<1?`just now`:n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}var Ca=[`bg-primary`,`bg-green`,`bg-violet`];function wa({narrative:e,screenshotSrc:t,projectName:n,humanTime:r,agentTime:i,stats:a}){let o=i?parseFloat(i)/parseFloat(r):void 0,s=o&&o>1?`${o.toFixed(1)}x`:void 0;return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 mb-4`,children:[t&&(0,F.jsxs)(`div`,{className:`rounded-md border border-ghost overflow-hidden shadow-sm`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2 bg-surface-low border-b border-ghost`,children:[(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#ff5f57]`}),(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#febc2e]`}),(0,F.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-[#28c840]`})]}),(0,F.jsx)(`div`,{className:`max-h-96 overflow-y-auto`,children:(0,F.jsx)(`img`,{src:t,alt:`${n} screenshot`,className:`w-full h-auto`})})]}),e&&(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Narrative summary`,meta:`editable`}),(0,F.jsx)(`p`,{className:`leading-relaxed text-on-surface border-l-[3px] border-primary pl-3`,style:{fontSize:`clamp(0.8125rem, 1.2vw, 1rem)`},children:e})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-[1fr_2fr] gap-3`,children:[(0,F.jsxs)(`div`,{className:`bg-surface-lowest border border-ghost rounded-md p-4 flex flex-col justify-between`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-on-surface-variant mb-1`,children:i?`Human / Agents`:`Time`}),(0,F.jsx)(`div`,{className:`font-display font-bold text-on-surface text-2xl`,children:i?`${r} / ${i}`:r})]}),s&&(0,F.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-ghost`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-on-surface-variant mb-0.5`,children:`Efficiency multiplier`}),(0,F.jsx)(`div`,{className:`font-display font-bold text-on-surface text-lg`,children:s})]})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-2 gap-3`,children:a.map(e=>(0,F.jsx)(Nr,{label:e.label,value:e.value},e.label))})]})]})}function Ta(){let{dirName:e}=st(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(!1),b=(0,_.useRef)(null),x=(0,_.useRef)(null);(0,_.useEffect)(()=>{e&&(nr(e).then(e=>{n(e),e.enhanceCache?.title&&c(e.enhanceCache.title),e.enhanceCache?.repoUrl&&u(e.enhanceCache.repoUrl),e.enhanceCache?.projectUrl&&f(e.enhanceCache.projectUrl),e.enhanceCache?.screenshotBase64&&m(e.enhanceCache.screenshotBase64)}).catch(()=>{}).finally(()=>i(!1)),_r(e).then(({url:e})=>{e&&u(t=>t||(e.startsWith(`http`)?e:`https://${e}`))}).catch(()=>{}))},[e]);let S=(0,_.useCallback)(()=>{if(!e||!t)return;let n=t.enhanceCache;gr(e,n?.selectedSessionIds??[],n?.result??{narrative:``,arc:[],skills:[],timeline:[],questions:[]},{title:s||void 0,repoUrl:l||void 0,projectUrl:d||void 0,screenshotBase64:p??void 0}).then(()=>y(!1)).catch(()=>{})},[e,t,s,l,d,p]);if((0,_.useEffect)(()=>{if(v)return b.current&&clearTimeout(b.current),b.current=setTimeout(S,800),()=>{b.current&&clearTimeout(b.current)}},[v,S]),r)return(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading project...`})});if(!t)return(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Project not found.`})});let{project:C,sessions:w,enhanceCache:T}=t,E=T??null,D=E?.result?.narrative??C.description,O=E?.result?.arc??[],ee=[...new Set(w.map(e=>e.source??`unknown`))],k=E?.screenshotBase64?`data:image/png;base64,${E.screenshotBase64}`:void 0,A=[],te=new Set;if(E?.result?.timeline)for(let e of E.result.timeline)for(let t of e.sessions)t.featured&&(te.add(t.sessionId),t.tag?A.push({sessionId:t.sessionId,label:t.tag}):A.push({sessionId:t.sessionId,label:t.title.slice(0,18)}));let ne=(()=>{let e=w.filter(e=>te.has(e.id));if(e.length>=6)return e.slice(0,6);let t=w.filter(e=>e.status===`enhanced`||e.status===`uploaded`),n=w.filter(e=>e.status===`draft`&&!te.has(e.id)),r=[...e,...t.filter(e=>!te.has(e.id)).sort((e,t)=>t.linesOfCode-e.linesOfCode),...n],i=new Set;return r.filter(e=>i.has(e.id)?!1:(i.add(e.id),!0)).slice(0,6)})();return(0,F.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] min-h-[calc(100vh-48px)]`,children:[(0,F.jsxs)(`aside`,{className:`border-r border-ghost bg-surface-low p-4`,children:[(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-1.5`,children:`Source mix`}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:ee.map(e=>(0,F.jsx)(I,{children:e},e))})]}),(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-1.5`,children:`Status`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:[(0,F.jsx)(I,{variant:`primary`,children:C.enhancedAt?`Refined`:`Unrefined`}),(0,F.jsx)(I,{variant:`green`,children:C.isUploaded?`Uploaded`:`Local only`})]})]}),(0,F.jsx)(R,{children:`The local project page is the main object. Public pages are just one projection of it.`}),(0,F.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-ghost`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-3`,children:`Project links`}),(0,F.jsxs)(`label`,{className:`block mb-3`,children:[(0,F.jsx)(`span`,{className:`text-[0.75rem] font-medium text-on-surface-variant block mb-1`,children:`Repo URL`}),(0,F.jsx)(`input`,{type:`url`,value:l,onChange:e=>{u(e.target.value),y(!0)},placeholder:`https://github.com/...`,className:`w-full text-xs font-mono px-2 py-1.5 rounded-sm border border-ghost bg-surface-lowest text-on-surface placeholder:text-outline`})]}),(0,F.jsxs)(`label`,{className:`block mb-3`,children:[(0,F.jsx)(`span`,{className:`text-[0.75rem] font-medium text-on-surface-variant block mb-1`,children:`Project URL`}),(0,F.jsx)(`input`,{type:`url`,value:d,onChange:e=>{f(e.target.value),y(!0)},placeholder:`https://example.com`,className:`w-full text-xs font-mono px-2 py-1.5 rounded-sm border border-ghost bg-surface-lowest text-on-surface placeholder:text-outline`})]}),(0,F.jsxs)(`div`,{className:`mb-2`,children:[(0,F.jsx)(`span`,{className:`text-[0.75rem] font-medium text-on-surface-variant block mb-1`,children:`Screenshot`}),p?(0,F.jsxs)(`div`,{className:`relative rounded-sm overflow-hidden border border-ghost`,children:[(0,F.jsx)(`img`,{src:p.startsWith(`data:`)?p:`data:image/png;base64,${p}`,alt:`Project screenshot`,className:`w-full h-auto max-h-32 object-cover object-top`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{m(null),y(!0)},className:`absolute top-1 right-1 w-5 h-5 rounded-full bg-black/60 text-white text-[10px] flex items-center justify-center hover:bg-black/80`,children:`×`})]}):(0,F.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>x.current?.click(),className:`text-xs font-mono text-primary hover:underline text-left`,children:`Upload image...`}),d&&(0,F.jsx)(`button`,{type:`button`,onClick:async()=>{if(!e)return;g(!0);let t=C.name.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``);try{let n=await vr(e,t,d);n.ok&&n.preview&&(m(n.preview),y(!0))}catch{}finally{g(!1)}},disabled:h,className:`text-xs font-mono text-primary hover:underline text-left`,children:h?`Capturing...`:`Auto-capture from URL`})]}),(0,F.jsx)(`input`,{ref:x,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{m(n.result),y(!0)},n.readAsDataURL(t)}})]}),v&&(0,F.jsx)(`div`,{className:`text-[9px] font-mono text-outline mt-2`,children:`Saving...`})]})]}),(0,F.jsxs)(`main`,{className:`p-6 overflow-y-auto max-w-[1200px] mx-auto`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`input`,{type:`text`,value:s,placeholder:C.name,onChange:e=>{c(e.target.value),y(!0)},className:`font-display text-xl font-bold text-on-surface bg-transparent border-none outline-none w-full hover:bg-surface-low focus:bg-surface-low rounded px-1 -ml-1 transition-colors placeholder:text-on-surface-variant/50`}),(0,F.jsxs)(`span`,{className:`text-on-surface-variant text-[0.8125rem]`,children:[C.dateRange?typeof C.dateRange==`string`?C.dateRange:`${xa(C.dateRange.start)} – ${xa(C.dateRange.end)}`:``,C.enhancedAt&&` · last refined ${Sa(C.enhancedAt)}`]})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,F.jsxs)(I,{variant:`primary`,children:[C.sessionCount,` sessions`]})})]}),(l||d)&&(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-1 mb-1`,children:[l&&(0,F.jsxs)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-xs text-primary hover:underline flex items-center gap-1`,children:[(0,F.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 16 16`,fill:`currentColor`,children:(0,F.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z`})}),l.replace(/^https?:\/\/(www\.)?/,``).replace(/\.git$/,``)]}),d&&(0,F.jsxs)(`a`,{href:d,target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-xs text-primary hover:underline flex items-center gap-1`,children:[(0,F.jsx)(`svg`,{className:`w-3.5 h-3.5`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,F.jsx)(`path`,{d:`M6.5 10.5l3-3m-1.5-2a2.5 2.5 0 013.54 3.54l-1.5 1.5m-4.08-1.08a2.5 2.5 0 01-3.54-3.54l1.5-1.5`})}),d.replace(/^https?:\/\/(www\.)?/,``)]})]}),(0,F.jsx)(`div`,{className:`h-4`}),(0,F.jsx)(wa,{narrative:D,screenshotSrc:p?p.startsWith(`data:`)?p:`data:image/png;base64,${p}`:k,projectName:C.name,humanTime:va(C.totalDuration),agentTime:C.totalAgentDuration?va(C.totalAgentDuration):void 0,stats:[{label:`Sessions`,value:C.sessionCount},{label:`Lines changed`,value:ya(C.totalLoc)},{label:`Files`,value:C.totalFiles},...C.totalInputTokens||C.totalOutputTokens?[{label:`Tokens`,value:ba((C.totalInputTokens??0)+(C.totalOutputTokens??0))}]:[]]}),(0,F.jsxs)(L,{className:`mb-4`,children:[(0,F.jsx)(z,{title:`Work timeline`,meta:`sessions over time`}),(0,F.jsx)(Ei,{sessions:w,maxHeight:300})]}),(0,F.jsxs)(L,{className:`mb-4`,children:[(0,F.jsx)(z,{title:`Project growth`,meta:`lines changed`}),(0,F.jsx)(zi,{sessions:w,totalLoc:C.totalLoc,totalFiles:C.totalFiles,keyMoments:A})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 mb-4`,children:[(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Key decisions`,meta:`signal`}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:O.length>0?O.slice(0,3).map(e=>(0,F.jsx)(R,{title:e.title,children:e.description},e.phase)):(0,F.jsx)(R,{children:`Enhance this project to extract key decisions.`})})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Source breakdown`,meta:`provenance`}),(0,F.jsx)(Ea,{sessions:w})]})]}),O.length>0&&(0,F.jsxs)(L,{className:`mb-4`,children:[(0,F.jsx)(z,{title:`Project phases`,meta:`timeline`}),(0,F.jsxs)(`div`,{className:`relative pl-5`,children:[(0,F.jsx)(`div`,{className:`absolute left-1 top-1.5 bottom-1.5 w-0.5 bg-ghost rounded-full`}),O.map(e=>(0,F.jsxs)(`div`,{className:`relative pb-4 last:pb-0`,children:[(0,F.jsx)(`div`,{className:`absolute -left-5 top-1.5 w-2 h-2 rounded-full bg-primary shadow-[0_0_0_3px_rgba(8,68,113,0.1)]`}),(0,F.jsx)(`div`,{className:`font-mono text-[0.6875rem] uppercase tracking-wider text-on-surface-variant`,children:e.title}),(0,F.jsx)(R,{children:(0,F.jsx)(`span`,{className:`text-on-surface-variant`,children:e.description})})]},e.phase))]})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Featured sessions`,children:(0,F.jsxs)(P,{to:`/project/${encodeURIComponent(e??``)}/sessions`,className:`font-mono text-[11px] text-primary hover:underline`,children:[`All `,w.length,` sessions →`]})}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:ne.map((e,t)=>(0,F.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`text-left bg-surface-lowest border border-ghost rounded-sm p-4 cursor-pointer transition-shadow hover:shadow-md`,children:[(0,F.jsx)(`div`,{className:`h-1 rounded-full mb-3 ${Ca[t%Ca.length]}`}),(0,F.jsx)(`h4`,{className:`font-display text-[0.8125rem] font-semibold text-on-surface mb-1 line-clamp-2`,children:e.title}),(0,F.jsxs)(`span`,{className:`text-on-surface-variant text-xs`,children:[va(e.durationMinutes),` · `,e.turns,` turns · `,ya(e.linesOfCode),` lines`]}),e.skills?.[0]&&(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(I,{variant:`violet`,children:e.skills[0]})})]},e.id))})]})]}),a&&e&&(0,F.jsx)(ma,{session:a,projectDirName:e,onClose:()=>o(null)})]})}function Ea({sessions:e}){let t=e.reduce((e,t)=>(e[t.source??`unknown`]=(e[t.source??`unknown`]??0)+1,e),{});return(0,F.jsxs)(`table`,{className:`w-full border-collapse text-[0.8125rem]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Source`}),(0,F.jsx)(`th`,{className:`text-left py-2 font-mono text-[9px] uppercase tracking-wider text-outline border-b border-ghost`,children:`Count`})]})}),(0,F.jsx)(`tbody`,{children:Object.entries(t).map(([e,t])=>(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:e}),(0,F.jsx)(`td`,{className:`py-2 border-b border-ghost`,children:t})]},e))})]})}function Da(){let{dirName:e}=st(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(!1);(0,_.useEffect)(()=>{e&&Promise.all([rr(e).catch(()=>null),Yn(e).catch(()=>[])]).then(([e,t])=>{e&&n(e),i(t)}).finally(()=>o(!1))},[e]);let l=r.filter(e=>t?.selectedSessionIds?.includes(e.id)),u=t?.skippedSessions??[];async function d(){if(!(!e||!t)){c(!0);try{await ir(e,t)}catch{}finally{c(!1)}}}return a?(0,F.jsx)(Ar,{back:{label:e??`Project`,to:`/project/${encodeURIComponent(e??``)}`},chips:[{label:`Project boundaries`}],children:(0,F.jsx)(`div`,{className:`p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading boundaries...`})})}):(0,F.jsx)(Ar,{back:{label:e??`Project`,to:`/project/${encodeURIComponent(e??``)}`},chips:[{label:`Project boundaries`}],actions:(0,F.jsx)(`button`,{onClick:d,disabled:s,className:`bg-primary text-on-primary font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm hover:bg-primary-hover transition-colors disabled:opacity-50`,children:s?`Saving...`:`Save boundaries`}),children:(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsx)(`h2`,{className:`font-display text-xl font-bold text-on-surface`,children:`Shape what this project actually contains`}),(0,F.jsx)(`p`,{className:`text-on-surface-variant text-sm mt-1`,children:`Clustering gets you close. This screen makes it trustworthy.`}),(0,F.jsx)(`div`,{className:`h-4`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Included sessions`,meta:`${l.length} total`}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:l.length===0?(0,F.jsx)(R,{children:`No sessions included yet.`}):l.map(e=>(0,F.jsx)(R,{title:e.title,children:(0,F.jsxs)(`span`,{className:`font-mono text-xs text-on-surface-variant`,children:[e.source??`unknown`,` · `,e.filesChanged?.length??0,` files · `,e.linesOfCode,` lines`]})},e.id))})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Nearby / excluded`,meta:`needs review`}),(0,F.jsx)(`div`,{className:`flex flex-col gap-3`,children:u.length===0?(0,F.jsx)(R,{children:`No excluded sessions.`}):u.map(e=>(0,F.jsx)(R,{title:r.find(t=>t.id===e.sessionId)?.title??e.sessionId,children:(0,F.jsxs)(`span`,{className:`font-mono text-xs text-on-surface-variant`,children:[`excluded · `,e.reason]})},e.sessionId))})]})]})]})})}function Oa(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function ka(e){return e<1e3?String(e):`${(e/1e3).toFixed(1)}k`}function Aa(e){return e?new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`}):``}function ja(e){if(!e)return``;let[t,n]=e.split(`|`);if(!t||!n)return``;let r=new Date(t),i=new Date(n),a=e=>e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`}),o=i.getFullYear();return`${a(r)}\u2013${a(i)}, ${o}`}var Ma=[`overview`,`triage`,`enhance`,`questions`,`timeline`];function Na({current:e}){let t=Ma.indexOf(e);return(0,F.jsx)(`div`,{className:`phase-bar`,children:Ma.slice(0,-1).map((e,n)=>(0,F.jsx)(`div`,{className:`phase-bar__segment ${n<=t?`phase-bar__segment--active`:``}`},n))})}function Pa({project:e,sessions:t,onTriage:n,onCancel:r}){let i=[...t].sort((e,t)=>{let n=e.date?new Date(e.date).getTime():0;return(t.date?new Date(t.date).getTime():0)-n});return(0,F.jsxs)(`div`,{className:`upload-flow`,children:[(0,F.jsx)(`div`,{className:`upload-flow__label`,children:`Upload Project`}),(0,F.jsx)(`h2`,{className:`upload-flow__title`,children:e.name}),(0,F.jsx)(`div`,{className:`upload-flow__date`,children:ja(e.dateRange)}),(0,F.jsxs)(`p`,{className:`upload-flow__desc`,children:[`The AI will scan all `,e.sessionCount,` sessions, pick the ones worth showcasing, and build a project narrative. Small or trivial sessions are skipped automatically.`]}),(0,F.jsxs)(`div`,{className:`upload-flow__stat-grid`,children:[(0,F.jsx)(Fa,{label:`Sessions`,value:String(e.sessionCount)}),(0,F.jsx)(Fa,{label:e.totalAgentDuration?`Human / Agents`:`Total Time`,value:e.totalAgentDuration?`${Oa(e.totalDuration)} / ${Oa(e.totalAgentDuration)}`:Oa(e.totalDuration)}),(0,F.jsx)(Fa,{label:`Lines changed`,value:ka(e.totalLoc)}),(0,F.jsx)(Fa,{label:`Files`,value:String(e.totalFiles)})]}),(0,F.jsxs)(`div`,{className:`upload-flow__section-label`,children:[`All Sessions (`,t.length,`)`]}),(0,F.jsxs)(`div`,{className:`session-table`,children:[(0,F.jsxs)(`div`,{className:`session-table__header`,children:[(0,F.jsx)(`span`,{children:`Session`}),(0,F.jsx)(`span`,{style:{textAlign:`right`},children:`Date`}),(0,F.jsx)(`span`,{style:{textAlign:`right`},children:`Time`}),(0,F.jsx)(`span`,{style:{textAlign:`right`},children:`LOC`}),(0,F.jsx)(`span`,{style:{textAlign:`right`},children:`Turns`})]}),(0,F.jsx)(`div`,{className:`session-table__body`,children:i.map(e=>(0,F.jsxs)(`div`,{className:`session-table__row`,children:[(0,F.jsx)(`span`,{className:`session-table__name`,children:e.title}),(0,F.jsx)(`span`,{className:`session-table__cell`,children:Aa(e.date)}),(0,F.jsx)(`span`,{className:`session-table__cell`,children:Oa(e.durationMinutes)}),(0,F.jsx)(`span`,{className:`session-table__cell`,children:ka(e.linesOfCode)}),(0,F.jsx)(`span`,{className:`session-table__cell`,children:e.turns})]},e.id))})]}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:r,children:`Cancel`}),(0,F.jsxs)(`button`,{className:`btn btn--primary btn--large`,onClick:n,children:[e.sessionCount<5?`Enhance all ${e.sessionCount} sessions`:`Let AI pick sessions`,` →`]})]})]})}function Fa({label:e,value:t}){return(0,F.jsxs)(`div`,{className:`stat-card`,children:[(0,F.jsx)(`div`,{className:`stat-card__label`,children:e}),(0,F.jsx)(`div`,{className:`stat-card__value`,children:t})]})}var Ia=[`◐`,`◑`,`◒`,`◓`];function La(){let[e,t]=(0,_.useState)(0);return(0,_.useEffect)(()=>{let e=setInterval(()=>t(e=>(e+1)%Ia.length),120);return()=>clearInterval(e)},[]),Ia[e]}function Ra(e,t){let n=[{id:`prompt`,text:`$ heyiam triage`,variant:`prompt`}],r=0,i=0,a=0,o=!1,s=!1,c=!1;for(let l of e)switch(l.type){case`scanning`:r=l.total,n.push({id:`scanning`,text:` Loading session stats... (${l.total} sessions)`,variant:`active`});break;case`loading_stats`:l.index;break;case`hard_floor`:{if(!o){let e=n.findIndex(e=>e.id===`scanning`);e!==-1&&(n[e]={id:`scanning-done`,text:` \u2713 Loaded ${r} sessions`,variant:`passed`}),n.push({id:`hf-header`,text:``,variant:`default`}),n.push({id:`hf-section`,text:` ── Hard floor filter ──`,variant:`section`}),o=!0}let e=l.sessionId.slice(0,8);l.passed?(i++,n.push({id:`hf-${l.sessionId}`,text:` \u2713 ${l.title||e} \u2192 passed`,variant:`passed`})):(a++,n.push({id:`hf-${l.sessionId}`,text:` \u2717 ${l.title||e} \u2192 skipped${l.reason?` (${l.reason})`:``}`,variant:`skipped`}));break}case`extracting_signals`:{s||=(o&&n.push({id:`hf-summary`,text:` \u2713 ${i} passed, ${a} filtered`,variant:`passed`}),n.push({id:`sig-header`,text:``,variant:`default`}),n.push({id:`sig-section`,text:` ── Signal extraction ──`,variant:`section`}),!0);let e=l.sessionId.slice(0,8);n.push({id:`sig-${l.sessionId}`,text:` ${t} Scanning ${l.title||e}...`,variant:`active`});break}case`signals_done`:{let e=n.findIndex(e=>e.id===`sig-${l.sessionId}`);if(e!==-1){let t=l.sessionId.slice(0,8);n[e]={id:`sig-done-${l.sessionId}`,text:` \u2713 ${t}: signals extracted`,variant:`passed`}}break}case`llm_ranking`:c||=(n.push({id:`rank-header`,text:``,variant:`default`}),n.push({id:`rank-section`,text:` ── AI ranking ──`,variant:`section`}),!0),n.push({id:`llm-ranking`,text:` ${t} Sending ${l.sessionCount} sessions to AI...`,variant:`active`});break;case`scoring_fallback`:c||=(n.push({id:`rank-header`,text:``,variant:`default`}),n.push({id:`rank-section`,text:` ── Scoring ──`,variant:`section`}),!0),n.push({id:`scoring-fallback`,text:` ${t} Scoring ${l.sessionCount} sessions...`,variant:`active`});break;case`done`:let e=n.findIndex(e=>e.id===`llm-ranking`||e.id===`scoring-fallback`);e!==-1&&(n[e]={id:`rank-done`,text:` \u2713 AI selected ${l.selected} sessions`,variant:`passed`});break;case`result`:break}return n}function za({events:e,dirName:t}){let n=La(),r=(0,_.useRef)(null),i=Ra(e,n);return(0,_.useEffect)(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[i.length]),(0,F.jsx)(`div`,{className:`triage-terminal`,role:`log`,"aria-live":`polite`,"aria-label":`Triage progress`,children:(0,F.jsx)(`div`,{className:`triage-terminal__feed`,ref:r,children:i.map(e=>(0,F.jsx)(`div`,{className:`triage-terminal__line${e.variant===`prompt`?` triage-terminal__prompt`:e.variant===`section`?` triage-terminal__section`:e.variant===`passed`?` triage-terminal__line--passed`:e.variant===`skipped`?` triage-terminal__line--skipped`:e.variant===`active`?` triage-terminal__line--active`:``}`,children:e.text},e.id))})})}function Ba({sessionId:e,title:t,stats:n,reason:r,variant:i,checked:a,onToggle:o,dimTitle:s,previouslyUploaded:c}){let[l,u]=(0,_.useState)(!1),d=r.length>(i===`selected`?60:40),f=i===`selected`?r.length>60?r.slice(0,57)+`...`:r:r.length>40?r.slice(0,37)+`...`:r;return(0,F.jsxs)(`div`,{className:`triage-item ${a?`triage-item--selected`:`triage-item--skipped`}`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:a,onChange:o,className:`triage-item__checkbox`}),(0,F.jsxs)(`div`,{className:`triage-item__info`,children:[(0,F.jsxs)(`div`,{className:`triage-item__name`,style:s?{color:`var(--on-surface-variant)`}:void 0,children:[t,c&&(0,F.jsx)(`span`,{className:`triage-item__uploaded-badge`,children:`previously uploaded`})]}),(0,F.jsx)(`div`,{className:`triage-item__stats`,children:n})]}),(0,F.jsx)(`div`,{className:`triage-item__reason triage-item__reason--${i} ${d?`triage-item__reason--expandable`:``}`,onClick:d?()=>u(!l):void 0,role:d?`button`:void 0,tabIndex:d?0:void 0,onKeyDown:d?e=>{e.key===`Enter`&&u(!l)}:void 0,children:l?r:f})]})}function Va({project:e,sessions:t,triageResult:n,selectedIds:r,onToggle:i,onEnhance:a,onBack:o,uploadedSessionIds:s}){let c=new Map(t.map(e=>[e.id,e])),l=r.size,u=t.length-l;return(0,F.jsxs)(`div`,{className:`upload-flow`,children:[(0,F.jsx)(Na,{current:`triage`}),(0,F.jsxs)(`div`,{className:`upload-flow__scan-status`,children:[`✓ Scanned `,t.length,` sessions · `,Oa(e.totalDuration),` · `,ka(e.totalLoc),` lines`]}),(0,F.jsxs)(`h2`,{className:`upload-flow__title`,children:[`AI selected `,l,` sessions to showcase`]}),(0,F.jsxs)(`p`,{className:`upload-flow__desc`,children:[`Skipped `,u,` sessions that were too small, purely mechanical, or redundant. You can override any selection.`]}),n.triageMethod===`scoring`&&(0,F.jsxs)(`div`,{className:`triage-method-banner`,children:[(0,F.jsx)(`span`,{className:`triage-method-banner__icon`,"aria-hidden":`true`,children:`ⓘ`}),(0,F.jsx)(`span`,{children:`Sessions selected by signal analysis (no API key configured). `}),(0,F.jsx)(`a`,{href:`/settings`,className:`triage-method-banner__link`,children:`Go to Settings`})]}),(0,F.jsxs)(`div`,{className:`upload-flow__section-label upload-flow__section-label--selected`,children:[`✓ Selected for showcase (`,l,`)`]}),(0,F.jsx)(`div`,{className:`triage-list`,children:n.selected.map(e=>{let t=c.get(e.sessionId),n=r.has(e.sessionId);return(0,F.jsx)(Ba,{sessionId:e.sessionId,title:t?.title??e.sessionId,stats:t?`${Oa(t.durationMinutes)} \u00b7 ${ka(t.linesOfCode)} lines \u00b7 ${t.turns} turns`:``,reason:e.reason,variant:`selected`,checked:n,onToggle:()=>i(e.sessionId),previouslyUploaded:s?.has(e.sessionId)},e.sessionId)})}),(0,F.jsxs)(`details`,{className:`triage-skipped`,children:[(0,F.jsxs)(`summary`,{className:`triage-skipped__summary`,children:[(0,F.jsx)(`span`,{children:`▶`}),` Skipped (`,n.skipped.length,`) — click to override`]}),(0,F.jsx)(`div`,{className:`triage-list`,style:{marginTop:`var(--spacing-3)`},children:n.skipped.map(e=>{let t=c.get(e.sessionId),n=r.has(e.sessionId);return(0,F.jsx)(Ba,{sessionId:e.sessionId,title:t?.title??e.sessionId,stats:t?`${Oa(t.durationMinutes)} \u00b7 ${ka(t.linesOfCode)} lines \u00b7 ${t.turns} turns`:``,reason:e.reason,variant:`skipped`,checked:n,onToggle:()=>i(e.sessionId),dimTitle:!n,previouslyUploaded:s?.has(e.sessionId)},e.sessionId)})})]}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:o,children:`Back`}),(0,F.jsx)(`button`,{className:`btn btn--primary btn--large`,onClick:a,disabled:l===0,children:`Enhance project →`})]})]})}function Ha({project:e,sessions:t,selectedIds:n,triageResult:r,onComplete:i,onBack:a}){let o=new Map(t.map(e=>[e.id,e])),[s,c]=(0,_.useState)(()=>{let e=r.selected.filter(e=>n.has(e.sessionId)),t=r.skipped.filter(e=>n.has(e.sessionId));return[...e,...t].map(e=>({sessionId:e.sessionId,title:o.get(e.sessionId)?.title??e.sessionId,status:`pending`}))}),[l,u]=(0,_.useState)(`waiting`),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),w=(0,_.useRef)(null),T=(0,_.useRef)(null),E=(0,_.useCallback)(t=>{if(!e.dirName)return;t&&(x(null),f(null),u(`waiting`),g(``),m([]),y(null),c(e=>e.map(e=>({...e,status:`pending`}))));let i=r.skipped.filter(e=>!n.has(e.sessionId)).map(e=>{let t=o.get(e.sessionId);return{title:t?.title??e.sessionId,duration:t?.durationMinutes??0,loc:t?.linesOfCode??0}}),a=or(e.dirName,Array.from(n),i,e=>{switch(e.type){case`session_progress`:c(t=>t.map(t=>t.sessionId===e.sessionId?{...t,status:e.status,title:e.title||t.title,detail:e.detail}:t)),(e.status===`done`||e.status===`skipped`)&&e.skills&&m(t=>{let n=new Set(t);for(let t of e.skills)n.add(t);return[...n]});break;case`project_enhance`:u(`generating`);break;case`narrative_chunk`:g(t=>t+e.text);break;case`cached`:x(e.enhancedAt),c(e=>e.map(e=>({...e,status:`done`}))),u(`done`);break;case`done`:u(`done`),f(e.result);break;case`error`:y(e.message);break}},t);return w.current=a,a},[e.dirName,n,r,o]);(0,_.useEffect)(()=>{let e=E(S);return()=>e?.abort()},[S]);let D=s.filter(e=>e.status!==`pending`).length;(0,_.useEffect)(()=>{if(!T.current||D===0)return;let e=T.current.querySelectorAll(`.enhance-feed-item:not(.enhance-feed-item--pending)`),t=e[e.length-1];t&&t.scrollIntoView({block:`nearest`,behavior:`smooth`})},[D]);let O=d!==null,ee=d?.skills??p,k=s.filter(e=>e.status===`failed`),A=s.filter(e=>e.status===`done`||e.status===`skipped`),te=s.every(e=>e.status!==`pending`&&e.status!==`enhancing`),ne=k.length>0,re=A.length>0,ie=(0,_.useCallback)(()=>{c(e=>e.map(e=>e.status===`failed`?{...e,status:`pending`,detail:void 0}:e)),y(null),w.current?.abort(),C(e=>!e)},[]),j=(0,_.useCallback)(()=>{i({narrative:``,arc:[],skills:p,timeline:[],questions:[]})},[p,i]);return(0,F.jsxs)(`div`,{className:`enhance-split`,children:[(0,F.jsxs)(`div`,{className:`enhance-split__left`,children:[(0,F.jsx)(`div`,{className:`enhance-split__left-header`,children:`Session Processing`}),(0,F.jsx)(`div`,{className:`enhance-split__feed`,ref:T,children:s.map(e=>(0,F.jsxs)(`div`,{className:`enhance-feed-item ${e.status===`pending`?`enhance-feed-item--pending`:``} ${e.status===`failed`?`enhance-feed-item--failed`:``}`,children:[(0,F.jsxs)(`div`,{className:`enhance-feed-item__row`,children:[e.status===`done`||e.status===`skipped`?(0,F.jsx)(`span`,{className:`enhance-feed-item__check`,children:`✓`}):e.status===`failed`?(0,F.jsx)(`span`,{className:`enhance-feed-item__fail`,children:`✗`}):e.status===`enhancing`?(0,F.jsx)(`span`,{className:`enhance-feed-item__spinner`}):(0,F.jsx)(`span`,{className:`enhance-feed-item__circle`,children:`◯`}),(0,F.jsx)(`span`,{className:`enhance-feed-item__title ${e.status===`enhancing`?`enhance-feed-item__title--active`:``} ${e.status===`failed`?`enhance-feed-item__title--failed`:``}`,children:e.title})]}),e.detail&&e.status!==`pending`&&(0,F.jsx)(`div`,{className:`enhance-feed-item__detail ${e.status===`failed`?`enhance-feed-item__detail--failed`:``}`,children:e.detail})]},e.sessionId))}),(0,F.jsxs)(`div`,{className:`enhance-split__narrative-box`,children:[(0,F.jsx)(`div`,{className:`enhance-split__narrative-label`,children:`PROJECT NARRATIVE`}),(0,F.jsx)(`div`,{className:`enhance-split__narrative-status`,children:b&&l===`done`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`enhance-feed-item__check`,children:`✓`}),(0,F.jsxs)(`span`,{children:[`Loaded from cache (`,new Date(b).toLocaleDateString(),`)`]})]}):l===`done`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`enhance-feed-item__check`,children:`✓`}),(0,F.jsx)(`span`,{children:`Project story complete`})]}):l===`generating`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`enhance-split__blink-dot`}),(0,F.jsxs)(`span`,{children:[`Building project story from `,n.size,` sessions...`]})]}):(0,F.jsx)(`span`,{children:`Waiting for session processing...`})})]})]}),(0,F.jsxs)(`div`,{className:`enhance-split__right`,children:[(0,F.jsx)(Na,{current:`enhance`}),v?(0,F.jsxs)(`div`,{className:`enhance-error`,style:{marginTop:`var(--spacing-4)`},children:[(0,F.jsx)(`div`,{className:`enhance-error__message`,children:v}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:a,children:`Back`}),(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:ie,children:`Retry`}),re&&(0,F.jsx)(`button`,{className:`btn btn--primary btn--large`,onClick:j,children:`Continue without narrative`})]})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`upload-flow__label`,children:`Project Story`}),(0,F.jsx)(`h2`,{className:`upload-flow__title`,children:e.name}),!h&&!d?.narrative&&(0,F.jsxs)(`div`,{className:`enhance-split__narrative-placeholder`,children:[(0,F.jsx)(`span`,{className:`enhance-split__blink-dot`}),(0,F.jsx)(`span`,{children:l===`generating`?`Writing project narrative...`:`Analyzing sessions — narrative will appear here...`})]}),(h||d?.narrative)&&(0,F.jsxs)(`div`,{className:`enhance-split__narrative-text`,children:[d?.narrative??h,l===`generating`&&(0,F.jsx)(`span`,{className:`typewriter-cursor`,"aria-hidden":`true`})]}),ee.length>0&&(0,F.jsx)(`div`,{className:`enhance-split__skills`,children:ee.map(e=>(0,F.jsx)(`span`,{className:`chip`,children:e},e))}),d?.arc&&d.arc.length>0&&(()=>{let e=d.arc;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`upload-flow__section-label`,style:{marginTop:`var(--spacing-6)`},children:`Project Arc`}),(0,F.jsx)(`div`,{className:`enhance-split__arc`,children:e.map((t,n)=>(0,F.jsxs)(`div`,{className:`enhance-split__arc-item ${!O&&n===e.length-1?`enhance-split__arc-item--generating`:``}`,children:[(0,F.jsx)(`div`,{className:`enhance-split__arc-num`,children:String(t.phase).padStart(2,`0`)}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`enhance-split__arc-title`,children:t.title}),(0,F.jsx)(`div`,{className:`enhance-split__arc-desc`,children:t.description})]})]},n))})]})})(),te&&ne&&!O&&(0,F.jsxs)(`div`,{className:`enhance-split__failure-recovery`,children:[(0,F.jsxs)(`p`,{className:`enhance-split__failure-text`,children:[k.length,` session`,k.length===1?``:`s`,` failed to enhance.`]}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:ie,children:`Retry failed`}),re&&(0,F.jsxs)(`button`,{className:`btn btn--primary btn--large`,onClick:j,children:[`Continue with `,A.length,` successful →`]})]})]}),O&&(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[b&&(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:()=>{w.current?.abort(),C(!0)},children:`Re-enhance`}),(0,F.jsxs)(`button`,{className:`btn btn--primary btn--large`,onClick:()=>i(d),children:[d.questions.length>0?`Answer a few questions`:`Continue`,` →`]})]})]})]})]})}var Ua={pattern:`Pattern detected`,architecture:`Architecture`,evolution:`Evolution`};function Wa({enhanceResult:e,onSkip:t,onWeave:n}){let[r,i]=(0,_.useState)(new Map),[a,o]=(0,_.useState)(!1),s=(0,_.useCallback)((e,t)=>{i(n=>{let r=new Map(n);return r.set(e,t),r})},[]),c=Array.from(r.values()).some(e=>e.trim().length>0),l=(0,_.useCallback)(()=>{let t=e.questions.filter(e=>(r.get(e.id)??``).trim().length>0).map(e=>({questionId:e.id,question:e.question,answer:r.get(e.id).trim()}));o(!0),n(t)},[r,e.questions,n]);return(0,F.jsxs)(`div`,{className:`upload-flow`,children:[(0,F.jsx)(Na,{current:`questions`}),(0,F.jsxs)(`div`,{className:`upload-flow__scan-status`,children:[`✓ `,e.timeline.reduce((e,t)=>e+t.sessions.length,0),` sessions enhanced · Project narrative generated`]}),(0,F.jsx)(`h2`,{className:`upload-flow__title`,children:`A few things we noticed`}),(0,F.jsx)(`p`,{className:`upload-flow__desc`,children:`Your answers get woven into the narrative. Skip any you don't want to answer.`}),(0,F.jsx)(`div`,{className:`questions-list`,children:e.questions.map(e=>(0,F.jsxs)(`div`,{className:`question-card`,children:[(0,F.jsx)(`div`,{className:`question-card__tag-row`,children:(0,F.jsx)(`span`,{className:`question-card__tag question-card__tag--${e.category}`,children:Ua[e.category]??e.category})}),(0,F.jsx)(`div`,{className:`question-card__text`,children:e.question}),(0,F.jsx)(`textarea`,{className:`question-card__textarea`,value:r.get(e.id)??``,onChange:t=>s(e.id,t.target.value),placeholder:e.context||``,rows:3})]},e.id))}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:t,disabled:a,children:`Skip questions`}),(0,F.jsx)(`button`,{className:`btn btn--primary btn--large`,onClick:l,disabled:!c||a,children:a?`Weaving...`:`Weave into narrative →`})]})]})}function Ga({project:e,timeline:t,onBack:n,onViewProject:r}){let i=t.reduce((e,t)=>e+t.sessions.length,0);return(0,F.jsxs)(`div`,{className:`upload-flow`,children:[(0,F.jsx)(Na,{current:`timeline`}),(0,F.jsx)(`div`,{className:`upload-flow__label`,children:`Project Timeline`}),(0,F.jsxs)(`h2`,{className:`upload-flow__title`,children:[e.name,` `,(0,F.jsxs)(`span`,{style:{fontWeight:400,fontSize:`1rem`,color:`var(--on-surface-variant)`},children:[i,` sessions`]})]}),(0,F.jsx)(`p`,{className:`upload-flow__desc`,children:e.description}),(0,F.jsxs)(`div`,{className:`timeline`,children:[(0,F.jsx)(`div`,{className:`timeline__line`}),t.map((e,t)=>{let n=e.sessions.filter(e=>e.featured),r=e.sessions.filter(e=>!e.featured);return(0,F.jsxs)(`div`,{className:`timeline__period`,children:[(0,F.jsxs)(`div`,{className:`timeline__period-header`,children:[(0,F.jsx)(`span`,{className:`timeline__period-date`,children:e.period}),(0,F.jsx)(`span`,{className:`timeline__period-sep`,children:`—`}),(0,F.jsx)(`span`,{className:`timeline__period-label`,children:e.label})]}),n.map(e=>(0,F.jsxs)(`div`,{className:`timeline__featured`,children:[(0,F.jsx)(`div`,{className:`timeline__dot--large`}),(0,F.jsxs)(`div`,{className:`timeline__card`,children:[(0,F.jsxs)(`div`,{className:`timeline__card-header`,children:[(0,F.jsx)(`span`,{className:`timeline__card-title`,children:e.title}),e.tag&&(0,F.jsx)(`span`,{className:`timeline__card-tag`,children:e.tag})]}),(0,F.jsxs)(`div`,{className:`timeline__card-meta`,children:[(0,F.jsx)(`span`,{children:Oa(e.duration)}),e.date&&(0,F.jsx)(`span`,{children:Aa(e.date)})]}),e.description&&(0,F.jsx)(`p`,{className:`timeline__card-desc`,children:e.description}),e.skills&&e.skills.length>0&&(0,F.jsx)(`div`,{className:`timeline__card-skills`,children:e.skills.map(e=>(0,F.jsx)(`span`,{className:`chip`,children:e},e))})]})]},e.sessionId)),r.length>0&&(0,F.jsxs)(`div`,{className:`timeline__collapsed`,children:[(0,F.jsx)(`div`,{className:`timeline__dot--small`}),(0,F.jsx)(Ka,{sessions:r})]})]},t)})]}),(0,F.jsxs)(`div`,{className:`upload-flow__actions`,children:[(0,F.jsx)(`button`,{className:`btn btn--secondary btn--large`,onClick:n,children:`Back`}),(0,F.jsx)(`button`,{className:`btn btn--primary btn--large`,onClick:r,children:`View updated project →`})]})]})}function Ka({sessions:e}){let t=e.map(e=>e.title.toLowerCase()).join(`, `),n=e.filter(e=>e.date).map(e=>e.date).sort(),r=n.length>=2?`${Aa(n[0])} \u2013 ${Aa(n[n.length-1])}`:n.length===1?Aa(n[0]):``;return(0,F.jsxs)(`span`,{className:`timeline__collapsed-text`,children:[e.length,` smaller session`,e.length===1?``:`s`,` — `,t,r&&(0,F.jsxs)(F.Fragment,{children:[` · `,r]})]})}var qa=[{period:`Mar 3–7`,label:`Foundation`,sessions:[{sessionId:`placeholder-1`,title:`Project scaffolding & architecture`,description:`Set up the monorepo structure, CI pipeline, and core abstractions.`,duration:145,featured:!0,tag:`KEY DECISION`,skills:[`Architecture`,`CI/CD`],date:`2026-03-03`},{sessionId:`placeholder-2`,title:`Dependency setup`,duration:30,featured:!1,date:`2026-03-04`},{sessionId:`placeholder-3`,title:`Initial config`,duration:15,featured:!1,date:`2026-03-05`}]},{period:`Mar 10–14`,label:`Core Implementation`,sessions:[{sessionId:`placeholder-4`,title:`Data model & API design`,description:`Designed the schema and REST endpoints for the core domain.`,duration:210,featured:!0,skills:[`API Design`,`PostgreSQL`],date:`2026-03-10`},{sessionId:`placeholder-5`,title:`Frontend component library`,description:`Built reusable components following the design system.`,duration:180,featured:!0,skills:[`React`,`CSS`],date:`2026-03-12`}]}];function Ja(){let{dirName:e}=st(),[t,n]=Mn(),r=at(),[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!0);(0,_.useEffect)(()=>{Jn().then(a).catch(()=>{}).finally(()=>s(!1))},[]);let c=i.find(t=>t.dirName===e),[l,u]=(0,_.useState)(`overview`),d=(0,_.useCallback)(e=>{u(e),window.scrollTo(0,0)},[]),[f,p]=(0,_.useState)([]),[m,h]=(0,_.useState)(!0),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(new Set),[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)([]),[T,E]=(0,_.useState)(null),D=(0,_.useRef)(null),[O,ee]=(0,_.useState)(null),[k,A]=(0,_.useState)(null);k?.narrative,k?.skills;let te=k?.timeline??[],ne=(0,_.useCallback)(()=>{f.length>0||!e||Yn(e).then(e=>{p(e),h(!1)}).catch(e=>{ee(e.message),h(!1)})},[e,f.length]);(0,_.useEffect)(()=>{[`overview`,`triage`,`enhance`].includes(l)&&ne()},[l,ne]),(0,_.useEffect)(()=>{let i=t.get(`view`)||t.get(`preview`);!e||i!==`1`||(n({},{replace:!0}),r(`/project/${e}`))},[e]);let re=(0,_.useCallback)(()=>{e&&(S(!0),ee(null),w([]),D.current=ar(e,e=>{if(w(t=>[...t,e]),e.type===`error`){ee(e.message),S(!1);return}if(e.type===`result`){let t={selected:e.selected,skipped:e.skipped,autoSelected:e.autoSelected,triageMethod:e.triageMethod};v(t);let n=new Set(t.selected.map(e=>e.sessionId));if(c?.uploadedSessions)for(let e of c.uploadedSessions)n.add(e);b(n),setTimeout(()=>{S(!1),t.autoSelected?(E(`All ${n.size} sessions selected (small project)`),d(`enhance`)):d(`triage`)},1200)}}))},[e]);(0,_.useEffect)(()=>()=>{D.current?.abort()},[]);let ie=(0,_.useCallback)(e=>{A(e),e.questions.length>0?d(`questions`):d(`timeline`)},[]),j=(0,_.useCallback)(()=>{d(`timeline`)},[]),M=(0,_.useCallback)(async t=>{if(!(!e||!k))try{let n=await sr(e,k.narrative,k.timeline,t);A(e=>e&&{...e,narrative:n.narrative,timeline:n.timeline}),d(`timeline`)}catch(e){ee(e.message)}},[e,k]),ae=(0,_.useCallback)(e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return o?(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},children:(0,F.jsx)(`div`,{className:`dashboard-loading`,children:`Loading project...`})}):c?(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},children:m&&l===`overview`?(0,F.jsx)(`div`,{className:`dashboard-loading`,children:`Loading sessions...`}):O&&l===`overview`?(0,F.jsx)(`div`,{className:`dashboard-error`,children:O}):l===`overview`?x?(0,F.jsx)(za,{events:C,dirName:e??``}):(0,F.jsx)(Pa,{project:c,sessions:f,onTriage:re,onCancel:()=>r(`/`)}):l===`triage`&&g?(0,F.jsx)(Va,{project:c,sessions:f,triageResult:g,selectedIds:y,onToggle:ae,onEnhance:()=>d(`enhance`),onBack:()=>d(`overview`),uploadedSessionIds:c.uploadedSessions?new Set(c.uploadedSessions):void 0}):l===`enhance`&&g?(0,F.jsxs)(F.Fragment,{children:[T&&(0,F.jsxs)(`div`,{className:`upload-flow__auto-select-banner`,children:[`✓ `,T]}),(0,F.jsx)(Ha,{project:c,sessions:f,selectedIds:y,triageResult:g,onComplete:ie,onBack:()=>d(`triage`)})]}):l===`questions`&&k?(0,F.jsx)(Wa,{enhanceResult:k,onSkip:j,onWeave:M}):l===`timeline`?(0,F.jsx)(Ga,{project:c,timeline:te.length>0?te.map(e=>({...e,sessions:e.sessions.map(e=>({sessionId:e.sessionId,title:e.title,featured:e.featured,tag:e.tag,duration:f.find(t=>t.id===e.sessionId)?.durationMinutes??0,date:f.find(t=>t.id===e.sessionId)?.date}))})):qa,onBack:()=>k?.questions.length?d(`questions`):d(`enhance`),onViewProject:()=>{e&&k&&gr(e,Array.from(y),k).catch(()=>{}),r(`/project/${e}`)}}):null}):(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},children:(0,F.jsx)(`div`,{className:`dashboard-error`,children:`Project not found`})})}function Ya(e){let t=e.indexOf(`-Dev-`);if(t!==-1)return e.slice(t+5);let n=e.split(`-`).filter(Boolean);return n.length>0?n[n.length-1]:e}function Xa(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)}function Za(){let{dirName:e=``}=st(),[t,n]=(0,_.useState)({step:`review`}),[r,i]=(0,_.useState)(null);(0,_.useEffect)(()=>{e&&nr(e).then(i).catch(()=>{})},[e]);let a=(0,_.useCallback)(()=>{n({step:`uploading`,messages:[]});let t=r?.enhanceCache,i=r?.project,a=t?.title||i?.name||Ya(e);cr(e,{title:a,slug:Xa(a),narrative:t?.result?.narrative??``,repoUrl:t?.repoUrl??``,projectUrl:t?.projectUrl??``,timeline:t?.result?.timeline??[],skills:t?.result?.skills??[],totalSessions:i?.sessionCount??0,totalLoc:i?.totalLoc??0,totalDurationMinutes:i?.totalDuration??0,totalAgentDurationMinutes:i?.totalAgentDuration,totalFilesChanged:i?.totalFiles??0,totalInputTokens:i?.totalInputTokens??0,totalOutputTokens:i?.totalOutputTokens??0,skippedSessions:[],selectedSessionIds:t?.selectedSessionIds??[],screenshotBase64:t?.screenshotBase64??void 0},e=>{switch(e.type){case`project`:n(t=>t.step===`uploading`?{...t,messages:[...t.messages,`Project ${e.status}`]}:t);break;case`session`:n(t=>t.step===`uploading`?{...t,messages:[...t.messages,`Session ${e.sessionId}: ${e.status}`]}:t);break;case`done`:n({step:`done`,projectUrl:e.projectUrl,uploaded:e.uploaded,failed:e.failed});break;case`error`:e.message===`AUTH_REQUIRED`?o():n({step:`error`,message:e.message});break}})},[e,r]),o=(0,_.useCallback)(async()=>{n({step:`auth`,status:`opening`});try{let e=await Sr();window.open(e.verification_uri,`_blank`),n({step:`auth`,status:`waiting`});let t=Date.now(),r=async()=>{try{if((await yr(e.device_code)).authenticated){n({step:`auth`,status:`done`}),setTimeout(()=>a(),500);return}}catch{}Date.now()-t<3e5?setTimeout(r,5e3):n({step:`auth`,status:`error`,error:`Timed out. Try again.`})};setTimeout(r,5e3)}catch{n({step:`auth`,status:`error`,error:`Could not connect. Try again later.`})}},[a]),s=(0,F.jsx)(`button`,{className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,onClick:a,disabled:t.step===`uploading`,children:`Upload to heyiam.com`});return(0,F.jsx)(Ar,{back:{label:`Project`,to:`/project/${e}`},chips:[{label:`Upload to heyiam.com`}],actions:t.step===`review`?s:void 0,children:(0,F.jsxs)(`div`,{className:`p-6`,children:[t.step===`uploading`&&(0,F.jsxs)(L,{className:`max-w-2xl mx-auto`,children:[(0,F.jsx)(z,{title:`Uploading...`,meta:`in progress`}),(0,F.jsxs)(`div`,{className:`space-y-1.5 mt-3`,children:[t.messages.map((e,t)=>(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-on-surface-variant`,children:[(0,F.jsx)(`span`,{className:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin shrink-0`}),e]},t)),t.messages.length===0&&(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-on-surface-variant`,children:[(0,F.jsx)(`span`,{className:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin shrink-0`}),`Connecting...`]})]})]}),t.step===`done`&&(0,F.jsxs)(L,{className:`max-w-2xl mx-auto`,children:[(0,F.jsx)(z,{title:`Uploaded`,meta:`on heyi.am`}),(0,F.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green shrink-0`}),(0,F.jsxs)(`span`,{className:`text-sm text-on-surface font-medium`,children:[t.uploaded,` session`,t.uploaded===1?``:`s`,` uploaded`]})]}),(0,F.jsx)(`p`,{className:`text-xs text-on-surface-variant`,children:`Sessions are unlisted by default. Go to the dashboard to publish them.`}),(0,F.jsx)(`a`,{href:t.projectUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors mt-1`,children:`Open dashboard`})]})]}),t.step===`auth`&&(0,F.jsxs)(L,{className:`max-w-2xl mx-auto`,children:[t.status===`opening`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{title:`Opening browser...`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 text-sm text-on-surface-variant`,children:[(0,F.jsx)(`span`,{className:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin shrink-0`}),`Starting login...`]})]}),t.status===`waiting`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{title:`Log in to heyiam.com`}),(0,F.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-on-surface-variant`,children:[(0,F.jsx)(`span`,{className:`w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin shrink-0`}),`Waiting for you to finish in the browser...`]}),(0,F.jsx)(`p`,{className:`text-xs text-on-surface-variant`,children:`Log in or create an account in the browser window that opened, then come back here.`})]})]}),t.status===`done`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{title:`Logged in`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 text-sm text-on-surface`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green shrink-0`}),`Uploading...`]})]}),t.status===`error`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(z,{title:`Login failed`}),(0,F.jsx)(`p`,{className:`text-error text-sm mt-2`,children:t.error}),(0,F.jsx)(`button`,{className:`mt-3 inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,onClick:o,children:`Try again`})]})]}),t.step===`error`&&(0,F.jsxs)(L,{className:`max-w-2xl mx-auto`,children:[(0,F.jsx)(z,{title:`Upload failed`}),(0,F.jsx)(`p`,{className:`text-error text-sm mt-2`,children:t.message}),(0,F.jsx)(`button`,{className:`mt-3 inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,onClick:a,children:`Retry`})]}),t.step===`review`&&(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`What gets uploaded`,meta:`review`}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(R,{children:`Project title and narrative summary`}),(0,F.jsx)(R,{children:`Selected sessions and stats`}),(0,F.jsx)(R,{children:`Curated decisions, phases, and rendered templates`})]})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`What stays local`,meta:`safety`}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(R,{children:`Excluded sessions and private notes`}),(0,F.jsx)(R,{children:`Source audit details and archive metadata`}),(0,F.jsx)(R,{children:`Sensitive flagged terms and personal data`})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-3 mt-4`,children:(0,F.jsx)(`button`,{className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,onClick:a,children:`Upload to heyiam.com`})})]})]})]})})}function Qa(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!0),[m,h]=(0,_.useState)({localOnly:!0,requireReview:!0,excludeOpenClaw:!1});(0,_.useEffect)(()=>{Promise.all([lr().catch(()=>({hasKey:!1})),dr().catch(()=>({authenticated:!1}))]).then(([e,n])=>{t(e),r(n)}).finally(()=>p(!1))},[]);async function g(){if(i.trim()){l(!0);try{await ur(i.trim()),t({hasKey:!0,keyPrefix:i.trim().slice(0,16)}),a(``)}finally{l(!1)}}}async function v(){l(!0);try{await ur(``),t({hasKey:!1}),a(``),s(!1)}finally{l(!1)}}async function y(){d(!0);try{await Cr(),r({authenticated:!1})}finally{d(!1)}}function b(e){h(t=>({...t,[e]:!t[e]}))}return f||!e||!n?(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},chips:[{label:`Settings`}],children:(0,F.jsx)(`div`,{className:`max-w-3xl mx-auto p-6`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading settings...`})})}):(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},chips:[{label:`Settings`}],children:(0,F.jsxs)(`div`,{className:`max-w-3xl mx-auto p-6`,children:[(0,F.jsx)(`h2`,{className:`font-display text-2xl font-bold text-on-surface`,children:`Settings`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 mt-6`,children:[(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`API configuration`,meta:`local only`}),(0,F.jsx)(`label`,{className:`font-mono text-[11px] uppercase tracking-wider text-on-surface-variant block mb-1.5`,children:`Anthropic API Key`}),e.hasKey&&!i?(0,F.jsx)(`input`,{type:o?`text`:`password`,value:e.keyPrefix?`${e.keyPrefix}...`:`••••••••••••`,readOnly:!0,className:`w-full bg-surface-low border border-ghost rounded-md px-3 py-1.5 text-sm font-mono text-on-surface mb-2`}):(0,F.jsx)(`input`,{type:`password`,value:i,onChange:e=>a(e.target.value),placeholder:`sk-ant-api03-...`,className:`w-full bg-surface-low border border-ghost rounded-md px-3 py-1.5 text-sm font-mono text-on-surface mb-2`,onKeyDown:e=>{e.key===`Enter`&&g()}}),(0,F.jsx)(`p`,{className:`text-on-surface-variant text-xs mb-3`,children:`Used for project refinement. Keys stay on your machine.`}),(0,F.jsx)(`div`,{className:`flex items-center gap-2`,children:e.hasKey&&!i?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{className:`text-xs font-medium px-2.5 py-1 rounded-md border border-outline text-on-surface hover:bg-surface-low transition-colors`,onClick:()=>s(!o),children:o?`Hide`:`Show`}),(0,F.jsx)(`button`,{className:`text-xs font-medium px-2.5 py-1 rounded-md text-on-surface-variant hover:text-on-surface transition-colors`,onClick:v,disabled:c,children:`Remove`})]}):i?(0,F.jsx)(`button`,{className:`text-xs font-medium px-2.5 py-1 rounded-md bg-primary text-on-primary hover:bg-primary-hover transition-colors`,onClick:g,disabled:c,children:c?`Saving...`:`Save key`}):null})]}),(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Privacy defaults`,meta:`recommended`}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)($a,{label:`Mark new projects local only by default`,checked:m.localOnly,onChange:()=>b(`localOnly`)}),(0,F.jsx)($a,{label:`Require review before publish`,checked:m.requireReview,onChange:()=>b(`requireReview`)}),(0,F.jsx)($a,{label:`Exclude personal OpenClaw sessions by default`,checked:m.excludeOpenClaw,onChange:()=>b(`excludeOpenClaw`)})]})]})]}),(0,F.jsx)(`div`,{className:`mt-4`,children:(0,F.jsxs)(L,{children:[(0,F.jsx)(z,{title:`Authentication`,meta:`optional`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${n.authenticated?`bg-green`:`bg-outline`}`}),n.authenticated?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`span`,{className:`text-[13px] text-on-surface`,children:[`Connected as `,(0,F.jsxs)(`strong`,{children:[`@`,n.username]})]}),(0,F.jsx)(`span`,{className:`text-xs text-on-surface-variant`,children:`Authenticated via device auth. Required for publishing.`}),(0,F.jsx)(`button`,{className:`ml-auto text-xs font-medium px-2.5 py-1 rounded-md text-on-surface-variant hover:text-on-surface transition-colors`,onClick:y,disabled:u,children:u?`Disconnecting...`:`Disconnect`})]}):(0,F.jsx)(`span`,{className:`text-[13px] text-on-surface-variant`,children:`Not connected. Authentication is required for publishing.`})]})]})})]})})}function $a({label:e,checked:t,onChange:n}){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(`span`,{className:`text-sm text-on-surface`,children:e}),(0,F.jsx)(`button`,{role:`switch`,"aria-checked":t,onClick:n,className:`relative w-[40px] h-[22px] rounded-full transition-colors ${t?`bg-green`:`bg-surface-high`}`,children:(0,F.jsx)(`span`,{className:`absolute top-[3px] w-4 h-4 rounded-full bg-surface-lowest shadow-sm transition-transform ${t?`left-[21px]`:`left-[3px]`}`})})]})}var eo=[`Claude`,`Cursor`,`Codex`,`Gemini`];function to(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function no(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ro(e){try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}catch{return e}}function io(){let[e,t]=Mn(),n=at(),r=e.get(`q`)??``,i=e.get(`source`)??``,a=e.get(`project`)??``,o=e.get(`skill`)??``,[s,c]=(0,_.useState)(r),[l,u]=(0,_.useState)([]),[d,f]=(0,_.useState)(0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(!1),v=i,y=a,b=o,[x,S]=(0,_.useState)([]),[C,w]=(0,_.useState)([]),T=(0,_.useCallback)(async(e,t,n,r)=>{if(!e&&!t&&!n&&!r){u([]),f(0),g(!1);return}m(!0),g(!0);try{let i=await fr(e,{source:t||void 0,project:n||void 0,skill:r||void 0});u(i.results),f(i.total);let a=[...new Set(i.results.map(e=>e.projectName))].sort(),o=[...new Set(i.results.flatMap(e=>e.skills))].sort();S(a),w(o)}catch{u([]),f(0)}finally{m(!1)}},[]);(0,_.useEffect)(()=>{let e=setTimeout(()=>{let e=new URLSearchParams;s&&e.set(`q`,s),v&&e.set(`source`,v),y&&e.set(`project`,y),b&&e.set(`skill`,b),t(e,{replace:!0}),T(s,v,y,b)},300);return()=>clearTimeout(e)},[s,v,y,b,t,T]),(0,_.useEffect)(()=>{(r||i||a||o)&&(c(r),T(r,i,a,o))},[]);function E(n,r){let i=new URLSearchParams(e);i.get(n)===r?i.delete(n):i.set(n,r),t(i,{replace:!0})}return(0,F.jsx)(Ar,{chips:[{label:`Search`}],children:(0,F.jsxs)(`div`,{className:`p-6 max-w-3xl mx-auto`,children:[(0,F.jsx)(kr,{value:s,onChange:c,autoFocus:!0,placeholder:`Search sessions...`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-3`,children:[(0,F.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mr-1`,children:`Source`}),eo.map(e=>(0,F.jsx)(`button`,{onClick:()=>E(`source`,e.toLowerCase()),className:[`font-mono text-[11px] leading-tight py-0.5 px-2 rounded-sm border transition-colors cursor-pointer`,v===e.toLowerCase()?`bg-primary/10 text-primary border-primary/30`:`bg-surface-low text-on-surface-variant border-ghost hover:border-outline`].join(` `),children:e},e)),x.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline ml-3 mr-1`,children:`Project`}),x.slice(0,5).map(e=>(0,F.jsx)(`button`,{onClick:()=>E(`project`,e),className:[`font-mono text-[11px] leading-tight py-0.5 px-2 rounded-sm border transition-colors cursor-pointer`,y===e?`bg-primary/10 text-primary border-primary/30`:`bg-surface-low text-on-surface-variant border-ghost hover:border-outline`].join(` `),children:e},e))]}),C.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline ml-3 mr-1`,children:`Skill`}),C.slice(0,5).map(e=>(0,F.jsx)(`button`,{onClick:()=>E(`skill`,e),className:[`font-mono text-[11px] leading-tight py-0.5 px-2 rounded-sm border transition-colors cursor-pointer`,b===e?`bg-violet-bg text-violet border-violet/30`:`bg-surface-low text-on-surface-variant border-ghost hover:border-outline`].join(` `),children:e},e))]})]}),(0,F.jsx)(`div`,{className:`h-4`}),p?(0,F.jsx)(`div`,{className:`text-sm text-on-surface-variant`,children:`Searching...`}):h?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`font-mono text-[11px] text-on-surface-variant mb-3`,children:[d,` result`,d===1?``:`s`,s?` for '${s}'`:``]}),l.length===0?(0,F.jsx)(L,{children:(0,F.jsx)(`p`,{className:`text-sm text-on-surface-variant`,children:`No sessions found. Try a different query or adjust filters.`})}):(0,F.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map(e=>(0,F.jsx)(`button`,{onClick:()=>n(`/session/${encodeURIComponent(e.sessionId)}${s?`?q=${encodeURIComponent(s)}`:``}`),className:`text-left w-full cursor-pointer`,children:(0,F.jsxs)(L,{hover:!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`h4`,{className:`font-display text-[0.8125rem] font-semibold text-on-surface truncate`,children:e.title}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,F.jsx)(`span`,{className:`text-xs text-on-surface-variant`,children:e.projectName}),(0,F.jsx)(I,{children:e.source}),(0,F.jsx)(`span`,{className:`text-xs text-outline`,children:ro(e.date)})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 font-mono text-[0.6875rem] text-outline shrink-0`,children:[(0,F.jsx)(`span`,{children:to(e.durationMinutes)}),(0,F.jsxs)(`span`,{children:[e.turns,` turns`]}),(0,F.jsxs)(`span`,{children:[no(e.linesOfCode),` lines`]})]})]}),e.snippet&&(0,F.jsx)(`p`,{className:`text-xs text-on-surface-variant mt-2 line-clamp-2 font-mono`,children:e.snippet}),e.skills.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.skills.map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e))})]})},e.sessionId))})]}):(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-center`,children:[(0,F.jsxs)(`svg`,{className:`w-12 h-12 text-outline mb-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,F.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,F.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,F.jsx)(`p`,{className:`font-display text-sm font-semibold text-on-surface`,children:`Search across all your AI sessions`}),(0,F.jsx)(`p`,{className:`text-xs text-on-surface-variant mt-1`,children:`Full-text search with source, project, and skill filters`})]})]})})}var ao={Read:`📄`,Write:`✏️`,Edit:`✏️`,Bash:`▶`,Grep:`🔍`,Glob:`📂`,Agent:`🤖`,WebSearch:`🌐`,WebFetch:`🌐`};function oo(e){return ao[e]??`⚙`}function so(e){let{toolName:t,input:n}=e;if(!n)return t;switch(t){case`Read`:return n;case`Write`:return n;case`Edit`:return n;case`Bash`:return n.length>80?n.slice(0,77)+`...`:n;case`Grep`:case`Glob`:return n;case`Agent`:return n;default:return n.length>60?n.slice(0,57)+`...`:n}}function co({block:e}){let[t,n]=(0,_.useState)(!1),r=!!e.output,i=e.toolName===`Edit`,a=e.toolName===`Bash`;return(0,F.jsxs)(`div`,{className:`my-1.5 border border-ghost rounded-md bg-surface-lowest overflow-hidden`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-surface-low transition-colors cursor-pointer`,children:[(0,F.jsx)(`span`,{className:`text-xs shrink-0 w-4 text-center`,children:oo(e.toolName)}),(0,F.jsx)(`span`,{className:`font-mono text-[11px] font-semibold text-primary shrink-0`,children:e.toolName}),(0,F.jsx)(`span`,{className:`font-mono text-[11px] text-on-surface-variant truncate flex-1`,children:so(e)}),e.isError&&(0,F.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-error shrink-0`,children:`error`}),(0,F.jsx)(`span`,{className:`text-[10px] text-outline shrink-0 transition-transform`,style:{transform:t?`rotate(90deg)`:`rotate(0deg)`},children:`▸`})]}),t&&(0,F.jsxs)(`div`,{className:`border-t border-ghost`,children:[i&&e.inputData&&(0,F.jsxs)(`div`,{className:`px-3 py-2 border-b border-ghost`,children:[typeof e.inputData.old_string==`string`&&(0,F.jsxs)(`div`,{className:`mb-2`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-1`,children:`old`}),(0,F.jsx)(`pre`,{className:`font-mono text-[11px] text-error/80 bg-error/5 rounded px-2 py-1.5 overflow-x-auto whitespace-pre-wrap break-all max-h-40 overflow-y-auto`,children:e.inputData.old_string})]}),typeof e.inputData.new_string==`string`&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-1`,children:`new`}),(0,F.jsx)(`pre`,{className:`font-mono text-[11px] text-green/80 bg-green/5 rounded px-2 py-1.5 overflow-x-auto whitespace-pre-wrap break-all max-h-40 overflow-y-auto`,children:e.inputData.new_string})]})]}),a&&e.input&&(0,F.jsx)(`div`,{className:`px-3 py-2 border-b border-ghost bg-[var(--inverse-surface)]`,children:(0,F.jsxs)(`pre`,{className:`font-mono text-[11px] text-[var(--inverse-on-surface)] whitespace-pre-wrap break-all`,children:[`$ `,e.input]})}),r&&(0,F.jsxs)(`div`,{className:`px-3 py-2 max-h-64 overflow-y-auto`,children:[(0,F.jsx)(`pre`,{className:`font-mono text-[11px] whitespace-pre-wrap break-all ${e.isError?`text-error`:`text-on-surface-variant`}`,children:e.output}),e.outputTruncated&&(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mt-2`,children:`output truncated`})]}),!r&&!i&&!a&&(0,F.jsx)(`div`,{className:`px-3 py-2 text-[11px] text-outline italic`,children:`no output`})]})]})}function W({text:e}){let[t,n]=(0,_.useState)(!1),r=e.slice(0,80).replace(/\n/g,` `);return(0,F.jsxs)(`div`,{className:`my-1`,children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex items-center gap-2 text-left cursor-pointer group`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-outline transition-transform shrink-0`,style:{transform:t?`rotate(90deg)`:`rotate(0deg)`},children:`▸`}),(0,F.jsx)(`span`,{className:`font-mono text-[11px] text-outline italic group-hover:text-on-surface-variant transition-colors`,children:t?`thinking`:`thinking: ${r}${e.length>80?`...`:``}`})]}),t&&(0,F.jsx)(`div`,{className:`ml-5 mt-1.5 pl-3 border-l-2 border-ghost`,children:(0,F.jsx)(`pre`,{className:`font-mono text-[11px] text-on-surface-variant/70 whitespace-pre-wrap break-words max-h-96 overflow-y-auto`,children:e})})]})}var G=300;function lo({text:e,highlights:t}){let[n,r]=(0,_.useState)(e.length<=G),i=e.length>G,a=(()=>{if(!i)return e.length;let t=e.slice(0,G+50),n=t.lastIndexOf(`. `,G);if(n>G*.6)return n+1;let r=t.lastIndexOf(` `,G);return r>G*.6?r:G})(),o=n?e:e.slice(0,a);if(t){let e=RegExp(`(${go(t)})`,`gi`);return(0,F.jsxs)(`div`,{className:`text-[0.8125rem] leading-relaxed whitespace-pre-wrap break-words`,children:[o.split(e).map((t,n)=>e.test(t)?(0,F.jsx)(`mark`,{className:`bg-amber/30 text-on-surface rounded-sm px-0.5`,children:t},n):(0,F.jsx)(`span`,{children:t},n)),i&&(0,F.jsx)(uo,{expanded:n,onToggle:()=>r(!n)})]})}return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(fo,{text:o}),i&&(0,F.jsx)(uo,{expanded:n,onToggle:()=>r(!n)})]})}function uo({expanded:e,onToggle:t}){return(0,F.jsx)(`button`,{type:`button`,onClick:t,className:`inline-block mt-1 font-mono text-[11px] text-primary hover:underline cursor-pointer`,children:e?`▴ Show less`:`▾ Show more`})}function fo({text:e}){return(0,F.jsx)(`div`,{className:`text-[0.8125rem] leading-relaxed whitespace-pre-wrap break-words`,children:e.split(/(```[\s\S]*?```)/g).map((e,t)=>{if(e.startsWith("```")&&e.endsWith("```")){let n=e.slice(3,-3),r=n.indexOf(`
|
|
21
21
|
`),i=r>0?n.slice(0,r).trim():``,a=r>0?n.slice(r+1):n;return(0,F.jsxs)(`pre`,{className:`my-2 bg-surface-lowest border border-ghost rounded-md px-3 py-2 font-mono text-[11px] overflow-x-auto`,children:[i&&(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-1.5`,children:i}),a]},t)}return(0,F.jsx)(`span`,{children:e.split(/(`[^`]+`)/g).map((e,t)=>e.startsWith("`")&&e.endsWith("`")?(0,F.jsx)(`code`,{className:`bg-surface-low rounded px-1 py-0.5 font-mono text-[11px]`,children:e.slice(1,-1)},t):(0,F.jsx)(`span`,{children:e},t))},t)})})}function po({message:e,searchQuery:t,messageIndex:n,showRoleBadge:r=!0}){let i=e.role===`user`,a=e.blocks.filter(e=>e.type===`tool_call`),o=e.blocks.filter(e=>e.type===`text`),s=e.blocks.filter(e=>e.type===`thinking`),[c,l]=(0,_.useState)(a.length<=3);return(0,F.jsxs)(`div`,{className:`relative`,"data-message-index":n,children:[r&&(0,F.jsx)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:(0,F.jsx)(`span`,{className:`inline-flex items-center font-mono text-[11px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded-sm ${i?`bg-primary/10 text-primary`:`bg-green/10 text-green`}`,children:i?`you`:`assistant`})}),(0,F.jsxs)(`div`,{className:`${i?`bg-primary/5 border-l-[3px] border-primary pl-3 py-2 rounded-r-md`:`pl-0.5`}`,children:[s.map((e,n)=>(0,F.jsx)(mo,{block:e,searchQuery:t},`t-${n}`)),o.map((e,n)=>(0,F.jsx)(mo,{block:e,searchQuery:t},`x-${n}`)),a.length>3&&!c?(0,F.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`mt-1.5 flex items-center gap-2 font-mono text-[11px] text-on-surface-variant hover:text-on-surface cursor-pointer transition-colors`,children:[(0,F.jsx)(`span`,{className:`text-[10px] text-outline`,children:`▸`}),(0,F.jsxs)(`span`,{children:[a.length,` tool calls`]}),(0,F.jsxs)(`span`,{className:`text-outline`,children:[`(`,[...new Set(a.map(e=>e.type===`tool_call`?e.toolName:``))].join(`, `),`)`]})]}):a.map((e,n)=>(0,F.jsx)(mo,{block:e,searchQuery:t},`tc-${n}`)),a.length>3&&c&&(0,F.jsxs)(`button`,{type:`button`,onClick:()=>l(!1),className:`mt-1 font-mono text-[10px] text-outline hover:text-on-surface-variant cursor-pointer`,children:[`▾ Collapse `,a.length,` tool calls`]})]})]})}function mo({block:e,searchQuery:t}){switch(e.type){case`text`:return(0,F.jsx)(lo,{text:e.text,highlights:t});case`thinking`:return(0,F.jsx)(W,{text:e.text});case`tool_call`:return(0,F.jsx)(co,{block:e})}}function ho({query:e,onQueryChange:t,matchCount:n,currentMatch:r,onNext:i,onPrev:a,onClose:o}){let s=(0,_.useRef)(null);return(0,_.useEffect)(()=>{s.current?.focus()},[]),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 bg-surface-lowest border border-ghost rounded-md px-3 py-1.5 shadow-sm`,children:[(0,F.jsxs)(`svg`,{className:`w-3.5 h-3.5 text-outline shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,F.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,F.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,F.jsx)(`input`,{ref:s,type:`text`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.shiftKey?a():i()),e.key===`Escape`&&o()},placeholder:`Search in session...`,className:`bg-transparent text-sm text-on-surface outline-none flex-1 min-w-0`}),e&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`font-mono text-[10px] text-outline shrink-0`,children:n>0?`${r+1}/${n}`:`no matches`}),(0,F.jsx)(`button`,{type:`button`,onClick:a,disabled:n===0,className:`text-xs text-on-surface-variant hover:text-on-surface disabled:opacity-30 cursor-pointer`,children:`↑`}),(0,F.jsx)(`button`,{type:`button`,onClick:i,disabled:n===0,className:`text-xs text-on-surface-variant hover:text-on-surface disabled:opacity-30 cursor-pointer`,children:`↓`})]}),(0,F.jsx)(`button`,{type:`button`,onClick:o,className:`text-xs text-outline hover:text-on-surface cursor-pointer ml-1`,children:`✕`})]})}function go(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _o({messages:e,initialSearchQuery:t,compact:n}){let[r,i]=(0,_.useState)(!!t),[a,o]=(0,_.useState)(t??``),[s,c]=(0,_.useState)(0),l=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(n)return;function e(e){(e.metaKey||e.ctrlKey)&&e.key===`f`&&(e.preventDefault(),i(!0))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let u=(0,_.useMemo)(()=>{if(!a)return 0;let t=new RegExp(go(a),`gi`),n=0;for(let r of e)for(let e of r.blocks)if(e.type===`text`){let r=e.text.match(t);r&&(n+=r.length)}return n},[e,a]),d=(0,_.useCallback)(()=>{c(e=>(e+1)%Math.max(1,u))},[u]),f=(0,_.useCallback)(()=>{c(e=>(e-1+Math.max(1,u))%Math.max(1,u))},[u]),p=(0,_.useCallback)(()=>{i(!1),o(``),c(0)},[]);return e.length===0?(0,F.jsx)(`div`,{className:`text-center ${n?`py-4`:`py-12`}`,children:(0,F.jsx)(`p`,{className:`text-sm text-on-surface-variant`,children:`No conversation data available.`})}):(0,F.jsxs)(`div`,{ref:l,className:`relative`,children:[!n&&r&&(0,F.jsx)(`div`,{className:`sticky top-12 z-40 mb-4`,children:(0,F.jsx)(ho,{query:a,onQueryChange:e=>{o(e),c(0)},matchCount:u,currentMatch:s,onNext:d,onPrev:f,onClose:p})}),(0,F.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.map((t,n)=>{let r=n>0?e[n-1].role:null,i=r!==t.role;return(0,F.jsxs)(`div`,{children:[r!==null&&r!==t.role&&t.role===`user`&&(0,F.jsx)(`div`,{className:`border-t border-ghost/60 mb-4 mt-1`}),(0,F.jsx)(po,{message:t,messageIndex:n,searchQuery:a||void 0,showRoleBadge:i})]},t.id)})}),!n&&!r&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`fixed bottom-6 right-6 z-40 bg-surface-lowest border border-ghost rounded-full w-10 h-10 flex items-center justify-center shadow-lg hover:shadow-xl transition-shadow cursor-pointer group`,title:`Search in session (Cmd+F)`,children:(0,F.jsxs)(`svg`,{className:`w-4 h-4 text-on-surface-variant group-hover:text-on-surface transition-colors`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,F.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,F.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]})})]})}function vo(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function yo(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function bo(e){try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`})}catch{return e}}function xo(e){let t=e.replace(/^#+\s*/gm,``).replace(/\*\*/g,``).replace(/\n.*/s,``);return t.length>120&&(t=t.slice(0,117)+`...`),t}function So(){let{sessionId:e}=st(),[t]=Mn(),n=at(),r=t.get(`q`)??``,[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(!0),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)([]),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(!1),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(!1);(0,_.useEffect)(()=>{e&&(s(!0),pr(e).then(a).catch(e=>l(e.message)).finally(()=>s(!1)))},[e]),(0,_.useEffect)(()=>{!e||m||(p(!0),hr(e).then(e=>{d(e.messages),h(!0)}).catch(()=>{}).finally(()=>p(!1)))},[e,m]),(0,_.useEffect)(()=>{if(!x)return;let e=setTimeout(()=>S(null),3e3);return()=>clearTimeout(e)},[x]);async function T(t){if(!(!e||y)){b(!0),v(!1);try{let n=await mr(e,t);await navigator.clipboard.writeText(n.content),S(`Context copied (${n.tokens.toLocaleString()} tokens)`)}catch{S(`Failed to copy context`)}finally{b(!1)}}}async function E(){if(!(!e||C)){w(!0);try{let t=await mr(e,`summary`),n=new Blob([t.content],{type:`text/markdown`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.slice(0,8)}.md`,i.click(),URL.revokeObjectURL(r),S(`Downloaded summary (${t.tokens.toLocaleString()} tokens)`)}catch{S(`Failed to download summary`)}finally{w(!1)}}}if(o)return(0,F.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-surface-mid`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading session...`})});if(c||!i)return(0,F.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center bg-surface-mid gap-3`,children:[(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:c??`Session not found.`}),(0,F.jsx)(`button`,{onClick:()=>n(-1),className:`text-xs text-primary hover:underline cursor-pointer`,children:`Go back`})]});let D=i.filesChanged??[],O=i.toolBreakdown??[],ee=Math.max(...O.map(e=>e.count),1),k=(()=>{if(u.length>0&&u[0].role===`user`)return u;let e=i.title.replace(/\.\.\.$/,``).replace(/\s*##\s*$/,``).trim();return[{id:`first-prompt`,timestamp:i.date,role:`user`,blocks:[{type:`text`,text:e}]},...u]})();return(0,F.jsxs)(`div`,{className:`min-h-screen bg-surface-mid`,children:[(0,F.jsx)(`header`,{className:`sticky top-0 z-50 bg-surface-lowest border-b border-ghost`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between h-12 px-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,F.jsx)(`button`,{onClick:()=>n(-1),className:`text-sm text-on-surface-variant hover:text-on-surface transition-colors cursor-pointer shrink-0`,children:`← Back`}),(0,F.jsx)(`span`,{className:`text-outline text-xs shrink-0`,children:`/`}),(0,F.jsx)(`span`,{className:`font-display text-sm font-semibold text-on-surface truncate`,children:xo(i.title)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,F.jsx)(`button`,{onClick:E,disabled:C,className:`inline-flex items-center gap-1.5 text-[0.8125rem] px-3 py-1.5 rounded-sm border border-ghost text-on-surface-variant hover:text-on-surface hover:border-outline transition-colors cursor-pointer disabled:opacity-50`,children:C?`Downloading...`:`↓ Summary`}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`button`,{onClick:()=>v(!g),disabled:y,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors cursor-pointer disabled:opacity-50`,children:y?`Copying...`:`Copy for AI`}),g&&(0,F.jsx)(`div`,{className:`absolute right-0 top-full mt-1 bg-surface-lowest border border-ghost rounded-md shadow-lg z-50 py-1 min-w-[160px]`,children:[`compact`,`summary`,`full`].map(e=>(0,F.jsxs)(`button`,{onClick:()=>T(e),className:`w-full text-left px-3 py-1.5 text-sm text-on-surface hover:bg-surface-low transition-colors cursor-pointer`,children:[(0,F.jsx)(`span`,{className:`font-semibold capitalize`,children:e}),(0,F.jsx)(`span`,{className:`text-on-surface-variant text-xs ml-1.5`,children:e===`compact`?`~500 tokens`:e===`summary`?`~2k tokens`:`~5k+ tokens`})]},e))})]})]})]})}),x&&(0,F.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 bg-surface-dark text-on-primary font-mono text-xs px-4 py-2.5 rounded-md shadow-lg`,children:x}),(0,F.jsxs)(`div`,{className:`p-6 max-w-3xl mx-auto`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-2`,children:[i.source&&(0,F.jsx)(I,{children:i.source}),(0,F.jsx)(I,{children:bo(i.date)}),i.projectName&&(0,F.jsx)(I,{variant:`primary`,children:i.projectName})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 font-mono text-[11px] text-on-surface-variant mb-4`,children:[(0,F.jsxs)(`span`,{children:[vo(i.durationMinutes),` active`]}),(0,F.jsx)(`span`,{className:`text-ghost`,children:`|`}),(0,F.jsxs)(`span`,{children:[i.turns,` turns`]}),(0,F.jsx)(`span`,{className:`text-ghost`,children:`|`}),(0,F.jsxs)(`span`,{children:[D.length,` files`]}),(0,F.jsx)(`span`,{className:`text-ghost`,children:`|`}),(0,F.jsxs)(`span`,{children:[yo(i.linesOfCode),` lines`]})]}),i.developerTake&&(0,F.jsx)(`div`,{className:`mb-5`,children:(0,F.jsx)(`p`,{className:`text-[0.9375rem] leading-relaxed text-on-surface border-l-[3px] border-primary pl-3`,children:i.developerTake})}),i.skills&&i.skills.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-5`,children:i.skills.map(e=>(0,F.jsx)(I,{variant:`violet`,children:e},e))}),f?(0,F.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin`}),(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading transcript...`})]})}):(0,F.jsx)(_o,{messages:k,initialSearchQuery:r}),(O.length>0||D.length>0||i.qaPairs&&i.qaPairs.length>0)&&(0,F.jsxs)(`div`,{className:`mt-8 pt-6 border-t border-ghost`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline mb-4`,children:`Supporting detail`}),D.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsxs)(`div`,{className:`font-mono text-[10px] uppercase tracking-wider text-on-surface-variant mb-2`,children:[`Files changed · `,D.length]}),(0,F.jsx)(`div`,{className:`flex flex-col divide-y divide-ghost bg-surface-lowest border border-ghost rounded-md`,children:D.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,F.jsx)(`span`,{className:`font-mono text-xs text-on-surface truncate flex-1 mr-3`,children:e.path}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[11px] shrink-0`,children:[e.additions>0&&(0,F.jsxs)(`span`,{className:`text-green`,children:[`+`,e.additions]}),e.deletions>0&&(0,F.jsxs)(`span`,{className:`text-error`,children:[`-`,e.deletions]})]})]},e.path))})]}),O.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsxs)(`div`,{className:`font-mono text-[10px] uppercase tracking-wider text-on-surface-variant mb-2`,children:[`Tool breakdown · `,O.reduce((e,t)=>e+t.count,0),` calls`]}),(0,F.jsx)(`div`,{className:`flex flex-col gap-2`,children:O.sort((e,t)=>t.count-e.count).map(e=>(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`font-mono text-[11px] text-on-surface-variant w-28 truncate shrink-0`,children:e.tool}),(0,F.jsx)(`div`,{className:`flex-1 h-4 bg-surface-low rounded-sm overflow-hidden`,children:(0,F.jsx)(`div`,{className:`h-full bg-primary/20 rounded-sm`,style:{width:`${e.count/ee*100}%`}})}),(0,F.jsx)(`span`,{className:`font-mono text-[11px] text-outline w-8 text-right shrink-0`,children:e.count})]},e.tool))})]}),i.qaPairs&&i.qaPairs.length>0&&(0,F.jsxs)(`div`,{className:`mb-5`,children:[(0,F.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-wider text-on-surface-variant mb-2`,children:`Questions & Answers`}),(0,F.jsx)(`div`,{className:`bg-surface-lowest border border-ghost rounded-md divide-y divide-ghost`,children:i.qaPairs.map((e,t)=>(0,F.jsxs)(`div`,{className:`px-3 py-3`,children:[(0,F.jsx)(`div`,{className:`font-semibold text-sm text-on-surface mb-1`,children:e.question}),(0,F.jsx)(`div`,{className:`text-[0.8125rem] text-on-surface-variant leading-relaxed`,children:e.answer})]},t))})]})]})]})]})}function Co(e){let t=e/60;return t>=1?`${t.toFixed(1)}h`:`${Math.round(e)}m`}function wo(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function To(e){try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}catch{return e}}function Eo(){let{dirName:e}=st(),t=at(),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(`date`),[c,l]=(0,_.useState)(!0),[u,d]=(0,_.useState)(``);if((0,_.useEffect)(()=>{e&&nr(e).then(r).catch(()=>{}).finally(()=>a(!1))},[e]),i)return(0,F.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-surface-mid`,children:(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Loading sessions...`})});if(!n)return(0,F.jsxs)(`div`,{className:`min-h-screen flex flex-col items-center justify-center bg-surface-mid gap-3`,children:[(0,F.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:`Project not found.`}),(0,F.jsx)(`button`,{onClick:()=>t(-1),className:`text-xs text-primary hover:underline cursor-pointer`,children:`Go back`})]});let{sessions:f}=n,p=[...u?f.filter(e=>e.title.toLowerCase().includes(u.toLowerCase())||(e.skills??[]).some(e=>e.toLowerCase().includes(u.toLowerCase()))||(e.source??``).toLowerCase().includes(u.toLowerCase())):f].sort((e,t)=>{let n=0;switch(o){case`date`:n=new Date(e.date).getTime()-new Date(t.date).getTime();break;case`duration`:n=e.durationMinutes-t.durationMinutes;break;case`loc`:n=e.linesOfCode-t.linesOfCode;break;case`turns`:n=e.turns-t.turns;break}return c?-n:n});function m(e){o===e?l(!c):(s(e),l(!0))}function h({label:e,sortKey:t}){let n=o===t;return(0,F.jsxs)(`button`,{type:`button`,onClick:()=>m(t),className:`font-mono text-[9px] uppercase tracking-wider cursor-pointer transition-colors ${n?`text-primary font-bold`:`text-outline hover:text-on-surface-variant`}`,children:[e,` `,n?c?`↓`:`↑`:``]})}return(0,F.jsxs)(`div`,{className:`min-h-screen bg-surface-mid`,children:[(0,F.jsx)(`header`,{className:`sticky top-0 z-50 bg-surface-lowest border-b border-ghost`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between h-12 px-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,F.jsxs)(`button`,{onClick:()=>t(`/project/${encodeURIComponent(e??``)}`),className:`text-sm text-on-surface-variant hover:text-on-surface transition-colors cursor-pointer shrink-0`,children:[`← `,n.project.name]}),(0,F.jsx)(`span`,{className:`text-outline text-xs shrink-0`,children:`/`}),(0,F.jsx)(`span`,{className:`font-display text-sm font-semibold text-on-surface`,children:`All sessions`})]}),(0,F.jsxs)(I,{variant:`primary`,children:[f.length,` sessions`]})]})}),(0,F.jsxs)(`div`,{className:`p-6 max-w-4xl mx-auto`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mb-4`,children:[(0,F.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:`Filter by title, skill, or source...`,className:`flex-1 bg-surface-lowest border border-ghost rounded-md px-3 py-2 text-sm text-on-surface placeholder:text-outline outline-none focus:border-primary transition-colors`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,F.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-outline`,children:`Sort:`}),(0,F.jsx)(h,{label:`Date`,sortKey:`date`}),(0,F.jsx)(h,{label:`Duration`,sortKey:`duration`}),(0,F.jsx)(h,{label:`Lines`,sortKey:`loc`}),(0,F.jsx)(h,{label:`Turns`,sortKey:`turns`})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p.map(e=>(0,F.jsxs)(P,{to:`/session/${encodeURIComponent(e.id)}`,className:`flex items-start gap-4 bg-surface-lowest border border-ghost rounded-md px-4 py-3 hover:shadow-md transition-shadow`,children:[(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`font-display text-[0.8125rem] font-semibold text-on-surface mb-0.5 truncate`,children:e.title}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 font-mono text-[10px] text-on-surface-variant`,children:[(0,F.jsx)(`span`,{children:To(e.date)}),(0,F.jsx)(`span`,{className:`text-ghost`,children:`|`}),(0,F.jsx)(`span`,{children:Co(e.durationMinutes)}),(0,F.jsx)(`span`,{className:`text-ghost`,children:`|`}),(0,F.jsxs)(`span`,{children:[e.turns,` turns`]}),(0,F.jsx)(`span`,{className:`text-ghost`,children:`|`}),(0,F.jsxs)(`span`,{children:[wo(e.linesOfCode),` lines`]})]}),e.developerTake&&(0,F.jsx)(`p`,{className:`text-xs text-on-surface-variant mt-1 line-clamp-1`,children:e.developerTake})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 pt-0.5`,children:[e.source&&(0,F.jsx)(I,{children:e.source}),e.skills?.[0]&&(0,F.jsx)(I,{variant:`violet`,children:e.skills[0]}),(e.skills?.length??0)>1&&(0,F.jsxs)(`span`,{className:`font-mono text-[9px] text-outline`,children:[`+`,e.skills.length-1]})]})]},e.id)),p.length===0&&(0,F.jsx)(`div`,{className:`text-center py-12`,children:(0,F.jsx)(`p`,{className:`text-sm text-on-surface-variant`,children:u?`No sessions match your filter.`:`No sessions in this project.`})})]})]})]})}function Do({dirName:e}){let[t,n]=(0,_.useState)(!1),r=(0,_.useRef)(null);(0,_.useEffect)(()=>{function e(e){r.current&&!r.current.contains(e.target)&&n(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let i=encodeURIComponent(e),a=[{label:`HTML (.zip)`,href:`/api/projects/${i}/download-html`},{label:`Markdown (.zip)`,href:`/api/projects/${i}/download-markdown`},{label:`JSON`,href:`/api/projects/${i}/download-json`}];return(0,F.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,F.jsxs)(`button`,{onClick:()=>n(e=>!e),className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm border border-ghost text-primary hover:border-outline transition-colors`,children:[`Export`,(0,F.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,className:`transition-transform ${t?`rotate-180`:``}`,children:(0,F.jsx)(`path`,{d:`M3 4.5L6 7.5L9 4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),t&&(0,F.jsx)(`div`,{className:`absolute right-0 top-full mt-1 z-50 min-w-[160px] rounded-md border border-outline bg-surface py-1 shadow-lg`,children:a.map(e=>(0,F.jsx)(`a`,{href:e.href,className:`block px-3 py-1.5 text-[0.8125rem] text-on-surface hover:bg-surface-low transition-colors`,onClick:()=>n(!1),children:e.label},e.label))})]})}function Oo(){let{dirName:e}=st(),[t,n]=(0,_.useState)(null);return(0,_.useEffect)(()=>{e&&nr(e).then(e=>{n(e.project.name)}).catch(()=>{})},[e]),(0,F.jsx)(Ar,{back:{label:`Projects`,to:`/projects`},chips:[{label:t??`...`}],actions:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(P,{to:`/project/${encodeURIComponent(e??``)}/enhance`,className:`inline-flex items-center gap-1.5 font-semibold text-[0.8125rem] px-3.5 py-1.5 rounded-sm bg-primary text-on-primary hover:bg-primary-hover transition-colors`,children:`Enhance project`}),(0,F.jsx)(Do,{dirName:e??``}),(0,F.jsx)(P,{to:`/project/${encodeURIComponent(e??``)}/publish`,className:`text-xs text-on-surface-variant hover:text-on-surface transition-colors`,children:`Upload to heyiam.com`})]}),children:(0,F.jsx)(Ta,{})})}function ko(){return(0,F.jsx)(Sn,{children:(0,F.jsxs)(Nt,{children:[(0,F.jsx)(jt,{path:`/`,element:(0,F.jsx)(Ui,{})}),(0,F.jsx)(jt,{path:`/sources`,element:(0,F.jsx)(ra,{})}),(0,F.jsx)(jt,{path:`/archive`,element:(0,F.jsx)(aa,{})}),(0,F.jsx)(jt,{path:`/projects`,element:(0,F.jsx)(ua,{})}),(0,F.jsx)(jt,{path:`/project/:dirName`,element:(0,F.jsx)(Oo,{})}),(0,F.jsx)(jt,{path:`/project/:dirName/sessions`,element:(0,F.jsx)(Eo,{})}),(0,F.jsx)(jt,{path:`/project/:dirName/boundaries`,element:(0,F.jsx)(Da,{})}),(0,F.jsx)(jt,{path:`/project/:dirName/enhance`,element:(0,F.jsx)(Ja,{})}),(0,F.jsx)(jt,{path:`/search`,element:(0,F.jsx)(io,{})}),(0,F.jsx)(jt,{path:`/session/:sessionId`,element:(0,F.jsx)(So,{})}),(0,F.jsx)(jt,{path:`/project/:dirName/publish`,element:(0,F.jsx)(Za,{})}),(0,F.jsx)(jt,{path:`/settings`,element:(0,F.jsx)(Qa,{})})]})})}(0,v.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(_.StrictMode,{children:(0,F.jsx)(ko,{})}));
|