PageSourceSearch

https://vidacious.ai/assets/ContextReplyWizard-B1G-B0PT.js

js vidacious.ai collected 2026-10-05 13:15:48 UTC 8,824 bytes, 1 lines download raw bytes

1import{r as s,j as e}from"./vendor-ui-Cp0o_ERz.js";import{b as I,L as w}from"./vendor-react-DblKtrgV.js";import{A as E}from"./AppLayout-aFpeq7cF.js";import{s as B,u as N,k as f,m as M,B as y,L as z,h as C,bL as A,b_ as F,ax as G,aK as O,ao as U,E as P,n as W,cU as k,j as q}from"./index-U2qI6hth.js";import{T as _}from"./textarea-CJ3wtdnc.js";import{L as D}from"./linkedin-DMSC3g_Z.js";import{M as K}from"./message-square-DuUPZRrh.js";import"./vendor-motion-P7V77m0j.js";import"./vendor-charts-BTyV52R2.js";import"./vendor-query-Bv5ntzP6.js";import"./vendor-supabase-B0Jha54I.js";function V(){const[t,a]=s.useState(!1),[i,u]=s.useState(null),[r,n]=s.useState(null),o=s.useCallback(async(m,l="public_reply",c="en")=>{a(!0),n(null);try{const{data:p,error:x}=await B.functions.invoke("context-reply-ingest",{body:{input:m,output_type:l,language:c}});if(x){let h=x.message||"Failed to generate script";const g=x?.context;if(g instanceof Response)try{h=(await g.json()).error||h}catch{}throw new Error(h)}return p?.blocked?(n(p.error||"Script blocked by content policy"),N.error("Script blocked",{description:p.safety?.reasoning||"Content policy violation"}),null):(u(p),p)}catch(p){const x=p instanceof Error?p.message:"Unknown error";return n(x),N.error("Failed to generate reply script",{description:x}),null}finally{a(!1)}},[]),d=s.useCallback(()=>{u(null),n(null)},[]);return{isLoading:t,result:i,error:r,ingest:o,reset:d}}const S=[{value:"public_reply",label:"Public Reply",description:"Conversational response"},{value:"email_response",label:"Email Response",description:"Professional reply"},{value:"sales_intro",label:"Sales Intro",description:"Benefit-led outreach"},{value:"endorsement",label:"Endorsement",description:"Enthusiastic support"}];function Y(t){const a=t.trim().toLowerCase();return a.includes("twitter.com")||a.includes("x.com")?{type:"tweet",icon:e.jsx(A,{className:"w-3 h-3"}),label:"Tweet"}:a.includes("linkedin.com")?{type:"linkedin",icon:e.jsx(D,{className:"w-3 h-3"}),label:"LinkedIn"}:a.startsWith("http://")||a.startsWith("https://")?{type:"website",icon:e.jsx(F,{className:"w-3 h-3"}),label:"Website"}:t.trim().length>0?{type:"raw_text",icon:e.jsx(K,{className:"w-3 h-3"}),label:"Text"}:{type:"none",icon:e.jsx(G,{className:"w-3 h-3"}),label:""}}function $({onSubmit:t,isLoading:a}){const[i,u]=s.useState(""),[r,n]=s.useState("public_reply"),[o,d]=s.useState(!1),m=s.useMemo(()=>Y(i),[i]),l=i.trim().length>=5&&!a;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{children:e.jsx(_,{value:i,onChange:c=>u(c.target.value),placeholder:"Paste a tweet URL, LinkedIn post, website link, or type/paste any text you want to reply to...",className:"min-h-[120px] resize-none pr-4 text-base",maxLength:5e3,disabled:a})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[m.type!=="none"&&e.jsxs(f,{variant:"secondary",className:"gap-1 text-xs",children:[m.icon,m.label]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.length>0?`${i.length} / 5000 characters`:"Min 5 characters"})]}),e.jsxs("button",{type:"button",onClick:()=>d(!o),className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:["Reply type: ",e.jsx("span",{className:"font-medium text-foreground",children:S.find(c=>c.value===r)?.label})]})]}),o&&e.jsx("div",{className:"grid grid-cols-2 gap-2",children:S.map(c=>e.jsxs("button",{type:"button",onClick:()=>{n(c.value),d(!1)},className:M("rounded-lg border p-3 text-left transition-colors",r===c.value?"border-primary bg-primary/5":"border-border hover:border-primary/40"),children:[e.jsx("span",{className:"text-sm font-medium",children:c.label}),e.jsx("span",{className:"block text-xs text-muted-foreground mt-0.5",children:c.description})]},c.value))}),e.jsx(y,{onClick:()=>t(i,r),disabled:!l,className:"w-full gap-2",size:"lg",children:a?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 animate-spin"}),"Generating Reply Script..."]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"w-4 h-4"}),"Generate Reply Script"]})})]})}function H({result:t,onGenerate:a,onRegenerate:i,onBack:u,isRegenerating:r}){const[n,o]=s.useState(t.script);s.useEffect(()=>{o(t.script)},[t.script]);const d=s.useMemo(()=>
1n.trim().split(/\s+/).filter(Boolean).length,[n]),m=s.useMemo(()=>Math.round(d/2.5),[d]),l=t.metadata;return e.jsxs("div",{className:"space-y-4",children:[(l.source_title||l.source_author||l.source_description)&&e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Replying to"}),l.source_title&&e.jsx("p",{className:"text-sm font-medium truncate",children:l.source_title}),l.source_author&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.source_author}),l.source_description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:l.source_description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{variant:"outline",className:"capitalize",children:t.detected_intent}),e.jsx(f,{variant:"secondary",children:t.output_type.replace("_"," ")}),t.safety.riskScore>20&&e.jsxs(f,{variant:"destructive",className:"text-xs",children:["Risk: ",t.safety.riskScore]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-medium",children:"Reply Script"}),e.jsxs(y,{variant:"ghost",size:"sm",onClick:i,disabled:r,className:"gap-1.5 text-xs",children:[e.jsx(O,{className:"w-3 h-3"}),"Regenerate"]})]}),e.jsx(_,{value:n,onChange:c=>o(c.target.value),className:"min-h-[140px] resize-none text-base leading-relaxed",disabled:r})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(U,{className:"w-3 h-3"}),d," words"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(P,{className:"w-3 h-3"}),"~",m,"s spoken"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{variant:"outline",onClick:u,className:"flex-1",children:"Back"}),e.jsxs(y,{onClick:()=>a(n),disabled:n.trim().length<10||r,className:"flex-1 gap-2",children:[e.jsx(C,{className:"w-4 h-4"}),"Continue to Video"]})]})]})}function ce(){const{user:t,session:a}=W(),i=I(),{isLoading:u,result:r,error:n,ingest:o}=V(),[d,m]=s.useState("input"),[l,c]=s.useState(!1),[p,x]=s.useState(""),[h,g]=s.useState("public_reply"),v=s.useCallback(async(b,j)=>{x(b),g(j),await o(b,j)&&m("review")},[o]),R=s.useCallback(async()=>{await o(p,h)},[o,p,h]),L=s.useCallback(()=>{m("input")},[]),T=s.useCallback(async b=>{if(!(!r||!t||!a))try{sessionStorage.setItem("context_reply_script",b),sessionStorage.setItem("context_reply_session_id",r.session_id),N.success("Script ready! Select an actor and generate your video."),i("/create")}catch(j){console.error("Failed to pass script:",j),N.error("Failed to prepare script")}},[r,t,a,i]);return t?e.jsx(E,{children:e.jsxs("div",{className:"max-w-xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx(y,{variant:"ghost",size:"icon",asChild:!0,className:"shrink-0",children:e.jsx(w,{to:"/dashboard",children:e.jsx(q,{className:"w-4 h-4"})})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(k,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold leading-tight",children:"Context Reply"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"AI video reply from any content"})]}),e.jsx(f,{variant:"outline",className:"bg-primary/10 text-primary border-primary/30 text-[10px] ml-1",children:"Alpha"})]})]}),n&&d==="input"&&e.jsx("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-3 mb-4",children:e.jsx("p",{className:"text-sm text-destructive",children:n})}),d==="input"&&e.jsx($,{onSubmit:v,isLoading:u}),d==="review"&&r&&e.jsx(H,{result:r,onGenerate:T,onRegenerate:R,onBack:L,isRegenerating:u})]})}):e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[60vh] px-4 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-6",children:e.jsx(k,{className:"w-8 h-8 text-primary"})}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Context Reply"}),e.jsx("p",{className:"text-muted-foreground max-w-md mb-8",children:"Sign in to create AI video replies from any URL or text."}),e.jsx(y,{asChild:!0,children:e.jsx(w,{to:"/auth",children:"Sign In"})})]})}export{ce 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.