PageSourceSearch

https://lipsyncx.com/_next/static/chunks/7992-863648ed35762571.js

js lipsyncx.com collected 2026-09-25 02:30:23 UTC 73,005 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7992],{37992:(e,t,r)=>{r.d(t,{QuickCreateSection:()=>ei});var a=r(50156),i=r(36128),l=r(57990),s=r.n(l),n=r(38411),o=r(59089),d=r(48450),c=r(74955),u=r(28575),m=r(93462),p=r(25496),x=r(81367),h=r(4357),b=r(14125),f=r(26768),w=r(4996),g=r(18669),v=r(93657),y=r(89617),j=r(21224),N=r(25206),S=r(41120),k=r(9574),_=r(67435),C=r(86251),E=r(95931),T=r(36439),A=r(36954),U=r(94014),F=r(44010),R=r(47099),I=r(31435),L=r(64708),P=r(24211),O=r(86343),D=r(37502),M=r(43177),V=r(17320),q=r(59158),z=r(43418),Q=r(76023),W=r(49363),G=r(85254),J=r(54167),$=r(8549),B=r(5038);let H=[{id:"talking-photo",nameKey:"talkingPhoto",descKey:"talkingPhotoDesc",href:"/ai-talking-photo-generator",icon:m.A},{id:"video-dubbing",nameKey:"videoDubbing",descKey:"videoDubbingDesc",href:"/ai-video-dubbing",icon:p.A},{id:"long-video",nameKey:"longVideo",descKey:"longVideoDesc",href:"/long-form-video-generator",icon:x.A},{id:"pet-anime",nameKey:"petAnime",descKey:"petAnimeSyncDesc",href:"/pet-and-anime-lip-sync",icon:h.A}],K=[],Z="lsx_voice_cache",Y="lsx_uploaded_media",X="lsx_quick_create_draft",ee="lsx_quick_create_restore_pending",et="lsx_quick_create_auto_generate_pending",er="lsx_preview_ai_choice_prompt_seen";function ea(e,t,r){var a,i;let l=e.find(e=>e.id===t||e.name===t);if(l)return l.id;let s=r&&e.length>1?1:0;return(null==(a=e[s])?void 0:a.id)||(null==(i=e[0])?void 0:i.id)||""}function ei(e){var t,r,l,m;let{variant:p="default",surface:x="default",hideHeader:h=!1,hideStepLabels:ei=!1,hideToolTabs:el=!1,initialModelSlug:es,initialMediaUrl:en,initialScript:eo,treatInitialMediaAsPreset:ed=!1,hideMobileToolTabs:ec=!1}=e,eu=(0,n.usePathname)(),em=(0,n.useRouter)(),ep=(0,o.Ym)(),ex=(0,d.k)(),eh=(0,d.c)("studio.common"),eb=(0,d.c)("common.quickCreate"),ef=(0,d.c)("common.nav"),{data:ew,status:eg}=(0,D.wV)(),ev="homeHero"===x,ey=ed&&!!en,[ej,eN]=(0,i.useState)(H[0]),[eS,ek]=(0,i.useState)(es?(0,Q.e5)(es):"lipsyncx-2-fast"),[e_,eC]=(0,i.useState)("audio"),eE=eb("defaultScript"),eT=eo||eE||eb("pasteScriptPlaceholder"),[eA,eU]=(0,i.useState)(""),[eF,eR]=(0,i.useState)(()=>ea(K,null,ey)),[eI,eL]=(0,i.useState)([]),[eP,eO]=(0,i.useState)("en"),[eD,eM]=(0,i.useState)("all"),[eV,eq]=(0,i.useState)(!0),[ez,eQ]=(0,i.useState)(!1),[eW,eG]=(0,i.useState)(0),eJ=(0,i.useMemo)(()=>eI.filter(e=>"all"===eP||"all"===e.language||e.language===eP),[eI,eP]),e$=(0,i.useMemo)(()=>eJ.filter(e=>"all"===eD||e.gender===eD),[eJ,eD]),[eB,eH]=(0,i.useState)(.9),[eK,eZ]=(0,i.useState)("[neutral]"),[eY,eX]=(0,i.useState)("480p"),[e0,e1]=(0,i.useState)("English"),[e2,e3]=(0,i.useState)("medium"),[e4,e5]=(0,i.useState)("9:16"),[e6,e8]=(0,i.useState)("all"),[e9,e7]=(0,i.useState)(null),[te,tt]=(0,i.useState)(null),[tr,ta]=(0,i.useState)(null),[ti,tl]=(0,i.useState)(!1),[ts,tn]=(0,i.useState)(!1),[to,td]=(0,i.useState)(null),[tc,tu]=(0,i.useState)(!1),[tm,tp]=(0,i.useState)(),[tx,th]=(0,i.useState)(),[tb,tf]=(0,i.useState)(null),tw=(0,i.useRef)(null),tg=(0,i.useRef)(null),[tv,ty]=(0,i.useState)(ev?null:z.Pw),[tj,tN]=(0,i.useState)(ev?null:z.aV),[tS,tk]=(0,i.useState)(!1),[t_,tC]=(0,i.useState)(!1),[tE,tT]=(0,i.useState)(!1),[tA,tU]=(0,i.useState)(!1),[tF,tR]=(0,i.useState)(!1),[tI,tL]=(0,i.useState)(null),[tP,tO]=(0,i.useState)("audio"),[tD,tM]=(0,i.useState)(ev?null:z.aV),[tV,tq]=(0,i.useState)(0),[tz,tQ]=(0,i.useState)(!1),[tW,tG]=(0,i.useState)(!1),[tJ,t$]=(0,i.useState)(!1),[tB,tH]=(0,i.useState)(!1),[tK,tZ]=(0,i.useState)(!1),[tY,tX]=(0,i.useState)(null),[t0,t1]=(0,i.useState)(null),t2=(0,i.useRef)(null),t3=(0,i.useRef)({start:0,end:0}),t4=(0,i.useRef)(null),[t5,t6]=(0,i.useState)(!1),[t8,t9]=(0,i.useState)(!1),[t7,re]=(0,i.useState)(!1),[rt,rr]=(0,i.useState)(null),[ra,ri]=(0,i.useState)(null),[rl,rs]=(0,i.useState)(null),[rn,ro]=(0,i.useState)(null),[rd,rc]=(0,i.useState)(null),[ru,rm]=(0,i.useState)(!1),[rp,rx]=(0,i.useState)(!1),[rh,rb]=(0,i.useState)(""),[rf,rw]=(0,i.useState)(""),[rg,rv]=(0,i.useState)(!1),[ry,rj]=(0,i.useState)(ev?null:z.dP),rN=(0,i.useRef)(null),rS=(0,i.useRef)(0),rk=(0,i.useRef)(null),r_=(0,i.useRef)(null),[rC,rE]=(0,i.useState)(!1),[rT,rA]=(0,i.useState)(!1),[rU,rF]=(0,i.useState)(null),[rR,rI]=(0,i.useState)(null),rL=(0,i.useRef)(null),rP=(0,i.useRef)([]),rO=(0,i.useRef)(null),[rD,rM]=(0,i.useState)(null),[rV,rq]=(0,i.useState)(!1),[rz,rQ]=(0,i.useState)(null),[rW,rG]=(0,i.useState)(1),[rJ,r$]=(0,i.useState)(!1),[rB,rH]=(0,i.useState)(!1),[rK,rZ]=(0,i.useState)(!0),[rY,rX]=(0,i.useState)(0),r0=ep.startsWith("zh"),r1=(0,i.useRef)(!1),r2=(0,i.useRef)(!1),r3=(0,i.useRef)(new Set),r4=(0,i.useRef)(null),r5=(0,i.useRef)(null),r6=(0,i.useRef)(null),r8=(0,i.useRef)(null),r9=(0,i.useRef)(null),r7=ed&&!!en,ae=(0,i.useCallback)(e=>(0,B.vA)(ep,e),[ep]);(0,i.useEffect)(()=>{let e=setTimeout(()=>rM(1),800);return()=>clearTimeout(e)},[]),(0,i.useEffect)(()=>{1===rD&&(e9||tr)&&rM(2)},[rD,e9,tr]),(0,i.useEffect)(()=>
1{if(null===rD||rD<2)return;if(4===rD&&"text"!==e_)return void rM(5);let e=setTimeout(()=>{rM(rD<5?rD+1:null)},3e3);return()=>clearTimeout(e)},[rD,e_]),(0,i.useEffect)(()=>{es&&ek((0,Q.e5)(es))},[es]),(0,i.useEffect)(()=>{if(!en||rV&&rz===en)return;if(r7&&1){let e=!!new URLSearchParams(window.location.search).get("media"),t=!!window.localStorage.getItem(Y);if(e||t)return}let e=en.match(/\.(mp4|webm|mov|avi)(\?|$)/i);ta(en),e7(en),tt(e?"video":"image"),td(ed?"avatar":"upload"),rH(!ed),rq(!1),rQ(null)},[r7,en,rz,ed,rV]),(0,i.useEffect)(()=>{if(en&&!r7||rV)return;let e=()=>{let e=new URLSearchParams(window.location.search).get("media");if(e&&!e9&&!tr){let t=e.match(/\.(mp4|webm|mov|avi)(\?|$)/i);ta(e),e7(e),tt(t?"video":"image"),td("upload")}};e();let t=()=>e();window.addEventListener("popstate",t);let r=setInterval(t,500);return()=>{window.removeEventListener("popstate",t),clearInterval(r)}},[r7,en,e9,tr,rV]),(0,i.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get("script");e&&eU(e)},[]),(0,i.useEffect)(()=>{if(r1.current)return;let e="1"===window.sessionStorage.getItem(ee),t=window.localStorage.getItem(X);if(t)try{let a=JSON.parse(t);if(!(Date.now()-(a.updatedAt||0)<864e5))return;if(!e&&"audio"===a.inputMode)return void window.localStorage.removeItem(X);if(!(e||(!en||r7)&&!rV&&!tr&&""===eA&&"audio"===e_))return;if(r1.current=!0,eN(H.find(e=>e.id===a.selectedTool)||H[0]),ek(a.model||"lipsyncx-2-fast"),eC(a.inputMode||"text"),eU(a.script||""),eR(a.voice||ea(K,null,ey)),eO(a.voiceLanguage||"en"),eM(a.voiceGender||"all"),eH(a.voiceSpeed||.9),eZ(a.emotion||"[neutral]"),eX(a.resolution||"480p"),e1(a.scriptLanguage||"English"),e5(a.aspectRatio||"9:16"),tN(a.remoteAudioUrl||null),ty(a.audioFileName||(a.remoteAudioUrl===z.aV?z.Pw:null)),tM(a.remoteAudioUrl||null),rj("number"==typeof a.audioDurationSeconds?a.audioDurationSeconds:a.remoteAudioUrl===z.aV?z.dP:null),td(a.mediaSource||null),a.remoteMediaUrl&&(ta(a.remoteMediaUrl),e7(a.remoteMediaUrl),tt(a.localMediaType||"image"),rH(!0)),e){var r;window.sessionStorage.removeItem(ee),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"quick_create_draft_restored",area:"quick_create",locale:ep,page_path:eu,variant:p,device:"mobile",restored_media:!!a.remoteMediaUrl,restored_script:!!(null==(r=a.script)?void 0:r.trim()),restored_audio:!!a.remoteAudioUrl}),(0,I.P0)({title:eb("draftRestoredTitle"),description:eb("draftRestoredDesc")})}}catch(e){window.localStorage.removeItem(X)}},[eE,r7,en,e_,tr,tj,eA,eb,rV,ep,eu,ey,p]),(0,i.useEffect)(()=>{let e={selectedTool:ej.id,model:eS,inputMode:e_,remoteMediaUrl:tr,localMediaType:te,remoteAudioUrl:tj,audioFileName:tv,audioDurationSeconds:ry,script:eA,voice:eF,voiceLanguage:eP,voiceGender:eD,voiceSpeed:eB,emotion:eK,resolution:eY,scriptLanguage:e0,aspectRatio:e4,mediaSource:to,updatedAt:Date.now()};window.localStorage.setItem(X,JSON.stringify(e))},[e4,tv,eK,e_,te,to,eS,tj,tr,eY,eA,e0,ej.id,ry,eF,eP,eD,eB]),(0,i.useEffect)(()=>{if(en&&!r7||rV)return;let e=localStorage.getItem(Y);if(e)try{let t=JSON.parse(e);t.remoteUrl&&t.localUrl&&t.mediaType&&(ta(t.remoteUrl),e7(t.localUrl),tt(t.mediaType),td("upload"))}catch(e){localStorage.removeItem(Y)}},[r7,en,rV]);let at=(0,i.useCallback)(e=>new Promise(t=>{let r=new Audio,a=()=>{r.onloadedmetadata=null,r.onerror=null};r.preload="metadata",r.onloadedmetadata=()=>{let e=Number.isFinite(r.duration)?r.duration:NaN;a(),t(Number.isFinite(e)&&e>0?e:null)},r.onerror=()=>{a(),t(null)},r.src=e}),[]),ar=[eA.trim(),eF,e0,eK,eB.toFixed(2),rd||"preview-choice-pending"].join("|"),aa=(0,i.useCallback)(async e=>{let t=e.trim();if(!t)throw Error("Missing text");let r=await fetch("/api/ai/emotion-script",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t,emotion:eK,language:(0,F.ZP)(e0),temperature:.35,maxChars:Math.min(1600,Math.max(t.length+160,240))})});if(!r.ok)throw Error((await r.json().catch(()=>({}))).error||"Script generation failed");let a=((await r.json()).text||"").trim();if(!a)throw Error("Script generation returned empty text");return a},[eK,e0]),ai=(0,i.useMemo)(()=>"text"===e_?eA.trim()?(0,G.Mk)({inputMode:"text",balanceCredits:tV,resolution:"480p"===eY||"720p"===eY?eY:"720p",script:eA}).billableDurationSeconds:0:ry?(0,G.u9)(ry):0,[tV,e_,eY,eA,ry]),al=(0,Q.Yn)(eS),as=(0,Q.O5)(eS),an=al.supportedResolutions,ao="1080p"===eY||"1440p"===eY||"2160p"===eY,ad="480p"===eY||"720p"===eY?eY:"720p",ac=as?null:(0,G.Mk)({inputMode:e_,balanceCredits:tV,resolution:ad,script:eA,audioDurationSeconds:ry}),au=ai?Math.ceil(ai/G.PJ):0,am=as?(0,G.s2)({workflowId:"audio-to-video",durationSeconds:G.PJ}):(0,G.W6)(G.PJ,"480p"===eY||"720p"===eY?eY:"720p"),ap=ai?as?(0,G.s2)({workflowId:"audio-to-video",durationSeconds:ai}):null!=(m=null==ac?void 0:ac.requiredCredits)?m:(0,G.W6)(ai,ad):0,ax=ap>0?Math.max(ap-tV,0):0,ah=ap>0&&ap>tV,ab=!!tr,af=!!eA.trim(),aw="text"===e_?4:3,ag=(0,i.useCallback)((e,t)=>{window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:e,area:"quick_create",locale:ep,page_path:eu,variant:p,device:"mobile",mobile_step:rW,input_mode:e_,has_media:ab,has_script:af,has_audio:!!tj,estimated_cost_cents:ap||0,...t})},[ap,ab,af,e_,ep,rW,eu,tj,p]);(0,i.useEffect)(()=>{let e=!1,t=0;tQ(!1);let r=()=>{let r=++t;(0,R.vL)().then(a=>{e||r!==t||(tq(a),tQ(!0))})};return r(),window.addEventListener((0,R.iI)(),r),()=>{e=!0,window.removeEventListener((0,R.iI)(),r)}},[eg,null==ew||null==(t=ew.user)?void 0:t.id]),(0,i.useEffect)(()=>{"text"===e_&&as&&ek("lipsyncx-2-fast")},[e_,as]),(0,i.useEffect)(()=>
1{if(as){ao||eX("1080p");return}ao&&eX("720p")},[as,ao]);let av=async e=>{let t=await e.arrayBuffer(),r=new(window.AudioContext||window.webkitAudioContext),a=(e=>{let t=e.numberOfChannels,r=e.sampleRate,a=e.length,i=16*t/8,l=a*i,s=new ArrayBuffer(44+l),n=new DataView(s),o=(e,t)=>{for(let r=0;r<t.length;r+=1)n.setUint8(e+r,t.charCodeAt(r))};o(0,"RIFF"),n.setUint32(4,36+l,!0),o(8,"WAVE"),o(12,"fmt "),n.setUint32(16,16,!0),n.setUint16(20,1,!0),n.setUint16(22,t,!0),n.setUint32(24,r,!0),n.setUint32(28,r*i,!0),n.setUint16(32,i,!0),n.setUint16(34,16,!0),o(36,"data"),n.setUint32(40,l,!0);let d=44;for(let r=0;r<a;r+=1)for(let a=0;a<t;a+=1){let t=e.getChannelData(a)[r]||0;t=Math.max(-1,Math.min(1,t)),n.setInt16(d,t<0?32768*t:32767*t,!0),d+=2}return s})(await r.decodeAudioData(t.slice(0)));return await r.close(),new Blob([a],{type:"audio/wav"})},ay=(0,i.useCallback)(()=>{var e;null==(e=tg.current)||e.call(tg),tg.current=null},[]),aj=async()=>{if(!tb||!tx||!tw.current)return null;let e=tw.current,t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return null;let a=e.naturalWidth/e.width,i=e.naturalHeight/e.height;return t.width=tx.width*a,t.height=tx.height*i,r.drawImage(e,tx.x*a,tx.y*i,tx.width*a,tx.height*i,0,0,t.width,t.height),new Promise(e=>{t.toBlob(t=>e(t||null),"image/png")})},aN=(0,i.useCallback)(e=>{let t=e instanceof q.g&&"NSFW_IMAGE_DETECTED"===e.code;(0,I.Qg)(eb(t?"nsfwImageDetectedTitle":"imageSafetyCheckFailedTitle"),eb(t?"nsfwImageDetectedDescription":"imageSafetyCheckFailedDescription"))},[eb]),aS=async()=>{let e=await aj();if(e){tk(!0);try{let t=URL.createObjectURL(e),r=new File([e],"cropped-".concat(Date.now(),".png"),{type:"image/png"}),a=await aC(r);await (0,q.F)(a),e7(t),ta(a),td("upload")}catch(e){aN(e)}finally{tk(!1)}ay(),tf(null),tu(!1),tp(void 0)}},ak=()=>{ay(),tf(null),tu(!1),tp(void 0)};(0,i.useEffect)(()=>()=>{ay()},[ay]);let a_=(0,i.useCallback)(async()=>{let e=e9||tr;if(e)try{ay();let t=await (0,V.u)(e);tg.current=t.revoke,tf(t.src),tu(!0)}catch(e){(0,I.Qg)("Crop failed",e instanceof Error?e.message:"Please try again.")}},[e9,tr,ay]),aC=(0,i.useCallback)(async e=>{let t=async()=>{let t=await fetch("/api/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e.name})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e&&e.error||"Failed to request upload URL")}let r=await t.json();if(!r.upload||!r.url)throw Error("Upload URL missing");if(!(await fetch(r.upload,{method:"PUT",body:e})).ok)throw Error("Upload failed");return r.url},r=async()=>{let t=new FormData;t.append("file",e);let r=await fetch("/api/v1/upload",{method:"POST",body:t});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e&&e.error||"Upload failed")}let a=await r.json();if(!a.url)throw Error("Upload did not return a URL");return a.url};try{return await t()}catch(e){return await r()}},[]),aE=(0,i.useCallback)(e=>e?e===z.aV?z.M6:e:null,[]),aT=async e=>{if(!e||tS)return;if(!e.type.startsWith("image/")&&!e.type.startsWith("video/"))return void(0,I.Qg)(eb("uploadRequirements"),eb("supportedFormats"));if(e.size>0x6400000)return void(0,I.Qg)(eb("uploadRequirements"),eb("maxFileSize"));rH(!0),rq(!1),rQ(null);let t=e.type.startsWith("video/"),r=URL.createObjectURL(e);if(!t){e7(r),tt("image"),td("upload"),tk(!0);try{let t=await aC(e);await (0,q.F)(t),ta(t)}catch(e){aN(e),e7(null),tt(null),td(null),ta(null)}finally{tk(!1)}return}e7(r),tt("video"),td("upload"),tk(!0);try{let t=await aC(e);ta(t)}catch(e){ta(null)}finally{tk(!1)}},aA=(0,i.useCallback)(()=>{var e;tS||null==(e=rO.current)||e.click()},[tS]),aU=async e=>{if(!e||tS)return;if(!e.type.startsWith("audio/")&&!(0,W.w)(e)||e.size>0x1e00000)return void(0,I.Qg)(eb("uploadRequirements"),eb("supportedAudioFormats"));tk(!0);let t=e,r=null;try{if((0,W.w)(e)){let a=await (0,W.d)(e,aC);r=a.audioUrl,t=new File([e],a.fileName,{type:"audio/mpeg"})}}catch(e){tN(null),rE(!1),rj(null),tk(!1),(0,I.Qg)(eb("audioPreviewFailed"),e instanceof Error?e.message:eb("unknownError"));return}ty(t.name);let a=URL.createObjectURL(t);tO("audio"),at(a).then(e=>{rj(e),URL.revokeObjectURL(a)});try{let e=r||await aC(t);tN(e),tM(e),rE(!1),rZ(!0)}catch(e){tN(null),rE(!1),rj(null),(0,I.Qg)(eb("audioPreviewFailed"),e instanceof Error?e.message:eb("unknownError"))}finally{tk(!1)}},aF=(0,i.useCallback)((e,t)=>{let r=t||(as?null:(0,G.Mk)({inputMode:e_,balanceCredits:tV,resolution:ad,script:eA,audioDurationSeconds:ry}));r&&(tL(r),tR(!0),ag("insufficient_balance_prompt_shown",{source:e,prompt_mode:"lipsync",required_cents:r.requiredCredits,shortfall_cents:r.shortfallCredits,balance_credits:r.balanceCredits}))},[tV,e_,as,ad,eA,ag,ry]),aR=(0,i.useCallback)(async(e,t)=>{if(tr&&tj&&e.previewOffer){tC(!0);try{let a=tr,i=await (0,J._j)(tD||tj,0,e.previewOffer.previewDurationSeconds),l=new File([i],"trimmed-audio.wav",{type:"audio/wav"}),s=await aC(l);if("video"===te){let e=document.createElement("video");
1e.crossOrigin="anonymous",e.src=tr,e.muted=!0,e.playsInline=!0;let t=await new Promise((t,r)=>{e.onloadeddata=()=>{e.currentTime=0},e.onseeked=()=>{let a=document.createElement("canvas");a.width=e.videoWidth,a.height=e.videoHeight;let i=a.getContext("2d");if(!i)return void r(Error("Failed to get canvas context"));i.drawImage(e,0,0,a.width,a.height),a.toBlob(e=>{e?t(e):r(Error("Failed to extract video frame"))},"image/png")},e.onerror=()=>r(Error("Failed to load video"))}),r=new File([t],"video-frame.png",{type:"image/png"});a=await aC(r)}let n=await fetch("/api/v2/lip-sync-video/job",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({video:a,audio:s,input_mode:tP,audio_duration_seconds:e.previewOffer.previewDurationSeconds,subtitle_mode:0,job_type:"generatedTemplates",estimated_time:e.previewOffer.previewDurationSeconds,preview_mode:!0,resolution:eY,model:eS,anon_id:(0,R.Ck)()})}),o=await n.json().catch(()=>({}));if(!n.ok){var r;throw Error((null==o||null==(r=o.error)?void 0:r.message)||"Preview generation failed")}tT(!0),(null==t?void 0:t.autoCropped)&&(0,I.P0)({title:eb("autoCroppedTitle"),description:eb("autoCroppedDesc",{seconds:e.previewOffer.previewDurationSeconds})}),window.localStorage.removeItem(X),window.sessionStorage.removeItem(ee),window.sessionStorage.removeItem(et),em.push(ae("/library"))}catch(e){throw(0,I.Qg)(eb("generationFailed"),e instanceof Error?e.message:eb("unknownError")),e}finally{tC(!1)}}},[te,ae,eS,tD,tP,tj,tr,eY,em,eb,aC]),aI=async()=>{var e;if(tr&&("text"!==e_||eA.trim())){if("text"===e_&&!eF)return void(0,I.Qg)(eb("generationFailed"),eb("voice"));if("text"===e_||tj){if(as&&"text"===e_)return void(0,I.Qg)(eb("generationFailed"),"LTX 2.3 only supports audio-driven generation.");if(as&&"video"===te)return void(0,I.Qg)(eb("generationFailed"),"LTX 2.3 currently supports image + audio, not video input.");if(ag("quick_create_generate_clicked",{source:4===rW?"mobile_step_4":"inline",resolution:eY,model:eS}),!(null==ew||null==(e=ew.user)?void 0:e.id)){window.sessionStorage.setItem(ee,"1"),window.sessionStorage.setItem(et,"1"),tG(!0);return}if(!as&&ap>tV)return void aF("generate_click");tC(!0);try{let e=as?"/api/models/ltx-23":"text"===e_?"/api/v2/tts-lipsync/job":"/api/v2/lip-sync-video/job",t=as?{audio_url:aE(tj),image_url:tr,resolution:"1080p"===eY||"1440p"===eY||"2160p"===eY?eY:"1080p",duration_seconds:ai||6,anon_id:(0,R.Ck)()}:"text"===e_?{video:tr,text:eA,language:(0,F.ZP)(e0),subtitle_mode:0,job_type:"generatedTemplates",estimated_time:ai||60,resolution:eY,model:eS,speaker:eF,speed:eB,pitch:0,volume:1,emotion:eK,anon_id:(0,R.Ck)()}:{video:tr,audio:aE(tj),input_mode:"record"===e_?"record":"audio",audio_duration_seconds:ry,subtitle_mode:0,job_type:"generatedTemplates",estimated_time:ai||60,resolution:eY,model:eS,anon_id:(0,R.Ck)()},r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){if(401===r.status){window.sessionStorage.setItem(ee,"1"),window.sessionStorage.setItem(et,"1"),tG(!0),tC(!1);return}let e=await r.json().catch(()=>({})),t=null==e?void 0:e.error,a="object"==typeof t&&null!==t,i=a?t.message||String(t.code)||"Generation failed":String(t)||"Generation failed",l=a&&!0===t.requiresRecharge,s=null==e?void 0:e.recovery;if(l){!as&&s?(tq(s.balanceCredits),aF("generate_requires_recharge",s)):as?((0,R.vL)().then(e=>{tq(e)}),tU(!0)):aF("generate_requires_recharge"),tC(!1);return}throw Error(i)}let a=await r.json().catch(()=>({}));if(as&&!(null==a?void 0:a.ok))throw Error((null==a?void 0:a.error)||"Generation failed");tT(!0),window.localStorage.removeItem(X),window.sessionStorage.removeItem(ee),window.sessionStorage.removeItem(et),em.push(ae("/library"))}catch(e){(0,I.Qg)(eb("generationFailed"),e instanceof Error?e.message:eb("unknownError"))}finally{tC(!1)}}}};(0,i.useEffect)(()=>{rk.current=aI});let aL=ap>0?{eyebrow:eb("generateVideo"),title:eb("rechargeContextTitle"),subtitle:eb("rechargeContextSubtitle",{credits:(0,R.Ql)(ap)}),note:ax>0?eb("rechargeContextShortfallNote",{balance:(0,R.Ql)(tV),shortfall:(0,R.Ql)(ax)}):eb("rechargeContextCheckoutNote"),requiredCredits:ap,balanceCredits:tV,shortfallCredits:ax}:void 0,aP=async()=>
1{if("text"===e_){t$(!0);try{let e=await aa(eA);if(e){let t=eA.trim();eU(e),ro(t),rc("beautified"),rw(e)}}catch(e){console.error("AI Script error:",e)}finally{t$(!1)}}},aO=(0,i.useCallback)(()=>{rv(!0),window.setTimeout(()=>{rv(!1)},2600)},[]),aD=(0,i.useCallback)(()=>{window.matchMedia("(max-width: 1023px)").matches&&(r$(!0),window.setTimeout(()=>{var e;null==(e=r9.current)||e.scrollIntoView({behavior:"smooth",block:"center"})},120)),aO()},[aO]),aM=async()=>{if("text"===e_&&eA.trim()){tH(!0);try{let e=await fetch("/api/ai/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:eA,targetLanguage:(0,F.ZP)(e0),sourceLanguage:"auto"})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t&&t.error||"Translation failed")}let t=await e.json();t.text&&eU(t.text)}catch(e){console.error("Translate error:",e),(0,I.Qg)(eb("translationFailed"),e instanceof Error?e.message:eb("unknownError"))}finally{tH(!1)}}};(0,i.useEffect)(()=>{let e=!1;{let e=window.localStorage.getItem(Z);if(e)try{let t=JSON.parse(e),r=(0,$.Mg)(t);r.length?(eL(r),eR(e=>ea(r,e,ey))):window.localStorage.removeItem(Z)}catch(e){}}return(async()=>{eq(!0),eQ(!1);try{let t=await fetch("/api/template/voice-list?lan=all");if(!t.ok)throw Error("Voice list unavailable");let r=await t.json();if(e)return;let a=(0,$.Mg)(r.list||[]);if(a.length)eL(a),eR(e=>ea(a,e,ey)),window.localStorage.setItem(Z,JSON.stringify(a));else throw Error("Voice list empty")}catch(t){e||eQ(!0)}finally{e||eq(!1)}})(),()=>{e=!0}},[ey,eW]),(0,i.useEffect)(()=>{if(eI.length){if(!eJ.length)return void eO("all");if(!e$.length)return void eM("all");eR(e=>ea(e$,e,ey))}},[eI,eJ,e$,ey]),(0,i.useEffect)(()=>{let e=t4.current;e&&(e.pause(),t6(!1))},[e_,eF]),(0,i.useEffect)(()=>{let e=r_.current;e&&(e.pause(),rE(!1))},[e_,tj,rU]),(0,i.useEffect)(()=>{var e;rS.current+=1,null==(e=rN.current)||e.pause(),re(!1),t9(!1),ri(null),rs(null),ro(null),rc(null),rw("")},[eA,eK,e0,eF,eB,e_]),(0,i.useEffect)(()=>{if("audio"!==e_||!tj)return;let e=!1;return at(tj).then(t=>{!e&&t&&rj(t)}),()=>{e=!0}},[at,e_,tj]),(0,i.useEffect)(()=>{if("record"!==e_||!rU)return;let e=!1;return at(rU).then(t=>{!e&&t&&rj(t)}),()=>{e=!0}},[at,e_,rU]),(0,i.useEffect)(()=>{"audio"!==e_||tj||rj(null),"record"!==e_||rU||rj(null)},[e_,rU,tj]),(0,i.useEffect)(()=>{if("text"===e_)return void rZ(!0);rZ(!!tj)},[e_,tj]);let aV=(0,i.useCallback)(async()=>{if("text"!==e_)return;let e=eA.trim();if(!e)return void(0,I.Qg)(eb("missingScript"),eb("enterTextBeforePreview"));let t=rN.current;if(!t)return;if(ag("quick_create_preview_clicked",{preview_type:"tts",voice_id:eF,ai_emotion_polish_enabled:"beautified"===rd}),t7){t.pause(),re(!1);return}let r="1"===window.localStorage.getItem(er),a="beautified"===rd&&rn===e;if(!r&&!a){window.localStorage.setItem(er,"1"),rx(!0),rb(e);try{let t=await aa(e);rw(t),rm(!0)}catch(e){(0,I.Qg)(eb("audioPreviewFailed"),e instanceof Error?e.message:eb("unknownError"))}finally{rx(!1)}return}if(rt&&ra===ar){t.src!==rt&&(t.src=rt),t.currentTime=0,t.play().then(()=>re(!0)).catch(()=>{re(!1)});return}t9(!0);let i=++rS.current;try{let r="beautified"===rd?rf:e,a=await fetch("/api/ai/tts-preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:r,language:(0,F.ZP)(e0),speaker:eF,speed:eB,emotion:"beautified"===rd?void 0:eK})}),l=await a.json().catch(()=>({}));if(!a.ok||!l.audioUrl)throw Error(l&&l.error||"Preview generation failed");if(i!==rS.current)return;rr(l.audioUrl),ri(ar);let s=await at(l.audioUrl);if(i!==rS.current)return;s&&rs(s),t.src=l.audioUrl,t.currentTime=0,await t.play(),re(!0),"beautified"===rd&&r!==e&&(0,I.P0)({title:"AI emotion polish applied",description:"Preview used a lightly optimized performance script."})}catch(e){if(i!==rS.current)return;re(!1),(0,I.Qg)(eb("audioPreviewFailed"),e instanceof Error?e.message:eb("unknownError"))}finally{i===rS.current&&t9(!1)}},[ar,eK,aa,at,e_,t7,rn,rf,rd,eA,e0,eb,ag,rN,rt,ra,eF,eB]),aq=async()=>{if(!rT){rI(null),rF(null);try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}
1),t=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",r=new MediaRecorder(e,t?{mimeType:t}:void 0);rP.current=[],r.ondataavailable=e=>{e.data.size>0&&rP.current.push(e.data)},r.onstop=async()=>{let t=new Blob(rP.current,{type:r.mimeType||"audio/webm"});if(0===rP.current.length||t.size<1024){rI("Recording is empty. Please try again."),tN(null),rj(null),tk(!1),e.getTracks().forEach(e=>e.stop());return}let a=t;try{a=await av(t)}catch(e){}let i=URL.createObjectURL(a);rF(i),tM(i),tO("record");let l=await at(i);rj(l),ty("Recording"),tk(!0);try{let e=a.type.includes("wav")?"wav":a.type.includes("mp4")?"m4a":"webm",t=new File([a],"recording.".concat(e),{type:a.type||"audio/wav"}),r=await aC(t);tN(r),rZ(!0)}catch(e){rI(e instanceof Error?e.message:"Upload failed"),tN(null),rj(null)}finally{tk(!1),e.getTracks().forEach(e=>e.stop())}},rL.current=r,r.start(250),rA(!0)}catch(e){rI(e instanceof Error?e.message:"Microphone permission denied")}}},az=()=>{if(rL.current){if("recording"===rL.current.state){try{rL.current.requestData()}catch(e){}rL.current.stop()}rA(!1)}};(0,i.useEffect)(()=>{"record"!==e_&&rT&&az()},[e_,rT]),(0,i.useEffect)(()=>{if(!eu)return;let e=H.find(e=>eu.startsWith(e.href));e&&e.id!==ej.id&&eN(e)},[eu,ej.id]),(0,i.useEffect)(()=>{if(!eu)return;let e=[["/ai-talking-photo-generator","host"],["/ai-video-dubbing","reporter"],["/long-form-video-generator","podcaster"],["/pet-and-anime-lip-sync","pet"],["/script-to-video-ai","host"],["/bulk-video-generator","reporter"],["/solutions/podcasts","podcaster"],["/solutions/youtube-automation","youtuber"],["/solutions/elearning","host"],["/solutions/marketing","host"],["/solutions-localization","reporter"],["/solutions-enterprise-training","host"],["/alternatives/best-heygen-alternative","host"],["/scenes","reporter"]].find(e=>{let[t]=e;return eu.startsWith(t)});if(e){let[,t]=e;t!==e6&&(e8(t),tX(null))}},[eu,e6]);let aQ=(0,i.useMemo)(()=>r0?{all:"全部",celebrity:"名人",streamer:"主播",host:"主持人",reporter:"记者",podcaster:"播客",youtuber:"YouTuber",cartoon:"卡通",pet:"宠物",baby:"宝宝",beauty:"美女",other:"其他"}:{all:"All",celebrity:"Celebrities",streamer:"Streamers",host:"Hosts",reporter:"Reporters",podcaster:"Podcasters",youtuber:"YouTubers",cartoon:"Cartoons",pet:"Pets",baby:"Babies",beauty:"Beauty",other:"Other"},[r0]),aW=(0,i.useMemo)(()=>r0?[{id:"birthday",label:"生日祝福",script:"生日快乐。愿你新的一岁平安顺遂,心想事成,每一天都比昨天更精彩。"},{id:"congrats",label:"恭喜庆祝",script:"太棒了,恭喜你达成这个重要里程碑。你的努力终于开花结果,值得今天所有掌声。"},{id:"team-win",label:"团队庆功",script:"这次成功属于整个团队。谢谢每一位伙伴的坚持、执行和冲刺,今晚我们一起庆功。"},{id:"wedding",label:"婚礼祝词",script:"祝你们新婚快乐,愿未来的每一天都充满爱、理解与陪伴,携手把平凡日子过成闪光时刻。"},{id:"graduation",label:"毕业寄语",script:"毕业快乐。愿你带着勇气与热爱走向下一段旅程,前路辽阔,未来可期。"},{id:"launch",label:"发布官宣",script:"今天很高兴向大家正式宣布,我们的新项目上线了。欢迎体验,并把这份惊喜分享给更多朋友。"}]:[{id:"birthday",label:"Birthday Wish",script:"Happy birthday. Wishing you a year full of good health, big wins, and unforgettable moments."},{id:"congrats",label:"Congrats",script:"Congratulations on this amazing milestone. You earned every bit of this moment, and today is your day to celebrate."},{id:"team-win",label:"Team Celebration",script:"This win belongs to the whole team. Thank you for the hustle, the focus, and the extra push that made it happen."},{id:"wedding",label:"Wedding Toast",script:"Wishing you both a beautiful marriage filled with laughter, loyalty, and a lifetime of unforgettable memories together."},{id:"graduation",label:"Graduation",script:"Congratulations on your graduation. Step into your next chapter with confidence, curiosity, and ambition."}
1,{id:"launch",label:"Launch Announcement",script:"Today we are excited to officially launch something we have worked hard to build. Thank you for being part of this moment."}],[r0]),aG=r0?"一键文案模板":"Instant script templates",aJ=r0?"常见祝福、庆功、官宣,点一下直接套用。":"One-click copy for greetings, celebrations, and announcements.",a$=M.F.reduce((e,t)=>{let r=aQ[t.category||t.id.split("-")[0]||"other"]||aQ.other;return e[r]||(e[r]=[]),e[r].push(t),e},{}),aB=Array.from(new Set(M.F.map(e=>e.category))),aH=["all","celebrity","streamer","host","reporter","podcaster","youtuber"].filter(e=>"all"===e||aB.includes(e)),aK="all"===e6?M.F:M.F.filter(e=>e.category===e6),aZ=Object.keys(a$),aY=tY||aZ[0]||"",aX=aY?a$[aY]:[],a0="text"===e_?!!eA.trim():!!tj,a1="text"===e_||!!tj,a2=!!(tr&&("text"===e_?eA.trim()&&eF:tj));(0,i.useEffect)(()=>{var e;if(r2.current||"authenticated"!==eg||!(null==ew||null==(e=ew.user)?void 0:e.id)||"1"!==window.sessionStorage.getItem(et)||t_||tS||!a2||!tz)return;let t=window.setTimeout(()=>{var e;r2.current=!0,window.sessionStorage.removeItem(et),null==(e=rk.current)||e.call(rk)},350);return()=>window.clearTimeout(t)},[eg,null==ew||null==(r=ew.user)?void 0:r.id,t_,tS,a2,tz,e_,tr,tj,eA]);let a3=(0,i.useCallback)(e=>{let t=1===e?r4.current:2===e?r5.current:3===e&&"text"===e_?r6.current:r8.current;null==t||t.scrollIntoView({behavior:"smooth",block:"start"})},[e_]),a4=(0,i.useCallback)(()=>!ev&&window.innerWidth<1024,[ev]);(0,i.useEffect)(()=>{if(!window.visualViewport)return;let e=()=>{let e=window.visualViewport;if(!e)return void rX(0);let t=Math.max(0,Math.round(window.innerHeight-e.height-e.offsetTop));rX(e=>e===t?e:t)};return e(),window.visualViewport.addEventListener("resize",e),window.visualViewport.addEventListener("scroll",e),window.addEventListener("resize",e),()=>{var t,r;null==(t=window.visualViewport)||t.removeEventListener("resize",e),null==(r=window.visualViewport)||r.removeEventListener("scroll",e),window.removeEventListener("resize",e)}},[]),(0,i.useEffect)(()=>{!(window.innerWidth>=1024)&&(r3.current.has(rW)||(r3.current.add(rW),ag("quick_create_mobile_step_viewed",{step_name:1===rW?"face":2===rW?"text"===e_?"script":"audio":3===rW&&"text"===e_?"voice":"generate"})))},[e_,rW,ag]),(0,i.useEffect)(()=>{a4()&&1===rW&&rB&&ab&&(rG(2),setTimeout(()=>a3(2),120))},[ab,a4,rB,rW,a3]),(0,i.useEffect)(()=>{a4()&&"text"===e_&&3===rW&&a1&&rK&&(rG(4),setTimeout(()=>a3(4),120))},[a1,e_,a4,rK,rW,a3]),(0,i.useEffect)(()=>{a4()&&"text"!==e_&&2===rW&&a0&&rG(3)},[a0,e_,a4,rW]),(0,i.useEffect)(()=>{a4()&&rW>aw&&rG(aw)},[a4,aw,rW]);let a5=()=>{if(1===rW){if(ab){ag("quick_create_mobile_step_completed",{completed_step:1,completed_step_name:"face",completion_method:"upload"===to?"upload_or_restore":"template"}),rH(!0),a3(2);return}a3(1);return}if(2===rW){if(!a0){if(a3(2),"text"===e_){var e;null==(e=t2.current)||e.focus()}return}ag("quick_create_mobile_step_completed",{completed_step:2,completed_step_name:"text"===e_?"script":"audio",completion_method:e_}),"text"===e_?(rG(3),setTimeout(()=>a3(3),120)):(rG(aw),setTimeout(()=>a3(aw),120));return}if(3===rW)return void("text"===e_&&eA.trim()&&tr?(ag("quick_create_mobile_step_completed",{completed_step:3,completed_step_name:"voice",completion_method:"continue_to_generate"}),rZ(!0),rG(4),setTimeout(()=>a3(4),120)):"text"!==e_&&a2?aI():a3(3));a2?aI():a3(4)},a6=1===rW?eb("mobileChooseFace"):2===rW?"text"===e_?eb("mobileContinueScript"):eb("continueToGenerate"):3===rW&&"text"===e_?eb("continueToGenerate"):eb("generateVideo"),a8=ef("balance"),a9=1===rW?eb("mobileStepFace"):2===rW?"text"===e_?eb("mobileStepScript"):eb("mobileStepAudio"):3===rW&&"text"===e_?eb("mobileStepVoice"):eb("mobileStepGenerate"),a7=3===rW?"text"===e_?eb("mobilePreviewHint"):eb("mobileGenerateHint"):4===rW?eb("mobileGenerateHint"):eb("mobileFlowHint"),ie=function(){let{compact:e=!1,className:t="",emptyClassName:r="text-[11px] font-semibold text-white/60"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ai?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 ".concat(t),children:[(0,a.jsx)(b.A,{className:"h-3.5 w-3.5 shrink-0 ".concat(ah?"text-rose-400":"text-primary")}),(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs ".concat(e?"font-semibold":"font-medium"),children:[(0,a.jsx)("span",{className:"text-white/45",children:eb("estTotal")}),(0,a.jsx)("span",{className:e?"text-white":"text-white/75",children:(0,R.Ql)(ap)}),(0,a.jsx)("span",{className:"text-white/25",children:"/"}),(0,a.jsx)("span",{className:"text-white/45",children:a8}),(0,a.jsx)("span",{className:ah?"text-rose-300":"text-emerald-300",children:(0,R.Ql)(tV)})]})]}):(0,a.jsx)("span",{className:r,children:"—"})};return(0,a.jsxs)("div",{className:"w-full",children:[(0,a.jsx)(c.P.div,{id:"quick-create",translate:"no",initial:{opacity:0,y:20}
1,animate:{opacity:1,y:0},className:ev?"notranslate w-full overflow-hidden rounded-lg border border-border bg-card":"notranslate glass rounded-2xl sm:rounded-3xl border border-white/[0.08] overflow-hidden mx-auto w-full ".concat("wide"===p?"max-w-6xl":"max-w-5xl"),children:(0,a.jsxs)("div",{className:ev?"space-y-3 p-3 sm:p-4":"p-4 space-y-4 sm:p-5 sm:space-y-5",children:[(0,a.jsx)("div",{className:ev?"hidden":"lg:hidden",children:(0,a.jsx)("div",{className:"mb-3 h-1.5 overflow-hidden rounded-full bg-white/10",children:(0,a.jsx)("div",{className:"h-full rounded-full bg-gradient-to-r from-yellow-400 to-amber-500 transition-all duration-300",style:{width:"".concat(Math.max(25,25*rW),"%")}})})}),!el&&(0,a.jsx)("div",{className:"flex flex-wrap gap-2 ".concat(ec?"hidden lg:flex":""),children:H.map(e=>(0,a.jsx)(s(),{href:ae(e.href),onClick:()=>eN(e),className:"rounded-full border px-4 py-2 text-sm transition ".concat(ej.id===e.id?"border-primary/40 bg-primary/10 text-primary":"border-white/10 bg-white/5 text-white/70 hover:border-primary/30 hover:text-white"),children:eb(e.nameKey)},e.id))}),(0,a.jsxs)("div",{className:"grid ".concat(ev?"gap-3 sm:gap-4":"gap-5 ".concat("wide"===p?"lg:grid-cols-[1.2fr_1fr]":"lg:grid-cols-[1fr_1.2fr]")),children:[(0,a.jsx)("div",{className:ev?"min-w-0 space-y-3":"space-y-6",children:(0,a.jsxs)("div",{ref:r4,className:"".concat(ev?"min-w-0 space-y-3":"rounded-2xl border border-white/10 bg-[#2a2a2a] p-4 space-y-4 sm:p-5 sm:space-y-5"," transition-shadow ").concat(1!==rD||ev?"":"guide-glow-active"),children:[(0,a.jsxs)("div",{className:ev?"hidden":"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",children:[!ei&&(0,a.jsxs)("p",{className:"text-xs uppercase tracking-[0.2em] text-white/50",children:["1. ",eb("mobileStepFace")]}),(0,a.jsxs)("div",{className:"".concat(ev?"hidden":"inline-flex"," rounded-full border border-primary/25 bg-primary/10 px-3 py-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-primary lg:hidden"),children:["1. ",eb("mobileStepFace")]})]}),(0,a.jsxs)("div",{className:"grid gap-4",children:[(0,a.jsxs)("div",{className:"relative",onMouseEnter:()=>tl(!0),onMouseLeave:()=>tl(!1),children:[(0,a.jsxs)("label",{onDragOver:e=>{e.preventDefault(),tl(!0)},onDragLeave:()=>tl(!1),onDrop:e=>{e.preventDefault(),tl(!1),aT(e.dataTransfer.files[0])},className:"flex flex-col ".concat(ev?"items-center justify-center px-5 py-7 text-center sm:py-8":"gap-2 px-6 py-8"," rounded-2xl border-2 border-dashed text-sm cursor-pointer transition-all duration-300 ").concat(ti?"border-primary/80 bg-primary/10 shadow-[0_0_20px_rgba(240,201,85,0.05)]":"border-white/20 hover:border-primary/50"),children:[(0,a.jsx)("span",{className:"font-medium text-white sm:hidden",children:eb("mobileChooseFace")}),(0,a.jsx)("span",{className:"hidden font-medium text-white sm:inline",children:eb("dragDropVideo")}),(0,a.jsx)("span",{className:"".concat(ev?"mt-1":""," text-xs text-white/60"),children:eb("orClickToUpload")}),(0,a.jsx)(f.A,{className:"".concat(ev?"mt-2":""," h-4 w-4 transition-colors ").concat(ti?"text-primary":"text-white/40")}),(0,a.jsx)("input",{ref:rO,type:"file",accept:"image/*,video/*",className:"hidden",disabled:tS,onChange:e=>{var t;aT(null==(t=e.target.files)?void 0:t[0]),e.target.value=""},"aria-label":"Upload or replace media"})]}),ti&&!ev&&(0,a.jsxs)("div",{className:"absolute left-full top-0 ml-4 w-72 bg-[#262626] rounded-xl border border-white/10 shadow-xl p-4 z-10",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-white mb-2",children:eb("uploadRequirements")}),(0,a.jsxs)("ul",{className:"text-xs text-white/80 space-y-1 mb-3",children:[(0,a.jsxs)("li",{children:["• ",eb("supportedFormats")]}),(0,a.jsxs)("li",{children:["• ",eb("portraitLandscape")]}),(0,a.jsxs)("li",{children:["• ",eb("maxFileSize")]}),(0,a.jsxs)("li",{children:["• ",eb("onlyOneFace")]}),(0,a.jsxs)("li",{children:["• ",eb("clearFaceVisible")]})]}),(0,a.jsx)("div",{className:"text-sm font-medium text-white mb-2",children:eb("sampleImages")}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-2",children:M.F.slice(0,3).map(e=>(0,a.jsx)("div",{className:"aspect-[9/16] rounded-md overflow-hidden bg-[#333333]",children:(0,a.jsx)("img",{src:"9:16"===e4?e.portraitThumbUrl:e.landscapeThumbUrl,alt:e.label,className:"w-full h-full object-cover"})},e.id))})]})]}),(e9||"avatar"===to&&tr)&&(0,a.jsxs)("div",{className:"rounded-xl border border-white/10 bg-[#2a2a2a] p-3",children:[(0,a.jsx)("button",{type:"button",onClick:aA,disabled:tS,className:"block w-full rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/70 focus-visible:ring-offset-2 focus-visible:ring-offset-[#2a2a2a] disabled:cursor-wait","aria-label":"Replace selected media",children:"video"===te?(0,a.jsx)("video",{src:e9,className:"max-h-52 mx-auto rounded-lg"}):(0,a.jsx)("img",{src:e9||tr,alt:"Selected media preview",className:"max-h-52 mx-auto rounded-lg"})}),(0,a.jsx)("button",{type:"button",onClick:()=>{rQ("avatar"===to&&en?en:null),e7(null),ta(null),td(null),tt(null),rq(!0),localStorage.removeItem(Y)},className:"mt-3 text-xs text-white/60 hover:text-white",children:eb("remove")}),"image"===te&&(0,a.jsx)("button",{type:"button",onClick:()=>{a_()},className:"mt-3 ml-3 text-xs text-primary hover:text-primary/80",children:eb("crop")})]})]}),!e9&&!tr&&(!en||rV)&&(0,a.jsx)("div",{className:"space-y-3",children:ev?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 overflow-hidden",children:[(0,a.jsx)("button",{type:"button",onClick:()=>tZ(!0),className:"min-w-0 truncate text-left text-xs font-medium text-white/55 hover:text-white",children:eb("avatarLibrary")}),(0,a.jsx)("button",{type:"button",onClick:()=>tZ(!0),className:"shrink-0 whitespace-nowrap text-right text-xs font-semibold text-primary hover:text-primary/80",children:eb("viewFullLibrary")})]}),(0,a.jsx)("div",{className:"-mx-1 flex gap-2 overflow-x-auto px-1 pb-1",children:M.F.slice(0,8).map(e=>{let t="9:16"===e4?e.portraitUrl:e.landscapeUrl,r="9:16"===e4?e.portraitThumbUrl:e.landscapeThumbUrl;return(0,a.jsx)("button",{type:"button",className:"w-[58px] shrink-0 rounded-xl border border-white/10 bg-[#262626]/70 p-1 text-left transition hover:border-primary/40 sm:w-[64px]",onClick:()=>{e7(t),ta(t),tt("image"),td("avatar"),rH(!0),rq(!1),rQ(null),localStorage.removeItem(Y)},children:(0,a.jsx)("div",{className:"aspect-square overflow-hidden rounded-lg bg-[#333333]",children:(0,a.jsx)("img",{src:r,alt:"","aria-hidden":"true",className:"h-full w-full object-cover",loading:"lazy",decoding:"async"})})},e.id)})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[aH.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>e8(e),className:"rounded-full px-3 py-1 text-xs border ".concat(e6===e?"border-primary/40 bg-primary/10 text-primary":"border-white/10 text-white/60 hover:border-primary/30"),children:aQ[e]||e},e)),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:()=>e5("9:16"),className:"rounded-full px-2 py-1 text-xs border ".concat("9:16"===e4?"border-primary text-primary":"border-white/10 text-white/60"),children:"9:16"}),(0,a.jsx)("button",{type:"button",onClick:()=>e5("16:9"),className:"rounded-full px-2 py-1 text-xs border ".concat("16:9"===e4?"border-primary text-primary":"border-white/10 text-white/60"),children:"16:9"})]})]}),(0,a.jsx)("div",{className:"max-h-56 overflow-y-auto pr-1",children:(0,a.jsx)("div",{className:"grid grid-cols-3 gap-3",children:aK.map(e=>{let t="9:16"===e4?e.portraitUrl:e.landscapeUrl,r="9:16"===e4?e.portraitThumbUrl:e.landscapeThumbUrl,i="9:16"===e4?"aspect-[9/16]":"aspect-[16/9]";return(0,a.jsxs)("button",{type:"button",className:"rounded-xl border border-white/10 bg-[#262626]/70 p-2 text-left hover:border-primary/30",onClick:()=>{e7(t),ta(t),tt("image"),td("avatar"),rH(!0),rq(!1),rQ(null),localStorage.removeItem(Y)},children:[(0,a.jsx)("div",{className:"w-full ".concat(i," overflow-hidden rounded-md bg-[#333333]"),children:(0,a.jsx)("img",{src:r,alt:"","aria-hidden":"true",className:"h-full w-full object-cover",loading:"lazy",decoding:"async"})}),(0,a.jsx)("div",{className:"mt-2 text-xs text-white/60",children:e.label})]},e.id)})})}),(0,a.jsx)("button",{type:"button",onClick:()=>tZ(!0),className:"text-xs text-primary hover:text-primary/80",children:eb("viewFullLibrary")})]})})]})}
1),(0,a.jsxs)("div",{className:ev?"min-w-0 space-y-3":"space-y-6",children:[(0,a.jsxs)("div",{className:"".concat(ev?"block min-w-0 space-y-3":"hidden rounded-2xl border border-white/10 bg-[#2a2a2a] p-5 space-y-4 lg:block"," transition-shadow ").concat(2!==rD||ev?"":"guide-glow-active"),children:[(0,a.jsx)("div",{className:ev?"hidden":"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:!ei&&(0,a.jsxs)("p",{className:"text-xs uppercase tracking-[0.2em] text-white/60",children:["2. ",eh("model")]})}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsx)("select",{"aria-label":eh("model"),value:eS,onChange:e=>ek(e.target.value),className:"min-w-0 w-full rounded-xl border border-white/10 bg-[#262626] px-2 py-3 text-sm focus:outline-none focus:border-primary sm:px-4",children:Q.L4.filter(e=>!e.studioOnly&&("text"!==e_||e.supportsText)).map(e=>(0,a.jsx)("option",{value:e.id,children:e.label},e.id))}),(0,a.jsx)("select",{"aria-label":eh("resolution"),value:eY,onChange:e=>eX(e.target.value),className:"min-w-0 w-full rounded-xl border border-white/10 bg-[#262626] px-2 py-3 text-sm focus:outline-none focus:border-primary sm:px-4",children:an.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]})]}),(0,a.jsxs)("div",{ref:r5,className:"".concat(ev?"block min-w-0 space-y-3":"".concat(rW>=2?"block":"hidden"," rounded-2xl border border-white/10 bg-[#2a2a2a] p-5 space-y-5 lg:block")," transition-shadow ").concat(3!==rD||ev?"":"guide-glow-active"),children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[!ei&&(0,a.jsxs)("p",{className:"text-xs uppercase tracking-[0.2em] text-white/60",children:["3. ","text"===e_?eb("mobileStepScript"):eb("mobileStepAudio")]}),(0,a.jsxs)("button",{type:"button",onClick:()=>a3(2),className:"".concat(ev?"hidden":"inline-flex"," rounded-full border border-primary/25 bg-primary/10 px-3 py-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-primary lg:hidden"),children:["2. ","text"===e_?eb("mobileStepScript"):eb("mobileStepAudio")]}),(0,a.jsx)("div",{className:"flex gap-2 flex-wrap",children:[{id:"text",label:eb("text")},{id:"audio",label:eb("audio")},{id:"record",label:eb("record")}].map(e=>(0,a.jsx)("button",{type:"button","aria-pressed":e_===e.id,className:"rounded-full px-3 py-1 text-xs border ".concat(e_===e.id?"border-primary/40 bg-primary/10 text-primary":"border-white/10 text-white/60 hover:border-primary/30"),onClick:()=>{"text"===e.id&&as&&ek("lipsyncx-2-fast"),"record"===e.id&&"record"!==e_&&(tN(null),rF(null),ty(null),tM(null),rj(null)),eC(e.id)},children:e.label},e.id))})]}),"text"===e_&&(0,a.jsxs)("div",{className:"space-y-4",children:[!eo&&(0,a.jsxs)("div",{className:"rounded-2xl border border-white/10 bg-[#262626] p-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-white",children:aG}),(0,a.jsx)("p",{className:"text-xs text-white/50",children:aJ})]}),(0,a.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:aW.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>{eU(e.script)},className:"rounded-full border border-white/10 bg-white/5 px-3 py-1.5 text-xs text-white/75 transition hover:border-primary/40 hover:bg-primary/10 hover:text-white",children:e.label},e.id))})]}),(0,a.jsx)("textarea",{"aria-label":eb("text"),ref:t2,value:eA,onChange:e=>{eU(e.target.value)},onSelect:e=>{let t=e.target;t3.current={start:t.selectionStart,end:t.selectionEnd}},placeholder:eT,className:"w-full rounded-2xl border border-white/10 bg-[#333333] p-4 text-sm text-white focus:outline-none focus:border-primary min-h-[160px]"}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("div",{className:"".concat(ev?"flex":"hidden lg:flex"," flex-wrap items-center gap-2"),children:[(0,a.jsxs)("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-medium transition ".concat("translate"===t0?"border-primary/70 bg-primary/12 text-white":"border-white/10 bg-[#2a2a2a] text-white/70 hover:border-primary/35 hover:text-white"),onClick:()=>t1("translate"===t0?null:"translate"),"aria-label":"Translate",children:[(0,a.jsx)(w.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{children:eb("translate")})]}),(0,a.jsxs)("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-medium transition ".concat(tJ?"border-primary/70 bg-primary/12 text-white":rg?"border-primary bg-primary/15 text-white animate-pulse shadow-[0_0_0_1px_rgba(255,212,0,0.22)]":"border-white/10 bg-[#2a2a2a] text-white/70 hover:border-primary/35 hover:text-white"),onClick:()=>{aP()},"aria-label":"AI polish",disabled:tJ||!eA.trim(),children:[tJ?(0,a.jsx)(g.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(v.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{children:tJ?eb("generating"):eb("aiScript")})]}),(0,a.jsxs)("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-medium transition ".concat("pause"===t0?"border-primary/70 bg-primary/12 text-white":"border-white/10 bg-[#2a2a2a] text-white/70 hover:border-primary/35 hover:text-white"),onClick:()=>t1("pause"===t0?null:"pause"),"aria-label":"Add pauses",children:[(0,a.jsx)(y.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{children:eb("addPauses")})]})]}),(0,a.jsxs)("div",{className:ev?"hidden":"relative group",children:[ai?ie():(0,a.jsx)("span",{className:"text-[11px] font-semibold text-white/60",children:"—"}),(0,a.jsxs)("div",{className:"pointer-events-none absolute left-1/2 bottom-full mb-2 w-[240px] max-w-[80vw] -translate-x-1/2 roun
1ded-xl border border-white/10 bg-[#262626] p-3 text-xs text-white/60 shadow-lg opacity-0 translate-y-1 transition group-hover:opacity-100 group-hover:translate-y-0 sm:left-auto sm:right-0 sm:translate-x-0",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{children:eb("billingUnit")}),(0,a.jsxs)("span",{children:[(0,R.Ql)(am)," credits / ",G.PJ,"s"]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{children:eb("billingUnits")}),(0,a.jsx)("span",{children:ai?"".concat(au):"—"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{children:eb("estimatedLength")}),(0,a.jsx)("span",{children:ai?"".concat(ai,"s"):"—"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{children:eb("estTotal")}),(0,a.jsx)("span",{children:ai?"".concat((0,R.Ql)(ap)," credits"):"—"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{children:a8}),(0,a.jsxs)("span",{className:ah?"text-rose-300":"text-emerald-300",children:[(0,R.Ql)(tV)," credits"]})]})]}),(0,a.jsx)("div",{className:"mt-2 text-[11px] text-white/40",children:eb("usesRealAudioDuration")})]})]})]})]}),"audio"===e_&&(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("div",{className:"relative",onMouseEnter:()=>tn(!0),onMouseLeave:()=>tn(!1),children:(0,a.jsxs)(c.P.label,{onDragOver:e=>{e.preventDefault(),tn(!0)},onDragLeave:()=>tn(!1),onDrop:e=>{e.preventDefault(),tn(!1),aU(e.dataTransfer.files[0])},animate:tj||tS?{}:{borderColor:ts?"rgba(240,201,85,0.8)":["rgba(255,255,255,0.1)","rgba(240,201,85,0.4)","rgba(255,255,255,0.1)"],backgroundColor:ts?"rgba(240,201,85,0.1)":["rgba(255,255,255,0)","rgba(240,201,85,0.05)","rgba(255,255,255,0)"],boxShadow:ts?"0 0 20px rgba(240,201,85,0.05)":"0 0 0px rgba(0,0,0,0)"},transition:{repeat:tj||tS||ts?0:1/0,duration:3,ease:"easeInOut"},className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed px-5 ".concat(ev?"py-8":"py-10"," text-sm transition-all duration-300 ").concat(tS?"cursor-wait border-primary/40 bg-primary/5 opacity-90":"cursor-pointer"," ").concat(tj||tS?ts?"border-primary/80 bg-primary/10 shadow-[0_0_20px_rgba(240,201,85,0.05)]":"border-white/10 hover:border-primary/50 hover:bg-white/5":""),children:[tS?(0,a.jsx)(g.A,{className:"h-8 w-8 text-primary mb-2 animate-spin"}):(0,a.jsx)(f.A,{className:"h-8 w-8 mb-2 transition-colors ".concat(ts?"text-primary":tj?"text-white/40":"text-primary/60")}),(0,a.jsx)("span",{className:"max-w-full break-all text-center text-white font-medium",children:tS?eb("uploading"):tv||eb("clickToUploadAudio")}),(0,a.jsx)("span",{className:"mt-1 max-w-full break-words text-center text-xs leading-relaxed text-white/40",children:eb("supportedAudioFormats")}),(0,a.jsx)("input",{type:"file",accept:"audio/*",className:"hidden",disabled:tS,onChange:e=>{var t;aU(null==(t=e.target.files)?void 0:t[0]),e.target.value=""}})]})}),tj&&(0,a.jsxs)("div",{className:"rounded-xl border border-white/10 bg-black/25 p-3",children:[(0,a.jsxs)("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-white/70",children:eb("previewUploadedAudio")}),(0,a.jsx)("span",{className:"text-[11px] text-white/40",children:eb("replaceAudioHint")})]}),(0,a.jsx)("audio",{ref:r_,src:tj||void 0,controls:!0,preload:"metadata",className:"h-10 w-full min-w-0 accent-primary",onPlay:()=>{rE(!0),rZ(!0),ag("quick_create_preview_clicked",{preview_type:"uploaded_audio_controls"})},onPause:()=>rE(!1)})]})]}),"record"===e_&&(0,a.jsxs)("div",{className:"rounded-xl border border-dashed border-white/10 p-4 space-y-3 text-sm text-white/60",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,a.jsxs)(A.$,{size:"sm",variant:rT?"default":"outline",className:rT?"":"border-white/30 text-white hover:bg-white/10 hover:border-white/50",onClick:rT?az:aq,children:[(0,a.jsx)(j.A,{className:"h-4 w-4 mr-2"}),rT?eb("stopRecording"):eb("startRecording")]}),rU&&(0,a.jsx)("button",{type:"button",onClick:()=>{let e=r_.current;if(e){if(ag("quick_create_preview_clicked",{preview_type:"uploaded_audio"}),rZ(!0),rC){e.pause(),rE(!1);return}e.play().then(()=>rE(!0)).catch(()=>{rE(!1)})}},className:"h-9 w-9 rounded-xl border border-white/10 flex items-center justify-center text-white/60 hover:text-white hover:border-primary/40","aria-label":"Preview recorded audio",children:rC?(0,a.jsx)(N.A,{className:"h-4 w-4"}):(0,a.jsx)(S.A,{className:"h-4 w-4"})})]}),rR&&(0,a.jsx)("div",{className:"text-xs text-red-500",children:rR}),rU&&(0,a.jsx)("audio",{ref:r_,src:rU,onEnded:()=>rE(!1)})]}),2===rW&&"text"===e_&&!ev&&(0,a.jsx)("div",{className:"lg:hidden",children:(0,a.jsx)(A.$,{type:"button",size:"lg",className:"w-full bg-primary text-[#1a1a1a] hover:bg-primary/90",onClick:a5,disabled:!a0||!tr,children:"text"===e_?eb("mobileContinueScript"):eb("continueToGenerate")})}),(0,a.jsxs)("div",{ref:r9,className:ev?"hidden":"rounded-2xl border border-white/10 bg-[#262626] p-3 lg:hidden",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>r$(e=>{let t=!e;return t&&ag("quick_create_mobile_advanced_opened"),t}),className:"flex w-full items-center justify-between text-left",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-white",children:eb("mobileAdvanced")}),(0,a.jsx)("span",{className:"text-xs text-white/50",children:rJ?eb("close"):eb("mobileShow")})]}),rJ&&(0,a.jsxs)("div",{className:"mt-3 space-y-3",children:["text"===e_?(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-3",children:[(0,a.jsxs)("button",{type:"button",className:"flex items-center gap-2 rounded-xl border px-3 py-3 text-sm font-medium transition ".concat("translate"===t0?"border-primary/70 bg-primary/15 text-white shadow-[0_0_0_1px_rgba(255,212,0,0.18)]":"border-white/10 bg-[#202020] text-white/75 hover:border-primary/35 hover:bg-[#262626] hover:text-white"),onClick:()=>t1("translate"===t0?null:"translate"),children:[(0,a.jsx)(w.A,{className:"h-4 w-4 ".concat("translate"===t0?"text-primary":"text-white/45")}),eb("translate")]}),(0,a.jsxs)("button",{type:"button",className:"flex items-center gap-2 rounded-xl border px-3 py-3 text-sm font-medium transition ".concat(tJ?"border-primary/70 bg-primary/15 text-white shadow-[0_0_0_1px_rgba(255,212,0,0.18)]":rg?"border-primary bg-primary/15 text-white animate-pulse shadow-[0_0_0_1px_rgba(255,212,0,0.22)]":"border-white/10 bg-[#202020] text-white/75 hover:border-primary/35 hover:bg-[#262626] hover:text-white"),onClick:()=>{aP()},disabled:tJ||!eA.trim(),children:[tJ?(0,a.jsx)(g.A,{className:"h-4 w-4 animate-spin text-primary"}):(0,a.jsx)(k.A,{className:"h-4 w-4 text-white/45"}),tJ?eb("generating"):eb("aiScript")]}),(0,a.jsxs)("button",{type:"button",className:"flex items-center gap-2 rounded-xl border px-3 py-3 text-sm font-medium transition ".concat("pause"===t0?"border-primary/70 bg-primary/15 text-white shadow-[0_0_0_1px_rgba(255,212,0,0.18)]":"border-white/10 bg-[#202020] text-white/75 hover:border-primary/35 hover:bg-[#262626] hover:text-white"),onClick:()=>t1("pause"===t0?null:"pause"),children:[(0,a.jsx)(y.A,{className:"h-4 w-4 ".concat("pause"===t0?"text-primary":"text-white/45")}),eb("addPauses")]})]}):null,(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsx)("select",{value:eS,onChange:e=>ek(e.target.value),className:"w-full rounded-xl border border-white/10 bg-[#1f1f1f] px-4 py-3 text-sm focus:outline-none focus:border-primary",children:Q.L4.filter(e=>!e.studioOnly&&("text"!==e_||e.supportsText)).map(e=>(0,a.jsx)("option",{value:e.id,children:e.label},e.id))}),(0,a.jsx)("select",{value:eY,onChange:e=>eX(e.target.value),className:"w-full rounded-xl border border-white/10 bg-[#1f1f1f] px-4 py-3 text-sm focus:outline-none focus:border-primary",children:an.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]})]})]}),"text"===e_&&(0,a.jsxs)("div",{className:"space-y-3",children:["translate"===t0&&(0,a.jsxs)("div",{className:"rounded-xl border border-white/10 bg-[#2a2a2a] p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-white",children:eb("targetLanguage")}),(0,a.jsx)("select",{className:"w-full rounded-xl border border-white/10 bg-[#262626] px-3 py-2 text-sm focus:outline-none focus:border-primary",value:e0,onChange:e=>e1(e.target.value),children:F.xf.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]}),(0,a.jsxs)(A.$,{size:"sm",variant:"default",className:"w-full justify-center gap-2 bg-primary text-[#1a1a1a] hover:bg-primary/90 sm:w-auto 
1sm:min-w-[140px]",onClick:aM,disabled:tB,children:[(0,a.jsx)(w.A,{className:"h-4 w-4"}),tB?eb("translating"):eb("translate")]})]}),"pause"===t0&&(0,a.jsxs)("div",{className:"rounded-xl border border-white/10 bg-[#2a2a2a] p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"block text-xs font-medium text-white",children:eb("pauseIntensity")}),(0,a.jsxs)("select",{className:"w-full rounded-xl border border-white/10 bg-[#262626] px-3 py-2 text-sm focus:outline-none focus:border-primary",value:e2,onChange:e=>e3(e.target.value),children:[(0,a.jsx)("option",{value:"light",children:eb("light")}),(0,a.jsx)("option",{value:"medium",children:eb("medium")}),(0,a.jsx)("option",{value:"heavy",children:eb("heavy")})]})]}),(0,a.jsxs)(A.$,{size:"sm",variant:"default",className:"w-full justify-center gap-2 bg-primary text-[#1a1a1a] hover:bg-primary/90 sm:w-auto sm:min-w-[140px]",onClick:()=>{if("text"!==e_)return;let e=(0,U.mR)(e2),t=t2.current;if(!t)return void eU(t=>"".concat(t," ").concat(e).trim());let r=Number.isFinite(t3.current.start)?t3.current.start:eA.length,a=Number.isFinite(t3.current.end)?t3.current.end:r;eU("".concat(eA.slice(0,r)).concat(e).concat(eA.slice(a))),requestAnimationFrame(()=>{t.focus();let a=r+e.length;t.setSelectionRange(a,a),t3.current={start:a,end:a}})},children:[(0,a.jsx)(y.A,{className:"h-4 w-4"}),eb("addPause")]})]})]}),(0,a.jsx)("div",{ref:r6,className:"".concat(ev?"grid":"".concat(rW>=3?"grid":"hidden"," lg:grid")," gap-4"),children:"text"===e_&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>a3(3),className:"".concat(ev?"hidden":"mb-3 inline-flex"," rounded-full border border-primary/25 bg-primary/10 px-3 py-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-primary lg:hidden"),children:["3. ",eb("mobileStepVoice")]}),(0,a.jsx)("label",{className:"block text-sm font-medium text-white mb-2",children:eb("voice")}),(0,a.jsxs)("div",{className:"grid min-w-0 grid-cols-2 gap-2",children:[(0,a.jsxs)("select",{"aria-label":eb("voiceGender"),value:eD,onChange:e=>eM(e.target.value),disabled:!eI.length,className:"min-w-0 w-full rounded-lg border border-border bg-muted px-3 py-2 text-sm focus:outline-none focus:border-primary",children:[(0,a.jsxs)("option",{value:"all",children:[eb("voiceGender"),": ",eb("all")]}),(0,a.jsx)("option",{value:"female",disabled:!eJ.some(e=>"female"===e.gender),children:eb("femaleVoice")}),(0,a.jsx)("option",{value:"male",disabled:!eJ.some(e=>"male"===e.gender),children:eb("maleVoice")})]}),(0,a.jsx)("select",{"aria-label":eb("targetLanguage"),value:eP,onChange:e=>eO(e.target.value),disabled:!eI.length,className:"min-w-0 w-full rounded-lg border border-border bg-muted px-3 py-2 text-sm focus:outline-none focus:border-primary",children:["all",...Array.from(new Set((eI.length?eI:K).map(e=>e.language).filter(e=>!!e)))].filter((e,t,r)=>r.indexOf(e)===t).sort((e,t)=>e.localeCompare(t)).map(e=>(0,a.jsx)("option",{value:e,children:"all"===e?eb("all"):e},e))})]}),(0,a.jsxs)("div",{className:"mt-2 flex min-w-0 items-center gap-2",children:[(0,a.jsxs)("select",{"aria-label":eb("voice"),className:"min-w-0 w-full lg:flex-1 rounded-xl border border-white/10 bg-[#262626] px-4 py-2 text-sm focus:outline-none focus:border-primary",value:eF,onChange:e=>eR(e.target.value),disabled:!eI.length,children:[!eI.length&&(0,a.jsx)("option",{value:"",children:eV?eb("loadingVoices"):eb("voice")}),e$.map(e=>(0,a.jsxs)("option",{value:e.id,children:[e.name,e.gender?" - ".concat(eb("female"===e.gender?"femaleVoice":"maleVoice")):"",e.language?" (".concat(e.language,")"):""]},e.id))]}),(0,a.jsx)("button",{type:"button",onClick:()=>{let e=t4.current;if(!e)return;let t=(eI.length?eI:[]).find(e=>e.id===eF),r=null==t?void 0:t.sampleUrl;if(r){if(ag("quick_create_preview_clicked",{preview_type:"voice_sample",voice_id:eF}),e.src!==r&&(e.src=r),t5){e.pause(),t6(!1);return}e.play().then(()=>t6(!0)).catch(()=>{t6(!1)})}},disabled:!(null==(l=eI.find(e=>e.id===eF))?void 0:l.sampleUrl),className:"h-10 w-10 shrink-0 rounded-xl border border-white/10 flex items-center justify-center text-white/60 hover:text-white hover:border-primary/40 disabled:opacity-40","aria-label":eb("previewVoice"),title:eb("previewVoice"),children:t5?(0,a.jsx)(N.A,{className:"h-4 w-4"}):(0,a.jsx)(S.A,{className:"h-4 w-4"})}),(0,a.jsx)("audio",{ref:t4,onEnded:()=>t6(!1),onError:()=>t6(!1)})]}),ez&&(0,a.jsxs)("div",{role:"status",className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-destructive",children:[(0,a.jsx)("span",{children:eb("voicesLoadFailed")}),(0,a.jsxs)("button",{type:"button",onClick:()=>eG(e=>e+1),className:"inline-flex items-center gap-1 text-primary",children:[(0,a.jsx)(_.A,{className:"h-3 w-3"}),eb("retry")]})]}),(0,a.jsxs)("div",{className:"mt-3",children:[(0,a.jsxs)("label",{className:"block text-xs font-medium text-white/80 mb-2",children:[eh("speed")," ",(0,a.jsxs)("span",{className:"text-white/40",children:["(",eB.toFixed(2),"x)"]})]}),(0,a.jsx)("input",{type:"range",min:.7,max:1.2,step:.05,value:eB,onChange:e=>eH(Number(e.target.value)),className:"w-full accent-primary"})]})]})}),"text"===e_&&(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:eb("characterCount",{count:ex.number(eA.length)})})]}),(0,a.jsxs)("div",{ref:r8,className:"".concat(ev?"flex min-w-0":"".concat(rW>=aw?"flex":"hidden"," lg:flex lg:flex-row lg:justify-end")," flex-col gap-2 pb-2 lg:pb-0"),children:[(0,a.jsxs)("button",{type:"button",onClick:()=>a3(aw),className:"".concat(ev?"hidden":"mb-2 inline-flex"," rounded-full border border-primary/25 bg-primary/10 px-3 py-1 text-[11px] font-semibold uppercase tracking-[0.18em] text-primary lg:hidden"),children:[aw,". ",eb("mobileStepGenerate")]}),(!ev||ap>0)&&(0,a.jsx)("div",{className:"".concat(ev?"":"lg:hidden"," rounded-lg border px-3 py-2 text-xs ").concat(ah?"border-rose-500/25 bg-rose-500/10 text-rose-100":"border-white/10 bg-[#262626] text-white/70"),children:ie({compact:!0,emptyClassName:"font-semibold text-white"})}),"text"===e_&&(0,a.jsx)(A.$,{size:"lg",variant:"outline",className:"w-full border-primary/20 bg-[#333333] text-white gap-2 lg:min-w-[220px] ".concat(4===rD?"guide-glow-active":""),onClick:()=>{aV()},disabled:t8||rp||!eA.trim()||!eF,children:t8||rp?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g.A,{className:"w-4 h-4 animate-spin"}),rp?eb("preparingAiComparison"):eb("generatingAudio")]}):(0,a.jsxs)(a.Fragment,{children:[t7?(0,a.jsx)(N.A,{className:"w-4 h-4"}):(0,a.jsx)(S.A,{className:"w-4 h-4"}),eb("previewAudioFree")]})}),(()=>{let e=!t_&&!tS&&tr&&("text"===e_?eA.trim()&&eF:tj)?null:tr?"audio"!==e_||tj?"text"!==e_||eA.trim()?"text"!==e_||eF?null:eb("voice"):eb("hintEnterScript"):eb("hintSelectAudio"):eb("hintUploadImage");return(0,a.jsx)(A.$,{size:"lg",variant:"default",className:"w-full gap-2 bg-accent text-[#1a1a1a] hover:bg-accent/90 shadow-sm shadow-accent/20 lg:min-w-[220px] ".concat(5===rD?"guide-glow-active":""),onClick:aI,disabled:t_||tS||!tr||("text"===e_?!eA.trim()||!eF:!tj),children:t_?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g.A,{className:"w-4 h-4 animate-spin"}),eb("generatingVideoBtn")]}):e?(0,a.jsx)("span",{className:"text-xs opacity-90",children:e}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k.A,{className:"w-4 h-4"}),eb("generateVideo")]})})})(),tE&&(0,a.jsx)(s(),{href:ae("/library"),className:"mt-3 text-sm text-primary hover:underline flex items-center justify-center gap-1",children:eb("viewInMyCreations")}),(0,a.jsx)("audio",{ref:rN,src:rt||void 0,onEnded:()=>re(!1)})]})]})]})]})}),rW<aw&&!ev&&(0,a.jsx)("div",{className:"fixed inset-x-0 bottom-0 z-40 border-t border-white/10 bg-[#111111]/95 p-3 pb-safe backdrop-blur transition-[bottom] duration-150 lg:hidden",style:rY>0?{bottom:"".concat(rY,"px")}:void 0,children:(0,a.jsxs)("div",{className:"mx-auto flex max-w-6xl items-center gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-white/45",children:[eb("mobileStepLabel")," ",rW,"/",aw]}),(0,a.jsx)("p",{className:"truncate text-sm font-medium text-white",children:a9}),(0,a.jsx)("p",{className:"mt-1 line-clamp-1 text-xs leading-4 text-white/45 sm:line-clamp-none",children:a7}),(0,a.jsx)("div",{className:"mt-1 text-[11px] ".concat(ah?"text-rose-200":"text-primary/90"),children:ie({compact:!0,emptyClassName:ah?"text-rose-200":"text-primary/90"})})]}),(0,a.jsx)(A.$,{size:"lg",className:"min-w-[160px] bg-primary text-[#1a1a1a] hover:bg-primary/90 sm:min-w-[180px]",onClick:a5,disabled:2===rW&&"text"!==e_?!tj||!tr:3===rW?"text"===e_?!eA.trim()||!tr:!tj||!tr:4===rW&&(t_||tS||!a2),children:a6})]})}),!ev&&(0,a.jsxs)("div",{className:"hidden lg:block",children:[(0,a.jsx)("div",{className:"mt-6 grid grid-cols-3 gap-6 text-sm max-w-4xl mx-auto",children:[{label:eb("avgRenderTime"),value:eb("avgRenderTimeValue")},{label:eb("languagesSupported"),value:eb("languagesSupportedValue")},{label:eb("creatorsOnboarded"),value:eb("creatorsOnboardedValue")}].map(e=>(0,a.jsxs)("div",{className:"rounded-2xl bg-[#2a2a2a] border border-white/10 px-4 py-3 text-center",children:[(0,a.jsx)("div",{className:"text-white/60",children:e.label}),(0,a.jsx)("div",{className:"font-display text-xl text-white",children:e.value})]},e.label))}),(0,a.jsxs)("div",{className:"mt-6",children:[(0,a.jsx)("p",{className:"text-xs uppercase tracking-[0.2em] text-white/60 mb-3 text-center",children:eb("trustedByTeams")}),(0,a.jsx)("div",{className:"flex flex-wrap gap-3 justify-center",children:["StudioBlend","AudioNova","CourseWave","Mintly","VisionSpark"].map(e=>(0,a.jsx)("span",{className:"rounded-full border border-white/10 bg-[#2a2a2a] px-4 py-2 text-sm text-white/80",children:e},e))})]})]}),tK&&(0,a.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center p-4",children:[(0,a.jsx)("button",{type:"button",className:"absolute inset-0 bg-black/40",onClick:()=>tZ(!1),"aria-label":"Close avatar library"}),(0,a.jsxs)("div",{className:"relative w-[min(1000px,95vw)] max-h-[85vh] overflow-hidden rounded-2xl border border-white/10 bg-[#1a1a1a] p-6 shadow-xl",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4 border-b border-white/10",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-base font-semibold text-white",children:eb("avatarLibrary")}),(0,a.jsx)("p",{className:"text-xs text-white/60",children:eb("browseCategories")})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("button",{type:"button",onClick:()=>e5("9:16"),className:"rounded-full px-2 py-1 text-xs border ".concat("9:16"===e4?"border-primary text-primary":"border-white/10"),children:"9:16"}),(0,a.jsx)("button",{type:"button",onClick:()=>e5("16:9"),className:"rounded-full px-2 py-1 text-xs border ".concat("16:9"===e4?"border-primary text-primary":"border-white/10"),children:"16:9"}),(0,a.jsx)(A.$,{size:"sm",variant:"outline",onClick:()=>tZ(!1),children:eb("close")})]})]}),(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-2 border-b border-white/10 pb-3",children:aZ.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>tX(e),className:"rounded-full px-3 py-1 text-xs border transition ".concat(tY===e?"border-primary/40 bg-primary/10 text-primary":"border-white/10 text-white/60 hover:border-primary/30"),children:e},e))}),(0,a.jsx)("div",{className:"mt-4 max-h-[60vh] overflow-y-auto pr-2",children:(0,a.jsx)("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:aX.map(e=>{let t="9:16"===e4?e.portraitUrl:e.landscapeUrl,r="9:16"===e4?e.portraitThumbUrl:e.landscapeThumbUrl,i="9:16"===e4?"aspect-[9/16]":"aspect-[16/9]";return(0,a.jsxs)("button",{type:"button",className:"rounded-xl border border-white/10 bg-[#262626]/70 p-2 text-left hover:border-primary/30",onClick:()=>{e7(t),ta(t),tt("image"),td("avatar"),rH(!0),tZ(!1),rq(!1),rQ(null),localStorage.removeItem(Y)},children:[(0,a.jsx)("div",{className:"w-full ".concat(i," overflow-hidden rounded-md bg-[#333333]"),children:(0,a.jsx)("img",{src:r,alt:"","aria-hidden":"true",className:"h-full w-full object-cover",loading:"lazy",decoding:"async"})}),(0,a.jsx)("div",{className:"mt-2 text-xs text-white/60",children:e.label})]},e.id)})})})]})]})]}),ru&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"w-full max-w-4xl rounded-2xl border border-white/10 bg-[#161616] p-6 shadow-2xl",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Use AI to beautify tone before preview?"}),(0,a.jsx)("p",{className:"mt-2 text-sm leading-6 text-white/65",children:"We generated an AI-polished version of your script for a more expressive read. Choose which version to preview."})]}),(0,a.jsx)("button",{type:"button",onClick:()=>{rm(!1),ro(rh),rc("original"),aD()},className:"rounded-full p-2 text-white/55 transition hover:bg-white/10 hover:text-white","aria-label":"Close AI preview comparison",children:(0,a.jsx)(C.A,{className:"h-5 w-5"})})]}),(0,a.jsxs)("div",{className:"mt-6 grid gap-4 lg:grid-cols-2",children:[(0,a.jsxs)("div",{className:"rounded-2xl border border-white/10 bg-[#202020] p-4",children:[(0,a.jsx)("div",{className:"mb-3 text-xs font-semibold uppercase tracking-[0.18em] text-white/45",children:"Original"}),(0,a.jsx)("div",{className:"max-h-[260px] overflow-y-auto whitespace-pre-wrap text-sm leading-6 text-white/85",children:rh})]}),(0,a.jsxs)("div",{className:"rounded-2xl border border-primary/30 bg-primary/10 p-4",children:[(0,a.jsxs)("div",{className:"mb-3 flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.18em] text-primary",children:[(0,a.jsx)(k.A,{className:"h-4 w-4"}),"AI Beautified"]}),(0,a.jsx)("div",{className:"max-h-[260px] overflow-y-auto whitespace-pre-wrap text-sm leading-6 text-white",children:rf})]})]}),(0,a.jsxs)("div",{className:"mt-6 flex flex-col gap-3 sm:flex-row sm:justify-end",children:[(0,a.jsx)(A.$,{variant:"outline",onClick:()=>{rm(!1),ro(rh),rc("original"),setTimeout(()=>{aV()},0)},children:"Preview original"}),(0,a.jsxs)(A.$,{variant:"default",className:"gap-2 bg-primary text-[#1a1a1a] hover:bg-primary/90",onClick:()=>{rm(!1),ro(rh),rc("beautified"),setTimeout(()=>{aV()},0)},children:[(0,a.jsx)(k.A,{className:"h-4 w-4"}),"Preview AI beautified"]})]})]})}),tc&&tb&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"relative w-full max-w-2xl bg-[#1a1a1a] rounded-2xl overflow-hidden shadow-2xl",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[(0,a.jsxs)("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[(0,a.jsx)(E.A,{className:"h-5 w-5"}),eb("cropImage")]}),(0,a.jsx)("button",{onClick:ak,className:"p-2 rounded-full hover:bg-white/10 transition-colors",children:(0,a.jsx)(C.A,{className:"h-5 w-5 text-white/70"})})]}),(0,a.jsx)("div",{className:"p-4 bg-[#2a2a2a]",children:(0,a.jsx)("div",{className:"relative max-h-[60vh] overflow-hidden rounded-lg",children:(0,a.jsx)(u.Ay,{crop:tm,onChange:(e,t)=>
1tp(t),onComplete:e=>th(e),aspect:void 0,className:"max-h-[60vh]",children:(0,a.jsx)("img",{ref:tw,src:tb,alt:eb("cropPreview"),onLoad:e=>{let{width:t,height:r}=e.currentTarget;tp({unit:"%",x:5,y:5,width:90,height:90})},className:"max-h-[60vh] mx-auto object-contain"})})})}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-white/10",children:[(0,a.jsx)(A.$,{variant:"outline",onClick:ak,children:eb("cancel")}),(0,a.jsxs)(A.$,{variant:"default",onClick:aS,className:"gap-2",children:[(0,a.jsx)(T.A,{className:"h-4 w-4"}),eb("apply")]})]})]})}),(0,a.jsx)(L.T,{isOpen:tA,onClose:()=>tU(!1),onAutoOpen:()=>tU(!0),context:aL,trackingContext:{area:"quick_create",locale:ep,page_path:eu,variant:p,input_mode:e_,has_media:ab,has_script:af,has_audio:!!tj,estimated_cost_cents:ap||0}}),(0,a.jsx)(P.Z,{isOpen:tF&&!!tI,locale:ep,surface:"quick_create",inputMode:"record"===tP&&"record"===e_?"record":e_,billingResolution:ad,recovery:tI,audioSourceUrl:tD||rU||tj,audioFileName:tv,script:eA,shortenLanguage:e0,shortenEmotion:eK,voicePreviewConfig:{language:(0,F.ZP)(e0),speaker:eF,speed:eB,emotion:eK},onClose:()=>{tR(!1),tL(null)},onRecharge:()=>{tR(!1),tL(null),tU(!0)},onRenderPreview:async()=>{tI&&(tR(!1),await aR(tI))},onApplyAudioCrop:async e=>{let{blob:t,durationSeconds:r,fileName:a}=e,i=new File([t],a.replace(/\.\w+$/,"")+"-trimmed.wav",{type:"audio/wav"}),l=URL.createObjectURL(i),s=await aC(i);rj(r),ty(i.name),tN(s),tM(l),tO("audio"),"record"===e_&&(eC("audio"),rF(null)),rE(!1)},onApplyShortenedText:e=>{eU(e)},onTrackEvent:ag}),(0,a.jsx)(O.M,{isOpen:tW,onClose:()=>{tG(!1),window.sessionStorage.removeItem(et)},context:{title:eb("signInToGenerateTitle"),subtitle:eb("signInToGenerateSubtitle"),autoContinue:!0}})]})}}}]);

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.