@epiphytic/claudecodeui 1.2.1 → 1.2.2

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.
@@ -1211,7 +1211,7 @@ File: ${e?.name||"New PRD"}
1211
1211
  Path: ${e?.path||"Not saved yet"}
1212
1212
 
1213
1213
  ${q}`)}finally{d(!1)}})()},[e,r,s]),b.useEffect(()=>{(async()=>{if(!n?.name){console.log("No project name available:",n);return}try{console.log("Fetching PRDs for project:",n.name);const K=await mt.get(`/taskmaster/prd/${encodeURIComponent(n.name)}`);if(K.ok){const he=await K.json();console.log("Fetched existing PRDs:",he.prds),M(he.prds||[])}else console.log("Failed to fetch PRDs:",K.status,K.statusText)}catch(K){console.error("Error fetching existing PRDs:",K)}})()},[n?.name]);const ae=async()=>{if(!l.trim()){alert("Please add content before saving.");return}if(!I.trim()){alert("Please provide a filename for the PRD.");return}const R=I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,K=$.find(he=>he.name===R);if(console.log("Save check:",{fullFileName:R,existingPRDs:$,existingFile:K,isExisting:e?.isExisting,fileObject:e,shouldShowModal:K&&!e?.isExisting}),K&&!e?.isExisting){console.log("Showing overwrite confirmation modal"),F(!0);return}await re()},re=async()=>{m(!0);try{const R=I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,K=await Ce(`/api/taskmaster/prd/${encodeURIComponent(n?.name)}`,{method:"POST",body:JSON.stringify({fileName:R,content:l})});if(!K.ok){const xe=await K.json();throw new Error(xe.message||`Save failed: ${K.status}`)}k(!0),setTimeout(()=>k(!1),2e3);const he=await mt.get(`/taskmaster/prd/${encodeURIComponent(n.name)}`);if(he.ok){const xe=await he.json();M(xe.prds||[])}o&&await o()}catch(R){console.error("Error saving PRD:",R),alert(`Error saving PRD: ${R.message}`)}finally{m(!1)}},ne=()=>{const R=new Blob([l],{type:"text/markdown"}),K=URL.createObjectURL(R),he=document.createElement("a");he.href=K;const xe=I?`${I}.txt`:"prd.txt";he.download=xe,document.body.appendChild(he),he.click(),document.body.removeChild(he),URL.revokeObjectURL(K)},C=async()=>{if(!l.trim()){alert("Please add content to the PRD before generating tasks.");return}_(!0)},V=()=>{g(!h)};b.useEffect(()=>{const R=K=>{(K.ctrlKey||K.metaKey)&&(K.key==="s"?(K.preventDefault(),ae()):K.key==="Escape"&&(K.preventDefault(),t()))};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[l]);const se=R=>R.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 u?a.jsx("div",{className:"fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center",children:a.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:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),a.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading PRD..."})]})})}):a.jsxs("div",{className:`fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${h?"md:p-0":""}`,children:[a.jsxs("div",{className:Fe("bg-white dark:bg-gray-900 shadow-2xl flex flex-col","w-full h-full md:rounded-lg md:shadow-2xl",h?"md:w-full md:h-full md:rounded-none":"md:w-full md:max-w-6xl md:h-[85vh] md:max-h-[85vh]"),children:[a.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:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:"w-8 h-8 bg-purple-600 rounded flex items-center justify-center flex-shrink-0",children:a.jsx(Ar,{className:"w-4 h-4 text-white"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[a.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:[a.jsx("input",{type:"text",value:I,onChange:R=>{const K=R.target.value.replace(/[<>:"/\\|?*]/g,"");D(K)},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}),a.jsx("span",{className:"text-sm sm:text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap ml-1",children:".txt"})]}),a.jsx("button",{onClick:()=>document.querySelector('input[placeholder="Enter PRD filename"]')?.focus(),className:"p-1 text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 transition-colors",title:"Click to edit filename",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})})})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.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"}),s&&a.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"})]})]}),a.jsx("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:"Product Requirements Document"})]})]}),a.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[a.jsx("button",{onClick:()=>E(!v),className:Fe("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",v?"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:v?"Switch to edit mode":"Preview markdown",children:a.jsx(ni,{className:"w-5 h-5 md:w-4 md:h-4"})}),a.jsx("button",{onClick:()=>S(!T),className:Fe("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",T?"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:T?"Disable word wrap":"Enable word wrap",children:a.jsx("span",{className:"text-sm md:text-xs font-mono font-bold",children:"↵"})}),a.jsx("button",{onClick:()=>w(!x),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:a.jsx("span",{className:"text-lg md:text-base",children:x?"☀️":"🌙"})}),a.jsx("button",{onClick:ne,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:a.jsx(zs,{className:"w-5 h-5 md:w-4 md:h-4"})}),a.jsxs("button",{onClick:C,disabled:!l.trim(),className:Fe("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:[a.jsx(Fn,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden md:inline",children:"Generate Tasks"})]}),a.jsx("button",{onClick:ae,disabled:p,className:Fe("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",N?"bg-green-600 hover:bg-green-700":"bg-purple-600 hover:bg-purple-700"),children:N?a.jsxs(a.Fragment,{children:[a.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),a.jsx("span",{className:"hidden sm:inline",children:"Saved!"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Oi,{className:"w-5 h-5 md:w-4 md:h-4"}),a.jsx("span",{className:"hidden sm:inline",children:p?"Saving...":"Save PRD"})]})}),a.jsx("button",{onClick:V,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:h?"Exit fullscreen":"Fullscreen",children:h?a.jsx(S2,{className:"w-4 h-4"}):a.jsx(ph,{className:"w-4 h-4"})}),a.jsx("button",{onClick:t,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:a.jsx(jt,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:v?a.jsx("div",{className:"h-full overflow-y-auto p-6 prose prose-gray dark:prose-invert max-w-none",children:a.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:se(l)}})}):a.jsx(h2,{ref:U,value:l,onChange:c,extensions:[f2(),...T?[Yr.lineWrapping]:[]],theme:x?g2: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}})}),a.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:[a.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[a.jsxs("span",{children:["Lines: ",l.split(`
