1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,709010,e=>{"use strict";var t=e.i(658457),s=e.i(221147),r=e.i(920932),a=e.i(519455),i=e.i(515288),o=e.i(110204),l=e.i(907246),d=e.i(624687),n=e.i(880749),c=e.i(846216),m=e.i(133713),u=e.i(229748),x=e.i(306097),p=e.i(975157),h=e.i(237525),f=e.i(89696),v=e.i(797659),g=e.i(861475),j=e.i(370874),b=e.i(452661),b=b,N=e.i(822600),w=e.i(247594),y=e.i(230245),C=e.i(315036),S=e.i(638179),D=e.i(898760),k=e.i(46957),L=e.i(714360),I=e.i(481554),R=e.i(120131),U=e.i(637667),M=e.i(755453),F=e.i(296410),O=e.i(967489),E=e.i(823121),E=E,V=e.i(671299),T=e.i(752847),T=T,B=e.i(866195),B=B;let _={"16:9":(0,t.jsx)(E.default,{className:"h-4 w-4"}),"9:16":(0,t.jsx)(V.Smartphone,{className:"h-4 w-4"}),"1:1":(0,t.jsx)(T.default,{className:"h-4 w-4"}),"4:3":(0,t.jsx)(B.default,{className:"h-4 w-4"}),"3:4":(0,t.jsx)(V.Smartphone,{className:"h-4 w-4"}),"21:9":(0,t.jsx)(E.default,{className:"h-4 w-4"})};function P({model:e,selectedRatio:s,onRatioChange:r}){let a=n.VIDEO_MODELS[e].supportedAspectRatios||["16:9"];return(0,t.jsxs)(O.Select,{value:s,onValueChange:r,children:[(0,t.jsx)(O.SelectTrigger,{className:"w-full",children:(0,t.jsx)(O.SelectValue,{placeholder:"Select Aspect Ratio"})}),(0,t.jsx)(O.SelectContent,{children:a.map(e=>(0,t.jsx)(O.SelectItem,{value:e,children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[_[e],(0,t.jsx)("span",{children:e})]})},e))})]})}function A({model:e,selectedDuration:s,onDurationChange:r}){let i=n.VIDEO_MODELS[e].supportedDurations;return e.includes("veo3")?(0,t.jsxs)("div",{className:"text-sm text-muted-foreground p-4 bg-muted/50 rounded-md",children:["Veo 3 models have a fixed duration of"," ",(0,t.jsx)("span",{className:"font-semibold",children:"8 seconds"})]}):e.includes("MiniMax")?(0,t.jsx)("div",{className:"flex gap-2",children:i.map(e=>(0,t.jsxs)(a.Button,{type:"button",variant:s===e?"default":"outline",onClick:()=>r(e),className:"flex-1",children:[e," seconds"]},e))}):(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(e=>(0,t.jsxs)(a.Button,{type:"button",variant:s===e?"default":"outline",onClick:()=>r(e),children:[e," seconds"]},e))})}var $=e.i(899454),H=e.i(585796),z=e.i(174673);let W=({uploadedImages:e,onRemoveImage:s,currentUser:i,mounted:o,isDragOver:l,isUploading:d,fileInputRef:n,onDragOver:c,onDragLeave:m,onDrop:u,onFileSelect:x,onUploadAreaClick:h,maxImages:f,uploadHint:v})=>(0,t.jsxs)("div",{className:"space-y-3",children:[e.length>0&&(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsx)("div",{className:"grid grid-cols-4 gap-2",children:e.map((e,r)=>(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)($.ClickableImage,{src:e.preview,alt:`Uploaded image ${r+1}`,width:200,height:200,fitMode:"contain",className:"w-full h-16 rounded border",expandHint:"Click to expand",showExpandHint:!0,unoptimized:!0}),(0,t.jsx)(a.Button,{type:"button",variant:"destructive",size:"icon",className:"absolute -top-1 -right-1 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>s(r),disabled:d,children:(0,t.jsx)(z.X,{className:"h-3 w-3"})})]},r))})}),o?i?(0,t.jsxs)("div",{className:(0,p.cn)("border-2 border-dashed rounded-lg p-4 transition-colors cursor-pointer",l?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50",d&&"cursor-not-allowed opacity-70"),onDragOver:d?void 0:c,onDragLeave:d?void 0:m,onDrop:d?void 0:u,onClick:d?void 0:h,children:[(0,t.jsxs)("div",{className:"text-center space-y-2",children:[d?(0,t.jsx)(y.Loader2,{className:"h-6 w-6 text-muted-foreground mx-auto animate-spin"}):(0,t.jsx)(H.Upload,{className:"h-6 w-6 text-muted-foreground mx-auto"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:d?"Uploading...":l?"Drop to upload":`Upload Image (${e.length}/${f})`}),!l&&!d&&v&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:v}),!l&&!d&&!v&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Click or drag image here to upload"})]})]}),(0,t.jsx)("input",{ref:n,type:"file",multiple:f>1,accept:"image/*",onChange:x,className:"hidden",disabled:d})]}):(0,t.jsx)(r.LoginWrapper,{mode:"modal",asChild:!0,children:(0,t.jsx)("div",{className:(0,p.cn)("border-2 border-dashed rounded-lg p-4 transition-colors cursor-pointer","border-muted-foreground
1/25 hover:border-primary/50"),children:(0,t.jsxs)("div",{className:"text-center space-y-2",children:[(0,t.jsx)(H.Upload,{className:"h-6 w-6 text-muted-foreground mx-auto"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:`Upload Image (${e.length}/${f})`}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:v||"Click or drag image here to upload"})]})]})})}):(0,t.jsx)("div",{className:"border-2 border-dashed rounded-lg p-4 transition-colors",children:(0,t.jsxs)("div",{className:"text-center space-y-2",children:[(0,t.jsx)(H.Upload,{className:"h-6 w-6 text-muted-foreground mx-auto"}),(0,t.jsx)("div",{children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading..."})})]})})]});var q=e.i(502509);function K({selectedModel:e,onModelChange:s,allowedModels:r,disabled:a=!1,estimatedCredits:i=0}){let o=(0,I.useMemo)(()=>{let e=Object.values(n.VIDEO_MODELS).map(e=>({id:e.id,name:e.name,description:e.description,provider:(0,n.getProviderName)(e.provider),speedLabel:(0,n.getModelSpeedLabel)(e.id),logo:e.logo,creditsCost:e.creditsCost,features:e.features||[]}));return r&&r.length>0?e.filter(e=>r.includes(e.id)):e},[r]),l=(0,I.useMemo)(()=>o.find(t=>t.id===e)||o[0],[o,e]),d=(0,I.useMemo)(()=>e&&e in n.VIDEO_MODELS?e:o[0]?.id||"google-veo3.1",[e,o]);return(0,t.jsxs)(O.Select,{value:d,onValueChange:s,disabled:a,children:[(0,t.jsx)(O.SelectTrigger,{className:"w-full",children:(0,t.jsx)(O.SelectValue,{children:l?.logo?(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 w-full",children:[(0,t.jsx)(q.default,{src:l.logo,alt:l.name,width:20,height:20,className:"flex-shrink-0"}),(0,t.jsx)("span",{className:"truncate flex-1 min-w-0",children:l.name}),l.speedLabel&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:l.speedLabel})]}):l?.name??"Select Model"})}),(0,t.jsx)(O.SelectContent,{children:o.map(e=>(0,t.jsx)(O.SelectItem,{value:e.id,children:(0,t.jsxs)("div",{className:"flex items-start gap-3 py-0.5 w-full",children:[e.logo&&(0,t.jsx)(q.default,{src:e.logo,alt:e.name,width:24,height:24,className:"flex-shrink-0 mt-0.5"}),(0,t.jsxs)("div",{className:"flex flex-col items-start gap-0.5 flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 w-full",children:[(0,t.jsx)("span",{className:"font-medium leading-tight",children:e.name}),e.speedLabel&&(0,t.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex-shrink-0",children:e.speedLabel})]}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground leading-tight",children:[e.provider," ⢠Base ",e.creditsCost.base," +"," ",e.creditsCost.perSecond," credits/sec"]})]})]})},e.id))})]})}var Q=e.i(929592),X=e.i(945981);function G({model:e,duration:s,selectedResolution:r,onResolutionChange:i}){let o=n.VIDEO_MODELS[e],l=(0,n.getSupportedResolutions)(e,s);if(!l||0===l.length)return null;let d=o.resolutionConstraints,c=e.includes("MiniMax")&&"1080p"===r&&5!==s;return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("div",{className:"md:hidden",children:(0,t.jsxs)(O.Select,{value:r,onValueChange:i,children:[(0,t.jsx)(O.SelectTrigger,{className:"w-full",children:(0,t.jsx)(O.SelectValue,{placeholder:"Select Resolution"})}),(0,t.jsx)(O.SelectContent,{children:l.map(e=>(0,t.jsx)(O.SelectItem,{value:e,children:e},e))})]})}),(0,t.jsx)("div",{className:"hidden md:grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-2",children:l.map(e=>{let s=r===e,o=!l.includes(e);return(0,t.jsx)(a.Button,{type:"button",variant:s?"default":"outline",onClick:()=>i(e),disabled:o,className:(0,p.cn)("flex flex-col items-center gap-1 h-auto py-3",s&&"ring-2 ring-primary ring-offset-2"),children:(0,t.jsx)("div",{className:"font-semibold",children:e})},e)})}),c&&(0,t.jsxs)(Q.Alert,{variant:"destructive",children:[(0,t.jsx)(X.AlertCircle,{className:"h-4 w-4"}),(0,t.jsx)(Q.AlertDescription,{children:"MiniMax Hailuo 1080p resolution only supports 5s duration. Please adjust duration or choose another resolution."})]}),d&&"1080p"===r&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Note: 1080p resolution of some models may have duration limits"})]})}var J=e.i(130867);let Y=({pendingVideo:e,onClearVideo:s,currentUser:i,mounted:o,isDragOver:l,isUploading:d,uploadProgress:n,fileInputRef:c,onDragOver:m,onDragLeave:u,onDrop:x,onFileSelect:h,onUploadAreaClick:f,uploadHint:v})=>(0,t.jsxs)("div",{className:"space-y-3",children:[e&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"relative group rounded-lg overflow-hidden border bg-black/5",children:[(0,t.jsx)("video",{src:e.preview,className:"w-full aspect-video object-contain bg-black",controls:!0,preload:"metadata"}),(0,t.jsx)(a.Button,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-8 w-8 op
1acity-0 group-hover:opacity-100 transition-opacity",onClick:s,disabled:d,children:(0,t.jsx)(z.X,{className:"h-4 w-4"})}),(0,t.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-3",children:(0,t.jsxs)("div",{className:"flex items-center justify-between text-white text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(J.Play,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"truncate max-w-[200px]",children:e.name})]}),void 0!==e.duration&&(0,t.jsxs)("span",{children:[e.duration.toFixed(1),"s"]})]})})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground text-center",children:"Video will be uploaded upon submission"})]}),!e&&(0,t.jsx)(t.Fragment,{children:o?i?(0,t.jsxs)("div",{className:(0,p.cn)("border-2 border-dashed rounded-lg p-6 transition-colors cursor-pointer",l?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50"),onDragOver:m,onDragLeave:u,onDrop:x,onClick:f,children:[(0,t.jsxs)("div",{className:"text-center space-y-3",children:[(0,t.jsx)(S.Video,{className:"h-8 w-8 text-muted-foreground mx-auto"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:l?"Drop to select":"Select Reference Video"}),!l&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:v||"Click or drag video here (MP4, WebM, max 50MB, max 30s)"})]})]}),(0,t.jsx)("input",{ref:c,type:"file",accept:"video/mp4,video/webm,video/quicktime",onChange:h,className:"hidden"})]}):(0,t.jsx)(r.LoginWrapper,{mode:"modal",asChild:!0,children:(0,t.jsx)("div",{className:(0,p.cn)("border-2 border-dashed rounded-lg p-6 transition-colors cursor-pointer","border-muted-foreground/25 hover:border-primary/50"),children:(0,t.jsxs)("div",{className:"text-center space-y-3",children:[(0,t.jsx)(S.Video,{className:"h-8 w-8 text-muted-foreground mx-auto"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Select Reference Video"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:v||"Click or drag video here (MP4, WebM, max 50MB, max 30s)"})]})]})})}):(0,t.jsx)("div",{className:"border-2 border-dashed rounded-lg p-6 transition-colors",children:(0,t.jsxs)("div",{className:"text-center space-y-2",children:[(0,t.jsx)(S.Video,{className:"h-8 w-8 text-muted-foreground mx-auto"}),(0,t.jsx)("div",{children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading..."})})]})})})]});var Z=e.i(981084),ee=e.i(243658);let et=["video/mp4","video/webm","video/quicktime"];async function es(e){return new Promise(t=>{let s=document.createElement("video");s.preload="metadata",s.onloadedmetadata=()=>{URL.revokeObjectURL(s.src),t(s.duration)},s.onerror=()=>{URL.revokeObjectURL(s.src),t(0)},s.src=URL.createObjectURL(e)})}function er({className:O,presetModel:E,allowedModels:V,presetImageVideoMode:T}){let B=(0,k.useTranslations)("VideoSubmission"),_=(0,L.useRouter)(),$=(0,m.useCurrentUser)(),H=(0,h.useMemberPackageModalStore)(e=>e.open),z=(0,v.useQueryClient)(),{data:q}=(0,c.useCreditBalance)({enabled:!!$}),[Q,X]=(0,I.useState)(!1),[J,er]=(0,I.useState)(0),[ea,ei]=(0,I.useState)(!1),[eo,el]=(0,I.useState)([]),[ed,en]=(0,I.useState)(),[ec,em]=(0,I.useState)(T||"text-to-video.md"),[eu,ex]=(0,I.useState)({state:"idle"}),[ep,eh]=(0,I.useState)(0);(0,I.useEffect)(()=>{if("loading"!==eu.state)return void eh(0);let e=n.VIDEO_MODELS[eu.model],t=95/(1e3*Math.max(2*(e?.estimatedProcessingTime||180),150))*100,s=setInterval(()=>{eh(e=>e>=95?95:Math.min(e+t,95))},100);return()=>clearInterval(s)},[eu.state,eu.model]);let ef=(0,I.useMemo)(()=>"text-to-video.md"===ec?0:"first-last-frame"===ec?2:"reference"===ec?3:1,[ec]),{uploadedImages:ev,isDragOver:eg,isUploading:ej,fileInputRef:eb,handleRemoveImage:eN,handleDragOver:ew,handleDragLeave:ey,handleDrop:eC,handleFileSelect:eS,handleUploadAreaClick:eD}=function({maxImages:e,initialImageUrls:t}){let[s,r]=(0,I.useState)([]),[a,i]=(0,I.useState)(!1),[o,l]=(0,I.useState)(!1),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{t&&t.length>0&&0===s.length&&(async()=>
1{l(!0);try{let e=[];for(let s of t)try{let t=await fetch(s),r=await t.blob(),a=new File([r],"reference-image.webp",{type:r.type});URL.createObjectURL(a);let i=new FileReader,o=await new Promise(e=>{i.onload=()=>e(i.result),i.readAsDataURL(a)});e.push({file:a,preview:s,base64:o})}catch(e){console.error("Failed to load initial image:",s,e)}e.length>0&&r(e)}catch(e){console.error("Error loading initial images",e)}finally{l(!1)}})()},[t]);let n=(0,I.useCallback)(async t=>{if(o)return;let a=s.length;if(1===e&&a>0){if(0===t.length)return;let e=t.slice(0,1);l(!0);try{let t=[],a=!1;for(let s of e)try{let e=await (0,Z.prepareImageForUpload)(s,{maxWidth:1920,maxHeight:1080,quality:.7}),r=(0,Z.validateImageFile)(e);if(!r.valid){U.toast.error(r.error||"ä¸ä¼ 失败"),a=!0;continue}let i=(0,Z.createImagePreview)(e),o=await (0,Z.fileToBase64)(e);t.push({file:e,preview:i,base64:o})}catch(e){console.error("å¤çå¾ç失败:",e),U.toast.error("å¾çå¤ç失败"),a=!0}t.length>0?(s.forEach(e=>{(0,Z.revokeImagePreview)(e.preview)}),r(t),U.toast.success("å¾çä¸ä¼ æå")):a||U.toast.error("ä¸ä¼ 失败")}catch(e){console.error("ä¸ä¼ 失败:",e),U.toast.error("ä¸ä¼ 失败")}finally{l(!1)}return}let i=e-a;if(i<=0)return void U.toast.error(`æå¤åªè½ä¸ä¼ ${e} å¼ å¾ç`);let d=t.slice(0,i);l(!0);try{let e=[];for(let t of d)try{let s=await (0,Z.prepareImageForUpload)(t,{maxWidth:1920,maxHeight:1080,quality:.7}),r=(0,Z.validateImageFile)(s);if(!r.valid){U.toast.error(`${t.name}: ${r.error}`);continue}let a=(0,Z.createImagePreview)(s),i=await (0,Z.fileToBase64)(s);e.push({file:s,preview:a,base64:i})}catch(e){console.error("å¾çå¤çé误:",e),U.toast.error(`${t.name}: å¤ç失败`)}e.length>0&&(r(t=>[...t,...e]),U.toast.success("å¾çä¸ä¼ æå"))}catch(e){console.error("ä¸ä¼ é误:",e),U.toast.error("ä¸ä¼ 失败")}finally{l(!1)}},[s,e,o]),c=(0,I.useCallback)(e=>{r(t=>{let s=t[e];return s&&(0,Z.revokeImagePreview)(s.preview),t.filter((t,s)=>s!==e)})},[]),m=(0,I.useCallback)(e=>{e.preventDefault(),i(!0)},[]),u=(0,I.useCallback)(e=>{e.preventDefault(),i(!1)},[]),x=(0,I.useCallback)(e=>{e.preventDefault(),i(!1),n(Array.from(e.dataTransfer.files))},[n]),p=(0,I.useCallback)(e=>{n(Array.from(e.target.files||[])),d.current&&(d.current.value="")},[n]),h=(0,I.useCallback)(()=>{d.current?.click()},[]);return{uploadedImages:s,isDragOver:a,isUploading:o,fileInputRef:d,handleRemoveImage:c,handleDragOver:m,handleDragLeave:u,handleDrop:x,handleFileSelect:p,handleUploadAreaClick:h}}({maxImages:ef,initialImageUrls:eo}),{pendingVideo:ek,isDragOver:eL,isUploading:eI,uploadProgress:eR,fileInputRef:eU,clearVideo:eM,uploadVideo:eF,handleDragOver:eO,handleDragLeave:eE,handleDrop:eV,handleFileSelect:eT,handleUploadAreaClick:eB}=function(){let[e,t]=(0,I.useState)(null),[s,r]=(0,I.useState)(!1),[a,i]=(0,I.useState)(!1),[o,l]=(0,I.useState)(0),d=(0,I.useRef)(null),n=(0,I.useCallback)(async s=>{let r=function(e){if(!et.includes(e.type))return{valid:!1,error:`䏿¯æçè§é¢æ ¼å¼ï¼è¯·ä¸ä¼ MP4ãWebM æ MOV æ ¼å¼`};let t=e.size/1048576;return t>50?{valid:!1,error:`è§é¢æä»¶è¿å¤§ï¼${t.toFixed(1)}MBï¼ï¼æå¤§æ¯æ 50MB`}:{valid:!0}}(s);if(!r.valid)return void U.toast.error(r.error||"æä»¶æ ¡éªå¤±è´¥");try{let r=await es(s);if(r>30)return void U.toast.error(`è§é¢æ¶é¿è¿é¿ï¼${r.toFixed(1)}ç§ï¼ï¼æå¤§æ¯æ 30 ç§`);e?.preview&&URL.revokeObjectURL(e.preview);let a=URL.createObjectURL(s),i={file:s,preview:a,duration:r,name:s.name};t(i),U.toast.success("è§é¢å·²éæ©")}catch(e){console.error("è§é¢é¢è§å¤±è´¥:",e),U.toast.error("è§é¢é¢è§å¤±è´¥ï¼è¯·éè¯")}},[e]),c=(0,I.useCallback)(async()=>{if(!e||a)return null;i(!0),l(0);try{l(20);let t=await (0,ee.uploadFileFromBrowser)(e.file,"videos/uploads");return l(100),t.url}catch(e){return console.error("è§é¢ä¸ä¼ 失败:",e),U.toast.error("è§é¢ä¸ä¼ 失败ï¼è¯·éè¯"),null}finally{i(!1),l(0)}},[e,a]),m=(0,I.useCallback)(()=>{e?.preview&&URL.revokeObjectURL(e.preview),t(null)},[e]),u=(0,I.useCallback)(e=>{e.preventDefault(),r(!0)},[]),x=(0,I.useCallback)(e=>{e.preventDefault(),r(!1)},[]),p=(0,I.useCallback)(e=>{e.preventDefault(),r(!1);let t=Array.from(e.dataTransfer.files).find(e=>et.includes(e.type));t?n(t):U.toast.error("请ä¸ä¼ è§é¢æä»¶ï¼MP4ãWebM æ MOVï¼")},[n]),h=(0,I.useCallback)(e=>{let t=Array.from(e.target.files||[]);t.length>0&&n(t[0]),d.current&&(d.current.value="")},[n]),f=(0,I.useCallback)(()=>{d.current?.click()},[]);return{pendingVideo:e,isDragOver:s,isUploading:a,uploadProgress:o,fileInputRef:d,clearVideo:m,uploadVideo:c,handleDragOver:u,handleDragLeave:x,handleDrop:p,handleFileSelect:h,handleUploadAreaClick:f}}(),{status:e_,loading:eP,progress:eA,estimatedTimeLeft:e$,refresh:eH}
1=(0,x.useVideoStatus)("loading"===eu.state&&eu.videoId?eu.videoId:""),ez=(0,I.useMemo)(()=>{if(V)return V;let e=Object.values(n.VIDEO_MODELS);return"text-to-video.md"===ec?e.filter(e=>"kling-o1"!==e.id).map(e=>e.id):"first-frame"===ec?e.filter(e=>e.features?.includes("image_to_video")).map(e=>e.id):"reference"===ec?e.filter(e=>e.features?.includes("reference_image")).map(e=>e.id):"first-last-frame"===ec?e.filter(e=>e.features?.includes("first_last_frame")).map(e=>e.id):"video-to-video"===ec?e.filter(e=>e.features?.includes("video_to_video")).map(e=>e.id):void 0},[ec,V]),eW=E||"google-veo3.1",eq=n.VIDEO_MODELS[eW].supportedDurations[0],eK=(0,L.useSearchParams)().get("remix_id"),eQ=(0,I.useMemo)(()=>M.z.object({model:M.z.string(),prompt:M.z.string().min(1,B("validation.enterDescription")).max(2e4,B("validation.descriptionTooLong")),duration:M.z.number().int().positive(),aspectRatio:M.z.string(),resolution:M.z.string().optional()}),[B]),{register:eX,handleSubmit:eG,watch:eJ,setValue:eY,formState:{errors:eZ},reset:e0}=(0,R.useForm)({resolver:(0,f.zodResolver)(eQ),defaultValues:{model:eW,prompt:"",duration:eq,aspectRatio:"16:9",resolution:"720p"}});(0,I.useEffect)(()=>{eK&&(async()=>{try{let{getVideoById:t}=await e.A(555383),s=await t(eK);if(s.success&&s.video){let e=s.video;eY("model",e.model),eY("prompt",e.prompt),e.duration&&eY("duration",e.duration),e.aspectRatio&&eY("aspectRatio",e.aspectRatio),e.resolution&&eY("resolution",e.resolution);let t="text-to-video.md";e.firstFrameUrl&&e.lastFrameUrl?(t="first-last-frame",el([e.firstFrameUrl,e.lastFrameUrl])):e.firstFrameUrl?(t="first-frame",el([e.firstFrameUrl])):e.referenceImageUrl&&(t="reference",el(e.referenceImageUrl.split(","))),em(t),U.toast.success(B("toast.loadedRemix"))}}catch(e){console.error("Failed to load remix data:",e),U.toast.error(B("toast.loadRemixFailed"))}})()},[eK,eY]);let e1=eJ("model"),e2=eJ("duration"),e4=eJ("prompt");(0,I.useEffect)(()=>{ei(!0)},[]),(0,I.useEffect)(()=>{if(e1&&e2){let e=n.VIDEO_MODELS[e1];if(e?.supportedDurations.includes(e2))try{let e=(0,n.calculateVideoCredits)(e1,e2);er(e)}catch(e){console.error("Failed to calculate credits:",e),er(0)}}},[e1,e2]),(0,I.useEffect)(()=>{if(e1){let e=n.VIDEO_MODELS[e1],t=eJ("duration");e.supportedDurations.includes(t)||eY("duration",e.supportedDurations[0]);let s=eJ("aspectRatio");e.supportedAspectRatios&&!e.supportedAspectRatios.includes(s)&&eY("aspectRatio",e.
1supportedAspectRatios[0]||"16:9")}},[e1]),(0,I.useEffect)(()=>{ez&&ez.length>0&&!ez.includes(e1)&&eY("model",ez[0])},[ez]),(0,I.useEffect)(()=>{"loading"!==eu.state||(!e_?.id||e_.id===eu.videoId)&&(e_?.status==="completed"&&e_.videoUrl?(ex({state:"results",videoId:e_.id,videoUrl:e_.videoUrl,thumbnailUrl:e_.thumbnailUrl||void 0,model:eu.model,duration:eu.duration}),U.toast.success(B("toast.generatedSuccess"))):e_?.status==="failed"?(ex({state:"error",videoId:e_.id,error:{message:e_.errorMessage||B("toast.generationFailed"),suggestion:B("preview.checkParameters")}}),U.toast.error(B("toast.generationFailed"))):eP&&ex(e=>({...e,progress:eA,estimatedTimeLeft:e$||void 0})))},[e_,eP,eA,e$,eu.state,eu.model,eu.duration]);let e5=async e=>{if(!$)return void U.toast.error(B("validation.loginRequired"));if("number"==typeof q&&q<J){H(),U.toast.info(B("validation.insufficientCredits"));return}if("video-to-video"===ec){if(!ek)return void U.toast.error(B("validation.selectReferenceVideo"))}else if("text-to-video.md"!==ec&&0===ev.length)return void U.toast.error(B("validation.uploadImages"));if(ec&&"text-to-video.md"!==ec&&"video-to-video"!==ec){if("first-frame"===ec&&1!==ev.length)return void U.toast.error(B("validation.firstFrameRequiresOne"));if("first-last-frame"===ec&&2!==ev.length)return void U.toast.error(B("validation.firstLastFrameRequiresTwo"));if("reference"===ec&&(ev.length<1||ev.length>3))return void U.toast.error(B("validation.referenceRequiresOneToThree"))}X(!0);try{let t;if("video-to-video"===ec&&ek){U.toast.info(B("toast.uploadingVideo"));let e=await eF();if(!e)return void X(!1);t=e,U.toast.success(B("toast.videoUploaded"))}let r=await (0,s.submitVideo)({model:e.model,prompt:e.prompt,duration:e.duration,aspectRatio:e.aspectRatio,resolution:e.resolution,imageVideoMode:"text-to-video.md"===ec?void 0:ec,uploadedImages:"video-to-video"!==ec&&"text-to-video.md"!==ec?ev.map(e=>({base64:e.base64})):void 0,videoUrl:t});r.success&&r.videoId?(U.toast.success(B("toast.generationStarted")),z.invalidateQueries({queryKey:u.historyVideosKeys.all}),ex({state:"loading",videoId:r.videoId,model:e.model,duration:e.duration,progress:0,videoUrl:void 0,thumbnailUrl:void 0,error:void 0})):(ex({state:"error",error:{message:r.error||B("toast.submitFailed"),code:r.errorCode,suggestion:"INSUFFICIENT_CREDITS"===r.errorCode?B("validation.insufficientCredits"):B("toast.tryAgainLater")}}),U.toast.error(r.error||B("toast.submitFailed")),"INSUFFICIENT_CREDITS"===r.errorCode&&(H(),U.toast.info(B("validation.insufficientCredits"))))}catch(e){console.error("Submit error:",e),U.toast.error(B("toast.submitFailed"))}finally{X(!1)}};return(0,t.jsxs)("div",{className:(0,p.cn)("space-y-6",O),children:[(0,t.jsx)("div",{className:"flex justify-center w-full",children:(0,t.jsx)("div",{className:"flex w-full overflow-x-auto md:grid md:grid-cols-5 gap-2 p-1 bg-muted/50 rounded-lg no-scrollbar",children:[{id:"text-to-video.md",label:B("modes.textToVideo"),icon:(0,t.jsx)(C.Type,{className:"w-3 h-3 sm:w-4 sm:h-4 mr-1 sm:mr-2 hidden xs:block"})},{id:"first-frame",label:B("modes.imageToVideo"),icon:(0,t.jsx)(N.Image,{className:"w-3 h-3 sm:w-4 sm:h-4 mr-1 sm:mr-2 hidden xs:block"})},{id:"reference",label:B("modes.referenceImage"),icon:(0,t.jsx)(w.Layers,{className:"w-3 h-3 sm:w-4 sm:h-4 mr-1 sm:mr-2 hidden xs:block"})},{id:"first-last-frame",label:B("modes.firstLastFrame"),icon:(0,t.jsx)(b.default,{className:"w-3 h-3 sm:w-4 sm:h-4 mr-1 sm:mr-2 hidden xs:block"})},{id:"video-to-video",label:B("modes.videoToVideo"),icon:(0,t.jsx)(S.Video,{className:"w-3 h-3 sm:w-4 sm:h-4 mr-1 sm:mr-2 hidden xs:block"})}].map(e=>{let s=ec===e.id;return(0,t.jsxs)("button",{type:"button",onClick:()=>em(e.id),className:(0,p.cn)("flex items-center justify-center flex-1 min-w-[max-content] md:min-w-0 px-3 py-2 text-[10px] sm:text-sm font-medium rounded-md transition-all duration-200",s?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/50 hover:text-foreground"),children:[e.icon,(0,t.jsx)("span",{className:"whitespace-nowrap",children:e.label})]},e.id)})})}),(0,t.jsxs)("div",{className:(0,p.cn)("grid gap-6","lg:grid-cols-2 lg:gap-8","grid-cols-1"),children:[(0,t.jsx)("div",{className:"lg:col-span-1 order-1",children:(0,t.jsx)(i.Card,{className:"h-full border shadow-sm pt-0",children:(0,t.jsx)(i.CardContent,{className:"pt-6",children:(0,t.jsxs)("form",{onSubmit:eG(e5),className:"space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o.Label,{htmlFor:"prompt",children:B("form.descriptionLabel")}),(0,t.jsx)(d.Textarea,{id:"prompt",placeholder:B("form.descriptionPlaceholder"),rows:4,...eX("prompt"),className:(0,p.cn)(eZ.prompt&&"border-red-500","max-h-[150px] overflow-y-auto")}),eZ.prompt&&(0,t.jsx)("p",{className:"text-sm text-red-500",children:eZ.prompt.message}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:B("form.descriptionHint")})]}
1),"text-to-video.md"!==ec&&"video-to-video"!==ec&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)(o.Label,{children:["first-frame"===ec&&B("form.uploadFirstFrame"),"reference"===ec&&B("form.uploadReferenceImages"),"first-last-frame"===ec&&B("form.uploadFirstLastFrames")]}),(0,t.jsx)(W,{uploadedImages:ev,onRemoveImage:eN,currentUser:$,mounted:ea,isDragOver:eg,isUploading:ej,fileInputRef:eb,onDragOver:ew,onDragLeave:ey,onDrop:eC,onFileSelect:eS,onUploadAreaClick:eD,maxImages:ef,uploadHint:"first-frame"===ec?B("form.uploadHintFirstFrame"):"reference"===ec?B("form.uploadHintReference"):B("form.uploadHintFirstLast")})]}),"video-to-video"===ec&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o.Label,{children:B("form.uploadReferenceVideo")}),(0,t.jsx)(Y,{pendingVideo:ek,onClearVideo:eM,currentUser:$,mounted:ea,isDragOver:eL,isUploading:eI,uploadProgress:eR,fileInputRef:eU,onDragOver:eO,onDragLeave:eE,onDrop:eV,onFileSelect:eT,onUploadAreaClick:eB,uploadHint:B("form.uploadHintVideo")})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o.Label,{children:B("form.videoModel")}),(0,t.jsx)(K,{selectedModel:e1,onModelChange:e=>eY("model",e),allowedModels:ez,disabled:!1,estimatedCredits:J})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o.Label,{children:B("form.duration")}),(0,t.jsx)(A,{model:e1,selectedDuration:e2,onDurationChange:e=>eY("duration",e)})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o.Label,{children:B("form.aspectRatio")}),(0,t.jsx)(P,{model:e1,selectedRatio:eJ("aspectRatio"),onRatioChange:e=>eY("aspectRatio",e)})]}),n.VIDEO_MODELS[e1]?.supportedResolutions&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(o.Label,{children:B("form.resolution")}),(0,t.jsx)(G,{model:e1,duration:e2,selectedResolution:eJ("resolution")||"720p",onResolutionChange:e=>eY("resolution",e)})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[ea?$?(0,t.jsx)(a.Button,{type:"submit",className:"w-full h-12",disabled:Q||!e4.trim(),children:Q?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(y.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),B("form.generating")]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(D.Wand2,{className:"mr-2 h-4 w-4"}),B("form.generateButton")]})}):(0,t.jsx)(r.LoginWrapper,{mode:"modal",asChild:!0,children:(0,t.jsxs)(a.Button,{type:"button",className:"w-full h-12",children:[(0,t.jsx)(D.Wand2,{className:"mr-2 h-4 w-4"}),B("form.generateButton")]})}):(0,t.jsxs)(a.Button,{type:"button",className:"w-full h-12",disabled:!0,children:[(0,t.jsx)(y.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),B("form.loading")]}),(0,t.jsx)("div",{className:"text-center",children:ea?$?(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[B("form.estimatedCost")," ",(0,t.jsx)("span",{className:"font-semibold",children:J})," ",B("form.credits")]}):(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:B("validation.loginRequired")}):(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:B("form.loading")})})]})]})})})}),(0,t.jsx)("div",{className:"lg:col-span-1 order-2",children:(0,t.jsx)(i.Card,{className:"h-full border shadow-sm",children:(0,t.jsxs)(i.CardContent,{className:"p-6 h-full flex items-center justify-center min-h-[400px]",children:["idle"===eu.state&&(0,t.jsxs)("div",{className:"text-center space-y-4",children:[(0,t.jsx)("div",{className:"text-6xl",children:"ð¬"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:B("preview.title")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:Q?B("preview.submitting"):B("preview.idleHint")})]}),e1&&(0,t.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,t.jsxs)("p",{children:["Model:"," ",n.VIDEO_MODELS[e1]?.name||e1]}),(0,t.jsxs)("p",{children:["Duration: ",e2,"s"]}),(0,t.jsxs)("p",{children:["Estimated Credits: ",J]})]})]}),"loading"===eu.state&&(0,t.jsxs)("div",{className:"w-full flex flex-col items-center justify-center gap-6 p-8",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"h-24 w-24 animate-spin rounded-full border-4 border-primary/20 border-t-primary"}),(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center text-4xl",children:"ð¬"})]}),(0,t.jsxs)("div",{className:"w-full space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2 text-center",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold",children:B("preview.generatingTitle")}),(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Model:"," ",n.VIDEO_MODELS[eu.model]?.name||eu.model," ","| Duration: ",eu.duration,"s"]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"h-2 w-full overflow-hidden rounded-full bg-secondary",children:(0,t.jsx)("div",{className:"h-full bg-primary transition-all duration-500",style:{width:`${ep}%`}})}),(0,t.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,t.jsxs)("span",{children:[Math.round(ep),"%"]}),void 0!==eu.estimatedTimeLeft&&eu.estimatedTimeLeft>0&&(0,t.jsxs)("span",{children:[B("preview.estimatedRemaining")," ",Math.
1ceil(eu.estimatedTimeLeft/60),B("preview.mins")]})]})]})]})]}),"results"===eu.state&&eu.videoUrl&&(0,t.jsxs)("div",{className:"w-full space-y-4",children:[(0,t.jsx)(F.VideoPlayer,{videoUrl:eu.videoUrl,thumbnailUrl:eu.thumbnailUrl,autoPlay:!1,loop:!0}),(0,t.jsx)("div",{className:"flex items-center justify-between text-sm",children:(0,t.jsxs)("div",{className:"text-muted-foreground space-y-1",children:[(0,t.jsxs)("p",{children:["Model:"," ",n.VIDEO_MODELS[eu.model]?.name||eu.model]}),(0,t.jsxs)("p",{children:["Duration: ",eu.duration,"s"]})]})}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(a.Button,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>{window.open(`/video/${eu.videoId}`,"_blank")},children:[(0,t.jsx)(j.ExternalLink,{className:"mr-2 h-4 w-4"}),B("preview.viewDetails")]}),(0,t.jsxs)(a.Button,{size:"sm",className:"flex-1",onClick:()=>{if(eu.videoUrl){let e=document.createElement("a");e.href=eu.videoUrl,e.download=`video-${eu.videoId}.mp4`,document.body.appendChild(e),e.click(),document.body.removeChild(e)}},children:[(0,t.jsx)(g.Download,{className:"mr-2 h-4 w-4"}),B("preview.downloadVideo")]})]}),(0,t.jsx)(a.Button,{variant:"outline",className:"w-full",onClick:()=>ex({state:"idle"}),children:B("preview.generateNew")})]}),"error"===eu.state&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 p-8",children:[(0,t.jsx)("div",{className:"text-5xl",children:"â ï¸"}),(0,t.jsxs)("div",{className:"space-y-2 text-center",children:[(0,t.jsx)("h3",{className:"text-lg font-semibold text-destructive",children:B("preview.failedTitle")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground break-words max-h-[200px] overflow-y-auto px-4 w-full",children:eu.error?.message}),eu.error?.suggestion&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["ð¡ ",eu.error.suggestion]})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(a.Button,{variant:"outline",onClick:()=>ex({state:"idle"}),children:B("preview.backToConfig")}),eu.videoId&&(0,t.jsx)(a.Button,{variant:"outline",onClick:()=>{window.open(`/video/${eu.videoId}`,"_blank")},children:B("preview.viewDetails")}),eu.error?.code==="INSUFFICIENT_CREDITS"&&(0,t.jsx)(a.Button,{onClick:()=>_.push("/pricing"),children:B("preview.purchaseCredits")})]})]})]})})})]}),ea&&$&&(0,t.jsx)(l.HistoryWorksPanel,{currentUser:$,defaultTab:"videos"})]})}e.s(["VideoSubmissionForm",()=>er],709010)}]);
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.