PageSourceSearch

https://brandwriter.ai/assets/VideoPreviewPage-D13Yk6tm.js

js brandwriter.ai collected 2026-10-05 14:08:34 UTC 26,617 bytes, 1 lines download raw bytes

1import{u as e,ar as t,bm as i,r as s,b as o,bo as a,bp as r,bq as n,br as l,bs as d,bt as c,bu as p,bb as u,bv as v,j as m,B as _,at as x,aC as g,a_ as h,aL as f,bw as y,bx as j}from"./index-DMmkt1ET.js";import{s as w}from"./creditToast-B3KZbI44.js";import{N as b,R as N}from"./regenerate-modal-DWoWQ2s1.js";import{T as S}from"./translation-modal-DAC4Cm8j.js";import{C as k}from"./ContentDialog-BM1CqYl5.js";import{T as C,a as T,b as E}from"./tabs-FV8LmHAm.js";import{C as I}from"./content-type-modal-DaFYlAZh.js";import{S as O}from"./SafetyNotice-DRQle0wz.js";import{A as D}from"./arrow-left-CvhR_RDz.js";import{A as R}from"./index-D0veQdn4.js";import{G as P}from"./globe-NBeNkQEl.js";import{S as A}from"./square-pen-CvhAuOSy.js";import{D as F}from"./download-ClacPVmK.js";import{C as J}from"./copy-CZXHaBcm.js";import{V as L}from"./video-DR8u-a4q.js";import{C as M}from"./clock-B2NtgCtf.js";import"./upgrade-notification-CgYA8MUu.js";import"./UserProductSelection-DnX4Pctv.js";import"./select-F5q4ZfZ1.js";import"./react-icons.esm-CeBdftn8.js";import"./index-jVOyRz7F.js";import"./index-DPmaI-h8.js";import"./index-r8ssOwms.js";import"./popover-B9-B3hxV.js";import"./lock-DNM1iP7B.js";import"./trash-2-3yJhmYr6.js";import"./save-DB4LBFqB.js";import"./settings-Cf3s6weJ.js";import"./language-selector-MDokYJZJ.js";import"./useOptionsQueries-38HAIZp1.js";import"./user-shop-helpers-DSINuLYe.js";import"./currencies-CW_gu8JS.js";import"./search-Ceake_zw.js";import"./tooltip-Dk25mjAY.js";import"./useCoachmark-BJyqlyht.js";import"./Trans-BKI1-DiJ.js";import"./image-tAh4VnYT.js";import"./type-COsa9J3Q.js";import"./thumbs-up-DfQVIui5.js";import"./label-C-FAycOj.js";const V=({title:e,time:t,content:i})=>m.jsxs("div",{className:"mb-3 p-4 bg-gray-50 rounded-lg",children:[m.jsxs("div",{className:"text-sm text-gray-500 bg-gray-100 rounded-md px-2 py-1 inline-flex items-center",children:[e," ",m.jsx(M,{className:"h-3.5 w-3.5 mr-1"}),m.jsx("span",{children:t})]}),m.jsx("div",{className:"whitespace-pre-line text-gray-700",children:i})]}),q=()=>m.jsxs("div",{className:"space-y-4",children:[m.jsx("div",{className:"h-20 bg-gray-200 rounded-md w-full"}),m.jsxs("div",{className:"space-y-2",children:[m.jsx("div",{className:"h-4 bg-gray-200 rounded w-5/6"}),m.jsx("div",{className:"h-4 bg-gray-200 rounded w-full"}),m.jsx("div",{className:"h-4 bg-gray-200 rounded w-4/6"})]}),m.jsxs("div",{className:"space-y-2 pt-4",children:[m.jsx("div",{className:"h-4 bg-gray-200 rounded w-full"}),m.jsx("div",{className:"h-4 bg-gray-200 rounded w-full"}),m.jsx("div",{className:"h-4 bg-gray-200 rounded w-5/6"}),m.jsx("div",{className:"h-4 bg-gray-200 rounded w-4/6"})]}),m.jsxs("div",{className:"space-y-2 pt-4",children:[m.jsx("div",{className:"h-4 bg-gray-200 rounded w-full"}),m.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4"})]})]}),$=()=>{var M,$,U,B,G,Q,z,K,W,X,Y,Z,H,ee,te,ie,se,oe,ae,re,ne,le,de,ce,pe;const{t:ue}=e(),[,ve]=t(),{id:me}=i(),[_e,xe]=s.useState(""),[ge,he]=s.useState(!1),[fe,ye]=s.useState(""),[je,we]=s.useState({}),[be,Ne]=s.useState(!1),[Se,ke]=s.useState(!1),[Ce,Te]=s.useState(""),[Ee,Ie]=s.useState(null),[Oe,De]=s.useState(null),[Re,Pe]=s.useState(!0),[Ae,Fe]=s.useState(!1),[Je,Le]=s.useState({current:0,max:0}),[Me,Ve]=s.useState(!1);o();const{refreshActivityData:qe}=a(),[$e,Ue]=s.useState(!1),[Be,Ge]=s.useState(!1),[Qe,ze]=s.useState(null),[Ke,We]=s.useState("视频口播"),[Xe,Ye]=s.useState(!1),[Ze,He]=s.useState(!1),[et,tt]=s.useState(!1),[it,st]=s.useState(!1),ot=s.useRef(null),at=s.useRef(new TextDecoder),rt=s.useRef(!1);s.useRef(null);const{data:nt}=r("profile"===(null==(M=null==Ee?void 0:Ee.topic)?void 0:M.topic_type)?"profile_topic_video":"keyword_topic_video",{is_advanced:(null==($=null==Ee?void 0:Ee.script_input_data)?void 0:$.is_advanced)?1:0,video_length:(null==(U=null==Ee?void 0:Ee.script_input_data)?void 0:U.video_length)||"90secs"},{enabled:!!Ee,refetchOnWindowFocus:!1}),lt=n(nt);s.useEffect((()=>{const e=e=>{e.detail&&e.detail.postId&&ve(`/post/preview/${e.detail.postId}`)};return window.addEventListener("postCreated",e),()=>{window.removeEventListener("postCreated",e)}}),[ve]),s.useEffect((()=>{xe(""),he(!1),ye(""),we({}),Ne(!1),ke(!1),Te(""),Ie(null),De(null),Pe(!0),Fe(!1),Le({current:0,max:0}),Ve(!1),Ue(!1),Ge(!1),ze(null),He(!1),st(!1),rt.current=!1}),[me]);const dt=s.useCallback((async()=>{var e,t,i;if(ge)return;if(!me)return void l({title:ue("video_preview.error","Error"),description:ue("video_preview.missing_id","Missing video script ID."),variant:"destructive"});rt.current=!1,he(!0),ke(!1),Te(""),Ne(!1),Fe(!1);let s="";try{const e=parseInt(me,10),t=await d(e);for(;;){const{done:e,value:i}=await t.read();if(e){Ne(!0);break}const o=at.current.decode(i,{stream:!0}).split("\n");for(const t of o)s+=t,ye(s)}}catch(o){console.error("Error generating video script content:",o);403===(null==(e=null==o?void 0:o.response)?void 0:e.status)||403===(null==o?void 0:o.status)||(null==(t=null==o?void 0:o.message)?void 0:t.includes("403"))||(null==(i=null==o?void 0:o.message)?void 0:i.includes("无权访问"))?(tt(!0),ke(!0),Te("Access denied")):(ke(!0),Te(o.message||"Failed to generate video script content"),l({title:ue("video_preview.generation_failed","Content Generation Failed"),description:o.message||ue("video_preview.try_again","Please try again later"),variant:"destructive"}))}finally{await qe(),await c(u),p(u),u.refetchQueries({queryKey:["postDetails",null==Ee?void 0:Ee.post_id]}),he(!1)}}),[me,ue,at,qe]),ct=s.useCallback((async()=>{var e;if(!me)return;const t=parseInt(me,10),i=await v(t);if(!i.status||!(null==(e=i.data)?void 0:e.script))return console.error("Invalid response from API"),!1;const s=i.data.script;if(Ie(s),"draft"===(null==Ee?void 0:Ee.script_status))return Fe(!1),void(rt.current=!1);if("generate_failed"===(null==Ee?void 0:Ee.script_status))return null==Ee||Ee.script_status,Te("Failed to generate content. Please try again."),Fe(!1),rt.current=!1,ke(!0),void ye("");let o=0;Le({current:0,max:20});const a=async()=>{var e,t,i,s,a,r,n,l,d,c,p,u;if(o>=20)return console.warn("Reached maximum polling attempts, using latest available content"),!1;o++,Le({current:o,max:20});
1try{const o=parseInt(me,10),c=await v(o);if(!c.status||!(null==(e=c.data)?void 0:e.script))return console.error("Invalid response from API"),!1;const p=c.data.script;if(Ie(p),xe(p.script_input_data.post_topic||"Video Script"),"draft"===p.script_status){const e={title:p.script_input_data.post_topic||"Video Script",contentType:"video",duration:(null==(t=p.script_input_data)?void 0:t.video_length)||"",framework:p.script_framework||"",tone:(null==(s=null==(i=p.script_input_data)?void 0:i.video_tone)?void 0:s.tone_value)||"",qualityType:(null==(a=p.script_input_data)?void 0:a.is_advanced)?"high":"standard",description:(null==(r=p.script_input_data)?void 0:r.video_user_idea)||"",image:"",timestamp:(new Date).toISOString(),topic:null,video_script_id:p.id,video_script:p};if(De(e),xe(e.title),localStorage.setItem("generated_content",JSON.stringify(e)),p.script_content)try{if("string"==typeof p.script_content)try{const e=JSON.parse(p.script_content);let t="",i={};e.开头||e.核心内容||e.结尾?(i=e,(null==(n=e.开头)?void 0:n.content)&&(t+=e.开头.content+"\n\n"),(null==(l=e.核心内容)?void 0:l.content)&&(t+=e.核心内容.content+"\n\n"),(null==(d=e.结尾)?void 0:d.content)&&(t+=e.结尾.content),t.trim().length>0&&(ye((e=>t.length>e.length||""===e.trim()?t:e)),Object.keys(i).length>0&&we(i))):(t=JSON.stringify(e,null,2),ye(t))}catch(m){console.error("Error parsing script content JSON:",m),p.script_content.trim().length>0&&ye(p.script_content)}else{const e=JSON.stringify(p.script_content,null,2);e.trim().length>0&&ye(e)}}catch(_){console.error("Error parsing updated script content:",_)}return!0}return p.script_status,!1}catch(x){console.error("Error during polling for script details:",x);return(403===(null==(c=null==x?void 0:x.response)?void 0:c.status)||403===(null==x?void 0:x.status)||(null==(p=null==x?void 0:x.message)?void 0:p.includes("403"))||(null==(u=null==x?void 0:x.message)?void 0:u.includes("无权访问")))&&(tt(!0),ke(!0),Te("Access denied")),!1}};let r=!1;for(;!r&&o<20;)r=await a(),r||await new Promise((e=>setTimeout(e,2e3)));Fe(!1),rt.current=!1,r||l({title:ue("video_preview.polling_timeout","Processing Timeout"),description:ue("video_preview.content_may_not_be_complete","The script processing took longer than expected. Content may not be complete."),variant:"destructive"})}),[me,ue,Ee]);s.useEffect((()=>{if(be&&fe&&!Re){if("draft"===(null==Ee?void 0:Ee.script_status))return;if(rt.current)return;const e=setTimeout((()=>{rt.current=!0,Fe(!0),ct()}),1e3);return()=>clearTimeout(e)}}),[be,fe,Re,ct,Ee]),s.useEffect((()=>(rt.current=!1,be||(rt.current=!1),()=>{rt.current=!1})),[be]),s.useEffect((()=>{me||(console.error("VideoPreviewPage: Missing ID parameter in URL"),l({title:ue("video_preview.error","Error"),description:ue("video_preview.missing_id","Missing video script ID. Redirecting to home page."),variant:"destructive"}),setTimeout((()=>ve("/")),1500))}),[me,ve,ue]),s.useEffect((()=>{(async()=>{var e,t,i,s,o,a,r,n,l,d,c,p,u;if(me){Pe(!0);try{const c=parseInt(me,10),p=await v(c);if(p.status&&(null==(e=p.data)?void 0:e.script)){const e=p.data.script;if(Ie(e),e.script_content){e.script_status;try{if("string"==typeof e.script_content)try{const o=JSON.parse(e.script_content);let a="";o.开头||o.核心内容||o.结尾?(we(o),(null==(t=o.开头)?void 0:t.content)&&(a+=o.开头.content+"\n\n"),(null==(i=o.核心内容)?void 0:i.content)&&(a+=o.核心内容.content+"\n\n"),(null==(s=o.结尾)?void 0:s.content)&&(a+=o.结尾.content)):a=JSON.stringify(o,null,2),ye(a),"draft"===e.script_status&&Ne(!0)}catch(m){ye(e.script_content),"draft"===e.script_status&&Ne(!0)}else ye(JSON.stringify(e.script_content,null,2)),"draft"===e.script_status&&Ne(!0)}catch(_){console.error("Error parsing script content:",_),ke(!0),Te("Failed to parse video script content")}}else"draft"===e.script_status&&Ne(!0);const c={title:(null==(o=e.script_input_data)?void 0:o.post_topic)||"Video Script",contentType:"video",duration:(null==(a=e.script_input_data)?void 0:a.video_length)||"",framework:e.script_framework||"",tone:(null==(n=null==(r=e.script_input_data)?void 0:r.video_tone)?void 0:n.tone_value)||"",qualityType:(null==(l=e.script_input_data)?void 0:l.is_advanced)?"high":"standard",description:(null==(d=e.script_input_data)?void 0:d.video_user_idea)||"",image:"",timestamp:(new Date).toISOString(),topic:null,video_script_id:e.id,video_script:e};De(c),xe(c.title),localStorage.setItem("generated_content",JSON.stringify(c))}}catch(x){console.error("Error fetching video script details:",x);(403===(null==(c=null==x?void 0:x.response)?void 0:c.status)||403===(null==x?void 0:x.status)||(null==(p=null==x?void 0:x.message)?void 0:p.includes("403"))||(null==(u=null==x?void 0:x.message)?void 0:u.includes("无权访问")))&&(tt(!0),ke(!0),Te("Access denied"))}finally{Pe(!1)}}})()}),[me]),s.useEffect((()=>
1{if(!Re&&!fe&&!be&&me&&!et&&!Se){const e=setTimeout((()=>{dt()}),500);return()=>clearTimeout(e)}}),[me,Re,fe,be,dt,et,Se]);function pt(){const e=document.createElement("textarea");e.value=fe,e.style.top="0",e.style.left="0",e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select();try{document.execCommand("copy"),l({title:ue("video_preview.copied","Copied to clipboard"),description:ue("video_preview.copy_success","Video script content has been copied to your clipboard")})}catch(t){console.error("Fallback copy failed:",t),l({title:ue("video_preview.copy_failed","Copy failed"),description:ue("video_preview.copy_error","Could not copy to clipboard"),variant:"destructive"})}document.body.removeChild(e)}const ut=e=>{switch(e){case"开头":return ue("video_editor.sections.intro.title","Introduction");case"核心内容":return ue("video_editor.sections.core.title","Core Content");case"结尾":return ue("video_editor.sections.outro.title","Conclusion");default:return e}};return et||Se&&!fe?m.jsx("div",{className:"min-h-screen bg-gray-50",children:m.jsx("div",{className:"flex",children:m.jsx("div",{className:"flex-1 p-6 mx-auto max-w-4xl",children:m.jsx("div",{className:"flex items-center justify-center h-[80vh]",children:m.jsxs("div",{className:"text-center p-6 bg-white rounded-lg shadow-sm max-w-md",children:[m.jsx("div",{className:"mb-4 text-5xl text-red-500",children:et?"🔒":"⚠️"}),m.jsx("h2",{className:"text-xl font-bold mb-2",children:et?ue("common.access_denied","访问被拒绝"):ue("common.error","Error")}),m.jsx("p",{className:"text-gray-600 mb-4",children:et?ue("common.access_denied_description","您没有权限访问此内容"):Ce}),m.jsx("button",{onClick:()=>{window.location.href="/topics"},className:"px-4 py-2 bg-purple-600 text-white rounded-md hover:bg-purple-700 transition",children:et?ue("common.back_to_dashboard","返回控制台"):ue("common.try_again","Try Again")})]})})})})}):m.jsxs("div",{className:"flex h-[calc(100vh-64px)]",children:[m.jsx("div",{className:"flex-1 flex flex-col h-full",children:m.jsx("div",{className:"flex-1 overflow-y-auto flex justify-center",children:m.jsx("div",{className:"w-full max-w-5xl flex flex-col",children:m.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden h-full pb-16",children:[m.jsx("div",{className:"pb-4 pt-4 px-4 relative",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{onClick:()=>{ve("/topics")},className:"text-gray-500 hover:text-gray-700 cursor-pointer",children:m.jsx(D,{className:"h-5 w-5"})}),m.jsx(C,{defaultValue:"视频口播",onValueChange:e=>{We(e),"帖文"===e&&Ee&&(Ee.topic.has_post?ve(`/post/preview/${Ee.post_id}`):Ye(!0))},className:"w-auto mb-2",children:m.jsxs(T,{className:"h-9",children:[m.jsx(E,{disabled:Re||ge||Ae,value:"帖文",className:"px-4",children:ue("video_editor.content_type.post","帖文")}),m.jsx(E,{disabled:Re||ge||Ae,value:"视频口播",className:"px-4 bg-purple-100 text-purple-800 data-[state=active]:bg-purple-600 data-[state=active]:text-white",children:ue("video_editor.content_type.video_script","视频口播")})]})}),m.jsxs(_,{variant:"ghost",className:"flex items-center gap-1 relative group ml-auto text-xs py-1 bg-gray-100",onClick:()=>{Ue(!0),f("video_preview_regenerate_btn")},disabled:Me||ge||Ae||!fe,children:[m.jsx(x,{className:"h-2 w-2"}),m.jsx("span",{className:"hidden md:block",children:ue("video_preview.regenerate","Regenerate")}),m.jsx("span",{className:"invisible group-hover:visible absolute -top-10 left-0 px-3 py-1 bg-gray-900 text-white text-xs rounded whitespace-nowrap",children:ue("post_preview.regenerate_hint","对当前版本不满意?试试不同的表达方式!")})]})]})}),m.jsxs("div",{className:"px-4  relative ",children:[m.jsx("div",{className:"text-lg",children:_e}),m.jsxs("div",{className:"relative absolute top-0 md:-top-10 right-0",children:[m.jsx("div",{className:"flex items-center justify-end",children:m.jsx("div",{className:"rounded-md p-1 hover:bg-gray-100 transition-colors focus:outline-none cursor-pointer",onMouseEnter:()=>st(!0),onMouseLeave:()=>st(!1),children:m.jsx("div",{className:"flex items-center gap-1",children:m.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[m.jsx(b,{className:"h-4 w-4"}),ue("common.info","信息")]})})})}),m.jsx("div",{className:"absolute top-full right-0 bg-white border rounded-b-lg shadow-lg transition-all duration-300 z-50 "+(it?"opacity-100 visible":"opacity-0 invisible"),onMouseEnter:()=>st(!0),onMouseLeave:()=>st(!1),children:m.jsx("div",{className:"p-4",children:m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[m.jsxs("div",{className:"space-y-3 bg-gray-50 p-4 rounded-lg border overflow-y-auto",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-sm text-gray-600",children:ue("post_preview.framework","文案框架")}),m.jsx(g,{variant:"outline",className:"bg-gray-100 text-gray-700",children:(null==Ee?void 0:Ee.framework_label)||"-"})]}),m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-sm text-gray-600",children:ue("post_preview.duration","时长")}),m.jsx(g,{variant:"outline",className:"bg-gray-100 text-gray-700",children:(null==(vt=null==Ee?void 0:Ee.script_input_data)?void 0:vt.video_length)||ue("common.duration","Duration")})]}),m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("span",{className:"text-sm text-gray-600",children:ue("post_preview.tone","语调风格")}),m.jsx(g,{variant:"outline",className:"bg-gray-100 text-gray-700",children:(null==Ee?void 0:Ee.tone_label)||"-"})]})]}),m.jsxs("div",{className:"space-y-3 bg-gray-50 p-4 rounded-lg border overflow-y-auto",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("span",{className:"text-sm text-gray-600",children:ue("post_preview.product","产品")}),m.jsx("div",{className:"bg-white p-2 rounded border text-sm opacity-50 max-h-[200px] overflow-y-auto",children:(null==(B=null==Ee?void 0:Ee.product)?void 0:B.product_name)||"-"})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("span",{className:"text-sm text-gray-600",children:ue("post_preview.user_idea","想法")}),m.jsx("div",{className:"bg-white p-2 rounded border text-sm opacity-50 max-h-[200px] overflow-y-auto",children:(null==(G=null==Ee?void 0:Ee.script_input_data)?void 0:G.video_user_idea)||"-"})]})]})]})})})]})]}),m.jsx("div",{className:"flex-1 px-2 overflow-y-auto min-h-[350px]",ref:ot,children:Re?m.jsx(q,{}):ge||Ae?m.jsxs("div",{className:"flex flex-col items-center justify-center py-4",children:[m.jsxs("div",{className:"text-sm flex items-center mx-auto gap-1 mt-2 shadow-sm rounded-full px-4 py-1",children:[m.jsx("div",{className:"w-1 h-1 bg-purple-500 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),m.jsx("div",{className:"w-1 h-1 bg-purple-500 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),m.jsx("div",{className:"w-1 h-1 bg-purple-500 rounded-full animate-bounce",style:{animationDelay:"300ms"}}),m.jsxs("span",{className:"text-primary",children:[" ",Ae?ue("video_preview.processing_data","Processing script..."):ue("video_preview.generating","Generating...")]})]}),Ae&&m.jsx("div",{className:"flex flex-col w-full",children:m.jsx("div",{className:"w-64 bg-gray-200 mx-auto rounded-full h-2.5 mt-4 mb-2 overflow-hidden",children:m.jsx("div",{className:"bg-purple-600 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${Math.min(100,Je.current/Je.max*100)}%`}})})}),fe&&m.jsx("div",{className:"whitespace-pre-line mt-4  text-gray-500",children:fe})]}):Object.keys(je).length>0?m.jsx(R,{children:m.jsx(h.div,{initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.5},children:Object.entries(je).map((([e,t])=>t&&t.content?m.jsx(V,{title:ut(e),time:t.time||"",content:t.content},e):null))})}):fe?m.jsx("div",{className:"whitespace-pre-line text-gray-700 text-sm",children:fe}):m.jsx(q,{})}),m.jsx(O,{className:"max-w-5xl mx-auto"}),m.jsxs("div",{className:"flex justify-between items-center pt-2 pb-2 px-4 border-t mt-auto fixed bottom-0 w-full bg-white max-w-5xl",children:[m.jsxs("div",{className:"flex gap-2",children:[m.jsxs(_,{variant:"ghost",className:"flex items-center gap-1",onClick:()=>{f("video_preview_translate_btn"),He(!0)},disabled:Me||ge||Ae||!fe,children:[m.jsx(P,{className:"h-4 w-4"}),m.jsx("span",{className:"hidden md:block",children:ue("video_editor.translate","翻译")})]}),m.jsxs(_,{variant:"outline",className:"flex items-center gap-1",onClick:()=>{me&&ve(`/video/editor/${me}`)},disabled:ge||Ae||Me,children:[m.jsx(A,{className:"h-4 w-4"}),m.jsx("span",{className:"hidden md:block",children:ue("video_preview.edit","Edit Content")})]})]}),m.jsxs("div",{className:"flex gap-2",children:[m.jsxs(_,{variant:"outline",onClick:()=>{if(!fe)return;f("video_preview_download_btn");const e=document.createElement("a"),t=new Blob([fe],{type:"text/plain"});e.href=URL.createObjectURL(t),e.download=`video-script-${me}.txt`,document.body.appendChild(e),e.click(),document.body.removeChild(e)},disabled:Me||ge||Ae||!fe,children:[m.jsx(F,{className:"h-4 w-4 mr-1"}),m.jsx("span",{className:"hidden md:block",children:ue("video_preview.download","Download")})]}),m.jsxs(_,{variant:"outline",onClick:()=>{fe&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(fe).then((()=>{l({title:ue("video_preview.copied","Copied to clipboard"),description:ue("video_preview.copy_success","Video script content has been copied to your clipboard")})}
1)).catch((e=>{console.error("Failed to copy:",e),pt()})):pt(),f("video_script_copied_preview",{video_script_id:me,video_script_content:fe}))},disabled:Me||ge||Ae||!fe,children:[m.jsx(J,{className:"h-4 w-4"}),m.jsx("span",{className:"hidden md:block",children:ue("video_preview.copy","Copy to Clipboard")})]}),m.jsxs(_,{className:"flex items-center gap-2 bg-purple-600 hover:bg-purple-700",onClick:()=>{fe&&me&&(f("video_script_record_clicked",{video_script_id:me}),ve(`/video/recorder/${me}`))},disabled:Me||ge||Ae||!fe,children:[m.jsx(L,{className:"h-4 w-4"}),m.jsx("span",{children:ue("video_preview.record","录制视频")})]})]})]})]})})})}),m.jsx(N,{open:$e,onOpenChange:Ue,onContinueRegenerate:async()=>{var e,t,i,s,o,a,r,n,d,c,p,u,v,m,_,x,g,h;if(Ee&&Ee.topic_id){Ue(!1),he(!0);try{if(null!==lt){const t="profile"===(null==(e=null==Ee?void 0:Ee.topic)?void 0:e.topic_type)?"profile_topic_video":"keyword_topic_video";await w({featureKey:t,cost:lt})}Ee.topic_id;const l=await y(Ee.topic_id);if(!l.status||!(null==(i=null==(t=l.data)?void 0:t.topic)?void 0:i.id))throw console.error("Failed to duplicate topic:",l.message),new Error(l.message||"Failed to duplicate topic");{const e=l.data.topic.id,t={post_topic_id:e,video_length:(null==(s=Ee.script_input_data)?void 0:s.video_length)||"90secs",video_user_idea:(null==(o=Ee.script_input_data)?void 0:o.video_user_idea)||"",video_framework:Ee.script_framework||"",video_tone:{is_custom:!1,tone_value:(null==(r=null==(a=Ee.script_input_data)?void 0:a.video_tone)?void 0:r.tone_value)||"casual"},is_advanced:(null==(n=Ee.script_input_data)?void 0:n.is_advanced)||!1,topic_title:(null==(d=Ee.topic)?void 0:d.topic_title)||_e,product_id:(null==(c=Ee.product)?void 0:c.product_id)||null},i=await j(t);if(!i.status||!(null==(p=i.data)?void 0:p.video_script_id))throw new Error(i.message||"Failed to create video script");localStorage.setItem("generated_content",JSON.stringify({title:(null==(u=Ee.topic)?void 0:u.topic_title)||_e,contentType:"video",duration:(null==(v=Ee.script_input_data)?void 0:v.video_length)||"90secs",framework:Ee.script_framework||"",tone:(null==(_=null==(m=Ee.script_input_data)?void 0:m.video_tone)?void 0:_.tone_value)||"casual",qualityType:(null==(x=Ee.script_input_data)?void 0:x.is_advanced)?"high":"standard",description:(null==(g=Ee.script_input_data)?void 0:g.video_user_idea)||"",image:(null==(h=Ee.topic)?void 0:h.topic_cover_url)||"",timestamp:(new Date).toISOString(),topic:Ee.topic,video_script_id:i.data.video_script_id,video_script:i.data.video_script})),ve(`/video/preview/${i.data.video_script_id}`)}}catch(f){console.error("Error in direct regeneration:",f),l({title:ue("video_preview.regeneration_failed","Regeneration Failed"),description:f.message||ue("video_preview.try_again","Please try again later"),variant:"destructive"}),he(!1)}}else l({title:ue("video_preview.error","Error"),description:ue("video_preview.missing_topic_data","Missing topic data needed for regeneration."),variant:"destructive"})},onReEdit:()=>{var e,t,i,s,o,a;if(Ee&&Ee.topic_id){const r={contentType:"video",duration:(null==(e=Ee.script_input_data)?void 0:e.video_length)||"90secs",framework:Ee.script_framework||"",tone:(null==(i=null==(t=Ee.script_input_data)?void 0:t.video_tone)?void 0:i.tone_value)||"",qualityType:(null==(s=Ee.script_input_data)?void 0:s.is_advanced)?"high":"standard",description:(null==(o=Ee.script_input_data)?void 0:o.video_user_idea)||"",productId:(null==(a=Ee.product)?void 0:a.product_id)||null};ze(r),Ue(!1),Ge(!0)}else l({title:ue("video_preview.error","Error"),description:ue("video_preview.missing_topic_data","Missing topic data needed for editing."),variant:"destructive"})},setContentData:ze,previewContent:{title:_e||(null==(Q=null==Ee?void 0:Ee.script_input_data)?void 0:Q.post_topic)||"",content:fe,contentType:"视频口播",framework:(null==Ee?void 0:Ee.framework_label)||"",tone:(null==Ee?void 0:Ee.tone_label)||"",quality:(null==(z=null==Ee?void 0:Ee.script_input_data)?void 0:z.is_advanced)?"高级":"标准",tags:[],userIdea:(null==(K=null==Ee?void 0:Ee.script_input_data)?void 0:K.video_user_idea)||"",image:(null==(W=null==Ee?void 0:Ee.topic)?void 0:W.topic_cover_url)||"",product:(null==(X=null==Ee?void 0:Ee.product)?void 0:X.product_name)||""},videoLength:(null==(Y=null==Ee?void 0:Ee.script_input_data)?void 0:Y.video_length)||"90secs",isAdvanced:(null==(Z=null==Ee?void 0:Ee.script_input_data)?void 0:Z.is_advanced)||!1,topicId:null==Ee?void 0:Ee.topic_id}),Ee&&Ee.topic_id&&m.jsx(k,{isOpen:Be,onClose:()=>Ge(!1),title:_e||(null==(H=Ee.script_input_data)?void 0:H.post_topic)||"",image:(null==(ee=null==Ee?void 0:Ee.topic)?void 0:ee.topic_cover_url)||"",purposeType:"",isRedo:!0,initialData:Qe||{contentType:"video",duration:(null==(te=Ee.script_input_data)?void 0:te.video_length)||"90secs",framework:Ee.script_framework||"",tone:(null==(se=null==(ie=Ee.script_input_data)?void 0:ie.video_tone)?void 0:se.tone_value)||"",qualityType:(null==(oe=Ee.script_input_data)?void 0:oe.is_advanced)?"high":"standard",description:(null==(ae=Ee.script_input_data)?void 0:ae.video_user_idea)||"",productId:(null==(re=Ee.product)?void 0:re.product_id)||null},topic:Ee.topic||{id:Ee.topic_id,topic_title:_e||(null==(ne=Ee.script_input_data)?void 0:ne.post_topic)||"",topic_cover_url:(null==(le=null==Ee?void 0:Ee.topic)?void 0:le.topic_cover_url)||""}}),m.jsx(I,{open:Xe,onOpenChange:Ye,activeType:Ke,topicId:null==Ee?void 0:Ee.topic_id,videoScriptId:me?parseInt(me,10):void 0}),m.jsx(S,{contentType:"video",topicId:(null==(de=null==Ee?void 0:Ee.topic_id)?void 0:de.toString())||"",imageUrl:"",open:Ze,onOpenChange:He,title:(null==(ce=null==Ee?void 0:Ee.topic)?void 0:ce.topic_title)||_e||"",content:Object.keys(je).length>0?Object.entries(je).map((([e,t])=>(null==t?void 0:t.content)||"")).filter((e=>
1e.trim())).join("\n\n"):fe,videoLength:null==(pe=null==Ee?void 0:Ee.script_input_data)?void 0:pe.video_length})]});var vt};export{$ 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.