live2dapi-noa 2.4.5 → 2.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -3
- package/autoload.js +1 -1
- package/css/left.css +20 -7
- package/css/left.min.css +1 -1
- package/css/right.css +16 -6
- package/css/right.min.css +1 -1
- package/docs/en/README.md +23 -3
- package/jsdelivr/random/autoload.js +1 -1
- package/jsdelivr/random/autoload.min.js +1 -1
- package/jsdelivr/random/waifu-tips.js +2 -2
- package/jsdelivr/sequential/autoload.js +1 -1
- package/jsdelivr/sequential/autoload.min.js +1 -1
- package/jsdelivr/sequential/waifu-tips.js +3 -3
- package/latest.mjs +37 -0
- package/modern/renderer.mjs +18 -18
- package/npm/random/autoload.js +1 -1
- package/npm/random/waifu-tips.js +2 -2
- package/npm/sequential/autoload.js +1 -1
- package/npm/sequential/waifu-tips.js +3 -3
- package/package.json +2 -1
- package/widget.mjs +1 -1
package/modern/renderer.mjs
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
var Hn=Object.defineProperty;var _e=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ke=(e,t)=>{for(var r in t)Hn(e,r,{get:t[r],enumerable:!0})};var m,Me=_e(()=>{m=class extends Error{code;details;constructor(e,t,r){super(t,r),this.name="Live2DError",this.code=e,this.details=r?.details?Object.freeze({...r.details}):void 0}}});function wt(e){if(e===void 0||e===!1)return;if(typeof e=="string"){if(e.trim()!=="")return;throw new m("invalid-props","idleMotion must be a non-empty motion group name, weighted options or false.")}if(typeof e!="object"||e===null||Array.isArray(e))throw new m("invalid-props","idleMotion weighted options must be an object.");if(typeof e.group!="string"||e.group.trim()==="")throw new m("invalid-props","idleMotion.group must be a non-empty string.");if(!Array.isArray(e.weights)||e.weights.length===0)throw new m("invalid-props","idleMotion.weights must be a non-empty array.");let t=!1;for(let r of e.weights){if(!Number.isFinite(r)||r<0)throw new m("invalid-props","Every idleMotion weight must be a finite, non-negative number.");t||=r>0}if(!t)throw new m("invalid-props","At least one idleMotion weight must be greater than 0.")}function Lr(e,t){if(wt(e),e===!1)return!1;if(e===void 0)return{group:"Idle"};if(typeof e=="string"){if(t(e)<=0)throw new m("invalid-props",`Unknown idle motion group: ${e}.`);return{group:e}}let r=t(e.group);if(r<=0)throw new m("invalid-props",`Unknown weighted idle motion group: ${e.group}.`);if(e.weights.length!==r)throw new m("invalid-props",`idleMotion.weights has ${e.weights.length} entries but group ${e.group} has ${r} motions.`);return{group:e.group,weights:[...e.weights]}}function Tr(e,t,r=Math.random){if(!t)return Math.min(e-1,Math.floor(r()*e));let i=0;for(let a of t)i=Math.max(i,a);let s=t.reduce((a,l)=>a+l/i,0),n=Math.min(1-Number.EPSILON,Math.max(0,r()))*s;for(let a=0;a<t.length;a++)if(n-=t[a]/i,n<0)return a;return t.length-1}function Dr(e,t,r){if(r!==void 0){if(!Number.isFinite(r)||r<0)throw new m("invalid-props",`${e} ${t} must be a finite, non-negative number of milliseconds.`);return r/1e3}}function Fr(e,t){if(t!==void 0&&(typeof t!="object"||t===null))throw new m("invalid-props",`${e} options must be an object.`);return{fadeInSeconds:Dr(e,"fadeInMs",t?.fadeInMs),fadeOutSeconds:Dr(e,"fadeOutMs",t?.fadeOutMs)}}function $e(e){return Fr("Motion",e)}function Or(e){return Fr("Expression",e)}function et(e){return e.fadeInSeconds!==void 0||e.fadeOutSeconds!==void 0}function Ue(e){if(e!==void 0){if(typeof e!="object"||e===null)throw new m("invalid-props","Motion options must be an object.");if(e.priority!==void 0&&e.priority!=="force"&&e.priority!=="idle"&&e.priority!=="normal")throw new m("invalid-props","Motion priority must be 'force', 'idle' or 'normal'.");$e(e)}}var xt=_e(()=>{Me()});var Qr={};Ke(Qr,{WLipSyncAudioNode:()=>vt,createWLipSyncNode:()=>zn,parseBinaryProfile:()=>Yn});function Vr(e,t,r,i,s){let n=2/i,a=n*s,l=1/(1+a+.48*a*a+.235*a*a*a),o=e-t,u=(r+n*o)*s;return Et.value=t+(o+u)*l,Et.velocity=(r-n*u)*l,Et}function Yn(e){let t=new DataView(e),r=0,i=()=>t.getUint8(r++),s=()=>{let u=t.getInt32(r);return r+=4,u},n=()=>String.fromCharCode(t.getUint8(r++)),a=()=>{let u=i(),h=Wn.decode(e.slice(r,r+u));return r+=u,h},l=u=>[...new Array(u)].map(h=>(()=>{let d=t.getFloat32(r);return r+=4,d})());if(n()!=="W"||n()!=="L"||n()!=="I"||n()!=="P")throw new Error("Invalid file signature for binary wLipSync profile");let o={targetSampleRate:s(),sampleCount:s(),melFilterBankChannels:i(),compareMethod:i(),mfccNum:12,mfccs:[...new Array(i())],mfccDataCount:i(),useStandardization:i()===1};for(let u=0;u<o.mfccs.length;u++)o.mfccs[u]={name:"",mfccCalibrationDataList:[],values:l(12)};o.means=l(12),o.stdDevs=l(12);for(let u=0;u<o.mfccs.length;u++)o.mfccs[u].name=a();return o}async function zn(e,t){try{return new vt(e,t)}catch{return await e.audioWorklet.addModule(new URL("data:text/javascript;base64,dmFyIEI9bmV3IFdlYkFzc2VtYmx5Lk1lbW9yeSh7aW5pdGlhbDo0fSksWD17ZW52OnttZW1vcnk6Qn19O2NsYXNzIFUgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3J7aW5wdXRCdWZmZXJJbmRleD0tMTtpbnB1dEJ1ZmZlclB0cj0tMTtpbnB1dEJ1ZmZlclNpemU9LTE7aW5wdXRCdWZmZXI9bnVsbDtsYXN0SW5kZXg9MDt2b2x1bWVQdHI9LTE7dm9sdW1lVmlldz1udWxsO21mY2NzPVtdO2V4cG9ydHM9bnVsbDtjb25zdHJ1Y3RvcihKKXtzdXBlcigpO2xldHt3YXNtTW9kdWxlOlMscHJvZmlsZTprfT1KLnByb2Nlc3Nvck9wdGlvbnM7V2ViQXNzZW1ibHkuaW5zdGFudGlhdGUoUyxYKS50aGVuKChHKT0+e2xldCB6PXRoaXMuZX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MCwhMCk7dGhpcy5wb3J0LnBvc3RNZXNzYWdlKHt0aW1lc3RhbXA6Y3VycmVudFRpbWUsaW5kZXg6eixuYW1lOnRoaXMubWZjY3Nbel0ubmFtZSx2b2x1bWU6RX0pLHRoaXMubGFzdEluZGV4PXRoaXMuaW5wdXRCdWZmZXJJbmRleH1yZXR1cm4hMH19cmVnaXN0ZXJQcm9jZXNzb3IoIndsaXBzeW5jLXByb2Nlc3NvciIsVSk7Cg==",""+import.meta.url)),new vt(e,t)}}var Et,kr,vt,Wn,Ur=_e(async()=>{Et={value:0,velocity:0};kr={wasmModule:void 0},vt=class extends AudioWorkletNode{openCloseVelocity=0;lastTimestamp=0;weightVelocities={};minVolume=-2.5;maxVolume=-1.5;smoothness=.05;volume=0;weights={};constructor(e,t,r=kr.wasmModule){super(e,"wlipsync-processor",{processorOptions:{wasmModule:r,profile:t}});for(let i of t.mfccs)this.weights[i.name]=0,this.weightVelocities[i.name]=0;this.port.onmessage=this.onMessage.bind(this)}onMessage(e){let t=e.data.timestamp-this.lastTimestamp;this.lastTimestamp=e.data.timestamp;let r=Number.isNaN(e.data.volume)?0:e.data.volume,i=Math.log10(r);i=(i-this.minVolume)/(this.maxVolume-this.minVolume),i=Math.max(Math.min(i,1),0);let s=Vr(this.volume,i,this.openCloseVelocity,this.smoothness,t);this.volume=s.value,this.openCloseVelocity=s.velocity;for(let n in this.weights){let a=n===e.data.name?1:0,l=Vr(this.weights[n],a,this.weightVelocities[n],this.smoothness,t);this.weights[n]=l.value,this.weightVelocities[n]=l.velocity}}get blockSize(){return this.parameters.get("blockSize").value}set blockSize(e){this.parameters.get("blockSize").setValueAtTime(e,this.context.currentTime)}},Wn=new TextDecoder;kr.wasmModule=await WebAssembly.compileStreaming(fetch("data:application/wasm;base64,AGFzbQEAAAABbRBgAAF/YAAAYAJ/fwBgBn9/f39/fwBgA39/fwBgAn9/AX1gA39/fQBgB39/f39/f38Bf2ABfwBgAX8Bf2AFf39/f38AYAR/f39/AGAFf39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HQ9D1rT6UQxgFKT+SIAeUQwAAgD+SIAhBF3S+lCEHIAb8ASIIRQ0AQwAAIEEhBgNAIAcgBkMAAIA/IAhBAXEblCEHIAYgBpQhBiAIQQF2IggNAAsLIAIgBzgCACAJQQFqIgkgBUcNAAsLC6sCAgR/An0CQCABRQ0AIAFBA3EhAwJAAkAgAUEESQRADAELIAFBfHEhBSAAIQIDQCACQQxqKgIAIAJBCGoqAgAgAkEEaioCACACKgIAIAaSkpKSIQYgAkEQaiECIAUgBEEEaiIERw0ACyADRQ0BCyAAIARBAnRqIQIDQCACKgIAIAaSIQYgAkEEaiECIANBAWsiAw0ACwsgBkMAAAAAX0UEQEEAIQMgAUEBRwRAIAFBAXFDAACAPyAGlSEHIAFBfnEhASAAIQIDQCACIAIqAgAgB5Q4AgAgAkEEaiIFIAUqAgAgB5Q4AgAgAkEIaiECIAEgA0ECaiIDRw0AC0UNAgsgACADQQJ0aiIAIAAqAgAgBpU4AgAMAQsgAUECdCIBRQ0AIABBACAB/AsACwsLGAEAQYCABAsQEAABABAYAQBAGAEAgLsAAAAmCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQVjbGFuZwYyMi4xLjgAlAEPdGFyZ2V0X2ZlYXR1cmVzCCsPbXV0YWJsZS1nbG9iYWxzKxNub250cmFwcGluZy1mcHRvaW50KwtidWxrLW1lbW9yeSsIc2lnbi1leHQrD3JlZmVyZW5jZS10eXBlcysKbXVsdGl2YWx1ZSsPYnVsay1tZW1vcnktb3B0KxZjYWxsLWluZGlyZWN0LW92ZXJsb25n"))});function q(e,t,r,i){if(!e)return i();let s=performance.now();try{return i()}finally{let n=performance.now()-s;t==="frame"?e.framePhase(r,n):e.loadPhase(r,n)}}async function Ce(e,t,r){if(!e)return r();let i=performance.now();try{return await r()}finally{e.loadPhase(t,performance.now()-i)}}function Jn(e,t){if(!t)return;let r=e.getExtension("EXT_disjoint_timer_query_webgl2");if(t.gpuTimerSupport(!!r),!r){t.gpuDraw(null);return}let i,s=[],n=()=>{for(;s.length>0;){let a=s[0];if(!e.getQueryParameter(a,e.QUERY_RESULT_AVAILABLE))return;s.shift();let l=e.getParameter(r.GPU_DISJOINT_EXT)?void 0:Number(e.getQueryParameter(a,e.QUERY_RESULT));t.gpuDraw(l===void 0||!Number.isFinite(l)?null:l/1e6),e.deleteQuery(a)}};return{begin(){if(n(),i)return;let a=e.createQuery();a&&(e.beginQuery(r.TIME_ELAPSED_EXT,a),i=a)},dispose(){i&&(e.endQuery(r.TIME_ELAPSED_EXT),e.deleteQuery(i),i=void 0);for(let a of s)e.deleteQuery(a);s.length=0},end(){i&&(e.endQuery(r.TIME_ELAPSED_EXT),s.push(i),i=void 0)},poll:n}}function Gr(e){return e.split("/").map(t=>t==="."||t===".."?t:encodeURIComponent(t)).join("/")}function Xr(e){return new URL(Gr(e.replace(/^\/+/,"")),Rt).href}function Dt(e){let t=new URL(e);if(t.origin===new URL(Rt).origin)return t.pathname.slice(1).split("/").map(r=>decodeURIComponent(r)).join("/")}function te(e,t){return t.startsWith(Rt)?/^[a-z][a-z\d+.-]*:/i.test(e)||e.startsWith("//")?new URL(e,t).href:new URL(Gr(e),t).href:new URL(e,t).href}function Hr(e){let t=typeof window>"u"?void 0:window.location.href,r=e instanceof URL?new URL(e.href):t?new URL(e,t):new URL(e);return r.pathname.endsWith("/")||(r.pathname+="/"),r.href}function ue(e,t,r){return{assetType:e,backend:"cubism-webgl",httpStatus:r,url:Dt(t)??t}}async function jn(e,t,r,i,s){let n;try{n=await e(t,s)}catch(a){throw s?.aborted?s.reason:new m("model-load-failed",`resolveAsset threw while loading ${t}.`,{cause:a,details:ue(i,r)})}if(s?.aborted)throw s.reason;if(n===void 0)throw new m("model-load-failed",`resolveAsset did not provide ${t}. The model declares it, so the source is missing this file or names it differently.`,{details:{...ue(i,r),httpStatus:404}});return n instanceof Blob?n:new Blob([n])}async function qn(e,t,r){let i;try{i=await fetch(e,{signal:r})}catch(s){throw r?.aborted?r.reason:new m("model-load-failed",`Failed to load ${e}.`,{cause:s,details:ue(t,e)})}if(!i.ok)throw new m("model-load-failed",`Failed to load ${e}: HTTP ${i.status}`,{details:ue(t,e,i.status)});return i}async function Wr(e,t,r,i){let s=i?Dt(e):void 0;return i&&s!==void 0?jn(i,s,e,t,r):(await qn(e,t,r)).blob()}async function he(e,t,r,i){let s=await(await Wr(e,t,r,i)).arrayBuffer();if(s.byteLength===0)throw new m("model-load-failed",`Loaded an empty asset from ${Dt(e)??e}.`,{details:ue(t,e)});return s}async function Zn(e,t,r){if(r?.aborted)throw r.reason;if(typeof createImageBitmap=="function")try{return await createImageBitmap(e,{premultiplyAlpha:"premultiply"})}catch(s){throw r?.aborted?r.reason:new m("model-load-failed",`Failed to decode model texture ${t}.`,{cause:s,details:ue("texture",t)})}let i=URL.createObjectURL(e);try{return await new Promise((s,n)=>{let a=new Image,l=()=>n(r?.reason);r?.addEventListener("abort",l,{once:!0}),a.onload=()=>{r?.removeEventListener("abort",l),s(a)},a.onerror=()=>{r?.removeEventListener("abort",l),n(new m("model-load-failed",`Failed to decode model texture ${t}.`,{details:ue("texture",t)}))},a.src=i})}finally{URL.revokeObjectURL(i)}}function Ne(e){"close"in e&&typeof e.close=="function"&&e.close()}async function Yr(e,t,r,i){let s=await Ce(r,"textureFetch",()=>Wr(e,"texture",t,i));return Ce(r,"textureDecode",()=>Zn(s,e,t))}function zr(e,t,r,i){let s=e.createTexture();if(!s)throw Ne(t),new m("render-error",`WebGL failed to create a texture for ${r}.`,{details:ue("texture",r)});let n=e.getParameter(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL);try{return q(i,"load","textureUpload",()=>{e.bindTexture(e.TEXTURE_2D,s),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)}),s}catch(a){throw e.deleteTexture(s),a instanceof m?a:new m("render-error",`Failed to upload model texture ${r} to WebGL.`,{cause:a,details:ue("texture",r)})}finally{e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n),Ne(t)}}function Nr(e,t){for(let r of["aria-describedby","aria-hidden","aria-label","role"])e.removeAttribute(r);if(e.textContent="",!!t){if(t.mode==="decorative"){e.setAttribute("aria-hidden","true"),e.setAttribute("role","presentation");return}e.setAttribute("aria-label",t.label),e.setAttribute("role","img"),t.describedBy&&e.setAttribute("aria-describedby",t.describedBy),e.textContent=t.fallbackText??t.label}}function tt(e){let t=!0;return()=>{t&&(t=!1,e())}}function Kn(e){return e instanceof m?e:new m("render-error",e instanceof Error?e.message:String(e),{cause:e,details:{backend:"cubism-webgl"}})}function we(e){let t=Pt.get(e);if(!t||t.disposed)throw new m("adapter-error","The StageHandle was not created by the active cubism-webgl adapter.",{details:{backend:"cubism-webgl"}});return t}function Jr(e,t,r){if(typeof window>"u")throw new m("browser-only","cubism-webgl can only run in a browser.");let i=document.createElement("canvas");Nr(i,t.accessibility);let s=i.getContext("webgl2",{alpha:!0,antialias:!0,depth:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,stencil:!1});if(!s)throw new m("webgl-unsupported","WebGL2 is required by cubism-webgl.",{details:{backend:"cubism-webgl"}});r?.changeResource("canvas",1),r?.changeResource("context",1);let n=Jn(s,r),a={height:Math.max(1,t.height),width:Math.max(1,t.width)},l=t.resolution??1,o=!1,u=!0,h=!1,d=0,c=0,g=!1,f,p,A=new Set,_=new Set,y=new Set,C=t.maxFps?1e3/t.maxFps:0,B=()=>{i.width=Math.max(1,Math.round(a.width*l)),i.height=Math.max(1,Math.round(a.height*l)),s.viewport(0,0,i.width,i.height);for(let v of A)v.resize(i.width,i.height)},x=()=>{u=!1,cancelAnimationFrame(d),d=0,c=0,f=void 0,p=void 0},b=v=>{if(!(o||h)){h=!0,x();for(let J of y)J(v)}},M=v=>{let J=Math.min(v,100);for(let W of A)W.update(J)},L=()=>{s.bindFramebuffer(s.FRAMEBUFFER,null),s.viewport(0,0,i.width,i.height),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT)},k=()=>{for(let v of A)v.draw()},H=v=>{if(!u||o)return;d=requestAnimationFrame(H);let J=p===void 0?0:v-p;if(p=v,c+=J,f!==void 0&&c<C-.25)return;let W=f===void 0?0:v-f;f=v,c=C?c>=C*2?0:Math.max(0,c-C):0;try{if(r)r.framePhase("frameDelta",W),q(r,"frame","stageFrame",()=>{M(W);for(let le of _)le(W);L(),n?.begin();try{q(r,"frame","drawCpu",k)}finally{n?.end()}});else{M(W);for(let le of _)le(W);L(),k()}A.size>0&&!g&&(g=!0,r?.firstDraw())}catch(le){b(Kn(le))}},ae=v=>{v.preventDefault(),b(new m("render-error","The WebGL context was lost. Call retry() to recreate the Live2D canvas.",{details:{backend:"cubism-webgl"}}))};i.style.display="block",i.style.height="100%",i.style.touchAction="none",i.style.width="100%",i.addEventListener("webglcontextlost",ae),e.appendChild(i),B();let oe,z={attachDriver(v){return A.add(v),v.resize(i.width,i.height),tt(()=>{A.delete(v)})},canvas:i,diagnostics:r,disposed:o,gl:s,reportError:b};return oe={dispose:tt(()=>{o=!0,z.disposed=!0,x(),A.clear(),_.clear(),y.clear(),i.removeEventListener("webglcontextlost",ae),n?.poll(),n?.dispose(),s.isContextLost()||s.getExtension("WEBGL_lose_context")?.loseContext(),i.width=1,i.height=1,i.remove(),r?.changeResource("context",-1),r?.changeResource("canvas",-1),Pt.delete(oe)}),getResolution:()=>l,getSize:()=>({...a}),onError(v){return y.add(v),tt(()=>y.delete(v))},onFrame(v){return _.add(v),tt(()=>_.delete(v))},pause:x,resize(v,J){a={height:Math.max(1,J),width:Math.max(1,v)},B()},resume(){o||h||u||(u=!0,d=requestAnimationFrame(H))},setAccessibility(v){Nr(i,v)},setResolution(v){if(!Number.isFinite(v)||v<1)throw new m("invalid-props","Stage resolution must be a finite number greater than or equal to 1.");l=v,B()},toWorld(v,J){let W=i.getBoundingClientRect();return{x:v-W.left,y:J-W.top}}},Pt.set(oe,z),d=requestAnimationFrame(H),oe}var Rt,Pt,Lt=_e(()=>{Me();Rt="https://live2d-web.invalid/";Pt=new WeakMap});var An={};Ke(An,{loadFrameworkModel:()=>ml});function la(e,t){let r=0;for(let s=1;;s++){let n=e.slice(s-1,s);if(n=="e"||n=="-"||n=="E")continue;let a=e.substring(0,s),l=Number(a);if(isNaN(l))break;r=s}let i=parseFloat(e);return isNaN(i)&&(i=NaN),t[0]=e.slice(r),i}function Le(e){e&&(e=void 0)}function U(e,t,r=null,i=null){if(e.length<t)if(i)for(let s=e.length;s<t;s++)typeof r=="function"?e[s]=JSON.parse(JSON.stringify(new r)):e[s]=r;else for(let s=e.length;s<t;s++)e[s]=r;else e.length=t}function Y(e,t,r){let i=new ze;return i.time=e.time+(t.time-e.time)*r,i.value=e.value+(t.value-e.value)*r,i}function Os(e,t){let r=(t-e[0].time)/(e[1].time-e[0].time);return r<0&&(r=0),e[0].value+(e[1].value-e[0].value)*r}function Ha(e,t){let r=(t-e[0].time)/(e[3].time-e[0].time);r<0&&(r=0);let i=Y(e[0],e[1],r),s=Y(e[1],e[2],r),n=Y(e[2],e[3],r);return Y(Y(i,s,r),Y(s,n,r),r).value}function Wa(e,t){let r=t,i=e[0].time,s=e[3].time,n=e[1].time,a=e[2].time,l=s-3*a+3*n-i,o=3*a-6*n+3*i,u=3*n-3*i,h=i-r,d=w.cardanoAlgorithmForBezier(l,o,u,h),c=Y(e[0],e[1],d),g=Y(e[1],e[2],d),f=Y(e[2],e[3],d);return Y(Y(c,g,d),Y(g,f,d),d).value}function Vs(e,t){return e[0].value}function ks(e,t){return e[1].value}function Vt(e,t,r,i,s){let n=e.curves[t],a=-1,l=n.baseSegmentIndex+n.segmentCount,o=0;for(let h=n.baseSegmentIndex;h<l;++h)if(o=e.segments[h].basePointIndex+(e.segments[h].segmentType==1?3:1),e.points[o].time>r){a=h;break}if(a==-1)return i&&r<s?Ya(e,l-1,e.segments[n.baseSegmentIndex].basePointIndex,o,r,s):e.points[o].value;let u=e.segments[a];return u.evaluate(e.points.slice(u.basePointIndex),r)}function Ya(e,t,r,i,s,n){let a=[new ze,new ze];{let l=e.points[i];a[0].time=l.time,a[0].value=l.value}{let l=e.points[r];a[1].time=n,a[1].value=l.value}switch(e.segments[t].segmentType){case 0:case 1:default:return Os(a,s);case 2:return Vs(a,s);case 3:return ks(a,s)}}function co(e){let t=0;return e>0?t=1:e<0&&(t=-1),t}function go(e,t,r,i,s,n,a,l,o,u){e.x+=hr(r,i,s,n,a.minimum,a.maximum,a.defalut,o)*u}function fo(e,t,r,i,s,n,a,l,o,u){e.y+=hr(r,i,s,n,a.minimum,a.maximum,a.defalut,o)*u}function Ao(e,t,r,i,s,n,a,l,o,u){t.angle+=hr(r,i,s,n,l.minimum,l.maximum,l.defalut,o)*u}function po(e,t,r,i,s){let n=e.x;return i&&(n*=-1),n}function mo(e,t,r,i,s){let n=e.y;return i&&(n*=-1),n}function _o(e,t,r,i,s){let n;return r>=2?s=t[r-1].position.substract(t[r-2].position):s=s.multiplyByScaler(-1),n=w.directionToRadian(s,e),i&&(n*=-1),n}function Co(e,t){let r=w.max(e,t),i=w.min(e,t);return w.abs(r-i)}function yo(e,t){return w.min(e,t)+Co(e,t)/2}function bo(e,t){return JSON.parse(JSON.stringify(e.x))}function Bo(e,t){return JSON.parse(JSON.stringify(e.y))}function Io(e,t){return JSON.parse(JSON.stringify(t))}function So(e,t,r,i,s,n,a,l){let o,u,h=new E(0,0),d=new E(0,0),c=new E(0,0),g=new E(0,0);e[0].position=new E(r.x,r.y);let f=w.degreesToRadian(i),p=w.radianToDirection(f);p.normalize();for(let A=1;A<t;++A)e[A].force=p.multiplyByScaler(e[A].acceleration).add(s),e[A].lastPosition=new E(e[A].position.x,e[A].position.y),o=e[A].delay*a*30,h=e[A].position.substract(e[A-1].position),u=w.directionToRadian(e[A].lastGravity,p)/l,h.x=w.cos(u)*h.x-h.y*w.sin(u),h.y=w.sin(u)*h.x+h.y*w.cos(u),e[A].position=e[A-1].position.add(h),d=e[A].velocity.multiplyByScaler(o),c=e[A].force.multiplyByScaler(o).multiplyByScaler(o),e[A].position=e[A].position.add(d).add(c),g=e[A].position.substract(e[A-1].position),g.normalize(),e[A].position=e[A-1].position.add(g.multiplyByScaler(e[A].radius)),w.abs(e[A].position.x)<n&&(e[A].position.x=0),o!=0&&(e[A].velocity=e[A].position.substract(e[A].lastPosition),e[A].velocity=e[A].velocity.divisionByScalar(o),e[A].velocity=e[A].velocity.multiplyByScaler(e[A].mobility)),e[A].force=new E(0,0),e[A].lastGravity=new E(p.x,p.y)}function Mo(e,t,r,i,s,n){let a=new E(0,0);e[0].position=new E(r.x,r.y);let l=w.degreesToRadian(i),o=w.radianToDirection(l);o.normalize();for(let u=1;u<t;++u)e[u].force=o.multiplyByScaler(e[u].acceleration).add(s),e[u].lastPosition=new E(e[u].position.x,e[u].position.y),e[u].velocity=new E(0,0),a=e[u].force,a.normalize(),a=a.multiplyByScaler(e[u].radius),e[u].position=e[u-1].position.add(a),w.abs(e[u].position.x)<n&&(e[u].position.x=0),e[u].force=new E(0,0),e[u].lastGravity=new E(o.x,o.y)}function Nt(e,t,r,i,s,n){let a;a=s*n.getScale(n.translationScale,n.angleScale),a<r?(a<n.valueBelowMinimum&&(n.valueBelowMinimum=a),a=r):a>i&&(a>n.valueExceededMaximum&&(n.valueExceededMaximum=a),a=i);let l=n.weight/Kt;l>=1||(a=e[t]*(1-l)+a*l),e[t]=a}function hr(e,t,r,i,s,n,a,l){let o=0,u=w.max(r,t);u<e&&(e=u);let h=w.min(r,t);h>e&&(e=h);let d=w.min(s,n),c=w.max(s,n),g=a,f=yo(h,u),p=e-f;switch(co(p)){case 1:{let A=c-g,_=u-f;_!=0&&(o=p*(A/_),o+=g);break}case-1:{let A=d-g,_=h-f;_!=0&&(o=p*(A/_),o+=g);break}case 0:o=g;break;default:break}return l?o:o*-1}function rl(e){let t=(e instanceof Error?e.message:String(e)).match(/Failed to load shader (.+?)(?:: HTTP (\d+)|: empty source)$/);return{assetType:"shader",backend:"cubism-webgl",httpStatus:t?.[2]?Number(t[2]):void 0,url:t?.[1]}}function il(e){let t=!0;return()=>{t&&(t=!1,e())}}function sl(e){if(lt===0){let t=globalThis.Live2DCubismCore;if(!t||typeof t.MocVersion_53!="number"||typeof t.ColorBlendType_Normal!="number")throw new m("core-missing","cubism-webgl requires Live2D Cubism Core 5.3.",{details:{assetType:"core",backend:"cubism-webgl"}});if(!P.startUp())throw new m("adapter-error","CubismFramework.startUp() failed.",{details:{backend:"cubism-webgl"}});P.initialize()}return lt++,e?.changeResource("frameworkReference",1),il(()=>{lt--,e?.changeResource("frameworkReference",-1),lt===0&&P.isInitialized()&&P.dispose()})}function nl(e,t){let r=t.transformX(-e.width/2),i=t.transformX(e.width/2),s=t.transformY(-e.height/2),n=t.transformY(e.height/2);return{centerX:(r+i)/2,centerY:(s+n)/2,height:Math.abs(n-s),width:Math.abs(i-r)}}function fs(e,t,r,i){let s=new ne,n=2*t.scale/Math.max(1,e.width),a=2*t.scale/Math.max(1,e.height),l=2*t.x/Math.max(1,e.width)-1,o=1-2*t.y/Math.max(1,e.height);return s.scale(n,a),s.translate(l-i.centerX*n,o-i.centerY*a),s.multiplyByMatrix(r),s}async function al(e,t){return e.buffer||(e.loading??=t().finally(()=>{e.loading=void 0}),e.buffer=await e.loading),e.buffer}function ol(e,t){return t.fadeInSeconds!==void 0&&e.setFadeInTime(t.fadeInSeconds),t.fadeOutSeconds!==void 0&&e.setFadeOutTime(t.fadeOutSeconds),e}function As(e,t,r,i){if(!et(t))return{autoDelete:!1,motion:e.motion,releaseBeforeStart(){},transferToQueue(){}};if(!e.buffer)throw new Error("A fade override needs the motion buffer loaded before playback.");let s=ol(r(e.buffer),t),n=!0;return{autoDelete:!0,motion:s,releaseBeforeStart(){n&&(n=!1,i(s))},transferToQueue(){n=!1}}}function ul(e){let t=!0;return()=>{t&&(t=!1,e())}}function hl(e){return We.set(e,(We.get(e)??0)+1),ul(()=>{let t=(We.get(e)??1)-1;if(t>0){We.set(e,t);return}We.delete(e),cr.getInstance().removeContext(e),K.getInstance().releaseContext(e)})}function ms(e){let t=!0;return()=>{t&&(t=!1,e())}}function fn(e,t){return e instanceof m?e:new m("model-load-failed",e instanceof Error?`${t}: ${e.message}`:t,{cause:e})}function se(e,t){return{assetType:e,backend:"cubism-webgl",url:t}}async function ml(e,t,r,i,s={}){let n=we(e).diagnostics,a=sl(n),l=n?performance.now():0,o;try{let u=s.resolveAsset?Xr(t):new URL(t,window.location.href).href,h=await Ce(n,"modelJsonFetch",()=>he(u,"model3",s.signal,s.resolveAsset)),d,c;try{let f=JSON.parse(new TextDecoder().decode(h));c=typeof f.Version=="number"&&Number.isFinite(f.Version)?f.Version:void 0,d=q(n,"load","modelJsonParse",()=>new Bs(h,h.byteLength))}catch(f){throw new m("model-load-failed",`Failed to parse model3.json ${u}.`,{cause:f,details:se("model3",u)})}let g=Lr(s.idleMotion,f=>d.getMotionCount(f));return o=new pl(e,u,d,r,i,g,a,c,n,s.resolveAsset),await o.initialize(s.signal),n&&n.loadPhase("ready",performance.now()-l),o.toHandle()}catch(u){throw o?o.toHandle().dispose():a(),s.signal?.aborted?s.signal.reason:fn(u,`Failed to load ${t}`)}}var S,jr,_s,qr,Cs,Zr,ys,Kr,E,$r,w,ei,ne,ti,$n,pt,Q,Wt,ge,O,D,ir,ri,Ae,ea,V,Tt,ta,ii,ra,si,ia,bs,ni,gt,ai,mt,sa,R,na,oi,aa,ft,oa,N,X,At,$,Ve,Ye,Fe,sr,Oe,li,Z,xe,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eROpen",ParamEyeRSmile:"ParamEyeRSmile",ParamEyeBallX:"ParamEyeBallX",ParamEyeBallY:"ParamEyeBallY",ParamEyeBallForm:"ParamEyeBallForm",ParamBrowLY:"ParamBrowLY",ParamBrowRY:"ParamBrowRY",ParamBrowLX:"ParamBrowLX",ParamBrowRX:"ParamBrowRX",ParamBrowLAngle:"ParamBrowLAngle",ParamBrowRAngle:"ParamBrowRAngle",ParamBrowLForm:"ParamBrowLForm",ParamBrowRForm:"ParamBrowRForm",ParamMouthForm:"ParamMouthForm",ParamMouthOpenY:"ParamMouthOpenY",ParamCheek:"ParamCheek",ParamBodyAngleX:"ParamBodyAngleX",ParamBodyAngleY:"ParamBodyAngleY",ParamBodyAngleZ:"ParamBodyAngleZ",ParamBreath:"ParamBreath",ParamArmLA:"ParamArmLA",ParamArmRA:"ParamArmRA",ParamArmLB:"ParamArmLB",ParamArmRB:"ParamArmRB",ParamHandL:"ParamHandL",ParamHandR:"ParamHandR",ParamHairFront:"ParamHairFront",ParamHairSide:"ParamHairSide",ParamHairBack:"ParamHairBack",ParamHairFluffy:"ParamHairFluffy",ParamShoulderY:"ParamShoulderY",ParamBustX:"ParamBustX",ParamBustY:"ParamBustY",ParamBaseX:"ParamBaseX",ParamBaseY:"ParamBaseY",ParamNONE:"NONE:"});(function(e){e.HitAreaBody=S.HitAreaBody,e.HitAreaHead=S.HitAreaHead,e.HitAreaPrefix=S.HitAreaPrefix,e.ParamAngleX=S.ParamAngleX,e.ParamAngleY=S.ParamAngleY,e.ParamAngleZ=S.ParamAngleZ,e.ParamArmLA=S.ParamArmLA,e.ParamArmLB=S.ParamArmLB,e.ParamArmRA=S.ParamArmRA,e.ParamArmRB=S.ParamArmRB,e.ParamBaseX=S.ParamBaseX,e.ParamBaseY=S.ParamBaseY,e.ParamBodyAngleX=S.ParamBodyAngleX,e.ParamBodyAngleY=S.ParamBodyAngleY,e.ParamBodyAngleZ=S.ParamBodyAngleZ,e.ParamBreath=S.ParamBreath,e.ParamBrowLAngle=S.ParamBrowLAngle,e.ParamBrowLForm=S.ParamBrowLForm,e.ParamBrowLX=S.ParamBrowLX,e.ParamBrowLY=S.ParamBrowLY,e.ParamBrowRAngle=S.ParamBrowRAngle,e.ParamBrowRForm=S.ParamBrowRForm,e.ParamBrowRX=S.ParamBrowRX,e.ParamBrowRY=S.ParamBrowRY,e.ParamBustX=S.ParamBustX,e.ParamBustY=S.ParamBustY,e.ParamCheek=S.ParamCheek,e.ParamEyeBallForm=S.ParamEyeBallForm,e.ParamEyeBallX=S.ParamEyeBallX,e.ParamEyeBallY=S.ParamEyeBallY,e.ParamEyeLOpen=S.ParamEyeLOpen,e.ParamEyeLSmile=S.ParamEyeLSmile,e.ParamEyeROpen=S.ParamEyeROpen,e.ParamEyeRSmile=S.ParamEyeRSmile,e.ParamHairBack=S.ParamHairBack,e.ParamHairFluffy=S.ParamHairFluffy,e.ParamHairFront=S.ParamHairFront,e.ParamHairSide=S.ParamHairSide,e.ParamHandL=S.ParamHandL,e.ParamHandR=S.ParamHandR,e.ParamMouthForm=S.ParamMouthForm,e.ParamMouthOpenY=S.ParamMouthOpenY,e.ParamNONE=S.ParamNONE,e.ParamShoulderY=S.ParamShoulderY,e.PartsArmLPrefix=S.PartsArmLPrefix,e.PartsArmPrefix=S.PartsArmPrefix,e.PartsArmRPrefix=S.PartsArmRPrefix,e.PartsIdCore=S.PartsIdCore})(jr||(jr={}));_s=class{};(function(e){e.ICubismModelSetting=_s})(qr||(qr={}));Cs=class ut{static createIdInternal(t){return new ut(t)}getString(){return this._id}isEqual(t){return typeof t=="string"?this._id==t:t instanceof ut?this._id==t._id:!1}isNotEqual(t){return typeof t=="string"?this._id!=t:t instanceof ut?this._id!=t._id:!1}constructor(t){this._id=t}_id};(function(e){e.CubismId=Cs})(Zr||(Zr={}));ys=class{constructor(){this._ids=new Array}release(){for(let e=0;e<this._ids.length;++e)this._ids[e]=void 0;this._ids=null}registerIds(e){for(let t=0;t<e.length;t++)this.registerId(e[t])}registerId(e){let t=null;if(typeof e=="string"){if((t=this.findId(e))!=null)return t;t=Cs.createIdInternal(e),this._ids.push(t)}else return this.registerId(e);return t}getId(e){return this.registerId(e)}isExist(e){return typeof e=="string"?this.findId(e)!=null:this.isExist(e)}findId(e){for(let t=0;t<this._ids.length;++t)if(this._ids[t].getString()==e)return this._ids[t];return null}_ids};(function(e){e.CubismIdManager=ys})(Kr||(Kr={}));E=class Be{x;y;constructor(t,r){this.x=t,this.y=r,this.x=t??0,this.y=r??0}add(t){let r=new Be(0,0);return r.x=this.x+t.x,r.y=this.y+t.y,r}substract(t){let r=new Be(0,0);return r.x=this.x-t.x,r.y=this.y-t.y,r}multiply(t){let r=new Be(0,0);return r.x=this.x*t.x,r.y=this.y*t.y,r}multiplyByScaler(t){return this.multiply(new Be(t,t))}division(t){let r=new Be(0,0);return r.x=this.x/t.x,r.y=this.y/t.y,r}divisionByScalar(t){return this.division(new Be(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){let t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}};(function(e){e.CubismVector2=E})($r||($r={}));w=class ht{static Epsilon=1e-5;static range(t,r,i){return t<r?t=r:t>i&&(t=i),t}static sin(t){return Math.sin(t)}static cos(t){return Math.cos(t)}static abs(t){return Math.abs(t)}static sqrt(t){return Math.sqrt(t)}static cbrt(t){if(t===0)return t;let r=t,i=r<0;i&&(r=-r);let s;return r===1/0?s=1/0:(s=Math.exp(Math.log(r)/3),s=(r/(s*s)+2*s)/3),i?-s:s}static getEasingSine(t){return t<0?0:t>1?1:.5-.5*this.cos(t*Math.PI)}static max(t,r){return t>r?t:r}static min(t,r){return t>r?r:t}static clamp(t,r,i){return t<r?r:i<t?i:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return t*180/Math.PI}static directionToRadian(t,r){let i=Math.atan2(r.y,r.x)-Math.atan2(t.y,t.x);for(;i<-Math.PI;)i+=Math.PI*2;for(;i>Math.PI;)i-=Math.PI*2;return i}static directionToDegrees(t,r){let i=this.directionToRadian(t,r),s=this.radianToDegrees(i);return r.x-t.x>0&&(s=-s),s}static radianToDirection(t){let r=new E;return r.x=this.sin(t),r.y=this.cos(t),r}static quadraticEquation(t,r,i){return this.abs(t)<ht.Epsilon?this.abs(r)<ht.Epsilon?-i:-i/r:-(r+this.sqrt(r*r-4*t*i))/(2*t)}static cardanoAlgorithmForBezier(t,r,i,s){if(this.abs(t)<ht.Epsilon)return this.range(this.quadraticEquation(r,i,s),0,1);let n=r/t,a=i/t,l=s/t,o=(3*a-n*n)/3,u=o/3,h=(2*n*n*n-9*n*a+27*l)/27,d=h/2,c=d*d+u*u*u,g=.5,f=.51;if(c<0){let _=-o/3,y=_*_*_,C=this.sqrt(y),B=-h/(2*C),x=this.range(B,-1,1),b=Math.acos(x),M=2*this.cbrt(C),L=M*this.cos(b/3)-n/3;if(this.abs(L-g)<f)return this.range(L,0,1);let k=M*this.cos((b+2*Math.PI)/3)-n/3;if(this.abs(k-g)<f)return this.range(k,0,1);let H=M*this.cos((b+4*Math.PI)/3)-n/3;return this.range(H,0,1)}if(c==0){let _;d<0?_=this.cbrt(-d):_=-this.cbrt(d);let y=2*_-n/3;if(this.abs(y-g)<f)return this.range(y,0,1);let C=-_-n/3;return this.range(C,0,1)}let p=this.sqrt(c),A=this.cbrt(p-d)-this.cbrt(p+d)-n/3;return this.range(A,0,1)}static mod(t,r){if(!isFinite(t)||r===0||isNaN(t)||isNaN(r))return console.warn(`divided: ${t}, divisor: ${r} mod() returns 'NaN'.`),NaN;let i=Math.abs(t),s=Math.abs(r),n=i-Math.floor(i/s)*s;return n*=Math.sign(t),n}constructor(){}};(function(e){e.CubismMath=w})(ei||(ei={}));ne=class Re{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,r,i){let s=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),n=4;for(let a=0;a<n;++a)for(let l=0;l<n;++l)for(let o=0;o<n;++o)s[l+a*4]+=t[o+a*4]*r[l+o*4];for(let a=0;a<16;++a)i[a]=s[a]}loadIdentity(){let t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let r=0;r<16;++r)this._tr[r]=t[r]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,r){let i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,r,0,1]);Re.multiply(i,this._tr,this._tr)}translate(t,r){this._tr[12]=t,this._tr[13]=r}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,r){let i=new Float32Array([t,0,0,0,0,r,0,0,0,0,1,0,0,0,0,1]);Re.multiply(i,this._tr,this._tr)}scale(t,r){this._tr[0]=t,this._tr[5]=r}multiplyByMatrix(t){Re.multiply(t.getArray(),this._tr,this._tr)}getInvert(){let t=this._tr[0],r=this._tr[1],i=this._tr[2],s=this._tr[4],n=this._tr[5],a=this._tr[6],l=this._tr[8],o=this._tr[9],u=this._tr[10],h=this._tr[12],d=this._tr[13],c=this._tr[14],g=t*(n*u-o*a)-s*(r*u-o*i)+l*(r*a-n*i),f=new Re;if(w.abs(g)<w.Epsilon)return f.loadIdentity(),f;let p=1/g,A=(n*u-o*a)*p,_=-(s*u-l*a)*p,y=(s*o-l*n)*p,C=-(r*u-o*i)*p,B=(t*u-l*i)*p,x=-(t*o-l*r)*p,b=(r*a-n*i)*p,M=-(t*a-s*i)*p,L=(t*n-s*r)*p;return f._tr[0]=A,f._tr[1]=C,f._tr[2]=b,f._tr[3]=0,f._tr[4]=_,f._tr[5]=B,f._tr[6]=M,f._tr[7]=0,f._tr[8]=y,f._tr[9]=x,f._tr[10]=L,f._tr[11]=0,f._tr[12]=-(A*h+_*d+y*c),f._tr[13]=-(C*h+B*d+x*c),f._tr[14]=-(b*h+M*d+L*c),f._tr[15]=1,f}clone(){let t=new Re;for(let r=0;r<this._tr.length;r++)t._tr[r]=this._tr[r];return t}_tr};(function(e){e.CubismMatrix44=ne})(ti||(ti={}));$n=(e,t,r)=>{ir.print(e,"[CSM]"+t,r)},pt=(e,t,r)=>{$n(e,t+`
|
|
3
|
-
`,r)},
|
|
2
|
+
var Hn=Object.defineProperty;var _e=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ke=(e,t)=>{for(var r in t)Hn(e,r,{get:t[r],enumerable:!0})};var m,Me=_e(()=>{m=class extends Error{code;details;constructor(e,t,r){super(t,r),this.name="Live2DError",this.code=e,this.details=r?.details?Object.freeze({...r.details}):void 0}}});function wt(e){if(e===void 0||e===!1)return;if(typeof e=="string"){if(e.trim()!=="")return;throw new m("invalid-props","idleMotion must be a non-empty motion group name, weighted options or false.")}if(typeof e!="object"||e===null||Array.isArray(e))throw new m("invalid-props","idleMotion weighted options must be an object.");if(typeof e.group!="string"||e.group.trim()==="")throw new m("invalid-props","idleMotion.group must be a non-empty string.");if(!Array.isArray(e.weights)||e.weights.length===0)throw new m("invalid-props","idleMotion.weights must be a non-empty array.");let t=!1;for(let r of e.weights){if(!Number.isFinite(r)||r<0)throw new m("invalid-props","Every idleMotion weight must be a finite, non-negative number.");t||=r>0}if(!t)throw new m("invalid-props","At least one idleMotion weight must be greater than 0.")}function Lr(e,t){if(wt(e),e===!1)return!1;if(e===void 0)return{group:"Idle"};if(typeof e=="string"){if(t(e)<=0)throw new m("invalid-props",`Unknown idle motion group: ${e}.`);return{group:e}}let r=t(e.group);if(r<=0)throw new m("invalid-props",`Unknown weighted idle motion group: ${e.group}.`);if(e.weights.length!==r)throw new m("invalid-props",`idleMotion.weights has ${e.weights.length} entries but group ${e.group} has ${r} motions.`);return{group:e.group,weights:[...e.weights]}}function Tr(e,t,r=Math.random){if(!t)return Math.min(e-1,Math.floor(r()*e));let i=0;for(let a of t)i=Math.max(i,a);let s=t.reduce((a,l)=>a+l/i,0),n=Math.min(1-Number.EPSILON,Math.max(0,r()))*s;for(let a=0;a<t.length;a++)if(n-=t[a]/i,n<0)return a;return t.length-1}function Dr(e,t,r){if(r!==void 0){if(!Number.isFinite(r)||r<0)throw new m("invalid-props",`${e} ${t} must be a finite, non-negative number of milliseconds.`);return r/1e3}}function Fr(e,t){if(t!==void 0&&(typeof t!="object"||t===null))throw new m("invalid-props",`${e} options must be an object.`);return{fadeInSeconds:Dr(e,"fadeInMs",t?.fadeInMs),fadeOutSeconds:Dr(e,"fadeOutMs",t?.fadeOutMs)}}function $e(e){return Fr("Motion",e)}function Or(e){return Fr("Expression",e)}function et(e){return e.fadeInSeconds!==void 0||e.fadeOutSeconds!==void 0}function Ue(e){if(e!==void 0){if(typeof e!="object"||e===null)throw new m("invalid-props","Motion options must be an object.");if(e.priority!==void 0&&e.priority!=="force"&&e.priority!=="idle"&&e.priority!=="normal")throw new m("invalid-props","Motion priority must be 'force', 'idle' or 'normal'.");$e(e)}}var xt=_e(()=>{Me()});var Qr={};Ke(Qr,{WLipSyncAudioNode:()=>vt,createWLipSyncNode:()=>zn,parseBinaryProfile:()=>Yn});function Vr(e,t,r,i,s){let n=2/i,a=n*s,l=1/(1+a+.48*a*a+.235*a*a*a),o=e-t,u=(r+n*o)*s;return Et.value=t+(o+u)*l,Et.velocity=(r-n*u)*l,Et}function Yn(e){let t=new DataView(e),r=0,i=()=>t.getUint8(r++),s=()=>{let u=t.getInt32(r);return r+=4,u},n=()=>String.fromCharCode(t.getUint8(r++)),a=()=>{let u=i(),c=Wn.decode(e.slice(r,r+u));return r+=u,c},l=u=>[...new Array(u)].map(c=>(()=>{let g=t.getFloat32(r);return r+=4,g})());if(n()!=="W"||n()!=="L"||n()!=="I"||n()!=="P")throw new Error("Invalid file signature for binary wLipSync profile");let o={targetSampleRate:s(),sampleCount:s(),melFilterBankChannels:i(),compareMethod:i(),mfccNum:12,mfccs:[...new Array(i())],mfccDataCount:i(),useStandardization:i()===1};for(let u=0;u<o.mfccs.length;u++)o.mfccs[u]={name:"",mfccCalibrationDataList:[],values:l(12)};o.means=l(12),o.stdDevs=l(12);for(let u=0;u<o.mfccs.length;u++)o.mfccs[u].name=a();return o}async function zn(e,t){try{return new vt(e,t)}catch{return await e.audioWorklet.addModule(new URL("data:text/javascript;base64,dmFyIEI9bmV3IFdlYkFzc2VtYmx5Lk1lbW9yeSh7aW5pdGlhbDo0fSksWD17ZW52OnttZW1vcnk6Qn19O2NsYXNzIFUgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3J7aW5wdXRCdWZmZXJJbmRleD0tMTtpbnB1dEJ1ZmZlclB0cj0tMTtpbnB1dEJ1ZmZlclNpemU9LTE7aW5wdXRCdWZmZXI9bnVsbDtsYXN0SW5kZXg9MDt2b2x1bWVQdHI9LTE7dm9sdW1lVmlldz1udWxsO21mY2NzPVtdO2V4cG9ydHM9bnVsbDtjb25zdHJ1Y3RvcihKKXtzdXBlcigpO2xldHt3YXNtTW9kdWxlOlMscHJvZmlsZTprfT1KLnByb2Nlc3Nvck9wdGlvbnM7V2ViQXNzZW1ibHkuaW5zdGFudGlhdGUoUyxYKS50aGVuKChHKT0+e2xldCB6PXRoaXMuZXhwb3J0cz1HLmV4cG9ydHMsRT1rLm1mY2NzLmxlbmd0aCxXPXoubG9hZF9wcm9maWxlKGsudGFyZ2V0U2FtcGxlUmF0ZSxrLnNhbXBsZUNvdW50LGsubWVsRmlsdGVyQmFua0NoYW5uZWxzLGsuY29tcGFyZU1ldGhvZCxFLGsubWZjY0RhdGFDb3VudCxrLnVzZVN0YW5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cm9jZXNzb3IoIndsaXBzeW5jLXByb2Nlc3NvciIsVSk7Cg==",""+import.meta.url)),new vt(e,t)}}var Et,kr,vt,Wn,Ur=_e(async()=>{Et={value:0,velocity:0};kr={wasmModule:void 0},vt=class extends AudioWorkletNode{openCloseVelocity=0;lastTimestamp=0;weightVelocities={};minVolume=-2.5;maxVolume=-1.5;smoothness=.05;volume=0;weights={};constructor(e,t,r=kr.wasmModule){super(e,"wlipsync-processor",{processorOptions:{wasmModule:r,profile:t}});for(let i of t.mfccs)this.weights[i.name]=0,this.weightVelocities[i.name]=0;this.port.onmessage=this.onMessage.bind(this)}onMessage(e){let t=e.data.timestamp-this.lastTimestamp;this.lastTimestamp=e.data.timestamp;let r=Number.isNaN(e.data.volume)?0:e.data.volume,i=Math.log10(r);i=(i-this.minVolume)/(this.maxVolume-this.minVolume),i=Math.max(Math.min(i,1),0);let s=Vr(this.volume,i,this.openCloseVelocity,this.smoothness,t);this.volume=s.value,this.openCloseVelocity=s.velocity;for(let n in this.weights){let a=n===e.data.name?1:0,l=Vr(this.weights[n],a,this.weightVelocities[n],this.smoothness,t);this.weights[n]=l.value,this.weightVelocities[n]=l.velocity}}get blockSize(){return this.parameters.get("blockSize").value}set blockSize(e){this.parameters.get("blockSize").setValueAtTime(e,this.context.currentTime)}},Wn=new TextDecoder;kr.wasmModule=await WebAssembly.compileStreaming(fetch("data:application/wasm;base64,AGFzbQEAAAABbRBgAAF/YAAAYAJ/fwBgBn9/f39/fwBgA39/fwBgAn9/AX1gA39/fQBgB39/f39/f38Bf2ABfwBgAX8Bf2AFf39/f38AYAR/f39/AGAFf39/f30AYAZ/f31/f38AYAZ/f319fX8AYAV/f399fwACDwEDZW52Bm1lbW9yeQIABAMdHAEBBwEACAAAAAkKBAsMBAINDg8FBgIGBQMDAwIGnAEXfwFBgIAEC38AQfiwCAt/AEGgsQgLfwBBkLAEC38AQcCwBAt/AEGQgAQLfwBBgIAEC38AQYyABAt/AEH0sAgLfwBB8LAEC38AQfC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AAIQIDQCACQQxqKgIAIAJBCGoqAgAgAkEEaioCACACKgIAIAaSkpKSIQYgAkEQaiECIAUgBEEEaiIERw0ACyADRQ0BCyAAIARBAnRqIQIDQCACKgIAIAaSIQYgAkEEaiECIANBAWsiAw0ACwsgBkMAAAAAX0UEQEEAIQMgAUEBRwRAIAFBAXFDAACAPyAGlSEHIAFBfnEhASAAIQIDQCACIAIqAgAgB5Q4AgAgAkEEaiIFIAUqAgAgB5Q4AgAgAkEIaiECIAEgA0ECaiIDRw0AC0UNAgsgACADQQJ0aiIAIAAqAgAgBpU4AgAMAQsgAUECdCIBRQ0AIABBACAB/AsACwsLGAEAQYCABAsQEAABABAYAQBAGAEAgLsAAAAmCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQVjbGFuZwYyMi4xLjgAlAEPdGFyZ2V0X2ZlYXR1cmVzCCsPbXV0YWJsZS1nbG9iYWxzKxNub250cmFwcGluZy1mcHRvaW50KwtidWxrLW1lbW9yeSsIc2lnbi1leHQrD3JlZmVyZW5jZS10eXBlcysKbXVsdGl2YWx1ZSsPYnVsay1tZW1vcnktb3B0KxZjYWxsLWluZGlyZWN0LW92ZXJsb25n"))});function Z(e,t,r,i){if(!e)return i();let s=performance.now();try{return i()}finally{let n=performance.now()-s;t==="frame"?e.framePhase(r,n):e.loadPhase(r,n)}}async function Ce(e,t,r){if(!e)return r();let i=performance.now();try{return await r()}finally{e.loadPhase(t,performance.now()-i)}}function Jn(e,t){if(!t)return;let r=e.getExtension("EXT_disjoint_timer_query_webgl2");if(t.gpuTimerSupport(!!r),!r){t.gpuDraw(null);return}let i,s=[],n=()=>{for(;s.length>0;){let a=s[0];if(!e.getQueryParameter(a,e.QUERY_RESULT_AVAILABLE))return;s.shift();let l=e.getParameter(r.GPU_DISJOINT_EXT)?void 0:Number(e.getQueryParameter(a,e.QUERY_RESULT));t.gpuDraw(l===void 0||!Number.isFinite(l)?null:l/1e6),e.deleteQuery(a)}};return{begin(){if(n(),i)return;let a=e.createQuery();a&&(e.beginQuery(r.TIME_ELAPSED_EXT,a),i=a)},dispose(){i&&(e.endQuery(r.TIME_ELAPSED_EXT),e.deleteQuery(i),i=void 0);for(let a of s)e.deleteQuery(a);s.length=0},end(){i&&(e.endQuery(r.TIME_ELAPSED_EXT),s.push(i),i=void 0)},poll:n}}function Gr(e){return e.split("/").map(t=>t==="."||t===".."?t:encodeURIComponent(t)).join("/")}function Xr(e){return new URL(Gr(e.replace(/^\/+/,"")),Rt).href}function Dt(e){let t=new URL(e);if(t.origin===new URL(Rt).origin)return t.pathname.slice(1).split("/").map(r=>decodeURIComponent(r)).join("/")}function re(e,t){return t.startsWith(Rt)?/^[a-z][a-z\d+.-]*:/i.test(e)||e.startsWith("//")?new URL(e,t).href:new URL(Gr(e),t).href:new URL(e,t).href}function Hr(e){let t=typeof window>"u"?void 0:window.location.href,r=e instanceof URL?new URL(e.href):t?new URL(e,t):new URL(e);return r.pathname.endsWith("/")||(r.pathname+="/"),r.href}function ue(e,t,r){return{assetType:e,backend:"cubism-webgl",httpStatus:r,url:Dt(t)??t}}async function jn(e,t,r,i,s){let n;try{n=await e(t,s)}catch(a){throw s?.aborted?s.reason:new m("model-load-failed",`resolveAsset threw while loading ${t}.`,{cause:a,details:ue(i,r)})}if(s?.aborted)throw s.reason;if(n===void 0)throw new m("model-load-failed",`resolveAsset did not provide ${t}. The model declares it, so the source is missing this file or names it differently.`,{details:{...ue(i,r),httpStatus:404}});return n instanceof Blob?n:new Blob([n])}async function qn(e,t,r){let i;try{i=await fetch(e,{signal:r})}catch(s){throw r?.aborted?r.reason:new m("model-load-failed",`Failed to load ${e}.`,{cause:s,details:ue(t,e)})}if(!i.ok)throw new m("model-load-failed",`Failed to load ${e}: HTTP ${i.status}`,{details:ue(t,e,i.status)});return i}async function Wr(e,t,r,i){let s=i?Dt(e):void 0;return i&&s!==void 0?jn(i,s,e,t,r):(await qn(e,t,r)).blob()}async function he(e,t,r,i){let s=await(await Wr(e,t,r,i)).arrayBuffer();if(s.byteLength===0)throw new m("model-load-failed",`Loaded an empty asset from ${Dt(e)??e}.`,{details:ue(t,e)});return s}async function Zn(e,t,r){if(r?.aborted)throw r.reason;if(typeof createImageBitmap=="function")try{return await createImageBitmap(e,{premultiplyAlpha:"premultiply"})}catch(s){throw r?.aborted?r.reason:new m("model-load-failed",`Failed to decode model texture ${t}.`,{cause:s,details:ue("texture",t)})}let i=URL.createObjectURL(e);try{return await new Promise((s,n)=>{let a=new Image,l=()=>n(r?.reason);r?.addEventListener("abort",l,{once:!0}),a.onload=()=>{r?.removeEventListener("abort",l),s(a)},a.onerror=()=>{r?.removeEventListener("abort",l),n(new m("model-load-failed",`Failed to decode model texture ${t}.`,{details:ue("texture",t)}))},a.src=i})}finally{URL.revokeObjectURL(i)}}function Ne(e){"close"in e&&typeof e.close=="function"&&e.close()}async function Yr(e,t,r,i){let s=await Ce(r,"textureFetch",()=>Wr(e,"texture",t,i));return Ce(r,"textureDecode",()=>Zn(s,e,t))}function zr(e,t,r,i){let s=e.createTexture();if(!s)throw Ne(t),new m("render-error",`WebGL failed to create a texture for ${r}.`,{details:ue("texture",r)});let n=e.getParameter(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL);try{return Z(i,"load","textureUpload",()=>{e.bindTexture(e.TEXTURE_2D,s),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)}),s}catch(a){throw e.deleteTexture(s),a instanceof m?a:new m("render-error",`Failed to upload model texture ${r} to WebGL.`,{cause:a,details:ue("texture",r)})}finally{e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n),Ne(t)}}function Nr(e,t){for(let r of["aria-describedby","aria-hidden","aria-label","role"])e.removeAttribute(r);if(e.textContent="",!!t){if(t.mode==="decorative"){e.setAttribute("aria-hidden","true"),e.setAttribute("role","presentation");return}e.setAttribute("aria-label",t.label),e.setAttribute("role","img"),t.describedBy&&e.setAttribute("aria-describedby",t.describedBy),e.textContent=t.fallbackText??t.label}}function tt(e){let t=!0;return()=>{t&&(t=!1,e())}}function Kn(e){return e instanceof m?e:new m("render-error",e instanceof Error?e.message:String(e),{cause:e,details:{backend:"cubism-webgl"}})}function we(e){let t=Pt.get(e);if(!t||t.disposed)throw new m("adapter-error","The StageHandle was not created by the active cubism-webgl adapter.",{details:{backend:"cubism-webgl"}});return t}function Jr(e,t,r){if(typeof window>"u")throw new m("browser-only","cubism-webgl can only run in a browser.");let i=document.createElement("canvas");Nr(i,t.accessibility);let s=i.getContext("webgl2",{alpha:!0,antialias:!0,depth:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,stencil:!1});if(!s)throw new m("webgl-unsupported","WebGL2 is required by cubism-webgl.",{details:{backend:"cubism-webgl"}});r?.changeResource("canvas",1),r?.changeResource("context",1);let n=Jn(s,r),a={height:Math.max(1,t.height),width:Math.max(1,t.width)},l=t.resolution??1,o=!1,u=!0,c=!1,g=0,h=0,d=!1,f,p,A=new Set,_=new Set,b=new Set,C=t.maxFps?1e3/t.maxFps:0,B=()=>{i.width=Math.max(1,Math.round(a.width*l)),i.height=Math.max(1,Math.round(a.height*l)),s.viewport(0,0,i.width,i.height);for(let v of A)v.resize(i.width,i.height)},I=()=>{u=!1,cancelAnimationFrame(g),g=0,h=0,f=void 0,p=void 0},y=v=>{if(!(o||c)){c=!0,I();for(let j of b)j(v)}},w=v=>{let j=Math.min(v,100);for(let W of A)W.update(j)},L=()=>{s.bindFramebuffer(s.FRAMEBUFFER,null),s.viewport(0,0,i.width,i.height),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT)},D=()=>{for(let v of A)v.draw()},O=v=>{if(!u||o)return;g=requestAnimationFrame(O);let j=p===void 0?0:v-p;if(p=v,h+=j,f!==void 0&&h<C-.25)return;let W=f===void 0?0:v-f;f=v,h=C?h>=C*2?0:Math.max(0,h-C):0;try{if(r)r.framePhase("frameDelta",W),Z(r,"frame","stageFrame",()=>{w(W);for(let le of _)le(W);L(),n?.begin();try{Z(r,"frame","drawCpu",D)}finally{n?.end()}});else{w(W);for(let le of _)le(W);L(),D()}A.size>0&&!d&&(d=!0,r?.firstDraw())}catch(le){y(Kn(le))}},z=v=>{v.preventDefault(),y(new m("render-error","The WebGL context was lost. Call retry() to recreate the Live2D canvas.",{details:{backend:"cubism-webgl"}}))};i.style.display="block",i.style.height="100%",i.style.touchAction="none",i.style.width="100%",i.addEventListener("webglcontextlost",z),e.appendChild(i),B();let oe,J={attachDriver(v){return A.add(v),v.resize(i.width,i.height),tt(()=>{A.delete(v)})},canvas:i,diagnostics:r,disposed:o,gl:s,reportError:y};return oe={dispose:tt(()=>{o=!0,J.disposed=!0,I(),A.clear(),_.clear(),b.clear(),i.removeEventListener("webglcontextlost",z),n?.poll(),n?.dispose(),s.isContextLost()||s.getExtension("WEBGL_lose_context")?.loseContext(),i.width=1,i.height=1,i.remove(),r?.changeResource("context",-1),r?.changeResource("canvas",-1),Pt.delete(oe)}),getResolution:()=>l,getSize:()=>({...a}),onError(v){return b.add(v),tt(()=>b.delete(v))},onFrame(v){return _.add(v),tt(()=>_.delete(v))},pause:I,resize(v,j){a={height:Math.max(1,j),width:Math.max(1,v)},B()},resume(){o||c||u||(u=!0,g=requestAnimationFrame(O))},setAccessibility(v){Nr(i,v)},setResolution(v){if(!Number.isFinite(v)||v<1)throw new m("invalid-props","Stage resolution must be a finite number greater than or equal to 1.");l=v,B()},toWorld(v,j){let W=i.getBoundingClientRect();return{x:v-W.left,y:j-W.top}}},Pt.set(oe,J),g=requestAnimationFrame(O),oe}var Rt,Pt,Lt=_e(()=>{Me();Rt="https://live2d-web.invalid/";Pt=new WeakMap});var An={};Ke(An,{loadFrameworkModel:()=>ml});function la(e,t){let r=0;for(let s=1;;s++){let n=e.slice(s-1,s);if(n=="e"||n=="-"||n=="E")continue;let a=e.substring(0,s),l=Number(a);if(isNaN(l))break;r=s}let i=parseFloat(e);return isNaN(i)&&(i=NaN),t[0]=e.slice(r),i}function Le(e){e&&(e=void 0)}function N(e,t,r=null,i=null){if(e.length<t)if(i)for(let s=e.length;s<t;s++)typeof r=="function"?e[s]=JSON.parse(JSON.stringify(new r)):e[s]=r;else for(let s=e.length;s<t;s++)e[s]=r;else e.length=t}function Y(e,t,r){let i=new ze;return i.time=e.time+(t.time-e.time)*r,i.value=e.value+(t.value-e.value)*r,i}function Os(e,t){let r=(t-e[0].time)/(e[1].time-e[0].time);return r<0&&(r=0),e[0].value+(e[1].value-e[0].value)*r}function Ha(e,t){let r=(t-e[0].time)/(e[3].time-e[0].time);r<0&&(r=0);let i=Y(e[0],e[1],r),s=Y(e[1],e[2],r),n=Y(e[2],e[3],r);return Y(Y(i,s,r),Y(s,n,r),r).value}function Wa(e,t){let r=t,i=e[0].time,s=e[3].time,n=e[1].time,a=e[2].time,l=s-3*a+3*n-i,o=3*a-6*n+3*i,u=3*n-3*i,c=i-r,g=x.cardanoAlgorithmForBezier(l,o,u,c),h=Y(e[0],e[1],g),d=Y(e[1],e[2],g),f=Y(e[2],e[3],g);return Y(Y(h,d,g),Y(d,f,g),g).value}function Vs(e,t){return e[0].value}function ks(e,t){return e[1].value}function Vt(e,t,r,i,s){let n=e.curves[t],a=-1,l=n.baseSegmentIndex+n.segmentCount,o=0;for(let c=n.baseSegmentIndex;c<l;++c)if(o=e.segments[c].basePointIndex+(e.segments[c].segmentType==1?3:1),e.points[o].time>r){a=c;break}if(a==-1)return i&&r<s?Ya(e,l-1,e.segments[n.baseSegmentIndex].basePointIndex,o,r,s):e.points[o].value;let u=e.segments[a];return u.evaluate(e.points.slice(u.basePointIndex),r)}function Ya(e,t,r,i,s,n){let a=[new ze,new ze];{let l=e.points[i];a[0].time=l.time,a[0].value=l.value}{let l=e.points[r];a[1].time=n,a[1].value=l.value}switch(e.segments[t].segmentType){case 0:case 1:default:return Os(a,s);case 2:return Vs(a,s);case 3:return ks(a,s)}}function co(e){let t=0;return e>0?t=1:e<0&&(t=-1),t}function go(e,t,r,i,s,n,a,l,o,u){e.x+=hr(r,i,s,n,a.minimum,a.maximum,a.defalut,o)*u}function fo(e,t,r,i,s,n,a,l,o,u){e.y+=hr(r,i,s,n,a.minimum,a.maximum,a.defalut,o)*u}function Ao(e,t,r,i,s,n,a,l,o,u){t.angle+=hr(r,i,s,n,l.minimum,l.maximum,l.defalut,o)*u}function po(e,t,r,i,s){let n=e.x;return i&&(n*=-1),n}function mo(e,t,r,i,s){let n=e.y;return i&&(n*=-1),n}function _o(e,t,r,i,s){let n;return r>=2?s=t[r-1].position.substract(t[r-2].position):s=s.multiplyByScaler(-1),n=x.directionToRadian(s,e),i&&(n*=-1),n}function Co(e,t){let r=x.max(e,t),i=x.min(e,t);return x.abs(r-i)}function yo(e,t){return x.min(e,t)+Co(e,t)/2}function bo(e,t){return JSON.parse(JSON.stringify(e.x))}function Bo(e,t){return JSON.parse(JSON.stringify(e.y))}function Io(e,t){return JSON.parse(JSON.stringify(t))}function So(e,t,r,i,s,n,a,l){let o,u,c=new E(0,0),g=new E(0,0),h=new E(0,0),d=new E(0,0);e[0].position=new E(r.x,r.y);let f=x.degreesToRadian(i),p=x.radianToDirection(f);p.normalize();for(let A=1;A<t;++A)e[A].force=p.multiplyByScaler(e[A].acceleration).add(s),e[A].lastPosition=new E(e[A].position.x,e[A].position.y),o=e[A].delay*a*30,c=e[A].position.substract(e[A-1].position),u=x.directionToRadian(e[A].lastGravity,p)/l,c.x=x.cos(u)*c.x-c.y*x.sin(u),c.y=x.sin(u)*c.x+c.y*x.cos(u),e[A].position=e[A-1].position.add(c),g=e[A].velocity.multiplyByScaler(o),h=e[A].force.multiplyByScaler(o).multiplyByScaler(o),e[A].position=e[A].position.add(g).add(h),d=e[A].position.substract(e[A-1].position),d.normalize(),e[A].position=e[A-1].position.add(d.multiplyByScaler(e[A].radius)),x.abs(e[A].position.x)<n&&(e[A].position.x=0),o!=0&&(e[A].velocity=e[A].position.substract(e[A].lastPosition),e[A].velocity=e[A].velocity.divisionByScalar(o),e[A].velocity=e[A].velocity.multiplyByScaler(e[A].mobility)),e[A].force=new E(0,0),e[A].lastGravity=new E(p.x,p.y)}function Mo(e,t,r,i,s,n){let a=new E(0,0);e[0].position=new E(r.x,r.y);let l=x.degreesToRadian(i),o=x.radianToDirection(l);o.normalize();for(let u=1;u<t;++u)e[u].force=o.multiplyByScaler(e[u].acceleration).add(s),e[u].lastPosition=new E(e[u].position.x,e[u].position.y),e[u].velocity=new E(0,0),a=e[u].force,a.normalize(),a=a.multiplyByScaler(e[u].radius),e[u].position=e[u-1].position.add(a),x.abs(e[u].position.x)<n&&(e[u].position.x=0),e[u].force=new E(0,0),e[u].lastGravity=new E(o.x,o.y)}function Nt(e,t,r,i,s,n){let a;a=s*n.getScale(n.translationScale,n.angleScale),a<r?(a<n.valueBelowMinimum&&(n.valueBelowMinimum=a),a=r):a>i&&(a>n.valueExceededMaximum&&(n.valueExceededMaximum=a),a=i);let l=n.weight/Kt;l>=1||(a=e[t]*(1-l)+a*l),e[t]=a}function hr(e,t,r,i,s,n,a,l){let o=0,u=x.max(r,t);u<e&&(e=u);let c=x.min(r,t);c>e&&(e=c);let g=x.min(s,n),h=x.max(s,n),d=a,f=yo(c,u),p=e-f;switch(co(p)){case 1:{let A=h-d,_=u-f;_!=0&&(o=p*(A/_),o+=d);break}case-1:{let A=g-d,_=c-f;_!=0&&(o=p*(A/_),o+=d);break}case 0:o=d;break;default:break}return l?o:o*-1}function rl(e){let t=(e instanceof Error?e.message:String(e)).match(/Failed to load shader (.+?)(?:: HTTP (\d+)|: empty source)$/);return{assetType:"shader",backend:"cubism-webgl",httpStatus:t?.[2]?Number(t[2]):void 0,url:t?.[1]}}function il(e){let t=!0;return()=>{t&&(t=!1,e())}}function sl(e){if(lt===0){let t=globalThis.Live2DCubismCore;if(!t||typeof t.MocVersion_53!="number"||typeof t.ColorBlendType_Normal!="number")throw new m("core-missing","cubism-webgl requires Live2D Cubism Core 5.3.",{details:{assetType:"core",backend:"cubism-webgl"}});if(!P.startUp())throw new m("adapter-error","CubismFramework.startUp() failed.",{details:{backend:"cubism-webgl"}});P.initialize()}return lt++,e?.changeResource("frameworkReference",1),il(()=>{lt--,e?.changeResource("frameworkReference",-1),lt===0&&P.isInitialized()&&P.dispose()})}function nl(e,t){let r=t.transformX(-e.width/2),i=t.transformX(e.width/2),s=t.transformY(-e.height/2),n=t.transformY(e.height/2);return{centerX:(r+i)/2,centerY:(s+n)/2,height:Math.abs(n-s),width:Math.abs(i-r)}}function fs(e,t,r,i){let s=new ae,n=2*t.scale/Math.max(1,e.width),a=2*t.scale/Math.max(1,e.height),l=2*t.x/Math.max(1,e.width)-1,o=1-2*t.y/Math.max(1,e.height);return s.scale(n,a),s.translate(l-i.centerX*n,o-i.centerY*a),s.multiplyByMatrix(r),s}async function al(e,t){return e.buffer||(e.loading??=t().finally(()=>{e.loading=void 0}),e.buffer=await e.loading),e.buffer}function ol(e,t){return t.fadeInSeconds!==void 0&&e.setFadeInTime(t.fadeInSeconds),t.fadeOutSeconds!==void 0&&e.setFadeOutTime(t.fadeOutSeconds),e}function As(e,t,r,i){if(!et(t))return{autoDelete:!1,motion:e.motion,releaseBeforeStart(){},transferToQueue(){}};if(!e.buffer)throw new Error("A fade override needs the motion buffer loaded before playback.");let s=ol(r(e.buffer),t),n=!0;return{autoDelete:!0,motion:s,releaseBeforeStart(){n&&(n=!1,i(s))},transferToQueue(){n=!1}}}function ul(e){let t=!0;return()=>{t&&(t=!1,e())}}function hl(e){return We.set(e,(We.get(e)??0)+1),ul(()=>{let t=(We.get(e)??1)-1;if(t>0){We.set(e,t);return}We.delete(e),cr.getInstance().removeContext(e),$.getInstance().releaseContext(e)})}function ms(e){let t=!0;return()=>{t&&(t=!1,e())}}function fn(e,t){return e instanceof m?e:new m("model-load-failed",e instanceof Error?`${t}: ${e.message}`:t,{cause:e})}function ne(e,t){return{assetType:e,backend:"cubism-webgl",url:t}}async function ml(e,t,r,i,s={}){let n=we(e).diagnostics,a=sl(n),l=n?performance.now():0,o;try{let u=s.resolveAsset?Xr(t):new URL(t,window.location.href).href,c=await Ce(n,"modelJsonFetch",()=>he(u,"model3",s.signal,s.resolveAsset)),g,h;try{let f=JSON.parse(new TextDecoder().decode(c));h=typeof f.Version=="number"&&Number.isFinite(f.Version)?f.Version:void 0,g=Z(n,"load","modelJsonParse",()=>new Bs(c,c.byteLength))}catch(f){throw new m("model-load-failed",`Failed to parse model3.json ${u}.`,{cause:f,details:ne("model3",u)})}let d=Lr(s.idleMotion,f=>g.getMotionCount(f));return o=new pl(e,u,g,r,i,d,a,h,n,s.resolveAsset),await o.initialize(s.signal),n&&n.loadPhase("ready",performance.now()-l),o.toHandle()}catch(u){throw o?o.toHandle().dispose():a(),s.signal?.aborted?s.signal.reason:fn(u,`Failed to load ${t}`)}}var M,jr,_s,qr,Cs,Zr,ys,Kr,E,$r,x,ei,ae,ti,$n,pt,U,Wt,ge,k,T,ir,ri,Ae,ea,Q,Tt,ta,ii,ra,si,ia,bs,ni,gt,ai,mt,sa,R,na,oi,aa,ft,oa,G,H,At,ee,Ve,Ye,Fe,sr,Oe,li,K,xe,Ee,Ge,te,P,ui,ua,Bs,hi,nr,De,ci,ar,ha,di,Jt,Ie,gi,or,fi,ca,Ft,Ai,pi,da,ga,jt,qt,mi,Ot,_i,xs,Ci,Es,yi,Se,bi,lr,Bi,fa,vs,Ii,Aa,pa,Si,ma,_a,rt,Ca,ya,ba,Mi,Te,Ba,Ps,wi,Ia,Sa,ze,Rs,Ds,Ls,Ts,xi,X,Ma,wa,xa,Ea,va,Pa,Ra,ce,Da,La,it,st,Ei,vi,Ta,Fa,Oa,Va,Fs,Pi,ka,Qa,Ua,Na,Ga,nt,Xa,Qs,Ri,Ns,Di,za,Ja,ja,ur,Zt,Gs,Xs,Hs,Ws,Ys,Li,Xe,kt,Qt,Ut,Ti,Fi,de,at,qa,Za,Ka,Oi,Vi,$a,eo,F,ve,ki,Qi,Ui,Ni,Gi,He,to,ye,ro,io,so,be,no,ao,oo,lo,zs,Xi,Hi,Wi,Yi,uo,Kt,zi,ho,$t,js,Ji,ji,Gt,wo,xo,Eo,pe,qi,vo,Po,cr,Zi,Ro,Do,Lo,To,Fo,Oo,Vo,ko,Qo,Uo,No,Go,Xo,Ho,Wo,Pe,Ki,Yo,zo,qs,$,Ks,Jo,$i,ot,Xt,dt,$s,jo,dr,es,tr,ts,rs,qo,Zo,Ht,Ko,$o,el,tn,is,tl,rn,rr,ss,nn,ns,fe,as,on,os,ln,ls,un,us,hn,hs,cn,cs,dn,ds,gn,gs,lt,ll,We,cl,dl,gl,ps,fl,Al,pl,pn=_e(()=>{Me();xt();Lt();M=Object.freeze({HitAreaPrefix:"HitArea",HitAreaHead:"Head",HitAreaBody:"Body",PartsIdCore:"Parts01Core",PartsArmPrefix:"Parts01Arm_",PartsArmLPrefix:"Parts01ArmL_",PartsArmRPrefix:"Parts01ArmR_",ParamAngleX:"ParamAngleX",ParamAngleY:"ParamAngleY",ParamAngleZ:"ParamAngleZ",ParamEyeLOpen:"ParamEyeLOpen",ParamEyeLSmile:"ParamEyeLSmile",ParamEyeROpen:"ParamEyeROpen",ParamEyeRSmile:"ParamEyeRSmile",ParamEyeBallX:"ParamEyeBallX",ParamEyeBallY:"ParamEyeBallY",ParamEyeBallForm:"ParamEyeBallForm",ParamBrowLY:"ParamBrowLY",ParamBrowRY:"ParamBrowRY",ParamBrowLX:"ParamBrowLX",ParamBrowRX:"ParamBrowRX",ParamBrowLAngle:"ParamBrowLAngle",ParamBrowRAngle:"ParamBrowRAngle",ParamBrowLForm:"ParamBrowLForm",ParamBrowRForm:"ParamBrowRForm",ParamMouthForm:"ParamMouthForm",ParamMouthOpenY:"ParamMouthOpenY",ParamCheek:"ParamCheek",ParamBodyAngleX:"ParamBodyAngleX",ParamBodyAngleY:"ParamBodyAngleY",ParamBodyAngleZ:"ParamBodyAngleZ",ParamBreath:"ParamBreath",ParamArmLA:"ParamArmLA",ParamArmRA:"ParamArmRA",ParamArmLB:"ParamArmLB",ParamArmRB:"ParamArmRB",ParamHandL:"ParamHandL",ParamHandR:"ParamHandR",ParamHairFront:"ParamHairFront",ParamHairSide:"ParamHairSide",ParamHairBack:"ParamHairBack",ParamHairFluffy:"ParamHairFluffy",ParamShoulderY:"ParamShoulderY",ParamBustX:"ParamBustX",ParamBustY:"ParamBustY",ParamBaseX:"ParamBaseX",ParamBaseY:"ParamBaseY",ParamNONE:"NONE:"});(function(e){e.HitAreaBody=M.HitAreaBody,e.HitAreaHead=M.HitAreaHead,e.HitAreaPrefix=M.HitAreaPrefix,e.ParamAngleX=M.ParamAngleX,e.ParamAngleY=M.ParamAngleY,e.ParamAngleZ=M.ParamAngleZ,e.ParamArmLA=M.ParamArmLA,e.ParamArmLB=M.ParamArmLB,e.ParamArmRA=M.ParamArmRA,e.ParamArmRB=M.ParamArmRB,e.ParamBaseX=M.ParamBaseX,e.ParamBaseY=M.ParamBaseY,e.ParamBodyAngleX=M.ParamBodyAngleX,e.ParamBodyAngleY=M.ParamBodyAngleY,e.ParamBodyAngleZ=M.ParamBodyAngleZ,e.ParamBreath=M.ParamBreath,e.ParamBrowLAngle=M.ParamBrowLAngle,e.ParamBrowLForm=M.ParamBrowLForm,e.ParamBrowLX=M.ParamBrowLX,e.ParamBrowLY=M.ParamBrowLY,e.ParamBrowRAngle=M.ParamBrowRAngle,e.ParamBrowRForm=M.ParamBrowRForm,e.ParamBrowRX=M.ParamBrowRX,e.ParamBrowRY=M.ParamBrowRY,e.ParamBustX=M.ParamBustX,e.ParamBustY=M.ParamBustY,e.ParamCheek=M.ParamCheek,e.ParamEyeBallForm=M.ParamEyeBallForm,e.ParamEyeBallX=M.ParamEyeBallX,e.ParamEyeBallY=M.ParamEyeBallY,e.ParamEyeLOpen=M.ParamEyeLOpen,e.ParamEyeLSmile=M.ParamEyeLSmile,e.ParamEyeROpen=M.ParamEyeROpen,e.ParamEyeRSmile=M.ParamEyeRSmile,e.ParamHairBack=M.ParamHairBack,e.ParamHairFluffy=M.ParamHairFluffy,e.ParamHairFront=M.ParamHairFront,e.ParamHairSide=M.ParamHairSide,e.ParamHandL=M.ParamHandL,e.ParamHandR=M.ParamHandR,e.ParamMouthForm=M.ParamMouthForm,e.ParamMouthOpenY=M.ParamMouthOpenY,e.ParamNONE=M.ParamNONE,e.ParamShoulderY=M.ParamShoulderY,e.PartsArmLPrefix=M.PartsArmLPrefix,e.PartsArmPrefix=M.PartsArmPrefix,e.PartsArmRPrefix=M.PartsArmRPrefix,e.PartsIdCore=M.PartsIdCore})(jr||(jr={}));_s=class{};(function(e){e.ICubismModelSetting=_s})(qr||(qr={}));Cs=class ut{static createIdInternal(t){return new ut(t)}getString(){return this._id}isEqual(t){return typeof t=="string"?this._id==t:t instanceof ut?this._id==t._id:!1}isNotEqual(t){return typeof t=="string"?this._id!=t:t instanceof ut?this._id!=t._id:!1}constructor(t){this._id=t}_id};(function(e){e.CubismId=Cs})(Zr||(Zr={}));ys=class{constructor(){this._ids=new Array}release(){for(let e=0;e<this._ids.length;++e)this._ids[e]=void 0;this._ids=null}registerIds(e){for(let t=0;t<e.length;t++)this.registerId(e[t])}registerId(e){let t=null;if(typeof e=="string"){if((t=this.findId(e))!=null)return t;t=Cs.createIdInternal(e),this._ids.push(t)}else return this.registerId(e);return t}getId(e){return this.registerId(e)}isExist(e){return typeof e=="string"?this.findId(e)!=null:this.isExist(e)}findId(e){for(let t=0;t<this._ids.length;++t)if(this._ids[t].getString()==e)return this._ids[t];return null}_ids};(function(e){e.CubismIdManager=ys})(Kr||(Kr={}));E=class Be{x;y;constructor(t,r){this.x=t,this.y=r,this.x=t??0,this.y=r??0}add(t){let r=new Be(0,0);return r.x=this.x+t.x,r.y=this.y+t.y,r}substract(t){let r=new Be(0,0);return r.x=this.x-t.x,r.y=this.y-t.y,r}multiply(t){let r=new Be(0,0);return r.x=this.x*t.x,r.y=this.y*t.y,r}multiplyByScaler(t){return this.multiply(new Be(t,t))}division(t){let r=new Be(0,0);return r.x=this.x/t.x,r.y=this.y/t.y,r}divisionByScalar(t){return this.division(new Be(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){let t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}};(function(e){e.CubismVector2=E})($r||($r={}));x=class ht{static Epsilon=1e-5;static range(t,r,i){return t<r?t=r:t>i&&(t=i),t}static sin(t){return Math.sin(t)}static cos(t){return Math.cos(t)}static abs(t){return Math.abs(t)}static sqrt(t){return Math.sqrt(t)}static cbrt(t){if(t===0)return t;let r=t,i=r<0;i&&(r=-r);let s;return r===1/0?s=1/0:(s=Math.exp(Math.log(r)/3),s=(r/(s*s)+2*s)/3),i?-s:s}static getEasingSine(t){return t<0?0:t>1?1:.5-.5*this.cos(t*Math.PI)}static max(t,r){return t>r?t:r}static min(t,r){return t>r?r:t}static clamp(t,r,i){return t<r?r:i<t?i:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return t*180/Math.PI}static directionToRadian(t,r){let i=Math.atan2(r.y,r.x)-Math.atan2(t.y,t.x);for(;i<-Math.PI;)i+=Math.PI*2;for(;i>Math.PI;)i-=Math.PI*2;return i}static directionToDegrees(t,r){let i=this.directionToRadian(t,r),s=this.radianToDegrees(i);return r.x-t.x>0&&(s=-s),s}static radianToDirection(t){let r=new E;return r.x=this.sin(t),r.y=this.cos(t),r}static quadraticEquation(t,r,i){return this.abs(t)<ht.Epsilon?this.abs(r)<ht.Epsilon?-i:-i/r:-(r+this.sqrt(r*r-4*t*i))/(2*t)}static cardanoAlgorithmForBezier(t,r,i,s){if(this.abs(t)<ht.Epsilon)return this.range(this.quadraticEquation(r,i,s),0,1);let n=r/t,a=i/t,l=s/t,o=(3*a-n*n)/3,u=o/3,c=(2*n*n*n-9*n*a+27*l)/27,g=c/2,h=g*g+u*u*u,d=.5,f=.51;if(h<0){let _=-o/3,b=_*_*_,C=this.sqrt(b),B=-c/(2*C),I=this.range(B,-1,1),y=Math.acos(I),w=2*this.cbrt(C),L=w*this.cos(y/3)-n/3;if(this.abs(L-d)<f)return this.range(L,0,1);let D=w*this.cos((y+2*Math.PI)/3)-n/3;if(this.abs(D-d)<f)return this.range(D,0,1);let O=w*this.cos((y+4*Math.PI)/3)-n/3;return this.range(O,0,1)}if(h==0){let _;g<0?_=this.cbrt(-g):_=-this.cbrt(g);let b=2*_-n/3;if(this.abs(b-d)<f)return this.range(b,0,1);let C=-_-n/3;return this.range(C,0,1)}let p=this.sqrt(h),A=this.cbrt(p-g)-this.cbrt(p+g)-n/3;return this.range(A,0,1)}static mod(t,r){if(!isFinite(t)||r===0||isNaN(t)||isNaN(r))return console.warn(`divided: ${t}, divisor: ${r} mod() returns 'NaN'.`),NaN;let i=Math.abs(t),s=Math.abs(r),n=i-Math.floor(i/s)*s;return n*=Math.sign(t),n}constructor(){}};(function(e){e.CubismMath=x})(ei||(ei={}));ae=class Re{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,r,i){let s=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),n=4;for(let a=0;a<n;++a)for(let l=0;l<n;++l)for(let o=0;o<n;++o)s[l+a*4]+=t[o+a*4]*r[l+o*4];for(let a=0;a<16;++a)i[a]=s[a]}loadIdentity(){let t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let r=0;r<16;++r)this._tr[r]=t[r]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,r){let i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,r,0,1]);Re.multiply(i,this._tr,this._tr)}translate(t,r){this._tr[12]=t,this._tr[13]=r}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,r){let i=new Float32Array([t,0,0,0,0,r,0,0,0,0,1,0,0,0,0,1]);Re.multiply(i,this._tr,this._tr)}scale(t,r){this._tr[0]=t,this._tr[5]=r}multiplyByMatrix(t){Re.multiply(t.getArray(),this._tr,this._tr)}getInvert(){let t=this._tr[0],r=this._tr[1],i=this._tr[2],s=this._tr[4],n=this._tr[5],a=this._tr[6],l=this._tr[8],o=this._tr[9],u=this._tr[10],c=this._tr[12],g=this._tr[13],h=this._tr[14],d=t*(n*u-o*a)-s*(r*u-o*i)+l*(r*a-n*i),f=new Re;if(x.abs(d)<x.Epsilon)return f.loadIdentity(),f;let p=1/d,A=(n*u-o*a)*p,_=-(s*u-l*a)*p,b=(s*o-l*n)*p,C=-(r*u-o*i)*p,B=(t*u-l*i)*p,I=-(t*o-l*r)*p,y=(r*a-n*i)*p,w=-(t*a-s*i)*p,L=(t*n-s*r)*p;return f._tr[0]=A,f._tr[1]=C,f._tr[2]=y,f._tr[3]=0,f._tr[4]=_,f._tr[5]=B,f._tr[6]=w,f._tr[7]=0,f._tr[8]=b,f._tr[9]=I,f._tr[10]=L,f._tr[11]=0,f._tr[12]=-(A*c+_*g+b*h),f._tr[13]=-(C*c+B*g+I*h),f._tr[14]=-(y*c+w*g+L*h),f._tr[15]=1,f}clone(){let t=new Re;for(let r=0;r<this._tr.length;r++)t._tr[r]=this._tr[r];return t}_tr};(function(e){e.CubismMatrix44=ae})(ti||(ti={}));$n=(e,t,r)=>{ir.print(e,"[CSM]"+t,r)},pt=(e,t,r)=>{$n(e,t+`
|
|
3
|
+
`,r)},U=e=>{e||console.assert(e)};Wt=(e,...t)=>{pt(1,"[D]"+e,t)};ge=(e,...t)=>{pt(2,"[I]"+e,t)};k=(e,...t)=>{pt(3,"[W]"+e,t)};T=(e,...t)=>{pt(4,"[E]"+e,t)};ir=class{static print(e,t,r){if(e<P.getLoggingLevel())return;let i=P.coreLogFunction;i&&i(t.replace(/\{(\d+)\}/g,(s,n)=>r[n]))}static dumpBytes(e,t,r){for(let i=0;i<r;i++)i%16==0&&i>0?this.print(e,`
|
|
4
4
|
`):i%8==0&&i>0&&this.print(e," "),this.print(e,"{0} ",[t[i]&255]);this.print(e,`
|
|
5
|
-
`)}constructor(){}};(function(e){e.CubismDebug=ir})(ri||(ri={}));Ae=class{constructor(e=!1,t=new R){this.isOverridden=e,this.color=t}isOverridden;color},ea=class{_model;_isOverriddenModelMultiplyColors;_isOverriddenModelScreenColors;_userPartScreenColors;_userPartMultiplyColors;_userDrawableScreenColors;_userDrawableMultiplyColors;_userOffscreenScreenColors;_userOffscreenMultiplyColors;constructor(e){this._model=e,this._isOverriddenModelMultiplyColors=!1,this._isOverriddenModelScreenColors=!1,this._userPartScreenColors=[],this._userPartMultiplyColors=[],this._userDrawableScreenColors=[],this._userDrawableMultiplyColors=[],this._userOffscreenScreenColors=[],this._userOffscreenMultiplyColors=[]}initialize(e,t,r){let i=new Ae(!1,new R(1,1,1,1)),s=new Ae(!1,new R(0,0,0,1));this._userPartMultiplyColors=new Array(e),this._userPartScreenColors=new Array(e);for(let n=0;n<e;n++)this._userPartMultiplyColors[n]=new Ae(i.isOverridden,new R(i.color.r,i.color.g,i.color.b,i.color.a)),this._userPartScreenColors[n]=new Ae(s.isOverridden,new R(s.color.r,s.color.g,s.color.b,s.color.a));this._userDrawableMultiplyColors=new Array(t),this._userDrawableScreenColors=new Array(t);for(let n=0;n<t;n++)this._userDrawableMultiplyColors[n]=new Ae(i.isOverridden,new R(i.color.r,i.color.g,i.color.b,i.color.a)),this._userDrawableScreenColors[n]=new Ae(s.isOverridden,new R(s.color.r,s.color.g,s.color.b,s.color.a));this._userOffscreenMultiplyColors=new Array(r),this._userOffscreenScreenColors=new Array(r);for(let n=0;n<r;n++)this._userOffscreenMultiplyColors[n]=new Ae(i.isOverridden,new R(i.color.r,i.color.g,i.color.b,i.color.a)),this._userOffscreenScreenColors[n]=new Ae(s.isOverridden,new R(s.color.r,s.color.g,s.color.b,s.color.a))}warnIndexOutOfRange(e,t,r){O(`${e}: index is out of range. index=${t}, valid range=[0, ${r}].`)}isValidPartIndex(e,t){return e<0||e>=this._model.getPartCount()?(this.warnIndexOutOfRange(t,e,this._model.getPartCount()-1),!1):!0}isValidDrawableIndex(e,t){return e<0||e>=this._model.getDrawableCount()?(this.warnIndexOutOfRange(t,e,this._model.getDrawableCount()-1),!1):!0}isValidOffscreenIndex(e,t){return e<0||e>=this._model.getOffscreenCount()?(this.warnIndexOutOfRange(t,e,this._model.getOffscreenCount()-1),!1):!0}setMultiplyColorEnabled(e){this._isOverriddenModelMultiplyColors=e}getMultiplyColorEnabled(){return this._isOverriddenModelMultiplyColors}setScreenColorEnabled(e){this._isOverriddenModelScreenColors=e}getScreenColorEnabled(){return this._isOverriddenModelScreenColors}setPartMultiplyColorEnabled(e,t){this.isValidPartIndex(e,"setPartMultiplyColorEnabled")&&this.setPartColorEnabled(e,t,this._userPartMultiplyColors,this._userDrawableMultiplyColors,this._userOffscreenMultiplyColors)}getPartMultiplyColorEnabled(e){return this.isValidPartIndex(e,"getPartMultiplyColorEnabled")?this._userPartMultiplyColors[e].isOverridden:!1}setPartScreenColorEnabled(e,t){this.isValidPartIndex(e,"setPartScreenColorEnabled")&&this.setPartColorEnabled(e,t,this._userPartScreenColors,this._userDrawableScreenColors,this._userOffscreenScreenColors)}getPartScreenColorEnabled(e){return this.isValidPartIndex(e,"getPartScreenColorEnabled")?this._userPartScreenColors[e].isOverridden:!1}setPartMultiplyColorByTextureColor(e,t){this.isValidPartIndex(e,"setPartMultiplyColorByTextureColor")&&this.setPartMultiplyColorByRGBA(e,t.r,t.g,t.b,t.a)}setPartMultiplyColorByRGBA(e,t,r,i,s=1){this.isValidPartIndex(e,"setPartMultiplyColorByRGBA")&&this.setPartColor(e,t,r,i,s,this._userPartMultiplyColors,this._userDrawableMultiplyColors,this._userOffscreenMultiplyColors)}getPartMultiplyColor(e){return this.isValidPartIndex(e,"getPartMultiplyColor")?this._userPartMultiplyColors[e].color:new R(1,1,1,1)}setPartScreenColorByTextureColor(e,t){this.isValidPartIndex(e,"setPartScreenColorByTextureColor")&&this.setPartScreenColorByRGBA(e,t.r,t.g,t.b,t.a)}setPartScreenColorByRGBA(e,t,r,i,s=1){this.isValidPartIndex(e,"setPartScreenColorByRGBA")&&this.setPartColor(e,t,r,i,s,this._userPartScreenColors,this._userDrawableScreenColors,this._userOffscreenScreenColors)}getPartScreenColor(e){return this.isValidPartIndex(e,"getPartScreenColor")?this._userPartScreenColors[e].color:new R(0,0,0,1)}setDrawableMultiplyColorEnabled(e,t){this.isValidDrawableIndex(e,"setDrawableMultiplyColorEnabled")&&(this._userDrawableMultiplyColors[e].isOverridden=t)}getDrawableMultiplyColorEnabled(e){return this.isValidDrawableIndex(e,"getDrawableMultiplyColorEnabled")?this._userDrawableMultiplyColors[e].isOverridden:!1}setDrawableScreenColorEnabled(e,t){this.isValidDrawableIndex(e,"setDrawableScreenColorEnabled")&&(this._userDrawableScreenColors[e].isOverridden=t)}getDrawableScreenColorEnabled(e){return this.isValidDrawableIndex(e,"getDrawableScreenColorEnabled")?this._userDrawableScreenColors[e].isOverridden:!1}setDrawableMultiplyColorByTextureColor(e,t){this.isValidDrawableIndex(e,"setDrawableMultiplyColorByTextureColor")&&this.setDrawableMultiplyColorByRGBA(e,t.r,t.g,t.b,t.a)}setDrawableMultiplyColorByRGBA(e,t,r,i,s=1){this.isValidDrawableIndex(e,"setDrawableMultiplyColorByRGBA")&&(this._userDrawableMultiplyColors[e].color.r=t,this._userDrawableMultiplyColors[e].color.g=r,this._userDrawableMultiplyColors[e].color.b=i,this._userDrawableMultiplyColors[e].color.a=s)}getDrawableMultiplyColor(e){return this.isValidDrawableIndex(e,"getDrawableMultiplyColor")?this.getMultiplyColorEnabled()||this.getDrawableMultiplyColorEnabled(e)?this._userDrawableMultiplyColors[e].color:this._model.getDrawableMultiplyColor(e):new R(1,1,1,1)}setDrawableScreenColorByTextureColor(e,t){this.isValidDrawableIndex(e,"setDrawableScreenColorByTextureColor")&&this.setDrawableScreenColorByRGBA(e,t.r,t.g,t.b,t.a)}setDrawableScreenColorByRGBA(e,t,r,i,s=1){this.isValidDrawableIndex(e,"setDrawableScreenColorByRGBA")&&(this._userDrawableScreenColors[e].color.r=t,this._userDrawableScreenColors[e].color.g=r,this._userDrawableScreenColors[e].color.b=i,this._userDrawableScreenColors[e].color.a=s)}getDrawableScreenColor(e){return this.isValidDrawableIndex(e,"getDrawableScreenColor")?this.getScreenColorEnabled()||this.getDrawableScreenColorEnabled(e)?this._userDrawableScreenColors[e].color:this._model.getDrawableScreenColor(e):new R(0,0,0,1)}setOffscreenMultiplyColorEnabled(e,t){this.isValidOffscreenIndex(e,"setOffscreenMultiplyColorEnabled")&&(this._userOffscreenMultiplyColors[e].isOverridden=t)}getOffscreenMultiplyColorEnabled(e){return this.isValidOffscreenIndex(e,"getOffscreenMultiplyColorEnabled")?this._userOffscreenMultiplyColors[e].isOverridden:!1}setOffscreenScreenColorEnabled(e,t){this.isValidOffscreenIndex(e,"setOffscreenScreenColorEnabled")&&(this._userOffscreenScreenColors[e].isOverridden=t)}getOffscreenScreenColorEnabled(e){return this.isValidOffscreenIndex(e,"getOffscreenScreenColorEnabled")?this._userOffscreenScreenColors[e].isOverridden:!1}setOffscreenMultiplyColorByTextureColor(e,t){this.isValidOffscreenIndex(e,"setOffscreenMultiplyColorByTextureColor")&&this.setOffscreenMultiplyColorByRGBA(e,t.r,t.g,t.b,t.a)}setOffscreenMultiplyColorByRGBA(e,t,r,i,s=1){this.isValidOffscreenIndex(e,"setOffscreenMultiplyColorByRGBA")&&(this._userOffscreenMultiplyColors[e].color.r=t,this._userOffscreenMultiplyColors[e].color.g=r,this._userOffscreenMultiplyColors[e].color.b=i,this._userOffscreenMultiplyColors[e].color.a=s)}getOffscreenMultiplyColor(e){return this.isValidOffscreenIndex(e,"getOffscreenMultiplyColor")?this.getMultiplyColorEnabled()||this.getOffscreenMultiplyColorEnabled(e)?this._userOffscreenMultiplyColors[e].color:this._model.getOffscreenMultiplyColor(e):new R(1,1,1,1)}setOffscreenScreenColorByTextureColor(e,t){this.isValidOffscreenIndex(e,"setOffscreenScreenColorByTextureColor")&&this.setOffscreenScreenColorByRGBA(e,t.r,t.g,t.b,t.a)}setOffscreenScreenColorByRGBA(e,t,r,i,s=1){this.isValidOffscreenIndex(e,"setOffscreenScreenColorByRGBA")&&(this._userOffscreenScreenColors[e].color.r=t,this._userOffscreenScreenColors[e].color.g=r,this._userOffscreenScreenColors[e].color.b=i,this._userOffscreenScreenColors[e].color.a=s)}getOffscreenScreenColor(e){return this.isValidOffscreenIndex(e,"getOffscreenScreenColor")?this.getScreenColorEnabled()||this.getOffscreenScreenColorEnabled(e)?this._userOffscreenScreenColors[e].color:this._model.getOffscreenScreenColor(e):new R(0,0,0,1)}setPartColor(e,t,r,i,s,n,a,l){if(n[e].color.r=t,n[e].color.g=r,n[e].color.b=i,n[e].color.a=s,n[e].isOverridden){let o=this._model.getPartOffscreenIndices()[e];if(o==-1){let u=this._model.getPartsHierarchy();if(u&&u[e])for(let h=0;h<u[e].objects.length;++h){let d=u[e].objects[h];if(d.objectType===0){let c=d.objectIndex;a[c].color.r=t,a[c].color.g=r,a[c].color.b=i,a[c].color.a=s}else{let c=d.objectIndex;this.setPartColor(c,t,r,i,s,n,a,l)}}}else l[o].color.r=t,l[o].color.g=r,l[o].color.b=i,l[o].color.a=s}}setPartColorEnabled(e,t,r,i,s){r[e].isOverridden=t;let n=this._model.getPartOffscreenIndices()[e];if(n==-1){let a=this._model.getPartsHierarchy();if(a&&a[e])for(let l=0;l<a[e].objects.length;++l){let o=a[e].objects[l];if(o.objectType===0){let u=o.objectIndex;i[u].isOverridden=t,t&&(i[u].color.r=r[e].color.r,i[u].color.g=r[e].color.g,i[u].color.b=r[e].color.b,i[u].color.a=r[e].color.a)}else{let u=o.objectIndex;t&&(r[u].color.r=r[e].color.r,r[u].color.g=r[e].color.g,r[u].color.b=r[e].color.b,r[u].color.a=r[e].color.a),this.setPartColorEnabled(u,t,r,i,s)}}}else s[n].isOverridden=t,t&&(s[n].color.r=r[e].color.r,s[n].color.g=r[e].color.g,s[n].color.b=r[e].color.b,s[n].color.a=r[e].color.a)}},V=(function(e){return e[e.ColorBlend_None=-1]="ColorBlend_None",e[e.ColorBlend_Normal=Live2DCubismCore.ColorBlendType_Normal]="ColorBlend_Normal",e[e.ColorBlend_AddGlow=Live2DCubismCore.ColorBlendType_AddGlow]="ColorBlend_AddGlow",e[e.ColorBlend_Add=Live2DCubismCore.ColorBlendType_Add]="ColorBlend_Add",e[e.ColorBlend_Darken=Live2DCubismCore.ColorBlendType_Darken]="ColorBlend_Darken",e[e.ColorBlend_Multiply=Live2DCubismCore.ColorBlendType_Multiply]="ColorBlend_Multiply",e[e.ColorBlend_ColorBurn=Live2DCubismCore.ColorBlendType_ColorBurn]="ColorBlend_ColorBurn",e[e.ColorBlend_LinearBurn=Live2DCubismCore.ColorBlendType_LinearBurn]="ColorBlend_LinearBurn",e[e.ColorBlend_Lighten=Live2DCubismCore.ColorBlendType_Lighten]="ColorBlend_Lighten",e[e.ColorBlend_Screen=Live2DCubismCore.ColorBlendType_Screen]="ColorBlend_Screen",e[e.ColorBlend_ColorDodge=Live2DCubismCore.ColorBlendType_ColorDodge]="ColorBlend_ColorDodge",e[e.ColorBlend_Overlay=Live2DCubismCore.ColorBlendType_Overlay]="ColorBlend_Overlay",e[e.ColorBlend_SoftLight=Live2DCubismCore.ColorBlendType_SoftLight]="ColorBlend_SoftLight",e[e.ColorBlend_HardLight=Live2DCubismCore.ColorBlendType_HardLight]="ColorBlend_HardLight",e[e.ColorBlend_LinearLight=Live2DCubismCore.ColorBlendType_LinearLight]="ColorBlend_LinearLight",e[e.ColorBlend_Hue=Live2DCubismCore.ColorBlendType_Hue]="ColorBlend_Hue",e[e.ColorBlend_Color=Live2DCubismCore.ColorBlendType_Color]="ColorBlend_Color",e[e.ColorBlend_AddCompatible=Live2DCubismCore.ColorBlendType_AddCompatible]="ColorBlend_AddCompatible",e[e.ColorBlend_MultiplyCompatible=Live2DCubismCore.ColorBlendType_MultiplyCompatible]="ColorBlend_MultiplyCompatible",e})({}),Tt=(function(e){return e[e.AlphaBlend_None=-1]="AlphaBlend_None",e[e.AlphaBlend_Over=0]="AlphaBlend_Over",e[e.AlphaBlend_Atop=1]="AlphaBlend_Atop",e[e.AlphaBlend_Out=2]="AlphaBlend_Out",e[e.AlphaBlend_ConjointOver=3]="AlphaBlend_ConjointOver",e[e.AlphaBlend_DisjointOver=4]="AlphaBlend_DisjointOver",e})({}),ta=class{constructor(e=!1,t=!1){this.isOverridden=e,this.isParameterRepeated=t}isOverridden;isParameterRepeated},ii=class{constructor(e=!1,t=!1){this.isOverridden=e,this.isCulling=t}isOverridden;isCulling},ra=class{drawableIndices;offscreenIndices;constructor(e=new Array,t=new Array){this.drawableIndices=e,this.offscreenIndices=t}},si=class{objectType;objectIndex;constructor(e,t){this.objectIndex=e,this.objectType=t}},ia=class{objects;childDrawObjects;constructor(e=new Array,t=new ra){this.objects=e,this.childDrawObjects=t}getChildObjectCount(){return this.objects.length}},bs=class{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return this._model==null?0:this._model.canvasinfo.PixelsPerUnit}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){let e=this._model.parameters.count,t=this._savedParameters.length;for(let r=0;r<e;++r)r<t?this._savedParameters[r]=this._parameterValues[r]:this._savedParameters.push(this._parameterValues[r])}getOverrideMultiplyAndScreenColor(){return this._overrideMultiplyAndScreenColor}getOverrideFlagForModelParameterRepeat(){return this._isOverriddenParameterRepeat}setOverrideFlagForModelParameterRepeat(e){this._isOverriddenParameterRepeat=e}getOverrideFlagForParameterRepeat(e){return this._userParameterRepeatDataList[e].isOverridden}setOverrideFlagForParameterRepeat(e,t){this._userParameterRepeatDataList[e].isOverridden=t}getRepeatFlagForParameterRepeat(e){return this._userParameterRepeatDataList[e].isParameterRepeated}setRepeatFlagForParameterRepeat(e,t){this._userParameterRepeatDataList[e].isParameterRepeated=t}getDrawableCulling(e){if(this.getOverrideFlagForModelCullings()||this.getOverrideFlagForDrawableCullings(e))return this._userDrawableCullings[e].isCulling;let t=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(t[e])}setDrawableCulling(e,t){this._userDrawableCullings[e].isCulling=t}getOffscreenCulling(e){if(this.getOverrideFlagForModelCullings()||this.getOverrideFlagForOffscreenCullings(e))return this._userOffscreenCullings[e].isCulling;let t=this._model.offscreens.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(t[e])}setOffscreenCulling(e,t){this._userOffscreenCullings[e].isCulling=t}getOverrideFlagForModelCullings(){return this._isOverriddenCullings}setOverrideFlagForModelCullings(e){this._isOverriddenCullings=e}getOverrideFlagForDrawableCullings(e){return this._userDrawableCullings[e].isOverridden}getOverrideFlagForOffscreenCullings(e){return this._userOffscreenCullings[e].isOverridden}setOverrideFlagForDrawableCullings(e,t){this._userDrawableCullings[e].isOverridden=t}getModelOapcity(){return this._modelOpacity}setModelOapcity(e){this._modelOpacity=e}getModel(){return this._model}getPartIndex(e){let t,r=this._model.parts.count;for(t=0;t<r;++t)if(e==this._partIds[t])return t;return this._notExistPartId.has(e)?this._notExistPartId.get(e):(t=r+this._notExistPartId.size,this._notExistPartId.set(e,t),this._notExistPartOpacities.set(t,null),t)}getPartId(e){let t=this._model.parts.ids[e];return P.getIdManager().getId(t)}getPartCount(){return this._model.parts.count}getPartOffscreenIndices(){return this._model.parts.offscreenIndices}getPartParentPartIndices(){return this._model.parts.parentIndices}setPartOpacityByIndex(e,t){if(this._notExistPartOpacities.has(e)){this._notExistPartOpacities.set(e,t);return}Q(0<=e&&e<this.getPartCount()),this._partOpacities[e]=t}setPartOpacityById(e,t){let r=this.getPartIndex(e);r<0||this.setPartOpacityByIndex(r,t)}getPartOpacityByIndex(e){return this._notExistPartOpacities.has(e)?this._notExistPartOpacities.get(e):(Q(0<=e&&e<this.getPartCount()),this._partOpacities[e])}getPartOpacityById(e){let t=this.getPartIndex(e);return t<0?0:this.getPartOpacityByIndex(t)}getParameterIndex(e){let t,r=this._model.parameters.count;for(t=0;t<r;++t)if(e==this._parameterIds[t])return t;return this._notExistParameterId.has(e)?this._notExistParameterId.get(e):(t=this._model.parameters.count+this._notExistParameterId.size,this._notExistParameterId.set(e,t),this._notExistParameterValues.set(t,null),t)}getParameterCount(){return this._model.parameters.count}getParameterType(e){return this._model.parameters.types[e]}getParameterMaximumValue(e){return this._model.parameters.maximumValues[e]}getParameterMinimumValue(e){return this._model.parameters.minimumValues[e]}getParameterDefaultValue(e){return this._model.parameters.defaultValues[e]}getParameterId(e){return P.getIdManager().getId(this._model.parameters.ids[e])}getParameterValueByIndex(e){return this._notExistParameterValues.has(e)?this._notExistParameterValues.get(e):(Q(0<=e&&e<this.getParameterCount()),this._parameterValues[e])}getParameterValueById(e){let t=this.getParameterIndex(e);return this.getParameterValueByIndex(t)}setParameterValueByIndex(e,t,r=1){if(this._notExistParameterValues.has(e)){this._notExistParameterValues.set(e,r==1?t:this._notExistParameterValues.get(e)*(1-r)+t*r);return}Q(0<=e&&e<this.getParameterCount()),this.isRepeat(e)?t=this.getParameterRepeatValue(e,t):t=this.getParameterClampValue(e,t),this._parameterValues[e]=r==1?t:this._parameterValues[e]=this._parameterValues[e]*(1-r)+t*r}setParameterValueById(e,t,r=1){let i=this.getParameterIndex(e);this.setParameterValueByIndex(i,t,r)}addParameterValueByIndex(e,t,r=1){this.setParameterValueByIndex(e,this.getParameterValueByIndex(e)+t*r)}addParameterValueById(e,t,r=1){let i=this.getParameterIndex(e);this.addParameterValueByIndex(i,t,r)}isRepeat(e){if(this._notExistParameterValues.has(e))return!1;Q(0<=e&&e<this.getParameterCount());let t;return this._isOverriddenParameterRepeat||this._userParameterRepeatDataList[e].isOverridden?t=this._userParameterRepeatDataList[e].isParameterRepeated:t=this._model.parameters.repeats[e]!=0,t}getParameterRepeatValue(e,t){if(this._notExistParameterValues.has(e))return t;Q(0<=e&&e<this.getParameterCount());let r=this._model.parameters.maximumValues[e],i=this._model.parameters.minimumValues[e],s=r-i;if(r<t){let n=w.mod(t-r,s);Number.isNaN(n)?t=r:t=i+n}if(t<i){let n=w.mod(i-t,s);Number.isNaN(n)?t=i:t=r-n}return t}getParameterClampValue(e,t){if(this._notExistParameterValues.has(e))return t;Q(0<=e&&e<this.getParameterCount());let r=this._model.parameters.maximumValues[e],i=this._model.parameters.minimumValues[e];return w.clamp(t,i,r)}getParameterRepeats(e){return this._model.parameters.repeats[e]!=0}multiplyParameterValueById(e,t,r=1){let i=this.getParameterIndex(e);this.multiplyParameterValueByIndex(i,t,r)}multiplyParameterValueByIndex(e,t,r=1){this.setParameterValueByIndex(e,this.getParameterValueByIndex(e)*(1+(t-1)*r))}getDrawableIndex(e){let t=this._model.drawables.count;for(let r=0;r<t;++r)if(this._drawableIds[r]==e)return r;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(e){let t=this._model.drawables.ids;return P.getIdManager().getId(t[e])}getRenderOrders(){return this._model.getRenderOrders()}getDrawableTextureIndex(e){return this._model.drawables.textureIndices[e]}getDrawableDynamicFlagVertexPositionsDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(t[e])}getDrawableVertexIndexCount(e){return this._model.drawables.indexCounts[e]}getDrawableVertexCount(e){return this._model.drawables.vertexCounts[e]}getDrawableVertices(e){return this.getDrawableVertexPositions(e)}getDrawableVertexIndices(e){return this._model.drawables.indices[e]}getDrawableVertexPositions(e){return this._model.drawables.vertexPositions[e]}getDrawableVertexUvs(e){return this._model.drawables.vertexUvs[e]}getDrawableOpacity(e){return this._model.drawables.opacities[e]}getDrawableMultiplyColor(e){this._drawableMultiplyColors==null&&(this._drawableMultiplyColors=new Array(this._model.drawables.count),this._drawableMultiplyColors.fill(new R));let t=this._model.drawables.multiplyColors,r=e*4;return this._drawableMultiplyColors[e].r=t[r],this._drawableMultiplyColors[e].g=t[r+1],this._drawableMultiplyColors[e].b=t[r+2],this._drawableMultiplyColors[e].a=t[r+3],this._drawableMultiplyColors[e]}getDrawableScreenColor(e){this._drawableScreenColors==null&&(this._drawableScreenColors=new Array(this._model.drawables.count),this._drawableScreenColors.fill(new R));let t=this._model.drawables.screenColors,r=e*4;return this._drawableScreenColors[e].r=t[r],this._drawableScreenColors[e].g=t[r+1],this._drawableScreenColors[e].b=t[r+2],this._drawableScreenColors[e].a=t[r+3],this._drawableScreenColors[e]}getOffscreenMultiplyColor(e){this._offscreenMultiplyColors==null&&(this._offscreenMultiplyColors=new Array(this._model.offscreens.count),this._offscreenMultiplyColors.fill(new R));let t=this._model.offscreens.multiplyColors,r=e*4;return this._offscreenMultiplyColors[e].r=t[r],this._offscreenMultiplyColors[e].g=t[r+1],this._offscreenMultiplyColors[e].b=t[r+2],this._offscreenMultiplyColors[e].a=t[r+3],this._offscreenMultiplyColors[e]}getOffscreenScreenColor(e){this._offscreenScreenColors==null&&(this._offscreenScreenColors=new Array(this._model.offscreens.count),this._offscreenScreenColors.fill(new R));let t=this._model.offscreens.screenColors,r=e*4;return this._offscreenScreenColors[e].r=t[r],this._offscreenScreenColors[e].g=t[r+1],this._offscreenScreenColors[e].b=t[r+2],this._offscreenScreenColors[e].a=t[r+3],this._offscreenScreenColors[e]}getDrawableParentPartIndex(e){return this._model.drawables.parentPartIndices[e]}getDrawableBlendMode(e){let t=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(t[e])?1:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(t[e])?2:0}getDrawableColorBlend(e){return this._drawableColorBlends[e]==-1&&(this._drawableColorBlends[e]=this._model.drawables.blendModes[e]&255),this._drawableColorBlends[e]}getDrawableAlphaBlend(e){return this._drawableAlphaBlends[e]==-1&&(this._drawableAlphaBlends[e]=this._model.drawables.blendModes[e]>>8&255),this._drawableAlphaBlends[e]}getDrawableInvertedMaskBit(e){let t=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(t[e])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let e=0;e<this._model.drawables.count;++e)if(!(this._model.drawables.maskCounts[e]<=0))return!0;return!1}isUsingMaskingForOffscreen(){for(let e=0;e<this.getOffscreenCount();++e)if(!(this._model.offscreens.maskCounts[e]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(t[e])}getDrawableDynamicFlagVisibilityDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(t[e])}getDrawableDynamicFlagOpacityDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(t[e])}getDrawableDynamicFlagRenderOrderDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(t[e])}getDrawableDynamicFlagBlendColorDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(t[e])}getOffscreenCount(){return this._model.offscreens.count}getOffscreenColorBlend(e){return this._offscreenColorBlends[e]==-1&&(this._offscreenColorBlends[e]=this._model.offscreens.blendModes[e]&255),this._offscreenColorBlends[e]}getOffscreenAlphaBlend(e){return this._offscreenAlphaBlends[e]==-1&&(this._offscreenAlphaBlends[e]=this._model.offscreens.blendModes[e]>>8&255),this._offscreenAlphaBlends[e]}getOffscreenOwnerIndices(){return this._model.offscreens.ownerIndices}getOffscreenOpacity(e){return e<0||e>=this._model.offscreens.count?1:this._model.offscreens.opacities[e]}getOffscreenMasks(){return this._model.offscreens.masks}getOffscreenMaskCounts(){return this._model.offscreens.maskCounts}getOffscreenInvertedMask(e){let t=this._model.offscreens.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(t[e])}isBlendModeEnabled(){return this._isBlendModeEnabled}loadParameters(){let e=this._model.parameters.count,t=this._savedParameters.length;e>t&&(e=t);for(let r=0;r<e;++r)this._parameterValues[r]=this._savedParameters[r]}initialize(){Q(this._model),this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._offscreenOpacities=this._model.offscreens.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{let t=this._model.parameters.ids,r=this._model.parameters.count;this._parameterIds.length=r,this._userParameterRepeatDataList.length=r;for(let i=0;i<r;++i)this._parameterIds[i]=P.getIdManager().getId(t[i]),this._userParameterRepeatDataList[i]=new ta(!1,!1)}let e=this._model.parts.count;{let t=this._model.parts.ids;this._partIds.length=e;for(let r=0;r<e;++r)this._partIds[r]=P.getIdManager().getId(t[r])}{let t=this._model.drawables.ids,r=this._model.drawables.count;this._userDrawableCullings.length=r;let i=new ii(!1,!1);this._userOffscreenCullings.length=this._model.offscreens.count;let s=new ii(!1,!1);for(let a=0;a<r;++a)this._drawableIds.push(P.getIdManager().getId(t[a])),this._userDrawableCullings[a]=i;for(let a=0;a<this._model.offscreens.count;++a)this._userOffscreenCullings[a]=s;if(this.getOffscreenCount()>0)this._isBlendModeEnabled=!0;else{this._model.drawables.blendModes;for(let a=0;a<r;++a){let l=this.getDrawableColorBlend(a),o=this.getDrawableAlphaBlend(a);if(!(l==V.ColorBlend_Normal&&o==0)&&l!=V.ColorBlend_AddCompatible&&l!=V.ColorBlend_MultiplyCompatible){this._isBlendModeEnabled=!0;break}}}this.setupPartsHierarchy();let n=this.getOffscreenCount();this._overrideMultiplyAndScreenColor.initialize(e,r,n)}}getPartsHierarchy(){return this._partsHierarchy}setupPartsHierarchy(){this._partsHierarchy.length=0;let e=this.getPartCount();this._partsHierarchy.length=e;for(let r=0;r<e;++r){let i=new ia;this._partsHierarchy[r]=i}for(let r=0;r<e;++r){let i=this.getPartParentPartIndices()[r];if(i!==-1){for(let s=0;s<this._partsHierarchy.length;++s)if(s===i){let n=new si(r,1);this._partsHierarchy[s].objects.push(n);break}}}let t=this.getDrawableCount();for(let r=0;r<t;++r){let i=this.getDrawableParentPartIndex(r);if(i!==-1){for(let s=0;s<this._partsHierarchy.length;++s)if(s===i){let n=new si(r,0);this._partsHierarchy[s].objects.push(n);break}}}for(let r=0;r<this._partsHierarchy.length;++r)this.getPartChildDrawObjects(r)}getPartChildDrawObjects(e){if(this._partsHierarchy[e].getChildObjectCount()<1)return this._partsHierarchy[e].childDrawObjects;let t=this._partsHierarchy[e].childDrawObjects;if(t.drawableIndices.length!==0||t.offscreenIndices.length!==0)return t;let r=this._partsHierarchy[e].objects;for(let i=0;i<r.length;++i){let s=r[i];if(s.objectType===1){this.getPartChildDrawObjects(s.objectIndex);let n=this._partsHierarchy[s.objectIndex].childDrawObjects;t.drawableIndices.push(...n.drawableIndices),t.offscreenIndices.push(...n.offscreenIndices);let a=this.getOffscreenIndices(),l=a?a[s.objectIndex]:-1;l!==-1&&t.offscreenIndices.push(l)}else s.objectType===0&&t.drawableIndices.push(s.objectIndex)}return t}getOffscreenIndices(){return this._model.parts.offscreenIndices}constructor(e){this._model=e,this._parameterValues=null,this._parameterMaximumValues=null,this._parameterMinimumValues=null,this._partOpacities=null,this._offscreenOpacities=null,this._savedParameters=new Array,this._parameterIds=new Array,this._drawableIds=new Array,this._partIds=new Array,this._isOverriddenParameterRepeat=!0,this._isOverriddenCullings=!1,this._modelOpacity=1,this._overrideMultiplyAndScreenColor=new ea(this),this._isBlendModeEnabled=!1,this._drawableColorBlends=null,this._drawableAlphaBlends=null,this._offscreenColorBlends=null,this._offscreenAlphaBlends=null,this._drawableMultiplyColors=null,this._drawableScreenColors=null,this._offscreenMultiplyColors=null,this._offscreenScreenColors=null,this._userParameterRepeatDataList=new Array,this._userDrawableCullings=new Array,this._userOffscreenCullings=new Array,this._partsHierarchy=new Array,this._notExistPartId=new Map,this._notExistParameterId=new Map,this._notExistParameterValues=new Map,this._notExistPartOpacities=new Map,this._drawableColorBlends=new Array(e.drawables.count).fill(-1),this._drawableAlphaBlends=new Array(e.drawables.count).fill(-1),this._offscreenColorBlends=new Array(e.offscreens.count).fill(-1),this._offscreenAlphaBlends=new Array(e.offscreens.count).fill(-1)}release(){this._model.release(),this._model=null,this._drawableColorBlends=null,this._drawableAlphaBlends=null,this._offscreenColorBlends=null,this._offscreenAlphaBlends=null,this._drawableMultiplyColors=null,this._drawableScreenColors=null,this._offscreenMultiplyColors=null,this._offscreenScreenColors=null}_notExistPartOpacities;_notExistPartId;_notExistParameterValues;_notExistParameterId;_savedParameters;_isOverriddenParameterRepeat;_overrideMultiplyAndScreenColor;_userParameterRepeatDataList;_partsHierarchy;_model;_parameterValues;_parameterMaximumValues;_parameterMinimumValues;_partOpacities;_offscreenOpacities;_modelOpacity;_parameterIds;_partIds;_drawableIds;_isOverriddenCullings;_userDrawableCullings;_userOffscreenCullings;_isBlendModeEnabled;_drawableColorBlends;_drawableAlphaBlends;_offscreenColorBlends;_offscreenAlphaBlends;_drawableMultiplyColors;_drawableScreenColors;_offscreenMultiplyColors;_offscreenScreenColors};(function(e){e.CubismModel=bs})(ni||(ni={}));gt=class{constructor(e,t,r,i){this.x=e,this.y=t,this.width=r,this.height=i}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height}expand(e,t){this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2}x;y;width;height};(function(e){e.csmRect=gt})(ai||(ai={}));mt=class{static create(){return null}static delete(e){e=null}initialize(e){this._model=e,e.isBlendModeEnabled()&&(this.useHighPrecisionMask(!0),ge("This model uses a high-resolution mask because it operates in blend mode."))}drawModel(e=null){this.getModel()!=null&&this.doDrawModel(e)}setMvpMatrix(e){this._mvpMatrix4x4.setMatrix(e.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(e,t,r,i){this._modelColor.r=w.clamp(e,0,1),this._modelColor.g=w.clamp(t,0,1),this._modelColor.b=w.clamp(r,0,1),this._modelColor.a=w.clamp(i,0,1)}getModelColor(){return this._modelColorScratch.r=this._modelColor.r,this._modelColorScratch.g=this._modelColor.g,this._modelColorScratch.b=this._modelColor.b,this._modelColorScratch.a=this._modelColor.a,this._modelColorScratch}getModelColorWithOpacity(e){let t=this._modelColorWithOpacityScratch;return t.r=this._modelColor.r,t.g=this._modelColor.g,t.b=this._modelColor.b,t.a=this._modelColor.a*e,this.isPremultipliedAlpha()&&(t.r*=t.a,t.g*=t.a,t.b*=t.a),t}setIsPremultipliedAlpha(e){this._isPremultipliedAlpha=e}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(e){this._isCulling=e}isCulling(){return this._isCulling}setAnisotropy(e){this._anisotropy=e}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(e){this._useHighPrecisionMask=e}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}setRenderTargetSize(e,t){this._modelRenderTargetWidth=e,this._modelRenderTargetHeight=t}constructor(e,t){this._modelRenderTargetWidth=e,this._modelRenderTargetHeight=t,this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._model=null,this._modelColor=new R,this._modelColorScratch=new R,this._modelColorWithOpacityScratch=new R,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new ne,this._mvpMatrix4x4.loadIdentity()}static staticRelease;_mvpMatrix4x4;_modelColor;_modelColorScratch;_modelColorWithOpacityScratch;_isCulling;_isPremultipliedAlpha;_anisotropy;_model;_useHighPrecisionMask;_modelRenderTargetWidth;_modelRenderTargetHeight},sa=(function(e){return e[e.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",e[e.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",e[e.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",e})({}),R=class{constructor(e=1,t=1,r=1,i=1){this.r=e,this.g=t,this.b=r,this.a=i}r;g;b;a},na=class{constructor(e,t){this._clippingIdList=e,this._clippingIdCount=t,this._allClippedDrawRect=new gt,this._layoutBounds=new gt,this._clippedDrawableIndexList=[],this._clippedOffscreenIndexList=[],this._matrixForMask=new ne,this._matrixForDraw=new ne,this._bufferIndex=0,this._layoutChannelIndex=0}release(){this._layoutBounds!=null&&(this._layoutBounds=null),this._allClippedDrawRect!=null&&(this._allClippedDrawRect=null),this._clippedDrawableIndexList!=null&&(this._clippedDrawableIndexList=null),this._clippedOffscreenIndexList!=null&&(this._clippedOffscreenIndexList=null)}addClippedDrawable(e){this._clippedDrawableIndexList.push(e)}addClippedOffscreen(e){this._clippedOffscreenIndexList.push(e)}_isUsing;_clippingIdList;_clippingIdCount;_layoutChannelIndex;_layoutBounds;_allClippedDrawRect;_matrixForMask;_matrixForDraw;_clippedDrawableIndexList;_clippedOffscreenIndexList;_bufferIndex};(function(e){e.CubismBlendMode=sa,e.CubismRenderer=mt,e.CubismTextureColor=R})(oi||(oi={}));aa=class Yt{static parseJsonObject(t,r){return Object.keys(t).forEach(i=>{if(typeof t[i]=="boolean"){let s=!!t[i];r.put(i,new $(s))}else if(typeof t[i]=="string"){let s=String(t[i]);r.put(i,new Ve(s))}else if(typeof t[i]=="number"){let s=Number(t[i]);r.put(i,new At(s))}else t[i]instanceof Array?r.put(i,Yt.parseJsonArray(t[i])):t[i]instanceof Object?r.put(i,Yt.parseJsonObject(t[i],new Oe)):t[i]==null?r.put(i,new Fe):r.put(i,t[i])}),r}static parseJsonArray(t){let r=new sr;return Object.keys(t).forEach(i=>{if(typeof Number(i)=="number")if(typeof t[i]=="boolean"){let s=!!t[i];r.add(new $(s))}else if(typeof t[i]=="string"){let s=String(t[i]);r.add(new Ve(s))}else if(typeof t[i]=="number"){let s=Number(t[i]);r.add(new At(s))}else t[i]instanceof Array?r.add(this.parseJsonArray(t[i])):t[i]instanceof Object?r.add(this.parseJsonObject(t[i],new Oe)):t[i]==null?r.add(new Fe):r.add(t[i]);else if(t[i]instanceof Array)r.add(this.parseJsonArray(t[i]));else if(t[i]instanceof Object)r.add(this.parseJsonObject(t[i],new Oe));else if(t[i]==null)r.add(new Fe);else{let s=Array(t[i]);for(let n=0;n<s.length;n++)r.add(s[n])}}),r}},ft="Error: type mismatch",oa="Error: index out of bounds",N=class re{constructor(){}getRawString(t,r){return this.getString(t,r)}toInt(t=0){return t}toFloat(t=0){return t}toBoolean(t=!1){return t}getSize(){return 0}getArray(t=null){return t}getVector(t=new Array){return t}getMap(t){return t}getValueByIndex(t){return re.errorValue.setErrorNotForClientCall(ft)}getValueByString(t){return re.nullValue.setErrorNotForClientCall(ft)}getKeys(){return re.dummyKeys}isError(){return!1}isNull(){return!1}isBool(){return!1}isFloat(){return!1}isString(){return!1}isArray(){return!1}isMap(){return!1}equals(t){return!1}isStatic(){return!1}setErrorNotForClientCall(t){return Ye.errorValue}static staticInitializeNotForClientCall(){$.trueValue=new $(!0),$.falseValue=new $(!1),re.errorValue=new Ye("ERROR",!0),re.nullValue=new Fe,re.dummyKeys=new Array}static staticReleaseNotForClientCall(){$.trueValue=null,$.falseValue=null,re.errorValue=null,re.nullValue=null,re.dummyKeys=null}_stringBuffer;static dummyKeys;static errorValue;static nullValue},X=class ct{constructor(t,r){this._error=null,this._lineCount=0,this._root=null,t!=null&&this.parseBytes(t,r,this._parseCallback)}static create(t,r){let i=new ct;return i.parseBytes(t,r,i._parseCallback)?i:(ct.delete(i),null)}static delete(t){t=null}getRoot(){return this._root}static arrayBufferToString(t){let r=new Uint8Array(t),i="";for(let s=0,n=r.length;s<n;++s)i+="%"+this.pad(r[s].toString(16));return i=decodeURIComponent(i),i}static pad(t){return t.length<2?"0"+t:t}parseBytes(t,r,i){let s=new Array(1),n=ct.arrayBufferToString(t);if(i==null?this._root=this.parseValue(n,r,0,s):this._root=i(JSON.parse(n),new Oe),this._error){let a="\0";return a="Json parse error : @line "+(this._lineCount+1)+`
|
|
6
|
-
`,this._root=new Ve(a),ge("{0}",this._root.getRawString()),!1}else if(this._root==null)return this._root=new Ye(this._error,!1),!1;return!0}getParseError(){return this._error}checkEndOfFile(){return this._root.getArray()[1].equals("EOF")}parseValue(t,r,i,s){if(this._error)return null;let n=null,a=i,l;for(;a<r;a++)switch(t[a]){case"-":case".":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{let o=new Array(1);return l=la(t.slice(a),o),s[0]=t.indexOf(o[0]),new At(l)}case'"':return new Ve(this.parseString(t,r,a+1,s));case"[":return n=this.parseArray(t,r,a+1,s),n;case"{":return n=this.parseObject(t,r,a+1,s),n;case"n":return a+3<r?(n=new Fe,s[0]=a+4):this._error="parse null",n;case"t":return a+3<r?(n
|
|
5
|
+
`)}constructor(){}};(function(e){e.CubismDebug=ir})(ri||(ri={}));Ae=class{constructor(e=!1,t=new R){this.isOverridden=e,this.color=t}isOverridden;color},ea=class{_model;_isOverriddenModelMultiplyColors;_isOverriddenModelScreenColors;_userPartScreenColors;_userPartMultiplyColors;_userDrawableScreenColors;_userDrawableMultiplyColors;_userOffscreenScreenColors;_userOffscreenMultiplyColors;constructor(e){this._model=e,this._isOverriddenModelMultiplyColors=!1,this._isOverriddenModelScreenColors=!1,this._userPartScreenColors=[],this._userPartMultiplyColors=[],this._userDrawableScreenColors=[],this._userDrawableMultiplyColors=[],this._userOffscreenScreenColors=[],this._userOffscreenMultiplyColors=[]}initialize(e,t,r){let i=new Ae(!1,new R(1,1,1,1)),s=new Ae(!1,new R(0,0,0,1));this._userPartMultiplyColors=new Array(e),this._userPartScreenColors=new Array(e);for(let n=0;n<e;n++)this._userPartMultiplyColors[n]=new Ae(i.isOverridden,new R(i.color.r,i.color.g,i.color.b,i.color.a)),this._userPartScreenColors[n]=new Ae(s.isOverridden,new R(s.color.r,s.color.g,s.color.b,s.color.a));this._userDrawableMultiplyColors=new Array(t),this._userDrawableScreenColors=new Array(t);for(let n=0;n<t;n++)this._userDrawableMultiplyColors[n]=new Ae(i.isOverridden,new R(i.color.r,i.color.g,i.color.b,i.color.a)),this._userDrawableScreenColors[n]=new Ae(s.isOverridden,new R(s.color.r,s.color.g,s.color.b,s.color.a));this._userOffscreenMultiplyColors=new Array(r),this._userOffscreenScreenColors=new Array(r);for(let n=0;n<r;n++)this._userOffscreenMultiplyColors[n]=new Ae(i.isOverridden,new R(i.color.r,i.color.g,i.color.b,i.color.a)),this._userOffscreenScreenColors[n]=new Ae(s.isOverridden,new R(s.color.r,s.color.g,s.color.b,s.color.a))}warnIndexOutOfRange(e,t,r){k(`${e}: index is out of range. index=${t}, valid range=[0, ${r}].`)}isValidPartIndex(e,t){return e<0||e>=this._model.getPartCount()?(this.warnIndexOutOfRange(t,e,this._model.getPartCount()-1),!1):!0}isValidDrawableIndex(e,t){return e<0||e>=this._model.getDrawableCount()?(this.warnIndexOutOfRange(t,e,this._model.getDrawableCount()-1),!1):!0}isValidOffscreenIndex(e,t){return e<0||e>=this._model.getOffscreenCount()?(this.warnIndexOutOfRange(t,e,this._model.getOffscreenCount()-1),!1):!0}setMultiplyColorEnabled(e){this._isOverriddenModelMultiplyColors=e}getMultiplyColorEnabled(){return this._isOverriddenModelMultiplyColors}setScreenColorEnabled(e){this._isOverriddenModelScreenColors=e}getScreenColorEnabled(){return this._isOverriddenModelScreenColors}setPartMultiplyColorEnabled(e,t){this.isValidPartIndex(e,"setPartMultiplyColorEnabled")&&this.setPartColorEnabled(e,t,this._userPartMultiplyColors,this._userDrawableMultiplyColors,this._userOffscreenMultiplyColors)}getPartMultiplyColorEnabled(e){return this.isValidPartIndex(e,"getPartMultiplyColorEnabled")?this._userPartMultiplyColors[e].isOverridden:!1}setPartScreenColorEnabled(e,t){this.isValidPartIndex(e,"setPartScreenColorEnabled")&&this.setPartColorEnabled(e,t,this._userPartScreenColors,this._userDrawableScreenColors,this._userOffscreenScreenColors)}getPartScreenColorEnabled(e){return this.isValidPartIndex(e,"getPartScreenColorEnabled")?this._userPartScreenColors[e].isOverridden:!1}setPartMultiplyColorByTextureColor(e,t){this.isValidPartIndex(e,"setPartMultiplyColorByTextureColor")&&this.setPartMultiplyColorByRGBA(e,t.r,t.g,t.b,t.a)}setPartMultiplyColorByRGBA(e,t,r,i,s=1){this.isValidPartIndex(e,"setPartMultiplyColorByRGBA")&&this.setPartColor(e,t,r,i,s,this._userPartMultiplyColors,this._userDrawableMultiplyColors,this._userOffscreenMultiplyColors)}getPartMultiplyColor(e){return this.isValidPartIndex(e,"getPartMultiplyColor")?this._userPartMultiplyColors[e].color:new R(1,1,1,1)}setPartScreenColorByTextureColor(e,t){this.isValidPartIndex(e,"setPartScreenColorByTextureColor")&&this.setPartScreenColorByRGBA(e,t.r,t.g,t.b,t.a)}setPartScreenColorByRGBA(e,t,r,i,s=1){this.isValidPartIndex(e,"setPartScreenColorByRGBA")&&this.setPartColor(e,t,r,i,s,this._userPartScreenColors,this._userDrawableScreenColors,this._userOffscreenScreenColors)}getPartScreenColor(e){return this.isValidPartIndex(e,"getPartScreenColor")?this._userPartScreenColors[e].color:new R(0,0,0,1)}setDrawableMultiplyColorEnabled(e,t){this.isValidDrawableIndex(e,"setDrawableMultiplyColorEnabled")&&(this._userDrawableMultiplyColors[e].isOverridden=t)}getDrawableMultiplyColorEnabled(e){return this.isValidDrawableIndex(e,"getDrawableMultiplyColorEnabled")?this._userDrawableMultiplyColors[e].isOverridden:!1}setDrawableScreenColorEnabled(e,t){this.isValidDrawableIndex(e,"setDrawableScreenColorEnabled")&&(this._userDrawableScreenColors[e].isOverridden=t)}getDrawableScreenColorEnabled(e){return this.isValidDrawableIndex(e,"getDrawableScreenColorEnabled")?this._userDrawableScreenColors[e].isOverridden:!1}setDrawableMultiplyColorByTextureColor(e,t){this.isValidDrawableIndex(e,"setDrawableMultiplyColorByTextureColor")&&this.setDrawableMultiplyColorByRGBA(e,t.r,t.g,t.b,t.a)}setDrawableMultiplyColorByRGBA(e,t,r,i,s=1){this.isValidDrawableIndex(e,"setDrawableMultiplyColorByRGBA")&&(this._userDrawableMultiplyColors[e].color.r=t,this._userDrawableMultiplyColors[e].color.g=r,this._userDrawableMultiplyColors[e].color.b=i,this._userDrawableMultiplyColors[e].color.a=s)}getDrawableMultiplyColor(e){return this.isValidDrawableIndex(e,"getDrawableMultiplyColor")?this.getMultiplyColorEnabled()||this.getDrawableMultiplyColorEnabled(e)?this._userDrawableMultiplyColors[e].color:this._model.getDrawableMultiplyColor(e):new R(1,1,1,1)}setDrawableScreenColorByTextureColor(e,t){this.isValidDrawableIndex(e,"setDrawableScreenColorByTextureColor")&&this.setDrawableScreenColorByRGBA(e,t.r,t.g,t.b,t.a)}setDrawableScreenColorByRGBA(e,t,r,i,s=1){this.isValidDrawableIndex(e,"setDrawableScreenColorByRGBA")&&(this._userDrawableScreenColors[e].color.r=t,this._userDrawableScreenColors[e].color.g=r,this._userDrawableScreenColors[e].color.b=i,this._userDrawableScreenColors[e].color.a=s)}getDrawableScreenColor(e){return this.isValidDrawableIndex(e,"getDrawableScreenColor")?this.getScreenColorEnabled()||this.getDrawableScreenColorEnabled(e)?this._userDrawableScreenColors[e].color:this._model.getDrawableScreenColor(e):new R(0,0,0,1)}setOffscreenMultiplyColorEnabled(e,t){this.isValidOffscreenIndex(e,"setOffscreenMultiplyColorEnabled")&&(this._userOffscreenMultiplyColors[e].isOverridden=t)}getOffscreenMultiplyColorEnabled(e){return this.isValidOffscreenIndex(e,"getOffscreenMultiplyColorEnabled")?this._userOffscreenMultiplyColors[e].isOverridden:!1}setOffscreenScreenColorEnabled(e,t){this.isValidOffscreenIndex(e,"setOffscreenScreenColorEnabled")&&(this._userOffscreenScreenColors[e].isOverridden=t)}getOffscreenScreenColorEnabled(e){return this.isValidOffscreenIndex(e,"getOffscreenScreenColorEnabled")?this._userOffscreenScreenColors[e].isOverridden:!1}setOffscreenMultiplyColorByTextureColor(e,t){this.isValidOffscreenIndex(e,"setOffscreenMultiplyColorByTextureColor")&&this.setOffscreenMultiplyColorByRGBA(e,t.r,t.g,t.b,t.a)}setOffscreenMultiplyColorByRGBA(e,t,r,i,s=1){this.isValidOffscreenIndex(e,"setOffscreenMultiplyColorByRGBA")&&(this._userOffscreenMultiplyColors[e].color.r=t,this._userOffscreenMultiplyColors[e].color.g=r,this._userOffscreenMultiplyColors[e].color.b=i,this._userOffscreenMultiplyColors[e].color.a=s)}getOffscreenMultiplyColor(e){return this.isValidOffscreenIndex(e,"getOffscreenMultiplyColor")?this.getMultiplyColorEnabled()||this.getOffscreenMultiplyColorEnabled(e)?this._userOffscreenMultiplyColors[e].color:this._model.getOffscreenMultiplyColor(e):new R(1,1,1,1)}setOffscreenScreenColorByTextureColor(e,t){this.isValidOffscreenIndex(e,"setOffscreenScreenColorByTextureColor")&&this.setOffscreenScreenColorByRGBA(e,t.r,t.g,t.b,t.a)}setOffscreenScreenColorByRGBA(e,t,r,i,s=1){this.isValidOffscreenIndex(e,"setOffscreenScreenColorByRGBA")&&(this._userOffscreenScreenColors[e].color.r=t,this._userOffscreenScreenColors[e].color.g=r,this._userOffscreenScreenColors[e].color.b=i,this._userOffscreenScreenColors[e].color.a=s)}getOffscreenScreenColor(e){return this.isValidOffscreenIndex(e,"getOffscreenScreenColor")?this.getScreenColorEnabled()||this.getOffscreenScreenColorEnabled(e)?this._userOffscreenScreenColors[e].color:this._model.getOffscreenScreenColor(e):new R(0,0,0,1)}setPartColor(e,t,r,i,s,n,a,l){if(n[e].color.r=t,n[e].color.g=r,n[e].color.b=i,n[e].color.a=s,n[e].isOverridden){let o=this._model.getPartOffscreenIndices()[e];if(o==-1){let u=this._model.getPartsHierarchy();if(u&&u[e])for(let c=0;c<u[e].objects.length;++c){let g=u[e].objects[c];if(g.objectType===0){let h=g.objectIndex;a[h].color.r=t,a[h].color.g=r,a[h].color.b=i,a[h].color.a=s}else{let h=g.objectIndex;this.setPartColor(h,t,r,i,s,n,a,l)}}}else l[o].color.r=t,l[o].color.g=r,l[o].color.b=i,l[o].color.a=s}}setPartColorEnabled(e,t,r,i,s){r[e].isOverridden=t;let n=this._model.getPartOffscreenIndices()[e];if(n==-1){let a=this._model.getPartsHierarchy();if(a&&a[e])for(let l=0;l<a[e].objects.length;++l){let o=a[e].objects[l];if(o.objectType===0){let u=o.objectIndex;i[u].isOverridden=t,t&&(i[u].color.r=r[e].color.r,i[u].color.g=r[e].color.g,i[u].color.b=r[e].color.b,i[u].color.a=r[e].color.a)}else{let u=o.objectIndex;t&&(r[u].color.r=r[e].color.r,r[u].color.g=r[e].color.g,r[u].color.b=r[e].color.b,r[u].color.a=r[e].color.a),this.setPartColorEnabled(u,t,r,i,s)}}}else s[n].isOverridden=t,t&&(s[n].color.r=r[e].color.r,s[n].color.g=r[e].color.g,s[n].color.b=r[e].color.b,s[n].color.a=r[e].color.a)}},Q=(function(e){return e[e.ColorBlend_None=-1]="ColorBlend_None",e[e.ColorBlend_Normal=Live2DCubismCore.ColorBlendType_Normal]="ColorBlend_Normal",e[e.ColorBlend_AddGlow=Live2DCubismCore.ColorBlendType_AddGlow]="ColorBlend_AddGlow",e[e.ColorBlend_Add=Live2DCubismCore.ColorBlendType_Add]="ColorBlend_Add",e[e.ColorBlend_Darken=Live2DCubismCore.ColorBlendType_Darken]="ColorBlend_Darken",e[e.ColorBlend_Multiply=Live2DCubismCore.ColorBlendType_Multiply]="ColorBlend_Multiply",e[e.ColorBlend_ColorBurn=Live2DCubismCore.ColorBlendType_ColorBurn]="ColorBlend_ColorBurn",e[e.ColorBlend_LinearBurn=Live2DCubismCore.ColorBlendType_LinearBurn]="ColorBlend_LinearBurn",e[e.ColorBlend_Lighten=Live2DCubismCore.ColorBlendType_Lighten]="ColorBlend_Lighten",e[e.ColorBlend_Screen=Live2DCubismCore.ColorBlendType_Screen]="ColorBlend_Screen",e[e.ColorBlend_ColorDodge=Live2DCubismCore.ColorBlendType_ColorDodge]="ColorBlend_ColorDodge",e[e.ColorBlend_Overlay=Live2DCubismCore.ColorBlendType_Overlay]="ColorBlend_Overlay",e[e.ColorBlend_SoftLight=Live2DCubismCore.ColorBlendType_SoftLight]="ColorBlend_SoftLight",e[e.ColorBlend_HardLight=Live2DCubismCore.ColorBlendType_HardLight]="ColorBlend_HardLight",e[e.ColorBlend_LinearLight=Live2DCubismCore.ColorBlendType_LinearLight]="ColorBlend_LinearLight",e[e.ColorBlend_Hue=Live2DCubismCore.ColorBlendType_Hue]="ColorBlend_Hue",e[e.ColorBlend_Color=Live2DCubismCore.ColorBlendType_Color]="ColorBlend_Color",e[e.ColorBlend_AddCompatible=Live2DCubismCore.ColorBlendType_AddCompatible]="ColorBlend_AddCompatible",e[e.ColorBlend_MultiplyCompatible=Live2DCubismCore.ColorBlendType_MultiplyCompatible]="ColorBlend_MultiplyCompatible",e})({}),Tt=(function(e){return e[e.AlphaBlend_None=-1]="AlphaBlend_None",e[e.AlphaBlend_Over=0]="AlphaBlend_Over",e[e.AlphaBlend_Atop=1]="AlphaBlend_Atop",e[e.AlphaBlend_Out=2]="AlphaBlend_Out",e[e.AlphaBlend_ConjointOver=3]="AlphaBlend_ConjointOver",e[e.AlphaBlend_DisjointOver=4]="AlphaBlend_DisjointOver",e})({}),ta=class{constructor(e=!1,t=!1){this.isOverridden=e,this.isParameterRepeated=t}isOverridden;isParameterRepeated},ii=class{constructor(e=!1,t=!1){this.isOverridden=e,this.isCulling=t}isOverridden;isCulling},ra=class{drawableIndices;offscreenIndices;constructor(e=new Array,t=new Array){this.drawableIndices=e,this.offscreenIndices=t}},si=class{objectType;objectIndex;constructor(e,t){this.objectIndex=e,this.objectType=t}},ia=class{objects;childDrawObjects;constructor(e=new Array,t=new ra){this.objects=e,this.childDrawObjects=t}getChildObjectCount(){return this.objects.length}},bs=class{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return this._model==null?0:this._model.canvasinfo.PixelsPerUnit}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){let e=this._model.parameters.count,t=this._savedParameters.length;for(let r=0;r<e;++r)r<t?this._savedParameters[r]=this._parameterValues[r]:this._savedParameters.push(this._parameterValues[r])}getOverrideMultiplyAndScreenColor(){return this._overrideMultiplyAndScreenColor}getOverrideFlagForModelParameterRepeat(){return this._isOverriddenParameterRepeat}setOverrideFlagForModelParameterRepeat(e){this._isOverriddenParameterRepeat=e}getOverrideFlagForParameterRepeat(e){return this._userParameterRepeatDataList[e].isOverridden}setOverrideFlagForParameterRepeat(e,t){this._userParameterRepeatDataList[e].isOverridden=t}getRepeatFlagForParameterRepeat(e){return this._userParameterRepeatDataList[e].isParameterRepeated}setRepeatFlagForParameterRepeat(e,t){this._userParameterRepeatDataList[e].isParameterRepeated=t}getDrawableCulling(e){if(this.getOverrideFlagForModelCullings()||this.getOverrideFlagForDrawableCullings(e))return this._userDrawableCullings[e].isCulling;let t=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(t[e])}setDrawableCulling(e,t){this._userDrawableCullings[e].isCulling=t}getOffscreenCulling(e){if(this.getOverrideFlagForModelCullings()||this.getOverrideFlagForOffscreenCullings(e))return this._userOffscreenCullings[e].isCulling;let t=this._model.offscreens.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(t[e])}setOffscreenCulling(e,t){this._userOffscreenCullings[e].isCulling=t}getOverrideFlagForModelCullings(){return this._isOverriddenCullings}setOverrideFlagForModelCullings(e){this._isOverriddenCullings=e}getOverrideFlagForDrawableCullings(e){return this._userDrawableCullings[e].isOverridden}getOverrideFlagForOffscreenCullings(e){return this._userOffscreenCullings[e].isOverridden}setOverrideFlagForDrawableCullings(e,t){this._userDrawableCullings[e].isOverridden=t}getModelOapcity(){return this._modelOpacity}setModelOapcity(e){this._modelOpacity=e}getModel(){return this._model}getPartIndex(e){let t,r=this._model.parts.count;for(t=0;t<r;++t)if(e==this._partIds[t])return t;return this._notExistPartId.has(e)?this._notExistPartId.get(e):(t=r+this._notExistPartId.size,this._notExistPartId.set(e,t),this._notExistPartOpacities.set(t,null),t)}getPartId(e){let t=this._model.parts.ids[e];return P.getIdManager().getId(t)}getPartCount(){return this._model.parts.count}getPartOffscreenIndices(){return this._model.parts.offscreenIndices}getPartParentPartIndices(){return this._model.parts.parentIndices}setPartOpacityByIndex(e,t){if(this._notExistPartOpacities.has(e)){this._notExistPartOpacities.set(e,t);return}U(0<=e&&e<this.getPartCount()),this._partOpacities[e]=t}setPartOpacityById(e,t){let r=this.getPartIndex(e);r<0||this.setPartOpacityByIndex(r,t)}getPartOpacityByIndex(e){return this._notExistPartOpacities.has(e)?this._notExistPartOpacities.get(e):(U(0<=e&&e<this.getPartCount()),this._partOpacities[e])}getPartOpacityById(e){let t=this.getPartIndex(e);return t<0?0:this.getPartOpacityByIndex(t)}getParameterIndex(e){let t,r=this._model.parameters.count;for(t=0;t<r;++t)if(e==this._parameterIds[t])return t;return this._notExistParameterId.has(e)?this._notExistParameterId.get(e):(t=this._model.parameters.count+this._notExistParameterId.size,this._notExistParameterId.set(e,t),this._notExistParameterValues.set(t,null),t)}getParameterCount(){return this._model.parameters.count}getParameterType(e){return this._model.parameters.types[e]}getParameterMaximumValue(e){return this._model.parameters.maximumValues[e]}getParameterMinimumValue(e){return this._model.parameters.minimumValues[e]}getParameterDefaultValue(e){return this._model.parameters.defaultValues[e]}getParameterId(e){return P.getIdManager().getId(this._model.parameters.ids[e])}getParameterValueByIndex(e){return this._notExistParameterValues.has(e)?this._notExistParameterValues.get(e):(U(0<=e&&e<this.getParameterCount()),this._parameterValues[e])}getParameterValueById(e){let t=this.getParameterIndex(e);return this.getParameterValueByIndex(t)}setParameterValueByIndex(e,t,r=1){if(this._notExistParameterValues.has(e)){this._notExistParameterValues.set(e,r==1?t:this._notExistParameterValues.get(e)*(1-r)+t*r);return}U(0<=e&&e<this.getParameterCount()),this.isRepeat(e)?t=this.getParameterRepeatValue(e,t):t=this.getParameterClampValue(e,t),this._parameterValues[e]=r==1?t:this._parameterValues[e]=this._parameterValues[e]*(1-r)+t*r}setParameterValueById(e,t,r=1){let i=this.getParameterIndex(e);this.setParameterValueByIndex(i,t,r)}addParameterValueByIndex(e,t,r=1){this.setParameterValueByIndex(e,this.getParameterValueByIndex(e)+t*r)}addParameterValueById(e,t,r=1){let i=this.getParameterIndex(e);this.addParameterValueByIndex(i,t,r)}isRepeat(e){if(this._notExistParameterValues.has(e))return!1;U(0<=e&&e<this.getParameterCount());let t;return this._isOverriddenParameterRepeat||this._userParameterRepeatDataList[e].isOverridden?t=this._userParameterRepeatDataList[e].isParameterRepeated:t=this._model.parameters.repeats[e]!=0,t}getParameterRepeatValue(e,t){if(this._notExistParameterValues.has(e))return t;U(0<=e&&e<this.getParameterCount());let r=this._model.parameters.maximumValues[e],i=this._model.parameters.minimumValues[e],s=r-i;if(r<t){let n=x.mod(t-r,s);Number.isNaN(n)?t=r:t=i+n}if(t<i){let n=x.mod(i-t,s);Number.isNaN(n)?t=i:t=r-n}return t}getParameterClampValue(e,t){if(this._notExistParameterValues.has(e))return t;U(0<=e&&e<this.getParameterCount());let r=this._model.parameters.maximumValues[e],i=this._model.parameters.minimumValues[e];return x.clamp(t,i,r)}getParameterRepeats(e){return this._model.parameters.repeats[e]!=0}multiplyParameterValueById(e,t,r=1){let i=this.getParameterIndex(e);this.multiplyParameterValueByIndex(i,t,r)}multiplyParameterValueByIndex(e,t,r=1){this.setParameterValueByIndex(e,this.getParameterValueByIndex(e)*(1+(t-1)*r))}getDrawableIndex(e){let t=this._model.drawables.count;for(let r=0;r<t;++r)if(this._drawableIds[r]==e)return r;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(e){let t=this._model.drawables.ids;return P.getIdManager().getId(t[e])}getRenderOrders(){return this._model.getRenderOrders()}getDrawableTextureIndex(e){return this._model.drawables.textureIndices[e]}getDrawableDynamicFlagVertexPositionsDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(t[e])}getDrawableVertexIndexCount(e){return this._model.drawables.indexCounts[e]}getDrawableVertexCount(e){return this._model.drawables.vertexCounts[e]}getDrawableVertices(e){return this.getDrawableVertexPositions(e)}getDrawableVertexIndices(e){return this._model.drawables.indices[e]}getDrawableVertexPositions(e){return this._model.drawables.vertexPositions[e]}getDrawableVertexUvs(e){return this._model.drawables.vertexUvs[e]}getDrawableOpacity(e){return this._model.drawables.opacities[e]}getDrawableMultiplyColor(e){this._drawableMultiplyColors==null&&(this._drawableMultiplyColors=new Array(this._model.drawables.count),this._drawableMultiplyColors.fill(new R));let t=this._model.drawables.multiplyColors,r=e*4;return this._drawableMultiplyColors[e].r=t[r],this._drawableMultiplyColors[e].g=t[r+1],this._drawableMultiplyColors[e].b=t[r+2],this._drawableMultiplyColors[e].a=t[r+3],this._drawableMultiplyColors[e]}getDrawableScreenColor(e){this._drawableScreenColors==null&&(this._drawableScreenColors=new Array(this._model.drawables.count),this._drawableScreenColors.fill(new R));let t=this._model.drawables.screenColors,r=e*4;return this._drawableScreenColors[e].r=t[r],this._drawableScreenColors[e].g=t[r+1],this._drawableScreenColors[e].b=t[r+2],this._drawableScreenColors[e].a=t[r+3],this._drawableScreenColors[e]}getOffscreenMultiplyColor(e){this._offscreenMultiplyColors==null&&(this._offscreenMultiplyColors=new Array(this._model.offscreens.count),this._offscreenMultiplyColors.fill(new R));let t=this._model.offscreens.multiplyColors,r=e*4;return this._offscreenMultiplyColors[e].r=t[r],this._offscreenMultiplyColors[e].g=t[r+1],this._offscreenMultiplyColors[e].b=t[r+2],this._offscreenMultiplyColors[e].a=t[r+3],this._offscreenMultiplyColors[e]}getOffscreenScreenColor(e){this._offscreenScreenColors==null&&(this._offscreenScreenColors=new Array(this._model.offscreens.count),this._offscreenScreenColors.fill(new R));let t=this._model.offscreens.screenColors,r=e*4;return this._offscreenScreenColors[e].r=t[r],this._offscreenScreenColors[e].g=t[r+1],this._offscreenScreenColors[e].b=t[r+2],this._offscreenScreenColors[e].a=t[r+3],this._offscreenScreenColors[e]}getDrawableParentPartIndex(e){return this._model.drawables.parentPartIndices[e]}getDrawableBlendMode(e){let t=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(t[e])?1:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(t[e])?2:0}getDrawableColorBlend(e){return this._drawableColorBlends[e]==-1&&(this._drawableColorBlends[e]=this._model.drawables.blendModes[e]&255),this._drawableColorBlends[e]}getDrawableAlphaBlend(e){return this._drawableAlphaBlends[e]==-1&&(this._drawableAlphaBlends[e]=this._model.drawables.blendModes[e]>>8&255),this._drawableAlphaBlends[e]}getDrawableInvertedMaskBit(e){let t=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(t[e])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let e=0;e<this._model.drawables.count;++e)if(!(this._model.drawables.maskCounts[e]<=0))return!0;return!1}isUsingMaskingForOffscreen(){for(let e=0;e<this.getOffscreenCount();++e)if(!(this._model.offscreens.maskCounts[e]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(t[e])}getDrawableDynamicFlagVisibilityDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(t[e])}getDrawableDynamicFlagOpacityDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(t[e])}getDrawableDynamicFlagRenderOrderDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(t[e])}getDrawableDynamicFlagBlendColorDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(t[e])}getOffscreenCount(){return this._model.offscreens.count}getOffscreenColorBlend(e){return this._offscreenColorBlends[e]==-1&&(this._offscreenColorBlends[e]=this._model.offscreens.blendModes[e]&255),this._offscreenColorBlends[e]}getOffscreenAlphaBlend(e){return this._offscreenAlphaBlends[e]==-1&&(this._offscreenAlphaBlends[e]=this._model.offscreens.blendModes[e]>>8&255),this._offscreenAlphaBlends[e]}getOffscreenOwnerIndices(){return this._model.offscreens.ownerIndices}getOffscreenOpacity(e){return e<0||e>=this._model.offscreens.count?1:this._model.offscreens.opacities[e]}getOffscreenMasks(){return this._model.offscreens.masks}getOffscreenMaskCounts(){return this._model.offscreens.maskCounts}getOffscreenInvertedMask(e){let t=this._model.offscreens.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(t[e])}isBlendModeEnabled(){return this._isBlendModeEnabled}loadParameters(){let e=this._model.parameters.count,t=this._savedParameters.length;e>t&&(e=t);for(let r=0;r<e;++r)this._parameterValues[r]=this._savedParameters[r]}initialize(){U(this._model),this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._offscreenOpacities=this._model.offscreens.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{let t=this._model.parameters.ids,r=this._model.parameters.count;this._parameterIds.length=r,this._userParameterRepeatDataList.length=r;for(let i=0;i<r;++i)this._parameterIds[i]=P.getIdManager().getId(t[i]),this._userParameterRepeatDataList[i]=new ta(!1,!1)}let e=this._model.parts.count;{let t=this._model.parts.ids;this._partIds.length=e;for(let r=0;r<e;++r)this._partIds[r]=P.getIdManager().getId(t[r])}{let t=this._model.drawables.ids,r=this._model.drawables.count;this._userDrawableCullings.length=r;let i=new ii(!1,!1);this._userOffscreenCullings.length=this._model.offscreens.count;let s=new ii(!1,!1);for(let a=0;a<r;++a)this._drawableIds.push(P.getIdManager().getId(t[a])),this._userDrawableCullings[a]=i;for(let a=0;a<this._model.offscreens.count;++a)this._userOffscreenCullings[a]=s;if(this.getOffscreenCount()>0)this._isBlendModeEnabled=!0;else{this._model.drawables.blendModes;for(let a=0;a<r;++a){let l=this.getDrawableColorBlend(a),o=this.getDrawableAlphaBlend(a);if(!(l==Q.ColorBlend_Normal&&o==0)&&l!=Q.ColorBlend_AddCompatible&&l!=Q.ColorBlend_MultiplyCompatible){this._isBlendModeEnabled=!0;break}}}this.setupPartsHierarchy();let n=this.getOffscreenCount();this._overrideMultiplyAndScreenColor.initialize(e,r,n)}}getPartsHierarchy(){return this._partsHierarchy}setupPartsHierarchy(){this._partsHierarchy.length=0;let e=this.getPartCount();this._partsHierarchy.length=e;for(let r=0;r<e;++r){let i=new ia;this._partsHierarchy[r]=i}for(let r=0;r<e;++r){let i=this.getPartParentPartIndices()[r];if(i!==-1){for(let s=0;s<this._partsHierarchy.length;++s)if(s===i){let n=new si(r,1);this._partsHierarchy[s].objects.push(n);break}}}let t=this.getDrawableCount();for(let r=0;r<t;++r){let i=this.getDrawableParentPartIndex(r);if(i!==-1){for(let s=0;s<this._partsHierarchy.length;++s)if(s===i){let n=new si(r,0);this._partsHierarchy[s].objects.push(n);break}}}for(let r=0;r<this._partsHierarchy.length;++r)this.getPartChildDrawObjects(r)}getPartChildDrawObjects(e){if(this._partsHierarchy[e].getChildObjectCount()<1)return this._partsHierarchy[e].childDrawObjects;let t=this._partsHierarchy[e].childDrawObjects;if(t.drawableIndices.length!==0||t.offscreenIndices.length!==0)return t;let r=this._partsHierarchy[e].objects;for(let i=0;i<r.length;++i){let s=r[i];if(s.objectType===1){this.getPartChildDrawObjects(s.objectIndex);let n=this._partsHierarchy[s.objectIndex].childDrawObjects;t.drawableIndices.push(...n.drawableIndices),t.offscreenIndices.push(...n.offscreenIndices);let a=this.getOffscreenIndices(),l=a?a[s.objectIndex]:-1;l!==-1&&t.offscreenIndices.push(l)}else s.objectType===0&&t.drawableIndices.push(s.objectIndex)}return t}getOffscreenIndices(){return this._model.parts.offscreenIndices}constructor(e){this._model=e,this._parameterValues=null,this._parameterMaximumValues=null,this._parameterMinimumValues=null,this._partOpacities=null,this._offscreenOpacities=null,this._savedParameters=new Array,this._parameterIds=new Array,this._drawableIds=new Array,this._partIds=new Array,this._isOverriddenParameterRepeat=!0,this._isOverriddenCullings=!1,this._modelOpacity=1,this._overrideMultiplyAndScreenColor=new ea(this),this._isBlendModeEnabled=!1,this._drawableColorBlends=null,this._drawableAlphaBlends=null,this._offscreenColorBlends=null,this._offscreenAlphaBlends=null,this._drawableMultiplyColors=null,this._drawableScreenColors=null,this._offscreenMultiplyColors=null,this._offscreenScreenColors=null,this._userParameterRepeatDataList=new Array,this._userDrawableCullings=new Array,this._userOffscreenCullings=new Array,this._partsHierarchy=new Array,this._notExistPartId=new Map,this._notExistParameterId=new Map,this._notExistParameterValues=new Map,this._notExistPartOpacities=new Map,this._drawableColorBlends=new Array(e.drawables.count).fill(-1),this._drawableAlphaBlends=new Array(e.drawables.count).fill(-1),this._offscreenColorBlends=new Array(e.offscreens.count).fill(-1),this._offscreenAlphaBlends=new Array(e.offscreens.count).fill(-1)}release(){this._model.release(),this._model=null,this._drawableColorBlends=null,this._drawableAlphaBlends=null,this._offscreenColorBlends=null,this._offscreenAlphaBlends=null,this._drawableMultiplyColors=null,this._drawableScreenColors=null,this._offscreenMultiplyColors=null,this._offscreenScreenColors=null}_notExistPartOpacities;_notExistPartId;_notExistParameterValues;_notExistParameterId;_savedParameters;_isOverriddenParameterRepeat;_overrideMultiplyAndScreenColor;_userParameterRepeatDataList;_partsHierarchy;_model;_parameterValues;_parameterMaximumValues;_parameterMinimumValues;_partOpacities;_offscreenOpacities;_modelOpacity;_parameterIds;_partIds;_drawableIds;_isOverriddenCullings;_userDrawableCullings;_userOffscreenCullings;_isBlendModeEnabled;_drawableColorBlends;_drawableAlphaBlends;_offscreenColorBlends;_offscreenAlphaBlends;_drawableMultiplyColors;_drawableScreenColors;_offscreenMultiplyColors;_offscreenScreenColors};(function(e){e.CubismModel=bs})(ni||(ni={}));gt=class{constructor(e,t,r,i){this.x=e,this.y=t,this.width=r,this.height=i}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height}expand(e,t){this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2}x;y;width;height};(function(e){e.csmRect=gt})(ai||(ai={}));mt=class{static create(){return null}static delete(e){e=null}initialize(e){this._model=e,e.isBlendModeEnabled()&&(this.useHighPrecisionMask(!0),ge("This model uses a high-resolution mask because it operates in blend mode."))}drawModel(e=null){this.getModel()!=null&&this.doDrawModel(e)}setMvpMatrix(e){this._mvpMatrix4x4.setMatrix(e.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(e,t,r,i){this._modelColor.r=x.clamp(e,0,1),this._modelColor.g=x.clamp(t,0,1),this._modelColor.b=x.clamp(r,0,1),this._modelColor.a=x.clamp(i,0,1)}getModelColor(){return this._modelColorScratch.r=this._modelColor.r,this._modelColorScratch.g=this._modelColor.g,this._modelColorScratch.b=this._modelColor.b,this._modelColorScratch.a=this._modelColor.a,this._modelColorScratch}getModelColorWithOpacity(e){let t=this._modelColorWithOpacityScratch;return t.r=this._modelColor.r,t.g=this._modelColor.g,t.b=this._modelColor.b,t.a=this._modelColor.a*e,this.isPremultipliedAlpha()&&(t.r*=t.a,t.g*=t.a,t.b*=t.a),t}setIsPremultipliedAlpha(e){this._isPremultipliedAlpha=e}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(e){this._isCulling=e}isCulling(){return this._isCulling}setAnisotropy(e){this._anisotropy=e}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(e){this._useHighPrecisionMask=e}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}setRenderTargetSize(e,t){this._modelRenderTargetWidth=e,this._modelRenderTargetHeight=t}constructor(e,t){this._modelRenderTargetWidth=e,this._modelRenderTargetHeight=t,this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._model=null,this._modelColor=new R,this._modelColorScratch=new R,this._modelColorWithOpacityScratch=new R,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new ae,this._mvpMatrix4x4.loadIdentity()}static staticRelease;_mvpMatrix4x4;_modelColor;_modelColorScratch;_modelColorWithOpacityScratch;_isCulling;_isPremultipliedAlpha;_anisotropy;_model;_useHighPrecisionMask;_modelRenderTargetWidth;_modelRenderTargetHeight},sa=(function(e){return e[e.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",e[e.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",e[e.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",e})({}),R=class{constructor(e=1,t=1,r=1,i=1){this.r=e,this.g=t,this.b=r,this.a=i}r;g;b;a},na=class{constructor(e,t){this._clippingIdList=e,this._clippingIdCount=t,this._allClippedDrawRect=new gt,this._layoutBounds=new gt,this._clippedDrawableIndexList=[],this._clippedOffscreenIndexList=[],this._matrixForMask=new ae,this._matrixForDraw=new ae,this._bufferIndex=0,this._layoutChannelIndex=0}release(){this._layoutBounds!=null&&(this._layoutBounds=null),this._allClippedDrawRect!=null&&(this._allClippedDrawRect=null),this._clippedDrawableIndexList!=null&&(this._clippedDrawableIndexList=null),this._clippedOffscreenIndexList!=null&&(this._clippedOffscreenIndexList=null)}addClippedDrawable(e){this._clippedDrawableIndexList.push(e)}addClippedOffscreen(e){this._clippedOffscreenIndexList.push(e)}_isUsing;_clippingIdList;_clippingIdCount;_layoutChannelIndex;_layoutBounds;_allClippedDrawRect;_matrixForMask;_matrixForDraw;_clippedDrawableIndexList;_clippedOffscreenIndexList;_bufferIndex};(function(e){e.CubismBlendMode=sa,e.CubismRenderer=mt,e.CubismTextureColor=R})(oi||(oi={}));aa=class Yt{static parseJsonObject(t,r){return Object.keys(t).forEach(i=>{if(typeof t[i]=="boolean"){let s=!!t[i];r.put(i,new ee(s))}else if(typeof t[i]=="string"){let s=String(t[i]);r.put(i,new Ve(s))}else if(typeof t[i]=="number"){let s=Number(t[i]);r.put(i,new At(s))}else t[i]instanceof Array?r.put(i,Yt.parseJsonArray(t[i])):t[i]instanceof Object?r.put(i,Yt.parseJsonObject(t[i],new Oe)):t[i]==null?r.put(i,new Fe):r.put(i,t[i])}),r}static parseJsonArray(t){let r=new sr;return Object.keys(t).forEach(i=>{if(typeof Number(i)=="number")if(typeof t[i]=="boolean"){let s=!!t[i];r.add(new ee(s))}else if(typeof t[i]=="string"){let s=String(t[i]);r.add(new Ve(s))}else if(typeof t[i]=="number"){let s=Number(t[i]);r.add(new At(s))}else t[i]instanceof Array?r.add(this.parseJsonArray(t[i])):t[i]instanceof Object?r.add(this.parseJsonObject(t[i],new Oe)):t[i]==null?r.add(new Fe):r.add(t[i]);else if(t[i]instanceof Array)r.add(this.parseJsonArray(t[i]));else if(t[i]instanceof Object)r.add(this.parseJsonObject(t[i],new Oe));else if(t[i]==null)r.add(new Fe);else{let s=Array(t[i]);for(let n=0;n<s.length;n++)r.add(s[n])}}),r}},ft="Error: type mismatch",oa="Error: index out of bounds",G=class ie{constructor(){}getRawString(t,r){return this.getString(t,r)}toInt(t=0){return t}toFloat(t=0){return t}toBoolean(t=!1){return t}getSize(){return 0}getArray(t=null){return t}getVector(t=new Array){return t}getMap(t){return t}getValueByIndex(t){return ie.errorValue.setErrorNotForClientCall(ft)}getValueByString(t){return ie.nullValue.setErrorNotForClientCall(ft)}getKeys(){return ie.dummyKeys}isError(){return!1}isNull(){return!1}isBool(){return!1}isFloat(){return!1}isString(){return!1}isArray(){return!1}isMap(){return!1}equals(t){return!1}isStatic(){return!1}setErrorNotForClientCall(t){return Ye.errorValue}static staticInitializeNotForClientCall(){ee.trueValue=new ee(!0),ee.falseValue=new ee(!1),ie.errorValue=new Ye("ERROR",!0),ie.nullValue=new Fe,ie.dummyKeys=new Array}static staticReleaseNotForClientCall(){ee.trueValue=null,ee.falseValue=null,ie.errorValue=null,ie.nullValue=null,ie.dummyKeys=null}_stringBuffer;static dummyKeys;static errorValue;static nullValue},H=class ct{constructor(t,r){this._error=null,this._lineCount=0,this._root=null,t!=null&&this.parseBytes(t,r,this._parseCallback)}static create(t,r){let i=new ct;return i.parseBytes(t,r,i._parseCallback)?i:(ct.delete(i),null)}static delete(t){t=null}getRoot(){return this._root}static arrayBufferToString(t){let r=new Uint8Array(t),i="";for(let s=0,n=r.length;s<n;++s)i+="%"+this.pad(r[s].toString(16));return i=decodeURIComponent(i),i}static pad(t){return t.length<2?"0"+t:t}parseBytes(t,r,i){let s=new Array(1),n=ct.arrayBufferToString(t);if(i==null?this._root=this.parseValue(n,r,0,s):this._root=i(JSON.parse(n),new Oe),this._error){let a="\0";return a="Json parse error : @line "+(this._lineCount+1)+`
|
|
6
|
+
`,this._root=new Ve(a),ge("{0}",this._root.getRawString()),!1}else if(this._root==null)return this._root=new Ye(this._error,!1),!1;return!0}getParseError(){return this._error}checkEndOfFile(){return this._root.getArray()[1].equals("EOF")}parseValue(t,r,i,s){if(this._error)return null;let n=null,a=i,l;for(;a<r;a++)switch(t[a]){case"-":case".":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{let o=new Array(1);return l=la(t.slice(a),o),s[0]=t.indexOf(o[0]),new At(l)}case'"':return new Ve(this.parseString(t,r,a+1,s));case"[":return n=this.parseArray(t,r,a+1,s),n;case"{":return n=this.parseObject(t,r,a+1,s),n;case"n":return a+3<r?(n=new Fe,s[0]=a+4):this._error="parse null",n;case"t":return a+3<r?(n=ee.trueValue,s[0]=a+4):this._error="parse true",n;case"f":return a+4<r?(n=ee.falseValue,s[0]=a+5):this._error="illegal ',' position",n;case",":return this._error="illegal ',' position",null;case"]":return s[0]=a,null;case`
|
|
7
7
|
`:this._lineCount++;default:break}return this._error="illegal end of value",null}parseString(t,r,i,s){if(this._error)return null;if(!t)return this._error="string is null",null;let n=i,a,l,o="",u=i;for(;n<r;n++)switch(a=t[n],a){case'"':return s[0]=n+1,o+=t.substr(u,n-u),o;case"//":if(n++,n-1>u&&(o+=t.substr(u,n-u)),u=n+1,n<r)switch(l=t[n],l){case"\\":o+="\\";break;case'"':o+='"';break;case"/":o+="/";break;case"b":o+="\b";break;case"f":o+="\f";break;case"n":o+=`
|
|
8
|
-
`;break;case"r":o+="\r";break;case"t":o+=" ";break;case"u":this._error="parse string/unicord escape not supported";break;default:break}else this._error="parse string/escape error";default:break}return this._error="parse string/illegal end",null}parseObject(t,r,i,s){if(this._error)return null;if(!t)return this._error="buffer is null",null;let n=new Oe,a="",l=i,o="",u=Array(1),
|
|
9
|
-
`:this._lineCount++;default:break}if(!
|
|
10
|
-
`:this._lineCount++;default:break}if(!
|
|
8
|
+
`;break;case"r":o+="\r";break;case"t":o+=" ";break;case"u":this._error="parse string/unicord escape not supported";break;default:break}else this._error="parse string/escape error";default:break}return this._error="parse string/illegal end",null}parseObject(t,r,i,s){if(this._error)return null;if(!t)return this._error="buffer is null",null;let n=new Oe,a="",l=i,o="",u=Array(1),c=!1;for(;l<r;l++){e:for(;l<r;l++)switch(o=t[l],o){case'"':if(a=this.parseString(t,r,l+1,u),this._error)return null;l=u[0],c=!0;break e;case"}":return s[0]=l+1,n;case":":this._error="illegal ':' position";break;case`
|
|
9
|
+
`:this._lineCount++;default:break}if(!c)return this._error="key not found",null;c=!1;e:for(;l<r;l++)switch(o=t[l],o){case":":c=!0,l++;break e;case"}":this._error="illegal '}' position";break;case`
|
|
10
|
+
`:this._lineCount++;default:break}if(!c)return this._error="':' not found",null;let g=this.parseValue(t,r,l,u);if(this._error)return null;l=u[0],n.put(a,g);e:for(;l<r;l++)switch(o=t[l],o){case",":break e;case"}":return s[0]=l+1,n;case`
|
|
11
11
|
`:this._lineCount++;default:break}}return this._error="illegal end of perseObject",null}parseArray(t,r,i,s){if(this._error)return null;if(!t)return this._error="buffer is null",null;let n=new sr,a=i,l,o=new Array(1);for(;a<r;a++){let u=this.parseValue(t,r,a,o);if(this._error)return null;a=o[0],u&&n.add(u);e:for(;a<r;a++)switch(l=t[a],l){case",":break e;case"]":return s[0]=a+1,n;case`
|
|
12
|
-
`:++this._lineCount;default:break}}return n=void 0,this._error="illegal end of parseObject",null}_parseCallback=aa.parseJsonObject;_error;_lineCount;_root},At=class extends
|
|
12
|
+
`:++this._lineCount;default:break}}return n=void 0,this._error="illegal end of parseObject",null}_parseCallback=aa.parseJsonObject;_error;_lineCount;_root},At=class extends G{constructor(e){super(),this._value=e}isFloat(){return!0}getString(e,t){return this._value=parseFloat("\0"),this._stringBuffer="\0",this._stringBuffer}toInt(e=0){return parseInt(this._value.toString())}toFloat(e=0){return this._value}equals(e){return typeof e=="number"?Math.round(e)?!1:e==this._value:!1}_value},ee=class extends G{isBool(){return!0}toBoolean(e=!1){return this._boolValue}getString(e,t){return this._stringBuffer=this._boolValue?"true":"false",this._stringBuffer}equals(e){return typeof e=="boolean"?e==this._boolValue:!1}isStatic(){return!0}constructor(e){super(),this._boolValue=e}static trueValue;static falseValue;_boolValue},Ve=class extends G{constructor(e){super(),this._stringBuffer=e}isString(){return!0}getString(e,t){return this._stringBuffer}equals(e){return typeof e=="string"?this._stringBuffer==e:!1}},Ye=class extends Ve{isStatic(){return this._isStatic}setErrorNotForClientCall(e){return this._stringBuffer=e,this}constructor(e,t){typeof e=="string"?super(e):super(e),this._isStatic=t}isError(){return!0}_isStatic},Fe=class extends G{isNull(){return!0}getString(e,t){return this._stringBuffer}isStatic(){return!0}setErrorNotForClientCall(e){return this._stringBuffer=e,Ye.nullValue}constructor(){super(),this._stringBuffer="NullValue"}},sr=class extends G{constructor(){super(),this._array=new Array}release(){for(let e=0;e<this._array.length;e++){let t=this._array[e];t&&!t.isStatic()&&(t=void 0,t=null)}}isArray(){return!0}getValueByIndex(e){if(e<0||this._array.length<=e)return G.errorValue.setErrorNotForClientCall(oa);let t=this._array[e];return t??G.nullValue}getValueByString(e){return G.errorValue.setErrorNotForClientCall(ft)}getString(e,t){let r=t+`[
|
|
13
13
|
`;for(let i=0;i<this._array.length;i++){let s=this._array[i];this._stringBuffer+=t+""+s.getString(t+" ")+`
|
|
14
14
|
`}return this._stringBuffer=r+t+`]
|
|
15
|
-
`,this._stringBuffer}add(e){this._array.push(e)}getVector(e=null){return this._array}getSize(){return this._array.length}_array},Oe=class extends
|
|
15
|
+
`,this._stringBuffer}add(e){this._array.push(e)}getVector(e=null){return this._array}getSize(){return this._array.length}_array},Oe=class extends G{constructor(){super(),this._map=new Map}release(){this._map.clear()}isMap(){return!0}getValueByString(e){let t=this._map.get(e);return t??G.nullValue}getValueByIndex(e){return G.errorValue.setErrorNotForClientCall(ft)}getString(e,t){this._stringBuffer=t+`{
|
|
16
16
|
`;for(let r of this._map){let i=r[0],s=r[1];this._stringBuffer+=t+" "+i+" : "+s.getString(t+" ")+`
|
|
17
17
|
`}return this._stringBuffer+=t+`}
|
|
18
|
-
`,this._stringBuffer}getMap(e){return this._map}put(e,t){this._map.set(e,t)}getKeys(){return this._keys||(this._keys=[...this._map.keys()]),this._keys}getSize(){return this._keys.length}_map;_keys};(function(e){e.CubismJson=X,e.JsonArray=sr,e.JsonBoolean=$,e.JsonError=Ye,e.JsonFloat=At,e.JsonMap=Oe,e.JsonNullvalue=Fe,e.JsonString=Ve,e.Value=N})(li||(li={}));Z=!1,xe=!1,Ee=null,Ge=null,ee=Object.freeze({vertexOffset:0,vertexStep:2});P=class{static startUp(e=null){if(Z)return ge("CubismFramework.startUp() is already done."),Z;if(Ee=e,Ee!=null&&Live2DCubismCore.Logging.csmSetLogFunction(Ee.logFunction),Z=!0,Z){let t=Live2DCubismCore.Version.csmGetVersion(),r=(t&4278190080)>>24,i=(t&16711680)>>16,s=t&65535,n=t;ge("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+r).slice(-2),("00"+i).slice(-2),("0000"+s).slice(-4),n)}return ge("CubismFramework.startUp() is complete."),Z}static cleanUp(){Z=!1,xe=!1,Ee=null,Ge=null}static initialize(e=0){if(Q(Z),!Z){O("CubismFramework is not started.");return}if(xe){O("CubismFramework.initialize() skipped, already initialized.");return}N.staticInitializeNotForClientCall(),Ge=new ys,Live2DCubismCore.Memory.initializeAmountOfMemory(e),xe=!0,ge("CubismFramework.initialize() is complete.")}static dispose(){if(Q(Z),!Z){O("CubismFramework is not started.");return}if(!xe){O("CubismFramework.dispose() skipped, not initialized.");return}N.staticReleaseNotForClientCall(),Ge.release(),Ge=null,mt.staticRelease(),xe=!1,ge("CubismFramework.dispose() is complete.")}static isStarted(){return Z}static isInitialized(){return xe}static coreLogFunction(e){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(e)}static getLoggingLevel(){return Ee!=null?Ee.loggingLevel:5}static getIdManager(){return Ge}constructor(){}};(function(e){e.Constant=ee,e.csmDelete=Le,e.CubismFramework=P})(ui||(ui={}));ua=(function(e){return e[e.FrequestNode_Groups=0]="FrequestNode_Groups",e[e.FrequestNode_Moc=1]="FrequestNode_Moc",e[e.FrequestNode_Motions=2]="FrequestNode_Motions",e[e.FrequestNode_Expressions=3]="FrequestNode_Expressions",e[e.FrequestNode_Textures=4]="FrequestNode_Textures",e[e.FrequestNode_Physics=5]="FrequestNode_Physics",e[e.FrequestNode_Pose=6]="FrequestNode_Pose",e[e.FrequestNode_HitAreas=7]="FrequestNode_HitAreas",e})({}),Bs=class extends _s{constructor(e,t){super(),this._json=X.create(e,t),this.getJson()&&(this._jsonValue=[this.getJson().getRoot().getValueByString(this.groups),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.moc),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.motions),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.expressions),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.textures),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.physics),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.pose),this.getJson().getRoot().getValueByString(this.hitAreas)])}release(){X.delete(this._json),this._jsonValue=null}getJson(){return this._json}getModelFileName(){return this.isExistModelFile()?this._jsonValue[1].getRawString():""}getTextureCount(){return this.isExistTextureFiles()?this._jsonValue[4].getSize():0}getTextureDirectory(){let e=this._jsonValue[4].getValueByIndex(0).getRawString().split("/"),t=e.length-1,r="";for(let i=0;i<t;i++)r+=e[i],i<t-1&&(r+="/");return r}getTextureFileName(e){return this._jsonValue[4].getValueByIndex(e).getRawString()}getHitAreasCount(){return this.isExistHitAreas()?this._jsonValue[7].getSize():0}getHitAreaId(e){return P.getIdManager().getId(this._jsonValue[7].getValueByIndex(e).getValueByString(this.id).getRawString())}getHitAreaName(e){return this._jsonValue[7].getValueByIndex(e).getValueByString(this.name).getRawString()}getPhysicsFileName(){return this.isExistPhysicsFile()?this._jsonValue[5].getRawString():""}getPoseFileName(){return this.isExistPoseFile()?this._jsonValue[6].getRawString():""}getExpressionCount(){return this.isExistExpressionFile()?this._jsonValue[3].getSize():0}getExpressionName(e){return this._jsonValue[3].getValueByIndex(e).getValueByString(this.name).getRawString()}getExpressionFileName(e){return this._jsonValue[3].getValueByIndex(e).getValueByString(this.filePath).getRawString()}getMotionGroupCount(){return this.isExistMotionGroups()?this._jsonValue[2].getKeys().length:0}getMotionGroupName(e){return this.isExistMotionGroups()?this._jsonValue[2].getKeys()[e]:null}getMotionCount(e){return this.isExistMotionGroupName(e)?this._jsonValue[2].getValueByString(e).getSize():0}getMotionFileName(e,t){return this.isExistMotionGroupName(e)?this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.filePath).getRawString():""}getMotionSoundFileName(e,t){return this.isExistMotionSoundFile(e,t)?this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.soundPath).getRawString():""}getMotionFadeInTimeValue(e,t){return this.isExistMotionFadeIn(e,t)?this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.fadeInTime).toFloat():-1}getMotionFadeOutTimeValue(e,t){return this.isExistMotionFadeOut(e,t)?this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.fadeOutTime).toFloat():-1}getUserDataFile(){return this.isExistUserDataFile()?this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData).getRawString():""}getLayoutMap(e){let t=this.getJson().getRoot().getValueByString(this.layout).getMap();if(t==null)return!1;let r=!1;for(let i of t)e.set(i[0],i[1].toFloat()),r=!0;return r}getEyeBlinkParameterCount(){if(!this.isExistEyeBlinkParameters())return 0;let e=0;for(let t=0;t<this._jsonValue[0].getSize();t++){let r=this._jsonValue[0].getValueByIndex(t);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.eyeBlink){e=r.getValueByString(this.ids).getVector().length;break}}return e}getEyeBlinkParameterId(e){if(!this.isExistEyeBlinkParameters())return null;for(let t=0;t<this._jsonValue[0].getSize();t++){let r=this._jsonValue[0].getValueByIndex(t);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.eyeBlink)return P.getIdManager().getId(r.getValueByString(this.ids).getValueByIndex(e).getRawString())}return null}getLipSyncParameterCount(){if(!this.isExistLipSyncParameters())return 0;let e=0;for(let t=0;t<this._jsonValue[0].getSize();t++){let r=this._jsonValue[0].getValueByIndex(t);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.lipSync){e=r.getValueByString(this.ids).getVector().length;break}}return e}getLipSyncParameterId(e){if(!this.isExistLipSyncParameters())return null;for(let t=0;t<this._jsonValue[0].getSize();t++){let r=this._jsonValue[0].getValueByIndex(t);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.lipSync)return P.getIdManager().getId(r.getValueByString(this.ids).getValueByIndex(e).getRawString())}return null}isExistModelFile(){let e=this._jsonValue[1];return!e.isNull()&&!e.isError()}isExistTextureFiles(){let e=this._jsonValue[4];return!e.isNull()&&!e.isError()}isExistHitAreas(){let e=this._jsonValue[7];return!e.isNull()&&!e.isError()}isExistPhysicsFile(){let e=this._jsonValue[5];return!e.isNull()&&!e.isError()}isExistPoseFile(){let e=this._jsonValue[6];return!e.isNull()&&!e.isError()}isExistExpressionFile(){let e=this._jsonValue[3];return!e.isNull()&&!e.isError()}isExistMotionGroups(){let e=this._jsonValue[2];return!e.isNull()&&!e.isError()}isExistMotionGroupName(e){let t=this._jsonValue[2].getValueByString(e);return!t.isNull()&&!t.isError()}isExistMotionSoundFile(e,t){let r=this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.soundPath);return!r.isNull()&&!r.isError()}isExistMotionFadeIn(e,t){let r=this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.fadeInTime);return!r.isNull()&&!r.isError()}isExistMotionFadeOut(e,t){let r=this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.fadeOutTime);return!r.isNull()&&!r.isError()}isExistUserDataFile(){let e=this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData);return!e.isNull()&&!e.isError()}isExistEyeBlinkParameters(){if(this._jsonValue[0].isNull()||this._jsonValue[0].isError())return!1;for(let e=0;e<this._jsonValue[0].getSize();++e)if(this._jsonValue[0].getValueByIndex(e).getValueByString(this.name).getRawString()==this.eyeBlink)return!0;return!1}isExistLipSyncParameters(){if(this._jsonValue[0].isNull()||this._jsonValue[0].isError())return!1;for(let e=0;e<this._jsonValue[0].getSize();++e)if(this._jsonValue[0].getValueByIndex(e).getValueByString(this.name).getRawString()==this.lipSync)return!0;return!1}_json;_jsonValue;version="Version";fileReferences="FileReferences";groups="Groups";layout="Layout";hitAreas="HitAreas";moc="Moc";textures="Textures";physics="Physics";pose="Pose";expressions="Expressions";motions="Motions";userData="UserData";name="Name";filePath="File";id="Id";ids="Ids";target="Target";idle="Idle";tapBody="TapBody";pinchIn="PinchIn";pinchOut="PinchOut";shake="Shake";flickHead="FlickHead";parameter="Parameter";soundPath="Sound";fadeInTime="FadeInTime";fadeOutTime="FadeOutTime";centerX="CenterX";centerY="CenterY";x="X";y="Y";width="Width";height="Height";lipSync="LipSync";eyeBlink="EyeBlink";initParameter="init_param";initPartsVisible="init_parts_visible";val="val"};(function(e){e.CubismModelSettingJson=Bs,e.FrequestNode=ua})(hi||(hi={}));nr=class Is{static create(){return new Is}static delete(t){t!=null&&(t=null)}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,r){this._currentTime+=r;let i=this._currentTime*2*Math.PI;for(let s=0;s<this._breathParameters.length;++s){let n=this._breathParameters[s];t.addParameterValueById(n.parameterId,n.offset+n.peak*Math.sin(i/n.cycle),n.weight)}}constructor(){this._currentTime=0}_breathParameters;_currentTime},De=class{constructor(e,t,r,i,s){this.parameterId=e??null,this.offset=t??0,this.peak=r??0,this.cycle=i??0,this.weight=s??0}parameterId;offset;peak;cycle;weight};(function(e){e.BreathParameterData=De,e.CubismBreath=nr})(ci||(ci={}));ar=class zt{static create(t=null){return new zt(t)}static delete(t){t!=null&&(t=null)}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,r,i){this._closingSeconds=t,this._closedSeconds=r,this._openingSeconds=i}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(t,r){this._userTimeSeconds+=r;let i,s=0;switch(this._blinkingState){case 2:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,s>=1&&(s=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),i=1-s;break;case 3:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,s>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),i=0;break;case 4:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,s>=1&&(s=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),i=s;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),i=1;break;default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),i=1;break}zt.CloseIfZero||(i=-i);for(let n=0;n<this._parameterIds.length;++n)t.setParameterValueById(this._parameterIds[n],i)}constructor(t){if(this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=new Array,t!=null){this._parameterIds.length=t.getEyeBlinkParameterCount();for(let r=0;r<t.getEyeBlinkParameterCount();++r)this._parameterIds[r]=t.getEyeBlinkParameterId(r)}}determinNextBlinkingTiming(){let t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}_blinkingState;_parameterIds;_nextBlinkingTime;_stateStartTimeSeconds;_blinkingIntervalSeconds;_closingSeconds;_closedSeconds;_openingSeconds;_userTimeSeconds;static CloseIfZero=!0},ha=(function(e){return e[e.EyeState_First=0]="EyeState_First",e[e.EyeState_Interval=1]="EyeState_Interval",e[e.EyeState_Closing=2]="EyeState_Closing",e[e.EyeState_Closed=3]="EyeState_Closed",e[e.EyeState_Opening=4]="EyeState_Opening",e})({});(function(e){e.CubismEyeBlink=ar,e.EyeState=ha})(di||(di={}));Jt=class Ss{static create(){return new Ss}static delete(t){t!=null&&(t=null)}setParameters(t){this._lookParameters=t}getParameters(){return this._lookParameters}updateParameters(t,r,i){for(let s=0;s<this._lookParameters.length;++s){let n=this._lookParameters[s];t.addParameterValueById(n.parameterId,n.factorX*r+n.factorY*i+n.factorXY*r*i)}}constructor(){this._lookParameters=new Array}_lookParameters},Ie=class{constructor(e,t,r,i){this.parameterId=e??null,this.factorX=t??0,this.factorY=r??0,this.factorXY=i??0}parameterId;factorX;factorY;factorXY};(function(e){e.LookParameterData=Ie,e.CubismLook=Jt})(gi||(gi={}));or=class extends ne{constructor(e,t){super(),this._width=e!==void 0?e:0,this._height=t!==void 0?t:0,this.setHeight(2)}setWidth(e){let t=e/this._width,r=t;this.scale(t,r)}setHeight(e){let t=e/this._height,r=t;this.scale(t,r)}setPosition(e,t){this.translate(e,t)}setCenterPosition(e,t){this.centerX(e),this.centerY(t)}top(e){this.setY(e)}bottom(e){let t=this._height*this.getScaleY();this.translateY(e-t)}left(e){this.setX(e)}right(e){let t=this._width*this.getScaleX();this.translateX(e-t)}centerX(e){let t=this._width*this.getScaleX();this.translateX(e-t/2)}setX(e){this.translateX(e)}centerY(e){let t=this._height*this.getScaleY();this.translateY(e-t/2)}setY(e){this.translateY(e)}setupFromLayout(e){let t="width",r="height",n="center_x",a="center_y",o="bottom",u="left",h="right";for(let d of e){let c=d[0],g=d[1];c==t?this.setWidth(g):c==r&&this.setHeight(g)}for(let d of e){let c=d[0],g=d[1];c=="x"?this.setX(g):c=="y"?this.setY(g):c==n?this.centerX(g):c==a?this.centerY(g):c=="top"?this.top(g):c==o?this.bottom(g):c==u?this.left(g):c==h&&this.right(g)}}_width;_height};(function(e){e.CubismModelMatrix=or})(fi||(fi={}));ca=.001,Ft=.5,Ai="FadeInTime",pi="Link",da="Groups",ga="Id",jt=class Ms{static create(t,r){let i=X.create(t,r);if(!i)return null;let s=new Ms,n=i.getRoot();n.getValueByString(Ai).isNull()||(s._fadeTimeSeconds=n.getValueByString(Ai).toFloat(Ft),s._fadeTimeSeconds<0&&(s._fadeTimeSeconds=Ft));let a=n.getValueByString(da),l=a.getSize();s._partGroupCounts.length=l;for(let o=0;o<l;++o){let u=a.getValueByIndex(o),h=u.getSize(),d=0;for(let c=0;c<h;++c){let g=u.getValueByIndex(c),f=new qt;if(f.partId=P.getIdManager().getId(g.getValueByString(ga).getRawString()),!g.getValueByString(pi).isNull()){let p=g.getValueByString(pi),A=p.getSize();for(let _=0;_<A;++_){let y=new qt;y.partId=P.getIdManager().getId(p.getValueByIndex(_).getString()),f.link.push(y)}}s._partGroups.push(f.clone()),++d}s._partGroupCounts[o]=d}return X.delete(i),s}static delete(t){t!=null&&(t=null)}updateParameters(t,r){t!=this._lastModel&&this.reset(t),this._lastModel=t,r<0&&(r=0);let i=0;for(let s=0;s<this._partGroupCounts.length;s++){let n=this._partGroupCounts[s];this.doFade(t,r,i,n),i+=n}this.copyPartOpacities(t)}reset(t){let r=0;for(let i=0;i<this._partGroupCounts.length;++i){let s=this._partGroupCounts[i];for(let n=r;n<r+s;++n){this._partGroups[n].initialize(t);let a=this._partGroups[n].partIndex,l=this._partGroups[n].parameterIndex;if(!(a<0)){t.setPartOpacityByIndex(a,n==r?1:0),t.setParameterValueByIndex(l,n==r?1:0);for(let o=0;o<this._partGroups[n].link.length;++o)this._partGroups[n].link[o].initialize(t)}}r+=s}}copyPartOpacities(t){for(let r=0;r<this._partGroups.length;++r){let i=this._partGroups[r];if(i.link.length==0)continue;let s=this._partGroups[r].partIndex,n=t.getPartOpacityByIndex(s);for(let a=0;a<i.link.length;++a){let l=i.link[a].partIndex;l<0||t.setPartOpacityByIndex(l,n)}}}doFade(t,r,i,s){let n=-1,a=1,l=.5,o=.15;for(let u=i;u<i+s;++u){let h=this._partGroups[u].partIndex,d=this._partGroups[u].parameterIndex;if(t.getParameterValueByIndex(d)>ca){if(n>=0)break;if(n=u,this._fadeTimeSeconds==0){a=1;continue}a=t.getPartOpacityByIndex(h),a+=r/this._fadeTimeSeconds,a>1&&(a=1)}}n<0&&(n=0,a=1);for(let u=i;u<i+s;++u){let h=this._partGroups[u].partIndex;if(n==u)t.setPartOpacityByIndex(h,a);else{let d=t.getPartOpacityByIndex(h),c;a<l?c=a*(l-1)/l+1:c=(1-a)*l/(1-l),(1-c)*(1-a)>o&&(c=1-o/(1-a)),d>c&&(d=c),t.setPartOpacityByIndex(h,d)}}}constructor(){this._fadeTimeSeconds=Ft,this._lastModel=null,this._partGroups=new Array,this._partGroupCounts=new Array}_partGroups;_partGroupCounts;_fadeTimeSeconds;_lastModel},qt=class ws{constructor(t){if(this.parameterIndex=0,this.partIndex=0,this.link=new Array,t!=null){this.partId=t.partId,this.link.length=t.link.length;for(let r=0;r<t.link.length;r++)this.link[r]=t.link[r].clone()}}assignment(t){this.partId=t.partId;let r=this.link.length;this.link.length+=t.link.length;for(let i of t.link)this.link[r++]=i.clone();return this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){let t=new ws;t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=new Array,t.link.length=this.link.length;for(let r=0;r<this.link.length;r++)t.link[r]=this.link[r].clone();return t}partId;parameterIndex;partIndex;link};(function(e){e.CubismPose=jt,e.PartData=qt})(mi||(mi={}));Ot=30,_i=.01,xs=class{constructor(){this._faceTargetX=0,this._faceTargetY=0,this._faceX=0,this._faceY=0,this._faceVX=0,this._faceVY=0,this._lastTimeSeconds=0,this._userTimeSeconds=0}update(e){this._userTimeSeconds+=e;let t=40/10*1/Ot;if(this._lastTimeSeconds==0){this._lastTimeSeconds=this._userTimeSeconds;return}let r=(this._userTimeSeconds-this._lastTimeSeconds)*Ot;this._lastTimeSeconds=this._userTimeSeconds;let i=.15*Ot,s=r*t/i,n=this._faceTargetX-this._faceX,a=this._faceTargetY-this._faceY;if(w.abs(n)<=_i&&w.abs(a)<=_i)return;let l=w.sqrt(n*n+a*a),o=t*n/l,u=t*a/l,h=o-this._faceVX,d=u-this._faceVY,c=w.sqrt(h*h+d*d);(c<-s||c>s)&&(h*=s/c,d*=s/c),this._faceVX+=h,this._faceVY+=d;{let g=.5*(w.sqrt(s*s+16*s*l-8*s*l)-s),f=w.sqrt(this._faceVX*this._faceVX+this._faceVY*this._faceVY);f>g&&(this._faceVX*=g/f,this._faceVY*=g/f)}this._faceX+=this._faceVX,this._faceY+=this._faceVY}getX(){return this._faceX}getY(){return this._faceY}set(e,t){this._faceTargetX=e,this._faceTargetY=t}_faceTargetX;_faceTargetY;_faceX;_faceY;_faceVX;_faceVY;_lastTimeSeconds;_userTimeSeconds};(function(e){e.CubismTargetPoint=xs})(Ci||(Ci={}));Es=class{constructor(){this._autoDelete=!1,this._motion=null,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&Se.delete(this._motion)}setFadeOut(e){this._fadeOutSeconds=e,this._isTriggeredFadeOut=!0}startFadeOut(e,t){let r=t+e;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||r<this._endTimeSeconds)&&(this._endTimeSeconds=r)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(e){this._startTimeSeconds=e}setFadeInStartTime(e){this._fadeInStartTimeSeconds=e}setEndTime(e){this._endTimeSeconds=e}setIsFinished(e){this._finished=e}setIsStarted(e){this._started=e}isAvailable(){return this._available}setIsAvailable(e){this._available=e}setState(e,t){this._stateTimeSeconds=e,this._stateWeight=t}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(e){this._lastEventCheckSeconds=e}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}getCubismMotion(){return this._motion}_autoDelete;_motion;_available;_finished;_started;_startTimeSeconds;_fadeInStartTimeSeconds;_endTimeSeconds;_stateTimeSeconds;_stateWeight;_lastEventCheckSeconds;_fadeOutSeconds;_isTriggeredFadeOut;_motionQueueEntryHandle};(function(e){e.CubismMotionQueueEntry=Es})(yi||(yi={}));Se=class{static delete(e){e.release(),e=null}constructor(){this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._isLoop=!1,this._isLoopFadeIn=!0,this._previousLoopState=this._isLoop,this._firedEventValues=new Array}release(){this._weight=0}updateParameters(e,t,r){if(!t.isAvailable()||t.isFinished())return;this.setupMotionQueueEntry(t,r);let i=this.updateFadeWeight(t,r);this.doUpdateParameters(e,r,i,t),t.getEndTime()>0&&t.getEndTime()<r&&t.setIsFinished(!0)}setupMotionQueueEntry(e,t){e==null||e.isStarted()||e.isAvailable()&&(e.setIsStarted(!0),e.setStartTime(t-this._offsetSeconds),e.setFadeInStartTime(t),e.getEndTime()<0&&this.adjustEndTime(e),e._motion._onBeganMotion&&e._motion._onBeganMotion(e._motion))}updateFadeWeight(e,t){e==null&&ir.print(4,"motionQueueEntry is null.");let r=this._weight,i=this._fadeInSeconds==0?1:w.getEasingSine((t-e.getFadeInStartTime())/this._fadeInSeconds),s=this._fadeOutSeconds==0||e.getEndTime()<0?1:w.getEasingSine((e.getEndTime()-t)/this._fadeOutSeconds);return r=r*i*s,e.setState(t,r),Q(0<=r&&r<=1),r}setFadeInTime(e){this._fadeInSeconds=e}setFadeOutTime(e){this._fadeOutSeconds=e}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(e){this._weight=e}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(e){this._offsetSeconds=e}setLoop(e){this._isLoop=e}getLoop(){return this._isLoop}setLoopFadeIn(e){this._isLoopFadeIn=e}getLoopFadeIn(){return this._isLoopFadeIn}getFiredEvent(e,t){return this._firedEventValues}setBeganMotionHandler=e=>this._onBeganMotion=e;getBeganMotionHandler=()=>this._onBeganMotion;setFinishedMotionHandler=e=>this._onFinishedMotion=e;getFinishedMotionHandler=()=>this._onFinishedMotion;isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(e){return null}getModelOpacityValue(){return 1}adjustEndTime(e){let t=this.getDuration(),r=t<=0?-1:e.getStartTime()+t;e.setEndTime(r)}_fadeInSeconds;_fadeOutSeconds;_weight;_offsetSeconds;_isLoop;_isLoopFadeIn;_previousLoopState;_firedEventValues;_onBeganMotion;_onFinishedMotion};(function(e){e.ACubismMotion=Se})(bi||(bi={}));lr=class{constructor(){this._userTimeSeconds=0,this._eventCallBack=null,this._eventCustomData=null,this._motions=new Array}release(){for(let e=0;e<this._motions.length;++e)this._motions[e]&&(this._motions[e].release(),this._motions[e]=null);this._motions=null}startMotion(e,t,r){if(e==null)return-1;let i=null;for(let s=0;s<this._motions.length;++s)i=this._motions[s],i?.setFadeOut(i._motion.getFadeOutTime());return i=new Es,i._autoDelete=t,i._motion=e,this._motions.push(i),i._motionQueueEntryHandle}isFinished(){for(let e=0;e<this._motions.length;){let t=this._motions[e];if(t==null){this._motions.splice(e,1);continue}if(t._motion==null){t.release(),t=null,this._motions.splice(e,1);continue}if(t.isFinished())e++;else return!1}return!0}isFinishedByHandle(e){for(let t=0;t<this._motions.length;t++){let r=this._motions[t];if(r!=null&&r._motionQueueEntryHandle==e&&!r.isFinished())return!1}return!0}stopAllMotions(){for(let e=0;e<this._motions.length;e++){let t=this._motions[e];if(t==null){this._motions.splice(e,1);continue}t.release(),this._motions.splice(e,1)}}getCubismMotionQueueEntries(){return this._motions}getCubismMotionQueueEntry(e){for(let t=0;t<this._motions.length;t++){let r=this._motions[t];if(r!=null&&r._motionQueueEntryHandle==e)return r}return null}setEventCallback(e,t=null){this._eventCallBack=e,this._eventCustomData=t}doUpdateMotion(e,t){let r=!1;for(let i=0;i<this._motions.length;){let s=this._motions[i];if(s==null){this._motions.splice(i,1);continue}let n=s._motion;if(n==null){s.release(),s=null,this._motions.splice(i,1);continue}n.updateParameters(e,s,t),r=!0;let a=n.getFiredEvent(s.getLastCheckEventSeconds()-s.getStartTime(),t-s.getStartTime());for(let l=0;l<a.length;++l)this._eventCallBack(this,a[l],this._eventCustomData);s.setLastCheckEventSeconds(t),s.isFinished()?(s.release(),s=null,this._motions.splice(i,1)):(s.isTriggeredFadeOut()&&s.startFadeOut(s.getFadeOutSeconds(),t),i++)}return r}_userTimeSeconds;_motions;_eventCallBack;_eventCustomData};(function(e){e.CubismMotionQueueManager=lr,e.InvalidMotionQueueEntryHandleValue=-1})(Bi||(Bi={}));fa=class{parameterId;additiveValue;multiplyValue;overwriteValue},vs=class extends lr{constructor(){super(),this._expressionParameterValues=new Array,this._fadeWeights=new Array}release(){this._expressionParameterValues&&(Le(this._expressionParameterValues),this._expressionParameterValues=null),this._fadeWeights&&(Le(this._fadeWeights),this._fadeWeights=null)}getFadeWeight(e){return e<0||this._fadeWeights.length<1||e>=this._fadeWeights.length?(console.warn("Failed to get the fade weight value. The element at that index does not exist."),-1):this._fadeWeights[e]}setFadeWeight(e,t){if(e<0||this._fadeWeights.length<1||this._fadeWeights.length<=e){console.warn("Failed to set the fade weight value. The element at that index does not exist.");return}this._fadeWeights[e]=t}updateMotion(e,t){this._userTimeSeconds+=t;let r=!1,i=this.getCubismMotionQueueEntries(),s=0,n=0;if(this._fadeWeights.length!==i.length){let a=i.length-this._fadeWeights.length,l=this._fadeWeights.length;this._fadeWeights.length+=a;for(let o=0;o<a;o++)this._fadeWeights[l++]=0}for(let a=0;a<this._motions.length;){let l=this._motions[a];if(l==null){i.splice(a,1);continue}let o=l.getCubismMotion();if(o==null){Le(l),i.splice(a,1);continue}let u=o.getExpressionParameters();if(l.isAvailable())for(let h=0;h<u.length;++h){if(u[h].parameterId==null)continue;let d=-1;for(let g=0;g<this._expressionParameterValues.length;++g)if(this._expressionParameterValues[g].parameterId==u[h].parameterId){d=g;break}if(d>=0)continue;let c=new fa;c.parameterId=u[h].parameterId,c.additiveValue=Te.DefaultAdditiveValue,c.multiplyValue=Te.DefaultMultiplyValue,c.overwriteValue=e.getParameterValueById(c.parameterId),this._expressionParameterValues.push(c)}o.setupMotionQueueEntry(l,this._userTimeSeconds),this.setFadeWeight(n,o.updateFadeWeight(l,this._userTimeSeconds)),o.calculateExpressionParameters(e,this._userTimeSeconds,l,this._expressionParameterValues,n,this.getFadeWeight(n)),s+=o.getFadeInTime()==0?1:w.getEasingSine((this._userTimeSeconds-l.getFadeInStartTime())/o.getFadeInTime()),r=!0,l.isTriggeredFadeOut()&&l.startFadeOut(l.getFadeOutSeconds(),this._userTimeSeconds),++a,++n}if(i.length>1&&this.getFadeWeight(this._fadeWeights.length-1)>=1)for(let a=i.length-2;a>=0;--a){let l=i[a];Le(l),i.splice(a,1),this._fadeWeights.splice(a,1)}s>1&&(s=1);for(let a=0;a<this._expressionParameterValues.length;++a){let l=this._expressionParameterValues[a];e.setParameterValueById(l.parameterId,(l.overwriteValue+l.additiveValue)*l.multiplyValue,s),l.additiveValue=Te.DefaultAdditiveValue,l.multiplyValue=Te.DefaultMultiplyValue}return r}_expressionParameterValues;_fadeWeights;_startExpressionTime};(function(e){e.CubismExpressionMotionManager=vs})(Ii||(Ii={}));Aa="FadeInTime",pa="FadeOutTime",Si="Parameters",ma="Id",_a="Value",rt="Blend",Ca="Add",ya="Multiply",ba="Overwrite",Mi=1,Te=class ie extends Se{static DefaultAdditiveValue=0;static DefaultMultiplyValue=1;static create(t,r){let i=new ie;return i.parse(t,r),i}doUpdateParameters(t,r,i,s){for(let n=0;n<this._parameters.length;++n){let a=this._parameters[n];switch(a.blendType){case 0:t.addParameterValueById(a.parameterId,a.value,i);break;case 1:t.multiplyParameterValueById(a.parameterId,a.value,i);break;case 2:t.setParameterValueById(a.parameterId,a.value,i);break;default:break}}}calculateExpressionParameters(t,r,i,s,n,a){if(!(i==null||s==null)&&i.isAvailable())for(let l=0;l<s.length;++l){let o=s[l];if(o.parameterId==null)continue;let u=o.overwriteValue=t.getParameterValueById(o.parameterId),h=this.getExpressionParameters(),d=-1;for(let A=0;A<h.length;++A)if(o.parameterId==h[A].parameterId){d=A;break}if(d<0){n==0?(o.additiveValue=ie.DefaultAdditiveValue,o.multiplyValue=ie.DefaultMultiplyValue,o.overwriteValue=u):(o.additiveValue=this.calculateValue(o.additiveValue,ie.DefaultAdditiveValue,a),o.multiplyValue=this.calculateValue(o.multiplyValue,ie.DefaultMultiplyValue,a),o.overwriteValue=this.calculateValue(o.overwriteValue,u,a));continue}let c=h[d].value,g,f,p;switch(h[d].blendType){case 0:g=c,f=ie.DefaultMultiplyValue,p=u;break;case 1:g=ie.DefaultAdditiveValue,f=c,p=u;break;case 2:g=ie.DefaultAdditiveValue,f=ie.DefaultMultiplyValue,p=c;break;default:return}n==0?(o.additiveValue=g,o.multiplyValue=f,o.overwriteValue=p):(o.additiveValue=o.additiveValue*(1-a)+g*a,o.multiplyValue=o.multiplyValue*(1-a)+f*a,o.overwriteValue=o.overwriteValue*(1-a)+p*a)}}getExpressionParameters(){return this._parameters}parse(t,r){let i=X.create(t,r);if(!i)return;let s=i.getRoot();this.setFadeInTime(s.getValueByString(Aa).toFloat(Mi)),this.setFadeOutTime(s.getValueByString(pa).toFloat(Mi));let n=s.getValueByString(Si).getSize(),a=this._parameters.length;this._parameters.length+=n;for(let l=0;l<n;++l){let o=s.getValueByString(Si).getValueByIndex(l),u=P.getIdManager().getId(o.getValueByString(ma).getRawString()),h=o.getValueByString(_a).toFloat(),d;o.getValueByString(rt).isNull()||o.getValueByString(rt).getString()==Ca?d=0:o.getValueByString(rt).getString()==ya?d=1:o.getValueByString(rt).getString()==ba?d=2:d=0;let c=new Ps;c.parameterId=u,c.blendType=d,c.value=h,this._parameters[a++]=c}X.delete(i)}calculateValue(t,r,i){return t*(1-i)+r*i}constructor(){super(),this._parameters=new Array}_parameters},Ba=(function(e){return e[e.Additive=0]="Additive",e[e.Multiply=1]="Multiply",e[e.Overwrite=2]="Overwrite",e})({}),Ps=class{parameterId;blendType;value};(function(e){e.CubismExpressionMotion=Te,e.ExpressionBlendType=Ba,e.ExpressionParameter=Ps})(wi||(wi={}));Ia=(function(e){return e[e.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",e[e.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",e[e.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",e})({}),Sa=(function(e){return e[e.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",e[e.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",e[e.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",e[e.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",e})({}),ze=class{time=0;value=0},Rs=class{constructor(){this.evaluate=null,this.basePointIndex=0,this.segmentType=0}evaluate;basePointIndex;segmentType},Ds=class{constructor(){this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}type;id;segmentCount;baseSegmentIndex;fadeInTime;fadeOutTime},Ls=class{fireTime=0;value},Ts=class{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=new Array,this.segments=new Array,this.points=new Array,this.events=new Array}duration;loop;curveCount;eventCount;fps;curves;segments;points;events};(function(e){e.CubismMotionCurve=Ds,e.CubismMotionCurveTarget=Ia,e.CubismMotionData=Ts,e.CubismMotionEvent=Ls,e.CubismMotionPoint=ze,e.CubismMotionSegment=Rs,e.CubismMotionSegmentType=Sa})(xi||(xi={}));G="Meta",Ma="Duration",wa="Loop",xa="AreBeziersRestricted",Ea="CurveCount",va="Fps",Pa="TotalSegmentCount",Ra="TotalPointCount",ce="Curves",Da="Target",La="Id",it="FadeInTime",st="FadeOutTime",Ei="Segments",vi="UserData",Ta="UserDataCount",Fa="TotalUserDataSize",Oa="Time",Va="Value",Fs=class{constructor(e,t){this._json=X.create(e,t)}release(){X.delete(this._json)}getMotionDuration(){return this._json.getRoot().getValueByString(G).getValueByString(Ma).toFloat()}isMotionLoop(){return this._json.getRoot().getValueByString(G).getValueByString(wa).toBoolean()}hasConsistency(){let e=!0;if(!this._json||!this._json.getRoot())return!1;let t=this._json.getRoot().getValueByString(ce).getVector().length,r=0,i=0;for(let s=0;s<t;++s)for(let n=0;n<this.getMotionCurveSegmentCount(s);){switch(n==0&&(i+=1,n+=2),this.getMotionCurveSegment(s,n)){case 0:i+=1,n+=3;break;case 1:i+=3,n+=7;break;case 2:i+=1,n+=3;break;case 3:i+=1,n+=3;break;default:Q(0);break}++r}return t!=this.getMotionCurveCount()&&(O("The number of curves does not match the metadata."),e=!1),r!=this.getMotionTotalSegmentCount()&&(O("The number of segment does not match the metadata."),e=!1),i!=this.getMotionTotalPointCount()&&(O("The number of point does not match the metadata."),e=!1),e}getEvaluationOptionFlag(e){return e==0?this._json.getRoot().getValueByString(G).getValueByString(xa).toBoolean():!1}getMotionCurveCount(){return this._json.getRoot().getValueByString(G).getValueByString(Ea).toInt()}getMotionFps(){return this._json.getRoot().getValueByString(G).getValueByString(va).toFloat()}getMotionTotalSegmentCount(){return this._json.getRoot().getValueByString(G).getValueByString(Pa).toInt()}getMotionTotalPointCount(){return this._json.getRoot().getValueByString(G).getValueByString(Ra).toInt()}isExistMotionFadeInTime(){return!this._json.getRoot().getValueByString(G).getValueByString(it).isNull()}isExistMotionFadeOutTime(){return!this._json.getRoot().getValueByString(G).getValueByString(st).isNull()}getMotionFadeInTime(){return this._json.getRoot().getValueByString(G).getValueByString(it).toFloat()}getMotionFadeOutTime(){return this._json.getRoot().getValueByString(G).getValueByString(st).toFloat()}getMotionCurveTarget(e){return this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(Da).getRawString()}getMotionCurveId(e){return P.getIdManager().getId(this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(La).getRawString())}isExistMotionCurveFadeInTime(e){return!this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(it).isNull()}isExistMotionCurveFadeOutTime(e){return!this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(st).isNull()}getMotionCurveFadeInTime(e){return this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(it).toFloat()}getMotionCurveFadeOutTime(e){return this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(st).toFloat()}getMotionCurveSegmentCount(e){return this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(Ei).getVector().length}getMotionCurveSegment(e,t){return this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(Ei).getValueByIndex(t).toFloat()}getEventCount(){return this._json.getRoot().getValueByString(G).getValueByString(Ta).toInt()}getTotalEventValueSize(){return this._json.getRoot().getValueByString(G).getValueByString(Fa).toInt()}getEventTime(e){return this._json.getRoot().getValueByString(vi).getValueByIndex(e).getValueByString(Oa).toFloat()}getEventValue(e){return this._json.getRoot().getValueByString(vi).getValueByIndex(e).getValueByString(Va).getRawString()}_json};(function(e){e.CubismMotionJson=Fs})(Pi||(Pi={}));ka="EyeBlink",Qa="LipSync",Ua="Model",Na="Parameter",Ga="PartOpacity",nt="Opacity",Xa=!1;Qs=class Us extends Se{static create(t,r,i,s,n=!1){let a=new Us;if(a.parse(t,r,n),a._motionData)a._sourceFrameRate=a._motionData.fps,a._loopDurationSeconds=a._motionData.duration,a._onFinishedMotion=i,a._onBeganMotion=s;else return Le(a),null;return a}doUpdateParameters(t,r,i,s){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=P.getIdManager().getId(ka)),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=P.getIdManager().getId(Qa)),this._modelCurveIdOpacity==null&&(this._modelCurveIdOpacity=P.getIdManager().getId(nt)),this._motionBehavior===1&&this._previousLoopState!==this._isLoop&&(this.adjustEndTime(s),this._previousLoopState=this._isLoop);let n=r-s.getStartTime();n<0&&(n=0);let a=Number.MAX_VALUE,l=Number.MAX_VALUE,o=64,u=0,h=0;this._eyeBlinkParameterIds.length>o&&Wt("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>o&&Wt("too many lip sync targets : {0}",this._lipSyncParameterIds.length);let d=this._fadeInSeconds<=0?1:w.getEasingSine((r-s.getFadeInStartTime())/this._fadeInSeconds),c=this._fadeOutSeconds<=0||s.getEndTime()<0?1:w.getEasingSine((s.getEndTime()-r)/this._fadeOutSeconds),g,f,p,A=n,_=this._motionData.duration,y=this._motionBehavior===1&&this._isLoop;if(this._isLoop)for(this._motionBehavior===1&&(_+=1/this._motionData.fps);A>_;)A-=_;let C=this._motionData.curves;for(f=0;f<this._motionData.curveCount&&C[f].type==0;++f)g=Vt(this._motionData,f,A,y,_),C[f].id==this._modelCurveIdEyeBlink?l=g:C[f].id==this._modelCurveIdLipSync?a=g:C[f].id==this._modelCurveIdOpacity&&(this._modelOpacity=g,t.setModelOapcity(this.getModelOpacityValue()));let B=0;for(;f<this._motionData.curveCount&&C[f].type==1;++f){if(B++,p=t.getParameterIndex(C[f].id),p==-1)continue;let x=t.getParameterValueByIndex(p);if(g=Vt(this._motionData,f,A,y,_),l!=Number.MAX_VALUE){for(let M=0;M<this._eyeBlinkParameterIds.length&&M<o;++M)if(this._eyeBlinkParameterIds[M]==C[f].id){g*=l,h|=1<<M;break}}if(a!=Number.MAX_VALUE){for(let M=0;M<this._lipSyncParameterIds.length&&M<o;++M)if(this._lipSyncParameterIds[M]==C[f].id){g+=a,u|=1<<M;break}}t.isRepeat(p)&&(g=t.getParameterRepeatValue(p,g));let b;if(C[f].fadeInTime<0&&C[f].fadeOutTime<0)b=x+(g-x)*i;else{let M,L;C[f].fadeInTime<0?M=d:M=C[f].fadeInTime==0?1:w.getEasingSine((r-s.getFadeInStartTime())/C[f].fadeInTime),C[f].fadeOutTime<0?L=c:L=C[f].fadeOutTime==0||s.getEndTime()<0?1:w.getEasingSine((s.getEndTime()-r)/C[f].fadeOutTime);let k=this._weight*M*L;b=x+(g-x)*k}t.setParameterValueByIndex(p,b,1)}if(l!=Number.MAX_VALUE)for(let x=0;x<this._eyeBlinkParameterIds.length&&x<o;++x){let b=t.getParameterValueById(this._eyeBlinkParameterIds[x]);if(h>>x&1)continue;let M=b+(l-b)*i;t.setParameterValueById(this._eyeBlinkParameterIds[x],M)}if(a!=Number.MAX_VALUE)for(let x=0;x<this._lipSyncParameterIds.length&&x<o;++x){let b=t.getParameterValueById(this._lipSyncParameterIds[x]);if(u>>x&1)continue;let M=b+(a-b)*i;t.setParameterValueById(this._lipSyncParameterIds[x],M)}for(;f<this._motionData.curveCount&&C[f].type==2;++f)p=t.getParameterIndex(C[f].id),p!=-1&&(g=Vt(this._motionData,f,A,y,_),t.setParameterValueByIndex(p,g));n>=_&&(this._isLoop?this.updateForNextLoop(s,r,A):(this._onFinishedMotion&&this._onFinishedMotion(this),s.setIsFinished(!0))),this._lastWeight=i}setMotionBehavior(t){this._motionBehavior=t}getMotionBehavior(){return this._motionBehavior}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(t,r){let i=this._motionData.curves;for(let s=0;s<this._motionData.curveCount;++s)if(t==i[s].id){i[s].fadeInTime=r;return}}setParameterFadeOutTime(t,r){let i=this._motionData.curves;for(let s=0;s<this._motionData.curveCount;++s)if(t==i[s].id){i[s].fadeOutTime=r;return}}getParameterFadeInTime(t){let r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r[i].id)return r[i].fadeInTime;return-1}getParameterFadeOutTime(t){let r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r[i].id)return r[i].fadeOutTime;return-1}setEffectIds(t,r){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=r}constructor(){super(),this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._motionData=null,this._modelCurveIdEyeBlink=null,this._modelCurveIdLipSync=null,this._modelCurveIdOpacity=null,this._eyeBlinkParameterIds=null,this._lipSyncParameterIds=null,this._modelOpacity=1,this._debugMode=!1}release(){this._motionData=void 0,this._motionData=null}updateForNextLoop(t,r,i){switch(this._motionBehavior){case 1:default:t.setStartTime(r-i),this._isLoopFadeIn&&t.setFadeInStartTime(r-i),this._onFinishedMotion!=null&&this._onFinishedMotion(this);break;case 0:t.setStartTime(r),this._isLoopFadeIn&&t.setFadeInStartTime(r);break}}parse(t,r,i=!1){let s=new Fs(t,r);if(!s){s.release(),s=void 0;return}if(i&&!s.hasConsistency()){s.release(),D("Inconsistent motion3.json.");return}this._motionData=new Ts,this._motionData.duration=s.getMotionDuration(),this._motionData.loop=s.isMotionLoop(),this._motionData.curveCount=s.getMotionCurveCount(),this._motionData.fps=s.getMotionFps(),this._motionData.eventCount=s.getEventCount();let n=s.getEvaluationOptionFlag(0);s.isExistMotionFadeInTime()?this._fadeInSeconds=s.getMotionFadeInTime()<0?1:s.getMotionFadeInTime():this._fadeInSeconds=1,s.isExistMotionFadeOutTime()?this._fadeOutSeconds=s.getMotionFadeOutTime()<0?1:s.getMotionFadeOutTime():this._fadeOutSeconds=1,U(this._motionData.curves,this._motionData.curveCount,Ds,!0),U(this._motionData.segments,s.getMotionTotalSegmentCount(),Rs,!0),U(this._motionData.points,s.getMotionTotalPointCount(),ze,!0),U(this._motionData.events,this._motionData.eventCount,Ls,!0);let a=0,l=0;for(let o=0;o<this._motionData.curveCount;++o){s.getMotionCurveTarget(o)==Ua?this._motionData.curves[o].type=0:s.getMotionCurveTarget(o)==Na?this._motionData.curves[o].type=1:s.getMotionCurveTarget(o)==Ga?this._motionData.curves[o].type=2:O('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!'),this._motionData.curves[o].id=s.getMotionCurveId(o),this._motionData.curves[o].baseSegmentIndex=l,this._motionData.curves[o].fadeInTime=s.isExistMotionCurveFadeInTime(o)?s.getMotionCurveFadeInTime(o):-1,this._motionData.curves[o].fadeOutTime=s.isExistMotionCurveFadeOutTime(o)?s.getMotionCurveFadeOutTime(o):-1;for(let u=0;u<s.getMotionCurveSegmentCount(o);){switch(u==0?(this._motionData.segments[l].basePointIndex=a,this._motionData.points[a].time=s.getMotionCurveSegment(o,u),this._motionData.points[a].value=s.getMotionCurveSegment(o,u+1),a+=1,u+=2):this._motionData.segments[l].basePointIndex=a-1,s.getMotionCurveSegment(o,u)){case 0:this._motionData.segments[l].segmentType=0,this._motionData.segments[l].evaluate=Os,this._motionData.points[a].time=s.getMotionCurveSegment(o,u+1),this._motionData.points[a].value=s.getMotionCurveSegment(o,u+2),a+=1,u+=3;break;case 1:this._motionData.segments[l].segmentType=1,n||Xa?this._motionData.segments[l].evaluate=Ha:this._motionData.segments[l].evaluate=Wa,this._motionData.points[a].time=s.getMotionCurveSegment(o,u+1),this._motionData.points[a].value=s.getMotionCurveSegment(o,u+2),this._motionData.points[a+1].time=s.getMotionCurveSegment(o,u+3),this._motionData.points[a+1].value=s.getMotionCurveSegment(o,u+4),this._motionData.points[a+2].time=s.getMotionCurveSegment(o,u+5),this._motionData.points[a+2].value=s.getMotionCurveSegment(o,u+6),a+=3,u+=7;break;case 2:this._motionData.segments[l].segmentType=2,this._motionData.segments[l].evaluate=Vs,this._motionData.points[a].time=s.getMotionCurveSegment(o,u+1),this._motionData.points[a].value=s.getMotionCurveSegment(o,u+2),a+=1,u+=3;break;case 3:this._motionData.segments[l].segmentType=3,this._motionData.segments[l].evaluate=ks,this._motionData.points[a].time=s.getMotionCurveSegment(o,u+1),this._motionData.points[a].value=s.getMotionCurveSegment(o,u+2),a+=1,u+=3;break;default:Q(0);break}++this._motionData.curves[o].segmentCount,++l}}for(let o=0;o<s.getEventCount();++o)this._motionData.events[o].fireTime=s.getEventTime(o),this._motionData.events[o].value=s.getEventValue(o);s.release(),s=void 0,s=null}getFiredEvent(t,r){U(this._firedEventValues,0);for(let i=0;i<this._motionData.eventCount;++i)this._motionData.events[i].fireTime>t&&this._motionData.events[i].fireTime<=r&&this._firedEventValues.push(this._motionData.events[i].value);return this._firedEventValues}isExistModelOpacity(){for(let t=0;t<this._motionData.curveCount;t++){let r=this._motionData.curves[t];if(r.type==0&&r.id.getString().localeCompare(nt)==0)return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let t=0;t<this._motionData.curveCount;t++){let r=this._motionData.curves[t];if(r.type==0&&r.id.getString().localeCompare(nt)==0)return t}return-1}getModelOpacityId(t){if(t!=-1){let r=this._motionData.curves[t];if(r.type==0&&r.id.getString().localeCompare(nt)==0)return P.getIdManager().getId(r.id.getString())}return null}getModelOpacityValue(){return this._modelOpacity}setDebugMode(t){this._debugMode=t}_sourceFrameRate;_loopDurationSeconds;_motionBehavior=1;_lastWeight;_motionData;_eyeBlinkParameterIds;_lipSyncParameterIds;_modelCurveIdEyeBlink;_modelCurveIdLipSync;_modelCurveIdOpacity;_modelOpacity;_debugMode};(function(e){e.CubismMotion=Qs})(Ri||(Ri={}));Ns=class extends lr{constructor(){super(),this._currentPriority=0,this._reservePriority=0}getCurrentPriority(){return this._currentPriority}getReservePriority(){return this._reservePriority}setReservePriority(e){this._reservePriority=e}startMotionPriority(e,t,r){return r==this._reservePriority&&(this._reservePriority=0),this._currentPriority=r,super.startMotion(e,t)}updateMotion(e,t){this._userTimeSeconds+=t;let r=super.doUpdateMotion(e,this._userTimeSeconds);return this.isFinished()&&(this._currentPriority=0),r}reserveMotion(e){return e<=this._reservePriority||e<=this._currentPriority?!1:(this._reservePriority=e,!0)}_currentPriority;_reservePriority};(function(e){e.CubismMotionManager=Ns})(Di||(Di={}));za=(function(e){return e[e.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",e})({}),Ja=(function(e){return e[e.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",e[e.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",e[e.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",e})({}),ja=class{constructor(){this.gravity=new E(0,0),this.wind=new E(0,0)}gravity;wind},ur=class{id;targetType},Zt=class{minimum;maximum;defalut},Gs=class{constructor(){this.initialPosition=new E(0,0),this.position=new E(0,0),this.lastPosition=new E(0,0),this.lastGravity=new E(0,0),this.force=new E(0,0),this.velocity=new E(0,0)}initialPosition;mobility;delay;acceleration;radius;position;lastPosition;lastGravity;force;velocity},Xs=class{constructor(){this.normalizationPosition=new Zt,this.normalizationAngle=new Zt}inputCount;outputCount;particleCount;baseInputIndex;baseOutputIndex;baseParticleIndex;normalizationPosition;normalizationAngle},Hs=class{constructor(){this.source=new ur}source;sourceParameterIndex;weight;type;reflect;getNormalizedParameterValue},Ws=class{constructor(){this.destination=new ur,this.translationScale=new E(0,0)}destination;destinationParameterIndex;vertexIndex;translationScale;angleScale;weight;type;reflect;valueBelowMinimum;valueExceededMaximum;getValue;getScale},Ys=class{constructor(){this.settings=new Array,this.inputs=new Array,this.outputs=new Array,this.particles=new Array,this.gravity=new E(0,0),this.wind=new E(0,0),this.fps=0}subRigCount;settings;inputs;outputs;particles;gravity;wind;fps};(function(e){e.CubismPhysicsInput=Hs,e.CubismPhysicsNormalization=Zt,e.CubismPhysicsOutput=Ws,e.CubismPhysicsParameter=ur,e.CubismPhysicsParticle=Gs,e.CubismPhysicsRig=Ys,e.CubismPhysicsSource=Ja,e.CubismPhysicsSubRig=Xs,e.CubismPhysicsTargetType=za,e.PhysicsJsonEffectiveForces=ja})(Li||(Li={}));Xe="Position",kt="X",Qt="Y",Ut="Angle",Ti="Type",Fi="Id",de="Meta",at="EffectiveForces",qa="TotalInputCount",Za="TotalOutputCount",Ka="PhysicsSettingCount",Oi="Gravity",Vi="Wind",$a="VertexCount",eo="Fps",T="PhysicsSettings",ve="Normalization",ki="Minimum",Qi="Maximum",Ui="Default",Ni="Reflect",Gi="Weight",He="Input",to="Source",ye="Output",ro="Scale",io="VertexIndex",so="Destination",be="Vertices",no="Mobility",ao="Delay",oo="Radius",lo="Acceleration",zs=class{constructor(e,t){this._json=X.create(e,t)}release(){X.delete(this._json)}getGravity(){let e=new E(0,0);return e.x=this._json.getRoot().getValueByString(de).getValueByString(at).getValueByString(Oi).getValueByString(kt).toFloat(),e.y=this._json.getRoot().getValueByString(de).getValueByString(at).getValueByString(Oi).getValueByString(Qt).toFloat(),e}getWind(){let e=new E(0,0);return e.x=this._json.getRoot().getValueByString(de).getValueByString(at).getValueByString(Vi).getValueByString(kt).toFloat(),e.y=this._json.getRoot().getValueByString(de).getValueByString(at).getValueByString(Vi).getValueByString(Qt).toFloat(),e}getFps(){return this._json.getRoot().getValueByString(de).getValueByString(eo).toFloat(0)}getSubRigCount(){return this._json.getRoot().getValueByString(de).getValueByString(Ka).toInt()}getTotalInputCount(){return this._json.getRoot().getValueByString(de).getValueByString(qa).toInt()}getTotalOutputCount(){return this._json.getRoot().getValueByString(de).getValueByString(Za).toInt()}getVertexCount(){return this._json.getRoot().getValueByString(de).getValueByString($a).toInt()}getNormalizationPositionMinimumValue(e){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ve).getValueByString(Xe).getValueByString(ki).toFloat()}getNormalizationPositionMaximumValue(e){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ve).getValueByString(Xe).getValueByString(Qi).toFloat()}getNormalizationPositionDefaultValue(e){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ve).getValueByString(Xe).getValueByString(Ui).toFloat()}getNormalizationAngleMinimumValue(e){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ve).getValueByString(Ut).getValueByString(ki).toFloat()}getNormalizationAngleMaximumValue(e){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ve).getValueByString(Ut).getValueByString(Qi).toFloat()}getNormalizationAngleDefaultValue(e){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ve).getValueByString(Ut).getValueByString(Ui).toFloat()}getInputCount(e){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(He).getVector().length}getInputWeight(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(He).getValueByIndex(t).getValueByString(Gi).toFloat()}getInputReflect(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(He).getValueByIndex(t).getValueByString(Ni).toBoolean()}getInputType(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(He).getValueByIndex(t).getValueByString(Ti).getRawString()}getInputSourceId(e,t){return P.getIdManager().getId(this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(He).getValueByIndex(t).getValueByString(to).getValueByString(Fi).getRawString())}getOutputCount(e){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ye).getVector().length}getOutputVertexIndex(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(io).toInt()}getOutputAngleScale(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(ro).toFloat()}getOutputWeight(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(Gi).toFloat()}getOutputDestinationId(e,t){return P.getIdManager().getId(this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(so).getValueByString(Fi).getRawString())}getOutputType(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(Ti).getRawString()}getOutputReflect(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(Ni).toBoolean()}getParticleCount(e){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(be).getVector().length}getParticleMobility(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(no).toFloat()}getParticleDelay(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(ao).toFloat()}getParticleAcceleration(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(lo).toFloat()}getParticleRadius(e,t){return this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(oo).toFloat()}getParticlePosition(e,t){let r=new E(0,0);return r.x=this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(Xe).getValueByString(kt).toFloat(),r.y=this._json.getRoot().getValueByString(T).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(Xe).getValueByString(Qt).toFloat(),r}_json};(function(e){e.CubismPhysicsJson=zs})(Xi||(Xi={}));Hi="X",Wi="Y",Yi="Angle",uo=5,Kt=100,zi=.001,ho=5,$t=class Js{static create(t,r){let i=new Js;return i.parse(t,r),i._physicsRig.gravity.y=0,i}static delete(t){t!=null&&(t.release(),t=null)}parse(t,r){this._physicsRig=new Ys;let i=new zs(t,r);this._physicsRig.gravity=i.getGravity(),this._physicsRig.wind=i.getWind(),this._physicsRig.subRigCount=i.getSubRigCount(),this._physicsRig.fps=i.getFps(),U(this._physicsRig.settings,this._physicsRig.subRigCount,Xs,!0),U(this._physicsRig.inputs,i.getTotalInputCount(),Hs,!0),U(this._physicsRig.outputs,i.getTotalOutputCount(),Ws,!0),U(this._physicsRig.particles,i.getVertexCount(),Gs,!0),this._currentRigOutputs.length=0,this._previousRigOutputs.length=0;let s=0,n=0,a=0,l=this._currentRigOutputs.length,o=this._previousRigOutputs.length;this._currentRigOutputs.length+=this._physicsRig.settings.length,this._previousRigOutputs.length+=this._physicsRig.settings.length;for(let u=0;u<this._physicsRig.settings.length;++u){this._physicsRig.settings[u].normalizationPosition.minimum=i.getNormalizationPositionMinimumValue(u),this._physicsRig.settings[u].normalizationPosition.maximum=i.getNormalizationPositionMaximumValue(u),this._physicsRig.settings[u].normalizationPosition.defalut=i.getNormalizationPositionDefaultValue(u),this._physicsRig.settings[u].normalizationAngle.minimum=i.getNormalizationAngleMinimumValue(u),this._physicsRig.settings[u].normalizationAngle.maximum=i.getNormalizationAngleMaximumValue(u),this._physicsRig.settings[u].normalizationAngle.defalut=i.getNormalizationAngleDefaultValue(u),this._physicsRig.settings[u].inputCount=i.getInputCount(u),this._physicsRig.settings[u].baseInputIndex=s;for(let c=0;c<this._physicsRig.settings[u].inputCount;++c)this._physicsRig.inputs[s+c].sourceParameterIndex=-1,this._physicsRig.inputs[s+c].weight=i.getInputWeight(u,c),this._physicsRig.inputs[s+c].reflect=i.getInputReflect(u,c),i.getInputType(u,c)==Hi?(this._physicsRig.inputs[s+c].type=0,this._physicsRig.inputs[s+c].getNormalizedParameterValue=go):i.getInputType(u,c)==Wi?(this._physicsRig.inputs[s+c].type=1,this._physicsRig.inputs[s+c].getNormalizedParameterValue=fo):i.getInputType(u,c)==Yi&&(this._physicsRig.inputs[s+c].type=2,this._physicsRig.inputs[s+c].getNormalizedParameterValue=Ao),this._physicsRig.inputs[s+c].source.targetType=0,this._physicsRig.inputs[s+c].source.id=i.getInputSourceId(u,c);s+=this._physicsRig.settings[u].inputCount,this._physicsRig.settings[u].outputCount=i.getOutputCount(u),this._physicsRig.settings[u].baseOutputIndex=n;let h=new Ji;U(h.outputs,this._physicsRig.settings[u].outputCount,null,!0);let d=new Ji;U(d.outputs,this._physicsRig.settings[u].outputCount,null,!0);for(let c=0;c<this._physicsRig.settings[u].outputCount;++c)h.outputs[c]=0,d.outputs[c]=0,this._physicsRig.outputs[n+c].destinationParameterIndex=-1,this._physicsRig.outputs[n+c].vertexIndex=i.getOutputVertexIndex(u,c),this._physicsRig.outputs[n+c].angleScale=i.getOutputAngleScale(u,c),this._physicsRig.outputs[n+c].weight=i.getOutputWeight(u,c),this._physicsRig.outputs[n+c].destination.targetType=0,this._physicsRig.outputs[n+c].destination.id=i.getOutputDestinationId(u,c),i.getOutputType(u,c)==Hi?(this._physicsRig.outputs[n+c].type=0,this._physicsRig.outputs[n+c].getValue=po,this._physicsRig.outputs[n+c].getScale=bo):i.getOutputType(u,c)==Wi?(this._physicsRig.outputs[n+c].type=1,this._physicsRig.outputs[n+c].getValue=mo,this._physicsRig.outputs[n+c].getScale=Bo):i.getOutputType(u,c)==Yi&&(this._physicsRig.outputs[n+c].type=2,this._physicsRig.outputs[n+c].getValue=_o,this._physicsRig.outputs[n+c].getScale=Io),this._physicsRig.outputs[n+c].reflect=i.getOutputReflect(u,c);this._currentRigOutputs[l++]=h,this._previousRigOutputs[o++]=d,n+=this._physicsRig.settings[u].outputCount,this._physicsRig.settings[u].particleCount=i.getParticleCount(u),this._physicsRig.settings[u].baseParticleIndex=a;for(let c=0;c<this._physicsRig.settings[u].particleCount;++c)this._physicsRig.particles[a+c].mobility=i.getParticleMobility(u,c),this._physicsRig.particles[a+c].delay=i.getParticleDelay(u,c),this._physicsRig.particles[a+c].acceleration=i.getParticleAcceleration(u,c),this._physicsRig.particles[a+c].radius=i.getParticleRadius(u,c),this._physicsRig.particles[a+c].position=i.getParticlePosition(u,c);a+=this._physicsRig.settings[u].particleCount}this._inputSlices.length=this._physicsRig.subRigCount,this._outputSlices.length=this._physicsRig.subRigCount,this._particleSlices.length=this._physicsRig.subRigCount;for(let u=0;u<this._physicsRig.subRigCount;++u){let h=this._physicsRig.settings[u];this._inputSlices[u]=this._physicsRig.inputs.slice(h.baseInputIndex,h.baseInputIndex+h.inputCount),this._outputSlices[u]=this._physicsRig.outputs.slice(h.baseOutputIndex,h.baseOutputIndex+h.outputCount),this._particleSlices[u]=this._physicsRig.particles.slice(h.baseParticleIndex,h.baseParticleIndex+h.particleCount)}this.initialize(),i.release(),i=void 0,i=null}stabilization(t){let r,i,s,n,a=new E,l,o,u,h,d=t.getModel().parameters.values,c=t.getModel().parameters.maximumValues,g=t.getModel().parameters.minimumValues,f=t.getModel().parameters.defaultValues;(this._parameterCaches?.length??0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),(this._parameterInputCaches?.length??0)<t.getParameterCount()&&(this._parameterInputCaches=new Float32Array(t.getParameterCount()));for(let p=0;p<t.getParameterCount();++p)this._parameterCaches[p]=d[p],this._parameterInputCaches[p]=d[p];for(let p=0;p<this._physicsRig.subRigCount;++p){r={angle:0},a.x=0,a.y=0,l=this._physicsRig.settings[p],o=this._inputSlices[p],u=this._outputSlices[p],h=this._particleSlices[p];for(let A=0;A<l.inputCount;++A)i=o[A].weight/Kt,o[A].sourceParameterIndex==-1&&(o[A].sourceParameterIndex=t.getParameterIndex(o[A].source.id)),o[A].getNormalizedParameterValue(a,r,d[o[A].sourceParameterIndex],g[o[A].sourceParameterIndex],c[o[A].sourceParameterIndex],f[o[A].sourceParameterIndex],l.normalizationPosition,l.normalizationAngle,o[A].reflect,i),this._parameterCaches[o[A].sourceParameterIndex]=d[o[A].sourceParameterIndex];s=w.degreesToRadian(-r.angle),a.x=a.x*w.cos(s)-a.y*w.sin(s),a.y=a.x*w.sin(s)+a.y*w.cos(s),Mo(h,l.particleCount,a,r.angle,this._options.wind,zi*l.normalizationPosition.maximum);for(let A=0;A<l.outputCount;++A){let _=u[A].vertexIndex;if(u[A].destinationParameterIndex==-1&&(u[A].destinationParameterIndex=t.getParameterIndex(u[A].destination.id)),_<1||_>=l.particleCount)continue;let y=new E;y=h[_].position.substract(h[_-1].position),n=u[A].getValue(y,h,_,u[A].reflect,this._options.gravity),this._currentRigOutputs[p].outputs[A]=n,this._previousRigOutputs[p].outputs[A]=n;let C=u[A].destinationParameterIndex;Nt(d,C,g[C],c[C],n,u[A]),this._parameterCaches[C]=d[C]}}}evaluate(t,r){let i,s,n,a,l=new E,o,u,h,d;if(0>=r)return;let c=t.getModel().parameters.values,g=t.getModel().parameters.maximumValues,f=t.getModel().parameters.minimumValues,p=t.getModel().parameters.defaultValues,A;if(this._currentRemainTime+=r,this._currentRemainTime>ho&&(this._currentRemainTime=0),(this._parameterCaches?.length??0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),(this._parameterInputCaches?.length??0)<t.getParameterCount()){this._parameterInputCaches=new Float32Array(t.getParameterCount());for(let y=0;y<t.getParameterCount();++y)this._parameterInputCaches[y]=c[y]}for(this._physicsRig.fps>0?A=1/this._physicsRig.fps:A=r;this._currentRemainTime>=A;){for(let C=0;C<this._physicsRig.subRigCount;++C){o=this._physicsRig.settings[C],h=this._outputSlices[C];for(let B=0;B<o.outputCount;++B)this._previousRigOutputs[C].outputs[B]=this._currentRigOutputs[C].outputs[B]}let y=A/this._currentRemainTime;for(let C=0;C<t.getParameterCount();++C)this._parameterCaches[C]=this._parameterInputCaches[C]*(1-y)+c[C]*y,this._parameterInputCaches[C]=this._parameterCaches[C];for(let C=0;C<this._physicsRig.subRigCount;++C){i={angle:0},l.x=0,l.y=0,o=this._physicsRig.settings[C],u=this._inputSlices[C],h=this._outputSlices[C],d=this._particleSlices[C];for(let B=0;B<o.inputCount;++B)s=u[B].weight/Kt,u[B].sourceParameterIndex==-1&&(u[B].sourceParameterIndex=t.getParameterIndex(u[B].source.id)),u[B].getNormalizedParameterValue(l,i,this._parameterCaches[u[B].sourceParameterIndex],f[u[B].sourceParameterIndex],g[u[B].sourceParameterIndex],p[u[B].sourceParameterIndex],o.normalizationPosition,o.normalizationAngle,u[B].reflect,s);n=w.degreesToRadian(-i.angle),l.x=l.x*w.cos(n)-l.y*w.sin(n),l.y=l.x*w.sin(n)+l.y*w.cos(n),So(d,o.particleCount,l,i.angle,this._options.wind,zi*o.normalizationPosition.maximum,A,uo);for(let B=0;B<o.outputCount;++B){let x=h[B].vertexIndex;if(h[B].destinationParameterIndex==-1&&(h[B].destinationParameterIndex=t.getParameterIndex(h[B].destination.id)),x<1||x>=o.particleCount)continue;let b=new E;b.x=d[x].position.x-d[x-1].position.x,b.y=d[x].position.y-d[x-1].position.y,a=h[B].getValue(b,d,x,h[B].reflect,this._options.gravity),this._currentRigOutputs[C].outputs[B]=a;let M=h[B].destinationParameterIndex;Nt(this._parameterCaches,M,f[M],g[M],a,h[B])}}this._currentRemainTime-=A}let _=this._currentRemainTime/A;this.interpolate(t,_)}interpolate(t,r){let i,s,n=t.getModel().parameters.values,a=t.getModel().parameters.maximumValues,l=t.getModel().parameters.minimumValues;for(let o=0;o<this._physicsRig.subRigCount;++o){s=this._physicsRig.settings[o],i=this._outputSlices[o];for(let u=0;u<s.outputCount;++u){if(i[u].destinationParameterIndex==-1)continue;let h=i[u].destinationParameterIndex;Nt(n,h,l[h],a[h],this._previousRigOutputs[o].outputs[u]*(1-r)+this._currentRigOutputs[o].outputs[u]*r,i[u])}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._physicsRig=null,this._options=new js,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=new Array,this._previousRigOutputs=new Array,this._inputSlices=new Array,this._outputSlices=new Array,this._particleSlices=new Array,this._currentRemainTime=0,this._parameterCaches=null,this._parameterInputCaches=null}release(){this._inputSlices.length=0,this._outputSlices.length=0,this._particleSlices.length=0,this._physicsRig=void 0,this._physicsRig=null}initialize(){let t,r,i;for(let s=0;s<this._physicsRig.subRigCount;++s){r=this._physicsRig.settings[s],t=this._particleSlices[s],t[0].initialPosition=new E(0,0),t[0].lastPosition=new E(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new E(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new E(0,0),t[0].force=new E(0,0);for(let n=1;n<r.particleCount;++n)i=new E(0,0),i.y=t[n].radius,t[n].initialPosition=new E(t[n-1].initialPosition.x+i.x,t[n-1].initialPosition.y+i.y),t[n].position=new E(t[n].initialPosition.x,t[n].initialPosition.y),t[n].lastPosition=new E(t[n].initialPosition.x,t[n].initialPosition.y),t[n].lastGravity=new E(0,-1),t[n].lastGravity.y*=-1,t[n].velocity=new E(0,0),t[n].force=new E(0,0)}}_physicsRig;_options;_currentRigOutputs;_previousRigOutputs;_inputSlices;_outputSlices;_particleSlices;_currentRemainTime;_parameterCaches;_parameterInputCaches},js=class{constructor(){this.gravity=new E(0,0),this.wind=new E(0,0)}gravity;wind},Ji=class{constructor(){this.outputs=new Array(0)}outputs};(function(e){e.CubismPhysics=$t,e.Options=js})(ji||(ji={}));Gt=4,wo=36,xo=32,Eo=class{constructor(e){this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=new Array,this._clippingContextListForDraw=new Array,this._clippingContextListForOffscreen=new Array,this._tmpBoundsOnModel=new gt,this._tmpMatrix=new ne,this._tmpMatrixForMask=new ne,this._tmpMatrixForDraw=new ne,this._clearedMaskBufferFlags=new Array,this._clippingContexttConstructor=e,this._channelColors=[new R(1,0,0,0),new R(0,1,0,0),new R(0,0,1,0),new R(0,0,0,1)]}release(){for(let e=0;e<this._clippingContextListForMask.length;e++)this._clippingContextListForMask[e]&&(this._clippingContextListForMask[e].release(),this._clippingContextListForMask[e]=void 0),this._clippingContextListForMask[e]=null;this._clippingContextListForMask=null;for(let e=0;e<this._clippingContextListForDraw.length;e++)this._clippingContextListForDraw[e]=null;this._clippingContextListForDraw=null;for(let e=0;e<this._channelColors.length;e++)this._channelColors[e]=null;this._channelColors=null,this._clearedMaskBufferFlags!=null&&(this._clearedMaskBufferFlags.length=0),this._clearedMaskBufferFlags=null}initializeForDrawable(e,t){t%1!=0&&(O("The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer."),t=~~t),t<1&&O("The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1."),this._renderTextureCount=t<1?1:t,this._clearedMaskBufferFlags=new Array(this._renderTextureCount),this._clippingContextListForDraw.length=e.getDrawableCount();for(let r=0;r<e.getDrawableCount();r++){if(e.getDrawableMaskCounts()[r]<=0){this._clippingContextListForDraw[r]=null;continue}let i=this.findSameClip(e.getDrawableMasks()[r],e.getDrawableMaskCounts()[r]);i==null&&(i=new this._clippingContexttConstructor(this,e.getDrawableMasks()[r],e.getDrawableMaskCounts()[r]),this._clippingContextListForMask.push(i)),i.addClippedDrawable(r),this._clippingContextListForDraw[r]=i}}initializeForOffscreen(e,t){this._renderTextureCount=t,this._clearedMaskBufferFlags.length=this._renderTextureCount;for(let r=0;r<this._renderTextureCount;++r)this._clearedMaskBufferFlags[r]=!1;this._clippingContextListForOffscreen.length=e.getOffscreenCount();for(let r=0;r<e.getOffscreenCount();++r){if(e.getOffscreenMaskCounts()[r]<=0){this._clippingContextListForOffscreen.push(null);continue}let i=this.findSameClip(e.getOffscreenMasks()[r],e.getOffscreenMaskCounts()[r]);i==null&&(i=new this._clippingContexttConstructor(this,e.getOffscreenMasks()[r],e.getOffscreenMaskCounts()[r]),this._clippingContextListForMask.push(i)),i.addClippedOffscreen(r),this._clippingContextListForOffscreen[r]=i}}findSameClip(e,t){for(let r=0;r<this._clippingContextListForMask.length;r++){let i=this._clippingContextListForMask[r],s=i._clippingIdCount;if(s!=t)continue;let n=0;for(let a=0;a<s;a++){let l=i._clippingIdList[a];for(let o=0;o<s;o++)if(e[o]==l){n++;break}}if(n==s)return i}return null}setupMatrixForHighPrecision(e,t){let r=0;for(let i=0;i<this._clippingContextListForMask.length;i++){let s=this._clippingContextListForMask[i];this.calcClippedDrawableTotalBounds(e,s),s._isUsing&&r++}if(r>0){if(this.setupLayoutBounds(0),this._clearedMaskBufferFlags.length!=this._renderTextureCount){this._clearedMaskBufferFlags.length=this._renderTextureCount;for(let i=0;i<this._renderTextureCount;i++)this._clearedMaskBufferFlags[i]=!1}else for(let i=0;i<this._renderTextureCount;i++)this._clearedMaskBufferFlags[i]=!1;for(let i=0;i<this._clippingContextListForMask.length;i++){let s=this._clippingContextListForMask[i],n=s._allClippedDrawRect,a=s._layoutBounds,l=.05,o=0,u=0,h=e.getPixelsPerUnit(),d=s.getClippingManager().getClippingMaskBufferSize(),c=a.width*d,g=a.height*d;this._tmpBoundsOnModel.setRect(n),this._tmpBoundsOnModel.width*h>c?(this._tmpBoundsOnModel.expand(n.width*l,0),o=a.width/this._tmpBoundsOnModel.width):o=h/c,this._tmpBoundsOnModel.height*h>g?(this._tmpBoundsOnModel.expand(0,n.height*l),u=a.height/this._tmpBoundsOnModel.height):u=h/g,this.createMatrixForMask(t,a,o,u),s._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),s._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray())}}}setupMatrixForOffscreenHighPrecision(e,t,r){let i=0;for(let s=0;s<this._clippingContextListForMask.length;s++){let n=this._clippingContextListForMask[s];this.calcClippedOffscreenTotalBounds(e,n),n._isUsing&&i++}if(!(i<=0)){if(this.setupLayoutBounds(0),this._clearedMaskBufferFlags.length!=this._renderTextureCount){this._clearedMaskBufferFlags.length=this._renderTextureCount;for(let s=0;s<this._renderTextureCount;++s)this._clearedMaskBufferFlags[s]=!1}else for(let s=0;s<this._renderTextureCount;++s)this._clearedMaskBufferFlags[s]=!1;for(let s=0;s<this._clippingContextListForMask.length;s++){let n=this._clippingContextListForMask[s],a=n._allClippedDrawRect,l=n._layoutBounds,o=.05,u=0,h=0,d=e.getPixelsPerUnit(),c=n.getClippingManager().getClippingMaskBufferSize(),g=l.width*c,f=l.height*c;this._tmpBoundsOnModel.setRect(a),this._tmpBoundsOnModel.width*d>g?(this._tmpBoundsOnModel.expand(a.width*o,0),u=l.width/this._tmpBoundsOnModel.width):u=d/g,this._tmpBoundsOnModel.height*d>f?(this._tmpBoundsOnModel.expand(0,a.height*o),h=l.height/this._tmpBoundsOnModel.height):h=d/f,this.createMatrixForMask(t,l,u,h),n._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),n._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray());let p=r.getInvert();n._matrixForDraw.multiplyByMatrix(p)}}}calcClippedOffscreenTotalBounds(e,t){let r=Number.MAX_VALUE,i=Number.MAX_VALUE,s=-Number.MAX_VALUE,n=-Number.MAX_VALUE,a=t._clippedOffscreenIndexList.length,l=new Array;for(let u=0;u<a;u++){let h=t._clippedOffscreenIndexList[u];this.getOffscreenChildDrawableIndexList(e,h,l)}let o=l.length;for(let u=0;u<o;u++){let h=e.getDrawableVertexCount(l[u]),d=e.getDrawableVertices(l[u]),c=Number.MAX_VALUE,g=Number.MAX_VALUE,f=-Number.MAX_VALUE,p=-Number.MAX_VALUE,A=h*ee.vertexStep;for(let _=ee.vertexOffset;_<A;_+=ee.vertexStep){let y=d[_],C=d[_+1];y<c&&(c=y),y>f&&(f=y),C<g&&(g=C),C>p&&(p=C)}c!=Number.MAX_VALUE&&(c<r&&(r=c),g<i&&(i=g),f>s&&(s=f),p>n&&(n=p))}if(r==Number.MAX_VALUE)t._allClippedDrawRect.x=0,t._allClippedDrawRect.y=0,t._allClippedDrawRect.width=0,t._allClippedDrawRect.height=0,t._isUsing=!1;else{t._isUsing=!0;let u=s-r,h=n-i;t._allClippedDrawRect.x=r,t._allClippedDrawRect.y=i,t._allClippedDrawRect.width=u,t._allClippedDrawRect.height=h}}getOffscreenChildDrawableIndexList(e,t,r){let i=e.getOffscreenOwnerIndices()[t];this.getPartChildDrawableIndexList(e,i,r)}getPartChildDrawableIndexList(e,t,r){let i=e.getPartsHierarchy()[t].childDrawObjects;r.push(...i.drawableIndices);for(let s=0;s<i.offscreenIndices.length;++s)this.getOffscreenChildDrawableIndexList(e,i.offscreenIndices[s],r)}createMatrixForMask(e,t,r,i){this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(t.x,t.y),this._tmpMatrix.scaleRelative(r,i),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(t.x,t.y*(e?-1:1)),this._tmpMatrix.scaleRelative(r,i*(e?-1:1)),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray())}setupLayoutBounds(e){let t=this._renderTextureCount<=1?wo:xo*this._renderTextureCount;if(e<=0||e>t){e>t&&D(`not supported mask count : {0}
|
|
19
|
-
[Details] render texture count : {1}, mask count : {2}`,e-t,this._renderTextureCount,e);for(let o=0;o<this._clippingContextListForMask.length;o++){let u=this._clippingContextListForMask[o];u._layoutChannelIndex=0,u._layoutBounds.x=0,u._layoutBounds.y=0,u._layoutBounds.width=1,u._layoutBounds.height=1,u._bufferIndex=0}return}let r=this._renderTextureCount<=1?9:8,i=e/this._renderTextureCount,s=e%this._renderTextureCount;i=Math.ceil(i);let n=i/Gt,a=i%Gt;n=~~n;let l=0;for(let o=0;o<this._renderTextureCount;o++)for(let u=0;u<Gt;u++){let
|
|
20
|
-
[Details] render texture count : {1}, mask count : {2}`,e-t,this._renderTextureCount,e);for(let c=0;c<h;c++){let g=this._clippingContextListForMask[l++];g._layoutChannelIndex=0,g._layoutBounds.x=0,g._layoutBounds.y=0,g._layoutBounds.width=1,g._layoutBounds.height=1,g._bufferIndex=0}}}}calcClippedDrawableTotalBounds(e,t){let r=Number.MAX_VALUE,i=Number.MAX_VALUE,s=Number.MIN_VALUE,n=Number.MIN_VALUE,a=t._clippedDrawableIndexList.length;for(let l=0;l<a;l++){let o=t._clippedDrawableIndexList[l],u=e.getDrawableVertexCount(o),h=e.getDrawableVertices(o),d=Number.MAX_VALUE,c=Number.MAX_VALUE,g=-Number.MAX_VALUE,f=-Number.MAX_VALUE,p=u*ee.vertexStep;for(let A=ee.vertexOffset;A<p;A+=ee.vertexStep){let _=h[A],y=h[A+1];_<d&&(d=_),_>g&&(g=_),y<c&&(c=y),y>f&&(f=y)}if(d!=Number.MAX_VALUE)if(d<r&&(r=d),c<i&&(i=c),g>s&&(s=g),f>n&&(n=f),r==Number.MAX_VALUE)t._allClippedDrawRect.x=0,t._allClippedDrawRect.y=0,t._allClippedDrawRect.width=0,t._allClippedDrawRect.height=0,t._isUsing=!1;else{t._isUsing=!0;let A=s-r,_=n-i;t._allClippedDrawRect.x=r,t._allClippedDrawRect.y=i,t._allClippedDrawRect.width=A,t._allClippedDrawRect.height=_}}}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingContextListForOffscreen(){return this._clippingContextListForOffscreen}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}getChannelFlagAsColor(e){return this._channelColors[e]}setClippingMaskBufferSize(e){this._clippingMaskBufferSize=e}_clearedMaskBufferFlags;_channelColors;_clippingContextListForMask;_clippingContextListForDraw;_clippingContextListForOffscreen;_clippingMaskBufferSize;_renderTextureCount;_tmpMatrix;_tmpMatrixForMask;_tmpMatrixForDraw;_tmpBoundsOnModel;_clippingContexttConstructor},pe=class{static copyBuffer(e,t,r,i=null,s=!1){if(t==null||r==null)return;if(!(e instanceof WebGL2RenderingContext))throw new Error("WebGL2RenderingContext is required for buffer copy.");let n=s?i:e.getParameter(e.FRAMEBUFFER_BINDING);e.bindFramebuffer(e.READ_FRAMEBUFFER,t.getRenderTexture()),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,r.getRenderTexture()),e.blitFramebuffer(0,0,t.getBufferWidth(),t.getBufferHeight(),0,0,r.getBufferWidth(),r.getBufferHeight(),e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.FRAMEBUFFER,n)}beginDraw(e=null,t=!1){if(this._renderTexture==null){console.error("_renderTexture is null");return}e==null&&!t?this._oldFbo=this._gl.getParameter(this._gl.FRAMEBUFFER_BINDING):this._oldFbo=e,this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,this._renderTexture)}endDraw(){this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,this._oldFbo)}clear(e,t,r,i){this._gl.clearColor(e,t,r,i),this._gl.clear(this._gl.COLOR_BUFFER_BIT)}createRenderTarget(e,t,r,i){this.destroyRenderTarget(),this._colorBuffer=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this._colorBuffer),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,r,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.bindTexture(e.TEXTURE_2D,null);let s=e.createFramebuffer();return s==null?(D("Failed to create framebuffer"),!1):(e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this._colorBuffer,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE?(D("Framebuffer is not complete"),e.bindFramebuffer(e.FRAMEBUFFER,i),e.deleteFramebuffer(s),this.destroyRenderTarget(),!1):(this._renderTexture=s,this._bufferWidth=t,this._bufferHeight=r,this._gl=e,!0))}destroyRenderTarget(){this._colorBuffer&&(this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.deleteTexture(this._colorBuffer),this._colorBuffer=null),this._renderTexture&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null),this._gl.deleteFramebuffer(this._renderTexture),this._renderTexture=null)}getGL(){return this._gl}getRenderTexture(){return this._renderTexture}getColorBuffer(){return this._colorBuffer}getBufferWidth(){return this._bufferWidth}getBufferHeight(){return this._bufferHeight}isValid(){return this._renderTexture!=null}getOldFBO(){return this._oldFbo}constructor(){this._gl=null,this._colorBuffer=null,this._renderTexture=null,this._bufferWidth=0,this._bufferHeight=0,this._oldFbo=null}_gl;_colorBuffer;_renderTexture;_bufferWidth;_bufferHeight;_oldFbo};(function(e){e.CubismOffscreenSurface_WebGL=pe})(qi||(qi={}));vo=class{constructor(e=null,t=null,r=!1){this.colorBuffer=e,this.renderTexture=t,this.inUse=r}clear(){this.colorBuffer=null,this.renderTexture=null,this.inUse=!1}getColorBuffer(){return this.colorBuffer}getRenderTexture(){return this.renderTexture}colorBuffer;renderTexture;inUse},Po=class{constructor(e){this.gl=e,this.offscreenRenderTargetContainers=new Array,this.previousActiveRenderTextureMaxCount=0,this.currentActiveRenderTextureCount=0,this.hasResetThisFrame=!1,this.width=0,this.height=0}release(){if(this.offscreenRenderTargetContainers!=null){for(let e=0;e<this.offscreenRenderTargetContainers.length;++e){let t=this.offscreenRenderTargetContainers[e];this.gl.deleteTexture(t.colorBuffer),this.gl.deleteFramebuffer(t.renderTexture)}this.offscreenRenderTargetContainers.length=0,this.offscreenRenderTargetContainers=null}}gl;offscreenRenderTargetContainers;previousActiveRenderTextureMaxCount;currentActiveRenderTextureCount;hasResetThisFrame;width;height},cr=class er{constructor(){this._contextManagers=new Map}release(){if(this._contextManagers!=null){for(let t of this._contextManagers.values())t.release();this._contextManagers.clear(),this._contextManagers=null}er._instance=null}static getInstance(){return this._instance==null&&(this._instance=new er),this._instance}getContextManager(t){return this._contextManagers.has(t)||this._contextManagers.set(t,new Po(t)),this._contextManagers.get(t)}removeContext(t){this._contextManagers.has(t)&&(this._contextManagers.get(t).release(),this._contextManagers.delete(t))}initialize(t,r,i){let s=this.getContextManager(t);if(s.offscreenRenderTargetContainers!=null){for(let n=0;n<s.offscreenRenderTargetContainers.length;++n){let a=s.offscreenRenderTargetContainers[n];s.gl.deleteTexture(a.colorBuffer),s.gl.deleteFramebuffer(a.renderTexture),a.clear()}s.offscreenRenderTargetContainers.length=0}else s.offscreenRenderTargetContainers=new Array;s.width=r,s.height=i,s.previousActiveRenderTextureMaxCount=0,s.currentActiveRenderTextureCount=0,s.hasResetThisFrame=!1}beginFrameProcess(t){let r=this.getContextManager(t);r.hasResetThisFrame||(r.previousActiveRenderTextureMaxCount=0,r.hasResetThisFrame=!0)}endFrameProcess(t){let r=this.getContextManager(t);r.hasResetThisFrame=!1}getContainerSize(t){let r=this.getContextManager(t);return r.offscreenRenderTargetContainers==null?0:r.offscreenRenderTargetContainers.length}getOffscreenRenderTargetContainers(t,r,i,s){let n=this.getContextManager(t);(n.width!=r||n.height!=i||n.offscreenRenderTargetContainers==null)&&this.initialize(t,r,i),this.updateRenderTargetContainerCount(t);let a=this.getUnusedOffscreenRenderTargetContainer(t);return a??this.createOffscreenRenderTargetContainer(t,r,i,s)}getUsingRenderTextureState(t,r){let i=this.getContextManager(t);for(let s=0;s<i.offscreenRenderTargetContainers.length;++s)if(i.offscreenRenderTargetContainers[s].renderTexture==r)return i.offscreenRenderTargetContainers[s].inUse;return!0}startUsingRenderTexture(t,r){let i=this.getContextManager(t);for(let s=0;s<i.offscreenRenderTargetContainers.length;++s)if(i.offscreenRenderTargetContainers[s].renderTexture==r){i.offscreenRenderTargetContainers[s].inUse=!0,this.updateRenderTargetContainerCount(t);break}}stopUsingRenderTexture(t,r){let i=this.getContextManager(t);for(let s=0;s<i.offscreenRenderTargetContainers.length;++s)if(i.offscreenRenderTargetContainers[s].renderTexture==r){i.offscreenRenderTargetContainers[s].inUse=!1,i.currentActiveRenderTextureCount--,i.currentActiveRenderTextureCount<0&&(i.currentActiveRenderTextureCount=0);break}}stopUsingAllRenderTextures(t){let r=this.getContextManager(t);for(let i=0;i<r.offscreenRenderTargetContainers.length;++i)r.offscreenRenderTargetContainers[i].inUse=!1;r.currentActiveRenderTextureCount=0}releaseStaleRenderTextures(t){let r=this.getContextManager(t),i=r.offscreenRenderTargetContainers.length;if(r.hasResetThisFrame||i===0)return;let s=0,n=r.previousActiveRenderTextureMaxCount;for(let a=i;r.previousActiveRenderTextureMaxCount<a;--a){let l=a-1;if(r.offscreenRenderTargetContainers[l].inUse){let u=!1;for(;s<r.previousActiveRenderTextureMaxCount;++s)if(!r.offscreenRenderTargetContainers[s].inUse){let h=r.offscreenRenderTargetContainers[s];r.offscreenRenderTargetContainers[s]=r.offscreenRenderTargetContainers[l],r.offscreenRenderTargetContainers[s].inUse=!0,r.offscreenRenderTargetContainers[l]=h,r.offscreenRenderTargetContainers[l].inUse=!1,u=!0;break}if(!u){n=a;break}}let o=r.offscreenRenderTargetContainers[l];r.gl.bindTexture(r.gl.TEXTURE_2D,null),r.gl.deleteTexture(o.colorBuffer),r.gl.bindFramebuffer(r.gl.FRAMEBUFFER,null),r.gl.deleteFramebuffer(o.renderTexture),o.clear()}U(r.offscreenRenderTargetContainers,n)}getPreviousActiveRenderTextureCount(t){return this.getContextManager(t).previousActiveRenderTextureMaxCount}getCurrentActiveRenderTextureCount(t){return this.getContextManager(t).currentActiveRenderTextureCount}updateRenderTargetContainerCount(t){let r=this.getContextManager(t);++r.currentActiveRenderTextureCount,r.previousActiveRenderTextureMaxCount=r.currentActiveRenderTextureCount>r.previousActiveRenderTextureMaxCount?r.currentActiveRenderTextureCount:r.previousActiveRenderTextureMaxCount}getUnusedOffscreenRenderTargetContainer(t){let r=this.getContextManager(t);for(let i=0;i<r.offscreenRenderTargetContainers.length;++i){let s=r.offscreenRenderTargetContainers[i];if(s.inUse==!1)return s.inUse=!0,s}return null}createOffscreenRenderTargetContainer(t,r,i,s){let n=new pe;if(!n.createRenderTarget(t,r,i,s))return D("Failed to create offscreen render texture."),null;let a=new vo(n.getColorBuffer(),n.getRenderTexture(),!0);return this.getContextManager(t).offscreenRenderTargetContainers.push(a),a}static _instance;_contextManagers},Zi=class extends pe{initializeOffscreenManager(e,t,r){this._gl=e,this._webGLOffscreenManager=cr.getInstance(),this._webGLOffscreenManager.getContainerSize(e)===0&&this._webGLOffscreenManager.initialize(e,t,r)}setOffscreenRenderTarget(e,t,r,i){this._webGLOffscreenManager==null&&this.initializeOffscreenManager(e,t,r);let s=this._webGLOffscreenManager.getOffscreenRenderTargetContainers(e,t,r,i);if(s==null){D("Failed to acquire offscreen render texture container.");return}this._colorBuffer=s.getColorBuffer(),this._renderTexture=s.getRenderTexture(),this._bufferWidth=t,this._bufferHeight=r,this._gl=e,this._renderTexture==null&&(this._renderTexture=i,D("Failed to create offscreen render texture."))}getUsingRenderTextureState(){return this._webGLOffscreenManager==null||this._gl==null?!0:this._webGLOffscreenManager.getUsingRenderTextureState(this._gl,this._renderTexture)}startUsingRenderTexture(){this._webGLOffscreenManager==null||this._gl==null||this._webGLOffscreenManager.startUsingRenderTexture(this._gl,this._renderTexture)}stopUsingRenderTexture(){this._webGLOffscreenManager==null||this._gl==null||this._webGLOffscreenManager.stopUsingRenderTexture(this._gl,this._renderTexture)}setOffscreenIndex(e){this._offscreenIndex=e}getOffscreenIndex(){return this._offscreenIndex}setOldOffscreen(e){this._oldOffscreen=e}getOldOffscreen(){return this._oldOffscreen}setParentPartOffscreen(e){this._parentOffscreenRenderTarget=e}getParentPartOffscreen(){return this._parentOffscreenRenderTarget}constructor(){super(),this._offscreenIndex=-1,this._parentOffscreenRenderTarget=null,this._oldOffscreen=null,this._webGLOffscreenManager=null}release(){this._webGLOffscreenManager!=null&&this._gl!=null&&this._renderTexture!=null&&this._webGLOffscreenManager.stopUsingRenderTexture(this._gl,this._renderTexture),this._colorBuffer&&this._gl&&(this._gl.deleteTexture(this._colorBuffer),this._colorBuffer=null),this._renderTexture&&this._gl&&(this._gl.deleteFramebuffer(this._renderTexture),this._renderTexture=null),this._webGLOffscreenManager!=null&&(this._webGLOffscreenManager=null),this._oldOffscreen=null,this._parentOffscreenRenderTarget=null}_offscreenIndex;_parentOffscreenRenderTarget;_oldOffscreen;_webGLOffscreenManager},Ro="vertshadersrc.vert",Do="vertshadersrcmasked.vert",Lo="vertshadersrcsetupmask.vert",To="fragshadersrcsetupmask.frag",Fo="fragshadersrcpremultipliedalpha.frag",Oo="fragshadersrcmaskpremultipliedalpha.frag",Vo="fragshadersrcmaskinvertedpremultipliedalpha.frag",ko="vertshadersrccopy.vert",Qo="fragshadersrccopy.frag",Uo="fragshadersrccolorblend.frag",No="fragshadersrcalphablend.frag",Go="vertshadersrcblend.vert",Xo="fragshadersrcpremultipliedalphablend.frag",Ho="ColorBlend_",Wo="AlphaBlend_",Ki=new Float32Array([-1,-1,1,-1,-1,1,1,1]),Yo=new Float32Array([0,0,1,0,0,1,1,1]),zo=new Float32Array([0,1,1,1,0,0,1,0]),qs=class{async loadShader(e,t){let r=e.slice(e.lastIndexOf("/")+1),i=this._shaderSources?.[r];if(i!==void 0){if(i.trim().length==0)throw new Error(`Failed to load shader ${e}: empty source`);return i}let s=await fetch(e,{signal:t});if(!s.ok)throw new Error(`Failed to load shader ${e}: HTTP ${s.status}`);let n=await s.text();if(n.trim().length==0)throw new Error(`Failed to load shader ${e}: empty source`);return n}async loadShaders(e){let t=this._shaderPath??this._defaultShaderPath,r=[{path:t+Ro,prop:"_vertShaderSrc"},{path:t+Do,prop:"_vertShaderSrcMasked"},{path:t+Lo,prop:"_vertShaderSrcSetupMask"},{path:t+To,prop:"_fragShaderSrcSetupMask"},{path:t+Fo,prop:"_fragShaderSrcPremultipliedAlpha"},{path:t+Oo,prop:"_fragShaderSrcMaskPremultipliedAlpha"},{path:t+Vo,prop:"_fragShaderSrcMaskInvertedPremultipliedAlpha"},{path:t+ko,prop:"_vertShaderSrcCopy"},{path:t+Qo,prop:"_fragShaderSrcCopy"},{path:t+Uo,prop:"_fragShaderSrcColorBlend"},{path:t+No,prop:"_fragShaderSrcAlphaBlend"},{path:t+Go,prop:"_vertShaderSrcBlend"},{path:t+Xo,prop:"_fragShaderSrcBlend"}];(await Promise.all(r.map(async i=>({prop:i.prop,data:await this.loadShader(i.path,e)})))).forEach(i=>{this[i.prop]=i.data})}constructor(){this._shaderSets=new Array,this._isShaderLoading=!1,this._isShaderLoaded=!1,this._blendShadersRegistered=!1,this._currentProgram=null,this._shaderLoadPromise=null,this._colorBlendMap=new Map,this._colorBlendValues=new Array;let e=Object.keys(V),t=Object.keys(V).map(s=>V[s]);for(let s=0;s<e.length;s++){let n=e[s];if(n.includes(Ho)){let a=n.slice(11),l=parseInt(t[s].toString());this._colorBlendMap.set(l,a),this._colorBlendValues.push(l)}}this._alphaBlendMap=new Map,this._alphaBlendValues=new Array;let r=Object.keys(Tt),i=Object.keys(Tt).map(s=>Tt[s]);for(let s=0;s<r.length;s++){let n=r[s];if(n.includes(Wo)){let a=n.slice(11),l=parseInt(i[s].toString());this._alphaBlendMap.set(l,a),this._alphaBlendValues.push(l)}}this._blendShaderSetMap=new Map,this._shaderCount=11+(this._colorBlendValues.length-3)*(this._alphaBlendValues.length-1)*3,this._defaultShaderPath="../../Framework/Shaders/WebGL/",this._shaderPath=this._defaultShaderPath}release(){this.releaseShaderProgram()}setProgram(e){this._currentProgram!==e&&(this._currentProgram=e,this.gl.useProgram(e))}setupShaderProgramForDrawable(e,t,r){if(e.isPremultipliedAlpha()||D("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders(void 0,t.isBlendModeEnabled()),this._isShaderLoaded==!1){O("Shader program is not initialized.");return}let i,s,n,a,l=e.getClippingContextBufferForDrawable()!=null,o=t.getDrawableInvertedMaskBit(r),u=l?o?2:1:0,h,d=!0;if(t.isBlendModeEnabled()){let B=t.getDrawableColorBlend(r),x=t.getDrawableAlphaBlend(r);if(B==-1||x==-1||B==V.ColorBlend_Normal&&x==0)h=this._shaderSets[1+u],i=this.gl.ONE,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ONE,a=this.gl.ONE_MINUS_SRC_ALPHA;else switch(B){case V.ColorBlend_AddCompatible:h=this._shaderSets[4+u],i=this.gl.ONE,s=this.gl.ONE,n=this.gl.ZERO,a=this.gl.ONE;break;case V.ColorBlend_MultiplyCompatible:h=this._shaderSets[7+u],i=this.gl.DST_COLOR,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ZERO,a=this.gl.ONE;break;default:{let b=e._currentOffscreen!=null?e._currentOffscreen:e.getModelRenderTarget(0);pe.copyBuffer(this.gl,b,e.getModelRenderTarget(1));let M=this._blendShaderSetMap.get(this._colorBlendMap.get(B)+this._alphaBlendMap.get(x));if(M===void 0)throw new Error("Blend shader programs are not registered for this context.");h=this._shaderSets[M+u],i=this.gl.ONE,s=this.gl.ZERO,n=this.gl.ONE,a=this.gl.ZERO,d=!1}break}}else switch(t.getDrawableBlendMode(r)){case 0:default:h=this._shaderSets[1+u],i=this.gl.ONE,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ONE,a=this.gl.ONE_MINUS_SRC_ALPHA;break;case 1:h=this._shaderSets[4+u],i=this.gl.ONE,s=this.gl.ONE,n=this.gl.ZERO,a=this.gl.ONE;break;case 2:h=this._shaderSets[7+u],i=this.gl.DST_COLOR,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ZERO,a=this.gl.ONE;break}this.setProgram(h.shaderProgram),e._bufferData.vertex==null&&(e._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.vertex);let c=t.getDrawableVertices(r);if(this.gl.bufferData(this.gl.ARRAY_BUFFER,c,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(h.attributePositionLocation),this.gl.vertexAttribPointer(h.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),e.bindDrawableUvBuffer(r),this.gl.enableVertexAttribArray(h.attributeTexCoordLocation),this.gl.vertexAttribPointer(h.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),l){this.gl.activeTexture(this.gl.TEXTURE1);let B=e.getDrawableMaskBuffer(e.getClippingContextBufferForDrawable()._bufferIndex).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,B),this.gl.uniform1i(h.samplerTexture1Location,1),this.gl.uniformMatrix4fv(h.uniformClipMatrixLocation,!1,e.getClippingContextBufferForDrawable()._matrixForDraw.getArray());let x=e.getClippingContextBufferForDrawable()._layoutChannelIndex,b=e.getClippingContextBufferForDrawable().getClippingManager().getChannelFlagAsColor(x);this.gl.uniform4f(h.uniformChannelFlagLocation,b.r,b.g,b.b,b.a),t.isBlendModeEnabled()&&this.gl.uniform1f(h.uniformInvertMaskFlagLocation,o?1:0)}let g=t.getDrawableTextureIndex(r),f=e.getBindedTextures().get(g);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,f),this.gl.uniform1i(h.samplerTexture0Location,0);let p=e.getMvpMatrix();this.gl.uniformMatrix4fv(h.uniformMatrixLocation,!1,p.getArray());let A=null;if(t.isBlendModeEnabled()){let B=t.getDrawableOpacity(r);A=new R(B,B,B,B)}else A=e.getModelColorWithOpacity(t.getDrawableOpacity(r));let _=t.getOverrideMultiplyAndScreenColor(),y=_.getDrawableMultiplyColor(r),C=_.getDrawableScreenColor(r);if(this.gl.uniform4f(h.uniformBaseColorLocation,A.r,A.g,A.b,A.a),this.gl.uniform4f(h.uniformMultiplyColorLocation,y.r,y.g,y.b,y.a),this.gl.uniform4f(h.uniformScreenColorLocation,C.r,C.g,C.b,C.a),t.isBlendModeEnabled()&&(this.gl.activeTexture(this.gl.TEXTURE2),!d)){let B=e.getModelRenderTarget(1).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,B),this.gl.uniform1i(h.samplerFrameBufferTextureLocation,2)}e.bindDrawableIndexBuffer(r),this.gl.blendFuncSeparate(i,s,n,a)}setupShaderProgramForOffscreen(e,t,r){if(e.isPremultipliedAlpha()||D("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders(void 0,t.isBlendModeEnabled()),this._isShaderLoaded==!1){O("Shader program is not initialized.");return}let i,s,n,a,l=r.getOffscreenIndex(),o=e.getClippingContextBufferForOffscreen()!=null,u=t.getOffscreenInvertedMask(l),h=o?u?2:1:0,d,c=!0,g=t.getOffscreenColorBlend(l),f=t.getOffscreenAlphaBlend(l);if(g==-1||f==-1||g==V.ColorBlend_Normal&&f==0)d=this._shaderSets[1+h],i=this.gl.ONE,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ONE,a=this.gl.ONE_MINUS_SRC_ALPHA;else switch(g){case V.ColorBlend_AddCompatible:d=this._shaderSets[4+h],i=this.gl.ONE,s=this.gl.ONE,n=this.gl.ZERO,a=this.gl.ONE;break;case V.ColorBlend_MultiplyCompatible:d=this._shaderSets[7+h],i=this.gl.DST_COLOR,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ZERO,a=this.gl.ONE;break;default:{let b=r.getOldOffscreen()!=null?r.getOldOffscreen():e.getModelRenderTarget(0);pe.copyBuffer(this.gl,b,e.getModelRenderTarget(1));let M=this._blendShaderSetMap.get(this._colorBlendMap.get(g)+this._alphaBlendMap.get(f));if(M===void 0)throw new Error("Blend shader programs are not registered for this context.");d=this._shaderSets[M+h],i=this.gl.ONE,s=this.gl.ZERO,n=this.gl.ONE,a=this.gl.ZERO,c=!1}break}this.setProgram(d.shaderProgram),pe.copyBuffer(this.gl,r,e.getModelRenderTarget(2)),this.gl.activeTexture(this.gl.TEXTURE0);let p=e.getModelRenderTarget(2).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,p),this.gl.uniform1i(d.samplerTexture0Location,0);let A=new ne;A.loadIdentity(),this.gl.uniformMatrix4fv(d.uniformMatrixLocation,!1,A.getArray());let _=t.getOffscreenOpacity(l),y=new R(_,_,_,_),C=t.getOverrideMultiplyAndScreenColor(),B=C.getOffscreenMultiplyColor(l),x=C.getOffscreenScreenColor(l);if(this.gl.uniform4f(d.uniformBaseColorLocation,y.r,y.g,y.b,y.a),this.gl.uniform4f(d.uniformMultiplyColorLocation,B.r,B.g,B.b,B.a),this.gl.uniform4f(d.uniformScreenColorLocation,x.r,x.g,x.b,x.a),this.gl.activeTexture(this.gl.TEXTURE2),!c){let b=e.getModelRenderTarget(1).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,b),this.gl.uniform1i(d.samplerFrameBufferTextureLocation,2)}if(o){this.gl.activeTexture(this.gl.TEXTURE1);let b=e.getOffscreenMaskBuffer(e.getClippingContextBufferForOffscreen()._bufferIndex).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,b),this.gl.uniform1i(d.samplerTexture1Location,1),this.gl.uniformMatrix4fv(d.uniformClipMatrixLocation,!1,e.getClippingContextBufferForOffscreen()._matrixForDraw.getArray());let M=e.getClippingContextBufferForOffscreen()._layoutChannelIndex,L=e.getClippingContextBufferForOffscreen().getClippingManager().getChannelFlagAsColor(M);this.gl.uniform4f(d.uniformChannelFlagLocation,L.r,L.g,L.b,L.a),t.isBlendModeEnabled()&&this.gl.uniform1f(d.uniformInvertMaskFlagLocation,u?1:0)}e._bufferData.vertex||(e._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,Ki,this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(d.attributePositionLocation),this.gl.vertexAttribPointer(d.attributePositionLocation,2,this.gl.FLOAT,!1,Float32Array.BYTES_PER_ELEMENT*2,0),e._bufferData.uv||(e._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,zo,this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(d.attributeTexCoordLocation),this.gl.vertexAttribPointer(d.attributeTexCoordLocation,2,this.gl.FLOAT,!1,Float32Array.BYTES_PER_ELEMENT*2,0),this.gl.blendFuncSeparate(i,s,n,a)}setupShaderProgramForMask(e,t,r){if(e.isPremultipliedAlpha()||D("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders(void 0,t.isBlendModeEnabled()),this._isShaderLoaded==!1){O("Shader program is not initialized.");return}let i=this._shaderSets[0];this.setProgram(i.shaderProgram),e._bufferData.vertex==null&&(e._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.vertex);let s=t.getDrawableVertices(r);this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(i.attributePositionLocation),this.gl.vertexAttribPointer(i.attributePositionLocation,2,this.gl.FLOAT,!1,0,0);let n=t.getDrawableTextureIndex(r),a=e.getBindedTextures().get(n);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,a),this.gl.uniform1i(i.samplerTexture0Location,0),e.bindDrawableUvBuffer(r),this.gl.enableVertexAttribArray(i.attributeTexCoordLocation),this.gl.vertexAttribPointer(i.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0);let l=e.getClippingContextBufferForMask()._layoutChannelIndex,o=e.getClippingContextBufferForMask().getClippingManager().getChannelFlagAsColor(l);this.gl.uniform4f(i.uniformChannelFlagLocation,o.r,o.g,o.b,o.a),this.gl.uniformMatrix4fv(i.uniformClipMatrixLocation,!1,e.getClippingContextBufferForMask()._matrixForMask.getArray());let u=e.getClippingContextBufferForMask()._layoutBounds;this.gl.uniform4f(i.uniformBaseColorLocation,u.x*2-1,u.y*2-1,u.getRight()*2-1,u.getBottom()*2-1);let h=this.gl.ZERO,d=this.gl.ONE_MINUS_SRC_COLOR,c=this.gl.ZERO,g=this.gl.ONE_MINUS_SRC_ALPHA;e.bindDrawableIndexBuffer(r),this.gl.blendFuncSeparate(h,d,c,g)}setupShaderProgramForOffscreenRenderTarget(e){if(this._shaderSets.length==0&&this.generateShaders(void 0,e.getModel().isBlendModeEnabled()),this._isShaderLoaded==!1){O("Shader program is not initialized.");return}let t=e.getModelColor();t.r*=t.a,t.g*=t.a,t.b*=t.a,this.copyTexture(e,t)}copyTexture(e,t){let r=this.gl.ONE,i=this.gl.ONE_MINUS_SRC_ALPHA,s=this.gl.ONE,n=this.gl.ONE_MINUS_SRC_ALPHA,a=this._shaderSets[10];this.setProgram(a.shaderProgram),this.gl.uniform4f(a.uniformBaseColorLocation,t.r,t.g,t.b,t.a),this.gl.activeTexture(this.gl.TEXTURE0);let l=e.getModelRenderTarget(0).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,l),this.gl.uniform1i(a.samplerTexture0Location,0),e._bufferData.vertex||(e._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,Ki,this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(a.attributePositionLocation),this.gl.vertexAttribPointer(a.attributePositionLocation,2,this.gl.FLOAT,!1,Float32Array.BYTES_PER_ELEMENT*2,0),e._bufferData.uv||(e._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,Yo,this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(a.attributeTexCoordLocation),this.gl.vertexAttribPointer(a.attributeTexCoordLocation,2,this.gl.FLOAT,!1,Float32Array.BYTES_PER_ELEMENT*2,0),this.gl.blendFuncSeparate(r,i,s,n)}releaseShaderProgram(){let e=new Set;for(let t=0;t<this._shaderSets.length;t++){let r=this._shaderSets[t];r&&(r.shaderProgram&&e.add(r.shaderProgram),r.shaderProgram=null,this._shaderSets[t]=void 0,this._shaderSets[t]=null)}for(let t of e)this.gl.deleteProgram(t);this._shaderSets.length=0,this._blendShaderSetMap.clear(),this._blendShadersRegistered=!1,this._currentProgram=null}generateShaders(e,t=!0){if(this._isShaderLoaded)return t&&!this._blendShadersRegistered&&(this.registerBlendShader(),this._blendShadersRegistered=!0),Promise.resolve();if(this._isShaderLoading)return this._shaderLoadPromise.then(()=>this.generateShaders(e,t));this._isShaderLoading=!0,this._isShaderLoaded=!1,this._shaderSets.length=this._shaderCount;for(let r=0;r<this._shaderCount;r++)this._shaderSets[r]=new Ks;return this._shaderLoadPromise=this.loadShaders(e).then(()=>{this.registerShader(),t&&this.registerBlendShader(),this._blendShadersRegistered=t,this._isShaderLoading=!1,this._isShaderLoaded=!0}).catch(r=>{throw this._isShaderLoading=!1,this._isShaderLoaded=!1,this.releaseShaderProgram(),r}),this._shaderLoadPromise}registerShader(){let e=this._vertShaderSrc,t=this._vertShaderSrcMasked,r=this._vertShaderSrcSetupMask,i=this._fragShaderSrcSetupMask,s=this._fragShaderSrcPremultipliedAlpha,n=this._fragShaderSrcMaskPremultipliedAlpha,a=this._fragShaderSrcMaskInvertedPremultipliedAlpha;this._shaderSets[0].shaderProgram=this.loadShaderProgram(r,i),this._shaderSets[1].shaderProgram=this.loadShaderProgram(e,s),this._shaderSets[2].shaderProgram=this.loadShaderProgram(t,n),this._shaderSets[3].shaderProgram=this.loadShaderProgram(t,a),this._shaderSets[4].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[5].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[6].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[7].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[8].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[9].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[0].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_position"),this._shaderSets[0].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_texCoord"),this._shaderSets[0].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"s_texture0"),this._shaderSets[0].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_clipMatrix"),this._shaderSets[0].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_channelFlag"),this._shaderSets[0].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_baseColor"),this._shaderSets[1].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_position"),this._shaderSets[1].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_texCoord"),this._shaderSets[1].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"s_texture0"),this._shaderSets[1].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_matrix"),this._shaderSets[1].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_baseColor"),this._shaderSets[1].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_multiplyColor"),this._shaderSets[1].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_screenColor"),this._shaderSets[2].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_position"),this._shaderSets[2].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_texCoord"),this._shaderSets[2].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture0"),this._shaderSets[2].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture1"),this._shaderSets[2].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_matrix"),this._shaderSets[2].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_clipMatrix"),this._shaderSets[2].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_channelFlag"),this._shaderSets[2].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_baseColor"),this._shaderSets[2].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_multiplyColor"),this._shaderSets[2].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_screenColor"),this._shaderSets[3].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_position"),this._shaderSets[3].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_texCoord"),this._shaderSets[3].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture0"),this._shaderSets[3].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture1"),this._shaderSets[3].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_matrix"),this._shaderSets[3].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_clipMatrix"),this._shaderSets[3].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_channelFlag"),this._shaderSets[3].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_baseColor"),this._shaderSets[3].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_multiplyColor"),this._shaderSets[3].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_screenColor"),this._shaderSets[4].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_position"),this._shaderSets[4].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_texCoord"),this._shaderSets[4].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"s_texture0"),this._shaderSets[4].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_matrix"),this._shaderSets[4].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_baseColor"),this._shaderSets[4].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_multiplyColor"),this._shaderSets[4].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_screenColor"),this._shaderSets[5].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_position"),this._shaderSets[5].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_texCoord"),this._shaderSets[5].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture0"),this._shaderSets[5].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture1"),this._shaderSets[5].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_matrix"),this._shaderSets[5].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_clipMatrix"),this._shaderSets[5].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_channelFlag"),this._shaderSets[5].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_baseColor"),this._shaderSets[5].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_multiplyColor"),this._shaderSets[5].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_screenColor"),this._shaderSets[6].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_position"),this._shaderSets[6].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_texCoord"),this._shaderSets[6].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture0"),this._shaderSets[6].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture1"),this._shaderSets[6].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_matrix"),this._shaderSets[6].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_clipMatrix"),this._shaderSets[6].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_channelFlag"),this._shaderSets[6].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_baseColor"),this._shaderSets[6].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_multiplyColor"),this._shaderSets[6].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_screenColor"),this._shaderSets[7].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_position"),this._shaderSets[7].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_texCoord"),this._shaderSets[7].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"s_texture0"),this._shaderSets[7].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_matrix"),this._shaderSets[7].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_baseColor"),this._shaderSets[7].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_multiplyColor"),this._shaderSets[7].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_screenColor"),this._shaderSets[8].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_position"),this._shaderSets[8].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_texCoord"),this._shaderSets[8].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture0"),this._shaderSets[8].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture1"),this._shaderSets[8].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_matrix"),this._shaderSets[8].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_clipMatrix"),this._shaderSets[8].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_channelFlag"),this._shaderSets[8].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_baseColor"),this._shaderSets[8].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_multiplyColor"),this._shaderSets[8].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_screenColor"),this._shaderSets[9].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_position"),this._shaderSets[9].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_texCoord"),this._shaderSets[9].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture0"),this._shaderSets[9].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture1"),this._shaderSets[9].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_matrix"),this._shaderSets[9].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_clipMatrix"),this._shaderSets[9].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_channelFlag"),this._shaderSets[9].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_baseColor"),this._shaderSets[9].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_multiplyColor"),this._shaderSets[9].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_screenColor")}registerBlendShader(){let e=this._vertShaderSrcCopy,t=this._fragShaderSrcCopy,r=this._shaderSets[10];r.shaderProgram=this.loadShaderProgram(e,t),r.attributeTexCoordLocation=this.gl.getAttribLocation(r.shaderProgram,"a_texCoord"),r.attributePositionLocation=this.gl.getAttribLocation(r.shaderProgram,"a_position"),r.uniformBaseColorLocation=this.gl.getUniformLocation(r.shaderProgram,"u_baseColor");let i=11;for(let s=0;s<this._colorBlendValues.length;s++){if(this._colorBlendValues[s]==-1||this._colorBlendValues[s]==V.ColorBlend_AddCompatible||this._colorBlendValues[s]==V.ColorBlend_MultiplyCompatible)continue;let n=this._colorBlendValues[s],a=`#define COLOR_BLEND_${this._colorBlendMap.get(n).toUpperCase()}
|
|
21
|
-
`;for(let l=0;l<this._alphaBlendValues.length;l++){if(this._alphaBlendValues[l]==-1||this._colorBlendValues[s]==
|
|
18
|
+
`,this._stringBuffer}getMap(e){return this._map}put(e,t){this._map.set(e,t)}getKeys(){return this._keys||(this._keys=[...this._map.keys()]),this._keys}getSize(){return this._keys.length}_map;_keys};(function(e){e.CubismJson=H,e.JsonArray=sr,e.JsonBoolean=ee,e.JsonError=Ye,e.JsonFloat=At,e.JsonMap=Oe,e.JsonNullvalue=Fe,e.JsonString=Ve,e.Value=G})(li||(li={}));K=!1,xe=!1,Ee=null,Ge=null,te=Object.freeze({vertexOffset:0,vertexStep:2});P=class{static startUp(e=null){if(K)return ge("CubismFramework.startUp() is already done."),K;if(Ee=e,Ee!=null&&Live2DCubismCore.Logging.csmSetLogFunction(Ee.logFunction),K=!0,K){let t=Live2DCubismCore.Version.csmGetVersion(),r=(t&4278190080)>>24,i=(t&16711680)>>16,s=t&65535,n=t;ge("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+r).slice(-2),("00"+i).slice(-2),("0000"+s).slice(-4),n)}return ge("CubismFramework.startUp() is complete."),K}static cleanUp(){K=!1,xe=!1,Ee=null,Ge=null}static initialize(e=0){if(U(K),!K){k("CubismFramework is not started.");return}if(xe){k("CubismFramework.initialize() skipped, already initialized.");return}G.staticInitializeNotForClientCall(),Ge=new ys,Live2DCubismCore.Memory.initializeAmountOfMemory(e),xe=!0,ge("CubismFramework.initialize() is complete.")}static dispose(){if(U(K),!K){k("CubismFramework is not started.");return}if(!xe){k("CubismFramework.dispose() skipped, not initialized.");return}G.staticReleaseNotForClientCall(),Ge.release(),Ge=null,mt.staticRelease(),xe=!1,ge("CubismFramework.dispose() is complete.")}static isStarted(){return K}static isInitialized(){return xe}static coreLogFunction(e){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(e)}static getLoggingLevel(){return Ee!=null?Ee.loggingLevel:5}static getIdManager(){return Ge}constructor(){}};(function(e){e.Constant=te,e.csmDelete=Le,e.CubismFramework=P})(ui||(ui={}));ua=(function(e){return e[e.FrequestNode_Groups=0]="FrequestNode_Groups",e[e.FrequestNode_Moc=1]="FrequestNode_Moc",e[e.FrequestNode_Motions=2]="FrequestNode_Motions",e[e.FrequestNode_Expressions=3]="FrequestNode_Expressions",e[e.FrequestNode_Textures=4]="FrequestNode_Textures",e[e.FrequestNode_Physics=5]="FrequestNode_Physics",e[e.FrequestNode_Pose=6]="FrequestNode_Pose",e[e.FrequestNode_HitAreas=7]="FrequestNode_HitAreas",e})({}),Bs=class extends _s{constructor(e,t){super(),this._json=H.create(e,t),this.getJson()&&(this._jsonValue=[this.getJson().getRoot().getValueByString(this.groups),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.moc),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.motions),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.expressions),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.textures),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.physics),this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.pose),this.getJson().getRoot().getValueByString(this.hitAreas)])}release(){H.delete(this._json),this._jsonValue=null}getJson(){return this._json}getModelFileName(){return this.isExistModelFile()?this._jsonValue[1].getRawString():""}getTextureCount(){return this.isExistTextureFiles()?this._jsonValue[4].getSize():0}getTextureDirectory(){let e=this._jsonValue[4].getValueByIndex(0).getRawString().split("/"),t=e.length-1,r="";for(let i=0;i<t;i++)r+=e[i],i<t-1&&(r+="/");return r}getTextureFileName(e){return this._jsonValue[4].getValueByIndex(e).getRawString()}getHitAreasCount(){return this.isExistHitAreas()?this._jsonValue[7].getSize():0}getHitAreaId(e){return P.getIdManager().getId(this._jsonValue[7].getValueByIndex(e).getValueByString(this.id).getRawString())}getHitAreaName(e){return this._jsonValue[7].getValueByIndex(e).getValueByString(this.name).getRawString()}getPhysicsFileName(){return this.isExistPhysicsFile()?this._jsonValue[5].getRawString():""}getPoseFileName(){return this.isExistPoseFile()?this._jsonValue[6].getRawString():""}getExpressionCount(){return this.isExistExpressionFile()?this._jsonValue[3].getSize():0}getExpressionName(e){return this._jsonValue[3].getValueByIndex(e).getValueByString(this.name).getRawString()}getExpressionFileName(e){return this._jsonValue[3].getValueByIndex(e).getValueByString(this.filePath).getRawString()}getMotionGroupCount(){return this.isExistMotionGroups()?this._jsonValue[2].getKeys().length:0}getMotionGroupName(e){return this.isExistMotionGroups()?this._jsonValue[2].getKeys()[e]:null}getMotionCount(e){return this.isExistMotionGroupName(e)?this._jsonValue[2].getValueByString(e).getSize():0}getMotionFileName(e,t){return this.isExistMotionGroupName(e)?this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.filePath).getRawString():""}getMotionSoundFileName(e,t){return this.isExistMotionSoundFile(e,t)?this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.soundPath).getRawString():""}getMotionFadeInTimeValue(e,t){return this.isExistMotionFadeIn(e,t)?this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.fadeInTime).toFloat():-1}getMotionFadeOutTimeValue(e,t){return this.isExistMotionFadeOut(e,t)?this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.fadeOutTime).toFloat():-1}getUserDataFile(){return this.isExistUserDataFile()?this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData).getRawString():""}getLayoutMap(e){let t=this.getJson().getRoot().getValueByString(this.layout).getMap();if(t==null)return!1;let r=!1;for(let i of t)e.set(i[0],i[1].toFloat()),r=!0;return r}getEyeBlinkParameterCount(){if(!this.isExistEyeBlinkParameters())return 0;let e=0;for(let t=0;t<this._jsonValue[0].getSize();t++){let r=this._jsonValue[0].getValueByIndex(t);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.eyeBlink){e=r.getValueByString(this.ids).getVector().length;break}}return e}getEyeBlinkParameterId(e){if(!this.isExistEyeBlinkParameters())return null;for(let t=0;t<this._jsonValue[0].getSize();t++){let r=this._jsonValue[0].getValueByIndex(t);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.eyeBlink)return P.getIdManager().getId(r.getValueByString(this.ids).getValueByIndex(e).getRawString())}return null}getLipSyncParameterCount(){if(!this.isExistLipSyncParameters())return 0;let e=0;for(let t=0;t<this._jsonValue[0].getSize();t++){let r=this._jsonValue[0].getValueByIndex(t);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.lipSync){e=r.getValueByString(this.ids).getVector().length;break}}return e}getLipSyncParameterId(e){if(!this.isExistLipSyncParameters())return null;for(let t=0;t<this._jsonValue[0].getSize();t++){let r=this._jsonValue[0].getValueByIndex(t);if(!(r.isNull()||r.isError())&&r.getValueByString(this.name).getRawString()==this.lipSync)return P.getIdManager().getId(r.getValueByString(this.ids).getValueByIndex(e).getRawString())}return null}isExistModelFile(){let e=this._jsonValue[1];return!e.isNull()&&!e.isError()}isExistTextureFiles(){let e=this._jsonValue[4];return!e.isNull()&&!e.isError()}isExistHitAreas(){let e=this._jsonValue[7];return!e.isNull()&&!e.isError()}isExistPhysicsFile(){let e=this._jsonValue[5];return!e.isNull()&&!e.isError()}isExistPoseFile(){let e=this._jsonValue[6];return!e.isNull()&&!e.isError()}isExistExpressionFile(){let e=this._jsonValue[3];return!e.isNull()&&!e.isError()}isExistMotionGroups(){let e=this._jsonValue[2];return!e.isNull()&&!e.isError()}isExistMotionGroupName(e){let t=this._jsonValue[2].getValueByString(e);return!t.isNull()&&!t.isError()}isExistMotionSoundFile(e,t){let r=this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.soundPath);return!r.isNull()&&!r.isError()}isExistMotionFadeIn(e,t){let r=this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.fadeInTime);return!r.isNull()&&!r.isError()}isExistMotionFadeOut(e,t){let r=this._jsonValue[2].getValueByString(e).getValueByIndex(t).getValueByString(this.fadeOutTime);return!r.isNull()&&!r.isError()}isExistUserDataFile(){let e=this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData);return!e.isNull()&&!e.isError()}isExistEyeBlinkParameters(){if(this._jsonValue[0].isNull()||this._jsonValue[0].isError())return!1;for(let e=0;e<this._jsonValue[0].getSize();++e)if(this._jsonValue[0].getValueByIndex(e).getValueByString(this.name).getRawString()==this.eyeBlink)return!0;return!1}isExistLipSyncParameters(){if(this._jsonValue[0].isNull()||this._jsonValue[0].isError())return!1;for(let e=0;e<this._jsonValue[0].getSize();++e)if(this._jsonValue[0].getValueByIndex(e).getValueByString(this.name).getRawString()==this.lipSync)return!0;return!1}_json;_jsonValue;version="Version";fileReferences="FileReferences";groups="Groups";layout="Layout";hitAreas="HitAreas";moc="Moc";textures="Textures";physics="Physics";pose="Pose";expressions="Expressions";motions="Motions";userData="UserData";name="Name";filePath="File";id="Id";ids="Ids";target="Target";idle="Idle";tapBody="TapBody";pinchIn="PinchIn";pinchOut="PinchOut";shake="Shake";flickHead="FlickHead";parameter="Parameter";soundPath="Sound";fadeInTime="FadeInTime";fadeOutTime="FadeOutTime";centerX="CenterX";centerY="CenterY";x="X";y="Y";width="Width";height="Height";lipSync="LipSync";eyeBlink="EyeBlink";initParameter="init_param";initPartsVisible="init_parts_visible";val="val"};(function(e){e.CubismModelSettingJson=Bs,e.FrequestNode=ua})(hi||(hi={}));nr=class Is{static create(){return new Is}static delete(t){t!=null&&(t=null)}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,r){this._currentTime+=r;let i=this._currentTime*2*Math.PI;for(let s=0;s<this._breathParameters.length;++s){let n=this._breathParameters[s];t.addParameterValueById(n.parameterId,n.offset+n.peak*Math.sin(i/n.cycle),n.weight)}}constructor(){this._currentTime=0}_breathParameters;_currentTime},De=class{constructor(e,t,r,i,s){this.parameterId=e??null,this.offset=t??0,this.peak=r??0,this.cycle=i??0,this.weight=s??0}parameterId;offset;peak;cycle;weight};(function(e){e.BreathParameterData=De,e.CubismBreath=nr})(ci||(ci={}));ar=class zt{static create(t=null){return new zt(t)}static delete(t){t!=null&&(t=null)}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,r,i){this._closingSeconds=t,this._closedSeconds=r,this._openingSeconds=i}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(t,r){this._userTimeSeconds+=r;let i,s=0;switch(this._blinkingState){case 2:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,s>=1&&(s=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),i=1-s;break;case 3:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,s>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),i=0;break;case 4:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,s>=1&&(s=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),i=s;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),i=1;break;default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),i=1;break}zt.CloseIfZero||(i=-i);for(let n=0;n<this._parameterIds.length;++n)t.setParameterValueById(this._parameterIds[n],i)}constructor(t){if(this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=new Array,t!=null){this._parameterIds.length=t.getEyeBlinkParameterCount();for(let r=0;r<t.getEyeBlinkParameterCount();++r)this._parameterIds[r]=t.getEyeBlinkParameterId(r)}}determinNextBlinkingTiming(){let t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}_blinkingState;_parameterIds;_nextBlinkingTime;_stateStartTimeSeconds;_blinkingIntervalSeconds;_closingSeconds;_closedSeconds;_openingSeconds;_userTimeSeconds;static CloseIfZero=!0},ha=(function(e){return e[e.EyeState_First=0]="EyeState_First",e[e.EyeState_Interval=1]="EyeState_Interval",e[e.EyeState_Closing=2]="EyeState_Closing",e[e.EyeState_Closed=3]="EyeState_Closed",e[e.EyeState_Opening=4]="EyeState_Opening",e})({});(function(e){e.CubismEyeBlink=ar,e.EyeState=ha})(di||(di={}));Jt=class Ss{static create(){return new Ss}static delete(t){t!=null&&(t=null)}setParameters(t){this._lookParameters=t}getParameters(){return this._lookParameters}updateParameters(t,r,i){for(let s=0;s<this._lookParameters.length;++s){let n=this._lookParameters[s];t.addParameterValueById(n.parameterId,n.factorX*r+n.factorY*i+n.factorXY*r*i)}}constructor(){this._lookParameters=new Array}_lookParameters},Ie=class{constructor(e,t,r,i){this.parameterId=e??null,this.factorX=t??0,this.factorY=r??0,this.factorXY=i??0}parameterId;factorX;factorY;factorXY};(function(e){e.LookParameterData=Ie,e.CubismLook=Jt})(gi||(gi={}));or=class extends ae{constructor(e,t){super(),this._width=e!==void 0?e:0,this._height=t!==void 0?t:0,this.setHeight(2)}setWidth(e){let t=e/this._width,r=t;this.scale(t,r)}setHeight(e){let t=e/this._height,r=t;this.scale(t,r)}setPosition(e,t){this.translate(e,t)}setCenterPosition(e,t){this.centerX(e),this.centerY(t)}top(e){this.setY(e)}bottom(e){let t=this._height*this.getScaleY();this.translateY(e-t)}left(e){this.setX(e)}right(e){let t=this._width*this.getScaleX();this.translateX(e-t)}centerX(e){let t=this._width*this.getScaleX();this.translateX(e-t/2)}setX(e){this.translateX(e)}centerY(e){let t=this._height*this.getScaleY();this.translateY(e-t/2)}setY(e){this.translateY(e)}setupFromLayout(e){let t="width",r="height",n="center_x",a="center_y",o="bottom",u="left",c="right";for(let g of e){let h=g[0],d=g[1];h==t?this.setWidth(d):h==r&&this.setHeight(d)}for(let g of e){let h=g[0],d=g[1];h=="x"?this.setX(d):h=="y"?this.setY(d):h==n?this.centerX(d):h==a?this.centerY(d):h=="top"?this.top(d):h==o?this.bottom(d):h==u?this.left(d):h==c&&this.right(d)}}_width;_height};(function(e){e.CubismModelMatrix=or})(fi||(fi={}));ca=.001,Ft=.5,Ai="FadeInTime",pi="Link",da="Groups",ga="Id",jt=class Ms{static create(t,r){let i=H.create(t,r);if(!i)return null;let s=new Ms,n=i.getRoot();n.getValueByString(Ai).isNull()||(s._fadeTimeSeconds=n.getValueByString(Ai).toFloat(Ft),s._fadeTimeSeconds<0&&(s._fadeTimeSeconds=Ft));let a=n.getValueByString(da),l=a.getSize();s._partGroupCounts.length=l;for(let o=0;o<l;++o){let u=a.getValueByIndex(o),c=u.getSize(),g=0;for(let h=0;h<c;++h){let d=u.getValueByIndex(h),f=new qt;if(f.partId=P.getIdManager().getId(d.getValueByString(ga).getRawString()),!d.getValueByString(pi).isNull()){let p=d.getValueByString(pi),A=p.getSize();for(let _=0;_<A;++_){let b=new qt;b.partId=P.getIdManager().getId(p.getValueByIndex(_).getString()),f.link.push(b)}}s._partGroups.push(f.clone()),++g}s._partGroupCounts[o]=g}return H.delete(i),s}static delete(t){t!=null&&(t=null)}updateParameters(t,r){t!=this._lastModel&&this.reset(t),this._lastModel=t,r<0&&(r=0);let i=0;for(let s=0;s<this._partGroupCounts.length;s++){let n=this._partGroupCounts[s];this.doFade(t,r,i,n),i+=n}this.copyPartOpacities(t)}reset(t){let r=0;for(let i=0;i<this._partGroupCounts.length;++i){let s=this._partGroupCounts[i];for(let n=r;n<r+s;++n){this._partGroups[n].initialize(t);let a=this._partGroups[n].partIndex,l=this._partGroups[n].parameterIndex;if(!(a<0)){t.setPartOpacityByIndex(a,n==r?1:0),t.setParameterValueByIndex(l,n==r?1:0);for(let o=0;o<this._partGroups[n].link.length;++o)this._partGroups[n].link[o].initialize(t)}}r+=s}}copyPartOpacities(t){for(let r=0;r<this._partGroups.length;++r){let i=this._partGroups[r];if(i.link.length==0)continue;let s=this._partGroups[r].partIndex,n=t.getPartOpacityByIndex(s);for(let a=0;a<i.link.length;++a){let l=i.link[a].partIndex;l<0||t.setPartOpacityByIndex(l,n)}}}doFade(t,r,i,s){let n=-1,a=1,l=.5,o=.15;for(let u=i;u<i+s;++u){let c=this._partGroups[u].partIndex,g=this._partGroups[u].parameterIndex;if(t.getParameterValueByIndex(g)>ca){if(n>=0)break;if(n=u,this._fadeTimeSeconds==0){a=1;continue}a=t.getPartOpacityByIndex(c),a+=r/this._fadeTimeSeconds,a>1&&(a=1)}}n<0&&(n=0,a=1);for(let u=i;u<i+s;++u){let c=this._partGroups[u].partIndex;if(n==u)t.setPartOpacityByIndex(c,a);else{let g=t.getPartOpacityByIndex(c),h;a<l?h=a*(l-1)/l+1:h=(1-a)*l/(1-l),(1-h)*(1-a)>o&&(h=1-o/(1-a)),g>h&&(g=h),t.setPartOpacityByIndex(c,g)}}}constructor(){this._fadeTimeSeconds=Ft,this._lastModel=null,this._partGroups=new Array,this._partGroupCounts=new Array}_partGroups;_partGroupCounts;_fadeTimeSeconds;_lastModel},qt=class ws{constructor(t){if(this.parameterIndex=0,this.partIndex=0,this.link=new Array,t!=null){this.partId=t.partId,this.link.length=t.link.length;for(let r=0;r<t.link.length;r++)this.link[r]=t.link[r].clone()}}assignment(t){this.partId=t.partId;let r=this.link.length;this.link.length+=t.link.length;for(let i of t.link)this.link[r++]=i.clone();return this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){let t=new ws;t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=new Array,t.link.length=this.link.length;for(let r=0;r<this.link.length;r++)t.link[r]=this.link[r].clone();return t}partId;parameterIndex;partIndex;link};(function(e){e.CubismPose=jt,e.PartData=qt})(mi||(mi={}));Ot=30,_i=.01,xs=class{constructor(){this._faceTargetX=0,this._faceTargetY=0,this._faceX=0,this._faceY=0,this._faceVX=0,this._faceVY=0,this._lastTimeSeconds=0,this._userTimeSeconds=0}update(e){this._userTimeSeconds+=e;let t=40/10*1/Ot;if(this._lastTimeSeconds==0){this._lastTimeSeconds=this._userTimeSeconds;return}let r=(this._userTimeSeconds-this._lastTimeSeconds)*Ot;this._lastTimeSeconds=this._userTimeSeconds;let i=.15*Ot,s=r*t/i,n=this._faceTargetX-this._faceX,a=this._faceTargetY-this._faceY;if(x.abs(n)<=_i&&x.abs(a)<=_i)return;let l=x.sqrt(n*n+a*a),o=t*n/l,u=t*a/l,c=o-this._faceVX,g=u-this._faceVY,h=x.sqrt(c*c+g*g);(h<-s||h>s)&&(c*=s/h,g*=s/h),this._faceVX+=c,this._faceVY+=g;{let d=.5*(x.sqrt(s*s+16*s*l-8*s*l)-s),f=x.sqrt(this._faceVX*this._faceVX+this._faceVY*this._faceVY);f>d&&(this._faceVX*=d/f,this._faceVY*=d/f)}this._faceX+=this._faceVX,this._faceY+=this._faceVY}getX(){return this._faceX}getY(){return this._faceY}set(e,t){this._faceTargetX=e,this._faceTargetY=t}_faceTargetX;_faceTargetY;_faceX;_faceY;_faceVX;_faceVY;_lastTimeSeconds;_userTimeSeconds};(function(e){e.CubismTargetPoint=xs})(Ci||(Ci={}));Es=class{constructor(){this._autoDelete=!1,this._motion=null,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&Se.delete(this._motion)}setFadeOut(e){this._fadeOutSeconds=e,this._isTriggeredFadeOut=!0}startFadeOut(e,t){let r=t+e;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||r<this._endTimeSeconds)&&(this._endTimeSeconds=r)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(e){this._startTimeSeconds=e}setFadeInStartTime(e){this._fadeInStartTimeSeconds=e}setEndTime(e){this._endTimeSeconds=e}setIsFinished(e){this._finished=e}setIsStarted(e){this._started=e}isAvailable(){return this._available}setIsAvailable(e){this._available=e}setState(e,t){this._stateTimeSeconds=e,this._stateWeight=t}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(e){this._lastEventCheckSeconds=e}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}getCubismMotion(){return this._motion}_autoDelete;_motion;_available;_finished;_started;_startTimeSeconds;_fadeInStartTimeSeconds;_endTimeSeconds;_stateTimeSeconds;_stateWeight;_lastEventCheckSeconds;_fadeOutSeconds;_isTriggeredFadeOut;_motionQueueEntryHandle};(function(e){e.CubismMotionQueueEntry=Es})(yi||(yi={}));Se=class{static delete(e){e.release(),e=null}constructor(){this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._isLoop=!1,this._isLoopFadeIn=!0,this._previousLoopState=this._isLoop,this._firedEventValues=new Array}release(){this._weight=0}updateParameters(e,t,r){if(!t.isAvailable()||t.isFinished())return;this.setupMotionQueueEntry(t,r);let i=this.updateFadeWeight(t,r);this.doUpdateParameters(e,r,i,t),t.getEndTime()>0&&t.getEndTime()<r&&t.setIsFinished(!0)}setupMotionQueueEntry(e,t){e==null||e.isStarted()||e.isAvailable()&&(e.setIsStarted(!0),e.setStartTime(t-this._offsetSeconds),e.setFadeInStartTime(t),e.getEndTime()<0&&this.adjustEndTime(e),e._motion._onBeganMotion&&e._motion._onBeganMotion(e._motion))}updateFadeWeight(e,t){e==null&&ir.print(4,"motionQueueEntry is null.");let r=this._weight,i=this._fadeInSeconds==0?1:x.getEasingSine((t-e.getFadeInStartTime())/this._fadeInSeconds),s=this._fadeOutSeconds==0||e.getEndTime()<0?1:x.getEasingSine((e.getEndTime()-t)/this._fadeOutSeconds);return r=r*i*s,e.setState(t,r),U(0<=r&&r<=1),r}setFadeInTime(e){this._fadeInSeconds=e}setFadeOutTime(e){this._fadeOutSeconds=e}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(e){this._weight=e}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(e){this._offsetSeconds=e}setLoop(e){this._isLoop=e}getLoop(){return this._isLoop}setLoopFadeIn(e){this._isLoopFadeIn=e}getLoopFadeIn(){return this._isLoopFadeIn}getFiredEvent(e,t){return this._firedEventValues}setBeganMotionHandler=e=>this._onBeganMotion=e;getBeganMotionHandler=()=>this._onBeganMotion;setFinishedMotionHandler=e=>this._onFinishedMotion=e;getFinishedMotionHandler=()=>this._onFinishedMotion;isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(e){return null}getModelOpacityValue(){return 1}adjustEndTime(e){let t=this.getDuration(),r=t<=0?-1:e.getStartTime()+t;e.setEndTime(r)}_fadeInSeconds;_fadeOutSeconds;_weight;_offsetSeconds;_isLoop;_isLoopFadeIn;_previousLoopState;_firedEventValues;_onBeganMotion;_onFinishedMotion};(function(e){e.ACubismMotion=Se})(bi||(bi={}));lr=class{constructor(){this._userTimeSeconds=0,this._eventCallBack=null,this._eventCustomData=null,this._motions=new Array}release(){for(let e=0;e<this._motions.length;++e)this._motions[e]&&(this._motions[e].release(),this._motions[e]=null);this._motions=null}startMotion(e,t,r){if(e==null)return-1;let i=null;for(let s=0;s<this._motions.length;++s)i=this._motions[s],i?.setFadeOut(i._motion.getFadeOutTime());return i=new Es,i._autoDelete=t,i._motion=e,this._motions.push(i),i._motionQueueEntryHandle}isFinished(){for(let e=0;e<this._motions.length;){let t=this._motions[e];if(t==null){this._motions.splice(e,1);continue}if(t._motion==null){t.release(),t=null,this._motions.splice(e,1);continue}if(t.isFinished())e++;else return!1}return!0}isFinishedByHandle(e){for(let t=0;t<this._motions.length;t++){let r=this._motions[t];if(r!=null&&r._motionQueueEntryHandle==e&&!r.isFinished())return!1}return!0}stopAllMotions(){for(let e=0;e<this._motions.length;e++){let t=this._motions[e];if(t==null){this._motions.splice(e,1);continue}t.release(),this._motions.splice(e,1)}}getCubismMotionQueueEntries(){return this._motions}getCubismMotionQueueEntry(e){for(let t=0;t<this._motions.length;t++){let r=this._motions[t];if(r!=null&&r._motionQueueEntryHandle==e)return r}return null}setEventCallback(e,t=null){this._eventCallBack=e,this._eventCustomData=t}doUpdateMotion(e,t){let r=!1;for(let i=0;i<this._motions.length;){let s=this._motions[i];if(s==null){this._motions.splice(i,1);continue}let n=s._motion;if(n==null){s.release(),s=null,this._motions.splice(i,1);continue}n.updateParameters(e,s,t),r=!0;let a=n.getFiredEvent(s.getLastCheckEventSeconds()-s.getStartTime(),t-s.getStartTime());for(let l=0;l<a.length;++l)this._eventCallBack(this,a[l],this._eventCustomData);s.setLastCheckEventSeconds(t),s.isFinished()?(s.release(),s=null,this._motions.splice(i,1)):(s.isTriggeredFadeOut()&&s.startFadeOut(s.getFadeOutSeconds(),t),i++)}return r}_userTimeSeconds;_motions;_eventCallBack;_eventCustomData};(function(e){e.CubismMotionQueueManager=lr,e.InvalidMotionQueueEntryHandleValue=-1})(Bi||(Bi={}));fa=class{parameterId;additiveValue;multiplyValue;overwriteValue},vs=class extends lr{constructor(){super(),this._expressionParameterValues=new Array,this._fadeWeights=new Array}release(){this._expressionParameterValues&&(Le(this._expressionParameterValues),this._expressionParameterValues=null),this._fadeWeights&&(Le(this._fadeWeights),this._fadeWeights=null)}getFadeWeight(e){return e<0||this._fadeWeights.length<1||e>=this._fadeWeights.length?(console.warn("Failed to get the fade weight value. The element at that index does not exist."),-1):this._fadeWeights[e]}setFadeWeight(e,t){if(e<0||this._fadeWeights.length<1||this._fadeWeights.length<=e){console.warn("Failed to set the fade weight value. The element at that index does not exist.");return}this._fadeWeights[e]=t}updateMotion(e,t){this._userTimeSeconds+=t;let r=!1,i=this.getCubismMotionQueueEntries(),s=0,n=0;if(this._fadeWeights.length!==i.length){let a=i.length-this._fadeWeights.length,l=this._fadeWeights.length;this._fadeWeights.length+=a;for(let o=0;o<a;o++)this._fadeWeights[l++]=0}for(let a=0;a<this._motions.length;){let l=this._motions[a];if(l==null){i.splice(a,1);continue}let o=l.getCubismMotion();if(o==null){Le(l),i.splice(a,1);continue}let u=o.getExpressionParameters();if(l.isAvailable())for(let c=0;c<u.length;++c){if(u[c].parameterId==null)continue;let g=-1;for(let d=0;d<this._expressionParameterValues.length;++d)if(this._expressionParameterValues[d].parameterId==u[c].parameterId){g=d;break}if(g>=0)continue;let h=new fa;h.parameterId=u[c].parameterId,h.additiveValue=Te.DefaultAdditiveValue,h.multiplyValue=Te.DefaultMultiplyValue,h.overwriteValue=e.getParameterValueById(h.parameterId),this._expressionParameterValues.push(h)}o.setupMotionQueueEntry(l,this._userTimeSeconds),this.setFadeWeight(n,o.updateFadeWeight(l,this._userTimeSeconds)),o.calculateExpressionParameters(e,this._userTimeSeconds,l,this._expressionParameterValues,n,this.getFadeWeight(n)),s+=o.getFadeInTime()==0?1:x.getEasingSine((this._userTimeSeconds-l.getFadeInStartTime())/o.getFadeInTime()),r=!0,l.isTriggeredFadeOut()&&l.startFadeOut(l.getFadeOutSeconds(),this._userTimeSeconds),++a,++n}if(i.length>1&&this.getFadeWeight(this._fadeWeights.length-1)>=1)for(let a=i.length-2;a>=0;--a){let l=i[a];Le(l),i.splice(a,1),this._fadeWeights.splice(a,1)}s>1&&(s=1);for(let a=0;a<this._expressionParameterValues.length;++a){let l=this._expressionParameterValues[a];e.setParameterValueById(l.parameterId,(l.overwriteValue+l.additiveValue)*l.multiplyValue,s),l.additiveValue=Te.DefaultAdditiveValue,l.multiplyValue=Te.DefaultMultiplyValue}return r}_expressionParameterValues;_fadeWeights;_startExpressionTime};(function(e){e.CubismExpressionMotionManager=vs})(Ii||(Ii={}));Aa="FadeInTime",pa="FadeOutTime",Si="Parameters",ma="Id",_a="Value",rt="Blend",Ca="Add",ya="Multiply",ba="Overwrite",Mi=1,Te=class se extends Se{static DefaultAdditiveValue=0;static DefaultMultiplyValue=1;static create(t,r){let i=new se;return i.parse(t,r),i}doUpdateParameters(t,r,i,s){for(let n=0;n<this._parameters.length;++n){let a=this._parameters[n];switch(a.blendType){case 0:t.addParameterValueById(a.parameterId,a.value,i);break;case 1:t.multiplyParameterValueById(a.parameterId,a.value,i);break;case 2:t.setParameterValueById(a.parameterId,a.value,i);break;default:break}}}calculateExpressionParameters(t,r,i,s,n,a){if(!(i==null||s==null)&&i.isAvailable())for(let l=0;l<s.length;++l){let o=s[l];if(o.parameterId==null)continue;let u=o.overwriteValue=t.getParameterValueById(o.parameterId),c=this.getExpressionParameters(),g=-1;for(let A=0;A<c.length;++A)if(o.parameterId==c[A].parameterId){g=A;break}if(g<0){n==0?(o.additiveValue=se.DefaultAdditiveValue,o.multiplyValue=se.DefaultMultiplyValue,o.overwriteValue=u):(o.additiveValue=this.calculateValue(o.additiveValue,se.DefaultAdditiveValue,a),o.multiplyValue=this.calculateValue(o.multiplyValue,se.DefaultMultiplyValue,a),o.overwriteValue=this.calculateValue(o.overwriteValue,u,a));continue}let h=c[g].value,d,f,p;switch(c[g].blendType){case 0:d=h,f=se.DefaultMultiplyValue,p=u;break;case 1:d=se.DefaultAdditiveValue,f=h,p=u;break;case 2:d=se.DefaultAdditiveValue,f=se.DefaultMultiplyValue,p=h;break;default:return}n==0?(o.additiveValue=d,o.multiplyValue=f,o.overwriteValue=p):(o.additiveValue=o.additiveValue*(1-a)+d*a,o.multiplyValue=o.multiplyValue*(1-a)+f*a,o.overwriteValue=o.overwriteValue*(1-a)+p*a)}}getExpressionParameters(){return this._parameters}parse(t,r){let i=H.create(t,r);if(!i)return;let s=i.getRoot();this.setFadeInTime(s.getValueByString(Aa).toFloat(Mi)),this.setFadeOutTime(s.getValueByString(pa).toFloat(Mi));let n=s.getValueByString(Si).getSize(),a=this._parameters.length;this._parameters.length+=n;for(let l=0;l<n;++l){let o=s.getValueByString(Si).getValueByIndex(l),u=P.getIdManager().getId(o.getValueByString(ma).getRawString()),c=o.getValueByString(_a).toFloat(),g;o.getValueByString(rt).isNull()||o.getValueByString(rt).getString()==Ca?g=0:o.getValueByString(rt).getString()==ya?g=1:o.getValueByString(rt).getString()==ba?g=2:g=0;let h=new Ps;h.parameterId=u,h.blendType=g,h.value=c,this._parameters[a++]=h}H.delete(i)}calculateValue(t,r,i){return t*(1-i)+r*i}constructor(){super(),this._parameters=new Array}_parameters},Ba=(function(e){return e[e.Additive=0]="Additive",e[e.Multiply=1]="Multiply",e[e.Overwrite=2]="Overwrite",e})({}),Ps=class{parameterId;blendType;value};(function(e){e.CubismExpressionMotion=Te,e.ExpressionBlendType=Ba,e.ExpressionParameter=Ps})(wi||(wi={}));Ia=(function(e){return e[e.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",e[e.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",e[e.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",e})({}),Sa=(function(e){return e[e.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",e[e.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",e[e.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",e[e.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",e})({}),ze=class{time=0;value=0},Rs=class{constructor(){this.evaluate=null,this.basePointIndex=0,this.segmentType=0}evaluate;basePointIndex;segmentType},Ds=class{constructor(){this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}type;id;segmentCount;baseSegmentIndex;fadeInTime;fadeOutTime},Ls=class{fireTime=0;value},Ts=class{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=new Array,this.segments=new Array,this.points=new Array,this.events=new Array}duration;loop;curveCount;eventCount;fps;curves;segments;points;events};(function(e){e.CubismMotionCurve=Ds,e.CubismMotionCurveTarget=Ia,e.CubismMotionData=Ts,e.CubismMotionEvent=Ls,e.CubismMotionPoint=ze,e.CubismMotionSegment=Rs,e.CubismMotionSegmentType=Sa})(xi||(xi={}));X="Meta",Ma="Duration",wa="Loop",xa="AreBeziersRestricted",Ea="CurveCount",va="Fps",Pa="TotalSegmentCount",Ra="TotalPointCount",ce="Curves",Da="Target",La="Id",it="FadeInTime",st="FadeOutTime",Ei="Segments",vi="UserData",Ta="UserDataCount",Fa="TotalUserDataSize",Oa="Time",Va="Value",Fs=class{constructor(e,t){this._json=H.create(e,t)}release(){H.delete(this._json)}getMotionDuration(){return this._json.getRoot().getValueByString(X).getValueByString(Ma).toFloat()}isMotionLoop(){return this._json.getRoot().getValueByString(X).getValueByString(wa).toBoolean()}hasConsistency(){let e=!0;if(!this._json||!this._json.getRoot())return!1;let t=this._json.getRoot().getValueByString(ce).getVector().length,r=0,i=0;for(let s=0;s<t;++s)for(let n=0;n<this.getMotionCurveSegmentCount(s);){switch(n==0&&(i+=1,n+=2),this.getMotionCurveSegment(s,n)){case 0:i+=1,n+=3;break;case 1:i+=3,n+=7;break;case 2:i+=1,n+=3;break;case 3:i+=1,n+=3;break;default:U(0);break}++r}return t!=this.getMotionCurveCount()&&(k("The number of curves does not match the metadata."),e=!1),r!=this.getMotionTotalSegmentCount()&&(k("The number of segment does not match the metadata."),e=!1),i!=this.getMotionTotalPointCount()&&(k("The number of point does not match the metadata."),e=!1),e}getEvaluationOptionFlag(e){return e==0?this._json.getRoot().getValueByString(X).getValueByString(xa).toBoolean():!1}getMotionCurveCount(){return this._json.getRoot().getValueByString(X).getValueByString(Ea).toInt()}getMotionFps(){return this._json.getRoot().getValueByString(X).getValueByString(va).toFloat()}getMotionTotalSegmentCount(){return this._json.getRoot().getValueByString(X).getValueByString(Pa).toInt()}getMotionTotalPointCount(){return this._json.getRoot().getValueByString(X).getValueByString(Ra).toInt()}isExistMotionFadeInTime(){return!this._json.getRoot().getValueByString(X).getValueByString(it).isNull()}isExistMotionFadeOutTime(){return!this._json.getRoot().getValueByString(X).getValueByString(st).isNull()}getMotionFadeInTime(){return this._json.getRoot().getValueByString(X).getValueByString(it).toFloat()}getMotionFadeOutTime(){return this._json.getRoot().getValueByString(X).getValueByString(st).toFloat()}getMotionCurveTarget(e){return this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(Da).getRawString()}getMotionCurveId(e){return P.getIdManager().getId(this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(La).getRawString())}isExistMotionCurveFadeInTime(e){return!this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(it).isNull()}isExistMotionCurveFadeOutTime(e){return!this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(st).isNull()}getMotionCurveFadeInTime(e){return this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(it).toFloat()}getMotionCurveFadeOutTime(e){return this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(st).toFloat()}getMotionCurveSegmentCount(e){return this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(Ei).getVector().length}getMotionCurveSegment(e,t){return this._json.getRoot().getValueByString(ce).getValueByIndex(e).getValueByString(Ei).getValueByIndex(t).toFloat()}getEventCount(){return this._json.getRoot().getValueByString(X).getValueByString(Ta).toInt()}getTotalEventValueSize(){return this._json.getRoot().getValueByString(X).getValueByString(Fa).toInt()}getEventTime(e){return this._json.getRoot().getValueByString(vi).getValueByIndex(e).getValueByString(Oa).toFloat()}getEventValue(e){return this._json.getRoot().getValueByString(vi).getValueByIndex(e).getValueByString(Va).getRawString()}_json};(function(e){e.CubismMotionJson=Fs})(Pi||(Pi={}));ka="EyeBlink",Qa="LipSync",Ua="Model",Na="Parameter",Ga="PartOpacity",nt="Opacity",Xa=!1;Qs=class Us extends Se{static create(t,r,i,s,n=!1){let a=new Us;if(a.parse(t,r,n),a._motionData)a._sourceFrameRate=a._motionData.fps,a._loopDurationSeconds=a._motionData.duration,a._onFinishedMotion=i,a._onBeganMotion=s;else return Le(a),null;return a}doUpdateParameters(t,r,i,s){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=P.getIdManager().getId(ka)),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=P.getIdManager().getId(Qa)),this._modelCurveIdOpacity==null&&(this._modelCurveIdOpacity=P.getIdManager().getId(nt)),this._motionBehavior===1&&this._previousLoopState!==this._isLoop&&(this.adjustEndTime(s),this._previousLoopState=this._isLoop);let n=r-s.getStartTime();n<0&&(n=0);let a=Number.MAX_VALUE,l=Number.MAX_VALUE,o=64,u=0,c=0;this._eyeBlinkParameterIds.length>o&&Wt("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>o&&Wt("too many lip sync targets : {0}",this._lipSyncParameterIds.length);let g=this._fadeInSeconds<=0?1:x.getEasingSine((r-s.getFadeInStartTime())/this._fadeInSeconds),h=this._fadeOutSeconds<=0||s.getEndTime()<0?1:x.getEasingSine((s.getEndTime()-r)/this._fadeOutSeconds),d,f,p,A=n,_=this._motionData.duration,b=this._motionBehavior===1&&this._isLoop;if(this._isLoop)for(this._motionBehavior===1&&(_+=1/this._motionData.fps);A>_;)A-=_;let C=this._motionData.curves;for(f=0;f<this._motionData.curveCount&&C[f].type==0;++f)d=Vt(this._motionData,f,A,b,_),C[f].id==this._modelCurveIdEyeBlink?l=d:C[f].id==this._modelCurveIdLipSync?a=d:C[f].id==this._modelCurveIdOpacity&&(this._modelOpacity=d,t.setModelOapcity(this.getModelOpacityValue()));let B=0;for(;f<this._motionData.curveCount&&C[f].type==1;++f){if(B++,p=t.getParameterIndex(C[f].id),p==-1)continue;let I=t.getParameterValueByIndex(p);if(d=Vt(this._motionData,f,A,b,_),l!=Number.MAX_VALUE){for(let w=0;w<this._eyeBlinkParameterIds.length&&w<o;++w)if(this._eyeBlinkParameterIds[w]==C[f].id){d*=l,c|=1<<w;break}}if(a!=Number.MAX_VALUE){for(let w=0;w<this._lipSyncParameterIds.length&&w<o;++w)if(this._lipSyncParameterIds[w]==C[f].id){d+=a,u|=1<<w;break}}t.isRepeat(p)&&(d=t.getParameterRepeatValue(p,d));let y;if(C[f].fadeInTime<0&&C[f].fadeOutTime<0)y=I+(d-I)*i;else{let w,L;C[f].fadeInTime<0?w=g:w=C[f].fadeInTime==0?1:x.getEasingSine((r-s.getFadeInStartTime())/C[f].fadeInTime),C[f].fadeOutTime<0?L=h:L=C[f].fadeOutTime==0||s.getEndTime()<0?1:x.getEasingSine((s.getEndTime()-r)/C[f].fadeOutTime);let D=this._weight*w*L;y=I+(d-I)*D}t.setParameterValueByIndex(p,y,1)}if(l!=Number.MAX_VALUE)for(let I=0;I<this._eyeBlinkParameterIds.length&&I<o;++I){let y=t.getParameterValueById(this._eyeBlinkParameterIds[I]);if(c>>I&1)continue;let w=y+(l-y)*i;t.setParameterValueById(this._eyeBlinkParameterIds[I],w)}if(a!=Number.MAX_VALUE)for(let I=0;I<this._lipSyncParameterIds.length&&I<o;++I){let y=t.getParameterValueById(this._lipSyncParameterIds[I]);if(u>>I&1)continue;let w=y+(a-y)*i;t.setParameterValueById(this._lipSyncParameterIds[I],w)}for(;f<this._motionData.curveCount&&C[f].type==2;++f)p=t.getParameterIndex(C[f].id),p!=-1&&(d=Vt(this._motionData,f,A,b,_),t.setParameterValueByIndex(p,d));n>=_&&(this._isLoop?this.updateForNextLoop(s,r,A):(this._onFinishedMotion&&this._onFinishedMotion(this),s.setIsFinished(!0))),this._lastWeight=i}setMotionBehavior(t){this._motionBehavior=t}getMotionBehavior(){return this._motionBehavior}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(t,r){let i=this._motionData.curves;for(let s=0;s<this._motionData.curveCount;++s)if(t==i[s].id){i[s].fadeInTime=r;return}}setParameterFadeOutTime(t,r){let i=this._motionData.curves;for(let s=0;s<this._motionData.curveCount;++s)if(t==i[s].id){i[s].fadeOutTime=r;return}}getParameterFadeInTime(t){let r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r[i].id)return r[i].fadeInTime;return-1}getParameterFadeOutTime(t){let r=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==r[i].id)return r[i].fadeOutTime;return-1}setEffectIds(t,r){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=r}constructor(){super(),this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._motionData=null,this._modelCurveIdEyeBlink=null,this._modelCurveIdLipSync=null,this._modelCurveIdOpacity=null,this._eyeBlinkParameterIds=null,this._lipSyncParameterIds=null,this._modelOpacity=1,this._debugMode=!1}release(){this._motionData=void 0,this._motionData=null}updateForNextLoop(t,r,i){switch(this._motionBehavior){case 1:default:t.setStartTime(r-i),this._isLoopFadeIn&&t.setFadeInStartTime(r-i),this._onFinishedMotion!=null&&this._onFinishedMotion(this);break;case 0:t.setStartTime(r),this._isLoopFadeIn&&t.setFadeInStartTime(r);break}}parse(t,r,i=!1){let s=new Fs(t,r);if(!s){s.release(),s=void 0;return}if(i&&!s.hasConsistency()){s.release(),T("Inconsistent motion3.json.");return}this._motionData=new Ts,this._motionData.duration=s.getMotionDuration(),this._motionData.loop=s.isMotionLoop(),this._motionData.curveCount=s.getMotionCurveCount(),this._motionData.fps=s.getMotionFps(),this._motionData.eventCount=s.getEventCount();let n=s.getEvaluationOptionFlag(0);s.isExistMotionFadeInTime()?this._fadeInSeconds=s.getMotionFadeInTime()<0?1:s.getMotionFadeInTime():this._fadeInSeconds=1,s.isExistMotionFadeOutTime()?this._fadeOutSeconds=s.getMotionFadeOutTime()<0?1:s.getMotionFadeOutTime():this._fadeOutSeconds=1,N(this._motionData.curves,this._motionData.curveCount,Ds,!0),N(this._motionData.segments,s.getMotionTotalSegmentCount(),Rs,!0),N(this._motionData.points,s.getMotionTotalPointCount(),ze,!0),N(this._motionData.events,this._motionData.eventCount,Ls,!0);let a=0,l=0;for(let o=0;o<this._motionData.curveCount;++o){s.getMotionCurveTarget(o)==Ua?this._motionData.curves[o].type=0:s.getMotionCurveTarget(o)==Na?this._motionData.curves[o].type=1:s.getMotionCurveTarget(o)==Ga?this._motionData.curves[o].type=2:k('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!'),this._motionData.curves[o].id=s.getMotionCurveId(o),this._motionData.curves[o].baseSegmentIndex=l,this._motionData.curves[o].fadeInTime=s.isExistMotionCurveFadeInTime(o)?s.getMotionCurveFadeInTime(o):-1,this._motionData.curves[o].fadeOutTime=s.isExistMotionCurveFadeOutTime(o)?s.getMotionCurveFadeOutTime(o):-1;for(let u=0;u<s.getMotionCurveSegmentCount(o);){switch(u==0?(this._motionData.segments[l].basePointIndex=a,this._motionData.points[a].time=s.getMotionCurveSegment(o,u),this._motionData.points[a].value=s.getMotionCurveSegment(o,u+1),a+=1,u+=2):this._motionData.segments[l].basePointIndex=a-1,s.getMotionCurveSegment(o,u)){case 0:this._motionData.segments[l].segmentType=0,this._motionData.segments[l].evaluate=Os,this._motionData.points[a].time=s.getMotionCurveSegment(o,u+1),this._motionData.points[a].value=s.getMotionCurveSegment(o,u+2),a+=1,u+=3;break;case 1:this._motionData.segments[l].segmentType=1,n||Xa?this._motionData.segments[l].evaluate=Ha:this._motionData.segments[l].evaluate=Wa,this._motionData.points[a].time=s.getMotionCurveSegment(o,u+1),this._motionData.points[a].value=s.getMotionCurveSegment(o,u+2),this._motionData.points[a+1].time=s.getMotionCurveSegment(o,u+3),this._motionData.points[a+1].value=s.getMotionCurveSegment(o,u+4),this._motionData.points[a+2].time=s.getMotionCurveSegment(o,u+5),this._motionData.points[a+2].value=s.getMotionCurveSegment(o,u+6),a+=3,u+=7;break;case 2:this._motionData.segments[l].segmentType=2,this._motionData.segments[l].evaluate=Vs,this._motionData.points[a].time=s.getMotionCurveSegment(o,u+1),this._motionData.points[a].value=s.getMotionCurveSegment(o,u+2),a+=1,u+=3;break;case 3:this._motionData.segments[l].segmentType=3,this._motionData.segments[l].evaluate=ks,this._motionData.points[a].time=s.getMotionCurveSegment(o,u+1),this._motionData.points[a].value=s.getMotionCurveSegment(o,u+2),a+=1,u+=3;break;default:U(0);break}++this._motionData.curves[o].segmentCount,++l}}for(let o=0;o<s.getEventCount();++o)this._motionData.events[o].fireTime=s.getEventTime(o),this._motionData.events[o].value=s.getEventValue(o);s.release(),s=void 0,s=null}getFiredEvent(t,r){N(this._firedEventValues,0);for(let i=0;i<this._motionData.eventCount;++i)this._motionData.events[i].fireTime>t&&this._motionData.events[i].fireTime<=r&&this._firedEventValues.push(this._motionData.events[i].value);return this._firedEventValues}isExistModelOpacity(){for(let t=0;t<this._motionData.curveCount;t++){let r=this._motionData.curves[t];if(r.type==0&&r.id.getString().localeCompare(nt)==0)return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let t=0;t<this._motionData.curveCount;t++){let r=this._motionData.curves[t];if(r.type==0&&r.id.getString().localeCompare(nt)==0)return t}return-1}getModelOpacityId(t){if(t!=-1){let r=this._motionData.curves[t];if(r.type==0&&r.id.getString().localeCompare(nt)==0)return P.getIdManager().getId(r.id.getString())}return null}getModelOpacityValue(){return this._modelOpacity}setDebugMode(t){this._debugMode=t}_sourceFrameRate;_loopDurationSeconds;_motionBehavior=1;_lastWeight;_motionData;_eyeBlinkParameterIds;_lipSyncParameterIds;_modelCurveIdEyeBlink;_modelCurveIdLipSync;_modelCurveIdOpacity;_modelOpacity;_debugMode};(function(e){e.CubismMotion=Qs})(Ri||(Ri={}));Ns=class extends lr{constructor(){super(),this._currentPriority=0,this._reservePriority=0}getCurrentPriority(){return this._currentPriority}getReservePriority(){return this._reservePriority}setReservePriority(e){this._reservePriority=e}startMotionPriority(e,t,r){return r==this._reservePriority&&(this._reservePriority=0),this._currentPriority=r,super.startMotion(e,t)}updateMotion(e,t){this._userTimeSeconds+=t;let r=super.doUpdateMotion(e,this._userTimeSeconds);return this.isFinished()&&(this._currentPriority=0),r}reserveMotion(e){return e<=this._reservePriority||e<=this._currentPriority?!1:(this._reservePriority=e,!0)}_currentPriority;_reservePriority};(function(e){e.CubismMotionManager=Ns})(Di||(Di={}));za=(function(e){return e[e.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",e})({}),Ja=(function(e){return e[e.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",e[e.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",e[e.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",e})({}),ja=class{constructor(){this.gravity=new E(0,0),this.wind=new E(0,0)}gravity;wind},ur=class{id;targetType},Zt=class{minimum;maximum;defalut},Gs=class{constructor(){this.initialPosition=new E(0,0),this.position=new E(0,0),this.lastPosition=new E(0,0),this.lastGravity=new E(0,0),this.force=new E(0,0),this.velocity=new E(0,0)}initialPosition;mobility;delay;acceleration;radius;position;lastPosition;lastGravity;force;velocity},Xs=class{constructor(){this.normalizationPosition=new Zt,this.normalizationAngle=new Zt}inputCount;outputCount;particleCount;baseInputIndex;baseOutputIndex;baseParticleIndex;normalizationPosition;normalizationAngle},Hs=class{constructor(){this.source=new ur}source;sourceParameterIndex;weight;type;reflect;getNormalizedParameterValue},Ws=class{constructor(){this.destination=new ur,this.translationScale=new E(0,0)}destination;destinationParameterIndex;vertexIndex;translationScale;angleScale;weight;type;reflect;valueBelowMinimum;valueExceededMaximum;getValue;getScale},Ys=class{constructor(){this.settings=new Array,this.inputs=new Array,this.outputs=new Array,this.particles=new Array,this.gravity=new E(0,0),this.wind=new E(0,0),this.fps=0}subRigCount;settings;inputs;outputs;particles;gravity;wind;fps};(function(e){e.CubismPhysicsInput=Hs,e.CubismPhysicsNormalization=Zt,e.CubismPhysicsOutput=Ws,e.CubismPhysicsParameter=ur,e.CubismPhysicsParticle=Gs,e.CubismPhysicsRig=Ys,e.CubismPhysicsSource=Ja,e.CubismPhysicsSubRig=Xs,e.CubismPhysicsTargetType=za,e.PhysicsJsonEffectiveForces=ja})(Li||(Li={}));Xe="Position",kt="X",Qt="Y",Ut="Angle",Ti="Type",Fi="Id",de="Meta",at="EffectiveForces",qa="TotalInputCount",Za="TotalOutputCount",Ka="PhysicsSettingCount",Oi="Gravity",Vi="Wind",$a="VertexCount",eo="Fps",F="PhysicsSettings",ve="Normalization",ki="Minimum",Qi="Maximum",Ui="Default",Ni="Reflect",Gi="Weight",He="Input",to="Source",ye="Output",ro="Scale",io="VertexIndex",so="Destination",be="Vertices",no="Mobility",ao="Delay",oo="Radius",lo="Acceleration",zs=class{constructor(e,t){this._json=H.create(e,t)}release(){H.delete(this._json)}getGravity(){let e=new E(0,0);return e.x=this._json.getRoot().getValueByString(de).getValueByString(at).getValueByString(Oi).getValueByString(kt).toFloat(),e.y=this._json.getRoot().getValueByString(de).getValueByString(at).getValueByString(Oi).getValueByString(Qt).toFloat(),e}getWind(){let e=new E(0,0);return e.x=this._json.getRoot().getValueByString(de).getValueByString(at).getValueByString(Vi).getValueByString(kt).toFloat(),e.y=this._json.getRoot().getValueByString(de).getValueByString(at).getValueByString(Vi).getValueByString(Qt).toFloat(),e}getFps(){return this._json.getRoot().getValueByString(de).getValueByString(eo).toFloat(0)}getSubRigCount(){return this._json.getRoot().getValueByString(de).getValueByString(Ka).toInt()}getTotalInputCount(){return this._json.getRoot().getValueByString(de).getValueByString(qa).toInt()}getTotalOutputCount(){return this._json.getRoot().getValueByString(de).getValueByString(Za).toInt()}getVertexCount(){return this._json.getRoot().getValueByString(de).getValueByString($a).toInt()}getNormalizationPositionMinimumValue(e){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ve).getValueByString(Xe).getValueByString(ki).toFloat()}getNormalizationPositionMaximumValue(e){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ve).getValueByString(Xe).getValueByString(Qi).toFloat()}getNormalizationPositionDefaultValue(e){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ve).getValueByString(Xe).getValueByString(Ui).toFloat()}getNormalizationAngleMinimumValue(e){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ve).getValueByString(Ut).getValueByString(ki).toFloat()}getNormalizationAngleMaximumValue(e){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ve).getValueByString(Ut).getValueByString(Qi).toFloat()}getNormalizationAngleDefaultValue(e){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ve).getValueByString(Ut).getValueByString(Ui).toFloat()}getInputCount(e){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(He).getVector().length}getInputWeight(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(He).getValueByIndex(t).getValueByString(Gi).toFloat()}getInputReflect(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(He).getValueByIndex(t).getValueByString(Ni).toBoolean()}getInputType(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(He).getValueByIndex(t).getValueByString(Ti).getRawString()}getInputSourceId(e,t){return P.getIdManager().getId(this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(He).getValueByIndex(t).getValueByString(to).getValueByString(Fi).getRawString())}getOutputCount(e){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ye).getVector().length}getOutputVertexIndex(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(io).toInt()}getOutputAngleScale(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(ro).toFloat()}getOutputWeight(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(Gi).toFloat()}getOutputDestinationId(e,t){return P.getIdManager().getId(this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(so).getValueByString(Fi).getRawString())}getOutputType(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(Ti).getRawString()}getOutputReflect(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(ye).getValueByIndex(t).getValueByString(Ni).toBoolean()}getParticleCount(e){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(be).getVector().length}getParticleMobility(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(no).toFloat()}getParticleDelay(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(ao).toFloat()}getParticleAcceleration(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(lo).toFloat()}getParticleRadius(e,t){return this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(oo).toFloat()}getParticlePosition(e,t){let r=new E(0,0);return r.x=this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(Xe).getValueByString(kt).toFloat(),r.y=this._json.getRoot().getValueByString(F).getValueByIndex(e).getValueByString(be).getValueByIndex(t).getValueByString(Xe).getValueByString(Qt).toFloat(),r}_json};(function(e){e.CubismPhysicsJson=zs})(Xi||(Xi={}));Hi="X",Wi="Y",Yi="Angle",uo=5,Kt=100,zi=.001,ho=5,$t=class Js{static create(t,r){let i=new Js;return i.parse(t,r),i._physicsRig.gravity.y=0,i}static delete(t){t!=null&&(t.release(),t=null)}parse(t,r){this._physicsRig=new Ys;let i=new zs(t,r);this._physicsRig.gravity=i.getGravity(),this._physicsRig.wind=i.getWind(),this._physicsRig.subRigCount=i.getSubRigCount(),this._physicsRig.fps=i.getFps(),N(this._physicsRig.settings,this._physicsRig.subRigCount,Xs,!0),N(this._physicsRig.inputs,i.getTotalInputCount(),Hs,!0),N(this._physicsRig.outputs,i.getTotalOutputCount(),Ws,!0),N(this._physicsRig.particles,i.getVertexCount(),Gs,!0),this._currentRigOutputs.length=0,this._previousRigOutputs.length=0;let s=0,n=0,a=0,l=this._currentRigOutputs.length,o=this._previousRigOutputs.length;this._currentRigOutputs.length+=this._physicsRig.settings.length,this._previousRigOutputs.length+=this._physicsRig.settings.length;for(let u=0;u<this._physicsRig.settings.length;++u){this._physicsRig.settings[u].normalizationPosition.minimum=i.getNormalizationPositionMinimumValue(u),this._physicsRig.settings[u].normalizationPosition.maximum=i.getNormalizationPositionMaximumValue(u),this._physicsRig.settings[u].normalizationPosition.defalut=i.getNormalizationPositionDefaultValue(u),this._physicsRig.settings[u].normalizationAngle.minimum=i.getNormalizationAngleMinimumValue(u),this._physicsRig.settings[u].normalizationAngle.maximum=i.getNormalizationAngleMaximumValue(u),this._physicsRig.settings[u].normalizationAngle.defalut=i.getNormalizationAngleDefaultValue(u),this._physicsRig.settings[u].inputCount=i.getInputCount(u),this._physicsRig.settings[u].baseInputIndex=s;for(let h=0;h<this._physicsRig.settings[u].inputCount;++h)this._physicsRig.inputs[s+h].sourceParameterIndex=-1,this._physicsRig.inputs[s+h].weight=i.getInputWeight(u,h),this._physicsRig.inputs[s+h].reflect=i.getInputReflect(u,h),i.getInputType(u,h)==Hi?(this._physicsRig.inputs[s+h].type=0,this._physicsRig.inputs[s+h].getNormalizedParameterValue=go):i.getInputType(u,h)==Wi?(this._physicsRig.inputs[s+h].type=1,this._physicsRig.inputs[s+h].getNormalizedParameterValue=fo):i.getInputType(u,h)==Yi&&(this._physicsRig.inputs[s+h].type=2,this._physicsRig.inputs[s+h].getNormalizedParameterValue=Ao),this._physicsRig.inputs[s+h].source.targetType=0,this._physicsRig.inputs[s+h].source.id=i.getInputSourceId(u,h);s+=this._physicsRig.settings[u].inputCount,this._physicsRig.settings[u].outputCount=i.getOutputCount(u),this._physicsRig.settings[u].baseOutputIndex=n;let c=new Ji;N(c.outputs,this._physicsRig.settings[u].outputCount,null,!0);let g=new Ji;N(g.outputs,this._physicsRig.settings[u].outputCount,null,!0);for(let h=0;h<this._physicsRig.settings[u].outputCount;++h)c.outputs[h]=0,g.outputs[h]=0,this._physicsRig.outputs[n+h].destinationParameterIndex=-1,this._physicsRig.outputs[n+h].vertexIndex=i.getOutputVertexIndex(u,h),this._physicsRig.outputs[n+h].angleScale=i.getOutputAngleScale(u,h),this._physicsRig.outputs[n+h].weight=i.getOutputWeight(u,h),this._physicsRig.outputs[n+h].destination.targetType=0,this._physicsRig.outputs[n+h].destination.id=i.getOutputDestinationId(u,h),i.getOutputType(u,h)==Hi?(this._physicsRig.outputs[n+h].type=0,this._physicsRig.outputs[n+h].getValue=po,this._physicsRig.outputs[n+h].getScale=bo):i.getOutputType(u,h)==Wi?(this._physicsRig.outputs[n+h].type=1,this._physicsRig.outputs[n+h].getValue=mo,this._physicsRig.outputs[n+h].getScale=Bo):i.getOutputType(u,h)==Yi&&(this._physicsRig.outputs[n+h].type=2,this._physicsRig.outputs[n+h].getValue=_o,this._physicsRig.outputs[n+h].getScale=Io),this._physicsRig.outputs[n+h].reflect=i.getOutputReflect(u,h);this._currentRigOutputs[l++]=c,this._previousRigOutputs[o++]=g,n+=this._physicsRig.settings[u].outputCount,this._physicsRig.settings[u].particleCount=i.getParticleCount(u),this._physicsRig.settings[u].baseParticleIndex=a;for(let h=0;h<this._physicsRig.settings[u].particleCount;++h)this._physicsRig.particles[a+h].mobility=i.getParticleMobility(u,h),this._physicsRig.particles[a+h].delay=i.getParticleDelay(u,h),this._physicsRig.particles[a+h].acceleration=i.getParticleAcceleration(u,h),this._physicsRig.particles[a+h].radius=i.getParticleRadius(u,h),this._physicsRig.particles[a+h].position=i.getParticlePosition(u,h);a+=this._physicsRig.settings[u].particleCount}this._inputSlices.length=this._physicsRig.subRigCount,this._outputSlices.length=this._physicsRig.subRigCount,this._particleSlices.length=this._physicsRig.subRigCount;for(let u=0;u<this._physicsRig.subRigCount;++u){let c=this._physicsRig.settings[u];this._inputSlices[u]=this._physicsRig.inputs.slice(c.baseInputIndex,c.baseInputIndex+c.inputCount),this._outputSlices[u]=this._physicsRig.outputs.slice(c.baseOutputIndex,c.baseOutputIndex+c.outputCount),this._particleSlices[u]=this._physicsRig.particles.slice(c.baseParticleIndex,c.baseParticleIndex+c.particleCount)}this.initialize(),i.release(),i=void 0,i=null}stabilization(t){let r,i,s,n,a=new E,l,o,u,c,g=t.getModel().parameters.values,h=t.getModel().parameters.maximumValues,d=t.getModel().parameters.minimumValues,f=t.getModel().parameters.defaultValues;(this._parameterCaches?.length??0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),(this._parameterInputCaches?.length??0)<t.getParameterCount()&&(this._parameterInputCaches=new Float32Array(t.getParameterCount()));for(let p=0;p<t.getParameterCount();++p)this._parameterCaches[p]=g[p],this._parameterInputCaches[p]=g[p];for(let p=0;p<this._physicsRig.subRigCount;++p){r={angle:0},a.x=0,a.y=0,l=this._physicsRig.settings[p],o=this._inputSlices[p],u=this._outputSlices[p],c=this._particleSlices[p];for(let A=0;A<l.inputCount;++A)i=o[A].weight/Kt,o[A].sourceParameterIndex==-1&&(o[A].sourceParameterIndex=t.getParameterIndex(o[A].source.id)),o[A].getNormalizedParameterValue(a,r,g[o[A].sourceParameterIndex],d[o[A].sourceParameterIndex],h[o[A].sourceParameterIndex],f[o[A].sourceParameterIndex],l.normalizationPosition,l.normalizationAngle,o[A].reflect,i),this._parameterCaches[o[A].sourceParameterIndex]=g[o[A].sourceParameterIndex];s=x.degreesToRadian(-r.angle),a.x=a.x*x.cos(s)-a.y*x.sin(s),a.y=a.x*x.sin(s)+a.y*x.cos(s),Mo(c,l.particleCount,a,r.angle,this._options.wind,zi*l.normalizationPosition.maximum);for(let A=0;A<l.outputCount;++A){let _=u[A].vertexIndex;if(u[A].destinationParameterIndex==-1&&(u[A].destinationParameterIndex=t.getParameterIndex(u[A].destination.id)),_<1||_>=l.particleCount)continue;let b=new E;b=c[_].position.substract(c[_-1].position),n=u[A].getValue(b,c,_,u[A].reflect,this._options.gravity),this._currentRigOutputs[p].outputs[A]=n,this._previousRigOutputs[p].outputs[A]=n;let C=u[A].destinationParameterIndex;Nt(g,C,d[C],h[C],n,u[A]),this._parameterCaches[C]=g[C]}}}evaluate(t,r){let i,s,n,a,l=new E,o,u,c,g;if(0>=r)return;let h=t.getModel().parameters.values,d=t.getModel().parameters.maximumValues,f=t.getModel().parameters.minimumValues,p=t.getModel().parameters.defaultValues,A;if(this._currentRemainTime+=r,this._currentRemainTime>ho&&(this._currentRemainTime=0),(this._parameterCaches?.length??0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),(this._parameterInputCaches?.length??0)<t.getParameterCount()){this._parameterInputCaches=new Float32Array(t.getParameterCount());for(let b=0;b<t.getParameterCount();++b)this._parameterInputCaches[b]=h[b]}for(this._physicsRig.fps>0?A=1/this._physicsRig.fps:A=r;this._currentRemainTime>=A;){for(let C=0;C<this._physicsRig.subRigCount;++C){o=this._physicsRig.settings[C],c=this._outputSlices[C];for(let B=0;B<o.outputCount;++B)this._previousRigOutputs[C].outputs[B]=this._currentRigOutputs[C].outputs[B]}let b=A/this._currentRemainTime;for(let C=0;C<t.getParameterCount();++C)this._parameterCaches[C]=this._parameterInputCaches[C]*(1-b)+h[C]*b,this._parameterInputCaches[C]=this._parameterCaches[C];for(let C=0;C<this._physicsRig.subRigCount;++C){i={angle:0},l.x=0,l.y=0,o=this._physicsRig.settings[C],u=this._inputSlices[C],c=this._outputSlices[C],g=this._particleSlices[C];for(let B=0;B<o.inputCount;++B)s=u[B].weight/Kt,u[B].sourceParameterIndex==-1&&(u[B].sourceParameterIndex=t.getParameterIndex(u[B].source.id)),u[B].getNormalizedParameterValue(l,i,this._parameterCaches[u[B].sourceParameterIndex],f[u[B].sourceParameterIndex],d[u[B].sourceParameterIndex],p[u[B].sourceParameterIndex],o.normalizationPosition,o.normalizationAngle,u[B].reflect,s);n=x.degreesToRadian(-i.angle),l.x=l.x*x.cos(n)-l.y*x.sin(n),l.y=l.x*x.sin(n)+l.y*x.cos(n),So(g,o.particleCount,l,i.angle,this._options.wind,zi*o.normalizationPosition.maximum,A,uo);for(let B=0;B<o.outputCount;++B){let I=c[B].vertexIndex;if(c[B].destinationParameterIndex==-1&&(c[B].destinationParameterIndex=t.getParameterIndex(c[B].destination.id)),I<1||I>=o.particleCount)continue;let y=new E;y.x=g[I].position.x-g[I-1].position.x,y.y=g[I].position.y-g[I-1].position.y,a=c[B].getValue(y,g,I,c[B].reflect,this._options.gravity),this._currentRigOutputs[C].outputs[B]=a;let w=c[B].destinationParameterIndex;Nt(this._parameterCaches,w,f[w],d[w],a,c[B])}}this._currentRemainTime-=A}let _=this._currentRemainTime/A;this.interpolate(t,_)}interpolate(t,r){let i,s,n=t.getModel().parameters.values,a=t.getModel().parameters.maximumValues,l=t.getModel().parameters.minimumValues;for(let o=0;o<this._physicsRig.subRigCount;++o){s=this._physicsRig.settings[o],i=this._outputSlices[o];for(let u=0;u<s.outputCount;++u){if(i[u].destinationParameterIndex==-1)continue;let c=i[u].destinationParameterIndex;Nt(n,c,l[c],a[c],this._previousRigOutputs[o].outputs[u]*(1-r)+this._currentRigOutputs[o].outputs[u]*r,i[u])}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._physicsRig=null,this._options=new js,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=new Array,this._previousRigOutputs=new Array,this._inputSlices=new Array,this._outputSlices=new Array,this._particleSlices=new Array,this._currentRemainTime=0,this._parameterCaches=null,this._parameterInputCaches=null}release(){this._inputSlices.length=0,this._outputSlices.length=0,this._particleSlices.length=0,this._physicsRig=void 0,this._physicsRig=null}initialize(){let t,r,i;for(let s=0;s<this._physicsRig.subRigCount;++s){r=this._physicsRig.settings[s],t=this._particleSlices[s],t[0].initialPosition=new E(0,0),t[0].lastPosition=new E(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new E(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new E(0,0),t[0].force=new E(0,0);for(let n=1;n<r.particleCount;++n)i=new E(0,0),i.y=t[n].radius,t[n].initialPosition=new E(t[n-1].initialPosition.x+i.x,t[n-1].initialPosition.y+i.y),t[n].position=new E(t[n].initialPosition.x,t[n].initialPosition.y),t[n].lastPosition=new E(t[n].initialPosition.x,t[n].initialPosition.y),t[n].lastGravity=new E(0,-1),t[n].lastGravity.y*=-1,t[n].velocity=new E(0,0),t[n].force=new E(0,0)}}_physicsRig;_options;_currentRigOutputs;_previousRigOutputs;_inputSlices;_outputSlices;_particleSlices;_currentRemainTime;_parameterCaches;_parameterInputCaches},js=class{constructor(){this.gravity=new E(0,0),this.wind=new E(0,0)}gravity;wind},Ji=class{constructor(){this.outputs=new Array(0)}outputs};(function(e){e.CubismPhysics=$t,e.Options=js})(ji||(ji={}));Gt=4,wo=36,xo=32,Eo=class{constructor(e){this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=new Array,this._clippingContextListForDraw=new Array,this._clippingContextListForOffscreen=new Array,this._tmpBoundsOnModel=new gt,this._tmpMatrix=new ae,this._tmpMatrixForMask=new ae,this._tmpMatrixForDraw=new ae,this._clearedMaskBufferFlags=new Array,this._clippingContexttConstructor=e,this._channelColors=[new R(1,0,0,0),new R(0,1,0,0),new R(0,0,1,0),new R(0,0,0,1)]}release(){for(let e=0;e<this._clippingContextListForMask.length;e++)this._clippingContextListForMask[e]&&(this._clippingContextListForMask[e].release(),this._clippingContextListForMask[e]=void 0),this._clippingContextListForMask[e]=null;this._clippingContextListForMask=null;for(let e=0;e<this._clippingContextListForDraw.length;e++)this._clippingContextListForDraw[e]=null;this._clippingContextListForDraw=null;for(let e=0;e<this._channelColors.length;e++)this._channelColors[e]=null;this._channelColors=null,this._clearedMaskBufferFlags!=null&&(this._clearedMaskBufferFlags.length=0),this._clearedMaskBufferFlags=null}initializeForDrawable(e,t){t%1!=0&&(k("The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer."),t=~~t),t<1&&k("The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1."),this._renderTextureCount=t<1?1:t,this._clearedMaskBufferFlags=new Array(this._renderTextureCount),this._clippingContextListForDraw.length=e.getDrawableCount();for(let r=0;r<e.getDrawableCount();r++){if(e.getDrawableMaskCounts()[r]<=0){this._clippingContextListForDraw[r]=null;continue}let i=this.findSameClip(e.getDrawableMasks()[r],e.getDrawableMaskCounts()[r]);i==null&&(i=new this._clippingContexttConstructor(this,e.getDrawableMasks()[r],e.getDrawableMaskCounts()[r]),this._clippingContextListForMask.push(i)),i.addClippedDrawable(r),this._clippingContextListForDraw[r]=i}}initializeForOffscreen(e,t){this._renderTextureCount=t,this._clearedMaskBufferFlags.length=this._renderTextureCount;for(let r=0;r<this._renderTextureCount;++r)this._clearedMaskBufferFlags[r]=!1;this._clippingContextListForOffscreen.length=e.getOffscreenCount();for(let r=0;r<e.getOffscreenCount();++r){if(e.getOffscreenMaskCounts()[r]<=0){this._clippingContextListForOffscreen.push(null);continue}let i=this.findSameClip(e.getOffscreenMasks()[r],e.getOffscreenMaskCounts()[r]);i==null&&(i=new this._clippingContexttConstructor(this,e.getOffscreenMasks()[r],e.getOffscreenMaskCounts()[r]),this._clippingContextListForMask.push(i)),i.addClippedOffscreen(r),this._clippingContextListForOffscreen[r]=i}}findSameClip(e,t){for(let r=0;r<this._clippingContextListForMask.length;r++){let i=this._clippingContextListForMask[r],s=i._clippingIdCount;if(s!=t)continue;let n=0;for(let a=0;a<s;a++){let l=i._clippingIdList[a];for(let o=0;o<s;o++)if(e[o]==l){n++;break}}if(n==s)return i}return null}setupMatrixForHighPrecision(e,t){let r=0;for(let i=0;i<this._clippingContextListForMask.length;i++){let s=this._clippingContextListForMask[i];this.calcClippedDrawableTotalBounds(e,s),s._isUsing&&r++}if(r>0){if(this.setupLayoutBounds(0),this._clearedMaskBufferFlags.length!=this._renderTextureCount){this._clearedMaskBufferFlags.length=this._renderTextureCount;for(let i=0;i<this._renderTextureCount;i++)this._clearedMaskBufferFlags[i]=!1}else for(let i=0;i<this._renderTextureCount;i++)this._clearedMaskBufferFlags[i]=!1;for(let i=0;i<this._clippingContextListForMask.length;i++){let s=this._clippingContextListForMask[i],n=s._allClippedDrawRect,a=s._layoutBounds,l=.05,o=0,u=0,c=e.getPixelsPerUnit(),g=s.getClippingManager().getClippingMaskBufferSize(),h=a.width*g,d=a.height*g;this._tmpBoundsOnModel.setRect(n),this._tmpBoundsOnModel.width*c>h?(this._tmpBoundsOnModel.expand(n.width*l,0),o=a.width/this._tmpBoundsOnModel.width):o=c/h,this._tmpBoundsOnModel.height*c>d?(this._tmpBoundsOnModel.expand(0,n.height*l),u=a.height/this._tmpBoundsOnModel.height):u=c/d,this.createMatrixForMask(t,a,o,u),s._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),s._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray())}}}setupMatrixForOffscreenHighPrecision(e,t,r){let i=0;for(let s=0;s<this._clippingContextListForMask.length;s++){let n=this._clippingContextListForMask[s];this.calcClippedOffscreenTotalBounds(e,n),n._isUsing&&i++}if(!(i<=0)){if(this.setupLayoutBounds(0),this._clearedMaskBufferFlags.length!=this._renderTextureCount){this._clearedMaskBufferFlags.length=this._renderTextureCount;for(let s=0;s<this._renderTextureCount;++s)this._clearedMaskBufferFlags[s]=!1}else for(let s=0;s<this._renderTextureCount;++s)this._clearedMaskBufferFlags[s]=!1;for(let s=0;s<this._clippingContextListForMask.length;s++){let n=this._clippingContextListForMask[s],a=n._allClippedDrawRect,l=n._layoutBounds,o=.05,u=0,c=0,g=e.getPixelsPerUnit(),h=n.getClippingManager().getClippingMaskBufferSize(),d=l.width*h,f=l.height*h;this._tmpBoundsOnModel.setRect(a),this._tmpBoundsOnModel.width*g>d?(this._tmpBoundsOnModel.expand(a.width*o,0),u=l.width/this._tmpBoundsOnModel.width):u=g/d,this._tmpBoundsOnModel.height*g>f?(this._tmpBoundsOnModel.expand(0,a.height*o),c=l.height/this._tmpBoundsOnModel.height):c=g/f,this.createMatrixForMask(t,l,u,c),n._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),n._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray());let p=r.getInvert();n._matrixForDraw.multiplyByMatrix(p)}}}calcClippedOffscreenTotalBounds(e,t){let r=Number.MAX_VALUE,i=Number.MAX_VALUE,s=-Number.MAX_VALUE,n=-Number.MAX_VALUE,a=t._clippedOffscreenIndexList.length,l=new Array;for(let u=0;u<a;u++){let c=t._clippedOffscreenIndexList[u];this.getOffscreenChildDrawableIndexList(e,c,l)}let o=l.length;for(let u=0;u<o;u++){let c=e.getDrawableVertexCount(l[u]),g=e.getDrawableVertices(l[u]),h=Number.MAX_VALUE,d=Number.MAX_VALUE,f=-Number.MAX_VALUE,p=-Number.MAX_VALUE,A=c*te.vertexStep;for(let _=te.vertexOffset;_<A;_+=te.vertexStep){let b=g[_],C=g[_+1];b<h&&(h=b),b>f&&(f=b),C<d&&(d=C),C>p&&(p=C)}h!=Number.MAX_VALUE&&(h<r&&(r=h),d<i&&(i=d),f>s&&(s=f),p>n&&(n=p))}if(r==Number.MAX_VALUE)t._allClippedDrawRect.x=0,t._allClippedDrawRect.y=0,t._allClippedDrawRect.width=0,t._allClippedDrawRect.height=0,t._isUsing=!1;else{t._isUsing=!0;let u=s-r,c=n-i;t._allClippedDrawRect.x=r,t._allClippedDrawRect.y=i,t._allClippedDrawRect.width=u,t._allClippedDrawRect.height=c}}getOffscreenChildDrawableIndexList(e,t,r){let i=e.getOffscreenOwnerIndices()[t];this.getPartChildDrawableIndexList(e,i,r)}getPartChildDrawableIndexList(e,t,r){let i=e.getPartsHierarchy()[t].childDrawObjects;r.push(...i.drawableIndices);for(let s=0;s<i.offscreenIndices.length;++s)this.getOffscreenChildDrawableIndexList(e,i.offscreenIndices[s],r)}createMatrixForMask(e,t,r,i){this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(t.x,t.y),this._tmpMatrix.scaleRelative(r,i),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(t.x,t.y*(e?-1:1)),this._tmpMatrix.scaleRelative(r,i*(e?-1:1)),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray())}setupLayoutBounds(e){let t=this._renderTextureCount<=1?wo:xo*this._renderTextureCount;if(e<=0||e>t){e>t&&T(`not supported mask count : {0}
|
|
19
|
+
[Details] render texture count : {1}, mask count : {2}`,e-t,this._renderTextureCount,e);for(let o=0;o<this._clippingContextListForMask.length;o++){let u=this._clippingContextListForMask[o];u._layoutChannelIndex=0,u._layoutBounds.x=0,u._layoutBounds.y=0,u._layoutBounds.width=1,u._layoutBounds.height=1,u._bufferIndex=0}return}let r=this._renderTextureCount<=1?9:8,i=e/this._renderTextureCount,s=e%this._renderTextureCount;i=Math.ceil(i);let n=i/Gt,a=i%Gt;n=~~n;let l=0;for(let o=0;o<this._renderTextureCount;o++)for(let u=0;u<Gt;u++){let c=n+(u<a?1:0),g=a+(n<1?-1:0);if(u==g&&s>0&&(c-=o<s?0:1),c!=0)if(c==1){let h=this._clippingContextListForMask[l++];h._layoutChannelIndex=u,h._layoutBounds.x=0,h._layoutBounds.y=0,h._layoutBounds.width=1,h._layoutBounds.height=1,h._bufferIndex=o}else if(c==2)for(let h=0;h<c;h++){let d=h%2;d=~~d;let f=this._clippingContextListForMask[l++];f._layoutChannelIndex=u,f._layoutBounds.x=d*.5,f._layoutBounds.y=0,f._layoutBounds.width=.5,f._layoutBounds.height=1,f._bufferIndex=o}else if(c<=4)for(let h=0;h<c;h++){let d=h%2,f=h/2;d=~~d,f=~~f;let p=this._clippingContextListForMask[l++];p._layoutChannelIndex=u,p._layoutBounds.x=d*.5,p._layoutBounds.y=f*.5,p._layoutBounds.width=.5,p._layoutBounds.height=.5,p._bufferIndex=o}else if(c<=r)for(let h=0;h<c;h++){let d=h%3,f=h/3;d=~~d,f=~~f;let p=this._clippingContextListForMask[l++];p._layoutChannelIndex=u,p._layoutBounds.x=d/3,p._layoutBounds.y=f/3,p._layoutBounds.width=1/3,p._layoutBounds.height=1/3,p._bufferIndex=o}else{T(`not supported mask count : {0}
|
|
20
|
+
[Details] render texture count : {1}, mask count : {2}`,e-t,this._renderTextureCount,e);for(let h=0;h<c;h++){let d=this._clippingContextListForMask[l++];d._layoutChannelIndex=0,d._layoutBounds.x=0,d._layoutBounds.y=0,d._layoutBounds.width=1,d._layoutBounds.height=1,d._bufferIndex=0}}}}calcClippedDrawableTotalBounds(e,t){let r=Number.MAX_VALUE,i=Number.MAX_VALUE,s=Number.MIN_VALUE,n=Number.MIN_VALUE,a=t._clippedDrawableIndexList.length;for(let l=0;l<a;l++){let o=t._clippedDrawableIndexList[l],u=e.getDrawableVertexCount(o),c=e.getDrawableVertices(o),g=Number.MAX_VALUE,h=Number.MAX_VALUE,d=-Number.MAX_VALUE,f=-Number.MAX_VALUE,p=u*te.vertexStep;for(let A=te.vertexOffset;A<p;A+=te.vertexStep){let _=c[A],b=c[A+1];_<g&&(g=_),_>d&&(d=_),b<h&&(h=b),b>f&&(f=b)}if(g!=Number.MAX_VALUE)if(g<r&&(r=g),h<i&&(i=h),d>s&&(s=d),f>n&&(n=f),r==Number.MAX_VALUE)t._allClippedDrawRect.x=0,t._allClippedDrawRect.y=0,t._allClippedDrawRect.width=0,t._allClippedDrawRect.height=0,t._isUsing=!1;else{t._isUsing=!0;let A=s-r,_=n-i;t._allClippedDrawRect.x=r,t._allClippedDrawRect.y=i,t._allClippedDrawRect.width=A,t._allClippedDrawRect.height=_}}}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingContextListForOffscreen(){return this._clippingContextListForOffscreen}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}getChannelFlagAsColor(e){return this._channelColors[e]}setClippingMaskBufferSize(e){this._clippingMaskBufferSize=e}_clearedMaskBufferFlags;_channelColors;_clippingContextListForMask;_clippingContextListForDraw;_clippingContextListForOffscreen;_clippingMaskBufferSize;_renderTextureCount;_tmpMatrix;_tmpMatrixForMask;_tmpMatrixForDraw;_tmpBoundsOnModel;_clippingContexttConstructor},pe=class{static copyBuffer(e,t,r,i=null,s=!1){if(t==null||r==null)return;if(!(e instanceof WebGL2RenderingContext))throw new Error("WebGL2RenderingContext is required for buffer copy.");let n=s?i:e.getParameter(e.FRAMEBUFFER_BINDING);e.bindFramebuffer(e.READ_FRAMEBUFFER,t.getRenderTexture()),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,r.getRenderTexture()),e.blitFramebuffer(0,0,t.getBufferWidth(),t.getBufferHeight(),0,0,r.getBufferWidth(),r.getBufferHeight(),e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.FRAMEBUFFER,n)}beginDraw(e=null,t=!1){if(this._renderTexture==null){console.error("_renderTexture is null");return}e==null&&!t?this._oldFbo=this._gl.getParameter(this._gl.FRAMEBUFFER_BINDING):this._oldFbo=e,this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,this._renderTexture)}endDraw(){this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,this._oldFbo)}clear(e,t,r,i){this._gl.clearColor(e,t,r,i),this._gl.clear(this._gl.COLOR_BUFFER_BIT)}createRenderTarget(e,t,r,i){this.destroyRenderTarget(),this._colorBuffer=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this._colorBuffer),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,r,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.bindTexture(e.TEXTURE_2D,null);let s=e.createFramebuffer();return s==null?(T("Failed to create framebuffer"),!1):(e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this._colorBuffer,0),e.checkFramebufferStatus(e.FRAMEBUFFER)!==e.FRAMEBUFFER_COMPLETE?(T("Framebuffer is not complete"),e.bindFramebuffer(e.FRAMEBUFFER,i),e.deleteFramebuffer(s),this.destroyRenderTarget(),!1):(this._renderTexture=s,this._bufferWidth=t,this._bufferHeight=r,this._gl=e,!0))}destroyRenderTarget(){this._colorBuffer&&(this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.deleteTexture(this._colorBuffer),this._colorBuffer=null),this._renderTexture&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null),this._gl.deleteFramebuffer(this._renderTexture),this._renderTexture=null)}getGL(){return this._gl}getRenderTexture(){return this._renderTexture}getColorBuffer(){return this._colorBuffer}getBufferWidth(){return this._bufferWidth}getBufferHeight(){return this._bufferHeight}isValid(){return this._renderTexture!=null}getOldFBO(){return this._oldFbo}constructor(){this._gl=null,this._colorBuffer=null,this._renderTexture=null,this._bufferWidth=0,this._bufferHeight=0,this._oldFbo=null}_gl;_colorBuffer;_renderTexture;_bufferWidth;_bufferHeight;_oldFbo};(function(e){e.CubismOffscreenSurface_WebGL=pe})(qi||(qi={}));vo=class{constructor(e=null,t=null,r=!1){this.colorBuffer=e,this.renderTexture=t,this.inUse=r}clear(){this.colorBuffer=null,this.renderTexture=null,this.inUse=!1}getColorBuffer(){return this.colorBuffer}getRenderTexture(){return this.renderTexture}colorBuffer;renderTexture;inUse},Po=class{constructor(e){this.gl=e,this.offscreenRenderTargetContainers=new Array,this.previousActiveRenderTextureMaxCount=0,this.currentActiveRenderTextureCount=0,this.hasResetThisFrame=!1,this.width=0,this.height=0}release(){if(this.offscreenRenderTargetContainers!=null){for(let e=0;e<this.offscreenRenderTargetContainers.length;++e){let t=this.offscreenRenderTargetContainers[e];this.gl.deleteTexture(t.colorBuffer),this.gl.deleteFramebuffer(t.renderTexture)}this.offscreenRenderTargetContainers.length=0,this.offscreenRenderTargetContainers=null}}gl;offscreenRenderTargetContainers;previousActiveRenderTextureMaxCount;currentActiveRenderTextureCount;hasResetThisFrame;width;height},cr=class er{constructor(){this._contextManagers=new Map}release(){if(this._contextManagers!=null){for(let t of this._contextManagers.values())t.release();this._contextManagers.clear(),this._contextManagers=null}er._instance=null}static getInstance(){return this._instance==null&&(this._instance=new er),this._instance}getContextManager(t){return this._contextManagers.has(t)||this._contextManagers.set(t,new Po(t)),this._contextManagers.get(t)}removeContext(t){this._contextManagers.has(t)&&(this._contextManagers.get(t).release(),this._contextManagers.delete(t))}initialize(t,r,i){let s=this.getContextManager(t);if(s.offscreenRenderTargetContainers!=null){for(let n=0;n<s.offscreenRenderTargetContainers.length;++n){let a=s.offscreenRenderTargetContainers[n];s.gl.deleteTexture(a.colorBuffer),s.gl.deleteFramebuffer(a.renderTexture),a.clear()}s.offscreenRenderTargetContainers.length=0}else s.offscreenRenderTargetContainers=new Array;s.width=r,s.height=i,s.previousActiveRenderTextureMaxCount=0,s.currentActiveRenderTextureCount=0,s.hasResetThisFrame=!1}beginFrameProcess(t){let r=this.getContextManager(t);r.hasResetThisFrame||(r.previousActiveRenderTextureMaxCount=0,r.hasResetThisFrame=!0)}endFrameProcess(t){let r=this.getContextManager(t);r.hasResetThisFrame=!1}getContainerSize(t){let r=this.getContextManager(t);return r.offscreenRenderTargetContainers==null?0:r.offscreenRenderTargetContainers.length}getOffscreenRenderTargetContainers(t,r,i,s){let n=this.getContextManager(t);(n.width!=r||n.height!=i||n.offscreenRenderTargetContainers==null)&&this.initialize(t,r,i),this.updateRenderTargetContainerCount(t);let a=this.getUnusedOffscreenRenderTargetContainer(t);return a??this.createOffscreenRenderTargetContainer(t,r,i,s)}getUsingRenderTextureState(t,r){let i=this.getContextManager(t);for(let s=0;s<i.offscreenRenderTargetContainers.length;++s)if(i.offscreenRenderTargetContainers[s].renderTexture==r)return i.offscreenRenderTargetContainers[s].inUse;return!0}startUsingRenderTexture(t,r){let i=this.getContextManager(t);for(let s=0;s<i.offscreenRenderTargetContainers.length;++s)if(i.offscreenRenderTargetContainers[s].renderTexture==r){i.offscreenRenderTargetContainers[s].inUse=!0,this.updateRenderTargetContainerCount(t);break}}stopUsingRenderTexture(t,r){let i=this.getContextManager(t);for(let s=0;s<i.offscreenRenderTargetContainers.length;++s)if(i.offscreenRenderTargetContainers[s].renderTexture==r){i.offscreenRenderTargetContainers[s].inUse=!1,i.currentActiveRenderTextureCount--,i.currentActiveRenderTextureCount<0&&(i.currentActiveRenderTextureCount=0);break}}stopUsingAllRenderTextures(t){let r=this.getContextManager(t);for(let i=0;i<r.offscreenRenderTargetContainers.length;++i)r.offscreenRenderTargetContainers[i].inUse=!1;r.currentActiveRenderTextureCount=0}releaseStaleRenderTextures(t){let r=this.getContextManager(t),i=r.offscreenRenderTargetContainers.length;if(r.hasResetThisFrame||i===0)return;let s=0,n=r.previousActiveRenderTextureMaxCount;for(let a=i;r.previousActiveRenderTextureMaxCount<a;--a){let l=a-1;if(r.offscreenRenderTargetContainers[l].inUse){let u=!1;for(;s<r.previousActiveRenderTextureMaxCount;++s)if(!r.offscreenRenderTargetContainers[s].inUse){let c=r.offscreenRenderTargetContainers[s];r.offscreenRenderTargetContainers[s]=r.offscreenRenderTargetContainers[l],r.offscreenRenderTargetContainers[s].inUse=!0,r.offscreenRenderTargetContainers[l]=c,r.offscreenRenderTargetContainers[l].inUse=!1,u=!0;break}if(!u){n=a;break}}let o=r.offscreenRenderTargetContainers[l];r.gl.bindTexture(r.gl.TEXTURE_2D,null),r.gl.deleteTexture(o.colorBuffer),r.gl.bindFramebuffer(r.gl.FRAMEBUFFER,null),r.gl.deleteFramebuffer(o.renderTexture),o.clear()}N(r.offscreenRenderTargetContainers,n)}getPreviousActiveRenderTextureCount(t){return this.getContextManager(t).previousActiveRenderTextureMaxCount}getCurrentActiveRenderTextureCount(t){return this.getContextManager(t).currentActiveRenderTextureCount}updateRenderTargetContainerCount(t){let r=this.getContextManager(t);++r.currentActiveRenderTextureCount,r.previousActiveRenderTextureMaxCount=r.currentActiveRenderTextureCount>r.previousActiveRenderTextureMaxCount?r.currentActiveRenderTextureCount:r.previousActiveRenderTextureMaxCount}getUnusedOffscreenRenderTargetContainer(t){let r=this.getContextManager(t);for(let i=0;i<r.offscreenRenderTargetContainers.length;++i){let s=r.offscreenRenderTargetContainers[i];if(s.inUse==!1)return s.inUse=!0,s}return null}createOffscreenRenderTargetContainer(t,r,i,s){let n=new pe;if(!n.createRenderTarget(t,r,i,s))return T("Failed to create offscreen render texture."),null;let a=new vo(n.getColorBuffer(),n.getRenderTexture(),!0);return this.getContextManager(t).offscreenRenderTargetContainers.push(a),a}static _instance;_contextManagers},Zi=class extends pe{initializeOffscreenManager(e,t,r){this._gl=e,this._webGLOffscreenManager=cr.getInstance(),this._webGLOffscreenManager.getContainerSize(e)===0&&this._webGLOffscreenManager.initialize(e,t,r)}setOffscreenRenderTarget(e,t,r,i){this._webGLOffscreenManager==null&&this.initializeOffscreenManager(e,t,r);let s=this._webGLOffscreenManager.getOffscreenRenderTargetContainers(e,t,r,i);if(s==null){T("Failed to acquire offscreen render texture container.");return}this._colorBuffer=s.getColorBuffer(),this._renderTexture=s.getRenderTexture(),this._bufferWidth=t,this._bufferHeight=r,this._gl=e,this._renderTexture==null&&(this._renderTexture=i,T("Failed to create offscreen render texture."))}getUsingRenderTextureState(){return this._webGLOffscreenManager==null||this._gl==null?!0:this._webGLOffscreenManager.getUsingRenderTextureState(this._gl,this._renderTexture)}startUsingRenderTexture(){this._webGLOffscreenManager==null||this._gl==null||this._webGLOffscreenManager.startUsingRenderTexture(this._gl,this._renderTexture)}stopUsingRenderTexture(){this._webGLOffscreenManager==null||this._gl==null||this._webGLOffscreenManager.stopUsingRenderTexture(this._gl,this._renderTexture)}setOffscreenIndex(e){this._offscreenIndex=e}getOffscreenIndex(){return this._offscreenIndex}setOldOffscreen(e){this._oldOffscreen=e}getOldOffscreen(){return this._oldOffscreen}setParentPartOffscreen(e){this._parentOffscreenRenderTarget=e}getParentPartOffscreen(){return this._parentOffscreenRenderTarget}constructor(){super(),this._offscreenIndex=-1,this._parentOffscreenRenderTarget=null,this._oldOffscreen=null,this._webGLOffscreenManager=null}release(){this._webGLOffscreenManager!=null&&this._gl!=null&&this._renderTexture!=null&&this._webGLOffscreenManager.stopUsingRenderTexture(this._gl,this._renderTexture),this._colorBuffer&&this._gl&&(this._gl.deleteTexture(this._colorBuffer),this._colorBuffer=null),this._renderTexture&&this._gl&&(this._gl.deleteFramebuffer(this._renderTexture),this._renderTexture=null),this._webGLOffscreenManager!=null&&(this._webGLOffscreenManager=null),this._oldOffscreen=null,this._parentOffscreenRenderTarget=null}_offscreenIndex;_parentOffscreenRenderTarget;_oldOffscreen;_webGLOffscreenManager},Ro="vertshadersrc.vert",Do="vertshadersrcmasked.vert",Lo="vertshadersrcsetupmask.vert",To="fragshadersrcsetupmask.frag",Fo="fragshadersrcpremultipliedalpha.frag",Oo="fragshadersrcmaskpremultipliedalpha.frag",Vo="fragshadersrcmaskinvertedpremultipliedalpha.frag",ko="vertshadersrccopy.vert",Qo="fragshadersrccopy.frag",Uo="fragshadersrccolorblend.frag",No="fragshadersrcalphablend.frag",Go="vertshadersrcblend.vert",Xo="fragshadersrcpremultipliedalphablend.frag",Ho="ColorBlend_",Wo="AlphaBlend_",Ki=new Float32Array([-1,-1,1,-1,-1,1,1,1]),Yo=new Float32Array([0,0,1,0,0,1,1,1]),zo=new Float32Array([0,1,1,1,0,0,1,0]),qs=class{async loadShader(e,t){let r=e.slice(e.lastIndexOf("/")+1),i=this._shaderSources?.[r];if(i!==void 0){if(i.trim().length==0)throw new Error(`Failed to load shader ${e}: empty source`);return i}let s=await fetch(e,{signal:t});if(!s.ok)throw new Error(`Failed to load shader ${e}: HTTP ${s.status}`);let n=await s.text();if(n.trim().length==0)throw new Error(`Failed to load shader ${e}: empty source`);return n}async loadShaders(e){let t=this._shaderPath??this._defaultShaderPath,r=[{path:t+Ro,prop:"_vertShaderSrc"},{path:t+Do,prop:"_vertShaderSrcMasked"},{path:t+Lo,prop:"_vertShaderSrcSetupMask"},{path:t+To,prop:"_fragShaderSrcSetupMask"},{path:t+Fo,prop:"_fragShaderSrcPremultipliedAlpha"},{path:t+Oo,prop:"_fragShaderSrcMaskPremultipliedAlpha"},{path:t+Vo,prop:"_fragShaderSrcMaskInvertedPremultipliedAlpha"},{path:t+ko,prop:"_vertShaderSrcCopy"},{path:t+Qo,prop:"_fragShaderSrcCopy"},{path:t+Uo,prop:"_fragShaderSrcColorBlend"},{path:t+No,prop:"_fragShaderSrcAlphaBlend"},{path:t+Go,prop:"_vertShaderSrcBlend"},{path:t+Xo,prop:"_fragShaderSrcBlend"}];(await Promise.all(r.map(async i=>({prop:i.prop,data:await this.loadShader(i.path,e)})))).forEach(i=>{this[i.prop]=i.data})}constructor(){this._shaderSets=new Array,this._isShaderLoading=!1,this._isShaderLoaded=!1,this._blendShadersRegistered=!1,this._currentProgram=null,this._shaderLoadPromise=null,this._colorBlendMap=new Map,this._colorBlendValues=new Array;let e=Object.keys(Q),t=Object.keys(Q).map(s=>Q[s]);for(let s=0;s<e.length;s++){let n=e[s];if(n.includes(Ho)){let a=n.slice(11),l=parseInt(t[s].toString());this._colorBlendMap.set(l,a),this._colorBlendValues.push(l)}}this._alphaBlendMap=new Map,this._alphaBlendValues=new Array;let r=Object.keys(Tt),i=Object.keys(Tt).map(s=>Tt[s]);for(let s=0;s<r.length;s++){let n=r[s];if(n.includes(Wo)){let a=n.slice(11),l=parseInt(i[s].toString());this._alphaBlendMap.set(l,a),this._alphaBlendValues.push(l)}}this._blendShaderSetMap=new Map,this._shaderCount=11+(this._colorBlendValues.length-3)*(this._alphaBlendValues.length-1)*3,this._defaultShaderPath="../../Framework/Shaders/WebGL/",this._shaderPath=this._defaultShaderPath}release(){this.releaseShaderProgram()}setProgram(e){this._currentProgram!==e&&(this._currentProgram=e,this.gl.useProgram(e))}setupShaderProgramForDrawable(e,t,r){if(e.isPremultipliedAlpha()||T("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders(void 0,t.isBlendModeEnabled()),this._isShaderLoaded==!1){k("Shader program is not initialized.");return}let i,s,n,a,l=e.getClippingContextBufferForDrawable()!=null,o=t.getDrawableInvertedMaskBit(r),u=l?o?2:1:0,c,g=!0;if(t.isBlendModeEnabled()){let B=t.getDrawableColorBlend(r),I=t.getDrawableAlphaBlend(r);if(B==-1||I==-1||B==Q.ColorBlend_Normal&&I==0)c=this._shaderSets[1+u],i=this.gl.ONE,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ONE,a=this.gl.ONE_MINUS_SRC_ALPHA;else switch(B){case Q.ColorBlend_AddCompatible:c=this._shaderSets[4+u],i=this.gl.ONE,s=this.gl.ONE,n=this.gl.ZERO,a=this.gl.ONE;break;case Q.ColorBlend_MultiplyCompatible:c=this._shaderSets[7+u],i=this.gl.DST_COLOR,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ZERO,a=this.gl.ONE;break;default:{let y=e._currentOffscreen!=null?e._currentOffscreen:e.getModelRenderTarget(0);pe.copyBuffer(this.gl,y,e.getModelRenderTarget(1));let w=this._blendShaderSetMap.get(this._colorBlendMap.get(B)+this._alphaBlendMap.get(I));if(w===void 0)throw new Error("Blend shader programs are not registered for this context.");c=this._shaderSets[w+u],i=this.gl.ONE,s=this.gl.ZERO,n=this.gl.ONE,a=this.gl.ZERO,g=!1}break}}else switch(t.getDrawableBlendMode(r)){case 0:default:c=this._shaderSets[1+u],i=this.gl.ONE,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ONE,a=this.gl.ONE_MINUS_SRC_ALPHA;break;case 1:c=this._shaderSets[4+u],i=this.gl.ONE,s=this.gl.ONE,n=this.gl.ZERO,a=this.gl.ONE;break;case 2:c=this._shaderSets[7+u],i=this.gl.DST_COLOR,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ZERO,a=this.gl.ONE;break}this.setProgram(c.shaderProgram),e._bufferData.vertex==null&&(e._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.vertex);let h=t.getDrawableVertices(r);if(this.gl.bufferData(this.gl.ARRAY_BUFFER,h,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(c.attributePositionLocation),this.gl.vertexAttribPointer(c.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),e.bindDrawableUvBuffer(r),this.gl.enableVertexAttribArray(c.attributeTexCoordLocation),this.gl.vertexAttribPointer(c.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),l){this.gl.activeTexture(this.gl.TEXTURE1);let B=e.getDrawableMaskBuffer(e.getClippingContextBufferForDrawable()._bufferIndex).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,B),this.gl.uniform1i(c.samplerTexture1Location,1),this.gl.uniformMatrix4fv(c.uniformClipMatrixLocation,!1,e.getClippingContextBufferForDrawable()._matrixForDraw.getArray());let I=e.getClippingContextBufferForDrawable()._layoutChannelIndex,y=e.getClippingContextBufferForDrawable().getClippingManager().getChannelFlagAsColor(I);this.gl.uniform4f(c.uniformChannelFlagLocation,y.r,y.g,y.b,y.a),t.isBlendModeEnabled()&&this.gl.uniform1f(c.uniformInvertMaskFlagLocation,o?1:0)}let d=t.getDrawableTextureIndex(r),f=e.getBindedTextures().get(d);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,f),this.gl.uniform1i(c.samplerTexture0Location,0);let p=e.getMvpMatrix();this.gl.uniformMatrix4fv(c.uniformMatrixLocation,!1,p.getArray());let A=null;if(t.isBlendModeEnabled()){let B=t.getDrawableOpacity(r);A=new R(B,B,B,B)}else A=e.getModelColorWithOpacity(t.getDrawableOpacity(r));let _=t.getOverrideMultiplyAndScreenColor(),b=_.getDrawableMultiplyColor(r),C=_.getDrawableScreenColor(r);if(this.gl.uniform4f(c.uniformBaseColorLocation,A.r,A.g,A.b,A.a),this.gl.uniform4f(c.uniformMultiplyColorLocation,b.r,b.g,b.b,b.a),this.gl.uniform4f(c.uniformScreenColorLocation,C.r,C.g,C.b,C.a),t.isBlendModeEnabled()&&(this.gl.activeTexture(this.gl.TEXTURE2),!g)){let B=e.getModelRenderTarget(1).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,B),this.gl.uniform1i(c.samplerFrameBufferTextureLocation,2)}e.bindDrawableIndexBuffer(r),this.gl.blendFuncSeparate(i,s,n,a)}setupShaderProgramForOffscreen(e,t,r){if(e.isPremultipliedAlpha()||T("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders(void 0,t.isBlendModeEnabled()),this._isShaderLoaded==!1){k("Shader program is not initialized.");return}let i,s,n,a,l=r.getOffscreenIndex(),o=e.getClippingContextBufferForOffscreen()!=null,u=t.getOffscreenInvertedMask(l),c=o?u?2:1:0,g,h=!0,d=t.getOffscreenColorBlend(l),f=t.getOffscreenAlphaBlend(l);if(d==-1||f==-1||d==Q.ColorBlend_Normal&&f==0)g=this._shaderSets[1+c],i=this.gl.ONE,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ONE,a=this.gl.ONE_MINUS_SRC_ALPHA;else switch(d){case Q.ColorBlend_AddCompatible:g=this._shaderSets[4+c],i=this.gl.ONE,s=this.gl.ONE,n=this.gl.ZERO,a=this.gl.ONE;break;case Q.ColorBlend_MultiplyCompatible:g=this._shaderSets[7+c],i=this.gl.DST_COLOR,s=this.gl.ONE_MINUS_SRC_ALPHA,n=this.gl.ZERO,a=this.gl.ONE;break;default:{let y=r.getOldOffscreen()!=null?r.getOldOffscreen():e.getModelRenderTarget(0);pe.copyBuffer(this.gl,y,e.getModelRenderTarget(1));let w=this._blendShaderSetMap.get(this._colorBlendMap.get(d)+this._alphaBlendMap.get(f));if(w===void 0)throw new Error("Blend shader programs are not registered for this context.");g=this._shaderSets[w+c],i=this.gl.ONE,s=this.gl.ZERO,n=this.gl.ONE,a=this.gl.ZERO,h=!1}break}this.setProgram(g.shaderProgram),pe.copyBuffer(this.gl,r,e.getModelRenderTarget(2)),this.gl.activeTexture(this.gl.TEXTURE0);let p=e.getModelRenderTarget(2).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,p),this.gl.uniform1i(g.samplerTexture0Location,0);let A=new ae;A.loadIdentity(),this.gl.uniformMatrix4fv(g.uniformMatrixLocation,!1,A.getArray());let _=t.getOffscreenOpacity(l),b=new R(_,_,_,_),C=t.getOverrideMultiplyAndScreenColor(),B=C.getOffscreenMultiplyColor(l),I=C.getOffscreenScreenColor(l);if(this.gl.uniform4f(g.uniformBaseColorLocation,b.r,b.g,b.b,b.a),this.gl.uniform4f(g.uniformMultiplyColorLocation,B.r,B.g,B.b,B.a),this.gl.uniform4f(g.uniformScreenColorLocation,I.r,I.g,I.b,I.a),this.gl.activeTexture(this.gl.TEXTURE2),!h){let y=e.getModelRenderTarget(1).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,y),this.gl.uniform1i(g.samplerFrameBufferTextureLocation,2)}if(o){this.gl.activeTexture(this.gl.TEXTURE1);let y=e.getOffscreenMaskBuffer(e.getClippingContextBufferForOffscreen()._bufferIndex).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,y),this.gl.uniform1i(g.samplerTexture1Location,1),this.gl.uniformMatrix4fv(g.uniformClipMatrixLocation,!1,e.getClippingContextBufferForOffscreen()._matrixForDraw.getArray());let w=e.getClippingContextBufferForOffscreen()._layoutChannelIndex,L=e.getClippingContextBufferForOffscreen().getClippingManager().getChannelFlagAsColor(w);this.gl.uniform4f(g.uniformChannelFlagLocation,L.r,L.g,L.b,L.a),t.isBlendModeEnabled()&&this.gl.uniform1f(g.uniformInvertMaskFlagLocation,u?1:0)}e._bufferData.vertex||(e._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,Ki,this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(g.attributePositionLocation),this.gl.vertexAttribPointer(g.attributePositionLocation,2,this.gl.FLOAT,!1,Float32Array.BYTES_PER_ELEMENT*2,0),e._bufferData.uv||(e._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,zo,this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(g.attributeTexCoordLocation),this.gl.vertexAttribPointer(g.attributeTexCoordLocation,2,this.gl.FLOAT,!1,Float32Array.BYTES_PER_ELEMENT*2,0),this.gl.blendFuncSeparate(i,s,n,a)}setupShaderProgramForMask(e,t,r){if(e.isPremultipliedAlpha()||T("NoPremultipliedAlpha is not allowed"),this._shaderSets.length==0&&this.generateShaders(void 0,t.isBlendModeEnabled()),this._isShaderLoaded==!1){k("Shader program is not initialized.");return}let i=this._shaderSets[0];this.setProgram(i.shaderProgram),e._bufferData.vertex==null&&(e._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.vertex);let s=t.getDrawableVertices(r);this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(i.attributePositionLocation),this.gl.vertexAttribPointer(i.attributePositionLocation,2,this.gl.FLOAT,!1,0,0);let n=t.getDrawableTextureIndex(r),a=e.getBindedTextures().get(n);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,a),this.gl.uniform1i(i.samplerTexture0Location,0),e.bindDrawableUvBuffer(r),this.gl.enableVertexAttribArray(i.attributeTexCoordLocation),this.gl.vertexAttribPointer(i.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0);let l=e.getClippingContextBufferForMask()._layoutChannelIndex,o=e.getClippingContextBufferForMask().getClippingManager().getChannelFlagAsColor(l);this.gl.uniform4f(i.uniformChannelFlagLocation,o.r,o.g,o.b,o.a),this.gl.uniformMatrix4fv(i.uniformClipMatrixLocation,!1,e.getClippingContextBufferForMask()._matrixForMask.getArray());let u=e.getClippingContextBufferForMask()._layoutBounds;this.gl.uniform4f(i.uniformBaseColorLocation,u.x*2-1,u.y*2-1,u.getRight()*2-1,u.getBottom()*2-1);let c=this.gl.ZERO,g=this.gl.ONE_MINUS_SRC_COLOR,h=this.gl.ZERO,d=this.gl.ONE_MINUS_SRC_ALPHA;e.bindDrawableIndexBuffer(r),this.gl.blendFuncSeparate(c,g,h,d)}setupShaderProgramForOffscreenRenderTarget(e){if(this._shaderSets.length==0&&this.generateShaders(void 0,e.getModel().isBlendModeEnabled()),this._isShaderLoaded==!1){k("Shader program is not initialized.");return}let t=e.getModelColor();t.r*=t.a,t.g*=t.a,t.b*=t.a,this.copyTexture(e,t)}copyTexture(e,t){let r=this.gl.ONE,i=this.gl.ONE_MINUS_SRC_ALPHA,s=this.gl.ONE,n=this.gl.ONE_MINUS_SRC_ALPHA,a=this._shaderSets[10];this.setProgram(a.shaderProgram),this.gl.uniform4f(a.uniformBaseColorLocation,t.r,t.g,t.b,t.a),this.gl.activeTexture(this.gl.TEXTURE0);let l=e.getModelRenderTarget(0).getColorBuffer();this.gl.bindTexture(this.gl.TEXTURE_2D,l),this.gl.uniform1i(a.samplerTexture0Location,0),e._bufferData.vertex||(e._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.vertex),this.gl.bufferData(this.gl.ARRAY_BUFFER,Ki,this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(a.attributePositionLocation),this.gl.vertexAttribPointer(a.attributePositionLocation,2,this.gl.FLOAT,!1,Float32Array.BYTES_PER_ELEMENT*2,0),e._bufferData.uv||(e._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.uv),this.gl.bufferData(this.gl.ARRAY_BUFFER,Yo,this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(a.attributeTexCoordLocation),this.gl.vertexAttribPointer(a.attributeTexCoordLocation,2,this.gl.FLOAT,!1,Float32Array.BYTES_PER_ELEMENT*2,0),this.gl.blendFuncSeparate(r,i,s,n)}releaseShaderProgram(){let e=new Set;for(let t=0;t<this._shaderSets.length;t++){let r=this._shaderSets[t];r&&(r.shaderProgram&&e.add(r.shaderProgram),r.shaderProgram=null,this._shaderSets[t]=void 0,this._shaderSets[t]=null)}for(let t of e)this.gl.deleteProgram(t);this._shaderSets.length=0,this._blendShaderSetMap.clear(),this._blendShadersRegistered=!1,this._currentProgram=null}generateShaders(e,t=!0){if(this._isShaderLoaded)return t&&!this._blendShadersRegistered&&(this.registerBlendShader(),this._blendShadersRegistered=!0),Promise.resolve();if(this._isShaderLoading)return this._shaderLoadPromise.then(()=>this.generateShaders(e,t));this._isShaderLoading=!0,this._isShaderLoaded=!1,this._shaderSets.length=this._shaderCount;for(let r=0;r<this._shaderCount;r++)this._shaderSets[r]=new Ks;return this._shaderLoadPromise=this.loadShaders(e).then(()=>{this.registerShader(),t&&this.registerBlendShader(),this._blendShadersRegistered=t,this._isShaderLoading=!1,this._isShaderLoaded=!0}).catch(r=>{throw this._isShaderLoading=!1,this._isShaderLoaded=!1,this.releaseShaderProgram(),r}),this._shaderLoadPromise}registerShader(){let e=this._vertShaderSrc,t=this._vertShaderSrcMasked,r=this._vertShaderSrcSetupMask,i=this._fragShaderSrcSetupMask,s=this._fragShaderSrcPremultipliedAlpha,n=this._fragShaderSrcMaskPremultipliedAlpha,a=this._fragShaderSrcMaskInvertedPremultipliedAlpha;this._shaderSets[0].shaderProgram=this.loadShaderProgram(r,i),this._shaderSets[1].shaderProgram=this.loadShaderProgram(e,s),this._shaderSets[2].shaderProgram=this.loadShaderProgram(t,n),this._shaderSets[3].shaderProgram=this.loadShaderProgram(t,a),this._shaderSets[4].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[5].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[6].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[7].shaderProgram=this._shaderSets[1].shaderProgram,this._shaderSets[8].shaderProgram=this._shaderSets[2].shaderProgram,this._shaderSets[9].shaderProgram=this._shaderSets[3].shaderProgram,this._shaderSets[0].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_position"),this._shaderSets[0].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[0].shaderProgram,"a_texCoord"),this._shaderSets[0].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"s_texture0"),this._shaderSets[0].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_clipMatrix"),this._shaderSets[0].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_channelFlag"),this._shaderSets[0].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[0].shaderProgram,"u_baseColor"),this._shaderSets[1].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_position"),this._shaderSets[1].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[1].shaderProgram,"a_texCoord"),this._shaderSets[1].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"s_texture0"),this._shaderSets[1].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_matrix"),this._shaderSets[1].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_baseColor"),this._shaderSets[1].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_multiplyColor"),this._shaderSets[1].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[1].shaderProgram,"u_screenColor"),this._shaderSets[2].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_position"),this._shaderSets[2].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[2].shaderProgram,"a_texCoord"),this._shaderSets[2].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture0"),this._shaderSets[2].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"s_texture1"),this._shaderSets[2].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_matrix"),this._shaderSets[2].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_clipMatrix"),this._shaderSets[2].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_channelFlag"),this._shaderSets[2].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_baseColor"),this._shaderSets[2].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_multiplyColor"),this._shaderSets[2].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[2].shaderProgram,"u_screenColor"),this._shaderSets[3].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_position"),this._shaderSets[3].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[3].shaderProgram,"a_texCoord"),this._shaderSets[3].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture0"),this._shaderSets[3].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"s_texture1"),this._shaderSets[3].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_matrix"),this._shaderSets[3].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_clipMatrix"),this._shaderSets[3].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_channelFlag"),this._shaderSets[3].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_baseColor"),this._shaderSets[3].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_multiplyColor"),this._shaderSets[3].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[3].shaderProgram,"u_screenColor"),this._shaderSets[4].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_position"),this._shaderSets[4].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[4].shaderProgram,"a_texCoord"),this._shaderSets[4].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"s_texture0"),this._shaderSets[4].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_matrix"),this._shaderSets[4].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_baseColor"),this._shaderSets[4].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_multiplyColor"),this._shaderSets[4].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[4].shaderProgram,"u_screenColor"),this._shaderSets[5].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_position"),this._shaderSets[5].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[5].shaderProgram,"a_texCoord"),this._shaderSets[5].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture0"),this._shaderSets[5].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"s_texture1"),this._shaderSets[5].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_matrix"),this._shaderSets[5].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_clipMatrix"),this._shaderSets[5].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_channelFlag"),this._shaderSets[5].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_baseColor"),this._shaderSets[5].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_multiplyColor"),this._shaderSets[5].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[5].shaderProgram,"u_screenColor"),this._shaderSets[6].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_position"),this._shaderSets[6].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[6].shaderProgram,"a_texCoord"),this._shaderSets[6].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture0"),this._shaderSets[6].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"s_texture1"),this._shaderSets[6].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_matrix"),this._shaderSets[6].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_clipMatrix"),this._shaderSets[6].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_channelFlag"),this._shaderSets[6].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_baseColor"),this._shaderSets[6].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_multiplyColor"),this._shaderSets[6].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[6].shaderProgram,"u_screenColor"),this._shaderSets[7].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_position"),this._shaderSets[7].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[7].shaderProgram,"a_texCoord"),this._shaderSets[7].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"s_texture0"),this._shaderSets[7].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_matrix"),this._shaderSets[7].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_baseColor"),this._shaderSets[7].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_multiplyColor"),this._shaderSets[7].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[7].shaderProgram,"u_screenColor"),this._shaderSets[8].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_position"),this._shaderSets[8].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[8].shaderProgram,"a_texCoord"),this._shaderSets[8].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture0"),this._shaderSets[8].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"s_texture1"),this._shaderSets[8].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_matrix"),this._shaderSets[8].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_clipMatrix"),this._shaderSets[8].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_channelFlag"),this._shaderSets[8].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_baseColor"),this._shaderSets[8].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_multiplyColor"),this._shaderSets[8].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[8].shaderProgram,"u_screenColor"),this._shaderSets[9].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_position"),this._shaderSets[9].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[9].shaderProgram,"a_texCoord"),this._shaderSets[9].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture0"),this._shaderSets[9].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"s_texture1"),this._shaderSets[9].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_matrix"),this._shaderSets[9].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_clipMatrix"),this._shaderSets[9].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_channelFlag"),this._shaderSets[9].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_baseColor"),this._shaderSets[9].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_multiplyColor"),this._shaderSets[9].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[9].shaderProgram,"u_screenColor")}registerBlendShader(){let e=this._vertShaderSrcCopy,t=this._fragShaderSrcCopy,r=this._shaderSets[10];r.shaderProgram=this.loadShaderProgram(e,t),r.attributeTexCoordLocation=this.gl.getAttribLocation(r.shaderProgram,"a_texCoord"),r.attributePositionLocation=this.gl.getAttribLocation(r.shaderProgram,"a_position"),r.uniformBaseColorLocation=this.gl.getUniformLocation(r.shaderProgram,"u_baseColor");let i=11;for(let s=0;s<this._colorBlendValues.length;s++){if(this._colorBlendValues[s]==-1||this._colorBlendValues[s]==Q.ColorBlend_AddCompatible||this._colorBlendValues[s]==Q.ColorBlend_MultiplyCompatible)continue;let n=this._colorBlendValues[s],a=`#define COLOR_BLEND_${this._colorBlendMap.get(n).toUpperCase()}
|
|
21
|
+
`;for(let l=0;l<this._alphaBlendValues.length;l++){if(this._alphaBlendValues[l]==-1||this._colorBlendValues[s]==Q.ColorBlend_Normal&&this._alphaBlendValues[l]==0)continue;let o=this._alphaBlendValues[l],u=`#define ALPHA_BLEND_${this._alphaBlendMap.get(o).toUpperCase()}
|
|
22
22
|
`;this.generateBlendShader(a,u,i),this._blendShaderSetMap.set(this._colorBlendMap.get(this._colorBlendValues[s])+this._alphaBlendMap.get(this._alphaBlendValues[l]),i),i+=3}}}generateBlendShader(e,t,r){for(let i=0;i<3;i++){let s="",n=`precision mediump float;
|
|
23
23
|
`,a=r+i;if(n+=e,n+=t,n+=this._fragShaderSrcColorBlend,n+=this._fragShaderSrcAlphaBlend,i==1||i==2){let l=`#define CLIPPING_MASK
|
|
24
|
-
`;s+=l,n+=l}s+=this._vertShaderSrcBlend,n+=this._fragShaderSrcBlend,this._shaderSets[a].shaderProgram=this.loadShaderProgram(s,n),this._shaderSets[a].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[a].shaderProgram,"a_position"),this._shaderSets[a].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[a].shaderProgram,"a_texCoord"),this._shaderSets[a].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"s_texture0"),this._shaderSets[a].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_matrix"),this._shaderSets[a].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_baseColor"),this._shaderSets[a].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_multiplyColor"),this._shaderSets[a].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_screenColor"),this._shaderSets[a].samplerFrameBufferTextureLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"s_blendTexture"),(i==1||i==2)&&(this._shaderSets[a].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"s_texture1"),this._shaderSets[a].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_clipMatrix"),this._shaderSets[a].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_channelFlag"),this._shaderSets[a].uniformInvertMaskFlagLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_invertClippingMask"))}}loadShaderProgram(e,t){let r=this.gl.createProgram();if(!r)throw new Error("WebGL failed to create a shader program");let i,s;try{i=this.compileShaderSource(this.gl.VERTEX_SHADER,e),s=this.compileShaderSource(this.gl.FRAGMENT_SHADER,t)}catch(n){throw i&&this.gl.deleteShader(i),this.gl.deleteProgram(r),n}if(this.gl.attachShader(r,i),this.gl.attachShader(r,s),this.gl.linkProgram(r),!this.gl.getProgramParameter(r,this.gl.LINK_STATUS)){let n=this.gl.getProgramInfoLog(r);throw
|
|
25
|
-
Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING),this._lastElementArrayBufferBinding=this.gl.getParameter(this.gl.ELEMENT_ARRAY_BUFFER_BINDING),this._lastProgram=this.gl.getParameter(this.gl.CURRENT_PROGRAM),this._lastActiveTexture=this.gl.getParameter(this.gl.ACTIVE_TEXTURE),this.gl.activeTexture(this.gl.TEXTURE1),this._lastTexture1Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this.gl.activeTexture(this.gl.TEXTURE0),this._lastTexture0Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._lastVertexAttribArrayEnabled[0]=this.gl.getVertexAttrib(0,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[1]=this.gl.getVertexAttrib(1,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[2]=this.gl.getVertexAttrib(2,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[3]=this.gl.getVertexAttrib(3,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastScissorTest=this.gl.isEnabled(this.gl.SCISSOR_TEST),this._lastStencilTest=this.gl.isEnabled(this.gl.STENCIL_TEST),this._lastDepthTest=this.gl.isEnabled(this.gl.DEPTH_TEST),this._lastCullFace=this.gl.isEnabled(this.gl.CULL_FACE),this._lastBlend=this.gl.isEnabled(this.gl.BLEND),this._lastFrontFace=this.gl.getParameter(this.gl.FRONT_FACE),this._lastColorMask=this.gl.getParameter(this.gl.COLOR_WRITEMASK),this._lastBlending[0]=this.gl.getParameter(this.gl.BLEND_SRC_RGB),this._lastBlending[1]=this.gl.getParameter(this.gl.BLEND_DST_RGB),this._lastBlending[2]=this.gl.getParameter(this.gl.BLEND_SRC_ALPHA),this._lastBlending[3]=this.gl.getParameter(this.gl.BLEND_DST_ALPHA)}restore(){if(this.gl==null){
|
|
26
|
-
Please call 'CubimRenderer_WebGL.startUp' function.`);return}this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])}setGl(e){this.gl=e}constructor(){this._lastVertexAttribArrayEnabled=new Array(4),this._lastColorMask=new Array(4),this._lastBlending=new Array(4)}_lastArrayBufferBinding;_lastElementArrayBufferBinding;_lastProgram;_lastActiveTexture;_lastTexture0Binding2D;_lastTexture1Binding2D;_lastVertexAttribArrayEnabled;_lastScissorTest;_lastBlend;_lastStencilTest;_lastDepthTest;_lastCullFace;_lastFrontFace;_lastColorMask;_lastBlending;gl},dr=class extends mt{initialize(e,t=1){e.isUsingMasking()&&(this._drawableClippingManager=new dt,this._drawableClippingManager.initializeForDrawable(e,t)),e.isUsingMaskingForOffscreen()&&(this._offscreenClippingManager=new dt,this._offscreenClippingManager.initializeForOffscreen(e,t)),U(this._sortedObjectsIndexList,e.getDrawableCount()+(e.getOffscreenCount?e.getOffscreenCount():0),0,!0),U(this._sortedObjectsTypeList,e.getDrawableCount()+(e.getOffscreenCount?e.getOffscreenCount():0),0,!0),super.initialize(e)}setupParentOffscreens(e,t){let r;for(let i=0;i<t;++i){r=null;let s=e.getOffscreenOwnerIndices()[i],n=e.getPartParentPartIndices()[s];for(;n!=-1;){for(let a=0;a<t;++a)if(e.getOffscreenOwnerIndices()[this._offscreenList[a].getOffscreenIndex()]==n){r=this._offscreenList[a];break}if(r!=null)break;n=e.getPartParentPartIndices()[n]}this._offscreenList[i].setParentPartOffscreen(r)}}bindTexture(e,t){this._textures.set(e,t)}getBindedTextures(){return this._textures}setClippingMaskBufferSize(e){if(!this._model.isUsingMasking())return;let t=this._drawableClippingManager.getRenderTextureCount();this._drawableClippingManager.release(),this._drawableClippingManager=void 0,this._drawableClippingManager=null,this._drawableClippingManager=new dt,this._drawableClippingManager.setClippingMaskBufferSize(e),this._drawableClippingManager.initializeForDrawable(this.getModel(),t)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._drawableClippingManager.getClippingMaskBufferSize():ot}getModelRenderTarget(e){return this._modelRenderTargets[e]}getRenderTextureCount(){return this._model.isUsingMasking()?this._drawableClippingManager.getRenderTextureCount():ot}constructor(e,t){super(e,t),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new jo,this._textures=new Map,this._sortedObjectsIndexList=new Array,this._sortedObjectsTypeList=new Array,this._bufferData={vertex:WebGLBuffer=null,uv:WebGLBuffer=null,index:WebGLBuffer=null},this._drawableIndexBuffers=new Array,this._drawableUvBuffers=new Array,this._renderTargetIndexBuffer=null,this._modelRenderTargets=new Array,this._drawableMasks=new Array,this._currentFbo=null,this._drawableClippingManager=null,this._offscreenClippingManager=null,this._offscreenMasks=new Array,this._offscreenList=new Array}release(){if(this._drawableClippingManager&&(this._drawableClippingManager.release(),this._drawableClippingManager=void 0,this._drawableClippingManager=null),this.gl!=null){this.gl.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,this.gl.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,this.gl.deleteBuffer(this._bufferData.index),this._bufferData.index=null,this._bufferData=null;for(let e=0;e<this._drawableIndexBuffers.length;e++)this._drawableIndexBuffers[e]!=null&&this.gl.deleteBuffer(this._drawableIndexBuffers[e]);this._drawableIndexBuffers.length=0,this._drawableIndexBuffers=null;for(let e=0;e<this._drawableUvBuffers.length;e++)this._drawableUvBuffers[e]!=null&&this.gl.deleteBuffer(this._drawableUvBuffers[e]);this._drawableUvBuffers.length=0,this._drawableUvBuffers=null,this._renderTargetIndexBuffer!=null&&(this.gl.deleteBuffer(this._renderTargetIndexBuffer),this._renderTargetIndexBuffer=null),this._textures=null;for(let e=0;e<this._modelRenderTargets.length;e++)this._modelRenderTargets[e]!=null&&this._modelRenderTargets[e].isValid()&&this._modelRenderTargets[e].destroyRenderTarget();this._modelRenderTargets.length=0,this._modelRenderTargets=null;for(let e=0;e<this._drawableMasks.length;e++)this._drawableMasks[e]!=null&&this._drawableMasks[e].isValid()&&this._drawableMasks[e].destroyRenderTarget();this._drawableMasks.length=0,this._drawableMasks=null;for(let e=0;e<this._offscreenMasks.length;e++)this._offscreenMasks[e]!=null&&this._offscreenMasks[e].isValid()&&this._offscreenMasks[e].destroyRenderTarget();this._offscreenMasks.length=0,this._offscreenMasks=null;for(let e=0;e<this._offscreenList.length;e++)this._offscreenList[e]!=null&&this._offscreenList[e].isValid()&&this._offscreenList[e].destroyRenderTarget();this._offscreenList.length=0,this._offscreenList=null,this._offscreenClippingManager=null,this._drawableClippingManager=null,this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=null,this._sortedObjectsIndexList=null,this._sortedObjectsTypeList=null,this._currentFbo=null,this._model=null,this.gl=null}}bindDrawableIndexBuffer(e){let t=this._drawableIndexBuffers[e];t==null?(t=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this._model.getDrawableVertexIndices(e),this.gl.STATIC_DRAW),this._drawableIndexBuffers[e]=t):this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t)}bindDrawableUvBuffer(e){let t=this._drawableUvBuffers[e];t==null?(t=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t),this.gl.bufferData(this.gl.ARRAY_BUFFER,this._model.getDrawableVertexUvs(e),this.gl.STATIC_DRAW),this._drawableUvBuffers[e]=t):this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t)}bindRenderTargetIndexBuffer(){this._renderTargetIndexBuffer==null?(this._renderTargetIndexBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._renderTargetIndexBuffer),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,Xt,this.gl.STATIC_DRAW)):this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._renderTargetIndexBuffer)}loadShaders(e=null,t,r){if(this.gl==null)return Promise.reject(new Error("'gl' is null. WebGLRenderingContext is required. Please call CubismRenderer_WebGL.startUp()."));let i=K.getInstance().getShader(this.gl);return(i._shaderSets.length==0||!i._isShaderLoaded)&&(e!=null&&i.setShaderPath(e),i.setShaderSources(r)),i.generateShaders(t,this._model!=null?this._model.isBlendModeEnabled():!0)}doDrawModel(e=null){this.beforeDrawModelRenderTarget();let t=this._renderStateFbo,r=this._renderStateViewport;if(this._drawableClippingManager!=null){this.preDraw();for(let i=0;i<this._drawableClippingManager.getRenderTextureCount();++i)(this._drawableMasks[i].getBufferWidth()!=this._drawableClippingManager.getClippingMaskBufferSize()||this._drawableMasks[i].getBufferHeight()!=this._drawableClippingManager.getClippingMaskBufferSize())&&this._drawableMasks[i].createRenderTarget(this.gl,this._drawableClippingManager.getClippingMaskBufferSize(),this._drawableClippingManager.getClippingMaskBufferSize(),t);this.isUsingHighPrecisionMask()?this._drawableClippingManager.setupMatrixForHighPrecision(this.getModel(),!1):this._drawableClippingManager.setupClippingContext(this.getModel(),this,t,r,0,this._renderStateKnown)}if(this._offscreenClippingManager!=null){this.preDraw();for(let i=0;i<this._offscreenClippingManager.getRenderTextureCount();++i)(this._offscreenMasks[i].getBufferWidth()!=this._offscreenClippingManager.getClippingMaskBufferSize()||this._offscreenMasks[i].getBufferHeight()!=this._offscreenClippingManager.getClippingMaskBufferSize())&&this._offscreenMasks[i].createRenderTarget(this.gl,this._offscreenClippingManager.getClippingMaskBufferSize(),this._offscreenClippingManager.getClippingMaskBufferSize(),t);this.isUsingHighPrecisionMask()?this._offscreenClippingManager.setupMatrixForOffscreenHighPrecision(this.getModel(),!1,this.getMvpMatrix()):this._offscreenClippingManager.setupClippingContext(this.getModel(),this,t,r,1,this._renderStateKnown)}this.preDraw(),this.drawObjectLoop(t),this.afterDrawModelRenderTarget()}drawObjectLoop(e){let t=this.getModel(),r=t.getDrawableCount(),i=r+t.getOffscreenCount(),s=t.getRenderOrders();this._currentOffscreen=null,this._currentFbo=e,this._modelRootFbo=e;for(let n=0;n<i;++n){let a=s[n];n<r?(this._sortedObjectsIndexList[a]=n,this._sortedObjectsTypeList[a]=0):n<i&&(this._sortedObjectsIndexList[a]=n-r,this._sortedObjectsTypeList[a]=1)}for(let n=0;n<i;++n){let a=this._sortedObjectsIndexList[n],l=this._sortedObjectsTypeList[n];this.renderObject(a,l)}for(;this._currentOffscreen!=null;)this.submitDrawToParentOffscreen(this._currentOffscreen.getOffscreenIndex(),1)}renderObject(e,t){switch(t){case 0:this.drawDrawable(e,this._modelRootFbo);break;case 1:this.addOffscreen(e);break;default:D("Unknown object type: "+t);break}}drawDrawable(e,t){if(!this.getModel().getDrawableDynamicFlagIsVisible(e))return;this.submitDrawToParentOffscreen(e,0);let r=this._drawableClippingManager!=null?this._drawableClippingManager.getClippingContextListForDraw()[e]:null;if(r!=null&&this.isUsingHighPrecisionMask()){r._isUsing&&(this.gl.viewport(0,0,this._drawableClippingManager.getClippingMaskBufferSize(),this._drawableClippingManager.getClippingMaskBufferSize()),this.preDraw(),this.getDrawableMaskBuffer(r._bufferIndex).beginDraw(this._currentFbo),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{let i=r._clippingIdCount;for(let s=0;s<i;s++){let n=r._clippingIdList[s];this._model.getDrawableDynamicFlagVertexPositionsDidChange(n)&&(this.setIsCulling(this._model.getDrawableCulling(n)!=!1),this.setClippingContextBufferForMask(r),this.drawMeshWebGL(this._model,n))}this.getDrawableMaskBuffer(r._bufferIndex).endDraw(),this.setClippingContextBufferForMask(null),this.gl.viewport(0,0,this._modelRenderTargetWidth,this._modelRenderTargetHeight),this.preDraw()}}this.setClippingContextBufferForDrawable(r),this.setIsCulling(this.getModel().getDrawableCulling(e)),this.drawMeshWebGL(this._model,e)}drawMeshWebGL(e,t){if(this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW),this.isGeneratingMask()?K.getInstance().getShader(this.gl).setupShaderProgramForMask(this,e,t):K.getInstance().getShader(this.gl).setupShaderProgramForDrawable(this,e,t),!!K.getInstance().getShader(this.gl)._isShaderLoaded){{let r=e.getDrawableVertexIndexCount(t);this.gl.drawElements(this.gl.TRIANGLES,r,this.gl.UNSIGNED_SHORT,0)}this.setClippingContextBufferForDrawable(null),this.setClippingContextBufferForMask(null)}}submitDrawToParentOffscreen(e,t){if(this._currentOffscreen==null||e==ot)return;let r=this.getModel().getOffscreenOwnerIndices()[this._currentOffscreen.getOffscreenIndex()];if(r==ot)return;let i=-1;switch(t){case 0:i=this.getModel().getDrawableParentPartIndex(e);break;case 1:i=this.getModel().getPartParentPartIndices()[this.getModel().getOffscreenOwnerIndices()[e]];break;default:return}for(;i!=-1;){if(i==r)return;i=this.getModel().getPartParentPartIndices()[i]}this.drawOffscreen(this._currentOffscreen),this.submitDrawToParentOffscreen(e,t)}addOffscreen(e){if(this._currentOffscreen!=null&&this._currentOffscreen.getOffscreenIndex()!=e){let s=!1,n=this.getModel().getOffscreenOwnerIndices()[e],a=this.getModel().getPartParentPartIndices()[n],l=this._currentOffscreen.getOffscreenIndex(),o=this.getModel().getOffscreenOwnerIndices()[l];for(;a!=-1;){if(a==o){s=!0;break}a=this.getModel().getPartParentPartIndices()[a]}s||this.submitDrawToParentOffscreen(e,1)}let t=this._offscreenList[e];t.getRenderTexture()==null||t.getBufferWidth()!=this._modelRenderTargetWidth||t.getBufferHeight()!=this._modelRenderTargetHeight||t.getUsingRenderTextureState()?t.setOffscreenRenderTarget(this.gl,this._modelRenderTargetWidth,this._modelRenderTargetHeight,this._currentFbo):t.startUsingRenderTexture();let r=t.getParentPartOffscreen();t.setOldOffscreen(r);let i=null;r!=null&&(i=r.getRenderTexture()),i==null&&(i=this._modelRootFbo),t.beginDraw(i),this.gl.viewport(0,0,this._modelRenderTargetWidth,this._modelRenderTargetHeight),t.clear(0,0,0,0),this._currentOffscreen=t,this._currentFbo=t.getRenderTexture()}drawOffscreen(e){let t=e.getOffscreenIndex(),r=this._offscreenClippingManager!=null?this._offscreenClippingManager.getClippingContextListForOffscreen()[t]:null;if(r!=null&&this.isUsingHighPrecisionMask()){r._isUsing&&(this.gl.viewport(0,0,this._offscreenClippingManager.getClippingMaskBufferSize(),this._offscreenClippingManager.getClippingMaskBufferSize()),this.preDraw(),this.getOffscreenMaskBuffer(r._bufferIndex).beginDraw(this._currentFbo),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{let i=r._clippingIdCount;for(let s=0;s<i;s++){let n=r._clippingIdList[s];this.getModel().getDrawableDynamicFlagVertexPositionsDidChange(n)&&(this.setIsCulling(this.getModel().getDrawableCulling(n)!=!1),this.setClippingContextBufferForMask(r),this.drawMeshWebGL(this.getModel(),n))}}this.getOffscreenMaskBuffer(r._bufferIndex).endDraw(),this.setClippingContextBufferForMask(null),this.gl.viewport(0,0,this._modelRenderTargetWidth,this._modelRenderTargetHeight),this.preDraw()}this.setClippingContextBufferForOffscreen(r),this.setIsCulling(this._model.getOffscreenCulling(t)!=!1),this.drawOffscreenWebGL(this.getModel(),e)}drawOffscreenWebGL(e,t){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW),K.getInstance().getShader(this.gl).setupShaderProgramForOffscreen(this,e,t),t.endDraw(),this._currentOffscreen=this._currentOffscreen.getOldOffscreen(),this._currentFbo=t.getOldFBO(),this._currentFbo==null&&(this._currentOffscreen=this._modelRenderTargets[0],this._currentFbo=this._modelRenderTargets[0].getRenderTexture(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentFbo)),this.bindRenderTargetIndexBuffer(),this.gl.drawElements(this.gl.TRIANGLES,Xt.length,this.gl.UNSIGNED_SHORT,0),t.stopUsingRenderTexture(),this.setClippingContextBufferForMask(null),this.setClippingContextBufferForOffscreen(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}beforeDrawModelRenderTarget(){if(this._modelRenderTargets.length!=0){for(let e=0;e<this._modelRenderTargets.length;++e)(this._modelRenderTargets[e].getBufferWidth()!=this._modelRenderTargetWidth||this._modelRenderTargets[e].getBufferHeight()!=this._modelRenderTargetHeight)&&this._modelRenderTargets[e].createRenderTarget(this.gl,this._modelRenderTargetWidth,this._modelRenderTargetHeight,this._currentFbo);this._modelRenderTargets[0].beginDraw(),this._modelRenderTargets[0].clear(0,0,0,0)}}afterDrawModelRenderTarget(){this._modelRenderTargets.length!=0&&(this._modelRenderTargets[0].endDraw(),K.getInstance().getShader(this.gl).setupShaderProgramForOffscreenRenderTarget(this),K.getInstance().getShader(this.gl)._isShaderLoaded&&(this.bindRenderTargetIndexBuffer(),this.gl.drawElements(this.gl.TRIANGLES,Xt.length,this.gl.UNSIGNED_SHORT,0)))}getOffscreenMaskBuffer(e){return this._offscreenMasks[e]}static doStaticRelease(){K.deleteInstance()}setRenderState(e,t){this._renderStateFbo=e,this._renderStateKnown=!0,this._renderStateViewport[0]=t[0],this._renderStateViewport[1]=t[1],this._renderStateViewport[2]=t[2],this._renderStateViewport[3]=t[3],this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e),this.gl.viewport(t[0],t[1],t[2],t[3]),(this._modelRenderTargetWidth!=t[2]||this._modelRenderTargetHeight!=t[3])&&(this._modelRenderTargetWidth=t[2],this._modelRenderTargetHeight=t[3])}preDraw(){if(this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(let e=0;e<this._textures.size;++e)this.gl.bindTexture(this.gl.TEXTURE_2D,this._textures.get(e)),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}getDrawableMaskBuffer(e){return this._drawableMasks[e]}setClippingContextBufferForMask(e){this._clippingContextBufferForMask=e}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDrawable(e){this._clippingContextBufferForDraw=e}getClippingContextBufferForDrawable(){return this._clippingContextBufferForDraw}setClippingContextBufferForOffscreen(e){this._clippingContextBufferForOffscreen=e}getClippingContextBufferForOffscreen(){return this._clippingContextBufferForOffscreen}isGeneratingMask(){return this.getClippingContextBufferForMask()!=null}startUp(e){if(this.gl=e,this._drawableClippingManager&&this._drawableClippingManager.setGL(e),this._offscreenClippingManager&&this._offscreenClippingManager.setGL(e),K.getInstance().setGlContext(e),this._rendererProfile.setGl(e),this._extension=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),this._model.isUsingMasking()){this._drawableMasks.length=this._drawableClippingManager.getRenderTextureCount();for(let t=0;t<this._drawableMasks.length;++t){let r=new pe;r.createRenderTarget(this.gl,this._drawableClippingManager.getClippingMaskBufferSize(),this._drawableClippingManager.getClippingMaskBufferSize(),this._currentFbo),this._drawableMasks[t]=r}}if(this._model.isBlendModeEnabled()){this._modelRenderTargets.length=0;let t=3;this._modelRenderTargets.length=t;for(let i=0;i<t;++i){let s=new Zi;s.createRenderTarget(this.gl,this._modelRenderTargetWidth,this._modelRenderTargetHeight,this._currentFbo),this._modelRenderTargets[i]=s}if(this._model.isUsingMaskingForOffscreen()){this._offscreenMasks.length=this._offscreenClippingManager.getRenderTextureCount();for(let i=0;i<this._offscreenMasks.length;++i){let s=new pe;s.createRenderTarget(this.gl,this._offscreenClippingManager.getClippingMaskBufferSize(),this._offscreenClippingManager.getClippingMaskBufferSize(),this._currentFbo),this._offscreenMasks[i]=s}}let r=this._model.getOffscreenCount();if(r>0){this._offscreenList=new Array(r);for(let i=0;i<r;++i){let s=new Zi;s.setOffscreenIndex(i),this._offscreenList[i]=s}this.setupParentOffscreens(this._model,r)}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentFbo)}_textures;_sortedObjectsIndexList;_sortedObjectsTypeList;_rendererProfile;_drawableClippingManager;_clippingContextBufferForMask;_clippingContextBufferForDraw;_clippingContextBufferForOffscreen;_offscreenClippingManager;_modelRenderTargets;_drawableMasks;_offscreenMasks;_offscreenList;_currentFbo;_currentOffscreen;_modelRootFbo;_renderStateFbo=null;_renderStateKnown=!1;_renderStateViewport=[0,0,0,0];_bufferData;_drawableIndexBuffers;_drawableUvBuffers;_renderTargetIndexBuffer;_extension;gl};mt.staticRelease=()=>{dr.doStaticRelease()};(function(e){e.CubismClippingContext=$s,e.CubismClippingManager_WebGL=dt,e.CubismRenderer_WebGL=dr})(es||(es={}));tr=class en{static create(t,r){let i=null;if(r&&!this.hasMocConsistency(t))return D("Inconsistent MOC3."),i;let s=Live2DCubismCore.Moc.fromArrayBuffer(t);return s&&(i=new en(s),i._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(t)),i}static delete(t){t._moc._release(),t._moc=null,t=null}createModel(){let t=null,r=Live2DCubismCore.Model.fromMoc(this._moc);return r&&(t=new bs(r),t.initialize(),++this._modelCount),t}deleteModel(t){t!=null&&(t.release(),t=null,--this._modelCount)}constructor(t){this._moc=t,this._modelCount=0,this._mocVersion=0}release(){Q(this._modelCount==0),this._moc._release(),this._moc=null}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static getMocVersionFromBuffer(t){return Live2DCubismCore.Version.csmGetMocVersion(t)}static hasMocConsistency(t){return Live2DCubismCore.Moc.prototype.hasMocConsistency(t)===1}_moc;_modelCount;_mocVersion};(function(e){e.CubismMoc=tr})(ts||(ts={}));rs="Meta",qo="UserDataCount",Zo="TotalUserDataSize",Ht="UserData",Ko="Target",$o="Id",el="Value",tn=class{constructor(e,t){this._json=X.create(e,t)}release(){X.delete(this._json)}getUserDataCount(){return this._json.getRoot().getValueByString(rs).getValueByString(qo).toInt()}getTotalUserDataSize(){return this._json.getRoot().getValueByString(rs).getValueByString(Zo).toInt()}getUserDataTargetType(e){return this._json.getRoot().getValueByString(Ht).getValueByIndex(e).getValueByString(Ko).getRawString()}getUserDataId(e){return P.getIdManager().getId(this._json.getRoot().getValueByString(Ht).getValueByIndex(e).getValueByString($o).getRawString())}getUserDataValue(e){return this._json.getRoot().getValueByString(Ht).getValueByIndex(e).getValueByString(el).getRawString()}_json};(function(e){e.CubismModelUserDataJson=tn})(is||(is={}));tl="ArtMesh",rn=class{targetType;targetId;value},rr=class sn{static create(t,r){let i=new sn;return i.parseUserData(t,r),i}static delete(t){t!=null&&(t.release(),t=null)}getArtMeshUserDatas(){return this._artMeshUserDataNode}parseUserData(t,r){let i=new tn(t,r);if(!i){i.release(),i=void 0;return}let s=P.getIdManager().getId(tl),n=i.getUserDataCount(),a=this._userDataNodes.length;this._userDataNodes.length=n;for(let l=0;l<n;l++){let o=new rn;o.targetId=i.getUserDataId(l),o.targetType=P.getIdManager().getId(i.getUserDataTargetType(l)),o.value=i.getUserDataValue(l),this._userDataNodes[a++]=o,o.targetType==s&&this._artMeshUserDataNode.push(o)}i.release(),i=void 0}constructor(){this._userDataNodes=new Array,this._artMeshUserDataNode=new Array}release(){for(let t=0;t<this._userDataNodes.length;++t)this._userDataNodes[t]=null;this._userDataNodes=null}_userDataNodes;_artMeshUserDataNode};(function(e){e.CubismModelUserData=rr,e.CubismModelUserDataNode=rn})(ss||(ss={}));nn=class an{isInitialized(){return this._initialized}setInitialized(t){this._initialized=t}isUpdating(){return this._updating}setUpdating(t){this._updating=t}setDragging(t,r){this._dragManager.set(t,r)}getModelMatrix(){return this._modelMatrix}setRenderTargetSize(t,r){this._renderer&&this._renderer.setRenderTargetSize(t,r)}setOpacity(t){this._opacity=t}getOpacity(){return this._opacity}loadModel(t,r=!1){if(this._moc=tr.create(t,r),this._moc==null){D("Failed to CubismMoc.create().");return}if(this._model=this._moc.createModel(),this._model==null){D("Failed to CreateModel().");return}this._model.saveParameters(),this._modelMatrix=new or(this._model.getCanvasWidth(),this._model.getCanvasHeight())}loadMotion(t,r,i,s,n,a,l,o,u=!1){if(t==null||r==0)return D("Failed to loadMotion()."),null;let h=Qs.create(t,r,s,n,u);if(h==null)return D("Failed to create motion from buffer in LoadMotion()"),null;if(a){let d=a.getMotionFadeInTimeValue(l,o);d>=0&&h.setFadeInTime(d);let c=a.getMotionFadeOutTimeValue(l,o);c>=0&&h.setFadeOutTime(c)}return h}loadExpression(t,r,i){return t==null||r==0?(D("Failed to loadExpression()."),null):Te.create(t,r)}loadPose(t,r){if(t==null||r==0){D("Failed to loadPose().");return}this._pose=jt.create(t,r)}loadUserData(t,r){if(t==null||r==0){D("Failed to loadUserData().");return}this._modelUserData=rr.create(t,r)}loadPhysics(t,r){if(t==null||r==0){D("Failed to loadPhysics().");return}this._physics=$t.create(t,r)}isHit(t,r,i){let s=this._model.getDrawableIndex(t);if(s<0)return!1;let n=this._model.getDrawableVertexCount(s),a=this._model.getDrawableVertices(s),l=a[0],o=a[0],u=a[1],h=a[1];for(let g=1;g<n;++g){let f=a[ee.vertexOffset+g*ee.vertexStep],p=a[ee.vertexOffset+g*ee.vertexStep+1];f<l&&(l=f),f>o&&(o=f),p<u&&(u=p),p>h&&(h=p)}let d=this._modelMatrix.invertTransformX(r),c=this._modelMatrix.invertTransformY(i);return l<=d&&d<=o&&u<=c&&c<=h}getModel(){return this._model}getMocVersionFromBuffer(t){return tr.getMocVersionFromBuffer(t)}getRenderer(){return this._renderer}createRenderer(t,r,i=1){this._renderer&&this.deleteRenderer(),this._renderer=new dr(t,r),this._renderer.initialize(this._model,i)}deleteRenderer(){this._renderer!=null&&(this._renderer.release(),this._renderer=null)}motionEventFired(t){ge("{0}",t)}static cubismDefaultMotionEventCallback(t,r,i){let s=i;s?.motionEventFired(r)}constructor(){this._moc=null,this._model=null,this._motionManager=null,this._expressionManager=null,this._eyeBlink=null,this._breath=null,this._modelMatrix=null,this._pose=null,this._dragManager=null,this._physics=null,this._modelUserData=null,this._initialized=!1,this._updating=!1,this._opacity=1,this._mocConsistency=!1,this._debugMode=!1,this._renderer=null,this._motionManager=new Ns,this._motionManager.setEventCallback(an.cubismDefaultMotionEventCallback,this),this._expressionManager=new vs,this._dragManager=new xs}release(){this._motionManager!=null&&(this._motionManager.release(),this._motionManager=null),this._expressionManager!=null&&(this._expressionManager.release(),this._expressionManager=null),this._moc!=null&&(this._moc.deleteModel(this._model),this._moc.release(),this._moc=null),this._modelMatrix=null,jt.delete(this._pose),ar.delete(this._eyeBlink),nr.delete(this._breath),this._dragManager=null,$t.delete(this._physics),rr.delete(this._modelUserData),this.deleteRenderer()}_moc;_model;_motionManager;_expressionManager;_eyeBlink;_breath;_modelMatrix;_pose;_dragManager;_physics;_modelUserData;_initialized;_updating;_opacity;_mocConsistency;_motionConsistency;_debugMode;_renderer};(function(e){e.CubismUserModel=nn})(ns||(ns={}));fe=class{static sortFunction(e,t){if(!e||!t){if(!e&&!t)return 0;if(!e)return 1;if(!t)return-1}return e.getExecutionOrder()-t.getExecutionOrder()}_executionOrder;_changeListeners=[];constructor(e=0){this._executionOrder=e}getExecutionOrder(){return this._executionOrder}setExecutionOrder(e){this._executionOrder!==e&&(this._executionOrder=e,this.notifyChangeListeners())}addChangeListener(e){e&&this._changeListeners.indexOf(e)===-1&&this._changeListeners.push(e)}removeChangeListener(e){let t=this._changeListeners.indexOf(e);t>=0&&this._changeListeners.splice(t,1)}notifyChangeListeners(){for(let e of this._changeListeners)e.onUpdaterChanged(this)}};(function(e){e.ICubismUpdater=fe})(as||(as={}));on=class extends fe{_breath;constructor(e,t){super(t??500),this._breath=e}onLateUpdate(e,t){e&&this._breath.updateParameters(e,t)}};(function(e){e.CubismBreathUpdater=on})(os||(os={}));ln=class extends fe{_expressionManager;constructor(e,t){super(t??300),this._expressionManager=e}onLateUpdate(e,t){e&&this._expressionManager.updateMotion(e,t)}};(function(e){e.CubismExpressionUpdater=ln})(ls||(ls={}));un=class extends fe{_motionUpdated;_eyeBlink;constructor(e,t,r){super(r??200),this._motionUpdated=e,this._eyeBlink=t}onLateUpdate(e,t){e&&(this._motionUpdated()||this._eyeBlink.updateParameters(e,t))}};(function(e){e.CubismEyeBlinkUpdater=un})(us||(us={}));hn=class extends fe{_look;_dragManager;constructor(e,t,r){super(r??400),this._look=e,this._dragManager=t}onLateUpdate(e,t){if(!e)return;this._dragManager.update(t);let r=this._dragManager.getX(),i=this._dragManager.getY();this._look.updateParameters(e,r,i)}};(function(e){e.CubismLookUpdater=hn})(hs||(hs={}));cn=class extends fe{_physics;constructor(e,t){super(t??600),this._physics=e}onLateUpdate(e,t){e&&this._physics.evaluate(e,t)}};(function(e){e.CubismPhysicsUpdater=cn})(cs||(cs={}));dn=class extends fe{_pose;constructor(e,t){super(t??800),this._pose=e}onLateUpdate(e,t){e&&this._pose.updateParameters(e,t)}};(function(e){e.CubismPoseUpdater=dn})(ds||(ds={}));gn=class{_cubismUpdatableList;_needsSort;constructor(){this._cubismUpdatableList=[],this._needsSort=!1}release(){for(let e of this._cubismUpdatableList)e&&e.removeChangeListener(this);this._cubismUpdatableList.length=0}addUpdatableList(e){e&&(this.hasUpdatable(e)||(this._cubismUpdatableList.push(e),e.addChangeListener(this),this._needsSort=!0))}removeUpdatableList(e){if(!e)return!1;let t=this._cubismUpdatableList.indexOf(e);return t>=0?(this._cubismUpdatableList.splice(t,1),e.removeChangeListener(this),!0):!1}sortUpdatableList(){this._cubismUpdatableList.sort(fe.sortFunction),this._needsSort=!1}onLateUpdate(e,t){if(e){this._needsSort&&this.sortUpdatableList();for(let r=0;r<this._cubismUpdatableList.length;++r){let i=this._cubismUpdatableList[r];i&&i.onLateUpdate(e,t)}}}getUpdatableCount(){return this._cubismUpdatableList.length}getUpdatable(e){return e<0||e>=this._cubismUpdatableList.length?null:this._cubismUpdatableList[e]}hasUpdatable(e){return this._cubismUpdatableList.indexOf(e)>=0}clearUpdatableList(){for(let e of this._cubismUpdatableList)e&&e.removeChangeListener(this);this._cubismUpdatableList.length=0,this._needsSort=!1}onUpdaterChanged(e){this._needsSort=!0}};(function(e){e.CubismUpdateScheduler=gn})(gs||(gs={}));lt=0;ll=class{disposed=!1;failure;pending=new Map;track(e){return this.failure?Promise.reject(this.failure):this.disposed?Promise.resolve({status:"disposed"}):new Promise((t,r)=>{this.pending.set(e,{reason:"completed",reject:r,resolve:t})})}interruptActive(){for(let e of this.pending.values())e.reason="interrupted"}settleFinished(e){for(let[t,r]of[...this.pending])e(t)&&(this.pending.delete(t),r.resolve({status:r.reason}))}fail(e){this.failure??=e;for(let t of this.takeAll())t.reject(this.failure)}dispose(){if(!this.disposed){this.disposed=!0;for(let e of this.takeAll())e.resolve({status:"disposed"})}}takeAll(){let e=[...this.pending.values()];return this.pending.clear(),e}},We=new Map;cl=1,dl=3,gl=1e3,ps={force:3,idle:1,normal:2};fl=550,Al=class extends fe{callbacks;constructor(e){super(fl),this.callbacks=e}onLateUpdate(e,t){for(let r of this.callbacks)r(t*1e3)}},pl=class extends nn{stage;modelUrl;setting;shaderBaseUrl;shaderSources;idleMotion;releaseFramework;model3Version;diagnostics;resolveAsset;afterMotionCallbacks=new Set;beforePhysicsCallbacks=new Set;assetController=new AbortController;expressionCache=new Map;loadedMotions=new Set;layoutMatrix;manualParameters=new Map;mvpMatrix;motionCache=new Map;motionStates=new ll;parameterIds=new Map;renderContext;releaseRenderContext;renderError;stopErrorWatch;pendingExpressionKeys=new Set;pendingMotionKeys=new Set;scheduler=new gn;textures=[];viewport=[0,0,1,1];bounds={centerX:0,centerY:0,height:1,width:1};detachDriver;disposed=!1;expressionGeneration=0;eyeBlinkIds=[];idlePending=!1;look;mvpDirty=!0;motionUpdated=!1;motionGeneration=0;transform={scale:1,x:0,y:0};constructor(e,t,r,i,s,n,a,l,o,u){super(),this.stage=e,this.modelUrl=t,this.setting=r,this.shaderBaseUrl=i,this.shaderSources=s,this.idleMotion=n,this.releaseFramework=a,this.model3Version=l,this.diagnostics=o,this.resolveAsset=u}parameterId(e){let t=this.parameterIds.get(e);if(t)return t;let r=P.getIdManager().getId(e);return this.parameterIds.set(e,r),r}async initialize(e){let t=()=>this.assetController.abort(e?.reason);e?.aborted&&t(),e?.addEventListener("abort",t,{once:!0});try{let r=this.setting.getModelFileName();if(!r)throw new m("model-load-failed","model3.json does not declare FileReferences.Moc.",{details:se("model3",this.modelUrl)});let i=te(r,this.modelUrl),s=await Ce(this.diagnostics,"mocFetch",()=>he(i,"moc3",this.assetController.signal,this.resolveAsset));try{q(this.diagnostics,"load","mocParse",()=>this.loadModel(s,!0))}catch(l){throw new m("model-load-failed",`Failed to parse moc3 asset ${i}.`,{cause:l,details:se("moc3",i)})}if(!this.getModel())throw new m("model-load-failed","Cubism Core rejected the moc3 model.",{details:se("moc3",i)});this.layoutMatrix=new or(this.getModel().getCanvasWidth(),this.getModel().getCanvasHeight());let n=new Map;this.setting.getLayoutMap(n),this.layoutMatrix.setupFromLayout(n),this.bounds=nl({height:this.getModel().getCanvasHeight(),width:this.getModel().getCanvasWidth()},this.layoutMatrix),await Ce(this.diagnostics,"optionalAssets",()=>this.loadOptionalAssets()),this.setupEffects(),await this.setupRenderer(),this.getModel().saveParameters();let a=we(this.stage);this.detachDriver=a.attachDriver({draw:()=>this.draw(),resize:(l,o)=>this.resize(l,o),update:l=>this.updateFrame(l)}),this.stopErrorWatch=this.stage.onError(l=>this.failMotions(l)),this.prefetchIdleMotions()}finally{e?.removeEventListener("abort",t)}}async prefetchIdleMotions(){if(await new Promise(t=>{let r,i=()=>{clearTimeout(r),t()};r=setTimeout(()=>{this.assetController.signal.removeEventListener("abort",i),t()},gl),this.assetController.signal.addEventListener("abort",i,{once:!0})}),this.disposed||this.idleMotion===!1)return;let e=this.setting.getMotionCount(this.idleMotion.group);for(let t=0;t<e;t++){if(this.disposed)return;try{await this.loadMotionAsset(this.idleMotion.group,t)}catch{}}}async loadOptionalAssets(){let e=this.assetController.signal,t=this.setting.getPhysicsFileName(),r=this.setting.getPoseFileName(),i=this.setting.getUserDataFile(),s=t?te(t,this.modelUrl):void 0,n=r?te(r,this.modelUrl):void 0,a=i?te(i,this.modelUrl):void 0,[l,o,u]=await Promise.all([s?he(s,"physics",e,this.resolveAsset):void 0,n?he(n,"pose",e,this.resolveAsset):void 0,a?he(a,"user-data",e,this.resolveAsset):void 0]);try{l&&this.loadPhysics(l,l.byteLength)}catch(h){throw new m("model-load-failed",`Failed to parse physics asset ${s}.`,{cause:h,details:se("physics",s)})}try{o&&this.loadPose(o,o.byteLength)}catch(h){throw new m("model-load-failed",`Failed to parse pose asset ${n}.`,{cause:h,details:se("pose",n)})}try{u&&this.loadUserData(u,u.byteLength)}catch(h){throw new m("model-load-failed",`Failed to parse user data asset ${a}.`,{cause:h,details:se("user-data",a)})}}setupEffects(){this.eyeBlinkIds=Array.from({length:this.setting.getEyeBlinkParameterCount()},(e,t)=>this.setting.getEyeBlinkParameterId(t)),this.eyeBlinkIds.length>0&&(this._eyeBlink=ar.create(this.setting),this.scheduler.addUpdatableList(new un(()=>this.motionUpdated,this._eyeBlink,300))),this._breath=nr.create(),this._breath.setParameters([new De(this.parameterId(S.ParamAngleX),0,15,6.5345,.5),new De(this.parameterId(S.ParamAngleY),0,8,3.5345,.5),new De(this.parameterId(S.ParamAngleZ),0,10,5.5345,.5),new De(this.parameterId(S.ParamBodyAngleX),0,4,15.5345,.5),new De(this.parameterId(S.ParamBreath),.5,.5,3.2345,1)]),this.scheduler.addUpdatableList(new on(this._breath)),this._physics&&this.scheduler.addUpdatableList(new cn(this._physics)),this._pose&&this.scheduler.addUpdatableList(new dn(this._pose)),this._expressionManager&&this.scheduler.addUpdatableList(new ln(this._expressionManager,200)),this.look=Jt.create(),this.look.setParameters([new Ie(this.parameterId(S.ParamAngleX),30,0,0),new Ie(this.parameterId(S.ParamAngleY),0,30,0),new Ie(this.parameterId(S.ParamAngleZ),0,0,-30),new Ie(this.parameterId(S.ParamBodyAngleX),10,0,0),new Ie(this.parameterId(S.ParamEyeBallX),1,0,0),new Ie(this.parameterId(S.ParamEyeBallY),0,1,0)]),this.scheduler.addUpdatableList(new hn(this.look,this._dragManager)),this.scheduler.addUpdatableList(new Al(this.beforePhysicsCallbacks)),this.scheduler.sortUpdatableList()}async setupRenderer(){let{canvas:e,gl:t}=we(this.stage);this.renderContext=t,this.releaseRenderContext=hl(t),this.createRenderer(e.width,e.height);let r=this.getRenderer();r.startUp(t),r.setIsPremultipliedAlpha(!0);let i=[];for(let a=0;a<this.setting.getTextureCount();a++){let l=this.setting.getTextureFileName(a);if(!l)throw new m("model-load-failed",`model3.json declares an empty texture at index ${a}.`,{details:se("texture",this.modelUrl)});i.push(te(l,this.modelUrl))}let s=i.map(a=>Yr(a,this.assetController.signal,this.diagnostics,this.resolveAsset));for(let a of s)a.catch(()=>{});let n=async()=>{await Promise.allSettled(s.map(async a=>Ne(await a)))};try{await Ce(this.diagnostics,"shaderSetup",()=>r.loadShaders(this.shaderBaseUrl,this.assetController.signal,this.shaderSources))}catch(a){throw await n(),a instanceof m?a:new m("render-error",a instanceof Error?a.message:"Cubism shader loading failed.",{cause:a,details:rl(a)})}try{for(let a=0;a<s.length;a++){let l=await s[a];if(this.assetController.signal.aborted)throw Ne(l),this.assetController.signal.reason;let o=zr(t,l,i[a],this.diagnostics);this.textures.push(o),this.diagnostics?.changeResource("texture",1),r.bindTexture(a,o)}}catch(a){throw await n(),a}}updateFrame(e){if(this.disposed)return;let t=e/1e3;if(!this.diagnostics){this.getModel().loadParameters(),this.motionUpdated=!1,this._motionManager.isFinished()?this.scheduleIdle():this.motionUpdated=this._motionManager.updateMotion(this.getModel(),t),this.getModel().saveParameters(),this.settleFinishedMotions(),this.scheduler.onLateUpdate(this.getModel(),t);for(let[r,i]of this.manualParameters)this.getModel().setParameterValueById(this.parameterId(r),i);for(let r of this.afterMotionCallbacks)r(e);this.getModel().update();return}q(this.diagnostics,"frame","motion",()=>{this.getModel().loadParameters(),this.motionUpdated=!1,this._motionManager.isFinished()?this.scheduleIdle():this.motionUpdated=this._motionManager.updateMotion(this.getModel(),t),this.getModel().saveParameters()}),this.settleFinishedMotions(),q(this.diagnostics,"frame","effectsPhysicsPose",()=>{this.scheduler.onLateUpdate(this.getModel(),t)}),q(this.diagnostics,"frame","manualParameters",()=>{for(let[r,i]of this.manualParameters)this.getModel().setParameterValueById(this.parameterId(r),i)}),q(this.diagnostics,"frame","externalDrivers",()=>{for(let r of this.afterMotionCallbacks)r(e)}),q(this.diagnostics,"frame","coreUpdate",()=>{this.getModel().update()})}scheduleIdle(){if(this.idleMotion===!1||this.idlePending)return;let{group:e,weights:t}=this.idleMotion,r=this.setting.getMotionCount(e);r!==0&&(this.idlePending=!0,this.playMotion(e,Tr(r,t),cl).catch(i=>{this.disposed||we(this.stage).reportError(fn(i,"Idle motion failed"))}).finally(()=>{this.idlePending=!1}))}async ensureAssetBuffer(e){return await al(e,()=>he(e.url,e.type,this.assetController.signal,this.resolveAsset)),e}async loadMotionAsset(e,t){let r=`${e}:${t}`,i=this.motionCache.get(r);if(i)return i;let s=(async()=>{this.pendingMotionKeys.add(r),this.diagnostics?.changeResource("pendingMotion",1);try{let n=te(this.setting.getMotionFileName(e,t),this.modelUrl),a=await he(n,"motion",this.assetController.signal,this.resolveAsset),l=this.parseMotion(a,r,e,t,n);return this.loadedMotions.add(l),{motion:l,type:"motion",url:n}}finally{this.pendingMotionKeys.delete(r)&&this.diagnostics?.changeResource("pendingMotion",-1)}})();return this.motionCache.set(r,s),s.catch(()=>this.motionCache.delete(r)),s}parseMotion(e,t,r,i,s=te(this.setting.getMotionFileName(r,i),this.modelUrl)){let n=this.loadMotion(e,e.byteLength,t,void 0,void 0,this.setting,r,i,!0);if(!n)throw new m("model-load-failed",`Failed to parse motion ${t}.`,{details:se("motion",s)});return n.setEffectIds(this.eyeBlinkIds,[]),n}motionGroupNames(){return Array.from({length:this.setting.getMotionGroupCount()},(e,t)=>this.setting.getMotionGroupName(t))}failMotions(e){this.renderError??=e,this.motionStates.fail(this.renderError)}settleFinishedMotions(){this.motionStates.settleFinished(e=>this._motionManager.isFinishedByHandle(e))}async playMotion(e,t,r,i={}){if(this.disposed)return{status:"disposed"};if(this.renderError)throw this.renderError;let s=this.setting.getMotionCount(e);if(s===0)throw new m("invalid-props",`Unknown Live2D motion group: ${e}. Available groups: ${this.motionGroupNames().join(", ")||"(none)"}`);let n=t??Math.floor(Math.random()*s);if(!Number.isInteger(n)||n<0||n>=s)throw new m("invalid-props",`Motion index ${n} is outside group ${e} (0-${s-1}).`);if(r===dl)this._motionManager.setReservePriority(r);else if(!this._motionManager.reserveMotion(r))return{status:"skipped"};let a=++this.motionGeneration,l,o;try{let u=await this.loadMotionAsset(e,n);if(this.disposed)return{status:"disposed"};if(a!==this.motionGeneration)return{status:"skipped"};if(et(i)){if(await this.ensureAssetBuffer(u),this.disposed)return{status:"disposed"};if(a!==this.motionGeneration)return{status:"skipped"}}if(o=As(u,i,h=>this.parseMotion(h,`${e}:${n}`,e,n),h=>Se.delete(h)),l=this._motionManager.startMotionPriority(o.motion,o.autoDelete,r),l===-1)return o.releaseBeforeStart(),{status:"skipped"};o.transferToQueue(),this.motionStates.interruptActive()}catch(u){if(o?.releaseBeforeStart(),this.disposed)return{status:"disposed"};throw a===this.motionGeneration&&this._motionManager.setReservePriority(0),u}return this.motionStates.track(l)}hitTestStagePoint(e,t){if(this.disposed||!this.layoutMatrix)return[];(!this.mvpMatrix||this.mvpDirty)&&(this.mvpMatrix=fs(this.stage.getSize(),this.transform,this.layoutMatrix,this.bounds));let r=this.stage.getSize(),i=e/Math.max(1,r.width)*2-1,s=1-t/Math.max(1,r.height)*2,n=this.mvpMatrix.invertTransformX(i),a=this.mvpMatrix.invertTransformY(s),l=[];for(let o=0;o<this.setting.getHitAreasCount();o++){let u=this.getModel().getDrawableIndex(this.setting.getHitAreaId(o));if(u<0||this.getModel().getDrawableOpacity(u)<=0)continue;let h=this.getModel().getDrawableVertexCount(u),d=this.getModel().getDrawableVertices(u);if(h===0)continue;let c=d[0],g=d[0],f=d[1],p=d[1];for(let A=1;A<h;A++){let _=d[A*2],y=d[A*2+1];c=Math.min(c,_),g=Math.max(g,_),f=Math.min(f,y),p=Math.max(p,y)}n>=c&&n<=g&&a>=f&&a<=p&&l.push(this.setting.getHitAreaName(o))}return l}readModelInfo(){let e={};for(let t of this.motionGroupNames())e[t]=this.setting.getMotionCount(t);return{expressions:Array.from({length:this.setting.getExpressionCount()},(t,r)=>this.setting.getExpressionName(r)),hitAreas:Array.from({length:this.setting.getHitAreasCount()},(t,r)=>this.setting.getHitAreaName(r)),motions:e,model3Version:this.model3Version,mocVersion:this._moc?.getMocVersion(),parameters:Array.from({length:this.getModel().getParameterCount()},(t,r)=>({defaultValue:this.getModel().getParameterDefaultValue(r),id:this.getModel().getParameterId(r).getString(),maximum:this.getModel().getParameterMaximumValue(r),minimum:this.getModel().getParameterMinimumValue(r)}))}}findExpression(e){for(let t=0;t<this.setting.getExpressionCount();t++)if(this.setting.getExpressionName(t)===e)return t;return-1}async loadExpressionAsset(e,t){let r=this.expressionCache.get(e);if(r)return r;let i=(async()=>{this.pendingExpressionKeys.add(e),this.diagnostics?.changeResource("pendingExpression",1);try{let s=te(this.setting.getExpressionFileName(t),this.modelUrl),n=await he(s,"expression",this.assetController.signal,this.resolveAsset),a=this.parseExpression(n,e,s);return this.loadedMotions.add(a),{motion:a,type:"expression",url:s}}finally{this.pendingExpressionKeys.delete(e)&&this.diagnostics?.changeResource("pendingExpression",-1)}})();return this.expressionCache.set(e,i),i.catch(()=>this.expressionCache.delete(e)),i}parseExpression(e,t,r=te(this.setting.getExpressionFileName(this.findExpression(t)),this.modelUrl)){let i=this.loadExpression(e,e.byteLength,t);if(!i)throw new m("model-load-failed",`Failed to parse expression ${t}.`,{details:se("expression",r)});return i}async playExpression(e,t,r){let i=++this.expressionGeneration,s;try{let n=await this.loadExpressionAsset(e,t);if(this.disposed||i!==this.expressionGeneration||et(r)&&(await this.ensureAssetBuffer(n),this.disposed||i!==this.expressionGeneration))return;if(s=As(n,r,a=>this.parseExpression(a,e),a=>Se.delete(a)),this._expressionManager.startMotion(s.motion,s.autoDelete)===-1){s.releaseBeforeStart();return}s.transferToQueue()}catch(n){if(s?.releaseBeforeStart(),!this.disposed)throw n}}draw(){if(this.disposed)return;let{gl:e}=we(this.stage),t=cr.getInstance();t.beginFrameProcess(e);try{let r=this.getRenderer();if(r.setRenderState(null,this.viewport),!this.layoutMatrix)return;(this.mvpDirty||!this.mvpMatrix)&&(this.mvpMatrix=fs(this.stage.getSize(),this.transform,this.layoutMatrix,this.bounds),this.mvpDirty=!1,r.setMvpMatrix(this.mvpMatrix)),r.drawModel(this.shaderBaseUrl)}finally{t.endFrameProcess(e),t.releaseStaleRenderTextures(e)}}resize(e,t){this.viewport[2]=e,this.viewport[3]=t,this.mvpDirty=!0,this.setRenderTargetSize(e,t)}toHandle(){return{clearExpression:()=>{this.disposed||(this.expressionGeneration++,this._expressionManager.stopAllMotions())},clearParameter:e=>{this.manualParameters.delete(e)},dispose:()=>this.disposeModel(),expression:async(e,t)=>{let r=Or(t),i=this.setting.getExpressionCount();if(i===0){if(e)throw new m("invalid-props",`Unknown Live2D expression: ${e}`);return}let s=e??this.setting.getExpressionName(Math.floor(Math.random()*i)),n=this.findExpression(s);if(n<0)throw new m("invalid-props",`Unknown Live2D expression: ${s}. Available: ${this.readModelInfo().expressions.join(", ")}`);await this.playExpression(s,n,r)},focus:(e,t)=>{let r=this.stage.getSize();this.setDragging(Math.max(-1,Math.min(1,e/Math.max(1,r.width)*2-1)),Math.max(-1,Math.min(1,1-t/Math.max(1,r.height)*2)))},getIntrinsicSize:()=>({height:this.bounds.height,width:this.bounds.width}),getModelInfo:()=>this.readModelInfo(),getParameter:e=>this.getModel().getParameterValueById(this.parameterId(e)),hitTest:(e,t)=>this.hitTestStagePoint(e,t),isMotionPlaying:()=>!this.disposed&&!this._motionManager.isFinished(),motion:async(e,t,r)=>{Ue(r);let i=$e(r);await this.playMotion(e,t,ps[r?.priority??"force"],i)},playMotion:(e,t,r)=>{Ue(r);let i=$e(r);return this.playMotion(e,t,ps[r?.priority??"force"],i)},onAfterMotionUpdate:e=>(this.afterMotionCallbacks.add(e),ms(()=>this.afterMotionCallbacks.delete(e))),onBeforePhysicsUpdate:e=>(this.beforePhysicsCallbacks.add(e),ms(()=>this.beforePhysicsCallbacks.delete(e))),setParameter:(e,t)=>{this.disposed||(this.manualParameters.set(e,t),this.getModel().setParameterValueById(this.parameterId(e),t))},setTransform:e=>{this.transform={...e},this.mvpDirty=!0}}}disposeModel(){if(this.disposed)return;this.disposed=!0,this.motionGeneration++,this.expressionGeneration++,this.assetController.abort(new DOMException("Model disposed","AbortError"));for(let t=this.pendingMotionKeys.size;t>0;t--)this.diagnostics?.changeResource("pendingMotion",-1);this.pendingMotionKeys.clear();for(let t=this.pendingExpressionKeys.size;t>0;t--)this.diagnostics?.changeResource("pendingExpression",-1);this.pendingExpressionKeys.clear(),this.motionStates.dispose(),this.detachDriver?.(),this.detachDriver=void 0,this.stopErrorWatch?.(),this.stopErrorWatch=void 0,this.afterMotionCallbacks.clear(),this.beforePhysicsCallbacks.clear(),this.scheduler.release(),this.look&&Jt.delete(this.look),this.look=void 0;let e=this.renderContext;this.renderContext=void 0;try{if(e)for(let t of this.textures)e.deleteTexture(t);for(let t=0;t<this.textures.length;t++)this.diagnostics?.changeResource("texture",-1);this.textures.length=0,this.motionCache.clear(),this.expressionCache.clear(),this.manualParameters.clear(),this.setting.release(),super.release();for(let t of this.loadedMotions)Se.delete(t);this.loadedMotions.clear(),this.releaseRenderContext?.(),this.releaseRenderContext=void 0}finally{this.releaseFramework()}}}});var _n={};Ke(_n,{createCubismWebGLBackend:()=>mn,cubismWebGL:()=>Je});function Cl(){return Reflect.construct(URL,["./cubism-webgl-shaders/",import.meta.url])}function mn(e={}){return{createStage:Jr,async loadModel(t,r,i){let s=Hr(e.shaderBaseUrl??Cl()),{loadFrameworkModel:n}=await Promise.resolve().then(()=>(pn(),An));return n(t,r,s,e.shaderBaseUrl?void 0:_l,i)}}}var _l,Je,gr=_e(()=>{Lt();_l={"fragshadersrcalphablend.frag":`/**
|
|
24
|
+
`;s+=l,n+=l}s+=this._vertShaderSrcBlend,n+=this._fragShaderSrcBlend,this._shaderSets[a].shaderProgram=this.loadShaderProgram(s,n),this._shaderSets[a].attributePositionLocation=this.gl.getAttribLocation(this._shaderSets[a].shaderProgram,"a_position"),this._shaderSets[a].attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets[a].shaderProgram,"a_texCoord"),this._shaderSets[a].samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"s_texture0"),this._shaderSets[a].uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_matrix"),this._shaderSets[a].uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_baseColor"),this._shaderSets[a].uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_multiplyColor"),this._shaderSets[a].uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_screenColor"),this._shaderSets[a].samplerFrameBufferTextureLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"s_blendTexture"),(i==1||i==2)&&(this._shaderSets[a].samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"s_texture1"),this._shaderSets[a].uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_clipMatrix"),this._shaderSets[a].uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_channelFlag"),this._shaderSets[a].uniformInvertMaskFlagLocation=this.gl.getUniformLocation(this._shaderSets[a].shaderProgram,"u_invertClippingMask"))}}loadShaderProgram(e,t){let r=this.gl.createProgram();if(!r)throw new Error("WebGL failed to create a shader program");let i,s;try{i=this.compileShaderSource(this.gl.VERTEX_SHADER,e),s=this.compileShaderSource(this.gl.FRAGMENT_SHADER,t)}catch(n){throw i&&this.gl.deleteShader(i),this.gl.deleteProgram(r),n}if(this.gl.attachShader(r,i),this.gl.attachShader(r,s),this.gl.linkProgram(r),!this.gl.getProgramParameter(r,this.gl.LINK_STATUS)){let n=this.gl.getProgramInfoLog(r);throw T("Failed to link program: {0}",n),this.gl.deleteShader(i),i=0,this.gl.deleteShader(s),s=0,r&&(this.gl.deleteProgram(r),r=0),new Error(`Failed to link WebGL shader program: ${n??"unknown error"}`)}return this.gl.deleteShader(i),this.gl.deleteShader(s),r}compileShaderSource(e,t){let r=t,i=this.gl.createShader(e);if(!i)throw new Error("WebGL failed to create a shader");if(this.gl.shaderSource(i,r),this.gl.compileShader(i),!this.gl.getShaderParameter(i,this.gl.COMPILE_STATUS)){let s=this.gl.getShaderInfoLog(i);T("Shader compile log: {0} ",s),this.gl.deleteShader(i);let n=e==this.gl.VERTEX_SHADER?"Vertex":"Fragment";throw new Error(`${n} shader compile error: ${s??"unknown error"}`)}return i}setGl(e){this.gl=e}setShaderPath(e){this._shaderPath=e}setShaderSources(e){this._shaderSources=e}getShaderPath(){return this._shaderPath}_shaderSets;gl;_colorBlendMap;_alphaBlendMap;_colorBlendValues;_alphaBlendValues;_blendShaderSetMap;_shaderCount;_vertShaderSrc;_vertShaderSrcMasked;_vertShaderSrcSetupMask;_fragShaderSrcSetupMask;_fragShaderSrcPremultipliedAlpha;_fragShaderSrcMaskPremultipliedAlpha;_fragShaderSrcMaskInvertedPremultipliedAlpha;_vertShaderSrcCopy;_fragShaderSrcCopy;_fragShaderSrcColorBlend;_fragShaderSrcAlphaBlend;_vertShaderSrcBlend;_fragShaderSrcBlend;_isShaderLoading;_isShaderLoaded;_blendShadersRegistered;_currentProgram;_shaderLoadPromise;_defaultShaderPath;_shaderPath;_shaderSources},$=class Zs{static getInstance(){return Pe==null&&(Pe=new Zs),Pe}static deleteInstance(){Pe&&(Pe.release(),Pe=null)}constructor(){this._shaderMap=new Map}release(){for(let t of this._shaderMap)t[1].release();this._shaderMap.clear()}getShader(t){return this._shaderMap.get(t)}setGlContext(t){if(!this._shaderMap.has(t)){let r=new qs;r.setGl(t),this._shaderMap.set(t,r)}}releaseContext(t){let r=this._shaderMap.get(t);r&&(r.release(),this._shaderMap.delete(t))}_shaderMap},Ks=class{shaderProgram;attributePositionLocation;attributeTexCoordLocation;uniformMatrixLocation;uniformClipMatrixLocation;samplerTexture0Location;samplerTexture1Location;uniformBaseColorLocation;uniformChannelFlagLocation;uniformMultiplyColorLocation;uniformScreenColorLocation;samplerFrameBufferTextureLocation;uniformInvertMaskFlagLocation},Jo=(function(e){return e[e.ShaderNames_SetupMask=0]="ShaderNames_SetupMask",e[e.ShaderNames_NormalPremultipliedAlpha=1]="ShaderNames_NormalPremultipliedAlpha",e[e.ShaderNames_NormalMaskedPremultipliedAlpha=2]="ShaderNames_NormalMaskedPremultipliedAlpha",e[e.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]="ShaderNames_NomralMaskedInvertedPremultipliedAlpha",e[e.ShaderNames_AddPremultipliedAlpha=4]="ShaderNames_AddPremultipliedAlpha",e[e.ShaderNames_AddMaskedPremultipliedAlpha=5]="ShaderNames_AddMaskedPremultipliedAlpha",e[e.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]="ShaderNames_AddMaskedPremultipliedAlphaInverted",e[e.ShaderNames_MultPremultipliedAlpha=7]="ShaderNames_MultPremultipliedAlpha",e[e.ShaderNames_MultMaskedPremultipliedAlpha=8]="ShaderNames_MultMaskedPremultipliedAlpha",e[e.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]="ShaderNames_MultMaskedPremultipliedAlphaInverted",e[e.ShaderNames_ShaderCount=10]="ShaderNames_ShaderCount",e})({});(function(e){e.CubismShaderSet=Ks,e.CubismShader_WebGL=qs,e.CubismShaderManager_WebGL=$,e.ShaderNames=Jo})($i||($i={}));ot=-1,Xt=new Uint16Array([0,1,2,2,1,3]),dt=class extends Eo{setGL(e){this.gl=e}constructor(){super($s)}setupClippingContext(e,t,r,i,s,n=!1){let a=0;for(let l=0;l<this._clippingContextListForMask.length;l++){let o=this._clippingContextListForMask[l];switch(s){case 0:default:this.calcClippedDrawableTotalBounds(e,o);break;case 1:this.calcClippedOffscreenTotalBounds(e,o);break}o._isUsing&&a++}if(!(a<=0)){switch(this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),s){case 0:default:this._currentMaskBuffer=t.getDrawableMaskBuffer(0);break;case 1:this._currentMaskBuffer=t.getOffscreenMaskBuffer(0);break}if(this._currentMaskBuffer.beginDraw(r,n),t.preDraw(),this.setupLayoutBounds(a),this._clearedMaskBufferFlags.length!=this._renderTextureCount){this._clearedMaskBufferFlags.length=0,this._clearedMaskBufferFlags=new Array(this._renderTextureCount);for(let l=0;l<this._clearedMaskBufferFlags.length;l++)this._clearedMaskBufferFlags[l]=!1}for(let l=0;l<this._clearedMaskBufferFlags.length;l++)this._clearedMaskBufferFlags[l]=!1;for(let l=0;l<this._clippingContextListForMask.length;l++){let o=this._clippingContextListForMask[l],u=o._allClippedDrawRect,c=o._layoutBounds,g=.05,h=0,d=0,f;switch(s){case 0:default:f=t.getDrawableMaskBuffer(o._bufferIndex);break;case 1:f=t.getOffscreenMaskBuffer(o._bufferIndex);break}if(this._currentMaskBuffer!=f&&(this._currentMaskBuffer.endDraw(),this._currentMaskBuffer=f,this._currentMaskBuffer.beginDraw(r,n),t.preDraw()),this._tmpBoundsOnModel.setRect(u),this._tmpBoundsOnModel.expand(u.width*g,u.height*g),h=c.width/this._tmpBoundsOnModel.width,d=c.height/this._tmpBoundsOnModel.height,this.createMatrixForMask(!1,c,h,d),o._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),o._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray()),s==1){let A=t.getMvpMatrix().getInvert();o._matrixForDraw.multiplyByMatrix(A)}let p=o._clippingIdCount;for(let A=0;A<p;A++){let _=o._clippingIdList[A];e.getDrawableDynamicFlagVertexPositionsDidChange(_)&&(t.setIsCulling(e.getDrawableCulling(_)!=!1),this._clearedMaskBufferFlags[o._bufferIndex]||(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this._clearedMaskBufferFlags[o._bufferIndex]=!0),t.setClippingContextBufferForMask(o),t.drawMeshWebGL(e,_))}}this._currentMaskBuffer.endDraw(),t.setClippingContextBufferForMask(null),this.gl.viewport(i[0],i[1],i[2],i[3])}}getClippingMaskCount(){return this._clippingContextListForMask.length}_currentMaskBuffer;gl},$s=class extends na{constructor(e,t,r){super(t,r),this._owner=e}getClippingManager(){return this._owner}setGl(e){this._owner.setGL(e)}_owner},jo=class{setGlEnable(e,t){t?this.gl.enable(e):this.gl.disable(e)}setGlEnableVertexAttribArray(e,t){t?this.gl.enableVertexAttribArray(e):this.gl.disableVertexAttribArray(e)}save(){if(this.gl==null){T(`'gl' is null. WebGLRenderingContext is required.
|
|
25
|
+
Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING),this._lastElementArrayBufferBinding=this.gl.getParameter(this.gl.ELEMENT_ARRAY_BUFFER_BINDING),this._lastProgram=this.gl.getParameter(this.gl.CURRENT_PROGRAM),this._lastActiveTexture=this.gl.getParameter(this.gl.ACTIVE_TEXTURE),this.gl.activeTexture(this.gl.TEXTURE1),this._lastTexture1Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this.gl.activeTexture(this.gl.TEXTURE0),this._lastTexture0Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._lastVertexAttribArrayEnabled[0]=this.gl.getVertexAttrib(0,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[1]=this.gl.getVertexAttrib(1,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[2]=this.gl.getVertexAttrib(2,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[3]=this.gl.getVertexAttrib(3,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastScissorTest=this.gl.isEnabled(this.gl.SCISSOR_TEST),this._lastStencilTest=this.gl.isEnabled(this.gl.STENCIL_TEST),this._lastDepthTest=this.gl.isEnabled(this.gl.DEPTH_TEST),this._lastCullFace=this.gl.isEnabled(this.gl.CULL_FACE),this._lastBlend=this.gl.isEnabled(this.gl.BLEND),this._lastFrontFace=this.gl.getParameter(this.gl.FRONT_FACE),this._lastColorMask=this.gl.getParameter(this.gl.COLOR_WRITEMASK),this._lastBlending[0]=this.gl.getParameter(this.gl.BLEND_SRC_RGB),this._lastBlending[1]=this.gl.getParameter(this.gl.BLEND_DST_RGB),this._lastBlending[2]=this.gl.getParameter(this.gl.BLEND_SRC_ALPHA),this._lastBlending[3]=this.gl.getParameter(this.gl.BLEND_DST_ALPHA)}restore(){if(this.gl==null){T(`'gl' is null. WebGLRenderingContext is required.
|
|
26
|
+
Please call 'CubimRenderer_WebGL.startUp' function.`);return}this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])}setGl(e){this.gl=e}constructor(){this._lastVertexAttribArrayEnabled=new Array(4),this._lastColorMask=new Array(4),this._lastBlending=new Array(4)}_lastArrayBufferBinding;_lastElementArrayBufferBinding;_lastProgram;_lastActiveTexture;_lastTexture0Binding2D;_lastTexture1Binding2D;_lastVertexAttribArrayEnabled;_lastScissorTest;_lastBlend;_lastStencilTest;_lastDepthTest;_lastCullFace;_lastFrontFace;_lastColorMask;_lastBlending;gl},dr=class extends mt{initialize(e,t=1){e.isUsingMasking()&&(this._drawableClippingManager=new dt,this._drawableClippingManager.initializeForDrawable(e,t)),e.isUsingMaskingForOffscreen()&&(this._offscreenClippingManager=new dt,this._offscreenClippingManager.initializeForOffscreen(e,t)),N(this._sortedObjectsIndexList,e.getDrawableCount()+(e.getOffscreenCount?e.getOffscreenCount():0),0,!0),N(this._sortedObjectsTypeList,e.getDrawableCount()+(e.getOffscreenCount?e.getOffscreenCount():0),0,!0),super.initialize(e)}setupParentOffscreens(e,t){let r;for(let i=0;i<t;++i){r=null;let s=e.getOffscreenOwnerIndices()[i],n=e.getPartParentPartIndices()[s];for(;n!=-1;){for(let a=0;a<t;++a)if(e.getOffscreenOwnerIndices()[this._offscreenList[a].getOffscreenIndex()]==n){r=this._offscreenList[a];break}if(r!=null)break;n=e.getPartParentPartIndices()[n]}this._offscreenList[i].setParentPartOffscreen(r)}}bindTexture(e,t){this._textures.set(e,t)}getBindedTextures(){return this._textures}setClippingMaskBufferSize(e){if(!this._model.isUsingMasking())return;let t=this._drawableClippingManager.getRenderTextureCount();this._drawableClippingManager.release(),this._drawableClippingManager=void 0,this._drawableClippingManager=null,this._drawableClippingManager=new dt,this._drawableClippingManager.setClippingMaskBufferSize(e),this._drawableClippingManager.initializeForDrawable(this.getModel(),t)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._drawableClippingManager.getClippingMaskBufferSize():ot}getModelRenderTarget(e){return this._modelRenderTargets[e]}getRenderTextureCount(){return this._model.isUsingMasking()?this._drawableClippingManager.getRenderTextureCount():ot}constructor(e,t){super(e,t),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new jo,this._textures=new Map,this._sortedObjectsIndexList=new Array,this._sortedObjectsTypeList=new Array,this._bufferData={vertex:WebGLBuffer=null,uv:WebGLBuffer=null,index:WebGLBuffer=null},this._drawableIndexBuffers=new Array,this._drawableUvBuffers=new Array,this._renderTargetIndexBuffer=null,this._modelRenderTargets=new Array,this._drawableMasks=new Array,this._currentFbo=null,this._drawableClippingManager=null,this._offscreenClippingManager=null,this._offscreenMasks=new Array,this._offscreenList=new Array}release(){if(this._drawableClippingManager&&(this._drawableClippingManager.release(),this._drawableClippingManager=void 0,this._drawableClippingManager=null),this.gl!=null){this.gl.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,this.gl.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,this.gl.deleteBuffer(this._bufferData.index),this._bufferData.index=null,this._bufferData=null;for(let e=0;e<this._drawableIndexBuffers.length;e++)this._drawableIndexBuffers[e]!=null&&this.gl.deleteBuffer(this._drawableIndexBuffers[e]);this._drawableIndexBuffers.length=0,this._drawableIndexBuffers=null;for(let e=0;e<this._drawableUvBuffers.length;e++)this._drawableUvBuffers[e]!=null&&this.gl.deleteBuffer(this._drawableUvBuffers[e]);this._drawableUvBuffers.length=0,this._drawableUvBuffers=null,this._renderTargetIndexBuffer!=null&&(this.gl.deleteBuffer(this._renderTargetIndexBuffer),this._renderTargetIndexBuffer=null),this._textures=null;for(let e=0;e<this._modelRenderTargets.length;e++)this._modelRenderTargets[e]!=null&&this._modelRenderTargets[e].isValid()&&this._modelRenderTargets[e].destroyRenderTarget();this._modelRenderTargets.length=0,this._modelRenderTargets=null;for(let e=0;e<this._drawableMasks.length;e++)this._drawableMasks[e]!=null&&this._drawableMasks[e].isValid()&&this._drawableMasks[e].destroyRenderTarget();this._drawableMasks.length=0,this._drawableMasks=null;for(let e=0;e<this._offscreenMasks.length;e++)this._offscreenMasks[e]!=null&&this._offscreenMasks[e].isValid()&&this._offscreenMasks[e].destroyRenderTarget();this._offscreenMasks.length=0,this._offscreenMasks=null;for(let e=0;e<this._offscreenList.length;e++)this._offscreenList[e]!=null&&this._offscreenList[e].isValid()&&this._offscreenList[e].destroyRenderTarget();this._offscreenList.length=0,this._offscreenList=null,this._offscreenClippingManager=null,this._drawableClippingManager=null,this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=null,this._sortedObjectsIndexList=null,this._sortedObjectsTypeList=null,this._currentFbo=null,this._model=null,this.gl=null}}bindDrawableIndexBuffer(e){let t=this._drawableIndexBuffers[e];t==null?(t=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this._model.getDrawableVertexIndices(e),this.gl.STATIC_DRAW),this._drawableIndexBuffers[e]=t):this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t)}bindDrawableUvBuffer(e){let t=this._drawableUvBuffers[e];t==null?(t=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t),this.gl.bufferData(this.gl.ARRAY_BUFFER,this._model.getDrawableVertexUvs(e),this.gl.STATIC_DRAW),this._drawableUvBuffers[e]=t):this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t)}bindRenderTargetIndexBuffer(){this._renderTargetIndexBuffer==null?(this._renderTargetIndexBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._renderTargetIndexBuffer),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,Xt,this.gl.STATIC_DRAW)):this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._renderTargetIndexBuffer)}loadShaders(e=null,t,r){if(this.gl==null)return Promise.reject(new Error("'gl' is null. WebGLRenderingContext is required. Please call CubismRenderer_WebGL.startUp()."));let i=$.getInstance().getShader(this.gl);return(i._shaderSets.length==0||!i._isShaderLoaded)&&(e!=null&&i.setShaderPath(e),i.setShaderSources(r)),i.generateShaders(t,this._model!=null?this._model.isBlendModeEnabled():!0)}doDrawModel(e=null){this.beforeDrawModelRenderTarget();let t=this._renderStateFbo,r=this._renderStateViewport;if(this._drawableClippingManager!=null){this.preDraw();for(let i=0;i<this._drawableClippingManager.getRenderTextureCount();++i)(this._drawableMasks[i].getBufferWidth()!=this._drawableClippingManager.getClippingMaskBufferSize()||this._drawableMasks[i].getBufferHeight()!=this._drawableClippingManager.getClippingMaskBufferSize())&&this._drawableMasks[i].createRenderTarget(this.gl,this._drawableClippingManager.getClippingMaskBufferSize(),this._drawableClippingManager.getClippingMaskBufferSize(),t);this.isUsingHighPrecisionMask()?this._drawableClippingManager.setupMatrixForHighPrecision(this.getModel(),!1):this._drawableClippingManager.setupClippingContext(this.getModel(),this,t,r,0,this._renderStateKnown)}if(this._offscreenClippingManager!=null){this.preDraw();for(let i=0;i<this._offscreenClippingManager.getRenderTextureCount();++i)(this._offscreenMasks[i].getBufferWidth()!=this._offscreenClippingManager.getClippingMaskBufferSize()||this._offscreenMasks[i].getBufferHeight()!=this._offscreenClippingManager.getClippingMaskBufferSize())&&this._offscreenMasks[i].createRenderTarget(this.gl,this._offscreenClippingManager.getClippingMaskBufferSize(),this._offscreenClippingManager.getClippingMaskBufferSize(),t);this.isUsingHighPrecisionMask()?this._offscreenClippingManager.setupMatrixForOffscreenHighPrecision(this.getModel(),!1,this.getMvpMatrix()):this._offscreenClippingManager.setupClippingContext(this.getModel(),this,t,r,1,this._renderStateKnown)}this.preDraw(),this.drawObjectLoop(t),this.afterDrawModelRenderTarget()}drawObjectLoop(e){let t=this.getModel(),r=t.getDrawableCount(),i=r+t.getOffscreenCount(),s=t.getRenderOrders();this._currentOffscreen=null,this._currentFbo=e,this._modelRootFbo=e;for(let n=0;n<i;++n){let a=s[n];n<r?(this._sortedObjectsIndexList[a]=n,this._sortedObjectsTypeList[a]=0):n<i&&(this._sortedObjectsIndexList[a]=n-r,this._sortedObjectsTypeList[a]=1)}for(let n=0;n<i;++n){let a=this._sortedObjectsIndexList[n],l=this._sortedObjectsTypeList[n];this.renderObject(a,l)}for(;this._currentOffscreen!=null;)this.submitDrawToParentOffscreen(this._currentOffscreen.getOffscreenIndex(),1)}renderObject(e,t){switch(t){case 0:this.drawDrawable(e,this._modelRootFbo);break;case 1:this.addOffscreen(e);break;default:T("Unknown object type: "+t);break}}drawDrawable(e,t){if(!this.getModel().getDrawableDynamicFlagIsVisible(e))return;this.submitDrawToParentOffscreen(e,0);let r=this._drawableClippingManager!=null?this._drawableClippingManager.getClippingContextListForDraw()[e]:null;if(r!=null&&this.isUsingHighPrecisionMask()){r._isUsing&&(this.gl.viewport(0,0,this._drawableClippingManager.getClippingMaskBufferSize(),this._drawableClippingManager.getClippingMaskBufferSize()),this.preDraw(),this.getDrawableMaskBuffer(r._bufferIndex).beginDraw(this._currentFbo),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{let i=r._clippingIdCount;for(let s=0;s<i;s++){let n=r._clippingIdList[s];this._model.getDrawableDynamicFlagVertexPositionsDidChange(n)&&(this.setIsCulling(this._model.getDrawableCulling(n)!=!1),this.setClippingContextBufferForMask(r),this.drawMeshWebGL(this._model,n))}this.getDrawableMaskBuffer(r._bufferIndex).endDraw(),this.setClippingContextBufferForMask(null),this.gl.viewport(0,0,this._modelRenderTargetWidth,this._modelRenderTargetHeight),this.preDraw()}}this.setClippingContextBufferForDrawable(r),this.setIsCulling(this.getModel().getDrawableCulling(e)),this.drawMeshWebGL(this._model,e)}drawMeshWebGL(e,t){if(this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW),this.isGeneratingMask()?$.getInstance().getShader(this.gl).setupShaderProgramForMask(this,e,t):$.getInstance().getShader(this.gl).setupShaderProgramForDrawable(this,e,t),!!$.getInstance().getShader(this.gl)._isShaderLoaded){{let r=e.getDrawableVertexIndexCount(t);this.gl.drawElements(this.gl.TRIANGLES,r,this.gl.UNSIGNED_SHORT,0)}this.setClippingContextBufferForDrawable(null),this.setClippingContextBufferForMask(null)}}submitDrawToParentOffscreen(e,t){if(this._currentOffscreen==null||e==ot)return;let r=this.getModel().getOffscreenOwnerIndices()[this._currentOffscreen.getOffscreenIndex()];if(r==ot)return;let i=-1;switch(t){case 0:i=this.getModel().getDrawableParentPartIndex(e);break;case 1:i=this.getModel().getPartParentPartIndices()[this.getModel().getOffscreenOwnerIndices()[e]];break;default:return}for(;i!=-1;){if(i==r)return;i=this.getModel().getPartParentPartIndices()[i]}this.drawOffscreen(this._currentOffscreen),this.submitDrawToParentOffscreen(e,t)}addOffscreen(e){if(this._currentOffscreen!=null&&this._currentOffscreen.getOffscreenIndex()!=e){let s=!1,n=this.getModel().getOffscreenOwnerIndices()[e],a=this.getModel().getPartParentPartIndices()[n],l=this._currentOffscreen.getOffscreenIndex(),o=this.getModel().getOffscreenOwnerIndices()[l];for(;a!=-1;){if(a==o){s=!0;break}a=this.getModel().getPartParentPartIndices()[a]}s||this.submitDrawToParentOffscreen(e,1)}let t=this._offscreenList[e];t.getRenderTexture()==null||t.getBufferWidth()!=this._modelRenderTargetWidth||t.getBufferHeight()!=this._modelRenderTargetHeight||t.getUsingRenderTextureState()?t.setOffscreenRenderTarget(this.gl,this._modelRenderTargetWidth,this._modelRenderTargetHeight,this._currentFbo):t.startUsingRenderTexture();let r=t.getParentPartOffscreen();t.setOldOffscreen(r);let i=null;r!=null&&(i=r.getRenderTexture()),i==null&&(i=this._modelRootFbo),t.beginDraw(i),this.gl.viewport(0,0,this._modelRenderTargetWidth,this._modelRenderTargetHeight),t.clear(0,0,0,0),this._currentOffscreen=t,this._currentFbo=t.getRenderTexture()}drawOffscreen(e){let t=e.getOffscreenIndex(),r=this._offscreenClippingManager!=null?this._offscreenClippingManager.getClippingContextListForOffscreen()[t]:null;if(r!=null&&this.isUsingHighPrecisionMask()){r._isUsing&&(this.gl.viewport(0,0,this._offscreenClippingManager.getClippingMaskBufferSize(),this._offscreenClippingManager.getClippingMaskBufferSize()),this.preDraw(),this.getOffscreenMaskBuffer(r._bufferIndex).beginDraw(this._currentFbo),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{let i=r._clippingIdCount;for(let s=0;s<i;s++){let n=r._clippingIdList[s];this.getModel().getDrawableDynamicFlagVertexPositionsDidChange(n)&&(this.setIsCulling(this.getModel().getDrawableCulling(n)!=!1),this.setClippingContextBufferForMask(r),this.drawMeshWebGL(this.getModel(),n))}}this.getOffscreenMaskBuffer(r._bufferIndex).endDraw(),this.setClippingContextBufferForMask(null),this.gl.viewport(0,0,this._modelRenderTargetWidth,this._modelRenderTargetHeight),this.preDraw()}this.setClippingContextBufferForOffscreen(r),this.setIsCulling(this._model.getOffscreenCulling(t)!=!1),this.drawOffscreenWebGL(this.getModel(),e)}drawOffscreenWebGL(e,t){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW),$.getInstance().getShader(this.gl).setupShaderProgramForOffscreen(this,e,t),t.endDraw(),this._currentOffscreen=this._currentOffscreen.getOldOffscreen(),this._currentFbo=t.getOldFBO(),this._currentFbo==null&&(this._currentOffscreen=this._modelRenderTargets[0],this._currentFbo=this._modelRenderTargets[0].getRenderTexture(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentFbo)),this.bindRenderTargetIndexBuffer(),this.gl.drawElements(this.gl.TRIANGLES,Xt.length,this.gl.UNSIGNED_SHORT,0),t.stopUsingRenderTexture(),this.setClippingContextBufferForMask(null),this.setClippingContextBufferForOffscreen(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}beforeDrawModelRenderTarget(){if(this._modelRenderTargets.length!=0){for(let e=0;e<this._modelRenderTargets.length;++e)(this._modelRenderTargets[e].getBufferWidth()!=this._modelRenderTargetWidth||this._modelRenderTargets[e].getBufferHeight()!=this._modelRenderTargetHeight)&&this._modelRenderTargets[e].createRenderTarget(this.gl,this._modelRenderTargetWidth,this._modelRenderTargetHeight,this._currentFbo);this._modelRenderTargets[0].beginDraw(),this._modelRenderTargets[0].clear(0,0,0,0)}}afterDrawModelRenderTarget(){this._modelRenderTargets.length!=0&&(this._modelRenderTargets[0].endDraw(),$.getInstance().getShader(this.gl).setupShaderProgramForOffscreenRenderTarget(this),$.getInstance().getShader(this.gl)._isShaderLoaded&&(this.bindRenderTargetIndexBuffer(),this.gl.drawElements(this.gl.TRIANGLES,Xt.length,this.gl.UNSIGNED_SHORT,0)))}getOffscreenMaskBuffer(e){return this._offscreenMasks[e]}static doStaticRelease(){$.deleteInstance()}setRenderState(e,t){this._renderStateFbo=e,this._renderStateKnown=!0,this._renderStateViewport[0]=t[0],this._renderStateViewport[1]=t[1],this._renderStateViewport[2]=t[2],this._renderStateViewport[3]=t[3],this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e),this.gl.viewport(t[0],t[1],t[2],t[3]),(this._modelRenderTargetWidth!=t[2]||this._modelRenderTargetHeight!=t[3])&&(this._modelRenderTargetWidth=t[2],this._modelRenderTargetHeight=t[3])}preDraw(){if(this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(let e=0;e<this._textures.size;++e)this.gl.bindTexture(this.gl.TEXTURE_2D,this._textures.get(e)),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}getDrawableMaskBuffer(e){return this._drawableMasks[e]}setClippingContextBufferForMask(e){this._clippingContextBufferForMask=e}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDrawable(e){this._clippingContextBufferForDraw=e}getClippingContextBufferForDrawable(){return this._clippingContextBufferForDraw}setClippingContextBufferForOffscreen(e){this._clippingContextBufferForOffscreen=e}getClippingContextBufferForOffscreen(){return this._clippingContextBufferForOffscreen}isGeneratingMask(){return this.getClippingContextBufferForMask()!=null}startUp(e){if(this.gl=e,this._drawableClippingManager&&this._drawableClippingManager.setGL(e),this._offscreenClippingManager&&this._offscreenClippingManager.setGL(e),$.getInstance().setGlContext(e),this._rendererProfile.setGl(e),this._extension=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),this._model.isUsingMasking()){this._drawableMasks.length=this._drawableClippingManager.getRenderTextureCount();for(let t=0;t<this._drawableMasks.length;++t){let r=new pe;r.createRenderTarget(this.gl,this._drawableClippingManager.getClippingMaskBufferSize(),this._drawableClippingManager.getClippingMaskBufferSize(),this._currentFbo),this._drawableMasks[t]=r}}if(this._model.isBlendModeEnabled()){this._modelRenderTargets.length=0;let t=3;this._modelRenderTargets.length=t;for(let i=0;i<t;++i){let s=new Zi;s.createRenderTarget(this.gl,this._modelRenderTargetWidth,this._modelRenderTargetHeight,this._currentFbo),this._modelRenderTargets[i]=s}if(this._model.isUsingMaskingForOffscreen()){this._offscreenMasks.length=this._offscreenClippingManager.getRenderTextureCount();for(let i=0;i<this._offscreenMasks.length;++i){let s=new pe;s.createRenderTarget(this.gl,this._offscreenClippingManager.getClippingMaskBufferSize(),this._offscreenClippingManager.getClippingMaskBufferSize(),this._currentFbo),this._offscreenMasks[i]=s}}let r=this._model.getOffscreenCount();if(r>0){this._offscreenList=new Array(r);for(let i=0;i<r;++i){let s=new Zi;s.setOffscreenIndex(i),this._offscreenList[i]=s}this.setupParentOffscreens(this._model,r)}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentFbo)}_textures;_sortedObjectsIndexList;_sortedObjectsTypeList;_rendererProfile;_drawableClippingManager;_clippingContextBufferForMask;_clippingContextBufferForDraw;_clippingContextBufferForOffscreen;_offscreenClippingManager;_modelRenderTargets;_drawableMasks;_offscreenMasks;_offscreenList;_currentFbo;_currentOffscreen;_modelRootFbo;_renderStateFbo=null;_renderStateKnown=!1;_renderStateViewport=[0,0,0,0];_bufferData;_drawableIndexBuffers;_drawableUvBuffers;_renderTargetIndexBuffer;_extension;gl};mt.staticRelease=()=>{dr.doStaticRelease()};(function(e){e.CubismClippingContext=$s,e.CubismClippingManager_WebGL=dt,e.CubismRenderer_WebGL=dr})(es||(es={}));tr=class en{static create(t,r){let i=null;if(r&&!this.hasMocConsistency(t))return T("Inconsistent MOC3."),i;let s=Live2DCubismCore.Moc.fromArrayBuffer(t);return s&&(i=new en(s),i._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(t)),i}static delete(t){t._moc._release(),t._moc=null,t=null}createModel(){let t=null,r=Live2DCubismCore.Model.fromMoc(this._moc);return r&&(t=new bs(r),t.initialize(),++this._modelCount),t}deleteModel(t){t!=null&&(t.release(),t=null,--this._modelCount)}constructor(t){this._moc=t,this._modelCount=0,this._mocVersion=0}release(){U(this._modelCount==0),this._moc._release(),this._moc=null}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static getMocVersionFromBuffer(t){return Live2DCubismCore.Version.csmGetMocVersion(t)}static hasMocConsistency(t){return Live2DCubismCore.Moc.prototype.hasMocConsistency(t)===1}_moc;_modelCount;_mocVersion};(function(e){e.CubismMoc=tr})(ts||(ts={}));rs="Meta",qo="UserDataCount",Zo="TotalUserDataSize",Ht="UserData",Ko="Target",$o="Id",el="Value",tn=class{constructor(e,t){this._json=H.create(e,t)}release(){H.delete(this._json)}getUserDataCount(){return this._json.getRoot().getValueByString(rs).getValueByString(qo).toInt()}getTotalUserDataSize(){return this._json.getRoot().getValueByString(rs).getValueByString(Zo).toInt()}getUserDataTargetType(e){return this._json.getRoot().getValueByString(Ht).getValueByIndex(e).getValueByString(Ko).getRawString()}getUserDataId(e){return P.getIdManager().getId(this._json.getRoot().getValueByString(Ht).getValueByIndex(e).getValueByString($o).getRawString())}getUserDataValue(e){return this._json.getRoot().getValueByString(Ht).getValueByIndex(e).getValueByString(el).getRawString()}_json};(function(e){e.CubismModelUserDataJson=tn})(is||(is={}));tl="ArtMesh",rn=class{targetType;targetId;value},rr=class sn{static create(t,r){let i=new sn;return i.parseUserData(t,r),i}static delete(t){t!=null&&(t.release(),t=null)}getArtMeshUserDatas(){return this._artMeshUserDataNode}parseUserData(t,r){let i=new tn(t,r);if(!i){i.release(),i=void 0;return}let s=P.getIdManager().getId(tl),n=i.getUserDataCount(),a=this._userDataNodes.length;this._userDataNodes.length=n;for(let l=0;l<n;l++){let o=new rn;o.targetId=i.getUserDataId(l),o.targetType=P.getIdManager().getId(i.getUserDataTargetType(l)),o.value=i.getUserDataValue(l),this._userDataNodes[a++]=o,o.targetType==s&&this._artMeshUserDataNode.push(o)}i.release(),i=void 0}constructor(){this._userDataNodes=new Array,this._artMeshUserDataNode=new Array}release(){for(let t=0;t<this._userDataNodes.length;++t)this._userDataNodes[t]=null;this._userDataNodes=null}_userDataNodes;_artMeshUserDataNode};(function(e){e.CubismModelUserData=rr,e.CubismModelUserDataNode=rn})(ss||(ss={}));nn=class an{isInitialized(){return this._initialized}setInitialized(t){this._initialized=t}isUpdating(){return this._updating}setUpdating(t){this._updating=t}setDragging(t,r){this._dragManager.set(t,r)}getModelMatrix(){return this._modelMatrix}setRenderTargetSize(t,r){this._renderer&&this._renderer.setRenderTargetSize(t,r)}setOpacity(t){this._opacity=t}getOpacity(){return this._opacity}loadModel(t,r=!1){if(this._moc=tr.create(t,r),this._moc==null){T("Failed to CubismMoc.create().");return}if(this._model=this._moc.createModel(),this._model==null){T("Failed to CreateModel().");return}this._model.saveParameters(),this._modelMatrix=new or(this._model.getCanvasWidth(),this._model.getCanvasHeight())}loadMotion(t,r,i,s,n,a,l,o,u=!1){if(t==null||r==0)return T("Failed to loadMotion()."),null;let c=Qs.create(t,r,s,n,u);if(c==null)return T("Failed to create motion from buffer in LoadMotion()"),null;if(a){let g=a.getMotionFadeInTimeValue(l,o);g>=0&&c.setFadeInTime(g);let h=a.getMotionFadeOutTimeValue(l,o);h>=0&&c.setFadeOutTime(h)}return c}loadExpression(t,r,i){return t==null||r==0?(T("Failed to loadExpression()."),null):Te.create(t,r)}loadPose(t,r){if(t==null||r==0){T("Failed to loadPose().");return}this._pose=jt.create(t,r)}loadUserData(t,r){if(t==null||r==0){T("Failed to loadUserData().");return}this._modelUserData=rr.create(t,r)}loadPhysics(t,r){if(t==null||r==0){T("Failed to loadPhysics().");return}this._physics=$t.create(t,r)}isHit(t,r,i){let s=this._model.getDrawableIndex(t);if(s<0)return!1;let n=this._model.getDrawableVertexCount(s),a=this._model.getDrawableVertices(s),l=a[0],o=a[0],u=a[1],c=a[1];for(let d=1;d<n;++d){let f=a[te.vertexOffset+d*te.vertexStep],p=a[te.vertexOffset+d*te.vertexStep+1];f<l&&(l=f),f>o&&(o=f),p<u&&(u=p),p>c&&(c=p)}let g=this._modelMatrix.invertTransformX(r),h=this._modelMatrix.invertTransformY(i);return l<=g&&g<=o&&u<=h&&h<=c}getModel(){return this._model}getMocVersionFromBuffer(t){return tr.getMocVersionFromBuffer(t)}getRenderer(){return this._renderer}createRenderer(t,r,i=1){this._renderer&&this.deleteRenderer(),this._renderer=new dr(t,r),this._renderer.initialize(this._model,i)}deleteRenderer(){this._renderer!=null&&(this._renderer.release(),this._renderer=null)}motionEventFired(t){ge("{0}",t)}static cubismDefaultMotionEventCallback(t,r,i){let s=i;s?.motionEventFired(r)}constructor(){this._moc=null,this._model=null,this._motionManager=null,this._expressionManager=null,this._eyeBlink=null,this._breath=null,this._modelMatrix=null,this._pose=null,this._dragManager=null,this._physics=null,this._modelUserData=null,this._initialized=!1,this._updating=!1,this._opacity=1,this._mocConsistency=!1,this._debugMode=!1,this._renderer=null,this._motionManager=new Ns,this._motionManager.setEventCallback(an.cubismDefaultMotionEventCallback,this),this._expressionManager=new vs,this._dragManager=new xs}release(){this._motionManager!=null&&(this._motionManager.release(),this._motionManager=null),this._expressionManager!=null&&(this._expressionManager.release(),this._expressionManager=null),this._moc!=null&&(this._moc.deleteModel(this._model),this._moc.release(),this._moc=null),this._modelMatrix=null,jt.delete(this._pose),ar.delete(this._eyeBlink),nr.delete(this._breath),this._dragManager=null,$t.delete(this._physics),rr.delete(this._modelUserData),this.deleteRenderer()}_moc;_model;_motionManager;_expressionManager;_eyeBlink;_breath;_modelMatrix;_pose;_dragManager;_physics;_modelUserData;_initialized;_updating;_opacity;_mocConsistency;_motionConsistency;_debugMode;_renderer};(function(e){e.CubismUserModel=nn})(ns||(ns={}));fe=class{static sortFunction(e,t){if(!e||!t){if(!e&&!t)return 0;if(!e)return 1;if(!t)return-1}return e.getExecutionOrder()-t.getExecutionOrder()}_executionOrder;_changeListeners=[];constructor(e=0){this._executionOrder=e}getExecutionOrder(){return this._executionOrder}setExecutionOrder(e){this._executionOrder!==e&&(this._executionOrder=e,this.notifyChangeListeners())}addChangeListener(e){e&&this._changeListeners.indexOf(e)===-1&&this._changeListeners.push(e)}removeChangeListener(e){let t=this._changeListeners.indexOf(e);t>=0&&this._changeListeners.splice(t,1)}notifyChangeListeners(){for(let e of this._changeListeners)e.onUpdaterChanged(this)}};(function(e){e.ICubismUpdater=fe})(as||(as={}));on=class extends fe{_breath;constructor(e,t){super(t??500),this._breath=e}onLateUpdate(e,t){e&&this._breath.updateParameters(e,t)}};(function(e){e.CubismBreathUpdater=on})(os||(os={}));ln=class extends fe{_expressionManager;constructor(e,t){super(t??300),this._expressionManager=e}onLateUpdate(e,t){e&&this._expressionManager.updateMotion(e,t)}};(function(e){e.CubismExpressionUpdater=ln})(ls||(ls={}));un=class extends fe{_motionUpdated;_eyeBlink;constructor(e,t,r){super(r??200),this._motionUpdated=e,this._eyeBlink=t}onLateUpdate(e,t){e&&(this._motionUpdated()||this._eyeBlink.updateParameters(e,t))}};(function(e){e.CubismEyeBlinkUpdater=un})(us||(us={}));hn=class extends fe{_look;_dragManager;constructor(e,t,r){super(r??400),this._look=e,this._dragManager=t}onLateUpdate(e,t){if(!e)return;this._dragManager.update(t);let r=this._dragManager.getX(),i=this._dragManager.getY();this._look.updateParameters(e,r,i)}};(function(e){e.CubismLookUpdater=hn})(hs||(hs={}));cn=class extends fe{_physics;constructor(e,t){super(t??600),this._physics=e}onLateUpdate(e,t){e&&this._physics.evaluate(e,t)}};(function(e){e.CubismPhysicsUpdater=cn})(cs||(cs={}));dn=class extends fe{_pose;constructor(e,t){super(t??800),this._pose=e}onLateUpdate(e,t){e&&this._pose.updateParameters(e,t)}};(function(e){e.CubismPoseUpdater=dn})(ds||(ds={}));gn=class{_cubismUpdatableList;_needsSort;constructor(){this._cubismUpdatableList=[],this._needsSort=!1}release(){for(let e of this._cubismUpdatableList)e&&e.removeChangeListener(this);this._cubismUpdatableList.length=0}addUpdatableList(e){e&&(this.hasUpdatable(e)||(this._cubismUpdatableList.push(e),e.addChangeListener(this),this._needsSort=!0))}removeUpdatableList(e){if(!e)return!1;let t=this._cubismUpdatableList.indexOf(e);return t>=0?(this._cubismUpdatableList.splice(t,1),e.removeChangeListener(this),!0):!1}sortUpdatableList(){this._cubismUpdatableList.sort(fe.sortFunction),this._needsSort=!1}onLateUpdate(e,t){if(e){this._needsSort&&this.sortUpdatableList();for(let r=0;r<this._cubismUpdatableList.length;++r){let i=this._cubismUpdatableList[r];i&&i.onLateUpdate(e,t)}}}getUpdatableCount(){return this._cubismUpdatableList.length}getUpdatable(e){return e<0||e>=this._cubismUpdatableList.length?null:this._cubismUpdatableList[e]}hasUpdatable(e){return this._cubismUpdatableList.indexOf(e)>=0}clearUpdatableList(){for(let e of this._cubismUpdatableList)e&&e.removeChangeListener(this);this._cubismUpdatableList.length=0,this._needsSort=!1}onUpdaterChanged(e){this._needsSort=!0}};(function(e){e.CubismUpdateScheduler=gn})(gs||(gs={}));lt=0;ll=class{disposed=!1;failure;pending=new Map;track(e){return this.failure?Promise.reject(this.failure):this.disposed?Promise.resolve({status:"disposed"}):new Promise((t,r)=>{this.pending.set(e,{reason:"completed",reject:r,resolve:t})})}interruptActive(){for(let e of this.pending.values())e.reason="interrupted"}settleFinished(e){for(let[t,r]of[...this.pending])e(t)&&(this.pending.delete(t),r.resolve({status:r.reason}))}fail(e){this.failure??=e;for(let t of this.takeAll())t.reject(this.failure)}dispose(){if(!this.disposed){this.disposed=!0;for(let e of this.takeAll())e.resolve({status:"disposed"})}}takeAll(){let e=[...this.pending.values()];return this.pending.clear(),e}},We=new Map;cl=1,dl=3,gl=1e3,ps={force:3,idle:1,normal:2};fl=550,Al=class extends fe{callbacks;constructor(e){super(fl),this.callbacks=e}onLateUpdate(e,t){for(let r of this.callbacks)r(t*1e3)}},pl=class extends nn{stage;modelUrl;setting;shaderBaseUrl;shaderSources;idleMotion;releaseFramework;model3Version;diagnostics;resolveAsset;afterMotionCallbacks=new Set;beforePhysicsCallbacks=new Set;assetController=new AbortController;expressionCache=new Map;loadedMotions=new Set;layoutMatrix;manualParameters=new Map;mvpMatrix;motionCache=new Map;motionStates=new ll;parameterIds=new Map;renderContext;releaseRenderContext;renderError;stopErrorWatch;pendingExpressionKeys=new Set;pendingMotionKeys=new Set;scheduler=new gn;textures=[];viewport=[0,0,1,1];bounds={centerX:0,centerY:0,height:1,width:1};detachDriver;disposed=!1;expressionGeneration=0;eyeBlinkIds=[];idlePending=!1;look;mvpDirty=!0;motionUpdated=!1;motionGeneration=0;transform={scale:1,x:0,y:0};constructor(e,t,r,i,s,n,a,l,o,u){super(),this.stage=e,this.modelUrl=t,this.setting=r,this.shaderBaseUrl=i,this.shaderSources=s,this.idleMotion=n,this.releaseFramework=a,this.model3Version=l,this.diagnostics=o,this.resolveAsset=u}parameterId(e){let t=this.parameterIds.get(e);if(t)return t;let r=P.getIdManager().getId(e);return this.parameterIds.set(e,r),r}async initialize(e){let t=()=>this.assetController.abort(e?.reason);e?.aborted&&t(),e?.addEventListener("abort",t,{once:!0});try{let r=this.setting.getModelFileName();if(!r)throw new m("model-load-failed","model3.json does not declare FileReferences.Moc.",{details:ne("model3",this.modelUrl)});let i=re(r,this.modelUrl),s=await Ce(this.diagnostics,"mocFetch",()=>he(i,"moc3",this.assetController.signal,this.resolveAsset));try{Z(this.diagnostics,"load","mocParse",()=>this.loadModel(s,!0))}catch(l){throw new m("model-load-failed",`Failed to parse moc3 asset ${i}.`,{cause:l,details:ne("moc3",i)})}if(!this.getModel())throw new m("model-load-failed","Cubism Core rejected the moc3 model.",{details:ne("moc3",i)});this.layoutMatrix=new or(this.getModel().getCanvasWidth(),this.getModel().getCanvasHeight());let n=new Map;this.setting.getLayoutMap(n),this.layoutMatrix.setupFromLayout(n),this.bounds=nl({height:this.getModel().getCanvasHeight(),width:this.getModel().getCanvasWidth()},this.layoutMatrix),await Ce(this.diagnostics,"optionalAssets",()=>this.loadOptionalAssets()),this.setupEffects(),await this.setupRenderer(),this.getModel().saveParameters();let a=we(this.stage);this.detachDriver=a.attachDriver({draw:()=>this.draw(),resize:(l,o)=>this.resize(l,o),update:l=>this.updateFrame(l)}),this.stopErrorWatch=this.stage.onError(l=>this.failMotions(l)),this.prefetchIdleMotions()}finally{e?.removeEventListener("abort",t)}}async prefetchIdleMotions(){if(await new Promise(t=>{let r,i=()=>{clearTimeout(r),t()};r=setTimeout(()=>{this.assetController.signal.removeEventListener("abort",i),t()},gl),this.assetController.signal.addEventListener("abort",i,{once:!0})}),this.disposed||this.idleMotion===!1)return;let e=this.setting.getMotionCount(this.idleMotion.group);for(let t=0;t<e;t++){if(this.disposed)return;try{await this.loadMotionAsset(this.idleMotion.group,t)}catch{}}}async loadOptionalAssets(){let e=this.assetController.signal,t=this.setting.getPhysicsFileName(),r=this.setting.getPoseFileName(),i=this.setting.getUserDataFile(),s=t?re(t,this.modelUrl):void 0,n=r?re(r,this.modelUrl):void 0,a=i?re(i,this.modelUrl):void 0,[l,o,u]=await Promise.all([s?he(s,"physics",e,this.resolveAsset):void 0,n?he(n,"pose",e,this.resolveAsset):void 0,a?he(a,"user-data",e,this.resolveAsset):void 0]);try{l&&this.loadPhysics(l,l.byteLength)}catch(c){throw new m("model-load-failed",`Failed to parse physics asset ${s}.`,{cause:c,details:ne("physics",s)})}try{o&&this.loadPose(o,o.byteLength)}catch(c){throw new m("model-load-failed",`Failed to parse pose asset ${n}.`,{cause:c,details:ne("pose",n)})}try{u&&this.loadUserData(u,u.byteLength)}catch(c){throw new m("model-load-failed",`Failed to parse user data asset ${a}.`,{cause:c,details:ne("user-data",a)})}}setupEffects(){this.eyeBlinkIds=Array.from({length:this.setting.getEyeBlinkParameterCount()},(e,t)=>this.setting.getEyeBlinkParameterId(t)),this.eyeBlinkIds.length>0&&(this._eyeBlink=ar.create(this.setting),this.scheduler.addUpdatableList(new un(()=>this.motionUpdated,this._eyeBlink,300))),this._breath=nr.create(),this._breath.setParameters([new De(this.parameterId(M.ParamAngleX),0,15,6.5345,.5),new De(this.parameterId(M.ParamAngleY),0,8,3.5345,.5),new De(this.parameterId(M.ParamAngleZ),0,10,5.5345,.5),new De(this.parameterId(M.ParamBodyAngleX),0,4,15.5345,.5),new De(this.parameterId(M.ParamBreath),.5,.5,3.2345,1)]),this.scheduler.addUpdatableList(new on(this._breath)),this._physics&&this.scheduler.addUpdatableList(new cn(this._physics)),this._pose&&this.scheduler.addUpdatableList(new dn(this._pose)),this._expressionManager&&this.scheduler.addUpdatableList(new ln(this._expressionManager,200)),this.look=Jt.create(),this.look.setParameters([new Ie(this.parameterId(M.ParamAngleX),30,0,0),new Ie(this.parameterId(M.ParamAngleY),0,30,0),new Ie(this.parameterId(M.ParamAngleZ),0,0,-30),new Ie(this.parameterId(M.ParamBodyAngleX),10,0,0),new Ie(this.parameterId(M.ParamEyeBallX),1,0,0),new Ie(this.parameterId(M.ParamEyeBallY),0,1,0)]),this.scheduler.addUpdatableList(new hn(this.look,this._dragManager)),this.scheduler.addUpdatableList(new Al(this.beforePhysicsCallbacks)),this.scheduler.sortUpdatableList()}async setupRenderer(){let{canvas:e,gl:t}=we(this.stage);this.renderContext=t,this.releaseRenderContext=hl(t),this.createRenderer(e.width,e.height);let r=this.getRenderer();r.startUp(t),r.setIsPremultipliedAlpha(!0);let i=[];for(let a=0;a<this.setting.getTextureCount();a++){let l=this.setting.getTextureFileName(a);if(!l)throw new m("model-load-failed",`model3.json declares an empty texture at index ${a}.`,{details:ne("texture",this.modelUrl)});i.push(re(l,this.modelUrl))}let s=i.map(a=>Yr(a,this.assetController.signal,this.diagnostics,this.resolveAsset));for(let a of s)a.catch(()=>{});let n=async()=>{await Promise.allSettled(s.map(async a=>Ne(await a)))};try{await Ce(this.diagnostics,"shaderSetup",()=>r.loadShaders(this.shaderBaseUrl,this.assetController.signal,this.shaderSources))}catch(a){throw await n(),a instanceof m?a:new m("render-error",a instanceof Error?a.message:"Cubism shader loading failed.",{cause:a,details:rl(a)})}try{for(let a=0;a<s.length;a++){let l=await s[a];if(this.assetController.signal.aborted)throw Ne(l),this.assetController.signal.reason;let o=zr(t,l,i[a],this.diagnostics);this.textures.push(o),this.diagnostics?.changeResource("texture",1),r.bindTexture(a,o)}}catch(a){throw await n(),a}}updateFrame(e){if(this.disposed)return;let t=e/1e3;if(!this.diagnostics){this.getModel().loadParameters(),this.motionUpdated=!1,this._motionManager.isFinished()?this.scheduleIdle():this.motionUpdated=this._motionManager.updateMotion(this.getModel(),this.motionSync?.update(t)??t),this.getModel().saveParameters(),this.settleFinishedMotions(),this.scheduler.onLateUpdate(this.getModel(),t);for(let[r,i]of this.manualParameters)this.getModel().setParameterValueById(this.parameterId(r),i);for(let r of this.afterMotionCallbacks)r(e);this.getModel().update();return}Z(this.diagnostics,"frame","motion",()=>{this.getModel().loadParameters(),this.motionUpdated=!1,this._motionManager.isFinished()?this.scheduleIdle():this.motionUpdated=this._motionManager.updateMotion(this.getModel(),this.motionSync?.update(t)??t),this.getModel().saveParameters()}),this.settleFinishedMotions(),Z(this.diagnostics,"frame","effectsPhysicsPose",()=>{this.scheduler.onLateUpdate(this.getModel(),t)}),Z(this.diagnostics,"frame","manualParameters",()=>{for(let[r,i]of this.manualParameters)this.getModel().setParameterValueById(this.parameterId(r),i)}),Z(this.diagnostics,"frame","externalDrivers",()=>{for(let r of this.afterMotionCallbacks)r(e)}),Z(this.diagnostics,"frame","coreUpdate",()=>{this.getModel().update()})}scheduleIdle(){if(this.idleMotion===!1||this.idlePending)return;let{group:e,weights:t}=this.idleMotion,r=this.setting.getMotionCount(e);r!==0&&(this.idlePending=!0,this.playMotion(e,Tr(r,t),cl).catch(i=>{this.disposed||we(this.stage).reportError(fn(i,"Idle motion failed"))}).finally(()=>{this.idlePending=!1}))}async ensureAssetBuffer(e){return await al(e,()=>he(e.url,e.type,this.assetController.signal,this.resolveAsset)),e}async loadMotionAsset(e,t){let r=`${e}:${t}`,i=this.motionCache.get(r);if(i)return i;let s=(async()=>{this.pendingMotionKeys.add(r),this.diagnostics?.changeResource("pendingMotion",1);try{let n=re(this.setting.getMotionFileName(e,t),this.modelUrl),a=await he(n,"motion",this.assetController.signal,this.resolveAsset),l=this.parseMotion(a,r,e,t,n);return this.loadedMotions.add(l),{motion:l,type:"motion",url:n}}finally{this.pendingMotionKeys.delete(r)&&this.diagnostics?.changeResource("pendingMotion",-1)}})();return this.motionCache.set(r,s),s.catch(()=>this.motionCache.delete(r)),s}parseMotion(e,t,r,i,s=re(this.setting.getMotionFileName(r,i),this.modelUrl)){let n=this.loadMotion(e,e.byteLength,t,void 0,void 0,this.setting,r,i,!0);if(!n)throw new m("model-load-failed",`Failed to parse motion ${t}.`,{details:ne("motion",s)});return n.setEffectIds(this.eyeBlinkIds,[]),n}motionGroupNames(){return Array.from({length:this.setting.getMotionGroupCount()},(e,t)=>this.setting.getMotionGroupName(t))}failMotions(e){this.renderError??=e,this.motionStates.fail(this.renderError)}settleFinishedMotions(){this.motionStates.settleFinished(e=>this._motionManager.isFinishedByHandle(e))}async playMotion(e,t,r,i={},s){if(this.disposed)return{status:"disposed"};if(this.renderError)throw this.renderError;let n=this.setting.getMotionCount(e);if(n===0)throw new m("invalid-props",`Unknown Live2D motion group: ${e}. Available groups: ${this.motionGroupNames().join(", ")||"(none)"}`);let a=t??Math.floor(Math.random()*n);if(!Number.isInteger(a)||a<0||a>=n)throw new m("invalid-props",`Motion index ${a} is outside group ${e} (0-${n-1}).`);if(r===dl)this._motionManager.setReservePriority(r);else if(!this._motionManager.reserveMotion(r))return{status:"skipped"};let l=++this.motionGeneration,o,u,c;try{let d=this.loadMotionAsset(e,a),f;if(s){let p=new Promise((A,_)=>{c=()=>_(s.signal.reason),s.signal.addEventListener("abort",c,{once:!0}),s.signal.aborted&&c()});[f]=await Promise.race([Promise.all([d,s.ready]),p])}else f=await d;if(this.disposed)return{status:"disposed"};if(l!==this.motionGeneration)return{status:"skipped"};if(et(i)){if(await this.ensureAssetBuffer(f),this.disposed)return{status:"disposed"};if(l!==this.motionGeneration)return{status:"skipped"}}if(s?.signal.throwIfAborted(),u=As(f,i,p=>this.parseMotion(p,`${e}:${a}`,e,a),p=>Se.delete(p)),o=this._motionManager.startMotionPriority(u.motion,u.autoDelete,r),o===-1)return u.releaseBeforeStart(),{status:"skipped"};u.transferToQueue(),this.motionStates.interruptActive()}catch(d){if(u?.releaseBeforeStart(),this.disposed)return{status:"disposed"};throw l===this.motionGeneration&&this._motionManager.setReservePriority(0),d}finally{c&&s.signal.removeEventListener("abort",c)}this.motionSync=s;let g=this.motionStates.track(o);if(!s)return g;let h=()=>{this.disposed||this.motionSync!==s||(this.motionSync=void 0,this._motionManager.stopAllMotions(),this.motionStates.interruptActive())};s.signal.addEventListener("abort",h,{once:!0});try{return await g}finally{s.signal.removeEventListener("abort",h),this.motionSync===s&&(this.motionSync=void 0)}}hitTestStagePoint(e,t){if(this.disposed||!this.layoutMatrix)return[];(!this.mvpMatrix||this.mvpDirty)&&(this.mvpMatrix=fs(this.stage.getSize(),this.transform,this.layoutMatrix,this.bounds));let r=this.stage.getSize(),i=e/Math.max(1,r.width)*2-1,s=1-t/Math.max(1,r.height)*2,n=this.mvpMatrix.invertTransformX(i),a=this.mvpMatrix.invertTransformY(s),l=[];for(let o=0;o<this.setting.getHitAreasCount();o++){let u=this.getModel().getDrawableIndex(this.setting.getHitAreaId(o));if(u<0||this.getModel().getDrawableOpacity(u)<=0)continue;let c=this.getModel().getDrawableVertexCount(u),g=this.getModel().getDrawableVertices(u);if(c===0)continue;let h=g[0],d=g[0],f=g[1],p=g[1];for(let A=1;A<c;A++){let _=g[A*2],b=g[A*2+1];h=Math.min(h,_),d=Math.max(d,_),f=Math.min(f,b),p=Math.max(p,b)}n>=h&&n<=d&&a>=f&&a<=p&&l.push(this.setting.getHitAreaName(o))}return l}readModelInfo(){let e={};for(let t of this.motionGroupNames())e[t]=this.setting.getMotionCount(t);return{expressions:Array.from({length:this.setting.getExpressionCount()},(t,r)=>this.setting.getExpressionName(r)),hitAreas:Array.from({length:this.setting.getHitAreasCount()},(t,r)=>this.setting.getHitAreaName(r)),motions:e,model3Version:this.model3Version,mocVersion:this._moc?.getMocVersion(),parameters:Array.from({length:this.getModel().getParameterCount()},(t,r)=>({defaultValue:this.getModel().getParameterDefaultValue(r),id:this.getModel().getParameterId(r).getString(),maximum:this.getModel().getParameterMaximumValue(r),minimum:this.getModel().getParameterMinimumValue(r)}))}}findExpression(e){for(let t=0;t<this.setting.getExpressionCount();t++)if(this.setting.getExpressionName(t)===e)return t;return-1}async loadExpressionAsset(e,t){let r=this.expressionCache.get(e);if(r)return r;let i=(async()=>{this.pendingExpressionKeys.add(e),this.diagnostics?.changeResource("pendingExpression",1);try{let s=re(this.setting.getExpressionFileName(t),this.modelUrl),n=await he(s,"expression",this.assetController.signal,this.resolveAsset),a=this.parseExpression(n,e,s);return this.loadedMotions.add(a),{motion:a,type:"expression",url:s}}finally{this.pendingExpressionKeys.delete(e)&&this.diagnostics?.changeResource("pendingExpression",-1)}})();return this.expressionCache.set(e,i),i.catch(()=>this.expressionCache.delete(e)),i}parseExpression(e,t,r=re(this.setting.getExpressionFileName(this.findExpression(t)),this.modelUrl)){let i=this.loadExpression(e,e.byteLength,t);if(!i)throw new m("model-load-failed",`Failed to parse expression ${t}.`,{details:ne("expression",r)});return i}async playExpression(e,t,r){let i=++this.expressionGeneration,s;try{let n=await this.loadExpressionAsset(e,t);if(this.disposed||i!==this.expressionGeneration||et(r)&&(await this.ensureAssetBuffer(n),this.disposed||i!==this.expressionGeneration))return;if(s=As(n,r,a=>this.parseExpression(a,e),a=>Se.delete(a)),this._expressionManager.startMotion(s.motion,s.autoDelete)===-1){s.releaseBeforeStart();return}s.transferToQueue()}catch(n){if(s?.releaseBeforeStart(),!this.disposed)throw n}}draw(){if(this.disposed)return;let{gl:e}=we(this.stage),t=cr.getInstance();t.beginFrameProcess(e);try{let r=this.getRenderer();if(r.setRenderState(null,this.viewport),!this.layoutMatrix)return;(this.mvpDirty||!this.mvpMatrix)&&(this.mvpMatrix=fs(this.stage.getSize(),this.transform,this.layoutMatrix,this.bounds),this.mvpDirty=!1,r.setMvpMatrix(this.mvpMatrix)),r.drawModel(this.shaderBaseUrl)}finally{t.endFrameProcess(e),t.releaseStaleRenderTextures(e)}}resize(e,t){this.viewport[2]=e,this.viewport[3]=t,this.mvpDirty=!0,this.setRenderTargetSize(e,t)}toHandle(){return{clearExpression:()=>{this.disposed||(this.expressionGeneration++,this._expressionManager.stopAllMotions())},clearParameter:e=>{this.manualParameters.delete(e)},dispose:()=>this.disposeModel(),expression:async(e,t)=>{let r=Or(t),i=this.setting.getExpressionCount();if(i===0){if(e)throw new m("invalid-props",`Unknown Live2D expression: ${e}`);return}let s=e??this.setting.getExpressionName(Math.floor(Math.random()*i)),n=this.findExpression(s);if(n<0)throw new m("invalid-props",`Unknown Live2D expression: ${s}. Available: ${this.readModelInfo().expressions.join(", ")}`);await this.playExpression(s,n,r)},focus:(e,t)=>{let r=this.stage.getSize();this.setDragging(Math.max(-1,Math.min(1,e/Math.max(1,r.width)*2-1)),Math.max(-1,Math.min(1,1-t/Math.max(1,r.height)*2)))},getIntrinsicSize:()=>({height:this.bounds.height,width:this.bounds.width}),getModelInfo:()=>this.readModelInfo(),getParameter:e=>this.getModel().getParameterValueById(this.parameterId(e)),hitTest:(e,t)=>this.hitTestStagePoint(e,t),isMotionPlaying:()=>!this.disposed&&!this._motionManager.isFinished(),motion:async(e,t,r)=>{Ue(r);let i=$e(r);await this.playMotion(e,t,ps[r?.priority??"force"],i)},playMotion:(e,t,r)=>{Ue(r);let i=$e(r);return this.playMotion(e,t,ps[r?.priority??"force"],i,r?.sync)},onAfterMotionUpdate:e=>(this.afterMotionCallbacks.add(e),ms(()=>this.afterMotionCallbacks.delete(e))),onBeforePhysicsUpdate:e=>(this.beforePhysicsCallbacks.add(e),ms(()=>this.beforePhysicsCallbacks.delete(e))),setParameter:(e,t)=>{this.disposed||(this.manualParameters.set(e,t),this.getModel().setParameterValueById(this.parameterId(e),t))},setTransform:e=>{this.transform={...e},this.mvpDirty=!0}}}disposeModel(){if(this.disposed)return;this.disposed=!0,this.motionGeneration++,this.expressionGeneration++,this.assetController.abort(new DOMException("Model disposed","AbortError"));for(let t=this.pendingMotionKeys.size;t>0;t--)this.diagnostics?.changeResource("pendingMotion",-1);this.pendingMotionKeys.clear();for(let t=this.pendingExpressionKeys.size;t>0;t--)this.diagnostics?.changeResource("pendingExpression",-1);this.pendingExpressionKeys.clear(),this.motionStates.dispose(),this.detachDriver?.(),this.detachDriver=void 0,this.stopErrorWatch?.(),this.stopErrorWatch=void 0,this.afterMotionCallbacks.clear(),this.beforePhysicsCallbacks.clear(),this.scheduler.release(),this.look&&Jt.delete(this.look),this.look=void 0;let e=this.renderContext;this.renderContext=void 0;try{if(e)for(let t of this.textures)e.deleteTexture(t);for(let t=0;t<this.textures.length;t++)this.diagnostics?.changeResource("texture",-1);this.textures.length=0,this.motionCache.clear(),this.expressionCache.clear(),this.manualParameters.clear(),this.setting.release(),super.release();for(let t of this.loadedMotions)Se.delete(t);this.loadedMotions.clear(),this.releaseRenderContext?.(),this.releaseRenderContext=void 0}finally{this.releaseFramework()}}}});var _n={};Ke(_n,{createCubismWebGLBackend:()=>mn,cubismWebGL:()=>Je});function Cl(){return Reflect.construct(URL,["./cubism-webgl-shaders/",import.meta.url])}function mn(e={}){return{createStage:Jr,async loadModel(t,r,i){let s=Hr(e.shaderBaseUrl??Cl()),{loadFrameworkModel:n}=await Promise.resolve().then(()=>(pn(),An));return n(t,r,s,e.shaderBaseUrl?void 0:_l,i)}}}var _l,Je,gr=_e(()=>{Lt();_l={"fragshadersrcalphablend.frag":`/**
|
|
27
27
|
* Copyright(c) Live2D Inc. All rights reserved.
|
|
28
28
|
*
|
|
29
29
|
* Use of this source code is governed by the Live2D Open Software license
|
|
@@ -676,7 +676,7 @@ void main()
|
|
|
676
676
|
v_texCoord = a_texCoord;
|
|
677
677
|
v_texCoord.y = 1.0 - v_texCoord.y;
|
|
678
678
|
}
|
|
679
|
-
`};Je=mn()});var Sn={};Ke(Sn,{mountLive2DDebugOverlay:()=>wl});function Ct(e,{max:t,min:r}){return Number.isFinite(e)?Math.min(t,Math.max(r,e)):r}function _r(e){return{offsetX:Ct(e.offsetX,_t.offset),offsetY:Ct(e.offsetY,_t.offset),scale:Ct(e.scale,_t.scale)}}function yl(e,t){return{x:t.width>0?(e.x-t.left)/t.width-.5:0,y:t.height>0?(e.y-t.top)/t.height-1:0}}function Cn(e,t,r){let i=Ct(t,_t.scale),s=e.scale===0?1:i/e.scale;return _r({offsetX:r.x-(r.x-e.offsetX)*s,offsetY:r.y-(r.y-e.offsetY)*s,scale:i})}function fr(e,t){return e.scale===t.scale&&e.offsetX===t.offsetX&&e.offsetY===t.offsetY}function yn(e){return{offsetX:e.offsetX,offsetY:e.offsetY,scale:e.scale,units:"stage"}}function bl(e,t){if(e==="full")return{...mr};if(e==="upper-body")return{...pr};let r=e.units==="stage",i=e.offsetX??0,s=e.offsetY??0;return _r({offsetX:r?i:t.width>0?i/t.width:0,offsetY:r?s:t.height>0?s/t.height:0,scale:e.scale})}function Ar(e){return Number(e.toFixed(3))}function bn(e){let{offsetX:t,offsetY:r,scale:i}=e;return`{ scale: ${Ar(i)}, offsetX: ${Ar(t)}, offsetY: ${Ar(r)}, units: 'stage' }`}function yt(e){throw new m("invalid-props",e)}function In(e){(!e||typeof e!="object")&&yt("Debug overlay target must be a Live2D instance.");for(let t of["setFit","getFit"])typeof e[t]!="function"&&yt(`Debug overlay target must provide ${t}().`)}function wl(e){if(typeof document>"u")throw new m("browser-only","The Live2D debug overlay can only be mounted in a browser.");(!e||typeof e!="object")&&yt("mountLive2DDebugOverlay options must be an object."),In(e.target),e.container instanceof HTMLElement||yt("mountLive2DDebugOverlay container must be an HTMLElement.");let{container:t}=e,r=e.target,i=!1,s=0,n=!1,a=!1,l=0,o=t.style.position,u=getComputedStyle(t).position;(!u||u==="static")&&(t.style.position="relative");let
|
|
679
|
+
`};Je=mn()});var Sn={};Ke(Sn,{mountLive2DDebugOverlay:()=>wl});function Ct(e,{max:t,min:r}){return Number.isFinite(e)?Math.min(t,Math.max(r,e)):r}function _r(e){return{offsetX:Ct(e.offsetX,_t.offset),offsetY:Ct(e.offsetY,_t.offset),scale:Ct(e.scale,_t.scale)}}function yl(e,t){return{x:t.width>0?(e.x-t.left)/t.width-.5:0,y:t.height>0?(e.y-t.top)/t.height-1:0}}function Cn(e,t,r){let i=Ct(t,_t.scale),s=e.scale===0?1:i/e.scale;return _r({offsetX:r.x-(r.x-e.offsetX)*s,offsetY:r.y-(r.y-e.offsetY)*s,scale:i})}function fr(e,t){return e.scale===t.scale&&e.offsetX===t.offsetX&&e.offsetY===t.offsetY}function yn(e){return{offsetX:e.offsetX,offsetY:e.offsetY,scale:e.scale,units:"stage"}}function bl(e,t){if(e==="full")return{...mr};if(e==="upper-body")return{...pr};let r=e.units==="stage",i=e.offsetX??0,s=e.offsetY??0;return _r({offsetX:r?i:t.width>0?i/t.width:0,offsetY:r?s:t.height>0?s/t.height:0,scale:e.scale})}function Ar(e){return Number(e.toFixed(3))}function bn(e){let{offsetX:t,offsetY:r,scale:i}=e;return`{ scale: ${Ar(i)}, offsetX: ${Ar(t)}, offsetY: ${Ar(r)}, units: 'stage' }`}function yt(e){throw new m("invalid-props",e)}function In(e){(!e||typeof e!="object")&&yt("Debug overlay target must be a Live2D instance.");for(let t of["setFit","getFit"])typeof e[t]!="function"&&yt(`Debug overlay target must provide ${t}().`)}function wl(e){if(typeof document>"u")throw new m("browser-only","The Live2D debug overlay can only be mounted in a browser.");(!e||typeof e!="object")&&yt("mountLive2DDebugOverlay options must be an object."),In(e.target),e.container instanceof HTMLElement||yt("mountLive2DDebugOverlay container must be an HTMLElement.");let{container:t}=e,r=e.target,i=!1,s=0,n=!1,a=!1,l=0,o=t.style.position,u=getComputedStyle(t).position;(!u||u==="static")&&(t.style.position="relative");let c=document.createElement("div");c.dataset.live2dDebug="";let g=c.attachShadow({mode:"open"}),h=document.createElement("style");h.textContent=Bl;let d=document.createElement("div");d.className="surface",d.tabIndex=0,d.setAttribute("role","application"),d.setAttribute("aria-label","Live2D placement. Drag to move, scroll to zoom, arrow keys to nudge."),d.innerHTML='<div class="frame"></div><div class="crosshair x"></div><div class="crosshair y"></div>';let f=document.createElement("div");f.className="bar";let p=document.createElement("output");p.className="zoom";let A=document.createElement("code");A.className="value",A.hidden=!0;let _=document.createElement("p");_.className="hint",_.textContent="Drag to move, scroll to zoom, arrow keys to nudge.";let b=(S,V,ke)=>{let Qe=document.createElement("button");return Qe.type="button",Qe.textContent=S,ke&&(Qe.className=ke),Qe.addEventListener("click",V),Qe},C=()=>{let S=document.createElement("span");return S.className="divider",S.setAttribute("aria-hidden","true"),S},B=()=>t.getBoundingClientRect(),I=S=>bl(S.getFit(),{height:B().height,width:B().width}),y=I(r),w,L,D,O,z={...y},oe=()=>{A.textContent=bn(y),p.textContent=`${Math.round(y.scale*100)}%`,w.setAttribute("aria-pressed",String(fr(y,pr))),L.setAttribute("aria-pressed",String(fr(y,mr))),D.disabled=fr(y,z)},J=()=>{_.hidden=!0},v=S=>{y=_r(S),oe(),!n&&(n=!0,s=requestAnimationFrame(()=>{if(n=!1,s=0,i)return;let V=yn(y);a=!0;try{r.setFit(V)}finally{a=!1}e.onChange?.(V)}))},j=S=>{O.textContent=S,clearTimeout(l),l=window.setTimeout(()=>{i||(O.textContent="Copy")},2e3)},W=()=>{J();let S=bn(y),V=navigator.clipboard;if(!V){A.hidden=!1;return}V.writeText(S).then(()=>j("Copied")).catch(()=>{A.hidden=!1})},le=S=>{J(),v({...S})},Mr=S=>{J(),Mt(S)};w=b("Upper body",()=>le(pr)),L=b("Full",()=>le(mr)),D=b("Reset",()=>le(z)),O=b("Copy",W),f.append(b("−",()=>Mr(-.05),"step"),p,b("+",()=>Mr(Bn),"step"),C(),w,L,D,C(),O),g.append(h,d,_,A,f),t.append(c),oe();function Mt(S){v(Cn(y,y.scale+S,{x:y.offsetX,y:y.offsetY}))}let q=null,wr=S=>{d.dataset.dragging=String(S),f.dataset.dragging=String(S)},xr=S=>{S.stopPropagation(),S.button===0&&(J(),d.setPointerCapture(S.pointerId),q={placement:y,pointerId:S.pointerId,x:S.clientX,y:S.clientY},wr(!0),d.focus())},Er=S=>{if(!q||q.pointerId!==S.pointerId)return;S.stopPropagation();let V=B();v({...q.placement,offsetX:q.placement.offsetX+(S.clientX-q.x)/Math.max(1,V.width),offsetY:q.placement.offsetY+(S.clientY-q.y)/Math.max(1,V.height)})},Ze=S=>{!q||q.pointerId!==S.pointerId||(S.stopPropagation(),d.hasPointerCapture(S.pointerId)&&d.releasePointerCapture(S.pointerId),q=null,wr(!1))},vr=S=>{S.preventDefault(),S.stopPropagation(),J();let V=S.deltaMode===1?S.deltaY*16:S.deltaY;v(Cn(y,y.scale*Math.exp(-V*.0015),yl({x:S.clientX,y:S.clientY},B())))},Pr=S=>{let V=Ml[S.key];if(V){S.preventDefault(),J();let ke=S.shiftKey?Sl:Il;v({...y,offsetX:y.offsetX+V[0]*ke,offsetY:y.offsetY+V[1]*ke});return}S.key==="+"||S.key==="="?(S.preventDefault(),J(),Mt(Bn)):S.key==="-"&&(S.preventDefault(),J(),Mt(-.05))},Rr=S=>S.stopPropagation();return d.addEventListener("click",Rr),d.addEventListener("pointerdown",xr),d.addEventListener("pointermove",Er),d.addEventListener("pointerup",Ze),d.addEventListener("pointercancel",Ze),d.addEventListener("wheel",vr,{passive:!1}),d.addEventListener("keydown",Pr),{dispose(){i||(i=!0,clearTimeout(l),s&&cancelAnimationFrame(s),s=0,n=!1,d.removeEventListener("click",Rr),d.removeEventListener("pointerdown",xr),d.removeEventListener("pointermove",Er),d.removeEventListener("pointerup",Ze),d.removeEventListener("pointercancel",Ze),d.removeEventListener("wheel",vr),d.removeEventListener("keydown",Pr),c.remove(),t.style.position=o)},getFit:()=>yn(y),refresh(){i||a||(y=I(r),z={...y},oe())},setTarget(S){In(S),r=S,y=I(S),z={...y},oe()}}}var _t,pr,mr,Bl,Il,Sl,Bn,Ml,Mn=_e(()=>{Me();_t={offset:{max:1,min:-1},scale:{max:2.5,min:.25}},pr=Object.freeze({offsetX:0,offsetY:0,scale:1}),mr=Object.freeze({offsetX:0,offsetY:-.5,scale:.5});Bl=`
|
|
680
680
|
:host {
|
|
681
681
|
--debug-accent: #ff718f;
|
|
682
682
|
--debug-line: #343942;
|
|
@@ -810,4 +810,4 @@ button.step { min-width: 28px; padding: 4px 0; font-size: 15px; }
|
|
|
810
810
|
[hidden] { display: none !important; }
|
|
811
811
|
`,Il=.01,Sl=.001,Bn=.05,Ml={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}});Me();xt();var Ir="https://cubism.live2d.com/sdk-web/core/06/live2dcubismcore.min.js",bt=new Map,wn=3e4;function xl(e){if(typeof performance>"u"||!performance.getEntriesByName)return;let t=performance.getEntriesByName(e,"resource").at(-1)?.responseStatus;return typeof t=="number"&&t>0?t:void 0}function qe(e){return{assetType:"core",httpStatus:e?xl(e):void 0,url:e}}function yr(){return`Live2D Cubism Core is not loaded. Pass a coreUrl option (to createLive2D() or <Live2DCanvas>), for example the OFFICIAL_CUBISM_CORE_URL constant, or load the script before creating a model:
|
|
812
812
|
<script src="/path/to/live2dcubismcore.min.js"><\/script>
|
|
813
|
-
Official SDK download: https://www.live2d.com/sdk/download/web/`}function El(){if(typeof window>"u"||typeof document>"u")throw new m("browser-only","live2d-web can only create a stage in a browser.")}function vl(e){return new Promise((t,r)=>{let i=document.createElement("script"),s=new AbortController,n,a=o=>{if(n!==void 0&&clearTimeout(n),n=void 0,s.abort(),!o){t();return}i.remove(),r(o)},l=o=>{if(o.type==="load"&&window.Live2DCubismCore){a();return}a(o.type==="load"?new m("core-missing",yr(),{details:qe(e)}):new m("core-missing",`Failed to load Live2D Cubism Core from ${e}.`,{cause:o,details:qe(e)}))};i.addEventListener("load",l,{signal:s.signal}),i.addEventListener("error",l,{signal:s.signal}),n=setTimeout(()=>{a(new m("core-missing",`Live2D Cubism Core did not load from ${e} within ${wn} ms.`,{details:qe(e)}))},wn),i.src=e,i.async=!0,i.dataset.live2dWebCore="true",document.head.appendChild(i)})}function Pl(e,t){return new Promise((r,i)=>{let s=()=>i(t.reason);t.addEventListener("abort",s,{once:!0}),e.then(r,i).finally(()=>{t.removeEventListener("abort",s)})})}async function Fn(e,t={}){El();let{signal:r}=t;if(r?.aborted)throw r.reason;if(window.Live2DCubismCore)return;if(!e)throw new m("core-missing",yr(),{details:qe()});let i=new URL(e,document.baseURI).href,s=bt.get(i);if(s||(s=vl(i).finally(()=>{bt.get(i)===s&&bt.delete(i)}),bt.set(i,s)),await(r?Pl(s,r):s),r?.aborted)throw r.reason;if(!window.Live2DCubismCore)throw new m("core-missing",yr(),{details:qe(i)})}function Cr(e){return Number.isFinite(e)&&e>0?e:1e-6}function On(e,t,r="upper-body"){let i=e.width/t.width,s=e.height/t.height;if(r==="full")return{scale:Cr(Math.min(i,s)),x:e.width/2,y:e.height/2};let n=Cr(Math.min(i*2,s*2));if(r==="upper-body")return{scale:n,x:e.width/2,y:e.height};let a=r.offsetX??0,l=r.offsetY??0,o=r.units==="stage";return{scale:Cr(n*r.scale),x:e.width/2+(o?a*e.width:a),y:e.height+(o?l*e.height:l)}}var St={desktopMaxResolution:2,desktopPixelBudget:4e6,longFrameMs:33,longFrameRatioThreshold:.05,minResolution:1,mobileMaxResolution:1.5,mobilePixelBudget:15e5,resolutionStep:.25,sampleWindowMs:3e3};function me(e,t){if(!Number.isFinite(e)||e<=0)throw new m("invalid-props",`${t} must be a finite number greater than 0.`);return e}function Vn(e){let t={...St,...e};if(me(t.desktopMaxResolution,"quality.desktopMaxResolution"),me(t.desktopPixelBudget,"quality.desktopPixelBudget"),me(t.longFrameMs,"quality.longFrameMs"),me(t.minResolution,"quality.minResolution"),me(t.mobileMaxResolution,"quality.mobileMaxResolution"),me(t.mobilePixelBudget,"quality.mobilePixelBudget"),me(t.resolutionStep,"quality.resolutionStep"),me(t.sampleWindowMs,"quality.sampleWindowMs"),!Number.isFinite(t.longFrameRatioThreshold)||t.longFrameRatioThreshold<0||t.longFrameRatioThreshold>1)throw new m("invalid-props","quality.longFrameRatioThreshold must be between 0 and 1.");if(t.mobileMaxResolution<t.minResolution||t.desktopMaxResolution<t.minResolution)throw new m("invalid-props","quality max resolutions must be greater than or equal to minResolution.");return t}function xn(e){return Number.isFinite(e)&&e>0?e:1}function br(e,t=St){let r=xn(e.width),i=xn(e.height),s=e.mobile?t.mobileMaxResolution:t.desktopMaxResolution,n=e.mobile?t.mobilePixelBudget:t.desktopPixelBudget,a=Number.isFinite(e.devicePixelRatio)&&e.devicePixelRatio>0?e.devicePixelRatio:t.minResolution,l=Math.sqrt(n/(r*i));return Math.max(t.minResolution,Math.min(a,s,l))}function kn(e,t,r=St){return!Number.isFinite(e)||e<=r.minResolution?r.minResolution:!Number.isFinite(t)||t<=r.longFrameRatioThreshold?e:Math.max(r.minResolution,Math.round((e-r.resolutionStep)*100)/100)}function Br(e,t){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches||Math.min(e,t)<768}function Rl(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Dl(e){return Number.isFinite(e)&&e>0?e:0}function En(e){return Number.isFinite(e)?e:0}function Ll(e){return e*e*(3-2*e)}var Tl=class{holdRemainingMs=0;lastForcedValue=0;releaseRemainingMs=0;update(e){if(e.speaking)return this.lastForcedValue=Rl(e.mouthOpen),this.releaseRemainingMs=200,this.holdRemainingMs=500,this.lastForcedValue;let t=Dl(e.deltaMs);if(this.releaseRemainingMs>0){let r=Math.min(this.releaseRemainingMs,t);if(this.releaseRemainingMs-=r,t-=r,this.releaseRemainingMs>0){let i=Ll(1-this.releaseRemainingMs/200);return this.lastForcedValue*(1-i)+En(e.motionValue)*i}if(t===0)return En(e.motionValue)}return this.holdRemainingMs>0&&(this.holdRemainingMs=Math.max(0,this.holdRemainingMs-t),this.holdRemainingMs>0)?0:null}},Fl=[["A","A"],["E","E"],["I","I"],["O","O"],["U","U"],["S","I"]],Ol=.7,Vl=50,kl=50,Ql=.7,Ul=.9,Bt=new Map,It;function vn(e){let t=!0;return()=>{t&&(t=!1,e())}}function Pn(e){return Number.isFinite(e)?Math.max(0,e):0}function Nl(){return typeof performance>"u"?Date.now():performance.now()}function Gl(){return It||(It=Ur().then(()=>Qr).catch(e=>{throw It=void 0,e})),It}function Xl(e){if(e instanceof URL)return e.href;let t=typeof location>"u"?"http://localhost/":location.href;return new URL(e,t).href}function Hl(e,t,r){let i=Xl(e),s=Bt.get(i);if(s)return s;let n=r(i).then(async a=>{if(!a.ok)throw new Error(`Failed to load the lip-sync profile (${a.status}).`);return new URL(i).pathname.toLowerCase().endsWith(".bin")?t.parseBinaryProfile(await a.arrayBuffer()):await a.json()});return Bt.set(i,n),n.catch(()=>{Bt.get(i)===n&&Bt.delete(i)}),n}function Wl(e,t,r=fetch){return typeof e=="string"||e instanceof URL?Hl(e,t,r):e instanceof ArrayBuffer?Promise.resolve(t.parseBinaryProfile(e)):Promise.resolve(e)}function Yl(e,t=Nl){let r=0,i=NaN,s=0,n=NaN,a=()=>{let l=Math.min(Pn(e.volume)*Ul,1)**Ql,o={A:0,E:0,I:0,O:0,U:0};for(let[u,h]of Fl){let d=Math.min(Ol,Pn(e.weights?.[u]??0)*l);o[h]=Math.max(o[h],d)}return Math.max(...Object.values(o))};return()=>{let l=t();if((Number.isNaN(i)||l-i>=Vl)&&(r=a(),i=l),Number.isNaN(n))return s=r,n=l,s;let o=Math.max(0,l-n),u=Math.min(1,o/kl);return s+=(r-s)*u,n=l,s}}async function zl(e,t,r={}){if(typeof window<"u"&&window.isSecureContext===!1)throw new Error("wLipSync requires HTTPS or localhost because it uses AudioWorklet.");if(!e.context||!("audioWorklet"in e.context))throw new Error("The source AudioNode context does not support AudioWorklet.");let i=await(r.loadModule??Gl)(),s=r.fetcher??(typeof fetch>"u"?void 0:fetch.bind(globalThis));if((typeof t=="string"||t instanceof URL)&&!s)throw new Error("fetch is unavailable, so the lip-sync profile URL cannot be loaded.");let n=await Wl(t,i,s),a=await i.createWLipSyncNode(e.context,n),l=vn(()=>{try{a.disconnect()}catch{}try{a.port.close()}catch{}});try{e.connect(a)}catch(u){throw l(),u}let o=Yl(a,r.now);return{dispose:vn(()=>{try{e.disconnect(a)}catch{}l()}),getMouthOpen:o,node:a}}function Jl(e,t){if(!Array.isArray(e))throw new m("invalid-props","Motion sequence steps must be an array.");for(let r=0;r<e.length;r++){let i=e[r];if(typeof i!="object"||i===null||Array.isArray(i))throw new m("invalid-props",`Motion sequence step ${r} must be an object.`);if(typeof i.group!="string"||i.group.trim()==="")throw new m("invalid-props",`Motion sequence step ${r} needs a non-empty group.`);let s=t.motions[i.group];if(!Number.isInteger(s)||s<=0)throw new m("invalid-props",`Unknown Live2D motion group in sequence step ${r}: ${i.group}.`);if(i.index!==void 0&&(!Number.isInteger(i.index)||i.index<0||i.index>=s))throw new m("invalid-props",`Motion index ${i.index} is outside group ${i.group} in sequence step ${r}.`);Ue(i.options)}}async function Rn(e,t,r){Jl(e,t);for(let i=0;i<e.length;i++){let s=e[i],n=await r(s.group,s.index,s.options);if(n.status!=="completed")return{completedSteps:i,status:n.status,stepIndex:i}}return{completedSteps:e.length,status:"completed"}}function Dn(e){let t=!0;return()=>{t&&(t=!1,e())}}var Ln=class{setup;report;cleanup;generation=0;constructor(e,t){this.setup=e,this.report=t}attach(e){this.detach();let t=this.generation;try{let r=this.setup(e);r instanceof Promise?r.then(i=>{if(t!==this.generation){i();return}this.cleanup=Dn(i)}).catch(i=>{t===this.generation&&this.report(i)}):this.cleanup=Dn(r)}catch(r){this.report(r)}}detach(){this.generation++,this.cleanup?.(),this.cleanup=void 0}};function Tn(e){let t=!0;return()=>{t&&(t=!1,e())}}function je(e,t){return e instanceof m?e:new m(t,e instanceof Error?e.message:String(e),{cause:e})}function Qn(e){if(e!==void 0){if(!e||typeof e!="object")throw new m("invalid-props","accessibility must be a decorative or image accessibility object.");if(e.mode!=="decorative"&&e.mode!=="image"&&e.mode!==void 0)throw new m("invalid-props",'accessibility.mode must be "decorative" or "image".');if(e.mode!=="decorative"){if(typeof e.label!="string"||e.label.trim()==="")throw new m("invalid-props","image accessibility requires a non-empty label.");for(let[t,r]of[["describedBy",e.describedBy],["fallbackText",e.fallbackText]])if(r!==void 0&&typeof r!="string")throw new m("invalid-props",`accessibility.${t} must be a string when provided.`)}}}function jl(e){if(typeof window>"u"||typeof document>"u"||typeof HTMLElement>"u")throw new m("browser-only","Live2D can only be created in a browser.");if(!(e.container instanceof HTMLElement))throw new m("invalid-props","container must be an HTMLElement.");if(Qn(e.accessibility),e.src!==void 0&&(typeof e.src!="string"||e.src.trim()===""))throw new m("invalid-props","src must be a non-empty model3.json path or URL string.");if(e.resolveAsset!==void 0&&typeof e.resolveAsset!="function")throw new m("invalid-props","resolveAsset must be a function.");if(e.quality!==void 0&&e.resolution!==void 0)throw new m("invalid-props","quality and resolution are mutually exclusive.");if(!Number.isInteger(e.retries??2)||(e.retries??2)<0)throw new m("invalid-props","retries must be a non-negative integer.");if("resolution"in e&&e.resolution!==void 0&&(!Number.isFinite(e.resolution)||e.resolution<1))throw new m("invalid-props","resolution must be a finite number greater than or equal to 1.");if(e.maxFps!==void 0&&(!Number.isFinite(e.maxFps)||e.maxFps<=0))throw new m("invalid-props","maxFps must be a finite number greater than 0.");if(e.pauseWhenOffscreen!==void 0&&typeof e.pauseWhenOffscreen!="boolean")throw new m("invalid-props","pauseWhenOffscreen must be a boolean.");if(e.followPointer!==void 0&&typeof e.followPointer!="boolean")throw new m("invalid-props","followPointer must be a boolean.");if(e.debug!==void 0&&typeof e.debug!="boolean")throw new m("invalid-props","debug must be a boolean.");wt(e.idleMotion)}function ql(e,t){return new Promise((r,i)=>{if(t.aborted){i(t.reason);return}let s,n=()=>{clearTimeout(s),i(t.reason)};s=setTimeout(()=>{t.removeEventListener("abort",n),r()},e),t.addEventListener("abort",n,{once:!0})})}var Zl=class{options;abortController;disposed=!1;features=[];accessibility;fit;debug;debugOverlay;debugWanted;intersectionObserver;listeners=new Set;models=[];backend;onStageResume;pauseReasons=new Set;resizeAnimationFrame=0;resizeObserver;stage;stageCleanup=[];state={loadingStage:"core",status:"loading"};constructor(e){this.options=e,this.fit=e.fit??"upper-body",this.debug=e.debug??!1,this.accessibility=e.accessibility}get model(){return this.models[0]?.handle}getState=()=>this.state;getModelHandle=()=>this.model??null;subscribe=e=>(this.listeners.add(e),Tn(()=>this.listeners.delete(e)));updateState(e){this.state={...this.state,...e};for(let t of this.listeners)t()}report(e){this.disposed||(this.updateState({error:e,loadingStage:void 0,status:"error"}),this.options.onError?.(e))}readRenderState(e){let t=e.getSize(),r=e.getResolution();return{bufferPixels:Math.round(t.width*t.height*r**2),height:t.height,resolution:r,width:t.width}}async resolveBackend(){if(this.options.backend)return this.options.backend;let{cubismWebGL:e}=await Promise.resolve().then(()=>(gr(),_n));return e}addPauseReason(e){if(this.pauseReasons.has(e))return;let t=this.pauseReasons.size===0;this.pauseReasons.add(e),t&&this.stage?.pause()}removePauseReason(e){!this.pauseReasons.delete(e)||this.pauseReasons.size>0||(this.onStageResume?.(),this.stage?.resume())}teardown(){this.abortController?.abort(),this.abortController=void 0,cancelAnimationFrame(this.resizeAnimationFrame),this.resizeAnimationFrame=0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.onStageResume=void 0,this.resizeObserver?.disconnect(),this.resizeObserver=void 0;for(let e of this.stageCleanup.splice(0).reverse())e();for(let e of[...this.features].reverse())e.detach();for(let e of this.models){this.releaseDebugOverlay(e);for(let t of e.features.splice(0).reverse())t.detach();e.handle.dispose()}this.models=[],this.stage?.dispose(),this.stage=void 0}async start(){if(this.disposed)throw new m("invalid-props","Cannot start a disposed Live2D instance.");jl(this.options),this.pauseReasons.delete("hidden"),this.pauseReasons.delete("offscreen");let e=this.options.resolution!==void 0?void 0:Vn(typeof this.options.quality=="object"?this.options.quality:void 0),t=new AbortController;this.abortController=t;let r=()=>t.abort(this.options.signal?.reason);this.options.signal?.aborted&&r(),this.options.signal?.addEventListener("abort",r,{once:!0}),this.stageCleanup.push(()=>{this.options.signal?.removeEventListener("abort",r)});try{if(this.updateState({error:void 0,loadingStage:"core",status:"loading"}),await Fn(this.options.coreUrl,{signal:t.signal}),t.signal.aborted)throw t.signal.reason;let i=this.backend??await this.resolveBackend();if(this.backend=i,t.signal.aborted)throw t.signal.reason;this.updateState({loadingStage:"stage"});let s=this.options.container.getBoundingClientRect();(s.width<1||s.height<1)&&console.warn("[live2d-web] The container has zero size, so the canvas will be 1x1 and nothing will be visible. Give the container a CSS width and height.");let n=Math.max(1,s.width),a=Math.max(1,s.height),l=this.options.resolution!==void 0?this.options.resolution:br({devicePixelRatio:window.devicePixelRatio,height:a,mobile:Br(n,a),width:n},e),o=i.createStage(this.options.container,{accessibility:this.accessibility,height:a,maxFps:this.options.maxFps,resolution:l,width:n});this.stage=o,this.pauseReasons.size>0&&o.pause(),this.stageCleanup.push(o.onError(p=>{this.report(je(p,"render-error"))}));let u=0,h=0,d=0;e&&this.stageCleanup.push(o.onFrame(p=>{if(u+=p,h++,p>e.longFrameMs&&d++,u<e.sampleWindowMs)return;let A=kn(o.getResolution(),h?d/h:0,e);A<o.getResolution()&&(o.setResolution(A),this.updateState({render:this.readRenderState(o)})),u=0,h=0,d=0}));let c=()=>{if(this.resizeAnimationFrame=0,this.disposed||this.stage!==o)return;let p=this.options.container.getBoundingClientRect(),A=Math.max(1,p.width),_=Math.max(1,p.height);if(!(Math.abs(A-n)<.5&&Math.abs(_-a)<.5)){if(n=A,a=_,e){let y=br({devicePixelRatio:window.devicePixelRatio,height:a,mobile:Br(n,a),width:n},e);y<o.getResolution()&&o.setResolution(y)}o.resize(n,a),this.applyFit(),this.updateState({render:this.readRenderState(o)})}},g=()=>{this.resizeAnimationFrame||(this.resizeAnimationFrame=requestAnimationFrame(c))};this.resizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(g),this.resizeObserver?.observe(this.options.container),this.onStageResume=()=>{u=0,h=0,d=0,g()};let f=()=>{document.hidden?this.addPauseReason("hidden"):this.removePauseReason("hidden")};if(document.addEventListener("visibilitychange",f),f(),this.stageCleanup.push(()=>{document.removeEventListener("visibilitychange",f)}),this.intersectionObserver=(this.options.pauseWhenOffscreen??!0)&&typeof IntersectionObserver<"u"?new IntersectionObserver(p=>{let A=p[p.length-1];A&&(A.isIntersecting?this.removePauseReason("offscreen"):this.addPauseReason("offscreen"))}):void 0,this.intersectionObserver?.observe(this.options.container),this.updateState({loadingStage:"model",render:this.readRenderState(o)}),this.options.src!==void 0){let p=await this.loadModel(i,o,this.options.src,t.signal);if(t.signal.aborted||this.stage!==o)throw p.dispose(),t.signal.reason;this.models.push({features:[],fit:this.fit,followPointer:this.options.followPointer??!1,handle:p}),this.applyFit();for(let A of this.features)A.attach(p)}{let p=this.options.container,A=y=>{if(this.stage!==o)return;let C=o.toWorld(y.clientX,y.clientY);for(let B of this.models)B.followPointer&&B.handle.focus(C.x,C.y)},_=()=>{if(this.stage!==o)return;let y=o.getSize();for(let C of this.models)C.followPointer&&C.handle.focus(y.width/2,y.height/2)};p.addEventListener("pointermove",A),p.addEventListener("pointerleave",_),this.stageCleanup.push(()=>{p.removeEventListener("pointermove",A),p.removeEventListener("pointerleave",_)})}this.debug&&this.models[0]&&await this.mountDebugOverlay(o,this.models[0]),this.updateState({error:void 0,loadingStage:void 0,render:this.readRenderState(o),status:"ready"})}catch(i){if(t.signal.aborted){if(this.disposed)return;throw i}let s=je(i,"adapter-error");throw this.teardown(),this.report(s),s}}async loadModel(e,t,r,i,s){let n=s?.retries??this.options.retries??2,a;for(let l=0;l<=n;l++)try{return await e.loadModel(t,r,{idleMotion:s?.idleMotion??this.options.idleMotion,resolveAsset:s?.resolveAsset??this.options.resolveAsset,signal:i})}catch(o){if(i.aborted)throw o;a=je(o,"model-load-failed");let u=a.details?.httpStatus;if(a.code==="invalid-props"||u!==void 0&&u>=400&&u<500||l===n)break;await ql(l===0?250:500,i)}throw a||new m("model-load-failed","The model could not be loaded.")}requireModel(){if(this.disposed)throw new m("invalid-props","The Live2D instance has been disposed.");if(!this.model)throw new m("model-load-failed","The Live2D model is not ready.");return this.model}async mountDebugOverlay(e,t){let{mountLive2DDebugOverlay:r}=await Promise.resolve().then(()=>(Mn(),Sn));if(this.disposed||this.stage!==e||!this.models.includes(t)||this.debugWanted!==t||this.debugOverlay?.owner===t)return;this.releaseDebugOverlay();let i=r({container:this.options.container,onChange:s=>(t.onFitChange??this.options.onFitChange)?.(s),target:{getFit:()=>typeof t.fit=="object"?{...t.fit}:t.fit,setFit:s=>{t.fit=s,this.applyFit()}}});this.debugOverlay={dispose:i.dispose,owner:t,refresh:i.refresh},this.stageCleanup.push(()=>this.releaseDebugOverlay(t))}releaseDebugOverlay(e){let t=this.debugOverlay;!t||e!==void 0&&t.owner!==e||(this.debugOverlay=void 0,t.dispose())}setDebug(e,t){if(typeof e!="boolean")throw new m("invalid-props","debug must be a boolean.");let r=t??this.models[0];if(!e){this.debugWanted===r&&(this.debugWanted=void 0),this.releaseDebugOverlay(r),t||(this.debug=!1);return}if(t||(this.debug=!0),!this.stage||!r)return;let i=this.debugWanted;this.debugWanted=r,i&&i!==r&&console.warn("[live2d-web] The placement overlay moved to the model that asked for it last. It covers the canvas to take the pointer, so only one model can have it at a time."),this.mountDebugOverlay(this.stage,r)}applyFit(){let e=this.stage;if(!e)return;let t=e.getSize();for(let r of this.models)r.handle.setTransform(On(t,r.handle.getIntrinsicSize(),r.fit))}motion(e,t,r){return this.requireModel().motion(e,t,r)}async playMotion(e,t,r){let i=this.requireModel();if(!i.playMotion)throw new m("adapter-error","The selected Live2D backend does not support detailed motion playback.");return i.playMotion(e,t,r)}async sequence(e){let t=this.requireModel();if(!t.playMotion)throw new m("adapter-error","The selected Live2D backend does not support motion sequences.");return Rn(e,t.getModelInfo(),(r,i,s)=>t.playMotion(r,i,s))}isMotionPlaying(){return this.model?.isMotionPlaying()??!1}expression(e,t){return this.requireModel().expression(e,t)}clearExpression(){this.requireModel().clearExpression()}getModelInfo(){return this.requireModel().getModelInfo()}focus(e,t){this.requireModel().focus(e,t)}focusAt(e,t){let r=this.stage;if(!r||this.models.length===0)return;let i=r.toWorld(e,t);for(let s of this.models)s.handle.focus(i.x,i.y)}hitTest(e,t){let r=this.stage;if(!r)return[];let i=r.toWorld(e,t);for(let s=this.models.length-1;s>=0;s--){let n=this.models[s].handle.hitTest(i.x,i.y);if(n.length>0)return n}return[]}getParameter(e){return this.requireModel().getParameter(e)}setParameter(e,t){this.requireModel().setParameter(e,t)}clearParameter(e){this.requireModel().clearParameter(e)}setFit(e){this.fit=e,this.models[0]&&(this.models[0].fit=e),this.applyFit(),this.debugOverlay?.refresh()}async addModel(e){if(this.disposed)throw new m("invalid-props","The Live2D instance has been disposed.");if(!e||typeof e.src!="string"||e.src==="")throw new m("invalid-props","addModel requires a src.");await this.whenStageReady();let t=this.stage,r=this.backend;if(!t||!r)throw new m("invalid-props","The Live2D canvas is not ready. Await createLive2D() before adding a model.");let i=new AbortController,s=()=>i.abort(e.signal?.reason);e.signal?.addEventListener("abort",s,{once:!0});let n;try{n=await this.loadModel(r,t,e.src,i.signal,e)}finally{e.signal?.removeEventListener("abort",s)}if(this.disposed||this.stage!==t)throw n.dispose(),new m("invalid-props","The Live2D canvas went away while the model loaded.");let a={features:[],fit:e.fit??"upper-body",followPointer:e.followPointer??!1,handle:n,onFitChange:e.onFitChange};return this.models.push(a),this.applyFit(),this.createModelHandle(a)}whenStageReady(){return this.stage&&this.backend?Promise.resolve():this.state.status==="error"?Promise.reject(this.state.error??new m("adapter-error","The Live2D canvas failed to start.")):new Promise((e,t)=>{let r=this.subscribe(()=>{if(this.disposed){r(),t(new m("invalid-props","The Live2D instance has been disposed."));return}if(this.stage&&this.backend){r(),e();return}this.state.status==="error"&&(r(),t(this.state.error??new m("adapter-error","The Live2D canvas failed to start.")))})})}createModelHandle(e){let t=()=>{if(!this.models.includes(e))throw new m("invalid-props","This Live2D model has been disposed.");return e.handle};return Object.freeze({addLipSync:r=>this.addLipSync(r,e),addParameterDriver:(r,i)=>this.addParameterDriver(r,i,e),clearExpression:()=>t().clearExpression(),clearParameter:r=>t().clearParameter(r),dispose:()=>{let r=this.models.indexOf(e);if(!(r<0)){this.models.splice(r,1),this.debugWanted===e&&(this.debugWanted=void 0),this.releaseDebugOverlay(e);for(let i of e.features.splice(0))i.detach();e.handle.dispose()}},expression:(r,i)=>t().expression(r,i),focus:(r,i)=>t().focus(r,i),focusAt:(r,i)=>{let s=this.stage;if(!s)return;let n=s.toWorld(r,i);t().focus(n.x,n.y)},getFit:()=>typeof e.fit=="object"?{...e.fit}:e.fit,getModelInfo:()=>t().getModelInfo(),getParameter:r=>t().getParameter(r),hitTest:(r,i)=>{let s=this.stage;if(!s)return[];let n=s.toWorld(r,i);return t().hitTest(n.x,n.y)},isMotionPlaying:()=>t().isMotionPlaying(),motion:(r,i,s)=>t().motion(r,i,s),playMotion:async(r,i,s)=>{let n=t();if(!n.playMotion)throw new m("adapter-error","The selected Live2D backend does not support detailed motion playback.");return n.playMotion(r,i,s)},sequence:async r=>{let i=t();if(!i.playMotion)throw new m("adapter-error","The selected Live2D backend does not support motion sequences.");return Rn(r,i.getModelInfo(),(s,n,a)=>i.playMotion(s,n,a))},setDebug:r=>this.setDebug(r,e),setFit:r=>{e.fit=r,this.applyFit()},setParameter:(r,i)=>t().setParameter(r,i)})}getFit(){return typeof this.fit=="object"?{...this.fit}:this.fit}setAccessibility(e){Qn(e),this.accessibility=e,this.stage?.setAccessibility?.(e)}addFeature(e,t){let r=t?.features??this.features;r.push(e);let i=t?.handle??this.model;return i&&e.attach(i),Tn(()=>{e.detach();let s=r.indexOf(e);s>=0&&r.splice(s,1)})}addParameterDriver(e,t,r){if(!t||typeof t.getValue!="function")throw new m("invalid-props","A parameter driver must provide getValue().");return this.addFeature(new Ln(i=>{let s=()=>{i.setParameter(e,t.getValue()),i.clearParameter(e)},n=(t.phase==="before-physics"&&i.onBeforePhysicsUpdate?i.onBeforePhysicsUpdate:i.onAfterMotionUpdate).call(i,s);return()=>{n(),i.clearParameter(e)}},i=>this.report(je(i,"render-error"))),r)}addLipSync(e,t){let r=n=>{let a=je(n,"lipsync-error");e.onError?.(a),!e.onError&&this.options.onError?this.options.onError?.(a):!e.onError&&!this.options.onError&&console.error("[live2d-web] lip sync disabled:",a)},i=e.parameterId??"ParamMouthOpenY",s=new Ln(async n=>{let a=new Tl,l="source"in e?await zl(e.source,e.profile):void 0,o="driver"in e?e.driver:{getMouthOpen:l.getMouthOpen,isSpeaking:e.isSpeaking},u=!1,h=n.onAfterMotionUpdate(d=>{if(!u)try{let c=o.isSpeaking(),g=a.update({deltaMs:d,motionValue:n.getParameter(i),mouthOpen:c?o.getMouthOpen():0,speaking:c});g!==null&&(n.setParameter(i,g),n.clearParameter(i))}catch(c){u=!0,r(c)}});return()=>{h(),n.clearParameter(i),l?.dispose()}},r);return this.addFeature(s,t)}pause(){this.addPauseReason("user")}resume(){this.removePauseReason("user")}async retry(){if(this.disposed)throw new m("invalid-props","Cannot retry a disposed Live2D instance.");this.teardown(),await this.start()}dispose(){this.disposed||(this.disposed=!0,this.teardown(),this.features=[],this.updateState({error:void 0,loadingStage:void 0,render:void 0,status:"disposed"}),this.listeners.clear())}};async function Sr(e){let t=new Zl(e);try{return await t.start(),t}catch(r){throw t.dispose(),r}}gr();function Un(e,t){let r=0,i=0;for(let{Segments:s}of e.Curves){if(s.length<2)throw new Error("Missing motion curve starting point");s.length===2&&s.push(0,e.Meta.Duration,s[1]),r++;for(let n=2;n<s.length;){let a=s[n];if(![0,1,2,3].includes(a))throw new Error("Invalid motion segment type: "+a);let l=a===1?3:1;if(n+=1+2*l,n>s.length)throw new Error("Incomplete motion curve");r+=l,i++}}return e.Meta.CurveCount=e.Curves.length,e.Meta.TotalSegmentCount=i,e.Meta.TotalPointCount=r,t&&(e.Meta.Loop=!1),e}async function Nn(e,t){let r=await fetch(e,{signal:t});if(!r.ok)throw new Error("HTTP "+r.status+" loading "+e);return r.json()}async function Gn(e,t,r){let[i,s]=await Promise.all([Nn(e,r),t&&Nn(t.url,r).catch(u=>{if(r.aborted)throw u;console.warn("[Live2D] Dialogue data unavailable",u)})]),n=[];for(let[u,h]of Object.entries(i.FileReferences.Motions??{}))h.forEach((d,c)=>{if(s&&t)for(let[g,f]of Object.entries(s.motionData)){if(f.motion_name.replace(/\.mtn$/i,".motion3.json")!==d.File||!!f.is_hurt!=(s.variant==="destroy")||!f.touch_area||f.touch_area==="0")continue;let p=s.voiceData[g],A=p?.char_code?.toUpperCase(),_=p?.voice_key?.toUpperCase();n.push({file:d.File,group:u,index:c,area:f.touch_area.toLowerCase(),weight:f.probability,delay:Math.max(0,f.delay||0),caption:t.captions?.[A+"|"+_]||p?.caption,sound:A&&_?t.audio.get("AUDIO/"+A+"/"+A+"_"+_+"_JP.OGG"):void 0})}else/^tap_?/i.test(u)&&n.push({file:d.File,group:u,index:c,area:u.replace(/^tap_?/i,"").toLowerCase(),weight:1,delay:0,sound:d.Sound?new URL(d.Sound,e).href:void 0})});let a=decodeURIComponent(new URL(e).pathname.slice(1)),l=new Set(t?n.map(u=>new URL(u.file,e).href):[]);async function o(u,h){if(u===a)return new Blob([JSON.stringify(i)],{type:"application/json"});let d=new URL("/"+u.split("/").map(encodeURIComponent).join("/"),e),c=await fetch(d,{signal:h??r});if(!c.ok)throw new Error("HTTP "+c.status+" loading "+d);if(!d.pathname.toLowerCase().endsWith(".motion3.json"))return c.blob();let g=Un(await c.json(),l.has(d.href));return new Blob([JSON.stringify(g)],{type:"application/json"})}return{actions:n,src:a,resolveAsset:o}}function Xn(e,t,r,i){let s;function n(){s?.abort(),s=void 0}i.addEventListener("abort",n,{once:!0});async function a(l){n();let o=s=new AbortController,u=l.sound?new Audio(l.sound):void 0,h={},d=!1;function c(p){d&&(d=!1,window.dispatchEvent(new CustomEvent("live2d:dialogue-end",{detail:{playback:h,interrupted:p}})))}o.signal.addEventListener("abort",()=>{u?.pause(),c(!0)},{once:!0});let g=t.playMotion(l.group,l.index).then(p=>{p.status!=="completed"&&o.abort()}),f=async()=>{if(l.delay&&await new Promise(_=>{let y=setTimeout(_,l.delay);o.signal.addEventListener("abort",()=>{clearTimeout(y),_()},{once:!0})}),o.signal.aborted)return;let p=l.caption?.trim();d=!0;let A=p?new CustomEvent("live2d:dialogue",{detail:p}):new CustomEvent("live2d:preset");if(window.dispatchEvent(Object.assign(A,{playback:h})),u){let _=new Promise(y=>{u.addEventListener("ended",()=>y(),{once:!0}),u.addEventListener("error",()=>y(),{once:!0}),o.signal.addEventListener("abort",()=>y(),{once:!0})});try{await u.play(),await _}catch{}}};try{await Promise.all([g,f()]),c(!1)}finally{o.abort(),s===o&&(s=void 0)}}return e.addEventListener("click",l=>{s&&(l.live2dHandlesCaption=!0);let o=t.hitTest(l.clientX,l.clientY);for(let u of o){let h=r.filter(d=>d.area===u.toLowerCase()&&d.weight>0);if(h.length){let d=Math.random()*h.reduce((g,f)=>g+f.weight,0),c=h.find(g=>(d-=g.weight)<0)??h[h.length-1];l.live2dHandlesCaption=!0,a(c).catch(g=>{i.aborted||console.error("[Live2D]",g)});break}if(u.toLowerCase()==="head"&&t.getModelInfo().expressions.length){t.expression().catch(d=>{i.aborted||console.error("[Live2D]",d)});break}}},{signal:i}),document.addEventListener("visibilitychange",()=>{document.hidden&&n()},{signal:i}),n}async function qh(e,t,r,i,s,n,a){if(i.throwIfAborted(),!(e instanceof HTMLCanvasElement))throw new Error("Missing Live2D canvas");let l=document.createElement("div");l.style.cssText="display:inline-block;position:relative;vertical-align:top;line-height:0";let o=document.createElement("div");o.className="waifu-model-stage",o.style.cssText="position:absolute;inset:0;cursor:grab";let u=e.style.visibility;e.before(l),l.append(e,o),e.style.visibility="hidden";let h;function d(){h?.dispose(),l.contains(e)&&(l.replaceWith(e),e.style.visibility=u),i.removeEventListener("abort",d)}i.addEventListener("abort",d,{once:!0});try{let{actions:c,src:g,resolveAsset:f}=await Gn(t,s,i);i.throwIfAborted();let p,A,_=(n||a)&&{...Je,createStage(b,M){return p=Je.createStage(b,M)},async loadModel(b,M,L){return A=await Je.loadModel(b,M,L)}},y=b=>({scale:b.scale/2,offsetX:b.x,offsetY:b.y-.5,units:"stage"});h=await Sr({container:o,src:g,resolveAsset:f,coreUrl:r||Ir,backend:_,fit:n?y(n.initial):"full",followPointer:!0,signal:i,onError:b=>console.error("[Live2D]",b)}),i.throwIfAborted();let C=h,B=o.querySelector("canvas");if(p&&B){let b=p.onFrame(()=>queueMicrotask(()=>{if(!i.aborted){if(n){let{width:M,height:L}=p.getSize(),k=n.measure(B,(H,ae)=>A.hitTest(H*M,ae*L));k&&(n=void 0,C.setFit(y(k)));return}b(),a?.(B)}}))}let x=Xn(o,C,c,i);return{pause:()=>{x(),C.pause()},resume:()=>C.resume(),capture(){requestAnimationFrame(()=>{let b=o.querySelector("canvas");if(!b||i.aborted)return;let M=document.createElement("a");M.download="photo.png",M.href=b.toDataURL("image/png"),M.click()})}}}catch(c){throw d(),c}}export{qh as mountModern};
|
|
813
|
+
Official SDK download: https://www.live2d.com/sdk/download/web/`}function El(){if(typeof window>"u"||typeof document>"u")throw new m("browser-only","live2d-web can only create a stage in a browser.")}function vl(e){return new Promise((t,r)=>{let i=document.createElement("script"),s=new AbortController,n,a=o=>{if(n!==void 0&&clearTimeout(n),n=void 0,s.abort(),!o){t();return}i.remove(),r(o)},l=o=>{if(o.type==="load"&&window.Live2DCubismCore){a();return}a(o.type==="load"?new m("core-missing",yr(),{details:qe(e)}):new m("core-missing",`Failed to load Live2D Cubism Core from ${e}.`,{cause:o,details:qe(e)}))};i.addEventListener("load",l,{signal:s.signal}),i.addEventListener("error",l,{signal:s.signal}),n=setTimeout(()=>{a(new m("core-missing",`Live2D Cubism Core did not load from ${e} within ${wn} ms.`,{details:qe(e)}))},wn),i.src=e,i.async=!0,i.dataset.live2dWebCore="true",document.head.appendChild(i)})}function Pl(e,t){return new Promise((r,i)=>{let s=()=>i(t.reason);t.addEventListener("abort",s,{once:!0}),e.then(r,i).finally(()=>{t.removeEventListener("abort",s)})})}async function Fn(e,t={}){El();let{signal:r}=t;if(r?.aborted)throw r.reason;if(window.Live2DCubismCore)return;if(!e)throw new m("core-missing",yr(),{details:qe()});let i=new URL(e,document.baseURI).href,s=bt.get(i);if(s||(s=vl(i).finally(()=>{bt.get(i)===s&&bt.delete(i)}),bt.set(i,s)),await(r?Pl(s,r):s),r?.aborted)throw r.reason;if(!window.Live2DCubismCore)throw new m("core-missing",yr(),{details:qe(i)})}function Cr(e){return Number.isFinite(e)&&e>0?e:1e-6}function On(e,t,r="upper-body"){let i=e.width/t.width,s=e.height/t.height;if(r==="full")return{scale:Cr(Math.min(i,s)),x:e.width/2,y:e.height/2};let n=Cr(Math.min(i*2,s*2));if(r==="upper-body")return{scale:n,x:e.width/2,y:e.height};let a=r.offsetX??0,l=r.offsetY??0,o=r.units==="stage";return{scale:Cr(n*r.scale),x:e.width/2+(o?a*e.width:a),y:e.height+(o?l*e.height:l)}}var St={desktopMaxResolution:2,desktopPixelBudget:4e6,longFrameMs:33,longFrameRatioThreshold:.05,minResolution:1,mobileMaxResolution:1.5,mobilePixelBudget:15e5,resolutionStep:.25,sampleWindowMs:3e3};function me(e,t){if(!Number.isFinite(e)||e<=0)throw new m("invalid-props",`${t} must be a finite number greater than 0.`);return e}function Vn(e){let t={...St,...e};if(me(t.desktopMaxResolution,"quality.desktopMaxResolution"),me(t.desktopPixelBudget,"quality.desktopPixelBudget"),me(t.longFrameMs,"quality.longFrameMs"),me(t.minResolution,"quality.minResolution"),me(t.mobileMaxResolution,"quality.mobileMaxResolution"),me(t.mobilePixelBudget,"quality.mobilePixelBudget"),me(t.resolutionStep,"quality.resolutionStep"),me(t.sampleWindowMs,"quality.sampleWindowMs"),!Number.isFinite(t.longFrameRatioThreshold)||t.longFrameRatioThreshold<0||t.longFrameRatioThreshold>1)throw new m("invalid-props","quality.longFrameRatioThreshold must be between 0 and 1.");if(t.mobileMaxResolution<t.minResolution||t.desktopMaxResolution<t.minResolution)throw new m("invalid-props","quality max resolutions must be greater than or equal to minResolution.");return t}function xn(e){return Number.isFinite(e)&&e>0?e:1}function br(e,t=St){let r=xn(e.width),i=xn(e.height),s=e.mobile?t.mobileMaxResolution:t.desktopMaxResolution,n=e.mobile?t.mobilePixelBudget:t.desktopPixelBudget,a=Number.isFinite(e.devicePixelRatio)&&e.devicePixelRatio>0?e.devicePixelRatio:t.minResolution,l=Math.sqrt(n/(r*i));return Math.max(t.minResolution,Math.min(a,s,l))}function kn(e,t,r=St){return!Number.isFinite(e)||e<=r.minResolution?r.minResolution:!Number.isFinite(t)||t<=r.longFrameRatioThreshold?e:Math.max(r.minResolution,Math.round((e-r.resolutionStep)*100)/100)}function Br(e,t){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches||Math.min(e,t)<768}function Rl(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Dl(e){return Number.isFinite(e)&&e>0?e:0}function En(e){return Number.isFinite(e)?e:0}function Ll(e){return e*e*(3-2*e)}var Tl=class{holdRemainingMs=0;lastForcedValue=0;releaseRemainingMs=0;update(e){if(e.speaking)return this.lastForcedValue=Rl(e.mouthOpen),this.releaseRemainingMs=200,this.holdRemainingMs=500,this.lastForcedValue;let t=Dl(e.deltaMs);if(this.releaseRemainingMs>0){let r=Math.min(this.releaseRemainingMs,t);if(this.releaseRemainingMs-=r,t-=r,this.releaseRemainingMs>0){let i=Ll(1-this.releaseRemainingMs/200);return this.lastForcedValue*(1-i)+En(e.motionValue)*i}if(t===0)return En(e.motionValue)}return this.holdRemainingMs>0&&(this.holdRemainingMs=Math.max(0,this.holdRemainingMs-t),this.holdRemainingMs>0)?0:null}},Fl=[["A","A"],["E","E"],["I","I"],["O","O"],["U","U"],["S","I"]],Ol=.7,Vl=50,kl=50,Ql=.7,Ul=.9,Bt=new Map,It;function vn(e){let t=!0;return()=>{t&&(t=!1,e())}}function Pn(e){return Number.isFinite(e)?Math.max(0,e):0}function Nl(){return typeof performance>"u"?Date.now():performance.now()}function Gl(){return It||(It=Ur().then(()=>Qr).catch(e=>{throw It=void 0,e})),It}function Xl(e){if(e instanceof URL)return e.href;let t=typeof location>"u"?"http://localhost/":location.href;return new URL(e,t).href}function Hl(e,t,r){let i=Xl(e),s=Bt.get(i);if(s)return s;let n=r(i).then(async a=>{if(!a.ok)throw new Error(`Failed to load the lip-sync profile (${a.status}).`);return new URL(i).pathname.toLowerCase().endsWith(".bin")?t.parseBinaryProfile(await a.arrayBuffer()):await a.json()});return Bt.set(i,n),n.catch(()=>{Bt.get(i)===n&&Bt.delete(i)}),n}function Wl(e,t,r=fetch){return typeof e=="string"||e instanceof URL?Hl(e,t,r):e instanceof ArrayBuffer?Promise.resolve(t.parseBinaryProfile(e)):Promise.resolve(e)}function Yl(e,t=Nl){let r=0,i=NaN,s=0,n=NaN,a=()=>{let l=Math.min(Pn(e.volume)*Ul,1)**Ql,o={A:0,E:0,I:0,O:0,U:0};for(let[u,c]of Fl){let g=Math.min(Ol,Pn(e.weights?.[u]??0)*l);o[c]=Math.max(o[c],g)}return Math.max(...Object.values(o))};return()=>{let l=t();if((Number.isNaN(i)||l-i>=Vl)&&(r=a(),i=l),Number.isNaN(n))return s=r,n=l,s;let o=Math.max(0,l-n),u=Math.min(1,o/kl);return s+=(r-s)*u,n=l,s}}async function zl(e,t,r={}){if(typeof window<"u"&&window.isSecureContext===!1)throw new Error("wLipSync requires HTTPS or localhost because it uses AudioWorklet.");if(!e.context||!("audioWorklet"in e.context))throw new Error("The source AudioNode context does not support AudioWorklet.");let i=await(r.loadModule??Gl)(),s=r.fetcher??(typeof fetch>"u"?void 0:fetch.bind(globalThis));if((typeof t=="string"||t instanceof URL)&&!s)throw new Error("fetch is unavailable, so the lip-sync profile URL cannot be loaded.");let n=await Wl(t,i,s),a=await i.createWLipSyncNode(e.context,n),l=vn(()=>{try{a.disconnect()}catch{}try{a.port.close()}catch{}});try{e.connect(a)}catch(u){throw l(),u}let o=Yl(a,r.now);return{dispose:vn(()=>{try{e.disconnect(a)}catch{}l()}),getMouthOpen:o,node:a}}function Jl(e,t){if(!Array.isArray(e))throw new m("invalid-props","Motion sequence steps must be an array.");for(let r=0;r<e.length;r++){let i=e[r];if(typeof i!="object"||i===null||Array.isArray(i))throw new m("invalid-props",`Motion sequence step ${r} must be an object.`);if(typeof i.group!="string"||i.group.trim()==="")throw new m("invalid-props",`Motion sequence step ${r} needs a non-empty group.`);let s=t.motions[i.group];if(!Number.isInteger(s)||s<=0)throw new m("invalid-props",`Unknown Live2D motion group in sequence step ${r}: ${i.group}.`);if(i.index!==void 0&&(!Number.isInteger(i.index)||i.index<0||i.index>=s))throw new m("invalid-props",`Motion index ${i.index} is outside group ${i.group} in sequence step ${r}.`);Ue(i.options)}}async function Rn(e,t,r){Jl(e,t);for(let i=0;i<e.length;i++){let s=e[i],n=await r(s.group,s.index,s.options);if(n.status!=="completed")return{completedSteps:i,status:n.status,stepIndex:i}}return{completedSteps:e.length,status:"completed"}}function Dn(e){let t=!0;return()=>{t&&(t=!1,e())}}var Ln=class{setup;report;cleanup;generation=0;constructor(e,t){this.setup=e,this.report=t}attach(e){this.detach();let t=this.generation;try{let r=this.setup(e);r instanceof Promise?r.then(i=>{if(t!==this.generation){i();return}this.cleanup=Dn(i)}).catch(i=>{t===this.generation&&this.report(i)}):this.cleanup=Dn(r)}catch(r){this.report(r)}}detach(){this.generation++,this.cleanup?.(),this.cleanup=void 0}};function Tn(e){let t=!0;return()=>{t&&(t=!1,e())}}function je(e,t){return e instanceof m?e:new m(t,e instanceof Error?e.message:String(e),{cause:e})}function Qn(e){if(e!==void 0){if(!e||typeof e!="object")throw new m("invalid-props","accessibility must be a decorative or image accessibility object.");if(e.mode!=="decorative"&&e.mode!=="image"&&e.mode!==void 0)throw new m("invalid-props",'accessibility.mode must be "decorative" or "image".');if(e.mode!=="decorative"){if(typeof e.label!="string"||e.label.trim()==="")throw new m("invalid-props","image accessibility requires a non-empty label.");for(let[t,r]of[["describedBy",e.describedBy],["fallbackText",e.fallbackText]])if(r!==void 0&&typeof r!="string")throw new m("invalid-props",`accessibility.${t} must be a string when provided.`)}}}function jl(e){if(typeof window>"u"||typeof document>"u"||typeof HTMLElement>"u")throw new m("browser-only","Live2D can only be created in a browser.");if(!(e.container instanceof HTMLElement))throw new m("invalid-props","container must be an HTMLElement.");if(Qn(e.accessibility),e.src!==void 0&&(typeof e.src!="string"||e.src.trim()===""))throw new m("invalid-props","src must be a non-empty model3.json path or URL string.");if(e.resolveAsset!==void 0&&typeof e.resolveAsset!="function")throw new m("invalid-props","resolveAsset must be a function.");if(e.quality!==void 0&&e.resolution!==void 0)throw new m("invalid-props","quality and resolution are mutually exclusive.");if(!Number.isInteger(e.retries??2)||(e.retries??2)<0)throw new m("invalid-props","retries must be a non-negative integer.");if("resolution"in e&&e.resolution!==void 0&&(!Number.isFinite(e.resolution)||e.resolution<1))throw new m("invalid-props","resolution must be a finite number greater than or equal to 1.");if(e.maxFps!==void 0&&(!Number.isFinite(e.maxFps)||e.maxFps<=0))throw new m("invalid-props","maxFps must be a finite number greater than 0.");if(e.pauseWhenOffscreen!==void 0&&typeof e.pauseWhenOffscreen!="boolean")throw new m("invalid-props","pauseWhenOffscreen must be a boolean.");if(e.followPointer!==void 0&&typeof e.followPointer!="boolean")throw new m("invalid-props","followPointer must be a boolean.");if(e.debug!==void 0&&typeof e.debug!="boolean")throw new m("invalid-props","debug must be a boolean.");wt(e.idleMotion)}function ql(e,t){return new Promise((r,i)=>{if(t.aborted){i(t.reason);return}let s,n=()=>{clearTimeout(s),i(t.reason)};s=setTimeout(()=>{t.removeEventListener("abort",n),r()},e),t.addEventListener("abort",n,{once:!0})})}var Zl=class{options;abortController;disposed=!1;features=[];accessibility;fit;debug;debugOverlay;debugWanted;intersectionObserver;listeners=new Set;models=[];backend;onStageResume;pauseReasons=new Set;resizeAnimationFrame=0;resizeObserver;stage;stageCleanup=[];state={loadingStage:"core",status:"loading"};constructor(e){this.options=e,this.fit=e.fit??"upper-body",this.debug=e.debug??!1,this.accessibility=e.accessibility}get model(){return this.models[0]?.handle}getState=()=>this.state;getModelHandle=()=>this.model??null;subscribe=e=>(this.listeners.add(e),Tn(()=>this.listeners.delete(e)));updateState(e){this.state={...this.state,...e};for(let t of this.listeners)t()}report(e){this.disposed||(this.updateState({error:e,loadingStage:void 0,status:"error"}),this.options.onError?.(e))}readRenderState(e){let t=e.getSize(),r=e.getResolution();return{bufferPixels:Math.round(t.width*t.height*r**2),height:t.height,resolution:r,width:t.width}}async resolveBackend(){if(this.options.backend)return this.options.backend;let{cubismWebGL:e}=await Promise.resolve().then(()=>(gr(),_n));return e}addPauseReason(e){if(this.pauseReasons.has(e))return;let t=this.pauseReasons.size===0;this.pauseReasons.add(e),t&&this.stage?.pause()}removePauseReason(e){!this.pauseReasons.delete(e)||this.pauseReasons.size>0||(this.onStageResume?.(),this.stage?.resume())}teardown(){this.abortController?.abort(),this.abortController=void 0,cancelAnimationFrame(this.resizeAnimationFrame),this.resizeAnimationFrame=0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.onStageResume=void 0,this.resizeObserver?.disconnect(),this.resizeObserver=void 0;for(let e of this.stageCleanup.splice(0).reverse())e();for(let e of[...this.features].reverse())e.detach();for(let e of this.models){this.releaseDebugOverlay(e);for(let t of e.features.splice(0).reverse())t.detach();e.handle.dispose()}this.models=[],this.stage?.dispose(),this.stage=void 0}async start(){if(this.disposed)throw new m("invalid-props","Cannot start a disposed Live2D instance.");jl(this.options),this.pauseReasons.delete("hidden"),this.pauseReasons.delete("offscreen");let e=this.options.resolution!==void 0?void 0:Vn(typeof this.options.quality=="object"?this.options.quality:void 0),t=new AbortController;this.abortController=t;let r=()=>t.abort(this.options.signal?.reason);this.options.signal?.aborted&&r(),this.options.signal?.addEventListener("abort",r,{once:!0}),this.stageCleanup.push(()=>{this.options.signal?.removeEventListener("abort",r)});try{if(this.updateState({error:void 0,loadingStage:"core",status:"loading"}),await Fn(this.options.coreUrl,{signal:t.signal}),t.signal.aborted)throw t.signal.reason;let i=this.backend??await this.resolveBackend();if(this.backend=i,t.signal.aborted)throw t.signal.reason;this.updateState({loadingStage:"stage"});let s=this.options.container.getBoundingClientRect();(s.width<1||s.height<1)&&console.warn("[live2d-web] The container has zero size, so the canvas will be 1x1 and nothing will be visible. Give the container a CSS width and height.");let n=Math.max(1,s.width),a=Math.max(1,s.height),l=this.options.resolution!==void 0?this.options.resolution:br({devicePixelRatio:window.devicePixelRatio,height:a,mobile:Br(n,a),width:n},e),o=i.createStage(this.options.container,{accessibility:this.accessibility,height:a,maxFps:this.options.maxFps,resolution:l,width:n});this.stage=o,this.pauseReasons.size>0&&o.pause(),this.stageCleanup.push(o.onError(p=>{this.report(je(p,"render-error"))}));let u=0,c=0,g=0;e&&this.stageCleanup.push(o.onFrame(p=>{if(u+=p,c++,p>e.longFrameMs&&g++,u<e.sampleWindowMs)return;let A=kn(o.getResolution(),c?g/c:0,e);A<o.getResolution()&&(o.setResolution(A),this.updateState({render:this.readRenderState(o)})),u=0,c=0,g=0}));let h=()=>{if(this.resizeAnimationFrame=0,this.disposed||this.stage!==o)return;let p=this.options.container.getBoundingClientRect(),A=Math.max(1,p.width),_=Math.max(1,p.height);if(!(Math.abs(A-n)<.5&&Math.abs(_-a)<.5)){if(n=A,a=_,e){let b=br({devicePixelRatio:window.devicePixelRatio,height:a,mobile:Br(n,a),width:n},e);b<o.getResolution()&&o.setResolution(b)}o.resize(n,a),this.applyFit(),this.updateState({render:this.readRenderState(o)})}},d=()=>{this.resizeAnimationFrame||(this.resizeAnimationFrame=requestAnimationFrame(h))};this.resizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(d),this.resizeObserver?.observe(this.options.container),this.onStageResume=()=>{u=0,c=0,g=0,d()};let f=()=>{document.hidden?this.addPauseReason("hidden"):this.removePauseReason("hidden")};if(document.addEventListener("visibilitychange",f),f(),this.stageCleanup.push(()=>{document.removeEventListener("visibilitychange",f)}),this.intersectionObserver=(this.options.pauseWhenOffscreen??!0)&&typeof IntersectionObserver<"u"?new IntersectionObserver(p=>{let A=p[p.length-1];A&&(A.isIntersecting?this.removePauseReason("offscreen"):this.addPauseReason("offscreen"))}):void 0,this.intersectionObserver?.observe(this.options.container),this.updateState({loadingStage:"model",render:this.readRenderState(o)}),this.options.src!==void 0){let p=await this.loadModel(i,o,this.options.src,t.signal);if(t.signal.aborted||this.stage!==o)throw p.dispose(),t.signal.reason;this.models.push({features:[],fit:this.fit,followPointer:this.options.followPointer??!1,handle:p}),this.applyFit();for(let A of this.features)A.attach(p)}{let p=this.options.container,A=b=>{if(this.stage!==o)return;let C=o.toWorld(b.clientX,b.clientY);for(let B of this.models)B.followPointer&&B.handle.focus(C.x,C.y)},_=()=>{if(this.stage!==o)return;let b=o.getSize();for(let C of this.models)C.followPointer&&C.handle.focus(b.width/2,b.height/2)};p.addEventListener("pointermove",A),p.addEventListener("pointerleave",_),this.stageCleanup.push(()=>{p.removeEventListener("pointermove",A),p.removeEventListener("pointerleave",_)})}this.debug&&this.models[0]&&await this.mountDebugOverlay(o,this.models[0]),this.updateState({error:void 0,loadingStage:void 0,render:this.readRenderState(o),status:"ready"})}catch(i){if(t.signal.aborted){if(this.disposed)return;throw i}let s=je(i,"adapter-error");throw this.teardown(),this.report(s),s}}async loadModel(e,t,r,i,s){let n=s?.retries??this.options.retries??2,a;for(let l=0;l<=n;l++)try{return await e.loadModel(t,r,{idleMotion:s?.idleMotion??this.options.idleMotion,resolveAsset:s?.resolveAsset??this.options.resolveAsset,signal:i})}catch(o){if(i.aborted)throw o;a=je(o,"model-load-failed");let u=a.details?.httpStatus;if(a.code==="invalid-props"||u!==void 0&&u>=400&&u<500||l===n)break;await ql(l===0?250:500,i)}throw a||new m("model-load-failed","The model could not be loaded.")}requireModel(){if(this.disposed)throw new m("invalid-props","The Live2D instance has been disposed.");if(!this.model)throw new m("model-load-failed","The Live2D model is not ready.");return this.model}async mountDebugOverlay(e,t){let{mountLive2DDebugOverlay:r}=await Promise.resolve().then(()=>(Mn(),Sn));if(this.disposed||this.stage!==e||!this.models.includes(t)||this.debugWanted!==t||this.debugOverlay?.owner===t)return;this.releaseDebugOverlay();let i=r({container:this.options.container,onChange:s=>(t.onFitChange??this.options.onFitChange)?.(s),target:{getFit:()=>typeof t.fit=="object"?{...t.fit}:t.fit,setFit:s=>{t.fit=s,this.applyFit()}}});this.debugOverlay={dispose:i.dispose,owner:t,refresh:i.refresh},this.stageCleanup.push(()=>this.releaseDebugOverlay(t))}releaseDebugOverlay(e){let t=this.debugOverlay;!t||e!==void 0&&t.owner!==e||(this.debugOverlay=void 0,t.dispose())}setDebug(e,t){if(typeof e!="boolean")throw new m("invalid-props","debug must be a boolean.");let r=t??this.models[0];if(!e){this.debugWanted===r&&(this.debugWanted=void 0),this.releaseDebugOverlay(r),t||(this.debug=!1);return}if(t||(this.debug=!0),!this.stage||!r)return;let i=this.debugWanted;this.debugWanted=r,i&&i!==r&&console.warn("[live2d-web] The placement overlay moved to the model that asked for it last. It covers the canvas to take the pointer, so only one model can have it at a time."),this.mountDebugOverlay(this.stage,r)}applyFit(){let e=this.stage;if(!e)return;let t=e.getSize();for(let r of this.models)r.handle.setTransform(On(t,r.handle.getIntrinsicSize(),r.fit))}motion(e,t,r){return this.requireModel().motion(e,t,r)}async playMotion(e,t,r){let i=this.requireModel();if(!i.playMotion)throw new m("adapter-error","The selected Live2D backend does not support detailed motion playback.");return i.playMotion(e,t,r)}async sequence(e){let t=this.requireModel();if(!t.playMotion)throw new m("adapter-error","The selected Live2D backend does not support motion sequences.");return Rn(e,t.getModelInfo(),(r,i,s)=>t.playMotion(r,i,s))}isMotionPlaying(){return this.model?.isMotionPlaying()??!1}expression(e,t){return this.requireModel().expression(e,t)}clearExpression(){this.requireModel().clearExpression()}getModelInfo(){return this.requireModel().getModelInfo()}focus(e,t){this.requireModel().focus(e,t)}focusAt(e,t){let r=this.stage;if(!r||this.models.length===0)return;let i=r.toWorld(e,t);for(let s of this.models)s.handle.focus(i.x,i.y)}hitTest(e,t){let r=this.stage;if(!r)return[];let i=r.toWorld(e,t);for(let s=this.models.length-1;s>=0;s--){let n=this.models[s].handle.hitTest(i.x,i.y);if(n.length>0)return n}return[]}getParameter(e){return this.requireModel().getParameter(e)}setParameter(e,t){this.requireModel().setParameter(e,t)}clearParameter(e){this.requireModel().clearParameter(e)}setFit(e){this.fit=e,this.models[0]&&(this.models[0].fit=e),this.applyFit(),this.debugOverlay?.refresh()}async addModel(e){if(this.disposed)throw new m("invalid-props","The Live2D instance has been disposed.");if(!e||typeof e.src!="string"||e.src==="")throw new m("invalid-props","addModel requires a src.");await this.whenStageReady();let t=this.stage,r=this.backend;if(!t||!r)throw new m("invalid-props","The Live2D canvas is not ready. Await createLive2D() before adding a model.");let i=new AbortController,s=()=>i.abort(e.signal?.reason);e.signal?.addEventListener("abort",s,{once:!0});let n;try{n=await this.loadModel(r,t,e.src,i.signal,e)}finally{e.signal?.removeEventListener("abort",s)}if(this.disposed||this.stage!==t)throw n.dispose(),new m("invalid-props","The Live2D canvas went away while the model loaded.");let a={features:[],fit:e.fit??"upper-body",followPointer:e.followPointer??!1,handle:n,onFitChange:e.onFitChange};return this.models.push(a),this.applyFit(),this.createModelHandle(a)}whenStageReady(){return this.stage&&this.backend?Promise.resolve():this.state.status==="error"?Promise.reject(this.state.error??new m("adapter-error","The Live2D canvas failed to start.")):new Promise((e,t)=>{let r=this.subscribe(()=>{if(this.disposed){r(),t(new m("invalid-props","The Live2D instance has been disposed."));return}if(this.stage&&this.backend){r(),e();return}this.state.status==="error"&&(r(),t(this.state.error??new m("adapter-error","The Live2D canvas failed to start.")))})})}createModelHandle(e){let t=()=>{if(!this.models.includes(e))throw new m("invalid-props","This Live2D model has been disposed.");return e.handle};return Object.freeze({addLipSync:r=>this.addLipSync(r,e),addParameterDriver:(r,i)=>this.addParameterDriver(r,i,e),clearExpression:()=>t().clearExpression(),clearParameter:r=>t().clearParameter(r),dispose:()=>{let r=this.models.indexOf(e);if(!(r<0)){this.models.splice(r,1),this.debugWanted===e&&(this.debugWanted=void 0),this.releaseDebugOverlay(e);for(let i of e.features.splice(0))i.detach();e.handle.dispose()}},expression:(r,i)=>t().expression(r,i),focus:(r,i)=>t().focus(r,i),focusAt:(r,i)=>{let s=this.stage;if(!s)return;let n=s.toWorld(r,i);t().focus(n.x,n.y)},getFit:()=>typeof e.fit=="object"?{...e.fit}:e.fit,getModelInfo:()=>t().getModelInfo(),getParameter:r=>t().getParameter(r),hitTest:(r,i)=>{let s=this.stage;if(!s)return[];let n=s.toWorld(r,i);return t().hitTest(n.x,n.y)},isMotionPlaying:()=>t().isMotionPlaying(),motion:(r,i,s)=>t().motion(r,i,s),playMotion:async(r,i,s)=>{let n=t();if(!n.playMotion)throw new m("adapter-error","The selected Live2D backend does not support detailed motion playback.");return n.playMotion(r,i,s)},sequence:async r=>{let i=t();if(!i.playMotion)throw new m("adapter-error","The selected Live2D backend does not support motion sequences.");return Rn(r,i.getModelInfo(),(s,n,a)=>i.playMotion(s,n,a))},setDebug:r=>this.setDebug(r,e),setFit:r=>{e.fit=r,this.applyFit()},setParameter:(r,i)=>t().setParameter(r,i)})}getFit(){return typeof this.fit=="object"?{...this.fit}:this.fit}setAccessibility(e){Qn(e),this.accessibility=e,this.stage?.setAccessibility?.(e)}addFeature(e,t){let r=t?.features??this.features;r.push(e);let i=t?.handle??this.model;return i&&e.attach(i),Tn(()=>{e.detach();let s=r.indexOf(e);s>=0&&r.splice(s,1)})}addParameterDriver(e,t,r){if(!t||typeof t.getValue!="function")throw new m("invalid-props","A parameter driver must provide getValue().");return this.addFeature(new Ln(i=>{let s=()=>{i.setParameter(e,t.getValue()),i.clearParameter(e)},n=(t.phase==="before-physics"&&i.onBeforePhysicsUpdate?i.onBeforePhysicsUpdate:i.onAfterMotionUpdate).call(i,s);return()=>{n(),i.clearParameter(e)}},i=>this.report(je(i,"render-error"))),r)}addLipSync(e,t){let r=n=>{let a=je(n,"lipsync-error");e.onError?.(a),!e.onError&&this.options.onError?this.options.onError?.(a):!e.onError&&!this.options.onError&&console.error("[live2d-web] lip sync disabled:",a)},i=e.parameterId??"ParamMouthOpenY",s=new Ln(async n=>{let a=new Tl,l="source"in e?await zl(e.source,e.profile):void 0,o="driver"in e?e.driver:{getMouthOpen:l.getMouthOpen,isSpeaking:e.isSpeaking},u=!1,c=n.onAfterMotionUpdate(g=>{if(!u)try{let h=o.isSpeaking(),d=a.update({deltaMs:g,motionValue:n.getParameter(i),mouthOpen:h?o.getMouthOpen():0,speaking:h});d!==null&&(n.setParameter(i,d),n.clearParameter(i))}catch(h){u=!0,r(h)}});return()=>{c(),n.clearParameter(i),l?.dispose()}},r);return this.addFeature(s,t)}pause(){this.addPauseReason("user")}resume(){this.removePauseReason("user")}async retry(){if(this.disposed)throw new m("invalid-props","Cannot retry a disposed Live2D instance.");this.teardown(),await this.start()}dispose(){this.disposed||(this.disposed=!0,this.teardown(),this.features=[],this.updateState({error:void 0,loadingStage:void 0,render:void 0,status:"disposed"}),this.listeners.clear())}};async function Sr(e){let t=new Zl(e);try{return await t.start(),t}catch(r){throw t.dispose(),r}}gr();function Un(e,t){let r=0,i=0;for(let{Segments:s}of e.Curves){if(s.length<2)throw new Error("Missing motion curve starting point");s.length===2&&s.push(0,e.Meta.Duration,s[1]),r++;for(let n=2;n<s.length;){let a=s[n];if(![0,1,2,3].includes(a))throw new Error("Invalid motion segment type: "+a);let l=a===1?3:1;if(n+=1+2*l,n>s.length)throw new Error("Incomplete motion curve");r+=l,i++}}return e.Meta.CurveCount=e.Curves.length,e.Meta.TotalSegmentCount=i,e.Meta.TotalPointCount=r,t&&(e.Meta.Loop=!1),e}async function Nn(e,t){let r=await fetch(e,{signal:t});if(!r.ok)throw new Error("HTTP "+r.status+" loading "+e);return r.json()}async function Gn(e,t,r){let[i,s]=await Promise.all([Nn(e,r),t&&Nn(t.url,r).catch(h=>{if(r.aborted)throw h;console.warn("[Live2D] Dialogue data unavailable",h)})]),n=[],a=i.FileReferences.Motions??{},l=new Set(Object.values(a).flat().map(h=>h.File)),o=new Map;for(let h of l){let d=h.slice(h.lastIndexOf("/")+1);o.set(d,o.has(d)?void 0:h)}for(let[h,d]of Object.entries(a))d.forEach((f,p)=>{if(s&&t)for(let[A,_]of Object.entries(s.motionData)){let b=_.motion_name.replace(/\.mtn$/i,".motion3.json");if((l.has(b)?b:o.get(b))!==f.File||!!_.is_hurt!=(s.variant==="destroy")||!_.touch_area||_.touch_area==="0")continue;let B=s.voiceData[A],I=B?.char_code?.toUpperCase(),y=B?.voice_key?.toUpperCase();n.push({file:f.File,group:h,index:p,area:_.touch_area.toLowerCase(),weight:_.probability,delay:Math.max(0,_.delay||0),caption:t.captions?.[I+"|"+y]||B?.caption,sound:I&&y?t.audio.get("AUDIO/"+I+"/"+I+"_"+y+"_JP.OGG"):void 0})}else/^tap_?/i.test(h)&&n.push({file:f.File,group:h,index:p,area:h.replace(/^tap_?/i,"").toLowerCase(),weight:1,delay:0,sound:f.Sound?new URL(f.Sound,e).href:void 0})});let u=decodeURIComponent(new URL(e).pathname.slice(1)),c=new Set(t?n.map(h=>new URL(h.file,e).href):[]);async function g(h,d){if(h===u)return new Blob([JSON.stringify(i)],{type:"application/json"});let f=new URL("/"+h.split("/").map(encodeURIComponent).join("/"),e),p=await fetch(f,{signal:d??r});if(!p.ok)throw new Error("HTTP "+p.status+" loading "+f);if(!f.pathname.toLowerCase().endsWith(".motion3.json"))return p.blob();let A=Un(await p.json(),c.has(f.href));return new Blob([JSON.stringify(A)],{type:"application/json"})}return{actions:n,src:u,resolveAsset:g}}function Xn(e,t,r,i){let s,n;function a(){s?.abort(),s=void 0}i.addEventListener("abort",()=>{a(),n?.close()},{once:!0});async function l(u,c){try{n??=new AudioContext,n.state!=="running"&&n.resume().catch(()=>{});let g=await fetch(u,{signal:c});if(!g.ok)throw Error("HTTP "+g.status);let h=await n.decodeAudioData(await g.arrayBuffer());if(!c.aborted&&n.state==="running"){let d=n.createBufferSource();return d.buffer=h,d}}catch(g){c.aborted||console.warn("[Live2D] Voice unavailable",u,g)}}async function o(u){a();let c=s=new AbortController,g=c.signal,h={},d,f=!1,p=0,A,_=new Promise(D=>{A=D}),b=u.sound?l(u.sound,g).then(D=>{d=D}):Promise.resolve();function C(D){f&&(f=!1,window.dispatchEvent(new CustomEvent("live2d:dialogue-end",{detail:{playback:h,interrupted:D}})))}g.addEventListener("abort",()=>{cancelAnimationFrame(p),d&&(d.onended&&d.stop(),d.onended=null,d.disconnect()),C(!0),A()},{once:!0});let B=()=>d?d.context.currentTime:performance.now()/1e3,I,y=0;function w(){if(g.aborted||f)return;if(B()<y){p=requestAnimationFrame(w);return}let D=u.caption?.trim();f=!0;let O=D?new CustomEvent("live2d:dialogue",{detail:D}):new CustomEvent("live2d:preset");window.dispatchEvent(Object.assign(O,{playback:h})),d||A()}function L(D){let O=B();I===void 0&&(y=O+u.delay/1e3,d&&(d.connect(d.context.destination),d.onended=A,d.start(y)),w());let z=I===void 0?0:Math.max(0,O-I);return I=O,d?z:D}try{(await t.playMotion(u.group,u.index,{sync:{ready:b,signal:g,update:L}})).status==="completed"&&(await _,C(!1))}catch(D){if(!g.aborted)throw D}finally{c.abort(),s===c&&(s=void 0)}}return e.addEventListener("click",u=>{s&&(u.live2dHandlesCaption=!0);let c=t.hitTest(u.clientX,u.clientY);for(let g of c){let h=r.filter(d=>d.area===g.toLowerCase()&&d.weight>0);if(h.length){let d=Math.random()*h.reduce((p,A)=>p+A.weight,0),f=h.find(p=>(d-=p.weight)<0)??h[h.length-1];u.live2dHandlesCaption=!0,o(f).catch(p=>{i.aborted||console.error("[Live2D]",p)});break}if(g.toLowerCase()==="head"&&t.getModelInfo().expressions.length){t.expression().catch(d=>{i.aborted||console.error("[Live2D]",d)});break}}},{signal:i}),document.addEventListener("visibilitychange",()=>{document.hidden&&a()},{signal:i}),a}async function qh(e,t,r,i,s,n,a){if(i.throwIfAborted(),!(e instanceof HTMLCanvasElement))throw new Error("Missing Live2D canvas");let l=document.createElement("div");l.style.cssText="display:inline-block;position:relative;vertical-align:top;line-height:0";let o=document.createElement("div");o.className="waifu-model-stage",o.style.cssText="position:absolute;inset:0;cursor:grab";let u=e.style.visibility;e.before(l),l.append(e,o),e.style.visibility="hidden";let c;function g(){c?.dispose(),l.contains(e)&&(l.replaceWith(e),e.style.visibility=u),i.removeEventListener("abort",g)}i.addEventListener("abort",g,{once:!0});try{let{actions:h,src:d,resolveAsset:f}=await Gn(t,s,i);i.throwIfAborted();let p,A,_=(n||a)&&{...Je,createStage(y,w){return p=Je.createStage(y,w)},async loadModel(y,w,L){return A=await Je.loadModel(y,w,L)}},b=y=>({scale:y.scale/2,offsetX:y.x,offsetY:y.y-.5,units:"stage"});c=await Sr({container:o,src:d,resolveAsset:f,coreUrl:r||Ir,backend:_,fit:n?b(n.initial):"full",followPointer:!0,signal:i,onError:y=>console.error("[Live2D]",y)}),i.throwIfAborted();let C=c,B=o.querySelector("canvas");if(p&&B){let y=p.onFrame(()=>queueMicrotask(()=>{if(!i.aborted){if(n){let{width:w,height:L}=p.getSize(),D=n.measure(B,(O,z)=>A.hitTest(O*w,z*L),O=>C.setFit(b(O)));D&&(n=void 0,C.setFit(b(D)));return}y(),a?.(B)}}))}let I=Xn(o,C,h,i);return{pause:()=>{I(),C.pause()},resume:()=>C.resume(),capture(){requestAnimationFrame(()=>{let y=o.querySelector("canvas");if(!y||i.aborted)return;let w=document.createElement("a");w.download="photo.png",w.href=y.toDataURL("image/png"),w.click()})}}}catch(h){throw g(),h}}export{qh as mountModern};
|