crewly 1.4.5 → 1.4.7

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.
Files changed (63) hide show
  1. package/config/constants.ts +57 -0
  2. package/dist/backend/backend/src/constants.d.ts +39 -0
  3. package/dist/backend/backend/src/constants.d.ts.map +1 -1
  4. package/dist/backend/backend/src/constants.js +22 -1
  5. package/dist/backend/backend/src/constants.js.map +1 -1
  6. package/dist/backend/backend/src/index.d.ts.map +1 -1
  7. package/dist/backend/backend/src/index.js +23 -0
  8. package/dist/backend/backend/src/index.js.map +1 -1
  9. package/dist/backend/backend/src/services/addon/addon-loader.service.d.ts +101 -0
  10. package/dist/backend/backend/src/services/addon/addon-loader.service.d.ts.map +1 -0
  11. package/dist/backend/backend/src/services/addon/addon-loader.service.js +253 -0
  12. package/dist/backend/backend/src/services/addon/addon-loader.service.js.map +1 -0
  13. package/dist/backend/backend/src/services/addon/addon.types.d.ts +62 -0
  14. package/dist/backend/backend/src/services/addon/addon.types.d.ts.map +1 -0
  15. package/dist/backend/backend/src/services/addon/addon.types.js +11 -0
  16. package/dist/backend/backend/src/services/addon/addon.types.js.map +1 -0
  17. package/dist/backend/backend/src/services/addon/index.d.ts +8 -0
  18. package/dist/backend/backend/src/services/addon/index.d.ts.map +1 -0
  19. package/dist/backend/backend/src/services/addon/index.js +7 -0
  20. package/dist/backend/backend/src/services/addon/index.js.map +1 -0
  21. package/dist/backend/backend/src/services/agent/agent-registration.service.js +2 -2
  22. package/dist/backend/backend/src/services/agent/agent-registration.service.js.map +1 -1
  23. package/dist/backend/backend/src/services/agent/crewly-agent/agent-runner.service.d.ts +2 -0
  24. package/dist/backend/backend/src/services/agent/crewly-agent/agent-runner.service.d.ts.map +1 -1
  25. package/dist/backend/backend/src/services/agent/crewly-agent/agent-runner.service.js +48 -31
  26. package/dist/backend/backend/src/services/agent/crewly-agent/agent-runner.service.js.map +1 -1
  27. package/dist/backend/backend/src/services/agent/crewly-agent/crewly-agent-runtime.service.d.ts.map +1 -1
  28. package/dist/backend/backend/src/services/agent/crewly-agent/crewly-agent-runtime.service.js +11 -2
  29. package/dist/backend/backend/src/services/agent/crewly-agent/crewly-agent-runtime.service.js.map +1 -1
  30. package/dist/backend/backend/src/services/agent/crewly-agent/model-manager.d.ts.map +1 -1
  31. package/dist/backend/backend/src/services/agent/crewly-agent/model-manager.js +34 -25
  32. package/dist/backend/backend/src/services/agent/crewly-agent/model-manager.js.map +1 -1
  33. package/dist/backend/backend/src/services/agent/crewly-agent/rate-limiter.d.ts +3 -1
  34. package/dist/backend/backend/src/services/agent/crewly-agent/rate-limiter.d.ts.map +1 -1
  35. package/dist/backend/backend/src/services/agent/crewly-agent/rate-limiter.js +21 -6
  36. package/dist/backend/backend/src/services/agent/crewly-agent/rate-limiter.js.map +1 -1
  37. package/dist/backend/backend/src/services/messaging/queue-processor.service.js +2 -2
  38. package/dist/backend/backend/src/services/messaging/queue-processor.service.js.map +1 -1
  39. package/dist/backend/backend/src/services/slack/slack.service.d.ts +35 -0
  40. package/dist/backend/backend/src/services/slack/slack.service.d.ts.map +1 -1
  41. package/dist/backend/backend/src/services/slack/slack.service.js +156 -2
  42. package/dist/backend/backend/src/services/slack/slack.service.js.map +1 -1
  43. package/dist/backend/config/constants.d.ts +49 -0
  44. package/dist/backend/config/constants.d.ts.map +1 -1
  45. package/dist/backend/config/constants.js +50 -0
  46. package/dist/backend/config/constants.js.map +1 -1
  47. package/dist/cli/backend/src/constants.d.ts +39 -0
  48. package/dist/cli/backend/src/constants.d.ts.map +1 -1
  49. package/dist/cli/backend/src/constants.js +22 -1
  50. package/dist/cli/backend/src/constants.js.map +1 -1
  51. package/dist/cli/cli/src/commands/upgrade.d.ts +20 -2
  52. package/dist/cli/cli/src/commands/upgrade.d.ts.map +1 -1
  53. package/dist/cli/cli/src/commands/upgrade.js +84 -3
  54. package/dist/cli/cli/src/commands/upgrade.js.map +1 -1
  55. package/dist/cli/cli/src/index.js +3 -0
  56. package/dist/cli/cli/src/index.js.map +1 -1
  57. package/dist/cli/config/constants.d.ts +49 -0
  58. package/dist/cli/config/constants.d.ts.map +1 -1
  59. package/dist/cli/config/constants.js +50 -0
  60. package/dist/cli/config/constants.js.map +1 -1
  61. package/frontend/dist/assets/{index-83869ca7.js → index-726a1859.js} +2 -2
  62. package/frontend/dist/index.html +1 -1
  63. package/package.json +1 -1
@@ -378,7 +378,7 @@ This will create milestone directories and detailed task files in .crewly/tasks/
378
378
  📋 ${Jt} steps sent to ${Qe.name}
379
379
  ⏱️ Final step in ${Er} minutes
380
380
 
381
- 🔍 Monitor ${ct.name}'s terminal for progress.`,"Build Specs Started");const Xr=setInterval(()=>{le(Lr=>{if(!Lr.isActive)return Lr;const Yr=new Date,wr=Lr.steps.map(_r=>_r.status==="pending"&&_r.scheduledAt&&Yr>=_r.scheduledAt?{..._r,status:"scheduled"}:_r);return wr.every(_r=>_r.status==="scheduled")?(clearInterval(Xr),{...Lr,steps:wr}):{...Lr,steps:wr}})},3e4),ks=it.reduce((Lr,Yr)=>Lr+Yr.delayMinutes,0);setTimeout(()=>{clearInterval(Xr)},(ks+5)*6e4)}else throw new Error("Some Build Specs steps failed to schedule")}catch(kt){console.error("Error building specs:",kt),a("Failed to build specs: "+(kt instanceof Error?kt.message:"Unknown error"))}};if(fe.loading)return i.jsxDEV("div",{className:"flex items-center justify-center min-h-[400px]",children:i.jsxDEV("div",{className:"text-center",children:[i.jsxDEV("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4 mx-auto"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1337,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-text-secondary-dark",children:"Loading project..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1338,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1336,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1335,columnNumber:7},globalThis);if(fe.error||!fe.project)return i.jsxDEV("div",{className:"max-w-4xl mx-auto px-6 py-16",children:i.jsxDEV("div",{className:"text-center",children:[i.jsxDEV("h2",{className:"text-2xl font-bold mb-4",children:"Error Loading Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1348,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-text-secondary-dark",children:fe.error||"Project not found"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1349,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1347,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1346,columnNumber:7},globalThis);const{project:Nt,assignedTeams:Vt,tickets:Ee}=fe;return i.jsxDEV("div",{className:"max-w-7xl mx-auto px-6 py-8",children:[i.jsxDEV("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between gap-4 mb-8",children:[i.jsxDEV("div",{className:"flex-1",children:[i.jsxDEV("div",{className:"flex items-center gap-3 text-sm text-text-secondary-dark mb-1",children:[i.jsxDEV(Cb,{to:"/projects",className:"hover:text-primary",children:"Projects"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1363,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-text-secondary-dark",children:"/"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1364,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-text-primary-dark",children:Nt.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1365,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1362,columnNumber:11},globalThis),i.jsxDEV("h1",{className:"text-3xl font-bold tracking-tight mb-2",children:Nt.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1367,columnNumber:11},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("span",{className:"flex items-center gap-1 text-sm text-text-secondary-dark",children:[i.jsxDEV(rl,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1370,columnNumber:15},globalThis),Nt.path]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1369,columnNumber:13},globalThis),i.jsxDEV(pr,{variant:"secondary",size:"sm",icon:IC,onClick:Cr,title:"Open project folder in Finder",children:"Open in Finder"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1373,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1368,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1361,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3",children:[Nt.status==="active"?i.jsxDEV(pr,{variant:"warning",icon:fV,onClick:pt,disabled:fe.loading,title:"Stop project and cancel scheduled messages",children:"Stop Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1388,columnNumber:13},globalThis):i.jsxDEV(pr,{variant:"primary",icon:Pp,onClick:Pe,disabled:fe.loading||Vt.length===0,loading:fe.loading,title:Vt.length===0?"Assign a team before starting the project":"Start project with assigned teams",children:fe.loading?"Starting...":"Start Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1398,columnNumber:13},globalThis),i.jsxDEV(bx,{align:"bottom-right",items:[{label:"Assign Team",onClick:Fe},...g==="tasks"?[{label:"Create Task",onClick:()=>Ce(!0)},{label:"Create Milestone",onClick:()=>Ke(!0)}]:[],{label:"Delete Project",onClick:ot,danger:!0}]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1410,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1385,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1360,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex gap-1 mb-6 border-b border-border-dark",children:[i.jsxDEV("button",{className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${g==="detail"?"border-primary text-primary":"border-transparent text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>Ye("detail"),children:[i.jsxDEV(kk,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1448,columnNumber:11},globalThis),"Detail"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1440,columnNumber:9},globalThis),i.jsxDEV("button",{className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${g==="editor"?"border-primary text-primary":"border-transparent text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>Ye("editor"),children:[i.jsxDEV(rl,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1459,columnNumber:11},globalThis),"Editor"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1451,columnNumber:9},globalThis),i.jsxDEV("button",{className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${g==="tasks"?"border-primary text-primary":"border-transparent text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>Ye("tasks"),children:[i.jsxDEV(fK,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1470,columnNumber:11},globalThis),"Tasks (",Ee.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1462,columnNumber:9},globalThis),i.jsxDEV("button",{className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${g==="teams"?"border-primary text-primary":"border-transparent text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>Ye("teams"),children:[i.jsxDEV(h4,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1481,columnNumber:11},globalThis),"Teams (",Vt.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1473,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1439,columnNumber:7},globalThis),i.jsxDEV("div",{children:g==="detail"?i.jsxDEV(jY,{project:Nt,onAddGoal:gt,onEditGoal:Ft,onAddUserJourney:Zt,onEditUserJourney:Hr,onBuildSpecs:Dr,onBuildTasks:ws,buildSpecsWorkflow:oe,alignmentStatus:ue,onContinueWithMisalignment:q,onViewAlignment:ge,selectedBuildSpecsTeam:ae,setSelectedBuildSpecsTeam:De,selectedBuildTasksTeam:Te,setSelectedBuildTasksTeam:Ve,availableTeams:me,onCreateSpecsTasks:qe,onCreateDevTasks:Ue,onCreateE2ETasks:nt},Nt.updatedAt,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1489,columnNumber:11},globalThis):g==="editor"?i.jsxDEV(_Y,{project:Nt,selectedFile:N,onFileSelect:j,setIsMarkdownEditorOpen:T},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1512,columnNumber:11},globalThis):g==="tasks"?i.jsxDEV("div",{children:[re.length>0&&i.jsxDEV("div",{className:"mb-4",children:[i.jsxDEV("button",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary-dark hover:text-primary mb-2",onClick:()=>Ge(!He),children:[i.jsxDEV("svg",{className:`w-4 h-4 transition-transform ${He?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1528,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1527,columnNumber:19},globalThis),"Task Flow (",re.length," active)"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1523,columnNumber:17},globalThis),He&&i.jsxDEV("div",{className:"rounded-lg border border-border-dark bg-surface-dark p-3",children:i.jsxDEV(A9,{tasks:re},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1534,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1533,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1522,columnNumber:15},globalThis),i.jsxDEV(EY,{project:Nt,tickets:Ee,onTicketsUpdate:()=>Ie(Nt.id),onCreateSpecsTasks:qe,onCreateDevTasks:Ue,onCreateE2ETasks:nt,loading:fe.loading,onTaskClick:ve,onTaskAssign:Se,onTaskUnblock:ke,taskAssignmentLoading:te,taskUnblockLoading:Z},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1540,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1519,columnNumber:11},globalThis):i.jsxDEV(kY,{assignedTeams:Vt,onUnassignTeam:We,openTerminalWithSession:r,onAssignTeam:Fe,projectName:Nt.name,onViewTeam:Ne=>t(`/teams/${Ne}`),onEditTeam:Ne=>t(`/teams/${Ne}?edit=true`)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1556,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1487,columnNumber:7},globalThis),b&&i.jsxDEV(NY,{project:Nt,onClose:()=>x(!1),onAssignmentComplete:st},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1570,columnNumber:9},globalThis),D&&i.jsxDEV(TY,{projectPath:Nt.path,onClose:()=>T(!1)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1579,columnNumber:9},globalThis),i.jsxDEV(DY,{isOpen:O,onClose:()=>{H(!1),ie(null)},task:J,onAssign:Se,taskAssignmentLoading:te},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1586,columnNumber:7},globalThis),E&&i.jsxDEV(ST,{isOpen:E,onClose:()=>k(!1),title:"Add Project Goal",subtitle:"Define your project's main objective and success criteria",onSubmit:Ne=>{Ne.preventDefault(),jt()},submitText:"Save Goal",size:"md",children:i.jsxDEV(ET,{children:[i.jsxDEV(Fr,{htmlFor:"goal-content",required:!0,children:"Project Goal"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1609,columnNumber:13},globalThis),i.jsxDEV($f,{id:"goal-content",value:M,onChange:Ne=>R(Ne.target.value),placeholder:"Describe your project's main objective, success criteria, and key outcomes...",rows:8,required:!0},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1612,columnNumber:13},globalThis),i.jsxDEV(fR,{children:"Define what you want to achieve with this project. Be specific about goals, target users, and success metrics."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1620,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1608,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1599,columnNumber:9},globalThis),U&&i.jsxDEV(ST,{isOpen:U,onClose:()=>V(!1),title:"Add User Journey",subtitle:"Map out how users will interact with your solution",onSubmit:Ne=>{Ne.preventDefault(),ur()},submitText:"Save User Journey",size:"md",children:i.jsxDEV(ET,{children:[i.jsxDEV(Fr,{htmlFor:"journey-content",required:!0,children:"User Journey"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1639,columnNumber:13},globalThis),i.jsxDEV($f,{id:"journey-content",value:P,onChange:Ne=>B(Ne.target.value),placeholder:"Describe your users' journey from discovery to success. Include user personas, key interactions, pain points, and desired outcomes...",rows:8,required:!0},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1642,columnNumber:13},globalThis),i.jsxDEV(fR,{children:"Map out how users will interact with your solution. Include user types, main flows, and critical touchpoints."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1650,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1638,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1629,columnNumber:9},globalThis),i.jsxDEV(c,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1658,columnNumber:7},globalThis),i.jsxDEV(f,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1659,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1358,columnNumber:5},globalThis)},Cf="/api/settings/roles";class zY{async listRoles(){const e=await ir.get(Cf);if(!e.data.success||!e.data.data)throw new Error(e.data.error||"Failed to get roles");return e.data.data}async getRole(e){const t=await ir.get(`${Cf}/${e}`);if(!t.data.success||!t.data.data)throw new Error(t.data.error||"Role not found");return t.data.data}async createRole(e){const t=await ir.post(Cf,e);if(!t.data.success||!t.data.data)throw new Error(t.data.error||"Failed to create role");return t.data.data}async updateRole(e,t){const r=await ir.put(`${Cf}/${e}`,t);if(!r.data.success||!r.data.data)throw new Error(r.data.error||"Failed to update role");return r.data.data}async deleteRole(e){const t=await ir.delete(`${Cf}/${e}`);if(!t.data.success)throw new Error(t.data.error||"Failed to delete role")}async assignSkills(e,t){const r=await ir.post(`${Cf}/${e}/skills`,{skillIds:t});if(!r.data.success||!r.data.data)throw new Error(r.data.error||"Failed to assign skills");return r.data.data}async removeSkills(e,t){const r=await ir.delete(`${Cf}/${e}/skills`,{data:{skillIds:t}});if(!r.data.success||!r.data.data)throw new Error(r.data.error||"Failed to remove skills");return r.data.data}async setDefaultRole(e){const t=await ir.post(`${Cf}/${e}/default`);if(!t.data.success||!t.data.data)throw new Error(t.data.error||"Failed to set default role");return t.data.data}async refreshFromDisk(){const e=await ir.post(`${Cf}/refresh`);if(!e.data.success)throw new Error(e.data.error||"Failed to refresh roles")}}const Of=new zY;function M9(){const[s,e]=F.useState(null),[t,r]=F.useState(!0),[n,o]=F.useState(null),a=F.useCallback(async()=>{r(!0),o(null);try{const g=await Of.listRoles();e(g)}catch(g){o(g instanceof Error?g.message:"Failed to load roles")}finally{r(!1)}},[]),c=F.useCallback(async g=>{await Of.createRole(g),await a()},[a]),u=F.useCallback(async(g,v)=>{await Of.updateRole(g,v),await a()},[a]),d=F.useCallback(async g=>{await Of.deleteRole(g),await a()},[a]),f=F.useCallback(async()=>{await a()},[a]),m=F.useCallback(async()=>{r(!0),o(null);try{await Of.refreshFromDisk();const g=await Of.listRoles();e(g)}catch(g){o(g instanceof Error?g.message:"Failed to refresh roles from disk")}finally{r(!1)}},[]);return F.useEffect(()=>{a()},[a]),{roles:s,isLoading:t,error:n,createRole:c,updateRole:u,deleteRole:d,refreshRoles:f,refreshFromDisk:m}}function U9(){const[s,e]=F.useState([]),[t,r]=F.useState(!0),[n,o]=F.useState(null),a=F.useCallback(async()=>{r(!0),o(null);try{const u=await fetch("/api/projects");if(!u.ok)throw new Error(`Failed to fetch projects: ${u.statusText}`);const d=await u.json(),f=d.success?d.data||[]:d||[];e(Array.isArray(f)?f:[])}catch(u){const d=u instanceof Error?u.message:"Failed to fetch projects";o(d),e([])}finally{r(!1)}},[]);F.useEffect(()=>{a()},[a]);const c=F.useMemo(()=>s.map(u=>({id:u.id,name:u.name,path:u.path})),[s]);return{projects:s,projectOptions:c,isLoading:t,error:n,refetch:a}}const WY="/api";function KY(){const[s,e]=F.useState([]),[t,r]=F.useState(!0),[n,o]=F.useState(null),a=F.useCallback(async u=>{r(!0),o(null);try{const d=await ir.get(`${WY}/teams`,{signal:u});d.data.success?e(d.data.data||[]):o(d.data.error||"Failed to load teams")}catch(d){if(ir.isCancel(d))return;const f=d instanceof Error?d.message:"Failed to load teams";o(f),console.error("useTeams: Failed to fetch teams:",d)}finally{r(!1)}},[]);F.useEffect(()=>{const u=new AbortController;return a(u.signal),()=>{u.abort()}},[a]);const c=F.useCallback(async()=>{await a()},[a]);return{teams:s,loading:t,error:n,refresh:c}}const Lp="/api/skills";async function XY(s){const e=new URLSearchParams;s!=null&&s.category&&e.set("category",s.category),s!=null&&s.roleId&&e.set("roleId",s.roleId),s!=null&&s.search&&e.set("search",s.search);const t=e.toString()?`${Lp}?${e}`:Lp,r=await fetch(t);if(!r.ok)throw new Error(`Failed to fetch skills: ${r.statusText}`);const n=await r.json();return n.data||n}async function ZY(s){const e=await fetch(`${Lp}/${s}`);if(!e.ok)throw e.status===404?new Error(`Skill not found: ${s}`):new Error(`Failed to fetch skill: ${e.statusText}`);const t=await e.json();return t.data||t}async function qY(s){const e=await fetch(Lp,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!e.ok){const r=await e.text();throw new Error(`Failed to create skill: ${r}`)}const t=await e.json();return t.data||t}async function YY(s,e){const t=await fetch(`${Lp}/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.text();throw new Error(`Failed to update skill: ${n}`)}const r=await t.json();return r.data||r}async function JY(s){const e=await fetch(`${Lp}/${s}`,{method:"DELETE"});if(!e.ok)throw new Error(`Failed to delete skill: ${e.statusText}`)}async function $Y(s,e){const t=await fetch(`${Lp}/${s}/execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:e})});if(!t.ok){const n=await t.text();throw new Error(`Failed to execute skill: ${n}`)}const r=await t.json();return r.data||r}async function QY(){const s=await fetch(`${Lp}/refresh`,{method:"POST"});if(!s.ok){const e=await s.text();throw new Error(`Failed to refresh skills: ${e}`)}}function XC(s={}){const{category:e,roleId:t,search:r,fetchOnMount:n=!0}=s,[o,a]=F.useState([]),[c,u]=F.useState(null),[d,f]=F.useState(n),[m,g]=F.useState(null),v=F.useCallback(async(k=!1)=>{f(!0),g(null);try{k&&await QY();const U={};e&&(U.category=e),t&&(U.roleId=t),r&&(U.search=r);const V=await XY(U);a(V)}catch(U){const V=U instanceof Error?U.message:"Failed to load skills";g(V),console.error("useSkills: Failed to fetch skills:",U)}finally{f(!1)}},[e,t,r]),N=F.useCallback(async k=>{try{const U=await ZY(k);u(U)}catch(U){const V=U instanceof Error?U.message:"Failed to load skill";g(V),console.error("useSkills: Failed to select skill:",U)}},[]),j=F.useCallback(()=>{u(null)},[]),b=F.useCallback(async k=>{const U=await qY(k);return await v(),U},[v]),x=F.useCallback(async(k,U)=>{const V=await YY(k,U);return await v(),(c==null?void 0:c.id)===k&&u(V),V},[v,c==null?void 0:c.id]),D=F.useCallback(async k=>{await JY(k),await v(),(c==null?void 0:c.id)===k&&u(null)},[v,c==null?void 0:c.id]),T=F.useCallback(async(k,U)=>$Y(k,U),[]),E=F.useCallback(async()=>{await v(!0)},[v]);return F.useEffect(()=>{n&&v(!1)},[n,v]),{skills:o,selectedSkill:c,loading:d,error:m,refresh:E,selectSkill:N,clearSelection:j,create:b,update:x,remove:D,execute:T}}const R9=({isOpen:s,onClose:e,onSubmit:t,team:r})=>{const{showWarning:n,AlertComponent:o}=Zp(),{roles:a,isLoading:c}=M9(),{projects:u,isLoading:d}=U9(),{teams:f,loading:m}=KY(),{skills:g,loading:v}=XC(),[N,j]=F.useState({name:"",projectPath:"",parentTeamId:""}),[b,x]=F.useState([]),[D,T]=F.useState({hierarchical:!1,leaderId:null,leaderIds:[]}),[E,k]=F.useState(!1),[U,V]=F.useState({}),[M,R]=F.useState({}),P=(a||[]).map(ee=>({key:ee.name,displayName:ee.displayName,promptFile:`${ee.name}-prompt.md`,description:ee.description||"",category:ee.category,hidden:!1,isDefault:ee.isDefault})),B=F.useCallback(async ee=>{if(M[ee])return M[ee];try{const ue=await Of.getRole(ee);return R(G=>({...G,[ee]:ue})),ue}catch(ue){return console.error("Failed to fetch role details:",ue),null}},[M]),O=ee=>{V(ue=>({...ue,[ee]:!ue[ee]}))},H=(ee,ue)=>{x(G=>G.map(ae=>{if(ae.id!==ee)return ae;const De=ae.skillOverrides||[],Te=De.includes(ue);return{...ae,skillOverrides:Te?De.filter(Ve=>Ve!==ue):[...De,ue]}}))},J=(ee,ue)=>{x(G=>G.map(ae=>{if(ae.id!==ee)return ae;const De=ae.excludedRoleSkills||[],Te=De.includes(ue);return{...ae,excludedRoleSkills:Te?De.filter(Ve=>Ve!==ue):[...De,ue]}}))},ie=ee=>{const ue=te(ee.role),G=ee.excludedRoleSkills||[];return ue.filter(ae=>!G.includes(ae))},te=ee=>{const ue=M[ee];return(ue==null?void 0:ue.assignedSkills)||[]},se=ee=>g.find(ue=>ue.id===ee);F.useEffect(()=>{var ee;if(r&&(j({name:r.name||"",projectPath:((ee=r.projectIds)==null?void 0:ee[0])||r.projectPath||"",parentTeamId:r.parentTeamId||""}),T({hierarchical:r.hierarchical||!1,leaderId:r.leaderId||null,leaderIds:r.leaderIds||(r.leaderId?[r.leaderId]:[])}),r.members&&Array.isArray(r.members))){const ue=r.members.map((G,ae)=>({...G,runtimeType:G.runtimeType||"claude-code",avatar:G.avatar||X[ae%X.length],skillOverrides:G.skillOverrides||[],excludedRoleSkills:G.excludedRoleSkills||[]}));x(ue),ue.forEach(G=>{G.role&&B(G.role)})}},[r,B]),F.useEffect(()=>{if(P.length>0&&b.length===0&&!r){const ue=P.filter(G=>G.isDefault).map((G,ae)=>({id:(ae+1).toString(),name:G.displayName,role:G.key,systemPrompt:`Load from ${G.promptFile}`,runtimeType:"claude-code",avatar:X[ae%X.length],skillOverrides:[],excludedRoleSkills:[]}));ue.length>0&&(x(ue),ue.forEach(G=>{B(G.role)}))}},[P,b.length,r,B]);const Z=ee=>{const{name:ue,value:G}=ee.target;j(ae=>({...ae,[ue]:G}))},Y=(ee,ue,G)=>{x(ae=>ae.map(De=>{if(De.id===ee){const Te={...De,[ue]:G};if(ue==="role"){const Ve=P.find(me=>me.key===G);Ve&&(Te.systemPrompt=`Load from ${Ve.promptFile}`),Te.skillOverrides=[],Te.excludedRoleSkills=[],B(G)}return Te}return De}))},X=["https://picsum.photos/seed/1/64","https://picsum.photos/seed/2/64","https://picsum.photos/seed/3/64","https://picsum.photos/seed/4/64","https://picsum.photos/seed/5/64","https://picsum.photos/seed/6/64"],z=()=>{const ee=(Math.max(...b.map(ae=>parseInt(ae.id)))+1).toString(),ue=P.find(ae=>ae.key==="fullstack-dev"),G={id:ee,name:"Fullstack Developer",role:"fullstack-dev",systemPrompt:ue?`Load from ${ue.promptFile}`:"Default fullstack developer prompt",runtimeType:"claude-code",avatar:X[b.length%X.length],skillOverrides:[],excludedRoleSkills:[]};x(ae=>[...ae,G]),B("fullstack-dev")},oe=ee=>{b.length>1&&x(ue=>ue.filter(G=>G.id!==ee))},le=async ee=>{if(ee.preventDefault(),!(!N.name.trim()||b.length===0)){for(const ue of b)if(!ue.name.trim()){n("All team members must have a name");return}k(!0);try{const ue=u.find(ae=>ae.id===N.projectPath),G={...N,members:b.map(ae=>({name:ae.name,role:ae.role,systemPrompt:ae.systemPrompt,runtimeType:ae.runtimeType,avatar:ae.avatar,skillOverrides:ae.skillOverrides||[],excludedRoleSkills:ae.excludedRoleSkills||[]})),projectIds:N.projectPath?[N.projectPath]:[],projectPath:ue?ue.path:void 0,parentTeamId:N.parentTeamId||null,hierarchical:D.hierarchical,leaderId:D.hierarchical?D.leaderId:void 0,leaderIds:D.hierarchical?D.leaderIds:void 0};await t(G)}catch(ue){console.error("Error submitting team:",ue)}finally{k(!1)}}},fe=ee=>{ee.preventDefault(),le(ee)};return s?i.jsxDEV(i.Fragment,{children:[i.jsxDEV("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:e,children:i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg w-full max-w-2xl m-4",onClick:ee=>ee.stopPropagation(),children:[i.jsxDEV("div",{className:"p-6",children:[i.jsxDEV("div",{className:"flex items-start justify-between",children:[i.jsxDEV("div",{children:[i.jsxDEV("h3",{className:"text-xl font-semibold text-text-primary-dark",children:r?"Edit Team":"Create New Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:347,columnNumber:17},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mt-1",children:r?"Modify team configuration and members":"Configure the details for your new AI agent team."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:350,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:346,columnNumber:15},globalThis),i.jsxDEV("button",{onClick:e,className:"w-8 h-8 -mt-1 -mr-1 rounded-lg hover:bg-background-dark flex items-center justify-center text-text-secondary-dark hover:text-text-primary-dark",children:i.jsxDEV("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:359,columnNumber:19},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:358,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:354,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:345,columnNumber:13},globalThis),i.jsxDEV("form",{onSubmit:fe,className:"mt-6 space-y-6 max-h-[60vh] overflow-y-auto pr-2",children:[i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"team-name",children:"Team Name"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:365,columnNumber:17},globalThis),i.jsxDEV(mn,{id:"team-name",type:"text",value:N.name,onChange:Z,name:"name",placeholder:"e.g., Frontend Wizards",required:!0},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:366,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:364,columnNumber:15},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"project-assignment",children:"Assigned Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:378,columnNumber:17},globalThis),i.jsxDEV(zc,{id:"project-assignment",value:N.projectPath||"",onChange:Z,name:"projectPath",children:[i.jsxDEV("option",{value:"",children:"No project assigned"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:385,columnNumber:19},globalThis),u.map(ee=>i.jsxDEV("option",{value:ee.id,children:ee.name},ee.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:387,columnNumber:21},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:379,columnNumber:17},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Optionally assign a project for this team to work on"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:390,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:377,columnNumber:15},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"parent-team",children:"Parent Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:396,columnNumber:17},globalThis),i.jsxDEV(zc,{id:"parent-team",value:N.parentTeamId||"",onChange:Z,name:"parentTeamId",children:[i.jsxDEV("option",{value:"",children:"None (Independent Team)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:403,columnNumber:19},globalThis),f.filter(ee=>ee.id!==(r==null?void 0:r.id)&&ee.id!=="orchestrator").map(ee=>i.jsxDEV("option",{value:ee.id,children:ee.name},ee.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:407,columnNumber:23},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:397,columnNumber:17},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Optionally link this team under a parent team for organization"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:410,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:395,columnNumber:15},globalThis),i.jsxDEV(C9,{config:D,onChange:T,members:b},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:415,columnNumber:15},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{children:"Team Members"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:422,columnNumber:17},globalThis),i.jsxDEV("div",{className:"space-y-4",children:[b.map((ee,ue)=>{var G,ae,De,Te;return i.jsxDEV("div",{className:"p-4 border border-border-dark rounded-lg space-y-4 bg-background-dark/50",children:[i.jsxDEV("div",{children:[i.jsxDEV(Fr,{children:"Avatar"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:427,columnNumber:25},globalThis),i.jsxDEV("div",{className:"flex items-center gap-4",children:[i.jsxDEV("img",{src:ee.avatar||X[0],alt:"Selected Avatar",className:"w-12 h-12 rounded-full ring-2 ring-primary/50"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:429,columnNumber:27},globalThis),i.jsxDEV("div",{className:"flex flex-wrap gap-2 flex-1",children:X.map(Ve=>i.jsxDEV("img",{src:Ve,alt:"Avatar option",onClick:()=>Y(ee.id,"avatar",Ve),className:`w-9 h-9 rounded-full cursor-pointer transition-all ${ee.avatar===Ve?"ring-2 ring-primary":"ring-2 ring-transparent hover:ring-primary/50"}`},Ve,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:436,columnNumber:31},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:434,columnNumber:27},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:428,columnNumber:25},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:426,columnNumber:23},globalThis),i.jsxDEV("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:`member-name-${ue}`,children:"Agent Name"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:449,columnNumber:27},globalThis),i.jsxDEV(mn,{id:`member-name-${ue}`,type:"text",value:ee.name,onChange:Ve=>Y(ee.id,"name",Ve.target.value),placeholder:"e.g., Agent Smith",required:!0},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:450,columnNumber:27},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:448,columnNumber:25},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:`member-role-${ue}`,children:"Role"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:460,columnNumber:27},globalThis),i.jsxDEV(zc,{id:`member-role-${ue}`,value:ee.role,onChange:Ve=>Y(ee.id,"role",Ve.target.value),required:!0,children:[i.jsxDEV("option",{value:"",children:"Select role"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:467,columnNumber:29},globalThis),P.filter(Ve=>!Ve.hidden).map(Ve=>i.jsxDEV("option",{value:Ve.key,children:Ve.displayName},Ve.key,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:469,columnNumber:31},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:461,columnNumber:27},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:459,columnNumber:25},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:447,columnNumber:23},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:`runtime-type-${ue}`,children:"Runtime Type"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:475,columnNumber:25},globalThis),i.jsxDEV(zc,{id:`runtime-type-${ue}`,value:ee.runtimeType,onChange:Ve=>Y(ee.id,"runtimeType",Ve.target.value),required:!0,children:[i.jsxDEV("option",{value:"claude-code",children:"Claude CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:482,columnNumber:27},globalThis),i.jsxDEV("option",{value:"gemini-cli",children:"Gemini CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:483,columnNumber:27},globalThis),i.jsxDEV("option",{value:"codex-cli",children:"Codex CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:484,columnNumber:27},globalThis),i.jsxDEV("option",{value:"crewly-agent",children:"Crewly Agent"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:485,columnNumber:27},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:476,columnNumber:25},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:474,columnNumber:23},globalThis),ee.role&&i.jsxDEV("div",{className:"border-t border-border-dark pt-3",children:[i.jsxDEV("button",{type:"button",onClick:()=>O(ee.id),className:"flex items-center gap-2 text-sm font-medium text-text-primary-dark hover:text-primary w-full",children:[U[ee.id]?i.jsxDEV(hx,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:498,columnNumber:31},globalThis):i.jsxDEV(Jf,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:500,columnNumber:31},globalThis),i.jsxDEV("span",{children:"Skills"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:502,columnNumber:29},globalThis),i.jsxDEV("span",{className:"text-xs text-text-secondary-dark ml-1",children:["(",ie(ee).length," from role",(((G=ee.excludedRoleSkills)==null?void 0:G.length)||0)>0&&` - ${(ae=ee.excludedRoleSkills)==null?void 0:ae.length} excluded`,(((De=ee.skillOverrides)==null?void 0:De.length)||0)>0&&` + ${(Te=ee.skillOverrides)==null?void 0:Te.length} additional`,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:503,columnNumber:29},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:492,columnNumber:27},globalThis),U[ee.id]&&i.jsxDEV("div",{className:"mt-3 space-y-2",children:[te(ee.role).length>0&&i.jsxDEV("div",{className:"space-y-1",children:[i.jsxDEV("p",{className:"text-xs text-text-secondary-dark font-medium uppercase tracking-wide",children:["From Role ",i.jsxDEV("span",{className:"font-normal",children:"(click to exclude for this member)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:516,columnNumber:47},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:515,columnNumber:35},globalThis),i.jsxDEV("div",{className:"flex flex-wrap gap-1.5",children:te(ee.role).map(Ve=>{var be;const me=se(Ve),Je=(be=ee.excludedRoleSkills)==null?void 0:be.includes(Ve);return i.jsxDEV("button",{type:"button",onClick:()=>J(ee.id,Ve),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md border transition-colors cursor-pointer ${Je?"bg-rose-500/10 border-rose-500/30 text-rose-400 hover:bg-rose-500/20":"bg-primary/10 border-primary/30 text-primary hover:bg-primary/20"}`,title:Je?`Click to re-enable "${(me==null?void 0:me.name)||Ve}" for this member`:`Click to exclude "${(me==null?void 0:me.name)||Ve}" for this member`,children:[Je?i.jsxDEV(ho,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:534,columnNumber:57},globalThis):i.jsxDEV(El,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:534,columnNumber:85},globalThis),(me==null?void 0:me.name)||Ve]},Ve,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:523,columnNumber:41},globalThis)})},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:518,columnNumber:35},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:514,columnNumber:33},globalThis),i.jsxDEV("div",{className:"space-y-1",children:[i.jsxDEV("p",{className:"text-xs text-text-secondary-dark font-medium uppercase tracking-wide",children:"Additional Skills"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:545,columnNumber:33},globalThis),v?i.jsxDEV("p",{className:"text-xs text-text-secondary-dark",children:"Loading skills..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:549,columnNumber:35},globalThis):i.jsxDEV("div",{className:"flex flex-wrap gap-1.5",children:[g.filter(Ve=>!te(ee.role).includes(Ve.id)).map(Ve=>{var Je;const me=(Je=ee.skillOverrides)==null?void 0:Je.includes(Ve.id);return i.jsxDEV("button",{type:"button",onClick:()=>H(ee.id,Ve.id),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md border transition-colors ${me?"bg-emerald-500/10 border-emerald-500/30 text-emerald-400":"bg-background-dark border-border-dark text-text-secondary-dark hover:border-primary/50 hover:text-text-primary-dark"}`,title:Ve.description,children:[me?i.jsxDEV(El,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:569,columnNumber:47},globalThis):i.jsxDEV($a,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:571,columnNumber:47},globalThis),Ve.name]},Ve.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:557,columnNumber:43},globalThis)}),g.filter(Ve=>!te(ee.role).includes(Ve.id)).length===0&&i.jsxDEV("p",{className:"text-xs text-text-secondary-dark",children:"No additional skills available"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:578,columnNumber:39},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:551,columnNumber:35},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:544,columnNumber:31},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:511,columnNumber:29},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:491,columnNumber:25},globalThis),i.jsxDEV("div",{className:"flex justify-end",children:i.jsxDEV("button",{type:"button",onClick:()=>oe(ee.id),className:"text-text-secondary-dark hover:text-red-500 h-auto p-0 text-sm flex items-center gap-1",children:[i.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:595,columnNumber:29},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:594,columnNumber:27},globalThis),"Delete Member"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:589,columnNumber:25},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:588,columnNumber:23},globalThis)]},ee.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:425,columnNumber:21},globalThis)}),i.jsxDEV("button",{type:"button",onClick:z,className:"w-full flex items-center justify-center gap-2 py-2 border-2 border-dashed border-border-dark rounded-lg text-text-secondary-dark hover:text-primary hover:border-primary transition-colors",children:[i.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:608,columnNumber:23},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:607,columnNumber:21},globalThis),i.jsxDEV("span",{children:"Add Team Member"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:610,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:602,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:423,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:421,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:363,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:344,columnNumber:11},globalThis),i.jsxDEV("div",{className:"bg-background-dark px-6 py-4 rounded-b-xl border-t border-border-dark flex justify-end gap-3",children:[i.jsxDEV(pr,{variant:"secondary",onClick:e,type:"button",children:"Cancel"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:617,columnNumber:13},globalThis),i.jsxDEV(pr,{variant:"primary",type:"submit",onClick:fe,disabled:!N.name.trim()||b.length===0||E||c||d||m,children:E?i.jsxDEV("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-current border-t-transparent"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:627,columnNumber:17},globalThis):i.jsxDEV("span",{className:"inline-flex items-center gap-2",children:[i.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:r?"M5 13l4 4L19 7":"M12 6v6m0 0v6m0-6h6m-6 0H6"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:631,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:630,columnNumber:19},globalThis),r?"Save Changes":"Create Team"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:629,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:620,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:616,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:343,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:342,columnNumber:7},globalThis),i.jsxDEV(o,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:640,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:341,columnNumber:5},globalThis):null},eJ=({member:s,teamId:e,onClose:t})=>{const[r,n]=F.useState(null),[o,a]=F.useState(!1),[c,u]=F.useState(null),[d,f]=F.useState(!1),[m,g]=F.useState(null),[v,N]=F.useState(!1),[j,b]=F.useState("prompt"),x=F.useRef(null);F.useEffect(()=>(D(),()=>{E()}),[s.id,e]);const D=async()=>{if(!s.sessionName){u("No active session for this team member");return}try{a(!0),u(null),tr.isConnected()||await tr.connect(),T(),tr.subscribeToSession(s.sessionName),await k()}catch(B){console.error("Error initializing terminal:",B),u("Failed to connect to terminal"),N(!1)}finally{a(!1)}},T=()=>{if(!s.sessionName)return;const B=te=>{te.sessionName===s.sessionName&&(n(se=>({...se,memberId:s.id,memberName:s.name,sessionName:s.sessionName,output:te.content,timestamp:te.timestamp})),setTimeout(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},10))},O=te=>{te.sessionName===s.sessionName&&(n({memberId:s.id,memberName:s.name,sessionName:s.sessionName,output:te.content,timestamp:te.timestamp}),N(!0),u(null))},H=te=>{te.sessionName===s.sessionName&&(console.log("Successfully subscribed to session:",te.sessionName),N(!0),u(null))},J=te=>{te.sessionName===s.sessionName&&(console.error("WebSocket error for session:",te),u(te.error||"WebSocket error occurred"),N(!1))},ie=()=>{N(!0)};return tr.on("terminal_output",B),tr.on("initial_terminal_state",O),tr.on("subscription_confirmed",H),tr.on("error",J),tr.on("connected",ie),()=>{tr.off("terminal_output",B),tr.off("initial_terminal_state",O),tr.off("subscription_confirmed",H),tr.off("error",J),tr.off("connected",ie)}},E=()=>{m&&clearInterval(m),s.sessionName&&tr.isConnected()&&tr.unsubscribeFromSession(s.sessionName)};F.useEffect(()=>{if(d){const B=setInterval(()=>{k()},15e3);g(B)}else m&&(clearInterval(m),g(null));return()=>{m&&clearInterval(m)}},[d]);const k=async()=>{if(!s.sessionName){u("No active session for this team member");return}a(!0),u(null);try{const B=await fetch(`/api/teams/${e}/members/${s.id}/session?lines=100`);if(B.ok){const O=await B.json();O.success?n(O.data):u(O.error||"Failed to fetch session data")}else{const O=await B.json();u(O.error||"Failed to fetch session data")}}catch(B){u("Network error while fetching session data"),console.error("Error fetching session data:",B)}finally{a(!1)}},U=B=>{B.target===B.currentTarget&&t()},V=B=>({orchestrator:"#8b5cf6",pm:"#3b82f6",developer:"#10b981",qa:"#f59e0b",tester:"#ef4444",designer:"#ec4899"})[B]||"#6b7280",M=B=>({inactive:"#6b7280",activating:"#f59e0b",active:"#059669"})[B]||"#6b7280",R=B=>({idle:"#6b7280",in_progress:"#10b981"})[B]||"#6b7280",P=B=>new Date(B).toLocaleString();return i.jsxDEV("div",{className:"modal-overlay",onClick:U,children:i.jsxDEV("div",{className:"modal-content member-modal-content",children:[i.jsxDEV("div",{className:"modal-header",children:[i.jsxDEV("div",{className:"member-header-info",children:[i.jsxDEV("h2",{children:s.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:260,columnNumber:13},globalThis),i.jsxDEV("div",{className:"member-badges",children:[i.jsxDEV("span",{className:"role-badge",style:{backgroundColor:V(s.role)},children:s.role},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:262,columnNumber:15},globalThis),i.jsxDEV("span",{className:"status-badge",style:{backgroundColor:M(s.agentStatus)},children:["Agent: ",s.agentStatus]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:268,columnNumber:15},globalThis),i.jsxDEV("span",{className:"status-badge",style:{backgroundColor:R(s.workingStatus)},children:["Work: ",s.workingStatus]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:274,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:261,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:259,columnNumber:11},globalThis),i.jsxDEV("button",{className:"close-button",onClick:t,children:"×"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:282,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:258,columnNumber:9},globalThis),i.jsxDEV("div",{className:"member-tabs",children:[i.jsxDEV("button",{className:`tab-button ${j==="prompt"?"active":""}`,onClick:()=>b("prompt"),children:"System Prompt"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:287,columnNumber:11},globalThis),i.jsxDEV("button",{className:`tab-button ${j==="terminal"?"active":""}`,onClick:()=>b("terminal"),children:"Terminal Output"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:293,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:286,columnNumber:9},globalThis),i.jsxDEV("div",{className:"member-modal-body",children:[j==="prompt"&&i.jsxDEV("div",{className:"system-prompt-panel",children:i.jsxDEV("div",{className:"system-prompt-content",children:i.jsxDEV("pre",{className:"system-prompt-text",children:s.systemPrompt},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:306,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:305,columnNumber:15},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:304,columnNumber:13},globalThis),j==="terminal"&&i.jsxDEV("div",{className:"terminal-panel",children:[i.jsxDEV("div",{className:"terminal-header",children:[i.jsxDEV("div",{className:"terminal-header-left",children:s.sessionName&&i.jsxDEV("span",{className:"session-name",children:["Session: ",s.sessionName]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:319,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:317,columnNumber:17},globalThis),i.jsxDEV("div",{className:"terminal-controls",children:[i.jsxDEV("div",{className:"connection-status",children:i.jsxDEV("span",{className:`status-indicator ${v?"connected":"disconnected"}`,children:v?"🟢 Live":"🔴 Offline"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:324,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:323,columnNumber:19},globalThis),i.jsxDEV("label",{className:"auto-refresh-toggle",children:[i.jsxDEV("input",{type:"checkbox",checked:d,onChange:B=>f(B.target.checked),disabled:v},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:329,columnNumber:21},globalThis),"Auto-refresh (fallback)"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:328,columnNumber:19},globalThis),i.jsxDEV(pr,{className:"refresh-button",onClick:k,disabled:o||v,variant:"secondary",size:"sm",children:o?"Loading...":"Manual Refresh"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:337,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:322,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:316,columnNumber:15},globalThis),i.jsxDEV("div",{className:"terminal-output",children:[o&&!r&&i.jsxDEV("div",{className:"loading-state",children:[i.jsxDEV("div",{className:"loading-spinner"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:352,columnNumber:21},globalThis),i.jsxDEV("p",{children:"Loading session data..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:353,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:351,columnNumber:19},globalThis),c&&i.jsxDEV("div",{className:"error-state",children:[i.jsxDEV("p",{children:["Error: ",c]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:359,columnNumber:21},globalThis),i.jsxDEV(pr,{onClick:k,className:"retry-button",variant:"outline",size:"sm",children:"Retry"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:360,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:358,columnNumber:19},globalThis),r&&i.jsxDEV("div",{className:"session-data",children:[i.jsxDEV("div",{className:"session-meta",children:i.jsxDEV("span",{children:["Last updated: ",P(r.timestamp)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:369,columnNumber:23},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:368,columnNumber:21},globalThis),i.jsxDEV("pre",{className:"terminal-content",ref:x,children:r.output||"No output available"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:371,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:367,columnNumber:19},globalThis),!o&&!c&&!r&&i.jsxDEV("div",{className:"empty-state",children:i.jsxDEV("p",{children:"No session data available"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:379,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:378,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:349,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:315,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:301,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:257,columnNumber:7},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:256,columnNumber:5},globalThis)},tJ=({team:s,onClick:e,onViewTeam:t,onEditTeam:r,onDeleteTeam:n,projectName:o})=>{var u;const a=s.members||[],c=a.some(d=>d.agentStatus==="active");return i.jsxDEV("div",{className:"flex items-center justify-between p-4 bg-surface-dark rounded-lg border border-border-dark hover:bg-background-dark hover:border-primary/50 transition-colors group",children:[i.jsxDEV("div",{className:"flex items-center gap-4 flex-grow cursor-pointer",onClick:e,children:[i.jsxDEV("div",{className:"p-3 bg-background-dark rounded-lg border border-transparent group-hover:border-primary/20 transition-colors",children:i.jsxDEV($o,{className:"text-text-secondary-dark group-hover:text-primary transition-colors"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:34,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:33,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("div",{children:[i.jsxDEV("p",{className:"font-semibold text-text-primary-dark",children:s.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:38,columnNumber:13},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:o||(((u=s.projectIds)==null?void 0:u.length)>0?s.projectIds.join(", "):"No Project")},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:39,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:37,columnNumber:11},globalThis),c&&i.jsxDEV("span",{className:"px-2 py-1 text-xs font-medium rounded-full bg-green-500/10 text-green-400",children:"Active"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:42,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:36,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:29,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex items-center gap-6",children:[i.jsxDEV("div",{className:"hidden md:flex -space-x-2",children:[a.slice(0,4).map((d,f)=>i.jsxDEV(T9,{name:d.name,avatar:d.avatar,size:"sm",className:"border-2 border-surface-dark"},d.id||f,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:51,columnNumber:13},globalThis)),a.length>4&&i.jsxDEV("div",{className:"w-8 h-8 rounded-full border-2 border-surface-dark bg-background-dark flex items-center justify-center text-xs font-medium text-text-secondary-dark",children:["+",a.length-4]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:60,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:49,columnNumber:9},globalThis),i.jsxDEV("div",{className:"hidden sm:flex items-center gap-2 text-sm text-text-secondary-dark w-28",children:[i.jsxDEV($o,{className:"text-base"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:66,columnNumber:11},globalThis),i.jsxDEV("span",{children:[a.length," Members"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:67,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:65,columnNumber:9},globalThis),i.jsxDEV("div",{onClick:d=>d.preventDefault(),children:i.jsxDEV(bx,{align:"bottom-right",items:[...t?[{label:"View Team",onClick:()=>t(s.id)}]:[],...r?[{label:"Edit Team",onClick:()=>r(s.id)}]:[],...n?[{label:"Delete Team",danger:!0,onClick:()=>n(s.id)}]:[]]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:70,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:69,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:48,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:28,columnNumber:5},globalThis)},SP=3e4,rJ=3e5,sJ=2;function nJ(s,e,t,r){const[n,o]=F.useState([]),[a,c]=F.useState(!1),[u,d]=F.useState(null),f=F.useRef(null),m=F.useRef(!0),g=F.useRef(0),v=F.useRef(s),N=F.useRef(t),j=F.useRef(r),b=F.useRef(e);v.current=s,N.current=t,j.current=r,b.current=e;const x=F.useCallback(()=>g.current===0?SP:Math.min(SP*Math.pow(sJ,g.current),rJ),[]),D=F.useCallback(()=>{if(!m.current||!b.current)return;f.current&&clearTimeout(f.current);const k=x();f.current=setTimeout(()=>{T()},k)},[x]),T=F.useCallback(async()=>{const k=v.current;if(!k||!m.current)return;const U={"Content-Type":"application/json",Authorization:`Bearer ${k}`};try{await fetch(`${xP}/devices/heartbeat`,{method:"POST",headers:U,body:JSON.stringify({deviceName:j.current,teams:N.current})});const M=await(await fetch(`${xP}/devices`,{headers:U})).json();m.current&&M.success&&(o(M.data||[]),d(null),g.current=0)}catch(V){m.current&&(g.current=Math.min(g.current+1,10),d(V instanceof Error?V.message:"Heartbeat failed"))}D()},[D]),E=F.useCallback(async()=>{c(!0),g.current=0,await T(),m.current&&c(!1)},[T]);return F.useEffect(()=>{if(m.current=!0,!e||!s){o([]),g.current=0;return}return c(!0),T().finally(()=>{m.current&&c(!1)}),()=>{m.current=!1,f.current&&(clearTimeout(f.current),f.current=null)}},[e,s,T]),{devices:n,isLoading:a,error:u,refresh:E}}function oJ(){const[s,e]=F.useState(null),[t,r]=F.useState(!0),[n,o]=F.useState(!1),[a,c]=F.useState(null),u=F.useRef(!0),d=F.useCallback(async()=>{try{const v=await es.getCloudStatus();u.current&&(e(v),c(null))}catch{u.current&&e({connected:!1,tier:null,cloudUrl:null,status:"disconnected"})}},[]);F.useEffect(()=>(u.current=!0,(async()=>{await d(),u.current&&r(!1)})(),()=>{u.current=!1}),[d]);const f=F.useCallback(async(v,N)=>{o(!0),c(null);try{const j=await es.connectToCloud(v,N);return u.current&&e({connected:j.connected,tier:j.tier,cloudUrl:j.cloudUrl,status:"connected"}),!0}catch(j){return u.current&&c(j instanceof Error?j.message:"Connection failed"),!1}finally{u.current&&o(!1)}},[]),m=F.useCallback(async()=>{o(!0),c(null);try{return await es.disconnectFromCloud(),u.current&&e({connected:!1,tier:null,cloudUrl:null,status:"disconnected"}),!0}catch(v){return u.current&&c(v instanceof Error?v.message:"Disconnect failed"),!1}finally{u.current&&o(!1)}},[]),g=F.useCallback(async()=>{await d()},[d]);return{isConnected:(s==null?void 0:s.connected)??!1,tier:(s==null?void 0:s.tier)??null,isLoading:t,isActioning:n,error:a,connect:f,disconnect:m,refresh:g}}const EP=["https://picsum.photos/seed/1/64","https://picsum.photos/seed/2/64","https://picsum.photos/seed/3/64","https://picsum.photos/seed/4/64","https://picsum.photos/seed/5/64","https://picsum.photos/seed/6/64"];function V9(s){return s.map((e,t)=>({...e,avatar:e.avatar||EP[t%EP.length]}))}const iJ=()=>{const s=gh(),[e,t]=F.useState([]),[r,n]=F.useState(""),[o,a]=F.useState("all"),[c,u]=F.useState(!1),[d,f]=F.useState(null),[m,g]=F.useState(""),[v,N]=F.useState(!0),[j,b]=F.useState("grid"),[x,D]=F.useState([]),{showError:T,AlertComponent:E}=Zp(),k=Object.fromEntries(x.map(ee=>[ee.id,ee.name])),[U,V]=F.useState("all"),{isConnected:M,tier:R}=oJ(),{getAccessToken:P}=t9(),B=M&&R==="pro"?P():null,O=F.useMemo(()=>e.map(ee=>({id:ee.id,name:ee.name,memberCount:ee.members.length})),[e]),H=M&&R==="pro",{devices:J,isLoading:ie,refresh:te}=nJ(B,H,O,typeof window<"u"&&window.location.hostname||"My Device"),se=F.useMemo(()=>{let ee=e;return r&&(ee=ee.filter(ue=>{var G;return ue.name.toLowerCase().includes(r.toLowerCase())||ue.description&&ue.description.toLowerCase().includes(r.toLowerCase())||((G=ue.projectIds)==null?void 0:G.length)>0&&ue.projectIds.some(ae=>ae.toLowerCase().includes(r.toLowerCase()))||ue.members.some(ae=>ae.name.toLowerCase().includes(r.toLowerCase())||ae.role.toLowerCase().includes(r.toLowerCase()))})),o!=="all"&&(ee=ee.filter(ue=>o==="active"?ue.members.some(G=>G.agentStatus==="active"):o==="inactive"?ue.members.every(G=>G.agentStatus==="inactive"):!0)),U!=="all"&&(ee=ee.filter(ue=>{var G;return(G=ue.projectIds)==null?void 0:G.includes(U)})),ee},[e,r,o,U]),Z=F.useMemo(()=>{const ee=new Map;for(const ue of se)ue.parentTeamId&&ee.set(ue.parentTeamId,(ee.get(ue.parentTeamId)||0)+1);return ee},[se]),Y=F.useCallback(ee=>{t(ue=>ue.map(G=>G.id===ee.teamId?{...G,members:G.members.map(ae=>ae.id===ee.memberId||ae.sessionName===ee.sessionName?{...ae,agentStatus:ee.agentStatus}:ae)}:G))},[]);F.useEffect(()=>{z(),X()},[]),F.useEffect(()=>(tr.on("team_member_status_changed",Y),()=>{tr.off("team_member_status_changed",Y)}),[Y]);const X=async()=>{try{const ee=await es.getProjects();D(ee.map(ue=>({id:ue.id,name:ue.name})))}catch(ee){kp(ee,{context:"Loading projects for filter"})}},z=async()=>{try{const ue=(await es.getTeams()).map(G=>({...G,members:V9(G.members)}));t(ue)}catch(ee){kp(ee,{context:"fetchTeams"}),t([])}finally{N(!1)}},oe=async ee=>{try{const ue=await fetch("/api/teams",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)});if(ue.ok){const G=await ue.json(),ae=G.success?G.data:G;ae&&(t(De=>[...De,ae]),u(!1))}else{const G=await ue.json();T("Error creating team: "+(G.error||"Unknown error"))}}catch(ue){kp(ue,{context:"handleCreateTeam"}),T("Error creating team: "+(ue instanceof Error?ue.message:"Unknown error"))}},le=ee=>{s(`/teams/${ee.id}`)},fe=()=>{f(null),g("")};return v?i.jsxDEV("div",{className:"flex items-center justify-center min-h-[400px]",children:i.jsxDEV("div",{className:"text-center",children:[i.jsxDEV("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4 mx-auto"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:211,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-text-secondary-dark",children:"Loading teams..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:212,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:210,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:209,columnNumber:7},globalThis):i.jsxDEV("div",{className:"max-w-7xl mx-auto",children:[i.jsxDEV("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between gap-4 mb-8",children:[i.jsxDEV("div",{children:[i.jsxDEV("h2",{className:"text-3xl font-bold tracking-tight",children:"Teams"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:222,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Manage and organize your development teams"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:223,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:221,columnNumber:9},globalThis),i.jsxDEV("button",{className:"bg-primary text-white px-4 py-2 rounded-lg hover:bg-primary/90 transition-colors flex items-center gap-2",onClick:()=>u(!0),children:[i.jsxDEV($a,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:230,columnNumber:11},globalThis),"New Team"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:226,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:220,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex flex-col md:flex-row items-center gap-4 mb-3",children:i.jsxDEV("div",{className:"relative flex-grow w-full md:w-auto",children:i.jsxDEV("input",{type:"text",placeholder:"Search teams...",value:r,onChange:ee=>n(ee.target.value),className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2.5 text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary transition-colors"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:238,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:237,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:236,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4 mb-6",children:[i.jsxDEV("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Status:"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:251,columnNumber:11},globalThis),i.jsxDEV("button",{className:`chip ${o==="all"?"chip--active":""}`,onClick:()=>a("all"),children:"All"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:252,columnNumber:11},globalThis),i.jsxDEV("button",{className:`chip ${o==="active"?"chip--active":""}`,onClick:()=>a("active"),children:"Active"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:253,columnNumber:11},globalThis),i.jsxDEV("button",{className:`chip ${o==="inactive"?"chip--active":""}`,onClick:()=>a("inactive"),children:"Inactive"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:254,columnNumber:11},globalThis),i.jsxDEV("span",{className:"ml-2 text-sm text-text-secondary-dark",children:"Project:"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:255,columnNumber:11},globalThis),i.jsxDEV("select",{value:U,onChange:ee=>V(ee.target.value),className:"bg-surface-dark border border-border-dark rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",children:[i.jsxDEV("option",{value:"all",children:"All"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:261,columnNumber:13},globalThis),x.map(ee=>i.jsxDEV("option",{value:ee.id,children:ee.name},ee.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:263,columnNumber:15},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:256,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:250,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("button",{onClick:()=>b("grid"),className:`inline-flex items-center justify-center w-9 h-9 rounded-lg border border-border-dark ${j==="grid"?"bg-primary/10 text-primary":"text-text-secondary-dark hover:text-text-primary-dark hover:border-primary/50"}`,title:"Grid view",children:i.jsxDEV(vK,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:273,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:268,columnNumber:11},globalThis),i.jsxDEV("button",{onClick:()=>b("list"),className:`inline-flex items-center justify-center w-9 h-9 rounded-lg border border-border-dark ${j==="list"?"bg-primary/10 text-primary":"text-text-secondary-dark hover:text-text-primary-dark hover:border-primary/50"}`,title:"List view",children:i.jsxDEV(NK,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:280,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:275,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:267,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:249,columnNumber:7},globalThis),H&&i.jsxDEV("div",{className:"mb-8",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV(fx,{className:"w-4 h-4 text-primary"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:290,columnNumber:15},globalThis),i.jsxDEV("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide",children:["Online Devices (",J.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:291,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:289,columnNumber:13},globalThis),i.jsxDEV("button",{onClick:te,className:"p-1.5 text-text-secondary-dark hover:text-text-primary-dark rounded-lg hover:bg-surface-dark transition-colors",title:"Refresh devices",children:i.jsxDEV(dc,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:300,columnNumber:15},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:295,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:288,columnNumber:11},globalThis),ie?i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-6 text-center",children:[i.jsxDEV("div",{className:"w-5 h-5 border-2 border-primary/20 border-t-primary rounded-full animate-spin mx-auto mb-2"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:306,columnNumber:15},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark",children:"Discovering devices..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:307,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:305,columnNumber:13},globalThis):J.length===0?i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-6 text-center",children:[i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:"No other devices online"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:311,columnNumber:15},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark/70 mt-1",children:"Other Pro users will appear here when they are online"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:312,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:310,columnNumber:13},globalThis):i.jsxDEV("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:J.map(ee=>i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-4",children:[i.jsxDEV("div",{className:"flex items-center gap-2 mb-2",children:[i.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:324,columnNumber:21},globalThis),i.jsxDEV("span",{className:"text-sm font-medium text-text-primary-dark truncate",children:ee.deviceName},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:325,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:323,columnNumber:19},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mb-3 font-mono truncate",children:ee.email},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:329,columnNumber:19},globalThis),ee.teams.length>0&&i.jsxDEV("div",{className:"space-y-1.5",children:[i.jsxDEV("p",{className:"text-xs text-text-secondary-dark/70 uppercase tracking-wide",children:["Teams (",ee.teams.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:334,columnNumber:23},globalThis),ee.teams.map(ue=>i.jsxDEV("div",{className:"flex items-center justify-between text-xs bg-background-dark rounded px-2 py-1.5",children:[i.jsxDEV("span",{className:"text-text-primary-dark truncate",children:ue.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:342,columnNumber:27},globalThis),i.jsxDEV("span",{className:"text-text-secondary-dark ml-2 shrink-0",children:[ue.memberCount," member",ue.memberCount!==1?"s":""]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:343,columnNumber:27},globalThis)]},ue.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:338,columnNumber:25},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:333,columnNumber:21},globalThis)]},ee.deviceId,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:319,columnNumber:17},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:317,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:287,columnNumber:9},globalThis),se.length>0&&i.jsxDEV(i.Fragment,{children:j==="grid"?i.jsxDEV("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6",children:[se.map(ee=>{var ue;return i.jsxDEV(j9,{team:ee,projectName:((ue=ee.projectIds)==null?void 0:ue.length)>0?k[ee.projectIds[0]]:void 0,subTeamCount:Z.get(ee.id),onClick:()=>le(ee),onViewTeam:G=>s(`/teams/${G}`),onEditTeam:G=>s(`/teams/${G}?edit=true`)},ee.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:363,columnNumber:17},globalThis)}),i.jsxDEV("div",{onClick:()=>u(!0),className:"flex items-center justify-center p-5 rounded-xl border-2 border-dashed border-border-dark hover:border-primary transition-colors cursor-pointer text-text-secondary-dark hover:text-primary",children:[i.jsxDEV($a,{className:"mr-2 w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:377,columnNumber:17},globalThis),i.jsxDEV("span",{children:"Create New Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:378,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:373,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:361,columnNumber:13},globalThis):i.jsxDEV("div",{className:"space-y-4",children:[se.map(ee=>{var ue;return i.jsxDEV(tJ,{team:ee,projectName:((ue=ee.projectIds)==null?void 0:ue.length)>0?k[ee.projectIds[0]]:void 0,onClick:()=>le(ee),onViewTeam:G=>s(`/teams/${G}`),onEditTeam:G=>s(`/teams/${G}?edit=true`),onDeleteTeam:async G=>{if(window.confirm("Are you sure you want to delete this team?"))try{await es.deleteTeam(G),t(ae=>ae.filter(De=>De.id!==G))}catch(ae){T("Failed to delete team: "+(ae instanceof Error?ae.message:"Unknown error"))}}},ee.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:384,columnNumber:17},globalThis)}),i.jsxDEV("div",{onClick:()=>u(!0),className:"flex items-center justify-center p-4 rounded-lg border-2 border-dashed border-border-dark hover:border-primary transition-colors cursor-pointer text-text-secondary-dark hover:text-primary",children:[i.jsxDEV($a,{className:"mr-2 w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:407,columnNumber:17},globalThis),i.jsxDEV("span",{children:"Create New Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:408,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:403,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:382,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:359,columnNumber:9},globalThis),se.length===0&&!v&&i.jsxDEV("div",{className:"text-center py-16",children:[i.jsxDEV("h3",{className:"text-lg font-semibold mb-2",children:"No teams found"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:417,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mb-6",children:r||o!=="all"?"Try adjusting your search or filters":"Create your first team to get started"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:418,columnNumber:11},globalThis),!r&&o==="all"&&i.jsxDEV("button",{className:"bg-primary text-white px-6 py-3 rounded-lg hover:bg-primary/90 transition-colors inline-flex items-center gap-2",onClick:()=>u(!0),children:[i.jsxDEV($a,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:428,columnNumber:15},globalThis),"Create Team"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:424,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:416,columnNumber:9},globalThis),i.jsxDEV(R9,{isOpen:c,onClose:()=>u(!1),onSubmit:oe},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:435,columnNumber:7},globalThis),d&&m&&i.jsxDEV(eJ,{member:d,teamId:m,onClose:fe},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:442,columnNumber:9},globalThis),i.jsxDEV(E,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:448,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:219,columnNumber:5},globalThis)},aJ=({isOpen:s,onClose:e,onStartTeam:t,team:r,loading:n})=>{var x,D;const{showWarning:o,AlertComponent:a}=Zp(),[c,u]=F.useState(""),[d,f]=F.useState([]),[m,g]=F.useState(!1),v=((x=r==null?void 0:r.projectIds)==null?void 0:x.length)>0;F.useEffect(()=>{s&&(N(),v&&u(r.projectIds[0]))},[s,v,r==null?void 0:r.projectIds]);const N=async()=>{g(!0);try{const T=await fetch("/api/projects");if(T.ok){const E=await T.json(),k=E.success?E.data||[]:E||[];f(Array.isArray(k)?k:[])}}catch(T){console.error("Error fetching projects:",T),f([])}finally{g(!1)}},j=T=>{if(T.preventDefault(),!v&&!c){o("Please select a project");return}const E=v?r.projectIds[0]:c;t(E),e()},b=()=>{if(!v)return"";const T=d.find(E=>{var k;return E.id===((k=r.projectIds)==null?void 0:k[0])});return T?T.name:"Unknown Project"};return i.jsxDEV(i.Fragment,{children:[i.jsxDEV(ST,{isOpen:s,onClose:e,title:"Start Team",subtitle:`Configure settings for ${(r==null?void 0:r.name)||"team"}`,size:"xl",onSubmit:j,submitText:n?"Starting...":"Proceed",submitDisabled:n||!v&&!c,loading:n,children:[i.jsxDEV(JK,{title:"Project Assignment",description:v?void 0:"Select which project this team will work on",children:v?i.jsxDEV("div",{className:"form-info-box form-info-box--success",children:i.jsxDEV("div",{className:"form-info-content",children:[i.jsxDEV("strong",{children:"Already assigned to:"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:101,columnNumber:8},globalThis)," ",b()]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:100,columnNumber:7},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:99,columnNumber:6},globalThis):i.jsxDEV(ET,{children:[i.jsxDEV(Fr,{htmlFor:"project-select",required:!0,children:"Select Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:106,columnNumber:7},globalThis),i.jsxDEV($K,{id:"project-select",value:c,onChange:u,placeholder:"Choose a project...",loading:m,required:!0,options:d.map(T=>({value:T.id,label:`${T.name} (${T.path})`}))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:109,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:105,columnNumber:6},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:92,columnNumber:4},globalThis),i.jsxDEV("div",{className:"form-info-box form-info-box--info",children:[i.jsxDEV("div",{className:"form-info-header",children:i.jsxDEV("h4",{children:["Team: ",r==null?void 0:r.name]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:127,columnNumber:6},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:126,columnNumber:5},globalThis),i.jsxDEV("div",{className:"form-info-content",children:[i.jsxDEV("div",{children:["Members: ",((D=r==null?void 0:r.members)==null?void 0:D.length)||0]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:130,columnNumber:6},globalThis),i.jsxDEV("div",{children:["Status: ",(r==null?void 0:r.status)||"idle"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:131,columnNumber:6},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:129,columnNumber:5},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:125,columnNumber:4},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:81,columnNumber:3},globalThis),i.jsxDEV(a,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:135,columnNumber:3},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:80,columnNumber:3},globalThis)},lJ=({team:s,teamStatus:e,orchestratorSessionActive:t,onStartTeam:r,onStopTeam:n,onViewTerminal:o,onDeleteTeam:a,onEditTeam:c,isStoppingTeam:u=!1,isStartingTeam:d=!1})=>{const f=(s==null?void 0:s.id)==="orchestrator"||(s==null?void 0:s.name)==="Orchestrator Team";return((s==null?void 0:s.members)||[]).filter(g=>g.agentStatus==="active"||g.sessionName).length,i.jsxDEV("div",{className:"page-header",children:[i.jsxDEV("div",{className:"header-info",children:i.jsxDEV("div",{className:"flex items-center gap-3 mb-1",children:i.jsxDEV("h1",{className:"page-title mb-0",children:s.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:27,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:26,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:25,columnNumber:7},globalThis),i.jsxDEV("div",{className:"header-controls",children:[e==="idle"&&!d?i.jsxDEV(pr,{variant:"success",onClick:r,icon:Pp,children:f?"Start Orchestrator":"Start Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:32,columnNumber:11},globalThis):d?i.jsxDEV(pr,{variant:"success",loading:!0,disabled:!0,children:"Starting..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:36,columnNumber:11},globalThis):i.jsxDEV(pr,{variant:"danger",onClick:n,icon:fV,loading:u,children:u?"Stopping...":f?"Stop Orchestrator":"Stop Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:40,columnNumber:11},globalThis),f&&e==="active"&&i.jsxDEV(pr,{variant:"primary",onClick:o,icon:Ck,children:"View Terminal"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:50,columnNumber:11},globalThis),!f&&i.jsxDEV(bx,{align:"bottom-right",items:[{label:"Edit Team",onClick:c},{label:"Delete Team",danger:!0,onClick:a}]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:56,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:30,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:24,columnNumber:5},globalThis)},cJ=({member:s,teamId:e,onStart:t,onStop:r,onViewTerminal:n,onViewAgent:o,isStartingTeam:a})=>{const[c,u]=F.useState(!1),[d,f]=F.useState(!1),m=s.agentStatus==="active",g=s.agentStatus==="started",v=s.agentStatus==="starting"||s.agentStatus==="activating",N=m||g||v,j=v||c||a&&!m&&!g,b=c||d||a&&!m&&!g;let x="Inactive",D="bg-gray-500/10 text-gray-300";d?(x="Stopping...",D="bg-orange-500/10 text-orange-400"):s.agentStatus==="suspended"?(x="Suspended",D="bg-purple-500/10 text-purple-400"):m?(x="Active",D="bg-emerald-500/10 text-emerald-400"):g?(x="Started",D="bg-blue-500/10 text-blue-400"):j&&(x="Starting...",D="bg-yellow-500/10 text-yellow-400");const T=async U=>{if(U.stopPropagation(),t&&!b){u(!0);try{await t(s.id)}finally{u(!1)}}},E=async U=>{if(U.stopPropagation(),r&&!b){f(!0);try{await r(s.id)}finally{f(!1)}}},k=s.avatar;return i.jsxDEV("div",{className:"member-row",children:[i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("div",{className:"w-10 h-10 rounded-full bg-background-dark border border-border-dark flex items-center justify-center overflow-hidden",children:k?k.startsWith("http")||k.startsWith("data:")?i.jsxDEV("img",{src:k,alt:s.name,className:"w-full h-full object-cover"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:83,columnNumber:15},globalThis):i.jsxDEV("span",{className:"text-sm",children:k},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:85,columnNumber:15},globalThis):i.jsxDEV("span",{className:"text-sm",children:s.name.charAt(0).toUpperCase()},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:88,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:80,columnNumber:9},globalThis),i.jsxDEV("div",{children:[i.jsxDEV("div",{className:"font-semibold",children:s.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:92,columnNumber:11},globalThis),i.jsxDEV("div",{className:"text-sm text-text-secondary-dark",children:["Session: ",s.sessionName||"Inactive"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:93,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:91,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:79,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("span",{className:`px-3 py-1 rounded-full text-sm font-medium flex items-center gap-2 ${D}`,children:[b&&i.jsxDEV(Tb,{className:"w-3 h-3 animate-spin"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:98,columnNumber:25},globalThis),x]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:97,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex items-center gap-2",children:[(m||g||v||d)&&!c?i.jsxDEV("button",{className:`w-9 h-9 rounded-full flex items-center justify-center transition-colors ${b?"opacity-50 cursor-not-allowed":"hover:bg-red-500/20 hover:text-red-400"}`,title:"Stop",onClick:E,disabled:b,children:d?i.jsxDEV(Tb,{className:"w-4 h-4 animate-spin"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:114,columnNumber:17},globalThis):i.jsxDEV(fV,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:116,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:103,columnNumber:13},globalThis):i.jsxDEV("button",{className:`w-9 h-9 rounded-full flex items-center justify-center transition-colors ${b?"opacity-50 cursor-not-allowed":"hover:bg-green-500/20 hover:text-green-400"}`,title:"Start",onClick:T,disabled:b,children:c?i.jsxDEV(Tb,{className:"w-4 h-4 animate-spin"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:131,columnNumber:17},globalThis):i.jsxDEV(Pp,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:133,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:120,columnNumber:13},globalThis),i.jsxDEV(bx,{align:"bottom-right",buttonClassName:"w-9 h-9 rounded-full hover:bg-primary/20 hover:text-primary flex items-center justify-center transition-colors",items:[...o?[{label:N?"View Agent":"Edit Agent",onClick:()=>o(s)}]:[],...N&&s.sessionName&&n?[{label:"View Terminal",onClick:()=>n(s)}]:[]]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:137,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:101,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:96,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:78,columnNumber:5},globalThis)},uJ=({team:s,teamId:e,onUpdateMember:t,onDeleteMember:r,onStartMember:n,onStopMember:o,onViewTerminal:a,onViewAgent:c,isStartingTeam:u})=>{var d,f;return i.jsxDEV("div",{className:"space-y-4",children:[(d=s==null?void 0:s.members)==null?void 0:d.map(m=>i.jsxDEV(cJ,{member:m,teamId:e,onStart:n,onStop:o,onViewTerminal:a,onViewAgent:c,isStartingTeam:u},m.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/MembersList.tsx",lineNumber:19,columnNumber:9},globalThis)),!((f=s==null?void 0:s.members)!=null&&f.length)&&i.jsxDEV("div",{className:"empty-state",children:i.jsxDEV("p",{children:"No team members yet. Add members to get started."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/MembersList.tsx",lineNumber:32,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/MembersList.tsx",lineNumber:31,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/MembersList.tsx",lineNumber:17,columnNumber:5},globalThis)},dJ=({team:s,teamId:e,projectName:t,onUpdateMember:r,onDeleteMember:n,onStartMember:o,onStopMember:a,onProjectChange:c,onViewTerminal:u,onViewAgent:d,isStartingTeam:f})=>{var D,T;const[m,g]=F.useState(!1),[v,N]=F.useState(((D=s==null?void 0:s.projectIds)==null?void 0:D[0])||""),{projectOptions:j}=U9(),b=(s==null?void 0:s.id)==="orchestrator"||(s==null?void 0:s.name)==="Orchestrator Team";F.useEffect(()=>{var E;N(((E=s==null?void 0:s.projectIds)==null?void 0:E[0])||"")},[s==null?void 0:s.projectIds]);const x=E=>{N(E),c&&c(E||null),g(!1)};return i.jsxDEV("div",{className:`grid grid-cols-1 ${b?"":"lg:grid-cols-3"} gap-6`,children:[i.jsxDEV("div",{className:b?"":"lg:col-span-2",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:i.jsxDEV("h3",{className:"text-xl font-semibold",children:b?"Orchestrator":`Team Members (${((T=s.members)==null?void 0:T.length)||0})`},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:90,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:89,columnNumber:9},globalThis),i.jsxDEV(uJ,{team:s,teamId:e,onUpdateMember:r,onDeleteMember:n,onStartMember:o,onStopMember:a,onViewTerminal:u,onViewAgent:d,isStartingTeam:f},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:94,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:88,columnNumber:7},globalThis),!b&&i.jsxDEV("div",{className:"space-y-6",children:[i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-xl p-6",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[i.jsxDEV("h4",{className:"text-lg font-semibold",children:"Assigned Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:111,columnNumber:15},globalThis),i.jsxDEV("button",{onClick:()=>g(!m),className:"p-1.5 hover:bg-background-dark rounded-lg transition-colors text-text-secondary-dark hover:text-primary",title:"Change project",children:i.jsxDEV(CK,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:117,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:112,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:110,columnNumber:13},globalThis),m?i.jsxDEV("div",{className:"space-y-3",children:[i.jsxDEV(zc,{value:v,onChange:E=>x(E.target.value),children:[i.jsxDEV("option",{value:"",children:"No project assigned"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:126,columnNumber:19},globalThis),j.map(E=>i.jsxDEV("option",{value:E.id,children:E.name},E.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:128,columnNumber:21},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:122,columnNumber:17},globalThis),i.jsxDEV("button",{onClick:()=>g(!1),className:"text-sm text-text-secondary-dark hover:text-primary",children:"Cancel"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:131,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:121,columnNumber:15},globalThis):i.jsxDEV("div",{className:"flex items-center gap-3 cursor-pointer hover:bg-background-dark/50 -mx-3 px-3 py-2 rounded-lg transition-colors",onClick:()=>g(!0),title:"Click to change project",children:[i.jsxDEV(rl,{className:"h-5 w-5 text-primary"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:144,columnNumber:17},globalThis),i.jsxDEV("div",{className:"flex-1",children:[i.jsxDEV("div",{className:"font-semibold text-white",children:t||"No Project Assigned"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:146,columnNumber:19},globalThis),!t&&i.jsxDEV("div",{className:"text-sm text-text-secondary-dark",children:"Click to assign a project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:148,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:145,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:139,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:109,columnNumber:11},globalThis),i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-xl p-5",children:[i.jsxDEV("h4",{className:"text-lg font-semibold mb-3",children:"Recent Activity"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:155,columnNumber:13},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:"No recent activity."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:156,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:154,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:108,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:87,columnNumber:5},globalThis)},hJ=["development","management","quality","design","sales","support","automation"],AV={development:"Development",management:"Management",quality:"Quality",design:"Design",sales:"Sales",support:"Support",automation:"Automation"},fJ=({member:s,onClose:e,isEditable:t=!1,onSave:r})=>{const[n,o]=F.useState(null),[a,c]=F.useState(!0),[u,d]=F.useState([]),[f,m]=F.useState(s.runtimeType||"claude-code"),{skills:g}=XC();F.useEffect(()=>{(async()=>{if(s.role)try{const D=await Of.getRole(s.role);o(D)}catch(D){console.error("Failed to fetch role details:",D)}finally{c(!1)}else c(!1)})()},[s.role]),F.useEffect(()=>{var E;if(!n&&!((E=s.skillOverrides)!=null&&E.length))return;const D=[...((n==null?void 0:n.assignedSkills)||[]).filter(k=>{var U;return!((U=s.excludedRoleSkills)!=null&&U.includes(k))}),...s.skillOverrides||[]];if(D.length===0)return;const T=D.map(k=>{const U=g.find(V=>V.id===k);return{id:k,name:(U==null?void 0:U.name)||k}});d(T)},[n,s.skillOverrides,s.excludedRoleSkills,a,g]);const v=x=>u.find(D=>D.id===x),N=()=>{const x=((n==null?void 0:n.assignedSkills)||[]).filter(T=>{var E;return!((E=s.excludedRoleSkills)!=null&&E.includes(T))}),D=s.skillOverrides||[];return[...new Set([...x,...D])]},j=x=>{x.target===x.currentTarget&&e()},b=(x,D)=>{const T=v(x),E=(T==null?void 0:T.name)||x,k="inline-flex items-center gap-1.5 px-2.5 py-1 text-sm rounded-md",U=D==="role"?"bg-primary/10 text-primary":"bg-emerald-500/10 text-emerald-400";return i.jsxDEV("div",{children:i.jsxDEV("span",{className:`${k} ${U}`,children:[i.jsxDEV(El,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:135,columnNumber:11},globalThis),E]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:134,columnNumber:9},globalThis)},x,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:133,columnNumber:7},globalThis)};return i.jsxDEV("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:j,children:i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg w-full max-w-lg m-4",onClick:x=>x.stopPropagation(),children:[i.jsxDEV("div",{className:"flex items-center justify-between p-6 border-b border-border-dark",children:[i.jsxDEV("div",{className:"flex items-center gap-4",children:[i.jsxDEV("div",{className:"w-12 h-12 rounded-full bg-background-dark border border-border-dark flex items-center justify-center overflow-hidden",children:s.avatar?s.avatar.startsWith("http")||s.avatar.startsWith("data:")?i.jsxDEV("img",{src:s.avatar,alt:s.name,className:"w-full h-full object-cover"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:157,columnNumber:19},globalThis):i.jsxDEV("span",{className:"text-lg",children:s.avatar},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:159,columnNumber:19},globalThis):i.jsxDEV(mx,{className:"w-6 h-6 text-text-secondary-dark"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:162,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:154,columnNumber:13},globalThis),i.jsxDEV("div",{children:[i.jsxDEV("h2",{className:"text-xl font-semibold text-text-primary-dark",children:s.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:166,columnNumber:15},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:t?"Edit Agent":"Agent Details"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:167,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:165,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:153,columnNumber:11},globalThis),i.jsxDEV("button",{onClick:e,className:"w-8 h-8 rounded-lg hover:bg-background-dark flex items-center justify-center text-text-secondary-dark hover:text-text-primary-dark",children:i.jsxDEV(ho,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:174,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:170,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:152,columnNumber:9},globalThis),i.jsxDEV("div",{className:"p-6 space-y-6",children:[i.jsxDEV("div",{children:[i.jsxDEV("div",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary-dark uppercase tracking-wide mb-3",children:[i.jsxDEV(dK,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:183,columnNumber:15},globalThis),"Role"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:182,columnNumber:13},globalThis),a?i.jsxDEV("div",{className:"animate-pulse",children:[i.jsxDEV("div",{className:"h-6 bg-background-dark rounded w-32 mb-2"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:188,columnNumber:17},globalThis),i.jsxDEV("div",{className:"h-4 bg-background-dark rounded w-full"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:189,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:187,columnNumber:15},globalThis):n?i.jsxDEV("div",{className:"bg-background-dark/50 rounded-lg p-4",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[i.jsxDEV("span",{className:"font-semibold text-text-primary-dark",children:n.displayName},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:194,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-xs px-2 py-0.5 rounded-full bg-primary/10 text-primary",children:AV[n.category]||n.category},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:195,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:193,columnNumber:17},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:n.description},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:199,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:192,columnNumber:15},globalThis):i.jsxDEV("p",{className:"text-sm text-text-secondary-dark italic",children:"No role assigned"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:202,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:181,columnNumber:11},globalThis),i.jsxDEV("div",{children:[i.jsxDEV("div",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary-dark uppercase tracking-wide mb-3",children:[i.jsxDEV(m4,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:209,columnNumber:15},globalThis),"Skills"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:208,columnNumber:13},globalThis),a?i.jsxDEV("div",{className:"animate-pulse flex flex-wrap gap-2",children:[i.jsxDEV("div",{className:"h-7 bg-background-dark rounded-md w-24"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:214,columnNumber:17},globalThis),i.jsxDEV("div",{className:"h-7 bg-background-dark rounded-md w-32"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:215,columnNumber:17},globalThis),i.jsxDEV("div",{className:"h-7 bg-background-dark rounded-md w-28"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:216,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:213,columnNumber:15},globalThis):i.jsxDEV("div",{className:"space-y-3",children:[(n==null?void 0:n.assignedSkills)&&n.assignedSkills.length>0&&i.jsxDEV("div",{children:[i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mb-2",children:"From Role"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:223,columnNumber:21},globalThis),i.jsxDEV("div",{className:"flex flex-wrap gap-2",children:n.assignedSkills.filter(x=>{var D;return!((D=s.excludedRoleSkills)!=null&&D.includes(x))}).map(x=>b(x,"role"))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:224,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:222,columnNumber:19},globalThis),s.skillOverrides&&s.skillOverrides.length>0&&i.jsxDEV("div",{children:[i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mb-2",children:"Additional Skills"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:237,columnNumber:21},globalThis),i.jsxDEV("div",{className:"flex flex-wrap gap-2",children:s.skillOverrides.map(x=>b(x,"additional"))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:238,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:236,columnNumber:19},globalThis),N().length===0&&i.jsxDEV("p",{className:"text-sm text-text-secondary-dark italic",children:"No skills assigned"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:248,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:219,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:207,columnNumber:11},globalThis),i.jsxDEV("div",{children:[i.jsxDEV("div",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary-dark uppercase tracking-wide mb-3",children:"Runtime"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:256,columnNumber:13},globalThis),t?i.jsxDEV("select",{value:f,onChange:x=>m(x.target.value),className:"w-full bg-background-dark border border-border-dark rounded-lg px-4 py-2 text-sm text-text-primary-dark focus:outline-none focus:border-primary",children:[i.jsxDEV("option",{value:"claude-code",children:"Claude CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:265,columnNumber:17},globalThis),i.jsxDEV("option",{value:"gemini-cli",children:"Gemini CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:266,columnNumber:17},globalThis),i.jsxDEV("option",{value:"codex-cli",children:"Codex CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:267,columnNumber:17},globalThis),i.jsxDEV("option",{value:"crewly-agent",children:"Crewly Agent"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:268,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:260,columnNumber:15},globalThis):i.jsxDEV("div",{className:"bg-background-dark/50 rounded-lg px-4 py-2",children:i.jsxDEV("span",{className:"text-sm text-text-primary-dark",children:s.runtimeType==="claude-code"?"Claude CLI":s.runtimeType==="gemini-cli"?"Gemini CLI":s.runtimeType==="codex-cli"?"Codex CLI":s.runtimeType==="crewly-agent"?"Crewly Agent":s.runtimeType||"Claude CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:272,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:271,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:255,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:179,columnNumber:9},globalThis),i.jsxDEV("div",{className:"px-6 py-4 border-t border-border-dark bg-background-dark rounded-b-xl",children:t?i.jsxDEV("div",{className:"flex gap-3",children:[i.jsxDEV("button",{onClick:e,className:"flex-1 px-4 py-2 border border-border-dark text-text-secondary-dark rounded-lg hover:bg-surface-dark transition-colors font-medium",children:"Cancel"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:288,columnNumber:15},globalThis),i.jsxDEV("button",{onClick:()=>{r&&r(s.id,{runtimeType:f}),e()},className:"flex-1 px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors font-medium",children:"Save"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:294,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:287,columnNumber:13},globalThis):i.jsxDEV("button",{onClick:e,className:"w-full px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors font-medium",children:"Close"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:307,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:285,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:147,columnNumber:7},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:143,columnNumber:5},globalThis)},mJ=50;let pJ=0;function $E(){return`feed-${Date.now()}-${++pJ}`}function yJ(s=mJ,e){const[t,r]=F.useState([]),n=F.useRef(s);n.current=s;const o=F.useRef(e);o.current=e;const a=F.useCallback(u=>{r(d=>{const f=[u,...d];return f.length>n.current?f.slice(0,n.current):f})},[]),c=F.useCallback(()=>r([]),[]);return F.useEffect(()=>{const u=N=>{if(o.current&&N.teamId&&N.teamId!==o.current)return;const j=N.name||N.sessionName||"Agent",b=N.agentStatus||N.workingStatus||"unknown",x=b==="error"?"error":"agent_status";a({id:$E(),type:x,source:j,title:`${j} is now ${b}`,detail:N.role?`Role: ${N.role}`:void 0,timestamp:new Date().toISOString(),agentStatus:N.agentStatus})},d=N=>{const j=N.agentStatus||N.status||(N.running?"active":"inactive");a({id:$E(),type:"system",source:"Orchestrator",title:`Orchestrator is now ${j}`,timestamp:new Date().toISOString(),agentStatus:j})},f=N=>j=>{const b=N.replace("queue:","").replace(/_/g," ");a({id:$E(),type:N.includes("failed")?"error":"message",source:j.sessionName||"Queue",title:`Message ${b}`,detail:j.snippet?j.snippet.slice(0,120):void 0,timestamp:new Date().toISOString()})},m=N=>{if(N.members)for(const j of N.members)j.agentStatus&&a({id:$E(),type:"task_update",source:j.name||j.sessionName||"Agent",title:j.currentTask?`Working on: ${j.currentTask}`:`Status: ${j.agentStatus}`,timestamp:new Date().toISOString(),agentStatus:j.agentStatus})};tr.on("team_member_status_changed",u),tr.on("orchestrator_status_changed",d),tr.on("team_activity_updated",m);const v=["queue:message_enqueued","queue:message_processing","queue:message_completed","queue:message_failed"].map(N=>{const j=f(N);return tr.on(N,j),{name:N,handler:j}});return()=>{tr.off("team_member_status_changed",u),tr.off("orchestrator_status_changed",d),tr.off("team_activity_updated",m);for(const{name:N,handler:j}of v)tr.off(N,j)}},[a]),{events:t,clearEvents:c}}const gJ={agent_status:"bg-emerald-400",task_update:"bg-blue-400",message:"bg-violet-400",system:"bg-amber-400",error:"bg-red-400"},bJ={agent_status:"Agent",task_update:"Task",message:"Message",system:"System",error:"Error"};function vJ(s){try{return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}const wJ=({event:s})=>{const e=s.agentStatus==="active"||s.agentStatus==="busy",t=gJ[s.type]||"bg-gray-400";return i.jsxDEV("div",{className:"feed-entry flex items-start gap-3 px-4 py-2.5 border-b border-[var(--color-border)] hover:bg-[var(--color-bg-hover)] transition-colors","data-testid":"feed-entry",children:[i.jsxDEV("span",{className:`mt-1.5 h-2 w-2 shrink-0 rounded-full ${t} ${e?"feed-pulse":""}`},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:65,columnNumber:4},globalThis),i.jsxDEV("div",{className:"min-w-0 flex-1",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("span",{className:"text-xs font-medium text-[var(--color-text-secondary)] uppercase tracking-wide",children:bJ[s.type]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:72,columnNumber:6},globalThis),i.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:vJ(s.timestamp)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:75,columnNumber:6},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:71,columnNumber:5},globalThis),i.jsxDEV("p",{className:"text-sm text-[var(--color-text-primary)] truncate",children:s.title},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:79,columnNumber:5},globalThis),s.detail&&i.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] truncate mt-0.5",children:s.detail},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:83,columnNumber:6},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:70,columnNumber:4},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:60,columnNumber:3},globalThis)},xJ=()=>i.jsxDEV("div",{className:"flex flex-col items-center justify-center py-12 text-[var(--color-text-muted)]",children:[i.jsxDEV("svg",{className:"h-10 w-10 mb-3 opacity-40",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M13 10V3L4 14h7v7l9-11h-7z"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:103,columnNumber:4},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:97,columnNumber:3},globalThis),i.jsxDEV("p",{className:"text-sm",children:"Waiting for live events…"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:110,columnNumber:3},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:96,columnNumber:2},globalThis),NJ=({maxEvents:s=50,className:e=""})=>{const{events:t,clearEvents:r}=yJ(s),n=F.useRef(null);return F.useEffect(()=>{n.current&&(n.current.scrollTop=0)},[t.length]),i.jsxDEV("div",{className:`flex flex-col rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] overflow-hidden ${e}`,"data-testid":"execution-feed",children:[i.jsxDEV("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--color-border)]",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("span",{className:"h-2 w-2 rounded-full bg-emerald-400 feed-pulse"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:147,columnNumber:6},globalThis),i.jsxDEV("h3",{className:"text-sm font-semibold text-[var(--color-text-primary)]",children:"Execution Feed"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:148,columnNumber:6},globalThis),t.length>0&&i.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:["(",t.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:152,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:146,columnNumber:5},globalThis),t.length>0&&i.jsxDEV("button",{onClick:r,className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition-colors","data-testid":"feed-clear",children:"Clear"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:158,columnNumber:6},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:145,columnNumber:4},globalThis),i.jsxDEV("div",{ref:n,className:"feed-scroll flex-1 overflow-y-auto",children:t.length===0?i.jsxDEV(xJ,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:174,columnNumber:6},globalThis):t.map(o=>i.jsxDEV(wJ,{event:o},o.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:177,columnNumber:7},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:169,columnNumber:4},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:140,columnNumber:3},globalThis)},DJ=()=>{const{id:s}=GB(),e=gh(),{openTerminalWithSession:t}=ej(),[r,n]=F.useState(null),[o,a]=F.useState(!0),[c,u]=F.useState(!1),[d,f]=F.useState(!1),[m,g]=F.useState(!1),[v,N]=F.useState(!1),[j,b]=F.useState(null),[x,D]=F.useState(!1),[T,E]=F.useState(!1),[k,U]=F.useState(null),[V,M]=F.useState(null),[R,P]=F.useState([]),{showSuccess:B,showError:O,showWarning:H,AlertComponent:J}=Zp(),{showConfirm:ie,ConfirmComponent:te}=YT(),se=F.useCallback(re=>{re.teamId===s&&n(Ae=>Ae&&{...Ae,members:Ae.members.map(He=>He.id===re.memberId||He.sessionName===re.sessionName?{...He,agentStatus:re.agentStatus}:He)})},[s]),Z=F.useCallback(re=>{(s==="orchestrator"||(r==null?void 0:r.name)==="Orchestrator Team")&&u(re.agentStatus==="active")},[s,r==null?void 0:r.name]);F.useEffect(()=>{s&&(X(),(s==="orchestrator"||(r==null?void 0:r.name)==="Orchestrator Team")&&z())},[s,r==null?void 0:r.name]),F.useEffect(()=>(tr.on("team_member_status_changed",se),tr.on("orchestrator_status_changed",Z),()=>{tr.off("team_member_status_changed",se),tr.off("orchestrator_status_changed",Z)}),[se,Z]),F.useEffect(()=>{var re;((re=r==null?void 0:r.projectIds)==null?void 0:re.length)>0?oe(r.projectIds[0]):(U(null),M(null))},[r==null?void 0:r.projectIds]),F.useEffect(()=>{s&&Y()},[s]);const Y=async()=>{try{const Ae=(await es.getTeams()).filter(He=>He.parentTeamId===s);P(Ae)}catch(re){console.error("Error fetching sub-teams:",re),P([])}},X=async()=>{try{const re=await fetch(`/api/teams/${s}`);if(re.ok){const Ae=await re.json();if(Ae.success&&Ae.data){const He={...Ae.data,members:V9(Ae.data.members)};n(He)}}}catch(re){console.error("Error fetching team data:",re)}finally{a(!1)}},z=async()=>{try{const re=await fetch("/api/terminal/sessions");if(re.ok){const Ae=await re.json();if(Ae.success&&Ae.data){const He=Ae.data.some(Ge=>Ge.sessionName==="crewly-orc");u(He)}}}catch(re){console.error("Error checking orchestrator session:",re),u(!1)}},oe=async re=>{try{const Ae=await fetch("/api/projects");if(Ae.ok){const He=await Ae.json(),Ye=(He.success?He.data||[]:He||[]).find(ne=>ne.id===re);U(Ye?Ye.name:re),M(Ye?Ye.path:null)}else U(re),M(null)}catch(Ae){console.error("Error fetching project data:",Ae),U(re),M(null)}},le=async()=>{if((r==null?void 0:r.id)==="orchestrator"||(r==null?void 0:r.name)==="Orchestrator Team"){D(!0);try{const Ae=await es.setupOrchestrator();Ae.success?(X(),B(Ae.message||"Orchestrator started successfully!")):O(Ae.error||"Failed to start orchestrator")}catch(Ae){console.error("Error starting orchestrator:",Ae),O("Error starting orchestrator. Please try again.")}finally{D(!1)}return}f(!0)},fe=async re=>{D(!0);try{const Ae=await fetch(`/api/teams/${s}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:re})}),He=await Ae.json();Ae.ok?(f(!1),X(),B(He.message||"Team started successfully!")):O(He.error||"Failed to start team")}catch(Ae){console.error("Error starting team:",Ae),O("Error starting team. Please try again.")}finally{D(!1)}},ee=()=>{g(!0)},ue=async re=>{if(r)try{const Ae=await fetch(`/api/teams/${r.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(re)});if(Ae.ok)X(),g(!1);else{const He=await Ae.json();O(He.error||"Failed to update team")}}catch(Ae){console.error("Error updating team:",Ae),O("Failed to update team")}},G=async()=>{E(!0);try{if((r==null?void 0:r.id)==="orchestrator"||(r==null?void 0:r.name)==="Orchestrator Team"){const re=await fetch("/api/orchestrator/stop",{method:"POST",headers:{"Content-Type":"application/json"}});if(re.ok)X(),z();else{const Ae=await re.json();O(Ae.error||"Failed to stop orchestrator")}}else(await fetch(`/api/teams/${s}/stop`,{method:"POST"})).ok&&X()}catch(re){console.error("Error stopping team:",re)}finally{E(!1)}},ae=async()=>{if(!r)return;if(r.id==="orchestrator"||r.name==="Orchestrator Team"){H("The Orchestrator Team cannot be deleted as it is required for system operations.");return}const re=async()=>{try{await fetch(`/api/teams/${s}/stop`,{method:"POST"});const Ae=await fetch(`/api/teams/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(Ae.ok)e("/teams");else{const He=await Ae.text();O("Failed to delete team: "+He)}}catch(Ae){console.error("Error deleting team:",Ae),O("Failed to delete team: "+(Ae instanceof Error?Ae.message:"Unknown error"))}};ie(`Are you sure you want to delete team "${r.name}"?
381
+ 🔍 Monitor ${ct.name}'s terminal for progress.`,"Build Specs Started");const Xr=setInterval(()=>{le(Lr=>{if(!Lr.isActive)return Lr;const Yr=new Date,wr=Lr.steps.map(_r=>_r.status==="pending"&&_r.scheduledAt&&Yr>=_r.scheduledAt?{..._r,status:"scheduled"}:_r);return wr.every(_r=>_r.status==="scheduled")?(clearInterval(Xr),{...Lr,steps:wr}):{...Lr,steps:wr}})},3e4),ks=it.reduce((Lr,Yr)=>Lr+Yr.delayMinutes,0);setTimeout(()=>{clearInterval(Xr)},(ks+5)*6e4)}else throw new Error("Some Build Specs steps failed to schedule")}catch(kt){console.error("Error building specs:",kt),a("Failed to build specs: "+(kt instanceof Error?kt.message:"Unknown error"))}};if(fe.loading)return i.jsxDEV("div",{className:"flex items-center justify-center min-h-[400px]",children:i.jsxDEV("div",{className:"text-center",children:[i.jsxDEV("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4 mx-auto"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1337,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-text-secondary-dark",children:"Loading project..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1338,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1336,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1335,columnNumber:7},globalThis);if(fe.error||!fe.project)return i.jsxDEV("div",{className:"max-w-4xl mx-auto px-6 py-16",children:i.jsxDEV("div",{className:"text-center",children:[i.jsxDEV("h2",{className:"text-2xl font-bold mb-4",children:"Error Loading Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1348,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-text-secondary-dark",children:fe.error||"Project not found"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1349,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1347,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1346,columnNumber:7},globalThis);const{project:Nt,assignedTeams:Vt,tickets:Ee}=fe;return i.jsxDEV("div",{className:"max-w-7xl mx-auto px-6 py-8",children:[i.jsxDEV("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between gap-4 mb-8",children:[i.jsxDEV("div",{className:"flex-1",children:[i.jsxDEV("div",{className:"flex items-center gap-3 text-sm text-text-secondary-dark mb-1",children:[i.jsxDEV(Cb,{to:"/projects",className:"hover:text-primary",children:"Projects"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1363,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-text-secondary-dark",children:"/"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1364,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-text-primary-dark",children:Nt.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1365,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1362,columnNumber:11},globalThis),i.jsxDEV("h1",{className:"text-3xl font-bold tracking-tight mb-2",children:Nt.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1367,columnNumber:11},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("span",{className:"flex items-center gap-1 text-sm text-text-secondary-dark",children:[i.jsxDEV(rl,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1370,columnNumber:15},globalThis),Nt.path]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1369,columnNumber:13},globalThis),i.jsxDEV(pr,{variant:"secondary",size:"sm",icon:IC,onClick:Cr,title:"Open project folder in Finder",children:"Open in Finder"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1373,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1368,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1361,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3",children:[Nt.status==="active"?i.jsxDEV(pr,{variant:"warning",icon:fV,onClick:pt,disabled:fe.loading,title:"Stop project and cancel scheduled messages",children:"Stop Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1388,columnNumber:13},globalThis):i.jsxDEV(pr,{variant:"primary",icon:Pp,onClick:Pe,disabled:fe.loading||Vt.length===0,loading:fe.loading,title:Vt.length===0?"Assign a team before starting the project":"Start project with assigned teams",children:fe.loading?"Starting...":"Start Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1398,columnNumber:13},globalThis),i.jsxDEV(bx,{align:"bottom-right",items:[{label:"Assign Team",onClick:Fe},...g==="tasks"?[{label:"Create Task",onClick:()=>Ce(!0)},{label:"Create Milestone",onClick:()=>Ke(!0)}]:[],{label:"Delete Project",onClick:ot,danger:!0}]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1410,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1385,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1360,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex gap-1 mb-6 border-b border-border-dark",children:[i.jsxDEV("button",{className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${g==="detail"?"border-primary text-primary":"border-transparent text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>Ye("detail"),children:[i.jsxDEV(kk,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1448,columnNumber:11},globalThis),"Detail"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1440,columnNumber:9},globalThis),i.jsxDEV("button",{className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${g==="editor"?"border-primary text-primary":"border-transparent text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>Ye("editor"),children:[i.jsxDEV(rl,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1459,columnNumber:11},globalThis),"Editor"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1451,columnNumber:9},globalThis),i.jsxDEV("button",{className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${g==="tasks"?"border-primary text-primary":"border-transparent text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>Ye("tasks"),children:[i.jsxDEV(fK,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1470,columnNumber:11},globalThis),"Tasks (",Ee.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1462,columnNumber:9},globalThis),i.jsxDEV("button",{className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 ${g==="teams"?"border-primary text-primary":"border-transparent text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>Ye("teams"),children:[i.jsxDEV(h4,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1481,columnNumber:11},globalThis),"Teams (",Vt.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1473,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1439,columnNumber:7},globalThis),i.jsxDEV("div",{children:g==="detail"?i.jsxDEV(jY,{project:Nt,onAddGoal:gt,onEditGoal:Ft,onAddUserJourney:Zt,onEditUserJourney:Hr,onBuildSpecs:Dr,onBuildTasks:ws,buildSpecsWorkflow:oe,alignmentStatus:ue,onContinueWithMisalignment:q,onViewAlignment:ge,selectedBuildSpecsTeam:ae,setSelectedBuildSpecsTeam:De,selectedBuildTasksTeam:Te,setSelectedBuildTasksTeam:Ve,availableTeams:me,onCreateSpecsTasks:qe,onCreateDevTasks:Ue,onCreateE2ETasks:nt},Nt.updatedAt,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1489,columnNumber:11},globalThis):g==="editor"?i.jsxDEV(_Y,{project:Nt,selectedFile:N,onFileSelect:j,setIsMarkdownEditorOpen:T},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1512,columnNumber:11},globalThis):g==="tasks"?i.jsxDEV("div",{children:[re.length>0&&i.jsxDEV("div",{className:"mb-4",children:[i.jsxDEV("button",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary-dark hover:text-primary mb-2",onClick:()=>Ge(!He),children:[i.jsxDEV("svg",{className:`w-4 h-4 transition-transform ${He?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1528,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1527,columnNumber:19},globalThis),"Task Flow (",re.length," active)"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1523,columnNumber:17},globalThis),He&&i.jsxDEV("div",{className:"rounded-lg border border-border-dark bg-surface-dark p-3",children:i.jsxDEV(A9,{tasks:re},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1534,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1533,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1522,columnNumber:15},globalThis),i.jsxDEV(EY,{project:Nt,tickets:Ee,onTicketsUpdate:()=>Ie(Nt.id),onCreateSpecsTasks:qe,onCreateDevTasks:Ue,onCreateE2ETasks:nt,loading:fe.loading,onTaskClick:ve,onTaskAssign:Se,onTaskUnblock:ke,taskAssignmentLoading:te,taskUnblockLoading:Z},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1540,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1519,columnNumber:11},globalThis):i.jsxDEV(kY,{assignedTeams:Vt,onUnassignTeam:We,openTerminalWithSession:r,onAssignTeam:Fe,projectName:Nt.name,onViewTeam:Ne=>t(`/teams/${Ne}`),onEditTeam:Ne=>t(`/teams/${Ne}?edit=true`)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1556,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1487,columnNumber:7},globalThis),b&&i.jsxDEV(NY,{project:Nt,onClose:()=>x(!1),onAssignmentComplete:st},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1570,columnNumber:9},globalThis),D&&i.jsxDEV(TY,{projectPath:Nt.path,onClose:()=>T(!1)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1579,columnNumber:9},globalThis),i.jsxDEV(DY,{isOpen:O,onClose:()=>{H(!1),ie(null)},task:J,onAssign:Se,taskAssignmentLoading:te},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1586,columnNumber:7},globalThis),E&&i.jsxDEV(ST,{isOpen:E,onClose:()=>k(!1),title:"Add Project Goal",subtitle:"Define your project's main objective and success criteria",onSubmit:Ne=>{Ne.preventDefault(),jt()},submitText:"Save Goal",size:"md",children:i.jsxDEV(ET,{children:[i.jsxDEV(Fr,{htmlFor:"goal-content",required:!0,children:"Project Goal"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1609,columnNumber:13},globalThis),i.jsxDEV($f,{id:"goal-content",value:M,onChange:Ne=>R(Ne.target.value),placeholder:"Describe your project's main objective, success criteria, and key outcomes...",rows:8,required:!0},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1612,columnNumber:13},globalThis),i.jsxDEV(fR,{children:"Define what you want to achieve with this project. Be specific about goals, target users, and success metrics."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1620,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1608,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1599,columnNumber:9},globalThis),U&&i.jsxDEV(ST,{isOpen:U,onClose:()=>V(!1),title:"Add User Journey",subtitle:"Map out how users will interact with your solution",onSubmit:Ne=>{Ne.preventDefault(),ur()},submitText:"Save User Journey",size:"md",children:i.jsxDEV(ET,{children:[i.jsxDEV(Fr,{htmlFor:"journey-content",required:!0,children:"User Journey"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1639,columnNumber:13},globalThis),i.jsxDEV($f,{id:"journey-content",value:P,onChange:Ne=>B(Ne.target.value),placeholder:"Describe your users' journey from discovery to success. Include user personas, key interactions, pain points, and desired outcomes...",rows:8,required:!0},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1642,columnNumber:13},globalThis),i.jsxDEV(fR,{children:"Map out how users will interact with your solution. Include user types, main flows, and critical touchpoints."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1650,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1638,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1629,columnNumber:9},globalThis),i.jsxDEV(c,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1658,columnNumber:7},globalThis),i.jsxDEV(f,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1659,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/ProjectDetail.tsx",lineNumber:1358,columnNumber:5},globalThis)},Cf="/api/settings/roles";class zY{async listRoles(){const e=await ir.get(Cf);if(!e.data.success||!e.data.data)throw new Error(e.data.error||"Failed to get roles");return e.data.data}async getRole(e){const t=await ir.get(`${Cf}/${e}`);if(!t.data.success||!t.data.data)throw new Error(t.data.error||"Role not found");return t.data.data}async createRole(e){const t=await ir.post(Cf,e);if(!t.data.success||!t.data.data)throw new Error(t.data.error||"Failed to create role");return t.data.data}async updateRole(e,t){const r=await ir.put(`${Cf}/${e}`,t);if(!r.data.success||!r.data.data)throw new Error(r.data.error||"Failed to update role");return r.data.data}async deleteRole(e){const t=await ir.delete(`${Cf}/${e}`);if(!t.data.success)throw new Error(t.data.error||"Failed to delete role")}async assignSkills(e,t){const r=await ir.post(`${Cf}/${e}/skills`,{skillIds:t});if(!r.data.success||!r.data.data)throw new Error(r.data.error||"Failed to assign skills");return r.data.data}async removeSkills(e,t){const r=await ir.delete(`${Cf}/${e}/skills`,{data:{skillIds:t}});if(!r.data.success||!r.data.data)throw new Error(r.data.error||"Failed to remove skills");return r.data.data}async setDefaultRole(e){const t=await ir.post(`${Cf}/${e}/default`);if(!t.data.success||!t.data.data)throw new Error(t.data.error||"Failed to set default role");return t.data.data}async refreshFromDisk(){const e=await ir.post(`${Cf}/refresh`);if(!e.data.success)throw new Error(e.data.error||"Failed to refresh roles")}}const Of=new zY;function M9(){const[s,e]=F.useState(null),[t,r]=F.useState(!0),[n,o]=F.useState(null),a=F.useCallback(async()=>{r(!0),o(null);try{const g=await Of.listRoles();e(g)}catch(g){o(g instanceof Error?g.message:"Failed to load roles")}finally{r(!1)}},[]),c=F.useCallback(async g=>{await Of.createRole(g),await a()},[a]),u=F.useCallback(async(g,v)=>{await Of.updateRole(g,v),await a()},[a]),d=F.useCallback(async g=>{await Of.deleteRole(g),await a()},[a]),f=F.useCallback(async()=>{await a()},[a]),m=F.useCallback(async()=>{r(!0),o(null);try{await Of.refreshFromDisk();const g=await Of.listRoles();e(g)}catch(g){o(g instanceof Error?g.message:"Failed to refresh roles from disk")}finally{r(!1)}},[]);return F.useEffect(()=>{a()},[a]),{roles:s,isLoading:t,error:n,createRole:c,updateRole:u,deleteRole:d,refreshRoles:f,refreshFromDisk:m}}function U9(){const[s,e]=F.useState([]),[t,r]=F.useState(!0),[n,o]=F.useState(null),a=F.useCallback(async()=>{r(!0),o(null);try{const u=await fetch("/api/projects");if(!u.ok)throw new Error(`Failed to fetch projects: ${u.statusText}`);const d=await u.json(),f=d.success?d.data||[]:d||[];e(Array.isArray(f)?f:[])}catch(u){const d=u instanceof Error?u.message:"Failed to fetch projects";o(d),e([])}finally{r(!1)}},[]);F.useEffect(()=>{a()},[a]);const c=F.useMemo(()=>s.map(u=>({id:u.id,name:u.name,path:u.path})),[s]);return{projects:s,projectOptions:c,isLoading:t,error:n,refetch:a}}const WY="/api";function KY(){const[s,e]=F.useState([]),[t,r]=F.useState(!0),[n,o]=F.useState(null),a=F.useCallback(async u=>{r(!0),o(null);try{const d=await ir.get(`${WY}/teams`,{signal:u});d.data.success?e(d.data.data||[]):o(d.data.error||"Failed to load teams")}catch(d){if(ir.isCancel(d))return;const f=d instanceof Error?d.message:"Failed to load teams";o(f),console.error("useTeams: Failed to fetch teams:",d)}finally{r(!1)}},[]);F.useEffect(()=>{const u=new AbortController;return a(u.signal),()=>{u.abort()}},[a]);const c=F.useCallback(async()=>{await a()},[a]);return{teams:s,loading:t,error:n,refresh:c}}const Lp="/api/skills";async function XY(s){const e=new URLSearchParams;s!=null&&s.category&&e.set("category",s.category),s!=null&&s.roleId&&e.set("roleId",s.roleId),s!=null&&s.search&&e.set("search",s.search);const t=e.toString()?`${Lp}?${e}`:Lp,r=await fetch(t);if(!r.ok)throw new Error(`Failed to fetch skills: ${r.statusText}`);const n=await r.json();return n.data||n}async function ZY(s){const e=await fetch(`${Lp}/${s}`);if(!e.ok)throw e.status===404?new Error(`Skill not found: ${s}`):new Error(`Failed to fetch skill: ${e.statusText}`);const t=await e.json();return t.data||t}async function qY(s){const e=await fetch(Lp,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!e.ok){const r=await e.text();throw new Error(`Failed to create skill: ${r}`)}const t=await e.json();return t.data||t}async function YY(s,e){const t=await fetch(`${Lp}/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const n=await t.text();throw new Error(`Failed to update skill: ${n}`)}const r=await t.json();return r.data||r}async function JY(s){const e=await fetch(`${Lp}/${s}`,{method:"DELETE"});if(!e.ok)throw new Error(`Failed to delete skill: ${e.statusText}`)}async function $Y(s,e){const t=await fetch(`${Lp}/${s}/execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:e})});if(!t.ok){const n=await t.text();throw new Error(`Failed to execute skill: ${n}`)}const r=await t.json();return r.data||r}async function QY(){const s=await fetch(`${Lp}/refresh`,{method:"POST"});if(!s.ok){const e=await s.text();throw new Error(`Failed to refresh skills: ${e}`)}}function XC(s={}){const{category:e,roleId:t,search:r,fetchOnMount:n=!0}=s,[o,a]=F.useState([]),[c,u]=F.useState(null),[d,f]=F.useState(n),[m,g]=F.useState(null),v=F.useCallback(async(k=!1)=>{f(!0),g(null);try{k&&await QY();const U={};e&&(U.category=e),t&&(U.roleId=t),r&&(U.search=r);const V=await XY(U);a(V)}catch(U){const V=U instanceof Error?U.message:"Failed to load skills";g(V),console.error("useSkills: Failed to fetch skills:",U)}finally{f(!1)}},[e,t,r]),N=F.useCallback(async k=>{try{const U=await ZY(k);u(U)}catch(U){const V=U instanceof Error?U.message:"Failed to load skill";g(V),console.error("useSkills: Failed to select skill:",U)}},[]),j=F.useCallback(()=>{u(null)},[]),b=F.useCallback(async k=>{const U=await qY(k);return await v(),U},[v]),x=F.useCallback(async(k,U)=>{const V=await YY(k,U);return await v(),(c==null?void 0:c.id)===k&&u(V),V},[v,c==null?void 0:c.id]),D=F.useCallback(async k=>{await JY(k),await v(),(c==null?void 0:c.id)===k&&u(null)},[v,c==null?void 0:c.id]),T=F.useCallback(async(k,U)=>$Y(k,U),[]),E=F.useCallback(async()=>{await v(!0)},[v]);return F.useEffect(()=>{n&&v(!1)},[n,v]),{skills:o,selectedSkill:c,loading:d,error:m,refresh:E,selectSkill:N,clearSelection:j,create:b,update:x,remove:D,execute:T}}const R9=({isOpen:s,onClose:e,onSubmit:t,team:r})=>{const{showWarning:n,AlertComponent:o}=Zp(),{roles:a,isLoading:c}=M9(),{projects:u,isLoading:d}=U9(),{teams:f,loading:m}=KY(),{skills:g,loading:v}=XC(),[N,j]=F.useState({name:"",projectPath:"",parentTeamId:""}),[b,x]=F.useState([]),[D,T]=F.useState({hierarchical:!1,leaderId:null,leaderIds:[]}),[E,k]=F.useState(!1),[U,V]=F.useState({}),[M,R]=F.useState({}),P=(a||[]).map(ee=>({key:ee.name,displayName:ee.displayName,promptFile:`${ee.name}-prompt.md`,description:ee.description||"",category:ee.category,hidden:!1,isDefault:ee.isDefault})),B=F.useCallback(async ee=>{if(M[ee])return M[ee];try{const ue=await Of.getRole(ee);return R(G=>({...G,[ee]:ue})),ue}catch(ue){return console.error("Failed to fetch role details:",ue),null}},[M]),O=ee=>{V(ue=>({...ue,[ee]:!ue[ee]}))},H=(ee,ue)=>{x(G=>G.map(ae=>{if(ae.id!==ee)return ae;const De=ae.skillOverrides||[],Te=De.includes(ue);return{...ae,skillOverrides:Te?De.filter(Ve=>Ve!==ue):[...De,ue]}}))},J=(ee,ue)=>{x(G=>G.map(ae=>{if(ae.id!==ee)return ae;const De=ae.excludedRoleSkills||[],Te=De.includes(ue);return{...ae,excludedRoleSkills:Te?De.filter(Ve=>Ve!==ue):[...De,ue]}}))},ie=ee=>{const ue=te(ee.role),G=ee.excludedRoleSkills||[];return ue.filter(ae=>!G.includes(ae))},te=ee=>{const ue=M[ee];return(ue==null?void 0:ue.assignedSkills)||[]},se=ee=>g.find(ue=>ue.id===ee);F.useEffect(()=>{var ee;if(r&&(j({name:r.name||"",projectPath:((ee=r.projectIds)==null?void 0:ee[0])||r.projectPath||"",parentTeamId:r.parentTeamId||""}),T({hierarchical:r.hierarchical||!1,leaderId:r.leaderId||null,leaderIds:r.leaderIds||(r.leaderId?[r.leaderId]:[])}),r.members&&Array.isArray(r.members))){const ue=r.members.map((G,ae)=>({...G,runtimeType:G.runtimeType||"claude-code",avatar:G.avatar||X[ae%X.length],skillOverrides:G.skillOverrides||[],excludedRoleSkills:G.excludedRoleSkills||[]}));x(ue),ue.forEach(G=>{G.role&&B(G.role)})}},[r,B]),F.useEffect(()=>{if(P.length>0&&b.length===0&&!r){const ue=P.filter(G=>G.isDefault).map((G,ae)=>({id:(ae+1).toString(),name:G.displayName,role:G.key,systemPrompt:`Load from ${G.promptFile}`,runtimeType:"claude-code",avatar:X[ae%X.length],skillOverrides:[],excludedRoleSkills:[]}));ue.length>0&&(x(ue),ue.forEach(G=>{B(G.role)}))}},[P,b.length,r,B]);const Z=ee=>{const{name:ue,value:G}=ee.target;j(ae=>({...ae,[ue]:G}))},Y=(ee,ue,G)=>{x(ae=>ae.map(De=>{if(De.id===ee){const Te={...De,[ue]:G};if(ue==="role"){const Ve=P.find(me=>me.key===G);Ve&&(Te.systemPrompt=`Load from ${Ve.promptFile}`),Te.skillOverrides=[],Te.excludedRoleSkills=[],B(G)}return Te}return De}))},X=["https://picsum.photos/seed/1/64","https://picsum.photos/seed/2/64","https://picsum.photos/seed/3/64","https://picsum.photos/seed/4/64","https://picsum.photos/seed/5/64","https://picsum.photos/seed/6/64"],z=()=>{const ee=(Math.max(...b.map(ae=>parseInt(ae.id)))+1).toString(),ue=P.find(ae=>ae.key==="fullstack-dev"),G={id:ee,name:"Fullstack Developer",role:"fullstack-dev",systemPrompt:ue?`Load from ${ue.promptFile}`:"Default fullstack developer prompt",runtimeType:"claude-code",avatar:X[b.length%X.length],skillOverrides:[],excludedRoleSkills:[]};x(ae=>[...ae,G]),B("fullstack-dev")},oe=ee=>{b.length>1&&x(ue=>ue.filter(G=>G.id!==ee))},le=async ee=>{if(ee.preventDefault(),!(!N.name.trim()||b.length===0)){for(const ue of b)if(!ue.name.trim()){n("All team members must have a name");return}k(!0);try{const ue=u.find(ae=>ae.id===N.projectPath),G={...N,members:b.map(ae=>({name:ae.name,role:ae.role,systemPrompt:ae.systemPrompt,runtimeType:ae.runtimeType,avatar:ae.avatar,skillOverrides:ae.skillOverrides||[],excludedRoleSkills:ae.excludedRoleSkills||[]})),projectIds:N.projectPath?[N.projectPath]:[],projectPath:ue?ue.path:void 0,parentTeamId:N.parentTeamId||null,hierarchical:D.hierarchical,leaderId:D.hierarchical?D.leaderId:void 0,leaderIds:D.hierarchical?D.leaderIds:void 0};await t(G)}catch(ue){console.error("Error submitting team:",ue)}finally{k(!1)}}},fe=ee=>{ee.preventDefault(),le(ee)};return s?i.jsxDEV(i.Fragment,{children:[i.jsxDEV("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:e,children:i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg w-full max-w-2xl m-4",onClick:ee=>ee.stopPropagation(),children:[i.jsxDEV("div",{className:"p-6",children:[i.jsxDEV("div",{className:"flex items-start justify-between",children:[i.jsxDEV("div",{children:[i.jsxDEV("h3",{className:"text-xl font-semibold text-text-primary-dark",children:r?"Edit Team":"Create New Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:347,columnNumber:17},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mt-1",children:r?"Modify team configuration and members":"Configure the details for your new AI agent team."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:350,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:346,columnNumber:15},globalThis),i.jsxDEV("button",{onClick:e,className:"w-8 h-8 -mt-1 -mr-1 rounded-lg hover:bg-background-dark flex items-center justify-center text-text-secondary-dark hover:text-text-primary-dark",children:i.jsxDEV("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:359,columnNumber:19},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:358,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:354,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:345,columnNumber:13},globalThis),i.jsxDEV("form",{onSubmit:fe,className:"mt-6 space-y-6 max-h-[60vh] overflow-y-auto pr-2",children:[i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"team-name",children:"Team Name"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:365,columnNumber:17},globalThis),i.jsxDEV(mn,{id:"team-name",type:"text",value:N.name,onChange:Z,name:"name",placeholder:"e.g., Frontend Wizards",required:!0},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:366,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:364,columnNumber:15},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"project-assignment",children:"Assigned Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:378,columnNumber:17},globalThis),i.jsxDEV(zc,{id:"project-assignment",value:N.projectPath||"",onChange:Z,name:"projectPath",children:[i.jsxDEV("option",{value:"",children:"No project assigned"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:385,columnNumber:19},globalThis),u.map(ee=>i.jsxDEV("option",{value:ee.id,children:ee.name},ee.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:387,columnNumber:21},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:379,columnNumber:17},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Optionally assign a project for this team to work on"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:390,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:377,columnNumber:15},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"parent-team",children:"Parent Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:396,columnNumber:17},globalThis),i.jsxDEV(zc,{id:"parent-team",value:N.parentTeamId||"",onChange:Z,name:"parentTeamId",children:[i.jsxDEV("option",{value:"",children:"None (Independent Team)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:403,columnNumber:19},globalThis),f.filter(ee=>ee.id!==(r==null?void 0:r.id)&&ee.id!=="orchestrator").map(ee=>i.jsxDEV("option",{value:ee.id,children:ee.name},ee.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:407,columnNumber:23},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:397,columnNumber:17},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Optionally link this team under a parent team for organization"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:410,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:395,columnNumber:15},globalThis),i.jsxDEV(C9,{config:D,onChange:T,members:b},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:415,columnNumber:15},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{children:"Team Members"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:422,columnNumber:17},globalThis),i.jsxDEV("div",{className:"space-y-4",children:[b.map((ee,ue)=>{var G,ae,De,Te;return i.jsxDEV("div",{className:"p-4 border border-border-dark rounded-lg space-y-4 bg-background-dark/50",children:[i.jsxDEV("div",{children:[i.jsxDEV(Fr,{children:"Avatar"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:427,columnNumber:25},globalThis),i.jsxDEV("div",{className:"flex items-center gap-4",children:[i.jsxDEV("img",{src:ee.avatar||X[0],alt:"Selected Avatar",className:"w-12 h-12 rounded-full ring-2 ring-primary/50"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:429,columnNumber:27},globalThis),i.jsxDEV("div",{className:"flex flex-wrap gap-2 flex-1",children:X.map(Ve=>i.jsxDEV("img",{src:Ve,alt:"Avatar option",onClick:()=>Y(ee.id,"avatar",Ve),className:`w-9 h-9 rounded-full cursor-pointer transition-all ${ee.avatar===Ve?"ring-2 ring-primary":"ring-2 ring-transparent hover:ring-primary/50"}`},Ve,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:436,columnNumber:31},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:434,columnNumber:27},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:428,columnNumber:25},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:426,columnNumber:23},globalThis),i.jsxDEV("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:`member-name-${ue}`,children:"Agent Name"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:449,columnNumber:27},globalThis),i.jsxDEV(mn,{id:`member-name-${ue}`,type:"text",value:ee.name,onChange:Ve=>Y(ee.id,"name",Ve.target.value),placeholder:"e.g., Agent Smith",required:!0},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:450,columnNumber:27},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:448,columnNumber:25},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:`member-role-${ue}`,children:"Role"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:460,columnNumber:27},globalThis),i.jsxDEV(zc,{id:`member-role-${ue}`,value:ee.role,onChange:Ve=>Y(ee.id,"role",Ve.target.value),required:!0,children:[i.jsxDEV("option",{value:"",children:"Select role"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:467,columnNumber:29},globalThis),P.filter(Ve=>!Ve.hidden).map(Ve=>i.jsxDEV("option",{value:Ve.key,children:Ve.displayName},Ve.key,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:469,columnNumber:31},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:461,columnNumber:27},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:459,columnNumber:25},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:447,columnNumber:23},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:`runtime-type-${ue}`,children:"Runtime Type"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:475,columnNumber:25},globalThis),i.jsxDEV(zc,{id:`runtime-type-${ue}`,value:ee.runtimeType,onChange:Ve=>Y(ee.id,"runtimeType",Ve.target.value),required:!0,children:[i.jsxDEV("option",{value:"claude-code",children:"Claude CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:482,columnNumber:27},globalThis),i.jsxDEV("option",{value:"gemini-cli",children:"Gemini CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:483,columnNumber:27},globalThis),i.jsxDEV("option",{value:"codex-cli",children:"Codex CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:484,columnNumber:27},globalThis),i.jsxDEV("option",{value:"crewly-agent",children:"Crewly Agent"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:485,columnNumber:27},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:476,columnNumber:25},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:474,columnNumber:23},globalThis),ee.role&&i.jsxDEV("div",{className:"border-t border-border-dark pt-3",children:[i.jsxDEV("button",{type:"button",onClick:()=>O(ee.id),className:"flex items-center gap-2 text-sm font-medium text-text-primary-dark hover:text-primary w-full",children:[U[ee.id]?i.jsxDEV(hx,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:498,columnNumber:31},globalThis):i.jsxDEV(Jf,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:500,columnNumber:31},globalThis),i.jsxDEV("span",{children:"Skills"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:502,columnNumber:29},globalThis),i.jsxDEV("span",{className:"text-xs text-text-secondary-dark ml-1",children:["(",ie(ee).length," from role",(((G=ee.excludedRoleSkills)==null?void 0:G.length)||0)>0&&` - ${(ae=ee.excludedRoleSkills)==null?void 0:ae.length} excluded`,(((De=ee.skillOverrides)==null?void 0:De.length)||0)>0&&` + ${(Te=ee.skillOverrides)==null?void 0:Te.length} additional`,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:503,columnNumber:29},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:492,columnNumber:27},globalThis),U[ee.id]&&i.jsxDEV("div",{className:"mt-3 space-y-2",children:[te(ee.role).length>0&&i.jsxDEV("div",{className:"space-y-1",children:[i.jsxDEV("p",{className:"text-xs text-text-secondary-dark font-medium uppercase tracking-wide",children:["From Role ",i.jsxDEV("span",{className:"font-normal",children:"(click to exclude for this member)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:516,columnNumber:47},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:515,columnNumber:35},globalThis),i.jsxDEV("div",{className:"flex flex-wrap gap-1.5",children:te(ee.role).map(Ve=>{var be;const me=se(Ve),Je=(be=ee.excludedRoleSkills)==null?void 0:be.includes(Ve);return i.jsxDEV("button",{type:"button",onClick:()=>J(ee.id,Ve),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md border transition-colors cursor-pointer ${Je?"bg-rose-500/10 border-rose-500/30 text-rose-400 hover:bg-rose-500/20":"bg-primary/10 border-primary/30 text-primary hover:bg-primary/20"}`,title:Je?`Click to re-enable "${(me==null?void 0:me.name)||Ve}" for this member`:`Click to exclude "${(me==null?void 0:me.name)||Ve}" for this member`,children:[Je?i.jsxDEV(ho,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:534,columnNumber:57},globalThis):i.jsxDEV(El,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:534,columnNumber:85},globalThis),(me==null?void 0:me.name)||Ve]},Ve,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:523,columnNumber:41},globalThis)})},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:518,columnNumber:35},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:514,columnNumber:33},globalThis),i.jsxDEV("div",{className:"space-y-1",children:[i.jsxDEV("p",{className:"text-xs text-text-secondary-dark font-medium uppercase tracking-wide",children:"Additional Skills"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:545,columnNumber:33},globalThis),v?i.jsxDEV("p",{className:"text-xs text-text-secondary-dark",children:"Loading skills..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:549,columnNumber:35},globalThis):i.jsxDEV("div",{className:"flex flex-wrap gap-1.5",children:[g.filter(Ve=>!te(ee.role).includes(Ve.id)).map(Ve=>{var Je;const me=(Je=ee.skillOverrides)==null?void 0:Je.includes(Ve.id);return i.jsxDEV("button",{type:"button",onClick:()=>H(ee.id,Ve.id),className:`inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md border transition-colors ${me?"bg-emerald-500/10 border-emerald-500/30 text-emerald-400":"bg-background-dark border-border-dark text-text-secondary-dark hover:border-primary/50 hover:text-text-primary-dark"}`,title:Ve.description,children:[me?i.jsxDEV(El,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:569,columnNumber:47},globalThis):i.jsxDEV($a,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:571,columnNumber:47},globalThis),Ve.name]},Ve.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:557,columnNumber:43},globalThis)}),g.filter(Ve=>!te(ee.role).includes(Ve.id)).length===0&&i.jsxDEV("p",{className:"text-xs text-text-secondary-dark",children:"No additional skills available"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:578,columnNumber:39},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:551,columnNumber:35},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:544,columnNumber:31},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:511,columnNumber:29},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:491,columnNumber:25},globalThis),i.jsxDEV("div",{className:"flex justify-end",children:i.jsxDEV("button",{type:"button",onClick:()=>oe(ee.id),className:"text-text-secondary-dark hover:text-red-500 h-auto p-0 text-sm flex items-center gap-1",children:[i.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:595,columnNumber:29},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:594,columnNumber:27},globalThis),"Delete Member"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:589,columnNumber:25},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:588,columnNumber:23},globalThis)]},ee.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:425,columnNumber:21},globalThis)}),i.jsxDEV("button",{type:"button",onClick:z,className:"w-full flex items-center justify-center gap-2 py-2 border-2 border-dashed border-border-dark rounded-lg text-text-secondary-dark hover:text-primary hover:border-primary transition-colors",children:[i.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:608,columnNumber:23},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:607,columnNumber:21},globalThis),i.jsxDEV("span",{children:"Add Team Member"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:610,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:602,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:423,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:421,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:363,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:344,columnNumber:11},globalThis),i.jsxDEV("div",{className:"bg-background-dark px-6 py-4 rounded-b-xl border-t border-border-dark flex justify-end gap-3",children:[i.jsxDEV(pr,{variant:"secondary",onClick:e,type:"button",children:"Cancel"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:617,columnNumber:13},globalThis),i.jsxDEV(pr,{variant:"primary",type:"submit",onClick:fe,disabled:!N.name.trim()||b.length===0||E||c||d||m,children:E?i.jsxDEV("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-current border-t-transparent"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:627,columnNumber:17},globalThis):i.jsxDEV("span",{className:"inline-flex items-center gap-2",children:[i.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:r?"M5 13l4 4L19 7":"M12 6v6m0 0v6m0-6h6m-6 0H6"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:631,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:630,columnNumber:19},globalThis),r?"Save Changes":"Create Team"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:629,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:620,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:616,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:343,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:342,columnNumber:7},globalThis),i.jsxDEV(o,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:640,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamModal.tsx",lineNumber:341,columnNumber:5},globalThis):null},eJ=({member:s,teamId:e,onClose:t})=>{const[r,n]=F.useState(null),[o,a]=F.useState(!1),[c,u]=F.useState(null),[d,f]=F.useState(!1),[m,g]=F.useState(null),[v,N]=F.useState(!1),[j,b]=F.useState("prompt"),x=F.useRef(null);F.useEffect(()=>(D(),()=>{E()}),[s.id,e]);const D=async()=>{if(!s.sessionName){u("No active session for this team member");return}try{a(!0),u(null),tr.isConnected()||await tr.connect(),T(),tr.subscribeToSession(s.sessionName),await k()}catch(B){console.error("Error initializing terminal:",B),u("Failed to connect to terminal"),N(!1)}finally{a(!1)}},T=()=>{if(!s.sessionName)return;const B=te=>{te.sessionName===s.sessionName&&(n(se=>({...se,memberId:s.id,memberName:s.name,sessionName:s.sessionName,output:te.content,timestamp:te.timestamp})),setTimeout(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},10))},O=te=>{te.sessionName===s.sessionName&&(n({memberId:s.id,memberName:s.name,sessionName:s.sessionName,output:te.content,timestamp:te.timestamp}),N(!0),u(null))},H=te=>{te.sessionName===s.sessionName&&(console.log("Successfully subscribed to session:",te.sessionName),N(!0),u(null))},J=te=>{te.sessionName===s.sessionName&&(console.error("WebSocket error for session:",te),u(te.error||"WebSocket error occurred"),N(!1))},ie=()=>{N(!0)};return tr.on("terminal_output",B),tr.on("initial_terminal_state",O),tr.on("subscription_confirmed",H),tr.on("error",J),tr.on("connected",ie),()=>{tr.off("terminal_output",B),tr.off("initial_terminal_state",O),tr.off("subscription_confirmed",H),tr.off("error",J),tr.off("connected",ie)}},E=()=>{m&&clearInterval(m),s.sessionName&&tr.isConnected()&&tr.unsubscribeFromSession(s.sessionName)};F.useEffect(()=>{if(d){const B=setInterval(()=>{k()},15e3);g(B)}else m&&(clearInterval(m),g(null));return()=>{m&&clearInterval(m)}},[d]);const k=async()=>{if(!s.sessionName){u("No active session for this team member");return}a(!0),u(null);try{const B=await fetch(`/api/teams/${e}/members/${s.id}/session?lines=100`);if(B.ok){const O=await B.json();O.success?n(O.data):u(O.error||"Failed to fetch session data")}else{const O=await B.json();u(O.error||"Failed to fetch session data")}}catch(B){u("Network error while fetching session data"),console.error("Error fetching session data:",B)}finally{a(!1)}},U=B=>{B.target===B.currentTarget&&t()},V=B=>({orchestrator:"#8b5cf6",pm:"#3b82f6",developer:"#10b981",qa:"#f59e0b",tester:"#ef4444",designer:"#ec4899"})[B]||"#6b7280",M=B=>({inactive:"#6b7280",activating:"#f59e0b",active:"#059669"})[B]||"#6b7280",R=B=>({idle:"#6b7280",in_progress:"#10b981"})[B]||"#6b7280",P=B=>new Date(B).toLocaleString();return i.jsxDEV("div",{className:"modal-overlay",onClick:U,children:i.jsxDEV("div",{className:"modal-content member-modal-content",children:[i.jsxDEV("div",{className:"modal-header",children:[i.jsxDEV("div",{className:"member-header-info",children:[i.jsxDEV("h2",{children:s.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:260,columnNumber:13},globalThis),i.jsxDEV("div",{className:"member-badges",children:[i.jsxDEV("span",{className:"role-badge",style:{backgroundColor:V(s.role)},children:s.role},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:262,columnNumber:15},globalThis),i.jsxDEV("span",{className:"status-badge",style:{backgroundColor:M(s.agentStatus)},children:["Agent: ",s.agentStatus]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:268,columnNumber:15},globalThis),i.jsxDEV("span",{className:"status-badge",style:{backgroundColor:R(s.workingStatus)},children:["Work: ",s.workingStatus]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:274,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:261,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:259,columnNumber:11},globalThis),i.jsxDEV("button",{className:"close-button",onClick:t,children:"×"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:282,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:258,columnNumber:9},globalThis),i.jsxDEV("div",{className:"member-tabs",children:[i.jsxDEV("button",{className:`tab-button ${j==="prompt"?"active":""}`,onClick:()=>b("prompt"),children:"System Prompt"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:287,columnNumber:11},globalThis),i.jsxDEV("button",{className:`tab-button ${j==="terminal"?"active":""}`,onClick:()=>b("terminal"),children:"Terminal Output"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:293,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:286,columnNumber:9},globalThis),i.jsxDEV("div",{className:"member-modal-body",children:[j==="prompt"&&i.jsxDEV("div",{className:"system-prompt-panel",children:i.jsxDEV("div",{className:"system-prompt-content",children:i.jsxDEV("pre",{className:"system-prompt-text",children:s.systemPrompt},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:306,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:305,columnNumber:15},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:304,columnNumber:13},globalThis),j==="terminal"&&i.jsxDEV("div",{className:"terminal-panel",children:[i.jsxDEV("div",{className:"terminal-header",children:[i.jsxDEV("div",{className:"terminal-header-left",children:s.sessionName&&i.jsxDEV("span",{className:"session-name",children:["Session: ",s.sessionName]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:319,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:317,columnNumber:17},globalThis),i.jsxDEV("div",{className:"terminal-controls",children:[i.jsxDEV("div",{className:"connection-status",children:i.jsxDEV("span",{className:`status-indicator ${v?"connected":"disconnected"}`,children:v?"🟢 Live":"🔴 Offline"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:324,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:323,columnNumber:19},globalThis),i.jsxDEV("label",{className:"auto-refresh-toggle",children:[i.jsxDEV("input",{type:"checkbox",checked:d,onChange:B=>f(B.target.checked),disabled:v},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:329,columnNumber:21},globalThis),"Auto-refresh (fallback)"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:328,columnNumber:19},globalThis),i.jsxDEV(pr,{className:"refresh-button",onClick:k,disabled:o||v,variant:"secondary",size:"sm",children:o?"Loading...":"Manual Refresh"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:337,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:322,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:316,columnNumber:15},globalThis),i.jsxDEV("div",{className:"terminal-output",children:[o&&!r&&i.jsxDEV("div",{className:"loading-state",children:[i.jsxDEV("div",{className:"loading-spinner"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:352,columnNumber:21},globalThis),i.jsxDEV("p",{children:"Loading session data..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:353,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:351,columnNumber:19},globalThis),c&&i.jsxDEV("div",{className:"error-state",children:[i.jsxDEV("p",{children:["Error: ",c]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:359,columnNumber:21},globalThis),i.jsxDEV(pr,{onClick:k,className:"retry-button",variant:"outline",size:"sm",children:"Retry"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:360,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:358,columnNumber:19},globalThis),r&&i.jsxDEV("div",{className:"session-data",children:[i.jsxDEV("div",{className:"session-meta",children:i.jsxDEV("span",{children:["Last updated: ",P(r.timestamp)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:369,columnNumber:23},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:368,columnNumber:21},globalThis),i.jsxDEV("pre",{className:"terminal-content",ref:x,children:r.output||"No output available"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:371,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:367,columnNumber:19},globalThis),!o&&!c&&!r&&i.jsxDEV("div",{className:"empty-state",children:i.jsxDEV("p",{children:"No session data available"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:379,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:378,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:349,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:315,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:301,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:257,columnNumber:7},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Modals/TeamMemberModal.tsx",lineNumber:256,columnNumber:5},globalThis)},tJ=({team:s,onClick:e,onViewTeam:t,onEditTeam:r,onDeleteTeam:n,projectName:o})=>{var u;const a=s.members||[],c=a.some(d=>d.agentStatus==="active");return i.jsxDEV("div",{className:"flex items-center justify-between p-4 bg-surface-dark rounded-lg border border-border-dark hover:bg-background-dark hover:border-primary/50 transition-colors group",children:[i.jsxDEV("div",{className:"flex items-center gap-4 flex-grow cursor-pointer",onClick:e,children:[i.jsxDEV("div",{className:"p-3 bg-background-dark rounded-lg border border-transparent group-hover:border-primary/20 transition-colors",children:i.jsxDEV($o,{className:"text-text-secondary-dark group-hover:text-primary transition-colors"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:34,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:33,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("div",{children:[i.jsxDEV("p",{className:"font-semibold text-text-primary-dark",children:s.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:38,columnNumber:13},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:o||(((u=s.projectIds)==null?void 0:u.length)>0?s.projectIds.join(", "):"No Project")},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:39,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:37,columnNumber:11},globalThis),c&&i.jsxDEV("span",{className:"px-2 py-1 text-xs font-medium rounded-full bg-green-500/10 text-green-400",children:"Active"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:42,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:36,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:29,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex items-center gap-6",children:[i.jsxDEV("div",{className:"hidden md:flex -space-x-2",children:[a.slice(0,4).map((d,f)=>i.jsxDEV(T9,{name:d.name,avatar:d.avatar,size:"sm",className:"border-2 border-surface-dark"},d.id||f,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:51,columnNumber:13},globalThis)),a.length>4&&i.jsxDEV("div",{className:"w-8 h-8 rounded-full border-2 border-surface-dark bg-background-dark flex items-center justify-center text-xs font-medium text-text-secondary-dark",children:["+",a.length-4]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:60,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:49,columnNumber:9},globalThis),i.jsxDEV("div",{className:"hidden sm:flex items-center gap-2 text-sm text-text-secondary-dark w-28",children:[i.jsxDEV($o,{className:"text-base"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:66,columnNumber:11},globalThis),i.jsxDEV("span",{children:[a.length," Members"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:67,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:65,columnNumber:9},globalThis),i.jsxDEV("div",{onClick:d=>d.preventDefault(),children:i.jsxDEV(bx,{align:"bottom-right",items:[...t?[{label:"View Team",onClick:()=>t(s.id)}]:[],...r?[{label:"Edit Team",onClick:()=>r(s.id)}]:[],...n?[{label:"Delete Team",danger:!0,onClick:()=>n(s.id)}]:[]]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:70,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:69,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:48,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Teams/TeamListItem.tsx",lineNumber:28,columnNumber:5},globalThis)},SP=3e4,rJ=3e5,sJ=2;function nJ(s,e,t,r){const[n,o]=F.useState([]),[a,c]=F.useState(!1),[u,d]=F.useState(null),f=F.useRef(null),m=F.useRef(!0),g=F.useRef(0),v=F.useRef(s),N=F.useRef(t),j=F.useRef(r),b=F.useRef(e);v.current=s,N.current=t,j.current=r,b.current=e;const x=F.useCallback(()=>g.current===0?SP:Math.min(SP*Math.pow(sJ,g.current),rJ),[]),D=F.useCallback(()=>{if(!m.current||!b.current)return;f.current&&clearTimeout(f.current);const k=x();f.current=setTimeout(()=>{T()},k)},[x]),T=F.useCallback(async()=>{const k=v.current;if(!k||!m.current)return;const U={"Content-Type":"application/json",Authorization:`Bearer ${k}`};try{await fetch(`${xP}/devices/heartbeat`,{method:"POST",headers:U,body:JSON.stringify({deviceName:j.current,teams:N.current})});const M=await(await fetch(`${xP}/devices`,{headers:U})).json();m.current&&M.success&&(o(M.data||[]),d(null),g.current=0)}catch(V){m.current&&(g.current=Math.min(g.current+1,10),d(V instanceof Error?V.message:"Heartbeat failed"))}D()},[D]),E=F.useCallback(async()=>{c(!0),g.current=0,await T(),m.current&&c(!1)},[T]);return F.useEffect(()=>{if(m.current=!0,!e||!s){o([]),g.current=0;return}return c(!0),T().finally(()=>{m.current&&c(!1)}),()=>{m.current=!1,f.current&&(clearTimeout(f.current),f.current=null)}},[e,s,T]),{devices:n,isLoading:a,error:u,refresh:E}}function oJ(){const[s,e]=F.useState(null),[t,r]=F.useState(!0),[n,o]=F.useState(!1),[a,c]=F.useState(null),u=F.useRef(!0),d=F.useCallback(async()=>{try{const v=await es.getCloudStatus();u.current&&(e(v),c(null))}catch{u.current&&e({connected:!1,tier:null,cloudUrl:null,status:"disconnected"})}},[]);F.useEffect(()=>(u.current=!0,(async()=>{await d(),u.current&&r(!1)})(),()=>{u.current=!1}),[d]);const f=F.useCallback(async(v,N)=>{o(!0),c(null);try{const j=await es.connectToCloud(v,N);return u.current&&e({connected:j.connected,tier:j.tier,cloudUrl:j.cloudUrl,status:"connected"}),!0}catch(j){return u.current&&c(j instanceof Error?j.message:"Connection failed"),!1}finally{u.current&&o(!1)}},[]),m=F.useCallback(async()=>{o(!0),c(null);try{return await es.disconnectFromCloud(),u.current&&e({connected:!1,tier:null,cloudUrl:null,status:"disconnected"}),!0}catch(v){return u.current&&c(v instanceof Error?v.message:"Disconnect failed"),!1}finally{u.current&&o(!1)}},[]),g=F.useCallback(async()=>{await d()},[d]);return{isConnected:(s==null?void 0:s.connected)??!1,tier:(s==null?void 0:s.tier)??null,isLoading:t,isActioning:n,error:a,connect:f,disconnect:m,refresh:g}}const EP=["https://picsum.photos/seed/1/64","https://picsum.photos/seed/2/64","https://picsum.photos/seed/3/64","https://picsum.photos/seed/4/64","https://picsum.photos/seed/5/64","https://picsum.photos/seed/6/64"];function V9(s){return s.map((e,t)=>({...e,avatar:e.avatar||EP[t%EP.length]}))}const iJ=()=>{const s=gh(),[e,t]=F.useState([]),[r,n]=F.useState(""),[o,a]=F.useState("all"),[c,u]=F.useState(!1),[d,f]=F.useState(null),[m,g]=F.useState(""),[v,N]=F.useState(!0),[j,b]=F.useState("grid"),[x,D]=F.useState([]),{showError:T,AlertComponent:E}=Zp(),k=Object.fromEntries(x.map(ee=>[ee.id,ee.name])),[U,V]=F.useState("all"),{isConnected:M,tier:R}=oJ(),{getAccessToken:P}=t9(),B=M&&R==="pro"?P():null,O=F.useMemo(()=>e.map(ee=>({id:ee.id,name:ee.name,memberCount:ee.members.length})),[e]),H=M&&R==="pro",{devices:J,isLoading:ie,refresh:te}=nJ(B,H,O,typeof window<"u"&&window.location.hostname||"My Device"),se=F.useMemo(()=>{let ee=e;return r&&(ee=ee.filter(ue=>{var G;return ue.name.toLowerCase().includes(r.toLowerCase())||ue.description&&ue.description.toLowerCase().includes(r.toLowerCase())||((G=ue.projectIds)==null?void 0:G.length)>0&&ue.projectIds.some(ae=>ae.toLowerCase().includes(r.toLowerCase()))||ue.members.some(ae=>ae.name.toLowerCase().includes(r.toLowerCase())||ae.role.toLowerCase().includes(r.toLowerCase()))})),o!=="all"&&(ee=ee.filter(ue=>o==="active"?ue.members.some(G=>G.agentStatus==="active"):o==="inactive"?ue.members.every(G=>G.agentStatus==="inactive"):!0)),U!=="all"&&(ee=ee.filter(ue=>{var G;return(G=ue.projectIds)==null?void 0:G.includes(U)})),ee=ee.filter(ue=>!ue.parentTeamId),ee},[e,r,o,U]),Z=F.useMemo(()=>{const ee=new Map;for(const ue of e)ue.parentTeamId&&ee.set(ue.parentTeamId,(ee.get(ue.parentTeamId)||0)+1);return ee},[e]),Y=F.useCallback(ee=>{t(ue=>ue.map(G=>G.id===ee.teamId?{...G,members:G.members.map(ae=>ae.id===ee.memberId||ae.sessionName===ee.sessionName?{...ae,agentStatus:ee.agentStatus}:ae)}:G))},[]);F.useEffect(()=>{z(),X()},[]),F.useEffect(()=>(tr.on("team_member_status_changed",Y),()=>{tr.off("team_member_status_changed",Y)}),[Y]);const X=async()=>{try{const ee=await es.getProjects();D(ee.map(ue=>({id:ue.id,name:ue.name})))}catch(ee){kp(ee,{context:"Loading projects for filter"})}},z=async()=>{try{const ue=(await es.getTeams()).map(G=>({...G,members:V9(G.members)}));t(ue)}catch(ee){kp(ee,{context:"fetchTeams"}),t([])}finally{N(!1)}},oe=async ee=>{try{const ue=await fetch("/api/teams",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ee)});if(ue.ok){const G=await ue.json(),ae=G.success?G.data:G;ae&&(t(De=>[...De,ae]),u(!1))}else{const G=await ue.json();T("Error creating team: "+(G.error||"Unknown error"))}}catch(ue){kp(ue,{context:"handleCreateTeam"}),T("Error creating team: "+(ue instanceof Error?ue.message:"Unknown error"))}},le=ee=>{s(`/teams/${ee.id}`)},fe=()=>{f(null),g("")};return v?i.jsxDEV("div",{className:"flex items-center justify-center min-h-[400px]",children:i.jsxDEV("div",{className:"text-center",children:[i.jsxDEV("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4 mx-auto"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:214,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-text-secondary-dark",children:"Loading teams..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:215,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:213,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:212,columnNumber:7},globalThis):i.jsxDEV("div",{className:"max-w-7xl mx-auto",children:[i.jsxDEV("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between gap-4 mb-8",children:[i.jsxDEV("div",{children:[i.jsxDEV("h2",{className:"text-3xl font-bold tracking-tight",children:"Teams"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:225,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Manage and organize your development teams"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:226,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:224,columnNumber:9},globalThis),i.jsxDEV("button",{className:"bg-primary text-white px-4 py-2 rounded-lg hover:bg-primary/90 transition-colors flex items-center gap-2",onClick:()=>u(!0),children:[i.jsxDEV($a,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:233,columnNumber:11},globalThis),"New Team"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:229,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:223,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex flex-col md:flex-row items-center gap-4 mb-3",children:i.jsxDEV("div",{className:"relative flex-grow w-full md:w-auto",children:i.jsxDEV("input",{type:"text",placeholder:"Search teams...",value:r,onChange:ee=>n(ee.target.value),className:"w-full bg-surface-dark border border-border-dark rounded-lg px-4 py-2.5 text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary transition-colors"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:241,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:240,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:239,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4 mb-6",children:[i.jsxDEV("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Status:"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:254,columnNumber:11},globalThis),i.jsxDEV("button",{className:`chip ${o==="all"?"chip--active":""}`,onClick:()=>a("all"),children:"All"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:255,columnNumber:11},globalThis),i.jsxDEV("button",{className:`chip ${o==="active"?"chip--active":""}`,onClick:()=>a("active"),children:"Active"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:256,columnNumber:11},globalThis),i.jsxDEV("button",{className:`chip ${o==="inactive"?"chip--active":""}`,onClick:()=>a("inactive"),children:"Inactive"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:257,columnNumber:11},globalThis),i.jsxDEV("span",{className:"ml-2 text-sm text-text-secondary-dark",children:"Project:"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:258,columnNumber:11},globalThis),i.jsxDEV("select",{value:U,onChange:ee=>V(ee.target.value),className:"bg-surface-dark border border-border-dark rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",children:[i.jsxDEV("option",{value:"all",children:"All"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:264,columnNumber:13},globalThis),x.map(ee=>i.jsxDEV("option",{value:ee.id,children:ee.name},ee.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:266,columnNumber:15},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:259,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:253,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("button",{onClick:()=>b("grid"),className:`inline-flex items-center justify-center w-9 h-9 rounded-lg border border-border-dark ${j==="grid"?"bg-primary/10 text-primary":"text-text-secondary-dark hover:text-text-primary-dark hover:border-primary/50"}`,title:"Grid view",children:i.jsxDEV(vK,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:276,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:271,columnNumber:11},globalThis),i.jsxDEV("button",{onClick:()=>b("list"),className:`inline-flex items-center justify-center w-9 h-9 rounded-lg border border-border-dark ${j==="list"?"bg-primary/10 text-primary":"text-text-secondary-dark hover:text-text-primary-dark hover:border-primary/50"}`,title:"List view",children:i.jsxDEV(NK,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:283,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:278,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:270,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:252,columnNumber:7},globalThis),H&&i.jsxDEV("div",{className:"mb-8",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV(fx,{className:"w-4 h-4 text-primary"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:293,columnNumber:15},globalThis),i.jsxDEV("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide",children:["Online Devices (",J.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:294,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:292,columnNumber:13},globalThis),i.jsxDEV("button",{onClick:te,className:"p-1.5 text-text-secondary-dark hover:text-text-primary-dark rounded-lg hover:bg-surface-dark transition-colors",title:"Refresh devices",children:i.jsxDEV(dc,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:303,columnNumber:15},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:298,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:291,columnNumber:11},globalThis),ie?i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-6 text-center",children:[i.jsxDEV("div",{className:"w-5 h-5 border-2 border-primary/20 border-t-primary rounded-full animate-spin mx-auto mb-2"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:309,columnNumber:15},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark",children:"Discovering devices..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:310,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:308,columnNumber:13},globalThis):J.length===0?i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-6 text-center",children:[i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:"No other devices online"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:314,columnNumber:15},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark/70 mt-1",children:"Other Pro users will appear here when they are online"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:315,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:313,columnNumber:13},globalThis):i.jsxDEV("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:J.map(ee=>i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-4",children:[i.jsxDEV("div",{className:"flex items-center gap-2 mb-2",children:[i.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:327,columnNumber:21},globalThis),i.jsxDEV("span",{className:"text-sm font-medium text-text-primary-dark truncate",children:ee.deviceName},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:328,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:326,columnNumber:19},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mb-3 font-mono truncate",children:ee.email},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:332,columnNumber:19},globalThis),ee.teams.length>0&&i.jsxDEV("div",{className:"space-y-1.5",children:[i.jsxDEV("p",{className:"text-xs text-text-secondary-dark/70 uppercase tracking-wide",children:["Teams (",ee.teams.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:337,columnNumber:23},globalThis),ee.teams.map(ue=>i.jsxDEV("div",{className:"flex items-center justify-between text-xs bg-background-dark rounded px-2 py-1.5",children:[i.jsxDEV("span",{className:"text-text-primary-dark truncate",children:ue.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:345,columnNumber:27},globalThis),i.jsxDEV("span",{className:"text-text-secondary-dark ml-2 shrink-0",children:[ue.memberCount," member",ue.memberCount!==1?"s":""]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:346,columnNumber:27},globalThis)]},ue.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:341,columnNumber:25},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:336,columnNumber:21},globalThis)]},ee.deviceId,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:322,columnNumber:17},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:320,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:290,columnNumber:9},globalThis),se.length>0&&i.jsxDEV(i.Fragment,{children:j==="grid"?i.jsxDEV("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6",children:[se.map(ee=>{var ue;return i.jsxDEV(j9,{team:ee,projectName:((ue=ee.projectIds)==null?void 0:ue.length)>0?k[ee.projectIds[0]]:void 0,subTeamCount:Z.get(ee.id),onClick:()=>le(ee),onViewTeam:G=>s(`/teams/${G}`),onEditTeam:G=>s(`/teams/${G}?edit=true`)},ee.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:366,columnNumber:17},globalThis)}),i.jsxDEV("div",{onClick:()=>u(!0),className:"flex items-center justify-center p-5 rounded-xl border-2 border-dashed border-border-dark hover:border-primary transition-colors cursor-pointer text-text-secondary-dark hover:text-primary",children:[i.jsxDEV($a,{className:"mr-2 w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:380,columnNumber:17},globalThis),i.jsxDEV("span",{children:"Create New Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:381,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:376,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:364,columnNumber:13},globalThis):i.jsxDEV("div",{className:"space-y-4",children:[se.map(ee=>{var ue;return i.jsxDEV(tJ,{team:ee,projectName:((ue=ee.projectIds)==null?void 0:ue.length)>0?k[ee.projectIds[0]]:void 0,onClick:()=>le(ee),onViewTeam:G=>s(`/teams/${G}`),onEditTeam:G=>s(`/teams/${G}?edit=true`),onDeleteTeam:async G=>{if(window.confirm("Are you sure you want to delete this team?"))try{await es.deleteTeam(G),t(ae=>ae.filter(De=>De.id!==G))}catch(ae){T("Failed to delete team: "+(ae instanceof Error?ae.message:"Unknown error"))}}},ee.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:387,columnNumber:17},globalThis)}),i.jsxDEV("div",{onClick:()=>u(!0),className:"flex items-center justify-center p-4 rounded-lg border-2 border-dashed border-border-dark hover:border-primary transition-colors cursor-pointer text-text-secondary-dark hover:text-primary",children:[i.jsxDEV($a,{className:"mr-2 w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:410,columnNumber:17},globalThis),i.jsxDEV("span",{children:"Create New Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:411,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:406,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:385,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:362,columnNumber:9},globalThis),se.length===0&&!v&&i.jsxDEV("div",{className:"text-center py-16",children:[i.jsxDEV("h3",{className:"text-lg font-semibold mb-2",children:"No teams found"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:420,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mb-6",children:r||o!=="all"?"Try adjusting your search or filters":"Create your first team to get started"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:421,columnNumber:11},globalThis),!r&&o==="all"&&i.jsxDEV("button",{className:"bg-primary text-white px-6 py-3 rounded-lg hover:bg-primary/90 transition-colors inline-flex items-center gap-2",onClick:()=>u(!0),children:[i.jsxDEV($a,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:431,columnNumber:15},globalThis),"Create Team"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:427,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:419,columnNumber:9},globalThis),i.jsxDEV(R9,{isOpen:c,onClose:()=>u(!1),onSubmit:oe},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:438,columnNumber:7},globalThis),d&&m&&i.jsxDEV(eJ,{member:d,teamId:m,onClose:fe},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:445,columnNumber:9},globalThis),i.jsxDEV(E,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:451,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Teams.tsx",lineNumber:222,columnNumber:5},globalThis)},aJ=({isOpen:s,onClose:e,onStartTeam:t,team:r,loading:n})=>{var x,D;const{showWarning:o,AlertComponent:a}=Zp(),[c,u]=F.useState(""),[d,f]=F.useState([]),[m,g]=F.useState(!1),v=((x=r==null?void 0:r.projectIds)==null?void 0:x.length)>0;F.useEffect(()=>{s&&(N(),v&&u(r.projectIds[0]))},[s,v,r==null?void 0:r.projectIds]);const N=async()=>{g(!0);try{const T=await fetch("/api/projects");if(T.ok){const E=await T.json(),k=E.success?E.data||[]:E||[];f(Array.isArray(k)?k:[])}}catch(T){console.error("Error fetching projects:",T),f([])}finally{g(!1)}},j=T=>{if(T.preventDefault(),!v&&!c){o("Please select a project");return}const E=v?r.projectIds[0]:c;t(E),e()},b=()=>{if(!v)return"";const T=d.find(E=>{var k;return E.id===((k=r.projectIds)==null?void 0:k[0])});return T?T.name:"Unknown Project"};return i.jsxDEV(i.Fragment,{children:[i.jsxDEV(ST,{isOpen:s,onClose:e,title:"Start Team",subtitle:`Configure settings for ${(r==null?void 0:r.name)||"team"}`,size:"xl",onSubmit:j,submitText:n?"Starting...":"Proceed",submitDisabled:n||!v&&!c,loading:n,children:[i.jsxDEV(JK,{title:"Project Assignment",description:v?void 0:"Select which project this team will work on",children:v?i.jsxDEV("div",{className:"form-info-box form-info-box--success",children:i.jsxDEV("div",{className:"form-info-content",children:[i.jsxDEV("strong",{children:"Already assigned to:"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:101,columnNumber:8},globalThis)," ",b()]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:100,columnNumber:7},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:99,columnNumber:6},globalThis):i.jsxDEV(ET,{children:[i.jsxDEV(Fr,{htmlFor:"project-select",required:!0,children:"Select Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:106,columnNumber:7},globalThis),i.jsxDEV($K,{id:"project-select",value:c,onChange:u,placeholder:"Choose a project...",loading:m,required:!0,options:d.map(T=>({value:T.id,label:`${T.name} (${T.path})`}))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:109,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:105,columnNumber:6},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:92,columnNumber:4},globalThis),i.jsxDEV("div",{className:"form-info-box form-info-box--info",children:[i.jsxDEV("div",{className:"form-info-header",children:i.jsxDEV("h4",{children:["Team: ",r==null?void 0:r.name]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:127,columnNumber:6},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:126,columnNumber:5},globalThis),i.jsxDEV("div",{className:"form-info-content",children:[i.jsxDEV("div",{children:["Members: ",((D=r==null?void 0:r.members)==null?void 0:D.length)||0]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:130,columnNumber:6},globalThis),i.jsxDEV("div",{children:["Status: ",(r==null?void 0:r.status)||"idle"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:131,columnNumber:6},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:129,columnNumber:5},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:125,columnNumber:4},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:81,columnNumber:3},globalThis),i.jsxDEV(a,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:135,columnNumber:3},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/StartTeamModal.tsx",lineNumber:80,columnNumber:3},globalThis)},lJ=({team:s,teamStatus:e,orchestratorSessionActive:t,onStartTeam:r,onStopTeam:n,onViewTerminal:o,onDeleteTeam:a,onEditTeam:c,isStoppingTeam:u=!1,isStartingTeam:d=!1})=>{const f=(s==null?void 0:s.id)==="orchestrator"||(s==null?void 0:s.name)==="Orchestrator Team";return((s==null?void 0:s.members)||[]).filter(g=>g.agentStatus==="active"||g.sessionName).length,i.jsxDEV("div",{className:"page-header",children:[i.jsxDEV("div",{className:"header-info",children:i.jsxDEV("div",{className:"flex items-center gap-3 mb-1",children:i.jsxDEV("h1",{className:"page-title mb-0",children:s.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:27,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:26,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:25,columnNumber:7},globalThis),i.jsxDEV("div",{className:"header-controls",children:[e==="idle"&&!d?i.jsxDEV(pr,{variant:"success",onClick:r,icon:Pp,children:f?"Start Orchestrator":"Start Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:32,columnNumber:11},globalThis):d?i.jsxDEV(pr,{variant:"success",loading:!0,disabled:!0,children:"Starting..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:36,columnNumber:11},globalThis):i.jsxDEV(pr,{variant:"danger",onClick:n,icon:fV,loading:u,children:u?"Stopping...":f?"Stop Orchestrator":"Stop Team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:40,columnNumber:11},globalThis),f&&e==="active"&&i.jsxDEV(pr,{variant:"primary",onClick:o,icon:Ck,children:"View Terminal"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:50,columnNumber:11},globalThis),!f&&i.jsxDEV(bx,{align:"bottom-right",items:[{label:"Edit Team",onClick:c},{label:"Delete Team",danger:!0,onClick:a}]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:56,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:30,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamHeader.tsx",lineNumber:24,columnNumber:5},globalThis)},cJ=({member:s,teamId:e,onStart:t,onStop:r,onViewTerminal:n,onViewAgent:o,isStartingTeam:a})=>{const[c,u]=F.useState(!1),[d,f]=F.useState(!1),m=s.agentStatus==="active",g=s.agentStatus==="started",v=s.agentStatus==="starting"||s.agentStatus==="activating",N=m||g||v,j=v||c||a&&!m&&!g,b=c||d||a&&!m&&!g;let x="Inactive",D="bg-gray-500/10 text-gray-300";d?(x="Stopping...",D="bg-orange-500/10 text-orange-400"):s.agentStatus==="suspended"?(x="Suspended",D="bg-purple-500/10 text-purple-400"):m?(x="Active",D="bg-emerald-500/10 text-emerald-400"):g?(x="Started",D="bg-blue-500/10 text-blue-400"):j&&(x="Starting...",D="bg-yellow-500/10 text-yellow-400");const T=async U=>{if(U.stopPropagation(),t&&!b){u(!0);try{await t(s.id)}finally{u(!1)}}},E=async U=>{if(U.stopPropagation(),r&&!b){f(!0);try{await r(s.id)}finally{f(!1)}}},k=s.avatar;return i.jsxDEV("div",{className:"member-row",children:[i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("div",{className:"w-10 h-10 rounded-full bg-background-dark border border-border-dark flex items-center justify-center overflow-hidden",children:k?k.startsWith("http")||k.startsWith("data:")?i.jsxDEV("img",{src:k,alt:s.name,className:"w-full h-full object-cover"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:83,columnNumber:15},globalThis):i.jsxDEV("span",{className:"text-sm",children:k},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:85,columnNumber:15},globalThis):i.jsxDEV("span",{className:"text-sm",children:s.name.charAt(0).toUpperCase()},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:88,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:80,columnNumber:9},globalThis),i.jsxDEV("div",{children:[i.jsxDEV("div",{className:"font-semibold",children:s.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:92,columnNumber:11},globalThis),i.jsxDEV("div",{className:"text-sm text-text-secondary-dark",children:["Session: ",s.sessionName||"Inactive"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:93,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:91,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:79,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("span",{className:`px-3 py-1 rounded-full text-sm font-medium flex items-center gap-2 ${D}`,children:[b&&i.jsxDEV(Tb,{className:"w-3 h-3 animate-spin"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:98,columnNumber:25},globalThis),x]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:97,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex items-center gap-2",children:[(m||g||v||d)&&!c?i.jsxDEV("button",{className:`w-9 h-9 rounded-full flex items-center justify-center transition-colors ${b?"opacity-50 cursor-not-allowed":"hover:bg-red-500/20 hover:text-red-400"}`,title:"Stop",onClick:E,disabled:b,children:d?i.jsxDEV(Tb,{className:"w-4 h-4 animate-spin"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:114,columnNumber:17},globalThis):i.jsxDEV(fV,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:116,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:103,columnNumber:13},globalThis):i.jsxDEV("button",{className:`w-9 h-9 rounded-full flex items-center justify-center transition-colors ${b?"opacity-50 cursor-not-allowed":"hover:bg-green-500/20 hover:text-green-400"}`,title:"Start",onClick:T,disabled:b,children:c?i.jsxDEV(Tb,{className:"w-4 h-4 animate-spin"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:131,columnNumber:17},globalThis):i.jsxDEV(Pp,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:133,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:120,columnNumber:13},globalThis),i.jsxDEV(bx,{align:"bottom-right",buttonClassName:"w-9 h-9 rounded-full hover:bg-primary/20 hover:text-primary flex items-center justify-center transition-colors",items:[...o?[{label:N?"View Agent":"Edit Agent",onClick:()=>o(s)}]:[],...N&&s.sessionName&&n?[{label:"View Terminal",onClick:()=>n(s)}]:[]]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:137,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:101,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:96,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamMemberRow.tsx",lineNumber:78,columnNumber:5},globalThis)},uJ=({team:s,teamId:e,onUpdateMember:t,onDeleteMember:r,onStartMember:n,onStopMember:o,onViewTerminal:a,onViewAgent:c,isStartingTeam:u})=>{var d,f;return i.jsxDEV("div",{className:"space-y-4",children:[(d=s==null?void 0:s.members)==null?void 0:d.map(m=>i.jsxDEV(cJ,{member:m,teamId:e,onStart:n,onStop:o,onViewTerminal:a,onViewAgent:c,isStartingTeam:u},m.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/MembersList.tsx",lineNumber:19,columnNumber:9},globalThis)),!((f=s==null?void 0:s.members)!=null&&f.length)&&i.jsxDEV("div",{className:"empty-state",children:i.jsxDEV("p",{children:"No team members yet. Add members to get started."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/MembersList.tsx",lineNumber:32,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/MembersList.tsx",lineNumber:31,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/MembersList.tsx",lineNumber:17,columnNumber:5},globalThis)},dJ=({team:s,teamId:e,projectName:t,onUpdateMember:r,onDeleteMember:n,onStartMember:o,onStopMember:a,onProjectChange:c,onViewTerminal:u,onViewAgent:d,isStartingTeam:f})=>{var D,T;const[m,g]=F.useState(!1),[v,N]=F.useState(((D=s==null?void 0:s.projectIds)==null?void 0:D[0])||""),{projectOptions:j}=U9(),b=(s==null?void 0:s.id)==="orchestrator"||(s==null?void 0:s.name)==="Orchestrator Team";F.useEffect(()=>{var E;N(((E=s==null?void 0:s.projectIds)==null?void 0:E[0])||"")},[s==null?void 0:s.projectIds]);const x=E=>{N(E),c&&c(E||null),g(!1)};return i.jsxDEV("div",{className:`grid grid-cols-1 ${b?"":"lg:grid-cols-3"} gap-6`,children:[i.jsxDEV("div",{className:b?"":"lg:col-span-2",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:i.jsxDEV("h3",{className:"text-xl font-semibold",children:b?"Orchestrator":`Team Members (${((T=s.members)==null?void 0:T.length)||0})`},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:90,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:89,columnNumber:9},globalThis),i.jsxDEV(uJ,{team:s,teamId:e,onUpdateMember:r,onDeleteMember:n,onStartMember:o,onStopMember:a,onViewTerminal:u,onViewAgent:d,isStartingTeam:f},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:94,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:88,columnNumber:7},globalThis),!b&&i.jsxDEV("div",{className:"space-y-6",children:[i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-xl p-6",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[i.jsxDEV("h4",{className:"text-lg font-semibold",children:"Assigned Project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:111,columnNumber:15},globalThis),i.jsxDEV("button",{onClick:()=>g(!m),className:"p-1.5 hover:bg-background-dark rounded-lg transition-colors text-text-secondary-dark hover:text-primary",title:"Change project",children:i.jsxDEV(CK,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:117,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:112,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:110,columnNumber:13},globalThis),m?i.jsxDEV("div",{className:"space-y-3",children:[i.jsxDEV(zc,{value:v,onChange:E=>x(E.target.value),children:[i.jsxDEV("option",{value:"",children:"No project assigned"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:126,columnNumber:19},globalThis),j.map(E=>i.jsxDEV("option",{value:E.id,children:E.name},E.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:128,columnNumber:21},globalThis))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:122,columnNumber:17},globalThis),i.jsxDEV("button",{onClick:()=>g(!1),className:"text-sm text-text-secondary-dark hover:text-primary",children:"Cancel"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:131,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:121,columnNumber:15},globalThis):i.jsxDEV("div",{className:"flex items-center gap-3 cursor-pointer hover:bg-background-dark/50 -mx-3 px-3 py-2 rounded-lg transition-colors",onClick:()=>g(!0),title:"Click to change project",children:[i.jsxDEV(rl,{className:"h-5 w-5 text-primary"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:144,columnNumber:17},globalThis),i.jsxDEV("div",{className:"flex-1",children:[i.jsxDEV("div",{className:"font-semibold text-white",children:t||"No Project Assigned"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:146,columnNumber:19},globalThis),!t&&i.jsxDEV("div",{className:"text-sm text-text-secondary-dark",children:"Click to assign a project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:148,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:145,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:139,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:109,columnNumber:11},globalThis),i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-xl p-5",children:[i.jsxDEV("h4",{className:"text-lg font-semibold mb-3",children:"Recent Activity"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:155,columnNumber:13},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:"No recent activity."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:156,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:154,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:108,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/TeamOverview.tsx",lineNumber:87,columnNumber:5},globalThis)},hJ=["development","management","quality","design","sales","support","automation"],AV={development:"Development",management:"Management",quality:"Quality",design:"Design",sales:"Sales",support:"Support",automation:"Automation"},fJ=({member:s,onClose:e,isEditable:t=!1,onSave:r})=>{const[n,o]=F.useState(null),[a,c]=F.useState(!0),[u,d]=F.useState([]),[f,m]=F.useState(s.runtimeType||"claude-code"),{skills:g}=XC();F.useEffect(()=>{(async()=>{if(s.role)try{const D=await Of.getRole(s.role);o(D)}catch(D){console.error("Failed to fetch role details:",D)}finally{c(!1)}else c(!1)})()},[s.role]),F.useEffect(()=>{var E;if(!n&&!((E=s.skillOverrides)!=null&&E.length))return;const D=[...((n==null?void 0:n.assignedSkills)||[]).filter(k=>{var U;return!((U=s.excludedRoleSkills)!=null&&U.includes(k))}),...s.skillOverrides||[]];if(D.length===0)return;const T=D.map(k=>{const U=g.find(V=>V.id===k);return{id:k,name:(U==null?void 0:U.name)||k}});d(T)},[n,s.skillOverrides,s.excludedRoleSkills,a,g]);const v=x=>u.find(D=>D.id===x),N=()=>{const x=((n==null?void 0:n.assignedSkills)||[]).filter(T=>{var E;return!((E=s.excludedRoleSkills)!=null&&E.includes(T))}),D=s.skillOverrides||[];return[...new Set([...x,...D])]},j=x=>{x.target===x.currentTarget&&e()},b=(x,D)=>{const T=v(x),E=(T==null?void 0:T.name)||x,k="inline-flex items-center gap-1.5 px-2.5 py-1 text-sm rounded-md",U=D==="role"?"bg-primary/10 text-primary":"bg-emerald-500/10 text-emerald-400";return i.jsxDEV("div",{children:i.jsxDEV("span",{className:`${k} ${U}`,children:[i.jsxDEV(El,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:135,columnNumber:11},globalThis),E]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:134,columnNumber:9},globalThis)},x,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:133,columnNumber:7},globalThis)};return i.jsxDEV("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:j,children:i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg w-full max-w-lg m-4",onClick:x=>x.stopPropagation(),children:[i.jsxDEV("div",{className:"flex items-center justify-between p-6 border-b border-border-dark",children:[i.jsxDEV("div",{className:"flex items-center gap-4",children:[i.jsxDEV("div",{className:"w-12 h-12 rounded-full bg-background-dark border border-border-dark flex items-center justify-center overflow-hidden",children:s.avatar?s.avatar.startsWith("http")||s.avatar.startsWith("data:")?i.jsxDEV("img",{src:s.avatar,alt:s.name,className:"w-full h-full object-cover"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:157,columnNumber:19},globalThis):i.jsxDEV("span",{className:"text-lg",children:s.avatar},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:159,columnNumber:19},globalThis):i.jsxDEV(mx,{className:"w-6 h-6 text-text-secondary-dark"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:162,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:154,columnNumber:13},globalThis),i.jsxDEV("div",{children:[i.jsxDEV("h2",{className:"text-xl font-semibold text-text-primary-dark",children:s.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:166,columnNumber:15},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:t?"Edit Agent":"Agent Details"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:167,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:165,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:153,columnNumber:11},globalThis),i.jsxDEV("button",{onClick:e,className:"w-8 h-8 rounded-lg hover:bg-background-dark flex items-center justify-center text-text-secondary-dark hover:text-text-primary-dark",children:i.jsxDEV(ho,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:174,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:170,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:152,columnNumber:9},globalThis),i.jsxDEV("div",{className:"p-6 space-y-6",children:[i.jsxDEV("div",{children:[i.jsxDEV("div",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary-dark uppercase tracking-wide mb-3",children:[i.jsxDEV(dK,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:183,columnNumber:15},globalThis),"Role"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:182,columnNumber:13},globalThis),a?i.jsxDEV("div",{className:"animate-pulse",children:[i.jsxDEV("div",{className:"h-6 bg-background-dark rounded w-32 mb-2"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:188,columnNumber:17},globalThis),i.jsxDEV("div",{className:"h-4 bg-background-dark rounded w-full"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:189,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:187,columnNumber:15},globalThis):n?i.jsxDEV("div",{className:"bg-background-dark/50 rounded-lg p-4",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[i.jsxDEV("span",{className:"font-semibold text-text-primary-dark",children:n.displayName},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:194,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-xs px-2 py-0.5 rounded-full bg-primary/10 text-primary",children:AV[n.category]||n.category},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:195,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:193,columnNumber:17},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:n.description},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:199,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:192,columnNumber:15},globalThis):i.jsxDEV("p",{className:"text-sm text-text-secondary-dark italic",children:"No role assigned"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:202,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:181,columnNumber:11},globalThis),i.jsxDEV("div",{children:[i.jsxDEV("div",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary-dark uppercase tracking-wide mb-3",children:[i.jsxDEV(m4,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:209,columnNumber:15},globalThis),"Skills"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:208,columnNumber:13},globalThis),a?i.jsxDEV("div",{className:"animate-pulse flex flex-wrap gap-2",children:[i.jsxDEV("div",{className:"h-7 bg-background-dark rounded-md w-24"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:214,columnNumber:17},globalThis),i.jsxDEV("div",{className:"h-7 bg-background-dark rounded-md w-32"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:215,columnNumber:17},globalThis),i.jsxDEV("div",{className:"h-7 bg-background-dark rounded-md w-28"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:216,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:213,columnNumber:15},globalThis):i.jsxDEV("div",{className:"space-y-3",children:[(n==null?void 0:n.assignedSkills)&&n.assignedSkills.length>0&&i.jsxDEV("div",{children:[i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mb-2",children:"From Role"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:223,columnNumber:21},globalThis),i.jsxDEV("div",{className:"flex flex-wrap gap-2",children:n.assignedSkills.filter(x=>{var D;return!((D=s.excludedRoleSkills)!=null&&D.includes(x))}).map(x=>b(x,"role"))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:224,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:222,columnNumber:19},globalThis),s.skillOverrides&&s.skillOverrides.length>0&&i.jsxDEV("div",{children:[i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mb-2",children:"Additional Skills"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:237,columnNumber:21},globalThis),i.jsxDEV("div",{className:"flex flex-wrap gap-2",children:s.skillOverrides.map(x=>b(x,"additional"))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:238,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:236,columnNumber:19},globalThis),N().length===0&&i.jsxDEV("p",{className:"text-sm text-text-secondary-dark italic",children:"No skills assigned"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:248,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:219,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:207,columnNumber:11},globalThis),i.jsxDEV("div",{children:[i.jsxDEV("div",{className:"flex items-center gap-2 text-sm font-medium text-text-secondary-dark uppercase tracking-wide mb-3",children:"Runtime"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:256,columnNumber:13},globalThis),t?i.jsxDEV("select",{value:f,onChange:x=>m(x.target.value),className:"w-full bg-background-dark border border-border-dark rounded-lg px-4 py-2 text-sm text-text-primary-dark focus:outline-none focus:border-primary",children:[i.jsxDEV("option",{value:"claude-code",children:"Claude CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:265,columnNumber:17},globalThis),i.jsxDEV("option",{value:"gemini-cli",children:"Gemini CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:266,columnNumber:17},globalThis),i.jsxDEV("option",{value:"codex-cli",children:"Codex CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:267,columnNumber:17},globalThis),i.jsxDEV("option",{value:"crewly-agent",children:"Crewly Agent"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:268,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:260,columnNumber:15},globalThis):i.jsxDEV("div",{className:"bg-background-dark/50 rounded-lg px-4 py-2",children:i.jsxDEV("span",{className:"text-sm text-text-primary-dark",children:s.runtimeType==="claude-code"?"Claude CLI":s.runtimeType==="gemini-cli"?"Gemini CLI":s.runtimeType==="codex-cli"?"Codex CLI":s.runtimeType==="crewly-agent"?"Crewly Agent":s.runtimeType||"Claude CLI"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:272,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:271,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:255,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:179,columnNumber:9},globalThis),i.jsxDEV("div",{className:"px-6 py-4 border-t border-border-dark bg-background-dark rounded-b-xl",children:t?i.jsxDEV("div",{className:"flex gap-3",children:[i.jsxDEV("button",{onClick:e,className:"flex-1 px-4 py-2 border border-border-dark text-text-secondary-dark rounded-lg hover:bg-surface-dark transition-colors font-medium",children:"Cancel"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:288,columnNumber:15},globalThis),i.jsxDEV("button",{onClick:()=>{r&&r(s.id,{runtimeType:f}),e()},className:"flex-1 px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors font-medium",children:"Save"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:294,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:287,columnNumber:13},globalThis):i.jsxDEV("button",{onClick:e,className:"w-full px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors font-medium",children:"Close"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:307,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:285,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:147,columnNumber:7},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/TeamDetail/AgentDetailModal.tsx",lineNumber:143,columnNumber:5},globalThis)},mJ=50;let pJ=0;function $E(){return`feed-${Date.now()}-${++pJ}`}function yJ(s=mJ,e){const[t,r]=F.useState([]),n=F.useRef(s);n.current=s;const o=F.useRef(e);o.current=e;const a=F.useCallback(u=>{r(d=>{const f=[u,...d];return f.length>n.current?f.slice(0,n.current):f})},[]),c=F.useCallback(()=>r([]),[]);return F.useEffect(()=>{const u=N=>{if(o.current&&N.teamId&&N.teamId!==o.current)return;const j=N.name||N.sessionName||"Agent",b=N.agentStatus||N.workingStatus||"unknown",x=b==="error"?"error":"agent_status";a({id:$E(),type:x,source:j,title:`${j} is now ${b}`,detail:N.role?`Role: ${N.role}`:void 0,timestamp:new Date().toISOString(),agentStatus:N.agentStatus})},d=N=>{const j=N.agentStatus||N.status||(N.running?"active":"inactive");a({id:$E(),type:"system",source:"Orchestrator",title:`Orchestrator is now ${j}`,timestamp:new Date().toISOString(),agentStatus:j})},f=N=>j=>{const b=N.replace("queue:","").replace(/_/g," ");a({id:$E(),type:N.includes("failed")?"error":"message",source:j.sessionName||"Queue",title:`Message ${b}`,detail:j.snippet?j.snippet.slice(0,120):void 0,timestamp:new Date().toISOString()})},m=N=>{if(N.members)for(const j of N.members)j.agentStatus&&a({id:$E(),type:"task_update",source:j.name||j.sessionName||"Agent",title:j.currentTask?`Working on: ${j.currentTask}`:`Status: ${j.agentStatus}`,timestamp:new Date().toISOString(),agentStatus:j.agentStatus})};tr.on("team_member_status_changed",u),tr.on("orchestrator_status_changed",d),tr.on("team_activity_updated",m);const v=["queue:message_enqueued","queue:message_processing","queue:message_completed","queue:message_failed"].map(N=>{const j=f(N);return tr.on(N,j),{name:N,handler:j}});return()=>{tr.off("team_member_status_changed",u),tr.off("orchestrator_status_changed",d),tr.off("team_activity_updated",m);for(const{name:N,handler:j}of v)tr.off(N,j)}},[a]),{events:t,clearEvents:c}}const gJ={agent_status:"bg-emerald-400",task_update:"bg-blue-400",message:"bg-violet-400",system:"bg-amber-400",error:"bg-red-400"},bJ={agent_status:"Agent",task_update:"Task",message:"Message",system:"System",error:"Error"};function vJ(s){try{return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}const wJ=({event:s})=>{const e=s.agentStatus==="active"||s.agentStatus==="busy",t=gJ[s.type]||"bg-gray-400";return i.jsxDEV("div",{className:"feed-entry flex items-start gap-3 px-4 py-2.5 border-b border-[var(--color-border)] hover:bg-[var(--color-bg-hover)] transition-colors","data-testid":"feed-entry",children:[i.jsxDEV("span",{className:`mt-1.5 h-2 w-2 shrink-0 rounded-full ${t} ${e?"feed-pulse":""}`},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:65,columnNumber:4},globalThis),i.jsxDEV("div",{className:"min-w-0 flex-1",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("span",{className:"text-xs font-medium text-[var(--color-text-secondary)] uppercase tracking-wide",children:bJ[s.type]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:72,columnNumber:6},globalThis),i.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:vJ(s.timestamp)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:75,columnNumber:6},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:71,columnNumber:5},globalThis),i.jsxDEV("p",{className:"text-sm text-[var(--color-text-primary)] truncate",children:s.title},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:79,columnNumber:5},globalThis),s.detail&&i.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] truncate mt-0.5",children:s.detail},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:83,columnNumber:6},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:70,columnNumber:4},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:60,columnNumber:3},globalThis)},xJ=()=>i.jsxDEV("div",{className:"flex flex-col items-center justify-center py-12 text-[var(--color-text-muted)]",children:[i.jsxDEV("svg",{className:"h-10 w-10 mb-3 opacity-40",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M13 10V3L4 14h7v7l9-11h-7z"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:103,columnNumber:4},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:97,columnNumber:3},globalThis),i.jsxDEV("p",{className:"text-sm",children:"Waiting for live events…"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:110,columnNumber:3},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:96,columnNumber:2},globalThis),NJ=({maxEvents:s=50,className:e=""})=>{const{events:t,clearEvents:r}=yJ(s),n=F.useRef(null);return F.useEffect(()=>{n.current&&(n.current.scrollTop=0)},[t.length]),i.jsxDEV("div",{className:`flex flex-col rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] overflow-hidden ${e}`,"data-testid":"execution-feed",children:[i.jsxDEV("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--color-border)]",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("span",{className:"h-2 w-2 rounded-full bg-emerald-400 feed-pulse"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:147,columnNumber:6},globalThis),i.jsxDEV("h3",{className:"text-sm font-semibold text-[var(--color-text-primary)]",children:"Execution Feed"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:148,columnNumber:6},globalThis),t.length>0&&i.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:["(",t.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:152,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:146,columnNumber:5},globalThis),t.length>0&&i.jsxDEV("button",{onClick:r,className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] transition-colors","data-testid":"feed-clear",children:"Clear"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:158,columnNumber:6},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:145,columnNumber:4},globalThis),i.jsxDEV("div",{ref:n,className:"feed-scroll flex-1 overflow-y-auto",children:t.length===0?i.jsxDEV(xJ,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:174,columnNumber:6},globalThis):t.map(o=>i.jsxDEV(wJ,{event:o},o.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:177,columnNumber:7},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:169,columnNumber:4},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/ExecutionFeed/ExecutionFeed.tsx",lineNumber:140,columnNumber:3},globalThis)},DJ=()=>{const{id:s}=GB(),e=gh(),{openTerminalWithSession:t}=ej(),[r,n]=F.useState(null),[o,a]=F.useState(!0),[c,u]=F.useState(!1),[d,f]=F.useState(!1),[m,g]=F.useState(!1),[v,N]=F.useState(!1),[j,b]=F.useState(null),[x,D]=F.useState(!1),[T,E]=F.useState(!1),[k,U]=F.useState(null),[V,M]=F.useState(null),[R,P]=F.useState([]),{showSuccess:B,showError:O,showWarning:H,AlertComponent:J}=Zp(),{showConfirm:ie,ConfirmComponent:te}=YT(),se=F.useCallback(re=>{re.teamId===s&&n(Ae=>Ae&&{...Ae,members:Ae.members.map(He=>He.id===re.memberId||He.sessionName===re.sessionName?{...He,agentStatus:re.agentStatus}:He)})},[s]),Z=F.useCallback(re=>{(s==="orchestrator"||(r==null?void 0:r.name)==="Orchestrator Team")&&u(re.agentStatus==="active")},[s,r==null?void 0:r.name]);F.useEffect(()=>{s&&(X(),(s==="orchestrator"||(r==null?void 0:r.name)==="Orchestrator Team")&&z())},[s,r==null?void 0:r.name]),F.useEffect(()=>(tr.on("team_member_status_changed",se),tr.on("orchestrator_status_changed",Z),()=>{tr.off("team_member_status_changed",se),tr.off("orchestrator_status_changed",Z)}),[se,Z]),F.useEffect(()=>{var re;((re=r==null?void 0:r.projectIds)==null?void 0:re.length)>0?oe(r.projectIds[0]):(U(null),M(null))},[r==null?void 0:r.projectIds]),F.useEffect(()=>{s&&Y()},[s]);const Y=async()=>{try{const Ae=(await es.getTeams()).filter(He=>He.parentTeamId===s);P(Ae)}catch(re){console.error("Error fetching sub-teams:",re),P([])}},X=async()=>{try{const re=await fetch(`/api/teams/${s}`);if(re.ok){const Ae=await re.json();if(Ae.success&&Ae.data){const He={...Ae.data,members:V9(Ae.data.members)};n(He)}}}catch(re){console.error("Error fetching team data:",re)}finally{a(!1)}},z=async()=>{try{const re=await fetch("/api/terminal/sessions");if(re.ok){const Ae=await re.json();if(Ae.success&&Ae.data){const He=Ae.data.some(Ge=>Ge.sessionName==="crewly-orc");u(He)}}}catch(re){console.error("Error checking orchestrator session:",re),u(!1)}},oe=async re=>{try{const Ae=await fetch("/api/projects");if(Ae.ok){const He=await Ae.json(),Ye=(He.success?He.data||[]:He||[]).find(ne=>ne.id===re);U(Ye?Ye.name:re),M(Ye?Ye.path:null)}else U(re),M(null)}catch(Ae){console.error("Error fetching project data:",Ae),U(re),M(null)}},le=async()=>{if((r==null?void 0:r.id)==="orchestrator"||(r==null?void 0:r.name)==="Orchestrator Team"){D(!0);try{const Ae=await es.setupOrchestrator();Ae.success?(X(),B(Ae.message||"Orchestrator started successfully!")):O(Ae.error||"Failed to start orchestrator")}catch(Ae){console.error("Error starting orchestrator:",Ae),O("Error starting orchestrator. Please try again.")}finally{D(!1)}return}f(!0)},fe=async re=>{D(!0);try{const Ae=await fetch(`/api/teams/${s}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:re})}),He=await Ae.json();Ae.ok?(f(!1),X(),B(He.message||"Team started successfully!")):O(He.error||"Failed to start team")}catch(Ae){console.error("Error starting team:",Ae),O("Error starting team. Please try again.")}finally{D(!1)}},ee=()=>{g(!0)},ue=async re=>{if(r)try{const Ae=await fetch(`/api/teams/${r.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(re)});if(Ae.ok)X(),g(!1);else{const He=await Ae.json();O(He.error||"Failed to update team")}}catch(Ae){console.error("Error updating team:",Ae),O("Failed to update team")}},G=async()=>{E(!0);try{if((r==null?void 0:r.id)==="orchestrator"||(r==null?void 0:r.name)==="Orchestrator Team"){const re=await fetch("/api/orchestrator/stop",{method:"POST",headers:{"Content-Type":"application/json"}});if(re.ok)X(),z();else{const Ae=await re.json();O(Ae.error||"Failed to stop orchestrator")}}else(await fetch(`/api/teams/${s}/stop`,{method:"POST"})).ok&&X()}catch(re){console.error("Error stopping team:",re)}finally{E(!1)}},ae=async()=>{if(!r)return;if(r.id==="orchestrator"||r.name==="Orchestrator Team"){H("The Orchestrator Team cannot be deleted as it is required for system operations.");return}const re=async()=>{try{await fetch(`/api/teams/${s}/stop`,{method:"POST"});const Ae=await fetch(`/api/teams/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(Ae.ok)e("/teams");else{const He=await Ae.text();O("Failed to delete team: "+He)}}catch(Ae){console.error("Error deleting team:",Ae),O("Failed to delete team: "+(Ae instanceof Error?Ae.message:"Unknown error"))}};ie(`Are you sure you want to delete team "${r.name}"?
382
382
 
383
383
  This will:
384
384
  • Delete the team and all its members
@@ -5210,4 +5210,4 @@ You are a...`,className:"font-mono text-sm"},void 0,!1,{fileName:"/Users/yellows
5210
5210
 
5211
5211
  Provide detailed instructions for this skill...`,rows:8,className:"font-mono text-sm"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:797,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:795,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:739,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-dark bg-background-dark",children:[i.jsxDEV(pr,{variant:"secondary",onClick:t,type:"button",children:"Cancel"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:810,columnNumber:11},globalThis),i.jsxDEV(pr,{type:"submit",onClick:f,disabled:a,loading:a,children:a?"Saving...":"Save Skill"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:813,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:809,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:702,columnNumber:7},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:698,columnNumber:5},globalThis)},Rhe=({skillName:s,onConfirm:e,onCancel:t})=>{const r=n=>{n.target===n.currentTarget&&t()};return i.jsxDEV("div",{className:"fixed inset-0 bg-background-dark/80 backdrop-blur-sm flex items-center justify-center z-50",onClick:r,children:i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-xl shadow-lg w-full max-w-md m-4",onClick:n=>n.stopPropagation(),children:[i.jsxDEV("div",{className:"p-6 border-b border-border-dark",children:i.jsxDEV("h2",{className:"text-xl font-semibold text-text-primary-dark",children:"Delete Skill"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:873,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:872,columnNumber:9},globalThis),i.jsxDEV("div",{className:"p-6",children:i.jsxDEV("p",{className:"text-text-secondary-dark",children:["Are you sure you want to delete ",i.jsxDEV("strong",{className:"text-text-primary-dark",children:s},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:879,columnNumber:45},globalThis),"? This action cannot be undone."]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:878,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:877,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-dark bg-background-dark rounded-b-xl",children:[i.jsxDEV(pr,{variant:"secondary",onClick:t,children:"Cancel"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:886,columnNumber:11},globalThis),i.jsxDEV(pr,{variant:"danger",onClick:e,children:"Delete"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:889,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:885,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:867,columnNumber:7},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SkillsTab.tsx",lineNumber:863,columnNumber:5},globalThis)},Vhe=()=>{const[s,e]=F.useState({connected:!1}),[t,r]=F.useState(!0),[n,o]=F.useState(!1),[a,c]=F.useState(null),[u,d]=F.useState({botToken:"",appToken:"",signingSecret:"",defaultChannel:""}),f=F.useCallback(async()=>{var N,j,b,x,D,T,E;try{c(null);const U=await(await fetch("/api/slack/status")).json();U.success?e({connected:((N=U.data)==null?void 0:N.isConfigured)||!1,workspaceName:(j=U.data)==null?void 0:j.workspaceName,botName:(b=U.data)==null?void 0:b.botName,channels:(x=U.data)==null?void 0:x.channels,lastMessageAt:(D=U.data)==null?void 0:D.lastMessageAt,messagesSent:(T=U.data)==null?void 0:T.messagesSent,messagesReceived:(E=U.data)==null?void 0:E.messagesReceived}):e({connected:!1,error:U.error})}catch{e({connected:!1,error:"Failed to fetch status"})}finally{r(!1)}},[]);F.useEffect(()=>{f()},[f]);const m=N=>{const{name:j,value:b}=N.target;d(x=>({...x,[j]:b}))},g=async N=>{N.preventDefault(),o(!0),c(null);try{const j=await fetch("/api/slack/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botToken:u.botToken,appToken:u.appToken,signingSecret:u.signingSecret,defaultChannelId:u.defaultChannel||void 0})}),b=await j.json();if(!j.ok||!b.success)throw new Error(b.error||"Connection failed");d({botToken:"",appToken:"",signingSecret:"",defaultChannel:""}),await f()}catch(j){c(j instanceof Error?j.message:"Failed to connect to Slack")}finally{o(!1)}},v=async()=>{if(window.confirm("Are you sure you want to disconnect from Slack?"))try{c(null);const N=await fetch("/api/slack/disconnect",{method:"POST"}),j=await N.json();if(!N.ok||!j.success)throw new Error(j.error||"Disconnect failed");await f()}catch(N){c(N instanceof Error?N.message:"Failed to disconnect")}};return t?i.jsxDEV("div",{className:"flex flex-col items-center justify-center py-16",children:[i.jsxDEV("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:168,columnNumber:9},globalThis),i.jsxDEV("p",{className:"text-text-secondary-dark",children:"Loading Slack status..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:169,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:167,columnNumber:7},globalThis):i.jsxDEV("div",{className:"space-y-6 max-w-3xl",children:[i.jsxDEV("div",{children:[i.jsxDEV("h2",{className:"text-xl font-semibold",children:"Slack Integration"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:178,columnNumber:9},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Connect Slack to communicate with the orchestrator from your phone or desktop Slack app."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:179,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:177,columnNumber:7},globalThis),a&&i.jsxDEV("div",{className:"bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg flex items-center justify-between",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV(Yf,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:188,columnNumber:13},globalThis),i.jsxDEV("span",{children:a},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:189,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:187,columnNumber:11},globalThis),i.jsxDEV("button",{onClick:()=>c(null),className:"text-rose-400 hover:text-rose-300 p-1",children:i.jsxDEV(ho,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:195,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:191,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:186,columnNumber:9},globalThis),s.connected?i.jsxDEV("div",{className:"space-y-6",children:[i.jsxDEV("div",{className:"bg-emerald-500/10 border border-emerald-500/30 rounded-lg p-4 flex items-center gap-3",children:[i.jsxDEV(Zc,{className:"w-5 h-5 text-emerald-400"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:205,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-emerald-400 font-medium",children:"Connected to Slack"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:206,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:204,columnNumber:11},globalThis),i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-6",children:[i.jsxDEV("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide mb-4",children:"Connection Details"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:211,columnNumber:13},globalThis),i.jsxDEV("div",{className:"space-y-3",children:[s.workspaceName&&i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Workspace"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:217,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:s.workspaceName},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:218,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:216,columnNumber:17},globalThis),s.botName&&i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Bot Name"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:223,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:s.botName},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:224,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:222,columnNumber:17},globalThis),s.channels&&s.channels.length>0&&i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Channels"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:229,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:s.channels.join(", ")},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:230,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:228,columnNumber:17},globalThis),s.messagesSent!==void 0&&i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Messages Sent"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:235,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:s.messagesSent},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:236,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:234,columnNumber:17},globalThis),s.messagesReceived!==void 0&&i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Messages Received"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:241,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:s.messagesReceived},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:242,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:240,columnNumber:17},globalThis),s.lastMessageAt&&i.jsxDEV("div",{className:"flex items-center justify-between py-2",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Last Activity"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:247,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:new Date(s.lastMessageAt).toLocaleString()},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:248,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:246,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:214,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:210,columnNumber:11},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV(pr,{variant:"secondary",onClick:f,icon:dc,children:"Refresh Status"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:258,columnNumber:13},globalThis),i.jsxDEV(pr,{variant:"danger",onClick:v,icon:mV,children:"Disconnect"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:261,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:257,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:202,columnNumber:9},globalThis):i.jsxDEV("div",{className:"space-y-6",children:[i.jsxDEV("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4 flex items-center gap-3",children:[i.jsxDEV(Yf,{className:"w-5 h-5 text-amber-400"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:271,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-amber-400 font-medium",children:"Not connected to Slack"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:272,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:270,columnNumber:11},globalThis),i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-6",children:[i.jsxDEV("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide mb-4",children:"Setup Instructions"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:277,columnNumber:13},globalThis),i.jsxDEV("ol",{className:"list-decimal list-inside space-y-3 text-sm text-text-secondary-dark",children:[i.jsxDEV("li",{children:["Create a Slack App at"," ",i.jsxDEV("a",{href:"https://api.slack.com/apps",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:["api.slack.com/apps",i.jsxDEV(IC,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:290,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:283,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:281,columnNumber:15},globalThis),i.jsxDEV("li",{children:"Enable Socket Mode in your app settings and create an App Token (starts with xapp-)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:293,columnNumber:15},globalThis),i.jsxDEV("li",{children:["Add Bot Token Scopes under OAuth & Permissions:",i.jsxDEV("ul",{className:"list-disc list-inside ml-4 mt-1.5 space-y-1",children:[i.jsxDEV("li",{children:[i.jsxDEV("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"chat:write"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:297,columnNumber:23},globalThis)," - Send messages"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:297,columnNumber:19},globalThis),i.jsxDEV("li",{children:[i.jsxDEV("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"channels:read"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:298,columnNumber:23},globalThis)," - View channels"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:298,columnNumber:19},globalThis),i.jsxDEV("li",{children:[i.jsxDEV("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"app_mentions:read"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:299,columnNumber:23},globalThis)," - Respond to mentions"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:299,columnNumber:19},globalThis),i.jsxDEV("li",{children:[i.jsxDEV("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"im:read"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:300,columnNumber:23},globalThis),", ",i.jsxDEV("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"im:write"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:300,columnNumber:106},globalThis)," - Direct messages"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:300,columnNumber:19},globalThis),i.jsxDEV("li",{children:[i.jsxDEV("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"files:read"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:301,columnNumber:23},globalThis)," - Receive images from Slack"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:301,columnNumber:19},globalThis),i.jsxDEV("li",{children:[i.jsxDEV("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"files:write"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:302,columnNumber:23},globalThis)," - Upload images to Slack"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:302,columnNumber:19},globalThis),i.jsxDEV("li",{children:[i.jsxDEV("code",{className:"text-xs bg-background-dark px-1.5 py-0.5 rounded",children:"reactions:write"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:303,columnNumber:23},globalThis)," - Typing/completion indicators (optional)"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:303,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:296,columnNumber:17},globalThis),i.jsxDEV("p",{className:"text-xs text-amber-400/80 mt-1.5 ml-4",children:["Note: Adding ",i.jsxDEV("code",{className:"text-xs bg-background-dark px-1 py-0.5 rounded",children:"files:read"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:306,columnNumber:32},globalThis)," and ",i.jsxDEV("code",{className:"text-xs bg-background-dark px-1 py-0.5 rounded",children:"files:write"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:306,columnNumber:119},globalThis)," scopes requires reinstalling the app to your workspace."]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:305,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:294,columnNumber:15},globalThis),i.jsxDEV("li",{children:"Install the app to your workspace"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:309,columnNumber:15},globalThis),i.jsxDEV("li",{children:"Copy the Bot Token (xoxb-...), App Token (xapp-...), and Signing Secret"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:310,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:280,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:276,columnNumber:11},globalThis),i.jsxDEV("form",{onSubmit:g,className:"bg-surface-dark border border-border-dark rounded-lg p-6 space-y-4",children:[i.jsxDEV("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide mb-4",children:"Connect to Slack"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:316,columnNumber:13},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"botToken",required:!0,children:"Bot Token (xoxb-...)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:321,columnNumber:15},globalThis),i.jsxDEV(mn,{id:"botToken",name:"botToken",type:"password",value:u.botToken,onChange:m,placeholder:"xoxb-your-bot-token",required:!0,autoComplete:"off"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:322,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:320,columnNumber:13},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"appToken",required:!0,children:"App Token (xapp-...)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:335,columnNumber:15},globalThis),i.jsxDEV(mn,{id:"appToken",name:"appToken",type:"password",value:u.appToken,onChange:m,placeholder:"xapp-your-app-token",required:!0,autoComplete:"off"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:336,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:334,columnNumber:13},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"signingSecret",required:!0,children:"Signing Secret"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:349,columnNumber:15},globalThis),i.jsxDEV(mn,{id:"signingSecret",name:"signingSecret",type:"password",value:u.signingSecret,onChange:m,placeholder:"Your signing secret",required:!0,autoComplete:"off"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:350,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:348,columnNumber:13},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"defaultChannel",children:"Default Channel (optional)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:363,columnNumber:15},globalThis),i.jsxDEV(mn,{id:"defaultChannel",name:"defaultChannel",type:"text",value:u.defaultChannel,onChange:m,placeholder:"C1234567890 or #crewly"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:364,columnNumber:15},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mt-1",children:"Channel ID or name where notifications will be sent by default"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:372,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:362,columnNumber:13},globalThis),i.jsxDEV("div",{className:"pt-2",children:i.jsxDEV(pr,{type:"submit",disabled:n||!u.botToken||!u.appToken||!u.signingSecret,loading:n,fullWidth:!0,children:n?"Connecting...":"Connect to Slack"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:378,columnNumber:15},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:377,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:315,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:268,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/SlackTab.tsx",lineNumber:175,columnNumber:5},globalThis)},Fhe=()=>{const[s,e]=F.useState({connected:!1}),[t,r]=F.useState(!0),[n,o]=F.useState(!1),[a,c]=F.useState(null),u=F.useCallback(async()=>{var m,g,v,N,j,b;try{c(null);const D=await(await fetch("/api/whatsapp/status")).json();D.success?e({connected:((m=D.data)==null?void 0:m.isConfigured)||((g=D.data)==null?void 0:g.connected)||!1,phoneNumber:(v=D.data)==null?void 0:v.phoneNumber,qrCode:(N=D.data)==null?void 0:N.qrCode,messagesSent:(j=D.data)==null?void 0:j.messagesSent,messagesReceived:(b=D.data)==null?void 0:b.messagesReceived}):e({connected:!1,error:D.error})}catch{e({connected:!1,error:"Failed to fetch WhatsApp status"})}finally{r(!1)}},[]);F.useEffect(()=>{u()},[u]);const d=async()=>{var m;o(!0),c(null);try{const g=await fetch("/api/whatsapp/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),v=await g.json();if(!g.ok||!v.success)throw new Error(v.error||"Connection failed");(m=v.data)!=null&&m.qrCode&&e(N=>({...N,qrCode:v.data.qrCode})),await u()}catch(g){c(g instanceof Error?g.message:"Failed to connect WhatsApp")}finally{o(!1)}},f=async()=>{if(window.confirm("Are you sure you want to disconnect from WhatsApp?"))try{c(null);const m=await fetch("/api/whatsapp/disconnect",{method:"POST"}),g=await m.json();if(!m.ok||!g.success)throw new Error(g.error||"Disconnect failed");await u()}catch(m){c(m instanceof Error?m.message:"Failed to disconnect")}};return t?i.jsxDEV("div",{className:"flex flex-col items-center justify-center py-8",children:[i.jsxDEV("div",{className:"w-8 h-8 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:142,columnNumber:9},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:"Loading WhatsApp status..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:143,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:141,columnNumber:7},globalThis):i.jsxDEV("div",{className:"space-y-5",children:[a&&i.jsxDEV("div",{className:"bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg flex items-center justify-between",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV(Yf,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:154,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-sm",children:a},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:155,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:153,columnNumber:11},globalThis),i.jsxDEV("button",{onClick:()=>c(null),className:"text-rose-400 hover:text-rose-300 p-1",children:i.jsxDEV(ho,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:161,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:157,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:152,columnNumber:9},globalThis),s.connected?i.jsxDEV("div",{className:"space-y-5",children:[i.jsxDEV("div",{className:"bg-emerald-500/10 border border-emerald-500/30 rounded-lg p-4 flex items-center gap-3",children:[i.jsxDEV(Zc,{className:"w-5 h-5 text-emerald-400"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:171,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-emerald-400 font-medium text-sm",children:"Connected to WhatsApp"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:172,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:170,columnNumber:11},globalThis),i.jsxDEV("div",{className:"bg-background-dark border border-border-dark rounded-lg p-5",children:[i.jsxDEV("h3",{className:"text-xs font-semibold text-text-secondary-dark uppercase tracking-wide mb-3",children:"Connection Details"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:177,columnNumber:13},globalThis),i.jsxDEV("div",{className:"space-y-2",children:[s.phoneNumber&&i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Phone Number"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:183,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:s.phoneNumber},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:184,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:182,columnNumber:17},globalThis),s.messagesSent!==void 0&&i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-b border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Messages Sent"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:189,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:s.messagesSent},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:190,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:188,columnNumber:17},globalThis),s.messagesReceived!==void 0&&i.jsxDEV("div",{className:"flex items-center justify-between py-2",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Messages Received"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:195,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:s.messagesReceived},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:196,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:194,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:180,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:176,columnNumber:11},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV(pr,{variant:"secondary",onClick:u,icon:dc,children:"Refresh Status"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:204,columnNumber:13},globalThis),i.jsxDEV(pr,{variant:"danger",onClick:f,icon:mV,children:"Disconnect"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:207,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:203,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:168,columnNumber:9},globalThis):i.jsxDEV("div",{className:"space-y-5",children:s.qrCode?i.jsxDEV("div",{className:"bg-background-dark border border-border-dark rounded-lg p-6 flex flex-col items-center gap-4",children:[i.jsxDEV("h3",{className:"text-sm font-semibold text-text-secondary-dark uppercase tracking-wide",children:"Scan QR Code"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:218,columnNumber:15},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark text-center max-w-sm",children:"Open WhatsApp on your phone, go to Settings > Linked Devices > Link a Device, then scan this QR code."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:221,columnNumber:15},globalThis),i.jsxDEV("div",{className:"bg-white p-4 rounded-lg",children:i.jsxDEV("img",{src:`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(s.qrCode)}`,alt:"WhatsApp QR Code",className:"w-48 h-48","data-testid":"whatsapp-qr-code"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:225,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:224,columnNumber:15},globalThis),i.jsxDEV(pr,{variant:"secondary",onClick:u,icon:dc,children:"Refresh QR Code"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:232,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:217,columnNumber:13},globalThis):i.jsxDEV("div",{className:"space-y-4",children:[i.jsxDEV("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4 flex items-center gap-3",children:[i.jsxDEV(Yf,{className:"w-5 h-5 text-amber-400"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:240,columnNumber:17},globalThis),i.jsxDEV("span",{className:"text-amber-400 font-medium text-sm",children:"Not connected to WhatsApp"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:241,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:239,columnNumber:15},globalThis),i.jsxDEV("div",{className:"bg-background-dark border border-border-dark rounded-lg p-5",children:[i.jsxDEV("h3",{className:"text-xs font-semibold text-text-secondary-dark uppercase tracking-wide mb-3",children:"How to Connect"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:246,columnNumber:17},globalThis),i.jsxDEV("ol",{className:"list-decimal list-inside space-y-2 text-sm text-text-secondary-dark",children:[i.jsxDEV("li",{children:'Click "Connect WhatsApp" below to generate a QR code'},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:250,columnNumber:19},globalThis),i.jsxDEV("li",{children:"Open WhatsApp on your phone"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:251,columnNumber:19},globalThis),i.jsxDEV("li",{children:["Go to ",i.jsxDEV("strong",{children:"Settings"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:252,columnNumber:29},globalThis)," > ",i.jsxDEV("strong",{children:"Linked Devices"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:252,columnNumber:60},globalThis)," > ",i.jsxDEV("strong",{children:"Link a Device"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:252,columnNumber:97},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:252,columnNumber:19},globalThis),i.jsxDEV("li",{children:"Scan the QR code displayed here"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:253,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:249,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:245,columnNumber:15},globalThis),i.jsxDEV(pr,{onClick:d,disabled:n,loading:n,icon:o4,fullWidth:!0,children:n?"Initializing...":"Connect WhatsApp"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:257,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:238,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:214,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/WhatsAppTab.tsx",lineNumber:149,columnNumber:5},globalThis)},Ihe=()=>{const[s,e]=F.useState({connected:!1}),[t,r]=F.useState(!0),[n,o]=F.useState(!1),[a,c]=F.useState(null),[u,d]=F.useState("pubsub"),[f,m]=F.useState("service_account"),[g,v]=F.useState(""),[N,j]=F.useState(""),[b,x]=F.useState(""),[D,T]=F.useState(""),[E,k]=F.useState(!1),[U,V]=F.useState(null),[M,R]=F.useState(!1),[P,B]=F.useState(null),[O,H]=F.useState(""),[J,ie]=F.useState(""),te=F.useRef(null),se=F.useCallback(async()=>{var ee;try{c(null);const G=await(await fetch("/api/messengers/status")).json();if(G.success&&Array.isArray(G.data)){const ae=G.data.find(De=>De.platform==="google-chat");if(ae){let De=ae.details||{};if(ae.connected&&((ee=ae.details)==null?void 0:ee.mode)==="pubsub")try{const Ve=await(await fetch("/api/messengers/google-chat/status")).json();Ve.success&&(De={...De,...Ve.data})}catch{}e({connected:ae.connected,mode:De.mode,authMode:De.authMode,serviceAccountEmail:De.serviceAccountEmail,pullActive:De.pullActive,pullPaused:De.pullPaused,subscriptionName:De.subscriptionName,projectId:De.projectId,consecutiveFailures:De.consecutiveFailures,lastPullAt:De.lastPullAt})}}}catch{e({connected:!1,error:"Failed to fetch status"})}finally{r(!1)}},[]);F.useEffect(()=>{se()},[se]),F.useEffect(()=>(s.connected&&s.mode==="pubsub"&&(te.current=setInterval(()=>{se()},1e4)),()=>{te.current&&(clearInterval(te.current),te.current=null)}),[s.connected,s.mode,se]);const Z=async ee=>{ee.preventDefault(),o(!0),c(null);try{let ue;u==="webhook"?ue={webhookUrl:g}:f==="adc"?(ue={authMode:"adc"},u==="pubsub"&&(ue.projectId=b,ue.subscriptionName=D),J.trim()&&(ue.serviceAccountEmail=J.trim())):u==="service-account"?ue={serviceAccountKey:N}:ue={serviceAccountKey:N,projectId:b,subscriptionName:D};const G=await fetch("/api/messengers/google-chat/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ue)}),ae=await G.json();if(!G.ok||!ae.success)throw new Error(ae.error||"Connection failed");v(""),j(""),x(""),T(""),ie(""),await se()}catch(ue){c(ue instanceof Error?ue.message:"Failed to connect")}finally{o(!1)}},Y=async()=>{if(window.confirm("Are you sure you want to disconnect from Google Chat?"))try{c(null);const ee=await fetch("/api/messengers/google-chat/disconnect",{method:"POST"}),ue=await ee.json();if(!ee.ok||!ue.success)throw new Error(ue.error||"Disconnect failed");await se()}catch(ee){c(ee instanceof Error?ee.message:"Failed to disconnect")}},X=async()=>{k(!0),V(null);try{const ee=await fetch("/api/messengers/google-chat/pull",{method:"POST"}),ue=await ee.json();if(!ee.ok||!ue.success)throw new Error(ue.error||"Pull failed");const G=ue.messagesReceived||0;V(G>0?`Pulled ${G} message${G!==1?"s":""}`:"No new messages"),await se()}catch(ee){V(ee instanceof Error?ee.message:"Pull failed")}finally{k(!1)}},z=async()=>{if(O.trim()){R(!0),B(null);try{const ee=await fetch("/api/messengers/google-chat/test-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({space:O.trim(),text:"Test message from Crewly"})}),ue=await ee.json();if(!ee.ok||!ue.success)throw new Error(ue.error||"Test send failed");B("Message sent successfully")}catch(ee){B(ee instanceof Error?ee.message:"Test send failed")}finally{R(!1)}}},oe=ee=>{switch(ee){case"webhook":return"Webhook";case"service-account":return"Service Account";case"pubsub":return"Pub/Sub (Bidirectional)";default:return"Unknown"}},le=ee=>ee==="adc"?"Application Default Credentials":"Service Account Key",fe=()=>u==="webhook"?!!g:f==="adc"?u==="pubsub"?!!(b&&D):!0:u==="service-account"?!!N:!!(N&&b&&D);return t?i.jsxDEV("div",{className:"flex flex-col items-center justify-center py-8",children:[i.jsxDEV("div",{className:"w-8 h-8 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:305,columnNumber:9},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark",children:"Loading Google Chat status..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:306,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:304,columnNumber:7},globalThis):i.jsxDEV("div",{className:"space-y-5",children:[a&&i.jsxDEV("div",{className:"bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg flex items-center justify-between",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV(Yf,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:317,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-sm",children:a},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:318,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:316,columnNumber:11},globalThis),i.jsxDEV("button",{onClick:()=>c(null),className:"text-rose-400 hover:text-rose-300 p-1",children:i.jsxDEV(ho,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:321,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:320,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:315,columnNumber:9},globalThis),s.connected?i.jsxDEV("div",{className:"space-y-5",children:[i.jsxDEV("div",{className:"bg-emerald-500/10 border border-emerald-500/30 rounded-lg p-4 flex items-center gap-3",children:[i.jsxDEV(Zc,{className:"w-5 h-5 text-emerald-400"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:330,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-emerald-400 font-medium text-sm",children:"Connected to Google Chat"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:331,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:329,columnNumber:11},globalThis),i.jsxDEV("div",{className:"bg-background-dark border border-border-dark rounded-lg p-5",children:[i.jsxDEV("h3",{className:"text-xs font-semibold text-text-secondary-dark uppercase tracking-wide mb-3",children:"Connection Details"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:335,columnNumber:13},globalThis),i.jsxDEV("div",{className:"space-y-2",children:[i.jsxDEV("div",{className:"flex items-center justify-between py-2",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Mode"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:340,columnNumber:17},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:oe(s.mode)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:341,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:339,columnNumber:15},globalThis),(s.mode==="pubsub"||s.mode==="service-account")&&i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-t border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Auth"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:345,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-medium",children:le(s.authMode)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:346,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:344,columnNumber:17},globalThis),s.serviceAccountEmail&&i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-t border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Impersonating"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:351,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-sm font-mono truncate max-w-[280px]","data-testid":"sa-email-display",children:s.serviceAccountEmail},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:352,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:350,columnNumber:17},globalThis),s.mode==="pubsub"&&i.jsxDEV(i.Fragment,{children:[i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-t border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Project ID"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:358,columnNumber:21},globalThis),i.jsxDEV("span",{className:"text-sm font-mono",children:s.projectId},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:359,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:357,columnNumber:19},globalThis),i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-t border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Subscription"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:362,columnNumber:21},globalThis),i.jsxDEV("span",{className:"text-sm font-mono text-text-secondary-dark/80 truncate max-w-[240px]",children:s.subscriptionName},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:363,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:361,columnNumber:19},globalThis),i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-t border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Pull Loop"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:366,columnNumber:21},globalThis),i.jsxDEV("span",{className:"flex items-center gap-2",children:[i.jsxDEV("span",{className:`w-2 h-2 rounded-full ${s.pullPaused?"bg-amber-400":s.pullActive?"bg-emerald-400 animate-pulse":"bg-gray-500"}`},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:368,columnNumber:23},globalThis),i.jsxDEV("span",{className:`text-sm font-medium ${s.pullPaused?"text-amber-400":s.pullActive?"text-emerald-400":"text-text-secondary-dark"}`,children:s.pullPaused?"Paused (errors)":s.pullActive?"Running":"Stopped"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:369,columnNumber:23},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:367,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:365,columnNumber:19},globalThis),i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-t border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Last Pull"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:375,columnNumber:21},globalThis),i.jsxDEV("span",{className:"text-sm font-mono","data-testid":"last-pull-at",children:s.lastPullAt?new Date(s.lastPullAt).toLocaleTimeString():"Never"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:376,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:374,columnNumber:19},globalThis),(s.consecutiveFailures??0)>0&&i.jsxDEV("div",{className:"flex items-center justify-between py-2 border-t border-border-dark",children:[i.jsxDEV("span",{className:"text-sm text-text-secondary-dark",children:"Consecutive Failures"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:382,columnNumber:23},globalThis),i.jsxDEV("span",{className:"text-sm font-medium text-amber-400","data-testid":"consecutive-failures",children:s.consecutiveFailures},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:383,columnNumber:23},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:381,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:356,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:338,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:334,columnNumber:11},globalThis),i.jsxDEV("div",{className:"flex items-center gap-3 flex-wrap",children:[s.mode==="pubsub"&&i.jsxDEV(pr,{variant:"primary",onClick:X,disabled:E,loading:E,icon:YB,"data-testid":"pull-now-btn",children:E?"Pulling...":"Pull Now"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:393,columnNumber:15},globalThis),i.jsxDEV(pr,{variant:"secondary",onClick:se,icon:dc,children:"Refresh Status"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:404,columnNumber:13},globalThis),i.jsxDEV(pr,{variant:"danger",onClick:Y,icon:mV,children:"Disconnect"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:407,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:391,columnNumber:11},globalThis),U&&i.jsxDEV("div",{className:`text-sm px-3 py-2 rounded-lg ${U.startsWith("Pulled")?"bg-emerald-500/10 text-emerald-400":U==="No new messages"?"bg-blue-500/10 text-blue-400":"bg-rose-500/10 text-rose-400"}`,"data-testid":"pull-result",children:U},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:414,columnNumber:13},globalThis),(s.mode==="pubsub"||s.mode==="service-account")&&i.jsxDEV("div",{className:"bg-background-dark border border-border-dark rounded-lg p-4 space-y-3",children:[i.jsxDEV("h3",{className:"text-xs font-semibold text-text-secondary-dark uppercase tracking-wide",children:"Test Send"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:426,columnNumber:15},globalThis),i.jsxDEV("div",{className:"flex items-end gap-2",children:[i.jsxDEV("div",{className:"flex-1",children:[i.jsxDEV(Fr,{htmlFor:"test-send-space",children:"Space Name"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:429,columnNumber:19},globalThis),i.jsxDEV(mn,{id:"test-send-space",name:"testSendSpace",type:"text",value:O,onChange:ee=>H(ee.target.value),placeholder:"spaces/AAAA...",autoComplete:"off","data-testid":"test-send-space"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:430,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:428,columnNumber:17},globalThis),i.jsxDEV(pr,{variant:"primary",onClick:z,disabled:M||!O.trim(),loading:M,icon:i4,"data-testid":"test-send-btn",children:M?"Sending...":"Test Send"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:441,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:427,columnNumber:15},globalThis),P&&i.jsxDEV("div",{className:`text-sm px-3 py-2 rounded-lg ${P==="Message sent successfully"?"bg-emerald-500/10 text-emerald-400":"bg-rose-500/10 text-rose-400"}`,"data-testid":"test-send-result",children:P},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:453,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:425,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:328,columnNumber:9},globalThis):i.jsxDEV("div",{className:"space-y-5",children:[i.jsxDEV("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-lg p-4 flex items-center gap-3",children:[i.jsxDEV(Yf,{className:"w-5 h-5 text-amber-400"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:467,columnNumber:13},globalThis),i.jsxDEV("span",{className:"text-amber-400 font-medium text-sm",children:"Not connected to Google Chat"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:468,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:466,columnNumber:11},globalThis),i.jsxDEV("div",{className:"flex gap-2",children:[i.jsxDEV("button",{className:`px-4 py-2 text-sm rounded-lg border transition-colors ${u==="pubsub"?"bg-primary/10 border-primary text-primary":"bg-surface-dark border-border-dark text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>d("pubsub"),"data-testid":"mode-pubsub",children:"Pub/Sub (Recommended)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:473,columnNumber:13},globalThis),i.jsxDEV("button",{className:`px-4 py-2 text-sm rounded-lg border transition-colors ${u==="webhook"?"bg-primary/10 border-primary text-primary":"bg-surface-dark border-border-dark text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>d("webhook"),"data-testid":"mode-webhook",children:"Webhook"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:484,columnNumber:13},globalThis),i.jsxDEV("button",{className:`px-4 py-2 text-sm rounded-lg border transition-colors ${u==="service-account"?"bg-primary/10 border-primary text-primary":"bg-surface-dark border-border-dark text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>d("service-account"),"data-testid":"mode-service-account",children:"Service Account"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:495,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:472,columnNumber:11},globalThis),i.jsxDEV("div",{className:"bg-background-dark border border-border-dark rounded-lg p-5",children:[i.jsxDEV("h3",{className:"text-xs font-semibold text-text-secondary-dark uppercase tracking-wide mb-3",children:u==="pubsub"?"Pub/Sub Setup (Bidirectional)":u==="webhook"?"Webhook Setup (Send-only)":"Service Account Setup (Send-only)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:510,columnNumber:13},globalThis),u==="pubsub"?i.jsxDEV("ol",{className:"list-decimal list-inside space-y-2 text-sm text-text-secondary-dark",children:[i.jsxDEV("li",{children:["Go to ",i.jsxDEV("strong",{children:"Google Cloud Console"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:517,columnNumber:27},globalThis)," > ",i.jsxDEV("strong",{children:"APIs & Services"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:517,columnNumber:70},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:517,columnNumber:17},globalThis),i.jsxDEV("li",{children:["Enable the ",i.jsxDEV("strong",{children:"Google Chat API"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:518,columnNumber:32},globalThis)," and ",i.jsxDEV("strong",{children:"Cloud Pub/Sub API"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:518,columnNumber:69},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:518,columnNumber:17},globalThis),i.jsxDEV("li",{children:["Create a ",i.jsxDEV("strong",{children:"Service Account"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:519,columnNumber:30},globalThis)," and download the JSON key"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:519,columnNumber:17},globalThis),i.jsxDEV("li",{children:["In the Chat API settings, create a ",i.jsxDEV("strong",{children:"Chat App"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:520,columnNumber:56},globalThis)," and select ",i.jsxDEV("strong",{children:"Cloud Pub/Sub"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:520,columnNumber:93},globalThis)," as the connection type"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:520,columnNumber:17},globalThis),i.jsxDEV("li",{children:["Enter a ",i.jsxDEV("strong",{children:"Pub/Sub topic name"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:521,columnNumber:29},globalThis)," (e.g., ",i.jsxDEV("code",{className:"bg-surface-dark px-1 rounded",children:"projects/my-project/topics/google-chat-events"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:521,columnNumber:72},globalThis),")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:521,columnNumber:17},globalThis),i.jsxDEV("li",{children:["Create a ",i.jsxDEV("strong",{children:"Pub/Sub subscription"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:522,columnNumber:30},globalThis)," for that topic (pull mode)"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:522,columnNumber:17},globalThis),i.jsxDEV("li",{children:["Grant the service account ",i.jsxDEV("strong",{children:"Pub/Sub Subscriber"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:523,columnNumber:47},globalThis)," role on the subscription"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:523,columnNumber:17},globalThis),i.jsxDEV("li",{children:"Fill in the details below"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:524,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:516,columnNumber:15},globalThis):u==="webhook"?i.jsxDEV("ol",{className:"list-decimal list-inside space-y-2 text-sm text-text-secondary-dark",children:[i.jsxDEV("li",{children:"Open your Google Chat space"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:528,columnNumber:17},globalThis),i.jsxDEV("li",{children:["Click the space name > ",i.jsxDEV("strong",{children:"Apps & integrations"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:529,columnNumber:47},globalThis)," > ",i.jsxDEV("strong",{children:"Manage webhooks"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:529,columnNumber:89},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:529,columnNumber:17},globalThis),i.jsxDEV("li",{children:"Create a new webhook and copy the URL"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:530,columnNumber:17},globalThis),i.jsxDEV("li",{children:"Paste the webhook URL below"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:531,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:527,columnNumber:15},globalThis):i.jsxDEV("ol",{className:"list-decimal list-inside space-y-2 text-sm text-text-secondary-dark",children:[i.jsxDEV("li",{children:["Go to the ",i.jsxDEV("strong",{children:"Google Cloud Console"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:535,columnNumber:31},globalThis)," > ",i.jsxDEV("strong",{children:"APIs & Services"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:535,columnNumber:74},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:535,columnNumber:17},globalThis),i.jsxDEV("li",{children:["Enable the ",i.jsxDEV("strong",{children:"Google Chat API"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:536,columnNumber:32},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:536,columnNumber:17},globalThis),i.jsxDEV("li",{children:["Create a ",i.jsxDEV("strong",{children:"Service Account"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:537,columnNumber:30},globalThis)," and download the JSON key"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:537,columnNumber:17},globalThis),i.jsxDEV("li",{children:"Grant the service account access to your Chat space"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:538,columnNumber:17},globalThis),i.jsxDEV("li",{children:"Paste the JSON key contents below"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:539,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:534,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:509,columnNumber:11},globalThis),i.jsxDEV("form",{onSubmit:Z,className:"space-y-4",children:[u==="webhook"?i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"gchat-webhook",required:!0,children:"Webhook URL"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:548,columnNumber:17},globalThis),i.jsxDEV(mn,{id:"gchat-webhook",name:"webhookUrl",type:"url",value:g,onChange:ee=>v(ee.target.value),placeholder:"https://chat.googleapis.com/v1/spaces/...",required:!0,autoComplete:"off"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:549,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:547,columnNumber:15},globalThis):i.jsxDEV(i.Fragment,{children:[i.jsxDEV("div",{children:[i.jsxDEV(Fr,{children:"Authentication Method"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:564,columnNumber:19},globalThis),i.jsxDEV("div",{className:"flex gap-2 mt-1",children:[i.jsxDEV("button",{type:"button",className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${f==="service_account"?"bg-primary/10 border-primary text-primary":"bg-surface-dark border-border-dark text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>m("service_account"),"data-testid":"auth-service-account",children:"Service Account Key"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:566,columnNumber:21},globalThis),i.jsxDEV("button",{type:"button",className:`px-3 py-1.5 text-xs rounded-lg border transition-colors ${f==="adc"?"bg-primary/10 border-primary text-primary":"bg-surface-dark border-border-dark text-text-secondary-dark hover:text-text-primary-dark"}`,onClick:()=>m("adc"),"data-testid":"auth-adc",children:"Application Default Credentials"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:578,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:565,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:563,columnNumber:17},globalThis),u==="pubsub"&&i.jsxDEV(i.Fragment,{children:[i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"gchat-project-id",required:!0,children:"GCP Project ID"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:596,columnNumber:23},globalThis),i.jsxDEV(mn,{id:"gchat-project-id",name:"projectId",type:"text",value:b,onChange:ee=>x(ee.target.value),placeholder:"my-gcp-project-id",required:!0,autoComplete:"off"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:597,columnNumber:23},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:595,columnNumber:21},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"gchat-subscription",required:!0,children:"Pub/Sub Subscription Name"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:609,columnNumber:23},globalThis),i.jsxDEV(mn,{id:"gchat-subscription",name:"subscriptionName",type:"text",value:D,onChange:ee=>T(ee.target.value),placeholder:"google-chat-events-sub",required:!0,autoComplete:"off"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:610,columnNumber:23},globalThis),i.jsxDEV("p",{className:"mt-1 text-xs text-text-secondary-dark/70",children:"Just the subscription name, not the full resource path"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:620,columnNumber:23},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:608,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:594,columnNumber:19},globalThis),f==="adc"?i.jsxDEV(i.Fragment,{children:[i.jsxDEV("div",{className:"bg-blue-500/10 border border-blue-500/30 rounded-lg p-4",children:[i.jsxDEV("p",{className:"text-sm text-blue-300 mb-2",children:"Using Application Default Credentials from your local gcloud CLI."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:630,columnNumber:23},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mb-2",children:"Run this command if you haven't already:"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:633,columnNumber:23},globalThis),i.jsxDEV("code",{className:"block bg-background-dark px-3 py-2 rounded text-xs text-text-primary-dark font-mono break-all",children:"gcloud auth application-default login --scopes=https://www.googleapis.com/auth/chat.bot,https://www.googleapis.com/auth/pubsub,https://www.googleapis.com/auth/cloud-platform"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:636,columnNumber:23},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:629,columnNumber:21},globalThis),i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"gchat-sa-email",children:"Service Account Email (for impersonation)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:641,columnNumber:23},globalThis),i.jsxDEV(mn,{id:"gchat-sa-email",name:"serviceAccountEmail",type:"email",value:J,onChange:ee=>ie(ee.target.value),placeholder:"chatbot@project.iam.gserviceaccount.com",autoComplete:"off","data-testid":"sa-email-input"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:642,columnNumber:23},globalThis),i.jsxDEV("p",{className:"mt-1 text-xs text-text-secondary-dark/70",children:"Required for sending messages. Your user needs the Service Account Token Creator IAM role."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:652,columnNumber:23},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:640,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:628,columnNumber:19},globalThis):i.jsxDEV("div",{children:[i.jsxDEV(Fr,{htmlFor:"gchat-sa-key",required:!0,children:"Service Account Key (JSON)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:659,columnNumber:21},globalThis),i.jsxDEV("textarea",{id:"gchat-sa-key",name:"serviceAccountKey",value:N,onChange:ee=>j(ee.target.value),placeholder:'{"type": "service_account", "project_id": "...", ...}',required:!0,rows:6,className:"w-full px-3 py-2 bg-background-dark border border-border-dark rounded-lg text-sm text-text-primary-dark placeholder:text-text-secondary-dark/50 focus:outline-none focus:ring-2 focus:ring-primary/50 font-mono"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:660,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:658,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:561,columnNumber:15},globalThis),i.jsxDEV(pr,{type:"submit",disabled:n||!fe(),loading:n,fullWidth:!0,children:n?"Connecting...":"Connect Google Chat"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:675,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:545,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:465,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/GoogleChatTab.tsx",lineNumber:312,columnNumber:5},globalThis)},Phe=[{id:"slack",name:"Slack",description:"Connect your Slack workspace for team communication with the orchestrator.",icon:wK,available:!0,component:Vhe},{id:"whatsapp",name:"WhatsApp",description:"Connect via WhatsApp Web to communicate with the orchestrator from your phone.",icon:MK,available:!0,component:Fhe},{id:"discord",name:"Discord",description:"Connect a Discord bot to communicate with the orchestrator via Discord server.",icon:TK,available:!1},{id:"telegram",name:"Telegram",description:"Connect a Telegram bot for messaging the orchestrator via Telegram.",icon:i4,available:!1},{id:"google-chat",name:"Google Chat",description:"Connect Google Chat for workspace communication with the orchestrator.",icon:r4,available:!0,component:Ihe}],Lhe=()=>{const[s,e]=F.useState(null),t=r=>{e(n=>n===r?null:r)};return i.jsxDEV("div",{className:"space-y-6 max-w-3xl",children:[i.jsxDEV("div",{children:[i.jsxDEV("h2",{className:"text-xl font-semibold",children:"Messaging Integrations"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:119,columnNumber:9},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Connect messaging platforms to communicate with the orchestrator from anywhere."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:120,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:118,columnNumber:7},globalThis),i.jsxDEV("div",{className:"space-y-3",children:Phe.map(r=>{const n=s===r.id,o=r.icon;return i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg overflow-hidden","data-testid":`platform-card-${r.id}`,children:[i.jsxDEV("button",{className:`w-full flex items-center gap-4 p-4 text-left transition-colors ${r.available?"hover:bg-background-dark cursor-pointer":"opacity-60 cursor-default"}`,onClick:()=>r.available&&t(r.id),disabled:!r.available,"data-testid":`platform-toggle-${r.id}`,children:[i.jsxDEV("div",{className:"flex items-center justify-center w-10 h-10 rounded-lg bg-background-dark border border-border-dark",children:i.jsxDEV(o,{className:"w-5 h-5 text-text-secondary-dark"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:149,columnNumber:19},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:148,columnNumber:17},globalThis),i.jsxDEV("div",{className:"flex-1 min-w-0",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("span",{className:"text-sm font-semibold",children:r.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:154,columnNumber:21},globalThis),!r.available&&i.jsxDEV("span",{className:"text-xs px-2 py-0.5 rounded-full bg-background-dark text-text-secondary-dark border border-border-dark",children:"Coming Soon"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:156,columnNumber:23},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:153,columnNumber:19},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mt-0.5 truncate",children:r.description},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:161,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:152,columnNumber:17},globalThis),r.available&&i.jsxDEV("div",{className:"text-text-secondary-dark",children:n?i.jsxDEV(hx,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:169,columnNumber:23},globalThis):i.jsxDEV(Jf,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:171,columnNumber:23},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:167,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:138,columnNumber:15},globalThis),n&&r.component&&i.jsxDEV("div",{className:"border-t border-border-dark p-6","data-testid":`platform-content-${r.id}`,children:i.jsxDEV(r.component,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:180,columnNumber:19},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:179,columnNumber:17},globalThis)]},r.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:132,columnNumber:13},globalThis)})},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:126,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/IntegrationsTab.tsx",lineNumber:116,columnNumber:5},globalThis)},nR={gemini:"Google Gemini",anthropic:"Anthropic",openai:"OpenAI"},EB={gemini:"GOOGLE_GENERATIVE_AI_API_KEY",anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY"},Ohe=2e3,Bhe=()=>{const{settings:s,updateSettings:e,isLoading:t,error:r}=WF(),[n,o]=F.useState({global:{},runtimeOverrides:{},skillOverrides:{}}),[a,c]=F.useState(!1),[u,d]=F.useState("idle"),[f,m]=F.useState(null),[g,v]=F.useState({}),[N,j]=F.useState({}),[b,x]=F.useState({}),[D,T]=F.useState({});F.useEffect(()=>{s!=null&&s.apiKeys&&(o(s.apiKeys),c(!1))},[s]);const E=F.useCallback((B,O)=>{o(H=>({...H,global:{...H.global,[B]:O}})),c(!0),d("idle"),j(H=>({...H,[`global-${B}`]:"idle"}))},[]),k=F.useCallback((B,O,H,J)=>{o(ie=>{var Z,Y,X;const se={...((Y=(Z=ie.runtimeOverrides)==null?void 0:Z[B])==null?void 0:Y[O])??{key:"",source:"global"},[H]:J};return{...ie,runtimeOverrides:{...ie.runtimeOverrides,[B]:{...(X=ie.runtimeOverrides)==null?void 0:X[B],[O]:se}}}}),c(!0),d("idle")},[]),U=async()=>{d("saving"),m(null);try{await e({apiKeys:n}),d("saved"),c(!1),setTimeout(()=>d("idle"),Ohe)}catch(B){d("error"),m(B instanceof Error?B.message:"Failed to save")}},V=async(B,O,H)=>{if(!(!O||O.startsWith("••••"))){j(J=>({...J,[H]:"testing"})),x(J=>({...J,[H]:""}));try{const J=await Ow.testApiKey(B,O);j(ie=>({...ie,[H]:J.valid?"valid":"invalid"})),!J.valid&&J.error&&x(ie=>({...ie,[H]:J.error}))}catch{j(J=>({...J,[H]:"invalid"})),x(J=>({...J,[H]:"Connection failed"}))}}},M=B=>{v(O=>({...O,[B]:!O[B]}))},R=B=>{T(O=>({...O,[B]:!O[B]}))},P=(B,O)=>{const H=N[O];return H==="testing"?i.jsxDEV("span",{className:"text-xs text-text-secondary-dark animate-pulse",children:"Testing..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:176,columnNumber:14},globalThis):H==="valid"?i.jsxDEV("span",{className:"flex items-center gap-1 text-xs text-green-400",children:[i.jsxDEV(El,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:179,columnNumber:79},globalThis)," Valid"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:179,columnNumber:14},globalThis):H==="invalid"?i.jsxDEV("span",{className:"flex items-center gap-1 text-xs text-red-400",children:[i.jsxDEV(Xc,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:182,columnNumber:77},globalThis)," ",b[O]||"Invalid"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:182,columnNumber:14},globalThis):B&&!B.startsWith("••••")?i.jsxDEV("span",{className:"flex items-center gap-1 text-xs text-green-400",children:[i.jsxDEV(El,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:185,columnNumber:79},globalThis)," Configured"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:185,columnNumber:14},globalThis):B&&B.startsWith("••••")?i.jsxDEV("span",{className:"flex items-center gap-1 text-xs text-blue-400",children:[i.jsxDEV(hR,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:188,columnNumber:78},globalThis)," Saved"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:188,columnNumber:14},globalThis):i.jsxDEV("span",{className:"flex items-center gap-1 text-xs text-text-secondary-dark",children:[i.jsxDEV(Xc,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:190,columnNumber:87},globalThis)," Not set"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:190,columnNumber:12},globalThis)};return t?i.jsxDEV("div",{className:"text-text-secondary-dark",children:"Loading settings..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:194,columnNumber:12},globalThis):r?i.jsxDEV("div",{className:"bg-red-900/20 border border-red-800 rounded-lg p-4",children:i.jsxDEV("p",{className:"text-red-400",children:r},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:200,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:199,columnNumber:7},globalThis):i.jsxDEV("div",{className:"space-y-8",children:[i.jsxDEV("div",{className:"flex items-center justify-between",children:[i.jsxDEV("div",{children:[i.jsxDEV("h2",{className:"text-xl font-semibold",children:"API Keys"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:210,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Configure AI provider API keys. Keys are encrypted at rest and never logged."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:211,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:209,columnNumber:9},globalThis),i.jsxDEV("div",{className:"flex gap-2",children:i.jsxDEV(pr,{variant:"secondary",size:"sm",onClick:U,disabled:!a||u==="saving",children:u==="saving"?i.jsxDEV(i.Fragment,{children:[i.jsxDEV(dV,{className:"w-4 h-4 animate-spin"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:223,columnNumber:17},globalThis)," Saving..."]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:223,columnNumber:15},globalThis):u==="saved"?i.jsxDEV(i.Fragment,{children:[i.jsxDEV(El,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:225,columnNumber:17},globalThis)," Saved"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:225,columnNumber:15},globalThis):i.jsxDEV(i.Fragment,{children:[i.jsxDEV(XT,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:227,columnNumber:17},globalThis)," Save Changes"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:227,columnNumber:15},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:216,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:215,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:208,columnNumber:7},globalThis),u==="error"&&f&&i.jsxDEV("div",{className:"bg-red-900/20 border border-red-800 rounded-lg p-3",children:i.jsxDEV("p",{className:"text-sm text-red-400",children:f},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:235,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:234,columnNumber:9},globalThis),i.jsxDEV("section",{className:"bg-surface-dark rounded-lg border border-border-dark p-6",children:[i.jsxDEV("div",{className:"flex items-center gap-2 mb-4",children:[i.jsxDEV(hR,{className:"w-5 h-5 text-primary"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:242,columnNumber:11},globalThis),i.jsxDEV("h3",{className:"text-lg font-medium",children:"Global API Keys"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:243,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:241,columnNumber:9},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mb-6",children:"These keys are used system-wide as defaults. Runtimes and skills can override them with their own keys."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:245,columnNumber:9},globalThis),i.jsxDEV("div",{className:"space-y-5",children:SB.map(B=>{const O=n.global[B]||"",H=`global-${B}`,J=g[H];return i.jsxDEV("div",{className:"space-y-1",children:[i.jsxDEV("div",{className:"flex items-center justify-between",children:[i.jsxDEV(Fr,{htmlFor:`global-${B}`,children:nR[B]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:258,columnNumber:19},globalThis),P(O,H)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:257,columnNumber:17},globalThis),i.jsxDEV("div",{className:"flex gap-2",children:[i.jsxDEV("div",{className:"relative flex-1",children:[i.jsxDEV(mn,{id:`global-${B}`,type:J?"text":"password",value:O,onChange:ie=>E(B,ie.target.value),placeholder:`Enter ${EB[B]}`,className:"pr-10 font-mono text-sm"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:265,columnNumber:21},globalThis),i.jsxDEV("button",{type:"button",onClick:()=>M(H),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-secondary-dark hover:text-text-primary-dark","aria-label":J?"Hide key":"Show key",children:J?i.jsxDEV(QI,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:279,columnNumber:36},globalThis):i.jsxDEV(dR,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:279,columnNumber:69},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:273,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:264,columnNumber:19},globalThis),i.jsxDEV(pr,{variant:"secondary",size:"sm",onClick:()=>V(B,O,H),disabled:!O||O.startsWith("••••")||N[H]==="testing",children:[i.jsxDEV(lT,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:288,columnNumber:21},globalThis),"Test"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:282,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:263,columnNumber:17},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark",children:["Env var: ",i.jsxDEV("code",{className:"bg-surface-dark px-1 rounded",children:EB[B]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:293,columnNumber:28},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:292,columnNumber:17},globalThis)]},B,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:256,columnNumber:15},globalThis)})},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:249,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:240,columnNumber:7},globalThis),i.jsxDEV("section",{className:"bg-surface-dark rounded-lg border border-border-dark p-6",children:[i.jsxDEV("div",{className:"flex items-center gap-2 mb-4",children:[i.jsxDEV(lT,{className:"w-5 h-5 text-primary"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:304,columnNumber:11},globalThis),i.jsxDEV("h3",{className:"text-lg font-medium",children:"Runtime Overrides"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:305,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:303,columnNumber:9},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mb-4",children:"Override global keys for specific AI runtimes. By default, runtimes use the global key."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:307,columnNumber:9},globalThis),i.jsxDEV("div",{className:"space-y-2",children:EH.map(B=>{const O=D[B];return i.jsxDEV("div",{className:"border border-border-dark rounded-lg",children:[i.jsxDEV("button",{type:"button",onClick:()=>R(B),className:"w-full flex items-center justify-between px-4 py-3 text-sm font-medium hover:bg-surface-dark/50 rounded-lg",children:[i.jsxDEV("span",{children:wT[B]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:322,columnNumber:19},globalThis),O?i.jsxDEV(hx,{className:"w-4 h-4 text-text-secondary-dark"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:324,columnNumber:21},globalThis):i.jsxDEV(Jf,{className:"w-4 h-4 text-text-secondary-dark"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:326,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:317,columnNumber:17},globalThis),O&&i.jsxDEV("div",{className:"px-4 pb-4 space-y-4 border-t border-border-dark pt-4",children:SB.map(H=>{var Z,Y;const J=(Y=(Z=n.runtimeOverrides)==null?void 0:Z[B])==null?void 0:Y[H],ie=(J==null?void 0:J.source)==="custom",te=ie&&(J==null?void 0:J.key)||"",se=`runtime-${B}-${H}`;return i.jsxDEV("div",{className:"space-y-2",children:[i.jsxDEV("div",{className:"flex items-center justify-between",children:[i.jsxDEV(Fr,{htmlFor:`${B}-${H}-toggle`,children:nR[H]},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:341,columnNumber:29},globalThis),i.jsxDEV("label",{className:"flex items-center gap-2 cursor-pointer text-sm",children:[i.jsxDEV("input",{id:`${B}-${H}-toggle`,type:"checkbox",checked:ie,onChange:X=>k(B,H,"source",X.target.checked?"custom":"global"),className:"form-checkbox rounded border-border-dark bg-surface-dark"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:345,columnNumber:31},globalThis),i.jsxDEV("span",{className:"text-text-secondary-dark",children:ie?"Custom key":"Use global"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:355,columnNumber:31},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:344,columnNumber:29},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:340,columnNumber:27},globalThis),ie&&i.jsxDEV("div",{className:"flex gap-2",children:[i.jsxDEV("div",{className:"relative flex-1",children:[i.jsxDEV(mn,{type:g[se]?"text":"password",value:te,onChange:X=>k(B,H,"key",X.target.value),placeholder:`Custom ${nR[H]} key for ${wT[B]}`,className:"pr-10 font-mono text-sm"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:364,columnNumber:33},globalThis),i.jsxDEV("button",{type:"button",onClick:()=>M(se),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-secondary-dark hover:text-text-primary-dark",children:g[se]?i.jsxDEV(QI,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:378,columnNumber:58},globalThis):i.jsxDEV(dR,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:378,columnNumber:91},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:373,columnNumber:33},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:363,columnNumber:31},globalThis),i.jsxDEV(pr,{variant:"secondary",size:"sm",onClick:()=>V(H,te,se),disabled:!te||te.startsWith("••••")||N[se]==="testing",children:[i.jsxDEV(lT,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:387,columnNumber:33},globalThis),"Test"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:381,columnNumber:31},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:362,columnNumber:29},globalThis)]},H,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:339,columnNumber:25},globalThis)})},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:331,columnNumber:19},globalThis)]},B,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:316,columnNumber:15},globalThis)})},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:311,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:302,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/ApiKeysTab.tsx",lineNumber:206,columnNumber:5},globalThis)},Hhe="/api/cloud/validate",Ghe="/api/relay/cloud-devices";function zhe(s){const e=Date.now()-new Date(s).getTime(),t=Math.floor(e/1e3);return t<5?"Just now":t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}const Whe={waiting:"Connecting",paired:"Connected",disconnected:"Offline"},Khe={waiting:"bg-yellow-400",paired:"bg-emerald-400",disconnected:"bg-gray-500"},Xhe=({device:s})=>{const e=s.role==="orchestrator"?fx:qB,t=Khe[s.state]??"bg-gray-500",r=Whe[s.state]??s.state,n=s.name??`${s.role} (${s.sessionId.slice(0,8)}...)`;return i.jsxDEV("div",{"data-testid":`cloud-device-${s.sessionId}`,className:`flex items-center justify-between p-3 rounded-lg border transition-colors ${s.isLocal?"border-primary/30 bg-primary/5":"border-border-dark bg-background-dark hover:border-border-dark/80"}`,children:[i.jsxDEV("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsxDEV("div",{className:`p-1.5 rounded-md ${s.isLocal?"bg-primary/10":"bg-surface-dark"}`,children:i.jsxDEV(e,{className:`w-4 h-4 ${s.isLocal?"text-primary":"text-text-secondary-dark"}`},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:112,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:111,columnNumber:9},globalThis),i.jsxDEV("div",{className:"min-w-0",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("span",{className:"text-sm font-medium text-text-primary-dark truncate",children:n},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:116,columnNumber:13},globalThis),s.isLocal&&i.jsxDEV("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-primary/10 text-primary whitespace-nowrap",children:"This machine"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:120,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:115,columnNumber:11},globalThis),i.jsxDEV("span",{className:"text-xs text-text-secondary-dark",children:["Last seen: ",zhe(s.lastHeartbeatAt)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:125,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:114,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:110,columnNumber:7},globalThis),i.jsxDEV("div",{className:"flex items-center gap-1.5 ml-3 whitespace-nowrap",children:[i.jsxDEV("span",{className:`h-2 w-2 rounded-full ${t}`},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:132,columnNumber:9},globalThis),i.jsxDEV("span",{className:"text-xs text-text-secondary-dark",children:r},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:133,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:131,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:102,columnNumber:5},globalThis)},Zhe=()=>{const[s,e]=F.useState([]),[t,r]=F.useState(!0),[n,o]=F.useState(null),a=F.useCallback(async()=>{var c;try{r(!0),o(null);const u=await fetch(Ghe),d=await u.json();u.ok&&d.success&&((c=d.data)!=null&&c.devices)?e(d.data.devices):o(d.error||"Failed to load devices")}catch{o("Could not reach the server")}finally{r(!1)}},[]);return F.useEffect(()=>{a()},[a]),i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-5 space-y-3","data-testid":"cloud-device-list-section",children:[i.jsxDEV("div",{className:"flex items-center justify-between",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV(f4,{className:"w-4 h-4 text-text-secondary-dark"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:179,columnNumber:11},globalThis),i.jsxDEV("h3",{className:"text-sm font-semibold text-text-primary-dark",children:"Connected Devices"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:180,columnNumber:11},globalThis),i.jsxDEV("span",{className:"text-xs text-text-secondary-dark",children:["(",s.length,")"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:181,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:178,columnNumber:9},globalThis),i.jsxDEV("button",{onClick:a,disabled:t,className:"p-1.5 text-text-secondary-dark hover:text-text-primary-dark rounded-md hover:bg-background-dark transition-colors disabled:opacity-50","aria-label":"Refresh devices","data-testid":"refresh-devices-button",children:i.jsxDEV(dc,{className:`w-3.5 h-3.5 ${t?"animate-spin":""}`},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:192,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:185,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:177,columnNumber:7},globalThis),n&&i.jsxDEV("div",{className:"text-xs text-rose-400 bg-rose-500/10 border border-rose-500/20 rounded px-3 py-2",children:n},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:197,columnNumber:9},globalThis),!t&&!n&&s.length===0&&i.jsxDEV("div",{className:"text-center py-6",children:[i.jsxDEV(fx,{className:"w-8 h-8 text-text-secondary-dark/30 mx-auto mb-2"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:204,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark",children:"No devices connected yet"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:205,columnNumber:11},globalThis),i.jsxDEV("p",{className:"text-[11px] text-text-secondary-dark/60 mt-0.5",children:["Connect from another machine using ",i.jsxDEV("code",{className:"text-primary/80",children:"crewly cloud connect"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:207,columnNumber:48},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:206,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:203,columnNumber:9},globalThis),s.length>0&&i.jsxDEV("div",{className:"space-y-2",children:s.map(c=>i.jsxDEV(Xhe,{device:c},c.sessionId,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:215,columnNumber:13},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:213,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:176,columnNumber:5},globalThis)},qhe=()=>{const[s,e]=F.useState(null),[t,r]=F.useState(!0),[n,o]=F.useState(null),a=F.useCallback(async()=>{const m=localStorage.getItem(Lw);if(!m){r(!1);return}try{const g=await fetch(Hhe,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`}}),v=await g.json();g.ok&&v.success&&v.data?(e({id:v.data.id,email:v.data.email,plan:v.data.plan,name:v.data.name,avatar:v.data.avatar}),o(null)):(localStorage.removeItem(Lw),e(null))}catch{o("Could not reach CrewlyAI Cloud. Check your internet connection.")}finally{r(!1)}},[]);F.useEffect(()=>{a()},[a]);const c=()=>{const m=`${window.location.origin}/auth/callback`;window.location.href=oY(m)},u=F.useCallback(async m=>{try{await fetch("/api/cloud/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:m})})}catch{}},[]);F.useEffect(()=>{const m=localStorage.getItem(Lw);m&&s&&u(m)},[s,u]);const d=()=>{localStorage.removeItem(Lw),e(null),o(null)},f=m=>{switch(m){case"pro":return"bg-indigo-500/10 text-indigo-400 border-indigo-500/30";case"enterprise":return"bg-amber-500/10 text-amber-400 border-amber-500/30";default:return"bg-gray-500/10 text-gray-400 border-gray-500/30"}};return t?i.jsxDEV("div",{className:"flex items-center justify-center py-12",children:i.jsxDEV("div",{className:"w-6 h-6 border-2 border-primary/20 border-t-primary rounded-full animate-spin"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:342,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:341,columnNumber:7},globalThis):i.jsxDEV("div",{className:"space-y-6",children:[i.jsxDEV("div",{children:[i.jsxDEV("h2",{className:"text-lg font-semibold text-text-primary-dark flex items-center gap-2",children:[i.jsxDEV(jT,{className:"w-5 h-5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:352,columnNumber:11},globalThis),"CrewlyAI Cloud"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:351,columnNumber:9},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Connect to CrewlyAI Cloud for device sync, remote access, and Pro features."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:355,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:350,columnNumber:7},globalThis),n&&i.jsxDEV("div",{className:"bg-rose-500/10 border border-rose-500/30 text-rose-400 px-4 py-3 rounded-lg text-sm",children:n},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:361,columnNumber:9},globalThis),s?i.jsxDEV(i.Fragment,{children:[i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-5 space-y-4",children:[i.jsxDEV("div",{className:"flex items-center justify-between",children:[i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("div",{className:"w-10 h-10 bg-primary/10 rounded-full flex items-center justify-center",children:s.avatar?i.jsxDEV("img",{src:s.avatar,alt:s.name||s.email,className:"w-10 h-10 rounded-full"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:374,columnNumber:21},globalThis):i.jsxDEV(jT,{className:"w-5 h-5 text-primary"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:380,columnNumber:21},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:372,columnNumber:17},globalThis),i.jsxDEV("div",{children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("span",{className:"text-sm font-medium text-text-primary-dark",children:s.name||s.email},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:385,columnNumber:21},globalThis),i.jsxDEV(El,{className:"w-4 h-4 text-emerald-400"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:388,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:384,columnNumber:19},globalThis),i.jsxDEV("span",{className:"text-xs text-text-secondary-dark",children:s.email},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:390,columnNumber:19},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:383,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:371,columnNumber:15},globalThis),i.jsxDEV("span",{className:`px-2 py-0.5 text-xs font-medium rounded border ${f(s.plan)}`,children:s.plan.charAt(0).toUpperCase()+s.plan.slice(1)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:394,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:370,columnNumber:13},globalThis),i.jsxDEV("div",{className:"flex items-center gap-2 pt-2 border-t border-border-dark",children:[i.jsxDEV("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-text-secondary-dark hover:text-text-primary-dark rounded-md hover:bg-background-dark transition-colors",children:[i.jsxDEV(dc,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:404,columnNumber:17},globalThis),"Refresh"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:400,columnNumber:15},globalThis),i.jsxDEV("button",{onClick:d,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-text-secondary-dark hover:text-rose-400 rounded-md hover:bg-background-dark transition-colors",children:[i.jsxDEV(t4,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:411,columnNumber:17},globalThis),"Disconnect"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:407,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:399,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:369,columnNumber:11},globalThis),i.jsxDEV(Zhe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:418,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:368,columnNumber:9},globalThis):i.jsxDEV("div",{className:"bg-surface-dark border border-border-dark rounded-lg p-6 text-center space-y-4",children:[i.jsxDEV("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-primary/10",children:i.jsxDEV(lT,{className:"w-6 h-6 text-primary"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:424,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:423,columnNumber:11},globalThis),i.jsxDEV("div",{children:[i.jsxDEV("h3",{className:"text-sm font-semibold text-text-primary-dark",children:"Connect to CrewlyAI Cloud"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:428,columnNumber:13},globalThis),i.jsxDEV("p",{className:"text-xs text-text-secondary-dark mt-1 max-w-sm mx-auto",children:"Sign in with your CrewlyAI account to enable device sync, remote team access, and Pro features."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:431,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:427,columnNumber:11},globalThis),i.jsxDEV("button",{onClick:c,className:"inline-flex items-center gap-2 px-5 py-2.5 bg-primary text-white rounded-lg font-medium text-sm hover:bg-primary/90 transition-colors","data-testid":"cloud-sign-in-button",children:[i.jsxDEV(IC,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:442,columnNumber:13},globalThis),"Sign in with CrewlyAI"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:437,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:422,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Settings/CloudTab.tsx",lineNumber:348,columnNumber:5},globalThis)},Yhe=new Set(["general","roles","skills","integrations","api-keys","cloud"]),Jhe=()=>{const[s]=FC(),e=s.get("tab"),t=e&&Yhe.has(e)?e:"general",[r,n]=F.useState(t),o=[{id:"general",label:"General",icon:a4},{id:"roles",label:"Roles",icon:mx},{id:"skills",label:"Skills",icon:m4},{id:"integrations",label:"Integrations",icon:uV},{id:"api-keys",label:"API Keys",icon:hR},{id:"cloud",label:"Cloud",icon:jT}],a=()=>{switch(r){case"general":return i.jsxDEV(ghe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:62,columnNumber:16},globalThis);case"roles":return i.jsxDEV(Nhe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:64,columnNumber:16},globalThis);case"skills":return i.jsxDEV(_he,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:66,columnNumber:16},globalThis);case"integrations":return i.jsxDEV(Lhe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:68,columnNumber:16},globalThis);case"api-keys":return i.jsxDEV(Bhe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:70,columnNumber:16},globalThis);case"cloud":return i.jsxDEV(qhe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:72,columnNumber:16},globalThis);default:return null}};return i.jsxDEV("div",{className:"max-w-7xl mx-auto",children:[i.jsxDEV("div",{className:"mb-8",children:[i.jsxDEV("h1",{className:"text-3xl font-bold tracking-tight",children:"Settings"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:82,columnNumber:9},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mt-1",children:"Configure Crewly behavior and manage roles and skills"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:83,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:81,columnNumber:7},globalThis),i.jsxDEV("nav",{className:"flex gap-1 border-b border-border-dark mb-6",role:"tablist",children:o.map(c=>i.jsxDEV("button",{className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors -mb-px ${r===c.id?"border-primary text-primary":"border-transparent text-text-secondary-dark hover:text-text-primary-dark hover:bg-surface-dark"}`,onClick:()=>n(c.id),"aria-selected":r===c.id,role:"tab",id:`tab-${c.id}`,"aria-controls":`panel-${c.id}`,children:[i.jsxDEV(c.icon,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:104,columnNumber:13},globalThis),i.jsxDEV("span",{children:c.label},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:105,columnNumber:13},globalThis)]},c.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:91,columnNumber:11},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:89,columnNumber:7},globalThis),i.jsxDEV("main",{role:"tabpanel",id:`panel-${r}`,"aria-labelledby":`tab-${r}`,children:a()},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:111,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Settings.tsx",lineNumber:79,columnNumber:5},globalThis)},If="/api/chat";class $he{async parseResponse(e,t){const r=await e.text();if(!r)throw new Error(t);try{return JSON.parse(r)}catch{throw new Error(t)}}async sendMessage(e){const t=await fetch(`${If}/send`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await this.parseResponse(t,"Failed to send message");if(!r.success)throw new Error(r.error||"Failed to send message");return r.data}async getMessages(e,t,r){return(await this.getMessagesWithMeta(e,t,r)).messages}async getMessagesWithMeta(e,t,r){const n=new URLSearchParams({conversationId:e});t&&n.set("limit",t.toString()),r&&n.set("before",r);const o=await fetch(`${If}/messages?${n.toString()}`),a=await this.parseResponse(o,"Failed to load messages");if(!a.success)throw new Error(a.error||"Failed to load messages");return{messages:a.data,hasMore:a.hasMore??!1,totalCount:a.totalCount??a.data.length}}async getConversations(e=!1,t){const r=new URLSearchParams;e&&r.set("includeArchived","true"),t&&r.set("channelType",t);const n=r.toString(),o=await fetch(`${If}/conversations${n?"?"+n:""}`),a=await this.parseResponse(o,"Failed to load conversations");if(!a.success)throw new Error(a.error||"Failed to load conversations");return a.data}async getCurrentConversation(){const e=await fetch(`${If}/conversations/current`),t=await this.parseResponse(e,"Failed to load current conversation");if(!t.success)throw new Error(t.error||"Failed to load current conversation");return t.data}async createConversation(e){const t=await fetch(`${If}/conversations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e})}),r=await this.parseResponse(t,"Request failed");if(!r.success)throw new Error(r.error||"Failed to create conversation");return r.data}async updateConversation(e,t){const r=await fetch(`${If}/conversations/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await this.parseResponse(r,"Request failed");if(!n.success)throw new Error(n.error||"Failed to update conversation");return n.data}async deleteConversation(e){const t=await fetch(`${If}/conversations/${e}`,{method:"DELETE"}),r=await this.parseResponse(t,"Request failed");if(!r.success)throw new Error(r.error||"Failed to delete conversation")}async archiveConversation(e){const t=await fetch(`${If}/conversations/${e}/archive`,{method:"PUT"}),r=await this.parseResponse(t,"Request failed");if(!r.success)throw new Error(r.error||"Failed to archive conversation")}async clearConversation(e){const t=await fetch(`${If}/conversations/${e}/clear`,{method:"POST"}),r=await this.parseResponse(t,"Request failed");if(!r.success)throw new Error(r.error||"Failed to clear conversation")}}const Hu=new $he,CH=F.createContext(null),Qhe=({children:s})=>{const[e,t]=F.useState([]),[r,n]=F.useState(null),[o,a]=F.useState([]),[c,u]=F.useState(!0),[d,f]=F.useState(!1),[m,g]=F.useState(null),[v,N]=F.useState(!1),[j,b]=F.useState(null),[x,D]=F.useState(!1),[T,E]=F.useState(!1),k=F.useRef(null);F.useEffect(()=>{k.current=r},[r]);const U=F.useCallback(Y=>{let X;const z=Y;if(z&&typeof z=="object"&&("data"in z&&z.data&&typeof z.data=="object"?X=z.data:"id"in z&&(X=z)),!X||!X.id)return;const oe=k.current;X.conversationId===(oe==null?void 0:oe.id)&&(a(le=>le.some(fe=>fe.id===X.id)?le:[...le,X]),N(!1)),t(le=>le.map(fe=>fe.id===X.conversationId?{...fe,lastMessage:{content:X.content.slice(0,100),timestamp:X.timestamp,from:X.from},messageCount:fe.messageCount+1,updatedAt:X.timestamp}:fe))},[]),V=F.useCallback(Y=>{const X=Y,z=X.data||X,oe=k.current;z.conversationId===(oe==null?void 0:oe.id)&&N(z.isTyping??!1)},[]),M=F.useCallback(Y=>{let X;const z=Y;if(z&&typeof z=="object"&&("data"in z&&z.data&&typeof z.data=="object"?X=z.data:"id"in z&&(X=z)),!X||!X.id)return;t(le=>{const fe=le.findIndex(ee=>ee.id===X.id);if(fe>=0){const ee=[...le];return ee[fe]=X,ee}return[X,...le]});const oe=k.current;(oe==null?void 0:oe.id)===X.id&&n(X)},[]);F.useEffect(()=>(tr.on("chat_message",U),tr.on("chat_typing",V),tr.on("conversation_updated",M),tr.subscribeToChat(),()=>{tr.off("chat_message",U),tr.off("chat_typing",V),tr.off("conversation_updated",M),tr.unsubscribeFromChat()}),[U,V,M]),F.useEffect(()=>{(async()=>{u(!0);try{const[X,z]=await Promise.all([Hu.getConversations(),Hu.getCurrentConversation()]);if(t(X),z){n(z);const oe=await Hu.getMessagesWithMeta(z.id);a(oe.messages),D(oe.hasMore)}}catch(X){g(X instanceof Error?X.message:"Failed to load chat")}finally{u(!1)}})()},[]);const R=F.useCallback(async Y=>{if(!(!Y.trim()||d)){f(!0),g(null);try{const X=await Hu.sendMessage({content:Y,conversationId:r==null?void 0:r.id});a(z=>z.some(oe=>oe.id===X.message.id)?z:[...z,X.message]),r||(n(X.conversation),t(z=>[X.conversation,...z])),X.orchestrator&&!X.orchestrator.forwarded&&X.orchestrator.error&&g(X.orchestrator.error)}catch(X){g(X instanceof Error?X.message:"Failed to send message")}finally{f(!1)}}},[d,r]),P=F.useCallback(async Y=>{const X=e.find(z=>z.id===Y);if(X){n(X),u(!0),g(null);try{const z=await Hu.getMessagesWithMeta(Y);a(z.messages),D(z.hasMore)}catch(z){g(z instanceof Error?z.message:"Failed to load messages")}finally{u(!1)}}},[e]),B=F.useCallback(async Y=>{const X=await Hu.createConversation(Y);return t(z=>[X,...z]),n(X),a([]),X},[]),O=F.useCallback(async Y=>{if(await Hu.deleteConversation(Y),t(X=>X.filter(z=>z.id!==Y)),(r==null?void 0:r.id)===Y){const X=e.filter(z=>z.id!==Y);X.length>0?await P(X[0].id):(n(null),a([]))}},[r,e,P]),H=F.useCallback(async Y=>{if(await Hu.archiveConversation(Y),t(X=>X.filter(z=>z.id!==Y)),(r==null?void 0:r.id)===Y){const X=e.filter(z=>z.id!==Y);X.length>0?await P(X[0].id):(n(null),a([]))}},[r,e,P]),J=F.useCallback(async Y=>{await Hu.clearConversation(Y),(r==null?void 0:r.id)===Y&&a([])},[r]),ie=F.useCallback(async()=>{if(!r)return;const Y=await Hu.getMessagesWithMeta(r.id);a(Y.messages),D(Y.hasMore)},[r]),te=F.useCallback(async()=>{if(!(!r||!x||T)){E(!0);try{const Y=o[0];if(!Y)return;const X=await Hu.getMessagesWithMeta(r.id,50,Y.timestamp);X.messages.length>0&&a(z=>{const oe=new Set(z.map(fe=>fe.id));return[...X.messages.filter(fe=>!oe.has(fe.id)),...z]}),D(X.hasMore)}catch(Y){g(Y instanceof Error?Y.message:"Failed to load older messages")}finally{E(!1)}}},[r,x,T,o]),se=F.useCallback(()=>{g(null)},[]),Z={conversations:e,currentConversation:r,messages:o,isLoading:c,isSending:d,error:m,isTyping:v,channelFilter:j,hasMoreMessages:x,isLoadingMore:T,sendMessage:R,selectConversation:P,createConversation:B,deleteConversation:O,archiveConversation:H,clearConversation:J,refreshMessages:ie,loadOlderMessages:te,clearError:se,setChannelFilter:b};return i.jsxDEV(CH.Provider,{value:Z,children:s},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/contexts/ChatContext.tsx",lineNumber:486,columnNumber:10},globalThis)},KF=()=>{const s=F.useContext(CH);if(!s)throw new Error("useChat must be used within a ChatProvider");return s},sV={slack:{icon:"🔷",label:"Slack",className:"channel-slack"},crewly_chat:{icon:"💬",label:"Crewly",className:"channel-crewly"},telegram:{icon:"✉️",label:"Telegram",className:"channel-telegram"},api:{icon:"🔌",label:"API",className:"channel-api"}};const efe=[{key:null,label:"All"},...Object.entries(sV).map(([s,{icon:e,label:t}])=>({key:s,label:t,icon:e}))],tfe=({activeFilter:s,onFilterChange:e,conversations:t})=>{const r=new Map;r.set(null,t.length);for(const o of t){const a=o.channelType??"crewly_chat";r.set(a,(r.get(a)??0)+1)}const n=efe.filter(o=>o.key===null||(r.get(o.key)??0)>0);return i.jsxDEV("div",{className:"channel-filter-bar","data-testid":"channel-filter-bar",children:n.map(o=>{const a=r.get(o.key)??0,c=s===o.key;return i.jsxDEV("button",{className:`filter-chip ${c?"active":""}`,onClick:()=>e(o.key),"data-testid":`filter-chip-${o.key??"all"}`,"aria-pressed":c,children:[o.icon&&i.jsxDEV("span",{className:"filter-chip-icon","aria-hidden":"true",children:o.icon},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChannelFilterBar.tsx",lineNumber:93,columnNumber:15},globalThis),i.jsxDEV("span",{className:"filter-chip-label",children:o.label},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChannelFilterBar.tsx",lineNumber:97,columnNumber:13},globalThis),i.jsxDEV("span",{className:"filter-chip-count",children:a},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChannelFilterBar.tsx",lineNumber:98,columnNumber:13},globalThis)]},o.key??"all",!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChannelFilterBar.tsx",lineNumber:85,columnNumber:11},globalThis)})},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChannelFilterBar.tsx",lineNumber:79,columnNumber:5},globalThis)};const AH=({channelType:s,showLabel:e=!0})=>{const t=sV[s]??sV.crewly_chat;return i.jsxDEV("span",{className:`channel-badge ${t.className}`,"data-testid":"channel-badge",title:t.label,children:[i.jsxDEV("span",{className:"channel-badge-icon","aria-hidden":"true",children:t.icon},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChannelBadge.tsx",lineNumber:47,columnNumber:7},globalThis),e&&i.jsxDEV("span",{className:"channel-badge-label",children:t.label},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChannelBadge.tsx",lineNumber:50,columnNumber:21},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChannelBadge.tsx",lineNumber:42,columnNumber:5},globalThis)},di={MINUTE:60*1e3,HOUR:60*60*1e3,DAY:24*60*60*1e3,WEEK:7*24*60*60*1e3,MONTH:30*24*60*60*1e3,YEAR:365*24*60*60*1e3};function MH(s,e=new Date){const t=typeof s=="string"?new Date(s):s,r=e.getTime()-t.getTime();if(r<0)return rfe(Math.abs(r));if(r<di.MINUTE)return"just now";if(r<di.HOUR){const n=Math.floor(r/di.MINUTE);return`${n} ${n===1?"minute":"minutes"} ago`}if(r<di.DAY){const n=Math.floor(r/di.HOUR);return`${n} ${n===1?"hour":"hours"} ago`}if(r<di.DAY*2)return"Yesterday";if(r<di.WEEK)return`${Math.floor(r/di.DAY)} days ago`;if(r<di.MONTH){const n=Math.floor(r/di.WEEK);return`${n} ${n===1?"week":"weeks"} ago`}if(r<di.YEAR){const n=Math.floor(r/di.MONTH);return`${n} ${n===1?"month":"months"} ago`}return sfe(t)}function rfe(s){if(s<di.MINUTE)return"in a moment";if(s<di.HOUR){const t=Math.floor(s/di.MINUTE);return`in ${t} ${t===1?"minute":"minutes"}`}if(s<di.DAY){const t=Math.floor(s/di.HOUR);return`in ${t} ${t===1?"hour":"hours"}`}return s<di.DAY*2?"Tomorrow":`in ${Math.floor(s/di.DAY)} days`}function sfe(s,e={}){const t={month:"short",day:"numeric",year:"numeric",...e};return s.toLocaleDateString(void 0,t)}const nfe=({conversation:s,isActive:e,onClick:t})=>{var c,u,d,f,m,g,v;const r=s.channelType??"crewly_chat",n=s.title||((u=(c=s.lastMessage)==null?void 0:c.content)==null?void 0:u.slice(0,60))||"New conversation",o=((d=s.lastMessage)==null?void 0:d.content)??"",a=((m=(f=s.lastMessage)==null?void 0:f.from)==null?void 0:m.name)??((v=(g=s.lastMessage)==null?void 0:g.from)==null?void 0:v.type)??"";return i.jsxDEV("button",{className:`thread-preview ${e?"active":""}`,onClick:t,"data-testid":"thread-preview","aria-pressed":e,children:[i.jsxDEV("div",{className:"thread-preview-header",children:[i.jsxDEV(AH,{channelType:r,showLabel:!1},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadPreview.tsx",lineNumber:56,columnNumber:9},globalThis),i.jsxDEV("span",{className:"thread-preview-title",children:n},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadPreview.tsx",lineNumber:57,columnNumber:9},globalThis),i.jsxDEV("span",{className:"thread-preview-time",children:MH(s.updatedAt)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadPreview.tsx",lineNumber:58,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadPreview.tsx",lineNumber:55,columnNumber:7},globalThis),i.jsxDEV("div",{className:"thread-preview-body",children:[a&&i.jsxDEV("span",{className:"thread-preview-sender",children:[a,": "]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadPreview.tsx",lineNumber:65,columnNumber:11},globalThis),i.jsxDEV("span",{className:"thread-preview-content",children:o.length>80?o.slice(0,77)+"...":o},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadPreview.tsx",lineNumber:67,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadPreview.tsx",lineNumber:63,columnNumber:7},globalThis),i.jsxDEV("div",{className:"thread-preview-footer",children:i.jsxDEV("span",{className:"thread-preview-count",children:[s.messageCount," ",s.messageCount===1?"message":"messages"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadPreview.tsx",lineNumber:73,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadPreview.tsx",lineNumber:72,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadPreview.tsx",lineNumber:49,columnNumber:5},globalThis)};const ofe=({conversations:s,selectedConversationId:e,onSelectThread:t,channelFilter:r,onChannelFilterChange:n})=>{const a=[...r?s.filter(c=>(c.channelType??"crewly_chat")===r):s].sort((c,u)=>u.updatedAt.localeCompare(c.updatedAt));return i.jsxDEV("div",{className:"thread-list-panel","data-testid":"thread-list-panel",children:[i.jsxDEV(tfe,{activeFilter:r,onFilterChange:n,conversations:s},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadListPanel.tsx",lineNumber:63,columnNumber:7},globalThis),i.jsxDEV("div",{className:"thread-list-scroll",children:a.length===0?i.jsxDEV("div",{className:"thread-list-empty","data-testid":"thread-list-empty",children:i.jsxDEV("p",{children:r?"No conversations for this channel.":"No conversations yet."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadListPanel.tsx",lineNumber:72,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadListPanel.tsx",lineNumber:71,columnNumber:11},globalThis):a.map(c=>i.jsxDEV(nfe,{conversation:c,isActive:c.id===e,onClick:()=>t(c.id)},c.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadListPanel.tsx",lineNumber:80,columnNumber:13},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadListPanel.tsx",lineNumber:69,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadListPanel.tsx",lineNumber:62,columnNumber:5},globalThis)};function ife(s){if(s.from.name)return s.from.name;switch(s.from.type){case"user":return"You";case"orchestrator":return"Orchestrator";case"agent":return s.from.role??"Agent";case"system":return"System";default:return"Unknown"}}function afe(s){switch(s.from.type){case"user":return"👤";case"orchestrator":return"🤖";case"agent":return"🔧";case"system":return"ℹ️";default:return"💬"}}function lfe(s){return s.split(/(```[\s\S]*?```)/g).map((t,r)=>{if(t.startsWith("```")&&t.endsWith("```")){const n=t.slice(3,-3),o=n.indexOf(`
5212
5212
  `),a=o>0?n.slice(0,o).trim():"",c=o>0?n.slice(o+1):n;return i.jsxDEV("pre",{className:"code-block","data-language":a,children:i.jsxDEV("code",{children:c},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:83,columnNumber:11},this)},r,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:82,columnNumber:9},this)}return i.jsxDEV("span",{children:cfe(t)},r,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:90,columnNumber:7},this)})}function cfe(s){return s.split(/(`[^`]+`)/g).map((t,r)=>{if(t.startsWith("`")&&t.endsWith("`"))return i.jsxDEV("code",{className:"inline-code",children:t.slice(1,-1)},r,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:107,columnNumber:9},this);let n=t;const o=/\*\*([^*]+)\*\*/g,a=t.split(o);return a.length>1&&(n=a.map((c,u)=>u%2===1?i.jsxDEV("strong",{children:c},`bold-${r}-${u}`,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:122,columnNumber:11},this):c)),i.jsxDEV(fn.Fragment,{children:n},r,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:129,columnNumber:12},this)})}const ufe=({message:s})=>{var u,d,f;const[e,t]=F.useState(!1),r=s.from.type==="user",n=s.from.type==="system",o=!!((u=s.metadata)!=null&&u.rawOutput),a=()=>{var m;return e&&((m=s.metadata)!=null&&m.rawOutput)?i.jsxDEV("pre",{className:"raw-output","data-testid":"raw-output",children:s.metadata.rawOutput},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:159,columnNumber:9},globalThis):s.contentType==="code"||s.contentType==="markdown"||s.contentType==="text"?i.jsxDEV("div",{className:"formatted-content",children:lfe(s.content)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:170,columnNumber:14},globalThis):i.jsxDEV("p",{children:s.content},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:173,columnNumber:12},globalThis)},c=["chat-message",s.from.type,r?"user-message":"",n?"system-message":"",s.status==="error"?"error-status":""].filter(Boolean).join(" ");return i.jsxDEV("div",{className:c,"data-testid":"chat-message",children:[i.jsxDEV("div",{className:"message-header",children:[i.jsxDEV("span",{className:"sender-icon","aria-hidden":"true",children:afe(s)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:189,columnNumber:9},globalThis),i.jsxDEV("span",{className:"sender-name",children:ife(s)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:192,columnNumber:9},globalThis),i.jsxDEV("span",{className:"message-time",children:MH(s.timestamp)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:193,columnNumber:9},globalThis),o&&i.jsxDEV("button",{className:"toggle-raw-btn",onClick:()=>t(!e),title:e?"Show formatted":"Show raw output","aria-label":e?"Show formatted":"Show raw output","data-testid":"toggle-raw-button",children:e?"📝":"🔍"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:195,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:188,columnNumber:7},globalThis),i.jsxDEV("div",{className:"message-content",children:a()},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:207,columnNumber:7},globalThis),((d=s.metadata)==null?void 0:d.skillUsed)&&i.jsxDEV("div",{className:"message-metadata",children:i.jsxDEV("span",{className:"skill-badge",children:["Skill: ",s.metadata.skillUsed]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:211,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:210,columnNumber:9},globalThis),((f=s.metadata)==null?void 0:f.taskCreated)&&i.jsxDEV("div",{className:"message-metadata",children:i.jsxDEV("span",{className:"task-badge",children:["Task created: ",s.metadata.taskCreated]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:217,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:216,columnNumber:9},globalThis),s.status==="error"&&i.jsxDEV("div",{className:"message-error",role:"alert",children:"Failed to deliver"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:224,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatMessage.tsx",lineNumber:187,columnNumber:5},globalThis)};const dfe=({disabled:s=!1,disabledPlaceholder:e,placeholder:t})=>{const{sendMessage:r,isSending:n,error:o,clearError:a}=KF(),[c,u]=F.useState(""),d=F.useRef(null);F.useEffect(()=>{const N=d.current;N&&(N.style.height="auto",N.style.height=`${Math.min(N.scrollHeight,200)}px`)},[c]);const f=s||n,m=async()=>{if(!c.trim()||f)return;const N=c.trim();u(""),a(),d.current&&(d.current.style.height="auto"),await r(N)},g=N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),m())},v=N=>{u(N.target.value),o&&a()};return i.jsxDEV("div",{className:"chat-input-container","data-testid":"chat-input-container",children:[o&&i.jsxDEV("div",{className:"input-error",role:"alert","data-testid":"chat-input-error",children:[i.jsxDEV("span",{children:["Error: ",o]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:109,columnNumber:11},globalThis),i.jsxDEV("button",{className:"dismiss-error",onClick:a,"aria-label":"Dismiss error",children:"×"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:110,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:108,columnNumber:9},globalThis),i.jsxDEV("div",{className:"input-wrapper",children:[i.jsxDEV("textarea",{ref:d,value:c,onChange:v,onKeyDown:g,placeholder:s&&e?e:t??"Type a message... (Enter to send, Shift+Enter for new line)",disabled:f,rows:1,className:`message-input ${s?"disabled-offline":""}`,"data-testid":"chat-message-input","aria-label":"Message input"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:121,columnNumber:9},globalThis),i.jsxDEV("button",{onClick:m,disabled:!c.trim()||f,className:"send-button",title:s?"Orchestrator offline":"Send message","data-testid":"chat-send-button","aria-label":n?"Sending message":s?"Orchestrator offline":"Send message",children:n?i.jsxDEV("span",{className:"sending-indicator","aria-hidden":"true",children:"⏳"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:147,columnNumber:13},globalThis):i.jsxDEV("span",{className:"send-icon","aria-hidden":"true",children:"➤"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:151,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:138,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:120,columnNumber:7},globalThis),i.jsxDEV("div",{className:"input-hints",children:[i.jsxDEV("span",{children:["Press ",i.jsxDEV("kbd",{children:"Enter"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:160,columnNumber:17},globalThis)," to send"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:159,columnNumber:9},globalThis),i.jsxDEV("span",{children:[i.jsxDEV("kbd",{children:"Shift"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:163,columnNumber:11},globalThis)," + ",i.jsxDEV("kbd",{children:"Enter"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:163,columnNumber:30},globalThis)," for new line"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:162,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:158,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ChatInput.tsx",lineNumber:106,columnNumber:5},globalThis)};const hfe=()=>i.jsxDEV("div",{className:"typing-indicator","data-testid":"typing-indicator",children:[i.jsxDEV("span",{className:"sender-icon","aria-hidden":"true",children:"🤖"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/TypingIndicator.tsx",lineNumber:26,columnNumber:7},globalThis),i.jsxDEV("span",{className:"sender-name",children:"Orchestrator"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/TypingIndicator.tsx",lineNumber:29,columnNumber:7},globalThis),i.jsxDEV("div",{className:"typing-dots","aria-label":"Orchestrator is typing",children:[i.jsxDEV("span",{className:"dot"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/TypingIndicator.tsx",lineNumber:31,columnNumber:9},globalThis),i.jsxDEV("span",{className:"dot"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/TypingIndicator.tsx",lineNumber:32,columnNumber:9},globalThis),i.jsxDEV("span",{className:"dot"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/TypingIndicator.tsx",lineNumber:33,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/TypingIndicator.tsx",lineNumber:30,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/TypingIndicator.tsx",lineNumber:25,columnNumber:5},globalThis);const ffe=60;function mfe(s,e){return s.length<=e?s:s.slice(0,e)+"..."}function pfe(s){const e=Date.now()-new Date(s).getTime(),t=Math.floor(e/1e3);if(t<60)return"just now";const r=Math.floor(t/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ago`}const yfe=()=>{const[s,e]=F.useState(null),[t,r]=F.useState([]),[n,o]=F.useState(!1),[a,c]=F.useState(new Set);F.useEffect(()=>{let U=!1;async function V(){try{const[M,R]=await Promise.all([es.getQueueStatus(),es.getPendingMessages()]);U||(e(M),r(R))}catch{}}return V(),()=>{U=!0}},[]);const u=F.useCallback(U=>{e(U)},[]),d=F.useCallback(U=>{r(V=>V.some(M=>M.id===U.id)?V:[...V,U])},[]),f=F.useCallback(U=>{r(V=>V.map(M=>M.id===U.id?{...M,status:"processing",processingStartedAt:U.processingStartedAt}:M))},[]),m=F.useCallback(U=>{r(V=>V.filter(M=>M.id!==U.id))},[]),g=F.useCallback(U=>{r(V=>V.filter(M=>M.id!==U.id))},[]),v=F.useCallback(U=>{r(V=>V.filter(M=>M.id!==U.id)),c(V=>{const M=new Set(V);return M.delete(U.id),M})},[]);F.useEffect(()=>(tr.on("queue:status_update",u),tr.on("queue:message_enqueued",d),tr.on("queue:message_processing",f),tr.on("queue:message_completed",m),tr.on("queue:message_failed",g),tr.on("queue:message_cancelled",v),()=>{tr.off("queue:status_update",u),tr.off("queue:message_enqueued",d),tr.off("queue:message_processing",f),tr.off("queue:message_completed",m),tr.off("queue:message_failed",g),tr.off("queue:message_cancelled",v)}),[u,d,f,m,g,v]);const N=async U=>{c(V=>new Set(V).add(U));try{await es.cancelQueueMessage(U)}catch{c(V=>{const M=new Set(V);return M.delete(U),M})}},[j,b]=F.useState(!1),x=async()=>{b(!0);try{await es.clearQueue(),r([]),e(null)}catch{}finally{b(!1)}},D=(s==null?void 0:s.pendingCount)??t.filter(U=>U.status==="pending").length,T=(s==null?void 0:s.isProcessing)??t.some(U=>U.status==="processing");if(D===0&&!T&&t.length===0)return null;const E=[];D>0&&E.push(`${D} queued`),T&&E.push("1 processing");const k=E.join(" · ");return i.jsxDEV("div",{className:"queue-status-bar","data-testid":"queue-status-bar",children:[i.jsxDEV("div",{className:"queue-status-summary",onClick:()=>o(!n),"data-testid":"queue-status-summary",role:"button",tabIndex:0,onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),o(!n))},children:[T&&i.jsxDEV("div",{className:"queue-spinner","data-testid":"queue-spinner"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:248,columnNumber:26},globalThis),i.jsxDEV("span",{className:"queue-status-text",children:k},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:249,columnNumber:9},globalThis),i.jsxDEV("button",{className:"queue-clear-all-btn",onClick:U=>{U.stopPropagation(),x()},disabled:j,"data-testid":"queue-clear-all-btn",title:"Clear all queued messages",children:j?"Clearing...":"Clear All"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:250,columnNumber:9},globalThis),i.jsxDEV("button",{className:`queue-toggle-btn${n?" expanded":""}`,"aria-label":n?"Collapse queue":"Expand queue",tabIndex:-1,children:"▼"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:262,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:235,columnNumber:7},globalThis),i.jsxDEV("div",{className:`queue-message-list${n?" expanded":""}`,"data-testid":"queue-message-list",children:t.map(U=>i.jsxDEV("div",{className:`queue-message-item${U.status==="processing"?" processing":""}`,"data-testid":"queue-message-item",children:[i.jsxDEV("div",{className:"queue-item-status",children:U.status==="processing"?i.jsxDEV("div",{className:"queue-spinner"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:283,columnNumber:17},globalThis):i.jsxDEV("span",{"aria-label":"pending",children:"🕑"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:285,columnNumber:17},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:281,columnNumber:13},globalThis),i.jsxDEV("div",{className:"queue-item-content",children:[i.jsxDEV("p",{className:"queue-item-preview",children:mfe(U.content,ffe)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:290,columnNumber:15},globalThis),i.jsxDEV("div",{className:"queue-item-meta",children:[i.jsxDEV("span",{className:"queue-source-badge",children:U.source==="slack"?"slack":"web"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:292,columnNumber:17},globalThis),i.jsxDEV("span",{className:"queue-item-time",children:pfe(U.enqueuedAt)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:293,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:291,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:289,columnNumber:13},globalThis),i.jsxDEV("button",{className:"queue-cancel-btn",onClick:()=>U.status==="processing"?x():N(U.id),disabled:a.has(U.id)||j,"data-testid":"queue-cancel-btn",children:a.has(U.id)||j?"Cancelling...":"Cancel"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:297,columnNumber:13},globalThis)]},U.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:276,columnNumber:11},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:271,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/QueueStatusBar.tsx",lineNumber:234,columnNumber:5},globalThis)};const gfe=[/^[\s⏺❯▸▶►›»─━┄┅┈┉╌╍═│┃┆┇┊┋╎╏║┌┐└┘├┤┬┴┼╔╗╚╝╠╣╦╩╬╭╮╰╯\s]*$/,/bypass permissions on/i,/shift\+tab to cycle/i,/esc to interrupt/i,/^\s*▸▸\s/];function bfe(s){const e=s.trim();return e?gfe.some(t=>t.test(e)):!0}function vfe(s){return s.filter(e=>!(e.from.type!=="user"&&e.from.type!=="orchestrator"||bfe(e.content)))}const wfe=({conversation:s,onBack:e})=>{const{messages:t,isLoading:r,error:n,isTyping:o,hasMoreMessages:a,isLoadingMore:c,loadOlderMessages:u}=KF(),d=vfe(t),{status:f,isLoading:m}=x9(),g=F.useRef(null),v=F.useRef(null),[N,j]=F.useState(!1),b=F.useCallback(()=>{requestAnimationFrame(()=>{var E;(E=v.current)==null||E.scrollIntoView({behavior:"auto"})})},[]);F.useEffect(()=>{b()},[d,o,b]);const x=F.useCallback(()=>{const E=g.current;if(!E)return;const k=E.scrollHeight-E.scrollTop-E.clientHeight;if(j(k>100),E.scrollTop<50&&a&&!c){const U=E.scrollHeight;u().then(()=>{requestAnimationFrame(()=>{const V=E.scrollHeight;E.scrollTop=V-U})})}},[a,c,u]),D=!m&&f&&!f.isActive,T=(s==null?void 0:s.channelType)??"crewly_chat";return s?r&&d.length===0?i.jsxDEV("div",{className:"thread-detail-panel loading","data-testid":"thread-detail-loading",children:i.jsxDEV("div",{className:"loading-spinner",children:[i.jsxDEV("div",{className:"spinner"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:169,columnNumber:11},globalThis),i.jsxDEV("span",{children:"Loading messages..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:170,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:168,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:167,columnNumber:7},globalThis):n&&d.length===0?i.jsxDEV("div",{className:"thread-detail-panel error","data-testid":"thread-detail-error",children:i.jsxDEV("div",{className:"error-message",children:[i.jsxDEV("span",{className:"error-icon",children:"⚠️"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:181,columnNumber:11},globalThis),i.jsxDEV("p",{children:["Error: ",n]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:182,columnNumber:11},globalThis),i.jsxDEV("button",{onClick:()=>window.location.reload(),className:"retry-button",children:"Retry"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:183,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:180,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:179,columnNumber:7},globalThis):i.jsxDEV("div",{className:"thread-detail-panel","data-testid":"thread-detail-panel",children:[i.jsxDEV("header",{className:"thread-detail-header",children:[e&&i.jsxDEV("button",{className:"thread-detail-back",onClick:e,"aria-label":"Back to thread list","data-testid":"thread-detail-back",children:"←"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:198,columnNumber:11},globalThis),i.jsxDEV("div",{className:"thread-detail-header-info",children:[i.jsxDEV("h2",{children:s.title??"Chat with Orchestrator"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:208,columnNumber:11},globalThis),i.jsxDEV("div",{className:"thread-detail-header-meta",children:i.jsxDEV(AH,{channelType:T},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:210,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:209,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:207,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:196,columnNumber:7},globalThis),i.jsxDEV(yfe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:215,columnNumber:7},globalThis),D&&i.jsxDEV("div",{className:"orchestrator-offline-banner","data-testid":"orchestrator-offline-banner",children:[i.jsxDEV("span",{className:"offline-icon","aria-hidden":"true",children:"⚠️"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:219,columnNumber:11},globalThis),i.jsxDEV("div",{className:"offline-content",children:[i.jsxDEV("strong",{children:"Orchestrator Offline"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:221,columnNumber:13},globalThis),i.jsxDEV("p",{children:(f==null?void 0:f.offlineMessage)||(f==null?void 0:f.message)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:222,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:220,columnNumber:11},globalThis),i.jsxDEV(Cb,{to:"/",className:"dashboard-link",children:"Go to Dashboard"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:224,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:218,columnNumber:9},globalThis),i.jsxDEV("div",{className:"messages-container",ref:g,onScroll:x,"data-testid":"messages-container",children:[c&&i.jsxDEV("div",{className:"load-more-spinner","data-testid":"load-more-spinner",children:[i.jsxDEV("div",{className:"spinner spinner-sm"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:238,columnNumber:13},globalThis),i.jsxDEV("span",{children:"Loading older messages..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:239,columnNumber:13},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:237,columnNumber:11},globalThis),d.length===0?i.jsxDEV("div",{className:"empty-chat","data-testid":"empty-chat",children:i.jsxDEV("div",{className:"welcome-message",children:[i.jsxDEV("h3",{children:"Welcome to Crewly"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:246,columnNumber:15},globalThis),i.jsxDEV("p",{children:"Start a conversation with the Orchestrator."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:247,columnNumber:15},globalThis),i.jsxDEV("p",{children:"Try asking to:"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:248,columnNumber:15},globalThis),i.jsxDEV("ul",{children:[i.jsxDEV("li",{children:"Create a new project"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:250,columnNumber:17},globalThis),i.jsxDEV("li",{children:"Assign a task to an agent"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:251,columnNumber:17},globalThis),i.jsxDEV("li",{children:"Check project status"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:252,columnNumber:17},globalThis),i.jsxDEV("li",{children:"Configure a team"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:253,columnNumber:17},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:249,columnNumber:15},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:245,columnNumber:13},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:244,columnNumber:11},globalThis):i.jsxDEV(i.Fragment,{children:d.map(E=>i.jsxDEV(ufe,{message:E},E.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:260,columnNumber:15},globalThis))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:258,columnNumber:11},globalThis),o&&i.jsxDEV(hfe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:265,columnNumber:22},globalThis),i.jsxDEV("div",{ref:v,className:"messages-end"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:267,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:230,columnNumber:7},globalThis),N&&i.jsxDEV("button",{className:"scroll-to-bottom-btn",onClick:b,"aria-label":"Scroll to bottom","data-testid":"scroll-to-bottom",children:"↓"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:271,columnNumber:9},globalThis),i.jsxDEV(dfe,{disabled:D,disabledPlaceholder:"Orchestrator is offline. Start it from the Dashboard to chat.",placeholder:"Reply in thread..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:281,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:195,columnNumber:5},globalThis):i.jsxDEV("div",{className:"thread-detail-panel empty","data-testid":"thread-detail-empty",children:i.jsxDEV("div",{className:"thread-detail-empty-state",children:[i.jsxDEV("h3",{children:"Select a thread"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:157,columnNumber:11},globalThis),i.jsxDEV("p",{children:"Choose a conversation from the list to view messages."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:158,columnNumber:11},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:156,columnNumber:9},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Chat/ThreadDetailPanel.tsx",lineNumber:155,columnNumber:7},globalThis)};const xfe=()=>{const{conversations:s,currentConversation:e,selectConversation:t,channelFilter:r,setChannelFilter:n}=KF(),[o,a]=F.useState("list"),c=F.useCallback(async d=>{await t(d),a("detail")},[t]),u=F.useCallback(()=>{a("list")},[]);return i.jsxDEV("div",{className:"chat-page thread-layout",children:[i.jsxDEV("header",{className:"chat-page-header",children:[i.jsxDEV("h1",{children:"Chat with Orchestrator"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Chat.tsx",lineNumber:56,columnNumber:9},globalThis),i.jsxDEV("p",{children:"Communicate with the Crewly orchestrator to manage projects and teams"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Chat.tsx",lineNumber:57,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Chat.tsx",lineNumber:55,columnNumber:7},globalThis),i.jsxDEV("div",{className:"chat-page-content",children:[i.jsxDEV("aside",{className:`chat-page-sidebar ${o==="list"?"mobile-visible":"mobile-hidden"}`,children:i.jsxDEV(ofe,{conversations:s,selectedConversationId:(e==null?void 0:e.id)??null,onSelectThread:c,channelFilter:r,onChannelFilterChange:n},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Chat.tsx",lineNumber:64,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Chat.tsx",lineNumber:61,columnNumber:9},globalThis),i.jsxDEV("main",{className:`chat-page-main ${o==="detail"?"mobile-visible":"mobile-hidden"}`,children:i.jsxDEV(wfe,{conversation:e,onBack:u},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Chat.tsx",lineNumber:76,columnNumber:11},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Chat.tsx",lineNumber:73,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Chat.tsx",lineNumber:60,columnNumber:7},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Chat.tsx",lineNumber:54,columnNumber:5},globalThis)},zb="/api/marketplace";async function Nfe(s){const e=new URLSearchParams;s!=null&&s.type&&e.set("type",s.type),s!=null&&s.search&&e.set("search",s.search),s!=null&&s.sort&&e.set("sort",s.sort);const t=e.toString(),r=`${zb}${t?`?${t}`:""}`;return(await ir.get(r)).data.data}async function Dfe(s){return(await ir.post(`${zb}/${s}/install`)).data}async function Tfe(s){return(await ir.post(`${zb}/${s}/uninstall`)).data}async function jfe(s){return(await ir.post(`${zb}/${s}/update`)).data}async function _B(){await ir.post(`${zb}/refresh`)}async function Sfe(s){const e=s?`?status=${s}`:"";return(await ir.get(`${zb}/submissions${e}`)).data.data}async function Efe(s,e,t){return(await ir.post(`${zb}/submissions/${s}/review`,{action:e,notes:t})).data}const _fe=4e3;function kfe(){const[s,e]=F.useState([]),t=F.useRef(0),r=F.useCallback((o,a="info")=>{const c=`toast-${++t.current}`,u={id:c,message:o,type:a};e(d=>[...d,u]),setTimeout(()=>{e(d=>d.filter(f=>f.id!==c))},_fe)},[]),n=F.useCallback(o=>{e(a=>a.filter(c=>c.id!==o))},[]);return{toasts:s,addToast:r,dismissToast:n}}const Cfe={success:"border-green-500 bg-green-500/10 text-green-300",error:"border-red-500 bg-red-500/10 text-red-300",info:"border-blue-500 bg-blue-500/10 text-blue-300"};function Afe({toasts:s,onDismiss:e}){return s.length===0?null:i.jsxDEV("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-sm",role:"log","aria-live":"polite",children:s.map(t=>i.jsxDEV("div",{"data-testid":`toast-${t.type}`,className:`flex items-center gap-3 px-4 py-3 rounded-lg border text-sm shadow-lg backdrop-blur-sm ${Cfe[t.type]}`,children:[i.jsxDEV("span",{className:"flex-1",children:t.message},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Toast.tsx",lineNumber:50,columnNumber:11},this),i.jsxDEV("button",{onClick:()=>e(t.id),className:"text-gray-400 hover:text-white transition-colors shrink-0","aria-label":"Dismiss notification",children:i.jsxDEV(ho,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Toast.tsx",lineNumber:56,columnNumber:13},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Toast.tsx",lineNumber:51,columnNumber:11},this)]},t.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Toast.tsx",lineNumber:45,columnNumber:9},this))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Toast.tsx",lineNumber:43,columnNumber:5},this)}const Mfe=[{label:"All",value:"all"},{label:"Skills",value:"skill"},{label:"3D Models",value:"model"},{label:"Roles",value:"role"},{label:"MCP Tools",value:"mcp_tool"}],Ufe=[{label:"Popular",value:"popular"},{label:"Highest Rated",value:"rating"},{label:"Newest",value:"newest"}];function Rfe(s){return s>=1e3?`${(s/1e3).toFixed(1)}k`:String(s)}const Vfe={skill:"bg-blue-500/20 text-blue-400",model:"bg-purple-500/20 text-purple-400",role:"bg-emerald-500/20 text-emerald-400",mcp_tool:"bg-orange-500/20 text-orange-400"};function Ffe(){const[s,e]=F.useState("browse"),[t,r]=F.useState([]),[n,o]=F.useState([]),[a,c]=F.useState(!0),[u,d]=F.useState("all"),[f,m]=F.useState(""),[g,v]=F.useState("popular"),[N,j]=F.useState(null),[b,x]=F.useState(null),{toasts:D,addToast:T,dismissToast:E}=kfe(),k=F.useCallback(async()=>{try{c(!0),x(null);const O=await Nfe({type:u==="all"?void 0:u,search:f||void 0,sort:g});r(O)}catch{x("Failed to load marketplace items")}finally{c(!1)}},[u,f,g]);F.useEffect(()=>{k()},[k]);const U=async O=>{j(O);try{const H=await Dfe(O);T(H.message||`Installed ${O}`,H.success?"success":"error"),await k()}catch(H){const J=H instanceof Error?H.message:"Install failed";T(J,"error")}j(null)},V=async O=>{j(O);try{const H=await Tfe(O);T(H.message||`Uninstalled ${O}`,H.success?"success":"error"),await k()}catch(H){const J=H instanceof Error?H.message:"Uninstall failed";T(J,"error")}j(null)},M=async O=>{j(O);try{const H=await jfe(O);T(H.message||`Updated ${O}`,H.success?"success":"error"),await k()}catch(H){const J=H instanceof Error?H.message:"Update failed";T(J,"error")}j(null)},R=async()=>{try{await _B(),T("Registry refreshed","success"),await k()}catch{T("Failed to refresh registry","error")}},P=F.useCallback(async()=>{try{c(!0),x(null);const O=await Sfe();o(O)}catch{x("Failed to load submissions")}finally{c(!1)}},[]);F.useEffect(()=>{s==="submissions"&&P()},[s,P]);const B=async(O,H)=>{j(O);try{const J=await Efe(O,H);T(J.message||`${H==="approve"?"Approved":"Rejected"}`,J.success?"success":"error"),await P(),H==="approve"&&await _B()}catch(J){const ie=J instanceof Error?J.message:"Review failed";T(ie,"error")}j(null)};return i.jsxDEV("div",{className:"p-6 max-w-7xl mx-auto",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV(u4,{className:"w-6 h-6 text-indigo-400"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:225,columnNumber:11},this),i.jsxDEV("h1",{className:"text-2xl font-bold text-white",children:"Marketplace"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:226,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:224,columnNumber:9},this),i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("div",{className:"flex gap-1 bg-gray-900 rounded-lg p-1",role:"tablist","aria-label":"View mode",children:[i.jsxDEV("button",{onClick:()=>e("browse"),role:"tab","aria-selected":s==="browse",className:`flex items-center gap-1 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${s==="browse"?"bg-gray-800 text-white":"text-gray-400 hover:text-white"}`,children:[i.jsxDEV(tP,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:238,columnNumber:15},this),"Browse"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:230,columnNumber:13},this),i.jsxDEV("button",{onClick:()=>e("submissions"),role:"tab","aria-selected":s==="submissions",className:`flex items-center gap-1 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${s==="submissions"?"bg-gray-800 text-white":"text-gray-400 hover:text-white"}`,children:[i.jsxDEV(IK,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:249,columnNumber:15},this),"Submissions"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:241,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:229,columnNumber:11},this),i.jsxDEV("button",{onClick:R,className:"flex items-center gap-2 px-3 py-1.5 text-sm bg-gray-800 hover:bg-gray-700 text-gray-300 rounded-lg transition-colors","aria-label":"Refresh marketplace",children:[i.jsxDEV(dc,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:258,columnNumber:13},this),"Refresh"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:253,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:228,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:223,columnNumber:7},this),s==="browse"&&i.jsxDEV(i.Fragment,{children:[i.jsxDEV("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-6",children:[i.jsxDEV("div",{className:"flex gap-1 bg-gray-900 rounded-lg p-1",role:"tablist","aria-label":"Filter by type",children:Mfe.map(O=>i.jsxDEV("button",{onClick:()=>d(O.value),role:"tab","aria-selected":u===O.value,className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${u===O.value?"bg-gray-800 text-white":"text-gray-400 hover:text-white"}`,children:O.label},O.value,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:270,columnNumber:17},this))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:268,columnNumber:13},this),i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("div",{className:"relative",children:[i.jsxDEV(hV,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:286,columnNumber:17},this),i.jsxDEV("input",{type:"text",placeholder:"Search...",value:f,onChange:O=>m(O.target.value),"aria-label":"Search marketplace",className:"bg-gray-900 border border-gray-700 rounded-lg pl-9 pr-3 py-1.5 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-indigo-500 w-48"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:287,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:285,columnNumber:15},this),i.jsxDEV("select",{value:g,onChange:O=>v(O.target.value),"aria-label":"Sort by",className:"bg-gray-900 border border-gray-700 rounded-lg px-3 py-1.5 text-sm text-gray-200 focus:outline-none focus:border-indigo-500",children:Ufe.map(O=>i.jsxDEV("option",{value:O.value,children:O.label},O.value,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:303,columnNumber:19},this))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:296,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:284,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:267,columnNumber:11},this),a?i.jsxDEV("div",{className:"text-center py-16 text-gray-400",role:"status",children:"Loading marketplace..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:311,columnNumber:13},this):b?i.jsxDEV("div",{className:"text-center py-16 text-red-400",role:"alert",children:b},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:313,columnNumber:13},this):t.length===0?i.jsxDEV("div",{className:"text-center py-16 text-gray-400",children:"No items found."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:315,columnNumber:13},this):i.jsxDEV("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:t.map(O=>i.jsxDEV("div",{className:"bg-gray-900 border border-gray-800 rounded-xl p-5 hover:border-gray-700 transition-colors","data-testid":`marketplace-item-${O.id}`,children:[i.jsxDEV("div",{className:"flex items-start justify-between mb-3",children:[i.jsxDEV("div",{className:"flex items-center gap-2",children:[i.jsxDEV("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${Vfe[O.type]}`,children:O.type},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:327,columnNumber:23},this),i.jsxDEV("span",{className:"text-xs text-gray-500",children:["v",O.version]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:330,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:326,columnNumber:21},this),O.installStatus==="installed"&&i.jsxDEV(El,{className:"w-4 h-4 text-green-400","aria-label":"Installed"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:333,columnNumber:23},this),O.installStatus==="update_available"&&i.jsxDEV(YI,{className:"w-4 h-4 text-yellow-400","aria-label":"Update available"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:336,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:325,columnNumber:19},this),i.jsxDEV("h3",{className:"text-base font-semibold text-white mb-1",children:O.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:341,columnNumber:19},this),i.jsxDEV("p",{className:"text-sm text-gray-400 mb-3 line-clamp-2",children:O.description},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:342,columnNumber:19},this),i.jsxDEV("div",{className:"flex items-center justify-between text-xs text-gray-500 mb-4",children:[i.jsxDEV("span",{children:["by ",O.author]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:346,columnNumber:21},this),i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("span",{className:"flex items-center gap-1",children:[i.jsxDEV(UK,{className:"w-3 h-3 text-yellow-500"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:349,columnNumber:25},this),O.rating.toFixed(1)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:348,columnNumber:23},this),i.jsxDEV("span",{className:"flex items-center gap-1",children:[i.jsxDEV(YB,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:353,columnNumber:25},this),Rfe(O.downloads)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:352,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:347,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:345,columnNumber:19},this),i.jsxDEV("div",{className:"flex gap-2",children:[O.installStatus==="not_installed"&&i.jsxDEV("button",{onClick:()=>U(O.id),disabled:N===O.id,className:"flex-1 flex items-center justify-center gap-1 px-3 py-1.5 text-sm bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:[i.jsxDEV(tP,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:367,columnNumber:25},this),N===O.id?"Installing...":"Install"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:362,columnNumber:23},this),O.installStatus==="installed"&&i.jsxDEV("button",{onClick:()=>V(O.id),disabled:N===O.id,className:"flex-1 px-3 py-1.5 text-sm bg-gray-800 hover:bg-red-900/50 text-gray-300 hover:text-red-300 rounded-lg disabled:opacity-50 transition-colors",children:N===O.id?"Removing...":"Uninstall"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:372,columnNumber:23},this),O.installStatus==="update_available"&&i.jsxDEV(i.Fragment,{children:[i.jsxDEV("button",{onClick:()=>M(O.id),disabled:N===O.id,className:"flex-1 flex items-center justify-center gap-1 px-3 py-1.5 text-sm bg-yellow-600 hover:bg-yellow-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:[i.jsxDEV(YI,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:387,columnNumber:27},this),N===O.id?"Updating...":"Update"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:382,columnNumber:25},this),i.jsxDEV("button",{onClick:()=>V(O.id),disabled:N===O.id,className:"px-3 py-1.5 text-sm bg-gray-800 hover:bg-red-900/50 text-gray-300 hover:text-red-300 rounded-lg disabled:opacity-50 transition-colors",children:"Remove"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:390,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:381,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:360,columnNumber:19},this)]},O.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:319,columnNumber:17},this))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:317,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:265,columnNumber:9},this),s==="submissions"&&i.jsxDEV(i.Fragment,{children:[i.jsxDEV("div",{className:"mb-6",children:i.jsxDEV("p",{className:"text-sm text-gray-400",children:["Submit skills via CLI: ",i.jsxDEV("code",{className:"bg-gray-800 px-2 py-0.5 rounded text-xs text-gray-300",children:"crewly publish path/to/skill --submit"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:412,columnNumber:38},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:411,columnNumber:13},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:410,columnNumber:11},this),a?i.jsxDEV("div",{className:"text-center py-16 text-gray-400",role:"status",children:"Loading submissions..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:418,columnNumber:13},this):b?i.jsxDEV("div",{className:"text-center py-16 text-red-400",role:"alert",children:b},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:420,columnNumber:13},this):n.length===0?i.jsxDEV("div",{className:"text-center py-16 text-gray-400",children:"No submissions yet."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:422,columnNumber:13},this):i.jsxDEV("div",{className:"space-y-3",children:n.map(O=>i.jsxDEV("div",{className:"bg-gray-900 border border-gray-800 rounded-xl p-5 hover:border-gray-700 transition-colors","data-testid":`submission-${O.id}`,children:i.jsxDEV("div",{className:"flex items-start justify-between",children:[i.jsxDEV("div",{className:"flex-1",children:[i.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[i.jsxDEV("h3",{className:"text-base font-semibold text-white",children:O.name},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:434,columnNumber:25},this),i.jsxDEV("span",{className:"text-xs text-gray-500",children:["v",O.version]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:435,columnNumber:25},this),i.jsxDEV("span",{className:`flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${O.status==="pending"?"bg-yellow-500/20 text-yellow-400":O.status==="approved"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[O.status==="pending"&&i.jsxDEV(qc,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:441,columnNumber:56},this),O.status==="approved"&&i.jsxDEV(Zc,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:442,columnNumber:57},this),O.status==="rejected"&&i.jsxDEV(Ak,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:443,columnNumber:57},this),O.status]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:436,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:433,columnNumber:23},this),i.jsxDEV("p",{className:"text-sm text-gray-400 mb-2",children:O.description},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:447,columnNumber:23},this),i.jsxDEV("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[i.jsxDEV("span",{children:["by ",O.author]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:449,columnNumber:25},this),i.jsxDEV("span",{children:O.category},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:450,columnNumber:25},this),i.jsxDEV("span",{children:new Date(O.submittedAt).toLocaleDateString()},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:451,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:448,columnNumber:23},this),O.reviewNotes&&i.jsxDEV("p",{className:"mt-2 text-xs text-gray-400 italic",children:["Review: ",O.reviewNotes]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:454,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:432,columnNumber:21},this),O.status==="pending"&&i.jsxDEV("div",{className:"flex gap-2 ml-4",children:[i.jsxDEV("button",{onClick:()=>B(O.id,"approve"),disabled:N===O.id,className:"flex items-center gap-1 px-3 py-1.5 text-sm bg-green-600 hover:bg-green-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:[i.jsxDEV(Zc,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:464,columnNumber:27},this),N===O.id?"...":"Approve"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:459,columnNumber:25},this),i.jsxDEV("button",{onClick:()=>B(O.id,"reject"),disabled:N===O.id,className:"px-3 py-1.5 text-sm bg-gray-800 hover:bg-red-900/50 text-gray-300 hover:text-red-300 rounded-lg disabled:opacity-50 transition-colors",children:"Reject"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:467,columnNumber:25},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:458,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:431,columnNumber:19},this)},O.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:426,columnNumber:17},this))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:424,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:408,columnNumber:9},this),i.jsxDEV(Afe,{toasts:D,onDismiss:E},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:484,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Marketplace.tsx",lineNumber:221,columnNumber:5},this)}function Ife({scope:s,onScopeChange:e,projects:t,selectedProjectPath:r,onProjectChange:n}){return i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV("div",{className:"flex gap-1 bg-gray-900 rounded-lg p-1",role:"tablist","aria-label":"Document scope",children:[i.jsxDEV("button",{role:"tab","aria-selected":s==="global",onClick:()=>e("global"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${s==="global"?"bg-gray-800 text-white":"text-gray-400 hover:text-white"}`,children:[i.jsxDEV(QB,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeScopeToggle.tsx",lineNumber:50,columnNumber:11},this),"Global"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeScopeToggle.tsx",lineNumber:42,columnNumber:9},this),i.jsxDEV("button",{role:"tab","aria-selected":s==="project",onClick:()=>e("project"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${s==="project"?"bg-gray-800 text-white":"text-gray-400 hover:text-white"}`,children:[i.jsxDEV(rl,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeScopeToggle.tsx",lineNumber:61,columnNumber:11},this),"Project"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeScopeToggle.tsx",lineNumber:53,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeScopeToggle.tsx",lineNumber:41,columnNumber:7},this),s==="project"&&i.jsxDEV("select",{value:r||"",onChange:o=>n(o.target.value),"aria-label":"Select project",className:"bg-gray-900 border border-gray-700 rounded-lg px-3 py-1.5 text-sm text-gray-200 focus:outline-none focus:border-indigo-500",children:[i.jsxDEV("option",{value:"",disabled:!0,children:"Select a project..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeScopeToggle.tsx",lineNumber:73,columnNumber:11},this),t.map(o=>i.jsxDEV("option",{value:o.path,children:o.name},o.id,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeScopeToggle.tsx",lineNumber:75,columnNumber:13},this))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeScopeToggle.tsx",lineNumber:67,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeScopeToggle.tsx",lineNumber:40,columnNumber:5},this)}function Pfe({categories:s,selectedCategory:e,onCategoryChange:t}){return i.jsxDEV("div",{className:"space-y-1",role:"listbox","aria-label":"Filter by category",children:[i.jsxDEV("button",{role:"option","aria-selected":e==="",onClick:()=>t(""),className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${e===""?"bg-indigo-600/20 text-indigo-400 font-medium":"text-gray-400 hover:bg-gray-800 hover:text-gray-200"}`,children:"All"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeCategoryFilter.tsx",lineNumber:32,columnNumber:7},this),s.map(r=>i.jsxDEV("button",{role:"option","aria-selected":e===r,onClick:()=>t(r),className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${e===r?"bg-indigo-600/20 text-indigo-400 font-medium":"text-gray-400 hover:bg-gray-800 hover:text-gray-200"}`,children:r},r,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeCategoryFilter.tsx",lineNumber:45,columnNumber:9},this))]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeCategoryFilter.tsx",lineNumber:31,columnNumber:5},this)}function Lfe(s){try{return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return s}}function Ofe({documents:s,loading:e,searchQuery:t,onSearchChange:r,selectedDocId:n,onSelectDocument:o}){return i.jsxDEV("div",{className:"flex flex-col h-full",children:[i.jsxDEV("div",{className:"relative mb-4",children:[i.jsxDEV(hV,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:64,columnNumber:9},this),i.jsxDEV("input",{type:"text",placeholder:"Search documents...",value:t,onChange:a=>r(a.target.value),"aria-label":"Search documents",className:"w-full bg-gray-900 border border-gray-700 rounded-lg pl-9 pr-3 py-2 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-indigo-500"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:65,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:63,columnNumber:7},this),e?i.jsxDEV("div",{className:"text-center py-8 text-gray-400",role:"status",children:"Loading documents..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:77,columnNumber:9},this):s.length===0?i.jsxDEV("div",{className:"text-center py-8 text-gray-500",children:[i.jsxDEV(Iw,{className:"w-8 h-8 mx-auto mb-2 opacity-50"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:80,columnNumber:11},this),i.jsxDEV("p",{children:"No documents found"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:81,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:79,columnNumber:9},this):i.jsxDEV("div",{className:"space-y-1 overflow-y-auto flex-1",children:s.map(a=>i.jsxDEV("button",{onClick:()=>o(a.id),className:`w-full text-left px-3 py-3 rounded-lg transition-colors ${n===a.id?"bg-indigo-600/20 border border-indigo-500/30":"hover:bg-gray-800 border border-transparent"}`,children:[i.jsxDEV("div",{className:"flex items-start justify-between gap-2",children:[i.jsxDEV("div",{className:"min-w-0 flex-1",children:[i.jsxDEV("h4",{className:"text-sm font-medium text-gray-200 truncate",children:a.title},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:97,columnNumber:19},this),i.jsxDEV("p",{className:"text-xs text-gray-500 mt-0.5 line-clamp-1",children:a.preview},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:98,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:96,columnNumber:17},this),i.jsxDEV("div",{className:"flex flex-col items-end flex-shrink-0",children:[i.jsxDEV("span",{className:"text-xs px-1.5 py-0.5 rounded bg-gray-800 text-gray-400",children:a.category},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:101,columnNumber:19},this),i.jsxDEV("span",{className:"text-xs text-gray-600 mt-1",children:Lfe(a.updatedAt)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:104,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:100,columnNumber:17},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:95,columnNumber:15},this),a.tags.length>0&&i.jsxDEV("div",{className:"flex gap-1 mt-1.5 flex-wrap",children:[a.tags.slice(0,3).map(c=>i.jsxDEV("span",{className:"text-xs px-1.5 py-0.5 rounded bg-gray-900 text-gray-500",children:c},c,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:110,columnNumber:21},this)),a.tags.length>3&&i.jsxDEV("span",{className:"text-xs text-gray-600",children:["+",a.tags.length-3]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:115,columnNumber:21},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:108,columnNumber:17},this)]},a.id,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:86,columnNumber:13},this))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:84,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentList.tsx",lineNumber:61,columnNumber:5},this)}function Bfe(s){try{return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return s}}function Hfe({document:s,onEdit:e,onDelete:t}){return i.jsxDEV("div",{className:"h-full overflow-y-auto",children:[i.jsxDEV("div",{className:"flex items-start justify-between mb-4",children:[i.jsxDEV("div",{className:"flex-1 min-w-0",children:[i.jsxDEV("h2",{className:"text-xl font-bold text-white mb-2",children:s.title},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:58,columnNumber:11},this),i.jsxDEV("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[i.jsxDEV("span",{className:"px-2 py-0.5 rounded bg-gray-800 text-gray-300",children:s.category},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:60,columnNumber:13},this),i.jsxDEV("span",{className:"flex items-center gap-1",children:[i.jsxDEV(mx,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:62,columnNumber:15},this),s.createdBy]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:61,columnNumber:13},this),i.jsxDEV("span",{className:"flex items-center gap-1",children:[i.jsxDEV(qc,{className:"w-3 h-3"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:66,columnNumber:15},this),Bfe(s.updatedAt)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:65,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:59,columnNumber:11},this),s.tags.length>0&&i.jsxDEV("div",{className:"flex gap-1.5 mt-2 flex-wrap",children:s.tags.map(r=>i.jsxDEV("span",{className:"text-xs px-2 py-0.5 rounded-full bg-indigo-500/10 text-indigo-400",children:r},r,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:73,columnNumber:17},this))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:71,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:57,columnNumber:9},this),i.jsxDEV("div",{className:"flex gap-2 ml-4",children:[i.jsxDEV("button",{onClick:e,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-gray-800 hover:bg-gray-700 text-gray-300 rounded-lg transition-colors","aria-label":"Edit document",children:[i.jsxDEV(s4,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:86,columnNumber:13},this),"Edit"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:81,columnNumber:11},this),i.jsxDEV("button",{onClick:t,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-gray-800 hover:bg-red-900/50 text-gray-300 hover:text-red-300 rounded-lg transition-colors","aria-label":"Delete document",children:[i.jsxDEV(ZT,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:94,columnNumber:13},this),"Delete"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:89,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:80,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:56,columnNumber:7},this),i.jsxDEV("div",{className:"border-t border-gray-800 pt-4",children:i.jsxDEV("div",{className:"prose prose-invert prose-sm max-w-none whitespace-pre-wrap text-gray-300 leading-relaxed",children:s.content},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:102,columnNumber:9},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:101,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentViewer.tsx",lineNumber:54,columnNumber:5},this)}const Gfe=["SOPs","Team Norms","Architecture","Onboarding","Runbooks","General"];function kB({document:s,categories:e,saving:t,onSave:r,onCancel:n}){const[o,a]=F.useState((s==null?void 0:s.title)||""),[c,u]=F.useState((s==null?void 0:s.content)||""),[d,f]=F.useState((s==null?void 0:s.category)||"General"),[m,g]=F.useState((s==null?void 0:s.tags.join(", "))||""),v=[...new Set([...Gfe,...e])].sort(),N=b=>{b.preventDefault();const x=m.split(",").map(D=>D.trim()).filter(Boolean);r({title:o,content:c,category:d,tags:x})},j=o.trim().length>0&&c.trim().length>0;return i.jsxDEV("form",{onSubmit:N,className:"h-full flex flex-col",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[i.jsxDEV("h2",{className:"text-lg font-bold text-white",children:s?"Edit Document":"New Document"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:64,columnNumber:9},this),i.jsxDEV("div",{className:"flex gap-2",children:[i.jsxDEV("button",{type:"button",onClick:n,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-gray-800 hover:bg-gray-700 text-gray-300 rounded-lg transition-colors",children:[i.jsxDEV(ho,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:73,columnNumber:13},this),"Cancel"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:68,columnNumber:11},this),i.jsxDEV("button",{type:"submit",disabled:!j||t,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:[i.jsxDEV(XT,{className:"w-3.5 h-3.5"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:81,columnNumber:13},this),t?"Saving...":"Save"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:76,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:67,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:63,columnNumber:7},this),i.jsxDEV("div",{className:"space-y-4 flex-1 flex flex-col",children:[i.jsxDEV("div",{children:[i.jsxDEV("label",{htmlFor:"doc-title",className:"block text-sm font-medium text-gray-300 mb-1",children:"Title"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:90,columnNumber:11},this),i.jsxDEV("input",{id:"doc-title",type:"text",value:o,onChange:b=>a(b.target.value),placeholder:"Document title",className:"w-full bg-gray-900 border border-gray-700 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-indigo-500",maxLength:200},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:91,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:89,columnNumber:9},this),i.jsxDEV("div",{className:"flex gap-4",children:[i.jsxDEV("div",{className:"flex-1",children:[i.jsxDEV("label",{htmlFor:"doc-category",className:"block text-sm font-medium text-gray-300 mb-1",children:"Category"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:105,columnNumber:13},this),i.jsxDEV("select",{id:"doc-category",value:d,onChange:b=>f(b.target.value),className:"w-full bg-gray-900 border border-gray-700 rounded-lg px-3 py-2 text-sm text-gray-200 focus:outline-none focus:border-indigo-500",children:v.map(b=>i.jsxDEV("option",{value:b,children:b},b,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:113,columnNumber:17},this))},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:106,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:104,columnNumber:11},this),i.jsxDEV("div",{className:"flex-1",children:[i.jsxDEV("label",{htmlFor:"doc-tags",className:"block text-sm font-medium text-gray-300 mb-1",children:"Tags (comma-separated)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:118,columnNumber:13},this),i.jsxDEV("input",{id:"doc-tags",type:"text",value:m,onChange:b=>g(b.target.value),placeholder:"api, backend, auth",className:"w-full bg-gray-900 border border-gray-700 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-indigo-500"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:119,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:117,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:103,columnNumber:9},this),i.jsxDEV("div",{className:"flex-1 flex flex-col",children:[i.jsxDEV("label",{htmlFor:"doc-content",className:"block text-sm font-medium text-gray-300 mb-1",children:"Content (Markdown)"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:132,columnNumber:11},this),i.jsxDEV("textarea",{id:"doc-content",value:c,onChange:b=>u(b.target.value),placeholder:"Write your document content in Markdown...",className:"flex-1 min-h-[200px] w-full bg-gray-900 border border-gray-700 rounded-lg px-3 py-2 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-indigo-500 font-mono resize-none"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:133,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:131,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:87,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/components/Knowledge/KnowledgeDocumentEditor.tsx",lineNumber:62,columnNumber:5},this)}function zfe(){const[s,e]=FC(),[t,r]=F.useState(s.get("project")?"project":"global"),[n,o]=F.useState([]),[a,c]=F.useState(""),[u,d]=F.useState([]),[f,m]=F.useState([]),[g,v]=F.useState(""),[N,j]=F.useState(""),[b,x]=F.useState(!0),[D,T]=F.useState("list"),[E,k]=F.useState(),[U,V]=F.useState(null),[M,R]=F.useState(!1),[P,B]=F.useState(null);F.useEffect(()=>{es.getProjects().then(o).catch(()=>{})},[]),F.useEffect(()=>{const Y=s.get("project");if(Y&&n.length>0){const X=n.find(z=>z.id===Y);X&&(r("project"),c(X.path))}},[s,n]);const O=F.useCallback(async()=>{try{if(x(!0),B(null),t==="project"&&!a){d([]),m([]),x(!1);return}const[Y,X]=await Promise.all([es.getKnowledgeDocuments(t,a||void 0,g||void 0,N||void 0),es.getKnowledgeCategories(t,a||void 0)]);d(Y),m(X)}catch{B("Failed to load documents")}finally{x(!1)}},[t,a,g,N]);F.useEffect(()=>{O()},[O]);const H=Y=>{r(Y),k(void 0),V(null),T("list"),Y==="global"&&(c(""),e({}))},J=Y=>{c(Y),k(void 0),V(null),T("list");const X=n.find(z=>z.path===Y);X&&e({project:X.id})},ie=async Y=>{k(Y);try{const X=await es.getKnowledgeDocument(Y,t,a||void 0);V(X),T("view")}catch{B("Failed to load document")}},te=()=>{k(void 0),V(null),T("create")},se=async Y=>{R(!0);try{if(D==="create"){const X=await es.createKnowledgeDocument({...Y,scope:t,projectPath:a||void 0});await O(),await ie(X)}else U&&(await es.updateKnowledgeDocument(U.id,{...Y,scope:t,projectPath:a||void 0}),await O(),await ie(U.id))}catch{B("Failed to save document")}finally{R(!1)}},Z=async()=>{if(U)try{await es.deleteKnowledgeDocument(U.id,t,a||void 0),V(null),k(void 0),T("list"),await O()}catch{B("Failed to delete document")}};return i.jsxDEV("div",{className:"p-6 max-w-7xl mx-auto h-full flex flex-col",children:[i.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[i.jsxDEV("div",{className:"flex items-center gap-3",children:[i.jsxDEV(JI,{className:"w-6 h-6 text-indigo-400"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:207,columnNumber:11},this),i.jsxDEV("h1",{className:"text-2xl font-bold text-white",children:"Knowledge"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:208,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:206,columnNumber:9},this),i.jsxDEV(Ife,{scope:t,onScopeChange:H,projects:n,selectedProjectPath:a,onProjectChange:J},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:210,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:205,columnNumber:7},this),P&&i.jsxDEV("div",{className:"mb-4 px-4 py-2 bg-red-900/20 border border-red-500/30 rounded-lg text-sm text-red-400",role:"alert",children:[P,i.jsxDEV("button",{onClick:()=>B(null),className:"ml-2 underline",children:"dismiss"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:222,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:220,columnNumber:9},this),i.jsxDEV("div",{className:"flex gap-6 flex-1 min-h-0",children:[i.jsxDEV("div",{className:"w-44 flex-shrink-0",children:[i.jsxDEV("div",{className:"mb-4",children:i.jsxDEV("button",{onClick:te,className:"w-full flex items-center justify-center gap-1.5 px-3 py-2 text-sm bg-indigo-600 hover:bg-indigo-500 text-white rounded-lg transition-colors",children:[i.jsxDEV($a,{className:"w-4 h-4"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:235,columnNumber:15},this),"New Document"]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:231,columnNumber:13},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:230,columnNumber:11},this),i.jsxDEV(Pfe,{categories:f,selectedCategory:g,onCategoryChange:v},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:239,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:229,columnNumber:9},this),i.jsxDEV("div",{className:"flex-1 min-w-0 flex gap-6",children:[i.jsxDEV("div",{className:`w-80 flex-shrink-0 ${D==="create"||D==="edit"?"hidden lg:block":""}`,children:i.jsxDEV(Ofe,{documents:u,loading:b,searchQuery:N,onSearchChange:j,selectedDocId:E,onSelectDocument:ie},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:250,columnNumber:13},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:249,columnNumber:11},this),i.jsxDEV("div",{className:"flex-1 min-w-0",children:[D==="view"&&U&&i.jsxDEV(Hfe,{document:U,onEdit:()=>T("edit"),onDelete:Z},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:263,columnNumber:15},this),D==="edit"&&U&&i.jsxDEV(kB,{document:U,categories:f,saving:M,onSave:se,onCancel:()=>T("view")},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:270,columnNumber:15},this),D==="create"&&i.jsxDEV(kB,{document:null,categories:f,saving:M,onSave:se,onCancel:()=>T("list")},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:279,columnNumber:15},this),D==="list"&&!b&&i.jsxDEV("div",{className:"flex items-center justify-center h-full text-gray-500",children:i.jsxDEV("div",{className:"text-center",children:[i.jsxDEV(JI,{className:"w-12 h-12 mx-auto mb-3 opacity-30"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:290,columnNumber:19},this),i.jsxDEV("p",{children:"Select a document to view"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:291,columnNumber:19},this),i.jsxDEV("p",{className:"text-sm mt-1",children:"or create a new one"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:292,columnNumber:19},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:289,columnNumber:17},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:288,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:261,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:247,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:227,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/Knowledge.tsx",lineNumber:203,columnNumber:5},this)}const Wfe=()=>{const[s]=FC(),e=gh();return F.useEffect(()=>{(async()=>{const r=s.get("token"),n=s.get("error");if(r){localStorage.setItem(Lw,r);try{await fetch("/api/cloud/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:r})})}catch{}}n?e("/settings?tab=cloud&error="+encodeURIComponent(n),{replace:!0}):e("/settings?tab=cloud",{replace:!0})})()},[s,e]),i.jsxDEV("div",{className:"min-h-screen flex items-center justify-center bg-background-dark",children:i.jsxDEV("div",{className:"text-center",children:[i.jsxDEV("div",{className:"w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin mx-auto"},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/AuthCallback.tsx",lineNumber:58,columnNumber:9},globalThis),i.jsxDEV("p",{className:"text-sm text-text-secondary-dark mt-4",children:"Completing sign-in..."},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/AuthCallback.tsx",lineNumber:59,columnNumber:9},globalThis)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/AuthCallback.tsx",lineNumber:57,columnNumber:7},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/pages/AuthCallback.tsx",lineNumber:56,columnNumber:5},globalThis)};function Kfe(){return i.jsxDEV(XZ,{children:i.jsxDEV(tq,{children:i.jsxDEV(LK,{children:i.jsxDEV(ZW,{children:i.jsxDEV(MW,{children:[i.jsxDEV(Za,{path:"/auth/callback",element:i.jsxDEV(Wfe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:29,columnNumber:51},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:29,columnNumber:13},this),i.jsxDEV(Za,{path:"/",element:i.jsxDEV(pY,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:32,columnNumber:38},this),children:[i.jsxDEV(Za,{index:!0,element:i.jsxDEV(bY,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:33,columnNumber:37},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:33,columnNumber:15},this),i.jsxDEV(Za,{path:"projects",element:i.jsxDEV(xY,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:34,columnNumber:47},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:34,columnNumber:15},this),i.jsxDEV(Za,{path:"projects/:id",element:i.jsxDEV(GY,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:35,columnNumber:51},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:35,columnNumber:15},this),i.jsxDEV(Za,{path:"teams",element:i.jsxDEV(iJ,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:36,columnNumber:44},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:36,columnNumber:15},this),i.jsxDEV(Za,{path:"teams/:id",element:i.jsxDEV(DJ,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:37,columnNumber:48},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:37,columnNumber:15},this),i.jsxDEV(Za,{path:"assignments",element:i.jsxDEV(CJ,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:38,columnNumber:50},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:38,columnNumber:15},this),i.jsxDEV(Za,{path:"scheduled-checkins",element:i.jsxDEV(FJ,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:39,columnNumber:57},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:39,columnNumber:15},this),i.jsxDEV(Za,{path:"factory",element:i.jsxDEV(yhe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:40,columnNumber:46},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:40,columnNumber:15},this),i.jsxDEV(Za,{path:"marketplace",element:i.jsxDEV(Ffe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:41,columnNumber:50},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:41,columnNumber:15},this),i.jsxDEV(Za,{path:"knowledge",element:i.jsxDEV(zfe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:42,columnNumber:48},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:42,columnNumber:15},this),i.jsxDEV(Za,{path:"settings",element:i.jsxDEV(Jhe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:43,columnNumber:47},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:43,columnNumber:15},this),i.jsxDEV(Za,{path:"chat",element:i.jsxDEV(Qhe,{children:i.jsxDEV(xfe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:48,columnNumber:21},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:47,columnNumber:19},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:44,columnNumber:15},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:32,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:27,columnNumber:11},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:26,columnNumber:9},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:25,columnNumber:7},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:24,columnNumber:5},this)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/App.tsx",lineNumber:23,columnNumber:5},this)}iR.createRoot(document.getElementById("root")).render(i.jsxDEV(fn.StrictMode,{children:i.jsxDEV(Kfe,{},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/main.tsx",lineNumber:13,columnNumber:5},globalThis)},void 0,!1,{fileName:"/Users/yellowsunhy/Desktop/projects/crewly-projects/crewly/frontend/src/main.tsx",lineNumber:12,columnNumber:3},globalThis));
5213
- //# sourceMappingURL=index-83869ca7.js.map
5213
+ //# sourceMappingURL=index-726a1859.js.map