VideoGod / app.js
jmpplbp's picture
Duplicate from jmpplbp/VideoGod-backup-20260926
96f79ae
Raw History Blame Contribute Delete
76.9 kB
(()=>{(()=>{let t=Symbol.for("app.loraTouch.v1");if(document[t])return;document[t]=!0;let e=null;function o(i){let{slider:a,offset:s}=e,l=a.getBoundingClientRect(),d=12,p=Number(a.min||0),r=Number(a.max||100),f=Number(a.step)||1,x=Math.max(0,Math.min(1,(i.clientX-s-l.left-d)/Math.max(1,l.width-d*2))),I=Math.min(r,Math.max(p,p+Math.round(x*(r-p)/f)*f)),M=Number(I.toFixed(8));a.valueAsNumber!==M&&(a.value=String(M),a.dispatchEvent(new Event("input",{bubbles:!0})))}document.addEventListener("pointerdown",i=>{if(e||!i.isPrimary||!["touch","pen"].includes(i.pointerType))return;let a=i.target instanceof Element?i.target.closest('input[type="range"][data-lora-slider]'):null;if(!a||a.disabled)return;let s=a.getBoundingClientRect(),l=Number(a.min||0),d=Number(a.max||100),p=s.left+12+(a.valueAsNumber-l)/(d-l)*(s.width-24);e={slider:a,id:i.pointerId,offset:Math.abs(i.clientX-p)<=12?i.clientX-p:0},i.preventDefault(),a.focus({preventScroll:!0}),a.setPointerCapture(i.pointerId),o(i)},{capture:!0,passive:!1}),document.addEventListener("pointermove",i=>{!e||i.pointerId!==e.id||(i.preventDefault(),o(i))},{capture:!0,passive:!1});function n(i){if(!e||i.pointerId!==e.id)return;let{slider:a,id:s}=e;i.type==="pointerup"&&(i.preventDefault(),o(i)),e=null,a.hasPointerCapture(s)&&a.releasePointerCapture(s),a.dispatchEvent(new Event("change",{bubbles:!0}))}document.addEventListener("pointerup",n,{capture:!0,passive:!1}),document.addEventListener("pointercancel",n,!0),document.addEventListener("lostpointercapture",n,!0)})();var Fe=["cream","cream2","mllti","fella","moving"],Tt={cream:"zamen1",cream2:"zamen2",mllti:"dynamic move",moving:"dynamic move2",fella:"fella"},It=["cream","cream2","mllti","moving","fella"],Ge=()=>Object.fromEntries(Fe.map(t=>[t,0]));function qe(t,e){let o=Fe.filter(l=>{let d=e[l];if(!Number.isFinite(d)||d<0||d>2)throw new Error("LoRA strength must be between 0 and 2: "+l);return d!==0});if(!o.length)return;let n=Object.entries(t).filter(([,l])=>l.class_type==="CheckpointLoaderSimple");if(n.length!==1)throw new Error("Expected one VIDEO checkpoint loader");let i=n[0][0],a=Object.values(t).flatMap(l=>Object.entries(l.inputs).filter(([,d])=>Array.isArray(d)&&d[0]===i&&d[1]===0).map(([d])=>({node:l,key:d})));if(!a.length)throw new Error("VIDEO checkpoint model has no consumers");let s=[i,0];for(let l of o){let d="video_user_lora_"+l;if(t[d])throw new Error("LoRA node already exists: "+d);t[d]={class_type:"LoraLoaderModelOnly",inputs:{model:s,lora_name:l+".safetensors",strength_model:e[l]},_meta:{title:l}},s=[d,0]}for(let{node:l,key:d}of a)l.inputs[d]=s}function $(t,e=It,o=Tt){let n=document.createElement("fieldset");n.className="video-loras",n.id="video-loras";let i=document.createElement("legend");i.textContent="LoRA",n.append(i);let a=[],s=document.createElement("p");s.className="hint",s.textContent="0 = \u7121\u52B9 / 1 = \u6A19\u6E96\u306E\u5F37\u3055\u3002LoRA\u306F\u5358\u4F53\u3067\u306E\u4F7F\u7528\u3092\u63A8\u5968\u3057\u307E\u3059\u3002",n.append(s);for(let d of e){let p=document.createElement("div");p.className="video-lora-control";let r=document.createElement("label");r.htmlFor="lora-"+d,r.textContent=o[d];let f=document.createElement("input");f.type="range",f.setAttribute("aria-label",o[d]+" LoRA \u5F37\u3055"),f.dataset.loraSlider=d;let x=document.createElement("input");x.type="number",x.id="lora-"+d,x.name="lora_"+d,x.required=!0,x.setAttribute("aria-label",o[d]+" LoRA \u5F37\u3055\uFF08\u6570\u5024\uFF09");for(let M of[f,x])M.min="0",M.max="2",M.step="0.05",M.value=String(t[d]);x.inputMode="decimal";let I=M=>{t[d]=M,x.value=String(M),f.value=String(M),f.style.setProperty("--lora-fill",String(M/2*100)+"%")};f.addEventListener("input",()=>I(f.valueAsNumber)),x.addEventListener("input",()=>{x.validity.valid&&I(x.valueAsNumber)}),a.push(()=>I(0)),I(t[d]),p.append(r,x,f),n.append(p)}let l=document.createElement("button");return l.type="button",l.textContent="\u3059\u3079\u3066\u7121\u52B9\u306B\u3059\u308B",l.addEventListener("click",()=>{for(let d of a)d()}),n.append(l),n}var ne=["fella","nameru","kijyo","ona","gansha","paipai","multi"],De=Object.fromEntries(ne.map(t=>[t,t])),vt=new Set(["UNETLoader","MiniMaxH3Easy"]),Ot=new Set(["MiniMaxH3TurboLoRA","LTX_lora_loader","LoraLoaderModelOnly"]),Ve=()=>Object.fromEntries(ne.map(t=>[t,0]));function Pe(t){let e=$(t,ne,De);return e.id="minimax-loras",e}function Re(t,e){let o=ne.filter(p=>{let r=e[p];if(!Number.isFinite(r)||r<0||r>2)throw new Error("LoRA strength must be between 0 and 2: "+p);return r!==0});if(!o.length)return;let n=Object.entries(t).filter(([,p])=>vt.has(p.class_type));if(n.length!==1)throw new Error("Expected one video model source");let i=n[0][0],a=p=>Object.entries(t).flatMap(([r,f])=>Object.entries(f.inputs).filter(([,x])=>Array.isArray(x)&&x[0]===p&&x[1]===0).map(([x])=>({nodeId:r,node:f,key:x}))),s=new Set,l=a(i);for(;;){if(s.has(i))throw new Error("Cyclic video LoRA chain");s.add(i);let p=l.filter(({node:r,key:f})=>f==="model"&&Ot.has(r.class_type));if(!p.length)break;if(p.length!==1||l.length!==1)throw new Error("Ambiguous video LoRA chain");i=p[0].nodeId,l=a(i)}if(!l.length)throw new Error("Video model has no consumers");for(let p of o){let r="minimax_user_lora_"+p;if(t[r])throw new Error("LoRA node already exists: "+r)}let d=[i,0];for(let p of o){let r="minimax_user_lora_"+p;t[r]={class_type:"LoraLoaderModelOnly",inputs:{model:d,lora_name:"user-"+p+".safetensors",strength_model:e[p]},_meta:{title:De[p]}},d=[r,0]}for(let{node:p,key:r}of l)p.inputs[r]=d}function Be(t){return new Set(Object.values(t).filter(e=>e.class_type==="MiniMaxH3ReferenceToVideo").flatMap(e=>Object.entries(e.inputs).filter(([o,n])=>o.startsWith("ref_")&&Array.isArray(n)).map(([,o])=>String(o[0]))))}function Ue(t,e){for(let o of Object.values(t))if(["MiniMaxH3ReferenceToVideo","MiniMaxH3PromptFormat"].includes(o.class_type))for(let[n,i]of Object.entries(o.inputs))n.startsWith("ref_")&&Array.isArray(i)&&String(i[0])===e&&delete o.inputs[n]}function We(t){let e=document.createElement("section");e.className="panel";let o=t.ultra_resolution.inputs,n=(d,p)=>{let r=document.createElement("label");r.className="field";let f=document.createElement("span");f.textContent=d,r.append(f,p),e.append(r)},i=document.createElement("select");i.name="aspect_ratio";for(let d of["1:1 (Square)","2:3 (Portrait Photo)","3:2 (Photo)","3:4 (Portrait Standard)","4:3 (Standard)","9:16 (Portrait Widescreen)","16:9 (Widescreen)","21:9 (Ultrawide)"]){let p=document.createElement("option");p.value=d,p.textContent=d.split(" ")[0],i.append(p)}i.value=String(o.aspect_ratio),i.onchange=()=>{o.aspect_ratio=i.value},n("\u7E26\u6A2A\u6BD4",i);let a=document.createElement("input");a.type="number",a.name="megapixels",a.min="0.1",a.max="16",a.step="0.1",a.required=!0,a.value=String(o.megapixels),a.oninput=()=>{a.validity.valid&&(o.megapixels=a.valueAsNumber)},n("\u751F\u6210\u89E3\u50CF\u5EA6\uFF08\u30E1\u30AC\u30D4\u30AF\u30BB\u30EB\uFF09",a);let s=document.createElement("input");if(s.type="number",s.name="seconds",s.min="1",s.max="30",s.step="0.5",s.required=!0,s.value=String(t[5481].inputs.value),s.oninput=()=>{s.validity.valid&&(t[5481].inputs.value=s.valueAsNumber)},n("\u79D2\u6570",s),t.prompt_format)t.prompt_format.inputs.enabled=!0;let l=document.createElement("p");return l.className="hint",l.textContent="\u53C2\u8003\u7D20\u6750\u306F\u4EFB\u610F\u3067\u3059\u3002\u751F\u6210\u5F8C\u306B\u7E26\u6A2A2\u500D\u3078\u62E1\u5927\u3057\u307E\u3059\u3002",e.append(l),e}var Y={randomSeed:!0,seed:1};function ze(t,e){let o=document.createElement("section");o.className="panel canvas-controls";let n=document.createElement("h3");n.textContent="\u753B\u50CF\u306E\u8A2D\u5B9A",o.append(n);let i=Object.values(t).filter(g=>g.class_type==="KSampler"),a=Object.values(t).find(g=>g.class_type==="EmptyLatentImage"),s=document.createElement("div");s.className="fields";function l(g,O,F=s){let q=document.createElement("label");q.className="field";let b=document.createElement("span");b.textContent=g,q.append(b,O),F.append(q)}function d(g,O,F,q,b,V,B,ee=s){let D=document.createElement("input");return D.type="number",D.name=O,D.min=String(q),D.max=String(b),D.step=String(V),D.value=String(F),D.required=!0,D.oninput=()=>{D.validity.valid&&D.value!==""&&B(Number(D.value))},l(g,D,ee),D}let r=[...new Set(i.map(g=>String(g.inputs.negative?.[0])))].map(g=>t[g]).filter(g=>g?.class_type==="CLIPTextEncode");if(r.length){let g=document.createElement("textarea");g.name="negative_prompt",g.rows=3,g.value=String(r[0].inputs.text),g.oninput=()=>r.forEach(O=>O.inputs.text=g.value),l("\u30CD\u30AC\u30C6\u30A3\u30D6\u30D7\u30ED\u30F3\u30D7\u30C8",g,o)}if(o.append(s),a){let g=document.createElement("select");g.name="canvas_size";for(let[b,V]of[["1024x1024","\u6B63\u65B9\u5F62 1024 \xD7 1024"],["768x1024","\u7E26\u9577 768 \xD7 1024"],["1024x768","\u6A2A\u9577 1024 \xD7 768"],["576x1024","\u7E26\u9577 576 \xD7 1024"],["1024x576","\u6A2A\u9577 1024 \xD7 576"],["custom","\u30AB\u30B9\u30BF\u30E0"]]){let B=document.createElement("option");B.value=b,B.textContent=V,g.append(B)}let O=a.inputs.width+"x"+a.inputs.height;g.value=Array.from(g.options).some(b=>b.value===O)?O:"custom",l("\u30B5\u30A4\u30BA",g);let F=d("\u5E45\uFF08px\uFF09","canvas_width",Number(a.inputs.width),256,1024,64,b=>{a.inputs.width=b,g.value="custom"}),q=d("\u9AD8\u3055\uFF08px\uFF09","canvas_height",Number(a.inputs.height),256,1024,64,b=>{a.inputs.height=b,g.value="custom"});g.onchange=()=>{if(g.value==="custom")return;let[b,V]=g.value.split("x").map(Number);F.value=String(b),q.value=String(V),a.inputs.width=b,a.inputs.height=V},d("\u751F\u6210\u679A\u6570","canvas_batch",Number(a.inputs.batch_size),1,4,1,b=>a.inputs.batch_size=b)}i.length&&(d("\u30B9\u30C6\u30C3\u30D7\u6570","canvas_steps",Number(i[0].inputs.steps),1,60,1,g=>i.forEach(O=>O.inputs.steps=g)),d("\u30D7\u30ED\u30F3\u30D7\u30C8\u306E\u5F37\u3055\uFF08CFG\uFF09","canvas_cfg",Number(i[0].inputs.cfg),1,20,.5,g=>i.forEach(O=>O.inputs.cfg=g)));let f=document.createElement("input");f.type="checkbox",f.name="canvas_random_seed",f.checked=Y.randomSeed,l("\u30B7\u30FC\u30C9\u3092\u6BCE\u56DE\u30E9\u30F3\u30C0\u30E0\u306B\u3059\u308B",f);let x=d("\u30B7\u30FC\u30C9","canvas_seed",Y.seed,0,Number.MAX_SAFE_INTEGER,1,g=>Y.seed=g);x.disabled=f.checked,f.onchange=()=>{Y.randomSeed=f.checked,x.disabled=f.checked};let I=document.createElement("details"),M=document.createElement("summary");M.textContent="\u8A73\u7D30\u8A2D\u5B9A",I.append(M);let E=document.createElement("div");E.className="fields",I.append(E),o.append(I);for(let[g,O]of[["sampler_name","\u30B5\u30F3\u30D7\u30E9\u30FC"],["scheduler","\u30B9\u30B1\u30B8\u30E5\u30FC\u30E9\u30FC"]]){if(!i.length)continue;let F=document.createElement("select");F.name="canvas_"+g;let q=e.KSampler?.input?.required?.[g]?.[0],b=[...new Set([String(i[0].inputs[g]),...Array.isArray(q)?q:[]])];for(let V of b){let B=document.createElement("option");B.value=String(V),B.textContent=String(V),F.append(B)}F.onchange=()=>i.forEach(V=>V.inputs[g]=F.value),l(O,F,E)}let G=Object.values(t).filter(g=>g.class_type==="CLIPSetLastLayer");return G.length&&d("CLIP\u30B9\u30AD\u30C3\u30D7","canvas_clip_skip",Math.abs(Number(G[0].inputs.stop_at_clip_layer)),1,12,1,g=>G.forEach(O=>O.inputs.stop_at_clip_layer=-g),E),o}function Ke(t){return Object.values(t).flatMap(e=>(e.class_type==="Krea2EditModelPatch"?["source_latent_b","source_image_b"]:e.class_type==="Krea2EditGroundedEncode"?["image_b"]:[]).filter(n=>Array.isArray(e.inputs[n])).map(n=>({node:e,key:n})))}function He(t){let e=new Set,o=new Set,n=Ke(t).map(({node:i,key:a})=>String(i.inputs[a][0]));for(;n.length;){let i=n.pop();if(o.has(i))continue;o.add(i);let a=t[i];if(a){if(a.class_type==="LoadImage"){e.add(i);continue}for(let s of Object.values(a.inputs))Array.isArray(s)&&s.length===2&&n.push(String(s[0]))}}return e}function Xe(t){for(let{node:e,key:o}of Ke(t))delete e.inputs[o]}(()=>{let t=Symbol.for("app.seisuiPrompts.v1");if(document[t])return;document[t]=!0;let e=()=>{let o=document.querySelector("#workflow-form");if(!o)return;let n=()=>{let i=o.querySelector("#lora-j")?.closest(".video-lora-control");if(!i||i.querySelector("[data-seisui-prompts]"))return;let a=document.createElement("select");a.className="lora-prompt-presets",a.dataset.seisuiPrompts="",a.setAttribute("aria-label","Seisui \u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u7F6E\u63DB\uFF09");let s=document.createElement("option");s.value="",s.textContent="\u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u7F6E\u63DB\uFF09",a.append(s);for(let l of["a woman, jumpcut, after the transition, she is nude sitting with her legs spread, she is pissing on the ground","a woman, jumpcut, after the transition, she is nude on all fours, a nude man is standing in front of her, he is holding his penis and pissing into her mouth","a woman, jumpcut, after the transition, she is nude lying on her back with her legs back, she is pissing on her own face, piss splashes against her face, soaking her skin and dripping down her body"]){let d=document.createElement("option");d.value=l,d.textContent=l,a.append(d)}a.addEventListener("change",()=>{let l=o.querySelector('textarea[name="prompt"]');a.value&&l&&(l.value=a.value,l.dispatchEvent(new Event("input",{bubbles:!0})),a.value="")}),i.append(a)};new MutationObserver(n).observe(o,{childList:!0,subtree:!0}),n()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()})();(()=>{let t=document.querySelector("#app-config");if(!t||JSON.parse(t.textContent).id!=="image-edit-prime")return;let e=window.appSdk,o=Symbol.for("app.imageEditPrimeBranding.v1");if(!e||e[o])return;e[o]=!0;let n=/flux/i,i=p=>typeof p=="string"&&n.test(p)?"Image Edit Prime\u306E\u51E6\u7406\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002\u5165\u529B\u3068\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3057\u3066\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002":p,a=p=>typeof p=="string"?p.replace(/flux(?:\d+(?:\.\d+)*)?/ig,"ImageEditPrime"):p,s=e.onStatus.bind(e);e.onStatus=p=>s(r=>p({...r,message:i(r.message)}));let l=e.onResult.bind(e);e.onResult=p=>l(r=>{let f=r.output&&typeof r.output=="object"?{...r.output}:r.output;if(f)for(let x of["files","images"])Array.isArray(f[x])&&(f[x]=f[x].map(I=>({...I,filename:a(I.filename)})));return p({...r,error:i(r.error),output:f})});let d=e.onGenerate.bind(e);e.onGenerate=p=>d(async()=>{try{return await p()}catch(r){let f=i(r?.message);throw f!==r?.message?new Error(f):r}})})();(()=>{let t=document.querySelector("#app-config");if(!t||JSON.parse(t.textContent).id!=="video-karma")return;let e=window.appSdk,o=Symbol.for("app.videoKarmaBranding.v1");if(!e||e[o])return;e[o]=!0;let n=/(?:^|[^a-z])wan(?=$|[^a-z]|image|video|model|text|vae|i2v|t2v)/i,i=p=>typeof p=="string"&&n.test(p)?"Video Karma\u306E\u51E6\u7406\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002\u5165\u529B\u3068\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3057\u3066\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002":p,a=p=>typeof p=="string"?p.replace(/wan(?:\d+(?:\.\d+)*)?/ig,"VideoKarma"):p,s=e.onStatus.bind(e);e.onStatus=p=>s(r=>p({...r,message:i(r.message)}));let l=e.onResult.bind(e);e.onResult=p=>l(r=>{let f=r.output&&typeof r.output=="object"?{...r.output}:r.output;if(f)for(let x of["files","images"])Array.isArray(f[x])&&(f[x]=f[x].map(I=>({...I,filename:a(I.filename)})));return p({...r,error:i(r.error),output:f})});let d=e.onGenerate.bind(e);e.onGenerate=p=>d(async()=>{try{return await p()}catch(r){let f=i(r?.message);throw f!==r?.message?new Error(f):r}})})();(()=>{let t=Symbol.for("app.sideGreetings.v1");if(document[t])return;document[t]=!0;let e=()=>{let o=document.querySelector("#workflow-form");if(!o)return;let n=()=>{let i=o.querySelector("#lora-i")?.closest(".video-lora-control");if(!i||i.querySelector("[data-side-prompts]"))return;let a=document.createElement("select");a.className="lora-prompt-presets",a.dataset.sidePrompts="",a.setAttribute("aria-label","Side \u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u7F6E\u63DB\uFF09");let s=document.createElement("option");s.value="",s.textContent="\u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u7F6E\u63DB\uFF09",a.append(s);for(let l of["changed to scene cuts and she is having sex with her leg aside "]){let d=document.createElement("option");d.value=l,d.textContent=l,a.append(d)}a.addEventListener("change",()=>{let l=o.querySelector('textarea[name="prompt"]');a.value&&l&&(l.value=a.value,l.dispatchEvent(new Event("input",{bubbles:!0})),a.value="")}),i.append(a)};new MutationObserver(n).observe(o,{childList:!0,subtree:!0}),n()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()})();(()=>{let t=Symbol.for("app.fellaGreetings.v1");if(document[t])return;document[t]=!0;let e=()=>{let o=document.querySelector("#workflow-form");if(!o)return;let n=()=>{let i=o.querySelector("#lora-g")?.closest(".video-lora-control");if(!i||i.querySelector("[data-fella-prompts]"))return;let a=document.createElement("select");a.className="lora-prompt-presets",a.dataset.fellaPrompts="",a.setAttribute("aria-label","Fella \u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u7F6E\u63DB\uFF09");let s=document.createElement("option");s.value="",s.textContent="\u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u7F6E\u63DB\uFF09",a.append(s);for(let l of["A woman looking at the camera. The video then jumpcuts to the same woman giving a blowjob to a man standing in the same location, looking up as she performs the blowjob on the man, she is kneeling in front of him, she is holding his penis with both hands. she looks at the camera the entire time. she shoves the penis deep in her mouth."]){let d=document.createElement("option");d.value=l,d.textContent=l,a.append(d)}a.addEventListener("change",()=>{let l=o.querySelector('textarea[name="prompt"]');a.value&&l&&(l.value=a.value,l.dispatchEvent(new Event("input",{bubbles:!0})),a.value="")}),i.append(a)};new MutationObserver(n).observe(o,{childList:!0,subtree:!0}),n()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()})();(()=>{let t=Symbol.for("app.backGreetings.v1");if(document[t])return;document[t]=!0;let e=()=>{let o=document.querySelector("#workflow-form");if(!o)return;let n=()=>{let i=o.querySelector("#lora-h")?.closest(".video-lora-control");if(!i||i.querySelector("[data-back-prompts]"))return;let a=document.createElement("select");a.className="lora-prompt-presets",a.dataset.backPrompts="",a.setAttribute("aria-label","Back \u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u7F6E\u63DB\uFF09");let s=document.createElement("option");s.value="",s.textContent="\u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u7F6E\u63DB\uFF09",a.append(s);for(let l of["The video begins with a close-up of a woman. The video then jumpcuts to the same woman now having sex in doggystyle position. She is lying on her stomach, facing forward, with her head turned slightly to the side as she reacts to the sensations of intercourse. Her facial expressions change throughout the sequence, showing moments of pleasure and exertion, including wide eyes, an open mouth, and clenched fists.","The video begins with a close-up of a woman. The video then jumpcuts to the same woman now having sex with a man in doggystyle position in the the same location. She is positioned standing, while the man stands behind her, The man is muscular his hands are wrapped around the womanss stomach holding her upright while embracing her from behind, he holds her close as he thrusts into her. As the scene progresses, she moves rhythmically with him. she is fully nude. the man aggressively rams his hips into her.","The video begins with a close-up of a woman. The video then jumpcuts to the same woman now having sex with a man in doggystyle position in the same location. She is bent over with her back arched and her head tilted down as he stands behind her, He is muscular. The womans expression changes throughout the sequence as she reacts to their movements, sometimes looking down, other times up at the camera with an open mouth. The scene is recorded from below looking up. she looks at the camera the entire time. The man agressively has sex with her. she is fully nude."]){let d=document.createElement("option");d.value=l,d.textContent=l,a.append(d)}a.addEventListener("change",()=>{let l=o.querySelector('textarea[name="prompt"]');a.value&&l&&(l.value=a.value,l.dispatchEvent(new Event("input",{bubbles:!0})),a.value="")}),i.append(a)};new MutationObserver(n).observe(o,{childList:!0,subtree:!0}),n()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()})();(()=>{let t=Symbol.for("app.kijyoGreetings.v1");if(document[t])return;document[t]=!0;let e=()=>{let o=document.querySelector("#workflow-form");if(!o)return;let n=()=>{let i=o.querySelector("#lora-d")?.closest(".video-lora-control");if(!i||i.querySelector("[data-kijyo-prompts]"))return;let a=document.createElement("select");a.className="lora-prompt-presets",a.dataset.kijyoPrompts="",a.setAttribute("aria-label","Kijyo \u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u7F6E\u63DB\uFF09");let s=document.createElement("option");s.value="",s.textContent="\u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u7F6E\u63DB\uFF09",a.append(s);for(let l of["The video begins with a close-up of a woman. The video then jumpcuts to the same woman now having sex with a man in squatting cowgirl position her face fills the screen she is leaning over forwards as she bounces up and down aggressively. His erect penis is in her vagina.she looks at the camera throughout the video.The video is shot from above looking down on the scene.","The video begins with a close-up of a woman. The video then jumpcuts to the same woman now having sex with a man in squatting cowgirl position she is leaning backwards as she bounces up and down aggressively. His erect penis is in her vagina.she looks at the camera throughout the video."]){let d=document.createElement("option");d.value=l,d.textContent=l,a.append(d)}a.addEventListener("change",()=>{let l=o.querySelector('textarea[name="prompt"]');a.value&&l&&(l.value=a.value,l.dispatchEvent(new Event("input",{bubbles:!0})),a.value="")}),i.append(a)};new MutationObserver(n).observe(o,{childList:!0,subtree:!0}),n()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()})();(()=>{let t=Symbol.for("app.ganshaGreetings.v1");if(document[t])return;document[t]=!0;let e=()=>{let o=document.querySelector("#workflow-form");if(!o)return;let n=()=>{let i=o.querySelector("#lora-e")?.closest(".video-lora-control");if(!i||i.querySelector("[data-gansha-prompts]"))return;let a=document.createElement("select");a.className="lora-prompt-presets",a.dataset.ganshaPrompts="",a.setAttribute("aria-label","Gansha \u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u7F6E\u63DB\uFF09");let s=document.createElement("option");s.value="",s.textContent="\u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u7F6E\u63DB\uFF09",a.append(s);for(let l of["The video begins with a close-up of a woman. The video then jumpcuts to the same woman now receiving a facial from a mans penis. She is kneeling on the floor looking up with a open mouth. The cum shoots all over her face. The mans hand holds his erect penis masturbating his penis and shooting the thick white cum directly onto her face, forehead, eyes, cheek and mouth. The thick white cum slowly drips down her face onto her body. An explosion of thick white cum blasts her face. she looks directly at the camera throughout the video.","The video begins with a close-up of a woman. The video then jumpcuts to the same woman now receiving a facial from a mans penis. She is lying on her back. The cum shoots all over her face. The mans hand holds his erect penis masturbating his penis and shooting the thick white cum directly onto her face, forehead, eyes, cheek and mouth. The thick white cum slowly drips down her onto her body. an explosion of thick white cum blasts her face.she looks directly at the camera throughout the video."]){let d=document.createElement("option");d.value=l,d.textContent=l,a.append(d)}a.addEventListener("change",()=>{let l=o.querySelector('textarea[name="prompt"]');a.value&&l&&(l.value=a.value,l.dispatchEvent(new Event("input",{bubbles:!0})),a.value="")}),i.append(a)};new MutationObserver(n).observe(o,{childList:!0,subtree:!0}),n()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()})();(()=>{let t=Symbol.for("app.tekokiGreetings.v1");if(document[t])return;document[t]=!0;let e=()=>{let o=document.querySelector("#workflow-form");if(!o)return;let n=()=>{let i=o.querySelector("#lora-f")?.closest(".video-lora-control");if(!i||i.querySelector("[data-tekoki-prompts]"))return;let a=document.createElement("select");a.className="lora-prompt-presets",a.dataset.tekokiPrompts="",a.setAttribute("aria-label","Tekoki \u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u7F6E\u63DB\uFF09");let s=document.createElement("option");s.value="",s.textContent="\u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u7F6E\u63DB\uFF09",a.append(s);for(let l of["The video begins with a close-up of a woman. The video then jumpcuts to the same woman on her stomach with her head resting low in the frame on a mans thigh next to his penis on the left of the frame with her right hand she grasps the mans erect penis and moves it up and down the shaft in a steady rhythm, performing the handjob. She goes through various facial expressions throughout the video from happy to gasping she looks like she is talking.She looks at the camera throughout the video","The video begins with a close-up of a woman. The video then jumpcuts to the same woman now kneeling between a mans legs with her upper body is bent forward over him, and her face is close to his lap. With one hand, she grasps the mans erect penis and moves it up and down its shaft in a steady rhythm, performing the handjob. She goes through various facial expressions throughout the video from happy to gasping she looks like she is talking.She looks at the camera throughout the video She mans feet are seen in the background","The video begins with close-up of a woman. The video then jumpcuts to the same woman now kneeling on the floor in front of the man who is sitting high above her. She is giving the mans penis a handjob with both hands moving them up and down along the shaft. she goes through various facial expressions throughout the video from happy to gasping she looks like she is talking. The woman is looking up to the man.She looks at the camera throughout the video"]){let d=document.createElement("option");d.value=l,d.textContent=l,a.append(d)}a.addEventListener("change",()=>{let l=o.querySelector('textarea[name="prompt"]');a.value&&l&&(l.value=a.value,l.dispatchEvent(new Event("input",{bubbles:!0})),a.value="")}),i.append(a)};new MutationObserver(n).observe(o,{childList:!0,subtree:!0}),n()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()})();(()=>{let t=Symbol.for("app.seijyoGreetings.v1");if(document[t])return;document[t]=!0;let e=()=>{let o=document.querySelector("#workflow-form");if(!o)return;let n=()=>{let i=o.querySelector("#lora-c")?.closest(".video-lora-control");if(!i||i.querySelector("[data-seijyo-prompts]"))return;let a=document.createElement("select");a.className="lora-prompt-presets",a.dataset.seijyoPrompts="",a.setAttribute("aria-label","Seijyo \u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u7F6E\u63DB\uFF09");let s=document.createElement("option");s.value="",s.textContent="\u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u7F6E\u63DB\uFF09",a.append(s);for(let l of["The video begins with a close-up of a woman. The video then jumpcuts to the same woman now having sex in missionary position. She is lying on her back on a bed with a patterned bed spread and pillow with her legs spread wide. A mans large penis is visible entering her vagina from below. The man is positioned kneeling between her legs infront of her thrusting his penis into her vagina. Throughout the scene, she appears to be experiencing pleasure, often with her mouth open or eyes closed as she lies back. Her hands hold onto her thighs spreading her legs.","The video begins with a close-up of a woman. The video then jumpcuts to the same woman now having sex in missionary position. She is lying on her back on a bed with a patterned bed spread and pillow with her legs spread with her knees to her chest. A mans large penis is visible entering her vagina from below. The man is positioned kneeling between her legs infront of her thrusting his penis into her vagina. Throughout the scene, she appears to be experiencing pleasure, often with her mouth open or eyes closed as she lies back. Her hands hold onto her thighs spreading her legs.","The video begins with a close-up of a woman.The video then jumpcuts to the same woman having sex in missionary position on the edge of a bed with a mans erect penis is in her vagina she is shown experiencing various stages of sexual pleasure, with her facial expressions changing from contentment to intense enjoyment as the act continues.she looks at the camera throughout the video."]){let d=document.createElement("option");d.value=l,d.textContent=l,a.append(d)}a.addEventListener("change",()=>{let l=o.querySelector('textarea[name="prompt"]');a.value&&l&&(l.value=a.value,l.dispatchEvent(new Event("input",{bubbles:!0})),a.value="")}),i.append(a)};new MutationObserver(n).observe(o,{childList:!0,subtree:!0}),n()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()})();var Ae=["a","b","c","d","e","f","g","h","i","j"],Je=()=>Object.fromEntries(Ae.map(t=>[t,0]));function je(t,e){let o=document.createElement("details");o.className="wan-lora-settings";let n=document.createElement("summary");n.textContent="LoRA \u8A2D\u5B9A",o.append(n,$(t,Ae,{a:"Multi Motion",b:"PaiPai",c:"Seijyo",d:"Kijyo",e:"Gansha",f:"Tekoki",g:"Fella",h:"Back",i:"Side",j:"Seisui"}));let i=o.querySelector("#lora-b").closest(".video-lora-control"),a=document.createElement("select");a.className="lora-prompt-presets",a.setAttribute("aria-label","PaiPai \u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u7F6E\u63DB\uFF09");let s=document.createElement("option");s.value="",s.textContent="\u304A\u3059\u3059\u3081\u30D7\u30ED\u30F3\u30D7\u30C8\uFF08\u9078\u3076\u3068\u7F6E\u63DB\uFF09",a.append(s);for(let l of["The video begins with a close up of a woman. The video then jumpcuts to the same woman now lying down on a tiled floor of the the same location with her breasts positioned around the mans erect penis as he thrusts his penis up and down in a titjob motion sliding it between her breasts. she makes various facial expressions during the video she looks like she is talking and has her eyes wide open with a crazy expression.","The video begins with a close up of a woman. The video then jumpcuts to the same woman kneeling in the same location with her breasts positioned around the mans erect penis as she moves them up and down in a sliding motion. she makes various facial expressions she looks like she is talking and has her eyes wide open with a crazy expression."]){let d=document.createElement("option");d.value=l,d.textContent=l,a.append(d)}return a.addEventListener("change",()=>{a.value&&(e(a.value),a.value="")}),i.append(a),o}function Ye(t,e){let o=Ae.filter(n=>{let i=e[n];if(!Number.isFinite(i)||i<0||i>2)throw new Error("LoRA strength must be between 0 and 2: "+n);return i!==0});if(o.length){for(let[n,i,a]of[["high","101","104"],["low","102","103"]]){if(t[i]?.class_type!=="LoraLoaderModelOnly"||t[a]?.class_type!=="ModelSamplingSD3"||JSON.stringify(t[a].inputs.model)!==JSON.stringify([i,0]))throw new Error("Unexpected Video Karma "+n+" model chain");for(let s of o)if(t["wan_user_lora_"+s+"_"+n])throw new Error("Duplicate Video Karma LoRA node")}if(o.some(n=>n!=="a")){if(t[86]?.class_type!=="KSamplerAdvanced"||t[85]?.class_type!=="KSamplerAdvanced")throw new Error("Unexpected Video Karma sampler pair");Object.assign(t[86].inputs,{steps:4,start_at_step:0,end_at_step:1}),Object.assign(t[85].inputs,{steps:4,start_at_step:1,end_at_step:4}),t[104].inputs.shift=2,t[103].inputs.shift=2}for(let[n,i,a]of[["high","101","104"],["low","102","103"]]){let s=[i,0];for(let l of o){let d="wan_user_lora_"+l+"_"+n;t[d]={class_type:"LoraLoaderModelOnly",inputs:{model:s,lora_name:l+"-"+n+".safetensors",strength_model:e[l]},_meta:{title:l+" "+n}},s=[d,0]}t[a].inputs.model=s}}}function Qe(t,e){return t==="video-flow"&&/^(i2v|t2v)/.test(e)?64:["video-flow","video-fusion","image-edit-super","image-studio"].includes(t)?32:t==="image-canvas"?64:16}function le(t,e){return t.startsWith("image-")||t==="media-enhance"&&e==="image"?1024:768}function Ze(t,e,o=!1){return o?256:t==="video-flow"&&/^(i2v|t2v)/.test(e)?128:64}function $e(t,e,o=768,n=64){if(!Number.isFinite(t.width)||!Number.isFinite(t.height)||t.width<=0||t.height<=0)throw Error("\u7D20\u6750\u306E\u30B5\u30A4\u30BA\u3092\u8AAD\u307F\u53D6\u308C\u307E\u305B\u3093\u3002");let i=Math.min(1,o/Math.max(t.width,t.height)),a=Math.round(t.width*i/e)*e,s=Math.round(t.height*i/e)*e;if(Math.min(a,s)<n)throw Error("\u3053\u306E\u7D20\u6750\u306F\u7E26\u6A2A\u6BD4\u3092\u4FDD\u3063\u3066\u8ABF\u6574\u3059\u308B\u3068\u77ED\u8FBA\u304C"+n+"px\u672A\u6E80\u306B\u306A\u308A\u307E\u3059\u3002\u9577\u8FBA"+o+"px\u4EE5\u5185\u30FB\u77ED\u8FBA"+n+"px\u4EE5\u4E0A\u306B\u306A\u308B\u753B\u50CF\u3084\u52D5\u753B\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\u3002");return{width:a,height:s}}function xe(t){let e={width:0,height:0};for(let o of["width","height"])for(let n of Object.values(t)){let i=n._meta?.title||"";new RegExp("(?:^|\\s)"+o+"(?:$|\\s)","i").test(i)&&typeof n.inputs.value=="number"&&(e[o]=n.inputs.value);for(let a of[o,"resize_type."+o,"custom_"+o]){let s=n.inputs[a];typeof s=="number"&&s>0&&!e[o]&&(e[o]=s)}}return{width:e.width||768,height:e.height||768}}function te(t,e){for(let o of Object.values(t))for(let n of["width","height"]){for(let i of[n,"custom_"+n,"resize_type."+n])typeof o.inputs[i]=="number"&&(o.inputs[i]=e[n]);if(new RegExp("(?:^|\\s)"+n+"(?:$|\\s)","i").test(o._meta?.title||"")&&(/^Primitive(?:Int|Float)$/.test(o.class_type)&&typeof o.inputs.value=="number"&&(o.inputs.value=e[n]),o.class_type==="mxSlider"))for(let i of["Xi","Xf"])typeof o.inputs[i]=="number"&&(o.inputs[i]=e[n])}}function et(t,e,o){for(let n of new Set(e.map(i=>i[0]))){if(!/loadimage/i.test(t[n]?.class_type||""))continue;let i="input_size_"+n;for(;t[i];)i+="_";for(let a of Object.values(t))for(let[s,l]of Object.entries(a.inputs))Array.isArray(l)&&String(l[0])===n&&l[1]===0&&(a.inputs[s]=[i,0]);t[i]={class_type:"ImageScale",inputs:{image:[n,0],upscale_method:"lanczos",width:o.width,height:o.height,crop:"disabled"}}}}async function tt(t,e,o){if(e==="audio")return null;let n=URL.createObjectURL(t);try{return await new Promise((i,a)=>{let s=document.createElement(e==="image"?"img":"video"),l=setTimeout(()=>d(new Error("\u7D20\u6750\u306E\u30B5\u30A4\u30BA\u78BA\u8A8D\u304C\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8\u3057\u307E\u3057\u305F\u3002")),15e3);function d(p){clearTimeout(l),s.onerror=null,!p&&o!==void 0&&s instanceof HTMLVideoElement&&(!Number.isFinite(s.duration)||s.duration<=0?p=new Error("\u7D20\u6750\u52D5\u753B\u306E\u9577\u3055\u3092\u78BA\u8A8D\u3067\u304D\u307E\u305B\u3093\u3002"):s.duration>o&&(p=new Error("\u7D20\u6750\u52D5\u753B\u306F"+o+"\u79D2\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002")));let r=s instanceof HTMLImageElement?s.naturalWidth:s.videoWidth,f=s instanceof HTMLImageElement?s.naturalHeight:s.videoHeight;s instanceof HTMLVideoElement?(s.onloadedmetadata=null,s.removeAttribute("src"),s.load()):s.onload=null,p?a(p):r&&f?i({width:r,height:f}):a(new Error("\u7D20\u6750\u306E\u30B5\u30A4\u30BA\u3092\u78BA\u8A8D\u3067\u304D\u307E\u305B\u3093\u3002"))}s.onerror=()=>d(new Error("\u3053\u306E\u7D20\u6750\u306E\u30B5\u30A4\u30BA\u3092\u30D6\u30E9\u30A6\u30B6\u3067\u78BA\u8A8D\u3067\u304D\u307E\u305B\u3093\u3002\u5225\u306E\u753B\u50CF\u30FB\u52D5\u753B\u5F62\u5F0F\u3067\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002")),s instanceof HTMLImageElement?s.onload=()=>d():(s.preload="metadata",s.onloadedmetadata=()=>d()),s.src=n})}finally{URL.revokeObjectURL(n)}}var Te=(t,e)=>{let o=Object.entries(t).filter(([,s])=>e[s.class_type]?.output_node===!0).map(([s])=>s);if(!o.length)return 0;let n=new Set,i=[...o];for(;i.length;){let s=i.pop();if(n.has(s))continue;let l=t[s];if(l){n.add(s);for(let d of Object.values(l.inputs))Array.isArray(d)&&d.length===2&&i.push(String(d[0]))}}let a=0;for(let s of Object.keys(t))n.has(s)||(delete t[s],a+=1);return a};var at=t=>{let e=t.class_type.toLowerCase(),o=Object.keys(t.inputs).map(i=>i.toLowerCase()),n=(t._meta?.title??"").toLowerCase();return e.includes("lora")||/lora|turbo|4\s*steps?/.test(n)?"lora":e.includes("loadimage")||e.includes("loadvideo")?"input":e.includes("loader")||o.some(i=>["ckpt_name","unet_name","model_name","vae_name","clip_name"].includes(i))?"model":e.includes("textencode")||o.some(i=>["text","prompt","positive","negative"].includes(i))||typeof t.inputs.value=="string"&&(e.includes("primitivestring")||e.includes("stringmultiline")||e.includes("multilinestring")||/prompt|text \(multiline\)|プロンプト/.test(n))&&!/replace|regex|concatenate|combine/.test(e)?"prompt":e.includes("sampler")||/steps?|cfg|seed/.test(n)||o.some(i=>["steps","cfg","sampler_name","scheduler","seed","noise_seed"].includes(i))?"sampling":/fps|frame rate|frames?|duration|seconds?|width|height|size|length/.test(n)||o.some(i=>["width","target_width","output_width","height","target_height","output_height","length","duration","duration_seconds","seconds","num_frames","video_frames","frame_count","frames","fps","frame_rate"].includes(i))?"size":e.includes("save")||e.includes("preview")||e.includes("combine")?"output":"advanced"};var it=t=>{let e=t.toLowerCase().replace(/[^a-z0-9]+/g,"_");return/(?:^|_)negative(?:_|$)/.test(e)||e==="neg"?"negative":/(?:^|_)positive(?:_|$)/.test(e)||e==="pos"?"positive":null},ot=t=>{let e={},o=(i,a)=>{let s=e[i];e[i]=s&&s!==a?"both":a},n=(i,a,s)=>{if(s.has(i))return;s.add(i);let l=t[i];if(!l)return;at(l)==="prompt"&&o(i,a);let d=Object.entries(l.inputs).filter(([r,f])=>it(r)===a&&Array.isArray(f)&&f.length===2),p=d.length?d.map(([,r])=>r):Object.values(l.inputs);for(let r of p)Array.isArray(r)&&r.length===2&&n(String(r[0]),a,s)};for(let i of Object.values(t))for(let[a,s]of Object.entries(i.inputs)){let l=it(a);!l||!Array.isArray(s)||s.length!==2||n(String(s[0]),l,new Set)}for(let[i,a]of Object.entries(t)){if(e[i]||at(a)!=="prompt")continue;let s=(a._meta?.title??"").toLowerCase();/negative|ネガティブ|除外/.test(s)?o(i,"negative"):/positive|ポジティブ|肯定/.test(s)&&o(i,"positive")}return e};var ae=t=>typeof t=="number"&&Number.isFinite(t),ie=(t,e)=>t[e.id]?.inputs[e.key],K=(t,e,o)=>{for(let n of e)t[n.id].inputs[n.key]=o},st=t=>t._meta?.title||"";function nt(t,e,o){let n=document.createElement("section");n.className="panel basic-controls";let i=document.createElement("div");i.className="basic-prompts";let a=document.createElement("div");a.className="fields",n.append(i,a);let s=Object.entries(t),l=()=>n.dispatchEvent(new CustomEvent("workflowchange",{bubbles:!0}));function d(u,c,_,m={}){let h=document.createElement("label");h.className="field";let y=document.createElement("span");y.textContent=u,h.append(y);let A=m.multiline?document.createElement("textarea"):document.createElement("input");return A instanceof HTMLTextAreaElement?A.rows=3:(A.type="number",m.min!==void 0&&(A.min=String(m.min)),m.max!==void 0&&(A.max=String(m.max)),A.step=String(m.step??1)),A.value=String(c),m.name&&(A.name=m.name),m.ref&&(A.dataset.node=m.ref.id,A.dataset.input=m.ref.key),A.addEventListener("input",()=>{if(A instanceof HTMLInputElement){if(A.value===""||!A.validity.valid)return;let C=Number(A.value);if(!Number.isFinite(C))return;_(C)}else _(A.value);l()}),h.append(A),(m.container||(m.multiline?i:a)).append(h),A}let p=ot(t),r=new Map;for(let[u,c]of s)if(!(p[u]==="negative"||/negative|ネガティブ|除外/i.test(st(c))))for(let[_,m]of Object.entries(c.inputs)){if(typeof m!="string"||!(/^(text|prompt)$/.test(_)||_==="value"&&/PrimitiveString|StringMultiline|MultilineString/.test(c.class_type))||o.angleControls?.node===u&&o.angleControls.key===_||!m.trim()&&p[u]!=="positive")continue;let h=r.get(m)||{refs:[],value:m};h.refs.push({id:u,key:_}),r.set(m,h)}let M=0;for(let u of r.values()){if(e.id==="image-edit-super"&&o.id==="pose")continue;M++;let c=e.id==="sound-sync"?"\u97F3\u306E\u5185\u5BB9":e.id==="dialogue"?"\u52D5\u753B\u306E\u5185\u5BB9":r.size>1?"\u30D7\u30ED\u30F3\u30D7\u30C8 "+M:"\u30D7\u30ED\u30F3\u30D7\u30C8",_=e.id==="dialogue"&&u.value.match(/^; she says: [^\n]*\n*/)?.[0]||"",m=d(c,_?u.value.slice(_.length):u.value,h=>K(t,u.refs,_+h),{multiline:!0,ref:u.refs[0],name:"prompt"+(M>1?"_"+M:"")});e.id==="video-flow"&&(m.placeholder="\u5973\u6027\u304C\u30B3\u30C3\u30D7\u3092\u624B\u306B\u53D6\u3063\u3066\u98F2\u3080"),e.id==="image-edit-prime"&&(m.placeholder="\u5973\u6027\u304C\u7B11\u3046")}if(["video-karma","video-flow","video-extend"].includes(e.id)){let u=new Map;for(let[_,m]of s)if(!(p[_]!=="negative"&&!/negative|ネガティブ|除外/i.test(st(m))))for(let[h,y]of Object.entries(m.inputs)){if(typeof y!="string"||!(/^(text|prompt)$/.test(h)||h==="value"&&/PrimitiveString|StringMultiline|MultilineString/.test(m.class_type)))continue;let A=u.get(y)||{refs:[],value:y};A.refs.push({id:_,key:h}),u.set(y,A)}let c=0;for(let _ of u.values())c++,d("\u30CD\u30AC\u30C6\u30A3\u30D6\u30D7\u30ED\u30F3\u30D7\u30C8"+(u.size>1?" "+c:""),_.value,h=>K(t,_.refs,h),{multiline:!0,ref:_.refs[0],name:"negative_prompt"+(c>1?"_"+c:"")}).setAttribute("placeholder","\u907F\u3051\u305F\u3044\u5185\u5BB9\u3092\u5165\u529B\uFF08\u4EFB\u610F\uFF09")}let E=(u,c,_)=>{let m=t[u]?.inputs[c];return ae(m)?m:_},G=(u,c,_)=>{ae(t[u]?.inputs[c])&&(t[u].inputs[c]=_)};function g(){return s.flatMap(([u,c])=>Object.entries(c.inputs).filter(([_,m])=>ae(m)&&(_==="length"&&/LatentVideo|ImageToVideo|BerniniConditioning/.test(c.class_type)||_==="frames_number"||_==="frame_load_cap"&&m>0)).map(([_])=>({id:u,key:_})))}let Q;function J(u,c,_,m=.25,h,y={}){Q=d(u,c,_,{name:"seconds",min:y.min??m,max:y.max??30,step:m,ref:h})}let Z=E("24","frame_rate",20),At=Math.max(1,E("26","multiplier",2)),ge=5;function we(){let u=Z/At,c=Math.max(5,Math.round(ge*u/4)*4+1);G("24","frame_rate",Z),K(t,g(),c);for(let[,_]of s)/^VHS_LoadVideo/.test(_.class_type)&&typeof _.inputs.force_rate=="number"&&(_.inputs.force_rate=u)}if(e.id==="video-extend"){let u=document.createElement("label");u.className="field bernini-fps-control";let c=document.createElement("span");c.textContent="FPS\uFF08\u51FA\u529B\uFF09";let _=document.createElement("output");_.textContent=String(Z);let m=document.createElement("input");m.type="range",m.name="fps",m.id="bernini-fps",m.min="1",m.max="24",m.step="1",m.value=String(Z),m.style.cssText="width:100%;min-height:44px;touch-action:pan-y",m.setAttribute("aria-valuetext",Z+" FPS"),m.addEventListener("input",()=>{let h=Number(m.value);!Number.isInteger(h)||h<1||h>24||(Z=h,_.textContent=String(h),m.setAttribute("aria-valuetext",h+" FPS"),we(),l())}),u.append(c,_,m),a.append(u)}if(!o.continuation)if(e.id==="video-karma"){let u=g(),c=E("94","fps",16),_=u.length?Number(ie(t,u[0])):81,m=Number(((_-1)/c).toFixed(2)),h=10,y=s.flatMap(([U,X])=>Object.entries(X.inputs).filter(([j,z])=>/^(fps|frame_rate)$/.test(j)&&ae(z)).map(([j])=>({id:U,key:j}))),A=U=>{let X=Math.max(5,Math.round(U*h/4)*4+1);K(t,u,X)};J("\u79D2\u6570",m,A,.25,u[0]);let C=document.createElement("label");C.className="field karma-fps-control";let L=document.createElement("span");L.textContent="FPS";let k=document.createElement("output");k.textContent=String(h);let S=document.createElement("input");S.type="range",S.name="fps",S.id="karma-fps",S.min="1",S.max="24",S.step="1",S.value=String(h),S.dataset.loraSlider="",k.htmlFor=S.id;let H=()=>{h=Number(S.value),k.textContent=String(h),S.setAttribute("aria-valuetext",h+" FPS"),K(t,y,h),A(Number(Q.value)),l()};S.addEventListener("input",H),C.append(L,k,S),a.append(C),H()}else if(e.id==="video-flow"&&/^(i2v|t2v)/.test(o.id)){let u=E("300","value",24);J("\u79D2\u6570",E("301","value",5),c=>{G("301","value",c)},1,{id:"301",key:"value"})}else if(e.id==="video-flow"){let u=o.id==="crossview",c=u?E("616","value",24):E("133","frame_rate",24),_=g(),m=u?E("614","value",121):E("113","length",121);J("\u79D2\u6570",u?E("615","value",5):Number(((m-1)/c).toFixed(2)),h=>{let y=Math.max(9,Math.round(h*c/8)*8+1);K(t,_,y),u?(G("614","value",y),G("615","value",h)):(G("116","video_end_time",h),G("116","audio_end_time",h))},1,u?{id:"615",key:"value"}:{id:"113",key:"length"})}else if(e.id==="dialogue"){let u=E("542","value",24);J("\u52D5\u753B\u306E\u79D2\u6570",E("796","Xi",144)/u,c=>{let _=Math.max(8,Math.round(c*u/8)*8);G("796","Xi",_),G("796","Xf",_),G("535","frames_number",_+1)},1,{id:"796",key:"Xi"})}else if(e.id==="video-fusion"&&o.id!=="ultra")if(t[21]?.class_type==="MiniMaxH3Easy")J("\u79D2\u6570",E("21","seconds",5),u=>G("21","seconds",u),1,{id:"21",key:"seconds"},{min:1,max:20});else{let u=E("132","fps",24),c=E("133","length",124);J("\u79D2\u6570",Math.round(c/u*2)/2,_=>G("133","length",Math.max(5,Math.ceil((_*u-5)/17)*17+5)),.5,{id:"133",key:"length"})}else e.id==="video-extend"&&J("\u79D2\u6570",ge,u=>{ge=u,we()},.1,{id:"20",key:"length"});if(e.id==="motion-smooth"){let u=s.find(([,c])=>c.class_type==="FrameInterpolate");if(u){let[c,_]=u,m=Number(_.inputs.multiplier)||2,h=s.find(([,A])=>A.class_type==="VHS_VideoCombine"),y=h&&ae(h[1].inputs.frame_rate)?h[1].inputs.frame_rate/m:void 0;d("\u306A\u3081\u3089\u304B\u3055\uFF08\u500D\uFF09",m,A=>{_.inputs.multiplier=A,h&&y!==void 0&&(h[1].inputs.frame_rate=y*A)},{name:"interpolation",ref:{id:c,key:"multiplier"},min:2,max:8,step:1})}}return n.hidden=!i.children.length&&!a.children.length,n}var lt={"CLIPSave":{"output_node":true},"CheckpointPerturbWeights":{"output_node":true},"CheckpointSave":{"output_node":true},"ConsoleDebug+":{"output_node":true},"CreateBoundingBoxes":{"output_node":true},"DebugTensorShape+":{"output_node":true},"DecodeAndSaveVideo":{"output_node":true},"Display Any (rgthree)":{"output_node":true},"Display Int (rgthree)":{"output_node":true},"DisplayAny":{"output_node":true},"DummyOut":{"output_node":true},"FastPreview":{"output_node":true},"FastPreviewBatch":{"output_node":true},"HDRPreviewKJ":{"output_node":true},"IPAdapterSaveEmbeds":{"output_node":true},"Image Comparer (rgthree)":{"output_node":true},"ImageAndMaskPreview":{"output_node":true},"ImageCompare":{"output_node":true},"ImageCompositor":{"output_node":true},"ImageOnlyCheckpointSave":{"output_node":true},"ImagePreviewFromLatent+":{"output_node":true},"LTXVGemmaEnhancePrompt":{"output_node":true},"LTXVHDRDecodePostprocess":{"output_node":true},"LTXVSaveConditioning":{"output_node":true},"LTXVSparseTrackEditor":{"output_node":true},"LoraExtractKJ":{"output_node":true},"LoraReduceRankKJ":{"output_node":true},"LoraSave":{"output_node":true},"LossGraphNode":{"output_node":true},"MaskPreview":{"output_node":true},"MaskPreview+":{"output_node":true},"ModelSave":{"output_node":true},"ModelSaveKJ":{"output_node":true},"PlaySoundKJ":{"output_node":true},"Preview3D":{"output_node":true},"Preview3DAdvanced":{"output_node":true},"PreviewAnimation":{"output_node":true},"PreviewAny":{"output_node":true},"PreviewAudio":{"output_node":true},"PreviewGaussianSplat":{"output_node":true},"PreviewImage":{"output_node":true},"PreviewImageOrMask":{"output_node":true},"PreviewPointCloud":{"output_node":true},"SAM3_TrackPreview":{"output_node":true},"Save3DAdvanced":{"output_node":true},"SaveAnimatedPNG":{"output_node":true},"SaveAnimatedWEBP":{"output_node":true},"SaveAudio":{"output_node":true},"SaveAudioAdvanced":{"output_node":true},"SaveAudioMP3":{"output_node":true},"SaveAudioOpus":{"output_node":true},"SaveCondition_EditUtils":{"output_node":true},"SaveGLB":{"output_node":true},"SaveGaussianSplat":{"output_node":true},"SaveImage":{"output_node":true},"SaveImageAdvanced":{"output_node":true},"SaveImageDataSetToFolder":{"output_node":true},"SaveImageKJ":{"output_node":true},"SaveImageTextDataSetToFolder":{"output_node":true},"SaveImageWebsocket":{"output_node":true},"SaveImageWithAlpha":{"output_node":true},"SaveLatent":{"output_node":true},"SaveLoRA":{"output_node":true},"SavePointCloud":{"output_node":true},"SavePoseKpsAsJsonFile":{"output_node":true},"SaveSVGNode":{"output_node":true},"SaveStringKJ":{"output_node":true},"SaveText":{"output_node":true},"SaveTrainingDataset":{"output_node":true},"SaveVideo":{"output_node":true},"SaveWEBM":{"output_node":true},"SeparateMasks":{"output_node":true},"VAESave":{"output_node":true},"VHS_PruneOutputs":{"output_node":true},"VHS_VideoCombine":{"output_node":true},"VisualizeCUDAMemoryHistory":{"output_node":true},"KSampler":{"input":{"required":{"sampler_name":[["euler","euler_cfg_pp","euler_ancestral","euler_ancestral_cfg_pp","heun","heunpp2","exp_heun_2_x0","exp_heun_2_x0_sde","dpm_2","dpm_2_ancestral","lms","dpm_fast","dpm_adaptive","dpmpp_2s_ancestral","dpmpp_2s_ancestral_cfg_pp","dpmpp_sde","dpmpp_sde_gpu","dpmpp_2m","dpmpp_2m_cfg_pp","dpmpp_2m_sde","dpmpp_2m_sde_gpu","dpmpp_2m_sde_heun","dpmpp_2m_sde_heun_gpu","dpmpp_3m_sde","dpmpp_3m_sde_gpu","ddpm","lcm","ipndm","ipndm_v","deis","res_multistep","res_multistep_cfg_pp","res_multistep_ancestral","res_multistep_ancestral_cfg_pp","gradient_estimation","gradient_estimation_cfg_pp","er_sde","seeds_2","seeds_3","sa_solver","sa_solver_pece","ddim","uni_pc","uni_pc_bh2"],{"tooltip":"The algorithm used when sampling, this can affect the quality, speed, and style of the generated output."}],"scheduler":[["simple","sgm_uniform","karras","exponential","ddim_uniform","beta","normal","linear_quadratic","kl_optimal"],{"tooltip":"The scheduler controls how noise is gradually removed to form the image."}]}}}};var T=JSON.parse(document.querySelector("#app-config").textContent),Ie=lt,v=t=>document.querySelector(t),re=t=>structuredClone(t),N=T.modes[0],R=re(N?.workflow||{}),dt=Ge(),ut=Ve(),rt=Je(),P=new Map,pe=[],ve="",me=1,_e=768;function pt(){return le(T.id,N.id)===768?_e:1024}function Le(){if(T.id==="image-canvas")return xe(R);let t=xe(N.workflow),e=le(T.id,N.id)===768&&_e===1024?1024/Math.max(t.width,t.height):1;return ft({width:t.width*e,height:t.height*e})}var w=(t,e,o)=>{let n=document.createElement(t);return n.textContent=e,o&&(n.className=o),n};function W(t,e=!1){v("#ui-status").textContent=t,v("#ui-status").classList.toggle("error",e)}function oe(t,e,o,n={}){let i=document.createElement("label");i.className="field",i.append(w("span",t));let a;if(n.choices){a=document.createElement("select");for(let s of[...new Set([String(e),...n.choices])]){let l=document.createElement("option");l.value=s,l.textContent=s,a.append(l)}}else n.rows?(a=document.createElement("textarea"),a.rows=n.rows):(a=document.createElement("input"),a.type=typeof e=="boolean"?"checkbox":n.type||(typeof e=="number"?"number":"text"));return a instanceof HTMLInputElement&&a.type==="checkbox"?(a.checked=!!e,i.classList.add("check-field")):a.value=String(e),a instanceof HTMLInputElement&&(n.min!==void 0&&(a.min=String(n.min)),n.max!==void 0&&(a.max=String(n.max)),n.step!==void 0?a.step=String(n.step):typeof e=="number"&&(a.step="any")),a.addEventListener("input",()=>{let s=a instanceof HTMLInputElement&&a.type==="checkbox"?a.checked:typeof e=="number"?Number(a.value):a.value;o(s)}),i.append(a),n.help&&i.append(w("small",n.help)),{wrapper:i,field:a}}var bt=t=>"upload-"+crypto.randomUUID()+"."+(t.name.split(".").pop()?.toLowerCase().replace(/[^a-z0-9]/g,"").slice(0,8)||"bin"),de=t=>/loadaudio/i.test(t.class_type)?"audio":/loadvideo/i.test(t.class_type)?"video":/loadimage/i.test(t.class_type)?"image":null,Oe=t=>Object.keys(t.inputs).find(e=>/^(image|video|audio|file|path|filename|audiofile|audiopath)$/i.test(e)&&typeof t.inputs[e]=="string");function ce(t,e,o,n,i=!0,a=!1){let s=e!=="video"?void 0:T.id==="sound-sync"?30:T.id==="video-extend"||o==="continuation-source"||T.id==="video-flow"&&N?.id==="crossview"?10:void 0,l=s!==void 0,d=document.createElement("div");d.className="media-card",d.append(w("strong",t));let p=document.createElement("input");p.type="file",p.accept=e+"/*",p.multiple=a,p.dataset.upload=o,p.setAttribute("aria-label",t);let r=document.createElement("div");r.className="media-preview";let f=w("small",i?"\u7D20\u6750\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002":"\u4EFB\u610F\u306E\u53C2\u8003\u7D20\u6750");return l&&d.append(w("small","\u7D20\u6750\u52D5\u753B\u306F"+s+"\u79D2\u4EE5\u5185\u3002")),p.onchange=()=>{p.setCustomValidity("");for(let[I,M]of P)(I===o||I.startsWith(o+"::"))&&(URL.revokeObjectURL(M.url),P.delete(I));r.replaceChildren();let x=Array.from(p.files||[]);try{if(x.length>20)throw new Error("\u53C2\u8003\u7D20\u6750\u306F20\u4EF6\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002");if(x.reduce((I,M)=>I+M.size,0)>2*1024*1024*1024)throw new Error("\u5165\u529B\u7D20\u6750\u306F\u5408\u8A082 GiB\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002");x.forEach((I,M)=>{if(I.size>512*1024*1024)throw new Error("\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306F512 MiB\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002");let E=URL.createObjectURL(I),G=bt(I),g=tt(I,e,s);g.catch(F=>{l&&P.get(o)?.file===I&&p.isConnected&&(p.setCustomValidity(F.message),f.textContent=F.message,W(F.message,!0))}),P.set(a?o+"::"+M:o,{file:I,name:G,refs:n,url:E,kind:e,dimensions:g});let O=document.createElement(e==="image"?"img":e==="audio"?"audio":"video");O.src=E,O instanceof HTMLMediaElement?(O.controls=!0,O.preload="metadata",O instanceof HTMLVideoElement&&(O.playsInline=!0)):O.alt=I.name,r.append(O)}),f.textContent=x.length?x.map(I=>I.name+" \xB7 "+(I.size/1048576).toFixed(1)+" MiB").join(", "):i?"\u7D20\u6750\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002":"\u4EFB\u610F\u306E\u53C2\u8003\u7D20\u6750",W(x.length?"\u7D20\u6750\u3092\u8AAD\u307F\u8FBC\u307F\u307E\u3057\u305F\u3002\u5B9F\u884C\u30DC\u30BF\u30F3\u3067\u958B\u59CB\u3067\u304D\u307E\u3059\u3002":"\u7D20\u6750\u3092\u89E3\u9664\u3057\u307E\u3057\u305F\u3002"),Ee().catch(I=>W(I.message,!0))}catch(I){W(I.message,!0),p.value=""}},d.append(p,r,f),d}function Lt(){for(let t of P.values())URL.revokeObjectURL(t.url);P.clear()}function Et(t){let e=T.modes.find(o=>o.id===t);e&&(N=e,R=re(e.workflow),Lt(),ct(),W("\u5165\u529B\u3092\u8A2D\u5B9A\u3057\u3001\u30B5\u30A4\u30C8\u4E0A\u306E\u300C\u751F\u6210\u3059\u308B\u300D\u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044\u3002"))}function mt(t){return T.task==="dialogue"&&t==="dialogue-generated.wav"||N?.continuation&&t===N.continuation.last_frame_name}function _t(t){return T.id==="video-fusion"&&N.id==="ultra"?Be(t):T.id==="image-studio"&&N.id==="reference"?He(t):T.id!=="image-edit-super"||N.id!=="reference"?new Set:new Set(Object.values(t).filter(e=>e.class_type==="TextEncodeQwenImageEditPlus").flatMap(e=>{let o=e.inputs.image2;return Array.isArray(o)&&t[String(o[0])]?.class_type==="LoadImage"?[String(o[0])]:[]}))}function ct(){v("#workflow-form").replaceChildren(),v("#upload-list").replaceChildren();let t=new Map,e={};for(let[i,a]of Object.entries(R)){let s=de(a),l=Oe(a);if(s&&l&&!mt(a.inputs[l])){let d=s+":"+String(a.inputs[l]),p=t.get(d);if(!p){e[s]=(e[s]||0)+1;let r={image:"\u753B\u50CF",video:"\u52D5\u753B",audio:"\u97F3\u58F0"},f=a._meta?.title||"",x=T.id==="video-extend"&&s==="image"?"\u30B5\u30D6\u753B\u50CF":/reference|参考|参照/i.test(f)?"\u53C2\u8003"+r[s]:/pose|姿勢/i.test(f)?"\u59FF\u52E2\u306E\u53C2\u8003\u753B\u50CF":r[s];p={kind:s,label:T.id==="image-edit-super"&&N.id==="pose"&&s==="image"&&e[s]===2?"\u30DD\u30FC\u30BA\u53C2\u7167\u753B\u50CF":x+(e[s]>1?" "+e[s]:""),refs:[]},t.set(d,p)}p.refs.push([i,l])}}let o=_t(R);for(let[i,a]of t){let s=!a.refs.every(([l])=>o.has(l));v("#upload-list").append(ce(a.label+(s?"":"\uFF08\u4EFB\u610F\uFF09"),a.kind,i,a.refs,s))}N?.continuation&&v("#upload-list").prepend(ce("\u5EF6\u9577\u3059\u308B\u5143\u52D5\u753B","video","continuation-source",[])),kt(),T.id==="video-fusion"&&N.id==="ultra"||te(R,Le()),v("#workflow-form").append(nt(R,T,N)),T.id==="image-canvas"&&v("#workflow-form").append(ze(R,Ie)),T.id==="video-flow"&&v("#workflow-form").append($(dt)),T.id==="video-fusion"&&v("#workflow-form").append(Pe(ut)),T.id==="video-karma"&&v("#workflow-form").append(je(rt,i=>{let a=v('#workflow-form textarea[name="prompt"]');a.value=i,a.dispatchEvent(new Event("input",{bubbles:!0}))}));let n=w("p","\u30B5\u30A4\u30BA\u306F\u81EA\u52D5\u8ABF\u6574\uFF08\u9577\u8FBA\u6700\u5927"+pt()+"px\uFF09\u3002\u7D20\u6750\u306E\u7E26\u6A2A\u6BD4\u3092\u57FA\u6E96\u306B\u3057\u307E\u3059\u3002","hint");n.id="output-size-hint",T.id==="image-canvas"&&(n.textContent="\u5E45\u30FB\u9AD8\u3055\u306F256\u301C1024px\u300164px\u5358\u4F4D\u3067\u8A2D\u5B9A\u3067\u304D\u307E\u3059\u3002"),v("#workflow-form").append(n)}function Ne(){let t=P.get("continuation-source");if(t)return t;let e=Array.from(document.querySelectorAll("[data-upload]")).flatMap(o=>{let n=P.get(o.dataset.upload);return n&&n.kind!=="audio"?[n]:[]});return e.find(o=>o.kind==="video")||e[0]}function ft(t){return $e(t,Qe(T.id,N.id),pt(),Ze(T.id,N.id,!!N.continuation))}async function Ee(){if(T.id==="video-fusion"&&N.id==="ultra")return null;let t=Ne();if(!t)return null;let e=await t.dimensions;if(t!==Ne()||!e)return null;let o=ft(e);te(R,o);let n=document.querySelector("#output-size-hint");return n&&(n.textContent="\u51FA\u529B\u30B5\u30A4\u30BA\uFF1A"+o.width+" \xD7 "+o.height+" px\uFF08\u7D20\u6750\u306E\u7E26\u6A2A\u6BD4\u306B\u5408\u308F\u305B\u3001\u5BFE\u5FDC\u3059\u308B\u30B5\u30A4\u30BA\u5358\u4F4D\u306B\u8ABF\u6574\uFF09"),o}function Me(){let t=crypto.getRandomValues(new Uint32Array(2)),e=(t[0]&2097151)*4294967296+t[1];return e===me&&(e=(e+1)%Number.MAX_SAFE_INTEGER),me=e,e}async function ht(){let t=Array.from(P.values());if(t.length>20)throw new Error("\u5165\u529B\u7D20\u6750\u306F\u6700\u592720\u30D5\u30A1\u30A4\u30EB\u3067\u3059\u3002");if(t.some(e=>e.file.size>512*1024*1024))throw new Error("\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306F512 MiB\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002");if(t.reduce((e,o)=>e+o.file.size,0)>2*1024*1024*1024)throw new Error("\u5165\u529B\u7D20\u6750\u306E\u5408\u8A08\u306F2 GiB\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002");return t.map(e=>({name:e.name,mime_type:e.file.type||Mt(e.file.name),blob:e.file}))}function Mt(t){let e=t.split(".").pop()?.toLowerCase();return{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",wav:"audio/wav",mp3:"audio/mpeg",flac:"audio/flac",ogg:"audio/ogg"}[e||""]||"application/octet-stream"}async function gt(){const promptField=document.querySelector('#workflow-form textarea[name="prompt"]');if(!promptField||!promptField.value.trim()){if(promptField){promptField.required=true;promptField.setCustomValidity('プロンプトを入力してください。');promptField.addEventListener('input',()=>promptField.setCustomValidity(''),{once:true});promptField.reportValidity();promptField.focus();}throw new Error('プロンプトを入力してください。');}promptField.setCustomValidity('');let t=await Ee();if(!v("#app-form").reportValidity())throw new Error("\u5165\u529B\u5185\u5BB9\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002");let e=re(R);for(let d of _t(e)){let p=e[d],r=Oe(p);if(r&&!P.has(de(p)+":"+p.inputs[r])){T.id==="video-fusion"&&N.id==="ultra"&&Ue(e,d),T.id==="image-studio"&&Xe(e);for(let f of Object.values(e))f.class_type==="TextEncodeQwenImageEditPlus"&&Array.isArray(f.inputs.image2)&&String(f.inputs.image2[0])===d&&delete f.inputs.image2}}(["image-edit-super","image-studio"].includes(T.id)&&N.id==="reference"||T.id==="video-fusion"&&N.id==="ultra")&&Te(e,Ie);let o=new Set;for(let d of Object.values(e)){let p=Oe(d);de(d)&&p&&!mt(d.inputs[p])&&o.add(de(d)+":"+d.inputs[p])}for(let d of o)if(!P.has(d))throw new Error("\u5165\u529B\u7D20\u6750\u304C\u672A\u9078\u629E\u3067\u3059: "+d.split(":").slice(1).join(":"));for(let d of P.values())for(let[p,r]of d.refs)e[p]&&(e[p].inputs[r]=d.name);let n=T.id==="image-canvas"&&!Y.randomSeed?Y.seed:Me();me=n;for(let[d,p]of Object.entries(e))for(let r of Object.keys(p.inputs))if(/^(seed|noise_seed)$/i.test(r)&&typeof p.inputs[r]=="number"){p.inputs[r]=n,R[d].inputs[r]=n;let f=document.querySelector(`[data-node="${CSS.escape(d)}"][data-input="${r}"]`);f&&(f.value=String(n))}let i=t||Le();T.id==="video-fusion"&&N.id==="ultra"||te(e,i);let a=Ne();a?.kind==="image"&&!(T.id==="video-fusion"&&N.id==="ultra")&&et(e,a.refs,i),T.id==="video-flow"&&qe(e,dt),T.id==="video-fusion"&&Re(e,ut),T.id==="video-karma"&&Ye(e,rt),Te(e,Ie);let s=await ht();W("\u751F\u6210\u7528\u306E\u5165\u529B\u3092\u30B5\u30A4\u30C8\u3078\u6E21\u3057\u307E\u3057\u305F\u3002");let l;if(N?.continuation){let d=P.get("continuation-source");if(!d)throw new Error("\u5EF6\u9577\u3059\u308B\u5143\u52D5\u753B\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002");l={...re(N.continuation),source_video_name:d.name};let p=e[20]?.inputs,r=e[24]?.inputs;p&&(l.width=p.width,l.height=p.height),r&&(l.fps=r.frame_rate)}return{workflow:e,files:s,...l?{continuation:l}:{}}}function kt(){let t=v("#quick-controls");t.replaceChildren();let e=N?.angleControls;if(T.id==="video-fusion"&&N.id==="ultra"){t.append(We(R));return}if(le(T.id,N.id)===768){let o=oe("\u52D5\u753B\u306E\u89E3\u50CF\u5EA6",String(_e),()=>{},{choices:["768","1024"],help:"\u6700\u59271024\u306F\u751F\u6210\u6642\u9593\u304C\u5897\u3048\u307E\u3059\u3002"}),n=o.field;n.name="video_max_edge";for(let i of Array.from(n.options))i.textContent="\u6700\u5927"+i.value+" px";n.onchange=()=>{_e=n.value==="1024"?1024:768,Ee().then(i=>{if(!i){let a=Le();te(R,a);let s=document.querySelector("#output-size-hint");s&&(s.textContent="\u51FA\u529B\u30B5\u30A4\u30BA\uFF1A"+a.width+" \xD7 "+a.height+" px")}}).catch(i=>W(i.message,!0))},t.append(o.wrapper)}if(e){let o=document.createElement("div");o.className="panel";let n={};for(let[i,a]of[["azimuth","\u5DE6\u53F3\u306E\u30A2\u30F3\u30B0\u30EB"],["elevation","\u30AB\u30E1\u30E9\u306E\u9AD8\u3055"],["distance","\u30AB\u30E1\u30E9\u306E\u8DDD\u96E2"]]){let s=e[i]||[];n[i]=s.find(p=>String(R[e.node]?.inputs[e.key]||"").includes(p.prompt))?.prompt||s[0]?.prompt||"";let l=document.createElement("label");l.className="field",l.append(w("span",a));let d=document.createElement("select");d.name=i;for(let p of s){let r=document.createElement("option");r.value=p.prompt,r.textContent=p.label,d.append(r)}d.value=n[i],d.onchange=()=>{n[i]=d.value;let p=e.prefix+" "+Object.values(n).join(e.prefix.startsWith("crossview")?", ":" ");R[e.node].inputs[e.key]=p;let r=document.querySelector('[data-node="'+e.node+'"][data-input="'+e.key+'"]');r&&(r.value=p)},l.append(d),o.append(l)}t.append(o)}if(N?.continuation){let o=oe("\u7D50\u5408\u5F8C\u306E\u76EE\u6A19\u79D2\u6570",Number(N.continuation.target_duration_seconds)||10,i=>{N.continuation.target_duration_seconds=i},{min:1,max:120,step:.1}),n=document.createElement("div");n.className="panel",n.append(o.wrapper),t.append(n)}}function St(){let t=document.createElement("section");t.className="panel",t.id="dialogue-controls",t.append(w("h3","\u30BB\u30EA\u30D5\u3068\u58F0"));let e={text:"\u3053\u3093\u306B\u3061\u306F\u3002\u4ECA\u65E5\u306F\u3044\u3044\u5929\u6C17\u3067\u3059\u306D\u3002",caption:"A calm, natural Japanese voice.",num_steps:60,cfg_scale_text:3,cfg_scale_caption:3,cfg_scale_speaker:10,duration_scale:1,useCaptionWithReference:!1};for(let[o,n,i]of[["text","\u30BB\u30EA\u30D5",{rows:4}],["caption","\u58F0\u306E\u8AAC\u660E",{rows:3}],["duration_scale","\u767A\u8A71\u306E\u9577\u3055\u500D\u7387",{min:.5,max:2,step:.05}]]){let a=oe(n,e[o],s=>e[o]=s,i);a.field.setAttribute("name","dialogue_"+o),t.append(a.wrapper)}return v("#quick-controls").after(t),v("#upload-list").append(ce("\u58F0\u306E\u53C2\u8003\u97F3\u58F0\uFF08\u4EFB\u610F\uFF09","audio","dialogue-voice",[],!1,!0)),async()=>{if(!e.text.trim()||e.text.length>1e3)throw new Error("\u30BB\u30EA\u30D5\u306F1\u301C1000\u6587\u5B57\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002");let o=await gt(),n=Array.from(P.entries()).filter(([i])=>i.startsWith("dialogue-voice")).map(([,i])=>i);if(n.reduce((i,a)=>i+a.file.size,0)>20*1024*1024)throw new Error("\u53C2\u8003\u97F3\u58F0\u306F\u5408\u8A0820 MiB\u4EE5\u5185\u3067\u3059\u3002");return o.workflow[536]&&(o.workflow[536].inputs.text=String(o.workflow[536].inputs.text).replace(/^; she says: [^\n]*/,"; she says: "+String(e.text).trim().replace(/[\"']/g,"").replace(/\s+/g," ")+".")),{...o,task:"dialogue",irodori:{...e,caption:n.length&&!e.useCaptionWithReference?"":e.caption,cfg_scale_speaker:n.length?e.cfg_scale_speaker:0,seed:me,reference_audios:n.map(i=>i.name)}}}}function Ct(){let t=v("#workflow-form");t.replaceChildren();let e={text:"\u3053\u3093\u306B\u3061\u306F\u3002\u4ECA\u65E5\u3082\u826F\u3044\u4E00\u65E5\u3092\u3002",caption:"\u843D\u3061\u7740\u3044\u305F\u81EA\u7136\u306A\u58F0",num_steps:60,cfg_scale_text:3,cfg_scale_caption:3,cfg_scale_speaker:10,speed:1,seconds:0,useCaptionWithReference:!1};for(let[o,n,i]of[["text","\u8AAD\u307F\u4E0A\u3052\u308B\u6587\u7AE0",{rows:4}],["caption","\u58F0\u306E\u8AAC\u660E",{rows:3}],["speed","\u8A71\u3059\u901F\u5EA6",{min:.5,max:2,step:.05}],["seconds","\u9577\u3055\uFF080\u306F\u81EA\u52D5\uFF09",{min:0,max:45,step:.5}]]){let a=oe(n,e[o],s=>e[o]=s,i);a.field.setAttribute("name",o),t.append(a.wrapper)}return v("#upload-list").append(ce("\u53C2\u8003\u97F3\u58F0\uFF08\u4EFB\u610F\u30FB\u8907\u6570\u5BFE\u5FDC\uFF09","audio","voice",[],!1,!0)),async()=>{if(!String(e.text).trim()||String(e.text).length>1e3)throw new Error("\u8AAD\u307F\u4E0A\u3052\u308B\u6587\u7AE0\u306F1\u301C1000\u6587\u5B57\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002");let o=Array.from(P.values());if(o.length>20||o.reduce((i,a)=>i+a.file.size,0)>20*1024*1024)throw new Error("\u53C2\u8003\u97F3\u58F0\u306F\u6700\u592720\u4EF6\u3001\u5408\u8A0820 MiB\u4EE5\u5185\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002");let n=Me();return{task:"irodori",text:e.text,caption:o.length&&!e.useCaptionWithReference?"":e.caption,num_steps:e.num_steps,cfg_scale_text:e.cfg_scale_text,cfg_scale_caption:e.cfg_scale_caption,cfg_scale_speaker:o.length?e.cfg_scale_speaker:0,duration_scale:1/e.speed,...e.seconds>0?{seconds:e.seconds}:{},seed:n,reference_audios:o.map(i=>i.name),files:await ht()}}}function wt(){let t={system:"\u65E5\u672C\u8A9E\u3067\u308F\u304B\u308A\u3084\u3059\u304F\u5FDC\u7B54\u3057\u3066\u304F\u3060\u3055\u3044\u3002",message:"",max_tokens:1024,temperature:.8,top_p:.95,repetition_penalty:1.1},e=v("#workflow-form");e.replaceChildren();for(let[n,i,a]of[["message","\u30E1\u30C3\u30BB\u30FC\u30B8",{rows:4}]]){let s=oe(i,t[n],l=>t[n]=l,a);s.field.setAttribute("name",n),e.append(s.wrapper)}let o=w("button","\u4F1A\u8A71\u5C65\u6B74\u3092\u6D88\u53BB");return o.type="button",o.onclick=()=>{pe=[],v("#chat-history").replaceChildren()},e.append(o,w("div","","chat-history")),e.lastElementChild.id="chat-history",async()=>{if(!t.message.trim())throw new Error("\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002");ve=t.message.trim();let n=Me();return{task:"chat",messages:[{role:"system",content:t.system},...pe.slice(-8),{role:"user",content:ve}],max_tokens:t.max_tokens,temperature:t.temperature,top_p:t.top_p,repetition_penalty:t.repetition_penalty,seed:n,files:[]}}}function Ft(t){if(t.url){let e=new URL(t.url);if(e.protocol!=="https:")throw new Error("\u51FA\u529BURL\u304C\u4E0D\u6B63\u3067\u3059\u3002");return e.href}if(t.data&&/^(image|video|audio)\//.test(t.mime_type))return"data:"+t.mime_type+";base64,"+t.data;throw new Error("\u7D50\u679C\u306B\u30E1\u30C7\u30A3\u30A2URL\u304C\u3042\u308A\u307E\u305B\u3093\u3002")}function ue(t){v("#preview-loading").hidden=!t,v("#results").hidden=t,v(".output").setAttribute("aria-busy",String(t))}function Gt({output:t,error:e}){ue(!1);let o=v("#results");if(o.replaceChildren(),e){o.append(w("p",e,"error")),W(e,!0);return}if(t?.text&&(o.append(w("pre",String(t.text),"text-result")),T.task==="chat")){pe.push({role:"user",content:ve},{role:"assistant",content:String(t.text)});let i=v("#chat-history");i.replaceChildren();for(let a of pe.slice(-8))i.append(w("p",(a.role==="user"?"\u3042\u306A\u305F: ":"AI: ")+a.content))}let n=Array.isArray(t?.files)?t.files:Array.isArray(t?.images)?t.images:[];for(let i of n)try{let a=Ft(i),s=document.createElement("article");s.className="result-card",s.append(w("h3",i.filename||"\u751F\u6210\u7D50\u679C"));let l;i.mime_type?.startsWith("image/")?(l=document.createElement("img"),l.alt=i.filename):i.mime_type?.startsWith("video/")?(l=document.createElement("video"),l.controls=!0,l.playsInline=!0):i.mime_type?.startsWith("audio/")&&(l=document.createElement("audio"),l.controls=!0),l&&(l.src=a,s.append(l));let d=document.createElement("a");d.href=a,d.download=i.filename||"output",d.textContent="\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9",d.rel="noreferrer",s.append(d),i.size&&s.append(w("small",(i.size/1048576).toFixed(2)+" MiB")),o.append(s)}catch(a){o.append(w("p",a.message,"error"))}!n.length&&!t?.text&&o.append(w("p","\u751F\u6210\u304C\u5B8C\u4E86\u3057\u307E\u3057\u305F\u3002")),W("\u751F\u6210\u7D50\u679C\u3092\u53D7\u3051\u53D6\u308A\u307E\u3057\u305F\u3002")}v("#title").textContent=T.title;v("#description").textContent=T.description;document.title=T.title+" \xB7 GPU App";var be=v("#mode");for(let t of T.modes){let e=document.createElement("option");e.value=t.id,e.textContent=t.label,be.append(e)}be.onchange=()=>Et(be.value);v(".top-panel").hidden=T.modes.length<2;v("#app-form").onsubmit=t=>t.preventDefault();T.modes.length&&ct();var qt=T.task==="irodori"?Ct():T.task==="chat"?wt():T.task==="dialogue"?St():gt;if(window.appSdk){let t=window.appSdk,e=document.createElement("dialog");e.id="app-run-confirm",e.setAttribute("aria-labelledby","app-run-confirm-title"),e.setAttribute("aria-describedby","app-run-confirm-message"),e.append(w("h2","GPU\u3067\u5B9F\u884C\u3057\u307E\u3059\u304B\uFF1F")),e.firstElementChild.id="app-run-confirm-title";let o=w("p","\u5B9F\u884C\u4E2D\u306F\u753B\u9762\u9589\u3058\u305A\u306B\u304A\u5F85\u3061\u304F\u3060\u3055\u3044");o.id="app-run-confirm-message",e.append(o);let n=document.createElement("div");n.className="app-confirm-actions";let i=document.createElement("button");i.type="button",i.textContent="\u30AD\u30E3\u30F3\u30BB\u30EB",i.autofocus=!0,i.onclick=()=>e.close();let a=document.createElement("button");a.type="button",a.id="app-run-approve",a.textContent="\u5B9F\u884C\u3059\u308B",n.append(i,a),e.append(n),document.body.append(e);let s=document.createElement("style");s.textContent="#app-run-confirm{box-sizing:border-box;width:min(440px,calc(100% - 32px));padding:24px;border:1px solid #35455d;border-radius:16px;background:#141c29;color:#eef3ff}#app-run-confirm::backdrop{background:rgba(0,0,0,.65)}#app-run-confirm h2{font-size:20px;margin:0 0 16px}#app-run-confirm p{line-height:1.7}.app-confirm-actions{display:flex;justify-content:flex-end;gap:12px;margin-top:24px}.app-confirm-actions button{padding:12px 18px;border:1px solid #43526a;border-radius:10px;background:#263449;color:#fff;font-size:16px;cursor:pointer}#app-run-approve{background:#2865df}",document.head.append(s);let l,d=async()=>{try{if(!t.getTokenBalance)throw Error("SDK update required");let r=await t.getTokenBalance();v("#token-balance").textContent="保有: "+(r.balance+(Number(r.reservedTokens)||0))+" \u30C8\u30FC\u30AF\u30F3"+(r.reservedTokens?"\uFF08\u5B9F\u884C\u7528\u306B "+r.reservedTokens+" \u78BA\u4FDD\u4E2D\uFF09":"")}catch{v("#token-balance").textContent="\u30C8\u30FC\u30AF\u30F3\u6B8B\u9AD8\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093"}},p=(r,f=0)=>{clearTimeout(l),r.status==="settled"?(v("#token-usage").textContent="\u4ECA\u56DE\u306E\u6D88\u8CBB: "+r.consumedTokens+" \u30C8\u30FC\u30AF\u30F3",d()):(v("#token-usage").textContent="\u6D88\u8CBB\u30C8\u30FC\u30AF\u30F3\u3092\u7CBE\u7B97\u4E2D\u2026",t.getUsage&&f<20&&(l=setTimeout(()=>{t.getUsage(r.jobId).then(x=>p(x,f+1)).catch(()=>{v("#token-usage").textContent="\u7CBE\u7B97\u7D50\u679C\u3092\u78BA\u8A8D\u3067\u304D\u307E\u305B\u3093\u3002\u518D\u8868\u793A\u3057\u3066\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002"})},3e3)))};t.onUsage?.(r=>p(r)),d(),t.onGenerate(qt),t.onResult(Gt),t.onStatus(r=>{ue(["collecting","preparing_input","uploading","starting","queued","running"].includes(r.phase)),v("#app-execute").disabled=!r.canRun,a.disabled=!r.canRun,!r.canRun&&e.open&&e.close(),W(r.message,r.phase==="failed");let f=v("#transfer-progress");f.hidden=!r.progress,r.progress&&(f.max=r.progress.totalBytes||1,f.value=r.progress.bytes||0)}),v("#app-execute").onclick=()=>{e.open||e.showModal()},a.onclick=()=>{a.disabled||!e.open||(e.close(),ue(!0),v("#token-usage").textContent="",t.run().catch(r=>W(r.message,!0)).finally(()=>{ue(!1),d()}))}}else W("\u3053\u306Eindex.html\u306FGPU App\u304B\u3089\u958B\u304F\u3068\u5B9F\u884C\u3067\u304D\u307E\u3059\u3002");})();
;/* media selection removal */
(()=>{var c=new WeakMap;function u(e){if(c.has(e))return;let n=document.createElement("div");n.className="media-clear-actions",e.insertAdjacentElement("afterend",n);let t=()=>{n.replaceChildren();let r=Array.from(e.files||[]);n.hidden=r.length===0,r.forEach((s,b)=>{let d=document.createElement("div");d.className="media-clear-row";let l=document.createElement("span");l.textContent=s.name;let a=document.createElement("button");a.type="button",a.className="media-clear-button",a.textContent="\xD7",a.title="\u7D20\u6750\u3092\u89E3\u9664",a.setAttribute("aria-label",s.name+"\u3092\u89E3\u9664"),a.disabled=e.disabled,a.addEventListener("click",()=>{if(e.disabled)return;let m=Array.from(e.files||[]).filter((i,o)=>o!==b);if(m.length){let i=new DataTransfer;m.forEach(o=>i.items.add(o)),e.files=i.files}else e.value="";e.setCustomValidity(""),e.dispatchEvent(new Event("change",{bubbles:!0})),t(),(n.querySelector("button")||e).focus()}),d.append(l,a),n.append(d)})};c.set(e,t),e.addEventListener("change",()=>queueMicrotask(t)),t()}function f(){if(document.getElementById("media-clear-style"))return;let e=document.createElement("style");e.id="media-clear-style",e.textContent=".media-clear-actions{display:grid;gap:6px;min-width:0;margin-top:6px}.media-clear-actions[hidden]{display:none!important}.media-clear-row{display:flex;align-items:center;gap:8px;min-width:0}.media-clear-row>span{flex:1;min-width:0;overflow-wrap:anywhere;font-size:12px;color:var(--muted,#63776a)}button.media-clear-button{flex:none;width:36px;min-width:36px;height:36px;min-height:36px;margin:0;padding:0;display:inline-flex;align-items:center;justify-content:center;border:1px solid #bed0c4;border-radius:8px;background:#fff;color:#245b43;font:24px/1 system-ui;cursor:pointer}button.media-clear-button:hover{background:#edf4ef}button.media-clear-button:disabled{opacity:.45;cursor:default}",document.head.append(e);let n=t=>{(t instanceof Element||t instanceof Document)&&(t instanceof HTMLInputElement&&t.type==="file"&&u(t),t.querySelectorAll('input[type="file"]').forEach(u))};n(document),new MutationObserver(t=>{for(let r of t)r.type==="attributes"?c.get(r.target)?.():r.addedNodes.forEach(n)}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["disabled"]})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",f,{once:!0}):f();})();