1214
- `).length]}),a.jsxs("span",{children:["Characters: ",l.length]}),a.jsxs("span",{children:["Words: ",l.split(/\s+/).filter(R=>R.length>0).length]}),a.jsx("span",{children:"Format: Markdown"})]}),a.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),L&&a.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:a.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:[a.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:a.jsx(Fn,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),a.jsx("button",{onClick:()=>_(!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:a.jsx(jt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 space-y-4",children:[a.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.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:a.jsx(Fn,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Claude Code Directly!"}),a.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask Claude Code 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."}),a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[a.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),a.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/`,I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),a.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[a.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),a.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),a.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 →"})]}),a.jsx("div",{className:"pt-4",children:a.jsx("button",{onClick:()=>_(!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 Claude Code directly"})})]})]})}),z&&a.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>F(!1)}),a.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:a.jsxs("div",{className:"p-6",children:[a.jsxs("div",{className:"flex items-center mb-4",children:[a.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:a.jsx(kn,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),a.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),a.jsxs("div",{className:"flex justify-end space-x-3",children:[a.jsx("button",{onClick:()=>F(!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"}),a.jsxs("button",{onClick:async()=>{F(!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:[a.jsx(Oi,{className:"w-4 h-4"}),a.jsx("span",{children:"Overwrite"})]})]})]})})]})]})};function nq({selectedProject:e,selectedSession:t,activeTab:r,setActiveTab:n,ws:i,sendMessage:s,messages:o,isMobile:l,isPWA:c,onMenuClick:u,isLoading:d,isProjectSwitching:p,onProjectReady:m,onInputFocusChange:h,onSessionActive:g,onSessionInactive:x,onSessionProcessing:w,onSessionNotProcessing:N,processingSessions:k,onReplaceTemporarySession:v,onNavigateToSession:E,onShowSettings:T,autoExpandTools:S,showRawParameters:I,showThinking:D,autoScrollToBottom:L,sendByCtrlEnter:_,externalMessageUpdate:z}){const[F,$]=b.useState(null),[M,U]=b.useState(null),[q,ae]=b.useState(!1),[re,ne]=b.useState(600),[C,V]=b.useState(!1),[se,R]=b.useState(!1),K=b.useRef(null),[he,xe]=b.useState(!1),[oe,De]=b.useState(null),[le,ge]=b.useState([]),[Ae,ie]=b.useState(null),{tasks:Ie,currentProject:ze,refreshTasks:wt,setCurrentProject:ot}=Wi(),{tasksEnabled:xt,isTaskMasterInstalled:ht,isTaskMasterReady:Ze}=Vi(),lt=xt&&ht;b.useEffect(()=>{e&&e!==ze&&ot(e)},[e,ze,ot]),b.useEffect(()=>{!lt&&r==="tasks"&&n("chat")},[lt,r,n]),b.useEffect(()=>{(async()=>{if(!ze?.name){ge([]);return}try{const ke=await mt.get(`/taskmaster/prd/${encodeURIComponent(ze.name)}`);if(ke.ok){const qe=await ke.json();ge(qe.prdFiles||[])}else ge([])}catch(ke){console.error("Failed to load existing PRDs:",ke),ge([])}})()},[ze?.name]);const Mt=(de,ke=null)=>{const qe={name:de.split("/").pop(),path:de,projectName:e?.name,diffInfo:ke};$(qe)},Bt=()=>{$(null),R(!1)},Yt=()=>{R(!se)},we=de=>{if(typeof de=="object"&&de.id&&!de.title){const ke=Ie?.find(qe=>qe.id===de.id);ke&&(U(ke),ae(!0))}else U(de),ae(!0)},ue=()=>{ae(!1),U(null)},X=(de,ke)=>{console.log("Update task status:",de,ke),wt?.()},J=de=>{l||(V(!0),de.preventDefault())};return b.useEffect(()=>{const de=qe=>{if(!C)return;const Ct=K.current?.parentElement;if(!Ct)return;const bt=Ct.getBoundingClientRect(),me=bt.right-qe.clientX,Ge=300,je=bt.width*.8;me>=Ge&&me<=je&&ne(me)},ke=()=>{V(!1)};return C&&(document.addEventListener("mousemove",de),document.addEventListener("mouseup",ke),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",ke),document.body.style.cursor="",document.body.style.userSelect=""}},[C]),b.useEffect(()=>{if(p&&e&&m){const de=setTimeout(()=>{m()},150);return()=>clearTimeout(de)}},[p,e,m]),d||p?a.jsxs("div",{className:"h-full flex flex-col",children:[l&&a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsx("button",{onClick:u,className:"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-700 pwa-menu-button",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[a.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:a.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-blue-500",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),a.jsx("h2",{className:"text-xl font-semibold mb-2",children:p?"Switching Project":"Loading Claude Code UI"}),a.jsx("p",{children:p?`Loading ${e?.displayName||"project"}...`:"Setting up your workspace..."})]})})]}):e?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsxs("div",{className:"flex items-center justify-between relative",children:[a.jsxs("div",{className:"flex items-center space-x-2 min-w-0 flex-1",children:[l&&a.jsx("button",{onClick:u,onTouchStart:de=>{de.preventDefault(),u()},className:"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-700 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),a.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[r==="chat"&&t&&a.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:t.__provider==="cursor"?a.jsx(Kr,{className:"w-4 h-4"}):a.jsx($r,{className:"w-4 h-4"})}),a.jsx("div",{className:"min-w-0 flex-1",children:r==="chat"&&t?a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white whitespace-nowrap overflow-x-auto scrollbar-hide",children:t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):r==="chat"&&!t?a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:"New Session"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:r==="files"?"Project Files":r==="git"?"Source Control":r==="tasks"&&lt?"TaskMaster":"Project"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),a.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:a.jsxs("div",{className:"relative flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[a.jsx(Ir,{content:"Chat",position:"bottom",children:a.jsx("button",{onClick:()=>n("chat"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md ${r==="chat"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Chat"})]})})}),a.jsx(Ir,{content:"Shell",position:"bottom",children:a.jsx("button",{onClick:()=>n("shell"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="shell"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Shell"})]})})}),a.jsx(Ir,{content:"Files",position:"bottom",children:a.jsx("button",{onClick:()=>n("files"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="files"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Files"})]})})}),a.jsx(Ir,{content:"Source Control",position:"bottom",children:a.jsx("button",{onClick:()=>n("git"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="git"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Source Control"})]})})}),lt&&a.jsx(Ir,{content:"Tasks",position:"bottom",children:a.jsx("button",{onClick:()=>n("tasks"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="tasks"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Tasks"})]})})})]})})]})}),a.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[a.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${F?"mr-0":""} ${se?"hidden":""}`,children:[a.jsx("div",{className:`h-full ${r==="chat"?"block":"hidden"}`,children:a.jsx(Q$,{showDetails:!0,children:a.jsx(o$,{selectedProject:e,selectedSession:t,ws:i,sendMessage:s,messages:o,onFileOpen:Mt,onInputFocusChange:h,onSessionActive:g,onSessionInactive:x,onSessionProcessing:w,onSessionNotProcessing:N,processingSessions:k,onReplaceTemporarySession:v,onNavigateToSession:E,onShowSettings:T,autoExpandTools:S,showRawParameters:I,showThinking:D,autoScrollToBottom:L,sendByCtrlEnter:_,externalMessageUpdate:z,onShowAllTasks:xt?()=>n("tasks"):null})})}),r==="files"&&a.jsx("div",{className:"h-full overflow-hidden",children:a.jsx(Z$,{selectedProject:e})}),r==="shell"&&a.jsx("div",{className:"h-full w-full overflow-hidden",children:a.jsx(sN,{project:e,session:t,showHeader:!1})}),r==="git"&&a.jsx("div",{className:"h-full overflow-hidden",children:a.jsx(J$,{selectedProject:e,isMobile:l,onFileOpen:Mt})}),lt&&a.jsx("div",{className:`h-full ${r==="tasks"?"block":"hidden"}`,children:a.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:a.jsx(tq,{tasks:Ie||[],onTaskClick:we,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:ze,onTaskCreated:wt,onShowPRDEditor:(de=null)=>{De(de),xe(!0)},existingPRDs:le,onRefreshPRDs:(de=!1)=>{ze?.name&&mt.get(`/taskmaster/prd/${encodeURIComponent(ze.name)}`).then(ke=>ke.ok?ke.json():Promise.reject()).then(ke=>{ge(ke.prdFiles||[]),de&&(ie("PRD saved successfully!"),setTimeout(()=>ie(null),3e3))}).catch(ke=>console.error("Failed to refresh PRDs:",ke))}})})}),a.jsx("div",{className:`h-full overflow-hidden ${r==="preview"?"block":"hidden"}`})]}),F&&!l&&a.jsxs(a.Fragment,{children:[!se&&a.jsx("div",{ref:K,onMouseDown:J,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:a.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),a.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${se?"flex-1":""}`,style:se?{}:{width:`${re}px`},children:a.jsx(ah,{file:F,onClose:Bt,projectPath:e?.path,isSidebar:!0,isExpanded:se,onToggleExpand:Yt})})]})]}),F&&l&&a.jsx(ah,{file:F,onClose:Bt,projectPath:e?.path,isSidebar:!1}),lt&&q&&M&&a.jsx(IE,{task:M,isOpen:q,onClose:ue,onStatusChange:X,onTaskClick:we}),he&&a.jsx(rq,{project:ze,projectPath:ze?.fullPath||ze?.path,onClose:()=>{xe(!1),De(null)},isNewFile:!oe?.isExisting,file:{name:oe?.name||"prd.txt",content:oe?.content||""},onSave:async()=>{xe(!1),De(null);try{const de=await mt.get(`/taskmaster/prd/${encodeURIComponent(ze.name)}`);if(de.ok){const ke=await de.json();ge(ke.prdFiles||[]),ie("PRD saved successfully!"),setTimeout(()=>ie(null),3e3)}}catch(de){console.error("Failed to refresh PRDs:",de)}wt?.()}}),Ae&&a.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:a.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),a.jsx("span",{className:"font-medium",children:Ae})]})})]}):a.jsxs("div",{className:"h-full flex flex-col",children:[l&&a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsx("button",{onClick:u,className:"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-700 pwa-menu-button",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 max-w-md mx-auto px-6",children:[a.jsx("div",{className:"w-16 h-16 mx-auto mb-6 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:a.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),a.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:"Choose Your Project"}),a.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:"Select a project from the sidebar to start coding with Claude. Each project contains your chat sessions and file history."}),a.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:a.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:["💡 ",a.jsx("strong",{children:"Tip:"})," ",l?"Tap the menu button above to access projects":"Create a new project by clicking the folder icon in the sidebar"]})})]})})]})}const aq=Pt.memo(nq);function iq({activeTab:e,setActiveTab:t,isInputFocused:r}){const{tasksEnabled:n}=Vi(),i=[{id:"chat",icon:zn,onClick:()=>t("chat")},{id:"shell",icon:Jr,onClick:()=>t("shell")},{id:"files",icon:Mn,onClick:()=>t("files")},{id:"git",icon:vn,onClick:()=>t("git")},...n?[{id:"tasks",icon:G5,onClick:()=>t("tasks")}]:[]];return a.jsx("div",{className:`fixed bottom-0 left-0 right-0 bg-background border-t border-border z-50 ios-bottom-safe transform transition-transform duration-300 ease-in-out shadow-lg ${r?"translate-y-full":"translate-y-0"}`,children:a.jsx("div",{className:"flex items-center justify-around py-1",children:i.map(s=>{const o=s.icon,l=e===s.id;return a.jsxs("button",{onClick:s.onClick,onTouchStart:c=>{c.preventDefault(),s.onClick()},className:`flex items-center justify-center p-2 rounded-lg min-h-[40px] min-w-[40px] relative touch-manipulation ${l?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,"aria-label":s.id,children:[a.jsx(o,{className:"w-5 h-5"}),l&&a.jsx("div",{className:"absolute top-0 left-1/2 transform -translate-x-1/2 w-6 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-full"})]},s.id)})})})}const ih="1.2.0",sq="@epiphytic/claudecodeui",oN=(e=null)=>{const[t,r]=b.useState(!1),[n,i]=b.useState(null),[s,o]=b.useState(null),l=e||void 0||sq;return b.useEffect(()=>{const c=async()=>{try{const d=encodeURIComponent(l),p=await fetch(`https://registry.npmjs.org/${d}/latest`);if(!p.ok){console.warn(`Version check: Package ${l} not found on npm`),r(!1),i(null),o(null);return}const m=await p.json();if(m.version){const h=m.version;i(h),r(oq(h,ih)),o({name:m.name,description:m.description||"",homepage:m.homepage||`https://www.npmjs.com/package/${l}`,repository:m.repository?.url||null})}else r(!1),i(null),o(null)}catch(d){console.error("Version check failed:",d),r(!1),i(null),o(null)}};c();const u=setInterval(c,300*1e3);return()=>clearInterval(u)},[l]),{updateAvailable:t,latestVersion:n,currentVersion:ih,packageInfo:s}};function oq(e,t){const r=e.split(".").map(s=>parseInt(s,10)||0),n=t.split(".").map(s=>parseInt(s,10)||0),i=Math.max(r.length,n.length);for(;r.length<i;)r.push(0);for(;n.length<i;)n.push(0);for(let s=0;s<i;s++){if(r[s]>n[s])return!0;if(r[s]<n[s])return!1}return!1}function lq(){const[e,t]=b.useState([]),[r,n]=b.useState([]),[i,s]=b.useState(!0),[o,l]=b.useState(!1),[c,u]=b.useState(!1),[d,p]=b.useState(""),[m,h]=b.useState(""),[g,x]=b.useState(""),[w,N]=b.useState(""),[k,v]=b.useState({}),[E,T]=b.useState(null),[S,I]=b.useState(null),{updateAvailable:D,latestVersion:L,packageInfo:_}=oN();b.useEffect(()=>{z()},[]);const z=async()=>{try{s(!0);const C=await(await Ce("/api/settings/api-keys")).json();t(C.apiKeys||[]);const se=await(await Ce("/api/settings/credentials?type=github_token")).json();n(se.credentials||[])}catch(ne){console.error("Error fetching settings:",ne)}finally{s(!1)}},F=async()=>{if(d.trim())try{const C=await(await Ce("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:d})})).json();C.success&&(I(C.apiKey),p(""),l(!1),z())}catch(ne){console.error("Error creating API key:",ne)}},$=async ne=>{if(confirm("Are you sure you want to delete this API key?"))try{await Ce(`/api/settings/api-keys/${ne}`,{method:"DELETE"}),z()}catch(C){console.error("Error deleting API key:",C)}},M=async(ne,C)=>{try{await Ce(`/api/settings/api-keys/${ne}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!C})}),z()}catch(V){console.error("Error toggling API key:",V)}},U=async()=>{if(!(!m.trim()||!g.trim()))try{(await(await Ce("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:m,credentialType:"github_token",credentialValue:g,description:w})})).json()).success&&(h(""),x(""),N(""),u(!1),z())}catch(ne){console.error("Error creating GitHub credential:",ne)}},q=async ne=>{if(confirm("Are you sure you want to delete this GitHub token?"))try{await Ce(`/api/settings/credentials/${ne}`,{method:"DELETE"}),z()}catch(C){console.error("Error deleting GitHub credential:",C)}},ae=async(ne,C)=>{try{await Ce(`/api/settings/credentials/${ne}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!C})}),z()}catch(V){console.error("Error toggling GitHub credential:",V)}},re=(ne,C)=>{navigator.clipboard.writeText(ne),T(C),setTimeout(()=>T(null),2e3)};return i?a.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):a.jsxs("div",{className:"space-y-8",children:[S&&a.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[a.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:"⚠️ Save Your API Key"}),a.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"This is the only time you'll see this key. Store it securely."}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:S.apiKey}),a.jsx(We,{size:"sm",variant:"outline",onClick:()=>re(S.apiKey,"new"),children:E==="new"?a.jsx(vr,{className:"h-4 w-4"}):a.jsx(y2,{className:"h-4 w-4"})})]}),a.jsx(We,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>I(null),children:"I've saved it"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(dh,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"API Keys"})]}),a.jsxs(We,{size:"sm",onClick:()=>l(!o),children:[a.jsx(hr,{className:"h-4 w-4 mr-1"}),"New API Key"]})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Generate API keys to access the external API from other applications."}),a.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:["API Documentation",a.jsx(Dg,{className:"h-3 w-3"})]})]}),o&&a.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[a.jsx(tr,{placeholder:"API Key Name (e.g., Production Server)",value:d,onChange:ne=>p(ne.target.value),className:"mb-2"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(We,{onClick:F,children:"Create"}),a.jsx(We,{variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]}),a.jsx("div",{className:"space-y-2",children:e.length===0?a.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No API keys created yet."}):e.map(ne=>a.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium",children:ne.key_name}),a.jsx("code",{className:"text-xs text-muted-foreground",children:ne.api_key}),a.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Created: ",new Date(ne.created_at).toLocaleDateString(),ne.last_used&&` • Last used: ${new Date(ne.last_used).toLocaleDateString()}`]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{size:"sm",variant:ne.is_active?"outline":"secondary",onClick:()=>M(ne.id,ne.is_active),children:ne.is_active?"Active":"Inactive"}),a.jsx(We,{size:"sm",variant:"ghost",onClick:()=>$(ne.id),children:a.jsx(_r,{className:"h-4 w-4"})})]})]},ne.id))})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(n5,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"GitHub Credentials"})]}),a.jsxs(We,{size:"sm",onClick:()=>u(!c),children:[a.jsx(hr,{className:"h-4 w-4 mr-1"}),"Add Token"]})]}),a.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add GitHub Personal Access Tokens to clone private repositories. You can also pass tokens directly in API requests without storing them."}),c&&a.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[a.jsx(tr,{placeholder:"Token Name (e.g., Personal Repos)",value:m,onChange:ne=>h(ne.target.value)}),a.jsxs("div",{className:"relative",children:[a.jsx(tr,{type:k.new?"text":"password",placeholder:"GitHub Personal Access Token (ghp_...)",value:g,onChange:ne=>x(ne.target.value),className:"pr-10"}),a.jsx("button",{type:"button",onClick:()=>v({...k,new:!k.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:k.new?a.jsx(v2,{className:"h-4 w-4"}):a.jsx(ni,{className:"h-4 w-4"})})]}),a.jsx(tr,{placeholder:"Description (optional)",value:w,onChange:ne=>N(ne.target.value)}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(We,{onClick:U,children:"Add Token"}),a.jsx(We,{variant:"outline",onClick:()=>{u(!1),h(""),x(""),N("")},children:"Cancel"})]}),a.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:"How to create a GitHub Personal Access Token →"})]}),a.jsx("div",{className:"space-y-2",children:r.length===0?a.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No GitHub tokens added yet."}):r.map(ne=>a.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium",children:ne.credential_name}),ne.description&&a.jsx("div",{className:"text-xs text-muted-foreground",children:ne.description}),a.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Added:"," ",new Date(ne.created_at).toLocaleDateString()]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{size:"sm",variant:ne.is_active?"outline":"secondary",onClick:()=>ae(ne.id,ne.is_active),children:ne.is_active?"Active":"Inactive"}),a.jsx(We,{size:"sm",variant:"ghost",onClick:()=>q(ne.id),children:a.jsx(_r,{className:"h-4 w-4"})})]})]},ne.id))})]}),a.jsx("div",{className:"pt-6 border-t border-border/50",children:a.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[a.jsxs("a",{href:_?.homepage||"https://www.npmjs.com/package/@epiphytic/claudecodeui",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",ih]}),D&&L&&a.jsxs("a",{href:_?.homepage||"https://www.npmjs.com/package/@epiphytic/claudecodeui",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:[a.jsxs("span",{className:"text-[10px]",children:["Update available: v",L]}),a.jsx(Dg,{className:"h-2.5 w-2.5"})]})]})})]})}function cq(){const[e,t]=b.useState(""),[r,n]=b.useState(""),[i,s]=b.useState(!1),[o,l]=b.useState(!1),[c,u]=b.useState(null);b.useEffect(()=>{d()},[]);const d=async()=>{try{s(!0);const m=await Ce("/api/user/git-config");if(m.ok){const h=await m.json();t(h.gitName||""),n(h.gitEmail||"")}}catch(m){console.error("Error loading git config:",m)}finally{s(!1)}},p=async()=>{try{l(!0);const m=await Ce("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:e,gitEmail:r})});if(m.ok)u("success"),setTimeout(()=>u(null),3e3);else{const h=await m.json();u("error"),console.error("Failed to save git config:",h.error)}}catch(m){console.error("Error saving git config:",m),u("error")}finally{l(!1)}};return a.jsx("div",{className:"space-y-8",children:a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(vn,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"Git Configuration"})]}),a.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Configure your git identity for commits. These settings will be applied globally via ",a.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs",children:"git config --global"})]}),a.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:"Git Name"}),a.jsx(tr,{id:"settings-git-name",type:"text",value:e,onChange:m=>t(m.target.value),placeholder:"John Doe",disabled:i,className:"w-full"}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Your name for git commits"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:"Git Email"}),a.jsx(tr,{id:"settings-git-email",type:"email",value:r,onChange:m=>n(m.target.value),placeholder:"john@example.com",disabled:i,className:"w-full"}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Your email for git commits"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{onClick:p,disabled:o||!e||!r,children:o?"Saving...":"Save Configuration"}),c==="success"&&a.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[a.jsx(vr,{className:"w-4 h-4"}),"Saved successfully"]})]})]})]})})}function uq(){const{tasksEnabled:e,setTasksEnabled:t,isTaskMasterInstalled:r,isCheckingInstallation:n}=Vi();return a.jsx("div",{className:"space-y-8",children:n?a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:"Checking TaskMaster installation..."})]})}):a.jsxs(a.Fragment,{children:[!r&&a.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.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:a.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:"TaskMaster AI CLI Not Installed"}),a.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[a.jsx("p",{children:"TaskMaster CLI is required to use task management features. Install it to get started:"}),a.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:a.jsx("code",{children:"npm install -g task-master-ai"})}),a.jsx("div",{children:a.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:[a.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:a.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"})}),"View on GitHub",a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})})]})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"font-medium",children:"After installation:"}),a.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[a.jsx("li",{children:"Restart this application"}),a.jsx("li",{children:"TaskMaster features will automatically become available"}),a.jsxs("li",{children:["Use ",a.jsx("code",{className:"bg-orange-100 dark:bg-orange-800 px-1 rounded",children:"task-master init"})," in your project directory"]})]})]})]})]})]})}),r&&a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Enable TaskMaster Integration"}),a.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:"Show TaskMaster tasks, banners, and sidebar indicators across the interface"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:i=>t(i.target.checked),className:"sr-only peer"}),a.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"})]})]})})})]})})}function lN({isOpen:e,onClose:t,provider:r="claude",project:n,onComplete:i,customCommand:s}){if(!e)return null;const o=()=>{if(s)return s;const u=!1;switch(r){case"claude":return"claude setup-token --dangerously-skip-permissions";case"cursor":return"cursor-agent login";case"codex":return u?"codex login --device-auth":"codex login";default:return"claude setup-token --dangerously-skip-permissions"}},l=()=>{switch(r){case"claude":return"Claude CLI Login";case"cursor":return"Cursor CLI Login";case"codex":return"Codex CLI Login";default:return"CLI Login"}},c=u=>{i&&i(u),u===0&&t()};return a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:l()}),a.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:a.jsx(jt,{className:"w-6 h-6"})})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(sN,{project:n,command:o(),onComplete:c,minimal:!0})})]})})}const dq={claude:{name:"Claude",color:"blue",Logo:$r},cursor:{name:"Cursor",color:"purple",Logo:Kr},codex:{name:"Codex",color:"gray",Logo:on}},pq={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 Ba({agentId:e,authStatus:t,isSelected:r,onClick:n,isMobile:i=!1}){const s=dq[e],o=pq[s.color],{Logo:l}=s;return i?a.jsx("button",{onClick:n,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${r?`${o.borderBottom} ${o.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsx(l,{className:"w-5 h-5"}),a.jsx("span",{className:"text-xs font-medium text-foreground",children:s.name}),t?.authenticated&&a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o.dot}`})]})}):a.jsxs("button",{onClick:n,className:`w-full text-left p-3 border-l-4 transition-colors ${r?`${o.border} ${o.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(l,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:s.name})]}),a.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:t?.loading?a.jsx("span",{className:"text-gray-400",children:"Checking..."}):t?.authenticated?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o.dot}`}),a.jsx("span",{className:"truncate max-w-[120px]",title:t.email,children:t.email||"Connected"})]}):a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),a.jsx("span",{children:"Not connected"})]})})]})}const mq={claude:{name:"Claude",description:"Anthropic Claude AI assistant",Logo:$r,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",Logo:Kr,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",Logo:on,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 hq({agent:e,authStatus:t,onLogin:r}){const n=mq[e],{Logo:i}=n;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx(i,{className:"w-6 h-6"}),a.jsxs("div",{children:[a.jsxs("h3",{className:"text-lg font-medium text-foreground",children:[n.name," Account"]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:n.description})]})]}),a.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:`font-medium ${n.textClass}`,children:"Connection Status"}),a.jsx("div",{className:`text-sm ${n.subtextClass}`,children:t?.loading?"Checking authentication status...":t?.authenticated?`Logged in as ${t.email||"authenticated user"}`:"Not connected"})]}),a.jsx("div",{children:t?.loading?a.jsx(Zr,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:"Checking..."}):t?.authenticated?a.jsx(Zr,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:"Connected"}):a.jsx(Zr,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:"Disconnected"})})]}),a.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:`font-medium ${n.textClass}`,children:t?.authenticated?"Re-authenticate":"Login"}),a.jsx("div",{className:`text-sm ${n.subtextClass}`,children:t?.authenticated?"Sign in with a different account or refresh credentials":`Sign in to your ${n.name} account to enable AI features`})]}),a.jsxs(We,{onClick:r,className:`${n.buttonClass} text-white`,size:"sm",children:[a.jsx(w2,{className:"w-4 h-4 mr-2"}),t?.authenticated?"Re-login":"Login"]})]})}),t?.error&&a.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:a.jsxs("div",{className:"text-sm text-red-600 dark:text-red-400",children:["Error: ",t.error]})})]})})]})}const gq=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],fq=["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 bq({skipPermissions:e,setSkipPermissions:t,allowedTools:r,setAllowedTools:n,disallowedTools:i,setDisallowedTools:s,newAllowedTool:o,setNewAllowedTool:l,newDisallowedTool:c,setNewDisallowedTool:u}){const d=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},p=g=>{n(r.filter(x=>x!==g))},m=g=>{g&&!i.includes(g)&&(s([...i,g]),u(""))},h=g=>{s(i.filter(x=>x!==g))};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(kn,{className:"w-5 h-5 text-orange-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Settings"})]}),a.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("label",{className:"flex items-center gap-3",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:g=>t(g.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"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"Skip permission prompts (use with caution)"}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Equivalent to --dangerously-skip-permissions flag"})]})]})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(mh,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Allowed Tools"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Tools that are automatically allowed without prompting for permission"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(tr,{value:o,onChange:g=>l(g.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),d(o))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>d(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[a.jsx(hr,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Quick add common tools:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:gq.map(g=>a.jsx(We,{variant:"outline",size:"sm",onClick:()=>d(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),a.jsxs("div",{className:"space-y-2",children:[r.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>p(g),className:"text-green-600 hover:text-green-700",children:a.jsx(jt,{className:"w-4 h-4"})})]},g)),r.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No allowed tools configured"})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(kn,{className:"w-5 h-5 text-red-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Blocked Tools"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Tools that are automatically blocked without prompting for permission"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(tr,{value:c,onChange:g=>u(g.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),m(c))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>m(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[a.jsx(hr,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[i.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>h(g),className:"text-red-600 hover:text-red-700",children:a.jsx(jt,{className:"w-4 h-4"})})]},g)),i.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No blocked tools configured"})]})]}),a.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:"Tool Pattern Examples:"}),a.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," - Allow all git log commands"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," - Allow all git diff commands"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," - Allow all Write tool usage"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," - Block all rm commands (dangerous)"]})]})]})]})}function xq({skipPermissions:e,setSkipPermissions:t,allowedCommands:r,setAllowedCommands:n,disallowedCommands:i,setDisallowedCommands:s,newAllowedCommand:o,setNewAllowedCommand:l,newDisallowedCommand:c,setNewDisallowedCommand:u}){const d=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},p=g=>{n(r.filter(x=>x!==g))},m=g=>{g&&!i.includes(g)&&(s([...i,g]),u(""))},h=g=>{s(i.filter(x=>x!==g))};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(kn,{className:"w-5 h-5 text-orange-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Settings"})]}),a.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("label",{className:"flex items-center gap-3",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:g=>t(g.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"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"Skip permission prompts (use with caution)"}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Equivalent to -f flag in Cursor CLI"})]})]})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(mh,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Allowed Shell Commands"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Shell commands that are automatically allowed without prompting"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(tr,{value:o,onChange:g=>l(g.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),d(o))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>d(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[a.jsx(hr,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Quick add common commands:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:fq.map(g=>a.jsx(We,{variant:"outline",size:"sm",onClick:()=>d(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),a.jsxs("div",{className:"space-y-2",children:[r.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>p(g),className:"text-green-600 hover:text-green-700",children:a.jsx(jt,{className:"w-4 h-4"})})]},g)),r.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No allowed commands configured"})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(kn,{className:"w-5 h-5 text-red-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Blocked Shell Commands"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Shell commands that are automatically blocked"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(tr,{value:c,onChange:g=>u(g.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),m(c))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>m(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[a.jsx(hr,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[i.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>h(g),className:"text-red-600 hover:text-red-700",children:a.jsx(jt,{className:"w-4 h-4"})})]},g)),i.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No blocked commands configured"})]})]}),a.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:"Shell Command Examples:"}),a.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," - Allow ls command"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," - Allow git status"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," - Allow npm install"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," - Block recursive delete"]})]})]})]})}function yq({permissionMode:e,setPermissionMode:t}){return a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(mh,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Mode"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls how Codex handles file modifications and command execution"}),a.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="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:()=>t("default"),children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="default",onChange:()=>t("default"),className:"mt-1 w-4 h-4 text-green-600"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Default"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Only trusted commands (ls, cat, grep, git status, etc.) run automatically. Other commands are skipped. Can write to workspace."})]})]})}),a.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="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:()=>t("acceptEdits"),children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="acceptEdits",onChange:()=>t("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:"Accept Edits"}),a.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:"All commands run automatically within the workspace. Full auto mode with sandboxed execution."})]})]})}),a.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="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:()=>t("bypassPermissions"),children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="bypassPermissions",onChange:()=>t("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),a.jsxs("div",{children:[a.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:["Bypass Permissions",a.jsx(kn,{className:"w-4 h-4"})]}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Full system access with no restrictions. All commands run automatically with full disk and network access. Use with caution."})]})]})}),a.jsxs("details",{className:"text-sm",children:[a.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Technical details"}),a.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:[a.jsxs("p",{children:[a.jsx("strong",{children:"Default:"})," sandboxMode=workspace-write, approvalPolicy=untrusted. Trusted commands: cat, cd, grep, head, ls, pwd, tail, git status/log/diff/show, find (without -exec), etc."]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Accept Edits:"})," sandboxMode=workspace-write, approvalPolicy=never. All commands auto-execute within project directory."]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Bypass Permissions:"})," sandboxMode=danger-full-access, approvalPolicy=never. Full system access, use only in trusted environments."]}),a.jsx("p",{className:"text-xs opacity-75",children:"You can override this per-session using the mode button in the chat interface."})]})]})]})})}function dm({agent:e,...t}){return e==="claude"?a.jsx(bq,{...t}):e==="cursor"?a.jsx(xq,{...t}):e==="codex"?a.jsx(yq,{...t}):null}const vq=e=>{switch(e){case"stdio":return a.jsx(Jr,{className:"w-4 h-4"});case"sse":return a.jsx(gh,{className:"w-4 h-4"});case"http":return a.jsx(hm,{className:"w-4 h-4"});default:return a.jsx(io,{className:"w-4 h-4"})}};function kq({servers:e,onAdd:t,onEdit:r,onDelete:n,onTest:i,onDiscoverTools:s,testResults:o,serverTools:l,toolsLoading:c}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(io,{className:"w-5 h-5 text-purple-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Claude"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[a.jsx(hr,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(u=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[vq(u.type),a.jsx("span",{className:"font-medium text-foreground",children:u.name}),a.jsx(Zr,{variant:"outline",className:"text-xs",children:u.type}),a.jsx(Zr,{variant:"outline",className:"text-xs",children:u.scope==="local"?"local":u.scope==="user"?"user":u.scope})]}),a.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[u.type==="stdio"&&u.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.command})]}),(u.type==="sse"||u.type==="http")&&u.config?.url&&a.jsxs("div",{children:["URL: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.url})]}),u.config?.args&&u.config.args.length>0&&a.jsxs("div",{children:["Args: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.args.join(" ")})]})]}),o?.[u.id]&&a.jsx("div",{className:`mt-2 p-2 rounded text-xs ${o[u.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:a.jsx("div",{className:"font-medium",children:o[u.id].message})}),l?.[u.id]&&l[u.id].tools?.length>0&&a.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:[a.jsxs("div",{className:"font-medium",children:["Tools (",l[u.id].tools.length,"):"]}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[l[u.id].tools.slice(0,5).map((d,p)=>a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:d.name},p)),l[u.id].tools.length>5&&a.jsxs("span",{className:"text-xs opacity-75",children:["+",l[u.id].tools.length-5," more"]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(u),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"Edit server",children:a.jsx(Li,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(u.id,u.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"Delete server",children:a.jsx(_r,{className:"w-4 h-4"})})]})]})},u.id)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]})]})}function wq({servers:e,onAdd:t,onEdit:r,onDelete:n}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(io,{className:"w-5 h-5 text-purple-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Cursor"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[a.jsx(hr,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(i=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Jr,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:i.name}),a.jsx(Zr,{variant:"outline",className:"text-xs",children:"stdio"})]}),a.jsx("div",{className:"text-sm text-muted-foreground",children:i.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.command})]})})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(i),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:a.jsx(Li,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(i.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",children:a.jsx(_r,{className:"w-4 h-4"})})]})]})},i.name||i.id)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]})]})}function Sq({servers:e,onAdd:t,onEdit:r,onDelete:n}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(io,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Codex"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[a.jsx(hr,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(i=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Jr,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:i.name}),a.jsx(Zr,{variant:"outline",className:"text-xs",children:"stdio"})]}),a.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[i.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.command})]}),i.config?.args&&i.config.args.length>0&&a.jsxs("div",{children:["Args: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.args.join(" ")})]}),i.config?.env&&Object.keys(i.config.env).length>0&&a.jsxs("div",{children:["Environment: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(i.config.env).map(([s,o])=>`${s}=${o}`).join(", ")})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(i),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"Edit server",children:a.jsx(Li,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(i.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"Delete server",children:a.jsx(_r,{className:"w-4 h-4"})})]})]})},i.name)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]}),a.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:"About Codex MCP"}),a.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Codex supports stdio-based MCP servers. You can add servers that extend Codex's capabilities with additional tools and resources."})]})]})}function pm({agent:e,...t}){return e==="claude"?a.jsx(kq,{...t}):e==="cursor"?a.jsx(wq,{...t}):e==="codex"?a.jsx(Sq,{...t}):null}function Eq({isOpen:e,onClose:t,projects:r=[],initialTab:n="agents"}){const{isDarkMode:i,toggleDarkMode:s}=Gi(),[o,l]=b.useState([]),[c,u]=b.useState([]),[d,p]=b.useState(""),[m,h]=b.useState(""),[g,x]=b.useState(!1),[w,N]=b.useState(!1),[k,v]=b.useState(null),[E,T]=b.useState("name"),[S,I]=b.useState("repo"),[D,L]=b.useState("1w"),[_,z]=b.useState([]),[F,$]=b.useState(!1),[M,U]=b.useState(null),[q,ae]=b.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[re,ne]=b.useState(!1),[C,V]=b.useState({}),[se,R]=b.useState({}),[K,he]=b.useState({}),[xe,oe]=b.useState(n),[De,le]=b.useState(""),[ge,Ae]=b.useState("claude"),[ie,Ie]=b.useState("account"),[ze,wt]=b.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[ot,xt]=b.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[ht,Ze]=b.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[lt,Mt]=b.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Bt,Yt]=b.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[we,ue]=b.useState([]),[X,J]=b.useState([]),[de,ke]=b.useState(!1),[qe,Ct]=b.useState(""),[bt,me]=b.useState(""),[Ge,je]=b.useState([]),[Me,st]=b.useState([]),[Ve,gt]=b.useState("default"),[Qe,Ot]=b.useState(!1),[Lt,dr]=b.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[Qt,Wr]=b.useState(null),[H,Te]=b.useState(!1),[ct,ut]=b.useState(!1),[fe,tt]=b.useState(""),[ee,ye]=b.useState(null),[et,At]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),[Ft,nr]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),[Nr,Cn]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),Tn=async()=>{try{const W=await Ce("/api/cursor/mcp");if(W.ok){const pe=await W.json();je(pe.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(W){console.error("Error fetching Cursor MCP servers:",W)}},ur=async()=>{try{const W=await Ce("/api/codex/mcp/config/read");if(W.ok){const _e=await W.json();if(_e.success&&_e.servers){st(_e.servers);return}}const pe=await Ce("/api/codex/mcp/cli/list");if(pe.ok){const _e=await pe.json();if(_e.success&&_e.servers){const nt=_e.servers.map(mr=>({id:mr.name,name:mr.name,type:mr.type||"stdio",scope:"user",config:{command:mr.command||"",args:mr.args||[],env:mr.env||{}}}));st(nt)}}}catch(W){console.error("Error fetching Codex MCP servers:",W)}},Wt=async()=>{try{const W=await Ce("/api/mcp/cli/list");if(W.ok){const nt=await W.json();if(nt.success&&nt.servers){const mr=nt.servers.map(gr=>({id:gr.id||gr.name,name:gr.name,type:gr.type,scope:"user",status:gr.status,config:{command:gr.command||"",args:gr.args||[],env:gr.env||{},url:gr.url||"",headers:gr.headers||{},timeout:3e4},description:gr.description,created:new Date().toISOString(),updated:new Date().toISOString()}));z(mr);return}}const pe=await Ce("/api/mcp/config/read");if(pe.ok){const nt=await pe.json();if(nt.success&&nt.servers){z(nt.servers);return}}const _e=await Ce("/api/mcp/servers?scope=user");if(_e.ok){const nt=await _e.json();z(nt.servers||[])}else console.error("Failed to fetch MCP servers")}catch(W){console.error("Error fetching MCP servers:",W)}},cn=async W=>{try{M&&await ma(M.id,"user");const pe=await Ce("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:W.name,type:W.type,scope:W.scope,projectPath:W.projectPath,command:W.config?.command,args:W.config?.args||[],url:W.config?.url,headers:W.config?.headers||{},env:W.config?.env||{}})});if(pe.ok){const _e=await pe.json();if(_e.success)return await Wt(),!0;throw new Error(_e.error||"Failed to save server via Claude CLI")}else{const _e=await pe.json();throw new Error(_e.error||"Failed to save server")}}catch(pe){throw console.error("Error saving MCP server:",pe),pe}},ma=async(W,pe="user")=>{try{const _e=await Ce(`/api/mcp/cli/remove/${W}?scope=${pe}`,{method:"DELETE"});if(_e.ok){const nt=await _e.json();if(nt.success)return await Wt(),!0;throw new Error(nt.error||"Failed to delete server via Claude CLI")}else{const nt=await _e.json();throw new Error(nt.error||"Failed to delete server")}}catch(_e){throw console.error("Error deleting MCP server:",_e),_e}},Kn=async(W,pe="user")=>{try{const _e=await Ce(`/api/mcp/servers/${W}/test?scope=${pe}`,{method:"POST"});if(_e.ok)return(await _e.json()).testResult;{const nt=await _e.json();throw new Error(nt.error||"Failed to test server")}}catch(_e){throw console.error("Error testing MCP server:",_e),_e}},di=async(W,pe="user")=>{try{const _e=await Ce(`/api/mcp/servers/${W}/tools?scope=${pe}`,{method:"POST"});if(_e.ok)return(await _e.json()).toolsResult;{const nt=await _e.json();throw new Error(nt.error||"Failed to discover tools")}}catch(_e){throw console.error("Error discovering MCP tools:",_e),_e}},rn=async W=>{try{Qt&&await ja(Qt.id);const pe=await Ce("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:W.name,command:W.config?.command,args:W.config?.args||[],env:W.config?.env||{}})});if(pe.ok){const _e=await pe.json();if(_e.success)return await ur(),!0;throw new Error(_e.error||"Failed to save Codex MCP server")}else{const _e=await pe.json();throw new Error(_e.error||"Failed to save server")}}catch(pe){throw console.error("Error saving Codex MCP server:",pe),pe}},ja=async W=>{try{const pe=await Ce(`/api/codex/mcp/cli/remove/${W}`,{method:"DELETE"});if(pe.ok){const _e=await pe.json();if(_e.success)return await ur(),!0;throw new Error(_e.error||"Failed to delete Codex MCP server")}else{const _e=await pe.json();throw new Error(_e.error||"Failed to delete server")}}catch(pe){throw console.error("Error deleting Codex MCP server:",pe),pe}},Mr=()=>{dr({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),Wr(null),Ot(!1)},Xn=(W=null)=>{W?(Wr(W),dr({name:W.name,type:W.type||"stdio",config:{command:W.config?.command||"",args:W.config?.args||[],env:W.config?.env||{}}})):Mr(),Ot(!0)},Eo=async W=>{W.preventDefault(),Te(!0);try{Qt&&await ja(Qt.name),await rn(Lt),Mr(),v("success")}catch(pe){alert(`Error: ${pe.message}`),v("error")}finally{Te(!1)}},No=async W=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await ja(W),v("success")}catch(pe){alert(`Error: ${pe.message}`),v("error")}};b.useEffect(()=>{e&&(Fr(),pi(),mi(),Zn(),oe(n))},[e,n]),b.useEffect(()=>{localStorage.setItem("codeEditorTheme",ze),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ze]),b.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",ot.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ot]),b.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",ht.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ht]),b.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",lt.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[lt]),b.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Bt),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Bt]);const Fr=async()=>{try{const W=localStorage.getItem("claude-settings");if(W){const nt=JSON.parse(W);l(nt.allowedTools||[]),u(nt.disallowedTools||[]),x(nt.skipPermissions||!1),T(nt.projectSortOrder||"name"),I(nt.sidebarViewMode||"repo"),L(nt.sidebarTimeframe||"1w")}else l([]),u([]),x(!1),T("name"),I("repo"),L("1w");const pe=localStorage.getItem("cursor-tools-settings");if(pe){const nt=JSON.parse(pe);ue(nt.allowedCommands||[]),J(nt.disallowedCommands||[]),ke(nt.skipPermissions||!1)}else ue([]),J([]),ke(!1);const _e=localStorage.getItem("codex-settings");if(_e){const nt=JSON.parse(_e);gt(nt.permissionMode||"default")}else gt("default");await Wt(),await Tn(),await ur()}catch(W){console.error("Error loading tool settings:",W),l([]),u([]),x(!1),T("name")}},pi=async()=>{try{const W=await Ce("/api/cli/claude/status");if(W.ok){const pe=await W.json();At({authenticated:pe.authenticated,email:pe.email,loading:!1,error:pe.error||null})}else At({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(W){console.error("Error checking Claude auth status:",W),At({authenticated:!1,email:null,loading:!1,error:W.message})}},mi=async()=>{try{const W=await Ce("/api/cli/cursor/status");if(W.ok){const pe=await W.json();nr({authenticated:pe.authenticated,email:pe.email,loading:!1,error:pe.error||null})}else nr({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(W){console.error("Error checking Cursor auth status:",W),nr({authenticated:!1,email:null,loading:!1,error:W.message})}},Zn=async()=>{try{const W=await Ce("/api/cli/codex/status");if(W.ok){const pe=await W.json();Cn({authenticated:pe.authenticated,email:pe.email,loading:!1,error:pe.error||null})}else Cn({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(W){console.error("Error checking Codex auth status:",W),Cn({authenticated:!1,email:null,loading:!1,error:W.message})}},An=()=>{tt("claude"),ye(r?.[0]||{name:"default",fullPath:process.cwd()}),ut(!0)},In=()=>{tt("cursor"),ye(r?.[0]||{name:"default",fullPath:process.cwd()}),ut(!0)},Jn=()=>{tt("codex"),ye(r?.[0]||{name:"default",fullPath:process.cwd()}),ut(!0)},rs=W=>{W===0&&(v("success"),fe==="claude"?pi():fe==="cursor"?mi():fe==="codex"&&Zn())},Co=()=>{N(!0),v(null);try{const W={allowedTools:o,disallowedTools:c,skipPermissions:g,projectSortOrder:E,sidebarViewMode:S,sidebarTimeframe:D,lastUpdated:new Date().toISOString()},pe={allowedCommands:we,disallowedCommands:X,skipPermissions:de,lastUpdated:new Date().toISOString()},_e={permissionMode:Ve,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(W)),localStorage.setItem("cursor-tools-settings",JSON.stringify(pe)),localStorage.setItem("codex-settings",JSON.stringify(_e)),v("success"),setTimeout(()=>{t()},1e3)}catch(W){console.error("Error saving tool settings:",W),v("error")}finally{N(!1)}},un=()=>{ae({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),U(null),$(!1),le("")},_a=(W=null)=>{W?(U(W),ae({name:W.name,type:W.type,scope:W.scope,projectPath:W.projectPath||"",config:{...W.config},raw:W.raw,importMode:"form",jsonInput:""})):un(),$(!0)},hi=async W=>{W.preventDefault(),ne(!0);try{if(q.importMode==="json"){const pe=await Ce("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:q.name,jsonConfig:q.jsonInput,scope:q.scope,projectPath:q.projectPath})});if(pe.ok){const _e=await pe.json();if(_e.success)await Wt(),un(),v("success");else throw new Error(_e.error||"Failed to add server via JSON")}else{const _e=await pe.json();throw new Error(_e.error||"Failed to add server")}}else await cn(q),un(),v("success")}catch(pe){alert(`Error: ${pe.message}`),v("error")}finally{ne(!1)}},Rn=async(W,pe)=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await ma(W,pe),v("success")}catch(_e){alert(`Error: ${_e.message}`),v("error")}},pr=async(W,pe)=>{try{V({...C,[W]:{loading:!0}});const _e=await Kn(W,pe);V({...C,[W]:_e})}catch(_e){V({...C,[W]:{success:!1,message:_e.message,details:[]}})}},ns=async(W,pe)=>{try{he({...K,[W]:!0});const _e=await di(W,pe);R({...se,[W]:_e})}catch{R({...se,[W]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{he({...K,[W]:!1})}},ft=(W,pe)=>{ae(_e=>({..._e,config:{..._e.config,[W]:pe}}))};return e?a.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[a.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:[a.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Sa,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),a.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:"Settings"})]}),a.jsx(We,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:a.jsx(jt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[a.jsx("div",{className:"border-b border-border",children:a.jsxs("div",{className:"flex px-4 md:px-6",children:[a.jsx("button",{onClick:()=>oe("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Agents"}),a.jsx("button",{onClick:()=>oe("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Appearance"}),a.jsxs("button",{onClick:()=>oe("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[a.jsx(vn,{className:"w-4 h-4 inline mr-2"}),"Git"]}),a.jsxs("button",{onClick:()=>oe("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[a.jsx(dh,{className:"w-4 h-4 inline mr-2"}),"API & Tokens"]}),a.jsx("button",{onClick:()=>oe("tasks"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Tasks"})]})}),a.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[xe==="appearance"&&a.jsx("div",{className:"space-y-6 md:space-y-8",children:xe==="appearance"&&a.jsxs("div",{className:"space-y-6 md:space-y-8",children:[a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Dark Mode"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Toggle between light and dark themes"})]}),a.jsxs("button",{onClick:s,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":i,"aria-label":"Toggle dark mode",children:[a.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),a.jsx("span",{className:`${i?"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:i?a.jsx(gm,{className:"w-3.5 h-3.5 text-gray-700"}):a.jsx(fm,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Project Sorting"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"How projects are ordered in the sidebar"})]}),a.jsxs("select",{value:E,onChange:W=>T(W.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:[a.jsx("option",{value:"name",children:"Alphabetical"}),a.jsx("option",{value:"date",children:"Recent Activity"})]})]})})}),a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Sessions View"}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Default View Mode"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"How sessions are displayed in the sidebar"})]}),a.jsxs("select",{value:S,onChange:W=>I(W.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:[a.jsx("option",{value:"repo",children:"Repo View"}),a.jsx("option",{value:"session",children:"Session View"})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Default Timeframe"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Default time filter for session view"})]}),a.jsxs("select",{value:D,onChange:W=>L(W.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:[a.jsx("option",{value:"1h",children:"1 hour"}),a.jsx("option",{value:"8h",children:"8 hours"}),a.jsx("option",{value:"1d",children:"1 day"}),a.jsx("option",{value:"1w",children:"1 week"}),a.jsx("option",{value:"2w",children:"2 weeks"}),a.jsx("option",{value:"1m",children:"1 month"}),a.jsx("option",{value:"all",children:"All time"})]})]})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Code Editor"}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Editor Theme"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Default theme for the code editor"})]}),a.jsxs("button",{onClick:()=>wt(ze==="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":ze==="dark","aria-label":"Toggle editor theme",children:[a.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),a.jsx("span",{className:`${ze==="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:ze==="dark"?a.jsx(gm,{className:"w-3.5 h-3.5 text-gray-700"}):a.jsx(fm,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Word Wrap"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Enable word wrapping by default in the editor"})]}),a.jsxs("button",{onClick:()=>xt(!ot),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":ot,"aria-label":"Toggle word wrap",children:[a.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),a.jsx("span",{className:`${ot?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Show Minimap"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Display a minimap for easier navigation in diff view"})]}),a.jsxs("button",{onClick:()=>Ze(!ht),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":ht,"aria-label":"Toggle minimap",children:[a.jsx("span",{className:"sr-only",children:"Toggle minimap"}),a.jsx("span",{className:`${ht?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Show Line Numbers"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Display line numbers in the editor"})]}),a.jsxs("button",{onClick:()=>Mt(!lt),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":lt,"aria-label":"Toggle line numbers",children:[a.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),a.jsx("span",{className:`${lt?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Font Size"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Editor font size in pixels"})]}),a.jsxs("select",{value:Bt,onChange:W=>Yt(W.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:[a.jsx("option",{value:"10",children:"10px"}),a.jsx("option",{value:"11",children:"11px"}),a.jsx("option",{value:"12",children:"12px"}),a.jsx("option",{value:"13",children:"13px"}),a.jsx("option",{value:"14",children:"14px"}),a.jsx("option",{value:"15",children:"15px"}),a.jsx("option",{value:"16",children:"16px"}),a.jsx("option",{value:"18",children:"18px"}),a.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),xe==="git"&&a.jsx(cq,{}),xe==="agents"&&a.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[a.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"flex",children:[a.jsx(Ba,{agentId:"claude",authStatus:et,isSelected:ge==="claude",onClick:()=>Ae("claude"),isMobile:!0}),a.jsx(Ba,{agentId:"cursor",authStatus:Ft,isSelected:ge==="cursor",onClick:()=>Ae("cursor"),isMobile:!0}),a.jsx(Ba,{agentId:"codex",authStatus:Nr,isSelected:ge==="codex",onClick:()=>Ae("codex"),isMobile:!0})]})}),a.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"p-2",children:[a.jsx(Ba,{agentId:"claude",authStatus:et,isSelected:ge==="claude",onClick:()=>Ae("claude")}),a.jsx(Ba,{agentId:"cursor",authStatus:Ft,isSelected:ge==="cursor",onClick:()=>Ae("cursor")}),a.jsx(Ba,{agentId:"codex",authStatus:Nr,isSelected:ge==="codex",onClick:()=>Ae("codex")})]})}),a.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[a.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[a.jsx("button",{onClick:()=>Ie("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 ${ie==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Account"}),a.jsx("button",{onClick:()=>Ie("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 ${ie==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Permissions"}),a.jsx("button",{onClick:()=>Ie("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 ${ie==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"MCP Servers"})]})}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[ie==="account"&&a.jsx(hq,{agent:ge,authStatus:ge==="claude"?et:ge==="cursor"?Ft:Nr,onLogin:ge==="claude"?An:ge==="cursor"?In:Jn}),ie==="permissions"&&ge==="claude"&&a.jsx(dm,{agent:"claude",skipPermissions:g,setSkipPermissions:x,allowedTools:o,setAllowedTools:l,disallowedTools:c,setDisallowedTools:u,newAllowedTool:d,setNewAllowedTool:p,newDisallowedTool:m,setNewDisallowedTool:h}),ie==="permissions"&&ge==="cursor"&&a.jsx(dm,{agent:"cursor",skipPermissions:de,setSkipPermissions:ke,allowedCommands:we,setAllowedCommands:ue,disallowedCommands:X,setDisallowedCommands:J,newAllowedCommand:qe,setNewAllowedCommand:Ct,newDisallowedCommand:bt,setNewDisallowedCommand:me}),ie==="permissions"&&ge==="codex"&&a.jsx(dm,{agent:"codex",permissionMode:Ve,setPermissionMode:gt}),ie==="mcp"&&ge==="claude"&&a.jsx(pm,{agent:"claude",servers:_,onAdd:()=>_a(),onEdit:W=>_a(W),onDelete:(W,pe)=>Rn(W,pe),onTest:(W,pe)=>pr(W,pe),onDiscoverTools:(W,pe)=>ns(W,pe),testResults:C,serverTools:se,toolsLoading:K}),ie==="mcp"&&ge==="cursor"&&a.jsx(pm,{agent:"cursor",servers:Ge,onAdd:()=>{},onEdit:W=>{},onDelete:W=>{}}),ie==="mcp"&&ge==="codex"&&a.jsx(pm,{agent:"codex",servers:Me,onAdd:()=>Xn(),onEdit:W=>Xn(W),onDelete:W=>No(W)})]})]})]}),F&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:a.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[a.jsx("h3",{className:"text-lg font-medium text-foreground",children:M?"Edit MCP Server":"Add MCP Server"}),a.jsx(We,{variant:"ghost",size:"sm",onClick:un,children:a.jsx(jt,{className:"w-4 h-4"})})]}),a.jsxs("form",{onSubmit:hi,className:"p-4 space-y-4",children:[!M&&a.jsxs("div",{className:"flex gap-2 mb-4",children:[a.jsx("button",{type:"button",onClick:()=>ae(W=>({...W,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${q.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:"Form Input"}),a.jsx("button",{type:"button",onClick:()=>ae(W=>({...W,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${q.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:"JSON Import"})]}),q.importMode==="form"&&M&&a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Scope"}),a.jsxs("div",{className:"flex items-center gap-2",children:[q.scope==="user"?a.jsx(hm,{className:"w-4 h-4"}):a.jsx(yn,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:q.scope==="user"?"User (Global)":"Project (Local)"}),q.scope==="local"&&q.projectPath&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",q.projectPath]})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Scope cannot be changed when editing an existing server"})]}),q.importMode==="form"&&!M&&a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Scope *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{type:"button",onClick:()=>ae(W=>({...W,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${q.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:a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(hm,{className:"w-4 h-4"}),a.jsx("span",{children:"User (Global)"})]})}),a.jsx("button",{type:"button",onClick:()=>ae(W=>({...W,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${q.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:a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(yn,{className:"w-4 h-4"}),a.jsx("span",{children:"Project (Local)"})]})})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:q.scope==="user"?"User scope: Available across all projects on your machine":"Local scope: Only available in the selected project"})]}),q.scope==="local"&&!M&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Project *"}),a.jsxs("select",{value:q.projectPath,onChange:W=>ae(pe=>({...pe,projectPath:W.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:q.scope==="local",children:[a.jsx("option",{value:"",children:"Select a project..."}),r.map(W=>a.jsx("option",{value:W.path||W.fullPath,children:W.displayName||W.name},W.name))]}),q.projectPath&&a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Path: ",q.projectPath]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:q.importMode==="json"?"md:col-span-2":"",children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Server Name *"}),a.jsx(tr,{value:q.name,onChange:W=>{ae(pe=>({...pe,name:W.target.value}))},placeholder:"my-server",required:!0})]}),q.importMode==="form"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Transport Type *"}),a.jsxs("select",{value:q.type,onChange:W=>{ae(pe=>({...pe,type:W.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:[a.jsx("option",{value:"stdio",children:"stdio"}),a.jsx("option",{value:"sse",children:"SSE"}),a.jsx("option",{value:"http",children:"HTTP"})]})]})]}),M&&q.raw&&q.importMode==="form"&&a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[a.jsxs("h4",{className:"text-sm font-medium text-foreground mb-2",children:["Configuration Details (from"," ",M.scope==="global"?"~/.claude.json":"project config",")"]}),a.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(q.raw,null,2)})]}),q.importMode==="json"&&a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"JSON Configuration *"}),a.jsx("textarea",{value:q.jsonInput,onChange:W=>{ae(pe=>({...pe,jsonInput:W.target.value}));try{if(W.target.value.trim()){const pe=JSON.parse(W.target.value);pe.type?pe.type==="stdio"&&!pe.command?le("stdio type requires a command field"):(pe.type==="http"||pe.type==="sse")&&!pe.url?le(`${pe.type} type requires a url field`):le(""):le("Missing required field: type")}}catch{W.target.value.trim()?le("Invalid JSON format"):le("")}},className:`w-full px-3 py-2 border ${De?"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:`{
1214
+ `).length]}),a.jsxs("span",{children:["Characters: ",l.length]}),a.jsxs("span",{children:["Words: ",l.split(/\s+/).filter(R=>R.length>0).length]}),a.jsx("span",{children:"Format: Markdown"})]}),a.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),L&&a.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:a.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:[a.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:a.jsx(Fn,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),a.jsx("button",{onClick:()=>_(!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:a.jsx(jt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 space-y-4",children:[a.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.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:a.jsx(Fn,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Claude Code Directly!"}),a.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask Claude Code 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."}),a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[a.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),a.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/`,I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),a.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[a.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),a.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),a.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 →"})]}),a.jsx("div",{className:"pt-4",children:a.jsx("button",{onClick:()=>_(!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 Claude Code directly"})})]})]})}),z&&a.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>F(!1)}),a.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:a.jsxs("div",{className:"p-6",children:[a.jsxs("div",{className:"flex items-center mb-4",children:[a.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:a.jsx(kn,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),a.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),a.jsxs("div",{className:"flex justify-end space-x-3",children:[a.jsx("button",{onClick:()=>F(!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"}),a.jsxs("button",{onClick:async()=>{F(!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:[a.jsx(Oi,{className:"w-4 h-4"}),a.jsx("span",{children:"Overwrite"})]})]})]})})]})]})};function nq({selectedProject:e,selectedSession:t,activeTab:r,setActiveTab:n,ws:i,sendMessage:s,messages:o,isMobile:l,isPWA:c,onMenuClick:u,isLoading:d,isProjectSwitching:p,onProjectReady:m,onInputFocusChange:h,onSessionActive:g,onSessionInactive:x,onSessionProcessing:w,onSessionNotProcessing:N,processingSessions:k,onReplaceTemporarySession:v,onNavigateToSession:E,onShowSettings:T,autoExpandTools:S,showRawParameters:I,showThinking:D,autoScrollToBottom:L,sendByCtrlEnter:_,externalMessageUpdate:z}){const[F,$]=b.useState(null),[M,U]=b.useState(null),[q,ae]=b.useState(!1),[re,ne]=b.useState(600),[C,V]=b.useState(!1),[se,R]=b.useState(!1),K=b.useRef(null),[he,xe]=b.useState(!1),[oe,De]=b.useState(null),[le,ge]=b.useState([]),[Ae,ie]=b.useState(null),{tasks:Ie,currentProject:ze,refreshTasks:wt,setCurrentProject:ot}=Wi(),{tasksEnabled:xt,isTaskMasterInstalled:ht,isTaskMasterReady:Ze}=Vi(),lt=xt&&ht;b.useEffect(()=>{e&&e!==ze&&ot(e)},[e,ze,ot]),b.useEffect(()=>{!lt&&r==="tasks"&&n("chat")},[lt,r,n]),b.useEffect(()=>{(async()=>{if(!ze?.name){ge([]);return}try{const ke=await mt.get(`/taskmaster/prd/${encodeURIComponent(ze.name)}`);if(ke.ok){const qe=await ke.json();ge(qe.prdFiles||[])}else ge([])}catch(ke){console.error("Failed to load existing PRDs:",ke),ge([])}})()},[ze?.name]);const Mt=(de,ke=null)=>{const qe={name:de.split("/").pop(),path:de,projectName:e?.name,diffInfo:ke};$(qe)},Bt=()=>{$(null),R(!1)},Yt=()=>{R(!se)},we=de=>{if(typeof de=="object"&&de.id&&!de.title){const ke=Ie?.find(qe=>qe.id===de.id);ke&&(U(ke),ae(!0))}else U(de),ae(!0)},ue=()=>{ae(!1),U(null)},X=(de,ke)=>{console.log("Update task status:",de,ke),wt?.()},J=de=>{l||(V(!0),de.preventDefault())};return b.useEffect(()=>{const de=qe=>{if(!C)return;const Ct=K.current?.parentElement;if(!Ct)return;const bt=Ct.getBoundingClientRect(),me=bt.right-qe.clientX,Ge=300,je=bt.width*.8;me>=Ge&&me<=je&&ne(me)},ke=()=>{V(!1)};return C&&(document.addEventListener("mousemove",de),document.addEventListener("mouseup",ke),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",ke),document.body.style.cursor="",document.body.style.userSelect=""}},[C]),b.useEffect(()=>{if(p&&e&&m){const de=setTimeout(()=>{m()},150);return()=>clearTimeout(de)}},[p,e,m]),d||p?a.jsxs("div",{className:"h-full flex flex-col",children:[l&&a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsx("button",{onClick:u,className:"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-700 pwa-menu-button",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[a.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:a.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-blue-500",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),a.jsx("h2",{className:"text-xl font-semibold mb-2",children:p?"Switching Project":"Loading Claude Code UI"}),a.jsx("p",{children:p?`Loading ${e?.displayName||"project"}...`:"Setting up your workspace..."})]})})]}):e?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsxs("div",{className:"flex items-center justify-between relative",children:[a.jsxs("div",{className:"flex items-center space-x-2 min-w-0 flex-1",children:[l&&a.jsx("button",{onClick:u,onTouchStart:de=>{de.preventDefault(),u()},className:"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-700 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),a.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[r==="chat"&&t&&a.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:t.__provider==="cursor"?a.jsx(Kr,{className:"w-4 h-4"}):a.jsx($r,{className:"w-4 h-4"})}),a.jsx("div",{className:"min-w-0 flex-1",children:r==="chat"&&t?a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white whitespace-nowrap overflow-x-auto scrollbar-hide",children:t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):r==="chat"&&!t?a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:"New Session"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:r==="files"?"Project Files":r==="git"?"Source Control":r==="tasks"&&lt?"TaskMaster":"Project"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),a.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:a.jsxs("div",{className:"relative flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[a.jsx(Ir,{content:"Chat",position:"bottom",children:a.jsx("button",{onClick:()=>n("chat"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md ${r==="chat"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Chat"})]})})}),a.jsx(Ir,{content:"Shell",position:"bottom",children:a.jsx("button",{onClick:()=>n("shell"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="shell"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Shell"})]})})}),a.jsx(Ir,{content:"Files",position:"bottom",children:a.jsx("button",{onClick:()=>n("files"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="files"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Files"})]})})}),a.jsx(Ir,{content:"Source Control",position:"bottom",children:a.jsx("button",{onClick:()=>n("git"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="git"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Source Control"})]})})}),lt&&a.jsx(Ir,{content:"Tasks",position:"bottom",children:a.jsx("button",{onClick:()=>n("tasks"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="tasks"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Tasks"})]})})})]})})]})}),a.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[a.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${F?"mr-0":""} ${se?"hidden":""}`,children:[a.jsx("div",{className:`h-full ${r==="chat"?"block":"hidden"}`,children:a.jsx(Q$,{showDetails:!0,children:a.jsx(o$,{selectedProject:e,selectedSession:t,ws:i,sendMessage:s,messages:o,onFileOpen:Mt,onInputFocusChange:h,onSessionActive:g,onSessionInactive:x,onSessionProcessing:w,onSessionNotProcessing:N,processingSessions:k,onReplaceTemporarySession:v,onNavigateToSession:E,onShowSettings:T,autoExpandTools:S,showRawParameters:I,showThinking:D,autoScrollToBottom:L,sendByCtrlEnter:_,externalMessageUpdate:z,onShowAllTasks:xt?()=>n("tasks"):null})})}),r==="files"&&a.jsx("div",{className:"h-full overflow-hidden",children:a.jsx(Z$,{selectedProject:e})}),r==="shell"&&a.jsx("div",{className:"h-full w-full overflow-hidden",children:a.jsx(sN,{project:e,session:t,showHeader:!1})}),r==="git"&&a.jsx("div",{className:"h-full overflow-hidden",children:a.jsx(J$,{selectedProject:e,isMobile:l,onFileOpen:Mt})}),lt&&a.jsx("div",{className:`h-full ${r==="tasks"?"block":"hidden"}`,children:a.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:a.jsx(tq,{tasks:Ie||[],onTaskClick:we,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:ze,onTaskCreated:wt,onShowPRDEditor:(de=null)=>{De(de),xe(!0)},existingPRDs:le,onRefreshPRDs:(de=!1)=>{ze?.name&&mt.get(`/taskmaster/prd/${encodeURIComponent(ze.name)}`).then(ke=>ke.ok?ke.json():Promise.reject()).then(ke=>{ge(ke.prdFiles||[]),de&&(ie("PRD saved successfully!"),setTimeout(()=>ie(null),3e3))}).catch(ke=>console.error("Failed to refresh PRDs:",ke))}})})}),a.jsx("div",{className:`h-full overflow-hidden ${r==="preview"?"block":"hidden"}`})]}),F&&!l&&a.jsxs(a.Fragment,{children:[!se&&a.jsx("div",{ref:K,onMouseDown:J,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:a.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),a.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${se?"flex-1":""}`,style:se?{}:{width:`${re}px`},children:a.jsx(ah,{file:F,onClose:Bt,projectPath:e?.path,isSidebar:!0,isExpanded:se,onToggleExpand:Yt})})]})]}),F&&l&&a.jsx(ah,{file:F,onClose:Bt,projectPath:e?.path,isSidebar:!1}),lt&&q&&M&&a.jsx(IE,{task:M,isOpen:q,onClose:ue,onStatusChange:X,onTaskClick:we}),he&&a.jsx(rq,{project:ze,projectPath:ze?.fullPath||ze?.path,onClose:()=>{xe(!1),De(null)},isNewFile:!oe?.isExisting,file:{name:oe?.name||"prd.txt",content:oe?.content||""},onSave:async()=>{xe(!1),De(null);try{const de=await mt.get(`/taskmaster/prd/${encodeURIComponent(ze.name)}`);if(de.ok){const ke=await de.json();ge(ke.prdFiles||[]),ie("PRD saved successfully!"),setTimeout(()=>ie(null),3e3)}}catch(de){console.error("Failed to refresh PRDs:",de)}wt?.()}}),Ae&&a.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:a.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),a.jsx("span",{className:"font-medium",children:Ae})]})})]}):a.jsxs("div",{className:"h-full flex flex-col",children:[l&&a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsx("button",{onClick:u,className:"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-700 pwa-menu-button",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 max-w-md mx-auto px-6",children:[a.jsx("div",{className:"w-16 h-16 mx-auto mb-6 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:a.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),a.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:"Choose Your Project"}),a.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:"Select a project from the sidebar to start coding with Claude. Each project contains your chat sessions and file history."}),a.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:a.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:["💡 ",a.jsx("strong",{children:"Tip:"})," ",l?"Tap the menu button above to access projects":"Create a new project by clicking the folder icon in the sidebar"]})})]})})]})}const aq=Pt.memo(nq);function iq({activeTab:e,setActiveTab:t,isInputFocused:r}){const{tasksEnabled:n}=Vi(),i=[{id:"chat",icon:zn,onClick:()=>t("chat")},{id:"shell",icon:Jr,onClick:()=>t("shell")},{id:"files",icon:Mn,onClick:()=>t("files")},{id:"git",icon:vn,onClick:()=>t("git")},...n?[{id:"tasks",icon:G5,onClick:()=>t("tasks")}]:[]];return a.jsx("div",{className:`fixed bottom-0 left-0 right-0 bg-background border-t border-border z-50 ios-bottom-safe transform transition-transform duration-300 ease-in-out shadow-lg ${r?"translate-y-full":"translate-y-0"}`,children:a.jsx("div",{className:"flex items-center justify-around py-1",children:i.map(s=>{const o=s.icon,l=e===s.id;return a.jsxs("button",{onClick:s.onClick,onTouchStart:c=>{c.preventDefault(),s.onClick()},className:`flex items-center justify-center p-2 rounded-lg min-h-[40px] min-w-[40px] relative touch-manipulation ${l?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,"aria-label":s.id,children:[a.jsx(o,{className:"w-5 h-5"}),l&&a.jsx("div",{className:"absolute top-0 left-1/2 transform -translate-x-1/2 w-6 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-full"})]},s.id)})})})}const ih="1.2.1",sq="@epiphytic/claudecodeui",oN=(e=null)=>{const[t,r]=b.useState(!1),[n,i]=b.useState(null),[s,o]=b.useState(null),l=e||void 0||sq;return b.useEffect(()=>{const c=async()=>{try{const d=encodeURIComponent(l),p=await fetch(`https://registry.npmjs.org/${d}/latest`);if(!p.ok){console.warn(`Version check: Package ${l} not found on npm`),r(!1),i(null),o(null);return}const m=await p.json();if(m.version){const h=m.version;i(h),r(oq(h,ih)),o({name:m.name,description:m.description||"",homepage:m.homepage||`https://www.npmjs.com/package/${l}`,repository:m.repository?.url||null})}else r(!1),i(null),o(null)}catch(d){console.error("Version check failed:",d),r(!1),i(null),o(null)}};c();const u=setInterval(c,300*1e3);return()=>clearInterval(u)},[l]),{updateAvailable:t,latestVersion:n,currentVersion:ih,packageInfo:s}};function oq(e,t){const r=e.split(".").map(s=>parseInt(s,10)||0),n=t.split(".").map(s=>parseInt(s,10)||0),i=Math.max(r.length,n.length);for(;r.length<i;)r.push(0);for(;n.length<i;)n.push(0);for(let s=0;s<i;s++){if(r[s]>n[s])return!0;if(r[s]<n[s])return!1}return!1}function lq(){const[e,t]=b.useState([]),[r,n]=b.useState([]),[i,s]=b.useState(!0),[o,l]=b.useState(!1),[c,u]=b.useState(!1),[d,p]=b.useState(""),[m,h]=b.useState(""),[g,x]=b.useState(""),[w,N]=b.useState(""),[k,v]=b.useState({}),[E,T]=b.useState(null),[S,I]=b.useState(null),{updateAvailable:D,latestVersion:L,packageInfo:_}=oN();b.useEffect(()=>{z()},[]);const z=async()=>{try{s(!0);const C=await(await Ce("/api/settings/api-keys")).json();t(C.apiKeys||[]);const se=await(await Ce("/api/settings/credentials?type=github_token")).json();n(se.credentials||[])}catch(ne){console.error("Error fetching settings:",ne)}finally{s(!1)}},F=async()=>{if(d.trim())try{const C=await(await Ce("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:d})})).json();C.success&&(I(C.apiKey),p(""),l(!1),z())}catch(ne){console.error("Error creating API key:",ne)}},$=async ne=>{if(confirm("Are you sure you want to delete this API key?"))try{await Ce(`/api/settings/api-keys/${ne}`,{method:"DELETE"}),z()}catch(C){console.error("Error deleting API key:",C)}},M=async(ne,C)=>{try{await Ce(`/api/settings/api-keys/${ne}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!C})}),z()}catch(V){console.error("Error toggling API key:",V)}},U=async()=>{if(!(!m.trim()||!g.trim()))try{(await(await Ce("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:m,credentialType:"github_token",credentialValue:g,description:w})})).json()).success&&(h(""),x(""),N(""),u(!1),z())}catch(ne){console.error("Error creating GitHub credential:",ne)}},q=async ne=>{if(confirm("Are you sure you want to delete this GitHub token?"))try{await Ce(`/api/settings/credentials/${ne}`,{method:"DELETE"}),z()}catch(C){console.error("Error deleting GitHub credential:",C)}},ae=async(ne,C)=>{try{await Ce(`/api/settings/credentials/${ne}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!C})}),z()}catch(V){console.error("Error toggling GitHub credential:",V)}},re=(ne,C)=>{navigator.clipboard.writeText(ne),T(C),setTimeout(()=>T(null),2e3)};return i?a.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):a.jsxs("div",{className:"space-y-8",children:[S&&a.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[a.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:"⚠️ Save Your API Key"}),a.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"This is the only time you'll see this key. Store it securely."}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:S.apiKey}),a.jsx(We,{size:"sm",variant:"outline",onClick:()=>re(S.apiKey,"new"),children:E==="new"?a.jsx(vr,{className:"h-4 w-4"}):a.jsx(y2,{className:"h-4 w-4"})})]}),a.jsx(We,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>I(null),children:"I've saved it"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(dh,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"API Keys"})]}),a.jsxs(We,{size:"sm",onClick:()=>l(!o),children:[a.jsx(hr,{className:"h-4 w-4 mr-1"}),"New API Key"]})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Generate API keys to access the external API from other applications."}),a.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:["API Documentation",a.jsx(Dg,{className:"h-3 w-3"})]})]}),o&&a.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[a.jsx(tr,{placeholder:"API Key Name (e.g., Production Server)",value:d,onChange:ne=>p(ne.target.value),className:"mb-2"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(We,{onClick:F,children:"Create"}),a.jsx(We,{variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]}),a.jsx("div",{className:"space-y-2",children:e.length===0?a.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No API keys created yet."}):e.map(ne=>a.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium",children:ne.key_name}),a.jsx("code",{className:"text-xs text-muted-foreground",children:ne.api_key}),a.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Created: ",new Date(ne.created_at).toLocaleDateString(),ne.last_used&&` • Last used: ${new Date(ne.last_used).toLocaleDateString()}`]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{size:"sm",variant:ne.is_active?"outline":"secondary",onClick:()=>M(ne.id,ne.is_active),children:ne.is_active?"Active":"Inactive"}),a.jsx(We,{size:"sm",variant:"ghost",onClick:()=>$(ne.id),children:a.jsx(_r,{className:"h-4 w-4"})})]})]},ne.id))})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(n5,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"GitHub Credentials"})]}),a.jsxs(We,{size:"sm",onClick:()=>u(!c),children:[a.jsx(hr,{className:"h-4 w-4 mr-1"}),"Add Token"]})]}),a.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add GitHub Personal Access Tokens to clone private repositories. You can also pass tokens directly in API requests without storing them."}),c&&a.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[a.jsx(tr,{placeholder:"Token Name (e.g., Personal Repos)",value:m,onChange:ne=>h(ne.target.value)}),a.jsxs("div",{className:"relative",children:[a.jsx(tr,{type:k.new?"text":"password",placeholder:"GitHub Personal Access Token (ghp_...)",value:g,onChange:ne=>x(ne.target.value),className:"pr-10"}),a.jsx("button",{type:"button",onClick:()=>v({...k,new:!k.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:k.new?a.jsx(v2,{className:"h-4 w-4"}):a.jsx(ni,{className:"h-4 w-4"})})]}),a.jsx(tr,{placeholder:"Description (optional)",value:w,onChange:ne=>N(ne.target.value)}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(We,{onClick:U,children:"Add Token"}),a.jsx(We,{variant:"outline",onClick:()=>{u(!1),h(""),x(""),N("")},children:"Cancel"})]}),a.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:"How to create a GitHub Personal Access Token →"})]}),a.jsx("div",{className:"space-y-2",children:r.length===0?a.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No GitHub tokens added yet."}):r.map(ne=>a.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium",children:ne.credential_name}),ne.description&&a.jsx("div",{className:"text-xs text-muted-foreground",children:ne.description}),a.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Added:"," ",new Date(ne.created_at).toLocaleDateString()]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{size:"sm",variant:ne.is_active?"outline":"secondary",onClick:()=>ae(ne.id,ne.is_active),children:ne.is_active?"Active":"Inactive"}),a.jsx(We,{size:"sm",variant:"ghost",onClick:()=>q(ne.id),children:a.jsx(_r,{className:"h-4 w-4"})})]})]},ne.id))})]}),a.jsx("div",{className:"pt-6 border-t border-border/50",children:a.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[a.jsxs("a",{href:_?.homepage||"https://www.npmjs.com/package/@epiphytic/claudecodeui",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",ih]}),D&&L&&a.jsxs("a",{href:_?.homepage||"https://www.npmjs.com/package/@epiphytic/claudecodeui",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:[a.jsxs("span",{className:"text-[10px]",children:["Update available: v",L]}),a.jsx(Dg,{className:"h-2.5 w-2.5"})]})]})})]})}function cq(){const[e,t]=b.useState(""),[r,n]=b.useState(""),[i,s]=b.useState(!1),[o,l]=b.useState(!1),[c,u]=b.useState(null);b.useEffect(()=>{d()},[]);const d=async()=>{try{s(!0);const m=await Ce("/api/user/git-config");if(m.ok){const h=await m.json();t(h.gitName||""),n(h.gitEmail||"")}}catch(m){console.error("Error loading git config:",m)}finally{s(!1)}},p=async()=>{try{l(!0);const m=await Ce("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:e,gitEmail:r})});if(m.ok)u("success"),setTimeout(()=>u(null),3e3);else{const h=await m.json();u("error"),console.error("Failed to save git config:",h.error)}}catch(m){console.error("Error saving git config:",m),u("error")}finally{l(!1)}};return a.jsx("div",{className:"space-y-8",children:a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(vn,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"Git Configuration"})]}),a.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Configure your git identity for commits. These settings will be applied globally via ",a.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs",children:"git config --global"})]}),a.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:"Git Name"}),a.jsx(tr,{id:"settings-git-name",type:"text",value:e,onChange:m=>t(m.target.value),placeholder:"John Doe",disabled:i,className:"w-full"}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Your name for git commits"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:"Git Email"}),a.jsx(tr,{id:"settings-git-email",type:"email",value:r,onChange:m=>n(m.target.value),placeholder:"john@example.com",disabled:i,className:"w-full"}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Your email for git commits"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{onClick:p,disabled:o||!e||!r,children:o?"Saving...":"Save Configuration"}),c==="success"&&a.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[a.jsx(vr,{className:"w-4 h-4"}),"Saved successfully"]})]})]})]})})}function uq(){const{tasksEnabled:e,setTasksEnabled:t,isTaskMasterInstalled:r,isCheckingInstallation:n}=Vi();return a.jsx("div",{className:"space-y-8",children:n?a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:"Checking TaskMaster installation..."})]})}):a.jsxs(a.Fragment,{children:[!r&&a.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.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:a.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:"TaskMaster AI CLI Not Installed"}),a.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[a.jsx("p",{children:"TaskMaster CLI is required to use task management features. Install it to get started:"}),a.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:a.jsx("code",{children:"npm install -g task-master-ai"})}),a.jsx("div",{children:a.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:[a.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:a.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"})}),"View on GitHub",a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})})]})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"font-medium",children:"After installation:"}),a.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[a.jsx("li",{children:"Restart this application"}),a.jsx("li",{children:"TaskMaster features will automatically become available"}),a.jsxs("li",{children:["Use ",a.jsx("code",{className:"bg-orange-100 dark:bg-orange-800 px-1 rounded",children:"task-master init"})," in your project directory"]})]})]})]})]})]})}),r&&a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Enable TaskMaster Integration"}),a.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:"Show TaskMaster tasks, banners, and sidebar indicators across the interface"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:i=>t(i.target.checked),className:"sr-only peer"}),a.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"})]})]})})})]})})}function lN({isOpen:e,onClose:t,provider:r="claude",project:n,onComplete:i,customCommand:s}){if(!e)return null;const o=()=>{if(s)return s;const u=!1;switch(r){case"claude":return"claude setup-token --dangerously-skip-permissions";case"cursor":return"cursor-agent login";case"codex":return u?"codex login --device-auth":"codex login";default:return"claude setup-token --dangerously-skip-permissions"}},l=()=>{switch(r){case"claude":return"Claude CLI Login";case"cursor":return"Cursor CLI Login";case"codex":return"Codex CLI Login";default:return"CLI Login"}},c=u=>{i&&i(u),u===0&&t()};return a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:l()}),a.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:a.jsx(jt,{className:"w-6 h-6"})})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(sN,{project:n,command:o(),onComplete:c,minimal:!0})})]})})}const dq={claude:{name:"Claude",color:"blue",Logo:$r},cursor:{name:"Cursor",color:"purple",Logo:Kr},codex:{name:"Codex",color:"gray",Logo:on}},pq={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 Ba({agentId:e,authStatus:t,isSelected:r,onClick:n,isMobile:i=!1}){const s=dq[e],o=pq[s.color],{Logo:l}=s;return i?a.jsx("button",{onClick:n,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${r?`${o.borderBottom} ${o.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsx(l,{className:"w-5 h-5"}),a.jsx("span",{className:"text-xs font-medium text-foreground",children:s.name}),t?.authenticated&&a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o.dot}`})]})}):a.jsxs("button",{onClick:n,className:`w-full text-left p-3 border-l-4 transition-colors ${r?`${o.border} ${o.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(l,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:s.name})]}),a.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:t?.loading?a.jsx("span",{className:"text-gray-400",children:"Checking..."}):t?.authenticated?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o.dot}`}),a.jsx("span",{className:"truncate max-w-[120px]",title:t.email,children:t.email||"Connected"})]}):a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),a.jsx("span",{children:"Not connected"})]})})]})}const mq={claude:{name:"Claude",description:"Anthropic Claude AI assistant",Logo:$r,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",Logo:Kr,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",Logo:on,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 hq({agent:e,authStatus:t,onLogin:r}){const n=mq[e],{Logo:i}=n;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx(i,{className:"w-6 h-6"}),a.jsxs("div",{children:[a.jsxs("h3",{className:"text-lg font-medium text-foreground",children:[n.name," Account"]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:n.description})]})]}),a.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:`font-medium ${n.textClass}`,children:"Connection Status"}),a.jsx("div",{className:`text-sm ${n.subtextClass}`,children:t?.loading?"Checking authentication status...":t?.authenticated?`Logged in as ${t.email||"authenticated user"}`:"Not connected"})]}),a.jsx("div",{children:t?.loading?a.jsx(Zr,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:"Checking..."}):t?.authenticated?a.jsx(Zr,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:"Connected"}):a.jsx(Zr,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:"Disconnected"})})]}),a.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:`font-medium ${n.textClass}`,children:t?.authenticated?"Re-authenticate":"Login"}),a.jsx("div",{className:`text-sm ${n.subtextClass}`,children:t?.authenticated?"Sign in with a different account or refresh credentials":`Sign in to your ${n.name} account to enable AI features`})]}),a.jsxs(We,{onClick:r,className:`${n.buttonClass} text-white`,size:"sm",children:[a.jsx(w2,{className:"w-4 h-4 mr-2"}),t?.authenticated?"Re-login":"Login"]})]})}),t?.error&&a.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:a.jsxs("div",{className:"text-sm text-red-600 dark:text-red-400",children:["Error: ",t.error]})})]})})]})}const gq=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],fq=["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 bq({skipPermissions:e,setSkipPermissions:t,allowedTools:r,setAllowedTools:n,disallowedTools:i,setDisallowedTools:s,newAllowedTool:o,setNewAllowedTool:l,newDisallowedTool:c,setNewDisallowedTool:u}){const d=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},p=g=>{n(r.filter(x=>x!==g))},m=g=>{g&&!i.includes(g)&&(s([...i,g]),u(""))},h=g=>{s(i.filter(x=>x!==g))};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(kn,{className:"w-5 h-5 text-orange-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Settings"})]}),a.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("label",{className:"flex items-center gap-3",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:g=>t(g.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"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"Skip permission prompts (use with caution)"}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Equivalent to --dangerously-skip-permissions flag"})]})]})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(mh,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Allowed Tools"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Tools that are automatically allowed without prompting for permission"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(tr,{value:o,onChange:g=>l(g.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),d(o))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>d(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[a.jsx(hr,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Quick add common tools:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:gq.map(g=>a.jsx(We,{variant:"outline",size:"sm",onClick:()=>d(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),a.jsxs("div",{className:"space-y-2",children:[r.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>p(g),className:"text-green-600 hover:text-green-700",children:a.jsx(jt,{className:"w-4 h-4"})})]},g)),r.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No allowed tools configured"})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(kn,{className:"w-5 h-5 text-red-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Blocked Tools"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Tools that are automatically blocked without prompting for permission"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(tr,{value:c,onChange:g=>u(g.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),m(c))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>m(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[a.jsx(hr,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[i.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>h(g),className:"text-red-600 hover:text-red-700",children:a.jsx(jt,{className:"w-4 h-4"})})]},g)),i.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No blocked tools configured"})]})]}),a.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:"Tool Pattern Examples:"}),a.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," - Allow all git log commands"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," - Allow all git diff commands"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," - Allow all Write tool usage"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," - Block all rm commands (dangerous)"]})]})]})]})}function xq({skipPermissions:e,setSkipPermissions:t,allowedCommands:r,setAllowedCommands:n,disallowedCommands:i,setDisallowedCommands:s,newAllowedCommand:o,setNewAllowedCommand:l,newDisallowedCommand:c,setNewDisallowedCommand:u}){const d=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},p=g=>{n(r.filter(x=>x!==g))},m=g=>{g&&!i.includes(g)&&(s([...i,g]),u(""))},h=g=>{s(i.filter(x=>x!==g))};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(kn,{className:"w-5 h-5 text-orange-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Settings"})]}),a.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("label",{className:"flex items-center gap-3",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:g=>t(g.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"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"Skip permission prompts (use with caution)"}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Equivalent to -f flag in Cursor CLI"})]})]})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(mh,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Allowed Shell Commands"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Shell commands that are automatically allowed without prompting"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(tr,{value:o,onChange:g=>l(g.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),d(o))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>d(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[a.jsx(hr,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Quick add common commands:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:fq.map(g=>a.jsx(We,{variant:"outline",size:"sm",onClick:()=>d(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),a.jsxs("div",{className:"space-y-2",children:[r.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>p(g),className:"text-green-600 hover:text-green-700",children:a.jsx(jt,{className:"w-4 h-4"})})]},g)),r.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No allowed commands configured"})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(kn,{className:"w-5 h-5 text-red-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Blocked Shell Commands"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Shell commands that are automatically blocked"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(tr,{value:c,onChange:g=>u(g.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),m(c))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>m(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[a.jsx(hr,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[i.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>h(g),className:"text-red-600 hover:text-red-700",children:a.jsx(jt,{className:"w-4 h-4"})})]},g)),i.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No blocked commands configured"})]})]}),a.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:"Shell Command Examples:"}),a.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," - Allow ls command"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," - Allow git status"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," - Allow npm install"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," - Block recursive delete"]})]})]})]})}function yq({permissionMode:e,setPermissionMode:t}){return a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(mh,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Mode"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls how Codex handles file modifications and command execution"}),a.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="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:()=>t("default"),children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="default",onChange:()=>t("default"),className:"mt-1 w-4 h-4 text-green-600"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Default"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Only trusted commands (ls, cat, grep, git status, etc.) run automatically. Other commands are skipped. Can write to workspace."})]})]})}),a.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="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:()=>t("acceptEdits"),children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="acceptEdits",onChange:()=>t("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:"Accept Edits"}),a.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:"All commands run automatically within the workspace. Full auto mode with sandboxed execution."})]})]})}),a.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="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:()=>t("bypassPermissions"),children:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="bypassPermissions",onChange:()=>t("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),a.jsxs("div",{children:[a.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:["Bypass Permissions",a.jsx(kn,{className:"w-4 h-4"})]}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Full system access with no restrictions. All commands run automatically with full disk and network access. Use with caution."})]})]})}),a.jsxs("details",{className:"text-sm",children:[a.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Technical details"}),a.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:[a.jsxs("p",{children:[a.jsx("strong",{children:"Default:"})," sandboxMode=workspace-write, approvalPolicy=untrusted. Trusted commands: cat, cd, grep, head, ls, pwd, tail, git status/log/diff/show, find (without -exec), etc."]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Accept Edits:"})," sandboxMode=workspace-write, approvalPolicy=never. All commands auto-execute within project directory."]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Bypass Permissions:"})," sandboxMode=danger-full-access, approvalPolicy=never. Full system access, use only in trusted environments."]}),a.jsx("p",{className:"text-xs opacity-75",children:"You can override this per-session using the mode button in the chat interface."})]})]})]})})}function dm({agent:e,...t}){return e==="claude"?a.jsx(bq,{...t}):e==="cursor"?a.jsx(xq,{...t}):e==="codex"?a.jsx(yq,{...t}):null}const vq=e=>{switch(e){case"stdio":return a.jsx(Jr,{className:"w-4 h-4"});case"sse":return a.jsx(gh,{className:"w-4 h-4"});case"http":return a.jsx(hm,{className:"w-4 h-4"});default:return a.jsx(io,{className:"w-4 h-4"})}};function kq({servers:e,onAdd:t,onEdit:r,onDelete:n,onTest:i,onDiscoverTools:s,testResults:o,serverTools:l,toolsLoading:c}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(io,{className:"w-5 h-5 text-purple-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Claude"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[a.jsx(hr,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(u=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[vq(u.type),a.jsx("span",{className:"font-medium text-foreground",children:u.name}),a.jsx(Zr,{variant:"outline",className:"text-xs",children:u.type}),a.jsx(Zr,{variant:"outline",className:"text-xs",children:u.scope==="local"?"local":u.scope==="user"?"user":u.scope})]}),a.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[u.type==="stdio"&&u.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.command})]}),(u.type==="sse"||u.type==="http")&&u.config?.url&&a.jsxs("div",{children:["URL: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.url})]}),u.config?.args&&u.config.args.length>0&&a.jsxs("div",{children:["Args: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.args.join(" ")})]})]}),o?.[u.id]&&a.jsx("div",{className:`mt-2 p-2 rounded text-xs ${o[u.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:a.jsx("div",{className:"font-medium",children:o[u.id].message})}),l?.[u.id]&&l[u.id].tools?.length>0&&a.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:[a.jsxs("div",{className:"font-medium",children:["Tools (",l[u.id].tools.length,"):"]}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[l[u.id].tools.slice(0,5).map((d,p)=>a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:d.name},p)),l[u.id].tools.length>5&&a.jsxs("span",{className:"text-xs opacity-75",children:["+",l[u.id].tools.length-5," more"]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(u),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"Edit server",children:a.jsx(Li,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(u.id,u.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"Delete server",children:a.jsx(_r,{className:"w-4 h-4"})})]})]})},u.id)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]})]})}function wq({servers:e,onAdd:t,onEdit:r,onDelete:n}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(io,{className:"w-5 h-5 text-purple-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Cursor"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[a.jsx(hr,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(i=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Jr,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:i.name}),a.jsx(Zr,{variant:"outline",className:"text-xs",children:"stdio"})]}),a.jsx("div",{className:"text-sm text-muted-foreground",children:i.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.command})]})})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(i),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:a.jsx(Li,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(i.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",children:a.jsx(_r,{className:"w-4 h-4"})})]})]})},i.name||i.id)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]})]})}function Sq({servers:e,onAdd:t,onEdit:r,onDelete:n}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(io,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Codex"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[a.jsx(hr,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(i=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Jr,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:i.name}),a.jsx(Zr,{variant:"outline",className:"text-xs",children:"stdio"})]}),a.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[i.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.command})]}),i.config?.args&&i.config.args.length>0&&a.jsxs("div",{children:["Args: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.args.join(" ")})]}),i.config?.env&&Object.keys(i.config.env).length>0&&a.jsxs("div",{children:["Environment: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(i.config.env).map(([s,o])=>`${s}=${o}`).join(", ")})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(i),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"Edit server",children:a.jsx(Li,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(i.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"Delete server",children:a.jsx(_r,{className:"w-4 h-4"})})]})]})},i.name)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]}),a.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:"About Codex MCP"}),a.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Codex supports stdio-based MCP servers. You can add servers that extend Codex's capabilities with additional tools and resources."})]})]})}function pm({agent:e,...t}){return e==="claude"?a.jsx(kq,{...t}):e==="cursor"?a.jsx(wq,{...t}):e==="codex"?a.jsx(Sq,{...t}):null}function Eq({isOpen:e,onClose:t,projects:r=[],initialTab:n="agents"}){const{isDarkMode:i,toggleDarkMode:s}=Gi(),[o,l]=b.useState([]),[c,u]=b.useState([]),[d,p]=b.useState(""),[m,h]=b.useState(""),[g,x]=b.useState(!1),[w,N]=b.useState(!1),[k,v]=b.useState(null),[E,T]=b.useState("name"),[S,I]=b.useState("repo"),[D,L]=b.useState("1w"),[_,z]=b.useState([]),[F,$]=b.useState(!1),[M,U]=b.useState(null),[q,ae]=b.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[re,ne]=b.useState(!1),[C,V]=b.useState({}),[se,R]=b.useState({}),[K,he]=b.useState({}),[xe,oe]=b.useState(n),[De,le]=b.useState(""),[ge,Ae]=b.useState("claude"),[ie,Ie]=b.useState("account"),[ze,wt]=b.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[ot,xt]=b.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[ht,Ze]=b.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[lt,Mt]=b.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Bt,Yt]=b.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[we,ue]=b.useState([]),[X,J]=b.useState([]),[de,ke]=b.useState(!1),[qe,Ct]=b.useState(""),[bt,me]=b.useState(""),[Ge,je]=b.useState([]),[Me,st]=b.useState([]),[Ve,gt]=b.useState("default"),[Qe,Ot]=b.useState(!1),[Lt,dr]=b.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[Qt,Wr]=b.useState(null),[H,Te]=b.useState(!1),[ct,ut]=b.useState(!1),[fe,tt]=b.useState(""),[ee,ye]=b.useState(null),[et,At]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),[Ft,nr]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),[Nr,Cn]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),Tn=async()=>{try{const W=await Ce("/api/cursor/mcp");if(W.ok){const pe=await W.json();je(pe.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(W){console.error("Error fetching Cursor MCP servers:",W)}},ur=async()=>{try{const W=await Ce("/api/codex/mcp/config/read");if(W.ok){const _e=await W.json();if(_e.success&&_e.servers){st(_e.servers);return}}const pe=await Ce("/api/codex/mcp/cli/list");if(pe.ok){const _e=await pe.json();if(_e.success&&_e.servers){const nt=_e.servers.map(mr=>({id:mr.name,name:mr.name,type:mr.type||"stdio",scope:"user",config:{command:mr.command||"",args:mr.args||[],env:mr.env||{}}}));st(nt)}}}catch(W){console.error("Error fetching Codex MCP servers:",W)}},Wt=async()=>{try{const W=await Ce("/api/mcp/cli/list");if(W.ok){const nt=await W.json();if(nt.success&&nt.servers){const mr=nt.servers.map(gr=>({id:gr.id||gr.name,name:gr.name,type:gr.type,scope:"user",status:gr.status,config:{command:gr.command||"",args:gr.args||[],env:gr.env||{},url:gr.url||"",headers:gr.headers||{},timeout:3e4},description:gr.description,created:new Date().toISOString(),updated:new Date().toISOString()}));z(mr);return}}const pe=await Ce("/api/mcp/config/read");if(pe.ok){const nt=await pe.json();if(nt.success&&nt.servers){z(nt.servers);return}}const _e=await Ce("/api/mcp/servers?scope=user");if(_e.ok){const nt=await _e.json();z(nt.servers||[])}else console.error("Failed to fetch MCP servers")}catch(W){console.error("Error fetching MCP servers:",W)}},cn=async W=>{try{M&&await ma(M.id,"user");const pe=await Ce("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:W.name,type:W.type,scope:W.scope,projectPath:W.projectPath,command:W.config?.command,args:W.config?.args||[],url:W.config?.url,headers:W.config?.headers||{},env:W.config?.env||{}})});if(pe.ok){const _e=await pe.json();if(_e.success)return await Wt(),!0;throw new Error(_e.error||"Failed to save server via Claude CLI")}else{const _e=await pe.json();throw new Error(_e.error||"Failed to save server")}}catch(pe){throw console.error("Error saving MCP server:",pe),pe}},ma=async(W,pe="user")=>{try{const _e=await Ce(`/api/mcp/cli/remove/${W}?scope=${pe}`,{method:"DELETE"});if(_e.ok){const nt=await _e.json();if(nt.success)return await Wt(),!0;throw new Error(nt.error||"Failed to delete server via Claude CLI")}else{const nt=await _e.json();throw new Error(nt.error||"Failed to delete server")}}catch(_e){throw console.error("Error deleting MCP server:",_e),_e}},Kn=async(W,pe="user")=>{try{const _e=await Ce(`/api/mcp/servers/${W}/test?scope=${pe}`,{method:"POST"});if(_e.ok)return(await _e.json()).testResult;{const nt=await _e.json();throw new Error(nt.error||"Failed to test server")}}catch(_e){throw console.error("Error testing MCP server:",_e),_e}},di=async(W,pe="user")=>{try{const _e=await Ce(`/api/mcp/servers/${W}/tools?scope=${pe}`,{method:"POST"});if(_e.ok)return(await _e.json()).toolsResult;{const nt=await _e.json();throw new Error(nt.error||"Failed to discover tools")}}catch(_e){throw console.error("Error discovering MCP tools:",_e),_e}},rn=async W=>{try{Qt&&await ja(Qt.id);const pe=await Ce("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:W.name,command:W.config?.command,args:W.config?.args||[],env:W.config?.env||{}})});if(pe.ok){const _e=await pe.json();if(_e.success)return await ur(),!0;throw new Error(_e.error||"Failed to save Codex MCP server")}else{const _e=await pe.json();throw new Error(_e.error||"Failed to save server")}}catch(pe){throw console.error("Error saving Codex MCP server:",pe),pe}},ja=async W=>{try{const pe=await Ce(`/api/codex/mcp/cli/remove/${W}`,{method:"DELETE"});if(pe.ok){const _e=await pe.json();if(_e.success)return await ur(),!0;throw new Error(_e.error||"Failed to delete Codex MCP server")}else{const _e=await pe.json();throw new Error(_e.error||"Failed to delete server")}}catch(pe){throw console.error("Error deleting Codex MCP server:",pe),pe}},Mr=()=>{dr({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),Wr(null),Ot(!1)},Xn=(W=null)=>{W?(Wr(W),dr({name:W.name,type:W.type||"stdio",config:{command:W.config?.command||"",args:W.config?.args||[],env:W.config?.env||{}}})):Mr(),Ot(!0)},Eo=async W=>{W.preventDefault(),Te(!0);try{Qt&&await ja(Qt.name),await rn(Lt),Mr(),v("success")}catch(pe){alert(`Error: ${pe.message}`),v("error")}finally{Te(!1)}},No=async W=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await ja(W),v("success")}catch(pe){alert(`Error: ${pe.message}`),v("error")}};b.useEffect(()=>{e&&(Fr(),pi(),mi(),Zn(),oe(n))},[e,n]),b.useEffect(()=>{localStorage.setItem("codeEditorTheme",ze),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ze]),b.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",ot.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ot]),b.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",ht.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ht]),b.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",lt.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[lt]),b.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Bt),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Bt]);const Fr=async()=>{try{const W=localStorage.getItem("claude-settings");if(W){const nt=JSON.parse(W);l(nt.allowedTools||[]),u(nt.disallowedTools||[]),x(nt.skipPermissions||!1),T(nt.projectSortOrder||"name"),I(nt.sidebarViewMode||"repo"),L(nt.sidebarTimeframe||"1w")}else l([]),u([]),x(!1),T("name"),I("repo"),L("1w");const pe=localStorage.getItem("cursor-tools-settings");if(pe){const nt=JSON.parse(pe);ue(nt.allowedCommands||[]),J(nt.disallowedCommands||[]),ke(nt.skipPermissions||!1)}else ue([]),J([]),ke(!1);const _e=localStorage.getItem("codex-settings");if(_e){const nt=JSON.parse(_e);gt(nt.permissionMode||"default")}else gt("default");await Wt(),await Tn(),await ur()}catch(W){console.error("Error loading tool settings:",W),l([]),u([]),x(!1),T("name")}},pi=async()=>{try{const W=await Ce("/api/cli/claude/status");if(W.ok){const pe=await W.json();At({authenticated:pe.authenticated,email:pe.email,loading:!1,error:pe.error||null})}else At({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(W){console.error("Error checking Claude auth status:",W),At({authenticated:!1,email:null,loading:!1,error:W.message})}},mi=async()=>{try{const W=await Ce("/api/cli/cursor/status");if(W.ok){const pe=await W.json();nr({authenticated:pe.authenticated,email:pe.email,loading:!1,error:pe.error||null})}else nr({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(W){console.error("Error checking Cursor auth status:",W),nr({authenticated:!1,email:null,loading:!1,error:W.message})}},Zn=async()=>{try{const W=await Ce("/api/cli/codex/status");if(W.ok){const pe=await W.json();Cn({authenticated:pe.authenticated,email:pe.email,loading:!1,error:pe.error||null})}else Cn({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(W){console.error("Error checking Codex auth status:",W),Cn({authenticated:!1,email:null,loading:!1,error:W.message})}},An=()=>{tt("claude"),ye(r?.[0]||{name:"default",fullPath:process.cwd()}),ut(!0)},In=()=>{tt("cursor"),ye(r?.[0]||{name:"default",fullPath:process.cwd()}),ut(!0)},Jn=()=>{tt("codex"),ye(r?.[0]||{name:"default",fullPath:process.cwd()}),ut(!0)},rs=W=>{W===0&&(v("success"),fe==="claude"?pi():fe==="cursor"?mi():fe==="codex"&&Zn())},Co=()=>{N(!0),v(null);try{const W={allowedTools:o,disallowedTools:c,skipPermissions:g,projectSortOrder:E,sidebarViewMode:S,sidebarTimeframe:D,lastUpdated:new Date().toISOString()},pe={allowedCommands:we,disallowedCommands:X,skipPermissions:de,lastUpdated:new Date().toISOString()},_e={permissionMode:Ve,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(W)),localStorage.setItem("cursor-tools-settings",JSON.stringify(pe)),localStorage.setItem("codex-settings",JSON.stringify(_e)),v("success"),setTimeout(()=>{t()},1e3)}catch(W){console.error("Error saving tool settings:",W),v("error")}finally{N(!1)}},un=()=>{ae({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),U(null),$(!1),le("")},_a=(W=null)=>{W?(U(W),ae({name:W.name,type:W.type,scope:W.scope,projectPath:W.projectPath||"",config:{...W.config},raw:W.raw,importMode:"form",jsonInput:""})):un(),$(!0)},hi=async W=>{W.preventDefault(),ne(!0);try{if(q.importMode==="json"){const pe=await Ce("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:q.name,jsonConfig:q.jsonInput,scope:q.scope,projectPath:q.projectPath})});if(pe.ok){const _e=await pe.json();if(_e.success)await Wt(),un(),v("success");else throw new Error(_e.error||"Failed to add server via JSON")}else{const _e=await pe.json();throw new Error(_e.error||"Failed to add server")}}else await cn(q),un(),v("success")}catch(pe){alert(`Error: ${pe.message}`),v("error")}finally{ne(!1)}},Rn=async(W,pe)=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await ma(W,pe),v("success")}catch(_e){alert(`Error: ${_e.message}`),v("error")}},pr=async(W,pe)=>{try{V({...C,[W]:{loading:!0}});const _e=await Kn(W,pe);V({...C,[W]:_e})}catch(_e){V({...C,[W]:{success:!1,message:_e.message,details:[]}})}},ns=async(W,pe)=>{try{he({...K,[W]:!0});const _e=await di(W,pe);R({...se,[W]:_e})}catch{R({...se,[W]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{he({...K,[W]:!1})}},ft=(W,pe)=>{ae(_e=>({..._e,config:{..._e.config,[W]:pe}}))};return e?a.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[a.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:[a.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Sa,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),a.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:"Settings"})]}),a.jsx(We,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:a.jsx(jt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[a.jsx("div",{className:"border-b border-border",children:a.jsxs("div",{className:"flex px-4 md:px-6",children:[a.jsx("button",{onClick:()=>oe("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Agents"}),a.jsx("button",{onClick:()=>oe("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Appearance"}),a.jsxs("button",{onClick:()=>oe("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[a.jsx(vn,{className:"w-4 h-4 inline mr-2"}),"Git"]}),a.jsxs("button",{onClick:()=>oe("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[a.jsx(dh,{className:"w-4 h-4 inline mr-2"}),"API & Tokens"]}),a.jsx("button",{onClick:()=>oe("tasks"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Tasks"})]})}),a.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[xe==="appearance"&&a.jsx("div",{className:"space-y-6 md:space-y-8",children:xe==="appearance"&&a.jsxs("div",{className:"space-y-6 md:space-y-8",children:[a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Dark Mode"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Toggle between light and dark themes"})]}),a.jsxs("button",{onClick:s,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":i,"aria-label":"Toggle dark mode",children:[a.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),a.jsx("span",{className:`${i?"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:i?a.jsx(gm,{className:"w-3.5 h-3.5 text-gray-700"}):a.jsx(fm,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Project Sorting"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"How projects are ordered in the sidebar"})]}),a.jsxs("select",{value:E,onChange:W=>T(W.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:[a.jsx("option",{value:"name",children:"Alphabetical"}),a.jsx("option",{value:"date",children:"Recent Activity"})]})]})})}),a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Sessions View"}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Default View Mode"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"How sessions are displayed in the sidebar"})]}),a.jsxs("select",{value:S,onChange:W=>I(W.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:[a.jsx("option",{value:"repo",children:"Repo View"}),a.jsx("option",{value:"session",children:"Session View"})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Default Timeframe"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Default time filter for session view"})]}),a.jsxs("select",{value:D,onChange:W=>L(W.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:[a.jsx("option",{value:"1h",children:"1 hour"}),a.jsx("option",{value:"8h",children:"8 hours"}),a.jsx("option",{value:"1d",children:"1 day"}),a.jsx("option",{value:"1w",children:"1 week"}),a.jsx("option",{value:"2w",children:"2 weeks"}),a.jsx("option",{value:"1m",children:"1 month"}),a.jsx("option",{value:"all",children:"All time"})]})]})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Code Editor"}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Editor Theme"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Default theme for the code editor"})]}),a.jsxs("button",{onClick:()=>wt(ze==="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":ze==="dark","aria-label":"Toggle editor theme",children:[a.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),a.jsx("span",{className:`${ze==="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:ze==="dark"?a.jsx(gm,{className:"w-3.5 h-3.5 text-gray-700"}):a.jsx(fm,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Word Wrap"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Enable word wrapping by default in the editor"})]}),a.jsxs("button",{onClick:()=>xt(!ot),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":ot,"aria-label":"Toggle word wrap",children:[a.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),a.jsx("span",{className:`${ot?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Show Minimap"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Display a minimap for easier navigation in diff view"})]}),a.jsxs("button",{onClick:()=>Ze(!ht),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":ht,"aria-label":"Toggle minimap",children:[a.jsx("span",{className:"sr-only",children:"Toggle minimap"}),a.jsx("span",{className:`${ht?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Show Line Numbers"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Display line numbers in the editor"})]}),a.jsxs("button",{onClick:()=>Mt(!lt),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":lt,"aria-label":"Toggle line numbers",children:[a.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),a.jsx("span",{className:`${lt?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Font Size"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Editor font size in pixels"})]}),a.jsxs("select",{value:Bt,onChange:W=>Yt(W.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:[a.jsx("option",{value:"10",children:"10px"}),a.jsx("option",{value:"11",children:"11px"}),a.jsx("option",{value:"12",children:"12px"}),a.jsx("option",{value:"13",children:"13px"}),a.jsx("option",{value:"14",children:"14px"}),a.jsx("option",{value:"15",children:"15px"}),a.jsx("option",{value:"16",children:"16px"}),a.jsx("option",{value:"18",children:"18px"}),a.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),xe==="git"&&a.jsx(cq,{}),xe==="agents"&&a.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[a.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"flex",children:[a.jsx(Ba,{agentId:"claude",authStatus:et,isSelected:ge==="claude",onClick:()=>Ae("claude"),isMobile:!0}),a.jsx(Ba,{agentId:"cursor",authStatus:Ft,isSelected:ge==="cursor",onClick:()=>Ae("cursor"),isMobile:!0}),a.jsx(Ba,{agentId:"codex",authStatus:Nr,isSelected:ge==="codex",onClick:()=>Ae("codex"),isMobile:!0})]})}),a.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"p-2",children:[a.jsx(Ba,{agentId:"claude",authStatus:et,isSelected:ge==="claude",onClick:()=>Ae("claude")}),a.jsx(Ba,{agentId:"cursor",authStatus:Ft,isSelected:ge==="cursor",onClick:()=>Ae("cursor")}),a.jsx(Ba,{agentId:"codex",authStatus:Nr,isSelected:ge==="codex",onClick:()=>Ae("codex")})]})}),a.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[a.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[a.jsx("button",{onClick:()=>Ie("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 ${ie==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Account"}),a.jsx("button",{onClick:()=>Ie("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 ${ie==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Permissions"}),a.jsx("button",{onClick:()=>Ie("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 ${ie==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"MCP Servers"})]})}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[ie==="account"&&a.jsx(hq,{agent:ge,authStatus:ge==="claude"?et:ge==="cursor"?Ft:Nr,onLogin:ge==="claude"?An:ge==="cursor"?In:Jn}),ie==="permissions"&&ge==="claude"&&a.jsx(dm,{agent:"claude",skipPermissions:g,setSkipPermissions:x,allowedTools:o,setAllowedTools:l,disallowedTools:c,setDisallowedTools:u,newAllowedTool:d,setNewAllowedTool:p,newDisallowedTool:m,setNewDisallowedTool:h}),ie==="permissions"&&ge==="cursor"&&a.jsx(dm,{agent:"cursor",skipPermissions:de,setSkipPermissions:ke,allowedCommands:we,setAllowedCommands:ue,disallowedCommands:X,setDisallowedCommands:J,newAllowedCommand:qe,setNewAllowedCommand:Ct,newDisallowedCommand:bt,setNewDisallowedCommand:me}),ie==="permissions"&&ge==="codex"&&a.jsx(dm,{agent:"codex",permissionMode:Ve,setPermissionMode:gt}),ie==="mcp"&&ge==="claude"&&a.jsx(pm,{agent:"claude",servers:_,onAdd:()=>_a(),onEdit:W=>_a(W),onDelete:(W,pe)=>Rn(W,pe),onTest:(W,pe)=>pr(W,pe),onDiscoverTools:(W,pe)=>ns(W,pe),testResults:C,serverTools:se,toolsLoading:K}),ie==="mcp"&&ge==="cursor"&&a.jsx(pm,{agent:"cursor",servers:Ge,onAdd:()=>{},onEdit:W=>{},onDelete:W=>{}}),ie==="mcp"&&ge==="codex"&&a.jsx(pm,{agent:"codex",servers:Me,onAdd:()=>Xn(),onEdit:W=>Xn(W),onDelete:W=>No(W)})]})]})]}),F&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:a.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[a.jsx("h3",{className:"text-lg font-medium text-foreground",children:M?"Edit MCP Server":"Add MCP Server"}),a.jsx(We,{variant:"ghost",size:"sm",onClick:un,children:a.jsx(jt,{className:"w-4 h-4"})})]}),a.jsxs("form",{onSubmit:hi,className:"p-4 space-y-4",children:[!M&&a.jsxs("div",{className:"flex gap-2 mb-4",children:[a.jsx("button",{type:"button",onClick:()=>ae(W=>({...W,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${q.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:"Form Input"}),a.jsx("button",{type:"button",onClick:()=>ae(W=>({...W,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${q.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:"JSON Import"})]}),q.importMode==="form"&&M&&a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Scope"}),a.jsxs("div",{className:"flex items-center gap-2",children:[q.scope==="user"?a.jsx(hm,{className:"w-4 h-4"}):a.jsx(yn,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:q.scope==="user"?"User (Global)":"Project (Local)"}),q.scope==="local"&&q.projectPath&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",q.projectPath]})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Scope cannot be changed when editing an existing server"})]}),q.importMode==="form"&&!M&&a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Scope *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{type:"button",onClick:()=>ae(W=>({...W,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${q.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:a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(hm,{className:"w-4 h-4"}),a.jsx("span",{children:"User (Global)"})]})}),a.jsx("button",{type:"button",onClick:()=>ae(W=>({...W,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${q.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:a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(yn,{className:"w-4 h-4"}),a.jsx("span",{children:"Project (Local)"})]})})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:q.scope==="user"?"User scope: Available across all projects on your machine":"Local scope: Only available in the selected project"})]}),q.scope==="local"&&!M&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Project *"}),a.jsxs("select",{value:q.projectPath,onChange:W=>ae(pe=>({...pe,projectPath:W.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:q.scope==="local",children:[a.jsx("option",{value:"",children:"Select a project..."}),r.map(W=>a.jsx("option",{value:W.path||W.fullPath,children:W.displayName||W.name},W.name))]}),q.projectPath&&a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Path: ",q.projectPath]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:q.importMode==="json"?"md:col-span-2":"",children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Server Name *"}),a.jsx(tr,{value:q.name,onChange:W=>{ae(pe=>({...pe,name:W.target.value}))},placeholder:"my-server",required:!0})]}),q.importMode==="form"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Transport Type *"}),a.jsxs("select",{value:q.type,onChange:W=>{ae(pe=>({...pe,type:W.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:[a.jsx("option",{value:"stdio",children:"stdio"}),a.jsx("option",{value:"sse",children:"SSE"}),a.jsx("option",{value:"http",children:"HTTP"})]})]})]}),M&&q.raw&&q.importMode==="form"&&a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[a.jsxs("h4",{className:"text-sm font-medium text-foreground mb-2",children:["Configuration Details (from"," ",M.scope==="global"?"~/.claude.json":"project config",")"]}),a.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(q.raw,null,2)})]}),q.importMode==="json"&&a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"JSON Configuration *"}),a.jsx("textarea",{value:q.jsonInput,onChange:W=>{ae(pe=>({...pe,jsonInput:W.target.value}));try{if(W.target.value.trim()){const pe=JSON.parse(W.target.value);pe.type?pe.type==="stdio"&&!pe.command?le("stdio type requires a command field"):(pe.type==="http"||pe.type==="sse")&&!pe.url?le(`${pe.type} type requires a url field`):le(""):le("Missing required field: type")}}catch{W.target.value.trim()?le("Invalid JSON format"):le("")}},className:`w-full px-3 py-2 border ${De?"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:`{
1215
1215
  "type": "stdio",
1216
1216
  "command": "/path/to/server",
1217
1217
  "args": ["--api-key", "abc123"],
package/dist/index.html CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
  <!-- Prevent zoom on iOS -->
27
27
  <meta name="format-detection" content="telephone=no" />
28
- <script type="module" crossorigin src="/assets/index-sqmQ9jF8.js"></script>
28
+ <script type="module" crossorigin src="/assets/index-DM1BeYBg.js"></script>
29
29
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-DcyRfQm3.js">
30
30
  <link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-CJLzwpLB.js">
31
31
  <link rel="modulepreload" crossorigin href="/assets/vendor-xterm-DfaPXD3y.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epiphytic/claudecodeui",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "A web-based UI for Claude Code CLI",
5
5
  "type": "module",
6
6
  "main": "server/index.js",
@@ -14,6 +14,10 @@ let cachedProjects = [];
14
14
  let cacheVersion = 0;
15
15
  let cacheTimestamp = null;
16
16
 
17
+ // Promise-based initialization waiting
18
+ let initResolvers = [];
19
+ const MAX_WAIT_MS = 30000; // 30 second timeout
20
+
17
21
  /**
18
22
  * Timeframe definitions in milliseconds
19
23
  * (Same as sessions-cache.js for consistency)
@@ -109,6 +113,14 @@ function updateProjectsCache(projects) {
109
113
 
110
114
  cacheVersion++;
111
115
  cacheTimestamp = new Date().toISOString();
116
+
117
+ // Resolve any waiting promises
118
+ if (initResolvers.length > 0) {
119
+ for (const resolve of initResolvers) {
120
+ resolve();
121
+ }
122
+ initResolvers = [];
123
+ }
112
124
  }
113
125
 
114
126
  /**
@@ -170,6 +182,35 @@ function isCacheInitialized() {
170
182
  return cacheTimestamp !== null;
171
183
  }
172
184
 
185
+ /**
186
+ * Wait for cache to be initialized
187
+ * Returns immediately if already initialized, otherwise waits up to MAX_WAIT_MS
188
+ */
189
+ function waitForInitialization() {
190
+ if (cacheTimestamp !== null) {
191
+ return Promise.resolve();
192
+ }
193
+
194
+ return new Promise((resolve, reject) => {
195
+ const timeout = setTimeout(() => {
196
+ // Remove this resolver from the list
197
+ const idx = initResolvers.indexOf(resolve);
198
+ if (idx !== -1) {
199
+ initResolvers.splice(idx, 1);
200
+ }
201
+ reject(new Error("Cache initialization timeout"));
202
+ }, MAX_WAIT_MS);
203
+
204
+ // Wrap resolver to clear timeout
205
+ const wrappedResolve = () => {
206
+ clearTimeout(timeout);
207
+ resolve();
208
+ };
209
+
210
+ initResolvers.push(wrappedResolve);
211
+ });
212
+ }
213
+
173
214
  /**
174
215
  * Get the raw cached projects (for initial load)
175
216
  */
@@ -190,6 +231,7 @@ export {
190
231
  generateETag,
191
232
  getCacheMeta,
192
233
  isCacheInitialized,
234
+ waitForInitialization,
193
235
  getCachedProjects,
194
236
  getProjectFromCache,
195
237
  TIMEFRAME_MS,
@@ -9,6 +9,7 @@ import {
9
9
  generateETag,
10
10
  getCacheMeta,
11
11
  isCacheInitialized,
12
+ waitForInitialization,
12
13
  TIMEFRAME_MS,
13
14
  } from "../projects-cache.js";
14
15
 
@@ -26,14 +27,18 @@ const router = express.Router();
26
27
  * Headers:
27
28
  * - If-None-Match: ETag from previous response (for 304 support)
28
29
  */
29
- router.get("/list", (req, res) => {
30
+ router.get("/list", async (req, res) => {
30
31
  try {
31
- // Check if cache is initialized
32
+ // Wait for cache to be initialized (blocks until ready or timeout)
32
33
  if (!isCacheInitialized()) {
33
- return res.status(503).json({
34
- error: "Projects cache not yet initialized",
35
- message: "Please wait for initial project scan to complete",
36
- });
34
+ try {
35
+ await waitForInitialization();
36
+ } catch (err) {
37
+ return res.status(503).json({
38
+ error: "Projects cache initialization timeout",
39
+ message: err.message,
40
+ });
41
+ }
37
42
  }
38
43
 
39
44
  // Get timeframe from query (validate against known values)
@@ -13,6 +13,7 @@ import {
13
13
  generateETag,
14
14
  getCacheMeta,
15
15
  isCacheInitialized,
16
+ waitForInitialization,
16
17
  TIMEFRAME_MS,
17
18
  } from "../sessions-cache.js";
18
19
 
@@ -31,14 +32,18 @@ const router = express.Router();
31
32
  * - 304 Not Modified (if ETag matches)
32
33
  * - 200 OK with sessions data
33
34
  */
34
- router.get("/list", (req, res) => {
35
+ router.get("/list", async (req, res) => {
35
36
  try {
36
- // Check if cache is initialized
37
+ // Wait for cache to be initialized (blocks until ready or timeout)
37
38
  if (!isCacheInitialized()) {
38
- return res.status(503).json({
39
- error: "Sessions cache not yet initialized",
40
- message: "Please wait for initial project scan to complete",
41
- });
39
+ try {
40
+ await waitForInitialization();
41
+ } catch (err) {
42
+ return res.status(503).json({
43
+ error: "Sessions cache initialization timeout",
44
+ message: err.message,
45
+ });
46
+ }
42
47
  }
43
48
 
44
49
  // Get timeframe from query (validate against known values)
@@ -14,6 +14,10 @@ let cacheVersion = 0;
14
14
  let cacheTimestamp = null;
15
15
  let lastProjectsData = null;
16
16
 
17
+ // Promise-based initialization waiting
18
+ let initResolvers = [];
19
+ const MAX_WAIT_MS = 30000; // 30 second timeout
20
+
17
21
  /**
18
22
  * Timeframe definitions in milliseconds
19
23
  */
@@ -100,6 +104,14 @@ function updateSessionsCache(projects) {
100
104
  cacheVersion++;
101
105
  cacheTimestamp = new Date().toISOString();
102
106
  lastProjectsData = projects;
107
+
108
+ // Resolve any waiting promises
109
+ if (initResolvers.length > 0) {
110
+ for (const resolve of initResolvers) {
111
+ resolve();
112
+ }
113
+ initResolvers = [];
114
+ }
103
115
  }
104
116
 
105
117
  /**
@@ -157,6 +169,35 @@ function isCacheInitialized() {
157
169
  return cacheTimestamp !== null;
158
170
  }
159
171
 
172
+ /**
173
+ * Wait for cache to be initialized
174
+ * Returns immediately if already initialized, otherwise waits up to MAX_WAIT_MS
175
+ */
176
+ function waitForInitialization() {
177
+ if (cacheTimestamp !== null) {
178
+ return Promise.resolve();
179
+ }
180
+
181
+ return new Promise((resolve, reject) => {
182
+ const timeout = setTimeout(() => {
183
+ // Remove this resolver from the list
184
+ const idx = initResolvers.indexOf(resolve);
185
+ if (idx !== -1) {
186
+ initResolvers.splice(idx, 1);
187
+ }
188
+ reject(new Error("Cache initialization timeout"));
189
+ }, MAX_WAIT_MS);
190
+
191
+ // Wrap resolver to clear timeout
192
+ const wrappedResolve = () => {
193
+ clearTimeout(timeout);
194
+ resolve();
195
+ };
196
+
197
+ initResolvers.push(wrappedResolve);
198
+ });
199
+ }
200
+
160
201
  /**
161
202
  * Get the raw cached sessions (for initial load)
162
203
  */
@@ -177,6 +218,7 @@ export {
177
218
  generateETag,
178
219
  getCacheMeta,
179
220
  isCacheInitialized,
221
+ waitForInitialization,
180
222
  getCachedSessions,
181
223
  getLastProjectsData,
182
224
  TIMEFRAME_MS,