@lovelybunch/api 1.0.76-alpha.9 → 1.0.76

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 (155) hide show
  1. package/dist/lib/git.d.ts +3 -0
  2. package/dist/lib/git.js +35 -0
  3. package/dist/routes/api/v1/ai/route.js +214 -152
  4. package/dist/routes/api/v1/config/route.js +13 -9
  5. package/dist/routes/api/v1/context/agents/route.d.ts +3 -0
  6. package/dist/routes/api/v1/context/agents/route.js +159 -0
  7. package/dist/routes/api/v1/context/index.js +6 -4
  8. package/dist/routes/api/v1/context/memory/route.d.ts +3 -0
  9. package/dist/routes/api/v1/context/memory/route.js +163 -0
  10. package/dist/routes/api/v1/context/team/route.d.ts +3 -0
  11. package/dist/routes/api/v1/context/team/route.js +159 -0
  12. package/dist/routes/api/v1/git/index.js +27 -1
  13. package/dist/routes/api/v1/jobs/[id]/route.d.ts +26 -32
  14. package/dist/routes/api/v1/jobs/[id]/route.js +3 -3
  15. package/dist/routes/api/v1/jobs/route.d.ts +33 -33
  16. package/dist/routes/api/v1/jobs/route.js +17 -2
  17. package/dist/routes/api/v1/mcp/index.js +194 -21
  18. package/dist/routes/api/v1/resources/generate/route.js +10 -3
  19. package/package.json +4 -4
  20. package/static/assets/ActivityPage-sJEQn6DK.js +1 -0
  21. package/static/assets/AgentsContextEditPage-DU3qIXk9.js +9 -0
  22. package/static/assets/AgentsContextPage-tJ-LhFYb.js +1 -0
  23. package/static/assets/{ApiKeysSettingsPage-CjrCuHHE.js → ApiKeysSettingsPage-Bg84BQHV.js} +2 -2
  24. package/static/assets/{AuthSettingsPage-elJX4TCV.js → AuthSettingsPage-Bwr7uP3z.js} +1 -1
  25. package/static/assets/{CallbackPage-CUuZYgBL.js → CallbackPage-BFn0Np2S.js} +1 -1
  26. package/static/assets/CodePage-kp4s3wCJ.js +2 -0
  27. package/static/assets/{CollapsibleSection-DfTxWX0X.js → CollapsibleSection-CNs1mvsZ.js} +1 -1
  28. package/static/assets/{DashboardPage-CmS8UPSm.js → DashboardPage-DMJSzzgD.js} +9 -19
  29. package/static/assets/{GitPage-DSfn76oO.js → GitPage-uqene8zj.js} +3 -3
  30. package/static/assets/{GitSettingsPage-Bu8h7hcr.js → GitSettingsPage-CLswbZsT.js} +2 -2
  31. package/static/assets/{IdentityPage-NFKq2FHi.js → IdentityPage-BDTPXEo7.js} +2 -2
  32. package/static/assets/{ImplementationStepsEditor-Cn-MshnR.js → ImplementationStepsEditor-D4cvhPhz.js} +2 -2
  33. package/static/assets/IntegrationsSettingsPage-o7NXZGt9.js +1 -0
  34. package/static/assets/JobDetailPage-DuEiPz6X.js +1 -0
  35. package/static/assets/KnowledgeDetailPage-DFVud_VC.js +1 -0
  36. package/static/assets/{KnowledgeEditPage-B28N-7vM.js → KnowledgeEditPage-XG6HKK7E.js} +1 -1
  37. package/static/assets/{KnowledgePage-C3zoPEcH.js → KnowledgePage-B2zI3xwW.js} +2 -2
  38. package/static/assets/{LoginPage-BYNLGEnz.js → LoginPage-CUJRxwXy.js} +1 -1
  39. package/static/assets/MailInboxPage-BlCG-tba.js +1 -0
  40. package/static/assets/MailProcessingModal-BJIdHOqK.js +1 -0
  41. package/static/assets/MailReadPage-MoNo_gmW.js +1 -0
  42. package/static/assets/{MailSentPage-ClaVWZCR.js → MailSentPage-QzpuIJmT.js} +1 -1
  43. package/static/assets/{McpSettingsPage-CfhBioEH.js → McpSettingsPage-BZcCGkGM.js} +1 -1
  44. package/static/assets/MemoryEditPage-DXSQoCT4.js +13 -0
  45. package/static/assets/MemoryPage-oBnyuvSf.js +1 -0
  46. package/static/assets/{NewKnowledgePage-BUwh_DFd.js → NewKnowledgePage-deMsezK8.js} +1 -1
  47. package/static/assets/{NewSkillPage-B2rztwzD.js → NewSkillPage-DRYWdrlV.js} +1 -1
  48. package/static/assets/{NewTaskPage-Cvw20nug.js → NewTaskPage-B6xdic5_.js} +2 -2
  49. package/static/assets/{NotFoundPage-CXvLVHsT.js → NotFoundPage-Bxu9uKFO.js} +1 -1
  50. package/static/assets/{NotificationsSettingsPage-Df_GZ7_p.js → NotificationsSettingsPage-CLgtsCVM.js} +1 -1
  51. package/static/assets/{PromptsSettingsPage-QTxJgO5-.js → PromptsSettingsPage-BWaELCjG.js} +1 -1
  52. package/static/assets/{ResourceDetailPage-C9RHHVKu.js → ResourceDetailPage-CMPDRdVM.js} +1 -1
  53. package/static/assets/ResourcesPage-DspYILfG.js +41 -0
  54. package/static/assets/{RoleEditPage-N2-v2MXN.js → RoleEditPage-DXtzicVZ.js} +1 -1
  55. package/static/assets/{RolePage-Da0kZMUH.js → RolePage-DafGURGp.js} +1 -1
  56. package/static/assets/{RulesSettingsPage-CSd5iz22.js → RulesSettingsPage-E8V9cexV.js} +1 -1
  57. package/static/assets/RunDetailPage-DsxkqFst.js +1 -0
  58. package/static/assets/SchedulePage-B2YvNDHr.js +4 -0
  59. package/static/assets/{SkillDetailPage-QjqBAuFU.js → SkillDetailPage-CWkqSfuT.js} +1 -1
  60. package/static/assets/{SkillEditPage-BB0x4VVH.js → SkillEditPage-DwyebzFV.js} +1 -1
  61. package/static/assets/{SkillsPage-BMDNxMmZ.js → SkillsPage-CauK65X_.js} +2 -2
  62. package/static/assets/{SkillsSettingsPage-DcdeOlAl.js → SkillsSettingsPage-DXMRv3jR.js} +1 -1
  63. package/static/assets/{SourceInput-rc4KSqcv.js → SourceInput-C0iKqbQ1.js} +1 -1
  64. package/static/assets/{TagInput-bxFcAknC.js → TagInput-Ct-WRvTs.js} +1 -1
  65. package/static/assets/{TaskDetailPage-CAmREdfh.js → TaskDetailPage-CApk2iBh.js} +1 -1
  66. package/static/assets/{TaskEditPage-BDgZtG36.js → TaskEditPage-NgOVShfK.js} +1 -1
  67. package/static/assets/{TasksPage-BQ6eLw0T.js → TasksPage-BoPrP_Rl.js} +3 -3
  68. package/static/assets/TeamEditPage-ChY6mYm8.js +9 -0
  69. package/static/assets/TeamPage-DH-dJhFG.js +1 -0
  70. package/static/assets/{TerminalPage-BhWGRGf1.js → TerminalPage-CRhcscF2.js} +1 -1
  71. package/static/assets/{TerminalSessionPage-Bu-WiE0d.js → TerminalSessionPage-CSCQg2sn.js} +2 -2
  72. package/static/assets/{UserPreferencesPage-B_Tu1a8h.js → UserPreferencesPage-DxCSWJnS.js} +1 -1
  73. package/static/assets/{UserSettingsPage-BnEGtrGo.js → UserSettingsPage-DKkOLNPV.js} +1 -1
  74. package/static/assets/UtilitiesPage-CBNSvixW.js +1 -0
  75. package/static/assets/{alert-C42EBWiI.js → alert-Dw_RSroN.js} +1 -1
  76. package/static/assets/{arrow-down-CuFFg288.js → arrow-down-UClxXzT-.js} +1 -1
  77. package/static/assets/{arrow-left-C8VbyW3d.js → arrow-left-DWmf9YJp.js} +1 -1
  78. package/static/assets/{arrow-up-down-GN3qK2mU.js → arrow-up-down-Btc3okb3.js} +1 -1
  79. package/static/assets/{arrow-up-vC1c-5gW.js → arrow-up-fLCh7Hvh.js} +1 -1
  80. package/static/assets/{badge-CKwUSKzT.js → badge-vIqE5SOP.js} +1 -1
  81. package/static/assets/{browser-modal-C9VBJ_El.js → browser-modal-DgMJTsMd.js} +2 -2
  82. package/static/assets/{card-DRBgMGuU.js → card-DPLdBoa5.js} +1 -1
  83. package/static/assets/{chevron-left-2sP4ienq.js → chevron-left-CiNaLX-v.js} +1 -1
  84. package/static/assets/{chevron-up-DJfyvHso.js → chevron-up-DFd-7wxW.js} +1 -1
  85. package/static/assets/{chevrons-up-DfFpzHXf.js → chevrons-up-BfU70OcQ.js} +1 -1
  86. package/static/assets/{circle-alert-DP4rtmEK.js → circle-alert-Mv00T-P2.js} +1 -1
  87. package/static/assets/{circle-check-big-3mrGMFVn.js → circle-check-big-BEY1IoIP.js} +1 -1
  88. package/static/assets/{circle-check-Cnp-EoKX.js → circle-check-xMiP6SLO.js} +1 -1
  89. package/static/assets/{circle-play-7F5AVehH.js → circle-play-iZZwaGbV.js} +1 -1
  90. package/static/assets/{circle-x-DxbiyJ6w.js → circle-x-z3iynaE7.js} +1 -1
  91. package/static/assets/{clipboard-CQNR4_yT.js → clipboard-C8wZRPDH.js} +1 -1
  92. package/static/assets/{clock-DGw3R_UL.js → clock-C_9shc08.js} +1 -1
  93. package/static/assets/{code-DSNMK8tD.js → code-DH-sRhus.js} +1 -1
  94. package/static/assets/{download-BWL6PFiw.js → download-CE8b59ER.js} +1 -1
  95. package/static/assets/{external-link-BqUE-DMN.js → external-link-DPyKt8NE.js} +1 -1
  96. package/static/assets/{eye-BD57N1qQ.js → eye-BpGD-yoS.js} +1 -1
  97. package/static/assets/{folder-git-2-CW5Zi8Bm.js → folder-git-2-BIw4zbmy.js} +1 -1
  98. package/static/assets/globe-CUo7eHKN.js +6 -0
  99. package/static/assets/{index-CheR43vH.js → index-B07hel4U.js} +1 -1
  100. package/static/assets/{index-B0fLM-4F.js → index-BCwmQxLC.js} +1 -1
  101. package/static/assets/{index-DO47L-WG.js → index-BOKaM9K-.js} +1 -1
  102. package/static/assets/{index-EpelXypg.js → index-BaR4iUzg.js} +1 -1
  103. package/static/assets/index-BcCuKdbf.css +1 -0
  104. package/static/assets/{index-BG5vEV31.js → index-Bfb3OTwj.js} +1 -1
  105. package/static/assets/{index-CMQcknsg.js → index-Bkt1rQVV.js} +1 -1
  106. package/static/assets/{index-BmTTXfmk.js → index-C65b3D5_.js} +1 -1
  107. package/static/assets/{index-CXWGFCS-.js → index-CGbmjmEy.js} +1 -1
  108. package/static/assets/{index-BArpuuuE.js → index-CTouvf2d.js} +1 -1
  109. package/static/assets/{index-D4awulBm.js → index-Cdwx6Zps.js} +1 -1
  110. package/static/assets/{index-CMt1ExW-.js → index-ClO9-JVh.js} +1 -1
  111. package/static/assets/{index-CVVL2h9f.js → index-CpJ0uBf3.js} +1 -1
  112. package/static/assets/{index-B9OOTqx4.js → index-CsBxEWw5.js} +1 -1
  113. package/static/assets/{index-stPObw-o.js → index-DZAYfTI2.js} +1 -1
  114. package/static/assets/{index-X4fPPLHI.js → index-Dkr9CBL7.js} +1 -1
  115. package/static/assets/{index-Bedu89qc.js → index-DnZKG-_7.js} +1 -1
  116. package/static/assets/index-UXL5-kaP.js +497 -0
  117. package/static/assets/{index-uxv5vQZF.js → index-iB8oed57.js} +1 -1
  118. package/static/assets/{index-BWktaW8U.js → index-jaRIZ6SY.js} +1 -1
  119. package/static/assets/{info-DMJxIp7i.js → info-D-UNBNx2.js} +1 -1
  120. package/static/assets/{label-DxDedS8x.js → label-8VKluf9w.js} +1 -1
  121. package/static/assets/{markdown-editor-DJ2CscSp.js → markdown-editor-DBdRsbP2.js} +3 -3
  122. package/static/assets/{message-square-DF58cqKJ.js → message-square-CO8kDUed.js} +1 -1
  123. package/static/assets/{paperclip-CHyfSVll.js → paperclip-DlLXZbru.js} +1 -1
  124. package/static/assets/{pause-B-ouFhaQ.js → pause-zSiaxJBu.js} +1 -1
  125. package/static/assets/{play-B0y1weCV.js → play-DVBhRokt.js} +1 -1
  126. package/static/assets/{radio-group-DFNQiPDU.js → radio-group-CThYUcA4.js} +1 -1
  127. package/static/assets/{refresh-cw-5y5jTc6x.js → refresh-cw-tXYl1ePu.js} +1 -1
  128. package/static/assets/{search-B5deRThk.js → search-BxF7Wwex.js} +1 -1
  129. package/static/assets/{select-BzOa_wZx.js → select-CyHFRA1Y.js} +1 -1
  130. package/static/assets/server-lRxThHjr.js +6 -0
  131. package/static/assets/{switch-Bf2z8aaj.js → switch-BUpDbrux.js} +1 -1
  132. package/static/assets/{tabs-DkdBSep3.js → tabs-DkvCmQEX.js} +1 -1
  133. package/static/assets/{tag-gRsTk0jY.js → tag-CkcZNLnh.js} +1 -1
  134. package/static/assets/{terminal-preview-BfrUN2ok.js → terminal-preview-CLWDhoOZ.js} +1 -1
  135. package/static/assets/triangle-alert-CmjG_mbF.js +6 -0
  136. package/static/assets/{use-terminal-D6Qe1nwM.js → use-terminal-D3iV7-iC.js} +1 -1
  137. package/static/assets/{video-DXo9sCfT.js → video-CY_dOujm.js} +1 -1
  138. package/static/index.html +2 -2
  139. package/static/assets/ActivityPage-BaSoKgwZ.js +0 -1
  140. package/static/assets/ArchitectureEditPage-MYU7btLs.js +0 -21
  141. package/static/assets/ArchitecturePage-CGqWy8b1.js +0 -1
  142. package/static/assets/CodePage-C_bzfOnI.js +0 -2
  143. package/static/assets/IntegrationsSettingsPage-Cw6ItrNf.js +0 -1
  144. package/static/assets/JobDetailPage-DLSD4HiU.js +0 -1
  145. package/static/assets/KnowledgeDetailPage-DY8PpD9X.js +0 -1
  146. package/static/assets/MailInboxPage-DDYg0W70.js +0 -1
  147. package/static/assets/MailProcessingModal-CXIrtSz0.js +0 -6
  148. package/static/assets/MailReadPage-CVz6oD-y.js +0 -1
  149. package/static/assets/ProjectEditPage-DKf6ZoiG.js +0 -11
  150. package/static/assets/ProjectPage-CHhx9s1k.js +0 -1
  151. package/static/assets/ResourcesPage-BI8tfYZ2.js +0 -41
  152. package/static/assets/SchedulePage-CS8g2Db-.js +0 -4
  153. package/static/assets/UtilitiesPage-k7ABCAig.js +0 -1
  154. package/static/assets/index-Cht-fo9a.css +0 -1
  155. package/static/assets/index-DB2Tq9wz.js +0 -487
