import{a as f,f as u,s as S}from"../chunks/r0JawsZc.js";import{p as ue,o as g,q as pe,u as he,v as me,w as ge,x as _e,y as r,z as s,$ as ye,c as o,s as d,f as F,A as Ce,r as t,B as q,t as xe}from"../chunks/CZHsSL_X.js";import{i as E}from"../chunks/B8XegpSE.js";import{B as L,a as Se,e as J,i as be,P as Pe,s as $e}from"../chunks/B5NAKyil.js";import{h as je}from"../chunks/BOYo8yTr.js";import{g as Ie}from"../chunks/BIaXC2t9.js";import{g as ke,s as we,c as Ae,S as Ee}from"../chunks/UJOiqIYE.js";import{i as Le}from"../chunks/DSU1n5N_.js";import{E as D}from"../chunks/CSoRdFvv.js";import{I as Me}from"../chunks/DjsDGxCa.js";import"../chunks/CQjSATpv.js";import{f as Te}from"../chunks/BLszSzTT.js";var Be=u('<meta name="description" content="Claude Code sessions across all projects"/>'),Re=u("<!> Refresh",1),Ke=u('<div class="loading-container"></div>'),Ne=u('<a class="session-card"><div class="session-card-header"><div><h3 class="session-card-title"> </h3> <div class="session-card-subtitle"> </div></div> <!></div> <div class="session-stats"><span><strong> </strong> </span></div></a>'),Oe=u('<div style="text-align: center; padding: 1rem;"><!></div>'),ze=u('<div class="projects-container svelte-1uha8ag"></div> <!>',1),Fe=u('<main class="main"><div class="page-header svelte-1uha8ag"><div class="page-header-content svelte-1uha8ag"><div><h1 class="page-title svelte-1uha8ag">Projects</h1> <p class="page-description svelte-1uha8ag">Claude Code sessions across all projects</p></div> <div class="page-actions svelte-1uha8ag"><!></div></div></div> <!> <!></main>');function es(G,H){ue(H,!0);const V=1e4,M=20;let n=g(pe([])),p=g(!1),b=!1,h=g(null),C=null,_=g(null),T=g(!1),P=g(0);he(()=>{Z();const e=ke("shooter_projects");e&&(r(n,e,!0),r(p,!1)),x(),C=setInterval(()=>{s(h)?.apiKey&&s(P)<=M&&x()},V)}),me(()=>{C&&(clearInterval(C),C=null)});function Z(){try{const e=localStorage.getItem("shooter_config");if(e){const a=JSON.parse(e);Le(a)?r(h,a,!0):(localStorage.removeItem("shooter_config"),r(h,null))}}catch{}}async function x(e=!1,a=!1){if(!s(h)?.apiKey||b)return;b=!0,s(n).length===0&&r(p,!0);const l=e?s(P):0;try{const y=await fetch(`${a?"/api/sessions?refresh=true&":"/api/sessions?"}limit=${M}&offset=${l}`,{headers:{Authorization:`Bearer ${s(h).apiKey}`}});if(!y.ok){r(_,`Failed to load projects (HTTP ${y.status})`);return}r(_,null);const i=await y.json();e?r(n,[...s(n),...i.projects],!0):r(n,i.projects,!0),r(P,s(n).length,!0),r(T,i.total!==void 0?s(n).length<i.total:!1,!0),we("shooter_projects",s(n))}catch(v){r(_,"Failed to load projects"),console.error("Failed to fetch sessions:",v)}finally{r(p,!1),b=!1}}async function Q(){await x(!0)}async function U(){r(p,!0),Ae("shooter_projects"),await x(!1,!0)}function W(){Ie("/config")}function X(){return s(n).reduce((e,a)=>e+a.sessionCount,0)}var $=Fe();je("1uha8ag",e=>{var a=Be();_e(()=>{ye.title="Projects - Shooter"}),f(e,a)});var j=o($),B=o(j),R=d(o(B),2),Y=o(R);L(Y,{classes:"btn-secondary",onclick:U,get disabled(){return s(p)},children:(e,a)=>{var l=Re(),v=F(l);Me(v,{name:"refresh",size:14}),Ce(),f(e,l)},$$slots:{default:!0}}),t(R),t(B),t(j);var K=d(j,2);{var ee=e=>{Se(e,{get text(){return s(_)},classes:"banner-error"})};E(K,e=>{s(_)&&e(ee)})}var se=d(K,2);{var ae=e=>{var a=Ke();J(a,20,()=>Array(5),be,(l,v)=>{Ee(l,{classes:"shimmer-card"})}),t(a),f(e,a)},te=e=>{D(e,{icon:"settings",title:"Configuration Required",description:"Set up your API credentials to start tracking sessions",children:(a,l)=>{L(a,{classes:"btn-primary",onclick:W,text:"Configure Settings"})}})},re=e=>{D(e,{icon:"bell",title:"No sessions yet",description:"Claude Code sessions will appear here once JSONL files are found"})},oe=q(()=>X()===0),ie=e=>{var a=ze(),l=F(a);J(l,21,()=>s(n),i=>i.id,(i,c)=>{var m=Ne(),I=o(m),k=o(I),w=o(k),ne=o(w,!0);t(w);var N=d(w,2),le=o(N,!0);t(N),t(k);var ce=d(k,2);{let fe=q(()=>Te(s(c).lastModified));Pe(ce,{get text(){return`Last updated ${s(fe)??""}`},classes:"pill-session-time"})}t(I);var O=d(I,2),z=o(O),A=o(z),de=o(A,!0);t(A);var ve=d(A);t(z),t(O),t(m),xe(()=>{$e(m,"href",`/project?id=${s(c).id??""}`),S(ne,s(c).name),S(le,s(c).fullPath),S(de,s(c).sessionCount),S(ve,` ${s(c).sessionCount===1?"session":"sessions"}`)}),f(i,m)}),t(l);var v=d(l,2);{var y=i=>{var c=Oe(),m=o(c);L(m,{classes:"btn-secondary",onclick:Q,text:"Load More"}),t(c),f(i,c)};E(v,i=>{s(T)&&i(y)})}f(e,a)};E(se,e=>{s(p)&&s(n).length===0?e(ae):s(h)?.apiKey?s(oe)?e(re,2):e(ie,-1):e(te,1)})}t($),f(G,$),ge()}export{es as component};
