PageSourceSearch

https://mstudio.ai/build/assets/MotionEditor.CyEx2Eo8.js

js mstudio.ai collected 2026-10-05 12:18:18 UTC 104,253 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CharacterModal.CEeDdccH.js","assets/dist.D4237Rk6.js","assets/inertia.BE4YqsTM.js","assets/http.DWpeO7Ui.js","assets/rolldown-runtime.C1f3BsDW.js","assets/icons.ChOq_Y4q.js","assets/dist.CoNAZqlp.js","assets/dist.DxccqHSW.js","assets/react-core.CAMe6Z4j.js","assets/dist.BhzTvz6X.js","assets/dist.DbqQa_sy.js","assets/es2015.Cr2X04_P.js","assets/dist.B-JETxGF.js","assets/dist.zmknLG-d.js","assets/utils.CgzVjNgC.js","assets/state.L8kQliOB.js","assets/CharacterModal.ehp1Mvsj.js","assets/entry-client.DX3aUoe5.js","assets/app.BpxBHA-A.css","assets/PromptReferencesRow.Dil-fpz5.js","assets/section-label.Cq6cQeLu.js","assets/BestPracticeTip.vi3UQdmd.js","assets/Tooltip.D5vWPvw2.js","assets/dialog.Bb7MGeDP.js","assets/input.GzdAc1Aj.js","assets/segmented.DHcH2lTJ.js","assets/bestPractices.CtL0Jx0E.js","assets/characterMention.DcxgzALo.js","assets/AssetGalleryModal.DBIZWl9v.js","assets/dist.D4LCotyC.js","assets/dist.C1cc-Zbw.js","assets/select.vYEvBl4E.js","assets/AssetGalleryModal.DteaM05Z.js","assets/imageValidation.BrtKjMLv.js"])))=>i.map(i=>d[i]);
2import{r as er}from"./rolldown-runtime.C1f3BsDW.js";import"./inertia.BE4YqsTM.js";import"./http.DWpeO7Ui.js";import{B as la,Gr as ca,Hr as Tn,I as qe,Ln as bt,Pt as In,Qn as da,Qr as ua,S as ss,T as ma,Un as pa,Ut as ei,V as xa,X as ha,Xt as we,_ as fa,ct as ti,d as Pn,f as si,gn as ga,gt as va,hr as ba,i as wt,it as ya,l as ja,p as wa,pn as yt,tt as ii,un as Na,ut as En,wr as jt,y as ni,yr as ri}from"./icons.ChOq_Y4q.js";import{t as _a}from"./react-core.CAMe6Z4j.js";import"./utils.CgzVjNgC.js";import"./state.L8kQliOB.js";import{It as ai,M as ka,Mt as Ee,Ot as Sa,Q as za,Tt as d,Z as I,j as is,jt as F,k as m,wt as tr,z as Ca}from"./entry-client.DX3aUoe5.js";import{n as Je,t as Ae}from"./segmented.DHcH2lTJ.js";import{n as Ma,t as Ta}from"./input.GzdAc1Aj.js";import"./dist.CoNAZqlp.js";import"./dist.DxccqHSW.js";import"./dist.D4237Rk6.js";import"./dist.BhzTvz6X.js";import"./dist.B-JETxGF.js";import"./dist.zmknLG-d.js";import{r as Qt}from"./Tooltip.D5vWPvw2.js";import"./es2015.Cr2X04_P.js";import"./dist.DbqQa_sy.js";import"./dialog.Bb7MGeDP.js";import"./dist.D4LCotyC.js";import"./dist.C1cc-Zbw.js";import{a as An,i as Rn,n as Vn,r as Ln,t as Dn}from"./select.vYEvBl4E.js";import{c as oi,i as Fn,l as Zt,n as Ia,o as Pa,r as Ea}from"./characterMention.DcxgzALo.js";import{t as Aa}from"./slider.BZoarXCr.js";import{n as Ra}from"./useFreeTierGate.CwupVhTY.js";import{t as li}from"./badge.CK53iWwP.js";import"./switch.D3Vh3rjF.js";import{a as On,i as $n,n as Va,o as La,s as Da,t as Fa}from"./dropdown-menu.D1MnQ7U0.js";import{n as Oa,r as $a,t as Ua}from"./PromptReferencesRow.Dil-fpz5.js";import"./section-label.Cq6cQeLu.js";import"./locationStore.DwRNJtUf.js";import"./usePolling.mKMvMVRm.js";import"./useLocationActions.DjW0qbmO.js";import{t as je}from"./projectStore.B74RetxK.js";import{t as Un}from"./MentionTextarea.BoOwGw9M.js";import{f as Ba,m as Wa}from"./shotMedium.DYKLpru1.js";import{a as Ga}from"./AnimationShotParts.B3fNwJfT.js";import{t as Ka}from"./useLocationMentions.Ch75-YXw.js";import{t as Bn}from"./kbd.F_PH3ELp.js";import{t as Ha}from"./useFramePairCharacters.BTpVDOC8.js";import{i as Ya,r as Xa,t as qa}from"./ShotNavigator.Bf6k38ex.js";import"./MentionText.Do-0ghUN.js";import"./ReviewShotsDialog.B0UjM6nz.js";import{c as Ja,d as Qa,f as ci,l as Za,o as eo,r as to,s as so,t as Wn}from"./motionEditorConstants.DV7TNLB3.js";import{i as di,n as ui}from"./DeletedMediaNote.4QDTVou1.js";import{n as Gn,r as io}from"./useAIProviders.DpznsHqJ.js";import{n as Kn,r as es,t as no}from"./GenerationTimingLabel.K5WCvCRk.js";import{t as Hn}from"./savedDraft.D7Sdk2MK.js";import{n as ro,t as Yn}from"./spokenLength.DIzJV6he.js";import{i as ao,n as oo,r as lo,t as co}from"./AddLocationButton.6fxYeEMu.js";import{a as uo,i as mo,n as po,r as xo,t as ho}from"./sheet.auH2KWa8.js";import{t as fo}from"./sceneAudio.Do-Wp-E3.js";import{t as go}from"./videoQuality.DDiClgPC.js";import{n as vo,t as bo}from"./ModelPicker.B9qrijHK.js";import"./useGenerationJobPoller.BUhANv0M.js";import{t as yo}from"./usePreparePrompts.OtIhvjD2.js";import"./filmLookStore.CfGPY-XO.js";import{t as Xn}from"./projectLanguages.AcWHm09B.js";import{t as jo}from"./DemoTutorialModal.n7nzQPTB.js";
2var i=er(ua(),1),qn=1500,Jn=n=>n.match(/\S+\s*|\s+/g)??[];function wo(n,o){const c=Jn(n),p=Jn(o);if(c.length>qn||p.length>qn)return null;const f=g=>g.trimEnd(),M=Array.from({length:c.length+1},()=>new Array(p.length+1).fill(0));for(let g=c.length-1;g>=0;g--)for(let b=p.length-1;b>=0;b--)M[g][b]=f(c[g])===f(p[b])?M[g+1][b+1]+1:Math.max(M[g+1][b],M[g][b+1]);const y=[],h=(g,b)=>{const $=y[y.length-1];$?.kind===g?$.text+=b:y.push({kind:g,text:b})};let x=0,S=0;for(;x<c.length&&S<p.length;)f(c[x])===f(p[S])?(h("same",p[S]),x++,S++):M[x+1][S]>=M[x][S+1]?h("removed",c[x++]):h("added",p[S++]);for(;x<c.length;)h("removed",c[x++]);for(;S<p.length;)h("added",p[S++]);return y}var e=er(_a(),1),mi=4e3,pi=60;const No=(0,i.memo)(function({frameId:o,audioSource:c,audioAssetId:p,imageAssetId:f,pictureUrl:M,onPictureRefusal:y}){const[h,x]=(0,i.useState)({status:"loading"}),S=c==="asset"&&p===null;(0,i.useEffect)(()=>{if(y(null),S)return;let b=!1,$,Ne=0,_e=0;x({status:"loading"});const ee=async()=>{try{const ke=await I.lipSyncWords(o,{audio_source:c,...c==="asset"&&p!==null?{audio_asset_id:p}:{},...f!==null?{image_asset_id:f}:{}});if(b)return;const _=ke.data.data;if(_.picture_refusal){x({status:"refused",message:_.picture_refusal}),y(_.picture_refusal);return}if(_.status==="listening"){x({status:"listening"}),Ne++,Ne<pi?$=setTimeout(ee,mi):x({status:"unavailable"});return}const Nt=_.picture==="checking"&&_e<pi;x(_.status==="ready"?{status:"ready",lines:_.lines,checkingPicture:Nt}:{status:_.status}),_.status==="ready"&&Nt&&(_e++,$=setTimeout(ee,mi))}catch(ke){if(b)return;const _=ke?.response?.status;if(Ne++,_===429&&Ne<pi){$=setTimeout(ee,mi*2);return}x({status:"error"})}};return ee(),()=>{b=!0,$&&clearTimeout($)}},[o,c,p,f,M,S,y]);const g=b=>`${b.toFixed(1)} s`;return(0,e.jsxs)("div",{className:"flex min-h-[144px] flex-1 flex-col rounded-lg border border-border bg-zinc-900 px-3 py-2",children:[(0,e.jsx)("p",{className:"text-[10px] font-medium uppercase tracking-wider text-zinc-500",children:"Words in this clip"}),(0,e.jsx)("div",{className:"mt-1.5 min-h-0 flex-1 overflow-y-auto","aria-live":"polite",children:S?(0,e.jsx)("p",{className:"text-xs text-zinc-500",children:"Choose the audio in the left panel. Who says what in it shows here."}):h.status==="loading"||h.status==="listening"?(0,e.jsxs)("p",{className:"flex items-center gap-2 text-xs text-zinc-400",children:[(0,e.jsx)(we,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),h.status==="listening"?"Listening to the audio to find who says what. This takes about a minute, once for each audio file.":"Reading the words…"]}):h.status==="ready"&&h.lines.length===0?(0,e.jsx)("p",{className:"text-xs text-zinc-400",children:"Nobody speaks in this part of the audio. Every mouth stays closed."}):h.status==="ready"?(0,e.jsx)("ul",{className:"flex flex-col gap-1",children:h.lines.map((b,$)=>(0,e.jsxs)("li",{className:"grid grid-cols-[4.5rem_minmax(0,1fr)] gap-2 text-xs leading-snug",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] text-zinc-500",children:g(b.start)}),(0,e.jsxs)("span",{className:"min-w-0",children:[(0,e.jsx)("span",{className:"font-medium text-zinc-200",children:b.speaker})," ",(0,e.jsx)("span",{className:F("text-[10px]",b.on_screen?"text-amber-400":"text-zinc-500"),children:b.on_screen?"in the picture":"off screen"}),(0,e.jsx)("span",{className:"block text-zinc-300",children:b.text})]})]},`${b.start}-${$}`))}):h.status==="refused"?(0,e.jsxs)("p",{role:"alert",className:"flex items-start gap-1.5 text-xs leading-snug text-amber-300",children:[(0,e.jsx)(ss,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),(0,e.jsxs)("span",{children:[h.message," Use Replace beside the source image to pick one from My files."]})]}):h.status==="none"?(0,e.jsx)("p",{className:"text-xs text-zinc-400",children:c==="soundtrack"?"Your soundtrack does not play under this shot. Choose an audio file instead.":"This audio file cannot be read. Choose another one."}):(0,e.jsx)("p",{className:"text-xs text-zinc-400",children:"The words could not be read just now. You can still Sync: the mouths follow the audio, but the AI does not know who says each line."})}),h.status==="ready"&&h.checkingPicture&&(0,e.jsxs)("p",{className:"mt-1.5 flex items-center gap-1.5 text-[10px] leading-snug text-zinc-500",children:[(0,e.jsx)(we,{className:"h-3 w-3 animate-spin","aria-hidden":"true"}),"Checking the picture for who is in it. Until then, the shot's cast is shown."]}),h.status==="ready"&&h.lines.length>0&&(0,e.jsx)("p",{className:"mt-1.5 text-[10px] leading-snug text-zinc-500",children:"Only the people in the picture move their lips, and only to their own lines. Off-screen lines play while their lips stay closed."})]})}),_o=(0,i.memo)(function({lines:o,currentTime:c,onSeek:p,nextShotNumber:f,onNewSync:M}){return(0,e.jsxs)("div",{className:"flex min-h-[144px] flex-1 flex-col rounded-lg border border-border bg-zinc-900 px-3 py-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("p",{className:"text-[10px] font-medium uppercase tracking-wider text-zinc-500",children:"Words this clip was synced to"}),(0,e.jsx)(m,{variant:"outline",size:"xs",onClick:M,children:"New lip sync"})]}),(0,e.jsx)("div",{className:"mt-1.5 min-h-0 flex-1 overflow-y-auto",children:o?o.length===0?(0,e.jsx)("p",{className:"text-xs text-zinc-400",children:"Nobody speaks in this clip. Every mouth stays closed."}):(0,e.jsx)("ul",{className:"flex flex-col gap-0.5",children:o.map((y,h)=>{const x=c>=y.start&&c<y.end;return(0,e.jsx)("li",{children:(0,e.jsxs)("button",{type:"button",onClick:()=>p(y.start),"aria-current":x?"true":void 0,className:F("grid w-full grid-cols-[4.5rem_minmax(0,1fr)] gap-2 rounded px-1 py-0.5 text-left text-xs leading-snug outline-none transition-colors duration-150 hover:bg-zinc-800 focus-visible:ring-[3px] focus-visible:ring-ring/50",x&&"bg-primary/10"),title:"Play from this line",children:[(0,e.jsxs)("span",{className:F("font-mono text-[11px]",x?"text-primary":"text-zinc-500"),children:[y.start.toFixed(1),"–",y.end.toFixed(1)," s"]}),(0,e.jsxs)("span",{className:"min-w-0",children:[(0,e.jsx)("span",{className:"font-medium text-zinc-200",children:y.speaker}),(0,e.jsx)("span",{className:"block text-zinc-300",children:y.text}),y.cut&&(0,e.jsxs)("span",{className:"block text-[10px] text-amber-400",children:["This line runs past the end of the shot.",f?` Shot ${f} plays the rest.`:""]})]})]})},`${y.start}-${h}`)})}):(0,e.jsx)("p",{className:"text-xs text-zinc-500",children:"The words were not saved for this clip. Clips synced from now on show them here."})})]})});function ko(n){return n.length<=1?n[0]??"":`${n.slice(0,-1).join(", ")} and ${n[n.length-1]}`}var So=(0,i.lazy)(()=>tr(()=>import("./CharacterModal.CEeDdccH.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
2)).then(n=>({default:n.CharacterModal}))),Re=(0,i.lazy)(()=>tr(()=>import("./AssetGalleryModal.DBIZWl9v.js"),__vite__mapDeps([28,1,2,3,4,5,6,7,8,9,29,30,10,11,31,17,14,15,18,13,24,12,32,22,23,25,27,33])).then(n=>({default:n.AssetGalleryModal}))),ts="border-dashed border-border-strong text-muted-foreground hover:text-foreground",Qn="aria-pressed:border-primary/30 aria-pressed:bg-primary/15 aria-pressed:text-primary hover:border-primary/40 hover:bg-primary/20",zo=15*1024*1024,Co=4e3,Mo=15e3,To=new Set(["audio/mpeg","audio/mp3","audio/wav","audio/x-wav","audio/wave","audio/vnd.wave"]),Io=50*1024*1024,Po=2e3,Eo=15e3,Ao=new Set(["video/mp4","video/quicktime","video/webm"]),fi=n=>`motion-editor:generation-context:${n}`;function Ro(n){if(n.jobId)try{sessionStorage.setItem(fi(n.jobId),JSON.stringify(n))}catch{}}function Vo(n){try{const o=sessionStorage.getItem(fi(n));return o?JSON.parse(o):null}catch{return null}}function xi(n){if(n)try{sessionStorage.removeItem(fi(n))}catch{}}function Lo(n){const o=n.filename.split(".").pop()?.toLowerCase();return!["mp3","wav"].includes(o??"")||!To.has(n.mime_type.toLowerCase())?"Choose an MP3 or WAV audio file.":n.file_size>zo?"Choose an audio file that is 15 MB or smaller.":n.duration_ms==null||n.duration_ms<Co||n.duration_ms>Mo?"Choose audio between 4 and 15 seconds long.":null}function Zn(n,o="still"){const c=n.filename.split(".").pop()?.toLowerCase();if(!(o==="clip"?["mp4","mov"]:["mp4","mov","webm"]).includes(c??"")||!Ao.has(n.mime_type.toLowerCase()))return o==="clip"?"Choose an MP4 or MOV video file.":"Choose an MP4, MOV, or WEBM video file.";if(n.file_size>Io)return"Choose a video file that is 50 MB or smaller.";const p=o==="clip"?1e4:Eo;return n.duration_ms==null||n.duration_ms<Po||n.duration_ms>p?o==="clip"?"Choose a clip between 2 and 10 seconds long.":"Choose video between 2 and 15 seconds long.":null}function Do(n,o,c,p){if(!n)return[];const f=n.ui_label||n.name,M=[],y=n.supported_durations??[];y.length>0&&!y.includes(o)&&M.push({message:`${f} only supports durations of ${y.map(x=>`${x}s`).join(", ")}. Selected: ${o}s.`});const h=n.supported_aspect_ratios??[];if(h.length>0&&!h.includes(c)){const x=p.find(S=>S.is_available&&(S.supported_aspect_ratios??[]).includes(c));M.push({message:`${f} doesn't support this film's aspect ratio (${c}).${x?` Switch to ${x.ui_label||x.name}.`:""}`,switchTo:x})}return M}var sr=(0,i.memo)(({videoUrl:n,versionNumber:o,detail:c,onClose:p})=>(0,e.jsx)("div",{className:"fixed inset-x-0 bottom-0 z-[60] flex items-center justify-center bg-black/90 backdrop-blur-sm",style:{top:"var(--global-announcement-height, 0px)"},onClick:p,children:(0,e.jsxs)("div",{className:"relative max-h-[80vh] max-w-3xl",onClick:f=>f.stopPropagation(),children:[(0,e.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"text-sm font-medium text-zinc-300",children:["Version ",o,c&&(0,e.jsx)("span",{className:"ml-2 font-normal text-zinc-500",children:c})]}),(0,e.jsx)(is,{size:"icon-sm",onClick:p,"aria-label":"Close preview",className:"text-muted-foreground hover:text-foreground",icon:(0,e.jsx)(wt,{className:"h-4 w-4"})})]}),(0,e.jsx)("video",{src:n,className:"max-h-[70vh] rounded-lg",controls:!0,autoPlay:!0,loop:!0,playsInline:!0})]})}));sr.displayName="VideoPreviewModal";var hi=(0,i.memo)(({videoUrl:n,imageUrl:o,onClose:c})=>((0,i.useEffect)(()=>{const p=f=>{f.key==="Escape"&&(f.stopPropagation(),c())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[c]),(0,e.jsx)("div",{className:"fixed inset-x-0 bottom-0 z-[65] flex items-center justify-center bg-black/90 backdrop-blur-sm",style:{top:"var(--global-announcement-height, 0px)"},onClick:c,children:(0,e.jsxs)("div",{className:"relative h-[90vh] w-[90vw] overflow-hidden rounded-lg border border-zinc-700 bg-black",onClick:p=>p.stopPropagation(),children:[(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",onClick:c,className:"absolute right-3 top-3 z-10 rounded-full bg-black/65 text-zinc-200 hover:bg-black/80 hover:text-white",title:"Close full preview",children:(0,e.jsx)(wt,{className:"h-4 w-4"})}),n?(0,e.jsx)("video",{src:n,className:"h-full w-full object-contain",controls:!0,autoPlay:!0,loop:!0,playsInl
2ine:!0}):(0,e.jsx)("img",{src:o,alt:"Storyboard picture, full size",className:"h-full w-full object-contain"})]})})));hi.displayName="ExpandedPreviewDialog";const Fo=(0,i.memo)(({frame:n,projectUuid:o,isOpen:c,onClose:p,onSave:f,currentStep:M,completedSteps:y=[],onNavigateToStep:h,onSwitchFrame:x,onLeaveWhileRunning:S})=>{const{fetchFrames:g,currentProject:b,revertToVersion:$}=je(),{blockIfFree:Ne}=Ra(),{shotNumber:_e,nextShotId:ee}=Ya(n.id),ke=b?.template?.config?.beat_align_cuts===!0,_=Ee(n.active_version?.data?.generated_image_url)||void 0,Nt=_,ir=n.active_version?.data?.generated_image_s3_key,[K,Ve]=(0,i.useState)(Nt),[ns,Qe]=(0,i.useState)(ir),[Ze,_t]=(0,i.useState)(null),[r,kt]=(0,i.useState)("image-to-video"),[gi,nr]=(0,i.useState)(!0),rr=Wa(),[P,ue]=(0,i.useState)(Ee(n.active_version?.data?.generated_video_url)||void 0),[et,Le]=(0,i.useState)(!1),[St,ar]=(0,i.useState)(0),[me,or]=(0,i.useState)(0),[Se,lr]=(0,i.useState)(1),[W,rs]=(0,i.useState)(!1),U=(0,i.useRef)(null),De=(0,i.useRef)(!1),[B,tt]=(0,i.useState)(n.active_version?.data?.motion_prompt??""),pe=Yn(n.active_version?.data),[H,vi]=(0,i.useState)(pe),zt=(0,i.useRef)(pe);(0,i.useEffect)(()=>{const t=zt.current;vi(s=>Hn(s,t,pe)),zt.current=pe},[pe]);const ze=Xa(n.id,"motion_prompt",B,n.active_version?.data?.motion_prompt??"",{field:"dialogue",text:H,stored:pe}),Ce=(0,i.useCallback)(()=>ze(p),[ze,p]),st=(0,i.useMemo)(()=>x&&(t=>ze(()=>x(t))),[ze,x]),as=st&&ee!==null&&_e!==null?`Work on shot ${_e+1}`:null,Ct=(0,i.useMemo)(()=>h&&(t=>ze(()=>h(t))),[ze,h]),[it,cr]=(0,i.useState)(""),[nt,bi]=(0,i.useState)(5),C=r==="omni-edit"?it:B,te=(0,i.useCallback)(t=>{r==="omni-edit"?cr(t):tt(t)},[r]),[yi,ji]=(0,i.useState)(!1),os=(0,i.useRef)(null),dr=(0,i.useCallback)(t=>{os.current=t.currentTarget.selectionStart},[]),rt=(0,i.useCallback)(t=>{let s={text:C,caret:os.current??C.length};for(const a of t)s=Pa(s.text,a,s.caret);os.current=s.caret,te(s.text)},[C,te]),[ls,Mt]=(0,i.useState)(null);(0,i.useEffect)(()=>Mt(null),[C,r]);const[v,wi]=(0,i.useState)("still"),{providers:Y,defaultSlug:cs,isLoading:ur,failed:mr}=io("video"),[Fe,Me]=(0,i.useState)("modal_h3_video"),[Ni,ds]=(0,i.useState)(!1),[pr,xr]=(0,i.useState)(null),Oe=(0,i.useMemo)(()=>r==="image-to-video"?"image_to_video":r==="text-to-video"?"text_to_video":r==="extend"?"extend_video":r==="lip-sync"?v==="clip"?"lip_sync":"image_audio_lip_sync":null,[r,v]),at=(0,i.useMemo)(()=>Y.find(t=>t.is_default&&(!Oe||t.supported_actions.includes(Oe)))?.slug??null,[Y,Oe]);(0,i.useEffect)(()=>{!Ni&&(at||cs)&&Me(at??cs)},[at,cs,Ni]);const re=(0,i.useMemo)(()=>Y.filter(t=>t.is_user_selectable!==!1&&(!Oe||t.supported_actions.includes(Oe))),[Y,Oe]);(0,i.useEffect)(()=>{re.length===0||re.some(t=>t.slug===Fe)||Me(at??re[0].slug)},[at,re,Fe]);const V=(0,i.useMemo)(()=>ci(Fe),[Fe]);(0,i.useEffect)(()=>{V!==Fe&&Me(V)},[V,Fe]);const j=(0,i.useMemo)(()=>Y.find(t=>t.slug===V),[Y,V]),$e=j?j.ui_label||j.name:null,_i=(0,i.useMemo)(()=>Y.find(t=>t.supported_actions.includes("image_audio_lip_sync"))??null,[Y]),us=(0,i.useMemo)(()=>Y.find(t=>t.supported_actions.includes("lip_sync"))??null,[Y]),ki=!ur&&!mr,Si=ki&&!_i&&!us,Ue=v==="clip"?us:_i,hr=Ue?Ue.ui_label||Ue.name:null,zi=ki&&!Ue,[z,Tt]=(0,i.useState)(()=>{const t=n.duration_seconds??5;return Math.round(t)}),[ms,Ci]=(0,i.useState)(ke),ps=r==="image-to-video"||r==="text-to-video",Mi=(0,i.useMemo)(()=>ro(H,z),[H,z]),fr=V==="modal_h3_video"?H.trim()?"The clip says these words.":"No one speaks.":H.trim()?"This model says them only when each speaker has a voice.":"The clip follows the video prompt.";(0,i.useEffect)(()=>{c&&Ci(ke)},[c,ke]);const[k,N]=(0,i.useState)(!1),[Be,ot]=(0,i.useState)(null),[X,xe]=(0,i.useState)(null),[gr,We]=(0,i.useState)(null),[lt,Ge]=(0,i.useState)(0),It=X!==null&&n.active_generation_job?.id===X?n.active_generation_job:null,[xs,he]=(0,i.useState)(!1),[Ti,Pt]=(0,i.useState)(null),[Ke,Ii]=(0,i.useState)(null),[Pi,hs]=(0,i.useState)(null),[G,q]=(0,i.useState)(null),[Te,fs]=(0,i.useState)("all"),[Ie,gs]=(0,i.useState)(""),[Ei,Ai]=(0,i.useState)(!1),[ct,Ri]=(0,i.useState)("all"),[vr,Vi]=(0,i.useState)(!1),[Li,br]=(0,i.useState)(!1),[ae,Di]=(0,i.useState)([]),[Fi,Et]=(0,i.useState)(!1),[vs,bs]=(0,i.useState)(null),[yr,jr]=(0,i.useState)(null),[wr,Oi]=(0,i.useState)(0),[$i,ys]=(0,i.useState)(!1),[js,ws]=(0,i.useState)(null),[At,Nr]=(0,i.useState)([]),[Rt,Ns]=(0,i.useState)(null),[L,_s]=(0,i.useState)(null),[ks,_r]=(0,i.useState)(""),[kr,D]=(0,i.useState)(null),[Ss,fe]=(0,i.useState)(!1),[zs,Vt]=(0,i.useState)(!1),[Cs,Lt]=(0,i.useState)(!1),[J,Dt]=(0,i.useState)(null),Ui=je(t=>t.audioTracks),Ft=je(t=>t.frames),T=(0,i.useMemo)(()=>fo(Ui),[Ui]),Q=(0,i.useMemo)(()=>
2{if(!T)return null;const t=[...Ft].sort((ye,O)=>ye.sequence_order-O.sequence_order),s=t.findIndex(ye=>ye.id===n.id);if(s<0)return null;const a=Sa(t).frameStartTimes[s]??0,l=Math.min(15,Math.max(5,Math.ceil(Number(n.duration_seconds)||5))),u=a-(T.start_time_ms||0)/1e3+(T.trim_start_ms||0)/1e3,w=((T.original_duration_ms??T.duration_ms??0)-(T.trim_end_ms||0))/1e3;if(u<0||u>=w)return null;const R=Math.min(u+l,w);return{start:a,end:a+(R-u),fileStart:u,fileEnd:R}},[T,Ft,n.id,n.duration_seconds]),oe=Kn(n.active_version?.data,n.active_version?.created_at),Bi=ui(n.active_version?.data,"still"),Wi=ui(n.active_version?.data,"clip"),Sr=(0,i.useMemo)(()=>{const t=[...Ft].sort((a,l)=>a.sequence_order-l.sequence_order),s=t.findIndex(a=>a.id===n.id);return s>=0&&s+1<t.length?s+2:null},[Ft,n.id]),dt=n.active_version?.data?.video_muted&&T&&Q&&Ee(T.asset?.s3_url||T.s3_url)||null,[ut,Ms]=(0,i.useState)(!1);(0,i.useEffect)(()=>Ms(!1),[n.id]);const mt=!!dt&&!ut,Ts=(0,i.useRef)(null),He=(0,i.useCallback)(()=>{const t=Ts.current,s=U.current;if(!t)return;if(!s||!Q||!mt||s.paused){t.paused||t.pause();return}const a=Q.fileStart+s.currentTime;if(a>=Q.fileEnd){t.paused||t.pause();return}t.volume=Se,t.muted=W,Math.abs(t.currentTime-a)>.1&&(t.currentTime=a),t.paused&&t.play().catch(()=>{})},[Q,mt,Se,W]);(0,i.useEffect)(()=>{He()},[He]),(0,i.useEffect)(()=>{const t=Ts.current;return()=>t?.pause()},[dt,c]);const[zr,Cr]=(0,i.useState)(null),se=v==="still"&&Q&&zr!=="asset"?"soundtrack":"asset",[Is,Mr]=(0,i.useState)(!1),Gi=v==="still"&&(se==="soundtrack"||T?.asset_id!=null&&L?.id===T.asset_id),[Ot,Pe]=(0,i.useState)(null),Ki=X!==null&&(Ot?.mode??r)!=="omni-edit",Hi=(0,i.useRef)(null);Hi.current=k&&Ki?X:null;const Yi=(0,i.useRef)(S);Yi.current=S,(0,i.useEffect)(()=>{const t=n.id;return()=>{const s=Hi.current;s!==null&&Yi.current?.(t,s)}},[n.id]);const le=Rt?.frameId===n.id&&Rt.activeFrameImageUrl===_?Rt.asset:null,ce=(Ot?.mode==="lip-sync"?Ot.sourceImageUrl:void 0)??le?.s3_url??_,$t=kr===n.id,[Xi,Tr]=(0,i.useState)(null),Ut=Xi?.frameId===n.id?Xi.message:null,Ir=(0,i.useCallback)(t=>Tr(t===null?null:{frameId:n.id,message:t}),[n.id]),Ye=(0,i.useRef)(null);(0,i.useEffect)(()=>{Ws(P?{url:P,name:`Shot ${n.sequence_order}`}:null)},[P,n.sequence_order,r]);const[,Pr]=(0,i.useState)(null),{projectCharacters:Xe,assignedCharacters:Er,charactersMissingRefs:qi,mentionItems:Ji,characterForTag:Ps,onMentionInserted:Es,attachCharacter:Qi,unassignCharacter:Bt}=Ha(n,o),As=oo(o,{characterForTag:Ps,onEditCharacter:_t}),Ar=(0,i.useCallback)(t=>{rt([Fn(t.id)]),Qi(t.id)},[rt,Qi]),Rr=(0,i.useCallback)(t=>{te(Zt(Zt(C,Fn(t.id)),Ea(t.slug))),Bt(t.id)},[C,te,Bt]),ge=(0,i.useMemo)(()=>Xe.filter(t=>!!t.voice_sample_url&&oi(C,t)),[Xe,C]),Rs=(0,i.useMemo)(()=>Xe.filter(t=>oi(C,t)&&(t.references?t.references.length===0:!t.references_count&&!t.primary_reference)),[Xe,C]),Zi=(0,i.useRef)(null),[Vs,Ls]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(ge.length===0){Ls(null);return}if(!j||j.supports_audio_reference||Zi.current===j.slug)return;const t=re.find(s=>s.supports_audio_reference);!t||t.slug===j.slug||(Ls({from:j.ui_label||j.name,to:t.ui_label||t.name}),Me(t.slug))},[ge.length,j,re]);const Wt=(0,i.useMemo)(()=>ge.length===0?null:j&&!j.supports_audio_reference?{kind:"kept",from:j.ui_label||j.name,to:null}:Vs?{kind:"swapped",...Vs}:null,[ge.length,j,Vs]),en=je(t=>t.projects.find(s=>s.uuid===o)?.aspect_ratio)??"16:9",Vr=je(t=>t.currentProject?.uuid===o?t.currentProject?.resolution:t.projects.find(s=>s.uuid===o)?.resolution),tn=!!n.active_version?.data?.generated_image_url,Ds=(0,i.useMemo)(()=>r!=="image-to-video"?[]:Do(j,z,en,re),[j,r,z,en,re]),Fs=$a({frameId:n.id,savedVersionId:n.active_version?.id??null,prompt:C,provider:V,mode:r==="omni-edit"?"edit":r==="text-to-video"?"text_to_video":"image_to_video",enabled:r!=="lip-sync"&&r!=="reverse"}),{prepare:sn,isPreparing:ie}=yo(o),{rewrite:Lr,isRewriting:ve}=lo(o,n.id),nn=Ka(o),rn=(0,i.useMemo)(()=>[...Ji,...nn,...(Fs.result?.references??[]).filter(t=>t.kind==="asset").map(t=>({tag:t.token,label:t.name,imageUrl:t.url}))],[Ji,nn,Fs.result]),be=(0,i.useRef)(null),Os=(0,i.useRef)(0),Gt=j?.quality_modes??[],Dr=go(Gt,Vr),pt=Gt.find(t=>
2t.value===pr)?.value??Dr,E=!!P,an=r==="image-to-video",Fr=r==="image-to-video"||r==="lip-sync"&&v==="still",$s=r==="lip-sync"?ce:K,on=r==="image-to-video"||r==="text-to-video"||r==="extend",ln=n.sequence_order??1,cn=(n.duration_seconds??0)>15,dn=Math.ceil((n.active_version?.data?.video_original_duration_ms??0)/1e3||(n.duration_seconds??0)),Kt=(0,i.useMemo)(()=>{const t=Math.max(1,Math.min(15,30-dn));return Array.from({length:t},(s,a)=>a+1)},[dn]);(0,i.useEffect)(()=>{const t=Kt[Kt.length-1];nt>t&&bi(t)},[Kt,nt]);const[Us,Bs]=(0,i.useState)(!1),Or=(0,i.useCallback)(t=>{const s=t.flatMap(a=>a.mention||a.short_id?[Ia(a)]:[]);rt(s),s.forEach(a=>Es({tag:a,label:"",imageUrl:""})),Bs(!1)},[rt,Es]),[Z,Ws]=(0,i.useState)(null),[Gs,xt]=(0,i.useState)(!1),$r=(0,i.useCallback)(t=>{t.length>0&&Ws({url:t[0].s3_url,name:t[0].original_name}),xt(!1)},[]),un=(0,i.useMemo)(()=>{let t=Wn;if(Te!=="all"&&(t=t.filter(s=>s.category===Te)),ct!=="all"&&(t=t.filter(s=>s.intensity===ct)),Ie){const s=Ie.toLowerCase();t=t.filter(a=>a.label.toLowerCase().includes(s)||a.prompt.toLowerCase().includes(s))}return t},[Te,ct,Ie]),Ks=(0,i.useMemo)(()=>[...j?.supported_durations??[]],[j]),ne=Ks.length>0,A=(0,i.useMemo)(()=>ne?Ks:[...to],[ne,Ks]),Ht=(0,i.useCallback)(t=>A.reduce((s,a)=>{const l=Math.abs(s-t);return Math.abs(a-t)<l?a:s},A[0]),[A]),mn=(0,i.useRef)(null);(0,i.useEffect)(()=>{const t=j?.slug??"__none__";if(mn.current===t||(mn.current=t,!ne)||A.includes(z))return;const s=Ht(z);Tt(s),$e&&d.info(`Duration adjusted to ${s}s (${$e} doesn't support ${z}s).`)},[j,$e,A,ne,Ht]);const[Hs,Yt]=(0,i.useState)(()=>String(z));(0,i.useEffect)(()=>{Yt(String(z))},[z]);const pn=(0,i.useCallback)(()=>{const t=Number(Hs);if(!Number.isFinite(t)||t<1){Yt(String(z));return}const s=ne?Ht(t):Math.round(t);Tt(s),Yt(String(s)),s!==t&&ne&&$e&&d.info(`${$e} makes ${A.join(", ")}s clips — using ${s}s.`)},[Hs,z,A,ne,Ht,$e]),Ys=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(!c){Ys.current=null,De.current=!1;return}const t=Ee(n.active_version?.data?.generated_video_url)||void 0,s=Ys.current;s?.frameId!==n.id?De.current=!1:t&&t!==s.url&&(De.current=!0),Ys.current={frameId:n.id,url:t},ue(t)},[c,n.id,n.active_version?.data?.generated_video_url]);const Xt=(0,i.useRef)(null);Xt.current=oe?oe.mode==="lip-sync"&&!Si?"lip-sync":oe.mode==="text-to-video"?"text-to-video":"image-to-video":null,(0,i.useEffect)(()=>{!c||Xt.current===null||(kt(Xt.current),Xt.current==="lip-sync"&&D(n.id))},[c,n.id]),(0,i.useEffect)(()=>{const t=n.active_version?.data?.generated_image_url;Ve(Ee(t)||void 0),Qe(n.active_version?.data?.generated_image_s3_key)},[n.active_version?.data?.generated_image_url,n.active_version?.data?.generated_image_s3_key,c]);const ht=(0,i.useRef)(B);(0,i.useEffect)(()=>{if(n.active_version?.data){const t=n.active_version.data;if(t.motion_prompt!==void 0){const s=t.motion_prompt??"",a=ht.current;tt(l=>Hn(l,a,s)),ht.current=s}t.video_provider_slug&&(Me(t.video_provider_slug),ds(!0))}n.duration_seconds&&Tt(Math.round(n.duration_seconds))},[n.active_version?.id,n.duration_seconds]);const[Xs,ft]=(0,i.useState)(!1),xn=(0,i.useCallback)(t=>{t[0]?.s3_url&&(Ve(t[0].s3_url),Qe(t[0].s3_key),d.success("Starting picture set.")),he(!1)},[]),[hn,fn]=(0,i.useState)(!1),Ur=(0,i.useCallback)(async t=>{fn(!0);try{const s=(await Ca.create(o,{file:t,category:"image"})).data?.data;if(!s?.s3_url)throw new Error("Upload returned no URL");Ve(s.s3_url),Qe(s.s3_key),d.success("Storyboard added")}catch{d.error("Could not upload the storyboard. Try again.")}finally{fn(!1)}},[o]),Br=(0,i.useCallback)(async t=>{if(t.category!=="video"){d.error("Choose a video.");return}ft(!1),N(!0),ot(null);try{const s=await I.setDirectVideo(n.id,{asset_id:t.id}),a=t.s3_url||s.data?.video_url,l=t.duration_ms??s.data?.asset_duration_ms;if(l&&l>0){const u=Math.min(60,Math.max(.1,Number((l/1e3).toFixed(2))));await I.update(n.id,{duration_seconds:u,change_summary:"Duration matched to uploaded clip"}),Tt(Math.round(u))}ue(a),f(a),await g(o),d.success("Video clip set from My files.")}
2catch(s){console.error("Failed to set video from assets:",s),d.error("Could not set the video clip. Try again.")}finally{N(!1)}},[n.id,f,g,o]),Wr=(0,i.useCallback)(t=>{Ns({asset:t,frameId:n.id,activeFrameImageUrl:_}),fe(!1),q(null),D(null)},[_,n.id]),Gr=(0,i.useCallback)(()=>{Ns(null),q(null),D(null)},[]),Kr=(0,i.useCallback)(t=>{const s=Lo(t);if(s){d.error(s);return}_s(t),Vt(!1),q(null),D(null)},[]),Hr=(0,i.useCallback)(t=>{const s=Zn(t,v);if(s){d.error(s);return}Dt(t),Lt(!1),q(null),D(null)},[v]);(0,i.useEffect)(()=>{P||ys(!1)},[P]),(0,i.useEffect)(()=>{r==="extend"&&E&&I.getExtensionInfo(n.id).then(t=>Pr(t.data?.data||t.data)).catch(()=>{})},[r,E,n.id]),(0,i.useEffect)(()=>{if(c&&n.active_generation_job){const t=n.active_generation_job;if((t.status==="pending"||t.status==="processing")&&t.type==="video"){const s=Vo(t.id);s?.frameId===n.id&&(Ye.current=s,Pe(s),kt(s.mode),s.mode==="lip-sync"&&(wi(s.lipSyncSource??"still"),_s(s.lipSyncAudioAsset),_r(s.lipSyncMotionInstructions),Ns(s.lipSyncImageAsset?{asset:s.lipSyncImageAsset,frameId:n.id,activeFrameImageUrl:_}:null),Dt(s.lipSyncVideoAsset??null))),xe(t.id),We(t.status),N(!0),Ge(t.progress??0)}}},[_,n.active_generation_job,n.id,c]),(0,i.useEffect)(()=>{if(!X)return;Os.current=Date.now();let t=0;return be.current=setInterval(async()=>{if(Date.now()-Os.current>12e5){clearInterval(be.current),N(!1),Pe(null),xe(null),d.error("The video clip is taking too long. Check back on this shot later.");return}try{const s=(await za.get(X)).data?.data;if(t=0,s?.status&&We(s.status),s?.progress){Ge(s.progress);const a=(Date.now()-Os.current)/1e3;if(s.progress>5){const l=a/s.progress*100,u=Math.max(0,l-a);Pt(u>60?`~${Math.ceil(u/60)}m`:`~${Math.ceil(u)}s`)}}if(s?.status==="completed"){if(clearInterval(be.current),N(!1),xe(null),We(null),Ge(0),Pt(null),s.result_url){const a=Ye.current||Ot||{jobId:X??void 0,frameId:n.id,mode:r,prompt:B,provider:V,duration:z,sourceImageUrl:_,sourceImageS3Key:ns,lipSyncImageAsset:Rt?.asset??null,lipSyncAudioAsset:L??null,lipSyncVideoAsset:J??null,lipSyncMotionInstructions:ks,lipSyncSource:v};q({url:s.result_url,context:a}),De.current=!0,ue(s.result_url),a.mode==="lip-sync"&&D(n.id)}}else s?.status==="failed"?(clearInterval(be.current),N(!1),xi(X),Ye.current=null,Pe(null),xe(null),We(null),Ge(0),Pt(null),ot(s.user_error??null),d.error(s.user_error?.message||"Could not make the video clip. Try again.",s.user_error?.title)):s?.status==="cancelled"&&(clearInterval(be.current),N(!1),xi(X),Ye.current=null,Pe(null),xe(null),We(null),Ge(0),Pt(null))}catch{t++,t>=5&&(clearInterval(be.current),N(!1),Pe(null),xe(null),d.error("Lost the connection. Reopen this shot to check on the video clip."))}},Za),()=>{be.current&&clearInterval(be.current)}},[X,o,g,f,r,n.id,B,V,z]);const[gn,qt]=(0,i.useState)(null),Yr=(0,i.useCallback)(t=>{const s=t.currentTarget,a=s.error,l=a?.message||"Failed to load video";qt(l),Le(!1),console.error("Video load error:",{message:l,code:a?.code,src:s.src})},[]),Jt=(0,i.useCallback)(t=>{De.current&&(De.current=!1,t.play().catch(()=>{t.muted=!0,rs(!0),t.play().catch(()=>{})}))},[]),Xr=(0,i.useCallback)(t=>{qt(null),Jt(t.currentTarget)},[Jt]);(0,i.useEffect)(()=>{qt(null)},[P]),(0,i.useEffect)(()=>{const t=U.current;t&&t.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&Jt(t)},[P,k,Jt]);const qr=(0,i.useCallback)(t=>ar(t.currentTarget.currentTime),[]),vn=(0,i.useCallback)(t=>{const s=t.currentTarget.duration;or(Number.isFinite(s)?s:0)},[]);(0,i.useEffect)(()=>{const t=U.current;t&&(t.volume=Se,t.muted=W||mt)},[Se,W,mt,P,k,gn]),(0,i.useEffect)(()=>{const t=s=>{s.key==="f"&&!s.metaKey&&!s.ctrlKey&&!s.altKey&&!(s.target instanceof HTMLTextAreaElement)&&!(s.target instanceof HTMLInputElement)&&nr(a=>!a)};if(c)return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[c]);const bn=$i||!!js||!!vs||Ei||yi||!!Ze||Gs||Us||Ss||zs||Cs||xs||Xs;(0,i.useEffect)(()=>{if(!c||bn)return;const t=s=>{const a=s.target;s.key!=="Escape"||s.defaultPrevented||a?.closest("input, textarea, select, [contenteditable='true']")||document.querySelector("[role='dialog'], [role='alertdialog'], [data-radix-popper-content-wrapper]")||Ce()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[c,bn,Ce]);const de=!!n.active_version?.data?.video_muted,[Jr,yn]=(0,i.useState)(!1),Qr=(0,i.useCallback)(async()=>{yn(!0);try{await I.update(n.id,{data:{video_muted:!de},change_summary:de?"Clip sound on":"Clip sound muted"}),await g(o),d.success(de?"The clip's own sound plays again.":"The clip is silent now. Your soundtrack still plays.")}catch{d.error("Could not change the clip's sound. Try again.")}finally{yn(!1)}},[de,g,n.id,o]),Zr=(0,i.useCallback)(async()=>
2{if(!P)return;const t=`shot-${ln}-generated.mp4`;try{const s=await fetch(P);if(!s.ok)throw new Error("Failed to fetch video");const a=await s.blob(),l=URL.createObjectURL(a),u=document.createElement("a");u.href=l,u.download=t,document.body.appendChild(u),u.click(),u.remove(),URL.revokeObjectURL(l)}catch{const s=document.createElement("a");s.href=P,s.download=t,s.target="_blank",s.rel="noopener noreferrer",document.body.appendChild(s),s.click(),s.remove()}},[P,ln]),qs=(0,i.useCallback)(async()=>{if(!k&&!Ne("generate-video")){if((r==="image-to-video"||r==="text-to-video")&&z!==Math.round(n.duration_seconds??0))try{await I.update(n.id,{duration_seconds:z})}catch{d.error("Could not save the clip length. Try again.");return}n.active_version?.id&&!(G&&Ke)&&Ii(n.active_version.id),hs(null),ot(null),Mt(null),N(!0),xe(null),We(null),Ge(0),r==="lip-sync"&&D(null);try{let t;const s=H!==pe?{dialogue:H}:{},a={provider:V,duration:z,...pt?{quality:pt}:{},...ms?{disable_audio:!0}:{}},l={frameId:n.id,mode:r,sourceImageUrl:r==="lip-sync"?ce:K,sourceImageS3Key:r==="lip-sync"?le?.s3_key??n.active_version?.data?.generated_image_s3_key:ns,prompt:C,provider:r==="lip-sync"?Ue?.slug??V:V,duration:z,lipSyncImageAsset:le,lipSyncAudioAsset:L,lipSyncVideoAsset:J,lipSyncMotionInstructions:ks,lipSyncSource:v};if(r==="image-to-video"){if(!K){d.error("Draw the storyboard picture first."),N(!1);return}t=await I.generateVideo(n.id,{...a,prompt:B,source_image_url:K,...s}),zt.current=H}else if(r==="text-to-video")t=await I.generateTextToVideo(n.id,{...a,prompt:B,...s}),zt.current=H;else if(r==="extend"){if(!E){d.error("No video clip to extend. Make one first."),N(!1);return}t=await I.extendVideo(n.id,{...a,duration:nt,prompt:B})}else if(r==="lip-sync"){if(se==="asset"&&!L){d.error("Choose a voice track for lip sync"),N(!1);return}if(v==="clip"){if(!J){d.error("Choose the clip you want to lip sync"),N(!1);return}t=await I.lipSync(n.id,{source:"clip",video_asset_id:J.id,audio_asset_id:L?.id})}else{if(!ce){d.error("Choose an image for lip sync"),N(!1);return}t=await I.lipSync(n.id,{source:"still",...se==="soundtrack"?{audio_source:"soundtrack"}:{audio_asset_id:L?.id},keep_clip_sound:Gi&&Is,...le?{image_asset_id:le.id}:{}})}}else if(r==="reverse"){if(!E){d.error("No video to reverse"),N(!1);return}t=await I.reverseVideo(n.id)}else if(r==="omni-edit"){if(!Z?.url&&!E){d.error("Pick a video to edit first"),N(!1);return}if(!it.trim()){d.error("Describe the edit you want to make"),N(!1);return}const u=n.active_version?.data?.generated_video_url,w=!!(Z?.url&&Z.url!==u),R=w?Z.url:u;t=await I.editVideoWithOmni(n.id,{prompt:it,source_video_url:R,previous_interaction_id:w?void 0:n.active_version?.data?.video_metadata?.interaction_id||void 0})}if(t?.data?.success||t?.data?.job_id){const u=t.data.job_id||t.data.data?.id||null,w={...l,...u?{jobId:u}:{}};Ye.current=w,Pe(w),Ro(w),xe(u);try{await g(o)}catch(R){console.warn("Failed to fetch frames:",R)}if(t.data.video_url){q({url:t.data.video_url,context:w}),ue(t.data.video_url),N(!1),d.success("Video reversed");return}}else throw new Error(t?.data?.message||"Could not start the video clip. Try again.")}catch(t){N(!1);const s=Oa(t);if(s){Mt(s),t?.config?.suppressErrorToast||d.error(`The clip did not start. ${s[0]}`);return}const a=t;a?.config?.suppressErrorToast||d.error(a?.response?.data?.message||"Could not start the video clip. Try again.")}}},[k,Ne,nt,G,Ke,r,n.id,n.duration_seconds,n.active_version?.id,n.active_version?.data?.generated_video_url,B,H,pe,it,C,z,V,pt,ms,K,ns,ce,E,L,le,J,ks,v,Ue,Z,n.active_version?.data?.video_metadata?.interaction_id,n.active_version?.data?.generated_image_s3_key,g,o]),jn=(0,i.useCallback)(async()=>{if(!G)return;const t=G.url,s=G.context;try{await g(o);const l=je.getState().frames.find(w=>w.id===n.id)?.active_version,u=l?.data;u&&l?.id&&u.generated_video_url===t&&s.mode==="image-to-video"&&s.sourceImageUrl&&u.generated_image_url!==s.sourceImageUrl&&(await I.update(n.id,{base_version_id:l.id,data:{...u,generated_image_url:s.sourceImageUrl,generated_image_s3_key:s.sourceImageS3Key||null},has_image:!0}),await g(o))}catch(l){console.error("Failed to refresh the shot after its new clip:",l)}const a=je.getState().frames.find(l=>l.id===n.id)?.active_version;hs(a?.id&&a.data?.generated_video_url===t?a.id:null),f(t),Nr(l=>[...l,{id:`variant-${Date.now()}`,videoUrl:t,prompt:s.mode==="lip-sync"?s.lipSyncMotionInstructions:s.prompt,provider:s.provider,duration:s.duration,createdAt:new Date().toISOString()}]),xi(s.jobId),Ye.current=null,Pe(null),q(null)},[G,f,g,o,n.id]),wn=(0,i.useRef)(jn);wn.current=jn;const Nn=(0,i.useRef)(new Set);(0,i.useEffect)(()=>
2{if(!G)return;const t=String(G.context.jobId??G.url);if(Nn.current.has(t)){q(null);return}Nn.current.add(t),wn.current()},[G]);const ea=(0,i.useCallback)(async()=>{if(!Ke){q(null),ue(void 0),D(null),d.success("Video preview discarded");return}try{N(!0),await I.revertToVersion(n.id,Ke),await g(o),ue(je.getState().frames.find(t=>t.id===n.id)?.active_version?.data?.generated_video_url||void 0),q(null),D(null),Ii(null),hs(null),d.success("Video generation discarded")}catch(t){console.error("Failed to discard video:",t),d.error("Could not discard the video clip. Try again.")}finally{N(!1)}},[Ke,n.id,g,o]),ta=(0,i.useCallback)(()=>{Ve(void 0),Qe(void 0),d.success("Reference picture removed.")},[]),sa=(0,i.useCallback)(()=>{U.current&&(et?U.current.pause():U.current.play().catch(()=>{}),Le(!et))},[et]),ia=(0,i.useCallback)(t=>{if(!U.current||!me)return;const s=t.currentTarget.getBoundingClientRect(),a=Math.max(0,Math.min(1,(t.clientX-s.left)/s.width));U.current.currentTime=a*me},[me]),_n=(0,i.useCallback)(t=>{if(!U.current)return;const s=1/24;U.current.currentTime+=t==="forward"?s:-s},[]),kn=(0,i.useCallback)(t=>{te(s=>{const a=s.trimEnd();return a?`${a.replace(/[.!?,;:]+$/,"")}. ${t}`:t})},[te]),na=(0,i.useCallback)(async()=>{Vi(!0),Et(!0);try{Di((await I.history(n.id)).data?.data||[])}catch{d.error("Could not load history. Try again.")}finally{Et(!1)}},[n.id]),Sn=(0,i.useMemo)(()=>{const t=new Map;let s=null;for(let a=ae.length-1;a>=0;a--){const l=ae[a],u=l.data?.generated_video_url,w=l.data?.video_generation_job;u&&u!==ae[a+1]?.data?.generated_video_url&&w?.prompt_sha256&&(s!==null&&t.set(l.id,s),s=w.prompt??"")}return t},[ae]),zn=(0,i.useMemo)(()=>{const t=new Map;for(const s of ae){const a=Sn.get(s.id),l=s.data?.video_generation_job?.prompt??"";a!==void 0&&a!==l&&t.set(s.id,wo(a,l))}return t},[ae,Sn]),ra=(0,i.useCallback)(async t=>{Et(!0);try{await $(n.id,t),Di((await I.history(n.id)).data?.data||[]),d.success("Reverted to previous version")}catch{d.error("Could not revert. Try again.")}finally{Et(!1)}},[n.id,$]),aa=(0,i.useCallback)(t=>{t.key==="Enter"&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),qs())},[qs]),oa=r==="image-to-video"||r==="text-to-video"||r==="extend"||r==="omni-edit",gt=ve?"The AI is rewriting this frame. Generate when it is done.":Ds.length>0?"Fix the warnings above first.":Rs.length>0&&oa?`${ko(Rs.map(t=>t.name))} ${Rs.length===1?"has":"have"} no reference image yet. Add one, or remove the mention.`:r==="image-to-video"&&!K?"Draw the shot's storyboard picture first.":(r==="image-to-video"||r==="text-to-video")&&!B.trim()?"Describe the movement first.":(r==="extend"||r==="reverse")&&!E?"Make a video clip first.":r==="lip-sync"&&zi?"No model for this kind of lip sync is switched on right now.":r==="lip-sync"&&v==="still"&&!ce?"Choose an image to animate.":r==="lip-sync"&&v==="still"&&Ut?Ut:r==="lip-sync"&&v==="clip"&&!J?"Choose the clip you want to lip sync.":r==="lip-sync"&&se==="asset"&&!L?"Choose a voice track.":r==="omni-edit"&&!(Z?.url||E)?"Pick a clip to edit first.":r==="omni-edit"&&!it.trim()?"Describe the change first.":null;if(!c)return null;const Cn=t=>ai(Number.isFinite(t)&&t>0?t:0);return(0,e.jsxs)("div",{className:"fixed inset-x-0 bottom-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",style:{top:"var(--global-announcement-height, 0px)"},children:[(0,e.jsxs)("div",{className:F("relative flex flex-col overflow-hidden rounded-lg border border-zinc-800 bg-zinc-950 transition-all duration-200",gi?"h-full w-full max-h-full max-w-none rounded-none":"h-[90dvh] w-[95vw] max-w-7xl"),children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-zinc-800 px-3 py-2.5 sm:px-5",children:[(0,e.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[(0,e.jsxs)(m,{variant:"ghost",size:"xs",onClick:Ce,"aria-label":"Back",className:"text-muted-foreground hover:text-foreground",children:[(0,e.jsx)(ca,{className:"h-4 w-4"}),(0,e.jsx)("span",{children:"Back"})]}),(0,e.jsx)("div",{className:"h-4 w-px bg-zinc-800"}),(0,e.jsx)(bt,{className:"h-4 w-4 text-primary"}),(0,e.jsx)("h2",{className:"whitespace-nowrap text-sm font-semibold text-zinc-100",children:"Shot video clip"}),(0,e.jsx)(qa,{frameId:n.id,onSwitchFrame:st}
2),rr&&(0,e.jsx)(Ga,{compact:!0,value:"footage",onChange:t=>void ze(()=>void Ba(n.id,t)),disabled:k||!!n.generating_image||!!n.generating_video,disabledReason:"You can change this once the picture or clip for this shot has finished."}),M&&Ct&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"hidden h-4 w-px bg-zinc-800 lg:block"}),(0,e.jsx)("nav",{className:"flex items-center gap-1.5","aria-label":"Workflow steps",children:[1,2].map(t=>{const s=y.includes(t),a=t===M,l={1:"Storyboard",2:"Video clip"};return(0,e.jsxs)(m,{type:"button",variant:"ghost",size:"xs",onClick:()=>Ct(t),className:F("px-2",a&&"bg-primary/15 text-primary hover:bg-primary/20",!a&&s&&"text-success",!a&&!s&&"text-muted-foreground hover:text-foreground"),title:`Step ${t}: ${l[t]}`,"aria-current":a?"step":void 0,children:[(0,e.jsx)("span",{className:F("flex h-5 w-5 items-center justify-center rounded-full text-[10px] font-semibold",a&&"bg-primary text-primary-foreground",!a&&s&&"bg-success/20",!a&&!s&&"bg-zinc-800"),children:s?(0,e.jsx)(jt,{className:"h-3 w-3"}):t}),(0,e.jsx)("span",{children:l[t]})]},t)})}),(0,e.jsx)("div",{className:"hidden h-4 w-px bg-zinc-800 lg:block"})]}),(0,e.jsx)(Qt,{content:"Watch a short video on how this screen works",side:"bottom",children:(0,e.jsx)(m,{variant:"outline",size:"xs",onClick:()=>ji(!0),className:"border-primary/30 bg-primary/10 text-primary hover:border-primary/50 hover:bg-primary/15",leftIcon:(0,e.jsx)(ba,{className:"h-3.5 w-3.5"}),children:(0,e.jsx)("span",{children:"Demo"})})})]}),(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,e.jsxs)(m,{variant:"outline",size:"xs",onClick:()=>ft(!0),title:"Upload a video or pick one from My files",children:[(0,e.jsx)(ni,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:"Upload or pick a video"}),(0,e.jsx)("span",{className:"sm:hidden",children:"Upload"})]}),(0,e.jsxs)(m,{variant:"ghost",size:"xs",onClick:na,className:"text-muted-foreground hover:text-foreground",title:"History",children:[(0,e.jsx)(ga,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:"History"})]}),E&&(0,e.jsxs)(m,{variant:"ghost",size:"xs",onClick:Qr,disabled:Jr,"aria-pressed":de,className:F(de?"text-amber-400 hover:text-amber-300":"text-muted-foreground hover:text-foreground"),title:de?"This clip plays silent. Turn its own sound back on.":"Mute this clip's own sound in the board, the preview and the export",children:[de?(0,e.jsx)(Pn,{className:"h-3.5 w-3.5","aria-hidden":"true"}):(0,e.jsx)(si,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:de?"Clip sound muted":"Mute clip sound"})]}),E&&(0,e.jsxs)(m,{variant:"ghost",size:"xs",onClick:Zr,className:"text-muted-foreground hover:text-foreground",title:"Download video",children:[(0,e.jsx)(da,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:"Download"})]}),(0,e.jsx)(Qt,{content:"Go back to the board",side:"bottom",children:(0,e.jsxs)(m,{variant:"outline",size:"xs",onClick:Ce,children:[(0,e.jsx)(jt,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{children:"Done"})]})})]})]}),(0,e.jsx)("div",{className:"flex items-center overflow-x-auto border-b border-zinc-800/50 px-3 py-2 sm:px-5",children:(0,e.jsx)("div",{className:Je("shrink-0"),children:eo.map(t=>{const s=t.value==="omni-edit",a=t.value==="lip-sync"&&Si,l=k||a||!s&&t.requiresVideo&&!E||t.requiresImage&&!K;return(0,e.jsx)("button",{type:"button","aria-pressed":r===t.value,onClick:()=>{l||(ot(null),q(null),D(null),kt(t.value))},disabled:l,className:Ae(r===t.value,"shrink-0 flex-none px-3 disabled:pointer-events-auto disabled:cursor-not-allowed"),title:k?"Wait until the current clip is done":a?"No lip sync model is switched on right now":l?t.requiresVideo?"Make a video clip first":"Draw the storyboard picture first":s&&cn?"VFX works on clips up to 15 seconds — trim this clip first":t.description,children:t.label},t.value)})})}),(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden",children:[(0,e.jsxs)("div",{className:F("max-h-[34dvh] w-full shrink-0 space-y-3 overflow-y-auto border-b border-zinc-800 p-3 lg:max-h-none lg:w-56 lg:border-b-0 lg:border-r",gi&&"lg:w-48"),children:[r!=="omni-edit"&&r!=="lip-sync"&&!an&&(0,e.jsx)("p",{className:"text-[11px] leading-snug text-zinc-500",children:r==="text-to-vi
2deo"?"This mode makes the clip from your words alone. To start from the shot's storyboard picture, switch to From picture.":r==="extend"?"Continues the clip already on this shot.":"Plays the existing clip backwards. Nothing to set."}),r==="omni-edit"?(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,e.jsx)("p",{className:"text-[10px] font-medium uppercase tracking-wider text-zinc-500",children:"Reference video"}),Z?.url&&(0,e.jsx)("button",{type:"button",onClick:()=>xt(!0),className:"rounded-md text-[10px] text-zinc-400 outline-none transition-colors hover:text-zinc-200 focus-visible:ring-[3px] focus-visible:ring-ring/50",title:"Swap reference video",children:"Swap"})]}),Z?.url?(0,e.jsxs)("div",{className:"relative aspect-video overflow-hidden rounded border border-zinc-800 bg-zinc-900 group",children:[(0,e.jsx)("video",{src:Z?.url,className:"h-full w-full object-contain",muted:!0,autoPlay:!0,loop:!0,playsInline:!0,preload:"auto"}),(0,e.jsx)("button",{type:"button",onClick:()=>xt(!0),className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 group-hover:opacity-100 transition-opacity","aria-label":"Swap reference video",children:(0,e.jsx)(bt,{className:"h-5 w-5 text-white"})})]}):(0,e.jsxs)("button",{type:"button",onClick:()=>xt(!0),className:"flex aspect-video w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-dashed border-border-strong bg-card/40 text-muted-foreground outline-none transition-colors hover:bg-surface-hover hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,e.jsx)(bt,{className:"h-5 w-5"}),(0,e.jsx)("span",{className:"text-[10px]",children:"Pick a video to edit"})]}),Z?.name&&(0,e.jsx)("p",{className:"mt-0.5 truncate text-[10px] text-zinc-600",children:Z.name})]}):an?(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"mb-1.5 text-[10px] font-medium uppercase tracking-wider text-zinc-500",children:"Starting storyboard"}),(0,e.jsx)("div",{className:"relative aspect-video overflow-hidden rounded border border-zinc-800 bg-zinc-900 group",children:K?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("img",{src:K,alt:"Storyboard picture",className:"h-full w-full object-cover"}),(0,e.jsx)("button",{type:"button",onClick:()=>ws(K),className:"absolute inset-0 flex items-center justify-center bg-black/0 opacity-0 transition-all hover:bg-black/40 focus-visible:bg-black/40 group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none","aria-label":"View storyboard picture full size",title:"View full size",children:(0,e.jsx)("span",{className:"rounded-full bg-black/70 p-1.5 text-zinc-100",children:(0,e.jsx)(ei,{className:"h-4 w-4"})})}),(0,e.jsxs)("div",{className:"absolute right-1.5 top-1.5 flex items-center gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>he(!0),className:"rounded-full bg-black/60 p-1 text-zinc-400 hover:bg-black/80 hover:text-white transition-colors",title:"Change reference image",children:(0,e.jsx)(yt,{className:"h-3.5 w-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:ta,className:"rounded-full bg-black/60 p-1 text-zinc-400 hover:bg-black/80 hover:text-white transition-colors",title:"Remove reference image",children:(0,e.jsx)(wt,{className:"h-3.5 w-3.5"})})]})]}):n.active_version?.data?.generated_image_url?(0,e.jsxs)("div",{className:"flex h-full w-full gap-2 p-2",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>he(!0),className:"group flex flex-1 flex-col items-center justify-center gap-1.5 rounded-lg border border-dashed border-border-strong p-1.5 text-muted-foreground outline-none transition-colors hover:bg-surface-hover hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",title:"Add a reference picture from My files",children:[(0,e.jsx)("div",{className:"w-5 h-5 rounded-full bg-zinc-800 flex items-center justify-center group-hover:bg-amber-500/20 group-hover:text-amber-400 transition-colors",children:(0,e.jsx)(ti,{className:"h-3 w-3"})}),(0,e.jsx)("span",{className:"text-[9px] font-medium text-zinc-400 group-hover:text-zinc-200 text-center leading-none mt-1",children:"Add reference"})]}),(0,e.jsxs)("button",{type:"button",onClick:()=>{Ve(Ee(n.active_version?.data?.generated_image_url)||void 0),Qe(n.active_version?.data?.generated_image_s3_key)},className:"group flex flex-1 flex-col items-center justify-center gap-1.5 rounded-lg border border-dashed border-border-strong p-1.5 text-muted-foreground outline-none transition-colors hover:bg-surface-hover hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",title:"Put back the shot's storyboard picture",children:[(0,e.jsx)("div",{className:"w-5 h-5 rounded-full bg-zinc-800 flex items-center justify-center group-hover:bg-amber-500/20 group-hover:text-amber-400 transition-colors",children:(0,e.jsx)(ii,{className:"h-3 w-3"})}),(0,e.jsx)("span",{className:"text-[9px] font-medium text-zinc-400 group-hover:text-zinc-200 text-center leading-none mt-1",children:"Reset"})]})]}):(0,e.jsxs)("button",{type:"button",onClick:()=>he(!0),className:"group flex h-full w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-dashed border-border-strong p-2 text-muted-foreground outline-none transition-colors hover:bg-surface-hover hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",title:"Add a reference picture from My files",children:[(0,e.jsx)("div",{className:"w-6 h-6 rounded-full bg-zinc-800 flex items-center justify-center group-hover:bg-amber-500/20 group-hover:text-amber-400 transition-colors",children:(0,e.jsx)(ti,{className:"h-3.5 w-3.5"})}),(0,e.jsx)("span",{className:"text-[10px] font-medium text-zinc-400 group-hover:text-zinc-200",children:"Add reference"})]})}),!K&&Bi&&(0,e.jsx)("p",{className:"mt-1 text-[10px] leading-tight text-warning",children:di("still",Bi)})]}
2):null,(r==="image-to-video"||r==="text-to-video")&&A.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"mb-1.5 text-[10px] font-medium uppercase tracking-wider text-zinc-500",children:"Clip length"}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(Ma,{type:"number",min:ne?A[0]:1,max:ne?A[A.length-1]:void 0,value:Hs,onChange:t=>Yt(t.target.value),onBlur:pn,onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),pn())},className:"w-full pr-12","aria-label":"Clip length in seconds"}),(0,e.jsx)("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-[11px] text-zinc-500",children:"sec"})]}),(0,e.jsx)("p",{className:"mt-1 text-[10px] leading-snug text-zinc-500",children:ne?(0,e.jsxs)(e.Fragment,{children:["This model makes clips of"," ",A.length<=4?A.join(", "):`${A[0]}–${A[A.length-1]}`," ","seconds."]}):(0,e.jsx)(e.Fragment,{children:"This model decides its own clip length."})})]}),on&&Gt.length>1&&(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"mb-1.5 text-[10px] font-medium uppercase tracking-wider text-zinc-500",children:"Quality"}),(0,e.jsx)("div",{className:Je("flex w-full"),children:Gt.map(t=>(0,e.jsx)("button",{type:"button","aria-pressed":pt===t.value,onClick:()=>xr(t.value),className:Ae(pt===t.value,"px-1"),children:t.label},t.value))})]}),r==="lip-sync"&&(0,e.jsxs)("div",{className:"space-y-3 border-t border-zinc-800 pt-3",children:[(0,e.jsx)("div",{className:"flex items-center justify-between gap-2",children:(0,e.jsx)("p",{className:"text-[10px] font-medium uppercase tracking-wider text-zinc-500",children:"Lip sync"})}),(us||v==="clip")&&(0,e.jsx)("div",{role:"radiogroup","aria-label":"What the lip sync starts from",className:Je("flex w-full"),children:[{value:"still",label:"From a picture"},{value:"clip",label:"From a clip"}].map(t=>(0,e.jsx)("button",{type:"button",role:"radio","aria-checked":v===t.value,onClick:()=>{wi(t.value),Dt(s=>s&&Zn(s,t.value)?null:s),D(null),Mt(null)},className:Ae(v===t.value,"px-1.5 text-[11px]"),children:t.label},t.value))}),(0,e.jsx)("p",{className:"text-[10px] leading-relaxed text-zinc-500",children:zi?v==="clip"?"No model that can sync an existing clip is switched on right now. Try From a picture.":"No model that can animate a picture is switched on right now. Try From a clip.":v==="clip"?"Pick a clip and a voice track. The model moves the mouth in that clip to match the words, and saves the result as a new version of this shot. The clip you picked is kept.":"Pick a picture and the audio. The AI hears who says what, and makes a clip of the people in the picture saying their words. It is saved as a new version of this shot."}),v==="still"&&(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-[10px] font-medium text-zinc-400",children:"Source image"}),(0,e.jsx)("button",{type:"button",onClick:()=>fe(!0),className:"rounded-md text-[10px] text-amber-400 hover:text-amber-300 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:ce?"Replace":"Choose"})]}),ce?(0,e.jsxs)("div",{className:"overflow-hidden rounded-md border border-zinc-800 bg-zinc-900",children:[(0,e.jsx)("img",{src:ce,alt:"Portrait selected for lip sync",className:"aspect-video w-full object-contain"}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 px-2 py-1.5",children:[(0,e.jsx)("span",{className:"truncate text-[10px] text-zinc-400",children:le?.original_name??"Current storyboard picture"}),le&&(0,e.jsx)("button",{type:"button",onClick:Gr,className:"shrink-0 rounded-md text-[10px] text-zinc-500 hover:text-zinc-200 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-label":"Remove the replacement picture and use the current storyboard picture",children:"Remove"})]})]}):(0,e.jsxs)("button",{type:"button",onClick:()=>fe(!0),className:"flex min-h-20 w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-border-strong bg-card/40 p-3 text-muted-foreground transition-colors hover:bg-surface-hover hover:text-foreground outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,e.jsx)(yt,{className:"h-4 w-4","aria-hidden":"true"}),(0,e.jsx)("span",{className:"text-[10px]",children:"Choose an image"})]})]}),v==="still"&&Q&&(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("span",{className:"text-[10px] font-medium text-zinc-400",children:"Audio the mouths follow"}),(0,e.jsx)("div",{role:"radiogroup","aria-label":"Audio the mouths follow",className:Je("flex w-full"),children:[{value:"soundtrack",label:"Soundtrack"},{value:"asset",label:"Audio file"}].map(t=>(0,e.jsx)("button",{type:"button",role:"radio","aria-checked":se===t.value,onClick:()=>{Cr(t.value),D(null)},className:Ae(se===t.value,"px-1.5 text-[11px]"),children:t.label},t.value))}),se==="soundtrack"&&T&&(0,e.jsxs)("div",{className:"space-y-1.5 rounded-md border border-zinc-800 bg-zinc-900 p-2",children:[(0,e.jsxs)("p",{className:"text-[10px] leading-relaxed text-zinc-300",children:[T.asset?.original_name||T.name," ",(0,e.jsxs)("span",{className:"font-mono tabular-nums text-zinc-500",children:[ai(Q.start),"–",ai(Q.end)]})]}),(0,e.jsx)("audio",{src:`${Ee(T.asset?.s3_url||T.s3_url)}#t=${Q.fileStart.toFixed(2)},${Q.fileEnd.toFixed(2)}`,controls:!0,preload:"metadata",className:"h-8 w-full",children:"Your browser does not support audio playback."}),(0,e.jsx)("p",{className:"text-[9px] leading-relaxed text-zinc-600",children:"The part of your soundtrack that plays under this shot on the timeline. Nothing to cut by hand."})]})]}),se==="asset"&&(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"text-[10px] font-medium text-zinc-400",children:["Voice track"," ",(0,e.jsx)("span",{className:"text-amber-400",children:"Required"})]}),(0,e.jsx)("button",{type:"button",onClick:()=>Vt(!0),className:"rounded-md text-[10px] text-amber-400 hover:text-amber-300 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:L?"Replace":"Choose"})]}),L?(0,e.jsxs)("div",{className:"space-y-1.5 rounded-md border border-zinc-800 bg-zinc-900 p-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"truncate text-[10px] text-zinc-300",children:L.original_name}),(0,e.jsx)("button",{type:"button",onClick:()=>{_s(null),D(null)},className:"shrink-0 rounded-md text-[10px] text-zinc-500 hover:text-zinc-200 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-label":`Remove ${L.original_name}`,children:"Remove"})]}),(0,e.jsx)("audio",{src:L.s3_url,controls:!0,preload:"metadata",className:"h-8 w-full",children:"Your browser does not support audio playback."})]}):(0,e.jsxs)("button",{type:"button",onClick:()=>Vt(!0),className:"flex min-h-16 w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-border-strong bg-card/40 p-3 text-muted-foreground transition-colors hover:bg-surface-hover hover:text-foreground outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,e.jsx)(si,{className:"h-4 w-4","aria-hidden":"true"}),(0,e.jsx)("span",{className:"text-[10px]",children:"Choose audio"})]}),(0,e.jsx)("p",{className:"text-[9px] leading-relaxed text-zinc-600",children:"MP3 or WAV · 4–15 seconds · up to 15 MB"})]}),Gi&&(0,e.jsxs)("div",{className:"space-y-1 rounded-md border border-zinc-800 bg-zinc-900/60 p-2",children:[(0,e.jsx)("p",{className:"text-[10px] leading-relaxed text-zinc-300",children:Is?"The clip keeps its own sound. It plays together with your soundtrack, so the words can be heard twice.":"The clip's sound is muted on this shot. Your soundtrack plays the same words under it, so each word is heard once. Use “Mute clip sound” to turn it back on later."}),(0,e.jsxs)("label",{className:"flex items-center gap-2 text-[10px] text-zinc-400",children:[(0,e.jsx)("input",{type:"checkbox",checked:Is,onChange:t=>Mr(t.target.checked),className:"h-3 w-3 accent-amber-400"}),"Keep the clip's own sound"]})]}),v==="clip"&&(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"text-[10px] font-medium text-zinc-400",children:["Clip to lip sync"," ",(0,e.jsx)("span",{className:"text-amber-400",children:"Required"})]}),(0,e.jsx)("button",{type:"button",onClick:()=>Lt(!0),className:"rounded-md text-[10px] text-amber-400 hover:text-amber-300 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:J?"Replace":"Choose"})]}),J?(0,e.jsxs)("div",{className:"space-y-1.5 rounded-md border border-zinc-800 bg-zinc-900 p-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"truncate text-[10px] text-zinc-300",children:J.original_name}),(0,e.jsx)("button",{type:"button",onClick:()=>{Dt(null),D(null)},className:"shrink-0 rounded-md text-[10px] text-zinc-500 hover:text-zinc-200 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-label":`Remove ${J.original_name}`,children:"Remove"})]}),(0,e.jsx)("video",{src:J.s3_url,controls:!0,preload:"metadata",className:"h-20 w-full rounded",children:"Your browser does not support video playback."})]}):(0,e.jsxs)("button",{type:"button",onClick:()=>Lt(!0),className:"flex min-h-16 w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-border-strong bg-card/40 p-3 text-muted-foreground transition-colors hover:bg-surface-hover hover:text-foreground outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,e.jsx)(wa,{className:"h-4 w-4","aria-hidden":"true"}),(0,e.jsx)("span",{className:"text-[10px]",children:"Choose a video"})]}),(0,e.jsx)("p",{className:"text-[9px] leading-relaxed text-zinc-600",children:"MP4 or MOV · 2–10 seconds · up to 50 MB"})]}),v==="still"&&ls&&(0,e.jsx)("div",{className:"space-y-1.5",children:(0,e.jsx)("ul",{role:"alert",className:"flex flex-col gap-0.5",children:ls.map(t=>(0,e.jsxs)("li",{className:"flex items-start gap-1.5 text-[11px] leading-snug text-amber-300",children:[(0,e.jsx)(ss,{className:"mt-0.5 h-3 w-3 shrink-0","aria-hidden":"true"}),t]},t))})})]})]}),(0,e.jsxs)("div",{className:"relative flex flex-1 flex-col lg:min-h-0",children:[!k&&G===null&&!E&&Wi&&(0,e.jsxs)("div",{className:"absolute inset-x-0 top-0 z-30 flex items-center gap-2 border-b border-zinc-800 bg-zinc-950/95 px-3 py-2 text-xs text-warning backdrop-blur-sm sm:px-4",children:[(0,e.jsx)(ma,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),(0,e.jsxs)("span",{children:[di("clip",Wi)," Generate it again below."]})]}),!k&&r!=="omni-edit"&&G===null&&E&&(r!=="lip-sync"||$t)&&(0,e.jsxs)("div",{className:"absolute inset-x-0 top-0 z-30 flex flex-wrap items-center gap-2 border-b border-zinc-800 bg-zinc-950/95 px-3 py-2 backdrop-blur-sm sm:px-4",children:[(0,e.jsx)(jt,{className:"h-4 w-4 text-success","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"mr-auto flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-zinc-400",children:[(0,e.jsx)("span",{className:"font-medium text-zinc-200",children:"This clip:"}),oe?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(li,{variant:"primary",children:oe.method}),(0,e.jsx)("span",{className:"tabular-nums",children:[oe.model,oe.madeAt&&es(oe.madeAt)].filter(
2Boolean).join(" · ")})]}):(0,e.jsx)("span",{children:"saved"}),n.active_version?.version_number&&(0,e.jsxs)("span",{className:"text-zinc-500",children:["v",n.active_version.version_number]})]}),Ke!==null&&Pi!==null&&n.active_version?.id===Pi&&(0,e.jsx)(m,{variant:"ghost",size:"sm",onClick:()=>void ea(),className:"text-muted-foreground hover:text-foreground",title:"Put back what this shot had before this clip",children:"Undo"}),st&&ee!==null?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(m,{variant:"outline",size:"sm",onClick:()=>st(ee),rightIcon:(0,e.jsx)(Tn,{className:"h-3.5 w-3.5"}),children:"Next shot"}),(0,e.jsx)(m,{variant:"outline",size:"sm",onClick:Ce,children:"Back to board"})]}):(0,e.jsx)(m,{variant:"outline",size:"sm",onClick:Ce,children:"Back to board"}),(0,e.jsx)(m,{variant:"ghost",size:"sm",onClick:()=>{ot(null),kt("omni-edit")},className:"text-muted-foreground hover:text-foreground",children:"Open VFX"})]}),(0,e.jsx)("div",{className:"relative flex min-h-[40dvh] flex-1 items-center justify-center overflow-hidden bg-black/50 p-2 sm:p-4 lg:min-h-0",children:k?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,e.jsx)(we,{className:"h-10 w-10 animate-spin text-primary"}),(0,e.jsxs)("div",{className:"min-h-14 text-center",children:[(0,e.jsx)("p",{role:"status",className:"text-sm text-zinc-300 transition-opacity",children:vo({kind:"video",hasJob:X!==null,jobStatus:gr,progress:lt,mode:r})}),lt>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mx-auto mt-2 h-1.5 w-48 overflow-hidden rounded-full bg-zinc-800",children:(0,e.jsx)("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:`${lt}%`}})}),(0,e.jsxs)("p",{className:"mt-1 text-xs text-zinc-500",children:[lt,"%",Ti?` — ${Ti} remaining`:""]})]})]}),Ki&&(0,e.jsxs)("div",{className:"w-full max-w-sm rounded-md border border-zinc-800 bg-zinc-900/80 px-4 py-3.5 text-center",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-zinc-100",children:"You don't have to wait here"}),(0,e.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-zinc-400",children:["This clip keeps generating while you work on other shots. We'll tell you when",_e!==null?` Shot ${_e}`:" it"," ","is ready."]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center justify-center gap-2",children:[as&&(0,e.jsxs)(m,{size:"sm",onClick:()=>ee!==null&&st?.(ee),children:[as,(0,e.jsx)(Tn,{className:"h-3.5 w-3.5","aria-hidden":!0})]}),(0,e.jsx)(m,{size:"sm",variant:as?"outline":"default",onClick:Ce,children:"Back to board"})]})]})]}):Li&&At.length>=2?(0,e.jsx)("div",{className:"flex h-full w-full flex-col gap-2 lg:flex-row",children:At.slice(-2).map((t,s)=>(0,e.jsxs)("div",{className:"flex-1 overflow-hidden rounded border border-zinc-700",children:[(0,e.jsx)("video",{src:t.videoUrl,className:"h-full w-full object-contain",loop:!0,playsInline:!0,controls:!0}),(0,e.jsxs)("div",{className:"bg-zinc-900 px-2 py-1",children:[(0,e.jsxs)("p",{className:"text-[10px] text-zinc-400",children:[Gn(ci(t.provider))," ","• ",t.duration,"s"]}),(0,e.jsx)("p",{className:"truncate text-[10px] text-zinc-500",children:t.prompt.substring(0,60)}),(0,e.jsx)(m,{size:"xs",onClick:()=>{ue(t.videoUrl),f(t.videoUrl),br(!1),d.success("Variant applied")},className:"mt-1 w-full",children:"Use this"})]})]},t.id))}):E&&(r!=="lip-sync"||$t)?(0,e.jsx)("div",{className:"relative flex h-full w-full max-h-full max-w-full items-center justify-center",children:gn?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center p-8",children:[(0,e.jsx)("div",{className:"text-amber-500",children:(0,e.jsx)(ri,{className:"h-12 w-12 mx-auto"})}),(0,e.jsx)("p",{className:"text-sm text-zinc-400 max-w-md",children:"Could not load this video clip. It may still be processing, or the connection dropped."}),(0,e.jsx)(m,{variant:"secondary",onClick:()=>qt(null),children:"Retry"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",onClick:()=>{U.current?.pause(),Le(!1),ys(!0)},className:"absolute right-2 top-2 z-10 rounded-full bg-black/65 p-2 text-zinc-200 outline-none transition-colors hover:bg-black/80 hover:text-white focus-visible:ring-[3px] focus-visible:ring-ring/50",title:"Open full preview",children:(0,e.jsx)(ei,{className:"h-4 w-4"})}),(0,e.jsx)("video",{ref:U,src:P,className:"h-full w-full max-h-full max-w-full rounded object-contain",loop:!0,playsInl
2ine:!0,muted:W||mt,onError:Yr,onLoadedData:Xr,onLoadedMetadata:vn,onDurationChange:vn,onTimeUpdate:t=>{qr(t),He()},onSeeked:He,onPlay:()=>{Le(!0),He()},onPause:()=>{Le(!1),He()},onEnded:()=>Le(!1)}),dt&&(0,e.jsx)("audio",{ref:Ts,src:dt,preload:"auto",className:"hidden"})]})}):Fr?$s?(0,e.jsxs)("div",{className:"group relative flex h-full min-h-0 w-full flex-col items-center gap-3 text-center",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>ws($s),className:"relative flex min-h-0 w-full flex-1 items-center justify-center rounded-lg outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-label":"View storyboard picture full size",title:"View full size",children:[(0,e.jsx)("img",{src:$s,alt:"Storyboard picture",className:"max-h-full max-w-full rounded object-contain opacity-60 transition-opacity group-hover:opacity-80"}),(0,e.jsx)("span",{className:"absolute right-2 top-2 rounded-full bg-black/65 p-1.5 text-zinc-200 opacity-0 transition-opacity group-hover:opacity-100",children:(0,e.jsx)(ei,{className:"h-4 w-4"})})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,e.jsx)("p",{className:"text-xs text-zinc-400",children:r==="lip-sync"?v==="still"&&Ut?Ut:se==="soundtrack"||L?"Ready. Check who says what below, then click Sync.":"Picture ready. Choose the audio, then click Sync.":"Starting storyboard ready. Describe the movement, then click Generate video clip."}),(0,e.jsx)(m,{size:"xs",variant:"ghost",onClick:()=>r==="lip-sync"?fe(!0):he(!0),className:"text-amber-400 hover:text-amber-300",children:"Change storyboard"}),(0,e.jsx)("span",{className:"text-zinc-600 text-xs",children:"•"}),(0,e.jsxs)(m,{size:"xs",variant:"ghost",onClick:()=>ft(!0),className:"text-muted-foreground hover:text-foreground",title:"Upload a video or pick one from My files for this shot",children:[(0,e.jsx)(ni,{className:"h-3 w-3"}),"Upload video"]})]})]}):(0,e.jsxs)("div",{onDragOver:t=>{t.preventDefault(),t.stopPropagation()},onDrop:t=>{if(t.preventDefault(),t.stopPropagation(),r==="lip-sync"){fe(!0);return}const s=Array.from(t.dataTransfer.files).find(a=>a.type.startsWith("image/"));if(s)Ur(s);else{const a=t.dataTransfer.getData("text/plain");a&&(a.startsWith("http")||a.startsWith("/"))&&(Ve(a),d.success("Reference picture added."))}},className:"flex flex-col items-center justify-center p-8 border-2 border-dashed border-zinc-700 hover:border-amber-500/60 rounded-xl bg-zinc-900/40 text-center transition-colors group max-w-md mx-auto my-6 cursor-pointer",onClick:()=>r==="lip-sync"?fe(!0):he(!0),children:[(0,e.jsx)("div",{className:"w-12 h-12 rounded-full bg-zinc-800 flex items-center justify-center mb-3 group-hover:scale-110 transition-transform",children:(0,e.jsx)(yt,{className:"h-6 w-6 text-amber-400/80"})}),(0,e.jsx)("p",{className:"text-sm font-semibold text-zinc-200 mb-1",children:r==="lip-sync"?"Choose a portrait":tn?"Choose a starting storyboard":"This shot needs a storyboard picture first"}),(0,e.jsx)("p",{className:"text-xs text-zinc-400 mb-4 max-w-xs leading-relaxed",children:hn?"Uploading storyboard…":r==="lip-sync"?"Pick a picture from My files to animate to your audio.":"A video clip starts from the shot's storyboard picture."}),(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[r!=="lip-sync"&&Ct&&!tn&&(0,e.jsxs)(m,{size:"sm",onClick:t=>{t.stopPropagation(),Ct(1)},children:[(0,e.jsx)(qe,{className:"h-3.5 w-3.5"}),"Draw storyboard"]}),(0,e.jsxs)(m,{size:"sm",variant:"outline",disabled:hn,onClick:t=>{t.stopPropagation(),r==="lip-sync"?fe(!0):he(!0)},children:[(0,e.jsx)(yt,{className:"h-3.5 w-3.5"}),"Use a picture from My files"]})]})]}):(0,e.jsxs)("div",{className:"mx-auto my-6 flex max-w-md flex-col items-center gap-2 p-8 text-center",children:[(0,e.jsx)("div",{className:"mb-1 flex h-12 w-12 items-center justify-center rounded-full bg-zinc-800",children:(0,e.jsx)(bt,{className:"h-6 w-6 text-amber-400/80"})}),(0,e.jsx)("p",{className:"text-sm font-semibold text-zinc-200",children:r==="text-to-video"?"No clip yet":r==="omni-edit"?"No video picked":r==="lip-sync"?"No clip picked":"Nothing to preview yet"}),(0,e.jsx)("p",{className:"max-w-xs text-xs leading-relaxed text-zinc-400",children:r==="text-to-vi
2deo"?"Describe the clip below, then click Generate video clip. This mode uses your words, not the shot's storyboard.":r==="omni-edit"?"Pick a video in the sidebar, then describe the change you want.":r==="lip-sync"?"Choose the clip you want to lip sync in the sidebar, then choose the voice track.":r==="extend"?"Generate a clip on this shot first, then make it longer.":"Generate a clip on this shot first, then reverse it."}),(0,e.jsxs)(m,{size:"sm",variant:"outline",onClick:()=>ft(!0),className:"mt-2",children:[(0,e.jsx)(ni,{className:"h-3.5 w-3.5"}),"Upload or pick a video"]})]})}),E&&!Li&&(r!=="lip-sync"||$t)&&(0,e.jsxs)("div",{className:"border-t border-zinc-800 px-4 py-2",children:[(0,e.jsxs)("div",{className:"group relative h-2 cursor-pointer rounded-full bg-zinc-800",onClick:ia,children:[(0,e.jsx)("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:`${me?St/me*100:0}%`}}),(0,e.jsx)("div",{className:"absolute top-1/2 h-3 w-3 -translate-y-1/2 rounded-full bg-white shadow-md opacity-0 transition-opacity group-hover:opacity-100",style:{left:`${me?St/me*100:0}%`}})]}),(0,e.jsxs)("div",{className:"mt-1.5 flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1 font-mono text-[10px] text-zinc-500 min-w-[70px]",children:[(0,e.jsx)("span",{children:Cn(St)}),(0,e.jsx)("span",{className:"text-zinc-700",children:"/"}),(0,e.jsx)("span",{children:Cn(me)})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsx)(is,{size:"icon-sm",onClick:()=>_n("back"),className:"text-muted-foreground hover:text-foreground",title:"Skip back","aria-label":"Skip back",icon:(0,e.jsx)(xa,{className:"h-3.5 w-3.5"})}),(0,e.jsx)("button",{type:"button",onClick:sa,className:"rounded-full bg-zinc-800 p-1.5 text-zinc-200 outline-none transition-colors hover:bg-zinc-700 focus-visible:ring-[3px] focus-visible:ring-ring/50",title:et?"Pause":"Play",children:et?(0,e.jsx)(va,{className:"h-4 w-4"}):(0,e.jsx)(En,{className:"h-4 w-4"})}),(0,e.jsx)(is,{size:"icon-sm",onClick:()=>_n("forward"),className:"text-muted-foreground hover:text-foreground",title:"Skip forward","aria-label":"Skip forward",icon:(0,e.jsx)(la,{className:"h-3.5 w-3.5"})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[dt&&(0,e.jsxs)("div",{className:Je("h-7"),role:"group","aria-label":"Sound in the preview",children:[(0,e.jsx)("button",{type:"button","aria-pressed":!ut,onClick:()=>Ms(!1),className:Ae(!ut,"px-2 text-[11px]"),title:"Play the soundtrack under this shot, as the film plays it",children:"Film sound"}),(0,e.jsx)("button",{type:"button","aria-pressed":ut,onClick:()=>Ms(!0),className:Ae(ut,"px-2 text-[11px]"),title:"Play the sound inside the clip file. The film does not play it.",children:"Clip's own sound"})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 rounded-lg bg-zinc-900/40 px-2 py-0.5 border border-zinc-800/40",children:[(0,e.jsx)(Qt,{content:W?"Unmute":"Mute",side:"top",children:(0,e.jsx)("button",{type:"button",onClick:()=>rs(!W),className:"flex items-center justify-center rounded-md text-zinc-400 outline-none transition-colors duration-150 hover:text-zinc-200 focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-label":W?"Unmute":"Mute","aria-pressed":W,children:W||Se===0?(0,e.jsx)(Pn,{className:"h-3.5 w-3.5","aria-hidden":"true"}):(0,e.jsx)(si,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),(0,e.jsx)(Aa,{min:0,max:1,step:.05,value:[W?0:Se],onValueChange:([t])=>{lr(t),t>0&&rs(!1)},className:"w-16","aria-label":"Video volume"}),(0,e.jsxs)("span",{className:"text-[9px] text-zinc-500 w-7 text-right tabular-nums",children:[Math.round((W?0:Se)*100),"%"]})]})]})]})]}),(0,e.jsx)(ao,{storageKey:"motion-editor-prompt-height",minHeight:160,maxHeight:850,className:"border-t border-zinc-800 bg-zinc-950",children:(0,e.jsxs)("div",{className:"flex flex-1 min-h-0 flex-col overflow-hidden",children:[(0,e.jsx)("div",{className:"shrink-0 px-3 pt-2 empty:hidden sm:px-4",children:Ds.length>0&&r==="image-to-video"&&(0,e.jsx)("div",{className:"mb-3 space-y-2",children:Ds.map((t,s)=>(0,e.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-800/50 bg-primary/30 p-2.5",children:[(0,e.jsx)(ss,{className:"mt-0.5 h-3.5 w-3.5 flex-shrink-0 text-primary"}),(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,e.jsx)("p",{className:"text-xs text-primary",children:t.message}),t.switchTo&&(0,e.jsx)("button",{type:"button",onClick:()=>{const a=t.switchTo;ds(!0),Me(a.slug),d.success(`Switched to ${a.ui_label||a.name}`)},className:"rounded-md text-left text-[10px] text-primary outline-none hover:underline focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"Switch model"})]})]},s))})}),r!=="lip-sync"&&(0,e.jsx)("div",{className:"shrink-0 border-t border-zinc-800/60 px-3 pt-2 sm:px-4",children:(0,e.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-1.5",children:[(0,e.jsxs)(Fa,{children:[(0,e.jsx)(Da,{asChild:!0,children:(0,e.jsxs)(m,{type:"button",variant:"outline",size:"xs",disabled:r==="reverse",className:ts,title:"Add a character's mention to the prompt",children:[(0,e.jsx)(fa,{className:"h-3 w-3"}),"Add character"]})}),(0,e.jsxs)(Va,{align:"start",className:"z-[70] w-56 bg-zinc-900 border border-zinc-800 text-zinc-100 p-1 shadow-xl",children:[Xe.filter(t=>t.is_active).length===0?(0,e.jsx)(On,{className:"text-xs text-zinc-500",children:"No characters yet"}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(On,{className:"text-[10px] uppercase tracking-wider text-zinc-500",children:"Characters"}),Xe.filter(t=>t.is_active).map(t=>{const s=oi(C,t);return(0,e.jsxs)($n,{onSelect:a=>{a.preventDefault(),s?Rr(t):Ar(t)},className:"flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-zinc-800 cursor-pointer rounded-sm",children:[t.primary_reference?.s3_url?(0,e.jsx)("img",{src:t.primary_reference.s3_url,alt:t.name,className:"h-6 w-6 rounded-full object-cover border border-zinc-700 shrink-0"}):(0,e.jsx)("div",{className:"h-6 w-6 rounded-full bg-zinc-800 border border-zinc-700 flex items-center justify-center text-[10px] text-zinc-400 font-semibold shrink-0",children:t.name[0]}),(0,e.jsxs)("div",{className:"flex flex-col min-w-0 flex-1",children:[(0,e.jsx)("span",{className:"truncate font-medium text-zinc-200",children:t.name}),t.role&&(0,e.jsx)("span",{className:"truncate text-[10px] text-zinc-400",children:t.role})]}),s&&(0,e.jsx)(jt,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},t.id)}),(0,e.jsx)(La,{className:"bg-zinc-800 my-1"})]}),(0,e.jsxs)($n,{onSelect:t=>{t.preventDefault(),_t("new")},className:"flex items-center gap-2 px-2 py-1.5 text-xs font-medium text-primary hover:bg-primary/10 hover:text-primary curs
2or-pointer rounded-sm",children:[(0,e.jsx)(ti,{className:"mr-2 h-4 w-4"}),"New character"]})]})]}),(0,e.jsx)(co,{projectUuid:o,prompt:C,onAdd:t=>rt([t]),onRemove:t=>te(Zt(C,t)),disabled:r==="reverse",className:F(ka({variant:"outline",size:"xs"}),ts),iconClassName:"h-3 w-3"}),(0,e.jsxs)(m,{type:"button",variant:"outline",size:"xs",onClick:()=>Ai(!0),title:`Open ${r==="omni-edit"?"VFX presets":"Motion templates"} sheet`,children:[(0,e.jsx)(qe,{className:"h-3.5 w-3.5 text-amber-400 shrink-0"}),(0,e.jsx)("span",{children:r==="omni-edit"?"VFX presets":"Motion templates"})]}),(r==="image-to-video"||r==="text-to-video")&&(0,e.jsxs)(m,{type:"button",variant:"outline",size:"xs",disabled:ve||ie||k,onClick:()=>void Lr(n.id,t=>{const s=t.motion_prompt??"";ht.current=s,tt(s)},{field:"motion_prompt",text:B}),className:ts,title:"Write this shot's picture prompt, video prompt and panels again from its script",children:[ve?(0,e.jsx)(we,{className:"h-3 w-3 animate-spin"}):(0,e.jsx)(ya,{className:"h-3 w-3"}),ve?"Regenerating frame…":"Regenerate frame from script"]}),qi.length>0&&(0,e.jsxs)("span",{className:"text-xs text-amber-500 font-medium flex items-center gap-1",children:[(0,e.jsx)(ss,{className:"h-3 w-3 shrink-0"}),(0,e.jsxs)("span",{children:["Missing ref:"," ",qi.map((t,s)=>(0,e.jsxs)("span",{children:[s>0&&", ",(0,e.jsx)("button",{type:"button",onClick:()=>_t(t),className:"underline underline-offset-2 hover:text-amber-400 cursor-pointer",children:t.name})]},t.id))]})]}),(0,e.jsxs)(m,{type:"button",variant:"outline",size:"xs",onClick:()=>Bs(!0),disabled:r==="reverse",className:ts,title:"Pick a picture from your files. Its mention goes into the prompt.",children:[(0,e.jsx)(yt,{className:"h-3 w-3"}),"Add reference"]})]})}),(0,e.jsxs)("div",{className:"flex-1 min-h-[170px] flex flex-col border-t border-zinc-800/60 px-3 pb-3 pt-2 sm:px-4",children:[Be&&(0,e.jsxs)("div",{className:"mb-2 flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/10 p-2.5",children:[(0,e.jsx)(ri,{className:"mt-0.5 h-3.5 w-3.5 flex-shrink-0 text-destructive"}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("p",{className:"text-[11px] font-medium text-destructive",children:Be.title}),(0,e.jsx)("p",{className:"mt-0.5 text-[11px] text-zinc-300",children:Be.message})]}),!Be.retryable&&(0,e.jsx)(li,{variant:"destructive",children:Be.action_label?`${Be.action_label} to continue`:"Retrying as-is won't help"})]}),(0,e.jsxs)("div",{className:"flex flex-1 min-h-0 flex-col items-stretch gap-2 lg:flex-row lg:items-end",children:[r==="lip-sync"?$t&&oe?.mode==="lip-sync"?(0,e.jsx)(_o,{lines:n.active_version?.data?.video_generation_job?.transcript_lines,currentTime:St,nextShotNumber:Sr,onSeek:t=>{const s=U.current;s&&(s.currentTime=t,s.play().catch(()=>{}))},onNewSync:()=>D(null)}):v==="still"?(0,e.jsx)(No,{frameId:n.id,audioSource:se,audioAssetId:L?.id??null,imageAssetId:le?.id??null,pictureUrl:ce??null,onPictureRefusal:Ir}):(0,e.jsx)("div",{className:"flex min-h-[144px] flex-1 items-center rounded-lg border border-border bg-zinc-900 px-3 py-2",children:(0,e.jsx)("p",{className:"text-xs text-zinc-400",children:"The mouth in your clip is moved to match the voice track. There is nothing to write."})}):(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-1.5",children:[ps&&(0,e.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-[10px] font-medium uppercase tracking-wide text-zinc-400",children:"Video prompt"}),(0,e.jsx)("span",{className:"text-[10px] text-zinc-500",children:"The clip is made from these words."})]}),ps&&n.active_version?.motion_prompt_stale&&(0,e.jsxs)("div",{role:"status",className:"rounded-md border border-amber-500/30 bg-amber-500/5 px-2.5 py-1.5",children:[(0,e.jsx)("p",{className:"text-[11px] leading-snug text-amber-300",children:"This video prompt was written for an earlier picture prompt, so the clip may not show your storyboard. Change it here, or rewrite it from the picture prompt."}),(0,e.jsxs)("details",{className:"mt-1",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-[10px] text-zinc-400 hover:text-zinc-200",children:"The storyboard's picture prompt"}),(0,e.jsx)("p",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] text-zinc-300",children:n.active_version?.data?.image_prompt})]}),(0,e.jsxs)(m,{type:"button",variant:"outline",size:"xs",className:"mt-1.5",disabled:ie||ve||k,onClick:()=>void sn([n.id],"motion_prompt",B,{askFirst:!1,onRewritten:t=>{ht.current=t,tt(t)}}),children:[ie?(0,e.jsx)(we,{className:"h-3 w-3 animate-spin"}):(0,e.jsx)(qe,{className:"h-3 w-3"}),ie?"Writing prompt…":"Rewrite from picture prompt"]})]}),(0,e.jsx)(Un,{value:C,onChange:ie||ve?()=>{}:te,readOnly:ie||ve,"aria-busy":ie,mentions:rn,onSelect:dr,onMentionInserted:Es,onMentionRemoved:t=>{const s=Ps(t.tag);s&&Bt(s.id)},onKeyDown:aa,canEditMention:As.canEditMention,onEditMention:As.onEditMention,placeholder:r==="omni-edit"?"Describe the edit — make it anime, remove the car, relight it. Type @ to add a character, a film set or a picture.":"Describe the movement. Type @ to add a character, a film set or a picture.",minHeight:"144px",className:"min-h-[144px] flex-1 rounded-lg border border-border bg-zinc-900 px-3 py-2 text-sm text-zinc-100 shadow-field placeholder:text-zinc-600 outline-none focus-visible:border-ring/60 focus-visible:ring-[3px] focus-visible:ring-ring/15",overlayBgClassName:"bg-zinc-900",mentionClassName:"bg-primary/20 text-primary font-medium ring-2 ring-zinc-900",fillHeight:!0}),ps&&(0,e.jsxs)("div",{className:"flex shrink-0 flex-col gap-1",children:[(0,e.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-[10px] font-medium uppercase tracking-wide text-zinc-400",children:"Spoken in this clip"}),(0,e.jsx)("span",{className:"text-[10px] text-zinc-500",children:fr})]}),(0,e.jsx)(Un,{value:H,onChange:k?()=>{}:vi,readOnly:k,mentions:rn,placeholder:"No one speaks. To add a line, type it as Name: words.",minHeight:"44px",className:"min-h-[44px] rounded-lg border border-border bg-zinc-900 px-3 py-2 text-sm text-zinc-100 shadow-field placeholder:text-zinc-600 outline-none focus-visible:border-ring/60 focus-visible:ring-[3px] focus-visible:ring-ring/15",overlayBgClassName:"bg-zinc-900",mentionClassName:"bg-primary/20 text-primary font-medium ring-2 ring-zinc-900"}),Mi&&(0,e.jsx)("p",{role:"status",className:"text-[11px] leading-snug text-amber-400",children:Mi})]})]}),(0,e.jsxs)("div",{className:"flex w-full shrink-0 flex-col justify-end gap-2 lg:w-56",children:[r==="lip-sync"?(0,e.jsxs)("div",{className:"rounded-lg border border-border bg-card/60 px-2.5 py-1.5",children:[(0,e.jsx)("p",{className:"text-[9px] uppercase tracking-wide text-zinc-500",children:"Model"}),(0,e.jsx)("p",{className:"text-[11px] font-medium text-zinc-200",children:hr??"None switched on"})]}):r==="extend"?(0,e.jsxs)("div",{className:"rounded-lg border border-border bg-card/60 px-2.5 py-1.5",children:[(0,e.jsx)("p",{className:"text-[9px] uppercase tracking-wide text-zinc-500",children:"Model"}),(0,e.jsx)("p",{className:"text-[11px] font-medium text-zinc-200",children:"WAN 3.0"}),(0,e.jsx)("p",{className:"text-[10px] leading-snug text-zinc-500",children:"Keeps this clip and adds the new seconds after it, up to 30 s in all. Clips up to 15 s."}),(0,e.jsxs)("div",{className:"mt-1.5 flex items-center gap-2",children:[(0,e.jsx)("label",{htmlFor:"extend-seconds",className:"text-[10px] text-zinc-400",children:"Add"}),(0,e.jsxs)(Dn,{value:String(nt),onValueChange:t=>bi(Number(t)),children:[(0,e.jsx)(Rn,{id:"extend-seconds",className:"h-7 w-auto min-w-[72px] text-xs",children:(0,e.jsx)(An,{})}),(0,e.jsx)(Vn,{children:Kt.map(t=>(0,e.jsxs)(Ln,{value:String(t),children:[t," s"]},t))})]})]})]}):(0,e.jsx)(bo,{providers:re,selectedSlug:V,onSelect:t=>{ds(!0);const s=Y.find(a=>a.slug===t);Zi.current=s&&!s.supports_audio_reference?t:null,Ls(null),Me(t)},compact:!0,stacked:!0,className:"w-full"}),on&&(0,e.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,e.jsx)("input",{type:"checkbox",checked:!ms,onChange:t=>Ci(!t.target.checked),className:"h-3.5 w-3.5 rounded border-zinc-600 bg-zinc-800 accent-amber-500"}),(0,e.jsx)("span",{className:"text-[11px] text-zinc-400",children:"Add sound to this clip"}),(0,e.jsx)(Qt,{content:"The AI adds its own sound or music to the clip. Turn it off when your film's music or voice carries the sound, for example in a music video.",side:"left",children:(0,e.jsx)(Na,{className:"h-3 w-3 text-zinc-500 hover:text-zinc-300","aria-label":"About clip sound"})})]}),Wt&&(0,e.jsxs)("p",{role:"status",className:F("flex items-start gap-1.5 text-[11px] leading-snug",Wt.kind==="swapped"?"text-zinc-400":"rounded-md bg-amber-500/10 px-2 py-1.5 text-amber-400"),children:[(0,e.jsx)(In,{className:"mt-px h-3 w-3 shrink-0","aria-hidden":"true"}),(0,e.jsx)("span",{children:Wt.kind==="swapped"?(0,e.jsxs)(e.Fragment,{children:["Picked because it can use"," ",ge.length===1?`${ge[0].name}'s voice`:"your cast's voices","."]}):(0,e.jsxs)(e.Fragment,{children:[Wt.from," takes no character voice, so"," ",ge.length===1?ge[0].name:"your cast"," ","will not sound right in this clip."]})})]}),(0,e.jsxs)(m,{onClick:qs,disabled:k||!!gt,title:gt??void 0,"aria-describedby":gt?"motion-generate-blocked":void 0,className:"w-full px-5",children:[k?(0,e.jsx)(we,{className:"h-4 w-4 animate-spin"}):r==="reverse"?(0,e.jsx)(ii,{className:"h-4 w-4"}):r==="lip-sync"?(0,e.jsx)(In,{className:"h-4 w-4"}):r==="extend"?(0,e.jsx)(pa,{className:"h-4 w-4"}):r==="omni-edit"?(0,e.jsx)(ja,{className:"h-4 w-4"}):(0,e.jsx)(bt,{className:"h-4 w-4"}),k?(0,e.jsx)(no,{kind:It?{type:It.type,providerSlug:It.provider_slug}:r==="omni-edit"?{type:"video_edit"}:r==="lip-sync"||r==="reverse"?null:{type:"video",providerSlug:V}
2,startedAt:It?.created_at,serverProgress:lt}):r==="reverse"?"Reverse":r==="lip-sync"?"Sync":r==="extend"?"Extend":r==="omni-edit"?"Edit":E?"Generate again":"Generate video clip"]}),gt&&!k&&(0,e.jsx)("p",{id:"motion-generate-blocked",className:"text-[11px] leading-snug text-zinc-400",children:gt})]})]}),r!=="lip-sync"&&r!=="reverse"&&(0,e.jsx)(Ua,{...Fs,refusedIssues:ls,onRemoveToken:t=>{te(Zt(C,t));const s=Ps(t);s&&Bt(s.id)},showCapacity:r!=="extend",className:"mt-1.5 shrink-0"}),(0,e.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[(r==="image-to-video"||r==="text-to-video")&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",onClick:()=>void sn([n.id],"motion_prompt",B,{onRewritten:t=>{ht.current=t,tt(t)}}),disabled:ie||ve||k,className:"inline-flex min-h-6 items-center gap-1 rounded-md text-[10px] text-zinc-400 outline-none transition-colors hover:text-zinc-200 focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50",children:[ie?(0,e.jsx)(we,{className:"h-3 w-3 animate-spin"}):(0,e.jsx)(qe,{className:"h-3 w-3 text-violet-400"}),ie?"Writing prompt…":"Rewrite this prompt with AI"]}),(0,e.jsx)("span",{className:"text-[10px] text-zinc-700",children:"|"})]}),(0,e.jsxs)(Bn,{children:[navigator.platform.includes("Mac")?"⌘":"Ctrl","+Enter"]}),(0,e.jsx)("span",{className:"text-[10px] text-zinc-600",children:"to generate"}),Er.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-[10px] text-zinc-700",children:"|"}),(0,e.jsxs)("span",{className:"text-[10px] text-zinc-500",children:["Type ",(0,e.jsx)(Bn,{children:"@"})," for characters"]})]})]})]})]})})]}),vr&&(0,e.jsxs)("div",{className:"max-h-[35vh] w-full shrink-0 overflow-y-auto border-t border-zinc-800 bg-zinc-900/50 p-4 lg:max-h-none lg:w-64 lg:border-l lg:border-t-0",children:[(0,e.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-zinc-200",children:"Version history"}),(0,e.jsx)(is,{size:"icon-sm",onClick:()=>Vi(!1),"aria-label":"Close version history",icon:(0,e.jsx)(wt,{className:"h-3.5 w-3.5"})})]}),Fi?(0,e.jsx)("div",{className:"flex justify-center py-8",children:(0,e.jsx)(we,{className:"h-5 w-5 animate-spin text-zinc-500"})}):ae.length===0?(0,e.jsx)("p",{className:"py-4 text-center text-xs text-zinc-600",children:"No history"}):(0,e.jsx)("div",{className:"space-y-2",children:ae.map((t,s)=>{const a=t.data?.generated_video_url,l=t.deleted_media?.clip??ui(t.data,"clip"),u=ae[s+1]?.data?.generated_video_url,w=!!a&&a!==u,R=t.data?.video_generation_job,ye=R?.prompt_sha256?R.prompt??"":null,O=w?Kn(t.data,t.created_at):null,Js=O?.mode==="lip-sync"?R?.transcript_lines?.[0]:void 0,Mn=w&&O?.mode!=="lip-sync"?Yn(t.data).trim():"",Qs=w&&ye!==null&&zn.has(t.id)?zn.get(t.id):void 0;return(0,e.jsxs)("div",{className:F("rounded-md border p-2.5",t.is_active?"border-amber-500/30 bg-primary/5":"border-zinc-800"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-zinc-300",children:["v",t.version_number]}),O&&(0,e.jsx)(li,{variant:O.mode==="lip-sync"?"primary":"outline",children:O.method}),t.is_active&&(0,e.jsxs)("span",{className:"ml-auto flex items-center gap-1 text-[10px] text-primary",children:[(0,e.jsx)(jt,{className:"h-3 w-3","aria-hidden":"true"}),"On the shot"]})]}),(0,e.jsx)("p",{className:"mt-0.5 text-[10px] tabular-nums text-zinc-500",title:t.created_at,children:es(t.created_at)}),l&&(0,e.jsx)("p",{className:"mt-1.5 text-[10px] leading-tight text-warning",children:di("clip",l)}),a&&!l&&(0,e.jsxs)("button",{type:"button",onClick:()=>{bs(a),Oi(t.version_number),jr(O?[O.method,O.model,es(t.created_at)].filter(Boolean).join(" · "):es(t.created_at))},className:"group mt-1.5 flex w-full items-center gap-2 rounded-lg bg-zinc-800/50 p-1.5 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[(0,e.jsx)("div",{className:"relative flex h-8 w-14 items-center justify-center rounded bg-black",children:(0,e.jsx)(En,{className:"h-3 w-3 text-zinc-400 group-hover:text-primary"})}),(0,e.jsx)("span",{className:"text-[10px] text-zinc-400 group-hover:text-zinc-200",children:"Preview video"})]}),O?O.model&&(0,e.jsx)("p",{className:"mt-1 text-[11px] text-zinc-500",children:O.model}):t.change_summary&&(0,e.jsx)("p",{className:"mt-1 text-[11px] text-zinc-500",children:t.change_summary}),O&&!!R?.speech_retry_of&&(0,e.jsx)("p",{className:"mt-1 text-[11px] text-zinc-500",children:"Made again: the line was not said as written"}),Js&&(0,e.jsxs)("p",{className:"mt-1 line-clamp-2 text-[11px] text-zinc-400",children:[(0,e.jsxs)("span",{className:"font-medium text-zinc-300",children:[Js.speaker,":"]})," ",Js.text,(R?.transcript_lines?.length??0)>1&&` +${(R?.transcript_lines?.length??1)-1} more`]}),Mn&&(0,e.jsxs)("p",{className:"mt-1 line-clamp-2 whitespace-pre-line text-[11px] text-zinc-400",children:[(0,e.jsx)("span",{className:"font-medium text-zinc-300",children:"Spoken:"})," ",Mn]}),w&&ye!==null&&(0,e.jsxs)("details",{className:"mt-1.5",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-[10px] text-zinc-400 hover:text-zinc-200",children:R?.structured_prompt?"Your video prompt":"Sent to the model"}),(0,e.jsx)("p",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] text-zinc-300",children:ye})]}),w&&R?.structured_prompt&&(0,e.jsxs)("details",{className:"mt-1",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-[10px] text-zinc-400 hover:text-zinc-200",children:"What MiniMax H3 read"}),(0,e.jsx)("p",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] text-zinc-300",children:R.structured_prompt})]}),Qs!==void 0&&(0,e.jsxs)("details",{className:"mt-1",children:[(0,e.jsx)("summary",{className:"cursor-pointer text-[10px] text-zinc-400 hover:text-zinc-200",children:"Changed from the clip before"}),Qs?(0,e.jsx)("p",{className:"mt-1 whitespace-pre-wrap break-words text-[11px] text-zinc-300",children:Qs.map((vt,Zs)=>vt.kind==="same"?(0,e.jsx)("span",{children:vt.text},Zs):vt.kind==="added"?(0,e.jsx)("ins",{className:"bg-emerald-500/15 text-emerald-300 no-underline",children:vt.text},Zs):(0,e.jsx)("del",{className:"bg-red-500/10 text-red-300/80",children:vt.text},Zs))}):(0,e.jsx)("p",{className:"mt-1 text-[11px] text-zinc-500",children:"Written again from the start."})]}),w&&ye===null&&(0,e.jsx)("p",{className:"mt-1 text-[10px] italic text-zinc-600",children:"Exact request was not recorded."}),!t.is_active&&(0,e.jsxs)(m,{variant:"outline",size:"xs",className:"mt-2 w-full",onClick:()=>ra(t.id),disabled:Fi,children:[(0,e.jsx)(ii,{className:"h-3 w-3"}),"Use version"]})]},t.id)})}),At.length>0&&(0,e.jsxs)("div",{className:"mt-4 border-t border-zinc-800 pt-3",children:[(0,e.jsx)("h4",{className:"mb-2 text-xs font-medium text-zinc-300",children:"Generation history"}),(0,e.jsx)("div",{className:"space-y-2",children:At.map(t=>(0,e.jsxs)("div",{className:"rounded border border-zinc-800 p-2",children:[(0,e.jsxs)("p",{className:"text-[10px] text-zinc-400",children:[Gn(ci(t.provider))," ","• ",t.duration,"s"]}),(0,e.jsx)("p",{className:"mt-0.5 truncate text-[10px] text-zinc-500",children:t.prompt.substring(0,50)}),(0,e.jsxs)("div",{className:"mt-1 flex gap-1",children:[(0,e.jsx)("button",{type:"button",onClick:()=>{bs(t.videoUrl),Oi(0)},className:"rounded-md text-[10px] text-zinc-400 outline-none hover:text-zinc-200 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"Preview"}),(0,e.jsx)("span",{className:"text-[10px] text-zinc-700",children:"|"}),(0,e.jsx)("button",{type:"button",onClick:()=>{ue(t.videoUrl),f(t.videoUrl)},className:"rounded-md text-[10px] text-primary outline-none hover:underline focus-visible:ring-[3px] focus-visible:ring-ring/50",children:"Use this"})]})]},t.id))})]})]})]})]}),$i&&P&&(0,e.jsx)(hi,{videoUrl:P,onClose:()=>ys(!1)}),js&&(0,e.jsx)(hi,{imageUrl:js,onClose:()=>ws(null)}
2),vs&&(0,e.jsx)(sr,{videoUrl:vs,versionNumber:wr,detail:yr,onClose:()=>bs(null)}),As.dialogs,Ze&&(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(So,{open:!!Ze,onOpenChange:t=>{t||_t(null)},projectUuid:o,character:Ze==="new"?null:Ze})}),Gs&&(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(Re,{projectUuid:o,isOpen:Gs,onClose:()=>xt(!1),multiSelect:!0,onAssetsSelect:$r,categoryFilter:"video",maxSelection:1})}),Us&&(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(Re,{projectUuid:o,isOpen:Us,onClose:()=>Bs(!1),multiSelect:!0,onAssetsSelect:Or,categoryFilter:"image"})}),Ss&&(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(Re,{projectUuid:o,isOpen:Ss,onClose:()=>fe(!1),onAssetSelect:Wr,categoryFilter:"image",multiSelect:!1,maxSelection:1})}),zs&&(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(Re,{projectUuid:o,isOpen:zs,onClose:()=>Vt(!1),onAssetSelect:Kr,categoryFilter:"audio",multiSelect:!1,maxSelection:1})}),Cs&&(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(Re,{projectUuid:o,isOpen:Cs,onClose:()=>Lt(!1),onAssetSelect:Hr,categoryFilter:"video",multiSelect:!1,maxSelection:1})}),xs&&(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(Re,{projectUuid:o,isOpen:xs,onClose:()=>he(!1),onAssetSelect:t=>xn([t]),onAssetsSelect:xn,categoryFilter:"image",multiSelect:!1,maxSelection:1})}),Xs&&(0,e.jsx)(i.Suspense,{fallback:null,children:(0,e.jsx)(Re,{projectUuid:o,isOpen:Xs,onClose:()=>ft(!1),onAssetSelect:Br,categoryFilter:"video",multiSelect:!1,maxSelection:1})}),(0,e.jsx)(jo,{isOpen:yi,onClose:()=>ji(!1),videoKey:"part-5"}),(0,e.jsx)(ho,{open:Ei,onOpenChange:Ai,children:(0,e.jsxs)(po,{side:"right",className:"z-[75] flex h-full w-full flex-col border-l border-zinc-800 bg-zinc-950 p-0 text-zinc-100 shadow-2xl sm:max-w-md",children:[(0,e.jsxs)(mo,{className:"border-b border-zinc-900 bg-zinc-900/40 px-5 py-4",children:[(0,e.jsxs)(uo,{className:"flex items-center gap-2 text-sm font-semibold text-zinc-100",children:[(0,e.jsx)(qe,{className:"h-4 w-4 text-amber-400"}),r==="omni-edit"?"VFX presets":"Motion templates"]}),(0,e.jsx)(xo,{className:"mt-1 text-xs leading-normal text-zinc-400",children:r==="omni-edit"?"Select preset visual effects and style transformations to apply to your clip.":"Browse and select camera movements, action presets, and motion styles."})]}),(0,e.jsxs)("div",{className:"flex-1 space-y-4 overflow-y-auto p-5",children:[r!=="omni-edit"&&(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,e.jsx)(m,{type:"button",variant:"outline",size:"xs","aria-pressed":Te==="all",onClick:()=>fs("all"),className:F(Te==="all"?Qn:"text-muted-foreground hover:text-foreground"),children:"All"}),Object.entries(so).map(([t,s])=>(0,e.jsx)(m,{type:"button",variant:"outline",size:"xs","aria-pressed":Te===t,onClick:()=>fs(t),className:F(Te===t?Qn:"text-muted-foreground hover:text-foreground"),children:s.title},t))]}),(0,e.jsxs)("div",{className:"relative w-full",children:[(0,e.jsx)(ha,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-zinc-500","aria-hidden":"true"}),(0,e.jsx)("input",{type:"text",value:Ie,onChange:t=>gs(t.target.value),placeholder:`Search ${Wn.length} templates…`,"aria-label":"Search motion templates",className:F(Ta,"h-9 pl-8 pr-8 text-xs")}),Ie&&(0,e.jsx)("button",{type:"button",onClick:()=>gs(""),"aria-label":"Clear search",title:"Clear search",className:"absolute right-2 top-1/2 -translate-y-1/2 rounded-md p-0.5 text-zinc-500 outline-none transition-colors hover:text-zinc-200 focus-visible:ring-[3px] focus-visible:ring-ring/50",children:(0,e.jsx)(wt,{className:"h-3.5 w-3.5"})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-[11px] font-medium text-zinc-500",children:"Intensity:"}),(0,e.jsx)("div",{className:Je("h-8"),children:["all","subtle","moderate","dramatic"].map(t=>(0,e.jsx)("button",{type:"button","aria-pressed":ct===t,onClick:()=>Ri(t),className:Ae(ct===t,"flex-none capitalize"),children:t},t))})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-1.5 pt-1",children:[un.map(t=>(0,e.jsx)("button",{type:"button",onClick:()=>{kn(t.prompt),d.success(`Applied template: "${t.label}"`)},title:t.prompt,className:F("h-7 rounded-lg border px-2.5 text-xs outline-none transition-colors focus-visible:ring-[3px] focus-visible:ring-ring/50",t.intensity==="dramatic"?"border-red-500/20 bg-red-950/20 text-zinc-300 hover:border-red-500/40 hover:bg-red-950/40 hover:text-red-200":t.intensity==="subtle"?"border-blue-500/20 bg-blue-950/20 text-zinc-300 hover:border-blue-500/40 hover:bg-blue-950/40 hover:text-blue-200":"border-zinc-800 bg-zinc-900/60 text-zinc-300 hover:border-zinc-700 hover:bg-zinc-800 hover:text-zinc-100"),children:t.label},`${t.category}-${t.label}`)),un.length===0&&(0,e.jsxs)("div",{className:"flex w-full flex-col items-center justify-center py-8 text-center",children:[(0,e.jsxs)("p",{className:"text-xs text-zinc-400",children:["No templates match",Ie&&(0,e.jsxs)("span",{className:"text-zinc-200",children:[" ","“",Ie,"”"]})]}),(0,e.jsx)(m,{type:"button",variant:"outline",size:"xs",onClick:()=>{gs(""),fs("all"),Ri("all")},className:"mt-3",children:"Clear filters"})]})]})]}),r==="omni-edit"&&(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[cn&&(0,e.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-300",children:[(0,e.jsx)(ri,{className:"h-4 w-4 shrink-0"}),(0,e.jsxs)("span",{children:["AI VFX edits clips up to ",15,"s. Trim this clip to ",15,"s or shorter first, then edit."]})]}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:Ja.map(t=>(0,e.jsx)(m,{type:"button",variant:"outline",size:"xs",onClick:()=>{kn(t.prompt),d.success(`Applied preset: "${t.label}"`)},children:t.label},t.label))}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("label",{htmlFor:"vfx-dub-language",className:"text-xs text-muted-foreground",children:"Change language"}),(0,e.jsxs)(Dn,{value:"",onValueChange:t=>{const s=Xn.find(a=>a.value===t);
2s&&(te(Qa(s.label)),d.success(`Dub into ${s.label} is ready`))},children:[(0,e.jsx)(Rn,{id:"vfx-dub-language",className:"h-8 w-auto min-w-[140px] text-xs",children:(0,e.jsx)(An,{placeholder:"Pick a language"})}),(0,e.jsx)(Vn,{children:Xn.map(t=>(0,e.jsx)(Ln,{value:t.value,children:t.native===t.label?t.label:`${t.native} · ${t.label}`},t.value))})]})]}),(0,e.jsxs)("div",{className:"mt-2 flex items-center gap-2 rounded-md border border-zinc-800 bg-zinc-900/60 px-3 py-2.5 text-xs text-zinc-400",children:[(0,e.jsx)(qe,{className:"h-4 w-4 shrink-0 text-amber-400"}),(0,e.jsx)("span",{children:"Describe the change — an outfit, the weather, lighting, remove an object — or dub the clip into another language. Everything else is preserved."})]})]})]})]})})]})});Fo.displayName="MotionEditor";export{Fo as MotionEditor};

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.