@lovelybunch/api 1.0.71 → 1.0.72

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 (271) hide show
  1. package/dist/lib/auth/auth-manager.d.ts.map +1 -0
  2. package/dist/lib/auth/auth-manager.js.map +1 -0
  3. package/dist/lib/gait-path.d.ts.map +1 -0
  4. package/dist/lib/gait-path.js.map +1 -0
  5. package/dist/lib/git-settings.d.ts.map +1 -0
  6. package/dist/lib/git-settings.js.map +1 -0
  7. package/dist/lib/git.d.ts.map +1 -0
  8. package/dist/lib/git.js.map +1 -0
  9. package/dist/lib/jobs/global-job-scheduler.d.ts.map +1 -0
  10. package/dist/lib/jobs/global-job-scheduler.js.map +1 -0
  11. package/dist/lib/jobs/job-runner.d.ts.map +1 -0
  12. package/dist/lib/jobs/job-runner.js.map +1 -0
  13. package/dist/lib/jobs/job-scheduler.d.ts.map +1 -0
  14. package/dist/lib/jobs/job-scheduler.js.map +1 -0
  15. package/dist/lib/jobs/job-store.d.ts.map +1 -0
  16. package/dist/lib/jobs/job-store.js.map +1 -0
  17. package/dist/lib/project-paths.d.ts.map +1 -0
  18. package/dist/lib/project-paths.js.map +1 -0
  19. package/dist/lib/storage/file-storage.d.ts.map +1 -0
  20. package/dist/lib/storage/file-storage.js.map +1 -0
  21. package/dist/lib/symlinks/symlink-manager.d.ts.map +1 -0
  22. package/dist/lib/symlinks/symlink-manager.js.map +1 -0
  23. package/dist/lib/symlinks/types.d.ts.map +1 -0
  24. package/dist/lib/symlinks/types.js.map +1 -0
  25. package/dist/lib/terminal/context-helper.d.ts +1 -1
  26. package/dist/lib/terminal/context-helper.d.ts.map +1 -0
  27. package/dist/lib/terminal/context-helper.js +4 -16
  28. package/dist/lib/terminal/context-helper.js.map +1 -0
  29. package/dist/lib/terminal/global-manager.d.ts.map +1 -0
  30. package/dist/lib/terminal/global-manager.js.map +1 -0
  31. package/dist/lib/terminal/shell-utils.d.ts.map +1 -0
  32. package/dist/lib/terminal/shell-utils.js.map +1 -0
  33. package/dist/lib/terminal/terminal-manager.d.ts.map +1 -0
  34. package/dist/lib/terminal/terminal-manager.js.map +1 -0
  35. package/dist/lib/user-preferences.d.ts.map +1 -0
  36. package/dist/lib/user-preferences.js.map +1 -0
  37. package/dist/middleware/auth.d.ts.map +1 -0
  38. package/dist/middleware/auth.js.map +1 -0
  39. package/dist/routes/api/v1/agents/[id]/index.d.ts.map +1 -0
  40. package/dist/routes/api/v1/agents/[id]/index.js.map +1 -0
  41. package/dist/routes/api/v1/agents/[id]/route.d.ts.map +1 -0
  42. package/dist/routes/api/v1/agents/[id]/route.js.map +1 -0
  43. package/dist/routes/api/v1/agents/index.d.ts.map +1 -0
  44. package/dist/routes/api/v1/agents/index.js.map +1 -0
  45. package/dist/routes/api/v1/agents/route.d.ts.map +1 -0
  46. package/dist/routes/api/v1/agents/route.js.map +1 -0
  47. package/dist/routes/api/v1/ai/index.d.ts.map +1 -0
  48. package/dist/routes/api/v1/ai/index.js.map +1 -0
  49. package/dist/routes/api/v1/ai/route.d.ts.map +1 -0
  50. package/dist/routes/api/v1/ai/route.js +134 -33
  51. package/dist/routes/api/v1/ai/route.js.map +1 -0
  52. package/dist/routes/api/v1/ai/tools.js +157 -34
  53. package/dist/routes/api/v1/api-keys/index.d.ts.map +1 -0
  54. package/dist/routes/api/v1/api-keys/index.js.map +1 -0
  55. package/dist/routes/api/v1/api-keys/route.d.ts.map +1 -0
  56. package/dist/routes/api/v1/api-keys/route.js.map +1 -0
  57. package/dist/routes/api/v1/auth/index.d.ts.map +1 -0
  58. package/dist/routes/api/v1/auth/index.js.map +1 -0
  59. package/dist/routes/api/v1/auth/route.d.ts.map +1 -0
  60. package/dist/routes/api/v1/auth/route.js.map +1 -0
  61. package/dist/routes/api/v1/auth-settings/index.d.ts.map +1 -0
  62. package/dist/routes/api/v1/auth-settings/index.js.map +1 -0
  63. package/dist/routes/api/v1/auth-settings/route.d.ts.map +1 -0
  64. package/dist/routes/api/v1/auth-settings/route.js.map +1 -0
  65. package/dist/routes/api/v1/chats/[id]/index.d.ts.map +1 -0
  66. package/dist/routes/api/v1/chats/[id]/index.js.map +1 -0
  67. package/dist/routes/api/v1/chats/[id]/route.d.ts.map +1 -0
  68. package/dist/routes/api/v1/chats/[id]/route.js.map +1 -0
  69. package/dist/routes/api/v1/chats/index.d.ts.map +1 -0
  70. package/dist/routes/api/v1/chats/index.js.map +1 -0
  71. package/dist/routes/api/v1/chats/route.d.ts.map +1 -0
  72. package/dist/routes/api/v1/chats/route.js.map +1 -0
  73. package/dist/routes/api/v1/config/index.d.ts.map +1 -0
  74. package/dist/routes/api/v1/config/index.js.map +1 -0
  75. package/dist/routes/api/v1/config/route.d.ts.map +1 -0
  76. package/dist/routes/api/v1/config/route.js.map +1 -0
  77. package/dist/routes/api/v1/context/architecture/route.d.ts.map +1 -0
  78. package/dist/routes/api/v1/context/architecture/route.js.map +1 -0
  79. package/dist/routes/api/v1/context/index.d.ts.map +1 -0
  80. package/dist/routes/api/v1/context/index.js +2 -0
  81. package/dist/routes/api/v1/context/index.js.map +1 -0
  82. package/dist/routes/api/v1/context/knowledge/[filename]/index.d.ts.map +1 -0
  83. package/dist/routes/api/v1/context/knowledge/[filename]/index.js.map +1 -0
  84. package/dist/routes/api/v1/context/knowledge/[filename]/route.d.ts.map +1 -0
  85. package/dist/routes/api/v1/context/knowledge/[filename]/route.js.map +1 -0
  86. package/dist/routes/api/v1/context/knowledge/index.d.ts.map +1 -0
  87. package/dist/routes/api/v1/context/knowledge/index.js.map +1 -0
  88. package/dist/routes/api/v1/context/knowledge/route.d.ts.map +1 -0
  89. package/dist/routes/api/v1/context/knowledge/route.js.map +1 -0
  90. package/dist/routes/api/v1/context/project/route.d.ts.map +1 -0
  91. package/dist/routes/api/v1/context/project/route.js.map +1 -0
  92. package/dist/routes/api/v1/context/role/route.d.ts +3 -0
  93. package/dist/routes/api/v1/context/role/route.js +198 -0
  94. package/dist/routes/api/v1/events/status/route.d.ts +1 -1
  95. package/dist/routes/api/v1/git/index.d.ts.map +1 -0
  96. package/dist/routes/api/v1/git/index.js.map +1 -0
  97. package/dist/routes/api/v1/jobs/[id]/route.d.ts.map +1 -0
  98. package/dist/routes/api/v1/jobs/[id]/route.js.map +1 -0
  99. package/dist/routes/api/v1/jobs/[id]/run/route.d.ts +2 -2
  100. package/dist/routes/api/v1/jobs/[id]/run/route.d.ts.map +1 -0
  101. package/dist/routes/api/v1/jobs/[id]/run/route.js.map +1 -0
  102. package/dist/routes/api/v1/jobs/[id]/runs/[runId]/route.d.ts +2 -2
  103. package/dist/routes/api/v1/jobs/index.d.ts.map +1 -0
  104. package/dist/routes/api/v1/jobs/index.js.map +1 -0
  105. package/dist/routes/api/v1/jobs/route.d.ts.map +1 -0
  106. package/dist/routes/api/v1/jobs/route.js.map +1 -0
  107. package/dist/routes/api/v1/jobs/status/route.d.ts +1 -1
  108. package/dist/routes/api/v1/jobs/status/route.d.ts.map +1 -0
  109. package/dist/routes/api/v1/jobs/status/route.js.map +1 -0
  110. package/dist/routes/api/v1/mcp/index.d.ts.map +1 -0
  111. package/dist/routes/api/v1/mcp/index.js +116 -3
  112. package/dist/routes/api/v1/mcp/index.js.map +1 -0
  113. package/dist/routes/api/v1/mcp/route.d.ts.map +1 -0
  114. package/dist/routes/api/v1/mcp/route.js.map +1 -0
  115. package/dist/routes/api/v1/proposals/[id]/route.d.ts +8 -8
  116. package/dist/routes/api/v1/proposals/[id]/route.d.ts.map +1 -0
  117. package/dist/routes/api/v1/proposals/[id]/route.js.map +1 -0
  118. package/dist/routes/api/v1/proposals/index.d.ts.map +1 -0
  119. package/dist/routes/api/v1/proposals/index.js.map +1 -0
  120. package/dist/routes/api/v1/proposals/route.d.ts.map +1 -0
  121. package/dist/routes/api/v1/proposals/route.js.map +1 -0
  122. package/dist/routes/api/v1/resources/[id]/index.d.ts.map +1 -0
  123. package/dist/routes/api/v1/resources/[id]/index.js.map +1 -0
  124. package/dist/routes/api/v1/resources/[id]/route.js.map +1 -0
  125. package/dist/routes/api/v1/resources/[id]/thumbnail/index.d.ts.map +1 -0
  126. package/dist/routes/api/v1/resources/[id]/thumbnail/index.js.map +1 -0
  127. package/dist/routes/api/v1/resources/[id]/thumbnail/route.js.map +1 -0
  128. package/dist/routes/api/v1/resources/generate/route.js +24 -3
  129. package/dist/routes/api/v1/resources/index.d.ts.map +1 -0
  130. package/dist/routes/api/v1/resources/index.js.map +1 -0
  131. package/dist/routes/api/v1/resources/route.d.ts.map +1 -0
  132. package/dist/routes/api/v1/resources/route.js.map +1 -0
  133. package/dist/routes/api/v1/symlinks/index.d.ts.map +1 -0
  134. package/dist/routes/api/v1/symlinks/index.js.map +1 -0
  135. package/dist/routes/api/v1/symlinks/route.d.ts.map +1 -0
  136. package/dist/routes/api/v1/symlinks/route.js.map +1 -0
  137. package/dist/routes/api/v1/terminal/[proposalId]/create/index.d.ts.map +1 -0
  138. package/dist/routes/api/v1/terminal/[proposalId]/create/index.js.map +1 -0
  139. package/dist/routes/api/v1/terminal/[proposalId]/create/route.d.ts.map +1 -0
  140. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js.map +1 -0
  141. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.d.ts.map +1 -0
  142. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.js.map +1 -0
  143. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.d.ts.map +1 -0
  144. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.js.map +1 -0
  145. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.d.ts.map +1 -0
  146. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.js.map +1 -0
  147. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.d.ts.map +1 -0
  148. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.js.map +1 -0
  149. package/dist/routes/api/v1/terminal/sessions/index.d.ts.map +1 -0
  150. package/dist/routes/api/v1/terminal/sessions/index.js.map +1 -0
  151. package/dist/routes/api/v1/terminal/sessions/route.d.ts.map +1 -0
  152. package/dist/routes/api/v1/terminal/sessions/route.js.map +1 -0
  153. package/dist/routes/api/v1/user/index.d.ts.map +1 -0
  154. package/dist/routes/api/v1/user/index.js.map +1 -0
  155. package/dist/routes/api/v1/user/settings/index.d.ts.map +1 -0
  156. package/dist/routes/api/v1/user/settings/index.js.map +1 -0
  157. package/dist/routes/api/v1/user/settings/route.d.ts.map +1 -0
  158. package/dist/routes/api/v1/user/settings/route.js.map +1 -0
  159. package/dist/server-with-static.d.ts.map +1 -0
  160. package/dist/server-with-static.js.map +1 -0
  161. package/dist/server.d.ts.map +1 -0
  162. package/dist/server.js.map +1 -0
  163. package/package.json +4 -4
  164. package/static/assets/ActivityPage-qJKqmwv7.js +1 -0
  165. package/static/assets/{AgentDetailPage-CZ2tz-Ol.js → AgentDetailPage-Dww8h17d.js} +1 -1
  166. package/static/assets/AgentEditPage-K6I9kvCf.js +1 -0
  167. package/static/assets/AgentsPage-nnMzCmw9.js +3 -0
  168. package/static/assets/AgentsSettingsPage-Dnkw87_8.js +6 -0
  169. package/static/assets/{ApiKeysSettingsPage-C7Xlzj-X.js → ApiKeysSettingsPage-DY0vNNSR.js} +3 -3
  170. package/static/assets/{ArchitectureEditPage-B9nVQn0B.js → ArchitectureEditPage-wx1LBCGC.js} +1 -1
  171. package/static/assets/ArchitecturePage-C4bkskmN.js +1 -0
  172. package/static/assets/{AuthSettingsPage-CaeV2cQ4.js → AuthSettingsPage-AXU_vx8p.js} +2 -2
  173. package/static/assets/{CallbackPage-DmeStBSx.js → CallbackPage-B6CJkdJu.js} +1 -1
  174. package/static/assets/CodePage-DGxzOKzh.js +2 -0
  175. package/static/assets/{CollapsibleSection-Cb80fCCb.js → CollapsibleSection-DgGytfeZ.js} +1 -1
  176. package/static/assets/DashboardPage-3PlgC6UV.js +41 -0
  177. package/static/assets/{GitPage-D2aJfzTq.js → GitPage-vBLrGiwG.js} +3 -3
  178. package/static/assets/{GitSettingsPage-Bz17VWrK.js → GitSettingsPage-D22W0fXd.js} +2 -2
  179. package/static/assets/{IdentityPage-O7o2b4JB.js → IdentityPage-B8xDJx3W.js} +3 -3
  180. package/static/assets/{ImplementationStepsEditor-BkJjQBc-.js → ImplementationStepsEditor-BY7wwwdO.js} +2 -2
  181. package/static/assets/IntegrationsSettingsPage-CSr-dlmL.js +1 -0
  182. package/static/assets/JobDetailPage-BUHRLYvQ.js +1 -0
  183. package/static/assets/KnowledgeDetailPage-8q-MYEOA.js +1 -0
  184. package/static/assets/{KnowledgeEditPage-DgyPoIJv.js → KnowledgeEditPage-Di63BhFz.js} +1 -1
  185. package/static/assets/{KnowledgePage-Ck_FeruK.js → KnowledgePage-BuEcOdou.js} +2 -2
  186. package/static/assets/{LoginPage-IqcnIlMj.js → LoginPage-CBRJBmlC.js} +1 -1
  187. package/static/assets/McpSettingsPage-gariusH3.js +1 -0
  188. package/static/assets/NewAgentPage-DDkFaqIq.js +1 -0
  189. package/static/assets/{NewKnowledgePage-xBm9PTKB.js → NewKnowledgePage-BqMSsS53.js} +2 -2
  190. package/static/assets/NewProposalPage-C77pO28o.js +90 -0
  191. package/static/assets/{ProjectEditPage-BlA-908F.js → ProjectEditPage-Dp5M7aXW.js} +1 -1
  192. package/static/assets/ProjectPage-BBL0XITa.js +1 -0
  193. package/static/assets/{PromptsSettingsPage-BvU01T7L.js → PromptsSettingsPage-DOcni_gq.js} +1 -1
  194. package/static/assets/ProposalDetailPage-5b6lLZRq.js +1 -0
  195. package/static/assets/ProposalEditPage-lm9wiiHa.js +1 -0
  196. package/static/assets/{ProposalsPage-erDBdH7Z.js → ProposalsPage-Dcms-16A.js} +2 -2
  197. package/static/assets/ResourcesPage-BGugJIYF.js +71 -0
  198. package/static/assets/RoleEditPage-DI1lGRK2.js +13 -0
  199. package/static/assets/RolePage-B1kmmDDF.js +1 -0
  200. package/static/assets/{RulesSettingsPage-DurFFm98.js → RulesSettingsPage-Br_c4fhl.js} +1 -1
  201. package/static/assets/SchedulePage-DMBddFXL.js +4 -0
  202. package/static/assets/SourceInput-BuPLoJuZ.js +1 -0
  203. package/static/assets/{TagInput-2_jYxO52.js → TagInput-CkZQYmnO.js} +1 -1
  204. package/static/assets/TerminalPage-CYqTT1pK.js +1 -0
  205. package/static/assets/{TerminalSessionPage-BjvQegW1.js → TerminalSessionPage-a9QWo08R.js} +4 -4
  206. package/static/assets/UserPreferencesPage-IVxOVtNk.js +1 -0
  207. package/static/assets/{UserSettingsPage-DhOu8xZ3.js → UserSettingsPage-Dsop4_yN.js} +1 -1
  208. package/static/assets/{UtilitiesPage-olcchfEX.js → UtilitiesPage-CZCmnyTp.js} +1 -1
  209. package/static/assets/{alert-bP1PxakB.js → alert-nipAjehb.js} +1 -1
  210. package/static/assets/{arrow-down-BoBPr1Sn.js → arrow-down-DQTEjf4E.js} +1 -1
  211. package/static/assets/{arrow-left-orDiJ2Pw.js → arrow-left-BgRi6mQL.js} +1 -1
  212. package/static/assets/{arrow-up-CCloQpeV.js → arrow-up-jLj_KhSo.js} +1 -1
  213. package/static/assets/{badge-D7styiB7.js → badge-CqnJU-OF.js} +1 -1
  214. package/static/assets/{browser-modal-n0MeSpgA.js → browser-modal-DBBFKngy.js} +2 -2
  215. package/static/assets/{calendar-w3geg78-.js → calendar-CA_W4UKa.js} +1 -1
  216. package/static/assets/{card-pzUJtmwJ.js → card-DdTVdbjN.js} +1 -1
  217. package/static/assets/{chevron-left-B6nXpDLi.js → chevron-left-CM04t09S.js} +1 -1
  218. package/static/assets/chevrons-up-DgSgy4LT.js +11 -0
  219. package/static/assets/{circle-alert-BcFpY-ZU.js → circle-alert-UErAnUQ-.js} +1 -1
  220. package/static/assets/{circle-check-HRharHjy.js → circle-check-2oo3aeGx.js} +1 -1
  221. package/static/assets/{circle-check-big-B2CFEks4.js → circle-check-big-CQsXU9Fx.js} +1 -1
  222. package/static/assets/{circle-play-CfrNAC9J.js → circle-play-BHGmBl9H.js} +1 -1
  223. package/static/assets/{circle-x-CNn7_0Ew.js → circle-x-DoAXluPx.js} +1 -1
  224. package/static/assets/{clipboard-LaXihY2m.js → clipboard-NaRSfq4S.js} +1 -1
  225. package/static/assets/{clock-By2Dd4u0.js → clock-C1lOY_Qr.js} +1 -1
  226. package/static/assets/{download--HiFU7TR.js → download-Co1Xt7Td.js} +1 -1
  227. package/static/assets/droid-Caom7ttu.js +4 -0
  228. package/static/assets/{eye-DorygWtP.js → eye-54QpT_B-.js} +1 -1
  229. package/static/assets/{folder-git-2-B8bjLoxc.js → folder-git-2-x65JY04J.js} +1 -1
  230. package/static/assets/index-BhlZ_D1Y.css +2 -0
  231. package/static/assets/index-VBSAUXJg.js +468 -0
  232. package/static/assets/{label-CTlQtJaU.js → label-C6P6J-NS.js} +1 -1
  233. package/static/assets/{markdown-editor-BOcltq2r.js → markdown-editor-CgzPMMiE.js} +1 -1
  234. package/static/assets/{pause-D33aM-oa.js → pause-CU8WFOyJ.js} +1 -1
  235. package/static/assets/{play-B6IdXHPj.js → play-nlXIUG-M.js} +1 -1
  236. package/static/assets/{plus-DhYjijTS.js → plus-nBUooJPr.js} +1 -1
  237. package/static/assets/{radio-group-B-Rc5x_L.js → radio-group-CQVEYWSk.js} +1 -1
  238. package/static/assets/{refresh-cw-BuuX9h4Z.js → refresh-cw-ChsHXM-C.js} +1 -1
  239. package/static/assets/{search-BiMN-o92.js → search-ygMlQfjH.js} +1 -1
  240. package/static/assets/{switch-vSV_roZ2.js → switch-BcjQDy93.js} +1 -1
  241. package/static/assets/{tabs-ChuwGq16.js → tabs-B2pmN66L.js} +1 -1
  242. package/static/assets/{tag-DERlGH35.js → tag-BEI3zSmE.js} +1 -1
  243. package/static/assets/terminal-preview-_bKoIC7R.js +1 -0
  244. package/static/assets/{use-terminal-qzkum-B5.js → use-terminal-DKszJuOd.js} +1 -1
  245. package/static/assets/{zap-DwFz_ltU.js → zap-w4hozPoR.js} +1 -1
  246. package/static/index.html +2 -2
  247. package/dist/lib/mcp-client.d.ts +0 -39
  248. package/dist/lib/mcp-client.js +0 -131
  249. package/static/assets/AgentEditPage-BiAoWU1z.js +0 -1
  250. package/static/assets/AgentsPage-D_HMA-40.js +0 -3
  251. package/static/assets/AgentsSettingsPage-C5ZsOVSL.js +0 -6
  252. package/static/assets/ArchitecturePage-CChIC6Qa.js +0 -1
  253. package/static/assets/CodePage-BtKkipWC.js +0 -2
  254. package/static/assets/DashboardPage-DdApq_B-.js +0 -11
  255. package/static/assets/IntegrationsSettingsPage-brFTXUBL.js +0 -1
  256. package/static/assets/KnowledgeDetailPage-e5OpRrZ2.js +0 -1
  257. package/static/assets/McpSettingsPage-KJBLTelP.js +0 -1
  258. package/static/assets/NewAgentPage-DLIvDpeZ.js +0 -1
  259. package/static/assets/NewProposalPage-BlocVyGv.js +0 -90
  260. package/static/assets/ProjectPage-Dj-tc-ZE.js +0 -1
  261. package/static/assets/ProposalDetailPage-_8Wn6NJt.js +0 -1
  262. package/static/assets/ProposalEditPage-BbbWkAuu.js +0 -1
  263. package/static/assets/ResourcesPage-B1uF-EA-.js +0 -71
  264. package/static/assets/SchedulePage-BAnM4Lu5.js +0 -4
  265. package/static/assets/SourceInput-7lTShZ6_.js +0 -1
  266. package/static/assets/TerminalPage-CRVEtFXr.js +0 -1
  267. package/static/assets/UserPreferencesPage-C5ueVUwG.js +0 -1
  268. package/static/assets/droid-C6RWH9f4.js +0 -4
  269. package/static/assets/index-B5SwW-PH.css +0 -2
  270. package/static/assets/index-BfJaT17z.js +0 -458
  271. package/static/assets/terminal-preview-BFedy4-J.js +0 -11
