@lovelybunch/api 1.0.75-alpha.8 → 1.0.75

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 (188) hide show
  1. package/dist/lib/jobs/job-runner.js +10 -2
  2. package/dist/lib/jobs/job-scheduler.js +21 -0
  3. package/dist/lib/mail/mail-runner.d.ts +51 -0
  4. package/dist/lib/mail/mail-runner.js +342 -0
  5. package/dist/lib/slack/slack-service.d.ts +2 -0
  6. package/dist/lib/slack/slack-service.js +3 -0
  7. package/dist/lib/storage/file-storage.d.ts +16 -16
  8. package/dist/lib/storage/file-storage.js +59 -64
  9. package/dist/lib/terminal/terminal-manager.d.ts +3 -5
  10. package/dist/lib/terminal/terminal-manager.js +10 -61
  11. package/dist/routes/api/v1/ai/route.js +361 -20
  12. package/dist/routes/api/v1/chats/[id]/index.js +2 -1
  13. package/dist/routes/api/v1/chats/[id]/route.d.ts +7 -0
  14. package/dist/routes/api/v1/chats/[id]/route.js +30 -1
  15. package/dist/routes/api/v1/context/index.js +0 -2
  16. package/dist/routes/api/v1/git/index.js +23 -0
  17. package/dist/routes/api/v1/knowledge/[filename]/index.d.ts +1 -0
  18. package/dist/routes/api/v1/knowledge/[filename]/index.js +1 -0
  19. package/dist/routes/api/v1/knowledge/[filename]/route.d.ts +3 -0
  20. package/dist/routes/api/v1/knowledge/[filename]/route.js +254 -0
  21. package/dist/routes/api/v1/knowledge/index.d.ts +1 -0
  22. package/dist/routes/api/v1/knowledge/index.js +1 -0
  23. package/dist/routes/api/v1/knowledge/route.d.ts +3 -0
  24. package/dist/routes/api/v1/knowledge/route.js +176 -0
  25. package/dist/routes/api/v1/mail/index.d.ts +3 -0
  26. package/dist/routes/api/v1/mail/index.js +23 -0
  27. package/dist/routes/api/v1/mail/route.d.ts +294 -0
  28. package/dist/routes/api/v1/mail/route.js +344 -0
  29. package/dist/routes/api/v1/mcp/index.js +109 -34
  30. package/dist/routes/api/v1/slack/index.d.ts +3 -0
  31. package/dist/routes/api/v1/slack/index.js +15 -0
  32. package/dist/routes/api/v1/slack/route.d.ts +124 -0
  33. package/dist/routes/api/v1/slack/route.js +192 -0
  34. package/dist/routes/api/v1/tasks/[id]/route.d.ts +117 -0
  35. package/dist/routes/api/v1/tasks/[id]/route.js +166 -0
  36. package/dist/routes/api/v1/tasks/index.d.ts +3 -0
  37. package/dist/routes/api/v1/tasks/index.js +10 -0
  38. package/dist/routes/api/v1/tasks/route.d.ts +96 -0
  39. package/dist/routes/api/v1/tasks/route.js +136 -0
  40. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +2 -2
  41. package/dist/routes/api/v1/terminal/[taskId]/create/index.d.ts +3 -0
  42. package/dist/routes/api/v1/terminal/[taskId]/create/index.js +5 -0
  43. package/dist/routes/api/v1/terminal/[taskId]/create/route.d.ts +10 -0
  44. package/dist/routes/api/v1/terminal/[taskId]/create/route.js +27 -0
  45. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.d.ts +3 -0
  46. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.js +5 -0
  47. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.d.ts +10 -0
  48. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.js +21 -0
  49. package/dist/routes/api/v1/terminal/[taskId]/resize/index.d.ts +3 -0
  50. package/dist/routes/api/v1/terminal/[taskId]/resize/index.js +5 -0
  51. package/dist/routes/api/v1/terminal/[taskId]/resize/route.d.ts +10 -0
  52. package/dist/routes/api/v1/terminal/[taskId]/resize/route.js +21 -0
  53. package/dist/routes/api/v1/terminal/sessions/route.js +4 -4
  54. package/dist/server-with-static.js +14 -8
  55. package/dist/server.js +14 -8
  56. package/package.json +4 -4
  57. package/static/assets/{ActivityPage-DSSML9J-.js → ActivityPage-k4I7Q53O.js} +1 -1
  58. package/static/assets/ApiKeysSettingsPage-B1YvVdmg.js +2 -0
  59. package/static/assets/{ArchitectureEditPage-CIjqkpMz.js → ArchitectureEditPage-CpowsIx2.js} +1 -1
  60. package/static/assets/{ArchitecturePage-Db__w054.js → ArchitecturePage-DYxC_aMR.js} +1 -1
  61. package/static/assets/{AuthSettingsPage-Bpooi8Z0.js → AuthSettingsPage-DtSo78Y_.js} +2 -2
  62. package/static/assets/{CallbackPage-BGLKeyjv.js → CallbackPage-bROCGapx.js} +1 -1
  63. package/static/assets/CodePage-CPCj64rX.js +2 -0
  64. package/static/assets/{CollapsibleSection-B6RO5o5R.js → CollapsibleSection-M5cXbl92.js} +1 -1
  65. package/static/assets/DashboardPage-B9BZZfw6.js +51 -0
  66. package/static/assets/{GitPage-DxjLaRWe.js → GitPage-BiDtdSK1.js} +2 -2
  67. package/static/assets/GitSettingsPage-THm6wDjs.js +6 -0
  68. package/static/assets/IdentityPage-BC16skg6.js +6 -0
  69. package/static/assets/{ImplementationStepsEditor-DWjDyZzP.js → ImplementationStepsEditor-HliLQav5.js} +2 -2
  70. package/static/assets/IntegrationsSettingsPage-CC_VKIQa.js +1 -0
  71. package/static/assets/JobDetailPage-z1QQYvmU.js +1 -0
  72. package/static/assets/KnowledgeDetailPage-DzHXBS7Q.js +1 -0
  73. package/static/assets/KnowledgeEditPage-BwGnUH_m.js +1 -0
  74. package/static/assets/KnowledgePage-CGIVMS02.js +3 -0
  75. package/static/assets/{LoginPage-DptfKsWo.js → LoginPage-VQ3lcfLV.js} +1 -1
  76. package/static/assets/MailInboxPage-DiZKqwdU.js +1 -0
  77. package/static/assets/MailProcessingModal-DIeSQBoR.js +6 -0
  78. package/static/assets/MailReadPage-C8AACmZQ.js +1 -0
  79. package/static/assets/MailSentPage-C_5yFly_.js +1 -0
  80. package/static/assets/McpSettingsPage-i9YHcu1s.js +1 -0
  81. package/static/assets/NewKnowledgePage-BnVY7WUD.js +9 -0
  82. package/static/assets/{NewSkillPage-Cwy2MSr9.js → NewSkillPage-DwniHD6D.js} +1 -1
  83. package/static/assets/NewTaskPage-F5UX2WMc.js +90 -0
  84. package/static/assets/NotFoundPage-BbSZX_4L.js +6 -0
  85. package/static/assets/NotificationsSettingsPage-C8kjcift.js +1 -0
  86. package/static/assets/ProjectEditPage-DUUlIEqI.js +11 -0
  87. package/static/assets/{ProjectPage-DgUr4bVU.js → ProjectPage-Unz9PQpA.js} +1 -1
  88. package/static/assets/PromptsSettingsPage-DVpIuRKI.js +1 -0
  89. package/static/assets/ResourceDetailPage-DqHZ2KYD.js +1 -0
  90. package/static/assets/ResourcesPage-BP5tuAi-.js +41 -0
  91. package/static/assets/RoleEditPage-BgKu8S0-.js +13 -0
  92. package/static/assets/{RolePage-Sc-GFiL2.js → RolePage-Fed52Ov5.js} +1 -1
  93. package/static/assets/{RulesSettingsPage-DdMCzh9j.js → RulesSettingsPage-BQ2O0u66.js} +2 -2
  94. package/static/assets/SchedulePage-jkxjuzBx.js +4 -0
  95. package/static/assets/SkillDetailPage-k3Q2-NFd.js +1 -0
  96. package/static/assets/{SkillEditPage-BDd2CtAS.js → SkillEditPage-urF4snjo.js} +1 -1
  97. package/static/assets/SkillsPage-DlWDhEjR.js +8 -0
  98. package/static/assets/{SkillsSettingsPage-1N0JQOYc.js → SkillsSettingsPage-BViFgckG.js} +1 -1
  99. package/static/assets/SourceInput-CAFKTHw-.js +1 -0
  100. package/static/assets/{TagInput-D_SdcypZ.js → TagInput-C6lI-ePr.js} +1 -1
  101. package/static/assets/TaskDetailPage-DpbRHnW_.js +16 -0
  102. package/static/assets/TaskEditPage-DssRbW0h.js +1 -0
  103. package/static/assets/TasksPage-CD_eo0Bj.js +17 -0
  104. package/static/assets/TerminalPage-BG_wlccr.js +1 -0
  105. package/static/assets/TerminalSessionPage-CsK-LznK.js +8 -0
  106. package/static/assets/UserPreferencesPage-CWUq3efu.js +1 -0
  107. package/static/assets/UserSettingsPage-CduI_MGS.js +1 -0
  108. package/static/assets/UtilitiesPage-BAxokhLh.js +1 -0
  109. package/static/assets/{alert-BD5jo3SI.js → alert-BXsc6_qu.js} +1 -1
  110. package/static/assets/{arrow-down-BxcoVp6S.js → arrow-down-DmW_3gE8.js} +1 -1
  111. package/static/assets/{arrow-left-CdM_IPng.js → arrow-left-1S-835kP.js} +1 -1
  112. package/static/assets/{arrow-up-BOJ6ob9X.js → arrow-up-BYism_o1.js} +1 -1
  113. package/static/assets/arrow-up-down-Dw3J0a4i.js +6 -0
  114. package/static/assets/{badge-DEiQk9C9.js → badge-BUEY53dV.js} +1 -1
  115. package/static/assets/{browser-modal-Dp1eMxt6.js → browser-modal-DCNdI4NT.js} +2 -2
  116. package/static/assets/{card-BCFxXzRk.js → card-BcPlIAH5.js} +1 -1
  117. package/static/assets/{chevron-left-C25izNzZ.js → chevron-left-FMmNe7yP.js} +1 -1
  118. package/static/assets/{plus-iamYJu5V.js → chevron-up-CqM3won3.js} +2 -2
  119. package/static/assets/{chevrons-up-DqbWMOjv.js → chevrons-up-DTvCkIHc.js} +1 -1
  120. package/static/assets/{circle-alert-CMRMPnbY.js → circle-alert-dseM-Ib7.js} +1 -1
  121. package/static/assets/{circle-check-big-NI18oHuP.js → circle-check-big-jKg34xC-.js} +1 -1
  122. package/static/assets/{circle-check-D5wZZPvj.js → circle-check-eyo6pBP1.js} +1 -1
  123. package/static/assets/{circle-play-BhVU869u.js → circle-play-BrY_lNiH.js} +1 -1
  124. package/static/assets/{circle-x-BXDB-G_q.js → circle-x-uqmzEce1.js} +1 -1
  125. package/static/assets/{clipboard-DC2xmNVx.js → clipboard-tzPFoieb.js} +1 -1
  126. package/static/assets/{clock-CeCp7Pz1.js → clock-Bjc06QBM.js} +1 -1
  127. package/static/assets/code-DrYqPukx.js +6 -0
  128. package/static/assets/{download-ZF_XbTIA.js → download-Bg__QCLT.js} +1 -1
  129. package/static/assets/{external-link-CYBz87-P.js → external-link-CNDy2UUo.js} +1 -1
  130. package/static/assets/{eye-BT8MAvKY.js → eye-DLFBnC8t.js} +1 -1
  131. package/static/assets/{folder-git-2-BE9AIPnj.js → folder-git-2-DUqd0WRi.js} +1 -1
  132. package/static/assets/index-CHdBxVyk.css +2 -0
  133. package/static/assets/index-DFcWlnzl.js +487 -0
  134. package/static/assets/{info-DunFSp-x.js → info-D6jxZC5X.js} +1 -1
  135. package/static/assets/kiro-CX1mOsRO.js +17 -0
  136. package/static/assets/{label-vYhfrPMD.js → label-DBuh-ke5.js} +1 -1
  137. package/static/assets/{markdown-editor-BzZ8tCto.js → markdown-editor-B4YNQFT2.js} +1 -1
  138. package/static/assets/message-square-B5RWz_ff.js +6 -0
  139. package/static/assets/paperclip-4A_3MaPx.js +6 -0
  140. package/static/assets/{pause-BHonpdnw.js → pause-BzhKXHtR.js} +1 -1
  141. package/static/assets/{play-CCo7tau2.js → play-CHIf-Rcz.js} +1 -1
  142. package/static/assets/{radio-group-Db-pBuyW.js → radio-group-C1ct-VsJ.js} +1 -1
  143. package/static/assets/{refresh-cw-Bg7vQzOw.js → refresh-cw-B3OwrDUf.js} +1 -1
  144. package/static/assets/{search-CH2zaibZ.js → search-Cq1ksEdp.js} +1 -1
  145. package/static/assets/select-44mcS2_G.js +1 -0
  146. package/static/assets/{status-utils-BDOyevaX.js → status-utils-CDkPeVfP.js} +1 -1
  147. package/static/assets/{switch-CH-VOgPo.js → switch-CIwjYvCt.js} +1 -1
  148. package/static/assets/{tabs-XeRAjZYR.js → tabs-DTV6Su-h.js} +1 -1
  149. package/static/assets/{tag-CRP5nL5-.js → tag-p6yeowCW.js} +1 -1
  150. package/static/assets/{terminal-preview-DMJMuORo.js → terminal-preview-DN38x9Jm.js} +1 -1
  151. package/static/assets/use-terminal-BXJqOeJe.js +1 -0
  152. package/static/assets/video-BH5ChaoS.js +36 -0
  153. package/static/index.html +2 -2
  154. package/static/assets/ApiKeysSettingsPage-Chw9PNL5.js +0 -2
  155. package/static/assets/CodePage-CrokcH-S.js +0 -2
  156. package/static/assets/DashboardPage-BaSQQ8Nv.js +0 -41
  157. package/static/assets/GitSettingsPage-tKBXYAFm.js +0 -6
  158. package/static/assets/IdentityPage-D2yBjeYn.js +0 -11
  159. package/static/assets/IntegrationsSettingsPage-Bx8-0Ig4.js +0 -1
  160. package/static/assets/JobDetailPage-BQmTHled.js +0 -1
  161. package/static/assets/KnowledgeDetailPage-QMU2bC3L.js +0 -1
  162. package/static/assets/KnowledgeEditPage-DbMJVcLc.js +0 -1
  163. package/static/assets/KnowledgePage-aU1GxZSZ.js +0 -8
  164. package/static/assets/McpSettingsPage-C3WxFwRB.js +0 -1
  165. package/static/assets/NewKnowledgePage-Cbiswrw_.js +0 -9
  166. package/static/assets/NewProposalPage-B_sDMBTK.js +0 -90
  167. package/static/assets/ProjectEditPage-BznWiBBc.js +0 -11
  168. package/static/assets/PromptsSettingsPage-CY0-870a.js +0 -1
  169. package/static/assets/ProposalDetailPage-K4iMXHEg.js +0 -1
  170. package/static/assets/ProposalEditPage-jZOtCMqP.js +0 -1
  171. package/static/assets/ProposalsPage-C7n4-G05.js +0 -17
  172. package/static/assets/ResourcesPage-vB5-XkUv.js +0 -71
  173. package/static/assets/RoleEditPage-Cu7ZB3yj.js +0 -13
  174. package/static/assets/SchedulePage-Bkkf2wA0.js +0 -4
  175. package/static/assets/SkillDetailPage-5sDxf3Of.js +0 -1
  176. package/static/assets/SkillsPage-D2G7EfK8.js +0 -8
  177. package/static/assets/SourceInput-DlC0zwva.js +0 -1
  178. package/static/assets/TerminalPage--KZ7azvP.js +0 -1
  179. package/static/assets/TerminalSessionPage-ClvxK9ia.js +0 -13
  180. package/static/assets/UserPreferencesPage-CheOH7jZ.js +0 -1
  181. package/static/assets/UserSettingsPage-C8STDvfQ.js +0 -1
  182. package/static/assets/UtilitiesPage-9rTxR2md.js +0 -1
  183. package/static/assets/calendar-Cx5r9R7A.js +0 -6
  184. package/static/assets/droid-DqWsM2dp.js +0 -17
  185. package/static/assets/index-DVTgTsDa.css +0 -2
  186. package/static/assets/index-hqVgTgRB.js +0 -462
  187. package/static/assets/use-terminal-DuGZuvd2.js +0 -1
  188. package/static/assets/zap-BlzMp7dY.js +0 -6