@@ -1 +1 @@
1
- import{x as Q,u as V,a as W,r as i,j as e,B as u,L as v,k as X,I as B,o as Y,aa as Z,A as y}from"./index-DB2Tq9wz.js";import{C as N,a as C,b as O,c as ee}from"./card-DRBgMGuU.js";import{L as l}from"./label-DxDedS8x.js";import{B as se}from"./badge-CKwUSKzT.js";import{c as te}from"./clipboard-B9ndUJKl.js";import{A as D}from"./arrow-left-C8VbyW3d.js";import{C as re,a as ae}from"./clipboard-CQNR4_yT.js";function me(){const{id:n}=Q(),q=V(),{toast:S}=W(),[U,k]=i.useState(!0),[o,w]=i.useState(!1),[d,c]=i.useState(null),[f,E]=i.useState(""),[x,P]=i.useState(""),[m,M]=i.useState("blue"),[h,F]=i.useState([]),[p,L]=i.useState(""),[$,g]=i.useState([]),[z,A]=i.useState(!0),[R,I]=i.useState(!1),_=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],H={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}};i.useEffect(()=>{async function s(){try{k(!0);const r=await(await fetch(`${y}/api/v1/skills/${n}`)).json();if(!r.success)throw new Error(r.error||"Failed to load skill");const t=r.document;E(t.name||""),P(t.description||""),M(t.metadata?.color||"blue"),L(t.content||""),F(Array.isArray(t.metadata?.mcpServers)?t.metadata.mcpServers:[])}catch(a){const r=a instanceof Error?a.message:"Failed to load skill";c(r)}finally{k(!1)}}n&&s()},[n]),i.useEffect(()=>{let s=!0;return(async()=>{A(!0);try{const r=await fetch(`${y}/api/v1/mcp`);if(!r.ok)throw new Error("Failed to fetch MCP servers");const t=await r.json();if(!t?.success||!Array.isArray(t.servers)){s&&g([]);return}const b=t.mcpServers&&typeof t.mcpServers=="object"?t.mcpServers:{},K=t.servers.map(T=>{const j=b[T]??{};return{name:T,enabled:j?.enabled!==!1,description:typeof j?.description=="string"?j.description:void 0}});s&&g(K)}catch(r){console.error("Failed to load MCP servers",r),s&&g([])}finally{s&&A(!1)}})(),()=>{s=!1}},[]);const J=async()=>{const s=".nut/config.json";try{await te(s),I(!0),S({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>I(!1),2e3)}catch(a){console.error("Failed to copy config path:",a),S({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},G=async s=>{if(s.preventDefault(),!f.trim()||!x.trim()||!p.trim()){c("Name, description, and skill instructions are required");return}try{w(!0),c(null);const a={name:f.trim(),description:x.trim(),content:p.trim(),metadata:{color:m,mcpServers:h.length?h:void 0}},t=await(await fetch(`${y}/api/v1/skills/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();if(!t.success)throw new Error(t.error||"Failed to update skill");const b=t.document?.id||n;q(`/skills/${b}`)}catch(a){const r=a instanceof Error?a.message:"Failed to update skill";c(r)}finally{w(!1)}};return U?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:"Loading skill..."})})}):d&&!f?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Skill"}),e.jsx("p",{className:"text-muted-foreground",children:"Unable to load skill"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:e.jsx("div",{className:"text-destructive",children:d})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Skill"}),e.jsxs("p",{className:"text-muted-foreground",children:["Skill ID: ",n]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsxs(N,{children:[e.jsx(O,{children:e.jsxs(ee,{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5"}),"Skill Configuration"]})}),e.jsx(C,{children:e.jsxs("form",{onSubmit:G,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:"Name *"}),e.jsx(B,{id:"name",value:f,onChange:s=>E(s.target.value),disabled:o})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(B,{id:"description",value:x,onChange:s=>P(s.target.value),disabled:o})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(s=>{const a=H[s];return e.jsx("button",{type:"button",onClick:()=>M(s),disabled:o,className:`w-10 h-10 rounded-md border-2 transition-all ${m===s?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:a.bg,borderColor:m===s?a.border:"hsl(var(--border))",...m===s&&{"--tw-ring-color":a.border}},title:s,children:e.jsx("span",{className:"sr-only",children:s})},s)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"content",children:"Skill Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this skill's behavior."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:J,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:R?e.jsx(re,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(ae,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the skill to be able to access its name, role, or email address."]}),e.jsx(Y,{id:"content",value:p,onChange:s=>L(s.target.value),rows:8,disabled:o,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"MCP Servers (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this skill requires. Leave empty to inherit all available servers."}),e.jsx("div",{className:"space-y-2",children:z?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers..."}):$.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):$.map(s=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(Z,{checked:h.includes(s.name),onCheckedChange:a=>{F(r=>a===!0?r.includes(s.name)?r:[...r,s.name]:r.filter(t=>t!==s.name))},disabled:o||!s.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s.name,!s.enabled&&e.jsx(se,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.enabled?s.description||"Enabled MCP server":"Enable this server in Settings to use it"})]})]},s.name))})]}),d&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:d}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(u,{type:"button",variant:"outline",asChild:!0,disabled:o,children:e.jsx(v,{to:`/skills/${n}`,children:"Cancel"})}),e.jsx(u,{type:"submit",disabled:o,children:o?"Saving...":"Save Changes"})]})]})})]})]})}export{me as default};
1
+ import{y as Q,u as V,a as W,r as i,j as e,B as u,L as v,k as X,I as B,o as Y,aa as Z,A as y}from"./index-UXL5-kaP.js";import{C as N,a as C,b as O,c as ee}from"./card-DPLdBoa5.js";import{L as l}from"./label-8VKluf9w.js";import{B as se}from"./badge-vIqE5SOP.js";import{c as te}from"./clipboard-B9ndUJKl.js";import{A as D}from"./arrow-left-DWmf9YJp.js";import{C as re,a as ae}from"./clipboard-C8wZRPDH.js";function me(){const{id:n}=Q(),q=V(),{toast:S}=W(),[U,k]=i.useState(!0),[o,w]=i.useState(!1),[d,c]=i.useState(null),[f,E]=i.useState(""),[x,P]=i.useState(""),[m,M]=i.useState("blue"),[h,F]=i.useState([]),[p,L]=i.useState(""),[$,g]=i.useState([]),[z,A]=i.useState(!0),[R,I]=i.useState(!1),_=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],H={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}};i.useEffect(()=>{async function s(){try{k(!0);const r=await(await fetch(`${y}/api/v1/skills/${n}`)).json();if(!r.success)throw new Error(r.error||"Failed to load skill");const t=r.document;E(t.name||""),P(t.description||""),M(t.metadata?.color||"blue"),L(t.content||""),F(Array.isArray(t.metadata?.mcpServers)?t.metadata.mcpServers:[])}catch(a){const r=a instanceof Error?a.message:"Failed to load skill";c(r)}finally{k(!1)}}n&&s()},[n]),i.useEffect(()=>{let s=!0;return(async()=>{A(!0);try{const r=await fetch(`${y}/api/v1/mcp`);if(!r.ok)throw new Error("Failed to fetch MCP servers");const t=await r.json();if(!t?.success||!Array.isArray(t.servers)){s&&g([]);return}const b=t.mcpServers&&typeof t.mcpServers=="object"?t.mcpServers:{},K=t.servers.map(T=>{const j=b[T]??{};return{name:T,enabled:j?.enabled!==!1,description:typeof j?.description=="string"?j.description:void 0}});s&&g(K)}catch(r){console.error("Failed to load MCP servers",r),s&&g([])}finally{s&&A(!1)}})(),()=>{s=!1}},[]);const J=async()=>{const s=".nut/config.json";try{await te(s),I(!0),S({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>I(!1),2e3)}catch(a){console.error("Failed to copy config path:",a),S({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},G=async s=>{if(s.preventDefault(),!f.trim()||!x.trim()||!p.trim()){c("Name, description, and skill instructions are required");return}try{w(!0),c(null);const a={name:f.trim(),description:x.trim(),content:p.trim(),metadata:{color:m,mcpServers:h.length?h:void 0}},t=await(await fetch(`${y}/api/v1/skills/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();if(!t.success)throw new Error(t.error||"Failed to update skill");const b=t.document?.id||n;q(`/skills/${b}`)}catch(a){const r=a instanceof Error?a.message:"Failed to update skill";c(r)}finally{w(!1)}};return U?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:"Loading skill..."})})}):d&&!f?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Skill"}),e.jsx("p",{className:"text-muted-foreground",children:"Unable to load skill"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:e.jsx("div",{className:"text-destructive",children:d})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Skill"}),e.jsxs("p",{className:"text-muted-foreground",children:["Skill ID: ",n]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsxs(N,{children:[e.jsx(O,{children:e.jsxs(ee,{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5"}),"Skill Configuration"]})}),e.jsx(C,{children:e.jsxs("form",{onSubmit:G,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:"Name *"}),e.jsx(B,{id:"name",value:f,onChange:s=>E(s.target.value),disabled:o})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(B,{id:"description",value:x,onChange:s=>P(s.target.value),disabled:o})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(s=>{const a=H[s];return e.jsx("button",{type:"button",onClick:()=>M(s),disabled:o,className:`w-10 h-10 rounded-md border-2 transition-all ${m===s?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:a.bg,borderColor:m===s?a.border:"hsl(var(--border))",...m===s&&{"--tw-ring-color":a.border}},title:s,children:e.jsx("span",{className:"sr-only",children:s})},s)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"content",children:"Skill Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this skill's behavior."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:J,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:R?e.jsx(re,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(ae,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the skill to be able to access its name, role, or email address."]}),e.jsx(Y,{id:"content",value:p,onChange:s=>L(s.target.value),rows:8,disabled:o,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"MCP Servers (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this skill requires. Leave empty to inherit all available servers."}),e.jsx("div",{className:"space-y-2",children:z?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers..."}):$.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):$.map(s=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(Z,{checked:h.includes(s.name),onCheckedChange:a=>{F(r=>a===!0?r.includes(s.name)?r:[...r,s.name]:r.filter(t=>t!==s.name))},disabled:o||!s.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s.name,!s.enabled&&e.jsx(se,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.enabled?s.description||"Enabled MCP server":"Enable this server in Settings to use it"})]})]},s.name))})]}),d&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:d}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(u,{type:"button",variant:"outline",asChild:!0,disabled:o,children:e.jsx(v,{to:`/skills/${n}`,children:"Cancel"})}),e.jsx(u,{type:"submit",disabled:o,children:o?"Saving...":"Save Changes"})]})]})})]})]})}export{me as default};
@@ -1,8 +1,8 @@
1
- import{c as M,j as e,S as z,_,r as f,a as $,A as R,t as O,B as j,L as y,P as E,k as F,ad as B,ae as U}from"./index-DB2Tq9wz.js";import{C as N,a as w,b as D,c as K}from"./card-DRBgMGuU.js";import{c as V}from"./clipboard-B9ndUJKl.js";import{R as H,L}from"./browser-modal-C9VBJ_El.js";import{R as P,f as Y}from"./registry-ANRa5WBi.js";import{B as v}from"./badge-CKwUSKzT.js";import"./search-B5deRThk.js";/**
1
+ import{c as M,j as e,S as $,$ as z,r as f,a as O,A as R,v as _,B as j,L as y,P as E,k as F,ad as B,ae as U}from"./index-UXL5-kaP.js";import{C as N,a as w,b as D,c as K}from"./card-DPLdBoa5.js";import{c as V}from"./clipboard-B9ndUJKl.js";import{R as H,L}from"./browser-modal-DgMJTsMd.js";import{R as P,f as Y}from"./registry-ANRa5WBi.js";import{B as v}from"./badge-vIqE5SOP.js";import"./search-BxF7Wwex.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
6
  */const q=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],G=M("package",q),J=["color","tools","createdAt","updatedAt","version","focusAreas","contextPreferences","tags"];function k(s){if(s){if(Array.isArray(s)){const i=s.map(a=>{if(typeof a=="string")return a.trim();if(typeof a=="number")return`${a}`}).filter(a=>typeof a=="string"&&a.length>0);return i.length>0?i:void 0}if(typeof s=="string"){const i=s.split(",").map(a=>a.trim()).filter(a=>a.length>0);return i.length>0?i:void 0}}}function W(s,i){const a=[];if(s.content&&typeof s.content=="object")for(const c of Object.values(s.content))typeof c=="string"&&c.trim().length>0&&a.push(c.trim());const n=[];return n.push(`# ${i}`),s.description?.trim()&&n.push(s.description.trim()),[...n,...a].join(`
7
7
 
8
- `).trim()}function T(s,i){const a=s.name||i.name,n=i.description||s.description||"",r={registryId:s.id,registryEndpoint:s.endpoint,registrySource:P,author:s.author};for(const o of J){const d=i[o];if(d!==void 0)if(o==="tools"){const h=k(d);h&&(r.mcpServers=h)}else if(o==="focusAreas"||o==="contextPreferences"||o==="tags"){const h=k(d);h&&(r[o]=h)}else r[o]=d}!r.version&&s.version&&(r.version=s.version),r.color||(r.color="blue"),!r.tags&&s.tags&&(r.tags=k(s.tags));for(const[o,d]of Object.entries(r))d==null&&delete r[o];let c;return i.archive&&(c=i.archive.startsWith("http")?i.archive:`${P}${i.archive}`),{name:a,description:n,content:W(i,a),metadata:Object.keys(r).length>0?r:void 0,archiveUrl:c}}function I({open:s,onOpenChange:i,onImport:a}){return e.jsx(H,{open:s,onOpenChange:i,categoryId:"skills",title:"Coconut Registry - Skills",confirmLabel:"Import Skill",getDetail:n=>Y(n.endpoint),renderPreview:(n,r)=>{if(!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a skill to preview"});const c=T(n,r),o=c.metadata??{},d=typeof o.version=="string"?o.version:void 0,h=Array.isArray(n.tags)?n.tags:[],g=Array.isArray(o.mcpServers)?o.mcpServers.filter(l=>typeof l=="string"):[],x=Array.isArray(o.focusAreas)?o.focusAreas.filter(l=>typeof l=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(z,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.description})]}),d&&e.jsxs(v,{variant:"outline",children:["v",d]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:n.id})]}),r.archive&&e.jsxs(v,{variant:"outline",className:"gap-1 text-[10px]",children:[e.jsx(G,{className:"h-3 w-3"}),"Includes companion files"]})]}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(l=>e.jsx(v,{variant:"secondary",children:l},l))}),g.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:"MCP Servers:"}),g.map(l=>e.jsx(v,{variant:"outline",children:l},l))]}),x.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Focus Areas"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground",children:x.map(l=>e.jsx("li",{children:l},l))})]})]}),c.content?e.jsx(_,{className:"[&_.prose]:max-w-none",children:c.content}):r.archive?e.jsx("div",{className:"rounded-md bg-muted/50 p-4 text-sm text-muted-foreground",children:e.jsx("p",{children:"Full skill content and companion files will be downloaded during import."})}):null]})})})},onConfirm:async(n,r)=>{const c=T(n,r);await a({summary:n,detail:r,payload:c})}})}function Q(s){return s.replace(/[-_]/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function ne(){const[s,i]=f.useState([]),[a,n]=f.useState(!0),[r,c]=f.useState({}),[o,d]=f.useState(!1),[h,g]=f.useState(!1),{toast:x}=$(),l=f.useCallback(async()=>{n(!0);try{const t=await fetch(`${R}/api/v1/skills`);if(!t.ok)throw new Error("Failed to load skills");const p=await t.json();i(Array.isArray(p.documents)?p.documents:[])}catch(t){console.error("Failed to load skills:",t),i([])}finally{n(!1)}},[]);f.useEffect(()=>{l()},[l]);const b=async t=>{const p=`.nut/skills/${t}/SKILL.md`;try{await V(p),c(m=>({...m,[t]:!0})),setTimeout(()=>{c(m=>({...m,[t]:!1}))},2e3),x({title:"Path copied!",description:`Copied ${p} to clipboard`})}catch(m){console.error("Failed to copy path:",m),x({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},S=f.useCallback(async({payload:t})=>{let p=!1;g(!0);try{const m=await fetch(`${R}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,description:t.description,content:t.content,metadata:t.metadata,...t.archiveUrl?{archiveUrl:t.archiveUrl}:{}})});let u=null;try{u=await m.json()}catch(C){console.error("Failed to parse registry import response:",C)}if(!(m.ok&&u?.success)){const A=(typeof u?.error=="string"?u.error:u?.error?.message)||m.statusText||"Failed to import skill from registry";throw x({title:"Failed to import skill",description:A,variant:"destructive"}),p=!0,new Error(A)}x({title:"Skill imported",description:`${t.name} is now available in Coconut`}),await l()}catch(m){if(!p){const u=m instanceof Error&&m.message?m.message:"Failed to import skill from registry";x({title:"Failed to import skill",description:u,variant:"destructive"})}throw m}finally{g(!1)}},[l,x]);return a?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(O,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading skills..."})]})})})}):s.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:h,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(j,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(F,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Skills Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Specialized skills help you automate your development and business workflows."})]})})})]}),e.jsx(I,{open:o,onOpenChange:d,onImport:S})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:h,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(j,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx("div",{className:"grid gap-4",children:s.map(t=>e.jsx(y,{to:`/skills/${t.id}`,className:"block",children:e.jsxs(N,{className:"group hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:[e.jsx(D,{children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"text-lg",children:Q(t.name)}),e.jsx(j,{variant:"ghost",size:"sm",onClick:p=>{p.preventDefault(),b(t.id)},className:"h-6 w-6 p-0 hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy file path to clipboard",children:r[t.id]?e.jsx(B,{className:"w-3 h-3 text-green-600"}):e.jsx(U,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono bg-muted/50 px-2 py-1 rounded inline-block cursor-pointer hover:bg-muted/70 transition-colors",onClick:p=>{p.preventDefault(),b(t.id)},title:"Click to copy file path to clipboard",children:[".nut/skills/",t.id,"/SKILL.md"]}),t.allowedTools&&e.jsx("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{className:"w-3 h-3"}),t.allowedTools]})})]})})}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:t.description})})})})]})},t.id))})]}),e.jsx(I,{open:o,onOpenChange:d,onImport:S})]})}export{ne as default};
8
+ `).trim()}function T(s,i){const a=s.name||i.name,n=i.description||s.description||"",r={registryId:s.id,registryEndpoint:s.endpoint,registrySource:P,author:s.author};for(const o of J){const d=i[o];if(d!==void 0)if(o==="tools"){const h=k(d);h&&(r.mcpServers=h)}else if(o==="focusAreas"||o==="contextPreferences"||o==="tags"){const h=k(d);h&&(r[o]=h)}else r[o]=d}!r.version&&s.version&&(r.version=s.version),r.color||(r.color="blue"),!r.tags&&s.tags&&(r.tags=k(s.tags));for(const[o,d]of Object.entries(r))d==null&&delete r[o];let c;return i.archive&&(c=i.archive.startsWith("http")?i.archive:`${P}${i.archive}`),{name:a,description:n,content:W(i,a),metadata:Object.keys(r).length>0?r:void 0,archiveUrl:c}}function I({open:s,onOpenChange:i,onImport:a}){return e.jsx(H,{open:s,onOpenChange:i,categoryId:"skills",title:"Coconut Registry - Skills",confirmLabel:"Import Skill",getDetail:n=>Y(n.endpoint),renderPreview:(n,r)=>{if(!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a skill to preview"});const c=T(n,r),o=c.metadata??{},d=typeof o.version=="string"?o.version:void 0,h=Array.isArray(n.tags)?n.tags:[],g=Array.isArray(o.mcpServers)?o.mcpServers.filter(l=>typeof l=="string"):[],x=Array.isArray(o.focusAreas)?o.focusAreas.filter(l=>typeof l=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx($,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.description})]}),d&&e.jsxs(v,{variant:"outline",children:["v",d]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:n.id})]}),r.archive&&e.jsxs(v,{variant:"outline",className:"gap-1 text-[10px]",children:[e.jsx(G,{className:"h-3 w-3"}),"Includes companion files"]})]}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(l=>e.jsx(v,{variant:"secondary",children:l},l))}),g.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:"MCP Servers:"}),g.map(l=>e.jsx(v,{variant:"outline",children:l},l))]}),x.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Focus Areas"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground",children:x.map(l=>e.jsx("li",{children:l},l))})]})]}),c.content?e.jsx(z,{className:"[&_.prose]:max-w-none",children:c.content}):r.archive?e.jsx("div",{className:"rounded-md bg-muted/50 p-4 text-sm text-muted-foreground",children:e.jsx("p",{children:"Full skill content and companion files will be downloaded during import."})}):null]})})})},onConfirm:async(n,r)=>{const c=T(n,r);await a({summary:n,detail:r,payload:c})}})}function Q(s){return s.replace(/[-_]/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function ne(){const[s,i]=f.useState([]),[a,n]=f.useState(!0),[r,c]=f.useState({}),[o,d]=f.useState(!1),[h,g]=f.useState(!1),{toast:x}=O(),l=f.useCallback(async()=>{n(!0);try{const t=await fetch(`${R}/api/v1/skills`);if(!t.ok)throw new Error("Failed to load skills");const p=await t.json();i(Array.isArray(p.documents)?p.documents:[])}catch(t){console.error("Failed to load skills:",t),i([])}finally{n(!1)}},[]);f.useEffect(()=>{l()},[l]);const b=async t=>{const p=`.nut/skills/${t}/SKILL.md`;try{await V(p),c(m=>({...m,[t]:!0})),setTimeout(()=>{c(m=>({...m,[t]:!1}))},2e3),x({title:"Path copied!",description:`Copied ${p} to clipboard`})}catch(m){console.error("Failed to copy path:",m),x({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},S=f.useCallback(async({payload:t})=>{let p=!1;g(!0);try{const m=await fetch(`${R}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,description:t.description,content:t.content,metadata:t.metadata,...t.archiveUrl?{archiveUrl:t.archiveUrl}:{}})});let u=null;try{u=await m.json()}catch(C){console.error("Failed to parse registry import response:",C)}if(!(m.ok&&u?.success)){const A=(typeof u?.error=="string"?u.error:u?.error?.message)||m.statusText||"Failed to import skill from registry";throw x({title:"Failed to import skill",description:A,variant:"destructive"}),p=!0,new Error(A)}x({title:"Skill imported",description:`${t.name} is now available in Coconut`}),await l()}catch(m){if(!p){const u=m instanceof Error&&m.message?m.message:"Failed to import skill from registry";x({title:"Failed to import skill",description:u,variant:"destructive"})}throw m}finally{g(!1)}},[l,x]);return a?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(_,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading skills..."})]})})})}):s.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:h,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(j,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(F,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Skills Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Specialized skills help you automate your development and business workflows."})]})})})]}),e.jsx(I,{open:o,onOpenChange:d,onImport:S})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:h,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(j,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx("div",{className:"grid gap-4",children:s.map(t=>e.jsx(y,{to:`/skills/${t.id}`,className:"block",children:e.jsxs(N,{className:"group hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:[e.jsx(D,{children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"text-lg",children:Q(t.name)}),e.jsx(j,{variant:"ghost",size:"sm",onClick:p=>{p.preventDefault(),b(t.id)},className:"h-6 w-6 p-0 hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy file path to clipboard",children:r[t.id]?e.jsx(B,{className:"w-3 h-3 text-green-600"}):e.jsx(U,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono bg-muted/50 px-2 py-1 rounded inline-block cursor-pointer hover:bg-muted/70 transition-colors",onClick:p=>{p.preventDefault(),b(t.id)},title:"Click to copy file path to clipboard",children:[".nut/skills/",t.id,"/SKILL.md"]}),t.allowedTools&&e.jsx("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{className:"w-3 h-3"}),t.allowedTools]})})]})})}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:t.description})})})})]})},t.id))})]}),e.jsx(I,{open:o,onOpenChange:d,onImport:S})]})}export{ne as default};
@@ -1 +1 @@
1
- import{j as s,bv as e,B as a,L as t}from"./index-DB2Tq9wz.js";import{C as i,b as l,c as r,d as n,a as d}from"./card-DRBgMGuU.js";import{E as o}from"./external-link-BqUE-DMN.js";function h(){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-medium",children:"Skills Management"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure and manage AI skills that automate various development tasks."})]}),s.jsx(e,{}),s.jsxs(i,{children:[s.jsxs(l,{children:[s.jsx(r,{children:"Skills"}),s.jsx(n,{children:"Skills are managed from the Skills page. Visit the skills page to create, edit, and manage your AI skills."})]}),s.jsx(d,{children:s.jsx(a,{asChild:!0,children:s.jsxs(t,{to:"/skills",children:[s.jsx(o,{className:"h-4 w-4 mr-2"}),"Go to Skills"]})})})]})]})}export{h as default};
1
+ import{j as s,bx as e,B as a,L as t}from"./index-UXL5-kaP.js";import{C as i,b as l,c as r,d as n,a as d}from"./card-DPLdBoa5.js";import{E as o}from"./external-link-DPyKt8NE.js";function h(){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-medium",children:"Skills Management"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure and manage AI skills that automate various development tasks."})]}),s.jsx(e,{}),s.jsxs(i,{children:[s.jsxs(l,{children:[s.jsx(r,{children:"Skills"}),s.jsx(n,{children:"Skills are managed from the Skills page. Visit the skills page to create, edit, and manage your AI skills."})]}),s.jsx(d,{children:s.jsx(a,{asChild:!0,children:s.jsxs(t,{to:"/skills",children:[s.jsx(o,{className:"h-4 w-4 mr-2"}),"Go to Skills"]})})})]})]})}export{h as default};
@@ -1 +1 @@
1
- import{r as h,j as t,I as x,B as d,P as j,X as N}from"./index-DB2Tq9wz.js";import{E as v}from"./external-link-BqUE-DMN.js";function g(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function S(n){return n?n.map(g):[]}function k({sources:n,onChange:i,disabled:a}){const[l,m]=h.useState(""),[o,c]=h.useState(""),u=()=>{const e=l.trim();if(!e)return;const s=o.trim()||void 0,r={title:e,url:s};i([...n,r]),m(""),c("")},f=e=>{i(n.filter((s,r)=>r!==e))},p=e=>{e.key==="Enter"&&(e.preventDefault(),u())};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(x,{placeholder:"Source title (e.g., Design System Audit)",value:l,onChange:e=>m(e.target.value),onKeyDown:p,disabled:a,className:"flex-1"}),t.jsx(x,{placeholder:"URL (optional)",value:o,onChange:e=>c(e.target.value),onKeyDown:p,disabled:a,className:"flex-1",type:"url"}),t.jsxs(d,{type:"button",variant:"outline",onClick:u,disabled:a||!l.trim(),className:"shrink-0",children:[t.jsx(j,{className:"h-4 w-4 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Add"})]})]}),n.length>0&&t.jsx("ul",{className:"space-y-2",children:n.map((e,s)=>t.jsxs("li",{className:"flex items-start gap-2 rounded-md border bg-muted/50 p-2 text-sm",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium truncate",children:e.title}),e.url&&t.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary flex items-center gap-1 truncate",children:[t.jsx(v,{className:"h-3 w-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e.url})]})]}),t.jsx(d,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(s),disabled:a,className:"h-6 w-6 p-0 shrink-0","aria-label":`Remove source ${e.title}`,children:t.jsx(N,{className:"h-3 w-3"})})]},s))})]})}export{k as S,S as n};
1
+ import{r as h,j as t,I as x,B as d,P as j,X as N}from"./index-UXL5-kaP.js";import{E as v}from"./external-link-DPyKt8NE.js";function g(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function S(n){return n?n.map(g):[]}function k({sources:n,onChange:i,disabled:a}){const[l,m]=h.useState(""),[o,c]=h.useState(""),u=()=>{const e=l.trim();if(!e)return;const s=o.trim()||void 0,r={title:e,url:s};i([...n,r]),m(""),c("")},f=e=>{i(n.filter((s,r)=>r!==e))},p=e=>{e.key==="Enter"&&(e.preventDefault(),u())};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(x,{placeholder:"Source title (e.g., Design System Audit)",value:l,onChange:e=>m(e.target.value),onKeyDown:p,disabled:a,className:"flex-1"}),t.jsx(x,{placeholder:"URL (optional)",value:o,onChange:e=>c(e.target.value),onKeyDown:p,disabled:a,className:"flex-1",type:"url"}),t.jsxs(d,{type:"button",variant:"outline",onClick:u,disabled:a||!l.trim(),className:"shrink-0",children:[t.jsx(j,{className:"h-4 w-4 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Add"})]})]}),n.length>0&&t.jsx("ul",{className:"space-y-2",children:n.map((e,s)=>t.jsxs("li",{className:"flex items-start gap-2 rounded-md border bg-muted/50 p-2 text-sm",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium truncate",children:e.title}),e.url&&t.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary flex items-center gap-1 truncate",children:[t.jsx(v,{className:"h-3 w-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e.url})]})]}),t.jsx(d,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(s),disabled:a,className:"h-6 w-6 p-0 shrink-0","aria-label":`Remove source ${e.title}`,children:t.jsx(N,{className:"h-3 w-3"})})]},s))})]})}export{k as S,S as n};
@@ -1 +1 @@
1
- import{r as p,j as t,I as d,B as m,X as x}from"./index-DB2Tq9wz.js";import{B as f}from"./badge-CKwUSKzT.js";function j({tags:a,onChange:r,disabled:n,placeholder:o}){const[l,s]=p.useState(""),c=()=>{const e=l.trim();if(e){if(a.includes(e)){s("");return}r([...a,e]),s("")}},i=e=>{r(a.filter(u=>u!==e))};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(d,{placeholder:o||"Add a tag",value:l,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),c())},disabled:n}),t.jsx(m,{type:"button",variant:"outline",onClick:c,disabled:n,children:"Add"})]}),a.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(e=>t.jsxs(f,{variant:"secondary",className:"flex items-center gap-1",children:[e,t.jsx("button",{type:"button",onClick:()=>i(e),className:"ml-1 hover:text-destructive",disabled:n,"aria-label":`Remove tag ${e}`,children:t.jsx(x,{className:"h-3 w-3"})})]},e))})]})}export{j as T};
1
+ import{r as p,j as t,I as d,B as m,X as x}from"./index-UXL5-kaP.js";import{B as f}from"./badge-vIqE5SOP.js";function j({tags:a,onChange:r,disabled:n,placeholder:o}){const[l,s]=p.useState(""),c=()=>{const e=l.trim();if(e){if(a.includes(e)){s("");return}r([...a,e]),s("")}},i=e=>{r(a.filter(u=>u!==e))};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(d,{placeholder:o||"Add a tag",value:l,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),c())},disabled:n}),t.jsx(m,{type:"button",variant:"outline",onClick:c,disabled:n,children:"Add"})]}),a.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(e=>t.jsxs(f,{variant:"secondary",className:"flex items-center gap-1",children:[e,t.jsx("button",{type:"button",onClick:()=>i(e),className:"ml-1 hover:text-destructive",disabled:n,"aria-label":`Remove tag ${e}`,children:t.jsx(x,{className:"h-3 w-3"})})]},e))})]})}export{j as T};
@@ -1,4 +1,4 @@
1
- import{c as T,x as xe,u as ue,r as i,a as pe,j as e,B as n,L as c,y as je,z as fe,E as ge,H as Ne,J as ye,N as ve,O as be,Q as we,R as Ce,U as ke,D as H,V,b as B,d as q,f as J,g as K,W as G,Y as Se,_ as Q,$ as De,m as Te,o as Ae,A as u}from"./index-DB2Tq9wz.js";import{c as $e}from"./clipboard-B9ndUJKl.js";import{C as m,b as k,a as h,c as W,d as Pe}from"./card-DRBgMGuU.js";import{B as g}from"./badge-CKwUSKzT.js";import{L as Y}from"./label-DxDedS8x.js";import{S as X,a as Z,b as ee,c as se,d as te}from"./select-BzOa_wZx.js";import{T as Ue,a as ae,g as Ee}from"./status-utils-PwF3DXLL.js";import{A as S}from"./arrow-left-C8VbyW3d.js";import{C as Ie,a as Oe}from"./clipboard-CQNR4_yT.js";import{A as Fe}from"./arrow-up-down-GN3qK2mU.js";import{I as ze}from"./info-DMJxIp7i.js";import{P as Le}from"./play-B0y1weCV.js";import{C as Me}from"./clock-DGw3R_UL.js";import{M as _e}from"./message-square-DF58cqKJ.js";import"./index-Bedu89qc.js";import"./chevron-up-DJfyvHso.js";/**
1
+ import{c as T,y as xe,u as ue,r as i,a as pe,j as e,B as n,L as c,z as je,E as fe,H as ge,J as Ne,N as ye,O as ve,Q as be,R as we,U as Ce,V as ke,D as H,W as V,b as B,d as q,f as J,g as K,Y as G,_ as Se,$ as Q,a0 as De,m as Te,o as Ae,A as u}from"./index-UXL5-kaP.js";import{c as $e}from"./clipboard-B9ndUJKl.js";import{C as m,b as k,a as h,c as W,d as Pe}from"./card-DPLdBoa5.js";import{B as g}from"./badge-vIqE5SOP.js";import{L as Y}from"./label-8VKluf9w.js";import{S as X,a as Z,b as ee,c as se,d as te}from"./select-CyHFRA1Y.js";import{T as Ue,a as ae,g as Ee}from"./status-utils-PwF3DXLL.js";import{A as S}from"./arrow-left-DWmf9YJp.js";import{C as Ie,a as Oe}from"./clipboard-C8wZRPDH.js";import{A as Fe}from"./arrow-up-down-Btc3okb3.js";import{I as ze}from"./info-D-UNBNx2.js";import{P as Le}from"./play-DVBhRokt.js";import{C as Me}from"./clock-C_9shc08.js";import{M as _e}from"./message-square-CO8kDUed.js";import"./index-DnZKG-_7.js";import"./chevron-up-DFd-7wxW.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{x as R,u as U,a as H,r as c,A,j as e,B as h,L as p,I as O,X as V,a0 as _}from"./index-DB2Tq9wz.js";import{L as j}from"./label-DxDedS8x.js";import{S as D,a as L,b as F,c as I,d as r}from"./select-BzOa_wZx.js";import{C as f,b as $,a as v,c as q,d as J}from"./card-DRBgMGuU.js";import{M as K}from"./markdown-editor-DJ2CscSp.js";import{C as W}from"./CollapsibleSection-DfTxWX0X.js";import{I as X,L as G}from"./ImplementationStepsEditor-Cn-MshnR.js";import{T as Q}from"./TagInput-bxFcAknC.js";import{A as N}from"./arrow-left-C8VbyW3d.js";import"./index-Bedu89qc.js";import"./chevron-up-DJfyvHso.js";import"./badge-CKwUSKzT.js";function oe(){const{id:i}=R(),P=U(),{toast:y}=H(),[z,S]=c.useState(!0),[u,k]=c.useState(!1),[C,w]=c.useState(null),[n,o]=c.useState({title:"",description:"",priority:"medium",status:"draft",author:{id:"current-user",name:"Current User",email:"user@example.com"}}),[m,b]=c.useState([]),[T,E]=c.useState([]);c.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${A}/api/v1/tasks/${i}`),s=await t.json();if(s.success||s.data||t.ok){const a=s.data||s;o({title:a.title||a.intent||"",description:a.content||"",priority:a.metadata?.priority||"medium",status:a.status||"draft",author:{id:a.author?.id||"current-user",name:a.author?.name||"Current User",email:a.author?.email||"user@example.com"}});const g=Array.isArray(a.planSteps)?a.planSteps:[];b(g.map((d,x)=>({id:d.id||`step-${x+1}`,description:d.description||"",status:d.status||"pending"}))),E(a.metadata?.tags||[])}else w(s.error?.message||"Failed to fetch task")}catch(t){w(t instanceof Error?t.message:"An error occurred")}finally{S(!1)}},M=async t=>{t.preventDefault(),k(!0);try{const s=m.map(l=>({id:l.id,description:l.description.trim(),status:l.status})).filter(l=>l.description.length>0),a=T.map(l=>l.trim()).filter(l=>l.length>0),g={title:n.title,status:n.status,planSteps:s,metadata:{priority:n.priority,tags:a},content:n.description},d=await fetch(`${A}/api/v1/tasks/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),x=await d.json();if(x.success||d.ok)y({title:"Success",description:"Task updated successfully."}),P(`/tasks/${i}`);else throw new Error(x.error?.message||"Failed to update task")}catch(s){y({title:"Error",description:`Failed to update task: ${s instanceof Error?s.message:"An error occurred"}`,variant:"destructive"})}finally{k(!1)}};return z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Task"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading task data..."})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:`/tasks/${i}`,className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsxs(f,{children:[e.jsx($,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-6 bg-muted rounded w-1/2 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-3/4 animate-pulse"})]})}),e.jsx(v,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-10 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-64 bg-muted rounded animate-pulse"})]})})]})]}):C?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:"/tasks",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx(f,{children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:C})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Task"}),e.jsxs("p",{className:"text-muted-foreground",children:["Editing ",i]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(p,{to:`/tasks/${i}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx("form",{onSubmit:M,children:e.jsxs(f,{children:[e.jsxs($,{children:[e.jsx(q,{children:"Task Details"}),e.jsx(J,{children:"Update the information for your task"})]}),e.jsxs(v,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"title",children:"Title *"}),e.jsx(O,{id:"title",placeholder:"Brief description of what you want to change",value:n.title,onChange:t=>o(s=>({...s,title:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"description",children:"Description"}),e.jsx(K,{value:n.description,onChange:t=>o(s=>({...s,description:t||""})),placeholder:"Write your task description in markdown...",height:400})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"status",children:"Status"}),e.jsxs(D,{value:n.status,onValueChange:t=>o(s=>({...s,status:t})),children:[e.jsx(L,{children:e.jsx(F,{placeholder:"Select status"})}),e.jsxs(I,{children:[e.jsx(r,{value:"draft",children:"Draft"}),e.jsx(r,{value:"proposed",children:"Proposed"}),e.jsx(r,{value:"in-review",children:"In Review"}),e.jsx(r,{value:"approved",children:"Approved"}),e.jsx(r,{value:"code-complete",children:"Code Complete"}),e.jsx(r,{value:"rejected",children:"Rejected"}),e.jsx(r,{value:"merged",children:"Merged"})]})]})]}),e.jsx(W,{defaultOpen:!0,icon:e.jsx(G,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"priority",children:"Priority"}),e.jsxs(D,{value:n.priority,onValueChange:t=>o(s=>({...s,priority:t})),children:[e.jsx(L,{children:e.jsx(F,{placeholder:"Select priority"})}),e.jsxs(I,{children:[e.jsx(r,{value:"low",children:"Low"}),e.jsx(r,{value:"medium",children:"Medium"}),e.jsx(r,{value:"high",children:"High"}),e.jsx(r,{value:"critical",children:"Critical"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Implementation Steps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Keep the implementation plan accurate as work progresses."})]}),m.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.length," step",m.length===1?"":"s"]})]}),e.jsx(X,{steps:m,onChange:b,disabled:u})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Tags"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tags power filtering and discovery across the task list."}),e.jsx(Q,{tags:T,onChange:E,disabled:u,placeholder:"Add a tag (e.g. backend, rollout)"})]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{type:"button",variant:"outline",asChild:!0,children:e.jsxs(p,{to:`/tasks/${i}`,children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Cancel"]})}),e.jsx(h,{type:"submit",disabled:u||!n.title,children:u?e.jsx(e.Fragment,{children:"Saving..."}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})]})]})]})})]})}export{oe as TaskEditPage};
1
+ import{y as R,u as U,a as H,r as c,A,j as e,B as h,L as p,I as O,X as V,a1 as _}from"./index-UXL5-kaP.js";import{L as j}from"./label-8VKluf9w.js";import{S as D,a as L,b as F,c as I,d as r}from"./select-CyHFRA1Y.js";import{C as f,b as $,a as v,c as q,d as J}from"./card-DPLdBoa5.js";import{M as K}from"./markdown-editor-DBdRsbP2.js";import{C as W}from"./CollapsibleSection-CNs1mvsZ.js";import{I as X,L as G}from"./ImplementationStepsEditor-D4cvhPhz.js";import{T as Q}from"./TagInput-Ct-WRvTs.js";import{A as N}from"./arrow-left-DWmf9YJp.js";import"./index-DnZKG-_7.js";import"./chevron-up-DFd-7wxW.js";import"./badge-vIqE5SOP.js";function oe(){const{id:i}=R(),P=U(),{toast:y}=H(),[z,S]=c.useState(!0),[u,k]=c.useState(!1),[C,w]=c.useState(null),[n,o]=c.useState({title:"",description:"",priority:"medium",status:"draft",author:{id:"current-user",name:"Current User",email:"user@example.com"}}),[m,b]=c.useState([]),[T,E]=c.useState([]);c.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${A}/api/v1/tasks/${i}`),s=await t.json();if(s.success||s.data||t.ok){const a=s.data||s;o({title:a.title||a.intent||"",description:a.content||"",priority:a.metadata?.priority||"medium",status:a.status||"draft",author:{id:a.author?.id||"current-user",name:a.author?.name||"Current User",email:a.author?.email||"user@example.com"}});const g=Array.isArray(a.planSteps)?a.planSteps:[];b(g.map((d,x)=>({id:d.id||`step-${x+1}`,description:d.description||"",status:d.status||"pending"}))),E(a.metadata?.tags||[])}else w(s.error?.message||"Failed to fetch task")}catch(t){w(t instanceof Error?t.message:"An error occurred")}finally{S(!1)}},M=async t=>{t.preventDefault(),k(!0);try{const s=m.map(l=>({id:l.id,description:l.description.trim(),status:l.status})).filter(l=>l.description.length>0),a=T.map(l=>l.trim()).filter(l=>l.length>0),g={title:n.title,status:n.status,planSteps:s,metadata:{priority:n.priority,tags:a},content:n.description},d=await fetch(`${A}/api/v1/tasks/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),x=await d.json();if(x.success||d.ok)y({title:"Success",description:"Task updated successfully."}),P(`/tasks/${i}`);else throw new Error(x.error?.message||"Failed to update task")}catch(s){y({title:"Error",description:`Failed to update task: ${s instanceof Error?s.message:"An error occurred"}`,variant:"destructive"})}finally{k(!1)}};return z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Task"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading task data..."})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:`/tasks/${i}`,className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsxs(f,{children:[e.jsx($,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-6 bg-muted rounded w-1/2 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-3/4 animate-pulse"})]})}),e.jsx(v,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-10 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-64 bg-muted rounded animate-pulse"})]})})]})]}):C?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:"/tasks",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx(f,{children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:C})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Task"}),e.jsxs("p",{className:"text-muted-foreground",children:["Editing ",i]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(p,{to:`/tasks/${i}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx("form",{onSubmit:M,children:e.jsxs(f,{children:[e.jsxs($,{children:[e.jsx(q,{children:"Task Details"}),e.jsx(J,{children:"Update the information for your task"})]}),e.jsxs(v,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"title",children:"Title *"}),e.jsx(O,{id:"title",placeholder:"Brief description of what you want to change",value:n.title,onChange:t=>o(s=>({...s,title:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"description",children:"Description"}),e.jsx(K,{value:n.description,onChange:t=>o(s=>({...s,description:t||""})),placeholder:"Write your task description in markdown...",height:400})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"status",children:"Status"}),e.jsxs(D,{value:n.status,onValueChange:t=>o(s=>({...s,status:t})),children:[e.jsx(L,{children:e.jsx(F,{placeholder:"Select status"})}),e.jsxs(I,{children:[e.jsx(r,{value:"draft",children:"Draft"}),e.jsx(r,{value:"proposed",children:"Proposed"}),e.jsx(r,{value:"in-review",children:"In Review"}),e.jsx(r,{value:"approved",children:"Approved"}),e.jsx(r,{value:"code-complete",children:"Code Complete"}),e.jsx(r,{value:"rejected",children:"Rejected"}),e.jsx(r,{value:"merged",children:"Merged"})]})]})]}),e.jsx(W,{defaultOpen:!0,icon:e.jsx(G,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"priority",children:"Priority"}),e.jsxs(D,{value:n.priority,onValueChange:t=>o(s=>({...s,priority:t})),children:[e.jsx(L,{children:e.jsx(F,{placeholder:"Select priority"})}),e.jsxs(I,{children:[e.jsx(r,{value:"low",children:"Low"}),e.jsx(r,{value:"medium",children:"Medium"}),e.jsx(r,{value:"high",children:"High"}),e.jsx(r,{value:"critical",children:"Critical"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Implementation Steps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Keep the implementation plan accurate as work progresses."})]}),m.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.length," step",m.length===1?"":"s"]})]}),e.jsx(X,{steps:m,onChange:b,disabled:u})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Tags"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tags power filtering and discovery across the task list."}),e.jsx(Q,{tags:T,onChange:E,disabled:u,placeholder:"Add a tag (e.g. backend, rollout)"})]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{type:"button",variant:"outline",asChild:!0,children:e.jsxs(p,{to:`/tasks/${i}`,children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Cancel"]})}),e.jsx(h,{type:"submit",disabled:u||!n.title,children:u?e.jsx(e.Fragment,{children:"Saving..."}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})]})]})]})})]})}export{oe as TaskEditPage};
@@ -1,4 +1,4 @@
1
- import{c as Ce,w as Ke,u as ze,q as Ve,r as A,j as t,B as P,L as te,P as ue,I as We,X,K as Ue,p as Ge,n as He,G as Qe,C as Ye,A as Xe}from"./index-DB2Tq9wz.js";import{C as J,a as Z,c as Je}from"./card-DRBgMGuU.js";import{B as se}from"./badge-CKwUSKzT.js";import{S as oe,a as he,b as de,c as me,d as B}from"./select-BzOa_wZx.js";import{A as Ze,a as Ee,T as qe,g as et}from"./status-utils-PwF3DXLL.js";import{S as tt}from"./search-B5deRThk.js";import{C as st}from"./chevron-up-DJfyvHso.js";import{C as rt}from"./chevron-left-2sP4ienq.js";import"./index-Bedu89qc.js";/**
1
+ import{c as Ce,x as Ke,u as ze,s as Ve,r as A,j as t,B as P,L as te,P as ue,I as We,X,K as Ue,p as Ge,n as He,G as Qe,C as Ye,A as Xe}from"./index-UXL5-kaP.js";import{C as J,a as Z,c as Je}from"./card-DPLdBoa5.js";import{B as se}from"./badge-vIqE5SOP.js";import{S as oe,a as he,b as de,c as me,d as B}from"./select-CyHFRA1Y.js";import{A as Ze,a as Ee,T as qe,g as et}from"./status-utils-PwF3DXLL.js";import{S as tt}from"./search-BxF7Wwex.js";import{C as st}from"./chevron-up-DFd-7wxW.js";import{C as rt}from"./chevron-left-CiNaLX-v.js";import"./index-DnZKG-_7.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -13,5 +13,5 @@ import{c as Ce,w as Ke,u as ze,q as Ve,r as A,j as t,B as P,L as te,P as ue,I as
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const lt=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],be=Ce("funnel",lt);function K(s){return Array.isArray?Array.isArray(s):_e(s)==="[object Array]"}function ut(s){if(typeof s=="string")return s;let e=s+"";return e=="0"&&1/s==-1/0?"-0":e}function ot(s){return s==null?"":ut(s)}function O(s){return typeof s=="string"}function De(s){return typeof s=="number"}function ht(s){return s===!0||s===!1||dt(s)&&_e(s)=="[object Boolean]"}function ke(s){return typeof s=="object"}function dt(s){return ke(s)&&s!==null}function D(s){return s!=null}function fe(s){return!s.trim().length}function _e(s){return s==null?s===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(s)}const mt="Incorrect 'index' type",ft=s=>`Invalid value for key ${s}`,gt=s=>`Pattern length exceeds max of ${s}.`,xt=s=>`Missing ${s} property in key`,pt=s=>`Property 'weight' in key '${s}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class At{constructor(e){this._keys=[],this._keyMap={};let r=0;e.forEach(n=>{let a=Ie(n);this._keys.push(a),this._keyMap[a.id]=a,r+=a.weight}),this._keys.forEach(n=>{n.weight/=r})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ie(s){let e=null,r=null,n=null,a=1,c=null;if(O(s)||K(s))n=s,e=Fe(s),r=ge(s);else{if(!ve.call(s,"name"))throw new Error(xt("name"));const l=s.name;if(n=l,ve.call(s,"weight")&&(a=s.weight,a<=0))throw new Error(pt(l));e=Fe(l),r=ge(l),c=s.getFn}return{path:e,id:r,weight:a,src:n,getFn:c}}function Fe(s){return K(s)?s:s.split(".")}function ge(s){return K(s)?s.join("."):s}function jt(s,e){let r=[],n=!1;const a=(c,l,u)=>{if(D(c))if(!l[u])r.push(c);else{let o=l[u];const h=c[o];if(!D(h))return;if(u===l.length-1&&(O(h)||De(h)||ht(h)))r.push(ot(h));else if(K(h)){n=!0;for(let d=0,f=h.length;d<f;d+=1)a(h[d],l,u+1)}else l.length&&a(h,l,u+1)}};return a(s,O(e)?e.split("."):e,0),n?r:r[0]}const yt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Ct={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(s,e)=>s.score===e.score?s.idx<e.idx?-1:1:s.score<e.score?-1:1},wt={location:0,threshold:.6,distance:100},Nt={useExtendedSearch:!1,getFn:jt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var m={...Ct,...yt,...wt,...Nt};const Et=/[^ ]+/g;function bt(s=1,e=3){const r=new Map,n=Math.pow(10,e);return{get(a){const c=a.match(Et).length;if(r.has(c))return r.get(c);const l=1/Math.pow(c,.5*s),u=parseFloat(Math.round(l*n)/n);return r.set(c,u),u},clear(){r.clear()}}}class we{constructor({getFn:e=m.getFn,fieldNormWeight:r=m.fieldNormWeight}={}){this.norm=bt(r,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((r,n)=>{this._keysMap[r.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,O(this.docs[0])?this.docs.forEach((e,r)=>{this._addString(e,r)}):this.docs.forEach((e,r)=>{this._addObject(e,r)}),this.norm.clear())}add(e){const r=this.size();O(e)?this._addString(e,r):this._addObject(e,r)}removeAt(e){this.records.splice(e,1);for(let r=e,n=this.size();r<n;r+=1)this.records[r].i-=1}getValueForItemAtKeyId(e,r){return e[this._keysMap[r]]}size(){return this.records.length}_addString(e,r){if(!D(e)||fe(e))return;let n={v:e,i:r,n:this.norm.get(e)};this.records.push(n)}_addObject(e,r){let n={i:r,$:{}};this.keys.forEach((a,c)=>{let l=a.getFn?a.getFn(e):this.getFn(e,a.path);if(D(l)){if(K(l)){let u=[];const o=[{nestedArrIndex:-1,value:l}];for(;o.length;){const{nestedArrIndex:h,value:d}=o.pop();if(D(d))if(O(d)&&!fe(d)){let f={v:d,i:h,n:this.norm.get(d)};u.push(f)}else K(d)&&d.forEach((f,p)=>{o.push({nestedArrIndex:p,value:f})})}n.$[c]=u}else if(O(l)&&!fe(l)){let u={v:l,n:this.norm.get(l)};n.$[c]=u}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Le(s,e,{getFn:r=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const a=new we({getFn:r,fieldNormWeight:n});return a.setKeys(s.map(Ie)),a.setSources(e),a.create(),a}function vt(s,{getFn:e=m.getFn,fieldNormWeight:r=m.fieldNormWeight}={}){const{keys:n,records:a}=s,c=new we({getFn:e,fieldNormWeight:r});return c.setKeys(n),c.setIndexRecords(a),c}function re(s,{errors:e=0,currentLocation:r=0,expectedLocation:n=0,distance:a=m.distance,ignoreLocation:c=m.ignoreLocation}={}){const l=e/s.length;if(c)return l;const u=Math.abs(n-r);return a?l+u/a:u?1:l}function Ft(s=[],e=m.minMatchCharLength){let r=[],n=-1,a=-1,c=0;for(let l=s.length;c<l;c+=1){let u=s[c];u&&n===-1?n=c:!u&&n!==-1&&(a=c-1,a-n+1>=e&&r.push([n,a]),n=-1)}return s[c-1]&&c-n>=e&&r.push([n,c-1]),r}const U=32;function Mt(s,e,r,{location:n=m.location,distance:a=m.distance,threshold:c=m.threshold,findAllMatches:l=m.findAllMatches,minMatchCharLength:u=m.minMatchCharLength,includeMatches:o=m.includeMatches,ignoreLocation:h=m.ignoreLocation}={}){if(e.length>U)throw new Error(gt(U));const d=e.length,f=s.length,p=Math.max(0,Math.min(n,f));let x=c,j=p;const C=u>1||o,M=C?Array(f):[];let v;for(;(v=s.indexOf(e,j))>-1;){let E=re(e,{currentLocation:v,expectedLocation:p,distance:a,ignoreLocation:h});if(x=Math.min(E,x),j=v+d,C){let R=0;for(;R<d;)M[v+R]=1,R+=1}}j=-1;let k=[],F=1,L=d+f;const ie=1<<d-1;for(let E=0;E<d;E+=1){let R=0,_=L;for(;R<_;)re(e,{errors:E,currentLocation:p+_,expectedLocation:p,distance:a,ignoreLocation:h})<=x?R=_:L=_,_=Math.floor((L-R)/2+R);L=_;let G=Math.max(1,p-_+1),N=l?f:Math.min(p+_,f)+d,I=Array(N+2);I[N+1]=(1<<E)-1;for(let b=N;b>=G;b-=1){let W=b-1,ee=r[s.charAt(W)];if(C&&(M[W]=+!!ee),I[b]=(I[b+1]<<1|1)&ee,E&&(I[b]|=(k[b+1]|k[b])<<1|1|k[b+1]),I[b]&ie&&(F=re(e,{errors:E,currentLocation:W,expectedLocation:p,distance:a,ignoreLocation:h}),F<=x)){if(x=F,j=W,j<=p)break;G=Math.max(1,2*p-j)}}if(re(e,{errors:E+1,currentLocation:p,expectedLocation:p,distance:a,ignoreLocation:h})>x)break;k=I}const T={isMatch:j>=0,score:Math.max(.001,F)};if(C){const E=Ft(M,u);E.length?o&&(T.indices=E):T.isMatch=!1}return T}function St(s){let e={};for(let r=0,n=s.length;r<n;r+=1){const a=s.charAt(r);e[a]=(e[a]||0)|1<<n-r-1}return e}const ne=String.prototype.normalize?(s=>s.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(s=>s);class Te{constructor(e,{location:r=m.location,threshold:n=m.threshold,distance:a=m.distance,includeMatches:c=m.includeMatches,findAllMatches:l=m.findAllMatches,minMatchCharLength:u=m.minMatchCharLength,isCaseSensitive:o=m.isCaseSensitive,ignoreDiacritics:h=m.ignoreDiacritics,ignoreLocation:d=m.ignoreLocation}={}){if(this.options={location:r,threshold:n,distance:a,includeMatches:c,findAllMatches:l,minMatchCharLength:u,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d},e=o?e:e.toLowerCase(),e=h?ne(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const f=(x,j)=>{this.chunks.push({pattern:x,alphabet:St(x),startIndex:j})},p=this.pattern.length;if(p>U){let x=0;const j=p%U,C=p-j;for(;x<C;)f(this.pattern.substr(x,U),x),x+=U;if(j){const M=p-U;f(this.pattern.substr(M),M)}}else f(this.pattern,0)}searchIn(e){const{isCaseSensitive:r,ignoreDiacritics:n,includeMatches:a}=this.options;if(e=r?e:e.toLowerCase(),e=n?ne(e):e,this.pattern===e){let C={isMatch:!0,score:0};return a&&(C.indices=[[0,e.length-1]]),C}const{location:c,distance:l,threshold:u,findAllMatches:o,minMatchCharLength:h,ignoreLocation:d}=this.options;let f=[],p=0,x=!1;this.chunks.forEach(({pattern:C,alphabet:M,startIndex:v})=>{const{isMatch:k,score:F,indices:L}=Mt(e,C,M,{location:c+v,distance:l,threshold:u,findAllMatches:o,minMatchCharLength:h,includeMatches:a,ignoreLocation:d});k&&(x=!0),p+=F,k&&L&&(f=[...f,...L])});let j={isMatch:x,score:x?p/this.chunks.length:1};return x&&a&&(j.indices=f),j}}class V{constructor(e){this.pattern=e}static isMultiMatch(e){return Me(e,this.multiRegex)}static isSingleMatch(e){return Me(e,this.singleRegex)}search(){}}function Me(s,e){const r=s.match(e);return r?r[1]:null}class Bt extends V{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const r=e===this.pattern;return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class Dt extends V{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class kt extends V{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const r=e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class _t extends V{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const r=!e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class It extends V{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const r=e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Lt extends V{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const r=!e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class Re extends V{constructor(e,{location:r=m.location,threshold:n=m.threshold,distance:a=m.distance,includeMatches:c=m.includeMatches,findAllMatches:l=m.findAllMatches,minMatchCharLength:u=m.minMatchCharLength,isCaseSensitive:o=m.isCaseSensitive,ignoreDiacritics:h=m.ignoreDiacritics,ignoreLocation:d=m.ignoreLocation}={}){super(e),this._bitapSearch=new Te(e,{location:r,threshold:n,distance:a,includeMatches:c,findAllMatches:l,minMatchCharLength:u,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class $e extends V{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let r=0,n;const a=[],c=this.pattern.length;for(;(n=e.indexOf(this.pattern,r))>-1;)r=n+c,a.push([n,r-1]);const l=!!a.length;return{isMatch:l,score:l?0:1,indices:a}}}const xe=[Bt,$e,kt,_t,Lt,It,Dt,Re],Se=xe.length,Tt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Rt="|";function $t(s,e={}){return s.split(Rt).map(r=>{let n=r.trim().split(Tt).filter(c=>c&&!!c.trim()),a=[];for(let c=0,l=n.length;c<l;c+=1){const u=n[c];let o=!1,h=-1;for(;!o&&++h<Se;){const d=xe[h];let f=d.isMultiMatch(u);f&&(a.push(new d(f,e)),o=!0)}if(!o)for(h=-1;++h<Se;){const d=xe[h];let f=d.isSingleMatch(u);if(f){a.push(new d(f,e));break}}}return a})}const Ot=new Set([Re.type,$e.type]);class Pt{constructor(e,{isCaseSensitive:r=m.isCaseSensitive,ignoreDiacritics:n=m.ignoreDiacritics,includeMatches:a=m.includeMatches,minMatchCharLength:c=m.minMatchCharLength,ignoreLocation:l=m.ignoreLocation,findAllMatches:u=m.findAllMatches,location:o=m.location,threshold:h=m.threshold,distance:d=m.distance}={}){this.query=null,this.options={isCaseSensitive:r,ignoreDiacritics:n,includeMatches:a,minMatchCharLength:c,findAllMatches:u,ignoreLocation:l,location:o,threshold:h,distance:d},e=r?e:e.toLowerCase(),e=n?ne(e):e,this.pattern=e,this.query=$t(this.pattern,this.options)}static condition(e,r){return r.useExtendedSearch}searchIn(e){const r=this.query;if(!r)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:a,ignoreDiacritics:c}=this.options;e=a?e:e.toLowerCase(),e=c?ne(e):e;let l=0,u=[],o=0;for(let h=0,d=r.length;h<d;h+=1){const f=r[h];u.length=0,l=0;for(let p=0,x=f.length;p<x;p+=1){const j=f[p],{isMatch:C,indices:M,score:v}=j.search(e);if(C){if(l+=1,o+=v,n){const k=j.constructor.type;Ot.has(k)?u=[...u,...M]:u.push(M)}}else{o=0,l=0,u.length=0;break}}if(l){let p={isMatch:!0,score:o/l};return n&&(p.indices=u),p}}return{isMatch:!1,score:1}}}const pe=[];function Kt(...s){pe.push(...s)}function Ae(s,e){for(let r=0,n=pe.length;r<n;r+=1){let a=pe[r];if(a.condition(s,e))return new a(s,e)}return new Te(s,e)}const ae={AND:"$and",OR:"$or"},je={PATH:"$path",PATTERN:"$val"},ye=s=>!!(s[ae.AND]||s[ae.OR]),zt=s=>!!s[je.PATH],Vt=s=>!K(s)&&ke(s)&&!ye(s),Be=s=>({[ae.AND]:Object.keys(s).map(e=>({[e]:s[e]}))});function Oe(s,e,{auto:r=!0}={}){const n=a=>{let c=Object.keys(a);const l=zt(a);if(!l&&c.length>1&&!ye(a))return n(Be(a));if(Vt(a)){const o=l?a[je.PATH]:c[0],h=l?a[je.PATTERN]:a[o];if(!O(h))throw new Error(ft(o));const d={keyId:ge(o),pattern:h};return r&&(d.searcher=Ae(h,e)),d}let u={children:[],operator:c[0]};return c.forEach(o=>{const h=a[o];K(h)&&h.forEach(d=>{u.children.push(n(d))})}),u};return ye(s)||(s=Be(s)),n(s)}function Wt(s,{ignoreFieldNorm:e=m.ignoreFieldNorm}){s.forEach(r=>{let n=1;r.matches.forEach(({key:a,norm:c,score:l})=>{const u=a?a.weight:null;n*=Math.pow(l===0&&u?Number.EPSILON:l,(u||1)*(e?1:c))}),r.score=n})}function Ut(s,e){const r=s.matches;e.matches=[],D(r)&&r.forEach(n=>{if(!D(n.indices)||!n.indices.length)return;const{indices:a,value:c}=n;let l={indices:a,value:c};n.key&&(l.key=n.key.src),n.idx>-1&&(l.refIndex=n.idx),e.matches.push(l)})}function Gt(s,e){e.score=s.score}function Ht(s,e,{includeMatches:r=m.includeMatches,includeScore:n=m.includeScore}={}){const a=[];return r&&a.push(Ut),n&&a.push(Gt),s.map(c=>{const{idx:l}=c,u={item:e[l],refIndex:l};return a.length&&a.forEach(o=>{o(c,u)}),u})}class H{constructor(e,r={},n){this.options={...m,...r},this.options.useExtendedSearch,this._keyStore=new At(this.options.keys),this.setCollection(e,n)}setCollection(e,r){if(this._docs=e,r&&!(r instanceof we))throw new Error(mt);this._myIndex=r||Le(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){D(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const r=[];for(let n=0,a=this._docs.length;n<a;n+=1){const c=this._docs[n];e(c,n)&&(this.removeAt(n),n-=1,a-=1,r.push(c))}return r}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:r=-1}={}){const{includeMatches:n,includeScore:a,shouldSort:c,sortFn:l,ignoreFieldNorm:u}=this.options;let o=O(e)?O(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return Wt(o,{ignoreFieldNorm:u}),c&&o.sort(l),De(r)&&r>-1&&(o=o.slice(0,r)),Ht(o,this._docs,{includeMatches:n,includeScore:a})}_searchStringList(e){const r=Ae(e,this.options),{records:n}=this._myIndex,a=[];return n.forEach(({v:c,i:l,n:u})=>{if(!D(c))return;const{isMatch:o,score:h,indices:d}=r.searchIn(c);o&&a.push({item:c,idx:l,matches:[{score:h,value:c,norm:u,indices:d}]})}),a}_searchLogical(e){const r=Oe(e,this.options),n=(u,o,h)=>{if(!u.children){const{keyId:f,searcher:p}=u,x=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(o,f),searcher:p});return x&&x.length?[{idx:h,item:o,matches:x}]:[]}const d=[];for(let f=0,p=u.children.length;f<p;f+=1){const x=u.children[f],j=n(x,o,h);if(j.length)d.push(...j);else if(u.operator===ae.AND)return[]}return d},a=this._myIndex.records,c={},l=[];return a.forEach(({$:u,i:o})=>{if(D(u)){let h=n(r,u,o);h.length&&(c[o]||(c[o]={idx:o,item:u,matches:[]},l.push(c[o])),h.forEach(({matches:d})=>{c[o].matches.push(...d)}))}}),l}_searchObjectList(e){const r=Ae(e,this.options),{keys:n,records:a}=this._myIndex,c=[];return a.forEach(({$:l,i:u})=>{if(!D(l))return;let o=[];n.forEach((h,d)=>{o.push(...this._findMatches({key:h,value:l[d],searcher:r}))}),o.length&&c.push({idx:u,item:l,matches:o})}),c}_findMatches({key:e,value:r,searcher:n}){if(!D(r))return[];let a=[];if(K(r))r.forEach(({v:c,i:l,n:u})=>{if(!D(c))return;const{isMatch:o,score:h,indices:d}=n.searchIn(c);o&&a.push({score:h,key:e,value:c,idx:l,norm:u,indices:d})});else{const{v:c,n:l}=r,{isMatch:u,score:o,indices:h}=n.searchIn(c);u&&a.push({score:o,key:e,value:c,norm:l,indices:h})}return a}}H.version="7.1.0";H.createIndex=Le;H.parseIndex=vt;H.config=m;H.parseQuery=Oe;Kt(Pt);function Qt(s){switch(s){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}const q=20;function ns(){const[s]=Ke(),e=ze(),r=Ve(),[n,a]=A.useState([]),[c,l]=A.useState([]),[u,o]=A.useState(!0),[h,d]=A.useState(null),[f,p]=A.useState(s.get("status")||"_default"),[x,j]=A.useState(s.get("priority")||"all"),[C,M]=A.useState(s.get("search")||""),[v,k]=A.useState(s.get("sortBy")||"created"),[F,L]=A.useState(s.get("order")||"desc"),[ie,T]=A.useState(()=>{const i=parseInt(s.get("page")||"1",10);return Number.isNaN(i)||i<1?1:i}),[E,R]=A.useState(!1),_=A.useRef(null),G=[f!=="_default",x!=="all",v!=="created",F!=="desc"].filter(Boolean).length,N=A.useCallback(i=>{const g=new URLSearchParams(s);Object.entries(i).forEach(([S,z])=>{z&&z!=="all"&&z!=="_default"&&z!==""?g.set(S,z):g.delete(S)});const y=g.toString(),w=y?`?${y}`:"";e(`${r.pathname}${w}`)},[s,e,r.pathname]),I=A.useCallback(i=>{p(i),T(1),N({status:i==="_default"?null:i,page:null})},[N]),Q=A.useCallback(i=>{j(i),T(1),N({priority:i==="all"?null:i,page:null})},[N]),b=A.useCallback(i=>{M(i),T(1),N({search:i||null,page:null})},[N]),W=A.useCallback(i=>{k(i),T(1),N({sortBy:i==="created"?null:i,page:null})},[N]),ee=A.useCallback(()=>{const i=F==="asc"?"desc":"asc";L(i),T(1),N({order:i==="desc"?null:i,page:null})},[F,N]),ce=A.useCallback(i=>{T(i),N({page:i===1?null:String(i)}),window.scrollTo({top:0,behavior:"smooth"})},[N]),le=A.useCallback(i=>{if(i.key==="s"||i.key==="S"){const g=document.activeElement;g?.tagName==="INPUT"||g?.tagName==="TEXTAREA"||g?.getAttribute("contenteditable")==="true"||(i.preventDefault(),_.current?.focus())}},[]);A.useEffect(()=>(document.addEventListener("keydown",le),()=>{document.removeEventListener("keydown",le)}),[le]);const Ne=A.useMemo(()=>{const i={keys:[{name:"title",weight:.4},{name:"intent",weight:.3},{name:"id",weight:.2},{name:"author.name",weight:.05},{name:"metadata.tags",weight:.05}],threshold:.3,includeScore:!0};return new H(n,i)},[n]);A.useEffect(()=>{async function i(){try{o(!0);const y=await(await fetch(`${Xe}/api/v1/tasks`)).json();y.success?(a(y.data),l(y.data)):d(y.error?.message||"Failed to fetch tasks")}catch(g){d(g instanceof Error?g.message:"Unknown error")}finally{o(!1)}}i()},[]),A.useEffect(()=>{let i=n;if(f==="_default"?i=i.filter(g=>Ze.includes(g.status)):f!=="all"&&(i=i.filter(g=>g.status===f)),x!=="all"&&(i=i.filter(g=>g.metadata.priority===x)),C.trim()){const g=Ne.search(C),y=new Set(g.map(w=>w.item.id));i=i.filter(w=>y.has(w.id))}i=i.sort((g,y)=>{let w,S;switch(v){case"created":{w=new Date(g.metadata.createdAt).getTime(),S=new Date(y.metadata.createdAt).getTime();break}case"updated":{w=new Date(g.metadata.updatedAt).getTime(),S=new Date(y.metadata.updatedAt).getTime();break}case"status":{w=g.status,S=y.status;break}case"priority":{const z={critical:4,high:3,medium:2,low:1};w=z[g.metadata.priority]||0,S=z[y.metadata.priority]||0;break}case"intent":{w=(g.title||g.intent||"").toLowerCase(),S=(y.title||y.intent||"").toLowerCase();break}default:w=new Date(g.metadata.createdAt).getTime(),S=new Date(y.metadata.createdAt).getTime()}return F==="asc"?w<S?-1:w>S?1:0:w>S?-1:w<S?1:0}),l(i)},[n,f,x,C,v,F,Ne]);const Y=Math.max(1,Math.ceil(c.length/q)),$=Math.min(ie,Y),Pe=c.slice(($-1)*q,$*q);return h?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your agents"})]}),t.jsx(P,{asChild:!0,children:t.jsxs(te,{to:"/tasks/new",children:[t.jsx(ue,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsx("div",{className:"text-center",children:t.jsxs("p",{className:"text-destructive",children:["Error: ",h]})})})})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your agents"})]}),t.jsx(P,{asChild:!0,children:t.jsxs(te,{to:"/tasks/new",children:[t.jsx(ue,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx(tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),t.jsx(We,{ref:_,placeholder:"Search tasks...",value:C,onChange:i=>b(i.target.value),className:"pl-9 pr-20 h-11 bg-muted/40 border-muted-foreground/20 focus:bg-background transition-colors"}),t.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2",children:C?t.jsx("button",{onClick:()=>b(""),className:"h-5 w-5 rounded-full bg-muted-foreground/20 hover:bg-muted-foreground/30 flex items-center justify-center transition-colors",children:t.jsx(X,{className:"h-3 w-3"})}):t.jsx(Ue,{children:t.jsx(Ge,{children:"S"})})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:()=>R(!E),className:"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg border border-muted-foreground/20 hover:bg-muted/50 transition-colors",children:[t.jsx(be,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Filters & Sort"}),t.jsx("span",{className:"sm:hidden",children:"Filters"}),G>0&&t.jsx("span",{className:"flex items-center justify-center h-5 w-5 text-xs font-bold rounded-full bg-primary text-primary-foreground",children:G}),E?t.jsx(st,{className:"h-4 w-4 ml-1"}):t.jsx(He,{className:"h-4 w-4 ml-1"})]}),t.jsxs("div",{className:"flex-1 flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[f!=="_default"&&t.jsxs("button",{onClick:()=>I("_default"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors whitespace-nowrap",children:[f==="all"?"All statuses":Ee(f),t.jsx(X,{className:"h-3 w-3"})]}),x!=="all"&&t.jsxs("button",{onClick:()=>Q("all"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors whitespace-nowrap",children:[x," priority",t.jsx(X,{className:"h-3 w-3"})]}),(v!=="created"||F!=="desc")&&t.jsxs("button",{onClick:()=>{W("created"),L("desc"),N({sortBy:null,order:null})},className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-purple-500/15 text-purple-600 dark:text-purple-400 hover:bg-purple-500/25 transition-colors whitespace-nowrap",children:[v," ",F==="asc"?"↑":"↓",t.jsx(X,{className:"h-3 w-3"})]})]}),!u&&t.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[c.length," result",c.length!==1?"s":""]})]}),E&&t.jsxs("div",{className:"p-4 rounded-lg border border-muted-foreground/20 bg-muted/30 space-y-4 animate-in slide-in-from-top-2 duration-200",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Status"}),t.jsxs(oe,{value:f,onValueChange:I,children:[t.jsx(he,{className:"w-full bg-background",children:t.jsx(de,{placeholder:"Filter by status"})}),t.jsxs(me,{children:[t.jsx(B,{value:"_default",children:"Active (Default)"}),t.jsx(B,{value:"all",children:"All statuses"}),qe.map(i=>t.jsx(B,{value:i,children:Ee(i)},i))]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Priority"}),t.jsxs(oe,{value:x,onValueChange:Q,children:[t.jsx(he,{className:"w-full bg-background",children:t.jsx(de,{placeholder:"Filter by priority"})}),t.jsxs(me,{children:[t.jsx(B,{value:"all",children:"All priorities"}),t.jsx(B,{value:"low",children:"Low"}),t.jsx(B,{value:"medium",children:"Medium"}),t.jsx(B,{value:"high",children:"High"}),t.jsx(B,{value:"critical",children:"Critical"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Sort By"}),t.jsxs(oe,{value:v,onValueChange:i=>W(i),children:[t.jsx(he,{className:"w-full bg-background",children:t.jsx(de,{})}),t.jsxs(me,{children:[t.jsx(B,{value:"created",children:"Created Date"}),t.jsx(B,{value:"updated",children:"Updated Date"}),t.jsx(B,{value:"status",children:"Status"}),t.jsx(B,{value:"priority",children:"Priority"}),t.jsx(B,{value:"intent",children:"Title"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Order"}),t.jsx(P,{variant:"outline",onClick:ee,className:"w-full justify-between bg-background",children:F==="asc"?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Ascending"}),t.jsx(ct,{className:"h-4 w-4"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Descending"}),t.jsx(at,{className:"h-4 w-4"})]})})]})]}),G>0&&t.jsx("div",{className:"pt-2 border-t border-muted-foreground/10",children:t.jsxs(P,{variant:"ghost",size:"sm",onClick:()=>{I("_default"),Q("all"),b("")},className:"text-muted-foreground hover:text-foreground",children:[t.jsx(X,{className:"h-3 w-3 mr-1"}),"Reset all filters"]})})]})]}),u?t.jsx("div",{className:"space-y-3",children:Array.from({length:6}).map((i,g)=>t.jsx(J,{className:"overflow-hidden",children:t.jsx(Z,{className:"py-4",children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsx("div",{className:"h-5 bg-muted rounded w-2/3 animate-pulse"}),t.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[t.jsx("div",{className:"h-5 w-14 bg-muted rounded-full animate-pulse"}),t.jsx("div",{className:"h-5 w-14 bg-muted rounded-full animate-pulse"})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("div",{className:"h-3.5 bg-muted rounded w-full animate-pulse"}),t.jsx("div",{className:"h-3.5 bg-muted rounded w-4/5 animate-pulse"})]}),t.jsxs("div",{className:"flex justify-between items-center pt-1",children:[t.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"}),t.jsx("div",{className:"h-3 bg-muted rounded w-1/6 animate-pulse"})]})]})})},g))}):c.length===0&&n.length>0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(be,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No tasks match your filters"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try adjusting your status or priority filters."}),t.jsx(P,{variant:"outline",className:"mt-4",onClick:()=>{I("_default"),Q("all"),b("")},children:"Clear Filters"})]})})}):n.length===0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Qe,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No tasks yet"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first task to get started."}),t.jsx(P,{asChild:!0,className:"mt-4",children:t.jsxs(te,{to:"/tasks/new",children:[t.jsx(ue,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"space-y-3",children:Pe.map(i=>t.jsx(te,{to:`/tasks/${i.id}`,className:"block",children:t.jsx(J,{className:"hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:t.jsx(Z,{className:"py-4",children:t.jsx("div",{className:"flex justify-between items-start gap-4",children:t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsx(Je,{className:"text-base leading-tight",children:i.title||i.intent}),t.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[i.metadata.priority&&t.jsx(se,{variant:Qt(i.metadata.priority),className:"text-xs",children:i.metadata.priority}),t.jsx(se,{variant:et(i.status),className:"text-xs",children:i.status})]})]}),i.content&&t.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[i.content.split(`
17
- `).slice(0,2).join(" ").substring(0,150),i.content.length>150?"...":""]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"text-xs text-muted-foreground",children:[i.id," • by ",i.author.name," • ",new Date(i.metadata.createdAt).toLocaleDateString()]}),t.jsxs("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[i.planSteps.length>0&&t.jsxs("span",{children:[i.planSteps.length," step",i.planSteps.length!==1?"s":""]}),i.metadata.tags&&i.metadata.tags.length>0&&t.jsxs("span",{children:[i.metadata.tags.length," tag",i.metadata.tags.length!==1?"s":""]})]})]}),i.metadata.tags&&i.metadata.tags.length>0&&t.jsxs("div",{className:"flex gap-1 mt-2",children:[i.metadata.tags.slice(0,3).map(g=>t.jsx(se,{variant:"outline",className:"text-xs",children:g},g)),i.metadata.tags.length>3&&t.jsxs(se,{variant:"outline",className:"text-xs",children:["+",i.metadata.tags.length-3]})]})]})})})})},i.id))}),Y>1&&t.jsxs("div",{className:"flex items-center justify-between pt-2",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",($-1)*q+1,"–",Math.min($*q,c.length)," of ",c.length]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(P,{variant:"outline",size:"sm",disabled:$<=1,onClick:()=>ce($-1),children:t.jsx(rt,{className:"h-4 w-4"})}),Array.from({length:Y},(i,g)=>g+1).filter(i=>i===1||i===Y||Math.abs(i-$)<=1).reduce((i,g,y,w)=>(y>0&&g-w[y-1]>1&&i.push("ellipsis"),i.push(g),i),[]).map((i,g)=>i==="ellipsis"?t.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:"…"},`e${g}`):t.jsx(P,{variant:i===$?"default":"outline",size:"sm",className:"min-w-[2rem]",onClick:()=>ce(i),children:i},i)),t.jsx(P,{variant:"outline",size:"sm",disabled:$>=Y,onClick:()=>ce($+1),children:t.jsx(Ye,{className:"h-4 w-4"})})]})]})]})]})}export{ns as default};
16
+ */const lt=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],be=Ce("funnel",lt);function K(s){return Array.isArray?Array.isArray(s):_e(s)==="[object Array]"}function ut(s){if(typeof s=="string")return s;let e=s+"";return e=="0"&&1/s==-1/0?"-0":e}function ot(s){return s==null?"":ut(s)}function O(s){return typeof s=="string"}function De(s){return typeof s=="number"}function ht(s){return s===!0||s===!1||dt(s)&&_e(s)=="[object Boolean]"}function ke(s){return typeof s=="object"}function dt(s){return ke(s)&&s!==null}function D(s){return s!=null}function fe(s){return!s.trim().length}function _e(s){return s==null?s===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(s)}const mt="Incorrect 'index' type",ft=s=>`Invalid value for key ${s}`,gt=s=>`Pattern length exceeds max of ${s}.`,xt=s=>`Missing ${s} property in key`,pt=s=>`Property 'weight' in key '${s}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class At{constructor(e){this._keys=[],this._keyMap={};let r=0;e.forEach(n=>{let a=Ie(n);this._keys.push(a),this._keyMap[a.id]=a,r+=a.weight}),this._keys.forEach(n=>{n.weight/=r})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ie(s){let e=null,r=null,n=null,a=1,c=null;if(O(s)||K(s))n=s,e=Fe(s),r=ge(s);else{if(!ve.call(s,"name"))throw new Error(xt("name"));const l=s.name;if(n=l,ve.call(s,"weight")&&(a=s.weight,a<=0))throw new Error(pt(l));e=Fe(l),r=ge(l),c=s.getFn}return{path:e,id:r,weight:a,src:n,getFn:c}}function Fe(s){return K(s)?s:s.split(".")}function ge(s){return K(s)?s.join("."):s}function jt(s,e){let r=[],n=!1;const a=(c,l,u)=>{if(D(c))if(!l[u])r.push(c);else{let o=l[u];const h=c[o];if(!D(h))return;if(u===l.length-1&&(O(h)||De(h)||ht(h)))r.push(ot(h));else if(K(h)){n=!0;for(let d=0,f=h.length;d<f;d+=1)a(h[d],l,u+1)}else l.length&&a(h,l,u+1)}};return a(s,O(e)?e.split("."):e,0),n?r:r[0]}const yt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Ct={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(s,e)=>s.score===e.score?s.idx<e.idx?-1:1:s.score<e.score?-1:1},Nt={location:0,threshold:.6,distance:100},wt={useExtendedSearch:!1,getFn:jt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var m={...Ct,...yt,...Nt,...wt};const Et=/[^ ]+/g;function bt(s=1,e=3){const r=new Map,n=Math.pow(10,e);return{get(a){const c=a.match(Et).length;if(r.has(c))return r.get(c);const l=1/Math.pow(c,.5*s),u=parseFloat(Math.round(l*n)/n);return r.set(c,u),u},clear(){r.clear()}}}class Ne{constructor({getFn:e=m.getFn,fieldNormWeight:r=m.fieldNormWeight}={}){this.norm=bt(r,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((r,n)=>{this._keysMap[r.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,O(this.docs[0])?this.docs.forEach((e,r)=>{this._addString(e,r)}):this.docs.forEach((e,r)=>{this._addObject(e,r)}),this.norm.clear())}add(e){const r=this.size();O(e)?this._addString(e,r):this._addObject(e,r)}removeAt(e){this.records.splice(e,1);for(let r=e,n=this.size();r<n;r+=1)this.records[r].i-=1}getValueForItemAtKeyId(e,r){return e[this._keysMap[r]]}size(){return this.records.length}_addString(e,r){if(!D(e)||fe(e))return;let n={v:e,i:r,n:this.norm.get(e)};this.records.push(n)}_addObject(e,r){let n={i:r,$:{}};this.keys.forEach((a,c)=>{let l=a.getFn?a.getFn(e):this.getFn(e,a.path);if(D(l)){if(K(l)){let u=[];const o=[{nestedArrIndex:-1,value:l}];for(;o.length;){const{nestedArrIndex:h,value:d}=o.pop();if(D(d))if(O(d)&&!fe(d)){let f={v:d,i:h,n:this.norm.get(d)};u.push(f)}else K(d)&&d.forEach((f,p)=>{o.push({nestedArrIndex:p,value:f})})}n.$[c]=u}else if(O(l)&&!fe(l)){let u={v:l,n:this.norm.get(l)};n.$[c]=u}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Le(s,e,{getFn:r=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const a=new Ne({getFn:r,fieldNormWeight:n});return a.setKeys(s.map(Ie)),a.setSources(e),a.create(),a}function vt(s,{getFn:e=m.getFn,fieldNormWeight:r=m.fieldNormWeight}={}){const{keys:n,records:a}=s,c=new Ne({getFn:e,fieldNormWeight:r});return c.setKeys(n),c.setIndexRecords(a),c}function re(s,{errors:e=0,currentLocation:r=0,expectedLocation:n=0,distance:a=m.distance,ignoreLocation:c=m.ignoreLocation}={}){const l=e/s.length;if(c)return l;const u=Math.abs(n-r);return a?l+u/a:u?1:l}function Ft(s=[],e=m.minMatchCharLength){let r=[],n=-1,a=-1,c=0;for(let l=s.length;c<l;c+=1){let u=s[c];u&&n===-1?n=c:!u&&n!==-1&&(a=c-1,a-n+1>=e&&r.push([n,a]),n=-1)}return s[c-1]&&c-n>=e&&r.push([n,c-1]),r}const U=32;function Mt(s,e,r,{location:n=m.location,distance:a=m.distance,threshold:c=m.threshold,findAllMatches:l=m.findAllMatches,minMatchCharLength:u=m.minMatchCharLength,includeMatches:o=m.includeMatches,ignoreLocation:h=m.ignoreLocation}={}){if(e.length>U)throw new Error(gt(U));const d=e.length,f=s.length,p=Math.max(0,Math.min(n,f));let x=c,j=p;const C=u>1||o,M=C?Array(f):[];let v;for(;(v=s.indexOf(e,j))>-1;){let E=re(e,{currentLocation:v,expectedLocation:p,distance:a,ignoreLocation:h});if(x=Math.min(E,x),j=v+d,C){let R=0;for(;R<d;)M[v+R]=1,R+=1}}j=-1;let k=[],F=1,L=d+f;const ie=1<<d-1;for(let E=0;E<d;E+=1){let R=0,_=L;for(;R<_;)re(e,{errors:E,currentLocation:p+_,expectedLocation:p,distance:a,ignoreLocation:h})<=x?R=_:L=_,_=Math.floor((L-R)/2+R);L=_;let G=Math.max(1,p-_+1),w=l?f:Math.min(p+_,f)+d,I=Array(w+2);I[w+1]=(1<<E)-1;for(let b=w;b>=G;b-=1){let W=b-1,ee=r[s.charAt(W)];if(C&&(M[W]=+!!ee),I[b]=(I[b+1]<<1|1)&ee,E&&(I[b]|=(k[b+1]|k[b])<<1|1|k[b+1]),I[b]&ie&&(F=re(e,{errors:E,currentLocation:W,expectedLocation:p,distance:a,ignoreLocation:h}),F<=x)){if(x=F,j=W,j<=p)break;G=Math.max(1,2*p-j)}}if(re(e,{errors:E+1,currentLocation:p,expectedLocation:p,distance:a,ignoreLocation:h})>x)break;k=I}const T={isMatch:j>=0,score:Math.max(.001,F)};if(C){const E=Ft(M,u);E.length?o&&(T.indices=E):T.isMatch=!1}return T}function St(s){let e={};for(let r=0,n=s.length;r<n;r+=1){const a=s.charAt(r);e[a]=(e[a]||0)|1<<n-r-1}return e}const ne=String.prototype.normalize?(s=>s.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(s=>s);class Te{constructor(e,{location:r=m.location,threshold:n=m.threshold,distance:a=m.distance,includeMatches:c=m.includeMatches,findAllMatches:l=m.findAllMatches,minMatchCharLength:u=m.minMatchCharLength,isCaseSensitive:o=m.isCaseSensitive,ignoreDiacritics:h=m.ignoreDiacritics,ignoreLocation:d=m.ignoreLocation}={}){if(this.options={location:r,threshold:n,distance:a,includeMatches:c,findAllMatches:l,minMatchCharLength:u,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d},e=o?e:e.toLowerCase(),e=h?ne(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const f=(x,j)=>{this.chunks.push({pattern:x,alphabet:St(x),startIndex:j})},p=this.pattern.length;if(p>U){let x=0;const j=p%U,C=p-j;for(;x<C;)f(this.pattern.substr(x,U),x),x+=U;if(j){const M=p-U;f(this.pattern.substr(M),M)}}else f(this.pattern,0)}searchIn(e){const{isCaseSensitive:r,ignoreDiacritics:n,includeMatches:a}=this.options;if(e=r?e:e.toLowerCase(),e=n?ne(e):e,this.pattern===e){let C={isMatch:!0,score:0};return a&&(C.indices=[[0,e.length-1]]),C}const{location:c,distance:l,threshold:u,findAllMatches:o,minMatchCharLength:h,ignoreLocation:d}=this.options;let f=[],p=0,x=!1;this.chunks.forEach(({pattern:C,alphabet:M,startIndex:v})=>{const{isMatch:k,score:F,indices:L}=Mt(e,C,M,{location:c+v,distance:l,threshold:u,findAllMatches:o,minMatchCharLength:h,includeMatches:a,ignoreLocation:d});k&&(x=!0),p+=F,k&&L&&(f=[...f,...L])});let j={isMatch:x,score:x?p/this.chunks.length:1};return x&&a&&(j.indices=f),j}}class V{constructor(e){this.pattern=e}static isMultiMatch(e){return Me(e,this.multiRegex)}static isSingleMatch(e){return Me(e,this.singleRegex)}search(){}}function Me(s,e){const r=s.match(e);return r?r[1]:null}class Bt extends V{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const r=e===this.pattern;return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class Dt extends V{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class kt extends V{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const r=e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class _t extends V{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const r=!e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class It extends V{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const r=e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Lt extends V{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const r=!e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class Re extends V{constructor(e,{location:r=m.location,threshold:n=m.threshold,distance:a=m.distance,includeMatches:c=m.includeMatches,findAllMatches:l=m.findAllMatches,minMatchCharLength:u=m.minMatchCharLength,isCaseSensitive:o=m.isCaseSensitive,ignoreDiacritics:h=m.ignoreDiacritics,ignoreLocation:d=m.ignoreLocation}={}){super(e),this._bitapSearch=new Te(e,{location:r,threshold:n,distance:a,includeMatches:c,findAllMatches:l,minMatchCharLength:u,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class $e extends V{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let r=0,n;const a=[],c=this.pattern.length;for(;(n=e.indexOf(this.pattern,r))>-1;)r=n+c,a.push([n,r-1]);const l=!!a.length;return{isMatch:l,score:l?0:1,indices:a}}}const xe=[Bt,$e,kt,_t,Lt,It,Dt,Re],Se=xe.length,Tt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Rt="|";function $t(s,e={}){return s.split(Rt).map(r=>{let n=r.trim().split(Tt).filter(c=>c&&!!c.trim()),a=[];for(let c=0,l=n.length;c<l;c+=1){const u=n[c];let o=!1,h=-1;for(;!o&&++h<Se;){const d=xe[h];let f=d.isMultiMatch(u);f&&(a.push(new d(f,e)),o=!0)}if(!o)for(h=-1;++h<Se;){const d=xe[h];let f=d.isSingleMatch(u);if(f){a.push(new d(f,e));break}}}return a})}const Ot=new Set([Re.type,$e.type]);class Pt{constructor(e,{isCaseSensitive:r=m.isCaseSensitive,ignoreDiacritics:n=m.ignoreDiacritics,includeMatches:a=m.includeMatches,minMatchCharLength:c=m.minMatchCharLength,ignoreLocation:l=m.ignoreLocation,findAllMatches:u=m.findAllMatches,location:o=m.location,threshold:h=m.threshold,distance:d=m.distance}={}){this.query=null,this.options={isCaseSensitive:r,ignoreDiacritics:n,includeMatches:a,minMatchCharLength:c,findAllMatches:u,ignoreLocation:l,location:o,threshold:h,distance:d},e=r?e:e.toLowerCase(),e=n?ne(e):e,this.pattern=e,this.query=$t(this.pattern,this.options)}static condition(e,r){return r.useExtendedSearch}searchIn(e){const r=this.query;if(!r)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:a,ignoreDiacritics:c}=this.options;e=a?e:e.toLowerCase(),e=c?ne(e):e;let l=0,u=[],o=0;for(let h=0,d=r.length;h<d;h+=1){const f=r[h];u.length=0,l=0;for(let p=0,x=f.length;p<x;p+=1){const j=f[p],{isMatch:C,indices:M,score:v}=j.search(e);if(C){if(l+=1,o+=v,n){const k=j.constructor.type;Ot.has(k)?u=[...u,...M]:u.push(M)}}else{o=0,l=0,u.length=0;break}}if(l){let p={isMatch:!0,score:o/l};return n&&(p.indices=u),p}}return{isMatch:!1,score:1}}}const pe=[];function Kt(...s){pe.push(...s)}function Ae(s,e){for(let r=0,n=pe.length;r<n;r+=1){let a=pe[r];if(a.condition(s,e))return new a(s,e)}return new Te(s,e)}const ae={AND:"$and",OR:"$or"},je={PATH:"$path",PATTERN:"$val"},ye=s=>!!(s[ae.AND]||s[ae.OR]),zt=s=>!!s[je.PATH],Vt=s=>!K(s)&&ke(s)&&!ye(s),Be=s=>({[ae.AND]:Object.keys(s).map(e=>({[e]:s[e]}))});function Oe(s,e,{auto:r=!0}={}){const n=a=>{let c=Object.keys(a);const l=zt(a);if(!l&&c.length>1&&!ye(a))return n(Be(a));if(Vt(a)){const o=l?a[je.PATH]:c[0],h=l?a[je.PATTERN]:a[o];if(!O(h))throw new Error(ft(o));const d={keyId:ge(o),pattern:h};return r&&(d.searcher=Ae(h,e)),d}let u={children:[],operator:c[0]};return c.forEach(o=>{const h=a[o];K(h)&&h.forEach(d=>{u.children.push(n(d))})}),u};return ye(s)||(s=Be(s)),n(s)}function Wt(s,{ignoreFieldNorm:e=m.ignoreFieldNorm}){s.forEach(r=>{let n=1;r.matches.forEach(({key:a,norm:c,score:l})=>{const u=a?a.weight:null;n*=Math.pow(l===0&&u?Number.EPSILON:l,(u||1)*(e?1:c))}),r.score=n})}function Ut(s,e){const r=s.matches;e.matches=[],D(r)&&r.forEach(n=>{if(!D(n.indices)||!n.indices.length)return;const{indices:a,value:c}=n;let l={indices:a,value:c};n.key&&(l.key=n.key.src),n.idx>-1&&(l.refIndex=n.idx),e.matches.push(l)})}function Gt(s,e){e.score=s.score}function Ht(s,e,{includeMatches:r=m.includeMatches,includeScore:n=m.includeScore}={}){const a=[];return r&&a.push(Ut),n&&a.push(Gt),s.map(c=>{const{idx:l}=c,u={item:e[l],refIndex:l};return a.length&&a.forEach(o=>{o(c,u)}),u})}class H{constructor(e,r={},n){this.options={...m,...r},this.options.useExtendedSearch,this._keyStore=new At(this.options.keys),this.setCollection(e,n)}setCollection(e,r){if(this._docs=e,r&&!(r instanceof Ne))throw new Error(mt);this._myIndex=r||Le(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){D(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const r=[];for(let n=0,a=this._docs.length;n<a;n+=1){const c=this._docs[n];e(c,n)&&(this.removeAt(n),n-=1,a-=1,r.push(c))}return r}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:r=-1}={}){const{includeMatches:n,includeScore:a,shouldSort:c,sortFn:l,ignoreFieldNorm:u}=this.options;let o=O(e)?O(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return Wt(o,{ignoreFieldNorm:u}),c&&o.sort(l),De(r)&&r>-1&&(o=o.slice(0,r)),Ht(o,this._docs,{includeMatches:n,includeScore:a})}_searchStringList(e){const r=Ae(e,this.options),{records:n}=this._myIndex,a=[];return n.forEach(({v:c,i:l,n:u})=>{if(!D(c))return;const{isMatch:o,score:h,indices:d}=r.searchIn(c);o&&a.push({item:c,idx:l,matches:[{score:h,value:c,norm:u,indices:d}]})}),a}_searchLogical(e){const r=Oe(e,this.options),n=(u,o,h)=>{if(!u.children){const{keyId:f,searcher:p}=u,x=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(o,f),searcher:p});return x&&x.length?[{idx:h,item:o,matches:x}]:[]}const d=[];for(let f=0,p=u.children.length;f<p;f+=1){const x=u.children[f],j=n(x,o,h);if(j.length)d.push(...j);else if(u.operator===ae.AND)return[]}return d},a=this._myIndex.records,c={},l=[];return a.forEach(({$:u,i:o})=>{if(D(u)){let h=n(r,u,o);h.length&&(c[o]||(c[o]={idx:o,item:u,matches:[]},l.push(c[o])),h.forEach(({matches:d})=>{c[o].matches.push(...d)}))}}),l}_searchObjectList(e){const r=Ae(e,this.options),{keys:n,records:a}=this._myIndex,c=[];return a.forEach(({$:l,i:u})=>{if(!D(l))return;let o=[];n.forEach((h,d)=>{o.push(...this._findMatches({key:h,value:l[d],searcher:r}))}),o.length&&c.push({idx:u,item:l,matches:o})}),c}_findMatches({key:e,value:r,searcher:n}){if(!D(r))return[];let a=[];if(K(r))r.forEach(({v:c,i:l,n:u})=>{if(!D(c))return;const{isMatch:o,score:h,indices:d}=n.searchIn(c);o&&a.push({score:h,key:e,value:c,idx:l,norm:u,indices:d})});else{const{v:c,n:l}=r,{isMatch:u,score:o,indices:h}=n.searchIn(c);u&&a.push({score:o,key:e,value:c,norm:l,indices:h})}return a}}H.version="7.1.0";H.createIndex=Le;H.parseIndex=vt;H.config=m;H.parseQuery=Oe;Kt(Pt);function Qt(s){switch(s){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}const q=20;function ns(){const[s]=Ke(),e=ze(),r=Ve(),[n,a]=A.useState([]),[c,l]=A.useState([]),[u,o]=A.useState(!0),[h,d]=A.useState(null),[f,p]=A.useState(s.get("status")||"_default"),[x,j]=A.useState(s.get("priority")||"all"),[C,M]=A.useState(s.get("search")||""),[v,k]=A.useState(s.get("sortBy")||"created"),[F,L]=A.useState(s.get("order")||"desc"),[ie,T]=A.useState(()=>{const i=parseInt(s.get("page")||"1",10);return Number.isNaN(i)||i<1?1:i}),[E,R]=A.useState(!1),_=A.useRef(null),G=[f!=="_default",x!=="all",v!=="created",F!=="desc"].filter(Boolean).length,w=A.useCallback(i=>{const g=new URLSearchParams(s);Object.entries(i).forEach(([S,z])=>{z&&z!=="all"&&z!=="_default"&&z!==""?g.set(S,z):g.delete(S)});const y=g.toString(),N=y?`?${y}`:"";e(`${r.pathname}${N}`)},[s,e,r.pathname]),I=A.useCallback(i=>{p(i),T(1),w({status:i==="_default"?null:i,page:null})},[w]),Q=A.useCallback(i=>{j(i),T(1),w({priority:i==="all"?null:i,page:null})},[w]),b=A.useCallback(i=>{M(i),T(1),w({search:i||null,page:null})},[w]),W=A.useCallback(i=>{k(i),T(1),w({sortBy:i==="created"?null:i,page:null})},[w]),ee=A.useCallback(()=>{const i=F==="asc"?"desc":"asc";L(i),T(1),w({order:i==="desc"?null:i,page:null})},[F,w]),ce=A.useCallback(i=>{T(i),w({page:i===1?null:String(i)}),window.scrollTo({top:0,behavior:"smooth"})},[w]),le=A.useCallback(i=>{if(i.key==="s"||i.key==="S"){const g=document.activeElement;g?.tagName==="INPUT"||g?.tagName==="TEXTAREA"||g?.getAttribute("contenteditable")==="true"||(i.preventDefault(),_.current?.focus())}},[]);A.useEffect(()=>(document.addEventListener("keydown",le),()=>{document.removeEventListener("keydown",le)}),[le]);const we=A.useMemo(()=>{const i={keys:[{name:"title",weight:.4},{name:"intent",weight:.3},{name:"id",weight:.2},{name:"author.name",weight:.05},{name:"metadata.tags",weight:.05}],threshold:.3,includeScore:!0};return new H(n,i)},[n]);A.useEffect(()=>{async function i(){try{o(!0);const y=await(await fetch(`${Xe}/api/v1/tasks`)).json();y.success?(a(y.data),l(y.data)):d(y.error?.message||"Failed to fetch tasks")}catch(g){d(g instanceof Error?g.message:"Unknown error")}finally{o(!1)}}i()},[]),A.useEffect(()=>{let i=n;if(f==="_default"?i=i.filter(g=>Ze.includes(g.status)):f!=="all"&&(i=i.filter(g=>g.status===f)),x!=="all"&&(i=i.filter(g=>g.metadata.priority===x)),C.trim()){const g=we.search(C),y=new Set(g.map(N=>N.item.id));i=i.filter(N=>y.has(N.id))}i=i.sort((g,y)=>{let N,S;switch(v){case"created":{N=new Date(g.metadata.createdAt).getTime(),S=new Date(y.metadata.createdAt).getTime();break}case"updated":{N=new Date(g.metadata.updatedAt).getTime(),S=new Date(y.metadata.updatedAt).getTime();break}case"status":{N=g.status,S=y.status;break}case"priority":{const z={critical:4,high:3,medium:2,low:1};N=z[g.metadata.priority]||0,S=z[y.metadata.priority]||0;break}case"intent":{N=(g.title||g.intent||"").toLowerCase(),S=(y.title||y.intent||"").toLowerCase();break}default:N=new Date(g.metadata.createdAt).getTime(),S=new Date(y.metadata.createdAt).getTime()}return F==="asc"?N<S?-1:N>S?1:0:N>S?-1:N<S?1:0}),l(i)},[n,f,x,C,v,F,we]);const Y=Math.max(1,Math.ceil(c.length/q)),$=Math.min(ie,Y),Pe=c.slice(($-1)*q,$*q);return h?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your agents"})]}),t.jsx(P,{asChild:!0,children:t.jsxs(te,{to:"/tasks/new",children:[t.jsx(ue,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsx("div",{className:"text-center",children:t.jsxs("p",{className:"text-destructive",children:["Error: ",h]})})})})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your agents"})]}),t.jsx(P,{asChild:!0,children:t.jsxs(te,{to:"/tasks/new",children:[t.jsx(ue,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx(tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),t.jsx(We,{ref:_,placeholder:"Search tasks...",value:C,onChange:i=>b(i.target.value),className:"pl-9 pr-20 h-11 bg-muted/40 border-muted-foreground/20 focus:bg-background transition-colors"}),t.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2",children:C?t.jsx("button",{onClick:()=>b(""),className:"h-5 w-5 rounded-full bg-muted-foreground/20 hover:bg-muted-foreground/30 flex items-center justify-center transition-colors",children:t.jsx(X,{className:"h-3 w-3"})}):t.jsx(Ue,{children:t.jsx(Ge,{children:"S"})})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:()=>R(!E),className:"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg border border-muted-foreground/20 hover:bg-muted/50 transition-colors",children:[t.jsx(be,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Filters & Sort"}),t.jsx("span",{className:"sm:hidden",children:"Filters"}),G>0&&t.jsx("span",{className:"flex items-center justify-center h-5 w-5 text-xs font-bold rounded-full bg-primary text-primary-foreground",children:G}),E?t.jsx(st,{className:"h-4 w-4 ml-1"}):t.jsx(He,{className:"h-4 w-4 ml-1"})]}),t.jsxs("div",{className:"flex-1 flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[f!=="_default"&&t.jsxs("button",{onClick:()=>I("_default"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors whitespace-nowrap",children:[f==="all"?"All statuses":Ee(f),t.jsx(X,{className:"h-3 w-3"})]}),x!=="all"&&t.jsxs("button",{onClick:()=>Q("all"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors whitespace-nowrap",children:[x," priority",t.jsx(X,{className:"h-3 w-3"})]}),(v!=="created"||F!=="desc")&&t.jsxs("button",{onClick:()=>{W("created"),L("desc"),w({sortBy:null,order:null})},className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-purple-500/15 text-purple-600 dark:text-purple-400 hover:bg-purple-500/25 transition-colors whitespace-nowrap",children:[v," ",F==="asc"?"↑":"↓",t.jsx(X,{className:"h-3 w-3"})]})]}),!u&&t.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[c.length," result",c.length!==1?"s":""]})]}),E&&t.jsxs("div",{className:"p-4 rounded-lg border border-muted-foreground/20 bg-muted/30 space-y-4 animate-in slide-in-from-top-2 duration-200",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Status"}),t.jsxs(oe,{value:f,onValueChange:I,children:[t.jsx(he,{className:"w-full bg-background",children:t.jsx(de,{placeholder:"Filter by status"})}),t.jsxs(me,{children:[t.jsx(B,{value:"_default",children:"Active (Default)"}),t.jsx(B,{value:"all",children:"All statuses"}),qe.map(i=>t.jsx(B,{value:i,children:Ee(i)},i))]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Priority"}),t.jsxs(oe,{value:x,onValueChange:Q,children:[t.jsx(he,{className:"w-full bg-background",children:t.jsx(de,{placeholder:"Filter by priority"})}),t.jsxs(me,{children:[t.jsx(B,{value:"all",children:"All priorities"}),t.jsx(B,{value:"low",children:"Low"}),t.jsx(B,{value:"medium",children:"Medium"}),t.jsx(B,{value:"high",children:"High"}),t.jsx(B,{value:"critical",children:"Critical"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Sort By"}),t.jsxs(oe,{value:v,onValueChange:i=>W(i),children:[t.jsx(he,{className:"w-full bg-background",children:t.jsx(de,{})}),t.jsxs(me,{children:[t.jsx(B,{value:"created",children:"Created Date"}),t.jsx(B,{value:"updated",children:"Updated Date"}),t.jsx(B,{value:"status",children:"Status"}),t.jsx(B,{value:"priority",children:"Priority"}),t.jsx(B,{value:"intent",children:"Title"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Order"}),t.jsx(P,{variant:"outline",onClick:ee,className:"w-full justify-between bg-background",children:F==="asc"?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Ascending"}),t.jsx(ct,{className:"h-4 w-4"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Descending"}),t.jsx(at,{className:"h-4 w-4"})]})})]})]}),G>0&&t.jsx("div",{className:"pt-2 border-t border-muted-foreground/10",children:t.jsxs(P,{variant:"ghost",size:"sm",onClick:()=>{I("_default"),Q("all"),b("")},className:"text-muted-foreground hover:text-foreground",children:[t.jsx(X,{className:"h-3 w-3 mr-1"}),"Reset all filters"]})})]})]}),u?t.jsx("div",{className:"space-y-3",children:Array.from({length:6}).map((i,g)=>t.jsx(J,{className:"overflow-hidden",children:t.jsx(Z,{className:"py-4",children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsx("div",{className:"h-5 bg-muted rounded w-2/3 animate-pulse"}),t.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[t.jsx("div",{className:"h-5 w-14 bg-muted rounded-full animate-pulse"}),t.jsx("div",{className:"h-5 w-14 bg-muted rounded-full animate-pulse"})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("div",{className:"h-3.5 bg-muted rounded w-full animate-pulse"}),t.jsx("div",{className:"h-3.5 bg-muted rounded w-4/5 animate-pulse"})]}),t.jsxs("div",{className:"flex justify-between items-center pt-1",children:[t.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"}),t.jsx("div",{className:"h-3 bg-muted rounded w-1/6 animate-pulse"})]})]})})},g))}):c.length===0&&n.length>0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(be,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No tasks match your filters"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try adjusting your status or priority filters."}),t.jsx(P,{variant:"outline",className:"mt-4",onClick:()=>{I("_default"),Q("all"),b("")},children:"Clear Filters"})]})})}):n.length===0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Qe,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No tasks yet"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first task to get started."}),t.jsx(P,{asChild:!0,className:"mt-4",children:t.jsxs(te,{to:"/tasks/new",children:[t.jsx(ue,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"space-y-3",children:Pe.map(i=>t.jsx(te,{to:`/tasks/${i.id}`,className:"block",children:t.jsx(J,{className:"hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:t.jsx(Z,{className:"py-4",children:t.jsx("div",{className:"flex justify-between items-start gap-4",children:t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsx(Je,{className:"text-base leading-tight",children:i.title||i.intent}),t.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[i.metadata.priority&&t.jsx(se,{variant:Qt(i.metadata.priority),className:"text-xs",children:i.metadata.priority}),t.jsx(se,{variant:et(i.status),className:"text-xs",children:i.status})]})]}),i.content&&t.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[i.content.split(`
17
+ `).slice(0,2).join(" ").substring(0,150),i.content.length>150?"...":""]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"text-xs text-muted-foreground",children:[i.id," • by ",i.author.name," • ",new Date(i.metadata.createdAt).toLocaleDateString()]}),t.jsxs("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[i.planSteps.length>0&&t.jsxs("span",{children:[i.planSteps.length," step",i.planSteps.length!==1?"s":""]}),i.metadata.tags&&i.metadata.tags.length>0&&t.jsxs("span",{children:[i.metadata.tags.length," tag",i.metadata.tags.length!==1?"s":""]})]})]}),i.metadata.tags&&i.metadata.tags.length>0&&t.jsxs("div",{className:"flex gap-1 mt-2",children:[i.metadata.tags.slice(0,3).map(g=>t.jsx(se,{variant:"outline",className:"text-xs",children:g},g)),i.metadata.tags.length>3&&t.jsxs(se,{variant:"outline",className:"text-xs",children:["+",i.metadata.tags.length-3]})]})]})})})})},i.id))}),Y>1&&t.jsxs("div",{className:"flex items-center justify-between pt-2",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",($-1)*q+1,"–",Math.min($*q,c.length)," of ",c.length]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(P,{variant:"outline",size:"sm",disabled:$<=1,onClick:()=>ce($-1),children:t.jsx(rt,{className:"h-4 w-4"})}),Array.from({length:Y},(i,g)=>g+1).filter(i=>i===1||i===Y||Math.abs(i-$)<=1).reduce((i,g,y,N)=>(y>0&&g-N[y-1]>1&&i.push("ellipsis"),i.push(g),i),[]).map((i,g)=>i==="ellipsis"?t.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:"…"},`e${g}`):t.jsx(P,{variant:i===$?"default":"outline",size:"sm",className:"min-w-[2rem]",onClick:()=>ce(i),children:i},i)),t.jsx(P,{variant:"outline",size:"sm",disabled:$>=Y,onClick:()=>ce($+1),children:t.jsx(Ye,{className:"h-4 w-4"})})]})]})]})]})}export{ns as default};
@@ -0,0 +1,9 @@
1
+ import{u as p,a as v,r as a,A as l,j as e,B as m,L as g,a1 as N}from"./index-UXL5-kaP.js";import{C as h,a as x,b as C,c as S}from"./card-DPLdBoa5.js";import{M as w}from"./markdown-editor-DBdRsbP2.js";import{A as y}from"./arrow-left-DWmf9YJp.js";import{C as b}from"./circle-check-big-BEY1IoIP.js";import"./index-DnZKG-_7.js";function F(){const u=p(),{toast:t}=v(),[n,i]=a.useState(""),[f,r]=a.useState(!0),[o,c]=a.useState(!1);a.useEffect(()=>{fetch(`${l}/api/v1/context/team`).then(s=>s.json()).then(s=>{s.success&&i(s.document.content.trim()),r(!1)}).catch(s=>{console.error("Failed to load context:",s),t({title:"Error",description:"Failed to load team definition",variant:"destructive"}),r(!1)})},[t]);const j=async()=>{c(!0);try{const d=await(await fetch(`${l}/api/v1/context/team`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,metadata:{}})})).json();if(d.success)t({title:"Success",description:"Team definition saved successfully",action:e.jsx(b,{className:"h-4 w-4"})}),u("/context/team");else throw new Error(d.error||"Failed to save")}catch(s){console.error("Save error:",s),t({title:"Error",description:"Failed to save team definition",variant:"destructive"})}finally{c(!1)}};return f?e.jsx("div",{className:"space-y-6",children:e.jsx(h,{children:e.jsx(x,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Team Definition"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Define team structure, members, and communication"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(g,{to:"/context/team",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(y,{className:"w-4 h-4"})})}),e.jsxs(m,{onClick:j,disabled:o,size:"sm",children:[e.jsx(N,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:o?"Saving...":"Save"})]})]})]}),e.jsxs(h,{children:[e.jsx(C,{children:e.jsx(S,{children:"Team Documentation"})}),e.jsx(x,{children:e.jsx(w,{value:n,onChange:s=>i(s||""),placeholder:`Write your team definition in markdown...
2
+
3
+ ## Team Members
4
+
5
+ List team members, their roles, and responsibilities.
6
+
7
+ ## Communication
8
+
9
+ Team communication channels and conventions.`,height:800})})]})]})}export{F as default};
@@ -0,0 +1 @@
1
+ import{a as N,r as t,A as v,j as e,v as C,aw as w,B as a,L as o,_ as d,M as g,au as y,aq as b}from"./index-UXL5-kaP.js";import{C as i,a as r,b as E}from"./card-DPLdBoa5.js";import{c as T}from"./clipboard-B9ndUJKl.js";function D(){const{toast:c}=N(),[l,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${v}/api/v1/context/team`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/team.md";try{await T(s),c({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),c({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"team-md",filename:"team.md",name:"team.md",path:".nut/context/team.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading team definition..."})]})})})}):!u||!l?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(w,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Team Definition Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Team definition will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(o,{to:"/context/team/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Team Definition"]})})]})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Team"}),e.jsx("p",{className:"text-muted-foreground",children:"Team structure and member information"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(g,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(o,{to:"/context/team/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(i,{children:[e.jsx(E,{className:"pb-0"}),e.jsx(r,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(b,{children:l.content||"No content available"})})})]})]})}export{D as default};
@@ -1 +1 @@
1
- import{u as U,a as J,r as i,j as e,B as r,T as C,n as K,X as L,t as H,a1 as G}from"./index-DB2Tq9wz.js";import{C as p,a as W}from"./card-DRBgMGuU.js";import{u as X}from"./use-terminal-D6Qe1nwM.js";import{T as _}from"./terminal-preview-BfrUN2ok.js";/* empty css */import{R as q}from"./refresh-cw-5y5jTc6x.js";import{C as Q,a as V}from"./chevrons-up-DfFpzHXf.js";import{C as Y}from"./chevron-up-DJfyvHso.js";import{P as M}from"./play-B0y1weCV.js";import{C as Z}from"./circle-play-7F5AVehH.js";import"./xterm-DTxiCjtJ.js";function he(){const m=U(),{sessions:f,loading:d,error:S,refreshSessions:h,createSession:j,destroySession:B}=X(),{toast:l}=J(),[x,u]=i.useState(""),[g,T]=i.useState(!1),[v,I]=i.useState(!1),[N,$]=i.useState([]),[,w]=i.useState(null),O=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const b=Math.floor(n/60);if(b<60)return`${b}m ago`;const k=Math.floor(b/60);return k<24?`${k}h ago`:`${Math.floor(k/24)}d ago`};i.useEffect(()=>{h()},[h]),i.useEffect(()=>{y(s=>{const t={...s};return f.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[f]),i.useEffect(()=>{try{const s=localStorage.getItem("terminal.commandHistory");s&&$(JSON.parse(s))}catch{}},[]);const D=s=>{s&&($(t=>{const a=[s,...t.filter(n=>n!==s)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a}),w(null))},c=f.filter(s=>!s.taskId?.startsWith("cp-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[o,y]=i.useState(()=>{const s={};return f.forEach(t=>{s[t.id]=!0}),s}),R=async()=>{const s=`session-${Date.now()}`;await j(s)&&(l({title:"New terminal started",description:`${s}`}),m(`/terminal/${s}`))},E=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;T(!0);try{await j(t,s)?(D(s),l({title:"Session started",description:`${t}`}),m(`/terminal/${t}`)):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{T(!1)}},A=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;I(!0);try{await j(t,s)?(D(s),setTimeout(()=>h(),150),u(""),l({title:"Started in background",description:`${t}`,action:e.jsx(G,{altText:"Open session",onClick:()=>m(`/terminal/${t}`),children:"Open"})})):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{I(!1)}},P=async s=>{await B(s)?(l({title:"Session closed",description:s}),setTimeout(()=>h(),100)):l({title:"Failed to close session",description:s,variant:"destructive"})},F=()=>{const s=c.every(a=>o[a.id]),t={};c.forEach(a=>{t[a.id]=!s}),y(t)},z=c.length>0&&c.every(s=>o[s.id]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Terminal"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage terminal sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",onClick:()=>h(),disabled:d,children:[e.jsx(q,{className:`h-4 w-4 sm:mr-2 ${d?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),c.length>0&&e.jsx(r,{variant:"outline",onClick:F,children:z?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{onClick:R,disabled:d,children:[e.jsx(C,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})]}),S&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:S})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),d?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(p,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):c.length===0?e.jsx(p,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(C,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching a new terminal session with the"," ",e.jsx("button",{onClick:R,className:"text-primary hover:underline font-medium",children:"New Terminal"})," ","button above."]})]})]})}):e.jsx("div",{className:"space-y-2",children:c.slice(0,10).map(s=>e.jsxs(p,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(C,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.taskId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",O(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{y(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":o[s.id]?"Hide preview":"Show preview",title:o[s.id]?"Hide preview":"Show preview",children:o[s.id]?e.jsx(Y,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})}),e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(`/terminal/${s.taskId}`),children:[e.jsx(M,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Open"})]}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>P(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(L,{className:"h-4 w-4"})})]})]}),o[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>m(`/terminal/${s.taskId}`),title:"Click to open full terminal session",children:e.jsx(_,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Run Custom Command"}),e.jsx(p,{children:e.jsxs(W,{className:"py-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:x,onChange:s=>u(s.target.value),onKeyDown:s=>{s.key==="Enter"?(s.preventDefault(),s.shiftKey?A():E()):s.key==="ArrowUp"?(s.preventDefault(),w(t=>{const a=t===null?0:Math.min((t??0)+1,N.length-1),n=N[a];return n&&u(n),a})):s.key==="ArrowDown"&&(s.preventDefault(),w(t=>{if(t===null)return null;const a=t-1;if(a<0)return u(""),null;const n=N[a];return n&&u(n),a}))},placeholder:"npm run dev",className:"flex-1 h-9 rounded-md border px-3 text-sm bg-white dark:bg-gray-900 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400"}),e.jsxs(r,{onClick:A,variant:"secondary",disabled:d||!x.trim()||v||g,children:[v?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-1"}):e.jsx(Z,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(r,{onClick:E,disabled:d||!x.trim()||g||v,children:[g?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(M,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Enter to Run • Shift+Enter to Run in background"})]})})]})]})}export{he as default};
1
+ import{u as U,a as J,r as i,j as e,B as r,T as C,n as K,X as L,v as H,a2 as G}from"./index-UXL5-kaP.js";import{C as p,a as W}from"./card-DPLdBoa5.js";import{u as X}from"./use-terminal-D3iV7-iC.js";import{T as _}from"./terminal-preview-CLWDhoOZ.js";/* empty css */import{R as q}from"./refresh-cw-tXYl1ePu.js";import{C as Q,a as V}from"./chevrons-up-BfU70OcQ.js";import{C as Y}from"./chevron-up-DFd-7wxW.js";import{P as M}from"./play-DVBhRokt.js";import{C as Z}from"./circle-play-iZZwaGbV.js";import"./xterm-DTxiCjtJ.js";function he(){const m=U(),{sessions:f,loading:d,error:S,refreshSessions:h,createSession:j,destroySession:B}=X(),{toast:l}=J(),[x,u]=i.useState(""),[g,T]=i.useState(!1),[v,I]=i.useState(!1),[N,$]=i.useState([]),[,w]=i.useState(null),O=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const b=Math.floor(n/60);if(b<60)return`${b}m ago`;const k=Math.floor(b/60);return k<24?`${k}h ago`:`${Math.floor(k/24)}d ago`};i.useEffect(()=>{h()},[h]),i.useEffect(()=>{y(s=>{const t={...s};return f.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[f]),i.useEffect(()=>{try{const s=localStorage.getItem("terminal.commandHistory");s&&$(JSON.parse(s))}catch{}},[]);const D=s=>{s&&($(t=>{const a=[s,...t.filter(n=>n!==s)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a}),w(null))},c=f.filter(s=>!s.taskId?.startsWith("cp-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[o,y]=i.useState(()=>{const s={};return f.forEach(t=>{s[t.id]=!0}),s}),R=async()=>{const s=`session-${Date.now()}`;await j(s)&&(l({title:"New terminal started",description:`${s}`}),m(`/terminal/${s}`))},E=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;T(!0);try{await j(t,s)?(D(s),l({title:"Session started",description:`${t}`}),m(`/terminal/${t}`)):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{T(!1)}},A=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;I(!0);try{await j(t,s)?(D(s),setTimeout(()=>h(),150),u(""),l({title:"Started in background",description:`${t}`,action:e.jsx(G,{altText:"Open session",onClick:()=>m(`/terminal/${t}`),children:"Open"})})):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{I(!1)}},P=async s=>{await B(s)?(l({title:"Session closed",description:s}),setTimeout(()=>h(),100)):l({title:"Failed to close session",description:s,variant:"destructive"})},F=()=>{const s=c.every(a=>o[a.id]),t={};c.forEach(a=>{t[a.id]=!s}),y(t)},z=c.length>0&&c.every(s=>o[s.id]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Terminal"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage terminal sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",onClick:()=>h(),disabled:d,children:[e.jsx(q,{className:`h-4 w-4 sm:mr-2 ${d?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),c.length>0&&e.jsx(r,{variant:"outline",onClick:F,children:z?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{onClick:R,disabled:d,children:[e.jsx(C,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})]}),S&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:S})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),d?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(p,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):c.length===0?e.jsx(p,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(C,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching a new terminal session with the"," ",e.jsx("button",{onClick:R,className:"text-primary hover:underline font-medium",children:"New Terminal"})," ","button above."]})]})]})}):e.jsx("div",{className:"space-y-2",children:c.slice(0,10).map(s=>e.jsxs(p,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(C,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.taskId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",O(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{y(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":o[s.id]?"Hide preview":"Show preview",title:o[s.id]?"Hide preview":"Show preview",children:o[s.id]?e.jsx(Y,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})}),e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(`/terminal/${s.taskId}`),children:[e.jsx(M,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Open"})]}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>P(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(L,{className:"h-4 w-4"})})]})]}),o[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>m(`/terminal/${s.taskId}`),title:"Click to open full terminal session",children:e.jsx(_,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Run Custom Command"}),e.jsx(p,{children:e.jsxs(W,{className:"py-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:x,onChange:s=>u(s.target.value),onKeyDown:s=>{s.key==="Enter"?(s.preventDefault(),s.shiftKey?A():E()):s.key==="ArrowUp"?(s.preventDefault(),w(t=>{const a=t===null?0:Math.min((t??0)+1,N.length-1),n=N[a];return n&&u(n),a})):s.key==="ArrowDown"&&(s.preventDefault(),w(t=>{if(t===null)return null;const a=t-1;if(a<0)return u(""),null;const n=N[a];return n&&u(n),a}))},placeholder:"npm run dev",className:"flex-1 h-9 rounded-md border px-3 text-sm bg-white dark:bg-gray-900 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400"}),e.jsxs(r,{onClick:A,variant:"secondary",disabled:d||!x.trim()||v||g,children:[v?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-1"}):e.jsx(Z,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(r,{onClick:E,disabled:d||!x.trim()||g||v,children:[g?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(M,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Enter to Run • Shift+Enter to Run in background"})]})})]})]})}export{he as default};