PageSourceSearch

https://www.ai-geminiomni.com/_astro/VideoStudio.astro_astro_type_script_index_0_lang.D6vDC_mI.js

js ai-geminiomni.com collected 2026-10-04 13:25:23 UTC 27,312 bytes, 1 lines download raw bytes

1const Ie="gemini_omni_4561",L="https://www.gushanai.com/api",at="auth_token",it="user_info",ct="gemini-omni:auth-changed";class m extends Error{code;status;constructor(t,n,o){super(n),this.code=t,this.status=o,this.name="ApiError"}}function Ut(){if(!(typeof document>"u"))return document.documentElement.lang||void 0}function de(){return typeof window>"u"?null:window.localStorage.getItem(at)}function Rt(){typeof window>"u"||(window.localStorage.removeItem(at),window.localStorage.removeItem(it),window.dispatchEvent(new CustomEvent(ct,{detail:{token:null,user:null}})))}async function Nt(e,t){const n={"Content-Type":"application/json","x-app-key":Ie},o=de();o&&(n.Authorization=o);const r=Ut();r&&(n["x-locale"]=r);let i;try{i=await fetch(`${L}${e}`,{method:"POST",headers:n,body:JSON.stringify(t??{})})}catch(d){throw new m(-1,d?.message||"Network error")}let s;try{s=await i.json()}catch{throw new m(i.status,`HTTP ${i.status}`,i.status)}if(!s||s.code!==200&&s.code!==0)throw i.status===401&&Rt(),new m(s?.code??i.status,s?.message||`HTTP ${i.status}`,i.status);return s.data}async function Ot(){const e=await Nt("/mine/info",{});return typeof window<"u"&&(window.localStorage.setItem(it,JSON.stringify(e)),window.dispatchEvent(new CustomEvent(ct,{detail:{token:de(),user:e}}))),e}const lt=-22,$t={queued:"queued",queue:"queued",waiting:"queued",processing:"processing",running:"processing",pending:"processing",in_progress:"processing","in-progress":"processing",inprogress:"processing",success:"success",completed:"success",complete:"success",succeeded:"success",done:"success",failed:"failed",fail:"failed",error:"failed",failure:"failed",canceled:"canceled",cancelled:"canceled"};function zt(e){if(typeof e!="string"||!e)return null;const t=e.trim().toLowerCase().replace(/\s+/g,"_");return $t[t]??null}function Dt(e){if(typeof e!="string"||!e)return null;const t=e.trim().toUpperCase().replace(/[\s_-]/g,"");return t==="720P"||t==="720"||t==="HD"?"720P":t==="1080P"||t==="1080"||t==="FHD"||t==="FULLHD"?"1080P":t==="4K"||t==="2160P"||t==="2160"||t==="UHD"?"4K":null}function Mt(e){if(typeof e!="string"||!e)return null;const t=e.trim().toLowerCase().replace(/\s+/g,"");return t==="16:9"||t==="16/9"||t==="landscape"?"16:9":t==="9:16"||t==="9/16"||t==="portrait"?"9:16":null}function g(e,...t){for(const n of t){const o=e[n];if(typeof o=="string"&&o.length>0)return o}return null}function b(e,...t){for(const n of t){const o=e[n];if(typeof o=="number"&&Number.isFinite(o))return o}return null}function Te(e,t){if(!e||typeof e!="object")return null;const n=e,o=g(n,"task_id","taskId","id"),r=zt(g(n,"status","task_status","taskStatus"));if(!o||!r)return null;const i=g(n,"prompt")??t?.prompt??"",s=Dt(g(n,"resolution"))??t?.resolution??"720P",d=Mt(g(n,"aspect_ratio","aspectRatio"))??t?.aspectRatio??"16:9",l=b(n,"duration_seconds","durationSeconds")??t?.durationSeconds??0;return{taskId:o,status:r,prompt:i,resolution:s,aspectRatio:d,durationSeconds:l,videoUrl:g(n,"video_url","videoUrl","output_url","outputUrl"),progress:b(n,"progress","progress_percent","progressPercent"),pointsCost:b(n,"points_cost","pointsCost","cost"),errorMessage:g(n,"error_message","errorMessage","fail_reason","failReason"),etaSeconds:b(n,"eta_seconds","etaSeconds","remaining_seconds","remainingSeconds"),createdAt:g(n,"created_at","createdAt"),updatedAt:g(n,"updated_at","updatedAt")}}const jt=5,dt=600*1e3,ye=[3e3,5e3,1e4],qt=10*1024*1024,ut="active_video_task_id";function ke(e){return e==="success"||e==="failed"||e==="canceled"}function Ht(e){return e==null||!Number.isFinite(e)?null:e<0?0:e<=1?e*100:Math.min(100,e)}function ft(e){if(!e||typeof e!="object")return!1;const t=e;return t.status===401||t.status===403||t.code===401||t.code===403}function Vt(e){if(!e||typeof e!="object")return!1;const t=e;return t.code===lt||t.message==="Invalid status response"}function Bt(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.status=="number"&&t.status>=500}function Ft(e,t){return ft(e)?"stop-auth":(Vt(e)||Bt(e))&&t>=jt?"stop-errors":"retry"}function Pe(e){return e?`active_video_task_id:${e}
1`:ut}function Kt(e){return JSON.stringify(e)}function Jt(e){if(!e)return null;try{const t=JSON.parse(e);if(t&&typeof t=="object"){const n=t;if(typeof n.taskId=="string"&&n.taskId&&typeof n.startedAt=="number")return{taskId:n.taskId,startedAt:n.startedAt}}}catch{return e.length>0&&e[0]!=="{"?{taskId:e,startedAt:Date.now()}:null}return e.length>0&&e[0]!=="{"?{taskId:e,startedAt:Date.now()}:null}function Yt(e,t=Date.now()){return t-e.startedAt<=dt}function Gt(e){return JSON.stringify({prompt:e.prompt,resolution:e.resolution,aspectRatio:e.aspectRatio,durationSeconds:e.durationSeconds,images:e.images??[]})}function Wt(e,t=qt){return e.type&&!e.type.startsWith("image/")?"type":e.size>t?"size":"ok"}function pt(){if(!(typeof document>"u"))return document.documentElement.lang||void 0}function Y(e){const t={"x-app-key":Ie};e&&(t["Content-Type"]=e);const n=de();n&&(t.Authorization=n);const o=pt();return o&&(t["x-locale"]=o),t}async function G(e){let t;try{t=await e.json()}catch{throw new m(e.status,`HTTP ${e.status}`,e.status)}if(!t||t.code!==200&&t.code!==0)throw new m(t?.code??e.status,t?.message||`HTTP ${e.status}`,e.status);return t.data}function Xt(e){if(!e||typeof e!="object")return null;const t=e,n=g(t,"id","ledger_id","ledgerId")??crypto.randomUUID(),o=g(t,"created_at","createdAt","time")??"",r=g(t,"type","change_type","changeType","biz_type","bizType")??"",i=b(t,"points_change","pointsChange","change","delta","amount")??0,s=b(t,"balance_after","balanceAfter","after_balance","afterBalance")??0,d=g(t,"remark","description","memo");return{id:n,createdAt:o,type:r,pointsChange:i,balanceAfter:s,remark:d}}function gt(e,t){if(!e||typeof e!="object")return{items:[],total:0,page:1,pageSize:10};const n=e,o=n.items??n.list??n.records??n.data,r=Array.isArray(o)?o.map(t).filter(i=>i!==null):[];return{items:r,total:b(n,"total","total_count","totalCount")??r.length,page:b(n,"page","current_page","currentPage")??1,pageSize:b(n,"page_size","pageSize","limit")??10}}function Qt(e){const t={prompt:e.prompt,resolution:e.resolution,aspect_ratio:e.aspectRatio,duration_seconds:e.durationSeconds,idempotency_key:e.idempotencyKey};return e.images&&e.images.length>0&&(t.images=e.images.map(n=>({url:n.url,role:n.role}))),t}async function Zt(e){let t;try{t=await fetch(`${L}/video/ai/create`,{method:"POST",headers:Y("application/json"),body:JSON.stringify(Qt(e))})}catch(r){throw new m(-1,r?.message||"Network error")}const n=await G(t),o=Te(n,{prompt:e.prompt,resolution:e.resolution,aspectRatio:e.aspectRatio,durationSeconds:e.durationSeconds});if(!o)throw new m(-1,"Invalid create response");return o}async function en(e,t){let n;try{n=await fetch(`${L}/video/ai/status`,{method:"POST",headers:Y("application/json"),body:JSON.stringify({task_id:e})})}catch(i){throw new m(-1,i?.message||"Network error")}const o=await G(n),r=Te(o,t);if(!r)throw new m(lt,"Invalid status response",n.status);return r}async function tn(e,t){let n;try{n=await fetch(`${L}/video/ai/list`,{method:"POST",headers:Y("application/json"),body:JSON.stringify({page:e,page_size:t})})}catch(r){throw new m(-1,r?.message||"Network error")}const o=await G(n);return gt(o,Te)}async function nn(e){const t=new FormData;t.append("file",e);let n;try{n=await fetch(`${L}/upload/image`,{method:"POST",headers:Y(),body:t})}catch(r){throw new m(-1,r?.message||"Network error")}const o=await G(n);if(typeof o=="string"&&o.length>0)return o;if(o&&typeof o=="object"){const r=g(o,"url","image_url","imageUrl");if(r)return r}throw new m(-1,"Invalid upload response")}async function on(e,t){let n;try{n=await fetch(`${L}/mine/point-ledger`,{method:"POST",headers:Y("application/json"),body:JSON.stringify({page:e,page_size:t})})}catch(r){throw new m(-1,r?.message||"Network error")}const o=await G(n);return gt(o,Xt)}function rn(e){const t=e.toUpperCase().replace(/[\s-]/g,"_");return/VIDEO|VEO|OMNI/.test(t)?/4K|2160/.test(t)?"4K":/1080/.test(t)?"1080P":/720/.test(t)?"720P":null:null}async function sn(){const e={"x-app-key":Ie},t=de();t&&(e.Authorization=t);const n=pt();n&&(e["x-locale"]=n);let o;try{o=await fetch(`${L}/config/aicost`,{method:"GET",headers:e})}catch{return{}}if(!o.ok)return{};let r;try{r=await o.json()}catch{return{}}if(!r||r.code!==200&&r.code!==0)return{};const i=Array.isArray(r.data)?r.data:[],s={};for(const d of i){if(!d||typeof d!="object")continue;const l=d,S=typeof l.code=="string"?l.code:"",He=rn(S),W=typeof l.aiModelCost=="number"?l.aiModelCost:typeof l.costPerSecond=="number"?l.costPerSecond:typeof l.rate=="number"?l.rate:null;He&&W!=null&&Number.isFinite(W)&&W>=0&&(s[He]=W)}return s}const ue={"720P":10,"1080P":20,"4K":50};let re={...ue};function an(e){const t={...re};Object.keys(ue).forEach(n=>{const o=e[n];typeof o=="number"&&Number.isFinite(o)&&o>=0&&(t[n]=o)}),re=t}function mt(e,t){const n=re[e]??ue[e],o=Math.max(0,Math.floor(t));return n*o}function cn(e){return re[e]??ue[e]}const ln=789,Ve=document.getElementById("vs-i18n-data"),a=Ve?JSON.parse(Ve.textContent||"{}"):{},Ue="auth_token",Re="user_info",Ne="gemini-omni:auth-changed",ht=8e3,vt=9,fe=document.querySelector("[data-vs-root]");if(!fe)throw new Error("VideoStudio root not found");let I="text",v="frames",se="16:9",x="720P",T=5;const f=new Map;let be=crypto.randomUUID(),we="",C=null,j=0,B=0,k=null,h=null,y=null,F=!1,ae=!1,q=0,P=0,H=!1,te=null,U=null,Oe=!1,pe=null,Ce=!1,_e=!1,R=1,ne=1,N=1,oe=1;const c=e=>fe.querySelector(e),p=e=>fe.querySelectorAll(e),E=c("[data-vs-prompt]"),Be=c("[data-vs-counter]"),Fe=c("[data-vs-duration]"),Ke=c("[data-vs-duration-label]"),Je=c("[data-vs-cost-estimate]"),Ye=c("[data-vs-cost-rate]"),Ge=c("[data-vs-balance]"),$=c("[data-vs-error]"),yt=c("[data-vs-generate]"),ie=c("[data-vs-generate-label]"),dn=c("[data-vs-image-panel]"),un=c("[data-vs-frames-panel]"),fn=c("[data-vs-reference-panel]"),pn=c("[data-vs-monitor-empty]"),gn=c("[data-vs-monitor-active]"),Ee=c("[data-vs-status-badge]"),w=c("[data-vs-p
1oll-indicator]"),We=c("[data-vs-task-id]"),Xe=c("[data-vs-elapsed]"),Qe=c("[data-vs-eta]"),Ze=c("[data-vs-progress-wrap]"),et=c("[data-vs-progress-bar]"),Ae=c("[data-vs-video-wrap]"),V=c("[data-vs-video]"),z=c("[data-vs-failed-hint]"),K=c("[data-vs-retry]"),M=c("[data-vs-download]"),ce=c("[data-vs-download-label]"),Se=c("[data-vs-cost-actual]"),xe=c("[data-vs-history-list]"),X=c("[data-vs-history-empty]"),Q=c("[data-vs-history-pager]"),tt=c("[data-vs-history-page-info]"),D=c("[data-vs-ledger-body]"),Z=c("[data-vs-ledger-empty]"),ee=c("[data-vs-ledger-pager]"),nt=c("[data-vs-ledger-page-info]"),A=()=>{try{return window.localStorage.getItem(Ue)}catch{return null}},$e=()=>{try{const e=window.localStorage.getItem(Re);return e?JSON.parse(e):null}catch{return null}},ge=()=>{const e=$e();return typeof e?.id=="string"&&e.id?e.id:null},bt=(e,t)=>{const n=ge()||pe;if(n)try{localStorage.setItem(Pe(n),Kt({taskId:e,startedAt:t}))}catch{}},J=()=>{try{const e=ge()||pe;e&&localStorage.removeItem(Pe(e)),localStorage.removeItem(ut)}catch{}},mn=()=>{const e=ge();if(!e)return null;try{return Jt(localStorage.getItem(Pe(e)))}catch{return null}},wt=()=>{fe.setAttribute("data-vs-signed-in",A()?"true":"false");const e=ge();e&&(pe=e),ze()},ze=()=>
1{const t=$e()?.wallet?.points?.totalBalance;Ge&&(Ge.textContent=typeof t=="number"&&Number.isFinite(t)?String(t):"—")},u=e=>{$&&(e?($.textContent=e,$.classList.remove("hidden")):($.textContent="",$.classList.add("hidden")))},Et=e=>a.durationSec.replace("{n}",String(e)),me=()=>{const e=mt(x,T),t=cn(x);Je&&(Je.textContent=a.costPoints.replace("{n}",String(e))),Ye&&(Ye.textContent=a.costRate.replace("{rate}",String(t))),Ke&&(Ke.textContent=Et(T))},At=e=>{Se&&typeof e=="number"&&Number.isFinite(e)&&(Se.textContent=a.costActual.replace("{n}",String(e)),Se.removeAttribute("hidden"))},De=()=>{const e=(E?.value||"").length;Be&&(Be.textContent=`${e} / ${ht}`)},St=e=>{switch(e){case"queued":return a.statusQueued;case"processing":return a.statusProcessing;case"success":return a.statusSuccess;case"failed":return a.statusFailed;case"canceled":return a.statusCanceled;default:return String(e)}},xt=e=>{switch(e){case"queued":return"bg-amber-500/15 text-amber-200 border border-amber-400/30";case"processing":return"bg-violet-500/15 text-violet-200 border border-violet-400/30";case"success":return"bg-emerald-500/15 text-emerald-200 border border-emerald-400/30";case"failed":return"bg-rose-500/15 text-rose-200 border border-rose-400/30";case"canceled":return"bg-zinc-500/15 text-zinc-300 border border-zinc-400/30";default:return String(e)}},Ct=e=>{const t=Math.floor(e/1e3),n=Math.floor(t/60),o=t%60;return`${n}:${String(o).padStart(2,"0")}`},_t=e=>{pn?.toggleAttribute("hidden",e),gn?.toggleAttribute("hidden",!e)},hn=e=>{V&&(V.dataset.portrait=e==="9:16"?"true":"false")},le=e=>{_t(!0),y=e,We&&(We.textContent=e.taskId),Ee&&(Ee.textContent=St(e.status),Ee.className=`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold ${xt(e.status)}`);const t=ke(e.status);w?.classList.toggle("hidden",t),w&&!t&&(w.textContent=F?a.paused:a.polling);const n=Ht(e.progress);if(n!=null&&Ze&&et&&(Ze.removeAttribute("hidden"),et.style.width=`${n}%`),Qe&&(Qe.textContent=typeof e.etaSeconds=="number"&&Number.isFinite(e.etaSeconds)?Ct(e.etaSeconds*1e3):"—"),At(e.pointsCost),hn(e.aspectRatio),K?.setAttribute("hidden",""),e.status==="success"&&e.videoUrl)Ae?.removeAttribute("hidden"),z?.setAttribute("hidden",""),U=e.videoUrl,Oe=!1,V&&(V.src=e.videoUrl,V.load()),M&&(M.removeAttribute("hidden"),ce&&(ce.textContent=a.download));else if(e.status==="failed"||e.status==="canceled"){if(Ae?.setAttribute("hidden",""),M?.setAttribute("hidden",""),U=null,z){const o=e.status==="canceled"?a.canceledHint:a.failedHint;z.textContent=e.errorMessage||o,z.removeAttribute("hidden")}}else Ae?.setAttribute("hidden",""),M?.setAttribute("hidden",""),z?.setAttribute("hidden",""),U=null},_=(e={})=>{C&&(clearTimeout(C),C=null),k&&(clearInterval(k),k=null),j=0,P=0,e.clearTask&&(h=null)},ot=e=>{if(F||h!==e)return;const t=ye[Math.min(j,ye.length-1)];j=Math.min(j+1,ye.length-1),C=window.setTimeout(()=>he(e),t)},vn=()=>{Ce=!0,_();try{localStorage.removeItem(Ue),localStorage.removeItem(Re)}catch{}window.dispatchEvent(new CustomEvent(Ne,{detail:{token:null,user:null}})),u(a.loginRequired),window.dispatchEvent(new CustomEvent("open-login"))},rt=()=>{K?.removeAttribute("hidden"),w&&(w.textContent=a.retry,w.classList.remove("hidden"))},he=async e=>{if(!(F||h!==e)){if(Date.now()-B>dt){_(),J(),u(a.timeout),rt();return}try{const t=y?{resolution:y.resolution,aspectRatio:y.aspectRatio,prompt:y.prompt,durationSeconds:y.durationSeconds}:void 0,n=await en(e,t);if(P=0,le(n),ke(n.status)){_({clearTask:!0}),J(),O(1);try{window.dispatchEvent(new CustomEvent("gemini-omni:refresh-user"))}catch{}return}ot(e)}catch(t){P+=1;const n=Ft(t,P);if(n==="stop-auth"){vn();return}if(n==="stop-errors"){_(),u(t?.message||a.genericError),rt();return}ot(e)}}},Lt=()=>{k&&clearInterval(k);const e=()=>{Xe&&(Xe.textContent=Ct(Date.now()-B))};e(),k=window.setInterval(e,1e3)},Me=(e,t=Date.now())=>{_(),h=e,B=t,j=0,P=0,bt(e,t),K?.setAttribute("hidden",""),Lt(),he(e)},It=()=>{if(!A())return;const e=mn();if(e){if(!Yt(e)){J();return}Me(e.taskId,e.startedAt)}},yn=()=>{if(I!=="image")return;const e=[];if(v==="frames"){const t=f.get("first_frame"),n=f.get("last_frame");t&&e.push({url:t.url,role:"first_frame"}),n&&e.push({url:n.url,role:"last_frame"})}else for(let t=0;t<3;t++){const n=f.get(`ref_${t}`);n&&e.push({url:n.url,role:"reference"})}return e.length>0?e:void 0},Le=()=>{yt?.toggleAttribute("disabled",ae||q>0),ie&&(ie.textContent=ae?a.generating:a.generate)},st=e=>{ae=e,Le()},Tt=async()=>
1{if(ae||q>0)return;u("");const e=(E?.value||"").trim();if(!e){u(a.emptyPrompt),E?.focus();return}if(!A()){H=!0,u(a.loginRequired),window.dispatchEvent(new CustomEvent("open-login"));return}if(I==="image"&&v==="frames"&&!f.has("first_frame")){u(a.needFirst);return}if(I==="image"&&v==="reference"&&[...f.keys()].filter(d=>d.startsWith("ref_")).length<1){u(a.needReference);return}try{await Ot(),ze()}catch(s){if(ft(s)||!A()){H=!0,u(a.loginRequired),window.dispatchEvent(new CustomEvent("open-login"));return}}const t=mt(x,T),o=$e()?.wallet?.points?.totalBalance;if(typeof o=="number"&&o<t){u(a.insufficient),window.dispatchEvent(new CustomEvent("gemini-omni:open-recharge"));return}const r=yn(),i=Gt({prompt:e,resolution:x,aspectRatio:se,durationSeconds:T,images:r});i!==we&&(be=crypto.randomUUID(),we=i),st(!0);try{const s=await Zt({prompt:e,resolution:x,aspectRatio:se,durationSeconds:T,images:r,idempotencyKey:be});be=crypto.randomUUID(),we="",le(s),At(s.pointsCost),Me(s.taskId);try{window.dispatchEvent(new CustomEvent("gemini-omni:refresh-user"))}catch{}}catch(s){const d=s?.code??s?.status;if(d===401||d===403){try{localStorage.removeItem(Ue),localStorage.removeItem(Re)}catch{}window.dispatchEvent(new CustomEvent(Ne,{detail:{token:null,user:null}})),H=!0,u(a.loginRequired),window.dispatchEvent(new CustomEvent("open-login"))}else if(d===ln){try{window.dispatchEvent(new CustomEvent("gemini-omni:refresh-user"))}catch{}window.dispatchEvent(new CustomEvent("gemini-omni:open-recharge")),u(s?.message||a.insufficient)}else u(s?.message||a.genericError)}finally{st(!1)}},bn=e=>{if(e==="frames")["first_frame","last_frame"].forEach(t=>{const n=f.get(t);n?.preview&&URL.revokeObjectURL(n.preview),f.delete(t)}),p("[data-vs-slot]").forEach(ve);else{for(let t=0;t<3;t++){const n=`ref_${t}`,o=f.get(n);o?.preview&&URL.revokeObjectURL(o.preview),f.delete(n)}p("[data-vs-ref-slot]").forEach(kt)}},ve=e=>{const t=e.querySelector("[data-vs-slot-preview]"),n=e.querySelector("[data-vs-slot-placeholder]"),o=e.querySelector("[data-vs-slot-remove]"),r=e.querySelector("[data-vs-file-input]");t?.classList.add("hidden"),n?.classList.remove("hidden"),n&&(n.textContent=n.getAttribute("data-vs-slot-placeholder-label")||a.imageUpload),o?.setAttribute("hidden",""),r&&(r.value="")},kt=e=>{ve(e)},wn=(e,t)=>{const n=e.querySelector("[data-vs-slot-preview]"),o=n?.querySelector("img"),r=e.querySelector("[data-vs-slot-placeholder]"),i=e.querySelector("[data-vs-slot-remove]");o&&(o.src=t),n?.classList.remove("hidden"),r?.classList.add("hidden"),i?.removeAttribute("hidden")},je=async(e,t,n)=>{const o=t.querySelector("[data-vs-file-input]");if(!A()){te={slotKey:e,slotEl:t,file:n},o&&(o.value=""),window.dispatchEvent(new CustomEvent("open-login"));return}const r=Wt(n);if(r==="type"){u(a.errorType),o&&(o.value="");return}if(r==="size"){u(a.errorSize),o&&(o.value="");return}const i=t.querySelector("[data-vs-slot-placeholder]"),s=i?.getAttribute("data-vs-slot-placeholder-label")||a.imageUpload;i&&(i.textContent=a.imageUploading),q+=1,Le();try{const d=await nn(n),l=URL.createObjectURL(n);f.set(e,{url:d,preview:l}),wn(t,l)}catch{u(a.uploadError),ve(t)}finally{q=Math.max(0,q-1),Le(),i&&!f.has(e)&&(i.textContent=s)}},Pt=async(e,t)=>{if(!e)return;const n=`video-${t||"studio"}.mp4`;try{const o=await fetch(e,{mode:"cors"});if(!o.ok)throw new Error("download failed");const r=await o.blob(),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=n,s.rel="noopener",document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(i)}catch{Oe=!0,ce&&(ce.textContent=a.openVideo),window.open(e,"_blank","noopener,noreferrer")}},O=async e=>{if(!A()){X?.removeAttribute("hidden"),xe.innerHTML="",Q?.setAttribute("hidden","");return}try{const t=await tn(e,vt);if(R=t.page,ne=Math.max(1,Math.ceil(t.total/t.pageSize)),xe.innerHTML="",t.items.length===0){X?.removeAttribute("hidden"),Q?.setAttribute("hidden","");return}X?.setAttribute("hidden",""),t.items.forEach(n=>{const o=document.createElement("article");o.className="flex flex-col gap-2 rounded-2xl border border-white/10 bg-white/[0.03] p-4 transition-colors hover:border-violet-400/30";const r=document.createElement("span");
1r.className=`self-start inline-flex rounded-full px-2 py-0.5 text-[10px] font-semibold ${xt(n.status)}`,r.textContent=St(n.status);const i=document.createElement("p");i.className="line-clamp-2 text-xs text-zinc-400",i.textContent=n.prompt;const s=document.createElement("p");if(s.className="text-[10px] text-zinc-600",s.textContent=`${n.resolution} · ${n.aspectRatio} · ${Et(n.durationSeconds)}`,o.appendChild(r),o.appendChild(i),o.appendChild(s),n.pointsCost!=null){const l=document.createElement("p");l.className="text-[10px] text-zinc-500",l.textContent=a.historyCost.replace("{n}",String(n.pointsCost)),o.appendChild(l)}const d=document.createElement("div");if(d.className="mt-1 flex gap-2",n.videoUrl){const l=document.createElement("button");l.type="button",l.className="text-xs text-violet-300 hover:text-violet-100",l.textContent=a.historyView,l.addEventListener("click",()=>{_({clearTask:!0}),J(),le(n),window.scrollTo({top:0,behavior:"smooth"})}),d.appendChild(l);const S=document.createElement("button");S.type="button",S.className="text-xs text-zinc-400 hover:text-zinc-200",S.textContent=a.historyDownload,S.addEventListener("click",()=>Pt(n.videoUrl,n.taskId)),d.appendChild(S)}else if(!ke(n.status)){const l=document.createElement("button");l.type="button",l.className="text-xs text-violet-300 hover:text-violet-100",l.textContent=a.historyMonitor,l.addEventListener("click",()=>{y=n,le(n),Me(n.taskId),window.scrollTo({top:0,behavior:"smooth"})}),d.appendChild(l)}o.appendChild(d),xe.appendChild(o)}),ne>1?(Q?.removeAttribute("hidden"),tt&&(tt.textContent=a.historyPage.replace("{page}",String(R)).replace("{total}",String(ne)))):Q?.setAttribute("hidden","")}catch{X?.removeAttribute("hidden")}},qe=async e=>{if(!A()){Z?.removeAttribute("hidden"),D&&(D.innerHTML=""),ee?.setAttribute("hidden","");return}try{const t=await on(e,vt);if(N=t.page,oe=Math.max(1,Math.ceil(t.total/t.pageSize)),D&&(D.innerHTML=""),t.items.length===0){Z?.removeAttribute("hidden"),ee?.setAttribute("hidden","");return}Z?.setAttribute("hidden",""),t.items.forEach(n=>{const o=document.createElement("tr");o.className="hover:bg-white/[0.02]";const r=document.createElement("td");r.className="px-4 py-2.5 text-xs text-zinc-400",r.textContent=n.createdAt?new Date(n.createdAt).toLocaleString():"—";const i=document.createElement("td");i.className="px-4 py-2.5 text-xs",i.textContent=n.type||"—";const s=document.createElement("td");s.className=`px-4 py-2.5 text-xs tabular-nums font-semibold ${n.pointsChange>=0?"text-emerald-300":"text-rose-300"}`,s.textContent=n.pointsChange>=0?`+${n.pointsChange}`:String(n.pointsChange);const d=document.createElement("td");d.className="px-4 py-2.5 text-xs tabular-nums text-zinc-300",d.textContent=String(n.balanceAfter),o.append(r,i,s,d),D?.appendChild(o)}),oe>1?(ee?.removeAttribute("hidden"),nt&&(nt.textContent=a.ledgerPage.replace("{page}",String(N)).replace("{total}",String(oe)))):ee?.setAttribute("hidden","")}catch{Z?.removeAttribute("hidden")}};p("[data-vs-mode]").forEach(e=>{e.addEventListener("click",()=>{const t=e.getAttribute("data-vs-mode");t!=="text"&&t!=="image"||(I=t,p("[data-vs-mode]").forEach(n=>{const o=n.getAttribute("data-vs-mode")===I;n.setAttribute("aria-selected",o?"true":"false")}),dn?.toggleAttribute("hidden",I!=="image"))})});p("[data-vs-image-submode]").forEach(e=>{e.addEventListener("click",()=>{const t=e.getAttribute("data-vs-image-submode");t!=="frames"&&t!=="reference"||t!==v&&(bn(v),v=t,p("[data-vs-image-submode]").forEach(n=>{const o=n.getAttribute("data-vs-image-submode")===v;n.setAttribute("aria-selected",o?"true":"false")}),un?.toggleAttribute("hidden",v!=="frames"),fn?.toggleAttribute("hidden",v!=="reference"))})});p("[data-vs-slot]").forEach(e=>{const t=e.getAttribute("data-vs-slot"),n=e.querySelector("[data-vs-file-input]");n?.addEventListener("change",()=>{const o=n.files?.[0];o&&je(t,e,o)}),e.querySelector("[data-vs-slot-remove]")?.addEventListener("click",()=>{const o=f.get(t);o?.preview&&URL.revokeObjectURL(o.preview),f.delete(t),ve(e)})});p("[data-vs-ref-slot]").forEach(e=>{const n=`ref_${e.getAttribute("data-vs-ref-slot")}`,o=e.querySelector("[data-vs-file-input]");o?.addEventListener("change",()=>{const r=o.files?.[0];if(!r)return;const i=[...f.keys()].filter(s=>s.startsWith("ref_")).length;if(!f.has(n)&&i>=3){u(a.maxReference),o.value="";return}je(n,e,r)}),e.querySelector("[data-vs-slot-remove]")?.addEventListener("click",()=>{const r=f.get(n);r?.preview&&URL.revokeObjectURL(r.preview),f.delete(n),kt(e)})});
1p("[data-vs-example]").forEach(e=>{e.addEventListener("click",()=>{const t=e.getAttribute("data-vs-example-prompt")||"";E&&(E.value=t.slice(0,ht),E.focus()),De(),u("")})});p("[data-vs-ratio]").forEach(e=>{e.addEventListener("click",()=>{const t=e.getAttribute("data-vs-ratio");t!=="16:9"&&t!=="9:16"||(se=t,p("[data-vs-ratio]").forEach(n=>{const o=n.getAttribute("data-vs-ratio")===se;n.setAttribute("aria-pressed",o?"true":"false"),n.classList.toggle("border-violet-400/40",o),n.classList.toggle("bg-violet-500/10",o),n.classList.toggle("text-violet-100",o),n.classList.toggle("border-white/10",!o),n.classList.toggle("bg-white/[0.04]",!o),n.classList.toggle("text-zinc-300",!o)}))})});p("[data-vs-resolution]").forEach(e=>{e.addEventListener("click",()=>{const t=e.getAttribute("data-vs-resolution");t!=="720P"&&t!=="1080P"&&t!=="4K"||(x=t,p("[data-vs-resolution]").forEach(n=>{const o=n.getAttribute("data-vs-resolution")===x;n.setAttribute("aria-pressed",o?"true":"false"),n.classList.toggle("border-violet-400/40",o),n.classList.toggle("bg-violet-500/10",o),n.classList.toggle("text-violet-100",o),n.classList.toggle("border-white/10",!o),n.classList.toggle("bg-white/[0.04]",!o),n.classList.toggle("text-zinc-300",!o)}),me())})});Fe?.addEventListener("input",()=>{T=Number(Fe.value)||5,me()});E?.addEventListener("input",De);ie&&(ie.textContent=a.generate);yt?.addEventListener("click",Tt);K?.addEventListener("click",()=>{h&&(u(""),P=0,B=Date.now(),bt(h,B),K.setAttribute("hidden",""),Lt(),he(h))});M?.addEventListener("click",()=>{if(U){if(Oe){window.open(U,"_blank","noopener,noreferrer");return}Pt(U,h||y?.taskId)}});p("[data-vs-bottom-tab]").forEach(e=>{e.addEventListener("click",()=>{const t=e.getAttribute("data-vs-bottom-tab");p("[data-vs-bottom-tab]").forEach(n=>{n.setAttribute("aria-selected",n.getAttribute("data-vs-bottom-tab")===t?"true":"false")}),c("[data-vs-panel-history]")?.toggleAttribute("hidden",t!=="history"),c("[data-vs-panel-ledger]")?.toggleAttribute("hidden",t!=="ledger"),t==="ledger"&&qe(1)})});c("[data-vs-history-prev]")?.addEventListener("click",()=>{R>1&&O(R-1)});c("[data-vs-history-next]")?.addEventListener("click",()=>{R<ne&&O(R+1)});c("[data-vs-ledger-prev]")?.addEventListener("click",()=>{N>1&&qe(N-1)});c("[data-vs-ledger-next]")?.addEventListener("click",()=>{N<oe&&qe(N+1)});document.addEventListener("visibilitychange",()=>{document.hidden?(F=!0,C&&(clearTimeout(C),C=null),h&&w&&(w.textContent=a.paused,w.classList.remove("hidden"))):(F=!1,h&&he(h))});window.addEventListener(Ne,e=>{const n=!!e?.detail?.token,o=n&&!_e;if(wt(),_e=n,n){if(te){const r=te;te=null,je(r.slotKey,r.slotEl,r.file)}H?(H=!1,u(""),O(1),(E?.value||"").trim()&&Tt()):o?(O(1),It()):ze()}else _({clearTask:!0}),Ce||J(),Ce=!1,pe=null,_t(!1),y=null});const En=async()=>{try{const e=await sn();an(e),me()}catch{}};wt();_e=!!A();De();me();En();O(1);It();

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.