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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/routes/api/v1/resources/generate/route.js +6 -0
  2. package/dist/routes/api/v1/resources/generate-audio/route.js +6 -0
  3. package/dist/routes/api/v1/resources/generate-video/index.d.ts +3 -0
  4. package/dist/routes/api/v1/resources/generate-video/index.js +5 -0
  5. package/dist/routes/api/v1/resources/generate-video/route.d.ts +19 -0
  6. package/dist/routes/api/v1/resources/generate-video/route.js +241 -0
  7. package/dist/routes/api/v1/resources/index.js +2 -0
  8. package/dist/routes/api/v1/resources/route.d.ts +4 -0
  9. package/dist/routes/api/v1/resources/route.js +8 -4
  10. package/package.json +4 -4
  11. package/static/assets/{AgentDetailPage-B3CFO9Vg.js → AgentDetailPage-Opv1vviq.js} +1 -1
  12. package/static/assets/{AgentEditPage-Cc8k9uYb.js → AgentEditPage-uLCBQAKt.js} +1 -1
  13. package/static/assets/{AgentsPage-CcRVHD2p.js → AgentsPage-CbwDfB0S.js} +1 -1
  14. package/static/assets/{AgentsSettingsPage-BMphtJ6C.js → AgentsSettingsPage-wqr9YnHr.js} +1 -1
  15. package/static/assets/{ApiKeysSettingsPage-BLlmALn1.js → ApiKeysSettingsPage-16htmPFV.js} +1 -1
  16. package/static/assets/{ArchitectureEditPage-B8YrHerA.js → ArchitectureEditPage-Dvfb4b-o.js} +1 -1
  17. package/static/assets/{ArchitecturePage-fIoEV_ow.js → ArchitecturePage-CzD1Oize.js} +1 -1
  18. package/static/assets/{AuthSettingsPage-CICO_5eb.js → AuthSettingsPage-BP2zlNfC.js} +1 -1
  19. package/static/assets/{CallbackPage-6lJyGru9.js → CallbackPage-DEnicyfd.js} +1 -1
  20. package/static/assets/{CodePage-gGhNXTQn.js → CodePage-wBG-_Rs8.js} +1 -1
  21. package/static/assets/{CollapsibleSection-CkCVMSBD.js → CollapsibleSection-DSatk0YZ.js} +1 -1
  22. package/static/assets/{DashboardPage-qkyq1COW.js → DashboardPage-DmXHKAfY.js} +1 -1
  23. package/static/assets/{GitPage-Dj9uMiQV.js → GitPage-C-ZudM8s.js} +1 -1
  24. package/static/assets/{GitSettingsPage--hjPt4zu.js → GitSettingsPage-DtvqZDAp.js} +1 -1
  25. package/static/assets/{IdentityPage-DzqrsAU2.js → IdentityPage-WwVp_vBZ.js} +1 -1
  26. package/static/assets/{ImplementationStepsEditor-GxhD-g8y.js → ImplementationStepsEditor-BKDdpUue.js} +1 -1
  27. package/static/assets/{IntegrationsSettingsPage-DR_v_Fbo.js → IntegrationsSettingsPage-Vhh08Jjd.js} +1 -1
  28. package/static/assets/{KnowledgeDetailPage-BEHrLcNg.js → KnowledgeDetailPage-B8jlP-NF.js} +1 -1
  29. package/static/assets/{KnowledgeEditPage-CETMgdZf.js → KnowledgeEditPage-BppjRoZZ.js} +1 -1
  30. package/static/assets/{KnowledgePage-Dz2YIqdH.js → KnowledgePage-CasWW1a1.js} +1 -1
  31. package/static/assets/{LoginPage-DSxl4xGK.js → LoginPage-DkguuNDQ.js} +1 -1
  32. package/static/assets/{McpSettingsPage-CLDzqlt3.js → McpSettingsPage-CZfBLxIj.js} +1 -1
  33. package/static/assets/{NewAgentPage-DlEnBUUY.js → NewAgentPage-BbANsmjr.js} +1 -1
  34. package/static/assets/{NewKnowledgePage-CI8D1NRB.js → NewKnowledgePage-BE18vt4E.js} +1 -1
  35. package/static/assets/{NewProposalPage-B1hVwad9.js → NewProposalPage-BxKHijwN.js} +1 -1
  36. package/static/assets/{ProjectEditPage-t_oD7x6f.js → ProjectEditPage-uwwvFm_Y.js} +1 -1
  37. package/static/assets/{ProjectPage-CMez4KRO.js → ProjectPage-DJvT8Jwp.js} +1 -1
  38. package/static/assets/{PromptsSettingsPage-DXvS4JX8.js → PromptsSettingsPage-CWdSTKxS.js} +1 -1
  39. package/static/assets/{ProposalDetailPage-Cbld0UYO.js → ProposalDetailPage-CDyosWFj.js} +1 -1
  40. package/static/assets/{ProposalEditPage-Dujm4G1-.js → ProposalEditPage-D9b0X_vT.js} +1 -1
  41. package/static/assets/{ProposalsPage-0L4kWC5Y.js → ProposalsPage-DdfAejqH.js} +1 -1
  42. package/static/assets/ResourcesPage-DCJ-ob0_.js +71 -0
  43. package/static/assets/{RulesSettingsPage-D6qjkKbl.js → RulesSettingsPage-CrIrk78x.js} +1 -1
  44. package/static/assets/{SchedulePage-CgnTsib0.js → SchedulePage-Dq53Q6fB.js} +1 -1
  45. package/static/assets/{TagInput-DJMwLVTn.js → TagInput-DtQl22K7.js} +1 -1
  46. package/static/assets/{TerminalPage-EYVbapc9.js → TerminalPage-BcclpXIS.js} +1 -1
  47. package/static/assets/{TerminalSessionPage-CQCLFjOR.js → TerminalSessionPage-Tecaum7f.js} +1 -1
  48. package/static/assets/{UserPreferencesPage-KAsCdvFQ.js → UserPreferencesPage-B4jeTbEe.js} +1 -1
  49. package/static/assets/{UserSettingsPage-DclI2Mhd.js → UserSettingsPage-D_fTJGEB.js} +1 -1
  50. package/static/assets/{UtilitiesPage-BKdyva6y.js → UtilitiesPage-BVSfnezp.js} +1 -1
  51. package/static/assets/{alert-p2sQnjrU.js → alert-DT5dIcQb.js} +1 -1
  52. package/static/assets/{arrow-down-DGeJDsho.js → arrow-down-D5JMw0I7.js} +1 -1
  53. package/static/assets/{arrow-left-BRSAC1N6.js → arrow-left-BbL7bi4b.js} +1 -1
  54. package/static/assets/{arrow-up-C5ecpR5U.js → arrow-up-D5zdohVZ.js} +1 -1
  55. package/static/assets/{badge-DaM4gF82.js → badge-CxMDR-vz.js} +1 -1
  56. package/static/assets/{browser-modal-CyeEbzDK.js → browser-modal-DZprh22G.js} +1 -1
  57. package/static/assets/{calendar-CV2haPQ9.js → calendar-DjIpzqju.js} +1 -1
  58. package/static/assets/{card-B9ym6neB.js → card-Cq3qftln.js} +1 -1
  59. package/static/assets/{chevron-left-D8aMFTU2.js → chevron-left-8PdSXGp8.js} +1 -1
  60. package/static/assets/{circle-alert-C-piOZLm.js → circle-alert-CPeWHRYV.js} +1 -1
  61. package/static/assets/{circle-check-4zzXsmHH.js → circle-check-BsF5HxbR.js} +1 -1
  62. package/static/assets/{circle-check-big-AlE11jqb.js → circle-check-big-DViAc1A0.js} +1 -1
  63. package/static/assets/{circle-play-cWY3nlZW.js → circle-play-C0yQlVR9.js} +1 -1
  64. package/static/assets/{circle-x-D58MbKgZ.js → circle-x-CT_9xyVN.js} +1 -1
  65. package/static/assets/{clipboard-BFF6-pdC.js → clipboard-D-CHbLVc.js} +1 -1
  66. package/static/assets/{clock-B-uSJOTR.js → clock-D5nAa1In.js} +1 -1
  67. package/static/assets/{download-DrQn0jny.js → download-Bl3cP1zr.js} +1 -1
  68. package/static/assets/{eye-BcjteMts.js → eye-DgdIekU1.js} +1 -1
  69. package/static/assets/{folder-git-2-B_ezHf_E.js → folder-git-2-BD7LL99o.js} +1 -1
  70. package/static/assets/{index-B0JO3x3V.js → index-CKcm92Kn.js} +3 -3
  71. package/static/assets/index-D9b0oysW.css +2 -0
  72. package/static/assets/{label-BHOOQ99D.js → label-COUiN2Pd.js} +1 -1
  73. package/static/assets/{markdown-editor-B0i_LOAR.js → markdown-editor-Cln2Jo2-.js} +1 -1
  74. package/static/assets/{pause-DqQ7Twc6.js → pause-CupPWZ26.js} +1 -1
  75. package/static/assets/{play-Y2N8OVBu.js → play-sWUKmZEy.js} +1 -1
  76. package/static/assets/{plus-D737EJ5S.js → plus-DM62ve-p.js} +1 -1
  77. package/static/assets/{radio-group-nRRUTZ_w.js → radio-group-B6pYL4p4.js} +1 -1
  78. package/static/assets/{refresh-cw-uBnPtZwp.js → refresh-cw-ClU12bdt.js} +1 -1
  79. package/static/assets/{search-cntvIhnF.js → search-DHLiojAp.js} +1 -1
  80. package/static/assets/{switch-BYf9VEgx.js → switch-DC_em8xh.js} +1 -1
  81. package/static/assets/{tabs-BnsC3AY5.js → tabs-KzUqSzqd.js} +1 -1
  82. package/static/assets/{tag-C_HL28Xd.js → tag-cF4ktw0a.js} +1 -1
  83. package/static/assets/{terminal-preview-Qv4UvCJz.js → terminal-preview-D-pmjUNP.js} +1 -1
  84. package/static/assets/{use-terminal-5sW1t6SD.js → use-terminal-C1j4Pa5C.js} +1 -1
  85. package/static/assets/{zap-CrLPiVyl.js → zap-DGHMgsd8.js} +1 -1
  86. package/static/index.html +2 -2
  87. package/static/assets/ResourcesPage-5sZL01s_.js +0 -66
  88. package/static/assets/index-C8p-lTq9.css +0 -2
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-B0JO3x3V.js";/**
1
+ import{c as e}from"./index-CKcm92Kn.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-B0JO3x3V.js";/**
1
+ import{c as a}from"./index-CKcm92Kn.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-B0JO3x3V.js";/**
1
+ import{c as e}from"./index-CKcm92Kn.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as n,b8 as E,aq as K,ak as T,j as a,al as N,b9 as U,ao as x,ap as w,ba as V,an as g,bb as z,at as H,as as $,f as I,bc as W}from"./index-B0JO3x3V.js";var C="Radio",[X,k]=N(C),[Y,J]=X(C),_=n.forwardRef((r,t)=>{const{__scopeRadio:e,name:c,checked:o=!1,required:s,disabled:i,value:p="on",onCheck:f,form:R,...v}=r,[l,m]=n.useState(null),d=w(t,y=>m(y)),u=n.useRef(!1),b=l?R||!!l.closest("form"):!0;return a.jsxs(Y,{scope:e,checked:o,disabled:i,children:[a.jsx(x.button,{type:"button",role:"radio","aria-checked":o,"data-state":S(o),"data-disabled":i?"":void 0,disabled:i,value:p,...v,ref:d,onClick:g(r.onClick,y=>{o||f?.(),b&&(u.current=y.isPropagationStopped(),u.current||y.stopPropagation())})}),b&&a.jsx(P,{control:l,bubbles:!u.current,name:c,value:p,checked:o,required:s,disabled:i,form:R,style:{transform:"translateX(-100%)"}})]})});_.displayName=C;var j="RadioIndicator",G=n.forwardRef((r,t)=>{const{__scopeRadio:e,forceMount:c,...o}=r,s=J(j,e);return a.jsx(z,{present:c||s.checked,children:a.jsx(x.span,{"data-state":S(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});G.displayName=j;var Q="RadioBubbleInput",P=n.forwardRef(({__scopeRadio:r,control:t,checked:e,bubbles:c=!0,...o},s)=>{const i=n.useRef(null),p=w(i,s),f=H(e),R=$(t);return n.useEffect(()=>{const v=i.current;if(!v)return;const l=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(l,"checked").set;if(f!==e&&d){const u=new Event("click",{bubbles:c});d.call(v,e),v.dispatchEvent(u)}},[f,e,c]),a.jsx(x.input,{type:"radio","aria-hidden":!0,defaultChecked:e,...o,tabIndex:-1,ref:p,style:{...o.style,...R,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});P.displayName=Q;function S(r){return r?"checked":"unchecked"}var Z=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],h="RadioGroup",[ee,ce]=N(h,[E,k]),A=E(),D=k(),[oe,re]=ee(h),M=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,name:c,defaultValue:o,value:s,required:i=!1,disabled:p=!1,orientation:f,dir:R,loop:v=!0,onValueChange:l,...m}=r,d=A(e),u=K(R),[b,y]=T({prop:s,defaultProp:o??null,onChange:l,caller:h});return a.jsx(oe,{scope:e,name:c,required:i,disabled:p,value:b,onValueChange:y,children:a.jsx(U,{asChild:!0,...d,orientation:f,dir:u,loop:v,children:a.jsx(x.div,{role:"radiogroup","aria-required":i,"aria-orientation":f,"data-disabled":p?"":void 0,dir:u,...m,ref:t})})})});M.displayName=h;var O="RadioGroupItem",q=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,disabled:c,...o}=r,s=re(O,e),i=s.disabled||c,p=A(e),f=D(e),R=n.useRef(null),v=w(t,R),l=s.value===o.value,m=n.useRef(!1);return n.useEffect(()=>{const d=b=>{Z.includes(b.key)&&(m.current=!0)},u=()=>m.current=!1;return document.addEventListener("keydown",d),document.addEventListener("keyup",u),()=>{document.removeEventListener("keydown",d),document.removeEventListener("keyup",u)}},[]),a.jsx(V,{asChild:!0,...p,focusable:!i,active:l,children:a.jsx(_,{disabled:i,required:s.required,checked:l,...f,...o,name:s.name,ref:v,onCheck:()=>s.onValueChange(o.value),onKeyDown:g(d=>{d.key==="Enter"&&d.preventDefault()}),onFocus:g(o.onFocus,()=>{m.current&&R.current?.click()})})})});q.displayName=O;var ae="RadioGroupIndicator",F=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,...c}=r,o=D(e);return a.jsx(G,{...o,...c,ref:t})});F.displayName=ae;var L=M,B=q,te=F;const se=n.forwardRef(({className:r,...t},e)=>a.jsx(L,{className:I("grid gap-2",r),...t,ref:e}));se.displayName=L.displayName;const ne=n.forwardRef(({className:r,...t},e)=>a.jsx(B,{ref:e,className:I("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),...t,children:a.jsx(te,{className:"flex items-center justify-center",children:a.jsx(W,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ne.displayName=B.displayName;export{se as R,ne as a};
1
+ import{r as n,b8 as E,aq as K,ak as T,j as a,al as N,b9 as U,ao as x,ap as w,ba as V,an as g,bb as z,at as H,as as $,f as I,bc as W}from"./index-CKcm92Kn.js";var C="Radio",[X,k]=N(C),[Y,J]=X(C),_=n.forwardRef((r,t)=>{const{__scopeRadio:e,name:c,checked:o=!1,required:s,disabled:i,value:p="on",onCheck:f,form:R,...v}=r,[l,m]=n.useState(null),d=w(t,y=>m(y)),u=n.useRef(!1),b=l?R||!!l.closest("form"):!0;return a.jsxs(Y,{scope:e,checked:o,disabled:i,children:[a.jsx(x.button,{type:"button",role:"radio","aria-checked":o,"data-state":S(o),"data-disabled":i?"":void 0,disabled:i,value:p,...v,ref:d,onClick:g(r.onClick,y=>{o||f?.(),b&&(u.current=y.isPropagationStopped(),u.current||y.stopPropagation())})}),b&&a.jsx(P,{control:l,bubbles:!u.current,name:c,value:p,checked:o,required:s,disabled:i,form:R,style:{transform:"translateX(-100%)"}})]})});_.displayName=C;var j="RadioIndicator",G=n.forwardRef((r,t)=>{const{__scopeRadio:e,forceMount:c,...o}=r,s=J(j,e);return a.jsx(z,{present:c||s.checked,children:a.jsx(x.span,{"data-state":S(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});G.displayName=j;var Q="RadioBubbleInput",P=n.forwardRef(({__scopeRadio:r,control:t,checked:e,bubbles:c=!0,...o},s)=>{const i=n.useRef(null),p=w(i,s),f=H(e),R=$(t);return n.useEffect(()=>{const v=i.current;if(!v)return;const l=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(l,"checked").set;if(f!==e&&d){const u=new Event("click",{bubbles:c});d.call(v,e),v.dispatchEvent(u)}},[f,e,c]),a.jsx(x.input,{type:"radio","aria-hidden":!0,defaultChecked:e,...o,tabIndex:-1,ref:p,style:{...o.style,...R,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});P.displayName=Q;function S(r){return r?"checked":"unchecked"}var Z=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],h="RadioGroup",[ee,ce]=N(h,[E,k]),A=E(),D=k(),[oe,re]=ee(h),M=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,name:c,defaultValue:o,value:s,required:i=!1,disabled:p=!1,orientation:f,dir:R,loop:v=!0,onValueChange:l,...m}=r,d=A(e),u=K(R),[b,y]=T({prop:s,defaultProp:o??null,onChange:l,caller:h});return a.jsx(oe,{scope:e,name:c,required:i,disabled:p,value:b,onValueChange:y,children:a.jsx(U,{asChild:!0,...d,orientation:f,dir:u,loop:v,children:a.jsx(x.div,{role:"radiogroup","aria-required":i,"aria-orientation":f,"data-disabled":p?"":void 0,dir:u,...m,ref:t})})})});M.displayName=h;var O="RadioGroupItem",q=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,disabled:c,...o}=r,s=re(O,e),i=s.disabled||c,p=A(e),f=D(e),R=n.useRef(null),v=w(t,R),l=s.value===o.value,m=n.useRef(!1);return n.useEffect(()=>{const d=b=>{Z.includes(b.key)&&(m.current=!0)},u=()=>m.current=!1;return document.addEventListener("keydown",d),document.addEventListener("keyup",u),()=>{document.removeEventListener("keydown",d),document.removeEventListener("keyup",u)}},[]),a.jsx(V,{asChild:!0,...p,focusable:!i,active:l,children:a.jsx(_,{disabled:i,required:s.required,checked:l,...f,...o,name:s.name,ref:v,onCheck:()=>s.onValueChange(o.value),onKeyDown:g(d=>{d.key==="Enter"&&d.preventDefault()}),onFocus:g(o.onFocus,()=>{m.current&&R.current?.click()})})})});q.displayName=O;var ae="RadioGroupIndicator",F=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,...c}=r,o=D(e);return a.jsx(G,{...o,...c,ref:t})});F.displayName=ae;var L=M,B=q,te=F;const se=n.forwardRef(({className:r,...t},e)=>a.jsx(L,{className:I("grid gap-2",r),...t,ref:e}));se.displayName=L.displayName;const ne=n.forwardRef(({className:r,...t},e)=>a.jsx(B,{ref:e,className:I("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),...t,children:a.jsx(te,{className:"flex items-center justify-center",children:a.jsx(W,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ne.displayName=B.displayName;export{se as R,ne as a};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-B0JO3x3V.js";/**
1
+ import{c as e}from"./index-CKcm92Kn.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c}from"./index-B0JO3x3V.js";/**
1
+ import{c}from"./index-CKcm92Kn.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as c,j as e,f as i}from"./index-B0JO3x3V.js";const d=c.forwardRef(({className:s,onCheckedChange:r,onChange:t,...o},n)=>{const l=a=>{t?.(a),r?.(a.target.checked)};return e.jsxs("label",{className:i("relative inline-flex cursor-pointer",s),children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",onChange:l,ref:n,...o}),e.jsx("div",{className:"block bg-gray-300 w-9 h-5 rounded-full transition-colors duration-200 ease-in-out peer-checked:bg-blue-600"}),e.jsx("div",{className:"absolute left-0 top-0 bg-white w-4 h-4 rounded-full mt-0.5 ml-0.5 transition-transform duration-200 ease-in-out transform peer-checked:translate-x-4 shadow"})]})});d.displayName="Switch";export{d as S};
1
+ import{r as c,j as e,f as i}from"./index-CKcm92Kn.js";const d=c.forwardRef(({className:s,onCheckedChange:r,onChange:t,...o},n)=>{const l=a=>{t?.(a),r?.(a.target.checked)};return e.jsxs("label",{className:i("relative inline-flex cursor-pointer",s),children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",onChange:l,ref:n,...o}),e.jsx("div",{className:"block bg-gray-300 w-9 h-5 rounded-full transition-colors duration-200 ease-in-out peer-checked:bg-blue-600"}),e.jsx("div",{className:"absolute left-0 top-0 bg-white w-4 h-4 rounded-full mt-0.5 ml-0.5 transition-transform duration-200 ease-in-out transform peer-checked:translate-x-4 shadow"})]})});d.displayName="Switch";export{d as S};
@@ -1 +1 @@
1
- import{r as l,aq as F,ak as $,j as c,al as k,be as D,ao as g,b8 as y,b9 as V,ba as G,an as m,bb as L,f as T}from"./index-B0JO3x3V.js";var p="Tabs",[K,Q]=k(p,[y]),h=y(),[q,x]=K(p),N=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,onValueChange:r,defaultValue:d,orientation:n="horizontal",dir:u,activationMode:f="automatic",...v}=e,i=F(u),[s,b]=$({prop:o,onChange:r,defaultProp:d??"",caller:p});return c.jsx(q,{scope:t,baseId:D(),value:s,onValueChange:b,orientation:n,dir:i,activationMode:f,children:c.jsx(g.div,{dir:i,"data-orientation":n,...v,ref:a})})});N.displayName=p;var C="TabsList",I=l.forwardRef((e,a)=>{const{__scopeTabs:t,loop:o=!0,...r}=e,d=x(C,t),n=h(t);return c.jsx(V,{asChild:!0,...n,orientation:d.orientation,dir:d.dir,loop:o,children:c.jsx(g.div,{role:"tablist","aria-orientation":d.orientation,...r,ref:a})})});I.displayName=C;var R="TabsTrigger",j=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,disabled:r=!1,...d}=e,n=x(R,t),u=h(t),f=A(n.baseId,o),v=E(n.baseId,o),i=o===n.value;return c.jsx(G,{asChild:!0,...u,focusable:!r,active:i,children:c.jsx(g.button,{type:"button",role:"tab","aria-selected":i,"aria-controls":v,"data-state":i?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:f,...d,ref:a,onMouseDown:m(e.onMouseDown,s=>{!r&&s.button===0&&s.ctrlKey===!1?n.onValueChange(o):s.preventDefault()}),onKeyDown:m(e.onKeyDown,s=>{[" ","Enter"].includes(s.key)&&n.onValueChange(o)}),onFocus:m(e.onFocus,()=>{const s=n.activationMode!=="manual";!i&&!r&&s&&n.onValueChange(o)})})})});j.displayName=R;var w="TabsContent",_=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,forceMount:r,children:d,...n}=e,u=x(w,t),f=A(u.baseId,o),v=E(u.baseId,o),i=o===u.value,s=l.useRef(i);return l.useEffect(()=>{const b=requestAnimationFrame(()=>s.current=!1);return()=>cancelAnimationFrame(b)},[]),c.jsx(L,{present:r||i,children:({present:b})=>c.jsx(g.div,{"data-state":i?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":f,hidden:!b,id:v,tabIndex:0,...n,ref:a,style:{...e.style,animationDuration:s.current?"0s":void 0},children:b&&d})})});_.displayName=w;function A(e,a){return`${e}-trigger-${a}`}function E(e,a){return`${e}-content-${a}`}var B=N,S=I,M=j,P=_;const U=B,z=l.forwardRef(({className:e,...a},t)=>c.jsx(S,{ref:t,className:T("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...a}));z.displayName=S.displayName;const H=l.forwardRef(({className:e,...a},t)=>c.jsx(M,{ref:t,className:T("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...a}));H.displayName=M.displayName;const O=l.forwardRef(({className:e,...a},t)=>c.jsx(P,{ref:t,className:T("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a}));O.displayName=P.displayName;export{U as T,z as a,H as b,O as c};
1
+ import{r as l,aq as F,ak as $,j as c,al as k,be as D,ao as g,b8 as y,b9 as V,ba as G,an as m,bb as L,f as T}from"./index-CKcm92Kn.js";var p="Tabs",[K,Q]=k(p,[y]),h=y(),[q,x]=K(p),N=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,onValueChange:r,defaultValue:d,orientation:n="horizontal",dir:u,activationMode:f="automatic",...v}=e,i=F(u),[s,b]=$({prop:o,onChange:r,defaultProp:d??"",caller:p});return c.jsx(q,{scope:t,baseId:D(),value:s,onValueChange:b,orientation:n,dir:i,activationMode:f,children:c.jsx(g.div,{dir:i,"data-orientation":n,...v,ref:a})})});N.displayName=p;var C="TabsList",I=l.forwardRef((e,a)=>{const{__scopeTabs:t,loop:o=!0,...r}=e,d=x(C,t),n=h(t);return c.jsx(V,{asChild:!0,...n,orientation:d.orientation,dir:d.dir,loop:o,children:c.jsx(g.div,{role:"tablist","aria-orientation":d.orientation,...r,ref:a})})});I.displayName=C;var R="TabsTrigger",j=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,disabled:r=!1,...d}=e,n=x(R,t),u=h(t),f=A(n.baseId,o),v=E(n.baseId,o),i=o===n.value;return c.jsx(G,{asChild:!0,...u,focusable:!r,active:i,children:c.jsx(g.button,{type:"button",role:"tab","aria-selected":i,"aria-controls":v,"data-state":i?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:f,...d,ref:a,onMouseDown:m(e.onMouseDown,s=>{!r&&s.button===0&&s.ctrlKey===!1?n.onValueChange(o):s.preventDefault()}),onKeyDown:m(e.onKeyDown,s=>{[" ","Enter"].includes(s.key)&&n.onValueChange(o)}),onFocus:m(e.onFocus,()=>{const s=n.activationMode!=="manual";!i&&!r&&s&&n.onValueChange(o)})})})});j.displayName=R;var w="TabsContent",_=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,forceMount:r,children:d,...n}=e,u=x(w,t),f=A(u.baseId,o),v=E(u.baseId,o),i=o===u.value,s=l.useRef(i);return l.useEffect(()=>{const b=requestAnimationFrame(()=>s.current=!1);return()=>cancelAnimationFrame(b)},[]),c.jsx(L,{present:r||i,children:({present:b})=>c.jsx(g.div,{"data-state":i?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":f,hidden:!b,id:v,tabIndex:0,...n,ref:a,style:{...e.style,animationDuration:s.current?"0s":void 0},children:b&&d})})});_.displayName=w;function A(e,a){return`${e}-trigger-${a}`}function E(e,a){return`${e}-content-${a}`}var B=N,S=I,M=j,P=_;const U=B,z=l.forwardRef(({className:e,...a},t)=>c.jsx(S,{ref:t,className:T("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...a}));z.displayName=S.displayName;const H=l.forwardRef(({className:e,...a},t)=>c.jsx(M,{ref:t,className:T("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...a}));H.displayName=M.displayName;const O=l.forwardRef(({className:e,...a},t)=>c.jsx(P,{ref:t,className:T("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a}));O.displayName=P.displayName;export{U as T,z as a,H as b,O as c};
@@ -1,4 +1,4 @@
1
- import{c}from"./index-B0JO3x3V.js";/**
1
+ import{c}from"./index-CKcm92Kn.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as p,r as e,ab as S,j as u}from"./index-B0JO3x3V.js";import{x as F,a as N}from"./xterm-DTxiCjtJ.js";/**
1
+ import{c as p,r as e,ab as S,j as u}from"./index-CKcm92Kn.js";import{x as F,a as N}from"./xterm-DTxiCjtJ.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as i,ag as b,A as f}from"./index-B0JO3x3V.js";function j(){const[y,u]=i.useState([]),[g,c]=i.useState(!1),[m,o]=i.useState(null),{refresh:p}=b(),d=i.useCallback(async(s,n,r)=>{try{c(!0),o(null);const e=await fetch(`${f}/api/v1/terminal/${s}/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enableLogging:n||!1,startupCommand:r})});if(!e.ok){const a=await e.json();throw new Error(a.error||"Failed to create terminal session")}const t=await e.json();return await p(),t.sessionId}catch(e){const t=e instanceof Error?e.message:"Unknown error";return o(t),null}finally{c(!1)}},[p]),S=i.useCallback(async s=>{try{c(!0),o(null);let n;if(s.startsWith("session-")){const e=s.split("-");n=`${e[0]}-${e[1]}`}else{const e=s.split("-");n=`${e[0]}-${e[1]}`}const r=await fetch(`${f}/api/v1/terminal/${n}/destroy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s})});if(!r.ok){const e=await r.json();throw new Error(e.error||"Failed to destroy terminal session")}return u(e=>e.filter(t=>t.id!==s)),await p(),!0}catch(n){const r=n instanceof Error?n.message:"Unknown error";return o(r),!1}finally{c(!1)}},[p]),$=i.useCallback(async(s,n,r)=>{try{o(null);let e;if(s.startsWith("session-")){const a=s.split("-");e=`${a[0]}-${a[1]}`}else{const a=s.split("-");e=`${a[0]}-${a[1]}`}const t=await fetch(`${f}/api/v1/terminal/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,cols:n,rows:r})});if(!t.ok){const a=await t.json();throw new Error(a.error||"Failed to resize terminal session")}return!0}catch(e){const t=e instanceof Error?e.message:"Unknown error";return o(t),!1}},[]),k=i.useCallback(async(s,n,r)=>{try{c(!0),o(null);const e=new URLSearchParams;s&&e.set("proposalId",s),n&&(e.set("withPreview","true"),r&&Number.isFinite(r)&&e.set("lines",String(r)));const t=`${f}/api/v1/terminal/sessions${e.toString()?`?${e.toString()}`:""}`,a=await fetch(t);if(!a.ok){const l=await a.json();throw new Error(l.error||"Failed to fetch terminal sessions")}const w=await a.json();u(w.sessions)}catch(e){const t=e instanceof Error?e.message:"Unknown error";o(t)}finally{c(!1)}},[]),E=i.useCallback(async(s,n=8)=>{try{o(null);const r=new URLSearchParams;r.set("sessionId",s),r.set("withPreview","true"),r.set("lines",String(n)),r.set("colorize","true");const e=`${f}/api/v1/terminal/sessions?${r.toString()}`,t=await fetch(e);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.error||"Failed to fetch preview")}const a=await t.json(),w=Array.isArray(a?.sessions)&&a.sessions[0]?.preview?a.sessions[0].preview:[];return u(l=>l.map(h=>h.id===s?{...h,preview:w}:h)),w}catch(r){const e=r instanceof Error?r.message:"Unknown error";return o(e),[]}},[]);return{sessions:y,loading:g,error:m,createSession:d,destroySession:S,resizeSession:$,refreshSessions:k,fetchPreview:E}}export{j as u};
1
+ import{r as i,ag as b,A as f}from"./index-CKcm92Kn.js";function j(){const[y,u]=i.useState([]),[g,c]=i.useState(!1),[m,o]=i.useState(null),{refresh:p}=b(),d=i.useCallback(async(s,n,r)=>{try{c(!0),o(null);const e=await fetch(`${f}/api/v1/terminal/${s}/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enableLogging:n||!1,startupCommand:r})});if(!e.ok){const a=await e.json();throw new Error(a.error||"Failed to create terminal session")}const t=await e.json();return await p(),t.sessionId}catch(e){const t=e instanceof Error?e.message:"Unknown error";return o(t),null}finally{c(!1)}},[p]),S=i.useCallback(async s=>{try{c(!0),o(null);let n;if(s.startsWith("session-")){const e=s.split("-");n=`${e[0]}-${e[1]}`}else{const e=s.split("-");n=`${e[0]}-${e[1]}`}const r=await fetch(`${f}/api/v1/terminal/${n}/destroy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s})});if(!r.ok){const e=await r.json();throw new Error(e.error||"Failed to destroy terminal session")}return u(e=>e.filter(t=>t.id!==s)),await p(),!0}catch(n){const r=n instanceof Error?n.message:"Unknown error";return o(r),!1}finally{c(!1)}},[p]),$=i.useCallback(async(s,n,r)=>{try{o(null);let e;if(s.startsWith("session-")){const a=s.split("-");e=`${a[0]}-${a[1]}`}else{const a=s.split("-");e=`${a[0]}-${a[1]}`}const t=await fetch(`${f}/api/v1/terminal/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,cols:n,rows:r})});if(!t.ok){const a=await t.json();throw new Error(a.error||"Failed to resize terminal session")}return!0}catch(e){const t=e instanceof Error?e.message:"Unknown error";return o(t),!1}},[]),k=i.useCallback(async(s,n,r)=>{try{c(!0),o(null);const e=new URLSearchParams;s&&e.set("proposalId",s),n&&(e.set("withPreview","true"),r&&Number.isFinite(r)&&e.set("lines",String(r)));const t=`${f}/api/v1/terminal/sessions${e.toString()?`?${e.toString()}`:""}`,a=await fetch(t);if(!a.ok){const l=await a.json();throw new Error(l.error||"Failed to fetch terminal sessions")}const w=await a.json();u(w.sessions)}catch(e){const t=e instanceof Error?e.message:"Unknown error";o(t)}finally{c(!1)}},[]),E=i.useCallback(async(s,n=8)=>{try{o(null);const r=new URLSearchParams;r.set("sessionId",s),r.set("withPreview","true"),r.set("lines",String(n)),r.set("colorize","true");const e=`${f}/api/v1/terminal/sessions?${r.toString()}`,t=await fetch(e);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.error||"Failed to fetch preview")}const a=await t.json(),w=Array.isArray(a?.sessions)&&a.sessions[0]?.preview?a.sessions[0].preview:[];return u(l=>l.map(h=>h.id===s?{...h,preview:w}:h)),w}catch(r){const e=r instanceof Error?r.message:"Unknown error";return o(e),[]}},[]);return{sessions:y,loading:g,error:m,createSession:d,destroySession:S,resizeSession:$,refreshSessions:k,fetchPreview:E}}export{j as u};
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-B0JO3x3V.js";/**
1
+ import{c as a}from"./index-CKcm92Kn.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
package/static/index.html CHANGED
@@ -8,8 +8,8 @@
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
9
9
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap" rel="stylesheet">
10
10
  <title>Coconut - Agentic Development Environment</title>
11
- <script type="module" crossorigin src="/assets/index-B0JO3x3V.js"></script>
12
- <link rel="stylesheet" crossorigin href="/assets/index-C8p-lTq9.css">
11
+ <script type="module" crossorigin src="/assets/index-CKcm92Kn.js"></script>
12
+ <link rel="stylesheet" crossorigin href="/assets/index-D9b0oysW.css">
13
13
  </head>
14
14
  <body class="font-inter">
15
15
  <div id="root"></div>
@@ -1,66 +0,0 @@
1
- import{c as X,r as l,j as e,D as re,a as ie,b as oe,d as ce,n as Y,S as ze,B as I,ah as He,aj as fe,H as Oe,A as q,a0 as pe,v as W,w as V,x as B,y as O,z as L,ac as Ye,ak as Ts,al as Gs,am as As,an as ne,ao as je,ap as de,aq as Ls,ar as ps,as as Ks,at as Ws,f as Vs,I as ke,ai as gs,X as Bs,C as Os,g as he,au as Ge,av as $s,aw as Us,ax as zs,e as Je,T as Qe,ay as Hs}from"./index-B0JO3x3V.js";import{C as De,b as qe,a as Te,c as Ys,d as Js}from"./card-B9ym6neB.js";import{L as M}from"./label-BHOOQ99D.js";import{B as ge}from"./badge-DaM4gF82.js";import{c as Qs}from"./clipboard-B9ndUJKl.js";import{R as vs}from"./registry-ANRa5WBi.js";import{D as Ae}from"./download-DrQn0jny.js";import{C as qs}from"./chevron-left-D8aMFTU2.js";import{C as Xs}from"./calendar-CV2haPQ9.js";import{P as Xe}from"./plus-D737EJ5S.js";import{S as Zs}from"./search-cntvIhnF.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 ea=[["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"}]],Ze=X("file-audio",ea);/**
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 sa=[["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"}]],Le=X("file-code",sa);/**
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 aa=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["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"}]],es=X("file-image",aa);/**
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 ta=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["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"}]],ss=X("file-json",ta);/**
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 na=[["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"}]],as=X("file-play",na);/**
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 la=[["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"}]],ts=X("file-spreadsheet",la);/**
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 ra=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]],ns=X("file-type",ra);/**
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 ia=[["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"}]],oa=X("hard-drive",ia);/**
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 ca=[["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"}]],ve=X("image",ca);/**
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 da=[["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=X("music",da);/**
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 ua=[["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"}]],ls=X("presentation",ua);/**
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 ma=[["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"}]],ha=X("upload",ma);/**
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 xa=[["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"}]],fa=X("video",xa);async function js(n){const i=n.startsWith("http")?n:`${vs}${n}`,a=await fetch(i,{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 pa(){return js("/registry/resources/root.json")}async function rs(n){return js(n)}function Pe(n){if(n)return n.startsWith("http")?n:`${vs}${n}`}function ga({open:n,onOpenChange:i,onSelectExample:a,onCustomizeInAssistant:c}){const[u,f]=l.useState([]),[m,p]=l.useState(!1),[v,S]=l.useState(null),[y,h]=l.useState(null),[x,w]=l.useState(null),[E,C]=l.useState(!1),[j,_]=l.useState(null);l.useEffect(()=>{n&&(p(!0),S(null),h(null),w(null),_(null),pa().then(d=>{f(d.elements??[]),d.elements&&d.elements.length>0&&G(d.elements[0])}).catch(d=>{console.error("Failed to load registry resources",d),f([]),S("Failed to load examples from registry")}).finally(()=>p(!1)))},[n]);const G=async d=>{h(d.id),_(null),w(null),C(!0);try{const P=await rs(d.endpoint);w(P)}catch(P){console.error("Failed to load resource detail",P),_("Unable to load details for this example")}finally{C(!1)}},k=()=>{x?.prompt&&(a(x.prompt),i(!1))},N=()=>{x?.prompt&&c&&(c(x.prompt),i(!1))},R=async d=>{if(y===d.id&&x?.prompt){a(x.prompt),i(!1);return}try{const P=await rs(d.endpoint);P.prompt&&(a(P.prompt),i(!1))}catch(P){console.error("Failed to load resource detail",P)}};return e.jsx(re,{open:n,onOpenChange:i,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?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(Y,{className:"h-5 w-5 animate-spin mr-2"}),"Loading..."]}):j?e.jsx("p",{className:"text-sm text-muted-foreground",children:j}):x?e.jsx("img",{src:Pe(x.imageUrl),alt:x.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select an example"})}),e.jsxs("div",{className:"flex-1 min-h-0 border-t flex flex-col",children:[m?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(Y,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):v?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:v}):u.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(ze,{className:"flex-1",children:e.jsx("div",{className:"p-3 space-y-2",children:u.map(d=>e.jsxs("button",{onClick:()=>G(d),onDoubleClick:()=>R(d),className:`w-full text-left p-2 rounded-lg border-2 transition-all flex gap-3 ${y===d.id?"border-primary bg-primary/5":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[d.thumbnailUrl&&e.jsx("img",{src:Pe(d.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:d.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:d.description})]})]},d.id))})}),e.jsx("div",{className:"p-3 border-t flex-shrink-0",children:e.jsxs(I,{onClick:k,disabled:!x?.prompt||E,className:"w-full",children:[e.jsx(He,{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(Y,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):v?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:v}):u.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(ze,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-3",children:u.map(d=>e.jsxs("button",{onClick:()=>G(d),onDoubleClick:()=>R(d),className:`w-full text-left p-3 rounded-lg border-2 transition-all flex gap-3 ${y===d.id?"border-primary bg-primary/5 shadow-sm":"border-transparent bg-muted/50 hover:bg-muted hover:border-muted-foreground/20"}`,children:[d.thumbnailUrl&&e.jsx("img",{src:Pe(d.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:d.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:d.description}),d.tags&&d.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[d.tags.slice(0,3).map(P=>e.jsx(ge,{variant:"secondary",className:"text-[10px]",children:P},P)),d.tags.length>3&&e.jsxs(ge,{variant:"outline",className:"text-[10px]",children:["+",d.tags.length-3]})]})]})]},d.id))})}),e.jsx("div",{className:"p-4 border-t flex-shrink-0",children:e.jsxs(I,{onClick:k,disabled:!x?.prompt||E,className:"w-full",children:[e.jsx(He,{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?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(Y,{className:"h-5 w-5 animate-spin mr-2"}),"Loading details..."]}):j?e.jsx("p",{className:"text-sm text-muted-foreground",children:j}):x?e.jsx("img",{src:Pe(x.imageUrl),alt:x.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select an example to preview"})}),x&&e.jsxs("div",{className:"border-t p-4 bg-background flex-shrink-0 max-h-[30%] overflow-y-auto 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:x.prompt}),c&&e.jsxs(I,{size:"sm",variant:"secondary",onClick:N,className:"absolute bottom-4 right-4",children:[e.jsx(fe,{className:"mr-1.5 h-3.5 w-3.5"}),"Customize in Assistant"]})]})]})]})]})})}const Ke={"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}}},is=Object.values(Ke).map(n=>({value:n.id,label:n.label})),os=[{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"}],va={value:"match_input_image",label:"Match Input"},cs=[{value:"png",label:"PNG"},{value:"jpg",label:"JPG"},{value:"webp",label:"WebP"}],ds=[{value:"60",label:"60"},{value:"70",label:"70"},{value:"80",label:"80"},{value:"90",label:"90"},{value:"100",label:"100"}],us=[{value:"1",label:"1 (Strict)"},{value:"2",label:"2"},{value:"3",label:"3"},{value:"4",label:"4"},{value:"5",label:"5"},{value:"6",label:"6 (Relaxed)"}];function ja({open:n,onOpenChange:i,onSave:a,onCustomizeInAssistant:c}){const[u,f]=l.useState(""),[m,p]=l.useState("nano-banana-pro"),[v,S]=l.useState("4:3"),[y,h]=l.useState("2K"),[x,w]=l.useState("png"),[E,C]=l.useState("80"),[j,_]=l.useState(!0),[G,k]=l.useState("2"),[N,R]=l.useState(null),[d,P]=l.useState(!1),[A,U]=l.useState(!1),[g,b]=l.useState([]),[D,T]=l.useState([]),[J,r]=l.useState(!0),[Z,$]=l.useState(!1),{toast:z}=Oe(),K=Ke[m],ye=K.features.matchInputImage?[va,...os]:os,_e=K.resolutionOptions||[];l.useEffect(()=>{const t=Ke[m];t.defaults.resolution&&t.features.resolution&&h(t.defaults.resolution),t.defaults.outputQuality!==void 0&&C(String(t.defaults.outputQuality)),t.defaults.goFast!==void 0&&_(t.defaults.goFast),t.defaults.safetyTolerance!==void 0&&k(String(t.defaults.safetyTolerance)),S(H=>H==="match_input_image"&&!t.features.matchInputImage?"4:3":H)},[m]),l.useEffect(()=>{n&&we()},[n]);const we=async()=>{try{const H=await(await fetch(`${q}/api/v1/resources`)).json();if(H.success){const te=(H.data||[]).filter(se=>{const me=se.type==="image/jpeg"||se.name.toLowerCase().endsWith(".jpg")||se.name.toLowerCase().endsWith(".jpeg"),Re=se.type==="image/png"||se.name.toLowerCase().endsWith(".png");return(me||Re)&&se.thumbnailPath});b(te)}}catch(t){console.error("Failed to fetch image resources:",t)}},Ne=async()=>{if(!u.trim()){z({title:"Prompt required",description:"Please enter a prompt to generate an image",variant:"destructive"});return}P(!0),R(null);try{const t=J||D.length===0?[]:[...D],H=await fetch(`${q}/api/v1/resources/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u,model:m,dimensions:v,resolution:K.features.resolution?y:void 0,output_format:x,output_quality:K.features.outputQuality?parseInt(E):void 0,go_fast:K.features.goFast?j:void 0,safety_tolerance:K.features.safetyTolerance?parseInt(G):void 0,image_input:t})}),te=await H.json();if(!H.ok||!te.success){const se=te.error?.message||"Failed to generate image",me=te.error?.code==="MISSING_API_TOKEN";throw new Error(me?"Replicate API token not configured. Please add it in Settings → Integrations.":se)}R(te.data.imageUrl),z({title:"Image generated",description:"Your image has been generated successfully"})}catch(t){console.error("Generation error:",t),z({title:"Generation failed",description:t instanceof Error?t.message:"Failed to generate image. Please try again.",variant:"destructive"})}finally{P(!1)}},be=async()=>{if(N){U(!0);try{await a(N),f(""),p("nano-banana-pro"),S("4:3"),h("2K"),w("png"),C("80"),_(!0),k("2"),R(null),r(!0),T([]),i(!1)}catch(t){z({title:"Save failed",description:t instanceof Error?t.message:"Failed to save image. Please try again.",variant:"destructive"})}finally{U(!1)}}},Ee=()=>{!d&&!A&&i(!1)},Se=()=>{r(!0),T([])},ae=t=>{J&&r(!1),D.includes(t)?(T(D.filter(H=>H!==t)),D.length===1&&r(!0)):D.length<3?T([...D,t]):z({title:"Maximum selection",description:"You can only select up to 3 images",variant:"destructive"})},Fe=t=>{f(t)},Ie=t=>{c&&($(!1),i(!1),c(`"${t}" Please customize this (and respond back just the updated markdown):`))};return e.jsxs(re,{open:n,onOpenChange:Ee,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:d?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(Y,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):N?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:N,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(ve,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"}),e.jsxs(I,{size:"sm",onClick:()=>$(!0),className:"mt-2",children:[e.jsx(fe,{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 ${J?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),g.map(t=>{const H=D.includes(t.id);return e.jsx("button",{onClick:()=>ae(t.id),className:`flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${H?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${q}/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(M,{htmlFor:"prompt-mobile",className:"text-xs",children:"Prompt"}),e.jsx(pe,{id:"prompt-mobile",placeholder:"Describe the image...",value:u,onChange:t=>f(t.target.value),rows:2,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{htmlFor:"model-mobile",className:"text-xs",children:"Model"}),e.jsxs(W,{value:m,onValueChange:t=>p(t),children:[e.jsx(V,{id:"model-mobile",className:"h-8 text-xs",children:e.jsx(B,{})}),e.jsx(O,{children:is.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(M,{htmlFor:"outputFormat-mobile",className:"text-xs",children:"Format"}),e.jsxs(W,{value:x,onValueChange:w,children:[e.jsx(V,{id:"outputFormat-mobile",className:"h-8 text-xs",children:e.jsx(B,{})}),e.jsx(O,{children:cs.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),K.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(Ye,{id:"goFast-mobile",checked:j,onCheckedChange:t=>_(t===!0)}),e.jsx(M,{htmlFor:"goFast-mobile",className:"text-xs cursor-pointer",children:"Go Fast"})]})}),K.features.safetyTolerance&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{htmlFor:"safetyTolerance-mobile",className:"text-xs",children:"Safety"}),e.jsxs(W,{value:G,onValueChange:k,children:[e.jsx(V,{id:"safetyTolerance-mobile",className:"h-8 text-xs",children:e.jsx(B,{})}),e.jsx(O,{children:us.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[K.features.resolution&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(M,{htmlFor:"resolution-mobile",className:"text-xs",children:"Resolution"}),e.jsxs(W,{value:y,onValueChange:h,children:[e.jsx(V,{id:"resolution-mobile",className:"h-8 text-xs",children:e.jsx(B,{})}),e.jsx(O,{children:_e.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(M,{htmlFor:"aspectRatio-mobile",className:"text-xs",children:"Ratio"}),e.jsxs(W,{value:v,onValueChange:S,children:[e.jsx(V,{id:"aspectRatio-mobile",className:"h-8 text-xs",children:e.jsx(B,{})}),e.jsx(O,{children:ye.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),K.features.outputQuality&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(M,{htmlFor:"outputQuality-mobile",className:"text-xs",children:"Quality"}),e.jsxs(W,{value:E,onValueChange:C,children:[e.jsx(V,{id:"outputQuality-mobile",className:"h-8 text-xs",children:e.jsx(B,{})}),e.jsx(O,{children:ds.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:Ne,disabled:!u.trim()||d||A,className:"flex-1 h-9",size:"sm",children:d?e.jsx(Y,{className:"h-4 w-4 animate-spin"}):"Generate"}),e.jsx(I,{onClick:be,disabled:!N||d||A,variant:"outline",className:"flex-1 h-9",size:"sm",children:A?e.jsx(Y,{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(M,{htmlFor:"prompt",children:"Prompt"}),e.jsx(pe,{id:"prompt",placeholder:"Describe the image you want to generate...",value:u,onChange:t=>f(t.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"model",children:"Model"}),e.jsxs(W,{value:m,onValueChange:t=>p(t),children:[e.jsx(V,{id:"model",children:e.jsx(B,{})}),e.jsx(O,{children:is.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(W,{value:v,onValueChange:S,children:[e.jsx(V,{id:"aspectRatio",children:e.jsx(B,{})}),e.jsx(O,{children:ye.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),K.features.resolution&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(W,{value:y,onValueChange:h,children:[e.jsx(V,{id:"resolution",children:e.jsx(B,{})}),e.jsx(O,{children:_e.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"outputFormat",children:"Output Format"}),e.jsxs(W,{value:x,onValueChange:w,children:[e.jsx(V,{id:"outputFormat",children:e.jsx(B,{})}),e.jsx(O,{children:cs.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),K.features.outputQuality&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"outputQuality",children:"Output Quality"}),e.jsxs(W,{value:E,onValueChange:C,children:[e.jsx(V,{id:"outputQuality",children:e.jsx(B,{})}),e.jsx(O,{children:ds.map(t=>e.jsx(L,{value:t.value,children:t.label},t.value))})]})]}),K.features.goFast&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ye,{id:"goFast",checked:j,onCheckedChange:t=>_(t===!0)}),e.jsx(M,{htmlFor:"goFast",className:"cursor-pointer",children:"Go Fast"})]}),K.features.safetyTolerance&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"safetyTolerance",children:"Safety Tolerance"}),e.jsxs(W,{value:G,onValueChange:k,children:[e.jsx(V,{id:"safetyTolerance",children:e.jsx(B,{})}),e.jsx(O,{children:us.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:Ne,disabled:!u.trim()||d||A,className:"w-full",children:d?e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate"}),e.jsx(I,{onClick:be,disabled:!N||d||A,variant:"outline",className:"w-full",children:A?e.jsxs(e.Fragment,{children:[e.jsx(Y,{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:d?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(Y,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating image..."})]}):N?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:N,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(ve,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated image will appear here"}),e.jsxs(I,{onClick:()=>$(!0),className:"mt-2",children:[e.jsx(fe,{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 ${J?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),g.map(t=>{const H=D.includes(t.id);return e.jsx("button",{onClick:()=>ae(t.id),className:`flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${H?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${q}/api/v1/resources/${t.id}/thumbnail`,alt:t.name,className:"w-full h-full object-cover"})},t.id)})]})})]})]})]}),e.jsx(ga,{open:Z,onOpenChange:$,onSelectExample:Fe,onCustomizeInAssistant:c?Ie:void 0})]})}var ys=["PageUp","PageDown"],_s=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ws={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ue="Slider",[We,ya,_a]=As(ue),[Ns,Xa]=Gs(ue,[_a]),[wa,Me]=Ns(ue),bs=l.forwardRef((n,i)=>{const{name:a,min:c=0,max:u=100,step:f=1,orientation:m="horizontal",disabled:p=!1,minStepsBetweenThumbs:v=0,defaultValue:S=[c],value:y,onValueChange:h=()=>{},onValueCommit:x=()=>{},inverted:w=!1,form:E,...C}=n,j=l.useRef(new Set),_=l.useRef(0),k=m==="horizontal"?Na:ba,[N=[],R]=Ts({prop:y,defaultProp:S,onChange:b=>{[...j.current][_.current]?.focus(),h(b)}}),d=l.useRef(N);function P(b){const D=Ma(N,b);g(b,D)}function A(b){g(b,_.current)}function U(){const b=d.current[_.current];N[_.current]!==b&&x(N)}function g(b,D,{commit:T}={commit:!1}){const J=Ra(f),r=Da(Math.round((b-c)/f)*f+c,J),Z=ps(r,[c,u]);R(($=[])=>{const z=Pa($,Z,D);if(Ia(z,v*f)){_.current=z.indexOf(Z);const K=String(z)!==String($);return K&&T&&x(z),K?z:$}else return $})}return e.jsx(wa,{scope:n.__scopeSlider,name:a,disabled:p,min:c,max:u,valueIndexToChangeRef:_,thumbs:j.current,values:N,orientation:m,form:E,children:e.jsx(We.Provider,{scope:n.__scopeSlider,children:e.jsx(We.Slot,{scope:n.__scopeSlider,children:e.jsx(k,{"aria-disabled":p,"data-disabled":p?"":void 0,...C,ref:i,onPointerDown:ne(C.onPointerDown,()=>{p||(d.current=N)}),min:c,max:u,inverted:w,onSlideStart:p?void 0:P,onSlideMove:p?void 0:A,onSlideEnd:p?void 0:U,onHomeKeyDown:()=>!p&&g(c,0,{commit:!0}),onEndKeyDown:()=>!p&&g(u,N.length-1,{commit:!0}),onStepKeyDown:({event:b,direction:D})=>{if(!p){const r=ys.includes(b.key)||b.shiftKey&&_s.includes(b.key)?10:1,Z=_.current,$=N[Z],z=f*r*D;g($+z,Z,{commit:!0})}}})})})})});bs.displayName=ue;var[Ss,Cs]=Ns(ue,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Na=l.forwardRef((n,i)=>{const{min:a,max:c,dir:u,inverted:f,onSlideStart:m,onSlideMove:p,onSlideEnd:v,onStepKeyDown:S,...y}=n,[h,x]=l.useState(null),w=de(i,k=>x(k)),E=l.useRef(void 0),C=Ls(u),j=C==="ltr",_=j&&!f||!j&&f;function G(k){const N=E.current||h.getBoundingClientRect(),R=[0,N.width],P=$e(R,_?[a,c]:[c,a]);return E.current=N,P(k-N.left)}return e.jsx(Ss,{scope:n.__scopeSlider,startEdge:_?"left":"right",endEdge:_?"right":"left",direction:_?1:-1,size:"width",children:e.jsx(Ps,{dir:C,"data-orientation":"horizontal",...y,ref:w,style:{...y.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:k=>{const N=G(k.clientX);m?.(N)},onSlideMove:k=>{const N=G(k.clientX);p?.(N)},onSlideEnd:()=>{E.current=void 0,v?.()},onStepKeyDown:k=>{const R=ws[_?"from-left":"from-right"].includes(k.key);S?.({event:k,direction:R?-1:1})}})})}),ba=l.forwardRef((n,i)=>{const{min:a,max:c,inverted:u,onSlideStart:f,onSlideMove:m,onSlideEnd:p,onStepKeyDown:v,...S}=n,y=l.useRef(null),h=de(i,y),x=l.useRef(void 0),w=!u;function E(C){const j=x.current||y.current.getBoundingClientRect(),_=[0,j.height],k=$e(_,w?[c,a]:[a,c]);return x.current=j,k(C-j.top)}return e.jsx(Ss,{scope:n.__scopeSlider,startEdge:w?"bottom":"top",endEdge:w?"top":"bottom",size:"height",direction:w?1:-1,children:e.jsx(Ps,{"data-orientation":"vertical",...S,ref:h,style:{...S.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:C=>{const j=E(C.clientY);f?.(j)},onSlideMove:C=>{const j=E(C.clientY);m?.(j)},onSlideEnd:()=>{x.current=void 0,p?.()},onStepKeyDown:C=>{const _=ws[w?"from-bottom":"from-top"].includes(C.key);v?.({event:C,direction:_?-1:1})}})})}),Ps=l.forwardRef((n,i)=>{const{__scopeSlider:a,onSlideStart:c,onSlideMove:u,onSlideEnd:f,onHomeKeyDown:m,onEndKeyDown:p,onStepKeyDown:v,...S}=n,y=Me(ue,a);return e.jsx(je.span,{...S,ref:i,onKeyDown:ne(n.onKeyDown,h=>{h.key==="Home"?(m(h),h.preventDefault()):h.key==="End"?(p(h),h.preventDefault()):ys.concat(_s).includes(h.key)&&(v(h),h.preventDefault())}),onPointerDown:ne(n.onPointerDown,h=>{const x=h.target;x.setPointerCapture(h.pointerId),h.preventDefault(),y.thumbs.has(x)?x.focus():c(h)}),onPointerMove:ne(n.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&u(h)}),onPointerUp:ne(n.onPointerUp,h=>{const x=h.target;x.hasPointerCapture(h.pointerId)&&(x.releasePointerCapture(h.pointerId),f(h))})})}),ks="SliderTrack",Ms=l.forwardRef((n,i)=>{const{__scopeSlider:a,...c}=n,u=Me(ks,a);return e.jsx(je.span,{"data-disabled":u.disabled?"":void 0,"data-orientation":u.orientation,...c,ref:i})});Ms.displayName=ks;var Ve="SliderRange",Es=l.forwardRef((n,i)=>{const{__scopeSlider:a,...c}=n,u=Me(Ve,a),f=Cs(Ve,a),m=l.useRef(null),p=de(i,m),v=u.values.length,S=u.values.map(x=>Rs(x,u.min,u.max)),y=v>1?Math.min(...S):0,h=100-Math.max(...S);return e.jsx(je.span,{"data-orientation":u.orientation,"data-disabled":u.disabled?"":void 0,...c,ref:p,style:{...n.style,[f.startEdge]:y+"%",[f.endEdge]:h+"%"}})});Es.displayName=Ve;var Be="SliderThumb",Fs=l.forwardRef((n,i)=>{const a=ya(n.__scopeSlider),[c,u]=l.useState(null),f=de(i,p=>u(p)),m=l.useMemo(()=>c?a().findIndex(p=>p.ref.current===c):-1,[a,c]);return e.jsx(Sa,{...n,ref:f,index:m})}),Sa=l.forwardRef((n,i)=>{const{__scopeSlider:a,index:c,name:u,...f}=n,m=Me(Be,a),p=Cs(Be,a),[v,S]=l.useState(null),y=de(i,G=>S(G)),h=v?m.form||!!v.closest("form"):!0,x=Ks(v),w=m.values[c],E=w===void 0?0:Rs(w,m.min,m.max),C=ka(c,m.values.length),j=x?.[p.size],_=j?Ea(j,E,p.direction):0;return l.useEffect(()=>{if(v)return m.thumbs.add(v),()=>{m.thumbs.delete(v)}},[v,m.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[p.startEdge]:`calc(${E}% + ${_}px)`},children:[e.jsx(We.ItemSlot,{scope:n.__scopeSlider,children:e.jsx(je.span,{role:"slider","aria-label":n["aria-label"]||C,"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,...f,ref:y,style:w===void 0?{display:"none"}:n.style,onFocus:ne(n.onFocus,()=>{m.valueIndexToChangeRef.current=c})})}),h&&e.jsx(Is,{name:u??(m.name?m.name+(m.values.length>1?"[]":""):void 0),form:m.form,value:w},c)]})});Fs.displayName=Be;var Ca="RadioBubbleInput",Is=l.forwardRef(({__scopeSlider:n,value:i,...a},c)=>{const u=l.useRef(null),f=de(u,c),m=Ws(i);return l.useEffect(()=>{const p=u.current;if(!p)return;const v=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(v,"value").set;if(m!==i&&y){const h=new Event("input",{bubbles:!0});y.call(p,i),p.dispatchEvent(h)}},[m,i]),e.jsx(je.input,{style:{display:"none"},...a,ref:f,defaultValue:i})});Is.displayName=Ca;function Pa(n=[],i,a){const c=[...n];return c[a]=i,c.sort((u,f)=>u-f)}function Rs(n,i,a){const f=100/(a-i)*(n-i);return ps(f,[0,100])}function ka(n,i){return i>2?`Value ${n+1} of ${i}`:i===2?["Minimum","Maximum"][n]:void 0}function Ma(n,i){if(n.length===1)return 0;const a=n.map(u=>Math.abs(u-i)),c=Math.min(...a);return a.indexOf(c)}function Ea(n,i,a){const c=n/2,f=$e([0,50],[0,c]);return(c-f(i)*a)*a}function Fa(n){return n.slice(0,-1).map((i,a)=>n[a+1]-i)}function Ia(n,i){if(i>0){const a=Fa(n);return Math.min(...a)>=i}return!0}function $e(n,i){return a=>{if(n[0]===n[1]||i[0]===i[1])return i[0];const c=(i[1]-i[0])/(n[1]-n[0]);return i[0]+c*(a-n[0])}}function Ra(n){return(String(n).split(".")[1]||"").length}function Da(n,i){const a=Math.pow(10,i);return Math.round(n*a)/a}var Ds=bs,Ta=Ms,Ga=Es,Aa=Fs;const xe=l.forwardRef(({className:n,...i},a)=>e.jsxs(Ds,{ref:a,className:Vs("relative flex w-full touch-none select-none items-center",n),...i,children:[e.jsx(Ta,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(Ga,{className:"absolute h-full bg-primary"})}),e.jsx(Aa,{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"})]}));xe.displayName=Ds.displayName;const ms=["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"],hs=[{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"}],xs=[{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"}],fs=[{value:"mp3",label:"MP3"},{value:"wav",label:"WAV"},{value:"flac",label:"FLAC"}];function La({open:n,onOpenChange:i,onSave:a}){const[c,u]=l.useState(""),[f,m]=l.useState("English_Trustworth_Man"),[p,v]=l.useState(!1),[S,y]=l.useState(""),[h,x]=l.useState(1),[w,E]=l.useState(0),[C,j]=l.useState("auto"),[_,G]=l.useState("English"),[k,N]=l.useState("mp3"),[R,d]=l.useState(null),[P,A]=l.useState(!1),[U,g]=l.useState(!1),{toast:b}=Oe(),D=async()=>{if(!c.trim()){b({title:"Text required",description:"Please enter text to generate audio",variant:"destructive"});return}A(!0),d(null);try{const r=p?S:f,Z=await fetch(`${q}/api/v1/resources/generate-audio`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:c,voice_id:r,speed:h,pitch:w,emotion:C,language_boost:_,audio_format:k})}),$=await Z.json();if(!Z.ok||!$.success){const z=$.error?.message||"Failed to generate audio",K=$.error?.code==="MISSING_API_TOKEN";throw new Error(K?"Replicate API token not configured. Please add it in Settings → Integrations.":z)}d($.data.audioUrl),b({title:"Audio generated",description:"Your audio has been generated successfully"})}catch(r){console.error("Generation error:",r),b({title:"Generation failed",description:r instanceof Error?r.message:"Failed to generate audio. Please try again.",variant:"destructive"})}finally{A(!1)}},T=async()=>{if(R){g(!0);try{await a(R),u(""),m("English_Trustworth_Man"),v(!1),y(""),x(1),E(0),j("auto"),G("English"),N("mp3"),d(null),i(!1)}catch(r){b({title:"Save failed",description:r instanceof Error?r.message:"Failed to save audio. Please try again.",variant:"destructive"})}finally{g(!1)}}},J=()=>{!P&&!U&&i(!1)};return e.jsx(re,{open:n,onOpenChange:J,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:P?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(Y,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):R?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:R,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(M,{htmlFor:"text-mobile",className:"text-xs",children:"Text"}),e.jsx(pe,{id:"text-mobile",placeholder:"Enter text to convert to speech...",value:c,onChange:r=>u(r.target.value),rows:3,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{className:"text-xs",children:"Voice"}),e.jsxs(W,{value:p?"__custom__":f,onValueChange:r=>{r==="__custom__"?v(!0):(v(!1),m(r))},children:[e.jsx(V,{className:"h-8 text-xs",children:e.jsx(B,{})}),e.jsxs(O,{className:"max-h-60",children:[ms.map(r=>e.jsx(L,{value:r,className:"text-xs",children:r.replace(/_/g," ")},r)),e.jsx(L,{value:"__custom__",className:"text-xs font-medium",children:"Custom Voice ID..."})]})]}),p&&e.jsx(ke,{placeholder:"Enter custom voice ID",value:S,onChange:r=>y(r.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(M,{className:"text-xs",children:["Speed: ",h.toFixed(1),"x"]}),e.jsx(xe,{value:[h],onValueChange:([r])=>x(r),min:.5,max:2,step:.1,className:"w-full"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(M,{className:"text-xs",children:["Pitch: ",w>0?"+":"",w]}),e.jsx(xe,{value:[w],onValueChange:([r])=>E(r),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(M,{className:"text-xs",children:"Emotion"}),e.jsxs(W,{value:C,onValueChange:j,children:[e.jsx(V,{className:"h-8 text-xs",children:e.jsx(B,{})}),e.jsx(O,{children:hs.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(M,{className:"text-xs",children:"Language"}),e.jsxs(W,{value:_,onValueChange:G,children:[e.jsx(V,{className:"h-8 text-xs",children:e.jsx(B,{})}),e.jsx(O,{children:xs.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(M,{className:"text-xs",children:"Format"}),e.jsxs(W,{value:k,onValueChange:N,children:[e.jsx(V,{className:"h-8 text-xs",children:e.jsx(B,{})}),e.jsx(O,{children:fs.map(r=>e.jsx(L,{value:r.value,className:"text-xs",children:r.label},r.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(I,{onClick:D,disabled:!c.trim()||P||U,className:"flex-1 h-9",size:"sm",children:P?e.jsx(Y,{className:"h-4 w-4 animate-spin"}):"Generate"}),e.jsx(I,{onClick:T,disabled:!R||P||U,variant:"outline",className:"flex-1 h-9",size:"sm",children:U?e.jsx(Y,{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(M,{htmlFor:"text",children:"Text"}),e.jsx(pe,{id:"text",placeholder:"Enter text to convert to speech...",value:c,onChange:r=>u(r.target.value),rows:6,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:"Voice"}),e.jsxs(W,{value:p?"__custom__":f,onValueChange:r=>{r==="__custom__"?v(!0):(v(!1),m(r))},children:[e.jsx(V,{children:e.jsx(B,{})}),e.jsxs(O,{className:"max-h-80",children:[ms.map(r=>e.jsx(L,{value:r,children:r.replace(/_/g," ")},r)),e.jsx(L,{value:"__custom__",className:"font-medium",children:"Custom Voice ID..."})]})]}),p&&e.jsx(ke,{placeholder:"Enter custom voice ID",value:S,onChange:r=>y(r.target.value),className:"mt-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(M,{children:["Speed: ",h.toFixed(1),"x"]}),e.jsx(xe,{value:[h],onValueChange:([r])=>x(r),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(M,{children:["Pitch: ",w>0?"+":"",w]}),e.jsx(xe,{value:[w],onValueChange:([r])=>E(r),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(M,{children:"Emotion"}),e.jsxs(W,{value:C,onValueChange:j,children:[e.jsx(V,{children:e.jsx(B,{})}),e.jsx(O,{children:hs.map(r=>e.jsx(L,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:"Language Boost"}),e.jsxs(W,{value:_,onValueChange:G,children:[e.jsx(V,{children:e.jsx(B,{})}),e.jsx(O,{children:xs.map(r=>e.jsx(L,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{children:"Audio Format"}),e.jsxs(W,{value:k,onValueChange:N,children:[e.jsx(V,{children:e.jsx(B,{})}),e.jsx(O,{children:fs.map(r=>e.jsx(L,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(I,{onClick:D,disabled:!c.trim()||P||U,className:"w-full",children:P?e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate"}),e.jsx(I,{onClick:T,disabled:!R||P||U,variant:"outline",className:"w-full",children:U?e.jsxs(e.Fragment,{children:[e.jsx(Y,{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:P?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(Y,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating audio..."})]}):R?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:R,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"})]})})})]})]})})}function Ka({open:n,onOpenChange:i,resource:a,onCopyPath:c,onDownload:u,onNavigate:f,canNavigatePrev:m,canNavigateNext:p}){const[v,S]=l.useState(null),[y,h]=l.useState(!1),x=a?`${q}/api/v1/resources/${a.id}`:"",w=a?.type.startsWith("image/")??!1,E=a?a.type==="image/svg+xml"||a.name.toLowerCase().endsWith(".svg"):!1,C=a?a.type==="application/pdf"||a.name.toLowerCase().endsWith(".pdf"):!1,j=a?.type.startsWith("video/")??!1,_=a?.type.startsWith("audio/")??!1,G=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,k=a?a.name.toLowerCase().endsWith(".md")||a.name.toLowerCase().endsWith(".markdown"):!1,N=a?a.type==="application/json"||a.name.toLowerCase().endsWith(".json"):!1,R=a?a.type==="text/html"||a.name.toLowerCase().endsWith(".html"):!1;if(l.useEffect(()=>{const g=b=>{if(n){if(b.key==="Escape"){i(!1);return}if(b.key==="ArrowLeft"&&m){b.preventDefault(),f("prev");return}b.key==="ArrowRight"&&p&&(b.preventDefault(),f("next"))}};if(n)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[n,i,f,m,p]),l.useEffect(()=>{n&&a&&(G||k||N||R)?(h(!0),fetch(x).then(g=>{if(g.ok)return g.text();throw new Error("Failed to load file")}).then(g=>{S(g)}).catch(g=>{console.error("Failed to load text content:",g),S(null)}).finally(()=>{h(!1)})):S(null)},[n,a?.id,G,k,N,R,x]),!a)return null;const d=g=>{if(g===0)return"0 B";const b=1024,D=["B","KB","MB","GB"],T=Math.floor(Math.log(g)/Math.log(b));return parseFloat((g/Math.pow(b,T)).toFixed(2))+" "+D[T]},P=g=>new Date(g).toLocaleString(),A=g=>g.startsWith("image/")?e.jsx(ve,{className:"h-6 w-6"}):g.startsWith("video/")?e.jsx(fa,{className:"h-6 w-6"}):g.startsWith("audio/")?e.jsx(le,{className:"h-6 w-6"}):g.includes("text")||g.includes("document")||g.includes("code")?e.jsx(he,{className:"h-6 w-6"}):g.includes("json")||g.includes("javascript")||g.includes("typescript")?e.jsx(Le,{className:"h-6 w-6"}):e.jsx(Ge,{className:"h-6 w-6"}),U=()=>{if(E)return e.jsx("img",{src:x,alt:a.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"});if(C)return e.jsx("iframe",{src:x,className:"w-full h-full min-h-[600px] rounded-lg border",title:a.name});if(j)return e.jsx("video",{src:x,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",children:"Your browser does not support the video tag."});if(_)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:x,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]});if(k&&v!==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($s,{remarkPlugins:[zs],rehypePlugins:[Us],children:v})});if(R&&v!==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:v,className:"w-full h-full min-h-[600px] rounded-lg border",title:a.name,sandbox:"allow-same-origin"});if(N&&v!==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 g=v;try{const b=JSON.parse(v);g=JSON.stringify(b,null,2)}catch{}return e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto",children:e.jsx("code",{children:g})})})}return G&&v!==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:v})})}):w?e.jsx("img",{src:x,alt:a.name,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:[A(a.type),e.jsx("p",{className:"text-sm",children:"Preview not available for this file type"}),e.jsxs(I,{variant:"outline",onClick:()=>u(a),children:[e.jsx(Ae,{className:"mr-2 h-4 w-4"}),"Download to view"]})]})};return e.jsx(re,{open:n,onOpenChange:i,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:[A(a.type),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(ce,{className:"text-xl truncate",children:a.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a.type})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>c(a),title:"Copy path to clipboard",children:e.jsx(gs,{className:"h-4 w-4"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>u(a),title:"Download",children:e.jsx(Ae,{className:"h-4 w-4"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>i(!1),title:"Close",children:e.jsx(Bs,{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-auto",children:[m&&e.jsx("button",{type:"button",onClick:()=>f("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(qs,{className:"h-5 w-5"})}),p&&e.jsx("button",{type:"button",onClick:()=>f("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(Os,{className:"h-5 w-5"})}),U()]}),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.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Information"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oa,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsx("span",{children:d(a.size)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"}),e.jsx("span",{children:P(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(g=>e.jsx(ge,{variant:"secondary",children:g},g))})]})]})]})})]})})]})})}function Za(){const[n,i]=l.useState([]),[a,c]=l.useState(!0),[u,f]=l.useState(!1),[m,p]=l.useState(""),[v,S]=l.useState(!1),[y,h]=l.useState([]),[x,w]=l.useState(""),[E,C]=l.useState(""),[j,_]=l.useState([]),[G,k]=l.useState(!1),[N,R]=l.useState(!1),[d,P]=l.useState(null),[A,U]=l.useState(null),[g,b]=l.useState(null),D=l.useRef(null),{toast:T}=Oe();l.useEffect(()=>{J()},[]);const J=async()=>{try{c(!0);const o=await(await fetch(`${q}/api/v1/resources`)).json();o.success&&i(o.data||[])}catch(s){console.error("Failed to fetch resources:",s)}finally{c(!1)}},r=s=>{s.length!==0&&_(Array.from(s))},Z=async()=>{if(j.length!==0){f(!0);try{for(const s of j){const o=new FormData;if(o.append("file",s),o.append("tags",y.join(", ")),o.append("description",E),!(await fetch(`${q}/api/v1/resources`,{method:"POST",body:o})).ok)throw new Error("Upload failed")}h([]),w(""),C(""),_([]),S(!1),await J(),T({title:"Upload successful",description:`${j.length} file(s) uploaded successfully`})}catch(s){console.error("Upload failed:",s),T({title:"Upload failed",description:"Failed to upload files. Please try again.",variant:"destructive"})}finally{f(!1)}}},$=()=>{h([]),w(""),C(""),_([]),S(!1)},z=s=>{if(s.key==="Enter"){s.preventDefault();const o=x.trim();o&&!y.includes(o)&&(h([...y,o]),w(""))}},K=s=>{h(y.filter(o=>o!==s))},ye=s=>{_(j.filter((o,F)=>F!==s))},_e=async()=>{if(g)try{if((await fetch(`${q}/api/v1/resources/${g.id}`,{method:"DELETE"})).ok)await J(),T({title:"Resource deleted",description:`${g.name} has been deleted`});else throw new Error("Delete failed")}catch(s){console.error("Failed to delete resource:",s),T({title:"Delete failed",description:"Failed to delete resource. Please try again.",variant:"destructive"})}finally{b(null)}},we=async s=>{try{const o=`.nut/resources/files/${s.path}`;await Qs(o),T({title:"Path copied!",description:`Copied ${o} to clipboard`})}catch(o){console.error("Failed to copy path:",o),T({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},Ne=s=>{if(s===0)return"0 B";const o=1024,F=["B","KB","MB","GB"],Q=Math.floor(Math.log(s)/Math.log(o));return parseFloat((s/Math.pow(o,Q)).toFixed(2))+" "+F[Q]},be=(s,o)=>{const F=o.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||F.endsWith(".svg")?e.jsx(es,{className:"h-4 w-4"}):e.jsx(ve,{className:"h-4 w-4"}):s.startsWith("video/")?e.jsx(as,{className:"h-4 w-4"}):s.startsWith("audio/")?e.jsx(Ze,{className:"h-4 w-4"}):s==="application/pdf"||F.endsWith(".pdf")?e.jsx(he,{className:"h-4 w-4"}):F.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx(Le,{className:"h-4 w-4"}):s==="application/json"||F.endsWith(".json")?e.jsx(ss,{className:"h-4 w-4"}):s.includes("spreadsheet")||s.includes("excel")||F.match(/\.(xls|xlsx|csv)$/)?e.jsx(ts,{className:"h-4 w-4"}):s.includes("presentation")||s.includes("powerpoint")||F.match(/\.(ppt|pptx)$/)?e.jsx(ls,{className:"h-4 w-4"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(he,{className:"h-4 w-4"}):s.includes("font")||F.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(ns,{className:"h-4 w-4"}):e.jsx(Ge,{className:"h-4 w-4"})},Ee=(s,o)=>{const F=o.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||F.endsWith(".svg")?e.jsx(es,{className:"h-16 w-16"}):e.jsx(ve,{className:"h-16 w-16"}):s.startsWith("video/")?e.jsx(as,{className:"h-16 w-16"}):s.startsWith("audio/")?e.jsx(Ze,{className:"h-16 w-16"}):s==="application/pdf"||F.endsWith(".pdf")?e.jsx(he,{className:"h-16 w-16"}):F.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx(Le,{className:"h-16 w-16"}):s==="application/json"||F.endsWith(".json")?e.jsx(ss,{className:"h-16 w-16"}):s.includes("spreadsheet")||s.includes("excel")||F.match(/\.(xls|xlsx|csv)$/)?e.jsx(ts,{className:"h-16 w-16"}):s.includes("presentation")||s.includes("powerpoint")||F.match(/\.(ppt|pptx)$/)?e.jsx(ls,{className:"h-16 w-16"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(he,{className:"h-16 w-16"}):s.includes("font")||F.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(ns,{className:"h-16 w-16"}):e.jsx(Ge,{className:"h-16 w-16"})},Se=s=>{const o=s.name.toLowerCase(),F=s.type.startsWith("image/");return s.type==="image/svg+xml"||o.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:`${q}/api/v1/resources/${s.id}`,alt:s.name,className:"w-full h-full object-contain"})}):F&&s.thumbnailPath?e.jsx("img",{src:`${q}/api/v1/resources/${s.id}/thumbnail`,alt:s.name,className:"w-full h-32 object-cover rounded-md border",onError:ee=>{ee.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:Ee(s.type,s.name)})})},ae=n.filter(s=>{if(!m)return!0;const o=m.toLowerCase();return s.name.toLowerCase().includes(o)||s.metadata.description?.toLowerCase().includes(o)||s.metadata.tags?.some(F=>F.toLowerCase().includes(o))}),Fe=s=>{s.preventDefault(),s.stopPropagation()},Ie=s=>{s.preventDefault(),s.stopPropagation(),s.dataTransfer.files&&s.dataTransfer.files.length>0&&r(s.dataTransfer.files)},t=(s,o)=>{if(o.target.closest("button"))return;P(s);const Q=ae.findIndex(ee=>ee.id===s.id);U(Q>=0?Q:null)},H=s=>{window.open(`${q}/api/v1/resources/${s.id}?download=true`)},te=async s=>{f(!0);try{const o=await fetch(s);if(!o.ok)throw new Error("Failed to download generated image");const F=await o.blob(),Q=`generated-image-${Date.now()}.png`,ee=new FormData;if(ee.append("file",F,Q),ee.append("tags",y.join(",")),ee.append("description",E),!(await fetch(`${q}/api/v1/resources`,{method:"POST",body:ee})).ok)throw new Error("Upload failed");await J(),T({title:"Image saved",description:"Generated image has been saved to resources"})}catch(o){throw console.error("Failed to save generated image:",o),T({title:"Save failed",description:o instanceof Error?o.message:"Failed to save generated image",variant:"destructive"}),o}finally{f(!1)}},se=s=>{window.dispatchEvent(new CustomEvent("customize-prompt-in-assistant",{detail:{prompt:s}}))},me=async s=>{f(!0);try{const o=await fetch(s);if(!o.ok)throw new Error("Failed to download generated audio");const F=await o.blob();let Q="mp3";const ee=o.headers.get("content-type");ee?.includes("wav")?Q="wav":ee?.includes("flac")?Q="flac":s.includes(".wav")?Q="wav":s.includes(".flac")&&(Q="flac");const Ue=`generated-audio-${Date.now()}.${Q}`,Ce=new FormData;if(Ce.append("file",F,Ue),Ce.append("tags",y.join(",")),Ce.append("description",E),!(await fetch(`${q}/api/v1/resources`,{method:"POST",body:Ce})).ok)throw new Error("Upload failed");await J(),T({title:"Audio saved",description:"Generated audio has been saved to resources"})}catch(o){throw console.error("Failed to save generated audio:",o),T({title:"Save failed",description:o instanceof Error?o.message:"Failed to save generated audio",variant:"destructive"}),o}finally{f(!1)}},Re=s=>{if(A===null)return;const o=s==="next"?A+1:A-1;if(o<0||o>=ae.length)return;const F=ae[o];U(o),P(F)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Resources"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Manage files and resources for your project"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>k(!0),children:[e.jsx(fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Image"})]}),e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>R(!0),children:[e.jsx(fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Audio"})]}),e.jsxs(I,{size:"sm",onClick:()=>S(!v),children:[e.jsx(Xe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Add Resource"})]})]})]}),e.jsx(re,{open:v,onOpenChange:s=>!s&&$(),children:e.jsxs(ie,{className:"max-w-2xl",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Upload Resource"}),e.jsx(Je,{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:Fe,onDrop:Ie,onClick:()=>D.current?.click(),children:[e.jsx(ha,{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:D,type:"file",multiple:!0,className:"hidden",onChange:s=>s.target.files&&r(s.target.files)}),j.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(M,{children:["Selected Files (",j.length,")"]}),e.jsx("div",{className:"border rounded-lg p-3 max-h-40 overflow-y-auto space-y-2",children:j.map((s,o)=>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:()=>ye(o),className:"h-6 w-6 p-0 ml-2",children:e.jsx(Qe,{className:"h-3 w-3"})})]},o))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"tags",children:"Tags"}),e.jsx(ke,{id:"tags",placeholder:"Type a tag and press Enter",value:x,onChange:s=>w(s.target.value),onKeyDown:z}),y.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:y.map(s=>e.jsxs(ge,{variant:"secondary",className:"text-xs",children:[s,e.jsx("button",{type:"button",onClick:()=>K(s),className:"ml-1 hover:text-destructive",children:"×"})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{htmlFor:"description",children:"Description"}),e.jsx(pe,{id:"description",placeholder:"Brief description of this resource...",value:E,onChange:s=>C(s.target.value),rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(I,{variant:"outline",onClick:$,disabled:u,children:"Cancel"}),e.jsx(I,{onClick:Z,disabled:j.length===0||u,children:u?"Uploading...":`Upload ${j.length>0?`(${j.length})`:""}`})]})]})]})}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs("div",{className:"relative flex-1 w-full",children:[e.jsx(Zs,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ke,{placeholder:"Search resources...",value:m,onChange:s=>p(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,o)=>e.jsxs(De,{className:"animate-pulse",children:[e.jsxs(qe,{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(Te,{children:e.jsx("div",{className:"h-20 bg-muted rounded"})})]},o)):ae.length>0?ae.map(s=>e.jsxs(De,{className:"hover:shadow-lg hover:bg-muted transition-all cursor-pointer",onClick:o=>t(s,o),children:[e.jsxs(qe,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[be(s.type,s.name),e.jsx(Ys,{className:"text-sm font-medium truncate",children:s.name})]}),e.jsxs(Js,{className:"text-xs",children:[Ne(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:o=>{o.stopPropagation(),we(s)},title:"Copy path to clipboard",children:e.jsx(gs,{className:"h-3 w-3"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:o=>{o.stopPropagation(),H(s)},children:e.jsx(Ae,{className:"h-3 w-3"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:o=>{o.stopPropagation(),b(s)},children:e.jsx(Qe,{className:"h-3 w-3"})})]})]}),e.jsxs(Te,{className:"pt-0",children:[e.jsx("div",{className:"mb-3",children:Se(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(o=>e.jsx(ge,{variant:"secondary",className:"text-xs",children:o},o))})]})]},s.id)):e.jsx("div",{className:"col-span-full",children:e.jsx(De,{children:e.jsxs(Te,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Hs,{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:()=>S(!0),children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),"Add First Resource"]})]})})})}),u&&e.jsx("div",{className:"fixed bottom-4 right-4 bg-background border rounded-lg shadow-lg p-4",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),e.jsx("span",{className:"text-sm",children:"Uploading files..."})]})}),e.jsx(ja,{open:G,onOpenChange:k,onSave:te,onCustomizeInAssistant:se}),e.jsx(La,{open:N,onOpenChange:R,onSave:me}),e.jsx(Ka,{open:!!d,onOpenChange:s=>{s||P(null),s||U(null)},resource:d,onCopyPath:we,onDownload:H,onNavigate:Re,canNavigatePrev:A!==null&&A>0,canNavigateNext:A!==null&&A<ae.length-1}),e.jsx(re,{open:!!g,onOpenChange:s=>!s&&b(null),children:e.jsxs(ie,{className:"max-w-md",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Delete Resource"}),e.jsxs(Je,{children:["Are you sure you want to delete ",e.jsx("strong",{children:g?.name}),"? This action cannot be undone."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(I,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(I,{variant:"destructive",onClick:_e,children:"Delete"})]})]})})]})}export{Za as default};