1import{e as o,P as C,f as u,j as e,B as x,L as k,N as w,au as q,r as F,K as y,t as m,k as f,i as P,q as N,S as b,aE as S}from"./index-DHwBXtP2.js";import{l as L}from"./video-library.functions-DVDYpHc9.js";import{l as _,g as E,s as K}from"./organic-cover.functions-l77Pu52U.js";import{I as Q}from"./image-OdvWkqq2.js";function V(){const i=o(C),r=o(L),{data:c}=u({queryKey:["workspaces"],queryFn:()=>i({})}),a=c?.[0],t=u({queryKey:["cover-videos",a?.id],queryFn:()=>r({data:{workspaceId:a.id,status:"active"}}),enabled:!!a?.id});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Cover Studio"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-2xl",children:"Every reel needs a scroll-stopping cover. Generate variants, preview them, then activate the winner â the active cover flows into the Instagram publish queue automatically."})]}),e.jsx(x,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(k,{to:"/organic",children:"â Back to Matrix"})})]}),!a||t.isLoading?e.jsx(w,{className:"h-64 w-full"}):t.error?e.jsx("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-6 text-sm text-destructive",children:t.error.message}):t.data?.length?e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:t.data.map(l=>e.jsx(B,{workspaceId:a.id,video:l},l.id))}):e.jsx("div",{className:"rounded-lg border p-8 text-center text-sm text-muted-foreground",children:"No approved renders yet. Approve a render in the gallery and it will show up here for cover generation."})]})}function B({workspaceId:i,video:r}){const c=q(),a=o(_),t=o(E),l=o(K),v=u({queryKey:["organic-covers",r.id],queryFn:()=>a({data:{workspaceId:i,videoLibraryId:r.id}})}),[d,h]=F.useState(""),p=()=>{c.invalidateQueries({queryKey:["organic-covers",r.id]}),c.invalidateQueries({queryKey:["cover-videos",i]})},n=y({mutationFn:s=>t({data:{workspaceId:i,videoLibraryId:r.id,customPrompt:s?d:null}}),onSuccess:()=>{m.success("Cover generated"),h(""),p()},onError:s=>m.error(s.message)}),g=y({mutationFn:s=>l({data:{workspaceId:i,coverId:s}}),onSuccess:()=>{m.success("Set as active cover"),p()},onError:s=>m.error(s.message)}),j=v.data?.covers??[];return e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[r.thumbnail_url?e.jsx("img",{src:r.thumbnail_url,alt:"",className:"h-20 w-14 object-cover rounded border shrink-0"}):e.jsx("div",{className:"h-20 w-14 rounded border bg-muted flex items-center justify-center shrink-0",children:e.jsx(Q,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium line-clamp-2",children:r.script_text??"(untitled render)"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 flex-wrap text-[10px]",children:[r.aspect&&e.jsx(f,{variant:"secondary",children:r.aspect}),r.hook_type&&e.jsx(f,{variant:"secondary",children:r.hook_type})]})]})]}),v.isLoading?e.jsx(w,{className:"h-24 w-full"}):j.length===0?e.jsx("div",{className:"text-xs text-muted-foreground",children:"No covers yet."}):e.jsx("div",{className:"grid grid-cols-3 gap-2",children:j.map(s=>e.jsxs("button",{onClick:()=>g.mutate(s.id),disabled:g.isPending,className:`relative rounded border overflow-hidden aspect-[9/16] group ${s.is_active?"ring-2 ring-primary border-primary":"hover:border-primary/50"}`,children:[e.jsx("img",{src:s.image_url,alt:"",className:"h-full w-full object-cover"}),s.is_active&&e.jsx("div",{className:"absolute top-1 right-1 bg-primary text-primary-foreground rounded-full p-0.5",children:e.jsx(P,{className:"h-3 w-3"})})]},s.id))}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs(x,{size:"sm",variant:"outline",className:"w-full",disabled:n.isPending,onClick:()=>n.mutate(!1),children:[n.isPending&&!d?e.jsx(N,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):e.jsx(b,{className:"h-3.5 w-3.5 mr-1.5"}),"Generate from script"]}),e.jsx(S,{placeholder:"â¦or describe a custom cover (optional)",value:d,onChange:s=>h(s.target.value),rows:2,className:"text-xs"}),d.trim().length>=4&&e.jsxs(x,{size:"sm",className:"w-full",disabled:n.isPending,onClick:()=>n.mutate(!0),children:[n.isPending?e.jsx(N,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}):e.jsx(b,{className:"h-3.5 w-3.5 mr-1.5"}),"Generate from prompt"]})]})]})}export{V as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.