@lovelybunch/api 1.0.76-alpha.6 → 1.0.76-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/package.json +4 -5
  2. package/static/assets/{ActivityPage-CIdWYzkx.js → ActivityPage-Dmuu0c1r.js} +1 -1
  3. package/static/assets/{ApiKeysSettingsPage-BAe5Dr37.js → ApiKeysSettingsPage-BtpcHzBO.js} +1 -1
  4. package/static/assets/{ArchitectureEditPage-C7zEkrcP.js → ArchitectureEditPage-CRK7l_pP.js} +1 -1
  5. package/static/assets/{ArchitecturePage-DrnLx7ZW.js → ArchitecturePage-Bb3Mr04V.js} +1 -1
  6. package/static/assets/{AuthSettingsPage-C2GgWQHX.js → AuthSettingsPage-BmcnjO0-.js} +1 -1
  7. package/static/assets/{CallbackPage-CDHWI_4B.js → CallbackPage-hQdlfqNL.js} +1 -1
  8. package/static/assets/{CodePage-Sx6uQ0To.js → CodePage-BlGRZW1v.js} +1 -1
  9. package/static/assets/{CollapsibleSection-B51ItrCZ.js → CollapsibleSection-dXTDG5xK.js} +1 -1
  10. package/static/assets/{DashboardPage-Dcvf2RzE.js → DashboardPage-SNgPwXuZ.js} +1 -1
  11. package/static/assets/{GitPage-CwduTMmS.js → GitPage-CmRS64Yi.js} +1 -1
  12. package/static/assets/{GitSettingsPage-CL9j1Ihj.js → GitSettingsPage-2sLN6YTn.js} +1 -1
  13. package/static/assets/{IdentityPage-BQtoiFXI.js → IdentityPage-Ce9aNd67.js} +1 -1
  14. package/static/assets/{ImplementationStepsEditor-C3OVNxOV.js → ImplementationStepsEditor-BCw5WEo-.js} +1 -1
  15. package/static/assets/{IntegrationsSettingsPage-CqQvBebL.js → IntegrationsSettingsPage-CNhL2RAP.js} +1 -1
  16. package/static/assets/{JobDetailPage-DoBQZguF.js → JobDetailPage-B1QoqEIg.js} +1 -1
  17. package/static/assets/{KnowledgeDetailPage-85L0nSFi.js → KnowledgeDetailPage-D6E4oPnB.js} +1 -1
  18. package/static/assets/{KnowledgeEditPage-yitW7Pqv.js → KnowledgeEditPage-Cx0I6UOP.js} +1 -1
  19. package/static/assets/{KnowledgePage-C-Nfd7BF.js → KnowledgePage-CtwNzWrO.js} +1 -1
  20. package/static/assets/{LoginPage-BnvS09ls.js → LoginPage-wCy6_Zm7.js} +1 -1
  21. package/static/assets/{MailInboxPage-pJxnMZrb.js → MailInboxPage-PlwJvbyZ.js} +1 -1
  22. package/static/assets/{MailProcessingModal-CmlWaFvR.js → MailProcessingModal-D7Ql9vO7.js} +1 -1
  23. package/static/assets/{MailReadPage-Dttd2XcH.js → MailReadPage-BIs7cMX8.js} +1 -1
  24. package/static/assets/{MailSentPage-th_4SPmE.js → MailSentPage-Bb0xtmoP.js} +1 -1
  25. package/static/assets/{McpSettingsPage-CcVGELdu.js → McpSettingsPage-CgxAuTpL.js} +1 -1
  26. package/static/assets/{NewKnowledgePage-DbPtI1Wr.js → NewKnowledgePage-ByxAeT6H.js} +1 -1
  27. package/static/assets/{NewSkillPage-BEim3_gS.js → NewSkillPage-OYWMDDx4.js} +1 -1
  28. package/static/assets/{NewTaskPage-DlNZFMbQ.js → NewTaskPage-BtQDlqV4.js} +1 -1
  29. package/static/assets/{NotFoundPage-JsE_EGs1.js → NotFoundPage-C6Y7qVDZ.js} +1 -1
  30. package/static/assets/{NotificationsSettingsPage-x8Ec-UvE.js → NotificationsSettingsPage-D7Ov-sWC.js} +1 -1
  31. package/static/assets/{ProjectEditPage-EkoUK3Zg.js → ProjectEditPage-DathnxH1.js} +1 -1
  32. package/static/assets/{ProjectPage-BNln2mWb.js → ProjectPage-Cqhn6x5U.js} +1 -1
  33. package/static/assets/{PromptsSettingsPage-CA1kr1tZ.js → PromptsSettingsPage-YUM57KBW.js} +1 -1
  34. package/static/assets/{ResourceDetailPage-w51n1ia2.js → ResourceDetailPage-DHjIUpZA.js} +1 -1
  35. package/static/assets/{ResourcesPage-BAVq2x9j.js → ResourcesPage-D6JnktN5.js} +1 -1
  36. package/static/assets/{RoleEditPage-DbZWKiYs.js → RoleEditPage-BkcUVWeb.js} +1 -1
  37. package/static/assets/{RolePage-4D7KXik1.js → RolePage-BvbK5LV5.js} +1 -1
  38. package/static/assets/{RulesSettingsPage-1RlcfntP.js → RulesSettingsPage-0FLxp6EA.js} +1 -1
  39. package/static/assets/{SchedulePage-CTxly6WM.js → SchedulePage-DedzsT29.js} +1 -1
  40. package/static/assets/{SkillDetailPage-CvCV8Afp.js → SkillDetailPage-tQFvdVX0.js} +1 -1
  41. package/static/assets/{SkillEditPage-BA2iUki_.js → SkillEditPage-DqNB953S.js} +1 -1
  42. package/static/assets/{SkillsPage-DsRmxk9r.js → SkillsPage-BjQJQ5dJ.js} +1 -1
  43. package/static/assets/{SkillsSettingsPage-B2gDvCCf.js → SkillsSettingsPage-CVXd-umU.js} +1 -1
  44. package/static/assets/{SourceInput-gjOlS_7W.js → SourceInput-8t5lHb_p.js} +1 -1
  45. package/static/assets/{TagInput-CgOjYo2a.js → TagInput-BSvCOVlX.js} +1 -1
  46. package/static/assets/{TaskDetailPage-smFafbM8.js → TaskDetailPage-mr6xlhU3.js} +1 -1
  47. package/static/assets/{TaskEditPage-DIJwK0ta.js → TaskEditPage-BPFpzGZd.js} +1 -1
  48. package/static/assets/{TasksPage-CVcdZkQY.js → TasksPage-DHhsW-6_.js} +1 -1
  49. package/static/assets/{TerminalPage-scN_gLbH.js → TerminalPage-BoULMlvX.js} +1 -1
  50. package/static/assets/{TerminalSessionPage-BPqF_2Gb.js → TerminalSessionPage-BUFKA_ff.js} +1 -1
  51. package/static/assets/{UserPreferencesPage-2zDFFX9r.js → UserPreferencesPage-CG8d6Etn.js} +1 -1
  52. package/static/assets/{UserSettingsPage-B9Nh1jS_.js → UserSettingsPage-xPNj059t.js} +1 -1
  53. package/static/assets/{UtilitiesPage-B-6wUO31.js → UtilitiesPage-1-65_2Xp.js} +1 -1
  54. package/static/assets/{alert-CGO08-55.js → alert-EL2xlTrX.js} +1 -1
  55. package/static/assets/{arrow-down-ClSaicmT.js → arrow-down-C4aI3BzN.js} +1 -1
  56. package/static/assets/{arrow-left-BSoXBQjE.js → arrow-left-D1gRXqBK.js} +1 -1
  57. package/static/assets/{arrow-up-C0ps77b3.js → arrow-up-DAYHG9Lx.js} +1 -1
  58. package/static/assets/{arrow-up-down-B7GzgKEr.js → arrow-up-down-CHPybwd-.js} +1 -1
  59. package/static/assets/{badge-D-5A_jAJ.js → badge-WU4FRCeV.js} +1 -1
  60. package/static/assets/{browser-modal-G-Zh1FPt.js → browser-modal-B41s3tKa.js} +1 -1
  61. package/static/assets/{card-BmKLfTSE.js → card-BHJKBprp.js} +1 -1
  62. package/static/assets/{chevron-left-Dp4jQZnO.js → chevron-left-BJKLaytG.js} +1 -1
  63. package/static/assets/{chevron-up-DcYrGzFP.js → chevron-up-BkAwyb-e.js} +1 -1
  64. package/static/assets/{chevrons-up-B32RP1_q.js → chevrons-up-DLVKnDAn.js} +1 -1
  65. package/static/assets/{circle-alert-CngqosqJ.js → circle-alert-Z70KQUGE.js} +1 -1
  66. package/static/assets/{circle-check-DMbbBi3F.js → circle-check-BADr-KOf.js} +1 -1
  67. package/static/assets/{circle-check-big-P_y4fjqZ.js → circle-check-big-D34PB5x-.js} +1 -1
  68. package/static/assets/{circle-play-CTAO3XQu.js → circle-play-BfLMQvSH.js} +1 -1
  69. package/static/assets/{circle-x-4ItVsEnH.js → circle-x-Bn4fyYbB.js} +1 -1
  70. package/static/assets/{clipboard-BrZi1A1O.js → clipboard-DFI4a7LI.js} +1 -1
  71. package/static/assets/{clock-BtaA4__3.js → clock-BwcvObAc.js} +1 -1
  72. package/static/assets/{code-tahDnqiL.js → code-DXA16K3p.js} +1 -1
  73. package/static/assets/{download-V8bZhLVX.js → download-Cb08Pn1l.js} +1 -1
  74. package/static/assets/{external-link-BgDYyk_g.js → external-link-BbPHlMU6.js} +1 -1
  75. package/static/assets/{eye-ClwGtS4D.js → eye-DKuTxsEz.js} +1 -1
  76. package/static/assets/{folder-git-2-BD3bOYHN.js → folder-git-2-CLjnVj8p.js} +1 -1
  77. package/static/assets/{index-CDkUCE5L.js → index-97wNbZjB.js} +1 -1
  78. package/static/assets/{index-DPoSgeJ9.js → index-9hNdrzuJ.js} +1 -1
  79. package/static/assets/{index-SWOj8KlO.js → index-B-VC5GM7.js} +1 -1
  80. package/static/assets/{index-BWh3hHZT.js → index-BBUGa7c5.js} +1 -1
  81. package/static/assets/{index-BUD3brzs.js → index-BShpFXJb.js} +1 -1
  82. package/static/assets/{index-xPWB9-hU.js → index-Bd8VZDeR.js} +1 -1
  83. package/static/assets/{index-Dy9y-Ewv.js → index-BjpC9OGL.js} +1 -1
  84. package/static/assets/{index-CoIuEZL-.js → index-C5Azpb6Z.js} +3 -3
  85. package/static/assets/{index-Bqq-HAqp.js → index-CHImvyA8.js} +1 -1
  86. package/static/assets/{index-PCCQX1sM.js → index-Cp2t41gG.js} +1 -1
  87. package/static/assets/{index-CAE4Af0Y.js → index-DDaqus6Y.js} +1 -1
  88. package/static/assets/{index-C4ppQAQR.js → index-DE9Jes-V.js} +1 -1
  89. package/static/assets/{index-CYbc5Tfm.js → index-DNQq4O0F.js} +1 -1
  90. package/static/assets/{index-B6rCO2J4.js → index-DO6rNgzu.js} +1 -1
  91. package/static/assets/{index-CtlrPZLB.js → index-DauoTeMC.js} +1 -1
  92. package/static/assets/{index-DTtH69su.js → index-DxQLy6Gv.js} +1 -1
  93. package/static/assets/{index-DO0ri2sg.js → index-DysiQsZ5.js} +1 -1
  94. package/static/assets/{index-Bguopfyy.js → index-KMYFtqs_.js} +1 -1
  95. package/static/assets/{index-DHduC8SJ.js → index-MT7xy-5k.js} +1 -1
  96. package/static/assets/{info-Lw7UJFgz.js → info-CwUnqjYK.js} +1 -1
  97. package/static/assets/{label-j04IpCQ3.js → label-Dk87UyXm.js} +1 -1
  98. package/static/assets/{markdown-editor-DtzC0VN_.js → markdown-editor-D0KOANlZ.js} +3 -3
  99. package/static/assets/{message-square-ChzqZzH2.js → message-square-qlP-j05_.js} +1 -1
  100. package/static/assets/{paperclip-DJuC6Yk8.js → paperclip-C7-B8_IK.js} +1 -1
  101. package/static/assets/{pause-8GBhPf8i.js → pause-DE1VFlNp.js} +1 -1
  102. package/static/assets/{play-BNqIC9DT.js → play-D8sJDiBu.js} +1 -1
  103. package/static/assets/{radio-group-BT3zKyNF.js → radio-group-C8YR94gC.js} +1 -1
  104. package/static/assets/{refresh-cw-CG3rbxSH.js → refresh-cw-CIEDgKUC.js} +1 -1
  105. package/static/assets/{search-PHGXbkfS.js → search-BGxb6jwl.js} +1 -1
  106. package/static/assets/{select-B7VRmZ7N.js → select-CpKkFDbr.js} +1 -1
  107. package/static/assets/{switch-CuxAwq5S.js → switch-BZ6eSoPj.js} +1 -1
  108. package/static/assets/{tabs-Oc0OBkXw.js → tabs-HysYyLO3.js} +1 -1
  109. package/static/assets/{tag-BQdG8RuS.js → tag-D2TG8w6l.js} +1 -1
  110. package/static/assets/{terminal-preview-D8nle4ul.js → terminal-preview-Cgpwpsv9.js} +1 -1
  111. package/static/assets/{use-terminal-BfyjkzZB.js → use-terminal-Bf1hClFd.js} +1 -1
  112. package/static/assets/{video-BopvCp9v.js → video-D0tTpDVb.js} +1 -1
  113. package/static/index.html +1 -1
@@ -1 +1 @@
1
- import{x as $,u as z,a as B,r as a,A as E,j as e,t as S,B as h,L as M,a0 as D,X as K,I as R}from"./index-CoIuEZL-.js";import{C as d,a as l,b as x,c as p}from"./card-BmKLfTSE.js";import{L as g}from"./label-j04IpCQ3.js";import{M as U}from"./markdown-editor-DtzC0VN_.js";import{T as _}from"./TagInput-CgOjYo2a.js";import{n as H,S as J}from"./SourceInput-gjOlS_7W.js";import{A as O}from"./arrow-left-BSoXBQjE.js";import"./index-CtlrPZLB.js";import"./badge-D-5A_jAJ.js";import"./external-link-BgDYyk_g.js";function se(){const y=$(),i=z(),{toast:n}=B(),r=y.filename,[m,T]=a.useState(null),[L,b]=a.useState(!0),[u,f]=a.useState(!1),[o,j]=a.useState(""),[c,v]=a.useState(""),[w,N]=a.useState([]),[k,C]=a.useState([]);a.useEffect(()=>{r&&A()},[r]);const A=async()=>{try{const t=await(await fetch(`${E}/api/v1/knowledge/${r}`)).json();t.success?(T(t.document),j(t.document.title),v(t.document.content),N(t.document.metadata.tags||[]),C(H(t.document.metadata.sources))):(n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge"))}catch(s){console.error("Error fetching document:",s),n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge")}finally{b(!1)}},F=async()=>{if(m){if(!o.trim()){n({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!c.trim()){n({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}f(!0);try{const t=await(await fetch(`${E}/api/v1/knowledge/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o.trim(),content:c.trim(),metadata:{tags:w,sources:k}})})).json();if(t.success){n({title:"Success",description:"Knowledge document updated successfully"});const P=t.document.filename.replace(".md","");i(`/knowledge/${P}`,{replace:!0})}else n({title:"Error",description:t.error||"Failed to update knowledge document",variant:"destructive"})}catch(s){console.error("Error updating document:",s),n({title:"Error",description:"Failed to update knowledge document",variant:"destructive"})}finally{f(!1)}}},I=()=>{i(`/knowledge/${r}`)};return L?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(S,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):m?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 Document"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:m.filename})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(M,{to:"/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(O,{className:"h-4 w-4"})})}),e.jsxs(h,{onClick:F,disabled:u||!o.trim()||!c.trim(),size:"sm",children:[u?e.jsx(S,{className:"w-4 h-4 animate-spin sm:mr-2"}):e.jsx(D,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:u?"Saving...":"Save"})]}),e.jsxs(h,{onClick:I,variant:"outline",size:"sm",children:[e.jsx(K,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Cancel"})]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Basic Information"})}),e.jsx(l,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(g,{htmlFor:"title",children:"Title *"}),e.jsx(R,{id:"title",value:o,onChange:s=>j(s.target.value),placeholder:"Enter document title...",className:"text-lg"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing the title will rename the file"})]})})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Metadata"})}),e.jsxs(l,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(g,{children:"Tags"}),e.jsx(_,{tags:w,onChange:N,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(g,{children:"Sources"}),e.jsx(J,{sources:k,onChange:C})]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Content *"})}),e.jsx(l,{children:e.jsx(U,{value:c,onChange:s=>v(s||""),placeholder:"Enter your knowledge content in Markdown..."})})]})]}):null}export{se as default};
1
+ import{x as $,u as z,a as B,r as a,A as E,j as e,t as S,B as h,L as M,a0 as D,X as K,I as R}from"./index-C5Azpb6Z.js";import{C as d,a as l,b as x,c as p}from"./card-BHJKBprp.js";import{L as g}from"./label-Dk87UyXm.js";import{M as U}from"./markdown-editor-D0KOANlZ.js";import{T as _}from"./TagInput-BSvCOVlX.js";import{n as H,S as J}from"./SourceInput-8t5lHb_p.js";import{A as O}from"./arrow-left-D1gRXqBK.js";import"./index-DauoTeMC.js";import"./badge-WU4FRCeV.js";import"./external-link-BbPHlMU6.js";function se(){const y=$(),i=z(),{toast:n}=B(),r=y.filename,[m,T]=a.useState(null),[L,b]=a.useState(!0),[u,f]=a.useState(!1),[o,j]=a.useState(""),[c,v]=a.useState(""),[w,N]=a.useState([]),[k,C]=a.useState([]);a.useEffect(()=>{r&&A()},[r]);const A=async()=>{try{const t=await(await fetch(`${E}/api/v1/knowledge/${r}`)).json();t.success?(T(t.document),j(t.document.title),v(t.document.content),N(t.document.metadata.tags||[]),C(H(t.document.metadata.sources))):(n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge"))}catch(s){console.error("Error fetching document:",s),n({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge")}finally{b(!1)}},F=async()=>{if(m){if(!o.trim()){n({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!c.trim()){n({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}f(!0);try{const t=await(await fetch(`${E}/api/v1/knowledge/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o.trim(),content:c.trim(),metadata:{tags:w,sources:k}})})).json();if(t.success){n({title:"Success",description:"Knowledge document updated successfully"});const P=t.document.filename.replace(".md","");i(`/knowledge/${P}`,{replace:!0})}else n({title:"Error",description:t.error||"Failed to update knowledge document",variant:"destructive"})}catch(s){console.error("Error updating document:",s),n({title:"Error",description:"Failed to update knowledge document",variant:"destructive"})}finally{f(!1)}}},I=()=>{i(`/knowledge/${r}`)};return L?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(S,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):m?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 Document"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:m.filename})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(M,{to:"/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(O,{className:"h-4 w-4"})})}),e.jsxs(h,{onClick:F,disabled:u||!o.trim()||!c.trim(),size:"sm",children:[u?e.jsx(S,{className:"w-4 h-4 animate-spin sm:mr-2"}):e.jsx(D,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:u?"Saving...":"Save"})]}),e.jsxs(h,{onClick:I,variant:"outline",size:"sm",children:[e.jsx(K,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Cancel"})]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Basic Information"})}),e.jsx(l,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(g,{htmlFor:"title",children:"Title *"}),e.jsx(R,{id:"title",value:o,onChange:s=>j(s.target.value),placeholder:"Enter document title...",className:"text-lg"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing the title will rename the file"})]})})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Metadata"})}),e.jsxs(l,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(g,{children:"Tags"}),e.jsx(_,{tags:w,onChange:N,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(g,{children:"Sources"}),e.jsx(J,{sources:k,onChange:C})]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(p,{children:"Content *"})}),e.jsx(l,{children:e.jsx(U,{value:c,onChange:s=>v(s||""),placeholder:"Enter your knowledge content in Markdown..."})})]})]}):null}export{se as default};
@@ -1,3 +1,3 @@
1
- import{j as e,S as V,_ as q,u as Q,r as p,a as W,A as $,t as X,B as x,L as P,P as z,F as C,M as K,ae as I,af as M}from"./index-CoIuEZL-.js";import{C as L,a as B}from"./card-BmKLfTSE.js";import{B as j}from"./badge-D-5A_jAJ.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{R as ee,L as O}from"./browser-modal-G-Zh1FPt.js";import{R as te,f as se}from"./registry-ANRa5WBi.js";import{A as ae}from"./arrow-up-down-B7GzgKEr.js";import{A as ne}from"./arrow-up-C0ps77b3.js";import{A as re}from"./arrow-down-ClSaicmT.js";import"./search-PHGXbkfS.js";const ie=["createdAt","updatedAt","version","tags"];function U(a){if(a){if(Array.isArray(a)){const l=a.map(i=>{if(typeof i=="string")return i.trim();if(typeof i=="number")return`${i}`}).filter(i=>typeof i=="string"&&i.length>0);return l.length>0?l:void 0}if(typeof a=="string"){const l=a.split(",").map(i=>i.trim()).filter(i=>i.length>0);return l.length>0?l:void 0}}}function oe(a,l){const i=[];if(a.content&&typeof a.content=="object")for(const r of Object.values(a.content))typeof r=="string"&&r.trim().length>0&&i.push(r.trim());const s=[];return s.push(`# ${l}`),a.description?.trim()&&s.push(a.description.trim()),[...s,...i].join(`
1
+ import{j as e,S as V,_ as q,u as Q,r as p,a as W,A as $,t as X,B as x,L as P,P as z,F as C,M as K,ae as I,af as M}from"./index-C5Azpb6Z.js";import{C as L,a as B}from"./card-BHJKBprp.js";import{B as j}from"./badge-WU4FRCeV.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{R as ee,L as O}from"./browser-modal-B41s3tKa.js";import{R as te,f as se}from"./registry-ANRa5WBi.js";import{A as ae}from"./arrow-up-down-CHPybwd-.js";import{A as ne}from"./arrow-up-DAYHG9Lx.js";import{A as re}from"./arrow-down-C4aI3BzN.js";import"./search-BGxb6jwl.js";const ie=["createdAt","updatedAt","version","tags"];function U(a){if(a){if(Array.isArray(a)){const l=a.map(i=>{if(typeof i=="string")return i.trim();if(typeof i=="number")return`${i}`}).filter(i=>typeof i=="string"&&i.length>0);return l.length>0?l:void 0}if(typeof a=="string"){const l=a.split(",").map(i=>i.trim()).filter(i=>i.length>0);return l.length>0?l:void 0}}}function oe(a,l){const i=[];if(a.content&&typeof a.content=="object")for(const r of Object.values(a.content))typeof r=="string"&&r.trim().length>0&&i.push(r.trim());const s=[];return s.push(`# ${l}`),a.description?.trim()&&s.push(a.description.trim()),[...s,...i].join(`
2
2
 
