@lovelybunch/api 1.0.71-alpha.5 → 1.0.71-alpha.6

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 (85) hide show
  1. package/dist/routes/api/v1/resources/generate-video/index.d.ts +3 -0
  2. package/dist/routes/api/v1/resources/generate-video/index.js +5 -0
  3. package/dist/routes/api/v1/resources/generate-video/route.d.ts +19 -0
  4. package/dist/routes/api/v1/resources/generate-video/route.js +235 -0
  5. package/dist/routes/api/v1/resources/index.js +2 -0
  6. package/dist/routes/api/v1/resources/route.js +3 -3
  7. package/package.json +4 -4
  8. package/static/assets/{AgentDetailPage-B3CFO9Vg.js → AgentDetailPage-Bw8wHgla.js} +1 -1
  9. package/static/assets/{AgentEditPage-Cc8k9uYb.js → AgentEditPage-CQ9Y3ez8.js} +1 -1
  10. package/static/assets/{AgentsPage-CcRVHD2p.js → AgentsPage-DcgU1MPa.js} +1 -1
  11. package/static/assets/{AgentsSettingsPage-BMphtJ6C.js → AgentsSettingsPage-CgoXxqGL.js} +1 -1
  12. package/static/assets/{ApiKeysSettingsPage-BLlmALn1.js → ApiKeysSettingsPage-BgqGOa4p.js} +1 -1
  13. package/static/assets/{ArchitectureEditPage-B8YrHerA.js → ArchitectureEditPage-DrEnTloL.js} +1 -1
  14. package/static/assets/{ArchitecturePage-fIoEV_ow.js → ArchitecturePage-Dpd6cyyT.js} +1 -1
  15. package/static/assets/{AuthSettingsPage-CICO_5eb.js → AuthSettingsPage-wu1zFEx-.js} +1 -1
  16. package/static/assets/{CallbackPage-6lJyGru9.js → CallbackPage-DYzikcPp.js} +1 -1
  17. package/static/assets/{CodePage-gGhNXTQn.js → CodePage-CtM-PEHU.js} +1 -1
  18. package/static/assets/{CollapsibleSection-CkCVMSBD.js → CollapsibleSection-B23j-nZD.js} +1 -1
  19. package/static/assets/{DashboardPage-qkyq1COW.js → DashboardPage-BoPCq6M9.js} +1 -1
  20. package/static/assets/{GitPage-Dj9uMiQV.js → GitPage-DYicFQBx.js} +1 -1
  21. package/static/assets/{GitSettingsPage--hjPt4zu.js → GitSettingsPage-B-1Nnid8.js} +1 -1
  22. package/static/assets/{IdentityPage-DzqrsAU2.js → IdentityPage-Cvj6SDPj.js} +1 -1
  23. package/static/assets/{ImplementationStepsEditor-GxhD-g8y.js → ImplementationStepsEditor-CCfJKk2U.js} +1 -1
  24. package/static/assets/{IntegrationsSettingsPage-DR_v_Fbo.js → IntegrationsSettingsPage-BgLXCF-u.js} +1 -1
  25. package/static/assets/{KnowledgeDetailPage-BEHrLcNg.js → KnowledgeDetailPage-I9erHJXN.js} +1 -1
  26. package/static/assets/{KnowledgeEditPage-CETMgdZf.js → KnowledgeEditPage-BfaWotPl.js} +1 -1
  27. package/static/assets/{KnowledgePage-Dz2YIqdH.js → KnowledgePage-x9ShzjoT.js} +1 -1
  28. package/static/assets/{LoginPage-DSxl4xGK.js → LoginPage-CZtwhbdN.js} +1 -1
  29. package/static/assets/{McpSettingsPage-CLDzqlt3.js → McpSettingsPage-BHPjMqOX.js} +1 -1
  30. package/static/assets/{NewAgentPage-DlEnBUUY.js → NewAgentPage-D-Pj_KgZ.js} +1 -1
  31. package/static/assets/{NewKnowledgePage-CI8D1NRB.js → NewKnowledgePage-CoVnCUx6.js} +1 -1
  32. package/static/assets/{NewProposalPage-B1hVwad9.js → NewProposalPage-nCTq2mBC.js} +1 -1
  33. package/static/assets/{ProjectEditPage-t_oD7x6f.js → ProjectEditPage-d1cMZArt.js} +1 -1
  34. package/static/assets/{ProjectPage-CMez4KRO.js → ProjectPage-KwwOjk5b.js} +1 -1
  35. package/static/assets/{PromptsSettingsPage-DXvS4JX8.js → PromptsSettingsPage-fSs6HBAk.js} +1 -1
  36. package/static/assets/{ProposalDetailPage-Cbld0UYO.js → ProposalDetailPage-BnLOBPPT.js} +1 -1
  37. package/static/assets/{ProposalEditPage-Dujm4G1-.js → ProposalEditPage-bIYTFTmG.js} +1 -1
  38. package/static/assets/{ProposalsPage-0L4kWC5Y.js → ProposalsPage-D8W2d6g6.js} +1 -1
  39. package/static/assets/ResourcesPage-Dq9DZFd7.js +71 -0
  40. package/static/assets/{RulesSettingsPage-D6qjkKbl.js → RulesSettingsPage-SWRxKVNH.js} +1 -1
  41. package/static/assets/{SchedulePage-CgnTsib0.js → SchedulePage-DGxD8ZaL.js} +1 -1
  42. package/static/assets/{TagInput-DJMwLVTn.js → TagInput-CYcNHzrk.js} +1 -1
  43. package/static/assets/{TerminalPage-EYVbapc9.js → TerminalPage-fabajZvk.js} +1 -1
  44. package/static/assets/{TerminalSessionPage-CQCLFjOR.js → TerminalSessionPage-DuJsKT9f.js} +1 -1
  45. package/static/assets/{UserPreferencesPage-KAsCdvFQ.js → UserPreferencesPage-DQMtobsK.js} +1 -1
  46. package/static/assets/{UserSettingsPage-DclI2Mhd.js → UserSettingsPage-CFEb7pD0.js} +1 -1
  47. package/static/assets/{UtilitiesPage-BKdyva6y.js → UtilitiesPage-qStPGLN_.js} +1 -1
  48. package/static/assets/{alert-p2sQnjrU.js → alert-Baaj8mli.js} +1 -1
  49. package/static/assets/{arrow-down-DGeJDsho.js → arrow-down-CSpiROUo.js} +1 -1
  50. package/static/assets/{arrow-left-BRSAC1N6.js → arrow-left-CdJt7_wH.js} +1 -1
  51. package/static/assets/{arrow-up-C5ecpR5U.js → arrow-up-ugn3lusK.js} +1 -1
  52. package/static/assets/{badge-DaM4gF82.js → badge-fHjW-wEe.js} +1 -1
  53. package/static/assets/{browser-modal-CyeEbzDK.js → browser-modal-D6BB5mxm.js} +1 -1
  54. package/static/assets/{calendar-CV2haPQ9.js → calendar-DXMWQL-h.js} +1 -1
  55. package/static/assets/{card-B9ym6neB.js → card-C9ekeZtD.js} +1 -1
  56. package/static/assets/{chevron-left-D8aMFTU2.js → chevron-left-BkP_F3xd.js} +1 -1
  57. package/static/assets/{circle-alert-C-piOZLm.js → circle-alert-DnIYekt3.js} +1 -1
  58. package/static/assets/{circle-check-4zzXsmHH.js → circle-check-BO-qmBFl.js} +1 -1
  59. package/static/assets/{circle-check-big-AlE11jqb.js → circle-check-big-BUVglreY.js} +1 -1
  60. package/static/assets/{circle-play-cWY3nlZW.js → circle-play-84ZOWBDG.js} +1 -1
  61. package/static/assets/{circle-x-D58MbKgZ.js → circle-x-EQNlLpRR.js} +1 -1
  62. package/static/assets/{clipboard-BFF6-pdC.js → clipboard-Dv0iwZO9.js} +1 -1
  63. package/static/assets/{clock-B-uSJOTR.js → clock-BxO7xcX9.js} +1 -1
  64. package/static/assets/{download-DrQn0jny.js → download-CpaVC4DU.js} +1 -1
  65. package/static/assets/{eye-BcjteMts.js → eye-BSR7OEmk.js} +1 -1
  66. package/static/assets/{folder-git-2-B_ezHf_E.js → folder-git-2-9fWvFiHp.js} +1 -1
  67. package/static/assets/{index-B0JO3x3V.js → index-BAEEeZzi.js} +3 -3
  68. package/static/assets/index-DdGUrKz8.css +2 -0
  69. package/static/assets/{label-BHOOQ99D.js → label-CRsu1MwQ.js} +1 -1
  70. package/static/assets/{markdown-editor-B0i_LOAR.js → markdown-editor-Dop22vuJ.js} +1 -1
  71. package/static/assets/{pause-DqQ7Twc6.js → pause-C7KYrzQF.js} +1 -1
  72. package/static/assets/{play-Y2N8OVBu.js → play-DhUf2mKM.js} +1 -1
  73. package/static/assets/{plus-D737EJ5S.js → plus-CemYz5Fm.js} +1 -1
  74. package/static/assets/{radio-group-nRRUTZ_w.js → radio-group-Dz2cO4IQ.js} +1 -1
  75. package/static/assets/{refresh-cw-uBnPtZwp.js → refresh-cw-BL3y7jJo.js} +1 -1
  76. package/static/assets/{search-cntvIhnF.js → search-BvRo_rak.js} +1 -1
  77. package/static/assets/{switch-BYf9VEgx.js → switch-CDOrVL8G.js} +1 -1
  78. package/static/assets/{tabs-BnsC3AY5.js → tabs-CP_A6r0A.js} +1 -1
  79. package/static/assets/{tag-C_HL28Xd.js → tag-BpNIhvRX.js} +1 -1
  80. package/static/assets/{terminal-preview-Qv4UvCJz.js → terminal-preview-CbgoHEQH.js} +1 -1
  81. package/static/assets/{use-terminal-5sW1t6SD.js → use-terminal-ZvK-kdxE.js} +1 -1
  82. package/static/assets/{zap-CrLPiVyl.js → zap-DOtH7YrV.js} +1 -1
  83. package/static/index.html +2 -2
  84. package/static/assets/ResourcesPage-5sZL01s_.js +0 -66
  85. package/static/assets/index-C8p-lTq9.css +0 -2
