upfynai-code 2.9.7 → 2.9.9
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/client/dist/assets/{AppContent-BXZDeSIC.js → AppContent-CapWOZnI.js} +3 -3
- package/client/dist/assets/{CanvasFullScreen-mnpCnLZ9.js → CanvasFullScreen-WOseUyrD.js} +1 -1
- package/client/dist/assets/{CanvasWorkspace-4CqmjAVQ.js → CanvasWorkspace-DksIgrfl.js} +1 -1
- package/client/dist/assets/{DashboardPanel-zFIFlw56.js → DashboardPanel-DmHbSyTP.js} +1 -1
- package/client/dist/assets/{FileTree-B0c_GaB3.js → FileTree-CbJF7m5P.js} +1 -1
- package/client/dist/assets/{GitPanel-DUP4zVU4.js → GitPanel-avzqm9Zj.js} +1 -1
- package/client/dist/assets/{LoginModal-BRycfsyD.js → LoginModal-Bk9mxZsi.js} +1 -1
- package/client/dist/assets/{Onboarding-BcnaZZ0o.js → Onboarding-CaiBrbYB.js} +1 -1
- package/client/dist/assets/{SetupForm-S0g6u5yT.js → SetupForm-DuIDpVGw.js} +1 -1
- package/client/dist/assets/{WorkflowsPanel-CouH9JDO.js → WorkflowsPanel-BOaVEpdu.js} +1 -1
- package/client/dist/assets/{index-CNDcVl2g.js → index-DtIQCXd6.js} +3 -3
- package/client/dist/index.html +1 -1
- package/package.json +5 -3
- package/server/cli.js +8 -2
- package/server/database/db.js +9 -1
- package/server/relay-client.js +11 -4
- package/server/routes/auth.js +7 -2
- package/server/utils/email.js +7 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MermaidBlock-BuBc_G-F.js","assets/vendor-syntax-DuHI9Ok6.js","assets/vendor-react-96lCPsRK.js","assets/vendor-markdown-CimbIo6Y.js","assets/vendor-diff-DNQpbhrT.js","assets/MarkdownPreview-DHmk3qzu.js","assets/FileTree-
|
|
2
|
-
import{r as l,j as e,R as it,i as Cr,g as Jn,h as Yn,u as hi}from"./vendor-react-96lCPsRK.js";import{a as hr,b as Be,c as ps,d as Me,e as Lr,l as Pa,f as pa,g as fr,u as Qn}from"./index-CNDcVl2g.js";import{S as Dt,b as Ut,c as $a,R as Vs,P as at,d as fi,e as Ar,X as Ve,F as Zr,f as xs,g as Pr,h as Ir,i as yt,j as Lt,k as bi,l as Pt,m as er,n as mr,o as _a,p as Mr,q as rr,W as Xn,G as br,K as xa,L as Sr,r as ga,E as sr,s as Zn,T as $t,t as vt,u as ha,v as Fa,w as yi,x as vi,y as fa,z as $r,A as qs,Z as tr,B as eo,D as Ks,H as Js,J as Ys,N as za,O as ki,Q as wi,U as ba,V as gs,Y as to,_ as es,$ as gt,a0 as ur,a as ji,a1 as ts,a2 as Ni,a3 as ro,a4 as ya,a5 as so,a6 as Qs,a7 as ao,a8 as Ci,a9 as Si,aa as Ei,ab as Ti,M as va,ac as Ai,ad as no,ae as Ii,af as oo,ag as io,ah as Mi,ai as Di,aj as Li,ak as Pi,al as $i,am as _i,an as Fi,ao as zi,ap as Ri,aq as Oi,ar as Bi,as as Wi}from"./vendor-icons-BaD0x9SL.js";import{C as Ui,a as Hi,b as Gi,u as We,L as Vi,S as lo}from"./LoginModal-BRycfsyD.js";import{h as co,p as uo,b as kt}from"./vendor-syntax-DuHI9Ok6.js";import{a as qi,b as Ki,c as Ji,M as Yi}from"./vendor-markdown-CimbIo6Y.js";import{F as mo,E as Wt,S as Qi,V as ka,c as pr,a as Xi,f as Zi,u as el,b as tl,T as Ra,l as rl,h as Oa,s as sl,d as al,e as nl,g as ol,i as Ds,j as il,R as po,o as xo,k as ll,m as go,n as cl,p as dl,q as ul,r as ml,t as pl,v as xl}from"./vendor-codemirror-CbtmxxaB.js";const Ba=t=>typeof window>"u"?!1:window.innerWidth<t,Wa=()=>{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 wa(t={}){const{mobileBreakpoint:r=768,trackMobile:s=!0,trackPWA:a=!0}=t,[n,o]=l.useState(()=>s?Ba(r):!1),[i,c]=l.useState(()=>a?Wa():!1);return l.useEffect(()=>{if(!s||typeof window>"u")return;const u=()=>{o(Ba(r))};return u(),window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}},[r,s]),l.useEffect(()=>{if(!a||typeof window>"u")return;const u=window.matchMedia("(display-mode: standalone)"),d=()=>{c(Wa())};return d(),typeof u.addEventListener=="function"?(u.addEventListener("change",d),()=>{u.removeEventListener("change",d)}):(u.addListener(d),()=>{u.removeListener(d)})},[a]),{isMobile:n,isPWA:i}}const Ua="2.9.1",Ha="upfyn-version-dismissed",gl=(t,r)=>{const s=t.split(".").map(Number),a=r.split(".").map(Number);for(let n=0;n<Math.max(s.length,a.length);n++){const o=s[n]||0,i=a[n]||0;if(o!==i)return o-i}return 0},ho=(t,r)=>{const[s,a]=l.useState(!1),[n,o]=l.useState(null),[i,c]=l.useState(null);l.useEffect(()=>{const d=async()=>{try{const h=await fetch("https://registry.npmjs.org/upfynai-code/latest");if(!h.ok)return;const p=await h.json();if(p.version){const g=p.version;if(o(g),localStorage.getItem(Ha)===g){a(!1);return}a(gl(g,Ua)>0),c({title:`v${g}`,body:"",htmlUrl:"https://www.npmjs.com/package/upfynai-code",publishedAt:null})}}catch{}};d();const m=setInterval(d,1800*1e3);return()=>clearInterval(m)},[t,r]);const u=l.useCallback(()=>{n&&localStorage.setItem(Ha,n),a(!1)},[n]);return{updateAvailable:s,latestVersion:n,currentVersion:Ua,releaseInfo:i,dismissUpdate:u}},Yt={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0},rs=Object.keys(Yt),hl=new Set(rs),Ls="ui-preferences:sync",ss=(t,r)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return r},fl=(t,r)=>{try{const s=localStorage.getItem(t);if(s===null)return r;const a=JSON.parse(s);return ss(a,r)}catch{return r}},bl=t=>{if(typeof window>"u")return Yt;try{const r=localStorage.getItem(t);if(r){const s=JSON.parse(r);if(s&&typeof s=="object"&&!Array.isArray(s)){const a=s;return rs.reduce((n,o)=>(n[o]=ss(a[o],Yt[o]),n),{...Yt})}}}catch{}return rs.reduce((r,s)=>(r[s]=fl(s,Yt[s]),r),{...Yt})};function yl(t,r){switch(r.type){case"set":{const{key:s,value:a}=r;if(!hl.has(s))return t;const n=ss(a,t[s]);return t[s]===n?t:{...t,[s]:n}}case"set_many":{const s=r.value||{};let a=!1;const n={...t};for(const o of rs){if(!(o in s))continue;const i=s[o],c=ss(i,t[o]);n[o]!==c&&(n[o]=c,a=!0)}return a?n:t}case"reset":return{...Yt,...r.value||{}};default:return t}}function ja(t="uiPreferences"){const r=l.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[s,a]=l.useReducer(yl,t,bl);return l.useEffect(()=>{typeof window>"u"||(localStorage.setItem(t,JSON.stringify(s)),window.dispatchEvent(new CustomEvent(Ls,{detail:{storageKey:t,sourceId:r.current,value:s}})))},[s,t]),l.useEffect(()=>{if(typeof window>"u")return;const c=m=>{!m||typeof m!="object"||Array.isArray(m)||a({type:"set_many",value:m})},u=m=>{if(!(m.key!==t||m.newValue===null))try{const h=JSON.parse(m.newValue);c(h)}catch{}},d=m=>{const p=m.detail;!p||p.storageKey!==t||p.sourceId===r.current||c(p.value)};return window.addEventListener("storage",u),window.addEventListener(Ls,d),()=>{window.removeEventListener("storage",u),window.removeEventListener(Ls,d)}},[t]),{preferences:s,setPreference:(c,u)=>{a({type:"set",key:c,value:u})},setPreferences:c=>{a({type:"set_many",value:c})},resetPreferences:c=>{a({type:"reset",value:c})},dispatch:a}}const vl=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},kl=()=>{try{const t=localStorage.getItem("starredProjects");return t?new Set(JSON.parse(t)):new Set}catch{return new Set}},wl=t=>{try{localStorage.setItem("starredProjects",JSON.stringify([...t]))}catch{}},as=t=>t.__provider==="cursor"?new Date(t.createdAt||0):t.__provider==="codex"?new Date(t.createdAt||t.lastActivity||0):new Date(t.lastActivity||0),jl=(t,r)=>t.__provider==="cursor"?t.name||r("projects.untitledSession"):t.__provider==="codex"?t.summary||t.name||r("projects.codexSession"):t.summary||r("projects.newSession"),Nl=t=>t.__provider==="cursor"?String(t.createdAt||""):t.__provider==="codex"?String(t.createdAt||t.lastActivity||""):String(t.lastActivity||""),Cl=(t,r,s)=>{const a=as(t),n=Math.floor((r.getTime()-a.getTime())/(1e3*60));return{isCursorSession:t.__provider==="cursor",isCodexSession:t.__provider==="codex",isActive:n<10,sessionName:jl(t,s),sessionTime:Nl(t),messageCount:Number(t.messageCount||0)}},fo=(t,r)=>{const s=[...t.sessions||[],...r[t.name]||[]].map(o=>({...o,__provider:"claude"})),a=(t.cursorSessions||[]).map(o=>({...o,__provider:"cursor"})),n=(t.codexSessions||[]).map(o=>({...o,__provider:"codex"}));return[...s,...a,...n].sort((o,i)=>as(i).getTime()-as(o).getTime())},Ga=(t,r)=>{const s=fo(t,r);return s.length===0?new Date(0):s.reduce((a,n)=>{const o=as(n);return o>a?o:a},new Date(0))},Sl=(t,r,s,a)=>{const n=[...t];return n.sort((o,i)=>{const c=s.has(o.name),u=s.has(i.name);return c&&!u?-1:!c&&u?1:r==="date"?Ga(i,a).getTime()-Ga(o,a).getTime():(o.displayName||o.name).localeCompare(i.displayName||i.name)}),n},El=(t,r)=>{const s=r.trim().toLowerCase();return s?t.filter(a=>{const n=(a.displayName||a.name).toLowerCase(),o=a.name.toLowerCase();return n.includes(s)||o.includes(s)}):t},Tl=(t,r)=>{var n;const s=!!((n=t.taskmaster)!=null&&n.hasTaskmaster),a=!!(r!=null&&r.hasMCPServer&&(r!=null&&r.isConfigured));return s&&a?"fully-configured":s?"taskmaster-only":a?"mcp-only":"not-configured"},Al=t=>{const r=typeof t.fullPath=="string"&&t.fullPath.length>0?t.fullPath:typeof t.path=="string"?t.path:"";return{name:t.name,displayName:typeof t.displayName=="string"&&t.displayName.trim().length>0?t.displayName:t.name,fullPath:r,path:typeof t.path=="string"&&t.path.length>0?t.path:r}};function Il({projects:t,selectedProject:r,selectedSession:s,isLoading:a,isMobile:n,t:o,onRefresh:i,onProjectSelect:c,onSessionSelect:u,onSessionDelete:d,onProjectDelete:m,setCurrentProject:h,setSidebarVisible:p,sidebarVisible:g}){const{addToast:f}=hr(),[x,b]=l.useState(new Set),[N,j]=l.useState(null),[y,k]=l.useState(!1),[I,D]=l.useState(""),[C,v]=l.useState({}),[E,T]=l.useState({}),[W,S]=l.useState(new Set),[O,H]=l.useState(new Date),[R,A]=l.useState("name"),[z,J]=l.useState(!1),[re,G]=l.useState({}),[ie,$]=l.useState(null),[Z,te]=l.useState(""),[Q,_]=l.useState(""),[F,q]=l.useState(new Set),[U,B]=l.useState(null),[ee,V]=l.useState(null),[w,M]=l.useState(!1),[Y,se]=l.useState(()=>kl()),de=!n&&!g;l.useEffect(()=>{const ae=setInterval(()=>{H(new Date)},6e4);return()=>clearInterval(ae)},[]),l.useEffect(()=>{T({}),S(new Set),G({})},[t]),l.useEffect(()=>{r&&b(ae=>{if(ae.has(r.name))return ae;const be=new Set(ae);return be.add(r.name),be})},[s,r]),l.useEffect(()=>{if(t.length>0&&!a){const ae=new Set;t.forEach(be=>{be.sessions&&be.sessions.length>=0&&ae.add(be.name)}),S(ae)}},[t,a]),l.useEffect(()=>{const ae=()=>{A(vl())};ae();const be=Ce=>{Ce.key==="claude-settings"&&ae()};window.addEventListener("storage",be);const ze=setInterval(()=>{document.hasFocus()&&ae()},1e3);return()=>{window.removeEventListener("storage",be),clearInterval(ze)}},[]);const je=l.useCallback(ae=>be=>{const ze=be.target;ze.closest(".overflow-y-auto")||ze.closest("[data-scroll-container]")||(be.preventDefault(),be.stopPropagation(),ae())},[]),ge=l.useCallback(ae=>{b(be=>{const ze=new Set;return be.has(ae)||ze.add(ae),ze})},[]),Re=l.useCallback((ae,be)=>{u({...ae,__projectName:be})},[u]),Ne=l.useCallback(ae=>{se(be=>{const ze=new Set(be);return ze.has(ae)?ze.delete(ae):ze.add(ae),wl(ze),ze})},[]),De=l.useCallback(ae=>Y.has(ae),[Y]),Ue=l.useCallback(ae=>fo(ae,E),[E]),_e=l.useMemo(()=>t.map(ae=>{const be=re[ae.name];return be===void 0?ae:{...ae,sessionMeta:{...ae.sessionMeta,hasMore:be}}}),[re,t]),L=l.useMemo(()=>Sl(_e,R,Y,E),[E,R,_e,Y]),K=l.useMemo(()=>El(L,Q),[Q,L]),pe=l.useCallback(ae=>{j(ae.name),D(ae.displayName)},[]),ye=l.useCallback(()=>{j(null),D("")},[]),Ie=l.useCallback(async ae=>{try{(await Be.renameProject(ae,I)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(be){console.error("Error renaming project:",be)}finally{j(null),D("")}},[I]),Fe=l.useCallback((ae,be,ze,Ce="claude")=>{V({projectName:ae,sessionId:be,sessionTitle:ze,provider:Ce})},[]),Se=l.useCallback(async()=>{if(!ee)return;const{projectName:ae,sessionId:be,provider:ze}=ee;V(null),d==null||d(be);try{const Ce=ze==="codex"?await Be.deleteCodexSession(be):await Be.deleteSession(ae,be);Ce.ok||console.error("[Sidebar] Failed to delete session:",Ce.status)}catch(Ce){console.error("[Sidebar] Error deleting session:",Ce)}},[d,ee,o]),Oe=l.useCallback(ae=>{B({project:ae,sessionCount:Ue(ae).length})},[Ue]),ne=l.useCallback(async()=>{if(!U)return;const{project:ae,sessionCount:be}=U,ze=be===0;B(null),q(Ce=>new Set([...Ce,ae.name]));try{const Ce=await Be.deleteProject(ae.name,!ze);if(Ce.ok)m==null||m(ae.name);else{const Ye=await Ce.json();f(Ye.error||o("messages.deleteProjectFailed"),"error")}}catch(Ce){console.error("Error deleting project:",Ce),f(o("messages.deleteProjectError"),"error")}finally{q(Ce=>{const Ye=new Set(Ce);return Ye.delete(ae.name),Ye})}},[U,m,o]),fe=l.useCallback(async ae=>{var Ce,Ye,lt;const be=re[ae.name];if(!(!(be!==void 0?be:((Ce=ae.sessionMeta)==null?void 0:Ce.hasMore)===!0)||C[ae.name])){v(dt=>({...dt,[ae.name]:!0}));try{const dt=(((Ye=ae.sessions)==null?void 0:Ye.length)||0)+(((lt=E[ae.name])==null?void 0:lt.length)||0),Tt=await Be.sessions(ae.name,5,dt);if(!Tt.ok)return;const At=await Tt.json();T(wt=>({...wt,[ae.name]:[...wt[ae.name]||[],...At.sessions||[]]})),At.hasMore===!1&&G(wt=>({...wt,[ae.name]:!1}))}catch(dt){console.error("Error loading more sessions:",dt)}finally{v(dt=>({...dt,[ae.name]:!1}))}}},[E,C,re]),Ee=l.useCallback(ae=>{c(ae),h(ae)},[c,h]),Le=l.useCallback(async()=>{J(!0);try{await i()}finally{J(!1)}},[i]),Pe=l.useCallback(async(ae,be,ze)=>{$(null),te("")},[]),Ae=l.useCallback(()=>{p(!1)},[p]),Ge=l.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:de,expandedProjects:x,editingProject:N,showNewProject:y,editingName:I,loadingSessions:C,additionalSessions:E,initialSessionsLoaded:W,currentTime:O,projectSortOrder:R,isRefreshing:z,editingSession:ie,editingSessionName:Z,searchFilter:Q,deletingProjects:F,deleteConfirmation:U,sessionDeleteConfirmation:ee,showVersionModal:w,starredProjects:Y,filteredProjects:K,handleTouchClick:je,toggleProject:ge,handleSessionClick:Re,toggleStarProject:Ne,isProjectStarred:De,getProjectSessions:Ue,startEditing:pe,cancelEditing:ye,saveProjectName:Ie,showDeleteSessionConfirmation:Fe,confirmDeleteSession:Se,requestProjectDelete:Oe,confirmDeleteProject:ne,loadMoreSessions:fe,handleProjectSelect:Ee,refreshProjects:Le,updateSessionSummary:Pe,collapseSidebar:Ae,expandSidebar:Ge,setShowNewProject:k,setEditingName:D,setEditingSession:$,setEditingSessionName:te,setSearchFilter:_,setDeleteConfirmation:B,setSessionDeleteConfirmation:V,setShowVersionModal:M}}function Ml({onExpand:t,onShowSettings:r,updateAvailable:s,onShowVersionModal:a,t:n}){return e.jsxs("div",{className:"h-full flex flex-col items-center py-3 gap-1 bg-background/80 backdrop-blur-sm w-12",children:[e.jsx("button",{onClick:t,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("common:versionUpdate.ariaLabels.showSidebar"),title:n("common:versionUpdate.ariaLabels.showSidebar"),children:e.jsx("img",{src:"/favicon.svg",alt:"",className:"w-6 h-6 rounded"})}),e.jsx("div",{className:"nav-divider w-6 my-1"}),e.jsx("button",{onClick:r,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("actions.settings"),title:n("actions.settings"),children:e.jsx(Dt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),s&&e.jsxs("button",{onClick:a,className:"relative w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors","aria-label":n("common:versionUpdate.ariaLabels.updateAvailable"),title:n("common:versionUpdate.ariaLabels.updateAvailable"),children:[e.jsx(Ut,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]})]})}function bo(t){var r,s,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(r=0;r<n;r++)t[r]&&(s=bo(t[r]))&&(a&&(a+=" "),a+=s)}else for(s in t)t[s]&&(a&&(a+=" "),a+=s);return a}function yo(){for(var t,r,s=0,a="",n=arguments.length;s<n;s++)(t=arguments[s])&&(r=bo(t))&&(a&&(a+=" "),a+=r);return a}const Dl=(t,r)=>{const s=new Array(t.length+r.length);for(let a=0;a<t.length;a++)s[a]=t[a];for(let a=0;a<r.length;a++)s[t.length+a]=r[a];return s},Ll=(t,r)=>({classGroupId:t,validator:r}),vo=(t=new Map,r=null,s)=>({nextPart:t,validators:r,classGroupId:s}),ns="-",Va=[],Pl="arbitrary..",$l=t=>{const r=Fl(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return _l(i);const c=i.split(ns),u=c[0]===""&&c.length>1?1:0;return ko(c,u,r)},getConflictingClassGroupIds:(i,c)=>{if(c){const u=a[i],d=s[i];return u?d?Dl(d,u):u:d||Va}return s[i]||Va}}},ko=(t,r,s)=>{if(t.length-r===0)return s.classGroupId;const n=t[r],o=s.nextPart.get(n);if(o){const d=ko(t,r+1,o);if(d)return d}const i=s.validators;if(i===null)return;const c=r===0?t.join(ns):t.slice(r).join(ns),u=i.length;for(let d=0;d<u;d++){const m=i[d];if(m.validator(c))return m.classGroupId}},_l=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=t.slice(1,-1),s=r.indexOf(":"),a=r.slice(0,s);return a?Pl+a:void 0})(),Fl=t=>{const{theme:r,classGroups:s}=t;return zl(s,r)},zl=(t,r)=>{const s=vo();for(const a in t){const n=t[a];Na(n,s,a,r)}return s},Na=(t,r,s,a)=>{const n=t.length;for(let o=0;o<n;o++){const i=t[o];Rl(i,r,s,a)}},Rl=(t,r,s,a)=>{if(typeof t=="string"){Ol(t,r,s);return}if(typeof t=="function"){Bl(t,r,s,a);return}Wl(t,r,s,a)},Ol=(t,r,s)=>{const a=t===""?r:wo(r,t);a.classGroupId=s},Bl=(t,r,s,a)=>{if(Ul(t)){Na(t(a),r,s,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Ll(s,t))},Wl=(t,r,s,a)=>{const n=Object.entries(t),o=n.length;for(let i=0;i<o;i++){const[c,u]=n[i];Na(u,wo(r,c),s,a)}},wo=(t,r)=>{let s=t;const a=r.split(ns),n=a.length;for(let o=0;o<n;o++){const i=a[o];let c=s.nextPart.get(i);c||(c=vo(),s.nextPart.set(i,c)),s=c}return s},Ul=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,Hl=t=>{if(t<1)return{get:()=>{},set:()=>{}};let r=0,s=Object.create(null),a=Object.create(null);const n=(o,i)=>{s[o]=i,r++,r>t&&(r=0,a=s,s=Object.create(null))};return{get(o){let i=s[o];if(i!==void 0)return i;if((i=a[o])!==void 0)return n(o,i),i},set(o,i){o in s?s[o]=i:n(o,i)}}},Xs="!",qa=":",Gl=[],Ka=(t,r,s,a,n)=>({modifiers:t,hasImportantModifier:r,baseClassName:s,maybePostfixModifierPosition:a,isExternal:n}),Vl=t=>{const{prefix:r,experimentalParseClassName:s}=t;let a=n=>{const o=[];let i=0,c=0,u=0,d;const m=n.length;for(let x=0;x<m;x++){const b=n[x];if(i===0&&c===0){if(b===qa){o.push(n.slice(u,x)),u=x+1;continue}if(b==="/"){d=x;continue}}b==="["?i++:b==="]"?i--:b==="("?c++:b===")"&&c--}const h=o.length===0?n:n.slice(u);let p=h,g=!1;h.endsWith(Xs)?(p=h.slice(0,-1),g=!0):h.startsWith(Xs)&&(p=h.slice(1),g=!0);const f=d&&d>u?d-u:void 0;return Ka(o,g,p,f)};if(r){const n=r+qa,o=a;a=i=>i.startsWith(n)?o(i.slice(n.length)):Ka(Gl,!1,i,void 0,!0)}if(s){const n=a;a=o=>s({className:o,parseClassName:n})}return a},ql=t=>{const r=new Map;return t.orderSensitiveModifiers.forEach((s,a)=>{r.set(s,1e6+a)}),s=>{const a=[];let n=[];for(let o=0;o<s.length;o++){const i=s[o],c=i[0]==="[",u=r.has(i);c||u?(n.length>0&&(n.sort(),a.push(...n),n=[]),a.push(i)):n.push(i)}return n.length>0&&(n.sort(),a.push(...n)),a}},Kl=t=>({cache:Hl(t.cacheSize),parseClassName:Vl(t),sortModifiers:ql(t),...$l(t)}),Jl=/\s+/,Yl=(t,r)=>{const{parseClassName:s,getClassGroupId:a,getConflictingClassGroupIds:n,sortModifiers:o}=r,i=[],c=t.trim().split(Jl);let u="";for(let d=c.length-1;d>=0;d-=1){const m=c[d],{isExternal:h,modifiers:p,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:x}=s(m);if(h){u=m+(u.length>0?" "+u:u);continue}let b=!!x,N=a(b?f.substring(0,x):f);if(!N){if(!b){u=m+(u.length>0?" "+u:u);continue}if(N=a(f),!N){u=m+(u.length>0?" "+u:u);continue}b=!1}const j=p.length===0?"":p.length===1?p[0]:o(p).join(":"),y=g?j+Xs:j,k=y+N;if(i.indexOf(k)>-1)continue;i.push(k);const I=n(N,b);for(let D=0;D<I.length;++D){const C=I[D];i.push(y+C)}u=m+(u.length>0?" "+u:u)}return u},Ql=(...t)=>{let r=0,s,a,n="";for(;r<t.length;)(s=t[r++])&&(a=jo(s))&&(n&&(n+=" "),n+=a);return n},jo=t=>{if(typeof t=="string")return t;let r,s="";for(let a=0;a<t.length;a++)t[a]&&(r=jo(t[a]))&&(s&&(s+=" "),s+=r);return s},Xl=(t,...r)=>{let s,a,n,o;const i=u=>{const d=r.reduce((m,h)=>h(m),t());return s=Kl(d),a=s.cache.get,n=s.cache.set,o=c,c(u)},c=u=>{const d=a(u);if(d)return d;const m=Yl(u,s);return n(u,m),m};return o=i,(...u)=>o(Ql(...u))},Zl=[],rt=t=>{const r=s=>s[t]||Zl;return r.isThemeGetter=!0,r},No=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Co=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ec=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,tc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,rc=/\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$/,sc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ac=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,nc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Rt=t=>ec.test(t),$e=t=>!!t&&!Number.isNaN(Number(t)),Ot=t=>!!t&&Number.isInteger(Number(t)),Ps=t=>t.endsWith("%")&&$e(t.slice(0,-1)),Mt=t=>tc.test(t),So=()=>!0,oc=t=>rc.test(t)&&!sc.test(t),Ca=()=>!1,ic=t=>ac.test(t),lc=t=>nc.test(t),cc=t=>!me(t)&&!xe(t),dc=t=>Ht(t,Ao,Ca),me=t=>No.test(t),Jt=t=>Ht(t,Io,oc),Ja=t=>Ht(t,bc,$e),uc=t=>Ht(t,Do,So),mc=t=>Ht(t,Mo,Ca),Ya=t=>Ht(t,Eo,Ca),pc=t=>Ht(t,To,lc),Hr=t=>Ht(t,Lo,ic),xe=t=>Co.test(t),kr=t=>ar(t,Io),xc=t=>ar(t,Mo),Qa=t=>ar(t,Eo),gc=t=>ar(t,Ao),hc=t=>ar(t,To),Gr=t=>ar(t,Lo,!0),fc=t=>ar(t,Do,!0),Ht=(t,r,s)=>{const a=No.exec(t);return a?a[1]?r(a[1]):s(a[2]):!1},ar=(t,r,s=!1)=>{const a=Co.exec(t);return a?a[1]?r(a[1]):s:!1},Eo=t=>t==="position"||t==="percentage",To=t=>t==="image"||t==="url",Ao=t=>t==="length"||t==="size"||t==="bg-size",Io=t=>t==="length",bc=t=>t==="number",Mo=t=>t==="family-name",Do=t=>t==="number"||t==="weight",Lo=t=>t==="shadow",yc=()=>{const t=rt("color"),r=rt("font"),s=rt("text"),a=rt("font-weight"),n=rt("tracking"),o=rt("leading"),i=rt("breakpoint"),c=rt("container"),u=rt("spacing"),d=rt("radius"),m=rt("shadow"),h=rt("inset-shadow"),p=rt("text-shadow"),g=rt("drop-shadow"),f=rt("blur"),x=rt("perspective"),b=rt("aspect"),N=rt("ease"),j=rt("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],I=()=>[...k(),xe,me],D=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],v=()=>[xe,me,u],E=()=>[Rt,"full","auto",...v()],T=()=>[Ot,"none","subgrid",xe,me],W=()=>["auto",{span:["full",Ot,xe,me]},Ot,xe,me],S=()=>[Ot,"auto",xe,me],O=()=>["auto","min","max","fr",xe,me],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R=()=>["start","end","center","stretch","center-safe","end-safe"],A=()=>["auto",...v()],z=()=>[Rt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],J=()=>[Rt,"screen","full","dvw","lvw","svw","min","max","fit",...v()],re=()=>[Rt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],G=()=>[t,xe,me],ie=()=>[...k(),Qa,Ya,{position:[xe,me]}],$=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",gc,dc,{size:[xe,me]}],te=()=>[Ps,kr,Jt],Q=()=>["","none","full",d,xe,me],_=()=>["",$e,kr,Jt],F=()=>["solid","dashed","dotted","double"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[$e,Ps,Qa,Ya],B=()=>["","none",f,xe,me],ee=()=>["none",$e,xe,me],V=()=>["none",$e,xe,me],w=()=>[$e,xe,me],M=()=>[Rt,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Mt],breakpoint:[Mt],color:[So],container:[Mt],"drop-shadow":[Mt],ease:["in","out","in-out"],font:[cc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Mt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Mt],shadow:[Mt],spacing:["px",$e],text:[Mt],"text-shadow":[Mt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Rt,me,xe,b]}],container:["container"],columns:[{columns:[$e,me,xe,c]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"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:I()}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{"inset-s":E(),start:E()}],end:[{"inset-e":E(),end:E()}],"inset-bs":[{"inset-bs":E()}],"inset-be":[{"inset-be":E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[Ot,"auto",xe,me]}],basis:[{basis:[Rt,"full","auto",c,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[$e,Rt,"auto","initial","none",me]}],grow:[{grow:["",$e,xe,me]}],shrink:[{shrink:["",$e,xe,me]}],order:[{order:[Ot,"first","last","none",xe,me]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[...R(),"normal"]}],"justify-self":[{"justify-self":["auto",...R()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[...R(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[...R(),"baseline"]}],"place-self":[{"place-self":["auto",...R()]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:A()}],mx:[{mx:A()}],my:[{my:A()}],ms:[{ms:A()}],me:[{me:A()}],mbs:[{mbs:A()}],mbe:[{mbe:A()}],mt:[{mt:A()}],mr:[{mr:A()}],mb:[{mb:A()}],ml:[{ml:A()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],"inline-size":[{inline:["auto",...J()]}],"min-inline-size":[{"min-inline":["auto",...J()]}],"max-inline-size":[{"max-inline":["none",...J()]}],"block-size":[{block:["auto",...re()]}],"min-block-size":[{"min-block":["auto",...re()]}],"max-block-size":[{"max-block":["none",...re()]}],w:[{w:[c,"screen",...z()]}],"min-w":[{"min-w":[c,"screen","none",...z()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",s,kr,Jt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,fc,uc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ps,me]}],"font-family":[{font:[xc,mc,r]}],"font-features":[{"font-features":[me]}],"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:[n,xe,me]}],"line-clamp":[{"line-clamp":[$e,"none",xe,Ja]}],leading:[{leading:[o,...v()]}],"list-image":[{"list-image":["none",xe,me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",xe,me]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:G()}],"text-color":[{text:G()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...F(),"wavy"]}],"text-decoration-thickness":[{decoration:[$e,"from-font","auto",xe,Jt]}],"text-decoration-color":[{decoration:G()}],"underline-offset":[{"underline-offset":[$e,"auto",xe,me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",xe,me]}],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",xe,me]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:$()}],"bg-size":[{bg:Z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ot,xe,me],radial:["",xe,me],conic:[Ot,xe,me]},hc,pc]}],"bg-color":[{bg:G()}],"gradient-from-pos":[{from:te()}],"gradient-via-pos":[{via:te()}],"gradient-to-pos":[{to:te()}],"gradient-from":[{from:G()}],"gradient-via":[{via:G()}],"gradient-to":[{to:G()}],rounded:[{rounded:Q()}],"rounded-s":[{"rounded-s":Q()}],"rounded-e":[{"rounded-e":Q()}],"rounded-t":[{"rounded-t":Q()}],"rounded-r":[{"rounded-r":Q()}],"rounded-b":[{"rounded-b":Q()}],"rounded-l":[{"rounded-l":Q()}],"rounded-ss":[{"rounded-ss":Q()}],"rounded-se":[{"rounded-se":Q()}],"rounded-ee":[{"rounded-ee":Q()}],"rounded-es":[{"rounded-es":Q()}],"rounded-tl":[{"rounded-tl":Q()}],"rounded-tr":[{"rounded-tr":Q()}],"rounded-br":[{"rounded-br":Q()}],"rounded-bl":[{"rounded-bl":Q()}],"border-w":[{border:_()}],"border-w-x":[{"border-x":_()}],"border-w-y":[{"border-y":_()}],"border-w-s":[{"border-s":_()}],"border-w-e":[{"border-e":_()}],"border-w-bs":[{"border-bs":_()}],"border-w-be":[{"border-be":_()}],"border-w-t":[{"border-t":_()}],"border-w-r":[{"border-r":_()}],"border-w-b":[{"border-b":_()}],"border-w-l":[{"border-l":_()}],"divide-x":[{"divide-x":_()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":_()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...F(),"hidden","none"]}],"divide-style":[{divide:[...F(),"hidden","none"]}],"border-color":[{border:G()}],"border-color-x":[{"border-x":G()}],"border-color-y":[{"border-y":G()}],"border-color-s":[{"border-s":G()}],"border-color-e":[{"border-e":G()}],"border-color-bs":[{"border-bs":G()}],"border-color-be":[{"border-be":G()}],"border-color-t":[{"border-t":G()}],"border-color-r":[{"border-r":G()}],"border-color-b":[{"border-b":G()}],"border-color-l":[{"border-l":G()}],"divide-color":[{divide:G()}],"outline-style":[{outline:[...F(),"none","hidden"]}],"outline-offset":[{"outline-offset":[$e,xe,me]}],"outline-w":[{outline:["",$e,kr,Jt]}],"outline-color":[{outline:G()}],shadow:[{shadow:["","none",m,Gr,Hr]}],"shadow-color":[{shadow:G()}],"inset-shadow":[{"inset-shadow":["none",h,Gr,Hr]}],"inset-shadow-color":[{"inset-shadow":G()}],"ring-w":[{ring:_()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:G()}],"ring-offset-w":[{"ring-offset":[$e,Jt]}],"ring-offset-color":[{"ring-offset":G()}],"inset-ring-w":[{"inset-ring":_()}],"inset-ring-color":[{"inset-ring":G()}],"text-shadow":[{"text-shadow":["none",p,Gr,Hr]}],"text-shadow-color":[{"text-shadow":G()}],opacity:[{opacity:[$e,xe,me]}],"mix-blend":[{"mix-blend":[...q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":q()}],"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":[$e]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":G()}],"mask-image-linear-to-color":[{"mask-linear-to":G()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":G()}],"mask-image-t-to-color":[{"mask-t-to":G()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":G()}],"mask-image-r-to-color":[{"mask-r-to":G()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":G()}],"mask-image-b-to-color":[{"mask-b-to":G()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":G()}],"mask-image-l-to-color":[{"mask-l-to":G()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":G()}],"mask-image-x-to-color":[{"mask-x-to":G()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":G()}],"mask-image-y-to-color":[{"mask-y-to":G()}],"mask-image-radial":[{"mask-radial":[xe,me]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":G()}],"mask-image-radial-to-color":[{"mask-radial-to":G()}],"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":k()}],"mask-image-conic-pos":[{"mask-conic":[$e]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":G()}],"mask-image-conic-to-color":[{"mask-conic-to":G()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:$()}],"mask-size":[{mask:Z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",xe,me]}],filter:[{filter:["","none",xe,me]}],blur:[{blur:B()}],brightness:[{brightness:[$e,xe,me]}],contrast:[{contrast:[$e,xe,me]}],"drop-shadow":[{"drop-shadow":["","none",g,Gr,Hr]}],"drop-shadow-color":[{"drop-shadow":G()}],grayscale:[{grayscale:["",$e,xe,me]}],"hue-rotate":[{"hue-rotate":[$e,xe,me]}],invert:[{invert:["",$e,xe,me]}],saturate:[{saturate:[$e,xe,me]}],sepia:[{sepia:["",$e,xe,me]}],"backdrop-filter":[{"backdrop-filter":["","none",xe,me]}],"backdrop-blur":[{"backdrop-blur":B()}],"backdrop-brightness":[{"backdrop-brightness":[$e,xe,me]}],"backdrop-contrast":[{"backdrop-contrast":[$e,xe,me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",$e,xe,me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[$e,xe,me]}],"backdrop-invert":[{"backdrop-invert":["",$e,xe,me]}],"backdrop-opacity":[{"backdrop-opacity":[$e,xe,me]}],"backdrop-saturate":[{"backdrop-saturate":[$e,xe,me]}],"backdrop-sepia":[{"backdrop-sepia":["",$e,xe,me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",xe,me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[$e,"initial",xe,me]}],ease:[{ease:["linear","initial",N,xe,me]}],delay:[{delay:[$e,xe,me]}],animate:[{animate:["none",j,xe,me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,xe,me]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:ee()}],"rotate-x":[{"rotate-x":ee()}],"rotate-y":[{"rotate-y":ee()}],"rotate-z":[{"rotate-z":ee()}],scale:[{scale:V()}],"scale-x":[{"scale-x":V()}],"scale-y":[{"scale-y":V()}],"scale-z":[{"scale-z":V()}],"scale-3d":["scale-3d"],skew:[{skew:w()}],"skew-x":[{"skew-x":w()}],"skew-y":[{"skew-y":w()}],transform:[{transform:[xe,me,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:M()}],"translate-x":[{"translate-x":M()}],"translate-y":[{"translate-y":M()}],"translate-z":[{"translate-z":M()}],"translate-none":["translate-none"],accent:[{accent:G()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:G()}],"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",xe,me]}],"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":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"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",xe,me]}],fill:[{fill:["none",...G()]}],"stroke-w":[{stroke:[$e,kr,Jt,Ja]}],stroke:[{stroke:["none",...G()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","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","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","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-bs","border-w-be","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-bs","border-color-be","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-mbs","scroll-mbe","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-pbs","scroll-pbe","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"]}},vc=Xl(yc);function ke(...t){return vc(yo(t))}function kc(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Po=l.forwardRef(({className:t,children:r,...s},a)=>e.jsx("div",{className:ke(t,"relative overflow-hidden"),...s,children:e.jsx("div",{ref:a,className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Po.displayName="ScrollArea";function wc({updateAvailable:t,releaseInfo:r,latestVersion:s,onShowVersionModal:a,onShowSettings:n,t:o}){return e.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-left hover:bg-blue-50/80 dark:hover:bg-blue-900/15 transition-colors group",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx($a,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),e.jsx("div",{className:"md:hidden px-3 py-2",children:e.jsxs("button",{className:"w-full h-11 bg-blue-50/80 dark:bg-blue-900/15 border border-blue-200/60 dark:border-blue-700/40 rounded-xl flex items-center gap-3 px-3.5 active:scale-[0.98] transition-all",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx($a,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors",onClick:n,children:[e.jsx(Dt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),e.jsx("div",{className:"md:hidden p-3 pb-20",children:e.jsxs("button",{className:"w-full h-12 bg-muted/40 hover:bg-muted/60 rounded-xl flex items-center gap-3.5 px-4 active:scale-[0.98] transition-all",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-background/80 flex items-center justify-center",children:e.jsx(Dt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),e.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const Xa=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Za=yo,$o=(t,r)=>s=>{var a;if((r==null?void 0:r.variants)==null)return Za(t,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:n,defaultVariants:o}=r,i=Object.keys(n).map(d=>{const m=s==null?void 0:s[d],h=o==null?void 0:o[d];if(m===null)return null;const p=Xa(m)||Xa(h);return n[d][p]}),c=s&&Object.entries(s).reduce((d,m)=>{let[h,p]=m;return p===void 0||(d[h]=p),d},{}),u=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((d,m)=>{let{class:h,className:p,...g}=m;return Object.entries(g).every(f=>{let[x,b]=f;return Array.isArray(b)?b.includes({...o,...c}[x]):{...o,...c}[x]===b})?[...d,h,p]:d},[]);return Za(t,i,u,s==null?void 0:s.class,s==null?void 0:s.className)},jc=$o("inline-flex 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",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),he=l.forwardRef(({className:t,variant:r,size:s,...a},n)=>e.jsx("button",{className:ke(jc({variant:r,size:s,className:t})),ref:n,...a}));he.displayName="Button";const Ze=l.forwardRef(({className:t,type:r,...s},a)=>e.jsx("input",{type:r,className:ke("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,...s}));Ze.displayName="Input";function Nc({isPWA:t,isMobile:r,isLoading:s,projectsCount:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,t:h}){const p=()=>e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("img",{src:"/favicon.svg",alt:"",className:"w-7 h-7 rounded-lg flex-shrink-0"}),e.jsx("h1",{className:"text-sm font-semibold text-foreground tracking-tight truncate",children:h("app.title")})]});return e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"hidden md:block px-3 pt-3 pb-2",style:{},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(p,{}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:c,disabled:u,title:h("tooltips.refresh"),children:e.jsx(Vs,{className:`w-3.5 h-3.5 ${u?"animate-spin":""}`})}),e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:d,title:h("tooltips.createProject"),children:e.jsx(at,{className:"w-3.5 h-3.5"})}),e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:m,title:h("tooltips.hideSidebar"),children:e.jsx(fi,{className:"w-3.5 h-3.5"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/50 pointer-events-none"}),e.jsx(Ze,{type:"text",placeholder:h("projects.searchPlaceholder"),value:n,onChange:g=>o(g.target.value),className:"nav-search-input pl-9 pr-8 h-9 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-accent rounded-md",children:e.jsx(Ve,{className:"w-3 h-3 text-muted-foreground"})})]})]}),e.jsx("div",{className:"hidden md:block nav-divider"}),e.jsxs("div",{className:"md:hidden p-3 pb-2",style:t&&r?{paddingTop:"16px"}:{},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{}),e.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-muted/50 flex items-center justify-center active:scale-95 transition-all",onClick:c,disabled:u,children:e.jsx(Vs,{className:`w-4 h-4 text-muted-foreground ${u?"animate-spin":""}`})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/90 text-primary-foreground flex items-center justify-center active:scale-95 transition-all",onClick:d,children:e.jsx(Zr,{className:"w-4 h-4"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 pointer-events-none"}),e.jsx(Ze,{type:"text",placeholder:h("projects.searchPlaceholder"),value:n,onChange:g=>o(g.target.value),className:"nav-search-input pl-10 pr-9 h-10 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 hover:bg-accent rounded-md",children:e.jsx(Ve,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})]}),e.jsx("div",{className:"md:hidden nav-divider"})]})}const Cc=({status:t="not-configured",size:r="sm",className:s="",showLabel:a=!1})=>{const o=(()=>{switch(t){case"fully-configured":return{icon:Pr,color:"text-green-500 dark:text-green-400",bgColor:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"};case"taskmaster-only":return{icon:Dt,color:"text-blue-500 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"};case"mcp-only":return{icon:xs,color:"text-amber-500 dark:text-amber-400",bgColor:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"};case"not-configured":case"error":default:return{icon:Ve,color:"text-gray-400 dark:text-gray-500",bgColor:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"}}})(),i=o.icon,c={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},u={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"};return a?e.jsxs("div",{className:ke("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",o.bgColor,o.color,s),title:o.title,children:[e.jsx(i,{className:c[r]}),e.jsx("span",{className:"font-medium",children:o.label})]}):e.jsx("div",{className:ke("inline-flex items-center justify-center rounded-full transition-colors",o.bgColor,u[r],s),title:o.title,children:e.jsx(i,{className:ke(c[r],o.color)})})},Sc=$o("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 bt({className:t,variant:r,...s}){return e.jsx("div",{className:ke(Sc({variant:r}),t),...s})}const en=(t,r,s)=>{const a=new Date(t),n=r;if(isNaN(a.getTime()))return s?s("status.unknown"):"Unknown";const o=n.getTime()-a.getTime(),i=Math.floor(o/1e3),c=Math.floor(o/(1e3*60)),u=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return i<60?s?s("time.justNow"):"Just now":c===1?s?s("time.oneMinuteAgo"):"1 min ago":c<60?s?s("time.minutesAgo",{count:c}):`${c} mins ago`:u===1?s?s("time.oneHourAgo"):"1 hour ago":u<24?s?s("time.hoursAgo",{count:u}):`${u} hours ago`:d===1?s?s("time.oneDayAgo"):"1 day ago":d<7?s?s("time.daysAgo",{count:d}):`${d} days ago`:a.toLocaleDateString()};function ft({provider:t="claude",className:r="w-5 h-5"}){return t==="cursor"?e.jsx(Ui,{className:r}):t==="codex"?e.jsx(Hi,{className:r}):e.jsx(Gi,{className:r})}function Ec({project:t,session:r,selectedSession:s,currentTime:a,editingSession:n,editingSessionName:o,onEditingSessionNameChange:i,onStartEditingSession:c,onCancelEditingSession:u,onSaveEditingSession:d,onProjectSelect:m,onSessionSelect:h,onDeleteSession:p,touchHandlerFactory:g,t:f}){const x=Cl(r,a,f),b=(s==null?void 0:s.id)===r.id,N=()=>{m(t),h(r,t.name)},j=()=>{d(t.name,r.id,o)},y=()=>{p(t.name,r.id,x.sessionName,r.__provider)};return e.jsxs("div",{className:"group relative",children:[x.isActive&&e.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:ke("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",b?"bg-primary/5 border-primary/20":"",!b&&x.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:N,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:ke("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",b?"bg-primary/10":"bg-muted/50"),children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:x.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Ir,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:en(x.sessionTime,a,f)}),x.messageCount>0&&e.jsx(bt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:x.messageCount}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})})]})]}),!x.isCursorSession&&e.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:k=>{k.stopPropagation(),y()},children:e.jsx(yt,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(he,{variant:"ghost",className:ke("w-full justify-start px-2 py-2.5 h-auto min-h-[48px] font-normal text-left hover:bg-accent/50 transition-colors duration-200",b&&"bg-accent text-accent-foreground"),onClick:()=>h(r,t.name),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full pr-14",children:[e.jsx(ft,{provider:r.__provider,className:"w-3 h-3 mt-1 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground leading-5",children:x.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Ir,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:en(x.sessionTime,a,f)}),x.messageCount>0&&e.jsx(bt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto group-hover:opacity-0 transition-opacity",children:x.messageCount}),e.jsx("span",{className:"ml-1 opacity-70 group-hover:opacity-0 transition-opacity",children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})})]})]})]})}),!x.isCursorSession&&e.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-all duration-200 bg-accent/80 backdrop-blur-sm rounded-md px-1 py-0.5",children:n===r.id&&!x.isCodexSession?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:o,onChange:k=>i(k.target.value),onKeyDown:k=>{k.stopPropagation(),k.key==="Enter"?j():k.key==="Escape"&&u()},onClick:k=>k.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),j()},title:f("tooltips.save"),children:e.jsx(Lt,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),u()},title:f("tooltips.cancel"),children:e.jsx(Ve,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):e.jsxs(e.Fragment,{children:[!x.isCodexSession&&e.jsx("button",{className:"w-7 h-7 bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),c(r.id,r.summary||f("projects.newSession"))},title:f("tooltips.editSessionName"),children:e.jsx(bi,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-7 h-7 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),y()},title:f("tooltips.deleteSession"),children:e.jsx(yt,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]})}function Tc(){return e.jsx(e.Fragment,{children:Array.from({length:3}).map((t,r)=>e.jsx("div",{className:"p-2 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+r*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},r))})}function Ac({project:t,isExpanded:r,sessions:s,selectedSession:a,initialSessionsLoaded:n,isLoadingSessions:o,currentTime:i,editingSession:c,editingSessionName:u,onEditingSessionNameChange:d,onStartEditingSession:m,onCancelEditingSession:h,onSaveEditingSession:p,onProjectSelect:g,onSessionSelect:f,onDeleteSession:x,onLoadMoreSessions:b,onNewSession:N,touchHandlerFactory:j,t:y}){var D;if(!r)return null;const k=s.length>0,I=((D=t.sessionMeta)==null?void 0:D.hasMore)===!0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[n?!k&&!o?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:y("sessions.noSessions")})}):s.map(C=>e.jsx(Ec,{project:t,session:C,selectedSession:a,currentTime:i,editingSession:c,editingSessionName:u,onEditingSessionNameChange:d,onStartEditingSession:m,onCancelEditingSession:h,onSaveEditingSession:p,onProjectSelect:g,onSessionSelect:f,onDeleteSession:x,touchHandlerFactory:j,t:y},C.id)):e.jsx(Tc,{}),k&&I&&e.jsx(he,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>b(t),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),y("sessions.loading")]}):e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-3 h-3"}),y("sessions.showMore")]})}),e.jsx("div",{className:"md:hidden px-3 pb-2",children:e.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{g(t),N(t)},children:[e.jsx(at,{className:"w-3 h-3"}),y("sessions.newSession")]})}),e.jsxs(he,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>N(t),children:[e.jsx(at,{className:"w-3 h-3"}),y("sessions.newSession")]})]})}const Ic=(t,r)=>{const s=t.length;return r&&s>=5?`${s}+`:`${s}`};function Mc({project:t,selectedProject:r,selectedSession:s,isExpanded:a,isDeleting:n,isStarred:o,editingProject:i,editingName:c,sessions:u,initialSessionsLoaded:d,isLoadingSessions:m,currentTime:h,editingSession:p,editingSessionName:g,tasksEnabled:f,mcpServerStatus:x,onEditingNameChange:b,onToggleProject:N,onProjectSelect:j,onToggleStarProject:y,onStartEditingProject:k,onCancelEditingProject:I,onSaveProjectName:D,onDeleteProject:C,onSessionSelect:v,onDeleteSession:E,onLoadMoreSessions:T,onNewSession:W,onEditingSessionNameChange:S,onStartEditingSession:O,onCancelEditingSession:H,onSaveEditingSession:R,onOpenProjectSettings:A,touchHandlerFactory:z,t:J}){var U;const re=(r==null?void 0:r.name)===t.name,G=i===t.name,ie=((U=t.sessionMeta)==null?void 0:U.hasMore)===!0,$=Ic(u,ie),Z=`${$} session${u.length===1?"":"s"}`,te=Tl(t,x),Q=()=>N(t.name),_=()=>y(t.name),F=()=>{D(t.name)},q=()=>{(r==null?void 0:r.name)!==t.name&&j(t),Q()};return e.jsxs("div",{className:ke("md:space-y-1",n&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"group md:group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:ke("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",re&&"bg-primary/5 border-primary/20",o&&!re&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:Q,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:ke("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",a?"bg-primary/10":"bg-muted"),children:a?e.jsx(er,{className:"w-4 h-4 text-primary"}):e.jsx(mr,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:G?e.jsx("input",{type:"text",value:c,onChange:B=>b(B.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:J("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:B=>B.stopPropagation(),onKeyDown:B=>{B.key==="Enter"&&F(),B.key==="Escape"&&I()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:t.displayName}),f&&e.jsx(Cc,{status:te,size:"xs",className:"hidden md:inline-flex flex-shrink-0 ml-2"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Z})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:G?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:B=>{B.stopPropagation(),F()},children:e.jsx(Lt,{className:"w-4 h-4 text-white"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:B=>{B.stopPropagation(),I()},children:e.jsx(Ve,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:ke("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",o?"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:B=>{B.stopPropagation(),_()},title:J(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(_a,{className:ke("w-4 h-4 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500/10 dark:bg-gray-900/30 flex items-center justify-center active:scale-90 border border-gray-200 dark:border-gray-800",onClick:B=>{B.stopPropagation(),A(t)},title:J("tooltips.projectSettings",{defaultValue:"Project settings"}),children:e.jsx(Dt,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:B=>{B.stopPropagation(),C(t)},children:e.jsx(yt,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:B=>{B.stopPropagation(),k(t)},children:e.jsx(Mr,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:a?e.jsx(Pt,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(rr,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(he,{variant:"ghost",className:ke("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",re&&"bg-accent text-accent-foreground",o&&!re&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:q,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a?e.jsx(er,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(mr,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:G?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:c,onChange:B=>b(B.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:J("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:B=>{B.key==="Enter"&&F(),B.key==="Escape"&&I()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:t.fullPath,children:t.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[$,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 items-center gap-1 flex-shrink-0",children:G?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:B=>{B.stopPropagation(),F()},children:e.jsx(Lt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:B=>{B.stopPropagation(),I()},children:e.jsx(Ve,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ke("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",o?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:B=>{B.stopPropagation(),_()},title:J(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(_a,{className:ke("w-3 h-3 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),A(t)},title:J("tooltips.projectSettings",{defaultValue:"Project settings"}),children:e.jsx(Dt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),k(t)},title:J("tooltips.renameProject"),children:e.jsx(Mr,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),C(t)},title:J("tooltips.deleteProject"),children:e.jsx(yt,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),a?e.jsx(Pt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(rr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),e.jsx(Ac,{project:t,isExpanded:a,sessions:u,selectedSession:s,initialSessionsLoaded:d,isLoadingSessions:m,currentTime:h,editingSession:p,editingSessionName:g,onEditingSessionNameChange:S,onStartEditingSession:O,onCancelEditingSession:H,onSaveEditingSession:R,onProjectSelect:j,onSessionSelect:v,onDeleteSession:E,onLoadMoreSessions:T,onNewSession:W,touchHandlerFactory:z,t:J})]})}function Dc({isLoading:t,loadingProgress:r,projectsCount:s,filteredProjectsCount:a,t:n}){const{isRelayConnected:o}=ps();return t?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.loadingProjects")}),r&&r.total>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full transition-all duration-300 ease-out",style:{width:`${r.current/r.total*100}%`}})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.current,"/",r.total," ",n("projects.projects")]}),r.currentProject&&e.jsx("p",{className:"text-xs text-muted-foreground/70 truncate max-w-[200px] mx-auto",title:r.currentProject,children:r.currentProject.split("-").slice(-2).join("/")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.fetchingProjects")})]}):s===0?o?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(mr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.runClaudeCli")})]}):e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Xn,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"No machine connected"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your machine to see projects"})]}):a===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Ar,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noMatchingProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.tryDifferentSearch")})]}):null}function Lc({projects:t,filteredProjects:r,selectedProject:s,selectedSession:a,isLoading:n,loadingProgress:o,expandedProjects:i,editingProject:c,editingName:u,loadingSessions:d,initialSessionsLoaded:m,currentTime:h,editingSession:p,editingSessionName:g,deletingProjects:f,tasksEnabled:x,mcpServerStatus:b,getProjectSessions:N,isProjectStarred:j,onEditingNameChange:y,onToggleProject:k,onProjectSelect:I,onToggleStarProject:D,onStartEditingProject:C,onCancelEditingProject:v,onSaveProjectName:E,onDeleteProject:T,onSessionSelect:W,onDeleteSession:S,onLoadMoreSessions:O,onNewSession:H,onEditingSessionNameChange:R,onStartEditingSession:A,onCancelEditingSession:z,onSaveEditingSession:J,onOpenProjectSettings:re,touchHandlerFactory:G,t:ie}){const $=e.jsx(Dc,{isLoading:n,loadingProgress:o,projectsCount:t.length,filteredProjectsCount:r.length,t:ie}),Z=!n&&t.length>0&&r.length>0;return e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:Z?r.map(te=>e.jsx(Mc,{project:te,selectedProject:s,selectedSession:a,isExpanded:i.has(te.name),isDeleting:f.has(te.name),isStarred:j(te.name),editingProject:c,editingName:u,sessions:N(te),initialSessionsLoaded:m.has(te.name),isLoadingSessions:!!d[te.name],currentTime:h,editingSession:p,editingSessionName:g,tasksEnabled:x,mcpServerStatus:b,onEditingNameChange:y,onToggleProject:k,onProjectSelect:I,onToggleStarProject:D,onStartEditingProject:C,onCancelEditingProject:v,onSaveProjectName:E,onDeleteProject:T,onSessionSelect:W,onDeleteSession:S,onLoadMoreSessions:O,onNewSession:H,onEditingSessionNameChange:R,onStartEditingSession:A,onCancelEditingSession:z,onSaveEditingSession:J,onOpenProjectSettings:re,touchHandlerFactory:G,t:ie},te.name)):$})}function Pc({isPWA:t,isMobile:r,isLoading:s,projects:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,updateAvailable:h,releaseInfo:p,latestVersion:g,onShowVersionModal:f,onShowSettings:x,projectListProps:b,t:N}){return e.jsxs("div",{className:"h-full flex flex-col bg-background/80 backdrop-blur-sm md:select-none md:w-72",style:{},children:[e.jsx(Nc,{isPWA:t,isMobile:r,isLoading:s,projectsCount:a.length,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,t:N}),e.jsx(Po,{className:"flex-1 px-1.5 py-1.5 md:py-2 overflow-y-auto overscroll-contain",children:e.jsx(Lc,{...b})}),e.jsx(wc,{updateAvailable:h,releaseInfo:p,latestVersion:g,onShowVersionModal:f,onShowSettings:x,t:N})]})}const $c=({onClose:t,onProjectCreated:r})=>{var _e;const{t:s}=We(),[a,n]=l.useState(1),[o,i]=l.useState("existing"),[c,u]=l.useState(""),[d,m]=l.useState(""),[h,p]=l.useState(""),[g,f]=l.useState("stored"),[x,b]=l.useState(""),[N,j]=l.useState(!1),[y,k]=l.useState(null),[I,D]=l.useState([]),[C,v]=l.useState(!1),[E,T]=l.useState([]),[W,S]=l.useState(!1),[O,H]=l.useState(!1),[R,A]=l.useState("~"),[z,J]=l.useState([]),[re,G]=l.useState(!1),[ie,$]=l.useState(!1),[Z,te]=l.useState(!1),[Q,_]=l.useState(""),[F,q]=l.useState(!1),[U,B]=l.useState(""),[ee,V]=l.useState([]);l.useEffect(()=>{a===2&&o==="new"&&d&&w()},[a,o,d]),l.useEffect(()=>{c.length>2?M(c):(T([]),S(!1))},[c]);const w=async()=>{try{v(!0);const pe=((await(await Be.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(ye=>ye.is_active);D(pe),pe.length>0&&!h&&p(pe[0].id.toString())}catch(L){console.error("Error loading GitHub tokens:",L)}finally{v(!1)}},M=async L=>{try{const K=L.lastIndexOf("/"),pe=K>0?L.substring(0,K):"~",Ie=await(await Be.browseFilesystem(pe)).json();if(Ie.suggestions){const Fe=Ie.suggestions.filter(Se=>Se.path.toLowerCase().startsWith(L.toLowerCase())&&Se.path.toLowerCase()!==L.toLowerCase());T(Fe.slice(0,5)),S(Fe.length>0)}}catch(K){console.error("Error loading path suggestions:",K)}},Y=()=>{if(k(null),a===1){if(!o){k(s("projectWizard.errors.selectType"));return}n(2)}else if(a===2){if(!c.trim()){k(s("projectWizard.errors.providePath"));return}n(3)}},se=()=>{k(null),n(a-1)},de=async()=>{j(!0),k(null),B("");try{if(o==="new"&&d){const ye=new URLSearchParams({path:c.trim(),githubUrl:d.trim()});g==="stored"&&h?ye.append("githubTokenId",h):g==="new"&&x&&ye.append("newGithubToken",x.trim());const Ie=`/api/projects/clone-progress?${ye}`;await new Promise((Fe,Se)=>{const Oe=new EventSource(Ie);Oe.onmessage=ne=>{try{const fe=JSON.parse(ne.data);fe.type==="progress"?B(fe.message):fe.type==="complete"?(Oe.close(),r&&r(fe.project),t(),Fe()):fe.type==="error"&&(Oe.close(),Se(new Error(fe.message)))}catch(fe){console.error("Error parsing SSE event:",fe)}},Oe.onerror=()=>{Oe.close(),Se(new Error("Connection lost during clone"))}});return}const L={workspaceType:o,path:c.trim()},K=await Be.createWorkspace(L),pe=await K.json();if(!K.ok)throw new Error(pe.details||pe.error||s("projectWizard.errors.failedToCreate"));r&&r(pe.project),t()}catch(L){console.error("Error creating workspace:",L),k(L.message||s("projectWizard.errors.failedToCreate"))}finally{j(!1)}},je=L=>{u(L.path),S(!1)},ge=async()=>{H(!0),await Re("~")},Re=async L=>{try{G(!0);const pe=await(await Be.browseFilesystem(L)).json();A(pe.path||L),J(pe.suggestions||[]),pe.drives&&Array.isArray(pe.drives)&&V(pe.drives)}catch(K){console.error("Error loading folders:",K)}finally{G(!1)}},Ne=(L,K=!1)=>{u(L),H(!1),K&&n(3)},De=async L=>{await Re(L)},Ue=async()=>{if(Q.trim()){q(!0),k(null);try{const L=R.includes("\\")?"\\":"/",K=`${R}${L}${Q.trim()}`,pe=await Be.createFolder(K),ye=await pe.json();if(!pe.ok)throw new Error(ye.error||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"));_(""),te(!1),await Re(ye.path||K)}catch(L){console.error("Error creating folder:",L),k(L.message||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{q(!1)}}};return e.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Zr,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s("projectWizard.title")})]}),e.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:N,children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"px-6 pt-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(L=>e.jsxs(it.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${L<a?"bg-green-500 text-white":L===a?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:L<a?e.jsx(Lt,{className:"w-4 h-4"}):L}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:s(L===1?"projectWizard.steps.type":L===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),L<3&&e.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${L<a?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},L))})}),e.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[y&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(xs,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:y})})]}),a===1&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:s("projectWizard.step1.question")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("button",{onClick:()=>i("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="existing"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(Zr,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.existing.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.existing.description")})]})]})}),e.jsx("button",{onClick:()=>i("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="new"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(br,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.new.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.new.description")})]})]})})]})]})}),a===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s(o==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),e.jsxs("div",{className:"relative flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ze,{type:"text",value:c,onChange:L=>u(L.target.value),placeholder:o==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),W&&E.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:E.map((L,K)=>e.jsxs("button",{onClick:()=>je(L),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:L.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:L.path})]},K))})]}),e.jsx(he,{type:"button",variant:"outline",onClick:ge,className:"px-3",title:"Browse folders",children:e.jsx(er,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s(o==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]}),o==="new"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.githubUrl")}),e.jsx(Ze,{type:"text",value:d,onChange:L=>m(L.target.value),placeholder:"https://github.com/username/repository",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.githubHelp")})]}),d&&!d.startsWith("git@")&&!d.startsWith("ssh://")&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(xa,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-medium text-gray-900 dark:text-white mb-1",children:s("projectWizard.step2.githubAuth")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step2.githubAuthHelp")})]})]}),C?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Sr,{className:"w-4 h-4 animate-spin"}),s("projectWizard.step2.loadingTokens")]}):I.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsx("button",{onClick:()=>f("stored"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="stored"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.storedToken")}),e.jsx("button",{onClick:()=>f("new"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="new"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.newToken")}),e.jsx("button",{onClick:()=>{f("none"),p(""),b("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="none"?"bg-green-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.nonePublic")})]}),g==="stored"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.selectToken")}),e.jsxs("select",{value:h,onChange:L=>p(L.target.value),className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:s("projectWizard.step2.selectTokenPlaceholder")}),I.map(L=>e.jsx("option",{value:L.id,children:L.credential_name},L.id))]})]}):g==="new"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.newToken")}),e.jsx(Ze,{type:"password",value:x,onChange:L=>b(L.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.tokenHelp")})]}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s("projectWizard.step2.publicRepoInfo")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.optionalTokenPublic")}),e.jsx(Ze,{type:"password",value:x,onChange:L=>b(L.target.value),placeholder:s("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.noTokensHelp")})]})]})]})]})]}),a===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:s("projectWizard.step3.reviewConfig")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.workspaceType")}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:s(o==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.path")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]}),o==="new"&&d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.cloneFrom")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:d})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.authentication")}),e.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:g==="stored"&&h?`${s("projectWizard.step3.usingStoredToken")} ${((_e=I.find(L=>L.id.toString()===h))==null?void 0:_e.credential_name)||"Unknown"}`:g==="new"&&x?s("projectWizard.step3.usingProvidedToken"):d.startsWith("git@")||d.startsWith("ssh://")?s("projectWizard.step3.sshKey","SSH Key"):s("projectWizard.step3.noAuthentication")})]})]})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:N&&U?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:s("projectWizard.step3.cloningRepository","Cloning repository...")}),e.jsx("code",{className:"block text-xs font-mono text-blue-700 dark:text-blue-300 whitespace-pre-wrap break-all",children:U})]}):e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s(o==="existing"?"projectWizard.step3.existingInfo":d?"projectWizard.step3.newWithClone":"projectWizard.step3.newEmpty")})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(he,{variant:"outline",onClick:a===1?t:se,disabled:N,children:a===1?s("projectWizard.buttons.cancel"):e.jsxs(e.Fragment,{children:[e.jsx(ga,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.back")]})}),e.jsx(he,{onClick:a===3?de:Y,disabled:N||a===1&&!o,children:N?e.jsxs(e.Fragment,{children:[e.jsx(Sr,{className:"w-4 h-4 mr-2 animate-spin"}),d?s("projectWizard.buttons.cloning","Cloning..."):s("projectWizard.buttons.creating")]}):a===3?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.createProject")]}):e.jsxs(e.Fragment,{children:[s("projectWizard.buttons.next"),e.jsx(rr,{className:"w-4 h-4 ml-1"})]})})]})]}),O&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(er,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>$(!ie),className:`p-2 rounded-md transition-colors ${ie?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:ie?"Hide hidden folders":"Show hidden folders",children:ie?e.jsx(sr,{className:"w-5 h-5"}):e.jsx(Zn,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>te(!Z),className:`p-2 rounded-md transition-colors ${Z?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:e.jsx(at,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>H(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Ve,{className:"w-5 h-5"})})]})]}),Z&&e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-blue-50 dark:bg-blue-900/20",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{type:"text",value:Q,onChange:L=>_(L.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:L=>{L.key==="Enter"&&Ue(),L.key==="Escape"&&(te(!1),_(""))},autoFocus:!0}),e.jsx(he,{size:"sm",onClick:Ue,disabled:!Q.trim()||F,children:F?e.jsx(Sr,{className:"w-4 h-4 animate-spin"}):"Create"}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>{te(!1),_("")},children:"Cancel"})]})}),ee.length>0&&e.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 mr-1",children:"Drives:"}),ee.map(L=>{const K=typeof L=="string"?L:L.name||L.path,pe=typeof L=="string"?`${L}\\`:L.path||`${L.name}\\`;return e.jsx("button",{onClick:()=>De(pe),className:`px-3 py-1.5 text-sm font-mono font-medium rounded-md border transition-colors ${R.startsWith(K)?"bg-blue-100 dark:bg-blue-900/50 border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:K},K)})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:re?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Sr,{className:"w-6 h-6 animate-spin text-gray-400"})}):e.jsxs("div",{className:"space-y-1",children:[R!=="~"&&R!=="/"&&!/^[A-Za-z]:\\?$/.test(R)&&e.jsxs("button",{onClick:()=>{const L=Math.max(R.lastIndexOf("/"),R.lastIndexOf("\\"));let K;L<=0?K="/":L===2&&/^[A-Za-z]:/.test(R)?K=R.substring(0,3):K=R.substring(0,L),De(K)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(er,{className:"w-5 h-5 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),z.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):z.filter(L=>ie||!L.name.startsWith(".")).sort((L,K)=>L.name.toLowerCase().localeCompare(K.name.toLowerCase())).map((L,K)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>De(L.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(Zr,{className:"w-5 h-5 text-blue-500"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:L.name})]}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>Ne(L.path,o==="existing"),className:"text-xs px-3",children:"Select"})]},K))]})}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:R})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[e.jsx(he,{variant:"outline",onClick:()=>{H(!1),te(!1),_("")},children:"Cancel"}),e.jsx(he,{variant:"outline",onClick:()=>Ne(R,o==="existing"),children:"Use this folder"})]})]})]})})]})};function _c({isOpen:t,onConfirm:r,onCancel:s,title:a,message:n,detail:o,variant:i="danger",confirmLabel:c="Confirm",cancelLabel:u="Cancel"}){const d=l.useRef(null);l.useEffect(()=>{var p;t&&((p=d.current)==null||p.focus())},[t]);const m=l.useCallback(p=>{p.key==="Escape"&&s()},[s]);if(!t)return null;const h=i==="danger";return Cr.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onKeyDown:m,children:e.jsxs("div",{className:"bg-card border border-border/40 rounded-2xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0 ${h?"bg-red-500/10":"bg-amber-500/10"}`,children:h?e.jsx($t,{className:"w-5 h-5 text-red-500"}):e.jsx(vt,{className:"w-5 h-5 text-amber-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1.5",children:a}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:n}),o&&e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-2 leading-relaxed",children:o})]})]})}),e.jsxs("div",{className:"flex gap-2 px-5 py-4 border-t border-border/20",children:[e.jsx("button",{ref:d,onClick:s,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:u}),e.jsx("button",{onClick:r,className:`flex-1 px-4 py-2.5 text-xs font-medium rounded-xl transition-opacity ${h?"bg-red-600 hover:bg-red-700 text-white":"bg-foreground hover:opacity-90 text-background"}`,children:c})]})]})}),document.body)}function Sa(){const[t,r]=l.useState(null),s=l.useCallback(i=>new Promise(c=>{r({...i,resolve:c})}),[]),a=l.useCallback(()=>{t==null||t.resolve(!0),r(null)},[t]),n=l.useCallback(()=>{t==null||t.resolve(!1),r(null)},[t]),o=t?{isOpen:!0,onConfirm:a,onCancel:n,title:t.title,message:t.message,detail:t.detail,variant:t.variant,confirmLabel:t.confirmLabel,cancelLabel:t.cancelLabel}:{isOpen:!1,onConfirm:()=>{},onCancel:()=>{},title:"",message:""};return{confirm:s,dialogProps:o,ConfirmDialog:_c}}const Fc="2.9.1";function zc(){const{t}=We("settings"),{confirm:r,dialogProps:s,ConfirmDialog:a}=Sa(),[n,o]=l.useState([]),[i,c]=l.useState([]),[u,d]=l.useState(!0),[m,h]=l.useState(!1),[p,g]=l.useState(!1),[f,x]=l.useState(""),[b,N]=l.useState(""),[j,y]=l.useState(""),[k,I]=l.useState(""),[D,C]=l.useState({}),[v,E]=l.useState(null),[T,W]=l.useState(null),{updateAvailable:S,latestVersion:O,releaseInfo:H}=ho("AnitChaudhry","UpfynAI-Code");l.useEffect(()=>{R()},[]);const R=async()=>{try{d(!0);const te=await(await Me("/api/settings/api-keys")).json();o(te.apiKeys||[]);const _=await(await Me("/api/settings/credentials?type=github_token")).json();c(_.credentials||[])}catch(Z){console.error("Error fetching settings:",Z)}finally{d(!1)}},A=async()=>{if(f.trim())try{const te=await(await Me("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:f})})).json();te.success&&(W(te.apiKey),x(""),h(!1),R())}catch(Z){console.error("Error creating API key:",Z)}},z=async Z=>{if(await r({title:t("apiKeys.deleteTitle","Delete API Key"),message:t("apiKeys.confirmDelete"),confirmLabel:t("apiKeys.deleteButton","Delete"),cancelLabel:t("common:cancel","Cancel")}))try{await Me(`/api/settings/api-keys/${Z}`,{method:"DELETE"}),R()}catch(Q){console.error("Error deleting API key:",Q)}},J=async(Z,te)=>{try{await Me(`/api/settings/api-keys/${Z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!te})}),R()}catch(Q){console.error("Error toggling API key:",Q)}},re=async()=>{if(!(!b.trim()||!j.trim()))try{(await(await Me("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:b,credentialType:"github_token",credentialValue:j,description:k})})).json()).success&&(N(""),y(""),I(""),g(!1),R())}catch(Z){console.error("Error creating GitHub credential:",Z)}},G=async Z=>{if(await r({title:t("apiKeys.github.deleteTitle","Delete GitHub Credential"),message:t("apiKeys.github.confirmDelete"),confirmLabel:t("apiKeys.deleteButton","Delete"),cancelLabel:t("common:cancel","Cancel")}))try{await Me(`/api/settings/credentials/${Z}`,{method:"DELETE"}),R()}catch(Q){console.error("Error deleting GitHub credential:",Q)}},ie=async(Z,te)=>{try{await Me(`/api/settings/credentials/${Z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!te})}),R()}catch(Q){console.error("Error toggling GitHub credential:",Q)}},$=(Z,te)=>{navigator.clipboard.writeText(Z),E(te),setTimeout(()=>E(null),2e3)};return u?e.jsx("div",{className:"text-muted-foreground",children:t("apiKeys.loading")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-8",children:[T&&e.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[e.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:t("apiKeys.newKey.alertTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t("apiKeys.newKey.alertMessage")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:T.apiKey}),e.jsx(he,{size:"sm",variant:"outline",onClick:()=>$(T.apiKey,"new"),children:v==="new"?e.jsx(Lt,{className:"h-4 w-4"}):e.jsx(ha,{className:"h-4 w-4"})})]}),e.jsx(he,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>W(null),children:t("apiKeys.newKey.iveSavedIt")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xa,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.title")})]}),e.jsxs(he,{size:"sm",onClick:()=>h(!m),children:[e.jsx(at,{className:"h-4 w-4 mr-1"}),t("apiKeys.newButton")]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:t("apiKeys.description")}),e.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[t("apiKeys.apiDocsLink"),e.jsx(Fa,{className:"h-3 w-3"})]})]}),m&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[e.jsx(Ze,{placeholder:t("apiKeys.form.placeholder"),value:f,onChange:Z=>x(Z.target.value),className:"mb-2"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(he,{onClick:A,children:t("apiKeys.form.createButton")}),e.jsx(he,{variant:"outline",onClick:()=>h(!1),children:t("apiKeys.form.cancelButton")})]})]}),e.jsx("div",{className:"space-y-2",children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.empty")}):n.map(Z=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:Z.key_name}),e.jsx("code",{className:"text-xs text-muted-foreground",children:Z.api_key}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.list.created")," ",new Date(Z.created_at).toLocaleDateString(),Z.last_used&&` • ${t("apiKeys.list.lastUsed")} ${new Date(Z.last_used).toLocaleDateString()}`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{size:"sm",variant:Z.is_active?"outline":"secondary",onClick:()=>J(Z.id,Z.is_active),children:Z.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>z(Z.id),children:e.jsx(yt,{className:"h-4 w-4"})})]})]},Z.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yi,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.github.title")})]}),e.jsxs(he,{size:"sm",onClick:()=>g(!p),children:[e.jsx(at,{className:"h-4 w-4 mr-1"}),t("apiKeys.github.addButton")]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("apiKeys.github.descriptionAlt")}),p&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[e.jsx(Ze,{placeholder:t("apiKeys.github.form.namePlaceholder"),value:b,onChange:Z=>N(Z.target.value)}),e.jsxs("div",{className:"relative",children:[e.jsx(Ze,{type:D.new?"text":"password",placeholder:t("apiKeys.github.form.tokenPlaceholder"),value:j,onChange:Z=>y(Z.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>C({...D,new:!D.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:D.new?e.jsx(Zn,{className:"h-4 w-4"}):e.jsx(sr,{className:"h-4 w-4"})})]}),e.jsx(Ze,{placeholder:t("apiKeys.github.form.descriptionPlaceholder"),value:k,onChange:Z=>I(Z.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(he,{onClick:re,children:t("apiKeys.github.form.addButton")}),e.jsx(he,{variant:"outline",onClick:()=>{g(!1),N(""),y(""),I("")},children:t("apiKeys.github.form.cancelButton")})]}),e.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:t("apiKeys.github.form.howToCreate")})]}),e.jsx("div",{className:"space-y-2",children:i.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.github.empty")}):i.map(Z=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:Z.credential_name}),Z.description&&e.jsx("div",{className:"text-xs text-muted-foreground",children:Z.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.github.added")," ",new Date(Z.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{size:"sm",variant:Z.is_active?"outline":"secondary",onClick:()=>ie(Z.id,Z.is_active),children:Z.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>G(Z.id),children:e.jsx(yt,{className:"h-4 w-4"})})]})]},Z.id))})]}),e.jsx("div",{className:"pt-6 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[e.jsxs("a",{href:(H==null?void 0:H.htmlUrl)||"https://github.com/AnitChaudhry/UpfynAI-Code/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Fc]}),S&&O&&e.jsxs("a",{href:(H==null?void 0:H.htmlUrl)||"https://github.com/AnitChaudhry/UpfynAI-Code/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[e.jsx("span",{className:"text-[10px]",children:t("apiKeys.version.updateAvailable",{version:O})}),e.jsx(Fa,{className:"h-2.5 w-2.5"})]})]})})]}),e.jsx(a,{...s})]})}function Rc(){const{t}=We("settings"),[r,s]=l.useState(""),[a,n]=l.useState(""),[o,i]=l.useState(!1),[c,u]=l.useState(!1),[d,m]=l.useState(null);l.useEffect(()=>{h()},[]);const h=async()=>{try{i(!0);const g=await Me("/api/user/git-config");if(g.ok){const f=await g.json();s(f.gitName||""),n(f.gitEmail||"")}}catch(g){console.error("Error loading git config:",g)}finally{i(!1)}},p=async()=>{try{u(!0);const g=await Me("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:a})});if(g.ok)m("success"),setTimeout(()=>m(null),3e3);else{const f=await g.json();m("error"),console.error("Failed to save git config:",f.error)}}catch(g){console.error("Error saving git config:",g),m("error")}finally{u(!1)}};return e.jsx("div",{className:"space-y-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(br,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("git.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("git.description")}),e.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:t("git.name.label")}),e.jsx(Ze,{id:"settings-git-name",type:"text",value:r,onChange:g=>s(g.target.value),placeholder:"John Doe",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.name.help")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:t("git.email.label")}),e.jsx(Ze,{id:"settings-git-email",type:"email",value:a,onChange:g=>n(g.target.value),placeholder:"john@example.com",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.email.help")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{onClick:p,disabled:c||!r||!a,children:t(c?"git.actions.saving":"git.actions.save")}),d==="success"&&e.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[e.jsx(Lt,{className:"w-4 h-4"}),t("git.status.success")]})]})]})]})})}function Oc(){const{t}=We("settings"),{tasksEnabled:r,setTasksEnabled:s,isTaskMasterInstalled:a,isCheckingInstallation:n}=Lr();return e.jsx("div",{className:"space-y-8",children:n?e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("tasks.checking")})]})}):e.jsxs(e.Fragment,{children:[!a&&e.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:t("tasks.notInstalled.title")}),e.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[e.jsx("p",{children:t("tasks.notInstalled.description")}),e.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:e.jsx("code",{children:t("tasks.notInstalled.installCommand")})}),e.jsx("div",{children:e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.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 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 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.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),t("tasks.notInstalled.viewOnGitHub"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:t("tasks.notInstalled.afterInstallation")}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[e.jsx("li",{children:t("tasks.notInstalled.steps.restart")}),e.jsx("li",{children:t("tasks.notInstalled.steps.autoAvailable")}),e.jsx("li",{children:t("tasks.notInstalled.steps.initCommand")})]})]})]})]})]})}),a&&e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:t("tasks.settings.enableLabel")}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:t("tasks.settings.enableDescription")})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:o=>s(o.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]})})})]})})}const Bc={claude:{name:"Claude",color:"blue"},cursor:{name:"Cursor",color:"purple"},codex:{name:"Codex",color:"gray"}},Wc={blue:{border:"border-l-blue-500 md:border-l-blue-500",borderBottom:"border-b-blue-500",bg:"bg-blue-50 dark:bg-blue-900/20",dot:"bg-blue-500"},purple:{border:"border-l-purple-500 md:border-l-purple-500",borderBottom:"border-b-purple-500",bg:"bg-purple-50 dark:bg-purple-900/20",dot:"bg-purple-500"},gray:{border:"border-l-gray-700 dark:border-l-gray-300",borderBottom:"border-b-gray-700 dark:border-b-gray-300",bg:"bg-gray-100 dark:bg-gray-800/50",dot:"bg-gray-700 dark:bg-gray-300"}};function dr({agentId:t,authStatus:r,isSelected:s,onClick:a,isMobile:n=!1}){const{t:o}=We("settings"),i=Bc[t],c=Wc[i.color];return n?e.jsx("button",{onClick:a,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${s?`${c.borderBottom} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(ft,{provider:t,className:"w-5 h-5"}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:i.name}),(r==null?void 0:r.authenticated)&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`})]})}):e.jsxs("button",{onClick:a,className:`w-full text-left p-3 border-l-4 transition-colors ${s?`${c.border} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ft,{provider:t,className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:i.name})]}),e.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:r!=null&&r.loading?e.jsx("span",{className:"text-gray-400",children:o("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`}),e.jsx("span",{className:"truncate max-w-[120px]",title:r.email,children:r.email||o("agents.authStatus.connected")})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),e.jsx("span",{children:o("agents.authStatus.notConnected")})]})})]})}const Uc={claude:{name:"Claude",description:"Anthropic Claude AI assistant",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800",textClass:"text-blue-900 dark:text-blue-100",subtextClass:"text-blue-700 dark:text-blue-300",buttonClass:"bg-blue-600 hover:bg-blue-700"},cursor:{name:"Cursor",description:"Cursor AI-powered code editor",bgClass:"bg-purple-50 dark:bg-purple-900/20",borderClass:"border-purple-200 dark:border-purple-800",textClass:"text-purple-900 dark:text-purple-100",subtextClass:"text-purple-700 dark:text-purple-300",buttonClass:"bg-purple-600 hover:bg-purple-700"},codex:{name:"Codex",description:"OpenAI Codex AI assistant",bgClass:"bg-gray-100 dark:bg-gray-800/50",borderClass:"border-gray-300 dark:border-gray-600",textClass:"text-gray-900 dark:text-gray-100",subtextClass:"text-gray-700 dark:text-gray-300",buttonClass:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"}};function Hc({agent:t,authStatus:r,onLogin:s}){const{t:a}=We("settings"),n=Uc[t];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(ft,{provider:t,className:"w-6 h-6"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a(`agents.account.${t}.description`)})]})]}),e.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:a("agents.connectionStatus")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.loading?a("agents.authStatus.checkingAuth"):r!=null&&r.authenticated?a("agents.authStatus.loggedInAs",{email:r.email||a("agents.authStatus.authenticatedUser")}):a("agents.authStatus.notConnected")})]}),e.jsx("div",{children:r!=null&&r.loading?e.jsx(bt,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:a("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsx(bt,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:a("agents.authStatus.connected")}):e.jsx(bt,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:a("agents.authStatus.disconnected")})})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthenticate"):a("agents.login.title")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthDescription"):a("agents.login.description",{agent:n.name})})]}),e.jsxs(he,{onClick:s,className:`${n.buttonClass} text-white`,size:"sm",children:[e.jsx(vi,{className:"w-4 h-4 mr-2"}),r!=null&&r.authenticated?a("agents.login.reLoginButton"):a("agents.login.button")]})]})}),(r==null?void 0:r.error)&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:a("agents.error",{error:r.error})})})]})})]})}const Gc=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],Vc=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function qc({skipPermissions:t,setSkipPermissions:r,allowedTools:s,setAllowedTools:a,disallowedTools:n,setDisallowedTools:o,newAllowedTool:i,setNewAllowedTool:c,newDisallowedTool:u,setNewDisallowedTool:d}){const{t:m}=We("settings"),h=x=>{x&&!s.includes(x)&&(a([...s,x]),c(""))},p=x=>{a(s.filter(b=>b!==x))},g=x=>{x&&!n.includes(x)&&(o([...n,x]),d(""))},f=x=>{o(n.filter(b=>b!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.claudeDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:i,onChange:x=>c(x.target.value),placeholder:m("permissions.allowedTools.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),h(i))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>h(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedTools.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Gc.map(x=>e.jsx(he,{variant:"outline",size:"sm",onClick:()=>h(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>p(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedTools.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:u,onChange:x=>d(x.target.value),placeholder:m("permissions.blockedTools.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(u))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>g(u),disabled:!u,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>f(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedTools.empty")})]})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:m("permissions.toolExamples.title")}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," ",m("permissions.toolExamples.bashGitLog")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," ",m("permissions.toolExamples.bashGitDiff")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," ",m("permissions.toolExamples.write")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," ",m("permissions.toolExamples.bashRm")]})]})]})]})}function Kc({skipPermissions:t,setSkipPermissions:r,allowedCommands:s,setAllowedCommands:a,disallowedCommands:n,setDisallowedCommands:o,newAllowedCommand:i,setNewAllowedCommand:c,newDisallowedCommand:u,setNewDisallowedCommand:d}){const{t:m}=We("settings"),h=x=>{x&&!s.includes(x)&&(a([...s,x]),c(""))},p=x=>{a(s.filter(b=>b!==x))},g=x=>{x&&!n.includes(x)&&(o([...n,x]),d(""))},f=x=>{o(n.filter(b=>b!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.cursorDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:i,onChange:x=>c(x.target.value),placeholder:m("permissions.allowedCommands.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),h(i))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>h(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedCommands.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Vc.map(x=>e.jsx(he,{variant:"outline",size:"sm",onClick:()=>h(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>p(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedCommands.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:u,onChange:x=>d(x.target.value),placeholder:m("permissions.blockedCommands.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(u))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>g(u),disabled:!u,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>f(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedCommands.empty")})]})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:m("permissions.shellExamples.title")}),e.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," ",m("permissions.shellExamples.ls")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," ",m("permissions.shellExamples.gitStatus")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," ",m("permissions.shellExamples.npmInstall")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," ",m("permissions.shellExamples.rmRf")]})]})]})]})}function Jc({permissionMode:t,setPermissionMode:r}){const{t:s}=We("settings");return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:s("permissions.codex.permissionMode")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("permissions.codex.description")}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("default"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>r("default"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:s("permissions.codex.modes.default.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("permissions.codex.modes.default.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("acceptEdits"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>r("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:s("permissions.codex.modes.acceptEdits.title")}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:s("permissions.codex.modes.acceptEdits.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("bypassPermissions"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>r("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:[s("permissions.codex.modes.bypassPermissions.title"),e.jsx($t,{className:"w-4 h-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:s("permissions.codex.modes.bypassPermissions.description")})]})]})}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:s("permissions.codex.technicalDetails")}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.default.title"),":"]})," ",s("permissions.codex.technicalInfo.default")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.acceptEdits.title"),":"]})," ",s("permissions.codex.technicalInfo.acceptEdits")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.bypassPermissions.title"),":"]})," ",s("permissions.codex.technicalInfo.bypassPermissions")]}),e.jsx("p",{className:"text-xs opacity-75",children:s("permissions.codex.technicalInfo.overrideNote")})]})]})]})})}function $s({agent:t,...r}){return t==="claude"?e.jsx(qc,{...r}):t==="cursor"?e.jsx(Kc,{...r}):t==="codex"?e.jsx(Jc,{...r}):null}const Yc=t=>{switch(t){case"stdio":return e.jsx(vt,{className:"w-4 h-4"});case"sse":return e.jsx(tr,{className:"w-4 h-4"});case"http":return e.jsx(qs,{className:"w-4 h-4"});default:return e.jsx($r,{className:"w-4 h-4"})}};function Qc({servers:t,onAdd:r,onEdit:s,onDelete:a,onTest:n,onDiscoverTools:o,testResults:i,serverTools:c,toolsLoading:u}){const{t:d}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d("mcpServers.description.claude")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),d("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(m=>{var h,p,g,f;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[Yc(m.type),e.jsx("span",{className:"font-medium text-foreground",children:m.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:m.type}),e.jsx(bt,{variant:"outline",className:"text-xs",children:m.scope==="local"?d("mcpServers.scope.local"):m.scope==="user"?d("mcpServers.scope.user"):m.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[m.type==="stdio"&&((h=m.config)==null?void 0:h.command)&&e.jsxs("div",{children:[d("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.command})]}),(m.type==="sse"||m.type==="http")&&((p=m.config)==null?void 0:p.url)&&e.jsxs("div",{children:[d("mcpServers.config.url"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.url})]}),((g=m.config)==null?void 0:g.args)&&m.config.args.length>0&&e.jsxs("div",{children:[d("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.args.join(" ")})]})]}),(i==null?void 0:i[m.id])&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[m.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:e.jsx("div",{className:"font-medium",children:i[m.id].message})}),(c==null?void 0:c[m.id])&&((f=c[m.id].tools)==null?void 0:f.length)>0&&e.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[e.jsxs("div",{className:"font-medium",children:[d("mcpServers.tools.title")," ",d("mcpServers.tools.count",{count:c[m.id].tools.length})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[c[m.id].tools.slice(0,5).map((x,b)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:x.name},b)),c[m.id].tools.length>5&&e.jsx("span",{className:"text-xs opacity-75",children:d("mcpServers.tools.more",{count:c[m.id].tools.length-5})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(m),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:d("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(m.id,m.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:d("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},m.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:d("mcpServers.empty")})]})]})}function Xc({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.cursor")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(vt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},o.name||o.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]})]})}function Zc({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.codex")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i,c,u;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(vt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]}),((c=o.config)==null?void 0:c.args)&&o.config.args.length>0&&e.jsxs("div",{children:[n("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.args.join(" ")})]}),((u=o.config)==null?void 0:u.env)&&Object.keys(o.config.env).length>0&&e.jsxs("div",{children:[n("mcpServers.config.environment"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(o.config.env).map(([d,m])=>`${d}=${m}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},o.name)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]}),e.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:n("mcpServers.help.title")}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:n("mcpServers.help.description")})]})]})}function _s({agent:t,...r}){return t==="claude"?e.jsx(Qc,{...r}):t==="cursor"?e.jsx(Xc,{...r}):t==="codex"?e.jsx(Zc,{...r}):null}const ed=[{name:"filesystem",description:"Read/write local files and directories",category:"Files & Code",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","/path"]}},{name:"github",description:"GitHub repos, issues, and PRs",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-github"]}},{name:"postgres",description:"Query PostgreSQL databases",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-postgres"]}},{name:"brave-search",description:"Web search via Brave Search API",category:"AI & Search",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-brave-search"]}},{name:"memory",description:"Persistent memory store for AI agents",category:"AI & Search",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-memory"]}},{name:"puppeteer",description:"Browser automation and scraping",category:"DevOps",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-puppeteer"]}},{name:"sqlite",description:"Query SQLite databases",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-sqlite"]}},{name:"fetch",description:"HTTP fetch and web content retrieval",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-fetch"]}}],td={"Files & Code":"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300","Data & APIs":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300","AI & Search":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300",DevOps:"bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-300"};function rd(){const[t,r]=l.useState([]),[s,a]=l.useState(!0),[n,o]=l.useState(null),[i,c]=l.useState(""),u=l.useCallback(async()=>{a(!0);try{const g=await(await Me("/api/mcp/config/read")).json();g.success&&g.servers&&r(g.servers)}catch{}a(!1)},[]);l.useEffect(()=>{u();const p=window.location.origin;c(`${p}/mcp`)},[u]);const d=async p=>{o(p.name);try{(await Me("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:p.name,config:{command:p.installConfig.command,args:p.installConfig.args}})})).ok&&await u()}catch{}o(null)},m=p=>t.some(g=>g.name===p),h=p=>{navigator.clipboard.writeText(p)};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Installed Servers"}),e.jsx("button",{onClick:()=>void u(),className:"ml-auto text-sm text-muted-foreground hover:text-foreground transition-colors",title:"Refresh",children:e.jsx("svg",{className:`w-4 h-4 ${s?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading servers..."]}):t.length===0?e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-4 py-4 border border-border/30",children:"No MCP servers installed. Browse the directory below to get started."}):e.jsx("div",{className:"grid gap-2",children:t.map(p=>{var g,f;return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-card border border-border/50 rounded-lg",children:[e.jsx("svg",{className:"w-4 h-4 text-primary flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name}),p.type==="stdio"&&((g=p.config)==null?void 0:g.command)&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:[p.config.command," ",p.config.args?p.config.args.join(" "):""]}),(p.type==="http"||p.type==="sse")&&((f=p.config)==null?void 0:f.url)&&e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:p.config.url})]}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.type==="stdio"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":p.type==="sse"?"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300"}`,children:p.type}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.scope==="user"?"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300"}`,children:p.scope})]},p.id)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Server Directory"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Popular MCP servers"})]}),e.jsx("div",{className:"grid gap-2",children:ed.map(p=>{const g=m(p.name);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/20 border border-border/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${td[p.category]||"bg-gray-100 text-gray-600"}`,children:p.category})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:p.description})]}),g?e.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 font-medium flex items-center gap-1 flex-shrink-0",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Installed"]}):e.jsx("button",{onClick:()=>void d(p),disabled:n===p.name,className:"text-xs px-3 py-1.5 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 font-medium transition-colors flex-shrink-0 min-h-[36px]",children:n===p.name?"Installing...":"Install"})]},p.name)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Your Upfyn MCP Server"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Connect external AI clients (Claude Desktop, Cursor, etc.) to your Upfyn instance using MCP."}),e.jsxs("div",{className:"bg-muted/30 border border-border/30 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"MCP Endpoint"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{className:"flex-1 text-sm bg-card border border-border rounded px-3 py-1.5 font-mono text-foreground truncate",children:i}),e.jsx("button",{onClick:()=>h(i),className:"px-2.5 py-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",title:"Copy",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Claude Desktop Config"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{className:"flex-1 text-xs bg-card border border-border rounded px-3 py-1.5 font-mono text-foreground overflow-x-auto",children:`{ "mcpServers": { "upfyn": { "url": "${i}" } } }`}),e.jsx("button",{onClick:()=>h(`{ "mcpServers": { "upfyn": { "url": "${i}" } } }`),className:"px-2.5 py-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 min-w-[44px] min-h-[44px] flex items-center justify-center",title:"Copy config",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})]})]})]})}function _o({compact:t=!1}){const{i18n:r,t:s}=We("settings"),a=n=>{const o=n.target.value;r.changeLanguage(o)};return t?e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(eo,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s("account.language")]}),e.jsx("select",{value:r.language,onChange:a,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400",children:Pa.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:s("account.languageLabel")}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("account.languageDescription")})]}),e.jsx("select",{value:r.language,onChange:a,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-36",children:Pa.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]})})}function sd(){const[t,r]=l.useState([]),[s,a]=l.useState(!0),[n,o]=l.useState(null),[i,c]=l.useState(!1),u=async()=>{try{const f=await Me("/api/sessions");if(f.ok){const x=await f.json();r(x.sessions||[])}}catch{}a(!1)};l.useEffect(()=>{u();const f=setInterval(u,1e4);return()=>clearInterval(f)},[]);const d=async(f,x)=>{o(f);try{await Me(`/api/sessions/${f}/abort`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:x})}),await u()}catch{}o(null)},m=async()=>{c(!0);try{await Me("/api/sessions/abort-all",{method:"POST"}),await u()}catch{}c(!1)},h=f=>{if(!f)return"";const x=Date.now()-new Date(f).getTime(),b=Math.floor(x/1e3);if(b<60)return`${b}s`;const N=Math.floor(b/60);return N<60?`${N}m`:`${Math.floor(N/60)}h ${N%60}m`},p=f=>({claude:"Claude",cursor:"Cursor",codex:"Codex"})[f]||f,g=f=>({claude:"text-orange-500",cursor:"text-blue-500",codex:"text-green-500"})[f]||"text-gray-500";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Ks,{className:"w-5 h-5"})," Active Sessions"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:u,className:"text-sm text-muted-foreground hover:text-foreground flex items-center gap-1",children:[e.jsx(Vs,{className:"w-3.5 h-3.5"})," Refresh"]}),t.length>0&&e.jsxs("button",{onClick:m,disabled:i,className:"text-sm text-red-500 hover:text-red-400 flex items-center gap-1 disabled:opacity-50",children:[e.jsx(za,{className:"w-3.5 h-3.5"})," ",i?"Aborting...":"Abort All"]})]})]}),s?e.jsx("div",{className:"text-center text-muted-foreground text-sm py-8",children:"Loading sessions..."}):t.length===0?e.jsxs("div",{className:"bg-muted/30 border border-border rounded-lg p-8 text-center",children:[e.jsx(Ks,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No active sessions"}),e.jsx("p",{className:"text-muted-foreground/60 text-xs mt-1",children:"Sessions appear here when you run Claude, Cursor, or Codex commands"})]}):e.jsx("div",{className:"border border-border rounded-lg overflow-hidden divide-y divide-border",children:t.map(f=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-mono text-foreground truncate",children:f.sessionId}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:`text-xs font-medium ${g(f.provider)}`,children:p(f.provider)}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium ${f.status==="active"?"bg-green-500/10 text-green-500 dark:text-green-400":"bg-gray-500/10 text-gray-500"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.status==="active"?"bg-green-500":"bg-gray-400"}`}),f.status]}),f.startedAt&&e.jsx("span",{className:"text-xs text-muted-foreground",children:h(f.startedAt)})]})]}),e.jsx("button",{onClick:()=>d(f.sessionId,f.provider),disabled:n===f.sessionId,className:"p-1.5 rounded hover:bg-red-500/10 text-red-500 hover:text-red-400 transition-colors disabled:opacity-50",title:"Abort session",children:e.jsx(za,{className:"w-4 h-4"})})]},f.sessionId))})]})}function ad({isOpen:t,onClose:r,projects:s=[],initialTab:a="agents"}){var Wr,et,It,Ms;const{isDarkMode:n,toggleDarkMode:o}=pa(),{t:i}=We("settings"),{addToast:c}=hr(),{confirm:u,dialogProps:d,ConfirmDialog:m}=Sa(),[h,p]=l.useState([]),[g,f]=l.useState([]),[x,b]=l.useState(""),[N,j]=l.useState(""),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState(null),[E,T]=l.useState("name"),[W,S]=l.useState([]),[O,H]=l.useState(!1),[R,A]=l.useState(null),[z,J]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[re,G]=l.useState(!1),[ie,$]=l.useState({}),[Z,te]=l.useState({}),[Q,_]=l.useState({}),[F,q]=l.useState(a),[U,B]=l.useState(""),[ee,V]=l.useState("claude"),[w,M]=l.useState("account"),[Y,se]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[de,je]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[ge,Re]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[Ne,De]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Ue,_e]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[L,K]=l.useState([]),[pe,ye]=l.useState([]),[Ie,Fe]=l.useState(!1),[Se,Oe]=l.useState(""),[ne,fe]=l.useState(""),[Ee,Le]=l.useState([]),[Pe,Ae]=l.useState([]),[Ge,ae]=l.useState("default"),[be,ze]=l.useState(!1),[Ce,Ye]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[lt,dt]=l.useState(null),[Tt,At]=l.useState(!1),[wt,Ft]=l.useState(!1),[le,ue]=l.useState(""),[ce,we]=l.useState(null),[He,Qe]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Xe,ut]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Vt,ht]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),jt=async()=>{try{const P=await Me("/api/cursor/mcp");if(P.ok){const X=await P.json();Le(X.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(P){console.error("Error fetching Cursor MCP servers:",P)}},st=async()=>{try{const P=await Me("/api/codex/mcp/config/read");if(P.ok){const oe=await P.json();if(oe.success&&oe.servers){Ae(oe.servers);return}}const X=await Me("/api/codex/mcp/cli/list");if(X.ok){const oe=await X.json();if(oe.success&&oe.servers){const ve=oe.servers.map(Ke=>({id:Ke.name,name:Ke.name,type:Ke.type||"stdio",scope:"user",config:{command:Ke.command||"",args:Ke.args||[],env:Ke.env||{}}}));Ae(ve)}}}catch(P){console.error("Error fetching Codex MCP servers:",P)}},tt=async()=>{try{const P=await Me("/api/mcp/config/read");if(P.ok){const ve=await P.json();if(ve.success&&ve.servers){S(ve.servers);return}}const X=await Me("/api/mcp/cli/list");if(X.ok){const ve=await X.json();if(ve.success&&ve.servers){const Ke=ve.servers.map(nt=>({id:nt.name,name:nt.name,type:nt.type,scope:"user",config:{command:nt.command||"",args:nt.args||[],env:nt.env||{},url:nt.url||"",headers:nt.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));S(Ke);return}}const oe=await Me("/api/mcp/servers?scope=user");if(oe.ok){const ve=await oe.json();S(ve.servers||[])}else console.error("Failed to fetch MCP servers")}catch(P){console.error("Error fetching MCP servers:",P)}},zt=async P=>{var X,oe,ve,Ke,nt;try{R&&await or(R.id,"user");const cr=await Me("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath,command:(X=P.config)==null?void 0:X.command,args:((oe=P.config)==null?void 0:oe.args)||[],url:(ve=P.config)==null?void 0:ve.url,headers:((Ke=P.config)==null?void 0:Ke.headers)||{},env:((nt=P.config)==null?void 0:nt.env)||{}})});if(cr.ok){const Ur=await cr.json();if(Ur.success)return await tt(),!0;throw new Error(Ur.error||"Failed to save server via Claude CLI")}else{const Ur=await cr.json();throw new Error(Ur.error||"Failed to save server")}}catch(cr){throw console.error("Error saving MCP server:",cr),cr}},or=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/cli/remove/${P}?scope=${X}`,{method:"DELETE"});if(oe.ok){const ve=await oe.json();if(ve.success)return await tt(),!0;throw new Error(ve.error||"Failed to delete server via Claude CLI")}else{const ve=await oe.json();throw new Error(ve.error||"Failed to delete server")}}catch(oe){throw console.error("Error deleting MCP server:",oe),oe}},bs=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/servers/${P}/test?scope=${X}`,{method:"POST"});if(oe.ok)return(await oe.json()).testResult;{const ve=await oe.json();throw new Error(ve.error||"Failed to test server")}}catch(oe){throw console.error("Error testing MCP server:",oe),oe}},ys=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/servers/${P}/tools?scope=${X}`,{method:"POST"});if(oe.ok)return(await oe.json()).toolsResult;{const ve=await oe.json();throw new Error(ve.error||"Failed to discover tools")}}catch(oe){throw console.error("Error discovering MCP tools:",oe),oe}},vs=async P=>{var X,oe,ve;try{lt&&await vr(lt.id);const Ke=await Me("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,command:(X=P.config)==null?void 0:X.command,args:((oe=P.config)==null?void 0:oe.args)||[],env:((ve=P.config)==null?void 0:ve.env)||{}})});if(Ke.ok){const nt=await Ke.json();if(nt.success)return await st(),!0;throw new Error(nt.error||"Failed to save Codex MCP server")}else{const nt=await Ke.json();throw new Error(nt.error||"Failed to save server")}}catch(Ke){throw console.error("Error saving Codex MCP server:",Ke),Ke}},vr=async P=>{try{const X=await Me(`/api/codex/mcp/cli/remove/${P}`,{method:"DELETE"});if(X.ok){const oe=await X.json();if(oe.success)return await st(),!0;throw new Error(oe.error||"Failed to delete Codex MCP server")}else{const oe=await X.json();throw new Error(oe.error||"Failed to delete server")}}catch(X){throw console.error("Error deleting Codex MCP server:",X),X}},ir=()=>{Ye({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),dt(null),ze(!1)},_r=(P=null)=>{var X,oe,ve;P?(dt(P),Ye({name:P.name,type:P.type||"stdio",config:{command:((X=P.config)==null?void 0:X.command)||"",args:((oe=P.config)==null?void 0:oe.args)||[],env:((ve=P.config)==null?void 0:ve.env)||{}}})):ir(),ze(!0)},ks=async P=>{P.preventDefault(),At(!0);try{lt&&await vr(lt.name),await vs(Ce),ir(),v("success")}catch(X){c(`Error: ${X.message}`,"error"),v("error")}finally{At(!1)}},ws=async P=>{if(await u({title:i("mcp.deleteTitle","Delete MCP Server"),message:i("mcp.confirmDelete","Are you sure you want to delete this MCP server?"),confirmLabel:i("mcp.deleteButton","Delete"),cancelLabel:i("common:cancel","Cancel")}))try{await vr(P),v("success")}catch(oe){c(`Error: ${oe.message}`,"error"),v("error")}};l.useEffect(()=>{t&&(js(),Fr(),zr(),Rr(),q(a))},[t,a]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",Y),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Y]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",de.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[de]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",ge.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ge]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",Ne.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ne]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Ue),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ue]);const js=async()=>{try{const P=localStorage.getItem("claude-settings");if(P){const ve=JSON.parse(P);p(ve.allowedTools||[]),f(ve.disallowedTools||[]),k(ve.skipPermissions||!1),T(ve.projectSortOrder||"name")}else p([]),f([]),k(!1),T("name");const X=localStorage.getItem("cursor-tools-settings");if(X){const ve=JSON.parse(X);K(ve.allowedCommands||[]),ye(ve.disallowedCommands||[]),Fe(ve.skipPermissions||!1)}else K([]),ye([]),Fe(!1);const oe=localStorage.getItem("codex-settings");if(oe){const ve=JSON.parse(oe);ae(ve.permissionMode||"default")}else ae("default");await tt(),await jt(),await st()}catch(P){console.error("Error loading tool settings:",P),p([]),f([]),k(!1),T("name")}},Fr=async()=>{try{const P=await Me("/api/cli/claude/status");if(P.ok){const X=await P.json();Qe({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else Qe({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Claude auth status:",P),Qe({authenticated:!1,email:null,loading:!1,error:P.message})}},zr=async()=>{try{const P=await Me("/api/cli/cursor/status");if(P.ok){const X=await P.json();ut({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else ut({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Cursor auth status:",P),ut({authenticated:!1,email:null,loading:!1,error:P.message})}},Rr=async()=>{try{const P=await Me("/api/cli/codex/status");if(P.ok){const X=await P.json();ht({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else ht({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Codex auth status:",P),ht({authenticated:!1,email:null,loading:!1,error:P.message})}},Ns=()=>{ue("claude"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},lr=()=>{ue("cursor"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},Cs=()=>{ue("codex"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},Ss=P=>{P===0&&(v("success"),le==="claude"?Fr():le==="cursor"?zr():le==="codex"&&Rr())},Or=()=>{D(!0),v(null);try{const P={allowedTools:h,disallowedTools:g,skipPermissions:y,projectSortOrder:E,lastUpdated:new Date().toISOString()},X={allowedCommands:L,disallowedCommands:pe,skipPermissions:Ie,lastUpdated:new Date().toISOString()},oe={permissionMode:Ge,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(P)),localStorage.setItem("cursor-tools-settings",JSON.stringify(X)),localStorage.setItem("codex-settings",JSON.stringify(oe)),v("success"),setTimeout(()=>{r()},1e3)}catch(P){console.error("Error saving tool settings:",P),v("error")}finally{D(!1)}},qt=()=>{J({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),A(null),H(!1),B("")},Br=(P=null)=>{P?(A(P),J({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath||"",config:{...P.config},raw:P.raw,importMode:"form",jsonInput:""})):qt(),H(!0)},Es=async P=>{P.preventDefault(),G(!0);try{if(z.importMode==="json"){const X=await Me("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:z.name,jsonConfig:z.jsonInput,scope:z.scope,projectPath:z.projectPath})});if(X.ok){const oe=await X.json();if(oe.success)await tt(),qt(),v("success");else throw new Error(oe.error||"Failed to add server via JSON")}else{const oe=await X.json();throw new Error(oe.error||"Failed to add server")}}else await zt(z),qt(),v("success")}catch(X){c(`Error: ${X.message}`,"error"),v("error")}finally{G(!1)}},Ts=async(P,X)=>{if(await u({title:i("mcp.deleteTitle","Delete MCP Server"),message:i("mcp.confirmDelete","Are you sure you want to delete this MCP server?"),confirmLabel:i("mcp.deleteButton","Delete"),cancelLabel:i("common:cancel","Cancel")}))try{await or(P,X),v("success")}catch(ve){c(`Error: ${ve.message}`,"error"),v("error")}},As=async(P,X)=>{try{$({...ie,[P]:{loading:!0}});const oe=await bs(P,X);$({...ie,[P]:oe})}catch(oe){$({...ie,[P]:{success:!1,message:oe.message,details:[]}})}},Is=async(P,X)=>{try{_({...Q,[P]:!0});const oe=await ys(P,X);te({...Z,[P]:oe})}catch{te({...Z,[P]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{_({...Q,[P]:!1})}},Kt=(P,X)=>{J(oe=>({...oe,config:{...oe.config,[P]:X}}))};return t?e.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[e.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Dt,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),e.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),e.jsx(he,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"border-b border-border",children:e.jsxs("div",{className:"flex overflow-x-auto scrollbar-none px-4 md:px-6",children:[e.jsx("button",{onClick:()=>q("agents"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.agents")}),e.jsx("button",{onClick:()=>q("appearance"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),e.jsxs("button",{onClick:()=>q("git"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(br,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.git")]}),e.jsxs("button",{onClick:()=>q("api"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(xa,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),e.jsx("button",{onClick:()=>q("tasks"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.tasks")}),e.jsxs("button",{onClick:()=>q("mcp"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx($r,{className:"w-4 h-4 inline mr-2"}),"MCP Hub"]}),e.jsxs("button",{onClick:()=>q("sessions"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="sessions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Ks,{className:"w-4 h-4 inline mr-2"}),"Sessions"]})]})}),e.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[F==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:F==="appearance"&&e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.darkMode.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.darkMode.description")})]}),e.jsxs("button",{onClick:o,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":n,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${n?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:n?e.jsx(Js,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Ys,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx(_o,{})}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.projectSorting.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.projectSorting.description")})]}),e.jsxs("select",{value:E,onChange:P=>T(P.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[e.jsx("option",{value:"name",children:i("appearanceSettings.projectSorting.alphabetical")}),e.jsx("option",{value:"date",children:i("appearanceSettings.projectSorting.recentActivity")})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:i("appearanceSettings.codeEditor.title")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.theme.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.theme.description")})]}),e.jsxs("button",{onClick:()=>se(Y==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Y==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${Y==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:Y==="dark"?e.jsx(Js,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Ys,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.wordWrap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.wordWrap.description")})]}),e.jsxs("button",{onClick:()=>je(!de),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":de,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${de?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.showMinimap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.showMinimap.description")})]}),e.jsxs("button",{onClick:()=>Re(!ge),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ge,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${ge?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),e.jsxs("button",{onClick:()=>De(!Ne),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ne,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${Ne?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),e.jsxs("select",{value:Ue,onChange:P=>_e(P.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[e.jsx("option",{value:"10",children:"10px"}),e.jsx("option",{value:"11",children:"11px"}),e.jsx("option",{value:"12",children:"12px"}),e.jsx("option",{value:"13",children:"13px"}),e.jsx("option",{value:"14",children:"14px"}),e.jsx("option",{value:"15",children:"15px"}),e.jsx("option",{value:"16",children:"16px"}),e.jsx("option",{value:"18",children:"18px"}),e.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),F==="git"&&e.jsx(Rc,{}),F==="agents"&&e.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[e.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex",children:[e.jsx(dr,{agentId:"claude",authStatus:He,isSelected:ee==="claude",onClick:()=>V("claude"),isMobile:!0}),e.jsx(dr,{agentId:"cursor",authStatus:Xe,isSelected:ee==="cursor",onClick:()=>V("cursor"),isMobile:!0}),e.jsx(dr,{agentId:"codex",authStatus:Vt,isSelected:ee==="codex",onClick:()=>V("codex"),isMobile:!0})]})}),e.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"p-2",children:[e.jsx(dr,{agentId:"claude",authStatus:He,isSelected:ee==="claude",onClick:()=>V("claude")}),e.jsx(dr,{agentId:"cursor",authStatus:Xe,isSelected:ee==="cursor",onClick:()=>V("cursor")}),e.jsx(dr,{agentId:"codex",authStatus:Vt,isSelected:ee==="codex",onClick:()=>V("codex")})]})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[e.jsx("button",{onClick:()=>M("account"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.account")}),e.jsx("button",{onClick:()=>M("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.permissions")}),e.jsx("button",{onClick:()=>M("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.mcpServers")})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[w==="account"&&e.jsx(Hc,{agent:ee,authStatus:ee==="claude"?He:ee==="cursor"?Xe:Vt,onLogin:ee==="claude"?Ns:ee==="cursor"?lr:Cs}),w==="permissions"&&ee==="claude"&&e.jsx($s,{agent:"claude",skipPermissions:y,setSkipPermissions:k,allowedTools:h,setAllowedTools:p,disallowedTools:g,setDisallowedTools:f,newAllowedTool:x,setNewAllowedTool:b,newDisallowedTool:N,setNewDisallowedTool:j}),w==="permissions"&&ee==="cursor"&&e.jsx($s,{agent:"cursor",skipPermissions:Ie,setSkipPermissions:Fe,allowedCommands:L,setAllowedCommands:K,disallowedCommands:pe,setDisallowedCommands:ye,newAllowedCommand:Se,setNewAllowedCommand:Oe,newDisallowedCommand:ne,setNewDisallowedCommand:fe}),w==="permissions"&&ee==="codex"&&e.jsx($s,{agent:"codex",permissionMode:Ge,setPermissionMode:ae}),w==="mcp"&&ee==="claude"&&e.jsx(_s,{agent:"claude",servers:W,onAdd:()=>Br(),onEdit:P=>Br(P),onDelete:(P,X)=>Ts(P,X),onTest:(P,X)=>As(P,X),onDiscoverTools:(P,X)=>Is(P,X),testResults:ie,serverTools:Z,toolsLoading:Q}),w==="mcp"&&ee==="cursor"&&e.jsx(_s,{agent:"cursor",servers:Ee,onAdd:()=>{},onEdit:P=>{},onDelete:P=>{}}),w==="mcp"&&ee==="codex"&&e.jsx(_s,{agent:"codex",servers:Pe,onAdd:()=>_r(),onEdit:P=>_r(P),onDelete:P=>ws(P)})]})]})]}),O&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(R?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(he,{variant:"ghost",size:"sm",onClick:qt,children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:Es,className:"p-4 space-y-4",children:[!R&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.form")}),e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.json")})]}),z.importMode==="form"&&R&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.scope.label")}),e.jsxs("div",{className:"flex items-center gap-2",children:[z.scope==="user"?e.jsx(qs,{className:"w-4 h-4"}):e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:z.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),z.scope==="local"&&z.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",z.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),z.importMode==="form"&&!R&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.scope.label")," *"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(qs,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.projectLocal")})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:z.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),z.scope==="local"&&!R&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.selectProject")," *"]}),e.jsxs("select",{value:z.projectPath,onChange:P=>J(X=>({...X,projectPath:P.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:z.scope==="local",children:[e.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),s.map(P=>e.jsx("option",{value:P.path||P.fullPath,children:P.displayName||P.name},P.name))]}),z.projectPath&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:z.projectPath})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:z.importMode==="json"?"md:col-span-2":"",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),e.jsx(Ze,{value:z.name,onChange:P=>{J(X=>({...X,name:P.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),z.importMode==="form"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.transportType")," *"]}),e.jsxs("select",{value:z.type,onChange:P=>{J(X=>({...X,type:P.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"sse",children:"SSE"}),e.jsx("option",{value:"http",children:"HTTP"})]})]})]}),R&&z.raw&&z.importMode==="form"&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:i("mcpForm.configDetails",{configFile:R.scope==="global"?"~/.claude.json":"project config"})}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(z.raw,null,2)})]}),z.importMode==="json"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.jsonConfig")," *"]}),e.jsx("textarea",{value:z.jsonInput,onChange:P=>{J(X=>({...X,jsonInput:P.target.value}));try{if(P.target.value.trim()){const X=JSON.parse(P.target.value);X.type?X.type==="stdio"&&!X.command?B(i("mcpForm.validation.stdioRequiresCommand")):(X.type==="http"||X.type==="sse")&&!X.url?B(i("mcpForm.validation.httpRequiresUrl",{type:X.type})):B(""):B(i("mcpForm.validation.missingType"))}}catch{P.target.value.trim()?B(i("mcpForm.validation.invalidJson")):B("")}},className:`w-full px-3 py-2 border ${U?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MermaidBlock-BuBc_G-F.js","assets/vendor-syntax-DuHI9Ok6.js","assets/vendor-react-96lCPsRK.js","assets/vendor-markdown-CimbIo6Y.js","assets/vendor-diff-DNQpbhrT.js","assets/MarkdownPreview-DHmk3qzu.js","assets/FileTree-CbJF7m5P.js","assets/index-DtIQCXd6.js","assets/vendor-icons-BaD0x9SL.js","assets/vendor-i18n-DCFGyhQR.js","assets/index-BFuqS0tY.css","assets/LoginModal-Bk9mxZsi.js","assets/vendor-xterm-CZq1hqo1.js","assets/vendor-xterm-qxJ8_QYu.css","assets/vendor-canvas-D39yWul6.js","assets/vendor-mermaid-CH7SGc99.js","assets/vendor-canvas-BZV40eAE.css","assets/vendor-codemirror-CbtmxxaB.js","assets/GitPanel-avzqm9Zj.js","assets/WorkflowsPanel-BOaVEpdu.js","assets/DashboardPanel-DmHbSyTP.js","assets/CanvasWorkspace-DksIgrfl.js","assets/PreviewPanel-CqCa92Tf.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as l,j as e,R as it,i as Cr,g as Jn,h as Yn,u as hi}from"./vendor-react-96lCPsRK.js";import{a as hr,b as Be,c as ps,d as Me,e as Lr,l as Pa,f as pa,g as fr,u as Qn}from"./index-DtIQCXd6.js";import{S as Dt,b as Ut,c as $a,R as Vs,P as at,d as fi,e as Ar,X as Ve,F as Zr,f as xs,g as Pr,h as Ir,i as yt,j as Lt,k as bi,l as Pt,m as er,n as mr,o as _a,p as Mr,q as rr,W as Xn,G as br,K as xa,L as Sr,r as ga,E as sr,s as Zn,T as $t,t as vt,u as ha,v as Fa,w as yi,x as vi,y as fa,z as $r,A as qs,Z as tr,B as eo,D as Ks,H as Js,J as Ys,N as za,O as ki,Q as wi,U as ba,V as gs,Y as to,_ as es,$ as gt,a0 as ur,a as ji,a1 as ts,a2 as Ni,a3 as ro,a4 as ya,a5 as so,a6 as Qs,a7 as ao,a8 as Ci,a9 as Si,aa as Ei,ab as Ti,M as va,ac as Ai,ad as no,ae as Ii,af as oo,ag as io,ah as Mi,ai as Di,aj as Li,ak as Pi,al as $i,am as _i,an as Fi,ao as zi,ap as Ri,aq as Oi,ar as Bi,as as Wi}from"./vendor-icons-BaD0x9SL.js";import{C as Ui,a as Hi,b as Gi,u as We,L as Vi,S as lo}from"./LoginModal-Bk9mxZsi.js";import{h as co,p as uo,b as kt}from"./vendor-syntax-DuHI9Ok6.js";import{a as qi,b as Ki,c as Ji,M as Yi}from"./vendor-markdown-CimbIo6Y.js";import{F as mo,E as Wt,S as Qi,V as ka,c as pr,a as Xi,f as Zi,u as el,b as tl,T as Ra,l as rl,h as Oa,s as sl,d as al,e as nl,g as ol,i as Ds,j as il,R as po,o as xo,k as ll,m as go,n as cl,p as dl,q as ul,r as ml,t as pl,v as xl}from"./vendor-codemirror-CbtmxxaB.js";const Ba=t=>typeof window>"u"?!1:window.innerWidth<t,Wa=()=>{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 wa(t={}){const{mobileBreakpoint:r=768,trackMobile:s=!0,trackPWA:a=!0}=t,[n,o]=l.useState(()=>s?Ba(r):!1),[i,c]=l.useState(()=>a?Wa():!1);return l.useEffect(()=>{if(!s||typeof window>"u")return;const u=()=>{o(Ba(r))};return u(),window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}},[r,s]),l.useEffect(()=>{if(!a||typeof window>"u")return;const u=window.matchMedia("(display-mode: standalone)"),d=()=>{c(Wa())};return d(),typeof u.addEventListener=="function"?(u.addEventListener("change",d),()=>{u.removeEventListener("change",d)}):(u.addListener(d),()=>{u.removeListener(d)})},[a]),{isMobile:n,isPWA:i}}const Ua="2.9.9",Ha="upfyn-version-dismissed",gl=(t,r)=>{const s=t.split(".").map(Number),a=r.split(".").map(Number);for(let n=0;n<Math.max(s.length,a.length);n++){const o=s[n]||0,i=a[n]||0;if(o!==i)return o-i}return 0},ho=(t,r)=>{const[s,a]=l.useState(!1),[n,o]=l.useState(null),[i,c]=l.useState(null);l.useEffect(()=>{const d=async()=>{try{const h=await fetch("https://registry.npmjs.org/upfynai-code/latest");if(!h.ok)return;const p=await h.json();if(p.version){const g=p.version;if(o(g),localStorage.getItem(Ha)===g){a(!1);return}a(gl(g,Ua)>0),c({title:`v${g}`,body:"",htmlUrl:"https://www.npmjs.com/package/upfynai-code",publishedAt:null})}}catch{}};d();const m=setInterval(d,1800*1e3);return()=>clearInterval(m)},[t,r]);const u=l.useCallback(()=>{n&&localStorage.setItem(Ha,n),a(!1)},[n]);return{updateAvailable:s,latestVersion:n,currentVersion:Ua,releaseInfo:i,dismissUpdate:u}},Yt={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0},rs=Object.keys(Yt),hl=new Set(rs),Ls="ui-preferences:sync",ss=(t,r)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return r},fl=(t,r)=>{try{const s=localStorage.getItem(t);if(s===null)return r;const a=JSON.parse(s);return ss(a,r)}catch{return r}},bl=t=>{if(typeof window>"u")return Yt;try{const r=localStorage.getItem(t);if(r){const s=JSON.parse(r);if(s&&typeof s=="object"&&!Array.isArray(s)){const a=s;return rs.reduce((n,o)=>(n[o]=ss(a[o],Yt[o]),n),{...Yt})}}}catch{}return rs.reduce((r,s)=>(r[s]=fl(s,Yt[s]),r),{...Yt})};function yl(t,r){switch(r.type){case"set":{const{key:s,value:a}=r;if(!hl.has(s))return t;const n=ss(a,t[s]);return t[s]===n?t:{...t,[s]:n}}case"set_many":{const s=r.value||{};let a=!1;const n={...t};for(const o of rs){if(!(o in s))continue;const i=s[o],c=ss(i,t[o]);n[o]!==c&&(n[o]=c,a=!0)}return a?n:t}case"reset":return{...Yt,...r.value||{}};default:return t}}function ja(t="uiPreferences"){const r=l.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[s,a]=l.useReducer(yl,t,bl);return l.useEffect(()=>{typeof window>"u"||(localStorage.setItem(t,JSON.stringify(s)),window.dispatchEvent(new CustomEvent(Ls,{detail:{storageKey:t,sourceId:r.current,value:s}})))},[s,t]),l.useEffect(()=>{if(typeof window>"u")return;const c=m=>{!m||typeof m!="object"||Array.isArray(m)||a({type:"set_many",value:m})},u=m=>{if(!(m.key!==t||m.newValue===null))try{const h=JSON.parse(m.newValue);c(h)}catch{}},d=m=>{const p=m.detail;!p||p.storageKey!==t||p.sourceId===r.current||c(p.value)};return window.addEventListener("storage",u),window.addEventListener(Ls,d),()=>{window.removeEventListener("storage",u),window.removeEventListener(Ls,d)}},[t]),{preferences:s,setPreference:(c,u)=>{a({type:"set",key:c,value:u})},setPreferences:c=>{a({type:"set_many",value:c})},resetPreferences:c=>{a({type:"reset",value:c})},dispatch:a}}const vl=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},kl=()=>{try{const t=localStorage.getItem("starredProjects");return t?new Set(JSON.parse(t)):new Set}catch{return new Set}},wl=t=>{try{localStorage.setItem("starredProjects",JSON.stringify([...t]))}catch{}},as=t=>t.__provider==="cursor"?new Date(t.createdAt||0):t.__provider==="codex"?new Date(t.createdAt||t.lastActivity||0):new Date(t.lastActivity||0),jl=(t,r)=>t.__provider==="cursor"?t.name||r("projects.untitledSession"):t.__provider==="codex"?t.summary||t.name||r("projects.codexSession"):t.summary||r("projects.newSession"),Nl=t=>t.__provider==="cursor"?String(t.createdAt||""):t.__provider==="codex"?String(t.createdAt||t.lastActivity||""):String(t.lastActivity||""),Cl=(t,r,s)=>{const a=as(t),n=Math.floor((r.getTime()-a.getTime())/(1e3*60));return{isCursorSession:t.__provider==="cursor",isCodexSession:t.__provider==="codex",isActive:n<10,sessionName:jl(t,s),sessionTime:Nl(t),messageCount:Number(t.messageCount||0)}},fo=(t,r)=>{const s=[...t.sessions||[],...r[t.name]||[]].map(o=>({...o,__provider:"claude"})),a=(t.cursorSessions||[]).map(o=>({...o,__provider:"cursor"})),n=(t.codexSessions||[]).map(o=>({...o,__provider:"codex"}));return[...s,...a,...n].sort((o,i)=>as(i).getTime()-as(o).getTime())},Ga=(t,r)=>{const s=fo(t,r);return s.length===0?new Date(0):s.reduce((a,n)=>{const o=as(n);return o>a?o:a},new Date(0))},Sl=(t,r,s,a)=>{const n=[...t];return n.sort((o,i)=>{const c=s.has(o.name),u=s.has(i.name);return c&&!u?-1:!c&&u?1:r==="date"?Ga(i,a).getTime()-Ga(o,a).getTime():(o.displayName||o.name).localeCompare(i.displayName||i.name)}),n},El=(t,r)=>{const s=r.trim().toLowerCase();return s?t.filter(a=>{const n=(a.displayName||a.name).toLowerCase(),o=a.name.toLowerCase();return n.includes(s)||o.includes(s)}):t},Tl=(t,r)=>{var n;const s=!!((n=t.taskmaster)!=null&&n.hasTaskmaster),a=!!(r!=null&&r.hasMCPServer&&(r!=null&&r.isConfigured));return s&&a?"fully-configured":s?"taskmaster-only":a?"mcp-only":"not-configured"},Al=t=>{const r=typeof t.fullPath=="string"&&t.fullPath.length>0?t.fullPath:typeof t.path=="string"?t.path:"";return{name:t.name,displayName:typeof t.displayName=="string"&&t.displayName.trim().length>0?t.displayName:t.name,fullPath:r,path:typeof t.path=="string"&&t.path.length>0?t.path:r}};function Il({projects:t,selectedProject:r,selectedSession:s,isLoading:a,isMobile:n,t:o,onRefresh:i,onProjectSelect:c,onSessionSelect:u,onSessionDelete:d,onProjectDelete:m,setCurrentProject:h,setSidebarVisible:p,sidebarVisible:g}){const{addToast:f}=hr(),[x,b]=l.useState(new Set),[N,j]=l.useState(null),[y,k]=l.useState(!1),[I,D]=l.useState(""),[C,v]=l.useState({}),[E,T]=l.useState({}),[W,S]=l.useState(new Set),[O,H]=l.useState(new Date),[R,A]=l.useState("name"),[z,J]=l.useState(!1),[re,G]=l.useState({}),[ie,$]=l.useState(null),[Z,te]=l.useState(""),[Q,_]=l.useState(""),[F,q]=l.useState(new Set),[U,B]=l.useState(null),[ee,V]=l.useState(null),[w,M]=l.useState(!1),[Y,se]=l.useState(()=>kl()),de=!n&&!g;l.useEffect(()=>{const ae=setInterval(()=>{H(new Date)},6e4);return()=>clearInterval(ae)},[]),l.useEffect(()=>{T({}),S(new Set),G({})},[t]),l.useEffect(()=>{r&&b(ae=>{if(ae.has(r.name))return ae;const be=new Set(ae);return be.add(r.name),be})},[s,r]),l.useEffect(()=>{if(t.length>0&&!a){const ae=new Set;t.forEach(be=>{be.sessions&&be.sessions.length>=0&&ae.add(be.name)}),S(ae)}},[t,a]),l.useEffect(()=>{const ae=()=>{A(vl())};ae();const be=Ce=>{Ce.key==="claude-settings"&&ae()};window.addEventListener("storage",be);const ze=setInterval(()=>{document.hasFocus()&&ae()},1e3);return()=>{window.removeEventListener("storage",be),clearInterval(ze)}},[]);const je=l.useCallback(ae=>be=>{const ze=be.target;ze.closest(".overflow-y-auto")||ze.closest("[data-scroll-container]")||(be.preventDefault(),be.stopPropagation(),ae())},[]),ge=l.useCallback(ae=>{b(be=>{const ze=new Set;return be.has(ae)||ze.add(ae),ze})},[]),Re=l.useCallback((ae,be)=>{u({...ae,__projectName:be})},[u]),Ne=l.useCallback(ae=>{se(be=>{const ze=new Set(be);return ze.has(ae)?ze.delete(ae):ze.add(ae),wl(ze),ze})},[]),De=l.useCallback(ae=>Y.has(ae),[Y]),Ue=l.useCallback(ae=>fo(ae,E),[E]),_e=l.useMemo(()=>t.map(ae=>{const be=re[ae.name];return be===void 0?ae:{...ae,sessionMeta:{...ae.sessionMeta,hasMore:be}}}),[re,t]),L=l.useMemo(()=>Sl(_e,R,Y,E),[E,R,_e,Y]),K=l.useMemo(()=>El(L,Q),[Q,L]),pe=l.useCallback(ae=>{j(ae.name),D(ae.displayName)},[]),ye=l.useCallback(()=>{j(null),D("")},[]),Ie=l.useCallback(async ae=>{try{(await Be.renameProject(ae,I)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(be){console.error("Error renaming project:",be)}finally{j(null),D("")}},[I]),Fe=l.useCallback((ae,be,ze,Ce="claude")=>{V({projectName:ae,sessionId:be,sessionTitle:ze,provider:Ce})},[]),Se=l.useCallback(async()=>{if(!ee)return;const{projectName:ae,sessionId:be,provider:ze}=ee;V(null),d==null||d(be);try{const Ce=ze==="codex"?await Be.deleteCodexSession(be):await Be.deleteSession(ae,be);Ce.ok||console.error("[Sidebar] Failed to delete session:",Ce.status)}catch(Ce){console.error("[Sidebar] Error deleting session:",Ce)}},[d,ee,o]),Oe=l.useCallback(ae=>{B({project:ae,sessionCount:Ue(ae).length})},[Ue]),ne=l.useCallback(async()=>{if(!U)return;const{project:ae,sessionCount:be}=U,ze=be===0;B(null),q(Ce=>new Set([...Ce,ae.name]));try{const Ce=await Be.deleteProject(ae.name,!ze);if(Ce.ok)m==null||m(ae.name);else{const Ye=await Ce.json();f(Ye.error||o("messages.deleteProjectFailed"),"error")}}catch(Ce){console.error("Error deleting project:",Ce),f(o("messages.deleteProjectError"),"error")}finally{q(Ce=>{const Ye=new Set(Ce);return Ye.delete(ae.name),Ye})}},[U,m,o]),fe=l.useCallback(async ae=>{var Ce,Ye,lt;const be=re[ae.name];if(!(!(be!==void 0?be:((Ce=ae.sessionMeta)==null?void 0:Ce.hasMore)===!0)||C[ae.name])){v(dt=>({...dt,[ae.name]:!0}));try{const dt=(((Ye=ae.sessions)==null?void 0:Ye.length)||0)+(((lt=E[ae.name])==null?void 0:lt.length)||0),Tt=await Be.sessions(ae.name,5,dt);if(!Tt.ok)return;const At=await Tt.json();T(wt=>({...wt,[ae.name]:[...wt[ae.name]||[],...At.sessions||[]]})),At.hasMore===!1&&G(wt=>({...wt,[ae.name]:!1}))}catch(dt){console.error("Error loading more sessions:",dt)}finally{v(dt=>({...dt,[ae.name]:!1}))}}},[E,C,re]),Ee=l.useCallback(ae=>{c(ae),h(ae)},[c,h]),Le=l.useCallback(async()=>{J(!0);try{await i()}finally{J(!1)}},[i]),Pe=l.useCallback(async(ae,be,ze)=>{$(null),te("")},[]),Ae=l.useCallback(()=>{p(!1)},[p]),Ge=l.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:de,expandedProjects:x,editingProject:N,showNewProject:y,editingName:I,loadingSessions:C,additionalSessions:E,initialSessionsLoaded:W,currentTime:O,projectSortOrder:R,isRefreshing:z,editingSession:ie,editingSessionName:Z,searchFilter:Q,deletingProjects:F,deleteConfirmation:U,sessionDeleteConfirmation:ee,showVersionModal:w,starredProjects:Y,filteredProjects:K,handleTouchClick:je,toggleProject:ge,handleSessionClick:Re,toggleStarProject:Ne,isProjectStarred:De,getProjectSessions:Ue,startEditing:pe,cancelEditing:ye,saveProjectName:Ie,showDeleteSessionConfirmation:Fe,confirmDeleteSession:Se,requestProjectDelete:Oe,confirmDeleteProject:ne,loadMoreSessions:fe,handleProjectSelect:Ee,refreshProjects:Le,updateSessionSummary:Pe,collapseSidebar:Ae,expandSidebar:Ge,setShowNewProject:k,setEditingName:D,setEditingSession:$,setEditingSessionName:te,setSearchFilter:_,setDeleteConfirmation:B,setSessionDeleteConfirmation:V,setShowVersionModal:M}}function Ml({onExpand:t,onShowSettings:r,updateAvailable:s,onShowVersionModal:a,t:n}){return e.jsxs("div",{className:"h-full flex flex-col items-center py-3 gap-1 bg-background/80 backdrop-blur-sm w-12",children:[e.jsx("button",{onClick:t,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("common:versionUpdate.ariaLabels.showSidebar"),title:n("common:versionUpdate.ariaLabels.showSidebar"),children:e.jsx("img",{src:"/favicon.svg",alt:"",className:"w-6 h-6 rounded"})}),e.jsx("div",{className:"nav-divider w-6 my-1"}),e.jsx("button",{onClick:r,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("actions.settings"),title:n("actions.settings"),children:e.jsx(Dt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),s&&e.jsxs("button",{onClick:a,className:"relative w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors","aria-label":n("common:versionUpdate.ariaLabels.updateAvailable"),title:n("common:versionUpdate.ariaLabels.updateAvailable"),children:[e.jsx(Ut,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]})]})}function bo(t){var r,s,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(r=0;r<n;r++)t[r]&&(s=bo(t[r]))&&(a&&(a+=" "),a+=s)}else for(s in t)t[s]&&(a&&(a+=" "),a+=s);return a}function yo(){for(var t,r,s=0,a="",n=arguments.length;s<n;s++)(t=arguments[s])&&(r=bo(t))&&(a&&(a+=" "),a+=r);return a}const Dl=(t,r)=>{const s=new Array(t.length+r.length);for(let a=0;a<t.length;a++)s[a]=t[a];for(let a=0;a<r.length;a++)s[t.length+a]=r[a];return s},Ll=(t,r)=>({classGroupId:t,validator:r}),vo=(t=new Map,r=null,s)=>({nextPart:t,validators:r,classGroupId:s}),ns="-",Va=[],Pl="arbitrary..",$l=t=>{const r=Fl(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return _l(i);const c=i.split(ns),u=c[0]===""&&c.length>1?1:0;return ko(c,u,r)},getConflictingClassGroupIds:(i,c)=>{if(c){const u=a[i],d=s[i];return u?d?Dl(d,u):u:d||Va}return s[i]||Va}}},ko=(t,r,s)=>{if(t.length-r===0)return s.classGroupId;const n=t[r],o=s.nextPart.get(n);if(o){const d=ko(t,r+1,o);if(d)return d}const i=s.validators;if(i===null)return;const c=r===0?t.join(ns):t.slice(r).join(ns),u=i.length;for(let d=0;d<u;d++){const m=i[d];if(m.validator(c))return m.classGroupId}},_l=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=t.slice(1,-1),s=r.indexOf(":"),a=r.slice(0,s);return a?Pl+a:void 0})(),Fl=t=>{const{theme:r,classGroups:s}=t;return zl(s,r)},zl=(t,r)=>{const s=vo();for(const a in t){const n=t[a];Na(n,s,a,r)}return s},Na=(t,r,s,a)=>{const n=t.length;for(let o=0;o<n;o++){const i=t[o];Rl(i,r,s,a)}},Rl=(t,r,s,a)=>{if(typeof t=="string"){Ol(t,r,s);return}if(typeof t=="function"){Bl(t,r,s,a);return}Wl(t,r,s,a)},Ol=(t,r,s)=>{const a=t===""?r:wo(r,t);a.classGroupId=s},Bl=(t,r,s,a)=>{if(Ul(t)){Na(t(a),r,s,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Ll(s,t))},Wl=(t,r,s,a)=>{const n=Object.entries(t),o=n.length;for(let i=0;i<o;i++){const[c,u]=n[i];Na(u,wo(r,c),s,a)}},wo=(t,r)=>{let s=t;const a=r.split(ns),n=a.length;for(let o=0;o<n;o++){const i=a[o];let c=s.nextPart.get(i);c||(c=vo(),s.nextPart.set(i,c)),s=c}return s},Ul=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,Hl=t=>{if(t<1)return{get:()=>{},set:()=>{}};let r=0,s=Object.create(null),a=Object.create(null);const n=(o,i)=>{s[o]=i,r++,r>t&&(r=0,a=s,s=Object.create(null))};return{get(o){let i=s[o];if(i!==void 0)return i;if((i=a[o])!==void 0)return n(o,i),i},set(o,i){o in s?s[o]=i:n(o,i)}}},Xs="!",qa=":",Gl=[],Ka=(t,r,s,a,n)=>({modifiers:t,hasImportantModifier:r,baseClassName:s,maybePostfixModifierPosition:a,isExternal:n}),Vl=t=>{const{prefix:r,experimentalParseClassName:s}=t;let a=n=>{const o=[];let i=0,c=0,u=0,d;const m=n.length;for(let x=0;x<m;x++){const b=n[x];if(i===0&&c===0){if(b===qa){o.push(n.slice(u,x)),u=x+1;continue}if(b==="/"){d=x;continue}}b==="["?i++:b==="]"?i--:b==="("?c++:b===")"&&c--}const h=o.length===0?n:n.slice(u);let p=h,g=!1;h.endsWith(Xs)?(p=h.slice(0,-1),g=!0):h.startsWith(Xs)&&(p=h.slice(1),g=!0);const f=d&&d>u?d-u:void 0;return Ka(o,g,p,f)};if(r){const n=r+qa,o=a;a=i=>i.startsWith(n)?o(i.slice(n.length)):Ka(Gl,!1,i,void 0,!0)}if(s){const n=a;a=o=>s({className:o,parseClassName:n})}return a},ql=t=>{const r=new Map;return t.orderSensitiveModifiers.forEach((s,a)=>{r.set(s,1e6+a)}),s=>{const a=[];let n=[];for(let o=0;o<s.length;o++){const i=s[o],c=i[0]==="[",u=r.has(i);c||u?(n.length>0&&(n.sort(),a.push(...n),n=[]),a.push(i)):n.push(i)}return n.length>0&&(n.sort(),a.push(...n)),a}},Kl=t=>({cache:Hl(t.cacheSize),parseClassName:Vl(t),sortModifiers:ql(t),...$l(t)}),Jl=/\s+/,Yl=(t,r)=>{const{parseClassName:s,getClassGroupId:a,getConflictingClassGroupIds:n,sortModifiers:o}=r,i=[],c=t.trim().split(Jl);let u="";for(let d=c.length-1;d>=0;d-=1){const m=c[d],{isExternal:h,modifiers:p,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:x}=s(m);if(h){u=m+(u.length>0?" "+u:u);continue}let b=!!x,N=a(b?f.substring(0,x):f);if(!N){if(!b){u=m+(u.length>0?" "+u:u);continue}if(N=a(f),!N){u=m+(u.length>0?" "+u:u);continue}b=!1}const j=p.length===0?"":p.length===1?p[0]:o(p).join(":"),y=g?j+Xs:j,k=y+N;if(i.indexOf(k)>-1)continue;i.push(k);const I=n(N,b);for(let D=0;D<I.length;++D){const C=I[D];i.push(y+C)}u=m+(u.length>0?" "+u:u)}return u},Ql=(...t)=>{let r=0,s,a,n="";for(;r<t.length;)(s=t[r++])&&(a=jo(s))&&(n&&(n+=" "),n+=a);return n},jo=t=>{if(typeof t=="string")return t;let r,s="";for(let a=0;a<t.length;a++)t[a]&&(r=jo(t[a]))&&(s&&(s+=" "),s+=r);return s},Xl=(t,...r)=>{let s,a,n,o;const i=u=>{const d=r.reduce((m,h)=>h(m),t());return s=Kl(d),a=s.cache.get,n=s.cache.set,o=c,c(u)},c=u=>{const d=a(u);if(d)return d;const m=Yl(u,s);return n(u,m),m};return o=i,(...u)=>o(Ql(...u))},Zl=[],rt=t=>{const r=s=>s[t]||Zl;return r.isThemeGetter=!0,r},No=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Co=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ec=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,tc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,rc=/\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$/,sc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ac=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,nc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Rt=t=>ec.test(t),$e=t=>!!t&&!Number.isNaN(Number(t)),Ot=t=>!!t&&Number.isInteger(Number(t)),Ps=t=>t.endsWith("%")&&$e(t.slice(0,-1)),Mt=t=>tc.test(t),So=()=>!0,oc=t=>rc.test(t)&&!sc.test(t),Ca=()=>!1,ic=t=>ac.test(t),lc=t=>nc.test(t),cc=t=>!me(t)&&!xe(t),dc=t=>Ht(t,Ao,Ca),me=t=>No.test(t),Jt=t=>Ht(t,Io,oc),Ja=t=>Ht(t,bc,$e),uc=t=>Ht(t,Do,So),mc=t=>Ht(t,Mo,Ca),Ya=t=>Ht(t,Eo,Ca),pc=t=>Ht(t,To,lc),Hr=t=>Ht(t,Lo,ic),xe=t=>Co.test(t),kr=t=>ar(t,Io),xc=t=>ar(t,Mo),Qa=t=>ar(t,Eo),gc=t=>ar(t,Ao),hc=t=>ar(t,To),Gr=t=>ar(t,Lo,!0),fc=t=>ar(t,Do,!0),Ht=(t,r,s)=>{const a=No.exec(t);return a?a[1]?r(a[1]):s(a[2]):!1},ar=(t,r,s=!1)=>{const a=Co.exec(t);return a?a[1]?r(a[1]):s:!1},Eo=t=>t==="position"||t==="percentage",To=t=>t==="image"||t==="url",Ao=t=>t==="length"||t==="size"||t==="bg-size",Io=t=>t==="length",bc=t=>t==="number",Mo=t=>t==="family-name",Do=t=>t==="number"||t==="weight",Lo=t=>t==="shadow",yc=()=>{const t=rt("color"),r=rt("font"),s=rt("text"),a=rt("font-weight"),n=rt("tracking"),o=rt("leading"),i=rt("breakpoint"),c=rt("container"),u=rt("spacing"),d=rt("radius"),m=rt("shadow"),h=rt("inset-shadow"),p=rt("text-shadow"),g=rt("drop-shadow"),f=rt("blur"),x=rt("perspective"),b=rt("aspect"),N=rt("ease"),j=rt("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],I=()=>[...k(),xe,me],D=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],v=()=>[xe,me,u],E=()=>[Rt,"full","auto",...v()],T=()=>[Ot,"none","subgrid",xe,me],W=()=>["auto",{span:["full",Ot,xe,me]},Ot,xe,me],S=()=>[Ot,"auto",xe,me],O=()=>["auto","min","max","fr",xe,me],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R=()=>["start","end","center","stretch","center-safe","end-safe"],A=()=>["auto",...v()],z=()=>[Rt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],J=()=>[Rt,"screen","full","dvw","lvw","svw","min","max","fit",...v()],re=()=>[Rt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],G=()=>[t,xe,me],ie=()=>[...k(),Qa,Ya,{position:[xe,me]}],$=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",gc,dc,{size:[xe,me]}],te=()=>[Ps,kr,Jt],Q=()=>["","none","full",d,xe,me],_=()=>["",$e,kr,Jt],F=()=>["solid","dashed","dotted","double"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[$e,Ps,Qa,Ya],B=()=>["","none",f,xe,me],ee=()=>["none",$e,xe,me],V=()=>["none",$e,xe,me],w=()=>[$e,xe,me],M=()=>[Rt,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Mt],breakpoint:[Mt],color:[So],container:[Mt],"drop-shadow":[Mt],ease:["in","out","in-out"],font:[cc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Mt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Mt],shadow:[Mt],spacing:["px",$e],text:[Mt],"text-shadow":[Mt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Rt,me,xe,b]}],container:["container"],columns:[{columns:[$e,me,xe,c]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"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:I()}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{"inset-s":E(),start:E()}],end:[{"inset-e":E(),end:E()}],"inset-bs":[{"inset-bs":E()}],"inset-be":[{"inset-be":E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[Ot,"auto",xe,me]}],basis:[{basis:[Rt,"full","auto",c,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[$e,Rt,"auto","initial","none",me]}],grow:[{grow:["",$e,xe,me]}],shrink:[{shrink:["",$e,xe,me]}],order:[{order:[Ot,"first","last","none",xe,me]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[...R(),"normal"]}],"justify-self":[{"justify-self":["auto",...R()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[...R(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[...R(),"baseline"]}],"place-self":[{"place-self":["auto",...R()]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:A()}],mx:[{mx:A()}],my:[{my:A()}],ms:[{ms:A()}],me:[{me:A()}],mbs:[{mbs:A()}],mbe:[{mbe:A()}],mt:[{mt:A()}],mr:[{mr:A()}],mb:[{mb:A()}],ml:[{ml:A()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],"inline-size":[{inline:["auto",...J()]}],"min-inline-size":[{"min-inline":["auto",...J()]}],"max-inline-size":[{"max-inline":["none",...J()]}],"block-size":[{block:["auto",...re()]}],"min-block-size":[{"min-block":["auto",...re()]}],"max-block-size":[{"max-block":["none",...re()]}],w:[{w:[c,"screen",...z()]}],"min-w":[{"min-w":[c,"screen","none",...z()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",s,kr,Jt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,fc,uc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ps,me]}],"font-family":[{font:[xc,mc,r]}],"font-features":[{"font-features":[me]}],"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:[n,xe,me]}],"line-clamp":[{"line-clamp":[$e,"none",xe,Ja]}],leading:[{leading:[o,...v()]}],"list-image":[{"list-image":["none",xe,me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",xe,me]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:G()}],"text-color":[{text:G()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...F(),"wavy"]}],"text-decoration-thickness":[{decoration:[$e,"from-font","auto",xe,Jt]}],"text-decoration-color":[{decoration:G()}],"underline-offset":[{"underline-offset":[$e,"auto",xe,me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",xe,me]}],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",xe,me]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:$()}],"bg-size":[{bg:Z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ot,xe,me],radial:["",xe,me],conic:[Ot,xe,me]},hc,pc]}],"bg-color":[{bg:G()}],"gradient-from-pos":[{from:te()}],"gradient-via-pos":[{via:te()}],"gradient-to-pos":[{to:te()}],"gradient-from":[{from:G()}],"gradient-via":[{via:G()}],"gradient-to":[{to:G()}],rounded:[{rounded:Q()}],"rounded-s":[{"rounded-s":Q()}],"rounded-e":[{"rounded-e":Q()}],"rounded-t":[{"rounded-t":Q()}],"rounded-r":[{"rounded-r":Q()}],"rounded-b":[{"rounded-b":Q()}],"rounded-l":[{"rounded-l":Q()}],"rounded-ss":[{"rounded-ss":Q()}],"rounded-se":[{"rounded-se":Q()}],"rounded-ee":[{"rounded-ee":Q()}],"rounded-es":[{"rounded-es":Q()}],"rounded-tl":[{"rounded-tl":Q()}],"rounded-tr":[{"rounded-tr":Q()}],"rounded-br":[{"rounded-br":Q()}],"rounded-bl":[{"rounded-bl":Q()}],"border-w":[{border:_()}],"border-w-x":[{"border-x":_()}],"border-w-y":[{"border-y":_()}],"border-w-s":[{"border-s":_()}],"border-w-e":[{"border-e":_()}],"border-w-bs":[{"border-bs":_()}],"border-w-be":[{"border-be":_()}],"border-w-t":[{"border-t":_()}],"border-w-r":[{"border-r":_()}],"border-w-b":[{"border-b":_()}],"border-w-l":[{"border-l":_()}],"divide-x":[{"divide-x":_()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":_()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...F(),"hidden","none"]}],"divide-style":[{divide:[...F(),"hidden","none"]}],"border-color":[{border:G()}],"border-color-x":[{"border-x":G()}],"border-color-y":[{"border-y":G()}],"border-color-s":[{"border-s":G()}],"border-color-e":[{"border-e":G()}],"border-color-bs":[{"border-bs":G()}],"border-color-be":[{"border-be":G()}],"border-color-t":[{"border-t":G()}],"border-color-r":[{"border-r":G()}],"border-color-b":[{"border-b":G()}],"border-color-l":[{"border-l":G()}],"divide-color":[{divide:G()}],"outline-style":[{outline:[...F(),"none","hidden"]}],"outline-offset":[{"outline-offset":[$e,xe,me]}],"outline-w":[{outline:["",$e,kr,Jt]}],"outline-color":[{outline:G()}],shadow:[{shadow:["","none",m,Gr,Hr]}],"shadow-color":[{shadow:G()}],"inset-shadow":[{"inset-shadow":["none",h,Gr,Hr]}],"inset-shadow-color":[{"inset-shadow":G()}],"ring-w":[{ring:_()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:G()}],"ring-offset-w":[{"ring-offset":[$e,Jt]}],"ring-offset-color":[{"ring-offset":G()}],"inset-ring-w":[{"inset-ring":_()}],"inset-ring-color":[{"inset-ring":G()}],"text-shadow":[{"text-shadow":["none",p,Gr,Hr]}],"text-shadow-color":[{"text-shadow":G()}],opacity:[{opacity:[$e,xe,me]}],"mix-blend":[{"mix-blend":[...q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":q()}],"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":[$e]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":G()}],"mask-image-linear-to-color":[{"mask-linear-to":G()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":G()}],"mask-image-t-to-color":[{"mask-t-to":G()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":G()}],"mask-image-r-to-color":[{"mask-r-to":G()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":G()}],"mask-image-b-to-color":[{"mask-b-to":G()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":G()}],"mask-image-l-to-color":[{"mask-l-to":G()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":G()}],"mask-image-x-to-color":[{"mask-x-to":G()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":G()}],"mask-image-y-to-color":[{"mask-y-to":G()}],"mask-image-radial":[{"mask-radial":[xe,me]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":G()}],"mask-image-radial-to-color":[{"mask-radial-to":G()}],"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":k()}],"mask-image-conic-pos":[{"mask-conic":[$e]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":G()}],"mask-image-conic-to-color":[{"mask-conic-to":G()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:$()}],"mask-size":[{mask:Z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",xe,me]}],filter:[{filter:["","none",xe,me]}],blur:[{blur:B()}],brightness:[{brightness:[$e,xe,me]}],contrast:[{contrast:[$e,xe,me]}],"drop-shadow":[{"drop-shadow":["","none",g,Gr,Hr]}],"drop-shadow-color":[{"drop-shadow":G()}],grayscale:[{grayscale:["",$e,xe,me]}],"hue-rotate":[{"hue-rotate":[$e,xe,me]}],invert:[{invert:["",$e,xe,me]}],saturate:[{saturate:[$e,xe,me]}],sepia:[{sepia:["",$e,xe,me]}],"backdrop-filter":[{"backdrop-filter":["","none",xe,me]}],"backdrop-blur":[{"backdrop-blur":B()}],"backdrop-brightness":[{"backdrop-brightness":[$e,xe,me]}],"backdrop-contrast":[{"backdrop-contrast":[$e,xe,me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",$e,xe,me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[$e,xe,me]}],"backdrop-invert":[{"backdrop-invert":["",$e,xe,me]}],"backdrop-opacity":[{"backdrop-opacity":[$e,xe,me]}],"backdrop-saturate":[{"backdrop-saturate":[$e,xe,me]}],"backdrop-sepia":[{"backdrop-sepia":["",$e,xe,me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",xe,me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[$e,"initial",xe,me]}],ease:[{ease:["linear","initial",N,xe,me]}],delay:[{delay:[$e,xe,me]}],animate:[{animate:["none",j,xe,me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,xe,me]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:ee()}],"rotate-x":[{"rotate-x":ee()}],"rotate-y":[{"rotate-y":ee()}],"rotate-z":[{"rotate-z":ee()}],scale:[{scale:V()}],"scale-x":[{"scale-x":V()}],"scale-y":[{"scale-y":V()}],"scale-z":[{"scale-z":V()}],"scale-3d":["scale-3d"],skew:[{skew:w()}],"skew-x":[{"skew-x":w()}],"skew-y":[{"skew-y":w()}],transform:[{transform:[xe,me,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:M()}],"translate-x":[{"translate-x":M()}],"translate-y":[{"translate-y":M()}],"translate-z":[{"translate-z":M()}],"translate-none":["translate-none"],accent:[{accent:G()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:G()}],"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",xe,me]}],"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":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"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",xe,me]}],fill:[{fill:["none",...G()]}],"stroke-w":[{stroke:[$e,kr,Jt,Ja]}],stroke:[{stroke:["none",...G()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","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","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","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-bs","border-w-be","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-bs","border-color-be","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-mbs","scroll-mbe","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-pbs","scroll-pbe","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"]}},vc=Xl(yc);function ke(...t){return vc(yo(t))}function kc(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Po=l.forwardRef(({className:t,children:r,...s},a)=>e.jsx("div",{className:ke(t,"relative overflow-hidden"),...s,children:e.jsx("div",{ref:a,className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Po.displayName="ScrollArea";function wc({updateAvailable:t,releaseInfo:r,latestVersion:s,onShowVersionModal:a,onShowSettings:n,t:o}){return e.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-left hover:bg-blue-50/80 dark:hover:bg-blue-900/15 transition-colors group",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx($a,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),e.jsx("div",{className:"md:hidden px-3 py-2",children:e.jsxs("button",{className:"w-full h-11 bg-blue-50/80 dark:bg-blue-900/15 border border-blue-200/60 dark:border-blue-700/40 rounded-xl flex items-center gap-3 px-3.5 active:scale-[0.98] transition-all",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx($a,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors",onClick:n,children:[e.jsx(Dt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),e.jsx("div",{className:"md:hidden p-3 pb-20",children:e.jsxs("button",{className:"w-full h-12 bg-muted/40 hover:bg-muted/60 rounded-xl flex items-center gap-3.5 px-4 active:scale-[0.98] transition-all",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-background/80 flex items-center justify-center",children:e.jsx(Dt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),e.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const Xa=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Za=yo,$o=(t,r)=>s=>{var a;if((r==null?void 0:r.variants)==null)return Za(t,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:n,defaultVariants:o}=r,i=Object.keys(n).map(d=>{const m=s==null?void 0:s[d],h=o==null?void 0:o[d];if(m===null)return null;const p=Xa(m)||Xa(h);return n[d][p]}),c=s&&Object.entries(s).reduce((d,m)=>{let[h,p]=m;return p===void 0||(d[h]=p),d},{}),u=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((d,m)=>{let{class:h,className:p,...g}=m;return Object.entries(g).every(f=>{let[x,b]=f;return Array.isArray(b)?b.includes({...o,...c}[x]):{...o,...c}[x]===b})?[...d,h,p]:d},[]);return Za(t,i,u,s==null?void 0:s.class,s==null?void 0:s.className)},jc=$o("inline-flex 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",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),he=l.forwardRef(({className:t,variant:r,size:s,...a},n)=>e.jsx("button",{className:ke(jc({variant:r,size:s,className:t})),ref:n,...a}));he.displayName="Button";const Ze=l.forwardRef(({className:t,type:r,...s},a)=>e.jsx("input",{type:r,className:ke("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,...s}));Ze.displayName="Input";function Nc({isPWA:t,isMobile:r,isLoading:s,projectsCount:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,t:h}){const p=()=>e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("img",{src:"/favicon.svg",alt:"",className:"w-7 h-7 rounded-lg flex-shrink-0"}),e.jsx("h1",{className:"text-sm font-semibold text-foreground tracking-tight truncate",children:h("app.title")})]});return e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"hidden md:block px-3 pt-3 pb-2",style:{},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(p,{}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:c,disabled:u,title:h("tooltips.refresh"),children:e.jsx(Vs,{className:`w-3.5 h-3.5 ${u?"animate-spin":""}`})}),e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:d,title:h("tooltips.createProject"),children:e.jsx(at,{className:"w-3.5 h-3.5"})}),e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:m,title:h("tooltips.hideSidebar"),children:e.jsx(fi,{className:"w-3.5 h-3.5"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/50 pointer-events-none"}),e.jsx(Ze,{type:"text",placeholder:h("projects.searchPlaceholder"),value:n,onChange:g=>o(g.target.value),className:"nav-search-input pl-9 pr-8 h-9 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-accent rounded-md",children:e.jsx(Ve,{className:"w-3 h-3 text-muted-foreground"})})]})]}),e.jsx("div",{className:"hidden md:block nav-divider"}),e.jsxs("div",{className:"md:hidden p-3 pb-2",style:t&&r?{paddingTop:"16px"}:{},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{}),e.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-muted/50 flex items-center justify-center active:scale-95 transition-all",onClick:c,disabled:u,children:e.jsx(Vs,{className:`w-4 h-4 text-muted-foreground ${u?"animate-spin":""}`})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/90 text-primary-foreground flex items-center justify-center active:scale-95 transition-all",onClick:d,children:e.jsx(Zr,{className:"w-4 h-4"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 pointer-events-none"}),e.jsx(Ze,{type:"text",placeholder:h("projects.searchPlaceholder"),value:n,onChange:g=>o(g.target.value),className:"nav-search-input pl-10 pr-9 h-10 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 hover:bg-accent rounded-md",children:e.jsx(Ve,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})]}),e.jsx("div",{className:"md:hidden nav-divider"})]})}const Cc=({status:t="not-configured",size:r="sm",className:s="",showLabel:a=!1})=>{const o=(()=>{switch(t){case"fully-configured":return{icon:Pr,color:"text-green-500 dark:text-green-400",bgColor:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"};case"taskmaster-only":return{icon:Dt,color:"text-blue-500 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"};case"mcp-only":return{icon:xs,color:"text-amber-500 dark:text-amber-400",bgColor:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"};case"not-configured":case"error":default:return{icon:Ve,color:"text-gray-400 dark:text-gray-500",bgColor:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"}}})(),i=o.icon,c={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},u={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"};return a?e.jsxs("div",{className:ke("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",o.bgColor,o.color,s),title:o.title,children:[e.jsx(i,{className:c[r]}),e.jsx("span",{className:"font-medium",children:o.label})]}):e.jsx("div",{className:ke("inline-flex items-center justify-center rounded-full transition-colors",o.bgColor,u[r],s),title:o.title,children:e.jsx(i,{className:ke(c[r],o.color)})})},Sc=$o("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 bt({className:t,variant:r,...s}){return e.jsx("div",{className:ke(Sc({variant:r}),t),...s})}const en=(t,r,s)=>{const a=new Date(t),n=r;if(isNaN(a.getTime()))return s?s("status.unknown"):"Unknown";const o=n.getTime()-a.getTime(),i=Math.floor(o/1e3),c=Math.floor(o/(1e3*60)),u=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return i<60?s?s("time.justNow"):"Just now":c===1?s?s("time.oneMinuteAgo"):"1 min ago":c<60?s?s("time.minutesAgo",{count:c}):`${c} mins ago`:u===1?s?s("time.oneHourAgo"):"1 hour ago":u<24?s?s("time.hoursAgo",{count:u}):`${u} hours ago`:d===1?s?s("time.oneDayAgo"):"1 day ago":d<7?s?s("time.daysAgo",{count:d}):`${d} days ago`:a.toLocaleDateString()};function ft({provider:t="claude",className:r="w-5 h-5"}){return t==="cursor"?e.jsx(Ui,{className:r}):t==="codex"?e.jsx(Hi,{className:r}):e.jsx(Gi,{className:r})}function Ec({project:t,session:r,selectedSession:s,currentTime:a,editingSession:n,editingSessionName:o,onEditingSessionNameChange:i,onStartEditingSession:c,onCancelEditingSession:u,onSaveEditingSession:d,onProjectSelect:m,onSessionSelect:h,onDeleteSession:p,touchHandlerFactory:g,t:f}){const x=Cl(r,a,f),b=(s==null?void 0:s.id)===r.id,N=()=>{m(t),h(r,t.name)},j=()=>{d(t.name,r.id,o)},y=()=>{p(t.name,r.id,x.sessionName,r.__provider)};return e.jsxs("div",{className:"group relative",children:[x.isActive&&e.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:ke("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",b?"bg-primary/5 border-primary/20":"",!b&&x.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:N,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:ke("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",b?"bg-primary/10":"bg-muted/50"),children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:x.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Ir,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:en(x.sessionTime,a,f)}),x.messageCount>0&&e.jsx(bt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:x.messageCount}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})})]})]}),!x.isCursorSession&&e.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:k=>{k.stopPropagation(),y()},children:e.jsx(yt,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(he,{variant:"ghost",className:ke("w-full justify-start px-2 py-2.5 h-auto min-h-[48px] font-normal text-left hover:bg-accent/50 transition-colors duration-200",b&&"bg-accent text-accent-foreground"),onClick:()=>h(r,t.name),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full pr-14",children:[e.jsx(ft,{provider:r.__provider,className:"w-3 h-3 mt-1 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground leading-5",children:x.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Ir,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:en(x.sessionTime,a,f)}),x.messageCount>0&&e.jsx(bt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto group-hover:opacity-0 transition-opacity",children:x.messageCount}),e.jsx("span",{className:"ml-1 opacity-70 group-hover:opacity-0 transition-opacity",children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})})]})]})]})}),!x.isCursorSession&&e.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-all duration-200 bg-accent/80 backdrop-blur-sm rounded-md px-1 py-0.5",children:n===r.id&&!x.isCodexSession?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:o,onChange:k=>i(k.target.value),onKeyDown:k=>{k.stopPropagation(),k.key==="Enter"?j():k.key==="Escape"&&u()},onClick:k=>k.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),j()},title:f("tooltips.save"),children:e.jsx(Lt,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),u()},title:f("tooltips.cancel"),children:e.jsx(Ve,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):e.jsxs(e.Fragment,{children:[!x.isCodexSession&&e.jsx("button",{className:"w-7 h-7 bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),c(r.id,r.summary||f("projects.newSession"))},title:f("tooltips.editSessionName"),children:e.jsx(bi,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-7 h-7 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),y()},title:f("tooltips.deleteSession"),children:e.jsx(yt,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]})}function Tc(){return e.jsx(e.Fragment,{children:Array.from({length:3}).map((t,r)=>e.jsx("div",{className:"p-2 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+r*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},r))})}function Ac({project:t,isExpanded:r,sessions:s,selectedSession:a,initialSessionsLoaded:n,isLoadingSessions:o,currentTime:i,editingSession:c,editingSessionName:u,onEditingSessionNameChange:d,onStartEditingSession:m,onCancelEditingSession:h,onSaveEditingSession:p,onProjectSelect:g,onSessionSelect:f,onDeleteSession:x,onLoadMoreSessions:b,onNewSession:N,touchHandlerFactory:j,t:y}){var D;if(!r)return null;const k=s.length>0,I=((D=t.sessionMeta)==null?void 0:D.hasMore)===!0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[n?!k&&!o?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:y("sessions.noSessions")})}):s.map(C=>e.jsx(Ec,{project:t,session:C,selectedSession:a,currentTime:i,editingSession:c,editingSessionName:u,onEditingSessionNameChange:d,onStartEditingSession:m,onCancelEditingSession:h,onSaveEditingSession:p,onProjectSelect:g,onSessionSelect:f,onDeleteSession:x,touchHandlerFactory:j,t:y},C.id)):e.jsx(Tc,{}),k&&I&&e.jsx(he,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>b(t),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),y("sessions.loading")]}):e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-3 h-3"}),y("sessions.showMore")]})}),e.jsx("div",{className:"md:hidden px-3 pb-2",children:e.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{g(t),N(t)},children:[e.jsx(at,{className:"w-3 h-3"}),y("sessions.newSession")]})}),e.jsxs(he,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>N(t),children:[e.jsx(at,{className:"w-3 h-3"}),y("sessions.newSession")]})]})}const Ic=(t,r)=>{const s=t.length;return r&&s>=5?`${s}+`:`${s}`};function Mc({project:t,selectedProject:r,selectedSession:s,isExpanded:a,isDeleting:n,isStarred:o,editingProject:i,editingName:c,sessions:u,initialSessionsLoaded:d,isLoadingSessions:m,currentTime:h,editingSession:p,editingSessionName:g,tasksEnabled:f,mcpServerStatus:x,onEditingNameChange:b,onToggleProject:N,onProjectSelect:j,onToggleStarProject:y,onStartEditingProject:k,onCancelEditingProject:I,onSaveProjectName:D,onDeleteProject:C,onSessionSelect:v,onDeleteSession:E,onLoadMoreSessions:T,onNewSession:W,onEditingSessionNameChange:S,onStartEditingSession:O,onCancelEditingSession:H,onSaveEditingSession:R,onOpenProjectSettings:A,touchHandlerFactory:z,t:J}){var U;const re=(r==null?void 0:r.name)===t.name,G=i===t.name,ie=((U=t.sessionMeta)==null?void 0:U.hasMore)===!0,$=Ic(u,ie),Z=`${$} session${u.length===1?"":"s"}`,te=Tl(t,x),Q=()=>N(t.name),_=()=>y(t.name),F=()=>{D(t.name)},q=()=>{(r==null?void 0:r.name)!==t.name&&j(t),Q()};return e.jsxs("div",{className:ke("md:space-y-1",n&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"group md:group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:ke("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",re&&"bg-primary/5 border-primary/20",o&&!re&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:Q,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:ke("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",a?"bg-primary/10":"bg-muted"),children:a?e.jsx(er,{className:"w-4 h-4 text-primary"}):e.jsx(mr,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:G?e.jsx("input",{type:"text",value:c,onChange:B=>b(B.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:J("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:B=>B.stopPropagation(),onKeyDown:B=>{B.key==="Enter"&&F(),B.key==="Escape"&&I()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:t.displayName}),f&&e.jsx(Cc,{status:te,size:"xs",className:"hidden md:inline-flex flex-shrink-0 ml-2"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Z})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:G?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:B=>{B.stopPropagation(),F()},children:e.jsx(Lt,{className:"w-4 h-4 text-white"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:B=>{B.stopPropagation(),I()},children:e.jsx(Ve,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:ke("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",o?"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:B=>{B.stopPropagation(),_()},title:J(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(_a,{className:ke("w-4 h-4 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500/10 dark:bg-gray-900/30 flex items-center justify-center active:scale-90 border border-gray-200 dark:border-gray-800",onClick:B=>{B.stopPropagation(),A(t)},title:J("tooltips.projectSettings",{defaultValue:"Project settings"}),children:e.jsx(Dt,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:B=>{B.stopPropagation(),C(t)},children:e.jsx(yt,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:B=>{B.stopPropagation(),k(t)},children:e.jsx(Mr,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:a?e.jsx(Pt,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(rr,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(he,{variant:"ghost",className:ke("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",re&&"bg-accent text-accent-foreground",o&&!re&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:q,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a?e.jsx(er,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(mr,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:G?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:c,onChange:B=>b(B.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:J("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:B=>{B.key==="Enter"&&F(),B.key==="Escape"&&I()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:t.fullPath,children:t.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[$,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 items-center gap-1 flex-shrink-0",children:G?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:B=>{B.stopPropagation(),F()},children:e.jsx(Lt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:B=>{B.stopPropagation(),I()},children:e.jsx(Ve,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ke("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",o?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:B=>{B.stopPropagation(),_()},title:J(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(_a,{className:ke("w-3 h-3 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),A(t)},title:J("tooltips.projectSettings",{defaultValue:"Project settings"}),children:e.jsx(Dt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),k(t)},title:J("tooltips.renameProject"),children:e.jsx(Mr,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),C(t)},title:J("tooltips.deleteProject"),children:e.jsx(yt,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),a?e.jsx(Pt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(rr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),e.jsx(Ac,{project:t,isExpanded:a,sessions:u,selectedSession:s,initialSessionsLoaded:d,isLoadingSessions:m,currentTime:h,editingSession:p,editingSessionName:g,onEditingSessionNameChange:S,onStartEditingSession:O,onCancelEditingSession:H,onSaveEditingSession:R,onProjectSelect:j,onSessionSelect:v,onDeleteSession:E,onLoadMoreSessions:T,onNewSession:W,touchHandlerFactory:z,t:J})]})}function Dc({isLoading:t,loadingProgress:r,projectsCount:s,filteredProjectsCount:a,t:n}){const{isRelayConnected:o}=ps();return t?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.loadingProjects")}),r&&r.total>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full transition-all duration-300 ease-out",style:{width:`${r.current/r.total*100}%`}})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.current,"/",r.total," ",n("projects.projects")]}),r.currentProject&&e.jsx("p",{className:"text-xs text-muted-foreground/70 truncate max-w-[200px] mx-auto",title:r.currentProject,children:r.currentProject.split("-").slice(-2).join("/")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.fetchingProjects")})]}):s===0?o?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(mr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.runClaudeCli")})]}):e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Xn,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"No machine connected"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your machine to see projects"})]}):a===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Ar,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noMatchingProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.tryDifferentSearch")})]}):null}function Lc({projects:t,filteredProjects:r,selectedProject:s,selectedSession:a,isLoading:n,loadingProgress:o,expandedProjects:i,editingProject:c,editingName:u,loadingSessions:d,initialSessionsLoaded:m,currentTime:h,editingSession:p,editingSessionName:g,deletingProjects:f,tasksEnabled:x,mcpServerStatus:b,getProjectSessions:N,isProjectStarred:j,onEditingNameChange:y,onToggleProject:k,onProjectSelect:I,onToggleStarProject:D,onStartEditingProject:C,onCancelEditingProject:v,onSaveProjectName:E,onDeleteProject:T,onSessionSelect:W,onDeleteSession:S,onLoadMoreSessions:O,onNewSession:H,onEditingSessionNameChange:R,onStartEditingSession:A,onCancelEditingSession:z,onSaveEditingSession:J,onOpenProjectSettings:re,touchHandlerFactory:G,t:ie}){const $=e.jsx(Dc,{isLoading:n,loadingProgress:o,projectsCount:t.length,filteredProjectsCount:r.length,t:ie}),Z=!n&&t.length>0&&r.length>0;return e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:Z?r.map(te=>e.jsx(Mc,{project:te,selectedProject:s,selectedSession:a,isExpanded:i.has(te.name),isDeleting:f.has(te.name),isStarred:j(te.name),editingProject:c,editingName:u,sessions:N(te),initialSessionsLoaded:m.has(te.name),isLoadingSessions:!!d[te.name],currentTime:h,editingSession:p,editingSessionName:g,tasksEnabled:x,mcpServerStatus:b,onEditingNameChange:y,onToggleProject:k,onProjectSelect:I,onToggleStarProject:D,onStartEditingProject:C,onCancelEditingProject:v,onSaveProjectName:E,onDeleteProject:T,onSessionSelect:W,onDeleteSession:S,onLoadMoreSessions:O,onNewSession:H,onEditingSessionNameChange:R,onStartEditingSession:A,onCancelEditingSession:z,onSaveEditingSession:J,onOpenProjectSettings:re,touchHandlerFactory:G,t:ie},te.name)):$})}function Pc({isPWA:t,isMobile:r,isLoading:s,projects:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,updateAvailable:h,releaseInfo:p,latestVersion:g,onShowVersionModal:f,onShowSettings:x,projectListProps:b,t:N}){return e.jsxs("div",{className:"h-full flex flex-col bg-background/80 backdrop-blur-sm md:select-none md:w-72",style:{},children:[e.jsx(Nc,{isPWA:t,isMobile:r,isLoading:s,projectsCount:a.length,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,t:N}),e.jsx(Po,{className:"flex-1 px-1.5 py-1.5 md:py-2 overflow-y-auto overscroll-contain",children:e.jsx(Lc,{...b})}),e.jsx(wc,{updateAvailable:h,releaseInfo:p,latestVersion:g,onShowVersionModal:f,onShowSettings:x,t:N})]})}const $c=({onClose:t,onProjectCreated:r})=>{var _e;const{t:s}=We(),[a,n]=l.useState(1),[o,i]=l.useState("existing"),[c,u]=l.useState(""),[d,m]=l.useState(""),[h,p]=l.useState(""),[g,f]=l.useState("stored"),[x,b]=l.useState(""),[N,j]=l.useState(!1),[y,k]=l.useState(null),[I,D]=l.useState([]),[C,v]=l.useState(!1),[E,T]=l.useState([]),[W,S]=l.useState(!1),[O,H]=l.useState(!1),[R,A]=l.useState("~"),[z,J]=l.useState([]),[re,G]=l.useState(!1),[ie,$]=l.useState(!1),[Z,te]=l.useState(!1),[Q,_]=l.useState(""),[F,q]=l.useState(!1),[U,B]=l.useState(""),[ee,V]=l.useState([]);l.useEffect(()=>{a===2&&o==="new"&&d&&w()},[a,o,d]),l.useEffect(()=>{c.length>2?M(c):(T([]),S(!1))},[c]);const w=async()=>{try{v(!0);const pe=((await(await Be.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(ye=>ye.is_active);D(pe),pe.length>0&&!h&&p(pe[0].id.toString())}catch(L){console.error("Error loading GitHub tokens:",L)}finally{v(!1)}},M=async L=>{try{const K=L.lastIndexOf("/"),pe=K>0?L.substring(0,K):"~",Ie=await(await Be.browseFilesystem(pe)).json();if(Ie.suggestions){const Fe=Ie.suggestions.filter(Se=>Se.path.toLowerCase().startsWith(L.toLowerCase())&&Se.path.toLowerCase()!==L.toLowerCase());T(Fe.slice(0,5)),S(Fe.length>0)}}catch(K){console.error("Error loading path suggestions:",K)}},Y=()=>{if(k(null),a===1){if(!o){k(s("projectWizard.errors.selectType"));return}n(2)}else if(a===2){if(!c.trim()){k(s("projectWizard.errors.providePath"));return}n(3)}},se=()=>{k(null),n(a-1)},de=async()=>{j(!0),k(null),B("");try{if(o==="new"&&d){const ye=new URLSearchParams({path:c.trim(),githubUrl:d.trim()});g==="stored"&&h?ye.append("githubTokenId",h):g==="new"&&x&&ye.append("newGithubToken",x.trim());const Ie=`/api/projects/clone-progress?${ye}`;await new Promise((Fe,Se)=>{const Oe=new EventSource(Ie);Oe.onmessage=ne=>{try{const fe=JSON.parse(ne.data);fe.type==="progress"?B(fe.message):fe.type==="complete"?(Oe.close(),r&&r(fe.project),t(),Fe()):fe.type==="error"&&(Oe.close(),Se(new Error(fe.message)))}catch(fe){console.error("Error parsing SSE event:",fe)}},Oe.onerror=()=>{Oe.close(),Se(new Error("Connection lost during clone"))}});return}const L={workspaceType:o,path:c.trim()},K=await Be.createWorkspace(L),pe=await K.json();if(!K.ok)throw new Error(pe.details||pe.error||s("projectWizard.errors.failedToCreate"));r&&r(pe.project),t()}catch(L){console.error("Error creating workspace:",L),k(L.message||s("projectWizard.errors.failedToCreate"))}finally{j(!1)}},je=L=>{u(L.path),S(!1)},ge=async()=>{H(!0),await Re("~")},Re=async L=>{try{G(!0);const pe=await(await Be.browseFilesystem(L)).json();A(pe.path||L),J(pe.suggestions||[]),pe.drives&&Array.isArray(pe.drives)&&V(pe.drives)}catch(K){console.error("Error loading folders:",K)}finally{G(!1)}},Ne=(L,K=!1)=>{u(L),H(!1),K&&n(3)},De=async L=>{await Re(L)},Ue=async()=>{if(Q.trim()){q(!0),k(null);try{const L=R.includes("\\")?"\\":"/",K=`${R}${L}${Q.trim()}`,pe=await Be.createFolder(K),ye=await pe.json();if(!pe.ok)throw new Error(ye.error||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"));_(""),te(!1),await Re(ye.path||K)}catch(L){console.error("Error creating folder:",L),k(L.message||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{q(!1)}}};return e.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Zr,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s("projectWizard.title")})]}),e.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:N,children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"px-6 pt-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(L=>e.jsxs(it.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${L<a?"bg-green-500 text-white":L===a?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:L<a?e.jsx(Lt,{className:"w-4 h-4"}):L}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:s(L===1?"projectWizard.steps.type":L===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),L<3&&e.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${L<a?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},L))})}),e.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[y&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(xs,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:y})})]}),a===1&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:s("projectWizard.step1.question")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("button",{onClick:()=>i("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="existing"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(Zr,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.existing.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.existing.description")})]})]})}),e.jsx("button",{onClick:()=>i("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="new"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(br,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.new.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.new.description")})]})]})})]})]})}),a===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s(o==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),e.jsxs("div",{className:"relative flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ze,{type:"text",value:c,onChange:L=>u(L.target.value),placeholder:o==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),W&&E.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:E.map((L,K)=>e.jsxs("button",{onClick:()=>je(L),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:L.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:L.path})]},K))})]}),e.jsx(he,{type:"button",variant:"outline",onClick:ge,className:"px-3",title:"Browse folders",children:e.jsx(er,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s(o==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]}),o==="new"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.githubUrl")}),e.jsx(Ze,{type:"text",value:d,onChange:L=>m(L.target.value),placeholder:"https://github.com/username/repository",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.githubHelp")})]}),d&&!d.startsWith("git@")&&!d.startsWith("ssh://")&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(xa,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-medium text-gray-900 dark:text-white mb-1",children:s("projectWizard.step2.githubAuth")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step2.githubAuthHelp")})]})]}),C?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Sr,{className:"w-4 h-4 animate-spin"}),s("projectWizard.step2.loadingTokens")]}):I.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsx("button",{onClick:()=>f("stored"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="stored"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.storedToken")}),e.jsx("button",{onClick:()=>f("new"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="new"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.newToken")}),e.jsx("button",{onClick:()=>{f("none"),p(""),b("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="none"?"bg-green-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.nonePublic")})]}),g==="stored"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.selectToken")}),e.jsxs("select",{value:h,onChange:L=>p(L.target.value),className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:s("projectWizard.step2.selectTokenPlaceholder")}),I.map(L=>e.jsx("option",{value:L.id,children:L.credential_name},L.id))]})]}):g==="new"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.newToken")}),e.jsx(Ze,{type:"password",value:x,onChange:L=>b(L.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.tokenHelp")})]}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s("projectWizard.step2.publicRepoInfo")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.optionalTokenPublic")}),e.jsx(Ze,{type:"password",value:x,onChange:L=>b(L.target.value),placeholder:s("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.noTokensHelp")})]})]})]})]})]}),a===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:s("projectWizard.step3.reviewConfig")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.workspaceType")}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:s(o==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.path")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]}),o==="new"&&d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.cloneFrom")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:d})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.authentication")}),e.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:g==="stored"&&h?`${s("projectWizard.step3.usingStoredToken")} ${((_e=I.find(L=>L.id.toString()===h))==null?void 0:_e.credential_name)||"Unknown"}`:g==="new"&&x?s("projectWizard.step3.usingProvidedToken"):d.startsWith("git@")||d.startsWith("ssh://")?s("projectWizard.step3.sshKey","SSH Key"):s("projectWizard.step3.noAuthentication")})]})]})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:N&&U?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:s("projectWizard.step3.cloningRepository","Cloning repository...")}),e.jsx("code",{className:"block text-xs font-mono text-blue-700 dark:text-blue-300 whitespace-pre-wrap break-all",children:U})]}):e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s(o==="existing"?"projectWizard.step3.existingInfo":d?"projectWizard.step3.newWithClone":"projectWizard.step3.newEmpty")})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(he,{variant:"outline",onClick:a===1?t:se,disabled:N,children:a===1?s("projectWizard.buttons.cancel"):e.jsxs(e.Fragment,{children:[e.jsx(ga,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.back")]})}),e.jsx(he,{onClick:a===3?de:Y,disabled:N||a===1&&!o,children:N?e.jsxs(e.Fragment,{children:[e.jsx(Sr,{className:"w-4 h-4 mr-2 animate-spin"}),d?s("projectWizard.buttons.cloning","Cloning..."):s("projectWizard.buttons.creating")]}):a===3?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.createProject")]}):e.jsxs(e.Fragment,{children:[s("projectWizard.buttons.next"),e.jsx(rr,{className:"w-4 h-4 ml-1"})]})})]})]}),O&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(er,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>$(!ie),className:`p-2 rounded-md transition-colors ${ie?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:ie?"Hide hidden folders":"Show hidden folders",children:ie?e.jsx(sr,{className:"w-5 h-5"}):e.jsx(Zn,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>te(!Z),className:`p-2 rounded-md transition-colors ${Z?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:e.jsx(at,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>H(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Ve,{className:"w-5 h-5"})})]})]}),Z&&e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-blue-50 dark:bg-blue-900/20",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{type:"text",value:Q,onChange:L=>_(L.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:L=>{L.key==="Enter"&&Ue(),L.key==="Escape"&&(te(!1),_(""))},autoFocus:!0}),e.jsx(he,{size:"sm",onClick:Ue,disabled:!Q.trim()||F,children:F?e.jsx(Sr,{className:"w-4 h-4 animate-spin"}):"Create"}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>{te(!1),_("")},children:"Cancel"})]})}),ee.length>0&&e.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 mr-1",children:"Drives:"}),ee.map(L=>{const K=typeof L=="string"?L:L.name||L.path,pe=typeof L=="string"?`${L}\\`:L.path||`${L.name}\\`;return e.jsx("button",{onClick:()=>De(pe),className:`px-3 py-1.5 text-sm font-mono font-medium rounded-md border transition-colors ${R.startsWith(K)?"bg-blue-100 dark:bg-blue-900/50 border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:K},K)})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:re?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Sr,{className:"w-6 h-6 animate-spin text-gray-400"})}):e.jsxs("div",{className:"space-y-1",children:[R!=="~"&&R!=="/"&&!/^[A-Za-z]:\\?$/.test(R)&&e.jsxs("button",{onClick:()=>{const L=Math.max(R.lastIndexOf("/"),R.lastIndexOf("\\"));let K;L<=0?K="/":L===2&&/^[A-Za-z]:/.test(R)?K=R.substring(0,3):K=R.substring(0,L),De(K)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(er,{className:"w-5 h-5 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),z.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):z.filter(L=>ie||!L.name.startsWith(".")).sort((L,K)=>L.name.toLowerCase().localeCompare(K.name.toLowerCase())).map((L,K)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>De(L.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(Zr,{className:"w-5 h-5 text-blue-500"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:L.name})]}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>Ne(L.path,o==="existing"),className:"text-xs px-3",children:"Select"})]},K))]})}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:R})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[e.jsx(he,{variant:"outline",onClick:()=>{H(!1),te(!1),_("")},children:"Cancel"}),e.jsx(he,{variant:"outline",onClick:()=>Ne(R,o==="existing"),children:"Use this folder"})]})]})]})})]})};function _c({isOpen:t,onConfirm:r,onCancel:s,title:a,message:n,detail:o,variant:i="danger",confirmLabel:c="Confirm",cancelLabel:u="Cancel"}){const d=l.useRef(null);l.useEffect(()=>{var p;t&&((p=d.current)==null||p.focus())},[t]);const m=l.useCallback(p=>{p.key==="Escape"&&s()},[s]);if(!t)return null;const h=i==="danger";return Cr.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onKeyDown:m,children:e.jsxs("div",{className:"bg-card border border-border/40 rounded-2xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0 ${h?"bg-red-500/10":"bg-amber-500/10"}`,children:h?e.jsx($t,{className:"w-5 h-5 text-red-500"}):e.jsx(vt,{className:"w-5 h-5 text-amber-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1.5",children:a}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:n}),o&&e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-2 leading-relaxed",children:o})]})]})}),e.jsxs("div",{className:"flex gap-2 px-5 py-4 border-t border-border/20",children:[e.jsx("button",{ref:d,onClick:s,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:u}),e.jsx("button",{onClick:r,className:`flex-1 px-4 py-2.5 text-xs font-medium rounded-xl transition-opacity ${h?"bg-red-600 hover:bg-red-700 text-white":"bg-foreground hover:opacity-90 text-background"}`,children:c})]})]})}),document.body)}function Sa(){const[t,r]=l.useState(null),s=l.useCallback(i=>new Promise(c=>{r({...i,resolve:c})}),[]),a=l.useCallback(()=>{t==null||t.resolve(!0),r(null)},[t]),n=l.useCallback(()=>{t==null||t.resolve(!1),r(null)},[t]),o=t?{isOpen:!0,onConfirm:a,onCancel:n,title:t.title,message:t.message,detail:t.detail,variant:t.variant,confirmLabel:t.confirmLabel,cancelLabel:t.cancelLabel}:{isOpen:!1,onConfirm:()=>{},onCancel:()=>{},title:"",message:""};return{confirm:s,dialogProps:o,ConfirmDialog:_c}}const Fc="2.9.9";function zc(){const{t}=We("settings"),{confirm:r,dialogProps:s,ConfirmDialog:a}=Sa(),[n,o]=l.useState([]),[i,c]=l.useState([]),[u,d]=l.useState(!0),[m,h]=l.useState(!1),[p,g]=l.useState(!1),[f,x]=l.useState(""),[b,N]=l.useState(""),[j,y]=l.useState(""),[k,I]=l.useState(""),[D,C]=l.useState({}),[v,E]=l.useState(null),[T,W]=l.useState(null),{updateAvailable:S,latestVersion:O,releaseInfo:H}=ho("AnitChaudhry","UpfynAI-Code");l.useEffect(()=>{R()},[]);const R=async()=>{try{d(!0);const te=await(await Me("/api/settings/api-keys")).json();o(te.apiKeys||[]);const _=await(await Me("/api/settings/credentials?type=github_token")).json();c(_.credentials||[])}catch(Z){console.error("Error fetching settings:",Z)}finally{d(!1)}},A=async()=>{if(f.trim())try{const te=await(await Me("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:f})})).json();te.success&&(W(te.apiKey),x(""),h(!1),R())}catch(Z){console.error("Error creating API key:",Z)}},z=async Z=>{if(await r({title:t("apiKeys.deleteTitle","Delete API Key"),message:t("apiKeys.confirmDelete"),confirmLabel:t("apiKeys.deleteButton","Delete"),cancelLabel:t("common:cancel","Cancel")}))try{await Me(`/api/settings/api-keys/${Z}`,{method:"DELETE"}),R()}catch(Q){console.error("Error deleting API key:",Q)}},J=async(Z,te)=>{try{await Me(`/api/settings/api-keys/${Z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!te})}),R()}catch(Q){console.error("Error toggling API key:",Q)}},re=async()=>{if(!(!b.trim()||!j.trim()))try{(await(await Me("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:b,credentialType:"github_token",credentialValue:j,description:k})})).json()).success&&(N(""),y(""),I(""),g(!1),R())}catch(Z){console.error("Error creating GitHub credential:",Z)}},G=async Z=>{if(await r({title:t("apiKeys.github.deleteTitle","Delete GitHub Credential"),message:t("apiKeys.github.confirmDelete"),confirmLabel:t("apiKeys.deleteButton","Delete"),cancelLabel:t("common:cancel","Cancel")}))try{await Me(`/api/settings/credentials/${Z}`,{method:"DELETE"}),R()}catch(Q){console.error("Error deleting GitHub credential:",Q)}},ie=async(Z,te)=>{try{await Me(`/api/settings/credentials/${Z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!te})}),R()}catch(Q){console.error("Error toggling GitHub credential:",Q)}},$=(Z,te)=>{navigator.clipboard.writeText(Z),E(te),setTimeout(()=>E(null),2e3)};return u?e.jsx("div",{className:"text-muted-foreground",children:t("apiKeys.loading")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-8",children:[T&&e.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[e.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:t("apiKeys.newKey.alertTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t("apiKeys.newKey.alertMessage")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:T.apiKey}),e.jsx(he,{size:"sm",variant:"outline",onClick:()=>$(T.apiKey,"new"),children:v==="new"?e.jsx(Lt,{className:"h-4 w-4"}):e.jsx(ha,{className:"h-4 w-4"})})]}),e.jsx(he,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>W(null),children:t("apiKeys.newKey.iveSavedIt")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xa,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.title")})]}),e.jsxs(he,{size:"sm",onClick:()=>h(!m),children:[e.jsx(at,{className:"h-4 w-4 mr-1"}),t("apiKeys.newButton")]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:t("apiKeys.description")}),e.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[t("apiKeys.apiDocsLink"),e.jsx(Fa,{className:"h-3 w-3"})]})]}),m&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[e.jsx(Ze,{placeholder:t("apiKeys.form.placeholder"),value:f,onChange:Z=>x(Z.target.value),className:"mb-2"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(he,{onClick:A,children:t("apiKeys.form.createButton")}),e.jsx(he,{variant:"outline",onClick:()=>h(!1),children:t("apiKeys.form.cancelButton")})]})]}),e.jsx("div",{className:"space-y-2",children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.empty")}):n.map(Z=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:Z.key_name}),e.jsx("code",{className:"text-xs text-muted-foreground",children:Z.api_key}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.list.created")," ",new Date(Z.created_at).toLocaleDateString(),Z.last_used&&` • ${t("apiKeys.list.lastUsed")} ${new Date(Z.last_used).toLocaleDateString()}`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{size:"sm",variant:Z.is_active?"outline":"secondary",onClick:()=>J(Z.id,Z.is_active),children:Z.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>z(Z.id),children:e.jsx(yt,{className:"h-4 w-4"})})]})]},Z.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yi,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.github.title")})]}),e.jsxs(he,{size:"sm",onClick:()=>g(!p),children:[e.jsx(at,{className:"h-4 w-4 mr-1"}),t("apiKeys.github.addButton")]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("apiKeys.github.descriptionAlt")}),p&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[e.jsx(Ze,{placeholder:t("apiKeys.github.form.namePlaceholder"),value:b,onChange:Z=>N(Z.target.value)}),e.jsxs("div",{className:"relative",children:[e.jsx(Ze,{type:D.new?"text":"password",placeholder:t("apiKeys.github.form.tokenPlaceholder"),value:j,onChange:Z=>y(Z.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>C({...D,new:!D.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:D.new?e.jsx(Zn,{className:"h-4 w-4"}):e.jsx(sr,{className:"h-4 w-4"})})]}),e.jsx(Ze,{placeholder:t("apiKeys.github.form.descriptionPlaceholder"),value:k,onChange:Z=>I(Z.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(he,{onClick:re,children:t("apiKeys.github.form.addButton")}),e.jsx(he,{variant:"outline",onClick:()=>{g(!1),N(""),y(""),I("")},children:t("apiKeys.github.form.cancelButton")})]}),e.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:t("apiKeys.github.form.howToCreate")})]}),e.jsx("div",{className:"space-y-2",children:i.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.github.empty")}):i.map(Z=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:Z.credential_name}),Z.description&&e.jsx("div",{className:"text-xs text-muted-foreground",children:Z.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.github.added")," ",new Date(Z.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{size:"sm",variant:Z.is_active?"outline":"secondary",onClick:()=>ie(Z.id,Z.is_active),children:Z.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>G(Z.id),children:e.jsx(yt,{className:"h-4 w-4"})})]})]},Z.id))})]}),e.jsx("div",{className:"pt-6 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[e.jsxs("a",{href:(H==null?void 0:H.htmlUrl)||"https://github.com/AnitChaudhry/UpfynAI-Code/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Fc]}),S&&O&&e.jsxs("a",{href:(H==null?void 0:H.htmlUrl)||"https://github.com/AnitChaudhry/UpfynAI-Code/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[e.jsx("span",{className:"text-[10px]",children:t("apiKeys.version.updateAvailable",{version:O})}),e.jsx(Fa,{className:"h-2.5 w-2.5"})]})]})})]}),e.jsx(a,{...s})]})}function Rc(){const{t}=We("settings"),[r,s]=l.useState(""),[a,n]=l.useState(""),[o,i]=l.useState(!1),[c,u]=l.useState(!1),[d,m]=l.useState(null);l.useEffect(()=>{h()},[]);const h=async()=>{try{i(!0);const g=await Me("/api/user/git-config");if(g.ok){const f=await g.json();s(f.gitName||""),n(f.gitEmail||"")}}catch(g){console.error("Error loading git config:",g)}finally{i(!1)}},p=async()=>{try{u(!0);const g=await Me("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:a})});if(g.ok)m("success"),setTimeout(()=>m(null),3e3);else{const f=await g.json();m("error"),console.error("Failed to save git config:",f.error)}}catch(g){console.error("Error saving git config:",g),m("error")}finally{u(!1)}};return e.jsx("div",{className:"space-y-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(br,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("git.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("git.description")}),e.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:t("git.name.label")}),e.jsx(Ze,{id:"settings-git-name",type:"text",value:r,onChange:g=>s(g.target.value),placeholder:"John Doe",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.name.help")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:t("git.email.label")}),e.jsx(Ze,{id:"settings-git-email",type:"email",value:a,onChange:g=>n(g.target.value),placeholder:"john@example.com",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.email.help")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{onClick:p,disabled:c||!r||!a,children:t(c?"git.actions.saving":"git.actions.save")}),d==="success"&&e.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[e.jsx(Lt,{className:"w-4 h-4"}),t("git.status.success")]})]})]})]})})}function Oc(){const{t}=We("settings"),{tasksEnabled:r,setTasksEnabled:s,isTaskMasterInstalled:a,isCheckingInstallation:n}=Lr();return e.jsx("div",{className:"space-y-8",children:n?e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("tasks.checking")})]})}):e.jsxs(e.Fragment,{children:[!a&&e.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:t("tasks.notInstalled.title")}),e.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[e.jsx("p",{children:t("tasks.notInstalled.description")}),e.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:e.jsx("code",{children:t("tasks.notInstalled.installCommand")})}),e.jsx("div",{children:e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.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 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 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.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),t("tasks.notInstalled.viewOnGitHub"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:t("tasks.notInstalled.afterInstallation")}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[e.jsx("li",{children:t("tasks.notInstalled.steps.restart")}),e.jsx("li",{children:t("tasks.notInstalled.steps.autoAvailable")}),e.jsx("li",{children:t("tasks.notInstalled.steps.initCommand")})]})]})]})]})]})}),a&&e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:t("tasks.settings.enableLabel")}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:t("tasks.settings.enableDescription")})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:o=>s(o.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]})})})]})})}const Bc={claude:{name:"Claude",color:"blue"},cursor:{name:"Cursor",color:"purple"},codex:{name:"Codex",color:"gray"}},Wc={blue:{border:"border-l-blue-500 md:border-l-blue-500",borderBottom:"border-b-blue-500",bg:"bg-blue-50 dark:bg-blue-900/20",dot:"bg-blue-500"},purple:{border:"border-l-purple-500 md:border-l-purple-500",borderBottom:"border-b-purple-500",bg:"bg-purple-50 dark:bg-purple-900/20",dot:"bg-purple-500"},gray:{border:"border-l-gray-700 dark:border-l-gray-300",borderBottom:"border-b-gray-700 dark:border-b-gray-300",bg:"bg-gray-100 dark:bg-gray-800/50",dot:"bg-gray-700 dark:bg-gray-300"}};function dr({agentId:t,authStatus:r,isSelected:s,onClick:a,isMobile:n=!1}){const{t:o}=We("settings"),i=Bc[t],c=Wc[i.color];return n?e.jsx("button",{onClick:a,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${s?`${c.borderBottom} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(ft,{provider:t,className:"w-5 h-5"}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:i.name}),(r==null?void 0:r.authenticated)&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`})]})}):e.jsxs("button",{onClick:a,className:`w-full text-left p-3 border-l-4 transition-colors ${s?`${c.border} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ft,{provider:t,className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:i.name})]}),e.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:r!=null&&r.loading?e.jsx("span",{className:"text-gray-400",children:o("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`}),e.jsx("span",{className:"truncate max-w-[120px]",title:r.email,children:r.email||o("agents.authStatus.connected")})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),e.jsx("span",{children:o("agents.authStatus.notConnected")})]})})]})}const Uc={claude:{name:"Claude",description:"Anthropic Claude AI assistant",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800",textClass:"text-blue-900 dark:text-blue-100",subtextClass:"text-blue-700 dark:text-blue-300",buttonClass:"bg-blue-600 hover:bg-blue-700"},cursor:{name:"Cursor",description:"Cursor AI-powered code editor",bgClass:"bg-purple-50 dark:bg-purple-900/20",borderClass:"border-purple-200 dark:border-purple-800",textClass:"text-purple-900 dark:text-purple-100",subtextClass:"text-purple-700 dark:text-purple-300",buttonClass:"bg-purple-600 hover:bg-purple-700"},codex:{name:"Codex",description:"OpenAI Codex AI assistant",bgClass:"bg-gray-100 dark:bg-gray-800/50",borderClass:"border-gray-300 dark:border-gray-600",textClass:"text-gray-900 dark:text-gray-100",subtextClass:"text-gray-700 dark:text-gray-300",buttonClass:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"}};function Hc({agent:t,authStatus:r,onLogin:s}){const{t:a}=We("settings"),n=Uc[t];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(ft,{provider:t,className:"w-6 h-6"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a(`agents.account.${t}.description`)})]})]}),e.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:a("agents.connectionStatus")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.loading?a("agents.authStatus.checkingAuth"):r!=null&&r.authenticated?a("agents.authStatus.loggedInAs",{email:r.email||a("agents.authStatus.authenticatedUser")}):a("agents.authStatus.notConnected")})]}),e.jsx("div",{children:r!=null&&r.loading?e.jsx(bt,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:a("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsx(bt,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:a("agents.authStatus.connected")}):e.jsx(bt,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:a("agents.authStatus.disconnected")})})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthenticate"):a("agents.login.title")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthDescription"):a("agents.login.description",{agent:n.name})})]}),e.jsxs(he,{onClick:s,className:`${n.buttonClass} text-white`,size:"sm",children:[e.jsx(vi,{className:"w-4 h-4 mr-2"}),r!=null&&r.authenticated?a("agents.login.reLoginButton"):a("agents.login.button")]})]})}),(r==null?void 0:r.error)&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:a("agents.error",{error:r.error})})})]})})]})}const Gc=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],Vc=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function qc({skipPermissions:t,setSkipPermissions:r,allowedTools:s,setAllowedTools:a,disallowedTools:n,setDisallowedTools:o,newAllowedTool:i,setNewAllowedTool:c,newDisallowedTool:u,setNewDisallowedTool:d}){const{t:m}=We("settings"),h=x=>{x&&!s.includes(x)&&(a([...s,x]),c(""))},p=x=>{a(s.filter(b=>b!==x))},g=x=>{x&&!n.includes(x)&&(o([...n,x]),d(""))},f=x=>{o(n.filter(b=>b!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.claudeDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:i,onChange:x=>c(x.target.value),placeholder:m("permissions.allowedTools.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),h(i))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>h(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedTools.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Gc.map(x=>e.jsx(he,{variant:"outline",size:"sm",onClick:()=>h(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>p(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedTools.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:u,onChange:x=>d(x.target.value),placeholder:m("permissions.blockedTools.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(u))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>g(u),disabled:!u,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>f(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedTools.empty")})]})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:m("permissions.toolExamples.title")}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," ",m("permissions.toolExamples.bashGitLog")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," ",m("permissions.toolExamples.bashGitDiff")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," ",m("permissions.toolExamples.write")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," ",m("permissions.toolExamples.bashRm")]})]})]})]})}function Kc({skipPermissions:t,setSkipPermissions:r,allowedCommands:s,setAllowedCommands:a,disallowedCommands:n,setDisallowedCommands:o,newAllowedCommand:i,setNewAllowedCommand:c,newDisallowedCommand:u,setNewDisallowedCommand:d}){const{t:m}=We("settings"),h=x=>{x&&!s.includes(x)&&(a([...s,x]),c(""))},p=x=>{a(s.filter(b=>b!==x))},g=x=>{x&&!n.includes(x)&&(o([...n,x]),d(""))},f=x=>{o(n.filter(b=>b!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.cursorDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:i,onChange:x=>c(x.target.value),placeholder:m("permissions.allowedCommands.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),h(i))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>h(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedCommands.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Vc.map(x=>e.jsx(he,{variant:"outline",size:"sm",onClick:()=>h(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>p(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedCommands.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:u,onChange:x=>d(x.target.value),placeholder:m("permissions.blockedCommands.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(u))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>g(u),disabled:!u,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>f(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedCommands.empty")})]})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:m("permissions.shellExamples.title")}),e.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," ",m("permissions.shellExamples.ls")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," ",m("permissions.shellExamples.gitStatus")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," ",m("permissions.shellExamples.npmInstall")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," ",m("permissions.shellExamples.rmRf")]})]})]})]})}function Jc({permissionMode:t,setPermissionMode:r}){const{t:s}=We("settings");return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:s("permissions.codex.permissionMode")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("permissions.codex.description")}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("default"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>r("default"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:s("permissions.codex.modes.default.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("permissions.codex.modes.default.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("acceptEdits"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>r("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:s("permissions.codex.modes.acceptEdits.title")}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:s("permissions.codex.modes.acceptEdits.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("bypassPermissions"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>r("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:[s("permissions.codex.modes.bypassPermissions.title"),e.jsx($t,{className:"w-4 h-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:s("permissions.codex.modes.bypassPermissions.description")})]})]})}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:s("permissions.codex.technicalDetails")}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.default.title"),":"]})," ",s("permissions.codex.technicalInfo.default")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.acceptEdits.title"),":"]})," ",s("permissions.codex.technicalInfo.acceptEdits")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.bypassPermissions.title"),":"]})," ",s("permissions.codex.technicalInfo.bypassPermissions")]}),e.jsx("p",{className:"text-xs opacity-75",children:s("permissions.codex.technicalInfo.overrideNote")})]})]})]})})}function $s({agent:t,...r}){return t==="claude"?e.jsx(qc,{...r}):t==="cursor"?e.jsx(Kc,{...r}):t==="codex"?e.jsx(Jc,{...r}):null}const Yc=t=>{switch(t){case"stdio":return e.jsx(vt,{className:"w-4 h-4"});case"sse":return e.jsx(tr,{className:"w-4 h-4"});case"http":return e.jsx(qs,{className:"w-4 h-4"});default:return e.jsx($r,{className:"w-4 h-4"})}};function Qc({servers:t,onAdd:r,onEdit:s,onDelete:a,onTest:n,onDiscoverTools:o,testResults:i,serverTools:c,toolsLoading:u}){const{t:d}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d("mcpServers.description.claude")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),d("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(m=>{var h,p,g,f;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[Yc(m.type),e.jsx("span",{className:"font-medium text-foreground",children:m.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:m.type}),e.jsx(bt,{variant:"outline",className:"text-xs",children:m.scope==="local"?d("mcpServers.scope.local"):m.scope==="user"?d("mcpServers.scope.user"):m.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[m.type==="stdio"&&((h=m.config)==null?void 0:h.command)&&e.jsxs("div",{children:[d("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.command})]}),(m.type==="sse"||m.type==="http")&&((p=m.config)==null?void 0:p.url)&&e.jsxs("div",{children:[d("mcpServers.config.url"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.url})]}),((g=m.config)==null?void 0:g.args)&&m.config.args.length>0&&e.jsxs("div",{children:[d("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.args.join(" ")})]})]}),(i==null?void 0:i[m.id])&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[m.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:e.jsx("div",{className:"font-medium",children:i[m.id].message})}),(c==null?void 0:c[m.id])&&((f=c[m.id].tools)==null?void 0:f.length)>0&&e.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[e.jsxs("div",{className:"font-medium",children:[d("mcpServers.tools.title")," ",d("mcpServers.tools.count",{count:c[m.id].tools.length})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[c[m.id].tools.slice(0,5).map((x,b)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:x.name},b)),c[m.id].tools.length>5&&e.jsx("span",{className:"text-xs opacity-75",children:d("mcpServers.tools.more",{count:c[m.id].tools.length-5})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(m),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:d("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(m.id,m.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:d("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},m.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:d("mcpServers.empty")})]})]})}function Xc({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.cursor")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(vt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},o.name||o.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]})]})}function Zc({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.codex")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i,c,u;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(vt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]}),((c=o.config)==null?void 0:c.args)&&o.config.args.length>0&&e.jsxs("div",{children:[n("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.args.join(" ")})]}),((u=o.config)==null?void 0:u.env)&&Object.keys(o.config.env).length>0&&e.jsxs("div",{children:[n("mcpServers.config.environment"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(o.config.env).map(([d,m])=>`${d}=${m}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},o.name)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]}),e.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:n("mcpServers.help.title")}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:n("mcpServers.help.description")})]})]})}function _s({agent:t,...r}){return t==="claude"?e.jsx(Qc,{...r}):t==="cursor"?e.jsx(Xc,{...r}):t==="codex"?e.jsx(Zc,{...r}):null}const ed=[{name:"filesystem",description:"Read/write local files and directories",category:"Files & Code",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","/path"]}},{name:"github",description:"GitHub repos, issues, and PRs",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-github"]}},{name:"postgres",description:"Query PostgreSQL databases",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-postgres"]}},{name:"brave-search",description:"Web search via Brave Search API",category:"AI & Search",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-brave-search"]}},{name:"memory",description:"Persistent memory store for AI agents",category:"AI & Search",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-memory"]}},{name:"puppeteer",description:"Browser automation and scraping",category:"DevOps",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-puppeteer"]}},{name:"sqlite",description:"Query SQLite databases",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-sqlite"]}},{name:"fetch",description:"HTTP fetch and web content retrieval",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-fetch"]}}],td={"Files & Code":"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300","Data & APIs":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300","AI & Search":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300",DevOps:"bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-300"};function rd(){const[t,r]=l.useState([]),[s,a]=l.useState(!0),[n,o]=l.useState(null),[i,c]=l.useState(""),u=l.useCallback(async()=>{a(!0);try{const g=await(await Me("/api/mcp/config/read")).json();g.success&&g.servers&&r(g.servers)}catch{}a(!1)},[]);l.useEffect(()=>{u();const p=window.location.origin;c(`${p}/mcp`)},[u]);const d=async p=>{o(p.name);try{(await Me("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:p.name,config:{command:p.installConfig.command,args:p.installConfig.args}})})).ok&&await u()}catch{}o(null)},m=p=>t.some(g=>g.name===p),h=p=>{navigator.clipboard.writeText(p)};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Installed Servers"}),e.jsx("button",{onClick:()=>void u(),className:"ml-auto text-sm text-muted-foreground hover:text-foreground transition-colors",title:"Refresh",children:e.jsx("svg",{className:`w-4 h-4 ${s?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading servers..."]}):t.length===0?e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-4 py-4 border border-border/30",children:"No MCP servers installed. Browse the directory below to get started."}):e.jsx("div",{className:"grid gap-2",children:t.map(p=>{var g,f;return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-card border border-border/50 rounded-lg",children:[e.jsx("svg",{className:"w-4 h-4 text-primary flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name}),p.type==="stdio"&&((g=p.config)==null?void 0:g.command)&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:[p.config.command," ",p.config.args?p.config.args.join(" "):""]}),(p.type==="http"||p.type==="sse")&&((f=p.config)==null?void 0:f.url)&&e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:p.config.url})]}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.type==="stdio"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":p.type==="sse"?"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300"}`,children:p.type}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.scope==="user"?"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300"}`,children:p.scope})]},p.id)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Server Directory"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Popular MCP servers"})]}),e.jsx("div",{className:"grid gap-2",children:ed.map(p=>{const g=m(p.name);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/20 border border-border/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${td[p.category]||"bg-gray-100 text-gray-600"}`,children:p.category})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:p.description})]}),g?e.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 font-medium flex items-center gap-1 flex-shrink-0",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Installed"]}):e.jsx("button",{onClick:()=>void d(p),disabled:n===p.name,className:"text-xs px-3 py-1.5 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 font-medium transition-colors flex-shrink-0 min-h-[36px]",children:n===p.name?"Installing...":"Install"})]},p.name)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Your Upfyn MCP Server"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Connect external AI clients (Claude Desktop, Cursor, etc.) to your Upfyn instance using MCP."}),e.jsxs("div",{className:"bg-muted/30 border border-border/30 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"MCP Endpoint"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{className:"flex-1 text-sm bg-card border border-border rounded px-3 py-1.5 font-mono text-foreground truncate",children:i}),e.jsx("button",{onClick:()=>h(i),className:"px-2.5 py-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",title:"Copy",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Claude Desktop Config"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{className:"flex-1 text-xs bg-card border border-border rounded px-3 py-1.5 font-mono text-foreground overflow-x-auto",children:`{ "mcpServers": { "upfyn": { "url": "${i}" } } }`}),e.jsx("button",{onClick:()=>h(`{ "mcpServers": { "upfyn": { "url": "${i}" } } }`),className:"px-2.5 py-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 min-w-[44px] min-h-[44px] flex items-center justify-center",title:"Copy config",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})]})]})]})}function _o({compact:t=!1}){const{i18n:r,t:s}=We("settings"),a=n=>{const o=n.target.value;r.changeLanguage(o)};return t?e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(eo,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s("account.language")]}),e.jsx("select",{value:r.language,onChange:a,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400",children:Pa.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:s("account.languageLabel")}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("account.languageDescription")})]}),e.jsx("select",{value:r.language,onChange:a,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-36",children:Pa.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]})})}function sd(){const[t,r]=l.useState([]),[s,a]=l.useState(!0),[n,o]=l.useState(null),[i,c]=l.useState(!1),u=async()=>{try{const f=await Me("/api/sessions");if(f.ok){const x=await f.json();r(x.sessions||[])}}catch{}a(!1)};l.useEffect(()=>{u();const f=setInterval(u,1e4);return()=>clearInterval(f)},[]);const d=async(f,x)=>{o(f);try{await Me(`/api/sessions/${f}/abort`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:x})}),await u()}catch{}o(null)},m=async()=>{c(!0);try{await Me("/api/sessions/abort-all",{method:"POST"}),await u()}catch{}c(!1)},h=f=>{if(!f)return"";const x=Date.now()-new Date(f).getTime(),b=Math.floor(x/1e3);if(b<60)return`${b}s`;const N=Math.floor(b/60);return N<60?`${N}m`:`${Math.floor(N/60)}h ${N%60}m`},p=f=>({claude:"Claude",cursor:"Cursor",codex:"Codex"})[f]||f,g=f=>({claude:"text-orange-500",cursor:"text-blue-500",codex:"text-green-500"})[f]||"text-gray-500";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Ks,{className:"w-5 h-5"})," Active Sessions"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:u,className:"text-sm text-muted-foreground hover:text-foreground flex items-center gap-1",children:[e.jsx(Vs,{className:"w-3.5 h-3.5"})," Refresh"]}),t.length>0&&e.jsxs("button",{onClick:m,disabled:i,className:"text-sm text-red-500 hover:text-red-400 flex items-center gap-1 disabled:opacity-50",children:[e.jsx(za,{className:"w-3.5 h-3.5"})," ",i?"Aborting...":"Abort All"]})]})]}),s?e.jsx("div",{className:"text-center text-muted-foreground text-sm py-8",children:"Loading sessions..."}):t.length===0?e.jsxs("div",{className:"bg-muted/30 border border-border rounded-lg p-8 text-center",children:[e.jsx(Ks,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No active sessions"}),e.jsx("p",{className:"text-muted-foreground/60 text-xs mt-1",children:"Sessions appear here when you run Claude, Cursor, or Codex commands"})]}):e.jsx("div",{className:"border border-border rounded-lg overflow-hidden divide-y divide-border",children:t.map(f=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-mono text-foreground truncate",children:f.sessionId}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:`text-xs font-medium ${g(f.provider)}`,children:p(f.provider)}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium ${f.status==="active"?"bg-green-500/10 text-green-500 dark:text-green-400":"bg-gray-500/10 text-gray-500"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.status==="active"?"bg-green-500":"bg-gray-400"}`}),f.status]}),f.startedAt&&e.jsx("span",{className:"text-xs text-muted-foreground",children:h(f.startedAt)})]})]}),e.jsx("button",{onClick:()=>d(f.sessionId,f.provider),disabled:n===f.sessionId,className:"p-1.5 rounded hover:bg-red-500/10 text-red-500 hover:text-red-400 transition-colors disabled:opacity-50",title:"Abort session",children:e.jsx(za,{className:"w-4 h-4"})})]},f.sessionId))})]})}function ad({isOpen:t,onClose:r,projects:s=[],initialTab:a="agents"}){var Wr,et,It,Ms;const{isDarkMode:n,toggleDarkMode:o}=pa(),{t:i}=We("settings"),{addToast:c}=hr(),{confirm:u,dialogProps:d,ConfirmDialog:m}=Sa(),[h,p]=l.useState([]),[g,f]=l.useState([]),[x,b]=l.useState(""),[N,j]=l.useState(""),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState(null),[E,T]=l.useState("name"),[W,S]=l.useState([]),[O,H]=l.useState(!1),[R,A]=l.useState(null),[z,J]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[re,G]=l.useState(!1),[ie,$]=l.useState({}),[Z,te]=l.useState({}),[Q,_]=l.useState({}),[F,q]=l.useState(a),[U,B]=l.useState(""),[ee,V]=l.useState("claude"),[w,M]=l.useState("account"),[Y,se]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[de,je]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[ge,Re]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[Ne,De]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Ue,_e]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[L,K]=l.useState([]),[pe,ye]=l.useState([]),[Ie,Fe]=l.useState(!1),[Se,Oe]=l.useState(""),[ne,fe]=l.useState(""),[Ee,Le]=l.useState([]),[Pe,Ae]=l.useState([]),[Ge,ae]=l.useState("default"),[be,ze]=l.useState(!1),[Ce,Ye]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[lt,dt]=l.useState(null),[Tt,At]=l.useState(!1),[wt,Ft]=l.useState(!1),[le,ue]=l.useState(""),[ce,we]=l.useState(null),[He,Qe]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Xe,ut]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Vt,ht]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),jt=async()=>{try{const P=await Me("/api/cursor/mcp");if(P.ok){const X=await P.json();Le(X.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(P){console.error("Error fetching Cursor MCP servers:",P)}},st=async()=>{try{const P=await Me("/api/codex/mcp/config/read");if(P.ok){const oe=await P.json();if(oe.success&&oe.servers){Ae(oe.servers);return}}const X=await Me("/api/codex/mcp/cli/list");if(X.ok){const oe=await X.json();if(oe.success&&oe.servers){const ve=oe.servers.map(Ke=>({id:Ke.name,name:Ke.name,type:Ke.type||"stdio",scope:"user",config:{command:Ke.command||"",args:Ke.args||[],env:Ke.env||{}}}));Ae(ve)}}}catch(P){console.error("Error fetching Codex MCP servers:",P)}},tt=async()=>{try{const P=await Me("/api/mcp/config/read");if(P.ok){const ve=await P.json();if(ve.success&&ve.servers){S(ve.servers);return}}const X=await Me("/api/mcp/cli/list");if(X.ok){const ve=await X.json();if(ve.success&&ve.servers){const Ke=ve.servers.map(nt=>({id:nt.name,name:nt.name,type:nt.type,scope:"user",config:{command:nt.command||"",args:nt.args||[],env:nt.env||{},url:nt.url||"",headers:nt.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));S(Ke);return}}const oe=await Me("/api/mcp/servers?scope=user");if(oe.ok){const ve=await oe.json();S(ve.servers||[])}else console.error("Failed to fetch MCP servers")}catch(P){console.error("Error fetching MCP servers:",P)}},zt=async P=>{var X,oe,ve,Ke,nt;try{R&&await or(R.id,"user");const cr=await Me("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath,command:(X=P.config)==null?void 0:X.command,args:((oe=P.config)==null?void 0:oe.args)||[],url:(ve=P.config)==null?void 0:ve.url,headers:((Ke=P.config)==null?void 0:Ke.headers)||{},env:((nt=P.config)==null?void 0:nt.env)||{}})});if(cr.ok){const Ur=await cr.json();if(Ur.success)return await tt(),!0;throw new Error(Ur.error||"Failed to save server via Claude CLI")}else{const Ur=await cr.json();throw new Error(Ur.error||"Failed to save server")}}catch(cr){throw console.error("Error saving MCP server:",cr),cr}},or=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/cli/remove/${P}?scope=${X}`,{method:"DELETE"});if(oe.ok){const ve=await oe.json();if(ve.success)return await tt(),!0;throw new Error(ve.error||"Failed to delete server via Claude CLI")}else{const ve=await oe.json();throw new Error(ve.error||"Failed to delete server")}}catch(oe){throw console.error("Error deleting MCP server:",oe),oe}},bs=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/servers/${P}/test?scope=${X}`,{method:"POST"});if(oe.ok)return(await oe.json()).testResult;{const ve=await oe.json();throw new Error(ve.error||"Failed to test server")}}catch(oe){throw console.error("Error testing MCP server:",oe),oe}},ys=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/servers/${P}/tools?scope=${X}`,{method:"POST"});if(oe.ok)return(await oe.json()).toolsResult;{const ve=await oe.json();throw new Error(ve.error||"Failed to discover tools")}}catch(oe){throw console.error("Error discovering MCP tools:",oe),oe}},vs=async P=>{var X,oe,ve;try{lt&&await vr(lt.id);const Ke=await Me("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,command:(X=P.config)==null?void 0:X.command,args:((oe=P.config)==null?void 0:oe.args)||[],env:((ve=P.config)==null?void 0:ve.env)||{}})});if(Ke.ok){const nt=await Ke.json();if(nt.success)return await st(),!0;throw new Error(nt.error||"Failed to save Codex MCP server")}else{const nt=await Ke.json();throw new Error(nt.error||"Failed to save server")}}catch(Ke){throw console.error("Error saving Codex MCP server:",Ke),Ke}},vr=async P=>{try{const X=await Me(`/api/codex/mcp/cli/remove/${P}`,{method:"DELETE"});if(X.ok){const oe=await X.json();if(oe.success)return await st(),!0;throw new Error(oe.error||"Failed to delete Codex MCP server")}else{const oe=await X.json();throw new Error(oe.error||"Failed to delete server")}}catch(X){throw console.error("Error deleting Codex MCP server:",X),X}},ir=()=>{Ye({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),dt(null),ze(!1)},_r=(P=null)=>{var X,oe,ve;P?(dt(P),Ye({name:P.name,type:P.type||"stdio",config:{command:((X=P.config)==null?void 0:X.command)||"",args:((oe=P.config)==null?void 0:oe.args)||[],env:((ve=P.config)==null?void 0:ve.env)||{}}})):ir(),ze(!0)},ks=async P=>{P.preventDefault(),At(!0);try{lt&&await vr(lt.name),await vs(Ce),ir(),v("success")}catch(X){c(`Error: ${X.message}`,"error"),v("error")}finally{At(!1)}},ws=async P=>{if(await u({title:i("mcp.deleteTitle","Delete MCP Server"),message:i("mcp.confirmDelete","Are you sure you want to delete this MCP server?"),confirmLabel:i("mcp.deleteButton","Delete"),cancelLabel:i("common:cancel","Cancel")}))try{await vr(P),v("success")}catch(oe){c(`Error: ${oe.message}`,"error"),v("error")}};l.useEffect(()=>{t&&(js(),Fr(),zr(),Rr(),q(a))},[t,a]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",Y),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Y]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",de.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[de]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",ge.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ge]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",Ne.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ne]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Ue),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ue]);const js=async()=>{try{const P=localStorage.getItem("claude-settings");if(P){const ve=JSON.parse(P);p(ve.allowedTools||[]),f(ve.disallowedTools||[]),k(ve.skipPermissions||!1),T(ve.projectSortOrder||"name")}else p([]),f([]),k(!1),T("name");const X=localStorage.getItem("cursor-tools-settings");if(X){const ve=JSON.parse(X);K(ve.allowedCommands||[]),ye(ve.disallowedCommands||[]),Fe(ve.skipPermissions||!1)}else K([]),ye([]),Fe(!1);const oe=localStorage.getItem("codex-settings");if(oe){const ve=JSON.parse(oe);ae(ve.permissionMode||"default")}else ae("default");await tt(),await jt(),await st()}catch(P){console.error("Error loading tool settings:",P),p([]),f([]),k(!1),T("name")}},Fr=async()=>{try{const P=await Me("/api/cli/claude/status");if(P.ok){const X=await P.json();Qe({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else Qe({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Claude auth status:",P),Qe({authenticated:!1,email:null,loading:!1,error:P.message})}},zr=async()=>{try{const P=await Me("/api/cli/cursor/status");if(P.ok){const X=await P.json();ut({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else ut({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Cursor auth status:",P),ut({authenticated:!1,email:null,loading:!1,error:P.message})}},Rr=async()=>{try{const P=await Me("/api/cli/codex/status");if(P.ok){const X=await P.json();ht({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else ht({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Codex auth status:",P),ht({authenticated:!1,email:null,loading:!1,error:P.message})}},Ns=()=>{ue("claude"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},lr=()=>{ue("cursor"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},Cs=()=>{ue("codex"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},Ss=P=>{P===0&&(v("success"),le==="claude"?Fr():le==="cursor"?zr():le==="codex"&&Rr())},Or=()=>{D(!0),v(null);try{const P={allowedTools:h,disallowedTools:g,skipPermissions:y,projectSortOrder:E,lastUpdated:new Date().toISOString()},X={allowedCommands:L,disallowedCommands:pe,skipPermissions:Ie,lastUpdated:new Date().toISOString()},oe={permissionMode:Ge,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(P)),localStorage.setItem("cursor-tools-settings",JSON.stringify(X)),localStorage.setItem("codex-settings",JSON.stringify(oe)),v("success"),setTimeout(()=>{r()},1e3)}catch(P){console.error("Error saving tool settings:",P),v("error")}finally{D(!1)}},qt=()=>{J({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),A(null),H(!1),B("")},Br=(P=null)=>{P?(A(P),J({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath||"",config:{...P.config},raw:P.raw,importMode:"form",jsonInput:""})):qt(),H(!0)},Es=async P=>{P.preventDefault(),G(!0);try{if(z.importMode==="json"){const X=await Me("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:z.name,jsonConfig:z.jsonInput,scope:z.scope,projectPath:z.projectPath})});if(X.ok){const oe=await X.json();if(oe.success)await tt(),qt(),v("success");else throw new Error(oe.error||"Failed to add server via JSON")}else{const oe=await X.json();throw new Error(oe.error||"Failed to add server")}}else await zt(z),qt(),v("success")}catch(X){c(`Error: ${X.message}`,"error"),v("error")}finally{G(!1)}},Ts=async(P,X)=>{if(await u({title:i("mcp.deleteTitle","Delete MCP Server"),message:i("mcp.confirmDelete","Are you sure you want to delete this MCP server?"),confirmLabel:i("mcp.deleteButton","Delete"),cancelLabel:i("common:cancel","Cancel")}))try{await or(P,X),v("success")}catch(ve){c(`Error: ${ve.message}`,"error"),v("error")}},As=async(P,X)=>{try{$({...ie,[P]:{loading:!0}});const oe=await bs(P,X);$({...ie,[P]:oe})}catch(oe){$({...ie,[P]:{success:!1,message:oe.message,details:[]}})}},Is=async(P,X)=>{try{_({...Q,[P]:!0});const oe=await ys(P,X);te({...Z,[P]:oe})}catch{te({...Z,[P]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{_({...Q,[P]:!1})}},Kt=(P,X)=>{J(oe=>({...oe,config:{...oe.config,[P]:X}}))};return t?e.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[e.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Dt,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),e.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),e.jsx(he,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"border-b border-border",children:e.jsxs("div",{className:"flex overflow-x-auto scrollbar-none px-4 md:px-6",children:[e.jsx("button",{onClick:()=>q("agents"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.agents")}),e.jsx("button",{onClick:()=>q("appearance"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),e.jsxs("button",{onClick:()=>q("git"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(br,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.git")]}),e.jsxs("button",{onClick:()=>q("api"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(xa,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),e.jsx("button",{onClick:()=>q("tasks"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.tasks")}),e.jsxs("button",{onClick:()=>q("mcp"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx($r,{className:"w-4 h-4 inline mr-2"}),"MCP Hub"]}),e.jsxs("button",{onClick:()=>q("sessions"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="sessions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Ks,{className:"w-4 h-4 inline mr-2"}),"Sessions"]})]})}),e.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[F==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:F==="appearance"&&e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.darkMode.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.darkMode.description")})]}),e.jsxs("button",{onClick:o,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":n,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${n?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:n?e.jsx(Js,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Ys,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx(_o,{})}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.projectSorting.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.projectSorting.description")})]}),e.jsxs("select",{value:E,onChange:P=>T(P.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[e.jsx("option",{value:"name",children:i("appearanceSettings.projectSorting.alphabetical")}),e.jsx("option",{value:"date",children:i("appearanceSettings.projectSorting.recentActivity")})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:i("appearanceSettings.codeEditor.title")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.theme.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.theme.description")})]}),e.jsxs("button",{onClick:()=>se(Y==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Y==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${Y==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:Y==="dark"?e.jsx(Js,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Ys,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.wordWrap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.wordWrap.description")})]}),e.jsxs("button",{onClick:()=>je(!de),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":de,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${de?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.showMinimap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.showMinimap.description")})]}),e.jsxs("button",{onClick:()=>Re(!ge),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ge,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${ge?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),e.jsxs("button",{onClick:()=>De(!Ne),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ne,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${Ne?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),e.jsxs("select",{value:Ue,onChange:P=>_e(P.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[e.jsx("option",{value:"10",children:"10px"}),e.jsx("option",{value:"11",children:"11px"}),e.jsx("option",{value:"12",children:"12px"}),e.jsx("option",{value:"13",children:"13px"}),e.jsx("option",{value:"14",children:"14px"}),e.jsx("option",{value:"15",children:"15px"}),e.jsx("option",{value:"16",children:"16px"}),e.jsx("option",{value:"18",children:"18px"}),e.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),F==="git"&&e.jsx(Rc,{}),F==="agents"&&e.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[e.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex",children:[e.jsx(dr,{agentId:"claude",authStatus:He,isSelected:ee==="claude",onClick:()=>V("claude"),isMobile:!0}),e.jsx(dr,{agentId:"cursor",authStatus:Xe,isSelected:ee==="cursor",onClick:()=>V("cursor"),isMobile:!0}),e.jsx(dr,{agentId:"codex",authStatus:Vt,isSelected:ee==="codex",onClick:()=>V("codex"),isMobile:!0})]})}),e.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"p-2",children:[e.jsx(dr,{agentId:"claude",authStatus:He,isSelected:ee==="claude",onClick:()=>V("claude")}),e.jsx(dr,{agentId:"cursor",authStatus:Xe,isSelected:ee==="cursor",onClick:()=>V("cursor")}),e.jsx(dr,{agentId:"codex",authStatus:Vt,isSelected:ee==="codex",onClick:()=>V("codex")})]})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[e.jsx("button",{onClick:()=>M("account"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.account")}),e.jsx("button",{onClick:()=>M("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.permissions")}),e.jsx("button",{onClick:()=>M("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.mcpServers")})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[w==="account"&&e.jsx(Hc,{agent:ee,authStatus:ee==="claude"?He:ee==="cursor"?Xe:Vt,onLogin:ee==="claude"?Ns:ee==="cursor"?lr:Cs}),w==="permissions"&&ee==="claude"&&e.jsx($s,{agent:"claude",skipPermissions:y,setSkipPermissions:k,allowedTools:h,setAllowedTools:p,disallowedTools:g,setDisallowedTools:f,newAllowedTool:x,setNewAllowedTool:b,newDisallowedTool:N,setNewDisallowedTool:j}),w==="permissions"&&ee==="cursor"&&e.jsx($s,{agent:"cursor",skipPermissions:Ie,setSkipPermissions:Fe,allowedCommands:L,setAllowedCommands:K,disallowedCommands:pe,setDisallowedCommands:ye,newAllowedCommand:Se,setNewAllowedCommand:Oe,newDisallowedCommand:ne,setNewDisallowedCommand:fe}),w==="permissions"&&ee==="codex"&&e.jsx($s,{agent:"codex",permissionMode:Ge,setPermissionMode:ae}),w==="mcp"&&ee==="claude"&&e.jsx(_s,{agent:"claude",servers:W,onAdd:()=>Br(),onEdit:P=>Br(P),onDelete:(P,X)=>Ts(P,X),onTest:(P,X)=>As(P,X),onDiscoverTools:(P,X)=>Is(P,X),testResults:ie,serverTools:Z,toolsLoading:Q}),w==="mcp"&&ee==="cursor"&&e.jsx(_s,{agent:"cursor",servers:Ee,onAdd:()=>{},onEdit:P=>{},onDelete:P=>{}}),w==="mcp"&&ee==="codex"&&e.jsx(_s,{agent:"codex",servers:Pe,onAdd:()=>_r(),onEdit:P=>_r(P),onDelete:P=>ws(P)})]})]})]}),O&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(R?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(he,{variant:"ghost",size:"sm",onClick:qt,children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:Es,className:"p-4 space-y-4",children:[!R&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.form")}),e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.json")})]}),z.importMode==="form"&&R&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.scope.label")}),e.jsxs("div",{className:"flex items-center gap-2",children:[z.scope==="user"?e.jsx(qs,{className:"w-4 h-4"}):e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:z.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),z.scope==="local"&&z.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",z.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),z.importMode==="form"&&!R&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.scope.label")," *"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(qs,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.projectLocal")})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:z.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),z.scope==="local"&&!R&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.selectProject")," *"]}),e.jsxs("select",{value:z.projectPath,onChange:P=>J(X=>({...X,projectPath:P.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:z.scope==="local",children:[e.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),s.map(P=>e.jsx("option",{value:P.path||P.fullPath,children:P.displayName||P.name},P.name))]}),z.projectPath&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:z.projectPath})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:z.importMode==="json"?"md:col-span-2":"",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),e.jsx(Ze,{value:z.name,onChange:P=>{J(X=>({...X,name:P.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),z.importMode==="form"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.transportType")," *"]}),e.jsxs("select",{value:z.type,onChange:P=>{J(X=>({...X,type:P.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"sse",children:"SSE"}),e.jsx("option",{value:"http",children:"HTTP"})]})]})]}),R&&z.raw&&z.importMode==="form"&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:i("mcpForm.configDetails",{configFile:R.scope==="global"?"~/.claude.json":"project config"})}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(z.raw,null,2)})]}),z.importMode==="json"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.jsonConfig")," *"]}),e.jsx("textarea",{value:z.jsonInput,onChange:P=>{J(X=>({...X,jsonInput:P.target.value}));try{if(P.target.value.trim()){const X=JSON.parse(P.target.value);X.type?X.type==="stdio"&&!X.command?B(i("mcpForm.validation.stdioRequiresCommand")):(X.type==="http"||X.type==="sse")&&!X.url?B(i("mcpForm.validation.httpRequiresUrl",{type:X.type})):B(""):B(i("mcpForm.validation.missingType"))}}catch{P.target.value.trim()?B(i("mcpForm.validation.invalidJson")):B("")}},className:`w-full px-3 py-2 border ${U?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
|
|
3
3
|
"type": "stdio",
|
|
4
4
|
"command": "/path/to/server",
|
|
5
5
|
"args": ["--api-key", "abc123"],
|
|
@@ -539,7 +539,7 @@ File: ${(t==null?void 0:t.name)||"New PRD"}
|
|
|
539
539
|
Path: ${(t==null?void 0:t.path)||"Not saved yet"}
|
|
540
540
|
|
|
541
541
|
${z}`)}finally{h(!1)}})()},[t,s,o]),l.useEffect(()=>{(async()=>{if(!(a!=null&&a.name)){console.log("No project name available:",a);return}try{console.log("Fetching PRDs for project:",a.name);const Q=await Be.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(Q.ok){const _=await Q.json();console.log("Fetched existing PRDs:",_.prds),R(_.prds||[])}else console.log("Failed to fetch PRDs:",Q.status,Q.statusText)}catch(Q){console.error("Error fetching existing PRDs:",Q)}})()},[a==null?void 0:a.name]);const J=async()=>{if(!u.trim()){c("Please add content before saving.","warning");return}if(!v.trim()){c("Please provide a filename for the PRD.","warning");return}const te=v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,Q=H.find(_=>_.name===te);if(console.log("Save check:",{fullFileName:te,existingPRDs:H,existingFile:Q,isExisting:t==null?void 0:t.isExisting,fileObject:t,shouldShowModal:Q&&!(t!=null&&t.isExisting)}),Q&&!(t!=null&&t.isExisting)){console.log("Showing overwrite confirmation modal"),O(!0);return}await re()},re=async()=>{g(!0);try{const te=v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,Q=await Me(`/api/taskmaster/prd/${encodeURIComponent(a==null?void 0:a.name)}`,{method:"POST",body:JSON.stringify({fileName:te,content:u})});if(!Q.ok){const F=await Q.json();throw new Error(F.message||`Save failed: ${Q.status}`)}y(!0),setTimeout(()=>y(!1),2e3);const _=await Be.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(_.ok){const F=await _.json();R(F.prds||[])}i&&await i()}catch(te){console.error("Error saving PRD:",te),c(`Error saving PRD: ${te.message}`,"error")}finally{g(!1)}},G=()=>{const te=new Blob([u],{type:"text/markdown"}),Q=URL.createObjectURL(te),_=document.createElement("a");_.href=Q;const F=v?`${v}.txt`:"prd.txt";_.download=F,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(Q)},ie=async()=>{if(!u.trim()){c("Please add content to the PRD before generating tasks.","warning");return}W(!0)},$=()=>{x(!f)};l.useEffect(()=>{const te=Q=>{(Q.ctrlKey||Q.metaKey)&&(Q.key==="s"?(Q.preventDefault(),J()):Q.key==="Escape"&&(Q.preventDefault(),r()))};return document.addEventListener("keydown",te),()=>document.removeEventListener("keydown",te)},[u]);const Z=te=>te.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/^\- (.*$)/gim,"<li>$1</li>").replace(/(<li>.*<\/li>)/gims,"<ul>$1</ul>").replace(/\n\n/gim,"</p><p>").replace(/^(?!<[h|u|l])(.*$)/gim,"<p>$1</p>").replace(/<\/ul>\s*<ul>/gim,"");return m?e.jsx("div",{className:"fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center bg-white dark:bg-gray-900",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading PRD..."})]})})}):e.jsxs("div",{className:`fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${f?"md:p-0":""}`,children:[e.jsxs("div",{className:ke("bg-white dark:bg-gray-900 shadow-2xl flex flex-col","w-full h-full md:rounded-lg md:shadow-2xl",f?"md:w-full md:h-full md:rounded-none":"md:w-full md:max-w-6xl md:h-[85vh] md:max-h-[85vh]"),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-600 rounded flex items-center justify-center flex-shrink-0",children:e.jsx(gt,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center min-w-0 flex-1 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md px-3 py-2 focus-within:ring-2 focus-within:ring-purple-500 focus-within:border-purple-500 dark:focus-within:ring-purple-400 dark:focus-within:border-purple-400",children:[e.jsx("input",{type:"text",value:v,onChange:te=>{const Q=te.target.value.replace(/[<>:"/\\|?*]/g,"");E(Q)},className:"font-medium text-gray-900 dark:text-white bg-transparent border-none outline-none min-w-0 flex-1 text-base sm:text-sm placeholder-gray-400 dark:placeholder-gray-500",placeholder:"Enter PRD filename",maxLength:100}),e.jsx("span",{className:"text-sm sm:text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap ml-1",children:".txt"})]}),e.jsx("button",{onClick:()=>{var te;return(te=document.querySelector('input[placeholder="Enter PRD filename"]'))==null?void 0:te.focus()},className:"p-1 text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 transition-colors",title:"Click to edit filename",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"text-xs bg-purple-100 dark:bg-purple-900 text-purple-600 dark:text-purple-300 px-2 py-1 rounded whitespace-nowrap",children:"📋 PRD"}),o&&e.jsx("span",{className:"text-xs bg-green-100 dark:bg-green-900 text-green-600 dark:text-green-300 px-2 py-1 rounded whitespace-nowrap",children:"✨ New"})]})]}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:"Product Requirements Document"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>I(!k),className:ke("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",k?"text-purple-600 dark:text-purple-400 bg-purple-50 dark:bg-purple-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:k?"Switch to edit mode":"Preview markdown",children:e.jsx(sr,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:()=>C(!D),className:ke("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",D?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:D?"Disable word wrap":"Enable word wrap",children:e.jsx("span",{className:"text-sm md:text-xs font-mono font-bold",children:"↵"})}),e.jsx("button",{onClick:()=>N(!b),className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Toggle theme",children:e.jsx("span",{className:"text-lg md:text-base",children:b?"☀️":"🌙"})}),e.jsx("button",{onClick:G,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Download PRD",children:e.jsx(oo,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsxs("button",{onClick:ie,disabled:!u.trim(),className:ke("px-3 py-2 rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors text-sm font-medium","bg-purple-600 hover:bg-purple-700 text-white","min-h-[44px] md:min-h-0"),title:"Generate tasks from PRD content",children:[e.jsx(Ut,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:"Generate Tasks"})]}),e.jsx("button",{onClick:J,disabled:p,className:ke("px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors","min-h-[44px] md:min-h-0",j?"bg-green-600 hover:bg-green-700":"bg-purple-600 hover:bg-purple-700"),children:j?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"hidden sm:inline",children:"Saved!"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Saving...":"Save PRD"})]})}),e.jsx("button",{onClick:$,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:f?"Exit fullscreen":"Fullscreen",children:f?e.jsx(io,{className:"w-4 h-4"}):e.jsx(ba,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Close",children:e.jsx(Ve,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:k?e.jsx("div",{className:"h-full overflow-y-auto p-6 prose prose-gray dark:prose-invert max-w-none",children:e.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:Z(u)}})}):e.jsx(po,{ref:A,value:u,onChange:d,extensions:[go(),...D?[Wt.lineWrapping]:[]],theme:b?xo:void 0,height:"100%",style:{fontSize:"14px",height:"100%"},basicSetup:{lineNumbers:!0,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:["Lines: ",u.split(`
|
|
542
|
-
`).length]}),e.jsxs("span",{children:["Characters: ",u.length]}),e.jsxs("span",{children:["Words: ",u.split(/\s+/).filter(te=>te.length>0).length]}),e.jsx("span",{children:"Format: Markdown"})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),T&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ut,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),e.jsx("button",{onClick:()=>W(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ut,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask your AI assistant in the chat to parse your PRD and generate tasks. The AI assistant will automatically save your PRD and create detailed tasks with implementation details."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),e.jsxs("p",{className:"text-xs text-gray-900 dark:text-white font-mono",children:[`"I've just initialized a new project with Claude Task Master. I have a PRD at .taskmaster/docs/`,v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),e.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[e.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:()=>W(!1),className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),S&&e.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>O(!1)}),e.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:e.jsx($t,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>O(!1),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:async()=>{O(!1),await re()},className:"px-4 py-2 text-sm text-white bg-yellow-600 hover:bg-yellow-700 rounded-md flex items-center space-x-2 transition-colors",children:[e.jsx(ts,{className:"w-4 h-4"}),e.jsx("span",{children:"Overwrite"})]})]})]})})]})]})},t0=Zp,r0=Wo,s0=e0,a0="PRD saved successfully!";function n0(t){return t.prdFiles||t.prds||[]}function o0({isVisible:t}){const{tasks:r=[],currentProject:s,refreshTasks:a}=fr(),[n,o]=l.useState(null),[i,c]=l.useState(!1),[u,d]=l.useState(!1),[m,h]=l.useState(null),[p,g]=l.useState([]),[f,x]=l.useState(null),b=l.useRef(null),N=l.useCallback(T=>{b.current&&clearTimeout(b.current),x(T),b.current=setTimeout(()=>{x(null),b.current=null},3e3)},[]),j=l.useCallback(async()=>{if(!(s!=null&&s.name)){g([]);return}try{const T=await Be.get(`/taskmaster/prd/${encodeURIComponent(s.name)}`);if(!T.ok){g([]);return}const W=await T.json();g(n0(W))}catch(T){console.error("Failed to load existing PRDs:",T),g([])}},[s==null?void 0:s.name]),y=l.useCallback(async(T=!1)=>{await j(),T&&N(a0)},[j,N]);l.useEffect(()=>{j()},[j]),l.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const k=l.useCallback(T=>{if(!(!T||typeof T!="object"||!("id"in T))){if(!("title"in T)||!T.title){const W=r.find(S=>String(S.id)===String(T.id));W&&(o(W),c(!0));return}o(T),c(!0)}},[r]),I=l.useCallback(()=>{c(!1),o(null)},[]),D=l.useCallback((T,W)=>{console.log("Update task status:",T,W),a==null||a()},[a]),C=l.useCallback((T=null)=>{h(T),d(!0)},[]),v=l.useCallback(()=>{d(!1),h(null)},[]),E=l.useCallback(async()=>{v(),await y(!0),a==null||a()},[v,y,a]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`h-full ${t?"block":"hidden"}`,children:e.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:e.jsx(t0,{tasks:r,onTaskClick:k,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:s,onTaskCreated:a||void 0,onShowPRDEditor:C,existingPRDs:p,onRefreshPRDs:(T=!1)=>{y(T)}})})}),i&&n&&e.jsx(r0,{task:n,isOpen:i,onClose:I,onStatusChange:D,onTaskClick:k}),u&&e.jsx(s0,{project:s,projectPath:(s==null?void 0:s.fullPath)||(s==null?void 0:s.path),onClose:v,isNewFile:!(m!=null&&m.isExisting),file:{name:(m==null?void 0:m.name)||"prd.txt",content:(m==null?void 0:m.content)||""},onSave:E}),f&&e.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:e.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"font-medium",children:f})]})})]})}function i0(){const{isRelayConnected:t,isChecking:r,sandboxActive:s,isDisconnecting:a,disconnect:n,relayCwd:o,relayMachine:i}=ps(),[c,u]=l.useState(!1),[d,m]=l.useState(!1),h="uc connect",p=l.useCallback(()=>{navigator.clipboard.writeText(h),u(!0),setTimeout(()=>u(!1),2e3)},[]),g=l.useCallback(async()=>{await n()&&m(!1)},[n]);return r?null:t?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-green-500/5 border-b border-green-500/15 text-sm",children:[e.jsx(zi,{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0"}),e.jsx("span",{className:"text-green-400 text-xs font-medium",children:"Connected"}),i&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[150px]",children:i}),o&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[200px] hidden sm:inline",children:o.split(/[\\/]/).slice(-2).join("/")}),s&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/20 text-emerald-400 border border-emerald-500/30",children:"Isolated"}),e.jsx("div",{className:"ml-auto flex items-center gap-1",children:d?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-amber-400",children:"Disconnect?"}),e.jsx("button",{onClick:g,disabled:a,className:"text-[10px] px-2 py-0.5 rounded bg-red-500/20 text-red-400 hover:bg-red-500/30 border border-red-500/30 transition-colors disabled:opacity-40",children:a?"Disconnecting...":"Yes"}),e.jsx("button",{onClick:()=>m(!1),className:"text-[10px] px-2 py-0.5 rounded bg-muted text-muted-foreground hover:bg-muted/80 transition-colors",children:"No"})]}):e.jsx("button",{onClick:()=>m(!0),className:"p-1 rounded hover:bg-red-500/10 text-muted-foreground hover:text-red-400 transition-colors",title:"Disconnect relay",children:e.jsx(Ri,{className:"w-3.5 h-3.5"})})})]}):e.jsxs("div",{className:"border-b border-amber-500/20 bg-amber-500/10",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(Xn,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-amber-300",children:"Connect your machine to get started"})]}),e.jsxs("div",{className:"px-4 pb-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1.5",children:"Run these commands in your terminal:"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:"npm install -g upfynai-code"})}),e.jsx("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:"uc login"})}),e.jsxs("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:[e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:h}),e.jsx("button",{onClick:p,className:"flex-shrink-0 p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",title:"Copy command",children:c?e.jsx(Lt,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(ha,{className:"w-3.5 h-3.5"})})]})]})]})]})}function l0(){const{connectionState:t,reconnectAttempts:r}=Qn();return t==="connected"||t==="disconnected"?null:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/10 border-b border-amber-500/20 text-amber-400 text-xs animate-in fade-in duration-300",children:[e.jsx("div",{className:"w-2 h-2 bg-amber-400 rounded-full animate-pulse shrink-0"}),e.jsx("span",{children:t==="connecting"?"Connecting...":e.jsxs(e.Fragment,{children:["Reconnecting to server",r>1&&e.jsxs("span",{className:"text-amber-400/60 ml-1",children:["(attempt ",r,")"]}),e.jsx("span",{className:"ml-1.5",children:"— your session is preserved"})]})})]})}function Xr({children:t,fallback:r,bypass:s}){const{isRelayConnected:a}=ps();return s||a?e.jsx(e.Fragment,{children:t}):e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 backdrop-blur-sm",children:r}),e.jsx("div",{className:"h-full w-full opacity-30 pointer-events-none select-none","aria-hidden":!0,children:t})]})}function fs({icon:t,label:r}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",role:"status","aria-label":`${r} loading`,children:[e.jsx(t,{className:"w-10 h-10 opacity-40"}),e.jsxs("p",{className:"text-sm font-medium",children:[r," requires a connected machine"]}),e.jsx("p",{className:"text-xs opacity-60",children:"Connect your machine to get started"})]})}function c0(){return e.jsx(fs,{icon:va,label:"Chat"})}function Un(){return e.jsx(fs,{icon:vt,label:"Shell"})}function Hn(){return e.jsx(fs,{icon:Oi,label:"Files"})}function Gn(){return e.jsx(fs,{icon:br,label:"Git"})}function d0({selectedProject:t,isMobile:r,initialWidth:s=600}){const[a,n]=l.useState(null),[o,i]=l.useState(s),[c,u]=l.useState(!1),[d,m]=l.useState(!1),h=l.useRef(null),[p,g]=l.useState(280),[f,x]=l.useState(!1),b=l.useRef(null),N=l.useCallback((D,C=null)=>{const E=D.replace(/\\/g,"/").split("/").pop()||D;n({name:E,path:D,projectName:t==null?void 0:t.name,diffInfo:C})},[t==null?void 0:t.name]),j=l.useCallback(()=>{n(null),u(!1)},[]),y=l.useCallback(()=>{u(D=>!D)},[]),k=l.useCallback(D=>{r||(x(!0),D.preventDefault())},[r]);l.useEffect(()=>{const D=v=>{var H;if(!f)return;const E=(H=b.current)==null?void 0:H.parentElement;if(!E)return;const T=E.getBoundingClientRect(),W=v.clientX-T.left,S=180,O=Math.min(500,T.width*.5);W>=S&&W<=O&&g(W)},C=()=>{x(!1)};return f&&(document.addEventListener("mousemove",D),document.addEventListener("mouseup",C),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",C),f&&(document.body.style.cursor="",document.body.style.userSelect="")}},[f]);const I=l.useCallback(D=>{r||(m(!0),D.preventDefault())},[r]);return l.useEffect(()=>{const D=v=>{var H;if(!d)return;const E=(H=h.current)==null?void 0:H.parentElement;if(!E)return;const T=E.getBoundingClientRect(),W=T.right-v.clientX,S=300,O=T.width*.8;W>=S&&W<=O&&i(W)},C=()=>{m(!1)};return d&&(document.addEventListener("mousemove",D),document.addEventListener("mouseup",C),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",C),document.body.style.cursor="",document.body.style.userSelect=""}},[d]),{editingFile:a,editorWidth:o,editorExpanded:c,resizeHandleRef:h,handleFileOpen:N,handleCloseEditor:j,handleToggleEditorExpand:y,handleResizeStart:I,fileTreeWidth:p,fileTreeResizeRef:b,handleFileTreeResizeStart:k}}function u0({isMobile:t,initialWidth:r=520}){const[s,a]=l.useState([]),[n,o]=l.useState([]),[i,c]=l.useState(null),[u,d]=l.useState(r),[m,h]=l.useState(!1),[p,g]=l.useState(!1),f=l.useRef(null),x=s.length>0||n.length>0,b=l.useCallback(C=>{a(v=>v.find(T=>T.id===C.id)?v.map(T=>T.id===C.id?C:T):[...v,C]),c(C.id)},[]),N=l.useCallback(C=>{a(v=>{const E=v.find(T=>T.id===C);return E&&o(T=>{const W=T.filter(S=>S.id!==C);return[E,...W].slice(0,20)}),v.filter(T=>T.id!==C)}),c(v=>{if(v!==C)return v;const E=s.filter(T=>T.id!==C);return E.length>0?E[E.length-1].id:null})},[s]),j=l.useCallback(C=>{const v=n.find(E=>E.id===C);v&&(o(E=>E.filter(T=>T.id!==C)),a(E=>[...E,v]),c(v.id))},[n]),y=l.useCallback(()=>{o([])},[]),k=l.useCallback(()=>{a(C=>(C.length>0&&o(v=>{const E=new Set(v.map(W=>W.id));return[...C.filter(W=>!E.has(W.id)),...v].slice(0,20)}),[])),c(null),h(!1)},[]),I=l.useCallback(()=>{h(C=>!C)},[]),D=l.useCallback(C=>{t||(g(!0),C.preventDefault())},[t]);return l.useEffect(()=>{const C=E=>{var R;if(!p)return;const T=(R=f.current)==null?void 0:R.parentElement;if(!T)return;const W=T.getBoundingClientRect(),S=W.right-E.clientX,O=320,H=W.width*.75;S>=O&&S<=H&&d(S)},v=()=>{g(!1)};return p&&(document.addEventListener("mousemove",C),document.addEventListener("mouseup",v),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",v),p&&(document.body.style.cursor="",document.body.style.userSelect="")}},[p]),{artifacts:s,recentArtifacts:n,activeArtifactId:i,setActiveArtifactId:c,panelWidth:u,panelExpanded:m,isOpen:x,resizeHandleRef:f,openArtifact:b,closeArtifact:N,reopenArtifact:j,clearHistory:y,closeAll:k,toggleExpand:I,handleResizeStart:D}}const m0=l.lazy(()=>kt(()=>import("./FileTree-B0c_GaB3.js"),__vite__mapDeps([6,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),p0=l.lazy(()=>kt(()=>import("./LoginModal-BRycfsyD.js").then(t=>t.c),__vite__mapDeps([11,2,7,1,3,8,9,10,12,13,14,15,16]))),x0=l.lazy(()=>kt(()=>import("./GitPanel-DUP4zVU4.js"),__vite__mapDeps([18,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),g0=l.lazy(()=>kt(()=>import("./WorkflowsPanel-CouH9JDO.js"),__vite__mapDeps([19,2,7,1,3,8,9,10]))),h0=l.lazy(()=>kt(()=>import("./DashboardPanel-zFIFlw56.js"),__vite__mapDeps([20,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),f0=l.lazy(()=>kt(()=>import("./CanvasWorkspace-4CqmjAVQ.js"),__vite__mapDeps([21,1,2,3,14,15,16,7,8,9,10]))),b0=l.lazy(()=>kt(()=>import("./PreviewPanel-CqCa92Tf.js"),__vite__mapDeps([22,2])));function y0({selectedProject:t,selectedSession:r,activeTab:s,setActiveTab:a,ws:n,sendMessage:o,latestMessage:i,isMobile:c,onMenuClick:u,isLoading:d,onInputFocusChange:m,onSessionActive:h,onSessionInactive:p,onSessionProcessing:g,onSessionNotProcessing:f,processingSessions:x,onReplaceTemporarySession:b,onNavigateToSession:N,onShowSettings:j,externalMessageUpdate:y}){var _e,L;const k=Yn(),{preferences:I}=ja(),{autoExpandTools:D,showRawParameters:C,showThinking:v,autoScrollToBottom:E,sendByCtrlEnter:T}=I,{currentProject:W,setCurrentProject:S}=fr(),{tasksEnabled:O,isTaskMasterInstalled:H}=Lr(),R=O!==!1,{editingFile:A,editorWidth:z,editorExpanded:J,resizeHandleRef:re,handleFileOpen:G,handleCloseEditor:ie,handleToggleEditorExpand:$,handleResizeStart:Z,fileTreeWidth:te,fileTreeResizeRef:Q,handleFileTreeResizeStart:_}=d0({selectedProject:t,isMobile:c}),{artifacts:F,recentArtifacts:q,activeArtifactId:U,setActiveArtifactId:B,panelWidth:ee,panelExpanded:V,isOpen:w,resizeHandleRef:M,openArtifact:Y,closeArtifact:se,reopenArtifact:de,clearHistory:je,closeAll:ge,toggleExpand:Re,handleResizeStart:Ne}=u0({isMobile:c}),De=it.useCallback(K=>{Y(K)},[Y]),Ue=it.useCallback(async K=>{var pe,ye,Ie,Fe;if(t!=null&&t.name)try{const Oe=await(await Be.canvas.load(t.name)).json(),ne=Oe.elements||[];let fe=[],Ee=[];ne.length===1&&((pe=ne[0])!=null&&pe.nodes)?(fe=ne[0].nodes,Ee=ne[0].edges||[]):ne.length>0&&((ye=ne[0])!=null&&ye.position)&&(fe=ne.filter(Ce=>!Ce.source),Ee=ne.filter(Ce=>Ce.source));const Pe={code:"response",diff:"response",terminal:"response",search:"response",html:"webpage",markdown:"note"}[K.type]||"note";let Ae="";K.type==="code"?Ae=String(K.data.content||""):K.type==="diff"?Ae=`Diff: ${K.data.filePath||"file"}
|
|
542
|
+
`).length]}),e.jsxs("span",{children:["Characters: ",u.length]}),e.jsxs("span",{children:["Words: ",u.split(/\s+/).filter(te=>te.length>0).length]}),e.jsx("span",{children:"Format: Markdown"})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),T&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ut,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),e.jsx("button",{onClick:()=>W(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ut,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask your AI assistant in the chat to parse your PRD and generate tasks. The AI assistant will automatically save your PRD and create detailed tasks with implementation details."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),e.jsxs("p",{className:"text-xs text-gray-900 dark:text-white font-mono",children:[`"I've just initialized a new project with Claude Task Master. I have a PRD at .taskmaster/docs/`,v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),e.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[e.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:()=>W(!1),className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),S&&e.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>O(!1)}),e.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:e.jsx($t,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>O(!1),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:async()=>{O(!1),await re()},className:"px-4 py-2 text-sm text-white bg-yellow-600 hover:bg-yellow-700 rounded-md flex items-center space-x-2 transition-colors",children:[e.jsx(ts,{className:"w-4 h-4"}),e.jsx("span",{children:"Overwrite"})]})]})]})})]})]})},t0=Zp,r0=Wo,s0=e0,a0="PRD saved successfully!";function n0(t){return t.prdFiles||t.prds||[]}function o0({isVisible:t}){const{tasks:r=[],currentProject:s,refreshTasks:a}=fr(),[n,o]=l.useState(null),[i,c]=l.useState(!1),[u,d]=l.useState(!1),[m,h]=l.useState(null),[p,g]=l.useState([]),[f,x]=l.useState(null),b=l.useRef(null),N=l.useCallback(T=>{b.current&&clearTimeout(b.current),x(T),b.current=setTimeout(()=>{x(null),b.current=null},3e3)},[]),j=l.useCallback(async()=>{if(!(s!=null&&s.name)){g([]);return}try{const T=await Be.get(`/taskmaster/prd/${encodeURIComponent(s.name)}`);if(!T.ok){g([]);return}const W=await T.json();g(n0(W))}catch(T){console.error("Failed to load existing PRDs:",T),g([])}},[s==null?void 0:s.name]),y=l.useCallback(async(T=!1)=>{await j(),T&&N(a0)},[j,N]);l.useEffect(()=>{j()},[j]),l.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const k=l.useCallback(T=>{if(!(!T||typeof T!="object"||!("id"in T))){if(!("title"in T)||!T.title){const W=r.find(S=>String(S.id)===String(T.id));W&&(o(W),c(!0));return}o(T),c(!0)}},[r]),I=l.useCallback(()=>{c(!1),o(null)},[]),D=l.useCallback((T,W)=>{console.log("Update task status:",T,W),a==null||a()},[a]),C=l.useCallback((T=null)=>{h(T),d(!0)},[]),v=l.useCallback(()=>{d(!1),h(null)},[]),E=l.useCallback(async()=>{v(),await y(!0),a==null||a()},[v,y,a]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`h-full ${t?"block":"hidden"}`,children:e.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:e.jsx(t0,{tasks:r,onTaskClick:k,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:s,onTaskCreated:a||void 0,onShowPRDEditor:C,existingPRDs:p,onRefreshPRDs:(T=!1)=>{y(T)}})})}),i&&n&&e.jsx(r0,{task:n,isOpen:i,onClose:I,onStatusChange:D,onTaskClick:k}),u&&e.jsx(s0,{project:s,projectPath:(s==null?void 0:s.fullPath)||(s==null?void 0:s.path),onClose:v,isNewFile:!(m!=null&&m.isExisting),file:{name:(m==null?void 0:m.name)||"prd.txt",content:(m==null?void 0:m.content)||""},onSave:E}),f&&e.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:e.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"font-medium",children:f})]})})]})}function i0(){const{isRelayConnected:t,isChecking:r,sandboxActive:s,isDisconnecting:a,disconnect:n,relayCwd:o,relayMachine:i}=ps(),[c,u]=l.useState(!1),[d,m]=l.useState(!1),h="uc connect",p=l.useCallback(()=>{navigator.clipboard.writeText(h),u(!0),setTimeout(()=>u(!1),2e3)},[]),g=l.useCallback(async()=>{await n()&&m(!1)},[n]);return r?null:t?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-green-500/5 border-b border-green-500/15 text-sm",children:[e.jsx(zi,{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0"}),e.jsx("span",{className:"text-green-400 text-xs font-medium",children:"Connected"}),i&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[150px]",children:i}),o&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[200px] hidden sm:inline",children:o.split(/[\\/]/).slice(-2).join("/")}),s&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/20 text-emerald-400 border border-emerald-500/30",children:"Isolated"}),e.jsx("div",{className:"ml-auto flex items-center gap-1",children:d?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-amber-400",children:"Disconnect?"}),e.jsx("button",{onClick:g,disabled:a,className:"text-[10px] px-2 py-0.5 rounded bg-red-500/20 text-red-400 hover:bg-red-500/30 border border-red-500/30 transition-colors disabled:opacity-40",children:a?"Disconnecting...":"Yes"}),e.jsx("button",{onClick:()=>m(!1),className:"text-[10px] px-2 py-0.5 rounded bg-muted text-muted-foreground hover:bg-muted/80 transition-colors",children:"No"})]}):e.jsx("button",{onClick:()=>m(!0),className:"p-1 rounded hover:bg-red-500/10 text-muted-foreground hover:text-red-400 transition-colors",title:"Disconnect relay",children:e.jsx(Ri,{className:"w-3.5 h-3.5"})})})]}):e.jsxs("div",{className:"border-b border-amber-500/20 bg-amber-500/10",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(Xn,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-amber-300",children:"Connect your machine to get started"})]}),e.jsxs("div",{className:"px-4 pb-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1.5",children:"Run these commands in your terminal:"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:"npm install -g upfynai-code"})}),e.jsx("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:"uc login"})}),e.jsxs("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:[e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:h}),e.jsx("button",{onClick:p,className:"flex-shrink-0 p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",title:"Copy command",children:c?e.jsx(Lt,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(ha,{className:"w-3.5 h-3.5"})})]})]})]})]})}function l0(){const{connectionState:t,reconnectAttempts:r}=Qn();return t==="connected"||t==="disconnected"?null:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/10 border-b border-amber-500/20 text-amber-400 text-xs animate-in fade-in duration-300",children:[e.jsx("div",{className:"w-2 h-2 bg-amber-400 rounded-full animate-pulse shrink-0"}),e.jsx("span",{children:t==="connecting"?"Connecting...":e.jsxs(e.Fragment,{children:["Reconnecting to server",r>1&&e.jsxs("span",{className:"text-amber-400/60 ml-1",children:["(attempt ",r,")"]}),e.jsx("span",{className:"ml-1.5",children:"— your session is preserved"})]})})]})}function Xr({children:t,fallback:r,bypass:s}){const{isRelayConnected:a}=ps();return s||a?e.jsx(e.Fragment,{children:t}):e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 backdrop-blur-sm",children:r}),e.jsx("div",{className:"h-full w-full opacity-30 pointer-events-none select-none","aria-hidden":!0,children:t})]})}function fs({icon:t,label:r}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",role:"status","aria-label":`${r} loading`,children:[e.jsx(t,{className:"w-10 h-10 opacity-40"}),e.jsxs("p",{className:"text-sm font-medium",children:[r," requires a connected machine"]}),e.jsx("p",{className:"text-xs opacity-60",children:"Connect your machine to get started"})]})}function c0(){return e.jsx(fs,{icon:va,label:"Chat"})}function Un(){return e.jsx(fs,{icon:vt,label:"Shell"})}function Hn(){return e.jsx(fs,{icon:Oi,label:"Files"})}function Gn(){return e.jsx(fs,{icon:br,label:"Git"})}function d0({selectedProject:t,isMobile:r,initialWidth:s=600}){const[a,n]=l.useState(null),[o,i]=l.useState(s),[c,u]=l.useState(!1),[d,m]=l.useState(!1),h=l.useRef(null),[p,g]=l.useState(280),[f,x]=l.useState(!1),b=l.useRef(null),N=l.useCallback((D,C=null)=>{const E=D.replace(/\\/g,"/").split("/").pop()||D;n({name:E,path:D,projectName:t==null?void 0:t.name,diffInfo:C})},[t==null?void 0:t.name]),j=l.useCallback(()=>{n(null),u(!1)},[]),y=l.useCallback(()=>{u(D=>!D)},[]),k=l.useCallback(D=>{r||(x(!0),D.preventDefault())},[r]);l.useEffect(()=>{const D=v=>{var H;if(!f)return;const E=(H=b.current)==null?void 0:H.parentElement;if(!E)return;const T=E.getBoundingClientRect(),W=v.clientX-T.left,S=180,O=Math.min(500,T.width*.5);W>=S&&W<=O&&g(W)},C=()=>{x(!1)};return f&&(document.addEventListener("mousemove",D),document.addEventListener("mouseup",C),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",C),f&&(document.body.style.cursor="",document.body.style.userSelect="")}},[f]);const I=l.useCallback(D=>{r||(m(!0),D.preventDefault())},[r]);return l.useEffect(()=>{const D=v=>{var H;if(!d)return;const E=(H=h.current)==null?void 0:H.parentElement;if(!E)return;const T=E.getBoundingClientRect(),W=T.right-v.clientX,S=300,O=T.width*.8;W>=S&&W<=O&&i(W)},C=()=>{m(!1)};return d&&(document.addEventListener("mousemove",D),document.addEventListener("mouseup",C),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",C),document.body.style.cursor="",document.body.style.userSelect=""}},[d]),{editingFile:a,editorWidth:o,editorExpanded:c,resizeHandleRef:h,handleFileOpen:N,handleCloseEditor:j,handleToggleEditorExpand:y,handleResizeStart:I,fileTreeWidth:p,fileTreeResizeRef:b,handleFileTreeResizeStart:k}}function u0({isMobile:t,initialWidth:r=520}){const[s,a]=l.useState([]),[n,o]=l.useState([]),[i,c]=l.useState(null),[u,d]=l.useState(r),[m,h]=l.useState(!1),[p,g]=l.useState(!1),f=l.useRef(null),x=s.length>0||n.length>0,b=l.useCallback(C=>{a(v=>v.find(T=>T.id===C.id)?v.map(T=>T.id===C.id?C:T):[...v,C]),c(C.id)},[]),N=l.useCallback(C=>{a(v=>{const E=v.find(T=>T.id===C);return E&&o(T=>{const W=T.filter(S=>S.id!==C);return[E,...W].slice(0,20)}),v.filter(T=>T.id!==C)}),c(v=>{if(v!==C)return v;const E=s.filter(T=>T.id!==C);return E.length>0?E[E.length-1].id:null})},[s]),j=l.useCallback(C=>{const v=n.find(E=>E.id===C);v&&(o(E=>E.filter(T=>T.id!==C)),a(E=>[...E,v]),c(v.id))},[n]),y=l.useCallback(()=>{o([])},[]),k=l.useCallback(()=>{a(C=>(C.length>0&&o(v=>{const E=new Set(v.map(W=>W.id));return[...C.filter(W=>!E.has(W.id)),...v].slice(0,20)}),[])),c(null),h(!1)},[]),I=l.useCallback(()=>{h(C=>!C)},[]),D=l.useCallback(C=>{t||(g(!0),C.preventDefault())},[t]);return l.useEffect(()=>{const C=E=>{var R;if(!p)return;const T=(R=f.current)==null?void 0:R.parentElement;if(!T)return;const W=T.getBoundingClientRect(),S=W.right-E.clientX,O=320,H=W.width*.75;S>=O&&S<=H&&d(S)},v=()=>{g(!1)};return p&&(document.addEventListener("mousemove",C),document.addEventListener("mouseup",v),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",v),p&&(document.body.style.cursor="",document.body.style.userSelect="")}},[p]),{artifacts:s,recentArtifacts:n,activeArtifactId:i,setActiveArtifactId:c,panelWidth:u,panelExpanded:m,isOpen:x,resizeHandleRef:f,openArtifact:b,closeArtifact:N,reopenArtifact:j,clearHistory:y,closeAll:k,toggleExpand:I,handleResizeStart:D}}const m0=l.lazy(()=>kt(()=>import("./FileTree-CbJF7m5P.js"),__vite__mapDeps([6,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),p0=l.lazy(()=>kt(()=>import("./LoginModal-Bk9mxZsi.js").then(t=>t.c),__vite__mapDeps([11,2,7,1,3,8,9,10,12,13,14,15,16]))),x0=l.lazy(()=>kt(()=>import("./GitPanel-avzqm9Zj.js"),__vite__mapDeps([18,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),g0=l.lazy(()=>kt(()=>import("./WorkflowsPanel-BOaVEpdu.js"),__vite__mapDeps([19,2,7,1,3,8,9,10]))),h0=l.lazy(()=>kt(()=>import("./DashboardPanel-DmHbSyTP.js"),__vite__mapDeps([20,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),f0=l.lazy(()=>kt(()=>import("./CanvasWorkspace-DksIgrfl.js"),__vite__mapDeps([21,1,2,3,14,15,16,7,8,9,10]))),b0=l.lazy(()=>kt(()=>import("./PreviewPanel-CqCa92Tf.js"),__vite__mapDeps([22,2])));function y0({selectedProject:t,selectedSession:r,activeTab:s,setActiveTab:a,ws:n,sendMessage:o,latestMessage:i,isMobile:c,onMenuClick:u,isLoading:d,onInputFocusChange:m,onSessionActive:h,onSessionInactive:p,onSessionProcessing:g,onSessionNotProcessing:f,processingSessions:x,onReplaceTemporarySession:b,onNavigateToSession:N,onShowSettings:j,externalMessageUpdate:y}){var _e,L;const k=Yn(),{preferences:I}=ja(),{autoExpandTools:D,showRawParameters:C,showThinking:v,autoScrollToBottom:E,sendByCtrlEnter:T}=I,{currentProject:W,setCurrentProject:S}=fr(),{tasksEnabled:O,isTaskMasterInstalled:H}=Lr(),R=O!==!1,{editingFile:A,editorWidth:z,editorExpanded:J,resizeHandleRef:re,handleFileOpen:G,handleCloseEditor:ie,handleToggleEditorExpand:$,handleResizeStart:Z,fileTreeWidth:te,fileTreeResizeRef:Q,handleFileTreeResizeStart:_}=d0({selectedProject:t,isMobile:c}),{artifacts:F,recentArtifacts:q,activeArtifactId:U,setActiveArtifactId:B,panelWidth:ee,panelExpanded:V,isOpen:w,resizeHandleRef:M,openArtifact:Y,closeArtifact:se,reopenArtifact:de,clearHistory:je,closeAll:ge,toggleExpand:Re,handleResizeStart:Ne}=u0({isMobile:c}),De=it.useCallback(K=>{Y(K)},[Y]),Ue=it.useCallback(async K=>{var pe,ye,Ie,Fe;if(t!=null&&t.name)try{const Oe=await(await Be.canvas.load(t.name)).json(),ne=Oe.elements||[];let fe=[],Ee=[];ne.length===1&&((pe=ne[0])!=null&&pe.nodes)?(fe=ne[0].nodes,Ee=ne[0].edges||[]):ne.length>0&&((ye=ne[0])!=null&&ye.position)&&(fe=ne.filter(Ce=>!Ce.source),Ee=ne.filter(Ce=>Ce.source));const Pe={code:"response",diff:"response",terminal:"response",search:"response",html:"webpage",markdown:"note"}[K.type]||"note";let Ae="";K.type==="code"?Ae=String(K.data.content||""):K.type==="diff"?Ae=`Diff: ${K.data.filePath||"file"}
|
|
543
543
|
+${String(K.data.newContent||"").split(`
|
|
544
544
|
`).length} lines`:K.type==="terminal"?Ae=String(K.data.output||""):K.type==="search"?Ae=(K.data.files||[]).join(`
|
|
545
545
|
`):K.type==="html"?Ae=String(K.data.html||""):Ae=String(K.data.content||"");const Ge=fe[fe.length-1],ae=Ge?(((Ie=Ge.position)==null?void 0:Ie.x)||0)+300:100,be=Ge?((Fe=Ge.position)==null?void 0:Fe.y)||0:100,ze={id:`pinned_${Date.now()}`,type:Pe,position:{x:ae,y:be},data:{label:K.title,content:Ae.slice(0,2e3),...K.type==="html"&&{html:Ae,pageName:K.title}}};fe.push(ze),await Be.canvas.save(t.name,[{nodes:fe,edges:Ee}],Oe.appState||{})}catch{}},[t==null?void 0:t.name]);return l.useEffect(()=>{t&&t!==W&&(S==null||S(t))},[t,W,S]),l.useEffect(()=>{!R&&s==="tasks"&&a("chat")},[R,s,a]),d?e.jsx($n,{mode:"loading",isMobile:c,onMenuClick:u}):t?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Cp,{activeTab:s,setActiveTab:a,selectedProject:t,selectedSession:r,shouldShowTasksTab:R,isMobile:c,onMenuClick:u}),e.jsx(l0,{}),e.jsx(i0,{}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:`flex flex-col min-h-0 overflow-hidden ${J?"hidden":""} ${s==="files"&&A?"flex-shrink-0":"flex-1"}`,style:s==="files"&&A?{width:`${te}px`}:void 0,children:[s==="dashboard"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading dashboard..."}),children:e.jsx(h0,{selectedProject:t})})}),e.jsx("div",{className:`h-full ${s==="chat"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(c0,{}),children:e.jsx(jr,{showDetails:!0,children:e.jsx(bp,{selectedProject:t,selectedSession:r,ws:n,sendMessage:o,latestMessage:i,onFileOpen:G,onInputFocusChange:m,onSessionActive:h,onSessionInactive:p,onSessionProcessing:g,onSessionNotProcessing:f,processingSessions:x,onReplaceTemporarySession:b,onNavigateToSession:N,onShowSettings:j,autoExpandTools:D,showRawParameters:C,showThinking:v,autoScrollToBottom:E,sendByCtrlEnter:T,externalMessageUpdate:y,onShowAllTasks:O?()=>a("tasks"):null,setActiveTab:a,onArtifactOpen:De})})})}),s==="canvas"&&e.jsxs("div",{className:"h-full overflow-hidden relative",children:[e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin"}),"Loading canvas..."]})}),children:(t==null?void 0:t.name)&&e.jsx(f0,{projectName:t.name,sendMessage:o,latestMessage:i,isFullScreen:!1})})}),(t==null?void 0:t.name)&&e.jsxs("button",{onClick:()=>k(`/canvas/${encodeURIComponent(t.name)}`),className:"absolute top-3 right-32 z-20 flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-card/90 border border-border/50 text-xs text-muted-foreground hover:text-foreground hover:bg-card transition-colors backdrop-blur-sm shadow-sm",title:"Open in fullscreen",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})}),"Fullscreen"]})]}),e.jsx("div",{className:`h-full overflow-hidden ${s==="files"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(Hn,{}),children:e.jsx(l.Suspense,{fallback:e.jsx(Hn,{}),children:e.jsx(m0,{selectedProject:t,onFileOpen:G,activeFilePath:(A==null?void 0:A.path)||null})})})}),e.jsx("div",{className:`h-full w-full overflow-hidden ${s==="shell"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(Un,{}),children:e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx(Un,{}),children:e.jsx(p0,{project:t,session:r,showHeader:!1,multiTab:!0})})})})}),e.jsx("div",{className:`h-full overflow-hidden ${s==="git"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(Gn,{}),children:e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx(Gn,{}),children:e.jsx(x0,{selectedProject:t,isMobile:c,onFileOpen:G})})})})}),s==="workflows"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading workflows..."}),children:e.jsx(g0,{selectedProject:t})})})}),R&&e.jsx(o0,{isVisible:s==="tasks"}),s==="preview"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading preview..."}),children:e.jsx(b0,{initialHtml:(L=(_e=F.find(K=>K.type==="html"))==null?void 0:_e.data)==null?void 0:L.html})})})]}),s==="files"&&A&&!J&&e.jsx("div",{ref:Q,onMouseDown:_,className:"w-1 flex-shrink-0 cursor-col-resize hover:bg-primary/30 active:bg-primary/50 transition-colors relative group",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1"})}),e.jsx(Bp,{editingFile:A,isMobile:c,editorExpanded:J,editorWidth:z,resizeHandleRef:re,onResizeStart:Z,onCloseEditor:ie,onToggleEditorExpand:$,projectPath:t.path,fillSpace:s==="files"}),w&&!A&&(c?e.jsx("div",{className:"fixed inset-0 z-40 bg-gray-900 flex flex-col",children:e.jsx(Bn,{artifacts:F,recentArtifacts:q,activeArtifactId:U,panelWidth:ee,panelExpanded:V,resizeHandleRef:M,onResizeStart:Ne,onSetActive:B,onClose:se,onReopenArtifact:de,onClearHistory:je,onCloseAll:ge,onToggleExpand:Re,onPinToCanvas:Ue,onFileOpen:G})}):e.jsx(Bn,{artifacts:F,recentArtifacts:q,activeArtifactId:U,panelWidth:ee,panelExpanded:V,resizeHandleRef:M,onResizeStart:Ne,onSetActive:B,onClose:se,onReopenArtifact:de,onClearHistory:je,onCloseAll:ge,onToggleExpand:Re,onPinToCanvas:Ue,onFileOpen:G}))]})]}):e.jsx($n,{mode:"empty",isMobile:c,onMenuClick:u})}const v0=it.memo(y0);function k0({activeTab:t,setActiveTab:r,isInputFocused:s}){const{tasksEnabled:a,isTaskMasterInstalled:n}=Lr(),i=[{id:"dashboard",icon:Bi,label:"Home"},{id:"chat",icon:va,label:"Chat"},{id:"shell",icon:vt,label:"Shell"},{id:"files",icon:mr,label:"Files"},{id:"canvas",icon:Wi,label:"Canvas"},{id:"preview",icon:sr,label:"Preview"},{id:"git",icon:br,label:"Git"},{id:"workflows",icon:tr,label:"Auto"},...!!(a&&n)?[{id:"tasks",icon:no,label:"Tasks"}]:[]];return e.jsx("div",{className:`fixed bottom-0 left-0 right-0 z-50 px-2 pb-[max(6px,env(safe-area-inset-bottom))] transform transition-transform duration-300 ease-in-out ${s?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"nav-glass mobile-nav-float rounded-2xl border border-border/30",children:e.jsx("div",{className:"flex items-center justify-around px-0.5 py-1 gap-0 overflow-x-auto scrollbar-hide",children:i.map(c=>{const u=c.icon,d=t===c.id;return e.jsxs("button",{onClick:()=>r(c.id),onTouchStart:m=>{m.preventDefault(),r(c.id)},className:`flex flex-col items-center justify-center gap-0.5 px-1.5 py-1.5 rounded-xl flex-shrink-0 min-w-[42px] relative touch-manipulation transition-all duration-200 active:scale-95 ${d?"text-primary":"text-muted-foreground hover:text-foreground"}`,"aria-label":c.label,"aria-current":d?"page":void 0,children:[d&&e.jsx("div",{className:"absolute inset-0 bg-primary/8 dark:bg-primary/12 rounded-xl"}),e.jsx(u,{className:`relative z-10 transition-all duration-200 ${d?"w-[18px] h-[18px]":"w-4 h-4"}`,strokeWidth:d?2.4:1.8}),e.jsx("span",{className:`relative z-10 text-[9px] leading-tight font-medium truncate w-full text-center transition-all duration-200 ${d?"opacity-100":"opacity-60"}`,children:c.label})]},c.id)})})})})}const Vn="upfyn-tour-complete",Nr=[{target:"chat",title:"Chat",description:"Talk to AI agents — Claude, Cursor, or Codex. Stream responses, run tools, and see every action live."},{target:"canvas",title:"Canvas",description:"A visual whiteboard for code blocks, diagrams, notes, and web previews. Drag, connect, and organize."},{target:"files",title:"Files",description:"Browse your project tree, open files in the built-in editor, and make quick edits."},{target:"shell",title:"Shell",description:"A full terminal — run commands, install packages, or manage processes. Supports multiple tabs."},{target:"git",title:"Git",description:"Stage, commit, push, and view diffs — all from the browser. No terminal needed."}];function w0(){const[t,r]=l.useState(!1),[s,a]=l.useState(0),[n,o]=l.useState(null);l.useEffect(()=>{if(localStorage.getItem(Vn))return;const x=setTimeout(()=>r(!0),800);return()=>clearTimeout(x)},[]);const i=l.useCallback(()=>{if(!t)return;const x=document.querySelector(`[data-tour="${Nr[s].target}"]`);o(x?x.getBoundingClientRect():null)},[t,s]);l.useEffect(()=>(i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)),[i]);const c=l.useCallback(()=>{r(!1),localStorage.setItem(Vn,"1")},[]),u=l.useCallback(()=>{s<Nr.length-1?a(s+1):c()},[s,c]),d=l.useCallback(()=>{s>0&&a(s-1)},[s]);if(l.useEffect(()=>{if(!t)return;const x=b=>{b.key==="Escape"?c():b.key==="ArrowRight"||b.key==="Enter"?u():b.key==="ArrowLeft"&&d()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t,u,d,c]),!t||!n)return null;const m=6,h={top:n.top-m,left:n.left-m,width:n.width+m*2,height:n.height+m*2},p=h.top+h.height+12,g=Math.max(12,Math.min(h.left+h.width/2-160,window.innerWidth-332)),f=Nr[s];return e.jsxs("div",{className:"fixed inset-0 z-[9999]",role:"dialog","aria-label":"Feature tour",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:c}),e.jsx("div",{className:"absolute rounded-lg ring-2 ring-primary/60 bg-transparent pointer-events-none",style:{...h,boxShadow:"0 0 0 9999px rgba(0,0,0,0.5)"}}),e.jsxs("div",{className:"absolute w-[320px] bg-card border border-border/60 rounded-xl shadow-2xl overflow-hidden",style:{top:p,left:g},children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:f.title}),e.jsx("button",{onClick:c,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors","aria-label":"Skip tour",children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:f.description})]}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-border/40 bg-muted/20",children:[e.jsxs("span",{className:"text-xs text-muted-foreground/60",children:[s+1," / ",Nr.length]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&e.jsxs("button",{onClick:d,className:"flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors rounded-lg",children:[e.jsx(ga,{className:"w-3.5 h-3.5"}),"Back"]}),e.jsx("button",{onClick:u,className:"flex items-center gap-1 px-4 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:s<Nr.length-1?e.jsxs(e.Fragment,{children:["Next",e.jsx(rr,{className:"w-3.5 h-3.5"})]}):"Done"})]})]})]})]})}function j0(){const[t,r]=l.useState(new Set),[s,a]=l.useState(new Set),n=l.useCallback(d=>{d&&r(m=>new Set([...m,d]))},[]),o=l.useCallback(d=>{d&&r(m=>{const h=new Set(m);return h.delete(d),h})},[]),i=l.useCallback(d=>{d&&a(m=>new Set([...m,d]))},[]),c=l.useCallback(d=>{d&&a(m=>{const h=new Set(m);return h.delete(d),h})},[]),u=l.useCallback(d=>{d&&r(m=>{const h=new Set;for(const p of m)p.startsWith("new-session-")||h.add(p);return h.add(d),h})},[]);return{activeSessions:t,processingSessions:s,markSessionAsActive:n,markSessionAsInactive:o,markSessionAsProcessing:i,markSessionAsNotProcessing:c,replaceTemporarySession:u}}const mt=t=>JSON.stringify(t??null),qn=(t,r,s)=>t.length!==r.length?!0:r.some((a,n)=>{const o=t[n];return!o||a.name!==o.name||a.displayName!==o.displayName||a.fullPath!==o.fullPath||mt(a.sessionMeta)!==mt(o.sessionMeta)||mt(a.sessions)!==mt(o.sessions)?!0:mt(a.cursorSessions)!==mt(o.cursorSessions)||mt(a.codexSessions)!==mt(o.codexSessions)}),ms=t=>[...t.sessions??[],...t.codexSessions??[],...t.cursorSessions??[]],N0=(t,r,s,a)=>{if(!s||!a)return!0;const n=t.find(u=>u.name===s.name),o=r.find(u=>u.name===s.name);if(!n||!o)return!1;const i=ms(n).find(u=>u.id===a.id),c=ms(o).find(u=>u.id===a.id);return!i||!c?!1:i.id===c.id&&i.title===c.title&&i.created_at===c.created_at&&i.updated_at===c.updated_at};function C0({sessionId:t,navigate:r,latestMessage:s,isMobile:a,activeSessions:n}){const[o,i]=l.useState([]),[c,u]=l.useState(null),[d,m]=l.useState(null),[h,p]=l.useState("chat"),[g,f]=l.useState(!1),[x,b]=l.useState(!0),[N,j]=l.useState(null),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState("agents"),[E,T]=l.useState(0),{relayCwd:W,isRelayConnected:S}=ps(),O=l.useRef(null),H=l.useRef(new Set),R=l.useRef(null),A=l.useCallback(async()=>{try{b(!0);const _=await Be.projects();if(!_.ok)return;const F=await _.json();if(!Array.isArray(F))return;i(q=>q.length===0||qn(q,F,!0)?F:q)}catch(_){console.error("Error fetching projects:",_)}finally{b(!1)}},[]),z=l.useCallback((_="tools")=>{v(_),D(!0)},[]);l.useEffect(()=>{A()},[A]);const J=l.useRef(0);l.useEffect(()=>{if(x||o.length>0||!S||!W){J.current=0;return}if(J.current>=3)return;const _=setTimeout(()=>{J.current++,A()},1500);return()=>clearTimeout(_)},[x,o.length,S,W,A]),l.useEffect(()=>{if(!(x||c||t||o.length===0)){if(S&&W){const _=B=>B.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),F=_(W),q=F.split("/").pop()||"",U=o.find(B=>_(B.fullPath||"")===F||_(B.name||"")===q);if(U){u(U);return}}o.length===1&&u(o[0])}},[x,o,c,t,S,W]),l.useEffect(()=>{if(!R.current||o.length===0)return;const _=R.current,F=ee=>ee.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),q=F(_),U=q.split("/").pop()||"",B=o.find(ee=>F(ee.fullPath||"")===q||F(ee.name||"")===U);B&&(R.current=null,u(B),m(null),p("chat"),r("/"))},[o,r]),l.useEffect(()=>{if(!s)return;if((s.type==="relay-init"||s.type==="relay-status")&&s.cwd&&s.connected!==!1){R.current=s.cwd,A();return}if(s.type==="shell-project-selected"&&s.projectPath){R.current=s.projectPath,A();return}if(s.type==="loading_progress"){O.current&&(clearTimeout(O.current),O.current=null),j(s),s.phase==="complete"&&(O.current=setTimeout(()=>{j(null),O.current=null},500));return}if(s.type!=="projects_updated")return;const _=s;if(_.changedFile&&d&&c){const V=_.changedFile.replace(/\\/g,"/").split("/");V.length>=2&&V[V.length-1].replace(".jsonl","")===d.id&&(n.has(d.id)||T(se=>se+1))}const F=d&&n.has(d.id)||n.size>0&&Array.from(n).some(ee=>ee.startsWith("new-session-")),q=_.projects;if(!Array.isArray(q)||F&&!N0(o,q,c,d)||(i(q),!c))return;const U=q.find(ee=>ee.name===c.name);if(!U||(mt(U)!==mt(c)&&u(U),!d))return;ms(U).find(ee=>ee.id===d.id)||m(null)},[s,c,d,n,o]),l.useEffect(()=>()=>{O.current&&(clearTimeout(O.current),O.current=null)},[]),l.useEffect(()=>{var F,q,U;if(!t||o.length===0)return;const _=!d||d.id!==t;for(const B of o){const ee=(F=B.sessions)==null?void 0:F.find(M=>M.id===t);if(ee){const M=(c==null?void 0:c.name)!==B.name,Y=(d==null?void 0:d.id)!==t||d.__provider!=="claude";M&&u(B),Y&&m({...ee,__provider:"claude"}),_&&p("chat");return}const V=(q=B.cursorSessions)==null?void 0:q.find(M=>M.id===t);if(V){const M=(c==null?void 0:c.name)!==B.name,Y=(d==null?void 0:d.id)!==t||d.__provider!=="cursor";M&&u(B),Y&&m({...V,__provider:"cursor"}),_&&p("chat");return}const w=(U=B.codexSessions)==null?void 0:U.find(M=>M.id===t);if(w){const M=(c==null?void 0:c.name)!==B.name,Y=(d==null?void 0:d.id)!==t||d.__provider!=="codex";M&&u(B),Y&&m({...w,__provider:"codex"}),_&&p("chat");return}}},[t,o,c==null?void 0:c.name,d==null?void 0:d.id,d==null?void 0:d.__provider]);const re=l.useCallback(_=>{u(_),m(null),r("/"),a&&f(!1)},[a,r]),G=l.useCallback(_=>{if(m(_),h!=="git"&&h!=="preview"&&p("chat"),(localStorage.getItem("selected-provider")||"claude")==="cursor"&&sessionStorage.setItem("cursorSessionId",_.id),a){const q=_.__projectName,U=c==null?void 0:c.name;q!==U&&f(!1)}r(`/session/${_.id}`)},[h,a,r,c==null?void 0:c.name]),ie=l.useCallback(_=>{u(_),m(null),p("chat"),r("/"),a&&f(!1)},[a,r]),$=l.useCallback(_=>{H.current.add(_),setTimeout(()=>H.current.delete(_),3e4),(d==null?void 0:d.id)===_&&(m(null),r("/")),i(F=>F.map(q=>{var U,B;return{...q,sessions:((U=q.sessions)==null?void 0:U.filter(ee=>ee.id!==_))??[],sessionMeta:{...q.sessionMeta,total:Math.max(0,(((B=q.sessionMeta)==null?void 0:B.total)??0)-1)}}}))},[r,d==null?void 0:d.id]),Z=l.useCallback(async()=>{try{const _=await Be.projects();if(!_.ok)return;let F=await _.json();if(!Array.isArray(F)||(H.current.size>0&&(F=F.map(B=>{var ee;return{...B,sessions:((ee=B.sessions)==null?void 0:ee.filter(V=>!H.current.has(V.id)))??[]}})),i(B=>qn(B,F,!0)?F:B),!c))return;const q=F.find(B=>B.name===c.name);if(!q||(mt(q)!==mt(c)&&u(q),!d))return;const U=ms(q).find(B=>B.id===d.id);if(U){const B=U.__provider||!d.__provider?U:{...U,__provider:d.__provider};mt(B)!==mt(d)&&m(B)}}catch(_){console.error("Error refreshing sidebar:",_)}},[c,d]),te=l.useCallback(_=>{(c==null?void 0:c.name)===_&&(u(null),m(null),r("/")),i(F=>F.filter(q=>q.name!==_))},[r,c==null?void 0:c.name]),Q=l.useMemo(()=>({projects:o,selectedProject:c,selectedSession:d,onProjectSelect:re,onSessionSelect:G,onNewSession:ie,onSessionDelete:$,onProjectDelete:te,isLoading:x,loadingProgress:N,onRefresh:Z,onShowSettings:()=>D(!0),showSettings:I,settingsInitialTab:C,onCloseSettings:()=>D(!1),isMobile:a}),[ie,te,re,$,G,Z,x,a,N,o,C,c,d,I]);return{projects:o,selectedProject:c,selectedSession:d,activeTab:h,sidebarOpen:g,isLoadingProjects:x,loadingProgress:N,isInputFocused:y,showSettings:I,settingsInitialTab:C,externalMessageUpdate:E,setActiveTab:p,setSidebarOpen:f,setIsInputFocused:k,setShowSettings:D,openSettings:z,fetchProjects:A,sidebarSharedProps:Q,handleProjectSelect:re,handleSessionSelect:G,handleNewSession:ie,handleSessionDelete:$,handleProjectDelete:te,handleSidebarRefresh:Z}}const Kn="upfyn-pwa-install-dismissed",S0=10080*60*1e3;function E0(){const[t,r]=l.useState(null),[s,a]=l.useState(!1),[n,o]=l.useState(()=>{const d=localStorage.getItem(Kn);if(!d)return!1;const m=parseInt(d,10);return Date.now()-m<S0});l.useEffect(()=>{if(window.matchMedia("(display-mode: standalone)").matches||navigator.standalone===!0){a(!0);return}const m=p=>{p.preventDefault(),r(p)};window.addEventListener("beforeinstallprompt",m);const h=()=>a(!0);return window.addEventListener("appinstalled",h),()=>{window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",h)}},[]);const i=l.useCallback(async()=>{if(!t)return;await t.prompt();const{outcome:d}=await t.userChoice;d==="accepted"&&a(!0),r(null)},[t]),c=l.useCallback(()=>{localStorage.setItem(Kn,String(Date.now())),o(!0)},[]);return{canPrompt:!!t&&!s&&!n,isInstalled:s,promptInstall:i,dismiss:c}}function T0(){const t=Yn(),{sessionId:r}=hi(),{t:s}=We("common"),{isMobile:a}=wa({trackPWA:!1}),{ws:n,sendMessage:o,latestMessage:i}=Qn(),{canPrompt:c,promptInstall:u,dismiss:d}=E0(),{activeSessions:m,processingSessions:h,markSessionAsActive:p,markSessionAsInactive:g,markSessionAsProcessing:f,markSessionAsNotProcessing:x,replaceTemporarySession:b}=j0(),{selectedProject:N,selectedSession:j,activeTab:y,sidebarOpen:k,isLoadingProjects:I,isInputFocused:D,externalMessageUpdate:C,setActiveTab:v,setSidebarOpen:E,setIsInputFocused:T,setShowSettings:W,openSettings:S,fetchProjects:O,sidebarSharedProps:H}=C0({sessionId:r,navigate:t,latestMessage:i,isMobile:a,activeSessions:m});return l.useEffect(()=>(window.refreshProjects=O,()=>{window.refreshProjects===O&&delete window.refreshProjects}),[O]),l.useEffect(()=>(window.openSettings=S,()=>{window.openSettings===S&&delete window.openSettings}),[S]),e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[a?e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${k?"opacity-100 visible":"opacity-0 invisible"}`,children:[e.jsx("button",{className:"fixed inset-0 bg-background/60 backdrop-blur-sm transition-opacity duration-150 ease-out",onClick:R=>{R.stopPropagation(),E(!1)},onTouchStart:R=>{R.preventDefault(),R.stopPropagation(),E(!1)},"aria-label":s("versionUpdate.ariaLabels.closeSidebar")}),e.jsx("div",{className:`relative w-[85vw] max-w-sm sm:w-80 h-full bg-card border-r border-border/40 transform transition-transform duration-150 ease-out ${k?"translate-x-0":"-translate-x-full"}`,onClick:R=>R.stopPropagation(),onTouchStart:R=>R.stopPropagation(),children:e.jsx(tn,{...H})})]}):e.jsx("div",{className:"h-full flex-shrink-0 border-r border-border/50",children:e.jsx(tn,{...H})}),e.jsxs("div",{className:`flex-1 flex flex-col min-w-0 ${a?"pb-mobile-nav":""}`,children:[a&&c&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-primary/10 border-b border-primary/20 flex-shrink-0",children:[e.jsx("span",{className:"text-xs text-foreground flex-1",children:"Install Upfyn for a better experience"}),e.jsx("button",{onClick:u,className:"text-xs px-3 py-1 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors",children:"Install"}),e.jsx("button",{onClick:d,className:"p-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Dismiss",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx(v0,{selectedProject:N,selectedSession:j,activeTab:y,setActiveTab:v,ws:n,sendMessage:o,latestMessage:i,isMobile:a,onMenuClick:()=>E(!0),isLoading:I,onInputFocusChange:T,onSessionActive:p,onSessionInactive:g,onSessionProcessing:f,onSessionNotProcessing:x,processingSessions:h,onReplaceTemporarySession:b,onNavigateToSession:R=>t(`/session/${R}`),onShowSettings:()=>W(!0),externalMessageUpdate:C})]}),a&&e.jsx(k0,{activeTab:y,setActiveTab:v,isInputFocused:D}),!a&&e.jsx(w0,{})]})}const _0=Object.freeze(Object.defineProperty({__proto__:null,default:T0},Symbol.toStringTag,{value:"Module"}));export{_0 as A,he as B,Ze as I,su as M,Po as S,wa as a,ke as c,E0 as u};
|