1import{j as e,m as d,A as Q}from"./vendor-ui-BRVg3_iW.js";import{d as X,r as o}from"./vendor-react-fhnP-ZxB.js";import{S as A,_ as P,j as q,as as J,az as N,x as l,a$ as M,ae as Z,E as ee,aX as T,C as re,$ as ae,o as j,b8 as te}from"./index-BTZS4ZAF.js";import{G as se}from"./generate-button-DIINowSl.js";import{T as ie}from"./textarea-D-Y40bXc.js";import{u as oe,I as de,a as ne}from"./ImageUploadSlot-uKa_fttQ.js";import{C as O}from"./clapperboard-CiDPoDpi.js";import"./vendor-three-BixXOMS4.js";import"./vendor-charts-CM-rxR9X.js";import"./vendor-radix-B2hiDlNL.js";import"./vendor-query-fmpM_ONB.js";import"./vendor-supabase-BDcQUG0T.js";import"./vendor-date-D8Ds2zcx.js";import"./label-BPIIQwcF.js";import"./AssetPickerModal-dCg4wh70.js";import"./scroll-area-DqwOcre8.js";import"./tabs-B-u7iS49.js";import"./heart-CZ4amK0d.js";import"./upload-blZ-ZbK1.js";import"./pickedAssetToFile-DO1Aqj9f.js";function ce({script:a,onCopy:t,copied:g}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card/50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border/30 bg-card/80",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4 text-primary"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Generated Script"})]}),e.jsx(P,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2.5 text-xs gap-1.5 hover:bg-primary/10",children:g?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"h-3.5 w-3.5 text-green-500"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"h-3.5 w-3.5"}),"Copy All"]})})]}),e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsxs(d.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:.1},children:[e.jsx(v,{label:"Hook",accent:!0}),e.jsx("p",{className:"text-sm bg-primary/8 border border-primary/15 p-3.5 rounded-lg font-medium leading-relaxed",children:a.hook})]}),e.jsxs(d.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:.2},children:[e.jsx(v,{label:"Script"}),e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed text-foreground/85",children:a.script})]}),e.jsxs(d.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:.3},children:[e.jsx(v,{label:"Call to Action",accent:!0}),e.jsx("p",{className:"text-sm bg-primary/8 border border-primary/15 p-3.5 rounded-lg font-medium leading-relaxed",children:a.cta})]})]})]}),e.jsxs(d.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.4},className:"rounded-xl border border-border/50 bg-card/50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border/30 bg-card/80",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-4 w-4 text-primary"}),e.jsx("h3",{className:"text-sm font-semibold",children:"Storyboard"})]}),e.jsxs(N,{className:"bg-primary/10 text-primary border-primary/20 text-[10px] font-semibold",children:[a.storyboard.length," shots"]})]}),e.jsx("div",{className:"p-4 space-y-2",children:a.storyboard.map((n,s)=>e.jsxs(d.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.45+s*.05},className:l("flex gap-3 p-3 rounded-lg transition-colors","bg-muted/20 hover:bg-muted/40 border border-transparent hover:border-border/30"),children:[e.jsx("div",{className:"flex-shrink-0 w-7 h-7 rounded-full bg-gradient-to-br from-primary to-primary/70 text-primary-foreground flex items-center justify-center text-xs font-bold",children:s+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("span",{className:"font-medium text-xs truncate",children:n.shot}),e.jsx("span",{className:"text-[9px] text-muted-foreground px-1.5 py-0.5 bg-background/80 border border-border/40 rounded-full shrink-0",children:n.duration})]}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:n.description})]})]},s))})]})]})}function v({label:a,accent:t}){return e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:l("text-[10px] font-bold uppercase tracking-widest",t?"text-primary":"text-muted-foreground"),children:a}),e.jsx("div",{className:l("flex-1 h-px",t?"bg-primary/15":"bg-border/50")})]})}const $="generate-video-script",le=[{id:"ugc",name:"UGC / Testimonial",emoji:"ð¤"},{id:"product-demo",name:"Product Demo",emoji:"ð¦"},{id:"educational",name:"Educational",emoji:"ð"},{id:"ad",name:"Ad / Commercial",emoji:"ðº"},{id:"unboxing",name:"Unboxing",emoji:"ð"},{id:"before-after",name:"Before & After",emoji:"â¨"}],me=[{id:"15",name:"15s",label:"Quick"},{id:"30",name:"30s",label:"Standard"},{id:"60",name:"60s",label:"Detailed"},{id:"90",name:"90s",label:"In-depth"}
1];function Oe(){const a=X(),{toast:t}=M(),[g,n]=o.useState(!1),[s,D]=o.useState("ugc"),[m,G]=o.useState("30"),[u,U]=o.useState(""),[w,R]=o.useState(""),[i,B]=o.useState(null),[E,C]=o.useState(!1),{handleUpload:L,handleClear:V,getImage:k}=oe(),{balance:y,deductCredits:z,refundCredits:K,getToolCost:F}=Z(),f=F($),H=y>=f,W=async()=>{var c,b;if(!u.trim()){t({title:"Please enter a topic",variant:"destructive"});return}const r=await z($);if(!r.success){t({title:"Insufficient credits",description:`You need ${f} credits but only have ${y}.`,variant:"destructive"});return}n(!0);try{let p=null;const S=k("product");S.file&&(p=await ne(j,S.file,"video-script"));const{data:x,error:I}=await j.functions.invoke("generate-video-script",{body:{videoType:s,duration:m,topic:u,keyPoints:w,productImageUrl:p}});if(I)throw I;B(x.script);const{data:h}=await j.auth.getSession();if((b=(c=h==null?void 0:h.session)==null?void 0:c.user)!=null&&b.id&&x.script){const _=`HOOK: 2${x.script.hook} 3 4SCRIPT: 5${x.script.script} 6 7CTA: 8${x.script.cta}`;te({userId:h.session.user.id,name:`${s} Script (${m}s) - ${new Date().toLocaleDateString()}`,content:_,type:"script",tags:["video-script",s],metadata:{videoType:s,duration:m,topic:u}})}}catch(p){console.error("Error generating script:",p),t({title:"Generation failed",description:p.message||"Please try again",variant:"destructive"}),r.transactionId&&await K(r.transactionId)}finally{n(!1)}},Y=async()=>{if(!i)return;const r=`HOOK: 9${i.hook} 10 11SCRIPT: 12${i.script} 13 14CTA: 15${i.cta} 16 17STORYBOARD: 18${i.storyboard.map((c,b)=>`${b+1}. [${c.duration}] ${c.shot}: ${c.description}`).join(` 19`)}`;await navigator.clipboard.writeText(r),C(!0),t({title:"Copied to clipboard!"}),setTimeout(()=>C(!1),2e3)};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"border-b border-border/50 bg-card/30 backdrop-blur-sm sticky top-0 z-10",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-4 sm:px-6 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(P,{variant:"ghost",size:"icon",onClick:()=>a("/dashboard"),className:"shrink-0 h-8 w-8 hover:bg-primary/10",children:e.jsx(ee,{className:"h-4 w-4"})}),e.jsx("div",{className:"h-9 w-9 rounded-lg bg-gradient-to-br from-primary/20 to-primary/5 border border-primary/20 flex items-center justify-center",children:e.jsx(T,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-base font-bold text-foreground leading-tight",children:"Video Script Writer"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"AI-powered scripts with storyboards"})]}),e.jsxs(N,{variant:"outline",className:"ml-auto text-[10px] border-primary/30 text-primary gap-1",children:[e.jsx(A,{className:"h-3 w-3"}),"AI Enhanced"]})]})})}),e.jsx("div",{className:"max-w-[1400px] mx-auto px-4 sm:px-6 py-5",children:e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[420px,1fr]",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card/50 p-4 space-y-3",children:[e.jsxs("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[e.jsx(O,{className:"h-3.5 w-3.5 text-primary"}),"Video Type"]}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:le.map(r=>e.jsxs("button",{onClick:()=>D(r.id),className:l("px-2.5 py-2 rounded-lg border text-left transition-all text-[11px] font-medium",s===r.id?"border-primary bg-primary/10 text-primary shadow-sm shadow-primary/10":"border-border/40 hover:border-primary/30 hover:bg-muted/50 text-muted-foreground"),children:[e.jsx("span",{className:"mr-1",children:r.emoji}),r.name]},r.id))})]}),e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card/50 p-4 space-y-3",children:[e.jsxs("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[e.jsx(re,{className:"h-3.5 w-3.5 text-primary"}),"Duration"]}),e.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:me.map(r=>e.jsxs("button",{onClick:()=>G(r.id),className:l("py-2.5 rounded-lg border text-center transition-all",m===r.id?"border-primary bg-primary/10 shadow-sm shadow-primary/10":"border-border/40 hover:border-primary/30 hover:bg-muted/50"),children:[e.jsx("span",{className:l("text-sm font-bold block",m===r.id?"text-primary":"text-foreground"),children:r.name}),e.jsx("span",{className:"text-[9px] text-muted-foreground",children:r.label})]},r.id))})]}),e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card/50 p-4 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:["Product / Topic ",e.jsx("span",{className:"text-destructive",children:"*"})]}
19),e.jsx(ae,{placeholder:"e.g., Wireless earbuds with noise cancellation",value:u,onChange:r=>U(r.target.value),className:"h-9 text-sm bg-background/50 border-border/50 focus:border-primary/40 focus:ring-1 focus:ring-primary/15"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Key Points"}),e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:"Optional"})]}),e.jsx(ie,{placeholder:"e.g., 40-hour battery, premium sound, comfortable fit...",value:w,onChange:r=>R(r.target.value),rows:2,className:"text-sm bg-background/50 border-border/50 focus:border-primary/40 focus:ring-1 focus:ring-primary/15 resize-none min-h-[60px]"})]})]}),e.jsxs("div",{className:"rounded-xl border border-dashed border-primary/20 bg-primary/[0.02] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Product Image"}),e.jsx(N,{variant:"outline",className:"text-[9px] px-1.5 py-0 h-4 border-primary/20 text-primary/70",children:"Optional"})]}),e.jsx(de,{id:"product-image",label:"Product Photo",tooltip:"Upload for more accurate visual descriptions",preview:k("product").preview,onUpload:L("product"),onClear:V("product"),aspectRatio:"video",placeholder:"Drop image here"})]}),e.jsx(se,{onClick:W,isLoading:g,canAfford:H,creditCost:f,creditBalance:y,label:"Generate Script",className:"w-full h-11 text-sm font-semibold rounded-xl"})]}),e.jsx(Q,{mode:"wait",children:i?e.jsx(d.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.3},children:e.jsx(ce,{script:i,onCopy:Y,copied:E})},"result"):e.jsx(d.div,{initial:{opacity:0}
19,animate:{opacity:1},className:"flex items-center justify-center min-h-[500px]",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"mx-auto h-16 w-16 rounded-2xl bg-gradient-to-br from-primary/15 to-primary/5 border border-primary/20 flex items-center justify-center",children:e.jsx(T,{className:"h-7 w-7 text-primary/50"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-foreground/80",children:"Your Script Awaits"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 max-w-[240px] mx-auto leading-relaxed",children:"Fill in the details and generate your AI-powered video script with storyboard"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-muted-foreground/50",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary/40 animate-pulse"}),"Powered by AI"]})]})},"empty")})]})})]})}export{Oe as default};
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.