@@ -1 +1 @@
1
- import{E as re,u as ne,r as l,H as le,j as e,B as n,L as h,J as ie,M as oe,N as ce,T as de,O as me,P as he,Q as xe,R as pe,U as ue,V as je,W as fe,Y as I,Z as F,k as ge,D as R,_ as B,a as z,b as H,d as V,e as J,v as ve,w as Ne,x as Ce,y as ye,z as c,$ as M,a0 as we,a1 as Se,A as g}from"./index-B0JO3x3V.js";import{c as be}from"./clipboard-B9ndUJKl.js";import{C as d,b as x,a as m,c as u,d as _}from"./card-B9ym6neB.js";import{B as p}from"./badge-DaM4gF82.js";import{L as q}from"./label-BHOOQ99D.js";import{A as S}from"./arrow-left-BRSAC1N6.js";import{C as De,a as Ae}from"./clipboard-BFF6-pdC.js";import{D as Pe}from"./download-DrQn0jny.js";import{C as ke}from"./calendar-CV2haPQ9.js";import{C as Ee}from"./clock-B-uSJOTR.js";function Q(r){switch(r){case"approved":case"code-complete":return"default";case"in-review":return"secondary";case"rejected":return"destructive";default:return"outline"}}function W(r){switch(r){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function He(){const{id:r}=re(),Y=ne(),[s,v]=l.useState(null),[Z,b]=l.useState(!0),[N,D]=l.useState(null),[A,P]=l.useState(!1),[k,E]=l.useState(!1),[T,$]=l.useState(!1),[j,C]=l.useState(""),[G,y]=l.useState(!1),[K,w]=l.useState(!1),[f,U]=l.useState("draft"),[X,L]=l.useState(!1),{toast:O}=le();l.useEffect(()=>{async function t(){if(r)try{b(!0);const o=await(await fetch(`${g}/api/v1/proposals/${r}`)).json();o.success?v(o.data):D(o.error?.message||"Failed to fetch proposal")}catch(a){D(a instanceof Error?a.message:"Unknown error")}finally{b(!1)}}t()},[r]);const ee=async()=>{if(r){P(!0);try{const a=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"DELETE"})).json();a.success?Y("/proposals"):alert(a.error?.message||"Failed to delete proposal")}catch(t){alert(`Error deleting proposal: ${t instanceof Error?t.message:"Unknown error"}`)}finally{P(!1)}}},se=async()=>{if(!(!s||!r||f===s.status)){E(!0);try{const a=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:f})})).json();a.success?(v(a.data),y(!1)):alert(a.error?.message||"Failed to update status")}catch(t){alert(`Error updating status: ${t instanceof Error?t.message:"Unknown error"}`)}finally{E(!1)}}},te=async()=>{if(!(!s||!r||!j.trim())){$(!0);try{const t={id:`comment-${Date.now()}`,text:j,author:"current-user",timestamp:new Date().toISOString()},a=[...s.metadata.comments||[],t],i=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comments:a})})).json();i.success?(v(i.data),C(""),w(!1)):alert(i.error?.message||"Failed to add comment")}catch(t){alert(`Error adding comment: ${t instanceof Error?t.message:"Unknown error"}`)}finally{$(!1)}}},ae=()=>{if(!s)return;const t={...s,exportedAt:new Date().toISOString()},a=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),o=URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.download=`proposal-${s.id}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)};return Z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(h,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})})})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]})}),e.jsx(m,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-5/6 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-4/6 animate-pulse"})]})})]})]}):N||!s?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:N||"Proposal not found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(h,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:N||"Proposal not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The proposal with ID "',r,'" could not be found.']}),e.jsx(n,{asChild:!0,className:"mt-4",children:e.jsx(h,{to:"/proposals",children:"Back to Proposals"})})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.intent}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(h,{to:"/proposals",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})}),e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(h,{to:`/proposals/${r}/edit`,children:[e.jsx(ie,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,children:e.jsxs(n,{variant:"destructive",size:"sm",disabled:A,children:[e.jsx(de,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:A?"Deleting...":"Delete"})]})}),e.jsxs(me,{children:[e.jsxs(he,{children:[e.jsx(xe,{children:"Are you absolutely sure?"}),e.jsxs(pe,{children:["This action cannot be undone. This will permanently delete the change proposal",e.jsxs("span",{className:"font-semibold",children:[' "',s.intent,'"']})," and remove it from the system."]})]}),e.jsxs(ue,{children:[e.jsx(je,{children:"Cancel"}),e.jsx(fe,{onClick:ee,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Proposal"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const t=`.nut/proposals/${s.id}.md`;try{await be(t),L(!0),O({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>L(!1),2e3)}catch(a){console.error("Failed to copy path:",a),O({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono",children:[e.jsx("span",{children:`.nut/proposals/${s.id}.md`}),X?e.jsx(De,{className:"h-3.5 w-3.5"}):e.jsx(Ae,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(d,{children:[e.jsx(x,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(u,{children:"Proposal Details"}),e.jsxs("div",{className:"flex gap-2",children:[s.metadata.priority&&e.jsx(p,{variant:W(s.metadata.priority),children:s.metadata.priority}),e.jsx(p,{variant:Q(s.status),children:s.status})]})]})}),e.jsx(m,{className:"space-y-4",children:s.content?e.jsx(I,{children:s.content}):e.jsx("p",{className:"text-muted-foreground",children:"No detailed content available for this proposal."})})]}),s.planSteps&&s.planSteps.length>0&&e.jsxs(d,{children:[e.jsxs(x,{children:[e.jsx(u,{children:"Implementation Steps"}),e.jsxs(_,{children:[s.planSteps.length," step",s.planSteps.length!==1?"s":""," planned"]})]}),e.jsx(m,{children:e.jsx("div",{className:"space-y-3",children:s.planSteps.map((t,a)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-xs font-medium",children:a+1}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:t.description}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:e.jsx(p,{variant:"outline",className:"text-xs",children:t.status})})]})]},t.id))})})]}),s.metadata.comments&&s.metadata.comments.length>0&&e.jsxs(d,{children:[e.jsxs(x,{children:[e.jsx(u,{children:"Comments"}),e.jsxs(_,{children:[s.metadata.comments.length," comment",s.metadata.comments.length!==1?"s":""]})]}),e.jsx(m,{children:e.jsx("div",{className:"space-y-4",children:s.metadata.comments.map((t,a)=>e.jsxs("div",{className:"border-l-2 border-muted pl-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(F,{className:"h-3 w-3"}),e.jsx("span",{children:t.author}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(t.timestamp).toLocaleString()})]}),e.jsx(I,{className:"prose-sm prose-p:mb-2 prose-ul:my-2 prose-ol:my-2",children:t.text})]},t.id||a))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(u,{children:"Proposal Actions"})}),e.jsxs(m,{className:"space-y-2",children:[e.jsx(n,{variant:"default",className:"w-full justify-start",asChild:!0,children:e.jsxs(h,{to:`/terminal/${r}`,children:[e.jsx(ge,{className:"h-4 w-4 mr-2"}),"Prepare Coding Agent"]})}),e.jsxs(R,{open:G,onOpenChange:y,children:[e.jsx(B,{asChild:!0,children:e.jsx(n,{variant:"outline",className:"w-full justify-start",onClick:()=>U(s?.status||"draft"),children:"Change Status"})}),e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(V,{children:"Change Proposal Status"}),e.jsx(J,{children:"Update the status of this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(q,{htmlFor:"status",children:"Status"}),e.jsxs(ve,{value:f,onValueChange:t=>U(t),children:[e.jsx(Ne,{children:e.jsx(Ce,{placeholder:"Select status"})}),e.jsxs(ye,{children:[e.jsx(c,{value:"draft",children:"Draft"}),e.jsx(c,{value:"proposed",children:"Proposed"}),e.jsx(c,{value:"in-review",children:"In Review"}),e.jsx(c,{value:"approved",children:"Approved"}),e.jsx(c,{value:"code-complete",children:"Code Complete"}),e.jsx(c,{value:"merged",children:"Merged"}),e.jsx(c,{value:"rejected",children:"Rejected"})]})]})]})}),e.jsxs(M,{children:[e.jsx(n,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(n,{onClick:se,disabled:k||f===s?.status,children:k?"Updating...":"Update Status"})]})]})]}),e.jsxs(R,{open:K,onOpenChange:w,children:[e.jsx(B,{asChild:!0,children:e.jsx(n,{variant:"outline",className:"w-full justify-start",children:"Add Comment"})}),e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(V,{children:"Add Comment"}),e.jsx(J,{children:"Add a comment to this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(q,{htmlFor:"comment",children:"Comment"}),e.jsx(we,{id:"comment",placeholder:"Enter your comment...",value:j,onChange:t=>C(t.target.value),rows:4})]})}),e.jsxs(M,{children:[e.jsx(n,{variant:"outline",onClick:()=>{w(!1),C("")},children:"Cancel"}),e.jsx(n,{onClick:te,disabled:T||!j.trim(),children:T?"Adding...":"Add Comment"})]})]})]}),e.jsxs(n,{variant:"outline",className:"w-full justify-start",onClick:ae,children:[e.jsx(Pe,{className:"h-4 w-4 mr-2"}),"Export"]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(u,{children:"Information"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(F,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Author:"}),e.jsx("span",{children:s.author.name})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ke,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:new Date(s.metadata.createdAt).toLocaleDateString()})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ee,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:new Date(s.metadata.updatedAt).toLocaleDateString()})]}),e.jsx(Se,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(p,{variant:Q(s.status),children:s.status})})]}),s.metadata.priority&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Priority:"}),e.jsx("div",{className:"mt-1",children:e.jsx(p,{variant:W(s.metadata.priority),children:s.metadata.priority})})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:s.metadata.tags.map(t=>e.jsx(p,{variant:"outline",className:"text-xs",children:t},t))})]})]})]})]})]})]})}export{He as default};
1
+ import{E as re,u as ne,r as l,H as le,j as e,B as n,L as h,J as ie,M as oe,N as ce,T as de,O as me,P as he,Q as xe,R as pe,U as ue,V as je,W as fe,Y as I,Z as F,k as ge,D as R,_ as B,a as z,b as H,d as V,e as J,v as ve,w as Ne,x as Ce,y as ye,z as c,$ as M,a0 as we,a1 as Se,A as g}from"./index-BAEEeZzi.js";import{c as be}from"./clipboard-B9ndUJKl.js";import{C as d,b as x,a as m,c as u,d as _}from"./card-C9ekeZtD.js";import{B as p}from"./badge-fHjW-wEe.js";import{L as q}from"./label-CRsu1MwQ.js";import{A as S}from"./arrow-left-CdJt7_wH.js";import{C as De,a as Ae}from"./clipboard-Dv0iwZO9.js";import{D as Pe}from"./download-CpaVC4DU.js";import{C as ke}from"./calendar-DXMWQL-h.js";import{C as Ee}from"./clock-BxO7xcX9.js";function Q(r){switch(r){case"approved":case"code-complete":return"default";case"in-review":return"secondary";case"rejected":return"destructive";default:return"outline"}}function W(r){switch(r){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}function He(){const{id:r}=re(),Y=ne(),[s,v]=l.useState(null),[Z,b]=l.useState(!0),[N,D]=l.useState(null),[A,P]=l.useState(!1),[k,E]=l.useState(!1),[T,$]=l.useState(!1),[j,C]=l.useState(""),[G,y]=l.useState(!1),[K,w]=l.useState(!1),[f,U]=l.useState("draft"),[X,L]=l.useState(!1),{toast:O}=le();l.useEffect(()=>{async function t(){if(r)try{b(!0);const o=await(await fetch(`${g}/api/v1/proposals/${r}`)).json();o.success?v(o.data):D(o.error?.message||"Failed to fetch proposal")}catch(a){D(a instanceof Error?a.message:"Unknown error")}finally{b(!1)}}t()},[r]);const ee=async()=>{if(r){P(!0);try{const a=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"DELETE"})).json();a.success?Y("/proposals"):alert(a.error?.message||"Failed to delete proposal")}catch(t){alert(`Error deleting proposal: ${t instanceof Error?t.message:"Unknown error"}`)}finally{P(!1)}}},se=async()=>{if(!(!s||!r||f===s.status)){E(!0);try{const a=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:f})})).json();a.success?(v(a.data),y(!1)):alert(a.error?.message||"Failed to update status")}catch(t){alert(`Error updating status: ${t instanceof Error?t.message:"Unknown error"}`)}finally{E(!1)}}},te=async()=>{if(!(!s||!r||!j.trim())){$(!0);try{const t={id:`comment-${Date.now()}`,text:j,author:"current-user",timestamp:new Date().toISOString()},a=[...s.metadata.comments||[],t],i=await(await fetch(`${g}/api/v1/proposals/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comments:a})})).json();i.success?(v(i.data),C(""),w(!1)):alert(i.error?.message||"Failed to add comment")}catch(t){alert(`Error adding comment: ${t instanceof Error?t.message:"Unknown error"}`)}finally{$(!1)}}},ae=()=>{if(!s)return;const t={...s,exportedAt:new Date().toISOString()},a=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),o=URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.download=`proposal-${s.id}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)};return Z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(h,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})})})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]})}),e.jsx(m,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-5/6 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-4/6 animate-pulse"})]})})]})]}):N||!s?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:N||"Proposal not found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(h,{to:"/proposals",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:N||"Proposal not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The proposal with ID "',r,'" could not be found.']}),e.jsx(n,{asChild:!0,className:"mt-4",children:e.jsx(h,{to:"/proposals",children:"Back to Proposals"})})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.intent}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(h,{to:"/proposals",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})}),e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(h,{to:`/proposals/${r}/edit`,children:[e.jsx(ie,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,children:e.jsxs(n,{variant:"destructive",size:"sm",disabled:A,children:[e.jsx(de,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:A?"Deleting...":"Delete"})]})}),e.jsxs(me,{children:[e.jsxs(he,{children:[e.jsx(xe,{children:"Are you absolutely sure?"}),e.jsxs(pe,{children:["This action cannot be undone. This will permanently delete the change proposal",e.jsxs("span",{className:"font-semibold",children:[' "',s.intent,'"']})," and remove it from the system."]})]}),e.jsxs(ue,{children:[e.jsx(je,{children:"Cancel"}),e.jsx(fe,{onClick:ee,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Proposal"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const t=`.nut/proposals/${s.id}.md`;try{await be(t),L(!0),O({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>L(!1),2e3)}catch(a){console.error("Failed to copy path:",a),O({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono",children:[e.jsx("span",{children:`.nut/proposals/${s.id}.md`}),X?e.jsx(De,{className:"h-3.5 w-3.5"}):e.jsx(Ae,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(d,{children:[e.jsx(x,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(u,{children:"Proposal Details"}),e.jsxs("div",{className:"flex gap-2",children:[s.metadata.priority&&e.jsx(p,{variant:W(s.metadata.priority),children:s.metadata.priority}),e.jsx(p,{variant:Q(s.status),children:s.status})]})]})}),e.jsx(m,{className:"space-y-4",children:s.content?e.jsx(I,{children:s.content}):e.jsx("p",{className:"text-muted-foreground",children:"No detailed content available for this proposal."})})]}),s.planSteps&&s.planSteps.length>0&&e.jsxs(d,{children:[e.jsxs(x,{children:[e.jsx(u,{children:"Implementation Steps"}),e.jsxs(_,{children:[s.planSteps.length," step",s.planSteps.length!==1?"s":""," planned"]})]}),e.jsx(m,{children:e.jsx("div",{className:"space-y-3",children:s.planSteps.map((t,a)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-xs font-medium",children:a+1}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:t.description}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:e.jsx(p,{variant:"outline",className:"text-xs",children:t.status})})]})]},t.id))})})]}),s.metadata.comments&&s.metadata.comments.length>0&&e.jsxs(d,{children:[e.jsxs(x,{children:[e.jsx(u,{children:"Comments"}),e.jsxs(_,{children:[s.metadata.comments.length," comment",s.metadata.comments.length!==1?"s":""]})]}),e.jsx(m,{children:e.jsx("div",{className:"space-y-4",children:s.metadata.comments.map((t,a)=>e.jsxs("div",{className:"border-l-2 border-muted pl-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(F,{className:"h-3 w-3"}),e.jsx("span",{children:t.author}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(t.timestamp).toLocaleString()})]}),e.jsx(I,{className:"prose-sm prose-p:mb-2 prose-ul:my-2 prose-ol:my-2",children:t.text})]},t.id||a))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(u,{children:"Proposal Actions"})}),e.jsxs(m,{className:"space-y-2",children:[e.jsx(n,{variant:"default",className:"w-full justify-start",asChild:!0,children:e.jsxs(h,{to:`/terminal/${r}`,children:[e.jsx(ge,{className:"h-4 w-4 mr-2"}),"Prepare Coding Agent"]})}),e.jsxs(R,{open:G,onOpenChange:y,children:[e.jsx(B,{asChild:!0,children:e.jsx(n,{variant:"outline",className:"w-full justify-start",onClick:()=>U(s?.status||"draft"),children:"Change Status"})}),e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(V,{children:"Change Proposal Status"}),e.jsx(J,{children:"Update the status of this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(q,{htmlFor:"status",children:"Status"}),e.jsxs(ve,{value:f,onValueChange:t=>U(t),children:[e.jsx(Ne,{children:e.jsx(Ce,{placeholder:"Select status"})}),e.jsxs(ye,{children:[e.jsx(c,{value:"draft",children:"Draft"}),e.jsx(c,{value:"proposed",children:"Proposed"}),e.jsx(c,{value:"in-review",children:"In Review"}),e.jsx(c,{value:"approved",children:"Approved"}),e.jsx(c,{value:"code-complete",children:"Code Complete"}),e.jsx(c,{value:"merged",children:"Merged"}),e.jsx(c,{value:"rejected",children:"Rejected"})]})]})]})}),e.jsxs(M,{children:[e.jsx(n,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(n,{onClick:se,disabled:k||f===s?.status,children:k?"Updating...":"Update Status"})]})]})]}),e.jsxs(R,{open:K,onOpenChange:w,children:[e.jsx(B,{asChild:!0,children:e.jsx(n,{variant:"outline",className:"w-full justify-start",children:"Add Comment"})}),e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(V,{children:"Add Comment"}),e.jsx(J,{children:"Add a comment to this change proposal."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(q,{htmlFor:"comment",children:"Comment"}),e.jsx(we,{id:"comment",placeholder:"Enter your comment...",value:j,onChange:t=>C(t.target.value),rows:4})]})}),e.jsxs(M,{children:[e.jsx(n,{variant:"outline",onClick:()=>{w(!1),C("")},children:"Cancel"}),e.jsx(n,{onClick:te,disabled:T||!j.trim(),children:T?"Adding...":"Add Comment"})]})]})]}),e.jsxs(n,{variant:"outline",className:"w-full justify-start",onClick:ae,children:[e.jsx(Pe,{className:"h-4 w-4 mr-2"}),"Export"]})]})]}),e.jsxs(d,{children:[e.jsx(x,{children:e.jsx(u,{children:"Information"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(F,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Author:"}),e.jsx("span",{children:s.author.name})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ke,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:new Date(s.metadata.createdAt).toLocaleDateString()})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ee,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:new Date(s.metadata.updatedAt).toLocaleDateString()})]}),e.jsx(Se,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(p,{variant:Q(s.status),children:s.status})})]}),s.metadata.priority&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Priority:"}),e.jsx("div",{className:"mt-1",children:e.jsx(p,{variant:W(s.metadata.priority),children:s.metadata.priority})})]}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:s.metadata.tags.map(t=>e.jsx(p,{variant:"outline",className:"text-xs",children:t},t))})]})]})]})]})]})]})}export{He as default};
@@ -1 +1 @@
1
- import{E as M,u as R,H as U,r as o,A as I,j as e,B as m,L as x,I as O,v as L,w as T,x as k,y as D,z as r,X as V,a2 as _}from"./index-B0JO3x3V.js";import{L as j}from"./label-BHOOQ99D.js";import{C as f,b as F,a as v,c as q,d as J}from"./card-B9ym6neB.js";import{M as K}from"./markdown-editor-B0i_LOAR.js";import{C as W}from"./CollapsibleSection-CkCVMSBD.js";import{I as X,L as G}from"./ImplementationStepsEditor-GxhD-g8y.js";import{T as Q}from"./TagInput-DJMwLVTn.js";import{A as N}from"./arrow-left-BRSAC1N6.js";import"./plus-D737EJ5S.js";import"./badge-DaM4gF82.js";function oe(){const{id:i}=M(),$=R(),{toast:y}=U(),[z,S]=o.useState(!0),[h,w]=o.useState(!1),[C,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([]),[P,A]=o.useState([]);o.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${I}/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)}},H=async t=>{t.preventDefault(),w(!0);try{const s=p.map(l=>({id:l.id,description:l.description.trim(),status:l.status})).filter(l=>l.description.length>0),a=P.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(`${I}/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{w(!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"})]})})]})]}):C?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(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:C})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit 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:H,children:e.jsxs(f,{children:[e.jsxs(F,{children:[e.jsx(q,{children:"Proposal 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(L,{value:n.status,onValueChange:t=>d(s=>({...s,status:t})),children:[e.jsx(T,{children:e.jsx(k,{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(W,{defaultOpen:!0,icon:e.jsx(G,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"priority",children:"Priority"}),e.jsxs(L,{value:n.priority,onValueChange:t=>d(s=>({...s,priority:t})),children:[e.jsx(T,{children:e.jsx(k,{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(X,{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(Q,{tags:P,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
+ import{E as M,u as R,H as U,r as o,A as I,j as e,B as m,L as x,I as O,v as L,w as T,x as k,y as D,z as r,X as V,a2 as _}from"./index-BAEEeZzi.js";import{L as j}from"./label-CRsu1MwQ.js";import{C as f,b as F,a as v,c as q,d as J}from"./card-C9ekeZtD.js";import{M as K}from"./markdown-editor-Dop22vuJ.js";import{C as W}from"./CollapsibleSection-B23j-nZD.js";import{I as X,L as G}from"./ImplementationStepsEditor-CCfJKk2U.js";import{T as Q}from"./TagInput-CYcNHzrk.js";import{A as N}from"./arrow-left-CdJt7_wH.js";import"./plus-CemYz5Fm.js";import"./badge-fHjW-wEe.js";function oe(){const{id:i}=M(),$=R(),{toast:y}=U(),[z,S]=o.useState(!0),[h,w]=o.useState(!1),[C,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([]),[P,A]=o.useState([]);o.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${I}/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)}},H=async t=>{t.preventDefault(),w(!0);try{const s=p.map(l=>({id:l.id,description:l.description.trim(),status:l.status})).filter(l=>l.description.length>0),a=P.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(`${I}/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{w(!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"})]})})]})]}):C?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(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:C})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit 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:H,children:e.jsxs(f,{children:[e.jsxs(F,{children:[e.jsx(q,{children:"Proposal 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(L,{value:n.status,onValueChange:t=>d(s=>({...s,status:t})),children:[e.jsx(T,{children:e.jsx(k,{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(W,{defaultOpen:!0,icon:e.jsx(G,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"priority",children:"Priority"}),e.jsxs(L,{value:n.priority,onValueChange:t=>d(s=>({...s,priority:t})),children:[e.jsx(T,{children:e.jsx(k,{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(X,{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(Q,{tags:P,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-B0JO3x3V.js";import{C as J,b as Ve,a as Z,c as We}from"./card-B9ym6neB.js";import{B as q}from"./badge-DaM4gF82.js";import{P as ee}from"./plus-D737EJ5S.js";import{S as Ue}from"./search-cntvIhnF.js";/**
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-BAEEeZzi.js";import{C as J,b as Ve,a as Z,c as We}from"./card-C9ekeZtD.js";import{B as q}from"./badge-fHjW-wEe.js";import{P as ee}from"./plus-CemYz5Fm.js";import{S as Ue}from"./search-BvRo_rak.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,71 @@
1
+ import{c as se,r as l,j as e,D as re,a as ie,b as oe,d as ce,n as z,S as Qe,B as I,ah as qe,aj as ke,H as Ie,A as J,a0 as de,v as V,w as W,x as O,y as $,z as L,ac as Me,ak as ea,al as sa,am as aa,an as xe,ao as be,ap as pe,aq as ta,ar as _s,as as na,at as la,f as ra,I as Ee,ai as Ss,X as Xe,C as Cs,g as je,au as We,av as ia,aw as oa,ax as ca,a5 as da,a6 as ua,s as ma,a7 as ha,aa as Le,e as Ze,T as es,ay as xa}from"./index-BAEEeZzi.js";import{C as Ke,b as ss,a as Ve,c as fa,d as pa}from"./card-C9ekeZtD.js";import{L as C}from"./label-CRsu1MwQ.js";import{B as Ne}from"./badge-fHjW-wEe.js";import{c as ga}from"./clipboard-B9ndUJKl.js";import{R as Ps}from"./registry-ANRa5WBi.js";import{D as Oe}from"./download-CpaVC4DU.js";import{C as ks}from"./chevron-left-BkP_F3xd.js";import{C as va}from"./calendar-DXMWQL-h.js";import{P as as}from"./plus-CemYz5Fm.js";import{S as ja}from"./search-BvRo_rak.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 wa=[["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"}]],ts=se("file-audio",wa);/**
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 Na=[["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"}]],$e=se("file-code",Na);/**
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 ba=[["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"}]],ns=se("file-image",ba);/**
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 ya=[["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"}]],ls=se("file-json",ya);/**
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 _a=[["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"}]],rs=se("file-play",_a);/**
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 Sa=[["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"}]],is=se("file-spreadsheet",Sa);/**
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 Ca=[["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"}]],os=se("file-type",Ca);/**
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 Pa=[["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"}]],ka=se("hard-drive",Pa);/**
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 Ma=[["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"}]],fe=se("image",Ma);/**
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 Ea=[["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"}]],cs=se("maximize-2",Ea);/**
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 Fa=[["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"}]],le=se("music",Fa);/**
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 Ia=[["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"}]],ds=se("presentation",Ia);/**
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 Ga=[["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"}]],Ra=se("upload",Ga);/**
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 Da=[["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"}]],Fe=se("video",Da);async function Ms(n){const c=n.startsWith("http")?n:`${Ps}${n}`,a=await fetch(c,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!a.ok)throw new Error(`Failed to fetch registry resource: ${a.status}`);return a.json()}async function Ta(){return Ms("/registry/resources/root.json")}async function us(n){return Ms(n)}function Pe(n){if(n)return n.startsWith("http")?n:`${Ps}${n}`}function Aa({open:n,onOpenChange:c,onSelectExample:a,onCustomizeInAssistant:d}){const[x,p]=l.useState([]),[m,v]=l.useState(!1),[j,E]=l.useState(null),[y,f]=l.useState(null),[g,w]=l.useState(null),[_,P]=l.useState(!1),[N,b]=l.useState(null);l.useEffect(()=>{n&&(v(!0),E(null),f(null),w(null),b(null),Ta().then(h=>{p(h.elements??[]),h.elements&&h.elements.length>0&&K(h.elements[0])}).catch(h=>{console.error("Failed to load registry resources",h),p([]),E("Failed to load examples from registry")}).finally(()=>v(!1)))},[n]);const K=async h=>{f(h.id),b(null),w(null),P(!0);try{const F=await us(h.endpoint);w(F)}catch(F){console.error("Failed to load resource detail",F),b("Unable to load details for this example")}finally{P(!1)}},k=()=>{g?.prompt&&(a(g.prompt),c(!1))},M=()=>{g?.prompt&&d&&(d(g.prompt),c(!1))},G=async h=>{if(y===h.id&&g?.prompt){a(g.prompt),c(!1);return}try{const F=await us(h.endpoint);F.prompt&&(a(F.prompt),c(!1))}catch(F){console.error("Failed to load resource detail",F)}};return e.jsx(re,{open:n,onOpenChange:c,children:e.jsxs(ie,{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(oe,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ce,{className:"text-base sm:text-lg",children:"Example Prompts"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"h-[40%] min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:_?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(z,{className:"h-5 w-5 animate-spin mr-2"}),"Loading..."]}):N?e.jsx("p",{className:"text-sm text-muted-foreground",children:N}):g?e.jsx("img",{src:Pe(g.imageUrl),alt:g.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:[m?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(z,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):j?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:j}):x.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(Qe,{className:"flex-1",children:e.jsx("div",{className:"p-3 space-y-2",children:x.map(h=>e.jsxs("button",{onClick:()=>K(h),onDoubleClick:()=>G(h),className:`w-full text-left p-2 rounded-lg border-2 transition-all flex gap-3 ${y===h.id?"border-primary bg-primary/5":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[h.thumbnailUrl&&e.jsx("img",{src:Pe(h.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:h.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:h.description})]})]},h.id))})}),e.jsx("div",{className:"p-3 border-t flex-shrink-0",children:e.jsxs(I,{onClick:k,disabled:!g?.prompt||_,className:"w-full",children:[e.jsx(qe,{className:"mr-2 h-4 w-4"}),"Use This Prompt"]})})]})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsxs("div",{className:"w-[35%] border-r flex flex-col",children:[m?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(z,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):j?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:j}):x.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(Qe,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-3",children:x.map(h=>e.jsxs("button",{onClick:()=>K(h),onDoubleClick:()=>G(h),className:`w-full text-left p-3 rounded-lg border-2 transition-all flex gap-3 ${y===h.id?"border-primary bg-primary/5 shadow-sm":"border-transparent bg-muted/50 hover:bg-muted hover:border-muted-foreground/20"}`,children:[h.thumbnailUrl&&e.jsx("img",{src:Pe(h.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:h.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:h.description}),h.tags&&h.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[h.tags.slice(0,3).map(F=>e.jsx(Ne,{variant:"secondary",className:"text-[10px]",children:F},F)),h.tags.length>3&&e.jsxs(Ne,{variant:"outline",className:"text-[10px]",children:["+",h.tags.length-3]})]})]})]},h.id))})}),e.jsx("div",{className:"p-4 border-t flex-shrink-0",children:e.jsxs(I,{onClick:k,disabled:!g?.prompt||_,className:"w-full",children:[e.jsx(qe,{className:"mr-2 h-4 w-4"}),"Use This Prompt"]})})]}),e.jsxs("div",{className:"flex-1 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:_?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(z,{className:"h-5 w-5 animate-spin mr-2"}),"Loading details..."]}):N?e.jsx("p",{className:"text-sm text-muted-foreground",children:N}):g?e.jsx("img",{src:Pe(g.imageUrl),alt:g.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"})}),g&&e.jsxs("div",{className:"border-t p-4 bg-background flex-shrink-0 max-h-[30%] overflow-y-auto relative",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 pr-32",children:g.prompt}),d&&e.jsxs(I,{size:"sm",variant:"secondary",onClick:M,className:"absolute bottom-4 right-4",children:[e.jsx(ke,{className:"mr-1.5 h-3.5 w-3.5"}),"Customize in Assistant"]})]})]})]})]})})}const Be={"nano-banana-pro":{id:"nano-banana-pro",label:"Nano Banana Pro",replicateId:"google/nano-banana-pro",features:{resolution:!0,outputQuality:!1,goFast:!1,safetyTolerance:!1,matchInputImage:!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,goFast:!0,safetyTolerance:!1,matchInputImage:!0},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,goFast:!1,safetyTolerance:!0,matchInputImage:!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}}},ms=Object.values(Be).map(n=>({value:n.id,label:n.label})),hs=[{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"}],La={value:"match_input_image",label:"Match Input"},xs=[{value:"png",label:"PNG"},{value:"jpg",label:"JPG"},{value:"webp",label:"WebP"}],fs=[{value:"60",label:"60"},{value:"70",label:"70"},{value:"80",label:"80"},{value:"90",label:"90"},{value:"100",label:"100"}],ps=[{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 Ka({open:n,onOpenChange:c,onSave:a,onCustomizeInAssistant:d}){const[x,p]=l.useState(""),[m,v]=l.useState("nano-banana-pro"),[j,E]=l.useState("4:3"),[y,f]=l.useState("2K"),[g,w]=l.useState("png"),[_,P]=l.useState("80"),[N,b]=l.useState(!0),[K,k]=l.useState("2"),[M,G]=l.useState(null),[h,F]=l.useState(!1),[Y,U]=l.useState(!1),[B,T]=l.useState([]),[u,D]=l.useState([]),[H,o]=l.useState(!0),[Q,r]=l.useState(!1),{toast:S}=Ie(),A=Be[m],ee=A.features.matchInputImage?[La,...hs]:hs,ue=A.resolutionOptions||[];l.useEffect(()=>{const t=Be[m];t.defaults.resolution&&t.features.resolution&&f(t.defaults.resolution),t.defaults.outputQuality!==void 0&&P(String(t.defaults.outputQuality)),t.defaults.goFast!==void 0&&b(t.defaults.goFast),t.defaults.safetyTolerance!==void 0&&k(String(t.defaults.safetyTolerance)),E(X=>X==="match_input_image"&&!t.features.matchInputImage?"4:3":X)},[m]),l.useEffect(()=>{n&&me()},[n]);const me=async()=>{try{const X=await(await fetch(`${J}/api/v1/resources`)).json();if(X.success){const Z=(X.data||[]).filter(ae=>{const he=ae.type==="image/jpeg"||ae.name.toLowerCase().endsWith(".jpg")||ae.name.toLowerCase().endsWith(".jpeg"),Ae=ae.type==="image/png"||ae.name.toLowerCase().endsWith(".png");return(he||Ae)&&ae.thumbnailPath});T(Z)}}catch(t){console.error("Failed to fetch image resources:",t)}},ye=async()=>{if(!x.trim()){S({title:"Prompt required",description:"Please enter a prompt to generate an image",variant:"destructive"});return}F(!0),G(null);try{const t=H||u.length===0?[]:[...u],X=await fetch(`${J}/api/v1/resources/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:x,model:m,dimensions:j,resolution:A.features.resolution?y:void 0,output_format:g,output_quality:A.features.outputQuality?parseInt(_):void 0,go_fast:A.features.goFast?N:void 0,safety_tolerance:A.features.safetyTolerance?parseInt(K):void 0,image_input:t})}),Z=await X.json();if(!X.ok||!Z.success){const ae=Z.error?.message||"Failed to generate image",he=Z.error?.code==="MISSING_API_TOKEN";throw new Error(he?"Replicate API token not configured. Please add it in Settings → Integrations.":ae)}G(Z.data.imageUrl),S({title:"Image generated",description:"Your image has been generated successfully"})}catch(t){console.error("Generation error:",t),S({title:"Generation failed",description:t instanceof Error?t.message:"Failed to generate image. Please try again.",variant:"destructive"})}finally{F(!1)}},_e=async()=>{if(M){U(!0);try{await a(M),p(""),v("nano-banana-pro"),E("4:3"),f("2K"),w("png"),P("80"),b(!0),k("2"),G(null),o(!0),D([]),c(!1)}catch(t){S({title:"Save failed",description:t instanceof Error?t.message:"Failed to save image. Please try again.",variant:"destructive"})}finally{U(!1)}}},Re=()=>{!h&&!Y&&c(!1)},Se=()=>{o(!0),D([])},ve=t=>{H&&o(!1),u.includes(t)?(D(u.filter(X=>X!==t)),u.length===1&&o(!0)):u.length<3?D([...u,t]):S({title:"Maximum selection",description:"You can only select up to 3 images",variant:"destructive"})},De=t=>{p(t)},Te=t=>{d&&(r(!1),c(!1),d(`"${t}" Please customize this (and respond back just the updated markdown):`))};return e.jsxs(re,{open:n,onOpenChange:Re,children:[e.jsxs(ie,{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(oe,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ce,{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:h?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(z,{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("img",{src:M,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(fe,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"}),e.jsxs(I,{size:"sm",onClick:()=>r(!0),className:"mt-2",children:[e.jsx(ke,{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:Se,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${H?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),B.map(t=>{const X=u.includes(t.id);return e.jsx("button",{onClick:()=>ve(t.id),className:`flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${X?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${J}/api/v1/resources/${t.id}/thumbnail`,alt:t.name,className:"w-full h-full object-cover"})},t.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(de,{id:"prompt-mobile",placeholder:"Describe the image...",value:x,onChange:t=>p(t.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(V,{value:m,onValueChange:t=>v(t),children:[e.jsx(W,{id:"model-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ms.map(t=>e.jsx(L,{value:t.value,children:t.label},t.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(V,{value:g,onValueChange:w,children:[e.jsx(W,{id:"outputFormat-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:xs.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),A.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(Me,{id:"goFast-mobile",checked:N,onCheckedChange:t=>b(t===!0)}),e.jsx(C,{htmlFor:"goFast-mobile",className:"text-xs cursor-pointer",children:"Go Fast"})]})}),A.features.safetyTolerance&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"safetyTolerance-mobile",className:"text-xs",children:"Safety"}),e.jsxs(V,{value:K,onValueChange:k,children:[e.jsx(W,{id:"safetyTolerance-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ps.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[A.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(V,{value:y,onValueChange:f,children:[e.jsx(W,{id:"resolution-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ue.map(t=>e.jsx(L,{value:t.value,children:t.label},t.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(V,{value:j,onValueChange:E,children:[e.jsx(W,{id:"aspectRatio-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ee.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),A.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(V,{value:_,onValueChange:P,children:[e.jsx(W,{id:"outputQuality-mobile",className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:fs.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(I,{onClick:ye,disabled:!x.trim()||h||Y,className:"flex-1 h-9",size:"sm",children:h?e.jsx(z,{className:"h-4 w-4 animate-spin"}):"Generate"}),e.jsx(I,{onClick:_e,disabled:!M||h||Y,variant:"outline",className:"flex-1 h-9",size:"sm",children:Y?e.jsx(z,{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(de,{id:"prompt",placeholder:"Describe the image you want to generate...",value:x,onChange:t=>p(t.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"model",children:"Model"}),e.jsxs(V,{value:m,onValueChange:t=>v(t),children:[e.jsx(W,{id:"model",children:e.jsx(O,{})}),e.jsx($,{children:ms.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(V,{value:j,onValueChange:E,children:[e.jsx(W,{id:"aspectRatio",children:e.jsx(O,{})}),e.jsx($,{children:ee.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),A.features.resolution&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(V,{value:y,onValueChange:f,children:[e.jsx(W,{id:"resolution",children:e.jsx(O,{})}),e.jsx($,{children:ue.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"outputFormat",children:"Output Format"}),e.jsxs(V,{value:g,onValueChange:w,children:[e.jsx(W,{id:"outputFormat",children:e.jsx(O,{})}),e.jsx($,{children:xs.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),A.features.outputQuality&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"outputQuality",children:"Output Quality"}),e.jsxs(V,{value:_,onValueChange:P,children:[e.jsx(W,{id:"outputQuality",children:e.jsx(O,{})}),e.jsx($,{children:fs.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),A.features.goFast&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Me,{id:"goFast",checked:N,onCheckedChange:t=>b(t===!0)}),e.jsx(C,{htmlFor:"goFast",className:"cursor-pointer",children:"Go Fast"})]}),A.features.safetyTolerance&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"safetyTolerance",children:"Safety Tolerance"}),e.jsxs(V,{value:K,onValueChange:k,children:[e.jsx(W,{id:"safetyTolerance",children:e.jsx(O,{})}),e.jsx($,{children:ps.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(I,{onClick:ye,disabled:!x.trim()||h||Y,className:"w-full",children:h?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate"}),e.jsx(I,{onClick:_e,disabled:!M||h||Y,variant:"outline",className:"w-full",children:Y?e.jsxs(e.Fragment,{children:[e.jsx(z,{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:h?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(z,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating image..."})]}):M?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:M,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(fe,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated image will appear here"}),e.jsxs(I,{onClick:()=>r(!0),className:"mt-2",children:[e.jsx(ke,{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:Se,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${H?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),B.map(t=>{const X=u.includes(t.id);return e.jsx("button",{onClick:()=>ve(t.id),className:`flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${X?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${J}/api/v1/resources/${t.id}/thumbnail`,alt:t.name,className:"w-full h-full object-cover"})},t.id)})]})})]})]})]}),e.jsx(Aa,{open:Q,onOpenChange:r,onSelectExample:De,onCustomizeInAssistant:d?Te:void 0})]})}var Es=["PageUp","PageDown"],Fs=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Is={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ge="Slider",[Ue,Va,Wa]=aa(ge),[Gs,vt]=sa(ge,[Wa]),[Oa,Ge]=Gs(ge),Rs=l.forwardRef((n,c)=>{const{name:a,min:d=0,max:x=100,step:p=1,orientation:m="horizontal",disabled:v=!1,minStepsBetweenThumbs:j=0,defaultValue:E=[d],value:y,onValueChange:f=()=>{},onValueCommit:g=()=>{},inverted:w=!1,form:_,...P}=n,N=l.useRef(new Set),b=l.useRef(0),k=m==="horizontal"?$a:Ba,[M=[],G]=ea({prop:y,defaultProp:E,onChange:T=>{[...N.current][b.current]?.focus(),f(T)}}),h=l.useRef(M);function F(T){const u=Ja(M,T);B(T,u)}function Y(T){B(T,b.current)}function U(){const T=h.current[b.current];M[b.current]!==T&&g(M)}function B(T,u,{commit:D}={commit:!1}){const H=Za(p),o=et(Math.round((T-d)/p)*p+d,H),Q=_s(o,[d,x]);G((r=[])=>{const S=Ha(r,Q,u);if(Xa(S,j*p)){b.current=S.indexOf(Q);const A=String(S)!==String(r);return A&&D&&g(S),A?S:r}else return r})}return e.jsx(Oa,{scope:n.__scopeSlider,name:a,disabled:v,min:d,max:x,valueIndexToChangeRef:b,thumbs:N.current,values:M,orientation:m,form:_,children:e.jsx(Ue.Provider,{scope:n.__scopeSlider,children:e.jsx(Ue.Slot,{scope:n.__scopeSlider,children:e.jsx(k,{"aria-disabled":v,"data-disabled":v?"":void 0,...P,ref:c,onPointerDown:xe(P.onPointerDown,()=>{v||(h.current=M)}),min:d,max:x,inverted:w,onSlideStart:v?void 0:F,onSlideMove:v?void 0:Y,onSlideEnd:v?void 0:U,onHomeKeyDown:()=>!v&&B(d,0,{commit:!0}),onEndKeyDown:()=>!v&&B(x,M.length-1,{commit:!0}),onStepKeyDown:({event:T,direction:u})=>{if(!v){const o=Es.includes(T.key)||T.shiftKey&&Fs.includes(T.key)?10:1,Q=b.current,r=M[Q],S=p*o*u;B(r+S,Q,{commit:!0})}}})})})})});Rs.displayName=ge;var[Ds,Ts]=Gs(ge,{startEdge:"left",endEdge:"right",size:"width",direction:1}),$a=l.forwardRef((n,c)=>{const{min:a,max:d,dir:x,inverted:p,onSlideStart:m,onSlideMove:v,onSlideEnd:j,onStepKeyDown:E,...y}=n,[f,g]=l.useState(null),w=pe(c,k=>g(k)),_=l.useRef(void 0),P=ta(x),N=P==="ltr",b=N&&!p||!N&&p;function K(k){const M=_.current||f.getBoundingClientRect(),G=[0,M.width],F=Ye(G,b?[a,d]:[d,a]);return _.current=M,F(k-M.left)}return e.jsx(Ds,{scope:n.__scopeSlider,startEdge:b?"left":"right",endEdge:b?"right":"left",direction:b?1:-1,size:"width",children:e.jsx(As,{dir:P,"data-orientation":"horizontal",...y,ref:w,style:{...y.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:k=>{const M=K(k.clientX);m?.(M)},onSlideMove:k=>{const M=K(k.clientX);v?.(M)},onSlideEnd:()=>{_.current=void 0,j?.()},onStepKeyDown:k=>{const G=Is[b?"from-left":"from-right"].includes(k.key);E?.({event:k,direction:G?-1:1})}})})}),Ba=l.forwardRef((n,c)=>{const{min:a,max:d,inverted:x,onSlideStart:p,onSlideMove:m,onSlideEnd:v,onStepKeyDown:j,...E}=n,y=l.useRef(null),f=pe(c,y),g=l.useRef(void 0),w=!x;function _(P){const N=g.current||y.current.getBoundingClientRect(),b=[0,N.height],k=Ye(b,w?[d,a]:[a,d]);return g.current=N,k(P-N.top)}return e.jsx(Ds,{scope:n.__scopeSlider,startEdge:w?"bottom":"top",endEdge:w?"top":"bottom",size:"height",direction:w?1:-1,children:e.jsx(As,{"data-orientation":"vertical",...E,ref:f,style:{...E.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:P=>{const N=_(P.clientY);p?.(N)},onSlideMove:P=>{const N=_(P.clientY);m?.(N)},onSlideEnd:()=>{g.current=void 0,v?.()},onStepKeyDown:P=>{const b=Is[w?"from-bottom":"from-top"].includes(P.key);j?.({event:P,direction:b?-1:1})}})})}),As=l.forwardRef((n,c)=>{const{__scopeSlider:a,onSlideStart:d,onSlideMove:x,onSlideEnd:p,onHomeKeyDown:m,onEndKeyDown:v,onStepKeyDown:j,...E}=n,y=Ge(ge,a);return e.jsx(be.span,{...E,ref:c,onKeyDown:xe(n.onKeyDown,f=>{f.key==="Home"?(m(f),f.preventDefault()):f.key==="End"?(v(f),f.preventDefault()):Es.concat(Fs).includes(f.key)&&(j(f),f.preventDefault())}),onPointerDown:xe(n.onPointerDown,f=>{const g=f.target;g.setPointerCapture(f.pointerId),f.preventDefault(),y.thumbs.has(g)?g.focus():d(f)}),onPointerMove:xe(n.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&x(f)}),onPointerUp:xe(n.onPointerUp,f=>{const g=f.target;g.hasPointerCapture(f.pointerId)&&(g.releasePointerCapture(f.pointerId),p(f))})})}),Ls="SliderTrack",Ks=l.forwardRef((n,c)=>{const{__scopeSlider:a,...d}=n,x=Ge(Ls,a);return e.jsx(be.span,{"data-disabled":x.disabled?"":void 0,"data-orientation":x.orientation,...d,ref:c})});Ks.displayName=Ls;var ze="SliderRange",Vs=l.forwardRef((n,c)=>{const{__scopeSlider:a,...d}=n,x=Ge(ze,a),p=Ts(ze,a),m=l.useRef(null),v=pe(c,m),j=x.values.length,E=x.values.map(g=>$s(g,x.min,x.max)),y=j>1?Math.min(...E):0,f=100-Math.max(...E);return e.jsx(be.span,{"data-orientation":x.orientation,"data-disabled":x.disabled?"":void 0,...d,ref:v,style:{...n.style,[p.startEdge]:y+"%",[p.endEdge]:f+"%"}})});Vs.displayName=ze;var He="SliderThumb",Ws=l.forwardRef((n,c)=>{const a=Va(n.__scopeSlider),[d,x]=l.useState(null),p=pe(c,v=>x(v)),m=l.useMemo(()=>d?a().findIndex(v=>v.ref.current===d):-1,[a,d]);return e.jsx(Ua,{...n,ref:p,index:m})}),Ua=l.forwardRef((n,c)=>{const{__scopeSlider:a,index:d,name:x,...p}=n,m=Ge(He,a),v=Ts(He,a),[j,E]=l.useState(null),y=pe(c,K=>E(K)),f=j?m.form||!!j.closest("form"):!0,g=na(j),w=m.values[d],_=w===void 0?0:$s(w,m.min,m.max),P=Ya(d,m.values.length),N=g?.[v.size],b=N?Qa(N,_,v.direction):0;return l.useEffect(()=>{if(j)return m.thumbs.add(j),()=>{m.thumbs.delete(j)}},[j,m.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[v.startEdge]:`calc(${_}% + ${b}px)`},children:[e.jsx(Ue.ItemSlot,{scope:n.__scopeSlider,children:e.jsx(be.span,{role:"slider","aria-label":n["aria-label"]||P,"aria-valuemin":m.min,"aria-valuenow":w,"aria-valuemax":m.max,"aria-orientation":m.orientation,"data-orientation":m.orientation,"data-disabled":m.disabled?"":void 0,tabIndex:m.disabled?void 0:0,...p,ref:y,style:w===void 0?{display:"none"}:n.style,onFocus:xe(n.onFocus,()=>{m.valueIndexToChangeRef.current=d})})}),f&&e.jsx(Os,{name:x??(m.name?m.name+(m.values.length>1?"[]":""):void 0),form:m.form,value:w},d)]})});Ws.displayName=He;var za="RadioBubbleInput",Os=l.forwardRef(({__scopeSlider:n,value:c,...a},d)=>{const x=l.useRef(null),p=pe(x,d),m=la(c);return l.useEffect(()=>{const v=x.current;if(!v)return;const j=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(j,"value").set;if(m!==c&&y){const f=new Event("input",{bubbles:!0});y.call(v,c),v.dispatchEvent(f)}},[m,c]),e.jsx(be.input,{style:{display:"none"},...a,ref:p,defaultValue:c})});Os.displayName=za;function Ha(n=[],c,a){const d=[...n];return d[a]=c,d.sort((x,p)=>x-p)}function $s(n,c,a){const p=100/(a-c)*(n-c);return _s(p,[0,100])}function Ya(n,c){return c>2?`Value ${n+1} of ${c}`:c===2?["Minimum","Maximum"][n]:void 0}function Ja(n,c){if(n.length===1)return 0;const a=n.map(x=>Math.abs(x-c)),d=Math.min(...a);return a.indexOf(d)}function Qa(n,c,a){const d=n/2,p=Ye([0,50],[0,d]);return(d-p(c)*a)*a}function qa(n){return n.slice(0,-1).map((c,a)=>n[a+1]-c)}function Xa(n,c){if(c>0){const a=qa(n);return Math.min(...a)>=c}return!0}function Ye(n,c){return a=>{if(n[0]===n[1]||c[0]===c[1])return c[0];const d=(c[1]-c[0])/(n[1]-n[0]);return c[0]+d*(a-n[0])}}function Za(n){return(String(n).split(".")[1]||"").length}function et(n,c){const a=Math.pow(10,c);return Math.round(n*a)/a}var Bs=Rs,st=Ks,at=Vs,tt=Ws;const we=l.forwardRef(({className:n,...c},a)=>e.jsxs(Bs,{ref:a,className:ra("relative flex w-full touch-none select-none items-center",n),...c,children:[e.jsx(st,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(at,{className:"absolute h-full bg-primary"})}),e.jsx(tt,{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"})]}));we.displayName=Bs.displayName;const gs=["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"],vs=[{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"}],js=[{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"}],ws=[{value:"mp3",label:"MP3"},{value:"wav",label:"WAV"},{value:"flac",label:"FLAC"}];function nt({open:n,onOpenChange:c,onSave:a}){const[d,x]=l.useState(""),[p,m]=l.useState("English_Trustworth_Man"),[v,j]=l.useState(!1),[E,y]=l.useState(""),[f,g]=l.useState(1),[w,_]=l.useState(0),[P,N]=l.useState("auto"),[b,K]=l.useState("English"),[k,M]=l.useState("mp3"),[G,h]=l.useState(null),[F,Y]=l.useState(!1),[U,B]=l.useState(!1),{toast:T}=Ie(),u=async()=>{if(!d.trim()){T({title:"Text required",description:"Please enter text to generate audio",variant:"destructive"});return}Y(!0),h(null);try{const o=v?E:p,Q=await fetch(`${J}/api/v1/resources/generate-audio`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:d,voice_id:o,speed:f,pitch:w,emotion:P,language_boost:b,audio_format:k})}),r=await Q.json();if(!Q.ok||!r.success){const S=r.error?.message||"Failed to generate audio",A=r.error?.code==="MISSING_API_TOKEN";throw new Error(A?"Replicate API token not configured. Please add it in Settings → Integrations.":S)}h(r.data.audioUrl),T({title:"Audio generated",description:"Your audio has been generated successfully"})}catch(o){console.error("Generation error:",o),T({title:"Generation failed",description:o instanceof Error?o.message:"Failed to generate audio. Please try again.",variant:"destructive"})}finally{Y(!1)}},D=async()=>{if(G){B(!0);try{await a(G),x(""),m("English_Trustworth_Man"),j(!1),y(""),g(1),_(0),N("auto"),K("English"),M("mp3"),h(null),c(!1)}catch(o){T({title:"Save failed",description:o instanceof Error?o.message:"Failed to save audio. Please try again.",variant:"destructive"})}finally{B(!1)}}},H=()=>{!F&&!U&&c(!1)};return e.jsx(re,{open:n,onOpenChange:H,children:e.jsxs(ie,{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(oe,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ce,{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:F?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(z,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):G?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(le,{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:G,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(le,{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(de,{id:"text-mobile",placeholder:"Enter text to convert to speech...",value:d,onChange:o=>x(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(V,{value:v?"__custom__":p,onValueChange:o=>{o==="__custom__"?j(!0):(j(!1),m(o))},children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsxs($,{className:"max-h-60",children:[gs.map(o=>e.jsx(L,{value:o,className:"text-xs",children:o.replace(/_/g," ")},o)),e.jsx(L,{value:"__custom__",className:"text-xs font-medium",children:"Custom Voice ID..."})]})]}),v&&e.jsx(Ee,{placeholder:"Enter custom voice ID",value:E,onChange:o=>y(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: ",f.toFixed(1),"x"]}),e.jsx(we,{value:[f],onValueChange:([o])=>g(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(we,{value:[w],onValueChange:([o])=>_(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(V,{value:P,onValueChange:N,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:vs.map(o=>e.jsx(L,{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(V,{value:b,onValueChange:K,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:js.map(o=>e.jsx(L,{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(V,{value:k,onValueChange:M,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ws.map(o=>e.jsx(L,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(I,{onClick:u,disabled:!d.trim()||F||U,className:"flex-1 h-9",size:"sm",children:F?e.jsx(z,{className:"h-4 w-4 animate-spin"}):"Generate"}),e.jsx(I,{onClick:D,disabled:!G||F||U,variant:"outline",className:"flex-1 h-9",size:"sm",children:U?e.jsx(z,{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(de,{id:"text",placeholder:"Enter text to convert to speech...",value:d,onChange:o=>x(o.target.value),rows:6,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Voice"}),e.jsxs(V,{value:v?"__custom__":p,onValueChange:o=>{o==="__custom__"?j(!0):(j(!1),m(o))},children:[e.jsx(W,{children:e.jsx(O,{})}),e.jsxs($,{className:"max-h-80",children:[gs.map(o=>e.jsx(L,{value:o,children:o.replace(/_/g," ")},o)),e.jsx(L,{value:"__custom__",className:"font-medium",children:"Custom Voice ID..."})]})]}),v&&e.jsx(Ee,{placeholder:"Enter custom voice ID",value:E,onChange:o=>y(o.target.value),className:"mt-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Speed: ",f.toFixed(1),"x"]}),e.jsx(we,{value:[f],onValueChange:([o])=>g(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(we,{value:[w],onValueChange:([o])=>_(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(V,{value:P,onValueChange:N,children:[e.jsx(W,{children:e.jsx(O,{})}),e.jsx($,{children:vs.map(o=>e.jsx(L,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Language Boost"}),e.jsxs(V,{value:b,onValueChange:K,children:[e.jsx(W,{children:e.jsx(O,{})}),e.jsx($,{children:js.map(o=>e.jsx(L,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Audio Format"}),e.jsxs(V,{value:k,onValueChange:M,children:[e.jsx(W,{children:e.jsx(O,{})}),e.jsx($,{children:ws.map(o=>e.jsx(L,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(I,{onClick:u,disabled:!d.trim()||F||U,className:"w-full",children:F?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate"}),e.jsx(I,{onClick:D,disabled:!G||F||U,variant:"outline",className:"w-full",children:U?e.jsxs(e.Fragment,{children:[e.jsx(z,{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:F?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(z,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating audio..."})]}):G?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(le,{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:G,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(le,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated audio will appear here"})]})})})]})]})})}const Ns=[{value:"5",label:"5 seconds"},{value:"8",label:"8 seconds"},{value:"10",label:"10 seconds"}],bs=[{value:"480p",label:"480p"},{value:"720p",label:"720p"},{value:"1080p",label:"1080p"}],ys=[{value:"16:9",label:"16:9 (Landscape)"},{value:"9:16",label:"9:16 (Portrait)"},{value:"1:1",label:"1:1 (Square)"}];function lt({open:n,onOpenChange:c,onSave:a}){const[d,x]=l.useState(""),[p,m]=l.useState("8"),[v,j]=l.useState("720p"),[E,y]=l.useState("16:9"),[f,g]=l.useState(!0),[w,_]=l.useState(null),[P,N]=l.useState(null),[b,K]=l.useState(null),[k,M]=l.useState(!1),[G,h]=l.useState(!1),[F,Y]=l.useState([]),{toast:U}=Ie();l.useEffect(()=>{n&&B()},[n]);const B=async()=>{try{const S=await(await fetch(`${J}/api/v1/resources`)).json();if(S.success){const A=(S.data||[]).filter(ee=>{const ue=ee.type==="image/jpeg"||ee.name.toLowerCase().endsWith(".jpg")||ee.name.toLowerCase().endsWith(".jpeg"),me=ee.type==="image/png"||ee.name.toLowerCase().endsWith(".png");return(ue||me)&&ee.thumbnailPath});Y(A)}}catch(r){console.error("Failed to fetch image resources:",r)}},T=r=>{r===P?N(null):r===w?(_(null),N(r)):w?N(r):_(r)},u=()=>{_(null),N(null)},D=async()=>{if(!d.trim()){U({title:"Prompt required",description:"Please enter a prompt to generate a video",variant:"destructive"});return}M(!0),K(null);try{const r=await fetch(`${J}/api/v1/resources/generate-video`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d,image:w||void 0,last_frame:P||void 0,duration:parseInt(p),resolution:v,aspect_ratio:E,generate_audio:f})}),S=await r.json();if(!r.ok||!S.success){const A=S.error?.message||"Failed to generate video",ee=S.error?.code==="MISSING_API_TOKEN";throw new Error(ee?"Replicate API token not configured. Please add it in Settings → Integrations.":A)}K(S.data.videoUrl),U({title:"Video generated",description:"Your video has been generated successfully"})}catch(r){console.error("Generation error:",r),U({title:"Generation failed",description:r instanceof Error?r.message:"Failed to generate video. Please try again.",variant:"destructive"})}finally{M(!1)}},H=async()=>{if(b){h(!0);try{await a(b),x(""),m("8"),j("720p"),y("16:9"),g(!0),_(null),N(null),K(null),c(!1)}catch(r){U({title:"Save failed",description:r instanceof Error?r.message:"Failed to save video. Please try again.",variant:"destructive"})}finally{h(!1)}}},o=()=>{!k&&!G&&c(!1)},Q=r=>r===w?"start":r===P?"end":null;return e.jsx(re,{open:n,onOpenChange:o,children:e.jsxs(ie,{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(oe,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(ce,{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:k?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(z,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):b?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:b,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(Fe,{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:u,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${!w&&!P?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),F.map(r=>{const S=Q(r.id);return e.jsxs("button",{onClick:()=>T(r.id),className:`relative flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${S?"border-green-500 ring-2 ring-green-500":"border-muted hover:border-muted-foreground/50"}`,children:[e.jsx("img",{src:`${J}/api/v1/resources/${r.id}/thumbnail`,alt:r.name,className:"w-full h-full object-cover"}),S&&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:S==="start"?"Start":"End"})]},r.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(de,{id:"prompt-mobile",placeholder:"Describe the video you want to generate...",value:d,onChange:r=>x(r.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(V,{value:p,onValueChange:m,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:Ns.map(r=>e.jsx(L,{value:r.value,className:"text-xs",children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Resolution"}),e.jsxs(V,{value:v,onValueChange:j,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:bs.map(r=>e.jsx(L,{value:r.value,className:"text-xs",children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Ratio"}),e.jsxs(V,{value:E,onValueChange:y,children:[e.jsx(W,{className:"h-8 text-xs",children:e.jsx(O,{})}),e.jsx($,{children:ys.map(r=>e.jsx(L,{value:r.value,className:"text-xs",children:r.label},r.value))})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Me,{id:"generateAudio-mobile",checked:f,onCheckedChange:r=>g(r===!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(I,{onClick:D,disabled:!d.trim()||k||G,className:"flex-1 h-9",size:"sm",children:k?e.jsx(z,{className:"h-4 w-4 animate-spin"}):"Generate"}),e.jsx(I,{onClick:H,disabled:!b||k||G,variant:"outline",className:"flex-1 h-9",size:"sm",children:G?e.jsx(z,{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(de,{id:"prompt",placeholder:"Describe the video you want to generate...",value:d,onChange:r=>x(r.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"duration",children:"Duration"}),e.jsxs(V,{value:p,onValueChange:m,children:[e.jsx(W,{id:"duration",children:e.jsx(O,{})}),e.jsx($,{children:Ns.map(r=>e.jsx(L,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(V,{value:v,onValueChange:j,children:[e.jsx(W,{id:"resolution",children:e.jsx(O,{})}),e.jsx($,{children:bs.map(r=>e.jsx(L,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(V,{value:E,onValueChange:y,children:[e.jsx(W,{id:"aspectRatio",children:e.jsx(O,{})}),e.jsx($,{children:ys.map(r=>e.jsx(L,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Me,{id:"generateAudio",checked:f,onCheckedChange:r=>g(r===!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(I,{onClick:D,disabled:!d.trim()||k||G,className:"w-full",children:k?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate"}),e.jsx(I,{onClick:H,disabled:!b||k||G,variant:"outline",className:"w-full",children:G?e.jsxs(e.Fragment,{children:[e.jsx(z,{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:k?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(z,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating video..."})]}):b?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:b,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(Fe,{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:u,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${!w&&!P?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),F.map(r=>{const S=Q(r.id);return e.jsxs("button",{onClick:()=>T(r.id),className:`relative flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${S?"border-green-500 ring-2 ring-green-500":"border-muted hover:border-muted-foreground/50"}`,children:[e.jsx("img",{src:`${J}/api/v1/resources/${r.id}/thumbnail`,alt:r.name,className:"w-full h-full object-cover"}),S&&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:S==="start"?"Start":"End"})]},r.id)})]})]})]})]})]})})}function rt({open:n,onOpenChange:c,resource:a,onCopyPath:d,onDownload:x,onNavigate:p,canNavigatePrev:m,canNavigateNext:v}){const[j,E]=l.useState(null),[y,f]=l.useState(!1),[g,w]=l.useState(!1);l.useEffect(()=>{w(!1)},[a?.id,n]);const _=a?`${J}/api/v1/resources/${a.id}`:"",P=a?.type.startsWith("image/")??!1,N=a?a.type==="image/svg+xml"||a.name.toLowerCase().endsWith(".svg"):!1,b=a?a.type==="application/pdf"||a.name.toLowerCase().endsWith(".pdf"):!1,K=a?.type.startsWith("video/")??!1,k=a?.type.startsWith("audio/")??!1,M=a?a.type.startsWith("text/")||a.type==="application/json"||a.type.includes("javascript")||a.type.includes("typescript")||a.type.includes("xml")||a.name.toLowerCase().match(/\.(txt|md|json|js|ts|jsx|tsx|css|html|xml|yaml|yml|log|sh|bash|zsh|fish)$/)!==null:!1,G=a?a.name.toLowerCase().endsWith(".md")||a.name.toLowerCase().endsWith(".markdown"):!1,h=a?a.type==="application/json"||a.name.toLowerCase().endsWith(".json"):!1,F=a?a.type==="text/html"||a.name.toLowerCase().endsWith(".html"):!1;if(l.useEffect(()=>{const u=D=>{if(n){if(D.key==="Escape"){g?w(!1):c(!1);return}if(!g){if(D.key==="ArrowLeft"&&m){D.preventDefault(),p("prev");return}D.key==="ArrowRight"&&v&&(D.preventDefault(),p("next"))}}};if(n)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[n,c,p,m,v,g]),l.useEffect(()=>{n&&a&&(M||G||h||F)?(f(!0),fetch(_).then(u=>{if(u.ok)return u.text();throw new Error("Failed to load file")}).then(u=>{E(u)}).catch(u=>{console.error("Failed to load text content:",u),E(null)}).finally(()=>{f(!1)})):E(null)},[n,a?.id,M,G,h,F,_]),!a)return null;const Y=u=>{if(u===0)return"0 B";const D=1024,H=["B","KB","MB","GB"],o=Math.floor(Math.log(u)/Math.log(D));return parseFloat((u/Math.pow(D,o)).toFixed(2))+" "+H[o]},U=u=>new Date(u).toLocaleString(),B=u=>u.startsWith("image/")?e.jsx(fe,{className:"h-6 w-6"}):u.startsWith("video/")?e.jsx(Fe,{className:"h-6 w-6"}):u.startsWith("audio/")?e.jsx(le,{className:"h-6 w-6"}):u.includes("text")||u.includes("document")||u.includes("code")?e.jsx(je,{className:"h-6 w-6"}):u.includes("json")||u.includes("javascript")||u.includes("typescript")?e.jsx($e,{className:"h-6 w-6"}):e.jsx(We,{className:"h-6 w-6"}),T=()=>{if(N)return e.jsxs(e.Fragment,{children:[e.jsx("img",{src:_,alt:a.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(I,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>w(!0),children:e.jsx(cs,{className:"h-4 w-4"})})]});if(b)return e.jsx("iframe",{src:_,className:"w-full h-full min-h-[600px] rounded-lg border",title:a.name});if(K)return e.jsx("video",{src:_,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",children:"Your browser does not support the video tag."});if(k)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(le,{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:_,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]});if(G&&j!==null)return y?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(ia,{remarkPlugins:[ca],rehypePlugins:[oa],children:j})});if(F&&j!==null)return y?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:j,className:"w-full h-full min-h-[600px] rounded-lg border",title:a.name,sandbox:"allow-same-origin"});if(h&&j!==null){if(y)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 u=j;try{const D=JSON.parse(j);u=JSON.stringify(D,null,2)}catch{}return e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto",children:e.jsx("code",{children:u})})})}return M&&j!==null?y?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:j})})}):P?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:_,alt:a.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(I,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>w(!0),children:e.jsx(cs,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[B(a.type),e.jsx("p",{className:"text-sm",children:"Preview not available for this file type"}),e.jsxs(I,{variant:"outline",onClick:()=>x(a),children:[e.jsx(Oe,{className:"mr-2 h-4 w-4"}),"Download to view"]})]})};return e.jsxs(e.Fragment,{children:[e.jsx(re,{open:n,onOpenChange:c,children:e.jsxs(ie,{className:"max-w-[90vw] w-[90vw] max-h-[90vh] h-[90vh] p-0 gap-0 flex flex-col [&>button]:hidden",children:[e.jsx(oe,{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:[B(a.type),e.jsxs("div",{className:"flex-1 min-w-0 flex items-baseline gap-3",children:[e.jsx(ce,{className:"text-xl truncate",children:a.name}),e.jsx("p",{className:"text-sm text-muted-foreground flex-shrink-0",children:a.type})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>d(a),title:"Copy path to clipboard",children:e.jsx(Ss,{className:"h-4 w-4"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>x(a),title:"Download",children:e.jsx(Oe,{className:"h-4 w-4"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>c(!1),title:"Close",children:e.jsx(Xe,{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:[m&&e.jsx("button",{type:"button",onClick:()=>p("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(ks,{className:"h-5 w-5"})}),v&&e.jsx("button",{type:"button",onClick:()=>p("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(Cs,{className:"h-5 w-5"})}),T()]}),e.jsx("div",{className:"border-t p-6 flex-shrink-0 bg-background",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{children:e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsx("span",{children:Y(a.size)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(va,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"}),e.jsx("span",{children:U(a.uploadedAt)})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[a.metadata.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-2",children:"Description"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.metadata.description})]}),a.metadata.tags&&a.metadata.tags.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:a.metadata.tags.map(u=>e.jsx(Ne,{variant:"secondary",children:u},u))})]})]})]})})]})})]})}),g&&(P||N)&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black/95 flex items-center justify-center",onClick:()=>w(!1),children:[e.jsx(I,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 h-10 w-10 text-white hover:bg-white/20",onClick:()=>w(!1),children:e.jsx(Xe,{className:"h-6 w-6"})}),e.jsx("img",{src:_,alt:a.name,className:"max-w-[95vw] max-h-[95vh] object-contain",onClick:u=>u.stopPropagation()})]})]})}function jt(){const[n,c]=l.useState([]),[a,d]=l.useState(!0),[x,p]=l.useState(!1),[m,v]=l.useState(""),[j,E]=l.useState(!1),[y,f]=l.useState([]),[g,w]=l.useState(""),[_,P]=l.useState(""),[N,b]=l.useState([]),[K,k]=l.useState(!1),[M,G]=l.useState(!1),[h,F]=l.useState(!1),[Y,U]=l.useState(null),[B,T]=l.useState(null),[u,D]=l.useState(null),[H,o]=l.useState(1),Q=12,r=l.useRef(null),{toast:S}=Ie();l.useEffect(()=>{A()},[]);const A=async()=>{try{d(!0);const i=await(await fetch(`${J}/api/v1/resources`)).json();i.success&&c(i.data||[])}catch(s){console.error("Failed to fetch resources:",s)}finally{d(!1)}},ee=s=>{s.length!==0&&b(Array.from(s))},ue=async()=>{if(N.length!==0){p(!0);try{for(const s of N){const i=new FormData;if(i.append("file",s),i.append("tags",y.join(", ")),i.append("description",_),!(await fetch(`${J}/api/v1/resources`,{method:"POST",body:i})).ok)throw new Error("Upload failed")}f([]),w(""),P(""),b([]),E(!1),await A(),S({title:"Upload successful",description:`${N.length} file(s) uploaded successfully`})}catch(s){console.error("Upload failed:",s),S({title:"Upload failed",description:"Failed to upload files. Please try again.",variant:"destructive"})}finally{p(!1)}}},me=()=>{f([]),w(""),P(""),b([]),E(!1)},ye=s=>{if(s.key==="Enter"){s.preventDefault();const i=g.trim();i&&!y.includes(i)&&(f([...y,i]),w(""))}},_e=s=>{f(y.filter(i=>i!==s))},Re=s=>{b(N.filter((i,R)=>R!==s))},Se=async()=>{if(u)try{if((await fetch(`${J}/api/v1/resources/${u.id}`,{method:"DELETE"})).ok)await A(),S({title:"Resource deleted",description:`${u.name} has been deleted`});else throw new Error("Delete failed")}catch(s){console.error("Failed to delete resource:",s),S({title:"Delete failed",description:"Failed to delete resource. Please try again.",variant:"destructive"})}finally{D(null)}},ve=async s=>{try{const i=`.nut/resources/files/${s.path}`;await ga(i),S({title:"Path copied!",description:`Copied ${i} to clipboard`})}catch(i){console.error("Failed to copy path:",i),S({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},De=s=>{if(s===0)return"0 B";const i=1024,R=["B","KB","MB","GB"],q=Math.floor(Math.log(s)/Math.log(i));return parseFloat((s/Math.pow(i,q)).toFixed(2))+" "+R[q]},Te=(s,i)=>{const R=i.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||R.endsWith(".svg")?e.jsx(ns,{className:"h-4 w-4"}):e.jsx(fe,{className:"h-4 w-4"}):s.startsWith("video/")?e.jsx(rs,{className:"h-4 w-4"}):s.startsWith("audio/")?e.jsx(ts,{className:"h-4 w-4"}):s==="application/pdf"||R.endsWith(".pdf")?e.jsx(je,{className:"h-4 w-4"}):R.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx($e,{className:"h-4 w-4"}):s==="application/json"||R.endsWith(".json")?e.jsx(ls,{className:"h-4 w-4"}):s.includes("spreadsheet")||s.includes("excel")||R.match(/\.(xls|xlsx|csv)$/)?e.jsx(is,{className:"h-4 w-4"}):s.includes("presentation")||s.includes("powerpoint")||R.match(/\.(ppt|pptx)$/)?e.jsx(ds,{className:"h-4 w-4"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(je,{className:"h-4 w-4"}):s.includes("font")||R.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(os,{className:"h-4 w-4"}):e.jsx(We,{className:"h-4 w-4"})},t=(s,i)=>{const R=i.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||R.endsWith(".svg")?e.jsx(ns,{className:"h-16 w-16"}):e.jsx(fe,{className:"h-16 w-16"}):s.startsWith("video/")?e.jsx(rs,{className:"h-16 w-16"}):s.startsWith("audio/")?e.jsx(ts,{className:"h-16 w-16"}):s==="application/pdf"||R.endsWith(".pdf")?e.jsx(je,{className:"h-16 w-16"}):R.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx($e,{className:"h-16 w-16"}):s==="application/json"||R.endsWith(".json")?e.jsx(ls,{className:"h-16 w-16"}):s.includes("spreadsheet")||s.includes("excel")||R.match(/\.(xls|xlsx|csv)$/)?e.jsx(is,{className:"h-16 w-16"}):s.includes("presentation")||s.includes("powerpoint")||R.match(/\.(ppt|pptx)$/)?e.jsx(ds,{className:"h-16 w-16"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(je,{className:"h-16 w-16"}):s.includes("font")||R.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(os,{className:"h-16 w-16"}):e.jsx(We,{className:"h-16 w-16"})},X=s=>{const i=s.name.toLowerCase(),R=s.type.startsWith("image/");return s.type==="image/svg+xml"||i.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:`${J}/api/v1/resources/${s.id}`,alt:s.name,className:"w-full h-full object-contain"})}):R&&s.thumbnailPath?e.jsx("img",{src:`${J}/api/v1/resources/${s.id}/thumbnail`,alt:s.name,className:"w-full h-32 object-cover rounded-md border",onError:te=>{te.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:t(s.type,s.name)})})},Z=n.filter(s=>{if(!m)return!0;const i=m.toLowerCase();return s.name.toLowerCase().includes(i)||s.metadata.description?.toLowerCase().includes(i)||s.metadata.tags?.some(R=>R.toLowerCase().includes(i))}),ae=Math.ceil(Z.length/Q),he=(H-1)*Q,Ae=Z.slice(he,he+Q);l.useEffect(()=>{o(1)},[m]);const Us=s=>{s.preventDefault(),s.stopPropagation()},zs=s=>{s.preventDefault(),s.stopPropagation(),s.dataTransfer.files&&s.dataTransfer.files.length>0&&ee(s.dataTransfer.files)},Hs=(s,i)=>{if(i.target.closest("button"))return;U(s);const q=Z.findIndex(te=>te.id===s.id);T(q>=0?q:null)},Je=s=>{window.open(`${J}/api/v1/resources/${s.id}?download=true`)},Ys=async s=>{p(!0);try{const i=await fetch(s);if(!i.ok)throw new Error("Failed to download generated image");const R=await i.blob(),q=`generated-image-${Date.now()}.png`,te=new FormData;if(te.append("file",R,q),te.append("tags",y.join(",")),te.append("description",_),!(await fetch(`${J}/api/v1/resources`,{method:"POST",body:te})).ok)throw new Error("Upload failed");await A(),S({title:"Image saved",description:"Generated image has been saved to resources"})}catch(i){throw console.error("Failed to save generated image:",i),S({title:"Save failed",description:i instanceof Error?i.message:"Failed to save generated image",variant:"destructive"}),i}finally{p(!1)}},Js=s=>{window.dispatchEvent(new CustomEvent("customize-prompt-in-assistant",{detail:{prompt:s}}))},Qs=async s=>{p(!0);try{const i=await fetch(s);if(!i.ok)throw new Error("Failed to download generated audio");const R=await i.blob();let q="mp3";const te=i.headers.get("content-type");te?.includes("wav")?q="wav":te?.includes("flac")?q="flac":s.includes(".wav")?q="wav":s.includes(".flac")&&(q="flac");const Ce=`generated-audio-${Date.now()}.${q}`,ne=new FormData;if(ne.append("file",R,Ce),ne.append("tags",y.join(",")),ne.append("description",_),!(await fetch(`${J}/api/v1/resources`,{method:"POST",body:ne})).ok)throw new Error("Upload failed");await A(),S({title:"Audio saved",description:"Generated audio has been saved to resources"})}catch(i){throw console.error("Failed to save generated audio:",i),S({title:"Save failed",description:i instanceof Error?i.message:"Failed to save generated audio",variant:"destructive"}),i}finally{p(!1)}},qs=async s=>{p(!0);try{const i=await fetch(s);if(!i.ok)throw new Error("Failed to download generated video");const R=await i.blob();let q="mp4";(i.headers.get("content-type")?.includes("webm")||s.includes(".webm"))&&(q="webm");const Ce=`generated-video-${Date.now()}.${q}`,ne=new FormData;if(ne.append("file",R,Ce),ne.append("tags",y.join(",")),ne.append("description",_),!(await fetch(`${J}/api/v1/resources`,{method:"POST",body:ne})).ok)throw new Error("Upload failed");await A(),S({title:"Video saved",description:"Generated video has been saved to resources"})}catch(i){throw console.error("Failed to save generated video:",i),S({title:"Save failed",description:i instanceof Error?i.message:"Failed to save generated video",variant:"destructive"}),i}finally{p(!1)}},Xs=s=>{if(B===null)return;const i=s==="next"?B+1:B-1;if(i<0||i>=Z.length)return;const R=Z[i];T(i),U(R)};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(da,{children:[e.jsx(ua,{asChild:!0,children:e.jsxs(I,{variant:"outline",size:"sm",children:[e.jsx(ke,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Generate"}),e.jsx(ma,{className:"h-3 w-3 ml-1 opacity-50"})]})}),e.jsxs(ha,{align:"end",className:"min-w-[var(--radix-dropdown-menu-trigger-width)]",children:[e.jsxs(Le,{onClick:()=>k(!0),children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Image"]}),e.jsxs(Le,{onClick:()=>G(!0),children:[e.jsx(le,{className:"h-4 w-4 mr-2"}),"Audio"]}),e.jsxs(Le,{onClick:()=>F(!0),children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Video"]})]})]}),e.jsxs(I,{size:"sm",onClick:()=>E(!j),children:[e.jsx(as,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Upload Resources"})]})]})]}),e.jsx(re,{open:j,onOpenChange:s=>!s&&me(),children:e.jsxs(ie,{className:"max-w-2xl",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Upload Resource"}),e.jsx(Ze,{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:Us,onDrop:zs,onClick:()=>r.current?.click(),children:[e.jsx(Ra,{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:r,type:"file",multiple:!0,className:"hidden",onChange:s=>s.target.files&&ee(s.target.files)}),N.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Selected Files (",N.length,")"]}),e.jsx("div",{className:"border rounded-lg p-3 max-h-40 overflow-y-auto space-y-2",children:N.map((s,i)=>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(I,{variant:"ghost",size:"sm",onClick:()=>Re(i),className:"h-6 w-6 p-0 ml-2",children:e.jsx(es,{className:"h-3 w-3"})})]},i))})]}),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(Ee,{id:"tags",placeholder:"Type a tag and press Enter",value:g,onChange:s=>w(s.target.value),onKeyDown:ye}),y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:y.map(s=>e.jsxs(Ne,{variant:"secondary",className:"text-xs",children:[s,e.jsx("button",{type:"button",onClick:()=>_e(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(de,{id:"description",placeholder:"Brief description of this resource...",value:_,onChange:s=>P(s.target.value),rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(I,{variant:"outline",onClick:me,disabled:x,children:"Cancel"}),e.jsx(I,{onClick:ue,disabled:N.length===0||x,children:x?"Uploading...":`Upload ${N.length>0?`(${N.length})`:""}`})]})]})]})}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs("div",{className:"relative flex-1 w-full",children:[e.jsx(ja,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Ee,{placeholder:"Search resources...",value:m,onChange:s=>v(s.target.value),className:"pl-8"})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:a?Array.from({length:6}).map((s,i)=>e.jsxs(Ke,{className:"animate-pulse",children:[e.jsxs(ss,{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(Ve,{children:e.jsx("div",{className:"h-20 bg-muted rounded"})})]},i)):Z.length>0?Ae.map(s=>e.jsxs(Ke,{className:"hover:shadow-lg hover:bg-muted transition-all cursor-pointer",onClick:i=>Hs(s,i),children:[e.jsxs(ss,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[Te(s.type,s.name),e.jsx(fa,{className:"text-sm font-medium truncate",children:s.name})]}),e.jsxs(pa,{className:"text-xs",children:[De(s.size)," • ",new Date(s.uploadedAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex justify-end space-x-1 mt-2",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),ve(s)},title:"Copy path to clipboard",children:e.jsx(Ss,{className:"h-3 w-3"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),Je(s)},children:e.jsx(Oe,{className:"h-3 w-3"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),D(s)},children:e.jsx(es,{className:"h-3 w-3"})})]})]}),e.jsxs(Ve,{className:"pt-0",children:[e.jsx("div",{className:"mb-3",children:X(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(i=>e.jsx(Ne,{variant:"secondary",className:"text-xs",children:i},i))})]})]},s.id)):e.jsx("div",{className:"col-span-full",children:e.jsx(Ke,{children:e.jsxs(Ve,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(xa,{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(I,{className:"mt-4",onClick:()=>E(!0),children:[e.jsx(as,{className:"mr-2 h-4 w-4"}),"Add First Resource"]})]})})})}),Z.length>Q&&e.jsxs("div",{className:"flex items-center justify-center gap-4 pt-4 pb-8",children:[e.jsxs(I,{variant:H===1?"outline":"default",size:"sm",onClick:()=>o(s=>Math.max(1,s-1)),disabled:H===1,children:[e.jsx(ks,{className:"h-4 w-4 mr-1"}),"Previous"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",H," of ",ae]}),e.jsxs(I,{variant:H===ae?"outline":"default",size:"sm",onClick:()=>o(s=>Math.min(ae,s+1)),disabled:H===ae,children:["Next",e.jsx(Cs,{className:"h-4 w-4 ml-1"})]})]}),x&&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(Ka,{open:K,onOpenChange:k,onSave:Ys,onCustomizeInAssistant:Js}),e.jsx(nt,{open:M,onOpenChange:G,onSave:Qs}),e.jsx(lt,{open:h,onOpenChange:F,onSave:qs}),e.jsx(rt,{open:!!Y,onOpenChange:s=>{s||U(null),s||T(null)},resource:Y,onCopyPath:ve,onDownload:Je,onNavigate:Xs,canNavigatePrev:B!==null&&B>0,canNavigateNext:B!==null&&B<Z.length-1}),e.jsx(re,{open:!!u,onOpenChange:s=>!s&&D(null),children:e.jsxs(ie,{className:"max-w-md",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Delete Resource"}),e.jsxs(Ze,{children:["Are you sure you want to delete ",e.jsx("strong",{children:u?.name}),"? This action cannot be undone."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(I,{variant:"outline",onClick:()=>D(null),children:"Cancel"}),e.jsx(I,{variant:"destructive",onClick:Se,children:"Delete"})]})]})})]})}export{jt as default};
@@ -1,4 +1,4 @@
1
- import{c as f,r,A as p,j as e,a1 as F,B as l,I as c,T as L}from"./index-B0JO3x3V.js";import{C as T,b as I,a as z}from"./card-B9ym6neB.js";import{L as n}from"./label-BHOOQ99D.js";import{B as _}from"./badge-DaM4gF82.js";import{P as D}from"./plus-D737EJ5S.js";/**
1
+ import{c as f,r,A as p,j as e,a1 as F,B as l,I as c,T as L}from"./index-BAEEeZzi.js";import{C as T,b as I,a as z}from"./card-C9ekeZtD.js";import{L as n}from"./label-CRsu1MwQ.js";import{B as _}from"./badge-fHjW-wEe.js";import{P as D}from"./plus-CemYz5Fm.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.