@@ -0,0 +1 @@
1
+ import{Q as R,u as U,a as H,r as o,A as P,j as e,B as m,L as x,I as O,h as T,i as I,k as L,l as D,m as r,X as V,a8 as _}from"./index-VBSAUXJg.js";import{L as j}from"./label-C6P6J-NS.js";import{C as f,b as F,a as v,c as q,d as J}from"./card-DdTVdbjN.js";import{M as K}from"./markdown-editor-CgzPMMiE.js";import{C as Q}from"./CollapsibleSection-DgGytfeZ.js";import{I as W,L as X}from"./ImplementationStepsEditor-BY7wwwdO.js";import{T as G}from"./TagInput-CkZQYmnO.js";import{A as N}from"./arrow-left-BgRi6mQL.js";import"./plus-nBUooJPr.js";import"./badge-CqnJU-OF.js";function oe(){const{id:i}=R(),$=U(),{toast:y}=H(),[z,S]=o.useState(!0),[h,C]=o.useState(!1),[w,b]=o.useState(null),[n,d]=o.useState({intent:"",description:"",priority:"medium",status:"draft",author:{id:"current-user",name:"Current User",email:"user@example.com"}}),[p,E]=o.useState([]),[k,A]=o.useState([]);o.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${P}/api/v1/proposals/${i}`),s=await t.json();if(s.success||s.data||t.ok){const a=s.data||s;d({intent:a.intent||"",description:a.content||"",priority:a.metadata?.priority||"medium",status:a.status||"draft",author:{id:a.author?.id||"current-user",name:a.author?.name||"Current User",email:a.author?.email||"user@example.com"}});const g=Array.isArray(a.planSteps)?a.planSteps:[];E(g.map((c,u)=>({id:c.id||`step-${u+1}`,description:c.description||"",status:c.status||"pending"}))),A(a.metadata?.tags||[])}else b(s.error?.message||"Failed to fetch proposal")}catch(t){b(t instanceof Error?t.message:"An error occurred")}finally{S(!1)}},M=async t=>{t.preventDefault(),C(!0);try{const s=p.map(l=>({id:l.id,description:l.description.trim(),status:l.status})).filter(l=>l.description.length>0),a=k.map(l=>l.trim()).filter(l=>l.length>0),g={intent:n.intent,status:n.status,planSteps:s,metadata:{priority:n.priority,tags:a},content:n.description},c=await fetch(`${P}/api/v1/proposals/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),u=await c.json();if(u.success||c.ok)y({title:"Success",description:"Proposal updated successfully."}),$(`/proposals/${i}`);else throw new Error(u.error?.message||"Failed to update proposal")}catch(s){y({title:"Error",description:`Failed to update proposal: ${s instanceof Error?s.message:"An error occurred"}`,variant:"destructive"})}finally{C(!1)}};return z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Proposal"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading proposal data..."})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:`/proposals/${i}`,className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsxs(f,{children:[e.jsx(F,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-6 bg-muted rounded w-1/2 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-3/4 animate-pulse"})]})}),e.jsx(v,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-10 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-64 bg-muted rounded animate-pulse"})]})})]})]}):w?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx(f,{children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:w})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Proposal"}),e.jsxs("p",{className:"text-muted-foreground",children:["Editing ",i]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(m,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(x,{to:`/proposals/${i}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx("form",{onSubmit:M,children:e.jsxs(f,{children:[e.jsxs(F,{children:[e.jsx(q,{children:"Task Details"}),e.jsx(J,{children:"Update the information for your change proposal"})]}),e.jsxs(v,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"intent",children:"Intent *"}),e.jsx(O,{id:"intent",placeholder:"Brief description of what you want to change",value:n.intent,onChange:t=>d(s=>({...s,intent:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"description",children:"Description"}),e.jsx(K,{value:n.description,onChange:t=>d(s=>({...s,description:t||""})),placeholder:"Write your proposal description in markdown...",height:400})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"status",children:"Status"}),e.jsxs(T,{value:n.status,onValueChange:t=>d(s=>({...s,status:t})),children:[e.jsx(I,{children:e.jsx(L,{placeholder:"Select status"})}),e.jsxs(D,{children:[e.jsx(r,{value:"draft",children:"Draft"}),e.jsx(r,{value:"proposed",children:"Proposed"}),e.jsx(r,{value:"in-review",children:"In Review"}),e.jsx(r,{value:"approved",children:"Approved"}),e.jsx(r,{value:"code-complete",children:"Code Complete"}),e.jsx(r,{value:"rejected",children:"Rejected"}),e.jsx(r,{value:"merged",children:"Merged"})]})]})]}),e.jsx(Q,{defaultOpen:!0,icon:e.jsx(X,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"priority",children:"Priority"}),e.jsxs(T,{value:n.priority,onValueChange:t=>d(s=>({...s,priority:t})),children:[e.jsx(I,{children:e.jsx(L,{placeholder:"Select priority"})}),e.jsxs(D,{children:[e.jsx(r,{value:"low",children:"Low"}),e.jsx(r,{value:"medium",children:"Medium"}),e.jsx(r,{value:"high",children:"High"}),e.jsx(r,{value:"critical",children:"Critical"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Implementation Steps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Keep the implementation plan accurate as work progresses."})]}),p.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.length," step",p.length===1?"":"s"]})]}),e.jsx(W,{steps:p,onChange:E,disabled:h})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Tags"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tags power filtering and discovery across the proposal list."}),e.jsx(G,{tags:k,onChange:A,disabled:h,placeholder:"Add a tag (e.g. backend, rollout)"})]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(m,{type:"button",variant:"outline",asChild:!0,children:e.jsxs(x,{to:`/proposals/${i}`,children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Cancel"]})}),e.jsx(m,{type:"submit",disabled:h||!n.intent,children:h?e.jsx(e.Fragment,{children:"Saving..."}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})]})]})]})})]})}export{oe as ProposalEditPage};
@@ -1,4 +1,4 @@
1
- import{c as xe,o as _e,u as Ie,l as Le,r as j,j as t,B as V,L as Y,I as Re,X,K as Pe,p as Oe,q as $e,s as Te,v as ie,w as ae,x as ce,y as ue,z as w,G as Ke,A as ze}from"./index-BfJaT17z.js";import{C as J,b as Ve,a as Z,c as We}from"./card-pzUJtmwJ.js";import{B as q}from"./badge-D7styiB7.js";import{P as ee}from"./plus-DhYjijTS.js";import{S as Ue}from"./search-BiMN-o92.js";/**
1
+ import{c as xe,O as _e,u as Ie,z as Le,r as j,j as t,B as V,L as Y,I as Re,X,K as Te,y as Oe,P as $e,v as Pe,h as ie,i as ae,k as ce,l as ue,m as w,G as Ke,A as ze}from"./index-VBSAUXJg.js";import{C as J,b as Ve,a as Z,c as We}from"./card-DdTVdbjN.js";import{B as q}from"./badge-CqnJU-OF.js";import{P as ee}from"./plus-nBUooJPr.js";import{S as Ue}from"./search-ygMlQfjH.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -13,5 +13,5 @@ import{c as xe,o as _e,u as Ie,l as Le,r as j,j as t,B as V,L as Y,I as Re,X,K a
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 Xe=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Ae=xe("funnel",Xe);function P(s){return Array.isArray?Array.isArray(s):be(s)==="[object Array]"}function Je(s){if(typeof s=="string")return s;let e=s+"";return e=="0"&&1/s==-1/0?"-0":e}function Ze(s){return s==null?"":Je(s)}function R(s){return typeof s=="string"}function ve(s){return typeof s=="number"}function qe(s){return s===!0||s===!1||et(s)&&be(s)=="[object Boolean]"}function Ee(s){return typeof s=="object"}function et(s){return Ee(s)&&s!==null}function S(s){return s!=null}function le(s){return!s.trim().length}function be(s){return s==null?s===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(s)}const tt="Incorrect 'index' type",st=s=>`Invalid value for key ${s}`,rt=s=>`Pattern length exceeds max of ${s}.`,nt=s=>`Missing ${s} property in key`,it=s=>`Property 'weight' in key '${s}' must be a positive integer`,je=Object.prototype.hasOwnProperty;class at{constructor(e){this._keys=[],this._keyMap={};let r=0;e.forEach(n=>{let i=Fe(n);this._keys.push(i),this._keyMap[i.id]=i,r+=i.weight}),this._keys.forEach(n=>{n.weight/=r})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Fe(s){let e=null,r=null,n=null,i=1,a=null;if(R(s)||P(s))n=s,e=ye(s),r=oe(s);else{if(!je.call(s,"name"))throw new Error(nt("name"));const c=s.name;if(n=c,je.call(s,"weight")&&(i=s.weight,i<=0))throw new Error(it(c));e=ye(c),r=oe(c),a=s.getFn}return{path:e,id:r,weight:i,src:n,getFn:a}}function ye(s){return P(s)?s:s.split(".")}function oe(s){return P(s)?s.join("."):s}function ct(s,e){let r=[],n=!1;const i=(a,c,l)=>{if(S(a))if(!c[l])r.push(a);else{let o=c[l];const h=a[o];if(!S(h))return;if(l===c.length-1&&(R(h)||ve(h)||qe(h)))r.push(Ze(h));else if(P(h)){n=!0;for(let d=0,m=h.length;d<m;d+=1)i(h[d],c,l+1)}else c.length&&i(h,c,l+1)}};return i(s,R(e)?e.split("."):e,0),n?r:r[0]}const ut={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},lt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(s,e)=>s.score===e.score?s.idx<e.idx?-1:1:s.score<e.score?-1:1},ot={location:0,threshold:.6,distance:100},ht={useExtendedSearch:!1,getFn:ct,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var f={...lt,...ut,...ot,...ht};const dt=/[^ ]+/g;function ft(s=1,e=3){const r=new Map,n=Math.pow(10,e);return{get(i){const a=i.match(dt).length;if(r.has(a))return r.get(a);const c=1/Math.pow(a,.5*s),l=parseFloat(Math.round(c*n)/n);return r.set(a,l),l},clear(){r.clear()}}}class pe{constructor({getFn:e=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){this.norm=ft(r,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((r,n)=>{this._keysMap[r.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,R(this.docs[0])?this.docs.forEach((e,r)=>{this._addString(e,r)}):this.docs.forEach((e,r)=>{this._addObject(e,r)}),this.norm.clear())}add(e){const r=this.size();R(e)?this._addString(e,r):this._addObject(e,r)}removeAt(e){this.records.splice(e,1);for(let r=e,n=this.size();r<n;r+=1)this.records[r].i-=1}getValueForItemAtKeyId(e,r){return e[this._keysMap[r]]}size(){return this.records.length}_addString(e,r){if(!S(e)||le(e))return;let n={v:e,i:r,n:this.norm.get(e)};this.records.push(n)}_addObject(e,r){let n={i:r,$:{}};this.keys.forEach((i,a)=>{let c=i.getFn?i.getFn(e):this.getFn(e,i.path);if(S(c)){if(P(c)){let l=[];const o=[{nestedArrIndex:-1,value:c}];for(;o.length;){const{nestedArrIndex:h,value:d}=o.pop();if(S(d))if(R(d)&&!le(d)){let m={v:d,i:h,n:this.norm.get(d)};l.push(m)}else P(d)&&d.forEach((m,x)=>{o.push({nestedArrIndex:x,value:m})})}n.$[a]=l}else if(R(c)&&!le(c)){let l={v:c,n:this.norm.get(c)};n.$[a]=l}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Me(s,e,{getFn:r=f.getFn,fieldNormWeight:n=f.fieldNormWeight}={}){const i=new pe({getFn:r,fieldNormWeight:n});return i.setKeys(s.map(Fe)),i.setSources(e),i.create(),i}function mt(s,{getFn:e=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){const{keys:n,records:i}=s,a=new pe({getFn:e,fieldNormWeight:r});return a.setKeys(n),a.setIndexRecords(i),a}function te(s,{errors:e=0,currentLocation:r=0,expectedLocation:n=0,distance:i=f.distance,ignoreLocation:a=f.ignoreLocation}={}){const c=e/s.length;if(a)return c;const l=Math.abs(n-r);return i?c+l/i:l?1:c}function gt(s=[],e=f.minMatchCharLength){let r=[],n=-1,i=-1,a=0;for(let c=s.length;a<c;a+=1){let l=s[a];l&&n===-1?n=a:!l&&n!==-1&&(i=a-1,i-n+1>=e&&r.push([n,i]),n=-1)}return s[a-1]&&a-n>=e&&r.push([n,a-1]),r}const W=32;function xt(s,e,r,{location:n=f.location,distance:i=f.distance,threshold:a=f.threshold,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,includeMatches:o=f.includeMatches,ignoreLocation:h=f.ignoreLocation}={}){if(e.length>W)throw new Error(rt(W));const d=e.length,m=s.length,x=Math.max(0,Math.min(n,m));let g=a,A=x;const C=l>1||o,M=C?Array(m):[];let E;for(;(E=s.indexOf(e,A))>-1;){let F=te(e,{currentLocation:E,expectedLocation:x,distance:i,ignoreLocation:h});if(g=Math.min(F,g),A=E+d,C){let k=0;for(;k<d;)M[E+k]=1,k+=1}}A=-1;let _=[],b=1,L=d+m;const G=1<<d-1;for(let F=0;F<d;F+=1){let k=0,y=L;for(;k<y;)te(e,{errors:F,currentLocation:x+y,expectedLocation:x,distance:i,ignoreLocation:h})<=g?k=y:L=y,y=Math.floor((L-k)/2+k);L=y;let z=Math.max(1,x-y+1),O=c?m:Math.min(x+y,m)+d,I=Array(O+2);I[O+1]=(1<<F)-1;for(let D=O;D>=z;D-=1){let $=D-1,Q=r[s.charAt($)];if(C&&(M[$]=+!!Q),I[D]=(I[D+1]<<1|1)&Q,F&&(I[D]|=(_[D+1]|_[D])<<1|1|_[D+1]),I[D]&G&&(b=te(e,{errors:F,currentLocation:$,expectedLocation:x,distance:i,ignoreLocation:h}),b<=g)){if(g=b,A=$,A<=x)break;z=Math.max(1,2*x-A)}}if(te(e,{errors:F+1,currentLocation:x,expectedLocation:x,distance:i,ignoreLocation:h})>g)break;_=I}const H={isMatch:A>=0,score:Math.max(.001,b)};if(C){const F=gt(M,l);F.length?o&&(H.indices=F):H.isMatch=!1}return H}function pt(s){let e={};for(let r=0,n=s.length;r<n;r+=1){const i=s.charAt(r);e[i]=(e[i]||0)|1<<n-r-1}return e}const se=String.prototype.normalize?(s=>s.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(s=>s);class De{constructor(e,{location:r=f.location,threshold:n=f.threshold,distance:i=f.distance,includeMatches:a=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,isCaseSensitive:o=f.isCaseSensitive,ignoreDiacritics:h=f.ignoreDiacritics,ignoreLocation:d=f.ignoreLocation}={}){if(this.options={location:r,threshold:n,distance:i,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d},e=o?e:e.toLowerCase(),e=h?se(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const m=(g,A)=>{this.chunks.push({pattern:g,alphabet:pt(g),startIndex:A})},x=this.pattern.length;if(x>W){let g=0;const A=x%W,C=x-A;for(;g<C;)m(this.pattern.substr(g,W),g),g+=W;if(A){const M=x-W;m(this.pattern.substr(M),M)}}else m(this.pattern,0)}searchIn(e){const{isCaseSensitive:r,ignoreDiacritics:n,includeMatches:i}=this.options;if(e=r?e:e.toLowerCase(),e=n?se(e):e,this.pattern===e){let C={isMatch:!0,score:0};return i&&(C.indices=[[0,e.length-1]]),C}const{location:a,distance:c,threshold:l,findAllMatches:o,minMatchCharLength:h,ignoreLocation:d}=this.options;let m=[],x=0,g=!1;this.chunks.forEach(({pattern:C,alphabet:M,startIndex:E})=>{const{isMatch:_,score:b,indices:L}=xt(e,C,M,{location:a+E,distance:c,threshold:l,findAllMatches:o,minMatchCharLength:h,includeMatches:i,ignoreLocation:d});_&&(g=!0),x+=b,_&&L&&(m=[...m,...L])});let A={isMatch:g,score:g?x/this.chunks.length:1};return g&&i&&(A.indices=m),A}}class K{constructor(e){this.pattern=e}static isMultiMatch(e){return Ce(e,this.multiRegex)}static isSingleMatch(e){return Ce(e,this.singleRegex)}search(){}}function Ce(s,e){const r=s.match(e);return r?r[1]:null}class At extends K{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const r=e===this.pattern;return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class jt extends K{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class yt extends K{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const r=e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class Ct extends K{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const r=!e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class wt extends K{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const r=e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Nt extends K{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const r=!e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class Be extends K{constructor(e,{location:r=f.location,threshold:n=f.threshold,distance:i=f.distance,includeMatches:a=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,isCaseSensitive:o=f.isCaseSensitive,ignoreDiacritics:h=f.ignoreDiacritics,ignoreLocation:d=f.ignoreLocation}={}){super(e),this._bitapSearch=new De(e,{location:r,threshold:n,distance:i,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class Se extends K{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let r=0,n;const i=[],a=this.pattern.length;for(;(n=e.indexOf(this.pattern,r))>-1;)r=n+a,i.push([n,r-1]);const c=!!i.length;return{isMatch:c,score:c?0:1,indices:i}}}const he=[At,Se,yt,Ct,Nt,wt,jt,Be],we=he.length,vt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Et="|";function bt(s,e={}){return s.split(Et).map(r=>{let n=r.trim().split(vt).filter(a=>a&&!!a.trim()),i=[];for(let a=0,c=n.length;a<c;a+=1){const l=n[a];let o=!1,h=-1;for(;!o&&++h<we;){const d=he[h];let m=d.isMultiMatch(l);m&&(i.push(new d(m,e)),o=!0)}if(!o)for(h=-1;++h<we;){const d=he[h];let m=d.isSingleMatch(l);if(m){i.push(new d(m,e));break}}}return i})}const Ft=new Set([Be.type,Se.type]);class Mt{constructor(e,{isCaseSensitive:r=f.isCaseSensitive,ignoreDiacritics:n=f.ignoreDiacritics,includeMatches:i=f.includeMatches,minMatchCharLength:a=f.minMatchCharLength,ignoreLocation:c=f.ignoreLocation,findAllMatches:l=f.findAllMatches,location:o=f.location,threshold:h=f.threshold,distance:d=f.distance}={}){this.query=null,this.options={isCaseSensitive:r,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:a,findAllMatches:l,ignoreLocation:c,location:o,threshold:h,distance:d},e=r?e:e.toLowerCase(),e=n?se(e):e,this.pattern=e,this.query=bt(this.pattern,this.options)}static condition(e,r){return r.useExtendedSearch}searchIn(e){const r=this.query;if(!r)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:a}=this.options;e=i?e:e.toLowerCase(),e=a?se(e):e;let c=0,l=[],o=0;for(let h=0,d=r.length;h<d;h+=1){const m=r[h];l.length=0,c=0;for(let x=0,g=m.length;x<g;x+=1){const A=m[x],{isMatch:C,indices:M,score:E}=A.search(e);if(C){if(c+=1,o+=E,n){const _=A.constructor.type;Ft.has(_)?l=[...l,...M]:l.push(M)}}else{o=0,c=0,l.length=0;break}}if(c){let x={isMatch:!0,score:o/c};return n&&(x.indices=l),x}}return{isMatch:!1,score:1}}}const de=[];function Dt(...s){de.push(...s)}function fe(s,e){for(let r=0,n=de.length;r<n;r+=1){let i=de[r];if(i.condition(s,e))return new i(s,e)}return new De(s,e)}const re={AND:"$and",OR:"$or"},me={PATH:"$path",PATTERN:"$val"},ge=s=>!!(s[re.AND]||s[re.OR]),Bt=s=>!!s[me.PATH],St=s=>!P(s)&&Ee(s)&&!ge(s),Ne=s=>({[re.AND]:Object.keys(s).map(e=>({[e]:s[e]}))});function ke(s,e,{auto:r=!0}={}){const n=i=>{let a=Object.keys(i);const c=Bt(i);if(!c&&a.length>1&&!ge(i))return n(Ne(i));if(St(i)){const o=c?i[me.PATH]:a[0],h=c?i[me.PATTERN]:i[o];if(!R(h))throw new Error(st(o));const d={keyId:oe(o),pattern:h};return r&&(d.searcher=fe(h,e)),d}let l={children:[],operator:a[0]};return a.forEach(o=>{const h=i[o];P(h)&&h.forEach(d=>{l.children.push(n(d))})}),l};return ge(s)||(s=Ne(s)),n(s)}function kt(s,{ignoreFieldNorm:e=f.ignoreFieldNorm}){s.forEach(r=>{let n=1;r.matches.forEach(({key:i,norm:a,score:c})=>{const l=i?i.weight:null;n*=Math.pow(c===0&&l?Number.EPSILON:c,(l||1)*(e?1:a))}),r.score=n})}function _t(s,e){const r=s.matches;e.matches=[],S(r)&&r.forEach(n=>{if(!S(n.indices)||!n.indices.length)return;const{indices:i,value:a}=n;let c={indices:i,value:a};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function It(s,e){e.score=s.score}function Lt(s,e,{includeMatches:r=f.includeMatches,includeScore:n=f.includeScore}={}){const i=[];return r&&i.push(_t),n&&i.push(It),s.map(a=>{const{idx:c}=a,l={item:e[c],refIndex:c};return i.length&&i.forEach(o=>{o(a,l)}),l})}class U{constructor(e,r={},n){this.options={...f,...r},this.options.useExtendedSearch,this._keyStore=new at(this.options.keys),this.setCollection(e,n)}setCollection(e,r){if(this._docs=e,r&&!(r instanceof pe))throw new Error(tt);this._myIndex=r||Me(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){S(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const r=[];for(let n=0,i=this._docs.length;n<i;n+=1){const a=this._docs[n];e(a,n)&&(this.removeAt(n),n-=1,i-=1,r.push(a))}return r}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:r=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:a,sortFn:c,ignoreFieldNorm:l}=this.options;let o=R(e)?R(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return kt(o,{ignoreFieldNorm:l}),a&&o.sort(c),ve(r)&&r>-1&&(o=o.slice(0,r)),Lt(o,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(e){const r=fe(e,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:a,i:c,n:l})=>{if(!S(a))return;const{isMatch:o,score:h,indices:d}=r.searchIn(a);o&&i.push({item:a,idx:c,matches:[{score:h,value:a,norm:l,indices:d}]})}),i}_searchLogical(e){const r=ke(e,this.options),n=(l,o,h)=>{if(!l.children){const{keyId:m,searcher:x}=l,g=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(o,m),searcher:x});return g&&g.length?[{idx:h,item:o,matches:g}]:[]}const d=[];for(let m=0,x=l.children.length;m<x;m+=1){const g=l.children[m],A=n(g,o,h);if(A.length)d.push(...A);else if(l.operator===re.AND)return[]}return d},i=this._myIndex.records,a={},c=[];return i.forEach(({$:l,i:o})=>{if(S(l)){let h=n(r,l,o);h.length&&(a[o]||(a[o]={idx:o,item:l,matches:[]},c.push(a[o])),h.forEach(({matches:d})=>{a[o].matches.push(...d)}))}}),c}_searchObjectList(e){const r=fe(e,this.options),{keys:n,records:i}=this._myIndex,a=[];return i.forEach(({$:c,i:l})=>{if(!S(c))return;let o=[];n.forEach((h,d)=>{o.push(...this._findMatches({key:h,value:c[d],searcher:r}))}),o.length&&a.push({idx:l,item:c,matches:o})}),a}_findMatches({key:e,value:r,searcher:n}){if(!S(r))return[];let i=[];if(P(r))r.forEach(({v:a,i:c,n:l})=>{if(!S(a))return;const{isMatch:o,score:h,indices:d}=n.searchIn(a);o&&i.push({score:h,key:e,value:a,idx:c,norm:l,indices:d})});else{const{v:a,n:c}=r,{isMatch:l,score:o,indices:h}=n.searchIn(a);l&&i.push({score:o,key:e,value:a,norm:c,indices:h})}return i}}U.version="7.1.0";U.createIndex=Me;U.parseIndex=mt;U.config=f;U.parseQuery=ke;Dt(Mt);function Rt(s){switch(s){case"approved":case"code-complete":return"default";case"in-review":return"secondary";case"rejected":return"destructive";default:return"outline"}}function Pt(s){switch(s){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function Vt(){const[s]=_e(),e=Ie(),r=Le(),[n,i]=j.useState([]),[a,c]=j.useState([]),[l,o]=j.useState(!0),[h,d]=j.useState(null),[m,x]=j.useState(s.get("status")||"active"),[g,A]=j.useState(s.get("priority")||"all"),[C,M]=j.useState(s.get("search")||""),[E,_]=j.useState(s.get("sortBy")||"created"),[b,L]=j.useState(s.get("order")||"desc"),[G,H]=j.useState(!1),F=j.useRef(null),k=[m!=="active",g!=="all",E!=="created",b!=="desc"].filter(Boolean).length,y=j.useCallback(u=>{const p=new URLSearchParams(s);Object.entries(u).forEach(([B,T])=>{T&&T!=="all"&&T!=="active"&&T!==""?p.set(B,T):p.delete(B)});const N=p.toString(),v=N?`?${N}`:"";e(`${r.pathname}${v}`)},[s,e,r.pathname]),z=j.useCallback(u=>{x(u),y({status:u==="active"?null:u})},[y]),O=j.useCallback(u=>{A(u),y({priority:u==="all"?null:u})},[y]),I=j.useCallback(u=>{M(u),y({search:u||null})},[y]),ne=j.useCallback(u=>{_(u),y({sortBy:u==="created"?null:u})},[y]),D=j.useCallback(()=>{const u=b==="asc"?"desc":"asc";L(u),y({order:u==="desc"?null:u})},[b,y]),$=j.useCallback(u=>{if(u.key==="s"||u.key==="S"){const p=document.activeElement;p?.tagName==="INPUT"||p?.tagName==="TEXTAREA"||p?.getAttribute("contenteditable")==="true"||(u.preventDefault(),F.current?.focus())}},[]);j.useEffect(()=>(document.addEventListener("keydown",$),()=>{document.removeEventListener("keydown",$)}),[$]);const Q=j.useMemo(()=>{const u={keys:[{name:"intent",weight:.4},{name:"id",weight:.3},{name:"author.name",weight:.2},{name:"metadata.tags",weight:.1}],threshold:.3,includeScore:!0};return new U(n,u)},[n]);return j.useEffect(()=>{async function u(){try{o(!0);const N=await(await fetch(`${ze}/api/v1/proposals`)).json();N.success?(i(N.data),c(N.data)):d(N.error?.message||"Failed to fetch proposals")}catch(p){d(p instanceof Error?p.message:"Unknown error")}finally{o(!1)}}u()},[]),j.useEffect(()=>{let u=n;if(m==="active"?u=u.filter(p=>["draft","proposed","in-review","approved","code-complete"].includes(p.status)):m==="approved"?u=u.filter(p=>["approved","code-complete"].includes(p.status)):m!=="all"&&(u=u.filter(p=>p.status===m)),g!=="all"&&(u=u.filter(p=>p.metadata.priority===g)),C.trim()){const p=Q.search(C),N=new Set(p.map(v=>v.item.id));u=u.filter(v=>N.has(v.id))}u=u.sort((p,N)=>{let v,B;switch(E){case"created":{v=new Date(p.metadata.createdAt).getTime(),B=new Date(N.metadata.createdAt).getTime();break}case"updated":{v=new Date(p.metadata.updatedAt).getTime(),B=new Date(N.metadata.updatedAt).getTime();break}case"status":{v=p.status,B=N.status;break}case"priority":{const T={critical:4,high:3,medium:2,low:1};v=T[p.metadata.priority]||0,B=T[N.metadata.priority]||0;break}case"intent":{v=p.intent.toLowerCase(),B=N.intent.toLowerCase();break}default:v=new Date(p.metadata.createdAt).getTime(),B=new Date(N.metadata.createdAt).getTime()}return b==="asc"?v<B?-1:v>B?1:0:v>B?-1:v<B?1:0}),c(u)},[n,m,g,C,E,b,Q]),l?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Proposals"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage change proposals for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Proposal"]})})]}),t.jsx("div",{className:"space-y-4",children:[...Array(3)].map((u,p)=>t.jsx(J,{children:t.jsx(Ve,{children:t.jsxs("div",{className:"flex justify-between items-start",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-6 bg-muted rounded w-3/4 animate-pulse"}),t.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]}),t.jsx("div",{className:"h-6 bg-muted rounded w-20 animate-pulse"})]})})},p))})]}):h?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Proposals"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage change proposals for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Proposal"]})})]}),t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsx("div",{className:"text-center",children:t.jsxs("p",{className:"text-destructive",children:["Error: ",h]})})})})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Proposals"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage change proposals for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Proposal"]})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx(Ue,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),t.jsx(Re,{ref:F,placeholder:"Search proposals...",value:C,onChange:u=>I(u.target.value),className:"pl-9 pr-20 h-11 bg-muted/40 border-muted-foreground/20 focus:bg-background transition-colors"}),t.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2",children:C?t.jsx("button",{onClick:()=>I(""),className:"h-5 w-5 rounded-full bg-muted-foreground/20 hover:bg-muted-foreground/30 flex items-center justify-center transition-colors",children:t.jsx(X,{className:"h-3 w-3"})}):t.jsx(Pe,{children:t.jsx(Oe,{children:"S"})})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:()=>H(!G),className:"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg border border-muted-foreground/20 hover:bg-muted/50 transition-colors",children:[t.jsx(Ae,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Filters & Sort"}),t.jsx("span",{className:"sm:hidden",children:"Filters"}),k>0&&t.jsx("span",{className:"flex items-center justify-center h-5 w-5 text-xs font-bold rounded-full bg-primary text-primary-foreground",children:k}),G?t.jsx($e,{className:"h-4 w-4 ml-1"}):t.jsx(Te,{className:"h-4 w-4 ml-1"})]}),t.jsxs("div",{className:"flex-1 flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[m!=="active"&&t.jsxs("button",{onClick:()=>z("active"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors whitespace-nowrap",children:[m,t.jsx(X,{className:"h-3 w-3"})]}),g!=="all"&&t.jsxs("button",{onClick:()=>O("all"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors whitespace-nowrap",children:[g," priority",t.jsx(X,{className:"h-3 w-3"})]}),(E!=="created"||b!=="desc")&&t.jsxs("button",{onClick:()=>{ne("created"),L("desc"),y({sortBy:null,order:null})},className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-purple-500/15 text-purple-600 dark:text-purple-400 hover:bg-purple-500/25 transition-colors whitespace-nowrap",children:[E," ",b==="asc"?"↑":"↓",t.jsx(X,{className:"h-3 w-3"})]})]}),t.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[a.length," result",a.length!==1?"s":""]})]}),G&&t.jsxs("div",{className:"p-4 rounded-lg border border-muted-foreground/20 bg-muted/30 space-y-4 animate-in slide-in-from-top-2 duration-200",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Status"}),t.jsxs(ie,{value:m,onValueChange:z,children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{placeholder:"Filter by status"})}),t.jsxs(ue,{children:[t.jsx(w,{value:"active",children:"Active (Default)"}),t.jsx(w,{value:"all",children:"All statuses"}),t.jsx(w,{value:"draft",children:"Draft"}),t.jsx(w,{value:"proposed",children:"Proposed"}),t.jsx(w,{value:"in-review",children:"In Review"}),t.jsx(w,{value:"approved",children:"Approved"}),t.jsx(w,{value:"code-complete",children:"Code Complete"}),t.jsx(w,{value:"merged",children:"Merged"}),t.jsx(w,{value:"rejected",children:"Rejected"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Priority"}),t.jsxs(ie,{value:g,onValueChange:O,children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{placeholder:"Filter by priority"})}),t.jsxs(ue,{children:[t.jsx(w,{value:"all",children:"All priorities"}),t.jsx(w,{value:"low",children:"Low"}),t.jsx(w,{value:"medium",children:"Medium"}),t.jsx(w,{value:"high",children:"High"}),t.jsx(w,{value:"critical",children:"Critical"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Sort By"}),t.jsxs(ie,{value:E,onValueChange:u=>ne(u),children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{})}),t.jsxs(ue,{children:[t.jsx(w,{value:"created",children:"Created Date"}),t.jsx(w,{value:"updated",children:"Updated Date"}),t.jsx(w,{value:"status",children:"Status"}),t.jsx(w,{value:"priority",children:"Priority"}),t.jsx(w,{value:"intent",children:"Title"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Order"}),t.jsx(V,{variant:"outline",onClick:D,className:"w-full justify-between bg-background",children:b==="asc"?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Ascending"}),t.jsx(Ye,{className:"h-4 w-4"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Descending"}),t.jsx(He,{className:"h-4 w-4"})]})})]})]}),k>0&&t.jsx("div",{className:"pt-2 border-t border-muted-foreground/10",children:t.jsxs(V,{variant:"ghost",size:"sm",onClick:()=>{z("active"),O("all"),I("")},className:"text-muted-foreground hover:text-foreground",children:[t.jsx(X,{className:"h-3 w-3 mr-1"}),"Reset all filters"]})})]})]}),a.length===0&&n.length>0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Ae,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals match your filters"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try adjusting your status or priority filters."}),t.jsx(V,{variant:"outline",className:"mt-4",onClick:()=>{z("active"),O("all"),I("")},children:"Clear Filters"})]})})}):n.length===0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Ke,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals yet"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first change proposal to get started."}),t.jsx(V,{asChild:!0,className:"mt-4",children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Proposal"]})})]})})}):t.jsx("div",{className:"space-y-4",children:a.map(u=>t.jsx(Y,{to:`/proposals/${u.id}`,className:"block",children:t.jsx(J,{className:"hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:t.jsx(Z,{className:"py-4",children:t.jsx("div",{className:"flex justify-between items-start gap-4",children:t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsx(We,{className:"text-base leading-tight",children:u.intent}),t.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[u.metadata.priority&&t.jsx(q,{variant:Pt(u.metadata.priority),className:"text-xs",children:u.metadata.priority}),t.jsx(q,{variant:Rt(u.status),className:"text-xs",children:u.status})]})]}),u.content&&t.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[u.content.split(`
16
+ */const Xe=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Ae=xe("funnel",Xe);function T(s){return Array.isArray?Array.isArray(s):be(s)==="[object Array]"}function Je(s){if(typeof s=="string")return s;let e=s+"";return e=="0"&&1/s==-1/0?"-0":e}function Ze(s){return s==null?"":Je(s)}function R(s){return typeof s=="string"}function ve(s){return typeof s=="number"}function qe(s){return s===!0||s===!1||et(s)&&be(s)=="[object Boolean]"}function Ee(s){return typeof s=="object"}function et(s){return Ee(s)&&s!==null}function k(s){return s!=null}function le(s){return!s.trim().length}function be(s){return s==null?s===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(s)}const tt="Incorrect 'index' type",st=s=>`Invalid value for key ${s}`,rt=s=>`Pattern length exceeds max of ${s}.`,nt=s=>`Missing ${s} property in key`,it=s=>`Property 'weight' in key '${s}' must be a positive integer`,je=Object.prototype.hasOwnProperty;class at{constructor(e){this._keys=[],this._keyMap={};let r=0;e.forEach(n=>{let i=Fe(n);this._keys.push(i),this._keyMap[i.id]=i,r+=i.weight}),this._keys.forEach(n=>{n.weight/=r})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Fe(s){let e=null,r=null,n=null,i=1,a=null;if(R(s)||T(s))n=s,e=ye(s),r=oe(s);else{if(!je.call(s,"name"))throw new Error(nt("name"));const c=s.name;if(n=c,je.call(s,"weight")&&(i=s.weight,i<=0))throw new Error(it(c));e=ye(c),r=oe(c),a=s.getFn}return{path:e,id:r,weight:i,src:n,getFn:a}}function ye(s){return T(s)?s:s.split(".")}function oe(s){return T(s)?s.join("."):s}function ct(s,e){let r=[],n=!1;const i=(a,c,l)=>{if(k(a))if(!c[l])r.push(a);else{let o=c[l];const h=a[o];if(!k(h))return;if(l===c.length-1&&(R(h)||ve(h)||qe(h)))r.push(Ze(h));else if(T(h)){n=!0;for(let d=0,m=h.length;d<m;d+=1)i(h[d],c,l+1)}else c.length&&i(h,c,l+1)}};return i(s,R(e)?e.split("."):e,0),n?r:r[0]}const ut={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},lt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(s,e)=>s.score===e.score?s.idx<e.idx?-1:1:s.score<e.score?-1:1},ot={location:0,threshold:.6,distance:100},ht={useExtendedSearch:!1,getFn:ct,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var f={...lt,...ut,...ot,...ht};const dt=/[^ ]+/g;function ft(s=1,e=3){const r=new Map,n=Math.pow(10,e);return{get(i){const a=i.match(dt).length;if(r.has(a))return r.get(a);const c=1/Math.pow(a,.5*s),l=parseFloat(Math.round(c*n)/n);return r.set(a,l),l},clear(){r.clear()}}}class pe{constructor({getFn:e=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){this.norm=ft(r,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((r,n)=>{this._keysMap[r.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,R(this.docs[0])?this.docs.forEach((e,r)=>{this._addString(e,r)}):this.docs.forEach((e,r)=>{this._addObject(e,r)}),this.norm.clear())}add(e){const r=this.size();R(e)?this._addString(e,r):this._addObject(e,r)}removeAt(e){this.records.splice(e,1);for(let r=e,n=this.size();r<n;r+=1)this.records[r].i-=1}getValueForItemAtKeyId(e,r){return e[this._keysMap[r]]}size(){return this.records.length}_addString(e,r){if(!k(e)||le(e))return;let n={v:e,i:r,n:this.norm.get(e)};this.records.push(n)}_addObject(e,r){let n={i:r,$:{}};this.keys.forEach((i,a)=>{let c=i.getFn?i.getFn(e):this.getFn(e,i.path);if(k(c)){if(T(c)){let l=[];const o=[{nestedArrIndex:-1,value:c}];for(;o.length;){const{nestedArrIndex:h,value:d}=o.pop();if(k(d))if(R(d)&&!le(d)){let m={v:d,i:h,n:this.norm.get(d)};l.push(m)}else T(d)&&d.forEach((m,x)=>{o.push({nestedArrIndex:x,value:m})})}n.$[a]=l}else if(R(c)&&!le(c)){let l={v:c,n:this.norm.get(c)};n.$[a]=l}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Me(s,e,{getFn:r=f.getFn,fieldNormWeight:n=f.fieldNormWeight}={}){const i=new pe({getFn:r,fieldNormWeight:n});return i.setKeys(s.map(Fe)),i.setSources(e),i.create(),i}function mt(s,{getFn:e=f.getFn,fieldNormWeight:r=f.fieldNormWeight}={}){const{keys:n,records:i}=s,a=new pe({getFn:e,fieldNormWeight:r});return a.setKeys(n),a.setIndexRecords(i),a}function te(s,{errors:e=0,currentLocation:r=0,expectedLocation:n=0,distance:i=f.distance,ignoreLocation:a=f.ignoreLocation}={}){const c=e/s.length;if(a)return c;const l=Math.abs(n-r);return i?c+l/i:l?1:c}function gt(s=[],e=f.minMatchCharLength){let r=[],n=-1,i=-1,a=0;for(let c=s.length;a<c;a+=1){let l=s[a];l&&n===-1?n=a:!l&&n!==-1&&(i=a-1,i-n+1>=e&&r.push([n,i]),n=-1)}return s[a-1]&&a-n>=e&&r.push([n,a-1]),r}const W=32;function xt(s,e,r,{location:n=f.location,distance:i=f.distance,threshold:a=f.threshold,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,includeMatches:o=f.includeMatches,ignoreLocation:h=f.ignoreLocation}={}){if(e.length>W)throw new Error(rt(W));const d=e.length,m=s.length,x=Math.max(0,Math.min(n,m));let g=a,A=x;const C=l>1||o,M=C?Array(m):[];let E;for(;(E=s.indexOf(e,A))>-1;){let F=te(e,{currentLocation:E,expectedLocation:x,distance:i,ignoreLocation:h});if(g=Math.min(F,g),A=E+d,C){let S=0;for(;S<d;)M[E+S]=1,S+=1}}A=-1;let _=[],b=1,L=d+m;const G=1<<d-1;for(let F=0;F<d;F+=1){let S=0,y=L;for(;S<y;)te(e,{errors:F,currentLocation:x+y,expectedLocation:x,distance:i,ignoreLocation:h})<=g?S=y:L=y,y=Math.floor((L-S)/2+S);L=y;let z=Math.max(1,x-y+1),O=c?m:Math.min(x+y,m)+d,I=Array(O+2);I[O+1]=(1<<F)-1;for(let D=O;D>=z;D-=1){let $=D-1,Q=r[s.charAt($)];if(C&&(M[$]=+!!Q),I[D]=(I[D+1]<<1|1)&Q,F&&(I[D]|=(_[D+1]|_[D])<<1|1|_[D+1]),I[D]&G&&(b=te(e,{errors:F,currentLocation:$,expectedLocation:x,distance:i,ignoreLocation:h}),b<=g)){if(g=b,A=$,A<=x)break;z=Math.max(1,2*x-A)}}if(te(e,{errors:F+1,currentLocation:x,expectedLocation:x,distance:i,ignoreLocation:h})>g)break;_=I}const H={isMatch:A>=0,score:Math.max(.001,b)};if(C){const F=gt(M,l);F.length?o&&(H.indices=F):H.isMatch=!1}return H}function pt(s){let e={};for(let r=0,n=s.length;r<n;r+=1){const i=s.charAt(r);e[i]=(e[i]||0)|1<<n-r-1}return e}const se=String.prototype.normalize?(s=>s.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(s=>s);class De{constructor(e,{location:r=f.location,threshold:n=f.threshold,distance:i=f.distance,includeMatches:a=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,isCaseSensitive:o=f.isCaseSensitive,ignoreDiacritics:h=f.ignoreDiacritics,ignoreLocation:d=f.ignoreLocation}={}){if(this.options={location:r,threshold:n,distance:i,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d},e=o?e:e.toLowerCase(),e=h?se(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const m=(g,A)=>{this.chunks.push({pattern:g,alphabet:pt(g),startIndex:A})},x=this.pattern.length;if(x>W){let g=0;const A=x%W,C=x-A;for(;g<C;)m(this.pattern.substr(g,W),g),g+=W;if(A){const M=x-W;m(this.pattern.substr(M),M)}}else m(this.pattern,0)}searchIn(e){const{isCaseSensitive:r,ignoreDiacritics:n,includeMatches:i}=this.options;if(e=r?e:e.toLowerCase(),e=n?se(e):e,this.pattern===e){let C={isMatch:!0,score:0};return i&&(C.indices=[[0,e.length-1]]),C}const{location:a,distance:c,threshold:l,findAllMatches:o,minMatchCharLength:h,ignoreLocation:d}=this.options;let m=[],x=0,g=!1;this.chunks.forEach(({pattern:C,alphabet:M,startIndex:E})=>{const{isMatch:_,score:b,indices:L}=xt(e,C,M,{location:a+E,distance:c,threshold:l,findAllMatches:o,minMatchCharLength:h,includeMatches:i,ignoreLocation:d});_&&(g=!0),x+=b,_&&L&&(m=[...m,...L])});let A={isMatch:g,score:g?x/this.chunks.length:1};return g&&i&&(A.indices=m),A}}class K{constructor(e){this.pattern=e}static isMultiMatch(e){return Ce(e,this.multiRegex)}static isSingleMatch(e){return Ce(e,this.singleRegex)}search(){}}function Ce(s,e){const r=s.match(e);return r?r[1]:null}class At extends K{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const r=e===this.pattern;return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class jt extends K{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class yt extends K{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const r=e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class Ct extends K{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const r=!e.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class wt extends K{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const r=e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Nt extends K{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const r=!e.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class Be extends K{constructor(e,{location:r=f.location,threshold:n=f.threshold,distance:i=f.distance,includeMatches:a=f.includeMatches,findAllMatches:c=f.findAllMatches,minMatchCharLength:l=f.minMatchCharLength,isCaseSensitive:o=f.isCaseSensitive,ignoreDiacritics:h=f.ignoreDiacritics,ignoreLocation:d=f.ignoreLocation}={}){super(e),this._bitapSearch=new De(e,{location:r,threshold:n,distance:i,includeMatches:a,findAllMatches:c,minMatchCharLength:l,isCaseSensitive:o,ignoreDiacritics:h,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ke extends K{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let r=0,n;const i=[],a=this.pattern.length;for(;(n=e.indexOf(this.pattern,r))>-1;)r=n+a,i.push([n,r-1]);const c=!!i.length;return{isMatch:c,score:c?0:1,indices:i}}}const he=[At,ke,yt,Ct,Nt,wt,jt,Be],we=he.length,vt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Et="|";function bt(s,e={}){return s.split(Et).map(r=>{let n=r.trim().split(vt).filter(a=>a&&!!a.trim()),i=[];for(let a=0,c=n.length;a<c;a+=1){const l=n[a];let o=!1,h=-1;for(;!o&&++h<we;){const d=he[h];let m=d.isMultiMatch(l);m&&(i.push(new d(m,e)),o=!0)}if(!o)for(h=-1;++h<we;){const d=he[h];let m=d.isSingleMatch(l);if(m){i.push(new d(m,e));break}}}return i})}const Ft=new Set([Be.type,ke.type]);class Mt{constructor(e,{isCaseSensitive:r=f.isCaseSensitive,ignoreDiacritics:n=f.ignoreDiacritics,includeMatches:i=f.includeMatches,minMatchCharLength:a=f.minMatchCharLength,ignoreLocation:c=f.ignoreLocation,findAllMatches:l=f.findAllMatches,location:o=f.location,threshold:h=f.threshold,distance:d=f.distance}={}){this.query=null,this.options={isCaseSensitive:r,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:a,findAllMatches:l,ignoreLocation:c,location:o,threshold:h,distance:d},e=r?e:e.toLowerCase(),e=n?se(e):e,this.pattern=e,this.query=bt(this.pattern,this.options)}static condition(e,r){return r.useExtendedSearch}searchIn(e){const r=this.query;if(!r)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:a}=this.options;e=i?e:e.toLowerCase(),e=a?se(e):e;let c=0,l=[],o=0;for(let h=0,d=r.length;h<d;h+=1){const m=r[h];l.length=0,c=0;for(let x=0,g=m.length;x<g;x+=1){const A=m[x],{isMatch:C,indices:M,score:E}=A.search(e);if(C){if(c+=1,o+=E,n){const _=A.constructor.type;Ft.has(_)?l=[...l,...M]:l.push(M)}}else{o=0,c=0,l.length=0;break}}if(c){let x={isMatch:!0,score:o/c};return n&&(x.indices=l),x}}return{isMatch:!1,score:1}}}const de=[];function Dt(...s){de.push(...s)}function fe(s,e){for(let r=0,n=de.length;r<n;r+=1){let i=de[r];if(i.condition(s,e))return new i(s,e)}return new De(s,e)}const re={AND:"$and",OR:"$or"},me={PATH:"$path",PATTERN:"$val"},ge=s=>!!(s[re.AND]||s[re.OR]),Bt=s=>!!s[me.PATH],kt=s=>!T(s)&&Ee(s)&&!ge(s),Ne=s=>({[re.AND]:Object.keys(s).map(e=>({[e]:s[e]}))});function Se(s,e,{auto:r=!0}={}){const n=i=>{let a=Object.keys(i);const c=Bt(i);if(!c&&a.length>1&&!ge(i))return n(Ne(i));if(kt(i)){const o=c?i[me.PATH]:a[0],h=c?i[me.PATTERN]:i[o];if(!R(h))throw new Error(st(o));const d={keyId:oe(o),pattern:h};return r&&(d.searcher=fe(h,e)),d}let l={children:[],operator:a[0]};return a.forEach(o=>{const h=i[o];T(h)&&h.forEach(d=>{l.children.push(n(d))})}),l};return ge(s)||(s=Ne(s)),n(s)}function St(s,{ignoreFieldNorm:e=f.ignoreFieldNorm}){s.forEach(r=>{let n=1;r.matches.forEach(({key:i,norm:a,score:c})=>{const l=i?i.weight:null;n*=Math.pow(c===0&&l?Number.EPSILON:c,(l||1)*(e?1:a))}),r.score=n})}function _t(s,e){const r=s.matches;e.matches=[],k(r)&&r.forEach(n=>{if(!k(n.indices)||!n.indices.length)return;const{indices:i,value:a}=n;let c={indices:i,value:a};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function It(s,e){e.score=s.score}function Lt(s,e,{includeMatches:r=f.includeMatches,includeScore:n=f.includeScore}={}){const i=[];return r&&i.push(_t),n&&i.push(It),s.map(a=>{const{idx:c}=a,l={item:e[c],refIndex:c};return i.length&&i.forEach(o=>{o(a,l)}),l})}class U{constructor(e,r={},n){this.options={...f,...r},this.options.useExtendedSearch,this._keyStore=new at(this.options.keys),this.setCollection(e,n)}setCollection(e,r){if(this._docs=e,r&&!(r instanceof pe))throw new Error(tt);this._myIndex=r||Me(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){k(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const r=[];for(let n=0,i=this._docs.length;n<i;n+=1){const a=this._docs[n];e(a,n)&&(this.removeAt(n),n-=1,i-=1,r.push(a))}return r}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:r=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:a,sortFn:c,ignoreFieldNorm:l}=this.options;let o=R(e)?R(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return St(o,{ignoreFieldNorm:l}),a&&o.sort(c),ve(r)&&r>-1&&(o=o.slice(0,r)),Lt(o,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(e){const r=fe(e,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:a,i:c,n:l})=>{if(!k(a))return;const{isMatch:o,score:h,indices:d}=r.searchIn(a);o&&i.push({item:a,idx:c,matches:[{score:h,value:a,norm:l,indices:d}]})}),i}_searchLogical(e){const r=Se(e,this.options),n=(l,o,h)=>{if(!l.children){const{keyId:m,searcher:x}=l,g=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(o,m),searcher:x});return g&&g.length?[{idx:h,item:o,matches:g}]:[]}const d=[];for(let m=0,x=l.children.length;m<x;m+=1){const g=l.children[m],A=n(g,o,h);if(A.length)d.push(...A);else if(l.operator===re.AND)return[]}return d},i=this._myIndex.records,a={},c=[];return i.forEach(({$:l,i:o})=>{if(k(l)){let h=n(r,l,o);h.length&&(a[o]||(a[o]={idx:o,item:l,matches:[]},c.push(a[o])),h.forEach(({matches:d})=>{a[o].matches.push(...d)}))}}),c}_searchObjectList(e){const r=fe(e,this.options),{keys:n,records:i}=this._myIndex,a=[];return i.forEach(({$:c,i:l})=>{if(!k(c))return;let o=[];n.forEach((h,d)=>{o.push(...this._findMatches({key:h,value:c[d],searcher:r}))}),o.length&&a.push({idx:l,item:c,matches:o})}),a}_findMatches({key:e,value:r,searcher:n}){if(!k(r))return[];let i=[];if(T(r))r.forEach(({v:a,i:c,n:l})=>{if(!k(a))return;const{isMatch:o,score:h,indices:d}=n.searchIn(a);o&&i.push({score:h,key:e,value:a,idx:c,norm:l,indices:d})});else{const{v:a,n:c}=r,{isMatch:l,score:o,indices:h}=n.searchIn(a);l&&i.push({score:o,key:e,value:a,norm:c,indices:h})}return i}}U.version="7.1.0";U.createIndex=Me;U.parseIndex=mt;U.config=f;U.parseQuery=Se;Dt(Mt);function Rt(s){switch(s){case"approved":case"code-complete":return"default";case"in-review":return"secondary";case"rejected":return"destructive";default:return"outline"}}function Tt(s){switch(s){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function Vt(){const[s]=_e(),e=Ie(),r=Le(),[n,i]=j.useState([]),[a,c]=j.useState([]),[l,o]=j.useState(!0),[h,d]=j.useState(null),[m,x]=j.useState(s.get("status")||"active"),[g,A]=j.useState(s.get("priority")||"all"),[C,M]=j.useState(s.get("search")||""),[E,_]=j.useState(s.get("sortBy")||"created"),[b,L]=j.useState(s.get("order")||"desc"),[G,H]=j.useState(!1),F=j.useRef(null),S=[m!=="active",g!=="all",E!=="created",b!=="desc"].filter(Boolean).length,y=j.useCallback(u=>{const p=new URLSearchParams(s);Object.entries(u).forEach(([B,P])=>{P&&P!=="all"&&P!=="active"&&P!==""?p.set(B,P):p.delete(B)});const N=p.toString(),v=N?`?${N}`:"";e(`${r.pathname}${v}`)},[s,e,r.pathname]),z=j.useCallback(u=>{x(u),y({status:u==="active"?null:u})},[y]),O=j.useCallback(u=>{A(u),y({priority:u==="all"?null:u})},[y]),I=j.useCallback(u=>{M(u),y({search:u||null})},[y]),ne=j.useCallback(u=>{_(u),y({sortBy:u==="created"?null:u})},[y]),D=j.useCallback(()=>{const u=b==="asc"?"desc":"asc";L(u),y({order:u==="desc"?null:u})},[b,y]),$=j.useCallback(u=>{if(u.key==="s"||u.key==="S"){const p=document.activeElement;p?.tagName==="INPUT"||p?.tagName==="TEXTAREA"||p?.getAttribute("contenteditable")==="true"||(u.preventDefault(),F.current?.focus())}},[]);j.useEffect(()=>(document.addEventListener("keydown",$),()=>{document.removeEventListener("keydown",$)}),[$]);const Q=j.useMemo(()=>{const u={keys:[{name:"intent",weight:.4},{name:"id",weight:.3},{name:"author.name",weight:.2},{name:"metadata.tags",weight:.1}],threshold:.3,includeScore:!0};return new U(n,u)},[n]);return j.useEffect(()=>{async function u(){try{o(!0);const N=await(await fetch(`${ze}/api/v1/proposals`)).json();N.success?(i(N.data),c(N.data)):d(N.error?.message||"Failed to fetch proposals")}catch(p){d(p instanceof Error?p.message:"Unknown error")}finally{o(!1)}}u()},[]),j.useEffect(()=>{let u=n;if(m==="active"?u=u.filter(p=>["draft","proposed","in-review","approved","code-complete"].includes(p.status)):m==="approved"?u=u.filter(p=>["approved","code-complete"].includes(p.status)):m!=="all"&&(u=u.filter(p=>p.status===m)),g!=="all"&&(u=u.filter(p=>p.metadata.priority===g)),C.trim()){const p=Q.search(C),N=new Set(p.map(v=>v.item.id));u=u.filter(v=>N.has(v.id))}u=u.sort((p,N)=>{let v,B;switch(E){case"created":{v=new Date(p.metadata.createdAt).getTime(),B=new Date(N.metadata.createdAt).getTime();break}case"updated":{v=new Date(p.metadata.updatedAt).getTime(),B=new Date(N.metadata.updatedAt).getTime();break}case"status":{v=p.status,B=N.status;break}case"priority":{const P={critical:4,high:3,medium:2,low:1};v=P[p.metadata.priority]||0,B=P[N.metadata.priority]||0;break}case"intent":{v=p.intent.toLowerCase(),B=N.intent.toLowerCase();break}default:v=new Date(p.metadata.createdAt).getTime(),B=new Date(N.metadata.createdAt).getTime()}return b==="asc"?v<B?-1:v>B?1:0:v>B?-1:v<B?1:0}),c(u)},[n,m,g,C,E,b,Q]),l?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsx("div",{className:"space-y-4",children:[...Array(3)].map((u,p)=>t.jsx(J,{children:t.jsx(Ve,{children:t.jsxs("div",{className:"flex justify-between items-start",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"h-6 bg-muted rounded w-3/4 animate-pulse"}),t.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]}),t.jsx("div",{className:"h-6 bg-muted rounded w-20 animate-pulse"})]})})},p))})]}):h?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsx("div",{className:"text-center",children:t.jsxs("p",{className:"text-destructive",children:["Error: ",h]})})})})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),t.jsx("p",{className:"text-muted-foreground",children:"Manage tasks for your project"})]}),t.jsx(V,{asChild:!0,children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsx(Ue,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),t.jsx(Re,{ref:F,placeholder:"Search tasks...",value:C,onChange:u=>I(u.target.value),className:"pl-9 pr-20 h-11 bg-muted/40 border-muted-foreground/20 focus:bg-background transition-colors"}),t.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-2",children:C?t.jsx("button",{onClick:()=>I(""),className:"h-5 w-5 rounded-full bg-muted-foreground/20 hover:bg-muted-foreground/30 flex items-center justify-center transition-colors",children:t.jsx(X,{className:"h-3 w-3"})}):t.jsx(Te,{children:t.jsx(Oe,{children:"S"})})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:()=>H(!G),className:"flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg border border-muted-foreground/20 hover:bg-muted/50 transition-colors",children:[t.jsx(Ae,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Filters & Sort"}),t.jsx("span",{className:"sm:hidden",children:"Filters"}),S>0&&t.jsx("span",{className:"flex items-center justify-center h-5 w-5 text-xs font-bold rounded-full bg-primary text-primary-foreground",children:S}),G?t.jsx($e,{className:"h-4 w-4 ml-1"}):t.jsx(Pe,{className:"h-4 w-4 ml-1"})]}),t.jsxs("div",{className:"flex-1 flex items-center gap-2 overflow-x-auto scrollbar-hide",children:[m!=="active"&&t.jsxs("button",{onClick:()=>z("active"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors whitespace-nowrap",children:[m,t.jsx(X,{className:"h-3 w-3"})]}),g!=="all"&&t.jsxs("button",{onClick:()=>O("all"),className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors whitespace-nowrap",children:[g," priority",t.jsx(X,{className:"h-3 w-3"})]}),(E!=="created"||b!=="desc")&&t.jsxs("button",{onClick:()=>{ne("created"),L("desc"),y({sortBy:null,order:null})},className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full bg-purple-500/15 text-purple-600 dark:text-purple-400 hover:bg-purple-500/25 transition-colors whitespace-nowrap",children:[E," ",b==="asc"?"↑":"↓",t.jsx(X,{className:"h-3 w-3"})]})]}),t.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[a.length," result",a.length!==1?"s":""]})]}),G&&t.jsxs("div",{className:"p-4 rounded-lg border border-muted-foreground/20 bg-muted/30 space-y-4 animate-in slide-in-from-top-2 duration-200",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Status"}),t.jsxs(ie,{value:m,onValueChange:z,children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{placeholder:"Filter by status"})}),t.jsxs(ue,{children:[t.jsx(w,{value:"active",children:"Active (Default)"}),t.jsx(w,{value:"all",children:"All statuses"}),t.jsx(w,{value:"draft",children:"Draft"}),t.jsx(w,{value:"proposed",children:"Proposed"}),t.jsx(w,{value:"in-review",children:"In Review"}),t.jsx(w,{value:"approved",children:"Approved"}),t.jsx(w,{value:"code-complete",children:"Code Complete"}),t.jsx(w,{value:"merged",children:"Merged"}),t.jsx(w,{value:"rejected",children:"Rejected"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Priority"}),t.jsxs(ie,{value:g,onValueChange:O,children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{placeholder:"Filter by priority"})}),t.jsxs(ue,{children:[t.jsx(w,{value:"all",children:"All priorities"}),t.jsx(w,{value:"low",children:"Low"}),t.jsx(w,{value:"medium",children:"Medium"}),t.jsx(w,{value:"high",children:"High"}),t.jsx(w,{value:"critical",children:"Critical"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Sort By"}),t.jsxs(ie,{value:E,onValueChange:u=>ne(u),children:[t.jsx(ae,{className:"w-full bg-background",children:t.jsx(ce,{})}),t.jsxs(ue,{children:[t.jsx(w,{value:"created",children:"Created Date"}),t.jsx(w,{value:"updated",children:"Updated Date"}),t.jsx(w,{value:"status",children:"Status"}),t.jsx(w,{value:"priority",children:"Priority"}),t.jsx(w,{value:"intent",children:"Title"})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Order"}),t.jsx(V,{variant:"outline",onClick:D,className:"w-full justify-between bg-background",children:b==="asc"?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Ascending"}),t.jsx(Ye,{className:"h-4 w-4"})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Descending"}),t.jsx(He,{className:"h-4 w-4"})]})})]})]}),S>0&&t.jsx("div",{className:"pt-2 border-t border-muted-foreground/10",children:t.jsxs(V,{variant:"ghost",size:"sm",onClick:()=>{z("active"),O("all"),I("")},className:"text-muted-foreground hover:text-foreground",children:[t.jsx(X,{className:"h-3 w-3 mr-1"}),"Reset all filters"]})})]})]}),a.length===0&&n.length>0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Ae,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals match your filters"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try adjusting your status or priority filters."}),t.jsx(V,{variant:"outline",className:"mt-4",onClick:()=>{z("active"),O("all"),I("")},children:"Clear Filters"})]})})}):n.length===0?t.jsx(J,{children:t.jsx(Z,{className:"pt-6",children:t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Ke,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),t.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No proposals yet"}),t.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first change proposal to get started."}),t.jsx(V,{asChild:!0,className:"mt-4",children:t.jsxs(Y,{to:"/proposals/new",children:[t.jsx(ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})}):t.jsx("div",{className:"space-y-4",children:a.map(u=>t.jsx(Y,{to:`/proposals/${u.id}`,className:"block",children:t.jsx(J,{className:"hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:t.jsx(Z,{className:"py-4",children:t.jsx("div",{className:"flex justify-between items-start gap-4",children:t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsx(We,{className:"text-base leading-tight",children:u.intent}),t.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[u.metadata.priority&&t.jsx(q,{variant:Tt(u.metadata.priority),className:"text-xs",children:u.metadata.priority}),t.jsx(q,{variant:Rt(u.status),className:"text-xs",children:u.status})]})]}),u.content&&t.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[u.content.split(`
17
17
  `).slice(0,2).join(" ").substring(0,150),u.content.length>150?"...":""]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"text-xs text-muted-foreground",children:[u.id," • by ",u.author.name," • ",new Date(u.metadata.createdAt).toLocaleDateString()]}),t.jsxs("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[u.planSteps.length>0&&t.jsxs("span",{children:[u.planSteps.length," step",u.planSteps.length!==1?"s":""]}),u.evidence.length>0&&t.jsxs("span",{children:[u.evidence.length," evidence"]}),u.metadata.tags&&u.metadata.tags.length>0&&t.jsxs("span",{children:[u.metadata.tags.length," tag",u.metadata.tags.length!==1?"s":""]})]})]}),u.metadata.tags&&u.metadata.tags.length>0&&t.jsxs("div",{className:"flex gap-1 mt-2",children:[u.metadata.tags.slice(0,3).map(p=>t.jsx(q,{variant:"outline",className:"text-xs",children:p},p)),u.metadata.tags.length>3&&t.jsxs(q,{variant:"outline",className:"text-xs",children:["+",u.metadata.tags.length-3]})]})]})})})})},u.id))})]})}export{Vt as default};
@@ -0,0 +1,71 @@
1
+ import{c as oe,r as t,j as e,D as pe,b as ge,d as ve,f as je,J as le,S as is,B as R,al as os,n as Ee,a as $e,A as ae,w as ye,h as W,i as B,k as $,l as U,m as G,ah as Ve,y as me,an as ca,ao as da,ap as ua,aq as be,ar as Fe,as as _e,at as ma,au as Bs,av as ha,aw as xa,e as fa,I as We,am as Xe,X as cs,C as $s,F as we,ax as Ze,ay as pa,az as ga,aA as va,aa as ja,ab as ya,v as ba,ac as wa,af as Je,g as ds,W as us,aB as Na}from"./index-VBSAUXJg.js";import{C as Ye,b as ms,a as Qe,c as _a,d as Sa}from"./card-DdTVdbjN.js";import{L as C}from"./label-C6P6J-NS.js";import{B as Me}from"./badge-CqnJU-OF.js";import{c as Ca}from"./clipboard-B9ndUJKl.js";import{R as Us}from"./registry-ANRa5WBi.js";import{D as es}from"./download-Co1Xt7Td.js";import{C as zs}from"./chevron-left-CM04t09S.js";import{C as ka}from"./calendar-CA_W4UKa.js";import{T as Pa}from"./tag-BEI3zSmE.js";import{P as hs}from"./plus-nBUooJPr.js";import{S as Ea}from"./search-ygMlQfjH.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 Ma=[["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"}]],xs=oe("file-audio",Ma);/**
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 Fa=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["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"}]],ss=oe("file-code",Fa);/**
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 Ia=[["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"}]],fs=oe("file-image",Ia);/**
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 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"}]],ps=oe("file-json",Ra);/**
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 Ta=[["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"}]],gs=oe("file-play",Ta);/**
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 Da=[["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"}]],vs=oe("file-spreadsheet",Da);/**
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 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:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]],js=oe("file-type",Ga);/**
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 Aa=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],La=oe("hard-drive",Aa);/**
42
+ * @license lucide-react v0.542.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const Ka=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Ne=oe("image",Ka);/**
47
+ * @license lucide-react v0.542.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const Oa=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ys=oe("maximize-2",Oa);/**
52
+ * @license lucide-react v0.542.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const Va=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],fe=oe("music",Va);/**
57
+ * @license lucide-react v0.542.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const Wa=[["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"}]],bs=oe("presentation",Wa);/**
62
+ * @license lucide-react v0.542.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const Ba=[["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"}]],$a=oe("upload",Ba);/**
67
+ * @license lucide-react v0.542.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const Ua=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Be=oe("video",Ua);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 za(){return qs("/registry/resources/root.json")}async function ws(l){return qs(l)}function Ke(l){if(l)return l.startsWith("http")?l:`${Us}${l}`}function qa({open:l,onOpenChange:c,onSelectExample:n,onCustomizeInAssistant:p}){const[m,u]=t.useState([]),[j,h]=t.useState(!1),[N,P]=t.useState(null),[S,d]=t.useState(null),[x,y]=t.useState(null),[E,w]=t.useState(!1),[b,_]=t.useState(null);t.useEffect(()=>{l&&(h(!0),P(null),d(null),y(null),_(null),za().then(v=>{u(v.elements??[]),v.elements&&v.elements.length>0&&z(v.elements[0])}).catch(v=>{console.error("Failed to load registry resources",v),u([]),P("Failed to load examples from registry")}).finally(()=>h(!1)))},[l]);const z=async v=>{d(v.id),_(null),y(null),w(!0);try{const k=await ws(v.endpoint);y(k)}catch(k){console.error("Failed to load resource detail",k),_("Unable to load details for this example")}finally{w(!1)}},M=()=>{x?.prompt&&(n(x.prompt),c(!1))},T=()=>{x?.prompt&&p&&(p(x.prompt),c(!1))},A=async v=>{if(S===v.id&&x?.prompt){n(x.prompt),c(!1);return}try{const k=await ws(v.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:E?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5 animate-spin mr-2"}),"Loading..."]}):b?e.jsx("p",{className:"text-sm text-muted-foreground",children:b}):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:[j?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..."]}):N?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:N}):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(is,{className:"flex-1",children:e.jsx("div",{className:"p-3 space-y-2",children:m.map(v=>e.jsxs("button",{onClick:()=>z(v),onDoubleClick:()=>A(v),className:`w-full text-left p-2 rounded-lg border-2 transition-all flex gap-3 ${S===v.id?"border-primary bg-primary/5":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[v.thumbnailUrl&&e.jsx("img",{src:Ke(v.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:v.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:v.description})]})]},v.id))})}),e.jsx("div",{className:"p-3 border-t flex-shrink-0",children:e.jsxs(R,{onClick:M,disabled:!x?.prompt||E,className:"w-full",children:[e.jsx(os,{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(R,{size:"sm",variant:"secondary",onClick:T,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:[j?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..."]}):N?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:N}):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(is,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-3",children:m.map(v=>e.jsxs("button",{onClick:()=>z(v),onDoubleClick:()=>A(v),className:`w-full text-left p-3 rounded-lg border-2 transition-all flex gap-3 ${S===v.id?"border-primary bg-primary/5 shadow-sm":"border-transparent bg-muted/50 hover:bg-muted hover:border-muted-foreground/20"}`,children:[v.thumbnailUrl&&e.jsx("img",{src:Ke(v.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:v.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:v.description}),v.tags&&v.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[v.tags.slice(0,3).map(k=>e.jsx(Me,{variant:"secondary",className:"text-[10px]",children:k},k)),v.tags.length>3&&e.jsxs(Me,{variant:"outline",className:"text-[10px]",children:["+",v.tags.length-3]})]})]})]},v.id))})}),e.jsx("div",{className:"p-4 border-t flex-shrink-0",children:e.jsxs(R,{onClick:M,disabled:!x?.prompt||E,className:"w-full",children:[e.jsx(os,{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:E?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..."]}):b?e.jsx("p",{className:"text-sm text-muted-foreground",children:b}):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(R,{size:"sm",variant:"secondary",onClick:T,children:[e.jsx(Ee,{className:"mr-1.5 h-3.5 w-3.5"}),"Customize in Assistant"]})})]})]})]})})}const Ns="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"}],Ha={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 Ja({open:l,onOpenChange:c,onSave:n,onCustomizeInAssistant:p}){const m=a=>a.aspectRatioOptions?a.aspectRatioOptions:a.features.matchInputImage?[Ha,...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(Ns);return a?JSON.parse(a):null}catch{return null}})(),N=h?.model||"nano-banana-pro",P=Oe[N],S=u(P,h?.aspectRatio)?h?.aspectRatio:P.defaults.aspectRatio||"16:9",[d,x]=t.useState(""),[y,E]=t.useState(N),[w,b]=t.useState(S),[_,z]=t.useState(h?.resolution||"2K"),[M,T]=t.useState(h?.outputFormat||"png"),[A,v]=t.useState(h?.outputQuality||"80"),[k,q]=t.useState(h?.quality||"high"),[L,D]=t.useState(h?.goFast??!0),[I,g]=t.useState(h?.safetyTolerance||"2"),[K,Y]=t.useState(h?.background||"auto"),[H,ee]=t.useState(null),[O,V]=t.useState(!1),[Q,o]=t.useState(!1),[te,i]=t.useState([]),[F,se]=t.useState([]),[X,re]=t.useState(!0),[ue,he]=t.useState(!1),[Ie,Re]=t.useState(0),xe=t.useRef(null),{toast:ie}=$e();t.useEffect(()=>{const a={model:y,aspectRatio:w,resolution:_,outputFormat:M,outputQuality:A,quality:k,goFast:L,safetyTolerance:I,background:K};localStorage.setItem(Ns,JSON.stringify(a))},[y,w,_,M,A,k,L,I,K]),t.useEffect(()=>(O?(Re(0),xe.current=setInterval(()=>{Re(a=>a+1)},1e3)):xe.current&&(clearInterval(xe.current),xe.current=null),()=>{xe.current&&clearInterval(xe.current)}),[O]);const J=Oe[y],Ce=m(J),Te=J.resolutionOptions||[];t.useEffect(()=>{const a=Oe[y];a.defaults.resolution&&a.features.resolution&&z(a.defaults.resolution),a.defaults.outputQuality!==void 0&&v(String(a.defaults.outputQuality)),a.defaults.quality!==void 0&&a.features.quality&&q(String(a.defaults.quality)),a.defaults.goFast!==void 0&&D(a.defaults.goFast),a.defaults.safetyTolerance!==void 0&&g(String(a.defaults.safetyTolerance)),a.defaults.background!==void 0&&a.features.background&&Y(String(a.defaults.background)),b(s=>{const r=m(a).map(f=>f.value);return r.includes(s)?s:a.defaults.aspectRatio||r[0]||"16:9"})},[y]),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}V(!0),ee(null);try{const a=X||F.length===0?[]:[...F],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:y,dimensions:w,resolution:J.features.resolution?_:void 0,output_format:M,output_quality:J.features.outputQuality?parseInt(A):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?K: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 de=ne.error?.message||"Failed to generate image",ce=ne.error?.code==="MISSING_API_TOKEN";throw new Error(ce?"Replicate API token not configured. Please add it in Settings → Integrations.":de)}ee(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{V(!1)}};t.useEffect(()=>{const a=s=>{l&&(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&(s.preventDefault(),d.trim()&&!O&&!Q&&ke())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[l,d,O,Q]);const De=async()=>{if(H){o(!0);try{await n(H,{prompt:d,model:y}),x(""),E("nano-banana-pro"),b("16:9"),z("2K"),T("png"),v("80"),q("high"),D(!0),g("2"),Y("auto"),ee(null),re(!0),se([]),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=()=>{!O&&!Q&&c(!1)},Ae=()=>{re(!0),se([])},Le=a=>{X&&re(!1),F.includes(a)?(se(F.filter(s=>s!==a)),F.length===1&&re(!0)):F.length<3?se([...F,a]):ie({title:"Maximum selection",description:"You can only select up to 3 images",variant:"destructive"})},qe=a=>{x(a)},He=a=>{p&&(he(!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: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..."})]}):H?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:H,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(Ne,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"}),e.jsxs(R,{size:"sm",onClick:()=>he(!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=F.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(ye,{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(W,{value:y,onValueChange:a=>E(a),children:[e.jsx(B,{id:"model-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ss.map(a=>e.jsx(G,{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(W,{value:M,onValueChange:T,children:[e.jsx(B,{id:"outputFormat-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:ks.map(a=>e.jsx(G,{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(W,{value:K,onValueChange:Y,children:[e.jsx(B,{id:"background-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ms.map(a=>e.jsx(G,{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=>D(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(W,{value:I,onValueChange:g,children:[e.jsx(B,{id:"safetyTolerance-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Fs.map(a=>e.jsx(G,{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(W,{value:_,onValueChange:z,children:[e.jsx(B,{id:"resolution-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Te.map(a=>e.jsx(G,{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(W,{value:w,onValueChange:b,children:[e.jsx(B,{id:"aspectRatio-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ce.map(a=>e.jsx(G,{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(W,{value:A,onValueChange:v,children:[e.jsx(B,{id:"outputQuality-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ps.map(a=>e.jsx(G,{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(W,{value:k,onValueChange:q,children:[e.jsx(B,{id:"quality-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Es.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(R,{onClick:ke,disabled:!d.trim()||O||Q,className:"flex-1 h-9",size:"sm",children:O?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(me,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(R,{onClick:De,disabled:!H||O||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(ye,{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(W,{value:y,onValueChange:a=>E(a),children:[e.jsx(B,{id:"model",children:e.jsx($,{})}),e.jsx(U,{children:Ss.map(a=>e.jsx(G,{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(W,{value:w,onValueChange:b,children:[e.jsx(B,{id:"aspectRatio",children:e.jsx($,{})}),e.jsx(U,{children:Ce.map(a=>e.jsx(G,{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(W,{value:_,onValueChange:z,children:[e.jsx(B,{id:"resolution",children:e.jsx($,{})}),e.jsx(U,{children:Te.map(a=>e.jsx(G,{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(W,{value:M,onValueChange:T,children:[e.jsx(B,{id:"outputFormat",children:e.jsx($,{})}),e.jsx(U,{children:ks.map(a=>e.jsx(G,{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(W,{value:K,onValueChange:Y,children:[e.jsx(B,{id:"background",children:e.jsx($,{})}),e.jsx(U,{children:Ms.map(a=>e.jsx(G,{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(W,{value:A,onValueChange:v,children:[e.jsx(B,{id:"outputQuality",children:e.jsx($,{})}),e.jsx(U,{children:Ps.map(a=>e.jsx(G,{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(W,{value:k,onValueChange:q,children:[e.jsx(B,{id:"quality",children:e.jsx($,{})}),e.jsx(U,{children:Es.map(a=>e.jsx(G,{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=>D(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(W,{value:I,onValueChange:g,children:[e.jsx(B,{id:"safetyTolerance",children:e.jsx($,{})}),e.jsx(U,{children:Fs.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(R,{onClick:ke,disabled:!d.trim()||O||Q,className:"w-full",children:O?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(me,{children:"⌘"}),e.jsx(me,{children:"↵"})]})}),e.jsx(R,{onClick:De,disabled:!H||O||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: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 image..."})]}):H?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:H,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(Ne,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated image will appear here"}),e.jsxs(R,{onClick:()=>he(!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=F.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(qa,{open:ue,onOpenChange:he,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",[as,Ya,Qa]=ua(Se),[Qs,Et]=da(Se,[Qa]),[Xa,Ue]=Qs(Se),Xs=t.forwardRef((l,c)=>{const{name:n,min:p=0,max:m=100,step:u=1,orientation:j="horizontal",disabled:h=!1,minStepsBetweenThumbs:N=0,defaultValue:P=[p],value:S,onValueChange:d=()=>{},onValueCommit:x=()=>{},inverted:y=!1,form:E,...w}=l,b=t.useRef(new Set),_=t.useRef(0),M=j==="horizontal"?Za:et,[T=[],A]=ca({prop:S,defaultProp:P,onChange:I=>{[...b.current][_.current]?.focus(),d(I)}}),v=t.useRef(T);function k(I){const g=lt(T,I);D(I,g)}function q(I){D(I,_.current)}function L(){const I=v.current[_.current];T[_.current]!==I&&x(T)}function D(I,g,{commit:K}={commit:!1}){const Y=ct(u),H=dt(Math.round((I-p)/u)*u+p,Y),ee=Bs(H,[p,m]);A((O=[])=>{const V=tt(O,ee,g);if(ot(V,N*u)){_.current=V.indexOf(ee);const Q=String(V)!==String(O);return Q&&K&&x(V),Q?V:O}else return O})}return e.jsx(Xa,{scope:l.__scopeSlider,name:n,disabled:h,min:p,max:m,valueIndexToChangeRef:_,thumbs:b.current,values:T,orientation:j,form:E,children:e.jsx(as.Provider,{scope:l.__scopeSlider,children:e.jsx(as.Slot,{scope:l.__scopeSlider,children:e.jsx(M,{"aria-disabled":h,"data-disabled":h?"":void 0,...w,ref:c,onPointerDown:be(w.onPointerDown,()=>{h||(v.current=T)}),min:p,max:m,inverted:y,onSlideStart:h?void 0:k,onSlideMove:h?void 0:q,onSlideEnd:h?void 0:L,onHomeKeyDown:()=>!h&&D(p,0,{commit:!0}),onEndKeyDown:()=>!h&&D(m,T.length-1,{commit:!0}),onStepKeyDown:({event:I,direction:g})=>{if(!h){const H=Hs.includes(I.key)||I.shiftKey&&Js.includes(I.key)?10:1,ee=_.current,O=T[ee],V=u*H*g;D(O+V,ee,{commit:!0})}}})})})})});Xs.displayName=Se;var[Zs,ea]=Qs(Se,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Za=t.forwardRef((l,c)=>{const{min:n,max:p,dir:m,inverted:u,onSlideStart:j,onSlideMove:h,onSlideEnd:N,onStepKeyDown:P,...S}=l,[d,x]=t.useState(null),y=_e(c,M=>x(M)),E=t.useRef(void 0),w=ma(m),b=w==="ltr",_=b&&!u||!b&&u;function z(M){const T=E.current||d.getBoundingClientRect(),A=[0,T.width],k=ls(A,_?[n,p]:[p,n]);return E.current=T,k(M-T.left)}return e.jsx(Zs,{scope:l.__scopeSlider,startEdge:_?"left":"right",endEdge:_?"right":"left",direction:_?1:-1,size:"width",children:e.jsx(sa,{dir:w,"data-orientation":"horizontal",...S,ref:y,style:{...S.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:M=>{const T=z(M.clientX);j?.(T)},onSlideMove:M=>{const T=z(M.clientX);h?.(T)},onSlideEnd:()=>{E.current=void 0,N?.()},onStepKeyDown:M=>{const A=Ys[_?"from-left":"from-right"].includes(M.key);P?.({event:M,direction:A?-1:1})}})})}),et=t.forwardRef((l,c)=>{const{min:n,max:p,inverted:m,onSlideStart:u,onSlideMove:j,onSlideEnd:h,onStepKeyDown:N,...P}=l,S=t.useRef(null),d=_e(c,S),x=t.useRef(void 0),y=!m;function E(w){const b=x.current||S.current.getBoundingClientRect(),_=[0,b.height],M=ls(_,y?[p,n]:[n,p]);return x.current=b,M(w-b.top)}return e.jsx(Zs,{scope:l.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:e.jsx(sa,{"data-orientation":"vertical",...P,ref:d,style:{...P.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const b=E(w.clientY);u?.(b)},onSlideMove:w=>{const b=E(w.clientY);j?.(b)},onSlideEnd:()=>{x.current=void 0,h?.()},onStepKeyDown:w=>{const _=Ys[y?"from-bottom":"from-top"].includes(w.key);N?.({event:w,direction:_?-1:1})}})})}),sa=t.forwardRef((l,c)=>{const{__scopeSlider:n,onSlideStart:p,onSlideMove:m,onSlideEnd:u,onHomeKeyDown:j,onEndKeyDown:h,onStepKeyDown:N,...P}=l,S=Ue(Se,n);return e.jsx(Fe.span,{...P,ref:c,onKeyDown:be(l.onKeyDown,d=>{d.key==="Home"?(j(d),d.preventDefault()):d.key==="End"?(h(d),d.preventDefault()):Hs.concat(Js).includes(d.key)&&(N(d),d.preventDefault())}),onPointerDown:be(l.onPointerDown,d=>{const x=d.target;x.setPointerCapture(d.pointerId),d.preventDefault(),S.thumbs.has(x)?x.focus():p(d)}),onPointerMove:be(l.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&m(d)}),onPointerUp:be(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 ts="SliderRange",na=t.forwardRef((l,c)=>{const{__scopeSlider:n,...p}=l,m=Ue(ts,n),u=ea(ts,n),j=t.useRef(null),h=_e(c,j),N=m.values.length,P=m.values.map(x=>ia(x,m.min,m.max)),S=N>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=ts;var ns="SliderThumb",la=t.forwardRef((l,c)=>{const n=Ya(l.__scopeSlider),[p,m]=t.useState(null),u=_e(c,h=>m(h)),j=t.useMemo(()=>p?n().findIndex(h=>h.ref.current===p):-1,[n,p]);return e.jsx(st,{...l,ref:u,index:j})}),st=t.forwardRef((l,c)=>{const{__scopeSlider:n,index:p,name:m,...u}=l,j=Ue(ns,n),h=ea(ns,n),[N,P]=t.useState(null),S=_e(c,z=>P(z)),d=N?j.form||!!N.closest("form"):!0,x=ha(N),y=j.values[p],E=y===void 0?0:ia(y,j.min,j.max),w=nt(p,j.values.length),b=x?.[h.size],_=b?rt(b,E,h.direction):0;return t.useEffect(()=>{if(N)return j.thumbs.add(N),()=>{j.thumbs.delete(N)}},[N,j.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[h.startEdge]:`calc(${E}% + ${_}px)`},children:[e.jsx(as.ItemSlot,{scope:l.__scopeSlider,children:e.jsx(Fe.span,{role:"slider","aria-label":l["aria-label"]||w,"aria-valuemin":j.min,"aria-valuenow":y,"aria-valuemax":j.max,"aria-orientation":j.orientation,"data-orientation":j.orientation,"data-disabled":j.disabled?"":void 0,tabIndex:j.disabled?void 0:0,...u,ref:S,style:y===void 0?{display:"none"}:l.style,onFocus:be(l.onFocus,()=>{j.valueIndexToChangeRef.current=p})})}),d&&e.jsx(ra,{name:m??(j.name?j.name+(j.values.length>1?"[]":""):void 0),form:j.form,value:y},p)]})});la.displayName=ns;var at="RadioBubbleInput",ra=t.forwardRef(({__scopeSlider:l,value:c,...n},p)=>{const m=t.useRef(null),u=_e(m,p),j=xa(c);return t.useEffect(()=>{const h=m.current;if(!h)return;const N=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(N,"value").set;if(j!==c&&S){const d=new Event("input",{bubbles:!0});S.call(h,c),h.dispatchEvent(d)}},[j,c]),e.jsx(Fe.input,{style:{display:"none"},...n,ref:u,defaultValue:c})});ra.displayName=at;function tt(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 nt(l,c){return c>2?`Value ${l+1} of ${c}`:c===2?["Minimum","Maximum"][l]:void 0}function lt(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 rt(l,c,n){const p=l/2,u=ls([0,50],[0,p]);return(p-u(c)*n)*n}function it(l){return l.slice(0,-1).map((c,n)=>l[n+1]-c)}function ot(l,c){if(c>0){const n=it(l);return Math.min(...n)>=c}return!0}function ls(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 ct(l){return(String(l).split(".")[1]||"").length}function dt(l,c){const n=Math.pow(10,c);return Math.round(l*n)/n}var oa=Xs,ut=ta,mt=na,ht=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(ut,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(mt,{className:"absolute h-full bg-primary"})}),e.jsx(ht,{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 Rs(){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 Ts=["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 xt({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,j]=t.useState(""),[h,N]=t.useState(m?.voiceId||"English_Trustworth_Man"),[P,S]=t.useState(m?.useCustomVoice||!1),[d,x]=t.useState(m?.customVoiceId||""),[y,E]=t.useState(m?.speed??1),[w,b]=t.useState(m?.pitch??0),[_,z]=t.useState(m?.emotion||"auto"),[M,T]=t.useState(m?.languageBoost||"English"),[A,v]=t.useState(m?.audioFormat||"mp3"),[k,q]=t.useState(null),[L,D]=t.useState(!1),[I,g]=t.useState(!1),[K,Y]=t.useState(0),H=t.useRef(null),{toast:ee}=$e();t.useEffect(()=>{const o={voiceId:h,useCustomVoice:P,customVoiceId:d,speed:y,pitch:w,emotion:_,languageBoost:M,audioFormat:A};localStorage.setItem(Is,JSON.stringify(o))},[h,P,d,y,w,_,M,A]),t.useEffect(()=>(L?(Y(0),H.current=setInterval(()=>{Y(o=>o+1)},1e3)):H.current&&(clearInterval(H.current),H.current=null),()=>{H.current&&clearInterval(H.current)}),[L]);const O=async()=>{if(!u.trim()){ee({title:"Text required",description:"Please enter text to generate audio",variant:"destructive"});return}D(!0),q(null);try{const o=P?d:h,te=new AbortController,i=setTimeout(()=>te.abort(),3e5),F=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:y,pitch:w,emotion:_,language_boost:M,audio_format:A})});if(clearTimeout(i),F.status===504||F.status===502||F.status===408)throw new Error("Request timed out. The audio model may be warming up - please try again.");const se=F.headers.get("content-type");if(!se||!se.includes("application/json"))throw new Error("Request timed out or server error. Please try again.");const X=await F.json();if(!F.ok||!X.success){const re=X.error?.message||"Failed to generate audio",ue=X.error?.code==="MISSING_API_TOKEN";throw new Error(ue?"Replicate API token not configured. Please add it in Settings → Integrations.":re)}q(X.data.audioUrl),ee({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.",F=te||i.toLowerCase().includes("timeout")||i.toLowerCase().includes("timed out");ee({title:F?"Generation timed out":"Generation failed",description:i,variant:"destructive"})}finally{D(!1)}};t.useEffect(()=>{const o=te=>{l&&(te.metaKey||te.ctrlKey)&&te.key==="Enter"&&(te.preventDefault(),u.trim()&&!L&&!I&&O())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l,u,L,I]);const V=async()=>{if(k){g(!0);try{await n(k),j(""),N("English_Trustworth_Man"),S(!1),x(""),E(1),b(0),z("auto"),T("English"),v("mp3"),q(null),c(!1)}catch(o){ee({title:"Save failed",description:o instanceof Error?o.message:"Failed to save audio. Please try again.",variant:"destructive"})}finally{g(!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(ye,{id:"text-mobile",placeholder:"Enter text to convert to speech...",value:u,onChange:o=>j(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(W,{value:P?"__custom__":h,onValueChange:o=>{o==="__custom__"?S(!0):(S(!1),N(o))},children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsxs(U,{className:"max-h-60",children:[Ts.map(o=>e.jsx(G,{value:o,className:"text-xs",children:o.replace(/_/g," ")},o)),e.jsx(G,{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: ",y.toFixed(1),"x"]}),e.jsx(Pe,{value:[y],onValueChange:([o])=>E(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: ",w>0?"+":"",w]}),e.jsx(Pe,{value:[w],onValueChange:([o])=>b(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(W,{value:_,onValueChange:z,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ds.map(o=>e.jsx(G,{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(W,{value:M,onValueChange:T,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Gs.map(o=>e.jsx(G,{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(W,{value:A,onValueChange:v,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:As.map(o=>e.jsx(G,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(R,{onClick:O,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(Rs,{}),e.jsxs("span",{children:[K,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(me,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(R,{onClick:V,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(ye,{id:"text",placeholder:"Enter text to convert to speech...",value:u,onChange:o=>j(o.target.value),rows:6,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Voice"}),e.jsxs(W,{value:P?"__custom__":h,onValueChange:o=>{o==="__custom__"?S(!0):(S(!1),N(o))},children:[e.jsx(B,{children:e.jsx($,{})}),e.jsxs(U,{className:"max-h-80",children:[Ts.map(o=>e.jsx(G,{value:o,children:o.replace(/_/g," ")},o)),e.jsx(G,{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: ",y.toFixed(1),"x"]}),e.jsx(Pe,{value:[y],onValueChange:([o])=>E(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: ",w>0?"+":"",w]}),e.jsx(Pe,{value:[w],onValueChange:([o])=>b(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(W,{value:_,onValueChange:z,children:[e.jsx(B,{children:e.jsx($,{})}),e.jsx(U,{children:Ds.map(o=>e.jsx(G,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Language Boost"}),e.jsxs(W,{value:M,onValueChange:T,children:[e.jsx(B,{children:e.jsx($,{})}),e.jsx(U,{children:Gs.map(o=>e.jsx(G,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Audio Format"}),e.jsxs(W,{value:A,onValueChange:v,children:[e.jsx(B,{children:e.jsx($,{})}),e.jsx(U,{children:As.map(o=>e.jsx(G,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(R,{onClick:O,disabled:!u.trim()||L||I,className:"w-full",children:L?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Rs,{}),e.jsxs("span",{children:["Generating... ",K,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(me,{children:"⌘"}),e.jsx(me,{children:"↵"})]})}),e.jsx(R,{onClick:V,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 ft({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,j]=t.useState(""),[h,N]=t.useState(m?.duration||"8"),[P,S]=t.useState(m?.resolution||"720p"),[d,x]=t.useState(m?.aspectRatio||"16:9"),[y,E]=t.useState(m?.generateAudio??!0),[w,b]=t.useState(null),[_,z]=t.useState(null),[M,T]=t.useState(null),[A,v]=t.useState(0),k=t.useRef(null),[q,L]=t.useState(!1),[D,I]=t.useState(!1),[g,K]=t.useState([]),{toast:Y}=$e();t.useEffect(()=>{const i={duration:h,resolution:P,aspectRatio:d,generateAudio:y};localStorage.setItem(Ls,JSON.stringify(i))},[h,P,d,y]),t.useEffect(()=>(q?(v(0),k.current=setInterval(()=>{v(i=>i+1)},1e3)):k.current&&(clearInterval(k.current),k.current=null),()=>{k.current&&clearInterval(k.current)}),[q]),t.useEffect(()=>{l&&H()},[l]);const H=async()=>{try{const F=await(await fetch(`${ae}/api/v1/resources`)).json();if(F.success){const se=(F.data||[]).filter(X=>{const re=X.type==="image/jpeg"||X.name.toLowerCase().endsWith(".jpg")||X.name.toLowerCase().endsWith(".jpeg"),ue=X.type==="image/png"||X.name.toLowerCase().endsWith(".png");return(re||ue)&&X.thumbnailPath});K(se)}}catch(i){console.error("Failed to fetch image resources:",i)}},ee=i=>{i===_?z(null):i===w?(b(null),z(i)):w?z(i):b(i)},O=()=>{b(null),z(null)},V=async()=>{if(!u.trim()){Y({title:"Prompt required",description:"Please enter a prompt to generate a video",variant:"destructive"});return}L(!0),T(null);try{const i=new AbortController,F=setTimeout(()=>i.abort(),3e5),se=await fetch(`${ae}/api/v1/resources/generate-video`,{method:"POST",headers:{"Content-Type":"application/json"},signal:i.signal,body:JSON.stringify({prompt:u,image:w||void 0,last_frame:_||void 0,duration:parseInt(h),resolution:P,aspect_ratio:d,generate_audio:y})});if(clearTimeout(F),se.status===504||se.status===502||se.status===408)throw new Error("Request timed out. The video model may be warming up - please try again.");const X=se.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 se.json();if(!se.ok||!re.success){const ue=re.error?.message||"Failed to generate video",he=re.error?.code==="MISSING_API_TOKEN";throw new Error(he?"Replicate API token not configured. Please add it in Settings → Integrations.":ue)}T(re.data.videoUrl),Y({title:"Video generated",description:"Your video has been generated successfully"})}catch(i){console.error("Generation error:",i);const F=i instanceof Error&&i.name==="AbortError",se=F?"Request timed out after 5 minutes. The model may be overloaded - please try again.":i instanceof Error?i.message:"Failed to generate video.",X=F||se.toLowerCase().includes("timeout")||se.toLowerCase().includes("timed out");Y({title:X?"Generation timed out":"Generation failed",description:se,variant:"destructive"})}finally{L(!1)}};t.useEffect(()=>{const i=F=>{l&&(F.metaKey||F.ctrlKey)&&F.key==="Enter"&&(F.preventDefault(),u.trim()&&!q&&!D&&V())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[l,u,q,D]);const Q=async()=>{if(M){I(!0);try{await n(M),j(""),N("8"),S("720p"),x("16:9"),E(!0),b(null),z(null),T(null),c(!1)}catch(i){Y({title:"Save failed",description:i instanceof Error?i.message:"Failed to save video. Please try again.",variant:"destructive"})}finally{I(!1)}}},o=()=>{!q&&!D&&c(!1)},te=i=>i===w?"start":i===_?"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:q?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..."})]}):M?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:M,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:O,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${!w&&!_?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),g.map(i=>{const F=te(i.id);return e.jsxs("button",{onClick:()=>ee(i.id),className:`relative flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${F?"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"}),F&&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:F==="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(ye,{id:"prompt-mobile",placeholder:"Describe the video you want to generate...",value:u,onChange:i=>j(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(W,{value:h,onValueChange:N,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Os.map(i=>e.jsx(G,{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(W,{value:P,onValueChange:S,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Vs.map(i=>e.jsx(G,{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(W,{value:d,onValueChange:x,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ws.map(i=>e.jsx(G,{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:y,onCheckedChange:i=>E(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(R,{onClick:V,disabled:!u.trim()||q||D,className:"flex-1 h-9",size:"sm",children:q?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ks,{}),e.jsxs("span",{children:[A,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(me,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(R,{onClick:Q,disabled:!M||q||D,variant:"outline",className:"flex-1 h-9",size:"sm",children:D?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(ye,{id:"prompt",placeholder:"Describe the video you want to generate...",value:u,onChange:i=>j(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(W,{value:h,onValueChange:N,children:[e.jsx(B,{id:"duration",children:e.jsx($,{})}),e.jsx(U,{children:Os.map(i=>e.jsx(G,{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(W,{value:P,onValueChange:S,children:[e.jsx(B,{id:"resolution",children:e.jsx($,{})}),e.jsx(U,{children:Vs.map(i=>e.jsx(G,{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(W,{value:d,onValueChange:x,children:[e.jsx(B,{id:"aspectRatio",children:e.jsx($,{})}),e.jsx(U,{children:Ws.map(i=>e.jsx(G,{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:y,onCheckedChange:i=>E(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(R,{onClick:V,disabled:!u.trim()||q||D,className:"w-full",children:q?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ks,{}),e.jsxs("span",{children:["Generating... ",A,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(me,{children:"⌘"}),e.jsx(me,{children:"↵"})]})}),e.jsx(R,{onClick:Q,disabled:!M||q||D,variant:"outline",className:"w-full",children:D?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:q?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..."})]}):M?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:M,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:O,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${!w&&!_?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),g.map(i=>{const F=te(i.id);return e.jsxs("button",{onClick:()=>ee(i.id),className:`relative flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${F?"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"}),F&&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:F==="start"?"Start":"End"})]},i.id)})]})]})]})]})]})})}function pt({open:l,onOpenChange:c,resource:n,onCopyPath:p,onDownload:m,onNavigate:u,canNavigatePrev:j,canNavigateNext:h}){const[N,P]=t.useState(null),[S,d]=t.useState(!1),[x,y]=t.useState(!1);t.useEffect(()=>{y(!1)},[n?.id,l]);const E=n?`${ae}/api/v1/resources/${n.id}`:"",w=n?.type.startsWith("image/")??!1,b=n?n.type==="image/svg+xml"||n.name.toLowerCase().endsWith(".svg"):!1,_=n?n.type==="application/pdf"||n.name.toLowerCase().endsWith(".pdf"):!1,z=n?.type.startsWith("video/")??!1,M=n?.type.startsWith("audio/")??!1,T=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,A=n?n.name.toLowerCase().endsWith(".md")||n.name.toLowerCase().endsWith(".markdown"):!1,v=n?n.type==="application/json"||n.name.toLowerCase().endsWith(".json"):!1,k=n?n.type==="text/html"||n.name.toLowerCase().endsWith(".html"):!1;if(t.useEffect(()=>{const g=K=>{if(l){if(K.key==="Escape"){x?y(!1):c(!1);return}if(!x){if(K.key==="ArrowLeft"&&j){K.preventDefault(),u("prev");return}K.key==="ArrowRight"&&h&&(K.preventDefault(),u("next"))}}};if(l)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[l,c,u,j,h,x]),t.useEffect(()=>{l&&n&&(T||A||v||k)?(d(!0),fetch(E).then(g=>{if(g.ok)return g.text();throw new Error("Failed to load file")}).then(g=>{P(g)}).catch(g=>{console.error("Failed to load text content:",g),P(null)}).finally(()=>{d(!1)})):P(null)},[l,n?.id,T,A,v,k,E]),!n)return null;const q=g=>{if(g===0)return"0 B";const K=1024,Y=["B","KB","MB","GB"],H=Math.floor(Math.log(g)/Math.log(K));return parseFloat((g/Math.pow(K,H)).toFixed(2))+" "+Y[H]},L=g=>new Date(g).toLocaleString(),D=g=>g.startsWith("image/")?e.jsx(Ne,{className:"h-6 w-6"}):g.startsWith("video/")?e.jsx(Be,{className:"h-6 w-6"}):g.startsWith("audio/")?e.jsx(fe,{className:"h-6 w-6"}):g.includes("text")||g.includes("document")||g.includes("code")?e.jsx(we,{className:"h-6 w-6"}):g.includes("json")||g.includes("javascript")||g.includes("typescript")?e.jsx(ss,{className:"h-6 w-6"}):e.jsx(Ze,{className:"h-6 w-6"}),I=()=>{if(b)return e.jsxs(e.Fragment,{children:[e.jsx("img",{src:E,alt:n.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(R,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>y(!0),children:e.jsx(ys,{className:"h-4 w-4"})})]});if(_)return e.jsx("iframe",{src:E,className:"w-full h-full min-h-[600px] rounded-lg border",title:n.name});if(z)return e.jsx("video",{src:E,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",children:"Your browser does not support the video tag."});if(M)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:E,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]});if(A&&N!==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(pa,{remarkPlugins:[va],rehypePlugins:[ga],children:N})});if(k&&N!==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:N,className:"w-full h-full min-h-[600px] rounded-lg border",title:n.name,sandbox:"allow-same-origin"});if(v&&N!==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 g=N;try{const K=JSON.parse(N);g=JSON.stringify(K,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:g})})})}return T&&N!==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:N})})}):w?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:E,alt:n.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(R,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>y(!0),children:e.jsx(ys,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[D(n.type),e.jsx("p",{className:"text-sm",children:"Preview not available for this file type"}),e.jsxs(R,{variant:"outline",onClick:()=>m(n),children:[e.jsx(es,{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:[D(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(R,{variant:"ghost",size:"sm",onClick:()=>p(n),title:"Copy path to clipboard",children:e.jsx(Xe,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>m(n),title:"Download",children:e.jsx(es,{className:"h-4 w-4"})}),e.jsx(R,{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:[j&&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"})}),I()]}),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(La,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsx("span",{children:q(n.size)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"}),e.jsx("span",{children:L(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(Pa,{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(g=>e.jsx(Me,{variant:"secondary",className:"text-xs",children:g},g))})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.metadata.description?e.jsxs(e.Fragment,{children:[e.jsx(we,{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(R,{size:"sm",className:"h-6 text-xs px-2 flex-shrink-0",onClick:()=>{navigator.clipboard.writeText(n.metadata.generationPrompt||"")},children:[e.jsx(Xe,{className:"h-2.5 w-2.5 mr-1"}),"Copy Prompt"]})]})]})})]})})]})}),x&&(w||b)&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black/95 flex items-center justify-center",onClick:()=>y(!1),children:[e.jsx(R,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 h-10 w-10 text-white hover:bg-white/20",onClick:()=>y(!1),children:e.jsx(cs,{className:"h-6 w-6"})}),e.jsx("img",{src:E,alt:n.name,className:"max-w-[95vw] max-h-[95vh] object-contain",onClick:g=>g.stopPropagation()})]})]})}function Mt(){const[l,c]=t.useState([]),[n,p]=t.useState(!0),[m,u]=t.useState(!1),[j,h]=t.useState(""),[N,P]=t.useState(!1),[S,d]=t.useState([]),[x,y]=t.useState(""),[E,w]=t.useState(""),[b,_]=t.useState([]),[z,M]=t.useState(!1),[T,A]=t.useState(!1),[v,k]=t.useState(!1),[q,L]=t.useState(null),[D,I]=t.useState(null),[g,K]=t.useState(null),[Y,H]=t.useState(1),ee=12,O=t.useRef(null),{toast:V}=$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&&_(Array.from(s))},te=async()=>{if(b.length!==0){u(!0);try{for(const s of b){const r=new FormData;if(r.append("file",s),r.append("tags",S.join(", ")),r.append("description",E),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:r})).ok)throw new Error("Upload failed")}d([]),y(""),w(""),_([]),P(!1),await Q(),V({title:"Upload successful",description:`${b.length} file(s) uploaded successfully`})}catch(s){console.error("Upload failed:",s),V({title:"Upload failed",description:"Failed to upload files. Please try again.",variant:"destructive"})}finally{u(!1)}}},i=()=>{d([]),y(""),w(""),_([]),P(!1)},F=s=>{if(s.key==="Enter"){s.preventDefault();const r=x.trim();r&&!S.includes(r)&&(d([...S,r]),y(""))}},se=s=>{d(S.filter(r=>r!==s))},X=s=>{_(b.filter((r,f)=>f!==s))},re=async()=>{if(g)try{if((await fetch(`${ae}/api/v1/resources/${g.id}`,{method:"DELETE"})).ok)await Q(),V({title:"Resource deleted",description:`${g.name} has been deleted`});else throw new Error("Delete failed")}catch(s){console.error("Failed to delete resource:",s),V({title:"Delete failed",description:"Failed to delete resource. Please try again.",variant:"destructive"})}finally{K(null)}},ue=async s=>{try{const r=`.nut/resources/files/${s.path}`;await Ca(r),V({title:"Path copied!",description:`Copied ${r} to clipboard`})}catch(r){console.error("Failed to copy path:",r),V({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},he=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(fs,{className:"h-4 w-4"}):e.jsx(Ne,{className:"h-4 w-4"}):s.startsWith("video/")?e.jsx(gs,{className:"h-4 w-4"}):s.startsWith("audio/")?e.jsx(xs,{className:"h-4 w-4"}):s==="application/pdf"||f.endsWith(".pdf")?e.jsx(we,{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(ps,{className:"h-4 w-4"}):s.includes("spreadsheet")||s.includes("excel")||f.match(/\.(xls|xlsx|csv)$/)?e.jsx(vs,{className:"h-4 w-4"}):s.includes("presentation")||s.includes("powerpoint")||f.match(/\.(ppt|pptx)$/)?e.jsx(bs,{className:"h-4 w-4"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(we,{className:"h-4 w-4"}):s.includes("font")||f.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(js,{className:"h-4 w-4"}):e.jsx(Ze,{className:"h-4 w-4"})},Re=(s,r)=>{const f=r.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||f.endsWith(".svg")?e.jsx(fs,{className:"h-16 w-16"}):e.jsx(Ne,{className:"h-16 w-16"}):s.startsWith("video/")?e.jsx(gs,{className:"h-16 w-16"}):s.startsWith("audio/")?e.jsx(xs,{className:"h-16 w-16"}):s==="application/pdf"||f.endsWith(".pdf")?e.jsx(we,{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(ps,{className:"h-16 w-16"}):s.includes("spreadsheet")||s.includes("excel")||f.match(/\.(xls|xlsx|csv)$/)?e.jsx(vs,{className:"h-16 w-16"}):s.includes("presentation")||s.includes("powerpoint")||f.match(/\.(ppt|pptx)$/)?e.jsx(bs,{className:"h-16 w-16"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(we,{className:"h-16 w-16"}):s.includes("font")||f.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(js,{className:"h-16 w-16"}):e.jsx(Ze,{className:"h-16 w-16"})},xe=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:Re(s.type,s.name)})})},ie=l.filter(s=>{if(!j)return!0;const r=j.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/ee),Ce=(Y-1)*ee,Te=ie.slice(Ce,Ce+ee);t.useEffect(()=>{H(1)},[j]);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`,de=new FormData;de.append("file",Z,ne),de.append("tags",S.join(","));const ce=r?.prompt?`Generated with: "${r.prompt}"${r.model?` (${r.model})`:""}`:E;if(de.append("description",ce),r?.prompt&&de.append("generationPrompt",r.prompt),r?.model&&de.append("generationModel",r.model),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:de})).ok)throw new Error("Upload failed");await Q(),V({title:"Image saved",description:"Generated image has been saved to resources"})}catch(f){throw console.error("Failed to save generated image:",f),V({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 de=`generated-audio-${Date.now()}.${Z}`,ce=new FormData;if(ce.append("file",f,de),ce.append("tags",S.join(",")),ce.append("description",E),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:ce})).ok)throw new Error("Upload failed");await Q(),V({title:"Audio saved",description:"Generated audio has been saved to resources"})}catch(r){throw console.error("Failed to save generated audio:",r),V({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 de=`generated-video-${Date.now()}.${Z}`,ce=new FormData;if(ce.append("file",f,de),ce.append("tags",S.join(",")),ce.append("description",E),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:ce})).ok)throw new Error("Upload failed");await Q(),V({title:"Video saved",description:"Generated video has been saved to resources"})}catch(r){throw console.error("Failed to save generated video:",r),V({title:"Save failed",description:r instanceof Error?r.message:"Failed to save generated video",variant:"destructive"}),r}finally{u(!1)}},a=s=>{if(D===null)return;const r=s==="next"?D+1:D-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(ja,{children:[e.jsx(ya,{asChild:!0,children:e.jsxs(R,{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(ba,{className:"h-3 w-3 ml-1 opacity-50"})]})}),e.jsxs(wa,{align:"end",className:"min-w-[var(--radix-dropdown-menu-trigger-width)]",children:[e.jsxs(Je,{onClick:()=>M(!0),children:[e.jsx(Ne,{className:"h-4 w-4 mr-2"}),"Image"]}),e.jsxs(Je,{onClick:()=>A(!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(R,{size:"sm",onClick:()=>P(!N),children:[e.jsx(hs,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Upload Resources"})]})]})]}),e.jsx(pe,{open:N,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(ds,{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:()=>O.current?.click(),children:[e.jsx($a,{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:O,type:"file",multiple:!0,className:"hidden",onChange:s=>s.target.files&&o(s.target.files)}),b.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Selected Files (",b.length,")"]}),e.jsx("div",{className:"border rounded-lg p-3 max-h-40 overflow-y-auto space-y-2",children:b.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(R,{variant:"ghost",size:"sm",onClick:()=>X(r),className:"h-6 w-6 p-0 ml-2",children:e.jsx(us,{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=>y(s.target.value),onKeyDown:F}),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:()=>se(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(ye,{id:"description",placeholder:"Brief description of this resource...",value:E,onChange:s=>w(s.target.value),rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(R,{variant:"outline",onClick:i,disabled:m,children:"Cancel"}),e.jsx(R,{onClick:te,disabled:b.length===0||m,children:m?"Uploading...":`Upload ${b.length>0?`(${b.length})`:""}`})]})]})]})}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs("div",{className:"relative flex-1 w-full",children:[e.jsx(Ea,{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:j,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(ms,{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?Te.map(s=>e.jsxs(Ye,{className:"hover:shadow-lg hover:bg-muted transition-all cursor-pointer",onClick:r=>De(s,r),children:[e.jsxs(ms,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[Ie(s.type,s.name),e.jsx(_a,{className:"text-sm font-medium truncate",children:s.name})]}),e.jsxs(Sa,{className:"text-xs",children:[he(s.size)," • ",new Date(s.uploadedAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex justify-end space-x-1 mt-2",children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:r=>{r.stopPropagation(),ue(s)},title:"Copy path to clipboard",children:e.jsx(Xe,{className:"h-3 w-3"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:r=>{r.stopPropagation(),Ge(s)},children:e.jsx(es,{className:"h-3 w-3"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:r=>{r.stopPropagation(),K(s)},children:e.jsx(us,{className:"h-3 w-3"})})]})]}),e.jsxs(Qe,{className:"pt-0",children:[e.jsx("div",{className:"mb-3",children:xe(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(Na,{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(R,{className:"mt-4",onClick:()=>P(!0),children:[e.jsx(hs,{className:"mr-2 h-4 w-4"}),"Add First Resource"]})]})})})}),ie.length>ee&&e.jsxs("div",{className:"flex items-center justify-center gap-4 pt-4 pb-8",children:[e.jsxs(R,{variant:Y===1?"outline":"default",size:"sm",onClick:()=>H(s=>Math.max(1,s-1)),disabled:Y===1,children:[e.jsx(zs,{className:"h-4 w-4 mr-1"}),"Previous"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",Y," of ",J]}),e.jsxs(R,{variant:Y===J?"outline":"default",size:"sm",onClick:()=>H(s=>Math.min(J,s+1)),disabled:Y===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(Ja,{open:z,onOpenChange:M,onSave:Ae,onCustomizeInAssistant:Le}),e.jsx(xt,{open:T,onOpenChange:A,onSave:qe}),e.jsx(ft,{open:v,onOpenChange:k,onSave:He}),e.jsx(pt,{open:!!q,onOpenChange:s=>{s||L(null),s||I(null)},resource:q,onCopyPath:ue,onDownload:Ge,onNavigate:a,canNavigatePrev:D!==null&&D>0,canNavigateNext:D!==null&&D<ie.length-1}),e.jsx(pe,{open:!!g,onOpenChange:s=>!s&&K(null),children:e.jsxs(ge,{className:"max-w-md",children:[e.jsxs(ve,{children:[e.jsx(je,{children:"Delete Resource"}),e.jsxs(ds,{children:["Are you sure you want to delete ",e.jsx("strong",{children:g?.name}),"? This action cannot be undone."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(R,{variant:"outline",onClick:()=>K(null),children:"Cancel"}),e.jsx(R,{variant:"destructive",onClick:re,children:"Delete"})]})]})})]})}export{Mt as default};
@@ -0,0 +1,13 @@
1
+ import{u as j,a as v,r as n,A as d,j as e,B as h,L as g,a8 as y}from"./index-VBSAUXJg.js";import{C as m,a as x,b as N,c as C}from"./card-DdTVdbjN.js";import{M as w}from"./markdown-editor-CgzPMMiE.js";import{A as S}from"./arrow-left-BgRi6mQL.js";import{C as b}from"./circle-check-big-CQsXU9Fx.js";function B(){const u=j(),{toast:t}=v(),[i,a]=n.useState(""),[f,r]=n.useState(!0),[o,l]=n.useState(!1);n.useEffect(()=>{fetch(`${d}/api/v1/context/role`).then(s=>s.json()).then(s=>{s.success&&a(s.document.content.trim()),r(!1)}).catch(s=>{console.error("Failed to load context:",s),t({title:"Error",description:"Failed to load role definition",variant:"destructive"}),r(!1)})},[t]);const p=async()=>{l(!0);try{const c=await(await fetch(`${d}/api/v1/context/role`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,metadata:{}})})).json();if(c.success)t({title:"Success",description:"Role definition saved successfully",action:e.jsx(b,{className:"h-4 w-4"})}),u("/context/role");else throw new Error(c.error||"Failed to save context")}catch(s){console.error("Save error:",s),t({title:"Error",description:"Failed to save role definition",variant:"destructive"})}finally{l(!1)}};return f?e.jsx("div",{className:"space-y-6",children:e.jsx(m,{children:e.jsx(x,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-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(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(g,{to:"/context/role",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"w-4 h-4"})})}),e.jsxs(h,{onClick:p,disabled:o,size:"sm",children:[e.jsx(y,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:o?"Saving...":"Save"})]})]})]}),e.jsxs(m,{children:[e.jsx(N,{children:e.jsx(C,{children:"Role Documentation"})}),e.jsx(x,{children:e.jsx(w,{value:i,onChange:s=>a(s||""),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{B as default};
@@ -0,0 +1 @@
1
+ import{a as N,r as t,A as v,j as e,J as C,F as g,B as a,L as c,R as d,M as w,aB as y,ay as b}from"./index-VBSAUXJg.js";import{C as i,a as r,b as E,c as R}from"./card-DdTVdbjN.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 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,{children:e.jsx(R,{className:"text-lg font-semibold",children:"Role Documentation"})}),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};