@lovelybunch/api 1.0.76-alpha.1 → 1.0.76-alpha.11

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 (543) hide show
  1. package/dist/lib/auth/auth-manager.js +1 -1
  2. package/dist/lib/git.d.ts +3 -0
  3. package/dist/lib/git.js +35 -0
  4. package/dist/lib/mcp-client.d.ts +39 -0
  5. package/dist/lib/mcp-client.js +131 -0
  6. package/dist/lib/terminal/terminal-manager.js +31 -0
  7. package/dist/routes/api/v1/ai/route.js +136 -1
  8. package/dist/routes/api/v1/ai/tools.js +49 -232
  9. package/dist/routes/api/v1/config/route.js +13 -9
  10. package/dist/routes/api/v1/context/agents/route.d.ts +3 -0
  11. package/dist/routes/api/v1/context/agents/route.js +159 -0
  12. package/dist/routes/api/v1/context/index.js +6 -0
  13. package/dist/routes/api/v1/context/memory/route.d.ts +3 -0
  14. package/dist/routes/api/v1/context/memory/route.js +163 -0
  15. package/dist/routes/api/v1/context/team/route.d.ts +3 -0
  16. package/dist/routes/api/v1/context/team/route.js +159 -0
  17. package/dist/routes/api/v1/git/index.js +27 -1
  18. package/dist/routes/api/v1/knowledge/route.js +26 -32
  19. package/dist/routes/api/v1/mail/route.d.ts +3 -3
  20. package/dist/routes/api/v1/mcp/index.js +170 -4
  21. package/dist/routes/api/v1/proposals/[id]/route.d.ts +10 -24
  22. package/dist/routes/api/v1/proposals/[id]/route.js +10 -1
  23. package/dist/routes/api/v1/proposals/route.d.ts +2 -16
  24. package/dist/routes/api/v1/proposals/route.js +11 -8
  25. package/dist/routes/api/v1/resources/generate/route.js +10 -3
  26. package/dist/routes/api/v1/tasks/route.d.ts +18 -38
  27. package/dist/routes/api/v1/tasks/route.js +94 -16
  28. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +2 -2
  29. package/dist/routes/api/v1/terminal/code/index.d.ts +3 -0
  30. package/dist/routes/api/v1/terminal/code/index.js +5 -0
  31. package/dist/routes/api/v1/terminal/code/route.d.ts +14 -0
  32. package/dist/routes/api/v1/terminal/code/route.js +159 -0
  33. package/dist/server-with-static.js +2 -0
  34. package/dist/server.js +2 -0
  35. package/package.json +6 -7
  36. package/static/assets/ActivityPage-CUPUsmhW.js +1 -0
  37. package/static/assets/ActivityPage-DGW0f70r.js +1 -0
  38. package/static/assets/AgentsContextEditPage-CBZaG033.js +9 -0
  39. package/static/assets/AgentsContextEditPage-CJbx9qwA.js +9 -0
  40. package/static/assets/AgentsContextPage-BWzSvM5V.js +1 -0
  41. package/static/assets/AgentsContextPage-C1wcPVUs.js +1 -0
  42. package/static/assets/{ApiKeysSettingsPage-DbXgxh7i.js → ApiKeysSettingsPage-CauZEPsx.js} +2 -2
  43. package/static/assets/ApiKeysSettingsPage-Ceww_YUR.js +2 -0
  44. package/static/assets/ArchitectureEditPage-DZhYQihz.js +15 -0
  45. package/static/assets/ArchitectureEditPage-Dk8NNc4k.js +15 -0
  46. package/static/assets/ArchitecturePage-Cvj4j0Mo.js +1 -0
  47. package/static/assets/ArchitecturePage-D0gLaPg5.js +1 -0
  48. package/static/assets/{AuthSettingsPage-nIgM05Yw.js → AuthSettingsPage-22eaC7la.js} +2 -2
  49. package/static/assets/AuthSettingsPage-BHPV0uSB.js +11 -0
  50. package/static/assets/{CallbackPage-NNbLun2S.js → CallbackPage-DCf0WTl0.js} +1 -1
  51. package/static/assets/CallbackPage-buKCnkYC.js +1 -0
  52. package/static/assets/CodePage-CuyF2xDA.js +2 -0
  53. package/static/assets/CodePage-x32C4yuN.js +2 -0
  54. package/static/assets/{CollapsibleSection-DbKW4cyU.js → CollapsibleSection-CUHXgJIe.js} +1 -1
  55. package/static/assets/CollapsibleSection-DMf0wWjc.js +1 -0
  56. package/static/assets/DashboardPage-DIU-4dPO.js +41 -0
  57. package/static/assets/DashboardPage-Dr4S3wVm.js +41 -0
  58. package/static/assets/{GitPage-Hi0mdDOi.js → GitPage-BGHRNljT.js} +4 -4
  59. package/static/assets/GitPage-DpCcZosR.js +16 -0
  60. package/static/assets/{GitSettingsPage-2vuCM-U-.js → GitSettingsPage-A4ty6ftB.js} +2 -2
  61. package/static/assets/GitSettingsPage-BRuP4Ihk.js +6 -0
  62. package/static/assets/{IdentityPage-2BzLc2EI.js → IdentityPage-4xn0DPW8.js} +2 -2
  63. package/static/assets/IdentityPage-Bps9Zjk3.js +6 -0
  64. package/static/assets/{ImplementationStepsEditor-BlmI5YuN.js → ImplementationStepsEditor-CaMsbJPb.js} +2 -2
  65. package/static/assets/ImplementationStepsEditor-KJkRc2Jn.js +6 -0
  66. package/static/assets/IntegrationsSettingsPage-B1sX003q.js +1 -0
  67. package/static/assets/IntegrationsSettingsPage-CpTuAA-H.js +1 -0
  68. package/static/assets/{JobDetailPage-CLEY1Z5e.js → JobDetailPage-BdYlGn4G.js} +1 -1
  69. package/static/assets/JobDetailPage-C5N3IyX3.js +1 -0
  70. package/static/assets/KnowledgeDetailPage-Dvk-QAJJ.js +1 -0
  71. package/static/assets/KnowledgeDetailPage-Dy0M4FgC.js +1 -0
  72. package/static/assets/KnowledgeEditPage-CN0wPWMV.js +1 -0
  73. package/static/assets/KnowledgeEditPage-DEP0bweP.js +1 -0
  74. package/static/assets/KnowledgePage-BLe2lXja.js +3 -0
  75. package/static/assets/{KnowledgePage-D-ahboFK.js → KnowledgePage-_bvnWXPU.js} +2 -2
  76. package/static/assets/{LoginPage-DQ2rJliF.js → LoginPage-BkZt_pMw.js} +1 -1
  77. package/static/assets/LoginPage-VfOnXGad.js +1 -0
  78. package/static/assets/{MailInboxPage-Bfh0_pBU.js → MailInboxPage-DklkHMyO.js} +1 -1
  79. package/static/assets/MailInboxPage-UF82OTOE.js +1 -0
  80. package/static/assets/{MailProcessingModal-NF9kjdgr.js → MailProcessingModal-BHFYVTQc.js} +2 -2
  81. package/static/assets/MailProcessingModal-rKHRB-wC.js +6 -0
  82. package/static/assets/{MailReadPage-C0QhDa1x.js → MailReadPage-B-vLDq-6.js} +1 -1
  83. package/static/assets/MailReadPage-mg3Wqvqh.js +1 -0
  84. package/static/assets/{MailSentPage-Ctgcp1RB.js → MailSentPage-DIJJ8I5v.js} +1 -1
  85. package/static/assets/MailSentPage-OJeb1vU9.js +1 -0
  86. package/static/assets/{McpSettingsPage-CFgpw5_r.js → McpSettingsPage-CgOnXuHZ.js} +1 -1
  87. package/static/assets/McpSettingsPage-Mi2-nB-i.js +1 -0
  88. package/static/assets/MemoryEditPage-CR6SmDXU.js +13 -0
  89. package/static/assets/MemoryEditPage-D8i7XQ5l.js +13 -0
  90. package/static/assets/MemoryPage-BcWVGuiS.js +1 -0
  91. package/static/assets/MemoryPage-vbCtMG4L.js +1 -0
  92. package/static/assets/NewKnowledgePage-BE4X0pSc.js +1 -0
  93. package/static/assets/NewKnowledgePage-CL3dpMwb.js +1 -0
  94. package/static/assets/{NewSkillPage-CvBSXZFE.js → NewSkillPage-B3prwJ_n.js} +1 -1
  95. package/static/assets/NewSkillPage-BCJ68pFK.js +1 -0
  96. package/static/assets/{NewTaskPage-DRL-pyjV.js → NewTaskPage-DszXfHrv.js} +2 -2
  97. package/static/assets/NewTaskPage-vj0LvAb_.js +91 -0
  98. package/static/assets/{NotFoundPage-DW0gfvNA.js → NotFoundPage-D3K7UoeF.js} +1 -1
  99. package/static/assets/NotFoundPage-DqwQiMc8.js +6 -0
  100. package/static/assets/NotificationsSettingsPage-BSuXKPiG.js +1 -0
  101. package/static/assets/NotificationsSettingsPage-C4Gthita.js +1 -0
  102. package/static/assets/ProjectEditPage-DTdhZKQg.js +11 -0
  103. package/static/assets/ProjectEditPage-ia6zDqUf.js +11 -0
  104. package/static/assets/{ProjectPage-78a-iVFG.js → ProjectPage-BIk487-h.js} +1 -1
  105. package/static/assets/ProjectPage-DJ5wGekX.js +1 -0
  106. package/static/assets/PromptsSettingsPage-4iJoggN0.js +1 -0
  107. package/static/assets/PromptsSettingsPage-COjiXPsT.js +1 -0
  108. package/static/assets/{ResourceDetailPage-CLcuo4yw.js → ResourceDetailPage-DJN3Rax4.js} +1 -1
  109. package/static/assets/ResourceDetailPage-DKs83OyV.js +1 -0
  110. package/static/assets/ResourcesPage-CO45MzEx.js +41 -0
  111. package/static/assets/ResourcesPage-DF8x1i_a.js +41 -0
  112. package/static/assets/RoleEditPage-B0pm5rVn.js +13 -0
  113. package/static/assets/RoleEditPage-CBl-M2s3.js +13 -0
  114. package/static/assets/{RolePage-haUf186q.js → RolePage-B7JswOZC.js} +1 -1
  115. package/static/assets/RolePage-IVBtcgCf.js +1 -0
  116. package/static/assets/{RulesSettingsPage-Cc8rvAvm.js → RulesSettingsPage-CB6YdyhI.js} +2 -2
  117. package/static/assets/RulesSettingsPage-CKUt1JkO.js +16 -0
  118. package/static/assets/SchedulePage-TCeGDlnw.js +4 -0
  119. package/static/assets/SchedulePage-_NAbasKs.js +4 -0
  120. package/static/assets/{SkillDetailPage-BqhoNNkM.js → SkillDetailPage-7EzSwjPh.js} +1 -1
  121. package/static/assets/SkillDetailPage-jTeSohec.js +1 -0
  122. package/static/assets/{SkillEditPage-cpSdv9D4.js → SkillEditPage-CpouyjFV.js} +1 -1
  123. package/static/assets/SkillEditPage-D_e69AQk.js +1 -0
  124. package/static/assets/{SkillsPage-Cxkm5ymf.js → SkillsPage-DP8zSnPo.js} +2 -2
  125. package/static/assets/SkillsPage-xfv43oJ4.js +8 -0
  126. package/static/assets/{SkillsSettingsPage-DrmRher8.js → SkillsSettingsPage-CktzJBa7.js} +1 -1
  127. package/static/assets/SkillsSettingsPage-jhNVgVSA.js +1 -0
  128. package/static/assets/{SourceInput-C0WkiXS6.js → SourceInput-CQnyDxzl.js} +1 -1
  129. package/static/assets/SourceInput-KeAQ1PMl.js +1 -0
  130. package/static/assets/{TagInput-raThOrbG.js → TagInput-DoO2Dwj6.js} +1 -1
  131. package/static/assets/TagInput-ZyP8Rq8B.js +1 -0
  132. package/static/assets/{TaskDetailPage-BMzce3uJ.js → TaskDetailPage-C6xKC_IM.js} +2 -2
  133. package/static/assets/TaskDetailPage-z557zwfE.js +16 -0
  134. package/static/assets/TaskEditPage-DPLOeh7K.js +1 -0
  135. package/static/assets/TaskEditPage-XuWzVm-k.js +1 -0
  136. package/static/assets/{TasksPage-CxKJQJ1_.js → TasksPage-C-toKZIZ.js} +3 -3
  137. package/static/assets/TasksPage-CwfLwTAV.js +17 -0
  138. package/static/assets/TeamEditPage-B8qk6fWu.js +9 -0
  139. package/static/assets/TeamEditPage-Dk7Yxh1i.js +9 -0
  140. package/static/assets/TeamPage-CQ4EE1rP.js +1 -0
  141. package/static/assets/TeamPage-Dmrjf_RA.js +1 -0
  142. package/static/assets/{TerminalPage-BWdNoEM5.js → TerminalPage-C0CSp8st.js} +1 -1
  143. package/static/assets/TerminalPage-Y59DZGfZ.js +1 -0
  144. package/static/assets/TerminalSessionPage-BQOMLYPX.js +3 -0
  145. package/static/assets/TerminalSessionPage-HvnYJEpU.js +3 -0
  146. package/static/assets/UserPreferencesPage-1l5T8TaE.js +1 -0
  147. package/static/assets/UserPreferencesPage-BSIvW5UI.js +1 -0
  148. package/static/assets/{UserSettingsPage-CqooRxDi.js → UserSettingsPage-CS7BrEZJ.js} +1 -1
  149. package/static/assets/UserSettingsPage-o4ikmR9k.js +1 -0
  150. package/static/assets/UtilitiesPage-D1YCA1eC.js +1 -0
  151. package/static/assets/UtilitiesPage-O5kjW0V2.js +1 -0
  152. package/static/assets/{alert-BGFBZOrZ.js → alert-DOfUEE4H.js} +1 -1
  153. package/static/assets/alert-u79hLEuY.js +1 -0
  154. package/static/assets/apl-B4CMkyY2.js +1 -0
  155. package/static/assets/{arrow-down-DXhs3vvo.js → arrow-down-DumN-Nal.js} +1 -1
  156. package/static/assets/arrow-down-Y539lEoZ.js +6 -0
  157. package/static/assets/{arrow-left-PEX5RePT.js → arrow-left-B_QwfLPP.js} +1 -1
  158. package/static/assets/arrow-left-DmNgC0xD.js +6 -0
  159. package/static/assets/{arrow-up-D7z0QZsQ.js → arrow-up-B3Oj7MxZ.js} +1 -1
  160. package/static/assets/arrow-up-BbDrY9nh.js +6 -0
  161. package/static/assets/{arrow-up-down-OTrzDHIL.js → arrow-up-down-D8T0kR2Q.js} +1 -1
  162. package/static/assets/arrow-up-down-DDTTwJEF.js +6 -0
  163. package/static/assets/asciiarmor-Df11BRmG.js +1 -0
  164. package/static/assets/asn1-EdZsLKOL.js +1 -0
  165. package/static/assets/asterisk-B-8jnY81.js +1 -0
  166. package/static/assets/{badge-rki-Xf0E.js → badge-BmHXIBBB.js} +1 -1
  167. package/static/assets/badge-BzEwwrAP.js +1 -0
  168. package/static/assets/brainfuck-C4LP7Hcl.js +1 -0
  169. package/static/assets/{browser-modal-BKnqJnf5.js → browser-modal-4AfJ98X7.js} +2 -2
  170. package/static/assets/browser-modal-CY4F-Mm8.js +6 -0
  171. package/static/assets/{card-_Grh-Otl.js → card-BpqK1BMM.js} +1 -1
  172. package/static/assets/card-Btt3HmXT.js +1 -0
  173. package/static/assets/{chevron-left-LQtIDk73.js → chevron-left-CSCdB-iz.js} +1 -1
  174. package/static/assets/chevron-left-DztJMlwc.js +6 -0
  175. package/static/assets/{chevron-up-BM1GKhAV.js → chevron-up-DaWWwb87.js} +1 -1
  176. package/static/assets/chevron-up-gnoSEbf_.js +6 -0
  177. package/static/assets/{chevrons-up-Ccej0FyZ.js → chevrons-up-B2GdB4F7.js} +1 -1
  178. package/static/assets/chevrons-up-D7gsSI9g.js +11 -0
  179. package/static/assets/{circle-alert-C5k9mZfC.js → circle-alert-CQ-Ir4mS.js} +1 -1
  180. package/static/assets/circle-alert-Coa2ulVd.js +6 -0
  181. package/static/assets/{circle-check-fwIZxHsK.js → circle-check-01UufaGN.js} +1 -1
  182. package/static/assets/circle-check-C9wy7OAO.js +6 -0
  183. package/static/assets/{circle-check-big-BaFefwt0.js → circle-check-big-CVbQ_zpj.js} +1 -1
  184. package/static/assets/circle-check-big-DqKKs8fZ.js +6 -0
  185. package/static/assets/{circle-play-C1R46Kry.js → circle-play-COMPwZ00.js} +1 -1
  186. package/static/assets/circle-play-DoomwgYb.js +6 -0
  187. package/static/assets/{circle-x-CKuM1691.js → circle-x-Cs5S3HID.js} +1 -1
  188. package/static/assets/circle-x-Du7Cp5MD.js +6 -0
  189. package/static/assets/clike-B9uivgTg.js +1 -0
  190. package/static/assets/{clipboard-DWJnnRi8.js → clipboard-C-VV2jbC.js} +1 -1
  191. package/static/assets/clipboard-CqRqQoij.js +11 -0
  192. package/static/assets/{clock-Diqm3Csm.js → clock-BKOkXNLP.js} +1 -1
  193. package/static/assets/clock-ehUSUqcI.js +6 -0
  194. package/static/assets/clojure-BMjYHr_A.js +1 -0
  195. package/static/assets/cmake-BQqOBYOt.js +1 -0
  196. package/static/assets/cobol-CWcv1MsR.js +1 -0
  197. package/static/assets/{code-Ao0cA5nW.js → code-CmFlYUo3.js} +1 -1
  198. package/static/assets/code-kQPD6ttp.js +6 -0
  199. package/static/assets/coffeescript-S37ZYGWr.js +1 -0
  200. package/static/assets/commonlisp-DBKNyK5s.js +1 -0
  201. package/static/assets/crystal-SjHAIU92.js +1 -0
  202. package/static/assets/css-BnMrqG3P.js +1 -0
  203. package/static/assets/cypher-C_CwsFkJ.js +1 -0
  204. package/static/assets/d-pRatUO7H.js +1 -0
  205. package/static/assets/diff-DbItnlRl.js +1 -0
  206. package/static/assets/dockerfile-BKs6k2Af.js +1 -0
  207. package/static/assets/{download-5iQDQeY0.js → download-Cg0a1Yh4.js} +1 -1
  208. package/static/assets/download-D8TKj0Hc.js +6 -0
  209. package/static/assets/dtd-DF_7sFjM.js +1 -0
  210. package/static/assets/dylan-DwRh75JA.js +1 -0
  211. package/static/assets/ebnf-CDyGwa7X.js +1 -0
  212. package/static/assets/ecl-Cabwm37j.js +1 -0
  213. package/static/assets/eiffel-CnydiIhH.js +1 -0
  214. package/static/assets/elm-vLlmbW-K.js +1 -0
  215. package/static/assets/erlang-BNw1qcRV.js +1 -0
  216. package/static/assets/{external-link-B6dkiWgP.js → external-link-BSAlwNHq.js} +1 -1
  217. package/static/assets/external-link-BVrPPG_7.js +6 -0
  218. package/static/assets/{eye-DQUzAWBY.js → eye-AP4j25wH.js} +1 -1
  219. package/static/assets/eye-DWC_Vybx.js +6 -0
  220. package/static/assets/factor-kuTfRLto.js +1 -0
  221. package/static/assets/fcl-Kvtd6kyn.js +1 -0
  222. package/static/assets/{folder-git-2-CQUj8P5W.js → folder-git-2-CMtTePKY.js} +1 -1
  223. package/static/assets/folder-git-2-Ds9p-D0Q.js +6 -0
  224. package/static/assets/forth-Ffai-XNe.js +1 -0
  225. package/static/assets/fortran-DYz_wnZ1.js +1 -0
  226. package/static/assets/gas-Bneqetm1.js +1 -0
  227. package/static/assets/gherkin-heZmZLOM.js +1 -0
  228. package/static/assets/globe-CJrZCIc6.js +6 -0
  229. package/static/assets/globe-DwQuaM7_.js +6 -0
  230. package/static/assets/groovy-D9Dt4D0W.js +1 -0
  231. package/static/assets/haskell-Cw1EW3IL.js +1 -0
  232. package/static/assets/haxe-H-WmDvRZ.js +1 -0
  233. package/static/assets/http-DBlCnlav.js +1 -0
  234. package/static/assets/idl-BEugSyMb.js +1 -0
  235. package/static/assets/index-0sq0wwbr.js +1 -0
  236. package/static/assets/index-B0Cea36W.js +1 -0
  237. package/static/assets/index-B0g-CMWG.js +1 -0
  238. package/static/assets/index-BFEMYO_w.js +1 -0
  239. package/static/assets/index-BFevJCwl.js +1 -0
  240. package/static/assets/index-BK1-hIKa.js +1 -0
  241. package/static/assets/index-BMie63_b.js +1 -0
  242. package/static/assets/index-BZvWD4ai.js +1 -0
  243. package/static/assets/index-BlyysfDZ.js +7 -0
  244. package/static/assets/index-BpQ9T8mu.js +3 -0
  245. package/static/assets/index-Bpm_mSd3.js +2 -0
  246. package/static/assets/index-Brkkhgwq.js +1 -0
  247. package/static/assets/index-Bvj_HZmE.js +1 -0
  248. package/static/assets/index-CE8kBKLn.js +1 -0
  249. package/static/assets/index-CL_XsRD7.js +1 -0
  250. package/static/assets/{index-CIFIEidO.js → index-C_KCaLlP.js} +117 -102
  251. package/static/assets/index-CfcUrE_I.js +1 -0
  252. package/static/assets/index-CisT9m8F.js +3 -0
  253. package/static/assets/index-CiyjdZHh.js +1 -0
  254. package/static/assets/index-CtnO1D9D.js +1 -0
  255. package/static/assets/index-D3hMbDtK.js +1 -0
  256. package/static/assets/index-DBS4Ya9k.js +1 -0
  257. package/static/assets/index-DEmcF6vO.js +1 -0
  258. package/static/assets/index-DYBGl9Zy.js +1 -0
  259. package/static/assets/index-DgeHIphZ.js +1 -0
  260. package/static/assets/index-Digxc7bT.js +1 -0
  261. package/static/assets/index-Dih0CGHs.js +1 -0
  262. package/static/assets/index-DoDazQp9.js +1 -0
  263. package/static/assets/index-DvviZzdo.js +1 -0
  264. package/static/assets/index-Dz52SxOy.js +2 -0
  265. package/static/assets/index-J8MrpD0P.js +1 -0
  266. package/static/assets/index-NgkIT4SV.js +1 -0
  267. package/static/assets/index-PBkZiuRI.js +1 -0
  268. package/static/assets/index-ZJ8xZq44.js +1 -0
  269. package/static/assets/index-oKV7MVo_.js +1 -0
  270. package/static/assets/index-oRAlpULD.css +1 -0
  271. package/static/assets/index-opozMhku.js +502 -0
  272. package/static/assets/index-vk3KOxHi.js +7 -0
  273. package/static/assets/index-wmWBSeOM.js +1 -0
  274. package/static/assets/{info-BvzdeJ30.js → info-D-7cQBbP.js} +1 -1
  275. package/static/assets/info-NEnL4zqX.js +6 -0
  276. package/static/assets/javascript-iXu5QeM3.js +1 -0
  277. package/static/assets/julia-DuME0IfC.js +1 -0
  278. package/static/assets/{label-B1lgxULu.js → label-bMzKAcdZ.js} +1 -1
  279. package/static/assets/label-wtSCiOqT.js +1 -0
  280. package/static/assets/livescript-BwQOo05w.js +1 -0
  281. package/static/assets/lua-BgMRiT3U.js +1 -0
  282. package/static/assets/markdown-editor-B3gIcmI2.js +111 -0
  283. package/static/assets/markdown-editor-B6HEtSkH.css +1 -0
  284. package/static/assets/markdown-editor-D_er7zWv.js +111 -0
  285. package/static/assets/mathematica-DTrFuWx2.js +1 -0
  286. package/static/assets/mbox-CNhZ1qSd.js +1 -0
  287. package/static/assets/{message-square-LKqx0LRr.js → message-square-Ca07XC8m.js} +1 -1
  288. package/static/assets/message-square-CvZFZAL0.js +6 -0
  289. package/static/assets/mirc-CjQqDB4T.js +1 -0
  290. package/static/assets/mllike-CXdrOF99.js +1 -0
  291. package/static/assets/modelica-Dc1JOy9r.js +1 -0
  292. package/static/assets/mscgen-BA5vi2Kp.js +1 -0
  293. package/static/assets/mumps-BT43cFF4.js +1 -0
  294. package/static/assets/nginx-DdIZxoE0.js +1 -0
  295. package/static/assets/nsis-LdVXkNf5.js +1 -0
  296. package/static/assets/ntriples-BfvgReVJ.js +1 -0
  297. package/static/assets/octave-Ck1zUtKM.js +1 -0
  298. package/static/assets/oz-BzwKVEFT.js +1 -0
  299. package/static/assets/{paperclip-Cvcr3t6l.js → paperclip-BICwD8BW.js} +1 -1
  300. package/static/assets/paperclip-D9bkHCO9.js +6 -0
  301. package/static/assets/pascal--L3eBynH.js +1 -0
  302. package/static/assets/{pause-TaMz44vG.js → pause-CZwBxJjx.js} +1 -1
  303. package/static/assets/pause-DrtOMeDr.js +6 -0
  304. package/static/assets/perl-CdXCOZ3F.js +1 -0
  305. package/static/assets/pig-CevX1Tat.js +1 -0
  306. package/static/assets/pipeline-builders-Bkf0wt_O.js +17 -0
  307. package/static/assets/{play-C4YxfQOO.js → play-BjDbhEcg.js} +1 -1
  308. package/static/assets/play-CQk31OJN.js +6 -0
  309. package/static/assets/powershell-CFHJl5sT.js +1 -0
  310. package/static/assets/properties-C78fOPTZ.js +1 -0
  311. package/static/assets/protobuf-ChK-085T.js +1 -0
  312. package/static/assets/pug-DeIclll2.js +1 -0
  313. package/static/assets/puppet-DMA9R1ak.js +1 -0
  314. package/static/assets/python-BuPzkPfP.js +1 -0
  315. package/static/assets/q-pXgVlZs6.js +1 -0
  316. package/static/assets/r-B6wPVr8A.js +1 -0
  317. package/static/assets/{radio-group-D7Rt-k1F.js → radio-group-BpmJzTM1.js} +1 -1
  318. package/static/assets/radio-group-DqCmfTij.js +1 -0
  319. package/static/assets/{refresh-cw-C9ZWZi2c.js → refresh-cw-CZLHY6zD.js} +1 -1
  320. package/static/assets/refresh-cw-yMcSYdEF.js +6 -0
  321. package/static/assets/rpm-CTu-6PCP.js +1 -0
  322. package/static/assets/ruby-B2Rjki9n.js +1 -0
  323. package/static/assets/sas-B4kiWyti.js +1 -0
  324. package/static/assets/scheme-C41bIUwD.js +1 -0
  325. package/static/assets/{search-C1RuN2pO.js → search-Cz2_2BkO.js} +1 -1
  326. package/static/assets/search-_5ueAoCg.js +6 -0
  327. package/static/assets/select-9YyUa5YH.js +1 -0
  328. package/static/assets/select-BKdFrV6O.js +1 -0
  329. package/static/assets/shell-CjFT_Tl9.js +1 -0
  330. package/static/assets/sieve-C3Gn_uJK.js +1 -0
  331. package/static/assets/simple-mode-GW_nhZxv.js +1 -0
  332. package/static/assets/smalltalk-CnHTOXQT.js +1 -0
  333. package/static/assets/solr-DehyRSwq.js +1 -0
  334. package/static/assets/sparql-DkYu6x3z.js +1 -0
  335. package/static/assets/spreadsheet-BCZA_wO0.js +1 -0
  336. package/static/assets/sql-D0XecflT.js +1 -0
  337. package/static/assets/stex-C3f8Ysf7.js +1 -0
  338. package/static/assets/stylus-B533Al4x.js +1 -0
  339. package/static/assets/swift-BzpIVaGY.js +1 -0
  340. package/static/assets/{switch-LSkE6hx8.js → switch-Bhm5em7I.js} +1 -1
  341. package/static/assets/switch-D7e1drXt.js +1 -0
  342. package/static/assets/tabs-oeAz0IIg.js +1 -0
  343. package/static/assets/tabs-qMSIjEoX.js +1 -0
  344. package/static/assets/{tag-B2iP7vv_.js → tag-D5LBbacJ.js} +1 -1
  345. package/static/assets/tag-dBrNwRvH.js +6 -0
  346. package/static/assets/tcl-DVfN8rqt.js +1 -0
  347. package/static/assets/{terminal-preview-PyMHLXJ3.js → terminal-preview-BZXyNaM9.js} +1 -1
  348. package/static/assets/terminal-preview-C3WCC5tV.js +1 -0
  349. package/static/assets/textile-CnDTJFAw.js +1 -0
  350. package/static/assets/tiddlywiki-DO-Gjzrf.js +1 -0
  351. package/static/assets/tiki-DGYXhP31.js +1 -0
  352. package/static/assets/toml-Bm5Em-hy.js +1 -0
  353. package/static/assets/troff-wAsdV37c.js +1 -0
  354. package/static/assets/ttcn-CfJYG6tj.js +1 -0
  355. package/static/assets/ttcn-cfg-B9xdYoR4.js +1 -0
  356. package/static/assets/turtle-B1tBg_DP.js +1 -0
  357. package/static/assets/{use-terminal-Blvh8GLp.js → use-terminal-CSttRkql.js} +1 -1
  358. package/static/assets/use-terminal-FzuSKCnc.js +1 -0
  359. package/static/assets/vb-CmGdzxic.js +1 -0
  360. package/static/assets/vbscript-BuJXcnF6.js +1 -0
  361. package/static/assets/velocity-D8B20fx6.js +1 -0
  362. package/static/assets/verilog-C6RDOZhf.js +1 -0
  363. package/static/assets/vhdl-lSbBsy5d.js +1 -0
  364. package/static/assets/{video-A2wzYKal.js → video-D7SzAtAp.js} +1 -1
  365. package/static/assets/video-DKqt_ev6.js +36 -0
  366. package/static/assets/webidl-ZXfAyPTL.js +1 -0
  367. package/static/assets/xquery-DzFWVndE.js +1 -0
  368. package/static/assets/yacas-BJ4BC0dw.js +1 -0
  369. package/static/assets/z80-Hz9HOZM7.js +1 -0
  370. package/static/index.html +2 -2
  371. package/dist/lib/auth/auth-manager.d.ts.map +0 -1
  372. package/dist/lib/auth/auth-manager.js.map +0 -1
  373. package/dist/lib/gait-path.d.ts.map +0 -1
  374. package/dist/lib/gait-path.js.map +0 -1
  375. package/dist/lib/git-settings.d.ts.map +0 -1
  376. package/dist/lib/git-settings.js.map +0 -1
  377. package/dist/lib/git.d.ts.map +0 -1
  378. package/dist/lib/git.js.map +0 -1
  379. package/dist/lib/jobs/global-job-scheduler.d.ts.map +0 -1
  380. package/dist/lib/jobs/global-job-scheduler.js.map +0 -1
  381. package/dist/lib/jobs/job-runner.d.ts.map +0 -1
  382. package/dist/lib/jobs/job-runner.js.map +0 -1
  383. package/dist/lib/jobs/job-scheduler.d.ts.map +0 -1
  384. package/dist/lib/jobs/job-scheduler.js.map +0 -1
  385. package/dist/lib/jobs/job-store.d.ts.map +0 -1
  386. package/dist/lib/jobs/job-store.js.map +0 -1
  387. package/dist/lib/project-paths.d.ts.map +0 -1
  388. package/dist/lib/project-paths.js.map +0 -1
  389. package/dist/lib/storage/file-storage.d.ts.map +0 -1
  390. package/dist/lib/storage/file-storage.js.map +0 -1
  391. package/dist/lib/symlinks/symlink-manager.d.ts.map +0 -1
  392. package/dist/lib/symlinks/symlink-manager.js.map +0 -1
  393. package/dist/lib/symlinks/types.d.ts.map +0 -1
  394. package/dist/lib/symlinks/types.js.map +0 -1
  395. package/dist/lib/terminal/context-helper.d.ts.map +0 -1
  396. package/dist/lib/terminal/context-helper.js.map +0 -1
  397. package/dist/lib/terminal/global-manager.d.ts.map +0 -1
  398. package/dist/lib/terminal/global-manager.js.map +0 -1
  399. package/dist/lib/terminal/shell-utils.d.ts.map +0 -1
  400. package/dist/lib/terminal/shell-utils.js.map +0 -1
  401. package/dist/lib/terminal/terminal-manager.d.ts.map +0 -1
  402. package/dist/lib/terminal/terminal-manager.js.map +0 -1
  403. package/dist/lib/user-preferences.d.ts.map +0 -1
  404. package/dist/lib/user-preferences.js.map +0 -1
  405. package/dist/middleware/auth.d.ts.map +0 -1
  406. package/dist/middleware/auth.js.map +0 -1
  407. package/dist/routes/api/v1/agents/[id]/index.d.ts.map +0 -1
  408. package/dist/routes/api/v1/agents/[id]/index.js.map +0 -1
  409. package/dist/routes/api/v1/agents/[id]/route.d.ts.map +0 -1
  410. package/dist/routes/api/v1/agents/[id]/route.js.map +0 -1
  411. package/dist/routes/api/v1/agents/index.d.ts.map +0 -1
  412. package/dist/routes/api/v1/agents/index.js.map +0 -1
  413. package/dist/routes/api/v1/agents/route.d.ts.map +0 -1
  414. package/dist/routes/api/v1/agents/route.js.map +0 -1
  415. package/dist/routes/api/v1/ai/index.d.ts.map +0 -1
  416. package/dist/routes/api/v1/ai/index.js.map +0 -1
  417. package/dist/routes/api/v1/ai/route.d.ts.map +0 -1
  418. package/dist/routes/api/v1/ai/route.js.map +0 -1
  419. package/dist/routes/api/v1/api-keys/index.d.ts.map +0 -1
  420. package/dist/routes/api/v1/api-keys/index.js.map +0 -1
  421. package/dist/routes/api/v1/api-keys/route.d.ts.map +0 -1
  422. package/dist/routes/api/v1/api-keys/route.js.map +0 -1
  423. package/dist/routes/api/v1/auth/index.d.ts.map +0 -1
  424. package/dist/routes/api/v1/auth/index.js.map +0 -1
  425. package/dist/routes/api/v1/auth/route.d.ts.map +0 -1
  426. package/dist/routes/api/v1/auth/route.js.map +0 -1
  427. package/dist/routes/api/v1/auth-settings/index.d.ts.map +0 -1
  428. package/dist/routes/api/v1/auth-settings/index.js.map +0 -1
  429. package/dist/routes/api/v1/auth-settings/route.d.ts.map +0 -1
  430. package/dist/routes/api/v1/auth-settings/route.js.map +0 -1
  431. package/dist/routes/api/v1/chats/[id]/index.d.ts.map +0 -1
  432. package/dist/routes/api/v1/chats/[id]/index.js.map +0 -1
  433. package/dist/routes/api/v1/chats/[id]/route.d.ts.map +0 -1
  434. package/dist/routes/api/v1/chats/[id]/route.js.map +0 -1
  435. package/dist/routes/api/v1/chats/index.d.ts.map +0 -1
  436. package/dist/routes/api/v1/chats/index.js.map +0 -1
  437. package/dist/routes/api/v1/chats/route.d.ts.map +0 -1
  438. package/dist/routes/api/v1/chats/route.js.map +0 -1
  439. package/dist/routes/api/v1/config/index.d.ts.map +0 -1
  440. package/dist/routes/api/v1/config/index.js.map +0 -1
  441. package/dist/routes/api/v1/config/route.d.ts.map +0 -1
  442. package/dist/routes/api/v1/config/route.js.map +0 -1
  443. package/dist/routes/api/v1/context/architecture/route.d.ts.map +0 -1
  444. package/dist/routes/api/v1/context/architecture/route.js.map +0 -1
  445. package/dist/routes/api/v1/context/index.d.ts.map +0 -1
  446. package/dist/routes/api/v1/context/index.js.map +0 -1
  447. package/dist/routes/api/v1/context/knowledge/[filename]/index.d.ts.map +0 -1
  448. package/dist/routes/api/v1/context/knowledge/[filename]/index.js.map +0 -1
  449. package/dist/routes/api/v1/context/knowledge/[filename]/route.d.ts.map +0 -1
  450. package/dist/routes/api/v1/context/knowledge/[filename]/route.js.map +0 -1
  451. package/dist/routes/api/v1/context/knowledge/index.d.ts.map +0 -1
  452. package/dist/routes/api/v1/context/knowledge/index.js.map +0 -1
  453. package/dist/routes/api/v1/context/knowledge/route.d.ts.map +0 -1
  454. package/dist/routes/api/v1/context/knowledge/route.js.map +0 -1
  455. package/dist/routes/api/v1/context/project/route.d.ts.map +0 -1
  456. package/dist/routes/api/v1/context/project/route.js.map +0 -1
  457. package/dist/routes/api/v1/git/index.d.ts.map +0 -1
  458. package/dist/routes/api/v1/git/index.js.map +0 -1
  459. package/dist/routes/api/v1/jobs/[id]/route.d.ts.map +0 -1
  460. package/dist/routes/api/v1/jobs/[id]/route.js.map +0 -1
  461. package/dist/routes/api/v1/jobs/[id]/run/route.d.ts.map +0 -1
  462. package/dist/routes/api/v1/jobs/[id]/run/route.js.map +0 -1
  463. package/dist/routes/api/v1/jobs/index.d.ts.map +0 -1
  464. package/dist/routes/api/v1/jobs/index.js.map +0 -1
  465. package/dist/routes/api/v1/jobs/route.d.ts.map +0 -1
  466. package/dist/routes/api/v1/jobs/route.js.map +0 -1
  467. package/dist/routes/api/v1/jobs/status/route.d.ts.map +0 -1
  468. package/dist/routes/api/v1/jobs/status/route.js.map +0 -1
  469. package/dist/routes/api/v1/mcp/index.d.ts.map +0 -1
  470. package/dist/routes/api/v1/mcp/index.js.map +0 -1
  471. package/dist/routes/api/v1/mcp/route.d.ts.map +0 -1
  472. package/dist/routes/api/v1/mcp/route.js.map +0 -1
  473. package/dist/routes/api/v1/proposals/[id]/route.d.ts.map +0 -1
  474. package/dist/routes/api/v1/proposals/[id]/route.js.map +0 -1
  475. package/dist/routes/api/v1/proposals/index.d.ts.map +0 -1
  476. package/dist/routes/api/v1/proposals/index.js.map +0 -1
  477. package/dist/routes/api/v1/proposals/route.d.ts.map +0 -1
  478. package/dist/routes/api/v1/proposals/route.js.map +0 -1
  479. package/dist/routes/api/v1/resources/[id]/index.d.ts.map +0 -1
  480. package/dist/routes/api/v1/resources/[id]/index.js.map +0 -1
  481. package/dist/routes/api/v1/resources/[id]/route.js.map +0 -1
  482. package/dist/routes/api/v1/resources/[id]/thumbnail/index.d.ts.map +0 -1
  483. package/dist/routes/api/v1/resources/[id]/thumbnail/index.js.map +0 -1
  484. package/dist/routes/api/v1/resources/[id]/thumbnail/route.js.map +0 -1
  485. package/dist/routes/api/v1/resources/index.d.ts.map +0 -1
  486. package/dist/routes/api/v1/resources/index.js.map +0 -1
  487. package/dist/routes/api/v1/resources/route.d.ts.map +0 -1
  488. package/dist/routes/api/v1/resources/route.js.map +0 -1
  489. package/dist/routes/api/v1/symlinks/index.d.ts.map +0 -1
  490. package/dist/routes/api/v1/symlinks/index.js.map +0 -1
  491. package/dist/routes/api/v1/symlinks/route.d.ts.map +0 -1
  492. package/dist/routes/api/v1/symlinks/route.js.map +0 -1
  493. package/dist/routes/api/v1/terminal/[proposalId]/create/index.d.ts.map +0 -1
  494. package/dist/routes/api/v1/terminal/[proposalId]/create/index.js.map +0 -1
  495. package/dist/routes/api/v1/terminal/[proposalId]/create/route.d.ts.map +0 -1
  496. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js.map +0 -1
  497. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.d.ts.map +0 -1
  498. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.js.map +0 -1
  499. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.d.ts.map +0 -1
  500. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.js.map +0 -1
  501. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.d.ts.map +0 -1
  502. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.js.map +0 -1
  503. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.d.ts.map +0 -1
  504. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.js.map +0 -1
  505. package/dist/routes/api/v1/terminal/sessions/index.d.ts.map +0 -1
  506. package/dist/routes/api/v1/terminal/sessions/index.js.map +0 -1
  507. package/dist/routes/api/v1/terminal/sessions/route.d.ts.map +0 -1
  508. package/dist/routes/api/v1/terminal/sessions/route.js.map +0 -1
  509. package/dist/routes/api/v1/user/index.d.ts.map +0 -1
  510. package/dist/routes/api/v1/user/index.js.map +0 -1
  511. package/dist/routes/api/v1/user/settings/index.d.ts.map +0 -1
  512. package/dist/routes/api/v1/user/settings/index.js.map +0 -1
  513. package/dist/routes/api/v1/user/settings/route.d.ts.map +0 -1
  514. package/dist/routes/api/v1/user/settings/route.js.map +0 -1
  515. package/dist/server-with-static.d.ts.map +0 -1
  516. package/dist/server-with-static.js.map +0 -1
  517. package/dist/server.d.ts.map +0 -1
  518. package/dist/server.js.map +0 -1
  519. package/static/assets/ActivityPage-DC2t-Kyv.js +0 -1
  520. package/static/assets/ArchitectureEditPage-B5dNFxvL.js +0 -21
  521. package/static/assets/ArchitecturePage-D796d-Je.js +0 -1
  522. package/static/assets/CodePage-xbYipiBR.js +0 -2
  523. package/static/assets/DashboardPage-Aw1xWH4M.js +0 -51
  524. package/static/assets/IntegrationsSettingsPage-Ds16sLG2.js +0 -1
  525. package/static/assets/KnowledgeDetailPage-D94ukozt.js +0 -1
  526. package/static/assets/KnowledgeEditPage-DpjdauND.js +0 -1
  527. package/static/assets/NewKnowledgePage-EqWKQ4lU.js +0 -9
  528. package/static/assets/NotificationsSettingsPage-BzVS1D5M.js +0 -1
  529. package/static/assets/ProjectEditPage-BlQk50Xs.js +0 -11
  530. package/static/assets/PromptsSettingsPage-DWEKgvMD.js +0 -1
  531. package/static/assets/ResourcesPage-C0TGRawd.js +0 -41
  532. package/static/assets/RoleEditPage-m6lOchyA.js +0 -13
  533. package/static/assets/SchedulePage-DUSxe93C.js +0 -4
  534. package/static/assets/TaskEditPage-Dpsi2Rcp.js +0 -1
  535. package/static/assets/TerminalSessionPage-B6_ssmNM.js +0 -8
  536. package/static/assets/UserPreferencesPage-CY_0CoMe.js +0 -1
  537. package/static/assets/UtilitiesPage-e4IaR2YV.js +0 -1
  538. package/static/assets/index-CHdBxVyk.css +0 -2
  539. package/static/assets/kiro-CGoI3Dqh.js +0 -17
  540. package/static/assets/markdown-editor-C-DC0mFI.js +0 -62
  541. package/static/assets/markdown-editor-DUEthZ0y.css +0 -1
  542. package/static/assets/select-Dp3J_OE9.js +0 -1
  543. package/static/assets/tabs-etlvrbtm.js +0 -1
