wind-agent-cli 1.38.0 → 1.38.1
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/assets/{CodeEditor-FvgsnJ7J.js → CodeEditor-Cx2QOPKS.js} +1 -1
- package/dist/assets/{FileTree-NLULrBDi.js → FileTree-CaCZBfXB.js} +1 -1
- package/dist/assets/{GitPanel-51KUBbEW.js → GitPanel-C8vu-HU9.js} +1 -1
- package/dist/assets/{MarkdownPreview-PEEWVWeS.js → MarkdownPreview-DM1I8sMC.js} +1 -1
- package/dist/assets/{Shell-BEx66cW_.js → Shell-eRBEAkRb.js} +1 -1
- package/dist/assets/{StandaloneShell-BkuUCPZP.js → StandaloneShell-C_SgfnxT.js} +1 -1
- package/dist/assets/{TaskMasterPanel-DfQG80SF.js → TaskMasterPanel-ePMcx8a-.js} +2 -2
- package/dist/assets/{abnfDiagram-N423BO3Z-Cc0ul87U.js → abnfDiagram-N423BO3Z-BcJZs1lF.js} +1 -1
- package/dist/assets/{arc-BAuugHw_.js → arc-B53XXXxy.js} +1 -1
- package/dist/assets/{architectureDiagram-T3A2C74G-DA3G7QZD.js → architectureDiagram-T3A2C74G-vTs0UDp_.js} +1 -1
- package/dist/assets/{blockDiagram-VBNYF7ZC-tJ12IJs3.js → blockDiagram-VBNYF7ZC-CRlmkPBH.js} +1 -1
- package/dist/assets/{c4Diagram-5PPSVZJV-5BTMCXL4.js → c4Diagram-5PPSVZJV-CDkarwX2.js} +1 -1
- package/dist/assets/channel-BBmlxLKm.js +1 -0
- package/dist/assets/{chunk-2GRJ4B5K-BPaI06Ou.js → chunk-2GRJ4B5K-CdVcURNG.js} +1 -1
- package/dist/assets/{chunk-2Q5K7J3B-HV4zmsEe.js → chunk-2Q5K7J3B-CSMQbOQx.js} +1 -1
- package/dist/assets/{chunk-5RXB4S5H-BAwutJoU.js → chunk-5RXB4S5H-DFW9zj_c.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-B9QAJPrv.js → chunk-5VM5RSS4-DBpthDmq.js} +1 -1
- package/dist/assets/{chunk-6Q2QTUOP-BOIW8bzI.js → chunk-6Q2QTUOP-BcUSTdgD.js} +1 -1
- package/dist/assets/{chunk-GF5L2VYU-DD13o00-.js → chunk-GF5L2VYU-4m17UUNv.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-CFBm23VK.js → chunk-JWPE2WC7-BQbCGGN3.js} +1 -1
- package/dist/assets/{chunk-KBJHAD2P-C0i0v8Op.js → chunk-KBJHAD2P-BSUyigrP.js} +1 -1
- package/dist/assets/{chunk-RYQCIY6F-DfeK0taV.js → chunk-RYQCIY6F-IDx48cke.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-BKWvf-QE.js → chunk-XXDRQBXY-CkptWWiw.js} +1 -1
- package/dist/assets/classDiagram-JCYQIIEL-Zuuh6WIs.js +1 -0
- package/dist/assets/classDiagram-v2-OCEON4UE-Zuuh6WIs.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-CBE8oM7L.js → cose-bilkent-JH36ORCC-Di3RMB4X.js} +1 -1
- package/dist/assets/{cynefin-VYW2F7L2-DziGp35A.js → cynefin-VYW2F7L2-DBEP-JNm.js} +1 -1
- package/dist/assets/{cynefinDiagram-MW4NZA55-CNvtHl39.js → cynefinDiagram-MW4NZA55-DCa5bQ3E.js} +1 -1
- package/dist/assets/{dagre-VZM6K2ZE-Bz9lsU7m.js → dagre-VZM6K2ZE-N0N_WSj2.js} +1 -1
- package/dist/assets/{diagram-7IWD3JNH-CV7D3VSd.js → diagram-7IWD3JNH-wYn0p431.js} +1 -1
- package/dist/assets/{diagram-B4RE2ZJO-Dj4EjDNC.js → diagram-B4RE2ZJO-Cse-jrwQ.js} +1 -1
- package/dist/assets/{diagram-LBJQPF4R-wJ6FHvf-.js → diagram-LBJQPF4R-Byhmgq5m.js} +1 -1
- package/dist/assets/{diagram-Q27KOJAE-DMFYMhOB.js → diagram-Q27KOJAE-BNsUkxU7.js} +1 -1
- package/dist/assets/{diagram-UB23O5K3-DeBSbWAI.js → diagram-UB23O5K3-C3QHYX7n.js} +1 -1
- package/dist/assets/{ebnfDiagram-BXEA7PRR-2NnJSGhT.js → ebnfDiagram-BXEA7PRR-BP6B3t_z.js} +1 -1
- package/dist/assets/{erDiagram-JOGREHBK-DrSlg8hr.js → erDiagram-JOGREHBK-CjYRNWDj.js} +1 -1
- package/dist/assets/feature-chat-CenAll-X.js +88 -0
- package/dist/assets/{feature-workspace-CAB6bgPy.js → feature-workspace-X9kJZ4EG.js} +2 -2
- package/dist/assets/{flowDiagram-UKHOOZJN-C0pejU6W.js → flowDiagram-UKHOOZJN-4H-yy-hv.js} +1 -1
- package/dist/assets/{ganttDiagram-PKOTCBZU-BM0VCUUz.js → ganttDiagram-PKOTCBZU-CEjsxzjF.js} +1 -1
- package/dist/assets/{gitGraphDiagram-DS77QQ5N-SbLG0c5_.js → gitGraphDiagram-DS77QQ5N-CNEvMqer.js} +1 -1
- package/dist/assets/{index-Btkf0_rU.js → index-BIKUx4Nd.js} +1 -1
- package/dist/assets/{index-Gqazqfs3.js → index-BnTqIKbW.js} +1 -1
- package/dist/assets/{index-nyrkoQK6.js → index-CblFvRGn.js} +2 -2
- package/dist/assets/{index-BflGfU1C.js → index-Dn_5mZup.js} +1 -1
- package/dist/assets/{infoDiagram-6WML65LV-Cf5DSa66.js → infoDiagram-6WML65LV-CaQEYwl_.js} +1 -1
- package/dist/assets/{ishikawaDiagram-WSZJBQD7-DwyFutKy.js → ishikawaDiagram-WSZJBQD7-jvmcvqKv.js} +1 -1
- package/dist/assets/{journeyDiagram-NVQOT4AX-Df0FRhLo.js → journeyDiagram-NVQOT4AX-D3t6ZEEp.js} +1 -1
- package/dist/assets/{kanban-definition-27J2QSJJ-HmpbjrZz.js → kanban-definition-27J2QSJJ-DndXvXlL.js} +1 -1
- package/dist/assets/{linear-DOM01LBe.js → linear-CRI9G1bv.js} +1 -1
- package/dist/assets/{mermaid.core-C2Ma-_S6.js → mermaid.core-Nej1-0Ug.js} +4 -4
- package/dist/assets/{mindmap-definition-FAOFIHXS-B4GOIn76.js → mindmap-definition-FAOFIHXS-7fzz0Exr.js} +1 -1
- package/dist/assets/{pegDiagram-VL7TDLO6-BHur7aH2.js → pegDiagram-VL7TDLO6-DTiRFRfv.js} +1 -1
- package/dist/assets/{pieDiagram-7S7Q4E2Y-Cw0UELLV.js → pieDiagram-7S7Q4E2Y-BU4cScsB.js} +1 -1
- package/dist/assets/{quadrantDiagram-CIZ2JOQS-CB2BrX3g.js → quadrantDiagram-CIZ2JOQS-Cc13j5j0.js} +1 -1
- package/dist/assets/{railroadDiagram-AXF67PYL-DPYZYmLX.js → railroadDiagram-AXF67PYL-CfB467SJ.js} +1 -1
- package/dist/assets/{requirementDiagram-LRYGKXZP-DSX4IJ1n.js → requirementDiagram-LRYGKXZP-BddSRoQa.js} +1 -1
- package/dist/assets/{sankeyDiagram-W5VNT64P-TenC3ZQo.js → sankeyDiagram-W5VNT64P-D33-L55R.js} +1 -1
- package/dist/assets/{sequenceDiagram-SI44F4Z6-DltGsf3F.js → sequenceDiagram-SI44F4Z6-BP7gKO1m.js} +1 -1
- package/dist/assets/{sizeCapture-X5ZJPWSS-D7llwbJZ.js → sizeCapture-X5ZJPWSS-DLmxTSos.js} +1 -1
- package/dist/assets/{stateDiagram-OKZ733FA-C-hAvbnY.js → stateDiagram-OKZ733FA-2fN5h0fl.js} +1 -1
- package/dist/assets/stateDiagram-v2-UEYNNEHI-ddGXuRHz.js +1 -0
- package/dist/assets/{swimlanes-SLNWSIFB-DWD30fv6.js → swimlanes-SLNWSIFB-m6QzM3CR.js} +2 -2
- package/dist/assets/swimlanesDiagram-ULZ7WXOC-DNmdh3Nm.js +8 -0
- package/dist/assets/{timeline-definition-Z64GVDOM-quWmimSE.js → timeline-definition-Z64GVDOM-B-4XL-3f.js} +1 -1
- package/dist/assets/{vennDiagram-T6HMQDX7-aUQcm8h5.js → vennDiagram-T6HMQDX7-C-2U26ta.js} +1 -1
- package/dist/assets/{wardleyDiagram-T6FBY63Y-BZ0bwsFQ.js → wardleyDiagram-T6FBY63Y-BM4F1_6i.js} +1 -1
- package/dist/assets/{xychartDiagram-ELKLHX3M-DOVzAq63.js → xychartDiagram-ELKLHX3M-BWBCnHJm.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/sw.js +1 -1
- package/package.json +5 -1
- package/dist/assets/channel-BGDgNNQz.js +0 -1
- package/dist/assets/classDiagram-JCYQIIEL-C2SNM4oy.js +0 -1
- package/dist/assets/classDiagram-v2-OCEON4UE-C2SNM4oy.js +0 -1
- package/dist/assets/feature-chat-CvOCyaLe.js +0 -88
- package/dist/assets/stateDiagram-v2-UEYNNEHI-DaYSFcRQ.js +0 -1
- package/dist/assets/swimlanesDiagram-ULZ7WXOC-LTkF2T6t.js +0 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/StandaloneShell-
|
|
2
|
-
import{r as n,j as e,b as ys,c as qt}from"./vendor-react-C2GTiUCy.js";import{X as ge,P as po,S as as,T as Oe,a as xo,L as ve,C as ns,_ as ke,b as et,M as ho,c as go,B as fo,d as bo,e as yo,f as Ir,g as os,R as is,h as Ee,i as vo,F as ht,j as ft,A as Xe,k as ls,l as xr,m as jo,n as Aa,E as Rr,o as Fe,p as Ar,q as La,r as Te,s as ar,t as cs,u as Lr,v as Ma,w as Fa,G as Ft,K as hr,x as wo,y as _a,z as Oa,D as No,H as gr,I as Da,J as ds,N as Lt,O as nr,Q as ko,U as $a,Z as So,V as Co,W as Vs,Y as Mr,$ as Fr,a0 as Po,a1 as Eo,a2 as To,a3 as Io,a4 as fr,a5 as Ro,a6 as Mt,a7 as za,a8 as us,a9 as Ua,aa as Ga,ab as _r,ac as Or,ad as Ao,ae as Lo,af as or,ag as Mo,ah as Fo,ai as _o,aj as Oo,ak as Do,al as $o,am as zo,an as Uo,ao as Go}from"./vendor-ui-CAUHSABu.js";import{u as ce}from"./vendor-i18n-B6HjLCnN.js";import{p as Vo}from"./vendor-data-DsEZeNPr.js";import{M as Ko,r as Bo}from"./vendor-markdown-DkITEES2.js";const Va=n.createContext(),br=()=>{const t=n.useContext(Va);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},Em=({children:t})=>{const[s,r]=n.useState(()=>{const i=localStorage.getItem("theme");return i?i==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1});n.useEffect(()=>{if(s){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const i=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');i&&i.setAttribute("content","black-translucent");const l=document.querySelector('meta[name="theme-color"]');l&&l.setAttribute("content","#141414")}else{document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light");const i=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');i&&i.setAttribute("content","default");const l=document.querySelector('meta[name="theme-color"]');l&&l.setAttribute("content","#f6f4ef")}},[s]),n.useEffect(()=>{if(!window.matchMedia)return;const i=window.matchMedia("(prefers-color-scheme: dark)"),l=c=>{localStorage.getItem("theme")||r(c.matches)};return i.addEventListener("change",l),()=>i.removeEventListener("change",l)},[]);const o={isDarkMode:s,toggleDarkMode:()=>{r(i=>!i)}};return e.jsx(Va.Provider,{value:o,children:t})},Wo={},he=Wo?.VITE_IS_PLATFORM==="true",ir="auth-token-refreshed",lr="auth-session-expired",ms=t=>typeof t=="string"&&/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(t),Ka=t=>{if(!ms(t))return null;try{const s=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=s.padEnd(s.length+(4-s.length%4)%4,"="),a=JSON.parse(atob(r));return typeof a.iat!="number"||!Number.isFinite(a.iat)||typeof a.exp!="number"||!Number.isFinite(a.exp)?null:{issuedAt:a.iat*1e3,expiresAt:a.exp*1e3}}catch{return null}},Ho=6e4,Ba=t=>{const s=Ka(t);return s?Date.now()>=s.expiresAt+Ho:!1},Dr=t=>{const s=Ka(t);if(!s)return null;const r=s.issuedAt+(s.expiresAt-s.issuedAt)/2;return Math.max(0,r-Date.now())},yr=()=>{localStorage.removeItem("auth-token"),typeof window<"u"&&window.dispatchEvent(new Event(lr))},vr=()=>{const t=localStorage.getItem("auth-token");return t&&Ba(t)?(yr(),null):t},Wa=t=>ms(t)?(localStorage.setItem("auth-token",t),typeof window<"u"&&window.dispatchEvent(new CustomEvent(ir,{detail:t})),!0):!1,z=(t,s={})=>{const r=vr(),a={};return s.body instanceof FormData||(a["Content-Type"]="application/json"),!he&&r&&(a.Authorization=`Bearer ${r}`),fetch(t,{...s,headers:{...a,...s.headers}}).then(o=>{const i=o.headers.get("X-Refreshed-Token");return i&&Wa(i),o.headers.get("X-Auth-Error")&&yr(),o})},ue={auth:{status:()=>fetch("/api/auth/status"),login:(t,s)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})}),register:(t,s)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})}),refresh:()=>z("/api/auth/refresh",{method:"POST"}),user:()=>z("/api/auth/user"),logout:()=>z("/api/auth/logout",{method:"POST"})},projects:()=>z("/api/projects"),archivedProjects:()=>z("/api/projects/archived"),projectSessions:(t,{limit:s=20,offset:r=0}={})=>{const a=new URLSearchParams;return a.set("limit",String(s)),a.set("offset",String(r)),z(`/api/projects/${encodeURIComponent(t)}/sessions?${a.toString()}`)},projectTaskmaster:t=>z(`/api/projects/${encodeURIComponent(t)}/taskmaster`),unifiedSessionMessages:(t,s="claude",{limit:r=null,offset:a=0}={})=>{const o=new URLSearchParams;r!==null&&(o.append("limit",String(r)),o.append("offset",String(a)));const i=o.toString();return z(`/api/providers/sessions/${encodeURIComponent(t)}/messages${i?`?${i}`:""}`)},renameProject:(t,s)=>z(`/api/projects/${t}/rename`,{method:"PUT",body:JSON.stringify({displayName:s})}),restoreProject:t=>z(`/api/projects/${encodeURIComponent(t)}/restore`,{method:"POST"}),deleteSession:(t,s=!1)=>{const r=new URLSearchParams;s&&r.set("force","true");const a=r.toString();return z(`/api/providers/sessions/${t}${a?`?${a}`:""}`,{method:"DELETE"})},getArchivedSessions:()=>z("/api/providers/sessions/archived"),sessionDetails:t=>z(`/api/providers/sessions/${encodeURIComponent(t)}`),runningSessions:()=>z("/api/providers/sessions/running"),recentConversations:({limit:t=40,offset:s=0}={})=>{const r=new URLSearchParams({limit:String(t),offset:String(s)});return z(`/api/providers/sessions/recent?${r.toString()}`)},providerSessionId:t=>z(`/api/providers/sessions/${encodeURIComponent(t)}/provider-id`),restoreSession:t=>z(`/api/providers/sessions/${t}/restore`,{method:"POST"}),renameSession:(t,s)=>z(`/api/providers/sessions/${t}`,{method:"PUT",body:JSON.stringify({summary:s})}),deleteProject:(t,s=!1)=>{const r=new URLSearchParams;s&&r.set("force","true");const a=r.toString();return z(`/api/projects/${t}${a?`?${a}`:""}`,{method:"DELETE"})},searchConversationsUrl:(t,s=50)=>{const r=vr(),a=new URLSearchParams({q:t,limit:String(s)});return r&&a.set("token",r),`/api/providers/search/sessions?${a.toString()}`},createProject:t=>z("/api/projects/create-project",{method:"POST",body:JSON.stringify(t)}),migrateLegacyProjectStars:t=>z("/api/projects/migrate-legacy-stars",{method:"POST",body:JSON.stringify({projectIds:t})}),toggleProjectStar:t=>z(`/api/projects/${encodeURIComponent(t)}/toggle-star`,{method:"POST"}),readFile:(t,s)=>z(`/api/file-tree/projects/${t}/file?filePath=${encodeURIComponent(s)}`),readFileBlob:(t,s)=>z(`/api/file-tree/projects/${t}/files/content?path=${encodeURIComponent(s)}`),saveFile:(t,s,r)=>z(`/api/file-tree/projects/${t}/file`,{method:"PUT",body:JSON.stringify({filePath:s,content:r})}),getFiles:(t,s={})=>z(`/api/file-tree/projects/${t}/files?respectGitignore=true`,s),getMentionableFiles:(t,s={})=>z(`/api/file-tree/projects/${t}/files?respectGitignore=true`,s),createFile:(t,{path:s,type:r,name:a})=>z(`/api/file-tree/projects/${t}/files/create`,{method:"POST",body:JSON.stringify({path:s,type:r,name:a})}),renameFile:(t,{oldPath:s,newName:r})=>z(`/api/file-tree/projects/${t}/files/rename`,{method:"PUT",body:JSON.stringify({oldPath:s,newName:r})}),deleteFile:(t,{path:s,type:r})=>z(`/api/file-tree/projects/${t}/files`,{method:"DELETE",body:JSON.stringify({path:s,type:r})}),uploadFiles:(t,s)=>z(`/api/file-tree/projects/${t}/files/upload`,{method:"POST",body:s,headers:{}}),taskmaster:{init:t=>z(`/api/taskmaster/init/${t}`,{method:"POST"}),addTask:(t,{prompt:s,title:r,description:a,priority:o,dependencies:i})=>z(`/api/taskmaster/add-task/${t}`,{method:"POST",body:JSON.stringify({prompt:s,title:r,description:a,priority:o,dependencies:i})}),parsePRD:(t,{fileName:s,numTasks:r,append:a})=>z(`/api/taskmaster/parse-prd/${t}`,{method:"POST",body:JSON.stringify({fileName:s,numTasks:r,append:a})}),getTemplates:()=>z("/api/taskmaster/prd-templates"),applyTemplate:(t,{templateId:s,fileName:r,customizations:a})=>z(`/api/taskmaster/apply-template/${t}`,{method:"POST",body:JSON.stringify({templateId:s,fileName:r,customizations:a})}),updateTask:(t,s,r)=>z(`/api/taskmaster/update-task/${t}/${s}`,{method:"PUT",body:JSON.stringify(r)})},browseFilesystem:(t=null)=>{const s=new URLSearchParams;return t&&s.append("path",t),z(`/api/file-tree/browse-filesystem?${s}`)},createFolder:t=>z("/api/file-tree/create-folder",{method:"POST",body:JSON.stringify({path:t})}),user:{gitConfig:()=>z("/api/user/git-config"),updateGitConfig:(t,s)=>z("/api/user/git-config",{method:"POST",body:JSON.stringify({gitName:t,gitEmail:s})}),onboardingStatus:()=>z("/api/user/onboarding-status"),completeOnboarding:()=>z("/api/user/complete-onboarding",{method:"POST"})},get:t=>z(`/api${t}`),post:(t,s)=>z(`/api${t}`,{method:"POST",...s instanceof FormData?{body:s}:{body:JSON.stringify(s)}}),put:(t,s)=>z(`/api${t}`,{method:"PUT",body:JSON.stringify(s)}),delete:(t,s={})=>z(`/api${t}`,{method:"DELETE",...s})},Ha="auth-token",Ve={authStatusCheckFailed:"Failed to check authentication status",loginFailed:"Login failed",registrationFailed:"Registration failed",networkError:"Network error. Please try again.",sessionExpired:"Your session expired. Please log in again."};async function it(t){try{return await t.json()}catch{return null}}function $r(t,s){return t?typeof t.error=="string"?t.error:typeof t.error=="object"&&t.error!==null&&"message"in t.error&&typeof t.error.message=="string"?t.error.message:typeof t.message=="string"?t.message:s:s}const Ja=n.createContext(null),Jo=()=>localStorage.getItem(Ha),zr=t=>{Wa(t)},qo=()=>{localStorage.removeItem(Ha)};function qa(){const t=n.useContext(Ja);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t}function Tm({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(()=>Jo()),[i,l]=n.useState(!0),[c,m]=n.useState(!1),[d,u]=n.useState(!0),[x,h]=n.useState(null),p=n.useCallback((C,T)=>{r(C),o(T),zr(T)},[]),f=n.useCallback(()=>{r(null),o(null),qo()},[]),b=n.useCallback(async()=>{try{const C=await ue.user.onboardingStatus();if(!C.ok)return;const T=await it(C);u(!!T?.hasCompletedOnboarding)}catch(C){console.error("Error checking onboarding status:",C),u(!0)}},[]),g=n.useCallback(async()=>{await b()},[b]),v=n.useCallback(async()=>{if(!(he||!a||!s))try{const C=await ue.auth.refresh();if(!C.ok)return;const T=await it(C);ms(T?.token)&&(o(T.token),zr(T.token))}catch(C){console.warn("[Auth] Session refresh failed:",C)}},[a,s]);n.useEffect(()=>{const C=I=>{const j=I.detail;ms(j)&&o(j)},T=()=>{f(),h(Ve.sessionExpired)};return window.addEventListener(ir,C),window.addEventListener(lr,T),()=>{window.removeEventListener(ir,C),window.removeEventListener(lr,T)}},[f]);const S=n.useCallback(async()=>{try{l(!0),h(null);const C=await ue.auth.status();if((await it(C))?.needsSetup){m(!0);return}if(m(!1),!a)return;const I=await ue.auth.user();if(!I.ok){f();return}const j=await it(I);if(!j?.user){f();return}r(j.user),await b()}catch(C){console.error("[Auth] Auth status check failed:",C),h(Ve.authStatusCheckFailed)}finally{l(!1)}},[b,f,a]);n.useEffect(()=>{if(he){r({username:"platform-user"}),m(!1),b().finally(()=>{l(!1)});return}S()},[S,b]),n.useEffect(()=>{if(he||!a||!s)return;const C=()=>{const $=Dr(a);$!==null&&$<=0&&v()},T=()=>{document.visibilityState==="visible"&&C()},I=Dr(a),j=I===null?null:window.setTimeout(()=>{v()},I);return window.addEventListener("focus",C),document.addEventListener("visibilitychange",T),()=>{j!==null&&window.clearTimeout(j),window.removeEventListener("focus",C),document.removeEventListener("visibilitychange",T)}},[v,a,s]);const k=n.useCallback(async(C,T)=>{try{h(null);const I=await ue.auth.login(C,T),j=await it(I);if(!I.ok||!j?.token||!j.user){const $=$r(j,Ve.loginFailed);return h($),{success:!1,error:$}}return p(j.user,j.token),m(!1),await b(),{success:!0}}catch(I){return console.error("Login error:",I),h(Ve.networkError),{success:!1,error:Ve.networkError}}},[b,p]),y=n.useCallback(async(C,T)=>{try{h(null);const I=await ue.auth.register(C,T),j=await it(I);if(!I.ok||!j?.token||!j.user){const $=$r(j,Ve.registrationFailed);return h($),{success:!1,error:$}}return p(j.user,j.token),m(!1),await b(),{success:!0}}catch(I){return console.error("Registration error:",I),h(Ve.networkError),{success:!1,error:Ve.networkError}}},[b,p]),P=n.useCallback(()=>{f()},[f]),E=n.useMemo(()=>({user:s,token:a,isLoading:i,needsSetup:c,hasCompletedOnboarding:d,error:x,login:k,register:y,logout:P,refreshOnboardingStatus:g}),[x,d,i,k,P,c,g,y,a,s]);return e.jsx(Ja.Provider,{value:E,children:t})}const Qo=["claude","cursor","codex","opencode"],Yo={claude:"/api/providers/claude/auth/status",cursor:"/api/providers/cursor/auth/status",codex:"/api/providers/codex/auth/status",opencode:"/api/providers/opencode/auth/status"},Zo=(t=!0)=>({claude:{authenticated:!1,email:null,method:null,error:null,loading:t},cursor:{authenticated:!1,email:null,method:null,error:null,loading:t},codex:{authenticated:!1,email:null,method:null,error:null,loading:t},opencode:{authenticated:!1,email:null,method:null,error:null,loading:t}}),Xo="Failed to check authentication status",ei="Unknown error",ti=t=>t instanceof Error?t.message:ei,si=(t,s=null)=>({authenticated:!!t.authenticated,email:t.email??null,method:t.method??null,error:t.error??s,loading:!1});function ri({initialLoading:t=!0}={}){const[s,r]=n.useState(()=>Zo(t)),a=n.useCallback(c=>{r(m=>({...m,[c]:{...m[c],loading:!0,error:null}}))},[]),o=n.useCallback((c,m)=>{r(d=>({...d,[c]:m}))},[]),i=n.useCallback(async c=>{a(c);try{const m=await z(Yo[c]);if(!m.ok){const x={authenticated:!1,email:null,method:null,loading:!1,error:Xo};return o(c,x),x}const d=await m.json(),u=si(d.data);return o(c,u),u}catch(m){console.error(`Error checking ${c} auth status:`,m);const d={authenticated:!1,email:null,method:null,loading:!1,error:ti(m)};return o(c,d),d}},[a,o]),l=n.useCallback(async(c=Qo)=>{await Promise.all(c.map(m=>i(m)))},[i]);return{providerAuthStatus:s,setProviderAuthStatus:r,checkProviderAuthStatus:i,refreshProviderAuthStatuses:l}}const ai="modulepreload",ni=function(t){return"/"+t},Ur={},oi=function(s,r,a){let o=Promise.resolve();if(r&&r.length>0){let m=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");o=m(r.map(d=>{if(d=ni(d),d in Ur)return;Ur[d]=!0;const u=d.endsWith(".css"),x=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${x}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":ai,u||(h.as="script"),h.crossOrigin="",h.href=d,c&&h.setAttribute("nonce",c),document.head.appendChild(h),u)return new Promise((p,f)=>{h.addEventListener("load",p),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return o.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return s().catch(i)})},ii=n.lazy(()=>oi(()=>import("./StandaloneShell-BkuUCPZP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]))),li={projectId:"default",displayName:"default",fullPath:he?"/workspace":"",path:he?"/workspace":""},ci=({provider:t,customCommand:s,isAuthenticated:r})=>s||(t==="claude"?"claude --dangerously-skip-permissions /login":t==="cursor"?"cursor-agent login":t==="codex"?he?"codex login --device-auth":"codex login":t==="opencode"?"opencode auth login":"claude --dangerously-skip-permissions /login"),di=t=>t==="claude"?"Claude CLI Login":t==="cursor"?"Cursor CLI Login":t==="codex"?"Codex CLI Login":t==="opencode"?"OpenCode CLI Login":"Claude CLI Login";function ui({isOpen:t,onClose:s,provider:r="claude",onComplete:a,customCommand:o,isAuthenticated:i=!1}){if(!t)return null;const l=ci({provider:r,customCommand:o,isAuthenticated:i}),c=di(r),m=d=>{a?.(d)};return e.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black bg-opacity-50 max-md:items-stretch max-md:justify-stretch",children:e.jsxs("div",{className:"flex h-3/4 w-full max-w-4xl flex-col rounded-lg bg-white shadow-xl dark:bg-gray-800 max-md:m-0 max-md:h-full max-md:max-w-none max-md:rounded-none md:m-4 md:h-3/4 md:max-w-4xl md:rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c}),e.jsx("button",{onClick:s,className:"text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-gray-300","aria-label":"Close login modal",children:e.jsx(ge,{className:"h-6 w-6"})})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"h-full w-full bg-gray-900"}),children:e.jsx(ii,{project:li,command:l,onComplete:m,minimal:!0})})})]})})}const mi=({className:t="w-5 h-5"})=>e.jsxs("svg",{viewBox:"0 0 512 509.64",role:"img","aria-label":"Claude",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{fill:"#D77655",d:"M115.612 0h280.775C459.974 0 512 52.026 512 115.612v278.415c0 63.587-52.026 115.612-115.613 115.612H115.612C52.026 509.639 0 457.614 0 394.027V115.612C0 52.026 52.026 0 115.612 0z"}),e.jsx("path",{fill:"#FCF2EE",fillRule:"nonzero",d:"M142.27 316.619l73.655-41.326 1.238-3.589-1.238-1.996-3.589-.001-12.31-.759-42.084-1.138-36.498-1.516-35.361-1.896-8.897-1.895-8.34-10.995.859-5.484 7.482-5.03 10.717.935 23.683 1.617 35.537 2.452 25.782 1.517 38.193 3.968h6.064l.86-2.451-2.073-1.517-1.618-1.517-36.776-24.922-39.81-26.338-20.852-15.166-11.273-7.683-5.687-7.204-2.451-15.721 10.237-11.273 13.75.935 3.513.936 13.928 10.716 29.749 23.027 38.848 28.612 5.687 4.727 2.275-1.617.278-1.138-2.553-4.271-21.13-38.193-22.546-38.848-10.035-16.101-2.654-9.655c-.935-3.968-1.617-7.304-1.617-11.374l11.652-15.823 6.445-2.073 15.545 2.073 6.547 5.687 9.655 22.092 15.646 34.78 24.265 47.291 7.103 14.028 3.791 12.992 1.416 3.968 2.449-.001v-2.275l1.997-26.641 3.69-32.707 3.589-42.084 1.239-11.854 5.863-14.206 11.652-7.683 9.099 4.348 7.482 10.716-1.036 6.926-4.449 28.915-8.72 45.294-5.687 30.331h3.313l3.792-3.791 15.342-20.372 25.782-32.227 11.374-12.789 13.27-14.129 8.517-6.724 16.1-.001 11.854 17.617-5.307 18.199-16.581 21.029-13.75 17.819-19.716 26.54-12.309 21.231 1.138 1.694 2.932-.278 44.536-9.479 24.062-4.347 28.714-4.928 12.992 6.066 1.416 6.167-5.106 12.613-30.71 7.583-36.018 7.204-53.636 12.689-.657.48.758.935 24.164 2.275 10.337.556h25.301l47.114 3.514 12.309 8.139 7.381 9.959-1.238 7.583-18.957 9.655-25.579-6.066-59.702-14.205-20.474-5.106-2.83-.001v1.694l17.061 16.682 31.266 28.233 39.152 36.397 1.997 8.999-5.03 7.102-5.307-.758-34.401-25.883-13.27-11.651-30.053-25.302-1.996-.001v2.654l6.926 10.136 36.574 54.975 1.895 16.859-2.653 5.485-9.479 3.311-10.414-1.895-21.408-30.054-22.092-33.844-17.819-30.331-2.173 1.238-10.515 113.261-4.929 5.788-11.374 4.348-9.478-7.204-5.03-11.652 5.03-23.027 6.066-30.052 4.928-23.886 4.449-29.674 2.654-9.858-.177-.657-2.173.278-22.37 30.71-34.021 45.977-26.919 28.815-6.445 2.553-11.173-5.789 1.037-10.337 6.243-9.2 37.257-47.392 22.47-29.371 14.508-16.961-.101-2.451h-.859l-98.954 64.251-17.618 2.275-7.583-7.103.936-11.652 3.589-3.791 29.749-20.474-.101.102.024.101z"})]}),pi=({className:t="w-5 h-5"})=>e.jsx("svg",{viewBox:"100 100 520 520",role:"img","aria-label":"Codex",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M304.246 294.611V249.028C304.246 245.189 305.687 242.309 309.044 240.392L400.692 187.612C413.167 180.415 428.042 177.058 443.394 177.058C500.971 177.058 537.44 221.682 537.44 269.182C537.44 272.54 537.44 276.379 536.959 280.218L441.954 224.558C436.197 221.201 430.437 221.201 424.68 224.558L304.246 294.611ZM518.245 472.145V363.224C518.245 356.505 515.364 351.707 509.608 348.349L389.174 278.296L428.519 255.743C431.877 253.826 434.757 253.826 438.115 255.743L529.762 308.523C556.154 323.879 573.905 356.505 573.905 388.171C573.905 424.636 552.315 458.225 518.245 472.141V472.145ZM275.937 376.182L236.592 353.152C233.235 351.235 231.794 348.354 231.794 344.515V238.956C231.794 187.617 271.139 148.749 324.4 148.749C344.555 148.749 363.264 155.468 379.102 167.463L284.578 222.164C278.822 225.521 275.942 230.319 275.942 237.039V376.186L275.937 376.182ZM360.626 425.122L304.246 393.455V326.283L360.626 294.616L417.002 326.283V393.455L360.626 425.122ZM396.852 570.989C376.698 570.989 357.989 564.27 342.151 552.276L436.674 497.574C442.431 494.217 445.311 489.419 445.311 482.699V343.552L485.138 366.582C488.495 368.499 489.936 371.379 489.936 375.219V480.778C489.936 532.117 450.109 570.985 396.852 570.985V570.989ZM283.134 463.99L191.486 411.211C165.094 395.854 147.343 363.229 147.343 331.562C147.343 294.616 169.415 261.509 203.48 247.593V356.991C203.48 363.71 206.361 368.508 212.117 371.866L332.074 441.437L292.729 463.99C289.372 465.907 286.491 465.907 283.134 463.99ZM277.859 542.68C223.639 542.68 183.813 501.895 183.813 451.514C183.813 447.675 184.294 443.836 184.771 439.997L279.295 494.698C285.051 498.056 290.812 498.056 296.568 494.698L417.002 425.127V470.71C417.002 474.549 415.562 477.429 412.204 479.346L320.557 532.126C308.081 539.323 293.206 542.68 277.854 542.68H277.859ZM396.852 599.776C454.911 599.776 503.37 558.513 514.41 503.812C568.149 489.896 602.696 439.515 602.696 388.176C602.696 354.587 588.303 321.962 562.392 298.45C564.791 288.373 566.231 278.296 566.231 268.224C566.231 199.611 510.571 148.267 446.274 148.267C433.322 148.267 420.846 150.184 408.37 154.505C386.775 133.392 357.026 119.958 324.4 119.958C266.342 119.958 217.883 161.22 206.843 215.921C153.104 229.837 118.557 280.218 118.557 331.557C118.557 365.146 132.95 397.771 158.861 421.283C156.462 431.36 155.022 441.437 155.022 451.51C155.022 520.123 210.682 571.466 274.978 571.466C287.931 571.466 300.407 569.549 312.883 565.228C334.473 586.341 364.222 599.776 396.852 599.776Z",fill:"currentColor"})}),xi=({className:t="w-5 h-5"})=>e.jsxs("svg",{viewBox:"0 0 24 24",role:"img","aria-label":"Cursor",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M11.925 24l10.425-6-10.425-6L1.5 18l10.425 6z",fill:"currentColor",opacity:".39"}),e.jsx("path",{d:"M22.35 18V6L11.925 0v12l10.425 6z",fill:"currentColor",opacity:".8"}),e.jsx("path",{d:"M11.925 0L1.5 6v12l10.425-6V0z",fill:"currentColor",opacity:".6"}),e.jsx("path",{d:"M22.35 6L11.925 24V12L22.35 6z",fill:"currentColor",opacity:".72"}),e.jsx("path",{d:"M22.35 6l-10.425 6L1.5 6h20.85z",fill:"currentColor",opacity:".95"})]}),hi=({className:t="w-5 h-5"})=>e.jsxs("svg",{viewBox:"0 0 24 24",role:"img","aria-label":"OpenCode",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2.5",y:"2.5",width:"19",height:"19",rx:"4",className:"fill-foreground"}),e.jsx("path",{d:"M8.1 8.1 4.9 12l3.2 3.9M15.9 8.1l3.2 3.9-3.2 3.9M13.2 6.9l-2.4 10.2",className:"stroke-background",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round"})]});function _e({provider:t="claude",className:s="w-5 h-5"}){return t==="cursor"?e.jsx(xi,{className:s}):t==="codex"?e.jsx(pi,{className:s}):t==="opencode"?e.jsx(hi,{className:s}):e.jsx(mi,{className:s})}const Qa="ui-sans-serif, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji",Ya=n.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0}),Za=()=>{const t=n.useContext(Ya);if(!t)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return t},Im=({children:t})=>{const[s,r]=n.useState(()=>{const p=localStorage.getItem("tasks-enabled");return p!==null?JSON.parse(p):!0}),[a,o]=n.useState(null),[i,l]=n.useState(null),[c,m]=n.useState(null),[d,u]=n.useState(!0);n.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(s))},[s]),n.useEffect(()=>{setTimeout(async()=>{try{const f=await ue.get("/taskmaster/installation-status");if(f.ok){const b=await f.json();m(b),o(b.installation?.isInstalled||!1),l(b.isReady||!1);const g=localStorage.getItem("tasks-enabled");!b.installation?.isInstalled&&!g&&r(!1)}else console.error("Failed to check TaskMaster installation status"),o(!1),l(!1)}catch(f){console.error("Error checking TaskMaster installation:",f),o(!1),l(!1)}finally{u(!1)}},0)},[]);const h={tasksEnabled:s,setTasksEnabled:r,toggleTasksEnabled:()=>{r(p=>!p)},isTaskMasterInstalled:a,isTaskMasterReady:i,installationStatus:c,isCheckingInstallation:d};return e.jsx(Ya.Provider,{value:h,children:t})},Xa=n.createContext(null),gi=()=>{const t=n.useContext(Xa);if(!t)throw new Error("useWebSocket must be used within a WebSocketProvider");return t},fi=t=>{const s=window.location.protocol==="https:"?"wss:":"ws:";return he?`${s}//${window.location.host}/ws`:t?Ba(t)?(yr(),null):`${s}//${window.location.host}/ws?token=${encodeURIComponent(t)}`:null},bi=()=>{const t=n.useRef(null),s=n.useRef(!1),r=n.useRef(!1),a=n.useRef(new Set),[o,i]=n.useState(null),[l,c]=n.useState(!1),m=n.useRef(null),{isLoading:d,token:u,user:x}=qa(),h=n.useCallback(v=>{for(const S of a.current)try{S(v)}catch(k){console.error("WebSocket listener error:",k)}i(v)},[]),p=n.useCallback(()=>{if(!s.current&&!(!he&&(d||!x)))try{const v=fi(u);if(!v)return console.warn("No authentication token found for WebSocket connection");const S=new WebSocket(v);t.current=S,S.onopen=()=>{c(!0),r.current&&h({kind:"websocket_reconnected",timestamp:Date.now()}),r.current=!0},S.onmessage=k=>{try{const y=JSON.parse(k.data);h(y)}catch(y){console.error("Error parsing WebSocket message:",y)}},S.onclose=()=>{t.current===S&&(c(!1),t.current=null,m.current=setTimeout(()=>{s.current||p()},3e3))},S.onerror=k=>{console.error("WebSocket error:",k)}}catch(v){console.error("Error creating WebSocket connection:",v)}},[h,d,u,x]);n.useEffect(()=>{if(s.current=!1,!(!he&&(d||!x)))return p(),()=>{s.current=!0,m.current&&clearTimeout(m.current);const v=t.current;v&&(v.onopen=null,v.onmessage=null,v.onclose=null,v.onerror=null,v.close(),t.current=null)}},[p,d,x]);const f=n.useCallback(v=>{const S=t.current;S&&S.readyState===WebSocket.OPEN?S.send(JSON.stringify(v)):console.warn("WebSocket not connected")},[]),b=n.useCallback(v=>(a.current.add(v),()=>{a.current.delete(v)}),[]);return n.useMemo(()=>({ws:t.current,sendMessage:f,subscribe:b,latestMessage:o,isConnected:l}),[f,b,o,l])},Rm=({children:t})=>{const s=bi();return e.jsx(Xa.Provider,{value:s,children:t})},en=n.createContext(null);function tn(){const t=n.useContext(en);if(!t)throw new Error("usePlugins must be used within a PluginsProvider");return t}function Am({children:t}){const[s,r]=n.useState([]),[a,o]=n.useState(!0),[i,l]=n.useState(null),c=n.useCallback(async()=>{try{const h=await z("/api/plugins");if(h.ok){const p=await h.json();r(p.plugins||[]),l(null)}else{let p=`Failed to fetch plugins (${h.status})`;try{const f=await h.json();p=f.details||f.error||p}catch{p=h.statusText||p}l(p)}}catch(h){const p=h instanceof Error?h.message:"Failed to fetch plugins";l(p),console.error("[Plugins] Failed to fetch plugins:",h)}finally{o(!1)}},[]);n.useEffect(()=>{c()},[c]);const m=n.useCallback(async h=>{try{const p=await z("/api/plugins/install",{method:"POST",body:JSON.stringify({url:h})}),f=await p.json();return p.ok?(await c(),{success:!0}):{success:!1,error:f.details||f.error||"Install failed"}}catch(p){return{success:!1,error:p instanceof Error?p.message:"Install failed"}}},[c]),d=n.useCallback(async h=>{try{const p=await z(`/api/plugins/${encodeURIComponent(h)}`,{method:"DELETE"}),f=await p.json();return p.ok?(await c(),{success:!0}):{success:!1,error:f.details||f.error||"Uninstall failed"}}catch(p){return{success:!1,error:p instanceof Error?p.message:"Uninstall failed"}}},[c]),u=n.useCallback(async h=>{try{const p=await z(`/api/plugins/${encodeURIComponent(h)}/update`,{method:"POST"}),f=await p.json();return p.ok?(await c(),{success:!0}):{success:!1,error:f.details||f.error||"Update failed"}}catch(p){return{success:!1,error:p instanceof Error?p.message:"Update failed"}}},[c]),x=n.useCallback(async(h,p)=>{try{const f=await z(`/api/plugins/${encodeURIComponent(h)}/enable`,{method:"PUT",body:JSON.stringify({enabled:p})});if(!f.ok){let b=`Toggle failed (${f.status})`;try{const g=await f.json();b=g.details||g.error||b}catch{b=f.statusText||b}return{success:!1,error:b}}return await c(),{success:!0,error:null}}catch(f){return{success:!1,error:f instanceof Error?f.message:"Toggle failed"}}},[c]);return e.jsx(en.Provider,{value:{plugins:s,loading:a,pluginsError:i,refreshPlugins:c,installPlugin:m,uninstallPlugin:d,updatePlugin:u,togglePlugin:x},children:t})}const Gr=t=>typeof window>"u"?!1:window.innerWidth<t,Vr=()=>{if(typeof window>"u")return!1;const t=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!t.standalone||document.referrer.includes("android-app://")};function yi(t={}){const{mobileBreakpoint:s=768,trackMobile:r=!0,trackPWA:a=!0}=t,[o,i]=n.useState(()=>r?Gr(s):!1),[l,c]=n.useState(()=>a?Vr():!1);return n.useEffect(()=>{if(!r||typeof window>"u")return;const m=()=>{i(Gr(s))};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[s,r]),n.useEffect(()=>{if(!a||typeof window>"u")return;const m=window.matchMedia("(display-mode: standalone)"),d=()=>{c(Vr())};return d(),typeof m.addEventListener=="function"?(m.addEventListener("change",d),()=>{m.removeEventListener("change",d)}):(m.addListener(d),()=>{m.removeListener(d)})},[a]),{isMobile:o,isPWA:l}}const Ks="1.38.0",vi=(t,s)=>{const r=t.split(".").map(Number),a=s.split(".").map(Number);for(let o=0;o<Math.max(r.length,a.length);o++){const i=r[o]||0,l=a[o]||0;if(i!==l)return i-l}return 0},sn=(t,s)=>{const[r,a]=n.useState(!1),[o,i]=n.useState(null),[l,c]=n.useState(null),[m,d]=n.useState("git"),[u,x]=n.useState(null),[h,p]=n.useState(!1);return n.useEffect(()=>{(async()=>{try{const g=await(await fetch("/health")).json();(g.installMode==="npm"||g.installMode==="git")&&d(g.installMode),typeof g.version=="string"&&g.version.length>0&&(x(g.version),p(g.version!==Ks))}catch{}})()},[]),n.useEffect(()=>{const f=async()=>{try{const v=await(await fetch(`https://api.github.com/repos/${t}/${s}/releases/latest`)).json();if(v.tag_name){const S=v.tag_name.replace(/^v/,"");i(S),a(vi(S,Ks)>0),c({title:v.name||v.tag_name,body:v.body||"",htmlUrl:v.html_url||`https://github.com/${t}/${s}/releases/latest`,publishedAt:v.published_at})}else a(!1),i(null),c(null)}catch(g){console.error("Version check failed:",g),a(!1),i(null),c(null)}};f();const b=setInterval(f,300*1e3);return()=>clearInterval(b)},[t,s]),{updateAvailable:r,latestVersion:o,currentVersion:Ks,releaseInfo:l,installMode:m,runningVersion:u,restartRequired:h}},Ze={showRawParameters:!1,showThinking:!0,sendByCtrlEnter:!1,sidebarVisible:!0,voiceEnabled:!1},ps=Object.keys(Ze),ji=new Set(ps),Bs="ui-preferences:sync",xs=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return s},wi=(t,s)=>{try{const r=localStorage.getItem(t);if(r===null)return s;const a=JSON.parse(r);return xs(a,s)}catch{return s}},Ni=t=>{if(typeof window>"u")return Ze;try{const s=localStorage.getItem(t);if(s){const r=JSON.parse(s);if(r&&typeof r=="object"&&!Array.isArray(r)){const a=r;return ps.reduce((o,i)=>(o[i]=xs(a[i],Ze[i]),o),{...Ze})}}}catch{}return ps.reduce((s,r)=>(s[r]=wi(r,Ze[r]),s),{...Ze})};function ki(t,s){switch(s.type){case"set":{const{key:r,value:a}=s;if(!ji.has(r))return t;const o=xs(a,t[r]);return t[r]===o?t:{...t,[r]:o}}case"set_many":{const r=s.value||{};let a=!1;const o={...t};for(const i of ps){if(!(i in r))continue;const l=r[i],c=xs(l,t[i]);o[i]!==c&&(o[i]=c,a=!0)}return a?o:t}case"reset":return{...Ze,...s.value||{}};default:return t}}function rn(t="uiPreferences"){const s=n.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,a]=n.useReducer(ki,t,Ni);return n.useEffect(()=>{typeof window>"u"||(localStorage.setItem(t,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(Bs,{detail:{storageKey:t,sourceId:s.current,value:r}})))},[r,t]),n.useEffect(()=>{if(typeof window>"u")return;const c=u=>{!u||typeof u!="object"||Array.isArray(u)||a({type:"set_many",value:u})},m=u=>{if(!(u.key!==t||u.newValue===null))try{const x=JSON.parse(u.newValue);c(x)}catch{}},d=u=>{const h=u.detail;!h||h.storageKey!==t||h.sourceId===s.current||c(h.value)};return window.addEventListener("storage",m),window.addEventListener(Bs,d),()=>{window.removeEventListener("storage",m),window.removeEventListener(Bs,d)}},[t]),{preferences:r,setPreference:(c,m)=>{a({type:"set",key:c,value:m})},setPreferences:c=>{a({type:"set_many",value:c})},resetPreferences:c=>{a({type:"reset",value:c})},dispatch:a}}const jr=n.createContext(null),Qt={openFile:()=>{},openFileInEditor:()=>{},openSettings:()=>{},refreshProjects:()=>{}};function Lm({children:t}){const s=n.useRef({});return e.jsx(jr.Provider,{value:s,children:t})}function an(){const t=n.useContext(jr);return n.useMemo(()=>({openFile:s=>(t?.current.openFile??Qt.openFile)(s),openFileInEditor:s=>(t?.current.openFileInEditor??Qt.openFileInEditor)(s),openSettings:s=>(t?.current.openSettings??Qt.openSettings)(s),refreshProjects:()=>(t?.current.refreshProjects??Qt.refreshProjects)()}),[t])}function Mm(t){const s=n.useContext(jr),{openFile:r,openFileInEditor:a,openSettings:o,refreshProjects:i}=t;n.useEffect(()=>{if(!s)return;const l=s.current,c={...l};return r&&(l.openFile=r),a&&(l.openFileInEditor=a),o&&(l.openSettings=o),i&&(l.refreshProjects=i),()=>{r&&l.openFile===r&&(l.openFile=c.openFile),a&&l.openFileInEditor===a&&(l.openFileInEditor=c.openFileInEditor),o&&l.openSettings===o&&(l.openSettings=c.openSettings),i&&l.refreshProjects===i&&(l.refreshProjects=c.refreshProjects)}},[s,r,a,o,i])}const Rt=(t,s)=>{if(!t)return"";const r=new Date(t);if(Number.isNaN(r.getTime()))return"";const a=Math.floor(Math.max(0,s.getTime()-r.getTime())/6e4);if(a<1)return"<1m";if(a<60)return`${a}m`;const o=Math.floor(a/60);return o<24?`${o}hr`:`${Math.floor(o/24)}d`},Si=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},nn="starredProjects",Ci=()=>{try{const t=localStorage.getItem(nn);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s.map(r=>String(r).trim()).filter(r=>r.length>0):[]}catch{return[]}},Pi=()=>{try{localStorage.removeItem(nn)}catch{}},on=t=>String(t.createdAt||t.created_at||""),ln=t=>String(t.lastActivity||""),Ei=t=>{const s=t.__provider??t.provider;return typeof s=="string"&&s.trim()?s:"claude"},hs=t=>new Date(ln(t)||on(t)||0),Ti=(t,s)=>t.summary||t.name||s("projects.newSession"),Ii=t=>ln(t)||on(t),Ri=(t,s,r)=>{const a=hs(t);return{isActive:Math.floor((s.getTime()-a.getTime())/(1e3*60))<10,sessionName:Ti(t,r),sessionTime:Ii(t),messageCount:Number(t.messageCount||0)}},gs=t=>(t.sessions||[]).map(s=>({...s,__provider:Ei(s)})).sort((s,r)=>hs(r).getTime()-hs(s).getTime()),Kr=t=>{const s=gs(t);return s.length===0?new Date(0):s.reduce((r,a)=>{const o=hs(a);return o>r?o:r},new Date(0))},Ai=(t,s)=>{const r=[...t];return r.sort((a,o)=>{const i=!!a.isStarred,l=!!o.isStarred;return i&&!l?-1:!i&&l?1:s==="date"?Kr(o).getTime()-Kr(a).getTime():(a.displayName||a.projectId).localeCompare(o.displayName||o.projectId)}),r},Li=(t,s)=>{const r=s.trim().toLowerCase();return r?t.filter(a=>{const o=(a.displayName||a.projectId).toLowerCase(),i=(a.path||a.fullPath||"").toLowerCase();return o.includes(r)||i.includes(r)}):t},Mi=(t,s)=>{const r=!!t.taskmaster?.hasTaskmaster,a=!!(s?.hasMCPServer&&s?.isConfigured);return r&&a?"fully-configured":r?"taskmaster-only":a?"mcp-only":"not-configured"},Fi=t=>{const s=typeof t.fullPath=="string"&&t.fullPath.length>0?t.fullPath:typeof t.path=="string"?t.path:"";return{name:t.projectId,displayName:typeof t.displayName=="string"&&t.displayName.trim().length>0?t.displayName:t.projectId,fullPath:s,path:typeof t.path=="string"&&t.path.length>0?t.path:s}};function _i({projects:t,selectedProject:s,selectedSession:r,activeSessions:a,isLoading:o,isMobile:i,t:l,onRefresh:c,onProjectSelect:m,onSessionSelect:d,onSessionDelete:u,onLoadMoreSessions:x,onProjectDelete:h,setSidebarVisible:p,sidebarVisible:f}){const b=an(),[g,v]=n.useState(new Set),[S,k]=n.useState(null),[y,P]=n.useState(!1),[E,C]=n.useState(""),[T,I]=n.useState(new Set),[j,$]=n.useState(new Date),[G,K]=n.useState("name"),[M,X]=n.useState(!1),[H,B]=n.useState(null),[w,D]=n.useState(""),[L,O]=n.useState(""),[U,N]=n.useState(new Set),[A,ee]=n.useState(null),[V,ae]=n.useState(null),[de,te]=n.useState(!1),[q,ye]=n.useState("projects"),[se,ne]=n.useState(null),[re,Ie]=n.useState(!1),[Ss,Re]=n.useState(null),[De,Cs]=n.useState([]),[tt,Ps]=n.useState([]),[Es,_t]=n.useState(!1),[vt,Ts]=n.useState([]),[Is,Rs]=n.useState(0),[jt,As]=n.useState(!1),[Ls,Ot]=n.useState(!1),[wt,qe]=n.useState(!1),[Ms,Dt]=n.useState(!1),[Se,Fs]=n.useState(""),[$e,st]=n.useState(new Map),[_s,$t]=n.useState(new Set),Ce=n.useRef(0),rt=n.useRef(0),we=n.useRef(null),at=n.useRef(new Map),Nt=n.useRef(!1),zt=n.useRef(c),Os=!i&&!f,nt=n.useMemo(()=>new Set(a.keys()),[a]),Ds=nt.size;n.useEffect(()=>{const R=setInterval(()=>{$(new Date)},6e4);return()=>clearInterval(R)},[]),n.useEffect(()=>{I(new Set)},[t]),n.useEffect(()=>{const R=s?.projectId;R&&v(_=>{if(_.has(R))return _;const Z=new Set(_);return Z.add(R),Z})},[s?.projectId]),n.useEffect(()=>{if(t.length>0&&!o){const R=new Set;t.forEach(_=>{_.sessions&&_.sessions.length>=0&&R.add(_.projectId)}),I(R)}},[t,o]),n.useEffect(()=>{const R=()=>{K(Si())};R();const _=J=>{J.key==="claude-settings"&&R()};window.addEventListener("storage",_);const Z=setInterval(()=>{document.hasFocus()&&R()},1e3);return()=>{window.removeEventListener("storage",_),clearInterval(Z)}},[]),n.useEffect(()=>{zt.current=c},[c]);const Ne=n.useCallback(async()=>{_t(!0);try{const[R,_]=await Promise.all([ue.archivedProjects(),ue.getArchivedSessions()]);if(!R.ok)throw new Error(`Failed to load archived projects: ${R.status}`);if(!_.ok)throw new Error(`Failed to load archived sessions: ${_.status}`);const Z=await R.json(),J=await _.json(),le=Array.isArray(Z.data?.projects)?Z.data.projects:[],ie=new Set(le.map(je=>je.projectId)),fe=Array.isArray(J.data?.sessions)?J.data.sessions.filter(je=>!je.projectId||!ie.has(je.projectId)):[];Cs(le),Ps(fe)}catch(R){console.error("[Sidebar] Failed to load archived sessions:",R)}finally{_t(!1)}},[]),ze=n.useCallback(async(R,_)=>{const Z=++rt.current;_?qe(!0):Ot(!0),Dt(!1);try{const J=await ue.recentConversations({limit:40,offset:R});if(!J.ok)throw new Error(`Failed to load recent conversations: ${J.status}`);const le=await J.json(),ie=Array.isArray(le.data?.conversations)?le.data.conversations:[];if(Z!==rt.current)return;Ts(fe=>{if(!_)return ie;const je=new Set(fe.map(xe=>xe.sessionId));return[...fe,...ie.filter(xe=>!je.has(xe.sessionId))]}),Rs(Number(le.data?.total??ie.length)),As(!!le.data?.hasMore)}catch(J){if(Z!==rt.current)return;console.error("[Sidebar] Failed to load recent conversations:",J),Dt(!0)}finally{Z===rt.current&&(Ot(!1),qe(!1))}},[]),kt=n.useCallback(()=>{ze(0,!1)},[ze]),Ut=n.useCallback(()=>{wt||!jt||ze(vt.length,!0)},[ze,wt,vt.length,jt]);n.useEffect(()=>{if(Nt.current)return;const R=Ci();if(R.length===0)return;Nt.current=!0,(async()=>{try{await ue.migrateLegacyProjectStars(R),await zt.current()}catch(Z){console.error("[Sidebar] Failed to migrate legacy starred projects:",Z)}finally{Pi()}})()},[c]),n.useEffect(()=>{Ne()},[Ne]),n.useEffect(()=>{q!=="conversations"||Se.length>=2||kt()},[Se,kt,q]),n.useEffect(()=>{q==="archived"&&Ne()},[Ne,q]),n.useEffect(()=>{st(R=>{if(R.size===0)return R;const _=new Map(R);let Z=!1;for(const[J,le]of R.entries()){const ie=t.find(fe=>fe.projectId===J);if(!ie){_.delete(J),Z=!0;continue}!!ie.isStarred===le&&(_.delete(J),Z=!0)}return Z?_:R})},[t]),n.useEffect(()=>{const R=setTimeout(()=>{Fs(L.trim())},300);return()=>{clearTimeout(R)}},[L]),n.useEffect(()=>{we.current&&(we.current.close(),we.current=null);const R=Se;if(q!=="conversations"||R.length<2){Ce.current+=1,ne(null),Re(null),Ie(!1);return}Ie(!0),ne(null),Re(null);const _=++Ce.current;if(_!==Ce.current)return;const Z=ue.searchConversationsUrl(R),J=new EventSource(Z);we.current=J;const le=[];let ie=[],fe=0;return J.addEventListener("title-results",je=>{if(_!==Ce.current){J.close();return}try{const xe=JSON.parse(je.data);ie=Array.isArray(xe.titleResults)?xe.titleResults:[],ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R})}catch{}}),J.addEventListener("result",je=>{if(_!==Ce.current){J.close();return}try{const xe=JSON.parse(je.data);le.push(xe.projectResult),fe=xe.totalMatches,ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R}),Re({scannedProjects:xe.scannedProjects,totalProjects:xe.totalProjects})}catch{}}),J.addEventListener("progress",je=>{if(_!==Ce.current){J.close();return}try{const xe=JSON.parse(je.data);fe=xe.totalMatches,Re({scannedProjects:xe.scannedProjects,totalProjects:xe.totalProjects})}catch{}}),J.addEventListener("done",()=>{if(_!==Ce.current){J.close();return}J.close(),we.current=null,Ie(!1),Re(null),ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R})}),J.addEventListener("error",()=>{if(_!==Ce.current){J.close();return}J.close(),we.current=null,Ie(!1),Re(null),ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R})}),()=>{we.current&&(we.current.close(),we.current=null)}},[Se,q]);const $s=n.useCallback(R=>{v(_=>{const Z=new Set;return _.has(R)||Z.add(R),Z})},[]),Gt=n.useCallback((R,_)=>{d({...R,__projectId:_})},[d]),Ue=n.useCallback(R=>$e.has(R)?!!$e.get(R):t.some(_=>_.projectId===R&&!!_.isStarred),[$e,t]),Vt=n.useCallback(R=>{const _=Ue(R),Z=!_,J=(at.current.get(R)??0)+1;at.current.set(R,J),st(ie=>{const fe=new Map(ie);return fe.set(R,Z),fe}),(async()=>{try{const ie=await ue.toggleProjectStar(R);if(!ie.ok){const Ae=(await ie.json()).error,mo=typeof Ae=="string"?Ae:Ae&&typeof Ae=="object"&&Ae.message?Ae.message:l("messages.updateProjectError");throw new Error(mo)}const fe=await ie.json();if(!(at.current.get(R)===J))return;st(xe=>{const Ae=new Map(xe);return Ae.set(R,!!fe.isStarred),Ae})}catch(ie){if(!(at.current.get(R)===J))return;st(je=>{const xe=new Map(je);return xe.set(R,_),xe}),console.error("[Sidebar] Failed to toggle project star:",ie),alert(l("messages.updateProjectError"))}})()},[Ue,l]),zs=n.useCallback(R=>Ue(R),[Ue]),St=n.useCallback(R=>gs(R),[]),Ct=n.useCallback(async R=>{if(!x)return;let _=!1;if($t(Z=>{if(Z.has(R))return Z;_=!0;const J=new Set(Z);return J.add(R),J}),!!_)try{await x(R)}catch(Z){console.error("[Sidebar] Failed to load more sessions:",Z),alert(l("messages.refreshError"))}finally{$t(Z=>{const J=new Set(Z);return J.delete(R),J})}},[x,l]),Kt=n.useMemo(()=>$e.size===0?t:t.map(R=>{const _=$e.get(R.projectId);return _===void 0||!!R.isStarred===_?R:{...R,isStarred:_}}),[$e,t]),ot=n.useMemo(()=>Ai(Kt,G),[G,Kt]),pe=n.useMemo(()=>nt.size===0?[]:ot.reduce((R,_)=>{const Z=(_.sessions??[]).filter(le=>nt.has(String(le.id))),J=Z.length;return J===0||R.push({..._,sessions:Z,sessionMeta:{..._.sessionMeta,total:J,hasMore:!1}}),R},[]),[nt,ot]),Ge=n.useMemo(()=>Li(q==="running"?pe:ot,Se),[Se,pe,q,ot]),Pt=n.useMemo(()=>{const R=Se.trim().toLowerCase();return R?tt.filter(_=>[_.sessionTitle,_.projectDisplayName,_.projectPath??"",_.provider].some(J=>J.toLowerCase().includes(R))):tt},[tt,Se]),Et=n.useMemo(()=>{const R=Se.trim().toLowerCase();return R?De.filter(_=>[_.displayName,_.fullPath||""].some(J=>J.toLowerCase().includes(R))?!0:gs(_).some(J=>[typeof J.summary=="string"&&J.summary.trim().length>0?J.summary:typeof J.name=="string"?J.name:"",J.__provider].some(ie=>ie.toLowerCase().includes(R)))):De},[De,Se]),Us=n.useCallback(R=>{k(R.projectId),C(R.displayName)},[]),Gs=n.useCallback(()=>{k(null),C("")},[]),Qe=n.useCallback(async R=>{try{(await ue.renameProject(R,E)).ok?await b.refreshProjects():console.error("Failed to rename project")}catch(_){console.error("Error renaming project:",_)}finally{k(null),C("")}},[E,b]),Bt=n.useCallback((R,_,Z,J="claude",le={})=>{ae({projectId:R,sessionId:_,sessionTitle:Z,provider:J,isArchived:!!le.isArchived})},[]),Wt=n.useCallback(async(R=!1)=>{if(!V)return;const{sessionId:_}=V;ae(null);try{const Z=await ue.deleteSession(_,R);if(Z.ok)u?.(_),await Ne();else{const J=await Z.text();console.error("[Sidebar] Failed to delete session:",{status:Z.status,error:J}),alert(l("messages.deleteSessionFailed"))}}catch(Z){console.error("[Sidebar] Error deleting session:",Z),alert(l("messages.deleteSessionError"))}},[Ne,u,V,l]),Ht=n.useCallback(R=>{ee({project:R,sessionCount:St(R).length})},[St]),Jt=n.useCallback(async(R=!1)=>{if(!A)return;const{project:_}=A;ee(null),N(Z=>new Set([...Z,_.projectId]));try{const Z=await ue.deleteProject(_.projectId,R);if(Z.ok)h?.(_.projectId);else{const le=(await Z.json()).error,ie=typeof le=="string"?le:le&&typeof le=="object"&&le.message?le.message:l("messages.deleteProjectFailed");alert(ie)}}catch(Z){console.error("Error deleting project:",Z),alert(l("messages.deleteProjectError"))}finally{N(Z=>{const J=new Set(Z);return J.delete(_.projectId),J})}},[A,h,l]),Tt=n.useCallback(R=>{m(R)},[m]),ao=n.useCallback(R=>{const _=R.projectId?t.find(ie=>ie.projectId===R.projectId):null,Z=R.projectId?De.find(ie=>ie.projectId===R.projectId):null,J=_??Z??null,le={id:R.sessionId,summary:R.sessionTitle,__provider:R.provider,__projectId:J?.projectId??R.projectId??void 0};J&&Tt(J),d(le)},[De,Tt,d,t]),no=n.useCallback(async R=>{try{const _=await ue.restoreProject(R);if(!_.ok){const Z=await _.text();console.error("[Sidebar] Failed to restore project:",{status:_.status,error:Z}),alert(l("messages.restoreProjectFailed","Failed to restore project. Please try again."));return}await Promise.all([Promise.resolve(c()),Ne()])}catch(_){console.error("[Sidebar] Error restoring project:",_),alert(l("messages.restoreProjectError","Error restoring project. Please try again."))}},[Ne,c,l]),oo=n.useCallback(async R=>{try{const _=await ue.restoreSession(R);if(!_.ok){const Z=await _.text();console.error("[Sidebar] Failed to restore session:",{status:_.status,error:Z}),alert(l("messages.restoreSessionFailed","Failed to restore session. Please try again."));return}await Promise.all([Promise.resolve(c()),Ne()])}catch(_){console.error("[Sidebar] Error restoring session:",_),alert(l("messages.restoreSessionError","Error restoring session. Please try again."))}},[Ne,c,l]),io=n.useCallback(async()=>{X(!0);try{await Promise.all([Promise.resolve(c()),Ne(),q==="conversations"?ze(0,!1):Promise.resolve()])}finally{X(!1)}},[Ne,ze,c,q]),lo=n.useCallback(async(R,_,Z,J)=>{const le=Z.trim();if(!le){B(null),D("");return}try{const ie=await ue.renameSession(_,le);ie.ok?await c():(console.error("[Sidebar] Failed to rename session:",ie.status),alert(l("messages.renameSessionFailed")))}catch(ie){console.error("[Sidebar] Error renaming session:",ie),alert(l("messages.renameSessionError"))}finally{B(null),D("")}},[c,l]),co=n.useCallback(()=>{p(!1)},[p]),uo=n.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:Os,expandedProjects:g,editingProject:S,showNewProject:y,editingName:E,initialSessionsLoaded:T,currentTime:j,projectSortOrder:G,isRefreshing:M,editingSession:H,editingSessionName:w,searchFilter:L,deletingProjects:U,loadingMoreProjects:_s,deleteConfirmation:A,sessionDeleteConfirmation:V,showVersionModal:de,filteredProjects:Ge,runningSessionsCount:Ds,archivedProjects:Et,archivedSessions:Pt,archivedSessionsCount:De.length+tt.length,isArchivedSessionsLoading:Es,recentConversations:vt,recentConversationsTotal:Is,recentConversationsHasMore:jt,isRecentConversationsLoading:Ls,isLoadingMoreRecentConversations:wt,recentConversationsError:Ms,reloadRecentConversations:kt,loadMoreRecentConversations:Ut,toggleProject:$s,handleSessionClick:Gt,toggleStarProject:Vt,isProjectStarred:zs,getProjectSessions:St,loadMoreSessionsForProject:Ct,startEditing:Us,cancelEditing:Gs,saveProjectName:Qe,showDeleteSessionConfirmation:Bt,confirmDeleteSession:Wt,requestProjectDelete:Ht,confirmDeleteProject:Jt,handleProjectSelect:Tt,openArchivedSession:ao,restoreArchivedProject:no,restoreArchivedSession:oo,refreshProjects:io,updateSessionSummary:lo,collapseSidebar:co,expandSidebar:uo,setShowNewProject:P,setEditingName:C,setEditingSession:B,setEditingSessionName:D,searchMode:q,setSearchMode:ye,conversationResults:se,isSearching:re,searchProgress:Ss,clearConversationResults:n.useCallback(()=>{Ce.current+=1,we.current&&(we.current.close(),we.current=null),Ie(!1),Re(null),ne(null)},[]),setSearchFilter:O,setDeleteConfirmation:ee,setSessionDeleteConfirmation:ae,setShowVersionModal:te}}const cn=n.createContext(null);function Oi(t,s){return{message:s instanceof Error?s.message:`Failed to ${t}`,context:t,timestamp:new Date().toISOString()}}function Br(t){return{...t,taskMasterConfigured:t.taskmaster?.hasTaskmaster??!1,taskMasterStatus:t.taskmaster?.status??"not-configured",taskCount:Number(t.taskmaster?.metadata?.taskCount??0),completedCount:Number(t.taskmaster?.metadata?.completed??0)}}function Di(t){return t.find(s=>s.status==="pending"||s.status==="in-progress")??null}function $i(t){return t?.type?t.type.startsWith("taskmaster-"):!1}function zi(){const t=n.useContext(cn);if(!t)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return t}function Fm({children:t,project:s,onProjectTaskMasterChange:r}){const{latestMessage:a}=gi(),{user:o,token:i,isLoading:l}=qa(),[c,m]=n.useState(null),[d,u]=n.useState(null),[x,h]=n.useState(null),[p,f]=n.useState([]),[b,g]=n.useState(null),[v,S]=n.useState(!1),[k,y]=n.useState(!1),[P,E]=n.useState(!1),[C,T]=n.useState(null),I=n.useRef(null),j=n.useRef(null),$=n.useRef(0),G=n.useRef(r);G.current=r,n.useEffect(()=>{I.current=c?.projectId??null},[c?.projectId]),n.useEffect(()=>{j.current=d},[d]);const K=n.useCallback(()=>{T(null)},[]),M=n.useCallback((O,U)=>{console.error(`TaskMaster ${O} error:`,U),T(Oi(O,U))},[]),X=n.useCallback((O,U)=>{u(U),m(N=>!N||N.projectId!==O?N:Br({...N,taskmaster:U??void 0})),G.current(O,U)},[]),H=n.useCallback(async O=>{if(!O||!o||!i)return;const U=++$.current;try{const N=await ue.projectTaskmaster(O);if(!N.ok)throw new Error(`Failed to fetch TaskMaster details: ${N.status}`);const ee=(await N.json()).taskmaster??null;if(U!==$.current||I.current!==O)return;X(O,ee)}catch(N){if(U!==$.current||I.current!==O)return;M("load selected project TaskMaster info",N)}},[X,M,i,o]),B=n.useCallback(async()=>{const O=I.current;if(O){S(!0);try{await H(O)}finally{I.current===O&&S(!1)}}},[H]);n.useEffect(()=>{const O=s?Br(s):null,U=I.current,N=O?.projectId??null;I.current=N,m(O),u(O?.taskmaster??null),U!==N&&($.current+=1,f([]),g(null))},[s]),n.useEffect(()=>{s?.projectId&&o&&i&&B()},[s?.projectId,B,i,o]);const w=n.useCallback(async()=>{const O=c?.projectId;if(!O||!o||!i){f([]),g(null);return}try{y(!0),K();const U=await ue.get(`/taskmaster/tasks/${encodeURIComponent(O)}`);if(!U.ok){const ee=await U.json();throw new Error(ee.message??"Failed to load tasks")}const N=await U.json(),A=Array.isArray(N.tasks)?N.tasks:[];f(A),g(Di(A))}catch(U){M("load tasks",U),f([]),g(null)}finally{y(!1)}},[K,c?.projectId,M,i,o]),D=n.useCallback(async()=>{if(!o||!i){h(null);return}try{E(!0),K();const O=await ue.get("/taskmaster/mcp-status");if(!O.ok)throw new Error(`Failed to load MCP status: ${O.status}`);const U=await O.json();h(U)}catch(O){M("check MCP server status",O),h(null)}finally{E(!1)}},[K,M,i,o]);n.useEffect(()=>{!l&&o&&i&&D()},[l,D,i,o]),n.useEffect(()=>{c?.projectId&&o&&i&&w()},[c?.projectId,w,i,o]),n.useEffect(()=>{const O=a;if($i(O)){if(O.type==="taskmaster-project-updated"&&O.projectId){O.projectId===I.current&&H(O.projectId);return}if(O.type==="taskmaster-tasks-updated"&&O.projectId===c?.projectId){w();return}O.type==="taskmaster-mcp-status-changed"&&D()}},[c?.projectId,a,H,D,w]);const L=n.useMemo(()=>({currentProject:c,projectTaskMaster:d,mcpServerStatus:x,tasks:p,nextTask:b,isLoading:v,isLoadingTasks:k,isLoadingMCP:P,error:C,refreshProjectTaskMaster:B,refreshTasks:w,refreshMCPStatus:D,clearError:K}),[K,c,C,v,P,k,x,b,d,D,B,w,p]);return e.jsx(cn.Provider,{value:L,children:t})}function Ui({onExpand:t,onShowSettings:s,updateAvailable:r,restartRequired:a,onShowVersionModal:o,t:i}){return e.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[e.jsx("button",{onClick:t,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("common:versionUpdate.ariaLabels.showSidebar"),title:i("common:versionUpdate.ariaLabels.showSidebar"),children:e.jsx(po,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),e.jsx("div",{className:"nav-divider my-1 w-6"}),e.jsx("button",{onClick:s,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("actions.settings"),title:i("actions.settings"),children:e.jsx(as,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),a&&e.jsxs("div",{className:"relative flex h-8 w-8 items-center justify-center rounded-lg","aria-label":i("version.restartRequired"),title:i("version.restartRequired"),children:[e.jsx(Oe,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-amber-500"})]}),r&&e.jsxs("button",{onClick:o,className:"relative flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("common:versionUpdate.ariaLabels.updateAvailable"),title:i("common:versionUpdate.ariaLabels.updateAvailable"),children:[e.jsx(xo,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function dn(t){var s,r,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(s=0;s<o;s++)t[s]&&(r=dn(t[s]))&&(a&&(a+=" "),a+=r)}else for(r in t)t[r]&&(a&&(a+=" "),a+=r);return a}function un(){for(var t,s,r=0,a="",o=arguments.length;r<o;r++)(t=arguments[r])&&(s=dn(t))&&(a&&(a+=" "),a+=s);return a}const Wr=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Hr=un,wr=(t,s)=>r=>{var a;if(s?.variants==null)return Hr(t,r?.class,r?.className);const{variants:o,defaultVariants:i}=s,l=Object.keys(o).map(d=>{const u=r?.[d],x=i?.[d];if(u===null)return null;const h=Wr(u)||Wr(x);return o[d][h]}),c=r&&Object.entries(r).reduce((d,u)=>{let[x,h]=u;return h===void 0||(d[x]=h),d},{}),m=s==null||(a=s.compoundVariants)===null||a===void 0?void 0:a.reduce((d,u)=>{let{class:x,className:h,...p}=u;return Object.entries(p).every(f=>{let[b,g]=f;return Array.isArray(g)?g.includes({...i,...c}[b]):{...i,...c}[b]===g})?[...d,x,h]:d},[]);return Hr(t,l,m,r?.class,r?.className)},Nr="-",Gi=t=>{const s=Ki(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:l=>{const c=l.split(Nr);return c[0]===""&&c.length!==1&&c.shift(),mn(c,s)||Vi(l)},getConflictingClassGroupIds:(l,c)=>{const m=r[l]||[];return c&&a[l]?[...m,...a[l]]:m}}},mn=(t,s)=>{if(t.length===0)return s.classGroupId;const r=t[0],a=s.nextPart.get(r),o=a?mn(t.slice(1),a):void 0;if(o)return o;if(s.validators.length===0)return;const i=t.join(Nr);return s.validators.find(({validator:l})=>l(i))?.classGroupId},Jr=/^\[(.+)\]$/,Vi=t=>{if(Jr.test(t)){const s=Jr.exec(t)[1],r=s?.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Ki=t=>{const{theme:s,classGroups:r}=t,a={nextPart:new Map,validators:[]};for(const o in r)cr(r[o],a,o,s);return a},cr=(t,s,r,a)=>{t.forEach(o=>{if(typeof o=="string"){const i=o===""?s:qr(s,o);i.classGroupId=r;return}if(typeof o=="function"){if(Bi(o)){cr(o(a),s,r,a);return}s.validators.push({validator:o,classGroupId:r});return}Object.entries(o).forEach(([i,l])=>{cr(l,qr(s,i),r,a)})})},qr=(t,s)=>{let r=t;return s.split(Nr).forEach(a=>{r.nextPart.has(a)||r.nextPart.set(a,{nextPart:new Map,validators:[]}),r=r.nextPart.get(a)}),r},Bi=t=>t.isThemeGetter,Wi=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,a=new Map;const o=(i,l)=>{r.set(i,l),s++,s>t&&(s=0,a=r,r=new Map)};return{get(i){let l=r.get(i);if(l!==void 0)return l;if((l=a.get(i))!==void 0)return o(i,l),l},set(i,l){r.has(i)?r.set(i,l):o(i,l)}}},dr="!",ur=":",Hi=ur.length,Ji=t=>{const{prefix:s,experimentalParseClassName:r}=t;let a=o=>{const i=[];let l=0,c=0,m=0,d;for(let f=0;f<o.length;f++){let b=o[f];if(l===0&&c===0){if(b===ur){i.push(o.slice(m,f)),m=f+Hi;continue}if(b==="/"){d=f;continue}}b==="["?l++:b==="]"?l--:b==="("?c++:b===")"&&c--}const u=i.length===0?o:o.substring(m),x=qi(u),h=x!==u,p=d&&d>m?d-m:void 0;return{modifiers:i,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:p}};if(s){const o=s+ur,i=a;a=l=>l.startsWith(o)?i(l.substring(o.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:l,maybePostfixModifierPosition:void 0}}if(r){const o=a;a=i=>r({className:i,parseClassName:o})}return a},qi=t=>t.endsWith(dr)?t.substring(0,t.length-1):t.startsWith(dr)?t.substring(1):t,Qi=t=>{const s=Object.fromEntries(t.orderSensitiveModifiers.map(a=>[a,!0]));return a=>{if(a.length<=1)return a;const o=[];let i=[];return a.forEach(l=>{l[0]==="["||s[l]?(o.push(...i.sort(),l),i=[]):i.push(l)}),o.push(...i.sort()),o}},Yi=t=>({cache:Wi(t.cacheSize),parseClassName:Ji(t),sortModifiers:Qi(t),...Gi(t)}),Zi=/\s+/,Xi=(t,s)=>{const{parseClassName:r,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:i}=s,l=[],c=t.trim().split(Zi);let m="";for(let d=c.length-1;d>=0;d-=1){const u=c[d],{isExternal:x,modifiers:h,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:b}=r(u);if(x){m=u+(m.length>0?" "+m:m);continue}let g=!!b,v=a(g?f.substring(0,b):f);if(!v){if(!g){m=u+(m.length>0?" "+m:m);continue}if(v=a(f),!v){m=u+(m.length>0?" "+m:m);continue}g=!1}const S=i(h).join(":"),k=p?S+dr:S,y=k+v;if(l.includes(y))continue;l.push(y);const P=o(v,g);for(let E=0;E<P.length;++E){const C=P[E];l.push(k+C)}m=u+(m.length>0?" "+m:m)}return m};function el(){let t=0,s,r,a="";for(;t<arguments.length;)(s=arguments[t++])&&(r=pn(s))&&(a&&(a+=" "),a+=r);return a}const pn=t=>{if(typeof t=="string")return t;let s,r="";for(let a=0;a<t.length;a++)t[a]&&(s=pn(t[a]))&&(r&&(r+=" "),r+=s);return r};function tl(t,...s){let r,a,o,i=l;function l(m){const d=s.reduce((u,x)=>x(u),t());return r=Yi(d),a=r.cache.get,o=r.cache.set,i=c,c(m)}function c(m){const d=a(m);if(d)return d;const u=Xi(m,r);return o(m,u),u}return function(){return i(el.apply(null,arguments))}}const be=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},xn=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,hn=/^\((?:(\w[\w-]*):)?(.+)\)$/i,sl=/^\d+\/\d+$/,rl=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,al=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,nl=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ol=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,il=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,lt=t=>sl.test(t),oe=t=>!!t&&!Number.isNaN(Number(t)),Ke=t=>!!t&&Number.isInteger(Number(t)),Ws=t=>t.endsWith("%")&&oe(t.slice(0,-1)),Le=t=>rl.test(t),ll=()=>!0,cl=t=>al.test(t)&&!nl.test(t),gn=()=>!1,dl=t=>ol.test(t),ul=t=>il.test(t),ml=t=>!Q(t)&&!Y(t),pl=t=>bt(t,yn,gn),Q=t=>xn.test(t),Ye=t=>bt(t,vn,cl),Hs=t=>bt(t,bl,oe),Qr=t=>bt(t,fn,gn),xl=t=>bt(t,bn,ul),Yt=t=>bt(t,jn,dl),Y=t=>hn.test(t),It=t=>yt(t,vn),hl=t=>yt(t,yl),Yr=t=>yt(t,fn),gl=t=>yt(t,yn),fl=t=>yt(t,bn),Zt=t=>yt(t,jn,!0),bt=(t,s,r)=>{const a=xn.exec(t);return a?a[1]?s(a[1]):r(a[2]):!1},yt=(t,s,r=!1)=>{const a=hn.exec(t);return a?a[1]?s(a[1]):r:!1},fn=t=>t==="position"||t==="percentage",bn=t=>t==="image"||t==="url",yn=t=>t==="length"||t==="size"||t==="bg-size",vn=t=>t==="length",bl=t=>t==="number",yl=t=>t==="family-name",jn=t=>t==="shadow",vl=()=>{const t=be("color"),s=be("font"),r=be("text"),a=be("font-weight"),o=be("tracking"),i=be("leading"),l=be("breakpoint"),c=be("container"),m=be("spacing"),d=be("radius"),u=be("shadow"),x=be("inset-shadow"),h=be("text-shadow"),p=be("drop-shadow"),f=be("blur"),b=be("perspective"),g=be("aspect"),v=be("ease"),S=be("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...y(),Y,Q],E=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],T=()=>[Y,Q,m],I=()=>[lt,"full","auto",...T()],j=()=>[Ke,"none","subgrid",Y,Q],$=()=>["auto",{span:["full",Ke,Y,Q]},Ke,Y,Q],G=()=>[Ke,"auto",Y,Q],K=()=>["auto","min","max","fr",Y,Q],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...T()],B=()=>[lt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],w=()=>[t,Y,Q],D=()=>[...y(),Yr,Qr,{position:[Y,Q]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],O=()=>["auto","cover","contain",gl,pl,{size:[Y,Q]}],U=()=>[Ws,It,Ye],N=()=>["","none","full",d,Y,Q],A=()=>["",oe,It,Ye],ee=()=>["solid","dashed","dotted","double"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ae=()=>[oe,Ws,Yr,Qr],de=()=>["","none",f,Y,Q],te=()=>["none",oe,Y,Q],q=()=>["none",oe,Y,Q],ye=()=>[oe,Y,Q],se=()=>[lt,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Le],breakpoint:[Le],color:[ll],container:[Le],"drop-shadow":[Le],ease:["in","out","in-out"],font:[ml],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Le],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Le],shadow:[Le],spacing:["px",oe],text:[Le],"text-shadow":[Le],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",lt,Q,Y,g]}],container:["container"],columns:[{columns:[oe,Q,Y,c]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{start:I()}],end:[{end:I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[Ke,"auto",Y,Q]}],basis:[{basis:[lt,"full","auto",c,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[oe,lt,"auto","initial","none",Q]}],grow:[{grow:["",oe,Y,Q]}],shrink:[{shrink:["",oe,Y,Q]}],order:[{order:[Ke,"first","last","none",Y,Q]}],"grid-cols":[{"grid-cols":j()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":G()}],"col-end":[{"col-end":G()}],"grid-rows":[{"grid-rows":j()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":G()}],"row-end":[{"row-end":G()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":K()}],"auto-rows":[{"auto-rows":K()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],w:[{w:[c,"screen",...B()]}],"min-w":[{"min-w":[c,"screen","none",...B()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[l]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",r,It,Ye]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Y,Hs]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ws,Q]}],"font-family":[{font:[hl,Q,s]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Y,Q]}],"line-clamp":[{"line-clamp":[oe,"none",Y,Hs]}],leading:[{leading:[i,...T()]}],"list-image":[{"list-image":["none",Y,Q]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Y,Q]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:w()}],"text-color":[{text:w()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:[oe,"from-font","auto",Y,Ye]}],"text-decoration-color":[{decoration:w()}],"underline-offset":[{"underline-offset":[oe,"auto",Y,Q]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Y,Q]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Y,Q]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:O()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ke,Y,Q],radial:["",Y,Q],conic:[Ke,Y,Q]},fl,xl]}],"bg-color":[{bg:w()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:w()}],"gradient-via":[{via:w()}],"gradient-to":[{to:w()}],rounded:[{rounded:N()}],"rounded-s":[{"rounded-s":N()}],"rounded-e":[{"rounded-e":N()}],"rounded-t":[{"rounded-t":N()}],"rounded-r":[{"rounded-r":N()}],"rounded-b":[{"rounded-b":N()}],"rounded-l":[{"rounded-l":N()}],"rounded-ss":[{"rounded-ss":N()}],"rounded-se":[{"rounded-se":N()}],"rounded-ee":[{"rounded-ee":N()}],"rounded-es":[{"rounded-es":N()}],"rounded-tl":[{"rounded-tl":N()}],"rounded-tr":[{"rounded-tr":N()}],"rounded-br":[{"rounded-br":N()}],"rounded-bl":[{"rounded-bl":N()}],"border-w":[{border:A()}],"border-w-x":[{"border-x":A()}],"border-w-y":[{"border-y":A()}],"border-w-s":[{"border-s":A()}],"border-w-e":[{"border-e":A()}],"border-w-t":[{"border-t":A()}],"border-w-r":[{"border-r":A()}],"border-w-b":[{"border-b":A()}],"border-w-l":[{"border-l":A()}],"divide-x":[{"divide-x":A()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":A()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ee(),"hidden","none"]}],"divide-style":[{divide:[...ee(),"hidden","none"]}],"border-color":[{border:w()}],"border-color-x":[{"border-x":w()}],"border-color-y":[{"border-y":w()}],"border-color-s":[{"border-s":w()}],"border-color-e":[{"border-e":w()}],"border-color-t":[{"border-t":w()}],"border-color-r":[{"border-r":w()}],"border-color-b":[{"border-b":w()}],"border-color-l":[{"border-l":w()}],"divide-color":[{divide:w()}],"outline-style":[{outline:[...ee(),"none","hidden"]}],"outline-offset":[{"outline-offset":[oe,Y,Q]}],"outline-w":[{outline:["",oe,It,Ye]}],"outline-color":[{outline:w()}],shadow:[{shadow:["","none",u,Zt,Yt]}],"shadow-color":[{shadow:w()}],"inset-shadow":[{"inset-shadow":["none",x,Zt,Yt]}],"inset-shadow-color":[{"inset-shadow":w()}],"ring-w":[{ring:A()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:w()}],"ring-offset-w":[{"ring-offset":[oe,Ye]}],"ring-offset-color":[{"ring-offset":w()}],"inset-ring-w":[{"inset-ring":A()}],"inset-ring-color":[{"inset-ring":w()}],"text-shadow":[{"text-shadow":["none",h,Zt,Yt]}],"text-shadow-color":[{"text-shadow":w()}],opacity:[{opacity:[oe,Y,Q]}],"mix-blend":[{"mix-blend":[...V(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":V()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[oe]}],"mask-image-linear-from-pos":[{"mask-linear-from":ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":ae()}],"mask-image-linear-from-color":[{"mask-linear-from":w()}],"mask-image-linear-to-color":[{"mask-linear-to":w()}],"mask-image-t-from-pos":[{"mask-t-from":ae()}],"mask-image-t-to-pos":[{"mask-t-to":ae()}],"mask-image-t-from-color":[{"mask-t-from":w()}],"mask-image-t-to-color":[{"mask-t-to":w()}],"mask-image-r-from-pos":[{"mask-r-from":ae()}],"mask-image-r-to-pos":[{"mask-r-to":ae()}],"mask-image-r-from-color":[{"mask-r-from":w()}],"mask-image-r-to-color":[{"mask-r-to":w()}],"mask-image-b-from-pos":[{"mask-b-from":ae()}],"mask-image-b-to-pos":[{"mask-b-to":ae()}],"mask-image-b-from-color":[{"mask-b-from":w()}],"mask-image-b-to-color":[{"mask-b-to":w()}],"mask-image-l-from-pos":[{"mask-l-from":ae()}],"mask-image-l-to-pos":[{"mask-l-to":ae()}],"mask-image-l-from-color":[{"mask-l-from":w()}],"mask-image-l-to-color":[{"mask-l-to":w()}],"mask-image-x-from-pos":[{"mask-x-from":ae()}],"mask-image-x-to-pos":[{"mask-x-to":ae()}],"mask-image-x-from-color":[{"mask-x-from":w()}],"mask-image-x-to-color":[{"mask-x-to":w()}],"mask-image-y-from-pos":[{"mask-y-from":ae()}],"mask-image-y-to-pos":[{"mask-y-to":ae()}],"mask-image-y-from-color":[{"mask-y-from":w()}],"mask-image-y-to-color":[{"mask-y-to":w()}],"mask-image-radial":[{"mask-radial":[Y,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":ae()}],"mask-image-radial-from-color":[{"mask-radial-from":w()}],"mask-image-radial-to-color":[{"mask-radial-to":w()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":y()}],"mask-image-conic-pos":[{"mask-conic":[oe]}],"mask-image-conic-from-pos":[{"mask-conic-from":ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":ae()}],"mask-image-conic-from-color":[{"mask-conic-from":w()}],"mask-image-conic-to-color":[{"mask-conic-to":w()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:O()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Y,Q]}],filter:[{filter:["","none",Y,Q]}],blur:[{blur:de()}],brightness:[{brightness:[oe,Y,Q]}],contrast:[{contrast:[oe,Y,Q]}],"drop-shadow":[{"drop-shadow":["","none",p,Zt,Yt]}],"drop-shadow-color":[{"drop-shadow":w()}],grayscale:[{grayscale:["",oe,Y,Q]}],"hue-rotate":[{"hue-rotate":[oe,Y,Q]}],invert:[{invert:["",oe,Y,Q]}],saturate:[{saturate:[oe,Y,Q]}],sepia:[{sepia:["",oe,Y,Q]}],"backdrop-filter":[{"backdrop-filter":["","none",Y,Q]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[oe,Y,Q]}],"backdrop-contrast":[{"backdrop-contrast":[oe,Y,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":["",oe,Y,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[oe,Y,Q]}],"backdrop-invert":[{"backdrop-invert":["",oe,Y,Q]}],"backdrop-opacity":[{"backdrop-opacity":[oe,Y,Q]}],"backdrop-saturate":[{"backdrop-saturate":[oe,Y,Q]}],"backdrop-sepia":[{"backdrop-sepia":["",oe,Y,Q]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Y,Q]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[oe,"initial",Y,Q]}],ease:[{ease:["linear","initial",v,Y,Q]}],delay:[{delay:[oe,Y,Q]}],animate:[{animate:["none",S,Y,Q]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Y,Q]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:q()}],"scale-x":[{"scale-x":q()}],"scale-y":[{"scale-y":q()}],"scale-z":[{"scale-z":q()}],"scale-3d":["scale-3d"],skew:[{skew:ye()}],"skew-x":[{"skew-x":ye()}],"skew-y":[{"skew-y":ye()}],transform:[{transform:[Y,Q,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:se()}],"translate-x":[{"translate-x":se()}],"translate-y":[{"translate-y":se()}],"translate-z":[{"translate-z":se()}],"translate-none":["translate-none"],accent:[{accent:w()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:w()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Y,Q]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Y,Q]}],fill:[{fill:["none",...w()]}],"stroke-w":[{stroke:[oe,It,Ye,Hs]}],stroke:[{stroke:["none",...w()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},jl=tl(vl);function F(...t){return jl(un(t))}const wl=wr("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current"}},defaultVariants:{variant:"default"}}),wn=n.forwardRef(({className:t,variant:s,...r},a)=>e.jsx("div",{ref:a,role:"alert","data-slot":"alert",className:F(wl({variant:s}),t),...r}));wn.displayName="Alert";const Nl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"alert-title",className:F("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...s}));Nl.displayName="AlertTitle";const kl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"alert-description",className:F("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...s}));kl.displayName="AlertDescription";const Nn=wr("inline-flex touch-manipulation items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90 active:bg-primary/80",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/80",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground active:bg-accent/80",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 active:bg-secondary/70",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent/80",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3 text-sm",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),W=n.forwardRef(({className:t,variant:s,size:r,...a},o)=>e.jsx("button",{className:F(Nn({variant:s,size:r,className:t})),ref:o,...a}));W.displayName="Button";function kn({label:t,items:s,icon:r,ariaLabel:a,align:o="right",variant:i="outline",size:l="sm",className:c,triggerClassName:m,menuClassName:d,disabled:u,iconOnly:x=!1,portal:h=!1,header:p,onOpenChange:f}){const[b,g]=n.useState(!1),[v,S]=n.useState(null),k=n.useRef(null),y=n.useRef(null),P=n.useRef(null),E=n.useRef(!1),C=n.useRef(!1),T=n.useRef(!1),I=n.useId(),j=n.useCallback(M=>{g(M),M||S(null),f?.(M)},[f]);n.useEffect(()=>{if(!b)return;const M=H=>{const B=H.target;k.current&&!k.current.contains(B)&&!P.current?.contains(B)&&j(!1)},X=H=>{H.key==="Escape"&&(E.current=!0,j(!1))};return document.addEventListener("mousedown",M),document.addEventListener("keydown",X),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",X)}},[b,j]),n.useEffect(()=>{if(!b||!h)return;const M=()=>j(!1);return window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[b,h,j]),n.useEffect(()=>{if(b){if(T.current=!0,C.current){const M=P.current;(M?.querySelector('[role="menuitem"]:not([disabled])')??M)?.focus()}return}T.current&&(T.current=!1,E.current&&y.current?.focus(),E.current=!1)},[b]);const $=M=>{M.disabled||M.loading||(M.closeOnSelect!==!1&&(E.current=!0,j(!1)),M.onSelect())},G=()=>{if(b){j(!1);return}if(h&&y.current){const M=y.current.getBoundingClientRect(),X=260,H=(p?52:0)+s.reduce((B,w)=>B+(w.description?58:40)+(w.showDividerBefore?9:0),12);S({top:M.bottom+6+H<=window.innerHeight-8?M.bottom+6:Math.max(8,M.top-H-6),left:Math.max(8,Math.min(M.right-X,window.innerWidth-X-8))})}j(!0)},K=b&&(!h||v)&&e.jsxs("div",{ref:P,id:I,role:"menu",tabIndex:-1,className:F(h?"fixed z-[70]":"absolute top-full z-50 mt-2","min-w-[220px] rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lg","animate-in fade-in-0 zoom-in-95",!h&&(o==="right"?"right-0":"left-0"),d),style:h&&v?v:void 0,children:[p,s.map(M=>{const X=M.icon;return e.jsxs(n.Fragment,{children:[M.showDividerBefore&&e.jsx("div",{className:"mx-2 my-1 h-px bg-border"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:M.disabled||M.loading,onClick:()=>$(M),className:F("flex w-full items-start gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors","focus:outline-none focus-visible:bg-accent",M.disabled||M.loading?"cursor-not-allowed opacity-50":M.isDanger?"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950":"hover:bg-accent"),children:[M.loading?e.jsx(ve,{className:"mt-0.5 h-4 w-4 flex-shrink-0 animate-spin"}):X&&e.jsx(X,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-medium leading-5",children:M.label}),M.description&&e.jsx("span",{className:"mt-0.5 block text-xs leading-4 text-muted-foreground",children:M.description})]})]})]},M.key)})]});return e.jsxs("div",{ref:k,className:F("relative inline-flex",c),children:[e.jsxs(W,{ref:y,type:"button",variant:i,size:l,className:m,disabled:u,"aria-label":a||t,"aria-haspopup":"menu","aria-expanded":b,"aria-controls":b?I:void 0,onClick:M=>{C.current=M.detail===0,G()},children:[r&&e.jsx(r,{className:"h-4 w-4"}),!x&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:t}),e.jsx(ns,{className:F("h-4 w-4 transition-transform",b&&"rotate-180")})]})]}),h&&typeof document<"u"?ys.createPortal(K,document.body):K]})}const Sl=wr("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Pe({className:t,variant:s,...r}){return e.jsx("div",{className:F(Sl({variant:s}),t),...r})}const Sn=n.createContext(null),Cn=()=>{const t=n.useContext(Sn);if(!t)throw new Error("Confirmation components must be used within Confirmation");return t},Cl=({className:t,approval:s="pending",children:r,...a})=>{const o=n.useMemo(()=>({approval:s}),[s]);return e.jsx(Sn.Provider,{value:o,children:e.jsx(wn,{className:F("flex flex-col gap-2",t),...a,children:r})})};Cl.displayName="Confirmation";const Pl=({className:t,...s})=>e.jsx("div",{"data-slot":"confirmation-title",className:F("text-muted-foreground inline text-sm",t),...s});Pl.displayName="ConfirmationTitle";const El=({children:t})=>{const{approval:s}=Cn();return s!=="pending"?null:e.jsx(e.Fragment,{children:t})};El.displayName="ConfirmationRequest";const Tl=({className:t,...s})=>{const{approval:r}=Cn();return r!=="pending"?null:e.jsx("div",{"data-slot":"confirmation-actions",className:F("flex items-center justify-end gap-2 self-end",t),...s})};Tl.displayName="ConfirmationActions";const Il=({variant:t="default",...s})=>e.jsx(W,{className:"h-8 px-3 text-sm",variant:t,type:"button",...s});Il.displayName="ConfirmationAction";const Rl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("rounded-xl border bg-card text-card-foreground shadow-sm",t),...s}));Rl.displayName="Card";const Al=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("flex flex-col space-y-1.5 p-4",t),...s}));Al.displayName="CardHeader";const Ll=n.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:F("font-semibold leading-none tracking-tight",t),...s}));Ll.displayName="CardTitle";const Ml=n.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:F("text-sm text-muted-foreground",t),...s}));Ml.displayName="CardDescription";const Fl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("p-4 pt-0",t),...s}));Fl.displayName="CardContent";const _l=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("flex items-center p-4 pt-0",t),...s}));_l.displayName="CardFooter";const Ol=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("ml-auto shrink-0",t),...s}));Ol.displayName="CardAction";const Pn=n.createContext(null);function En(){const t=n.useContext(Pn);if(!t)throw new Error("Collapsible components must be used within <Collapsible>");return t}const Tn=n.forwardRef(({defaultOpen:t=!1,open:s,onOpenChange:r,className:a,children:o,...i},l)=>{const[c,m]=n.useState(t),d=s!==void 0,u=d?s:c,x=n.useCallback(p=>{d||m(p),r?.(p)},[d,r]),h=n.useMemo(()=>({open:u,onOpenChange:x}),[u,x]);return e.jsx(Pn.Provider,{value:h,children:e.jsx("div",{ref:l,"data-state":u?"open":"closed",className:a,...i,children:o})})});Tn.displayName="Collapsible";const In=n.forwardRef(({onClick:t,children:s,className:r,...a},o)=>{const{open:i,onOpenChange:l}=En(),c=n.useCallback(m=>{l(!i),t?.(m)},[i,l,t]);return e.jsx("button",{ref:o,type:"button","aria-expanded":i,"data-state":i?"open":"closed",onClick:c,className:r,...a,children:s})});In.displayName="CollapsibleTrigger";const Rn=n.forwardRef(({className:t,children:s,...r},a)=>{const{open:o}=En();return e.jsx("div",{ref:a,"data-state":o?"open":"closed",className:F("grid transition-[grid-template-rows] duration-200 ease-out",o?"grid-rows-[1fr]":"grid-rows-[0fr]",t),...r,children:e.jsx("div",{className:"overflow-hidden",children:s})})});Rn.displayName="CollapsibleContent";const Dl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke,{ref:r,className:F("flex flex-col",t),...s}));Dl.displayName=ke.displayName;const $l=n.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3",children:[e.jsx(et,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),e.jsx(ke.Input,{ref:r,className:F("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));$l.displayName=ke.Input.displayName;const zl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.List,{ref:r,className:F("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));zl.displayName=ke.List.displayName;const Ul=n.forwardRef((t,s)=>e.jsx(ke.Empty,{ref:s,className:"py-6 text-center text-sm text-muted-foreground",...t}));Ul.displayName=ke.Empty.displayName;const Gl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.Group,{ref:r,className:F("overflow-hidden p-1 text-foreground","[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));Gl.displayName=ke.Group.displayName;const Vl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.Item,{ref:r,className:F("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none","data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground","data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",t),...s}));Vl.displayName=ke.Item.displayName;const Kl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.Separator,{ref:r,className:F("-mx-1 h-px bg-border",t),...s}));Kl.displayName=ke.Separator.displayName;function Bl({checked:t,onToggle:s,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:a,toggleDarkMode:o}=br(),i=typeof t=="boolean"&&typeof s=="function",l=i?t:a,c=()=>{if(i&&s){s(!l);return}o()};return e.jsxs("button",{onClick:c,className:F("relative inline-flex h-7 w-12 flex-shrink-0 touch-manipulation cursor-pointer items-center rounded-full border-2 transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",l?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":l,"aria-label":r,children:[e.jsx("span",{className:"sr-only",children:r}),e.jsx("span",{className:F("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",l?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:l?e.jsx(ho,{className:"h-3 w-3 text-primary"}):e.jsx(go,{className:"h-3 w-3 text-white dark:text-background"})})]})}const An=n.createContext(null);function Ln(){const t=n.useContext(An);if(!t)throw new Error("Dialog components must be used within <Dialog>");return t}const Mn=({open:t,onOpenChange:s,defaultOpen:r=!1,children:a})=>{const[o,i]=n.useState(r),l=n.useRef(null),c=t!==void 0,m=c?t:o,d=n.useCallback(x=>{c||i(x),s?.(x)},[c,s]),u=n.useMemo(()=>({open:m,onOpenChange:d,triggerRef:l}),[m,d]);return e.jsx(An.Provider,{value:u,children:a})},Wl=n.forwardRef(({onClick:t,children:s,asChild:r,...a},o)=>{const{onOpenChange:i,triggerRef:l}=Ln(),c=n.useCallback(m=>{i(!0),t?.(m)},[i,t]);if(r&&n.isValidElement(s)){const m=s;return n.cloneElement(m,{onClick:d=>{i(!0),m.props.onClick?.(d)},ref:d=>{l.current=d,typeof o=="function"?o(d):o&&(o.current=d)}})}return e.jsx("button",{ref:m=>{l.current=m,typeof o=="function"?o(m):o&&(o.current=m)},type:"button",onClick:c,...a,children:s})});Wl.displayName="DialogTrigger";const Zr='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',kr=n.forwardRef(({className:t,children:s,onEscapeKeyDown:r,onPointerDownOutside:a,wrapperClassName:o,animationClassName:i,...l},c)=>{const{open:m,onOpenChange:d,triggerRef:u}=Ln(),x=n.useRef(null),h=n.useRef(null);return n.useEffect(()=>{m?h.current=document.activeElement:h.current&&((u.current||h.current)?.focus(),h.current=null)},[m,u]),n.useEffect(()=>{if(!m)return;const p=b=>{if(b.key==="Escape"){b.stopPropagation(),r?.(),d(!1);return}if(b.key==="Tab"&&x.current){const g=Array.from(x.current.querySelectorAll(Zr));if(g.length===0)return;const v=g[0],S=g[g.length-1];b.shiftKey&&document.activeElement===v?(b.preventDefault(),S.focus()):!b.shiftKey&&document.activeElement===S&&(b.preventDefault(),v.focus())}};document.addEventListener("keydown",p,!0);const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=f}},[m,d,r]),n.useEffect(()=>{m&&x.current&&requestAnimationFrame(()=>{x.current?.querySelector(Zr)?.focus()})},[m]),m?ys.createPortal(e.jsxs("div",{className:F("fixed inset-0 z-50",o),children:[e.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{a?.(),d(!1)},"aria-hidden":!0}),e.jsx("div",{ref:p=>{x.current=p,typeof c=="function"?c(p):c&&(c.current=p)},role:"dialog","aria-modal":"true",className:F("fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2","rounded-xl border bg-popover text-popover-foreground shadow-lg",i??"animate-dialog-content-show",t),...l,children:s})]}),document.body):null});kr.displayName="DialogContent";const Sr=n.forwardRef(({className:t,...s},r)=>e.jsx("h2",{ref:r,className:F("sr-only",t),...s}));Sr.displayName="DialogTitle";const me=n.forwardRef(({className:t,type:s,...r},a)=>e.jsx("input",{type:s,className:F("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:a,...r}));me.displayName="Input";const Fn=n.forwardRef(({className:t,children:s,...r},a)=>e.jsx("div",{className:F(t,"relative overflow-hidden"),...r,children:e.jsx("div",{ref:a,className:"h-full w-full overflow-auto rounded-[inherit]",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:s})}));Fn.displayName="ScrollArea";const _n=n.memo(({children:t,className:s,as:r="span"})=>e.jsx(r,{className:F("animate-shimmer inline-block bg-[length:250%_100%] bg-clip-text text-transparent","bg-[linear-gradient(90deg,transparent_33%,hsl(var(--foreground))_50%,transparent_67%),linear-gradient(hsl(var(--muted-foreground)),hsl(var(--muted-foreground)))]",s),children:t}));_n.displayName="Shimmer";const On=n.createContext(null),Hl=()=>{const t=n.useContext(On);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Jl=1e3,ql=1e3,Ql=n.memo(({className:t,isStreaming:s=!1,open:r,defaultOpen:a,onOpenChange:o,duration:i,children:l,...c})=>{const m=a??s,d=a===!1,[u,x]=n.useState(m),h=r!==void 0,p=h?r:u,f=n.useCallback(E=>{h||x(E),o?.(E)},[h,o]),[b,g]=n.useState(i),v=n.useRef(s),[S,k]=n.useState(!1),y=n.useRef(null);n.useEffect(()=>{i!==void 0&&g(i)},[i]),n.useEffect(()=>{s?(v.current=!0,y.current===null&&(y.current=Date.now())):y.current!==null&&(g(Math.ceil((Date.now()-y.current)/ql)),y.current=null)},[s]),n.useEffect(()=>{s&&!p&&!d&&f(!0)},[s,p,f,d]),n.useEffect(()=>{if(v.current&&!s&&p&&!S){const E=setTimeout(()=>{f(!1),k(!0)},Jl);return()=>clearTimeout(E)}},[s,p,f,S]);const P=n.useMemo(()=>({duration:b,isOpen:p,isStreaming:s,setIsOpen:f}),[b,p,s,f]);return e.jsx(On.Provider,{value:P,children:e.jsx(Tn,{open:p,onOpenChange:f,className:F("not-prose",t),...c,children:l})})});Ql.displayName="Reasoning";const Yl=(t,s)=>t||s===0?e.jsx(_n,{children:"Thinking..."}):s===void 0?e.jsx("p",{children:"Thought for a few seconds"}):e.jsxs("p",{children:["Thought for ",s," seconds"]}),Zl=n.memo(({className:t,children:s,getThinkingMessage:r=Yl,...a})=>{const{isStreaming:o,isOpen:i,duration:l}=Hl();return e.jsx(In,{className:F("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",t),...a,children:s??e.jsxs(e.Fragment,{children:[e.jsx(fo,{className:"h-4 w-4"}),r(o,l),e.jsx(ns,{className:F("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Zl.displayName="ReasoningTrigger";const Xl=n.memo(({className:t,children:s,...r})=>e.jsx(Rn,{className:F("mt-4 text-sm text-muted-foreground",t),...r,children:s}));Xl.displayName="ReasoningContent";function ec(t){switch(t){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}}function He({children:t,content:s,position:r="top",className:a="",delay:o=350}){const[i,l]=n.useState(!1),c=n.useRef(null),m=n.useRef(!1),d=n.useRef(null),u=n.useRef(null),[x,h]=n.useState(null),p=n.useCallback(()=>{const k=d.current;if(!k)return;const y=k.getBoundingClientRect(),P=8,E={position:"fixed",zIndex:9999};switch(r){case"bottom":E.left=y.left+y.width/2,E.top=y.bottom+P,E.transform="translateX(-50%)";break;case"left":E.left=y.left-P,E.top=y.top+y.height/2,E.transform="translate(-100%, -50%)";break;case"right":E.left=y.right+P,E.top=y.top+y.height/2,E.transform="translateY(-50%)";break;default:E.left=y.left+y.width/2,E.top=y.top-P,E.transform="translate(-50%, -100%)";break}h(E)},[r]),f=()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},b=()=>{f(),c.current=window.setTimeout(()=>{l(!0)},o)},g=()=>{f(),l(!1)},v=()=>{f(),m.current=!1,c.current=window.setTimeout(()=>{m.current=!0,l(!0)},o)},S=()=>{f(),!m.current&&l(!1)};return n.useEffect(()=>()=>{f()},[]),n.useEffect(()=>{if(!i||typeof document>"u")return;const k=y=>{const P=y.target;P instanceof Node&&d.current?.contains(P)||(l(!1),m.current=!1)};return document.addEventListener("pointerdown",k,!0),()=>document.removeEventListener("pointerdown",k,!0)},[i]),n.useEffect(()=>{if(!i){h(null);return}const k=window.requestAnimationFrame(p),y=()=>p();return window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{window.cancelAnimationFrame(k),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[i,p]),s?e.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:g,onTouchStart:v,onTouchEnd:S,onTouchCancel:S,children:[t,i&&typeof document<"u"&&ys.createPortal(e.jsxs("div",{ref:u,style:x||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:F("px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",a),children:[s,e.jsx("div",{className:F("absolute w-0 h-0 border-4 border-transparent",ec(r))})]}),document.body)]}):e.jsx(e.Fragment,{children:t})}const Dn=n.createContext(null),tc=n.forwardRef(({className:t,status:s="ready",children:r,...a},o)=>{const i=n.useMemo(()=>({status:s}),[s]);return e.jsx(Dn.Provider,{value:i,children:e.jsx("form",{ref:o,"data-slot":"prompt-input",className:F("relative overflow-hidden rounded-xl border border-border/50 bg-card/80 shadow-sm backdrop-blur-sm transition-all duration-200 focus-within:border-primary/30 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/15",t),...a,children:r})})});tc.displayName="PromptInput";const sc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:F("px-3 pt-3",t),...s}));sc.displayName="PromptInputHeader";const rc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:F("relative",t),...s}));rc.displayName="PromptInputBody";const ac=n.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:F("chat-input-placeholder block max-h-[40vh] w-full resize-none overflow-y-auto bg-transparent px-4 py-2 text-sm leading-6 text-foreground placeholder-muted-foreground/50 focus:outline-none sm:max-h-[300px]",t),...s}));ac.displayName="PromptInputTextarea";const nc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:F("flex items-center justify-between border-t border-border/30 px-3 py-2",t),...s}));nc.displayName="PromptInputFooter";const oc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:F("flex items-center gap-1",t),...s}));oc.displayName="PromptInputTools";const ic=n.forwardRef(({className:t,tooltip:s,children:r,...a},o)=>{const i=e.jsx(W,{ref:o,type:"button",variant:"ghost",size:"icon",className:F("h-8 w-8 [&_svg]:size-4",t),...a,children:r});return s?e.jsx(He,{content:s.shortcut?e.jsxs("span",{className:"flex items-center gap-1.5",children:[s.content,e.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:s.shortcut})]}):s.content,position:s.side??"top",children:i}):i});ic.displayName="PromptInputButton";const lc=n.forwardRef(({className:t,status:s,children:r,...a},o)=>{const i=n.useContext(Dn),l=s??i?.status??"ready",c=l==="submitted"||l==="streaming";return e.jsx(W,{ref:o,type:c?"button":"submit",variant:"default",size:"icon",className:F("h-8 w-8 shrink-0 rounded-lg",t),...a,children:r??(c?e.jsx(bo,{className:"h-3.5 w-3.5 fill-current"}):e.jsx(yo,{className:"h-4 w-4"}))})});lc.displayName="PromptInputSubmit";function $n({children:t,className:s,...r}){return e.jsx("div",{className:F("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",s),...r,children:t})}function zn({isActive:t,onClick:s,children:r,className:a,...o}){return e.jsx("button",{type:"button",onClick:s,className:F("flex shrink-0 touch-manipulation items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium outline-none transition-all duration-150 focus-visible:ring-2 focus-visible:ring-primary/60 focus-visible:ring-offset-1 focus-visible:ring-offset-muted",t?"bg-background text-foreground shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:bg-background/50 hover:text-foreground active:bg-background/70",a),...o,children:r})}const Un=n.createContext(null);function Gn(){const t=n.useContext(Un);if(!t)throw new Error("QueueItem sub-components must be used within <QueueItem>");return t}const cc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:F("space-y-0.5",t),...s}));cc.displayName="Queue";const dc=n.forwardRef(({status:t="pending",className:s,children:r,...a},o)=>{const i=n.useMemo(()=>({status:t}),[t]);return e.jsx(Un.Provider,{value:i,children:e.jsx("div",{ref:o,"data-slot":"queue-item","data-status":t,role:"listitem",className:F("flex items-start gap-2 py-0.5",s),...a,children:r})})});dc.displayName="QueueItem";const uc=n.forwardRef(({className:t,...s},r)=>{const{status:a}=Gn();return e.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:F("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",t),...s,children:[a==="completed"&&e.jsx("svg",{className:"h-3.5 w-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),a==="in_progress"&&e.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),a==="pending"&&e.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});uc.displayName="QueueItemIndicator";const mc=n.forwardRef(({className:t,children:s,...r},a)=>{const{status:o}=Gn();return e.jsx("div",{ref:a,"data-slot":"queue-item-content",className:F("min-w-0 flex-1 text-xs",o==="completed"&&"text-muted-foreground line-through",o==="in_progress"&&"font-medium text-foreground",o==="pending"&&"text-foreground",t),...r,children:s})});mc.displayName="QueueItemContent";const pc="https://github.com/CaineWind/wacli";function xc({updateAvailable:t,restartRequired:s,releaseInfo:r,latestVersion:a,currentVersion:o,onShowVersionModal:i,onShowSettings:l,t:c}){return e.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"px-2 py-1.5 md:px-2 md:py-1.5",children:e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-amber-300/60 bg-amber-50/80 px-2.5 py-2 dark:border-amber-700/40 dark:bg-amber-900/15",children:[e.jsx(Oe,{className:"h-4 w-4 flex-shrink-0 text-amber-500 dark:text-amber-400"}),e.jsx("span",{className:"min-w-0 flex-1 text-xs font-medium text-amber-700 dark:text-amber-300",children:c("version.restartRequired")})]})})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:e.jsxs("button",{className:"group flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-blue-50/80 dark:hover:bg-blue-900/15",onClick:i,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Ir,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-normal text-blue-600 dark:text-blue-300",children:r?.title||`v${a}`}),e.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:c("version.updateAvailable")})]})]})}),e.jsx("div",{className:"px-3 py-2 md:hidden",children:e.jsxs("button",{className:"flex h-11 w-full items-center gap-3 rounded-xl border border-blue-200/60 bg-blue-50/80 px-3.5 transition-all active:scale-[0.98] dark:border-blue-700/40 dark:bg-blue-900/15",onClick:i,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Ir,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-normal text-blue-600 dark:text-blue-300",children:r?.title||`v${a}`}),e.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:c("version.updateAvailable")})]})]})})]}),e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:e.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",onClick:l,children:[e.jsx(as,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:c("actions.settings")})]})}),!he&&e.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:e.jsxs("a",{href:pc,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["WindCli v",o," – ",c("branding.openSource")]})}),e.jsx("div",{className:"px-3 py-3 md:hidden",children:e.jsxs("button",{className:"flex h-10 w-full items-center gap-3 rounded-xl bg-muted/40 px-3.5 transition-all hover:bg-muted/60 active:scale-[0.98]",onClick:l,children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-background/80",children:e.jsx(as,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-normal text-foreground",children:c("actions.settings")})]})})]})}const Xr="WINDCLI_GITHUB_STARS",ea="WINDCLI_HIDE_GITHUB_STAR",hc=3600*1e3,gc=(t,s)=>{const[r,a]=n.useState(null),[o,i]=n.useState(()=>{try{return localStorage.getItem(ea)==="true"}catch{return!1}});n.useEffect(()=>{if(o)return;try{const d=localStorage.getItem(Xr);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<hc){a(u.count);return}}}catch{}(async()=>{try{const d=await fetch(`https://api.github.com/repos/${t}/${s}`);if(!d.ok)return;const x=(await d.json()).stargazers_count;if(typeof x=="number"){a(x);try{localStorage.setItem(Xr,JSON.stringify({count:x,timestamp:Date.now()}))}catch{}}}catch{}})()},[t,s,o]);const l=n.useCallback(()=>{i(!0);try{localStorage.setItem(ea,"true")}catch{}},[]),c=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:c,isDismissed:o,dismiss:l}},fc="https://github.com/CaineWind/wacli";function bc({className:t}){return e.jsx("svg",{className:t,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})})}function yc(){const{formattedCount:t,isDismissed:s,dismiss:r}=gc("CaineWind","wacli");return he||s?null:e.jsxs("div",{className:"group/star relative hidden md:block",children:[e.jsxs("a",{href:fc,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[e.jsx(bc,{className:"h-3.5 w-3.5"}),e.jsx(os,{className:"h-3 w-3"}),e.jsx("span",{className:"font-normal",children:"Star"}),t&&e.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:t})]}),e.jsx("button",{onClick:a=>{a.preventDefault(),a.stopPropagation(),r()},className:"absolute -right-1.5 -top-1.5 hidden h-4 w-4 items-center justify-center rounded-full border border-border/50 bg-muted text-muted-foreground transition-colors hover:text-foreground group-hover/star:flex","aria-label":"Dismiss",children:e.jsx(ge,{className:"h-2.5 w-2.5"})})]})}const vc=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl";function jc({isPWA:t,isMobile:s,isLoading:r,projectsCount:a,runningSessionsCount:o,archivedSessionsCount:i,isArchivedSessionsLoading:l,searchFilter:c,onSearchFilterChange:m,onClearSearchFilter:d,searchMode:u,onSearchModeChange:x,onRefresh:h,isRefreshing:p,onCreateProject:f,onCollapseSidebar:b,t:g}){const v=(a>0||o>0||i>0||l)&&!r,S=u==="conversations"?g("search.conversationsPlaceholder"):u==="archived"?g("search.archivedPlaceholder","Search archived sessions..."):u==="running"?g("search.runningPlaceholder","Search running sessions..."):g("projects.searchPlaceholder"),k=o>99?"99+":String(o),y=()=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-primary/90 shadow-sm",children:e.jsx("svg",{className:"h-3.5 w-3.5 text-primary-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),e.jsx("h1",{className:"truncate text-sm font-bold tracking-tight text-foreground",style:{fontFamily:Qa},children:g("app.title")})]});return e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"hidden px-3 pb-2 pt-3 md:block",style:{},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[he?e.jsx("a",{href:"https://cloudcli.ai/dashboard",className:"flex min-w-0 items-center gap-2.5 transition-opacity hover:opacity-80",title:g("tooltips.viewEnvironments"),children:e.jsx(y,{})}):e.jsx(y,{}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:h,disabled:p,title:g("tooltips.refresh"),children:e.jsx(is,{className:`h-3.5 w-3.5 ${p?"animate-spin":""}`})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:f,title:g("tooltips.createProject"),children:e.jsx(Ee,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:b,title:g("tooltips.hideSidebar"),children:e.jsx(vo,{className:"h-3.5 w-3.5"})})]})]}),e.jsx(yc,{}),v&&e.jsxs("div",{className:"mt-2.5 space-y-2",children:[e.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[e.jsxs("button",{onClick:()=>x("projects"),"aria-pressed":u==="projects",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ht,{className:"h-3 w-3"}),g("search.modeProjects")]}),e.jsxs("button",{onClick:()=>x("conversations"),"aria-pressed":u==="conversations",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ft,{className:"h-3 w-3"}),g("search.modeConversations")]}),e.jsx(He,{content:g("search.runningTooltip","Running sessions"),position:"top",children:e.jsx("button",{onClick:()=>x("running"),"aria-pressed":u==="running","aria-label":g("search.runningTooltip","Running sessions"),title:g("search.runningTooltip","Running sessions"),className:F("flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="running"?"bg-background shadow-sm text-foreground ring-1 ring-emerald-500/15":"text-muted-foreground hover:text-foreground"),children:e.jsxs("span",{className:"relative flex h-3 w-3 items-center justify-center",children:[e.jsx(Xe,{className:F("h-3 w-3",o>0&&"text-emerald-500")}),o>0&&e.jsx("span",{className:"absolute -right-2.5 -top-2 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-emerald-500 px-0.5 text-[8px] font-semibold leading-none text-white shadow-sm ring-1 ring-background",children:k})]})})}),e.jsx(He,{content:g("search.archiveOnlyTooltip","Archive only"),position:"top",children:e.jsx("button",{onClick:()=>x("archived"),"aria-pressed":u==="archived","aria-label":g("search.archiveOnlyTooltip","Archive only"),title:g("search.archiveOnlyTooltip","Archive only"),className:F("flex items-center justify-center rounded-md px-2.5 py-1.5 text-xs font-normal transition-all",u==="archived"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:e.jsx(ls,{className:"h-3 w-3"})})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(et,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),e.jsx(me,{type:"text",placeholder:S,value:c,onChange:P=>m(P.target.value),className:"nav-search-input h-9 rounded-xl border-0 pl-9 pr-14 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),c?e.jsx("button",{onClick:d,"aria-label":g("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-0.5 hover:bg-accent",children:e.jsx(ge,{className:"h-3 w-3 text-muted-foreground"})}):e.jsxs("kbd",{"aria-hidden":!0,title:g("tooltips.openCommandPalette"),className:"pointer-events-none absolute right-2.5 top-1/2 hidden -translate-y-1/2 items-center gap-0.5 rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground md:inline-flex",children:[vc,e.jsx("span",{children:"K"})]})]})]})]}),e.jsx("div",{className:"nav-divider hidden md:block"}),e.jsxs("div",{className:"p-3 pb-2 md:hidden",style:t&&s?{paddingTop:"16px"}:{},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[he?e.jsx("a",{href:"https://cloudcli.ai/dashboard",className:"flex min-w-0 items-center gap-2.5 transition-opacity active:opacity-70",title:g("tooltips.viewEnvironments"),children:e.jsx(y,{})}):e.jsx(y,{}),e.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-muted/50 transition-all active:scale-95",onClick:h,disabled:p,children:e.jsx(is,{className:`h-4 w-4 text-muted-foreground ${p?"animate-spin":""}`})}),e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/90 text-primary-foreground transition-all active:scale-95",onClick:f,children:e.jsx(xr,{className:"h-4 w-4"})})]})]}),v&&e.jsxs("div",{className:"mt-2.5 space-y-2",children:[e.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[e.jsxs("button",{onClick:()=>x("projects"),"aria-pressed":u==="projects",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ht,{className:"h-3 w-3"}),g("search.modeProjects")]}),e.jsxs("button",{onClick:()=>x("conversations"),"aria-pressed":u==="conversations",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ft,{className:"h-3 w-3"}),g("search.modeConversations")]}),e.jsx(He,{content:g("search.runningTooltip","Running sessions"),position:"top",children:e.jsxs("button",{onClick:()=>x("running"),"aria-pressed":u==="running","aria-label":g("search.runningTooltip","Running sessions"),title:g("search.runningTooltip","Running sessions"),className:F("flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="running"?"bg-background shadow-sm text-foreground ring-1 ring-emerald-500/15":"text-muted-foreground hover:text-foreground"),children:[e.jsxs("span",{className:"relative flex h-3 w-3 items-center justify-center",children:[e.jsx(Xe,{className:F("h-3 w-3",o>0&&"text-emerald-500")}),o>0&&e.jsx("span",{className:"absolute -right-2.5 -top-2 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-emerald-500 px-0.5 text-[8px] font-semibold leading-none text-white shadow-sm ring-1 ring-background",children:k})]}),e.jsx("span",{className:"sr-only",children:g("search.modeRunning","Running")})]})}),e.jsx(He,{content:g("search.archiveOnlyTooltip","Archive only"),position:"top",children:e.jsx("button",{onClick:()=>x("archived"),"aria-pressed":u==="archived","aria-label":g("search.archiveOnlyTooltip","Archive only"),title:g("search.archiveOnlyTooltip","Archive only"),className:F("flex items-center justify-center rounded-md px-2.5 py-1.5 text-xs font-normal transition-all",u==="archived"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:e.jsx(ls,{className:"h-3 w-3"})})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(et,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),e.jsx(me,{type:"text",placeholder:S,value:c,onChange:P=>m(P.target.value),className:"nav-search-input h-10 rounded-xl border-0 pl-10 pr-9 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),c&&e.jsx("button",{onClick:d,"aria-label":g("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-1 hover:bg-accent",children:e.jsx(ge,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),e.jsx("div",{className:"nav-divider md:hidden"})]})}const ta="WindCli",wc=t=>t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session",Nc=(t,s)=>{if(s)return wc(s);const r=t?.displayName?.trim();return r?`${r} - ${ta}`:ta},sa={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},kc={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},Sc=t=>t==="fully-configured"?{icon:jo,colorClassName:"text-green-500 dark:text-green-400",backgroundClassName:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"}:t==="taskmaster-only"?{icon:as,colorClassName:"text-blue-500 dark:text-blue-400",backgroundClassName:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"}:t==="mcp-only"?{icon:Aa,colorClassName:"text-amber-500 dark:text-amber-400",backgroundClassName:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"}:{icon:ge,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function Cc({status:t="not-configured",size:s="sm",className:r="",showLabel:a=!1}){const o=Sc(t),i=o.icon;return a?e.jsxs("div",{className:F("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",o.backgroundClassName,o.colorClassName,r),title:o.title,children:[e.jsx(i,{className:sa[s]}),e.jsx("span",{className:"font-normal",children:o.label})]}):e.jsx("div",{className:F("inline-flex items-center justify-center rounded-full transition-colors",o.backgroundClassName,kc[s],r),title:o.title,children:e.jsx(i,{className:F(sa[s],o.colorClassName)})})}function Pc(t){if(!t||typeof document>"u")return!1;const s=document.createElement("textarea");s.value=t,s.setAttribute("readonly",""),s.style.position="fixed",s.style.opacity="0",s.style.pointerEvents="none",document.body.appendChild(s),s.focus(),s.select();let r=!1;try{r=document.execCommand("copy")}catch{r=!1}finally{document.body.removeChild(s)}return r}async function Cr(t){if(!t)return!1;let s=!1;try{typeof navigator<"u"&&navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(t),s=!0)}catch{s=!1}return s||(s=Pc(t)),s}const Ec={claude:"Claude",codex:"Codex",cursor:"Cursor",opencode:"OpenCode"};function Tc({project:t,session:s,selectedSession:r,isProcessing:a,needsAttention:o,currentTime:i,editingSession:l,editingSessionName:c,onEditingSessionNameChange:m,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:x,onProjectSelect:h,onSessionSelect:p,onDeleteSession:f,t:b}){const g=Ri(s,i,b),v=r?.id===s.id,S=l===s.id,k=Rt(g.sessionTime,i),y=n.useRef(null),[P,E]=n.useState(!1),[C,T]=n.useState("idle"),[I,j]=n.useState(null),$=n.useRef(0),G=o&&!v,K=!G&&!a&&g.isActive,M=Ec[s.__provider];n.useEffect(()=>{if(!S||P)return;const te=q=>{const ye=y.current;ye&&!ye.contains(q.target)&&u()};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[S,P,u]);const X=()=>{h(t),p(s,t.projectId)},H=()=>{x(t.projectId,s.id,c,s.__provider)},B=()=>{f(t.projectId,s.id,g.sessionName,s.__provider)},w=async()=>{const te=++$.current;T("loading");try{const q=await ue.providerSessionId(s.id),se=(await q.json())?.data?.sessionId;if(!q.ok||typeof se!="string"||!se)throw new Error("Provider session ID is unavailable");if(te!==$.current)return;j(se),T("idle")}catch{if(te!==$.current)return;j(null),T("error")}},D=()=>{$.current+=1,T("idle"),j(null)},L=te=>{te?(j(null),w()):D()},O=te=>{E(te),L(te),!te&&S&&u()},U=()=>{d(s.id,g.sessionName)},N=()=>{H(),O(!1)},A=async()=>{if(!I){T("error");return}T("copying");const te=await Cr(I);T(te?"copied":"error")},ee=()=>{C==="error"&&!I?w():A()},V=C==="loading"||C==="copying",ae=C==="copied"?Fe:La,de=C==="loading"?`Loading ${M} session ID…`:C==="copied"?`${M} session ID copied`:C==="error"?I?`Couldn't copy ${M} session ID`:`${M} session ID unavailable`:`Copy ${M} session ID`;return e.jsxs("div",{className:"group relative",children:[(G||K)&&e.jsx("div",{className:"absolute left-0 top-1/2 -translate-x-1 -translate-y-1/2 transform",children:e.jsx(He,{content:G?b("tooltips.attentionRequiredIndicator",{defaultValue:"Session needs attention"}):b("tooltips.activeSessionIndicator"),position:"right",children:e.jsx("div",{role:"status","aria-label":G?b("tooltips.attentionRequiredIndicator",{defaultValue:"Session needs attention"}):b("tooltips.activeSessionIndicator"),className:F("h-2 w-2 animate-pulse rounded-full",G?"bg-amber-500":"bg-green-500")})})}),e.jsxs("div",{className:"md:hidden",children:[e.jsx("div",{className:F("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",v?"bg-primary/5 border-primary/20":"",!v&&a?"border-border/60 bg-muted/20":!v&&g.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:X,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:F("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",v?"bg-primary/10":"bg-muted/50"),children:e.jsx(_e,{provider:s.__provider,className:"h-3 w-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground",title:g.sessionName,children:g.sessionName}),a?e.jsx("span",{className:"ml-auto flex-shrink-0",children:e.jsx(He,{content:b("tooltips.processingSessionIndicator","Processing session"),position:"top",children:e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground",children:e.jsx(ve,{className:"h-3 w-3 animate-spin"})})})}):k&&e.jsx("span",{className:"ml-auto flex-shrink-0 text-[11px] text-muted-foreground",children:k})]}),e.jsx("div",{className:"mt-0.5 flex items-center",children:g.messageCount>0&&e.jsx(Pe,{variant:"secondary",className:"px-1 py-0 text-xs",children:g.messageCount})})]}),e.jsx("button",{type:"button","aria-label":`Session options for ${g.sessionName}`,"aria-haspopup":"dialog","aria-expanded":P,className:"ml-1 flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted active:scale-95",onClick:te=>{te.stopPropagation(),O(!0)},children:e.jsx(Rr,{className:"h-4 w-4"})})]})}),e.jsx(Mn,{open:P,onOpenChange:O,children:e.jsxs(kr,{"aria-describedby":"mobile-session-options-description",wrapperClassName:"md:hidden",animationClassName:"animate-bottom-sheet-content-show motion-reduce:animate-none",className:"bottom-0 left-0 top-auto max-w-none translate-x-0 translate-y-0 rounded-b-none rounded-t-2xl border-x-0 border-b-0 px-4 pb-safe-area-inset-bottom pt-3",children:[e.jsx(Sr,{children:"Session options"}),e.jsx("div",{className:"mx-auto mb-4 h-1 w-10 rounded-full bg-muted-foreground/30","aria-hidden":"true"}),e.jsxs("div",{className:"mb-4 flex items-center gap-3 px-1",children:[e.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-muted",children:e.jsx(_e,{provider:s.__provider,className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:g.sessionName,children:g.sessionName}),e.jsxs("p",{id:"mobile-session-options-description",className:"text-xs text-muted-foreground",children:[M," session"]})]})]}),S?e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("label",{htmlFor:`mobile-session-rename-${s.id}`,className:"block px-1 text-xs font-medium text-muted-foreground",children:"Session name"}),e.jsx("input",{id:`mobile-session-rename-${s.id}`,type:"text",value:c,onChange:te=>m(te.target.value),onKeyDown:te=>{te.stopPropagation(),te.key==="Enter"&&N()},className:"w-full rounded-xl border-2 border-primary/40 bg-background px-3 py-3 text-foreground shadow-sm focus:border-primary focus:outline-none",autoFocus:!0,autoComplete:"off",style:{fontSize:"16px"}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:N,className:"flex min-h-12 flex-1 items-center justify-center gap-2 rounded-xl bg-primary px-4 py-3 text-sm font-medium text-primary-foreground transition-transform active:scale-95",children:[e.jsx(Fe,{className:"h-5 w-5 flex-shrink-0"}),"Save"]}),e.jsxs("button",{type:"button",onClick:u,className:"flex min-h-12 flex-1 items-center justify-center gap-2 rounded-xl border border-border bg-muted/35 px-4 py-3 text-sm font-medium text-foreground transition-colors active:bg-muted",children:[e.jsx(ge,{className:"h-5 w-5 flex-shrink-0"}),"Cancel"]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:U,className:"flex min-h-12 w-full items-center gap-3 rounded-xl border border-border bg-muted/35 px-4 py-3 text-left text-foreground transition-colors active:bg-muted",children:[e.jsx(Ar,{className:"h-5 w-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Rename session"})]}),e.jsxs("button",{type:"button",onClick:ee,disabled:V,className:F("flex min-h-12 w-full items-center gap-3 rounded-xl border px-4 py-3 text-left transition-colors",C==="copied"?"border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300":C==="error"?"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300":"border-border bg-muted/35 text-foreground active:bg-muted"),children:[V?e.jsx(ve,{className:"h-5 w-5 flex-shrink-0 animate-spin"}):e.jsx(ae,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-sm font-medium",children:de}),C==="error"&&e.jsx("span",{className:"mt-0.5 block text-xs",children:"Tap to try again."})]})]}),!a&&e.jsxs("button",{type:"button",onClick:()=>{O(!1),B()},className:"flex min-h-12 w-full items-center gap-3 rounded-xl px-4 py-3 text-left text-red-600 transition-colors active:bg-red-500/10 dark:text-red-400",children:[e.jsx(Te,{className:"h-5 w-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Archive or delete session"})]})]}),!S&&e.jsx("button",{type:"button",onClick:()=>O(!1),className:"mb-3 mt-2 min-h-11 w-full rounded-xl text-sm font-medium text-muted-foreground transition-colors active:bg-muted",children:"Cancel"})]})})]}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx("a",{href:`/session/${s.id}`,className:F(Nn({variant:"ghost"}),"h-auto w-full justify-start rounded-md border bg-card p-2 pr-11 text-left font-normal transition-all duration-150",v?"border-primary/20 bg-primary/5":"border-border/30",!v&&a?"border-border/60 bg-muted/20 hover:bg-muted/25":!v&&g.isActive?"border-green-500/30 bg-green-50/5 hover:bg-green-50/10 dark:bg-green-900/5 dark:hover:bg-green-900/10":"hover:bg-accent/50"),onClick:te=>{te.metaKey||te.ctrlKey||te.shiftKey||te.altKey||(te.preventDefault(),p(s,t.projectId))},children:e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsx("div",{className:F("flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/50"),children:e.jsx(_e,{provider:s.__provider,className:"h-3 w-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground",title:g.sessionName,children:g.sessionName}),a?e.jsx("span",{className:F("ml-auto flex-shrink-0 transition-opacity duration-200",S?"opacity-0":"group-hover:opacity-0"),children:e.jsx(He,{content:b("tooltips.processingSessionIndicator","Processing session"),position:"top",children:e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground",children:e.jsx(ve,{className:"h-3 w-3 animate-spin"})})})}):k&&e.jsx("span",{className:F("ml-auto flex-shrink-0 text-[11px] text-muted-foreground transition-opacity duration-200",S?"opacity-0":"group-hover:opacity-0"),children:k})]}),e.jsx("div",{className:"mt-0.5 flex items-center",children:g.messageCount>0&&e.jsx(Pe,{variant:"secondary",className:"px-1 py-0 text-xs",children:g.messageCount})})]})]})}),e.jsx("div",{ref:y,className:"absolute right-2 top-1/2 flex -translate-y-1/2 transform items-center gap-1 opacity-100 transition-all duration-200",children:S?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:c,onChange:te=>m(te.target.value),onKeyDown:te=>{te.stopPropagation(),te.key==="Enter"?H():te.key==="Escape"&&u()},onClick:te=>te.stopPropagation(),className:"w-32 rounded border border-border bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40",onClick:te=>{te.stopPropagation(),H()},title:b("tooltips.save"),children:e.jsx(Fe,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40",onClick:te=>{te.stopPropagation(),u()},title:b("tooltips.cancel"),children:e.jsx(ge,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}):e.jsx(kn,{label:"Session options",ariaLabel:`Session options for ${g.sessionName}`,icon:Rr,iconOnly:!0,portal:!0,variant:"ghost",size:"icon",onOpenChange:L,triggerClassName:"h-7 w-7 text-muted-foreground opacity-70 hover:bg-muted hover:opacity-100",menuClassName:"w-[260px] rounded-xl p-1.5 shadow-xl",header:e.jsxs("div",{className:"mb-1 border-b border-border px-3 py-2",children:[e.jsx("p",{className:"truncate text-xs font-medium text-foreground",title:g.sessionName,children:g.sessionName}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[M," session"]})]}),items:[{key:"rename",label:"Rename session",icon:Ar,onSelect:()=>d(s.id,g.sessionName)},{key:"copy",label:de,description:C==="error"?"Click to try again.":void 0,icon:ae,loading:V,closeOnSelect:!1,onSelect:ee},...a?[]:[{key:"delete",label:"Archive or delete session",icon:Te,isDanger:!0,showDividerBefore:!0,onSelect:B}]]})})]})]})}function Ic(){return e.jsx(e.Fragment,{children:Array.from({length:3}).map((t,s)=>e.jsx("div",{className:"rounded-md p-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+s*15}%`}}),e.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},s))})}function Rc({project:t,isExpanded:s,sessions:r,selectedSession:a,initialSessionsLoaded:o,hasMoreSessions:i,isLoadingMoreSessions:l,activeSessions:c,attentionSessionIds:m,currentTime:d,editingSession:u,editingSessionName:x,onEditingSessionNameChange:h,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:b,onProjectSelect:g,onSessionSelect:v,onDeleteSession:S,onLoadMoreSessions:k,onNewSession:y,t:P}){if(!s)return null;const E=r.length>0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[e.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:e.jsxs("button",{className:"flex h-8 w-full items-center justify-center gap-2 rounded-md bg-primary text-xs font-medium text-primary-foreground transition-all duration-150 hover:bg-primary/90 active:scale-[0.98]",onClick:()=>{g(t),y(t)},children:[e.jsx(Ee,{className:"h-3 w-3"}),P("sessions.newSession")]})}),e.jsxs(W,{variant:"default",size:"sm",className:"hidden h-8 w-full justify-start gap-2 bg-primary text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 md:flex",onClick:()=>y(t),children:[e.jsx(Ee,{className:"h-3 w-3"}),P("sessions.newSession")]}),o?E?e.jsxs(e.Fragment,{children:[r.map(C=>e.jsx(Tc,{project:t,session:C,selectedSession:a,isProcessing:c.has(C.id),needsAttention:m.has(C.id),currentTime:d,editingSession:u,editingSessionName:x,onEditingSessionNameChange:h,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:b,onProjectSelect:g,onSessionSelect:v,onDeleteSession:S,t:P},C.id)),i&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-full justify-center text-xs text-muted-foreground hover:text-foreground",onClick:()=>k(t.projectId),disabled:l,children:l?P("sessions.loadingSessions"):"Load more sessions"})]}):e.jsx("div",{className:"px-3 py-2 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:P("sessions.noSessions")})}):e.jsx(Ic,{})]})}const Ac=(t,s)=>{const r=Number(t.sessionMeta?.total??s.length);return String(r)};function Lc({project:t,selectedProject:s,selectedSession:r,isExpanded:a,isDeleting:o,isStarred:i,editingProject:l,editingName:c,sessions:m,initialSessionsLoaded:d,isLoadingMoreSessions:u,currentTime:x,editingSession:h,editingSessionName:p,tasksEnabled:f,mcpServerStatus:b,onEditingNameChange:g,onToggleProject:v,onProjectSelect:S,onToggleStarProject:k,onStartEditingProject:y,onCancelEditingProject:P,onSaveProjectName:E,onDeleteProject:C,onSessionSelect:T,onDeleteSession:I,onLoadMoreSessions:j,activeSessions:$,attentionSessionIds:G,onNewSession:K,onEditingSessionNameChange:M,onStartEditingSession:X,onCancelEditingSession:H,onSaveEditingSession:B,t:w}){const D=s?.projectId===t.projectId,L=l===t.projectId,O=Number(t.sessionMeta?.total??m.length),U=Ac(t,m),N=`${U} session${O===1?"":"s"}`,A=Mi(t,b),ee=n.useRef(null);n.useEffect(()=>{if(!L||!ee.current)return;let q=0;const ye=()=>{window.cancelAnimationFrame(q),q=window.requestAnimationFrame(()=>{ee.current?.scrollIntoView({block:"center",inline:"nearest"})})};return ye(),window.visualViewport?.addEventListener("resize",ye),()=>{window.cancelAnimationFrame(q),window.visualViewport?.removeEventListener("resize",ye)}},[L]);const V=()=>v(t.projectId),ae=()=>k(t.projectId),de=()=>{E(t.projectId)},te=()=>{s?.projectId!==t.projectId&&S(t),V()};return e.jsxs("div",{className:F("md:space-y-1",o&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"md:group group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:F("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",D&&"bg-primary/5 border-primary/20",i&&!D&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:V,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("button",{className:F("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",i?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:q=>{q.stopPropagation(),ae()},title:w(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(os,{className:F("w-4 h-4 transition-colors",i?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("div",{className:"min-w-0 flex-1",children:L?e.jsx("input",{ref:ee,type:"text",value:c,onChange:q=>g(q.target.value),className:"w-full rounded-lg border-2 border-primary/40 bg-background px-3 py-2 text-sm text-foreground shadow-sm transition-all duration-200 focus:border-primary focus:shadow-md focus:outline-none",placeholder:w("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:q=>q.stopPropagation(),onKeyDown:q=>{q.key==="Enter"&&de(),q.key==="Escape"&&P()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:[e.jsx("h3",{className:"truncate text-sm font-normal text-foreground",children:t.displayName}),f&&e.jsx(Cc,{status:A,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:L?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-green-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-green-600",onClick:q=>{q.stopPropagation(),de()},children:e.jsx(Fe,{className:"h-4 w-4 text-white"})}),e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-gray-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-gray-600",onClick:q=>{q.stopPropagation(),P()},children:e.jsx(ge,{className:"h-4 w-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-red-200 bg-red-500/10 active:scale-90 dark:border-red-800 dark:bg-red-900/30",onClick:q=>{q.stopPropagation(),C(t)},children:e.jsx(Te,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 active:scale-90 dark:border-primary/30 dark:bg-primary/20",onClick:q=>{q.stopPropagation(),y(t)},children:e.jsx(ar,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:a?e.jsx(ns,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(cs,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),e.jsxs(W,{variant:"ghost",className:F("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",D&&"bg-accent text-accent-foreground",i&&!D&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:te,children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:F("w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-all duration-200",i?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20":"opacity-40 hover:opacity-100 hover:bg-accent"),onClick:q=>{q.stopPropagation(),ae()},title:w(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(os,{className:F("w-3 h-3 transition-colors",i?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:L?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:c,onChange:q=>g(q.target.value),className:"w-full rounded border border-border bg-background px-2 py-1 text-sm text-foreground focus:ring-2 focus:ring-primary/20",placeholder:w("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:q=>{q.key==="Enter"&&de(),q.key==="Escape"&&P()}}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",title:t.fullPath,children:t.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"truncate text-sm font-normal text-foreground",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[U,t.fullPath!==t.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:t.fullPath,children:[" - ",t.fullPath.length>25?`...${t.fullPath.slice(-22)}`:t.fullPath]})]})]})})]}),e.jsx("div",{className:"flex flex-shrink-0 items-center gap-1",children:L?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:q=>{q.stopPropagation(),de()},children:e.jsx(Fe,{className:"h-3 w-3"})}),e.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-gray-500 transition-colors hover:bg-gray-50 hover:text-gray-700 dark:hover:bg-gray-800",onClick:q=>{q.stopPropagation(),P()},children:e.jsx(ge,{className:"h-3 w-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"touch:opacity-100 flex h-6 w-6 cursor-pointer items-center justify-center rounded opacity-0 transition-all duration-200 hover:bg-accent group-hover:opacity-100",onClick:q=>{q.stopPropagation(),y(t)},title:w("tooltips.renameProject"),children:e.jsx(ar,{className:"h-3 w-3"})}),e.jsx("div",{className:"touch:opacity-100 flex h-6 w-6 cursor-pointer items-center justify-center rounded opacity-0 transition-all duration-200 hover:bg-red-50 group-hover:opacity-100 dark:hover:bg-red-900/20",onClick:q=>{q.stopPropagation(),C(t)},title:w("tooltips.deleteProject"),children:e.jsx(Te,{className:"h-3 w-3 text-red-600 dark:text-red-400"})}),a?e.jsx(ns,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):e.jsx(cs,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),e.jsx(Rc,{project:t,isExpanded:a,sessions:m,selectedSession:r,initialSessionsLoaded:d,hasMoreSessions:!!t.sessionMeta?.hasMore,isLoadingMoreSessions:u,activeSessions:$,attentionSessionIds:G,currentTime:x,editingSession:h,editingSessionName:p,onEditingSessionNameChange:M,onStartEditingSession:X,onCancelEditingSession:H,onSaveEditingSession:B,onProjectSelect:S,onSessionSelect:T,onDeleteSession:I,onLoadMoreSessions:j,onNewSession:K,t:w})]})}function Mc({isLoading:t,loadingProgress:s,projectsCount:r,filteredProjectsCount:a,t:o}){return t?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:o("projects.loadingProjects")}),s&&s.total>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${s.current/s.total*100}%`}})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.current,"/",s.total," ",o("projects.projects")]}),s.currentProject&&e.jsx("p",{className:"mx-auto max-w-[200px] truncate text-xs text-muted-foreground/70",title:s.currentProject,children:s.currentProject.split("-").slice(-2).join("/")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:o("projects.fetchingProjects")})]}):r===0?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx(ht,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:o("projects.noProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o("projects.runClaudeCli")})]}):a===0?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx(et,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:o("projects.noMatchingProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o("projects.tryDifferentSearch")})]}):null}function ra({projects:t,filteredProjects:s,selectedProject:r,selectedSession:a,isLoading:o,loadingProgress:i,expandedProjects:l,editingProject:c,editingName:m,initialSessionsLoaded:d,currentTime:u,editingSession:x,editingSessionName:h,deletingProjects:p,tasksEnabled:f,mcpServerStatus:b,getProjectSessions:g,onLoadMoreSessions:v,loadingMoreProjects:S,activeSessions:k,attentionSessionIds:y,forceExpanded:P=!1,isProjectStarred:E,onEditingNameChange:C,onToggleProject:T,onProjectSelect:I,onToggleStarProject:j,onStartEditingProject:$,onCancelEditingProject:G,onSaveProjectName:K,onDeleteProject:M,onSessionSelect:X,onDeleteSession:H,onNewSession:B,onEditingSessionNameChange:w,onStartEditingSession:D,onCancelEditingSession:L,onSaveEditingSession:O,t:U}){const N=Nc(r,a),A=e.jsx(Mc,{isLoading:o,loadingProgress:i,projectsCount:t.length,filteredProjectsCount:s.length,t:U});n.useEffect(()=>{document.title=N},[N]);const ee=!o&&t.length>0&&s.length>0;return e.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:ee?s.map(V=>e.jsx(Lc,{project:V,selectedProject:r,selectedSession:a,isExpanded:P||l.has(V.projectId),isDeleting:p.has(V.projectId),isStarred:E(V.projectId),editingProject:c,editingName:m,sessions:g(V),initialSessionsLoaded:d.has(V.projectId),isLoadingMoreSessions:S.has(V.projectId),currentTime:u,editingSession:x,editingSessionName:h,tasksEnabled:f,mcpServerStatus:b,onEditingNameChange:C,onToggleProject:T,onProjectSelect:I,onToggleStarProject:j,onStartEditingProject:$,onCancelEditingProject:G,onSaveProjectName:K,onDeleteProject:M,onSessionSelect:X,onDeleteSession:H,onLoadMoreSessions:v,activeSessions:k,attentionSessionIds:y,onNewSession:B,onEditingSessionNameChange:w,onStartEditingSession:D,onCancelEditingSession:L,onSaveEditingSession:O,t:U},V.projectId)):A})}function Fc(){return e.jsx("div",{className:"space-y-1 px-1","aria-label":"Loading recent conversations",children:Array.from({length:8}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-2 py-2.5",children:[e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md bg-muted"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${72-s*3}%`}}),e.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-muted/70"})]})]},s))})}function _c({conversations:t,total:s,hasMore:r,isLoading:a,isLoadingMore:o,hasError:i,selectedSession:l,currentTime:c,onConversationSelect:m,onLoadMore:d,onRetry:u,t:x}){return a&&t.length===0?e.jsx(Fc,{}):i&&t.length===0?e.jsxs("div",{className:"px-4 py-10 text-center",children:[e.jsx(ft,{className:"mx-auto mb-3 h-6 w-6 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:x("recent.loadFailed","Could not load recent conversations")}),e.jsx(W,{variant:"ghost",size:"sm",className:"mt-2",onClick:u,children:x("buttons.retry",{ns:"common",defaultValue:"Try again"})})]}):t.length===0?e.jsxs("div",{className:"px-4 py-10 text-center",children:[e.jsx(ft,{className:"mx-auto mb-3 h-6 w-6 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:x("recent.emptyTitle","No conversations yet")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:x("recent.emptyDescription","Your most recently updated conversations will appear here.")})]}):e.jsxs("div",{className:"px-1","data-testid":"recent-conversations-list",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5 pt-0.5",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:x("recent.title","Recent conversations")}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:s})]}),e.jsx("div",{className:"space-y-0.5",children:t.map(h=>{const p=String(l?.id??"")===h.sessionId,f=Rt(h.lastActivity,c),b=g=>{g.button!==0||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||(g.preventDefault(),m(h.projectId,h.sessionId,h.provider))};return e.jsxs("a",{href:`/session/${h.sessionId}`,onClick:b,"data-testid":"recent-conversation-row",className:F("group flex min-w-0 items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",p?"bg-primary/10 text-foreground":"text-foreground hover:bg-accent/60"),children:[e.jsx("span",{className:F("flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md",p?"bg-primary/10":"bg-muted/60"),children:e.jsx(_e,{provider:h.provider,className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[13px] font-normal leading-4",children:h.sessionTitle}),e.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[10px] leading-3 text-muted-foreground",children:[e.jsx("span",{className:"truncate",children:h.projectDisplayName}),f&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-shrink-0 text-muted-foreground/40",children:"·"}),e.jsx("time",{className:"flex-shrink-0 tabular-nums",dateTime:h.lastActivity??void 0,children:f})]})]})]}),e.jsx(cs,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/40 transition-transform group-hover:translate-x-0.5 group-hover:text-muted-foreground"})]},h.sessionId)})}),r&&e.jsx(W,{variant:"ghost",size:"sm",className:"mt-1 h-8 w-full text-xs text-muted-foreground",onClick:d,disabled:o,children:o?x("recent.loadingMore","Loading more..."):x("recent.loadMore","Load older conversations")})]})}function Oc({snippet:t,highlights:s}){const r=[];let a=0;for(const o of s)o.start>a&&r.push(t.slice(a,o.start)),r.push(e.jsx("mark",{className:"rounded-sm bg-yellow-200 px-0.5 text-foreground dark:bg-yellow-800",children:t.slice(o.start,o.end)},o.start)),a=o.end;return a<t.length&&r.push(t.slice(a)),e.jsx("span",{className:"min-w-0 flex-1 break-words text-xs leading-relaxed text-muted-foreground",children:r})}function Dc(t){const s=new Map;for(const r of t){const a=r.projectId??r.projectPath??`session:${r.sessionId}`,o=s.get(a);if(o){o.sessions.push(r),(!o.latestActivity||r.lastActivity&&r.lastActivity>o.latestActivity)&&(o.latestActivity=r.lastActivity);continue}s.set(a,{key:a,projectId:r.projectId,projectDisplayName:r.projectDisplayName,projectPath:r.projectPath,isProjectArchived:r.isProjectArchived,sessions:[r],latestActivity:r.lastActivity})}return[...s.values()].sort((r,a)=>{const o=r.latestActivity??"";return(a.latestActivity??"").localeCompare(o)})}function $c({isPWA:t,isMobile:s,isLoading:r,projects:a,runningSessionsCount:o,archivedProjects:i,archivedSessions:l,archivedSessionsCount:c,isArchivedSessionsLoading:m,recentConversations:d,recentConversationsTotal:u,recentConversationsHasMore:x,isRecentConversationsLoading:h,isLoadingMoreRecentConversations:p,recentConversationsError:f,searchFilter:b,onSearchFilterChange:g,onClearSearchFilter:v,searchMode:S,onSearchModeChange:k,conversationResults:y,isSearching:P,searchProgress:E,onRestoreArchivedProject:C,onLoadMoreRecentConversations:T,onRetryRecentConversations:I,onArchivedSessionClick:j,onRestoreArchivedSession:$,onDeleteArchivedSession:G,onConversationResultClick:K,onRefresh:M,isRefreshing:X,onCreateProject:H,onCollapseSidebar:B,updateAvailable:w,restartRequired:D,releaseInfo:L,latestVersion:O,currentVersion:U,onShowVersionModal:N,onShowSettings:A,projectListProps:ee,t:V}){const ae=S==="conversations"&&b.trim().length>=2,de=!!(y&&(y.titleResults.length>0||y.results.length>0)),te=Dc(l),q=i.length+l.length,ye=s&&!!(ee.editingProject||ee.editingSession);return e.jsxs("div",{className:"flex h-full flex-col bg-background/80 backdrop-blur-sm md:w-72 md:select-none",style:{},children:[e.jsx(jc,{isPWA:t,isMobile:s,isLoading:r,projectsCount:a.length,runningSessionsCount:o,archivedSessionsCount:c,isArchivedSessionsLoading:m,searchFilter:b,onSearchFilterChange:g,onClearSearchFilter:v,searchMode:S,onSearchModeChange:k,onRefresh:M,isRefreshing:X,onCreateProject:H,onCollapseSidebar:B,t:V}),e.jsx(Fn,{className:"flex-1 overflow-y-auto overscroll-contain md:px-1.5 md:py-2",children:ae?P&&!y?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V("search.searching")}),E&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground/60",children:[V("search.projectsScanned",{count:E.scannedProjects}),"/",E.totalProjects]})]}):!P&&y&&!de?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx(et,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:V("search.noResults")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V("search.tryDifferentQuery")})]}):y&&(de||P)?e.jsxs("div",{className:"space-y-4 px-2","aria-live":"polite",children:[y.titleResults.length>0&&e.jsxs("section",{className:"space-y-1","aria-labelledby":"session-title-results-heading",children:[e.jsxs("div",{className:"flex items-center justify-between px-1 py-0.5",children:[e.jsx("h3",{id:"session-title-results-heading",className:"text-[11px] font-medium text-muted-foreground",children:V("search.sessionTitles","Session")}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:y.titleResults.length})]}),y.titleResults.map(se=>{const ne=Rt(se.lastActivity,ee.currentTime);return e.jsxs("button",{type:"button",className:"group flex w-full min-w-0 items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors hover:bg-accent/60",onClick:()=>K(se.projectId,se.sessionId,se.provider),children:[e.jsx("span",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md bg-muted/60",children:e.jsx(_e,{provider:se.provider,className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[13px] font-normal leading-4 text-foreground",children:se.sessionTitle}),e.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[10px] leading-3 text-muted-foreground",children:[e.jsx("span",{className:"truncate",children:se.projectDisplayName}),ne&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-shrink-0 text-muted-foreground/40",children:"·"}),e.jsx("time",{className:"flex-shrink-0 tabular-nums",dateTime:se.lastActivity??void 0,children:ne})]})]})]})]},`${se.provider}-${se.sessionId}`)})]}),(y.results.length>0||P)&&e.jsxs("section",{className:"space-y-3","aria-labelledby":"conversation-content-results-heading",children:[e.jsxs("div",{className:"flex items-center justify-between px-1 py-0.5",children:[e.jsx("h3",{id:"conversation-content-results-heading",className:"text-[11px] font-medium text-muted-foreground",children:V("search.conversationContents","Conversation contents")}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:V("search.matches",{count:y.totalMatches})})]}),P&&E&&e.jsxs("div",{className:"space-y-1.5 px-1",children:[e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[e.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-[1.5px] border-muted-foreground/40 border-t-primary"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/60",children:[E.scannedProjects,"/",E.totalProjects]})]}),e.jsx("div",{className:"h-0.5 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-primary/60 transition-all duration-300",style:{width:`${E.totalProjects>0?Math.round(E.scannedProjects/E.totalProjects*100):0}%`}})})]}),y.results.map(se=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1 py-1",children:[e.jsx(ht,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-xs font-normal text-foreground",children:se.projectDisplayName})]}),se.sessions.map(ne=>e.jsxs("button",{className:"w-full rounded-md px-2 py-2 text-left transition-colors hover:bg-accent/50",onClick:()=>K(se.projectId,ne.sessionId,ne.provider||ne.matches[0]?.provider||"claude",ne.matches[0]?.timestamp,ne.matches[0]?.snippet),children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[e.jsx(ft,{className:"h-3 w-3 flex-shrink-0 text-primary"}),e.jsx("span",{className:"truncate text-xs font-normal text-foreground",children:ne.sessionSummary}),ne.provider&&ne.provider!=="claude"&&e.jsx("span",{className:"flex-shrink-0 rounded bg-muted px-1 py-0.5 text-[9px] uppercase text-muted-foreground",children:ne.provider})]}),e.jsx("div",{className:"space-y-1 pl-4",children:ne.matches.map((re,Ie)=>e.jsxs("div",{className:"flex items-start gap-1",children:[e.jsx("span",{className:"mt-0.5 flex-shrink-0 text-[10px] font-normal uppercase text-muted-foreground/60",children:re.role==="user"?"U":"A"}),e.jsx(Oc,{snippet:re.snippet,highlights:re.highlights})]},Ie))})]},`${se.projectId??se.projectName}-${ne.sessionId}`))]},se.projectName))]})]}):null:S==="conversations"?e.jsx(_c,{conversations:d,total:u,hasMore:x,isLoading:h,isLoadingMore:p,hasError:f,selectedSession:ee.selectedSession,currentTime:ee.currentTime,onConversationSelect:K,onLoadMore:T,onRetry:I,t:V}):S==="running"?ee.filteredProjects.length===0?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg border border-border/70 bg-muted/50 md:mb-3",children:e.jsx(Xe,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:V("running.emptyTitle","No sessions running")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o>0?V("running.noMatchingSessions","No running sessions match this search."):V("running.emptyDescription","Active work will appear here while a provider is processing.")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"mx-2 flex items-center justify-between rounded-lg border border-border/60 bg-card/50 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",children:e.jsx(Xe,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"truncate text-xs font-normal text-foreground",children:V("running.title","Running now")})]}),e.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-normal text-emerald-700 dark:text-emerald-300",children:o})]}),e.jsx(ra,{...ee})]}):S==="archived"?m?e.jsxs("div",{className:"space-y-2 px-2 py-1","aria-live":"polite","aria-busy":"true",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-muted/70",children:e.jsx("div",{className:"h-3.5 w-3.5 animate-spin rounded-full border-[1.5px] border-muted-foreground/40 border-t-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-medium text-foreground",children:V("archived.loadingTitle","Loading archive...")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:V("archived.loadingDescription","Fetching hidden workspaces and sessions you can restore later.")})]})]}),[0,1].map(se=>e.jsx("div",{className:"animate-pulse rounded-xl border border-border/50 bg-card/40 p-3",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-muted"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx("div",{className:"h-3 w-2/3 rounded bg-muted"}),e.jsx("div",{className:"h-2.5 w-5/6 rounded bg-muted/70"})]})]})},se))]}):i.length===0&&te.length===0?e.jsx("div",{className:"px-3 py-8 text-center",children:e.jsxs("div",{className:"mx-auto max-w-[240px] rounded-2xl border border-dashed border-border/80 bg-muted/20 px-5 py-7",children:[e.jsx("div",{className:"mx-auto mb-3 flex h-10 w-10 items-center justify-center rounded-xl border border-border/70 bg-background shadow-sm",children:e.jsx(ls,{className:"h-[18px] w-[18px] text-muted-foreground"})}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:c>0?V("archived.noMatchingSessions","No matching archived items"):V("archived.emptyTitle","No archived items")}),e.jsx("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:c>0?V("archived.tryDifferentSearch","Try a different search term."):V("archived.emptyDescription","Archived workspaces and sessions will appear here when you hide them from the active list.")})]})}):e.jsxs("div",{className:"space-y-2.5 px-2 pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-1 pb-0.5 pt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground",children:e.jsx(ls,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs font-medium leading-none text-foreground",children:V("archived.title","Archive")}),e.jsx("p",{className:"mt-1 text-[10px] leading-none text-muted-foreground",children:V("archived.restoreHint","Restore items whenever you need them")})]})]}),e.jsx("span",{className:"rounded-full border border-border/60 bg-muted/40 px-2 py-0.5 text-[10px] tabular-nums text-muted-foreground",title:q!==c?`${q} of ${c}`:void 0,children:q!==c?`${q}/${c}`:c})]}),i.map(se=>{const ne=gs(se);return e.jsxs("section",{className:"group/archive overflow-hidden rounded-xl border border-border/70 bg-card/45 shadow-[0_1px_0_hsl(var(--border)/0.2)] transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-2.5",children:[e.jsx("span",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg border border-border/60 bg-muted/45 text-muted-foreground",children:e.jsx(ht,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("h3",{className:"truncate text-[13px] font-medium text-foreground",children:se.displayName}),ne.length>0&&e.jsx("span",{className:"flex-shrink-0 rounded-md bg-muted/60 px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground",children:ne.length})]}),e.jsx("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",title:se.fullPath,children:se.fullPath})]}),e.jsxs("button",{className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-lg border border-emerald-600/15 bg-emerald-500/10 px-2 text-[10px] font-medium text-emerald-700 transition-all hover:border-emerald-600/25 hover:bg-emerald-500/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/40 dark:text-emerald-300",onClick:()=>C(se.projectId),title:V("archived.restoreProject","Restore workspace"),"aria-label":`${V("archived.restoreProject","Restore workspace")}: ${se.displayName}`,children:[e.jsx(Lr,{className:"h-3 w-3"}),V("archived.restoreAction","Restore")]})]}),ne.length>0&&e.jsx("div",{className:"border-t border-border/45 bg-muted/[0.08]",children:ne.map(re=>e.jsxs("button",{className:"flex w-full items-center gap-2.5 border-b border-border/35 px-2.5 py-2 text-left transition-colors last:border-b-0 hover:bg-accent/35 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>j({sessionId:String(re.id),provider:re.__provider,projectId:se.projectId,projectPath:se.fullPath,projectDisplayName:se.displayName,sessionTitle:typeof re.summary=="string"&&re.summary.trim().length>0?re.summary:typeof re.name=="string"&&re.name.trim().length>0?re.name:String(re.id),createdAt:typeof re.created_at=="string"?re.created_at:null,updatedAt:typeof re.updated_at=="string"?re.updated_at:null,lastActivity:typeof re.lastActivity=="string"?re.lastActivity:typeof re.updated_at=="string"?re.updated_at:typeof re.created_at=="string"?re.created_at:null,isProjectArchived:!0}),children:[e.jsx("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md bg-background/70",children:e.jsx(_e,{provider:re.__provider,className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-xs text-foreground",children:typeof re.summary=="string"&&re.summary.trim().length>0?re.summary:typeof re.name=="string"&&re.name.trim().length>0?re.name:String(re.id)}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] text-muted-foreground/70",children:[e.jsx("span",{className:"uppercase tracking-wide",children:re.__provider}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:Rt(typeof re.lastActivity=="string"?re.lastActivity:typeof re.updated_at=="string"?re.updated_at:typeof re.created_at=="string"?re.created_at:null,ee.currentTime)})]})]})]},String(re.id)))})]},se.projectId)}),te.map(se=>e.jsxs("section",{className:"group/archive overflow-hidden rounded-xl border border-border/70 bg-card/45 shadow-[0_1px_0_hsl(var(--border)/0.2)] transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-2.5",children:[e.jsx("span",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg border border-border/60 bg-muted/45 text-muted-foreground",children:e.jsx(ht,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("h3",{className:"truncate text-[13px] font-medium text-foreground",children:se.projectDisplayName}),e.jsx("span",{className:"flex-shrink-0 rounded-md bg-muted/60 px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground",children:se.sessions.length})]}),se.projectPath&&e.jsx("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",title:se.projectPath,children:se.projectPath})]})]}),e.jsx("div",{className:"border-t border-border/45 bg-muted/[0.08]",children:se.sessions.map(ne=>e.jsxs("div",{className:"group/session flex items-center gap-1 border-b border-border/35 px-2.5 py-2 last:border-b-0 hover:bg-accent/35",children:[e.jsxs("button",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>j(ne),children:[e.jsx("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md bg-background/70",children:e.jsx(_e,{provider:ne.provider,className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-xs text-foreground",children:ne.sessionTitle}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] text-muted-foreground/70",children:[e.jsx("span",{className:"uppercase tracking-wide",children:ne.provider}),ne.lastActivity&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:Rt(ne.lastActivity,ee.currentTime)})]})]})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[e.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-emerald-500/10 hover:text-emerald-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/40 dark:hover:text-emerald-300",onClick:()=>$(ne.sessionId),title:V("archived.restore","Restore session"),"aria-label":`${V("archived.restore","Restore session")}: ${ne.sessionTitle}`,children:e.jsx(Lr,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/60 transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/40",onClick:()=>G(ne),title:V("archived.deletePermanently","Delete permanently"),"aria-label":`${V("archived.deletePermanently","Delete permanently")}: ${ne.sessionTitle}`,children:e.jsx(Te,{className:"h-3.5 w-3.5"})})]})]},ne.sessionId))})]},se.key))]}):e.jsx(ra,{...ee})}),!ye&&e.jsx(xc,{updateAvailable:w,restartRequired:D,releaseInfo:L,latestVersion:O,currentVersion:U,onShowVersionModal:N,onShowSettings:A,t:V})]})}const aa=[{id:"agents",labelKey:"mainTabs.agents",icon:Ma},{id:"appearance",labelKey:"mainTabs.appearance",icon:Fa},{id:"git",labelKey:"mainTabs.git",icon:Ft},{id:"api",labelKey:"mainTabs.apiTokens",icon:hr},{id:"voice",labelKey:"mainTabs.voice",icon:wo},{id:"tasks",labelKey:"mainTabs.tasks",icon:_a},{id:"browser",labelKey:"mainTabs.browser",icon:Oa},{id:"plugins",labelKey:"mainTabs.plugins",icon:No},{id:"notifications",labelKey:"mainTabs.notifications",icon:gr},{id:"about",labelKey:"mainTabs.about",icon:Da}];function zc({activeTab:t,onChange:s}){const{t:r}=ce("settings");return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"hidden w-56 flex-shrink-0 border-r border-border bg-muted/30 md:flex md:flex-col",children:e.jsx("nav",{className:"flex flex-col gap-1 p-3",children:aa.map(a=>{const o=a.icon,i=t===a.id;return e.jsxs("button",{onClick:()=>s(a.id),className:F("flex items-center gap-3 rounded-lg px-3 py-2.5 text-left text-sm font-medium transition-colors duration-150",i?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground active:bg-accent/50"),children:[e.jsx(o,{className:"h-4 w-4 flex-shrink-0"}),r(a.labelKey)]},a.id)})})}),e.jsx("div",{className:"flex-shrink-0 border-b border-border px-3 py-2 md:hidden",children:e.jsx($n,{className:"scrollbar-hide w-full overflow-x-auto",children:aa.map(a=>{const o=a.icon;return e.jsxs(zn,{isActive:t===a.id,onClick:()=>s(a.id),className:"flex-shrink-0",children:[e.jsx(o,{className:"h-3.5 w-3.5"}),r(a.labelKey)]},a.id)})})})]})}const Pr={claude:"Claude",cursor:"Cursor",codex:"Codex",opencode:"OpenCode"},vs={claude:["user","project","local"],cursor:["user","project"],codex:["user","project"],opencode:["user","project"]},js={claude:["stdio","http","sse"],cursor:["stdio","http"],codex:["stdio","http"],opencode:["stdio","http"]},Uc=["user","project"],Vn=["stdio","http"],Gc={claude:"bg-primary text-primary-foreground hover:bg-primary/90",cursor:"bg-primary text-primary-foreground hover:bg-primary/90",codex:"bg-primary text-primary-foreground hover:bg-primary/90",opencode:"bg-primary text-primary-foreground hover:bg-primary/90"},Er={claude:!1,cursor:!1,codex:!0,opencode:!1},Vc={name:"",scope:"user",workspacePath:"",transport:"stdio",command:"",args:[],env:{},cwd:"",url:"",headers:{},envVars:[],bearerTokenEnvVar:"",envHttpHeaders:{},importMode:"form",jsonInput:""},Kn=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Be=t=>typeof t=="string"&&t.trim()?t.trim():void 0,na=t=>Array.isArray(t)?t.filter(s=>typeof s=="string"):void 0,Js=t=>{if(!Kn(t))return;const s={};return Object.entries(t).forEach(([r,a])=>{typeof a=="string"&&(s[r]=a)}),Object.keys(s).length>0?s:void 0},qs=t=>Object.entries(t).map(([s,r])=>`${s}=${r}`).join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/StandaloneShell-C_SgfnxT.js","assets/vendor-react-C2GTiUCy.js","assets/Shell-eRBEAkRb.js","assets/vendor-ui-CAUHSABu.js","assets/vendor-i18n-B6HjLCnN.js","assets/Shell-DrlLKa8f.css","assets/vendor-data-DsEZeNPr.js","assets/vendor-markdown-DkITEES2.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as n,j as e,b as ys,c as qt}from"./vendor-react-C2GTiUCy.js";import{X as ge,P as po,S as as,T as Oe,a as xo,L as ve,C as ns,_ as ke,b as et,M as ho,c as go,B as fo,d as bo,e as yo,f as Ir,g as os,R as is,h as Ee,i as vo,F as ht,j as ft,A as Xe,k as ls,l as xr,m as jo,n as Aa,E as Rr,o as Fe,p as Ar,q as La,r as Te,s as ar,t as cs,u as Lr,v as Ma,w as Fa,G as Ft,K as hr,x as wo,y as _a,z as Oa,D as No,H as gr,I as Da,J as ds,N as Lt,O as nr,Q as ko,U as $a,Z as So,V as Co,W as Vs,Y as Mr,$ as Fr,a0 as Po,a1 as Eo,a2 as To,a3 as Io,a4 as fr,a5 as Ro,a6 as Mt,a7 as za,a8 as us,a9 as Ua,aa as Ga,ab as _r,ac as Or,ad as Ao,ae as Lo,af as or,ag as Mo,ah as Fo,ai as _o,aj as Oo,ak as Do,al as $o,am as zo,an as Uo,ao as Go}from"./vendor-ui-CAUHSABu.js";import{u as ce}from"./vendor-i18n-B6HjLCnN.js";import{p as Vo}from"./vendor-data-DsEZeNPr.js";import{M as Ko,r as Bo}from"./vendor-markdown-DkITEES2.js";const Va=n.createContext(),br=()=>{const t=n.useContext(Va);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},Em=({children:t})=>{const[s,r]=n.useState(()=>{const i=localStorage.getItem("theme");return i?i==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1});n.useEffect(()=>{if(s){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const i=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');i&&i.setAttribute("content","black-translucent");const l=document.querySelector('meta[name="theme-color"]');l&&l.setAttribute("content","#141414")}else{document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light");const i=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');i&&i.setAttribute("content","default");const l=document.querySelector('meta[name="theme-color"]');l&&l.setAttribute("content","#f6f4ef")}},[s]),n.useEffect(()=>{if(!window.matchMedia)return;const i=window.matchMedia("(prefers-color-scheme: dark)"),l=c=>{localStorage.getItem("theme")||r(c.matches)};return i.addEventListener("change",l),()=>i.removeEventListener("change",l)},[]);const o={isDarkMode:s,toggleDarkMode:()=>{r(i=>!i)}};return e.jsx(Va.Provider,{value:o,children:t})},Wo={},he=Wo?.VITE_IS_PLATFORM==="true",ir="auth-token-refreshed",lr="auth-session-expired",ms=t=>typeof t=="string"&&/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(t),Ka=t=>{if(!ms(t))return null;try{const s=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r=s.padEnd(s.length+(4-s.length%4)%4,"="),a=JSON.parse(atob(r));return typeof a.iat!="number"||!Number.isFinite(a.iat)||typeof a.exp!="number"||!Number.isFinite(a.exp)?null:{issuedAt:a.iat*1e3,expiresAt:a.exp*1e3}}catch{return null}},Ho=6e4,Ba=t=>{const s=Ka(t);return s?Date.now()>=s.expiresAt+Ho:!1},Dr=t=>{const s=Ka(t);if(!s)return null;const r=s.issuedAt+(s.expiresAt-s.issuedAt)/2;return Math.max(0,r-Date.now())},yr=()=>{localStorage.removeItem("auth-token"),typeof window<"u"&&window.dispatchEvent(new Event(lr))},vr=()=>{const t=localStorage.getItem("auth-token");return t&&Ba(t)?(yr(),null):t},Wa=t=>ms(t)?(localStorage.setItem("auth-token",t),typeof window<"u"&&window.dispatchEvent(new CustomEvent(ir,{detail:t})),!0):!1,z=(t,s={})=>{const r=vr(),a={};return s.body instanceof FormData||(a["Content-Type"]="application/json"),!he&&r&&(a.Authorization=`Bearer ${r}`),fetch(t,{...s,headers:{...a,...s.headers}}).then(o=>{const i=o.headers.get("X-Refreshed-Token");return i&&Wa(i),o.headers.get("X-Auth-Error")&&yr(),o})},ue={auth:{status:()=>fetch("/api/auth/status"),login:(t,s)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})}),register:(t,s)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})}),refresh:()=>z("/api/auth/refresh",{method:"POST"}),user:()=>z("/api/auth/user"),logout:()=>z("/api/auth/logout",{method:"POST"})},projects:()=>z("/api/projects"),archivedProjects:()=>z("/api/projects/archived"),projectSessions:(t,{limit:s=20,offset:r=0}={})=>{const a=new URLSearchParams;return a.set("limit",String(s)),a.set("offset",String(r)),z(`/api/projects/${encodeURIComponent(t)}/sessions?${a.toString()}`)},projectTaskmaster:t=>z(`/api/projects/${encodeURIComponent(t)}/taskmaster`),unifiedSessionMessages:(t,s="claude",{limit:r=null,offset:a=0}={})=>{const o=new URLSearchParams;r!==null&&(o.append("limit",String(r)),o.append("offset",String(a)));const i=o.toString();return z(`/api/providers/sessions/${encodeURIComponent(t)}/messages${i?`?${i}`:""}`)},renameProject:(t,s)=>z(`/api/projects/${t}/rename`,{method:"PUT",body:JSON.stringify({displayName:s})}),restoreProject:t=>z(`/api/projects/${encodeURIComponent(t)}/restore`,{method:"POST"}),deleteSession:(t,s=!1)=>{const r=new URLSearchParams;s&&r.set("force","true");const a=r.toString();return z(`/api/providers/sessions/${t}${a?`?${a}`:""}`,{method:"DELETE"})},getArchivedSessions:()=>z("/api/providers/sessions/archived"),sessionDetails:t=>z(`/api/providers/sessions/${encodeURIComponent(t)}`),runningSessions:()=>z("/api/providers/sessions/running"),recentConversations:({limit:t=40,offset:s=0}={})=>{const r=new URLSearchParams({limit:String(t),offset:String(s)});return z(`/api/providers/sessions/recent?${r.toString()}`)},providerSessionId:t=>z(`/api/providers/sessions/${encodeURIComponent(t)}/provider-id`),restoreSession:t=>z(`/api/providers/sessions/${t}/restore`,{method:"POST"}),renameSession:(t,s)=>z(`/api/providers/sessions/${t}`,{method:"PUT",body:JSON.stringify({summary:s})}),deleteProject:(t,s=!1)=>{const r=new URLSearchParams;s&&r.set("force","true");const a=r.toString();return z(`/api/projects/${t}${a?`?${a}`:""}`,{method:"DELETE"})},searchConversationsUrl:(t,s=50)=>{const r=vr(),a=new URLSearchParams({q:t,limit:String(s)});return r&&a.set("token",r),`/api/providers/search/sessions?${a.toString()}`},createProject:t=>z("/api/projects/create-project",{method:"POST",body:JSON.stringify(t)}),migrateLegacyProjectStars:t=>z("/api/projects/migrate-legacy-stars",{method:"POST",body:JSON.stringify({projectIds:t})}),toggleProjectStar:t=>z(`/api/projects/${encodeURIComponent(t)}/toggle-star`,{method:"POST"}),readFile:(t,s)=>z(`/api/file-tree/projects/${t}/file?filePath=${encodeURIComponent(s)}`),readFileBlob:(t,s)=>z(`/api/file-tree/projects/${t}/files/content?path=${encodeURIComponent(s)}`),saveFile:(t,s,r)=>z(`/api/file-tree/projects/${t}/file`,{method:"PUT",body:JSON.stringify({filePath:s,content:r})}),getFiles:(t,s={})=>z(`/api/file-tree/projects/${t}/files?respectGitignore=true`,s),getMentionableFiles:(t,s={})=>z(`/api/file-tree/projects/${t}/files?respectGitignore=true`,s),createFile:(t,{path:s,type:r,name:a})=>z(`/api/file-tree/projects/${t}/files/create`,{method:"POST",body:JSON.stringify({path:s,type:r,name:a})}),renameFile:(t,{oldPath:s,newName:r})=>z(`/api/file-tree/projects/${t}/files/rename`,{method:"PUT",body:JSON.stringify({oldPath:s,newName:r})}),deleteFile:(t,{path:s,type:r})=>z(`/api/file-tree/projects/${t}/files`,{method:"DELETE",body:JSON.stringify({path:s,type:r})}),uploadFiles:(t,s)=>z(`/api/file-tree/projects/${t}/files/upload`,{method:"POST",body:s,headers:{}}),taskmaster:{init:t=>z(`/api/taskmaster/init/${t}`,{method:"POST"}),addTask:(t,{prompt:s,title:r,description:a,priority:o,dependencies:i})=>z(`/api/taskmaster/add-task/${t}`,{method:"POST",body:JSON.stringify({prompt:s,title:r,description:a,priority:o,dependencies:i})}),parsePRD:(t,{fileName:s,numTasks:r,append:a})=>z(`/api/taskmaster/parse-prd/${t}`,{method:"POST",body:JSON.stringify({fileName:s,numTasks:r,append:a})}),getTemplates:()=>z("/api/taskmaster/prd-templates"),applyTemplate:(t,{templateId:s,fileName:r,customizations:a})=>z(`/api/taskmaster/apply-template/${t}`,{method:"POST",body:JSON.stringify({templateId:s,fileName:r,customizations:a})}),updateTask:(t,s,r)=>z(`/api/taskmaster/update-task/${t}/${s}`,{method:"PUT",body:JSON.stringify(r)})},browseFilesystem:(t=null)=>{const s=new URLSearchParams;return t&&s.append("path",t),z(`/api/file-tree/browse-filesystem?${s}`)},createFolder:t=>z("/api/file-tree/create-folder",{method:"POST",body:JSON.stringify({path:t})}),user:{gitConfig:()=>z("/api/user/git-config"),updateGitConfig:(t,s)=>z("/api/user/git-config",{method:"POST",body:JSON.stringify({gitName:t,gitEmail:s})}),onboardingStatus:()=>z("/api/user/onboarding-status"),completeOnboarding:()=>z("/api/user/complete-onboarding",{method:"POST"})},get:t=>z(`/api${t}`),post:(t,s)=>z(`/api${t}`,{method:"POST",...s instanceof FormData?{body:s}:{body:JSON.stringify(s)}}),put:(t,s)=>z(`/api${t}`,{method:"PUT",body:JSON.stringify(s)}),delete:(t,s={})=>z(`/api${t}`,{method:"DELETE",...s})},Ha="auth-token",Ve={authStatusCheckFailed:"Failed to check authentication status",loginFailed:"Login failed",registrationFailed:"Registration failed",networkError:"Network error. Please try again.",sessionExpired:"Your session expired. Please log in again."};async function it(t){try{return await t.json()}catch{return null}}function $r(t,s){return t?typeof t.error=="string"?t.error:typeof t.error=="object"&&t.error!==null&&"message"in t.error&&typeof t.error.message=="string"?t.error.message:typeof t.message=="string"?t.message:s:s}const Ja=n.createContext(null),Jo=()=>localStorage.getItem(Ha),zr=t=>{Wa(t)},qo=()=>{localStorage.removeItem(Ha)};function qa(){const t=n.useContext(Ja);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t}function Tm({children:t}){const[s,r]=n.useState(null),[a,o]=n.useState(()=>Jo()),[i,l]=n.useState(!0),[c,m]=n.useState(!1),[d,u]=n.useState(!0),[x,h]=n.useState(null),p=n.useCallback((C,T)=>{r(C),o(T),zr(T)},[]),f=n.useCallback(()=>{r(null),o(null),qo()},[]),b=n.useCallback(async()=>{try{const C=await ue.user.onboardingStatus();if(!C.ok)return;const T=await it(C);u(!!T?.hasCompletedOnboarding)}catch(C){console.error("Error checking onboarding status:",C),u(!0)}},[]),g=n.useCallback(async()=>{await b()},[b]),v=n.useCallback(async()=>{if(!(he||!a||!s))try{const C=await ue.auth.refresh();if(!C.ok)return;const T=await it(C);ms(T?.token)&&(o(T.token),zr(T.token))}catch(C){console.warn("[Auth] Session refresh failed:",C)}},[a,s]);n.useEffect(()=>{const C=I=>{const j=I.detail;ms(j)&&o(j)},T=()=>{f(),h(Ve.sessionExpired)};return window.addEventListener(ir,C),window.addEventListener(lr,T),()=>{window.removeEventListener(ir,C),window.removeEventListener(lr,T)}},[f]);const S=n.useCallback(async()=>{try{l(!0),h(null);const C=await ue.auth.status();if((await it(C))?.needsSetup){m(!0);return}if(m(!1),!a)return;const I=await ue.auth.user();if(!I.ok){f();return}const j=await it(I);if(!j?.user){f();return}r(j.user),await b()}catch(C){console.error("[Auth] Auth status check failed:",C),h(Ve.authStatusCheckFailed)}finally{l(!1)}},[b,f,a]);n.useEffect(()=>{if(he){r({username:"platform-user"}),m(!1),b().finally(()=>{l(!1)});return}S()},[S,b]),n.useEffect(()=>{if(he||!a||!s)return;const C=()=>{const $=Dr(a);$!==null&&$<=0&&v()},T=()=>{document.visibilityState==="visible"&&C()},I=Dr(a),j=I===null?null:window.setTimeout(()=>{v()},I);return window.addEventListener("focus",C),document.addEventListener("visibilitychange",T),()=>{j!==null&&window.clearTimeout(j),window.removeEventListener("focus",C),document.removeEventListener("visibilitychange",T)}},[v,a,s]);const k=n.useCallback(async(C,T)=>{try{h(null);const I=await ue.auth.login(C,T),j=await it(I);if(!I.ok||!j?.token||!j.user){const $=$r(j,Ve.loginFailed);return h($),{success:!1,error:$}}return p(j.user,j.token),m(!1),await b(),{success:!0}}catch(I){return console.error("Login error:",I),h(Ve.networkError),{success:!1,error:Ve.networkError}}},[b,p]),y=n.useCallback(async(C,T)=>{try{h(null);const I=await ue.auth.register(C,T),j=await it(I);if(!I.ok||!j?.token||!j.user){const $=$r(j,Ve.registrationFailed);return h($),{success:!1,error:$}}return p(j.user,j.token),m(!1),await b(),{success:!0}}catch(I){return console.error("Registration error:",I),h(Ve.networkError),{success:!1,error:Ve.networkError}}},[b,p]),P=n.useCallback(()=>{f()},[f]),E=n.useMemo(()=>({user:s,token:a,isLoading:i,needsSetup:c,hasCompletedOnboarding:d,error:x,login:k,register:y,logout:P,refreshOnboardingStatus:g}),[x,d,i,k,P,c,g,y,a,s]);return e.jsx(Ja.Provider,{value:E,children:t})}const Qo=["claude","cursor","codex","opencode"],Yo={claude:"/api/providers/claude/auth/status",cursor:"/api/providers/cursor/auth/status",codex:"/api/providers/codex/auth/status",opencode:"/api/providers/opencode/auth/status"},Zo=(t=!0)=>({claude:{authenticated:!1,email:null,method:null,error:null,loading:t},cursor:{authenticated:!1,email:null,method:null,error:null,loading:t},codex:{authenticated:!1,email:null,method:null,error:null,loading:t},opencode:{authenticated:!1,email:null,method:null,error:null,loading:t}}),Xo="Failed to check authentication status",ei="Unknown error",ti=t=>t instanceof Error?t.message:ei,si=(t,s=null)=>({authenticated:!!t.authenticated,email:t.email??null,method:t.method??null,error:t.error??s,loading:!1});function ri({initialLoading:t=!0}={}){const[s,r]=n.useState(()=>Zo(t)),a=n.useCallback(c=>{r(m=>({...m,[c]:{...m[c],loading:!0,error:null}}))},[]),o=n.useCallback((c,m)=>{r(d=>({...d,[c]:m}))},[]),i=n.useCallback(async c=>{a(c);try{const m=await z(Yo[c]);if(!m.ok){const x={authenticated:!1,email:null,method:null,loading:!1,error:Xo};return o(c,x),x}const d=await m.json(),u=si(d.data);return o(c,u),u}catch(m){console.error(`Error checking ${c} auth status:`,m);const d={authenticated:!1,email:null,method:null,loading:!1,error:ti(m)};return o(c,d),d}},[a,o]),l=n.useCallback(async(c=Qo)=>{await Promise.all(c.map(m=>i(m)))},[i]);return{providerAuthStatus:s,setProviderAuthStatus:r,checkProviderAuthStatus:i,refreshProviderAuthStatuses:l}}const ai="modulepreload",ni=function(t){return"/"+t},Ur={},oi=function(s,r,a){let o=Promise.resolve();if(r&&r.length>0){let m=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");o=m(r.map(d=>{if(d=ni(d),d in Ur)return;Ur[d]=!0;const u=d.endsWith(".css"),x=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${x}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":ai,u||(h.as="script"),h.crossOrigin="",h.href=d,c&&h.setAttribute("nonce",c),document.head.appendChild(h),u)return new Promise((p,f)=>{h.addEventListener("load",p),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return o.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return s().catch(i)})},ii=n.lazy(()=>oi(()=>import("./StandaloneShell-C_SgfnxT.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]))),li={projectId:"default",displayName:"default",fullPath:he?"/workspace":"",path:he?"/workspace":""},ci=({provider:t,customCommand:s,isAuthenticated:r})=>s||(t==="claude"?"claude --dangerously-skip-permissions /login":t==="cursor"?"cursor-agent login":t==="codex"?he?"codex login --device-auth":"codex login":t==="opencode"?"opencode auth login":"claude --dangerously-skip-permissions /login"),di=t=>t==="claude"?"Claude CLI Login":t==="cursor"?"Cursor CLI Login":t==="codex"?"Codex CLI Login":t==="opencode"?"OpenCode CLI Login":"Claude CLI Login";function ui({isOpen:t,onClose:s,provider:r="claude",onComplete:a,customCommand:o,isAuthenticated:i=!1}){if(!t)return null;const l=ci({provider:r,customCommand:o,isAuthenticated:i}),c=di(r),m=d=>{a?.(d)};return e.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black bg-opacity-50 max-md:items-stretch max-md:justify-stretch",children:e.jsxs("div",{className:"flex h-3/4 w-full max-w-4xl flex-col rounded-lg bg-white shadow-xl dark:bg-gray-800 max-md:m-0 max-md:h-full max-md:max-w-none max-md:rounded-none md:m-4 md:h-3/4 md:max-w-4xl md:rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c}),e.jsx("button",{onClick:s,className:"text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-gray-300","aria-label":"Close login modal",children:e.jsx(ge,{className:"h-6 w-6"})})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"h-full w-full bg-gray-900"}),children:e.jsx(ii,{project:li,command:l,onComplete:m,minimal:!0})})})]})})}const mi=({className:t="w-5 h-5"})=>e.jsxs("svg",{viewBox:"0 0 512 509.64",role:"img","aria-label":"Claude",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{fill:"#D77655",d:"M115.612 0h280.775C459.974 0 512 52.026 512 115.612v278.415c0 63.587-52.026 115.612-115.613 115.612H115.612C52.026 509.639 0 457.614 0 394.027V115.612C0 52.026 52.026 0 115.612 0z"}),e.jsx("path",{fill:"#FCF2EE",fillRule:"nonzero",d:"M142.27 316.619l73.655-41.326 1.238-3.589-1.238-1.996-3.589-.001-12.31-.759-42.084-1.138-36.498-1.516-35.361-1.896-8.897-1.895-8.34-10.995.859-5.484 7.482-5.03 10.717.935 23.683 1.617 35.537 2.452 25.782 1.517 38.193 3.968h6.064l.86-2.451-2.073-1.517-1.618-1.517-36.776-24.922-39.81-26.338-20.852-15.166-11.273-7.683-5.687-7.204-2.451-15.721 10.237-11.273 13.75.935 3.513.936 13.928 10.716 29.749 23.027 38.848 28.612 5.687 4.727 2.275-1.617.278-1.138-2.553-4.271-21.13-38.193-22.546-38.848-10.035-16.101-2.654-9.655c-.935-3.968-1.617-7.304-1.617-11.374l11.652-15.823 6.445-2.073 15.545 2.073 6.547 5.687 9.655 22.092 15.646 34.78 24.265 47.291 7.103 14.028 3.791 12.992 1.416 3.968 2.449-.001v-2.275l1.997-26.641 3.69-32.707 3.589-42.084 1.239-11.854 5.863-14.206 11.652-7.683 9.099 4.348 7.482 10.716-1.036 6.926-4.449 28.915-8.72 45.294-5.687 30.331h3.313l3.792-3.791 15.342-20.372 25.782-32.227 11.374-12.789 13.27-14.129 8.517-6.724 16.1-.001 11.854 17.617-5.307 18.199-16.581 21.029-13.75 17.819-19.716 26.54-12.309 21.231 1.138 1.694 2.932-.278 44.536-9.479 24.062-4.347 28.714-4.928 12.992 6.066 1.416 6.167-5.106 12.613-30.71 7.583-36.018 7.204-53.636 12.689-.657.48.758.935 24.164 2.275 10.337.556h25.301l47.114 3.514 12.309 8.139 7.381 9.959-1.238 7.583-18.957 9.655-25.579-6.066-59.702-14.205-20.474-5.106-2.83-.001v1.694l17.061 16.682 31.266 28.233 39.152 36.397 1.997 8.999-5.03 7.102-5.307-.758-34.401-25.883-13.27-11.651-30.053-25.302-1.996-.001v2.654l6.926 10.136 36.574 54.975 1.895 16.859-2.653 5.485-9.479 3.311-10.414-1.895-21.408-30.054-22.092-33.844-17.819-30.331-2.173 1.238-10.515 113.261-4.929 5.788-11.374 4.348-9.478-7.204-5.03-11.652 5.03-23.027 6.066-30.052 4.928-23.886 4.449-29.674 2.654-9.858-.177-.657-2.173.278-22.37 30.71-34.021 45.977-26.919 28.815-6.445 2.553-11.173-5.789 1.037-10.337 6.243-9.2 37.257-47.392 22.47-29.371 14.508-16.961-.101-2.451h-.859l-98.954 64.251-17.618 2.275-7.583-7.103.936-11.652 3.589-3.791 29.749-20.474-.101.102.024.101z"})]}),pi=({className:t="w-5 h-5"})=>e.jsx("svg",{viewBox:"100 100 520 520",role:"img","aria-label":"Codex",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M304.246 294.611V249.028C304.246 245.189 305.687 242.309 309.044 240.392L400.692 187.612C413.167 180.415 428.042 177.058 443.394 177.058C500.971 177.058 537.44 221.682 537.44 269.182C537.44 272.54 537.44 276.379 536.959 280.218L441.954 224.558C436.197 221.201 430.437 221.201 424.68 224.558L304.246 294.611ZM518.245 472.145V363.224C518.245 356.505 515.364 351.707 509.608 348.349L389.174 278.296L428.519 255.743C431.877 253.826 434.757 253.826 438.115 255.743L529.762 308.523C556.154 323.879 573.905 356.505 573.905 388.171C573.905 424.636 552.315 458.225 518.245 472.141V472.145ZM275.937 376.182L236.592 353.152C233.235 351.235 231.794 348.354 231.794 344.515V238.956C231.794 187.617 271.139 148.749 324.4 148.749C344.555 148.749 363.264 155.468 379.102 167.463L284.578 222.164C278.822 225.521 275.942 230.319 275.942 237.039V376.186L275.937 376.182ZM360.626 425.122L304.246 393.455V326.283L360.626 294.616L417.002 326.283V393.455L360.626 425.122ZM396.852 570.989C376.698 570.989 357.989 564.27 342.151 552.276L436.674 497.574C442.431 494.217 445.311 489.419 445.311 482.699V343.552L485.138 366.582C488.495 368.499 489.936 371.379 489.936 375.219V480.778C489.936 532.117 450.109 570.985 396.852 570.985V570.989ZM283.134 463.99L191.486 411.211C165.094 395.854 147.343 363.229 147.343 331.562C147.343 294.616 169.415 261.509 203.48 247.593V356.991C203.48 363.71 206.361 368.508 212.117 371.866L332.074 441.437L292.729 463.99C289.372 465.907 286.491 465.907 283.134 463.99ZM277.859 542.68C223.639 542.68 183.813 501.895 183.813 451.514C183.813 447.675 184.294 443.836 184.771 439.997L279.295 494.698C285.051 498.056 290.812 498.056 296.568 494.698L417.002 425.127V470.71C417.002 474.549 415.562 477.429 412.204 479.346L320.557 532.126C308.081 539.323 293.206 542.68 277.854 542.68H277.859ZM396.852 599.776C454.911 599.776 503.37 558.513 514.41 503.812C568.149 489.896 602.696 439.515 602.696 388.176C602.696 354.587 588.303 321.962 562.392 298.45C564.791 288.373 566.231 278.296 566.231 268.224C566.231 199.611 510.571 148.267 446.274 148.267C433.322 148.267 420.846 150.184 408.37 154.505C386.775 133.392 357.026 119.958 324.4 119.958C266.342 119.958 217.883 161.22 206.843 215.921C153.104 229.837 118.557 280.218 118.557 331.557C118.557 365.146 132.95 397.771 158.861 421.283C156.462 431.36 155.022 441.437 155.022 451.51C155.022 520.123 210.682 571.466 274.978 571.466C287.931 571.466 300.407 569.549 312.883 565.228C334.473 586.341 364.222 599.776 396.852 599.776Z",fill:"currentColor"})}),xi=({className:t="w-5 h-5"})=>e.jsxs("svg",{viewBox:"0 0 24 24",role:"img","aria-label":"Cursor",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M11.925 24l10.425-6-10.425-6L1.5 18l10.425 6z",fill:"currentColor",opacity:".39"}),e.jsx("path",{d:"M22.35 18V6L11.925 0v12l10.425 6z",fill:"currentColor",opacity:".8"}),e.jsx("path",{d:"M11.925 0L1.5 6v12l10.425-6V0z",fill:"currentColor",opacity:".6"}),e.jsx("path",{d:"M22.35 6L11.925 24V12L22.35 6z",fill:"currentColor",opacity:".72"}),e.jsx("path",{d:"M22.35 6l-10.425 6L1.5 6h20.85z",fill:"currentColor",opacity:".95"})]}),hi=({className:t="w-5 h-5"})=>e.jsxs("svg",{viewBox:"0 0 24 24",role:"img","aria-label":"OpenCode",className:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2.5",y:"2.5",width:"19",height:"19",rx:"4",className:"fill-foreground"}),e.jsx("path",{d:"M8.1 8.1 4.9 12l3.2 3.9M15.9 8.1l3.2 3.9-3.2 3.9M13.2 6.9l-2.4 10.2",className:"stroke-background",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round"})]});function _e({provider:t="claude",className:s="w-5 h-5"}){return t==="cursor"?e.jsx(xi,{className:s}):t==="codex"?e.jsx(pi,{className:s}):t==="opencode"?e.jsx(hi,{className:s}):e.jsx(mi,{className:s})}const Qa="ui-sans-serif, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji",Ya=n.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0}),Za=()=>{const t=n.useContext(Ya);if(!t)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return t},Im=({children:t})=>{const[s,r]=n.useState(()=>{const p=localStorage.getItem("tasks-enabled");return p!==null?JSON.parse(p):!0}),[a,o]=n.useState(null),[i,l]=n.useState(null),[c,m]=n.useState(null),[d,u]=n.useState(!0);n.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(s))},[s]),n.useEffect(()=>{setTimeout(async()=>{try{const f=await ue.get("/taskmaster/installation-status");if(f.ok){const b=await f.json();m(b),o(b.installation?.isInstalled||!1),l(b.isReady||!1);const g=localStorage.getItem("tasks-enabled");!b.installation?.isInstalled&&!g&&r(!1)}else console.error("Failed to check TaskMaster installation status"),o(!1),l(!1)}catch(f){console.error("Error checking TaskMaster installation:",f),o(!1),l(!1)}finally{u(!1)}},0)},[]);const h={tasksEnabled:s,setTasksEnabled:r,toggleTasksEnabled:()=>{r(p=>!p)},isTaskMasterInstalled:a,isTaskMasterReady:i,installationStatus:c,isCheckingInstallation:d};return e.jsx(Ya.Provider,{value:h,children:t})},Xa=n.createContext(null),gi=()=>{const t=n.useContext(Xa);if(!t)throw new Error("useWebSocket must be used within a WebSocketProvider");return t},fi=t=>{const s=window.location.protocol==="https:"?"wss:":"ws:";return he?`${s}//${window.location.host}/ws`:t?Ba(t)?(yr(),null):`${s}//${window.location.host}/ws?token=${encodeURIComponent(t)}`:null},bi=()=>{const t=n.useRef(null),s=n.useRef(!1),r=n.useRef(!1),a=n.useRef(new Set),[o,i]=n.useState(null),[l,c]=n.useState(!1),m=n.useRef(null),{isLoading:d,token:u,user:x}=qa(),h=n.useCallback(v=>{for(const S of a.current)try{S(v)}catch(k){console.error("WebSocket listener error:",k)}i(v)},[]),p=n.useCallback(()=>{if(!s.current&&!(!he&&(d||!x)))try{const v=fi(u);if(!v)return console.warn("No authentication token found for WebSocket connection");const S=new WebSocket(v);t.current=S,S.onopen=()=>{c(!0),r.current&&h({kind:"websocket_reconnected",timestamp:Date.now()}),r.current=!0},S.onmessage=k=>{try{const y=JSON.parse(k.data);h(y)}catch(y){console.error("Error parsing WebSocket message:",y)}},S.onclose=()=>{t.current===S&&(c(!1),t.current=null,m.current=setTimeout(()=>{s.current||p()},3e3))},S.onerror=k=>{console.error("WebSocket error:",k)}}catch(v){console.error("Error creating WebSocket connection:",v)}},[h,d,u,x]);n.useEffect(()=>{if(s.current=!1,!(!he&&(d||!x)))return p(),()=>{s.current=!0,m.current&&clearTimeout(m.current);const v=t.current;v&&(v.onopen=null,v.onmessage=null,v.onclose=null,v.onerror=null,v.close(),t.current=null)}},[p,d,x]);const f=n.useCallback(v=>{const S=t.current;S&&S.readyState===WebSocket.OPEN?S.send(JSON.stringify(v)):console.warn("WebSocket not connected")},[]),b=n.useCallback(v=>(a.current.add(v),()=>{a.current.delete(v)}),[]);return n.useMemo(()=>({ws:t.current,sendMessage:f,subscribe:b,latestMessage:o,isConnected:l}),[f,b,o,l])},Rm=({children:t})=>{const s=bi();return e.jsx(Xa.Provider,{value:s,children:t})},en=n.createContext(null);function tn(){const t=n.useContext(en);if(!t)throw new Error("usePlugins must be used within a PluginsProvider");return t}function Am({children:t}){const[s,r]=n.useState([]),[a,o]=n.useState(!0),[i,l]=n.useState(null),c=n.useCallback(async()=>{try{const h=await z("/api/plugins");if(h.ok){const p=await h.json();r(p.plugins||[]),l(null)}else{let p=`Failed to fetch plugins (${h.status})`;try{const f=await h.json();p=f.details||f.error||p}catch{p=h.statusText||p}l(p)}}catch(h){const p=h instanceof Error?h.message:"Failed to fetch plugins";l(p),console.error("[Plugins] Failed to fetch plugins:",h)}finally{o(!1)}},[]);n.useEffect(()=>{c()},[c]);const m=n.useCallback(async h=>{try{const p=await z("/api/plugins/install",{method:"POST",body:JSON.stringify({url:h})}),f=await p.json();return p.ok?(await c(),{success:!0}):{success:!1,error:f.details||f.error||"Install failed"}}catch(p){return{success:!1,error:p instanceof Error?p.message:"Install failed"}}},[c]),d=n.useCallback(async h=>{try{const p=await z(`/api/plugins/${encodeURIComponent(h)}`,{method:"DELETE"}),f=await p.json();return p.ok?(await c(),{success:!0}):{success:!1,error:f.details||f.error||"Uninstall failed"}}catch(p){return{success:!1,error:p instanceof Error?p.message:"Uninstall failed"}}},[c]),u=n.useCallback(async h=>{try{const p=await z(`/api/plugins/${encodeURIComponent(h)}/update`,{method:"POST"}),f=await p.json();return p.ok?(await c(),{success:!0}):{success:!1,error:f.details||f.error||"Update failed"}}catch(p){return{success:!1,error:p instanceof Error?p.message:"Update failed"}}},[c]),x=n.useCallback(async(h,p)=>{try{const f=await z(`/api/plugins/${encodeURIComponent(h)}/enable`,{method:"PUT",body:JSON.stringify({enabled:p})});if(!f.ok){let b=`Toggle failed (${f.status})`;try{const g=await f.json();b=g.details||g.error||b}catch{b=f.statusText||b}return{success:!1,error:b}}return await c(),{success:!0,error:null}}catch(f){return{success:!1,error:f instanceof Error?f.message:"Toggle failed"}}},[c]);return e.jsx(en.Provider,{value:{plugins:s,loading:a,pluginsError:i,refreshPlugins:c,installPlugin:m,uninstallPlugin:d,updatePlugin:u,togglePlugin:x},children:t})}const Gr=t=>typeof window>"u"?!1:window.innerWidth<t,Vr=()=>{if(typeof window>"u")return!1;const t=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!t.standalone||document.referrer.includes("android-app://")};function yi(t={}){const{mobileBreakpoint:s=768,trackMobile:r=!0,trackPWA:a=!0}=t,[o,i]=n.useState(()=>r?Gr(s):!1),[l,c]=n.useState(()=>a?Vr():!1);return n.useEffect(()=>{if(!r||typeof window>"u")return;const m=()=>{i(Gr(s))};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[s,r]),n.useEffect(()=>{if(!a||typeof window>"u")return;const m=window.matchMedia("(display-mode: standalone)"),d=()=>{c(Vr())};return d(),typeof m.addEventListener=="function"?(m.addEventListener("change",d),()=>{m.removeEventListener("change",d)}):(m.addListener(d),()=>{m.removeListener(d)})},[a]),{isMobile:o,isPWA:l}}const Ks="1.38.1",vi=(t,s)=>{const r=t.split(".").map(Number),a=s.split(".").map(Number);for(let o=0;o<Math.max(r.length,a.length);o++){const i=r[o]||0,l=a[o]||0;if(i!==l)return i-l}return 0},sn=(t,s)=>{const[r,a]=n.useState(!1),[o,i]=n.useState(null),[l,c]=n.useState(null),[m,d]=n.useState("git"),[u,x]=n.useState(null),[h,p]=n.useState(!1);return n.useEffect(()=>{(async()=>{try{const g=await(await fetch("/health")).json();(g.installMode==="npm"||g.installMode==="git")&&d(g.installMode),typeof g.version=="string"&&g.version.length>0&&(x(g.version),p(g.version!==Ks))}catch{}})()},[]),n.useEffect(()=>{const f=async()=>{try{const v=await(await fetch(`https://api.github.com/repos/${t}/${s}/releases/latest`)).json();if(v.tag_name){const S=v.tag_name.replace(/^v/,"");i(S),a(vi(S,Ks)>0),c({title:v.name||v.tag_name,body:v.body||"",htmlUrl:v.html_url||`https://github.com/${t}/${s}/releases/latest`,publishedAt:v.published_at})}else a(!1),i(null),c(null)}catch(g){console.error("Version check failed:",g),a(!1),i(null),c(null)}};f();const b=setInterval(f,300*1e3);return()=>clearInterval(b)},[t,s]),{updateAvailable:r,latestVersion:o,currentVersion:Ks,releaseInfo:l,installMode:m,runningVersion:u,restartRequired:h}},Ze={showRawParameters:!1,showThinking:!0,sendByCtrlEnter:!1,sidebarVisible:!0,voiceEnabled:!1},ps=Object.keys(Ze),ji=new Set(ps),Bs="ui-preferences:sync",xs=(t,s)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return s},wi=(t,s)=>{try{const r=localStorage.getItem(t);if(r===null)return s;const a=JSON.parse(r);return xs(a,s)}catch{return s}},Ni=t=>{if(typeof window>"u")return Ze;try{const s=localStorage.getItem(t);if(s){const r=JSON.parse(s);if(r&&typeof r=="object"&&!Array.isArray(r)){const a=r;return ps.reduce((o,i)=>(o[i]=xs(a[i],Ze[i]),o),{...Ze})}}}catch{}return ps.reduce((s,r)=>(s[r]=wi(r,Ze[r]),s),{...Ze})};function ki(t,s){switch(s.type){case"set":{const{key:r,value:a}=s;if(!ji.has(r))return t;const o=xs(a,t[r]);return t[r]===o?t:{...t,[r]:o}}case"set_many":{const r=s.value||{};let a=!1;const o={...t};for(const i of ps){if(!(i in r))continue;const l=r[i],c=xs(l,t[i]);o[i]!==c&&(o[i]=c,a=!0)}return a?o:t}case"reset":return{...Ze,...s.value||{}};default:return t}}function rn(t="uiPreferences"){const s=n.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,a]=n.useReducer(ki,t,Ni);return n.useEffect(()=>{typeof window>"u"||(localStorage.setItem(t,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(Bs,{detail:{storageKey:t,sourceId:s.current,value:r}})))},[r,t]),n.useEffect(()=>{if(typeof window>"u")return;const c=u=>{!u||typeof u!="object"||Array.isArray(u)||a({type:"set_many",value:u})},m=u=>{if(!(u.key!==t||u.newValue===null))try{const x=JSON.parse(u.newValue);c(x)}catch{}},d=u=>{const h=u.detail;!h||h.storageKey!==t||h.sourceId===s.current||c(h.value)};return window.addEventListener("storage",m),window.addEventListener(Bs,d),()=>{window.removeEventListener("storage",m),window.removeEventListener(Bs,d)}},[t]),{preferences:r,setPreference:(c,m)=>{a({type:"set",key:c,value:m})},setPreferences:c=>{a({type:"set_many",value:c})},resetPreferences:c=>{a({type:"reset",value:c})},dispatch:a}}const jr=n.createContext(null),Qt={openFile:()=>{},openFileInEditor:()=>{},openSettings:()=>{},refreshProjects:()=>{}};function Lm({children:t}){const s=n.useRef({});return e.jsx(jr.Provider,{value:s,children:t})}function an(){const t=n.useContext(jr);return n.useMemo(()=>({openFile:s=>(t?.current.openFile??Qt.openFile)(s),openFileInEditor:s=>(t?.current.openFileInEditor??Qt.openFileInEditor)(s),openSettings:s=>(t?.current.openSettings??Qt.openSettings)(s),refreshProjects:()=>(t?.current.refreshProjects??Qt.refreshProjects)()}),[t])}function Mm(t){const s=n.useContext(jr),{openFile:r,openFileInEditor:a,openSettings:o,refreshProjects:i}=t;n.useEffect(()=>{if(!s)return;const l=s.current,c={...l};return r&&(l.openFile=r),a&&(l.openFileInEditor=a),o&&(l.openSettings=o),i&&(l.refreshProjects=i),()=>{r&&l.openFile===r&&(l.openFile=c.openFile),a&&l.openFileInEditor===a&&(l.openFileInEditor=c.openFileInEditor),o&&l.openSettings===o&&(l.openSettings=c.openSettings),i&&l.refreshProjects===i&&(l.refreshProjects=c.refreshProjects)}},[s,r,a,o,i])}const Rt=(t,s)=>{if(!t)return"";const r=new Date(t);if(Number.isNaN(r.getTime()))return"";const a=Math.floor(Math.max(0,s.getTime()-r.getTime())/6e4);if(a<1)return"<1m";if(a<60)return`${a}m`;const o=Math.floor(a/60);return o<24?`${o}hr`:`${Math.floor(o/24)}d`},Si=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},nn="starredProjects",Ci=()=>{try{const t=localStorage.getItem(nn);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s.map(r=>String(r).trim()).filter(r=>r.length>0):[]}catch{return[]}},Pi=()=>{try{localStorage.removeItem(nn)}catch{}},on=t=>String(t.createdAt||t.created_at||""),ln=t=>String(t.lastActivity||""),Ei=t=>{const s=t.__provider??t.provider;return typeof s=="string"&&s.trim()?s:"claude"},hs=t=>new Date(ln(t)||on(t)||0),Ti=(t,s)=>t.summary||t.name||s("projects.newSession"),Ii=t=>ln(t)||on(t),Ri=(t,s,r)=>{const a=hs(t);return{isActive:Math.floor((s.getTime()-a.getTime())/(1e3*60))<10,sessionName:Ti(t,r),sessionTime:Ii(t),messageCount:Number(t.messageCount||0)}},gs=t=>(t.sessions||[]).map(s=>({...s,__provider:Ei(s)})).sort((s,r)=>hs(r).getTime()-hs(s).getTime()),Kr=t=>{const s=gs(t);return s.length===0?new Date(0):s.reduce((r,a)=>{const o=hs(a);return o>r?o:r},new Date(0))},Ai=(t,s)=>{const r=[...t];return r.sort((a,o)=>{const i=!!a.isStarred,l=!!o.isStarred;return i&&!l?-1:!i&&l?1:s==="date"?Kr(o).getTime()-Kr(a).getTime():(a.displayName||a.projectId).localeCompare(o.displayName||o.projectId)}),r},Li=(t,s)=>{const r=s.trim().toLowerCase();return r?t.filter(a=>{const o=(a.displayName||a.projectId).toLowerCase(),i=(a.path||a.fullPath||"").toLowerCase();return o.includes(r)||i.includes(r)}):t},Mi=(t,s)=>{const r=!!t.taskmaster?.hasTaskmaster,a=!!(s?.hasMCPServer&&s?.isConfigured);return r&&a?"fully-configured":r?"taskmaster-only":a?"mcp-only":"not-configured"},Fi=t=>{const s=typeof t.fullPath=="string"&&t.fullPath.length>0?t.fullPath:typeof t.path=="string"?t.path:"";return{name:t.projectId,displayName:typeof t.displayName=="string"&&t.displayName.trim().length>0?t.displayName:t.projectId,fullPath:s,path:typeof t.path=="string"&&t.path.length>0?t.path:s}};function _i({projects:t,selectedProject:s,selectedSession:r,activeSessions:a,isLoading:o,isMobile:i,t:l,onRefresh:c,onProjectSelect:m,onSessionSelect:d,onSessionDelete:u,onLoadMoreSessions:x,onProjectDelete:h,setSidebarVisible:p,sidebarVisible:f}){const b=an(),[g,v]=n.useState(new Set),[S,k]=n.useState(null),[y,P]=n.useState(!1),[E,C]=n.useState(""),[T,I]=n.useState(new Set),[j,$]=n.useState(new Date),[G,K]=n.useState("name"),[M,X]=n.useState(!1),[H,B]=n.useState(null),[w,D]=n.useState(""),[L,O]=n.useState(""),[U,N]=n.useState(new Set),[A,ee]=n.useState(null),[V,ae]=n.useState(null),[de,te]=n.useState(!1),[q,ye]=n.useState("projects"),[se,ne]=n.useState(null),[re,Ie]=n.useState(!1),[Ss,Re]=n.useState(null),[De,Cs]=n.useState([]),[tt,Ps]=n.useState([]),[Es,_t]=n.useState(!1),[vt,Ts]=n.useState([]),[Is,Rs]=n.useState(0),[jt,As]=n.useState(!1),[Ls,Ot]=n.useState(!1),[wt,qe]=n.useState(!1),[Ms,Dt]=n.useState(!1),[Se,Fs]=n.useState(""),[$e,st]=n.useState(new Map),[_s,$t]=n.useState(new Set),Ce=n.useRef(0),rt=n.useRef(0),we=n.useRef(null),at=n.useRef(new Map),Nt=n.useRef(!1),zt=n.useRef(c),Os=!i&&!f,nt=n.useMemo(()=>new Set(a.keys()),[a]),Ds=nt.size;n.useEffect(()=>{const R=setInterval(()=>{$(new Date)},6e4);return()=>clearInterval(R)},[]),n.useEffect(()=>{I(new Set)},[t]),n.useEffect(()=>{const R=s?.projectId;R&&v(_=>{if(_.has(R))return _;const Z=new Set(_);return Z.add(R),Z})},[s?.projectId]),n.useEffect(()=>{if(t.length>0&&!o){const R=new Set;t.forEach(_=>{_.sessions&&_.sessions.length>=0&&R.add(_.projectId)}),I(R)}},[t,o]),n.useEffect(()=>{const R=()=>{K(Si())};R();const _=J=>{J.key==="claude-settings"&&R()};window.addEventListener("storage",_);const Z=setInterval(()=>{document.hasFocus()&&R()},1e3);return()=>{window.removeEventListener("storage",_),clearInterval(Z)}},[]),n.useEffect(()=>{zt.current=c},[c]);const Ne=n.useCallback(async()=>{_t(!0);try{const[R,_]=await Promise.all([ue.archivedProjects(),ue.getArchivedSessions()]);if(!R.ok)throw new Error(`Failed to load archived projects: ${R.status}`);if(!_.ok)throw new Error(`Failed to load archived sessions: ${_.status}`);const Z=await R.json(),J=await _.json(),le=Array.isArray(Z.data?.projects)?Z.data.projects:[],ie=new Set(le.map(je=>je.projectId)),fe=Array.isArray(J.data?.sessions)?J.data.sessions.filter(je=>!je.projectId||!ie.has(je.projectId)):[];Cs(le),Ps(fe)}catch(R){console.error("[Sidebar] Failed to load archived sessions:",R)}finally{_t(!1)}},[]),ze=n.useCallback(async(R,_)=>{const Z=++rt.current;_?qe(!0):Ot(!0),Dt(!1);try{const J=await ue.recentConversations({limit:40,offset:R});if(!J.ok)throw new Error(`Failed to load recent conversations: ${J.status}`);const le=await J.json(),ie=Array.isArray(le.data?.conversations)?le.data.conversations:[];if(Z!==rt.current)return;Ts(fe=>{if(!_)return ie;const je=new Set(fe.map(xe=>xe.sessionId));return[...fe,...ie.filter(xe=>!je.has(xe.sessionId))]}),Rs(Number(le.data?.total??ie.length)),As(!!le.data?.hasMore)}catch(J){if(Z!==rt.current)return;console.error("[Sidebar] Failed to load recent conversations:",J),Dt(!0)}finally{Z===rt.current&&(Ot(!1),qe(!1))}},[]),kt=n.useCallback(()=>{ze(0,!1)},[ze]),Ut=n.useCallback(()=>{wt||!jt||ze(vt.length,!0)},[ze,wt,vt.length,jt]);n.useEffect(()=>{if(Nt.current)return;const R=Ci();if(R.length===0)return;Nt.current=!0,(async()=>{try{await ue.migrateLegacyProjectStars(R),await zt.current()}catch(Z){console.error("[Sidebar] Failed to migrate legacy starred projects:",Z)}finally{Pi()}})()},[c]),n.useEffect(()=>{Ne()},[Ne]),n.useEffect(()=>{q!=="conversations"||Se.length>=2||kt()},[Se,kt,q]),n.useEffect(()=>{q==="archived"&&Ne()},[Ne,q]),n.useEffect(()=>{st(R=>{if(R.size===0)return R;const _=new Map(R);let Z=!1;for(const[J,le]of R.entries()){const ie=t.find(fe=>fe.projectId===J);if(!ie){_.delete(J),Z=!0;continue}!!ie.isStarred===le&&(_.delete(J),Z=!0)}return Z?_:R})},[t]),n.useEffect(()=>{const R=setTimeout(()=>{Fs(L.trim())},300);return()=>{clearTimeout(R)}},[L]),n.useEffect(()=>{we.current&&(we.current.close(),we.current=null);const R=Se;if(q!=="conversations"||R.length<2){Ce.current+=1,ne(null),Re(null),Ie(!1);return}Ie(!0),ne(null),Re(null);const _=++Ce.current;if(_!==Ce.current)return;const Z=ue.searchConversationsUrl(R),J=new EventSource(Z);we.current=J;const le=[];let ie=[],fe=0;return J.addEventListener("title-results",je=>{if(_!==Ce.current){J.close();return}try{const xe=JSON.parse(je.data);ie=Array.isArray(xe.titleResults)?xe.titleResults:[],ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R})}catch{}}),J.addEventListener("result",je=>{if(_!==Ce.current){J.close();return}try{const xe=JSON.parse(je.data);le.push(xe.projectResult),fe=xe.totalMatches,ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R}),Re({scannedProjects:xe.scannedProjects,totalProjects:xe.totalProjects})}catch{}}),J.addEventListener("progress",je=>{if(_!==Ce.current){J.close();return}try{const xe=JSON.parse(je.data);fe=xe.totalMatches,Re({scannedProjects:xe.scannedProjects,totalProjects:xe.totalProjects})}catch{}}),J.addEventListener("done",()=>{if(_!==Ce.current){J.close();return}J.close(),we.current=null,Ie(!1),Re(null),ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R})}),J.addEventListener("error",()=>{if(_!==Ce.current){J.close();return}J.close(),we.current=null,Ie(!1),Re(null),ne({results:[...le],titleResults:[...ie],totalMatches:fe,query:R})}),()=>{we.current&&(we.current.close(),we.current=null)}},[Se,q]);const $s=n.useCallback(R=>{v(_=>{const Z=new Set;return _.has(R)||Z.add(R),Z})},[]),Gt=n.useCallback((R,_)=>{d({...R,__projectId:_})},[d]),Ue=n.useCallback(R=>$e.has(R)?!!$e.get(R):t.some(_=>_.projectId===R&&!!_.isStarred),[$e,t]),Vt=n.useCallback(R=>{const _=Ue(R),Z=!_,J=(at.current.get(R)??0)+1;at.current.set(R,J),st(ie=>{const fe=new Map(ie);return fe.set(R,Z),fe}),(async()=>{try{const ie=await ue.toggleProjectStar(R);if(!ie.ok){const Ae=(await ie.json()).error,mo=typeof Ae=="string"?Ae:Ae&&typeof Ae=="object"&&Ae.message?Ae.message:l("messages.updateProjectError");throw new Error(mo)}const fe=await ie.json();if(!(at.current.get(R)===J))return;st(xe=>{const Ae=new Map(xe);return Ae.set(R,!!fe.isStarred),Ae})}catch(ie){if(!(at.current.get(R)===J))return;st(je=>{const xe=new Map(je);return xe.set(R,_),xe}),console.error("[Sidebar] Failed to toggle project star:",ie),alert(l("messages.updateProjectError"))}})()},[Ue,l]),zs=n.useCallback(R=>Ue(R),[Ue]),St=n.useCallback(R=>gs(R),[]),Ct=n.useCallback(async R=>{if(!x)return;let _=!1;if($t(Z=>{if(Z.has(R))return Z;_=!0;const J=new Set(Z);return J.add(R),J}),!!_)try{await x(R)}catch(Z){console.error("[Sidebar] Failed to load more sessions:",Z),alert(l("messages.refreshError"))}finally{$t(Z=>{const J=new Set(Z);return J.delete(R),J})}},[x,l]),Kt=n.useMemo(()=>$e.size===0?t:t.map(R=>{const _=$e.get(R.projectId);return _===void 0||!!R.isStarred===_?R:{...R,isStarred:_}}),[$e,t]),ot=n.useMemo(()=>Ai(Kt,G),[G,Kt]),pe=n.useMemo(()=>nt.size===0?[]:ot.reduce((R,_)=>{const Z=(_.sessions??[]).filter(le=>nt.has(String(le.id))),J=Z.length;return J===0||R.push({..._,sessions:Z,sessionMeta:{..._.sessionMeta,total:J,hasMore:!1}}),R},[]),[nt,ot]),Ge=n.useMemo(()=>Li(q==="running"?pe:ot,Se),[Se,pe,q,ot]),Pt=n.useMemo(()=>{const R=Se.trim().toLowerCase();return R?tt.filter(_=>[_.sessionTitle,_.projectDisplayName,_.projectPath??"",_.provider].some(J=>J.toLowerCase().includes(R))):tt},[tt,Se]),Et=n.useMemo(()=>{const R=Se.trim().toLowerCase();return R?De.filter(_=>[_.displayName,_.fullPath||""].some(J=>J.toLowerCase().includes(R))?!0:gs(_).some(J=>[typeof J.summary=="string"&&J.summary.trim().length>0?J.summary:typeof J.name=="string"?J.name:"",J.__provider].some(ie=>ie.toLowerCase().includes(R)))):De},[De,Se]),Us=n.useCallback(R=>{k(R.projectId),C(R.displayName)},[]),Gs=n.useCallback(()=>{k(null),C("")},[]),Qe=n.useCallback(async R=>{try{(await ue.renameProject(R,E)).ok?await b.refreshProjects():console.error("Failed to rename project")}catch(_){console.error("Error renaming project:",_)}finally{k(null),C("")}},[E,b]),Bt=n.useCallback((R,_,Z,J="claude",le={})=>{ae({projectId:R,sessionId:_,sessionTitle:Z,provider:J,isArchived:!!le.isArchived})},[]),Wt=n.useCallback(async(R=!1)=>{if(!V)return;const{sessionId:_}=V;ae(null);try{const Z=await ue.deleteSession(_,R);if(Z.ok)u?.(_),await Ne();else{const J=await Z.text();console.error("[Sidebar] Failed to delete session:",{status:Z.status,error:J}),alert(l("messages.deleteSessionFailed"))}}catch(Z){console.error("[Sidebar] Error deleting session:",Z),alert(l("messages.deleteSessionError"))}},[Ne,u,V,l]),Ht=n.useCallback(R=>{ee({project:R,sessionCount:St(R).length})},[St]),Jt=n.useCallback(async(R=!1)=>{if(!A)return;const{project:_}=A;ee(null),N(Z=>new Set([...Z,_.projectId]));try{const Z=await ue.deleteProject(_.projectId,R);if(Z.ok)h?.(_.projectId);else{const le=(await Z.json()).error,ie=typeof le=="string"?le:le&&typeof le=="object"&&le.message?le.message:l("messages.deleteProjectFailed");alert(ie)}}catch(Z){console.error("Error deleting project:",Z),alert(l("messages.deleteProjectError"))}finally{N(Z=>{const J=new Set(Z);return J.delete(_.projectId),J})}},[A,h,l]),Tt=n.useCallback(R=>{m(R)},[m]),ao=n.useCallback(R=>{const _=R.projectId?t.find(ie=>ie.projectId===R.projectId):null,Z=R.projectId?De.find(ie=>ie.projectId===R.projectId):null,J=_??Z??null,le={id:R.sessionId,summary:R.sessionTitle,__provider:R.provider,__projectId:J?.projectId??R.projectId??void 0};J&&Tt(J),d(le)},[De,Tt,d,t]),no=n.useCallback(async R=>{try{const _=await ue.restoreProject(R);if(!_.ok){const Z=await _.text();console.error("[Sidebar] Failed to restore project:",{status:_.status,error:Z}),alert(l("messages.restoreProjectFailed","Failed to restore project. Please try again."));return}await Promise.all([Promise.resolve(c()),Ne()])}catch(_){console.error("[Sidebar] Error restoring project:",_),alert(l("messages.restoreProjectError","Error restoring project. Please try again."))}},[Ne,c,l]),oo=n.useCallback(async R=>{try{const _=await ue.restoreSession(R);if(!_.ok){const Z=await _.text();console.error("[Sidebar] Failed to restore session:",{status:_.status,error:Z}),alert(l("messages.restoreSessionFailed","Failed to restore session. Please try again."));return}await Promise.all([Promise.resolve(c()),Ne()])}catch(_){console.error("[Sidebar] Error restoring session:",_),alert(l("messages.restoreSessionError","Error restoring session. Please try again."))}},[Ne,c,l]),io=n.useCallback(async()=>{X(!0);try{await Promise.all([Promise.resolve(c()),Ne(),q==="conversations"?ze(0,!1):Promise.resolve()])}finally{X(!1)}},[Ne,ze,c,q]),lo=n.useCallback(async(R,_,Z,J)=>{const le=Z.trim();if(!le){B(null),D("");return}try{const ie=await ue.renameSession(_,le);ie.ok?await c():(console.error("[Sidebar] Failed to rename session:",ie.status),alert(l("messages.renameSessionFailed")))}catch(ie){console.error("[Sidebar] Error renaming session:",ie),alert(l("messages.renameSessionError"))}finally{B(null),D("")}},[c,l]),co=n.useCallback(()=>{p(!1)},[p]),uo=n.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:Os,expandedProjects:g,editingProject:S,showNewProject:y,editingName:E,initialSessionsLoaded:T,currentTime:j,projectSortOrder:G,isRefreshing:M,editingSession:H,editingSessionName:w,searchFilter:L,deletingProjects:U,loadingMoreProjects:_s,deleteConfirmation:A,sessionDeleteConfirmation:V,showVersionModal:de,filteredProjects:Ge,runningSessionsCount:Ds,archivedProjects:Et,archivedSessions:Pt,archivedSessionsCount:De.length+tt.length,isArchivedSessionsLoading:Es,recentConversations:vt,recentConversationsTotal:Is,recentConversationsHasMore:jt,isRecentConversationsLoading:Ls,isLoadingMoreRecentConversations:wt,recentConversationsError:Ms,reloadRecentConversations:kt,loadMoreRecentConversations:Ut,toggleProject:$s,handleSessionClick:Gt,toggleStarProject:Vt,isProjectStarred:zs,getProjectSessions:St,loadMoreSessionsForProject:Ct,startEditing:Us,cancelEditing:Gs,saveProjectName:Qe,showDeleteSessionConfirmation:Bt,confirmDeleteSession:Wt,requestProjectDelete:Ht,confirmDeleteProject:Jt,handleProjectSelect:Tt,openArchivedSession:ao,restoreArchivedProject:no,restoreArchivedSession:oo,refreshProjects:io,updateSessionSummary:lo,collapseSidebar:co,expandSidebar:uo,setShowNewProject:P,setEditingName:C,setEditingSession:B,setEditingSessionName:D,searchMode:q,setSearchMode:ye,conversationResults:se,isSearching:re,searchProgress:Ss,clearConversationResults:n.useCallback(()=>{Ce.current+=1,we.current&&(we.current.close(),we.current=null),Ie(!1),Re(null),ne(null)},[]),setSearchFilter:O,setDeleteConfirmation:ee,setSessionDeleteConfirmation:ae,setShowVersionModal:te}}const cn=n.createContext(null);function Oi(t,s){return{message:s instanceof Error?s.message:`Failed to ${t}`,context:t,timestamp:new Date().toISOString()}}function Br(t){return{...t,taskMasterConfigured:t.taskmaster?.hasTaskmaster??!1,taskMasterStatus:t.taskmaster?.status??"not-configured",taskCount:Number(t.taskmaster?.metadata?.taskCount??0),completedCount:Number(t.taskmaster?.metadata?.completed??0)}}function Di(t){return t.find(s=>s.status==="pending"||s.status==="in-progress")??null}function $i(t){return t?.type?t.type.startsWith("taskmaster-"):!1}function zi(){const t=n.useContext(cn);if(!t)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return t}function Fm({children:t,project:s,onProjectTaskMasterChange:r}){const{latestMessage:a}=gi(),{user:o,token:i,isLoading:l}=qa(),[c,m]=n.useState(null),[d,u]=n.useState(null),[x,h]=n.useState(null),[p,f]=n.useState([]),[b,g]=n.useState(null),[v,S]=n.useState(!1),[k,y]=n.useState(!1),[P,E]=n.useState(!1),[C,T]=n.useState(null),I=n.useRef(null),j=n.useRef(null),$=n.useRef(0),G=n.useRef(r);G.current=r,n.useEffect(()=>{I.current=c?.projectId??null},[c?.projectId]),n.useEffect(()=>{j.current=d},[d]);const K=n.useCallback(()=>{T(null)},[]),M=n.useCallback((O,U)=>{console.error(`TaskMaster ${O} error:`,U),T(Oi(O,U))},[]),X=n.useCallback((O,U)=>{u(U),m(N=>!N||N.projectId!==O?N:Br({...N,taskmaster:U??void 0})),G.current(O,U)},[]),H=n.useCallback(async O=>{if(!O||!o||!i)return;const U=++$.current;try{const N=await ue.projectTaskmaster(O);if(!N.ok)throw new Error(`Failed to fetch TaskMaster details: ${N.status}`);const ee=(await N.json()).taskmaster??null;if(U!==$.current||I.current!==O)return;X(O,ee)}catch(N){if(U!==$.current||I.current!==O)return;M("load selected project TaskMaster info",N)}},[X,M,i,o]),B=n.useCallback(async()=>{const O=I.current;if(O){S(!0);try{await H(O)}finally{I.current===O&&S(!1)}}},[H]);n.useEffect(()=>{const O=s?Br(s):null,U=I.current,N=O?.projectId??null;I.current=N,m(O),u(O?.taskmaster??null),U!==N&&($.current+=1,f([]),g(null))},[s]),n.useEffect(()=>{s?.projectId&&o&&i&&B()},[s?.projectId,B,i,o]);const w=n.useCallback(async()=>{const O=c?.projectId;if(!O||!o||!i){f([]),g(null);return}try{y(!0),K();const U=await ue.get(`/taskmaster/tasks/${encodeURIComponent(O)}`);if(!U.ok){const ee=await U.json();throw new Error(ee.message??"Failed to load tasks")}const N=await U.json(),A=Array.isArray(N.tasks)?N.tasks:[];f(A),g(Di(A))}catch(U){M("load tasks",U),f([]),g(null)}finally{y(!1)}},[K,c?.projectId,M,i,o]),D=n.useCallback(async()=>{if(!o||!i){h(null);return}try{E(!0),K();const O=await ue.get("/taskmaster/mcp-status");if(!O.ok)throw new Error(`Failed to load MCP status: ${O.status}`);const U=await O.json();h(U)}catch(O){M("check MCP server status",O),h(null)}finally{E(!1)}},[K,M,i,o]);n.useEffect(()=>{!l&&o&&i&&D()},[l,D,i,o]),n.useEffect(()=>{c?.projectId&&o&&i&&w()},[c?.projectId,w,i,o]),n.useEffect(()=>{const O=a;if($i(O)){if(O.type==="taskmaster-project-updated"&&O.projectId){O.projectId===I.current&&H(O.projectId);return}if(O.type==="taskmaster-tasks-updated"&&O.projectId===c?.projectId){w();return}O.type==="taskmaster-mcp-status-changed"&&D()}},[c?.projectId,a,H,D,w]);const L=n.useMemo(()=>({currentProject:c,projectTaskMaster:d,mcpServerStatus:x,tasks:p,nextTask:b,isLoading:v,isLoadingTasks:k,isLoadingMCP:P,error:C,refreshProjectTaskMaster:B,refreshTasks:w,refreshMCPStatus:D,clearError:K}),[K,c,C,v,P,k,x,b,d,D,B,w,p]);return e.jsx(cn.Provider,{value:L,children:t})}function Ui({onExpand:t,onShowSettings:s,updateAvailable:r,restartRequired:a,onShowVersionModal:o,t:i}){return e.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[e.jsx("button",{onClick:t,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("common:versionUpdate.ariaLabels.showSidebar"),title:i("common:versionUpdate.ariaLabels.showSidebar"),children:e.jsx(po,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),e.jsx("div",{className:"nav-divider my-1 w-6"}),e.jsx("button",{onClick:s,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("actions.settings"),title:i("actions.settings"),children:e.jsx(as,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),a&&e.jsxs("div",{className:"relative flex h-8 w-8 items-center justify-center rounded-lg","aria-label":i("version.restartRequired"),title:i("version.restartRequired"),children:[e.jsx(Oe,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-amber-500"})]}),r&&e.jsxs("button",{onClick:o,className:"relative flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":i("common:versionUpdate.ariaLabels.updateAvailable"),title:i("common:versionUpdate.ariaLabels.updateAvailable"),children:[e.jsx(xo,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function dn(t){var s,r,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(s=0;s<o;s++)t[s]&&(r=dn(t[s]))&&(a&&(a+=" "),a+=r)}else for(r in t)t[r]&&(a&&(a+=" "),a+=r);return a}function un(){for(var t,s,r=0,a="",o=arguments.length;r<o;r++)(t=arguments[r])&&(s=dn(t))&&(a&&(a+=" "),a+=s);return a}const Wr=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Hr=un,wr=(t,s)=>r=>{var a;if(s?.variants==null)return Hr(t,r?.class,r?.className);const{variants:o,defaultVariants:i}=s,l=Object.keys(o).map(d=>{const u=r?.[d],x=i?.[d];if(u===null)return null;const h=Wr(u)||Wr(x);return o[d][h]}),c=r&&Object.entries(r).reduce((d,u)=>{let[x,h]=u;return h===void 0||(d[x]=h),d},{}),m=s==null||(a=s.compoundVariants)===null||a===void 0?void 0:a.reduce((d,u)=>{let{class:x,className:h,...p}=u;return Object.entries(p).every(f=>{let[b,g]=f;return Array.isArray(g)?g.includes({...i,...c}[b]):{...i,...c}[b]===g})?[...d,x,h]:d},[]);return Hr(t,l,m,r?.class,r?.className)},Nr="-",Gi=t=>{const s=Ki(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:l=>{const c=l.split(Nr);return c[0]===""&&c.length!==1&&c.shift(),mn(c,s)||Vi(l)},getConflictingClassGroupIds:(l,c)=>{const m=r[l]||[];return c&&a[l]?[...m,...a[l]]:m}}},mn=(t,s)=>{if(t.length===0)return s.classGroupId;const r=t[0],a=s.nextPart.get(r),o=a?mn(t.slice(1),a):void 0;if(o)return o;if(s.validators.length===0)return;const i=t.join(Nr);return s.validators.find(({validator:l})=>l(i))?.classGroupId},Jr=/^\[(.+)\]$/,Vi=t=>{if(Jr.test(t)){const s=Jr.exec(t)[1],r=s?.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Ki=t=>{const{theme:s,classGroups:r}=t,a={nextPart:new Map,validators:[]};for(const o in r)cr(r[o],a,o,s);return a},cr=(t,s,r,a)=>{t.forEach(o=>{if(typeof o=="string"){const i=o===""?s:qr(s,o);i.classGroupId=r;return}if(typeof o=="function"){if(Bi(o)){cr(o(a),s,r,a);return}s.validators.push({validator:o,classGroupId:r});return}Object.entries(o).forEach(([i,l])=>{cr(l,qr(s,i),r,a)})})},qr=(t,s)=>{let r=t;return s.split(Nr).forEach(a=>{r.nextPart.has(a)||r.nextPart.set(a,{nextPart:new Map,validators:[]}),r=r.nextPart.get(a)}),r},Bi=t=>t.isThemeGetter,Wi=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,a=new Map;const o=(i,l)=>{r.set(i,l),s++,s>t&&(s=0,a=r,r=new Map)};return{get(i){let l=r.get(i);if(l!==void 0)return l;if((l=a.get(i))!==void 0)return o(i,l),l},set(i,l){r.has(i)?r.set(i,l):o(i,l)}}},dr="!",ur=":",Hi=ur.length,Ji=t=>{const{prefix:s,experimentalParseClassName:r}=t;let a=o=>{const i=[];let l=0,c=0,m=0,d;for(let f=0;f<o.length;f++){let b=o[f];if(l===0&&c===0){if(b===ur){i.push(o.slice(m,f)),m=f+Hi;continue}if(b==="/"){d=f;continue}}b==="["?l++:b==="]"?l--:b==="("?c++:b===")"&&c--}const u=i.length===0?o:o.substring(m),x=qi(u),h=x!==u,p=d&&d>m?d-m:void 0;return{modifiers:i,hasImportantModifier:h,baseClassName:x,maybePostfixModifierPosition:p}};if(s){const o=s+ur,i=a;a=l=>l.startsWith(o)?i(l.substring(o.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:l,maybePostfixModifierPosition:void 0}}if(r){const o=a;a=i=>r({className:i,parseClassName:o})}return a},qi=t=>t.endsWith(dr)?t.substring(0,t.length-1):t.startsWith(dr)?t.substring(1):t,Qi=t=>{const s=Object.fromEntries(t.orderSensitiveModifiers.map(a=>[a,!0]));return a=>{if(a.length<=1)return a;const o=[];let i=[];return a.forEach(l=>{l[0]==="["||s[l]?(o.push(...i.sort(),l),i=[]):i.push(l)}),o.push(...i.sort()),o}},Yi=t=>({cache:Wi(t.cacheSize),parseClassName:Ji(t),sortModifiers:Qi(t),...Gi(t)}),Zi=/\s+/,Xi=(t,s)=>{const{parseClassName:r,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:i}=s,l=[],c=t.trim().split(Zi);let m="";for(let d=c.length-1;d>=0;d-=1){const u=c[d],{isExternal:x,modifiers:h,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:b}=r(u);if(x){m=u+(m.length>0?" "+m:m);continue}let g=!!b,v=a(g?f.substring(0,b):f);if(!v){if(!g){m=u+(m.length>0?" "+m:m);continue}if(v=a(f),!v){m=u+(m.length>0?" "+m:m);continue}g=!1}const S=i(h).join(":"),k=p?S+dr:S,y=k+v;if(l.includes(y))continue;l.push(y);const P=o(v,g);for(let E=0;E<P.length;++E){const C=P[E];l.push(k+C)}m=u+(m.length>0?" "+m:m)}return m};function el(){let t=0,s,r,a="";for(;t<arguments.length;)(s=arguments[t++])&&(r=pn(s))&&(a&&(a+=" "),a+=r);return a}const pn=t=>{if(typeof t=="string")return t;let s,r="";for(let a=0;a<t.length;a++)t[a]&&(s=pn(t[a]))&&(r&&(r+=" "),r+=s);return r};function tl(t,...s){let r,a,o,i=l;function l(m){const d=s.reduce((u,x)=>x(u),t());return r=Yi(d),a=r.cache.get,o=r.cache.set,i=c,c(m)}function c(m){const d=a(m);if(d)return d;const u=Xi(m,r);return o(m,u),u}return function(){return i(el.apply(null,arguments))}}const be=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},xn=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,hn=/^\((?:(\w[\w-]*):)?(.+)\)$/i,sl=/^\d+\/\d+$/,rl=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,al=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,nl=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ol=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,il=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,lt=t=>sl.test(t),oe=t=>!!t&&!Number.isNaN(Number(t)),Ke=t=>!!t&&Number.isInteger(Number(t)),Ws=t=>t.endsWith("%")&&oe(t.slice(0,-1)),Le=t=>rl.test(t),ll=()=>!0,cl=t=>al.test(t)&&!nl.test(t),gn=()=>!1,dl=t=>ol.test(t),ul=t=>il.test(t),ml=t=>!Q(t)&&!Y(t),pl=t=>bt(t,yn,gn),Q=t=>xn.test(t),Ye=t=>bt(t,vn,cl),Hs=t=>bt(t,bl,oe),Qr=t=>bt(t,fn,gn),xl=t=>bt(t,bn,ul),Yt=t=>bt(t,jn,dl),Y=t=>hn.test(t),It=t=>yt(t,vn),hl=t=>yt(t,yl),Yr=t=>yt(t,fn),gl=t=>yt(t,yn),fl=t=>yt(t,bn),Zt=t=>yt(t,jn,!0),bt=(t,s,r)=>{const a=xn.exec(t);return a?a[1]?s(a[1]):r(a[2]):!1},yt=(t,s,r=!1)=>{const a=hn.exec(t);return a?a[1]?s(a[1]):r:!1},fn=t=>t==="position"||t==="percentage",bn=t=>t==="image"||t==="url",yn=t=>t==="length"||t==="size"||t==="bg-size",vn=t=>t==="length",bl=t=>t==="number",yl=t=>t==="family-name",jn=t=>t==="shadow",vl=()=>{const t=be("color"),s=be("font"),r=be("text"),a=be("font-weight"),o=be("tracking"),i=be("leading"),l=be("breakpoint"),c=be("container"),m=be("spacing"),d=be("radius"),u=be("shadow"),x=be("inset-shadow"),h=be("text-shadow"),p=be("drop-shadow"),f=be("blur"),b=be("perspective"),g=be("aspect"),v=be("ease"),S=be("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...y(),Y,Q],E=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],T=()=>[Y,Q,m],I=()=>[lt,"full","auto",...T()],j=()=>[Ke,"none","subgrid",Y,Q],$=()=>["auto",{span:["full",Ke,Y,Q]},Ke,Y,Q],G=()=>[Ke,"auto",Y,Q],K=()=>["auto","min","max","fr",Y,Q],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...T()],B=()=>[lt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],w=()=>[t,Y,Q],D=()=>[...y(),Yr,Qr,{position:[Y,Q]}],L=()=>["no-repeat",{repeat:["","x","y","space","round"]}],O=()=>["auto","cover","contain",gl,pl,{size:[Y,Q]}],U=()=>[Ws,It,Ye],N=()=>["","none","full",d,Y,Q],A=()=>["",oe,It,Ye],ee=()=>["solid","dashed","dotted","double"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ae=()=>[oe,Ws,Yr,Qr],de=()=>["","none",f,Y,Q],te=()=>["none",oe,Y,Q],q=()=>["none",oe,Y,Q],ye=()=>[oe,Y,Q],se=()=>[lt,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Le],breakpoint:[Le],color:[ll],container:[Le],"drop-shadow":[Le],ease:["in","out","in-out"],font:[ml],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Le],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Le],shadow:[Le],spacing:["px",oe],text:[Le],"text-shadow":[Le],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",lt,Q,Y,g]}],container:["container"],columns:[{columns:[oe,Q,Y,c]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{start:I()}],end:[{end:I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[Ke,"auto",Y,Q]}],basis:[{basis:[lt,"full","auto",c,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[oe,lt,"auto","initial","none",Q]}],grow:[{grow:["",oe,Y,Q]}],shrink:[{shrink:["",oe,Y,Q]}],order:[{order:[Ke,"first","last","none",Y,Q]}],"grid-cols":[{"grid-cols":j()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":G()}],"col-end":[{"col-end":G()}],"grid-rows":[{"grid-rows":j()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":G()}],"row-end":[{"row-end":G()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":K()}],"auto-rows":[{"auto-rows":K()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],w:[{w:[c,"screen",...B()]}],"min-w":[{"min-w":[c,"screen","none",...B()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[l]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",r,It,Ye]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Y,Hs]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ws,Q]}],"font-family":[{font:[hl,Q,s]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Y,Q]}],"line-clamp":[{"line-clamp":[oe,"none",Y,Hs]}],leading:[{leading:[i,...T()]}],"list-image":[{"list-image":["none",Y,Q]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Y,Q]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:w()}],"text-color":[{text:w()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:[oe,"from-font","auto",Y,Ye]}],"text-decoration-color":[{decoration:w()}],"underline-offset":[{"underline-offset":[oe,"auto",Y,Q]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Y,Q]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Y,Q]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:L()}],"bg-size":[{bg:O()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ke,Y,Q],radial:["",Y,Q],conic:[Ke,Y,Q]},fl,xl]}],"bg-color":[{bg:w()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:w()}],"gradient-via":[{via:w()}],"gradient-to":[{to:w()}],rounded:[{rounded:N()}],"rounded-s":[{"rounded-s":N()}],"rounded-e":[{"rounded-e":N()}],"rounded-t":[{"rounded-t":N()}],"rounded-r":[{"rounded-r":N()}],"rounded-b":[{"rounded-b":N()}],"rounded-l":[{"rounded-l":N()}],"rounded-ss":[{"rounded-ss":N()}],"rounded-se":[{"rounded-se":N()}],"rounded-ee":[{"rounded-ee":N()}],"rounded-es":[{"rounded-es":N()}],"rounded-tl":[{"rounded-tl":N()}],"rounded-tr":[{"rounded-tr":N()}],"rounded-br":[{"rounded-br":N()}],"rounded-bl":[{"rounded-bl":N()}],"border-w":[{border:A()}],"border-w-x":[{"border-x":A()}],"border-w-y":[{"border-y":A()}],"border-w-s":[{"border-s":A()}],"border-w-e":[{"border-e":A()}],"border-w-t":[{"border-t":A()}],"border-w-r":[{"border-r":A()}],"border-w-b":[{"border-b":A()}],"border-w-l":[{"border-l":A()}],"divide-x":[{"divide-x":A()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":A()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ee(),"hidden","none"]}],"divide-style":[{divide:[...ee(),"hidden","none"]}],"border-color":[{border:w()}],"border-color-x":[{"border-x":w()}],"border-color-y":[{"border-y":w()}],"border-color-s":[{"border-s":w()}],"border-color-e":[{"border-e":w()}],"border-color-t":[{"border-t":w()}],"border-color-r":[{"border-r":w()}],"border-color-b":[{"border-b":w()}],"border-color-l":[{"border-l":w()}],"divide-color":[{divide:w()}],"outline-style":[{outline:[...ee(),"none","hidden"]}],"outline-offset":[{"outline-offset":[oe,Y,Q]}],"outline-w":[{outline:["",oe,It,Ye]}],"outline-color":[{outline:w()}],shadow:[{shadow:["","none",u,Zt,Yt]}],"shadow-color":[{shadow:w()}],"inset-shadow":[{"inset-shadow":["none",x,Zt,Yt]}],"inset-shadow-color":[{"inset-shadow":w()}],"ring-w":[{ring:A()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:w()}],"ring-offset-w":[{"ring-offset":[oe,Ye]}],"ring-offset-color":[{"ring-offset":w()}],"inset-ring-w":[{"inset-ring":A()}],"inset-ring-color":[{"inset-ring":w()}],"text-shadow":[{"text-shadow":["none",h,Zt,Yt]}],"text-shadow-color":[{"text-shadow":w()}],opacity:[{opacity:[oe,Y,Q]}],"mix-blend":[{"mix-blend":[...V(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":V()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[oe]}],"mask-image-linear-from-pos":[{"mask-linear-from":ae()}],"mask-image-linear-to-pos":[{"mask-linear-to":ae()}],"mask-image-linear-from-color":[{"mask-linear-from":w()}],"mask-image-linear-to-color":[{"mask-linear-to":w()}],"mask-image-t-from-pos":[{"mask-t-from":ae()}],"mask-image-t-to-pos":[{"mask-t-to":ae()}],"mask-image-t-from-color":[{"mask-t-from":w()}],"mask-image-t-to-color":[{"mask-t-to":w()}],"mask-image-r-from-pos":[{"mask-r-from":ae()}],"mask-image-r-to-pos":[{"mask-r-to":ae()}],"mask-image-r-from-color":[{"mask-r-from":w()}],"mask-image-r-to-color":[{"mask-r-to":w()}],"mask-image-b-from-pos":[{"mask-b-from":ae()}],"mask-image-b-to-pos":[{"mask-b-to":ae()}],"mask-image-b-from-color":[{"mask-b-from":w()}],"mask-image-b-to-color":[{"mask-b-to":w()}],"mask-image-l-from-pos":[{"mask-l-from":ae()}],"mask-image-l-to-pos":[{"mask-l-to":ae()}],"mask-image-l-from-color":[{"mask-l-from":w()}],"mask-image-l-to-color":[{"mask-l-to":w()}],"mask-image-x-from-pos":[{"mask-x-from":ae()}],"mask-image-x-to-pos":[{"mask-x-to":ae()}],"mask-image-x-from-color":[{"mask-x-from":w()}],"mask-image-x-to-color":[{"mask-x-to":w()}],"mask-image-y-from-pos":[{"mask-y-from":ae()}],"mask-image-y-to-pos":[{"mask-y-to":ae()}],"mask-image-y-from-color":[{"mask-y-from":w()}],"mask-image-y-to-color":[{"mask-y-to":w()}],"mask-image-radial":[{"mask-radial":[Y,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":ae()}],"mask-image-radial-to-pos":[{"mask-radial-to":ae()}],"mask-image-radial-from-color":[{"mask-radial-from":w()}],"mask-image-radial-to-color":[{"mask-radial-to":w()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":y()}],"mask-image-conic-pos":[{"mask-conic":[oe]}],"mask-image-conic-from-pos":[{"mask-conic-from":ae()}],"mask-image-conic-to-pos":[{"mask-conic-to":ae()}],"mask-image-conic-from-color":[{"mask-conic-from":w()}],"mask-image-conic-to-color":[{"mask-conic-to":w()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:L()}],"mask-size":[{mask:O()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Y,Q]}],filter:[{filter:["","none",Y,Q]}],blur:[{blur:de()}],brightness:[{brightness:[oe,Y,Q]}],contrast:[{contrast:[oe,Y,Q]}],"drop-shadow":[{"drop-shadow":["","none",p,Zt,Yt]}],"drop-shadow-color":[{"drop-shadow":w()}],grayscale:[{grayscale:["",oe,Y,Q]}],"hue-rotate":[{"hue-rotate":[oe,Y,Q]}],invert:[{invert:["",oe,Y,Q]}],saturate:[{saturate:[oe,Y,Q]}],sepia:[{sepia:["",oe,Y,Q]}],"backdrop-filter":[{"backdrop-filter":["","none",Y,Q]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[oe,Y,Q]}],"backdrop-contrast":[{"backdrop-contrast":[oe,Y,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":["",oe,Y,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[oe,Y,Q]}],"backdrop-invert":[{"backdrop-invert":["",oe,Y,Q]}],"backdrop-opacity":[{"backdrop-opacity":[oe,Y,Q]}],"backdrop-saturate":[{"backdrop-saturate":[oe,Y,Q]}],"backdrop-sepia":[{"backdrop-sepia":["",oe,Y,Q]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Y,Q]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[oe,"initial",Y,Q]}],ease:[{ease:["linear","initial",v,Y,Q]}],delay:[{delay:[oe,Y,Q]}],animate:[{animate:["none",S,Y,Q]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Y,Q]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:q()}],"scale-x":[{"scale-x":q()}],"scale-y":[{"scale-y":q()}],"scale-z":[{"scale-z":q()}],"scale-3d":["scale-3d"],skew:[{skew:ye()}],"skew-x":[{"skew-x":ye()}],"skew-y":[{"skew-y":ye()}],transform:[{transform:[Y,Q,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:se()}],"translate-x":[{"translate-x":se()}],"translate-y":[{"translate-y":se()}],"translate-z":[{"translate-z":se()}],"translate-none":["translate-none"],accent:[{accent:w()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:w()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Y,Q]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Y,Q]}],fill:[{fill:["none",...w()]}],"stroke-w":[{stroke:[oe,It,Ye,Hs]}],stroke:[{stroke:["none",...w()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},jl=tl(vl);function F(...t){return jl(un(t))}const wl=wr("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current"}},defaultVariants:{variant:"default"}}),wn=n.forwardRef(({className:t,variant:s,...r},a)=>e.jsx("div",{ref:a,role:"alert","data-slot":"alert",className:F(wl({variant:s}),t),...r}));wn.displayName="Alert";const Nl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"alert-title",className:F("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...s}));Nl.displayName="AlertTitle";const kl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"alert-description",className:F("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...s}));kl.displayName="AlertDescription";const Nn=wr("inline-flex touch-manipulation items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90 active:bg-primary/80",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/80",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground active:bg-accent/80",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 active:bg-secondary/70",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent/80",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3 text-sm",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),W=n.forwardRef(({className:t,variant:s,size:r,...a},o)=>e.jsx("button",{className:F(Nn({variant:s,size:r,className:t})),ref:o,...a}));W.displayName="Button";function kn({label:t,items:s,icon:r,ariaLabel:a,align:o="right",variant:i="outline",size:l="sm",className:c,triggerClassName:m,menuClassName:d,disabled:u,iconOnly:x=!1,portal:h=!1,header:p,onOpenChange:f}){const[b,g]=n.useState(!1),[v,S]=n.useState(null),k=n.useRef(null),y=n.useRef(null),P=n.useRef(null),E=n.useRef(!1),C=n.useRef(!1),T=n.useRef(!1),I=n.useId(),j=n.useCallback(M=>{g(M),M||S(null),f?.(M)},[f]);n.useEffect(()=>{if(!b)return;const M=H=>{const B=H.target;k.current&&!k.current.contains(B)&&!P.current?.contains(B)&&j(!1)},X=H=>{H.key==="Escape"&&(E.current=!0,j(!1))};return document.addEventListener("mousedown",M),document.addEventListener("keydown",X),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",X)}},[b,j]),n.useEffect(()=>{if(!b||!h)return;const M=()=>j(!1);return window.addEventListener("resize",M),window.addEventListener("scroll",M,!0),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,!0)}},[b,h,j]),n.useEffect(()=>{if(b){if(T.current=!0,C.current){const M=P.current;(M?.querySelector('[role="menuitem"]:not([disabled])')??M)?.focus()}return}T.current&&(T.current=!1,E.current&&y.current?.focus(),E.current=!1)},[b]);const $=M=>{M.disabled||M.loading||(M.closeOnSelect!==!1&&(E.current=!0,j(!1)),M.onSelect())},G=()=>{if(b){j(!1);return}if(h&&y.current){const M=y.current.getBoundingClientRect(),X=260,H=(p?52:0)+s.reduce((B,w)=>B+(w.description?58:40)+(w.showDividerBefore?9:0),12);S({top:M.bottom+6+H<=window.innerHeight-8?M.bottom+6:Math.max(8,M.top-H-6),left:Math.max(8,Math.min(M.right-X,window.innerWidth-X-8))})}j(!0)},K=b&&(!h||v)&&e.jsxs("div",{ref:P,id:I,role:"menu",tabIndex:-1,className:F(h?"fixed z-[70]":"absolute top-full z-50 mt-2","min-w-[220px] rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lg","animate-in fade-in-0 zoom-in-95",!h&&(o==="right"?"right-0":"left-0"),d),style:h&&v?v:void 0,children:[p,s.map(M=>{const X=M.icon;return e.jsxs(n.Fragment,{children:[M.showDividerBefore&&e.jsx("div",{className:"mx-2 my-1 h-px bg-border"}),e.jsxs("button",{type:"button",role:"menuitem",disabled:M.disabled||M.loading,onClick:()=>$(M),className:F("flex w-full items-start gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors","focus:outline-none focus-visible:bg-accent",M.disabled||M.loading?"cursor-not-allowed opacity-50":M.isDanger?"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950":"hover:bg-accent"),children:[M.loading?e.jsx(ve,{className:"mt-0.5 h-4 w-4 flex-shrink-0 animate-spin"}):X&&e.jsx(X,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block font-medium leading-5",children:M.label}),M.description&&e.jsx("span",{className:"mt-0.5 block text-xs leading-4 text-muted-foreground",children:M.description})]})]})]},M.key)})]});return e.jsxs("div",{ref:k,className:F("relative inline-flex",c),children:[e.jsxs(W,{ref:y,type:"button",variant:i,size:l,className:m,disabled:u,"aria-label":a||t,"aria-haspopup":"menu","aria-expanded":b,"aria-controls":b?I:void 0,onClick:M=>{C.current=M.detail===0,G()},children:[r&&e.jsx(r,{className:"h-4 w-4"}),!x&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:t}),e.jsx(ns,{className:F("h-4 w-4 transition-transform",b&&"rotate-180")})]})]}),h&&typeof document<"u"?ys.createPortal(K,document.body):K]})}const Sl=wr("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Pe({className:t,variant:s,...r}){return e.jsx("div",{className:F(Sl({variant:s}),t),...r})}const Sn=n.createContext(null),Cn=()=>{const t=n.useContext(Sn);if(!t)throw new Error("Confirmation components must be used within Confirmation");return t},Cl=({className:t,approval:s="pending",children:r,...a})=>{const o=n.useMemo(()=>({approval:s}),[s]);return e.jsx(Sn.Provider,{value:o,children:e.jsx(wn,{className:F("flex flex-col gap-2",t),...a,children:r})})};Cl.displayName="Confirmation";const Pl=({className:t,...s})=>e.jsx("div",{"data-slot":"confirmation-title",className:F("text-muted-foreground inline text-sm",t),...s});Pl.displayName="ConfirmationTitle";const El=({children:t})=>{const{approval:s}=Cn();return s!=="pending"?null:e.jsx(e.Fragment,{children:t})};El.displayName="ConfirmationRequest";const Tl=({className:t,...s})=>{const{approval:r}=Cn();return r!=="pending"?null:e.jsx("div",{"data-slot":"confirmation-actions",className:F("flex items-center justify-end gap-2 self-end",t),...s})};Tl.displayName="ConfirmationActions";const Il=({variant:t="default",...s})=>e.jsx(W,{className:"h-8 px-3 text-sm",variant:t,type:"button",...s});Il.displayName="ConfirmationAction";const Rl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("rounded-xl border bg-card text-card-foreground shadow-sm",t),...s}));Rl.displayName="Card";const Al=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("flex flex-col space-y-1.5 p-4",t),...s}));Al.displayName="CardHeader";const Ll=n.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:F("font-semibold leading-none tracking-tight",t),...s}));Ll.displayName="CardTitle";const Ml=n.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:F("text-sm text-muted-foreground",t),...s}));Ml.displayName="CardDescription";const Fl=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("p-4 pt-0",t),...s}));Fl.displayName="CardContent";const _l=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("flex items-center p-4 pt-0",t),...s}));_l.displayName="CardFooter";const Ol=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:F("ml-auto shrink-0",t),...s}));Ol.displayName="CardAction";const Pn=n.createContext(null);function En(){const t=n.useContext(Pn);if(!t)throw new Error("Collapsible components must be used within <Collapsible>");return t}const Tn=n.forwardRef(({defaultOpen:t=!1,open:s,onOpenChange:r,className:a,children:o,...i},l)=>{const[c,m]=n.useState(t),d=s!==void 0,u=d?s:c,x=n.useCallback(p=>{d||m(p),r?.(p)},[d,r]),h=n.useMemo(()=>({open:u,onOpenChange:x}),[u,x]);return e.jsx(Pn.Provider,{value:h,children:e.jsx("div",{ref:l,"data-state":u?"open":"closed",className:a,...i,children:o})})});Tn.displayName="Collapsible";const In=n.forwardRef(({onClick:t,children:s,className:r,...a},o)=>{const{open:i,onOpenChange:l}=En(),c=n.useCallback(m=>{l(!i),t?.(m)},[i,l,t]);return e.jsx("button",{ref:o,type:"button","aria-expanded":i,"data-state":i?"open":"closed",onClick:c,className:r,...a,children:s})});In.displayName="CollapsibleTrigger";const Rn=n.forwardRef(({className:t,children:s,...r},a)=>{const{open:o}=En();return e.jsx("div",{ref:a,"data-state":o?"open":"closed",className:F("grid transition-[grid-template-rows] duration-200 ease-out",o?"grid-rows-[1fr]":"grid-rows-[0fr]",t),...r,children:e.jsx("div",{className:"overflow-hidden",children:s})})});Rn.displayName="CollapsibleContent";const Dl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke,{ref:r,className:F("flex flex-col",t),...s}));Dl.displayName=ke.displayName;const $l=n.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3",children:[e.jsx(et,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),e.jsx(ke.Input,{ref:r,className:F("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));$l.displayName=ke.Input.displayName;const zl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.List,{ref:r,className:F("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));zl.displayName=ke.List.displayName;const Ul=n.forwardRef((t,s)=>e.jsx(ke.Empty,{ref:s,className:"py-6 text-center text-sm text-muted-foreground",...t}));Ul.displayName=ke.Empty.displayName;const Gl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.Group,{ref:r,className:F("overflow-hidden p-1 text-foreground","[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));Gl.displayName=ke.Group.displayName;const Vl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.Item,{ref:r,className:F("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none","data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground","data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",t),...s}));Vl.displayName=ke.Item.displayName;const Kl=n.forwardRef(({className:t,...s},r)=>e.jsx(ke.Separator,{ref:r,className:F("-mx-1 h-px bg-border",t),...s}));Kl.displayName=ke.Separator.displayName;function Bl({checked:t,onToggle:s,ariaLabel:r="Toggle dark mode"}){const{isDarkMode:a,toggleDarkMode:o}=br(),i=typeof t=="boolean"&&typeof s=="function",l=i?t:a,c=()=>{if(i&&s){s(!l);return}o()};return e.jsxs("button",{onClick:c,className:F("relative inline-flex h-7 w-12 flex-shrink-0 touch-manipulation cursor-pointer items-center rounded-full border-2 transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",l?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":l,"aria-label":r,children:[e.jsx("span",{className:"sr-only",children:r}),e.jsx("span",{className:F("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",l?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:l?e.jsx(ho,{className:"h-3 w-3 text-primary"}):e.jsx(go,{className:"h-3 w-3 text-white dark:text-background"})})]})}const An=n.createContext(null);function Ln(){const t=n.useContext(An);if(!t)throw new Error("Dialog components must be used within <Dialog>");return t}const Mn=({open:t,onOpenChange:s,defaultOpen:r=!1,children:a})=>{const[o,i]=n.useState(r),l=n.useRef(null),c=t!==void 0,m=c?t:o,d=n.useCallback(x=>{c||i(x),s?.(x)},[c,s]),u=n.useMemo(()=>({open:m,onOpenChange:d,triggerRef:l}),[m,d]);return e.jsx(An.Provider,{value:u,children:a})},Wl=n.forwardRef(({onClick:t,children:s,asChild:r,...a},o)=>{const{onOpenChange:i,triggerRef:l}=Ln(),c=n.useCallback(m=>{i(!0),t?.(m)},[i,t]);if(r&&n.isValidElement(s)){const m=s;return n.cloneElement(m,{onClick:d=>{i(!0),m.props.onClick?.(d)},ref:d=>{l.current=d,typeof o=="function"?o(d):o&&(o.current=d)}})}return e.jsx("button",{ref:m=>{l.current=m,typeof o=="function"?o(m):o&&(o.current=m)},type:"button",onClick:c,...a,children:s})});Wl.displayName="DialogTrigger";const Zr='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',kr=n.forwardRef(({className:t,children:s,onEscapeKeyDown:r,onPointerDownOutside:a,wrapperClassName:o,animationClassName:i,...l},c)=>{const{open:m,onOpenChange:d,triggerRef:u}=Ln(),x=n.useRef(null),h=n.useRef(null);return n.useEffect(()=>{m?h.current=document.activeElement:h.current&&((u.current||h.current)?.focus(),h.current=null)},[m,u]),n.useEffect(()=>{if(!m)return;const p=b=>{if(b.key==="Escape"){b.stopPropagation(),r?.(),d(!1);return}if(b.key==="Tab"&&x.current){const g=Array.from(x.current.querySelectorAll(Zr));if(g.length===0)return;const v=g[0],S=g[g.length-1];b.shiftKey&&document.activeElement===v?(b.preventDefault(),S.focus()):!b.shiftKey&&document.activeElement===S&&(b.preventDefault(),v.focus())}};document.addEventListener("keydown",p,!0);const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=f}},[m,d,r]),n.useEffect(()=>{m&&x.current&&requestAnimationFrame(()=>{x.current?.querySelector(Zr)?.focus()})},[m]),m?ys.createPortal(e.jsxs("div",{className:F("fixed inset-0 z-50",o),children:[e.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{a?.(),d(!1)},"aria-hidden":!0}),e.jsx("div",{ref:p=>{x.current=p,typeof c=="function"?c(p):c&&(c.current=p)},role:"dialog","aria-modal":"true",className:F("fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2","rounded-xl border bg-popover text-popover-foreground shadow-lg",i??"animate-dialog-content-show",t),...l,children:s})]}),document.body):null});kr.displayName="DialogContent";const Sr=n.forwardRef(({className:t,...s},r)=>e.jsx("h2",{ref:r,className:F("sr-only",t),...s}));Sr.displayName="DialogTitle";const me=n.forwardRef(({className:t,type:s,...r},a)=>e.jsx("input",{type:s,className:F("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:a,...r}));me.displayName="Input";const Fn=n.forwardRef(({className:t,children:s,...r},a)=>e.jsx("div",{className:F(t,"relative overflow-hidden"),...r,children:e.jsx("div",{ref:a,className:"h-full w-full overflow-auto rounded-[inherit]",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:s})}));Fn.displayName="ScrollArea";const _n=n.memo(({children:t,className:s,as:r="span"})=>e.jsx(r,{className:F("animate-shimmer inline-block bg-[length:250%_100%] bg-clip-text text-transparent","bg-[linear-gradient(90deg,transparent_33%,hsl(var(--foreground))_50%,transparent_67%),linear-gradient(hsl(var(--muted-foreground)),hsl(var(--muted-foreground)))]",s),children:t}));_n.displayName="Shimmer";const On=n.createContext(null),Hl=()=>{const t=n.useContext(On);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Jl=1e3,ql=1e3,Ql=n.memo(({className:t,isStreaming:s=!1,open:r,defaultOpen:a,onOpenChange:o,duration:i,children:l,...c})=>{const m=a??s,d=a===!1,[u,x]=n.useState(m),h=r!==void 0,p=h?r:u,f=n.useCallback(E=>{h||x(E),o?.(E)},[h,o]),[b,g]=n.useState(i),v=n.useRef(s),[S,k]=n.useState(!1),y=n.useRef(null);n.useEffect(()=>{i!==void 0&&g(i)},[i]),n.useEffect(()=>{s?(v.current=!0,y.current===null&&(y.current=Date.now())):y.current!==null&&(g(Math.ceil((Date.now()-y.current)/ql)),y.current=null)},[s]),n.useEffect(()=>{s&&!p&&!d&&f(!0)},[s,p,f,d]),n.useEffect(()=>{if(v.current&&!s&&p&&!S){const E=setTimeout(()=>{f(!1),k(!0)},Jl);return()=>clearTimeout(E)}},[s,p,f,S]);const P=n.useMemo(()=>({duration:b,isOpen:p,isStreaming:s,setIsOpen:f}),[b,p,s,f]);return e.jsx(On.Provider,{value:P,children:e.jsx(Tn,{open:p,onOpenChange:f,className:F("not-prose",t),...c,children:l})})});Ql.displayName="Reasoning";const Yl=(t,s)=>t||s===0?e.jsx(_n,{children:"Thinking..."}):s===void 0?e.jsx("p",{children:"Thought for a few seconds"}):e.jsxs("p",{children:["Thought for ",s," seconds"]}),Zl=n.memo(({className:t,children:s,getThinkingMessage:r=Yl,...a})=>{const{isStreaming:o,isOpen:i,duration:l}=Hl();return e.jsx(In,{className:F("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",t),...a,children:s??e.jsxs(e.Fragment,{children:[e.jsx(fo,{className:"h-4 w-4"}),r(o,l),e.jsx(ns,{className:F("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Zl.displayName="ReasoningTrigger";const Xl=n.memo(({className:t,children:s,...r})=>e.jsx(Rn,{className:F("mt-4 text-sm text-muted-foreground",t),...r,children:s}));Xl.displayName="ReasoningContent";function ec(t){switch(t){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}}function He({children:t,content:s,position:r="top",className:a="",delay:o=350}){const[i,l]=n.useState(!1),c=n.useRef(null),m=n.useRef(!1),d=n.useRef(null),u=n.useRef(null),[x,h]=n.useState(null),p=n.useCallback(()=>{const k=d.current;if(!k)return;const y=k.getBoundingClientRect(),P=8,E={position:"fixed",zIndex:9999};switch(r){case"bottom":E.left=y.left+y.width/2,E.top=y.bottom+P,E.transform="translateX(-50%)";break;case"left":E.left=y.left-P,E.top=y.top+y.height/2,E.transform="translate(-100%, -50%)";break;case"right":E.left=y.right+P,E.top=y.top+y.height/2,E.transform="translateY(-50%)";break;default:E.left=y.left+y.width/2,E.top=y.top-P,E.transform="translate(-50%, -100%)";break}h(E)},[r]),f=()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},b=()=>{f(),c.current=window.setTimeout(()=>{l(!0)},o)},g=()=>{f(),l(!1)},v=()=>{f(),m.current=!1,c.current=window.setTimeout(()=>{m.current=!0,l(!0)},o)},S=()=>{f(),!m.current&&l(!1)};return n.useEffect(()=>()=>{f()},[]),n.useEffect(()=>{if(!i||typeof document>"u")return;const k=y=>{const P=y.target;P instanceof Node&&d.current?.contains(P)||(l(!1),m.current=!1)};return document.addEventListener("pointerdown",k,!0),()=>document.removeEventListener("pointerdown",k,!0)},[i]),n.useEffect(()=>{if(!i){h(null);return}const k=window.requestAnimationFrame(p),y=()=>p();return window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),()=>{window.cancelAnimationFrame(k),window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0)}},[i,p]),s?e.jsxs("div",{ref:d,className:"relative inline-block",onMouseEnter:b,onMouseLeave:g,onTouchStart:v,onTouchEnd:S,onTouchCancel:S,children:[t,i&&typeof document<"u"&&ys.createPortal(e.jsxs("div",{ref:u,style:x||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:F("px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",a),children:[s,e.jsx("div",{className:F("absolute w-0 h-0 border-4 border-transparent",ec(r))})]}),document.body)]}):e.jsx(e.Fragment,{children:t})}const Dn=n.createContext(null),tc=n.forwardRef(({className:t,status:s="ready",children:r,...a},o)=>{const i=n.useMemo(()=>({status:s}),[s]);return e.jsx(Dn.Provider,{value:i,children:e.jsx("form",{ref:o,"data-slot":"prompt-input",className:F("relative overflow-hidden rounded-xl border border-border/50 bg-card/80 shadow-sm backdrop-blur-sm transition-all duration-200 focus-within:border-primary/30 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/15",t),...a,children:r})})});tc.displayName="PromptInput";const sc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-header",className:F("px-3 pt-3",t),...s}));sc.displayName="PromptInputHeader";const rc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-body",className:F("relative",t),...s}));rc.displayName="PromptInputBody";const ac=n.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{ref:r,"data-slot":"prompt-input-textarea",className:F("chat-input-placeholder block max-h-[40vh] w-full resize-none overflow-y-auto bg-transparent px-4 py-2 text-sm leading-6 text-foreground placeholder-muted-foreground/50 focus:outline-none sm:max-h-[300px]",t),...s}));ac.displayName="PromptInputTextarea";const nc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-footer",className:F("flex items-center justify-between border-t border-border/30 px-3 py-2",t),...s}));nc.displayName="PromptInputFooter";const oc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"prompt-input-tools",className:F("flex items-center gap-1",t),...s}));oc.displayName="PromptInputTools";const ic=n.forwardRef(({className:t,tooltip:s,children:r,...a},o)=>{const i=e.jsx(W,{ref:o,type:"button",variant:"ghost",size:"icon",className:F("h-8 w-8 [&_svg]:size-4",t),...a,children:r});return s?e.jsx(He,{content:s.shortcut?e.jsxs("span",{className:"flex items-center gap-1.5",children:[s.content,e.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:s.shortcut})]}):s.content,position:s.side??"top",children:i}):i});ic.displayName="PromptInputButton";const lc=n.forwardRef(({className:t,status:s,children:r,...a},o)=>{const i=n.useContext(Dn),l=s??i?.status??"ready",c=l==="submitted"||l==="streaming";return e.jsx(W,{ref:o,type:c?"button":"submit",variant:"default",size:"icon",className:F("h-8 w-8 shrink-0 rounded-lg",t),...a,children:r??(c?e.jsx(bo,{className:"h-3.5 w-3.5 fill-current"}):e.jsx(yo,{className:"h-4 w-4"}))})});lc.displayName="PromptInputSubmit";function $n({children:t,className:s,...r}){return e.jsx("div",{className:F("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",s),...r,children:t})}function zn({isActive:t,onClick:s,children:r,className:a,...o}){return e.jsx("button",{type:"button",onClick:s,className:F("flex shrink-0 touch-manipulation items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium outline-none transition-all duration-150 focus-visible:ring-2 focus-visible:ring-primary/60 focus-visible:ring-offset-1 focus-visible:ring-offset-muted",t?"bg-background text-foreground shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:bg-background/50 hover:text-foreground active:bg-background/70",a),...o,children:r})}const Un=n.createContext(null);function Gn(){const t=n.useContext(Un);if(!t)throw new Error("QueueItem sub-components must be used within <QueueItem>");return t}const cc=n.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,"data-slot":"queue",role:"list",className:F("space-y-0.5",t),...s}));cc.displayName="Queue";const dc=n.forwardRef(({status:t="pending",className:s,children:r,...a},o)=>{const i=n.useMemo(()=>({status:t}),[t]);return e.jsx(Un.Provider,{value:i,children:e.jsx("div",{ref:o,"data-slot":"queue-item","data-status":t,role:"listitem",className:F("flex items-start gap-2 py-0.5",s),...a,children:r})})});dc.displayName="QueueItem";const uc=n.forwardRef(({className:t,...s},r)=>{const{status:a}=Gn();return e.jsxs("div",{ref:r,"data-slot":"queue-item-indicator","aria-hidden":"true",className:F("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",t),...s,children:[a==="completed"&&e.jsx("svg",{className:"h-3.5 w-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),a==="in_progress"&&e.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),a==="pending"&&e.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});uc.displayName="QueueItemIndicator";const mc=n.forwardRef(({className:t,children:s,...r},a)=>{const{status:o}=Gn();return e.jsx("div",{ref:a,"data-slot":"queue-item-content",className:F("min-w-0 flex-1 text-xs",o==="completed"&&"text-muted-foreground line-through",o==="in_progress"&&"font-medium text-foreground",o==="pending"&&"text-foreground",t),...r,children:s})});mc.displayName="QueueItemContent";const pc="https://github.com/CaineWind/wacli";function xc({updateAvailable:t,restartRequired:s,releaseInfo:r,latestVersion:a,currentVersion:o,onShowVersionModal:i,onShowSettings:l,t:c}){return e.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"px-2 py-1.5 md:px-2 md:py-1.5",children:e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-amber-300/60 bg-amber-50/80 px-2.5 py-2 dark:border-amber-700/40 dark:bg-amber-900/15",children:[e.jsx(Oe,{className:"h-4 w-4 flex-shrink-0 text-amber-500 dark:text-amber-400"}),e.jsx("span",{className:"min-w-0 flex-1 text-xs font-medium text-amber-700 dark:text-amber-300",children:c("version.restartRequired")})]})})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:e.jsxs("button",{className:"group flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-blue-50/80 dark:hover:bg-blue-900/15",onClick:i,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Ir,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-normal text-blue-600 dark:text-blue-300",children:r?.title||`v${a}`}),e.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:c("version.updateAvailable")})]})]})}),e.jsx("div",{className:"px-3 py-2 md:hidden",children:e.jsxs("button",{className:"flex h-11 w-full items-center gap-3 rounded-xl border border-blue-200/60 bg-blue-50/80 px-3.5 transition-all active:scale-[0.98] dark:border-blue-700/40 dark:bg-blue-900/15",onClick:i,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Ir,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"block truncate text-sm font-normal text-blue-600 dark:text-blue-300",children:r?.title||`v${a}`}),e.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:c("version.updateAvailable")})]})]})})]}),e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:e.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",onClick:l,children:[e.jsx(as,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:c("actions.settings")})]})}),!he&&e.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:e.jsxs("a",{href:pc,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["WindCli v",o," – ",c("branding.openSource")]})}),e.jsx("div",{className:"px-3 py-3 md:hidden",children:e.jsxs("button",{className:"flex h-10 w-full items-center gap-3 rounded-xl bg-muted/40 px-3.5 transition-all hover:bg-muted/60 active:scale-[0.98]",onClick:l,children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-background/80",children:e.jsx(as,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-normal text-foreground",children:c("actions.settings")})]})})]})}const Xr="WINDCLI_GITHUB_STARS",ea="WINDCLI_HIDE_GITHUB_STAR",hc=3600*1e3,gc=(t,s)=>{const[r,a]=n.useState(null),[o,i]=n.useState(()=>{try{return localStorage.getItem(ea)==="true"}catch{return!1}});n.useEffect(()=>{if(o)return;try{const d=localStorage.getItem(Xr);if(d){const u=JSON.parse(d);if(Date.now()-u.timestamp<hc){a(u.count);return}}}catch{}(async()=>{try{const d=await fetch(`https://api.github.com/repos/${t}/${s}`);if(!d.ok)return;const x=(await d.json()).stargazers_count;if(typeof x=="number"){a(x);try{localStorage.setItem(Xr,JSON.stringify({count:x,timestamp:Date.now()}))}catch{}}}catch{}})()},[t,s,o]);const l=n.useCallback(()=>{i(!0);try{localStorage.setItem(ea,"true")}catch{}},[]),c=r!==null?r>=1e3?`${(r/1e3).toFixed(1)}k`:`${r}`:null;return{starCount:r,formattedCount:c,isDismissed:o,dismiss:l}},fc="https://github.com/CaineWind/wacli";function bc({className:t}){return e.jsx("svg",{className:t,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})})}function yc(){const{formattedCount:t,isDismissed:s,dismiss:r}=gc("CaineWind","wacli");return he||s?null:e.jsxs("div",{className:"group/star relative hidden md:block",children:[e.jsxs("a",{href:fc,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[e.jsx(bc,{className:"h-3.5 w-3.5"}),e.jsx(os,{className:"h-3 w-3"}),e.jsx("span",{className:"font-normal",children:"Star"}),t&&e.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:t})]}),e.jsx("button",{onClick:a=>{a.preventDefault(),a.stopPropagation(),r()},className:"absolute -right-1.5 -top-1.5 hidden h-4 w-4 items-center justify-center rounded-full border border-border/50 bg-muted text-muted-foreground transition-colors hover:text-foreground group-hover/star:flex","aria-label":"Dismiss",children:e.jsx(ge,{className:"h-2.5 w-2.5"})})]})}const vc=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl";function jc({isPWA:t,isMobile:s,isLoading:r,projectsCount:a,runningSessionsCount:o,archivedSessionsCount:i,isArchivedSessionsLoading:l,searchFilter:c,onSearchFilterChange:m,onClearSearchFilter:d,searchMode:u,onSearchModeChange:x,onRefresh:h,isRefreshing:p,onCreateProject:f,onCollapseSidebar:b,t:g}){const v=(a>0||o>0||i>0||l)&&!r,S=u==="conversations"?g("search.conversationsPlaceholder"):u==="archived"?g("search.archivedPlaceholder","Search archived sessions..."):u==="running"?g("search.runningPlaceholder","Search running sessions..."):g("projects.searchPlaceholder"),k=o>99?"99+":String(o),y=()=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-primary/90 shadow-sm",children:e.jsx("svg",{className:"h-3.5 w-3.5 text-primary-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),e.jsx("h1",{className:"truncate text-sm font-bold tracking-tight text-foreground",style:{fontFamily:Qa},children:g("app.title")})]});return e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"hidden px-3 pb-2 pt-3 md:block",style:{},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[he?e.jsx("a",{href:"https://cloudcli.ai/dashboard",className:"flex min-w-0 items-center gap-2.5 transition-opacity hover:opacity-80",title:g("tooltips.viewEnvironments"),children:e.jsx(y,{})}):e.jsx(y,{}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:h,disabled:p,title:g("tooltips.refresh"),children:e.jsx(is,{className:`h-3.5 w-3.5 ${p?"animate-spin":""}`})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:f,title:g("tooltips.createProject"),children:e.jsx(Ee,{className:"h-3.5 w-3.5"})}),e.jsx(W,{variant:"ghost",size:"sm",className:"h-7 w-7 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:b,title:g("tooltips.hideSidebar"),children:e.jsx(vo,{className:"h-3.5 w-3.5"})})]})]}),e.jsx(yc,{}),v&&e.jsxs("div",{className:"mt-2.5 space-y-2",children:[e.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[e.jsxs("button",{onClick:()=>x("projects"),"aria-pressed":u==="projects",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ht,{className:"h-3 w-3"}),g("search.modeProjects")]}),e.jsxs("button",{onClick:()=>x("conversations"),"aria-pressed":u==="conversations",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ft,{className:"h-3 w-3"}),g("search.modeConversations")]}),e.jsx(He,{content:g("search.runningTooltip","Running sessions"),position:"top",children:e.jsx("button",{onClick:()=>x("running"),"aria-pressed":u==="running","aria-label":g("search.runningTooltip","Running sessions"),title:g("search.runningTooltip","Running sessions"),className:F("flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="running"?"bg-background shadow-sm text-foreground ring-1 ring-emerald-500/15":"text-muted-foreground hover:text-foreground"),children:e.jsxs("span",{className:"relative flex h-3 w-3 items-center justify-center",children:[e.jsx(Xe,{className:F("h-3 w-3",o>0&&"text-emerald-500")}),o>0&&e.jsx("span",{className:"absolute -right-2.5 -top-2 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-emerald-500 px-0.5 text-[8px] font-semibold leading-none text-white shadow-sm ring-1 ring-background",children:k})]})})}),e.jsx(He,{content:g("search.archiveOnlyTooltip","Archive only"),position:"top",children:e.jsx("button",{onClick:()=>x("archived"),"aria-pressed":u==="archived","aria-label":g("search.archiveOnlyTooltip","Archive only"),title:g("search.archiveOnlyTooltip","Archive only"),className:F("flex items-center justify-center rounded-md px-2.5 py-1.5 text-xs font-normal transition-all",u==="archived"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:e.jsx(ls,{className:"h-3 w-3"})})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(et,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),e.jsx(me,{type:"text",placeholder:S,value:c,onChange:P=>m(P.target.value),className:"nav-search-input h-9 rounded-xl border-0 pl-9 pr-14 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),c?e.jsx("button",{onClick:d,"aria-label":g("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-0.5 hover:bg-accent",children:e.jsx(ge,{className:"h-3 w-3 text-muted-foreground"})}):e.jsxs("kbd",{"aria-hidden":!0,title:g("tooltips.openCommandPalette"),className:"pointer-events-none absolute right-2.5 top-1/2 hidden -translate-y-1/2 items-center gap-0.5 rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground md:inline-flex",children:[vc,e.jsx("span",{children:"K"})]})]})]})]}),e.jsx("div",{className:"nav-divider hidden md:block"}),e.jsxs("div",{className:"p-3 pb-2 md:hidden",style:t&&s?{paddingTop:"16px"}:{},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[he?e.jsx("a",{href:"https://cloudcli.ai/dashboard",className:"flex min-w-0 items-center gap-2.5 transition-opacity active:opacity-70",title:g("tooltips.viewEnvironments"),children:e.jsx(y,{})}):e.jsx(y,{}),e.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-muted/50 transition-all active:scale-95",onClick:h,disabled:p,children:e.jsx(is,{className:`h-4 w-4 text-muted-foreground ${p?"animate-spin":""}`})}),e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/90 text-primary-foreground transition-all active:scale-95",onClick:f,children:e.jsx(xr,{className:"h-4 w-4"})})]})]}),v&&e.jsxs("div",{className:"mt-2.5 space-y-2",children:[e.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[e.jsxs("button",{onClick:()=>x("projects"),"aria-pressed":u==="projects",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ht,{className:"h-3 w-3"}),g("search.modeProjects")]}),e.jsxs("button",{onClick:()=>x("conversations"),"aria-pressed":u==="conversations",className:F("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(ft,{className:"h-3 w-3"}),g("search.modeConversations")]}),e.jsx(He,{content:g("search.runningTooltip","Running sessions"),position:"top",children:e.jsxs("button",{onClick:()=>x("running"),"aria-pressed":u==="running","aria-label":g("search.runningTooltip","Running sessions"),title:g("search.runningTooltip","Running sessions"),className:F("flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-normal transition-all",u==="running"?"bg-background shadow-sm text-foreground ring-1 ring-emerald-500/15":"text-muted-foreground hover:text-foreground"),children:[e.jsxs("span",{className:"relative flex h-3 w-3 items-center justify-center",children:[e.jsx(Xe,{className:F("h-3 w-3",o>0&&"text-emerald-500")}),o>0&&e.jsx("span",{className:"absolute -right-2.5 -top-2 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-emerald-500 px-0.5 text-[8px] font-semibold leading-none text-white shadow-sm ring-1 ring-background",children:k})]}),e.jsx("span",{className:"sr-only",children:g("search.modeRunning","Running")})]})}),e.jsx(He,{content:g("search.archiveOnlyTooltip","Archive only"),position:"top",children:e.jsx("button",{onClick:()=>x("archived"),"aria-pressed":u==="archived","aria-label":g("search.archiveOnlyTooltip","Archive only"),title:g("search.archiveOnlyTooltip","Archive only"),className:F("flex items-center justify-center rounded-md px-2.5 py-1.5 text-xs font-normal transition-all",u==="archived"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:e.jsx(ls,{className:"h-3 w-3"})})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(et,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),e.jsx(me,{type:"text",placeholder:S,value:c,onChange:P=>m(P.target.value),className:"nav-search-input h-10 rounded-xl border-0 pl-10 pr-9 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),c&&e.jsx("button",{onClick:d,"aria-label":g("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-1 hover:bg-accent",children:e.jsx(ge,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),e.jsx("div",{className:"nav-divider md:hidden"})]})}const ta="WindCli",wc=t=>t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session",Nc=(t,s)=>{if(s)return wc(s);const r=t?.displayName?.trim();return r?`${r} - ${ta}`:ta},sa={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},kc={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},Sc=t=>t==="fully-configured"?{icon:jo,colorClassName:"text-green-500 dark:text-green-400",backgroundClassName:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"}:t==="taskmaster-only"?{icon:as,colorClassName:"text-blue-500 dark:text-blue-400",backgroundClassName:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"}:t==="mcp-only"?{icon:Aa,colorClassName:"text-amber-500 dark:text-amber-400",backgroundClassName:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"}:{icon:ge,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function Cc({status:t="not-configured",size:s="sm",className:r="",showLabel:a=!1}){const o=Sc(t),i=o.icon;return a?e.jsxs("div",{className:F("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",o.backgroundClassName,o.colorClassName,r),title:o.title,children:[e.jsx(i,{className:sa[s]}),e.jsx("span",{className:"font-normal",children:o.label})]}):e.jsx("div",{className:F("inline-flex items-center justify-center rounded-full transition-colors",o.backgroundClassName,kc[s],r),title:o.title,children:e.jsx(i,{className:F(sa[s],o.colorClassName)})})}function Pc(t){if(!t||typeof document>"u")return!1;const s=document.createElement("textarea");s.value=t,s.setAttribute("readonly",""),s.style.position="fixed",s.style.opacity="0",s.style.pointerEvents="none",document.body.appendChild(s),s.focus(),s.select();let r=!1;try{r=document.execCommand("copy")}catch{r=!1}finally{document.body.removeChild(s)}return r}async function Cr(t){if(!t)return!1;let s=!1;try{typeof navigator<"u"&&navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(t),s=!0)}catch{s=!1}return s||(s=Pc(t)),s}const Ec={claude:"Claude",codex:"Codex",cursor:"Cursor",opencode:"OpenCode"};function Tc({project:t,session:s,selectedSession:r,isProcessing:a,needsAttention:o,currentTime:i,editingSession:l,editingSessionName:c,onEditingSessionNameChange:m,onStartEditingSession:d,onCancelEditingSession:u,onSaveEditingSession:x,onProjectSelect:h,onSessionSelect:p,onDeleteSession:f,t:b}){const g=Ri(s,i,b),v=r?.id===s.id,S=l===s.id,k=Rt(g.sessionTime,i),y=n.useRef(null),[P,E]=n.useState(!1),[C,T]=n.useState("idle"),[I,j]=n.useState(null),$=n.useRef(0),G=o&&!v,K=!G&&!a&&g.isActive,M=Ec[s.__provider];n.useEffect(()=>{if(!S||P)return;const te=q=>{const ye=y.current;ye&&!ye.contains(q.target)&&u()};return document.addEventListener("mousedown",te),()=>document.removeEventListener("mousedown",te)},[S,P,u]);const X=()=>{h(t),p(s,t.projectId)},H=()=>{x(t.projectId,s.id,c,s.__provider)},B=()=>{f(t.projectId,s.id,g.sessionName,s.__provider)},w=async()=>{const te=++$.current;T("loading");try{const q=await ue.providerSessionId(s.id),se=(await q.json())?.data?.sessionId;if(!q.ok||typeof se!="string"||!se)throw new Error("Provider session ID is unavailable");if(te!==$.current)return;j(se),T("idle")}catch{if(te!==$.current)return;j(null),T("error")}},D=()=>{$.current+=1,T("idle"),j(null)},L=te=>{te?(j(null),w()):D()},O=te=>{E(te),L(te),!te&&S&&u()},U=()=>{d(s.id,g.sessionName)},N=()=>{H(),O(!1)},A=async()=>{if(!I){T("error");return}T("copying");const te=await Cr(I);T(te?"copied":"error")},ee=()=>{C==="error"&&!I?w():A()},V=C==="loading"||C==="copying",ae=C==="copied"?Fe:La,de=C==="loading"?`Loading ${M} session ID…`:C==="copied"?`${M} session ID copied`:C==="error"?I?`Couldn't copy ${M} session ID`:`${M} session ID unavailable`:`Copy ${M} session ID`;return e.jsxs("div",{className:"group relative",children:[(G||K)&&e.jsx("div",{className:"absolute left-0 top-1/2 -translate-x-1 -translate-y-1/2 transform",children:e.jsx(He,{content:G?b("tooltips.attentionRequiredIndicator",{defaultValue:"Session needs attention"}):b("tooltips.activeSessionIndicator"),position:"right",children:e.jsx("div",{role:"status","aria-label":G?b("tooltips.attentionRequiredIndicator",{defaultValue:"Session needs attention"}):b("tooltips.activeSessionIndicator"),className:F("h-2 w-2 animate-pulse rounded-full",G?"bg-amber-500":"bg-green-500")})})}),e.jsxs("div",{className:"md:hidden",children:[e.jsx("div",{className:F("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",v?"bg-primary/5 border-primary/20":"",!v&&a?"border-border/60 bg-muted/20":!v&&g.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:X,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:F("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",v?"bg-primary/10":"bg-muted/50"),children:e.jsx(_e,{provider:s.__provider,className:"h-3 w-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground",title:g.sessionName,children:g.sessionName}),a?e.jsx("span",{className:"ml-auto flex-shrink-0",children:e.jsx(He,{content:b("tooltips.processingSessionIndicator","Processing session"),position:"top",children:e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground",children:e.jsx(ve,{className:"h-3 w-3 animate-spin"})})})}):k&&e.jsx("span",{className:"ml-auto flex-shrink-0 text-[11px] text-muted-foreground",children:k})]}),e.jsx("div",{className:"mt-0.5 flex items-center",children:g.messageCount>0&&e.jsx(Pe,{variant:"secondary",className:"px-1 py-0 text-xs",children:g.messageCount})})]}),e.jsx("button",{type:"button","aria-label":`Session options for ${g.sessionName}`,"aria-haspopup":"dialog","aria-expanded":P,className:"ml-1 flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted active:scale-95",onClick:te=>{te.stopPropagation(),O(!0)},children:e.jsx(Rr,{className:"h-4 w-4"})})]})}),e.jsx(Mn,{open:P,onOpenChange:O,children:e.jsxs(kr,{"aria-describedby":"mobile-session-options-description",wrapperClassName:"md:hidden",animationClassName:"animate-bottom-sheet-content-show motion-reduce:animate-none",className:"bottom-0 left-0 top-auto max-w-none translate-x-0 translate-y-0 rounded-b-none rounded-t-2xl border-x-0 border-b-0 px-4 pb-safe-area-inset-bottom pt-3",children:[e.jsx(Sr,{children:"Session options"}),e.jsx("div",{className:"mx-auto mb-4 h-1 w-10 rounded-full bg-muted-foreground/30","aria-hidden":"true"}),e.jsxs("div",{className:"mb-4 flex items-center gap-3 px-1",children:[e.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-muted",children:e.jsx(_e,{provider:s.__provider,className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:g.sessionName,children:g.sessionName}),e.jsxs("p",{id:"mobile-session-options-description",className:"text-xs text-muted-foreground",children:[M," session"]})]})]}),S?e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("label",{htmlFor:`mobile-session-rename-${s.id}`,className:"block px-1 text-xs font-medium text-muted-foreground",children:"Session name"}),e.jsx("input",{id:`mobile-session-rename-${s.id}`,type:"text",value:c,onChange:te=>m(te.target.value),onKeyDown:te=>{te.stopPropagation(),te.key==="Enter"&&N()},className:"w-full rounded-xl border-2 border-primary/40 bg-background px-3 py-3 text-foreground shadow-sm focus:border-primary focus:outline-none",autoFocus:!0,autoComplete:"off",style:{fontSize:"16px"}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:N,className:"flex min-h-12 flex-1 items-center justify-center gap-2 rounded-xl bg-primary px-4 py-3 text-sm font-medium text-primary-foreground transition-transform active:scale-95",children:[e.jsx(Fe,{className:"h-5 w-5 flex-shrink-0"}),"Save"]}),e.jsxs("button",{type:"button",onClick:u,className:"flex min-h-12 flex-1 items-center justify-center gap-2 rounded-xl border border-border bg-muted/35 px-4 py-3 text-sm font-medium text-foreground transition-colors active:bg-muted",children:[e.jsx(ge,{className:"h-5 w-5 flex-shrink-0"}),"Cancel"]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:U,className:"flex min-h-12 w-full items-center gap-3 rounded-xl border border-border bg-muted/35 px-4 py-3 text-left text-foreground transition-colors active:bg-muted",children:[e.jsx(Ar,{className:"h-5 w-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Rename session"})]}),e.jsxs("button",{type:"button",onClick:ee,disabled:V,className:F("flex min-h-12 w-full items-center gap-3 rounded-xl border px-4 py-3 text-left transition-colors",C==="copied"?"border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300":C==="error"?"border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300":"border-border bg-muted/35 text-foreground active:bg-muted"),children:[V?e.jsx(ve,{className:"h-5 w-5 flex-shrink-0 animate-spin"}):e.jsx(ae,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-sm font-medium",children:de}),C==="error"&&e.jsx("span",{className:"mt-0.5 block text-xs",children:"Tap to try again."})]})]}),!a&&e.jsxs("button",{type:"button",onClick:()=>{O(!1),B()},className:"flex min-h-12 w-full items-center gap-3 rounded-xl px-4 py-3 text-left text-red-600 transition-colors active:bg-red-500/10 dark:text-red-400",children:[e.jsx(Te,{className:"h-5 w-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Archive or delete session"})]})]}),!S&&e.jsx("button",{type:"button",onClick:()=>O(!1),className:"mb-3 mt-2 min-h-11 w-full rounded-xl text-sm font-medium text-muted-foreground transition-colors active:bg-muted",children:"Cancel"})]})})]}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx("a",{href:`/session/${s.id}`,className:F(Nn({variant:"ghost"}),"h-auto w-full justify-start rounded-md border bg-card p-2 pr-11 text-left font-normal transition-all duration-150",v?"border-primary/20 bg-primary/5":"border-border/30",!v&&a?"border-border/60 bg-muted/20 hover:bg-muted/25":!v&&g.isActive?"border-green-500/30 bg-green-50/5 hover:bg-green-50/10 dark:bg-green-900/5 dark:hover:bg-green-900/10":"hover:bg-accent/50"),onClick:te=>{te.metaKey||te.ctrlKey||te.shiftKey||te.altKey||(te.preventDefault(),p(s,t.projectId))},children:e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsx("div",{className:F("flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/50"),children:e.jsx(_e,{provider:s.__provider,className:"h-3 w-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground",title:g.sessionName,children:g.sessionName}),a?e.jsx("span",{className:F("ml-auto flex-shrink-0 transition-opacity duration-200",S?"opacity-0":"group-hover:opacity-0"),children:e.jsx(He,{content:b("tooltips.processingSessionIndicator","Processing session"),position:"top",children:e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground",children:e.jsx(ve,{className:"h-3 w-3 animate-spin"})})})}):k&&e.jsx("span",{className:F("ml-auto flex-shrink-0 text-[11px] text-muted-foreground transition-opacity duration-200",S?"opacity-0":"group-hover:opacity-0"),children:k})]}),e.jsx("div",{className:"mt-0.5 flex items-center",children:g.messageCount>0&&e.jsx(Pe,{variant:"secondary",className:"px-1 py-0 text-xs",children:g.messageCount})})]})]})}),e.jsx("div",{ref:y,className:"absolute right-2 top-1/2 flex -translate-y-1/2 transform items-center gap-1 opacity-100 transition-all duration-200",children:S?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:c,onChange:te=>m(te.target.value),onKeyDown:te=>{te.stopPropagation(),te.key==="Enter"?H():te.key==="Escape"&&u()},onClick:te=>te.stopPropagation(),className:"w-32 rounded border border-border bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40",onClick:te=>{te.stopPropagation(),H()},title:b("tooltips.save"),children:e.jsx(Fe,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40",onClick:te=>{te.stopPropagation(),u()},title:b("tooltips.cancel"),children:e.jsx(ge,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}):e.jsx(kn,{label:"Session options",ariaLabel:`Session options for ${g.sessionName}`,icon:Rr,iconOnly:!0,portal:!0,variant:"ghost",size:"icon",onOpenChange:L,triggerClassName:"h-7 w-7 text-muted-foreground opacity-70 hover:bg-muted hover:opacity-100",menuClassName:"w-[260px] rounded-xl p-1.5 shadow-xl",header:e.jsxs("div",{className:"mb-1 border-b border-border px-3 py-2",children:[e.jsx("p",{className:"truncate text-xs font-medium text-foreground",title:g.sessionName,children:g.sessionName}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:[M," session"]})]}),items:[{key:"rename",label:"Rename session",icon:Ar,onSelect:()=>d(s.id,g.sessionName)},{key:"copy",label:de,description:C==="error"?"Click to try again.":void 0,icon:ae,loading:V,closeOnSelect:!1,onSelect:ee},...a?[]:[{key:"delete",label:"Archive or delete session",icon:Te,isDanger:!0,showDividerBefore:!0,onSelect:B}]]})})]})]})}function Ic(){return e.jsx(e.Fragment,{children:Array.from({length:3}).map((t,s)=>e.jsx("div",{className:"rounded-md p-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+s*15}%`}}),e.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},s))})}function Rc({project:t,isExpanded:s,sessions:r,selectedSession:a,initialSessionsLoaded:o,hasMoreSessions:i,isLoadingMoreSessions:l,activeSessions:c,attentionSessionIds:m,currentTime:d,editingSession:u,editingSessionName:x,onEditingSessionNameChange:h,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:b,onProjectSelect:g,onSessionSelect:v,onDeleteSession:S,onLoadMoreSessions:k,onNewSession:y,t:P}){if(!s)return null;const E=r.length>0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[e.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:e.jsxs("button",{className:"flex h-8 w-full items-center justify-center gap-2 rounded-md bg-primary text-xs font-medium text-primary-foreground transition-all duration-150 hover:bg-primary/90 active:scale-[0.98]",onClick:()=>{g(t),y(t)},children:[e.jsx(Ee,{className:"h-3 w-3"}),P("sessions.newSession")]})}),e.jsxs(W,{variant:"default",size:"sm",className:"hidden h-8 w-full justify-start gap-2 bg-primary text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 md:flex",onClick:()=>y(t),children:[e.jsx(Ee,{className:"h-3 w-3"}),P("sessions.newSession")]}),o?E?e.jsxs(e.Fragment,{children:[r.map(C=>e.jsx(Tc,{project:t,session:C,selectedSession:a,isProcessing:c.has(C.id),needsAttention:m.has(C.id),currentTime:d,editingSession:u,editingSessionName:x,onEditingSessionNameChange:h,onStartEditingSession:p,onCancelEditingSession:f,onSaveEditingSession:b,onProjectSelect:g,onSessionSelect:v,onDeleteSession:S,t:P},C.id)),i&&e.jsx(W,{variant:"ghost",size:"sm",className:"h-8 w-full justify-center text-xs text-muted-foreground hover:text-foreground",onClick:()=>k(t.projectId),disabled:l,children:l?P("sessions.loadingSessions"):"Load more sessions"})]}):e.jsx("div",{className:"px-3 py-2 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:P("sessions.noSessions")})}):e.jsx(Ic,{})]})}const Ac=(t,s)=>{const r=Number(t.sessionMeta?.total??s.length);return String(r)};function Lc({project:t,selectedProject:s,selectedSession:r,isExpanded:a,isDeleting:o,isStarred:i,editingProject:l,editingName:c,sessions:m,initialSessionsLoaded:d,isLoadingMoreSessions:u,currentTime:x,editingSession:h,editingSessionName:p,tasksEnabled:f,mcpServerStatus:b,onEditingNameChange:g,onToggleProject:v,onProjectSelect:S,onToggleStarProject:k,onStartEditingProject:y,onCancelEditingProject:P,onSaveProjectName:E,onDeleteProject:C,onSessionSelect:T,onDeleteSession:I,onLoadMoreSessions:j,activeSessions:$,attentionSessionIds:G,onNewSession:K,onEditingSessionNameChange:M,onStartEditingSession:X,onCancelEditingSession:H,onSaveEditingSession:B,t:w}){const D=s?.projectId===t.projectId,L=l===t.projectId,O=Number(t.sessionMeta?.total??m.length),U=Ac(t,m),N=`${U} session${O===1?"":"s"}`,A=Mi(t,b),ee=n.useRef(null);n.useEffect(()=>{if(!L||!ee.current)return;let q=0;const ye=()=>{window.cancelAnimationFrame(q),q=window.requestAnimationFrame(()=>{ee.current?.scrollIntoView({block:"center",inline:"nearest"})})};return ye(),window.visualViewport?.addEventListener("resize",ye),()=>{window.cancelAnimationFrame(q),window.visualViewport?.removeEventListener("resize",ye)}},[L]);const V=()=>v(t.projectId),ae=()=>k(t.projectId),de=()=>{E(t.projectId)},te=()=>{s?.projectId!==t.projectId&&S(t),V()};return e.jsxs("div",{className:F("md:space-y-1",o&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"md:group group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:F("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",D&&"bg-primary/5 border-primary/20",i&&!D&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:V,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("button",{className:F("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",i?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:q=>{q.stopPropagation(),ae()},title:w(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(os,{className:F("w-4 h-4 transition-colors",i?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("div",{className:"min-w-0 flex-1",children:L?e.jsx("input",{ref:ee,type:"text",value:c,onChange:q=>g(q.target.value),className:"w-full rounded-lg border-2 border-primary/40 bg-background px-3 py-2 text-sm text-foreground shadow-sm transition-all duration-200 focus:border-primary focus:shadow-md focus:outline-none",placeholder:w("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:q=>q.stopPropagation(),onKeyDown:q=>{q.key==="Enter"&&de(),q.key==="Escape"&&P()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:[e.jsx("h3",{className:"truncate text-sm font-normal text-foreground",children:t.displayName}),f&&e.jsx(Cc,{status:A,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:L?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-green-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-green-600",onClick:q=>{q.stopPropagation(),de()},children:e.jsx(Fe,{className:"h-4 w-4 text-white"})}),e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-gray-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-gray-600",onClick:q=>{q.stopPropagation(),P()},children:e.jsx(ge,{className:"h-4 w-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-red-200 bg-red-500/10 active:scale-90 dark:border-red-800 dark:bg-red-900/30",onClick:q=>{q.stopPropagation(),C(t)},children:e.jsx(Te,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 active:scale-90 dark:border-primary/30 dark:bg-primary/20",onClick:q=>{q.stopPropagation(),y(t)},children:e.jsx(ar,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:a?e.jsx(ns,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(cs,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),e.jsxs(W,{variant:"ghost",className:F("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",D&&"bg-accent text-accent-foreground",i&&!D&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:te,children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:F("w-6 h-6 flex items-center justify-center rounded cursor-pointer transition-all duration-200",i?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20":"opacity-40 hover:opacity-100 hover:bg-accent"),onClick:q=>{q.stopPropagation(),ae()},title:w(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(os,{className:F("w-3 h-3 transition-colors",i?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:L?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:c,onChange:q=>g(q.target.value),className:"w-full rounded border border-border bg-background px-2 py-1 text-sm text-foreground focus:ring-2 focus:ring-primary/20",placeholder:w("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:q=>{q.key==="Enter"&&de(),q.key==="Escape"&&P()}}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",title:t.fullPath,children:t.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"truncate text-sm font-normal text-foreground",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[U,t.fullPath!==t.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:t.fullPath,children:[" - ",t.fullPath.length>25?`...${t.fullPath.slice(-22)}`:t.fullPath]})]})]})})]}),e.jsx("div",{className:"flex flex-shrink-0 items-center gap-1",children:L?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:q=>{q.stopPropagation(),de()},children:e.jsx(Fe,{className:"h-3 w-3"})}),e.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-gray-500 transition-colors hover:bg-gray-50 hover:text-gray-700 dark:hover:bg-gray-800",onClick:q=>{q.stopPropagation(),P()},children:e.jsx(ge,{className:"h-3 w-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"touch:opacity-100 flex h-6 w-6 cursor-pointer items-center justify-center rounded opacity-0 transition-all duration-200 hover:bg-accent group-hover:opacity-100",onClick:q=>{q.stopPropagation(),y(t)},title:w("tooltips.renameProject"),children:e.jsx(ar,{className:"h-3 w-3"})}),e.jsx("div",{className:"touch:opacity-100 flex h-6 w-6 cursor-pointer items-center justify-center rounded opacity-0 transition-all duration-200 hover:bg-red-50 group-hover:opacity-100 dark:hover:bg-red-900/20",onClick:q=>{q.stopPropagation(),C(t)},title:w("tooltips.deleteProject"),children:e.jsx(Te,{className:"h-3 w-3 text-red-600 dark:text-red-400"})}),a?e.jsx(ns,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):e.jsx(cs,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),e.jsx(Rc,{project:t,isExpanded:a,sessions:m,selectedSession:r,initialSessionsLoaded:d,hasMoreSessions:!!t.sessionMeta?.hasMore,isLoadingMoreSessions:u,activeSessions:$,attentionSessionIds:G,currentTime:x,editingSession:h,editingSessionName:p,onEditingSessionNameChange:M,onStartEditingSession:X,onCancelEditingSession:H,onSaveEditingSession:B,onProjectSelect:S,onSessionSelect:T,onDeleteSession:I,onLoadMoreSessions:j,onNewSession:K,t:w})]})}function Mc({isLoading:t,loadingProgress:s,projectsCount:r,filteredProjectsCount:a,t:o}){return t?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:o("projects.loadingProjects")}),s&&s.total>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${s.current/s.total*100}%`}})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.current,"/",s.total," ",o("projects.projects")]}),s.currentProject&&e.jsx("p",{className:"mx-auto max-w-[200px] truncate text-xs text-muted-foreground/70",title:s.currentProject,children:s.currentProject.split("-").slice(-2).join("/")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:o("projects.fetchingProjects")})]}):r===0?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx(ht,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:o("projects.noProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o("projects.runClaudeCli")})]}):a===0?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx(et,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:o("projects.noMatchingProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o("projects.tryDifferentSearch")})]}):null}function ra({projects:t,filteredProjects:s,selectedProject:r,selectedSession:a,isLoading:o,loadingProgress:i,expandedProjects:l,editingProject:c,editingName:m,initialSessionsLoaded:d,currentTime:u,editingSession:x,editingSessionName:h,deletingProjects:p,tasksEnabled:f,mcpServerStatus:b,getProjectSessions:g,onLoadMoreSessions:v,loadingMoreProjects:S,activeSessions:k,attentionSessionIds:y,forceExpanded:P=!1,isProjectStarred:E,onEditingNameChange:C,onToggleProject:T,onProjectSelect:I,onToggleStarProject:j,onStartEditingProject:$,onCancelEditingProject:G,onSaveProjectName:K,onDeleteProject:M,onSessionSelect:X,onDeleteSession:H,onNewSession:B,onEditingSessionNameChange:w,onStartEditingSession:D,onCancelEditingSession:L,onSaveEditingSession:O,t:U}){const N=Nc(r,a),A=e.jsx(Mc,{isLoading:o,loadingProgress:i,projectsCount:t.length,filteredProjectsCount:s.length,t:U});n.useEffect(()=>{document.title=N},[N]);const ee=!o&&t.length>0&&s.length>0;return e.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:ee?s.map(V=>e.jsx(Lc,{project:V,selectedProject:r,selectedSession:a,isExpanded:P||l.has(V.projectId),isDeleting:p.has(V.projectId),isStarred:E(V.projectId),editingProject:c,editingName:m,sessions:g(V),initialSessionsLoaded:d.has(V.projectId),isLoadingMoreSessions:S.has(V.projectId),currentTime:u,editingSession:x,editingSessionName:h,tasksEnabled:f,mcpServerStatus:b,onEditingNameChange:C,onToggleProject:T,onProjectSelect:I,onToggleStarProject:j,onStartEditingProject:$,onCancelEditingProject:G,onSaveProjectName:K,onDeleteProject:M,onSessionSelect:X,onDeleteSession:H,onLoadMoreSessions:v,activeSessions:k,attentionSessionIds:y,onNewSession:B,onEditingSessionNameChange:w,onStartEditingSession:D,onCancelEditingSession:L,onSaveEditingSession:O,t:U},V.projectId)):A})}function Fc(){return e.jsx("div",{className:"space-y-1 px-1","aria-label":"Loading recent conversations",children:Array.from({length:8}).map((t,s)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-2 py-2.5",children:[e.jsx("div",{className:"h-7 w-7 animate-pulse rounded-md bg-muted"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${72-s*3}%`}}),e.jsx("div",{className:"h-2.5 w-1/2 animate-pulse rounded bg-muted/70"})]})]},s))})}function _c({conversations:t,total:s,hasMore:r,isLoading:a,isLoadingMore:o,hasError:i,selectedSession:l,currentTime:c,onConversationSelect:m,onLoadMore:d,onRetry:u,t:x}){return a&&t.length===0?e.jsx(Fc,{}):i&&t.length===0?e.jsxs("div",{className:"px-4 py-10 text-center",children:[e.jsx(ft,{className:"mx-auto mb-3 h-6 w-6 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:x("recent.loadFailed","Could not load recent conversations")}),e.jsx(W,{variant:"ghost",size:"sm",className:"mt-2",onClick:u,children:x("buttons.retry",{ns:"common",defaultValue:"Try again"})})]}):t.length===0?e.jsxs("div",{className:"px-4 py-10 text-center",children:[e.jsx(ft,{className:"mx-auto mb-3 h-6 w-6 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:x("recent.emptyTitle","No conversations yet")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:x("recent.emptyDescription","Your most recently updated conversations will appear here.")})]}):e.jsxs("div",{className:"px-1","data-testid":"recent-conversations-list",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5 pt-0.5",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:x("recent.title","Recent conversations")}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:s})]}),e.jsx("div",{className:"space-y-0.5",children:t.map(h=>{const p=String(l?.id??"")===h.sessionId,f=Rt(h.lastActivity,c),b=g=>{g.button!==0||g.metaKey||g.ctrlKey||g.shiftKey||g.altKey||(g.preventDefault(),m(h.projectId,h.sessionId,h.provider))};return e.jsxs("a",{href:`/session/${h.sessionId}`,onClick:b,"data-testid":"recent-conversation-row",className:F("group flex min-w-0 items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",p?"bg-primary/10 text-foreground":"text-foreground hover:bg-accent/60"),children:[e.jsx("span",{className:F("flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md",p?"bg-primary/10":"bg-muted/60"),children:e.jsx(_e,{provider:h.provider,className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[13px] font-normal leading-4",children:h.sessionTitle}),e.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[10px] leading-3 text-muted-foreground",children:[e.jsx("span",{className:"truncate",children:h.projectDisplayName}),f&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-shrink-0 text-muted-foreground/40",children:"·"}),e.jsx("time",{className:"flex-shrink-0 tabular-nums",dateTime:h.lastActivity??void 0,children:f})]})]})]}),e.jsx(cs,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/40 transition-transform group-hover:translate-x-0.5 group-hover:text-muted-foreground"})]},h.sessionId)})}),r&&e.jsx(W,{variant:"ghost",size:"sm",className:"mt-1 h-8 w-full text-xs text-muted-foreground",onClick:d,disabled:o,children:o?x("recent.loadingMore","Loading more..."):x("recent.loadMore","Load older conversations")})]})}function Oc({snippet:t,highlights:s}){const r=[];let a=0;for(const o of s)o.start>a&&r.push(t.slice(a,o.start)),r.push(e.jsx("mark",{className:"rounded-sm bg-yellow-200 px-0.5 text-foreground dark:bg-yellow-800",children:t.slice(o.start,o.end)},o.start)),a=o.end;return a<t.length&&r.push(t.slice(a)),e.jsx("span",{className:"min-w-0 flex-1 break-words text-xs leading-relaxed text-muted-foreground",children:r})}function Dc(t){const s=new Map;for(const r of t){const a=r.projectId??r.projectPath??`session:${r.sessionId}`,o=s.get(a);if(o){o.sessions.push(r),(!o.latestActivity||r.lastActivity&&r.lastActivity>o.latestActivity)&&(o.latestActivity=r.lastActivity);continue}s.set(a,{key:a,projectId:r.projectId,projectDisplayName:r.projectDisplayName,projectPath:r.projectPath,isProjectArchived:r.isProjectArchived,sessions:[r],latestActivity:r.lastActivity})}return[...s.values()].sort((r,a)=>{const o=r.latestActivity??"";return(a.latestActivity??"").localeCompare(o)})}function $c({isPWA:t,isMobile:s,isLoading:r,projects:a,runningSessionsCount:o,archivedProjects:i,archivedSessions:l,archivedSessionsCount:c,isArchivedSessionsLoading:m,recentConversations:d,recentConversationsTotal:u,recentConversationsHasMore:x,isRecentConversationsLoading:h,isLoadingMoreRecentConversations:p,recentConversationsError:f,searchFilter:b,onSearchFilterChange:g,onClearSearchFilter:v,searchMode:S,onSearchModeChange:k,conversationResults:y,isSearching:P,searchProgress:E,onRestoreArchivedProject:C,onLoadMoreRecentConversations:T,onRetryRecentConversations:I,onArchivedSessionClick:j,onRestoreArchivedSession:$,onDeleteArchivedSession:G,onConversationResultClick:K,onRefresh:M,isRefreshing:X,onCreateProject:H,onCollapseSidebar:B,updateAvailable:w,restartRequired:D,releaseInfo:L,latestVersion:O,currentVersion:U,onShowVersionModal:N,onShowSettings:A,projectListProps:ee,t:V}){const ae=S==="conversations"&&b.trim().length>=2,de=!!(y&&(y.titleResults.length>0||y.results.length>0)),te=Dc(l),q=i.length+l.length,ye=s&&!!(ee.editingProject||ee.editingSession);return e.jsxs("div",{className:"flex h-full flex-col bg-background/80 backdrop-blur-sm md:w-72 md:select-none",style:{},children:[e.jsx(jc,{isPWA:t,isMobile:s,isLoading:r,projectsCount:a.length,runningSessionsCount:o,archivedSessionsCount:c,isArchivedSessionsLoading:m,searchFilter:b,onSearchFilterChange:g,onClearSearchFilter:v,searchMode:S,onSearchModeChange:k,onRefresh:M,isRefreshing:X,onCreateProject:H,onCollapseSidebar:B,t:V}),e.jsx(Fn,{className:"flex-1 overflow-y-auto overscroll-contain md:px-1.5 md:py-2",children:ae?P&&!y?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V("search.searching")}),E&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground/60",children:[V("search.projectsScanned",{count:E.scannedProjects}),"/",E.totalProjects]})]}):!P&&y&&!de?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:e.jsx(et,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:V("search.noResults")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:V("search.tryDifferentQuery")})]}):y&&(de||P)?e.jsxs("div",{className:"space-y-4 px-2","aria-live":"polite",children:[y.titleResults.length>0&&e.jsxs("section",{className:"space-y-1","aria-labelledby":"session-title-results-heading",children:[e.jsxs("div",{className:"flex items-center justify-between px-1 py-0.5",children:[e.jsx("h3",{id:"session-title-results-heading",className:"text-[11px] font-medium text-muted-foreground",children:V("search.sessionTitles","Session")}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:y.titleResults.length})]}),y.titleResults.map(se=>{const ne=Rt(se.lastActivity,ee.currentTime);return e.jsxs("button",{type:"button",className:"group flex w-full min-w-0 items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors hover:bg-accent/60",onClick:()=>K(se.projectId,se.sessionId,se.provider),children:[e.jsx("span",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-md bg-muted/60",children:e.jsx(_e,{provider:se.provider,className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[13px] font-normal leading-4 text-foreground",children:se.sessionTitle}),e.jsxs("span",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[10px] leading-3 text-muted-foreground",children:[e.jsx("span",{className:"truncate",children:se.projectDisplayName}),ne&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-shrink-0 text-muted-foreground/40",children:"·"}),e.jsx("time",{className:"flex-shrink-0 tabular-nums",dateTime:se.lastActivity??void 0,children:ne})]})]})]})]},`${se.provider}-${se.sessionId}`)})]}),(y.results.length>0||P)&&e.jsxs("section",{className:"space-y-3","aria-labelledby":"conversation-content-results-heading",children:[e.jsxs("div",{className:"flex items-center justify-between px-1 py-0.5",children:[e.jsx("h3",{id:"conversation-content-results-heading",className:"text-[11px] font-medium text-muted-foreground",children:V("search.conversationContents","Conversation contents")}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:V("search.matches",{count:y.totalMatches})})]}),P&&E&&e.jsxs("div",{className:"space-y-1.5 px-1",children:[e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[e.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-[1.5px] border-muted-foreground/40 border-t-primary"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/60",children:[E.scannedProjects,"/",E.totalProjects]})]}),e.jsx("div",{className:"h-0.5 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-primary/60 transition-all duration-300",style:{width:`${E.totalProjects>0?Math.round(E.scannedProjects/E.totalProjects*100):0}%`}})})]}),y.results.map(se=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1 py-1",children:[e.jsx(ht,{className:"h-3 w-3 flex-shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-xs font-normal text-foreground",children:se.projectDisplayName})]}),se.sessions.map(ne=>e.jsxs("button",{className:"w-full rounded-md px-2 py-2 text-left transition-colors hover:bg-accent/50",onClick:()=>K(se.projectId,ne.sessionId,ne.provider||ne.matches[0]?.provider||"claude",ne.matches[0]?.timestamp,ne.matches[0]?.snippet),children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[e.jsx(ft,{className:"h-3 w-3 flex-shrink-0 text-primary"}),e.jsx("span",{className:"truncate text-xs font-normal text-foreground",children:ne.sessionSummary}),ne.provider&&ne.provider!=="claude"&&e.jsx("span",{className:"flex-shrink-0 rounded bg-muted px-1 py-0.5 text-[9px] uppercase text-muted-foreground",children:ne.provider})]}),e.jsx("div",{className:"space-y-1 pl-4",children:ne.matches.map((re,Ie)=>e.jsxs("div",{className:"flex items-start gap-1",children:[e.jsx("span",{className:"mt-0.5 flex-shrink-0 text-[10px] font-normal uppercase text-muted-foreground/60",children:re.role==="user"?"U":"A"}),e.jsx(Oc,{snippet:re.snippet,highlights:re.highlights})]},Ie))})]},`${se.projectId??se.projectName}-${ne.sessionId}`))]},se.projectName))]})]}):null:S==="conversations"?e.jsx(_c,{conversations:d,total:u,hasMore:x,isLoading:h,isLoadingMore:p,hasError:f,selectedSession:ee.selectedSession,currentTime:ee.currentTime,onConversationSelect:K,onLoadMore:T,onRetry:I,t:V}):S==="running"?ee.filteredProjects.length===0?e.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg border border-border/70 bg-muted/50 md:mb-3",children:e.jsx(Xe,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:V("running.emptyTitle","No sessions running")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o>0?V("running.noMatchingSessions","No running sessions match this search."):V("running.emptyDescription","Active work will appear here while a provider is processing.")})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"mx-2 flex items-center justify-between rounded-lg border border-border/60 bg-card/50 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",children:e.jsx(Xe,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"truncate text-xs font-normal text-foreground",children:V("running.title","Running now")})]}),e.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-normal text-emerald-700 dark:text-emerald-300",children:o})]}),e.jsx(ra,{...ee})]}):S==="archived"?m?e.jsxs("div",{className:"space-y-2 px-2 py-1","aria-live":"polite","aria-busy":"true",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-muted/70",children:e.jsx("div",{className:"h-3.5 w-3.5 animate-spin rounded-full border-[1.5px] border-muted-foreground/40 border-t-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-medium text-foreground",children:V("archived.loadingTitle","Loading archive...")}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:V("archived.loadingDescription","Fetching hidden workspaces and sessions you can restore later.")})]})]}),[0,1].map(se=>e.jsx("div",{className:"animate-pulse rounded-xl border border-border/50 bg-card/40 p-3",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-muted"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx("div",{className:"h-3 w-2/3 rounded bg-muted"}),e.jsx("div",{className:"h-2.5 w-5/6 rounded bg-muted/70"})]})]})},se))]}):i.length===0&&te.length===0?e.jsx("div",{className:"px-3 py-8 text-center",children:e.jsxs("div",{className:"mx-auto max-w-[240px] rounded-2xl border border-dashed border-border/80 bg-muted/20 px-5 py-7",children:[e.jsx("div",{className:"mx-auto mb-3 flex h-10 w-10 items-center justify-center rounded-xl border border-border/70 bg-background shadow-sm",children:e.jsx(ls,{className:"h-[18px] w-[18px] text-muted-foreground"})}),e.jsx("h3",{className:"text-sm font-medium text-foreground",children:c>0?V("archived.noMatchingSessions","No matching archived items"):V("archived.emptyTitle","No archived items")}),e.jsx("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:c>0?V("archived.tryDifferentSearch","Try a different search term."):V("archived.emptyDescription","Archived workspaces and sessions will appear here when you hide them from the active list.")})]})}):e.jsxs("div",{className:"space-y-2.5 px-2 pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-1 pb-0.5 pt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground",children:e.jsx(ls,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs font-medium leading-none text-foreground",children:V("archived.title","Archive")}),e.jsx("p",{className:"mt-1 text-[10px] leading-none text-muted-foreground",children:V("archived.restoreHint","Restore items whenever you need them")})]})]}),e.jsx("span",{className:"rounded-full border border-border/60 bg-muted/40 px-2 py-0.5 text-[10px] tabular-nums text-muted-foreground",title:q!==c?`${q} of ${c}`:void 0,children:q!==c?`${q}/${c}`:c})]}),i.map(se=>{const ne=gs(se);return e.jsxs("section",{className:"group/archive overflow-hidden rounded-xl border border-border/70 bg-card/45 shadow-[0_1px_0_hsl(var(--border)/0.2)] transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-2.5",children:[e.jsx("span",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg border border-border/60 bg-muted/45 text-muted-foreground",children:e.jsx(ht,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("h3",{className:"truncate text-[13px] font-medium text-foreground",children:se.displayName}),ne.length>0&&e.jsx("span",{className:"flex-shrink-0 rounded-md bg-muted/60 px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground",children:ne.length})]}),e.jsx("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",title:se.fullPath,children:se.fullPath})]}),e.jsxs("button",{className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-lg border border-emerald-600/15 bg-emerald-500/10 px-2 text-[10px] font-medium text-emerald-700 transition-all hover:border-emerald-600/25 hover:bg-emerald-500/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/40 dark:text-emerald-300",onClick:()=>C(se.projectId),title:V("archived.restoreProject","Restore workspace"),"aria-label":`${V("archived.restoreProject","Restore workspace")}: ${se.displayName}`,children:[e.jsx(Lr,{className:"h-3 w-3"}),V("archived.restoreAction","Restore")]})]}),ne.length>0&&e.jsx("div",{className:"border-t border-border/45 bg-muted/[0.08]",children:ne.map(re=>e.jsxs("button",{className:"flex w-full items-center gap-2.5 border-b border-border/35 px-2.5 py-2 text-left transition-colors last:border-b-0 hover:bg-accent/35 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:()=>j({sessionId:String(re.id),provider:re.__provider,projectId:se.projectId,projectPath:se.fullPath,projectDisplayName:se.displayName,sessionTitle:typeof re.summary=="string"&&re.summary.trim().length>0?re.summary:typeof re.name=="string"&&re.name.trim().length>0?re.name:String(re.id),createdAt:typeof re.created_at=="string"?re.created_at:null,updatedAt:typeof re.updated_at=="string"?re.updated_at:null,lastActivity:typeof re.lastActivity=="string"?re.lastActivity:typeof re.updated_at=="string"?re.updated_at:typeof re.created_at=="string"?re.created_at:null,isProjectArchived:!0}),children:[e.jsx("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md bg-background/70",children:e.jsx(_e,{provider:re.__provider,className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-xs text-foreground",children:typeof re.summary=="string"&&re.summary.trim().length>0?re.summary:typeof re.name=="string"&&re.name.trim().length>0?re.name:String(re.id)}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] text-muted-foreground/70",children:[e.jsx("span",{className:"uppercase tracking-wide",children:re.__provider}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:Rt(typeof re.lastActivity=="string"?re.lastActivity:typeof re.updated_at=="string"?re.updated_at:typeof re.created_at=="string"?re.created_at:null,ee.currentTime)})]})]})]},String(re.id)))})]},se.projectId)}),te.map(se=>e.jsxs("section",{className:"group/archive overflow-hidden rounded-xl border border-border/70 bg-card/45 shadow-[0_1px_0_hsl(var(--border)/0.2)] transition-colors hover:border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-2.5",children:[e.jsx("span",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg border border-border/60 bg-muted/45 text-muted-foreground",children:e.jsx(ht,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("h3",{className:"truncate text-[13px] font-medium text-foreground",children:se.projectDisplayName}),e.jsx("span",{className:"flex-shrink-0 rounded-md bg-muted/60 px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground",children:se.sessions.length})]}),se.projectPath&&e.jsx("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",title:se.projectPath,children:se.projectPath})]})]}),e.jsx("div",{className:"border-t border-border/45 bg-muted/[0.08]",children:se.sessions.map(ne=>e.jsxs("div",{className:"group/session flex items-center gap-1 border-b border-border/35 px-2.5 py-2 last:border-b-0 hover:bg-accent/35",children:[e.jsxs("button",{className:"flex min-w-0 flex-1 items-center gap-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>j(ne),children:[e.jsx("span",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md bg-background/70",children:e.jsx(_e,{provider:ne.provider,className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-xs text-foreground",children:ne.sessionTitle}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-[10px] text-muted-foreground/70",children:[e.jsx("span",{className:"uppercase tracking-wide",children:ne.provider}),ne.lastActivity&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"tabular-nums",children:Rt(ne.lastActivity,ee.currentTime)})]})]})]})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[e.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-emerald-500/10 hover:text-emerald-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/40 dark:hover:text-emerald-300",onClick:()=>$(ne.sessionId),title:V("archived.restore","Restore session"),"aria-label":`${V("archived.restore","Restore session")}: ${ne.sessionTitle}`,children:e.jsx(Lr,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/60 transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/40",onClick:()=>G(ne),title:V("archived.deletePermanently","Delete permanently"),"aria-label":`${V("archived.deletePermanently","Delete permanently")}: ${ne.sessionTitle}`,children:e.jsx(Te,{className:"h-3.5 w-3.5"})})]})]},ne.sessionId))})]},se.key))]}):e.jsx(ra,{...ee})}),!ye&&e.jsx(xc,{updateAvailable:w,restartRequired:D,releaseInfo:L,latestVersion:O,currentVersion:U,onShowVersionModal:N,onShowSettings:A,t:V})]})}const aa=[{id:"agents",labelKey:"mainTabs.agents",icon:Ma},{id:"appearance",labelKey:"mainTabs.appearance",icon:Fa},{id:"git",labelKey:"mainTabs.git",icon:Ft},{id:"api",labelKey:"mainTabs.apiTokens",icon:hr},{id:"voice",labelKey:"mainTabs.voice",icon:wo},{id:"tasks",labelKey:"mainTabs.tasks",icon:_a},{id:"browser",labelKey:"mainTabs.browser",icon:Oa},{id:"plugins",labelKey:"mainTabs.plugins",icon:No},{id:"notifications",labelKey:"mainTabs.notifications",icon:gr},{id:"about",labelKey:"mainTabs.about",icon:Da}];function zc({activeTab:t,onChange:s}){const{t:r}=ce("settings");return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"hidden w-56 flex-shrink-0 border-r border-border bg-muted/30 md:flex md:flex-col",children:e.jsx("nav",{className:"flex flex-col gap-1 p-3",children:aa.map(a=>{const o=a.icon,i=t===a.id;return e.jsxs("button",{onClick:()=>s(a.id),className:F("flex items-center gap-3 rounded-lg px-3 py-2.5 text-left text-sm font-medium transition-colors duration-150",i?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground active:bg-accent/50"),children:[e.jsx(o,{className:"h-4 w-4 flex-shrink-0"}),r(a.labelKey)]},a.id)})})}),e.jsx("div",{className:"flex-shrink-0 border-b border-border px-3 py-2 md:hidden",children:e.jsx($n,{className:"scrollbar-hide w-full overflow-x-auto",children:aa.map(a=>{const o=a.icon;return e.jsxs(zn,{isActive:t===a.id,onClick:()=>s(a.id),className:"flex-shrink-0",children:[e.jsx(o,{className:"h-3.5 w-3.5"}),r(a.labelKey)]},a.id)})})})]})}const Pr={claude:"Claude",cursor:"Cursor",codex:"Codex",opencode:"OpenCode"},vs={claude:["user","project","local"],cursor:["user","project"],codex:["user","project"],opencode:["user","project"]},js={claude:["stdio","http","sse"],cursor:["stdio","http"],codex:["stdio","http"],opencode:["stdio","http"]},Uc=["user","project"],Vn=["stdio","http"],Gc={claude:"bg-primary text-primary-foreground hover:bg-primary/90",cursor:"bg-primary text-primary-foreground hover:bg-primary/90",codex:"bg-primary text-primary-foreground hover:bg-primary/90",opencode:"bg-primary text-primary-foreground hover:bg-primary/90"},Er={claude:!1,cursor:!1,codex:!0,opencode:!1},Vc={name:"",scope:"user",workspacePath:"",transport:"stdio",command:"",args:[],env:{},cwd:"",url:"",headers:{},envVars:[],bearerTokenEnvVar:"",envHttpHeaders:{},importMode:"form",jsonInput:""},Kn=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Be=t=>typeof t=="string"&&t.trim()?t.trim():void 0,na=t=>Array.isArray(t)?t.filter(s=>typeof s=="string"):void 0,Js=t=>{if(!Kn(t))return;const s={};return Object.entries(t).forEach(([r,a])=>{typeof a=="string"&&(s[r]=a)}),Object.keys(s).length>0?s:void 0},qs=t=>Object.entries(t).map(([s,r])=>`${s}=${r}`).join(`
|
|
3
3
|
`),Qs=t=>{const s={};return t.split(`
|
|
4
4
|
`).forEach(r=>{const[a,...o]=r.split("=");a?.trim()&&(s[a.trim()]=o.join("=").trim())}),s},oa=t=>t.split(`
|
|
5
5
|
`).map(s=>s.trim()).filter(Boolean),Kc=t=>{const s=String(t??"");return s.length<=4?"****":`${s.slice(0,2)}****${s.slice(-2)}`},Bc=t=>t==="user"||t==="local"||t==="project",Tr=t=>t==="stdio"||t==="http"||t==="sse",Bn=t=>t.fullPath||t.path||"",es=t=>t instanceof Error?t.message:"Unknown error",Wn=(t,s,r)=>{if(!(r?.supportedTransports??js[t]).includes(s))throw new Error(r?.unsupportedTransportMessage?.(s)??`${t} does not support ${s} MCP servers`)},Wc=(t,s,r)=>{const a=JSON.parse(s.jsonInput);if(!Kn(a))throw new Error("JSON configuration must be an object");const o=Be(a.transport)??Be(a.type),i=Tr(o)?o:void 0;if(!i)throw new Error("Missing required field: type");if(Wn(t,i,r),i==="stdio"&&!Be(a.command))throw new Error("stdio type requires a command field");if((i==="http"||i==="sse")&&!Be(a.url))throw new Error(`${i} type requires a url field`);return{name:s.name.trim(),scope:s.scope,workspacePath:s.scope==="user"?void 0:s.workspacePath,transport:i,command:Be(a.command),args:na(a.args)??[],env:Js(a.env)??{},cwd:r?.supportsWorkingDirectory??Er[t]?Be(a.cwd):void 0,url:Be(a.url),headers:Js(a.headers??a.http_headers)??{},envVars:r?.includeProviderSpecificFields??t==="codex"?na(a.envVars??a.env_vars)??[]:void 0,bearerTokenEnvVar:r?.includeProviderSpecificFields??t==="codex"?Be(a.bearerTokenEnvVar??a.bearer_token_env_var):void 0,envHttpHeaders:r?.includeProviderSpecificFields??t==="codex"?Js(a.envHttpHeaders??a.env_http_headers)??{}:void 0}},ia=(t,s,r)=>{if(s.importMode==="json")return Wc(t,s,r);Wn(t,s.transport,r);const a=r?.supportsWorkingDirectory??Er[t],o=r?.includeProviderSpecificFields??t==="codex";return{name:s.name.trim(),scope:s.scope,workspacePath:s.scope==="user"?void 0:s.workspacePath,transport:s.transport,command:s.transport==="stdio"?s.command.trim():void 0,args:s.transport==="stdio"?s.args:void 0,env:s.env,cwd:a&&s.cwd.trim()||void 0,url:s.transport!=="stdio"?s.url.trim():void 0,headers:s.transport!=="stdio"?s.headers:void 0,envVars:o?s.envVars:void 0,bearerTokenEnvVar:o&&s.bearerTokenEnvVar.trim()||void 0,envHttpHeaders:o?s.envHttpHeaders:void 0}},Hc=3e4,ct=new Map,ws=async t=>t.json(),Ns=(t,s)=>{if(!t||typeof t!="object")return s;const r=t,a=r.error;if(a&&typeof a=="object"){const i=a.message;if(typeof i=="string"&&i.trim())return i}if(typeof a=="string"&&a.trim())return a;const o=r.details;return typeof o=="string"&&o.trim()?o:s},Jc=(t,s="stdio")=>Tr(t)?t:s,qc=(t,s)=>Bc(t)?t:s,Qc=(t,s,r,a)=>{const o=Jc(r.transport,r.url?"http":"stdio");return{provider:t,name:String(r.name??""),scope:qc(r.scope,s),transport:o,command:r.command,args:r.args??[],env:r.env??{},cwd:r.cwd,url:r.url,headers:r.headers??{},envVars:r.envVars??[],bearerTokenEnvVar:r.bearerTokenEnvVar,envHttpHeaders:r.envHttpHeaders??{},workspacePath:a?.path||r.workspacePath,projectName:a?.name||r.projectName,projectDisplayName:a?.displayName||r.projectDisplayName}},Yc=t=>{const s=new Set;return t.reduce((r,a)=>{const o=Bn(a);return!o||s.has(o)||(s.add(o),r.push({name:a.projectId,displayName:a.displayName||a.projectId,path:o})),r},[])},la=async(t,s,r)=>{const a=new URLSearchParams({scope:s});r?.path&&a.set("workspacePath",r.path);const o=await z(`/api/providers/${t}/mcp/servers?${a.toString()}`),i=await ws(o);if(!o.ok||!i.success)throw new Error(Ns(i,`Failed to load ${t} MCP servers`));return(i.data.servers||[]).map(l=>Qc(t,s,l,r))},ca=async(t,s)=>{const r=new URLSearchParams({scope:s.scope});s.workspacePath&&r.set("workspacePath",s.workspacePath);const a=await z(`/api/providers/${t}/mcp/servers/${encodeURIComponent(s.name)}?${r.toString()}`,{method:"DELETE"}),o=await ws(a);if(!a.ok||!o.success)throw new Error(Ns(o,"Failed to delete MCP server"))},Zc=async(t,s)=>{const r=await z(`/api/providers/${t}/mcp/servers`,{method:"POST",body:JSON.stringify(s)}),a=await ws(r);if(!r.ok||!a.success)throw new Error(Ns(a,"Failed to save MCP server"))},Xc=async t=>{const s=await z("/api/providers/mcp/servers/global",{method:"POST",body:JSON.stringify(t)}),r=await ws(s);if(!s.ok||!r.success)throw new Error(Ns(r,"Failed to save MCP server to all providers"));return r.data.results||[]},ed=(t,s)=>t.name!==s.name||t.scope!==s.scope||(t.workspacePath||"")!==(s.workspacePath||""),da=t=>`${t.provider}:${t.scope}:${t.workspacePath||"global"}:${t.name}`,td=(t,s)=>{const r=s.map(a=>a.path).sort().join("|");return`${t}:${r}`},sd=t=>t.map(s=>`${Pr[s.provider]}: ${s.error||"Unknown error"}`).join("; "),ts=t=>{const s={user:0,project:1,local:2};return[...t].sort((r,a)=>{const o=s[r.scope]-s[a.scope];if(o!==0)return o;const i=(r.projectDisplayName||"").localeCompare(a.projectDisplayName||"");return i!==0?i:r.name.localeCompare(a.name)})},rd=(t,s)=>{const r=new Map;return t.forEach(a=>{r.set(da(a),a)}),s.forEach(a=>{r.set(da(a),a)}),ts([...r.values()])},ua=(t,s,r,a)=>{const o=t.filter(i=>i.scope!==r||(i.workspacePath||"")!==(a||""));return rd(o,s)};function ad({selectedProvider:t,currentProjects:s}){const[r,a]=n.useState([]),[o,i]=n.useState(!1),[l,c]=n.useState(null),[m,d]=n.useState(null),[u,x]=n.useState(null),[h,p]=n.useState(!1),[f,b]=n.useState(!1),[g,v]=n.useState(!1),[S,k]=n.useState(null),y=n.useRef(0),P=n.useMemo(()=>Yc(s),[s]),E=n.useMemo(()=>td(t,P),[P,t]),C=n.useCallback(async(X={})=>{const H=y.current+1;y.current=H;const B=ct.get(E);if(!X.force&&B&&Date.now()-B.updatedAt<Hc){a(B.servers),i(!1),p(!1),c(null);return}B&&!X.force?a(B.servers):a([]),i(!B),p(!1),c(null);const D=vs[t];let L=B&&!X.force?B.servers:[],O=null;if(D.includes("user"))try{const A=await la(t,"user");if(y.current!==H)return;L=ua(L,A,"user"),a(ts(L))}catch(A){O=es(A)}if(y.current!==H)return;i(!1);const U=[];if(P.forEach(A=>{D.includes("project")&&U.push({scope:"project",project:A}),D.includes("local")&&U.push({scope:"local",project:A})}),U.length===0){const A=ts(L);ct.set(E,{servers:A,updatedAt:Date.now()}),c(O);return}if(p(!0),await Promise.all(U.map(async({scope:A,project:ee})=>{try{const V=await la(t,A,ee);if(y.current!==H)return;L=ua(L,V,A,ee.path),a(L)}catch(V){O=O||es(V)}})),y.current!==H)return;const N=ts(L);ct.set(E,{servers:N,updatedAt:Date.now()}),a(N),c(O),p(!1)},[E,P,t]),T=n.useCallback(X=>{k(X||null),b(!0)},[]),I=n.useCallback(()=>{b(!1),k(null)},[]),j=n.useCallback(()=>{v(!0)},[]),$=n.useCallback(()=>{v(!1)},[]),G=n.useCallback(async(X,H)=>{const B=ia(t,X);if(B.scope!=="user"&&!B.workspacePath)throw new Error("Select a project for project-scoped MCP servers");await Zc(t,B),H&&ed(H,B)&&await ca(t,H),ct.delete(E),await C({force:!0}),x("success"),I()},[E,I,C,t]),K=n.useCallback(async X=>{const H=ia(t,X,{supportedTransports:Vn,supportsWorkingDirectory:!1,includeProviderSpecificFields:!1,unsupportedTransportMessage:D=>`Add MCP Server supports only stdio and http across all providers, not ${D}.`});if(H.scope==="local")throw new Error("Add MCP Server supports only user or project scope across all providers.");if(H.scope!=="user"&&!H.workspacePath)throw new Error("Select a project for project-scoped MCP servers");const B=await Xc(H);ct.clear(),await C({force:!0});const w=B.filter(D=>!D.created);if(w.length>0)throw x("error"),new Error(`Failed to add MCP server to all providers. ${sd(w)}`);x("success"),$()},[$,C,t]),M=n.useCallback(async X=>{if(window.confirm("Are you sure you want to delete this MCP server?")){d(null);try{await ca(t,X),ct.delete(E),await C({force:!0}),x("success")}catch(H){d(es(H)),x("error")}}},[E,C,t]);return n.useEffect(()=>{C()},[C]),n.useEffect(()=>{b(!1),v(!1),k(null),d(null),x(null)},[t]),n.useEffect(()=>{if(u===null)return;const X=window.setTimeout(()=>x(null),2e3);return()=>window.clearTimeout(X)},[u]),{servers:r,isLoading:o,isLoadingProjectScopes:h,loadError:l,deleteError:m,saveStatus:u,isFormOpen:f,isGlobalFormOpen:g,editingServer:S,openForm:T,openGlobalForm:j,closeForm:I,closeGlobalForm:$,submitForm:G,submitGlobalForm:K,deleteServer:M,refreshServers:C}}const ss=(t,s=vs[t],r=js[t])=>({...Vc,scope:s[0],transport:r[0],args:[],env:{},headers:{},envVars:[],envHttpHeaders:{}}),nd=(t,s,r,a)=>({...ss(t,r,a),name:s.name,scope:s.scope,workspacePath:s.workspacePath||"",transport:s.transport,command:s.command||"",args:s.args||[],env:s.env||{},cwd:s.cwd||"",url:s.url||"",headers:s.headers||{},envVars:s.envVars||[],bearerTokenEnvVar:s.bearerTokenEnvVar||"",envHttpHeaders:s.envHttpHeaders||{}}),Ys=t=>({args:t.args.join(`
|