1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[278],{70278:(t,r,e)=>{e.d(r,{executeGenerationRuntime:()=>a});var l=e(51562),i=e(50125),n=e(80999);async function u(t){let r=await fetch(t),e=await r.blob(),l="bin";e.type.startsWith("image/")?l="png":e.type.startsWith("video/")?l="mp4":e.type.startsWith("audio/")&&(l=e.type.includes("wav")?"wav":"mp3");let i=new File([e],"upload.".concat(l),{type:e.type}),n=new FormData;n.append("files",i);let u=await fetch("/api/storage/upload-image",{method:"POST",body:n});if(!u.ok)throw Error("File upload failed");let a=await u.json();if(0!==a.code)throw Error(a.message||"File upload failed");return a.data.urls[0]}async function a(t){var r,e;let{pending:a,remainingCredits:o,previewCost:s,mediaType:f,newTask:p,resolvePricingProvider:d}=t,c=[];for(let t of a.blobUrls)if(t.startsWith("blob:")){let r=await u(t);c.push(r)}else c.push(t);let y=null==(r=a.mediaItems)?void 0:r.map((t,r)=>{var e;return{...t,url:null!=(e=c[r])?e:t.url}}),{endpoint:m,body:g}=(0,i.p)({prompt:null!=(e=a.submissionPrompt)?e:a.prompt,model:a.model,feature:a.feature,genParams:a.params,uploadedFileUrls:c,uploadedMediaItems:y});g.provider=d(a.model,g.provider);let v=(0,l.b)(g);if(o<v)throw Error("Insufficient credits. Please top up to keep creating.");let h=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json","x-request-id":p.id},body:JSON.stringify(g)});if(!h.ok)throw Error("Request failed: ".concat(h.status));let{code:b,message:w,data:k}=await h.json();if(0!==b)throw Error(w||"Failed to create task");let j=null==k?void 0:k.id;if(!j)throw Error("Task ID missing in response");return"success"===k.status&&k.taskInfo?{type:"completed",task:{...p,taskId:j,status:"success",result:(0,n.T2)(f,(0,n.tO)(k.taskInfo)),uploadedFileUrls:c,mediaItems:y,creditsCost:v}}:{type:"polling",task:{...p,taskId:j,status:"pending",uploadedFileUrls:c,mediaItems:y,creditsCost:v!==s?v:p.creditsCost}}}},80999:(t,r,e)=>{function l(t){if(!t)return null;try{return JSON.parse(t)}catch(t){return null}}function i(t,r){if("video"===t){let t=function(t){var r,e,l,i,n,u;if(!t)return[];let a=t.videos;if(a&&Array.isArray(a))return a.map(t=>{if(!t)return null;if("string"==typeof t)return t;if("object"==typeof t){var r,e,l,i;return null!=(i=null!=(l=null!=(e=null!=(r=t.url)?r:t.uri)?e:t.video)?l:t.src)?i:t.videoUrl}return null}).filter(Boolean);let o=null!=(e=null!=(r=t.output)?r:t.video)?e:t.data;if(!o)return[];if("string"==typeof o)return[o];if(Array.isArray(o))return o.flatMap(t=>{if(!t)return[];if("string"==typeof t)return[t];if("object"==typeof t){var r,e,l,i;let n=null!=(i=null!=(l=null!=(e=null!=(r=t.url)?r:t.uri)?e:t.video)?l:t.src)?i:t.videoUrl;return"string"==typeof n?[n]:[]}return[]}).filter(Boolean);if("object"==typeof o){let t=null!=(u=null!=(n=null!=(i=null!=(l=o.url)?l:o.uri)?i:o.video)?n:o.src)?u:o.videoUrl;if("string"==typeof t)return[t]}return[]}(r);return t.length>0?{videos:t.map(t=>({videoUrl:t}))}:null}let e=function(t){var r,e,l,i,n;if(!t)return[];let u=t.images;if(u&&Array.isArray(u))return u.map(t=>{if(!t)return null;if("string"==typeof t)return t;if("object"==typeof t){var r,e,l;return null!=(l=null!=(e=null!=(r=t.url)?r:t.uri)?e:t.imageUrl)?l:t.src}return null}).filter(Boolean);let a=null!=(e=null!=(r=t.output)?r:t.image)?e:t.data;if(!a)return[];if("string"==typeof a)return[a];if(Array.isArray(a))return a.flatMap(t=>{if(!t)return[];if("string"==typeof t)return[t];if("object"==typeof t){var r,e,l;let i=null!=(l=null!=(e=null!=(r=t.url)?r:t.uri)?e:t.imageUrl)?l:t.src;return"string"==typeof i?[i]:[]}return[]}).filter(Boolean);if("object"==typeof a){let t=null!=(n=null!=(i=null!=(l=a.url)?l:a.uri)?i:a.imageUrl)?n:a.src;if("string"==typeof t)return[t]}return[]}(r);return e.length>0?{images:e.map(t=>({imageUrl:t}))}:null}e.d(r,{T2:()=>i,tO:()=>l})}}]);
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.