@@ -1 +0,0 @@
1
- import{x as A,u as T,a as F,r as i,A as p,j as e,t as g,B as o,L as x,M as L,Y as S,y as $,z,E as P,H as B,J as K,N as U,O as _,Q as H,R as M,U as R,ae as q,af as I,m as W,_ as J}from"./index-CIFIEidO.js";import{C as d,a as m,b as O,c as Q}from"./card-_Grh-Otl.js";import{B as V}from"./badge-rki-Xf0E.js";import{c as Y}from"./clipboard-B9ndUJKl.js";import{A as j}from"./arrow-left-PEX5RePT.js";import{T as G}from"./tag-B2iP7vv_.js";import{E as X}from"./external-link-B6dkiWgP.js";function Z(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function ie(){const n=A(),N=T(),{toast:r}=F(),l=n.filename,[s,v]=i.useState(null),[w,k]=i.useState(!0),[h,u]=i.useState(!1),[y,f]=i.useState(!1);i.useEffect(()=>{l&&C()},[l]);const C=async()=>{try{const a=await(await fetch(`${p}/api/v1/knowledge/${l}`)).json();a.success?v(a.document):r({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}catch(t){console.error("Error fetching document:",t),r({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}finally{k(!1)}},D=async()=>{if(!s)return;const t=`.nut/knowledge/${s.filename}`;try{await Y(t),f(!0),setTimeout(()=>f(!1),2e3),r({title:"Copied!",description:`Path copied to clipboard: ${t}`})}catch(a){console.error("Failed to copy path:",a),r({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},b=()=>{if(!s)return;const t=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${s.filename.replace(".md","")}`,filename:s.filename,name:s.filename,path:`.nut/knowledge/${s.filename}`}});window.dispatchEvent(t)},E=async()=>{if(s){u(!0);try{const a=await(await fetch(`${p}/api/v1/knowledge/${l}`,{method:"DELETE"})).json();a.success?(r({title:"Success",description:"Knowledge document deleted successfully"}),N("/knowledge")):r({title:"Error",description:a.error||"Failed to delete knowledge document",variant:"destructive"})}catch(t){console.error("Error deleting document:",t),r({title:"Error",description:"Failed to delete knowledge document",variant:"destructive"})}finally{u(!1)}}};return w?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(x,{to:"/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})}),e.jsxs(o,{variant:"outline",size:"sm",onClick:b,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsx(o,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(x,{to:`/knowledge/${l}/edit`,children:[e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs($,{children:[e.jsx(z,{asChild:!0,children:e.jsxs(o,{variant:"destructive",size:"sm",children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})}),e.jsxs(B,{children:[e.jsxs(K,{children:[e.jsx(U,{children:"Delete Knowledge Document"}),e.jsxs(_,{children:["Are you sure you want to delete “",s.title,"”? This action cannot be undone."]})]}),e.jsxs(H,{children:[e.jsx(M,{children:"Cancel"}),e.jsx(R,{onClick:E,disabled:h,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:h?e.jsx(g,{className:"w-4 h-4 animate-spin"}):"Delete"})]})]})]})]})]}),e.jsx("div",{className:"text-left",children:e.jsxs("button",{type:"button",onClick:D,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono text-left",children:[e.jsxs("span",{className:"break-all",children:[".nut/knowledge/",s.filename]}),y?e.jsx(q,{className:"h-3.5 w-3.5 flex-shrink-0 text-green-600"}):e.jsx(I,{className:"h-3.5 w-3.5 flex-shrink-0"})]})})]}),e.jsxs("div",{className:"flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(W,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Updated ",s.metadata.updated]})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-start gap-1.5 sm:items-center",children:[e.jsx(G,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5 sm:mt-0"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map((t,a)=>e.jsx(V,{variant:"outline",className:"text-xs",children:t},a))})]})]}),s.metadata.sources&&s.metadata.sources.length>0&&e.jsxs(d,{children:[e.jsx(O,{children:e.jsx(Q,{children:"Sources"})}),e.jsx(m,{children:e.jsx("ul",{className:"space-y-2",children:s.metadata.sources.map((t,a)=>{const c=Z(t);return e.jsx("li",{children:c.url?e.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-foreground hover:text-primary transition-colors group",children:[e.jsx("span",{className:"group-hover:underline",children:c.title}),e.jsx(X,{className:"w-3.5 h-3.5 text-muted-foreground group-hover:text-primary flex-shrink-0"})]}):e.jsx("span",{className:"text-muted-foreground",children:c.title})},a)})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsx(J,{children:s.content})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:"/knowledge",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The requested knowledge document could not be found."})]})})})]})}export{ie as default};
@@ -1 +0,0 @@
1
- import{x as $,u as z,a as B,r as n,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-CIFIEidO.js";import{C as d,a as l,b as x,c as g}from"./card-_Grh-Otl.js";import{L as p}from"./label-B1lgxULu.js";import{M as U}from"./markdown-editor-C-DC0mFI.js";import{T as _}from"./TagInput-raThOrbG.js";import{n as H,S as J}from"./SourceInput-C0WkiXS6.js";import{A as O}from"./arrow-left-PEX5RePT.js";import"./badge-rki-Xf0E.js";import"./external-link-B6dkiWgP.js";function te(){const y=$(),i=z(),{toast:a}=B(),r=y.filename,[m,T]=n.useState(null),[L,b]=n.useState(!0),[u,f]=n.useState(!1),[o,j]=n.useState(""),[c,v]=n.useState(""),[w,N]=n.useState([]),[k,C]=n.useState([]);n.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))):(a({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge"))}catch(s){console.error("Error fetching document:",s),a({title:"Error",description:"Failed to load knowledge document",variant:"destructive"}),i("/knowledge")}finally{b(!1)}},F=async()=>{if(m){if(!o.trim()){a({title:"Error",description:"Please provide a title for the knowledge document",variant:"destructive"});return}if(!c.trim()){a({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){a({title:"Success",description:"Knowledge document updated successfully"});const P=t.document.filename.replace(".md","");i(`/knowledge/${P}`,{replace:!0})}else a({title:"Error",description:t.error||"Failed to update knowledge document",variant:"destructive"})}catch(s){console.error("Error updating document:",s),a({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 Knowledge 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(g,{children:"Basic Information"})}),e.jsx(l,{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(p,{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(g,{children:"Metadata"})}),e.jsxs(l,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{children:"Tags"}),e.jsx(_,{tags:w,onChange:N,placeholder:"Add a tag"})]}),e.jsxs("div",{children:[e.jsx(p,{children:"Sources"}),e.jsx(J,{sources:k,onChange:C})]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(g,{children:"Content *"})}),e.jsx(l,{children:e.jsx(U,{value:c,onChange:s=>v(s||""),placeholder:"Enter your knowledge content in Markdown..."})})]})]}):null}export{te as default};
@@ -1,9 +0,0 @@
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-CIFIEidO.js";import{C as i,b as c,c as l,a as d}from"./card-_Grh-Otl.js";import{L as m}from"./label-B1lgxULu.js";import{M as A}from"./markdown-editor-C-DC0mFI.js";import{T as B}from"./TagInput-raThOrbG.js";import{S as P}from"./SourceInput-C0WkiXS6.js";import{A as M}from"./arrow-left-PEX5RePT.js";import"./badge-rki-Xf0E.js";import"./external-link-B6dkiWgP.js";function J(){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
-
3
- You can use:
4
- - **Bold text**
5
- - *Italic text*
6
- - # Headers
7
- - - Lists
8
- - [Links](https://example.com)
9
- - Code blocks and more!`})})]})]})}export{J as default};
@@ -1 +0,0 @@
1
- import{r as i,a as W,A as m,j as e,a$ as T,B as v,I as F,a0 as Y,bp as Z,bq as ee}from"./index-CIFIEidO.js";import{C as E,b as B,c as U,d as I,a as O}from"./card-_Grh-Otl.js";import{L as c}from"./label-B1lgxULu.js";import{S as h}from"./switch-LSkE6hx8.js";import{S as se,a as te,b as ae,c as ne,d as ie}from"./select-Dp3J_OE9.js";import{M as re}from"./message-square-LKqx0LRr.js";import{C as oe}from"./circle-check-fwIZxHsK.js";import{C as D}from"./circle-x-CKuM1691.js";import{R as V}from"./refresh-cw-C9ZWZi2c.js";import"./chevron-up-BM1GKhAV.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 je(){const[t,k]=i.useState(y),[x,$]=i.useState(""),[p,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(),G=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]),q=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 q();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(()=>{G()},[G]),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(E,{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(D,{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(D,{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:q,disabled:J||!t.hasBotToken,children:[e.jsx(V,{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(F,{id:"botToken",type:"password",placeholder:t.hasBotToken?"••••••••••••••••":"xoxb-...",value:x,onChange:s=>$(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(F,{id:"signingSecret",type:"password",placeholder:t.hasSigningSecret?"••••••••••••••••":"Enter signing secret",value:p,onChange:s=>P(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(F,{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(E,{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(V,{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(E,{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{je as default};
@@ -1,11 +0,0 @@
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-CIFIEidO.js";import{C as m,a as x,b,c as P}from"./card-_Grh-Otl.js";import{L as l}from"./label-B1lgxULu.js";import{S as B,a as D,b as T,c as O,d as j}from"./select-Dp3J_OE9.js";import{M as V}from"./markdown-editor-C-DC0mFI.js";import{A as W}from"./arrow-left-PEX5RePT.js";import{C as z}from"./circle-check-big-BaFefwt0.js";import"./chevron-up-BM1GKhAV.js";function G(){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 h=0;h<o.length-1;h++)r=r[o[h]];return r[o[o.length-1]]=s,n})};return F?e.jsx("div",{className:"space-y-6",children:e.jsx(m,{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(m,{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(m,{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
-
3
- ## What is this project?
4
-
5
- Describe what your project does, who it's for, and why it exists.
6
-
7
- ## Current State
8
-
9
- - Development stage
10
- - Key features that are working
11
- - What's planned for next releases`,height:800})})]})]})}export{G as default};
@@ -1 +0,0 @@
1
- import{j as e,a$ as p,B as r,P as h,Y as j,af as u,E as g,I as l}from"./index-CIFIEidO.js";import{C as t,b as i,c as n,d as c,a as d}from"./card-_Grh-Otl.js";import{L as a}from"./label-B1lgxULu.js";import{S as f,a as v,b as N,c as y,d as b}from"./select-Dp3J_OE9.js";import{B as o}from"./badge-rki-Xf0E.js";import{E as w}from"./eye-DQUzAWBY.js";import{D as C}from"./download-5iQDQeY0.js";import"./chevron-up-BM1GKhAV.js";function U(){const m=[{id:"1",name:"Code Review Assistant",description:"Prompt for AI agents to perform thorough code reviews",category:"Code Review",usage:"cursor-cli, claude-code",lastUpdated:"2 days ago",active:!0},{id:"2",name:"Architecture Advisor",description:"System prompt for architectural decision guidance",category:"Architecture",usage:"gemini-cli, claude-code",lastUpdated:"1 week ago",active:!0},{id:"3",name:"Bug Analysis Expert",description:"Specialized prompt for debugging and error analysis",category:"Debugging",usage:"cursor-cli",lastUpdated:"3 days ago",active:!1},{id:"4",name:"Documentation Generator",description:"Prompt for generating comprehensive code documentation",category:"Documentation",usage:"github-copilot, claude-code",lastUpdated:"5 days ago",active:!0}],x=["Code Review","Architecture","Debugging","Documentation","Testing","Refactoring","Security","Performance"];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"System Prompts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage system prompts used by AI agents and integrations for consistent behavior."})]}),e.jsx(p,{}),e.jsxs(t,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(n,{children:"Prompt Library"}),e.jsx(c,{children:"Pre-configured prompts for different AI agents and use cases."})]}),e.jsxs(r,{size:"sm",children:[e.jsx(h,{className:"h-4 w-4 mr-2"}),"New Prompt"]})]})}),e.jsx(d,{children:e.jsx("div",{className:"space-y-4",children:m.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h4",{className:"font-medium",children:s.name}),e.jsx(o,{variant:s.active?"default":"secondary",children:s.active?"Active":"Inactive"}),e.jsx(o,{variant:"outline",children:s.category})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.description}),e.jsxs("div",{className:"flex items-center space-x-4 mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used by: ",s.usage]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Updated: ",s.lastUpdated]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(w,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(j,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(u,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(g,{className:"h-4 w-4"})})]})]},s.id))})})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Create New Prompt"}),e.jsx(c,{children:"Design a new system prompt for your AI agents and integrations."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptName",children:"Prompt Name"}),e.jsx(l,{id:"promptName",placeholder:"Enter prompt name"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptCategory",children:"Category"}),e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(N,{placeholder:"Select category"})}),e.jsx(y,{children:x.map(s=>e.jsx(b,{value:s.toLowerCase(),children:s},s))})]})]})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptDescription",children:"Description"}),e.jsx(l,{id:"promptDescription",placeholder:"Brief description of the prompt's purpose"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"targetIntegrations",children:"Target Integrations"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:["cursor-cli","claude-code","gemini-cli","github-copilot"].map(s=>e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",className:"rounded"}),e.jsx("span",{className:"text-sm",children:s})]},s))})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptContent",children:"Prompt Content"}),e.jsx("textarea",{id:"promptContent",className:"w-full min-h-[200px] p-3 border rounded-md font-mono text-sm",placeholder:"You are an expert code reviewer. Your task is to..."})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptVariables",children:"Variables (JSON format)"}),e.jsx("textarea",{id:"promptVariables",className:"w-full min-h-[100px] p-3 border rounded-md font-mono text-sm",placeholder:'{"language": "typescript", "framework": "react", "style": "functional"}'})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(r,{variant:"outline",children:"Preview"}),e.jsx(r,{variant:"outline",children:"Save as Draft"}),e.jsx(r,{children:"Save & Activate"})]})]})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Prompt Templates"}),e.jsx(c,{children:"Import and export prompt templates for sharing across teams."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(r,{variant:"outline",size:"sm",children:[e.jsx(C,{className:"h-4 w-4 mr-2"}),"Import Template"]}),e.jsx(r,{variant:"outline",size:"sm",children:"Export All Prompts"}),e.jsx(r,{variant:"outline",size:"sm",children:"Export Selected"})]}),e.jsx("div",{className:"p-4 border-2 border-dashed rounded-lg text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag and drop prompt template files here, or click to browse"})})]})]})]})}export{U as default};
@@ -1,41 +0,0 @@
1
- import{c as xe,r as t,j as e,D as pe,b as ge,d as ve,f as je,t as le,S as os,B as F,ae as Xe,h as Ee,a as $e,A as ae,o as be,ab as Ve,p as ue,ag as ca,ah as da,ai as ua,aj as we,ak as Fe,al as _e,am as ma,an as Bs,ao as ha,ap as xa,e as fa,I as We,af as Ze,X as cs,C as $s,m as pa,F as Ne,aq as es,ar as ga,as as va,at as ja,a2 as ba,a3 as wa,n as Na,a4 as ya,a7 as Je,P as ds,g as us,E as ms,au as _a}from"./index-CIFIEidO.js";import{C as Ye,b as hs,a as Qe,c as Sa,d as Ca}from"./card-_Grh-Otl.js";import{L as C}from"./label-B1lgxULu.js";import{B as Me}from"./badge-rki-Xf0E.js";import{c as ka}from"./clipboard-B9ndUJKl.js";import{S as B,a as $,b as U,c as z,d as K}from"./select-Dp3J_OE9.js";import{R as Us}from"./registry-ANRa5WBi.js";import{I as ye,M as fe,V as Be,L as Pa,H as Ea,F as ss,a as xs}from"./video-A2wzYKal.js";import{D as as}from"./download-5iQDQeY0.js";import{C as zs}from"./chevron-left-LQtIDk73.js";import{T as Ma}from"./tag-B2iP7vv_.js";import{S as Fa}from"./search-C1RuN2pO.js";import"./chevron-up-BM1GKhAV.js";/**
2
- * @license lucide-react v0.542.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Ia=[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]],fs=xe("file-audio",Ia);/**
7
- * @license lucide-react v0.542.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Ta=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],ps=xe("file-image",Ta);/**
12
- * @license lucide-react v0.542.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Ra=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],gs=xe("file-json",Ra);/**
17
- * @license lucide-react v0.542.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Da=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z",key:"1tzo1f"}]],vs=xe("file-play",Da);/**
22
- * @license lucide-react v0.542.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Ga=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],js=xe("file-spreadsheet",Ga);/**
27
- * @license lucide-react v0.542.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Aa=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]],bs=xe("file-type",Aa);/**
32
- * @license lucide-react v0.542.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const La=[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]],ws=xe("presentation",La);/**
37
- * @license lucide-react v0.542.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const Ka=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Oa=xe("upload",Ka);async function qs(l){const c=l.startsWith("http")?l:`${Us}${l}`,n=await fetch(c,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!n.ok)throw new Error(`Failed to fetch registry resource: ${n.status}`);return n.json()}async function Va(){return qs("/registry/resources/root.json")}async function Ns(l){return qs(l)}function Ke(l){if(l)return l.startsWith("http")?l:`${Us}${l}`}function Wa({open:l,onOpenChange:c,onSelectExample:n,onCustomizeInAssistant:p}){const[m,u]=t.useState([]),[v,h]=t.useState(!1),[_,P]=t.useState(null),[S,d]=t.useState(null),[x,w]=t.useState(null),[T,N]=t.useState(!1),[j,y]=t.useState(null);t.useEffect(()=>{l&&(h(!0),P(null),d(null),w(null),y(null),Va().then(g=>{u(g.elements??[]),g.elements&&g.elements.length>0&&V(g.elements[0])}).catch(g=>{console.error("Failed to load registry resources",g),u([]),P("Failed to load examples from registry")}).finally(()=>h(!1)))},[l]);const V=async g=>{d(g.id),y(null),w(null),N(!0);try{const k=await Ns(g.endpoint);w(k)}catch(k){console.error("Failed to load resource detail",k),y("Unable to load details for this example")}finally{N(!1)}},E=()=>{x?.prompt&&(n(x.prompt),c(!1))},R=()=>{x?.prompt&&p&&(p(x.prompt),c(!1))},q=async g=>{if(S===g.id&&x?.prompt){n(x.prompt),c(!1);return}try{const k=await Ns(g.endpoint);k.prompt&&(n(k.prompt),c(!1))}catch(k){console.error("Failed to load resource detail",k)}};return e.jsx(pe,{open:l,onOpenChange:c,children:e.jsxs(ge,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ve,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(je,{className:"text-base sm:text-lg",children:"Example Prompts"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden relative",children:[e.jsx("div",{className:"h-[40%] min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:T?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5 animate-spin mr-2"}),"Loading..."]}):j?e.jsx("p",{className:"text-sm text-muted-foreground",children:j}):x?e.jsx("img",{src:Ke(x.imageUrl),alt:x.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select an example"})}),e.jsxs("div",{className:"flex-1 min-h-0 border-t flex flex-col",children:[v?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):_?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:_}):m.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(os,{className:"flex-1",children:e.jsx("div",{className:"p-3 space-y-2",children:m.map(g=>e.jsxs("button",{onClick:()=>V(g),onDoubleClick:()=>q(g),className:`w-full text-left p-2 rounded-lg border-2 transition-all flex gap-3 ${S===g.id?"border-primary bg-primary/5":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[g.thumbnailUrl&&e.jsx("img",{src:Ke(g.thumbnailUrl),alt:"",className:"w-12 h-12 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:g.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:g.description})]})]},g.id))})}),e.jsx("div",{className:"p-3 border-t flex-shrink-0",children:e.jsxs(F,{onClick:E,disabled:!x?.prompt||T,className:"w-full",children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),"Use This Prompt"]})})]}),x&&p&&e.jsx("div",{className:"absolute bottom-16 right-3 z-10",children:e.jsxs(F,{size:"sm",variant:"secondary",onClick:R,children:[e.jsx(Ee,{className:"mr-1.5 h-3.5 w-3.5"}),"Customize"]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsxs("div",{className:"w-[35%] border-r flex flex-col",children:[v?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):_?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:_}):m.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(os,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-3",children:m.map(g=>e.jsxs("button",{onClick:()=>V(g),onDoubleClick:()=>q(g),className:`w-full text-left p-3 rounded-lg border-2 transition-all flex gap-3 ${S===g.id?"border-primary bg-primary/5 shadow-sm":"border-transparent bg-muted/50 hover:bg-muted hover:border-muted-foreground/20"}`,children:[g.thumbnailUrl&&e.jsx("img",{src:Ke(g.thumbnailUrl),alt:"",className:"w-16 h-16 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:g.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:g.description}),g.tags&&g.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[g.tags.slice(0,3).map(k=>e.jsx(Me,{variant:"secondary",className:"text-[10px]",children:k},k)),g.tags.length>3&&e.jsxs(Me,{variant:"outline",className:"text-[10px]",children:["+",g.tags.length-3]})]})]})]},g.id))})}),e.jsx("div",{className:"p-4 border-t flex-shrink-0",children:e.jsxs(F,{onClick:E,disabled:!x?.prompt||T,className:"w-full",children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),"Use This Prompt"]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:T?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5 animate-spin mr-2"}),"Loading details..."]}):j?e.jsx("p",{className:"text-sm text-muted-foreground",children:j}):x?e.jsx("img",{src:Ke(x.imageUrl),alt:x.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select an example to preview"})}),x&&e.jsxs("div",{className:"border-t p-4 bg-background flex-shrink-0 max-h-[30%] overflow-y-auto",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2 font-medium",children:"Full Prompt:"}),e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:x.prompt})]}),x&&p&&e.jsx("div",{className:"absolute bottom-4 right-4 z-10",children:e.jsxs(F,{size:"sm",variant:"secondary",onClick:R,children:[e.jsx(Ee,{className:"mr-1.5 h-3.5 w-3.5"}),"Customize in Assistant"]})})]})]})]})})}const ys="image-generator-settings";function _s(){return e.jsxs("div",{className:"relative h-4 w-4",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-primary/30"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin"}),e.jsx("div",{className:"absolute inset-[3px] rounded-full border border-transparent border-t-primary/60 animate-spin",style:{animationDirection:"reverse",animationDuration:"0.6s"}})]})}const Oe={"nano-banana-pro":{id:"nano-banana-pro",label:"Nano Banana Pro",replicateId:"google/nano-banana-pro",features:{resolution:!0,outputQuality:!1,quality:!1,goFast:!1,safetyTolerance:!1,matchInputImage:!1,background:!1},resolutionOptions:[{value:"1K",label:"1K"},{value:"2K",label:"2K"},{value:"4K",label:"4K"}],defaults:{resolution:"2K"}},"flux-2-dev":{id:"flux-2-dev",label:"FLUX.2 Dev",replicateId:"black-forest-labs/flux-2-dev",features:{resolution:!1,outputQuality:!0,quality:!1,goFast:!0,safetyTolerance:!1,matchInputImage:!0,background:!1},defaults:{outputQuality:80,goFast:!0}},"flux-2-pro":{id:"flux-2-pro",label:"FLUX.2 Pro",replicateId:"black-forest-labs/flux-2-pro",features:{resolution:!0,outputQuality:!0,quality:!1,goFast:!1,safetyTolerance:!0,matchInputImage:!1,background:!1},resolutionOptions:[{value:"0.5 MP",label:"0.5 MP"},{value:"1 MP",label:"1 MP"},{value:"2 MP",label:"2 MP"},{value:"4 MP",label:"4 MP"}],defaults:{resolution:"2 MP",outputQuality:80,safetyTolerance:2}},"gpt-image-1.5":{id:"gpt-image-1.5",label:"GPT Image 1.5",replicateId:"openai/gpt-image-1.5",features:{resolution:!1,outputQuality:!1,quality:!0,goFast:!1,safetyTolerance:!1,matchInputImage:!1,background:!0},aspectRatioOptions:[{value:"1:1",label:"1:1"},{value:"3:2",label:"3:2"},{value:"2:3",label:"2:3"}],defaults:{aspectRatio:"1:1",quality:"high",background:"auto"}}},Ss=Object.values(Oe).map(l=>({value:l.id,label:l.label})),Cs=[{value:"1:1",label:"1:1"},{value:"2:3",label:"2:3"},{value:"3:2",label:"3:2"},{value:"3:4",label:"3:4"},{value:"4:3",label:"4:3"},{value:"4:5",label:"4:5"},{value:"5:4",label:"5:4"},{value:"9:16",label:"9:16"},{value:"16:9",label:"16:9"},{value:"21:9",label:"21:9"}],Ba={value:"match_input_image",label:"Match Input"},ks=[{value:"png",label:"PNG"},{value:"jpg",label:"JPG"},{value:"webp",label:"WebP"}],Ps=[{value:"60",label:"60"},{value:"70",label:"70"},{value:"80",label:"80"},{value:"90",label:"90"},{value:"100",label:"100"}],Es=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}],Ms=[{value:"auto",label:"Auto"},{value:"transparent",label:"Transparent"},{value:"opaque",label:"Opaque"}],Fs=[{value:"1",label:"1 (Strict)"},{value:"2",label:"2"},{value:"3",label:"3"},{value:"4",label:"4"},{value:"5",label:"5"},{value:"6",label:"6 (Relaxed)"}];function $a({open:l,onOpenChange:c,onSave:n,onCustomizeInAssistant:p}){const m=a=>a.aspectRatioOptions?a.aspectRatioOptions:a.features.matchInputImage?[Ba,...Cs]:Cs,u=(a,s)=>typeof s!="string"?!1:new Set(m(a).map(f=>f.value)).has(s),h=(()=>{if(typeof window>"u")return null;try{const a=localStorage.getItem(ys);return a?JSON.parse(a):null}catch{return null}})(),_=h?.model||"nano-banana-pro",P=Oe[_],S=u(P,h?.aspectRatio)?h?.aspectRatio:P.defaults.aspectRatio||"16:9",[d,x]=t.useState(""),[w,T]=t.useState(_),[N,j]=t.useState(S),[y,V]=t.useState(h?.resolution||"2K"),[E,R]=t.useState(h?.outputFormat||"png"),[q,g]=t.useState(h?.outputQuality||"80"),[k,O]=t.useState(h?.quality||"high"),[L,G]=t.useState(h?.goFast??!0),[I,H]=t.useState(h?.safetyTolerance||"2"),[se,b]=t.useState(h?.background||"auto"),[D,Y]=t.useState(null),[A,W]=t.useState(!1),[Q,o]=t.useState(!1),[te,i]=t.useState([]),[M,ee]=t.useState([]),[X,re]=t.useState(!0),[de,me]=t.useState(!1),[Ie,Te]=t.useState(0),he=t.useRef(null),{toast:ie}=$e();t.useEffect(()=>{const a={model:w,aspectRatio:N,resolution:y,outputFormat:E,outputQuality:q,quality:k,goFast:L,safetyTolerance:I,background:se};localStorage.setItem(ys,JSON.stringify(a))},[w,N,y,E,q,k,L,I,se]),t.useEffect(()=>(A?(Te(0),he.current=setInterval(()=>{Te(a=>a+1)},1e3)):he.current&&(clearInterval(he.current),he.current=null),()=>{he.current&&clearInterval(he.current)}),[A]);const J=Oe[w],Ce=m(J),Re=J.resolutionOptions||[];t.useEffect(()=>{const a=Oe[w];a.defaults.resolution&&a.features.resolution&&V(a.defaults.resolution),a.defaults.outputQuality!==void 0&&g(String(a.defaults.outputQuality)),a.defaults.quality!==void 0&&a.features.quality&&O(String(a.defaults.quality)),a.defaults.goFast!==void 0&&G(a.defaults.goFast),a.defaults.safetyTolerance!==void 0&&H(String(a.defaults.safetyTolerance)),a.defaults.background!==void 0&&a.features.background&&b(String(a.defaults.background)),j(s=>{const r=m(a).map(f=>f.value);return r.includes(s)?s:a.defaults.aspectRatio||r[0]||"16:9"})},[w]),t.useEffect(()=>{l&&ze()},[l]);const ze=async()=>{try{const s=await(await fetch(`${ae}/api/v1/resources`)).json();if(s.success){const r=(s.data||[]).filter(f=>{const Z=f.type==="image/jpeg"||f.name.toLowerCase().endsWith(".jpg")||f.name.toLowerCase().endsWith(".jpeg"),ne=f.type==="image/png"||f.name.toLowerCase().endsWith(".png");return(Z||ne)&&f.thumbnailPath});i(r)}}catch(a){console.error("Failed to fetch image resources:",a)}},ke=async()=>{if(!d.trim()){ie({title:"Prompt required",description:"Please enter a prompt to generate an image",variant:"destructive"});return}W(!0),Y(null);try{const a=X||M.length===0?[]:[...M],s=new AbortController,r=setTimeout(()=>s.abort(),3e5),f=await fetch(`${ae}/api/v1/resources/generate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:s.signal,body:JSON.stringify({prompt:d,model:w,dimensions:N,resolution:J.features.resolution?y:void 0,output_format:E,output_quality:J.features.outputQuality?parseInt(q):void 0,quality:J.features.quality?k:void 0,go_fast:J.features.goFast?L:void 0,safety_tolerance:J.features.safetyTolerance?parseInt(I):void 0,background:J.features.background?se:void 0,image_input:a})});if(clearTimeout(r),f.status===504||f.status===502||f.status===408)throw new Error("Request timed out. The image model may be warming up - please try again.");const Z=f.headers.get("content-type");if(!Z||!Z.includes("application/json"))throw new Error("Request timed out or server error. Please try again.");const ne=await f.json();if(!f.ok||!ne.success){const ce=ne.error?.message||"Failed to generate image",oe=ne.error?.code==="MISSING_API_TOKEN";throw new Error(oe?"Replicate API token not configured. Please add it in Settings → Integrations.":ce)}Y(ne.data.imageUrl),ie({title:"Image generated",description:"Your image has been generated successfully"})}catch(a){console.error("Generation error:",a);const s=a instanceof Error&&a.name==="AbortError",r=s?"Request timed out after 5 minutes. The model may be overloaded - please try again.":a instanceof Error?a.message:"Failed to generate image.",f=s||r.toLowerCase().includes("timeout")||r.toLowerCase().includes("timed out");ie({title:f?"Generation timed out":"Generation failed",description:r,variant:"destructive"})}finally{W(!1)}};t.useEffect(()=>{const a=s=>{l&&(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&(s.preventDefault(),d.trim()&&!A&&!Q&&ke())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[l,d,A,Q]);const De=async()=>{if(D){o(!0);try{await n(D,{prompt:d,model:w}),x(""),T("nano-banana-pro"),j("16:9"),V("2K"),R("png"),g("80"),O("high"),G(!0),H("2"),b("auto"),Y(null),re(!0),ee([]),c(!1)}catch(a){ie({title:"Save failed",description:a instanceof Error?a.message:"Failed to save image. Please try again.",variant:"destructive"})}finally{o(!1)}}},Ge=()=>{!A&&!Q&&c(!1)},Ae=()=>{re(!0),ee([])},Le=a=>{X&&re(!1),M.includes(a)?(ee(M.filter(s=>s!==a)),M.length===1&&re(!0)):M.length<3?ee([...M,a]):ie({title:"Maximum selection",description:"You can only select up to 3 images",variant:"destructive"})},qe=a=>{x(a)},He=a=>{p&&(me(!1),c(!1),p(`"${a}" Please customize this (and respond back just the updated markdown):`))};return e.jsxs(pe,{open:l,onOpenChange:Ge,children:[e.jsxs(ge,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ve,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(je,{className:"text-base sm:text-lg",children:"Generate Image"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:A?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(le,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):D?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:D,alt:"Generated",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(ye,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"}),e.jsxs(F,{size:"sm",onClick:()=>me(!0),className:"mt-2",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"View Examples"]})]})}),e.jsx("div",{className:"border-t bg-background p-2 flex-shrink-0",children:e.jsxs("div",{className:"flex gap-1.5 overflow-x-auto pb-1",children:[e.jsx("button",{onClick:Ae,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${X?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),te.map(a=>{const s=M.includes(a.id);return e.jsx("button",{onClick:()=>Le(a.id),className:`flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${s?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${ae}/api/v1/resources/${a.id}/thumbnail`,alt:a.name,className:"w-full h-full object-cover"})},a.id)})]})}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[45vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"prompt-mobile",className:"text-xs",children:"Prompt"}),e.jsx(be,{id:"prompt-mobile",placeholder:"Describe the image...",value:d,onChange:a=>x(a.target.value),rows:2,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"model-mobile",className:"text-xs",children:"Model"}),e.jsxs(B,{value:w,onValueChange:a=>T(a),children:[e.jsx($,{id:"model-mobile",className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Ss.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"outputFormat-mobile",className:"text-xs",children:"Format"}),e.jsxs(B,{value:E,onValueChange:R,children:[e.jsx($,{id:"outputFormat-mobile",className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:ks.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),J.features.background&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"background-mobile",className:"text-xs",children:"Background"}),e.jsxs(B,{value:se,onValueChange:b,children:[e.jsx($,{id:"background-mobile",className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Ms.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),J.features.goFast&&e.jsx("div",{className:"space-y-1 flex flex-col justify-end",children:e.jsxs("div",{className:"flex items-center space-x-2 h-8",children:[e.jsx(Ve,{id:"goFast-mobile",checked:L,onCheckedChange:a=>G(a===!0)}),e.jsx(C,{htmlFor:"goFast-mobile",className:"text-xs cursor-pointer",children:"Go Fast"})]})}),J.features.safetyTolerance&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"safetyTolerance-mobile",className:"text-xs",children:"Safety"}),e.jsxs(B,{value:I,onValueChange:H,children:[e.jsx($,{id:"safetyTolerance-mobile",className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Fs.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[J.features.resolution&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"resolution-mobile",className:"text-xs",children:"Resolution"}),e.jsxs(B,{value:y,onValueChange:V,children:[e.jsx($,{id:"resolution-mobile",className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Re.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"aspectRatio-mobile",className:"text-xs",children:"Ratio"}),e.jsxs(B,{value:N,onValueChange:j,children:[e.jsx($,{id:"aspectRatio-mobile",className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Ce.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),J.features.outputQuality&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"outputQuality-mobile",className:"text-xs",children:"Quality"}),e.jsxs(B,{value:q,onValueChange:g,children:[e.jsx($,{id:"outputQuality-mobile",className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Ps.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),J.features.quality&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"quality-mobile",className:"text-xs",children:"Quality"}),e.jsxs(B,{value:k,onValueChange:O,children:[e.jsx($,{id:"quality-mobile",className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Es.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(F,{onClick:ke,disabled:!d.trim()||A||Q,className:"flex-1 h-9",size:"sm",children:A?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(_s,{}),e.jsxs("span",{children:[Ie,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(ue,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(F,{onClick:De,disabled:!D||A||Q,variant:"outline",className:"flex-1 h-9",size:"sm",children:Q?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[22%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"prompt",children:"Prompt"}),e.jsx(be,{id:"prompt",placeholder:"Describe the image you want to generate...",value:d,onChange:a=>x(a.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"model",children:"Model"}),e.jsxs(B,{value:w,onValueChange:a=>T(a),children:[e.jsx($,{id:"model",children:e.jsx(U,{})}),e.jsx(z,{children:Ss.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(B,{value:N,onValueChange:j,children:[e.jsx($,{id:"aspectRatio",children:e.jsx(U,{})}),e.jsx(z,{children:Ce.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),J.features.resolution&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(B,{value:y,onValueChange:V,children:[e.jsx($,{id:"resolution",children:e.jsx(U,{})}),e.jsx(z,{children:Re.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"outputFormat",children:"Output Format"}),e.jsxs(B,{value:E,onValueChange:R,children:[e.jsx($,{id:"outputFormat",children:e.jsx(U,{})}),e.jsx(z,{children:ks.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),J.features.background&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"background",children:"Background"}),e.jsxs(B,{value:se,onValueChange:b,children:[e.jsx($,{id:"background",children:e.jsx(U,{})}),e.jsx(z,{children:Ms.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),J.features.outputQuality&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"outputQuality",children:"Output Quality"}),e.jsxs(B,{value:q,onValueChange:g,children:[e.jsx($,{id:"outputQuality",children:e.jsx(U,{})}),e.jsx(z,{children:Ps.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),J.features.quality&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"quality",children:"Quality"}),e.jsxs(B,{value:k,onValueChange:O,children:[e.jsx($,{id:"quality",children:e.jsx(U,{})}),e.jsx(z,{children:Es.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),J.features.goFast&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"goFast",checked:L,onCheckedChange:a=>G(a===!0)}),e.jsx(C,{htmlFor:"goFast",className:"cursor-pointer",children:"Go Fast"})]}),J.features.safetyTolerance&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"safetyTolerance",children:"Safety Tolerance"}),e.jsxs(B,{value:I,onValueChange:H,children:[e.jsx($,{id:"safetyTolerance",children:e.jsx(U,{})}),e.jsx(z,{children:Fs.map(a=>e.jsx(K,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(F,{onClick:ke,disabled:!d.trim()||A||Q,className:"w-full",children:A?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(_s,{}),e.jsxs("span",{children:["Generating... ",Ie,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(ue,{children:"⌘"}),e.jsx(ue,{children:"↵"})]})}),e.jsx(F,{onClick:De,disabled:!D||A||Q,variant:"outline",className:"w-full",children:Q?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:A?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(le,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating image..."})]}):D?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:D,alt:"Generated",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(ye,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated image will appear here"}),e.jsxs(F,{onClick:()=>me(!0),className:"mt-2",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"View Examples"]})]})}),e.jsx("div",{className:"border-t bg-background p-4 flex-shrink-0",children:e.jsxs("div",{className:"flex gap-2 overflow-x-auto",children:[e.jsx("button",{onClick:Ae,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${X?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),te.map(a=>{const s=M.includes(a.id);return e.jsx("button",{onClick:()=>Le(a.id),className:`flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${s?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${ae}/api/v1/resources/${a.id}/thumbnail`,alt:a.name,className:"w-full h-full object-cover"})},a.id)})]})})]})]})]}),e.jsx(Wa,{open:de,onOpenChange:me,onSelectExample:qe,onCustomizeInAssistant:p?He:void 0})]})}var Hs=["PageUp","PageDown"],Js=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Ys={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Se="Slider",[ts,Ua,za]=ua(Se),[Qs,St]=da(Se,[za]),[qa,Ue]=Qs(Se),Xs=t.forwardRef((l,c)=>{const{name:n,min:p=0,max:m=100,step:u=1,orientation:v="horizontal",disabled:h=!1,minStepsBetweenThumbs:_=0,defaultValue:P=[p],value:S,onValueChange:d=()=>{},onValueCommit:x=()=>{},inverted:w=!1,form:T,...N}=l,j=t.useRef(new Set),y=t.useRef(0),E=v==="horizontal"?Ha:Ja,[R=[],q]=ca({prop:S,defaultProp:P,onChange:I=>{[...j.current][y.current]?.focus(),d(I)}}),g=t.useRef(R);function k(I){const H=et(R,I);G(I,H)}function O(I){G(I,y.current)}function L(){const I=g.current[y.current];R[y.current]!==I&&x(R)}function G(I,H,{commit:se}={commit:!1}){const b=nt(u),D=lt(Math.round((I-p)/u)*u+p,b),Y=Bs(D,[p,m]);q((A=[])=>{const W=Xa(A,Y,H);if(tt(W,_*u)){y.current=W.indexOf(Y);const Q=String(W)!==String(A);return Q&&se&&x(W),Q?W:A}else return A})}return e.jsx(qa,{scope:l.__scopeSlider,name:n,disabled:h,min:p,max:m,valueIndexToChangeRef:y,thumbs:j.current,values:R,orientation:v,form:T,children:e.jsx(ts.Provider,{scope:l.__scopeSlider,children:e.jsx(ts.Slot,{scope:l.__scopeSlider,children:e.jsx(E,{"aria-disabled":h,"data-disabled":h?"":void 0,...N,ref:c,onPointerDown:we(N.onPointerDown,()=>{h||(g.current=R)}),min:p,max:m,inverted:w,onSlideStart:h?void 0:k,onSlideMove:h?void 0:O,onSlideEnd:h?void 0:L,onHomeKeyDown:()=>!h&&G(p,0,{commit:!0}),onEndKeyDown:()=>!h&&G(m,R.length-1,{commit:!0}),onStepKeyDown:({event:I,direction:H})=>{if(!h){const D=Hs.includes(I.key)||I.shiftKey&&Js.includes(I.key)?10:1,Y=y.current,A=R[Y],W=u*D*H;G(A+W,Y,{commit:!0})}}})})})})});Xs.displayName=Se;var[Zs,ea]=Qs(Se,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Ha=t.forwardRef((l,c)=>{const{min:n,max:p,dir:m,inverted:u,onSlideStart:v,onSlideMove:h,onSlideEnd:_,onStepKeyDown:P,...S}=l,[d,x]=t.useState(null),w=_e(c,E=>x(E)),T=t.useRef(void 0),N=ma(m),j=N==="ltr",y=j&&!u||!j&&u;function V(E){const R=T.current||d.getBoundingClientRect(),q=[0,R.width],k=rs(q,y?[n,p]:[p,n]);return T.current=R,k(E-R.left)}return e.jsx(Zs,{scope:l.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:e.jsx(sa,{dir:N,"data-orientation":"horizontal",...S,ref:w,style:{...S.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const R=V(E.clientX);v?.(R)},onSlideMove:E=>{const R=V(E.clientX);h?.(R)},onSlideEnd:()=>{T.current=void 0,_?.()},onStepKeyDown:E=>{const q=Ys[y?"from-left":"from-right"].includes(E.key);P?.({event:E,direction:q?-1:1})}})})}),Ja=t.forwardRef((l,c)=>{const{min:n,max:p,inverted:m,onSlideStart:u,onSlideMove:v,onSlideEnd:h,onStepKeyDown:_,...P}=l,S=t.useRef(null),d=_e(c,S),x=t.useRef(void 0),w=!m;function T(N){const j=x.current||S.current.getBoundingClientRect(),y=[0,j.height],E=rs(y,w?[p,n]:[n,p]);return x.current=j,E(N-j.top)}return e.jsx(Zs,{scope:l.__scopeSlider,startEdge:w?"bottom":"top",endEdge:w?"top":"bottom",size:"height",direction:w?1:-1,children:e.jsx(sa,{"data-orientation":"vertical",...P,ref:d,style:{...P.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:N=>{const j=T(N.clientY);u?.(j)},onSlideMove:N=>{const j=T(N.clientY);v?.(j)},onSlideEnd:()=>{x.current=void 0,h?.()},onStepKeyDown:N=>{const y=Ys[w?"from-bottom":"from-top"].includes(N.key);_?.({event:N,direction:y?-1:1})}})})}),sa=t.forwardRef((l,c)=>{const{__scopeSlider:n,onSlideStart:p,onSlideMove:m,onSlideEnd:u,onHomeKeyDown:v,onEndKeyDown:h,onStepKeyDown:_,...P}=l,S=Ue(Se,n);return e.jsx(Fe.span,{...P,ref:c,onKeyDown:we(l.onKeyDown,d=>{d.key==="Home"?(v(d),d.preventDefault()):d.key==="End"?(h(d),d.preventDefault()):Hs.concat(Js).includes(d.key)&&(_(d),d.preventDefault())}),onPointerDown:we(l.onPointerDown,d=>{const x=d.target;x.setPointerCapture(d.pointerId),d.preventDefault(),S.thumbs.has(x)?x.focus():p(d)}),onPointerMove:we(l.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&m(d)}),onPointerUp:we(l.onPointerUp,d=>{const x=d.target;x.hasPointerCapture(d.pointerId)&&(x.releasePointerCapture(d.pointerId),u(d))})})}),aa="SliderTrack",ta=t.forwardRef((l,c)=>{const{__scopeSlider:n,...p}=l,m=Ue(aa,n);return e.jsx(Fe.span,{"data-disabled":m.disabled?"":void 0,"data-orientation":m.orientation,...p,ref:c})});ta.displayName=aa;var ns="SliderRange",na=t.forwardRef((l,c)=>{const{__scopeSlider:n,...p}=l,m=Ue(ns,n),u=ea(ns,n),v=t.useRef(null),h=_e(c,v),_=m.values.length,P=m.values.map(x=>ia(x,m.min,m.max)),S=_>1?Math.min(...P):0,d=100-Math.max(...P);return e.jsx(Fe.span,{"data-orientation":m.orientation,"data-disabled":m.disabled?"":void 0,...p,ref:h,style:{...l.style,[u.startEdge]:S+"%",[u.endEdge]:d+"%"}})});na.displayName=ns;var ls="SliderThumb",la=t.forwardRef((l,c)=>{const n=Ua(l.__scopeSlider),[p,m]=t.useState(null),u=_e(c,h=>m(h)),v=t.useMemo(()=>p?n().findIndex(h=>h.ref.current===p):-1,[n,p]);return e.jsx(Ya,{...l,ref:u,index:v})}),Ya=t.forwardRef((l,c)=>{const{__scopeSlider:n,index:p,name:m,...u}=l,v=Ue(ls,n),h=ea(ls,n),[_,P]=t.useState(null),S=_e(c,V=>P(V)),d=_?v.form||!!_.closest("form"):!0,x=ha(_),w=v.values[p],T=w===void 0?0:ia(w,v.min,v.max),N=Za(p,v.values.length),j=x?.[h.size],y=j?st(j,T,h.direction):0;return t.useEffect(()=>{if(_)return v.thumbs.add(_),()=>{v.thumbs.delete(_)}},[_,v.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[h.startEdge]:`calc(${T}% + ${y}px)`},children:[e.jsx(ts.ItemSlot,{scope:l.__scopeSlider,children:e.jsx(Fe.span,{role:"slider","aria-label":l["aria-label"]||N,"aria-valuemin":v.min,"aria-valuenow":w,"aria-valuemax":v.max,"aria-orientation":v.orientation,"data-orientation":v.orientation,"data-disabled":v.disabled?"":void 0,tabIndex:v.disabled?void 0:0,...u,ref:S,style:w===void 0?{display:"none"}:l.style,onFocus:we(l.onFocus,()=>{v.valueIndexToChangeRef.current=p})})}),d&&e.jsx(ra,{name:m??(v.name?v.name+(v.values.length>1?"[]":""):void 0),form:v.form,value:w},p)]})});la.displayName=ls;var Qa="RadioBubbleInput",ra=t.forwardRef(({__scopeSlider:l,value:c,...n},p)=>{const m=t.useRef(null),u=_e(m,p),v=xa(c);return t.useEffect(()=>{const h=m.current;if(!h)return;const _=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(_,"value").set;if(v!==c&&S){const d=new Event("input",{bubbles:!0});S.call(h,c),h.dispatchEvent(d)}},[v,c]),e.jsx(Fe.input,{style:{display:"none"},...n,ref:u,defaultValue:c})});ra.displayName=Qa;function Xa(l=[],c,n){const p=[...l];return p[n]=c,p.sort((m,u)=>m-u)}function ia(l,c,n){const u=100/(n-c)*(l-c);return Bs(u,[0,100])}function Za(l,c){return c>2?`Value ${l+1} of ${c}`:c===2?["Minimum","Maximum"][l]:void 0}function et(l,c){if(l.length===1)return 0;const n=l.map(m=>Math.abs(m-c)),p=Math.min(...n);return n.indexOf(p)}function st(l,c,n){const p=l/2,u=rs([0,50],[0,p]);return(p-u(c)*n)*n}function at(l){return l.slice(0,-1).map((c,n)=>l[n+1]-c)}function tt(l,c){if(c>0){const n=at(l);return Math.min(...n)>=c}return!0}function rs(l,c){return n=>{if(l[0]===l[1]||c[0]===c[1])return c[0];const p=(c[1]-c[0])/(l[1]-l[0]);return c[0]+p*(n-l[0])}}function nt(l){return(String(l).split(".")[1]||"").length}function lt(l,c){const n=Math.pow(10,c);return Math.round(l*n)/n}var oa=Xs,rt=ta,it=na,ot=la;const Pe=t.forwardRef(({className:l,...c},n)=>e.jsxs(oa,{ref:n,className:fa("relative flex w-full touch-none select-none items-center",l),...c,children:[e.jsx(rt,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(it,{className:"absolute h-full bg-primary"})}),e.jsx(ot,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));Pe.displayName=oa.displayName;const Is="audio-generator-settings";function Ts(){return e.jsxs("div",{className:"relative h-4 w-4",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-primary/30"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin"}),e.jsx("div",{className:"absolute inset-[3px] rounded-full border border-transparent border-t-primary/60 animate-spin",style:{animationDirection:"reverse",animationDuration:"0.6s"}})]})}const Rs=["English_Trustworth_Man","English_Aussie_Bloke","English_CalmWoman","English_UpsetGirl","English_Gentle-voiced_man","English_Whispering_girl","English_Diligent_Man","English_Graceful_Lady","English_ReservedYoungMan","English_PlayfulGirl","English_ManWithDeepVoice","English_MaturePartner","English_FriendlyPerson","English_MatureBoss","English_Debator","English_LovelyGirl","English_Steadymentor","English_Deep-VoicedGentleman","English_Wiselady","English_CaptivatingStoryteller","English_DecentYoungMan","English_SentimentalLady","English_ImposingManner","English_SadTeen","English_PassionateWarrior","English_WiseScholar","English_Soft-spokenGirl","English_SereneWoman","English_ConfidentWoman","English_PatientMan","English_Comedian","English_BossyLeader","English_Strong-WilledBoy","English_StressedLady","English_AssertiveQueen","English_AnimeCharacter","English_Jovialman","English_WhimsicalGirl","English_Kind-heartedGirl","Chinese (Mandarin)_Reliable_Executive","Chinese (Mandarin)_News_Anchor","Chinese (Mandarin)_Unrestrained_Young_Man","Chinese (Mandarin)_Mature_Woman","Arrogant_Miss","Robot_Armor","Chinese (Mandarin)_Kind-hearted_Antie","Chinese (Mandarin)_Refreshing_Young_Man","Chinese (Mandarin)_HK_Flight_Attendant","Chinese (Mandarin)_Humorous_Elder","Chinese (Mandarin)_Gentleman","Chinese (Mandarin)_Warm_Bestie","Chinese (Mandarin)_Stubborn_Friend","Chinese (Mandarin)_Sweet_Lady","Chinese (Mandarin)_Southern_Young_Man","Chinese (Mandarin)_Wise_Women","Chinese (Mandarin)_Gentle_Youth","Chinese (Mandarin)_Warm_Girl","Chinese (Mandarin)_Male_Announcer","Chinese (Mandarin)_Kind-hearted_Elder","Chinese (Mandarin)_Cute_Spirit","Chinese (Mandarin)_Radio_Host","Chinese (Mandarin)_Lyrical_Voice","Chinese (Mandarin)_Straightforward_Boy","Chinese (Mandarin)_Sincere_Adult","Chinese (Mandarin)_Gentle_Senior","Chinese (Mandarin)_Crisp_Girl","Chinese (Mandarin)_Pure-hearted_Boy","Chinese (Mandarin)_Soft_Girl","Chinese (Mandarin)_IntellectualGirl","Chinese (Mandarin)_Warm_HeartedGirl","Chinese (Mandarin)_Laid_BackGirl","Chinese (Mandarin)_ExplorativeGirl","Chinese (Mandarin)_Warm-HeartedAunt","Chinese (Mandarin)_BashfulGirl","Japanese_IntellectualSenior","Japanese_DecisivePrincess","Japanese_LoyalKnight","Japanese_DominantMan","Japanese_SeriousCommander","Japanese_ColdQueen","Japanese_DependableWoman","Japanese_GentleButler","Japanese_KindLady","Japanese_CalmLady","Japanese_OptimisticYouth","Japanese_GenerousIzakayaOwner","Japanese_SportyStudent","Japanese_InnocentBoy","Japanese_GracefulMaiden","Cantonese_ProfessionalHost(F)","Cantonese_GentleLady","Cantonese_ProfessionalHost(M)","Cantonese_PlayfulMan","Cantonese_CuteGirl","Cantonese_KindWoman","Korean_SweetGirl","Korean_CheerfulBoyfriend","Korean_EnchantingSister","Korean_ShyGirl","Korean_ReliableSister","Korean_StrictBoss","Korean_SassyGirl","Korean_ChildhoodFriendGirl","Korean_PlayboyCharmer","Korean_ElegantPrincess","Korean_BraveFemaleWarrior","Korean_BraveYouth","Korean_CalmLady","Korean_EnthusiasticTeen","Korean_SoothingLady","Korean_IntellectualSenior","Korean_LonelyWarrior","Korean_MatureLady","Korean_InnocentBoy","Korean_CharmingSister","Korean_AthleticStudent","Korean_BraveAdventurer","Korean_CalmGentleman","Korean_WiseElf","Korean_CheerfulCoolJunior","Korean_DecisiveQueen","Korean_ColdYoungMan","Korean_MysteriousGirl","Korean_QuirkyGirl","Korean_ConsiderateSenior","Korean_CheerfulLittleSister","Korean_DominantMan","Korean_AirheadedGirl","Korean_ReliableYouth","Korean_FriendlyBigSister","Korean_GentleBoss","Korean_ColdGirl","Korean_HaughtyLady","Korean_CharmingElderSister","Korean_IntellectualMan","Korean_CaringWoman","Korean_WiseTeacher","Korean_ConfidentBoss","Korean_AthleticGirl","Korean_PossessiveMan","Korean_GentleWoman","Korean_CockyGuy","Korean_ThoughtfulWoman","Korean_OptimisticYouth","Spanish_SereneWoman","Spanish_MaturePartner","Spanish_CaptivatingStoryteller","Spanish_Narrator","Spanish_WiseScholar","Spanish_Kind-heartedGirl","Spanish_DeterminedManager","Spanish_BossyLeader","Spanish_ReservedYoungMan","Spanish_ConfidentWoman","Spanish_ThoughtfulMan","Spanish_Strong-WilledBoy","Spanish_SophisticatedLady","Spanish_RationalMan","Spanish_AnimeCharacter","Spanish_Deep-tonedMan","Spanish_Fussyhostess","Spanish_SincereTeen","Spanish_FrankLady","Spanish_Comedian","Spanish_Debator","Spanish_ToughBoss","Spanish_Wiselady","Spanish_Steadymentor","Spanish_Jovialman","Spanish_SantaClaus","Spanish_Rudolph","Spanish_Intonategirl","Spanish_Arnold","Spanish_Ghost","Spanish_HumorousElder","Spanish_EnergeticBoy","Spanish_WhimsicalGirl","Spanish_StrictBoss","Spanish_ReliableMan","Spanish_SereneElder","Spanish_AngryMan","Spanish_AssertiveQueen","Spanish_CaringGirlfriend","Spanish_PowerfulSoldier","Spanish_PassionateWarrior","Spanish_ChattyGirl","Spanish_RomanticHusband","Spanish_CompellingGirl","Spanish_PowerfulVeteran","Spanish_SensibleManager","Spanish_ThoughtfulLady","Portuguese_SentimentalLady","Portuguese_BossyLeader","Portuguese_Wiselady","Portuguese_Strong-WilledBoy","Portuguese_Deep-VoicedGentleman","Portuguese_UpsetGirl","Portuguese_PassionateWarrior","Portuguese_AnimeCharacter","Portuguese_ConfidentWoman","Portuguese_AngryMan","Portuguese_CaptivatingStoryteller","Portuguese_Godfather","Portuguese_ReservedYoungMan","Portuguese_SmartYoungGirl","Portuguese_Kind-heartedGirl","Portuguese_Pompouslady","Portuguese_Grinch","Portuguese_Debator","Portuguese_SweetGirl","Portuguese_AttractiveGirl","Portuguese_ThoughtfulMan","Portuguese_PlayfulGirl","Portuguese_GorgeousLady","Portuguese_LovelyLady","Portuguese_SereneWoman","Portuguese_SadTeen","Portuguese_MaturePartner","Portuguese_Comedian","Portuguese_NaughtySchoolgirl","Portuguese_Narrator","Portuguese_ToughBoss","Portuguese_Fussyhostess","Portuguese_Dramatist","Portuguese_Steadymentor","Portuguese_Jovialman","Portuguese_CharmingQueen","Portuguese_SantaClaus","Portuguese_Rudolph","Portuguese_Arnold","Portuguese_CharmingSanta","Portuguese_CharmingLady","Portuguese_Ghost","Portuguese_HumorousElder","Portuguese_CalmLeader","Portuguese_GentleTeacher","Portuguese_EnergeticBoy","Portuguese_ReliableMan","Portuguese_SereneElder","Portuguese_GrimReaper","Portuguese_AssertiveQueen","Portuguese_WhimsicalGirl","Portuguese_StressedLady","Portuguese_FriendlyNeighbor","Portuguese_CaringGirlfriend","Portuguese_PowerfulSoldier","Portuguese_FascinatingBoy","Portuguese_RomanticHusband","Portuguese_StrictBoss","Portuguese_InspiringLady","Portuguese_PlayfulSpirit","Portuguese_ElegantGirl","Portuguese_CompellingGirl","Portuguese_PowerfulVeteran","Portuguese_SensibleManager","Portuguese_ThoughtfulLady","Portuguese_TheatricalActor","Portuguese_FragileBoy","Portuguese_ChattyGirl","Portuguese_Conscientiousinstructor","Portuguese_RationalMan","Portuguese_WiseScholar","Portuguese_FrankLady","Portuguese_DeterminedManager","French_Male_Speech_New","French_Female_News Anchor","French_CasualMan","French_MovieLeadFemale","French_FemaleAnchor","French_MaleNarrator","Indonesian_SweetGirl","Indonesian_ReservedYoungMan","Indonesian_CharmingGirl","Indonesian_CalmWoman","Indonesian_ConfidentWoman","Indonesian_CaringMan","Indonesian_BossyLeader","Indonesian_DeterminedBoy","Indonesian_GentleGirl","German_FriendlyMan","German_SweetLady","German_PlayfulMan","Russian_HandsomeChildhoodFriend","Russian_BrightHeroine","Russian_AmbitiousWoman","Russian_ReliableMan","Russian_CrazyQueen","Russian_PessimisticGirl","Russian_AttractiveGuy","Russian_Bad-temperedBoy","Italian_BraveHeroine","Italian_Narrator","Italian_WanderingSorcerer","Italian_DiligentLeader","Dutch_kindhearted_girl","Dutch_bossy_leader","Vietnamese_kindhearted_girl","Arabic_CalmWoman","Arabic_FriendlyGuy","Turkish_CalmWoman","Turkish_Trustworthyman","Ukrainian_CalmWoman"],Ds=[{value:"auto",label:"Auto"},{value:"happy",label:"Happy"},{value:"sad",label:"Sad"},{value:"angry",label:"Angry"},{value:"fearful",label:"Fearful"},{value:"disgusted",label:"Disgusted"},{value:"surprised",label:"Surprised"},{value:"neutral",label:"Neutral"}],Gs=[{value:"English",label:"English"},{value:"Chinese",label:"Chinese"},{value:"Japanese",label:"Japanese"},{value:"Korean",label:"Korean"},{value:"Spanish",label:"Spanish"},{value:"Portuguese",label:"Portuguese"},{value:"French",label:"French"},{value:"Indonesian",label:"Indonesian"},{value:"German",label:"German"},{value:"Russian",label:"Russian"},{value:"Italian",label:"Italian"},{value:"Dutch",label:"Dutch"},{value:"Vietnamese",label:"Vietnamese"},{value:"Arabic",label:"Arabic"},{value:"Turkish",label:"Turkish"},{value:"Ukrainian",label:"Ukrainian"},{value:"Cantonese",label:"Cantonese"}],As=[{value:"mp3",label:"MP3"},{value:"wav",label:"WAV"},{value:"flac",label:"FLAC"}];function ct({open:l,onOpenChange:c,onSave:n}){const m=(()=>{if(typeof window>"u")return null;try{const o=localStorage.getItem(Is);return o?JSON.parse(o):null}catch{return null}})(),[u,v]=t.useState(""),[h,_]=t.useState(m?.voiceId||"English_Trustworth_Man"),[P,S]=t.useState(m?.useCustomVoice||!1),[d,x]=t.useState(m?.customVoiceId||""),[w,T]=t.useState(m?.speed??1),[N,j]=t.useState(m?.pitch??0),[y,V]=t.useState(m?.emotion||"auto"),[E,R]=t.useState(m?.languageBoost||"English"),[q,g]=t.useState(m?.audioFormat||"mp3"),[k,O]=t.useState(null),[L,G]=t.useState(!1),[I,H]=t.useState(!1),[se,b]=t.useState(0),D=t.useRef(null),{toast:Y}=$e();t.useEffect(()=>{const o={voiceId:h,useCustomVoice:P,customVoiceId:d,speed:w,pitch:N,emotion:y,languageBoost:E,audioFormat:q};localStorage.setItem(Is,JSON.stringify(o))},[h,P,d,w,N,y,E,q]),t.useEffect(()=>(L?(b(0),D.current=setInterval(()=>{b(o=>o+1)},1e3)):D.current&&(clearInterval(D.current),D.current=null),()=>{D.current&&clearInterval(D.current)}),[L]);const A=async()=>{if(!u.trim()){Y({title:"Text required",description:"Please enter text to generate audio",variant:"destructive"});return}G(!0),O(null);try{const o=P?d:h,te=new AbortController,i=setTimeout(()=>te.abort(),3e5),M=await fetch(`${ae}/api/v1/resources/generate-audio`,{method:"POST",headers:{"Content-Type":"application/json"},signal:te.signal,body:JSON.stringify({text:u,voice_id:o,speed:w,pitch:N,emotion:y,language_boost:E,audio_format:q})});if(clearTimeout(i),M.status===504||M.status===502||M.status===408)throw new Error("Request timed out. The audio model may be warming up - please try again.");const ee=M.headers.get("content-type");if(!ee||!ee.includes("application/json"))throw new Error("Request timed out or server error. Please try again.");const X=await M.json();if(!M.ok||!X.success){const re=X.error?.message||"Failed to generate audio",de=X.error?.code==="MISSING_API_TOKEN";throw new Error(de?"Replicate API token not configured. Please add it in Settings → Integrations.":re)}O(X.data.audioUrl),Y({title:"Audio generated",description:"Your audio has been generated successfully"})}catch(o){console.error("Generation error:",o);const te=o instanceof Error&&o.name==="AbortError",i=te?"Request timed out after 5 minutes. The model may be overloaded - please try again.":o instanceof Error?o.message:"Failed to generate audio.",M=te||i.toLowerCase().includes("timeout")||i.toLowerCase().includes("timed out");Y({title:M?"Generation timed out":"Generation failed",description:i,variant:"destructive"})}finally{G(!1)}};t.useEffect(()=>{const o=te=>{l&&(te.metaKey||te.ctrlKey)&&te.key==="Enter"&&(te.preventDefault(),u.trim()&&!L&&!I&&A())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l,u,L,I]);const W=async()=>{if(k){H(!0);try{await n(k),v(""),_("English_Trustworth_Man"),S(!1),x(""),T(1),j(0),V("auto"),R("English"),g("mp3"),O(null),c(!1)}catch(o){Y({title:"Save failed",description:o instanceof Error?o.message:"Failed to save audio. Please try again.",variant:"destructive"})}finally{H(!1)}}},Q=()=>{!L&&!I&&c(!1)};return e.jsx(pe,{open:l,onOpenChange:Q,children:e.jsxs(ge,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ve,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(je,{className:"text-base sm:text-lg",children:"Generate Audio"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:L?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(le,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):k?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(fe,{className:"h-16 w-16 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-4 bg-muted/50 flex justify-center",children:e.jsx("audio",{src:k,controls:!0,className:"w-full max-w-[90%]",children:"Your browser does not support the audio tag."})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(fe,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"})]})}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[55vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"text-mobile",className:"text-xs",children:"Text"}),e.jsx(be,{id:"text-mobile",placeholder:"Enter text to convert to speech...",value:u,onChange:o=>v(o.target.value),rows:3,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Voice"}),e.jsxs(B,{value:P?"__custom__":h,onValueChange:o=>{o==="__custom__"?S(!0):(S(!1),_(o))},children:[e.jsx($,{className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsxs(z,{className:"max-h-60",children:[Rs.map(o=>e.jsx(K,{value:o,className:"text-xs",children:o.replace(/_/g," ")},o)),e.jsx(K,{value:"__custom__",className:"text-xs font-medium",children:"Custom Voice ID..."})]})]}),P&&e.jsx(We,{placeholder:"Enter custom voice ID",value:d,onChange:o=>x(o.target.value),className:"h-8 text-xs mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(C,{className:"text-xs",children:["Speed: ",w.toFixed(1),"x"]}),e.jsx(Pe,{value:[w],onValueChange:([o])=>T(o),min:.5,max:2,step:.1,className:"w-full"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(C,{className:"text-xs",children:["Pitch: ",N>0?"+":"",N]}),e.jsx(Pe,{value:[N],onValueChange:([o])=>j(o),min:-12,max:12,step:1,className:"w-full"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Emotion"}),e.jsxs(B,{value:y,onValueChange:V,children:[e.jsx($,{className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Ds.map(o=>e.jsx(K,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Language"}),e.jsxs(B,{value:E,onValueChange:R,children:[e.jsx($,{className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Gs.map(o=>e.jsx(K,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Format"}),e.jsxs(B,{value:q,onValueChange:g,children:[e.jsx($,{className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:As.map(o=>e.jsx(K,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(F,{onClick:A,disabled:!u.trim()||L||I,className:"flex-1 h-9",size:"sm",children:L?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ts,{}),e.jsxs("span",{children:[se,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(ue,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(F,{onClick:W,disabled:!k||L||I,variant:"outline",className:"flex-1 h-9",size:"sm",children:I?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[30%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"text",children:"Text"}),e.jsx(be,{id:"text",placeholder:"Enter text to convert to speech...",value:u,onChange:o=>v(o.target.value),rows:6,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Voice"}),e.jsxs(B,{value:P?"__custom__":h,onValueChange:o=>{o==="__custom__"?S(!0):(S(!1),_(o))},children:[e.jsx($,{children:e.jsx(U,{})}),e.jsxs(z,{className:"max-h-80",children:[Rs.map(o=>e.jsx(K,{value:o,children:o.replace(/_/g," ")},o)),e.jsx(K,{value:"__custom__",className:"font-medium",children:"Custom Voice ID..."})]})]}),P&&e.jsx(We,{placeholder:"Enter custom voice ID",value:d,onChange:o=>x(o.target.value),className:"mt-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Speed: ",w.toFixed(1),"x"]}),e.jsx(Pe,{value:[w],onValueChange:([o])=>T(o),min:.5,max:2,step:.1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0.5x"}),e.jsx("span",{children:"2x"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Pitch: ",N>0?"+":"",N]}),e.jsx(Pe,{value:[N],onValueChange:([o])=>j(o),min:-12,max:12,step:1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"-12"}),e.jsx("span",{children:"+12"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Emotion"}),e.jsxs(B,{value:y,onValueChange:V,children:[e.jsx($,{children:e.jsx(U,{})}),e.jsx(z,{children:Ds.map(o=>e.jsx(K,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Language Boost"}),e.jsxs(B,{value:E,onValueChange:R,children:[e.jsx($,{children:e.jsx(U,{})}),e.jsx(z,{children:Gs.map(o=>e.jsx(K,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Audio Format"}),e.jsxs(B,{value:q,onValueChange:g,children:[e.jsx($,{children:e.jsx(U,{})}),e.jsx(z,{children:As.map(o=>e.jsx(K,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(F,{onClick:A,disabled:!u.trim()||L||I,className:"w-full",children:L?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ts,{}),e.jsxs("span",{children:["Generating... ",se,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(ue,{children:"⌘"}),e.jsx(ue,{children:"↵"})]})}),e.jsx(F,{onClick:W,disabled:!k||L||I,variant:"outline",className:"w-full",children:I?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:L?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(le,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating audio..."})]}):k?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(fe,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/50 flex justify-center",children:e.jsx("audio",{src:k,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(fe,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated audio will appear here"})]})})})]})]})})}const Ls="video-generator-settings";function Ks(){return e.jsxs("div",{className:"relative h-4 w-4",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-primary/30"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin"}),e.jsx("div",{className:"absolute inset-[3px] rounded-full border border-transparent border-t-primary/60 animate-spin",style:{animationDirection:"reverse",animationDuration:"0.6s"}})]})}const Os=[{value:"5",label:"5 seconds"},{value:"8",label:"8 seconds"},{value:"10",label:"10 seconds"}],Vs=[{value:"480p",label:"480p"},{value:"720p",label:"720p"},{value:"1080p",label:"1080p"}],Ws=[{value:"16:9",label:"16:9 (Landscape)"},{value:"9:16",label:"9:16 (Portrait)"},{value:"1:1",label:"1:1 (Square)"}];function dt({open:l,onOpenChange:c,onSave:n}){const m=(()=>{if(typeof window>"u")return null;try{const i=localStorage.getItem(Ls);return i?JSON.parse(i):null}catch{return null}})(),[u,v]=t.useState(""),[h,_]=t.useState(m?.duration||"8"),[P,S]=t.useState(m?.resolution||"720p"),[d,x]=t.useState(m?.aspectRatio||"16:9"),[w,T]=t.useState(m?.generateAudio??!0),[N,j]=t.useState(null),[y,V]=t.useState(null),[E,R]=t.useState(null),[q,g]=t.useState(0),k=t.useRef(null),[O,L]=t.useState(!1),[G,I]=t.useState(!1),[H,se]=t.useState([]),{toast:b}=$e();t.useEffect(()=>{const i={duration:h,resolution:P,aspectRatio:d,generateAudio:w};localStorage.setItem(Ls,JSON.stringify(i))},[h,P,d,w]),t.useEffect(()=>(O?(g(0),k.current=setInterval(()=>{g(i=>i+1)},1e3)):k.current&&(clearInterval(k.current),k.current=null),()=>{k.current&&clearInterval(k.current)}),[O]),t.useEffect(()=>{l&&D()},[l]);const D=async()=>{try{const M=await(await fetch(`${ae}/api/v1/resources`)).json();if(M.success){const ee=(M.data||[]).filter(X=>{const re=X.type==="image/jpeg"||X.name.toLowerCase().endsWith(".jpg")||X.name.toLowerCase().endsWith(".jpeg"),de=X.type==="image/png"||X.name.toLowerCase().endsWith(".png");return(re||de)&&X.thumbnailPath});se(ee)}}catch(i){console.error("Failed to fetch image resources:",i)}},Y=i=>{i===y?V(null):i===N?(j(null),V(i)):N?V(i):j(i)},A=()=>{j(null),V(null)},W=async()=>{if(!u.trim()){b({title:"Prompt required",description:"Please enter a prompt to generate a video",variant:"destructive"});return}L(!0),R(null);try{const i=new AbortController,M=setTimeout(()=>i.abort(),3e5),ee=await fetch(`${ae}/api/v1/resources/generate-video`,{method:"POST",headers:{"Content-Type":"application/json"},signal:i.signal,body:JSON.stringify({prompt:u,image:N||void 0,last_frame:y||void 0,duration:parseInt(h),resolution:P,aspect_ratio:d,generate_audio:w})});if(clearTimeout(M),ee.status===504||ee.status===502||ee.status===408)throw new Error("Request timed out. The video model may be warming up - please try again.");const X=ee.headers.get("content-type");if(!X||!X.includes("application/json"))throw new Error("Request timed out or server error. Please try again.");const re=await ee.json();if(!ee.ok||!re.success){const de=re.error?.message||"Failed to generate video",me=re.error?.code==="MISSING_API_TOKEN";throw new Error(me?"Replicate API token not configured. Please add it in Settings → Integrations.":de)}R(re.data.videoUrl),b({title:"Video generated",description:"Your video has been generated successfully"})}catch(i){console.error("Generation error:",i);const M=i instanceof Error&&i.name==="AbortError",ee=M?"Request timed out after 5 minutes. The model may be overloaded - please try again.":i instanceof Error?i.message:"Failed to generate video.",X=M||ee.toLowerCase().includes("timeout")||ee.toLowerCase().includes("timed out");b({title:X?"Generation timed out":"Generation failed",description:ee,variant:"destructive"})}finally{L(!1)}};t.useEffect(()=>{const i=M=>{l&&(M.metaKey||M.ctrlKey)&&M.key==="Enter"&&(M.preventDefault(),u.trim()&&!O&&!G&&W())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[l,u,O,G]);const Q=async()=>{if(E){I(!0);try{await n(E),v(""),_("8"),S("720p"),x("16:9"),T(!0),j(null),V(null),R(null),c(!1)}catch(i){b({title:"Save failed",description:i instanceof Error?i.message:"Failed to save video. Please try again.",variant:"destructive"})}finally{I(!1)}}},o=()=>{!O&&!G&&c(!1)},te=i=>i===N?"start":i===y?"end":null;return e.jsx(pe,{open:l,onOpenChange:o,children:e.jsxs(ge,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ve,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(je,{className:"text-base sm:text-lg",children:"Generate Video"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:O?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(le,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):E?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:E,controls:!0,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg",children:"Your browser does not support the video tag."})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(Be,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"})]})}),e.jsxs("div",{className:"border-t bg-background p-2 flex-shrink-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2 px-1",children:"Select start and end frames (optional)"}),e.jsxs("div",{className:"flex gap-1.5 overflow-x-auto pb-1",children:[e.jsx("button",{onClick:A,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${!N&&!y?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),H.map(i=>{const M=te(i.id);return e.jsxs("button",{onClick:()=>Y(i.id),className:`relative flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${M?"border-green-500 ring-2 ring-green-500":"border-muted hover:border-muted-foreground/50"}`,children:[e.jsx("img",{src:`${ae}/api/v1/resources/${i.id}/thumbnail`,alt:i.name,className:"w-full h-full object-cover"}),M&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-green-500 text-white text-[10px] font-medium text-center py-0.5",children:M==="start"?"Start":"End"})]},i.id)})]})]}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[40vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"prompt-mobile",className:"text-xs",children:"Prompt"}),e.jsx(be,{id:"prompt-mobile",placeholder:"Describe the video you want to generate...",value:u,onChange:i=>v(i.target.value),rows:2,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Duration"}),e.jsxs(B,{value:h,onValueChange:_,children:[e.jsx($,{className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Os.map(i=>e.jsx(K,{value:i.value,className:"text-xs",children:i.label},i.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Resolution"}),e.jsxs(B,{value:P,onValueChange:S,children:[e.jsx($,{className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Vs.map(i=>e.jsx(K,{value:i.value,className:"text-xs",children:i.label},i.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Ratio"}),e.jsxs(B,{value:d,onValueChange:x,children:[e.jsx($,{className:"h-8 text-xs",children:e.jsx(U,{})}),e.jsx(z,{children:Ws.map(i=>e.jsx(K,{value:i.value,className:"text-xs",children:i.label},i.value))})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"generateAudio-mobile",checked:w,onCheckedChange:i=>T(i===!0)}),e.jsx(C,{htmlFor:"generateAudio-mobile",className:"text-xs cursor-pointer",children:"Generate audio"})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(F,{onClick:W,disabled:!u.trim()||O||G,className:"flex-1 h-9",size:"sm",children:O?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ks,{}),e.jsxs("span",{children:[q,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(ue,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(F,{onClick:Q,disabled:!E||O||G,variant:"outline",className:"flex-1 h-9",size:"sm",children:G?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[22%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"prompt",children:"Prompt"}),e.jsx(be,{id:"prompt",placeholder:"Describe the video you want to generate...",value:u,onChange:i=>v(i.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"duration",children:"Duration"}),e.jsxs(B,{value:h,onValueChange:_,children:[e.jsx($,{id:"duration",children:e.jsx(U,{})}),e.jsx(z,{children:Os.map(i=>e.jsx(K,{value:i.value,children:i.label},i.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(B,{value:P,onValueChange:S,children:[e.jsx($,{id:"resolution",children:e.jsx(U,{})}),e.jsx(z,{children:Vs.map(i=>e.jsx(K,{value:i.value,children:i.label},i.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(B,{value:d,onValueChange:x,children:[e.jsx($,{id:"aspectRatio",children:e.jsx(U,{})}),e.jsx(z,{children:Ws.map(i=>e.jsx(K,{value:i.value,children:i.label},i.value))})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"generateAudio",checked:w,onCheckedChange:i=>T(i===!0)}),e.jsx(C,{htmlFor:"generateAudio",className:"cursor-pointer",children:"Generate audio"})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(F,{onClick:W,disabled:!u.trim()||O||G,className:"w-full",children:O?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ks,{}),e.jsxs("span",{children:["Generating... ",q,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(ue,{children:"⌘"}),e.jsx(ue,{children:"↵"})]})}),e.jsx(F,{onClick:Q,disabled:!E||O||G,variant:"outline",className:"w-full",children:G?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:O?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(le,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating video..."})]}):E?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:E,controls:!0,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg",children:"Your browser does not support the video tag."})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(Be,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated video will appear here"})]})}),e.jsxs("div",{className:"border-t bg-background p-4 flex-shrink-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select start and end frames (optional)"}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto",children:[e.jsx("button",{onClick:A,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${!N&&!y?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),H.map(i=>{const M=te(i.id);return e.jsxs("button",{onClick:()=>Y(i.id),className:`relative flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${M?"border-green-500 ring-2 ring-green-500":"border-muted hover:border-muted-foreground/50"}`,children:[e.jsx("img",{src:`${ae}/api/v1/resources/${i.id}/thumbnail`,alt:i.name,className:"w-full h-full object-cover"}),M&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-green-500 text-white text-xs font-medium text-center py-1",children:M==="start"?"Start":"End"})]},i.id)})]})]})]})]})]})})}function ut({open:l,onOpenChange:c,resource:n,onCopyPath:p,onDownload:m,onNavigate:u,canNavigatePrev:v,canNavigateNext:h}){const[_,P]=t.useState(null),[S,d]=t.useState(!1),[x,w]=t.useState(!1),[T,N]=t.useState(!1);t.useEffect(()=>{w(!1),N(!1)},[n?.id,l]);const j=n?`${ae}/api/v1/resources/${n.id}`:"",y=n?.type.startsWith("image/")??!1,V=n?n.type==="image/svg+xml"||n.name.toLowerCase().endsWith(".svg"):!1,E=n?n.type==="application/pdf"||n.name.toLowerCase().endsWith(".pdf"):!1,R=n?.type.startsWith("video/")??!1,q=n?.type.startsWith("audio/")??!1,g=n?n.type.startsWith("text/")||n.type==="application/json"||n.type.includes("javascript")||n.type.includes("typescript")||n.type.includes("xml")||n.name.toLowerCase().match(/\.(txt|md|json|js|ts|jsx|tsx|css|html|xml|yaml|yml|log|sh|bash|zsh|fish)$/)!==null:!1,k=n?n.name.toLowerCase().endsWith(".md")||n.name.toLowerCase().endsWith(".markdown"):!1,O=n?n.type==="application/json"||n.name.toLowerCase().endsWith(".json"):!1,L=n?n.type==="text/html"||n.name.toLowerCase().endsWith(".html"):!1;if(t.useEffect(()=>{const b=D=>{if(l){if(D.key==="Escape"){x?w(!1):c(!1);return}if(!x){if(D.key==="ArrowLeft"&&v){D.preventDefault(),u("prev");return}D.key==="ArrowRight"&&h&&(D.preventDefault(),u("next"))}}};if(l)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[l,c,u,v,h,x]),t.useEffect(()=>{l&&n&&(g||k||O||L)?(d(!0),fetch(j).then(b=>{if(b.ok)return b.text();throw new Error("Failed to load file")}).then(b=>{P(b)}).catch(b=>{console.error("Failed to load text content:",b),P(null)}).finally(()=>{d(!1)})):P(null)},[l,n?.id,g,k,O,L,j]),!n)return null;const G=b=>{if(b===0)return"0 B";const D=1024,Y=["B","KB","MB","GB"],A=Math.floor(Math.log(b)/Math.log(D));return parseFloat((b/Math.pow(D,A)).toFixed(2))+" "+Y[A]},I=b=>new Date(b).toLocaleString(),H=b=>b.startsWith("image/")?e.jsx(ye,{className:"h-6 w-6"}):b.startsWith("video/")?e.jsx(Be,{className:"h-6 w-6"}):b.startsWith("audio/")?e.jsx(fe,{className:"h-6 w-6"}):b.includes("text")||b.includes("document")||b.includes("code")?e.jsx(Ne,{className:"h-6 w-6"}):b.includes("json")||b.includes("javascript")||b.includes("typescript")?e.jsx(ss,{className:"h-6 w-6"}):e.jsx(es,{className:"h-6 w-6"}),se=()=>{if(V)return e.jsxs(e.Fragment,{children:[e.jsx("img",{src:j,alt:n.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(F,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>w(!0),children:e.jsx(xs,{className:"h-4 w-4"})})]});if(E)return e.jsx("iframe",{src:j,className:"w-full h-full min-h-[600px] rounded-lg border",title:n.name});if(R)return e.jsx("video",{src:j,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",children:"Your browser does not support the video tag."});if(q)return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(fe,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/30 flex justify-center",children:e.jsx("audio",{src:j,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]});if(k&&_!==null)return S?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6 prose prose-sm dark:prose-invert max-w-none",children:e.jsx(ga,{remarkPlugins:[ja],rehypePlugins:[va],children:_})});if(L&&_!==null)return S?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("iframe",{srcDoc:_,className:"w-full h-full min-h-[600px] rounded-lg border",title:n.name,sandbox:"allow-same-origin"});if(O&&_!==null){if(S)return e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})});let b=_;try{const D=JSON.parse(_);b=JSON.stringify(D,null,2)}catch{}return e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto",children:e.jsx("code",{children:b})})})}return g&&_!==null?S?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto whitespace-pre-wrap",children:e.jsx("code",{children:_})})}):y?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:j,alt:n.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(F,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>w(!0),children:e.jsx(xs,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[H(n.type),e.jsx("p",{className:"text-sm",children:"Preview not available for this file type"}),e.jsxs(F,{variant:"outline",onClick:()=>m(n),children:[e.jsx(as,{className:"mr-2 h-4 w-4"}),"Download to view"]})]})};return e.jsxs(e.Fragment,{children:[e.jsx(pe,{open:l,onOpenChange:c,children:e.jsxs(ge,{className:"max-w-[90vw] w-[90vw] max-h-[90vh] h-[90vh] p-0 gap-0 flex flex-col [&>button]:hidden",children:[e.jsx(ve,{className:"px-6 pt-6 pb-4 border-b flex-shrink-0",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[H(n.type),e.jsxs("div",{className:"flex-1 min-w-0 flex items-baseline gap-3",children:[e.jsx(je,{className:"text-xl truncate",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground flex-shrink-0",children:n.type})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/resources/${n.id}`),N(!0),setTimeout(()=>N(!1),2e3)},title:"Copy share link",children:T?e.jsx(Xe,{className:"h-4 w-4"}):e.jsx(Pa,{className:"h-4 w-4"})}),e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>p(n),title:"Copy path to clipboard",children:e.jsx(Ze,{className:"h-4 w-4"})}),e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>m(n),title:"Download",children:e.jsx(as,{className:"h-4 w-4"})}),e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>c(!1),title:"Close",children:e.jsx(cs,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 flex overflow-hidden",children:e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 relative flex items-center justify-center bg-muted/30 p-6 overflow-hidden",children:[v&&e.jsx("button",{type:"button",onClick:()=>u("prev"),className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full border bg-background/80 p-2 shadow-sm hover:bg-background transition-colors","aria-label":"Previous resource",children:e.jsx(zs,{className:"h-5 w-5"})}),h&&e.jsx("button",{type:"button",onClick:()=>u("next"),className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full border bg-background/80 p-2 shadow-sm hover:bg-background transition-colors","aria-label":"Next resource",children:e.jsx($s,{className:"h-5 w-5"})}),se()]}),e.jsx("div",{className:"border-t p-6 flex-shrink-0 bg-background",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 md:grid-cols-2 text-sm",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ea,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsx("span",{children:G(n.size)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pa,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"}),e.jsx("span",{children:I(n.uploadedAt)})]})]}),e.jsx("div",{className:"space-y-2",children:n.metadata.tags&&n.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ma,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:n.metadata.tags.map(b=>e.jsx(Me,{variant:"secondary",className:"text-xs",children:b},b))})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.metadata.description?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Description:"}),e.jsx("span",{className:"truncate flex-1",title:n.metadata.description,children:n.metadata.description})]}):e.jsx("div",{className:"flex-1"}),n.metadata.generationPrompt&&e.jsxs(F,{size:"sm",className:"h-6 text-xs px-2 flex-shrink-0",onClick:()=>{navigator.clipboard.writeText(n.metadata.generationPrompt||"")},children:[e.jsx(Ze,{className:"h-2.5 w-2.5 mr-1"}),"Copy Prompt"]})]})]})})]})})]})}),x&&(y||V)&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black/95 flex items-center justify-center",onClick:()=>w(!1),children:[e.jsx(F,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 h-10 w-10 text-white hover:bg-white/20",onClick:()=>w(!1),children:e.jsx(cs,{className:"h-6 w-6"})}),e.jsx("img",{src:j,alt:n.name,className:"max-w-[95vw] max-h-[95vh] object-contain",onClick:b=>b.stopPropagation()})]})]})}function Ct(){const[l,c]=t.useState([]),[n,p]=t.useState(!0),[m,u]=t.useState(!1),[v,h]=t.useState(""),[_,P]=t.useState(!1),[S,d]=t.useState([]),[x,w]=t.useState(""),[T,N]=t.useState(""),[j,y]=t.useState([]),[V,E]=t.useState(!1),[R,q]=t.useState(!1),[g,k]=t.useState(!1),[O,L]=t.useState(null),[G,I]=t.useState(null),[H,se]=t.useState(null),[b,D]=t.useState(1),Y=12,A=t.useRef(null),{toast:W}=$e();t.useEffect(()=>{Q()},[]);const Q=async()=>{try{p(!0);const r=await(await fetch(`${ae}/api/v1/resources`)).json();r.success&&c(r.data||[])}catch(s){console.error("Failed to fetch resources:",s)}finally{p(!1)}},o=s=>{s.length!==0&&y(Array.from(s))},te=async()=>{if(j.length!==0){u(!0);try{for(const s of j){const r=new FormData;if(r.append("file",s),r.append("tags",S.join(", ")),r.append("description",T),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:r})).ok)throw new Error("Upload failed")}d([]),w(""),N(""),y([]),P(!1),await Q(),W({title:"Upload successful",description:`${j.length} file(s) uploaded successfully`})}catch(s){console.error("Upload failed:",s),W({title:"Upload failed",description:"Failed to upload files. Please try again.",variant:"destructive"})}finally{u(!1)}}},i=()=>{d([]),w(""),N(""),y([]),P(!1)},M=s=>{if(s.key==="Enter"){s.preventDefault();const r=x.trim();r&&!S.includes(r)&&(d([...S,r]),w(""))}},ee=s=>{d(S.filter(r=>r!==s))},X=s=>{y(j.filter((r,f)=>f!==s))},re=async()=>{if(H)try{if((await fetch(`${ae}/api/v1/resources/${H.id}`,{method:"DELETE"})).ok)await Q(),W({title:"Resource deleted",description:`${H.name} has been deleted`});else throw new Error("Delete failed")}catch(s){console.error("Failed to delete resource:",s),W({title:"Delete failed",description:"Failed to delete resource. Please try again.",variant:"destructive"})}finally{se(null)}},de=async s=>{try{const r=`.nut/resources/files/${s.path}`;await ka(r),W({title:"Path copied!",description:`Copied ${r} to clipboard`})}catch(r){console.error("Failed to copy path:",r),W({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},me=s=>{if(s===0)return"0 B";const r=1024,f=["B","KB","MB","GB"],Z=Math.floor(Math.log(s)/Math.log(r));return parseFloat((s/Math.pow(r,Z)).toFixed(2))+" "+f[Z]},Ie=(s,r)=>{const f=r.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||f.endsWith(".svg")?e.jsx(ps,{className:"h-4 w-4"}):e.jsx(ye,{className:"h-4 w-4"}):s.startsWith("video/")?e.jsx(vs,{className:"h-4 w-4"}):s.startsWith("audio/")?e.jsx(fs,{className:"h-4 w-4"}):s==="application/pdf"||f.endsWith(".pdf")?e.jsx(Ne,{className:"h-4 w-4"}):f.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx(ss,{className:"h-4 w-4"}):s==="application/json"||f.endsWith(".json")?e.jsx(gs,{className:"h-4 w-4"}):s.includes("spreadsheet")||s.includes("excel")||f.match(/\.(xls|xlsx|csv)$/)?e.jsx(js,{className:"h-4 w-4"}):s.includes("presentation")||s.includes("powerpoint")||f.match(/\.(ppt|pptx)$/)?e.jsx(ws,{className:"h-4 w-4"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(Ne,{className:"h-4 w-4"}):s.includes("font")||f.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(bs,{className:"h-4 w-4"}):e.jsx(es,{className:"h-4 w-4"})},Te=(s,r)=>{const f=r.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||f.endsWith(".svg")?e.jsx(ps,{className:"h-16 w-16"}):e.jsx(ye,{className:"h-16 w-16"}):s.startsWith("video/")?e.jsx(vs,{className:"h-16 w-16"}):s.startsWith("audio/")?e.jsx(fs,{className:"h-16 w-16"}):s==="application/pdf"||f.endsWith(".pdf")?e.jsx(Ne,{className:"h-16 w-16"}):f.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx(ss,{className:"h-16 w-16"}):s==="application/json"||f.endsWith(".json")?e.jsx(gs,{className:"h-16 w-16"}):s.includes("spreadsheet")||s.includes("excel")||f.match(/\.(xls|xlsx|csv)$/)?e.jsx(js,{className:"h-16 w-16"}):s.includes("presentation")||s.includes("powerpoint")||f.match(/\.(ppt|pptx)$/)?e.jsx(ws,{className:"h-16 w-16"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(Ne,{className:"h-16 w-16"}):s.includes("font")||f.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(bs,{className:"h-16 w-16"}):e.jsx(es,{className:"h-16 w-16"})},he=s=>{const r=s.name.toLowerCase(),f=s.type.startsWith("image/");return s.type==="image/svg+xml"||r.endsWith(".svg")?e.jsx("div",{className:"w-full h-32 flex items-center justify-center bg-muted/30 rounded-md border overflow-hidden p-2",children:e.jsx("img",{src:`${ae}/api/v1/resources/${s.id}`,alt:s.name,className:"w-full h-full object-contain"})}):f&&s.thumbnailPath?e.jsx("img",{src:`${ae}/api/v1/resources/${s.id}/thumbnail`,alt:s.name,className:"w-full h-32 object-cover rounded-md border",onError:ne=>{ne.currentTarget.style.display="none"}}):e.jsx("div",{className:"w-full h-32 flex items-center justify-center bg-muted/50 rounded-md border",children:e.jsx("div",{className:"text-muted-foreground",children:Te(s.type,s.name)})})},ie=l.filter(s=>{if(!v)return!0;const r=v.toLowerCase();return s.name.toLowerCase().includes(r)||s.metadata.description?.toLowerCase().includes(r)||s.metadata.tags?.some(f=>f.toLowerCase().includes(r))}),J=Math.ceil(ie.length/Y),Ce=(b-1)*Y,Re=ie.slice(Ce,Ce+Y);t.useEffect(()=>{D(1)},[v]);const ze=s=>{s.preventDefault(),s.stopPropagation()},ke=s=>{s.preventDefault(),s.stopPropagation(),s.dataTransfer.files&&s.dataTransfer.files.length>0&&o(s.dataTransfer.files)},De=(s,r)=>{if(r.target.closest("button"))return;L(s);const Z=ie.findIndex(ne=>ne.id===s.id);I(Z>=0?Z:null)},Ge=s=>{window.open(`${ae}/api/v1/resources/${s.id}?download=true`)},Ae=async(s,r)=>{u(!0);try{const f=await fetch(s);if(!f.ok)throw new Error("Failed to download generated image");const Z=await f.blob(),ne=`generated-image-${Date.now()}.png`,ce=new FormData;ce.append("file",Z,ne),ce.append("tags",S.join(","));const oe=r?.prompt?`Generated with: "${r.prompt}"${r.model?` (${r.model})`:""}`:T;if(ce.append("description",oe),r?.prompt&&ce.append("generationPrompt",r.prompt),r?.model&&ce.append("generationModel",r.model),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:ce})).ok)throw new Error("Upload failed");await Q(),W({title:"Image saved",description:"Generated image has been saved to resources"})}catch(f){throw console.error("Failed to save generated image:",f),W({title:"Save failed",description:f instanceof Error?f.message:"Failed to save generated image",variant:"destructive"}),f}finally{u(!1)}},Le=s=>{window.dispatchEvent(new CustomEvent("customize-prompt-in-assistant",{detail:{prompt:s}}))},qe=async s=>{u(!0);try{const r=await fetch(s);if(!r.ok)throw new Error("Failed to download generated audio");const f=await r.blob();let Z="mp3";const ne=r.headers.get("content-type");ne?.includes("wav")?Z="wav":ne?.includes("flac")?Z="flac":s.includes(".wav")?Z="wav":s.includes(".flac")&&(Z="flac");const ce=`generated-audio-${Date.now()}.${Z}`,oe=new FormData;if(oe.append("file",f,ce),oe.append("tags",S.join(",")),oe.append("description",T),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:oe})).ok)throw new Error("Upload failed");await Q(),W({title:"Audio saved",description:"Generated audio has been saved to resources"})}catch(r){throw console.error("Failed to save generated audio:",r),W({title:"Save failed",description:r instanceof Error?r.message:"Failed to save generated audio",variant:"destructive"}),r}finally{u(!1)}},He=async s=>{u(!0);try{const r=await fetch(s);if(!r.ok)throw new Error("Failed to download generated video");const f=await r.blob();let Z="mp4";(r.headers.get("content-type")?.includes("webm")||s.includes(".webm"))&&(Z="webm");const ce=`generated-video-${Date.now()}.${Z}`,oe=new FormData;if(oe.append("file",f,ce),oe.append("tags",S.join(",")),oe.append("description",T),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:oe})).ok)throw new Error("Upload failed");await Q(),W({title:"Video saved",description:"Generated video has been saved to resources"})}catch(r){throw console.error("Failed to save generated video:",r),W({title:"Save failed",description:r instanceof Error?r.message:"Failed to save generated video",variant:"destructive"}),r}finally{u(!1)}},a=s=>{if(G===null)return;const r=s==="next"?G+1:G-1;if(r<0||r>=ie.length)return;const f=ie[r];I(r),L(f)};return 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-2xl font-bold tracking-tight",children:"Resources"}),e.jsx("p",{className:"text-muted-foreground",children:"Upload and generate media assets for your project"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(ba,{children:[e.jsx(wa,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",children:[e.jsx(Ee,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Generate"}),e.jsx(Na,{className:"h-3 w-3 ml-1 opacity-50"})]})}),e.jsxs(ya,{align:"end",className:"min-w-[var(--radix-dropdown-menu-trigger-width)]",children:[e.jsxs(Je,{onClick:()=>E(!0),children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),"Image"]}),e.jsxs(Je,{onClick:()=>q(!0),children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Audio"]}),e.jsxs(Je,{onClick:()=>k(!0),children:[e.jsx(Be,{className:"h-4 w-4 mr-2"}),"Video"]})]})]}),e.jsxs(F,{size:"sm",onClick:()=>P(!_),children:[e.jsx(ds,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Upload Resources"})]})]})]}),e.jsx(pe,{open:_,onOpenChange:s=>!s&&i(),children:e.jsxs(ge,{className:"max-w-2xl",children:[e.jsxs(ve,{children:[e.jsx(je,{children:"Upload Resource"}),e.jsx(us,{children:"Add files to your project resources"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-muted-foreground/50 transition-colors",onDragOver:ze,onDrop:ke,onClick:()=>A.current?.click(),children:[e.jsx(Oa,{className:"mx-auto h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"mt-2 text-sm font-medium",children:"Drop files here or click to browse"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Support for images, documents, and other files"})]}),e.jsx("input",{ref:A,type:"file",multiple:!0,className:"hidden",onChange:s=>s.target.files&&o(s.target.files)}),j.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Selected Files (",j.length,")"]}),e.jsx("div",{className:"border rounded-lg p-3 max-h-40 overflow-y-auto space-y-2",children:j.map((s,r)=>e.jsxs("div",{className:"flex items-center justify-between text-sm bg-muted/50 rounded px-3 py-2",children:[e.jsx("span",{className:"truncate flex-1",children:s.name}),e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>X(r),className:"h-6 w-6 p-0 ml-2",children:e.jsx(ms,{className:"h-3 w-3"})})]},r))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"tags",children:"Tags"}),e.jsx(We,{id:"tags",placeholder:"Type a tag and press Enter",value:x,onChange:s=>w(s.target.value),onKeyDown:M}),S.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:S.map(s=>e.jsxs(Me,{variant:"secondary",className:"text-xs",children:[s,e.jsx("button",{type:"button",onClick:()=>ee(s),className:"ml-1 hover:text-destructive",children:"×"})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"description",children:"Description"}),e.jsx(be,{id:"description",placeholder:"Brief description of this resource...",value:T,onChange:s=>N(s.target.value),rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(F,{variant:"outline",onClick:i,disabled:m,children:"Cancel"}),e.jsx(F,{onClick:te,disabled:j.length===0||m,children:m?"Uploading...":`Upload ${j.length>0?`(${j.length})`:""}`})]})]})]})}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs("div",{className:"relative flex-1 w-full",children:[e.jsx(Fa,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(We,{placeholder:"Search resources...",value:v,onChange:s=>h(s.target.value),className:"pl-8"})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:n?Array.from({length:6}).map((s,r)=>e.jsxs(Ye,{className:"animate-pulse",children:[e.jsxs(hs,{children:[e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]}),e.jsx(Qe,{children:e.jsx("div",{className:"h-20 bg-muted rounded"})})]},r)):ie.length>0?Re.map(s=>e.jsxs(Ye,{className:"hover:shadow-lg hover:bg-muted transition-all cursor-pointer",onClick:r=>De(s,r),children:[e.jsxs(hs,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[Ie(s.type,s.name),e.jsx(Sa,{className:"text-sm font-medium truncate",children:s.name})]}),e.jsxs(Ca,{className:"text-xs",children:[me(s.size)," • ",new Date(s.uploadedAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex justify-end space-x-1 mt-2",children:[e.jsx(F,{variant:"ghost",size:"sm",onClick:r=>{r.stopPropagation(),de(s)},title:"Copy path to clipboard",children:e.jsx(Ze,{className:"h-3 w-3"})}),e.jsx(F,{variant:"ghost",size:"sm",onClick:r=>{r.stopPropagation(),Ge(s)},children:e.jsx(as,{className:"h-3 w-3"})}),e.jsx(F,{variant:"ghost",size:"sm",onClick:r=>{r.stopPropagation(),se(s)},children:e.jsx(ms,{className:"h-3 w-3"})})]})]}),e.jsxs(Qe,{className:"pt-0",children:[e.jsx("div",{className:"mb-3",children:he(s)}),s.metadata.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:s.metadata.description}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map(r=>e.jsx(Me,{variant:"secondary",className:"text-xs",children:r},r))})]})]},s.id)):e.jsx("div",{className:"col-span-full",children:e.jsx(Ye,{children:e.jsxs(Qe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(_a,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No resources yet"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground text-center max-w-sm",children:"Upload files to get started. Resources can be referenced by LLMs and team members for enhanced context."}),e.jsxs(F,{className:"mt-4",onClick:()=>P(!0),children:[e.jsx(ds,{className:"mr-2 h-4 w-4"}),"Add First Resource"]})]})})})}),ie.length>Y&&e.jsxs("div",{className:"flex items-center justify-center gap-4 pt-4 pb-8",children:[e.jsxs(F,{variant:b===1?"outline":"default",size:"sm",onClick:()=>D(s=>Math.max(1,s-1)),disabled:b===1,children:[e.jsx(zs,{className:"h-4 w-4 mr-1"}),"Previous"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",b," of ",J]}),e.jsxs(F,{variant:b===J?"outline":"default",size:"sm",onClick:()=>D(s=>Math.min(J,s+1)),disabled:b===J,children:["Next",e.jsx($s,{className:"h-4 w-4 ml-1"})]})]}),m&&e.jsx("div",{className:"fixed bottom-4 right-4 bg-background border rounded-lg shadow-lg p-4",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),e.jsx("span",{className:"text-sm",children:"Uploading files..."})]})}),e.jsx($a,{open:V,onOpenChange:E,onSave:Ae,onCustomizeInAssistant:Le}),e.jsx(ct,{open:R,onOpenChange:q,onSave:qe}),e.jsx(dt,{open:g,onOpenChange:k,onSave:He}),e.jsx(ut,{open:!!O,onOpenChange:s=>{s||L(null),s||I(null)},resource:O,onCopyPath:de,onDownload:Ge,onNavigate:a,canNavigatePrev:G!==null&&G>0,canNavigateNext:G!==null&&G<ie.length-1}),e.jsx(pe,{open:!!H,onOpenChange:s=>!s&&se(null),children:e.jsxs(ge,{className:"max-w-md",children:[e.jsxs(ve,{children:[e.jsx(je,{children:"Delete Resource"}),e.jsxs(us,{children:["Are you sure you want to delete ",e.jsx("strong",{children:H?.name}),"? This action cannot be undone."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(F,{variant:"outline",onClick:()=>se(null),children:"Cancel"}),e.jsx(F,{variant:"destructive",onClick:re,children:"Delete"})]})]})})]})}export{Ct as default};
@@ -1,13 +0,0 @@
1
- import{u as N,a as E,r as s,A as o,j as e,B as v,L as R,a0 as D}from"./index-CIFIEidO.js";import{C as y,a as S,b as A,c as L}from"./card-_Grh-Otl.js";import{L as P}from"./label-B1lgxULu.js";import{S as z,a as I,b as q,c as T,d as M}from"./select-Dp3J_OE9.js";import{M as O}from"./markdown-editor-C-DC0mFI.js";import{A as B}from"./arrow-left-PEX5RePT.js";import{C as F}from"./circle-check-big-BaFefwt0.js";import"./chevron-up-BM1GKhAV.js";const d=[{id:"software-engineer",title:"Software Engineer",description:"Builds, refactors, and reviews high-quality code across stacks. Excellent at translating specs into implementation and optimizing system performance. Strong at debugging, architecture patterns, and accelerating development velocity."},{id:"product-strategist",title:"Product Strategist",description:"Defines product direction, clarifies requirements, and aligns work with user and business goals. Skilled in roadmap planning, prioritization, and transforming ambiguous ideas into actionable plans."},{id:"researcher",title:"Researcher",description:"Investigates topics deeply, synthesizes information, and produces evidence-based insights. Strong at literature review, competitive analysis, and generating clear summaries to inform decisions."},{id:"designer",title:"Designer",description:"Creates intuitive interfaces, user flows, and visual assets. Focused on usability, accessibility, and crafting polished experiences. Strong at wireframing and turning requirements into elegant solutions."},{id:"qa-engineer",title:"QA Engineer",description:"Identifies bugs, edge cases, and reliability gaps. Produces test plans, automated tests, and reproducible reports. Strong at ensuring product quality and preventing regressions."},{id:"devops-engineer",title:"DevOps Engineer",description:"Manages infrastructure, deployments, and operational reliability. Skilled with CI/CD, observability, automation, and environment provisioning. Ensures systems are scalable and fault-tolerant."},{id:"data-analyst",title:"Data Analyst",description:"Analyzes data, defines metrics, and generates actionable insights. Strong in SQL, visualization, experimentation, and turning raw data into strategic recommendations."},{id:"marketer",title:"Marketer",description:"Creates campaigns, messaging, and positioning to reach target audiences. Skilled in content, funnels, and brand strategy. Strong at synthesizing market needs and shaping demand."},{id:"sales-partnerships-agent",title:"Sales & Partnerships Agent",description:"Identifies prospects, crafts outreach, and develops strategic relationships. Strong at value articulation, objection handling, and mapping product capabilities to customer needs."},{id:"growth-operator",title:"Growth Operator",description:"Optimizes acquisition, activation, and retention through experimentation. Skilled in funnel analysis, rapid testing, and leveraging data for compounding growth."},{id:"customer-success-specialist",title:"Customer Success Specialist",description:"Ensures users succeed by providing onboarding, guidance, and proactive support. Strong at diagnosing user challenges and improving long-term satisfaction and retention."},{id:"orchestration-engineer",title:"Orchestration Engineer",description:"Coordinates multi-agent workflows, dependencies, and handoffs. Strong at breaking large tasks into sequenced steps and ensuring agents operate cohesively and efficiently."},{id:"context-curator",title:"Context Curator",description:"Maintains clean, accurate project context by organizing files, logs, and knowledge. Strong at eliminating ambiguity, ensuring agents have the right information at the right time."},{id:"documentation-writer",title:"Documentation Writer",description:"Produces clear technical docs, guides, READMEs, and CP summaries. Strong at structuring complex information and keeping knowledge bases up to date and accessible."}];function H(){const j=N(),{toast:a}=E(),[l,c]=s.useState(""),[r,g]=s.useState(""),[b,u]=s.useState(!0),[p,m]=s.useState(!1),h=s.useRef(!1),w=t=>{if(g(t),!h.current)return;const i=d.find(n=>n.id===t);i?.description&&c(i.description)};s.useEffect(()=>{Promise.all([fetch(`${o}/api/v1/context/role`).then(t=>t.json()),fetch(`${o}/api/v1/config`).then(t=>t.json())]).then(([t,i])=>{if(t.success&&c(t.document.content.trim()),i?.success){const n=i.data?.coconut?.role;n&&g(n)}h.current=!0,u(!1)}).catch(t=>{console.error("Failed to load context:",t),a({title:"Error",description:"Failed to load role definition",variant:"destructive"}),u(!1)})},[a]);const C=async()=>{m(!0);try{const t=r?d.find(k=>k.id===r)?.description:void 0,[i,n]=await Promise.all([fetch(`${o}/api/v1/context/role`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:l,metadata:{}})}),fetch(`${o}/api/v1/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconut:{role:r||void 0,roleDescription:t}})})]),f=await i.json(),x=await n.json();if(f.success&&x.success)a({title:"Success",description:"Role definition saved successfully",action:e.jsx(F,{className:"h-4 w-4"})}),j("/context/role");else throw new Error(f.error||x.error||"Failed to save")}catch(t){console.error("Save error:",t),a({title:"Error",description:"Failed to save role definition",variant:"destructive"})}finally{m(!1)}};return b?e.jsx("div",{className:"space-y-6",children:e.jsx(y,{children:e.jsx(S,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Role Definition"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Define your role, responsibilities, and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(v,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(R,{to:"/context/role",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(B,{className:"w-4 h-4"})})}),e.jsxs(v,{onClick:C,disabled:p,size:"sm",children:[e.jsx(D,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Saving...":"Save"})]})]})]}),e.jsxs(y,{children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(L,{children:"Role Documentation"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"text-sm text-muted-foreground",children:"Role:"}),e.jsxs(z,{value:r,onValueChange:w,children:[e.jsx(I,{className:"w-48",children:e.jsx(q,{placeholder:"Select role"})}),e.jsx(T,{children:d.map(t=>e.jsx(M,{value:t.id,children:t.title},t.id))})]})]})]})}),e.jsx(S,{children:e.jsx(O,{value:l,onChange:t=>c(t||""),placeholder:`Write your role definition in markdown...
2
-
3
- ## Your Role
4
-
5
- Describe your role and primary responsibilities.
6
-
7
- ## Guidelines
8
-
9
- Key guidelines and principles to follow.
10
-
11
- ## Constraints
12
-
13
- Any constraints or boundaries to be aware of.`,height:800})})]})]})}export{H as default};