@@ -0,0 +1,41 @@
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-DFcWlnzl.js";import{C as Ye,b as hs,a as Qe,c as Sa,d as Ca}from"./card-BcPlIAH5.js";import{L as C}from"./label-DBuh-ke5.js";import{B as Me}from"./badge-BUEY53dV.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-44mcS2_G.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-BH5ChaoS.js";import{D as as}from"./download-Bg__QCLT.js";import{C as zs}from"./chevron-left-FMmNe7yP.js";import{T as Ma}from"./tag-p6yeowCW.js";import{S as Fa}from"./search-Cq1ksEdp.js";import"./chevron-up-CqM3won3.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};
@@ -0,0 +1,13 @@
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-DFcWlnzl.js";import{C as y,a as S,b as A,c as L}from"./card-BcPlIAH5.js";import{L as P}from"./label-DBuh-ke5.js";import{S as z,a as I,b as q,c as T,d as M}from"./select-44mcS2_G.js";import{M as O}from"./markdown-editor-B4YNQFT2.js";import{A as B}from"./arrow-left-1S-835kP.js";import{C as F}from"./circle-check-big-jKg34xC-.js";import"./chevron-up-CqM3won3.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};
@@ -1 +1 @@
1
- import{a as N,r as t,A as v,j as e,H as C,F as g,B as a,L as c,Q as d,M as w,aB as y,ay as b}from"./index-hqVgTgRB.js";import{C as i,a as r,b as E}from"./card-BCFxXzRk.js";import{c as k}from"./clipboard-B9ndUJKl.js";function F(){const{toast:l}=N(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${v}/api/v1/context/role`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/role.md";try{await k(s),l({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),l({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"role-md",filename:"role.md",name:"role.md",path:".nut/context/role.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading role definition..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(g,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Role Definition Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Role definition will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Role Definition"]})})]})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Role Definition"}),e.jsx("p",{className:"text-muted-foreground",children:"The Coconut's role, responsibilities, and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(i,{children:[e.jsx(E,{className:"pb-0"}),e.jsx(r,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(b,{children:o.content||"No content available"})})})]})]})}export{F as default};
1
+ import{a as N,r as t,A as v,j as e,t as C,F as g,B as a,L as c,Y as d,M as w,au as y,ar as b}from"./index-DFcWlnzl.js";import{C as i,a as r,b as E}from"./card-BcPlIAH5.js";import{c as k}from"./clipboard-B9ndUJKl.js";function L(){const{toast:l}=N(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${v}/api/v1/context/role`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/role.md";try{await k(s),l({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),l({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"role-md",filename:"role.md",name:"role.md",path:".nut/context/role.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading role definition..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(g,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Role Definition Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Role definition will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Role Definition"]})})]})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Role"}),e.jsx("p",{className:"text-muted-foreground",children:"This Coconut's responsibilities and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(i,{children:[e.jsx(E,{className:"pb-0"}),e.jsx(r,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(b,{children:o.content||"No content available"})})})]})]})}export{L as default};
@@ -1,4 +1,4 @@
1
- import{c as f,r,A as p,j as e,a6 as F,B as l,I as c,V as L}from"./index-hqVgTgRB.js";import{C as T,b as I,a as z}from"./card-BCFxXzRk.js";import{L as n}from"./label-vYhfrPMD.js";import{B as _}from"./badge-DEiQk9C9.js";import{P as D}from"./plus-iamYJu5V.js";/**
1
+ import{c as f,r,A as p,j as e,a$ as F,B as l,P as L,I as c,E as T}from"./index-DFcWlnzl.js";import{C as I,b as z,a as _}from"./card-BcPlIAH5.js";import{L as n}from"./label-DBuh-ke5.js";import{B as D}from"./badge-BUEY53dV.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -13,4 +13,4 @@ import{c as f,r,A as p,j as e,a6 as F,B as l,I as c,V as L}from"./index-hqVgTgRB
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const R=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],w=f("unlink",R);function G(){const[v,C]=r.useState([]),[y,k]=r.useState(!1),[o,h]=r.useState(null),[u,j]=r.useState(!1),[g,N]=r.useState(null),[a,d]=r.useState({name:"",description:"",linkPath:"",targetPath:"",isActive:!1}),[i,m]=r.useState({name:"",description:"",linkPath:"",targetPath:"",isActive:!1});r.useEffect(()=>{x()},[]);const x=async()=>{try{const s=await(await fetch(`${p}/api/v1/symlinks`)).json();s.success&&C(s.symlinks)}catch(t){console.error("Error fetching symlinks:",t)}},S=async t=>{h(t);try{(await fetch(`${p}/api/v1/symlinks/${t}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok?await x():console.error("Error toggling symlink")}catch(s){console.error("Error toggling symlink:",s)}finally{h(null)}},A=async t=>{if(confirm("Are you sure you want to delete this symlink configuration?")){h(t);try{(await fetch(`${p}/api/v1/symlinks/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok?await x():console.error("Error deleting symlink")}catch(s){console.error("Error deleting symlink:",s)}finally{h(null)}}},E=async()=>{if(!a.name||!a.linkPath||!a.targetPath){alert("Please fill in all required fields");return}k(!0);try{const t=await fetch(`${p}/api/v1/symlinks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(t.ok)await x(),j(!1),d({name:"",description:"",linkPath:"",targetPath:"",isActive:!1});else{const s=await t.json();alert(s.error?.message||"Error creating symlink")}}catch(t){console.error("Error adding symlink:",t),alert("Failed to create symlink")}finally{k(!1)}},b=t=>{N(t.id),m({name:t.name,description:t.description||"",linkPath:t.linkPath,targetPath:t.targetPath,isActive:t.isActive})},P=()=>{N(null),m({name:"",description:"",linkPath:"",targetPath:"",isActive:!1})},$=async()=>{if(g){if(!i.name||!i.linkPath||!i.targetPath){alert("Please fill in all required fields");return}h(g);try{const t=await fetch(`${p}/api/v1/symlinks/${g}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(t.ok)await x(),P();else{const s=await t.json();alert(s.error?.message||"Error updating symlink")}}catch(t){console.error("Error updating symlink:",t),alert("Failed to update symlink")}finally{h(null)}}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Symlinks Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage symlinks for easy access to project rules and configurations."})]}),e.jsx(F,{}),e.jsxs(T,{children:[e.jsx(I,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(l,{size:"sm",variant:"outline",onClick:()=>j(!u),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),u?"Cancel":"Add Symlink"]})})}),e.jsxs(z,{children:[u&&e.jsxs("div",{className:"mb-6 p-4 border rounded-lg bg-muted/50",children:[e.jsx("h4",{className:"font-medium mb-4",children:"New Symlink Configuration"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-name",children:"Name *"}),e.jsx(c,{id:"new-name",placeholder:"e.g., Claude Rules",value:a.name,onChange:t=>d({...a,name:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-description",children:"Description"}),e.jsx(c,{id:"new-description",placeholder:"e.g., Project-specific rules for Claude AI",value:a.description,onChange:t=>d({...a,description:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-link-path",children:"Link Path * (relative to project root)"}),e.jsx(c,{id:"new-link-path",placeholder:"e.g., CLAUDE.md or docs/README.md",value:a.linkPath,onChange:t=>d({...a,linkPath:t.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Where the symlink will be created in your project"})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-target-path",children:"Target Path * (relative to project root)"}),e.jsx(c,{id:"new-target-path",placeholder:"e.g., .nut/rules/CLAUDE.md",value:a.targetPath,onChange:t=>d({...a,targetPath:t.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"The actual file that the symlink will point to"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-active",checked:a.isActive,onChange:t=>d({...a,isActive:t.target.checked}),className:"rounded"}),e.jsx(n,{htmlFor:"new-active",children:"Activate immediately"})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",onClick:()=>{j(!1),d({name:"",description:"",linkPath:"",targetPath:"",isActive:!1})},children:"Cancel"}),e.jsx(l,{onClick:E,disabled:y,children:y?"Creating...":"Create Symlink"})]})]})]}),v.length===0&&!u?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(w,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No symlinks configured"}),e.jsx("p",{className:"text-sm mt-2",children:'Click "Add Symlink" to create your first symlink configuration.'})]}):e.jsx("div",{className:"space-y-4",children:v.map(t=>e.jsx("div",{className:"border rounded-lg",children:g===t.id?e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-name-${t.id}`,children:"Name *"}),e.jsx(c,{id:`edit-name-${t.id}`,value:i.name,onChange:s=>m({...i,name:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-desc-${t.id}`,children:"Description"}),e.jsx(c,{id:`edit-desc-${t.id}`,value:i.description,onChange:s=>m({...i,description:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-link-${t.id}`,children:"Link Path *"}),e.jsx(c,{id:`edit-link-${t.id}`,value:i.linkPath,onChange:s=>m({...i,linkPath:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-target-${t.id}`,children:"Target Path *"}),e.jsx(c,{id:`edit-target-${t.id}`,value:i.targetPath,onChange:s=>m({...i,targetPath:s.target.value})})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",size:"sm",onClick:P,children:"Cancel"}),e.jsx(l,{size:"sm",onClick:$,disabled:o===t.id,children:o===t.id?"Saving...":"Save"})]})]}):e.jsx("div",{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[t.isActive?e.jsx(O,{className:"h-4 w-4 text-green-600 flex-shrink-0"}):e.jsx(w,{className:"h-4 w-4 text-gray-400 flex-shrink-0"}),e.jsx("h4",{className:"font-medium text-sm sm:text-base",children:t.name})]}),e.jsx(_,{variant:t.isActive?"default":"secondary",className:"text-xs",children:t.isActive?"Active":"Inactive"})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-2 font-mono break-all",children:[e.jsx("span",{className:"text-foreground/70",children:t.linkPath}),e.jsx("span",{className:"mx-1",children:"→"}),e.jsx("span",{children:t.targetPath})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[e.jsx(l,{onClick:()=>S(t.id),disabled:o===t.id,variant:t.isActive?"outline":"default",size:"sm",children:o===t.id?"...":e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:t.isActive?"Disable":"Enable"}),e.jsx("span",{className:"sm:hidden",children:t.isActive?"Off":"On"})]})}),e.jsx(l,{onClick:()=>b(t),variant:"outline",size:"icon",className:"h-8 w-8",disabled:o===t.id,children:e.jsx(M,{className:"h-4 w-4"})}),e.jsx(l,{onClick:()=>A(t.id),variant:"outline",size:"icon",className:"h-8 w-8",disabled:o===t.id,children:e.jsx(L,{className:"h-4 w-4"})})]})]})})},t.id))})]})]})]})}export{G as default};
16
+ */const R=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],w=f("unlink",R);function G(){const[v,C]=r.useState([]),[y,k]=r.useState(!1),[o,h]=r.useState(null),[u,j]=r.useState(!1),[g,N]=r.useState(null),[a,d]=r.useState({name:"",description:"",linkPath:"",targetPath:"",isActive:!1}),[i,m]=r.useState({name:"",description:"",linkPath:"",targetPath:"",isActive:!1});r.useEffect(()=>{x()},[]);const x=async()=>{try{const s=await(await fetch(`${p}/api/v1/symlinks`)).json();s.success&&C(s.symlinks)}catch(t){console.error("Error fetching symlinks:",t)}},S=async t=>{h(t);try{(await fetch(`${p}/api/v1/symlinks/${t}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok?await x():console.error("Error toggling symlink")}catch(s){console.error("Error toggling symlink:",s)}finally{h(null)}},A=async t=>{if(confirm("Are you sure you want to delete this symlink configuration?")){h(t);try{(await fetch(`${p}/api/v1/symlinks/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok?await x():console.error("Error deleting symlink")}catch(s){console.error("Error deleting symlink:",s)}finally{h(null)}}},E=async()=>{if(!a.name||!a.linkPath||!a.targetPath){alert("Please fill in all required fields");return}k(!0);try{const t=await fetch(`${p}/api/v1/symlinks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(t.ok)await x(),j(!1),d({name:"",description:"",linkPath:"",targetPath:"",isActive:!1});else{const s=await t.json();alert(s.error?.message||"Error creating symlink")}}catch(t){console.error("Error adding symlink:",t),alert("Failed to create symlink")}finally{k(!1)}},b=t=>{N(t.id),m({name:t.name,description:t.description||"",linkPath:t.linkPath,targetPath:t.targetPath,isActive:t.isActive})},P=()=>{N(null),m({name:"",description:"",linkPath:"",targetPath:"",isActive:!1})},$=async()=>{if(g){if(!i.name||!i.linkPath||!i.targetPath){alert("Please fill in all required fields");return}h(g);try{const t=await fetch(`${p}/api/v1/symlinks/${g}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(t.ok)await x(),P();else{const s=await t.json();alert(s.error?.message||"Error updating symlink")}}catch(t){console.error("Error updating symlink:",t),alert("Failed to update symlink")}finally{h(null)}}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Symlinks Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage symlinks for easy access to project rules and configurations."})]}),e.jsx(F,{}),e.jsxs(I,{children:[e.jsx(z,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(l,{size:"sm",variant:"outline",onClick:()=>j(!u),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),u?"Cancel":"Add Symlink"]})})}),e.jsxs(_,{children:[u&&e.jsxs("div",{className:"mb-6 p-4 border rounded-lg bg-muted/50",children:[e.jsx("h4",{className:"font-medium mb-4",children:"New Symlink Configuration"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-name",children:"Name *"}),e.jsx(c,{id:"new-name",placeholder:"e.g., Claude Rules",value:a.name,onChange:t=>d({...a,name:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-description",children:"Description"}),e.jsx(c,{id:"new-description",placeholder:"e.g., Project-specific rules for Claude AI",value:a.description,onChange:t=>d({...a,description:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-link-path",children:"Link Path * (relative to project root)"}),e.jsx(c,{id:"new-link-path",placeholder:"e.g., CLAUDE.md or docs/README.md",value:a.linkPath,onChange:t=>d({...a,linkPath:t.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Where the symlink will be created in your project"})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-target-path",children:"Target Path * (relative to project root)"}),e.jsx(c,{id:"new-target-path",placeholder:"e.g., .nut/rules/CLAUDE.md",value:a.targetPath,onChange:t=>d({...a,targetPath:t.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"The actual file that the symlink will point to"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-active",checked:a.isActive,onChange:t=>d({...a,isActive:t.target.checked}),className:"rounded"}),e.jsx(n,{htmlFor:"new-active",children:"Activate immediately"})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",onClick:()=>{j(!1),d({name:"",description:"",linkPath:"",targetPath:"",isActive:!1})},children:"Cancel"}),e.jsx(l,{onClick:E,disabled:y,children:y?"Creating...":"Create Symlink"})]})]})]}),v.length===0&&!u?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(w,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No symlinks configured"}),e.jsx("p",{className:"text-sm mt-2",children:'Click "Add Symlink" to create your first symlink configuration.'})]}):e.jsx("div",{className:"space-y-4",children:v.map(t=>e.jsx("div",{className:"border rounded-lg",children:g===t.id?e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-name-${t.id}`,children:"Name *"}),e.jsx(c,{id:`edit-name-${t.id}`,value:i.name,onChange:s=>m({...i,name:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-desc-${t.id}`,children:"Description"}),e.jsx(c,{id:`edit-desc-${t.id}`,value:i.description,onChange:s=>m({...i,description:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-link-${t.id}`,children:"Link Path *"}),e.jsx(c,{id:`edit-link-${t.id}`,value:i.linkPath,onChange:s=>m({...i,linkPath:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-target-${t.id}`,children:"Target Path *"}),e.jsx(c,{id:`edit-target-${t.id}`,value:i.targetPath,onChange:s=>m({...i,targetPath:s.target.value})})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",size:"sm",onClick:P,children:"Cancel"}),e.jsx(l,{size:"sm",onClick:$,disabled:o===t.id,children:o===t.id?"Saving...":"Save"})]})]}):e.jsx("div",{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[t.isActive?e.jsx(O,{className:"h-4 w-4 text-green-600 flex-shrink-0"}):e.jsx(w,{className:"h-4 w-4 text-gray-400 flex-shrink-0"}),e.jsx("h4",{className:"font-medium text-sm sm:text-base",children:t.name})]}),e.jsx(D,{variant:t.isActive?"default":"secondary",className:"text-xs",children:t.isActive?"Active":"Inactive"})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-2 font-mono break-all",children:[e.jsx("span",{className:"text-foreground/70",children:t.linkPath}),e.jsx("span",{className:"mx-1",children:"→"}),e.jsx("span",{children:t.targetPath})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[e.jsx(l,{onClick:()=>S(t.id),disabled:o===t.id,variant:t.isActive?"outline":"default",size:"sm",children:o===t.id?"...":e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:t.isActive?"Disable":"Enable"}),e.jsx("span",{className:"sm:hidden",children:t.isActive?"Off":"On"})]})}),e.jsx(l,{onClick:()=>b(t),variant:"outline",size:"icon",className:"h-8 w-8",disabled:o===t.id,children:e.jsx(M,{className:"h-4 w-4"})}),e.jsx(l,{onClick:()=>A(t.id),variant:"outline",size:"icon",className:"h-8 w-8",disabled:o===t.id,children:e.jsx(T,{className:"h-4 w-4"})})]})]})})},t.id))})]})]})]})}export{G as default};
@@ -0,0 +1,4 @@
1
+ import{a as Xe,ad as Ze,r as m,j as e,B as u,t as J,P as pe,bs as ge,y as q,z as fe,E as ve,H as V,J as Y,N as G,O as K,Q,R as X,U as Z,L as je,k as ee,a9 as Ne,bt as es,C as ss,n as se,D as be,b as ye,d as we,f as Se,g as Ce,I as te,a2 as ke,a3 as Ae,a4 as De,a5 as Ie,a6 as Te,aa as Fe,o as ts,ab as as,W as Pe,A as j}from"./index-DFcWlnzl.js";import{C as O,a as ae,c as re,b as $e}from"./card-BcPlIAH5.js";import{B as F}from"./badge-BUEY53dV.js";import{S as rs,a as ns,b as is,c as ls,d as ds}from"./select-44mcS2_G.js";import{L as v}from"./label-DBuh-ke5.js";import{S as cs}from"./switch-CIwjYvCt.js";import{T as os,a as ms,b as ne,c as ie}from"./tabs-DTV6Su-h.js";import{R as us}from"./refresh-cw-B3OwrDUf.js";import{P as Me}from"./play-CHIf-Rcz.js";import{P as hs}from"./pause-BzhKXHtR.js";import{C as xs}from"./clock-Bjc06QBM.js";import{C as ps}from"./chevron-up-CqM3won3.js";const ce=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"},{id:"kiro",label:"Kiro"}],gs=[{label:"Monday",value:"monday"},{label:"Tuesday",value:"tuesday"},{label:"Wednesday",value:"wednesday"},{label:"Thursday",value:"thursday"},{label:"Friday",value:"friday"},{label:"Saturday",value:"saturday"},{label:"Sunday",value:"sunday"}],Ee=["monday","tuesday","wednesday","thursday","friday"],Je=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},H=a=>{if(!a)return"—";const x=new Date(a).getTime()-Date.now(),f=Math.round(x/(1e3*60));if(Number.isNaN(f))return Je(a);if(Math.abs(f)<1)return"now";if(f>0){if(f<60)return`in ${f}m`;const b=Math.round(f/60);return b<24?`in ${b}h`:`in ${Math.round(b/24)}d`}const N=Math.abs(f);if(N<60)return`${N}m ago`;const T=Math.round(N/60);return T<24?`${T}h ago`:`${Math.round(T/24)}d ago`},fs=a=>{if(a.type==="interval"){const o=a.daysOfWeek.map(x=>x.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${o||"All days"})`}return a.description||`Cron: ${a.expression}`},vs=a=>{const o=ce.find(x=>x.id===a);return o?o.label:a},le=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}},de=()=>({name:"",model:"claude",prompt:"",hours:6,daysOfWeek:new Set(Ee),status:!0,anchorHour:"",agentIds:[],mcpServers:[]}),Re=a=>{if(a.schedule.type!=="interval")return de();const o=a.agentIds||(a.agentId?[a.agentId]:[]);return{name:a.name,model:ce.some(x=>x.id===a.model)?a.model:"claude",prompt:a.prompt,hours:a.schedule.hours,daysOfWeek:new Set(a.schedule.daysOfWeek),status:a.status==="active",anchorHour:a.schedule.anchorHour===void 0?"":String(a.schedule.anchorHour),agentIds:o,mcpServers:a.mcpServers||[]}},js=a=>a?Array.isArray(a)?a.filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean):typeof a=="string"?a.split(",").map(o=>o.trim()).filter(Boolean):[]:[];function Ps(){const{toast:a}=Xe(),{refresh:o}=Ze(),[x,f]=m.useState([]),[N,T]=m.useState(!0),[L,b]=m.useState(!1),[P,y]=m.useState(!1),[n,p]=m.useState(()=>de()),[z,oe]=m.useState(!1),[w,S]=m.useState(null),[c,C]=m.useState(null),[g,$]=m.useState(null),[Oe,M]=m.useState(!1),[R,He]=m.useState([]),[W,Le]=m.useState([]),[ze,We]=m.useState(new Set),[B,U]=m.useState({open:!1,serverToRemove:null}),k=async(s=!1)=>{try{N||b(!0);const t=await fetch(`${j}/api/v1/jobs`);if(!t.ok)throw new Error(`Failed to fetch jobs (${t.status})`);const r=await t.json();if(!r?.success)throw new Error(r?.error?.message||"Unknown error loading jobs");const i=r.data??[];if(f(i),c){const l=i.find(d=>d.id===c.id);l&&(C(l),l.schedule.type!=="cron"&&p(Re(l)))}if(g){const l=i.find(d=>d.id===g.id);l&&$(l)}s&&a({title:"Schedule refreshed",description:"Latest job information loaded."})}catch(t){console.error("Failed to load jobs:",t),a({title:"Failed to load schedule",description:t?.message??"Unknown error",variant:"destructive"})}finally{T(!1),b(!1)}};m.useEffect(()=>{k()},[]),m.useEffect(()=>{P&&(async()=>{try{const t=await fetch(`${j}/api/v1/agents`);if(t.ok){const i=await t.json(),d=(Array.isArray(i?.documents)?i.documents:[]).map(h=>({id:h.filename,name:h?.metadata?.name||h.title||h.filename,tools:js(h?.metadata?.tools)}));if(He(d),c){const D=(c.agentIds||(c.agentId?[c.agentId]:[])).filter(I=>!d.find(_=>_.id===I));D.length>0&&(a({title:"Some agents no longer available",description:`The following agents have been removed: ${D.join(", ")}`,variant:"destructive"}),p(I=>({...I,agentIds:I.agentIds.filter(_=>d.find(Qe=>Qe.id===_))})))}}const r=await fetch(`${j}/api/v1/mcp`);if(r.ok){const i=await r.json();if(i?.success&&Array.isArray(i.servers)&&(Le(i.servers),c?.mcpServers)){const l=c.mcpServers.filter(d=>!i.servers.includes(d));l.length>0&&(a({title:"Some MCP servers are no longer available",description:`The following servers have been removed: ${l.join(", ")}`,variant:"destructive"}),p(d=>({...d,mcpServers:d.mcpServers.filter(h=>i.servers.includes(h))})))}}}catch(t){console.error("Failed to load agents or MCP servers:",t)}})()},[P,c,a]);const A=s=>{p(t=>({...t,...s}))},Be=(s,t)=>{p(r=>{let i;if(t){i=[...r.agentIds,s];const l=R.find(d=>d.id===s);if(l&&l.tools.length>0){const d=new Set([...r.mcpServers,...l.tools]);return{...r,agentIds:i,mcpServers:Array.from(d).filter(h=>W.includes(h))}}}else i=r.agentIds.filter(l=>l!==s);return{...r,agentIds:i}})},Ue=(s,t)=>{if(!t&&R.filter(i=>n.agentIds.includes(i.id)&&i.tools.includes(s)).length>0){U({open:!0,serverToRemove:s});return}p(r=>({...r,mcpServers:t?[...r.mcpServers,s]:r.mcpServers.filter(i=>i!==s)}))},_e=()=>{const s=B.serverToRemove;s&&p(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),U({open:!1,serverToRemove:null})},qe=(s,t)=>{p(r=>{const i=new Set(r.daysOfWeek);return t?i.add(s):i.delete(s),i.size===0&&Ee.forEach(l=>i.add(l)),{...r,daysOfWeek:i}})},E=()=>{p(de())},me=s=>{We(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},ue=s=>{$(s),M(!0)},he=()=>{C(null),E(),y(!0)},Ve=s=>{if(s._error){a({title:"Cannot edit corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}if(s.schedule.type==="cron"){a({title:"Manual edit required",description:"Cron-based jobs can be edited directly in .nut/jobs/<id>.md for now.",variant:"destructive"});return}C(s),p(Re(s)),y(!0)},Ye=async s=>{if(s.preventDefault(),!n.name.trim()){a({title:"Job name required",description:"Please provide a name for the scheduled job.",variant:"destructive"});return}if(!n.prompt.trim()){a({title:"Prompt required",description:"Please provide instructions for the scheduled job.",variant:"destructive"});return}oe(!0);const t=!!c;try{const r=Number(n.anchorHour.trim()),i=n.anchorHour.trim()===""||Number.isNaN(r)?void 0:Math.min(23,Math.max(0,r)),l={name:n.name.trim(),prompt:n.prompt.trim(),model:n.model,status:n.status?"active":"paused",schedule:{type:"interval",hours:Math.max(1,Number(n.hours)||6),daysOfWeek:Array.from(n.daysOfWeek),anchorHour:i},agentIds:n.agentIds.length>0?n.agentIds:void 0,mcpServers:n.mcpServers.length>0?n.mcpServers:void 0},d=t?`${j}/api/v1/jobs/${c?.id}`:`${j}/api/v1/jobs`,D=await fetch(d,{method:t?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!D.ok){const I=await D.json().catch(()=>({}));throw new Error(I?.error?.message||`Failed to ${t?"update":"create"} job (${D.status})`)}a({title:t?"Scheduled job updated":"Scheduled job created",description:l.name}),y(!1),C(null),E(),await k()}catch(r){console.error("Failed to submit job:",r),a({title:`Failed to ${c?"update":"create"} job`,description:r?.message??"Unknown error",variant:"destructive"})}finally{oe(!1)}},Ge=async s=>{if(s._error){a({title:"Cannot run corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}/run`,{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to run job (${t.status})`)}a({title:"Run started",description:`${s.name} is executing.`}),await k(),await o()}catch(t){console.error("Failed to run job:",t),a({title:"Run failed to start",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},Ke=async s=>{if(s._error){a({title:"Cannot update corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);const t=s.status==="active"?"paused":"active";try{const r=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i?.error?.message||`Failed to update job (${r.status})`)}a({title:t==="active"?"Job resumed":"Job paused",description:s.name}),await k(),await o()}catch(r){console.error("Failed to update job status:",r),a({title:"Failed to update job",description:r?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},xe=async s=>{S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to delete job (${t.status})`)}a({title:"Scheduled job deleted",description:s.name}),c?.id===s.id&&(y(!1),C(null),E()),g?.id===s.id&&(M(!1),$(null)),await k()}catch(t){console.error("Failed to delete job:",t),a({title:"Failed to delete job",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Jobs"}),e.jsx("p",{className:"text-md text-muted-foreground",children:"Automate recurring agent runs"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",onClick:()=>k(!0),disabled:N||L,children:[L?e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(us,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsxs(u,{onClick:he,children:[e.jsx(pe,{className:"mr-2 h-4 w-4"}),"New Scheduled Job"]})]})]}),N?e.jsx(O,{children:e.jsxs(ae,{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(J,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading scheduled jobs..."]})}):x.length===0?e.jsx(O,{className:"border-dashed",children:e.jsxs(ae,{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-6 mb-6",children:e.jsx(ge,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx(re,{className:"text-2xl mb-3",children:"No scheduled jobs yet"}),e.jsx("p",{className:"text-muted-foreground max-w-md mb-6",children:"Automate recurring tasks by scheduling an agent to run on your behalf. Set up your first job to get started."}),e.jsxs("div",{className:"bg-accent/50 rounded-lg p-6 max-w-lg space-y-3 text-sm text-left",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"1"})}),e.jsx("p",{className:"text-muted-foreground",children:"Choose the days of the week and cadence that fit your workflow"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"2"})}),e.jsx("p",{className:"text-muted-foreground",children:"Provide detailed instructions so the agent can execute safely"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"3"})}),e.jsx("p",{className:"text-muted-foreground",children:"All runs are logged under for review"})]})]}),e.jsxs(u,{onClick:he,className:"mt-8",size:"lg",children:[e.jsx(pe,{className:"mr-2 h-5 w-5"}),"Create Your First Job"]})]})}):e.jsx("div",{className:"grid gap-4",children:x.map(s=>s._error?e.jsx(O,{className:"border-destructive/50 bg-destructive/5",children:e.jsx($e,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs(re,{className:"text-lg truncate text-destructive",children:["Unable to load job: ",s.id]}),e.jsx(F,{variant:"destructive",className:"text-xs shrink-0",children:"Error"})]}),e.jsx("p",{className:"text-sm text-destructive/80 mt-1",children:s._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/",s.id,".md"]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs(q,{children:[e.jsx(fe,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(ve,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete corrupted job?"}),e.jsxs(K,{children:["This will remove the corrupted job file ",e.jsx("strong",{children:s.id}),". This action cannot be undone."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})})]})})},s.id):e.jsxs(O,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all hover:shadow-lg",children:[e.jsx($e,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(je,{to:`/schedule/${s.id}`,className:"hover:underline",children:e.jsx(re,{className:"text-lg truncate",children:s.name})}),e.jsx(F,{variant:le(s.status),className:"capitalize text-xs shrink-0",children:s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:s.description||s.prompt||"No description provided"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(u,{size:"sm",variant:"default",onClick:()=>Ge(s),disabled:w===s.id,className:"h-8 px-3",children:w===s.id?e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}),e.jsx(u,{size:"sm",variant:"outline",asChild:!0,className:"h-8 px-3 text-xs",children:e.jsx(je,{to:`/schedule/${s.id}`,children:"View"})}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ve(s),disabled:w===s.id,className:"h-8 px-3 text-xs",children:"Edit"}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ke(s),disabled:w===s.id,className:"h-8 px-2",children:s.status==="active"?e.jsx(hs,{className:"h-3.5 w-3.5"}):e.jsx(Me,{className:"h-3.5 w-3.5"})}),e.jsxs(q,{children:[e.jsx(fe,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(ve,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete scheduled job?"}),e.jsxs(K,{children:["This will remove ",e.jsx("strong",{children:s.name}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})}),e.jsxs(ae,{className:"space-y-3 pt-0",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(xs,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"font-semibold truncate",children:fs(s.schedule)})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"font-semibold",children:vs(s.model)})]}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Next"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.nextRunAt)})]})}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Last"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.lastRunAt)})]})})]}),(s.agentIds&&s.agentIds.length>0||s.agentId||s.mcpServers&&s.mcpServers.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[(s.agentIds||(s.agentId?[s.agentId]:[])).map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(ee,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:t.replace(".md","")})]},t)),s.mcpServers&&s.mcpServers.length>0&&s.mcpServers.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800",children:[e.jsx(Ne,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:t})]},t))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[e.jsx(es,{className:"h-3 w-3"}),"Recent Runs"]}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ue(s),children:["View All (",s.runs.length,")",e.jsx(ss,{className:"ml-1 h-3 w-3"})]})]}),s.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-4 text-center text-xs text-muted-foreground",children:'No runs yet • Click "Run" to execute'}):e.jsxs("div",{className:"space-y-1.5",children:[s.runs.slice(0,1).map(t=>{const r=ze.has(t.id);return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden transition-all",children:[e.jsxs("div",{className:"p-2.5 text-xs hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>me(t.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(F,{variant:le(t.status),className:"capitalize text-[10px] h-5",children:t.status}),e.jsx("span",{className:"text-muted-foreground truncate",children:H(t.startedAt)})]}),t.trigger==="manual"&&e.jsx(F,{variant:"outline",className:"text-[10px] h-5",children:"manual"})]}),t.error&&e.jsx("p",{className:"text-destructive font-medium mt-1 line-clamp-1",children:t.error})]}),t.summary&&e.jsx("div",{className:"px-2.5 pb-2.5",children:e.jsxs("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground relative cursor-pointer hover:bg-muted/70 transition-colors",onClick:i=>{i.stopPropagation(),me(t.id)},children:[e.jsx("div",{className:r?"":"line-clamp-2",children:t.summary}),e.jsx("div",{className:"flex justify-center mt-1",children:e.jsx("div",{className:"text-muted-foreground p-0.5",children:r?e.jsx(ps,{className:"h-3 w-3"}):e.jsx(se,{className:"h-3 w-3"})})})]})})]},t.id)}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>ue(s),children:["+",s.runs.length-1," more runs"]})]})]})]})]},s.id))}),e.jsx(be,{open:P,onOpenChange:s=>{y(s),s||(C(null),E())},children:e.jsxs(ye,{className:"max-w-4xl h-[700px] overflow-hidden flex flex-col",children:[e.jsxs(we,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(Se,{className:"text-xl flex items-center gap-2",children:[e.jsx(ge,{className:"h-5 w-5 text-primary"}),c?"Edit Scheduled Job":"Create New Scheduled Job"]}),e.jsx(Ce,{className:"text-sm",children:c?"Update the prompt, cadence, or agent preference":"Automate recurring tasks by scheduling an agent"})]}),e.jsxs("form",{onSubmit:Ye,className:"flex flex-col flex-1 min-h-0",children:[e.jsxs(os,{defaultValue:"basics",className:"flex-1 flex flex-col min-h-0",children:[e.jsxs(ms,{className:"grid w-full grid-cols-3 mb-4 shrink-0",children:[e.jsx(ne,{value:"basics",children:"Basics"}),e.jsx(ne,{value:"schedule",children:"Schedule"}),e.jsx(ne,{value:"advanced",children:"Advanced"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 -mr-2 min-h-0",children:[e.jsxs(ie,{value:"basics",className:"space-y-5 mt-0",children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-name",className:"text-sm font-medium flex items-center gap-1.5",children:["Job Name",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(te,{id:"job-name",placeholder:"e.g., Publish docs nightly",value:n.name,onChange:s=>A({name:s.target.value}),className:"h-11",required:!0})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-model",className:"text-sm font-medium",children:"AI Model"}),e.jsxs(rs,{value:n.model,onValueChange:s=>A({model:s}),children:[e.jsx(ns,{id:"job-model",className:"h-11",children:e.jsx(is,{placeholder:"Select a model"})}),e.jsx(ls,{children:ce.map(s=>e.jsx(ds,{value:s.id,children:s.label},s.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ee,{className:"h-4 w-4"}),"Custom Agent",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(ke,{children:[e.jsx(Ae,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.agentIds.length===0?"No agents selected":`${n.agentIds.length} agent${n.agentIds.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(De,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ie,{children:"Available Agents"}),e.jsx(Te,{}),R.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No agents configured"}):R.map(s=>e.jsx(Fe,{checked:n.agentIds.includes(s.id),onCheckedChange:t=>Be(s.id,t),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.name}),s.tools.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP: ",s.tools.join(", ")]})]})},s.id))]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(Ne,{className:"h-4 w-4"}),"MCP Servers",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(ke,{children:[e.jsx(Ae,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.mcpServers.length===0?"No MCP servers selected":`${n.mcpServers.length} server${n.mcpServers.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(De,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ie,{children:"Available MCP Servers"}),e.jsx(Te,{}),W.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No MCP servers configured"}):W.map(s=>e.jsx(Fe,{checked:n.mcpServers.includes(s),onCheckedChange:t=>Ue(s,t),children:s},s))]})]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-prompt",className:"text-sm font-medium flex items-center gap-1.5",children:[n.agentIds.length>0?"Custom Instructions":"Instructions",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ts,{id:"job-prompt",placeholder:n.agentIds.length>0?`Additional instructions to supplement the agent's predefined behavior...
2
+ Example: Focus on performance optimizations`:`Example:
3
+ Run the following command and append the output to .nut/knowledge/runs.md:
4
+ pnpm docs:publish`,rows:6,value:n.prompt,onChange:s=>A({prompt:s.target.value}),className:"resize-none font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1.5",children:[e.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:"⚠"}),e.jsx("span",{children:n.agentIds.length>0?"These custom instructions will be combined with the selected agents' predefined instructions. Jobs run with autonomous permissions.":"Provide clear, actionable instructions. Jobs run with autonomous permissions - include safety checks where needed."})]})]})]}),e.jsx(ie,{value:"schedule",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-[1.2fr_1fr]",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{className:"text-sm font-medium",children:"Days of the Week"}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:gs.map(s=>e.jsxs("label",{className:"flex items-center gap-2.5 text-sm rounded-md border border-input px-3.5 py-2.5 cursor-pointer hover:bg-accent/50 transition-colors",children:[e.jsx(as,{checked:n.daysOfWeek.has(s.value),onCheckedChange:t=>qe(s.value,t)}),e.jsx("span",{className:"font-medium",children:s.label})]},s.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which days the job should run"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-hours",className:"text-sm font-medium",children:"Frequency (hours)"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-hours",type:"number",min:1,value:n.hours,onChange:s=>A({hours:Number(s.target.value)||1}),className:"h-11 pr-16"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"hours"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How often the job runs on selected days"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-anchor",className:"text-sm font-medium flex items-center gap-1.5",children:["Start Hour",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-anchor",type:"number",min:0,max:23,placeholder:"Auto",value:n.anchorHour,onChange:s=>A({anchorHour:s.target.value}),className:"h-11"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"0-23"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Preferred starting hour in 24h format"})]})]})]})}),e.jsx(ie,{value:"advanced",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"flex items-start gap-4 rounded-lg border border-border bg-accent/20 p-4",children:[e.jsx(cs,{id:"job-status",checked:n.status,onCheckedChange:s=>A({status:s}),className:"mt-1"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(v,{htmlFor:"job-status",className:"text-base font-semibold cursor-pointer",children:n.status?"Start Active":"Start Paused"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.status?"Job will begin running on the configured schedule immediately after creation.":"Job will be created in a paused state. You can activate it later from the schedule page."})]})]})})]})]}),e.jsxs(Pe,{className:"gap-2 sm:gap-2 pt-4 border-t mt-4",children:[e.jsx(u,{type:"button",variant:"outline",onClick:()=>y(!1),disabled:z,className:"min-w-24",children:"Cancel"}),e.jsx(u,{type:"submit",disabled:z||!n.name.trim()||!n.prompt.trim(),className:"min-w-32",children:z?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}),c?"Saving...":"Creating..."]}):e.jsx(e.Fragment,{children:c?"Save Changes":"Create Job"})})]})]})]})}),e.jsx(be,{open:Oe,onOpenChange:s=>{M(s),s||$(null)},children:e.jsxs(ye,{className:"max-w-3xl",children:[e.jsxs(we,{children:[e.jsxs(Se,{children:["Run history — ",g?.name]}),e.jsxs(Ce,{children:[g?.runs?.length??0," recorded runs. Logs stored in ",e.jsxs("code",{children:[".nut/jobs/",g?.id,".md"]})," and ",e.jsxs("code",{children:[".nut/jobs/logs/",g?.id]}),"."]})]}),e.jsxs("div",{className:"max-h-[420px] space-y-3 overflow-y-auto pr-2",children:[g?.runs.map(s=>e.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[e.jsxs("div",{className:"p-3 text-xs bg-card/50",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx(F,{variant:le(s.status),className:"capitalize text-[10px] h-5",children:s.status}),e.jsxs("span",{className:"text-muted-foreground",children:[s.trigger," • ",Je(s.startedAt)]}),s.finishedAt&&e.jsxs("span",{className:"text-muted-foreground",children:["• completed ",H(s.finishedAt)]})]}),s.error&&e.jsx("p",{className:"text-destructive font-medium mb-2",children:s.error}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-[10px] text-muted-foreground",children:[s.outputPath&&e.jsxs("span",{children:["log: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.outputPath})]}),s.cliCommand&&e.jsxs("span",{children:["cmd: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.cliCommand})]})]})]}),s.summary&&e.jsx("div",{className:"px-3 pb-3",children:e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap",children:s.summary})})]},s.id)),g&&g.runs.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No recorded runs yet."})]}),e.jsx(Pe,{children:e.jsx(u,{variant:"outline",onClick:()=>M(!1),children:"Close"})})]})}),e.jsx(q,{open:B.open,onOpenChange:s=>{s||U({open:!1,serverToRemove:null})},children:e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Remove MCP Server?"}),e.jsxs(K,{children:["One or more selected agents require the ",e.jsx("strong",{children:B.serverToRemove})," MCP server. Removing it may lead to unexpected consequences when the job runs."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:_e,children:"OK"})]})]})})]})}export{Ps as default};
@@ -0,0 +1 @@
1
+ import{x as C,u as S,r as h,j as e,B as a,L as c,Y as E,E as T,k as A,A as N}from"./index-DFcWlnzl.js";import{C as l,b as d,a as o,c as f,d as z}from"./card-BcPlIAH5.js";import{B as v}from"./badge-BUEY53dV.js";import{A as p}from"./arrow-left-1S-835kP.js";function B(n){return n.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())}const i={blue:{bg:"#dbeafe",border:"#2563eb",text:"#1e40af"},green:{bg:"#dcfce7",border:"#16a34a",text:"#166534"},red:{bg:"#fee2e2",border:"#dc2626",text:"#991b1b"},emerald:{bg:"#d1fae5",border:"#10b981",text:"#047857"},purple:{bg:"#f3e8ff",border:"#9333ea",text:"#6b21a8"},orange:{bg:"#fed7aa",border:"#ea580c",text:"#9a3412"},yellow:{bg:"#fef9c3",border:"#eab308",text:"#854d0e"},teal:{bg:"#ccfbf1",border:"#14b8a6",text:"#0f766e"},indigo:{bg:"#e0e7ff",border:"#6366f1",text:"#4338ca"},pink:{bg:"#fce7f3",border:"#ec4899",text:"#9f1239"},cyan:{bg:"#cffafe",border:"#06b6d4",text:"#155e75"},slate:{bg:"#f1f5f9",border:"#475569",text:"#334155"},gray:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"}};function U(){const n=C(),u=S(),[s,w]=h.useState(null),[k,g]=h.useState(!0),[b,m]=h.useState(null);h.useEffect(()=>{async function r(){try{g(!0);const j=await(await fetch(`${N}/api/v1/skills/${n.id}`)).json();j.success?w(j.document):m(j.error||"Failed to fetch skill")}catch(t){m(t instanceof Error?t.message:"Unknown error")}finally{g(!1)}}n.id&&r()},[n.id]);const y=async()=>{if(!(!s||!confirm("Are you sure you want to delete this skill?")))try{const t=await(await fetch(`${N}/api/v1/skills/${s.id}`,{method:"DELETE"})).json();t.success?u("/skills"):m(t.error?.message||"Failed to delete skill")}catch(r){m(r instanceof Error?r.message:"Unknown error")}};if(k)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-64 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 animate-pulse mt-2"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(c,{to:"/skills",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsxs(d,{children:[e.jsx("div",{className:"h-6 bg-muted rounded w-48 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-64 animate-pulse"})]})})]});if(b||!s)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Skill Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:"The requested skill could not be found"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(c,{to:"/skills",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsx(o,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-destructive",children:b||"Skill not found"})})})})]});const x=s.metadata?.color||"blue";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("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",children:B(s.name)}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(c,{to:"/skills",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})}),e.jsx(a,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(c,{to:`/skills/${s.id}/edit`,children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(a,{variant:"destructive",size:"sm",onClick:y,children:[e.jsx(T,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(f,{children:"Description"})}),e.jsx(o,{children:e.jsx("p",{children:s.description})})]}),s.content&&e.jsxs(l,{children:[e.jsxs(d,{children:[e.jsx(f,{children:"Instructions"}),e.jsx(z,{children:"System prompt and behavior instructions for this skill"})]}),e.jsx(o,{children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm bg-muted p-4 rounded-md",children:s.content})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(f,{children:"Actions"})}),e.jsx(o,{className:"space-y-2",children:e.jsx(a,{variant:"default",className:"w-full justify-start",asChild:!0,children:e.jsxs(c,{to:`/terminal/sk-${s.id}`,children:[e.jsx(A,{className:"h-4 w-4 mr-2"}),"Use Skill"]})})})]}),e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(f,{children:"Information"})}),e.jsxs(o,{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Color"}),e.jsx(v,{variant:"outline",className:"capitalize border-2",style:{backgroundColor:i[x]?.bg||i.blue.bg,color:i[x]?.text||i.blue.text,borderColor:i[x]?.border||i.blue.border},children:x})]}),s.allowedTools&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Allowed Tools"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.allowedTools})]}),s.metadata?.mcpServers&&s.metadata.mcpServers.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"MCP Servers"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:s.metadata.mcpServers.map(r=>e.jsx(v,{variant:"secondary",children:r},r))})]}),!s.allowedTools&&!(s.metadata?.mcpServers&&s.metadata.mcpServers.length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Tools"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No specific tools configured - inherits all tools"})]})]})]})]})]})]})}export{U as default};