3
3
  `).trim()}function _(a,l){const i=a.name||l.name,s={registryId:a.id,registryEndpoint:a.endpoint,registrySource:te,author:a.author,category:"general"};for(const r of ie){const o=l[r];if(o!==void 0)if(r==="tags"){const m=U(o);m&&(s[r]=m)}else s[r]=o}!s.version&&a.version&&(s.version=a.version),!s.tags&&a.tags&&(s.tags=U(a.tags));const d=s.tags;if(d){const r=["knowledge","architecture","rules"],o=d.find(m=>r.includes(m.toLowerCase()));o&&(s.type=o.toLowerCase())}for(const[r,o]of Object.entries(s))o==null&&delete s[r];return{title:i,content:oe(l,i),metadata:Object.keys(s).length>0?s:void 0}}function H({open:a,onOpenChange:l,onImport:i}){return e.jsx(ee,{open:a,onOpenChange:l,categoryId:"knowledge",title:"Coconut Registry – Knowledge",confirmLabel:"Import Knowledge",getDetail:s=>se(s.endpoint),renderPreview:(s,d)=>{if(!d)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a knowledge item to preview"});const r=_(s,d),o=r.metadata??{},m=typeof o.version=="string"?o.version:void 0,h=Array.isArray(s.tags)?s.tags:[],y=typeof o.category=="string"?o.category:"general",w=typeof o.type=="string"?o.type:void 0;return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(V,{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:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]}),m&&e.jsxs(j,{variant:"outline",children:["v",m]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:s.id})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(j,{variant:"secondary",className:"capitalize",children:y}),w&&e.jsx(j,{variant:"outline",className:"capitalize",children:w})]}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(g=>e.jsx(j,{variant:"secondary",children:g},g))})]}),e.jsx(q,{className:"[&_.prose]:max-w-none",children:r.content})]})})})},onConfirm:async(s,d)=>{const r=_(s,d);await i({summary:s,detail:d,payload:r})}})}const J=a=>{if(!a)return"Unknown";const l=new Date(a);if(Number.isNaN(l.getTime()))return a;const s=new Date().getTime()-l.getTime(),d=Math.floor(s/6e4),r=Math.floor(s/36e5),o=Math.floor(s/864e5);return d<1?"Just now":d<60?`${d} minute${d===1?"":"s"} ago`:r<24?`${r} hour${r===1?"":"s"} ago`:o<7?`${o} day${o===1?"":"s"} ago`:new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(l)};function je(){const a=Q(),[l,i]=p.useState([]),[s,d]=p.useState(!0),[r,o]=p.useState({}),[m,h]=p.useState(!1),[y,w]=p.useState(!1),[g,Y]=p.useState("updated"),[A,S]=p.useState("desc"),{toast:u}=W(),v=p.useCallback(async()=>{d(!0);try{const t=await fetch(`${$}/api/v1/knowledge`);if(!t.ok)throw new Error("Failed to load knowledge");const n=await t.json();i(n.documents||[])}catch(t){console.error("Failed to load knowledge:",t),i([])}finally{d(!1)}},[]);p.useEffect(()=>{v()},[v]);const N=t=>{g===t?S(n=>n==="asc"?"desc":"asc"):(Y(t),S(t==="updated"?"desc":"asc"))},G=[...l].sort((t,n)=>{let c=0;switch(g){case"file":c=(t.title||t.filename).localeCompare(n.title||n.filename);break;case"category":c=(t.metadata.category||"general").localeCompare(n.metadata.category||"general");break;case"updated":{const f=new Date(t.metadata.updated||0).getTime(),E=new Date(n.metadata.updated||0).getTime();c=f-E;break}}return A==="asc"?c:-c}),b=({column:t})=>g!==t?e.jsx(ae,{className:"h-3 w-3 ml-1 opacity-50"}):A==="asc"?e.jsx(ne,{className:"h-3 w-3 ml-1"}):e.jsx(re,{className:"h-3 w-3 ml-1"}),k=async t=>{const n=`.nut/knowledge/${t}`;try{await Z(n),o(c=>({...c,[t]:!0})),setTimeout(()=>{o(c=>({...c,[t]:!1}))},2e3),u({title:"Path copied!",description:`Copied ${n} to clipboard`})}catch(c){console.error("Failed to copy path:",c),u({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},D=t=>{const n=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${t.filename.replace(".md","")}`,filename:t.filename,name:t.filename,path:`.nut/knowledge/${t.filename}`}});window.dispatchEvent(n)},T=p.useCallback(async({payload:t})=>{let n=!1;w(!0);try{const c=await fetch(`${$}/api/v1/knowledge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t.title,content:t.content,metadata:t.metadata})});let f=null;try{f=await c.json()}catch(F){console.error("Failed to parse registry import response:",F)}if(!(c.ok&&f?.success)){const R=(typeof f?.error=="string"?f.error:f?.error?.message)||c.statusText||"Failed to import knowledge from registry";throw u({title:"Failed to import knowledge",description:R,variant:"destructive"}),n=!0,new Error(R)}u({title:"Knowledge imported",description:`${t.title} is now available in Coconut`}),await v()}catch(c){if(!n){const f=c instanceof Error&&c.message?c.message:"Failed to import knowledge from registry";u({title:"Failed to import knowledge",description:f,variant:"destructive"})}throw c}finally{w(!1)}},[v,u]);return s?e.jsx("div",{className:"space-y-6",children:e.jsx(L,{children:e.jsx(B,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(X,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge base..."})]})})})}):l.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Knowledge Base"}),e.jsx("p",{className:"text-muted-foreground",children:"Accumulated project knowledge, patterns, and best practices"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>h(!0),disabled:y,children:[e.jsx(O,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(x,{size:"sm",asChild:!0,children:e.jsxs(P,{to:"/knowledge/new",children:[e.jsx(z,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(L,{children:e.jsx(B,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Knowledge Documents Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Knowledge documents will appear here as they are created."})]})})})]}),e.jsx(H,{open:m,onOpenChange:h,onImport:T})]}):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("h1",{className:"text-2xl font-bold tracking-tight",children:"Knowledge Base"}),e.jsxs("p",{className:"text-muted-foreground",children:["Accumulated project knowledge, patterns, and best practices (",l.length," documents)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>h(!0),disabled:y,children:[e.jsx(O,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(x,{size:"sm",asChild:!0,children:e.jsxs(P,{to:"/knowledge/new",children:[e.jsx(z,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden",children:[e.jsxs("div",{className:"hidden bg-muted/50 px-4 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground md:grid md:grid-cols-[minmax(0,2.5fr),minmax(0,1fr),minmax(0,1fr),auto] md:items-center md:gap-4",children:[e.jsxs("button",{type:"button",onClick:()=>N("file"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["File",e.jsx(b,{column:"file"})]}),e.jsxs("button",{type:"button",onClick:()=>N("category"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["Category",e.jsx(b,{column:"category"})]}),e.jsxs("button",{type:"button",onClick:()=>N("updated"),className:"flex items-center hover:text-foreground transition-colors text-left",children:["Updated",e.jsx(b,{column:"updated"})]}),e.jsx("span",{className:"justify-self-end",children:"Actions"})]}),e.jsx("div",{className:"divide-y",children:G.map(t=>e.jsxs("div",{onClick:()=>a(`/knowledge/${t.filename.replace(".md","")}`),className:"px-3 py-3 transition-colors hover:bg-muted/60 cursor-pointer md:px-4 md:py-4 md:grid md:grid-cols-[minmax(0,2.5fr),minmax(0,1fr),minmax(0,1fr),auto] md:items-center md:gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 md:hidden",children:[e.jsx("div",{className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:e.jsx(C,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium text-foreground text-sm",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(j,{variant:"secondary",className:"capitalize text-[10px] px-1.5 py-0",children:t.metadata.category||"general"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:J(t.metadata.updated)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),D(t)},className:"h-7 w-7",title:"Discuss in chat",children:e.jsx(K,{className:"h-3 w-3"})}),e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),k(t.filename)},className:"h-7 w-7",title:"Copy file path to clipboard",children:r[t.filename]?e.jsx(I,{className:"h-3 w-3 text-green-600"}):e.jsx(M,{className:"h-3 w-3"})})]})]})})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:e.jsx(C,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("div",{className:"block truncate font-medium text-foreground",children:t.title}),e.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),k(t.filename)},className:`inline-flex max-w-full items-center overflow-hidden rounded bg-muted px-2 py-1 font-mono text-xs text-muted-foreground transition-colors hover:bg-muted/80${r[t.filename]?" ring-1 ring-primary/50 text-foreground":""}`,title:"Copy file path to clipboard",children:e.jsxs("span",{className:"truncate",children:[".nut/knowledge/",t.filename]})})]})]}),e.jsx("div",{className:"hidden md:block",children:e.jsx(j,{variant:"secondary",className:"capitalize",children:t.metadata.category||"general"})}),e.jsx("div",{className:"hidden text-sm text-muted-foreground md:block",children:J(t.metadata.updated)}),e.jsxs("div",{className:"hidden md:flex items-center gap-1 justify-end",children:[e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),D(t)},className:"h-8 w-8",title:"Discuss in chat",children:e.jsx(K,{className:"h-3.5 w-3.5"})}),e.jsx(x,{variant:"ghost",size:"icon",onClick:n=>{n.stopPropagation(),k(t.filename)},className:"h-8 w-8",title:"Copy file path to clipboard",children:r[t.filename]?e.jsx(I,{className:"h-3 w-3 text-green-600"}):e.jsx(M,{className:"h-3 w-3"})})]})]},t.filename))})]})]}),e.jsx(H,{open:m,onOpenChange:h,onImport:T})]})}export{je as default};
@@ -1 +1 @@
1
- import{u as I,q as z,s as B,r as t,j as e,t as g,I as l,B as y,v as n}from"./index-CoIuEZL-.js";import{L as c}from"./label-j04IpCQ3.js";import{C as D,b as k,c as H,d as M,a as O}from"./card-BmKLfTSE.js";import{T as V,a as W,b as w,c as N}from"./tabs-Oc0OBkXw.js";function Q(){const i=I(),o=z(),{login:b,register:C,isAuthenticated:h,authEnabled:x,isLoading:m}=B(),[a,d]=t.useState(!1),[L,S]=t.useState("login"),[p,E]=t.useState(""),[f,T]=t.useState(""),[j,F]=t.useState(""),[u,P]=t.useState(""),[v,R]=t.useState("");t.useEffect(()=>{if(!m){if(!x)i("/");else if(h){const s=o.state?.from?.pathname||"/";i(s,{replace:!0})}}},[x,h,m,i,o]);const q=async s=>{s.preventDefault(),d(!0);try{await b(p,f),n({title:"Success",description:"Logged in successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Login failed",description:r.message||"Invalid email or password",variant:"destructive"})}finally{d(!1)}},A=async s=>{if(s.preventDefault(),u.length<8){n({title:"Invalid password",description:"Password must be at least 8 characters",variant:"destructive"});return}d(!0);try{await C(j,u,v),n({title:"Success",description:"Account created successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Registration failed",description:r.message||"Failed to create account",variant:"destructive"})}finally{d(!1)}};return m?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-background to-muted p-4",children:e.jsxs(D,{className:"w-full max-w-md",children:[e.jsxs(k,{className:"space-y-1 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("svg",{className:"h-12 w-12 text-green-600",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"})})}),e.jsx(H,{className:"text-2xl font-bold",children:"Welcome to Coconut"}),e.jsx(M,{children:"Sign in to your account or create a new one"})]}),e.jsx(O,{children:e.jsxs(V,{value:L,onValueChange:s=>S(s),children:[e.jsxs(W,{className:"grid w-full grid-cols-2",children:[e.jsx(w,{value:"login",children:"Login"}),e.jsx(w,{value:"register",children:"Register"})]}),e.jsx(N,{value:"login",className:"space-y-4",children:e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-email",children:"Email"}),e.jsx(l,{id:"login-email",type:"email",placeholder:"you@example.com",value:p,onChange:s=>E(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-password",children:"Password"}),e.jsx(l,{id:"login-password",type:"password",value:f,onChange:s=>T(s.target.value),required:!0,disabled:a})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Logging in..."]}):"Login"})]})}),e.jsx(N,{value:"register",className:"space-y-4",children:e.jsxs("form",{onSubmit:A,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-email",children:"Email"}),e.jsx(l,{id:"register-email",type:"email",placeholder:"you@example.com",value:j,onChange:s=>F(s.target.value),required:!0,disabled:a}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only whitelisted emails can register"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-name",children:"Name"}),e.jsx(l,{id:"register-name",type:"text",placeholder:"Your name",value:v,onChange:s=>R(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-password",children:"Password"}),e.jsx(l,{id:"register-password",type:"password",value:u,onChange:s=>P(s.target.value),required:!0,disabled:a,minLength:8}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"At least 8 characters"})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account..."]}):"Create Account"})]})})]})})]})})}export{Q as default};
1
+ import{u as I,q as z,s as B,r as t,j as e,t as g,I as l,B as y,v as n}from"./index-C5Azpb6Z.js";import{L as c}from"./label-Dk87UyXm.js";import{C as D,b as k,c as H,d as M,a as O}from"./card-BHJKBprp.js";import{T as V,a as W,b as w,c as N}from"./tabs-HysYyLO3.js";function Q(){const i=I(),o=z(),{login:b,register:C,isAuthenticated:h,authEnabled:x,isLoading:m}=B(),[a,d]=t.useState(!1),[L,S]=t.useState("login"),[p,E]=t.useState(""),[f,T]=t.useState(""),[j,F]=t.useState(""),[u,P]=t.useState(""),[v,R]=t.useState("");t.useEffect(()=>{if(!m){if(!x)i("/");else if(h){const s=o.state?.from?.pathname||"/";i(s,{replace:!0})}}},[x,h,m,i,o]);const q=async s=>{s.preventDefault(),d(!0);try{await b(p,f),n({title:"Success",description:"Logged in successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Login failed",description:r.message||"Invalid email or password",variant:"destructive"})}finally{d(!1)}},A=async s=>{if(s.preventDefault(),u.length<8){n({title:"Invalid password",description:"Password must be at least 8 characters",variant:"destructive"});return}d(!0);try{await C(j,u,v),n({title:"Success",description:"Account created successfully"});const r=o.state?.from?.pathname||"/";i(r,{replace:!0})}catch(r){n({title:"Registration failed",description:r.message||"Failed to create account",variant:"destructive"})}finally{d(!1)}};return m?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-background to-muted p-4",children:e.jsxs(D,{className:"w-full max-w-md",children:[e.jsxs(k,{className:"space-y-1 text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("svg",{className:"h-12 w-12 text-green-600",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"})})}),e.jsx(H,{className:"text-2xl font-bold",children:"Welcome to Coconut"}),e.jsx(M,{children:"Sign in to your account or create a new one"})]}),e.jsx(O,{children:e.jsxs(V,{value:L,onValueChange:s=>S(s),children:[e.jsxs(W,{className:"grid w-full grid-cols-2",children:[e.jsx(w,{value:"login",children:"Login"}),e.jsx(w,{value:"register",children:"Register"})]}),e.jsx(N,{value:"login",className:"space-y-4",children:e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-email",children:"Email"}),e.jsx(l,{id:"login-email",type:"email",placeholder:"you@example.com",value:p,onChange:s=>E(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"login-password",children:"Password"}),e.jsx(l,{id:"login-password",type:"password",value:f,onChange:s=>T(s.target.value),required:!0,disabled:a})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Logging in..."]}):"Login"})]})}),e.jsx(N,{value:"register",className:"space-y-4",children:e.jsxs("form",{onSubmit:A,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-email",children:"Email"}),e.jsx(l,{id:"register-email",type:"email",placeholder:"you@example.com",value:j,onChange:s=>F(s.target.value),required:!0,disabled:a}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only whitelisted emails can register"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-name",children:"Name"}),e.jsx(l,{id:"register-name",type:"text",placeholder:"Your name",value:v,onChange:s=>R(s.target.value),required:!0,disabled:a})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"register-password",children:"Password"}),e.jsx(l,{id:"register-password",type:"password",value:u,onChange:s=>P(s.target.value),required:!0,disabled:a,minLength:8}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"At least 8 characters"})]}),e.jsx(y,{type:"submit",className:"w-full",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating account..."]}):"Create Account"})]})})]})})]})})}export{Q as default};
@@ -1 +1 @@
1
- import{a as A,r as i,A as N,j as e,bJ as D,B as v,bK as T,t as w,k,bL as L,n as R}from"./index-CoIuEZL-.js";import{C as y,a as C}from"./card-BmKLfTSE.js";import{B as j}from"./badge-D-5A_jAJ.js";import{M as B}from"./MailProcessingModal-CmlWaFvR.js";import{R as U}from"./refresh-cw-CG3rbxSH.js";import{P as M}from"./paperclip-DJuC6Yk8.js";import{C as $}from"./chevron-up-DcYrGzFP.js";import{C as F}from"./clock-BtaA4__3.js";function O(a){if(!a)return"";try{const s=new Date(a),x=new Date().getTime()-s.getTime(),o=Math.floor(x/(1e3*60*60*24));return o===0?s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):o<7?s.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return a}}function z(a){const s=a.match(/^([^<]+)\s*</);return s?s[1].trim():a.split("@")[0]||a}function J(a,s=120){const c=a.replace(/\n+/g," ").trim();return c.length<=s?c:c.slice(0,s)+"..."}function _({startedAt:a}){const[s,c]=i.useState("");return i.useEffect(()=>{function x(){const f=new Date(a).getTime(),h=Date.now(),m=Math.floor((h-f)/1e3);if(m<60)c(`${m}s`);else{const p=Math.floor(m/60),d=m%60;c(`${p}m ${d}s`)}}x();const o=setInterval(x,1e3);return()=>clearInterval(o)},[a]),e.jsxs("span",{className:"flex items-center gap-1 text-blue-600 dark:text-blue-400",children:[e.jsx(F,{className:"h-3 w-3"}),s]})}function Y(){const{toast:a}=A(),[s,c]=i.useState([]),[x,o]=i.useState(!0),[f,h]=i.useState(null),[m,p]=i.useState(null),[d,g]=i.useState(null),l=i.useRef(null),u=i.useCallback(async(t=!1)=>{try{t||o(!0);const r=await(await fetch(`${N}/api/v1/mail/inbox`)).json();r.success&&c(r.data.messages||[])}catch(n){console.error("Failed to fetch inbox:",n)}finally{t||o(!1)}},[]);i.useEffect(()=>{u()},[u]),i.useEffect(()=>{const t=s.some(n=>n.processing);return t&&!l.current?l.current=setInterval(()=>u(!0),5e3):!t&&l.current&&(clearInterval(l.current),l.current=null),()=>{l.current&&(clearInterval(l.current),l.current=null)}},[s,u]);const S=async(t,n)=>{n.stopPropagation(),p(t);try{const b=await(await fetch(`${N}/api/v1/mail/${t}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"read"})})).json();b.success?(c(P=>P.filter(E=>E.id!==t)),f===t&&h(null),a({title:"Marked as read",description:"Email moved to Read folder."})):a({title:"Error",description:b.error||"Failed to mark as read",variant:"destructive"})}catch{a({title:"Error",description:"Failed to mark as read",variant:"destructive"})}finally{p(null)}},I=d?s.find(t=>t.id===d):null;return x?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Inbox"})}),[1,2,3].map(t=>e.jsx(D,{className:"h-20 w-full"},t))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Inbox"}),s.length>0&&e.jsx(j,{variant:"secondary",children:s.length})]}),e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>u(),children:e.jsx(U,{className:"h-4 w-4"})})]}),s.length===0?e.jsx(y,{children:e.jsxs(C,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(T,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No emails in inbox"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Incoming emails will appear here when received."})]})}):e.jsx("div",{className:"space-y-2",children:s.map(t=>{const n=f===t.id;return e.jsx(y,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>h(n?null:t.id),children:e.jsxs(C,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-semibold text-sm truncate",children:z(t.from)}),t.processing&&!t.action&&e.jsxs(j,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-blue-300 text-blue-600 dark:border-blue-700 dark:text-blue-400 gap-1",children:[e.jsx(w,{className:"h-2.5 w-2.5 animate-spin"}),"Processing"]}),!t.processing&&t.action&&e.jsxs(j,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-green-300 text-green-600 dark:border-green-700 dark:text-green-400 gap-1",children:[e.jsx(k,{className:"h-2.5 w-2.5"}),"Processed"]}),t.attachments.length>0&&e.jsx(M,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:O(t.receivedAt)})]}),e.jsx("p",{className:"text-sm font-medium truncate",children:t.subject}),!n&&t.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:J(t.content)})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:r=>S(t.id,r),disabled:m===t.id,title:"Mark as read",children:e.jsx(L,{className:"h-4 w-4"})}),n?e.jsx($,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(R,{className:"h-4 w-4 text-muted-foreground"})]})]}),n&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",t.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",t.to.join(", ")]}),t.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",t.cc.join(", ")]})]}),t.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:t.attachments.map(r=>e.jsxs(j,{variant:"outline",className:"text-xs",children:[e.jsx(M,{className:"h-3 w-3 mr-1"}),r.filename]},r.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:t.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})}),t.processing&&!t.action&&e.jsx("button",{type:"button",className:"w-full text-left bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-3 text-sm cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-950/50 transition-colors",onClick:r=>{r.stopPropagation(),g(t.id)},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-blue-700 dark:text-blue-400 font-medium text-xs",children:[e.jsx(w,{className:"h-3.5 w-3.5 animate-spin"}),"Processing email..."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.processingStartedAt&&e.jsx(_,{startedAt:t.processingStartedAt}),e.jsx("span",{className:"text-blue-500 dark:text-blue-400 text-[10px] font-medium",children:"View details"})]})]})}),t.action&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium text-xs mb-1",children:[e.jsx(k,{className:"h-3.5 w-3.5"}),"Agent Action"]}),e.jsx("p",{className:"text-green-900 dark:text-green-200",children:t.action})]})]})]})},t.id)})}),d&&e.jsx(B,{open:!!d,onOpenChange:t=>{t||g(null)},mailId:d,subject:I?.subject||"",onStopped:()=>u(!0)})]})}export{Y as default};
1
+ import{a as A,r as i,A as N,j as e,bJ as D,B as v,bK as T,t as w,k,bL as L,n as R}from"./index-C5Azpb6Z.js";import{C as y,a as C}from"./card-BHJKBprp.js";import{B as j}from"./badge-WU4FRCeV.js";import{M as B}from"./MailProcessingModal-D7Ql9vO7.js";import{R as U}from"./refresh-cw-CIEDgKUC.js";import{P as M}from"./paperclip-C7-B8_IK.js";import{C as $}from"./chevron-up-BkAwyb-e.js";import{C as F}from"./clock-BwcvObAc.js";function O(a){if(!a)return"";try{const s=new Date(a),x=new Date().getTime()-s.getTime(),o=Math.floor(x/(1e3*60*60*24));return o===0?s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):o<7?s.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return a}}function z(a){const s=a.match(/^([^<]+)\s*</);return s?s[1].trim():a.split("@")[0]||a}function J(a,s=120){const c=a.replace(/\n+/g," ").trim();return c.length<=s?c:c.slice(0,s)+"..."}function _({startedAt:a}){const[s,c]=i.useState("");return i.useEffect(()=>{function x(){const f=new Date(a).getTime(),h=Date.now(),m=Math.floor((h-f)/1e3);if(m<60)c(`${m}s`);else{const p=Math.floor(m/60),d=m%60;c(`${p}m ${d}s`)}}x();const o=setInterval(x,1e3);return()=>clearInterval(o)},[a]),e.jsxs("span",{className:"flex items-center gap-1 text-blue-600 dark:text-blue-400",children:[e.jsx(F,{className:"h-3 w-3"}),s]})}function Y(){const{toast:a}=A(),[s,c]=i.useState([]),[x,o]=i.useState(!0),[f,h]=i.useState(null),[m,p]=i.useState(null),[d,g]=i.useState(null),l=i.useRef(null),u=i.useCallback(async(t=!1)=>{try{t||o(!0);const r=await(await fetch(`${N}/api/v1/mail/inbox`)).json();r.success&&c(r.data.messages||[])}catch(n){console.error("Failed to fetch inbox:",n)}finally{t||o(!1)}},[]);i.useEffect(()=>{u()},[u]),i.useEffect(()=>{const t=s.some(n=>n.processing);return t&&!l.current?l.current=setInterval(()=>u(!0),5e3):!t&&l.current&&(clearInterval(l.current),l.current=null),()=>{l.current&&(clearInterval(l.current),l.current=null)}},[s,u]);const S=async(t,n)=>{n.stopPropagation(),p(t);try{const b=await(await fetch(`${N}/api/v1/mail/${t}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"read"})})).json();b.success?(c(P=>P.filter(E=>E.id!==t)),f===t&&h(null),a({title:"Marked as read",description:"Email moved to Read folder."})):a({title:"Error",description:b.error||"Failed to mark as read",variant:"destructive"})}catch{a({title:"Error",description:"Failed to mark as read",variant:"destructive"})}finally{p(null)}},I=d?s.find(t=>t.id===d):null;return x?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Inbox"})}),[1,2,3].map(t=>e.jsx(D,{className:"h-20 w-full"},t))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Inbox"}),s.length>0&&e.jsx(j,{variant:"secondary",children:s.length})]}),e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>u(),children:e.jsx(U,{className:"h-4 w-4"})})]}),s.length===0?e.jsx(y,{children:e.jsxs(C,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(T,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No emails in inbox"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Incoming emails will appear here when received."})]})}):e.jsx("div",{className:"space-y-2",children:s.map(t=>{const n=f===t.id;return e.jsx(y,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>h(n?null:t.id),children:e.jsxs(C,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-semibold text-sm truncate",children:z(t.from)}),t.processing&&!t.action&&e.jsxs(j,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-blue-300 text-blue-600 dark:border-blue-700 dark:text-blue-400 gap-1",children:[e.jsx(w,{className:"h-2.5 w-2.5 animate-spin"}),"Processing"]}),!t.processing&&t.action&&e.jsxs(j,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-green-300 text-green-600 dark:border-green-700 dark:text-green-400 gap-1",children:[e.jsx(k,{className:"h-2.5 w-2.5"}),"Processed"]}),t.attachments.length>0&&e.jsx(M,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:O(t.receivedAt)})]}),e.jsx("p",{className:"text-sm font-medium truncate",children:t.subject}),!n&&t.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:J(t.content)})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:r=>S(t.id,r),disabled:m===t.id,title:"Mark as read",children:e.jsx(L,{className:"h-4 w-4"})}),n?e.jsx($,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(R,{className:"h-4 w-4 text-muted-foreground"})]})]}),n&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",t.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",t.to.join(", ")]}),t.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",t.cc.join(", ")]})]}),t.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:t.attachments.map(r=>e.jsxs(j,{variant:"outline",className:"text-xs",children:[e.jsx(M,{className:"h-3 w-3 mr-1"}),r.filename]},r.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:t.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})}),t.processing&&!t.action&&e.jsx("button",{type:"button",className:"w-full text-left bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-3 text-sm cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-950/50 transition-colors",onClick:r=>{r.stopPropagation(),g(t.id)},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-blue-700 dark:text-blue-400 font-medium text-xs",children:[e.jsx(w,{className:"h-3.5 w-3.5 animate-spin"}),"Processing email..."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.processingStartedAt&&e.jsx(_,{startedAt:t.processingStartedAt}),e.jsx("span",{className:"text-blue-500 dark:text-blue-400 text-[10px] font-medium",children:"View details"})]})]})}),t.action&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium text-xs mb-1",children:[e.jsx(k,{className:"h-3.5 w-3.5"}),"Agent Action"]}),e.jsx("p",{className:"text-green-900 dark:text-green-200",children:t.action})]})]})]})},t.id)})}),d&&e.jsx(B,{open:!!d,onOpenChange:t=>{t||g(null)},mailId:d,subject:I?.subject||"",onStopped:()=>u(!0)})]})}export{Y as default};
@@ -1,4 +1,4 @@
1
- import{c as M,a as D,r as t,A as k,j as e,D as R,b as T,d as $,f as C,k as P,g as I,B as S,bM as B,T as L}from"./index-CoIuEZL-.js";import{B as x}from"./badge-D-5A_jAJ.js";import{C as F}from"./clock-BtaA4__3.js";import{R as _}from"./refresh-cw-CG3rbxSH.js";/**
1
+ import{c as M,a as D,r as t,A as k,j as e,D as R,b as T,d as $,f as C,k as P,g as I,B as S,bM as B,T as L}from"./index-C5Azpb6Z.js";import{B as x}from"./badge-WU4FRCeV.js";import{C as F}from"./clock-BwcvObAc.js";import{R as _}from"./refresh-cw-CIEDgKUC.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{a as T,r as l,A as v,j as e,bJ as A,B as w,bL as L,t as k,k as C,bK as R,E as $,n as B}from"./index-CoIuEZL-.js";import{C as E,a as M}from"./card-BmKLfTSE.js";import{B as g}from"./badge-D-5A_jAJ.js";import{M as F}from"./MailProcessingModal-CmlWaFvR.js";import{R as U}from"./refresh-cw-CG3rbxSH.js";import{P as S}from"./paperclip-DJuC6Yk8.js";import{C as z}from"./chevron-up-DcYrGzFP.js";import{C as O}from"./clock-BtaA4__3.js";function J(a){if(!a)return"";try{const s=new Date(a),m=new Date().getTime()-s.getTime(),o=Math.floor(m/(1e3*60*60*24));return o===0?s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):o<7?s.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return a}}function _(a){const s=a.match(/^([^<]+)\s*</);return s?s[1].trim():a.split("@")[0]||a}function K(a,s=120){const i=a.replace(/\n+/g," ").trim();return i.length<=s?i:i.slice(0,s)+"..."}function V({startedAt:a}){const[s,i]=l.useState("");return l.useEffect(()=>{function m(){const f=new Date(a).getTime(),p=Date.now(),d=Math.floor((p-f)/1e3);if(d<60)i(`${d}s`);else{const u=Math.floor(d/60),x=d%60;i(`${u}m ${x}s`)}}m();const o=setInterval(m,1e3);return()=>clearInterval(o)},[a]),e.jsxs("span",{className:"flex items-center gap-1 text-blue-600 dark:text-blue-400",children:[e.jsx(O,{className:"h-3 w-3"}),s]})}function ee(){const{toast:a}=T(),[s,i]=l.useState([]),[m,o]=l.useState(!0),[f,p]=l.useState(null),[d,u]=l.useState(null),[x,y]=l.useState(null),c=l.useRef(null),h=l.useCallback(async(t=!1)=>{try{t||o(!0);const n=await(await fetch(`${v}/api/v1/mail/read`)).json();n.success&&i(n.data.messages||[])}catch(r){console.error("Failed to fetch read mail:",r)}finally{t||o(!1)}},[]);l.useEffect(()=>{h()},[h]),l.useEffect(()=>{const t=s.some(r=>r.processing);return t&&!c.current?c.current=setInterval(()=>h(!0),5e3):!t&&c.current&&(clearInterval(c.current),c.current=null),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[s,h]);const I=async(t,r)=>{r.stopPropagation(),u(t);try{const j=await(await fetch(`${v}/api/v1/mail/${t}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"unread"})})).json();j.success?(i(b=>b.filter(N=>N.id!==t)),f===t&&p(null),a({title:"Moved to Inbox",description:"Email moved back to Inbox."})):a({title:"Error",description:j.error||"Failed to move email",variant:"destructive"})}catch{a({title:"Error",description:"Failed to move email",variant:"destructive"})}finally{u(null)}},P=async(t,r)=>{r.stopPropagation(),u(t);try{const j=await(await fetch(`${v}/api/v1/mail/read/${t}`,{method:"DELETE"})).json();j.success?(i(b=>b.filter(N=>N.id!==t)),f===t&&p(null),a({title:"Deleted",description:"Email has been deleted."})):a({title:"Error",description:j.error||"Failed to delete email",variant:"destructive"})}catch{a({title:"Error",description:"Failed to delete email",variant:"destructive"})}finally{u(null)}},D=x?s.find(t=>t.id===x):null;return m?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Read"})}),[1,2,3].map(t=>e.jsx(A,{className:"h-20 w-full"},t))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Read"}),s.length>0&&e.jsx(g,{variant:"secondary",children:s.length})]}),e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>h(),children:e.jsx(U,{className:"h-4 w-4"})})]}),s.length===0?e.jsx(E,{children:e.jsxs(M,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(L,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No read emails"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Emails marked as read will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:s.map(t=>{const r=f===t.id;return e.jsx(E,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>p(r?null:t.id),children:e.jsxs(M,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground truncate",children:_(t.from)}),t.processing&&!t.action&&e.jsxs(g,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-blue-300 text-blue-600 dark:border-blue-700 dark:text-blue-400 gap-1",children:[e.jsx(k,{className:"h-2.5 w-2.5 animate-spin"}),"Processing"]}),!t.processing&&t.action&&e.jsxs(g,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-green-300 text-green-600 dark:border-green-700 dark:text-green-400 gap-1",children:[e.jsx(C,{className:"h-2.5 w-2.5"}),"Processed"]}),t.attachments.length>0&&e.jsx(S,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:J(t.receivedAt)})]}),e.jsx("p",{className:"text-sm truncate",children:t.subject}),!r&&t.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:K(t.content)})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:n=>I(t.id,n),disabled:d===t.id,title:"Move to Inbox",children:e.jsx(R,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"sm",onClick:n=>P(t.id,n),disabled:d===t.id,title:"Delete",className:"text-destructive hover:text-destructive",children:e.jsx($,{className:"h-4 w-4"})}),r?e.jsx(z,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(B,{className:"h-4 w-4 text-muted-foreground"})]})]}),r&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",t.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",t.to.join(", ")]}),t.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",t.cc.join(", ")]})]}),t.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:t.attachments.map(n=>e.jsxs(g,{variant:"outline",className:"text-xs",children:[e.jsx(S,{className:"h-3 w-3 mr-1"}),n.filename]},n.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:t.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})}),t.processing&&!t.action&&e.jsx("button",{type:"button",className:"w-full text-left bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-3 text-sm cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-950/50 transition-colors",onClick:n=>{n.stopPropagation(),y(t.id)},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-blue-700 dark:text-blue-400 font-medium text-xs",children:[e.jsx(k,{className:"h-3.5 w-3.5 animate-spin"}),"Processing email..."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.processingStartedAt&&e.jsx(V,{startedAt:t.processingStartedAt}),e.jsx("span",{className:"text-blue-500 dark:text-blue-400 text-[10px] font-medium",children:"View details"})]})]})}),t.action&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium text-xs mb-1",children:[e.jsx(C,{className:"h-3.5 w-3.5"}),"Agent Action"]}),e.jsx("p",{className:"text-green-900 dark:text-green-200",children:t.action})]})]})]})},t.id)})}),x&&e.jsx(F,{open:!!x,onOpenChange:t=>{t||y(null)},mailId:x,subject:D?.subject||"",onStopped:()=>h(!0)})]})}export{ee as default};
1
+ import{a as T,r as l,A as v,j as e,bJ as A,B as w,bL as L,t as k,k as C,bK as R,E as $,n as B}from"./index-C5Azpb6Z.js";import{C as E,a as M}from"./card-BHJKBprp.js";import{B as g}from"./badge-WU4FRCeV.js";import{M as F}from"./MailProcessingModal-D7Ql9vO7.js";import{R as U}from"./refresh-cw-CIEDgKUC.js";import{P as S}from"./paperclip-C7-B8_IK.js";import{C as z}from"./chevron-up-BkAwyb-e.js";import{C as O}from"./clock-BwcvObAc.js";function J(a){if(!a)return"";try{const s=new Date(a),m=new Date().getTime()-s.getTime(),o=Math.floor(m/(1e3*60*60*24));return o===0?s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):o<7?s.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return a}}function _(a){const s=a.match(/^([^<]+)\s*</);return s?s[1].trim():a.split("@")[0]||a}function K(a,s=120){const i=a.replace(/\n+/g," ").trim();return i.length<=s?i:i.slice(0,s)+"..."}function V({startedAt:a}){const[s,i]=l.useState("");return l.useEffect(()=>{function m(){const f=new Date(a).getTime(),p=Date.now(),d=Math.floor((p-f)/1e3);if(d<60)i(`${d}s`);else{const u=Math.floor(d/60),x=d%60;i(`${u}m ${x}s`)}}m();const o=setInterval(m,1e3);return()=>clearInterval(o)},[a]),e.jsxs("span",{className:"flex items-center gap-1 text-blue-600 dark:text-blue-400",children:[e.jsx(O,{className:"h-3 w-3"}),s]})}function ee(){const{toast:a}=T(),[s,i]=l.useState([]),[m,o]=l.useState(!0),[f,p]=l.useState(null),[d,u]=l.useState(null),[x,y]=l.useState(null),c=l.useRef(null),h=l.useCallback(async(t=!1)=>{try{t||o(!0);const n=await(await fetch(`${v}/api/v1/mail/read`)).json();n.success&&i(n.data.messages||[])}catch(r){console.error("Failed to fetch read mail:",r)}finally{t||o(!1)}},[]);l.useEffect(()=>{h()},[h]),l.useEffect(()=>{const t=s.some(r=>r.processing);return t&&!c.current?c.current=setInterval(()=>h(!0),5e3):!t&&c.current&&(clearInterval(c.current),c.current=null),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[s,h]);const I=async(t,r)=>{r.stopPropagation(),u(t);try{const j=await(await fetch(`${v}/api/v1/mail/${t}/status`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"unread"})})).json();j.success?(i(b=>b.filter(N=>N.id!==t)),f===t&&p(null),a({title:"Moved to Inbox",description:"Email moved back to Inbox."})):a({title:"Error",description:j.error||"Failed to move email",variant:"destructive"})}catch{a({title:"Error",description:"Failed to move email",variant:"destructive"})}finally{u(null)}},P=async(t,r)=>{r.stopPropagation(),u(t);try{const j=await(await fetch(`${v}/api/v1/mail/read/${t}`,{method:"DELETE"})).json();j.success?(i(b=>b.filter(N=>N.id!==t)),f===t&&p(null),a({title:"Deleted",description:"Email has been deleted."})):a({title:"Error",description:j.error||"Failed to delete email",variant:"destructive"})}catch{a({title:"Error",description:"Failed to delete email",variant:"destructive"})}finally{u(null)}},D=x?s.find(t=>t.id===x):null;return m?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Read"})}),[1,2,3].map(t=>e.jsx(A,{className:"h-20 w-full"},t))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Read"}),s.length>0&&e.jsx(g,{variant:"secondary",children:s.length})]}),e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>h(),children:e.jsx(U,{className:"h-4 w-4"})})]}),s.length===0?e.jsx(E,{children:e.jsxs(M,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(L,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No read emails"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Emails marked as read will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:s.map(t=>{const r=f===t.id;return e.jsx(E,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>p(r?null:t.id),children:e.jsxs(M,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground truncate",children:_(t.from)}),t.processing&&!t.action&&e.jsxs(g,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-blue-300 text-blue-600 dark:border-blue-700 dark:text-blue-400 gap-1",children:[e.jsx(k,{className:"h-2.5 w-2.5 animate-spin"}),"Processing"]}),!t.processing&&t.action&&e.jsxs(g,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-green-300 text-green-600 dark:border-green-700 dark:text-green-400 gap-1",children:[e.jsx(C,{className:"h-2.5 w-2.5"}),"Processed"]}),t.attachments.length>0&&e.jsx(S,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:J(t.receivedAt)})]}),e.jsx("p",{className:"text-sm truncate",children:t.subject}),!r&&t.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:K(t.content)})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:n=>I(t.id,n),disabled:d===t.id,title:"Move to Inbox",children:e.jsx(R,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"sm",onClick:n=>P(t.id,n),disabled:d===t.id,title:"Delete",className:"text-destructive hover:text-destructive",children:e.jsx($,{className:"h-4 w-4"})}),r?e.jsx(z,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(B,{className:"h-4 w-4 text-muted-foreground"})]})]}),r&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",t.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",t.to.join(", ")]}),t.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",t.cc.join(", ")]})]}),t.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:t.attachments.map(n=>e.jsxs(g,{variant:"outline",className:"text-xs",children:[e.jsx(S,{className:"h-3 w-3 mr-1"}),n.filename]},n.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:t.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})}),t.processing&&!t.action&&e.jsx("button",{type:"button",className:"w-full text-left bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-3 text-sm cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-950/50 transition-colors",onClick:n=>{n.stopPropagation(),y(t.id)},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-blue-700 dark:text-blue-400 font-medium text-xs",children:[e.jsx(k,{className:"h-3.5 w-3.5 animate-spin"}),"Processing email..."]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.processingStartedAt&&e.jsx(V,{startedAt:t.processingStartedAt}),e.jsx("span",{className:"text-blue-500 dark:text-blue-400 text-[10px] font-medium",children:"View details"})]})]})}),t.action&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium text-xs mb-1",children:[e.jsx(C,{className:"h-3.5 w-3.5"}),"Agent Action"]}),e.jsx("p",{className:"text-green-900 dark:text-green-200",children:t.action})]})]})]})},t.id)})}),x&&e.jsx(F,{open:!!x,onOpenChange:t=>{t||y(null)},mailId:x,subject:D?.subject||"",onStopped:()=>h(!0)})]})}export{ee as default};
@@ -1 +1 @@
1
- import{r as c,A as j,j as e,bJ as p,B as N,bD as g,n as w}from"./index-CoIuEZL-.js";import{C as m,a as x}from"./card-BmKLfTSE.js";import{B as h}from"./badge-D-5A_jAJ.js";import{R as v}from"./refresh-cw-CG3rbxSH.js";import{P as u}from"./paperclip-DJuC6Yk8.js";import{C as y}from"./chevron-up-DcYrGzFP.js";function b(t){if(!t)return"";try{const a=new Date(t),i=new Date().getTime()-a.getTime(),l=Math.floor(i/(1e3*60*60*24));return l===0?a.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):l<7?a.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return t}}function C(t,a=120){const r=t.replace(/\n+/g," ").trim();return r.length<=a?r:r.slice(0,a)+"..."}function P(){const[t,a]=c.useState([]),[r,i]=c.useState(!0),[l,f]=c.useState(null),o=c.useCallback(async()=>{try{i(!0);const n=await(await fetch(`${j}/api/v1/mail/sent`)).json();n.success&&a(n.data.messages||[])}catch(s){console.error("Failed to fetch sent mail:",s)}finally{i(!1)}},[]);return c.useEffect(()=>{o()},[o]),r?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Sent"})}),[1,2,3].map(s=>e.jsx(p,{className:"h-20 w-full"},s))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sent"}),t.length>0&&e.jsx(h,{variant:"secondary",children:t.length})]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:o,children:e.jsx(v,{className:"h-4 w-4"})})]}),t.length===0?e.jsx(m,{children:e.jsxs(x,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(g,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No sent emails"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Replies and sent emails will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:t.map(s=>{const n=l===s.id;return e.jsx(m,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>f(n?null:s.id),children:e.jsxs(x,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-sm text-muted-foreground truncate",children:["To: ",s.to.join(", ")]}),s.attachments.length>0&&e.jsx(u,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:b(s.receivedAt)})]}),e.jsx("p",{className:"text-sm truncate",children:s.subject}),!n&&s.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:C(s.content)})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:n?e.jsx(y,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(w,{className:"h-4 w-4 text-muted-foreground"})})]}),n&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",s.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",s.to.join(", ")]}),s.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",s.cc.join(", ")]})]}),s.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:s.attachments.map(d=>e.jsxs(h,{variant:"outline",className:"text-xs",children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),d.filename]},d.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:s.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})})]})]})},s.id)})})]})}export{P as default};
1
+ import{r as c,A as j,j as e,bJ as p,B as N,bD as g,n as w}from"./index-C5Azpb6Z.js";import{C as m,a as x}from"./card-BHJKBprp.js";import{B as h}from"./badge-WU4FRCeV.js";import{R as v}from"./refresh-cw-CIEDgKUC.js";import{P as u}from"./paperclip-C7-B8_IK.js";import{C as y}from"./chevron-up-BkAwyb-e.js";function b(t){if(!t)return"";try{const a=new Date(t),i=new Date().getTime()-a.getTime(),l=Math.floor(i/(1e3*60*60*24));return l===0?a.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):l<7?a.toLocaleDateString("en-US",{weekday:"short",hour:"numeric",minute:"2-digit"}):a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return t}}function C(t,a=120){const r=t.replace(/\n+/g," ").trim();return r.length<=a?r:r.slice(0,a)+"..."}function P(){const[t,a]=c.useState([]),[r,i]=c.useState(!0),[l,f]=c.useState(null),o=c.useCallback(async()=>{try{i(!0);const n=await(await fetch(`${j}/api/v1/mail/sent`)).json();n.success&&a(n.data.messages||[])}catch(s){console.error("Failed to fetch sent mail:",s)}finally{i(!1)}},[]);return c.useEffect(()=>{o()},[o]),r?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h2",{className:"text-lg font-semibold",children:"Sent"})}),[1,2,3].map(s=>e.jsx(p,{className:"h-20 w-full"},s))]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sent"}),t.length>0&&e.jsx(h,{variant:"secondary",children:t.length})]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:o,children:e.jsx(v,{className:"h-4 w-4"})})]}),t.length===0?e.jsx(m,{children:e.jsxs(x,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(g,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-muted-foreground",children:"No sent emails"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Replies and sent emails will appear here."})]})}):e.jsx("div",{className:"space-y-2",children:t.map(s=>{const n=l===s.id;return e.jsx(m,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>f(n?null:s.id),children:e.jsxs(x,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-sm text-muted-foreground truncate",children:["To: ",s.to.join(", ")]}),s.attachments.length>0&&e.jsx(u,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-auto flex-shrink-0",children:b(s.receivedAt)})]}),e.jsx("p",{className:"text-sm truncate",children:s.subject}),!n&&s.content&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:C(s.content)})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:n?e.jsx(y,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(w,{className:"h-4 w-4 text-muted-foreground"})})]}),n&&e.jsxs("div",{className:"mt-4 pt-4 border-t space-y-3",children:[e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"From:"})," ",s.from]}),e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"To:"})," ",s.to.join(", ")]}),s.cc.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"CC:"})," ",s.cc.join(", ")]})]}),s.attachments.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:s.attachments.map(d=>e.jsxs(h,{variant:"outline",className:"text-xs",children:[e.jsx(u,{className:"h-3 w-3 mr-1"}),d.filename]},d.id))}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/50 rounded-md p-3",children:s.content||e.jsx("span",{className:"text-muted-foreground italic",children:"No content"})})]})]})},s.id)})})]})}export{P as default};
@@ -1 +1 @@
1
- import{j as e,S as ne,_ as k,r as b,bw as q,v as f,bv as ie,bt as ae,B as C,P as B,I as u,o as R,Y as oe,E as le,F as ce,l as de}from"./index-CoIuEZL-.js";import{C as L,b as T,c as O,d as $,a as U}from"./card-BmKLfTSE.js";import{L as h}from"./label-j04IpCQ3.js";import{B as P}from"./badge-D-5A_jAJ.js";import{S as I}from"./switch-CuxAwq5S.js";import{A as z,a as Y}from"./alert-CGO08-55.js";import{R as me,L as he}from"./browser-modal-G-Zh1FPt.js";import{R as xe}from"./registry-ANRa5WBi.js";import{C as J}from"./circle-alert-CngqosqJ.js";import{C as ve}from"./circle-check-big-P_y4fjqZ.js";import"./search-PHGXbkfS.js";function K(t){if(t){if(Array.isArray(t)){const n=t.map(l=>{if(typeof l=="string")return l.trim();if(typeof l=="number")return`${l}`}).filter(l=>typeof l=="string"&&l.length>0);return n.length>0?n:void 0}if(typeof t=="string"){const n=t.split(",").map(l=>l.trim()).filter(l=>l.length>0);return n.length>0?n:void 0}}}function G(t,n){const l=t.name||n.name,x=n.description||t.description||"",a={registryId:t.id,registryEndpoint:t.endpoint,registrySource:xe,author:t.author||n.author};(n.version||t.version)&&(a.version=n.version||t.version);const d=K(n.tags)||K(t.tags);d&&(a.tags=d),n.capabilities&&Array.isArray(n.capabilities)&&(a.capabilities=n.capabilities),n.requirements&&typeof n.requirements=="object"&&(a.requirements=n.requirements),n.links&&typeof n.links=="object"&&(a.links=n.links),n.metadata&&typeof n.metadata=="object"&&(a.mcpMetadata=n.metadata);for(const[i,p]of Object.entries(a))p==null&&delete a[i];return{name:l,command:n.configuration.command,args:n.configuration.args,url:n.configuration.url,env:n.configuration.env,enabled:!0,description:x,metadata:Object.keys(a).length>0?a:void 0}}async function pe(t){const n=t.startsWith("http")?t:`https://registry.coconut.dev${t}`,l=await fetch(n,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!l.ok)throw new Error(`Failed to fetch MCP server detail: ${l.status}`);return l.json()}function ue({open:t,onOpenChange:n,onImport:l}){return e.jsx(me,{open:t,onOpenChange:n,categoryId:"mcp-servers",title:"Coconut Registry – MCP Servers",confirmLabel:"Add Server",getDetail:x=>pe(x.endpoint),renderPreview:(x,a)=>{if(!a)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select an MCP server to preview"});const d=G(x,a),i=d.metadata??{},p=typeof i.version=="string"?i.version:void 0,y=Array.isArray(x.tags)?x.tags:[],w=Array.isArray(i.capabilities)?i.capabilities.filter(j=>typeof j=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(ne,{className:"h-full",children:e.jsx("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:x.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.description})]}),p&&e.jsxs(P,{variant:"outline",children:["v",p]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:x.id})]}),y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(j=>e.jsx(P,{variant:"secondary",children:j},j))}),e.jsxs("div",{className:"space-y-2 rounded-md border p-3 bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Configuration"}),e.jsx(P,{variant:"outline",className:"text-xs",children:d.url?"HTTP":"stdio"})]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono",children:[d.url?e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"URL:"})," ",e.jsx("span",{className:"text-foreground break-all",children:d.url})]}):e.jsxs(e.Fragment,{children:[d.command&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Command:"})," ",e.jsx("span",{className:"text-foreground",children:d.command})]}),d.args&&d.args.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Args:"})," ",e.jsx("span",{className:"text-foreground",children:d.args.join(" ")})]})]}),d.env&&Object.keys(d.env).length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Env:"})," ",e.jsx("span",{className:"text-foreground",children:JSON.stringify(d.env)})]})]})]}),w.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Capabilities"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground space-y-1",children:w.map(j=>e.jsx("li",{children:j},j))})]}),a.documentation&&e.jsxs("div",{className:"space-y-3",children:[a.documentation.overview&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Overview"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.overview})]}),a.documentation.installation&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Installation"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.installation})]}),a.documentation.usage&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Usage"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.usage})]}),a.documentation.examples&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Examples"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.examples})]})]})]})})})})},onConfirm:async(x,a)=>{const d=G(x,a);await l({summary:x,detail:a,payload:d})}})}function Ae(){const[t,n]=b.useState({}),[l,x]=b.useState(!0),[a,d]=b.useState(!1),[i,p]=b.useState({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),[y,w]=b.useState(!1),[j,M]=b.useState(null),[o,N]=b.useState({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),[V,_]=b.useState(!1);b.useEffect(()=>{D()},[]);const D=async()=>{try{x(!0);const s=await q("/api/v1/mcp/raw-config");n(s||{})}catch(s){console.error("Failed to load MCP config:",s),f({title:"Error",description:"Failed to load MCP configuration",variant:"destructive"})}finally{x(!1)}},E=async s=>{try{d(!0),await q("/api/v1/mcp/raw-config",{method:"PUT",body:JSON.stringify(s)}),n(s),f({title:"Success",description:"MCP configuration saved successfully"})}catch(r){console.error("Failed to save MCP config:",r),f({title:"Error",description:"Failed to save MCP configuration",variant:"destructive"})}finally{d(!1)}},W=()=>{if(!i.name){f({title:"Error",description:"Server name is required",variant:"destructive"});return}const s=i.command.trim().length>0,r=i.url.trim().length>0;if(!s&&!r){f({title:"Error",description:"Either Command (for stdio) or URL (for HTTP) is required",variant:"destructive"});return}if(s&&r){f({title:"Error",description:"Provide either Command or URL, not both",variant:"destructive"});return}const c={name:i.name,enabled:i.enabled,description:i.description||void 0};if(s?(c.type="stdio",c.command=i.command,i.args.trim()&&(c.args=i.args.split(" ").filter(g=>g.trim()))):(c.type="http",c.url=i.url),i.env.trim())try{c.env=JSON.parse(i.env)}catch{f({title:"Error",description:"Invalid JSON format for environment variables",variant:"destructive"});return}const v={...t,mcpServers:{...t.mcpServers,[i.name]:c}};E(v),p({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),w(!1)},Q=(s,r)=>{const c={...t,mcpServers:{...t.mcpServers,[s]:{...t.mcpServers[s],enabled:r}}};E(c)},X=s=>{const{[s]:r,...c}=t.mcpServers||{},v={...t,mcpServers:c};E(v)},Z=s=>{const r=t.mcpServers?.[s];r&&(N({name:r.name||s,command:r.command||"",args:r.args?.join(" ")||"",url:r.url||"",env:r.env?JSON.stringify(r.env,null,2):"",description:r.description||"",enabled:r.enabled!==!1}),M(s))},ee=s=>{const r=o.command.trim().length>0,c=o.url.trim().length>0;if(!r&&!c){f({title:"Error",description:"Either Command (for stdio) or URL (for HTTP) is required",variant:"destructive"});return}if(r&&c){f({title:"Error",description:"Provide either Command or URL, not both",variant:"destructive"});return}const v={name:o.name,enabled:o.enabled,description:o.description||void 0};if(r?(v.type="stdio",v.command=o.command,o.args.trim()&&(v.args=o.args.split(" ").filter(A=>A.trim()))):(v.type="http",v.url=o.url),o.env.trim())try{v.env=JSON.parse(o.env)}catch{f({title:"Error",description:"Invalid JSON format for environment variables",variant:"destructive"});return}const{[s]:g,...m}=t.mcpServers||{},S={...t,mcpServers:{...m,[s]:v}};E(S),M(null)},se=()=>{M(null),N({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0})},F=s=>{const r={...t,globalSettings:{...t.globalSettings,...s}};E(r)},re=async s=>{const{payload:r}=s;let c=r.name.toLowerCase().replace(/\s+/g,"-");const v=t.mcpServers||{};let g=c,m=1;for(;v[g];)g=`${c}-${m}`,m++;const S={name:g,enabled:r.enabled!==!1,description:r.description,env:r.env};r.url?(S.type="http",S.url=r.url):r.command&&(S.type="stdio",S.command=r.command,S.args=r.args);const A={...t,mcpServers:{...t.mcpServers,[g]:S}};await E(A);const te=r.url?"HTTP":"stdio";f({title:"Success",description:`MCP server "${g}" (${te}) added from registry`})};if(l)return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"MCP Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading configuration..."})]})});const H=t.mcpServers||{};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"MCP Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Model Context Protocol servers and settings."})]}),e.jsx(ie,{}),Object.keys(H).length===0&&!y&&e.jsxs(z,{children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(Y,{children:"No MCP servers configured yet. Add your first server to get started."})]}),e.jsxs(L,{children:[e.jsx(T,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-5 w-5"}),"MCP Servers"]}),e.jsx($,{className:"hidden sm:block",children:"Configure and manage Model Context Protocol servers for enhanced AI capabilities."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>_(!0),children:[e.jsx(he,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsxs(C,{size:"sm",onClick:()=>w(!y),variant:y?"outline":"default",children:[e.jsx(B,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:y?"Cancel":"Add Server"})]})]})]})}),e.jsxs(U,{children:[y&&e.jsxs("div",{className:"space-y-4 p-3 sm:p-4 border rounded-lg mb-4",children:[e.jsx("h4",{className:"font-medium",children:"Add MCP Server"}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverName",children:"Server Name"}),e.jsx(u,{id:"serverName",value:i.name,onChange:s=>p({...i,name:s.target.value}),placeholder:"e.g., filesystem-server"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverCommand",children:"Command"}),e.jsx(u,{id:"serverCommand",value:i.command,onChange:s=>p({...i,command:s.target.value}),placeholder:"e.g., npx @modelcontextprotocol/server-filesystem"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverArgs",children:"Arguments (space-separated)"}),e.jsx(u,{id:"serverArgs",value:i.args,onChange:s=>p({...i,args:s.target.value}),placeholder:"e.g., /path/to/allowed/directory"})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverUrl",children:"URL"}),e.jsx(u,{id:"serverUrl",value:i.url,onChange:s=>p({...i,url:s.target.value}),placeholder:"e.g., https://mcp.example.com/api"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Provide either Command (for stdio) or URL (for HTTP/SSE), not both."})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverDescription",children:"Description (optional)"}),e.jsx(u,{id:"serverDescription",value:i.description,onChange:s=>p({...i,description:s.target.value}),placeholder:"Brief description of what this server provides"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverEnv",children:"Environment Variables (JSON)"}),e.jsx(R,{id:"serverEnv",value:i.env,onChange:s=>p({...i,env:s.target.value}),placeholder:'{"KEY": "value", "ANOTHER_KEY": "another_value"}',rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:"serverEnabled",checked:i.enabled,onCheckedChange:s=>p({...i,enabled:s})}),e.jsx(h,{htmlFor:"serverEnabled",children:"Enable server"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(C,{onClick:W,disabled:a,children:[e.jsx(B,{className:"h-4 w-4 mr-2"}),"Add Server"]}),e.jsx(C,{variant:"outline",onClick:()=>w(!1),children:"Cancel"})]})]}),e.jsx("div",{className:"space-y-4",children:Object.entries(H).map(([s,r])=>{const c=r.enabled!==!1,v=r.name||s,g=j===s;return e.jsx("div",{className:"border rounded-lg",children:g?e.jsxs("div",{className:"space-y-4 p-3 sm:p-4",children:[e.jsx("h4",{className:"font-medium",children:"Edit MCP Server"}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-name-${s}`,children:"Server Name"}),e.jsx(u,{id:`edit-name-${s}`,value:o.name,onChange:m=>N({...o,name:m.target.value}),placeholder:"e.g., filesystem-server"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-command-${s}`,children:"Command"}),e.jsx(u,{id:`edit-command-${s}`,value:o.command,onChange:m=>N({...o,command:m.target.value}),placeholder:"e.g., npx @modelcontextprotocol/server-filesystem"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-args-${s}`,children:"Arguments (space-separated)"}),e.jsx(u,{id:`edit-args-${s}`,value:o.args,onChange:m=>N({...o,args:m.target.value}),placeholder:"e.g., /path/to/allowed/directory"})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-url-${s}`,children:"URL"}),e.jsx(u,{id:`edit-url-${s}`,value:o.url,onChange:m=>N({...o,url:m.target.value}),placeholder:"e.g., https://mcp.example.com/api"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Provide either Command (for stdio) or URL (for HTTP/SSE), not both."})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-description-${s}`,children:"Description (optional)"}),e.jsx(u,{id:`edit-description-${s}`,value:o.description,onChange:m=>N({...o,description:m.target.value}),placeholder:"Brief description of what this server provides"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-env-${s}`,children:"Environment Variables (JSON)"}),e.jsx(R,{id:`edit-env-${s}`,value:o.env,onChange:m=>N({...o,env:m.target.value}),placeholder:'{"KEY": "value", "ANOTHER_KEY": "another_value"}',rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:`edit-enabled-${s}`,checked:o.enabled,onCheckedChange:m=>N({...o,enabled:m})}),e.jsx(h,{htmlFor:`edit-enabled-${s}`,children:"Enable server"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(C,{onClick:()=>ee(s),disabled:a,children:"Save Changes"}),e.jsx(C,{variant:"outline",onClick:se,children:"Cancel"})]})]}):e.jsx("div",{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[c?e.jsx(ve,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"}):e.jsx(J,{className:"h-4 w-4 text-gray-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"font-medium text-sm sm:text-base",children:v}),e.jsx(P,{variant:c?"default":"secondary",className:"text-xs",children:c?"Enabled":"Disabled"}),e.jsx(P,{variant:"outline",className:"text-xs",children:r.url?"HTTP":"stdio"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:r.description||r.url||r.command}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:r.url?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"URL:"})," ",r.url]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Command:"})," ",r.command," ",r.args?.join(" ")]})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 shrink-0",children:[e.jsx(I,{checked:c,onCheckedChange:m=>Q(s,m),disabled:a}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(s),children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(s),disabled:a,children:e.jsx(le,{className:"h-4 w-4"})})]})]})})},s)})})]})]}),e.jsxs(L,{children:[e.jsxs(T,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),"Configuration File"]}),e.jsxs($,{children:["The MCP configuration is stored in ",e.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:".nut/mcp/config.json"})]})]}),e.jsxs(U,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"configJson",children:"Current Configuration (JSON)"}),e.jsx(R,{id:"configJson",value:JSON.stringify(t,null,2),readOnly:!0,rows:12,className:"font-mono text-sm",placeholder:"Loading configuration..."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This is a read-only view of the current configuration. Use the forms above to make changes."})]}),e.jsxs(z,{children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(Y,{children:"Configuration changes are automatically saved to the MCP config file. This file can also be edited manually if you prefer working with JSON directly."})]})]})]}),e.jsxs(L,{children:[e.jsxs(T,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(de,{className:"h-5 w-5"}),"Global Settings"]}),e.jsx($,{children:"Configure global MCP behavior and connection settings."})]}),e.jsx(U,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"timeout",children:"Connection Timeout (ms)"}),e.jsx(u,{id:"timeout",type:"number",value:t.globalSettings?.timeout||3e4,onChange:s=>F({timeout:parseInt(s.target.value)}),placeholder:"30000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"retryAttempts",children:"Retry Attempts"}),e.jsx(u,{id:"retryAttempts",type:"number",value:t.globalSettings?.retryAttempts||3,onChange:s=>F({retryAttempts:parseInt(s.target.value)}),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"logLevel",children:"Log Level"}),e.jsxs("select",{id:"logLevel",className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",value:t.globalSettings?.logLevel||"info",onChange:s=>F({logLevel:s.target.value}),children:[e.jsx("option",{value:"debug",children:"Debug"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warn",children:"Warning"}),e.jsx("option",{value:"error",children:"Error"})]})]})]})})]}),e.jsx("div",{className:"flex justify-end space-x-2",children:e.jsx(C,{variant:"outline",onClick:D,disabled:l,children:"Reload Configuration"})}),e.jsx(ue,{open:V,onOpenChange:_,onImport:re})]})}export{Ae as default};
1
+ import{j as e,S as ne,_ as k,r as b,bw as q,v as f,bv as ie,bt as ae,B as C,P as B,I as u,o as R,Y as oe,E as le,F as ce,l as de}from"./index-C5Azpb6Z.js";import{C as L,b as T,c as O,d as $,a as U}from"./card-BHJKBprp.js";import{L as h}from"./label-Dk87UyXm.js";import{B as P}from"./badge-WU4FRCeV.js";import{S as I}from"./switch-BZ6eSoPj.js";import{A as z,a as Y}from"./alert-EL2xlTrX.js";import{R as me,L as he}from"./browser-modal-B41s3tKa.js";import{R as xe}from"./registry-ANRa5WBi.js";import{C as J}from"./circle-alert-Z70KQUGE.js";import{C as ve}from"./circle-check-big-D34PB5x-.js";import"./search-BGxb6jwl.js";function K(t){if(t){if(Array.isArray(t)){const n=t.map(l=>{if(typeof l=="string")return l.trim();if(typeof l=="number")return`${l}`}).filter(l=>typeof l=="string"&&l.length>0);return n.length>0?n:void 0}if(typeof t=="string"){const n=t.split(",").map(l=>l.trim()).filter(l=>l.length>0);return n.length>0?n:void 0}}}function G(t,n){const l=t.name||n.name,x=n.description||t.description||"",a={registryId:t.id,registryEndpoint:t.endpoint,registrySource:xe,author:t.author||n.author};(n.version||t.version)&&(a.version=n.version||t.version);const d=K(n.tags)||K(t.tags);d&&(a.tags=d),n.capabilities&&Array.isArray(n.capabilities)&&(a.capabilities=n.capabilities),n.requirements&&typeof n.requirements=="object"&&(a.requirements=n.requirements),n.links&&typeof n.links=="object"&&(a.links=n.links),n.metadata&&typeof n.metadata=="object"&&(a.mcpMetadata=n.metadata);for(const[i,p]of Object.entries(a))p==null&&delete a[i];return{name:l,command:n.configuration.command,args:n.configuration.args,url:n.configuration.url,env:n.configuration.env,enabled:!0,description:x,metadata:Object.keys(a).length>0?a:void 0}}async function pe(t){const n=t.startsWith("http")?t:`https://registry.coconut.dev${t}`,l=await fetch(n,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!l.ok)throw new Error(`Failed to fetch MCP server detail: ${l.status}`);return l.json()}function ue({open:t,onOpenChange:n,onImport:l}){return e.jsx(me,{open:t,onOpenChange:n,categoryId:"mcp-servers",title:"Coconut Registry – MCP Servers",confirmLabel:"Add Server",getDetail:x=>pe(x.endpoint),renderPreview:(x,a)=>{if(!a)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select an MCP server to preview"});const d=G(x,a),i=d.metadata??{},p=typeof i.version=="string"?i.version:void 0,y=Array.isArray(x.tags)?x.tags:[],w=Array.isArray(i.capabilities)?i.capabilities.filter(j=>typeof j=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(ne,{className:"h-full",children:e.jsx("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:x.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.description})]}),p&&e.jsxs(P,{variant:"outline",children:["v",p]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:x.id})]}),y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(j=>e.jsx(P,{variant:"secondary",children:j},j))}),e.jsxs("div",{className:"space-y-2 rounded-md border p-3 bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Configuration"}),e.jsx(P,{variant:"outline",className:"text-xs",children:d.url?"HTTP":"stdio"})]}),e.jsxs("div",{className:"space-y-1 text-sm font-mono",children:[d.url?e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"URL:"})," ",e.jsx("span",{className:"text-foreground break-all",children:d.url})]}):e.jsxs(e.Fragment,{children:[d.command&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Command:"})," ",e.jsx("span",{className:"text-foreground",children:d.command})]}),d.args&&d.args.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Args:"})," ",e.jsx("span",{className:"text-foreground",children:d.args.join(" ")})]})]}),d.env&&Object.keys(d.env).length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Env:"})," ",e.jsx("span",{className:"text-foreground",children:JSON.stringify(d.env)})]})]})]}),w.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Capabilities"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground space-y-1",children:w.map(j=>e.jsx("li",{children:j},j))})]}),a.documentation&&e.jsxs("div",{className:"space-y-3",children:[a.documentation.overview&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Overview"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.overview})]}),a.documentation.installation&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Installation"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.installation})]}),a.documentation.usage&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Usage"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.usage})]}),a.documentation.examples&&e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium mb-2",children:"Examples"}),e.jsx(k,{className:"[&_.prose]:max-w-none text-sm",children:a.documentation.examples})]})]})]})})})})},onConfirm:async(x,a)=>{const d=G(x,a);await l({summary:x,detail:a,payload:d})}})}function Ae(){const[t,n]=b.useState({}),[l,x]=b.useState(!0),[a,d]=b.useState(!1),[i,p]=b.useState({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),[y,w]=b.useState(!1),[j,M]=b.useState(null),[o,N]=b.useState({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),[V,_]=b.useState(!1);b.useEffect(()=>{D()},[]);const D=async()=>{try{x(!0);const s=await q("/api/v1/mcp/raw-config");n(s||{})}catch(s){console.error("Failed to load MCP config:",s),f({title:"Error",description:"Failed to load MCP configuration",variant:"destructive"})}finally{x(!1)}},E=async s=>{try{d(!0),await q("/api/v1/mcp/raw-config",{method:"PUT",body:JSON.stringify(s)}),n(s),f({title:"Success",description:"MCP configuration saved successfully"})}catch(r){console.error("Failed to save MCP config:",r),f({title:"Error",description:"Failed to save MCP configuration",variant:"destructive"})}finally{d(!1)}},W=()=>{if(!i.name){f({title:"Error",description:"Server name is required",variant:"destructive"});return}const s=i.command.trim().length>0,r=i.url.trim().length>0;if(!s&&!r){f({title:"Error",description:"Either Command (for stdio) or URL (for HTTP) is required",variant:"destructive"});return}if(s&&r){f({title:"Error",description:"Provide either Command or URL, not both",variant:"destructive"});return}const c={name:i.name,enabled:i.enabled,description:i.description||void 0};if(s?(c.type="stdio",c.command=i.command,i.args.trim()&&(c.args=i.args.split(" ").filter(g=>g.trim()))):(c.type="http",c.url=i.url),i.env.trim())try{c.env=JSON.parse(i.env)}catch{f({title:"Error",description:"Invalid JSON format for environment variables",variant:"destructive"});return}const v={...t,mcpServers:{...t.mcpServers,[i.name]:c}};E(v),p({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0}),w(!1)},Q=(s,r)=>{const c={...t,mcpServers:{...t.mcpServers,[s]:{...t.mcpServers[s],enabled:r}}};E(c)},X=s=>{const{[s]:r,...c}=t.mcpServers||{},v={...t,mcpServers:c};E(v)},Z=s=>{const r=t.mcpServers?.[s];r&&(N({name:r.name||s,command:r.command||"",args:r.args?.join(" ")||"",url:r.url||"",env:r.env?JSON.stringify(r.env,null,2):"",description:r.description||"",enabled:r.enabled!==!1}),M(s))},ee=s=>{const r=o.command.trim().length>0,c=o.url.trim().length>0;if(!r&&!c){f({title:"Error",description:"Either Command (for stdio) or URL (for HTTP) is required",variant:"destructive"});return}if(r&&c){f({title:"Error",description:"Provide either Command or URL, not both",variant:"destructive"});return}const v={name:o.name,enabled:o.enabled,description:o.description||void 0};if(r?(v.type="stdio",v.command=o.command,o.args.trim()&&(v.args=o.args.split(" ").filter(A=>A.trim()))):(v.type="http",v.url=o.url),o.env.trim())try{v.env=JSON.parse(o.env)}catch{f({title:"Error",description:"Invalid JSON format for environment variables",variant:"destructive"});return}const{[s]:g,...m}=t.mcpServers||{},S={...t,mcpServers:{...m,[s]:v}};E(S),M(null)},se=()=>{M(null),N({name:"",command:"",args:"",url:"",env:"",description:"",enabled:!0})},F=s=>{const r={...t,globalSettings:{...t.globalSettings,...s}};E(r)},re=async s=>{const{payload:r}=s;let c=r.name.toLowerCase().replace(/\s+/g,"-");const v=t.mcpServers||{};let g=c,m=1;for(;v[g];)g=`${c}-${m}`,m++;const S={name:g,enabled:r.enabled!==!1,description:r.description,env:r.env};r.url?(S.type="http",S.url=r.url):r.command&&(S.type="stdio",S.command=r.command,S.args=r.args);const A={...t,mcpServers:{...t.mcpServers,[g]:S}};await E(A);const te=r.url?"HTTP":"stdio";f({title:"Success",description:`MCP server "${g}" (${te}) added from registry`})};if(l)return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"MCP Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading configuration..."})]})});const H=t.mcpServers||{};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"MCP Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Model Context Protocol servers and settings."})]}),e.jsx(ie,{}),Object.keys(H).length===0&&!y&&e.jsxs(z,{children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(Y,{children:"No MCP servers configured yet. Add your first server to get started."})]}),e.jsxs(L,{children:[e.jsx(T,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-5 w-5"}),"MCP Servers"]}),e.jsx($,{className:"hidden sm:block",children:"Configure and manage Model Context Protocol servers for enhanced AI capabilities."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{size:"sm",variant:"outline",onClick:()=>_(!0),children:[e.jsx(he,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsxs(C,{size:"sm",onClick:()=>w(!y),variant:y?"outline":"default",children:[e.jsx(B,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:y?"Cancel":"Add Server"})]})]})]})}),e.jsxs(U,{children:[y&&e.jsxs("div",{className:"space-y-4 p-3 sm:p-4 border rounded-lg mb-4",children:[e.jsx("h4",{className:"font-medium",children:"Add MCP Server"}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverName",children:"Server Name"}),e.jsx(u,{id:"serverName",value:i.name,onChange:s=>p({...i,name:s.target.value}),placeholder:"e.g., filesystem-server"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverCommand",children:"Command"}),e.jsx(u,{id:"serverCommand",value:i.command,onChange:s=>p({...i,command:s.target.value}),placeholder:"e.g., npx @modelcontextprotocol/server-filesystem"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverArgs",children:"Arguments (space-separated)"}),e.jsx(u,{id:"serverArgs",value:i.args,onChange:s=>p({...i,args:s.target.value}),placeholder:"e.g., /path/to/allowed/directory"})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverUrl",children:"URL"}),e.jsx(u,{id:"serverUrl",value:i.url,onChange:s=>p({...i,url:s.target.value}),placeholder:"e.g., https://mcp.example.com/api"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Provide either Command (for stdio) or URL (for HTTP/SSE), not both."})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverDescription",children:"Description (optional)"}),e.jsx(u,{id:"serverDescription",value:i.description,onChange:s=>p({...i,description:s.target.value}),placeholder:"Brief description of what this server provides"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"serverEnv",children:"Environment Variables (JSON)"}),e.jsx(R,{id:"serverEnv",value:i.env,onChange:s=>p({...i,env:s.target.value}),placeholder:'{"KEY": "value", "ANOTHER_KEY": "another_value"}',rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:"serverEnabled",checked:i.enabled,onCheckedChange:s=>p({...i,enabled:s})}),e.jsx(h,{htmlFor:"serverEnabled",children:"Enable server"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(C,{onClick:W,disabled:a,children:[e.jsx(B,{className:"h-4 w-4 mr-2"}),"Add Server"]}),e.jsx(C,{variant:"outline",onClick:()=>w(!1),children:"Cancel"})]})]}),e.jsx("div",{className:"space-y-4",children:Object.entries(H).map(([s,r])=>{const c=r.enabled!==!1,v=r.name||s,g=j===s;return e.jsx("div",{className:"border rounded-lg",children:g?e.jsxs("div",{className:"space-y-4 p-3 sm:p-4",children:[e.jsx("h4",{className:"font-medium",children:"Edit MCP Server"}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-name-${s}`,children:"Server Name"}),e.jsx(u,{id:`edit-name-${s}`,value:o.name,onChange:m=>N({...o,name:m.target.value}),placeholder:"e.g., filesystem-server"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-command-${s}`,children:"Command"}),e.jsx(u,{id:`edit-command-${s}`,value:o.command,onChange:m=>N({...o,command:m.target.value}),placeholder:"e.g., npx @modelcontextprotocol/server-filesystem"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-args-${s}`,children:"Arguments (space-separated)"}),e.jsx(u,{id:`edit-args-${s}`,value:o.args,onChange:m=>N({...o,args:m.target.value}),placeholder:"e.g., /path/to/allowed/directory"})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-url-${s}`,children:"URL"}),e.jsx(u,{id:`edit-url-${s}`,value:o.url,onChange:m=>N({...o,url:m.target.value}),placeholder:"e.g., https://mcp.example.com/api"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Provide either Command (for stdio) or URL (for HTTP/SSE), not both."})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-description-${s}`,children:"Description (optional)"}),e.jsx(u,{id:`edit-description-${s}`,value:o.description,onChange:m=>N({...o,description:m.target.value}),placeholder:"Brief description of what this server provides"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:`edit-env-${s}`,children:"Environment Variables (JSON)"}),e.jsx(R,{id:`edit-env-${s}`,value:o.env,onChange:m=>N({...o,env:m.target.value}),placeholder:'{"KEY": "value", "ANOTHER_KEY": "another_value"}',rows:3})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:`edit-enabled-${s}`,checked:o.enabled,onCheckedChange:m=>N({...o,enabled:m})}),e.jsx(h,{htmlFor:`edit-enabled-${s}`,children:"Enable server"})]}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(C,{onClick:()=>ee(s),disabled:a,children:"Save Changes"}),e.jsx(C,{variant:"outline",onClick:se,children:"Cancel"})]})]}):e.jsx("div",{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[c?e.jsx(ve,{className:"h-4 w-4 text-green-500 shrink-0 mt-0.5"}):e.jsx(J,{className:"h-4 w-4 text-gray-400 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"font-medium text-sm sm:text-base",children:v}),e.jsx(P,{variant:c?"default":"secondary",className:"text-xs",children:c?"Enabled":"Disabled"}),e.jsx(P,{variant:"outline",className:"text-xs",children:r.url?"HTTP":"stdio"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:r.description||r.url||r.command}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:r.url?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"URL:"})," ",r.url]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:"Command:"})," ",r.command," ",r.args?.join(" ")]})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 shrink-0",children:[e.jsx(I,{checked:c,onCheckedChange:m=>Q(s,m),disabled:a}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(s),children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx(C,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(s),disabled:a,children:e.jsx(le,{className:"h-4 w-4"})})]})]})})},s)})})]})]}),e.jsxs(L,{children:[e.jsxs(T,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),"Configuration File"]}),e.jsxs($,{children:["The MCP configuration is stored in ",e.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:".nut/mcp/config.json"})]})]}),e.jsxs(U,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"configJson",children:"Current Configuration (JSON)"}),e.jsx(R,{id:"configJson",value:JSON.stringify(t,null,2),readOnly:!0,rows:12,className:"font-mono text-sm",placeholder:"Loading configuration..."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This is a read-only view of the current configuration. Use the forms above to make changes."})]}),e.jsxs(z,{children:[e.jsx(J,{className:"h-4 w-4"}),e.jsx(Y,{children:"Configuration changes are automatically saved to the MCP config file. This file can also be edited manually if you prefer working with JSON directly."})]})]})]}),e.jsxs(L,{children:[e.jsxs(T,{children:[e.jsxs(O,{className:"flex items-center gap-2",children:[e.jsx(de,{className:"h-5 w-5"}),"Global Settings"]}),e.jsx($,{children:"Configure global MCP behavior and connection settings."})]}),e.jsx(U,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"timeout",children:"Connection Timeout (ms)"}),e.jsx(u,{id:"timeout",type:"number",value:t.globalSettings?.timeout||3e4,onChange:s=>F({timeout:parseInt(s.target.value)}),placeholder:"30000"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"retryAttempts",children:"Retry Attempts"}),e.jsx(u,{id:"retryAttempts",type:"number",value:t.globalSettings?.retryAttempts||3,onChange:s=>F({retryAttempts:parseInt(s.target.value)}),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"logLevel",children:"Log Level"}),e.jsxs("select",{id:"logLevel",className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",value:t.globalSettings?.logLevel||"info",onChange:s=>F({logLevel:s.target.value}),children:[e.jsx("option",{value:"debug",children:"Debug"}),e.jsx("option",{value:"info",children:"Info"}),e.jsx("option",{value:"warn",children:"Warning"}),e.jsx("option",{value:"error",children:"Error"})]})]})]})})]}),e.jsx("div",{className:"flex justify-end space-x-2",children:e.jsx(C,{variant:"outline",onClick:D,disabled:l,children:"Reload Configuration"})}),e.jsx(ue,{open:V,onOpenChange:_,onImport:re})]})}export{Ae as default};
@@ -1,4 +1,4 @@
1
- import{u as S,a as y,r,j as e,B as j,t as E,a0 as T,L,I as b,A as I}from"./index-CoIuEZL-.js";import{C as i,b as c,c as l,a as d}from"./card-BmKLfTSE.js";import{L as m}from"./label-j04IpCQ3.js";import{M as A}from"./markdown-editor-DtzC0VN_.js";import{T as B}from"./TagInput-CgOjYo2a.js";import{S as P}from"./SourceInput-gjOlS_7W.js";import{A as M}from"./arrow-left-BSoXBQjE.js";import"./index-CtlrPZLB.js";import"./badge-D-5A_jAJ.js";import"./external-link-BgDYyk_g.js";function U(){const g=S(),{toast:s}=y(),[u,h]=r.useState(!1),[a,f]=r.useState(""),[n,v]=r.useState(""),[x,w]=r.useState([]),[p,C]=r.useState([]),k=async()=>{if(!a.trim()){s({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!n.trim()){s({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}h(!0);try{const o=await(await fetch(`${I}/api/v1/knowledge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a.trim(),content:n.trim(),metadata:{tags:x,sources:p}})})).json();if(o.success){s({title:"Success",description:"Knowledge document created successfully"});const N=o.document.filename.replace(".md","");g(`/knowledge/${N}`)}else s({title:"Error",description:o.error||"Failed to create knowledge document",variant:"destructive"})}catch(t){console.error("Error creating document:",t),s({title:"Error",description:"Failed to create knowledge document",variant:"destructive"})}finally{h(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h1",{className:"text-3xl font-bold",children:"Create Knowledge Document"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{onClick:k,disabled:u||!a.trim()||!n.trim(),size:"sm",children:[u?e.jsx(E,{className:"w-4 h-4 animate-spin"}):e.jsx(T,{className:"w-4 h-4"}),"Create Document"]}),e.jsx(j,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(L,{to:"/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(M,{className:"h-4 w-4"})})})]})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Basic Information"})}),e.jsx(d,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(m,{htmlFor:"title",children:"Title *"}),e.jsx(b,{id:"title",value:a,onChange:t=>f(t.target.value),placeholder:"Enter document title...",className:"text-lg"})]})})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Metadata"})}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{children:"Tags"}),e.jsx(B,{tags:x,onChange:w,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(m,{children:"Sources"}),e.jsx(P,{sources:p,onChange:C})]})]})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Content *"})}),e.jsx(d,{children:e.jsx(A,{value:n,onChange:t=>v(t||""),placeholder:`Enter your knowledge content in Markdown...
1
+ import{u as S,a as y,r,j as e,B as j,t as E,a0 as T,L,I as b,A as I}from"./index-C5Azpb6Z.js";import{C as i,b as c,c as l,a as d}from"./card-BHJKBprp.js";import{L as m}from"./label-Dk87UyXm.js";import{M as A}from"./markdown-editor-D0KOANlZ.js";import{T as B}from"./TagInput-BSvCOVlX.js";import{S as P}from"./SourceInput-8t5lHb_p.js";import{A as M}from"./arrow-left-D1gRXqBK.js";import"./index-DauoTeMC.js";import"./badge-WU4FRCeV.js";import"./external-link-BbPHlMU6.js";function U(){const g=S(),{toast:s}=y(),[u,h]=r.useState(!1),[a,f]=r.useState(""),[n,v]=r.useState(""),[x,w]=r.useState([]),[p,C]=r.useState([]),k=async()=>{if(!a.trim()){s({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!n.trim()){s({title:"Error",description:"Please provide content for the knowledge document",variant:"destructive"});return}h(!0);try{const o=await(await fetch(`${I}/api/v1/knowledge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a.trim(),content:n.trim(),metadata:{tags:x,sources:p}})})).json();if(o.success){s({title:"Success",description:"Knowledge document created successfully"});const N=o.document.filename.replace(".md","");g(`/knowledge/${N}`)}else s({title:"Error",description:o.error||"Failed to create knowledge document",variant:"destructive"})}catch(t){console.error("Error creating document:",t),s({title:"Error",description:"Failed to create knowledge document",variant:"destructive"})}finally{h(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h1",{className:"text-3xl font-bold",children:"Create Knowledge Document"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{onClick:k,disabled:u||!a.trim()||!n.trim(),size:"sm",children:[u?e.jsx(E,{className:"w-4 h-4 animate-spin"}):e.jsx(T,{className:"w-4 h-4"}),"Create Document"]}),e.jsx(j,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(L,{to:"/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(M,{className:"h-4 w-4"})})})]})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Basic Information"})}),e.jsx(d,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(m,{htmlFor:"title",children:"Title *"}),e.jsx(b,{id:"title",value:a,onChange:t=>f(t.target.value),placeholder:"Enter document title...",className:"text-lg"})]})})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Metadata"})}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{children:"Tags"}),e.jsx(B,{tags:x,onChange:w,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(m,{children:"Sources"}),e.jsx(P,{sources:p,onChange:C})]})]})]}),e.jsxs(i,{children:[e.jsx(c,{children:e.jsx(l,{children:"Content *"})}),e.jsx(d,{children:e.jsx(A,{value:n,onChange:t=>v(t||""),placeholder:`Enter your knowledge content in Markdown...
2
2
 
3
3
  You can use:
4
4
  - **Bold text**
@@ -1 +1 @@
1
- import{u as z,a as H,r as a,j as e,B as b,L as w,k as J,I as P,o as W,ab as Y,A as M}from"./index-CoIuEZL-.js";import{C as G,b as K,c as Q,a as V}from"./card-BmKLfTSE.js";import{L as l}from"./label-j04IpCQ3.js";import{B as X}from"./badge-D-5A_jAJ.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{A as O}from"./arrow-left-BSoXBQjE.js";import{C as ee,a as se}from"./clipboard-BrZi1A1O.js";function de(){const E=z(),{toast:g}=H(),[n,j]=a.useState(!1),[v,d]=a.useState(null),[m,A]=a.useState(""),[u,L]=a.useState(""),[c,F]=a.useState("blue"),[x,C]=a.useState([]),[h,T]=a.useState(""),[y,p]=a.useState([]),[B,N]=a.useState(!0),[I,S]=a.useState(!1),D=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],$={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"}};a.useEffect(()=>{let s=!0;return(async()=>{N(!0);try{const o=await fetch(`${M}/api/v1/mcp`);if(!o.ok)throw new Error("Failed to fetch MCP servers");const r=await o.json();if(!r?.success||!Array.isArray(r.servers)){s&&p([]);return}const U=r.mcpServers&&typeof r.mcpServers=="object"?r.mcpServers:{},k=r.servers.map(f=>{const i=U[f]??{};return{name:f,enabled:i?.enabled!==!1,description:typeof i?.description=="string"?i.description:void 0}});s&&(p(k),C(f=>f.filter(i=>k.some(_=>_.name===i))))}catch(o){console.error("Failed to load MCP servers",o),s&&p([])}finally{s&&N(!1)}})(),()=>{s=!1}},[]);const q=async()=>{const s=".nut/config.json";try{await Z(s),S(!0),g({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>S(!1),2e3)}catch(t){console.error("Failed to copy config path:",t),g({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},R=async s=>{if(s.preventDefault(),!m.trim()||!u.trim()||!h.trim()){d("Name, description, and skill instructions are required");return}try{j(!0),d(null);const t={name:m.trim(),description:u.trim(),content:h.trim(),metadata:{color:c,mcpServers:x.length>0?x:void 0}},r=await(await fetch(`${M}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json();r.success?E("/skills"):d(r.error?.message||"Failed to create skill")}catch(t){d(t instanceof Error?t.message:"Unknown error")}finally{j(!1)}};return 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:"Create New Skill"}),e.jsx("p",{className:"text-muted-foreground",children:"Define an AI skill for automated development workflows"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(b,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(w,{to:"/skills",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(O,{className:"h-4 w-4"})})})})]}),e.jsxs(G,{children:[e.jsx(K,{children:e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"Skill Configuration"]})}),e.jsx(V,{children:e.jsxs("form",{onSubmit:R,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(P,{id:"name",placeholder:"e.g., design expert",value:m,onChange:s=>A(s.target.value),disabled:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(P,{id:"description",placeholder:"When should this skill be used?",value:u,onChange:s=>L(s.target.value),disabled:n})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:D.map(s=>{const t=$[s];return e.jsx("button",{type:"button",onClick:()=>F(s),disabled:n,className:`w-10 h-10 rounded-md border-2 transition-all ${c===s?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:t.bg,borderColor:c===s?t.border:"hsl(var(--border))",...c===s&&{"--tw-ring-color":t.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."," ","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:q,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:I?e.jsx(ee,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(se,{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(W,{id:"content",placeholder:"You are a design expert that focuses on...",value:h,onChange:s=>T(s.target.value),rows:8,disabled:n,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."}),e.jsx("div",{className:"space-y-2",children:B?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers..."}):y.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."}):y.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(Y,{checked:x.includes(s.name),onCheckedChange:t=>{C(o=>t===!0?o.includes(s.name)?o:[...o,s.name]:o.filter(r=>r!==s.name))},disabled:n||!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(X,{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))})]}),v&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:v}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(b,{type:"button",variant:"outline",asChild:!0,disabled:n,children:e.jsx(w,{to:"/skills",children:"Cancel"})}),e.jsx(b,{type:"submit",disabled:n,children:n?"Creating...":"Create Skill"})]})]})})]})]})}export{de as default};
1
+ import{u as z,a as H,r as a,j as e,B as b,L as w,k as J,I as P,o as W,ab as Y,A as M}from"./index-C5Azpb6Z.js";import{C as G,b as K,c as Q,a as V}from"./card-BHJKBprp.js";import{L as l}from"./label-Dk87UyXm.js";import{B as X}from"./badge-WU4FRCeV.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{A as O}from"./arrow-left-D1gRXqBK.js";import{C as ee,a as se}from"./clipboard-DFI4a7LI.js";function de(){const E=z(),{toast:g}=H(),[n,j]=a.useState(!1),[v,d]=a.useState(null),[m,A]=a.useState(""),[u,L]=a.useState(""),[c,F]=a.useState("blue"),[x,C]=a.useState([]),[h,T]=a.useState(""),[y,p]=a.useState([]),[B,N]=a.useState(!0),[I,S]=a.useState(!1),D=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],$={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"}};a.useEffect(()=>{let s=!0;return(async()=>{N(!0);try{const o=await fetch(`${M}/api/v1/mcp`);if(!o.ok)throw new Error("Failed to fetch MCP servers");const r=await o.json();if(!r?.success||!Array.isArray(r.servers)){s&&p([]);return}const U=r.mcpServers&&typeof r.mcpServers=="object"?r.mcpServers:{},k=r.servers.map(f=>{const i=U[f]??{};return{name:f,enabled:i?.enabled!==!1,description:typeof i?.description=="string"?i.description:void 0}});s&&(p(k),C(f=>f.filter(i=>k.some(_=>_.name===i))))}catch(o){console.error("Failed to load MCP servers",o),s&&p([])}finally{s&&N(!1)}})(),()=>{s=!1}},[]);const q=async()=>{const s=".nut/config.json";try{await Z(s),S(!0),g({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>S(!1),2e3)}catch(t){console.error("Failed to copy config path:",t),g({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},R=async s=>{if(s.preventDefault(),!m.trim()||!u.trim()||!h.trim()){d("Name, description, and skill instructions are required");return}try{j(!0),d(null);const t={name:m.trim(),description:u.trim(),content:h.trim(),metadata:{color:c,mcpServers:x.length>0?x:void 0}},r=await(await fetch(`${M}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json();r.success?E("/skills"):d(r.error?.message||"Failed to create skill")}catch(t){d(t instanceof Error?t.message:"Unknown error")}finally{j(!1)}};return 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:"Create New Skill"}),e.jsx("p",{className:"text-muted-foreground",children:"Define an AI skill for automated development workflows"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(b,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(w,{to:"/skills",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(O,{className:"h-4 w-4"})})})})]}),e.jsxs(G,{children:[e.jsx(K,{children:e.jsxs(Q,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5"}),"Skill Configuration"]})}),e.jsx(V,{children:e.jsxs("form",{onSubmit:R,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(P,{id:"name",placeholder:"e.g., design expert",value:m,onChange:s=>A(s.target.value),disabled:n})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(P,{id:"description",placeholder:"When should this skill be used?",value:u,onChange:s=>L(s.target.value),disabled:n})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:D.map(s=>{const t=$[s];return e.jsx("button",{type:"button",onClick:()=>F(s),disabled:n,className:`w-10 h-10 rounded-md border-2 transition-all ${c===s?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:t.bg,borderColor:c===s?t.border:"hsl(var(--border))",...c===s&&{"--tw-ring-color":t.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."," ","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:q,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:I?e.jsx(ee,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(se,{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(W,{id:"content",placeholder:"You are a design expert that focuses on...",value:h,onChange:s=>T(s.target.value),rows:8,disabled:n,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."}),e.jsx("div",{className:"space-y-2",children:B?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers..."}):y.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."}):y.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(Y,{checked:x.includes(s.name),onCheckedChange:t=>{C(o=>t===!0?o.includes(s.name)?o:[...o,s.name]:o.filter(r=>r!==s.name))},disabled:n||!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(X,{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))})]}),v&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:v}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(b,{type:"button",variant:"outline",asChild:!0,disabled:n,children:e.jsx(w,{to:"/skills",children:"Cancel"})}),e.jsx(b,{type:"submit",disabled:n,children:n?"Creating...":"Create Skill"})]})]})})]})]})}export{de as default};
@@ -1,4 +1,4 @@
1
- import{u as X,q as Z,a as ee,s as te,r as n,A,j as e,B as j,L as E,I as y,a0 as se,y as ae,H as ie,J as ne,N as re,O as oe,Q as le,R as ce,U as de}from"./index-CoIuEZL-.js";import{C as he,b as ue,c as me,a as pe}from"./card-BmKLfTSE.js";import{L as h}from"./label-j04IpCQ3.js";import{M as ge}from"./markdown-editor-DtzC0VN_.js";import{S as F,a as L,b as P,c as I,d as r}from"./select-B7VRmZ7N.js";import{C as xe}from"./CollapsibleSection-B51ItrCZ.js";import{I as fe,L as je}from"./ImplementationStepsEditor-C3OVNxOV.js";import{T as ye}from"./TagInput-CgOjYo2a.js";import{A as ve}from"./arrow-left-BSoXBQjE.js";import"./index-CtlrPZLB.js";import"./chevron-up-DcYrGzFP.js";import"./badge-D-5A_jAJ.js";const R={"quick-change":{name:"Quick Change",content:`## Overview
1
+ import{u as X,q as Z,a as ee,s as te,r as n,A,j as e,B as j,L as E,I as y,a0 as se,y as ae,H as ie,J as ne,N as re,O as oe,Q as le,R as ce,U as de}from"./index-C5Azpb6Z.js";import{C as he,b as ue,c as me,a as pe}from"./card-BHJKBprp.js";import{L as h}from"./label-Dk87UyXm.js";import{M as ge}from"./markdown-editor-D0KOANlZ.js";import{S as F,a as L,b as P,c as I,d as r}from"./select-CpKkFDbr.js";import{C as xe}from"./CollapsibleSection-dXTDG5xK.js";import{I as fe,L as je}from"./ImplementationStepsEditor-BCw5WEo-.js";import{T as ye}from"./TagInput-BSvCOVlX.js";import{A as ve}from"./arrow-left-D1gRXqBK.js";import"./index-DauoTeMC.js";import"./chevron-up-BkAwyb-e.js";import"./badge-WU4FRCeV.js";const R={"quick-change":{name:"Quick Change",content:`## Overview
2
2
 
3
3
  Describe the quick change you're proposing.`},feature:{name:"New Feature",content:`## Problem Statement
4
4
  Describe the problem this new feature addresses.
@@ -1,4 +1,4 @@
1
- import{c as s,q as a,j as e,B as c,L as o}from"./index-CoIuEZL-.js";/**
1
+ import{c as s,q as a,j as e,B as c,L as o}from"./index-C5Azpb6Z.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{r as i,a as W,A as m,j as e,bv as T,B as v,I as E,a0 as Y,bD as Z,bE as ee}from"./index-CoIuEZL-.js";import{C as F,b as B,c as U,d as I,a as O}from"./card-BmKLfTSE.js";import{L as c}from"./label-j04IpCQ3.js";import{S as h}from"./switch-CuxAwq5S.js";import{S as se,a as te,b as ae,c as ne,d as ie}from"./select-B7VRmZ7N.js";import{M as re}from"./message-square-ChzqZzH2.js";import{C as oe}from"./circle-check-DMbbBi3F.js";import{C as V}from"./circle-x-4ItVsEnH.js";import{R as q}from"./refresh-cw-CG3rbxSH.js";import"./index-CtlrPZLB.js";import"./chevron-up-DcYrGzFP.js";const y={enabled:!1,channelId:"",channelName:"",siteUrl:"",notifications:{proposals:{created:!0,statusChange:!0},jobs:{completed:!0,failed:!0},git:{push:!1,merge:!0}},hasBotToken:!1,hasSigningSecret:!1};function be(){const[t,k]=i.useState(y),[x,P]=i.useState(""),[p,$]=i.useState(""),[S]=i.useState(()=>typeof window<"u"?window.location.origin:""),[l,j]=i.useState({data:[],error:null,loading:!1}),[H,L]=i.useState(!0),[A,g]=i.useState(!1),[J,R]=i.useState(!1),[M,_]=i.useState(!1),[o,z]=i.useState(null),[b,N]=i.useState(null),{toast:r}=W(),D=i.useCallback(async()=>{L(!0);try{const a=await(await fetch(`${m}/api/v1/slack/config`)).json();if(a.success)k({...y,...a.data});else throw new Error(a.error||"Failed to load Slack configuration")}catch(s){console.error("Failed to load Slack config:",s),r({title:"Error",description:"Failed to load Slack configuration",variant:"destructive"})}finally{L(!1)}},[r]),G=i.useCallback(async()=>{R(!0),N(null);try{const a=await(await fetch(`${m}/api/v1/slack/test`,{method:"POST"})).json();a.success?(N({success:!0,teamName:a.teamName}),r({title:"Connected",description:`Connected to workspace: ${a.teamName}`})):(N({success:!1,error:a.error}),r({title:"Connection failed",description:a.error||"Failed to connect",variant:"destructive"}))}catch(s){N({success:!1,error:s.message}),r({title:"Error",description:s.message||"Connection test failed",variant:"destructive"})}finally{R(!1)}},[r]),C=i.useCallback(async()=>{j(s=>({...s,loading:!0,error:null}));try{const a=await(await fetch(`${m}/api/v1/slack/channels`)).json();if(a.success)j({data:a.data||[],error:null,loading:!1});else{const n=a.error||"Failed to load channels";j({data:[],error:n,loading:!1})}}catch(s){console.error("Failed to load Slack channels:",s),j({data:[],error:s.message||"Failed to load channels",loading:!1})}},[]),X=async()=>{g(!0);try{const s={};if(x&&x!=="***"&&(s.botToken=x),p&&p!=="***"&&(s.signingSecret=p),s.siteUrl=S,Object.keys(s).length===1&&s.siteUrl&&!x&&!p){r({title:"No changes",description:"Enter new tokens to save"}),g(!1);return}const n=await(await fetch(`${m}/api/v1/slack/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).json();if(n.success)k({...y,...n.data}),P(""),$(""),r({title:"Saved",description:"Slack tokens saved successfully"}),await G();else throw new Error(n.error||"Failed to save tokens")}catch(s){r({title:"Error",description:s.message||"Failed to save tokens",variant:"destructive"})}finally{g(!1)}},w=async s=>{g(!0);try{const n=await(await fetch(`${m}/api/v1/slack/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).json();if(n.success)k({...y,...n.data}),r({title:"Saved",description:"Configuration updated"});else throw new Error(n.error||"Failed to save configuration")}catch(a){r({title:"Error",description:a.message||"Failed to save",variant:"destructive"})}finally{g(!1)}},K=async()=>{_(!0);try{const a=await(await fetch(`${m}/api/v1/slack/notify`,{method:"POST"})).json();if(a.success)r({title:"Sent",description:"Test notification sent to Slack"});else throw new Error(a.error||"Failed to send notification")}catch(s){r({title:"Error",description:s.message||"Failed to send test notification",variant:"destructive"})}finally{_(!1)}},u=(s,a,n)=>{const Q={...t.notifications,[s]:{...t.notifications[s],[a]:n}};w({notifications:Q})},f=async s=>{z(s);try{const n=await(await fetch(`${m}/api/v1/slack/notify/example`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:s})})).json();if(n.success)r({title:"Sent",description:`Example notification sent to ${t.channelName}`});else throw new Error(n.error||"Failed to send example notification")}catch(a){r({title:"Error",description:a.message||"Failed to send example notification",variant:"destructive"})}finally{z(null)}};if(i.useEffect(()=>{D()},[D]),i.useEffect(()=>{t.hasBotToken&&C()},[t.hasBotToken,C]),H)return e.jsx("div",{children:"Loading..."});const d=!!t.channelId;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Slack notifications for Coconut events."})]}),e.jsx(T,{}),e.jsxs(F,{children:[e.jsxs(B,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-5 w-5"}),e.jsx(U,{children:"Slack Connection"})]}),e.jsx(I,{children:"Connect your Slack workspace to receive notifications from Coconut."})]}),e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded border bg-muted/30 px-3 py-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:t.hasBotToken?b?.success?e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"h-4 w-4 text-green-600"}),e.jsxs("span",{className:"text-sm font-medium text-green-600",children:["Connected to ",b.teamName]})]}):b?.error?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 text-red-600"}),e.jsx("span",{className:"text-sm text-red-600",children:b.error})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 rounded-full bg-yellow-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Token configured - click Test to verify"})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Not connected"})]})}),e.jsxs(v,{variant:"outline",size:"sm",onClick:G,disabled:J||!t.hasBotToken,children:[e.jsx(q,{className:`h-4 w-4 mr-2 ${J?"animate-spin":""}`}),"Test"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"botToken",children:"Bot User OAuth Token"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(E,{id:"botToken",type:"password",placeholder:t.hasBotToken?"••••••••••••••••":"xoxb-...",value:x,onChange:s=>P(s.target.value),className:"flex-1"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Find this in your Slack app settings under OAuth & Permissions. The token should start with ",e.jsx("code",{className:"text-xs bg-muted px-1 rounded",children:"xoxb-"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"signingSecret",children:"Signing Secret"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(E,{id:"signingSecret",type:"password",placeholder:t.hasSigningSecret?"••••••••••••••••":"Enter signing secret",value:p,onChange:s=>$(s.target.value),className:"flex-1"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Find this in your Slack app settings under Basic Information → App Credentials."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"siteUrl",children:"Site URL"}),e.jsx(E,{id:"siteUrl",type:"text",value:S,disabled:!0,className:"bg-muted"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This URL will be used for links in Slack notifications.",t.siteUrl&&t.siteUrl!==S&&e.jsxs("span",{className:"block mt-1 text-amber-600",children:["Currently saved: ",t.siteUrl]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(v,{onClick:X,disabled:A||!x&&!p,children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),A?"Saving...":"Save Tokens"]})}),e.jsxs("div",{className:"rounded border bg-muted/50 p-4 space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Setup Instructions"}),e.jsxs("ol",{className:"text-xs text-muted-foreground space-y-1 list-decimal list-inside",children:[e.jsxs("li",{children:["Go to ",e.jsx("a",{href:"https://api.slack.com/apps",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"api.slack.com/apps"})," and select your app"]}),e.jsxs("li",{children:['Under "OAuth & Permissions", add these Bot Token Scopes:',e.jsxs("ul",{className:"ml-4 mt-1 space-y-0.5",children:[e.jsxs("li",{children:[e.jsx("code",{className:"text-xs bg-background px-1 rounded",children:"chat:write"})," - Send messages"]}),e.jsxs("li",{children:[e.jsx("code",{className:"text-xs bg-background px-1 rounded",children:"channels:read"})," - List public channels"]}),e.jsxs("li",{children:[e.jsx("code",{className:"text-xs bg-background px-1 rounded",children:"groups:read"})," - List private channels (optional)"]})]})]}),e.jsx("li",{children:"Install the app to your workspace and copy the Bot User OAuth Token"}),e.jsx("li",{children:'Under "Basic Information", copy the Signing Secret'})]})]})]})]}),e.jsxs(F,{children:[e.jsxs(B,{children:[e.jsx(U,{children:"Notification Channel"}),e.jsx(I,{children:"Select the Slack channel where notifications will be posted."})]}),e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:"Channel"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{value:t.channelId,onValueChange:s=>{const a=l.data.find(n=>n.id===s);w({channelId:s,channelName:a?`#${a.name}`:""})},disabled:!t.hasBotToken||l.loading||!!l.error,children:[e.jsx(te,{className:"flex-1",children:e.jsx(ae,{placeholder:l.loading?"Loading channels...":l.error?"Unable to load channels":"Select a channel"})}),e.jsx(ne,{children:l.data.map(s=>e.jsxs(ie,{value:s.id,children:[s.isPrivate?"🔒":"#"," ",s.name,!s.isMember&&" (bot not member)"]},s.id))})]}),e.jsx(v,{variant:"outline",size:"icon",onClick:C,disabled:l.loading||!t.hasBotToken,children:e.jsx(q,{className:`h-4 w-4 ${l.loading?"animate-spin":""}`})})]}),l.error&&e.jsxs("div",{className:"rounded border border-red-200 bg-red-50 p-3 text-xs text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:[e.jsx("span",{className:"font-medium",children:"Error loading channels:"})," ",l.error]}),t.channelName&&!l.error&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Currently set to: ",e.jsx("span",{className:"font-medium",children:t.channelName})]}),!t.hasBotToken&&e.jsx("p",{className:"text-xs text-amber-600",children:"Configure your Bot Token above to select a channel."})]}),d&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Send a test notification to verify the setup"}),e.jsxs(v,{variant:"outline",size:"sm",onClick:K,disabled:M||!t.enabled,children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),M?"Sending...":"Send Test"]})]})]})]}),e.jsxs(F,{children:[e.jsxs(B,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-5 w-5"}),e.jsx(U,{children:"Notification Types"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c,{htmlFor:"notifications-enabled",className:"text-sm font-normal",children:"Enable notifications"}),e.jsx(h,{id:"notifications-enabled",checked:t.enabled,onCheckedChange:s=>w({enabled:s}),disabled:!t.hasBotToken||!d})]})]}),e.jsx(I,{children:"Choose which events trigger Slack notifications."})]}),e.jsxs(O,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Proposals"}),e.jsxs("div",{className:"space-y-3 ml-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"proposals-created",className:"text-sm font-normal",children:"New proposal created"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("proposal.created"),disabled:!d||o==="proposal.created",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="proposal.created"?"Sending...":"Send Example"}),e.jsx(h,{id:"proposals-created",checked:t.notifications.proposals.created,onCheckedChange:s=>u("proposals","created",s),disabled:!t.enabled})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"proposals-status",className:"text-sm font-normal",children:"Proposal status changed"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("proposal.statusChange"),disabled:!d||o==="proposal.statusChange",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="proposal.statusChange"?"Sending...":"Send Example"}),e.jsx(h,{id:"proposals-status",checked:t.notifications.proposals.statusChange,onCheckedChange:s=>u("proposals","statusChange",s),disabled:!t.enabled})]})]})]})]}),e.jsx(T,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Scheduled Jobs"}),e.jsxs("div",{className:"space-y-3 ml-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"jobs-completed",className:"text-sm font-normal",children:"Job completed successfully"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("job.completed"),disabled:!d||o==="job.completed",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="job.completed"?"Sending...":"Send Example"}),e.jsx(h,{id:"jobs-completed",checked:t.notifications.jobs.completed,onCheckedChange:s=>u("jobs","completed",s),disabled:!t.enabled})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"jobs-failed",className:"text-sm font-normal",children:"Job failed"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("job.failed"),disabled:!d||o==="job.failed",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="job.failed"?"Sending...":"Send Example"}),e.jsx(h,{id:"jobs-failed",checked:t.notifications.jobs.failed,onCheckedChange:s=>u("jobs","failed",s),disabled:!t.enabled})]})]})]})]}),e.jsx(T,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Git Operations"}),e.jsxs("div",{className:"space-y-3 ml-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"git-push",className:"text-sm font-normal",children:"Code pushed"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("git.push"),disabled:!d||o==="git.push",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="git.push"?"Sending...":"Send Example"}),e.jsx(h,{id:"git-push",checked:t.notifications.git.push,onCheckedChange:s=>u("git","push",s),disabled:!t.enabled})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"git-merge",className:"text-sm font-normal",children:"Branch merged"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("git.merge"),disabled:!d||o==="git.merge",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="git.merge"?"Sending...":"Send Example"}),e.jsx(h,{id:"git-merge",checked:t.notifications.git.merge,onCheckedChange:s=>u("git","merge",s),disabled:!t.enabled})]})]})]})]}),!t.enabled&&t.hasBotToken&&d&&e.jsx("div",{className:"rounded border border-amber-200 bg-amber-50 p-3 text-xs text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200",children:"Enable notifications above to start receiving Slack messages for these events."})]})]})]})}export{be as default};
1
+ import{r as i,a as W,A as m,j as e,bv as T,B as v,I as E,a0 as Y,bD as Z,bE as ee}from"./index-C5Azpb6Z.js";import{C as F,b as B,c as U,d as I,a as O}from"./card-BHJKBprp.js";import{L as c}from"./label-Dk87UyXm.js";import{S as h}from"./switch-BZ6eSoPj.js";import{S as se,a as te,b as ae,c as ne,d as ie}from"./select-CpKkFDbr.js";import{M as re}from"./message-square-qlP-j05_.js";import{C as oe}from"./circle-check-BADr-KOf.js";import{C as V}from"./circle-x-Bn4fyYbB.js";import{R as q}from"./refresh-cw-CIEDgKUC.js";import"./index-DauoTeMC.js";import"./chevron-up-BkAwyb-e.js";const y={enabled:!1,channelId:"",channelName:"",siteUrl:"",notifications:{proposals:{created:!0,statusChange:!0},jobs:{completed:!0,failed:!0},git:{push:!1,merge:!0}},hasBotToken:!1,hasSigningSecret:!1};function be(){const[t,k]=i.useState(y),[x,P]=i.useState(""),[p,$]=i.useState(""),[S]=i.useState(()=>typeof window<"u"?window.location.origin:""),[l,j]=i.useState({data:[],error:null,loading:!1}),[H,L]=i.useState(!0),[A,g]=i.useState(!1),[J,R]=i.useState(!1),[M,_]=i.useState(!1),[o,z]=i.useState(null),[b,N]=i.useState(null),{toast:r}=W(),D=i.useCallback(async()=>{L(!0);try{const a=await(await fetch(`${m}/api/v1/slack/config`)).json();if(a.success)k({...y,...a.data});else throw new Error(a.error||"Failed to load Slack configuration")}catch(s){console.error("Failed to load Slack config:",s),r({title:"Error",description:"Failed to load Slack configuration",variant:"destructive"})}finally{L(!1)}},[r]),G=i.useCallback(async()=>{R(!0),N(null);try{const a=await(await fetch(`${m}/api/v1/slack/test`,{method:"POST"})).json();a.success?(N({success:!0,teamName:a.teamName}),r({title:"Connected",description:`Connected to workspace: ${a.teamName}`})):(N({success:!1,error:a.error}),r({title:"Connection failed",description:a.error||"Failed to connect",variant:"destructive"}))}catch(s){N({success:!1,error:s.message}),r({title:"Error",description:s.message||"Connection test failed",variant:"destructive"})}finally{R(!1)}},[r]),C=i.useCallback(async()=>{j(s=>({...s,loading:!0,error:null}));try{const a=await(await fetch(`${m}/api/v1/slack/channels`)).json();if(a.success)j({data:a.data||[],error:null,loading:!1});else{const n=a.error||"Failed to load channels";j({data:[],error:n,loading:!1})}}catch(s){console.error("Failed to load Slack channels:",s),j({data:[],error:s.message||"Failed to load channels",loading:!1})}},[]),X=async()=>{g(!0);try{const s={};if(x&&x!=="***"&&(s.botToken=x),p&&p!=="***"&&(s.signingSecret=p),s.siteUrl=S,Object.keys(s).length===1&&s.siteUrl&&!x&&!p){r({title:"No changes",description:"Enter new tokens to save"}),g(!1);return}const n=await(await fetch(`${m}/api/v1/slack/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).json();if(n.success)k({...y,...n.data}),P(""),$(""),r({title:"Saved",description:"Slack tokens saved successfully"}),await G();else throw new Error(n.error||"Failed to save tokens")}catch(s){r({title:"Error",description:s.message||"Failed to save tokens",variant:"destructive"})}finally{g(!1)}},w=async s=>{g(!0);try{const n=await(await fetch(`${m}/api/v1/slack/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).json();if(n.success)k({...y,...n.data}),r({title:"Saved",description:"Configuration updated"});else throw new Error(n.error||"Failed to save configuration")}catch(a){r({title:"Error",description:a.message||"Failed to save",variant:"destructive"})}finally{g(!1)}},K=async()=>{_(!0);try{const a=await(await fetch(`${m}/api/v1/slack/notify`,{method:"POST"})).json();if(a.success)r({title:"Sent",description:"Test notification sent to Slack"});else throw new Error(a.error||"Failed to send notification")}catch(s){r({title:"Error",description:s.message||"Failed to send test notification",variant:"destructive"})}finally{_(!1)}},u=(s,a,n)=>{const Q={...t.notifications,[s]:{...t.notifications[s],[a]:n}};w({notifications:Q})},f=async s=>{z(s);try{const n=await(await fetch(`${m}/api/v1/slack/notify/example`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:s})})).json();if(n.success)r({title:"Sent",description:`Example notification sent to ${t.channelName}`});else throw new Error(n.error||"Failed to send example notification")}catch(a){r({title:"Error",description:a.message||"Failed to send example notification",variant:"destructive"})}finally{z(null)}};if(i.useEffect(()=>{D()},[D]),i.useEffect(()=>{t.hasBotToken&&C()},[t.hasBotToken,C]),H)return e.jsx("div",{children:"Loading..."});const d=!!t.channelId;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Slack notifications for Coconut events."})]}),e.jsx(T,{}),e.jsxs(F,{children:[e.jsxs(B,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-5 w-5"}),e.jsx(U,{children:"Slack Connection"})]}),e.jsx(I,{children:"Connect your Slack workspace to receive notifications from Coconut."})]}),e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded border bg-muted/30 px-3 py-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:t.hasBotToken?b?.success?e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"h-4 w-4 text-green-600"}),e.jsxs("span",{className:"text-sm font-medium text-green-600",children:["Connected to ",b.teamName]})]}):b?.error?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 text-red-600"}),e.jsx("span",{className:"text-sm text-red-600",children:b.error})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 rounded-full bg-yellow-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Token configured - click Test to verify"})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Not connected"})]})}),e.jsxs(v,{variant:"outline",size:"sm",onClick:G,disabled:J||!t.hasBotToken,children:[e.jsx(q,{className:`h-4 w-4 mr-2 ${J?"animate-spin":""}`}),"Test"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"botToken",children:"Bot User OAuth Token"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(E,{id:"botToken",type:"password",placeholder:t.hasBotToken?"••••••••••••••••":"xoxb-...",value:x,onChange:s=>P(s.target.value),className:"flex-1"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Find this in your Slack app settings under OAuth & Permissions. The token should start with ",e.jsx("code",{className:"text-xs bg-muted px-1 rounded",children:"xoxb-"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"signingSecret",children:"Signing Secret"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(E,{id:"signingSecret",type:"password",placeholder:t.hasSigningSecret?"••••••••••••••••":"Enter signing secret",value:p,onChange:s=>$(s.target.value),className:"flex-1"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Find this in your Slack app settings under Basic Information → App Credentials."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"siteUrl",children:"Site URL"}),e.jsx(E,{id:"siteUrl",type:"text",value:S,disabled:!0,className:"bg-muted"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This URL will be used for links in Slack notifications.",t.siteUrl&&t.siteUrl!==S&&e.jsxs("span",{className:"block mt-1 text-amber-600",children:["Currently saved: ",t.siteUrl]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(v,{onClick:X,disabled:A||!x&&!p,children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),A?"Saving...":"Save Tokens"]})}),e.jsxs("div",{className:"rounded border bg-muted/50 p-4 space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Setup Instructions"}),e.jsxs("ol",{className:"text-xs text-muted-foreground space-y-1 list-decimal list-inside",children:[e.jsxs("li",{children:["Go to ",e.jsx("a",{href:"https://api.slack.com/apps",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"api.slack.com/apps"})," and select your app"]}),e.jsxs("li",{children:['Under "OAuth & Permissions", add these Bot Token Scopes:',e.jsxs("ul",{className:"ml-4 mt-1 space-y-0.5",children:[e.jsxs("li",{children:[e.jsx("code",{className:"text-xs bg-background px-1 rounded",children:"chat:write"})," - Send messages"]}),e.jsxs("li",{children:[e.jsx("code",{className:"text-xs bg-background px-1 rounded",children:"channels:read"})," - List public channels"]}),e.jsxs("li",{children:[e.jsx("code",{className:"text-xs bg-background px-1 rounded",children:"groups:read"})," - List private channels (optional)"]})]})]}),e.jsx("li",{children:"Install the app to your workspace and copy the Bot User OAuth Token"}),e.jsx("li",{children:'Under "Basic Information", copy the Signing Secret'})]})]})]})]}),e.jsxs(F,{children:[e.jsxs(B,{children:[e.jsx(U,{children:"Notification Channel"}),e.jsx(I,{children:"Select the Slack channel where notifications will be posted."})]}),e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{children:"Channel"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{value:t.channelId,onValueChange:s=>{const a=l.data.find(n=>n.id===s);w({channelId:s,channelName:a?`#${a.name}`:""})},disabled:!t.hasBotToken||l.loading||!!l.error,children:[e.jsx(te,{className:"flex-1",children:e.jsx(ae,{placeholder:l.loading?"Loading channels...":l.error?"Unable to load channels":"Select a channel"})}),e.jsx(ne,{children:l.data.map(s=>e.jsxs(ie,{value:s.id,children:[s.isPrivate?"🔒":"#"," ",s.name,!s.isMember&&" (bot not member)"]},s.id))})]}),e.jsx(v,{variant:"outline",size:"icon",onClick:C,disabled:l.loading||!t.hasBotToken,children:e.jsx(q,{className:`h-4 w-4 ${l.loading?"animate-spin":""}`})})]}),l.error&&e.jsxs("div",{className:"rounded border border-red-200 bg-red-50 p-3 text-xs text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200",children:[e.jsx("span",{className:"font-medium",children:"Error loading channels:"})," ",l.error]}),t.channelName&&!l.error&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Currently set to: ",e.jsx("span",{className:"font-medium",children:t.channelName})]}),!t.hasBotToken&&e.jsx("p",{className:"text-xs text-amber-600",children:"Configure your Bot Token above to select a channel."})]}),d&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Send a test notification to verify the setup"}),e.jsxs(v,{variant:"outline",size:"sm",onClick:K,disabled:M||!t.enabled,children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),M?"Sending...":"Send Test"]})]})]})]}),e.jsxs(F,{children:[e.jsxs(B,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-5 w-5"}),e.jsx(U,{children:"Notification Types"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c,{htmlFor:"notifications-enabled",className:"text-sm font-normal",children:"Enable notifications"}),e.jsx(h,{id:"notifications-enabled",checked:t.enabled,onCheckedChange:s=>w({enabled:s}),disabled:!t.hasBotToken||!d})]})]}),e.jsx(I,{children:"Choose which events trigger Slack notifications."})]}),e.jsxs(O,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Proposals"}),e.jsxs("div",{className:"space-y-3 ml-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"proposals-created",className:"text-sm font-normal",children:"New proposal created"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("proposal.created"),disabled:!d||o==="proposal.created",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="proposal.created"?"Sending...":"Send Example"}),e.jsx(h,{id:"proposals-created",checked:t.notifications.proposals.created,onCheckedChange:s=>u("proposals","created",s),disabled:!t.enabled})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"proposals-status",className:"text-sm font-normal",children:"Proposal status changed"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("proposal.statusChange"),disabled:!d||o==="proposal.statusChange",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="proposal.statusChange"?"Sending...":"Send Example"}),e.jsx(h,{id:"proposals-status",checked:t.notifications.proposals.statusChange,onCheckedChange:s=>u("proposals","statusChange",s),disabled:!t.enabled})]})]})]})]}),e.jsx(T,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Scheduled Jobs"}),e.jsxs("div",{className:"space-y-3 ml-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"jobs-completed",className:"text-sm font-normal",children:"Job completed successfully"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("job.completed"),disabled:!d||o==="job.completed",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="job.completed"?"Sending...":"Send Example"}),e.jsx(h,{id:"jobs-completed",checked:t.notifications.jobs.completed,onCheckedChange:s=>u("jobs","completed",s),disabled:!t.enabled})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"jobs-failed",className:"text-sm font-normal",children:"Job failed"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("job.failed"),disabled:!d||o==="job.failed",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="job.failed"?"Sending...":"Send Example"}),e.jsx(h,{id:"jobs-failed",checked:t.notifications.jobs.failed,onCheckedChange:s=>u("jobs","failed",s),disabled:!t.enabled})]})]})]})]}),e.jsx(T,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Git Operations"}),e.jsxs("div",{className:"space-y-3 ml-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"git-push",className:"text-sm font-normal",children:"Code pushed"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("git.push"),disabled:!d||o==="git.push",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="git.push"?"Sending...":"Send Example"}),e.jsx(h,{id:"git-push",checked:t.notifications.git.push,onCheckedChange:s=>u("git","push",s),disabled:!t.enabled})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(c,{htmlFor:"git-merge",className:"text-sm font-normal",children:"Branch merged"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f("git.merge"),disabled:!d||o==="git.merge",className:"text-xs text-primary hover:underline disabled:opacity-50 disabled:no-underline",children:o==="git.merge"?"Sending...":"Send Example"}),e.jsx(h,{id:"git-merge",checked:t.notifications.git.merge,onCheckedChange:s=>u("git","merge",s),disabled:!t.enabled})]})]})]})]}),!t.enabled&&t.hasBotToken&&d&&e.jsx("div",{className:"rounded border border-amber-200 bg-amber-50 p-3 text-xs text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200",children:"Enable notifications above to start receiving Slack messages for these events."})]})]})]})}export{be as default};
@@ -1,4 +1,4 @@
1
- import{u as L,a as I,r as i,A as S,j as e,B as C,L as M,a0 as A,I as p}from"./index-CoIuEZL-.js";import{C as h,a as x,b,c as P}from"./card-BmKLfTSE.js";import{L as l}from"./label-j04IpCQ3.js";import{S as B,a as D,b as T,c as O,d as j}from"./select-B7VRmZ7N.js";import{M as V}from"./markdown-editor-DtzC0VN_.js";import{A as W}from"./arrow-left-BSoXBQjE.js";import{C as z}from"./circle-check-big-P_y4fjqZ.js";import"./index-CtlrPZLB.js";import"./chevron-up-DcYrGzFP.js";function Q(){const E=L(),{toast:d}=I(),[a,v]=i.useState({project:{name:"",description:"",website:"",version:"1.0.0",stage:"development"}}),[u,g]=i.useState(""),[F,f]=i.useState(!0),[y,w]=i.useState(!1);i.useEffect(()=>{fetch(`${S}/api/v1/context/project`).then(t=>t.json()).then(t=>{if(t.success){const s=t.document;v({project:{name:s.metadata.project?.name||"",description:s.metadata.project?.description||"",website:s.metadata.project?.website||s.metadata.project?.repository||"",version:s.metadata.project?.version||"1.0.0",stage:s.metadata.project?.stage||"development"}}),g(s.content.trim())}f(!1)}).catch(t=>{console.error("Failed to load context:",t),d({title:"Error",description:"Failed to load project context",variant:"destructive"}),f(!1)})},[d]);const k=async()=>{w(!0);try{const s={project:Object.fromEntries(Object.entries(a.project).map(([o,r])=>[o,typeof r=="string"?r.trim():r]))},n=await(await fetch(`${S}/api/v1/context/project`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:u,metadata:s})})).json();if(n.success)d({title:"Success",description:"Project context saved successfully",action:e.jsx(z,{className:"h-4 w-4"})}),E("/context/project");else throw new Error(n.error||"Failed to save context")}catch(t){console.error("Save error:",t),d({title:"Error",description:"Failed to save project context",variant:"destructive"})}finally{w(!1)}},c=(t,s)=>{v(N=>{const n={...N},o=t.split(".");let r=n;for(let m=0;m<o.length-1;m++)r=r[o[m]];return r[o[o.length-1]]=s,n})};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-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Edit project information and documentation"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(M,{to:"/context/project",children:[e.jsx(W,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Back"})]})}),e.jsxs(C,{size:"sm",onClick:k,disabled:y,children:[e.jsx(A,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:y?"Saving...":"Save"})]})]})]}),e.jsxs(h,{children:[e.jsx(b,{children:e.jsx(P,{children:"Project Information"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-name",children:"Project Name"}),e.jsx(p,{id:"project-name",value:a.project.name,onChange:t=>c("project.name",t.target.value),placeholder:"My Awesome Project"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-version",children:"Version"}),e.jsx(p,{id:"project-version",value:a.project.version,onChange:t=>c("project.version",t.target.value),placeholder:"1.0.0"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-description",children:"Description"}),e.jsx(p,{id:"project-description",value:a.project.description,onChange:t=>c("project.description",t.target.value),placeholder:"Brief description of what this project does"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-website",children:"Website"}),e.jsx(p,{id:"project-website",value:a.project.website,onChange:t=>c("project.website",t.target.value),placeholder:"https://yourproject.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-stage",children:"Development Stage"}),e.jsxs(B,{value:a.project.stage,onValueChange:t=>c("project.stage",t),children:[e.jsx(D,{children:e.jsx(T,{placeholder:"Select stage"})}),e.jsxs(O,{children:[e.jsx(j,{value:"prototype",children:"Prototype"}),e.jsx(j,{value:"development",children:"Development"}),e.jsx(j,{value:"mvp",children:"MVP"}),e.jsx(j,{value:"production",children:"Production"})]})]})]})]})]})]}),e.jsxs(h,{children:[e.jsx(b,{children:e.jsx(P,{children:"Documentation"})}),e.jsx(x,{children:e.jsx(V,{value:u,onChange:t=>g(t||""),placeholder:`Write your project documentation in markdown...
1
+ import{u as L,a as I,r as i,A as S,j as e,B as C,L as M,a0 as A,I as p}from"./index-C5Azpb6Z.js";import{C as h,a as x,b,c as P}from"./card-BHJKBprp.js";import{L as l}from"./label-Dk87UyXm.js";import{S as B,a as D,b as T,c as O,d as j}from"./select-CpKkFDbr.js";import{M as V}from"./markdown-editor-D0KOANlZ.js";import{A as W}from"./arrow-left-D1gRXqBK.js";import{C as z}from"./circle-check-big-D34PB5x-.js";import"./index-DauoTeMC.js";import"./chevron-up-BkAwyb-e.js";function Q(){const E=L(),{toast:d}=I(),[a,v]=i.useState({project:{name:"",description:"",website:"",version:"1.0.0",stage:"development"}}),[u,g]=i.useState(""),[F,f]=i.useState(!0),[y,w]=i.useState(!1);i.useEffect(()=>{fetch(`${S}/api/v1/context/project`).then(t=>t.json()).then(t=>{if(t.success){const s=t.document;v({project:{name:s.metadata.project?.name||"",description:s.metadata.project?.description||"",website:s.metadata.project?.website||s.metadata.project?.repository||"",version:s.metadata.project?.version||"1.0.0",stage:s.metadata.project?.stage||"development"}}),g(s.content.trim())}f(!1)}).catch(t=>{console.error("Failed to load context:",t),d({title:"Error",description:"Failed to load project context",variant:"destructive"}),f(!1)})},[d]);const k=async()=>{w(!0);try{const s={project:Object.fromEntries(Object.entries(a.project).map(([o,r])=>[o,typeof r=="string"?r.trim():r]))},n=await(await fetch(`${S}/api/v1/context/project`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:u,metadata:s})})).json();if(n.success)d({title:"Success",description:"Project context saved successfully",action:e.jsx(z,{className:"h-4 w-4"})}),E("/context/project");else throw new Error(n.error||"Failed to save context")}catch(t){console.error("Save error:",t),d({title:"Error",description:"Failed to save project context",variant:"destructive"})}finally{w(!1)}},c=(t,s)=>{v(N=>{const n={...N},o=t.split(".");let r=n;for(let m=0;m<o.length-1;m++)r=r[o[m]];return r[o[o.length-1]]=s,n})};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-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Edit project information and documentation"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(M,{to:"/context/project",children:[e.jsx(W,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Back"})]})}),e.jsxs(C,{size:"sm",onClick:k,disabled:y,children:[e.jsx(A,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:y?"Saving...":"Save"})]})]})]}),e.jsxs(h,{children:[e.jsx(b,{children:e.jsx(P,{children:"Project Information"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-name",children:"Project Name"}),e.jsx(p,{id:"project-name",value:a.project.name,onChange:t=>c("project.name",t.target.value),placeholder:"My Awesome Project"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-version",children:"Version"}),e.jsx(p,{id:"project-version",value:a.project.version,onChange:t=>c("project.version",t.target.value),placeholder:"1.0.0"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-description",children:"Description"}),e.jsx(p,{id:"project-description",value:a.project.description,onChange:t=>c("project.description",t.target.value),placeholder:"Brief description of what this project does"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-website",children:"Website"}),e.jsx(p,{id:"project-website",value:a.project.website,onChange:t=>c("project.website",t.target.value),placeholder:"https://yourproject.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"project-stage",children:"Development Stage"}),e.jsxs(B,{value:a.project.stage,onValueChange:t=>c("project.stage",t),children:[e.jsx(D,{children:e.jsx(T,{placeholder:"Select stage"})}),e.jsxs(O,{children:[e.jsx(j,{value:"prototype",children:"Prototype"}),e.jsx(j,{value:"development",children:"Development"}),e.jsx(j,{value:"mvp",children:"MVP"}),e.jsx(j,{value:"production",children:"Production"})]})]})]})]})]})]}),e.jsxs(h,{children:[e.jsx(b,{children:e.jsx(P,{children:"Documentation"})}),e.jsx(x,{children:e.jsx(V,{value:u,onChange:t=>g(t||""),placeholder:`Write your project documentation in markdown...
2
2
 
3
3
  ## What is this project?
4
4